Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/drzeus/mmc
authorLinus Torvalds <torvalds@woody.linux-foundation.org>
Sun, 11 Feb 2007 19:39:00 +0000 (11:39 -0800)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Sun, 11 Feb 2007 19:39:00 +0000 (11:39 -0800)
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/drzeus/mmc:
  tifm_sd: treat "status error" as normal command completion
  mmc: wbsd: Remove stray kunmap_atomic()
  mmc: sdhci: Stop asking for mail
  mmc: sdhci: Remove driver version
  mmc: wbsd: Remove driver version

1759 files changed:
CREDITS
Documentation/ABI/testing/debugfs-pktcdvd
Documentation/ABI/testing/sysfs-class-pktcdvd
Documentation/DocBook/gadget.tmpl
Documentation/DocBook/kernel-api.tmpl
Documentation/DocBook/stylesheet.xsl
Documentation/DocBook/usb.tmpl
Documentation/auxdisplay/cfag12864b [new file with mode: 0644]
Documentation/auxdisplay/cfag12864b-example.c [new file with mode: 0644]
Documentation/auxdisplay/ks0108 [new file with mode: 0644]
Documentation/cdrom/packet-writing.txt
Documentation/crypto/api-intro.txt
Documentation/driver-model/devres.txt [new file with mode: 0644]
Documentation/feature-removal-schedule.txt
Documentation/filesystems/relay.txt
Documentation/ioctl-number.txt
Documentation/kernel-doc-nano-HOWTO.txt
Documentation/kernel-parameters.txt
Documentation/local_ops.txt [new file with mode: 0644]
Documentation/rbtree.txt [new file with mode: 0644]
Documentation/rtc.txt
Documentation/sound/alsa/ALSA-Configuration.txt
Documentation/sound/alsa/DocBook/alsa-driver-api.tmpl
Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl
Documentation/sound/alsa/hda_codec.txt
Documentation/sound/alsa/soc/DAI.txt [new file with mode: 0644]
Documentation/sound/alsa/soc/clocking.txt [new file with mode: 0644]
Documentation/sound/alsa/soc/codec.txt [new file with mode: 0644]
Documentation/sound/alsa/soc/dapm.txt [new file with mode: 0644]
Documentation/sound/alsa/soc/machine.txt [new file with mode: 0644]
Documentation/sound/alsa/soc/overview.txt [new file with mode: 0644]
Documentation/sound/alsa/soc/platform.txt [new file with mode: 0644]
Documentation/sound/alsa/soc/pops_clicks.txt [new file with mode: 0644]
Documentation/sysrq.txt
MAINTAINERS
arch/alpha/Kconfig
arch/alpha/kernel/time.c
arch/alpha/kernel/vmlinux.lds.S
arch/arm/Kconfig
arch/arm/common/sharpsl_pm.c
arch/arm/kernel/Makefile
arch/arm/kernel/time.c
arch/arm/kernel/vmlinux.lds.S
arch/arm/mach-pxa/corgi_pm.c
arch/arm/mach-pxa/sharpsl_pm.c
arch/arm/mach-pxa/spitz_pm.c
arch/arm26/Kconfig
arch/arm26/kernel/ecard.c
arch/arm26/kernel/time.c
arch/arm26/kernel/vmlinux-arm26-xip.lds.in
arch/arm26/kernel/vmlinux-arm26.lds.in
arch/avr32/boards/atstk1000/Makefile
arch/avr32/boards/atstk1000/atstk1002.c
arch/avr32/boards/atstk1000/spi.c [deleted file]
arch/avr32/kernel/cpu.c
arch/avr32/kernel/irq.c
arch/avr32/kernel/setup.c
arch/avr32/kernel/time.c
arch/avr32/kernel/vmlinux.lds.c
arch/avr32/lib/libgcc.h [deleted file]
arch/avr32/lib/longlong.h [deleted file]
arch/avr32/mach-at32ap/Makefile
arch/avr32/mach-at32ap/at32ap7000.c
arch/avr32/mach-at32ap/extint.c
arch/avr32/mach-at32ap/pio.c
arch/avr32/mm/cache.c
arch/cris/Kconfig
arch/cris/arch-v10/drivers/axisflashmap.c
arch/cris/arch-v10/kernel/time.c
arch/cris/arch-v10/mm/tlb.c
arch/cris/arch-v10/vmlinux.lds.S
arch/cris/arch-v32/mm/tlb.c
arch/cris/arch-v32/vmlinux.lds.S
arch/cris/kernel/time.c
arch/cris/mm/tlb.c
arch/frv/Kconfig
arch/frv/kernel/vmlinux.lds.S
arch/h8300/Kconfig
arch/h8300/kernel/Makefile
arch/h8300/kernel/time.c
arch/h8300/kernel/vmlinux.lds.S
arch/i386/Kconfig
arch/i386/kernel/hpet.c
arch/i386/kernel/io_apic.c
arch/i386/kernel/sysenter.c
arch/i386/kernel/vmlinux.lds.S
arch/i386/mm/fault.c
arch/i386/mm/highmem.c
arch/i386/mm/pageattr.c
arch/ia64/Kconfig
arch/ia64/ia32/binfmt_elf32.c
arch/ia64/ia32/ia32_entry.S
arch/ia64/ia32/sys_ia32.c
arch/ia64/kernel/crash.c
arch/ia64/kernel/perfmon.c
arch/ia64/kernel/smp.c
arch/ia64/kernel/traps.c
arch/ia64/kernel/vmlinux.lds.S
arch/ia64/mm/contig.c
arch/ia64/mm/discontig.c
arch/ia64/mm/init.c
arch/ia64/sn/kernel/sn2/sn_proc_fs.c
arch/m32r/Kconfig
arch/m32r/Makefile
arch/m32r/defconfig
arch/m32r/kernel/head.S
arch/m32r/kernel/process.c
arch/m32r/kernel/signal.c
arch/m32r/kernel/time.c
arch/m32r/kernel/vmlinux.lds.S
arch/m32r/lib/ashxdi3.S
arch/m32r/lib/checksum.S
arch/m32r/lib/delay.c
arch/m32r/lib/memcpy.S
arch/m32r/lib/memset.S
arch/m32r/lib/strlen.S
arch/m32r/m32104ut/defconfig.m32104ut
arch/m32r/m32700ut/defconfig.m32700ut.smp
arch/m32r/m32700ut/defconfig.m32700ut.up
arch/m32r/mappi/defconfig.nommu
arch/m32r/mappi/defconfig.smp
arch/m32r/mappi/defconfig.up
arch/m32r/mappi2/defconfig.opsp [new file with mode: 0644]
arch/m32r/mappi2/defconfig.vdec2
arch/m32r/mappi3/defconfig.smp
arch/m32r/mm/fault-nommu.c
arch/m32r/mm/fault.c
arch/m32r/mm/mmu.S
arch/m32r/oaks32r/defconfig.nommu
arch/m32r/opsput/defconfig.opsput
arch/m68k/Kconfig
arch/m68k/kernel/Makefile
arch/m68k/kernel/ptrace.c
arch/m68k/kernel/time.c
arch/m68k/kernel/traps.c
arch/m68k/kernel/vmlinux-std.lds
arch/m68k/kernel/vmlinux-sun3.lds
arch/m68knommu/Kconfig
arch/m68knommu/kernel/ptrace.c
arch/m68knommu/kernel/time.c
arch/m68knommu/kernel/traps.c
arch/m68knommu/kernel/vmlinux.lds.S
arch/m68knommu/platform/5206/config.c
arch/m68knommu/platform/5206e/config.c
arch/m68knommu/platform/520x/config.c
arch/m68knommu/platform/523x/config.c
arch/m68knommu/platform/5249/config.c
arch/m68knommu/platform/5272/config.c
arch/m68knommu/platform/527x/config.c
arch/m68knommu/platform/528x/config.c
arch/m68knommu/platform/5307/config.c
arch/m68knommu/platform/5307/pit.c
arch/m68knommu/platform/5307/timers.c
arch/m68knommu/platform/532x/config.c
arch/m68knommu/platform/5407/config.c
arch/m68knommu/platform/68328/config.c
arch/mips/Kconfig
arch/mips/dec/Makefile
arch/mips/dec/prom/identify.c
arch/mips/dec/setup.c
arch/mips/dec/tc.c [new file with mode: 0644]
arch/mips/kernel/Makefile
arch/mips/kernel/apm.c [deleted file]
arch/mips/kernel/linux32.c
arch/mips/kernel/scall64-n32.S
arch/mips/kernel/scall64-o32.S
arch/mips/kernel/time.c
arch/mips/kernel/vmlinux.lds.S
arch/mips/mm/cache.c
arch/mips/philips/pnx8550/common/proc.c
arch/parisc/Kconfig
arch/parisc/kernel/sys_parisc32.c
arch/parisc/kernel/syscall_table.S
arch/parisc/kernel/time.c
arch/parisc/kernel/vmlinux.lds.S
arch/parisc/mm/init.c
arch/powerpc/Kconfig
arch/powerpc/kernel/proc_ppc64.c
arch/powerpc/kernel/rtas_flash.c
arch/powerpc/kernel/sys_ppc32.c
arch/powerpc/kernel/vdso.c
arch/powerpc/kernel/vmlinux.lds.S
arch/powerpc/platforms/cell/iommu.c
arch/powerpc/platforms/celleb/pci.c
arch/powerpc/platforms/celleb/scc_epci.c
arch/powerpc/platforms/chrp/setup.c
arch/powerpc/platforms/iseries/mf.c
arch/powerpc/platforms/ps3/interrupt.c
arch/powerpc/platforms/ps3/system-bus.c
arch/powerpc/platforms/pseries/reconfig.c
arch/powerpc/xmon/spu-dis.c
arch/ppc/Kconfig
arch/ppc/kernel/vmlinux.lds.S
arch/s390/Kconfig
arch/s390/defconfig
arch/s390/kernel/compat_linux.c
arch/s390/kernel/compat_wrapper.S
arch/s390/kernel/syscalls.S
arch/s390/kernel/vmlinux.lds.S
arch/s390/mm/Makefile
arch/s390/mm/fault.c
arch/s390/mm/ioremap.c [deleted file]
arch/sh/Kconfig
arch/sh/boards/hp6xx/hp6xx_apm.c
arch/sh/kernel/Makefile
arch/sh/kernel/apm.c [deleted file]
arch/sh/kernel/time.c
arch/sh/kernel/vmlinux.lds.S
arch/sh/kernel/vsyscall/vsyscall.c
arch/sh/mm/init.c
arch/sh64/Kconfig
arch/sh64/kernel/time.c
arch/sh64/kernel/vmlinux.lds.S
arch/sh64/mm/init.c
arch/sparc/Kconfig
arch/sparc/kernel/Makefile
arch/sparc/kernel/sunos_ioctl.c
arch/sparc/kernel/time.c
arch/sparc/kernel/vmlinux.lds.S
arch/sparc64/Kconfig
arch/sparc64/defconfig
arch/sparc64/kernel/irq.c
arch/sparc64/kernel/pci.c
arch/sparc64/kernel/pci_common.c
arch/sparc64/kernel/pci_sun4v.c
arch/sparc64/kernel/pci_sun4v.h
arch/sparc64/kernel/pci_sun4v_asm.S
arch/sparc64/kernel/sunos_ioctl32.c
arch/sparc64/kernel/sys_sparc32.c
arch/sparc64/kernel/systbls.S
arch/sparc64/kernel/vmlinux.lds.S
arch/sparc64/mm/init.c
arch/um/Kconfig
arch/um/drivers/chan_kern.c
arch/um/drivers/harddog_kern.c
arch/um/drivers/harddog_user.c
arch/um/drivers/hostaudio_kern.c
arch/um/drivers/line.c
arch/um/drivers/mconsole_kern.c
arch/um/drivers/mconsole_user.c
arch/um/drivers/net_kern.c
arch/um/drivers/port_kern.c
arch/um/drivers/port_user.c
arch/um/drivers/random.c
arch/um/drivers/ssl.c
arch/um/drivers/stdio_console.c
arch/um/drivers/ubd_kern.c
arch/um/include/chan_kern.h
arch/um/include/chan_user.h
arch/um/include/kern_util.h
arch/um/include/line.h
arch/um/include/mconsole_kern.h
arch/um/include/net_kern.h
arch/um/include/os.h
arch/um/include/sigio.h
arch/um/include/tempfile.h
arch/um/include/umid.h [deleted file]
arch/um/kernel/Makefile
arch/um/kernel/exec.c
arch/um/kernel/irq.c
arch/um/kernel/mem.c
arch/um/kernel/physmem.c
arch/um/kernel/ptrace.c
arch/um/kernel/resource.c [deleted file]
arch/um/kernel/sigio.c
arch/um/kernel/skas/mem.c
arch/um/kernel/syscall.c
arch/um/kernel/sysrq.c
arch/um/kernel/time.c
arch/um/kernel/trap.c
arch/um/kernel/tt/gdb.c
arch/um/kernel/tt/gdb_kern.c
arch/um/kernel/um_arch.c
arch/um/kernel/umid.c
arch/um/os-Linux/aio.c
arch/um/os-Linux/elf_aux.c
arch/um/os-Linux/file.c
arch/um/os-Linux/irq.c
arch/um/os-Linux/mem.c
arch/um/os-Linux/start_up.c
arch/um/os-Linux/sys-i386/registers.c
arch/um/os-Linux/sys-x86_64/Makefile
arch/um/os-Linux/sys-x86_64/prctl.c [new file with mode: 0644]
arch/um/os-Linux/sys-x86_64/registers.c
arch/um/os-Linux/umid.c
arch/um/sys-x86_64/ptrace.c
arch/um/sys-x86_64/syscalls.c
arch/um/sys-x86_64/tls.c
arch/v850/Kconfig
arch/v850/kernel/anna.c
arch/v850/kernel/as85ep1.c
arch/v850/kernel/fpga85e2c.c
arch/v850/kernel/gbus_int.c
arch/v850/kernel/ma.c
arch/v850/kernel/me2.c
arch/v850/kernel/rte_cb.c
arch/v850/kernel/rte_mb_a_pci.c
arch/v850/kernel/rte_me2_cb.c
arch/v850/kernel/teg.c
arch/v850/kernel/time.c
arch/v850/kernel/vmlinux.lds.S
arch/x86_64/Kconfig
arch/x86_64/ia32/ia32_binfmt.c
arch/x86_64/ia32/ia32entry.S
arch/x86_64/ia32/sys_ia32.c
arch/x86_64/ia32/syscall32.c
arch/x86_64/kernel/mce_amd.c
arch/x86_64/kernel/vmlinux.lds.S
arch/x86_64/mm/fault.c
arch/xtensa/Kconfig
arch/xtensa/kernel/time.c
arch/xtensa/kernel/vmlinux.lds.S
block/blktrace.c
block/ioctl.c
block/ll_rw_blk.c
crypto/Kconfig
crypto/Makefile
crypto/algapi.c
crypto/api.c
crypto/blkcipher.c
crypto/camellia.c [new file with mode: 0644]
crypto/cbc.c
crypto/cipher.c
crypto/compress.c
crypto/digest.c
crypto/ecb.c
crypto/fcrypt.c [new file with mode: 0644]
crypto/hash.c
crypto/hmac.c
crypto/internal.h
crypto/lrw.c
crypto/pcbc.c [new file with mode: 0644]
crypto/tcrypt.c
crypto/tcrypt.h
crypto/xcbc.c
drivers/Kconfig
drivers/Makefile
drivers/acpi/bay.c
drivers/ata/Kconfig
drivers/ata/Makefile
drivers/ata/ahci.c
drivers/ata/ata_generic.c
drivers/ata/ata_piix.c
drivers/ata/libata-core.c
drivers/ata/libata-eh.c
drivers/ata/libata-scsi.c
drivers/ata/libata-sff.c
drivers/ata/libata.h
drivers/ata/pata_ali.c
drivers/ata/pata_amd.c
drivers/ata/pata_artop.c
drivers/ata/pata_atiixp.c
drivers/ata/pata_cmd64x.c
drivers/ata/pata_cs5520.c
drivers/ata/pata_cs5530.c
drivers/ata/pata_cs5535.c
drivers/ata/pata_cypress.c
drivers/ata/pata_efar.c
drivers/ata/pata_hpt366.c
drivers/ata/pata_hpt37x.c
drivers/ata/pata_hpt3x2n.c
drivers/ata/pata_hpt3x3.c
drivers/ata/pata_isapnp.c
drivers/ata/pata_it8213.c [new file with mode: 0644]
drivers/ata/pata_it821x.c
drivers/ata/pata_ixp4xx_cf.c
drivers/ata/pata_jmicron.c
drivers/ata/pata_legacy.c
drivers/ata/pata_marvell.c
drivers/ata/pata_mpc52xx.c [new file with mode: 0644]
drivers/ata/pata_mpiix.c
drivers/ata/pata_netcell.c
drivers/ata/pata_ns87410.c
drivers/ata/pata_oldpiix.c
drivers/ata/pata_opti.c
drivers/ata/pata_optidma.c
drivers/ata/pata_pcmcia.c
drivers/ata/pata_pdc2027x.c
drivers/ata/pata_pdc202xx_old.c
drivers/ata/pata_platform.c
drivers/ata/pata_qdi.c
drivers/ata/pata_radisys.c
drivers/ata/pata_rz1000.c
drivers/ata/pata_sc1200.c
drivers/ata/pata_serverworks.c
drivers/ata/pata_sil680.c
drivers/ata/pata_sis.c
drivers/ata/pata_sl82c105.c
drivers/ata/pata_triflex.c
drivers/ata/pata_via.c
drivers/ata/pata_winbond.c
drivers/ata/pdc_adma.c
drivers/ata/sata_inic162x.c [new file with mode: 0644]
drivers/ata/sata_mv.c
drivers/ata/sata_nv.c
drivers/ata/sata_promise.c
drivers/ata/sata_qstor.c
drivers/ata/sata_sil.c
drivers/ata/sata_sil24.c
drivers/ata/sata_sis.c
drivers/ata/sata_svw.c
drivers/ata/sata_sx4.c
drivers/ata/sata_uli.c
drivers/ata/sata_via.c
drivers/ata/sata_vsc.c
drivers/atm/eni.c
drivers/auxdisplay/Kconfig [new file with mode: 0644]
drivers/auxdisplay/Makefile [new file with mode: 0644]
drivers/auxdisplay/cfag12864b.c [new file with mode: 0644]
drivers/auxdisplay/cfag12864bfb.c [new file with mode: 0644]
drivers/auxdisplay/ks0108.c [new file with mode: 0644]
drivers/base/Kconfig
drivers/base/Makefile
drivers/base/base.h
drivers/base/core.c
drivers/base/dd.c
drivers/base/devres.c [new file with mode: 0644]
drivers/base/dma-mapping.c [new file with mode: 0644]
drivers/base/dmapool.c
drivers/base/node.c
drivers/block/DAC960.c
drivers/block/DAC960.h
drivers/block/Kconfig
drivers/block/paride/Kconfig
drivers/block/pktcdvd.c
drivers/char/Kconfig
drivers/char/Makefile
drivers/char/amiserial.c
drivers/char/apm-emulation.c [moved from arch/arm/kernel/apm.c with 99% similarity]
drivers/char/cyclades.c
drivers/char/epca.c
drivers/char/generic_serial.c
drivers/char/ip2/i2lib.c
drivers/char/ipmi/ipmi_msghandler.c
drivers/char/isicom.c
drivers/char/istallion.c
drivers/char/keyboard.c
drivers/char/moxa.c
drivers/char/mxser.c
drivers/char/mxser.h
drivers/char/mxser_new.c
drivers/char/mxser_new.h
drivers/char/n_r3964.c
drivers/char/pcmcia/synclink_cs.c
drivers/char/raw.c
drivers/char/rio/riointr.c
drivers/char/riscom8.c
drivers/char/rocket.c
drivers/char/serial167.c
drivers/char/specialix.c
drivers/char/synclink.c
drivers/char/synclink_gt.c
drivers/char/synclinkmp.c
drivers/char/sysrq.c
drivers/char/toshiba.c
drivers/char/tty_io.c
drivers/char/tty_ioctl.c
drivers/char/vt.c
drivers/char/vt_ioctl.c
drivers/char/watchdog/machzwd.c
drivers/crypto/geode-aes.c
drivers/firmware/edd.c
drivers/hwmon/ams/ams-input.c
drivers/ide/ide-proc.c
drivers/ieee1394/.gitignore [deleted file]
drivers/ieee1394/Kconfig
drivers/ieee1394/Makefile
drivers/ieee1394/csr1212.c
drivers/ieee1394/dv1394.c
drivers/ieee1394/hosts.c
drivers/ieee1394/hosts.h
drivers/ieee1394/ieee1394_core.c
drivers/ieee1394/nodemgr.c
drivers/ieee1394/nodemgr.h
drivers/ieee1394/ohci1394.c
drivers/ieee1394/oui.db [deleted file]
drivers/ieee1394/oui2c.sh [deleted file]
drivers/ieee1394/raw1394.c
drivers/ieee1394/sbp2.c
drivers/ieee1394/video1394.c
drivers/infiniband/hw/ehca/ehca_cq.c
drivers/infiniband/hw/ehca/ehca_mrmw.c
drivers/infiniband/hw/ehca/ehca_pd.c
drivers/infiniband/hw/ehca/ehca_qp.c
drivers/infiniband/ulp/iser/iser_initiator.c
drivers/input/gameport/ns558.c
drivers/input/touchscreen/ucb1400_ts.c
drivers/isdn/gigaset/bas-gigaset.c
drivers/isdn/gigaset/interface.c
drivers/isdn/i4l/isdn_tty.c
drivers/kvm/kvm_main.c
drivers/kvm/mmu.c
drivers/kvm/svm.c
drivers/kvm/vmx.c
drivers/macintosh/Kconfig
drivers/macintosh/rack-meter.c
drivers/macintosh/via-pmu.c
drivers/md/bitmap.c
drivers/md/raid5.c
drivers/media/common/ir-keymaps.c
drivers/media/video/usbvision/usbvision-video.c
drivers/media/video/zoran_driver.c
drivers/misc/Kconfig
drivers/misc/hdpuftrs/hdpu_nexus.c
drivers/misc/ioc4.c
drivers/misc/lkdtm.c
drivers/mmc/Kconfig
drivers/mtd/devices/block2mtd.c
drivers/net/3c503.c
drivers/net/Kconfig
drivers/net/Makefile
drivers/net/ac3200.c
drivers/net/atl1/Makefile [new file with mode: 0644]
drivers/net/atl1/atl1.h [new file with mode: 0644]
drivers/net/atl1/atl1_ethtool.c [new file with mode: 0644]
drivers/net/atl1/atl1_hw.c [new file with mode: 0644]
drivers/net/atl1/atl1_hw.h [new file with mode: 0644]
drivers/net/atl1/atl1_main.c [new file with mode: 0644]
drivers/net/atl1/atl1_param.c [new file with mode: 0644]
drivers/net/bonding/bond_alb.c
drivers/net/bonding/bond_main.c
drivers/net/cxgb3/cxgb3_main.c
drivers/net/cxgb3/cxgb3_offload.c
drivers/net/defxx.c
drivers/net/defxx.h
drivers/net/e2100.c
drivers/net/es3210.c
drivers/net/macsonic.c
drivers/net/mv643xx_eth.c
drivers/net/ppp_generic.c
drivers/net/r8169.c
drivers/net/s2io.c
drivers/net/s2io.h
drivers/net/slip.c
drivers/net/smc-mca.c
drivers/net/smc-ultra.c
drivers/net/smc-ultra32.c
drivers/net/spider_net.c
drivers/net/tg3.c
drivers/net/ucc_geth.c
drivers/net/ucc_geth_phy.c
drivers/net/wan/pc300too.c
drivers/net/wd.c
drivers/parisc/led.c
drivers/pci/Kconfig
drivers/pci/pci.c
drivers/pci/quirks.c
drivers/pcmcia/m32r_pcc.c
drivers/pnp/base.h
drivers/pnp/pnpbios/rsparser.c
drivers/rapidio/rio-scan.c
drivers/rtc/Kconfig
drivers/rtc/Makefile
drivers/rtc/rtc-cmos.c [new file with mode: 0644]
drivers/rtc/rtc-dev.c
drivers/rtc/rtc-pcf8563.c
drivers/s390/char/monreader.c
drivers/s390/char/vmlogrdr.c
drivers/s390/crypto/zcrypt_api.c
drivers/s390/net/Kconfig
drivers/s390/net/Makefile
drivers/s390/net/iucv.c [deleted file]
drivers/s390/net/iucv.h [deleted file]
drivers/s390/net/lcs.c
drivers/s390/net/netiucv.c
drivers/s390/net/smsgiucv.c
drivers/sbus/sbus.c
drivers/scsi/53c7xx.c
drivers/scsi/NCR53C9x.c
drivers/scsi/NCR53C9x.h
drivers/scsi/aic94xx/aic94xx_hwi.c
drivers/scsi/blz1230.c
drivers/scsi/blz2060.c
drivers/scsi/cyberstorm.c
drivers/scsi/cyberstormII.c
drivers/scsi/dec_esp.c
drivers/scsi/fastlane.c
drivers/scsi/iscsi_tcp.c
drivers/scsi/jazz_esp.c
drivers/scsi/libiscsi.c
drivers/scsi/mac_esp.c
drivers/scsi/mca_53c9x.c
drivers/scsi/oktagon_esp.c
drivers/scsi/osst.c
drivers/scsi/osst.h
drivers/scsi/scsi_lib.c
drivers/scsi/sun3x_esp.c
drivers/serial/8250.c
drivers/serial/8250_pci.c
drivers/serial/Kconfig
drivers/serial/crisv10.c
drivers/serial/ioc4_serial.c
drivers/serial/serial_txx9.c
drivers/serial/uartlite.c
drivers/sn/ioc3.c
drivers/tc/Makefile
drivers/tc/tc-driver.c [new file with mode: 0644]
drivers/tc/tc.c
drivers/tc/zs.c
drivers/usb/gadget/file_storage.c
drivers/usb/gadget/rndis.c
drivers/usb/host/ehci-ps3.c
drivers/usb/host/ehci.h
drivers/usb/host/hc_crisv10.c
drivers/usb/host/ohci-ps3.c
drivers/usb/host/ohci.h
drivers/usb/host/uhci-q.c
drivers/usb/net/gl620a.c
drivers/usb/serial/cp2101.c
drivers/usb/serial/digi_acceleport.c
drivers/usb/serial/keyspan_pda.c
drivers/usb/serial/mos7720.c
drivers/usb/serial/mos7840.c
drivers/video/Kconfig
drivers/video/pmag-ba-fb.c
drivers/video/pmagb-b-fb.c
drivers/video/sa1100fb.h
fs/9p/vfs_file.c
fs/9p/vfs_inode.c
fs/Kconfig
fs/aio.c
fs/binfmt_elf_fdpic.c
fs/binfmt_flat.c
fs/buffer.c
fs/coda/sysctl.c
fs/configfs/dir.c
fs/dlm/lowcomms-tcp.c
fs/dlm/memory.c
fs/dquot.c
fs/drop_caches.c
fs/ecryptfs/crypto.c
fs/ecryptfs/ecryptfs_kernel.h
fs/ecryptfs/file.c
fs/ecryptfs/inode.c
fs/ecryptfs/keystore.c
fs/ecryptfs/main.c
fs/exec.c
fs/ext2/dir.c
fs/ext2/super.c
fs/ext3/inode.c
fs/ext3/namei.c
fs/ext3/super.c
fs/ext4/inode.c
fs/ext4/namei.c
fs/ext4/super.c
fs/fuse/file.c
fs/fuse/inode.c
fs/gfs2/meta_io.c
fs/hfs/hfs.h
fs/hfsplus/hfsplus_raw.h
fs/hugetlbfs/inode.c
fs/inode.c
fs/jffs/inode-v23.c
fs/namespace.c
fs/partitions/check.c
fs/partitions/msdos.c
fs/partitions/sgi.c
fs/partitions/sun.c
fs/proc/base.c
fs/proc/proc_misc.c
fs/ramfs/file-mmu.c
fs/ramfs/file-nommu.c
fs/read_write.c
fs/smbfs/request.c
fs/sysfs/dir.c
fs/ufs/dir.c
fs/ufs/super.c
include/asm-alpha/io.h
include/asm-alpha/mman.h
include/asm-alpha/percpu.h
include/asm-alpha/termios.h
include/asm-arm/arch-ixp4xx/io.h
include/asm-arm/io.h
include/asm-arm/spinlock.h
include/asm-arm/termios.h
include/asm-arm/uaccess.h
include/asm-arm26/termios.h
include/asm-arm26/uaccess-asm.h
include/asm-avr32/arch-at32ap/at32ap7000.h
include/asm-avr32/arch-at32ap/gpio.h [new file with mode: 0644]
include/asm-avr32/arch-at32ap/irq.h [new file with mode: 0644]
include/asm-avr32/arch-at32ap/portmux.h
include/asm-avr32/checksum.h
include/asm-avr32/dma-mapping.h
include/asm-avr32/gpio.h [new file with mode: 0644]
include/asm-avr32/irq.h
include/asm-avr32/posix_types.h
include/asm-avr32/termios.h
include/asm-avr32/uaccess.h
include/asm-cris/io.h
include/asm-cris/semaphore-helper.h
include/asm-cris/system.h
include/asm-cris/termios.h
include/asm-frv/termios.h
include/asm-generic/memory_model.h
include/asm-generic/mman.h
include/asm-h8300/termios.h
include/asm-i386/atomic.h
include/asm-i386/bitops.h
include/asm-i386/io.h
include/asm-i386/termios.h
include/asm-i386/uaccess.h
include/asm-ia64/termios.h
include/asm-m32r/a.out.h
include/asm-m32r/addrspace.h
include/asm-m32r/bugs.h
include/asm-m32r/byteorder.h
include/asm-m32r/cache.h
include/asm-m32r/cacheflush.h
include/asm-m32r/current.h
include/asm-m32r/delay.h
include/asm-m32r/dma.h
include/asm-m32r/errno.h
include/asm-m32r/ide.h
include/asm-m32r/ioctls.h
include/asm-m32r/ipcbuf.h
include/asm-m32r/kmap_types.h
include/asm-m32r/m32104ut/m32104ut_pld.h
include/asm-m32r/m32700ut/m32700ut_lan.h
include/asm-m32r/m32700ut/m32700ut_lcd.h
include/asm-m32r/m32700ut/m32700ut_pld.h
include/asm-m32r/mappi2/mappi2_pld.h
include/asm-m32r/mappi3/mappi3_pld.h
include/asm-m32r/mc146818rtc.h
include/asm-m32r/mman.h
include/asm-m32r/mmu.h
include/asm-m32r/mmu_context.h
include/asm-m32r/module.h
include/asm-m32r/msgbuf.h
include/asm-m32r/namei.h
include/asm-m32r/opsput/opsput_lan.h
include/asm-m32r/opsput/opsput_lcd.h
include/asm-m32r/opsput/opsput_pld.h
include/asm-m32r/page.h
include/asm-m32r/param.h
include/asm-m32r/pci.h
include/asm-m32r/pgalloc.h
include/asm-m32r/pgtable-2level.h
include/asm-m32r/posix_types.h
include/asm-m32r/rtc.h
include/asm-m32r/scatterlist.h
include/asm-m32r/sections.h
include/asm-m32r/segment.h
include/asm-m32r/sembuf.h
include/asm-m32r/setup.h
include/asm-m32r/shmbuf.h
include/asm-m32r/shmparam.h
include/asm-m32r/sigcontext.h
include/asm-m32r/siginfo.h
include/asm-m32r/signal.h
include/asm-m32r/smp.h
include/asm-m32r/sockios.h
include/asm-m32r/spinlock_types.h
include/asm-m32r/stat.h
include/asm-m32r/string.h
include/asm-m32r/syscall.h
include/asm-m32r/system.h
include/asm-m32r/termbits.h
include/asm-m32r/termios.h
include/asm-m32r/timex.h
include/asm-m32r/tlbflush.h
include/asm-m32r/types.h
include/asm-m32r/uaccess.h
include/asm-m32r/ucontext.h
include/asm-m32r/unaligned.h
include/asm-m32r/unistd.h
include/asm-m32r/user.h
include/asm-m32r/vga.h
include/asm-m32r/xor.h
include/asm-m68k/math-emu.h
include/asm-m68k/termios.h
include/asm-m68k/user.h
include/asm-m68knommu/bitops.h
include/asm-mips/apm.h [deleted file]
include/asm-mips/dec/system.h
include/asm-mips/dec/tc.h [deleted file]
include/asm-mips/dec/tcinfo.h [deleted file]
include/asm-mips/dec/tcmodule.h [deleted file]
include/asm-mips/io.h
include/asm-mips/mman.h
include/asm-mips/termios.h
include/asm-parisc/io.h
include/asm-parisc/mman.h
include/asm-parisc/termios.h
include/asm-powerpc/termios.h
include/asm-ppc/io.h
include/asm-s390/io.h
include/asm-s390/termios.h
include/asm-sh/apm.h [deleted file]
include/asm-sh/termios.h
include/asm-sh64/termios.h
include/asm-sparc/io.h
include/asm-sparc/termios.h
include/asm-sparc64/irq.h
include/asm-sparc64/pbm.h
include/asm-sparc64/termios.h
include/asm-um/elf-ppc.h
include/asm-um/processor-x86_64.h
include/asm-um/ptrace-x86_64.h
include/asm-v850/termios.h
include/asm-x86_64/io.h
include/asm-x86_64/proto.h
include/asm-x86_64/termios.h
include/asm-x86_64/uaccess.h
include/asm-xtensa/mman.h
include/asm-xtensa/termios.h
include/crypto/algapi.h
include/linux/Kbuild
include/linux/apm-emulation.h [moved from include/asm-arm/apm.h with 93% similarity]
include/linux/ata.h
include/linux/atmarp.h
include/linux/byteorder/Kbuild
include/linux/byteorder/pdp_endian.h [deleted file]
include/linux/byteorder/swabb.h
include/linux/cfag12864b.h [new file with mode: 0644]
include/linux/compiler-gcc.h
include/linux/console.h
include/linux/console_struct.h
include/linux/crypto.h
include/linux/device.h
include/linux/dma-mapping.h
include/linux/dmapool.h
include/linux/dn.h
include/linux/eisa.h
include/linux/fs.h
include/linux/genhd.h
include/linux/gfp.h
include/linux/i2c-id.h
include/linux/if_packet.h
include/linux/init.h
include/linux/interrupt.h
include/linux/io.h
include/linux/ioport.h
include/linux/kernel.h
include/linux/kfifo.h
include/linux/ks0108.h [new file with mode: 0644]
include/linux/ktime.h
include/linux/libata.h
include/linux/list.h
include/linux/lockdep.h
include/linux/mc146818rtc.h
include/linux/mm.h
include/linux/mm_inline.h
include/linux/mmzone.h
include/linux/mount.h
include/linux/net.h
include/linux/netdevice.h
include/linux/netfilter/Kbuild
include/linux/netfilter/nf_conntrack_sane.h [new file with mode: 0644]
include/linux/netfilter/nf_conntrack_tcp.h
include/linux/netfilter/xt_TCPMSS.h [new file with mode: 0644]
include/linux/netfilter_ipv4/ip_nat.h
include/linux/netfilter_ipv4/ip_tables.h
include/linux/netfilter_ipv4/ipt_TCPMSS.h
include/linux/netfilter_ipv6/ip6_tables.h
include/linux/netfilter_ipv6/ip6t_mh.h [new file with mode: 0644]
include/linux/pagemap.h
include/linux/pci.h
include/linux/pci_ids.h
include/linux/pfkeyv2.h
include/linux/pnp.h
include/linux/raid/bitmap.h
include/linux/reiserfs_xattr.h
include/linux/relay.h
include/linux/rio.h
include/linux/sched.h
include/linux/security.h
include/linux/slab_def.h
include/linux/socket.h
include/linux/spinlock.h
include/linux/stat.h
include/linux/sunrpc/svcsock.h
include/linux/swap.h
include/linux/sysctl.h
include/linux/tc.h [new file with mode: 0644]
include/linux/tcp.h
include/linux/time.h
include/linux/timex.h
include/linux/tty.h
include/linux/ufs_fs.h
include/linux/vmstat.h
include/linux/wanrouter.h
include/linux/xattr.h
include/linux/xfrm.h
include/net/dn_route.h
include/net/dst.h
include/net/inet_hashtables.h
include/net/ip6_fib.h
include/net/iucv/af_iucv.h [new file with mode: 0644]
include/net/iucv/iucv.h [new file with mode: 0644]
include/net/netfilter/nf_conntrack.h
include/net/netfilter/nf_nat.h
include/net/route.h
include/net/tcp.h
include/net/x25.h
include/net/xfrm.h
include/scsi/iscsi_proto.h
include/scsi/libsas.h
include/sound/ac97_codec.h
include/sound/ad1848.h
include/sound/ak4114.h
include/sound/ak4117.h
include/sound/ak4xxx-adda.h
include/sound/control.h
include/sound/core.h
include/sound/emu10k1.h
include/sound/pcm.h
include/sound/pt2258.h [new file with mode: 0644]
include/sound/sb16_csp.h
include/sound/snd_wavefront.h
include/sound/soc-dapm.h [new file with mode: 0644]
include/sound/soc.h [new file with mode: 0644]
include/sound/typedefs.h [deleted file]
include/sound/version.h
include/sound/vx_core.h
include/sound/ymfpci.h
init/Kconfig
init/Makefile
init/initramfs.c
init/main.c
init/noinitramfs.c [new file with mode: 0644]
ipc/util.c
kernel/auditfilter.c
kernel/compat.c
kernel/cpu.c
kernel/exit.c
kernel/fork.c
kernel/hrtimer.c
kernel/irq/Makefile
kernel/irq/devres.c [new file with mode: 0644]
kernel/irq/proc.c
kernel/kfifo.c
kernel/kthread.c
kernel/lockdep.c
kernel/lockdep_proc.c
kernel/panic.c
kernel/posix-timers.c
kernel/power/Kconfig
kernel/power/disk.c
kernel/power/main.c
kernel/power/snapshot.c
kernel/power/swsusp.c
kernel/power/user.c
kernel/printk.c
kernel/profile.c
kernel/relay.c
kernel/resource.c
kernel/sched.c
kernel/signal.c
kernel/sys.c
kernel/sysctl.c
kernel/time/clocksource.c
kernel/timer.c
kernel/workqueue.c
lib/Kconfig
lib/Kconfig.debug
lib/Makefile
lib/bitmap.c
lib/bust_spinlocks.c
lib/cmdline.c
lib/devres.c [new file with mode: 0644]
lib/idr.c
lib/iomap.c
lib/kobject.c
lib/sha1.c
lib/sort.c
lib/string.c
lib/textsearch.c
lib/vsprintf.c
mm/Kconfig
mm/filemap.c
mm/highmem.c
mm/hugetlb.c
mm/memory.c
mm/mempolicy.c
mm/mempool.c
mm/mmap.c
mm/page-writeback.c
mm/page_alloc.c
mm/readahead.c
mm/shmem.c
mm/slab.c
mm/truncate.c
mm/vmalloc.c
mm/vmscan.c
mm/vmstat.c
net/802/fc.c
net/802/fddi.c
net/802/hippi.c
net/802/psnap.c
net/802/tr.c
net/8021q/vlan.c
net/8021q/vlan.h
net/8021q/vlan_dev.c
net/8021q/vlanproc.c
net/Kconfig
net/Makefile
net/appletalk/aarp.c
net/appletalk/atalk_proc.c
net/appletalk/ddp.c
net/appletalk/dev.c
net/atm/atm_sysfs.c
net/atm/br2684.c
net/atm/common.c
net/atm/common.h
net/atm/ioctl.c
net/atm/lec.c
net/atm/lec.h
net/atm/mpc.c
net/atm/mpc.h
net/atm/mpoa_caches.c
net/atm/mpoa_caches.h
net/atm/mpoa_proc.c
net/atm/proc.c
net/atm/pvc.c
net/atm/raw.c
net/atm/resources.c
net/atm/signaling.h
net/atm/svc.c
net/ax25/af_ax25.c
net/ax25/ax25_addr.c
net/ax25/ax25_ip.c
net/ax25/ax25_route.c
net/ax25/ax25_std_timer.c
net/ax25/ax25_subr.c
net/ax25/ax25_uid.c
net/bluetooth/af_bluetooth.c
net/bluetooth/bnep/bnep.h
net/bluetooth/bnep/core.c
net/bluetooth/bnep/netdev.c
net/bluetooth/bnep/sock.c
net/bluetooth/cmtp/capi.c
net/bluetooth/cmtp/cmtp.h
net/bluetooth/cmtp/core.c
net/bluetooth/cmtp/sock.c
net/bluetooth/hci_conn.c
net/bluetooth/hci_core.c
net/bluetooth/hci_event.c
net/bluetooth/hci_sock.c
net/bluetooth/hidp/core.c
net/bluetooth/hidp/hidp.h
net/bluetooth/hidp/sock.c
net/bluetooth/l2cap.c
net/bluetooth/lib.c
net/bluetooth/rfcomm/core.c
net/bluetooth/rfcomm/sock.c
net/bluetooth/rfcomm/tty.c
net/bluetooth/sco.c
net/bridge/br_device.c
net/bridge/br_fdb.c
net/bridge/br_forward.c
net/bridge/br_if.c
net/bridge/br_input.c
net/bridge/br_ioctl.c
net/bridge/br_netfilter.c
net/bridge/br_netlink.c
net/bridge/br_notify.c
net/bridge/br_private.h
net/bridge/br_stp.c
net/bridge/br_stp_bpdu.c
net/bridge/br_stp_if.c
net/bridge/br_stp_timer.c
net/bridge/br_sysfs_br.c
net/bridge/netfilter/ebt_802_3.c
net/bridge/netfilter/ebt_among.c
net/bridge/netfilter/ebt_arpreply.c
net/bridge/netfilter/ebt_ip.c
net/bridge/netfilter/ebt_log.c
net/bridge/netfilter/ebt_mark_m.c
net/bridge/netfilter/ebt_stp.c
net/bridge/netfilter/ebt_ulog.c
net/bridge/netfilter/ebt_vlan.c
net/bridge/netfilter/ebtable_filter.c
net/bridge/netfilter/ebtables.c
net/compat.c
net/core/datagram.c
net/core/dev.c
net/core/dev_mcast.c
net/core/dst.c
net/core/ethtool.c
net/core/fib_rules.c
net/core/filter.c
net/core/gen_estimator.c
net/core/gen_stats.c
net/core/iovec.c
net/core/link_watch.c
net/core/neighbour.c
net/core/net-sysfs.c
net/core/netpoll.c
net/core/pktgen.c
net/core/rtnetlink.c
net/core/scm.c
net/core/skbuff.c
net/core/sock.c
net/core/stream.c
net/core/user_dma.c
net/core/utils.c
net/core/wireless.c
net/dccp/ccids/ccid2.c
net/dccp/ccids/ccid3.c
net/dccp/ccids/lib/packet_history.h
net/dccp/ccids/lib/tfrc_equation.c
net/dccp/dccp.h
net/dccp/feat.c
net/dccp/feat.h
net/dccp/input.c
net/dccp/ipv4.c
net/dccp/ipv6.c
net/dccp/options.c
net/dccp/output.c
net/dccp/proto.c
net/dccp/timer.c
net/decnet/af_decnet.c
net/decnet/dn_dev.c
net/decnet/dn_fib.c
net/decnet/dn_neigh.c
net/decnet/dn_nsp_in.c
net/decnet/dn_nsp_out.c
net/decnet/dn_route.c
net/decnet/dn_rules.c
net/decnet/dn_table.c
net/decnet/netfilter/dn_rtmsg.c
net/decnet/sysctl_net_decnet.c
net/econet/af_econet.c
net/ethernet/eth.c
net/ieee80211/ieee80211_crypt_wep.c
net/ieee80211/ieee80211_rx.c
net/ieee80211/ieee80211_tx.c
net/ieee80211/ieee80211_wx.c
net/ieee80211/softmac/ieee80211softmac_assoc.c
net/ieee80211/softmac/ieee80211softmac_auth.c
net/ieee80211/softmac/ieee80211softmac_event.c
net/ieee80211/softmac/ieee80211softmac_io.c
net/ieee80211/softmac/ieee80211softmac_module.c
net/ieee80211/softmac/ieee80211softmac_priv.h
net/ieee80211/softmac/ieee80211softmac_scan.c
net/ieee80211/softmac/ieee80211softmac_wx.c
net/ipv4/af_inet.c
net/ipv4/ah4.c
net/ipv4/arp.c
net/ipv4/datagram.c
net/ipv4/devinet.c
net/ipv4/esp4.c
net/ipv4/fib_frontend.c
net/ipv4/fib_hash.c
net/ipv4/fib_semantics.c
net/ipv4/fib_trie.c
net/ipv4/icmp.c
net/ipv4/igmp.c
net/ipv4/inet_connection_sock.c
net/ipv4/inet_diag.c
net/ipv4/inet_hashtables.c
net/ipv4/inet_timewait_sock.c
net/ipv4/ip_forward.c
net/ipv4/ip_fragment.c
net/ipv4/ip_gre.c
net/ipv4/ip_input.c
net/ipv4/ip_options.c
net/ipv4/ip_output.c
net/ipv4/ip_sockglue.c
net/ipv4/ipcomp.c
net/ipv4/ipconfig.c
net/ipv4/ipip.c
net/ipv4/ipmr.c
net/ipv4/ipvs/ip_vs_conn.c
net/ipv4/ipvs/ip_vs_core.c
net/ipv4/ipvs/ip_vs_ftp.c
net/ipv4/ipvs/ip_vs_lblc.c
net/ipv4/ipvs/ip_vs_lblcr.c
net/ipv4/ipvs/ip_vs_rr.c
net/ipv4/multipath_drr.c
net/ipv4/multipath_random.c
net/ipv4/multipath_rr.c
net/ipv4/multipath_wrandom.c
net/ipv4/netfilter.c
net/ipv4/netfilter/Kconfig
net/ipv4/netfilter/Makefile
net/ipv4/netfilter/arp_tables.c
net/ipv4/netfilter/arpt_mangle.c
net/ipv4/netfilter/ip_conntrack_amanda.c
net/ipv4/netfilter/ip_conntrack_core.c
net/ipv4/netfilter/ip_conntrack_ftp.c
net/ipv4/netfilter/ip_conntrack_helper_h323.c
net/ipv4/netfilter/ip_conntrack_helper_pptp.c
net/ipv4/netfilter/ip_conntrack_irc.c
net/ipv4/netfilter/ip_conntrack_netbios_ns.c
net/ipv4/netfilter/ip_conntrack_netlink.c
net/ipv4/netfilter/ip_conntrack_proto_icmp.c
net/ipv4/netfilter/ip_conntrack_proto_sctp.c
net/ipv4/netfilter/ip_conntrack_proto_tcp.c
net/ipv4/netfilter/ip_conntrack_proto_udp.c
net/ipv4/netfilter/ip_conntrack_sip.c
net/ipv4/netfilter/ip_conntrack_standalone.c
net/ipv4/netfilter/ip_conntrack_tftp.c
net/ipv4/netfilter/ip_nat_core.c
net/ipv4/netfilter/ip_nat_ftp.c
net/ipv4/netfilter/ip_nat_helper.c
net/ipv4/netfilter/ip_nat_helper_pptp.c
net/ipv4/netfilter/ip_nat_irc.c
net/ipv4/netfilter/ip_nat_proto_icmp.c
net/ipv4/netfilter/ip_nat_proto_tcp.c
net/ipv4/netfilter/ip_nat_proto_udp.c
net/ipv4/netfilter/ip_nat_rule.c
net/ipv4/netfilter/ip_nat_sip.c
net/ipv4/netfilter/ip_nat_snmp_basic.c
net/ipv4/netfilter/ip_nat_standalone.c
net/ipv4/netfilter/ip_queue.c
net/ipv4/netfilter/ip_tables.c
net/ipv4/netfilter/ipt_CLUSTERIP.c
net/ipv4/netfilter/ipt_ECN.c
net/ipv4/netfilter/ipt_LOG.c
net/ipv4/netfilter/ipt_MASQUERADE.c
net/ipv4/netfilter/ipt_NETMAP.c
net/ipv4/netfilter/ipt_REDIRECT.c
net/ipv4/netfilter/ipt_REJECT.c
net/ipv4/netfilter/ipt_SAME.c
net/ipv4/netfilter/ipt_TCPMSS.c [deleted file]
net/ipv4/netfilter/ipt_TOS.c
net/ipv4/netfilter/ipt_TTL.c
net/ipv4/netfilter/ipt_ULOG.c
net/ipv4/netfilter/ipt_addrtype.c
net/ipv4/netfilter/ipt_ah.c
net/ipv4/netfilter/ipt_ecn.c
net/ipv4/netfilter/ipt_iprange.c
net/ipv4/netfilter/ipt_owner.c
net/ipv4/netfilter/ipt_recent.c
net/ipv4/netfilter/ipt_tos.c
net/ipv4/netfilter/ipt_ttl.c
net/ipv4/netfilter/iptable_filter.c
net/ipv4/netfilter/iptable_mangle.c
net/ipv4/netfilter/iptable_raw.c
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c
net/ipv4/netfilter/nf_conntrack_proto_icmp.c
net/ipv4/netfilter/nf_nat_core.c
net/ipv4/netfilter/nf_nat_h323.c
net/ipv4/netfilter/nf_nat_helper.c
net/ipv4/netfilter/nf_nat_pptp.c
net/ipv4/netfilter/nf_nat_proto_icmp.c
net/ipv4/netfilter/nf_nat_proto_tcp.c
net/ipv4/netfilter/nf_nat_proto_udp.c
net/ipv4/netfilter/nf_nat_rule.c
net/ipv4/netfilter/nf_nat_sip.c
net/ipv4/netfilter/nf_nat_snmp_basic.c
net/ipv4/netfilter/nf_nat_standalone.c
net/ipv4/proc.c
net/ipv4/protocol.c
net/ipv4/raw.c
net/ipv4/route.c
net/ipv4/syncookies.c
net/ipv4/sysctl_net_ipv4.c
net/ipv4/tcp.c
net/ipv4/tcp_cong.c
net/ipv4/tcp_cubic.c
net/ipv4/tcp_highspeed.c
net/ipv4/tcp_htcp.c
net/ipv4/tcp_input.c
net/ipv4/tcp_ipv4.c
net/ipv4/tcp_minisocks.c
net/ipv4/tcp_output.c
net/ipv4/tcp_timer.c
net/ipv4/tcp_vegas.c
net/ipv4/tcp_westwood.c
net/ipv4/udp.c
net/ipv4/udp_impl.h
net/ipv4/xfrm4_input.c
net/ipv4/xfrm4_mode_tunnel.c
net/ipv4/xfrm4_output.c
net/ipv4/xfrm4_policy.c
net/ipv4/xfrm4_state.c
net/ipv4/xfrm4_tunnel.c
net/ipv6/addrconf.c
net/ipv6/af_inet6.c
net/ipv6/ah6.c
net/ipv6/anycast.c
net/ipv6/datagram.c
net/ipv6/esp6.c
net/ipv6/exthdrs.c
net/ipv6/exthdrs_core.c
net/ipv6/icmp.c
net/ipv6/inet6_hashtables.c
net/ipv6/ip6_fib.c
net/ipv6/ip6_flowlabel.c
net/ipv6/ip6_input.c
net/ipv6/ip6_output.c
net/ipv6/ip6_tunnel.c
net/ipv6/ipcomp6.c
net/ipv6/ipv6_sockglue.c
net/ipv6/mcast.c
net/ipv6/mip6.c
net/ipv6/ndisc.c
net/ipv6/netfilter.c
net/ipv6/netfilter/Kconfig
net/ipv6/netfilter/Makefile
net/ipv6/netfilter/ip6_queue.c
net/ipv6/netfilter/ip6_tables.c
net/ipv6/netfilter/ip6t_HL.c
net/ipv6/netfilter/ip6t_LOG.c
net/ipv6/netfilter/ip6t_REJECT.c
net/ipv6/netfilter/ip6t_ah.c
net/ipv6/netfilter/ip6t_eui64.c
net/ipv6/netfilter/ip6t_frag.c
net/ipv6/netfilter/ip6t_hbh.c
net/ipv6/netfilter/ip6t_hl.c
net/ipv6/netfilter/ip6t_ipv6header.c
net/ipv6/netfilter/ip6t_mh.c [new file with mode: 0644]
net/ipv6/netfilter/ip6t_owner.c
net/ipv6/netfilter/ip6t_rt.c
net/ipv6/netfilter/ip6table_filter.c
net/ipv6/netfilter/ip6table_mangle.c
net/ipv6/netfilter/ip6table_raw.c
net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
net/ipv6/netfilter/nf_conntrack_reasm.c
net/ipv6/proc.c
net/ipv6/protocol.c
net/ipv6/raw.c
net/ipv6/reassembly.c
net/ipv6/route.c
net/ipv6/sit.c
net/ipv6/sysctl_net_ipv6.c
net/ipv6/tcp_ipv6.c
net/ipv6/udp.c
net/ipv6/udp_impl.h
net/ipv6/xfrm6_input.c
net/ipv6/xfrm6_mode_tunnel.c
net/ipv6/xfrm6_output.c
net/ipv6/xfrm6_policy.c
net/ipv6/xfrm6_state.c
net/ipv6/xfrm6_tunnel.c
net/ipx/af_ipx.c
net/ipx/ipx_proc.c
net/ipx/ipx_route.c
net/ipx/sysctl_net_ipx.c
net/irda/af_irda.c
net/irda/discovery.c
net/irda/ircomm/ircomm_core.c
net/irda/ircomm/ircomm_event.c
net/irda/ircomm/ircomm_lmp.c
net/irda/ircomm/ircomm_param.c
net/irda/ircomm/ircomm_ttp.c
net/irda/ircomm/ircomm_tty.c
net/irda/ircomm/ircomm_tty_attach.c
net/irda/ircomm/ircomm_tty_ioctl.c
net/irda/irda_device.c
net/irda/iriap.c
net/irda/irias_object.c
net/irda/irlan/irlan_client.c
net/irda/irlan/irlan_client_event.c
net/irda/irlan/irlan_common.c
net/irda/irlan/irlan_eth.c
net/irda/irlan/irlan_event.c
net/irda/irlan/irlan_filter.c
net/irda/irlan/irlan_provider.c
net/irda/irlan/irlan_provider_event.c
net/irda/irlap.c
net/irda/irlap_event.c
net/irda/irlap_frame.c
net/irda/irlmp.c
net/irda/irlmp_event.c
net/irda/irlmp_frame.c
net/irda/irmod.c
net/irda/irnet/irnet.h
net/irda/irnet/irnet_irda.c
net/irda/irnet/irnet_irda.h
net/irda/irnet/irnet_ppp.c
net/irda/irproc.c
net/irda/irqueue.c
net/irda/irsysctl.c
net/irda/irttp.c
net/irda/parameters.c
net/irda/qos.c
net/irda/timer.c
net/irda/wrapper.c
net/iucv/Kconfig [new file with mode: 0644]
net/iucv/Makefile [new file with mode: 0644]
net/iucv/af_iucv.c [new file with mode: 0644]
net/iucv/iucv.c [new file with mode: 0644]
net/key/af_key.c
net/lapb/lapb_iface.c
net/lapb/lapb_out.c
net/lapb/lapb_subr.c
net/lapb/lapb_timer.c
net/llc/af_llc.c
net/llc/llc_conn.c
net/llc/llc_input.c
net/llc/llc_output.c
net/llc/llc_pdu.c
net/llc/llc_proc.c
net/llc/llc_s_st.c
net/llc/llc_sap.c
net/llc/llc_station.c
net/llc/sysctl_net_llc.c
net/netfilter/Kconfig
net/netfilter/Makefile
net/netfilter/nf_conntrack_proto_tcp.c
net/netfilter/nf_conntrack_sane.c [new file with mode: 0644]
net/netfilter/xt_CLASSIFY.c
net/netfilter/xt_CONNMARK.c
net/netfilter/xt_CONNSECMARK.c
net/netfilter/xt_MARK.c
net/netfilter/xt_SECMARK.c
net/netfilter/xt_TCPMSS.c [new file with mode: 0644]
net/netfilter/xt_hashlimit.c
net/netlabel/netlabel_cipso_v4.c
net/netlink/af_netlink.c
net/netlink/genetlink.c
net/netrom/af_netrom.c
net/netrom/nr_route.c
net/netrom/nr_subr.c
net/netrom/nr_timer.c
net/netrom/sysctl_net_netrom.c
net/packet/af_packet.c
net/rose/af_rose.c
net/rose/rose_route.c
net/rose/sysctl_net_rose.c
net/rxrpc/connection.c
net/rxrpc/internal.h
net/rxrpc/krxiod.c
net/rxrpc/krxsecd.c
net/rxrpc/main.c
net/rxrpc/sysctl.c
net/rxrpc/transport.c
net/sched/act_api.c
net/sched/act_gact.c
net/sched/act_ipt.c
net/sched/act_pedit.c
net/sched/act_police.c
net/sched/act_simple.c
net/sched/cls_api.c
net/sched/cls_basic.c
net/sched/cls_fw.c
net/sched/cls_rsvp.h
net/sched/cls_tcindex.c
net/sched/cls_u32.c
net/sched/em_cmp.c
net/sched/em_meta.c
net/sched/em_nbyte.c
net/sched/em_text.c
net/sched/em_u32.c
net/sched/ematch.c
net/sched/sch_api.c
net/sched/sch_atm.c
net/sched/sch_cbq.c
net/sched/sch_dsmark.c
net/sched/sch_generic.c
net/sched/sch_gred.c
net/sched/sch_hfsc.c
net/sched/sch_htb.c
net/sched/sch_ingress.c
net/sched/sch_netem.c
net/sched/sch_prio.c
net/sched/sch_red.c
net/sched/sch_sfq.c
net/sched/sch_tbf.c
net/sched/sch_teql.c
net/sctp/associola.c
net/sctp/bind_addr.c
net/sctp/crc32c.c
net/sctp/debug.c
net/sctp/endpointola.c
net/sctp/input.c
net/sctp/inqueue.c
net/sctp/ipv6.c
net/sctp/objcnt.c
net/sctp/output.c
net/sctp/outqueue.c
net/sctp/primitive.c
net/sctp/proc.c
net/sctp/protocol.c
net/sctp/sm_make_chunk.c
net/sctp/sm_sideeffect.c
net/sctp/sm_statefuns.c
net/sctp/sm_statetable.c
net/sctp/socket.c
net/sctp/transport.c
net/sctp/tsnmap.c
net/sctp/ulpevent.c
net/sctp/ulpqueue.c
net/socket.c
net/sunrpc/auth.c
net/sunrpc/auth_gss/auth_gss.c
net/sunrpc/auth_gss/gss_generic_token.c
net/sunrpc/auth_gss/gss_krb5_crypto.c
net/sunrpc/auth_gss/gss_krb5_seqnum.c
net/sunrpc/auth_gss/gss_mech_switch.c
net/sunrpc/auth_gss/gss_spkm3_token.c
net/sunrpc/auth_gss/gss_spkm3_unseal.c
net/sunrpc/auth_gss/svcauth_gss.c
net/sunrpc/cache.c
net/sunrpc/clnt.c
net/sunrpc/pmap_clnt.c
net/sunrpc/sched.c
net/sunrpc/svc.c
net/sunrpc/svcauth.c
net/sunrpc/svcauth_unix.c
net/sunrpc/svcsock.c
net/sunrpc/sysctl.c
net/sunrpc/xdr.c
net/sunrpc/xprt.c
net/tipc/addr.c
net/tipc/addr.h
net/tipc/bcast.c
net/tipc/bcast.h
net/tipc/bearer.c
net/tipc/bearer.h
net/tipc/cluster.c
net/tipc/cluster.h
net/tipc/config.c
net/tipc/config.h
net/tipc/core.c
net/tipc/core.h
net/tipc/dbg.c
net/tipc/dbg.h
net/tipc/discover.c
net/tipc/discover.h
net/tipc/eth_media.c
net/tipc/handler.c
net/tipc/link.c
net/tipc/link.h
net/tipc/msg.c
net/tipc/msg.h
net/tipc/name_distr.c
net/tipc/name_distr.h
net/tipc/name_table.c
net/tipc/name_table.h
net/tipc/net.c
net/tipc/net.h
net/tipc/netlink.c
net/tipc/node.c
net/tipc/node.h
net/tipc/node_subscr.c
net/tipc/node_subscr.h
net/tipc/port.c
net/tipc/port.h
net/tipc/ref.c
net/tipc/ref.h
net/tipc/socket.c
net/tipc/subscr.c
net/tipc/subscr.h
net/tipc/user_reg.c
net/tipc/user_reg.h
net/tipc/zone.c
net/tipc/zone.h
net/unix/af_unix.c
net/unix/garbage.c
net/wanrouter/af_wanpipe.c
net/wanrouter/wanmain.c
net/wanrouter/wanproc.c
net/x25/Makefile
net/x25/af_x25.c
net/x25/sysctl_net_x25.c
net/x25/x25_dev.c
net/x25/x25_facilities.c
net/x25/x25_forward.c [new file with mode: 0644]
net/x25/x25_in.c
net/x25/x25_link.c
net/x25/x25_out.c
net/x25/x25_proc.c
net/x25/x25_route.c
net/x25/x25_timer.c
net/xfrm/Kconfig
net/xfrm/xfrm_algo.c
net/xfrm/xfrm_input.c
net/xfrm/xfrm_policy.c
net/xfrm/xfrm_state.c
net/xfrm/xfrm_user.c
scripts/Kbuild.include
scripts/kernel-doc
security/selinux/avc.c
security/selinux/hooks.c
security/selinux/ss/avtab.c
sound/Kconfig
sound/Makefile
sound/ac97_bus.c
sound/aoa/aoa.h
sound/aoa/codecs/snd-aoa-codec-onyx.c
sound/aoa/core/snd-aoa-alsa.c
sound/aoa/core/snd-aoa-alsa.h
sound/aoa/core/snd-aoa-core.c
sound/aoa/fabrics/snd-aoa-fabric-layout.c
sound/aoa/soundbus/i2sbus/i2sbus-core.c
sound/aoa/soundbus/i2sbus/i2sbus-pcm.c
sound/aoa/soundbus/i2sbus/i2sbus.h
sound/arm/aaci.h
sound/core/control.c
sound/core/control_compat.c
sound/core/device.c
sound/core/hwdep.c
sound/core/init.c
sound/core/memalloc.c
sound/core/misc.c
sound/core/pcm.c
sound/core/pcm_lib.c
sound/core/pcm_memory.c
sound/core/rawmidi.c
sound/core/seq/seq_clientmgr.c
sound/core/seq/seq_device.c
sound/core/seq/seq_ports.c
sound/core/seq/seq_virmidi.c
sound/core/sound.c
sound/core/timer.c
sound/drivers/Kconfig
sound/drivers/Makefile
sound/drivers/dummy.c
sound/drivers/portman2x4.c [new file with mode: 0644]
sound/drivers/serial-u16550.c
sound/drivers/vx/vx_mixer.c
sound/i2c/Makefile
sound/i2c/other/Makefile
sound/i2c/other/ak4114.c
sound/i2c/other/ak4117.c
sound/i2c/other/ak4xxx-adda.c
sound/i2c/other/pt2258.c [new file with mode: 0644]
sound/isa/Kconfig
sound/isa/ad1816a/ad1816a_lib.c
sound/isa/ad1848/ad1848_lib.c
sound/isa/gus/gus_main.c
sound/isa/opl3sa2.c
sound/isa/sb/sb16_csp.c
sound/isa/wavefront/wavefront.c
sound/isa/wavefront/wavefront_fx.c
sound/isa/wavefront/yss225.c [new file with mode: 0644]
sound/oss/Kconfig
sound/oss/dmasound/Kconfig
sound/pci/Kconfig
sound/pci/ac97/ac97_codec.c
sound/pci/ac97/ac97_patch.c
sound/pci/ac97/ac97_patch.h
sound/pci/ac97/ak4531_codec.c
sound/pci/als300.c
sound/pci/atiixp.c
sound/pci/atiixp_modem.c
sound/pci/ca0106/ca0106_main.c
sound/pci/ca0106/ca0106_mixer.c
sound/pci/cs4281.c
sound/pci/echoaudio/darla20.c
sound/pci/echoaudio/darla24.c
sound/pci/echoaudio/echo3g.c
sound/pci/echoaudio/echo3g_dsp.c
sound/pci/echoaudio/echoaudio.c
sound/pci/echoaudio/gina20.c
sound/pci/echoaudio/gina24.c
sound/pci/echoaudio/indigo.c
sound/pci/echoaudio/indigodj.c
sound/pci/echoaudio/indigoio.c
sound/pci/echoaudio/layla20.c
sound/pci/echoaudio/layla24.c
sound/pci/echoaudio/mia.c
sound/pci/echoaudio/mona.c
sound/pci/emu10k1/emu10k1_main.c
sound/pci/emu10k1/emu10k1x.c
sound/pci/emu10k1/emufx.c
sound/pci/emu10k1/emumixer.c
sound/pci/emu10k1/emupcm.c
sound/pci/emu10k1/emuproc.c
sound/pci/emu10k1/io.c
sound/pci/emu10k1/p16v.c
sound/pci/emu10k1/p17v.h
sound/pci/emu10k1/voice.c
sound/pci/ens1370.c
sound/pci/es1938.c
sound/pci/fm801.c
sound/pci/hda/Makefile
sound/pci/hda/hda_codec.c
sound/pci/hda/hda_intel.c
sound/pci/hda/hda_local.h
sound/pci/hda/hda_patch.h
sound/pci/hda/patch_analog.c
sound/pci/hda/patch_cmedia.c
sound/pci/hda/patch_conexant.c [new file with mode: 0644]
sound/pci/hda/patch_realtek.c
sound/pci/hda/patch_sigmatel.c
sound/pci/hda/patch_via.c [new file with mode: 0644]
sound/pci/ice1712/Makefile
sound/pci/ice1712/amp.c
sound/pci/ice1712/amp.h
sound/pci/ice1712/aureon.c
sound/pci/ice1712/aureon.h
sound/pci/ice1712/delta.c
sound/pci/ice1712/delta.h
sound/pci/ice1712/ews.c
sound/pci/ice1712/ews.h
sound/pci/ice1712/hoontech.c
sound/pci/ice1712/hoontech.h
sound/pci/ice1712/ice1712.c
sound/pci/ice1712/ice1712.h
sound/pci/ice1712/ice1724.c
sound/pci/ice1712/juli.c
sound/pci/ice1712/juli.h
sound/pci/ice1712/phase.c
sound/pci/ice1712/phase.h
sound/pci/ice1712/pontis.c
sound/pci/ice1712/pontis.h
sound/pci/ice1712/prodigy192.c
sound/pci/ice1712/prodigy192.h
sound/pci/ice1712/revo.c
sound/pci/ice1712/revo.h
sound/pci/ice1712/vt1720_mobo.c
sound/pci/ice1712/vt1720_mobo.h
sound/pci/ice1712/wtm.c [new file with mode: 0644]
sound/pci/ice1712/wtm.h [new file with mode: 0644]
sound/pci/intel8x0.c
sound/pci/intel8x0m.c
sound/pci/korg1212/korg1212.c
sound/pci/maestro3.c
sound/pci/mixart/mixart_mixer.c
sound/pci/nm256/nm256.c
sound/pci/pcxhr/pcxhr_mixer.c
sound/pci/rme9652/hdsp.c
sound/pci/rme9652/hdspm.c
sound/pci/trident/trident_main.c
sound/pci/via82xx.c
sound/pci/via82xx_modem.c
sound/pci/vx222/vx222.c
sound/pci/vx222/vx222_ops.c
sound/pci/ymfpci/ymfpci_image.h
sound/pci/ymfpci/ymfpci_main.c
sound/pcmcia/vx/vxp_mixer.c
sound/pcmcia/vx/vxpocket.c
sound/soc/Kconfig [new file with mode: 0644]
sound/soc/Makefile [new file with mode: 0644]
sound/soc/at91/Kconfig [new file with mode: 0644]
sound/soc/at91/Makefile [new file with mode: 0644]
sound/soc/at91/at91-i2s.c [new file with mode: 0644]
sound/soc/at91/at91-i2s.h [new file with mode: 0644]
sound/soc/at91/at91-pcm.c [new file with mode: 0644]
sound/soc/at91/at91-pcm.h [new file with mode: 0644]
sound/soc/at91/eti_b1_wm8731.c [new file with mode: 0644]
sound/soc/codecs/Kconfig [new file with mode: 0644]
sound/soc/codecs/Makefile [new file with mode: 0644]
sound/soc/codecs/ac97.c [new file with mode: 0644]
sound/soc/codecs/ac97.h [new file with mode: 0644]
sound/soc/codecs/wm8731.c [new file with mode: 0644]
sound/soc/codecs/wm8731.h [new file with mode: 0644]
sound/soc/codecs/wm8750.c [new file with mode: 0644]
sound/soc/codecs/wm8750.h [new file with mode: 0644]
sound/soc/codecs/wm9712.c [new file with mode: 0644]
sound/soc/codecs/wm9712.h [new file with mode: 0644]
sound/soc/pxa/Kconfig [new file with mode: 0644]
sound/soc/pxa/Makefile [new file with mode: 0644]
sound/soc/pxa/corgi.c [new file with mode: 0644]
sound/soc/pxa/poodle.c [new file with mode: 0644]
sound/soc/pxa/pxa2xx-ac97.c [new file with mode: 0644]
sound/soc/pxa/pxa2xx-ac97.h [new file with mode: 0644]
sound/soc/pxa/pxa2xx-i2s.c [new file with mode: 0644]
sound/soc/pxa/pxa2xx-i2s.h [new file with mode: 0644]
sound/soc/pxa/pxa2xx-pcm.c [new file with mode: 0644]
sound/soc/pxa/pxa2xx-pcm.h [new file with mode: 0644]
sound/soc/pxa/spitz.c [new file with mode: 0644]
sound/soc/pxa/tosa.c [new file with mode: 0644]
sound/soc/soc-core.c [new file with mode: 0644]
sound/soc/soc-dapm.c [new file with mode: 0644]
sound/sparc/dbri.c
sound/usb/usbaudio.c
sound/usb/usbaudio.h
sound/usb/usbquirks.h
usr/Makefile
usr/gen_init_cpio.c

diff --git a/CREDITS b/CREDITS
index ae08e4c10ed4f5c2364db7326cbdd4a7cce529f8..a4e5599003b28d5c5e7f74f08d24d1c2dba718c3 100644 (file)
--- a/CREDITS
+++ b/CREDITS
@@ -2571,6 +2571,16 @@ S: Subiaco, 6008
 S: Perth, Western Australia
 S: Australia
 
+N: Miguel Ojeda Sandonis
+E: maxextreme@gmail.com
+D: Author: Auxiliary LCD Controller driver (ks0108)
+D: Author: Auxiliary LCD driver (cfag12864b)
+D: Author: Auxiliary LCD framebuffer driver (cfag12864bfb)
+D: Maintainer: Auxiliary display drivers tree (drivers/auxdisplay/*)
+S: C/ Mieses 20, 9-B
+S: Valladolid 47009
+S: Spain
+
 N: Greg Page
 E: gpage@sovereign.org
 D: IPX development and support
index 03dbd883cc41599211cb1c462fc126352112bb3a..bf9c16b64c34feff4087a6b83b78995d213bcc96 100644 (file)
@@ -1,6 +1,6 @@
 What:           /debug/pktcdvd/pktcdvd[0-7]
 Date:           Oct. 2006
-KernelVersion:  2.6.19
+KernelVersion:  2.6.20
 Contact:        Thomas Maier <balagi@justmail.de>
 Description:
 
@@ -11,8 +11,7 @@ The pktcdvd module (packet writing driver) creates
 these files in debugfs:
 
 /debug/pktcdvd/pktcdvd[0-7]/
-    info            (0444) Lots of human readable driver
-                           statistics and infos. Multiple lines!
+    info            (0444) Lots of driver statistics and infos.
 
 Example:
 -------
index c4c55edc9a5c9ca7f5eaa6441049360ad5813017..b1c3f0263359150017e37081baa5f0aeb01c2121 100644 (file)
@@ -1,6 +1,6 @@
 What:           /sys/class/pktcdvd/
 Date:           Oct. 2006
-KernelVersion:  2.6.19
+KernelVersion:  2.6.20
 Contact:        Thomas Maier <balagi@justmail.de>
 Description:
 
index a34442436128ebd2e0ac209f050402e298e23827..e7fc964334086403ea4a4b73b35ef253464b2d0e 100644 (file)
@@ -482,13 +482,13 @@ slightly.
 <para>Gadget drivers
 rely on common USB structures and constants
 defined in the
-<filename>&lt;linux/usb_ch9.h&gt;</filename>
+<filename>&lt;linux/usb/ch9.h&gt;</filename>
 header file, which is standard in Linux 2.6 kernels.
 These are the same types and constants used by host
 side drivers (and usbcore).
 </para>
 
-!Iinclude/linux/usb_ch9.h
+!Iinclude/linux/usb/ch9.h
 </sect1>
 
 <sect1 id="core"><title>Core Objects and Methods</title>
index 3fa0c4b4541e065760a3c119e88d314ba3b6ee91..0bb90237e230d5e0d9c05448767741bd8c0c6e87 100644 (file)
@@ -316,6 +316,9 @@ X!Earch/i386/kernel/mca.c
      <sect1><title>DMI Interfaces</title>
 !Edrivers/firmware/dmi_scan.c
      </sect1>
+     <sect1><title>EDD Interfaces</title>
+!Idrivers/firmware/edd.c
+     </sect1>
   </chapter>
 
   <chapter id="security">
index 3ccce886c349d4ab3d5e357213d651b82d204eb4..974e17ccf10644af33b1d6347655b7a9c26e747c 100644 (file)
@@ -4,4 +4,5 @@
 <param name="funcsynopsis.style">ansi</param>
 <param name="funcsynopsis.tabular.threshold">80</param>
 <!-- <param name="paper.type">A4</param> -->
+<param name="generate.section.toc.level">2</param>
 </stylesheet>
index 143e5ff7deb8c4fad66789c02750749251a2acea..a2ebd651b05a8d241dc529ae29c3ee05fd7459ac 100644 (file)
 
 <chapter><title>USB-Standard Types</title>
 
-    <para>In <filename>&lt;linux/usb_ch9.h&gt;</filename> you will find
+    <para>In <filename>&lt;linux/usb/ch9.h&gt;</filename> you will find
     the USB data types defined in chapter 9 of the USB specification.
     These data types are used throughout USB, and in APIs including
     this host side API, gadget APIs, and usbfs.
     </para>
 
-!Iinclude/linux/usb_ch9.h
+!Iinclude/linux/usb/ch9.h
 
     </chapter>
 
@@ -574,7 +574,7 @@ for (;;) {
 #include &lt;asm/byteorder.h&gt;</programlisting>
            The standard USB device model requests, from "Chapter 9" of
            the USB 2.0 specification, are automatically included from
-           the <filename>&lt;linux/usb_ch9.h&gt;</filename> header.
+           the <filename>&lt;linux/usb/ch9.h&gt;</filename> header.
            </para>
 
            <para>Unless noted otherwise, the ioctl requests
diff --git a/Documentation/auxdisplay/cfag12864b b/Documentation/auxdisplay/cfag12864b
new file mode 100644 (file)
index 0000000..3572b98
--- /dev/null
@@ -0,0 +1,105 @@
+       ===================================
+       cfag12864b LCD Driver Documentation
+       ===================================
+
+License:               GPLv2
+Author & Maintainer:   Miguel Ojeda Sandonis <maxextreme@gmail.com>
+Date:                  2006-10-27
+
+
+
+--------
+0. INDEX
+--------
+
+       1. DRIVER INFORMATION
+       2. DEVICE INFORMATION
+       3. WIRING
+       4. USERSPACE PROGRAMMING
+
+
+---------------------
+1. DRIVER INFORMATION
+---------------------
+
+This driver support one cfag12864b display at time.
+
+
+---------------------
+2. DEVICE INFORMATION
+---------------------
+
+Manufacturer:  Crystalfontz
+Device Name:   Crystalfontz 12864b LCD Series
+Device Code:   cfag12864b
+Webpage:       http://www.crystalfontz.com
+Device Webpage:        http://www.crystalfontz.com/products/12864b/
+Type:          LCD (Liquid Crystal Display)
+Width:         128
+Height:                64
+Colors:                2 (B/N)
+Controller:    ks0108
+Controllers:   2
+Pages:         8 each controller
+Addresses:     64 each page
+Data size:     1 byte each address
+Memory size:   2 * 8 * 64 * 1 = 1024 bytes = 1 Kbyte
+
+
+---------
+3. WIRING
+---------
+
+The cfag12864b LCD Series don't have official wiring.
+
+The common wiring is done to the parallel port as shown:
+
+Parallel Port                          cfag12864b
+
+  Name Pin#                            Pin# Name
+
+Strobe ( 1)------------------------------(17) Enable
+Data 0 ( 2)------------------------------( 4) Data 0
+Data 1 ( 3)------------------------------( 5) Data 1
+Data 2 ( 4)------------------------------( 6) Data 2
+Data 3 ( 5)------------------------------( 7) Data 3
+Data 4 ( 6)------------------------------( 8) Data 4
+Data 5 ( 7)------------------------------( 9) Data 5
+Data 6 ( 8)------------------------------(10) Data 6
+Data 7 ( 9)------------------------------(11) Data 7
+       (10)                      [+5v]---( 1) Vdd
+       (11)                      [GND]---( 2) Ground
+       (12)                      [+5v]---(14) Reset
+       (13)                      [GND]---(15) Read / Write
+  Line (14)------------------------------(13) Controller Select 1
+       (15)
+  Init (16)------------------------------(12) Controller Select 2
+Select (17)------------------------------(16) Data / Instruction
+Ground (18)---[GND]              [+5v]---(19) LED +
+Ground (19)---[GND]
+Ground (20)---[GND]              E    A             Values:
+Ground (21)---[GND]       [GND]---[P1]---(18) Vee    · R = Resistor = 22 ohm
+Ground (22)---[GND]                |                 · P1 = Preset = 10 Kohm
+Ground (23)---[GND]       ----   S ------( 3) V0     · P2 = Preset = 1 Kohm
+Ground (24)---[GND]       |  |
+Ground (25)---[GND] [GND]---[P2]---[R]---(20) LED -
+
+
+------------------------
+4. USERSPACE PROGRAMMING
+------------------------
+
+The cfag12864bfb describes a framebuffer device (/dev/fbX).
+
+It has a size of 1024 bytes = 1 Kbyte.
+Each bit represents one pixel. If the bit is high, the pixel will
+turn on. If the pixel is low, the pixel will turn off.
+
+You can use the framebuffer as a file: fopen, fwrite, fclose...
+Although the LCD won't get updated until the next refresh time arrives.
+
+Also, you can mmap the framebuffer: open & mmap, munmap & close...
+which is the best option for most uses.
+
+Check Documentation/auxdisplay/cfag12864b-example.c
+for a real working userspace complete program with usage examples.
diff --git a/Documentation/auxdisplay/cfag12864b-example.c b/Documentation/auxdisplay/cfag12864b-example.c
new file mode 100644 (file)
index 0000000..7bfac35
--- /dev/null
@@ -0,0 +1,282 @@
+/*
+ *    Filename: cfag12864b-example.c
+ *     Version: 0.1.0
+ * Description: cfag12864b LCD userspace example program
+ *     License: GPLv2
+ *
+ *      Author: Copyright (C) Miguel Ojeda Sandonis <maxextreme@gmail.com>
+ *        Date: 2006-10-31
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+/*
+ * ------------------------
+ * start of cfag12864b code
+ * ------------------------
+ */
+
+#include <string.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+
+#define CFAG12864B_WIDTH               (128)
+#define CFAG12864B_HEIGHT              (64)
+#define CFAG12864B_SIZE                        (128 * 64 / 8)
+#define CFAG12864B_BPB                 (8)
+#define CFAG12864B_ADDRESS(x, y)       ((y) * CFAG12864B_WIDTH / \
+                                       CFAG12864B_BPB + (x) / CFAG12864B_BPB)
+#define CFAG12864B_BIT(n)              (((unsigned char) 1) << (n))
+
+#undef CFAG12864B_DOCHECK
+#ifdef CFAG12864B_DOCHECK
+       #define CFAG12864B_CHECK(x, y)          ((x) < CFAG12864B_WIDTH && \
+                                               (y) < CFAG12864B_HEIGHT)
+#else
+       #define CFAG12864B_CHECK(x, y)          (1)
+#endif
+
+int cfag12864b_fd;
+unsigned char * cfag12864b_mem;
+unsigned char cfag12864b_buffer[CFAG12864B_SIZE];
+
+/*
+ * init a cfag12864b framebuffer device
+ *
+ * No error:       return = 0
+ * Unable to open: return = -1
+ * Unable to mmap: return = -2
+ */
+int cfag12864b_init(char *path)
+{
+       cfag12864b_fd = open(path, O_RDWR);
+       if (cfag12864b_fd == -1)
+               return -1;
+
+       cfag12864b_mem = mmap(0, CFAG12864B_SIZE, PROT_READ | PROT_WRITE,
+               MAP_SHARED, cfag12864b_fd, 0);
+       if (cfag12864b_mem == MAP_FAILED) {
+               close(cfag12864b_fd);
+               return -2;
+       }
+
+       return 0;
+}
+
+/*
+ * exit a cfag12864b framebuffer device
+ */
+void cfag12864b_exit(void)
+{
+       munmap(cfag12864b_mem, CFAG12864B_SIZE);
+       close(cfag12864b_fd);
+}
+
+/*
+ * set (x, y) pixel
+ */
+void cfag12864b_set(unsigned char x, unsigned char y)
+{
+       if (CFAG12864B_CHECK(x, y))
+               cfag12864b_buffer[CFAG12864B_ADDRESS(x, y)] |=
+                       CFAG12864B_BIT(x % CFAG12864B_BPB);
+}
+
+/*
+ * unset (x, y) pixel
+ */
+void cfag12864b_unset(unsigned char x, unsigned char y)
+{
+       if (CFAG12864B_CHECK(x, y))
+               cfag12864b_buffer[CFAG12864B_ADDRESS(x, y)] &=
+                       ~CFAG12864B_BIT(x % CFAG12864B_BPB);
+}
+
+/*
+ * is set (x, y) pixel?
+ *
+ * Pixel off: return = 0
+ * Pixel on:  return = 1
+ */
+unsigned char cfag12864b_isset(unsigned char x, unsigned char y)
+{
+       if (CFAG12864B_CHECK(x, y))
+               if (cfag12864b_buffer[CFAG12864B_ADDRESS(x, y)] &
+                       CFAG12864B_BIT(x % CFAG12864B_BPB))
+                       return 1;
+
+       return 0;
+}
+
+/*
+ * not (x, y) pixel
+ */
+void cfag12864b_not(unsigned char x, unsigned char y)
+{
+       if (cfag12864b_isset(x, y))
+               cfag12864b_unset(x, y);
+       else
+               cfag12864b_set(x, y);
+}
+
+/*
+ * fill (set all pixels)
+ */
+void cfag12864b_fill(void)
+{
+       unsigned short i;
+
+       for (i = 0; i < CFAG12864B_SIZE; i++)
+               cfag12864b_buffer[i] = 0xFF;
+}
+
+/*
+ * clear (unset all pixels)
+ */
+void cfag12864b_clear(void)
+{
+       unsigned short i;
+
+       for (i = 0; i < CFAG12864B_SIZE; i++)
+               cfag12864b_buffer[i] = 0;
+}
+
+/*
+ * format a [128*64] matrix
+ *
+ * Pixel off: src[i] = 0
+ * Pixel on:  src[i] > 0
+ */
+void cfag12864b_format(unsigned char * matrix)
+{
+       unsigned char i, j, n;
+
+       for (i = 0; i < CFAG12864B_HEIGHT; i++)
+       for (j = 0; j < CFAG12864B_WIDTH / CFAG12864B_BPB; j++) {
+               cfag12864b_buffer[i * CFAG12864B_WIDTH / CFAG12864B_BPB +
+                       j] = 0;
+               for (n = 0; n < CFAG12864B_BPB; n++)
+                       if (matrix[i * CFAG12864B_WIDTH +
+                               j * CFAG12864B_BPB + n])
+                               cfag12864b_buffer[i * CFAG12864B_WIDTH /
+                                       CFAG12864B_BPB + j] |=
+                                       CFAG12864B_BIT(n);
+       }
+}
+
+/*
+ * blit buffer to lcd
+ */
+void cfag12864b_blit(void)
+{
+       memcpy(cfag12864b_mem, cfag12864b_buffer, CFAG12864B_SIZE);
+}
+
+/*
+ * ----------------------
+ * end of cfag12864b code
+ * ----------------------
+ */
+
+#include <stdio.h>
+#include <string.h>
+
+#define EXAMPLES       6
+
+void example(unsigned char n)
+{
+       unsigned short i, j;
+       unsigned char matrix[CFAG12864B_WIDTH * CFAG12864B_HEIGHT];
+
+       if (n > EXAMPLES)
+               return;
+
+       printf("Example %i/%i - ", n, EXAMPLES);
+
+       switch (n) {
+       case 1:
+               printf("Draw points setting bits");
+               cfag12864b_clear();
+               for (i = 0; i < CFAG12864B_WIDTH; i += 2)
+                       for (j = 0; j < CFAG12864B_HEIGHT; j += 2)
+                               cfag12864b_set(i, j);
+               break;
+
+       case 2:
+               printf("Clear the LCD");
+               cfag12864b_clear();
+               break;
+
+       case 3:
+               printf("Draw rows formatting a [128*64] matrix");
+               memset(matrix, 0, CFAG12864B_WIDTH * CFAG12864B_HEIGHT);
+               for (i = 0; i < CFAG12864B_WIDTH; i++)
+                       for (j = 0; j < CFAG12864B_HEIGHT; j += 2)
+                               matrix[j * CFAG12864B_WIDTH + i] = 1;
+               cfag12864b_format(matrix);
+               break;
+
+       case 4:
+               printf("Fill the lcd");
+               cfag12864b_fill();
+               break;
+
+       case 5:
+               printf("Draw columns unsetting bits");
+               for (i = 0; i < CFAG12864B_WIDTH; i += 2)
+                       for (j = 0; j < CFAG12864B_HEIGHT; j++)
+                               cfag12864b_unset(i, j);
+               break;
+
+       case 6:
+               printf("Do negative not-ing all bits");
+               for (i = 0; i < CFAG12864B_WIDTH; i++)
+                       for (j = 0; j < CFAG12864B_HEIGHT; j ++)
+                               cfag12864b_not(i, j);
+               break;
+       }
+
+       puts(" - [Press Enter]");
+}
+
+int main(int argc, char *argv[])
+{
+       unsigned char n;
+
+       if (argc != 2) {
+               printf(
+                       "Sintax:  %s fbdev\n"
+                       "Usually: /dev/fb0, /dev/fb1...\n", argv[0]);
+               return -1;
+       }
+
+       if (cfag12864b_init(argv[1])) {
+               printf("Can't init %s fbdev\n", argv[1]);
+               return -2;
+       }
+
+       for (n = 1; n <= EXAMPLES; n++) {
+               example(n);
+               cfag12864b_blit();
+               while (getchar() != '\n');
+       }
+
+       cfag12864b_exit();
+
+       return 0;
+}
diff --git a/Documentation/auxdisplay/ks0108 b/Documentation/auxdisplay/ks0108
new file mode 100644 (file)
index 0000000..92b03b6
--- /dev/null
@@ -0,0 +1,55 @@
+       ==========================================
+       ks0108 LCD Controller Driver Documentation
+       ==========================================
+
+License:               GPLv2
+Author & Maintainer:   Miguel Ojeda Sandonis <maxextreme@gmail.com>
+Date:                  2006-10-27
+
+
+
+--------
+0. INDEX
+--------
+
+       1. DRIVER INFORMATION
+       2. DEVICE INFORMATION
+       3. WIRING
+
+
+---------------------
+1. DRIVER INFORMATION
+---------------------
+
+This driver support the ks0108 LCD controller.
+
+
+---------------------
+2. DEVICE INFORMATION
+---------------------
+
+Manufacturer:  Samsung
+Device Name:   KS0108 LCD Controller
+Device Code:   ks0108
+Webpage:       -
+Device Webpage:        -
+Type:          LCD Controller (Liquid Crystal Display Controller)
+Width:         64
+Height:                64
+Colors:                2 (B/N)
+Pages:         8
+Addresses:     64 each page
+Data size:     1 byte each address
+Memory size:   8 * 64 * 1 = 512 bytes
+
+
+---------
+3. WIRING
+---------
+
+The driver supports data parallel port wiring.
+
+If you aren't building LCD related hardware, you should check
+your LCD specific wiring information in the same folder.
+
+For example, check Documentation/auxdisplay/cfag12864b.
index 7715d2247c4de4cf01045a7f46ce9ce5bf36a7a4..cf1f8126991c00fe5f904631d0471821bf958515 100644 (file)
@@ -93,7 +93,7 @@ Notes
 Using the pktcdvd sysfs interface
 ---------------------------------
 
-Since Linux 2.6.19, the pktcdvd module has a sysfs interface
+Since Linux 2.6.20, the pktcdvd module has a sysfs interface
 and can be controlled by it. For example the "pktcdvd" tool uses
 this interface. (see http://people.freenet.de/BalaGi#pktcdvd )
 
index 5a03a2801d676f4308566b4384b6264a9b6cebc4..e41a79aa71ce30df467342cfbccdedde71a78880 100644 (file)
@@ -193,6 +193,7 @@ Original developers of the crypto algorithms:
   Kartikey Mahendra Bhatt (CAST6)
   Jon Oberheide (ARC4)
   Jouni Malinen (Michael MIC)
+  NTT(Nippon Telegraph and Telephone Corporation) (Camellia)
 
 SHA1 algorithm contributors:
   Jean-Francois Dive
@@ -246,6 +247,9 @@ Tiger algorithm contributors:
 VIA PadLock contributors:
   Michal Ludvig
 
+Camellia algorithm contributors:
+  NTT(Nippon Telegraph and Telephone Corporation) (Camellia)
+
 Generic scatterwalk code by Adam J. Richter <adam@yggdrasil.com>
 
 Please send any credits updates or corrections to:
diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt
new file mode 100644 (file)
index 0000000..5163b85
--- /dev/null
@@ -0,0 +1,268 @@
+Devres - Managed Device Resource
+================================
+
+Tejun Heo      <teheo@suse.de>
+
+First draft    10 January 2007
+
+
+1. Intro                       : Huh? Devres?
+2. Devres                      : Devres in a nutshell
+3. Devres Group                        : Group devres'es and release them together
+4. Details                     : Life time rules, calling context, ...
+5. Overhead                    : How much do we have to pay for this?
+6. List of managed interfaces  : Currently implemented managed interfaces
+
+
+  1. Intro
+  --------
+
+devres came up while trying to convert libata to use iomap.  Each
+iomapped address should be kept and unmapped on driver detach.  For
+example, a plain SFF ATA controller (that is, good old PCI IDE) in
+native mode makes use of 5 PCI BARs and all of them should be
+maintained.
+
+As with many other device drivers, libata low level drivers have
+sufficient bugs in ->remove and ->probe failure path.  Well, yes,
+that's probably because libata low level driver developers are lazy
+bunch, but aren't all low level driver developers?  After spending a
+day fiddling with braindamaged hardware with no document or
+braindamaged document, if it's finally working, well, it's working.
+
+For one reason or another, low level drivers don't receive as much
+attention or testing as core code, and bugs on driver detach or
+initilaization failure doesn't happen often enough to be noticeable.
+Init failure path is worse because it's much less travelled while
+needs to handle multiple entry points.
+
+So, many low level drivers end up leaking resources on driver detach
+and having half broken failure path implementation in ->probe() which
+would leak resources or even cause oops when failure occurs.  iomap
+adds more to this mix.  So do msi and msix.
+
+
+  2. Devres
+  ---------
+
+devres is basically linked list of arbitrarily sized memory areas
+associated with a struct device.  Each devres entry is associated with
+a release function.  A devres can be released in several ways.  No
+matter what, all devres entries are released on driver detach.  On
+release, the associated release function is invoked and then the
+devres entry is freed.
+
+Managed interface is created for resources commonly used by device
+drivers using devres.  For example, coherent DMA memory is acquired
+using dma_alloc_coherent().  The managed version is called
+dmam_alloc_coherent().  It is identical to dma_alloc_coherent() except
+for the DMA memory allocated using it is managed and will be
+automatically released on driver detach.  Implementation looks like
+the following.
+
+  struct dma_devres {
+       size_t          size;
+       void            *vaddr;
+       dma_addr_t      dma_handle;
+  };
+
+  static void dmam_coherent_release(struct device *dev, void *res)
+  {
+       struct dma_devres *this = res;
+
+       dma_free_coherent(dev, this->size, this->vaddr, this->dma_handle);
+  }
+
+  dmam_alloc_coherent(dev, size, dma_handle, gfp)
+  {
+       struct dma_devres *dr;
+       void *vaddr;
+
+       dr = devres_alloc(dmam_coherent_release, sizeof(*dr), gfp);
+       ...
+
+       /* alloc DMA memory as usual */
+       vaddr = dma_alloc_coherent(...);
+       ...
+
+       /* record size, vaddr, dma_handle in dr */
+       dr->vaddr = vaddr;
+       ...
+
+       devres_add(dev, dr);
+
+       return vaddr;
+  }
+
+If a driver uses dmam_alloc_coherent(), the area is guaranteed to be
+freed whether initialization fails half-way or the device gets
+detached.  If most resources are acquired using managed interface, a
+driver can have much simpler init and exit code.  Init path basically
+looks like the following.
+
+  my_init_one()
+  {
+       struct mydev *d;
+
+       d = devm_kzalloc(dev, sizeof(*d), GFP_KERNEL);
+       if (!d)
+               return -ENOMEM;
+
+       d->ring = dmam_alloc_coherent(...);
+       if (!d->ring)
+               return -ENOMEM;
+
+       if (check something)
+               return -EINVAL;
+       ...
+
+       return register_to_upper_layer(d);
+  }
+
+And exit path,
+
+  my_remove_one()
+  {
+       unregister_from_upper_layer(d);
+       shutdown_my_hardware();
+  }
+
+As shown above, low level drivers can be simplified a lot by using
+devres.  Complexity is shifted from less maintained low level drivers
+to better maintained higher layer.  Also, as init failure path is
+shared with exit path, both can get more testing.
+
+
+  3. Devres group
+  ---------------
+
+Devres entries can be grouped using devres group.  When a group is
+released, all contained normal devres entries and properly nested
+groups are released.  One usage is to rollback series of acquired
+resources on failure.  For example,
+
+  if (!devres_open_group(dev, NULL, GFP_KERNEL))
+       return -ENOMEM;
+
+  acquire A;
+  if (failed)
+       goto err;
+
+  acquire B;
+  if (failed)
+       goto err;
+  ...
+
+  devres_remove_group(dev, NULL);
+  return 0;
+
+ err:
+  devres_release_group(dev, NULL);
+  return err_code;
+
+As resource acquision failure usually means probe failure, constructs
+like above are usually useful in midlayer driver (e.g. libata core
+layer) where interface function shouldn't have side effect on failure.
+For LLDs, just returning error code suffices in most cases.
+
+Each group is identified by void *id.  It can either be explicitly
+specified by @id argument to devres_open_group() or automatically
+created by passing NULL as @id as in the above example.  In both
+cases, devres_open_group() returns the group's id.  The returned id
+can be passed to other devres functions to select the target group.
+If NULL is given to those functions, the latest open group is
+selected.
+
+For example, you can do something like the following.
+
+  int my_midlayer_create_something()
+  {
+       if (!devres_open_group(dev, my_midlayer_create_something, GFP_KERNEL))
+               return -ENOMEM;
+
+       ...
+
+       devres_close_group(dev, my_midlayer_something);
+       return 0;
+  }
+
+  void my_midlayer_destroy_something()
+  {
+       devres_release_group(dev, my_midlayer_create_soemthing);
+  }
+
+
+  4. Details
+  ----------
+
+Lifetime of a devres entry begins on devres allocation and finishes
+when it is released or destroyed (removed and freed) - no reference
+counting.
+
+devres core guarantees atomicity to all basic devres operations and
+has support for single-instance devres types (atomic
+lookup-and-add-if-not-found).  Other than that, synchronizing
+concurrent accesses to allocated devres data is caller's
+responsibility.  This is usually non-issue because bus ops and
+resource allocations already do the job.
+
+For an example of single-instance devres type, read pcim_iomap_table()
+in lib/iomap.c.
+
+All devres interface functions can be called without context if the
+right gfp mask is given.
+
+
+  5. Overhead
+  -----------
+
+Each devres bookkeeping info is allocated together with requested data
+area.  With debug option turned off, bookkeeping info occupies 16
+bytes on 32bit machines and 24 bytes on 64bit (three pointers rounded
+up to ull alignment).  If singly linked list is used, it can be
+reduced to two pointers (8 bytes on 32bit, 16 bytes on 64bit).
+
+Each devres group occupies 8 pointers.  It can be reduced to 6 if
+singly linked list is used.
+
+Memory space overhead on ahci controller with two ports is between 300
+and 400 bytes on 32bit machine after naive conversion (we can
+certainly invest a bit more effort into libata core layer).
+
+
+  6. List of managed interfaces
+  -----------------------------
+
+IO region
+  devm_request_region()
+  devm_request_mem_region()
+  devm_release_region()
+  devm_release_mem_region()
+
+IRQ
+  devm_request_irq()
+  devm_free_irq()
+
+DMA
+  dmam_alloc_coherent()
+  dmam_free_coherent()
+  dmam_alloc_noncoherent()
+  dmam_free_noncoherent()
+  dmam_declare_coherent_memory()
+  dmam_pool_create()
+  dmam_pool_destroy()
+
+PCI
+  pcim_enable_device() : after success, all PCI ops become managed
+  pcim_pin_device()    : keep PCI device enabled after release
+
+IOMAP
+  devm_ioport_map()
+  devm_ioport_unmap()
+  devm_ioremap()
+  devm_ioremap_nocache()
+  devm_iounmap()
+  pcim_iomap()
+  pcim_iounmap()
+  pcim_iomap_table()   : array of mapped addresses indexed by BAR
+  pcim_iomap_regions() : do request_region() and iomap() on multiple BARs
index 2dc5e5da8f88c69360e9f5e85b38861cd932f308..8247a4b79d09e73775cb139de8dc2fedde44f86a 100644 (file)
@@ -50,22 +50,6 @@ Who: Dan Dennedy <dan@dennedy.org>, Stefan Richter <stefanr@s5r6.in-berlin.de>
 
 ---------------------------
 
-What:  ieee1394 core's unused exports (CONFIG_IEEE1394_EXPORT_FULL_API)
-When:  January 2007
-Why:   There are no projects known to use these exported symbols, except
-       dfg1394 (uses one symbol whose functionality is core-internal now).
-Who:   Stefan Richter <stefanr@s5r6.in-berlin.de>
-
----------------------------
-
-What:  ieee1394's *_oui sysfs attributes (CONFIG_IEEE1394_OUI_DB)
-When:  January 2007
-Files: drivers/ieee1394/: oui.db, oui2c.sh
-Why:   big size, little value
-Who:   Stefan Richter <stefanr@s5r6.in-berlin.de>
-
----------------------------
-
 What:  Video4Linux API 1 ioctls and video_decoder.h from Video devices.
 When:  December 2006
 Why:   V4L1 AP1 was replaced by V4L2 API. during migration from 2.4 to 2.6
@@ -186,18 +170,6 @@ Who:       Greg Kroah-Hartman <gregkh@suse.de>
 
 ---------------------------
 
-What:  find_trylock_page
-When:  January 2007
-Why:   The interface no longer has any callers left in the kernel. It
-       is an odd interface (compared with other find_*_page functions), in
-       that it does not take a refcount to the page, only the page lock.
-       It should be replaced with find_get_page or find_lock_page if possible.
-       This feature removal can be reevaluated if users of the interface
-       cannot cleanly use something else.
-Who:   Nick Piggin <npiggin@suse.de>
-
----------------------------
-
 What:  Interrupt only SA_* flags
 When:  Januar 2007
 Why:   The interrupt related SA_* flags are replaced by IRQF_* to move them
@@ -243,6 +215,13 @@ Who:       Jean Delvare <khali@linux-fr.org>,
 
 ---------------------------
 
+What:  drivers depending on OBSOLETE_OSS
+When:  options in 2.6.22, code in 2.6.24
+Why:   OSS drivers with ALSA replacements
+Who:   Adrian Bunk <bunk@stusta.de>
+
+---------------------------
+
 What:  IPv4 only connection tracking/NAT/helpers
 When:  2.6.22
 Why:   The new layer 3 independant connection tracking replaces the old
index d6788dae034948ce35eab71bfa80e013217864ac..7fbb6ffe576910695a5aecabd21c1c428497304f 100644 (file)
@@ -157,7 +157,7 @@ TBD(curr. line MT:/API/)
   channel management functions:
 
     relay_open(base_filename, parent, subbuf_size, n_subbufs,
-               callbacks)
+               callbacks, private_data)
     relay_close(chan)
     relay_flush(chan)
     relay_reset(chan)
@@ -251,7 +251,7 @@ static struct rchan_callbacks relay_callbacks =
 
 And an example relay_open() invocation using them:
 
-  chan = relay_open("cpu", NULL, SUBBUF_SIZE, N_SUBBUFS, &relay_callbacks);
+  chan = relay_open("cpu", NULL, SUBBUF_SIZE, N_SUBBUFS, &relay_callbacks, NULL);
 
 If the create_buf_file() callback fails, or isn't defined, channel
 creation and thus relay_open() will fail.
@@ -289,6 +289,11 @@ they use the proper locking for such a buffer, either by wrapping
 writes in a spinlock, or by copying a write function from relay.h and
 creating a local version that internally does the proper locking.
 
+The private_data passed into relay_open() allows clients to associate
+user-defined data with a channel, and is immediately available
+(including in create_buf_file()) via chan->private_data or
+buf->chan->private_data.
+
 Channel 'modes'
 ---------------
 
index 5a8bd5bd88eff17f02421165fff6811674e0a53f..8f750c0efed5ed0adc5329ff5bd6a5e17d5c9113 100644 (file)
@@ -94,8 +94,7 @@ Code  Seq#    Include File            Comments
 'L'    00-1F   linux/loop.h
 'L'    E0-FF   linux/ppdd.h            encrypted disk device driver
                                        <http://linux01.gwdg.de/~alatham/ppdd.html>
-'M'    all     linux/soundcard.h       conflict!
-'M'    00-1F   linux/isicom.h          conflict!
+'M'    all     linux/soundcard.h
 'N'    00-1F   drivers/usb/scanner.h
 'P'    all     linux/soundcard.h
 'Q'    all     linux/soundcard.h
index 284e7e198e93a288624c6258ff30294c6aacf8d6..2075c0658bf547d04d36fa1b6a59a2c7a48d50b8 100644 (file)
@@ -101,16 +101,20 @@ The format of the block comment is like this:
 
 /**
  * function_name(:)? (- short description)?
-(* @parameterx: (description of parameter x)?)*
+(* @parameterx(space)*: (description of parameter x)?)*
 (* a blank line)?
  * (Description:)? (Description of function)?
  * (section header: (section description)? )*
 (*)?*/
 
-The short function description cannot be multiline, but the other
-descriptions can be (and they can contain blank lines). Avoid putting a
-spurious blank line after the function name, or else the description will
-be repeated!
+The short function description ***cannot be multiline***, but the other
+descriptions can be (and they can contain blank lines).  If you continue
+that initial short description onto a second line, that second line will
+appear further down at the beginning of the description section, which is
+almost certainly not what you had in mind.
+
+Avoid putting a spurious blank line after the function name, or else the
+description will be repeated!
 
 All descriptive text is further processed, scanning for the following special
 patterns, which are highlighted appropriately.
@@ -121,6 +125,31 @@ patterns, which are highlighted appropriately.
 '@parameter' - name of a parameter
 '%CONST' - name of a constant.
 
+NOTE 1:  The multi-line descriptive text you provide does *not* recognize
+line breaks, so if you try to format some text nicely, as in:
+
+  Return codes
+    0 - cool
+    1 - invalid arg
+    2 - out of memory
+
+this will all run together and produce:
+
+  Return codes 0 - cool 1 - invalid arg 2 - out of memory
+
+NOTE 2:  If the descriptive text you provide has lines that begin with
+some phrase followed by a colon, each of those phrases will be taken as
+a new section heading, which means you should similarly try to avoid text
+like:
+
+  Return codes:
+    0: cool
+    1: invalid arg
+    2: out of memory
+
+every line of which would start a new section.  Again, probably not
+what you were after.
+
 Take a look around the source tree for examples.
 
 
index 25d2985171044712e864035fc5201147ba96cdb8..d25acd51e18105aca3f3d0811d37f39aa8d3119c 100644 (file)
@@ -1396,6 +1396,8 @@ and is between 256 and 4096 characters. It is defined in the file
                        in <PAGE_SIZE> units (needed only for swap files).
                        See  Documentation/power/swsusp-and-swap-files.txt
 
+       retain_initrd   [RAM] Keep initrd memory after extraction
+
        rhash_entries=  [KNL,NET]
                        Set number of hash buckets for route cache
 
diff --git a/Documentation/local_ops.txt b/Documentation/local_ops.txt
new file mode 100644 (file)
index 0000000..b0aca07
--- /dev/null
@@ -0,0 +1,163 @@
+            Semantics and Behavior of Local Atomic Operations
+
+                           Mathieu Desnoyers
+
+
+       This document explains the purpose of the local atomic operations, how
+to implement them for any given architecture and shows how they can be used
+properly. It also stresses on the precautions that must be taken when reading
+those local variables across CPUs when the order of memory writes matters.
+
+
+
+* Purpose of local atomic operations
+
+Local atomic operations are meant to provide fast and highly reentrant per CPU
+counters. They minimize the performance cost of standard atomic operations by
+removing the LOCK prefix and memory barriers normally required to synchronize
+across CPUs.
+
+Having fast per CPU atomic counters is interesting in many cases : it does not
+require disabling interrupts to protect from interrupt handlers and it permits
+coherent counters in NMI handlers. It is especially useful for tracing purposes
+and for various performance monitoring counters.
+
+Local atomic operations only guarantee variable modification atomicity wrt the
+CPU which owns the data. Therefore, care must taken to make sure that only one
+CPU writes to the local_t data. This is done by using per cpu data and making
+sure that we modify it from within a preemption safe context. It is however
+permitted to read local_t data from any CPU : it will then appear to be written
+out of order wrt other memory writes on the owner CPU.
+
+
+* Implementation for a given architecture
+
+It can be done by slightly modifying the standard atomic operations : only
+their UP variant must be kept. It typically means removing LOCK prefix (on
+i386 and x86_64) and any SMP sychronization barrier. If the architecture does
+not have a different behavior between SMP and UP, including asm-generic/local.h
+in your archtecture's local.h is sufficient.
+
+The local_t type is defined as an opaque signed long by embedding an
+atomic_long_t inside a structure. This is made so a cast from this type to a
+long fails. The definition looks like :
+
+typedef struct { atomic_long_t a; } local_t;
+
+
+* How to use local atomic operations
+
+#include <linux/percpu.h>
+#include <asm/local.h>
+
+static DEFINE_PER_CPU(local_t, counters) = LOCAL_INIT(0);
+
+
+* Counting
+
+Counting is done on all the bits of a signed long.
+
+In preemptible context, use get_cpu_var() and put_cpu_var() around local atomic
+operations : it makes sure that preemption is disabled around write access to
+the per cpu variable. For instance :
+
+       local_inc(&get_cpu_var(counters));
+       put_cpu_var(counters);
+
+If you are already in a preemption-safe context, you can directly use
+__get_cpu_var() instead.
+
+       local_inc(&__get_cpu_var(counters));
+
+
+
+* Reading the counters
+
+Those local counters can be read from foreign CPUs to sum the count. Note that
+the data seen by local_read across CPUs must be considered to be out of order
+relatively to other memory writes happening on the CPU that owns the data.
+
+       long sum = 0;
+       for_each_online_cpu(cpu)
+               sum += local_read(&per_cpu(counters, cpu));
+
+If you want to use a remote local_read to synchronize access to a resource
+between CPUs, explicit smp_wmb() and smp_rmb() memory barriers must be used
+respectively on the writer and the reader CPUs. It would be the case if you use
+the local_t variable as a counter of bytes written in a buffer : there should
+be a smp_wmb() between the buffer write and the counter increment and also a
+smp_rmb() between the counter read and the buffer read.
+
+
+Here is a sample module which implements a basic per cpu counter using local.h.
+
+--- BEGIN ---
+/* test-local.c
+ *
+ * Sample module for local.h usage.
+ */
+
+
+#include <asm/local.h>
+#include <linux/module.h>
+#include <linux/timer.h>
+
+static DEFINE_PER_CPU(local_t, counters) = LOCAL_INIT(0);
+
+static struct timer_list test_timer;
+
+/* IPI called on each CPU. */
+static void test_each(void *info)
+{
+       /* Increment the counter from a non preemptible context */
+       printk("Increment on cpu %d\n", smp_processor_id());
+       local_inc(&__get_cpu_var(counters));
+
+       /* This is what incrementing the variable would look like within a
+        * preemptible context (it disables preemption) :
+        *
+        * local_inc(&get_cpu_var(counters));
+        * put_cpu_var(counters);
+        */
+}
+
+static void do_test_timer(unsigned long data)
+{
+       int cpu;
+
+       /* Increment the counters */
+       on_each_cpu(test_each, NULL, 0, 1);
+       /* Read all the counters */
+       printk("Counters read from CPU %d\n", smp_processor_id());
+       for_each_online_cpu(cpu) {
+               printk("Read : CPU %d, count %ld\n", cpu,
+                       local_read(&per_cpu(counters, cpu)));
+       }
+       del_timer(&test_timer);
+       test_timer.expires = jiffies + 1000;
+       add_timer(&test_timer);
+}
+
+static int __init test_init(void)
+{
+       /* initialize the timer that will increment the counter */
+       init_timer(&test_timer);
+       test_timer.function = do_test_timer;
+       test_timer.expires = jiffies + 1;
+       add_timer(&test_timer);
+
+       return 0;
+}
+
+static void __exit test_exit(void)
+{
+       del_timer_sync(&test_timer);
+}
+
+module_init(test_init);
+module_exit(test_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Mathieu Desnoyers");
+MODULE_DESCRIPTION("Local Atomic Ops");
+--- END ---
diff --git a/Documentation/rbtree.txt b/Documentation/rbtree.txt
new file mode 100644 (file)
index 0000000..7224459
--- /dev/null
@@ -0,0 +1,192 @@
+Red-black Trees (rbtree) in Linux
+January 18, 2007
+Rob Landley <rob@landley.net>
+=============================
+
+What are red-black trees, and what are they for?
+------------------------------------------------
+
+Red-black trees are a type of self-balancing binary search tree, used for
+storing sortable key/value data pairs.  This differs from radix trees (which
+are used to efficiently store sparse arrays and thus use long integer indexes
+to insert/access/delete nodes) and hash tables (which are not kept sorted to
+be easily traversed in order, and must be tuned for a specific size and
+hash function where rbtrees scale gracefully storing arbitrary keys).
+
+Red-black trees are similar to AVL trees, but provide faster real-time bounded
+worst case performance for insertion and deletion (at most two rotations and
+three rotations, respectively, to balance the tree), with slightly slower
+(but still O(log n)) lookup time.
+
+To quote Linux Weekly News:
+
+    There are a number of red-black trees in use in the kernel.
+    The anticipatory, deadline, and CFQ I/O schedulers all employ
+    rbtrees to track requests; the packet CD/DVD driver does the same.
+    The high-resolution timer code uses an rbtree to organize outstanding
+    timer requests.  The ext3 filesystem tracks directory entries in a
+    red-black tree.  Virtual memory areas (VMAs) are tracked with red-black
+    trees, as are epoll file descriptors, cryptographic keys, and network
+    packets in the "hierarchical token bucket" scheduler.
+
+This document covers use of the Linux rbtree implementation.  For more
+information on the nature and implementation of Red Black Trees,  see:
+
+  Linux Weekly News article on red-black trees
+    http://lwn.net/Articles/184495/
+
+  Wikipedia entry on red-black trees
+    http://en.wikipedia.org/wiki/Red-black_tree
+
+Linux implementation of red-black trees
+---------------------------------------
+
+Linux's rbtree implementation lives in the file "lib/rbtree.c".  To use it,
+"#include <linux/rbtree.h>".
+
+The Linux rbtree implementation is optimized for speed, and thus has one
+less layer of indirection (and better cache locality) than more traditional
+tree implementations.  Instead of using pointers to separate rb_node and data
+structures, each instance of struct rb_node is embedded in the data structure
+it organizes.  And instead of using a comparison callback function pointer,
+users are expected to write their own tree search and insert functions
+which call the provided rbtree functions.  Locking is also left up to the
+user of the rbtree code.
+
+Creating a new rbtree
+---------------------
+
+Data nodes in an rbtree tree are structures containing a struct rb_node member:
+
+  struct mytype {
+       struct rb_node node;
+       char *keystring;
+  };
+
+When dealing with a pointer to the embedded struct rb_node, the containing data
+structure may be accessed with the standard container_of() macro.  In addition,
+individual members may be accessed directly via rb_entry(node, type, member).
+
+At the root of each rbtree is an rb_root structure, which is initialized to be
+empty via:
+
+  struct rb_root mytree = RB_ROOT;
+
+Searching for a value in an rbtree
+----------------------------------
+
+Writing a search function for your tree is fairly straightforward: start at the
+root, compare each value, and follow the left or right branch as necessary.
+
+Example:
+
+  struct mytype *my_search(struct rb_root *root, char *string)
+  {
+       struct rb_node *node = root->rb_node;
+
+       while (node) {
+               struct mytype *data = container_of(node, struct mytype, node);
+               int result;
+
+               result = strcmp(string, data->keystring);
+
+               if (result < 0)
+                       node = node->rb_left;
+               else if (result > 0)
+                       node = node->rb_right;
+               else
+                       return data;
+       }
+       return NULL;
+  }
+
+Inserting data into an rbtree
+-----------------------------
+
+Inserting data in the tree involves first searching for the place to insert the
+new node, then inserting the node and rebalancing ("recoloring") the tree.
+
+The search for insertion differs from the previous search by finding the
+location of the pointer on which to graft the new node.  The new node also
+needs a link to its parent node for rebalancing purposes.
+
+Example:
+
+  int my_insert(struct rb_root *root, struct mytype *data)
+  {
+       struct rb_node **new = &(root->rb_node), *parent = NULL;
+
+       /* Figure out where to put new node */
+       while (*new) {
+               struct mytype *this = container_of(*new, struct mytype, node);
+               int result = strcmp(data->keystring, this->keystring);
+
+               parent = *new;
+               if (result < 0)
+                       new = &((*new)->rb_left);
+               else if (result > 0)
+                       new = &((*new)->rb_right);
+               else
+                       return FALSE;
+       }
+
+       /* Add new node and rebalance tree. */
+       rb_link_node(data->node, parent, new);
+       rb_insert_color(data->node, root);
+
+       return TRUE;
+  }
+
+Removing or replacing existing data in an rbtree
+------------------------------------------------
+
+To remove an existing node from a tree, call:
+
+  void rb_erase(struct rb_node *victim, struct rb_root *tree);
+
+Example:
+
+  struct mytype *data = mysearch(mytree, "walrus");
+
+  if (data) {
+       rb_erase(data->node, mytree);
+       myfree(data);
+  }
+
+To replace an existing node in a tree with a new one with the same key, call:
+
+  void rb_replace_node(struct rb_node *old, struct rb_node *new,
+                       struct rb_root *tree);
+
+Replacing a node this way does not re-sort the tree: If the new node doesn't
+have the same key as the old node, the rbtree will probably become corrupted.
+
+Iterating through the elements stored in an rbtree (in sort order)
+------------------------------------------------------------------
+
+Four functions are provided for iterating through an rbtree's contents in
+sorted order.  These work on arbitrary trees, and should not need to be
+modified or wrapped (except for locking purposes):
+
+  struct rb_node *rb_first(struct rb_root *tree);
+  struct rb_node *rb_last(struct rb_root *tree);
+  struct rb_node *rb_next(struct rb_node *node);
+  struct rb_node *rb_prev(struct rb_node *node);
+
+To start iterating, call rb_first() or rb_last() with a pointer to the root
+of the tree, which will return a pointer to the node structure contained in
+the first or last element in the tree.  To continue, fetch the next or previous
+node by calling rb_next() or rb_prev() on the current node.  This will return
+NULL when there are no more nodes left.
+
+The iterator functions return a pointer to the embedded struct rb_node, from
+which the containing data structure may be accessed with the container_of()
+macro, and individual members may be accessed directly via
+rb_entry(node, type, member).
+
+Example:
+
+  struct rb_node *node;
+  for (node = rb_first(&mytree); node; node = rb_next(node))
+       printk("key=%s\n", rb_entry(node, int, keystring));
+
index 7cf1ec5bcdd3b37854ec34ebc085cd3be4532ee7..1ef6bb88cd0003ad05a0d813533689e130a72002 100644 (file)
@@ -149,7 +149,7 @@ RTC class framework, but can't be supported by the older driver.
        is connected to an IRQ line, it can often issue an alarm IRQ up to
        24 hours in the future.
 
-    *  RTC_WKALM_SET, RTC_WKALM_READ ... RTCs that can issue alarms beyond
+    *  RTC_WKALM_SET, RTC_WKALM_RD ... RTCs that can issue alarms beyond
        the next 24 hours use a slightly more powerful API, which supports
        setting the longer alarm time and enabling its IRQ using a single
        request (using the same model as EFI firmware).
@@ -167,6 +167,28 @@ Linux out of a low power sleep state (or hibernation) back to a fully
 operational state.  For example, a system could enter a deep power saving
 state until it's time to execute some scheduled tasks.
 
+Note that many of these ioctls need not actually be implemented by your
+driver.  The common rtc-dev interface handles many of these nicely if your
+driver returns ENOIOCTLCMD.  Some common examples:
+
+    *  RTC_RD_TIME, RTC_SET_TIME: the read_time/set_time functions will be
+       called with appropriate values.
+
+    *  RTC_ALM_SET, RTC_ALM_READ, RTC_WKALM_SET, RTC_WKALM_RD: the
+       set_alarm/read_alarm functions will be called.  To differentiate
+       between the ALM and WKALM, check the larger fields of the rtc_wkalrm
+       struct (like tm_year).  These will be set to -1 when using ALM and
+       will be set to proper values when using WKALM.
+
+    *  RTC_IRQP_SET, RTC_IRQP_READ: the irq_set_freq function will be called
+       to set the frequency while the framework will handle the read for you
+       since the frequency is stored in the irq_freq member of the rtc_device
+       structure.  Also make sure you set the max_user_freq member in your
+       initialization routines so the framework can sanity check the user
+       input for you.
+
+If all else fails, check out the rtc-test.c driver!
+
 
 -------------------- 8< ---------------- 8< -----------------------------
 
@@ -237,7 +259,7 @@ int main(int argc, char **argv)
                                "\n...Update IRQs not supported.\n");
                        goto test_READ;
                }
-               perror("ioctl");
+               perror("RTC_UIE_ON ioctl");
                exit(errno);
        }
 
@@ -284,7 +306,7 @@ int main(int argc, char **argv)
        /* Turn off update interrupts */
        retval = ioctl(fd, RTC_UIE_OFF, 0);
        if (retval == -1) {
-               perror("ioctl");
+               perror("RTC_UIE_OFF ioctl");
                exit(errno);
        }
 
@@ -292,7 +314,7 @@ test_READ:
        /* Read the RTC time/date */
        retval = ioctl(fd, RTC_RD_TIME, &rtc_tm);
        if (retval == -1) {
-               perror("ioctl");
+               perror("RTC_RD_TIME ioctl");
                exit(errno);
        }
 
@@ -320,14 +342,14 @@ test_READ:
                                "\n...Alarm IRQs not supported.\n");
                        goto test_PIE;
                }
-               perror("ioctl");
+               perror("RTC_ALM_SET ioctl");
                exit(errno);
        }
 
        /* Read the current alarm settings */
        retval = ioctl(fd, RTC_ALM_READ, &rtc_tm);
        if (retval == -1) {
-               perror("ioctl");
+               perror("RTC_ALM_READ ioctl");
                exit(errno);
        }
 
@@ -337,7 +359,7 @@ test_READ:
        /* Enable alarm interrupts */
        retval = ioctl(fd, RTC_AIE_ON, 0);
        if (retval == -1) {
-               perror("ioctl");
+               perror("RTC_AIE_ON ioctl");
                exit(errno);
        }
 
@@ -355,7 +377,7 @@ test_READ:
        /* Disable alarm interrupts */
        retval = ioctl(fd, RTC_AIE_OFF, 0);
        if (retval == -1) {
-               perror("ioctl");
+               perror("RTC_AIE_OFF ioctl");
                exit(errno);
        }
 
@@ -368,7 +390,7 @@ test_PIE:
                        fprintf(stderr, "\nNo periodic IRQ support\n");
                        return 0;
                }
-               perror("ioctl");
+               perror("RTC_IRQP_READ ioctl");
                exit(errno);
        }
        fprintf(stderr, "\nPeriodic IRQ rate is %ldHz.\n", tmp);
@@ -387,7 +409,7 @@ test_PIE:
                                        "\n...Periodic IRQ rate is fixed\n");
                                goto done;
                        }
-                       perror("ioctl");
+                       perror("RTC_IRQP_SET ioctl");
                        exit(errno);
                }
 
@@ -397,7 +419,7 @@ test_PIE:
                /* Enable periodic interrupts */
                retval = ioctl(fd, RTC_PIE_ON, 0);
                if (retval == -1) {
-                       perror("ioctl");
+                       perror("RTC_PIE_ON ioctl");
                        exit(errno);
                }
 
@@ -416,7 +438,7 @@ test_PIE:
                /* Disable periodic interrupts */
                retval = ioctl(fd, RTC_PIE_OFF, 0);
                if (retval == -1) {
-                       perror("ioctl");
+                       perror("RTC_PIE_OFF ioctl");
                        exit(errno);
                }
        }
index 9fef210ab50ab3914cd6e7d9c261edcb72ec489f..c30ff1bb2d1019aedfb8d96d97cd248b9e711b93 100644 (file)
@@ -242,6 +242,12 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
     ac97_clock         - AC'97 clock (default = 48000)
     ac97_quirk         - AC'97 workaround for strange hardware
                          See "AC97 Quirk Option" section below.
+    ac97_codec         - Workaround to specify which AC'97 codec 
+                         instead of probing.  If this works for you
+                         file a bug with your `lspci -vn` output.
+                         -2  -- Force probing.
+                         -1  -- Default behavior.
+                         0-2 -- Use the specified codec.
     spdif_aclink       - S/PDIF transfer over AC-link (default = 1)
 
     This module supports one card and autoprobe.
@@ -779,6 +785,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
          asus-dig      ASUS with SPDIF out
          asus-dig2     ASUS with SPDIF out (using GPIO2)
          uniwill       3-jack
+         fujitsu       Fujitsu Laptops (Pi1536)
          F1734         2-jack
          lg            LG laptop (m1 express dual)
          lg-lw         LG LW20/LW25 laptop
@@ -800,14 +807,18 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
        ALC262
          fujitsu       Fujitsu Laptop
          hp-bpc        HP xw4400/6400/8400/9400 laptops
+         hp-bpc-d7000  HP BPC D7000
          benq          Benq ED8
+         hippo         Hippo (ATI) with jack detection, Sony UX-90s
+         hippo_1       Hippo (Benq) with jack detection
          basic         fixed pin assignment w/o SPDIF
          auto          auto-config reading BIOS (default)
 
        ALC882/885
          3stack-dig    3-jack with SPDIF I/O
-         6stck-dig     6-jack digital with SPDIF I/O
+         6stack-dig    6-jack digital with SPDIF I/O
          arima         Arima W820Di1
+         macpro        MacPro support
          auto          auto-config reading BIOS (default)
 
        ALC883/888
@@ -817,6 +828,10 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
          3stack-6ch-dig 3-jack 6-channel with SPDIF I/O
          6stack-dig-demo  6-jack digital for Intel demo board
          acer          Acer laptops (Travelmate 3012WTMi, Aspire 5600, etc)
+         medion        Medion Laptops
+         targa-dig     Targa/MSI
+         targa-2ch-dig Targs/MSI with 2-channel
+         laptop-eapd   3-jack with SPDIF I/O and EAPD (Clevo M540JE, M550JE)
          auto          auto-config reading BIOS (default)
 
        ALC861/660
@@ -825,6 +840,16 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
          6stack-dig    6-jack with SPDIF I/O
          3stack-660    3-jack (for ALC660)
          uniwill-m31   Uniwill M31 laptop
+         toshiba       Toshiba laptop support
+         asus          Asus laptop support
+         asus-laptop   ASUS F2/F3 laptops
+         auto          auto-config reading BIOS (default)
+
+       ALC861VD/660VD
+         3stack        3-jack
+         3stack-dig    3-jack with SPDIF OUT
+         6stack-dig    6-jack with SPDIF OUT
+         3stack-660    3-jack (for ALC660VD)
          auto          auto-config reading BIOS (default)
 
        CMI9880
@@ -845,6 +870,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
          3stack        3-stack, shared surrounds
          laptop        2-channel only (FSC V2060, Samsung M50)
          laptop-eapd   2-channel with EAPD (Samsung R65, ASUS A6J)
+         ultra         2-channel with EAPD (Samsung Ultra tablet PC)
 
        AD1988
          6stack        6-jack
@@ -854,12 +880,31 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
          laptop        3-jack with hp-jack automute
          laptop-dig    ditto with SPDIF
          auto          auto-config reading BIOS (default)
+       
+       Conexant 5045
+         laptop        Laptop config 
+         test          for testing/debugging purpose, almost all controls
+                       can be adjusted.  Appearing only when compiled with
+                       $CONFIG_SND_DEBUG=y
+
+       Conexant 5047
+         laptop        Basic Laptop config 
+         laptop-hp     Laptop config for some HP models (subdevice 30A5)
+         laptop-eapd   Laptop config with EAPD support
+         test          for testing/debugging purpose, almost all controls
+                       can be adjusted.  Appearing only when compiled with
+                       $CONFIG_SND_DEBUG=y
 
        STAC9200/9205/9220/9221/9254
          ref           Reference board
          3stack        D945 3stack
          5stack        D945 5stack + SPDIF
 
+       STAC9202/9250/9251
+         ref           Reference board, base config
+         m2-2          Some Gateway MX series laptops
+         m6            Some Gateway NX series laptops
+
        STAC9227/9228/9229/927x
          ref           Reference board
          3stack        D965 3stack
@@ -974,6 +1019,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
     Module for Envy24HT (VT/ICE1724), Envy24PT (VT1720) based PCI sound cards.
                        * MidiMan M Audio Revolution 5.1
                        * MidiMan M Audio Revolution 7.1
+                       * MidiMan M Audio Audiophile 192
                        * AMP Ltd AUDIO2000
                        * TerraTec Aureon 5.1 Sky
                        * TerraTec Aureon 7.1 Space
@@ -993,7 +1039,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
 
     model       - Use the given board model, one of the following:
                  revo51, revo71, amp2000, prodigy71, prodigy71lt,
-                 prodigy192, aureon51, aureon71, universe,
+                 prodigy192, aureon51, aureon71, universe, ap192,
                  k8x800, phase22, phase28, ms300, av710
 
     This module supports multiple cards and autoprobe.
@@ -1049,6 +1095,9 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
     buggy_semaphore - Enable workaround for hardwares with buggy
                    semaphores (e.g. on some ASUS laptops)
                    (default off)
+    spdif_aclink  - Use S/PDIF over AC-link instead of direct connection
+                   from the controller chip
+                   (0 = off, 1 = on, -1 = default)
 
     This module supports one chip and autoprobe.
 
@@ -1371,6 +1420,13 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
 
     This module supports multiple cards.
 
+  Module snd-portman2x4
+  ---------------------
+
+    Module for Midiman Portman 2x4 parallel port MIDI interface
+
+    This module supports multiple cards.
+
   Module snd-powermac (on ppc only)
   ---------------------------------
 
index 1f3ae3e32d699a4943d0eba08abcaed39096451d..c4d2e3507af9187adb6a941f859fea9acff3ce61 100644 (file)
@@ -36,7 +36,7 @@
   </bookinfo>
 
   <chapter><title>Management of Cards and Devices</title>
-     <sect1><title>Card Managment</title>
+     <sect1><title>Card Management</title>
 !Esound/core/init.c
      </sect1>
      <sect1><title>Device Components</title>
@@ -59,7 +59,7 @@
      <sect1><title>PCM Format Helpers</title>
 !Esound/core/pcm_misc.c
      </sect1>
-     <sect1><title>PCM Memory Managment</title>
+     <sect1><title>PCM Memory Management</title>
 !Esound/core/pcm_memory.c
      </sect1>
   </chapter>
index ccd0a953953dcc09a52288d766bff968afff3e4b..74d3a35b59bc699ba512cccf7f9aab3105fb6cec 100644 (file)
         <informalexample>
           <programlisting>
 <![CDATA[
-  static irqreturn_t snd_mychip_interrupt(int irq, void *dev_id,
-                                          struct pt_regs *regs)
+  static irqreturn_t snd_mychip_interrupt(int irq, void *dev_id)
   {
           struct mychip *chip = dev_id;
           ....
        accessible via <constant>substream-&gt;runtime</constant>.
        This runtime pointer holds the various information; it holds
        the copy of hw_params and sw_params configurations, the buffer
-       pointers, mmap records, spinlocks, etc.  Almost everyhing you
+       pointers, mmap records, spinlocks, etc.  Almost everything you
        need for controlling the PCM can be found there.
        </para>
 
@@ -2340,7 +2339,7 @@ struct _snd_pcm_runtime {
 
        <para>
          When the PCM substreams can be synchronized (typically,
-       synchorinized start/stop of a playback and a capture streams),
+       synchronized start/stop of a playback and a capture streams),
        you can give <constant>SNDRV_PCM_INFO_SYNC_START</constant>,
        too.  In this case, you'll need to check the linked-list of
        PCM substreams in the trigger callback.  This will be
@@ -3062,8 +3061,7 @@ struct _snd_pcm_runtime {
            <title>Interrupt Handler Case #1</title>
             <programlisting>
 <![CDATA[
-  static irqreturn_t snd_mychip_interrupt(int irq, void *dev_id,
-                                          struct pt_regs *regs)
+  static irqreturn_t snd_mychip_interrupt(int irq, void *dev_id)
   {
           struct mychip *chip = dev_id;
           spin_lock(&chip->lock);
@@ -3106,8 +3104,7 @@ struct _snd_pcm_runtime {
            <title>Interrupt Handler Case #2</title>
             <programlisting>
 <![CDATA[
-  static irqreturn_t snd_mychip_interrupt(int irq, void *dev_id,
-                                          struct pt_regs *regs)
+  static irqreturn_t snd_mychip_interrupt(int irq, void *dev_id)
   {
           struct mychip *chip = dev_id;
           spin_lock(&chip->lock);
@@ -3247,7 +3244,7 @@ struct _snd_pcm_runtime {
         You can even define your own constraint rules.
         For example, let's suppose my_chip can manage a substream of 1 channel
         if and only if the format is S16_LE, otherwise it supports any format
-        specified in the <structname>snd_pcm_hardware</structname> stucture (or in any
+        specified in the <structname>snd_pcm_hardware</structname> structure (or in any
         other constraint_list). You can build a rule like this:
 
         <example>
@@ -3690,16 +3687,6 @@ struct _snd_pcm_runtime {
           </example>
         </para>
 
-        <para>
-          Here, the chip instance is retrieved via
-        <function>snd_kcontrol_chip()</function> macro.  This macro
-        just accesses to kcontrol-&gt;private_data. The
-        kcontrol-&gt;private_data field is 
-        given as the argument of <function>snd_ctl_new()</function>
-        (see the later subsection
-        <link linkend="control-interface-constructor"><citetitle>Constructor</citetitle></link>).
-        </para>
-
         <para>
        The <structfield>value</structfield> field is depending on
         the type of control as well as on info callback.  For example,
@@ -3780,7 +3767,7 @@ struct _snd_pcm_runtime {
         <para>
        Like <structfield>get</structfield> callback,
        when the control has more than one elements,
-       all elemehts must be evaluated in this callback, too.
+       all elements must be evaluated in this callback, too.
         </para>
       </section>
 
@@ -5541,12 +5528,12 @@ struct _snd_pcm_runtime {
   #ifdef CONFIG_PM
   static int snd_my_suspend(struct pci_dev *pci, pm_message_t state)
   {
-          .... /* do things for suspsend */
+          .... /* do things for suspend */
           return 0;
   }
   static int snd_my_resume(struct pci_dev *pci)
   {
-          .... /* do things for suspsend */
+          .... /* do things for suspend */
           return 0;
   }
   #endif
@@ -6111,7 +6098,7 @@ struct _snd_pcm_runtime {
 <!-- ****************************************************** -->
 <!-- Acknowledgments  -->
 <!-- ****************************************************** -->
-  <chapter id="acknowledments">
+  <chapter id="acknowledgments">
     <title>Acknowledgments</title>
     <para>
       I would like to thank Phil Kerr for his help for improvement and
index 0be57ed813022ae587bf55fb84afa7b735173d19..4eaae2a45534184b678108dd515d31a2636b9aab 100644 (file)
@@ -277,11 +277,11 @@ Helper Functions
 snd_hda_get_codec_name() stores the codec name on the given string.
 
 snd_hda_check_board_config() can be used to obtain the configuration
-information matching with the device.  Define the table with struct
-hda_board_config entries (zero-terminated), and pass it to the
-function.  The function checks the modelname given as a module
-parameter, and PCI subsystem IDs.  If the matching entry is found, it
-returns the config field value.
+information matching with the device.  Define the model string table
+and the table with struct snd_pci_quirk entries (zero-terminated),
+and pass it to the function.  The function checks the modelname given
+as a module parameter, and PCI subsystem IDs.  If the matching entry
+is found, it returns the config field value.
 
 snd_hda_add_new_ctls() can be used to create and add control entries.
 Pass the zero-terminated array of struct snd_kcontrol_new.  The same array
diff --git a/Documentation/sound/alsa/soc/DAI.txt b/Documentation/sound/alsa/soc/DAI.txt
new file mode 100644 (file)
index 0000000..58cbfd0
--- /dev/null
@@ -0,0 +1,56 @@
+ASoC currently supports the three main Digital Audio Interfaces (DAI) found on
+SoC controllers and portable audio CODECS today, namely AC97, I2S and PCM.
+
+
+AC97
+====
+
+  AC97 is a five wire interface commonly found on many PC sound cards. It is
+now also popular in many portable devices. This DAI has a reset line and time
+multiplexes its data on its SDATA_OUT (playback) and SDATA_IN (capture) lines.
+The bit clock (BCLK) is always driven by the CODEC (usually 12.288MHz) and the
+frame (FRAME) (usually 48kHz) is always driven by the controller. Each AC97
+frame is 21uS long and is divided into 13 time slots.
+
+The AC97 specification can be found at :-
+http://www.intel.com/design/chipsets/audio/ac97_r23.pdf
+
+
+I2S
+===
+
+ I2S is a common 4 wire DAI used in HiFi, STB and portable devices. The Tx and
+Rx lines are used for audio transmision, whilst the bit clock (BCLK) and
+left/right clock (LRC) synchronise the link. I2S is flexible in that either the
+controller or CODEC can drive (master) the BCLK and LRC clock lines. Bit clock
+usually varies depending on the sample rate and the master system clock
+(SYSCLK). LRCLK is the same as the sample rate. A few devices support separate
+ADC and DAC LRCLK's, this allows for similtanious capture and playback at
+different sample rates.
+
+I2S has several different operating modes:-
+
+ o I2S - MSB is transmitted on the falling edge of the first BCLK after LRC
+         transition.
+
+ o Left Justified - MSB is transmitted on transition of LRC.
+
+ o Right Justified - MSB is transmitted sample size BCLK's before LRC
+                     transition.
+
+PCM
+===
+
+PCM is another 4 wire interface, very similar to I2S, that can support a more
+flexible protocol. It has bit clock (BCLK) and sync (SYNC) lines that are used
+to synchronise the link whilst the Tx and Rx lines are used to transmit and
+receive the audio data. Bit clock usually varies depending on sample rate
+whilst sync runs at the sample rate. PCM also supports Time Division
+Multiplexing (TDM) in that several devices can use the bus similtaniuosly (This
+is sometimes referred to as network mode).
+
+Common PCM operating modes:-
+
+ o Mode A - MSB is transmitted on falling edge of first BCLK after FRAME/SYNC.
+
+ o Mode B - MSB is transmitted on rising edge of FRAME/SYNC.
diff --git a/Documentation/sound/alsa/soc/clocking.txt b/Documentation/sound/alsa/soc/clocking.txt
new file mode 100644 (file)
index 0000000..e93960d
--- /dev/null
@@ -0,0 +1,51 @@
+Audio Clocking
+==============
+
+This text describes the audio clocking terms in ASoC and digital audio in
+general. Note: Audio clocking can be complex !
+
+
+Master Clock
+------------
+
+Every audio subsystem is driven by a master clock (sometimes refered to as MCLK
+or SYSCLK). This audio master clock can be derived from a number of sources
+(e.g. crystal, PLL, CPU clock) and is responsible for producing the correct
+audio playback and capture sample rates.
+
+Some master clocks (e.g. PLL's and CPU based clocks) are configuarble in that
+their speed can be altered by software (depending on the system use and to save
+power). Other master clocks are fixed at at set frequency (i.e. crystals).
+
+
+DAI Clocks
+----------
+The Digital Audio Interface is usually driven by a Bit Clock (often referred to
+as BCLK). This clock is used to drive the digital audio data across the link
+between the codec and CPU.
+
+The DAI also has a frame clock to signal the start of each audio frame. This
+clock is sometimes referred to as LRC (left right clock) or FRAME. This clock
+runs at exactly the sample rate (LRC = Rate).
+
+Bit Clock can be generated as follows:-
+
+BCLK = MCLK / x
+
+ or
+
+BCLK = LRC * x
+
+ or
+
+BCLK = LRC * Channels * Word Size
+
+This relationship depends on the codec or SoC CPU in particular. In general
+it's best to configure BCLK to the lowest possible speed (depending on your
+rate, number of channels and wordsize) to save on power.
+
+It's also desireable to use the codec (if possible) to drive (or master) the
+audio clocks as it's usually gives more accurate sample rates than the CPU.
+
+
+
diff --git a/Documentation/sound/alsa/soc/codec.txt b/Documentation/sound/alsa/soc/codec.txt
new file mode 100644 (file)
index 0000000..48983c7
--- /dev/null
@@ -0,0 +1,197 @@
+ASoC Codec Driver
+=================
+
+The codec driver is generic and hardware independent code that configures the
+codec to provide audio capture and playback. It should contain no code that is
+specific to the target platform or machine. All platform and machine specific
+code should be added to the platform and machine drivers respectively.
+
+Each codec driver *must* provide the following features:-
+
+ 1) Codec DAI and PCM configuration
+ 2) Codec control IO - using I2C, 3 Wire(SPI) or both API's
+ 3) Mixers and audio controls
+ 4) Codec audio operations
+
+Optionally, codec drivers can also provide:-
+
+ 5) DAPM description.
+ 6) DAPM event handler.
+ 7) DAC Digital mute control.
+
+It's probably best to use this guide in conjuction with the existing codec
+driver code in sound/soc/codecs/
+
+ASoC Codec driver breakdown
+===========================
+
+1 - Codec DAI and PCM configuration
+-----------------------------------
+Each codec driver must have a struct snd_soc_codec_dai to define it's DAI and
+PCM's capablities and operations. This struct is exported so that it can be
+registered with the core by your machine driver.
+
+e.g.
+
+struct snd_soc_codec_dai wm8731_dai = {
+       .name = "WM8731",
+       /* playback capabilities */
+       .playback = {
+               .stream_name = "Playback",
+               .channels_min = 1,
+               .channels_max = 2,
+               .rates = WM8731_RATES,
+               .formats = WM8731_FORMATS,},
+       /* capture capabilities */
+       .capture = {
+               .stream_name = "Capture",
+               .channels_min = 1,
+               .channels_max = 2,
+               .rates = WM8731_RATES,
+               .formats = WM8731_FORMATS,},
+       /* pcm operations - see section 4 below */
+       .ops = {
+               .prepare = wm8731_pcm_prepare,
+               .hw_params = wm8731_hw_params,
+               .shutdown = wm8731_shutdown,
+       },
+       /* DAI operations - see DAI.txt */
+       .dai_ops = {
+               .digital_mute = wm8731_mute,
+               .set_sysclk = wm8731_set_dai_sysclk,
+               .set_fmt = wm8731_set_dai_fmt,
+       }
+};
+EXPORT_SYMBOL_GPL(wm8731_dai);
+
+
+2 - Codec control IO
+--------------------
+The codec can ususally be controlled via an I2C or SPI style interface (AC97
+combines control with data in the DAI). The codec drivers will have to provide
+functions to read and write the codec registers along with supplying a register
+cache:-
+
+       /* IO control data and register cache */
+    void *control_data; /* codec control (i2c/3wire) data */
+    void *reg_cache;
+
+Codec read/write should do any data formatting and call the hardware read write
+below to perform the IO. These functions are called by the core and alsa when
+performing DAPM or changing the mixer:-
+
+    unsigned int (*read)(struct snd_soc_codec *, unsigned int);
+    int (*write)(struct snd_soc_codec *, unsigned int, unsigned int);
+
+Codec hardware IO functions - usually points to either the I2C, SPI or AC97
+read/write:-
+
+       hw_write_t hw_write;
+       hw_read_t hw_read;
+
+
+3 - Mixers and audio controls
+-----------------------------
+All the codec mixers and audio controls can be defined using the convenience
+macros defined in soc.h.
+
+    #define SOC_SINGLE(xname, reg, shift, mask, invert)
+
+Defines a single control as follows:-
+
+  xname = Control name e.g. "Playback Volume"
+  reg = codec register
+  shift = control bit(s) offset in register
+  mask = control bit size(s) e.g. mask of 7 = 3 bits
+  invert = the control is inverted
+
+Other macros include:-
+
+    #define SOC_DOUBLE(xname, reg, shift_left, shift_right, mask, invert)
+
+A stereo control
+
+    #define SOC_DOUBLE_R(xname, reg_left, reg_right, shift, mask, invert)
+
+A stereo control spanning 2 registers
+
+    #define SOC_ENUM_SINGLE(xreg, xshift, xmask, xtexts)
+
+Defines an single enumerated control as follows:-
+
+   xreg = register
+   xshift = control bit(s) offset in register
+   xmask = control bit(s) size
+   xtexts = pointer to array of strings that describe each setting
+
+   #define SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, xtexts)
+
+Defines a stereo enumerated control
+
+
+4 - Codec Audio Operations
+--------------------------
+The codec driver also supports the following alsa operations:-
+
+/* SoC audio ops */
+struct snd_soc_ops {
+       int (*startup)(struct snd_pcm_substream *);
+       void (*shutdown)(struct snd_pcm_substream *);
+       int (*hw_params)(struct snd_pcm_substream *, struct snd_pcm_hw_params *);
+       int (*hw_free)(struct snd_pcm_substream *);
+       int (*prepare)(struct snd_pcm_substream *);
+};
+
+Please refer to the alsa driver PCM documentation for details.
+http://www.alsa-project.org/~iwai/writing-an-alsa-driver/c436.htm
+
+
+5 - DAPM description.
+---------------------
+The Dynamic Audio Power Management description describes the codec's power
+components, their relationships and registers to the ASoC core. Please read
+dapm.txt for details of building the description.
+
+Please also see the examples in other codec drivers.
+
+
+6 - DAPM event handler
+----------------------
+This function is a callback that handles codec domain PM calls and system
+domain PM calls (e.g. suspend and resume). It's used to put the codec to sleep
+when not in use.
+
+Power states:-
+
+       SNDRV_CTL_POWER_D0: /* full On */
+       /* vref/mid, clk and osc on, active */
+
+       SNDRV_CTL_POWER_D1: /* partial On */
+       SNDRV_CTL_POWER_D2: /* partial On */
+
+       SNDRV_CTL_POWER_D3hot: /* Off, with power */
+       /* everything off except vref/vmid, inactive */
+
+       SNDRV_CTL_POWER_D3cold: /* Everything Off, without power */
+
+
+7 - Codec DAC digital mute control.
+------------------------------------
+Most codecs have a digital mute before the DAC's that can be used to minimise
+any system noise.  The mute stops any digital data from entering the DAC.
+
+A callback can be created that is called by the core for each codec DAI when the
+mute is applied or freed.
+
+i.e.
+
+static int wm8974_mute(struct snd_soc_codec *codec,
+       struct snd_soc_codec_dai *dai, int mute)
+{
+       u16 mute_reg = wm8974_read_reg_cache(codec, WM8974_DAC) & 0xffbf;
+       if(mute)
+               wm8974_write(codec, WM8974_DAC, mute_reg | 0x40);
+       else
+               wm8974_write(codec, WM8974_DAC, mute_reg);
+       return 0;
+}
diff --git a/Documentation/sound/alsa/soc/dapm.txt b/Documentation/sound/alsa/soc/dapm.txt
new file mode 100644 (file)
index 0000000..c11877f
--- /dev/null
@@ -0,0 +1,297 @@
+Dynamic Audio Power Management for Portable Devices
+===================================================
+
+1. Description
+==============
+
+Dynamic Audio Power Management (DAPM) is designed to allow portable Linux devices
+to use the minimum amount of power within the audio subsystem at all times. It
+is independent of other kernel PM and as such, can easily co-exist with the
+other PM systems.
+
+DAPM is also completely transparent to all user space applications as all power
+switching is done within the ASoC core. No code changes or recompiling are
+required for user space applications. DAPM makes power switching descisions based
+upon any audio stream (capture/playback) activity and audio mixer settings
+within the device.
+
+DAPM spans the whole machine. It covers power control within the entire audio
+subsystem, this includes internal codec power blocks and machine level power
+systems.
+
+There are 4 power domains within DAPM
+
+   1. Codec domain - VREF, VMID (core codec and audio power)
+      Usually controlled at codec probe/remove and suspend/resume, although
+      can be set at stream time if power is not needed for sidetone, etc.
+
+   2. Platform/Machine domain - physically connected inputs and outputs
+      Is platform/machine and user action specific, is configured by the
+      machine driver and responds to asynchronous events e.g when HP
+      are inserted
+
+   3. Path domain - audio susbsystem signal paths
+      Automatically set when mixer and mux settings are changed by the user.
+      e.g. alsamixer, amixer.
+
+   4. Stream domain - DAC's and ADC's.
+      Enabled and disabled when stream playback/capture is started and
+      stopped respectively. e.g. aplay, arecord.
+
+All DAPM power switching descisons are made automatically by consulting an audio
+routing map of the whole machine. This map is specific to each machine and
+consists of the interconnections between every audio component (including
+internal codec components). All audio components that effect power are called
+widgets hereafter.
+
+
+2. DAPM Widgets
+===============
+
+Audio DAPM widgets fall into a number of types:-
+
+ o Mixer      - Mixes several analog signals into a single analog signal.
+ o Mux        - An analog switch that outputs only 1 of it's inputs.
+ o PGA        - A programmable gain amplifier or attenuation widget.
+ o ADC        - Analog to Digital Converter
+ o DAC        - Digital to Analog Converter
+ o Switch     - An analog switch
+ o Input      - A codec input pin
+ o Output     - A codec output pin
+ o Headphone  - Headphone (and optional Jack)
+ o Mic        - Mic (and optional Jack)
+ o Line       - Line Input/Output (and optional Jack)
+ o Speaker    - Speaker
+ o Pre        - Special PRE widget (exec before all others)
+ o Post       - Special POST widget (exec after all others)
+
+(Widgets are defined in include/sound/soc-dapm.h)
+
+Widgets are usually added in the codec driver and the machine driver. There are
+convience macros defined in soc-dapm.h that can be used to quickly build a
+list of widgets of the codecs and machines DAPM widgets.
+
+Most widgets have a name, register, shift and invert. Some widgets have extra
+parameters for stream name and kcontrols.
+
+
+2.1 Stream Domain Widgets
+-------------------------
+
+Stream Widgets relate to the stream power domain and only consist of ADC's
+(analog to digital converters) and DAC's (digital to analog converters).
+
+Stream widgets have the following format:-
+
+SND_SOC_DAPM_DAC(name, stream name, reg, shift, invert),
+
+NOTE: the stream name must match the corresponding stream name in your codecs
+snd_soc_codec_dai.
+
+e.g. stream widgets for HiFi playback and capture
+
+SND_SOC_DAPM_DAC("HiFi DAC", "HiFi Playback", REG, 3, 1),
+SND_SOC_DAPM_ADC("HiFi ADC", "HiFi Capture", REG, 2, 1),
+
+
+2.2 Path Domain Widgets
+-----------------------
+
+Path domain widgets have a ability to control or effect the audio signal or
+audio paths within the audio subsystem. They have the following form:-
+
+SND_SOC_DAPM_PGA(name, reg, shift, invert, controls, num_controls)
+
+Any widget kcontrols can be set using the controls and num_controls members.
+
+e.g. Mixer widget (the kcontrols are declared first)
+
+/* Output Mixer */
+static const snd_kcontrol_new_t wm8731_output_mixer_controls[] = {
+SOC_DAPM_SINGLE("Line Bypass Switch", WM8731_APANA, 3, 1, 0),
+SOC_DAPM_SINGLE("Mic Sidetone Switch", WM8731_APANA, 5, 1, 0),
+SOC_DAPM_SINGLE("HiFi Playback Switch", WM8731_APANA, 4, 1, 0),
+};
+
+SND_SOC_DAPM_MIXER("Output Mixer", WM8731_PWR, 4, 1, wm8731_output_mixer_controls,
+       ARRAY_SIZE(wm8731_output_mixer_controls)),
+
+
+2.3 Platform/Machine domain Widgets
+-----------------------------------
+
+Machine widgets are different from codec widgets in that they don't have a
+codec register bit associated with them. A machine widget is assigned to each
+machine audio component (non codec) that can be independently powered. e.g.
+
+ o Speaker Amp
+ o Microphone Bias
+ o Jack connectors
+
+A machine widget can have an optional call back.
+
+e.g. Jack connector widget for an external Mic that enables Mic Bias
+when the Mic is inserted:-
+
+static int spitz_mic_bias(struct snd_soc_dapm_widget* w, int event)
+{
+       if(SND_SOC_DAPM_EVENT_ON(event))
+               set_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_MIC_BIAS);
+       else
+               reset_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_MIC_BIAS);
+
+       return 0;
+}
+
+SND_SOC_DAPM_MIC("Mic Jack", spitz_mic_bias),
+
+
+2.4 Codec Domain
+----------------
+
+The Codec power domain has no widgets and is handled by the codecs DAPM event
+handler. This handler is called when the codec powerstate is changed wrt to any
+stream event or by kernel PM events.
+
+
+2.5 Virtual Widgets
+-------------------
+
+Sometimes widgets exist in the codec or machine audio map that don't have any
+corresponding register bit for power control. In this case it's necessary to
+create a virtual widget - a widget with no control bits e.g.
+
+SND_SOC_DAPM_MIXER("AC97 Mixer", SND_SOC_DAPM_NOPM, 0, 0, NULL, 0),
+
+This can be used to merge to signal paths together in software.
+
+After all the widgets have been defined, they can then be added to the DAPM
+subsystem individually with a call to snd_soc_dapm_new_control().
+
+
+3. Codec Widget Interconnections
+================================
+
+Widgets are connected to each other within the codec and machine by audio
+paths (called interconnections). Each interconnection must be defined in order
+to create a map of all audio paths between widgets.
+This is easiest with a diagram of the codec (and schematic of the machine audio
+system), as it requires joining widgets together via their audio signal paths.
+
+i.e. from the WM8731 codec's output mixer (wm8731.c)
+
+The WM8731 output mixer has 3 inputs (sources)
+
+ 1. Line Bypass Input
+ 2. DAC (HiFi playback)
+ 3. Mic Sidetone Input
+
+Each input in this example has a kcontrol associated with it (defined in example
+above) and is connected to the output mixer via it's kcontrol name. We can now
+connect the destination widget (wrt audio signal) with it's source widgets.
+
+       /* output mixer */
+       {"Output Mixer", "Line Bypass Switch", "Line Input"},
+       {"Output Mixer", "HiFi Playback Switch", "DAC"},
+       {"Output Mixer", "Mic Sidetone Switch", "Mic Bias"},
+
+So we have :-
+
+       Destination Widget  <=== Path Name <=== Source Widget
+
+Or:-
+
+       Sink, Path, Source
+
+Or :-
+
+       "Output Mixer" is connected to the "DAC" via the "HiFi Playback Switch".
+
+When there is no path name connecting widgets (e.g. a direct connection) we
+pass NULL for the path name.
+
+Interconnections are created with a call to:-
+
+snd_soc_dapm_connect_input(codec, sink, path, source);
+
+Finally, snd_soc_dapm_new_widgets(codec) must be called after all widgets and
+interconnections have been registered with the core. This causes the core to
+scan the codec and machine so that the internal DAPM state matches the
+physical state of the machine.
+
+
+3.1 Machine Widget Interconnections
+-----------------------------------
+Machine widget interconnections are created in the same way as codec ones and
+directly connect the codec pins to machine level widgets.
+
+e.g. connects the speaker out codec pins to the internal speaker.
+
+       /* ext speaker connected to codec pins LOUT2, ROUT2  */
+       {"Ext Spk", NULL , "ROUT2"},
+       {"Ext Spk", NULL , "LOUT2"},
+
+This allows the DAPM to power on and off pins that are connected (and in use)
+and pins that are NC respectively.
+
+
+4 Endpoint Widgets
+===================
+An endpoint is a start or end point (widget) of an audio signal within the
+machine and includes the codec. e.g.
+
+ o Headphone Jack
+ o Internal Speaker
+ o Internal Mic
+ o Mic Jack
+ o Codec Pins
+
+When a codec pin is NC it can be marked as not used with a call to
+
+snd_soc_dapm_set_endpoint(codec, "Widget Name", 0);
+
+The last argument is 0 for inactive and 1 for active. This way the pin and its
+input widget will never be powered up and consume power.
+
+This also applies to machine widgets. e.g. if a headphone is connected to a
+jack then the jack can be marked active. If the headphone is removed, then
+the headphone jack can be marked inactive.
+
+
+5 DAPM Widget Events
+====================
+
+Some widgets can register their interest with the DAPM core in PM events.
+e.g. A Speaker with an amplifier registers a widget so the amplifier can be
+powered only when the spk is in use.
+
+/* turn speaker amplifier on/off depending on use */
+static int corgi_amp_event(struct snd_soc_dapm_widget *w, int event)
+{
+       if (SND_SOC_DAPM_EVENT_ON(event))
+               set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_APM_ON);
+       else
+               reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_APM_ON);
+
+       return 0;
+}
+
+/* corgi machine dapm widgets */
+static const struct snd_soc_dapm_widget wm8731_dapm_widgets =
+       SND_SOC_DAPM_SPK("Ext Spk", corgi_amp_event);
+
+Please see soc-dapm.h for all other widgets that support events.
+
+
+5.1 Event types
+---------------
+
+The following event types are supported by event widgets.
+
+/* dapm event types */
+#define SND_SOC_DAPM_PRE_PMU   0x1     /* before widget power up */
+#define SND_SOC_DAPM_POST_PMU  0x2             /* after widget power up */
+#define SND_SOC_DAPM_PRE_PMD   0x4     /* before widget power down */
+#define SND_SOC_DAPM_POST_PMD  0x8             /* after widget power down */
+#define SND_SOC_DAPM_PRE_REG   0x10    /* before audio path setup */
+#define SND_SOC_DAPM_POST_REG  0x20    /* after audio path setup */
diff --git a/Documentation/sound/alsa/soc/machine.txt b/Documentation/sound/alsa/soc/machine.txt
new file mode 100644 (file)
index 0000000..72bd222
--- /dev/null
@@ -0,0 +1,113 @@
+ASoC Machine Driver
+===================
+
+The ASoC machine (or board) driver is the code that glues together the platform
+and codec drivers.
+
+The machine driver can contain codec and platform specific code. It registers
+the audio subsystem with the kernel as a platform device and is represented by
+the following struct:-
+
+/* SoC machine */
+struct snd_soc_machine {
+       char *name;
+
+       int (*probe)(struct platform_device *pdev);
+       int (*remove)(struct platform_device *pdev);
+
+       /* the pre and post PM functions are used to do any PM work before and
+        * after the codec and DAI's do any PM work. */
+       int (*suspend_pre)(struct platform_device *pdev, pm_message_t state);
+       int (*suspend_post)(struct platform_device *pdev, pm_message_t state);
+       int (*resume_pre)(struct platform_device *pdev);
+       int (*resume_post)(struct platform_device *pdev);
+
+       /* machine stream operations */
+       struct snd_soc_ops *ops;
+
+       /* CPU <--> Codec DAI links  */
+       struct snd_soc_dai_link *dai_link;
+       int num_links;
+};
+
+probe()/remove()
+----------------
+probe/remove are optional. Do any machine specific probe here.
+
+
+suspend()/resume()
+------------------
+The machine driver has pre and post versions of suspend and resume to take care
+of any machine audio tasks that have to be done before or after the codec, DAI's
+and DMA is suspended and resumed. Optional.
+
+
+Machine operations
+------------------
+The machine specific audio operations can be set here. Again this is optional.
+
+
+Machine DAI Configuration
+-------------------------
+The machine DAI configuration glues all the codec and CPU DAI's together. It can
+also be used to set up the DAI system clock and for any machine related DAI
+initialisation e.g. the machine audio map can be connected to the codec audio
+map, unconnnected codec pins can be set as such. Please see corgi.c, spitz.c
+for examples.
+
+struct snd_soc_dai_link is used to set up each DAI in your machine. e.g.
+
+/* corgi digital audio interface glue - connects codec <--> CPU */
+static struct snd_soc_dai_link corgi_dai = {
+       .name = "WM8731",
+       .stream_name = "WM8731",
+       .cpu_dai = &pxa_i2s_dai,
+       .codec_dai = &wm8731_dai,
+       .init = corgi_wm8731_init,
+       .ops = &corgi_ops,
+};
+
+struct snd_soc_machine then sets up the machine with it's DAI's. e.g.
+
+/* corgi audio machine driver */
+static struct snd_soc_machine snd_soc_machine_corgi = {
+       .name = "Corgi",
+       .dai_link = &corgi_dai,
+       .num_links = 1,
+};
+
+
+Machine Audio Subsystem
+-----------------------
+
+The machine soc device glues the platform, machine and codec driver together.
+Private data can also be set here. e.g.
+
+/* corgi audio private data */
+static struct wm8731_setup_data corgi_wm8731_setup = {
+       .i2c_address = 0x1b,
+};
+
+/* corgi audio subsystem */
+static struct snd_soc_device corgi_snd_devdata = {
+       .machine = &snd_soc_machine_corgi,
+       .platform = &pxa2xx_soc_platform,
+       .codec_dev = &soc_codec_dev_wm8731,
+       .codec_data = &corgi_wm8731_setup,
+};
+
+
+Machine Power Map
+-----------------
+
+The machine driver can optionally extend the codec power map and to become an
+audio power map of the audio subsystem. This allows for automatic power up/down
+of speaker/HP amplifiers, etc. Codec pins can be connected to the machines jack
+sockets in the machine init function. See soc/pxa/spitz.c and dapm.txt for
+details.
+
+
+Machine Controls
+----------------
+
+Machine specific audio mixer controls can be added in the dai init function.
\ No newline at end of file
diff --git a/Documentation/sound/alsa/soc/overview.txt b/Documentation/sound/alsa/soc/overview.txt
new file mode 100644 (file)
index 0000000..753c5cc
--- /dev/null
@@ -0,0 +1,83 @@
+ALSA SoC Layer
+==============
+
+The overall project goal of the ALSA System on Chip (ASoC) layer is to provide
+better ALSA support for embedded system on chip procesors (e.g. pxa2xx, au1x00,
+iMX, etc) and portable audio codecs. Currently there is some support in the
+kernel for SoC audio, however it has some limitations:-
+
+  * Currently, codec drivers are often tightly coupled to the underlying SoC
+    cpu. This is not ideal and leads to code duplication i.e. Linux now has 4
+    different wm8731 drivers for 4 different SoC platforms.
+
+  * There is no standard method to signal user initiated audio events.
+    e.g. Headphone/Mic insertion, Headphone/Mic detection after an insertion
+    event. These are quite common events on portable devices and ofter require
+    machine specific code to re route audio, enable amps etc after such an event.
+
+  * Current drivers tend to power up the entire codec when playing
+    (or recording) audio. This is fine for a PC, but tends to waste a lot of
+    power on portable devices. There is also no support for saving power via
+    changing codec oversampling rates, bias currents, etc.
+
+
+ASoC Design
+===========
+
+The ASoC layer is designed to address these issues and provide the following
+features :-
+
+  * Codec independence. Allows reuse of codec drivers on other platforms
+    and machines.
+
+  * Easy I2S/PCM audio interface setup between codec and SoC. Each SoC interface
+    and codec registers it's audio interface capabilities with the core and are
+    subsequently matched and configured when the application hw params are known.
+
+  * Dynamic Audio Power Management (DAPM). DAPM automatically sets the codec to
+    it's minimum power state at all times. This includes powering up/down
+    internal power blocks depending on the internal codec audio routing and any
+    active streams.
+
+  * Pop and click reduction. Pops and clicks can be reduced by powering the
+    codec up/down in the correct sequence (including using digital mute). ASoC
+    signals the codec when to change power states.
+
+  * Machine specific controls: Allow machines to add controls to the sound card
+    e.g. volume control for speaker amp.
+
+To achieve all this, ASoC basically splits an embedded audio system into 3
+components :-
+
+  * Codec driver: The codec driver is platform independent and contains audio
+    controls, audio interface capabilities, codec dapm definition and codec IO
+    functions.
+
+  * Platform driver: The platform driver contains the audio dma engine and audio
+    interface drivers (e.g. I2S, AC97, PCM) for that platform.
+
+  * Machine driver: The machine driver handles any machine specific controls and
+    audio events. i.e. turing on an amp at start of playback.
+
+
+Documentation
+=============
+
+The documentation is spilt into the following sections:-
+
+overview.txt: This file.
+
+codec.txt: Codec driver internals.
+
+DAI.txt: Description of Digital Audio Interface standards and how to configure
+a DAI within your codec and CPU DAI drivers.
+
+dapm.txt: Dynamic Audio Power Management
+
+platform.txt: Platform audio DMA and DAI.
+
+machine.txt: Machine driver internals.
+
+pop_clicks.txt: How to minimise audio artifacts.
+
+clocking.txt: ASoC clocking for best power performance.
\ No newline at end of file
diff --git a/Documentation/sound/alsa/soc/platform.txt b/Documentation/sound/alsa/soc/platform.txt
new file mode 100644 (file)
index 0000000..e95b16d
--- /dev/null
@@ -0,0 +1,58 @@
+ASoC Platform Driver
+====================
+
+An ASoC platform driver can be divided into audio DMA and SoC DAI configuration
+and control. The platform drivers only target the SoC CPU and must have no board
+specific code.
+
+Audio DMA
+=========
+
+The platform DMA driver optionally supports the following alsa operations:-
+
+/* SoC audio ops */
+struct snd_soc_ops {
+       int (*startup)(struct snd_pcm_substream *);
+       void (*shutdown)(struct snd_pcm_substream *);
+       int (*hw_params)(struct snd_pcm_substream *, struct snd_pcm_hw_params *);
+       int (*hw_free)(struct snd_pcm_substream *);
+       int (*prepare)(struct snd_pcm_substream *);
+       int (*trigger)(struct snd_pcm_substream *, int);
+};
+
+The platform driver exports it's DMA functionailty via struct snd_soc_platform:-
+
+struct snd_soc_platform {
+       char *name;
+
+       int (*probe)(struct platform_device *pdev);
+       int (*remove)(struct platform_device *pdev);
+       int (*suspend)(struct platform_device *pdev, struct snd_soc_cpu_dai *cpu_dai);
+       int (*resume)(struct platform_device *pdev, struct snd_soc_cpu_dai *cpu_dai);
+
+       /* pcm creation and destruction */
+       int (*pcm_new)(struct snd_card *, struct snd_soc_codec_dai *, struct snd_pcm *);
+       void (*pcm_free)(struct snd_pcm *);
+
+       /* platform stream ops */
+       struct snd_pcm_ops *pcm_ops;
+};
+
+Please refer to the alsa driver documentation for details of audio DMA.
+http://www.alsa-project.org/~iwai/writing-an-alsa-driver/c436.htm
+
+An example DMA driver is soc/pxa/pxa2xx-pcm.c
+
+
+SoC DAI Drivers
+===============
+
+Each SoC DAI driver must provide the following features:-
+
+ 1) Digital audio interface (DAI) description
+ 2) Digital audio interface configuration
+ 3) PCM's description
+ 4) Sysclk configuration
+ 5) Suspend and resume (optional)
+
+Please see codec.txt for a description of items 1 - 4.
diff --git a/Documentation/sound/alsa/soc/pops_clicks.txt b/Documentation/sound/alsa/soc/pops_clicks.txt
new file mode 100644 (file)
index 0000000..2cf7ee5
--- /dev/null
@@ -0,0 +1,52 @@
+Audio Pops and Clicks
+=====================
+
+Pops and clicks are unwanted audio artifacts caused by the powering up and down
+of components within the audio subsystem. This is noticable on PC's when an
+audio module is either loaded or unloaded (at module load time the sound card is
+powered up and causes a popping noise on the speakers).
+
+Pops and clicks can be more frequent on portable systems with DAPM. This is
+because the components within the subsystem are being dynamically powered
+depending on the audio usage and this can subsequently cause a small pop or
+click every time a component power state is changed.
+
+
+Minimising Playback Pops and Clicks
+===================================
+
+Playback pops in portable audio subsystems cannot be completely eliminated atm,
+however future audio codec hardware will have better pop and click supression.
+Pops can be reduced within playback by powering the audio components in a
+specific order. This order is different for startup and shutdown and follows
+some basic rules:-
+
+ Startup Order :- DAC --> Mixers --> Output PGA --> Digital Unmute
+
+ Shutdown Order :- Digital Mute --> Output PGA --> Mixers --> DAC
+
+This assumes that the codec PCM output path from the DAC is via a mixer and then
+a PGA (programmable gain amplifier) before being output to the speakers.
+
+
+Minimising Capture Pops and Clicks
+==================================
+
+Capture artifacts are somewhat easier to get rid as we can delay activating the
+ADC until all the pops have occured. This follows similar power rules to
+playback in that components are powered in a sequence depending upon stream
+startup or shutdown.
+
+ Startup Order - Input PGA --> Mixers --> ADC
+
+ Shutdown Order - ADC --> Mixers --> Input PGA
+
+
+Zipper Noise
+============
+An unwanted zipper noise can occur within the audio playback or capture stream
+when a volume control is changed near its maximum gain value. The zipper noise
+is heard when the gain increase or decrease changes the mean audio signal
+amplitude too quickly. It can be minimised by enabling the zero cross setting
+for each volume control. The ZC forces the gain change to occur when the signal
+crosses the zero amplitude line.
index 61613166981b9139a5961fe0c3344cbd03286688..452c0f1523044883b785fc5d35699b270fa7493a 100644 (file)
@@ -64,11 +64,6 @@ On all -  write a character to /proc/sysrq-trigger.  e.g.:
 
 *  What are the 'command' keys?
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-'r'     - Turns off keyboard raw mode and sets it to XLATE.
-
-'k'     - Secure Access Key (SAK) Kills all programs on the current virtual
-          console. NOTE: See important comments below in SAK section.
-
 'b'     - Will immediately reboot the system without syncing or unmounting
           your disks.
 
@@ -76,21 +71,37 @@ On all -  write a character to /proc/sysrq-trigger.  e.g.:
 
 'd'    - Shows all locks that are held.
 
-'o'     - Will shut your system off (if configured and supported).
+'e'     - Send a SIGTERM to all processes, except for init.
 
-'s'     - Will attempt to sync all mounted filesystems.
+'f'    - Will call oom_kill to kill a memory hog process.
 
-'u'     - Will attempt to remount all mounted filesystems read-only.
+'g'    - Used by kgdb on ppc platforms.
 
-'p'     - Will dump the current registers and flags to your console.
+'h'     - Will display help (actually any other key than those listed
+          above will display help. but 'h' is easy to remember :-)
 
-'t'     - Will dump a list of current tasks and their information to your
-          console.
+'i'     - Send a SIGKILL to all processes, except for init.
+
+'k'     - Secure Access Key (SAK) Kills all programs on the current virtual
+          console. NOTE: See important comments below in SAK section.
 
 'm'     - Will dump current memory info to your console.
 
 'n'    - Used to make RT tasks nice-able
 
+'o'     - Will shut your system off (if configured and supported).
+
+'p'     - Will dump the current registers and flags to your console.
+
+'r'     - Turns off keyboard raw mode and sets it to XLATE.
+
+'s'     - Will attempt to sync all mounted filesystems.
+
+'t'     - Will dump a list of current tasks and their information to your
+          console.
+
+'u'     - Will attempt to remount all mounted filesystems read-only.
+
 'v'    - Dumps Voyager SMP processor info to your console.
 
 'w'    - Dumps tasks that are in uninterruptable (blocked) state.
@@ -102,17 +113,6 @@ On all -  write a character to /proc/sysrq-trigger.  e.g.:
           it so that only emergency messages like PANICs or OOPSes would
           make it to your console.)
 
-'f'    - Will call oom_kill to kill a memory hog process.
-
-'e'     - Send a SIGTERM to all processes, except for init.
-
-'g'    - Used by kgdb on ppc platforms.
-
-'i'     - Send a SIGKILL to all processes, except for init.
-
-'h'     - Will display help (actually any other key than those listed
-          above will display help. but 'h' is easy to remember :-)
-
 *  Okay, so what can I use them for?
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Well, un'R'aw is very handy when your X server or a svgalib program crashes.
index fe35f3ac4cd30c1bb8446071f1ec7c482cc2417e..9ea954ace2ffabdb21b45de731517261be3605fa 100644 (file)
@@ -635,6 +635,12 @@ W: http://people.redhat.com/sgrubb/audit/
 T:     git kernel.org:/pub/scm/linux/kernel/git/dwmw2/audit-2.6.git
 S:     Maintained
 
+AUXILIARY DISPLAY DRIVERS
+P:     Miguel Ojeda Sandonis
+M:     maxextreme@gmail.com
+L:     linux-kernel@vger.kernel.org
+S:     Maintained
+
 AVR32 ARCHITECTURE
 P:     Haavard Skinnemoen
 M:     hskinnemoen@atmel.com
@@ -836,6 +842,18 @@ L: linux-kernel@vger.kernel.org
 L:     discuss@x86-64.org
 S:     Maintained
 
+CFAG12864B LCD DRIVER
+P:     Miguel Ojeda Sandonis
+M:     maxextreme@gmail.com
+L:     linux-kernel@vger.kernel.org
+S:     Maintained
+
+CFAG12864BFB LCD FRAMEBUFFER DRIVER
+P:     Miguel Ojeda Sandonis
+M:     maxextreme@gmail.com
+L:     linux-kernel@vger.kernel.org
+S:     Maintained
+
 COMMON INTERNET FILE SYSTEM (CIFS)
 P:     Steve French
 M:     sfrench@samba.org
@@ -1114,7 +1132,7 @@ S:        Supported
 DAVICOM FAST ETHERNET (DMFE) NETWORK DRIVER
 P:     Tobias Ringstrom
 M:     tori@unhappy.mine.nu
-L:     linux-kernel@vger.kernel.org
+L:     netdev@vger.kernel.org
 S:     Maintained
 
 DOCBOOK FOR DOCUMENTATION
@@ -1971,6 +1989,12 @@ M:       davem@davemloft.net
 L:     linux-kernel@vger.kernel.org
 S:     Maintained
 
+KS0108 LCD CONTROLLER DRIVER
+P:     Miguel Ojeda Sandonis
+M:     maxextreme@gmail.com
+L:     linux-kernel@vger.kernel.org
+S:     Maintained
+
 LAPB module
 L:     linux-x25@vger.kernel.org
 S:     Orphan
@@ -2361,7 +2385,7 @@ S:        Maintained
 NETWORKING [WIRELESS]
 P:     John W. Linville
 M:     linville@tuxdriver.com
-L:     netdev@vger.kernel.org
+L:     linux-wireless@vger.kernel.org
 T:     git kernel.org:/pub/scm/linux/kernel/git/linville/wireless-2.6.git
 S:     Maintained
 
@@ -3037,6 +3061,12 @@ M:       perex@suse.cz
 L:     alsa-devel@alsa-project.org
 S:     Maintained
 
+SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEMENT
+P:     Liam Girdwood
+M:     liam.girdwood@wolfsonmicro.com
+L:     alsa-devel@alsa-project.org
+S:     Supported
+
 SPI SUBSYSTEM
 P:     David Brownell
 M:     dbrownell@users.sourceforge.net
@@ -3287,6 +3317,11 @@ L:       vtun@office.satix.net
 W:     http://vtun.sourceforge.net/tun
 S:     Maintained
 
+TURBOCHANNEL SUBSYSTEM
+P:     Maciej W. Rozycki
+M:     macro@linux-mips.org
+S:     Maintained
+
 U14-34F SCSI DRIVER
 P:     Dario Ballabio
 M:     ballabio_dario@emc.com
index 84caf50725b53e829df2a39baa059084d63663e4..770f717bd250c2c0965b6477e2b6b205b8f37dbe 100644 (file)
@@ -41,6 +41,10 @@ config GENERIC_CALIBRATE_DELAY
        bool
        default y
 
+config ZONE_DMA
+       bool
+       default y
+
 config GENERIC_ISA_DMA
        bool
        default y
index d7053eb4ffcfd93623d58aabda82d30cf9118dee..4748e14a28bca3b9edd05b73d0787b60367cee7d 100644 (file)
@@ -90,17 +90,6 @@ static inline __u32 rpcc(void)
     return result;
 }
 
-/*
- * Scheduler clock - returns current time in nanosec units.
- *
- * Copied from ARM code for expediency... ;-}
- */
-unsigned long long sched_clock(void)
-{
-        return (unsigned long long)jiffies * (1000000000 / HZ);
-}
-
-
 /*
  * timer_interrupt() needs to keep up the real-time clock,
  * as well as call the "do_timer()" routine every clocktick
index 76bf071e376c9915b31fe96fc30dbb3090672a34..4cc44bd33d3345502339ebe62e45790841eddff0 100644 (file)
@@ -52,10 +52,12 @@ SECTIONS
   }
   __initcall_end = .;
 
+#ifdef CONFIG_BLK_DEV_INITRD
   . = ALIGN(8192);
   __initramfs_start = .;
   .init.ramfs : { *(.init.ramfs) }
   __initramfs_end = .;
+#endif
 
   . = ALIGN(8);
   .con_initcall.init : {
index 6783c2e5512de6e75bed91d55a45ff0c14ee0cf5..5c795193ebbad56bcde85161ffaab4fde02e2e90 100644 (file)
@@ -9,6 +9,7 @@ config ARM
        bool
        default y
        select RTC_LIB
+       select SYS_SUPPORTS_APM_EMULATION
        help
          The ARM series is a line of low-power-consumption RISC chip designs
          licensed by ARM Ltd and targeted at embedded applications and
@@ -17,6 +18,9 @@ config ARM
          Europe.  There is an ARM Linux project with a web page at
          <http://www.arm.linux.org.uk/>.
 
+config SYS_SUPPORTS_APM_EMULATION
+       bool
+
 config GENERIC_TIME
        bool
        default n
@@ -25,6 +29,10 @@ config MMU
        bool
        default y
 
+config NO_IOPORT
+       bool
+       default n
+
 config EISA
        bool
        ---help---
@@ -96,6 +104,10 @@ config GENERIC_BUST_SPINLOCK
 config ARCH_MAY_HAVE_PC_FDC
        bool
 
+config ZONE_DMA
+       bool
+       default y
+
 config GENERIC_ISA_DMA
        bool
 
@@ -290,6 +302,7 @@ config ARCH_RPC
        select TIMER_ACORN
        select ARCH_MAY_HAVE_PC_FDC
        select ISA_DMA_API
+       select NO_IOPORT
        help
          On the Acorn Risc-PC, Linux can support the internal IDE disk and
          CD-ROM interface, serial and parallel port, and the floppy drive.
@@ -856,31 +869,6 @@ menu "Power management options"
 
 source "kernel/power/Kconfig"
 
-config APM
-       tristate "Advanced Power Management Emulation"
-       ---help---
-         APM is a BIOS specification for saving power using several different
-         techniques. This is mostly useful for battery powered laptops with
-         APM compliant BIOSes. If you say Y here, the system time will be
-         reset after a RESUME operation, the /proc/apm device will provide
-         battery status information, and user-space programs will receive
-         notification of APM "events" (e.g. battery status change).
-
-         In order to use APM, you will need supporting software. For location
-         and more information, read <file:Documentation/pm.txt> and the
-         Battery Powered Linux mini-HOWTO, available from
-         <http://www.tldp.org/docs.html#howto>.
-
-         This driver does not spin down disk drives (see the hdparm(8)
-         manpage ("man 8 hdparm") for that), and it doesn't turn off
-         VESA-compliant "green" monitors.
-
-         Generally, if you don't have a battery in your machine, there isn't
-         much point in using this driver and you should say N. If you get
-         random kernel OOPSes or reboots that don't seem to be related to
-         anything, try disabling/enabling this option (or disabling/enabling
-         APM in your BIOS).
-
 endmenu
 
 source "net/Kconfig"
index b3599743093ba8f5ece1bc6a3753ee4eb70ee852..a3b450f8ef17b94a32c83b9c92acbf2861019386 100644 (file)
@@ -27,7 +27,7 @@
 #include <asm/hardware.h>
 #include <asm/mach-types.h>
 #include <asm/irq.h>
-#include <asm/apm.h>
+#include <asm/apm-emulation.h>
 #include <asm/arch/pm.h>
 #include <asm/arch/pxa-regs.h>
 #include <asm/arch/sharpsl.h>
index ab06a86e85d58c71e17fb223e8e8ef4b45e22587..1b935fb94b8300a10552b45fc214e2e4d2735198 100644 (file)
@@ -10,7 +10,6 @@ obj-y         := compat.o entry-armv.o entry-common.o irq.o \
                   process.o ptrace.o semaphore.o setup.o signal.o sys_arm.o \
                   time.o traps.o
 
-obj-$(CONFIG_APM)              += apm.o
 obj-$(CONFIG_ISA_DMA_API)      += dma.o
 obj-$(CONFIG_ARCH_ACORN)       += ecard.o 
 obj-$(CONFIG_FIQ)              += fiq.o
index 3c8cdcfe8d4a9f72c9ffb3762a72b260be85d73c..ee47c532e2108b0879bef642c3a5ee174891b581 100644 (file)
@@ -77,16 +77,6 @@ static unsigned long dummy_gettimeoffset(void)
 }
 #endif
 
-/*
- * Scheduler clock - returns current time in nanosec units.
- * This is the default implementation.  Sub-architecture
- * implementations can override this.
- */
-unsigned long long __attribute__((weak)) sched_clock(void)
-{
-       return (unsigned long long)jiffies * (1000000000 / HZ);
-}
-
 /*
  * An implementation of printk_clock() independent from
  * sched_clock().  This avoids non-bootable kernels when
index a8fa75ea07a991a3211da58766cb33dfbca235a9..b929a60f7547cdde716dca1c18b06aafd92f8a22 100644 (file)
@@ -53,10 +53,12 @@ SECTIONS
                __security_initcall_start = .;
                        *(.security_initcall.init)
                __security_initcall_end = .;
+#ifdef CONFIG_BLK_DEV_INITRD
                . = ALIGN(32);
                __initramfs_start = .;
                        usr/built-in.o(.init.ramfs)
                __initramfs_end = .;
+#endif
                . = ALIGN(64);
                __per_cpu_start = .;
                        *(.data.percpu)
index 4c3de4008a43f5e846cc374127983524cccbcc78..165017de8d0d39e2e261c55d41af2ef01ffcdc20 100644 (file)
@@ -16,7 +16,7 @@
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
-#include <asm/apm.h>
+#include <asm/apm-emulation.h>
 #include <asm/irq.h>
 #include <asm/mach-types.h>
 #include <asm/hardware.h>
index db6e8f56a75f59690cb83cc41659a19654a6ba70..b1d8cfca245a2dd18d582963cb2c04a267f19bea 100644 (file)
@@ -23,7 +23,7 @@
 
 #include <asm/hardware.h>
 #include <asm/mach-types.h>
-#include <asm/apm.h>
+#include <asm/apm-emulation.h>
 #include <asm/arch/pm.h>
 #include <asm/arch/pxa-regs.h>
 #include <asm/arch/sharpsl.h>
index 40be833079c7a1f20aee74cac6a262e5ff94a07d..b97d543d93640d6a4f1cb01efbd8e46fac9fe0f7 100644 (file)
@@ -16,7 +16,7 @@
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
-#include <asm/apm.h>
+#include <asm/apm-emulation.h>
 #include <asm/irq.h>
 #include <asm/mach-types.h>
 #include <asm/hardware.h>
index 74eba8b5a8ca41c5576b30c691b56344f0a416ce..989113dce415fadb3ac3e4e6dff03ea40a2ebd7c 100644 (file)
@@ -60,6 +60,10 @@ config GENERIC_CALIBRATE_DELAY
 config GENERIC_BUST_SPINLOCK
        bool
 
+config ZONE_DMA
+       bool
+       default y
+
 config GENERIC_ISA_DMA
        bool
 
index 9dbc17247c6fdfd6a3b00b2fdc734b02aaae02f9..e2bcefc91cc30fe2001e01b6481003659cc64ddc 100644 (file)
@@ -665,7 +665,7 @@ ecard_probe(int slot, card_type_t type)
                ec->fiqmask = 4;
        }
 
-       for (i = 0; i < sizeof(blacklist) / sizeof(*blacklist); i++)
+       for (i = 0; i < ARRAY_SIZE(blacklist); i++)
                if (blacklist[i].manufacturer == ec->cid.manufacturer &&
                    blacklist[i].product == ec->cid.product) {
                        ec->card_desc = blacklist[i].type;
index 1206469b2b86249574f0dd111a83d457b960c7a8..0f1d57fbd3d7bea278fed6bf0ed3a20b0e7ce8d6 100644 (file)
@@ -89,14 +89,6 @@ static unsigned long gettimeoffset(void)
         return (offset + LATCH/2) / LATCH;
 }
 
-/*
- * Scheduler clock - returns current time in nanosec units.
- */
-unsigned long long sched_clock(void)
-{
-       return (unsigned long long)jiffies * (1000000000 / HZ);
-}
-
 static unsigned long next_rtc_update;
 
 /*
index ca61ec8218fe4bd33657766cbec3f2c0cfabdbc7..046a85054018ff4ee849e99d2cfe3483b3025657 100644 (file)
@@ -46,10 +46,12 @@ SECTIONS
                __con_initcall_start = .;
                        *(.con_initcall.init)
                __con_initcall_end = .;
+#ifdef CONFIG_BLK_DEV_INITRD
                . = ALIGN(32);
                __initramfs_start = .;
                        usr/built-in.o(.init.ramfs)
                __initramfs_end = .;
+#endif
                . = ALIGN(32768);
                __init_end = .;
        }
index d1d3418d7eb623627005e398094660ed678035d1..1d2949e83be8de301112f98bec3599cd046a7047 100644 (file)
@@ -47,10 +47,12 @@ SECTIONS
                __con_initcall_start = .;
                        *(.con_initcall.init)
                __con_initcall_end = .;
+#ifdef CONFIG_BLK_DEV_INITRD
                . = ALIGN(32);
                __initramfs_start = .;
                        usr/built-in.o(.init.ramfs)
                __initramfs_end = .;
+#endif
                . = ALIGN(32768);
                __init_end = .;
        }
index df9499480530bf2640cfd2b653ae609175c6e2ea..8e0992201bb98b931d9578feeac8a05d5a9ae828 100644 (file)
@@ -1,2 +1,2 @@
-obj-y                          += setup.o spi.o flash.o
+obj-y                          += setup.o flash.o
 obj-$(CONFIG_BOARD_ATSTK1002)  += atstk1002.o
index 32b361f31c2ce443a9c8760bd80ce6eeaade8d44..d47e39f0e971925f81cba2588fa185b5829ed1a0 100644 (file)
@@ -8,17 +8,24 @@
  * published by the Free Software Foundation.
  */
 #include <linux/clk.h>
+#include <linux/device.h>
 #include <linux/etherdevice.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/platform_device.h>
 #include <linux/string.h>
 #include <linux/types.h>
+#include <linux/spi/spi.h>
 
 #include <asm/io.h>
 #include <asm/setup.h>
+#include <asm/arch/at32ap7000.h>
 #include <asm/arch/board.h>
 #include <asm/arch/init.h>
+#include <asm/arch/portmux.h>
+
+
+#define        SW2_DEFAULT             /* MMCI and UART_A available */
 
 struct eth_addr {
        u8 addr[6];
@@ -29,6 +36,16 @@ static struct eth_addr __initdata hw_addr[2];
 static struct eth_platform_data __initdata eth_data[2];
 extern struct lcdc_platform_data atstk1000_fb0_data;
 
+static struct spi_board_info spi_board_info[] __initdata = {
+       {
+               .modalias       = "ltv350qv",
+               .controller_data = (void *)GPIO_PIN_PA(4),
+               .max_speed_hz   = 16000000,
+               .bus_num        = 0,
+               .chip_select    = 1,
+       },
+};
+
 /*
  * The next two functions should go away as the boot loader is
  * supposed to initialize the macb address registers with a valid
@@ -86,23 +103,53 @@ static void __init set_hw_addr(struct platform_device *pdev)
 
 void __init setup_board(void)
 {
-       at32_map_usart(1, 0);   /* /dev/ttyS0 */
-       at32_map_usart(2, 1);   /* /dev/ttyS1 */
-       at32_map_usart(3, 2);   /* /dev/ttyS2 */
+#ifdef SW2_DEFAULT
+       at32_map_usart(1, 0);   /* USART 1/A: /dev/ttyS0, DB9 */
+#else
+       at32_map_usart(0, 1);   /* USART 0/B: /dev/ttyS1, IRDA */
+#endif
+       /* USART 2/unused: expansion connector */
+       at32_map_usart(3, 2);   /* USART 3/C: /dev/ttyS2, DB9 */
 
        at32_setup_serial_console(0);
 }
 
 static int __init atstk1002_init(void)
 {
+       /*
+        * ATSTK1000 uses 32-bit SDRAM interface. Reserve the
+        * SDRAM-specific pins so that nobody messes with them.
+        */
+       at32_reserve_pin(GPIO_PIN_PE(0));       /* DATA[16]     */
+       at32_reserve_pin(GPIO_PIN_PE(1));       /* DATA[17]     */
+       at32_reserve_pin(GPIO_PIN_PE(2));       /* DATA[18]     */
+       at32_reserve_pin(GPIO_PIN_PE(3));       /* DATA[19]     */
+       at32_reserve_pin(GPIO_PIN_PE(4));       /* DATA[20]     */
+       at32_reserve_pin(GPIO_PIN_PE(5));       /* DATA[21]     */
+       at32_reserve_pin(GPIO_PIN_PE(6));       /* DATA[22]     */
+       at32_reserve_pin(GPIO_PIN_PE(7));       /* DATA[23]     */
+       at32_reserve_pin(GPIO_PIN_PE(8));       /* DATA[24]     */
+       at32_reserve_pin(GPIO_PIN_PE(9));       /* DATA[25]     */
+       at32_reserve_pin(GPIO_PIN_PE(10));      /* DATA[26]     */
+       at32_reserve_pin(GPIO_PIN_PE(11));      /* DATA[27]     */
+       at32_reserve_pin(GPIO_PIN_PE(12));      /* DATA[28]     */
+       at32_reserve_pin(GPIO_PIN_PE(13));      /* DATA[29]     */
+       at32_reserve_pin(GPIO_PIN_PE(14));      /* DATA[30]     */
+       at32_reserve_pin(GPIO_PIN_PE(15));      /* DATA[31]     */
+       at32_reserve_pin(GPIO_PIN_PE(26));      /* SDCS         */
+
        at32_add_system_devices();
 
+#ifdef SW2_DEFAULT
        at32_add_device_usart(0);
+#else
        at32_add_device_usart(1);
+#endif
        at32_add_device_usart(2);
 
        set_hw_addr(at32_add_device_eth(0, &eth_data[0]));
 
+       spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
        at32_add_device_spi(0);
        at32_add_device_lcdc(0, &atstk1000_fb0_data);
 
diff --git a/arch/avr32/boards/atstk1000/spi.c b/arch/avr32/boards/atstk1000/spi.c
deleted file mode 100644 (file)
index 567726c..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * ATSTK1000 SPI devices
- *
- * Copyright (C) 2005 Atmel Norway
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-#include <linux/device.h>
-#include <linux/spi/spi.h>
-
-static struct spi_board_info spi_board_info[] __initdata = {
-       {
-               .modalias       = "ltv350qv",
-               .max_speed_hz   = 16000000,
-               .bus_num        = 0,
-               .chip_select    = 1,
-       },
-};
-
-static int board_init_spi(void)
-{
-       spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
-       return 0;
-}
-arch_initcall(board_init_spi);
index 342452ba204927f31ff5fc2d8b829582af52f5e5..2e72fd2699dfc4aaf83d7437ddbb028be8046a46 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/sysdev.h>
 #include <linux/seq_file.h>
 #include <linux/cpu.h>
+#include <linux/module.h>
 #include <linux/percpu.h>
 #include <linux/param.h>
 #include <linux/errno.h>
index 856f3548e6648065d9d7cea8057ed1f77ba759ae..fd311248c143ce8b53ba605be192ef28a7f26784 100644 (file)
@@ -57,6 +57,7 @@ int show_interrupts(struct seq_file *p, void *v)
                seq_printf(p, "%3d: ", i);
                for_each_online_cpu(cpu)
                        seq_printf(p, "%10u ", kstat_cpu(cpu).irqs[i]);
+               seq_printf(p, " %8s", irq_desc[i].chip->name ? : "-");
                seq_printf(p, "  %s", action->name);
                for (action = action->next; action; action = action->next)
                        seq_printf(p, ", %s", action->name);
index a34211601008420f456e185b825c9ed426eb51c7..c6734aefb559992e4eef8b4eb5d25b64ce0a6d6b 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/module.h>
 #include <linux/root_dev.h>
 #include <linux/cpu.h>
+#include <linux/kernel.h>
 
 #include <asm/sections.h>
 #include <asm/processor.h>
@@ -174,8 +175,7 @@ static int __init parse_tag_mem_range(struct tag *tag,
         * Copy the data so the bootmem init code doesn't need to care
         * about it.
         */
-       if (mem_range_next_free >=
-           (sizeof(mem_range_cache) / sizeof(mem_range_cache[0])))
+       if (mem_range_next_free >= ARRAY_SIZE(mem_range_cache))
                panic("Physical memory map too complex!\n");
 
        new = &mem_range_cache[mem_range_next_free++];
index 5a247ba71a72e1bdfcd036e3ca8840eb35fbfe08..a2f74affaa98b920729d629a71d55c796475e0e3 100644 (file)
@@ -109,15 +109,6 @@ static void avr32_hpt_init(unsigned int count)
        sysreg_write(COUNT, count);
 }
 
-/*
- * Scheduler clock - returns current time in nanosec units.
- */
-unsigned long long sched_clock(void)
-{
-       /* There must be better ways...? */
-       return (unsigned long long)jiffies * (1000000000 / HZ);
-}
-
 /*
  * local_timer_interrupt() does profiling and process accounting on a
  * per-CPU basis.
index 5c4424e362b50cbaf918ccb264693f87ccf7509b..ef13b7c78935dba91cce904c289f3259f689db75 100644 (file)
@@ -46,10 +46,12 @@ SECTIONS
                __security_initcall_start = .;
                        *(.security_initcall.init)
                __security_initcall_end = .;
+#ifdef CONFIG_BLK_DEV_INITRD
                . = ALIGN(32);
                __initramfs_start = .;
                        *(.init.ramfs)
                __initramfs_end = .;
+#endif
                . = ALIGN(4096);
                __init_end = .;
        }
diff --git a/arch/avr32/lib/libgcc.h b/arch/avr32/lib/libgcc.h
deleted file mode 100644 (file)
index 5a091b5..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Definitions for various functions 'borrowed' from gcc-3.4.3 */
-
-#define BITS_PER_UNIT  8
-
-typedef                 int QItype     __attribute__ ((mode (QI)));
-typedef unsigned int UQItype   __attribute__ ((mode (QI)));
-typedef                 int HItype     __attribute__ ((mode (HI)));
-typedef unsigned int UHItype   __attribute__ ((mode (HI)));
-typedef         int SItype     __attribute__ ((mode (SI)));
-typedef unsigned int USItype   __attribute__ ((mode (SI)));
-typedef                 int DItype     __attribute__ ((mode (DI)));
-typedef unsigned int UDItype   __attribute__ ((mode (DI)));
-typedef        float SFtype    __attribute__ ((mode (SF)));
-typedef                float DFtype    __attribute__ ((mode (DF)));
-typedef int word_type __attribute__ ((mode (__word__)));
-
-#define W_TYPE_SIZE (4 * BITS_PER_UNIT)
-#define Wtype  SItype
-#define UWtype USItype
-#define HWtype SItype
-#define UHWtype        USItype
-#define DWtype DItype
-#define UDWtype        UDItype
-#define __NW(a,b)      __ ## a ## si ## b
-#define __NDW(a,b)     __ ## a ## di ## b
-
-struct DWstruct {Wtype high, low;};
-
-typedef union
-{
-  struct DWstruct s;
-  DWtype ll;
-} DWunion;
diff --git a/arch/avr32/lib/longlong.h b/arch/avr32/lib/longlong.h
deleted file mode 100644 (file)
index cd5e369..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/* longlong.h -- definitions for mixed size 32/64 bit arithmetic.
-   Copyright (C) 1991, 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000
-   Free Software Foundation, Inc.
-
-   This definition file is free software; you can redistribute it
-   and/or modify it under the terms of the GNU General Public
-   License as published by the Free Software Foundation; either
-   version 2, or (at your option) any later version.
-
-   This definition file is distributed in the hope that it will be
-   useful, but WITHOUT ANY WARRANTY; without even the implied
-   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-   See the GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  */
-
-/* Borrowed from gcc-3.4.3 */
-
-#define __BITS4 (W_TYPE_SIZE / 4)
-#define __ll_B ((UWtype) 1 << (W_TYPE_SIZE / 2))
-#define __ll_lowpart(t) ((UWtype) (t) & (__ll_B - 1))
-#define __ll_highpart(t) ((UWtype) (t) >> (W_TYPE_SIZE / 2))
-
-#define count_leading_zeros(count, x) ((count) = __builtin_clz(x))
-
-#define __udiv_qrnnd_c(q, r, n1, n0, d) \
-  do {                                                                 \
-    UWtype __d1, __d0, __q1, __q0;                                     \
-    UWtype __r1, __r0, __m;                                            \
-    __d1 = __ll_highpart (d);                                          \
-    __d0 = __ll_lowpart (d);                                           \
-                                                                       \
-    __r1 = (n1) % __d1;                                                        \
-    __q1 = (n1) / __d1;                                                        \
-    __m = (UWtype) __q1 * __d0;                                                \
-    __r1 = __r1 * __ll_B | __ll_highpart (n0);                         \
-    if (__r1 < __m)                                                    \
-      {                                                                        \
-       __q1--, __r1 += (d);                                            \
-       if (__r1 >= (d)) /* i.e. we didn't get carry when adding to __r1 */\
-         if (__r1 < __m)                                               \
-           __q1--, __r1 += (d);                                        \
-      }                                                                        \
-    __r1 -= __m;                                                       \
-                                                                       \
-    __r0 = __r1 % __d1;                                                        \
-    __q0 = __r1 / __d1;                                                        \
-    __m = (UWtype) __q0 * __d0;                                                \
-    __r0 = __r0 * __ll_B | __ll_lowpart (n0);                          \
-    if (__r0 < __m)                                                    \
-      {                                                                        \
-       __q0--, __r0 += (d);                                            \
-       if (__r0 >= (d))                                                \
-         if (__r0 < __m)                                               \
-           __q0--, __r0 += (d);                                        \
-      }                                                                        \
-    __r0 -= __m;                                                       \
-                                                                       \
-    (q) = (UWtype) __q1 * __ll_B | __q0;                               \
-    (r) = __r0;                                                                \
-  } while (0)
-
-#define udiv_qrnnd __udiv_qrnnd_c
-
-#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
-  do {                                                                 \
-    UWtype __x;                                                                \
-    __x = (al) - (bl);                                                 \
-    (sh) = (ah) - (bh) - (__x > (al));                                 \
-    (sl) = __x;                                                                \
-  } while (0)
-
-#define umul_ppmm(w1, w0, u, v)                                                \
-  do {                                                                 \
-    UWtype __x0, __x1, __x2, __x3;                                     \
-    UHWtype __ul, __vl, __uh, __vh;                                    \
-                                                                       \
-    __ul = __ll_lowpart (u);                                           \
-    __uh = __ll_highpart (u);                                          \
-    __vl = __ll_lowpart (v);                                           \
-    __vh = __ll_highpart (v);                                          \
-                                                                       \
-    __x0 = (UWtype) __ul * __vl;                                       \
-    __x1 = (UWtype) __ul * __vh;                                       \
-    __x2 = (UWtype) __uh * __vl;                                       \
-    __x3 = (UWtype) __uh * __vh;                                       \
-                                                                       \
-    __x1 += __ll_highpart (__x0);/* this can't give carry */           \
-    __x1 += __x2;              /* but this indeed can */               \
-    if (__x1 < __x2)           /* did we get it? */                    \
-      __x3 += __ll_B;          /* yes, add it in the proper pos.  */   \
-                                                                       \
-    (w1) = __x3 + __ll_highpart (__x1);                                        \
-    (w0) = __ll_lowpart (__x1) * __ll_B + __ll_lowpart (__x0);         \
-  } while (0)
index f62eb691551010f63f6d76b2b845732b550be63a..b21bea9af8b11000ddccb6a38355f75809984d6c 100644 (file)
@@ -1,2 +1,2 @@
-obj-y                          += at32ap.o clock.o pio.o intc.o extint.o hsmc.o
+obj-y                          += at32ap.o clock.o intc.o extint.o pio.o hsmc.o
 obj-$(CONFIG_CPU_AT32AP7000)   += at32ap7000.o
index 48f4ef38c70e4a097ead99b9dc8a3ccd8195048f..c1e477ec7576850887591f9cc14c7d42128fa0b0 100644 (file)
@@ -496,9 +496,16 @@ static struct resource pio3_resource[] = {
 DEFINE_DEV(pio, 3);
 DEV_CLK(mck, pio3, pba, 13);
 
+static struct resource pio4_resource[] = {
+       PBMEM(0xffe03800),
+       IRQ(17),
+};
+DEFINE_DEV(pio, 4);
+DEV_CLK(mck, pio4, pba, 14);
+
 void __init at32_add_system_devices(void)
 {
-       system_manager.eim_first_irq = NR_INTERNAL_IRQS;
+       system_manager.eim_first_irq = EIM_IRQ_BASE;
 
        platform_device_register(&at32_sm_device);
        platform_device_register(&at32_intc0_device);
@@ -509,6 +516,7 @@ void __init at32_add_system_devices(void)
        platform_device_register(&pio1_device);
        platform_device_register(&pio2_device);
        platform_device_register(&pio3_device);
+       platform_device_register(&pio4_device);
 }
 
 /* --------------------------------------------------------------------
@@ -521,7 +529,7 @@ static struct atmel_uart_data atmel_usart0_data = {
 };
 static struct resource atmel_usart0_resource[] = {
        PBMEM(0xffe00c00),
-       IRQ(7),
+       IRQ(6),
 };
 DEFINE_DEV_DATA(atmel_usart, 0);
 DEV_CLK(usart, atmel_usart0, pba, 4);
@@ -583,7 +591,7 @@ static inline void configure_usart3_pins(void)
        select_peripheral(PB(17), PERIPH_B, 0); /* TXD  */
 }
 
-static struct platform_device *at32_usarts[4];
+static struct platform_device *__initdata at32_usarts[4];
 
 void __init at32_map_usart(unsigned int hw_id, unsigned int line)
 {
@@ -728,12 +736,19 @@ at32_add_device_eth(unsigned int id, struct eth_platform_data *data)
 /* --------------------------------------------------------------------
  *  SPI
  * -------------------------------------------------------------------- */
-static struct resource spi0_resource[] = {
+static struct resource atmel_spi0_resource[] = {
        PBMEM(0xffe00000),
        IRQ(3),
 };
-DEFINE_DEV(spi, 0);
-DEV_CLK(mck, spi0, pba, 0);
+DEFINE_DEV(atmel_spi, 0);
+DEV_CLK(spi_clk, atmel_spi0, pba, 0);
+
+static struct resource atmel_spi1_resource[] = {
+       PBMEM(0xffe00400),
+       IRQ(4),
+};
+DEFINE_DEV(atmel_spi, 1);
+DEV_CLK(spi_clk, atmel_spi1, pba, 1);
 
 struct platform_device *__init at32_add_device_spi(unsigned int id)
 {
@@ -741,13 +756,33 @@ struct platform_device *__init at32_add_device_spi(unsigned int id)
 
        switch (id) {
        case 0:
-               pdev = &spi0_device;
+               pdev = &atmel_spi0_device;
                select_peripheral(PA(0),  PERIPH_A, 0); /* MISO  */
                select_peripheral(PA(1),  PERIPH_A, 0); /* MOSI  */
                select_peripheral(PA(2),  PERIPH_A, 0); /* SCK   */
-               select_peripheral(PA(3),  PERIPH_A, 0); /* NPCS0 */
-               select_peripheral(PA(4),  PERIPH_A, 0); /* NPCS1 */
-               select_peripheral(PA(5),  PERIPH_A, 0); /* NPCS2 */
+
+               /* NPCS[2:0] */
+               at32_select_gpio(GPIO_PIN_PA(3),
+                                AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH);
+               at32_select_gpio(GPIO_PIN_PA(4),
+                                AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH);
+               at32_select_gpio(GPIO_PIN_PA(5),
+                                AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH);
+               break;
+
+       case 1:
+               pdev = &atmel_spi1_device;
+               select_peripheral(PB(0),  PERIPH_B, 0); /* MISO  */
+               select_peripheral(PB(1),  PERIPH_B, 0); /* MOSI  */
+               select_peripheral(PB(5),  PERIPH_B, 0); /* SCK   */
+
+               /* NPCS[2:0] */
+               at32_select_gpio(GPIO_PIN_PB(2),
+                                AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH);
+               at32_select_gpio(GPIO_PIN_PB(3),
+                                AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH);
+               at32_select_gpio(GPIO_PIN_PB(4),
+                                AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH);
                break;
 
        default:
@@ -860,6 +895,7 @@ struct clk *at32_clock_list[] = {
        &pio1_mck,
        &pio2_mck,
        &pio3_mck,
+       &pio4_mck,
        &atmel_usart0_usart,
        &atmel_usart1_usart,
        &atmel_usart2_usart,
@@ -868,7 +904,8 @@ struct clk *at32_clock_list[] = {
        &macb0_pclk,
        &macb1_hclk,
        &macb1_pclk,
-       &spi0_mck,
+       &atmel_spi0_spi_clk,
+       &atmel_spi1_spi_clk,
        &lcdc0_hclk,
        &lcdc0_pixclk,
 };
@@ -880,6 +917,7 @@ void __init at32_portmux_init(void)
        at32_init_pio(&pio1_device);
        at32_init_pio(&pio2_device);
        at32_init_pio(&pio3_device);
+       at32_init_pio(&pio4_device);
 }
 
 void __init at32_clock_init(void)
index b59272e81b9a049be31be3105d23354742d11388..4a60eccfebd240762e751a3c43bd4191cb5fe714 100644 (file)
@@ -55,20 +55,11 @@ static int eim_set_irq_type(unsigned int irq, unsigned int flow_type)
        unsigned long flags;
        int ret = 0;
 
+       flow_type &= IRQ_TYPE_SENSE_MASK;
        if (flow_type == IRQ_TYPE_NONE)
                flow_type = IRQ_TYPE_LEVEL_LOW;
 
        desc = &irq_desc[irq];
-       desc->status &= ~(IRQ_TYPE_SENSE_MASK | IRQ_LEVEL);
-       desc->status |= flow_type & IRQ_TYPE_SENSE_MASK;
-
-       if (flow_type & (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_LEVEL_HIGH)) {
-               desc->status |= IRQ_LEVEL;
-               set_irq_handler(irq, handle_level_irq);
-       } else {
-               set_irq_handler(irq, handle_edge_irq);
-       }
-
        spin_lock_irqsave(&sm->lock, flags);
 
        mode = sm_readl(sm, EIM_MODE);
@@ -97,9 +88,16 @@ static int eim_set_irq_type(unsigned int irq, unsigned int flow_type)
                break;
        }
 
-       sm_writel(sm, EIM_MODE, mode);
-       sm_writel(sm, EIM_EDGE, edge);
-       sm_writel(sm, EIM_LEVEL, level);
+       if (ret == 0) {
+               sm_writel(sm, EIM_MODE, mode);
+               sm_writel(sm, EIM_EDGE, edge);
+               sm_writel(sm, EIM_LEVEL, level);
+
+               if (flow_type & (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_LEVEL_HIGH))
+                       flow_type |= IRQ_LEVEL;
+               desc->status &= ~(IRQ_TYPE_SENSE_MASK | IRQ_LEVEL);
+               desc->status |= flow_type;
+       }
 
        spin_unlock_irqrestore(&sm->lock, flags);
 
@@ -122,8 +120,6 @@ static void demux_eim_irq(unsigned int irq, struct irq_desc *desc)
        unsigned long status, pending;
        unsigned int i, ext_irq;
 
-       spin_lock(&sm->lock);
-
        status = sm_readl(sm, EIM_ISR);
        pending = status & sm_readl(sm, EIM_IMR);
 
@@ -133,10 +129,11 @@ static void demux_eim_irq(unsigned int irq, struct irq_desc *desc)
 
                ext_irq = i + sm->eim_first_irq;
                ext_desc = irq_desc + ext_irq;
-               ext_desc->handle_irq(ext_irq, ext_desc);
+               if (ext_desc->status & IRQ_LEVEL)
+                       handle_level_irq(ext_irq, ext_desc);
+               else
+                       handle_edge_irq(ext_irq, ext_desc);
        }
-
-       spin_unlock(&sm->lock);
 }
 
 static int __init eim_init(void)
@@ -168,8 +165,9 @@ static int __init eim_init(void)
        sm->eim_chip = &eim_chip;
 
        for (i = 0; i < nr_irqs; i++) {
+               /* NOTE the handler we set here is ignored by the demux */
                set_irq_chip_and_handler(sm->eim_first_irq + i, &eim_chip,
-                                        handle_edge_irq);
+                                        handle_level_irq);
                set_irq_chip_data(sm->eim_first_irq + i, sm);
        }
 
index f1280ed8ed6dcb6a7b48fd5418d3c116e3bb7794..9ba5654cde110dda279fe83498ab5a1c25d33144 100644 (file)
@@ -12,7 +12,9 @@
 #include <linux/debugfs.h>
 #include <linux/fs.h>
 #include <linux/platform_device.h>
+#include <linux/irq.h>
 
+#include <asm/gpio.h>
 #include <asm/io.h>
 
 #include <asm/arch/portmux.h>
@@ -26,7 +28,8 @@ struct pio_device {
        const struct platform_device *pdev;
        struct clk *clk;
        u32 pinmux_mask;
-       char name[32];
+       u32 gpio_mask;
+       char name[8];
 };
 
 static struct pio_device pio_dev[MAX_NR_PIO_DEVICES];
@@ -76,6 +79,9 @@ void __init at32_select_periph(unsigned int pin, unsigned int periph,
        if (!(flags & AT32_GPIOF_PULLUP))
                pio_writel(pio, PUDR, mask);
 
+       /* gpio_request NOT allowed */
+       set_bit(pin_index, &pio->gpio_mask);
+
        return;
 
 fail:
@@ -99,19 +105,52 @@ void __init at32_select_gpio(unsigned int pin, unsigned long flags)
                goto fail;
        }
 
-       pio_writel(pio, PUER, mask);
-       if (flags & AT32_GPIOF_HIGH)
-               pio_writel(pio, SODR, mask);
-       else
-               pio_writel(pio, CODR, mask);
-       if (flags & AT32_GPIOF_OUTPUT)
+       if (flags & AT32_GPIOF_OUTPUT) {
+               if (flags & AT32_GPIOF_HIGH)
+                       pio_writel(pio, SODR, mask);
+               else
+                       pio_writel(pio, CODR, mask);
+               pio_writel(pio, PUDR, mask);
                pio_writel(pio, OER, mask);
-       else
+       } else {
+               if (flags & AT32_GPIOF_PULLUP)
+                       pio_writel(pio, PUER, mask);
+               else
+                       pio_writel(pio, PUDR, mask);
+               if (flags & AT32_GPIOF_DEGLITCH)
+                       pio_writel(pio, IFER, mask);
+               else
+                       pio_writel(pio, IFDR, mask);
                pio_writel(pio, ODR, mask);
+       }
 
        pio_writel(pio, PER, mask);
-       if (!(flags & AT32_GPIOF_PULLUP))
-               pio_writel(pio, PUDR, mask);
+
+       /* gpio_request now allowed */
+       clear_bit(pin_index, &pio->gpio_mask);
+
+       return;
+
+fail:
+       dump_stack();
+}
+
+/* Reserve a pin, preventing anyone else from changing its configuration. */
+void __init at32_reserve_pin(unsigned int pin)
+{
+       struct pio_device *pio;
+       unsigned int pin_index = pin & 0x1f;
+
+       pio = gpio_to_pio(pin);
+       if (unlikely(!pio)) {
+               printk("pio: invalid pin %u\n", pin);
+               goto fail;
+       }
+
+       if (unlikely(test_and_set_bit(pin_index, &pio->pinmux_mask))) {
+               printk("%s: pin %u is busy\n", pio->name, pin_index);
+               goto fail;
+       }
 
        return;
 
@@ -119,20 +158,197 @@ fail:
        dump_stack();
 }
 
+/*--------------------------------------------------------------------------*/
+
+/* GPIO API */
+
+int gpio_request(unsigned int gpio, const char *label)
+{
+       struct pio_device *pio;
+       unsigned int pin;
+
+       pio = gpio_to_pio(gpio);
+       if (!pio)
+               return -ENODEV;
+
+       pin = gpio & 0x1f;
+       if (test_and_set_bit(pin, &pio->gpio_mask))
+               return -EBUSY;
+
+       return 0;
+}
+EXPORT_SYMBOL(gpio_request);
+
+void gpio_free(unsigned int gpio)
+{
+       struct pio_device *pio;
+       unsigned int pin;
+
+       pio = gpio_to_pio(gpio);
+       if (!pio) {
+               printk(KERN_ERR
+                      "gpio: attempted to free invalid pin %u\n", gpio);
+               return;
+       }
+
+       pin = gpio & 0x1f;
+       if (!test_and_clear_bit(pin, &pio->gpio_mask))
+               printk(KERN_ERR "gpio: freeing free or non-gpio pin %s-%u\n",
+                      pio->name, pin);
+}
+EXPORT_SYMBOL(gpio_free);
+
+int gpio_direction_input(unsigned int gpio)
+{
+       struct pio_device *pio;
+       unsigned int pin;
+
+       pio = gpio_to_pio(gpio);
+       if (!pio)
+               return -ENODEV;
+
+       pin = gpio & 0x1f;
+       pio_writel(pio, ODR, 1 << pin);
+
+       return 0;
+}
+EXPORT_SYMBOL(gpio_direction_input);
+
+int gpio_direction_output(unsigned int gpio)
+{
+       struct pio_device *pio;
+       unsigned int pin;
+
+       pio = gpio_to_pio(gpio);
+       if (!pio)
+               return -ENODEV;
+
+       pin = gpio & 0x1f;
+       pio_writel(pio, OER, 1 << pin);
+
+       return 0;
+}
+EXPORT_SYMBOL(gpio_direction_output);
+
+int gpio_get_value(unsigned int gpio)
+{
+       struct pio_device *pio = &pio_dev[gpio >> 5];
+
+       return (pio_readl(pio, PDSR) >> (gpio & 0x1f)) & 1;
+}
+EXPORT_SYMBOL(gpio_get_value);
+
+void gpio_set_value(unsigned int gpio, int value)
+{
+       struct pio_device *pio = &pio_dev[gpio >> 5];
+       u32 mask;
+
+       mask = 1 << (gpio & 0x1f);
+       if (value)
+               pio_writel(pio, SODR, mask);
+       else
+               pio_writel(pio, CODR, mask);
+}
+EXPORT_SYMBOL(gpio_set_value);
+
+/*--------------------------------------------------------------------------*/
+
+/* GPIO IRQ support */
+
+static void gpio_irq_mask(unsigned irq)
+{
+       unsigned                gpio = irq_to_gpio(irq);
+       struct pio_device       *pio = &pio_dev[gpio >> 5];
+
+       pio_writel(pio, IDR, 1 << (gpio & 0x1f));
+}
+
+static void gpio_irq_unmask(unsigned irq)
+{
+       unsigned                gpio = irq_to_gpio(irq);
+       struct pio_device       *pio = &pio_dev[gpio >> 5];
+
+       pio_writel(pio, IER, 1 << (gpio & 0x1f));
+}
+
+static int gpio_irq_type(unsigned irq, unsigned type)
+{
+       if (type != IRQ_TYPE_EDGE_BOTH && type != IRQ_TYPE_NONE)
+               return -EINVAL;
+
+       return 0;
+}
+
+static struct irq_chip gpio_irqchip = {
+       .name           = "gpio",
+       .mask           = gpio_irq_mask,
+       .unmask         = gpio_irq_unmask,
+       .set_type       = gpio_irq_type,
+};
+
+static void gpio_irq_handler(unsigned irq, struct irq_desc *desc)
+{
+       struct pio_device       *pio = get_irq_chip_data(irq);
+       unsigned                gpio_irq;
+
+       gpio_irq = (unsigned) get_irq_data(irq);
+       for (;;) {
+               u32             isr;
+               struct irq_desc *d;
+
+               /* ack pending GPIO interrupts */
+               isr = pio_readl(pio, ISR) & pio_readl(pio, IMR);
+               if (!isr)
+                       break;
+               do {
+                       int i;
+
+                       i = ffs(isr) - 1;
+                       isr &= ~(1 << i);
+
+                       i += gpio_irq;
+                       d = &irq_desc[i];
+
+                       d->handle_irq(i, d);
+               } while (isr);
+       }
+}
+
+static void __init
+gpio_irq_setup(struct pio_device *pio, int irq, int gpio_irq)
+{
+       unsigned        i;
+
+       set_irq_chip_data(irq, pio);
+       set_irq_data(irq, (void *) gpio_irq);
+
+       for (i = 0; i < 32; i++, gpio_irq++) {
+               set_irq_chip_data(gpio_irq, pio);
+               set_irq_chip_and_handler(gpio_irq, &gpio_irqchip,
+                               handle_simple_irq);
+       }
+
+       set_irq_chained_handler(irq, gpio_irq_handler);
+}
+
+/*--------------------------------------------------------------------------*/
+
 static int __init pio_probe(struct platform_device *pdev)
 {
        struct pio_device *pio = NULL;
+       int irq = platform_get_irq(pdev, 0);
+       int gpio_irq_base = GPIO_IRQ_BASE + pdev->id * 32;
 
        BUG_ON(pdev->id >= MAX_NR_PIO_DEVICES);
        pio = &pio_dev[pdev->id];
        BUG_ON(!pio->regs);
 
-       /* TODO: Interrupts */
+       gpio_irq_setup(pio, irq, gpio_irq_base);
 
        platform_set_drvdata(pdev, pio);
 
-       printk(KERN_INFO "%s: Atmel Port Multiplexer at 0x%p (irq %d)\n",
-              pio->name, pio->regs, platform_get_irq(pdev, 0));
+       printk(KERN_DEBUG "%s: base 0x%p, irq %d chains %d..%d\n",
+              pio->name, pio->regs, irq, gpio_irq_base, gpio_irq_base + 31);
 
        return 0;
 }
@@ -148,7 +364,7 @@ static int __init pio_init(void)
 {
        return platform_driver_register(&pio_driver);
 }
-subsys_initcall(pio_init);
+postcore_initcall(pio_init);
 
 void __init at32_init_pio(struct platform_device *pdev)
 {
@@ -184,6 +400,13 @@ void __init at32_init_pio(struct platform_device *pdev)
        pio->pdev = pdev;
        pio->regs = ioremap(regs->start, regs->end - regs->start + 1);
 
-       pio_writel(pio, ODR, ~0UL);
-       pio_writel(pio, PER, ~0UL);
+       /*
+        * request_gpio() is only valid for pins that have been
+        * explicitly configured as GPIO and not previously requested
+        */
+       pio->gpio_mask = ~0UL;
+
+       /* start with irqs disabled and acked */
+       pio_writel(pio, IDR, ~0UL);
+       (void) pio_readl(pio, ISR);
 }
index 450515b245a08dd0418ec65f51610048815cfcd4..fb13f72e9a0290430a45db2ff6a65dafe9c114b4 100644 (file)
 
 void invalidate_dcache_region(void *start, size_t size)
 {
-       unsigned long v, begin, end, linesz;
+       unsigned long v, begin, end, linesz, mask;
+       int flush = 0;
 
        linesz = boot_cpu_data.dcache.linesz;
+       mask = linesz - 1;
+
+       /* when first and/or last cachelines are shared, flush them
+        * instead of invalidating ... never discard valid data!
+        */
+       begin = (unsigned long)start;
+       end = begin + size - 1;
+
+       if (begin & mask) {
+               flush_dcache_line(start);
+               begin += linesz;
+               flush = 1;
+       }
+       if ((end & mask) != mask) {
+               flush_dcache_line((void *)end);
+               end -= linesz;
+               flush = 1;
+       }
 
-       //printk("invalidate dcache: %p + %u\n", start, size);
-
-       /* You asked for it, you got it */
-       begin = (unsigned long)start & ~(linesz - 1);
-       end = ((unsigned long)start + size + linesz - 1) & ~(linesz - 1);
-
-       for (v = begin; v < end; v += linesz)
+       /* remaining cachelines only need invalidation */
+       for (v = begin; v <= end; v += linesz)
                invalidate_dcache_line((void *)v);
+       if (flush)
+               flush_write_buffer();
 }
 
 void clean_dcache_region(void *start, size_t size)
index 3474309e049c857ac2192c50fe1429358aff0dfc..4b41248b61ad8b6922df5b31c3ebdfa98d52945d 100644 (file)
@@ -9,6 +9,10 @@ config MMU
        bool
        default y
 
+config ZONE_DMA
+       bool
+       default y
+
 config RWSEM_GENERIC_SPINLOCK
        bool
        default y
@@ -40,6 +44,9 @@ config IRQ_PER_CPU
        bool
        default y
 
+config NO_IOPORT
+       def_bool y
+
 config CRIS
        bool
        default y
index ffade19a14e6f0b974dbea77034bacc329ebd795..efd7b0f3a91042aa85455309594979ec6de44a3a 100644 (file)
@@ -359,8 +359,7 @@ static struct mtd_info *flash_probe(void)
                 * So we use the MTD concatenation layer instead of further
                 * complicating the probing procedure.
                 */
-               mtd_cse = mtd_concat_create(mtds,
-                                           sizeof(mtds) / sizeof(mtds[0]),
+               mtd_cse = mtd_concat_create(mtds, ARRAY_SIZE(mtds),
                                            "cse0+cse1");
 #else
                printk(KERN_ERR "%s and %s: Cannot concatenate due to kernel "
index ebacf1457d914cacae4069c21094639fbc906dd7..077e973c33f0c131be44a9c8e32fd4c149b61528 100644 (file)
@@ -38,7 +38,6 @@ unsigned long get_ns_in_jiffie(void)
        unsigned long flags;
 
        local_irq_save(flags);
-       local_irq_disable();
        timer_count = *R_TIMER0_DATA;
        presc_count = *R_TIM_PRESC_STATUS;  
        /* presc_count might be wrapped */
index 70a5523eff78b3a5f7ec2c98b4e4d98bd6a6d70d..7d9fec88dee56c16bdc6eef806c4d1b3fc450708 100644 (file)
@@ -42,8 +42,7 @@ flush_tlb_all(void)
         * in the same 4-way entry group. details.. 
         */
 
-       local_save_flags(flags);
-       local_irq_disable();
+       local_irq_save(flags);
        for(i = 0; i < NUM_TLB_ENTRIES; i++) {
                *R_TLB_SELECT = ( IO_FIELD(R_TLB_SELECT, index, i) );
                *R_TLB_HI = ( IO_FIELD(R_TLB_HI, page_id, INVALID_PAGEID ) |
@@ -78,8 +77,7 @@ flush_tlb_mm(struct mm_struct *mm)
         * global pages. is it worth the extra I/O ? 
         */
 
-       local_save_flags(flags);
-       local_irq_disable();
+       local_irq_save(flags);
        for(i = 0; i < NUM_TLB_ENTRIES; i++) {
                *R_TLB_SELECT = IO_FIELD(R_TLB_SELECT, index, i);
                if (IO_EXTRACT(R_TLB_HI, page_id, *R_TLB_HI) == page_id) {
@@ -118,8 +116,7 @@ flush_tlb_page(struct vm_area_struct *vma,
         * and the virtual address requested 
         */
 
-       local_save_flags(flags);
-       local_irq_disable();
+       local_irq_save(flags);
        for(i = 0; i < NUM_TLB_ENTRIES; i++) {
                unsigned long tlb_hi;
                *R_TLB_SELECT = IO_FIELD(R_TLB_SELECT, index, i);
index 689729a7e66e6b217d8649a3f8ae6235f1b2798d..4b348b38cf333f9819776a817a4de43f618ded6d 100644 (file)
@@ -82,7 +82,8 @@ SECTIONS
                __con_initcall_end = .;
        }       
        SECURITY_INIT
-               
+
+#ifdef CONFIG_BLK_DEV_INITRD
        .init.ramfs : {
                __initramfs_start = .;
                *(.init.ramfs)
@@ -93,6 +94,7 @@ SECTIONS
                FILL (0); 
                . = ALIGN (8192);
        }
+#endif
        
        __vmlinux_end = .;            /* last address of the physical file */
        __init_end = .;
index 9d75d7692303fca512713743952403f07cab07fe..c2d12e9c40d79a2e5720837bdaca10bebd07693c 100644 (file)
@@ -54,8 +54,7 @@ __flush_tlb_all(void)
         * Mask with 0xf so similar TLB entries aren't written in the same 4-way
         * entry group.
         */
-       local_save_flags(flags);
-       local_irq_disable();
+       local_irq_save(flags);
 
        for (mmu = 1; mmu <= 2; mmu++) {
                SUPP_BANK_SEL(mmu); /* Select the MMU */
@@ -92,8 +91,7 @@ __flush_tlb_mm(struct mm_struct *mm)
                return;
 
        /* Mark the TLB entries that match the page_id as invalid. */
-       local_save_flags(flags);
-       local_irq_disable();
+       local_irq_save(flags);
 
        for (mmu = 1; mmu <= 2; mmu++) {
                SUPP_BANK_SEL(mmu);
@@ -140,8 +138,7 @@ __flush_tlb_page(struct vm_area_struct *vma, unsigned long addr)
         * Invalidate those TLB entries that match both the mm context and the
         * requested virtual address.
         */
-       local_save_flags(flags);
-       local_irq_disable();
+       local_irq_save(flags);
 
        for (mmu = 1; mmu <= 2; mmu++) {
                SUPP_BANK_SEL(mmu);
index 472d4b3c4cf4b1d595d36a7b43dabd063d7c5a2d..e124fcd766d5c0fcd1cfd06fd42a746e5444822b 100644 (file)
@@ -95,6 +95,7 @@ SECTIONS
        .data.percpu  : { *(.data.percpu) }
        __per_cpu_end = .;
 
+#ifdef CONFIG_BLK_DEV_INITRD
        .init.ramfs : {
                __initramfs_start = .;
                *(.init.ramfs)
@@ -107,6 +108,7 @@ SECTIONS
                FILL (0);
                . = ALIGN (8192);
        }
+#endif
 
        __vmlinux_end = .;      /* Last address of the physical file. */
        __init_end = .;
index 0f9213cbd48e24f9068c62125b7b9814d09ce617..acfd0455940590c5e5292ce86b89dde0e1b0200e 100644 (file)
@@ -55,7 +55,6 @@ void do_gettimeofday(struct timeval *tv)
        unsigned long flags;
        signed long usec, sec;
        local_irq_save(flags);
-       local_irq_disable();
        usec = do_gettimeoffset();
 
         /*
@@ -217,14 +216,6 @@ cris_do_profile(struct pt_regs* regs)
 #endif
 }
 
-/*
- * Scheduler clock - returns current time in nanosec units.
- */
-unsigned long long sched_clock(void)
-{
-       return (unsigned long long)jiffies * (1000000000 / HZ);
-}
-
 static int
 __init init_udelay(void)
 {
index 0df390a656cdf9f1edfc94c25b5bf6cbc7a33497..c4a98e2e529e04dd46b85ff768bdabad3df8d1a4 100644 (file)
@@ -8,6 +8,7 @@
  */
 
 #include <linux/init.h>
+#include <linux/kernel.h>
 #include <asm/tlb.h>
 
 #define D(x)
@@ -100,7 +101,7 @@ tlb_init(void)
 
        /* clear the page_id map */
 
-       for (i = 1; i < sizeof (page_id_map) / sizeof (page_id_map[0]); i++)
+       for (i = 1; i < ARRAY_SIZE(page_id_map); i++)
                page_id_map[i] = NULL;
        
        /* invalidate the entire TLB */
index 7561d7b72e75408bb05f3998008c2cee2b1debcf..cea237413aa242b995442e5abee32cfdac728fca 100644 (file)
@@ -6,6 +6,10 @@ config FRV
        bool
        default y
 
+config ZONE_DMA
+       bool
+       default y
+
 config RWSEM_GENERIC_SPINLOCK
        bool
        default y
index 9c1fb12367fa3cfbedf6b8abe926fc40eb0e431e..97910e016825e29361f4fb41b5e5aee69b043d60 100644 (file)
@@ -61,10 +61,12 @@ SECTIONS
   .data.percpu  : { *(.data.percpu) }
   __per_cpu_end = .;
 
+#ifdef CONFIG_BLK_DEV_INITRD
   . = ALIGN(4096);
   __initramfs_start = .;
   .init.ramfs : { *(.init.ramfs) }
   __initramfs_end = .;
+#endif
 
   . = ALIGN(THREAD_SIZE);
   __init_end = .;
index 34a84bc4baf59ae515c1a0b0c899deee21604ef4..1734d96422c60f82219e779d57bae3c81fac525b 100644 (file)
@@ -17,6 +17,10 @@ config SWAP
        bool
        default n
 
+config ZONE_DMA
+       bool
+       default y
+
 config FPU
        bool
        default n
@@ -53,6 +57,9 @@ config TIME_LOW_RES
        bool
        default y
 
+config NO_IOPORT
+       def_bool y
+
 config ISA
        bool
        default y
index 71b6131e98b877f1d21559a80139707b2dce1de8..4edbc2ef6ca28e6d2c8a09c9727ec5c9f9a50b30 100644 (file)
@@ -6,6 +6,8 @@ extra-y := vmlinux.lds
 
 obj-y := process.o traps.o ptrace.o ints.o \
         sys_h8300.o time.o semaphore.o signal.o \
-         setup.o gpio.o init_task.o syscalls.o
+         setup.o gpio.o init_task.o syscalls.o devres.o
+
+devres-y = ../../../kernel/irq/devres.o
 
 obj-$(CONFIG_MODULES) += module.o h8300_ksyms.o 
index 8abab3bc2b6fe1615cf80c71e3ca6450e8ee91f2..d1ef615ba895369ffb4883b082600e1e66e9651f 100644 (file)
@@ -118,9 +118,3 @@ int do_settimeofday(struct timespec *tv)
 }
 
 EXPORT_SYMBOL(do_settimeofday);
-
-unsigned long long sched_clock(void)
-{
-       return (unsigned long long)jiffies * (1000000000 / HZ);
-
-}
index f05288be8878fb86efcf4bcae6b95fdafe69073d..65f1cdc5ee0459fd20b3fab62ee5f36a2e962216 100644 (file)
@@ -126,10 +126,12 @@ SECTIONS
        ___con_initcall_end = .;
                *(.exit.text)
                *(.exit.data)
+#if defined(CONFIG_BLK_DEV_INITRD)
                . = ALIGN(4);
        ___initramfs_start = .;
                *(.init.ramfs)
        ___initramfs_end = .;
+#endif
        . = ALIGN(0x4) ;
        ___init_end = .;
        __edata = . ;
index 0dfee812811a9c75427551ef8177b45f2ca7a998..63d5e841caf5a1ce0ceb7e986c572b6b70f7f3e9 100644 (file)
@@ -38,6 +38,10 @@ config MMU
        bool
        default y
 
+config ZONE_DMA
+       bool
+       default y
+
 config SBUS
        bool
 
index 45a8685bb60bb5e21e638cd6c0b6df95586606f2..0b29d41322a2620c50a0bdc98fa1ec314d397ac9 100644 (file)
@@ -12,7 +12,7 @@
 /* FSEC = 10^-15 NSEC = 10^-9 */
 #define FSEC_PER_NSEC  1000000
 
-static void *hpet_ptr;
+static void __iomem *hpet_ptr;
 
 static cycle_t read_hpet(void)
 {
@@ -40,8 +40,7 @@ static int __init init_hpet_clocksource(void)
                return -ENODEV;
 
        /* calculate the hpet address: */
-       hpet_base =
-               (void __iomem*)ioremap_nocache(hpet_address, HPET_MMAP_SIZE);
+       hpet_base = ioremap_nocache(hpet_address, HPET_MMAP_SIZE);
        hpet_ptr = hpet_base + HPET_COUNTER;
 
        /* calculate the frequency: */
index 5592fa6e1fa1fa8dfb1adaa7167f706f2016a6d6..ba8d302a0b728718d099f5254a8e463d45b1853d 100644 (file)
@@ -126,7 +126,7 @@ static inline void io_apic_write(unsigned int apic, unsigned int reg, unsigned i
  */
 static inline void io_apic_modify(unsigned int apic, unsigned int reg, unsigned int value)
 {
-       volatile struct io_apic *io_apic = io_apic_base(apic);
+       volatile struct io_apic __iomem *io_apic = io_apic_base(apic);
        if (sis_apic_bug)
                writel(reg, &io_apic->index);
        writel(value, &io_apic->data);
index 5da744204d100661f3ff35502800335702652ca4..bc882a2b1db6f4fda8f80976d968ae48e804f0e8 100644 (file)
@@ -70,11 +70,12 @@ void enable_sep_cpu(void)
  */
 extern const char vsyscall_int80_start, vsyscall_int80_end;
 extern const char vsyscall_sysenter_start, vsyscall_sysenter_end;
-static void *syscall_page;
+static struct page *syscall_pages[1];
 
 int __init sysenter_setup(void)
 {
-       syscall_page = (void *)get_zeroed_page(GFP_ATOMIC);
+       void *syscall_page = (void *)get_zeroed_page(GFP_ATOMIC);
+       syscall_pages[0] = virt_to_page(syscall_page);
 
 #ifdef CONFIG_COMPAT_VDSO
        __set_fixmap(FIX_VDSO, __pa(syscall_page), PAGE_READONLY);
@@ -96,31 +97,12 @@ int __init sysenter_setup(void)
 }
 
 #ifndef CONFIG_COMPAT_VDSO
-static struct page *syscall_nopage(struct vm_area_struct *vma,
-                               unsigned long adr, int *type)
-{
-       struct page *p = virt_to_page(adr - vma->vm_start + syscall_page);
-       get_page(p);
-       return p;
-}
-
-/* Prevent VMA merging */
-static void syscall_vma_close(struct vm_area_struct *vma)
-{
-}
-
-static struct vm_operations_struct syscall_vm_ops = {
-       .close = syscall_vma_close,
-       .nopage = syscall_nopage,
-};
-
 /* Defined in vsyscall-sysenter.S */
 extern void SYSENTER_RETURN;
 
 /* Setup a VMA at program startup for the vsyscall page */
 int arch_setup_additional_pages(struct linux_binprm *bprm, int exstack)
 {
-       struct vm_area_struct *vma;
        struct mm_struct *mm = current->mm;
        unsigned long addr;
        int ret;
@@ -132,38 +114,25 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int exstack)
                goto up_fail;
        }
 
-       vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
-       if (!vma) {
-               ret = -ENOMEM;
-               goto up_fail;
-       }
-
-       vma->vm_start = addr;
-       vma->vm_end = addr + PAGE_SIZE;
-       /* MAYWRITE to allow gdb to COW and set breakpoints */
-       vma->vm_flags = VM_READ|VM_EXEC|VM_MAYREAD|VM_MAYEXEC|VM_MAYWRITE;
        /*
+        * MAYWRITE to allow gdb to COW and set breakpoints
+        *
         * Make sure the vDSO gets into every core dump.
         * Dumping its contents makes post-mortem fully interpretable later
         * without matching up the same kernel and hardware config to see
         * what PC values meant.
         */
-       vma->vm_flags |= VM_ALWAYSDUMP;
-       vma->vm_flags |= mm->def_flags;
-       vma->vm_page_prot = protection_map[vma->vm_flags & 7];
-       vma->vm_ops = &syscall_vm_ops;
-       vma->vm_mm = mm;
-
-       ret = insert_vm_struct(mm, vma);
-       if (unlikely(ret)) {
-               kmem_cache_free(vm_area_cachep, vma);
+       ret = install_special_mapping(mm, addr, PAGE_SIZE,
+                                     VM_READ|VM_EXEC|
+                                     VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC|
+                                     VM_ALWAYSDUMP,
+                                     syscall_pages);
+       if (ret)
                goto up_fail;
-       }
 
        current->mm->context.vdso = (void *)addr;
        current_thread_info()->sysenter_return =
                                    (void *)VDSO_SYM(&SYSENTER_RETURN);
-       mm->total_vm++;
 up_fail:
        up_write(&mm->mmap_sem);
        return ret;
index a53c8b1854b58896a2dbc2b384d52722a1754481..5038a73d554e18df68cc097c5f77431ddf50a5b5 100644 (file)
@@ -181,12 +181,14 @@ SECTIONS
      from .altinstructions and .eh_frame */
   .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) { *(.exit.text) }
   .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) { *(.exit.data) }
+#if defined(CONFIG_BLK_DEV_INITRD)
   . = ALIGN(4096);
   .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) {
        __initramfs_start = .;
        *(.init.ramfs)
        __initramfs_end = .;
   }
+#endif
   . = ALIGN(L1_CACHE_BYTES);
   .data.percpu  : AT(ADDR(.data.percpu) - LOAD_OFFSET) {
        __per_cpu_start = .;
index aaaa4d225f7e25ad86c66511fcdf06d598ce9a09..cba9b3894a3325c0490ab1f8475a851cea25ba2f 100644 (file)
@@ -59,32 +59,6 @@ static inline int notify_page_fault(enum die_val val, const char *str,
        return atomic_notifier_call_chain(&notify_page_fault_chain, val, &args);
 }
 
-/*
- * Unlock any spinlocks which will prevent us from getting the
- * message out 
- */
-void bust_spinlocks(int yes)
-{
-       int loglevel_save = console_loglevel;
-
-       if (yes) {
-               oops_in_progress = 1;
-               return;
-       }
-#ifdef CONFIG_VT
-       unblank_screen();
-#endif
-       oops_in_progress = 0;
-       /*
-        * OK, the message is on the console.  Now we call printk()
-        * without oops_in_progress set so that printk will give klogd
-        * a poke.  Hold onto your hats...
-        */
-       console_loglevel = 15;          /* NMI oopser may have shut the console up */
-       printk(" ");
-       console_loglevel = loglevel_save;
-}
-
 /*
  * Return EIP plus the CS segment base.  The segment limit is also
  * adjusted, clamped to the kernel/user address space (whichever is
index e0fa6cb655a82574a50c3e8fc9334c2f71b9c156..bb2de1089add4e90270e4f35afbbe442007cbefe 100644 (file)
@@ -33,13 +33,14 @@ void *kmap_atomic(struct page *page, enum km_type type)
 
        /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */
        pagefault_disable();
+
+       idx = type + KM_TYPE_NR*smp_processor_id();
+       BUG_ON(!pte_none(*(kmap_pte-idx)));
+
        if (!PageHighMem(page))
                return page_address(page);
 
-       idx = type + KM_TYPE_NR*smp_processor_id();
        vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
-       if (!pte_none(*(kmap_pte-idx)))
-               BUG();
        set_pte(kmap_pte-idx, mk_pte(page, kmap_prot));
 
        return (void*) vaddr;
index ad91528bdc14f0cd341a6e3be8d04f29bd9b4e52..e223b1d4981c2ee845f65d5337606862c57f0213 100644 (file)
@@ -224,7 +224,7 @@ void global_flush_tlb(void)
        list_replace_init(&df_list, &l);
        spin_unlock_irq(&cpa_lock);
        if (!cpu_has_clflush)
-               flush_map(0);
+               flush_map(NULL);
        list_for_each_entry_safe(pg, next, &l, lru) {
                if (cpu_has_clflush)
                        flush_map(page_address(pg));
index f1d2899e9a629763173afffb8d86766a5fac08fc..db185f34e34117ddca100abf49df37d1af5bfed4 100644 (file)
@@ -24,6 +24,10 @@ config 64BIT
        bool
        default y
 
+config ZONE_DMA
+       def_bool y
+       depends on !IA64_SGI_SN2
+
 config MMU
        bool
        default y
index 578737ec7629374253ea7b53029b8a3fe7d6848c..c05bda66236451291e51e7622682ab41593739bf 100644 (file)
@@ -91,9 +91,8 @@ ia64_elf32_init (struct pt_regs *regs)
         * it with privilege level 3 because the IVE uses non-privileged accesses to these
         * tables.  IA-32 segmentation is used to protect against IA-32 accesses to them.
         */
-       vma = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
+       vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
        if (vma) {
-               memset(vma, 0, sizeof(*vma));
                vma->vm_mm = current->mm;
                vma->vm_start = IA32_GDT_OFFSET;
                vma->vm_end = vma->vm_start + PAGE_SIZE;
@@ -117,9 +116,8 @@ ia64_elf32_init (struct pt_regs *regs)
         * code is locked in specific gate page, which is pointed by pretcode
         * when setup_frame_ia32
         */
-       vma = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
+       vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
        if (vma) {
-               memset(vma, 0, sizeof(*vma));
                vma->vm_mm = current->mm;
                vma->vm_start = IA32_GATE_OFFSET;
                vma->vm_end = vma->vm_start + PAGE_SIZE;
@@ -142,9 +140,8 @@ ia64_elf32_init (struct pt_regs *regs)
         * Install LDT as anonymous memory.  This gives us all-zero segment descriptors
         * until a task modifies them via modify_ldt().
         */
-       vma = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
+       vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
        if (vma) {
-               memset(vma, 0, sizeof(*vma));
                vma->vm_mm = current->mm;
                vma->vm_start = IA32_LDT_OFFSET;
                vma->vm_end = vma->vm_start + PAGE_ALIGN(IA32_LDT_ENTRIES*IA32_LDT_ENTRY_SIZE);
@@ -214,12 +211,10 @@ ia32_setup_arg_pages (struct linux_binprm *bprm, int executable_stack)
                bprm->loader += stack_base;
        bprm->exec += stack_base;
 
-       mpnt = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
+       mpnt = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
        if (!mpnt)
                return -ENOMEM;
 
-       memset(mpnt, 0, sizeof(*mpnt));
-
        down_write(&current->mm->mmap_sem);
        {
                mpnt->vm_mm = current->mm;
index a32cd59b81ed7e00658fd0f7b6fcf00924121736..687e5fdc968377fcead5c80c909f9f7aa8e02f5b 100644 (file)
@@ -326,7 +326,7 @@ ia32_syscall_table:
        data8 sys_ni_syscall
        data8 compat_sys_wait4
        data8 sys_swapoff         /* 115 */
-       data8 sys32_sysinfo
+       data8 compat_sys_sysinfo
        data8 sys32_ipc
        data8 sys_fsync
        data8 sys32_sigreturn
index 957681c39ad9957a287929c093aa060908b7c9c4..d430d36ae49d62763757d05c354ec4590781d6da 100644 (file)
@@ -2209,74 +2209,6 @@ sys32_fstat64 (unsigned int fd, struct stat64 __user *statbuf)
        return ret;
 }
 
-struct sysinfo32 {
-       s32 uptime;
-       u32 loads[3];
-       u32 totalram;
-       u32 freeram;
-       u32 sharedram;
-       u32 bufferram;
-       u32 totalswap;
-       u32 freeswap;
-       u16 procs;
-       u16 pad;
-       u32 totalhigh;
-       u32 freehigh;
-       u32 mem_unit;
-       char _f[8];
-};
-
-asmlinkage long
-sys32_sysinfo (struct sysinfo32 __user *info)
-{
-       struct sysinfo s;
-       long ret, err;
-       int bitcount = 0;
-       mm_segment_t old_fs = get_fs();
-
-       set_fs(KERNEL_DS);
-       ret = sys_sysinfo((struct sysinfo __user *) &s);
-       set_fs(old_fs);
-       /* Check to see if any memory value is too large for 32-bit and
-        * scale down if needed.
-        */
-       if ((s.totalram >> 32) || (s.totalswap >> 32)) {
-               while (s.mem_unit < PAGE_SIZE) {
-                       s.mem_unit <<= 1;
-                       bitcount++;
-               }
-               s.totalram >>= bitcount;
-               s.freeram >>= bitcount;
-               s.sharedram >>= bitcount;
-               s.bufferram >>= bitcount;
-               s.totalswap >>= bitcount;
-               s.freeswap >>= bitcount;
-               s.totalhigh >>= bitcount;
-               s.freehigh >>= bitcount;
-       }
-
-       if (!access_ok(VERIFY_WRITE, info, sizeof(*info)))
-               return -EFAULT;
-
-       err  = __put_user(s.uptime, &info->uptime);
-       err |= __put_user(s.loads[0], &info->loads[0]);
-       err |= __put_user(s.loads[1], &info->loads[1]);
-       err |= __put_user(s.loads[2], &info->loads[2]);
-       err |= __put_user(s.totalram, &info->totalram);
-       err |= __put_user(s.freeram, &info->freeram);
-       err |= __put_user(s.sharedram, &info->sharedram);
-       err |= __put_user(s.bufferram, &info->bufferram);
-       err |= __put_user(s.totalswap, &info->totalswap);
-       err |= __put_user(s.freeswap, &info->freeswap);
-       err |= __put_user(s.procs, &info->procs);
-       err |= __put_user (s.totalhigh, &info->totalhigh);
-       err |= __put_user (s.freehigh, &info->freehigh);
-       err |= __put_user (s.mem_unit, &info->mem_unit);
-       if (err)
-               return -EFAULT;
-       return ret;
-}
-
 asmlinkage long
 sys32_sched_rr_get_interval (pid_t pid, struct compat_timespec __user *interval)
 {
index 9d92097ce96daaf5ccd2210eba88e44d53018ce6..37bb16f07fc3f2fd2b7a3ca8112f0d6a0a6af2e0 100644 (file)
@@ -52,7 +52,7 @@ extern void ia64_dump_cpu_regs(void *);
 static DEFINE_PER_CPU(struct elf_prstatus, elf_prstatus);
 
 void
-crash_save_this_cpu()
+crash_save_this_cpu(void)
 {
        void *buf;
        unsigned long cfm, sof, sol;
index aa94f60fa8e7724ee04f83e665e9b762c97540ca..86e144f321ff5b59e9545eb80d9ec751b4415846 100644 (file)
@@ -2301,12 +2301,11 @@ pfm_smpl_buffer_alloc(struct task_struct *task, pfm_context_t *ctx, unsigned lon
        DPRINT(("smpl_buf @%p\n", smpl_buf));
 
        /* allocate vma */
-       vma = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
+       vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
        if (!vma) {
                DPRINT(("Cannot allocate vma\n"));
                goto error_kmem;
        }
-       memset(vma, 0, sizeof(*vma));
 
        /*
         * partially initialize the vma for the sampling buffer
index f4c7f7769cf7df617bdb7cecefd5be4802bb840e..55ddd809b02d47aa72fc7b1f251c851aeffddc40 100644 (file)
@@ -221,13 +221,13 @@ send_IPI_self (int op)
 
 #ifdef CONFIG_KEXEC
 void
-kdump_smp_send_stop()
+kdump_smp_send_stop(void)
 {
        send_IPI_allbutself(IPI_KDUMP_CPU_STOP);
 }
 
 void
-kdump_smp_send_init()
+kdump_smp_send_init(void)
 {
        unsigned int cpu, self_cpu;
        self_cpu = smp_processor_id();
index ab684747036fbcf71b6ce464a9561942f982e48d..765cbe5ba6ae280474761231db44d890ff74cbde 100644 (file)
@@ -24,8 +24,6 @@
 #include <asm/uaccess.h>
 #include <asm/kdebug.h>
 
-extern spinlock_t timerlist_lock;
-
 fpswa_interface_t *fpswa_interface;
 EXPORT_SYMBOL(fpswa_interface);
 
@@ -53,34 +51,6 @@ trap_init (void)
                fpswa_interface = __va(ia64_boot_param->fpswa);
 }
 
-/*
- * Unlock any spinlocks which will prevent us from getting the message out (timerlist_lock
- * is acquired through the console unblank code)
- */
-void
-bust_spinlocks (int yes)
-{
-       int loglevel_save = console_loglevel;
-
-       if (yes) {
-               oops_in_progress = 1;
-               return;
-       }
-
-#ifdef CONFIG_VT
-       unblank_screen();
-#endif
-       oops_in_progress = 0;
-       /*
-        * OK, the message is on the console.  Now we call printk() without
-        * oops_in_progress set so that printk will give klogd a poke.  Hold onto
-        * your hats...
-        */
-       console_loglevel = 15;          /* NMI oopser may have shut the console up */
-       printk(" ");
-       console_loglevel = loglevel_save;
-}
-
 void
 die (const char *str, struct pt_regs *regs, long err)
 {
index 8f3d0066f4468cffbb980ce04e091ea48c4b6106..25dd55e4db2482985e86563599be0f05ec74058b 100644 (file)
@@ -111,12 +111,14 @@ SECTIONS
   .init.data : AT(ADDR(.init.data) - LOAD_OFFSET)
        { *(.init.data) }
 
+#ifdef CONFIG_BLK_DEV_INITRD
   .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET)
        {
          __initramfs_start = .;
          *(.init.ramfs)
          __initramfs_end = .;
        }
+#endif
 
    . = ALIGN(16);
   .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET)
index 63e6d49c5813ed2bac5d027f0668a80080544a97..ca4d41e5f177563c5739816c14ee563dc51ed87b 100644 (file)
@@ -259,9 +259,11 @@ paging_init (void)
        num_physpages = 0;
        efi_memmap_walk(count_pages, &num_physpages);
 
-       max_dma = virt_to_phys((void *) MAX_DMA_ADDRESS) >> PAGE_SHIFT;
        memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
+#ifdef CONFIG_ZONE_DMA
+       max_dma = virt_to_phys((void *) MAX_DMA_ADDRESS) >> PAGE_SHIFT;
        max_zone_pfns[ZONE_DMA] = max_dma;
+#endif
        max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
 
 #ifdef CONFIG_VIRTUAL_MEM_MAP
index 6eae596c509d5cc5c17a5ebc5b5702f4e6d6bf01..16835108bb5bc71a3e19cdcc1f582473ce89899c 100644 (file)
@@ -37,7 +37,9 @@ struct early_node_data {
        unsigned long pernode_size;
        struct bootmem_data bootmem_data;
        unsigned long num_physpages;
+#ifdef CONFIG_ZONE_DMA
        unsigned long num_dma_physpages;
+#endif
        unsigned long min_pfn;
        unsigned long max_pfn;
 };
@@ -633,9 +635,11 @@ static __init int count_node_pages(unsigned long start, unsigned long len, int n
        unsigned long end = start + len;
 
        mem_data[node].num_physpages += len >> PAGE_SHIFT;
+#ifdef CONFIG_ZONE_DMA
        if (start <= __pa(MAX_DMA_ADDRESS))
                mem_data[node].num_dma_physpages +=
                        (min(end, __pa(MAX_DMA_ADDRESS)) - start) >>PAGE_SHIFT;
+#endif
        start = GRANULEROUNDDOWN(start);
        start = ORDERROUNDDOWN(start);
        end = GRANULEROUNDUP(end);
@@ -688,7 +692,9 @@ void __init paging_init(void)
        }
 
        memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
+#ifdef CONFIG_ZONE_DMA
        max_zone_pfns[ZONE_DMA] = max_dma;
+#endif
        max_zone_pfns[ZONE_NORMAL] = max_pfn;
        free_area_init_nodes(max_zone_pfns);
 
index faaca21a3718c5e7b5b82ed7a5b04fbc7c586a8e..f225dd72968b3bdd159b1b7c0552eec66b3c92e2 100644 (file)
@@ -68,7 +68,7 @@ max_pgt_pages(void)
 #ifndef        CONFIG_NUMA
        node_free_pages = nr_free_pages();
 #else
-       node_free_pages = nr_free_pages_pgdat(NODE_DATA(numa_node_id()));
+       node_free_pages = node_page_state(numa_node_id(), NR_FREE_PAGES);
 #endif
        max_pgt_pages = node_free_pages / PGT_FRACTION_OF_NODE_MEM;
        max_pgt_pages = max(max_pgt_pages, MIN_PGT_PAGES);
@@ -176,9 +176,8 @@ ia64_init_addr_space (void)
         * the problem.  When the process attempts to write to the register backing store
         * for the first time, it will get a SEGFAULT in this case.
         */
-       vma = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
+       vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
        if (vma) {
-               memset(vma, 0, sizeof(*vma));
                vma->vm_mm = current->mm;
                vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
                vma->vm_end = vma->vm_start + PAGE_SIZE;
@@ -195,9 +194,8 @@ ia64_init_addr_space (void)
 
        /* map NaT-page at address zero to speed up speculative dereferencing of NULL: */
        if (!(current->personality & MMAP_PAGE_ZERO)) {
-               vma = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
+               vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
                if (vma) {
-                       memset(vma, 0, sizeof(*vma));
                        vma->vm_mm = current->mm;
                        vma->vm_end = PAGE_SIZE;
                        vma->vm_page_prot = __pgprot(pgprot_val(PAGE_READONLY) | _PAGE_MA_NAT);
index 43ddc2eccb965bd3c71d372e1afc6c53505babc4..62b3e9a496acc7bd0d716c74931cd6e58db78bf5 100644 (file)
@@ -89,61 +89,80 @@ static int coherence_id_open(struct inode *inode, struct file *file)
        return single_open(file, coherence_id_show, NULL);
 }
 
-static struct proc_dir_entry
-*sn_procfs_create_entry(const char *name, struct proc_dir_entry *parent,
-                       int (*openfunc)(struct inode *, struct file *),
-       int (*releasefunc)(struct inode *, struct file *),
-       ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *))
-{
-       struct proc_dir_entry *e = create_proc_entry(name, 0444, parent);
-
-       if (e) {
-               struct file_operations *f;
-
-               f = kzalloc(sizeof(*f), GFP_KERNEL);
-               if (f) {
-                       f->open = openfunc;
-                       f->read = seq_read;
-                       f->llseek = seq_lseek;
-                       f->release = releasefunc;
-                       f->write = write;
-                       e->proc_fops = f;
-               }
-       }
-
-       return e;
-}
-
 /* /proc/sgi_sn/sn_topology uses seq_file, see sn_hwperf.c */
 extern int sn_topology_open(struct inode *, struct file *);
 extern int sn_topology_release(struct inode *, struct file *);
 
+static const struct file_operations proc_partition_id_fops = {
+       .open           = partition_id_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
+
+static const struct file_operations proc_system_sn_fops = {
+       .open           = system_serial_number_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
+
+static const struct file_operations proc_license_id_fops = {
+       .open           = licenseID_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
+
+static const struct file_operations proc_sn_force_intr_fops = {
+       .open           = sn_force_interrupt_open,
+       .read           = seq_read,
+       .write          = sn_force_interrupt_write_proc,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
+
+static const struct file_operations proc_coherence_id_fops = {
+       .open           = coherence_id_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
+
+static const struct file_operations proc_sn_topo_fops = {
+       .open           = sn_topology_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = sn_topology_release,
+};
+
 void register_sn_procfs(void)
 {
        static struct proc_dir_entry *sgi_proc_dir = NULL;
+       struct proc_dir_entry *pde;
 
        BUG_ON(sgi_proc_dir != NULL);
        if (!(sgi_proc_dir = proc_mkdir("sgi_sn", NULL)))
                return;
 
-       sn_procfs_create_entry("partition_id", sgi_proc_dir,
-               partition_id_open, single_release, NULL);
-
-       sn_procfs_create_entry("system_serial_number", sgi_proc_dir,
-               system_serial_number_open, single_release, NULL);
-
-       sn_procfs_create_entry("licenseID", sgi_proc_dir, 
-               licenseID_open, single_release, NULL);
-
-       sn_procfs_create_entry("sn_force_interrupt", sgi_proc_dir,
-               sn_force_interrupt_open, single_release,
-               sn_force_interrupt_write_proc);
-
-       sn_procfs_create_entry("coherence_id", sgi_proc_dir, 
-               coherence_id_open, single_release, NULL);
-       
-       sn_procfs_create_entry("sn_topology", sgi_proc_dir,
-               sn_topology_open, sn_topology_release, NULL);
+       pde = create_proc_entry("partition_id", 0444, sgi_proc_dir);
+       if (pde)
+               pde->proc_fops = &proc_partition_id_fops;
+       pde = create_proc_entry("system_serial_number", 0444, sgi_proc_dir);
+       if (pde)
+               pde->proc_fops = &proc_system_sn_fops;
+       pde = create_proc_entry("licenseID", 0444, sgi_proc_dir);
+       if (pde)
+               pde->proc_fops = &proc_license_id_fops;
+       pde = create_proc_entry("sn_force_interrupt", 0644, sgi_proc_dir);
+       if (pde)
+               pde->proc_fops = &proc_sn_force_intr_fops;
+       pde = create_proc_entry("coherence_id", 0444, sgi_proc_dir);
+       if (pde)
+               pde->proc_fops = &proc_coherence_id_fops;
+       pde = create_proc_entry("sn_topology", 0444, sgi_proc_dir);
+       if (pde)
+               pde->proc_fops = &proc_sn_topo_fops;
 }
 
 #endif /* CONFIG_PROC_FS */
index f383dab973f5ea62d86f914a5774357be3ea7a4d..9740d6b8ae11c407ae56d4c88bf6b179056deceb 100644 (file)
@@ -16,6 +16,10 @@ config GENERIC_ISA_DMA
        bool
        default y
 
+config ZONE_DMA
+       bool
+       default y
+
 config GENERIC_HARDIRQS
        bool
        default y
@@ -24,6 +28,9 @@ config GENERIC_IRQ_PROBE
        bool
        default y
 
+config NO_IOPORT
+       def_bool y
+
 source "init/Kconfig"
 
 
index f219c47d334fefd3c12892ecf7ffd640e8fda1ed..cdf63b210c53d68d7ebad661498515401851fb05 100644 (file)
@@ -7,7 +7,7 @@
 
 LDFLAGS                :=
 OBJCOPYFLAGS   := -O binary -R .note -R .comment -S
-LDFLAGS_vmlinux        := -e startup_32
+LDFLAGS_vmlinux        :=
 
 CFLAGS += -pipe -fno-schedule-insns
 CFLAGS_KERNEL += -mmodel=medium
index 853093093168e40bede4a8df4baa86dc0931af2f..13579917afef09e621bdfbf6fd08e6393e90f174 100644 (file)
@@ -1,20 +1,18 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.12-rc5
-# Fri Jun  3 16:20:11 2005
+# Linux kernel version: 2.6.19
+# Tue Dec 12 17:52:38 2006
 #
 CONFIG_M32R=y
-# CONFIG_UID16 is not set
 CONFIG_GENERIC_ISA_DMA=y
 CONFIG_GENERIC_HARDIRQS=y
 CONFIG_GENERIC_IRQ_PROBE=y
+CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
 
 #
 # Code maturity level options
 #
 CONFIG_EXPERIMENTAL=y
-CONFIG_CLEAN_COMPILE=y
-CONFIG_BROKEN_ON_SMP=y
 CONFIG_LOCK_KERNEL=y
 CONFIG_INIT_ENV_ARG_LIMIT=32
 
@@ -22,32 +20,40 @@ CONFIG_INIT_ENV_ARG_LIMIT=32
 # General setup
 #
 CONFIG_LOCALVERSION=""
+CONFIG_LOCALVERSION_AUTO=y
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
+# CONFIG_IPC_NS is not set
 # CONFIG_POSIX_MQUEUE is not set
 CONFIG_BSD_PROCESS_ACCT=y
 # CONFIG_BSD_PROCESS_ACCT_V3 is not set
-CONFIG_SYSCTL=y
+# CONFIG_TASKSTATS is not set
+# CONFIG_UTS_NS is not set
 # CONFIG_AUDIT is not set
-CONFIG_HOTPLUG=y
-CONFIG_KOBJECT_UEVENT=y
 CONFIG_IKCONFIG=y
-# CONFIG_IKCONFIG_PROC is not set
+CONFIG_IKCONFIG_PROC=y
+# CONFIG_CPUSETS is not set
+CONFIG_SYSFS_DEPRECATED=y
+# CONFIG_RELAY is not set
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SYSCTL=y
 CONFIG_EMBEDDED=y
+CONFIG_SYSCTL_SYSCALL=y
 # CONFIG_KALLSYMS is not set
+CONFIG_HOTPLUG=y
 CONFIG_PRINTK=y
 CONFIG_BUG=y
+CONFIG_ELF_CORE=y
 CONFIG_BASE_FULL=y
 # CONFIG_FUTEX is not set
 # CONFIG_EPOLL is not set
-# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
 CONFIG_SHMEM=y
-CONFIG_CC_ALIGN_FUNCTIONS=0
-CONFIG_CC_ALIGN_LABELS=0
-CONFIG_CC_ALIGN_LOOPS=0
-CONFIG_CC_ALIGN_JUMPS=0
+CONFIG_SLAB=y
+CONFIG_VM_EVENT_COUNTERS=y
 # CONFIG_TINY_SHMEM is not set
 CONFIG_BASE_SMALL=0
+# CONFIG_SLOB is not set
 
 #
 # Loadable module support
@@ -55,10 +61,29 @@ CONFIG_BASE_SMALL=0
 CONFIG_MODULES=y
 CONFIG_MODULE_UNLOAD=y
 # CONFIG_MODULE_FORCE_UNLOAD is not set
-CONFIG_OBSOLETE_MODPARM=y
 # CONFIG_MODVERSIONS is not set
 # CONFIG_MODULE_SRCVERSION_ALL is not set
 CONFIG_KMOD=y
+CONFIG_STOP_MACHINE=y
+
+#
+# Block layer
+#
+CONFIG_BLOCK=y
+# CONFIG_BLK_DEV_IO_TRACE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+# CONFIG_IOSCHED_AS is not set
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+# CONFIG_DEFAULT_AS is not set
+# CONFIG_DEFAULT_DEADLINE is not set
+CONFIG_DEFAULT_CFQ=y
+# CONFIG_DEFAULT_NOOP is not set
+CONFIG_DEFAULT_IOSCHED="cfq"
 
 #
 # Processor type and features
@@ -70,8 +95,10 @@ CONFIG_PLAT_M32700UT=y
 # CONFIG_PLAT_OAKS32R is not set
 # CONFIG_PLAT_MAPPI2 is not set
 # CONFIG_PLAT_MAPPI3 is not set
+# CONFIG_PLAT_M32104UT is not set
 CONFIG_CHIP_M32700=y
 # CONFIG_CHIP_M32102 is not set
+# CONFIG_CHIP_M32104 is not set
 # CONFIG_CHIP_VDEC2 is not set
 # CONFIG_CHIP_OPSP is not set
 CONFIG_MMU=y
@@ -85,34 +112,39 @@ CONFIG_TIMER_DIVIDE=128
 CONFIG_MEMORY_START=0x08000000
 CONFIG_MEMORY_SIZE=0x01000000
 CONFIG_NOHIGHMEM=y
-# CONFIG_DISCONTIGMEM is not set
+CONFIG_ARCH_DISCONTIGMEM_ENABLE=y
+CONFIG_SELECT_MEMORY_MODEL=y
+# CONFIG_FLATMEM_MANUAL is not set
+CONFIG_DISCONTIGMEM_MANUAL=y
+# CONFIG_SPARSEMEM_MANUAL is not set
+CONFIG_DISCONTIGMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
+CONFIG_NEED_MULTIPLE_NODES=y
+# CONFIG_SPARSEMEM_STATIC is not set
+CONFIG_SPLIT_PTLOCK_CPUS=4
+# CONFIG_RESOURCES_64BIT is not set
+CONFIG_IRAM_START=0x00f00000
+CONFIG_IRAM_SIZE=0x00080000
 CONFIG_RWSEM_GENERIC_SPINLOCK=y
 # CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
+CONFIG_GENERIC_FIND_NEXT_BIT=y
+CONFIG_GENERIC_HWEIGHT=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_PREEMPT=y
-# CONFIG_HAVE_DEC_LOCK is not set
-# CONFIG_SMP is not set
+CONFIG_SMP=y
+# CONFIG_CHIP_M32700_TS1 is not set
+CONFIG_NR_CPUS=2
+CONFIG_NODES_SHIFT=1
 
 #
 # Bus options (PCI, PCMCIA, EISA, MCA, ISA)
 #
-# CONFIG_PCI is not set
 # CONFIG_ISA is not set
 
 #
 # PCCARD (PCMCIA/CardBus) support
 #
-CONFIG_PCCARD=y
-# CONFIG_PCMCIA_DEBUG is not set
-CONFIG_PCMCIA=y
-
-#
-# PC-card bridges
-#
-# CONFIG_TCIC is not set
-# CONFIG_M32R_PCC is not set
-CONFIG_M32R_CFC=y
-CONFIG_M32R_CFC_NUM=1
+# CONFIG_PCCARD is not set
 
 #
 # PCI Hotplug Support
@@ -124,6 +156,94 @@ CONFIG_M32R_CFC_NUM=1
 CONFIG_BINFMT_ELF=y
 # CONFIG_BINFMT_MISC is not set
 
+#
+# Networking
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+# CONFIG_NETDEBUG is not set
+CONFIG_PACKET=y
+# CONFIG_PACKET_MMAP is not set
+CONFIG_UNIX=y
+CONFIG_XFRM=y
+# CONFIG_XFRM_USER is not set
+# CONFIG_XFRM_SUB_POLICY is not set
+# CONFIG_NET_KEY is not set
+CONFIG_INET=y
+# CONFIG_IP_MULTICAST is not set
+# CONFIG_IP_ADVANCED_ROUTER is not set
+CONFIG_IP_FIB_HASH=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+# CONFIG_IP_PNP_BOOTP is not set
+# CONFIG_IP_PNP_RARP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_ARPD is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_XFRM_TUNNEL is not set
+# CONFIG_INET_TUNNEL is not set
+CONFIG_INET_XFRM_MODE_TRANSPORT=y
+CONFIG_INET_XFRM_MODE_TUNNEL=y
+CONFIG_INET_XFRM_MODE_BEET=y
+CONFIG_INET_DIAG=y
+CONFIG_INET_TCP_DIAG=y
+# CONFIG_TCP_CONG_ADVANCED is not set
+CONFIG_TCP_CONG_CUBIC=y
+CONFIG_DEFAULT_TCP_CONG="cubic"
+# CONFIG_TCP_MD5SIG is not set
+# CONFIG_IPV6 is not set
+# CONFIG_INET6_XFRM_TUNNEL is not set
+# CONFIG_INET6_TUNNEL is not set
+# CONFIG_NETWORK_SECMARK is not set
+# CONFIG_NETFILTER is not set
+
+#
+# DCCP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_DCCP is not set
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_SCTP is not set
+
+#
+# TIPC Configuration (EXPERIMENTAL)
+#
+# CONFIG_TIPC is not set
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+# CONFIG_IEEE80211 is not set
+
 #
 # Device Drivers
 #
@@ -133,12 +253,100 @@ CONFIG_BINFMT_ELF=y
 #
 CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
-# CONFIG_FW_LOADER is not set
+CONFIG_FW_LOADER=y
+# CONFIG_SYS_HYPERVISOR is not set
+
+#
+# Connector - unified userspace <-> kernelspace linker
+#
+# CONFIG_CONNECTOR is not set
 
 #
 # Memory Technology Devices (MTD)
 #
-# CONFIG_MTD is not set
+CONFIG_MTD=y
+# CONFIG_MTD_DEBUG is not set
+# CONFIG_MTD_CONCAT is not set
+CONFIG_MTD_PARTITIONS=y
+CONFIG_MTD_REDBOOT_PARTS=y
+CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-1
+# CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED is not set
+# CONFIG_MTD_REDBOOT_PARTS_READONLY is not set
+# CONFIG_MTD_CMDLINE_PARTS is not set
+
+#
+# User Modules And Translation Layers
+#
+# CONFIG_MTD_CHAR is not set
+CONFIG_MTD_BLOCK=y
+# CONFIG_FTL is not set
+# CONFIG_NFTL is not set
+# CONFIG_INFTL is not set
+# CONFIG_RFD_FTL is not set
+# CONFIG_SSFDC is not set
+
+#
+# RAM/ROM/Flash chip drivers
+#
+CONFIG_MTD_CFI=m
+CONFIG_MTD_JEDECPROBE=m
+CONFIG_MTD_GEN_PROBE=m
+CONFIG_MTD_CFI_ADV_OPTIONS=y
+# CONFIG_MTD_CFI_NOSWAP is not set
+CONFIG_MTD_CFI_BE_BYTE_SWAP=y
+# CONFIG_MTD_CFI_LE_BYTE_SWAP is not set
+CONFIG_MTD_CFI_GEOMETRY=y
+CONFIG_MTD_MAP_BANK_WIDTH_1=y
+CONFIG_MTD_MAP_BANK_WIDTH_2=y
+CONFIG_MTD_MAP_BANK_WIDTH_4=y
+# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
+CONFIG_MTD_CFI_I1=y
+# CONFIG_MTD_CFI_I2 is not set
+# CONFIG_MTD_CFI_I4 is not set
+# CONFIG_MTD_CFI_I8 is not set
+# CONFIG_MTD_OTP is not set
+# CONFIG_MTD_CFI_INTELEXT is not set
+CONFIG_MTD_CFI_AMDSTD=m
+# CONFIG_MTD_CFI_STAA is not set
+CONFIG_MTD_CFI_UTIL=m
+# CONFIG_MTD_RAM is not set
+# CONFIG_MTD_ROM is not set
+# CONFIG_MTD_ABSENT is not set
+# CONFIG_MTD_OBSOLETE_CHIPS is not set
+
+#
+# Mapping drivers for chip access
+#
+# CONFIG_MTD_COMPLEX_MAPPINGS is not set
+# CONFIG_MTD_PHYSMAP is not set
+# CONFIG_MTD_PLATRAM is not set
+
+#
+# Self-contained MTD device drivers
+#
+# CONFIG_MTD_SLRAM is not set
+# CONFIG_MTD_PHRAM is not set
+# CONFIG_MTD_MTDRAM is not set
+# CONFIG_MTD_BLOCK2MTD is not set
+
+#
+# Disk-On-Chip Device Drivers
+#
+# CONFIG_MTD_DOC2000 is not set
+# CONFIG_MTD_DOC2001 is not set
+# CONFIG_MTD_DOC2001PLUS is not set
+
+#
+# NAND Flash Device Drivers
+#
+# CONFIG_MTD_NAND is not set
+
+#
+# OneNAND Flash Device Drivers
+#
+# CONFIG_MTD_ONENAND is not set
 
 #
 # Parallel port support
@@ -152,7 +360,6 @@ CONFIG_PREVENT_FIRMWARE_BUILD=y
 #
 # Block devices
 #
-# CONFIG_BLK_DEV_FD is not set
 # CONFIG_BLK_DEV_COW_COMMON is not set
 CONFIG_BLK_DEV_LOOP=y
 # CONFIG_BLK_DEV_CRYPTOLOOP is not set
@@ -160,23 +367,21 @@ CONFIG_BLK_DEV_NBD=y
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_COUNT=16
 CONFIG_BLK_DEV_RAM_SIZE=4096
+CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
 # CONFIG_BLK_DEV_INITRD is not set
-CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_CDROM_PKTCDVD is not set
+CONFIG_ATA_OVER_ETH=m
 
 #
-# IO Schedulers
+# Misc devices
 #
-CONFIG_IOSCHED_NOOP=y
-# CONFIG_IOSCHED_AS is not set
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
-# CONFIG_ATA_OVER_ETH is not set
+# CONFIG_TIFM_CORE is not set
 
 #
 # ATA/ATAPI/MFM/RLL support
 #
 CONFIG_IDE=y
+CONFIG_IDE_MAX_HWIFS=4
 CONFIG_BLK_DEV_IDE=y
 
 #
@@ -185,7 +390,6 @@ CONFIG_BLK_DEV_IDE=y
 # CONFIG_BLK_DEV_IDE_SATA is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-CONFIG_BLK_DEV_IDECS=y
 CONFIG_BLK_DEV_IDECD=m
 # CONFIG_BLK_DEV_IDETAPE is not set
 # CONFIG_BLK_DEV_IDEFLOPPY is not set
@@ -204,7 +408,9 @@ CONFIG_IDE_GENERIC=y
 #
 # SCSI device support
 #
+# CONFIG_RAID_ATTRS is not set
 CONFIG_SCSI=m
+# CONFIG_SCSI_NETLINK is not set
 CONFIG_SCSI_PROC_FS=y
 
 #
@@ -216,6 +422,7 @@ CONFIG_BLK_DEV_SD=m
 CONFIG_BLK_DEV_SR=m
 # CONFIG_BLK_DEV_SR_VENDOR is not set
 CONFIG_CHR_DEV_SG=m
+# CONFIG_CHR_DEV_SCH is not set
 
 #
 # Some SCSI devices (e.g. CD jukebox) support multiple LUNs
@@ -225,26 +432,23 @@ CONFIG_SCSI_MULTI_LUN=y
 # CONFIG_SCSI_LOGGING is not set
 
 #
-# SCSI Transport Attributes
+# SCSI Transports
 #
 # CONFIG_SCSI_SPI_ATTRS is not set
 # CONFIG_SCSI_FC_ATTRS is not set
 # CONFIG_SCSI_ISCSI_ATTRS is not set
+# CONFIG_SCSI_SAS_ATTRS is not set
+# CONFIG_SCSI_SAS_LIBSAS is not set
 
 #
 # SCSI low-level drivers
 #
-# CONFIG_SCSI_SATA is not set
+# CONFIG_ISCSI_TCP is not set
 # CONFIG_SCSI_DEBUG is not set
 
 #
-# PCMCIA SCSI adapter support
+# Serial ATA (prod) and Parallel ATA (experimental) drivers
 #
-# CONFIG_PCMCIA_AHA152X is not set
-# CONFIG_PCMCIA_FDOMAIN is not set
-# CONFIG_PCMCIA_NINJA_SCSI is not set
-# CONFIG_PCMCIA_QLOGIC is not set
-# CONFIG_PCMCIA_SYM53C500 is not set
 
 #
 # Multi-device support (RAID and LVM)
@@ -254,6 +458,7 @@ CONFIG_SCSI_MULTI_LUN=y
 #
 # Fusion MPT device support
 #
+# CONFIG_FUSION is not set
 
 #
 # IEEE 1394 (FireWire) support
@@ -264,75 +469,19 @@ CONFIG_SCSI_MULTI_LUN=y
 #
 
 #
-# Networking support
-#
-CONFIG_NET=y
-
-#
-# Networking options
-#
-CONFIG_PACKET=y
-# CONFIG_PACKET_MMAP is not set
-CONFIG_UNIX=y
-# CONFIG_NET_KEY is not set
-CONFIG_INET=y
-# CONFIG_IP_MULTICAST is not set
-# CONFIG_IP_ADVANCED_ROUTER is not set
-CONFIG_IP_PNP=y
-CONFIG_IP_PNP_DHCP=y
-# CONFIG_IP_PNP_BOOTP is not set
-# CONFIG_IP_PNP_RARP is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_ARPD is not set
-# CONFIG_SYN_COOKIES is not set
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-# CONFIG_INET_TUNNEL is not set
-CONFIG_IP_TCPDIAG=y
-# CONFIG_IP_TCPDIAG_IPV6 is not set
-# CONFIG_IPV6 is not set
-# CONFIG_NETFILTER is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_DECNET is not set
-# CONFIG_LLC2 is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-# CONFIG_NET_CLS_ROUTE is not set
-
-#
-# Network testing
+# Network device support
 #
-# CONFIG_NET_PKTGEN is not set
-# CONFIG_NETPOLL is not set
-# CONFIG_NET_POLL_CONTROLLER is not set
-# CONFIG_HAMRADIO is not set
-# CONFIG_IRDA is not set
-# CONFIG_BT is not set
 CONFIG_NETDEVICES=y
 # CONFIG_DUMMY is not set
 # CONFIG_BONDING is not set
 # CONFIG_EQUALIZER is not set
 # CONFIG_TUN is not set
 
+#
+# PHY device support
+#
+# CONFIG_PHYLIB is not set
+
 #
 # Ethernet (10 or 100Mbit)
 #
@@ -358,11 +507,6 @@ CONFIG_SMC91X=y
 #
 # CONFIG_NET_RADIO is not set
 
-#
-# PCMCIA network device support
-#
-# CONFIG_NET_PCMCIA is not set
-
 #
 # Wan interfaces
 #
@@ -371,6 +515,8 @@ CONFIG_SMC91X=y
 # CONFIG_SLIP is not set
 # CONFIG_SHAPER is not set
 # CONFIG_NETCONSOLE is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
 
 #
 # ISDN subsystem
@@ -386,6 +532,7 @@ CONFIG_SMC91X=y
 # Input device support
 #
 CONFIG_INPUT=y
+# CONFIG_INPUT_FF_MEMLESS is not set
 
 #
 # Userland interfaces
@@ -414,7 +561,6 @@ CONFIG_SERIO_SERPORT=y
 # CONFIG_SERIO_LIBPS2 is not set
 # CONFIG_SERIO_RAW is not set
 # CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
 
 #
 # Character devices
@@ -422,6 +568,7 @@ CONFIG_SOUND_GAMEPORT=y
 CONFIG_VT=y
 CONFIG_VT_CONSOLE=y
 CONFIG_HW_CONSOLE=y
+# CONFIG_VT_HW_CONSOLE_BINDING is not set
 # CONFIG_SERIAL_NONSTANDARD is not set
 
 #
@@ -450,8 +597,8 @@ CONFIG_LEGACY_PTY_COUNT=256
 # Watchdog Cards
 #
 # CONFIG_WATCHDOG is not set
+CONFIG_HW_RANDOM=y
 # CONFIG_RTC is not set
-# CONFIG_GEN_RTC is not set
 CONFIG_DS1302=y
 # CONFIG_DTLK is not set
 # CONFIG_R3964 is not set
@@ -459,52 +606,64 @@ CONFIG_DS1302=y
 #
 # Ftape, the floppy tape device driver
 #
-# CONFIG_DRM is not set
-
-#
-# PCMCIA character devices
-#
-# CONFIG_SYNCLINK_CS is not set
 # CONFIG_RAW_DRIVER is not set
 
 #
 # TPM devices
 #
+# CONFIG_TCG_TPM is not set
 
 #
 # I2C support
 #
 # CONFIG_I2C is not set
 
+#
+# SPI support
+#
+# CONFIG_SPI is not set
+# CONFIG_SPI_MASTER is not set
+
 #
 # Dallas's 1-wire bus
 #
 # CONFIG_W1 is not set
 
 #
-# Misc devices
+# Hardware Monitoring support
 #
+CONFIG_HWMON=y
+# CONFIG_HWMON_VID is not set
+# CONFIG_SENSORS_ABITUGURU is not set
+# CONFIG_SENSORS_F71805F is not set
+# CONFIG_SENSORS_VT1211 is not set
+# CONFIG_HWMON_DEBUG_CHIP is not set
 
 #
 # Multimedia devices
 #
-CONFIG_VIDEO_DEV=y
+CONFIG_VIDEO_DEV=m
+CONFIG_VIDEO_V4L1=y
+CONFIG_VIDEO_V4L1_COMPAT=y
+CONFIG_VIDEO_V4L2=y
 
 #
-# Video For Linux
+# Video Capture Adapters
 #
 
 #
-# Video Adapters
+# Video Capture Adapters
 #
+# CONFIG_VIDEO_ADV_DEBUG is not set
+CONFIG_VIDEO_HELPER_CHIPS_AUTO=y
+# CONFIG_VIDEO_VIVI is not set
 # CONFIG_VIDEO_CPIA is not set
-CONFIG_VIDEO_M32R_AR=y
-CONFIG_VIDEO_M32R_AR_M64278=y
+CONFIG_VIDEO_M32R_AR=m
+CONFIG_VIDEO_M32R_AR_M64278=m
 
 #
 # Radio Adapters
 #
-# CONFIG_RADIO_MAESTRO is not set
 
 #
 # Digital Video Broadcasting Devices
@@ -514,15 +673,16 @@ CONFIG_VIDEO_M32R_AR_M64278=y
 #
 # Graphics support
 #
+CONFIG_FIRMWARE_EDID=y
 CONFIG_FB=y
-# CONFIG_FB_CFB_FILLRECT is not set
-# CONFIG_FB_CFB_COPYAREA is not set
-# CONFIG_FB_CFB_IMAGEBLIT is not set
-# CONFIG_FB_SOFT_CURSOR is not set
+CONFIG_FB_CFB_FILLRECT=y
+CONFIG_FB_CFB_COPYAREA=y
+CONFIG_FB_CFB_IMAGEBLIT=y
 # CONFIG_FB_MACMODES is not set
+# CONFIG_FB_BACKLIGHT is not set
 # CONFIG_FB_MODE_HELPERS is not set
 # CONFIG_FB_TILEBLITTING is not set
-# CONFIG_FB_S1D13XXX is not set
+CONFIG_FB_S1D13XXX=y
 # CONFIG_FB_VIRTUAL is not set
 
 #
@@ -531,6 +691,7 @@ CONFIG_FB=y
 # CONFIG_VGA_CONSOLE is not set
 CONFIG_DUMMY_CONSOLE=y
 CONFIG_FRAMEBUFFER_CONSOLE=y
+# CONFIG_FRAMEBUFFER_CONSOLE_ROTATION is not set
 # CONFIG_FONTS is not set
 CONFIG_FONT_8x8=y
 CONFIG_FONT_8x16=y
@@ -542,6 +703,7 @@ CONFIG_LOGO=y
 CONFIG_LOGO_LINUX_MONO=y
 CONFIG_LOGO_LINUX_VGA16=y
 CONFIG_LOGO_LINUX_CLUT224=y
+CONFIG_LOGO_M32R_CLUT224=y
 # CONFIG_BACKLIGHT_LCD_SUPPORT is not set
 
 #
@@ -554,6 +716,11 @@ CONFIG_LOGO_LINUX_CLUT224=y
 #
 # CONFIG_USB_ARCH_HAS_HCD is not set
 # CONFIG_USB_ARCH_HAS_OHCI is not set
+# CONFIG_USB_ARCH_HAS_EHCI is not set
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
+#
 
 #
 # USB Gadget Support
@@ -563,23 +730,62 @@ CONFIG_LOGO_LINUX_CLUT224=y
 #
 # MMC/SD Card support
 #
-# CONFIG_MMC is not set
+CONFIG_MMC=y
+CONFIG_MMC_DEBUG=y
+CONFIG_MMC_BLOCK=y
+# CONFIG_MMC_TIFM_SD is not set
+
+#
+# LED devices
+#
+# CONFIG_NEW_LEDS is not set
+
+#
+# LED drivers
+#
+
+#
+# LED Triggers
+#
 
 #
 # InfiniBand support
 #
-# CONFIG_INFINIBAND is not set
+
+#
+# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
+#
+
+#
+# Real Time Clock
+#
+# CONFIG_RTC_CLASS is not set
+
+#
+# DMA Engine support
+#
+# CONFIG_DMA_ENGINE is not set
+
+#
+# DMA Clients
+#
+
+#
+# DMA Devices
+#
 
 #
 # File systems
 #
 CONFIG_EXT2_FS=y
 # CONFIG_EXT2_FS_XATTR is not set
-CONFIG_EXT3_FS=m
+# CONFIG_EXT2_FS_XIP is not set
+CONFIG_EXT3_FS=y
 CONFIG_EXT3_FS_XATTR=y
 # CONFIG_EXT3_FS_POSIX_ACL is not set
 # CONFIG_EXT3_FS_SECURITY is not set
-CONFIG_JBD=m
+# CONFIG_EXT4DEV_FS is not set
+CONFIG_JBD=y
 CONFIG_JBD_DEBUG=y
 CONFIG_FS_MBCACHE=y
 CONFIG_REISERFS_FS=m
@@ -587,17 +793,19 @@ CONFIG_REISERFS_FS=m
 # CONFIG_REISERFS_PROC_INFO is not set
 # CONFIG_REISERFS_FS_XATTR is not set
 # CONFIG_JFS_FS is not set
-
-#
-# XFS support
-#
+# CONFIG_FS_POSIX_ACL is not set
 # CONFIG_XFS_FS is not set
+# CONFIG_GFS2_FS is not set
+# CONFIG_OCFS2_FS is not set
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
+CONFIG_INOTIFY=y
+CONFIG_INOTIFY_USER=y
 # CONFIG_QUOTA is not set
 CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
+# CONFIG_FUSE_FS is not set
 
 #
 # CD-ROM/DVD Filesystems
@@ -623,15 +831,13 @@ CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
 #
 CONFIG_PROC_FS=y
 CONFIG_PROC_KCORE=y
+CONFIG_PROC_SYSCTL=y
 CONFIG_SYSFS=y
-CONFIG_DEVFS_FS=y
-CONFIG_DEVFS_MOUNT=y
-# CONFIG_DEVFS_DEBUG is not set
-# CONFIG_DEVPTS_FS_XATTR is not set
 CONFIG_TMPFS=y
-# CONFIG_TMPFS_XATTR is not set
+# CONFIG_TMPFS_POSIX_ACL is not set
 # CONFIG_HUGETLB_PAGE is not set
 CONFIG_RAMFS=y
+# CONFIG_CONFIGFS_FS is not set
 
 #
 # Miscellaneous filesystems
@@ -643,6 +849,8 @@ CONFIG_RAMFS=y
 # CONFIG_BEFS_FS is not set
 # CONFIG_BFS_FS is not set
 # CONFIG_EFS_FS is not set
+# CONFIG_JFFS_FS is not set
+# CONFIG_JFFS2_FS is not set
 # CONFIG_CRAMFS is not set
 # CONFIG_VXFS_FS is not set
 # CONFIG_HPFS_FS is not set
@@ -655,12 +863,14 @@ CONFIG_RAMFS=y
 #
 CONFIG_NFS_FS=y
 CONFIG_NFS_V3=y
+# CONFIG_NFS_V3_ACL is not set
 # CONFIG_NFS_V4 is not set
 # CONFIG_NFS_DIRECTIO is not set
 # CONFIG_NFSD is not set
 CONFIG_ROOT_NFS=y
 CONFIG_LOCKD=y
 CONFIG_LOCKD_V4=y
+CONFIG_NFS_COMMON=y
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
 # CONFIG_RPCSEC_GSS_SPKM3 is not set
@@ -669,6 +879,7 @@ CONFIG_SUNRPC=y
 # CONFIG_NCP_FS is not set
 # CONFIG_CODA_FS is not set
 # CONFIG_AFS_FS is not set
+# CONFIG_9P_FS is not set
 
 #
 # Partition Types
@@ -723,16 +934,23 @@ CONFIG_NLS_DEFAULT="iso8859-1"
 #
 # Profiling support
 #
-# CONFIG_PROFILING is not set
+CONFIG_PROFILING=y
+CONFIG_OPROFILE=y
 
 #
 # Kernel hacking
 #
 # CONFIG_PRINTK_TIME is not set
+CONFIG_ENABLE_MUST_CHECK=y
+# CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_UNUSED_SYMBOLS is not set
 # CONFIG_DEBUG_KERNEL is not set
-CONFIG_LOG_BUF_SHIFT=14
+CONFIG_LOG_BUF_SHIFT=15
 # CONFIG_DEBUG_BUGVERBOSE is not set
+# CONFIG_DEBUG_FS is not set
 # CONFIG_FRAME_POINTER is not set
+# CONFIG_UNWIND_INFO is not set
+# CONFIG_HEADERS_CHECK is not set
 
 #
 # Security options
@@ -745,13 +963,10 @@ CONFIG_LOG_BUF_SHIFT=14
 #
 # CONFIG_CRYPTO is not set
 
-#
-# Hardware crypto devices
-#
-
 #
 # Library routines
 #
 # CONFIG_CRC_CCITT is not set
+# CONFIG_CRC16 is not set
 CONFIG_CRC32=y
 # CONFIG_LIBCRC32C is not set
index 0d3c8ee0e03d9fc21de2fd05f160d7d612d993a2..dab7436d7bbe85e2997c18b43b5082e4eece4255 100644 (file)
@@ -7,8 +7,6 @@
  *                            Hitoshi Yamamoto
  */
 
-/* $Id$ */
-
 #include <linux/init.h>
 __INIT
 __INITDATA
index 44cbe0ce0f8fb21681590509e76af47ac9696727..a689e2978b6e382bdad4f9fcd56fbf194a1ddb6f 100644 (file)
@@ -174,7 +174,7 @@ void show_regs(struct pt_regs * regs)
          regs->acc1h, regs->acc1l);
 #elif defined(CONFIG_ISA_M32R2) || defined(CONFIG_ISA_M32R)
        printk("ACCH[%08lx]:ACCL[%08lx]\n", \
-         regs->acch, regs->accl);
+         regs->acc0h, regs->acc0l);
 #else
 #error unknown isa configuration
 #endif
index 092ea86bb0794a473780c2b474197f2bcf4ef1ee..4b156054baa6306f0d1d5d774c3f972809951737 100644 (file)
@@ -109,19 +109,10 @@ restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc,
        COPY(r10);
        COPY(r11);
        COPY(r12);
-#if defined(CONFIG_ISA_M32R2) && defined(CONFIG_ISA_DSP_LEVEL2)
        COPY(acc0h);
        COPY(acc0l);
-       COPY(acc1h);
-       COPY(acc1l);
-#elif defined(CONFIG_ISA_M32R2) || defined(CONFIG_ISA_M32R)
-       COPY(acch);
-       COPY(accl);
-       COPY(dummy_acc1h);
-       COPY(dummy_acc1l);
-#else
-#error unknown isa configuration
-#endif
+       COPY(acc1h);            /* ISA_DSP_LEVEL2 only */
+       COPY(acc1l);            /* ISA_DSP_LEVEL2 only */
        COPY(psw);
        COPY(bpc);
        COPY(bbpsw);
@@ -196,19 +187,10 @@ setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs,
        COPY(r10);
        COPY(r11);
        COPY(r12);
-#if defined(CONFIG_ISA_M32R2) && defined(CONFIG_ISA_DSP_LEVEL2)
        COPY(acc0h);
        COPY(acc0l);
-       COPY(acc1h);
-       COPY(acc1l);
-#elif defined(CONFIG_ISA_M32R2) || defined(CONFIG_ISA_M32R)
-       COPY(acch);
-       COPY(accl);
-       COPY(dummy_acc1h);
-       COPY(dummy_acc1l);
-#else
-#error unknown isa configuration
-#endif
+       COPY(acc1h);            /* ISA_DSP_LEVEL2 only */
+       COPY(acc1l);            /* ISA_DSP_LEVEL2 only */
        COPY(psw);
        COPY(bpc);
        COPY(bbpsw);
index a09038282c78a3f5b452f4c4cbbf06120283d15f..3858c9f39ba5fb2362ad60e5ce381514e5c7c933 100644 (file)
@@ -286,11 +286,3 @@ void __init time_init(void)
 #error no chip configuration
 #endif
 }
-
-/*
- *  Scheduler clock - returns current time in nanosec units.
- */
-unsigned long long sched_clock(void)
-{
-       return (unsigned long long)jiffies * (1000000000 / HZ);
-}
index 358b9cee2c6585c0a84d42e9e22ef4c7fbe52b64..439cc257cd1df7faf55a57051530d65be3dac13b 100644 (file)
@@ -6,12 +6,15 @@
 #include <asm/page.h>
 
 OUTPUT_ARCH(m32r)
-ENTRY(startup_32)
 #if defined(__LITTLE_ENDIAN__)
        jiffies = jiffies_64;
 #else
        jiffies = jiffies_64 + 4;
 #endif
+
+kernel_entry = boot - 0x80000000;
+ENTRY(kernel_entry)
+
 SECTIONS
 {
   . = CONFIG_MEMORY_START + __PAGE_OFFSET;
@@ -99,10 +102,14 @@ SECTIONS
      from .altinstructions and .eh_frame */
   .exit.text : { *(.exit.text) }
   .exit.data : { *(.exit.data) }
+
+#ifdef CONFIG_BLK_DEV_INITRD
   . = ALIGN(4096);
   __initramfs_start = .;
   .init.ramfs : { *(.init.ramfs) }
   __initramfs_end = .;
+#endif
+
   . = ALIGN(32);
   __per_cpu_start = .;
   .data.percpu  : { *(.data.percpu) }
index 107594b65d58315059fd86f0cfe02c284cb6fc95..7fc0c19801ba4a3a688a8e8bd6e95daa8c1d9137 100644 (file)
@@ -4,8 +4,6 @@
  * Copyright (C) 2001,2002  Hiroyuki Kondo, and Hirokazu Takata
  *
  */
-/* $Id$ */
-
 
 ;
 ;      input   (r0,r1)  src
@@ -293,4 +291,3 @@ __lshrdi3:
 #endif /* not CONFIG_ISA_DUAL_ISSUE */
 
        .end
-
index cfbe00e5184a7dcbfb189cfde256942060e9f95f..0af0360c76d9505f2ce1965f3fc9e337830d1f46 100644 (file)
@@ -25,8 +25,6 @@
  *             as published by the Free Software Foundation; either version
  *             2 of the License, or (at your option) any later version.
  */
-/* $Id$ */
-
 
 #include <linux/linkage.h>
 #include <asm/assembler.h>
@@ -319,3 +317,4 @@ ENTRY(csum_partial_copy_generic)
        nop
        nop
 
+       .end
index 06382a38c3185f79242b2dbec8a3f12850bccced..59bfc34e0d9f8aa86ded52d4145592af889aec1f 100644 (file)
@@ -5,8 +5,6 @@
  * Copyright (c) 2004  Hirokazu Takata
  */
 
-/* $Id$ */
-
 #include <linux/param.h>
 #ifdef CONFIG_SMP
 #include <linux/sched.h>
index 2089a215314eb5aff9c18f032182bc0693696584..05987cd639ef70b9fa193ff3c0351e4f9215b4e0 100644 (file)
@@ -10,8 +10,6 @@
  *        src: r1
  *        n  : r2
  */
-/* $Id$ */
-
 
        .text
 #include <linux/linkage.h>
index b47fa3537aa4f16067473a9b7085beea3f79d6de..2b2831a379273730c79c026e64bc911d3e456caa 100644 (file)
@@ -12,8 +12,6 @@
  *        ret: r0
  *
  */
-/* $Id$ */
-
 
        .text
        .global memset
index 5f41aacd7b3e43f71ab10ed5fba0e07acd76b84a..916de9e8f80121cdbdc51d733b11d382636a0292 100644 (file)
@@ -6,8 +6,6 @@
  *  size_t strlen(const char *s);
  *
  */
-/* $Id$ */
-
 
 #include <linux/linkage.h>
 #include <asm/assembler.h>
index 454de336803a10b971d77ab2a98e3cd72dbe11c8..7b68fe8d921e2b8328f4d9cd58842090a9d11292 100644 (file)
@@ -1,20 +1,20 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.14
-# Wed Nov  9 16:04:51 2005
+# Linux kernel version: 2.6.19
+# Wed Dec 13 17:22:20 2006
 #
 CONFIG_M32R=y
-# CONFIG_UID16 is not set
 CONFIG_GENERIC_ISA_DMA=y
 CONFIG_GENERIC_HARDIRQS=y
 CONFIG_GENERIC_IRQ_PROBE=y
+CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
 
 #
 # Code maturity level options
 #
 CONFIG_EXPERIMENTAL=y
-CONFIG_CLEAN_COMPILE=y
 CONFIG_BROKEN_ON_SMP=y
+CONFIG_LOCK_KERNEL=y
 CONFIG_INIT_ENV_ARG_LIMIT=32
 
 #
@@ -22,33 +22,66 @@ CONFIG_INIT_ENV_ARG_LIMIT=32
 #
 CONFIG_LOCALVERSION=""
 CONFIG_LOCALVERSION_AUTO=y
+CONFIG_SYSVIPC=y
+# CONFIG_IPC_NS is not set
 # CONFIG_POSIX_MQUEUE is not set
 # CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
+# CONFIG_TASKSTATS is not set
+# CONFIG_UTS_NS is not set
 # CONFIG_AUDIT is not set
-CONFIG_HOTPLUG=y
-# CONFIG_KOBJECT_UEVENT is not set
-# CONFIG_IKCONFIG is not set
+CONFIG_IKCONFIG=y
+CONFIG_IKCONFIG_PROC=y
+CONFIG_SYSFS_DEPRECATED=y
+# CONFIG_RELAY is not set
 CONFIG_INITRAMFS_SOURCE=""
-CONFIG_EMBEDDED=y
-# CONFIG_KALLSYMS is not set
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_SYSCTL=y
+# CONFIG_EMBEDDED is not set
+CONFIG_SYSCTL_SYSCALL=y
+CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_HOTPLUG=y
 CONFIG_PRINTK=y
 CONFIG_BUG=y
+CONFIG_ELF_CORE=y
 CONFIG_BASE_FULL=y
-# CONFIG_FUTEX is not set
-# CONFIG_EPOLL is not set
-# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
-CONFIG_CC_ALIGN_FUNCTIONS=0
-CONFIG_CC_ALIGN_LABELS=0
-CONFIG_CC_ALIGN_LOOPS=0
-CONFIG_CC_ALIGN_JUMPS=0
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+CONFIG_SLAB=y
+CONFIG_VM_EVENT_COUNTERS=y
+CONFIG_RT_MUTEXES=y
 CONFIG_TINY_SHMEM=y
 CONFIG_BASE_SMALL=0
+# CONFIG_SLOB is not set
 
 #
 # Loadable module support
 #
-# CONFIG_MODULES is not set
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+CONFIG_MODULE_FORCE_UNLOAD=y
+# CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SRCVERSION_ALL is not set
+CONFIG_KMOD=y
+
+#
+# Block layer
+#
+CONFIG_BLOCK=y
+# CONFIG_BLK_DEV_IO_TRACE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+CONFIG_DEFAULT_AS=y
+# CONFIG_DEFAULT_DEADLINE is not set
+# CONFIG_DEFAULT_CFQ is not set
+# CONFIG_DEFAULT_NOOP is not set
+CONFIG_DEFAULT_IOSCHED="anticipatory"
 
 #
 # Processor type and features
@@ -70,40 +103,40 @@ CONFIG_ISA_M32R=y
 CONFIG_BUS_CLOCK=54000000
 CONFIG_TIMER_DIVIDE=128
 # CONFIG_CPU_LITTLE_ENDIAN is not set
-CONFIG_MEMORY_START=04000000
-CONFIG_MEMORY_SIZE=01000000
+CONFIG_MEMORY_START=0x04000000
+CONFIG_MEMORY_SIZE=0x01000000
 CONFIG_NOHIGHMEM=y
-# CONFIG_ARCH_DISCONTIGMEM_ENABLE is not set
+CONFIG_ARCH_DISCONTIGMEM_ENABLE=y
 CONFIG_SELECT_MEMORY_MODEL=y
-CONFIG_FLATMEM_MANUAL=y
-# CONFIG_DISCONTIGMEM_MANUAL is not set
+# CONFIG_FLATMEM_MANUAL is not set
+CONFIG_DISCONTIGMEM_MANUAL=y
 # CONFIG_SPARSEMEM_MANUAL is not set
-CONFIG_FLATMEM=y
+CONFIG_DISCONTIGMEM=y
 CONFIG_FLAT_NODE_MEM_MAP=y
+CONFIG_NEED_MULTIPLE_NODES=y
 # CONFIG_SPARSEMEM_STATIC is not set
+CONFIG_SPLIT_PTLOCK_CPUS=4
+# CONFIG_RESOURCES_64BIT is not set
+CONFIG_IRAM_START=0x00700000
+CONFIG_IRAM_SIZE=0x00010000
 CONFIG_RWSEM_GENERIC_SPINLOCK=y
 # CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
+CONFIG_GENERIC_FIND_NEXT_BIT=y
+CONFIG_GENERIC_HWEIGHT=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
-# CONFIG_PREEMPT is not set
+CONFIG_PREEMPT=y
 # CONFIG_SMP is not set
+CONFIG_NODES_SHIFT=1
 
 #
 # Bus options (PCI, PCMCIA, EISA, MCA, ISA)
 #
-# CONFIG_ISA is not set
+CONFIG_ISA=y
 
 #
 # PCCARD (PCMCIA/CardBus) support
 #
-CONFIG_PCCARD=y
-# CONFIG_PCMCIA_DEBUG is not set
-CONFIG_PCMCIA=y
-CONFIG_PCMCIA_LOAD_CIS=y
-CONFIG_PCMCIA_IOCTL=y
-
-#
-# PC-card bridges
-#
+# CONFIG_PCCARD is not set
 
 #
 # PCI Hotplug Support
@@ -112,10 +145,8 @@ CONFIG_PCMCIA_IOCTL=y
 #
 # Executable file formats
 #
-CONFIG_BINFMT_FLAT=y
-# CONFIG_BINFMT_ZFLAT is not set
-# CONFIG_BINFMT_SHARED_FLAT is not set
-# CONFIG_BINFMT_MISC is not set
+# CONFIG_BINFMT_FLAT is not set
+CONFIG_BINFMT_MISC=y
 
 #
 # Networking
@@ -125,17 +156,19 @@ CONFIG_NET=y
 #
 # Networking options
 #
-# CONFIG_PACKET is not set
+# CONFIG_NETDEBUG is not set
+CONFIG_PACKET=y
+# CONFIG_PACKET_MMAP is not set
 CONFIG_UNIX=y
+CONFIG_XFRM=y
+# CONFIG_XFRM_USER is not set
+# CONFIG_XFRM_SUB_POLICY is not set
 # CONFIG_NET_KEY is not set
 CONFIG_INET=y
 # CONFIG_IP_MULTICAST is not set
 # CONFIG_IP_ADVANCED_ROUTER is not set
 CONFIG_IP_FIB_HASH=y
-CONFIG_IP_PNP=y
-CONFIG_IP_PNP_DHCP=y
-# CONFIG_IP_PNP_BOOTP is not set
-# CONFIG_IP_PNP_RARP is not set
+# CONFIG_IP_PNP is not set
 # CONFIG_NET_IPIP is not set
 # CONFIG_NET_IPGRE is not set
 # CONFIG_ARPD is not set
@@ -143,13 +176,87 @@ CONFIG_IP_PNP_DHCP=y
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_XFRM_TUNNEL is not set
 # CONFIG_INET_TUNNEL is not set
+CONFIG_INET_XFRM_MODE_TRANSPORT=y
+CONFIG_INET_XFRM_MODE_TUNNEL=y
+CONFIG_INET_XFRM_MODE_BEET=y
 CONFIG_INET_DIAG=y
 CONFIG_INET_TCP_DIAG=y
 # CONFIG_TCP_CONG_ADVANCED is not set
-CONFIG_TCP_CONG_BIC=y
+CONFIG_TCP_CONG_CUBIC=y
+CONFIG_DEFAULT_TCP_CONG="cubic"
+# CONFIG_TCP_MD5SIG is not set
+
+#
+# IP: Virtual Server Configuration
+#
+# CONFIG_IP_VS is not set
 # CONFIG_IPV6 is not set
-# CONFIG_NETFILTER is not set
+# CONFIG_INET6_XFRM_TUNNEL is not set
+# CONFIG_INET6_TUNNEL is not set
+# CONFIG_NETWORK_SECMARK is not set
+CONFIG_NETFILTER=y
+# CONFIG_NETFILTER_DEBUG is not set
+
+#
+# Core Netfilter Configuration
+#
+CONFIG_NETFILTER_NETLINK=m
+CONFIG_NETFILTER_NETLINK_QUEUE=m
+CONFIG_NETFILTER_NETLINK_LOG=m
+# CONFIG_NF_CONNTRACK_ENABLED is not set
+CONFIG_NETFILTER_XTABLES=m
+CONFIG_NETFILTER_XT_TARGET_CLASSIFY=m
+# CONFIG_NETFILTER_XT_TARGET_DSCP is not set
+CONFIG_NETFILTER_XT_TARGET_MARK=m
+CONFIG_NETFILTER_XT_TARGET_NFQUEUE=m
+# CONFIG_NETFILTER_XT_TARGET_NFLOG is not set
+CONFIG_NETFILTER_XT_MATCH_COMMENT=m
+CONFIG_NETFILTER_XT_MATCH_DCCP=m
+# CONFIG_NETFILTER_XT_MATCH_DSCP is not set
+# CONFIG_NETFILTER_XT_MATCH_ESP is not set
+CONFIG_NETFILTER_XT_MATCH_LENGTH=m
+CONFIG_NETFILTER_XT_MATCH_LIMIT=m
+CONFIG_NETFILTER_XT_MATCH_MAC=m
+CONFIG_NETFILTER_XT_MATCH_MARK=m
+# CONFIG_NETFILTER_XT_MATCH_POLICY is not set
+# CONFIG_NETFILTER_XT_MATCH_MULTIPORT is not set
+CONFIG_NETFILTER_XT_MATCH_PKTTYPE=m
+# CONFIG_NETFILTER_XT_MATCH_QUOTA is not set
+CONFIG_NETFILTER_XT_MATCH_REALM=m
+CONFIG_NETFILTER_XT_MATCH_SCTP=m
+# CONFIG_NETFILTER_XT_MATCH_STATISTIC is not set
+CONFIG_NETFILTER_XT_MATCH_STRING=m
+CONFIG_NETFILTER_XT_MATCH_TCPMSS=m
+# CONFIG_NETFILTER_XT_MATCH_HASHLIMIT is not set
+
+#
+# IP: Netfilter Configuration
+#
+CONFIG_IP_NF_QUEUE=m
+CONFIG_IP_NF_IPTABLES=m
+CONFIG_IP_NF_MATCH_IPRANGE=m
+CONFIG_IP_NF_MATCH_TOS=m
+CONFIG_IP_NF_MATCH_RECENT=m
+CONFIG_IP_NF_MATCH_ECN=m
+# CONFIG_IP_NF_MATCH_AH is not set
+CONFIG_IP_NF_MATCH_TTL=m
+CONFIG_IP_NF_MATCH_OWNER=m
+CONFIG_IP_NF_MATCH_ADDRTYPE=m
+CONFIG_IP_NF_FILTER=m
+CONFIG_IP_NF_TARGET_REJECT=m
+CONFIG_IP_NF_TARGET_LOG=m
+CONFIG_IP_NF_TARGET_ULOG=m
+CONFIG_IP_NF_TARGET_TCPMSS=m
+CONFIG_IP_NF_MANGLE=m
+CONFIG_IP_NF_TARGET_TOS=m
+CONFIG_IP_NF_TARGET_ECN=m
+CONFIG_IP_NF_TARGET_TTL=m
+CONFIG_IP_NF_RAW=m
+CONFIG_IP_NF_ARPTABLES=m
+CONFIG_IP_NF_ARPFILTER=m
+CONFIG_IP_NF_ARP_MANGLE=m
 
 #
 # DCCP Configuration (EXPERIMENTAL)
@@ -160,6 +267,11 @@ CONFIG_TCP_CONG_BIC=y
 # SCTP Configuration (EXPERIMENTAL)
 #
 # CONFIG_IP_SCTP is not set
+
+#
+# TIPC Configuration (EXPERIMENTAL)
+#
+# CONFIG_TIPC is not set
 # CONFIG_ATM is not set
 # CONFIG_BRIDGE is not set
 # CONFIG_VLAN_8021Q is not set
@@ -169,11 +281,14 @@ CONFIG_TCP_CONG_BIC=y
 # CONFIG_ATALK is not set
 # CONFIG_X25 is not set
 # CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
+
+#
+# QoS and/or fair queueing
+#
 # CONFIG_NET_SCHED is not set
-# CONFIG_NET_CLS_ROUTE is not set
+CONFIG_NET_CLS_ROUTE=y
 
 #
 # Network testing
@@ -193,8 +308,8 @@ CONFIG_TCP_CONG_BIC=y
 #
 CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
-CONFIG_FW_LOADER=y
-# CONFIG_DEBUG_DRIVER is not set
+# CONFIG_FW_LOADER is not set
+# CONFIG_SYS_HYPERVISOR is not set
 
 #
 # Connector - unified userspace <-> kernelspace linker
@@ -209,11 +324,21 @@ CONFIG_FW_LOADER=y
 #
 # Parallel port support
 #
-# CONFIG_PARPORT is not set
+CONFIG_PARPORT=m
+# CONFIG_PARPORT_GSC is not set
+# CONFIG_PARPORT_AX88796 is not set
+CONFIG_PARPORT_1284=y
 
 #
 # Plug and Play support
 #
+CONFIG_PNP=y
+# CONFIG_PNP_DEBUG is not set
+
+#
+# Protocols
+#
+CONFIG_ISAPNP=y
 
 #
 # Block devices
@@ -221,37 +346,130 @@ CONFIG_FW_LOADER=y
 # CONFIG_BLK_DEV_COW_COMMON is not set
 CONFIG_BLK_DEV_LOOP=y
 # CONFIG_BLK_DEV_CRYPTOLOOP is not set
-CONFIG_BLK_DEV_NBD=y
-CONFIG_BLK_DEV_RAM=y
-CONFIG_BLK_DEV_RAM_COUNT=16
-CONFIG_BLK_DEV_RAM_SIZE=4096
-CONFIG_BLK_DEV_INITRD=y
-# CONFIG_CDROM_PKTCDVD is not set
+CONFIG_BLK_DEV_NBD=m
+# CONFIG_BLK_DEV_RAM is not set
+# CONFIG_BLK_DEV_INITRD is not set
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+CONFIG_CDROM_PKTCDVD_WCACHE=y
+# CONFIG_ATA_OVER_ETH is not set
 
 #
-# IO Schedulers
+# Misc devices
 #
-CONFIG_IOSCHED_NOOP=y
-# CONFIG_IOSCHED_AS is not set
-# CONFIG_IOSCHED_DEADLINE is not set
-# CONFIG_IOSCHED_CFQ is not set
-# CONFIG_ATA_OVER_ETH is not set
+# CONFIG_TIFM_CORE is not set
 
 #
 # ATA/ATAPI/MFM/RLL support
 #
-# CONFIG_IDE is not set
+CONFIG_IDE=y
+CONFIG_BLK_DEV_IDE=y
+
+#
+# Please see Documentation/ide.txt for help/info on IDE drives
+#
+# CONFIG_BLK_DEV_IDE_SATA is not set
+CONFIG_BLK_DEV_IDEDISK=y
+# CONFIG_IDEDISK_MULTI_MODE is not set
+CONFIG_BLK_DEV_IDECD=y
+# CONFIG_BLK_DEV_IDETAPE is not set
+# CONFIG_BLK_DEV_IDEFLOPPY is not set
+# CONFIG_BLK_DEV_IDESCSI is not set
+# CONFIG_IDE_TASK_IOCTL is not set
+
+#
+# IDE chipset support/bugfixes
+#
+CONFIG_IDE_GENERIC=y
+# CONFIG_BLK_DEV_IDEPNP is not set
+# CONFIG_IDE_ARM is not set
+# CONFIG_IDE_CHIPSETS is not set
+# CONFIG_BLK_DEV_IDEDMA is not set
+# CONFIG_IDEDMA_AUTO is not set
+# CONFIG_BLK_DEV_HD is not set
 
 #
 # SCSI device support
 #
 # CONFIG_RAID_ATTRS is not set
-# CONFIG_SCSI is not set
+CONFIG_SCSI=y
+# CONFIG_SCSI_NETLINK is not set
+CONFIG_SCSI_PROC_FS=y
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+CONFIG_BLK_DEV_SD=y
+CONFIG_CHR_DEV_ST=m
+# CONFIG_CHR_DEV_OSST is not set
+CONFIG_BLK_DEV_SR=m
+# CONFIG_BLK_DEV_SR_VENDOR is not set
+CONFIG_CHR_DEV_SG=m
+# CONFIG_CHR_DEV_SCH is not set
+
+#
+# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
+#
+CONFIG_SCSI_MULTI_LUN=y
+CONFIG_SCSI_CONSTANTS=y
+# CONFIG_SCSI_LOGGING is not set
+
+#
+# SCSI Transports
+#
+CONFIG_SCSI_SPI_ATTRS=y
+# CONFIG_SCSI_FC_ATTRS is not set
+# CONFIG_SCSI_ISCSI_ATTRS is not set
+# CONFIG_SCSI_SAS_ATTRS is not set
+# CONFIG_SCSI_SAS_LIBSAS is not set
+
+#
+# SCSI low-level drivers
+#
+# CONFIG_ISCSI_TCP is not set
+# CONFIG_SCSI_AHA152X is not set
+# CONFIG_SCSI_AIC7XXX_OLD is not set
+# CONFIG_SCSI_IN2000 is not set
+# CONFIG_SCSI_DTC3280 is not set
+# CONFIG_SCSI_FUTURE_DOMAIN is not set
+# CONFIG_SCSI_GENERIC_NCR5380 is not set
+# CONFIG_SCSI_GENERIC_NCR5380_MMIO is not set
+# CONFIG_SCSI_NCR53C406A is not set
+# CONFIG_SCSI_PAS16 is not set
+# CONFIG_SCSI_PSI240I is not set
+# CONFIG_SCSI_QLOGIC_FAS is not set
+# CONFIG_SCSI_SYM53C416 is not set
+# CONFIG_SCSI_T128 is not set
+# CONFIG_SCSI_DEBUG is not set
+
+#
+# Serial ATA (prod) and Parallel ATA (experimental) drivers
+#
+
+#
+# Old CD-ROM drivers (not SCSI, not IDE)
+#
+# CONFIG_CD_NO_IDESCSI is not set
 
 #
 # Multi-device support (RAID and LVM)
 #
-# CONFIG_MD is not set
+CONFIG_MD=y
+CONFIG_BLK_DEV_MD=y
+# CONFIG_MD_LINEAR is not set
+# CONFIG_MD_RAID0 is not set
+CONFIG_MD_RAID1=y
+# CONFIG_MD_RAID10 is not set
+# CONFIG_MD_RAID456 is not set
+# CONFIG_MD_MULTIPATH is not set
+# CONFIG_MD_FAULTY is not set
+CONFIG_BLK_DEV_DM=m
+# CONFIG_DM_DEBUG is not set
+CONFIG_DM_CRYPT=m
+CONFIG_DM_SNAPSHOT=m
+# CONFIG_DM_MIRROR is not set
+# CONFIG_DM_ZERO is not set
+# CONFIG_DM_MULTIPATH is not set
 
 #
 # Fusion MPT device support
@@ -270,10 +488,16 @@ CONFIG_IOSCHED_NOOP=y
 # Network device support
 #
 CONFIG_NETDEVICES=y
-CONFIG_DUMMY=y
+CONFIG_DUMMY=m
 # CONFIG_BONDING is not set
 # CONFIG_EQUALIZER is not set
 # CONFIG_TUN is not set
+# CONFIG_NET_SB1000 is not set
+
+#
+# ARCnet devices
+#
+# CONFIG_ARCNET is not set
 
 #
 # PHY device support
@@ -285,8 +509,33 @@ CONFIG_DUMMY=y
 #
 CONFIG_NET_ETHERNET=y
 CONFIG_MII=y
-CONFIG_SMC91X=y
-# CONFIG_NE2000 is not set
+CONFIG_NET_VENDOR_3COM=y
+# CONFIG_EL1 is not set
+# CONFIG_EL2 is not set
+# CONFIG_EL16 is not set
+# CONFIG_EL3 is not set
+# CONFIG_NET_VENDOR_SMC is not set
+# CONFIG_SMC91X is not set
+# CONFIG_NET_VENDOR_RACAL is not set
+# CONFIG_AT1700 is not set
+# CONFIG_DEPCA is not set
+# CONFIG_HP100 is not set
+CONFIG_NET_ISA=y
+# CONFIG_E2100 is not set
+# CONFIG_EWRK3 is not set
+# CONFIG_EEXPRESS is not set
+# CONFIG_EEXPRESS_PRO is not set
+# CONFIG_HPLAN_PLUS is not set
+# CONFIG_HPLAN is not set
+# CONFIG_LP486E is not set
+# CONFIG_ETH16I is not set
+CONFIG_NE2000=m
+# CONFIG_SEEQ8005 is not set
+CONFIG_NET_PCI=y
+# CONFIG_AC3200 is not set
+# CONFIG_APRICOT is not set
+# CONFIG_CS89x0 is not set
+# CONFIG_NET_POCKET is not set
 
 #
 # Ethernet (1000 Mbit)
@@ -299,21 +548,18 @@ CONFIG_SMC91X=y
 #
 # Token Ring devices
 #
+# CONFIG_TR is not set
 
 #
 # Wireless LAN (non-hamradio)
 #
 # CONFIG_NET_RADIO is not set
 
-#
-# PCMCIA network device support
-#
-# CONFIG_NET_PCMCIA is not set
-
 #
 # Wan interfaces
 #
 # CONFIG_WAN is not set
+# CONFIG_PLIP is not set
 # CONFIG_PPP is not set
 # CONFIG_SLIP is not set
 # CONFIG_SHAPER is not set
@@ -334,35 +580,83 @@ CONFIG_SMC91X=y
 #
 # Input device support
 #
-# CONFIG_INPUT is not set
+CONFIG_INPUT=y
+# CONFIG_INPUT_FF_MEMLESS is not set
+
+#
+# Userland interfaces
+#
+CONFIG_INPUT_MOUSEDEV=y
+CONFIG_INPUT_MOUSEDEV_PSAUX=y
+CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
+CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_TSDEV is not set
+# CONFIG_INPUT_EVDEV is not set
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input Device Drivers
+#
+CONFIG_INPUT_KEYBOARD=y
+CONFIG_KEYBOARD_ATKBD=y
+# CONFIG_KEYBOARD_SUNKBD is not set
+# CONFIG_KEYBOARD_LKKBD is not set
+# CONFIG_KEYBOARD_XTKBD is not set
+# CONFIG_KEYBOARD_NEWTON is not set
+# CONFIG_KEYBOARD_STOWAWAY is not set
+CONFIG_INPUT_MOUSE=y
+CONFIG_MOUSE_PS2=y
+# CONFIG_MOUSE_SERIAL is not set
+# CONFIG_MOUSE_INPORT is not set
+# CONFIG_MOUSE_LOGIBM is not set
+# CONFIG_MOUSE_PC110PAD is not set
+# CONFIG_MOUSE_VSXXXAA is not set
+# CONFIG_INPUT_JOYSTICK is not set
+# CONFIG_INPUT_TOUCHSCREEN is not set
+# CONFIG_INPUT_MISC is not set
 
 #
 # Hardware I/O ports
 #
-# CONFIG_SERIO is not set
+CONFIG_SERIO=y
+CONFIG_SERIO_I8042=y
+CONFIG_SERIO_SERPORT=y
+# CONFIG_SERIO_PARKBD is not set
+CONFIG_SERIO_LIBPS2=y
+# CONFIG_SERIO_RAW is not set
 # CONFIG_GAMEPORT is not set
 
 #
 # Character devices
 #
-# CONFIG_VT is not set
+CONFIG_VT=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+# CONFIG_VT_HW_CONSOLE_BINDING is not set
 # CONFIG_SERIAL_NONSTANDARD is not set
 
 #
 # Serial drivers
 #
-# CONFIG_SERIAL_8250 is not set
+CONFIG_SERIAL_8250=m
+CONFIG_SERIAL_8250_PNP=m
+CONFIG_SERIAL_8250_NR_UARTS=4
+CONFIG_SERIAL_8250_RUNTIME_UARTS=4
+# CONFIG_SERIAL_8250_EXTENDED is not set
 
 #
 # Non-8250 serial port support
 #
 CONFIG_SERIAL_CORE=y
-CONFIG_SERIAL_CORE_CONSOLE=y
 CONFIG_SERIAL_M32R_SIO=y
-CONFIG_SERIAL_M32R_SIO_CONSOLE=y
+# CONFIG_SERIAL_M32R_SIO_CONSOLE is not set
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
+# CONFIG_PRINTER is not set
+# CONFIG_PPDEV is not set
+# CONFIG_TIPAR is not set
 
 #
 # IPMI
@@ -372,13 +666,8 @@ CONFIG_LEGACY_PTY_COUNT=256
 #
 # Watchdog Cards
 #
-CONFIG_WATCHDOG=y
-# CONFIG_WATCHDOG_NOWAYOUT is not set
-
-#
-# Watchdog Device Drivers
-#
-CONFIG_SOFT_WATCHDOG=y
+# CONFIG_WATCHDOG is not set
+# CONFIG_HW_RANDOM is not set
 # CONFIG_RTC is not set
 # CONFIG_DTLK is not set
 # CONFIG_R3964 is not set
@@ -386,21 +675,57 @@ CONFIG_SOFT_WATCHDOG=y
 #
 # Ftape, the floppy tape device driver
 #
-
-#
-# PCMCIA character devices
-#
-# CONFIG_SYNCLINK_CS is not set
 # CONFIG_RAW_DRIVER is not set
 
 #
 # TPM devices
 #
+# CONFIG_TCG_TPM is not set
 
 #
 # I2C support
 #
-# CONFIG_I2C is not set
+CONFIG_I2C=m
+CONFIG_I2C_CHARDEV=m
+
+#
+# I2C Algorithms
+#
+CONFIG_I2C_ALGOBIT=m
+CONFIG_I2C_ALGOPCF=m
+# CONFIG_I2C_ALGOPCA is not set
+
+#
+# I2C Hardware Bus support
+#
+CONFIG_I2C_ELEKTOR=m
+CONFIG_I2C_ISA=m
+# CONFIG_I2C_OCORES is not set
+# CONFIG_I2C_PARPORT is not set
+# CONFIG_I2C_PARPORT_LIGHT is not set
+# CONFIG_I2C_STUB is not set
+# CONFIG_I2C_PCA_ISA is not set
+
+#
+# Miscellaneous I2C Chip support
+#
+# CONFIG_SENSORS_DS1337 is not set
+# CONFIG_SENSORS_DS1374 is not set
+# CONFIG_SENSORS_EEPROM is not set
+# CONFIG_SENSORS_PCF8574 is not set
+# CONFIG_SENSORS_PCA9539 is not set
+# CONFIG_SENSORS_PCF8591 is not set
+# CONFIG_SENSORS_MAX6875 is not set
+# CONFIG_I2C_DEBUG_CORE is not set
+# CONFIG_I2C_DEBUG_ALGO is not set
+# CONFIG_I2C_DEBUG_BUS is not set
+# CONFIG_I2C_DEBUG_CHIP is not set
+
+#
+# SPI support
+#
+# CONFIG_SPI is not set
+# CONFIG_SPI_MASTER is not set
 
 #
 # Dallas's 1-wire bus
@@ -410,21 +735,89 @@ CONFIG_SOFT_WATCHDOG=y
 #
 # Hardware Monitoring support
 #
-# CONFIG_HWMON is not set
-# CONFIG_HWMON_VID is not set
+CONFIG_HWMON=y
+CONFIG_HWMON_VID=m
+# CONFIG_SENSORS_ABITUGURU is not set
+CONFIG_SENSORS_ADM1021=m
+CONFIG_SENSORS_ADM1025=m
+# CONFIG_SENSORS_ADM1026 is not set
+CONFIG_SENSORS_ADM1031=m
+# CONFIG_SENSORS_ADM9240 is not set
+CONFIG_SENSORS_ASB100=m
+# CONFIG_SENSORS_ATXP1 is not set
+CONFIG_SENSORS_DS1621=m
+# CONFIG_SENSORS_F71805F is not set
+CONFIG_SENSORS_FSCHER=m
+# CONFIG_SENSORS_FSCPOS is not set
+CONFIG_SENSORS_GL518SM=m
+# CONFIG_SENSORS_GL520SM is not set
+CONFIG_SENSORS_IT87=m
+# CONFIG_SENSORS_LM63 is not set
+CONFIG_SENSORS_LM75=m
+CONFIG_SENSORS_LM77=m
+CONFIG_SENSORS_LM78=m
+CONFIG_SENSORS_LM80=m
+CONFIG_SENSORS_LM83=m
+CONFIG_SENSORS_LM85=m
+# CONFIG_SENSORS_LM87 is not set
+CONFIG_SENSORS_LM90=m
+# CONFIG_SENSORS_LM92 is not set
+CONFIG_SENSORS_MAX1619=m
+# CONFIG_SENSORS_PC87360 is not set
+CONFIG_SENSORS_SMSC47M1=m
+# CONFIG_SENSORS_SMSC47M192 is not set
+# CONFIG_SENSORS_SMSC47B397 is not set
+# CONFIG_SENSORS_VT1211 is not set
+CONFIG_SENSORS_W83781D=m
+# CONFIG_SENSORS_W83791D is not set
+# CONFIG_SENSORS_W83792D is not set
+CONFIG_SENSORS_W83L785TS=m
+CONFIG_SENSORS_W83627HF=m
+# CONFIG_SENSORS_W83627EHF is not set
+# CONFIG_HWMON_DEBUG_CHIP is not set
 
 #
-# Misc devices
+# Multimedia devices
 #
+CONFIG_VIDEO_DEV=m
+CONFIG_VIDEO_V4L1=y
+CONFIG_VIDEO_V4L1_COMPAT=y
+CONFIG_VIDEO_V4L2=y
 
 #
-# Multimedia Capabilities Port drivers
+# Video Capture Adapters
 #
 
 #
-# Multimedia devices
+# Video Capture Adapters
 #
-# CONFIG_VIDEO_DEV is not set
+# CONFIG_VIDEO_ADV_DEBUG is not set
+CONFIG_VIDEO_HELPER_CHIPS_AUTO=y
+# CONFIG_VIDEO_VIVI is not set
+# CONFIG_VIDEO_PMS is not set
+CONFIG_VIDEO_BWQCAM=m
+CONFIG_VIDEO_CQCAM=m
+# CONFIG_VIDEO_W9966 is not set
+# CONFIG_VIDEO_CPIA is not set
+# CONFIG_VIDEO_SAA5246A is not set
+# CONFIG_VIDEO_SAA5249 is not set
+# CONFIG_TUNER_3036 is not set
+# CONFIG_VIDEO_M32R_AR is not set
+
+#
+# Radio Adapters
+#
+# CONFIG_RADIO_CADET is not set
+# CONFIG_RADIO_RTRACK is not set
+# CONFIG_RADIO_RTRACK2 is not set
+# CONFIG_RADIO_AZTECH is not set
+# CONFIG_RADIO_GEMTEK is not set
+# CONFIG_RADIO_SF16FMI is not set
+# CONFIG_RADIO_SF16FMR2 is not set
+# CONFIG_RADIO_TERRATEC is not set
+# CONFIG_RADIO_TRUST is not set
+# CONFIG_RADIO_TYPHOON is not set
+# CONFIG_RADIO_ZOLTRIX is not set
 
 #
 # Digital Video Broadcasting Devices
@@ -434,8 +827,18 @@ CONFIG_SOFT_WATCHDOG=y
 #
 # Graphics support
 #
+CONFIG_FIRMWARE_EDID=y
 # CONFIG_FB is not set
 
+#
+# Console display driver support
+#
+CONFIG_VGA_CONSOLE=y
+# CONFIG_VGACON_SOFT_SCROLLBACK is not set
+# CONFIG_MDA_CONSOLE is not set
+CONFIG_DUMMY_CONSOLE=y
+# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
+
 #
 # Sound
 #
@@ -446,6 +849,11 @@ CONFIG_SOFT_WATCHDOG=y
 #
 # CONFIG_USB_ARCH_HAS_HCD is not set
 # CONFIG_USB_ARCH_HAS_OHCI is not set
+# CONFIG_USB_ARCH_HAS_EHCI is not set
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
+#
 
 #
 # USB Gadget Support
@@ -457,34 +865,70 @@ CONFIG_SOFT_WATCHDOG=y
 #
 # CONFIG_MMC is not set
 
+#
+# LED devices
+#
+# CONFIG_NEW_LEDS is not set
+
+#
+# LED drivers
+#
+
+#
+# LED Triggers
+#
+
 #
 # InfiniBand support
 #
 
 #
-# SN Devices
+# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
+#
+
+#
+# Real Time Clock
+#
+# CONFIG_RTC_CLASS is not set
+
+#
+# DMA Engine support
+#
+# CONFIG_DMA_ENGINE is not set
+
+#
+# DMA Clients
+#
+
+#
+# DMA Devices
 #
 
 #
 # File systems
 #
 CONFIG_EXT2_FS=y
-# CONFIG_EXT2_FS_XATTR is not set
-# CONFIG_EXT2_FS_XIP is not set
+CONFIG_EXT2_FS_XATTR=y
+CONFIG_EXT2_FS_POSIX_ACL=y
+CONFIG_EXT2_FS_SECURITY=y
 CONFIG_EXT3_FS=y
 CONFIG_EXT3_FS_XATTR=y
 CONFIG_EXT3_FS_POSIX_ACL=y
-# CONFIG_EXT3_FS_SECURITY is not set
+CONFIG_EXT3_FS_SECURITY=y
+# CONFIG_EXT4DEV_FS is not set
 CONFIG_JBD=y
-# CONFIG_JBD_DEBUG is not set
+CONFIG_JBD_DEBUG=y
 CONFIG_FS_MBCACHE=y
 # CONFIG_REISERFS_FS is not set
 # CONFIG_JFS_FS is not set
 CONFIG_FS_POSIX_ACL=y
 # CONFIG_XFS_FS is not set
+# CONFIG_GFS2_FS is not set
+# CONFIG_OCFS2_FS is not set
 # CONFIG_MINIX_FS is not set
-# CONFIG_ROMFS_FS is not set
-# CONFIG_INOTIFY is not set
+CONFIG_ROMFS_FS=y
+CONFIG_INOTIFY=y
+CONFIG_INOTIFY_USER=y
 # CONFIG_QUOTA is not set
 CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
@@ -494,8 +938,11 @@ CONFIG_DNOTIFY=y
 #
 # CD-ROM/DVD Filesystems
 #
-# CONFIG_ISO9660_FS is not set
-# CONFIG_UDF_FS is not set
+CONFIG_ISO9660_FS=y
+CONFIG_JOLIET=y
+# CONFIG_ZISOFS is not set
+CONFIG_UDF_FS=m
+CONFIG_UDF_NLS=y
 
 #
 # DOS/FAT/NT Filesystems
@@ -503,7 +950,7 @@ CONFIG_DNOTIFY=y
 CONFIG_FAT_FS=y
 CONFIG_MSDOS_FS=y
 CONFIG_VFAT_FS=y
-CONFIG_FAT_DEFAULT_CODEPAGE=932
+CONFIG_FAT_DEFAULT_CODEPAGE=437
 CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
 # CONFIG_NTFS_FS is not set
 
@@ -511,11 +958,13 @@ CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
 # Pseudo filesystems
 #
 CONFIG_PROC_FS=y
+CONFIG_PROC_SYSCTL=y
 CONFIG_SYSFS=y
 CONFIG_TMPFS=y
+# CONFIG_TMPFS_POSIX_ACL is not set
 # CONFIG_HUGETLB_PAGE is not set
 CONFIG_RAMFS=y
-# CONFIG_RELAYFS_FS is not set
+CONFIG_CONFIGFS_FS=m
 
 #
 # Miscellaneous filesystems
@@ -527,7 +976,7 @@ CONFIG_RAMFS=y
 # CONFIG_BEFS_FS is not set
 # CONFIG_BFS_FS is not set
 # CONFIG_EFS_FS is not set
-CONFIG_CRAMFS=y
+# CONFIG_CRAMFS is not set
 # CONFIG_VXFS_FS is not set
 # CONFIG_HPFS_FS is not set
 # CONFIG_QNX4FS_FS is not set
@@ -542,10 +991,14 @@ CONFIG_NFS_V3=y
 # CONFIG_NFS_V3_ACL is not set
 # CONFIG_NFS_V4 is not set
 # CONFIG_NFS_DIRECTIO is not set
-# CONFIG_NFSD is not set
-CONFIG_ROOT_NFS=y
+CONFIG_NFSD=m
+CONFIG_NFSD_V3=y
+# CONFIG_NFSD_V3_ACL is not set
+# CONFIG_NFSD_V4 is not set
+# CONFIG_NFSD_TCP is not set
 CONFIG_LOCKD=y
 CONFIG_LOCKD_V4=y
+CONFIG_EXPORTFS=m
 CONFIG_NFS_COMMON=y
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
@@ -567,7 +1020,7 @@ CONFIG_MSDOS_PARTITION=y
 # Native Language Support
 #
 CONFIG_NLS=y
-CONFIG_NLS_DEFAULT="iso8859-1"
+CONFIG_NLS_DEFAULT="cp437"
 CONFIG_NLS_CODEPAGE_437=y
 # CONFIG_NLS_CODEPAGE_737 is not set
 # CONFIG_NLS_CODEPAGE_775 is not set
@@ -592,7 +1045,7 @@ CONFIG_NLS_CODEPAGE_932=y
 # CONFIG_NLS_CODEPAGE_1250 is not set
 # CONFIG_NLS_CODEPAGE_1251 is not set
 # CONFIG_NLS_ASCII is not set
-# CONFIG_NLS_ISO8859_1 is not set
+CONFIG_NLS_ISO8859_1=y
 # CONFIG_NLS_ISO8859_2 is not set
 # CONFIG_NLS_ISO8859_3 is not set
 # CONFIG_NLS_ISO8859_4 is not set
@@ -605,32 +1058,28 @@ CONFIG_NLS_CODEPAGE_932=y
 # CONFIG_NLS_ISO8859_15 is not set
 # CONFIG_NLS_KOI8_R is not set
 # CONFIG_NLS_KOI8_U is not set
-CONFIG_NLS_UTF8=y
+# CONFIG_NLS_UTF8 is not set
 
 #
 # Profiling support
 #
-# CONFIG_PROFILING is not set
+CONFIG_PROFILING=y
+CONFIG_OPROFILE=m
 
 #
 # Kernel hacking
 #
 # CONFIG_PRINTK_TIME is not set
-CONFIG_DEBUG_KERNEL=y
-CONFIG_MAGIC_SYSRQ=y
+CONFIG_ENABLE_MUST_CHECK=y
+# CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_UNUSED_SYMBOLS is not set
+# CONFIG_DEBUG_KERNEL is not set
 CONFIG_LOG_BUF_SHIFT=14
-CONFIG_DETECT_SOFTLOCKUP=y
-# CONFIG_SCHEDSTATS is not set
-# CONFIG_DEBUG_SLAB is not set
-# CONFIG_DEBUG_SPINLOCK is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
-# CONFIG_DEBUG_KOBJECT is not set
-# CONFIG_DEBUG_BUGVERBOSE is not set
-CONFIG_DEBUG_INFO=y
+CONFIG_DEBUG_BUGVERBOSE=y
 # CONFIG_DEBUG_FS is not set
 # CONFIG_FRAME_POINTER is not set
-# CONFIG_DEBUG_STACKOVERFLOW is not set
-# CONFIG_DEBUG_STACK_USAGE is not set
+# CONFIG_UNWIND_INFO is not set
+# CONFIG_HEADERS_CHECK is not set
 
 #
 # Security options
@@ -641,7 +1090,38 @@ CONFIG_DEBUG_INFO=y
 #
 # Cryptographic options
 #
-# CONFIG_CRYPTO is not set
+CONFIG_CRYPTO=y
+CONFIG_CRYPTO_ALGAPI=y
+CONFIG_CRYPTO_BLKCIPHER=m
+CONFIG_CRYPTO_HASH=y
+CONFIG_CRYPTO_MANAGER=y
+CONFIG_CRYPTO_HMAC=y
+CONFIG_CRYPTO_NULL=m
+CONFIG_CRYPTO_MD4=m
+CONFIG_CRYPTO_MD5=m
+CONFIG_CRYPTO_SHA1=m
+CONFIG_CRYPTO_SHA256=m
+CONFIG_CRYPTO_SHA512=m
+CONFIG_CRYPTO_WP512=m
+# CONFIG_CRYPTO_TGR192 is not set
+CONFIG_CRYPTO_ECB=m
+CONFIG_CRYPTO_CBC=m
+CONFIG_CRYPTO_DES=m
+CONFIG_CRYPTO_BLOWFISH=m
+CONFIG_CRYPTO_TWOFISH=m
+CONFIG_CRYPTO_TWOFISH_COMMON=m
+CONFIG_CRYPTO_SERPENT=m
+CONFIG_CRYPTO_AES=m
+# CONFIG_CRYPTO_CAST5 is not set
+# CONFIG_CRYPTO_CAST6 is not set
+# CONFIG_CRYPTO_TEA is not set
+# CONFIG_CRYPTO_ARC4 is not set
+# CONFIG_CRYPTO_KHAZAD is not set
+# CONFIG_CRYPTO_ANUBIS is not set
+# CONFIG_CRYPTO_DEFLATE is not set
+# CONFIG_CRYPTO_MICHAEL_MIC is not set
+CONFIG_CRYPTO_CRC32C=m
+# CONFIG_CRYPTO_TEST is not set
 
 #
 # Hardware crypto devices
@@ -650,8 +1130,12 @@ CONFIG_DEBUG_INFO=y
 #
 # Library routines
 #
-# CONFIG_CRC_CCITT is not set
-# CONFIG_CRC16 is not set
+CONFIG_CRC_CCITT=m
+CONFIG_CRC16=m
 CONFIG_CRC32=y
-CONFIG_LIBCRC32C=y
-CONFIG_ZLIB_INFLATE=y
+CONFIG_LIBCRC32C=m
+CONFIG_TEXTSEARCH=y
+CONFIG_TEXTSEARCH_KMP=m
+CONFIG_TEXTSEARCH_BM=m
+CONFIG_TEXTSEARCH_FSM=m
+CONFIG_PLIST=y
index 3e607d90b5f45b71af6cd34a907ecece49c5ecc1..13579917afef09e621bdfbf6fd08e6393e90f174 100644 (file)
@@ -1,19 +1,18 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.12-rc5
-# Fri Jun  3 16:20:58 2005
+# Linux kernel version: 2.6.19
+# Tue Dec 12 17:52:38 2006
 #
 CONFIG_M32R=y
-# CONFIG_UID16 is not set
 CONFIG_GENERIC_ISA_DMA=y
 CONFIG_GENERIC_HARDIRQS=y
 CONFIG_GENERIC_IRQ_PROBE=y
+CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
 
 #
 # Code maturity level options
 #
 CONFIG_EXPERIMENTAL=y
-CONFIG_CLEAN_COMPILE=y
 CONFIG_LOCK_KERNEL=y
 CONFIG_INIT_ENV_ARG_LIMIT=32
 
@@ -21,33 +20,40 @@ CONFIG_INIT_ENV_ARG_LIMIT=32
 # General setup
 #
 CONFIG_LOCALVERSION=""
+CONFIG_LOCALVERSION_AUTO=y
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
+# CONFIG_IPC_NS is not set
 # CONFIG_POSIX_MQUEUE is not set
 CONFIG_BSD_PROCESS_ACCT=y
 # CONFIG_BSD_PROCESS_ACCT_V3 is not set
-CONFIG_SYSCTL=y
+# CONFIG_TASKSTATS is not set
+# CONFIG_UTS_NS is not set
 # CONFIG_AUDIT is not set
-CONFIG_HOTPLUG=y
-CONFIG_KOBJECT_UEVENT=y
 CONFIG_IKCONFIG=y
-# CONFIG_IKCONFIG_PROC is not set
+CONFIG_IKCONFIG_PROC=y
 # CONFIG_CPUSETS is not set
+CONFIG_SYSFS_DEPRECATED=y
+# CONFIG_RELAY is not set
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SYSCTL=y
 CONFIG_EMBEDDED=y
+CONFIG_SYSCTL_SYSCALL=y
 # CONFIG_KALLSYMS is not set
+CONFIG_HOTPLUG=y
 CONFIG_PRINTK=y
 CONFIG_BUG=y
+CONFIG_ELF_CORE=y
 CONFIG_BASE_FULL=y
 # CONFIG_FUTEX is not set
 # CONFIG_EPOLL is not set
-# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
 CONFIG_SHMEM=y
-CONFIG_CC_ALIGN_FUNCTIONS=0
-CONFIG_CC_ALIGN_LABELS=0
-CONFIG_CC_ALIGN_LOOPS=0
-CONFIG_CC_ALIGN_JUMPS=0
+CONFIG_SLAB=y
+CONFIG_VM_EVENT_COUNTERS=y
 # CONFIG_TINY_SHMEM is not set
 CONFIG_BASE_SMALL=0
+# CONFIG_SLOB is not set
 
 #
 # Loadable module support
@@ -55,12 +61,30 @@ CONFIG_BASE_SMALL=0
 CONFIG_MODULES=y
 CONFIG_MODULE_UNLOAD=y
 # CONFIG_MODULE_FORCE_UNLOAD is not set
-CONFIG_OBSOLETE_MODPARM=y
 # CONFIG_MODVERSIONS is not set
 # CONFIG_MODULE_SRCVERSION_ALL is not set
 CONFIG_KMOD=y
 CONFIG_STOP_MACHINE=y
 
+#
+# Block layer
+#
+CONFIG_BLOCK=y
+# CONFIG_BLK_DEV_IO_TRACE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+# CONFIG_IOSCHED_AS is not set
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+# CONFIG_DEFAULT_AS is not set
+# CONFIG_DEFAULT_DEADLINE is not set
+CONFIG_DEFAULT_CFQ=y
+# CONFIG_DEFAULT_NOOP is not set
+CONFIG_DEFAULT_IOSCHED="cfq"
+
 #
 # Processor type and features
 #
@@ -71,8 +95,10 @@ CONFIG_PLAT_M32700UT=y
 # CONFIG_PLAT_OAKS32R is not set
 # CONFIG_PLAT_MAPPI2 is not set
 # CONFIG_PLAT_MAPPI3 is not set
+# CONFIG_PLAT_M32104UT is not set
 CONFIG_CHIP_M32700=y
 # CONFIG_CHIP_M32102 is not set
+# CONFIG_CHIP_M32104 is not set
 # CONFIG_CHIP_VDEC2 is not set
 # CONFIG_CHIP_OPSP is not set
 CONFIG_MMU=y
@@ -86,37 +112,39 @@ CONFIG_TIMER_DIVIDE=128
 CONFIG_MEMORY_START=0x08000000
 CONFIG_MEMORY_SIZE=0x01000000
 CONFIG_NOHIGHMEM=y
-# CONFIG_DISCONTIGMEM is not set
+CONFIG_ARCH_DISCONTIGMEM_ENABLE=y
+CONFIG_SELECT_MEMORY_MODEL=y
+# CONFIG_FLATMEM_MANUAL is not set
+CONFIG_DISCONTIGMEM_MANUAL=y
+# CONFIG_SPARSEMEM_MANUAL is not set
+CONFIG_DISCONTIGMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
+CONFIG_NEED_MULTIPLE_NODES=y
+# CONFIG_SPARSEMEM_STATIC is not set
+CONFIG_SPLIT_PTLOCK_CPUS=4
+# CONFIG_RESOURCES_64BIT is not set
+CONFIG_IRAM_START=0x00f00000
+CONFIG_IRAM_SIZE=0x00080000
 CONFIG_RWSEM_GENERIC_SPINLOCK=y
 # CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
+CONFIG_GENERIC_FIND_NEXT_BIT=y
+CONFIG_GENERIC_HWEIGHT=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_PREEMPT=y
-# CONFIG_HAVE_DEC_LOCK is not set
 CONFIG_SMP=y
-CONFIG_CHIP_M32700_TS1=y
+# CONFIG_CHIP_M32700_TS1 is not set
 CONFIG_NR_CPUS=2
-# CONFIG_NUMA is not set
+CONFIG_NODES_SHIFT=1
 
 #
 # Bus options (PCI, PCMCIA, EISA, MCA, ISA)
 #
-# CONFIG_PCI is not set
 # CONFIG_ISA is not set
 
 #
 # PCCARD (PCMCIA/CardBus) support
 #
-CONFIG_PCCARD=y
-# CONFIG_PCMCIA_DEBUG is not set
-CONFIG_PCMCIA=y
-
-#
-# PC-card bridges
-#
-# CONFIG_TCIC is not set
-# CONFIG_M32R_PCC is not set
-CONFIG_M32R_CFC=y
-CONFIG_M32R_CFC_NUM=1
+# CONFIG_PCCARD is not set
 
 #
 # PCI Hotplug Support
@@ -128,6 +156,94 @@ CONFIG_M32R_CFC_NUM=1
 CONFIG_BINFMT_ELF=y
 # CONFIG_BINFMT_MISC is not set
 
+#
+# Networking
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+# CONFIG_NETDEBUG is not set
+CONFIG_PACKET=y
+# CONFIG_PACKET_MMAP is not set
+CONFIG_UNIX=y
+CONFIG_XFRM=y
+# CONFIG_XFRM_USER is not set
+# CONFIG_XFRM_SUB_POLICY is not set
+# CONFIG_NET_KEY is not set
+CONFIG_INET=y
+# CONFIG_IP_MULTICAST is not set
+# CONFIG_IP_ADVANCED_ROUTER is not set
+CONFIG_IP_FIB_HASH=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+# CONFIG_IP_PNP_BOOTP is not set
+# CONFIG_IP_PNP_RARP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_ARPD is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_XFRM_TUNNEL is not set
+# CONFIG_INET_TUNNEL is not set
+CONFIG_INET_XFRM_MODE_TRANSPORT=y
+CONFIG_INET_XFRM_MODE_TUNNEL=y
+CONFIG_INET_XFRM_MODE_BEET=y
+CONFIG_INET_DIAG=y
+CONFIG_INET_TCP_DIAG=y
+# CONFIG_TCP_CONG_ADVANCED is not set
+CONFIG_TCP_CONG_CUBIC=y
+CONFIG_DEFAULT_TCP_CONG="cubic"
+# CONFIG_TCP_MD5SIG is not set
+# CONFIG_IPV6 is not set
+# CONFIG_INET6_XFRM_TUNNEL is not set
+# CONFIG_INET6_TUNNEL is not set
+# CONFIG_NETWORK_SECMARK is not set
+# CONFIG_NETFILTER is not set
+
+#
+# DCCP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_DCCP is not set
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_SCTP is not set
+
+#
+# TIPC Configuration (EXPERIMENTAL)
+#
+# CONFIG_TIPC is not set
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+# CONFIG_IEEE80211 is not set
+
 #
 # Device Drivers
 #
@@ -137,12 +253,100 @@ CONFIG_BINFMT_ELF=y
 #
 CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
-# CONFIG_FW_LOADER is not set
+CONFIG_FW_LOADER=y
+# CONFIG_SYS_HYPERVISOR is not set
+
+#
+# Connector - unified userspace <-> kernelspace linker
+#
+# CONFIG_CONNECTOR is not set
 
 #
 # Memory Technology Devices (MTD)
 #
-# CONFIG_MTD is not set
+CONFIG_MTD=y
+# CONFIG_MTD_DEBUG is not set
+# CONFIG_MTD_CONCAT is not set
+CONFIG_MTD_PARTITIONS=y
+CONFIG_MTD_REDBOOT_PARTS=y
+CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-1
+# CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED is not set
+# CONFIG_MTD_REDBOOT_PARTS_READONLY is not set
+# CONFIG_MTD_CMDLINE_PARTS is not set
+
+#
+# User Modules And Translation Layers
+#
+# CONFIG_MTD_CHAR is not set
+CONFIG_MTD_BLOCK=y
+# CONFIG_FTL is not set
+# CONFIG_NFTL is not set
+# CONFIG_INFTL is not set
+# CONFIG_RFD_FTL is not set
+# CONFIG_SSFDC is not set
+
+#
+# RAM/ROM/Flash chip drivers
+#
+CONFIG_MTD_CFI=m
+CONFIG_MTD_JEDECPROBE=m
+CONFIG_MTD_GEN_PROBE=m
+CONFIG_MTD_CFI_ADV_OPTIONS=y
+# CONFIG_MTD_CFI_NOSWAP is not set
+CONFIG_MTD_CFI_BE_BYTE_SWAP=y
+# CONFIG_MTD_CFI_LE_BYTE_SWAP is not set
+CONFIG_MTD_CFI_GEOMETRY=y
+CONFIG_MTD_MAP_BANK_WIDTH_1=y
+CONFIG_MTD_MAP_BANK_WIDTH_2=y
+CONFIG_MTD_MAP_BANK_WIDTH_4=y
+# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
+CONFIG_MTD_CFI_I1=y
+# CONFIG_MTD_CFI_I2 is not set
+# CONFIG_MTD_CFI_I4 is not set
+# CONFIG_MTD_CFI_I8 is not set
+# CONFIG_MTD_OTP is not set
+# CONFIG_MTD_CFI_INTELEXT is not set
+CONFIG_MTD_CFI_AMDSTD=m
+# CONFIG_MTD_CFI_STAA is not set
+CONFIG_MTD_CFI_UTIL=m
+# CONFIG_MTD_RAM is not set
+# CONFIG_MTD_ROM is not set
+# CONFIG_MTD_ABSENT is not set
+# CONFIG_MTD_OBSOLETE_CHIPS is not set
+
+#
+# Mapping drivers for chip access
+#
+# CONFIG_MTD_COMPLEX_MAPPINGS is not set
+# CONFIG_MTD_PHYSMAP is not set
+# CONFIG_MTD_PLATRAM is not set
+
+#
+# Self-contained MTD device drivers
+#
+# CONFIG_MTD_SLRAM is not set
+# CONFIG_MTD_PHRAM is not set
+# CONFIG_MTD_MTDRAM is not set
+# CONFIG_MTD_BLOCK2MTD is not set
+
+#
+# Disk-On-Chip Device Drivers
+#
+# CONFIG_MTD_DOC2000 is not set
+# CONFIG_MTD_DOC2001 is not set
+# CONFIG_MTD_DOC2001PLUS is not set
+
+#
+# NAND Flash Device Drivers
+#
+# CONFIG_MTD_NAND is not set
+
+#
+# OneNAND Flash Device Drivers
+#
+# CONFIG_MTD_ONENAND is not set
 
 #
 # Parallel port support
@@ -156,7 +360,6 @@ CONFIG_PREVENT_FIRMWARE_BUILD=y
 #
 # Block devices
 #
-# CONFIG_BLK_DEV_FD is not set
 # CONFIG_BLK_DEV_COW_COMMON is not set
 CONFIG_BLK_DEV_LOOP=y
 # CONFIG_BLK_DEV_CRYPTOLOOP is not set
@@ -164,23 +367,21 @@ CONFIG_BLK_DEV_NBD=y
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_COUNT=16
 CONFIG_BLK_DEV_RAM_SIZE=4096
+CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
 # CONFIG_BLK_DEV_INITRD is not set
-CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_CDROM_PKTCDVD is not set
+CONFIG_ATA_OVER_ETH=m
 
 #
-# IO Schedulers
+# Misc devices
 #
-CONFIG_IOSCHED_NOOP=y
-# CONFIG_IOSCHED_AS is not set
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
-# CONFIG_ATA_OVER_ETH is not set
+# CONFIG_TIFM_CORE is not set
 
 #
 # ATA/ATAPI/MFM/RLL support
 #
 CONFIG_IDE=y
+CONFIG_IDE_MAX_HWIFS=4
 CONFIG_BLK_DEV_IDE=y
 
 #
@@ -189,7 +390,6 @@ CONFIG_BLK_DEV_IDE=y
 # CONFIG_BLK_DEV_IDE_SATA is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-CONFIG_BLK_DEV_IDECS=y
 CONFIG_BLK_DEV_IDECD=m
 # CONFIG_BLK_DEV_IDETAPE is not set
 # CONFIG_BLK_DEV_IDEFLOPPY is not set
@@ -208,7 +408,9 @@ CONFIG_IDE_GENERIC=y
 #
 # SCSI device support
 #
+# CONFIG_RAID_ATTRS is not set
 CONFIG_SCSI=m
+# CONFIG_SCSI_NETLINK is not set
 CONFIG_SCSI_PROC_FS=y
 
 #
@@ -220,6 +422,7 @@ CONFIG_BLK_DEV_SD=m
 CONFIG_BLK_DEV_SR=m
 # CONFIG_BLK_DEV_SR_VENDOR is not set
 CONFIG_CHR_DEV_SG=m
+# CONFIG_CHR_DEV_SCH is not set
 
 #
 # Some SCSI devices (e.g. CD jukebox) support multiple LUNs
@@ -229,26 +432,23 @@ CONFIG_SCSI_MULTI_LUN=y
 # CONFIG_SCSI_LOGGING is not set
 
 #
-# SCSI Transport Attributes
+# SCSI Transports
 #
 # CONFIG_SCSI_SPI_ATTRS is not set
 # CONFIG_SCSI_FC_ATTRS is not set
 # CONFIG_SCSI_ISCSI_ATTRS is not set
+# CONFIG_SCSI_SAS_ATTRS is not set
+# CONFIG_SCSI_SAS_LIBSAS is not set
 
 #
 # SCSI low-level drivers
 #
-# CONFIG_SCSI_SATA is not set
+# CONFIG_ISCSI_TCP is not set
 # CONFIG_SCSI_DEBUG is not set
 
 #
-# PCMCIA SCSI adapter support
+# Serial ATA (prod) and Parallel ATA (experimental) drivers
 #
-# CONFIG_PCMCIA_AHA152X is not set
-# CONFIG_PCMCIA_FDOMAIN is not set
-# CONFIG_PCMCIA_NINJA_SCSI is not set
-# CONFIG_PCMCIA_QLOGIC is not set
-# CONFIG_PCMCIA_SYM53C500 is not set
 
 #
 # Multi-device support (RAID and LVM)
@@ -258,6 +458,7 @@ CONFIG_SCSI_MULTI_LUN=y
 #
 # Fusion MPT device support
 #
+# CONFIG_FUSION is not set
 
 #
 # IEEE 1394 (FireWire) support
@@ -268,75 +469,19 @@ CONFIG_SCSI_MULTI_LUN=y
 #
 
 #
-# Networking support
-#
-CONFIG_NET=y
-
-#
-# Networking options
-#
-CONFIG_PACKET=y
-# CONFIG_PACKET_MMAP is not set
-CONFIG_UNIX=y
-# CONFIG_NET_KEY is not set
-CONFIG_INET=y
-# CONFIG_IP_MULTICAST is not set
-# CONFIG_IP_ADVANCED_ROUTER is not set
-CONFIG_IP_PNP=y
-CONFIG_IP_PNP_DHCP=y
-# CONFIG_IP_PNP_BOOTP is not set
-# CONFIG_IP_PNP_RARP is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_ARPD is not set
-# CONFIG_SYN_COOKIES is not set
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-# CONFIG_INET_TUNNEL is not set
-CONFIG_IP_TCPDIAG=y
-# CONFIG_IP_TCPDIAG_IPV6 is not set
-# CONFIG_IPV6 is not set
-# CONFIG_NETFILTER is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_DECNET is not set
-# CONFIG_LLC2 is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-# CONFIG_NET_CLS_ROUTE is not set
-
-#
-# Network testing
+# Network device support
 #
-# CONFIG_NET_PKTGEN is not set
-# CONFIG_NETPOLL is not set
-# CONFIG_NET_POLL_CONTROLLER is not set
-# CONFIG_HAMRADIO is not set
-# CONFIG_IRDA is not set
-# CONFIG_BT is not set
 CONFIG_NETDEVICES=y
 # CONFIG_DUMMY is not set
 # CONFIG_BONDING is not set
 # CONFIG_EQUALIZER is not set
 # CONFIG_TUN is not set
 
+#
+# PHY device support
+#
+# CONFIG_PHYLIB is not set
+
 #
 # Ethernet (10 or 100Mbit)
 #
@@ -362,11 +507,6 @@ CONFIG_SMC91X=y
 #
 # CONFIG_NET_RADIO is not set
 
-#
-# PCMCIA network device support
-#
-# CONFIG_NET_PCMCIA is not set
-
 #
 # Wan interfaces
 #
@@ -375,6 +515,8 @@ CONFIG_SMC91X=y
 # CONFIG_SLIP is not set
 # CONFIG_SHAPER is not set
 # CONFIG_NETCONSOLE is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
 
 #
 # ISDN subsystem
@@ -390,6 +532,7 @@ CONFIG_SMC91X=y
 # Input device support
 #
 CONFIG_INPUT=y
+# CONFIG_INPUT_FF_MEMLESS is not set
 
 #
 # Userland interfaces
@@ -418,7 +561,6 @@ CONFIG_SERIO_SERPORT=y
 # CONFIG_SERIO_LIBPS2 is not set
 # CONFIG_SERIO_RAW is not set
 # CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
 
 #
 # Character devices
@@ -426,6 +568,7 @@ CONFIG_SOUND_GAMEPORT=y
 CONFIG_VT=y
 CONFIG_VT_CONSOLE=y
 CONFIG_HW_CONSOLE=y
+# CONFIG_VT_HW_CONSOLE_BINDING is not set
 # CONFIG_SERIAL_NONSTANDARD is not set
 
 #
@@ -454,8 +597,8 @@ CONFIG_LEGACY_PTY_COUNT=256
 # Watchdog Cards
 #
 # CONFIG_WATCHDOG is not set
+CONFIG_HW_RANDOM=y
 # CONFIG_RTC is not set
-# CONFIG_GEN_RTC is not set
 CONFIG_DS1302=y
 # CONFIG_DTLK is not set
 # CONFIG_R3964 is not set
@@ -463,52 +606,64 @@ CONFIG_DS1302=y
 #
 # Ftape, the floppy tape device driver
 #
-# CONFIG_DRM is not set
-
-#
-# PCMCIA character devices
-#
-# CONFIG_SYNCLINK_CS is not set
 # CONFIG_RAW_DRIVER is not set
 
 #
 # TPM devices
 #
+# CONFIG_TCG_TPM is not set
 
 #
 # I2C support
 #
 # CONFIG_I2C is not set
 
+#
+# SPI support
+#
+# CONFIG_SPI is not set
+# CONFIG_SPI_MASTER is not set
+
 #
 # Dallas's 1-wire bus
 #
 # CONFIG_W1 is not set
 
 #
-# Misc devices
+# Hardware Monitoring support
 #
+CONFIG_HWMON=y
+# CONFIG_HWMON_VID is not set
+# CONFIG_SENSORS_ABITUGURU is not set
+# CONFIG_SENSORS_F71805F is not set
+# CONFIG_SENSORS_VT1211 is not set
+# CONFIG_HWMON_DEBUG_CHIP is not set
 
 #
 # Multimedia devices
 #
-CONFIG_VIDEO_DEV=y
+CONFIG_VIDEO_DEV=m
+CONFIG_VIDEO_V4L1=y
+CONFIG_VIDEO_V4L1_COMPAT=y
+CONFIG_VIDEO_V4L2=y
 
 #
-# Video For Linux
+# Video Capture Adapters
 #
 
 #
-# Video Adapters
+# Video Capture Adapters
 #
+# CONFIG_VIDEO_ADV_DEBUG is not set
+CONFIG_VIDEO_HELPER_CHIPS_AUTO=y
+# CONFIG_VIDEO_VIVI is not set
 # CONFIG_VIDEO_CPIA is not set
-CONFIG_VIDEO_M32R_AR=y
-CONFIG_VIDEO_M32R_AR_M64278=y
+CONFIG_VIDEO_M32R_AR=m
+CONFIG_VIDEO_M32R_AR_M64278=m
 
 #
 # Radio Adapters
 #
-# CONFIG_RADIO_MAESTRO is not set
 
 #
 # Digital Video Broadcasting Devices
@@ -518,15 +673,16 @@ CONFIG_VIDEO_M32R_AR_M64278=y
 #
 # Graphics support
 #
+CONFIG_FIRMWARE_EDID=y
 CONFIG_FB=y
-# CONFIG_FB_CFB_FILLRECT is not set
-# CONFIG_FB_CFB_COPYAREA is not set
-# CONFIG_FB_CFB_IMAGEBLIT is not set
-# CONFIG_FB_SOFT_CURSOR is not set
+CONFIG_FB_CFB_FILLRECT=y
+CONFIG_FB_CFB_COPYAREA=y
+CONFIG_FB_CFB_IMAGEBLIT=y
 # CONFIG_FB_MACMODES is not set
+# CONFIG_FB_BACKLIGHT is not set
 # CONFIG_FB_MODE_HELPERS is not set
 # CONFIG_FB_TILEBLITTING is not set
-# CONFIG_FB_S1D13XXX is not set
+CONFIG_FB_S1D13XXX=y
 # CONFIG_FB_VIRTUAL is not set
 
 #
@@ -535,6 +691,7 @@ CONFIG_FB=y
 # CONFIG_VGA_CONSOLE is not set
 CONFIG_DUMMY_CONSOLE=y
 CONFIG_FRAMEBUFFER_CONSOLE=y
+# CONFIG_FRAMEBUFFER_CONSOLE_ROTATION is not set
 # CONFIG_FONTS is not set
 CONFIG_FONT_8x8=y
 CONFIG_FONT_8x16=y
@@ -546,6 +703,7 @@ CONFIG_LOGO=y
 CONFIG_LOGO_LINUX_MONO=y
 CONFIG_LOGO_LINUX_VGA16=y
 CONFIG_LOGO_LINUX_CLUT224=y
+CONFIG_LOGO_M32R_CLUT224=y
 # CONFIG_BACKLIGHT_LCD_SUPPORT is not set
 
 #
@@ -558,6 +716,11 @@ CONFIG_LOGO_LINUX_CLUT224=y
 #
 # CONFIG_USB_ARCH_HAS_HCD is not set
 # CONFIG_USB_ARCH_HAS_OHCI is not set
+# CONFIG_USB_ARCH_HAS_EHCI is not set
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
+#
 
 #
 # USB Gadget Support
@@ -567,23 +730,62 @@ CONFIG_LOGO_LINUX_CLUT224=y
 #
 # MMC/SD Card support
 #
-# CONFIG_MMC is not set
+CONFIG_MMC=y
+CONFIG_MMC_DEBUG=y
+CONFIG_MMC_BLOCK=y
+# CONFIG_MMC_TIFM_SD is not set
+
+#
+# LED devices
+#
+# CONFIG_NEW_LEDS is not set
+
+#
+# LED drivers
+#
+
+#
+# LED Triggers
+#
 
 #
 # InfiniBand support
 #
-# CONFIG_INFINIBAND is not set
+
+#
+# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
+#
+
+#
+# Real Time Clock
+#
+# CONFIG_RTC_CLASS is not set
+
+#
+# DMA Engine support
+#
+# CONFIG_DMA_ENGINE is not set
+
+#
+# DMA Clients
+#
+
+#
+# DMA Devices
+#
 
 #
 # File systems
 #
 CONFIG_EXT2_FS=y
 # CONFIG_EXT2_FS_XATTR is not set
-CONFIG_EXT3_FS=m
+# CONFIG_EXT2_FS_XIP is not set
+CONFIG_EXT3_FS=y
 CONFIG_EXT3_FS_XATTR=y
 # CONFIG_EXT3_FS_POSIX_ACL is not set
 # CONFIG_EXT3_FS_SECURITY is not set
-CONFIG_JBD=m
+# CONFIG_EXT4DEV_FS is not set
+CONFIG_JBD=y
 CONFIG_JBD_DEBUG=y
 CONFIG_FS_MBCACHE=y
 CONFIG_REISERFS_FS=m
@@ -591,17 +793,19 @@ CONFIG_REISERFS_FS=m
 # CONFIG_REISERFS_PROC_INFO is not set
 # CONFIG_REISERFS_FS_XATTR is not set
 # CONFIG_JFS_FS is not set
-
-#
-# XFS support
-#
+# CONFIG_FS_POSIX_ACL is not set
 # CONFIG_XFS_FS is not set
+# CONFIG_GFS2_FS is not set
+# CONFIG_OCFS2_FS is not set
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
+CONFIG_INOTIFY=y
+CONFIG_INOTIFY_USER=y
 # CONFIG_QUOTA is not set
 CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
+# CONFIG_FUSE_FS is not set
 
 #
 # CD-ROM/DVD Filesystems
@@ -627,15 +831,13 @@ CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
 #
 CONFIG_PROC_FS=y
 CONFIG_PROC_KCORE=y
+CONFIG_PROC_SYSCTL=y
 CONFIG_SYSFS=y
-CONFIG_DEVFS_FS=y
-CONFIG_DEVFS_MOUNT=y
-# CONFIG_DEVFS_DEBUG is not set
-# CONFIG_DEVPTS_FS_XATTR is not set
 CONFIG_TMPFS=y
-# CONFIG_TMPFS_XATTR is not set
+# CONFIG_TMPFS_POSIX_ACL is not set
 # CONFIG_HUGETLB_PAGE is not set
 CONFIG_RAMFS=y
+# CONFIG_CONFIGFS_FS is not set
 
 #
 # Miscellaneous filesystems
@@ -647,6 +849,8 @@ CONFIG_RAMFS=y
 # CONFIG_BEFS_FS is not set
 # CONFIG_BFS_FS is not set
 # CONFIG_EFS_FS is not set
+# CONFIG_JFFS_FS is not set
+# CONFIG_JFFS2_FS is not set
 # CONFIG_CRAMFS is not set
 # CONFIG_VXFS_FS is not set
 # CONFIG_HPFS_FS is not set
@@ -659,12 +863,14 @@ CONFIG_RAMFS=y
 #
 CONFIG_NFS_FS=y
 CONFIG_NFS_V3=y
+# CONFIG_NFS_V3_ACL is not set
 # CONFIG_NFS_V4 is not set
 # CONFIG_NFS_DIRECTIO is not set
 # CONFIG_NFSD is not set
 CONFIG_ROOT_NFS=y
 CONFIG_LOCKD=y
 CONFIG_LOCKD_V4=y
+CONFIG_NFS_COMMON=y
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
 # CONFIG_RPCSEC_GSS_SPKM3 is not set
@@ -673,6 +879,7 @@ CONFIG_SUNRPC=y
 # CONFIG_NCP_FS is not set
 # CONFIG_CODA_FS is not set
 # CONFIG_AFS_FS is not set
+# CONFIG_9P_FS is not set
 
 #
 # Partition Types
@@ -727,16 +934,23 @@ CONFIG_NLS_DEFAULT="iso8859-1"
 #
 # Profiling support
 #
-# CONFIG_PROFILING is not set
+CONFIG_PROFILING=y
+CONFIG_OPROFILE=y
 
 #
 # Kernel hacking
 #
 # CONFIG_PRINTK_TIME is not set
+CONFIG_ENABLE_MUST_CHECK=y
+# CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_UNUSED_SYMBOLS is not set
 # CONFIG_DEBUG_KERNEL is not set
 CONFIG_LOG_BUF_SHIFT=15
 # CONFIG_DEBUG_BUGVERBOSE is not set
+# CONFIG_DEBUG_FS is not set
 # CONFIG_FRAME_POINTER is not set
+# CONFIG_UNWIND_INFO is not set
+# CONFIG_HEADERS_CHECK is not set
 
 #
 # Security options
@@ -749,13 +963,10 @@ CONFIG_LOG_BUF_SHIFT=15
 #
 # CONFIG_CRYPTO is not set
 
-#
-# Hardware crypto devices
-#
-
 #
 # Library routines
 #
 # CONFIG_CRC_CCITT is not set
+# CONFIG_CRC16 is not set
 CONFIG_CRC32=y
 # CONFIG_LIBCRC32C is not set
index 2d3e7cda8f461e5f8a35a51e61f6ada8a006268e..190f961d33e2b4baf77f4d059b96e6a77febbb66 100644 (file)
@@ -1,19 +1,18 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.12-rc5
-# Fri Jun  3 16:21:34 2005
+# Linux kernel version: 2.6.19
+# Tue Dec 12 12:07:08 2006
 #
 CONFIG_M32R=y
-# CONFIG_UID16 is not set
 CONFIG_GENERIC_ISA_DMA=y
 CONFIG_GENERIC_HARDIRQS=y
 CONFIG_GENERIC_IRQ_PROBE=y
+CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
 
 #
 # Code maturity level options
 #
 CONFIG_EXPERIMENTAL=y
-CONFIG_CLEAN_COMPILE=y
 CONFIG_BROKEN_ON_SMP=y
 CONFIG_LOCK_KERNEL=y
 CONFIG_INIT_ENV_ARG_LIMIT=32
@@ -22,32 +21,39 @@ CONFIG_INIT_ENV_ARG_LIMIT=32
 # General setup
 #
 CONFIG_LOCALVERSION=""
+CONFIG_LOCALVERSION_AUTO=y
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
+# CONFIG_IPC_NS is not set
 # CONFIG_POSIX_MQUEUE is not set
 CONFIG_BSD_PROCESS_ACCT=y
 # CONFIG_BSD_PROCESS_ACCT_V3 is not set
-CONFIG_SYSCTL=y
+# CONFIG_TASKSTATS is not set
+# CONFIG_UTS_NS is not set
 # CONFIG_AUDIT is not set
-CONFIG_HOTPLUG=y
-CONFIG_KOBJECT_UEVENT=y
 CONFIG_IKCONFIG=y
-# CONFIG_IKCONFIG_PROC is not set
+CONFIG_IKCONFIG_PROC=y
+CONFIG_SYSFS_DEPRECATED=y
+# CONFIG_RELAY is not set
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SYSCTL=y
 CONFIG_EMBEDDED=y
+CONFIG_SYSCTL_SYSCALL=y
 # CONFIG_KALLSYMS is not set
+CONFIG_HOTPLUG=y
 CONFIG_PRINTK=y
 CONFIG_BUG=y
+CONFIG_ELF_CORE=y
 CONFIG_BASE_FULL=y
 # CONFIG_FUTEX is not set
 # CONFIG_EPOLL is not set
-# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
 CONFIG_SHMEM=y
-CONFIG_CC_ALIGN_FUNCTIONS=0
-CONFIG_CC_ALIGN_LABELS=0
-CONFIG_CC_ALIGN_LOOPS=0
-CONFIG_CC_ALIGN_JUMPS=0
+CONFIG_SLAB=y
+CONFIG_VM_EVENT_COUNTERS=y
 # CONFIG_TINY_SHMEM is not set
 CONFIG_BASE_SMALL=0
+# CONFIG_SLOB is not set
 
 #
 # Loadable module support
@@ -55,11 +61,29 @@ CONFIG_BASE_SMALL=0
 CONFIG_MODULES=y
 CONFIG_MODULE_UNLOAD=y
 # CONFIG_MODULE_FORCE_UNLOAD is not set
-CONFIG_OBSOLETE_MODPARM=y
 # CONFIG_MODVERSIONS is not set
 # CONFIG_MODULE_SRCVERSION_ALL is not set
 CONFIG_KMOD=y
 
+#
+# Block layer
+#
+CONFIG_BLOCK=y
+# CONFIG_BLK_DEV_IO_TRACE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+# CONFIG_IOSCHED_AS is not set
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+# CONFIG_DEFAULT_AS is not set
+# CONFIG_DEFAULT_DEADLINE is not set
+CONFIG_DEFAULT_CFQ=y
+# CONFIG_DEFAULT_NOOP is not set
+CONFIG_DEFAULT_IOSCHED="cfq"
+
 #
 # Processor type and features
 #
@@ -70,8 +94,10 @@ CONFIG_PLAT_M32700UT=y
 # CONFIG_PLAT_OAKS32R is not set
 # CONFIG_PLAT_MAPPI2 is not set
 # CONFIG_PLAT_MAPPI3 is not set
+# CONFIG_PLAT_M32104UT is not set
 CONFIG_CHIP_M32700=y
 # CONFIG_CHIP_M32102 is not set
+# CONFIG_CHIP_M32104 is not set
 # CONFIG_CHIP_VDEC2 is not set
 # CONFIG_CHIP_OPSP is not set
 CONFIG_MMU=y
@@ -85,34 +111,37 @@ CONFIG_TIMER_DIVIDE=128
 CONFIG_MEMORY_START=0x08000000
 CONFIG_MEMORY_SIZE=0x01000000
 CONFIG_NOHIGHMEM=y
-# CONFIG_DISCONTIGMEM is not set
+CONFIG_ARCH_DISCONTIGMEM_ENABLE=y
+CONFIG_SELECT_MEMORY_MODEL=y
+# CONFIG_FLATMEM_MANUAL is not set
+CONFIG_DISCONTIGMEM_MANUAL=y
+# CONFIG_SPARSEMEM_MANUAL is not set
+CONFIG_DISCONTIGMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
+CONFIG_NEED_MULTIPLE_NODES=y
+# CONFIG_SPARSEMEM_STATIC is not set
+CONFIG_SPLIT_PTLOCK_CPUS=4
+# CONFIG_RESOURCES_64BIT is not set
+CONFIG_IRAM_START=0x00f00000
+CONFIG_IRAM_SIZE=0x00080000
 CONFIG_RWSEM_GENERIC_SPINLOCK=y
 # CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
+CONFIG_GENERIC_FIND_NEXT_BIT=y
+CONFIG_GENERIC_HWEIGHT=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_PREEMPT=y
-# CONFIG_HAVE_DEC_LOCK is not set
 # CONFIG_SMP is not set
+CONFIG_NODES_SHIFT=1
 
 #
 # Bus options (PCI, PCMCIA, EISA, MCA, ISA)
 #
-# CONFIG_PCI is not set
 # CONFIG_ISA is not set
 
 #
 # PCCARD (PCMCIA/CardBus) support
 #
-CONFIG_PCCARD=y
-# CONFIG_PCMCIA_DEBUG is not set
-CONFIG_PCMCIA=y
-
-#
-# PC-card bridges
-#
-# CONFIG_TCIC is not set
-# CONFIG_M32R_PCC is not set
-CONFIG_M32R_CFC=y
-CONFIG_M32R_CFC_NUM=1
+# CONFIG_PCCARD is not set
 
 #
 # PCI Hotplug Support
@@ -124,6 +153,94 @@ CONFIG_M32R_CFC_NUM=1
 CONFIG_BINFMT_ELF=y
 # CONFIG_BINFMT_MISC is not set
 
+#
+# Networking
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+# CONFIG_NETDEBUG is not set
+CONFIG_PACKET=y
+# CONFIG_PACKET_MMAP is not set
+CONFIG_UNIX=y
+CONFIG_XFRM=y
+# CONFIG_XFRM_USER is not set
+# CONFIG_XFRM_SUB_POLICY is not set
+# CONFIG_NET_KEY is not set
+CONFIG_INET=y
+# CONFIG_IP_MULTICAST is not set
+# CONFIG_IP_ADVANCED_ROUTER is not set
+CONFIG_IP_FIB_HASH=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+# CONFIG_IP_PNP_BOOTP is not set
+# CONFIG_IP_PNP_RARP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_ARPD is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_XFRM_TUNNEL is not set
+# CONFIG_INET_TUNNEL is not set
+CONFIG_INET_XFRM_MODE_TRANSPORT=y
+CONFIG_INET_XFRM_MODE_TUNNEL=y
+CONFIG_INET_XFRM_MODE_BEET=y
+CONFIG_INET_DIAG=y
+CONFIG_INET_TCP_DIAG=y
+# CONFIG_TCP_CONG_ADVANCED is not set
+CONFIG_TCP_CONG_CUBIC=y
+CONFIG_DEFAULT_TCP_CONG="cubic"
+# CONFIG_TCP_MD5SIG is not set
+# CONFIG_IPV6 is not set
+# CONFIG_INET6_XFRM_TUNNEL is not set
+# CONFIG_INET6_TUNNEL is not set
+# CONFIG_NETWORK_SECMARK is not set
+# CONFIG_NETFILTER is not set
+
+#
+# DCCP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_DCCP is not set
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_SCTP is not set
+
+#
+# TIPC Configuration (EXPERIMENTAL)
+#
+# CONFIG_TIPC is not set
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+# CONFIG_IEEE80211 is not set
+
 #
 # Device Drivers
 #
@@ -133,12 +250,100 @@ CONFIG_BINFMT_ELF=y
 #
 CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
-# CONFIG_FW_LOADER is not set
+CONFIG_FW_LOADER=y
+# CONFIG_SYS_HYPERVISOR is not set
+
+#
+# Connector - unified userspace <-> kernelspace linker
+#
+# CONFIG_CONNECTOR is not set
 
 #
 # Memory Technology Devices (MTD)
 #
-# CONFIG_MTD is not set
+CONFIG_MTD=y
+# CONFIG_MTD_DEBUG is not set
+# CONFIG_MTD_CONCAT is not set
+CONFIG_MTD_PARTITIONS=y
+CONFIG_MTD_REDBOOT_PARTS=y
+CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-1
+# CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED is not set
+# CONFIG_MTD_REDBOOT_PARTS_READONLY is not set
+# CONFIG_MTD_CMDLINE_PARTS is not set
+
+#
+# User Modules And Translation Layers
+#
+# CONFIG_MTD_CHAR is not set
+CONFIG_MTD_BLOCK=y
+# CONFIG_FTL is not set
+# CONFIG_NFTL is not set
+# CONFIG_INFTL is not set
+# CONFIG_RFD_FTL is not set
+# CONFIG_SSFDC is not set
+
+#
+# RAM/ROM/Flash chip drivers
+#
+CONFIG_MTD_CFI=m
+CONFIG_MTD_JEDECPROBE=m
+CONFIG_MTD_GEN_PROBE=m
+CONFIG_MTD_CFI_ADV_OPTIONS=y
+# CONFIG_MTD_CFI_NOSWAP is not set
+CONFIG_MTD_CFI_BE_BYTE_SWAP=y
+# CONFIG_MTD_CFI_LE_BYTE_SWAP is not set
+CONFIG_MTD_CFI_GEOMETRY=y
+CONFIG_MTD_MAP_BANK_WIDTH_1=y
+CONFIG_MTD_MAP_BANK_WIDTH_2=y
+CONFIG_MTD_MAP_BANK_WIDTH_4=y
+# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
+CONFIG_MTD_CFI_I1=y
+# CONFIG_MTD_CFI_I2 is not set
+# CONFIG_MTD_CFI_I4 is not set
+# CONFIG_MTD_CFI_I8 is not set
+# CONFIG_MTD_OTP is not set
+# CONFIG_MTD_CFI_INTELEXT is not set
+CONFIG_MTD_CFI_AMDSTD=m
+# CONFIG_MTD_CFI_STAA is not set
+CONFIG_MTD_CFI_UTIL=m
+# CONFIG_MTD_RAM is not set
+# CONFIG_MTD_ROM is not set
+# CONFIG_MTD_ABSENT is not set
+# CONFIG_MTD_OBSOLETE_CHIPS is not set
+
+#
+# Mapping drivers for chip access
+#
+# CONFIG_MTD_COMPLEX_MAPPINGS is not set
+# CONFIG_MTD_PHYSMAP is not set
+# CONFIG_MTD_PLATRAM is not set
+
+#
+# Self-contained MTD device drivers
+#
+# CONFIG_MTD_SLRAM is not set
+# CONFIG_MTD_PHRAM is not set
+# CONFIG_MTD_MTDRAM is not set
+# CONFIG_MTD_BLOCK2MTD is not set
+
+#
+# Disk-On-Chip Device Drivers
+#
+# CONFIG_MTD_DOC2000 is not set
+# CONFIG_MTD_DOC2001 is not set
+# CONFIG_MTD_DOC2001PLUS is not set
+
+#
+# NAND Flash Device Drivers
+#
+# CONFIG_MTD_NAND is not set
+
+#
+# OneNAND Flash Device Drivers
+#
+# CONFIG_MTD_ONENAND is not set
 
 #
 # Parallel port support
@@ -152,7 +357,6 @@ CONFIG_PREVENT_FIRMWARE_BUILD=y
 #
 # Block devices
 #
-# CONFIG_BLK_DEV_FD is not set
 # CONFIG_BLK_DEV_COW_COMMON is not set
 CONFIG_BLK_DEV_LOOP=y
 # CONFIG_BLK_DEV_CRYPTOLOOP is not set
@@ -160,23 +364,21 @@ CONFIG_BLK_DEV_NBD=y
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_COUNT=16
 CONFIG_BLK_DEV_RAM_SIZE=4096
+CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
 # CONFIG_BLK_DEV_INITRD is not set
-CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_CDROM_PKTCDVD is not set
+CONFIG_ATA_OVER_ETH=m
 
 #
-# IO Schedulers
+# Misc devices
 #
-CONFIG_IOSCHED_NOOP=y
-# CONFIG_IOSCHED_AS is not set
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
-# CONFIG_ATA_OVER_ETH is not set
+# CONFIG_TIFM_CORE is not set
 
 #
 # ATA/ATAPI/MFM/RLL support
 #
 CONFIG_IDE=y
+CONFIG_IDE_MAX_HWIFS=4
 CONFIG_BLK_DEV_IDE=y
 
 #
@@ -185,7 +387,6 @@ CONFIG_BLK_DEV_IDE=y
 # CONFIG_BLK_DEV_IDE_SATA is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-CONFIG_BLK_DEV_IDECS=y
 CONFIG_BLK_DEV_IDECD=m
 # CONFIG_BLK_DEV_IDETAPE is not set
 # CONFIG_BLK_DEV_IDEFLOPPY is not set
@@ -204,7 +405,9 @@ CONFIG_IDE_GENERIC=y
 #
 # SCSI device support
 #
+# CONFIG_RAID_ATTRS is not set
 CONFIG_SCSI=m
+# CONFIG_SCSI_NETLINK is not set
 CONFIG_SCSI_PROC_FS=y
 
 #
@@ -216,6 +419,7 @@ CONFIG_BLK_DEV_SD=m
 CONFIG_BLK_DEV_SR=m
 # CONFIG_BLK_DEV_SR_VENDOR is not set
 CONFIG_CHR_DEV_SG=m
+# CONFIG_CHR_DEV_SCH is not set
 
 #
 # Some SCSI devices (e.g. CD jukebox) support multiple LUNs
@@ -225,26 +429,23 @@ CONFIG_SCSI_MULTI_LUN=y
 # CONFIG_SCSI_LOGGING is not set
 
 #
-# SCSI Transport Attributes
+# SCSI Transports
 #
 # CONFIG_SCSI_SPI_ATTRS is not set
 # CONFIG_SCSI_FC_ATTRS is not set
 # CONFIG_SCSI_ISCSI_ATTRS is not set
+# CONFIG_SCSI_SAS_ATTRS is not set
+# CONFIG_SCSI_SAS_LIBSAS is not set
 
 #
 # SCSI low-level drivers
 #
-# CONFIG_SCSI_SATA is not set
+# CONFIG_ISCSI_TCP is not set
 # CONFIG_SCSI_DEBUG is not set
 
 #
-# PCMCIA SCSI adapter support
+# Serial ATA (prod) and Parallel ATA (experimental) drivers
 #
-# CONFIG_PCMCIA_AHA152X is not set
-# CONFIG_PCMCIA_FDOMAIN is not set
-# CONFIG_PCMCIA_NINJA_SCSI is not set
-# CONFIG_PCMCIA_QLOGIC is not set
-# CONFIG_PCMCIA_SYM53C500 is not set
 
 #
 # Multi-device support (RAID and LVM)
@@ -254,6 +455,7 @@ CONFIG_SCSI_MULTI_LUN=y
 #
 # Fusion MPT device support
 #
+# CONFIG_FUSION is not set
 
 #
 # IEEE 1394 (FireWire) support
@@ -264,75 +466,19 @@ CONFIG_SCSI_MULTI_LUN=y
 #
 
 #
-# Networking support
-#
-CONFIG_NET=y
-
-#
-# Networking options
-#
-CONFIG_PACKET=y
-# CONFIG_PACKET_MMAP is not set
-CONFIG_UNIX=y
-# CONFIG_NET_KEY is not set
-CONFIG_INET=y
-# CONFIG_IP_MULTICAST is not set
-# CONFIG_IP_ADVANCED_ROUTER is not set
-CONFIG_IP_PNP=y
-CONFIG_IP_PNP_DHCP=y
-# CONFIG_IP_PNP_BOOTP is not set
-# CONFIG_IP_PNP_RARP is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_ARPD is not set
-# CONFIG_SYN_COOKIES is not set
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-# CONFIG_INET_TUNNEL is not set
-CONFIG_IP_TCPDIAG=y
-# CONFIG_IP_TCPDIAG_IPV6 is not set
-# CONFIG_IPV6 is not set
-# CONFIG_NETFILTER is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_DECNET is not set
-# CONFIG_LLC2 is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-# CONFIG_NET_CLS_ROUTE is not set
-
-#
-# Network testing
+# Network device support
 #
-# CONFIG_NET_PKTGEN is not set
-# CONFIG_NETPOLL is not set
-# CONFIG_NET_POLL_CONTROLLER is not set
-# CONFIG_HAMRADIO is not set
-# CONFIG_IRDA is not set
-# CONFIG_BT is not set
 CONFIG_NETDEVICES=y
 # CONFIG_DUMMY is not set
 # CONFIG_BONDING is not set
 # CONFIG_EQUALIZER is not set
 # CONFIG_TUN is not set
 
+#
+# PHY device support
+#
+# CONFIG_PHYLIB is not set
+
 #
 # Ethernet (10 or 100Mbit)
 #
@@ -358,11 +504,6 @@ CONFIG_SMC91X=y
 #
 # CONFIG_NET_RADIO is not set
 
-#
-# PCMCIA network device support
-#
-# CONFIG_NET_PCMCIA is not set
-
 #
 # Wan interfaces
 #
@@ -371,6 +512,8 @@ CONFIG_SMC91X=y
 # CONFIG_SLIP is not set
 # CONFIG_SHAPER is not set
 # CONFIG_NETCONSOLE is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
 
 #
 # ISDN subsystem
@@ -386,6 +529,7 @@ CONFIG_SMC91X=y
 # Input device support
 #
 CONFIG_INPUT=y
+# CONFIG_INPUT_FF_MEMLESS is not set
 
 #
 # Userland interfaces
@@ -414,7 +558,6 @@ CONFIG_SERIO_SERPORT=y
 # CONFIG_SERIO_LIBPS2 is not set
 # CONFIG_SERIO_RAW is not set
 # CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
 
 #
 # Character devices
@@ -422,6 +565,7 @@ CONFIG_SOUND_GAMEPORT=y
 CONFIG_VT=y
 CONFIG_VT_CONSOLE=y
 CONFIG_HW_CONSOLE=y
+# CONFIG_VT_HW_CONSOLE_BINDING is not set
 # CONFIG_SERIAL_NONSTANDARD is not set
 
 #
@@ -450,8 +594,8 @@ CONFIG_LEGACY_PTY_COUNT=256
 # Watchdog Cards
 #
 # CONFIG_WATCHDOG is not set
+CONFIG_HW_RANDOM=y
 # CONFIG_RTC is not set
-# CONFIG_GEN_RTC is not set
 CONFIG_DS1302=y
 # CONFIG_DTLK is not set
 # CONFIG_R3964 is not set
@@ -459,52 +603,64 @@ CONFIG_DS1302=y
 #
 # Ftape, the floppy tape device driver
 #
-# CONFIG_DRM is not set
-
-#
-# PCMCIA character devices
-#
-# CONFIG_SYNCLINK_CS is not set
 # CONFIG_RAW_DRIVER is not set
 
 #
 # TPM devices
 #
+# CONFIG_TCG_TPM is not set
 
 #
 # I2C support
 #
 # CONFIG_I2C is not set
 
+#
+# SPI support
+#
+# CONFIG_SPI is not set
+# CONFIG_SPI_MASTER is not set
+
 #
 # Dallas's 1-wire bus
 #
 # CONFIG_W1 is not set
 
 #
-# Misc devices
+# Hardware Monitoring support
 #
+CONFIG_HWMON=y
+# CONFIG_HWMON_VID is not set
+# CONFIG_SENSORS_ABITUGURU is not set
+# CONFIG_SENSORS_F71805F is not set
+# CONFIG_SENSORS_VT1211 is not set
+# CONFIG_HWMON_DEBUG_CHIP is not set
 
 #
 # Multimedia devices
 #
-CONFIG_VIDEO_DEV=y
+CONFIG_VIDEO_DEV=m
+CONFIG_VIDEO_V4L1=y
+CONFIG_VIDEO_V4L1_COMPAT=y
+CONFIG_VIDEO_V4L2=y
 
 #
-# Video For Linux
+# Video Capture Adapters
 #
 
 #
-# Video Adapters
+# Video Capture Adapters
 #
+# CONFIG_VIDEO_ADV_DEBUG is not set
+CONFIG_VIDEO_HELPER_CHIPS_AUTO=y
+# CONFIG_VIDEO_VIVI is not set
 # CONFIG_VIDEO_CPIA is not set
-CONFIG_VIDEO_M32R_AR=y
-CONFIG_VIDEO_M32R_AR_M64278=y
+CONFIG_VIDEO_M32R_AR=m
+CONFIG_VIDEO_M32R_AR_M64278=m
 
 #
 # Radio Adapters
 #
-# CONFIG_RADIO_MAESTRO is not set
 
 #
 # Digital Video Broadcasting Devices
@@ -514,15 +670,16 @@ CONFIG_VIDEO_M32R_AR_M64278=y
 #
 # Graphics support
 #
+CONFIG_FIRMWARE_EDID=y
 CONFIG_FB=y
-# CONFIG_FB_CFB_FILLRECT is not set
-# CONFIG_FB_CFB_COPYAREA is not set
-# CONFIG_FB_CFB_IMAGEBLIT is not set
-# CONFIG_FB_SOFT_CURSOR is not set
+CONFIG_FB_CFB_FILLRECT=y
+CONFIG_FB_CFB_COPYAREA=y
+CONFIG_FB_CFB_IMAGEBLIT=y
 # CONFIG_FB_MACMODES is not set
+# CONFIG_FB_BACKLIGHT is not set
 # CONFIG_FB_MODE_HELPERS is not set
 # CONFIG_FB_TILEBLITTING is not set
-# CONFIG_FB_S1D13XXX is not set
+CONFIG_FB_S1D13XXX=y
 # CONFIG_FB_VIRTUAL is not set
 
 #
@@ -531,6 +688,7 @@ CONFIG_FB=y
 # CONFIG_VGA_CONSOLE is not set
 CONFIG_DUMMY_CONSOLE=y
 CONFIG_FRAMEBUFFER_CONSOLE=y
+# CONFIG_FRAMEBUFFER_CONSOLE_ROTATION is not set
 # CONFIG_FONTS is not set
 CONFIG_FONT_8x8=y
 CONFIG_FONT_8x16=y
@@ -542,6 +700,7 @@ CONFIG_LOGO=y
 CONFIG_LOGO_LINUX_MONO=y
 CONFIG_LOGO_LINUX_VGA16=y
 CONFIG_LOGO_LINUX_CLUT224=y
+CONFIG_LOGO_M32R_CLUT224=y
 # CONFIG_BACKLIGHT_LCD_SUPPORT is not set
 
 #
@@ -554,6 +713,11 @@ CONFIG_LOGO_LINUX_CLUT224=y
 #
 # CONFIG_USB_ARCH_HAS_HCD is not set
 # CONFIG_USB_ARCH_HAS_OHCI is not set
+# CONFIG_USB_ARCH_HAS_EHCI is not set
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
+#
 
 #
 # USB Gadget Support
@@ -563,23 +727,62 @@ CONFIG_LOGO_LINUX_CLUT224=y
 #
 # MMC/SD Card support
 #
-# CONFIG_MMC is not set
+CONFIG_MMC=y
+CONFIG_MMC_DEBUG=y
+CONFIG_MMC_BLOCK=y
+# CONFIG_MMC_TIFM_SD is not set
+
+#
+# LED devices
+#
+# CONFIG_NEW_LEDS is not set
+
+#
+# LED drivers
+#
+
+#
+# LED Triggers
+#
 
 #
 # InfiniBand support
 #
-# CONFIG_INFINIBAND is not set
+
+#
+# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
+#
+
+#
+# Real Time Clock
+#
+# CONFIG_RTC_CLASS is not set
+
+#
+# DMA Engine support
+#
+# CONFIG_DMA_ENGINE is not set
+
+#
+# DMA Clients
+#
+
+#
+# DMA Devices
+#
 
 #
 # File systems
 #
 CONFIG_EXT2_FS=y
 # CONFIG_EXT2_FS_XATTR is not set
-CONFIG_EXT3_FS=m
+# CONFIG_EXT2_FS_XIP is not set
+CONFIG_EXT3_FS=y
 CONFIG_EXT3_FS_XATTR=y
 # CONFIG_EXT3_FS_POSIX_ACL is not set
 # CONFIG_EXT3_FS_SECURITY is not set
-CONFIG_JBD=m
+# CONFIG_EXT4DEV_FS is not set
+CONFIG_JBD=y
 CONFIG_JBD_DEBUG=y
 CONFIG_FS_MBCACHE=y
 CONFIG_REISERFS_FS=m
@@ -587,17 +790,19 @@ CONFIG_REISERFS_FS=m
 # CONFIG_REISERFS_PROC_INFO is not set
 # CONFIG_REISERFS_FS_XATTR is not set
 # CONFIG_JFS_FS is not set
-
-#
-# XFS support
-#
+# CONFIG_FS_POSIX_ACL is not set
 # CONFIG_XFS_FS is not set
+# CONFIG_GFS2_FS is not set
+# CONFIG_OCFS2_FS is not set
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
+CONFIG_INOTIFY=y
+CONFIG_INOTIFY_USER=y
 # CONFIG_QUOTA is not set
 CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
+# CONFIG_FUSE_FS is not set
 
 #
 # CD-ROM/DVD Filesystems
@@ -623,15 +828,13 @@ CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
 #
 CONFIG_PROC_FS=y
 CONFIG_PROC_KCORE=y
+CONFIG_PROC_SYSCTL=y
 CONFIG_SYSFS=y
-CONFIG_DEVFS_FS=y
-CONFIG_DEVFS_MOUNT=y
-# CONFIG_DEVFS_DEBUG is not set
-# CONFIG_DEVPTS_FS_XATTR is not set
 CONFIG_TMPFS=y
-# CONFIG_TMPFS_XATTR is not set
+# CONFIG_TMPFS_POSIX_ACL is not set
 # CONFIG_HUGETLB_PAGE is not set
 CONFIG_RAMFS=y
+# CONFIG_CONFIGFS_FS is not set
 
 #
 # Miscellaneous filesystems
@@ -643,6 +846,8 @@ CONFIG_RAMFS=y
 # CONFIG_BEFS_FS is not set
 # CONFIG_BFS_FS is not set
 # CONFIG_EFS_FS is not set
+# CONFIG_JFFS_FS is not set
+# CONFIG_JFFS2_FS is not set
 # CONFIG_CRAMFS is not set
 # CONFIG_VXFS_FS is not set
 # CONFIG_HPFS_FS is not set
@@ -655,12 +860,14 @@ CONFIG_RAMFS=y
 #
 CONFIG_NFS_FS=y
 CONFIG_NFS_V3=y
+# CONFIG_NFS_V3_ACL is not set
 # CONFIG_NFS_V4 is not set
 # CONFIG_NFS_DIRECTIO is not set
 # CONFIG_NFSD is not set
 CONFIG_ROOT_NFS=y
 CONFIG_LOCKD=y
 CONFIG_LOCKD_V4=y
+CONFIG_NFS_COMMON=y
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
 # CONFIG_RPCSEC_GSS_SPKM3 is not set
@@ -669,6 +876,7 @@ CONFIG_SUNRPC=y
 # CONFIG_NCP_FS is not set
 # CONFIG_CODA_FS is not set
 # CONFIG_AFS_FS is not set
+# CONFIG_9P_FS is not set
 
 #
 # Partition Types
@@ -723,16 +931,23 @@ CONFIG_NLS_DEFAULT="iso8859-1"
 #
 # Profiling support
 #
-# CONFIG_PROFILING is not set
+CONFIG_PROFILING=y
+CONFIG_OPROFILE=y
 
 #
 # Kernel hacking
 #
 # CONFIG_PRINTK_TIME is not set
+CONFIG_ENABLE_MUST_CHECK=y
+# CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_UNUSED_SYMBOLS is not set
 # CONFIG_DEBUG_KERNEL is not set
 CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_DEBUG_BUGVERBOSE is not set
+# CONFIG_DEBUG_FS is not set
 # CONFIG_FRAME_POINTER is not set
+# CONFIG_UNWIND_INFO is not set
+# CONFIG_HEADERS_CHECK is not set
 
 #
 # Security options
@@ -745,13 +960,10 @@ CONFIG_LOG_BUF_SHIFT=14
 #
 # CONFIG_CRYPTO is not set
 
-#
-# Hardware crypto devices
-#
-
 #
 # Library routines
 #
 # CONFIG_CRC_CCITT is not set
+# CONFIG_CRC16 is not set
 CONFIG_CRC32=y
 # CONFIG_LIBCRC32C is not set
index a8425fba340b43a8cbe924bc35d71dd8177b7c16..fbf6c384c9d094b305cf0adf442ddbf1c56a3a9d 100644 (file)
@@ -1,19 +1,18 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.12-rc5
-# Fri Jun  3 16:21:46 2005
+# Linux kernel version: 2.6.19
+# Wed Dec 13 17:57:45 2006
 #
 CONFIG_M32R=y
-# CONFIG_UID16 is not set
 CONFIG_GENERIC_ISA_DMA=y
 CONFIG_GENERIC_HARDIRQS=y
 CONFIG_GENERIC_IRQ_PROBE=y
+CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
 
 #
 # Code maturity level options
 #
 CONFIG_EXPERIMENTAL=y
-CONFIG_CLEAN_COMPILE=y
 CONFIG_BROKEN_ON_SMP=y
 CONFIG_LOCK_KERNEL=y
 CONFIG_INIT_ENV_ARG_LIMIT=32
@@ -22,29 +21,36 @@ CONFIG_INIT_ENV_ARG_LIMIT=32
 # General setup
 #
 CONFIG_LOCALVERSION=""
+CONFIG_LOCALVERSION_AUTO=y
+# CONFIG_SYSVIPC is not set
 # CONFIG_POSIX_MQUEUE is not set
 CONFIG_BSD_PROCESS_ACCT=y
 # CONFIG_BSD_PROCESS_ACCT_V3 is not set
-CONFIG_SYSCTL=y
+# CONFIG_TASKSTATS is not set
+# CONFIG_UTS_NS is not set
 # CONFIG_AUDIT is not set
-CONFIG_HOTPLUG=y
-CONFIG_KOBJECT_UEVENT=y
 CONFIG_IKCONFIG=y
 # CONFIG_IKCONFIG_PROC is not set
+CONFIG_SYSFS_DEPRECATED=y
+# CONFIG_RELAY is not set
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SYSCTL=y
 CONFIG_EMBEDDED=y
+CONFIG_SYSCTL_SYSCALL=y
 # CONFIG_KALLSYMS is not set
+CONFIG_HOTPLUG=y
 CONFIG_PRINTK=y
 CONFIG_BUG=y
+CONFIG_ELF_CORE=y
 CONFIG_BASE_FULL=y
 # CONFIG_FUTEX is not set
 # CONFIG_EPOLL is not set
-# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
-CONFIG_CC_ALIGN_FUNCTIONS=0
-CONFIG_CC_ALIGN_LABELS=0
-CONFIG_CC_ALIGN_LOOPS=0
-CONFIG_CC_ALIGN_JUMPS=0
+CONFIG_SLAB=y
+CONFIG_VM_EVENT_COUNTERS=y
 CONFIG_TINY_SHMEM=y
 CONFIG_BASE_SMALL=0
+# CONFIG_SLOB is not set
 
 #
 # Loadable module support
@@ -52,11 +58,29 @@ CONFIG_BASE_SMALL=0
 CONFIG_MODULES=y
 CONFIG_MODULE_UNLOAD=y
 # CONFIG_MODULE_FORCE_UNLOAD is not set
-CONFIG_OBSOLETE_MODPARM=y
 # CONFIG_MODVERSIONS is not set
 # CONFIG_MODULE_SRCVERSION_ALL is not set
 CONFIG_KMOD=y
 
+#
+# Block layer
+#
+CONFIG_BLOCK=y
+# CONFIG_BLK_DEV_IO_TRACE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+# CONFIG_IOSCHED_AS is not set
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+# CONFIG_DEFAULT_AS is not set
+# CONFIG_DEFAULT_DEADLINE is not set
+CONFIG_DEFAULT_CFQ=y
+# CONFIG_DEFAULT_NOOP is not set
+CONFIG_DEFAULT_IOSCHED="cfq"
+
 #
 # Processor type and features
 #
@@ -67,8 +91,10 @@ CONFIG_PLAT_MAPPI=y
 # CONFIG_PLAT_OAKS32R is not set
 # CONFIG_PLAT_MAPPI2 is not set
 # CONFIG_PLAT_MAPPI3 is not set
+# CONFIG_PLAT_M32104UT is not set
 CONFIG_CHIP_M32700=y
 # CONFIG_CHIP_M32102 is not set
+# CONFIG_CHIP_M32104 is not set
 # CONFIG_CHIP_VDEC2 is not set
 # CONFIG_CHIP_OPSP is not set
 # CONFIG_MMU is not set
@@ -82,18 +108,31 @@ CONFIG_TIMER_DIVIDE=128
 CONFIG_MEMORY_START=0x00000000
 CONFIG_MEMORY_SIZE=0x00E00000
 CONFIG_NOHIGHMEM=y
-# CONFIG_DISCONTIGMEM is not set
+CONFIG_ARCH_DISCONTIGMEM_ENABLE=y
+CONFIG_SELECT_MEMORY_MODEL=y
+# CONFIG_FLATMEM_MANUAL is not set
+CONFIG_DISCONTIGMEM_MANUAL=y
+# CONFIG_SPARSEMEM_MANUAL is not set
+CONFIG_DISCONTIGMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
+CONFIG_NEED_MULTIPLE_NODES=y
+# CONFIG_SPARSEMEM_STATIC is not set
+CONFIG_SPLIT_PTLOCK_CPUS=4
+# CONFIG_RESOURCES_64BIT is not set
+CONFIG_IRAM_START=0x00f00000
+CONFIG_IRAM_SIZE=0x00080000
 CONFIG_RWSEM_GENERIC_SPINLOCK=y
 # CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
+CONFIG_GENERIC_FIND_NEXT_BIT=y
+CONFIG_GENERIC_HWEIGHT=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_PREEMPT=y
-# CONFIG_HAVE_DEC_LOCK is not set
 # CONFIG_SMP is not set
+CONFIG_NODES_SHIFT=1
 
 #
 # Bus options (PCI, PCMCIA, EISA, MCA, ISA)
 #
-# CONFIG_PCI is not set
 # CONFIG_ISA is not set
 
 #
@@ -102,12 +141,14 @@ CONFIG_PREEMPT=y
 CONFIG_PCCARD=y
 # CONFIG_PCMCIA_DEBUG is not set
 CONFIG_PCMCIA=y
+CONFIG_PCMCIA_LOAD_CIS=y
+CONFIG_PCMCIA_IOCTL=y
 
 #
 # PC-card bridges
 #
-# CONFIG_TCIC is not set
 CONFIG_M32R_PCC=y
+CONFIG_PCCARD_NONSTATIC=y
 
 #
 # PCI Hotplug Support
@@ -121,6 +162,94 @@ CONFIG_BINFMT_FLAT=y
 # CONFIG_BINFMT_SHARED_FLAT is not set
 # CONFIG_BINFMT_MISC is not set
 
+#
+# Networking
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+# CONFIG_NETDEBUG is not set
+CONFIG_PACKET=y
+# CONFIG_PACKET_MMAP is not set
+CONFIG_UNIX=y
+CONFIG_XFRM=y
+# CONFIG_XFRM_USER is not set
+# CONFIG_XFRM_SUB_POLICY is not set
+# CONFIG_NET_KEY is not set
+CONFIG_INET=y
+# CONFIG_IP_MULTICAST is not set
+# CONFIG_IP_ADVANCED_ROUTER is not set
+CONFIG_IP_FIB_HASH=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+# CONFIG_IP_PNP_BOOTP is not set
+# CONFIG_IP_PNP_RARP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_ARPD is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_XFRM_TUNNEL is not set
+# CONFIG_INET_TUNNEL is not set
+CONFIG_INET_XFRM_MODE_TRANSPORT=y
+CONFIG_INET_XFRM_MODE_TUNNEL=y
+CONFIG_INET_XFRM_MODE_BEET=y
+CONFIG_INET_DIAG=y
+CONFIG_INET_TCP_DIAG=y
+# CONFIG_TCP_CONG_ADVANCED is not set
+CONFIG_TCP_CONG_CUBIC=y
+CONFIG_DEFAULT_TCP_CONG="cubic"
+# CONFIG_TCP_MD5SIG is not set
+# CONFIG_IPV6 is not set
+# CONFIG_INET6_XFRM_TUNNEL is not set
+# CONFIG_INET6_TUNNEL is not set
+# CONFIG_NETWORK_SECMARK is not set
+# CONFIG_NETFILTER is not set
+
+#
+# DCCP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_DCCP is not set
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_SCTP is not set
+
+#
+# TIPC Configuration (EXPERIMENTAL)
+#
+# CONFIG_TIPC is not set
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+# CONFIG_IEEE80211 is not set
+
 #
 # Device Drivers
 #
@@ -130,7 +259,13 @@ CONFIG_BINFMT_FLAT=y
 #
 CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
-# CONFIG_FW_LOADER is not set
+CONFIG_FW_LOADER=y
+# CONFIG_SYS_HYPERVISOR is not set
+
+#
+# Connector - unified userspace <-> kernelspace linker
+#
+# CONFIG_CONNECTOR is not set
 
 #
 # Memory Technology Devices (MTD)
@@ -149,7 +284,6 @@ CONFIG_PREVENT_FIRMWARE_BUILD=y
 #
 # Block devices
 #
-# CONFIG_BLK_DEV_FD is not set
 # CONFIG_BLK_DEV_COW_COMMON is not set
 CONFIG_BLK_DEV_LOOP=y
 # CONFIG_BLK_DEV_CRYPTOLOOP is not set
@@ -157,18 +291,15 @@ CONFIG_BLK_DEV_NBD=y
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_COUNT=16
 CONFIG_BLK_DEV_RAM_SIZE=4096
+CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
 # CONFIG_BLK_DEV_INITRD is not set
-CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_CDROM_PKTCDVD is not set
+# CONFIG_ATA_OVER_ETH is not set
 
 #
-# IO Schedulers
+# Misc devices
 #
-CONFIG_IOSCHED_NOOP=y
-# CONFIG_IOSCHED_AS is not set
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
-# CONFIG_ATA_OVER_ETH is not set
+# CONFIG_TIFM_CORE is not set
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -178,7 +309,13 @@ CONFIG_IOSCHED_CFQ=y
 #
 # SCSI device support
 #
+# CONFIG_RAID_ATTRS is not set
 # CONFIG_SCSI is not set
+# CONFIG_SCSI_NETLINK is not set
+
+#
+# Serial ATA (prod) and Parallel ATA (experimental) drivers
+#
 
 #
 # Multi-device support (RAID and LVM)
@@ -188,6 +325,7 @@ CONFIG_IOSCHED_CFQ=y
 #
 # Fusion MPT device support
 #
+# CONFIG_FUSION is not set
 
 #
 # IEEE 1394 (FireWire) support
@@ -198,75 +336,18 @@ CONFIG_IOSCHED_CFQ=y
 #
 
 #
-# Networking support
-#
-CONFIG_NET=y
-
-#
-# Networking options
-#
-CONFIG_PACKET=y
-# CONFIG_PACKET_MMAP is not set
-CONFIG_UNIX=y
-# CONFIG_NET_KEY is not set
-CONFIG_INET=y
-# CONFIG_IP_MULTICAST is not set
-# CONFIG_IP_ADVANCED_ROUTER is not set
-CONFIG_IP_PNP=y
-CONFIG_IP_PNP_DHCP=y
-# CONFIG_IP_PNP_BOOTP is not set
-# CONFIG_IP_PNP_RARP is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_ARPD is not set
-# CONFIG_SYN_COOKIES is not set
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-# CONFIG_INET_TUNNEL is not set
-CONFIG_IP_TCPDIAG=y
-# CONFIG_IP_TCPDIAG_IPV6 is not set
-# CONFIG_IPV6 is not set
-# CONFIG_NETFILTER is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_DECNET is not set
-# CONFIG_LLC2 is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-# CONFIG_NET_CLS_ROUTE is not set
-
-#
-# Network testing
+# Network device support
 #
-# CONFIG_NET_PKTGEN is not set
-# CONFIG_NETPOLL is not set
-# CONFIG_NET_POLL_CONTROLLER is not set
-# CONFIG_HAMRADIO is not set
-# CONFIG_IRDA is not set
-# CONFIG_BT is not set
 CONFIG_NETDEVICES=y
 # CONFIG_DUMMY is not set
 # CONFIG_BONDING is not set
 # CONFIG_EQUALIZER is not set
 # CONFIG_TUN is not set
 
+#
+# PHY device support
+#
+
 #
 # Ethernet (10 or 100Mbit)
 #
@@ -303,6 +384,8 @@ CONFIG_NE2000=y
 # CONFIG_SLIP is not set
 # CONFIG_SHAPER is not set
 # CONFIG_NETCONSOLE is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
 
 #
 # ISDN subsystem
@@ -318,6 +401,7 @@ CONFIG_NE2000=y
 # Input device support
 #
 CONFIG_INPUT=y
+# CONFIG_INPUT_FF_MEMLESS is not set
 
 #
 # Userland interfaces
@@ -346,7 +430,6 @@ CONFIG_SERIO_SERPORT=y
 # CONFIG_SERIO_LIBPS2 is not set
 # CONFIG_SERIO_RAW is not set
 # CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
 
 #
 # Character devices
@@ -366,7 +449,6 @@ CONFIG_SERIAL_CORE=y
 CONFIG_SERIAL_CORE_CONSOLE=y
 CONFIG_SERIAL_M32R_SIO=y
 CONFIG_SERIAL_M32R_SIO_CONSOLE=y
-# CONFIG_SERIAL_M32R_PLDSIO is not set
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
@@ -380,39 +462,53 @@ CONFIG_LEGACY_PTY_COUNT=256
 # Watchdog Cards
 #
 # CONFIG_WATCHDOG is not set
+CONFIG_HW_RANDOM=y
 # CONFIG_RTC is not set
-# CONFIG_GEN_RTC is not set
 # CONFIG_DTLK is not set
 # CONFIG_R3964 is not set
 
 #
 # Ftape, the floppy tape device driver
 #
-# CONFIG_DRM is not set
 
 #
 # PCMCIA character devices
 #
 # CONFIG_SYNCLINK_CS is not set
+# CONFIG_CARDMAN_4000 is not set
+# CONFIG_CARDMAN_4040 is not set
 # CONFIG_RAW_DRIVER is not set
 
 #
 # TPM devices
 #
+# CONFIG_TCG_TPM is not set
 
 #
 # I2C support
 #
 # CONFIG_I2C is not set
 
+#
+# SPI support
+#
+# CONFIG_SPI is not set
+# CONFIG_SPI_MASTER is not set
+
 #
 # Dallas's 1-wire bus
 #
 # CONFIG_W1 is not set
 
 #
-# Misc devices
+# Hardware Monitoring support
 #
+CONFIG_HWMON=y
+# CONFIG_HWMON_VID is not set
+# CONFIG_SENSORS_ABITUGURU is not set
+# CONFIG_SENSORS_F71805F is not set
+# CONFIG_SENSORS_VT1211 is not set
+# CONFIG_HWMON_DEBUG_CHIP is not set
 
 #
 # Multimedia devices
@@ -427,7 +523,9 @@ CONFIG_LEGACY_PTY_COUNT=256
 #
 # Graphics support
 #
+CONFIG_FIRMWARE_EDID=y
 # CONFIG_FB is not set
+# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
 
 #
 # Sound
@@ -439,6 +537,11 @@ CONFIG_LEGACY_PTY_COUNT=256
 #
 # CONFIG_USB_ARCH_HAS_HCD is not set
 # CONFIG_USB_ARCH_HAS_OHCI is not set
+# CONFIG_USB_ARCH_HAS_EHCI is not set
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
+#
 
 #
 # USB Gadget Support
@@ -450,31 +553,73 @@ CONFIG_LEGACY_PTY_COUNT=256
 #
 # CONFIG_MMC is not set
 
+#
+# LED devices
+#
+# CONFIG_NEW_LEDS is not set
+
+#
+# LED drivers
+#
+
+#
+# LED Triggers
+#
+
 #
 # InfiniBand support
 #
-# CONFIG_INFINIBAND is not set
+
+#
+# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
+#
+
+#
+# Real Time Clock
+#
+# CONFIG_RTC_CLASS is not set
+
+#
+# DMA Engine support
+#
+# CONFIG_DMA_ENGINE is not set
+
+#
+# DMA Clients
+#
+
+#
+# DMA Devices
+#
 
 #
 # File systems
 #
 CONFIG_EXT2_FS=y
 # CONFIG_EXT2_FS_XATTR is not set
-# CONFIG_EXT3_FS is not set
-# CONFIG_JBD is not set
+CONFIG_EXT3_FS=y
+CONFIG_EXT3_FS_XATTR=y
+# CONFIG_EXT3_FS_POSIX_ACL is not set
+# CONFIG_EXT3_FS_SECURITY is not set
+# CONFIG_EXT4DEV_FS is not set
+CONFIG_JBD=y
+# CONFIG_JBD_DEBUG is not set
+CONFIG_FS_MBCACHE=y
 # CONFIG_REISERFS_FS is not set
 # CONFIG_JFS_FS is not set
-
-#
-# XFS support
-#
+# CONFIG_FS_POSIX_ACL is not set
 # CONFIG_XFS_FS is not set
+# CONFIG_GFS2_FS is not set
+# CONFIG_OCFS2_FS is not set
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
+CONFIG_INOTIFY=y
+CONFIG_INOTIFY_USER=y
 # CONFIG_QUOTA is not set
 CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
+# CONFIG_FUSE_FS is not set
 
 #
 # CD-ROM/DVD Filesystems
@@ -493,15 +638,12 @@ CONFIG_DNOTIFY=y
 # Pseudo filesystems
 #
 CONFIG_PROC_FS=y
+CONFIG_PROC_SYSCTL=y
 CONFIG_SYSFS=y
-CONFIG_DEVFS_FS=y
-CONFIG_DEVFS_MOUNT=y
-# CONFIG_DEVFS_DEBUG is not set
-CONFIG_DEVPTS_FS_XATTR=y
-CONFIG_DEVPTS_FS_SECURITY=y
 # CONFIG_TMPFS is not set
 # CONFIG_HUGETLB_PAGE is not set
 CONFIG_RAMFS=y
+# CONFIG_CONFIGFS_FS is not set
 
 #
 # Miscellaneous filesystems
@@ -525,12 +667,14 @@ CONFIG_RAMFS=y
 #
 CONFIG_NFS_FS=y
 CONFIG_NFS_V3=y
+# CONFIG_NFS_V3_ACL is not set
 # CONFIG_NFS_V4 is not set
 # CONFIG_NFS_DIRECTIO is not set
 # CONFIG_NFSD is not set
 CONFIG_ROOT_NFS=y
 CONFIG_LOCKD=y
 CONFIG_LOCKD_V4=y
+CONFIG_NFS_COMMON=y
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
 # CONFIG_RPCSEC_GSS_SPKM3 is not set
@@ -539,6 +683,7 @@ CONFIG_SUNRPC=y
 # CONFIG_NCP_FS is not set
 # CONFIG_CODA_FS is not set
 # CONFIG_AFS_FS is not set
+# CONFIG_9P_FS is not set
 
 #
 # Partition Types
@@ -599,10 +744,16 @@ CONFIG_NLS_DEFAULT="iso8859-1"
 # Kernel hacking
 #
 # CONFIG_PRINTK_TIME is not set
+CONFIG_ENABLE_MUST_CHECK=y
+# CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_UNUSED_SYMBOLS is not set
 # CONFIG_DEBUG_KERNEL is not set
 CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_DEBUG_BUGVERBOSE is not set
+# CONFIG_DEBUG_FS is not set
 # CONFIG_FRAME_POINTER is not set
+# CONFIG_UNWIND_INFO is not set
+# CONFIG_HEADERS_CHECK is not set
 
 #
 # Security options
@@ -615,13 +766,10 @@ CONFIG_LOG_BUF_SHIFT=14
 #
 # CONFIG_CRYPTO is not set
 
-#
-# Hardware crypto devices
-#
-
 #
 # Library routines
 #
 # CONFIG_CRC_CCITT is not set
+# CONFIG_CRC16 is not set
 CONFIG_CRC32=y
 # CONFIG_LIBCRC32C is not set
index 1a7f3cd4224667cc82e71f2e1ca4de92d0e85c2a..168669202b94518cab1d0a7cf282d4dcd73c1cd0 100644 (file)
@@ -1,21 +1,18 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.12-rc5
-# Fri Jun  3 16:21:52 2005
+# Linux kernel version: 2.6.19
+# Wed Dec 13 17:50:59 2006
 #
 CONFIG_M32R=y
-# CONFIG_UID16 is not set
 CONFIG_GENERIC_ISA_DMA=y
 CONFIG_GENERIC_HARDIRQS=y
 CONFIG_GENERIC_IRQ_PROBE=y
+CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
 
 #
 # Code maturity level options
 #
 CONFIG_EXPERIMENTAL=y
-# CONFIG_CLEAN_COMPILE is not set
-CONFIG_BROKEN=y
-CONFIG_BROKEN_ON_SMP=y
 CONFIG_LOCK_KERNEL=y
 CONFIG_INIT_ENV_ARG_LIMIT=32
 
@@ -23,32 +20,39 @@ CONFIG_INIT_ENV_ARG_LIMIT=32
 # General setup
 #
 CONFIG_LOCALVERSION=""
+CONFIG_LOCALVERSION_AUTO=y
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
+# CONFIG_IPC_NS is not set
 # CONFIG_POSIX_MQUEUE is not set
 # CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
+# CONFIG_TASKSTATS is not set
+# CONFIG_UTS_NS is not set
 # CONFIG_AUDIT is not set
-CONFIG_HOTPLUG=y
-CONFIG_KOBJECT_UEVENT=y
 CONFIG_IKCONFIG=y
 CONFIG_IKCONFIG_PROC=y
 # CONFIG_CPUSETS is not set
+CONFIG_SYSFS_DEPRECATED=y
+# CONFIG_RELAY is not set
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SYSCTL=y
 CONFIG_EMBEDDED=y
+CONFIG_SYSCTL_SYSCALL=y
 # CONFIG_KALLSYMS is not set
+CONFIG_HOTPLUG=y
 CONFIG_PRINTK=y
 CONFIG_BUG=y
+CONFIG_ELF_CORE=y
 CONFIG_BASE_FULL=y
 # CONFIG_FUTEX is not set
 # CONFIG_EPOLL is not set
-# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
 CONFIG_SHMEM=y
-CONFIG_CC_ALIGN_FUNCTIONS=0
-CONFIG_CC_ALIGN_LABELS=0
-CONFIG_CC_ALIGN_LOOPS=0
-CONFIG_CC_ALIGN_JUMPS=0
+CONFIG_SLAB=y
+CONFIG_VM_EVENT_COUNTERS=y
 # CONFIG_TINY_SHMEM is not set
 CONFIG_BASE_SMALL=0
+# CONFIG_SLOB is not set
 
 #
 # Loadable module support
@@ -56,12 +60,30 @@ CONFIG_BASE_SMALL=0
 CONFIG_MODULES=y
 CONFIG_MODULE_UNLOAD=y
 # CONFIG_MODULE_FORCE_UNLOAD is not set
-CONFIG_OBSOLETE_MODPARM=y
 # CONFIG_MODVERSIONS is not set
 # CONFIG_MODULE_SRCVERSION_ALL is not set
 CONFIG_KMOD=y
 CONFIG_STOP_MACHINE=y
 
+#
+# Block layer
+#
+CONFIG_BLOCK=y
+# CONFIG_BLK_DEV_IO_TRACE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+# CONFIG_IOSCHED_AS is not set
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+# CONFIG_DEFAULT_AS is not set
+# CONFIG_DEFAULT_DEADLINE is not set
+CONFIG_DEFAULT_CFQ=y
+# CONFIG_DEFAULT_NOOP is not set
+CONFIG_DEFAULT_IOSCHED="cfq"
+
 #
 # Processor type and features
 #
@@ -72,8 +94,10 @@ CONFIG_PLAT_MAPPI=y
 # CONFIG_PLAT_OAKS32R is not set
 # CONFIG_PLAT_MAPPI2 is not set
 # CONFIG_PLAT_MAPPI3 is not set
+# CONFIG_PLAT_M32104UT is not set
 CONFIG_CHIP_M32700=y
 # CONFIG_CHIP_M32102 is not set
+# CONFIG_CHIP_M32104 is not set
 # CONFIG_CHIP_VDEC2 is not set
 # CONFIG_CHIP_OPSP is not set
 CONFIG_MMU=y
@@ -87,23 +111,33 @@ CONFIG_TIMER_DIVIDE=128
 CONFIG_MEMORY_START=0x08000000
 CONFIG_MEMORY_SIZE=0x04000000
 CONFIG_NOHIGHMEM=y
+CONFIG_ARCH_DISCONTIGMEM_ENABLE=y
+CONFIG_SELECT_MEMORY_MODEL=y
+# CONFIG_FLATMEM_MANUAL is not set
+CONFIG_DISCONTIGMEM_MANUAL=y
+# CONFIG_SPARSEMEM_MANUAL is not set
 CONFIG_DISCONTIGMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
+CONFIG_NEED_MULTIPLE_NODES=y
+# CONFIG_SPARSEMEM_STATIC is not set
+CONFIG_SPLIT_PTLOCK_CPUS=4
+# CONFIG_RESOURCES_64BIT is not set
 CONFIG_IRAM_START=0x00f00000
 CONFIG_IRAM_SIZE=0x00080000
 CONFIG_RWSEM_GENERIC_SPINLOCK=y
 # CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
+CONFIG_GENERIC_FIND_NEXT_BIT=y
+CONFIG_GENERIC_HWEIGHT=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_PREEMPT=y
-# CONFIG_HAVE_DEC_LOCK is not set
 CONFIG_SMP=y
 CONFIG_CHIP_M32700_TS1=y
 CONFIG_NR_CPUS=2
-# CONFIG_NUMA is not set
+CONFIG_NODES_SHIFT=1
 
 #
 # Bus options (PCI, PCMCIA, EISA, MCA, ISA)
 #
-# CONFIG_PCI is not set
 # CONFIG_ISA is not set
 
 #
@@ -112,12 +146,14 @@ CONFIG_NR_CPUS=2
 CONFIG_PCCARD=y
 # CONFIG_PCMCIA_DEBUG is not set
 CONFIG_PCMCIA=y
+CONFIG_PCMCIA_LOAD_CIS=y
+CONFIG_PCMCIA_IOCTL=y
 
 #
 # PC-card bridges
 #
-# CONFIG_TCIC is not set
 CONFIG_M32R_PCC=y
+CONFIG_PCCARD_NONSTATIC=y
 
 #
 # PCI Hotplug Support
@@ -129,6 +165,93 @@ CONFIG_M32R_PCC=y
 CONFIG_BINFMT_ELF=y
 # CONFIG_BINFMT_MISC is not set
 
+#
+# Networking
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+# CONFIG_NETDEBUG is not set
+# CONFIG_PACKET is not set
+CONFIG_UNIX=y
+CONFIG_XFRM=y
+# CONFIG_XFRM_USER is not set
+# CONFIG_XFRM_SUB_POLICY is not set
+# CONFIG_NET_KEY is not set
+CONFIG_INET=y
+# CONFIG_IP_MULTICAST is not set
+# CONFIG_IP_ADVANCED_ROUTER is not set
+CONFIG_IP_FIB_HASH=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+# CONFIG_IP_PNP_BOOTP is not set
+# CONFIG_IP_PNP_RARP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_ARPD is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_XFRM_TUNNEL is not set
+# CONFIG_INET_TUNNEL is not set
+CONFIG_INET_XFRM_MODE_TRANSPORT=y
+CONFIG_INET_XFRM_MODE_TUNNEL=y
+CONFIG_INET_XFRM_MODE_BEET=y
+CONFIG_INET_DIAG=y
+CONFIG_INET_TCP_DIAG=y
+# CONFIG_TCP_CONG_ADVANCED is not set
+CONFIG_TCP_CONG_CUBIC=y
+CONFIG_DEFAULT_TCP_CONG="cubic"
+# CONFIG_TCP_MD5SIG is not set
+# CONFIG_IPV6 is not set
+# CONFIG_INET6_XFRM_TUNNEL is not set
+# CONFIG_INET6_TUNNEL is not set
+# CONFIG_NETWORK_SECMARK is not set
+# CONFIG_NETFILTER is not set
+
+#
+# DCCP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_DCCP is not set
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_SCTP is not set
+
+#
+# TIPC Configuration (EXPERIMENTAL)
+#
+# CONFIG_TIPC is not set
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+# CONFIG_IEEE80211 is not set
+
 #
 # Device Drivers
 #
@@ -138,7 +261,13 @@ CONFIG_BINFMT_ELF=y
 #
 # CONFIG_STANDALONE is not set
 CONFIG_PREVENT_FIRMWARE_BUILD=y
-# CONFIG_FW_LOADER is not set
+CONFIG_FW_LOADER=y
+# CONFIG_SYS_HYPERVISOR is not set
+
+#
+# Connector - unified userspace <-> kernelspace linker
+#
+# CONFIG_CONNECTOR is not set
 
 #
 # Memory Technology Devices (MTD)
@@ -161,6 +290,8 @@ CONFIG_MTD_BLOCK=y
 # CONFIG_FTL is not set
 # CONFIG_NFTL is not set
 # CONFIG_INFTL is not set
+# CONFIG_RFD_FTL is not set
+# CONFIG_SSFDC is not set
 
 #
 # RAM/ROM/Flash chip drivers
@@ -186,6 +317,7 @@ CONFIG_MTD_CFI_I2=y
 # Mapping drivers for chip access
 #
 # CONFIG_MTD_COMPLEX_MAPPINGS is not set
+# CONFIG_MTD_PLATRAM is not set
 
 #
 # Self-contained MTD device drivers
@@ -193,7 +325,6 @@ CONFIG_MTD_CFI_I2=y
 # CONFIG_MTD_SLRAM is not set
 # CONFIG_MTD_PHRAM is not set
 # CONFIG_MTD_MTDRAM is not set
-# CONFIG_MTD_BLKMTD is not set
 # CONFIG_MTD_BLOCK2MTD is not set
 
 #
@@ -208,6 +339,11 @@ CONFIG_MTD_CFI_I2=y
 #
 # CONFIG_MTD_NAND is not set
 
+#
+# OneNAND Flash Device Drivers
+#
+# CONFIG_MTD_ONENAND is not set
+
 #
 # Parallel port support
 #
@@ -220,7 +356,6 @@ CONFIG_MTD_CFI_I2=y
 #
 # Block devices
 #
-# CONFIG_BLK_DEV_FD is not set
 # CONFIG_BLK_DEV_COW_COMMON is not set
 CONFIG_BLK_DEV_LOOP=y
 # CONFIG_BLK_DEV_CRYPTOLOOP is not set
@@ -228,23 +363,21 @@ CONFIG_BLK_DEV_NBD=m
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_COUNT=16
 CONFIG_BLK_DEV_RAM_SIZE=4096
+CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
 CONFIG_BLK_DEV_INITRD=y
-CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_CDROM_PKTCDVD is not set
+# CONFIG_ATA_OVER_ETH is not set
 
 #
-# IO Schedulers
+# Misc devices
 #
-CONFIG_IOSCHED_NOOP=y
-# CONFIG_IOSCHED_AS is not set
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
-# CONFIG_ATA_OVER_ETH is not set
+# CONFIG_TIFM_CORE is not set
 
 #
 # ATA/ATAPI/MFM/RLL support
 #
 CONFIG_IDE=m
+CONFIG_IDE_MAX_HWIFS=4
 CONFIG_BLK_DEV_IDE=m
 
 #
@@ -271,7 +404,13 @@ CONFIG_IDE_GENERIC=m
 #
 # SCSI device support
 #
+# CONFIG_RAID_ATTRS is not set
 # CONFIG_SCSI is not set
+# CONFIG_SCSI_NETLINK is not set
+
+#
+# Serial ATA (prod) and Parallel ATA (experimental) drivers
+#
 
 #
 # Multi-device support (RAID and LVM)
@@ -281,85 +420,29 @@ CONFIG_IDE_GENERIC=m
 #
 # Fusion MPT device support
 #
+# CONFIG_FUSION is not set
 
 #
 # IEEE 1394 (FireWire) support
 #
-# CONFIG_IEEE1394 is not set
 
 #
 # I2O device support
 #
 
 #
-# Networking support
+# Network device support
 #
-CONFIG_NET=y
-
-#
-# Networking options
-#
-# CONFIG_PACKET is not set
-CONFIG_UNIX=y
-# CONFIG_NET_KEY is not set
-CONFIG_INET=y
-# CONFIG_IP_MULTICAST is not set
-# CONFIG_IP_ADVANCED_ROUTER is not set
-CONFIG_IP_PNP=y
-CONFIG_IP_PNP_DHCP=y
-# CONFIG_IP_PNP_BOOTP is not set
-# CONFIG_IP_PNP_RARP is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_ARPD is not set
-# CONFIG_SYN_COOKIES is not set
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-# CONFIG_INET_TUNNEL is not set
-CONFIG_IP_TCPDIAG=y
-# CONFIG_IP_TCPDIAG_IPV6 is not set
-# CONFIG_IPV6 is not set
-# CONFIG_NETFILTER is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_DECNET is not set
-# CONFIG_LLC2 is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-# CONFIG_NET_CLS_ROUTE is not set
-
-#
-# Network testing
-#
-# CONFIG_NET_PKTGEN is not set
-# CONFIG_NETPOLL is not set
-# CONFIG_NET_POLL_CONTROLLER is not set
-# CONFIG_HAMRADIO is not set
-# CONFIG_IRDA is not set
-# CONFIG_BT is not set
 CONFIG_NETDEVICES=y
 # CONFIG_DUMMY is not set
 # CONFIG_BONDING is not set
 # CONFIG_EQUALIZER is not set
 # CONFIG_TUN is not set
 
+#
+# PHY device support
+#
+
 #
 # Ethernet (10 or 100Mbit)
 #
@@ -396,6 +479,8 @@ CONFIG_NE2000=y
 # CONFIG_SLIP is not set
 # CONFIG_SHAPER is not set
 # CONFIG_NETCONSOLE is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
 
 #
 # ISDN subsystem
@@ -411,6 +496,7 @@ CONFIG_NE2000=y
 # Input device support
 #
 CONFIG_INPUT=y
+# CONFIG_INPUT_FF_MEMLESS is not set
 
 #
 # Userland interfaces
@@ -442,7 +528,6 @@ CONFIG_SERIO=y
 # CONFIG_SERIO_LIBPS2 is not set
 # CONFIG_SERIO_RAW is not set
 # CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
 
 #
 # Character devices
@@ -462,7 +547,6 @@ CONFIG_SERIAL_CORE=y
 CONFIG_SERIAL_CORE_CONSOLE=y
 CONFIG_SERIAL_M32R_SIO=y
 CONFIG_SERIAL_M32R_SIO_CONSOLE=y
-# CONFIG_SERIAL_M32R_PLDSIO is not set
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
@@ -476,39 +560,53 @@ CONFIG_LEGACY_PTY_COUNT=256
 # Watchdog Cards
 #
 # CONFIG_WATCHDOG is not set
+CONFIG_HW_RANDOM=y
 # CONFIG_RTC is not set
-# CONFIG_GEN_RTC is not set
 # CONFIG_DTLK is not set
 # CONFIG_R3964 is not set
 
 #
 # Ftape, the floppy tape device driver
 #
-# CONFIG_DRM is not set
 
 #
 # PCMCIA character devices
 #
 # CONFIG_SYNCLINK_CS is not set
+# CONFIG_CARDMAN_4000 is not set
+# CONFIG_CARDMAN_4040 is not set
 # CONFIG_RAW_DRIVER is not set
 
 #
 # TPM devices
 #
+# CONFIG_TCG_TPM is not set
 
 #
 # I2C support
 #
 # CONFIG_I2C is not set
 
+#
+# SPI support
+#
+# CONFIG_SPI is not set
+# CONFIG_SPI_MASTER is not set
+
 #
 # Dallas's 1-wire bus
 #
 # CONFIG_W1 is not set
 
 #
-# Misc devices
+# Hardware Monitoring support
 #
+CONFIG_HWMON=y
+# CONFIG_HWMON_VID is not set
+# CONFIG_SENSORS_ABITUGURU is not set
+# CONFIG_SENSORS_F71805F is not set
+# CONFIG_SENSORS_VT1211 is not set
+# CONFIG_HWMON_DEBUG_CHIP is not set
 
 #
 # Multimedia devices
@@ -523,7 +621,9 @@ CONFIG_LEGACY_PTY_COUNT=256
 #
 # Graphics support
 #
+CONFIG_FIRMWARE_EDID=y
 # CONFIG_FB is not set
+# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
 
 #
 # Sound
@@ -535,6 +635,11 @@ CONFIG_LEGACY_PTY_COUNT=256
 #
 # CONFIG_USB_ARCH_HAS_HCD is not set
 # CONFIG_USB_ARCH_HAS_OHCI is not set
+# CONFIG_USB_ARCH_HAS_EHCI is not set
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
+#
 
 #
 # USB Gadget Support
@@ -546,31 +651,74 @@ CONFIG_LEGACY_PTY_COUNT=256
 #
 # CONFIG_MMC is not set
 
+#
+# LED devices
+#
+# CONFIG_NEW_LEDS is not set
+
+#
+# LED drivers
+#
+
+#
+# LED Triggers
+#
+
 #
 # InfiniBand support
 #
-# CONFIG_INFINIBAND is not set
+
+#
+# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
+#
+
+#
+# Real Time Clock
+#
+# CONFIG_RTC_CLASS is not set
+
+#
+# DMA Engine support
+#
+# CONFIG_DMA_ENGINE is not set
+
+#
+# DMA Clients
+#
+
+#
+# DMA Devices
+#
 
 #
 # File systems
 #
 CONFIG_EXT2_FS=y
 # CONFIG_EXT2_FS_XATTR is not set
-# CONFIG_EXT3_FS is not set
-# CONFIG_JBD is not set
+# CONFIG_EXT2_FS_XIP is not set
+CONFIG_EXT3_FS=y
+CONFIG_EXT3_FS_XATTR=y
+# CONFIG_EXT3_FS_POSIX_ACL is not set
+# CONFIG_EXT3_FS_SECURITY is not set
+# CONFIG_EXT4DEV_FS is not set
+CONFIG_JBD=y
+# CONFIG_JBD_DEBUG is not set
+CONFIG_FS_MBCACHE=y
 # CONFIG_REISERFS_FS is not set
 # CONFIG_JFS_FS is not set
-
-#
-# XFS support
-#
+# CONFIG_FS_POSIX_ACL is not set
 # CONFIG_XFS_FS is not set
+# CONFIG_GFS2_FS is not set
+# CONFIG_OCFS2_FS is not set
 # CONFIG_MINIX_FS is not set
 CONFIG_ROMFS_FS=y
+CONFIG_INOTIFY=y
+CONFIG_INOTIFY_USER=y
 # CONFIG_QUOTA is not set
 CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
+# CONFIG_FUSE_FS is not set
 
 #
 # CD-ROM/DVD Filesystems
@@ -595,16 +743,13 @@ CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
 #
 CONFIG_PROC_FS=y
 CONFIG_PROC_KCORE=y
+CONFIG_PROC_SYSCTL=y
 CONFIG_SYSFS=y
-CONFIG_DEVFS_FS=y
-CONFIG_DEVFS_MOUNT=y
-# CONFIG_DEVFS_DEBUG is not set
-# CONFIG_DEVPTS_FS_XATTR is not set
 CONFIG_TMPFS=y
-# CONFIG_TMPFS_XATTR is not set
-# CONFIG_HUGETLBFS is not set
+# CONFIG_TMPFS_POSIX_ACL is not set
 # CONFIG_HUGETLB_PAGE is not set
 CONFIG_RAMFS=y
+# CONFIG_CONFIGFS_FS is not set
 
 #
 # Miscellaneous filesystems
@@ -621,8 +766,9 @@ CONFIG_JFFS_FS_VERBOSE=0
 CONFIG_JFFS_PROC_FS=y
 CONFIG_JFFS2_FS=y
 CONFIG_JFFS2_FS_DEBUG=0
-# CONFIG_JFFS2_FS_NAND is not set
-# CONFIG_JFFS2_FS_NOR_ECC is not set
+CONFIG_JFFS2_FS_WRITEBUFFER=y
+# CONFIG_JFFS2_SUMMARY is not set
+# CONFIG_JFFS2_FS_XATTR is not set
 # CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
 CONFIG_JFFS2_ZLIB=y
 CONFIG_JFFS2_RTIME=y
@@ -639,12 +785,14 @@ CONFIG_JFFS2_RTIME=y
 #
 CONFIG_NFS_FS=y
 CONFIG_NFS_V3=y
+# CONFIG_NFS_V3_ACL is not set
 # CONFIG_NFS_V4 is not set
 # CONFIG_NFS_DIRECTIO is not set
 # CONFIG_NFSD is not set
 CONFIG_ROOT_NFS=y
 CONFIG_LOCKD=y
 CONFIG_LOCKD_V4=y
+CONFIG_NFS_COMMON=y
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
 # CONFIG_RPCSEC_GSS_SPKM3 is not set
@@ -653,6 +801,7 @@ CONFIG_SUNRPC=y
 # CONFIG_NCP_FS is not set
 # CONFIG_CODA_FS is not set
 # CONFIG_AFS_FS is not set
+# CONFIG_9P_FS is not set
 
 #
 # Partition Types
@@ -713,10 +862,16 @@ CONFIG_NLS_DEFAULT="iso8859-1"
 # Kernel hacking
 #
 # CONFIG_PRINTK_TIME is not set
+CONFIG_ENABLE_MUST_CHECK=y
+# CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_UNUSED_SYMBOLS is not set
 # CONFIG_DEBUG_KERNEL is not set
 CONFIG_LOG_BUF_SHIFT=15
 # CONFIG_DEBUG_BUGVERBOSE is not set
+# CONFIG_DEBUG_FS is not set
 # CONFIG_FRAME_POINTER is not set
+# CONFIG_UNWIND_INFO is not set
+# CONFIG_HEADERS_CHECK is not set
 
 #
 # Security options
@@ -729,14 +884,11 @@ CONFIG_LOG_BUF_SHIFT=15
 #
 # CONFIG_CRYPTO is not set
 
-#
-# Hardware crypto devices
-#
-
 #
 # Library routines
 #
 # CONFIG_CRC_CCITT is not set
+# CONFIG_CRC16 is not set
 CONFIG_CRC32=y
 # CONFIG_LIBCRC32C is not set
 CONFIG_ZLIB_INFLATE=y
index 38910fb766926078b6cb7bf38b0c37b8b3ce3b45..5ba00603c1a0d09500b4c8fa9f4bf83e7e659120 100644 (file)
@@ -1,20 +1,18 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.12-rc5
-# Fri Jun  3 16:21:59 2005
+# Linux kernel version: 2.6.19
+# Wed Dec 13 17:51:20 2006
 #
 CONFIG_M32R=y
-# CONFIG_UID16 is not set
 CONFIG_GENERIC_ISA_DMA=y
 CONFIG_GENERIC_HARDIRQS=y
 CONFIG_GENERIC_IRQ_PROBE=y
+CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
 
 #
 # Code maturity level options
 #
 CONFIG_EXPERIMENTAL=y
-# CONFIG_CLEAN_COMPILE is not set
-CONFIG_BROKEN=y
 CONFIG_BROKEN_ON_SMP=y
 CONFIG_LOCK_KERNEL=y
 CONFIG_INIT_ENV_ARG_LIMIT=32
@@ -23,31 +21,38 @@ CONFIG_INIT_ENV_ARG_LIMIT=32
 # General setup
 #
 CONFIG_LOCALVERSION=""
+CONFIG_LOCALVERSION_AUTO=y
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
+# CONFIG_IPC_NS is not set
 # CONFIG_POSIX_MQUEUE is not set
 # CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
+# CONFIG_TASKSTATS is not set
+# CONFIG_UTS_NS is not set
 # CONFIG_AUDIT is not set
-CONFIG_HOTPLUG=y
-CONFIG_KOBJECT_UEVENT=y
 CONFIG_IKCONFIG=y
 CONFIG_IKCONFIG_PROC=y
+CONFIG_SYSFS_DEPRECATED=y
+# CONFIG_RELAY is not set
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SYSCTL=y
 CONFIG_EMBEDDED=y
+CONFIG_SYSCTL_SYSCALL=y
 # CONFIG_KALLSYMS is not set
+CONFIG_HOTPLUG=y
 CONFIG_PRINTK=y
 CONFIG_BUG=y
+CONFIG_ELF_CORE=y
 CONFIG_BASE_FULL=y
 # CONFIG_FUTEX is not set
 # CONFIG_EPOLL is not set
-# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
 CONFIG_SHMEM=y
-CONFIG_CC_ALIGN_FUNCTIONS=0
-CONFIG_CC_ALIGN_LABELS=0
-CONFIG_CC_ALIGN_LOOPS=0
-CONFIG_CC_ALIGN_JUMPS=0
+CONFIG_SLAB=y
+CONFIG_VM_EVENT_COUNTERS=y
 # CONFIG_TINY_SHMEM is not set
 CONFIG_BASE_SMALL=0
+# CONFIG_SLOB is not set
 
 #
 # Loadable module support
@@ -55,11 +60,29 @@ CONFIG_BASE_SMALL=0
 CONFIG_MODULES=y
 CONFIG_MODULE_UNLOAD=y
 # CONFIG_MODULE_FORCE_UNLOAD is not set
-CONFIG_OBSOLETE_MODPARM=y
 # CONFIG_MODVERSIONS is not set
 # CONFIG_MODULE_SRCVERSION_ALL is not set
 CONFIG_KMOD=y
 
+#
+# Block layer
+#
+CONFIG_BLOCK=y
+# CONFIG_BLK_DEV_IO_TRACE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+# CONFIG_IOSCHED_AS is not set
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+# CONFIG_DEFAULT_AS is not set
+# CONFIG_DEFAULT_DEADLINE is not set
+CONFIG_DEFAULT_CFQ=y
+# CONFIG_DEFAULT_NOOP is not set
+CONFIG_DEFAULT_IOSCHED="cfq"
+
 #
 # Processor type and features
 #
@@ -70,8 +93,10 @@ CONFIG_PLAT_MAPPI=y
 # CONFIG_PLAT_OAKS32R is not set
 # CONFIG_PLAT_MAPPI2 is not set
 # CONFIG_PLAT_MAPPI3 is not set
+# CONFIG_PLAT_M32104UT is not set
 CONFIG_CHIP_M32700=y
 # CONFIG_CHIP_M32102 is not set
+# CONFIG_CHIP_M32104 is not set
 # CONFIG_CHIP_VDEC2 is not set
 # CONFIG_CHIP_OPSP is not set
 CONFIG_MMU=y
@@ -85,20 +110,31 @@ CONFIG_TIMER_DIVIDE=128
 CONFIG_MEMORY_START=0x08000000
 CONFIG_MEMORY_SIZE=0x04000000
 CONFIG_NOHIGHMEM=y
+CONFIG_ARCH_DISCONTIGMEM_ENABLE=y
+CONFIG_SELECT_MEMORY_MODEL=y
+# CONFIG_FLATMEM_MANUAL is not set
+CONFIG_DISCONTIGMEM_MANUAL=y
+# CONFIG_SPARSEMEM_MANUAL is not set
 CONFIG_DISCONTIGMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
+CONFIG_NEED_MULTIPLE_NODES=y
+# CONFIG_SPARSEMEM_STATIC is not set
+CONFIG_SPLIT_PTLOCK_CPUS=4
+# CONFIG_RESOURCES_64BIT is not set
 CONFIG_IRAM_START=0x00f00000
 CONFIG_IRAM_SIZE=0x00080000
 CONFIG_RWSEM_GENERIC_SPINLOCK=y
 # CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
+CONFIG_GENERIC_FIND_NEXT_BIT=y
+CONFIG_GENERIC_HWEIGHT=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_PREEMPT=y
-# CONFIG_HAVE_DEC_LOCK is not set
 # CONFIG_SMP is not set
+CONFIG_NODES_SHIFT=1
 
 #
 # Bus options (PCI, PCMCIA, EISA, MCA, ISA)
 #
-# CONFIG_PCI is not set
 # CONFIG_ISA is not set
 
 #
@@ -107,12 +143,14 @@ CONFIG_PREEMPT=y
 CONFIG_PCCARD=y
 # CONFIG_PCMCIA_DEBUG is not set
 CONFIG_PCMCIA=y
+CONFIG_PCMCIA_LOAD_CIS=y
+CONFIG_PCMCIA_IOCTL=y
 
 #
 # PC-card bridges
 #
-# CONFIG_TCIC is not set
 CONFIG_M32R_PCC=y
+CONFIG_PCCARD_NONSTATIC=y
 
 #
 # PCI Hotplug Support
@@ -124,6 +162,93 @@ CONFIG_M32R_PCC=y
 CONFIG_BINFMT_ELF=y
 # CONFIG_BINFMT_MISC is not set
 
+#
+# Networking
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+# CONFIG_NETDEBUG is not set
+# CONFIG_PACKET is not set
+CONFIG_UNIX=y
+CONFIG_XFRM=y
+# CONFIG_XFRM_USER is not set
+# CONFIG_XFRM_SUB_POLICY is not set
+# CONFIG_NET_KEY is not set
+CONFIG_INET=y
+# CONFIG_IP_MULTICAST is not set
+# CONFIG_IP_ADVANCED_ROUTER is not set
+CONFIG_IP_FIB_HASH=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+# CONFIG_IP_PNP_BOOTP is not set
+# CONFIG_IP_PNP_RARP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_ARPD is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_XFRM_TUNNEL is not set
+# CONFIG_INET_TUNNEL is not set
+CONFIG_INET_XFRM_MODE_TRANSPORT=y
+CONFIG_INET_XFRM_MODE_TUNNEL=y
+CONFIG_INET_XFRM_MODE_BEET=y
+CONFIG_INET_DIAG=y
+CONFIG_INET_TCP_DIAG=y
+# CONFIG_TCP_CONG_ADVANCED is not set
+CONFIG_TCP_CONG_CUBIC=y
+CONFIG_DEFAULT_TCP_CONG="cubic"
+# CONFIG_TCP_MD5SIG is not set
+# CONFIG_IPV6 is not set
+# CONFIG_INET6_XFRM_TUNNEL is not set
+# CONFIG_INET6_TUNNEL is not set
+# CONFIG_NETWORK_SECMARK is not set
+# CONFIG_NETFILTER is not set
+
+#
+# DCCP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_DCCP is not set
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_SCTP is not set
+
+#
+# TIPC Configuration (EXPERIMENTAL)
+#
+# CONFIG_TIPC is not set
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+# CONFIG_IEEE80211 is not set
+
 #
 # Device Drivers
 #
@@ -133,7 +258,13 @@ CONFIG_BINFMT_ELF=y
 #
 # CONFIG_STANDALONE is not set
 CONFIG_PREVENT_FIRMWARE_BUILD=y
-# CONFIG_FW_LOADER is not set
+CONFIG_FW_LOADER=y
+# CONFIG_SYS_HYPERVISOR is not set
+
+#
+# Connector - unified userspace <-> kernelspace linker
+#
+# CONFIG_CONNECTOR is not set
 
 #
 # Memory Technology Devices (MTD)
@@ -156,6 +287,8 @@ CONFIG_MTD_BLOCK=y
 # CONFIG_FTL is not set
 # CONFIG_NFTL is not set
 # CONFIG_INFTL is not set
+# CONFIG_RFD_FTL is not set
+# CONFIG_SSFDC is not set
 
 #
 # RAM/ROM/Flash chip drivers
@@ -181,6 +314,7 @@ CONFIG_MTD_CFI_I2=y
 # Mapping drivers for chip access
 #
 # CONFIG_MTD_COMPLEX_MAPPINGS is not set
+# CONFIG_MTD_PLATRAM is not set
 
 #
 # Self-contained MTD device drivers
@@ -188,7 +322,6 @@ CONFIG_MTD_CFI_I2=y
 # CONFIG_MTD_SLRAM is not set
 # CONFIG_MTD_PHRAM is not set
 # CONFIG_MTD_MTDRAM is not set
-# CONFIG_MTD_BLKMTD is not set
 # CONFIG_MTD_BLOCK2MTD is not set
 
 #
@@ -203,6 +336,11 @@ CONFIG_MTD_CFI_I2=y
 #
 # CONFIG_MTD_NAND is not set
 
+#
+# OneNAND Flash Device Drivers
+#
+# CONFIG_MTD_ONENAND is not set
+
 #
 # Parallel port support
 #
@@ -215,7 +353,6 @@ CONFIG_MTD_CFI_I2=y
 #
 # Block devices
 #
-# CONFIG_BLK_DEV_FD is not set
 # CONFIG_BLK_DEV_COW_COMMON is not set
 CONFIG_BLK_DEV_LOOP=y
 # CONFIG_BLK_DEV_CRYPTOLOOP is not set
@@ -223,23 +360,21 @@ CONFIG_BLK_DEV_NBD=m
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_COUNT=16
 CONFIG_BLK_DEV_RAM_SIZE=4096
+CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
 CONFIG_BLK_DEV_INITRD=y
-CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_CDROM_PKTCDVD is not set
+# CONFIG_ATA_OVER_ETH is not set
 
 #
-# IO Schedulers
+# Misc devices
 #
-CONFIG_IOSCHED_NOOP=y
-# CONFIG_IOSCHED_AS is not set
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
-# CONFIG_ATA_OVER_ETH is not set
+# CONFIG_TIFM_CORE is not set
 
 #
 # ATA/ATAPI/MFM/RLL support
 #
 CONFIG_IDE=m
+CONFIG_IDE_MAX_HWIFS=4
 CONFIG_BLK_DEV_IDE=m
 
 #
@@ -266,7 +401,13 @@ CONFIG_IDE_GENERIC=m
 #
 # SCSI device support
 #
+# CONFIG_RAID_ATTRS is not set
 # CONFIG_SCSI is not set
+# CONFIG_SCSI_NETLINK is not set
+
+#
+# Serial ATA (prod) and Parallel ATA (experimental) drivers
+#
 
 #
 # Multi-device support (RAID and LVM)
@@ -276,85 +417,29 @@ CONFIG_IDE_GENERIC=m
 #
 # Fusion MPT device support
 #
+# CONFIG_FUSION is not set
 
 #
 # IEEE 1394 (FireWire) support
 #
-# CONFIG_IEEE1394 is not set
 
 #
 # I2O device support
 #
 
 #
-# Networking support
+# Network device support
 #
-CONFIG_NET=y
-
-#
-# Networking options
-#
-# CONFIG_PACKET is not set
-CONFIG_UNIX=y
-# CONFIG_NET_KEY is not set
-CONFIG_INET=y
-# CONFIG_IP_MULTICAST is not set
-# CONFIG_IP_ADVANCED_ROUTER is not set
-CONFIG_IP_PNP=y
-CONFIG_IP_PNP_DHCP=y
-# CONFIG_IP_PNP_BOOTP is not set
-# CONFIG_IP_PNP_RARP is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_ARPD is not set
-# CONFIG_SYN_COOKIES is not set
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-# CONFIG_INET_TUNNEL is not set
-CONFIG_IP_TCPDIAG=y
-# CONFIG_IP_TCPDIAG_IPV6 is not set
-# CONFIG_IPV6 is not set
-# CONFIG_NETFILTER is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_DECNET is not set
-# CONFIG_LLC2 is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-# CONFIG_NET_CLS_ROUTE is not set
-
-#
-# Network testing
-#
-# CONFIG_NET_PKTGEN is not set
-# CONFIG_NETPOLL is not set
-# CONFIG_NET_POLL_CONTROLLER is not set
-# CONFIG_HAMRADIO is not set
-# CONFIG_IRDA is not set
-# CONFIG_BT is not set
 CONFIG_NETDEVICES=y
 # CONFIG_DUMMY is not set
 # CONFIG_BONDING is not set
 # CONFIG_EQUALIZER is not set
 # CONFIG_TUN is not set
 
+#
+# PHY device support
+#
+
 #
 # Ethernet (10 or 100Mbit)
 #
@@ -391,6 +476,8 @@ CONFIG_NE2000=y
 # CONFIG_SLIP is not set
 # CONFIG_SHAPER is not set
 # CONFIG_NETCONSOLE is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
 
 #
 # ISDN subsystem
@@ -406,6 +493,7 @@ CONFIG_NE2000=y
 # Input device support
 #
 CONFIG_INPUT=y
+# CONFIG_INPUT_FF_MEMLESS is not set
 
 #
 # Userland interfaces
@@ -437,7 +525,6 @@ CONFIG_SERIO=y
 # CONFIG_SERIO_LIBPS2 is not set
 # CONFIG_SERIO_RAW is not set
 # CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
 
 #
 # Character devices
@@ -457,7 +544,6 @@ CONFIG_SERIAL_CORE=y
 CONFIG_SERIAL_CORE_CONSOLE=y
 CONFIG_SERIAL_M32R_SIO=y
 CONFIG_SERIAL_M32R_SIO_CONSOLE=y
-# CONFIG_SERIAL_M32R_PLDSIO is not set
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
@@ -471,39 +557,53 @@ CONFIG_LEGACY_PTY_COUNT=256
 # Watchdog Cards
 #
 # CONFIG_WATCHDOG is not set
+CONFIG_HW_RANDOM=y
 # CONFIG_RTC is not set
-# CONFIG_GEN_RTC is not set
 # CONFIG_DTLK is not set
 # CONFIG_R3964 is not set
 
 #
 # Ftape, the floppy tape device driver
 #
-# CONFIG_DRM is not set
 
 #
 # PCMCIA character devices
 #
 # CONFIG_SYNCLINK_CS is not set
+# CONFIG_CARDMAN_4000 is not set
+# CONFIG_CARDMAN_4040 is not set
 # CONFIG_RAW_DRIVER is not set
 
 #
 # TPM devices
 #
+# CONFIG_TCG_TPM is not set
 
 #
 # I2C support
 #
 # CONFIG_I2C is not set
 
+#
+# SPI support
+#
+# CONFIG_SPI is not set
+# CONFIG_SPI_MASTER is not set
+
 #
 # Dallas's 1-wire bus
 #
 # CONFIG_W1 is not set
 
 #
-# Misc devices
+# Hardware Monitoring support
 #
+CONFIG_HWMON=y
+# CONFIG_HWMON_VID is not set
+# CONFIG_SENSORS_ABITUGURU is not set
+# CONFIG_SENSORS_F71805F is not set
+# CONFIG_SENSORS_VT1211 is not set
+# CONFIG_HWMON_DEBUG_CHIP is not set
 
 #
 # Multimedia devices
@@ -518,7 +618,9 @@ CONFIG_LEGACY_PTY_COUNT=256
 #
 # Graphics support
 #
+CONFIG_FIRMWARE_EDID=y
 # CONFIG_FB is not set
+# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
 
 #
 # Sound
@@ -530,6 +632,11 @@ CONFIG_LEGACY_PTY_COUNT=256
 #
 # CONFIG_USB_ARCH_HAS_HCD is not set
 # CONFIG_USB_ARCH_HAS_OHCI is not set
+# CONFIG_USB_ARCH_HAS_EHCI is not set
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
+#
 
 #
 # USB Gadget Support
@@ -541,31 +648,74 @@ CONFIG_LEGACY_PTY_COUNT=256
 #
 # CONFIG_MMC is not set
 
+#
+# LED devices
+#
+# CONFIG_NEW_LEDS is not set
+
+#
+# LED drivers
+#
+
+#
+# LED Triggers
+#
+
 #
 # InfiniBand support
 #
-# CONFIG_INFINIBAND is not set
+
+#
+# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
+#
+
+#
+# Real Time Clock
+#
+# CONFIG_RTC_CLASS is not set
+
+#
+# DMA Engine support
+#
+# CONFIG_DMA_ENGINE is not set
+
+#
+# DMA Clients
+#
+
+#
+# DMA Devices
+#
 
 #
 # File systems
 #
 CONFIG_EXT2_FS=y
 # CONFIG_EXT2_FS_XATTR is not set
-# CONFIG_EXT3_FS is not set
-# CONFIG_JBD is not set
+# CONFIG_EXT2_FS_XIP is not set
+CONFIG_EXT3_FS=y
+CONFIG_EXT3_FS_XATTR=y
+# CONFIG_EXT3_FS_POSIX_ACL is not set
+# CONFIG_EXT3_FS_SECURITY is not set
+# CONFIG_EXT4DEV_FS is not set
+CONFIG_JBD=y
+# CONFIG_JBD_DEBUG is not set
+CONFIG_FS_MBCACHE=y
 # CONFIG_REISERFS_FS is not set
 # CONFIG_JFS_FS is not set
-
-#
-# XFS support
-#
+# CONFIG_FS_POSIX_ACL is not set
 # CONFIG_XFS_FS is not set
+# CONFIG_GFS2_FS is not set
+# CONFIG_OCFS2_FS is not set
 # CONFIG_MINIX_FS is not set
 CONFIG_ROMFS_FS=y
+CONFIG_INOTIFY=y
+CONFIG_INOTIFY_USER=y
 # CONFIG_QUOTA is not set
 CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
+# CONFIG_FUSE_FS is not set
 
 #
 # CD-ROM/DVD Filesystems
@@ -590,16 +740,13 @@ CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
 #
 CONFIG_PROC_FS=y
 CONFIG_PROC_KCORE=y
+CONFIG_PROC_SYSCTL=y
 CONFIG_SYSFS=y
-CONFIG_DEVFS_FS=y
-CONFIG_DEVFS_MOUNT=y
-# CONFIG_DEVFS_DEBUG is not set
-# CONFIG_DEVPTS_FS_XATTR is not set
 CONFIG_TMPFS=y
-# CONFIG_TMPFS_XATTR is not set
-# CONFIG_HUGETLBFS is not set
+# CONFIG_TMPFS_POSIX_ACL is not set
 # CONFIG_HUGETLB_PAGE is not set
 CONFIG_RAMFS=y
+# CONFIG_CONFIGFS_FS is not set
 
 #
 # Miscellaneous filesystems
@@ -616,8 +763,9 @@ CONFIG_JFFS_FS_VERBOSE=0
 CONFIG_JFFS_PROC_FS=y
 CONFIG_JFFS2_FS=y
 CONFIG_JFFS2_FS_DEBUG=0
-# CONFIG_JFFS2_FS_NAND is not set
-# CONFIG_JFFS2_FS_NOR_ECC is not set
+CONFIG_JFFS2_FS_WRITEBUFFER=y
+# CONFIG_JFFS2_SUMMARY is not set
+# CONFIG_JFFS2_FS_XATTR is not set
 # CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
 CONFIG_JFFS2_ZLIB=y
 CONFIG_JFFS2_RTIME=y
@@ -634,12 +782,14 @@ CONFIG_JFFS2_RTIME=y
 #
 CONFIG_NFS_FS=y
 CONFIG_NFS_V3=y
+# CONFIG_NFS_V3_ACL is not set
 # CONFIG_NFS_V4 is not set
 # CONFIG_NFS_DIRECTIO is not set
 # CONFIG_NFSD is not set
 CONFIG_ROOT_NFS=y
 CONFIG_LOCKD=y
 CONFIG_LOCKD_V4=y
+CONFIG_NFS_COMMON=y
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
 # CONFIG_RPCSEC_GSS_SPKM3 is not set
@@ -648,6 +798,7 @@ CONFIG_SUNRPC=y
 # CONFIG_NCP_FS is not set
 # CONFIG_CODA_FS is not set
 # CONFIG_AFS_FS is not set
+# CONFIG_9P_FS is not set
 
 #
 # Partition Types
@@ -708,10 +859,16 @@ CONFIG_NLS_DEFAULT="iso8859-1"
 # Kernel hacking
 #
 # CONFIG_PRINTK_TIME is not set
+CONFIG_ENABLE_MUST_CHECK=y
+# CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_UNUSED_SYMBOLS is not set
 # CONFIG_DEBUG_KERNEL is not set
 CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_DEBUG_BUGVERBOSE is not set
+# CONFIG_DEBUG_FS is not set
 # CONFIG_FRAME_POINTER is not set
+# CONFIG_UNWIND_INFO is not set
+# CONFIG_HEADERS_CHECK is not set
 
 #
 # Security options
@@ -724,14 +881,11 @@ CONFIG_LOG_BUF_SHIFT=14
 #
 # CONFIG_CRYPTO is not set
 
-#
-# Hardware crypto devices
-#
-
 #
 # Library routines
 #
 # CONFIG_CRC_CCITT is not set
+# CONFIG_CRC16 is not set
 CONFIG_CRC32=y
 # CONFIG_LIBCRC32C is not set
 CONFIG_ZLIB_INFLATE=y
diff --git a/arch/m32r/mappi2/defconfig.opsp b/arch/m32r/mappi2/defconfig.opsp
new file mode 100644 (file)
index 0000000..b379ae9
--- /dev/null
@@ -0,0 +1,883 @@
+#
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.19
+# Wed Dec 13 19:40:30 2006
+#
+CONFIG_M32R=y
+CONFIG_GENERIC_ISA_DMA=y
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
+CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_BROKEN_ON_SMP=y
+CONFIG_LOCK_KERNEL=y
+CONFIG_INIT_ENV_ARG_LIMIT=32
+
+#
+# General setup
+#
+CONFIG_LOCALVERSION=""
+CONFIG_LOCALVERSION_AUTO=y
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+# CONFIG_IPC_NS is not set
+# CONFIG_POSIX_MQUEUE is not set
+CONFIG_BSD_PROCESS_ACCT=y
+# CONFIG_BSD_PROCESS_ACCT_V3 is not set
+# CONFIG_TASKSTATS is not set
+# CONFIG_UTS_NS is not set
+# CONFIG_AUDIT is not set
+CONFIG_IKCONFIG=y
+# CONFIG_IKCONFIG_PROC is not set
+CONFIG_SYSFS_DEPRECATED=y
+# CONFIG_RELAY is not set
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SYSCTL=y
+CONFIG_EMBEDDED=y
+CONFIG_SYSCTL_SYSCALL=y
+# CONFIG_KALLSYMS is not set
+CONFIG_HOTPLUG=y
+CONFIG_PRINTK=y
+CONFIG_BUG=y
+CONFIG_ELF_CORE=y
+CONFIG_BASE_FULL=y
+# CONFIG_FUTEX is not set
+# CONFIG_EPOLL is not set
+CONFIG_SHMEM=y
+CONFIG_SLAB=y
+CONFIG_VM_EVENT_COUNTERS=y
+# CONFIG_TINY_SHMEM is not set
+CONFIG_BASE_SMALL=0
+# CONFIG_SLOB is not set
+
+#
+# Loadable module support
+#
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+# CONFIG_MODULE_FORCE_UNLOAD is not set
+# CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SRCVERSION_ALL is not set
+CONFIG_KMOD=y
+
+#
+# Block layer
+#
+CONFIG_BLOCK=y
+# CONFIG_BLK_DEV_IO_TRACE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+# CONFIG_IOSCHED_AS is not set
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+# CONFIG_DEFAULT_AS is not set
+# CONFIG_DEFAULT_DEADLINE is not set
+CONFIG_DEFAULT_CFQ=y
+# CONFIG_DEFAULT_NOOP is not set
+CONFIG_DEFAULT_IOSCHED="cfq"
+
+#
+# Processor type and features
+#
+# CONFIG_PLAT_MAPPI is not set
+# CONFIG_PLAT_USRV is not set
+# CONFIG_PLAT_M32700UT is not set
+# CONFIG_PLAT_OPSPUT is not set
+# CONFIG_PLAT_OAKS32R is not set
+CONFIG_PLAT_MAPPI2=y
+# CONFIG_PLAT_MAPPI3 is not set
+# CONFIG_PLAT_M32104UT is not set
+# CONFIG_CHIP_M32700 is not set
+# CONFIG_CHIP_M32102 is not set
+# CONFIG_CHIP_M32104 is not set
+# CONFIG_CHIP_VDEC2 is not set
+CONFIG_CHIP_OPSP=y
+CONFIG_MMU=y
+CONFIG_TLB_ENTRIES=16
+CONFIG_ISA_M32R2=y
+CONFIG_ISA_DSP_LEVEL2=y
+CONFIG_ISA_DUAL_ISSUE=y
+CONFIG_BUS_CLOCK=50000000
+CONFIG_TIMER_DIVIDE=128
+# CONFIG_CPU_LITTLE_ENDIAN is not set
+CONFIG_MEMORY_START=0x08000000
+CONFIG_MEMORY_SIZE=0x01000000
+CONFIG_NOHIGHMEM=y
+CONFIG_ARCH_DISCONTIGMEM_ENABLE=y
+CONFIG_SELECT_MEMORY_MODEL=y
+# CONFIG_FLATMEM_MANUAL is not set
+CONFIG_DISCONTIGMEM_MANUAL=y
+# CONFIG_SPARSEMEM_MANUAL is not set
+CONFIG_DISCONTIGMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
+CONFIG_NEED_MULTIPLE_NODES=y
+# CONFIG_SPARSEMEM_STATIC is not set
+CONFIG_SPLIT_PTLOCK_CPUS=4
+# CONFIG_RESOURCES_64BIT is not set
+CONFIG_IRAM_START=0x00f00000
+CONFIG_IRAM_SIZE=0x00008000
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
+CONFIG_GENERIC_FIND_NEXT_BIT=y
+CONFIG_GENERIC_HWEIGHT=y
+CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_PREEMPT=y
+# CONFIG_SMP is not set
+CONFIG_NODES_SHIFT=1
+
+#
+# Bus options (PCI, PCMCIA, EISA, MCA, ISA)
+#
+# CONFIG_ISA is not set
+
+#
+# PCCARD (PCMCIA/CardBus) support
+#
+CONFIG_PCCARD=y
+# CONFIG_PCMCIA_DEBUG is not set
+CONFIG_PCMCIA=y
+CONFIG_PCMCIA_LOAD_CIS=y
+CONFIG_PCMCIA_IOCTL=y
+
+#
+# PC-card bridges
+#
+# CONFIG_M32R_CFC is not set
+
+#
+# PCI Hotplug Support
+#
+
+#
+# Executable file formats
+#
+CONFIG_BINFMT_ELF=y
+# CONFIG_BINFMT_MISC is not set
+
+#
+# Networking
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+# CONFIG_NETDEBUG is not set
+CONFIG_PACKET=y
+# CONFIG_PACKET_MMAP is not set
+CONFIG_UNIX=y
+CONFIG_XFRM=y
+# CONFIG_XFRM_USER is not set
+# CONFIG_XFRM_SUB_POLICY is not set
+# CONFIG_NET_KEY is not set
+CONFIG_INET=y
+# CONFIG_IP_MULTICAST is not set
+# CONFIG_IP_ADVANCED_ROUTER is not set
+CONFIG_IP_FIB_HASH=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+# CONFIG_IP_PNP_BOOTP is not set
+# CONFIG_IP_PNP_RARP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_ARPD is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_XFRM_TUNNEL is not set
+# CONFIG_INET_TUNNEL is not set
+CONFIG_INET_XFRM_MODE_TRANSPORT=y
+CONFIG_INET_XFRM_MODE_TUNNEL=y
+CONFIG_INET_XFRM_MODE_BEET=y
+CONFIG_INET_DIAG=y
+CONFIG_INET_TCP_DIAG=y
+# CONFIG_TCP_CONG_ADVANCED is not set
+CONFIG_TCP_CONG_CUBIC=y
+CONFIG_DEFAULT_TCP_CONG="cubic"
+# CONFIG_TCP_MD5SIG is not set
+# CONFIG_IPV6 is not set
+# CONFIG_INET6_XFRM_TUNNEL is not set
+# CONFIG_INET6_TUNNEL is not set
+# CONFIG_NETWORK_SECMARK is not set
+# CONFIG_NETFILTER is not set
+
+#
+# DCCP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_DCCP is not set
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_SCTP is not set
+
+#
+# TIPC Configuration (EXPERIMENTAL)
+#
+# CONFIG_TIPC is not set
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+# CONFIG_IEEE80211 is not set
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+CONFIG_FW_LOADER=y
+# CONFIG_SYS_HYPERVISOR is not set
+
+#
+# Connector - unified userspace <-> kernelspace linker
+#
+# CONFIG_CONNECTOR is not set
+
+#
+# Memory Technology Devices (MTD)
+#
+# CONFIG_MTD is not set
+
+#
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
+# Plug and Play support
+#
+
+#
+# Block devices
+#
+# CONFIG_BLK_DEV_COW_COMMON is not set
+CONFIG_BLK_DEV_LOOP=y
+# CONFIG_BLK_DEV_CRYPTOLOOP is not set
+CONFIG_BLK_DEV_NBD=y
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_COUNT=16
+CONFIG_BLK_DEV_RAM_SIZE=4096
+CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
+# CONFIG_BLK_DEV_INITRD is not set
+# CONFIG_CDROM_PKTCDVD is not set
+# CONFIG_ATA_OVER_ETH is not set
+
+#
+# Misc devices
+#
+# CONFIG_TIFM_CORE is not set
+
+#
+# ATA/ATAPI/MFM/RLL support
+#
+CONFIG_IDE=y
+CONFIG_IDE_MAX_HWIFS=4
+CONFIG_BLK_DEV_IDE=y
+
+#
+# Please see Documentation/ide.txt for help/info on IDE drives
+#
+# CONFIG_BLK_DEV_IDE_SATA is not set
+CONFIG_BLK_DEV_IDEDISK=y
+# CONFIG_IDEDISK_MULTI_MODE is not set
+CONFIG_BLK_DEV_IDECS=y
+CONFIG_BLK_DEV_IDECD=m
+# CONFIG_BLK_DEV_IDETAPE is not set
+# CONFIG_BLK_DEV_IDEFLOPPY is not set
+# CONFIG_BLK_DEV_IDESCSI is not set
+# CONFIG_IDE_TASK_IOCTL is not set
+
+#
+# IDE chipset support/bugfixes
+#
+CONFIG_IDE_GENERIC=y
+# CONFIG_IDE_ARM is not set
+# CONFIG_BLK_DEV_IDEDMA is not set
+# CONFIG_IDEDMA_AUTO is not set
+# CONFIG_BLK_DEV_HD is not set
+
+#
+# SCSI device support
+#
+# CONFIG_RAID_ATTRS is not set
+CONFIG_SCSI=m
+# CONFIG_SCSI_NETLINK is not set
+CONFIG_SCSI_PROC_FS=y
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+CONFIG_BLK_DEV_SD=m
+# CONFIG_CHR_DEV_ST is not set
+# CONFIG_CHR_DEV_OSST is not set
+CONFIG_BLK_DEV_SR=m
+# CONFIG_BLK_DEV_SR_VENDOR is not set
+CONFIG_CHR_DEV_SG=m
+# CONFIG_CHR_DEV_SCH is not set
+
+#
+# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
+#
+CONFIG_SCSI_MULTI_LUN=y
+# CONFIG_SCSI_CONSTANTS is not set
+# CONFIG_SCSI_LOGGING is not set
+
+#
+# SCSI Transports
+#
+# CONFIG_SCSI_SPI_ATTRS is not set
+# CONFIG_SCSI_FC_ATTRS is not set
+# CONFIG_SCSI_ISCSI_ATTRS is not set
+# CONFIG_SCSI_SAS_ATTRS is not set
+# CONFIG_SCSI_SAS_LIBSAS is not set
+
+#
+# SCSI low-level drivers
+#
+# CONFIG_ISCSI_TCP is not set
+# CONFIG_SCSI_DEBUG is not set
+
+#
+# PCMCIA SCSI adapter support
+#
+# CONFIG_PCMCIA_AHA152X is not set
+# CONFIG_PCMCIA_FDOMAIN is not set
+# CONFIG_PCMCIA_NINJA_SCSI is not set
+# CONFIG_PCMCIA_QLOGIC is not set
+# CONFIG_PCMCIA_SYM53C500 is not set
+
+#
+# Serial ATA (prod) and Parallel ATA (experimental) drivers
+#
+
+#
+# Multi-device support (RAID and LVM)
+#
+# CONFIG_MD is not set
+
+#
+# Fusion MPT device support
+#
+# CONFIG_FUSION is not set
+
+#
+# IEEE 1394 (FireWire) support
+#
+
+#
+# I2O device support
+#
+
+#
+# Network device support
+#
+CONFIG_NETDEVICES=y
+# CONFIG_DUMMY is not set
+# CONFIG_BONDING is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_TUN is not set
+
+#
+# PHY device support
+#
+# CONFIG_PHYLIB is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=y
+CONFIG_SMC91X=y
+# CONFIG_NE2000 is not set
+
+#
+# Ethernet (1000 Mbit)
+#
+
+#
+# Ethernet (10000 Mbit)
+#
+
+#
+# Token Ring devices
+#
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# PCMCIA network device support
+#
+# CONFIG_NET_PCMCIA is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+# CONFIG_SHAPER is not set
+# CONFIG_NETCONSOLE is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
+
+#
+# ISDN subsystem
+#
+# CONFIG_ISDN is not set
+
+#
+# Telephony Support
+#
+# CONFIG_PHONE is not set
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+# CONFIG_INPUT_FF_MEMLESS is not set
+
+#
+# Userland interfaces
+#
+# CONFIG_INPUT_MOUSEDEV is not set
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_TSDEV is not set
+# CONFIG_INPUT_EVDEV is not set
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input Device Drivers
+#
+# CONFIG_INPUT_KEYBOARD is not set
+# CONFIG_INPUT_MOUSE is not set
+# CONFIG_INPUT_JOYSTICK is not set
+# CONFIG_INPUT_TOUCHSCREEN is not set
+# CONFIG_INPUT_MISC is not set
+
+#
+# Hardware I/O ports
+#
+CONFIG_SERIO=y
+# CONFIG_SERIO_I8042 is not set
+CONFIG_SERIO_SERPORT=y
+# CONFIG_SERIO_LIBPS2 is not set
+# CONFIG_SERIO_RAW is not set
+# CONFIG_GAMEPORT is not set
+
+#
+# Character devices
+#
+CONFIG_VT=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+# CONFIG_VT_HW_CONSOLE_BINDING is not set
+# CONFIG_SERIAL_NONSTANDARD is not set
+
+#
+# Serial drivers
+#
+# CONFIG_SERIAL_8250 is not set
+
+#
+# Non-8250 serial port support
+#
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
+CONFIG_SERIAL_M32R_SIO=y
+CONFIG_SERIAL_M32R_SIO_CONSOLE=y
+CONFIG_UNIX98_PTYS=y
+CONFIG_LEGACY_PTYS=y
+CONFIG_LEGACY_PTY_COUNT=256
+
+#
+# IPMI
+#
+# CONFIG_IPMI_HANDLER is not set
+
+#
+# Watchdog Cards
+#
+# CONFIG_WATCHDOG is not set
+CONFIG_HW_RANDOM=y
+# CONFIG_RTC is not set
+# CONFIG_DTLK is not set
+# CONFIG_R3964 is not set
+
+#
+# Ftape, the floppy tape device driver
+#
+
+#
+# PCMCIA character devices
+#
+# CONFIG_SYNCLINK_CS is not set
+# CONFIG_CARDMAN_4000 is not set
+# CONFIG_CARDMAN_4040 is not set
+# CONFIG_RAW_DRIVER is not set
+
+#
+# TPM devices
+#
+# CONFIG_TCG_TPM is not set
+
+#
+# I2C support
+#
+# CONFIG_I2C is not set
+
+#
+# SPI support
+#
+# CONFIG_SPI is not set
+# CONFIG_SPI_MASTER is not set
+
+#
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
+# Hardware Monitoring support
+#
+CONFIG_HWMON=y
+# CONFIG_HWMON_VID is not set
+# CONFIG_SENSORS_ABITUGURU is not set
+# CONFIG_SENSORS_F71805F is not set
+# CONFIG_SENSORS_VT1211 is not set
+# CONFIG_HWMON_DEBUG_CHIP is not set
+
+#
+# Multimedia devices
+#
+CONFIG_VIDEO_DEV=y
+CONFIG_VIDEO_V4L1=y
+CONFIG_VIDEO_V4L1_COMPAT=y
+CONFIG_VIDEO_V4L2=y
+
+#
+# Video Capture Adapters
+#
+
+#
+# Video Capture Adapters
+#
+# CONFIG_VIDEO_ADV_DEBUG is not set
+CONFIG_VIDEO_HELPER_CHIPS_AUTO=y
+# CONFIG_VIDEO_VIVI is not set
+# CONFIG_VIDEO_CPIA is not set
+# CONFIG_VIDEO_M32R_AR is not set
+
+#
+# Radio Adapters
+#
+
+#
+# Digital Video Broadcasting Devices
+#
+# CONFIG_DVB is not set
+
+#
+# Graphics support
+#
+CONFIG_FIRMWARE_EDID=y
+# CONFIG_FB is not set
+
+#
+# Console display driver support
+#
+# CONFIG_VGA_CONSOLE is not set
+CONFIG_DUMMY_CONSOLE=y
+# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
+
+#
+# Sound
+#
+# CONFIG_SOUND is not set
+
+#
+# USB support
+#
+# CONFIG_USB_ARCH_HAS_HCD is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
+# CONFIG_USB_ARCH_HAS_EHCI is not set
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
+#
+
+#
+# USB Gadget Support
+#
+# CONFIG_USB_GADGET is not set
+
+#
+# MMC/SD Card support
+#
+# CONFIG_MMC is not set
+
+#
+# LED devices
+#
+# CONFIG_NEW_LEDS is not set
+
+#
+# LED drivers
+#
+
+#
+# LED Triggers
+#
+
+#
+# InfiniBand support
+#
+
+#
+# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
+#
+
+#
+# Real Time Clock
+#
+# CONFIG_RTC_CLASS is not set
+
+#
+# DMA Engine support
+#
+# CONFIG_DMA_ENGINE is not set
+
+#
+# DMA Clients
+#
+
+#
+# DMA Devices
+#
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+# CONFIG_EXT2_FS_XATTR is not set
+# CONFIG_EXT2_FS_XIP is not set
+CONFIG_EXT3_FS=y
+CONFIG_EXT3_FS_XATTR=y
+# CONFIG_EXT3_FS_POSIX_ACL is not set
+# CONFIG_EXT3_FS_SECURITY is not set
+# CONFIG_EXT4DEV_FS is not set
+CONFIG_JBD=y
+CONFIG_JBD_DEBUG=y
+CONFIG_FS_MBCACHE=y
+# CONFIG_REISERFS_FS is not set
+# CONFIG_JFS_FS is not set
+# CONFIG_FS_POSIX_ACL is not set
+# CONFIG_XFS_FS is not set
+# CONFIG_GFS2_FS is not set
+# CONFIG_OCFS2_FS is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_ROMFS_FS is not set
+CONFIG_INOTIFY=y
+CONFIG_INOTIFY_USER=y
+# CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
+# CONFIG_AUTOFS_FS is not set
+# CONFIG_AUTOFS4_FS is not set
+# CONFIG_FUSE_FS is not set
+
+#
+# CD-ROM/DVD Filesystems
+#
+CONFIG_ISO9660_FS=m
+CONFIG_JOLIET=y
+# CONFIG_ZISOFS is not set
+CONFIG_UDF_FS=m
+CONFIG_UDF_NLS=y
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=m
+CONFIG_MSDOS_FS=m
+CONFIG_VFAT_FS=m
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_PROC_SYSCTL=y
+CONFIG_SYSFS=y
+CONFIG_TMPFS=y
+# CONFIG_TMPFS_POSIX_ACL is not set
+# CONFIG_HUGETLB_PAGE is not set
+CONFIG_RAMFS=y
+# CONFIG_CONFIGFS_FS is not set
+
+#
+# Miscellaneous filesystems
+#
+# CONFIG_ADFS_FS is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_HFSPLUS_FS is not set
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+# CONFIG_CRAMFS is not set
+# CONFIG_VXFS_FS is not set
+# CONFIG_HPFS_FS is not set
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_SYSV_FS is not set
+# CONFIG_UFS_FS is not set
+
+#
+# Network File Systems
+#
+CONFIG_NFS_FS=y
+CONFIG_NFS_V3=y
+# CONFIG_NFS_V3_ACL is not set
+# CONFIG_NFS_V4 is not set
+# CONFIG_NFS_DIRECTIO is not set
+# CONFIG_NFSD is not set
+CONFIG_ROOT_NFS=y
+CONFIG_LOCKD=y
+CONFIG_LOCKD_V4=y
+CONFIG_NFS_COMMON=y
+CONFIG_SUNRPC=y
+# CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
+# CONFIG_SMB_FS is not set
+# CONFIG_CIFS is not set
+# CONFIG_NCP_FS is not set
+# CONFIG_CODA_FS is not set
+# CONFIG_AFS_FS is not set
+# CONFIG_9P_FS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+
+#
+# Native Language Support
+#
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="iso8859-1"
+# CONFIG_NLS_CODEPAGE_437 is not set
+# CONFIG_NLS_CODEPAGE_737 is not set
+# CONFIG_NLS_CODEPAGE_775 is not set
+# CONFIG_NLS_CODEPAGE_850 is not set
+# CONFIG_NLS_CODEPAGE_852 is not set
+# CONFIG_NLS_CODEPAGE_855 is not set
+# CONFIG_NLS_CODEPAGE_857 is not set
+# CONFIG_NLS_CODEPAGE_860 is not set
+# CONFIG_NLS_CODEPAGE_861 is not set
+# CONFIG_NLS_CODEPAGE_862 is not set
+# CONFIG_NLS_CODEPAGE_863 is not set
+# CONFIG_NLS_CODEPAGE_864 is not set
+# CONFIG_NLS_CODEPAGE_865 is not set
+# CONFIG_NLS_CODEPAGE_866 is not set
+# CONFIG_NLS_CODEPAGE_869 is not set
+# CONFIG_NLS_CODEPAGE_936 is not set
+# CONFIG_NLS_CODEPAGE_950 is not set
+# CONFIG_NLS_CODEPAGE_932 is not set
+# CONFIG_NLS_CODEPAGE_949 is not set
+# CONFIG_NLS_CODEPAGE_874 is not set
+# CONFIG_NLS_ISO8859_8 is not set
+# CONFIG_NLS_CODEPAGE_1250 is not set
+# CONFIG_NLS_CODEPAGE_1251 is not set
+# CONFIG_NLS_ASCII is not set
+# CONFIG_NLS_ISO8859_1 is not set
+# CONFIG_NLS_ISO8859_2 is not set
+# CONFIG_NLS_ISO8859_3 is not set
+# CONFIG_NLS_ISO8859_4 is not set
+# CONFIG_NLS_ISO8859_5 is not set
+# CONFIG_NLS_ISO8859_6 is not set
+# CONFIG_NLS_ISO8859_7 is not set
+# CONFIG_NLS_ISO8859_9 is not set
+# CONFIG_NLS_ISO8859_13 is not set
+# CONFIG_NLS_ISO8859_14 is not set
+# CONFIG_NLS_ISO8859_15 is not set
+# CONFIG_NLS_KOI8_R is not set
+# CONFIG_NLS_KOI8_U is not set
+# CONFIG_NLS_UTF8 is not set
+
+#
+# Profiling support
+#
+# CONFIG_PROFILING is not set
+
+#
+# Kernel hacking
+#
+# CONFIG_PRINTK_TIME is not set
+CONFIG_ENABLE_MUST_CHECK=y
+# CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_UNUSED_SYMBOLS is not set
+# CONFIG_DEBUG_KERNEL is not set
+CONFIG_LOG_BUF_SHIFT=14
+# CONFIG_DEBUG_BUGVERBOSE is not set
+# CONFIG_DEBUG_FS is not set
+# CONFIG_FRAME_POINTER is not set
+# CONFIG_UNWIND_INFO is not set
+# CONFIG_HEADERS_CHECK is not set
+
+#
+# Security options
+#
+# CONFIG_KEYS is not set
+# CONFIG_SECURITY is not set
+
+#
+# Cryptographic options
+#
+# CONFIG_CRYPTO is not set
+
+#
+# Library routines
+#
+# CONFIG_CRC_CCITT is not set
+# CONFIG_CRC16 is not set
+CONFIG_CRC32=y
+# CONFIG_LIBCRC32C is not set
index 56f287b658989cbf700afc53c4dd55b82080d2b5..fe5b2a63cd6805873087d39946148e2152274c29 100644 (file)
@@ -1,19 +1,18 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.12-rc5
-# Fri Jun  3 16:22:02 2005
+# Linux kernel version: 2.6.19
+# Wed Dec 13 19:31:44 2006
 #
 CONFIG_M32R=y
-# CONFIG_UID16 is not set
 CONFIG_GENERIC_ISA_DMA=y
 CONFIG_GENERIC_HARDIRQS=y
 CONFIG_GENERIC_IRQ_PROBE=y
+CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
 
 #
 # Code maturity level options
 #
 CONFIG_EXPERIMENTAL=y
-CONFIG_CLEAN_COMPILE=y
 CONFIG_BROKEN_ON_SMP=y
 CONFIG_LOCK_KERNEL=y
 CONFIG_INIT_ENV_ARG_LIMIT=32
@@ -22,32 +21,39 @@ CONFIG_INIT_ENV_ARG_LIMIT=32
 # General setup
 #
 CONFIG_LOCALVERSION=""
+CONFIG_LOCALVERSION_AUTO=y
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
+# CONFIG_IPC_NS is not set
 # CONFIG_POSIX_MQUEUE is not set
 CONFIG_BSD_PROCESS_ACCT=y
 # CONFIG_BSD_PROCESS_ACCT_V3 is not set
-CONFIG_SYSCTL=y
+# CONFIG_TASKSTATS is not set
+# CONFIG_UTS_NS is not set
 # CONFIG_AUDIT is not set
-CONFIG_HOTPLUG=y
-CONFIG_KOBJECT_UEVENT=y
 CONFIG_IKCONFIG=y
 # CONFIG_IKCONFIG_PROC is not set
+CONFIG_SYSFS_DEPRECATED=y
+# CONFIG_RELAY is not set
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SYSCTL=y
 CONFIG_EMBEDDED=y
+CONFIG_SYSCTL_SYSCALL=y
 # CONFIG_KALLSYMS is not set
+CONFIG_HOTPLUG=y
 CONFIG_PRINTK=y
 CONFIG_BUG=y
+CONFIG_ELF_CORE=y
 CONFIG_BASE_FULL=y
 # CONFIG_FUTEX is not set
 # CONFIG_EPOLL is not set
-# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
 CONFIG_SHMEM=y
-CONFIG_CC_ALIGN_FUNCTIONS=0
-CONFIG_CC_ALIGN_LABELS=0
-CONFIG_CC_ALIGN_LOOPS=0
-CONFIG_CC_ALIGN_JUMPS=0
+CONFIG_SLAB=y
+CONFIG_VM_EVENT_COUNTERS=y
 # CONFIG_TINY_SHMEM is not set
 CONFIG_BASE_SMALL=0
+# CONFIG_SLOB is not set
 
 #
 # Loadable module support
@@ -55,11 +61,29 @@ CONFIG_BASE_SMALL=0
 CONFIG_MODULES=y
 CONFIG_MODULE_UNLOAD=y
 # CONFIG_MODULE_FORCE_UNLOAD is not set
-CONFIG_OBSOLETE_MODPARM=y
 # CONFIG_MODVERSIONS is not set
 # CONFIG_MODULE_SRCVERSION_ALL is not set
 CONFIG_KMOD=y
 
+#
+# Block layer
+#
+CONFIG_BLOCK=y
+# CONFIG_BLK_DEV_IO_TRACE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+# CONFIG_IOSCHED_AS is not set
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+# CONFIG_DEFAULT_AS is not set
+# CONFIG_DEFAULT_DEADLINE is not set
+CONFIG_DEFAULT_CFQ=y
+# CONFIG_DEFAULT_NOOP is not set
+CONFIG_DEFAULT_IOSCHED="cfq"
+
 #
 # Processor type and features
 #
@@ -70,8 +94,10 @@ CONFIG_KMOD=y
 # CONFIG_PLAT_OAKS32R is not set
 CONFIG_PLAT_MAPPI2=y
 # CONFIG_PLAT_MAPPI3 is not set
+# CONFIG_PLAT_M32104UT is not set
 # CONFIG_CHIP_M32700 is not set
 # CONFIG_CHIP_M32102 is not set
+# CONFIG_CHIP_M32104 is not set
 CONFIG_CHIP_VDEC2=y
 # CONFIG_CHIP_OPSP is not set
 CONFIG_MMU=y
@@ -83,18 +109,31 @@ CONFIG_TIMER_DIVIDE=128
 CONFIG_MEMORY_START=0x08000000
 CONFIG_MEMORY_SIZE=0x01000000
 CONFIG_NOHIGHMEM=y
-# CONFIG_DISCONTIGMEM is not set
+CONFIG_ARCH_DISCONTIGMEM_ENABLE=y
+CONFIG_SELECT_MEMORY_MODEL=y
+# CONFIG_FLATMEM_MANUAL is not set
+CONFIG_DISCONTIGMEM_MANUAL=y
+# CONFIG_SPARSEMEM_MANUAL is not set
+CONFIG_DISCONTIGMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
+CONFIG_NEED_MULTIPLE_NODES=y
+# CONFIG_SPARSEMEM_STATIC is not set
+CONFIG_SPLIT_PTLOCK_CPUS=4
+# CONFIG_RESOURCES_64BIT is not set
+CONFIG_IRAM_START=0x00f00000
+CONFIG_IRAM_SIZE=0x00008000
 CONFIG_RWSEM_GENERIC_SPINLOCK=y
 # CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
+CONFIG_GENERIC_FIND_NEXT_BIT=y
+CONFIG_GENERIC_HWEIGHT=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_PREEMPT=y
-# CONFIG_HAVE_DEC_LOCK is not set
 # CONFIG_SMP is not set
+CONFIG_NODES_SHIFT=1
 
 #
 # Bus options (PCI, PCMCIA, EISA, MCA, ISA)
 #
-# CONFIG_PCI is not set
 # CONFIG_ISA is not set
 
 #
@@ -103,11 +142,12 @@ CONFIG_PREEMPT=y
 CONFIG_PCCARD=y
 # CONFIG_PCMCIA_DEBUG is not set
 CONFIG_PCMCIA=y
+CONFIG_PCMCIA_LOAD_CIS=y
+CONFIG_PCMCIA_IOCTL=y
 
 #
 # PC-card bridges
 #
-# CONFIG_TCIC is not set
 # CONFIG_M32R_CFC is not set
 
 #
@@ -120,6 +160,94 @@ CONFIG_PCMCIA=y
 CONFIG_BINFMT_ELF=y
 # CONFIG_BINFMT_MISC is not set
 
+#
+# Networking
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+# CONFIG_NETDEBUG is not set
+CONFIG_PACKET=y
+# CONFIG_PACKET_MMAP is not set
+CONFIG_UNIX=y
+CONFIG_XFRM=y
+# CONFIG_XFRM_USER is not set
+# CONFIG_XFRM_SUB_POLICY is not set
+# CONFIG_NET_KEY is not set
+CONFIG_INET=y
+# CONFIG_IP_MULTICAST is not set
+# CONFIG_IP_ADVANCED_ROUTER is not set
+CONFIG_IP_FIB_HASH=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+# CONFIG_IP_PNP_BOOTP is not set
+# CONFIG_IP_PNP_RARP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_ARPD is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_XFRM_TUNNEL is not set
+# CONFIG_INET_TUNNEL is not set
+CONFIG_INET_XFRM_MODE_TRANSPORT=y
+CONFIG_INET_XFRM_MODE_TUNNEL=y
+CONFIG_INET_XFRM_MODE_BEET=y
+CONFIG_INET_DIAG=y
+CONFIG_INET_TCP_DIAG=y
+# CONFIG_TCP_CONG_ADVANCED is not set
+CONFIG_TCP_CONG_CUBIC=y
+CONFIG_DEFAULT_TCP_CONG="cubic"
+# CONFIG_TCP_MD5SIG is not set
+# CONFIG_IPV6 is not set
+# CONFIG_INET6_XFRM_TUNNEL is not set
+# CONFIG_INET6_TUNNEL is not set
+# CONFIG_NETWORK_SECMARK is not set
+# CONFIG_NETFILTER is not set
+
+#
+# DCCP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_DCCP is not set
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_SCTP is not set
+
+#
+# TIPC Configuration (EXPERIMENTAL)
+#
+# CONFIG_TIPC is not set
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+# CONFIG_IEEE80211 is not set
+
 #
 # Device Drivers
 #
@@ -129,7 +257,13 @@ CONFIG_BINFMT_ELF=y
 #
 CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
-# CONFIG_FW_LOADER is not set
+CONFIG_FW_LOADER=y
+# CONFIG_SYS_HYPERVISOR is not set
+
+#
+# Connector - unified userspace <-> kernelspace linker
+#
+# CONFIG_CONNECTOR is not set
 
 #
 # Memory Technology Devices (MTD)
@@ -148,7 +282,6 @@ CONFIG_PREVENT_FIRMWARE_BUILD=y
 #
 # Block devices
 #
-# CONFIG_BLK_DEV_FD is not set
 # CONFIG_BLK_DEV_COW_COMMON is not set
 CONFIG_BLK_DEV_LOOP=y
 # CONFIG_BLK_DEV_CRYPTOLOOP is not set
@@ -156,23 +289,21 @@ CONFIG_BLK_DEV_NBD=y
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_COUNT=16
 CONFIG_BLK_DEV_RAM_SIZE=4096
+CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
 # CONFIG_BLK_DEV_INITRD is not set
-CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_CDROM_PKTCDVD is not set
+# CONFIG_ATA_OVER_ETH is not set
 
 #
-# IO Schedulers
+# Misc devices
 #
-CONFIG_IOSCHED_NOOP=y
-# CONFIG_IOSCHED_AS is not set
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
-# CONFIG_ATA_OVER_ETH is not set
+# CONFIG_TIFM_CORE is not set
 
 #
 # ATA/ATAPI/MFM/RLL support
 #
 CONFIG_IDE=y
+CONFIG_IDE_MAX_HWIFS=4
 CONFIG_BLK_DEV_IDE=y
 
 #
@@ -200,7 +331,9 @@ CONFIG_IDE_GENERIC=y
 #
 # SCSI device support
 #
+# CONFIG_RAID_ATTRS is not set
 CONFIG_SCSI=m
+# CONFIG_SCSI_NETLINK is not set
 CONFIG_SCSI_PROC_FS=y
 
 #
@@ -212,6 +345,7 @@ CONFIG_BLK_DEV_SD=m
 CONFIG_BLK_DEV_SR=m
 # CONFIG_BLK_DEV_SR_VENDOR is not set
 CONFIG_CHR_DEV_SG=m
+# CONFIG_CHR_DEV_SCH is not set
 
 #
 # Some SCSI devices (e.g. CD jukebox) support multiple LUNs
@@ -221,16 +355,18 @@ CONFIG_SCSI_MULTI_LUN=y
 # CONFIG_SCSI_LOGGING is not set
 
 #
-# SCSI Transport Attributes
+# SCSI Transports
 #
 # CONFIG_SCSI_SPI_ATTRS is not set
 # CONFIG_SCSI_FC_ATTRS is not set
 # CONFIG_SCSI_ISCSI_ATTRS is not set
+# CONFIG_SCSI_SAS_ATTRS is not set
+# CONFIG_SCSI_SAS_LIBSAS is not set
 
 #
 # SCSI low-level drivers
 #
-# CONFIG_SCSI_SATA is not set
+# CONFIG_ISCSI_TCP is not set
 # CONFIG_SCSI_DEBUG is not set
 
 #
@@ -242,6 +378,10 @@ CONFIG_SCSI_MULTI_LUN=y
 # CONFIG_PCMCIA_QLOGIC is not set
 # CONFIG_PCMCIA_SYM53C500 is not set
 
+#
+# Serial ATA (prod) and Parallel ATA (experimental) drivers
+#
+
 #
 # Multi-device support (RAID and LVM)
 #
@@ -250,6 +390,7 @@ CONFIG_SCSI_MULTI_LUN=y
 #
 # Fusion MPT device support
 #
+# CONFIG_FUSION is not set
 
 #
 # IEEE 1394 (FireWire) support
@@ -260,75 +401,19 @@ CONFIG_SCSI_MULTI_LUN=y
 #
 
 #
-# Networking support
-#
-CONFIG_NET=y
-
-#
-# Networking options
-#
-CONFIG_PACKET=y
-# CONFIG_PACKET_MMAP is not set
-CONFIG_UNIX=y
-# CONFIG_NET_KEY is not set
-CONFIG_INET=y
-# CONFIG_IP_MULTICAST is not set
-# CONFIG_IP_ADVANCED_ROUTER is not set
-CONFIG_IP_PNP=y
-CONFIG_IP_PNP_DHCP=y
-# CONFIG_IP_PNP_BOOTP is not set
-# CONFIG_IP_PNP_RARP is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_ARPD is not set
-# CONFIG_SYN_COOKIES is not set
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-# CONFIG_INET_TUNNEL is not set
-CONFIG_IP_TCPDIAG=y
-# CONFIG_IP_TCPDIAG_IPV6 is not set
-# CONFIG_IPV6 is not set
-# CONFIG_NETFILTER is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_DECNET is not set
-# CONFIG_LLC2 is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-# CONFIG_NET_CLS_ROUTE is not set
-
-#
-# Network testing
+# Network device support
 #
-# CONFIG_NET_PKTGEN is not set
-# CONFIG_NETPOLL is not set
-# CONFIG_NET_POLL_CONTROLLER is not set
-# CONFIG_HAMRADIO is not set
-# CONFIG_IRDA is not set
-# CONFIG_BT is not set
 CONFIG_NETDEVICES=y
 # CONFIG_DUMMY is not set
 # CONFIG_BONDING is not set
 # CONFIG_EQUALIZER is not set
 # CONFIG_TUN is not set
 
+#
+# PHY device support
+#
+# CONFIG_PHYLIB is not set
+
 #
 # Ethernet (10 or 100Mbit)
 #
@@ -367,6 +452,8 @@ CONFIG_SMC91X=y
 # CONFIG_SLIP is not set
 # CONFIG_SHAPER is not set
 # CONFIG_NETCONSOLE is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
 
 #
 # ISDN subsystem
@@ -382,6 +469,7 @@ CONFIG_SMC91X=y
 # Input device support
 #
 CONFIG_INPUT=y
+# CONFIG_INPUT_FF_MEMLESS is not set
 
 #
 # Userland interfaces
@@ -410,7 +498,6 @@ CONFIG_SERIO_SERPORT=y
 # CONFIG_SERIO_LIBPS2 is not set
 # CONFIG_SERIO_RAW is not set
 # CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
 
 #
 # Character devices
@@ -418,6 +505,7 @@ CONFIG_SOUND_GAMEPORT=y
 CONFIG_VT=y
 CONFIG_VT_CONSOLE=y
 CONFIG_HW_CONSOLE=y
+# CONFIG_VT_HW_CONSOLE_BINDING is not set
 # CONFIG_SERIAL_NONSTANDARD is not set
 
 #
@@ -432,7 +520,6 @@ CONFIG_SERIAL_CORE=y
 CONFIG_SERIAL_CORE_CONSOLE=y
 CONFIG_SERIAL_M32R_SIO=y
 CONFIG_SERIAL_M32R_SIO_CONSOLE=y
-# CONFIG_SERIAL_M32R_PLDSIO is not set
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
@@ -446,59 +533,78 @@ CONFIG_LEGACY_PTY_COUNT=256
 # Watchdog Cards
 #
 # CONFIG_WATCHDOG is not set
+CONFIG_HW_RANDOM=y
 # CONFIG_RTC is not set
-# CONFIG_GEN_RTC is not set
 # CONFIG_DTLK is not set
 # CONFIG_R3964 is not set
 
 #
 # Ftape, the floppy tape device driver
 #
-# CONFIG_DRM is not set
 
 #
 # PCMCIA character devices
 #
 # CONFIG_SYNCLINK_CS is not set
+# CONFIG_CARDMAN_4000 is not set
+# CONFIG_CARDMAN_4040 is not set
 # CONFIG_RAW_DRIVER is not set
 
 #
 # TPM devices
 #
+# CONFIG_TCG_TPM is not set
 
 #
 # I2C support
 #
 # CONFIG_I2C is not set
 
+#
+# SPI support
+#
+# CONFIG_SPI is not set
+# CONFIG_SPI_MASTER is not set
+
 #
 # Dallas's 1-wire bus
 #
 # CONFIG_W1 is not set
 
 #
-# Misc devices
+# Hardware Monitoring support
 #
+CONFIG_HWMON=y
+# CONFIG_HWMON_VID is not set
+# CONFIG_SENSORS_ABITUGURU is not set
+# CONFIG_SENSORS_F71805F is not set
+# CONFIG_SENSORS_VT1211 is not set
+# CONFIG_HWMON_DEBUG_CHIP is not set
 
 #
 # Multimedia devices
 #
 CONFIG_VIDEO_DEV=y
+CONFIG_VIDEO_V4L1=y
+CONFIG_VIDEO_V4L1_COMPAT=y
+CONFIG_VIDEO_V4L2=y
 
 #
-# Video For Linux
+# Video Capture Adapters
 #
 
 #
-# Video Adapters
+# Video Capture Adapters
 #
+# CONFIG_VIDEO_ADV_DEBUG is not set
+CONFIG_VIDEO_HELPER_CHIPS_AUTO=y
+# CONFIG_VIDEO_VIVI is not set
 # CONFIG_VIDEO_CPIA is not set
 # CONFIG_VIDEO_M32R_AR is not set
 
 #
 # Radio Adapters
 #
-# CONFIG_RADIO_MAESTRO is not set
 
 #
 # Digital Video Broadcasting Devices
@@ -508,6 +614,7 @@ CONFIG_VIDEO_DEV=y
 #
 # Graphics support
 #
+CONFIG_FIRMWARE_EDID=y
 # CONFIG_FB is not set
 
 #
@@ -515,6 +622,7 @@ CONFIG_VIDEO_DEV=y
 #
 # CONFIG_VGA_CONSOLE is not set
 CONFIG_DUMMY_CONSOLE=y
+# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
 
 #
 # Sound
@@ -526,6 +634,11 @@ CONFIG_DUMMY_CONSOLE=y
 #
 # CONFIG_USB_ARCH_HAS_HCD is not set
 # CONFIG_USB_ARCH_HAS_OHCI is not set
+# CONFIG_USB_ARCH_HAS_EHCI is not set
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
+#
 
 #
 # USB Gadget Support
@@ -537,39 +650,74 @@ CONFIG_DUMMY_CONSOLE=y
 #
 # CONFIG_MMC is not set
 
+#
+# LED devices
+#
+# CONFIG_NEW_LEDS is not set
+
+#
+# LED drivers
+#
+
+#
+# LED Triggers
+#
+
 #
 # InfiniBand support
 #
-# CONFIG_INFINIBAND is not set
+
+#
+# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
+#
+
+#
+# Real Time Clock
+#
+# CONFIG_RTC_CLASS is not set
+
+#
+# DMA Engine support
+#
+# CONFIG_DMA_ENGINE is not set
+
+#
+# DMA Clients
+#
+
+#
+# DMA Devices
+#
 
 #
 # File systems
 #
 CONFIG_EXT2_FS=y
 # CONFIG_EXT2_FS_XATTR is not set
-CONFIG_EXT3_FS=m
+# CONFIG_EXT2_FS_XIP is not set
+CONFIG_EXT3_FS=y
 CONFIG_EXT3_FS_XATTR=y
 # CONFIG_EXT3_FS_POSIX_ACL is not set
 # CONFIG_EXT3_FS_SECURITY is not set
-CONFIG_JBD=m
+# CONFIG_EXT4DEV_FS is not set
+CONFIG_JBD=y
 CONFIG_JBD_DEBUG=y
 CONFIG_FS_MBCACHE=y
-CONFIG_REISERFS_FS=m
-# CONFIG_REISERFS_CHECK is not set
-# CONFIG_REISERFS_PROC_INFO is not set
-# CONFIG_REISERFS_FS_XATTR is not set
+# CONFIG_REISERFS_FS is not set
 # CONFIG_JFS_FS is not set
-
-#
-# XFS support
-#
+# CONFIG_FS_POSIX_ACL is not set
 # CONFIG_XFS_FS is not set
+# CONFIG_GFS2_FS is not set
+# CONFIG_OCFS2_FS is not set
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
+CONFIG_INOTIFY=y
+CONFIG_INOTIFY_USER=y
 # CONFIG_QUOTA is not set
 CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
+# CONFIG_FUSE_FS is not set
 
 #
 # CD-ROM/DVD Filesystems
@@ -595,15 +743,13 @@ CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
 #
 CONFIG_PROC_FS=y
 CONFIG_PROC_KCORE=y
+CONFIG_PROC_SYSCTL=y
 CONFIG_SYSFS=y
-CONFIG_DEVFS_FS=y
-CONFIG_DEVFS_MOUNT=y
-# CONFIG_DEVFS_DEBUG is not set
-# CONFIG_DEVPTS_FS_XATTR is not set
 CONFIG_TMPFS=y
-# CONFIG_TMPFS_XATTR is not set
+# CONFIG_TMPFS_POSIX_ACL is not set
 # CONFIG_HUGETLB_PAGE is not set
 CONFIG_RAMFS=y
+# CONFIG_CONFIGFS_FS is not set
 
 #
 # Miscellaneous filesystems
@@ -627,12 +773,14 @@ CONFIG_RAMFS=y
 #
 CONFIG_NFS_FS=y
 CONFIG_NFS_V3=y
+# CONFIG_NFS_V3_ACL is not set
 # CONFIG_NFS_V4 is not set
 # CONFIG_NFS_DIRECTIO is not set
 # CONFIG_NFSD is not set
 CONFIG_ROOT_NFS=y
 CONFIG_LOCKD=y
 CONFIG_LOCKD_V4=y
+CONFIG_NFS_COMMON=y
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
 # CONFIG_RPCSEC_GSS_SPKM3 is not set
@@ -641,6 +789,7 @@ CONFIG_SUNRPC=y
 # CONFIG_NCP_FS is not set
 # CONFIG_CODA_FS is not set
 # CONFIG_AFS_FS is not set
+# CONFIG_9P_FS is not set
 
 #
 # Partition Types
@@ -701,10 +850,16 @@ CONFIG_NLS_DEFAULT="iso8859-1"
 # Kernel hacking
 #
 # CONFIG_PRINTK_TIME is not set
+CONFIG_ENABLE_MUST_CHECK=y
+# CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_UNUSED_SYMBOLS is not set
 # CONFIG_DEBUG_KERNEL is not set
 CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_DEBUG_BUGVERBOSE is not set
+# CONFIG_DEBUG_FS is not set
 # CONFIG_FRAME_POINTER is not set
+# CONFIG_UNWIND_INFO is not set
+# CONFIG_HEADERS_CHECK is not set
 
 #
 # Security options
@@ -717,13 +872,10 @@ CONFIG_LOG_BUF_SHIFT=14
 #
 # CONFIG_CRYPTO is not set
 
-#
-# Hardware crypto devices
-#
-
 #
 # Library routines
 #
 # CONFIG_CRC_CCITT is not set
+# CONFIG_CRC16 is not set
 CONFIG_CRC32=y
 # CONFIG_LIBCRC32C is not set
index 2eebe75fc07176c28878ee8d9a6d440cc923a2da..2f352267a6d9d3c39e937f888d752fab19cf91bb 100644 (file)
@@ -1,21 +1,18 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.12-rc5
-# Tue May 31 17:55:34 2005
+# Linux kernel version: 2.6.19
+# Mon Dec 11 19:57:33 2006
 #
 CONFIG_M32R=y
-# CONFIG_UID16 is not set
 CONFIG_GENERIC_ISA_DMA=y
 CONFIG_GENERIC_HARDIRQS=y
 CONFIG_GENERIC_IRQ_PROBE=y
+CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
 
 #
 # Code maturity level options
 #
 CONFIG_EXPERIMENTAL=y
-# CONFIG_CLEAN_COMPILE is not set
-CONFIG_BROKEN=y
-CONFIG_BROKEN_ON_SMP=y
 CONFIG_LOCK_KERNEL=y
 CONFIG_INIT_ENV_ARG_LIMIT=32
 
@@ -23,32 +20,39 @@ CONFIG_INIT_ENV_ARG_LIMIT=32
 # General setup
 #
 CONFIG_LOCALVERSION=""
+CONFIG_LOCALVERSION_AUTO=y
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
+# CONFIG_IPC_NS is not set
 # CONFIG_POSIX_MQUEUE is not set
 # CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
+# CONFIG_TASKSTATS is not set
+# CONFIG_UTS_NS is not set
 # CONFIG_AUDIT is not set
-CONFIG_HOTPLUG=y
-CONFIG_KOBJECT_UEVENT=y
 CONFIG_IKCONFIG=y
 CONFIG_IKCONFIG_PROC=y
 # CONFIG_CPUSETS is not set
+CONFIG_SYSFS_DEPRECATED=y
+# CONFIG_RELAY is not set
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SYSCTL=y
 CONFIG_EMBEDDED=y
+CONFIG_SYSCTL_SYSCALL=y
 # CONFIG_KALLSYMS is not set
+CONFIG_HOTPLUG=y
 CONFIG_PRINTK=y
 CONFIG_BUG=y
+CONFIG_ELF_CORE=y
 CONFIG_BASE_FULL=y
 # CONFIG_FUTEX is not set
 # CONFIG_EPOLL is not set
-# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
 CONFIG_SHMEM=y
-CONFIG_CC_ALIGN_FUNCTIONS=0
-CONFIG_CC_ALIGN_LABELS=0
-CONFIG_CC_ALIGN_LOOPS=0
-CONFIG_CC_ALIGN_JUMPS=0
+CONFIG_SLAB=y
+CONFIG_VM_EVENT_COUNTERS=y
 # CONFIG_TINY_SHMEM is not set
 CONFIG_BASE_SMALL=0
+# CONFIG_SLOB is not set
 
 #
 # Loadable module support
@@ -56,12 +60,30 @@ CONFIG_BASE_SMALL=0
 CONFIG_MODULES=y
 CONFIG_MODULE_UNLOAD=y
 # CONFIG_MODULE_FORCE_UNLOAD is not set
-CONFIG_OBSOLETE_MODPARM=y
 # CONFIG_MODVERSIONS is not set
 # CONFIG_MODULE_SRCVERSION_ALL is not set
 CONFIG_KMOD=y
 CONFIG_STOP_MACHINE=y
 
+#
+# Block layer
+#
+CONFIG_BLOCK=y
+# CONFIG_BLK_DEV_IO_TRACE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+# CONFIG_IOSCHED_AS is not set
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+# CONFIG_DEFAULT_AS is not set
+# CONFIG_DEFAULT_DEADLINE is not set
+CONFIG_DEFAULT_CFQ=y
+# CONFIG_DEFAULT_NOOP is not set
+CONFIG_DEFAULT_IOSCHED="cfq"
+
 #
 # Processor type and features
 #
@@ -72,8 +94,10 @@ CONFIG_STOP_MACHINE=y
 # CONFIG_PLAT_OAKS32R is not set
 # CONFIG_PLAT_MAPPI2 is not set
 CONFIG_PLAT_MAPPI3=y
+# CONFIG_PLAT_M32104UT is not set
 CONFIG_CHIP_M32700=y
 # CONFIG_CHIP_M32102 is not set
+# CONFIG_CHIP_M32104 is not set
 # CONFIG_CHIP_VDEC2 is not set
 # CONFIG_CHIP_OPSP is not set
 CONFIG_MMU=y
@@ -87,23 +111,33 @@ CONFIG_TIMER_DIVIDE=128
 CONFIG_MEMORY_START=0x08000000
 CONFIG_MEMORY_SIZE=0x08000000
 CONFIG_NOHIGHMEM=y
+CONFIG_ARCH_DISCONTIGMEM_ENABLE=y
+CONFIG_SELECT_MEMORY_MODEL=y
+# CONFIG_FLATMEM_MANUAL is not set
+CONFIG_DISCONTIGMEM_MANUAL=y
+# CONFIG_SPARSEMEM_MANUAL is not set
 CONFIG_DISCONTIGMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
+CONFIG_NEED_MULTIPLE_NODES=y
+# CONFIG_SPARSEMEM_STATIC is not set
+CONFIG_SPLIT_PTLOCK_CPUS=4
+# CONFIG_RESOURCES_64BIT is not set
 CONFIG_IRAM_START=0x00f00000
 CONFIG_IRAM_SIZE=0x00080000
 CONFIG_RWSEM_GENERIC_SPINLOCK=y
 # CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
+CONFIG_GENERIC_FIND_NEXT_BIT=y
+CONFIG_GENERIC_HWEIGHT=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_PREEMPT=y
-# CONFIG_HAVE_DEC_LOCK is not set
 CONFIG_SMP=y
 # CONFIG_CHIP_M32700_TS1 is not set
 CONFIG_NR_CPUS=2
-# CONFIG_NUMA is not set
+CONFIG_NODES_SHIFT=1
 
 #
 # Bus options (PCI, PCMCIA, EISA, MCA, ISA)
 #
-# CONFIG_PCI is not set
 # CONFIG_ISA is not set
 
 #
@@ -112,11 +146,12 @@ CONFIG_NR_CPUS=2
 CONFIG_PCCARD=y
 # CONFIG_PCMCIA_DEBUG is not set
 CONFIG_PCMCIA=y
+CONFIG_PCMCIA_LOAD_CIS=y
+CONFIG_PCMCIA_IOCTL=y
 
 #
 # PC-card bridges
 #
-# CONFIG_TCIC is not set
 # CONFIG_M32R_PCC is not set
 # CONFIG_M32R_CFC is not set
 
@@ -130,6 +165,93 @@ CONFIG_PCMCIA=y
 CONFIG_BINFMT_ELF=y
 # CONFIG_BINFMT_MISC is not set
 
+#
+# Networking
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+# CONFIG_NETDEBUG is not set
+# CONFIG_PACKET is not set
+CONFIG_UNIX=y
+CONFIG_XFRM=y
+# CONFIG_XFRM_USER is not set
+# CONFIG_XFRM_SUB_POLICY is not set
+# CONFIG_NET_KEY is not set
+CONFIG_INET=y
+# CONFIG_IP_MULTICAST is not set
+# CONFIG_IP_ADVANCED_ROUTER is not set
+CONFIG_IP_FIB_HASH=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+# CONFIG_IP_PNP_BOOTP is not set
+# CONFIG_IP_PNP_RARP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_ARPD is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_XFRM_TUNNEL is not set
+# CONFIG_INET_TUNNEL is not set
+CONFIG_INET_XFRM_MODE_TRANSPORT=y
+CONFIG_INET_XFRM_MODE_TUNNEL=y
+CONFIG_INET_XFRM_MODE_BEET=y
+CONFIG_INET_DIAG=y
+CONFIG_INET_TCP_DIAG=y
+# CONFIG_TCP_CONG_ADVANCED is not set
+CONFIG_TCP_CONG_CUBIC=y
+CONFIG_DEFAULT_TCP_CONG="cubic"
+# CONFIG_TCP_MD5SIG is not set
+# CONFIG_IPV6 is not set
+# CONFIG_INET6_XFRM_TUNNEL is not set
+# CONFIG_INET6_TUNNEL is not set
+# CONFIG_NETWORK_SECMARK is not set
+# CONFIG_NETFILTER is not set
+
+#
+# DCCP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_DCCP is not set
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_SCTP is not set
+
+#
+# TIPC Configuration (EXPERIMENTAL)
+#
+# CONFIG_TIPC is not set
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+# CONFIG_IEEE80211 is not set
+
 #
 # Device Drivers
 #
@@ -140,6 +262,12 @@ CONFIG_BINFMT_ELF=y
 CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
 CONFIG_FW_LOADER=y
+# CONFIG_SYS_HYPERVISOR is not set
+
+#
+# Connector - unified userspace <-> kernelspace linker
+#
+# CONFIG_CONNECTOR is not set
 
 #
 # Memory Technology Devices (MTD)
@@ -162,6 +290,8 @@ CONFIG_MTD_BLOCK=y
 # CONFIG_FTL is not set
 # CONFIG_NFTL is not set
 # CONFIG_INFTL is not set
+# CONFIG_RFD_FTL is not set
+# CONFIG_SSFDC is not set
 
 #
 # RAM/ROM/Flash chip drivers
@@ -187,6 +317,7 @@ CONFIG_MTD_CFI_I2=y
 # Mapping drivers for chip access
 #
 # CONFIG_MTD_COMPLEX_MAPPINGS is not set
+# CONFIG_MTD_PLATRAM is not set
 
 #
 # Self-contained MTD device drivers
@@ -194,7 +325,6 @@ CONFIG_MTD_CFI_I2=y
 # CONFIG_MTD_SLRAM is not set
 # CONFIG_MTD_PHRAM is not set
 # CONFIG_MTD_MTDRAM is not set
-# CONFIG_MTD_BLKMTD is not set
 # CONFIG_MTD_BLOCK2MTD is not set
 
 #
@@ -209,6 +339,11 @@ CONFIG_MTD_CFI_I2=y
 #
 # CONFIG_MTD_NAND is not set
 
+#
+# OneNAND Flash Device Drivers
+#
+# CONFIG_MTD_ONENAND is not set
+
 #
 # Parallel port support
 #
@@ -221,7 +356,6 @@ CONFIG_MTD_CFI_I2=y
 #
 # Block devices
 #
-# CONFIG_BLK_DEV_FD is not set
 # CONFIG_BLK_DEV_COW_COMMON is not set
 CONFIG_BLK_DEV_LOOP=y
 # CONFIG_BLK_DEV_CRYPTOLOOP is not set
@@ -229,23 +363,21 @@ CONFIG_BLK_DEV_NBD=m
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_COUNT=16
 CONFIG_BLK_DEV_RAM_SIZE=4096
+CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
 CONFIG_BLK_DEV_INITRD=y
-CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_CDROM_PKTCDVD is not set
+# CONFIG_ATA_OVER_ETH is not set
 
 #
-# IO Schedulers
+# Misc devices
 #
-CONFIG_IOSCHED_NOOP=y
-# CONFIG_IOSCHED_AS is not set
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
-# CONFIG_ATA_OVER_ETH is not set
+# CONFIG_TIFM_CORE is not set
 
 #
 # ATA/ATAPI/MFM/RLL support
 #
 CONFIG_IDE=y
+CONFIG_IDE_MAX_HWIFS=4
 CONFIG_BLK_DEV_IDE=y
 
 #
@@ -254,7 +386,7 @@ CONFIG_BLK_DEV_IDE=y
 # CONFIG_BLK_DEV_IDE_SATA is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
-CONFIG_BLK_DEV_IDECS=y
+CONFIG_BLK_DEV_IDECS=m
 CONFIG_BLK_DEV_IDECD=m
 # CONFIG_BLK_DEV_IDETAPE is not set
 # CONFIG_BLK_DEV_IDEFLOPPY is not set
@@ -272,7 +404,13 @@ CONFIG_IDE_GENERIC=y
 #
 # SCSI device support
 #
+# CONFIG_RAID_ATTRS is not set
 # CONFIG_SCSI is not set
+# CONFIG_SCSI_NETLINK is not set
+
+#
+# Serial ATA (prod) and Parallel ATA (experimental) drivers
+#
 
 #
 # Multi-device support (RAID and LVM)
@@ -282,85 +420,30 @@ CONFIG_IDE_GENERIC=y
 #
 # Fusion MPT device support
 #
+# CONFIG_FUSION is not set
 
 #
 # IEEE 1394 (FireWire) support
 #
-# CONFIG_IEEE1394 is not set
 
 #
 # I2O device support
 #
 
 #
-# Networking support
+# Network device support
 #
-CONFIG_NET=y
-
-#
-# Networking options
-#
-# CONFIG_PACKET is not set
-CONFIG_UNIX=y
-# CONFIG_NET_KEY is not set
-CONFIG_INET=y
-# CONFIG_IP_MULTICAST is not set
-# CONFIG_IP_ADVANCED_ROUTER is not set
-CONFIG_IP_PNP=y
-CONFIG_IP_PNP_DHCP=y
-# CONFIG_IP_PNP_BOOTP is not set
-# CONFIG_IP_PNP_RARP is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_ARPD is not set
-# CONFIG_SYN_COOKIES is not set
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-# CONFIG_INET_TUNNEL is not set
-CONFIG_IP_TCPDIAG=y
-# CONFIG_IP_TCPDIAG_IPV6 is not set
-# CONFIG_IPV6 is not set
-# CONFIG_NETFILTER is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_DECNET is not set
-# CONFIG_LLC2 is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-# CONFIG_NET_CLS_ROUTE is not set
-
-#
-# Network testing
-#
-# CONFIG_NET_PKTGEN is not set
-# CONFIG_NETPOLL is not set
-# CONFIG_NET_POLL_CONTROLLER is not set
-# CONFIG_HAMRADIO is not set
-# CONFIG_IRDA is not set
-# CONFIG_BT is not set
 CONFIG_NETDEVICES=y
 # CONFIG_DUMMY is not set
 # CONFIG_BONDING is not set
 # CONFIG_EQUALIZER is not set
 # CONFIG_TUN is not set
 
+#
+# PHY device support
+#
+# CONFIG_PHYLIB is not set
+
 #
 # Ethernet (10 or 100Mbit)
 #
@@ -399,6 +482,8 @@ CONFIG_SMC91X=y
 # CONFIG_SLIP is not set
 # CONFIG_SHAPER is not set
 # CONFIG_NETCONSOLE is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
 
 #
 # ISDN subsystem
@@ -414,6 +499,7 @@ CONFIG_SMC91X=y
 # Input device support
 #
 CONFIG_INPUT=y
+# CONFIG_INPUT_FF_MEMLESS is not set
 
 #
 # Userland interfaces
@@ -445,7 +531,6 @@ CONFIG_SERIO=y
 # CONFIG_SERIO_LIBPS2 is not set
 # CONFIG_SERIO_RAW is not set
 # CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
 
 #
 # Character devices
@@ -465,7 +550,6 @@ CONFIG_SERIAL_CORE=y
 CONFIG_SERIAL_CORE_CONSOLE=y
 CONFIG_SERIAL_M32R_SIO=y
 CONFIG_SERIAL_M32R_SIO_CONSOLE=y
-# CONFIG_SERIAL_M32R_PLDSIO is not set
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
@@ -479,39 +563,53 @@ CONFIG_LEGACY_PTY_COUNT=256
 # Watchdog Cards
 #
 # CONFIG_WATCHDOG is not set
+CONFIG_HW_RANDOM=y
 # CONFIG_RTC is not set
-# CONFIG_GEN_RTC is not set
 # CONFIG_DTLK is not set
 # CONFIG_R3964 is not set
 
 #
 # Ftape, the floppy tape device driver
 #
-# CONFIG_DRM is not set
 
 #
 # PCMCIA character devices
 #
 # CONFIG_SYNCLINK_CS is not set
+# CONFIG_CARDMAN_4000 is not set
+# CONFIG_CARDMAN_4040 is not set
 # CONFIG_RAW_DRIVER is not set
 
 #
 # TPM devices
 #
+# CONFIG_TCG_TPM is not set
 
 #
 # I2C support
 #
 # CONFIG_I2C is not set
 
+#
+# SPI support
+#
+# CONFIG_SPI is not set
+# CONFIG_SPI_MASTER is not set
+
 #
 # Dallas's 1-wire bus
 #
 # CONFIG_W1 is not set
 
 #
-# Misc devices
+# Hardware Monitoring support
 #
+CONFIG_HWMON=y
+# CONFIG_HWMON_VID is not set
+# CONFIG_SENSORS_ABITUGURU is not set
+# CONFIG_SENSORS_F71805F is not set
+# CONFIG_SENSORS_VT1211 is not set
+# CONFIG_HWMON_DEBUG_CHIP is not set
 
 #
 # Multimedia devices
@@ -526,7 +624,9 @@ CONFIG_LEGACY_PTY_COUNT=256
 #
 # Graphics support
 #
+CONFIG_FIRMWARE_EDID=y
 # CONFIG_FB is not set
+# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
 
 #
 # Sound
@@ -538,6 +638,11 @@ CONFIG_LEGACY_PTY_COUNT=256
 #
 # CONFIG_USB_ARCH_HAS_HCD is not set
 # CONFIG_USB_ARCH_HAS_OHCI is not set
+# CONFIG_USB_ARCH_HAS_EHCI is not set
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
+#
 
 #
 # USB Gadget Support
@@ -549,36 +654,74 @@ CONFIG_LEGACY_PTY_COUNT=256
 #
 # CONFIG_MMC is not set
 
+#
+# LED devices
+#
+# CONFIG_NEW_LEDS is not set
+
+#
+# LED drivers
+#
+
+#
+# LED Triggers
+#
+
 #
 # InfiniBand support
 #
-# CONFIG_INFINIBAND is not set
+
+#
+# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
+#
+
+#
+# Real Time Clock
+#
+# CONFIG_RTC_CLASS is not set
+
+#
+# DMA Engine support
+#
+# CONFIG_DMA_ENGINE is not set
+
+#
+# DMA Clients
+#
+
+#
+# DMA Devices
+#
 
 #
 # File systems
 #
 CONFIG_EXT2_FS=y
 # CONFIG_EXT2_FS_XATTR is not set
+# CONFIG_EXT2_FS_XIP is not set
 CONFIG_EXT3_FS=y
 CONFIG_EXT3_FS_XATTR=y
 # CONFIG_EXT3_FS_POSIX_ACL is not set
 # CONFIG_EXT3_FS_SECURITY is not set
+# CONFIG_EXT4DEV_FS is not set
 CONFIG_JBD=y
 # CONFIG_JBD_DEBUG is not set
 CONFIG_FS_MBCACHE=y
 # CONFIG_REISERFS_FS is not set
 # CONFIG_JFS_FS is not set
-
-#
-# XFS support
-#
+# CONFIG_FS_POSIX_ACL is not set
 # CONFIG_XFS_FS is not set
+# CONFIG_GFS2_FS is not set
+# CONFIG_OCFS2_FS is not set
 # CONFIG_MINIX_FS is not set
 CONFIG_ROMFS_FS=y
+CONFIG_INOTIFY=y
+CONFIG_INOTIFY_USER=y
 # CONFIG_QUOTA is not set
 CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
+# CONFIG_FUSE_FS is not set
 
 #
 # CD-ROM/DVD Filesystems
@@ -603,16 +746,13 @@ CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
 #
 CONFIG_PROC_FS=y
 CONFIG_PROC_KCORE=y
+CONFIG_PROC_SYSCTL=y
 CONFIG_SYSFS=y
-CONFIG_DEVFS_FS=y
-CONFIG_DEVFS_MOUNT=y
-# CONFIG_DEVFS_DEBUG is not set
-# CONFIG_DEVPTS_FS_XATTR is not set
 CONFIG_TMPFS=y
-# CONFIG_TMPFS_XATTR is not set
-# CONFIG_HUGETLBFS is not set
+# CONFIG_TMPFS_POSIX_ACL is not set
 # CONFIG_HUGETLB_PAGE is not set
 CONFIG_RAMFS=y
+# CONFIG_CONFIGFS_FS is not set
 
 #
 # Miscellaneous filesystems
@@ -629,8 +769,9 @@ CONFIG_JFFS_FS_VERBOSE=0
 CONFIG_JFFS_PROC_FS=y
 CONFIG_JFFS2_FS=y
 CONFIG_JFFS2_FS_DEBUG=0
-# CONFIG_JFFS2_FS_NAND is not set
-# CONFIG_JFFS2_FS_NOR_ECC is not set
+CONFIG_JFFS2_FS_WRITEBUFFER=y
+# CONFIG_JFFS2_SUMMARY is not set
+# CONFIG_JFFS2_FS_XATTR is not set
 # CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
 CONFIG_JFFS2_ZLIB=y
 CONFIG_JFFS2_RTIME=y
@@ -647,12 +788,14 @@ CONFIG_JFFS2_RTIME=y
 #
 CONFIG_NFS_FS=y
 CONFIG_NFS_V3=y
+# CONFIG_NFS_V3_ACL is not set
 # CONFIG_NFS_V4 is not set
 # CONFIG_NFS_DIRECTIO is not set
 # CONFIG_NFSD is not set
 CONFIG_ROOT_NFS=y
 CONFIG_LOCKD=y
 CONFIG_LOCKD_V4=y
+CONFIG_NFS_COMMON=y
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
 # CONFIG_RPCSEC_GSS_SPKM3 is not set
@@ -661,6 +804,7 @@ CONFIG_SUNRPC=y
 # CONFIG_NCP_FS is not set
 # CONFIG_CODA_FS is not set
 # CONFIG_AFS_FS is not set
+# CONFIG_9P_FS is not set
 
 #
 # Partition Types
@@ -721,10 +865,16 @@ CONFIG_NLS_DEFAULT="iso8859-1"
 # Kernel hacking
 #
 # CONFIG_PRINTK_TIME is not set
+CONFIG_ENABLE_MUST_CHECK=y
+# CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_UNUSED_SYMBOLS is not set
 # CONFIG_DEBUG_KERNEL is not set
 CONFIG_LOG_BUF_SHIFT=15
 # CONFIG_DEBUG_BUGVERBOSE is not set
+# CONFIG_DEBUG_FS is not set
 # CONFIG_FRAME_POINTER is not set
+# CONFIG_UNWIND_INFO is not set
+# CONFIG_HEADERS_CHECK is not set
 
 #
 # Security options
@@ -737,14 +887,11 @@ CONFIG_LOG_BUF_SHIFT=15
 #
 # CONFIG_CRYPTO is not set
 
-#
-# Hardware crypto devices
-#
-
 #
 # Library routines
 #
 # CONFIG_CRC_CCITT is not set
+# CONFIG_CRC16 is not set
 CONFIG_CRC32=y
 # CONFIG_LIBCRC32C is not set
 CONFIG_ZLIB_INFLATE=y
index 03fc4c858e0e01d521fac4a1aa2c55322b88bbdf..9880abac3f5488ffc7d5ccc1ea9f6bc2afd20604 100644 (file)
@@ -7,8 +7,6 @@
  *    Copyright (C) 1995  Linus Torvalds
  */
 
-/* $Id: fault-nommu.c,v 1.1 2004/03/30 06:40:59 sakugawa Exp $ */
-
 #include <linux/signal.h>
 #include <linux/sched.h>
 #include <linux/kernel.h>
@@ -46,32 +44,6 @@ unsigned int tlb_entry_d_dat[NR_CPUS];
 #define tlb_entry_d tlb_entry_d_dat[smp_processor_id()]
 #endif
 
-/*
- * Unlock any spinlocks which will prevent us from getting the
- * message out
- */
-void bust_spinlocks(int yes)
-{
-       int loglevel_save = console_loglevel;
-
-       if (yes) {
-               oops_in_progress = 1;
-               return;
-       }
-#ifdef CONFIG_VT
-       unblank_screen();
-#endif
-       oops_in_progress = 0;
-       /*
-        * OK, the message is on the console.  Now we call printk()
-        * without oops_in_progress set so that printk will give klogd
-        * a poke.  Hold onto your hats...
-        */
-       console_loglevel = 15;          /* NMI oopser may have shut the console up */
-       printk(" ");
-       console_loglevel = loglevel_save;
-}
-
 void do_BUG(const char *file, int line)
 {
        bust_spinlocks(1);
@@ -161,4 +133,3 @@ void local_flush_tlb_all(void)
 {
        BUG();
 }
-
index 9b9feb0f161075c09fb9f012017449e240f40cfa..037d58e82fb5a06319396fbb23670f0e1e939489 100644 (file)
@@ -49,32 +49,6 @@ unsigned int tlb_entry_d_dat[NR_CPUS];
 
 extern void init_tlb(void);
 
-/*
- * Unlock any spinlocks which will prevent us from getting the
- * message out
- */
-void bust_spinlocks(int yes)
-{
-       int loglevel_save = console_loglevel;
-
-       if (yes) {
-               oops_in_progress = 1;
-               return;
-       }
-#ifdef CONFIG_VT
-       unblank_screen();
-#endif
-       oops_in_progress = 0;
-       /*
-        * OK, the message is on the console.  Now we call printk()
-        * without oops_in_progress set so that printk will give klogd
-        * a poke.  Hold onto your hats...
-        */
-       console_loglevel = 15;          /* NMI oopser may have shut the console up */
-       printk(" ");
-       console_loglevel = loglevel_save;
-}
-
 /*======================================================================*
  * do_page_fault()
  *======================================================================*
@@ -362,8 +336,10 @@ vmalloc_fault:
                if (!pte_present(*pte_k))
                        goto no_context;
 
-               addr = (address & PAGE_MASK) | (error_code & ACE_INSTRUCTION);
+               addr = (address & PAGE_MASK);
+               set_thread_fault_code(error_code);
                update_mmu_cache(NULL, addr, *pte_k);
+               set_thread_fault_code(0);
                return;
        }
 }
@@ -377,7 +353,7 @@ vmalloc_fault:
 void update_mmu_cache(struct vm_area_struct *vma, unsigned long vaddr,
        pte_t pte)
 {
-       unsigned long *entry1, *entry2;
+       volatile unsigned long *entry1, *entry2;
        unsigned long pte_data, flags;
        unsigned int *entry_dat;
        int inst = get_thread_fault_code() & ACE_INSTRUCTION;
@@ -391,30 +367,26 @@ void update_mmu_cache(struct vm_area_struct *vma, unsigned long vaddr,
 
        vaddr = (vaddr & PAGE_MASK) | get_asid();
 
+       pte_data = pte_val(pte);
+
 #ifdef CONFIG_CHIP_OPSP
        entry1 = (unsigned long *)ITLB_BASE;
-       for(i = 0 ; i < NR_TLB_ENTRIES; i++) {
-               if(*entry1++ == vaddr) {
-                       pte_data = pte_val(pte);
-                       set_tlb_data(entry1, pte_data);
-                       break;
-               }
-               entry1++;
+       for (i = 0; i < NR_TLB_ENTRIES; i++) {
+               if (*entry1++ == vaddr) {
+                       set_tlb_data(entry1, pte_data);
+                       break;
+               }
+               entry1++;
        }
        entry2 = (unsigned long *)DTLB_BASE;
-       for(i = 0 ; i < NR_TLB_ENTRIES ; i++) {
-               if(*entry2++ == vaddr) {
-                       pte_data = pte_val(pte);
-                       set_tlb_data(entry2, pte_data);
-                       break;
-               }
-               entry2++;
+       for (i = 0; i < NR_TLB_ENTRIES; i++) {
+               if (*entry2++ == vaddr) {
+                       set_tlb_data(entry2, pte_data);
+                       break;
+               }
+               entry2++;
        }
-       local_irq_restore(flags);
-       return;
 #else
-       pte_data = pte_val(pte);
-
        /*
         * Update TLB entries
         *  entry1: ITLB entry address
@@ -439,6 +411,7 @@ void update_mmu_cache(struct vm_area_struct *vma, unsigned long vaddr,
                "i" (MSVA_offset), "i" (MTOP_offset), "i" (MIDXI_offset)
                : "r4", "memory"
        );
+#endif
 
        if ((!inst && entry2 >= DTLB_END) || (inst && entry1 >= ITLB_END))
                goto notfound;
@@ -482,7 +455,6 @@ notfound:
        set_tlb_data(entry1, pte_data);
 
        goto found;
-#endif
 }
 
 /*======================================================================*
index 9a4d40b3d6a26ceab9c021ba1d558371e1930880..8bb74b10dca76707a2d7c52e4fb3399fd3f26fbf 100644 (file)
@@ -4,8 +4,6 @@
  *  Copyright (C) 2001 by Hiroyuki Kondo
  */
 
-/* $Id: mmu.S,v 1.15 2004/03/16 02:56:27 takata Exp $ */
-
 #include <linux/linkage.h>
 #include <asm/assembler.h>
 #include <asm/smp.h>
@@ -345,5 +343,4 @@ ENTRY(m32r_otlb_entrys)
 
 #endif  /* CONFIG_MMU */
 
-.end
-
+       .end
index 3f9fe519acb2413e62ccb26ac004c4ddcc616277..aaa00828e0d38e746405417752a9fd6956eddf02 100644 (file)
@@ -1,19 +1,18 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.12-rc5
-# Fri Jun  3 16:22:04 2005
+# Linux kernel version: 2.6.19
+# Tue Dec 12 12:09:17 2006
 #
 CONFIG_M32R=y
-# CONFIG_UID16 is not set
 CONFIG_GENERIC_ISA_DMA=y
 CONFIG_GENERIC_HARDIRQS=y
 CONFIG_GENERIC_IRQ_PROBE=y
+CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
 
 #
 # Code maturity level options
 #
 CONFIG_EXPERIMENTAL=y
-CONFIG_CLEAN_COMPILE=y
 CONFIG_BROKEN_ON_SMP=y
 CONFIG_LOCK_KERNEL=y
 CONFIG_INIT_ENV_ARG_LIMIT=32
@@ -22,28 +21,35 @@ CONFIG_INIT_ENV_ARG_LIMIT=32
 # General setup
 #
 CONFIG_LOCALVERSION=""
+CONFIG_LOCALVERSION_AUTO=y
+# CONFIG_SYSVIPC is not set
 # CONFIG_POSIX_MQUEUE is not set
 CONFIG_BSD_PROCESS_ACCT=y
 # CONFIG_BSD_PROCESS_ACCT_V3 is not set
-CONFIG_SYSCTL=y
+# CONFIG_TASKSTATS is not set
+# CONFIG_UTS_NS is not set
 # CONFIG_AUDIT is not set
-CONFIG_HOTPLUG=y
-CONFIG_KOBJECT_UEVENT=y
 # CONFIG_IKCONFIG is not set
+CONFIG_SYSFS_DEPRECATED=y
+# CONFIG_RELAY is not set
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SYSCTL=y
 CONFIG_EMBEDDED=y
+CONFIG_SYSCTL_SYSCALL=y
 # CONFIG_KALLSYMS is not set
+CONFIG_HOTPLUG=y
 CONFIG_PRINTK=y
 CONFIG_BUG=y
+CONFIG_ELF_CORE=y
 CONFIG_BASE_FULL=y
 # CONFIG_FUTEX is not set
 # CONFIG_EPOLL is not set
-# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
-CONFIG_CC_ALIGN_FUNCTIONS=0
-CONFIG_CC_ALIGN_LABELS=0
-CONFIG_CC_ALIGN_LOOPS=0
-CONFIG_CC_ALIGN_JUMPS=0
+CONFIG_SLAB=y
+CONFIG_VM_EVENT_COUNTERS=y
 CONFIG_TINY_SHMEM=y
 CONFIG_BASE_SMALL=0
+# CONFIG_SLOB is not set
 
 #
 # Loadable module support
@@ -51,11 +57,29 @@ CONFIG_BASE_SMALL=0
 CONFIG_MODULES=y
 CONFIG_MODULE_UNLOAD=y
 # CONFIG_MODULE_FORCE_UNLOAD is not set
-CONFIG_OBSOLETE_MODPARM=y
 # CONFIG_MODVERSIONS is not set
 # CONFIG_MODULE_SRCVERSION_ALL is not set
 CONFIG_KMOD=y
 
+#
+# Block layer
+#
+CONFIG_BLOCK=y
+# CONFIG_BLK_DEV_IO_TRACE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+# CONFIG_IOSCHED_AS is not set
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+# CONFIG_DEFAULT_AS is not set
+# CONFIG_DEFAULT_DEADLINE is not set
+CONFIG_DEFAULT_CFQ=y
+# CONFIG_DEFAULT_NOOP is not set
+CONFIG_DEFAULT_IOSCHED="cfq"
+
 #
 # Processor type and features
 #
@@ -66,8 +90,10 @@ CONFIG_KMOD=y
 CONFIG_PLAT_OAKS32R=y
 # CONFIG_PLAT_MAPPI2 is not set
 # CONFIG_PLAT_MAPPI3 is not set
+# CONFIG_PLAT_M32104UT is not set
 # CONFIG_CHIP_M32700 is not set
 CONFIG_CHIP_M32102=y
+# CONFIG_CHIP_M32104 is not set
 # CONFIG_CHIP_VDEC2 is not set
 # CONFIG_CHIP_OPSP is not set
 CONFIG_ISA_M32R=y
@@ -77,18 +103,31 @@ CONFIG_TIMER_DIVIDE=128
 CONFIG_MEMORY_START=0x01000000
 CONFIG_MEMORY_SIZE=0x00800000
 CONFIG_NOHIGHMEM=y
-# CONFIG_DISCONTIGMEM is not set
+CONFIG_ARCH_DISCONTIGMEM_ENABLE=y
+CONFIG_SELECT_MEMORY_MODEL=y
+# CONFIG_FLATMEM_MANUAL is not set
+CONFIG_DISCONTIGMEM_MANUAL=y
+# CONFIG_SPARSEMEM_MANUAL is not set
+CONFIG_DISCONTIGMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
+CONFIG_NEED_MULTIPLE_NODES=y
+# CONFIG_SPARSEMEM_STATIC is not set
+CONFIG_SPLIT_PTLOCK_CPUS=4
+# CONFIG_RESOURCES_64BIT is not set
+CONFIG_IRAM_START=0x00f00000
+CONFIG_IRAM_SIZE=0x00010000
 CONFIG_RWSEM_GENERIC_SPINLOCK=y
 # CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
+CONFIG_GENERIC_FIND_NEXT_BIT=y
+CONFIG_GENERIC_HWEIGHT=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_PREEMPT=y
-# CONFIG_HAVE_DEC_LOCK is not set
 # CONFIG_SMP is not set
+CONFIG_NODES_SHIFT=1
 
 #
 # Bus options (PCI, PCMCIA, EISA, MCA, ISA)
 #
-# CONFIG_PCI is not set
 # CONFIG_ISA is not set
 
 #
@@ -108,6 +147,94 @@ CONFIG_BINFMT_FLAT=y
 # CONFIG_BINFMT_SHARED_FLAT is not set
 # CONFIG_BINFMT_MISC is not set
 
+#
+# Networking
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+# CONFIG_NETDEBUG is not set
+CONFIG_PACKET=y
+# CONFIG_PACKET_MMAP is not set
+CONFIG_UNIX=y
+CONFIG_XFRM=y
+# CONFIG_XFRM_USER is not set
+# CONFIG_XFRM_SUB_POLICY is not set
+# CONFIG_NET_KEY is not set
+CONFIG_INET=y
+# CONFIG_IP_MULTICAST is not set
+# CONFIG_IP_ADVANCED_ROUTER is not set
+CONFIG_IP_FIB_HASH=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+# CONFIG_IP_PNP_BOOTP is not set
+# CONFIG_IP_PNP_RARP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_ARPD is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_XFRM_TUNNEL is not set
+# CONFIG_INET_TUNNEL is not set
+CONFIG_INET_XFRM_MODE_TRANSPORT=y
+CONFIG_INET_XFRM_MODE_TUNNEL=y
+CONFIG_INET_XFRM_MODE_BEET=y
+CONFIG_INET_DIAG=y
+CONFIG_INET_TCP_DIAG=y
+# CONFIG_TCP_CONG_ADVANCED is not set
+CONFIG_TCP_CONG_CUBIC=y
+CONFIG_DEFAULT_TCP_CONG="cubic"
+# CONFIG_TCP_MD5SIG is not set
+# CONFIG_IPV6 is not set
+# CONFIG_INET6_XFRM_TUNNEL is not set
+# CONFIG_INET6_TUNNEL is not set
+# CONFIG_NETWORK_SECMARK is not set
+# CONFIG_NETFILTER is not set
+
+#
+# DCCP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_DCCP is not set
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_SCTP is not set
+
+#
+# TIPC Configuration (EXPERIMENTAL)
+#
+# CONFIG_TIPC is not set
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+# CONFIG_IEEE80211 is not set
+
 #
 # Device Drivers
 #
@@ -118,6 +245,12 @@ CONFIG_BINFMT_FLAT=y
 CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
 # CONFIG_FW_LOADER is not set
+# CONFIG_SYS_HYPERVISOR is not set
+
+#
+# Connector - unified userspace <-> kernelspace linker
+#
+# CONFIG_CONNECTOR is not set
 
 #
 # Memory Technology Devices (MTD)
@@ -136,7 +269,6 @@ CONFIG_PREVENT_FIRMWARE_BUILD=y
 #
 # Block devices
 #
-# CONFIG_BLK_DEV_FD is not set
 # CONFIG_BLK_DEV_COW_COMMON is not set
 CONFIG_BLK_DEV_LOOP=y
 # CONFIG_BLK_DEV_CRYPTOLOOP is not set
@@ -144,18 +276,15 @@ CONFIG_BLK_DEV_NBD=y
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_COUNT=16
 CONFIG_BLK_DEV_RAM_SIZE=4096
+CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
 # CONFIG_BLK_DEV_INITRD is not set
-CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_CDROM_PKTCDVD is not set
+# CONFIG_ATA_OVER_ETH is not set
 
 #
-# IO Schedulers
+# Misc devices
 #
-CONFIG_IOSCHED_NOOP=y
-# CONFIG_IOSCHED_AS is not set
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
-# CONFIG_ATA_OVER_ETH is not set
+# CONFIG_TIFM_CORE is not set
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -165,7 +294,13 @@ CONFIG_IOSCHED_CFQ=y
 #
 # SCSI device support
 #
+# CONFIG_RAID_ATTRS is not set
 # CONFIG_SCSI is not set
+# CONFIG_SCSI_NETLINK is not set
+
+#
+# Serial ATA (prod) and Parallel ATA (experimental) drivers
+#
 
 #
 # Multi-device support (RAID and LVM)
@@ -175,6 +310,7 @@ CONFIG_IOSCHED_CFQ=y
 #
 # Fusion MPT device support
 #
+# CONFIG_FUSION is not set
 
 #
 # IEEE 1394 (FireWire) support
@@ -185,75 +321,18 @@ CONFIG_IOSCHED_CFQ=y
 #
 
 #
-# Networking support
-#
-CONFIG_NET=y
-
-#
-# Networking options
-#
-CONFIG_PACKET=y
-# CONFIG_PACKET_MMAP is not set
-CONFIG_UNIX=y
-# CONFIG_NET_KEY is not set
-CONFIG_INET=y
-# CONFIG_IP_MULTICAST is not set
-# CONFIG_IP_ADVANCED_ROUTER is not set
-CONFIG_IP_PNP=y
-CONFIG_IP_PNP_DHCP=y
-# CONFIG_IP_PNP_BOOTP is not set
-# CONFIG_IP_PNP_RARP is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_ARPD is not set
-# CONFIG_SYN_COOKIES is not set
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-# CONFIG_INET_TUNNEL is not set
-CONFIG_IP_TCPDIAG=y
-# CONFIG_IP_TCPDIAG_IPV6 is not set
-# CONFIG_IPV6 is not set
-# CONFIG_NETFILTER is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_DECNET is not set
-# CONFIG_LLC2 is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-# CONFIG_NET_CLS_ROUTE is not set
-
-#
-# Network testing
+# Network device support
 #
-# CONFIG_NET_PKTGEN is not set
-# CONFIG_NETPOLL is not set
-# CONFIG_NET_POLL_CONTROLLER is not set
-# CONFIG_HAMRADIO is not set
-# CONFIG_IRDA is not set
-# CONFIG_BT is not set
 CONFIG_NETDEVICES=y
 # CONFIG_DUMMY is not set
 # CONFIG_BONDING is not set
 # CONFIG_EQUALIZER is not set
 # CONFIG_TUN is not set
 
+#
+# PHY device support
+#
+
 #
 # Ethernet (10 or 100Mbit)
 #
@@ -285,6 +364,8 @@ CONFIG_NE2000=y
 # CONFIG_SLIP is not set
 # CONFIG_SHAPER is not set
 # CONFIG_NETCONSOLE is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
 
 #
 # ISDN subsystem
@@ -300,6 +381,7 @@ CONFIG_NE2000=y
 # Input device support
 #
 CONFIG_INPUT=y
+# CONFIG_INPUT_FF_MEMLESS is not set
 
 #
 # Userland interfaces
@@ -328,7 +410,6 @@ CONFIG_SERIO_SERPORT=y
 # CONFIG_SERIO_LIBPS2 is not set
 # CONFIG_SERIO_RAW is not set
 # CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
 
 #
 # Character devices
@@ -348,7 +429,6 @@ CONFIG_SERIAL_CORE=y
 CONFIG_SERIAL_CORE_CONSOLE=y
 CONFIG_SERIAL_M32R_SIO=y
 CONFIG_SERIAL_M32R_SIO_CONSOLE=y
-# CONFIG_SERIAL_M32R_PLDSIO is not set
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
@@ -362,34 +442,46 @@ CONFIG_LEGACY_PTY_COUNT=256
 # Watchdog Cards
 #
 # CONFIG_WATCHDOG is not set
+CONFIG_HW_RANDOM=y
 # CONFIG_RTC is not set
-# CONFIG_GEN_RTC is not set
 # CONFIG_DTLK is not set
 # CONFIG_R3964 is not set
 
 #
 # Ftape, the floppy tape device driver
 #
-# CONFIG_DRM is not set
 # CONFIG_RAW_DRIVER is not set
 
 #
 # TPM devices
 #
+# CONFIG_TCG_TPM is not set
 
 #
 # I2C support
 #
 # CONFIG_I2C is not set
 
+#
+# SPI support
+#
+# CONFIG_SPI is not set
+# CONFIG_SPI_MASTER is not set
+
 #
 # Dallas's 1-wire bus
 #
 # CONFIG_W1 is not set
 
 #
-# Misc devices
+# Hardware Monitoring support
 #
+CONFIG_HWMON=y
+# CONFIG_HWMON_VID is not set
+# CONFIG_SENSORS_ABITUGURU is not set
+# CONFIG_SENSORS_F71805F is not set
+# CONFIG_SENSORS_VT1211 is not set
+# CONFIG_HWMON_DEBUG_CHIP is not set
 
 #
 # Multimedia devices
@@ -404,7 +496,9 @@ CONFIG_LEGACY_PTY_COUNT=256
 #
 # Graphics support
 #
+CONFIG_FIRMWARE_EDID=y
 # CONFIG_FB is not set
+# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
 
 #
 # Sound
@@ -416,6 +510,11 @@ CONFIG_LEGACY_PTY_COUNT=256
 #
 # CONFIG_USB_ARCH_HAS_HCD is not set
 # CONFIG_USB_ARCH_HAS_OHCI is not set
+# CONFIG_USB_ARCH_HAS_EHCI is not set
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
+#
 
 #
 # USB Gadget Support
@@ -427,10 +526,44 @@ CONFIG_LEGACY_PTY_COUNT=256
 #
 # CONFIG_MMC is not set
 
+#
+# LED devices
+#
+# CONFIG_NEW_LEDS is not set
+
+#
+# LED drivers
+#
+
+#
+# LED Triggers
+#
+
 #
 # InfiniBand support
 #
-# CONFIG_INFINIBAND is not set
+
+#
+# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
+#
+
+#
+# Real Time Clock
+#
+# CONFIG_RTC_CLASS is not set
+
+#
+# DMA Engine support
+#
+# CONFIG_DMA_ENGINE is not set
+
+#
+# DMA Clients
+#
+
+#
+# DMA Devices
+#
 
 #
 # File systems
@@ -438,20 +571,22 @@ CONFIG_LEGACY_PTY_COUNT=256
 CONFIG_EXT2_FS=y
 # CONFIG_EXT2_FS_XATTR is not set
 # CONFIG_EXT3_FS is not set
-# CONFIG_JBD is not set
+# CONFIG_EXT4DEV_FS is not set
 # CONFIG_REISERFS_FS is not set
 # CONFIG_JFS_FS is not set
-
-#
-# XFS support
-#
+# CONFIG_FS_POSIX_ACL is not set
 # CONFIG_XFS_FS is not set
+# CONFIG_GFS2_FS is not set
+# CONFIG_OCFS2_FS is not set
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
+CONFIG_INOTIFY=y
+CONFIG_INOTIFY_USER=y
 # CONFIG_QUOTA is not set
 CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
+# CONFIG_FUSE_FS is not set
 
 #
 # CD-ROM/DVD Filesystems
@@ -470,13 +605,12 @@ CONFIG_DNOTIFY=y
 # Pseudo filesystems
 #
 CONFIG_PROC_FS=y
+CONFIG_PROC_SYSCTL=y
 CONFIG_SYSFS=y
-# CONFIG_DEVFS_FS is not set
-CONFIG_DEVPTS_FS_XATTR=y
-CONFIG_DEVPTS_FS_SECURITY=y
 # CONFIG_TMPFS is not set
 # CONFIG_HUGETLB_PAGE is not set
 CONFIG_RAMFS=y
+# CONFIG_CONFIGFS_FS is not set
 
 #
 # Miscellaneous filesystems
@@ -500,12 +634,14 @@ CONFIG_RAMFS=y
 #
 CONFIG_NFS_FS=y
 CONFIG_NFS_V3=y
+# CONFIG_NFS_V3_ACL is not set
 # CONFIG_NFS_V4 is not set
 # CONFIG_NFS_DIRECTIO is not set
 # CONFIG_NFSD is not set
 CONFIG_ROOT_NFS=y
 CONFIG_LOCKD=y
 CONFIG_LOCKD_V4=y
+CONFIG_NFS_COMMON=y
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
 # CONFIG_RPCSEC_GSS_SPKM3 is not set
@@ -514,6 +650,7 @@ CONFIG_SUNRPC=y
 # CONFIG_NCP_FS is not set
 # CONFIG_CODA_FS is not set
 # CONFIG_AFS_FS is not set
+# CONFIG_9P_FS is not set
 
 #
 # Partition Types
@@ -574,10 +711,16 @@ CONFIG_NLS_DEFAULT="iso8859-1"
 # Kernel hacking
 #
 # CONFIG_PRINTK_TIME is not set
+CONFIG_ENABLE_MUST_CHECK=y
+# CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_UNUSED_SYMBOLS is not set
 # CONFIG_DEBUG_KERNEL is not set
 CONFIG_LOG_BUF_SHIFT=14
 # CONFIG_DEBUG_BUGVERBOSE is not set
+# CONFIG_DEBUG_FS is not set
 # CONFIG_FRAME_POINTER is not set
+# CONFIG_UNWIND_INFO is not set
+# CONFIG_HEADERS_CHECK is not set
 
 #
 # Security options
@@ -590,13 +733,10 @@ CONFIG_LOG_BUF_SHIFT=14
 #
 # CONFIG_CRYPTO is not set
 
-#
-# Hardware crypto devices
-#
-
 #
 # Library routines
 #
 # CONFIG_CRC_CCITT is not set
+# CONFIG_CRC16 is not set
 CONFIG_CRC32=y
 # CONFIG_LIBCRC32C is not set
index 66adec6a701adeba82cdf8a5fd9e69c2ef755d44..461f95e72d173bd1aed1db49ce277d62500db6f2 100644 (file)
@@ -1,19 +1,18 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.12-rc5
-# Fri Jun  3 16:22:06 2005
+# Linux kernel version: 2.6.19
+# Wed Dec 13 18:34:36 2006
 #
 CONFIG_M32R=y
-# CONFIG_UID16 is not set
 CONFIG_GENERIC_ISA_DMA=y
 CONFIG_GENERIC_HARDIRQS=y
 CONFIG_GENERIC_IRQ_PROBE=y
+CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
 
 #
 # Code maturity level options
 #
 CONFIG_EXPERIMENTAL=y
-CONFIG_CLEAN_COMPILE=y
 CONFIG_BROKEN_ON_SMP=y
 CONFIG_INIT_ENV_ARG_LIMIT=32
 
@@ -21,32 +20,39 @@ CONFIG_INIT_ENV_ARG_LIMIT=32
 # General setup
 #
 CONFIG_LOCALVERSION=""
+CONFIG_LOCALVERSION_AUTO=y
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
+# CONFIG_IPC_NS is not set
 # CONFIG_POSIX_MQUEUE is not set
 CONFIG_BSD_PROCESS_ACCT=y
 # CONFIG_BSD_PROCESS_ACCT_V3 is not set
-CONFIG_SYSCTL=y
+# CONFIG_TASKSTATS is not set
+# CONFIG_UTS_NS is not set
 # CONFIG_AUDIT is not set
-CONFIG_HOTPLUG=y
-CONFIG_KOBJECT_UEVENT=y
 CONFIG_IKCONFIG=y
 # CONFIG_IKCONFIG_PROC is not set
+CONFIG_SYSFS_DEPRECATED=y
+# CONFIG_RELAY is not set
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SYSCTL=y
 CONFIG_EMBEDDED=y
+CONFIG_SYSCTL_SYSCALL=y
 # CONFIG_KALLSYMS is not set
+CONFIG_HOTPLUG=y
 CONFIG_PRINTK=y
 CONFIG_BUG=y
+CONFIG_ELF_CORE=y
 CONFIG_BASE_FULL=y
 # CONFIG_FUTEX is not set
 # CONFIG_EPOLL is not set
-# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
 CONFIG_SHMEM=y
-CONFIG_CC_ALIGN_FUNCTIONS=0
-CONFIG_CC_ALIGN_LABELS=0
-CONFIG_CC_ALIGN_LOOPS=0
-CONFIG_CC_ALIGN_JUMPS=0
+CONFIG_SLAB=y
+CONFIG_VM_EVENT_COUNTERS=y
 # CONFIG_TINY_SHMEM is not set
 CONFIG_BASE_SMALL=0
+# CONFIG_SLOB is not set
 
 #
 # Loadable module support
@@ -54,11 +60,29 @@ CONFIG_BASE_SMALL=0
 CONFIG_MODULES=y
 CONFIG_MODULE_UNLOAD=y
 # CONFIG_MODULE_FORCE_UNLOAD is not set
-CONFIG_OBSOLETE_MODPARM=y
 # CONFIG_MODVERSIONS is not set
 # CONFIG_MODULE_SRCVERSION_ALL is not set
 CONFIG_KMOD=y
 
+#
+# Block layer
+#
+CONFIG_BLOCK=y
+# CONFIG_BLK_DEV_IO_TRACE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+# CONFIG_IOSCHED_AS is not set
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+# CONFIG_DEFAULT_AS is not set
+# CONFIG_DEFAULT_DEADLINE is not set
+CONFIG_DEFAULT_CFQ=y
+# CONFIG_DEFAULT_NOOP is not set
+CONFIG_DEFAULT_IOSCHED="cfq"
+
 #
 # Processor type and features
 #
@@ -69,8 +93,10 @@ CONFIG_PLAT_OPSPUT=y
 # CONFIG_PLAT_OAKS32R is not set
 # CONFIG_PLAT_MAPPI2 is not set
 # CONFIG_PLAT_MAPPI3 is not set
+# CONFIG_PLAT_M32104UT is not set
 # CONFIG_CHIP_M32700 is not set
 # CONFIG_CHIP_M32102 is not set
+# CONFIG_CHIP_M32104 is not set
 # CONFIG_CHIP_VDEC2 is not set
 CONFIG_CHIP_OPSP=y
 CONFIG_MMU=y
@@ -84,17 +110,31 @@ CONFIG_TIMER_DIVIDE=128
 CONFIG_MEMORY_START=0x08000000
 CONFIG_MEMORY_SIZE=0x01000000
 CONFIG_NOHIGHMEM=y
-# CONFIG_DISCONTIGMEM is not set
+CONFIG_ARCH_DISCONTIGMEM_ENABLE=y
+CONFIG_SELECT_MEMORY_MODEL=y
+# CONFIG_FLATMEM_MANUAL is not set
+CONFIG_DISCONTIGMEM_MANUAL=y
+# CONFIG_SPARSEMEM_MANUAL is not set
+CONFIG_DISCONTIGMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
+CONFIG_NEED_MULTIPLE_NODES=y
+# CONFIG_SPARSEMEM_STATIC is not set
+CONFIG_SPLIT_PTLOCK_CPUS=4
+# CONFIG_RESOURCES_64BIT is not set
+CONFIG_IRAM_START=0x00f00000
+CONFIG_IRAM_SIZE=0x00010000
 CONFIG_RWSEM_GENERIC_SPINLOCK=y
 # CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
+CONFIG_GENERIC_FIND_NEXT_BIT=y
+CONFIG_GENERIC_HWEIGHT=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
 # CONFIG_PREEMPT is not set
 # CONFIG_SMP is not set
+CONFIG_NODES_SHIFT=1
 
 #
 # Bus options (PCI, PCMCIA, EISA, MCA, ISA)
 #
-# CONFIG_PCI is not set
 # CONFIG_ISA is not set
 
 #
@@ -103,13 +143,15 @@ CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_PCCARD=y
 # CONFIG_PCMCIA_DEBUG is not set
 CONFIG_PCMCIA=y
+CONFIG_PCMCIA_LOAD_CIS=y
+CONFIG_PCMCIA_IOCTL=y
 
 #
 # PC-card bridges
 #
-# CONFIG_TCIC is not set
 CONFIG_M32R_CFC=y
 CONFIG_M32R_CFC_NUM=1
+CONFIG_PCCARD_NONSTATIC=y
 
 #
 # PCI Hotplug Support
@@ -121,6 +163,94 @@ CONFIG_M32R_CFC_NUM=1
 CONFIG_BINFMT_ELF=y
 # CONFIG_BINFMT_MISC is not set
 
+#
+# Networking
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+# CONFIG_NETDEBUG is not set
+CONFIG_PACKET=y
+# CONFIG_PACKET_MMAP is not set
+CONFIG_UNIX=y
+CONFIG_XFRM=y
+# CONFIG_XFRM_USER is not set
+# CONFIG_XFRM_SUB_POLICY is not set
+# CONFIG_NET_KEY is not set
+CONFIG_INET=y
+# CONFIG_IP_MULTICAST is not set
+# CONFIG_IP_ADVANCED_ROUTER is not set
+CONFIG_IP_FIB_HASH=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+# CONFIG_IP_PNP_BOOTP is not set
+# CONFIG_IP_PNP_RARP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_ARPD is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_XFRM_TUNNEL is not set
+# CONFIG_INET_TUNNEL is not set
+CONFIG_INET_XFRM_MODE_TRANSPORT=y
+CONFIG_INET_XFRM_MODE_TUNNEL=y
+CONFIG_INET_XFRM_MODE_BEET=y
+CONFIG_INET_DIAG=y
+CONFIG_INET_TCP_DIAG=y
+# CONFIG_TCP_CONG_ADVANCED is not set
+CONFIG_TCP_CONG_CUBIC=y
+CONFIG_DEFAULT_TCP_CONG="cubic"
+# CONFIG_TCP_MD5SIG is not set
+# CONFIG_IPV6 is not set
+# CONFIG_INET6_XFRM_TUNNEL is not set
+# CONFIG_INET6_TUNNEL is not set
+# CONFIG_NETWORK_SECMARK is not set
+# CONFIG_NETFILTER is not set
+
+#
+# DCCP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_DCCP is not set
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_SCTP is not set
+
+#
+# TIPC Configuration (EXPERIMENTAL)
+#
+# CONFIG_TIPC is not set
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+# CONFIG_IEEE80211 is not set
+
 #
 # Device Drivers
 #
@@ -130,8 +260,14 @@ CONFIG_BINFMT_ELF=y
 #
 CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
-# CONFIG_FW_LOADER is not set
+CONFIG_FW_LOADER=y
 # CONFIG_DEBUG_DRIVER is not set
+# CONFIG_SYS_HYPERVISOR is not set
+
+#
+# Connector - unified userspace <-> kernelspace linker
+#
+# CONFIG_CONNECTOR is not set
 
 #
 # Memory Technology Devices (MTD)
@@ -150,7 +286,6 @@ CONFIG_PREVENT_FIRMWARE_BUILD=y
 #
 # Block devices
 #
-# CONFIG_BLK_DEV_FD is not set
 # CONFIG_BLK_DEV_COW_COMMON is not set
 CONFIG_BLK_DEV_LOOP=y
 # CONFIG_BLK_DEV_CRYPTOLOOP is not set
@@ -158,18 +293,15 @@ CONFIG_BLK_DEV_LOOP=y
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_COUNT=16
 CONFIG_BLK_DEV_RAM_SIZE=4096
+CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
 # CONFIG_BLK_DEV_INITRD is not set
-CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_CDROM_PKTCDVD is not set
+# CONFIG_ATA_OVER_ETH is not set
 
 #
-# IO Schedulers
+# Misc devices
 #
-CONFIG_IOSCHED_NOOP=y
-# CONFIG_IOSCHED_AS is not set
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
-# CONFIG_ATA_OVER_ETH is not set
+# CONFIG_TIFM_CORE is not set
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -179,7 +311,9 @@ CONFIG_IOSCHED_CFQ=y
 #
 # SCSI device support
 #
+# CONFIG_RAID_ATTRS is not set
 CONFIG_SCSI=m
+# CONFIG_SCSI_NETLINK is not set
 CONFIG_SCSI_PROC_FS=y
 
 #
@@ -191,6 +325,7 @@ CONFIG_BLK_DEV_SD=m
 CONFIG_BLK_DEV_SR=m
 # CONFIG_BLK_DEV_SR_VENDOR is not set
 CONFIG_CHR_DEV_SG=m
+# CONFIG_CHR_DEV_SCH is not set
 
 #
 # Some SCSI devices (e.g. CD jukebox) support multiple LUNs
@@ -200,16 +335,18 @@ CONFIG_SCSI_MULTI_LUN=y
 # CONFIG_SCSI_LOGGING is not set
 
 #
-# SCSI Transport Attributes
+# SCSI Transports
 #
 # CONFIG_SCSI_SPI_ATTRS is not set
 # CONFIG_SCSI_FC_ATTRS is not set
 # CONFIG_SCSI_ISCSI_ATTRS is not set
+# CONFIG_SCSI_SAS_ATTRS is not set
+# CONFIG_SCSI_SAS_LIBSAS is not set
 
 #
 # SCSI low-level drivers
 #
-# CONFIG_SCSI_SATA is not set
+# CONFIG_ISCSI_TCP is not set
 # CONFIG_SCSI_DEBUG is not set
 
 #
@@ -221,6 +358,10 @@ CONFIG_SCSI_MULTI_LUN=y
 # CONFIG_PCMCIA_QLOGIC is not set
 # CONFIG_PCMCIA_SYM53C500 is not set
 
+#
+# Serial ATA (prod) and Parallel ATA (experimental) drivers
+#
+
 #
 # Multi-device support (RAID and LVM)
 #
@@ -229,6 +370,7 @@ CONFIG_SCSI_MULTI_LUN=y
 #
 # Fusion MPT device support
 #
+# CONFIG_FUSION is not set
 
 #
 # IEEE 1394 (FireWire) support
@@ -239,75 +381,19 @@ CONFIG_SCSI_MULTI_LUN=y
 #
 
 #
-# Networking support
-#
-CONFIG_NET=y
-
-#
-# Networking options
-#
-CONFIG_PACKET=y
-# CONFIG_PACKET_MMAP is not set
-CONFIG_UNIX=y
-# CONFIG_NET_KEY is not set
-CONFIG_INET=y
-# CONFIG_IP_MULTICAST is not set
-# CONFIG_IP_ADVANCED_ROUTER is not set
-CONFIG_IP_PNP=y
-CONFIG_IP_PNP_DHCP=y
-# CONFIG_IP_PNP_BOOTP is not set
-# CONFIG_IP_PNP_RARP is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_ARPD is not set
-# CONFIG_SYN_COOKIES is not set
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-# CONFIG_INET_TUNNEL is not set
-CONFIG_IP_TCPDIAG=y
-# CONFIG_IP_TCPDIAG_IPV6 is not set
-# CONFIG_IPV6 is not set
-# CONFIG_NETFILTER is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
+# Network device support
 #
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_DECNET is not set
-# CONFIG_LLC2 is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-# CONFIG_NET_CLS_ROUTE is not set
-
-#
-# Network testing
-#
-# CONFIG_NET_PKTGEN is not set
-# CONFIG_NETPOLL is not set
-# CONFIG_NET_POLL_CONTROLLER is not set
-# CONFIG_HAMRADIO is not set
-# CONFIG_IRDA is not set
-# CONFIG_BT is not set
 CONFIG_NETDEVICES=y
 # CONFIG_DUMMY is not set
 # CONFIG_BONDING is not set
 # CONFIG_EQUALIZER is not set
 # CONFIG_TUN is not set
 
+#
+# PHY device support
+#
+# CONFIG_PHYLIB is not set
+
 #
 # Ethernet (10 or 100Mbit)
 #
@@ -346,6 +432,8 @@ CONFIG_SMC91X=y
 # CONFIG_SLIP is not set
 # CONFIG_SHAPER is not set
 # CONFIG_NETCONSOLE is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
 
 #
 # ISDN subsystem
@@ -361,6 +449,7 @@ CONFIG_SMC91X=y
 # Input device support
 #
 CONFIG_INPUT=y
+# CONFIG_INPUT_FF_MEMLESS is not set
 
 #
 # Userland interfaces
@@ -389,7 +478,6 @@ CONFIG_SERIO_SERPORT=y
 # CONFIG_SERIO_LIBPS2 is not set
 # CONFIG_SERIO_RAW is not set
 # CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
 
 #
 # Character devices
@@ -423,8 +511,8 @@ CONFIG_LEGACY_PTY_COUNT=256
 # Watchdog Cards
 #
 # CONFIG_WATCHDOG is not set
+CONFIG_HW_RANDOM=y
 # CONFIG_RTC is not set
-# CONFIG_GEN_RTC is not set
 CONFIG_DS1302=y
 # CONFIG_DTLK is not set
 # CONFIG_R3964 is not set
@@ -432,31 +520,45 @@ CONFIG_DS1302=y
 #
 # Ftape, the floppy tape device driver
 #
-# CONFIG_DRM is not set
 
 #
 # PCMCIA character devices
 #
 # CONFIG_SYNCLINK_CS is not set
+# CONFIG_CARDMAN_4000 is not set
+# CONFIG_CARDMAN_4040 is not set
 # CONFIG_RAW_DRIVER is not set
 
 #
 # TPM devices
 #
+# CONFIG_TCG_TPM is not set
 
 #
 # I2C support
 #
 # CONFIG_I2C is not set
 
+#
+# SPI support
+#
+# CONFIG_SPI is not set
+# CONFIG_SPI_MASTER is not set
+
 #
 # Dallas's 1-wire bus
 #
 # CONFIG_W1 is not set
 
 #
-# Misc devices
+# Hardware Monitoring support
 #
+CONFIG_HWMON=y
+# CONFIG_HWMON_VID is not set
+# CONFIG_SENSORS_ABITUGURU is not set
+# CONFIG_SENSORS_F71805F is not set
+# CONFIG_SENSORS_VT1211 is not set
+# CONFIG_HWMON_DEBUG_CHIP is not set
 
 #
 # Multimedia devices
@@ -471,7 +573,9 @@ CONFIG_DS1302=y
 #
 # Graphics support
 #
+CONFIG_FIRMWARE_EDID=y
 # CONFIG_FB is not set
+# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
 
 #
 # Sound
@@ -483,6 +587,11 @@ CONFIG_DS1302=y
 #
 # CONFIG_USB_ARCH_HAS_HCD is not set
 # CONFIG_USB_ARCH_HAS_OHCI is not set
+# CONFIG_USB_ARCH_HAS_EHCI is not set
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
+#
 
 #
 # USB Gadget Support
@@ -494,39 +603,74 @@ CONFIG_DS1302=y
 #
 # CONFIG_MMC is not set
 
+#
+# LED devices
+#
+# CONFIG_NEW_LEDS is not set
+
+#
+# LED drivers
+#
+
+#
+# LED Triggers
+#
+
 #
 # InfiniBand support
 #
-# CONFIG_INFINIBAND is not set
+
+#
+# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
+#
+
+#
+# Real Time Clock
+#
+# CONFIG_RTC_CLASS is not set
+
+#
+# DMA Engine support
+#
+# CONFIG_DMA_ENGINE is not set
+
+#
+# DMA Clients
+#
+
+#
+# DMA Devices
+#
 
 #
 # File systems
 #
 CONFIG_EXT2_FS=y
 # CONFIG_EXT2_FS_XATTR is not set
-CONFIG_EXT3_FS=m
+# CONFIG_EXT2_FS_XIP is not set
+CONFIG_EXT3_FS=y
 CONFIG_EXT3_FS_XATTR=y
 # CONFIG_EXT3_FS_POSIX_ACL is not set
 # CONFIG_EXT3_FS_SECURITY is not set
-CONFIG_JBD=m
+# CONFIG_EXT4DEV_FS is not set
+CONFIG_JBD=y
 CONFIG_JBD_DEBUG=y
 CONFIG_FS_MBCACHE=y
-CONFIG_REISERFS_FS=m
-# CONFIG_REISERFS_CHECK is not set
-# CONFIG_REISERFS_PROC_INFO is not set
-# CONFIG_REISERFS_FS_XATTR is not set
+# CONFIG_REISERFS_FS is not set
 # CONFIG_JFS_FS is not set
-
-#
-# XFS support
-#
+# CONFIG_FS_POSIX_ACL is not set
 # CONFIG_XFS_FS is not set
+# CONFIG_GFS2_FS is not set
+# CONFIG_OCFS2_FS is not set
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
+CONFIG_INOTIFY=y
+CONFIG_INOTIFY_USER=y
 # CONFIG_QUOTA is not set
 CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
+# CONFIG_FUSE_FS is not set
 
 #
 # CD-ROM/DVD Filesystems
@@ -552,15 +696,13 @@ CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
 #
 CONFIG_PROC_FS=y
 CONFIG_PROC_KCORE=y
+CONFIG_PROC_SYSCTL=y
 CONFIG_SYSFS=y
-CONFIG_DEVFS_FS=y
-CONFIG_DEVFS_MOUNT=y
-# CONFIG_DEVFS_DEBUG is not set
-# CONFIG_DEVPTS_FS_XATTR is not set
 CONFIG_TMPFS=y
-# CONFIG_TMPFS_XATTR is not set
+# CONFIG_TMPFS_POSIX_ACL is not set
 # CONFIG_HUGETLB_PAGE is not set
 CONFIG_RAMFS=y
+# CONFIG_CONFIGFS_FS is not set
 
 #
 # Miscellaneous filesystems
@@ -584,12 +726,14 @@ CONFIG_RAMFS=y
 #
 CONFIG_NFS_FS=y
 CONFIG_NFS_V3=y
+# CONFIG_NFS_V3_ACL is not set
 # CONFIG_NFS_V4 is not set
 # CONFIG_NFS_DIRECTIO is not set
 # CONFIG_NFSD is not set
 CONFIG_ROOT_NFS=y
 CONFIG_LOCKD=y
 CONFIG_LOCKD_V4=y
+CONFIG_NFS_COMMON=y
 CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
 # CONFIG_RPCSEC_GSS_SPKM3 is not set
@@ -598,6 +742,7 @@ CONFIG_SUNRPC=y
 # CONFIG_NCP_FS is not set
 # CONFIG_CODA_FS is not set
 # CONFIG_AFS_FS is not set
+# CONFIG_9P_FS is not set
 
 #
 # Partition Types
@@ -658,21 +803,32 @@ CONFIG_NLS_DEFAULT="iso8859-1"
 # Kernel hacking
 #
 # CONFIG_PRINTK_TIME is not set
-CONFIG_DEBUG_KERNEL=y
+CONFIG_ENABLE_MUST_CHECK=y
 # CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_UNUSED_SYMBOLS is not set
+CONFIG_DEBUG_KERNEL=y
 CONFIG_LOG_BUF_SHIFT=14
+CONFIG_DETECT_SOFTLOCKUP=y
 # CONFIG_SCHEDSTATS is not set
 # CONFIG_DEBUG_SLAB is not set
 # CONFIG_DEBUG_SPINLOCK is not set
+# CONFIG_DEBUG_MUTEXES is not set
+# CONFIG_DEBUG_RWSEMS is not set
 # CONFIG_DEBUG_SPINLOCK_SLEEP is not set
+# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
 # CONFIG_DEBUG_KOBJECT is not set
 # CONFIG_DEBUG_BUGVERBOSE is not set
 CONFIG_DEBUG_INFO=y
 # CONFIG_DEBUG_FS is not set
+# CONFIG_DEBUG_VM is not set
+# CONFIG_DEBUG_LIST is not set
 # CONFIG_FRAME_POINTER is not set
+# CONFIG_UNWIND_INFO is not set
+CONFIG_FORCED_INLINING=y
+# CONFIG_HEADERS_CHECK is not set
+# CONFIG_RCU_TORTURE_TEST is not set
 # CONFIG_DEBUG_STACKOVERFLOW is not set
 # CONFIG_DEBUG_STACK_USAGE is not set
-# CONFIG_DEBUG_PAGEALLOC is not set
 
 #
 # Security options
@@ -685,13 +841,10 @@ CONFIG_DEBUG_INFO=y
 #
 # CONFIG_CRYPTO is not set
 
-#
-# Hardware crypto devices
-#
-
 #
 # Library routines
 #
 # CONFIG_CRC_CCITT is not set
+# CONFIG_CRC16 is not set
 CONFIG_CRC32=y
 # CONFIG_LIBCRC32C is not set
index 70a577c89c7c84d279d9ce9f9c08f1c0bbaa08db..a8e1e604dfa81427b19d77a1ae3d81fdfb9841c8 100644 (file)
@@ -42,6 +42,9 @@ config ARCH_MAY_HAVE_PC_FDC
        depends on Q40 || (BROKEN && SUN3X)
        default y
 
+config NO_IOPORT
+       def_bool y
+
 mainmenu "Linux/68k Kernel Configuration"
 
 source "init/Kconfig"
@@ -439,6 +442,10 @@ config GENERIC_ISA_DMA
        depends on Q40 || AMIGA_PCMCIA || GG2
        default y
 
+config ZONE_DMA
+       bool
+       default y
+
 source "drivers/pci/Kconfig"
 
 source "drivers/zorro/Kconfig"
index 1c9ecaa473d5795e90ef0540ae3c9accedec9a20..0b68ab8d63d1d5a120f9e4403b317ecdbfd71308 100644 (file)
@@ -10,7 +10,9 @@ endif
 extra-y        += vmlinux.lds
 
 obj-y  := entry.o process.o traps.o ints.o signal.o ptrace.o \
-          sys_m68k.o time.o semaphore.o setup.o m68k_ksyms.o
+          sys_m68k.o time.o semaphore.o setup.o m68k_ksyms.o devres.o
+
+devres-y = ../../../kernel/irq/devres.o
 
 obj-$(CONFIG_PCI)      += bios32.o
 obj-$(CONFIG_MODULES)  += module.o
index ef89060ea328374d25fe9d03a8a449cf9126d52f..7fd2720c38416f422d70d695d8dc73c67ed0a7b5 100644 (file)
@@ -76,7 +76,7 @@ static inline long get_reg(struct task_struct *task, int regno)
 
        if (regno == PT_USP)
                addr = &task->thread.usp;
-       else if (regno < sizeof(regoff)/sizeof(regoff[0]))
+       else if (regno < ARRAY_SIZE(regoff))
                addr = (unsigned long *)(task->thread.esp0 + regoff[regno]);
        else
                return 0;
@@ -93,7 +93,7 @@ static inline int put_reg(struct task_struct *task, int regno,
 
        if (regno == PT_USP)
                addr = &task->thread.usp;
-       else if (regno < sizeof(regoff)/sizeof(regoff[0]))
+       else if (regno < ARRAY_SIZE(regoff))
                addr = (unsigned long *)(task->thread.esp0 + regoff[regno]);
        else
                return -1;
index 2a599c3ed7878322239737583dd0137399e19077..4c065f9ceffcd5ab7fcfe6e8de09b3e6d2adacc9 100644 (file)
@@ -159,12 +159,3 @@ int do_settimeofday(struct timespec *tv)
 }
 
 EXPORT_SYMBOL(do_settimeofday);
-
-/*
- * Scheduler clock - returns current time in ns units.
- */
-unsigned long long sched_clock(void)
-{
-       return (unsigned long long)jiffies*(1000000000/HZ);
-}
-
index 759fa244e6cd60cc5e226c486525e64b43aae190..a27a4fa332962a6c35918c1f28c3f6494c026453 100644 (file)
@@ -1011,7 +1011,7 @@ EXPORT_SYMBOL(dump_stack);
 void bad_super_trap (struct frame *fp)
 {
        console_verbose();
-       if (fp->ptregs.vector < 4*sizeof(vec_names)/sizeof(vec_names[0]))
+       if (fp->ptregs.vector < 4 * ARRAY_SIZE(vec_names))
                printk ("*** %s ***   FORMAT=%X\n",
                        vec_names[(fp->ptregs.vector) >> 2],
                        fp->ptregs.format);
index d2794452b195cbcafd1bca92c069df1f85ebdb23..437b4f8d86c58200d15fcce3a0eaa6d99d9a98d3 100644 (file)
@@ -61,10 +61,12 @@ SECTIONS
   .con_initcall.init : { *(.con_initcall.init) }
   __con_initcall_end = .;
   SECURITY_INIT
+#ifdef CONFIG_BLK_DEV_INITRD
   . = ALIGN(8192);
   __initramfs_start = .;
   .init.ramfs : { *(.init.ramfs) }
   __initramfs_end = .;
+#endif
   . = ALIGN(8192);
   __init_end = .;
 
index 8c7eccbfc982e31205f37cb7a062b713faa60efd..2868e206fc76816a5cb795fb31632b5e35c7d713 100644 (file)
@@ -55,10 +55,12 @@ __init_begin = .;
        .con_initcall.init : { *(.con_initcall.init) }
        __con_initcall_end = .;
        SECURITY_INIT
+#ifdef CONFIG_BLK_DEV_INITRD
        . = ALIGN(8192);
        __initramfs_start = .;
        .init.ramfs : { *(.init.ramfs) }
        __initramfs_end = .;
+#endif
        . = ALIGN(8192);
        __init_end = .;
        .data.init.task : { *(.data.init_task) }
index 25993c2a8fbbeb4c540218980f05d22c60a9dfcb..823f73736bb5b3c8a35f84e608302224e3abcedd 100644 (file)
@@ -17,6 +17,10 @@ config FPU
        bool
        default n
 
+config ZONE_DMA
+       bool
+       default y
+
 config RWSEM_GENERIC_SPINLOCK
        bool
        default y
@@ -49,6 +53,9 @@ config TIME_LOW_RES
        bool
        default y
 
+config NO_IOPORT
+       def_bool y
+
 source "init/Kconfig"
 
 menu "Processor type and features"
index 9130119537b9ffdbe082e9857f0ea9c657ae159b..72d34962357519477ea234a93e928402a759fc82 100644 (file)
@@ -62,7 +62,7 @@ static inline long get_reg(struct task_struct *task, int regno)
 
        if (regno == PT_USP)
                addr = &task->thread.usp;
-       else if (regno < sizeof(regoff)/sizeof(regoff[0]))
+       else if (regno < ARRAY_SIZE(regoff))
                addr = (unsigned long *)(task->thread.esp0 + regoff[regno]);
        else
                return 0;
@@ -79,7 +79,7 @@ static inline int put_reg(struct task_struct *task, int regno,
 
        if (regno == PT_USP)
                addr = &task->thread.usp;
-       else if (regno < sizeof(regoff)/sizeof(regoff[0]))
+       else if (regno < ARRAY_SIZE(regoff))
                addr = (unsigned long *) (task->thread.esp0 + regoff[regno]);
        else
                return -1;
index 9226264abf1ab610846d9df98afa4a9c9dfca91d..467053da2d08343d29f77c7cc31529c7caef8e54 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <asm/machdep.h>
 #include <asm/io.h>
+#include <asm/irq_regs.h>
 
 #define        TICK_SIZE (tick_nsec / 1000)
 
@@ -38,7 +39,7 @@ static inline int set_rtc_mmss(unsigned long nowtime)
  * timer_interrupt() needs to keep up the real-time clock,
  * as well as call the "do_timer()" routine every clocktick
  */
-static irqreturn_t timer_interrupt(int irq, void *dummy, struct pt_regs * regs)
+static irqreturn_t timer_interrupt(int irq, void *dummy)
 {
        /* last time the cmos clock got updated */
        static long last_rtc_update=0;
@@ -51,7 +52,7 @@ static irqreturn_t timer_interrupt(int irq, void *dummy, struct pt_regs * regs)
 
        do_timer(1);
 #ifndef CONFIG_SMP
-       update_process_times(user_mode(regs));
+       update_process_times(user_mode(get_irq_regs()));
 #endif
        if (current->pid)
                profile_tick(CPU_PROFILING);
@@ -173,13 +174,4 @@ int do_settimeofday(struct timespec *tv)
        clock_was_set();
        return 0;
 }
-
-/*
- * Scheduler clock - returns current time in nanosec units.
- */
-unsigned long long sched_clock(void)
-{
-       return (unsigned long long)jiffies * (1000000000 / HZ);
-}
-
 EXPORT_SYMBOL(do_settimeofday);
index 9129b3a5258bc28a8e832eea7dcd809bb7860c44..bed5f47bf568c05c940d19a289085ba5ea4fdbf5 100644 (file)
@@ -158,7 +158,7 @@ void show_stack(struct task_struct *task, unsigned long *stack)
 void bad_super_trap(struct frame *fp)
 {
        console_verbose();
-       if (fp->ptregs.vector < 4*sizeof(vec_names)/sizeof(vec_names[0]))
+       if (fp->ptregs.vector < 4 * ARRAY_SIZE(vec_names))
                printk (KERN_WARNING "*** %s ***   FORMAT=%X\n",
                        vec_names[(fp->ptregs.vector) >> 2],
                        fp->ptregs.format);
index 2b2a10da64a4b3af8e8daebaadc876314bc8fcd9..c86a1bf589d4582fb9cf6ee3bac1dc070556333f 100644 (file)
@@ -87,6 +87,16 @@ SECTIONS {
                *(__ksymtab_gpl)
                __stop___ksymtab_gpl = .;
 
+               /* Kernel symbol table: Normal unused symbols */
+               __start___ksymtab_unused = .;
+               *(__ksymtab_unused)
+               __stop___ksymtab_unused = .;
+
+               /* Kernel symbol table: GPL-only unused symbols */
+               __start___ksymtab_unused_gpl = .;
+               *(__ksymtab_unused_gpl)
+               __stop___ksymtab_unused_gpl = .;
+
                /* Kernel symbol table: GPL-future symbols */
                __start___ksymtab_gpl_future = .;
                *(__ksymtab_gpl_future)
@@ -149,10 +159,12 @@ SECTIONS {
                __security_initcall_start = .;
                *(.security_initcall.init)
                __security_initcall_end = .;
+#ifdef CONFIG_BLK_DEV_INITRD
                . = ALIGN(4);
                __initramfs_start = .;
                *(.init.ramfs)
                __initramfs_end = .;
+#endif
                . = ALIGN(4096);
                __init_end = .;
        } > INIT
index 34657f85e7024d40fc724ccaee67305de6834ab0..3343830aad10f40ce267e522ce41a51d62727a18 100644 (file)
@@ -26,7 +26,7 @@
 /***************************************************************************/
 
 void coldfire_tick(void);
-void coldfire_timer_init(irqreturn_t (*handler)(int, void *, struct pt_regs *));
+void coldfire_timer_init(irq_handler_t handler);
 unsigned long coldfire_timer_offset(void);
 void coldfire_trap_init(void);
 void coldfire_reset(void);
index 48e4d62665077b583a502df29d592b4c7baf22f0..0f67320b4031aaea269cfc7e7004ed9ce6ef905c 100644 (file)
@@ -25,7 +25,7 @@
 /***************************************************************************/
 
 void coldfire_tick(void);
-void coldfire_timer_init(irqreturn_t (*handler)(int, void *, struct pt_regs *));
+void coldfire_timer_init(irq_handler_t handler);
 unsigned long coldfire_timer_offset(void);
 void coldfire_trap_init(void);
 void coldfire_reset(void);
index 823f561f35b0c7d9dce2e9e0cbaba27bde83a3ef..58b2878deb61e8524de686639cd63ff5ef1fa018 100644 (file)
@@ -13,6 +13,7 @@
 
 #include <linux/kernel.h>
 #include <linux/param.h>
+#include <linux/interrupt.h>
 #include <asm/machdep.h>
 #include <asm/dma.h>
 
@@ -27,7 +28,7 @@ unsigned int dma_device_address[MAX_M68K_DMA_CHANNELS];
 /***************************************************************************/
 
 void coldfire_pit_tick(void);
-void coldfire_pit_init(irqreturn_t (*handler)(int, void *, struct pt_regs *));
+void coldfire_pit_init(irq_handler_t handler);
 unsigned long coldfire_pit_offset(void);
 void coldfire_trap_init(void);
 void coldfire_reset(void);
index 85de817e9ec581d02f1927f3bab5d4e0bba6afde..9b054e6caee20a22df0adb1b0d79baf7db10403d 100644 (file)
@@ -27,7 +27,7 @@
 /***************************************************************************/
 
 void coldfire_pit_tick(void);
-void coldfire_pit_init(irqreturn_t (*handler)(int, void *, struct pt_regs *));
+void coldfire_pit_init(irq_handler_t handler);
 unsigned long coldfire_pit_offset(void);
 void coldfire_trap_init(void);
 void coldfire_reset(void);
index 9d19d5bdb8afd3cc5598465965a921761dc92a80..d6706079d64ab4ba1f08a1a64aee8902ec57ab5e 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/sched.h>
 #include <linux/param.h>
 #include <linux/init.h>
+#include <linux/interrupt.h>
 #include <asm/irq.h>
 #include <asm/dma.h>
 #include <asm/traps.h>
@@ -24,7 +25,7 @@
 /***************************************************************************/
 
 void coldfire_tick(void);
-void coldfire_timer_init(irqreturn_t (*handler)(int, void *, struct pt_regs *));
+void coldfire_timer_init(irq_handler_t handler);
 unsigned long coldfire_timer_offset(void);
 void coldfire_trap_init(void);
 void coldfire_reset(void);
index d500e27eda57cd4f8cf4eb3469b3a322b63aa8a8..6b437cc977763c6f19645b5114eafb58e47bd12d 100644 (file)
@@ -26,7 +26,7 @@
 /***************************************************************************/
 
 void coldfire_tick(void);
-void coldfire_timer_init(irqreturn_t (*handler)(int, void *, struct pt_regs *));
+void coldfire_timer_init(irq_handler_t handler);
 unsigned long coldfire_timer_offset(void);
 void coldfire_trap_init(void);
 void coldfire_reset(void);
index bbae515974579b5b0f6fb94a2aee4aed26a99a3e..28e7d964eef14d85e374e609b303893a033bba9a 100644 (file)
@@ -27,7 +27,7 @@
 /***************************************************************************/
 
 void coldfire_pit_tick(void);
-void coldfire_pit_init(irqreturn_t (*handler)(int, void *, struct pt_regs *));
+void coldfire_pit_init(irq_handler_t handler);
 unsigned long coldfire_pit_offset(void);
 void coldfire_trap_init(void);
 void coldfire_reset(void);
index 18dad90461445b2298fbdda3c23328897515a8dc..805b4f74ff1948e04638255f7b072c3670f653ef 100644 (file)
@@ -27,7 +27,7 @@
 /***************************************************************************/
 
 void coldfire_pit_tick(void);
-void coldfire_pit_init(irqreturn_t (*handler)(int, void *, struct pt_regs *));
+void coldfire_pit_init(irq_handler_t handler);
 unsigned long coldfire_pit_offset(void);
 void coldfire_trap_init(void);
 void coldfire_reset(void);
index 8074ac56f479b26eab53801f9816564eaabbef68..e04b84deb57d0cfdf83a161c6cff8c7b1cd85c6c 100644 (file)
@@ -27,7 +27,7 @@
 /***************************************************************************/
 
 void coldfire_tick(void);
-void coldfire_timer_init(irqreturn_t (*handler)(int, void *, struct pt_regs *));
+void coldfire_timer_init(irq_handler_t handler);
 unsigned long coldfire_timer_offset(void);
 void coldfire_trap_init(void);
 void coldfire_reset(void);
index 9dc5688f71b54040ce80daf6ea95357773b874bd..aa15beeb36ca8b7676a49894860f66baee32c7e1 100644 (file)
@@ -43,7 +43,7 @@ void coldfire_pit_tick(void)
 
 /***************************************************************************/
 
-void coldfire_pit_init(irqreturn_t (*handler)(int, void *, struct pt_regs *))
+void coldfire_pit_init(irq_handler_t handler)
 {
        volatile unsigned char *icrp;
        volatile unsigned long *imrp;
index e5668af19789ccae8e2843befd28f2749341d3ed..87b112b363a618fda2c8c76cb784269e11c5c224 100644 (file)
@@ -62,7 +62,7 @@ void coldfire_tick(void)
 
 /***************************************************************************/
 
-void coldfire_timer_init(irqreturn_t (*handler)(int, void *, struct pt_regs *))
+void coldfire_timer_init(irq_handler_t handler)
 {
        __raw_writew(MCFTIMER_TMR_DISABLE, TA(MCFTIMER_TMR));
        __raw_writetrr(((MCF_BUSCLK / 16) / HZ), TA(MCFTIMER_TRR));
@@ -111,12 +111,13 @@ unsigned long coldfire_timer_offset(void)
 /*
  *     Use the other timer to provide high accuracy profiling info.
  */
-void coldfire_profile_tick(int irq, void *dummy, struct pt_regs *regs)
+irqreturn_t coldfire_profile_tick(int irq, void *dummy)
 {
        /* Reset ColdFire timer2 */
        __raw_writeb(MCFTIMER_TER_CAP | MCFTIMER_TER_REF, PA(MCFTIMER_TER));
        if (current->pid)
                profile_tick(CPU_PROFILING, regs);
+       return IRQ_HANDLED;
 }
 
 /***************************************************************************/
index c7d6ad5138206bd924334e47e1d992a66d424b55..664c3a12b0c128a6f927c82fc2ab2731add26f8d 100644 (file)
@@ -35,7 +35,7 @@
 /***************************************************************************/
 
 void coldfire_tick(void);
-void coldfire_timer_init(irqreturn_t (*handler)(int, void *, struct pt_regs *));
+void coldfire_timer_init(irq_handler_t handler);
 unsigned long coldfire_timer_offset(void);
 void coldfire_trap_init(void);
 void coldfire_reset(void);
index 5aad2645f0f1e1d476b5832548e2f6d12508ce28..036f62876241f82b4aa16c5adec42828845acf71 100644 (file)
@@ -26,7 +26,7 @@
 /***************************************************************************/
 
 void coldfire_tick(void);
-void coldfire_timer_init(irqreturn_t (*handler)(int, void *, struct pt_regs *));
+void coldfire_timer_init(irq_handler_t handler);
 unsigned long coldfire_timer_offset(void);
 void coldfire_trap_init(void);
 void coldfire_reset(void);
index 26ffeba286424a0b41c4e9089fed15945692107a..e5c537d14dfb0a4c006568c89a8179f46243abe2 100644 (file)
@@ -34,7 +34,7 @@
 
 /***************************************************************************/
 
-void m68328_timer_init(irqreturn_t (*timer_routine) (int, void *, struct pt_regs *));
+void m68328_timer_init(irq_handler_t timer_routine);
 void m68328_timer_tick(void);
 unsigned long m68328_timer_gettimeoffset(void);
 void m68328_timer_gettod(int *year, int *mon, int *day, int *hour, int *min, int *sec);
index 44a0224c32ddbe39d30c3134b4d41766e95d4d0b..1bc6d249be4494d61a42a3e431d854664eac91f5 100644 (file)
@@ -8,6 +8,10 @@ mainmenu "Linux/MIPS Kernel Configuration"
 
 menu "Machine selection"
 
+config ZONE_DMA
+       bool
+       default y
+
 choice
        prompt "System type"
        default SGI_IP22
@@ -934,6 +938,9 @@ config CPU_LITTLE_ENDIAN
 
 endchoice
 
+config SYS_SUPPORTS_APM_EMULATION
+       bool
+
 config SYS_SUPPORTS_BIG_ENDIAN
        bool
 
@@ -1001,6 +1008,7 @@ config SOC_AU1X00
        bool
        select SYS_HAS_CPU_MIPS32_R1
        select SYS_SUPPORTS_32BIT_KERNEL
+       select SYS_SUPPORTS_APM_EMULATION
 
 config PNX8550
        bool
@@ -2071,35 +2079,11 @@ config BINFMT_ELF32
        bool
        default y if MIPS32_O32 || MIPS32_N32
 
-config PM
-       bool "Power Management support (EXPERIMENTAL)"
-       depends on EXPERIMENTAL && SOC_AU1X00
-
-config APM
-        tristate "Advanced Power Management Emulation"
-       depends on PM
-        ---help---
-         APM is a BIOS specification for saving power using several different
-         techniques. This is mostly useful for battery powered systems with
-         APM compliant BIOSes. If you say Y here, the system time will be
-         reset after a RESUME operation, the /proc/apm device will provide
-         battery status information, and user-space programs will receive
-         notification of APM "events" (e.g. battery status change).
-
-         In order to use APM, you will need supporting software. For location
-         and more information, read <file:Documentation/pm.txt> and the
-         Battery Powered Linux mini-HOWTO, available from
-         <http://www.tldp.org/docs.html#howto>.
-
-         This driver does not spin down disk drives (see the hdparm(8)
-         manpage ("man 8 hdparm") for that), and it doesn't turn off
-         VESA-compliant "green" monitors.
-
-         Generally, if you don't have a battery in your machine, there isn't
-         much point in using this driver and you should say N. If you get
-         random kernel OOPSes or reboots that don't seem to be related to
-         anything, try disabling/enabling this option (or disabling/enabling
-         APM in your BIOS).
+endmenu
+
+menu "Power management options"
+
+source "kernel/power/Kconfig"
 
 endmenu
 
index ed181fdc3ac9f1f9214ddc2a925a965410135569..8b790c2900d5b5c84af4d30479eddfc61507bc8c 100644 (file)
@@ -6,6 +6,7 @@ obj-y           := ecc-berr.o int-handler.o ioasic-irq.o kn01-berr.o \
                   kn02-irq.o kn02xa-berr.o reset.o setup.o time.o
 
 obj-$(CONFIG_PROM_CONSOLE)     += promcon.o
+obj-$(CONFIG_TC)               += tc.o
 obj-$(CONFIG_CPU_HAS_WB)       += wbflush.o
 
 EXTRA_AFLAGS := $(CFLAGS)
index 81d5e878ddce8d409cfafd326454dc6eab0fcae3..c4e3c1ea0d48946f0c84b315817c43dab0f1aef6 100644 (file)
@@ -88,6 +88,7 @@ static inline void prom_init_kn02(void)
 {
        dec_kn_slot_base = KN02_SLOT_BASE;
        dec_kn_slot_size = KN02_SLOT_SIZE;
+       dec_tc_bus = 1;
 
        dec_rtc_base = (void *)CKSEG1ADDR(dec_kn_slot_base + KN02_RTC);
 }
@@ -96,6 +97,7 @@ static inline void prom_init_kn02xa(void)
 {
        dec_kn_slot_base = KN02XA_SLOT_BASE;
        dec_kn_slot_size = IOASIC_SLOT_SIZE;
+       dec_tc_bus = 1;
 
        ioasic_base = (void *)CKSEG1ADDR(dec_kn_slot_base + IOASIC_IOCTL);
        dec_rtc_base = (void *)CKSEG1ADDR(dec_kn_slot_base + IOASIC_TOY);
@@ -105,6 +107,7 @@ static inline void prom_init_kn03(void)
 {
        dec_kn_slot_base = KN03_SLOT_BASE;
        dec_kn_slot_size = IOASIC_SLOT_SIZE;
+       dec_tc_bus = 1;
 
        ioasic_base = (void *)CKSEG1ADDR(dec_kn_slot_base + IOASIC_IOCTL);
        dec_rtc_base = (void *)CKSEG1ADDR(dec_kn_slot_base + IOASIC_TOY);
index 1058e2f409bb9ec6a3fed658103affd4d5b338d1..b8a5e75ba0ab4b6bce2bc979a8c7527f050c571d 100644 (file)
@@ -53,6 +53,8 @@ unsigned long dec_kn_slot_base, dec_kn_slot_size;
 EXPORT_SYMBOL(dec_kn_slot_base);
 EXPORT_SYMBOL(dec_kn_slot_size);
 
+int dec_tc_bus;
+
 spinlock_t ioasic_ssr_lock;
 
 volatile u32 *ioasic_base;
diff --git a/arch/mips/dec/tc.c b/arch/mips/dec/tc.c
new file mode 100644 (file)
index 0000000..732027c
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ *     TURBOchannel architecture calls.
+ *
+ *     Copyright (c) Harald Koerfgen, 1998
+ *     Copyright (c) 2001, 2003, 2005, 2006  Maciej W. Rozycki
+ *     Copyright (c) 2005  James Simmons
+ *
+ *     This file is subject to the terms and conditions of the GNU
+ *     General Public License.  See the file "COPYING" in the main
+ *     directory of this archive for more details.
+ */
+#include <linux/compiler.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/string.h>
+#include <linux/tc.h>
+#include <linux/types.h>
+
+#include <asm/addrspace.h>
+#include <asm/bootinfo.h>
+#include <asm/paccess.h>
+
+#include <asm/dec/interrupts.h>
+#include <asm/dec/prom.h>
+#include <asm/dec/system.h>
+
+/*
+ * Protected read byte from TURBOchannel slot space.
+ */
+int tc_preadb(u8 *valp, void __iomem *addr)
+{
+       return get_dbe(*valp, (u8 *)addr);
+}
+
+/*
+ * Get TURBOchannel bus information as specified by the spec, plus
+ * the slot space base address and the number of slots.
+ */
+int __init tc_bus_get_info(struct tc_bus *tbus)
+{
+       if (!dec_tc_bus)
+               return -ENXIO;
+
+       memcpy(&tbus->info, rex_gettcinfo(), sizeof(tbus->info));
+       tbus->slot_base = CPHYSADDR((long)rex_slot_address(0));
+
+       switch (mips_machtype) {
+       case MACH_DS5000_200:
+               tbus->num_tcslots = 7;
+               break;
+       case MACH_DS5000_2X0:
+       case MACH_DS5900:
+               tbus->ext_slot_base = 0x20000000;
+               tbus->ext_slot_size = 0x20000000;
+               /* fall through */
+       case MACH_DS5000_1XX:
+               tbus->num_tcslots = 3;
+               break;
+       case MACH_DS5000_XX:
+               tbus->num_tcslots = 2;
+       default:
+               break;
+       }
+       return 0;
+}
+
+/*
+ * Get the IRQ for the specified slot.
+ */
+void __init tc_device_get_irq(struct tc_dev *tdev)
+{
+       switch (tdev->slot) {
+       case 0:
+               tdev->interrupt = dec_interrupt[DEC_IRQ_TC0];
+               break;
+       case 1:
+               tdev->interrupt = dec_interrupt[DEC_IRQ_TC1];
+               break;
+       case 2:
+               tdev->interrupt = dec_interrupt[DEC_IRQ_TC2];
+               break;
+       /*
+        * Yuck! DS5000/200 onboard devices
+        */
+       case 5:
+               tdev->interrupt = dec_interrupt[DEC_IRQ_TC5];
+               break;
+       case 6:
+               tdev->interrupt = dec_interrupt[DEC_IRQ_TC6];
+               break;
+       default:
+               tdev->interrupt = -1;
+               break;
+       }
+}
index bbbb8d7cb89b41f2c74eba075e104d3c76ab85dd..1bf2c84489125cd673cb0d7d1cbb52a5ad24e7ee 100644 (file)
@@ -14,8 +14,6 @@ binfmt_irix-objs      := irixelf.o irixinv.o irixioctl.o irixsig.o    \
 obj-$(CONFIG_STACKTRACE)       += stacktrace.o
 obj-$(CONFIG_MODULES)          += mips_ksyms.o module.o
 
-obj-$(CONFIG_APM)              += apm.o
-
 obj-$(CONFIG_CPU_R3000)                += r2300_fpu.o r2300_switch.o
 obj-$(CONFIG_CPU_TX39XX)       += r2300_fpu.o r2300_switch.o
 obj-$(CONFIG_CPU_TX49XX)       += r4k_fpu.o r4k_switch.o
diff --git a/arch/mips/kernel/apm.c b/arch/mips/kernel/apm.c
deleted file mode 100644 (file)
index ba16d07..0000000
+++ /dev/null
@@ -1,604 +0,0 @@
-/*
- * bios-less APM driver for MIPS Linux
- *  Jamey Hicks <jamey@crl.dec.com>
- *  adapted from the APM BIOS driver for Linux by Stephen Rothwell (sfr@linuxcare.com)
- *
- * APM 1.2 Reference:
- *   Intel Corporation, Microsoft Corporation. Advanced Power Management
- *   (APM) BIOS Interface Specification, Revision 1.2, February 1996.
- *
- * [This document is available from Microsoft at:
- *    http://www.microsoft.com/hwdev/busbios/amp_12.htm]
- */
-#include <linux/module.h>
-#include <linux/poll.h>
-#include <linux/timer.h>
-#include <linux/slab.h>
-#include <linux/proc_fs.h>
-#include <linux/miscdevice.h>
-#include <linux/apm_bios.h>
-#include <linux/capability.h>
-#include <linux/sched.h>
-#include <linux/pm.h>
-#include <linux/device.h>
-#include <linux/kernel.h>
-#include <linux/list.h>
-#include <linux/init.h>
-#include <linux/completion.h>
-
-#include <asm/apm.h> /* apm_power_info */
-#include <asm/system.h>
-
-/*
- * The apm_bios device is one of the misc char devices.
- * This is its minor number.
- */
-#define APM_MINOR_DEV  134
-
-/*
- * See Documentation/Config.help for the configuration options.
- *
- * Various options can be changed at boot time as follows:
- * (We allow underscores for compatibility with the modules code)
- *     apm=on/off                      enable/disable APM
- */
-
-/*
- * Maximum number of events stored
- */
-#define APM_MAX_EVENTS         16
-
-struct apm_queue {
-       unsigned int            event_head;
-       unsigned int            event_tail;
-       apm_event_t             events[APM_MAX_EVENTS];
-};
-
-/*
- * The per-file APM data
- */
-struct apm_user {
-       struct list_head        list;
-
-       unsigned int            suser: 1;
-       unsigned int            writer: 1;
-       unsigned int            reader: 1;
-
-       int                     suspend_result;
-       unsigned int            suspend_state;
-#define SUSPEND_NONE   0               /* no suspend pending */
-#define SUSPEND_PENDING        1               /* suspend pending read */
-#define SUSPEND_READ   2               /* suspend read, pending ack */
-#define SUSPEND_ACKED  3               /* suspend acked */
-#define SUSPEND_DONE   4               /* suspend completed */
-
-       struct apm_queue        queue;
-};
-
-/*
- * Local variables
- */
-static int suspends_pending;
-static int apm_disabled;
-static int mips_apm_active;
-
-static DECLARE_WAIT_QUEUE_HEAD(apm_waitqueue);
-static DECLARE_WAIT_QUEUE_HEAD(apm_suspend_waitqueue);
-
-/*
- * This is a list of everyone who has opened /dev/apm_bios
- */
-static DECLARE_RWSEM(user_list_lock);
-static LIST_HEAD(apm_user_list);
-
-/*
- * kapmd info.  kapmd provides us a process context to handle
- * "APM" events within - specifically necessary if we're going
- * to be suspending the system.
- */
-static DECLARE_WAIT_QUEUE_HEAD(kapmd_wait);
-static DECLARE_COMPLETION(kapmd_exit);
-static DEFINE_SPINLOCK(kapmd_queue_lock);
-static struct apm_queue kapmd_queue;
-
-
-static const char driver_version[] = "1.13";   /* no spaces */
-
-
-
-/*
- * Compatibility cruft until the IPAQ people move over to the new
- * interface.
- */
-static void __apm_get_power_status(struct apm_power_info *info)
-{
-}
-
-/*
- * This allows machines to provide their own "apm get power status" function.
- */
-void (*apm_get_power_status)(struct apm_power_info *) = __apm_get_power_status;
-EXPORT_SYMBOL(apm_get_power_status);
-
-
-/*
- * APM event queue management.
- */
-static inline int queue_empty(struct apm_queue *q)
-{
-       return q->event_head == q->event_tail;
-}
-
-static inline apm_event_t queue_get_event(struct apm_queue *q)
-{
-       q->event_tail = (q->event_tail + 1) % APM_MAX_EVENTS;
-       return q->events[q->event_tail];
-}
-
-static void queue_add_event(struct apm_queue *q, apm_event_t event)
-{
-       q->event_head = (q->event_head + 1) % APM_MAX_EVENTS;
-       if (q->event_head == q->event_tail) {
-               static int notified;
-
-               if (notified++ == 0)
-                   printk(KERN_ERR "apm: an event queue overflowed\n");
-               q->event_tail = (q->event_tail + 1) % APM_MAX_EVENTS;
-       }
-       q->events[q->event_head] = event;
-}
-
-static void queue_event_one_user(struct apm_user *as, apm_event_t event)
-{
-       if (as->suser && as->writer) {
-               switch (event) {
-               case APM_SYS_SUSPEND:
-               case APM_USER_SUSPEND:
-                       /*
-                        * If this user already has a suspend pending,
-                        * don't queue another one.
-                        */
-                       if (as->suspend_state != SUSPEND_NONE)
-                               return;
-
-                       as->suspend_state = SUSPEND_PENDING;
-                       suspends_pending++;
-                       break;
-               }
-       }
-       queue_add_event(&as->queue, event);
-}
-
-static void queue_event(apm_event_t event, struct apm_user *sender)
-{
-       struct apm_user *as;
-
-       down_read(&user_list_lock);
-       list_for_each_entry(as, &apm_user_list, list) {
-               if (as != sender && as->reader)
-                       queue_event_one_user(as, event);
-       }
-       up_read(&user_list_lock);
-       wake_up_interruptible(&apm_waitqueue);
-}
-
-static void apm_suspend(void)
-{
-       struct apm_user *as;
-       int err = pm_suspend(PM_SUSPEND_MEM);
-
-       /*
-        * Anyone on the APM queues will think we're still suspended.
-        * Send a message so everyone knows we're now awake again.
-        */
-       queue_event(APM_NORMAL_RESUME, NULL);
-
-       /*
-        * Finally, wake up anyone who is sleeping on the suspend.
-        */
-       down_read(&user_list_lock);
-       list_for_each_entry(as, &apm_user_list, list) {
-               as->suspend_result = err;
-               as->suspend_state = SUSPEND_DONE;
-       }
-       up_read(&user_list_lock);
-
-       wake_up(&apm_suspend_waitqueue);
-}
-
-static ssize_t apm_read(struct file *fp, char __user *buf, size_t count, loff_t *ppos)
-{
-       struct apm_user *as = fp->private_data;
-       apm_event_t event;
-       int i = count, ret = 0;
-
-       if (count < sizeof(apm_event_t))
-               return -EINVAL;
-
-       if (queue_empty(&as->queue) && fp->f_flags & O_NONBLOCK)
-               return -EAGAIN;
-
-       wait_event_interruptible(apm_waitqueue, !queue_empty(&as->queue));
-
-       while ((i >= sizeof(event)) && !queue_empty(&as->queue)) {
-               event = queue_get_event(&as->queue);
-
-               ret = -EFAULT;
-               if (copy_to_user(buf, &event, sizeof(event)))
-                       break;
-
-               if (event == APM_SYS_SUSPEND || event == APM_USER_SUSPEND)
-                       as->suspend_state = SUSPEND_READ;
-
-               buf += sizeof(event);
-               i -= sizeof(event);
-       }
-
-       if (i < count)
-               ret = count - i;
-
-       return ret;
-}
-
-static unsigned int apm_poll(struct file *fp, poll_table * wait)
-{
-       struct apm_user *as = fp->private_data;
-
-       poll_wait(fp, &apm_waitqueue, wait);
-       return queue_empty(&as->queue) ? 0 : POLLIN | POLLRDNORM;
-}
-
-/*
- * apm_ioctl - handle APM ioctl
- *
- * APM_IOC_SUSPEND
- *   This IOCTL is overloaded, and performs two functions.  It is used to:
- *     - initiate a suspend
- *     - acknowledge a suspend read from /dev/apm_bios.
- *   Only when everyone who has opened /dev/apm_bios with write permission
- *   has acknowledge does the actual suspend happen.
- */
-static int
-apm_ioctl(struct inode * inode, struct file *filp, unsigned int cmd, unsigned long arg)
-{
-       struct apm_user *as = filp->private_data;
-       unsigned long flags;
-       int err = -EINVAL;
-
-       if (!as->suser || !as->writer)
-               return -EPERM;
-
-       switch (cmd) {
-       case APM_IOC_SUSPEND:
-               as->suspend_result = -EINTR;
-
-               if (as->suspend_state == SUSPEND_READ) {
-                       /*
-                        * If we read a suspend command from /dev/apm_bios,
-                        * then the corresponding APM_IOC_SUSPEND ioctl is
-                        * interpreted as an acknowledge.
-                        */
-                       as->suspend_state = SUSPEND_ACKED;
-                       suspends_pending--;
-               } else {
-                       /*
-                        * Otherwise it is a request to suspend the system.
-                        * Queue an event for all readers, and expect an
-                        * acknowledge from all writers who haven't already
-                        * acknowledged.
-                        */
-                       queue_event(APM_USER_SUSPEND, as);
-               }
-
-               /*
-                * If there are no further acknowledges required, suspend
-                * the system.
-                */
-               if (suspends_pending == 0)
-                       apm_suspend();
-
-               /*
-                * Wait for the suspend/resume to complete.  If there are
-                * pending acknowledges, we wait here for them.
-                *
-                * Note that we need to ensure that the PM subsystem does
-                * not kick us out of the wait when it suspends the threads.
-                */
-               flags = current->flags;
-               current->flags |= PF_NOFREEZE;
-
-               /*
-                * Note: do not allow a thread which is acking the suspend
-                * to escape until the resume is complete.
-                */
-               if (as->suspend_state == SUSPEND_ACKED)
-                       wait_event(apm_suspend_waitqueue,
-                                        as->suspend_state == SUSPEND_DONE);
-               else
-                       wait_event_interruptible(apm_suspend_waitqueue,
-                                        as->suspend_state == SUSPEND_DONE);
-
-               current->flags = flags;
-               err = as->suspend_result;
-               as->suspend_state = SUSPEND_NONE;
-               break;
-       }
-
-       return err;
-}
-
-static int apm_release(struct inode * inode, struct file * filp)
-{
-       struct apm_user *as = filp->private_data;
-       filp->private_data = NULL;
-
-       down_write(&user_list_lock);
-       list_del(&as->list);
-       up_write(&user_list_lock);
-
-       /*
-        * We are now unhooked from the chain.  As far as new
-        * events are concerned, we no longer exist.  However, we
-        * need to balance suspends_pending, which means the
-        * possibility of sleeping.
-        */
-       if (as->suspend_state != SUSPEND_NONE) {
-               suspends_pending -= 1;
-               if (suspends_pending == 0)
-                       apm_suspend();
-       }
-
-       kfree(as);
-       return 0;
-}
-
-static int apm_open(struct inode * inode, struct file * filp)
-{
-       struct apm_user *as;
-
-       as = kzalloc(sizeof(*as), GFP_KERNEL);
-       if (as) {
-               /*
-                * XXX - this is a tiny bit broken, when we consider BSD
-                * process accounting. If the device is opened by root, we
-                * instantly flag that we used superuser privs. Who knows,
-                * we might close the device immediately without doing a
-                * privileged operation -- cevans
-                */
-               as->suser = capable(CAP_SYS_ADMIN);
-               as->writer = (filp->f_mode & FMODE_WRITE) == FMODE_WRITE;
-               as->reader = (filp->f_mode & FMODE_READ) == FMODE_READ;
-
-               down_write(&user_list_lock);
-               list_add(&as->list, &apm_user_list);
-               up_write(&user_list_lock);
-
-               filp->private_data = as;
-       }
-
-       return as ? 0 : -ENOMEM;
-}
-
-static struct file_operations apm_bios_fops = {
-       .owner          = THIS_MODULE,
-       .read           = apm_read,
-       .poll           = apm_poll,
-       .ioctl          = apm_ioctl,
-       .open           = apm_open,
-       .release        = apm_release,
-};
-
-static struct miscdevice apm_device = {
-       .minor          = APM_MINOR_DEV,
-       .name           = "apm_bios",
-       .fops           = &apm_bios_fops
-};
-
-
-#ifdef CONFIG_PROC_FS
-/*
- * Arguments, with symbols from linux/apm_bios.h.
- *
- *   0) Linux driver version (this will change if format changes)
- *   1) APM BIOS Version.  Usually 1.0, 1.1 or 1.2.
- *   2) APM flags from APM Installation Check (0x00):
- *     bit 0: APM_16_BIT_SUPPORT
- *     bit 1: APM_32_BIT_SUPPORT
- *     bit 2: APM_IDLE_SLOWS_CLOCK
- *     bit 3: APM_BIOS_DISABLED
- *     bit 4: APM_BIOS_DISENGAGED
- *   3) AC line status
- *     0x00: Off-line
- *     0x01: On-line
- *     0x02: On backup power (BIOS >= 1.1 only)
- *     0xff: Unknown
- *   4) Battery status
- *     0x00: High
- *     0x01: Low
- *     0x02: Critical
- *     0x03: Charging
- *     0x04: Selected battery not present (BIOS >= 1.2 only)
- *     0xff: Unknown
- *   5) Battery flag
- *     bit 0: High
- *     bit 1: Low
- *     bit 2: Critical
- *     bit 3: Charging
- *     bit 7: No system battery
- *     0xff: Unknown
- *   6) Remaining battery life (percentage of charge):
- *     0-100: valid
- *     -1: Unknown
- *   7) Remaining battery life (time units):
- *     Number of remaining minutes or seconds
- *     -1: Unknown
- *   8) min = minutes; sec = seconds
- */
-static int apm_get_info(char *buf, char **start, off_t fpos, int length)
-{
-       struct apm_power_info info;
-       char *units;
-       int ret;
-
-       info.ac_line_status = 0xff;
-       info.battery_status = 0xff;
-       info.battery_flag   = 0xff;
-       info.battery_life   = -1;
-       info.time           = -1;
-       info.units          = -1;
-
-       if (apm_get_power_status)
-               apm_get_power_status(&info);
-
-       switch (info.units) {
-       default:        units = "?";    break;
-       case 0:         units = "min";  break;
-       case 1:         units = "sec";  break;
-       }
-
-       ret = sprintf(buf, "%s 1.2 0x%02x 0x%02x 0x%02x 0x%02x %d%% %d %s\n",
-                    driver_version, APM_32_BIT_SUPPORT,
-                    info.ac_line_status, info.battery_status,
-                    info.battery_flag, info.battery_life,
-                    info.time, units);
-
-       return ret;
-}
-#endif
-
-static int kapmd(void *arg)
-{
-       daemonize("kapmd");
-       current->flags |= PF_NOFREEZE;
-
-       do {
-               apm_event_t event;
-
-               wait_event_interruptible(kapmd_wait,
-                               !queue_empty(&kapmd_queue) || !mips_apm_active);
-
-               if (!mips_apm_active)
-                       break;
-
-               spin_lock_irq(&kapmd_queue_lock);
-               event = 0;
-               if (!queue_empty(&kapmd_queue))
-                       event = queue_get_event(&kapmd_queue);
-               spin_unlock_irq(&kapmd_queue_lock);
-
-               switch (event) {
-               case 0:
-                       break;
-
-               case APM_LOW_BATTERY:
-               case APM_POWER_STATUS_CHANGE:
-                       queue_event(event, NULL);
-                       break;
-
-               case APM_USER_SUSPEND:
-               case APM_SYS_SUSPEND:
-                       queue_event(event, NULL);
-                       if (suspends_pending == 0)
-                               apm_suspend();
-                       break;
-
-               case APM_CRITICAL_SUSPEND:
-                       apm_suspend();
-                       break;
-               }
-       } while (1);
-
-       complete_and_exit(&kapmd_exit, 0);
-}
-
-static int __init apm_init(void)
-{
-       int ret;
-
-       if (apm_disabled) {
-               printk(KERN_NOTICE "apm: disabled on user request.\n");
-               return -ENODEV;
-       }
-
-       mips_apm_active = 1;
-
-       ret = kernel_thread(kapmd, NULL, CLONE_KERNEL);
-       if (ret < 0) {
-               mips_apm_active = 0;
-               return ret;
-       }
-
-#ifdef CONFIG_PROC_FS
-       create_proc_info_entry("apm", 0, NULL, apm_get_info);
-#endif
-
-       ret = misc_register(&apm_device);
-       if (ret != 0) {
-               remove_proc_entry("apm", NULL);
-
-               mips_apm_active = 0;
-               wake_up(&kapmd_wait);
-               wait_for_completion(&kapmd_exit);
-       }
-
-       return ret;
-}
-
-static void __exit apm_exit(void)
-{
-       misc_deregister(&apm_device);
-       remove_proc_entry("apm", NULL);
-
-       mips_apm_active = 0;
-       wake_up(&kapmd_wait);
-       wait_for_completion(&kapmd_exit);
-}
-
-module_init(apm_init);
-module_exit(apm_exit);
-
-MODULE_AUTHOR("Stephen Rothwell");
-MODULE_DESCRIPTION("Advanced Power Management");
-MODULE_LICENSE("GPL");
-
-#ifndef MODULE
-static int __init apm_setup(char *str)
-{
-       while ((str != NULL) && (*str != '\0')) {
-               if (strncmp(str, "off", 3) == 0)
-                       apm_disabled = 1;
-               if (strncmp(str, "on", 2) == 0)
-                       apm_disabled = 0;
-               str = strchr(str, ',');
-               if (str != NULL)
-                       str += strspn(str, ", \t");
-       }
-       return 1;
-}
-
-__setup("apm=", apm_setup);
-#endif
-
-/**
- * apm_queue_event - queue an APM event for kapmd
- * @event: APM event
- *
- * Queue an APM event for kapmd to process and ultimately take the
- * appropriate action.  Only a subset of events are handled:
- *   %APM_LOW_BATTERY
- *   %APM_POWER_STATUS_CHANGE
- *   %APM_USER_SUSPEND
- *   %APM_SYS_SUSPEND
- *   %APM_CRITICAL_SUSPEND
- */
-void apm_queue_event(apm_event_t event)
-{
-       unsigned long flags;
-
-       spin_lock_irqsave(&kapmd_queue_lock, flags);
-       queue_add_event(&kapmd_queue, event);
-       spin_unlock_irqrestore(&kapmd_queue_lock, flags);
-
-       wake_up_interruptible(&kapmd_wait);
-}
-EXPORT_SYMBOL(apm_queue_event);
index 0b8ce59429a8d1e3e73a6fe22cfe9b61b6429b40..ca7ad78f4def1fea27de9142b1ffd17d91900337 100644 (file)
@@ -193,50 +193,6 @@ sysn32_waitid(int which, compat_pid_t pid,
        return ret;
 }
 
-struct sysinfo32 {
-       s32 uptime;
-       u32 loads[3];
-       u32 totalram;
-       u32 freeram;
-       u32 sharedram;
-       u32 bufferram;
-       u32 totalswap;
-       u32 freeswap;
-       u16 procs;
-       u32 totalhigh;
-       u32 freehigh;
-       u32 mem_unit;
-       char _f[8];
-};
-
-asmlinkage int sys32_sysinfo(struct sysinfo32 __user *info)
-{
-       struct sysinfo s;
-       int ret, err;
-       mm_segment_t old_fs = get_fs ();
-
-       set_fs (KERNEL_DS);
-       ret = sys_sysinfo((struct sysinfo __user *)&s);
-       set_fs (old_fs);
-       err = put_user (s.uptime, &info->uptime);
-       err |= __put_user (s.loads[0], &info->loads[0]);
-       err |= __put_user (s.loads[1], &info->loads[1]);
-       err |= __put_user (s.loads[2], &info->loads[2]);
-       err |= __put_user (s.totalram, &info->totalram);
-       err |= __put_user (s.freeram, &info->freeram);
-       err |= __put_user (s.sharedram, &info->sharedram);
-       err |= __put_user (s.bufferram, &info->bufferram);
-       err |= __put_user (s.totalswap, &info->totalswap);
-       err |= __put_user (s.freeswap, &info->freeswap);
-       err |= __put_user (s.procs, &info->procs);
-       err |= __put_user (s.totalhigh, &info->totalhigh);
-       err |= __put_user (s.freehigh, &info->freehigh);
-       err |= __put_user (s.mem_unit, &info->mem_unit);
-       if (err)
-               return -EFAULT;
-       return ret;
-}
-
 #define RLIM_INFINITY32        0x7fffffff
 #define RESOURCE32(x) ((x > RLIM_INFINITY32) ? RLIM_INFINITY32 : x)
 
index 39add2341aa296f303f0d4f0b0d18c67aa232a74..ee8802b597582ef1a71458dfeb93ad0de5412a74 100644 (file)
@@ -217,7 +217,7 @@ EXPORT(sysn32_call_table)
        PTR     sys32_gettimeofday
        PTR     compat_sys_getrlimit            /* 6095 */
        PTR     compat_sys_getrusage
-       PTR     sys32_sysinfo
+       PTR     compat_sys_sysinfo
        PTR     compat_sys_times
        PTR     sys32_ptrace
        PTR     sys_getuid                      /* 6100 */
index c58b8e0105ea0db8fa4cc2994324fddde7a4d17b..c5f590ca99b09d47a293a40b2c55ae83a01687dd 100644 (file)
@@ -321,7 +321,7 @@ sys_call_table:
        PTR     sys_ni_syscall                  /* sys_vm86 */
        PTR     compat_sys_wait4
        PTR     sys_swapoff                     /* 4115 */
-       PTR     sys32_sysinfo
+       PTR     compat_sys_sysinfo
        PTR     sys32_ipc
        PTR     sys_fsync
        PTR     sys32_sigreturn
index 8aa544f73a5ea27fd85eb007ac9ec59938e0ff35..545fcbc8cea2283525f3b7fd6b214c9646c9545e 100644 (file)
@@ -455,8 +455,3 @@ EXPORT_SYMBOL(rtc_lock);
 EXPORT_SYMBOL(to_tm);
 EXPORT_SYMBOL(rtc_mips_set_time);
 EXPORT_SYMBOL(rtc_mips_get_time);
-
-unsigned long long sched_clock(void)
-{
-       return (unsigned long long)jiffies*(1000000000/HZ);
-}
index cecff24cc9721a16e7abdb9e04980f73b53293ec..c76b793310c26d4a5a5c4895a7d83fe839826165 100644 (file)
@@ -113,10 +113,12 @@ SECTIONS
      references from .rodata */
   .exit.text : { *(.exit.text) }
   .exit.data : { *(.exit.data) }
+#if defined(CONFIG_BLK_DEV_INITRD)
   . = ALIGN(_PAGE_SIZE);
   __initramfs_start = .;
   .init.ramfs : { *(.init.ramfs) }
   __initramfs_end = .;
+#endif
   . = ALIGN(32);
   __per_cpu_start = .;
   .data.percpu  : { *(.data.percpu) }
index 1f954a238a6332b0d8aaa0a4dde2fc5903f4f225..31819c58bffaa188c676f9c61112c569a2f8874c 100644 (file)
@@ -107,8 +107,6 @@ void __update_cache(struct vm_area_struct *vma, unsigned long address,
        }
 }
 
-#define __weak __attribute__((weak))
-
 static char cache_panic[] __initdata = "Yeee, unsupported cache architecture.";
 
 void __init cpu_cache_init(void)
index 72a016767e09d399f3ff65d95641a7082e639e32..3f097558ef1365df5b3f1d62343744322e731782 100644 (file)
@@ -79,10 +79,7 @@ static int pnx8550_proc_init( void )
 
        // Create /proc/pnx8550
         pnx8550_dir = create_proc_entry("pnx8550", S_IFDIR|S_IRUGO, NULL);
-        if (pnx8550_dir){
-                pnx8550_dir->nlink = 1;
-        }
-        else {
+        if (!pnx8550_dir) {
                 printk(KERN_ERR "Can't create pnx8550 proc dir\n");
                 return -1;
         }
@@ -90,7 +87,6 @@ static int pnx8550_proc_init( void )
        // Create /proc/pnx8550/timers
         pnx8550_timers = create_proc_entry("timers", S_IFREG|S_IRUGO, pnx8550_dir );
         if (pnx8550_timers){
-                pnx8550_timers->nlink = 1;
                 pnx8550_timers->read_proc = pnx8550_timers_read;
         }
         else {
@@ -100,7 +96,6 @@ static int pnx8550_proc_init( void )
        // Create /proc/pnx8550/registers
         pnx8550_registers = create_proc_entry("registers", S_IFREG|S_IRUGO, pnx8550_dir );
         if (pnx8550_registers){
-                pnx8550_registers->nlink = 1;
                 pnx8550_registers->read_proc = pnx8550_registers_read;
         }
         else {
index 0f9ff618c6d7205c7d86f856cd78b9898b89e85a..28da4e71c44311e7111f8a2b2182b0d595a2d62d 100644 (file)
@@ -50,9 +50,6 @@ config TIME_LOW_RES
        depends on SMP
        default y
 
-config GENERIC_ISA_DMA
-       bool
-
 config GENERIC_HARDIRQS
        def_bool y
 
index 29be4377aca6c0fb1e2cebd00d4fba4556efdc01..ce3245f87fddf832f9385a53b691ae7585a7d2a4 100644 (file)
@@ -579,70 +579,6 @@ asmlinkage int sys32_sendfile64(int out_fd, int in_fd, compat_loff_t __user *off
 }
 
 
-struct sysinfo32 {
-       s32 uptime;
-       u32 loads[3];
-       u32 totalram;
-       u32 freeram;
-       u32 sharedram;
-       u32 bufferram;
-       u32 totalswap;
-       u32 freeswap;
-       unsigned short procs;
-       u32 totalhigh;
-       u32 freehigh;
-       u32 mem_unit;
-       char _f[12];
-};
-
-/* We used to call sys_sysinfo and translate the result.  But sys_sysinfo
- * undoes the good work done elsewhere, and rather than undoing the
- * damage, I decided to just duplicate the code from sys_sysinfo here.
- */
-
-asmlinkage int sys32_sysinfo(struct sysinfo32 __user *info)
-{
-       struct sysinfo val;
-       int err;
-       unsigned long seq;
-
-       /* We don't need a memset here because we copy the
-        * struct to userspace once element at a time.
-        */
-
-       do {
-               seq = read_seqbegin(&xtime_lock);
-               val.uptime = jiffies / HZ;
-
-               val.loads[0] = avenrun[0] << (SI_LOAD_SHIFT - FSHIFT);
-               val.loads[1] = avenrun[1] << (SI_LOAD_SHIFT - FSHIFT);
-               val.loads[2] = avenrun[2] << (SI_LOAD_SHIFT - FSHIFT);
-
-               val.procs = nr_threads;
-       } while (read_seqretry(&xtime_lock, seq));
-
-
-       si_meminfo(&val);
-       si_swapinfo(&val);
-       
-       err = put_user (val.uptime, &info->uptime);
-       err |= __put_user (val.loads[0], &info->loads[0]);
-       err |= __put_user (val.loads[1], &info->loads[1]);
-       err |= __put_user (val.loads[2], &info->loads[2]);
-       err |= __put_user (val.totalram, &info->totalram);
-       err |= __put_user (val.freeram, &info->freeram);
-       err |= __put_user (val.sharedram, &info->sharedram);
-       err |= __put_user (val.bufferram, &info->bufferram);
-       err |= __put_user (val.totalswap, &info->totalswap);
-       err |= __put_user (val.freeswap, &info->freeswap);
-       err |= __put_user (val.procs, &info->procs);
-       err |= __put_user (val.totalhigh, &info->totalhigh);
-       err |= __put_user (val.freehigh, &info->freehigh);
-       err |= __put_user (val.mem_unit, &info->mem_unit);
-       return err ? -EFAULT : 0;
-}
-
-
 /* lseek() needs a wrapper because 'offset' can be negative, but the top
  * half of the argument has been zeroed by syscall.S.
  */
index 701d66a596e8855d22ab3ddaa4a889b68b4500ce..be8eb9a0d24a7420879fc819b776870b01b21b21 100644 (file)
        /* struct rusage contains longs... */
        ENTRY_COMP(wait4)
        ENTRY_SAME(swapoff)             /* 115 */
-       ENTRY_DIFF(sysinfo)
+       ENTRY_COMP(sysinfo)
        ENTRY_SAME(shutdown)
        ENTRY_SAME(fsync)
        ENTRY_SAME(madvise)
index bad7d1eb62b975dff89921860ca30e816e948de3..5f1b51af06a9820ff54e57479c50543eacb0799f 100644 (file)
@@ -288,17 +288,6 @@ do_settimeofday (struct timespec *tv)
 }
 EXPORT_SYMBOL(do_settimeofday);
 
-/*
- * XXX: We can do better than this.
- * Returns nanoseconds
- */
-
-unsigned long long sched_clock(void)
-{
-       return (unsigned long long)jiffies * (1000000000 / HZ);
-}
-
-
 void __init start_cpu_itimer(void)
 {
        unsigned int cpu = smp_processor_id();
index 7b943b45f7cd518f7749aa50fcf6ed081d5615f0..3b78c2794c369e72bfe57d2bdd461fc8754b0d63 100644 (file)
@@ -173,10 +173,12 @@ SECTIONS
      from .altinstructions and .eh_frame */
   .exit.text : { *(.exit.text) }
   .exit.data : { *(.exit.data) }
+#ifdef CONFIG_BLK_DEV_INITRD
   . = ALIGN(ASM_PAGE_SIZE);
   __initramfs_start = .;
   .init.ramfs : { *(.init.ramfs) }
   __initramfs_end = .;
+#endif
   . = ALIGN(32);
   __per_cpu_start = .;
   .data.percpu  : { *(.data.percpu) }
index 0667f2b4f9775b13ab6fbc527884de52022bfa34..0c118e584e7341bde28a65fdc2d23a2c5929fe79 100644 (file)
@@ -808,9 +808,7 @@ void __init paging_init(void)
        for (i = 0; i < npmem_ranges; i++) {
                unsigned long zones_size[MAX_NR_ZONES] = { 0, };
 
-               /* We have an IOMMU, so all memory can go into a single
-                  ZONE_DMA zone. */
-               zones_size[ZONE_DMA] = pmem_ranges[i].pages;
+               zones_size[ZONE_NORMAL] = pmem_ranges[i].pages;
 
 #ifdef CONFIG_DISCONTIGMEM
                /* Need to initialize the pfnnid_map before we can initialize
index f08e80a0bf0addaf3a33d95f30238a6064f4a53e..0088c5ebca78190328a382ceebaa522ded7489b0 100644 (file)
@@ -977,6 +977,10 @@ config ISA
          have an IBM RS/6000 or pSeries machine or a PReP machine, say Y.  If
          you have an embedded board, consult your board documentation.
 
+config ZONE_DMA
+       bool
+       default y
+
 config GENERIC_ISA_DMA
        bool
        depends on PPC64 || POWER4 || 6xx && !CPM2
index dd7001cacf75cfc09040b05961c39bb7c0471cfd..3d437c32546ee6a463af22c4a0270e28279cae71 100644 (file)
@@ -71,7 +71,6 @@ static int __init proc_ppc64_init(void)
        pde = create_proc_entry("ppc64/systemcfg", S_IFREG|S_IRUGO, NULL);
        if (!pde)
                return 1;
-       pde->nlink = 1;
        pde->data = vdso_data;
        pde->size = PAGE_SIZE;
        pde->proc_fops = &page_map_fops;
index 0c4fcd34bfe585ce199271ec7f73fcc549e9d171..65e4ebe8db319e58c16730c37642a13770a80f43 100644 (file)
@@ -708,7 +708,6 @@ static struct proc_dir_entry *create_flash_pde(const char *filename,
 
        ent = create_proc_entry(filename, S_IRUSR | S_IWUSR, NULL);
        if (ent != NULL) {
-               ent->nlink = 1;
                ent->proc_fops = fops;
                ent->owner = THIS_MODULE;
        }
index 03a2a2f30d66dfcf555881fd05bed1228de6dbd7..673e8d9df7f58e0067d9eee854c5e789741d90e0 100644 (file)
@@ -198,73 +198,6 @@ static inline long put_tv32(struct compat_timeval __user *o, struct timeval *i)
                 __put_user(i->tv_usec, &o->tv_usec)));
 }
 
-struct sysinfo32 {
-        s32 uptime;
-        u32 loads[3];
-        u32 totalram;
-        u32 freeram;
-        u32 sharedram;
-        u32 bufferram;
-        u32 totalswap;
-        u32 freeswap;
-        unsigned short procs;
-       unsigned short pad;
-       u32 totalhigh;
-       u32 freehigh;
-       u32 mem_unit;
-       char _f[20-2*sizeof(int)-sizeof(int)];
-};
-
-asmlinkage long compat_sys_sysinfo(struct sysinfo32 __user *info)
-{
-       struct sysinfo s;
-       int ret, err;
-       int bitcount=0;
-       mm_segment_t old_fs = get_fs ();
-       
-       /* The __user cast is valid due to set_fs() */
-       set_fs (KERNEL_DS);
-       ret = sys_sysinfo((struct sysinfo __user *)&s);
-       set_fs (old_fs);
-
-       /* Check to see if any memory value is too large for 32-bit and
-         * scale down if needed.
-         */
-       if ((s.totalram >> 32) || (s.totalswap >> 32)) {
-           while (s.mem_unit < PAGE_SIZE) {
-               s.mem_unit <<= 1;
-               bitcount++;
-           }
-           s.totalram >>=bitcount;
-           s.freeram >>= bitcount;
-           s.sharedram >>= bitcount;
-           s.bufferram >>= bitcount;
-           s.totalswap >>= bitcount;
-           s.freeswap >>= bitcount;
-           s.totalhigh >>= bitcount;
-           s.freehigh >>= bitcount;
-       }
-
-       err = put_user (s.uptime, &info->uptime);
-       err |= __put_user (s.loads[0], &info->loads[0]);
-       err |= __put_user (s.loads[1], &info->loads[1]);
-       err |= __put_user (s.loads[2], &info->loads[2]);
-       err |= __put_user (s.totalram, &info->totalram);
-       err |= __put_user (s.freeram, &info->freeram);
-       err |= __put_user (s.sharedram, &info->sharedram);
-       err |= __put_user (s.bufferram, &info->bufferram);
-       err |= __put_user (s.totalswap, &info->totalswap);
-       err |= __put_user (s.freeswap, &info->freeswap);
-       err |= __put_user (s.procs, &info->procs);
-       err |= __put_user (s.totalhigh, &info->totalhigh);
-       err |= __put_user (s.freehigh, &info->freehigh);
-       err |= __put_user (s.mem_unit, &info->mem_unit);
-       if (err)
-               return -EFAULT;
-       
-       return ret;
-}
-
 
 
 
index ae0ede19879ded35d9dba71b760e887aff75e020..50149ec6efa4354c29e0013f7131492baf17939b 100644 (file)
 /* Max supported size for symbol names */
 #define MAX_SYMNAME    64
 
+#define VDSO32_MAXPAGES        (((0x3000 + PAGE_MASK) >> PAGE_SHIFT) + 2)
+#define VDSO64_MAXPAGES        (((0x3000 + PAGE_MASK) >> PAGE_SHIFT) + 2)
+
 extern char vdso32_start, vdso32_end;
 static void *vdso32_kbase = &vdso32_start;
 unsigned int vdso32_pages;
+static struct page *vdso32_pagelist[VDSO32_MAXPAGES];
 unsigned long vdso32_sigtramp;
 unsigned long vdso32_rt_sigtramp;
 
@@ -59,6 +63,7 @@ unsigned long vdso32_rt_sigtramp;
 extern char vdso64_start, vdso64_end;
 static void *vdso64_kbase = &vdso64_start;
 unsigned int vdso64_pages;
+static struct page *vdso64_pagelist[VDSO64_MAXPAGES];
 unsigned long vdso64_rt_sigtramp;
 #endif /* CONFIG_PPC64 */
 
@@ -164,55 +169,6 @@ static void dump_vdso_pages(struct vm_area_struct * vma)
 }
 #endif /* DEBUG */
 
-/*
- * Keep a dummy vma_close for now, it will prevent VMA merging.
- */
-static void vdso_vma_close(struct vm_area_struct * vma)
-{
-}
-
-/*
- * Our nopage() function, maps in the actual vDSO kernel pages, they will
- * be mapped read-only by do_no_page(), and eventually COW'ed, either
- * right away for an initial write access, or by do_wp_page().
- */
-static struct page * vdso_vma_nopage(struct vm_area_struct * vma,
-                                    unsigned long address, int *type)
-{
-       unsigned long offset = address - vma->vm_start;
-       struct page *pg;
-#ifdef CONFIG_PPC64
-       void *vbase = (vma->vm_mm->task_size > TASK_SIZE_USER32) ?
-               vdso64_kbase : vdso32_kbase;
-#else
-       void *vbase = vdso32_kbase;
-#endif
-
-       DBG("vdso_vma_nopage(current: %s, address: %016lx, off: %lx)\n",
-           current->comm, address, offset);
-
-       if (address < vma->vm_start || address > vma->vm_end)
-               return NOPAGE_SIGBUS;
-
-       /*
-        * Last page is systemcfg.
-        */
-       if ((vma->vm_end - address) <= PAGE_SIZE)
-               pg = virt_to_page(vdso_data);
-       else
-               pg = virt_to_page(vbase + offset);
-
-       get_page(pg);
-       DBG(" ->page count: %d\n", page_count(pg));
-
-       return pg;
-}
-
-static struct vm_operations_struct vdso_vmops = {
-       .close  = vdso_vma_close,
-       .nopage = vdso_vma_nopage,
-};
-
 /*
  * This is called from binfmt_elf, we create the special vma for the
  * vDSO and insert it into the mm struct tree
@@ -221,20 +177,23 @@ int arch_setup_additional_pages(struct linux_binprm *bprm,
                                int executable_stack)
 {
        struct mm_struct *mm = current->mm;
-       struct vm_area_struct *vma;
+       struct page **vdso_pagelist;
        unsigned long vdso_pages;
        unsigned long vdso_base;
        int rc;
 
 #ifdef CONFIG_PPC64
        if (test_thread_flag(TIF_32BIT)) {
+               vdso_pagelist = vdso32_pagelist;
                vdso_pages = vdso32_pages;
                vdso_base = VDSO32_MBASE;
        } else {
+               vdso_pagelist = vdso64_pagelist;
                vdso_pages = vdso64_pages;
                vdso_base = VDSO64_MBASE;
        }
 #else
+       vdso_pagelist = vdso32_pagelist;
        vdso_pages = vdso32_pages;
        vdso_base = VDSO32_MBASE;
 #endif
@@ -262,17 +221,6 @@ int arch_setup_additional_pages(struct linux_binprm *bprm,
                goto fail_mmapsem;
        }
 
-
-       /* Allocate a VMA structure and fill it up */
-       vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
-       if (vma == NULL) {
-               rc = -ENOMEM;
-               goto fail_mmapsem;
-       }
-       vma->vm_mm = mm;
-       vma->vm_start = vdso_base;
-       vma->vm_end = vma->vm_start + (vdso_pages << PAGE_SHIFT);
-
        /*
         * our vma flags don't have VM_WRITE so by default, the process isn't
         * allowed to write those pages.
@@ -282,32 +230,26 @@ int arch_setup_additional_pages(struct linux_binprm *bprm,
         * and your nice userland gettimeofday will be totally dead.
         * It's fine to use that for setting breakpoints in the vDSO code
         * pages though
-        */
-       vma->vm_flags = VM_READ|VM_EXEC|VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC;
-       /*
+        *
         * Make sure the vDSO gets into every core dump.
         * Dumping its contents makes post-mortem fully interpretable later
         * without matching up the same kernel and hardware config to see
         * what PC values meant.
         */
-       vma->vm_flags |= VM_ALWAYSDUMP;
-       vma->vm_flags |= mm->def_flags;
-       vma->vm_page_prot = protection_map[vma->vm_flags & 0x7];
-       vma->vm_ops = &vdso_vmops;
-
-       /* Insert new VMA */
-       rc = insert_vm_struct(mm, vma);
+       rc = install_special_mapping(mm, vdso_base, vdso_pages << PAGE_SHIFT,
+                                    VM_READ|VM_EXEC|
+                                    VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC|
+                                    VM_ALWAYSDUMP,
+                                    vdso_pagelist);
        if (rc)
-               goto fail_vma;
+               goto fail_mmapsem;
 
-       /* Put vDSO base into mm struct and account for memory usage */
+       /* Put vDSO base into mm struct */
        current->mm->context.vdso_base = vdso_base;
-       mm->total_vm += (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
+
        up_write(&mm->mmap_sem);
        return 0;
 
- fail_vma:
-       kmem_cache_free(vm_area_cachep, vma);
  fail_mmapsem:
        up_write(&mm->mmap_sem);
        return rc;
@@ -778,18 +720,26 @@ void __init vdso_init(void)
        }
 
        /* Make sure pages are in the correct state */
+       BUG_ON(vdso32_pages + 2 > VDSO32_MAXPAGES);
        for (i = 0; i < vdso32_pages; i++) {
                struct page *pg = virt_to_page(vdso32_kbase + i*PAGE_SIZE);
                ClearPageReserved(pg);
                get_page(pg);
-
+               vdso32_pagelist[i] = pg;
        }
+       vdso32_pagelist[i++] = virt_to_page(vdso_data);
+       vdso32_pagelist[i] = NULL;
+
 #ifdef CONFIG_PPC64
+       BUG_ON(vdso64_pages + 2 > VDSO64_MAXPAGES);
        for (i = 0; i < vdso64_pages; i++) {
                struct page *pg = virt_to_page(vdso64_kbase + i*PAGE_SIZE);
                ClearPageReserved(pg);
                get_page(pg);
+               vdso64_pagelist[i] = pg;
        }
+       vdso64_pagelist[i++] = virt_to_page(vdso_data);
+       vdso64_pagelist[i] = NULL;
 #endif /* CONFIG_PPC64 */
 
        get_page(virt_to_page(vdso_data));
index 04b8e71bf5b0087a814fba70bd47dce22eda717f..7eefeb4a30e70b9837f3e50eb045444521095baf 100644 (file)
@@ -131,14 +131,14 @@ SECTIONS
                __stop___fw_ftr_fixup = .;
        }
 #endif
-
+#ifdef CONFIG_BLK_DEV_INITRD
        . = ALIGN(PAGE_SIZE);
        .init.ramfs : {
                __initramfs_start = .;
                *(.init.ramfs)
                __initramfs_end = .;
        }
-
+#endif
 #ifdef CONFIG_PPC32
        . = ALIGN(32);
 #else
index b43466ba8096259222d45c51a8a6ba884c15d577..67d617b60a2344ab00a78a9b32e7fb508f1b05fc 100644 (file)
@@ -149,7 +149,8 @@ static int cbe_nr_iommus;
 static void invalidate_tce_cache(struct cbe_iommu *iommu, unsigned long *pte,
                long n_ptes)
 {
-       unsigned long *reg, val;
+       unsigned long __iomem *reg;
+       unsigned long val;
        long n;
 
        reg = iommu->xlate_regs + IOC_IOPT_CacheInvd;
@@ -592,7 +593,7 @@ static void __init cell_iommu_init_one(struct device_node *np, unsigned long off
        /* Init base fields */
        i = cbe_nr_iommus++;
        iommu = &iommus[i];
-       iommu->stab = 0;
+       iommu->stab = NULL;
        iommu->nid = nid;
        snprintf(iommu->name, sizeof(iommu->name), "iommu%d", i);
        INIT_LIST_HEAD(&iommu->windows);
index 867f83a7d0c9a82b5616f180b3f345007c8c0b3d..98de836dfed3fd4e7219e6a43130ad7bde04a1a3 100644 (file)
@@ -65,13 +65,13 @@ static inline u8 celleb_fake_config_readb(void *addr)
 
 static inline u16 celleb_fake_config_readw(void *addr)
 {
-       u16 *p = addr;
+       __le16 *p = addr;
        return le16_to_cpu(*p);
 }
 
 static inline u32 celleb_fake_config_readl(void *addr)
 {
-       u32 *p = addr;
+       __le32 *p = addr;
        return le32_to_cpu(*p);
 }
 
@@ -83,16 +83,16 @@ static inline void celleb_fake_config_writeb(u32 val, void *addr)
 
 static inline void celleb_fake_config_writew(u32 val, void *addr)
 {
-       u16 val16;
-       u16 *p = addr;
+       __le16 val16;
+       __le16 *p = addr;
        val16 = cpu_to_le16(val);
        *p = val16;
 }
 
 static inline void celleb_fake_config_writel(u32 val, void *addr)
 {
-       u32 val32;
-       u32 *p = addr;
+       __le32 val32;
+       __le32 *p = addr;
        val32 = cpu_to_le32(val);
        *p = val32;
 }
index 0edbc0c4f338e8ca916a9afc2981256ecc6a1b43..c11b39c3776a5565848a4e3c8d723cb314316579 100644 (file)
@@ -47,7 +47,7 @@
 #if 0 /* test code for epci dummy read */
 static void celleb_epci_dummy_read(struct pci_dev *dev)
 {
-       void *epci_base;
+       void __iomem *epci_base;
        struct device_node *node;
        struct pci_controller *hose;
        u32 val;
@@ -58,7 +58,7 @@ static void celleb_epci_dummy_read(struct pci_dev *dev)
        if (!hose)
                return;
 
-       epci_base = (void *)hose->cfg_addr;
+       epci_base = hose->cfg_addr;
 
        val = in_be32(epci_base + SCC_EPCI_WATRP);
        iosync();
@@ -71,18 +71,18 @@ static inline void clear_and_disable_master_abort_interrupt(
                                        struct pci_controller *hose)
 {
        void __iomem *addr;
-       addr = (void *)hose->cfg_addr + PCI_COMMAND;
+       addr = hose->cfg_addr + PCI_COMMAND;
        out_be32(addr, in_be32(addr) | (PCI_STATUS_REC_MASTER_ABORT << 16));
 }
 
 static int celleb_epci_check_abort(struct pci_controller *hose,
-                                  unsigned long addr)
+                                  void __iomem *addr)
 {
        void __iomem *reg, *epci_base;
        u32 val;
 
        iob();
-       epci_base = (void *)hose->cfg_addr;
+       epci_base = hose->cfg_addr;
 
        reg = epci_base + PCI_COMMAND;
        val = in_be32(reg);
@@ -108,23 +108,23 @@ static int celleb_epci_check_abort(struct pci_controller *hose,
        return PCIBIOS_SUCCESSFUL;
 }
 
-static unsigned long celleb_epci_make_config_addr(struct pci_controller *hose,
+static void __iomem *celleb_epci_make_config_addr(struct pci_controller *hose,
                                        unsigned int devfn, int where)
 {
-       unsigned long addr;
+       void __iomem *addr;
        struct pci_bus *bus = hose->bus;
 
        if (bus->self)
-               addr = (unsigned long)hose->cfg_data +
+               addr = hose->cfg_data +
                       (((bus->number & 0xff) << 16)
                        | ((devfn & 0xff) << 8)
                        | (where & 0xff)
                        | 0x01000000);
        else
-               addr = (unsigned long)hose->cfg_data +
+               addr = hose->cfg_data +
                       (((devfn & 0xff) << 8) | (where & 0xff));
 
-       pr_debug("EPCI: config_addr = 0x%016lx\n", addr);
+       pr_debug("EPCI: config_addr = 0x%p\n", addr);
 
        return addr;
 }
@@ -132,7 +132,7 @@ static unsigned long celleb_epci_make_config_addr(struct pci_controller *hose,
 static int celleb_epci_read_config(struct pci_bus *bus,
                        unsigned int devfn, int where, int size, u32 * val)
 {
-       unsigned long addr;
+       void __iomem *addr;
        struct device_node *node;
        struct pci_controller *hose;
 
@@ -148,17 +148,17 @@ static int celleb_epci_read_config(struct pci_bus *bus,
        if (bus->number == hose->first_busno && devfn == 0) {
                /* EPCI controller self */
 
-               addr = (unsigned long)hose->cfg_addr + where;
+               addr = hose->cfg_addr + where;
 
                switch (size) {
                case 1:
-                       *val = in_8((u8 *)addr);
+                       *val = in_8(addr);
                        break;
                case 2:
-                       *val = in_be16((u16 *)addr);
+                       *val = in_be16(addr);
                        break;
                case 4:
-                       *val = in_be32((u32 *)addr);
+                       *val = in_be32(addr);
                        break;
                default:
                        return PCIBIOS_DEVICE_NOT_FOUND;
@@ -171,13 +171,13 @@ static int celleb_epci_read_config(struct pci_bus *bus,
 
                switch (size) {
                case 1:
-                       *val = in_8((u8 *)addr);
+                       *val = in_8(addr);
                        break;
                case 2:
-                       *val = in_le16((u16 *)addr);
+                       *val = in_le16(addr);
                        break;
                case 4:
-                       *val = in_le32((u32 *)addr);
+                       *val = in_le32(addr);
                        break;
                default:
                        return PCIBIOS_DEVICE_NOT_FOUND;
@@ -188,13 +188,13 @@ static int celleb_epci_read_config(struct pci_bus *bus,
                 "addr=0x%lx, devfn=0x%x, where=0x%x, size=0x%x, val=0x%x\n",
                 addr, devfn, where, size, *val);
 
-       return celleb_epci_check_abort(hose, 0);
+       return celleb_epci_check_abort(hose, NULL);
 }
 
 static int celleb_epci_write_config(struct pci_bus *bus,
                        unsigned int devfn, int where, int size, u32 val)
 {
-       unsigned long addr;
+       void __iomem *addr;
        struct device_node *node;
        struct pci_controller *hose;
 
@@ -210,17 +210,17 @@ static int celleb_epci_write_config(struct pci_bus *bus,
        if (bus->number == hose->first_busno && devfn == 0) {
                /* EPCI controller self */
 
-               addr = (unsigned long)hose->cfg_addr + where;
+               addr = hose->cfg_addr + where;
 
                switch (size) {
                case 1:
-                       out_8((u8 *)addr, val);
+                       out_8(addr, val);
                        break;
                case 2:
-                       out_be16((u16 *)addr, val);
+                       out_be16(addr, val);
                        break;
                case 4:
-                       out_be32((u32 *)addr, val);
+                       out_be32(addr, val);
                        break;
                default:
                        return PCIBIOS_DEVICE_NOT_FOUND;
@@ -233,13 +233,13 @@ static int celleb_epci_write_config(struct pci_bus *bus,
 
                switch (size) {
                case 1:
-                       out_8((u8 *)addr, val);
+                       out_8(addr, val);
                        break;
                case 2:
-                       out_le16((u16 *)addr, val);
+                       out_le16(addr, val);
                        break;
                case 4:
-                       out_le32((u32 *)addr, val);
+                       out_le32(addr, val);
                        break;
                default:
                        return PCIBIOS_DEVICE_NOT_FOUND;
@@ -261,7 +261,7 @@ static int __devinit celleb_epci_init(struct pci_controller *hose)
        void __iomem *reg, *epci_base;
        int hwres = 0;
 
-       epci_base = (void *)hose->cfg_addr;
+       epci_base = hose->cfg_addr;
 
        /* PCI core reset(Internal bus and PCI clock) */
        reg = epci_base + SCC_EPCI_CKCTRL;
index e1f51d45598445e00d6a3fbbfe0a445cd2fd01c7..117c9a0055bd734939b3ac5269c96edeef08f9c7 100644 (file)
@@ -75,7 +75,7 @@ extern irqreturn_t xmon_irq(int, void *);
 extern unsigned long loops_per_jiffy;
 
 /* To be replaced by RTAS when available */
-static unsigned int *briq_SPOR;
+static unsigned int __iomem *briq_SPOR;
 
 #ifdef CONFIG_SMP
 extern struct smp_ops_t chrp_smp_ops;
@@ -267,7 +267,7 @@ void __init chrp_setup_arch(void)
        } else if (machine && strncmp(machine, "TotalImpact,BRIQ-1", 18) == 0) {
                _chrp_type = _CHRP_briq;
                /* Map the SPOR register on briq and change the restart hook */
-               briq_SPOR = (unsigned int *)ioremap(0xff0000e8, 4);
+               briq_SPOR = ioremap(0xff0000e8, 4);
                ppc_md.restart = briq_restart;
        } else {
                /* Let's assume it is an IBM chrp if all else fails */
index 1ad0e4aaad1a0d5ba514e4d1d136c9cf7d40907c..90d3d49f713e827b6312d43a8656f4981d3b397c 100644 (file)
@@ -1253,7 +1253,6 @@ static int __init mf_proc_init(void)
                ent = create_proc_entry("cmdline", S_IFREG|S_IRUSR|S_IWUSR, mf);
                if (!ent)
                        return 1;
-               ent->nlink = 1;
                ent->data = (void *)(long)i;
                ent->read_proc = proc_mf_dump_cmdline;
                ent->write_proc = proc_mf_change_cmdline;
@@ -1264,7 +1263,6 @@ static int __init mf_proc_init(void)
                ent = create_proc_entry("vmlinux", S_IFREG|S_IWUSR, mf);
                if (!ent)
                        return 1;
-               ent->nlink = 1;
                ent->data = (void *)(long)i;
                ent->proc_fops = &proc_vmlinux_operations;
        }
@@ -1272,7 +1270,6 @@ static int __init mf_proc_init(void)
        ent = create_proc_entry("side", S_IFREG|S_IRUSR|S_IWUSR, mf_proc_root);
        if (!ent)
                return 1;
-       ent->nlink = 1;
        ent->data = (void *)0;
        ent->read_proc = proc_mf_dump_side;
        ent->write_proc = proc_mf_change_side;
@@ -1280,7 +1277,6 @@ static int __init mf_proc_init(void)
        ent = create_proc_entry("src", S_IFREG|S_IRUSR|S_IWUSR, mf_proc_root);
        if (!ent)
                return 1;
-       ent->nlink = 1;
        ent->data = (void *)0;
        ent->read_proc = proc_mf_dump_src;
        ent->write_proc = proc_mf_change_src;
index bb17283275aa7122aaa4c13d6cd7df99cba968f1..631c30095617889efa43a8af7dcde0bbfc91c998 100644 (file)
@@ -194,6 +194,7 @@ int ps3_alloc_io_irq(enum ps3_cpu_binding cpu, unsigned int interrupt_id,
 
        return result;
 }
+EXPORT_SYMBOL_GPL(ps3_alloc_io_irq);
 
 int ps3_free_io_irq(unsigned int virq)
 {
@@ -209,6 +210,7 @@ int ps3_free_io_irq(unsigned int virq)
 
        return result;
 }
+EXPORT_SYMBOL_GPL(ps3_free_io_irq);
 
 /**
  * ps3_alloc_event_irq - Allocate a virq for use with a system event.
index bce6136cbce706ac3887a1d11be0c97ba7908a57..a9f7e4a39a2ae26041e3928fbaf7c969ea3c12a8 100644 (file)
@@ -57,6 +57,7 @@ int ps3_mmio_region_create(struct ps3_mmio_region *r)
        dump_mmio_region(r);
        return result;
 }
+EXPORT_SYMBOL_GPL(ps3_mmio_region_create);
 
 int ps3_free_mmio_region(struct ps3_mmio_region *r)
 {
@@ -72,6 +73,7 @@ int ps3_free_mmio_region(struct ps3_mmio_region *r)
        r->lpar_addr = 0;
        return result;
 }
+EXPORT_SYMBOL_GPL(ps3_free_mmio_region);
 
 static int ps3_system_bus_match(struct device *_dev,
        struct device_driver *_drv)
index 4ad33e41b0082794582e9a8710d063aa6e7ab599..789a5e99aefdedc7b77c6bdbd719494df50b06a1 100644 (file)
@@ -513,7 +513,6 @@ static int proc_ppc64_create_ofdt(void)
 
        ent = create_proc_entry("ppc64/ofdt", S_IWUSR, NULL);
        if (ent) {
-               ent->nlink = 1;
                ent->data = NULL;
                ent->size = 0;
                ent->proc_fops = &ofdt_fops;
index ee929c641bf3205a3a57b09a8e61b232bb897cfb..e5f89837c82e0edb39e77e39ccea793ca08a4736 100644 (file)
@@ -85,7 +85,7 @@ get_index_for_opcode (unsigned int insn)
   if ((index = spu_disassemble_table[opcode & 0x7ff]) != 0)
     return index;
 
-  return 0;
+  return NULL;
 }
 
 /* Print a Spu instruction.  */
index c22e60619d9bb6c257f0b7a6483c355cf45112ea..0df9c33629fd992159cf95406157886dff090994 100644 (file)
@@ -1177,6 +1177,10 @@ config ISA
          have an IBM RS/6000 or pSeries machine or a PReP machine, say Y.  If
          you have an embedded board, consult your board documentation.
 
+config ZONE_DMA
+       bool
+       default y
+
 config GENERIC_ISA_DMA
        bool
        depends on 6xx && !CPM2
index 61921268a0d00c290e7dfd1db163a8311d934461..a0625562a44bb7a82db233c6388b984662ec44a8 100644 (file)
@@ -135,10 +135,12 @@ SECTIONS
   .data.percpu  : { *(.data.percpu) }
   __per_cpu_end = .;
 
+#ifdef CONFIG_BLK_DEV_INITRD
   . = ALIGN(4096);
   __initramfs_start = .;
   .init.ramfs : { *(.init.ramfs) }
   __initramfs_end = .;
+#endif
 
   . = ALIGN(4096);
   __init_end = .;
index eaed402ad3460a758872ccf271971a36f6042add..eaaac3788110ec90ad076dc92d922da452675242 100644 (file)
@@ -7,6 +7,10 @@ config MMU
        bool
        default y
 
+config ZONE_DMA
+       bool
+       default y
+
 config LOCKDEP_SUPPORT
        bool
        default y
@@ -37,6 +41,9 @@ config GENERIC_HWEIGHT
 config GENERIC_TIME
        def_bool y
 
+config NO_IOMEM
+       def_bool y
+
 mainmenu "Linux Kernel Configuration"
 
 config S390
index 7c621b8ef68370eb7f7dd5f023db1dd0fb87b9e6..1406400bf3ea3b18a25779227e71013ea4e4a13b 100644 (file)
@@ -179,6 +179,8 @@ CONFIG_XFRM=y
 # CONFIG_XFRM_USER is not set
 # CONFIG_XFRM_SUB_POLICY is not set
 CONFIG_NET_KEY=y
+CONFIG_IUCV=m
+CONFIG_AFIUCV=m
 CONFIG_INET=y
 CONFIG_IP_MULTICAST=y
 # CONFIG_IP_ADVANCED_ROUTER is not set
@@ -508,7 +510,6 @@ CONFIG_NET_ETHERNET=y
 #
 CONFIG_LCS=m
 CONFIG_CTC=m
-CONFIG_IUCV=m
 # CONFIG_NETIUCV is not set
 # CONFIG_SMSGIUCV is not set
 # CONFIG_CLAW is not set
index 666bb6daa148e649d3156aea4b88c65e7c553b3e..664c669b1856ac881e96bca89b8c5a2429a517c6 100644 (file)
@@ -398,51 +398,6 @@ int cp_compat_stat(struct kstat *stat, struct compat_stat __user *statbuf)
        return err;
 }
 
-struct sysinfo32 {
-        s32 uptime;
-        u32 loads[3];
-        u32 totalram;
-        u32 freeram;
-        u32 sharedram;
-        u32 bufferram;
-        u32 totalswap;
-        u32 freeswap;
-        unsigned short procs;
-       unsigned short pads;
-       u32 totalhigh;
-       u32 freehigh;
-       unsigned int mem_unit;
-        char _f[8];
-};
-
-asmlinkage long sys32_sysinfo(struct sysinfo32 __user *info)
-{
-       struct sysinfo s;
-       int ret, err;
-       mm_segment_t old_fs = get_fs ();
-       
-       set_fs (KERNEL_DS);
-       ret = sys_sysinfo((struct sysinfo __force __user *) &s);
-       set_fs (old_fs);
-       err = put_user (s.uptime, &info->uptime);
-       err |= __put_user (s.loads[0], &info->loads[0]);
-       err |= __put_user (s.loads[1], &info->loads[1]);
-       err |= __put_user (s.loads[2], &info->loads[2]);
-       err |= __put_user (s.totalram, &info->totalram);
-       err |= __put_user (s.freeram, &info->freeram);
-       err |= __put_user (s.sharedram, &info->sharedram);
-       err |= __put_user (s.bufferram, &info->bufferram);
-       err |= __put_user (s.totalswap, &info->totalswap);
-       err |= __put_user (s.freeswap, &info->freeswap);
-       err |= __put_user (s.procs, &info->procs);
-       err |= __put_user (s.totalhigh, &info->totalhigh);
-       err |= __put_user (s.freehigh, &info->freehigh);
-       err |= __put_user (s.mem_unit, &info->mem_unit);
-       if (err)
-               return -EFAULT;
-       return ret;
-}
-
 asmlinkage long sys32_sched_rr_get_interval(compat_pid_t pid,
                                struct compat_timespec __user *interval)
 {
index 71e54ef0931e1846d35ae784462a993ca21d4705..97901296894eae6785bf74edfc6cceb2842f6656 100644 (file)
@@ -517,10 +517,10 @@ sys32_swapoff_wrapper:
        llgtr   %r2,%r2                 # const char *
        jg      sys_swapoff             # branch to system call
 
-       .globl  sys32_sysinfo_wrapper
-sys32_sysinfo_wrapper:
+       .globl  compat_sys_sysinfo_wrapper
+compat_sys_sysinfo_wrapper:
        llgtr   %r2,%r2                 # struct sysinfo_emu31 *
-       jg      sys32_sysinfo           # branch to system call
+       jg      compat_sys_sysinfo      # branch to system call
 
        .globl  sys32_ipc_wrapper
 sys32_ipc_wrapper:
index a4ceae3dbcf1b5fe8ed8ae27b931a56d8791b346..a52c44455bf0bbb20db3e3f65e8d9edc0c9fc5a5 100644 (file)
@@ -124,7 +124,7 @@ NI_SYSCALL                                                  /* old "idle" system call */
 NI_SYSCALL                                                     /* vm86old for i386 */
 SYSCALL(sys_wait4,sys_wait4,compat_sys_wait4_wrapper)
 SYSCALL(sys_swapoff,sys_swapoff,sys32_swapoff_wrapper)         /* 115 */
-SYSCALL(sys_sysinfo,sys_sysinfo,sys32_sysinfo_wrapper)
+SYSCALL(sys_sysinfo,sys_sysinfo,compat_sys_sysinfo_wrapper)
 SYSCALL(sys_ipc,sys_ipc,sys32_ipc_wrapper)
 SYSCALL(sys_fsync,sys_fsync,sys32_fsync_wrapper)
 SYSCALL(sys_sigreturn_glue,sys_sigreturn_glue,sys32_sigreturn_glue)
index a4890739252230df4ebb28cc70a0e79915aa7bd0..c30716ae130ca7b47afc2183997cc387923013f8 100644 (file)
@@ -91,11 +91,14 @@ SECTIONS
   .con_initcall.init : { *(.con_initcall.init) }
   __con_initcall_end = .;
   SECURITY_INIT
+
+#ifdef CONFIG_BLK_DEV_INITRD
   . = ALIGN(256);
   __initramfs_start = .;
   .init.ramfs : { *(.init.initramfs) }
   . = ALIGN(2);
   __initramfs_end = .;
+#endif
   . = ALIGN(256);
   __per_cpu_start = .;
   .data.percpu  : { *(.data.percpu) }
index 8e09db1edbb91a8cb835d35e7af6605d65c2364e..f95449b29fa5229bcb16bdb3dd9262b9121c2f5b 100644 (file)
@@ -2,6 +2,6 @@
 # Makefile for the linux s390-specific parts of the memory manager.
 #
 
-obj-y   := init.o fault.o ioremap.o extmem.o mmap.o vmem.o
+obj-y   := init.o fault.o extmem.o mmap.o vmem.o
 obj-$(CONFIG_CMM) += cmm.o
 
index 9ff143e87746b5ac0bf350c1496307c10506d123..641aef36ccc498847ee90fb42c77fa676f496d9d 100644 (file)
@@ -83,12 +83,10 @@ static inline int notify_page_fault(enum die_val val, const char *str,
 }
 #endif
 
-extern spinlock_t timerlist_lock;
 
 /*
  * Unlock any spinlocks which will prevent us from getting the
- * message out (timerlist_lock is acquired through the
- * console unblank code)
+ * message out.
  */
 void bust_spinlocks(int yes)
 {
diff --git a/arch/s390/mm/ioremap.c b/arch/s390/mm/ioremap.c
deleted file mode 100644 (file)
index 3d2100a..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- *  arch/s390/mm/ioremap.c
- *
- *  S390 version
- *    Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
- *    Author(s): Hartmut Penner (hp@de.ibm.com)
- *
- *  Derived from "arch/i386/mm/extable.c"
- *    (C) Copyright 1995 1996 Linus Torvalds
- *
- * Re-map IO memory to kernel address space so that we can access it.
- * This is needed for high PCI addresses that aren't mapped in the
- * 640k-1MB IO memory area on PC's
- */
-
-#include <linux/vmalloc.h>
-#include <linux/mm.h>
-#include <linux/io.h>
-#include <asm/pgalloc.h>
-
-/*
- * Generic mapping function (not visible outside):
- */
-
-/*
- * Remap an arbitrary physical address space into the kernel virtual
- * address space. Needed when the kernel wants to access high addresses
- * directly.
- */
-void * __ioremap(unsigned long phys_addr, unsigned long size, unsigned long flags)
-{
-       void * addr;
-       struct vm_struct * area;
-
-       if (phys_addr < virt_to_phys(high_memory))
-               return phys_to_virt(phys_addr);
-       if (phys_addr & ~PAGE_MASK)
-               return NULL;
-       size = PAGE_ALIGN(size);
-       if (!size || size > phys_addr + size)
-               return NULL;
-       area = get_vm_area(size, VM_IOREMAP);
-       if (!area)
-               return NULL;
-       addr = area->addr;
-       if (ioremap_page_range((unsigned long)addr, (unsigned long)addr + size,
-                              phys_addr, __pgprot(flags))) {
-               vfree(addr);
-               return NULL;
-       }
-       return addr;
-}
-
-void iounmap(void *addr)
-{
-       if (addr > high_memory)
-               vfree(addr);
-}
index 3aa3b885ab36ae4fd9575d44e8a7691c5ad03e3e..4f3891215b87c83f3ff03252558e78b74b981bbd 100644 (file)
@@ -48,6 +48,9 @@ config GENERIC_IOMAP
 config GENERIC_TIME
        def_bool n
 
+config SYS_SUPPORTS_APM_EMULATION
+       bool
+
 config ARCH_MAY_HAVE_PC_FDC
        bool
 
@@ -126,6 +129,7 @@ config SH_7751_SYSTEMH
 
 config SH_HP6XX
        bool "HP6XX"
+       select SYS_SUPPORTS_APM_EMULATION
        help
          Select HP6XX if configuring for a HP jornada HP6xx.
          More information (hardware only) at
@@ -694,9 +698,6 @@ depends on EXPERIMENTAL
 
 source kernel/power/Kconfig
 
-config APM
-       bool "Advanced Power Management Emulation"
-       depends on PM
 endmenu
 
 source "net/Kconfig"
index d146cdaa0b8b03897b5f09e68aec42f2acd4abd4..d1c1460c8a06ecf7905fe303f62ce9af03eb6f1f 100644 (file)
@@ -7,12 +7,11 @@
  * modify it under the terms of the GNU General Public License.
  */
 #include <linux/module.h>
-#include <linux/apm_bios.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
-#include <asm/io.h>
-#include <asm/apm.h>
+#include <linux/apm-emulation.h>
+#include <linux/io.h>
 #include <asm/adc.h>
 #include <asm/hp6xx.h>
 
 
 #define MODNAME "hp6x0_apm"
 
-static int hp6x0_apm_get_info(char *buf, char **start, off_t fpos, int length)
+static void hp6x0_apm_get_power_status(struct apm_power_info *info)
 {
+       int battery, backup, charging, percentage;
        u8 pgdr;
-       char *p;
-       int battery_status;
-       int battery_flag;
-       int ac_line_status;
-       int time_units = APM_BATTERY_LIFE_UNKNOWN;
 
-       int battery = adc_single(ADC_CHANNEL_BATTERY);
-       int backup = adc_single(ADC_CHANNEL_BACKUP);
-       int charging = adc_single(ADC_CHANNEL_CHARGE);
-       int percentage;
+       battery         = adc_single(ADC_CHANNEL_BATTERY);
+       backup          = adc_single(ADC_CHANNEL_BACKUP);
+       charging        = adc_single(ADC_CHANNEL_CHARGE);
 
        percentage = 100 * (battery - HP680_BATTERY_MIN) /
                           (HP680_BATTERY_MAX - HP680_BATTERY_MIN);
 
-       ac_line_status = (battery > HP680_BATTERY_AC_ON) ?
+       info->ac_line_status = (battery > HP680_BATTERY_AC_ON) ?
                         APM_AC_ONLINE : APM_AC_OFFLINE;
 
-       p = buf;
-
        pgdr = ctrl_inb(SH7709_PGDR);
        if (pgdr & PGDR_MAIN_BATTERY_OUT) {
-               battery_status = APM_BATTERY_STATUS_NOT_PRESENT;
-               battery_flag = 0x80;
-               percentage = -1;
-       } else if (charging < 8 ) {
-               battery_status = APM_BATTERY_STATUS_CHARGING;
-               battery_flag = 0x08;
-               ac_line_status = 0xff;
+               info->battery_status    = APM_BATTERY_STATUS_NOT_PRESENT;
+               info->battery_flag      = 0x80;
+       } else if (charging < 8) {
+               info->battery_status    = APM_BATTERY_STATUS_CHARGING;
+               info->battery_flag      = 0x08;
+               info->ac_line_status = 0xff;
        } else if (percentage <= APM_CRITICAL) {
-               battery_status = APM_BATTERY_STATUS_CRITICAL;
-               battery_flag = 0x04;
+               info->battery_status    = APM_BATTERY_STATUS_CRITICAL;
+               info->battery_flag      = 0x04;
        } else if (percentage <= APM_LOW) {
-               battery_status = APM_BATTERY_STATUS_LOW;
-               battery_flag = 0x02;
+               info->battery_status    = APM_BATTERY_STATUS_LOW;
+               info->battery_flag      = 0x02;
        } else {
-               battery_status = APM_BATTERY_STATUS_HIGH;
-               battery_flag = 0x01;
+               info->battery_status    = APM_BATTERY_STATUS_HIGH;
+               info->battery_flag      = 0x01;
        }
 
-       p += sprintf(p, "1.0 1.2 0x%02x 0x%02x 0x%02x 0x%02x %d%% %d %s\n",
-                    APM_32_BIT_SUPPORT,
-                    ac_line_status,
-                    battery_status,
-                    battery_flag,
-                    percentage,
-                    time_units,
-                    "min");
-       p += sprintf(p, "bat=%d backup=%d charge=%d\n",
-                    battery, backup, charging);
-
-       return p - buf;
+       info->units = 0;
 }
 
 static irqreturn_t hp6x0_apm_interrupt(int irq, void *dev)
@@ -96,14 +76,14 @@ static int __init hp6x0_apm_init(void)
        int ret;
 
        ret = request_irq(HP680_BTN_IRQ, hp6x0_apm_interrupt,
-                         IRQF_DISABLED, MODNAME, 0);
+                         IRQF_DISABLED, MODNAME, NULL);
        if (unlikely(ret < 0)) {
                printk(KERN_ERR MODNAME ": IRQ %d request failed\n",
                       HP680_BTN_IRQ);
                return ret;
        }
 
-       apm_get_info = hp6x0_apm_get_info;
+       apm_get_power_status = hp6x0_apm_get_power_status;
 
        return ret;
 }
@@ -111,7 +91,7 @@ static int __init hp6x0_apm_init(void)
 static void __exit hp6x0_apm_exit(void)
 {
        free_irq(HP680_BTN_IRQ, 0);
-       apm_get_info = 0;
+       apm_get_info = NULL;
 }
 
 module_init(hp6x0_apm_init);
index 99c7e5249f7a6ca16a68911955e90e3abb357855..2f6d2bcb1c93f8fbc26b7daee131b894e02dd9ad 100644 (file)
@@ -19,6 +19,5 @@ obj-$(CONFIG_SH_CPU_FREQ)     += cpufreq.o
 obj-$(CONFIG_MODULES)          += module.o
 obj-$(CONFIG_EARLY_PRINTK)     += early_printk.o
 obj-$(CONFIG_KEXEC)            += machine_kexec.o relocate_kernel.o
-obj-$(CONFIG_APM)              += apm.o
 obj-$(CONFIG_PM)               += pm.o
 obj-$(CONFIG_STACKTRACE)       += stacktrace.o
diff --git a/arch/sh/kernel/apm.c b/arch/sh/kernel/apm.c
deleted file mode 100644 (file)
index 4f66f91..0000000
+++ /dev/null
@@ -1,538 +0,0 @@
-/*
- * bios-less APM driver for hp680
- *
- * Copyright 2005 (c) Andriy Skulysh <askulysh@gmail.com>
- *
- * based on ARM APM driver by
- *  Jamey Hicks <jamey@crl.dec.com>
- *
- * adapted from the APM BIOS driver for Linux by
- *  Stephen Rothwell (sfr@linuxcare.com)
- *
- * APM 1.2 Reference:
- *   Intel Corporation, Microsoft Corporation. Advanced Power Management
- *   (APM) BIOS Interface Specification, Revision 1.2, February 1996.
- *
- * [This document is available from Microsoft at:
- *    http://www.microsoft.com/hwdev/busbios/amp_12.htm]
- */
-#include <linux/module.h>
-#include <linux/poll.h>
-#include <linux/timer.h>
-#include <linux/slab.h>
-#include <linux/proc_fs.h>
-#include <linux/miscdevice.h>
-#include <linux/apm_bios.h>
-#include <linux/pm.h>
-#include <linux/pm_legacy.h>
-#include <asm/apm.h>
-
-#define MODNAME "apm"
-
-/*
- * The apm_bios device is one of the misc char devices.
- * This is its minor number.
- */
-#define APM_MINOR_DEV                  134
-
-/*
- * Maximum number of events stored
- */
-#define APM_MAX_EVENTS                 16
-
-struct apm_queue {
-       unsigned int            event_head;
-       unsigned int            event_tail;
-       apm_event_t             events[APM_MAX_EVENTS];
-};
-
-/*
- * The per-file APM data
- */
-struct apm_user {
-       struct list_head        list;
-
-       unsigned int            suser: 1;
-       unsigned int            writer: 1;
-       unsigned int            reader: 1;
-
-       int                     suspend_result;
-       unsigned int            suspend_state;
-#define SUSPEND_NONE   0               /* no suspend pending */
-#define SUSPEND_PENDING        1               /* suspend pending read */
-#define SUSPEND_READ   2               /* suspend read, pending ack */
-#define SUSPEND_ACKED  3               /* suspend acked */
-#define SUSPEND_DONE   4               /* suspend completed */
-
-       struct apm_queue        queue;
-};
-
-/*
- * Local variables
- */
-static int suspends_pending;
-
-static DECLARE_WAIT_QUEUE_HEAD(apm_waitqueue);
-static DECLARE_WAIT_QUEUE_HEAD(apm_suspend_waitqueue);
-
-/*
- * This is a list of everyone who has opened /dev/apm_bios
- */
-static DECLARE_RWSEM(user_list_lock);
-static LIST_HEAD(apm_user_list);
-
-/*
- * kapmd info.  kapmd provides us a process context to handle
- * "APM" events within - specifically necessary if we're going
- * to be suspending the system.
- */
-static DECLARE_WAIT_QUEUE_HEAD(kapmd_wait);
-static DECLARE_COMPLETION(kapmd_exit);
-static DEFINE_SPINLOCK(kapmd_queue_lock);
-static struct apm_queue kapmd_queue;
-
-int apm_suspended;
-EXPORT_SYMBOL(apm_suspended);
-
-/* Platform-specific apm_read_proc(). */
-int (*apm_get_info)(char *buf, char **start, off_t fpos, int length);
-EXPORT_SYMBOL(apm_get_info);
-
-/*
- * APM event queue management.
- */
-static inline int queue_empty(struct apm_queue *q)
-{
-       return q->event_head == q->event_tail;
-}
-
-static inline apm_event_t queue_get_event(struct apm_queue *q)
-{
-       q->event_tail = (q->event_tail + 1) % APM_MAX_EVENTS;
-       return q->events[q->event_tail];
-}
-
-static void queue_add_event(struct apm_queue *q, apm_event_t event)
-{
-       q->event_head = (q->event_head + 1) % APM_MAX_EVENTS;
-       if (q->event_head == q->event_tail) {
-               static int notified;
-
-               if (notified++ == 0)
-                       printk(KERN_ERR "apm: an event queue overflowed\n");
-
-               q->event_tail = (q->event_tail + 1) % APM_MAX_EVENTS;
-       }
-       q->events[q->event_head] = event;
-}
-
-static void queue_event_one_user(struct apm_user *as, apm_event_t event)
-{
-       if (as->suser && as->writer) {
-               switch (event) {
-               case APM_SYS_SUSPEND:
-               case APM_USER_SUSPEND:
-                       /*
-                        * If this user already has a suspend pending,
-                        * don't queue another one.
-                        */
-                       if (as->suspend_state != SUSPEND_NONE)
-                               return;
-
-                       as->suspend_state = SUSPEND_PENDING;
-                       suspends_pending++;
-                       break;
-               }
-       }
-       queue_add_event(&as->queue, event);
-}
-
-static void queue_event(apm_event_t event, struct apm_user *sender)
-{
-       struct apm_user *as;
-
-       down_read(&user_list_lock);
-
-       list_for_each_entry(as, &apm_user_list, list)
-               if (as != sender && as->reader)
-                       queue_event_one_user(as, event);
-
-       up_read(&user_list_lock);
-       wake_up_interruptible(&apm_waitqueue);
-}
-
-/**
- * apm_queue_event - queue an APM event for kapmd
- * @event: APM event
- *
- * Queue an APM event for kapmd to process and ultimately take the
- * appropriate action.  Only a subset of events are handled:
- *   %APM_LOW_BATTERY
- *   %APM_POWER_STATUS_CHANGE
- *   %APM_USER_SUSPEND
- *   %APM_SYS_SUSPEND
- *   %APM_CRITICAL_SUSPEND
- */
-void apm_queue_event(apm_event_t event)
-{
-       spin_lock_irq(&kapmd_queue_lock);
-       queue_add_event(&kapmd_queue, event);
-       spin_unlock_irq(&kapmd_queue_lock);
-
-       wake_up_interruptible(&kapmd_wait);
-}
-EXPORT_SYMBOL(apm_queue_event);
-
-static void apm_suspend(void)
-{
-       struct apm_user *as;
-       int err;
-
-       apm_suspended = 1;
-       err = pm_suspend(PM_SUSPEND_MEM);
-
-       /*
-        * Anyone on the APM queues will think we're still suspended.
-        * Send a message so everyone knows we're now awake again.
-        */
-       queue_event(APM_NORMAL_RESUME, NULL);
-
-       /*
-        * Finally, wake up anyone who is sleeping on the suspend.
-        */
-       down_read(&user_list_lock);
-       list_for_each_entry(as, &apm_user_list, list) {
-               as->suspend_result = err;
-               as->suspend_state = SUSPEND_DONE;
-       }
-       up_read(&user_list_lock);
-
-       wake_up(&apm_suspend_waitqueue);
-       apm_suspended = 0;
-}
-
-static ssize_t apm_read(struct file *fp, char __user *buf,
-                       size_t count, loff_t *ppos)
-{
-       struct apm_user *as = fp->private_data;
-       apm_event_t event;
-       int i = count, ret = 0;
-
-       if (count < sizeof(apm_event_t))
-               return -EINVAL;
-
-       if (queue_empty(&as->queue) && fp->f_flags & O_NONBLOCK)
-               return -EAGAIN;
-
-       wait_event_interruptible(apm_waitqueue, !queue_empty(&as->queue));
-
-       while ((i >= sizeof(event)) && !queue_empty(&as->queue)) {
-               event = queue_get_event(&as->queue);
-
-               ret = -EFAULT;
-               if (copy_to_user(buf, &event, sizeof(event)))
-                       break;
-
-               if (event == APM_SYS_SUSPEND || event == APM_USER_SUSPEND)
-                       as->suspend_state = SUSPEND_READ;
-
-               buf += sizeof(event);
-               i -= sizeof(event);
-       }
-
-       if (i < count)
-               ret = count - i;
-
-       return ret;
-}
-
-static unsigned int apm_poll(struct file *fp, poll_table * wait)
-{
-       struct apm_user *as = fp->private_data;
-
-       poll_wait(fp, &apm_waitqueue, wait);
-       return queue_empty(&as->queue) ? 0 : POLLIN | POLLRDNORM;
-}
-
-/*
- * apm_ioctl - handle APM ioctl
- *
- * APM_IOC_SUSPEND
- *   This IOCTL is overloaded, and performs two functions.  It is used to:
- *     - initiate a suspend
- *     - acknowledge a suspend read from /dev/apm_bios.
- *   Only when everyone who has opened /dev/apm_bios with write permission
- *   has acknowledge does the actual suspend happen.
- */
-static int
-apm_ioctl(struct inode * inode, struct file *filp, u_int cmd, u_long arg)
-{
-       struct apm_user *as = filp->private_data;
-       unsigned long flags;
-       int err = -EINVAL;
-
-       if (!as->suser || !as->writer)
-               return -EPERM;
-
-       switch (cmd) {
-       case APM_IOC_SUSPEND:
-               as->suspend_result = -EINTR;
-
-               if (as->suspend_state == SUSPEND_READ) {
-                       /*
-                        * If we read a suspend command from /dev/apm_bios,
-                        * then the corresponding APM_IOC_SUSPEND ioctl is
-                        * interpreted as an acknowledge.
-                        */
-                       as->suspend_state = SUSPEND_ACKED;
-                       suspends_pending--;
-               } else {
-                       /*
-                        * Otherwise it is a request to suspend the system.
-                        * Queue an event for all readers, and expect an
-                        * acknowledge from all writers who haven't already
-                        * acknowledged.
-                        */
-                       queue_event(APM_USER_SUSPEND, as);
-               }
-
-               /*
-                * If there are no further acknowledges required, suspend
-                * the system.
-                */
-               if (suspends_pending == 0)
-                       apm_suspend();
-
-               /*
-                * Wait for the suspend/resume to complete.  If there are
-                * pending acknowledges, we wait here for them.
-                *
-                * Note that we need to ensure that the PM subsystem does
-                * not kick us out of the wait when it suspends the threads.
-                */
-               flags = current->flags;
-               current->flags |= PF_NOFREEZE;
-
-               /*
-                * Note: do not allow a thread which is acking the suspend
-                * to escape until the resume is complete.
-                */
-               if (as->suspend_state == SUSPEND_ACKED)
-                       wait_event(apm_suspend_waitqueue,
-                                        as->suspend_state == SUSPEND_DONE);
-               else
-                       wait_event_interruptible(apm_suspend_waitqueue,
-                                        as->suspend_state == SUSPEND_DONE);
-
-               current->flags = flags;
-               err = as->suspend_result;
-               as->suspend_state = SUSPEND_NONE;
-               break;
-       }
-
-       return err;
-}
-
-static int apm_release(struct inode * inode, struct file * filp)
-{
-       struct apm_user *as = filp->private_data;
-       filp->private_data = NULL;
-
-       down_write(&user_list_lock);
-       list_del(&as->list);
-       up_write(&user_list_lock);
-
-       /*
-        * We are now unhooked from the chain.  As far as new
-        * events are concerned, we no longer exist.  However, we
-        * need to balance suspends_pending, which means the
-        * possibility of sleeping.
-        */
-       if (as->suspend_state != SUSPEND_NONE) {
-               suspends_pending -= 1;
-               if (suspends_pending == 0)
-                       apm_suspend();
-       }
-
-       kfree(as);
-       return 0;
-}
-
-static int apm_open(struct inode * inode, struct file * filp)
-{
-       struct apm_user *as;
-
-       as = kzalloc(sizeof(*as), GFP_KERNEL);
-       if (as) {
-               /*
-                * XXX - this is a tiny bit broken, when we consider BSD
-                * process accounting. If the device is opened by root, we
-                * instantly flag that we used superuser privs. Who knows,
-                * we might close the device immediately without doing a
-                * privileged operation -- cevans
-                */
-               as->suser = capable(CAP_SYS_ADMIN);
-               as->writer = (filp->f_mode & FMODE_WRITE) == FMODE_WRITE;
-               as->reader = (filp->f_mode & FMODE_READ) == FMODE_READ;
-
-               down_write(&user_list_lock);
-               list_add(&as->list, &apm_user_list);
-               up_write(&user_list_lock);
-
-               filp->private_data = as;
-       }
-
-       return as ? 0 : -ENOMEM;
-}
-
-static struct file_operations apm_bios_fops = {
-       .owner          = THIS_MODULE,
-       .read           = apm_read,
-       .poll           = apm_poll,
-       .ioctl          = apm_ioctl,
-       .open           = apm_open,
-       .release        = apm_release,
-};
-
-static struct miscdevice apm_device = {
-       .minor          = APM_MINOR_DEV,
-       .name           = "apm_bios",
-       .fops           = &apm_bios_fops
-};
-
-
-#ifdef CONFIG_PROC_FS
-/*
- * Arguments, with symbols from linux/apm_bios.h.
- *
- *   0) Linux driver version (this will change if format changes)
- *   1) APM BIOS Version.  Usually 1.0, 1.1 or 1.2.
- *   2) APM flags from APM Installation Check (0x00):
- *     bit 0: APM_16_BIT_SUPPORT
- *     bit 1: APM_32_BIT_SUPPORT
- *     bit 2: APM_IDLE_SLOWS_CLOCK
- *     bit 3: APM_BIOS_DISABLED
- *     bit 4: APM_BIOS_DISENGAGED
- *   3) AC line status
- *     0x00: Off-line
- *     0x01: On-line
- *     0x02: On backup power (BIOS >= 1.1 only)
- *     0xff: Unknown
- *   4) Battery status
- *     0x00: High
- *     0x01: Low
- *     0x02: Critical
- *     0x03: Charging
- *     0x04: Selected battery not present (BIOS >= 1.2 only)
- *     0xff: Unknown
- *   5) Battery flag
- *     bit 0: High
- *     bit 1: Low
- *     bit 2: Critical
- *     bit 3: Charging
- *     bit 7: No system battery
- *     0xff: Unknown
- *   6) Remaining battery life (percentage of charge):
- *     0-100: valid
- *     -1: Unknown
- *   7) Remaining battery life (time units):
- *     Number of remaining minutes or seconds
- *     -1: Unknown
- *   8) min = minutes; sec = seconds
- */
-static int apm_read_proc(char *buf, char **start, off_t fpos, int length)
-{
-       if (likely(apm_get_info))
-               return apm_get_info(buf, start, fpos, length);
-
-       return -EINVAL;
-}
-#endif
-
-static int kapmd(void *arg)
-{
-       daemonize("kapmd");
-       current->flags |= PF_NOFREEZE;
-
-       do {
-               apm_event_t event;
-
-               wait_event_interruptible(kapmd_wait,
-                               !queue_empty(&kapmd_queue) || !pm_active);
-
-               if (!pm_active)
-                       break;
-
-               spin_lock_irq(&kapmd_queue_lock);
-               event = 0;
-               if (!queue_empty(&kapmd_queue))
-                       event = queue_get_event(&kapmd_queue);
-               spin_unlock_irq(&kapmd_queue_lock);
-
-               switch (event) {
-               case 0:
-                       break;
-
-               case APM_LOW_BATTERY:
-               case APM_POWER_STATUS_CHANGE:
-                       queue_event(event, NULL);
-                       break;
-
-               case APM_USER_SUSPEND:
-               case APM_SYS_SUSPEND:
-                       queue_event(event, NULL);
-                       if (suspends_pending == 0)
-                               apm_suspend();
-                       break;
-
-               case APM_CRITICAL_SUSPEND:
-                       apm_suspend();
-                       break;
-               }
-       } while (1);
-
-       complete_and_exit(&kapmd_exit, 0);
-}
-
-static int __init apm_init(void)
-{
-       int ret;
-
-       pm_active = 1;
-
-       ret = kernel_thread(kapmd, NULL, CLONE_KERNEL);
-       if (unlikely(ret < 0)) {
-               pm_active = 0;
-               return ret;
-       }
-
-       create_proc_info_entry("apm", 0, NULL, apm_read_proc);
-
-       ret = misc_register(&apm_device);
-       if (unlikely(ret != 0)) {
-               remove_proc_entry("apm", NULL);
-
-               pm_active = 0;
-               wake_up(&kapmd_wait);
-               wait_for_completion(&kapmd_exit);
-       }
-
-       return ret;
-}
-
-static void __exit apm_exit(void)
-{
-       misc_deregister(&apm_device);
-       remove_proc_entry("apm", NULL);
-
-       pm_active = 0;
-       wake_up(&kapmd_wait);
-       wait_for_completion(&kapmd_exit);
-}
-
-module_init(apm_init);
-module_exit(apm_exit);
-
-MODULE_AUTHOR("Stephen Rothwell, Andriy Skulysh");
-MODULE_DESCRIPTION("Advanced Power Management");
-MODULE_LICENSE("GPL");
index c206c9504c4bb40da950a374ead73943f9ab36a4..d47e775962e955054f8e0296f4f3a5fdd65377e5 100644 (file)
@@ -41,14 +41,6 @@ static int null_rtc_set_time(const time_t secs)
 void (*rtc_sh_get_time)(struct timespec *) = null_rtc_get_time;
 int (*rtc_sh_set_time)(const time_t) = null_rtc_set_time;
 
-/*
- * Scheduler clock - returns current time in nanosec units.
- */
-unsigned long long __attribute__ ((weak)) sched_clock(void)
-{
-       return (unsigned long long)jiffies * (1000000000 / HZ);
-}
-
 #ifndef CONFIG_GENERIC_TIME
 void do_gettimeofday(struct timeval *tv)
 {
index f34bdcc33a7dd5a39124e7f3f1c543b48884353a..75de165867a0e75a83ac4220c493c5b10a530bfb 100644 (file)
@@ -83,9 +83,13 @@ SECTIONS
   .con_initcall.init : { *(.con_initcall.init) }
   __con_initcall_end = .;
   SECURITY_INIT
+
+#ifdef CONFIG_BLK_DEV_INITRD
   __initramfs_start = .;
   .init.ramfs : { *(.init.ramfs) }
   __initramfs_end = .;
+#endif
+
   __machvec_start = .;
   .init.machvec : { *(.init.machvec) }
   __machvec_end = .;
index deb46941f315c6aa711e72b4f8b828ee73b011a6..7b0f66f033197b83d186231f6a16b5a12580130c 100644 (file)
@@ -37,11 +37,12 @@ __setup("vdso=", vdso_setup);
  * of the ELF DSO images included therein.
  */
 extern const char vsyscall_trapa_start, vsyscall_trapa_end;
-static void *syscall_page;
+static struct page *syscall_pages[1];
 
 int __init vsyscall_init(void)
 {
-       syscall_page = (void *)get_zeroed_page(GFP_ATOMIC);
+       void *syscall_page = (void *)get_zeroed_page(GFP_ATOMIC);
+       syscall_pages[0] = virt_to_page(syscall_page);
 
        /*
         * XXX: Map this page to a fixmap entry if we get around
@@ -55,37 +56,10 @@ int __init vsyscall_init(void)
        return 0;
 }
 
-static struct page *syscall_vma_nopage(struct vm_area_struct *vma,
-                                      unsigned long address, int *type)
-{
-       unsigned long offset = address - vma->vm_start;
-       struct page *page;
-
-       if (address < vma->vm_start || address > vma->vm_end)
-               return NOPAGE_SIGBUS;
-
-       page = virt_to_page(syscall_page + offset);
-
-       get_page(page);
-
-       return page;
-}
-
-/* Prevent VMA merging */
-static void syscall_vma_close(struct vm_area_struct *vma)
-{
-}
-
-static struct vm_operations_struct syscall_vm_ops = {
-       .nopage = syscall_vma_nopage,
-       .close  = syscall_vma_close,
-};
-
 /* Setup a VMA at program startup for the vsyscall page */
 int arch_setup_additional_pages(struct linux_binprm *bprm,
                                int executable_stack)
 {
-       struct vm_area_struct *vma;
        struct mm_struct *mm = current->mm;
        unsigned long addr;
        int ret;
@@ -97,30 +71,16 @@ int arch_setup_additional_pages(struct linux_binprm *bprm,
                goto up_fail;
        }
 
-       vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
-       if (!vma) {
-               ret = -ENOMEM;
+       ret = install_special_mapping(mm, addr, PAGE_SIZE,
+                                     VM_READ | VM_EXEC |
+                                     VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC |
+                                     VM_ALWAYSDUMP,
+                                     syscall_pages);
+       if (unlikely(ret))
                goto up_fail;
-       }
-
-       vma->vm_start = addr;
-       vma->vm_end = addr + PAGE_SIZE;
-       /* MAYWRITE to allow gdb to COW and set breakpoints */
-       vma->vm_flags = VM_READ|VM_EXEC|VM_MAYREAD|VM_MAYEXEC|VM_MAYWRITE;
-       vma->vm_flags |= mm->def_flags;
-       vma->vm_page_prot = protection_map[vma->vm_flags & 7];
-       vma->vm_ops = &syscall_vm_ops;
-       vma->vm_mm = mm;
-
-       ret = insert_vm_struct(mm, vma);
-       if (unlikely(ret)) {
-               kmem_cache_free(vm_area_cachep, vma);
-               goto up_fail;
-       }
 
        current->mm->context.vdso = (void *)addr;
 
-       mm->total_vm++;
 up_fail:
        up_write(&mm->mmap_sem);
        return ret;
index 29bd37b1488e42ee7e5a74d5beb5cf5ba680b059..bf0c263cb6fd036ec3f3f9e971799dc41f18fa56 100644 (file)
@@ -158,7 +158,6 @@ void __init paging_init(void)
         * Setup some defaults for the zone sizes.. these should be safe
         * regardless of distcontiguous memory or MMU settings.
         */
-       zones_size[ZONE_DMA] = 0 >> PAGE_SHIFT;
        zones_size[ZONE_NORMAL] = __MEMORY_SIZE >> PAGE_SHIFT;
 #ifdef CONFIG_HIGHMEM
        zones_size[ZONE_HIGHMEM] = 0 >> PAGE_SHIFT;
@@ -170,8 +169,6 @@ void __init paging_init(void)
         * the zone sizes accordingly, in addition to turning it on.
         */
        {
-               unsigned long max_dma, low, start_pfn;
-
                /* We don't need to map the kernel through the TLB, as
                 * it is permanatly mapped using P1. So clear the
                 * entire pgd. */
@@ -179,19 +176,7 @@ void __init paging_init(void)
 
                /* Turn on the MMU */
                enable_mmu();
-
-               /* Fixup the zone sizes */
-               start_pfn = START_PFN;
-               max_dma = virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT;
-               low = MAX_LOW_PFN;
-
-               if (low < max_dma) {
-                       zones_size[ZONE_DMA] = low - start_pfn;
-                       zones_size[ZONE_NORMAL] = 0;
-               } else {
-                       zones_size[ZONE_DMA] = max_dma - start_pfn;
-                       zones_size[ZONE_NORMAL] = low - max_dma;
-               }
+               zones_size[ZONE_NORMAL] = MAX_LOW_PFN - START_PFN;
        }
 
        /* Set an initial value for the MMU.TTB so we don't have to
index 7bc0744b7ab6aca55207c96740c48c793fa286e4..e14b533558c8a87fc712c17252dc22ea140318cd 100644 (file)
@@ -36,9 +36,6 @@ config GENERIC_CALIBRATE_DELAY
 config RWSEM_XCHGADD_ALGORITHM
        bool
 
-config GENERIC_ISA_DMA
-       bool
-
 config ARCH_HAS_ILOG2_U32
        bool
        default n
index 9c4a38a8698c608e353a04831fc1761fcd99e526..390b40de7cefcb6886b81bc50ad6513cfbf3b43f 100644 (file)
@@ -579,12 +579,3 @@ void enter_deep_standby(void)
        asm __volatile__ ("nop");
        panic("Unexpected wakeup!\n");
 }
-
-/*
- * Scheduler clock - returns current time in nanosec units.
- */
-unsigned long long sched_clock(void)
-{
-       return (unsigned long long)jiffies * (1000000000 / HZ);
-}
-
index 95c4d753e357132bc6e98ac8a3c4a465ba106451..a59c5e998131e93c5649e82d21328e8ba720d493 100644 (file)
@@ -115,9 +115,13 @@ SECTIONS
   .con_initcall.init : C_PHYS(.con_initcall.init) { *(.con_initcall.init) }
   __con_initcall_end = .;
   SECURITY_INIT
+
+#ifdef CONFIG_BLK_DEV_INITRD
   __initramfs_start = .;
   .init.ramfs : C_PHYS(.init.ramfs) { *(.init.ramfs) }
   __initramfs_end = .;
+#endif
+
   . = ALIGN(PAGE_SIZE);
   __init_end = .;
 
index 83295bd21aa7d050c3046e5b1189a66c793fcf51..5dc08787259c1220acf701e1e2730ee85a125c9c 100644 (file)
@@ -118,10 +118,7 @@ void __init paging_init(void)
 
        mmu_context_cache = MMU_CONTEXT_FIRST_VERSION;
 
-        /*
-        * All memory is good as ZONE_NORMAL (fall-through) and ZONE_DMA.
-         */
-       zones_size[ZONE_DMA] = MAX_LOW_PFN - START_PFN;
+       zones_size[ZONE_NORMAL] = MAX_LOW_PFN - START_PFN;
        NODE_DATA(0)->node_mem_map = NULL;
        free_area_init_node(0, NODE_DATA(0), zones_size, __MEMORY_START >> PAGE_SHIFT, 0);
 }
index d0dec1ea2eed93345091981a64c6028f9ae474ff..bd992c0048f0aa1d8801b6dde2b3380982268ef9 100644 (file)
@@ -13,6 +13,10 @@ config HIGHMEM
        bool
        default y
 
+config ZONE_DMA
+       bool
+       default y
+
 config GENERIC_ISA_DMA
        bool
        default y
index 6616ee05c313c613f3f4fe18053fb806458d2ef2..e795f282dece9f29d6914bc639ffb0c73da5d9f9 100644 (file)
@@ -12,7 +12,9 @@ obj-y    := entry.o wof.o wuf.o etrap.o rtrap.o traps.o $(IRQ_OBJS) \
            sys_sparc.o sunos_asm.o systbls.o \
            time.o windows.o cpu.o devices.o sclow.o \
            tadpole.o tick14.o ptrace.o sys_solaris.o \
-           unaligned.o muldiv.o semaphore.o prom.o of_device.o
+           unaligned.o muldiv.o semaphore.o prom.o of_device.o devres.o
+
+devres-y = ../../../kernel/irq/devres.o
 
 obj-$(CONFIG_PCI) += pcic.o
 obj-$(CONFIG_SUN4) += sun4setup.o
index a6ba3d26222c1c173d4e5960ba26904705178843..32e8274e43574513c501fb8cd42940741f88aae7 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/termios.h>
+#include <linux/tty.h>
 #include <linux/ioctl.h>
 #include <linux/route.h>
 #include <linux/sockios.h>
index 2fcce000d87731c8c13a5965842f13b71bb6f251..9bb1240aaf8afee365a25a14b566de19f02ce601 100644 (file)
@@ -436,15 +436,6 @@ static inline unsigned long do_gettimeoffset(void)
        return (*master_l10_counter >> 10) & 0x1fffff;
 }
 
-/*
- * Returns nanoseconds
- * XXX This is a suboptimal implementation.
- */
-unsigned long long sched_clock(void)
-{
-       return (unsigned long long)jiffies * (1000000000 / HZ);
-}
-
 /* Ok, my cute asm atomicity trick doesn't work anymore.
  * There are just too many variables that need to be protected
  * now (both members of xtime, et al.)
index b73e6b9067eddf5ba48ea26d503c607f67d2ea60..e5c24e0521dee34f43e0ef32c693320512f841a9 100644 (file)
@@ -57,10 +57,14 @@ SECTIONS
   .con_initcall.init : { *(.con_initcall.init) }
   __con_initcall_end = .;
   SECURITY_INIT
+
+#ifdef CONFIG_BLK_DEV_INITRD
   . = ALIGN(4096);
   __initramfs_start = .;
   .init.ramfs : { *(.init.ramfs) }
   __initramfs_end = .;
+#endif
+
   . = ALIGN(32);
   __per_cpu_start = .;
   .data.percpu  : { *(.data.percpu) }
index d41f66ac7fff71dd8768271775aad6b183de987f..fb84647dbf3dedd132e4e0082a232ab95e9da0e4 100644 (file)
@@ -232,6 +232,10 @@ config LARGE_ALLOCS
 
 source "mm/Kconfig"
 
+config ZONE_DMA
+       bool
+       default y
+
 config GENERIC_ISA_DMA
        bool
        default y
index 5a9e68b13e606277d37fdbe527fd3b758463696c..069ee3ccd84968784755cdcb7c2f95c3b41380f8 100644 (file)
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.20-rc2
-# Thu Dec 28 15:09:49 2006
+# Linux kernel version: 2.6.20
+# Sat Feb 10 23:08:12 2007
 #
 CONFIG_SPARC=y
 CONFIG_SPARC64=y
@@ -151,7 +151,7 @@ CONFIG_SUN_AUXIO=y
 CONFIG_SUN_IO=y
 CONFIG_PCI=y
 CONFIG_PCI_DOMAINS=y
-# CONFIG_PCI_MULTITHREAD_PROBE is not set
+CONFIG_PCI_MSI=y
 # CONFIG_PCI_DEBUG is not set
 CONFIG_SUN_OPENPROMFS=m
 CONFIG_SPARC32_COMPAT=y
@@ -182,7 +182,9 @@ CONFIG_UNIX=y
 CONFIG_XFRM=y
 CONFIG_XFRM_USER=m
 # CONFIG_XFRM_SUB_POLICY is not set
+CONFIG_XFRM_MIGRATE=y
 CONFIG_NET_KEY=m
+CONFIG_NET_KEY_MIGRATE=y
 CONFIG_INET=y
 CONFIG_IP_MULTICAST=y
 # CONFIG_IP_ADVANCED_ROUTER is not set
@@ -300,6 +302,7 @@ CONFIG_STANDALONE=y
 # CONFIG_PREVENT_FIRMWARE_BUILD is not set
 CONFIG_FW_LOADER=y
 # CONFIG_DEBUG_DRIVER is not set
+# CONFIG_DEBUG_DEVRES is not set
 # CONFIG_SYS_HYPERVISOR is not set
 
 #
@@ -393,6 +396,7 @@ CONFIG_BLK_DEV_ALI15X3=y
 # CONFIG_BLK_DEV_JMICRON is not set
 # CONFIG_BLK_DEV_SC1200 is not set
 # CONFIG_BLK_DEV_PIIX is not set
+# CONFIG_BLK_DEV_IT8213 is not set
 # CONFIG_BLK_DEV_IT821X is not set
 # CONFIG_BLK_DEV_NS87415 is not set
 # CONFIG_BLK_DEV_PDC202XX_OLD is not set
@@ -402,6 +406,7 @@ CONFIG_BLK_DEV_ALI15X3=y
 # CONFIG_BLK_DEV_SLC90E66 is not set
 # CONFIG_BLK_DEV_TRM290 is not set
 # CONFIG_BLK_DEV_VIA82CXXX is not set
+# CONFIG_BLK_DEV_TC86C001 is not set
 # CONFIG_IDE_ARM is not set
 CONFIG_BLK_DEV_IDEDMA=y
 # CONFIG_IDEDMA_IVB is not set
@@ -579,6 +584,7 @@ CONFIG_NET_PCI=y
 # CONFIG_EPIC100 is not set
 # CONFIG_SUNDANCE is not set
 # CONFIG_VIA_RHINE is not set
+# CONFIG_SC92031 is not set
 
 #
 # Ethernet (1000 Mbit)
@@ -601,11 +607,13 @@ CONFIG_E1000_NAPI=y
 CONFIG_TIGON3=m
 CONFIG_BNX2=m
 # CONFIG_QLA3XXX is not set
+# CONFIG_ATL1 is not set
 
 #
 # Ethernet (10000 Mbit)
 #
 # CONFIG_CHELSIO_T1 is not set
+# CONFIG_CHELSIO_T3 is not set
 # CONFIG_IXGB is not set
 # CONFIG_S2IO is not set
 # CONFIG_MYRI10GE is not set
@@ -627,8 +635,17 @@ CONFIG_BNX2=m
 # CONFIG_WAN is not set
 # CONFIG_FDDI is not set
 # CONFIG_HIPPI is not set
-# CONFIG_PPP is not set
+CONFIG_PPP=m
+CONFIG_PPP_MULTILINK=y
+CONFIG_PPP_FILTER=y
+CONFIG_PPP_ASYNC=m
+CONFIG_PPP_SYNC_TTY=m
+CONFIG_PPP_DEFLATE=m
+CONFIG_PPP_BSDCOMP=m
+CONFIG_PPP_MPPE=m
+CONFIG_PPPOE=m
 # CONFIG_SLIP is not set
+CONFIG_SLHC=m
 # CONFIG_NET_FC is not set
 # CONFIG_SHAPER is not set
 # CONFIG_NETCONSOLE is not set
@@ -1042,6 +1059,11 @@ CONFIG_SND_ALI5451=m
 CONFIG_SND_SUN_CS4231=m
 # CONFIG_SND_SUN_DBRI is not set
 
+#
+# SoC audio support
+#
+# CONFIG_SND_SOC is not set
+
 #
 # Open Sound System
 #
@@ -1052,6 +1074,7 @@ CONFIG_AC97_BUS=m
 # HID Devices
 #
 CONFIG_HID=y
+# CONFIG_HID_DEBUG is not set
 
 #
 # USB support
@@ -1066,9 +1089,7 @@ CONFIG_USB=y
 # Miscellaneous USB options
 #
 CONFIG_USB_DEVICEFS=y
-# CONFIG_USB_BANDWIDTH is not set
 # CONFIG_USB_DYNAMIC_MINORS is not set
-# CONFIG_USB_MULTITHREAD_PROBE is not set
 # CONFIG_USB_OTG is not set
 
 #
@@ -1078,9 +1099,11 @@ CONFIG_USB_EHCI_HCD=m
 # CONFIG_USB_EHCI_SPLIT_ISO is not set
 # CONFIG_USB_EHCI_ROOT_HUB_TT is not set
 # CONFIG_USB_EHCI_TT_NEWSCHED is not set
+# CONFIG_USB_EHCI_BIG_ENDIAN_MMIO is not set
 # CONFIG_USB_ISP116X_HCD is not set
 CONFIG_USB_OHCI_HCD=y
-# CONFIG_USB_OHCI_BIG_ENDIAN is not set
+# CONFIG_USB_OHCI_BIG_ENDIAN_DESC is not set
+# CONFIG_USB_OHCI_BIG_ENDIAN_MMIO is not set
 CONFIG_USB_OHCI_LITTLE_ENDIAN=y
 CONFIG_USB_UHCI_HCD=m
 # CONFIG_USB_SL811_HCD is not set
@@ -1132,6 +1155,7 @@ CONFIG_USB_HIDDEV=y
 # CONFIG_USB_ATI_REMOTE2 is not set
 # CONFIG_USB_KEYSPAN_REMOTE is not set
 # CONFIG_USB_APPLETOUCH is not set
+# CONFIG_USB_GTCO is not set
 
 #
 # USB Imaging devices
@@ -1473,8 +1497,10 @@ CONFIG_CRYPTO_TGR192=m
 CONFIG_CRYPTO_GF128MUL=m
 CONFIG_CRYPTO_ECB=m
 CONFIG_CRYPTO_CBC=y
+CONFIG_CRYPTO_PCBC=m
 CONFIG_CRYPTO_LRW=m
 CONFIG_CRYPTO_DES=y
+CONFIG_CRYPTO_FCRYPT=m
 CONFIG_CRYPTO_BLOWFISH=m
 CONFIG_CRYPTO_TWOFISH=m
 CONFIG_CRYPTO_TWOFISH_COMMON=m
@@ -1489,6 +1515,7 @@ CONFIG_CRYPTO_ANUBIS=m
 CONFIG_CRYPTO_DEFLATE=y
 CONFIG_CRYPTO_MICHAEL_MIC=m
 CONFIG_CRYPTO_CRC32C=m
+CONFIG_CRYPTO_CAMELLIA=m
 CONFIG_CRYPTO_TEST=m
 
 #
index c3d068c7a4128c5ad7a94a8ad62936f425fe2569..b5ff3ee5ace1cc23d3a86cd50878568b505ea7d8 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/seq_file.h>
 #include <linux/bootmem.h>
 #include <linux/irq.h>
+#include <linux/msi.h>
 
 #include <asm/ptrace.h>
 #include <asm/processor.h>
@@ -87,7 +88,6 @@ struct ino_bucket ivector_table[NUM_IVECS] __attribute__ ((aligned (SMP_CACHE_BY
 #define irq_work(__cpu)        &(trap_block[(__cpu)].irq_worklist)
 
 static unsigned int virt_to_real_irq_table[NR_IRQS];
-static unsigned char virt_irq_cur = 1;
 
 static unsigned char virt_irq_alloc(unsigned int real_irq)
 {
@@ -95,26 +95,32 @@ static unsigned char virt_irq_alloc(unsigned int real_irq)
 
        BUILD_BUG_ON(NR_IRQS >= 256);
 
-       ent = virt_irq_cur;
+       for (ent = 1; ent < NR_IRQS; ent++) {
+               if (!virt_to_real_irq_table[ent])
+                       break;
+       }
        if (ent >= NR_IRQS) {
                printk(KERN_ERR "IRQ: Out of virtual IRQs.\n");
                return 0;
        }
 
-       virt_irq_cur = ent + 1;
        virt_to_real_irq_table[ent] = real_irq;
 
        return ent;
 }
 
-#if 0 /* Currently unused. */
-static unsigned char real_to_virt_irq(unsigned int real_irq)
+static void virt_irq_free(unsigned int virt_irq)
 {
-       struct ino_bucket *bucket = __bucket(real_irq);
+       unsigned int real_irq;
 
-       return bucket->virt_irq;
+       if (virt_irq >= NR_IRQS)
+               return;
+
+       real_irq = virt_to_real_irq_table[virt_irq];
+       virt_to_real_irq_table[virt_irq] = 0;
+
+       __bucket(real_irq)->virt_irq = 0;
 }
-#endif
 
 static unsigned int virt_to_real_irq(unsigned char virt_irq)
 {
@@ -268,8 +274,7 @@ static int irq_choose_cpu(unsigned int virt_irq)
 
 static void sun4u_irq_enable(unsigned int virt_irq)
 {
-       irq_desc_t *desc = irq_desc + virt_irq;
-       struct irq_handler_data *data = desc->handler_data;
+       struct irq_handler_data *data = get_irq_chip_data(virt_irq);
 
        if (likely(data)) {
                unsigned long cpuid, imap;
@@ -286,8 +291,7 @@ static void sun4u_irq_enable(unsigned int virt_irq)
 
 static void sun4u_irq_disable(unsigned int virt_irq)
 {
-       irq_desc_t *desc = irq_desc + virt_irq;
-       struct irq_handler_data *data = desc->handler_data;
+       struct irq_handler_data *data = get_irq_chip_data(virt_irq);
 
        if (likely(data)) {
                unsigned long imap = data->imap;
@@ -300,8 +304,7 @@ static void sun4u_irq_disable(unsigned int virt_irq)
 
 static void sun4u_irq_end(unsigned int virt_irq)
 {
-       irq_desc_t *desc = irq_desc + virt_irq;
-       struct irq_handler_data *data = desc->handler_data;
+       struct irq_handler_data *data = get_irq_chip_data(virt_irq);
 
        if (likely(data))
                upa_writel(ICLR_IDLE, data->iclr);
@@ -344,6 +347,20 @@ static void sun4v_irq_disable(unsigned int virt_irq)
        }
 }
 
+#ifdef CONFIG_PCI_MSI
+static void sun4v_msi_enable(unsigned int virt_irq)
+{
+       sun4v_irq_enable(virt_irq);
+       unmask_msi_irq(virt_irq);
+}
+
+static void sun4v_msi_disable(unsigned int virt_irq)
+{
+       mask_msi_irq(virt_irq);
+       sun4v_irq_disable(virt_irq);
+}
+#endif
+
 static void sun4v_irq_end(unsigned int virt_irq)
 {
        struct ino_bucket *bucket = virt_irq_to_bucket(virt_irq);
@@ -362,8 +379,7 @@ static void sun4v_irq_end(unsigned int virt_irq)
 static void run_pre_handler(unsigned int virt_irq)
 {
        struct ino_bucket *bucket = virt_irq_to_bucket(virt_irq);
-       irq_desc_t *desc = irq_desc + virt_irq;
-       struct irq_handler_data *data = desc->handler_data;
+       struct irq_handler_data *data = get_irq_chip_data(virt_irq);
 
        if (likely(data->pre_handler)) {
                data->pre_handler(__irq_ino(__irq(bucket)),
@@ -402,30 +418,47 @@ static struct irq_chip sun4v_irq_ack = {
        .end            = sun4v_irq_end,
 };
 
+#ifdef CONFIG_PCI_MSI
+static struct irq_chip sun4v_msi = {
+       .typename       = "sun4v+msi",
+       .mask           = mask_msi_irq,
+       .unmask         = unmask_msi_irq,
+       .enable         = sun4v_msi_enable,
+       .disable        = sun4v_msi_disable,
+       .ack            = run_pre_handler,
+       .end            = sun4v_irq_end,
+};
+#endif
+
 void irq_install_pre_handler(int virt_irq,
                             void (*func)(unsigned int, void *, void *),
                             void *arg1, void *arg2)
 {
-       irq_desc_t *desc = irq_desc + virt_irq;
-       struct irq_handler_data *data = desc->handler_data;
+       struct irq_handler_data *data = get_irq_chip_data(virt_irq);
+       struct irq_chip *chip;
 
        data->pre_handler = func;
        data->pre_handler_arg1 = arg1;
        data->pre_handler_arg2 = arg2;
 
-       if (desc->chip == &sun4u_irq_ack ||
-           desc->chip == &sun4v_irq_ack)
+       chip = get_irq_chip(virt_irq);
+       if (chip == &sun4u_irq_ack ||
+           chip == &sun4v_irq_ack
+#ifdef CONFIG_PCI_MSI
+           || chip == &sun4v_msi
+#endif
+           )
                return;
 
-       desc->chip = (desc->chip == &sun4u_irq ?
-                     &sun4u_irq_ack : &sun4v_irq_ack);
+       chip = (chip == &sun4u_irq ?
+               &sun4u_irq_ack : &sun4v_irq_ack);
+       set_irq_chip(virt_irq, chip);
 }
 
 unsigned int build_irq(int inofixup, unsigned long iclr, unsigned long imap)
 {
        struct ino_bucket *bucket;
        struct irq_handler_data *data;
-       irq_desc_t *desc;
        int ino;
 
        BUG_ON(tlb_type == hypervisor);
@@ -434,11 +467,11 @@ unsigned int build_irq(int inofixup, unsigned long iclr, unsigned long imap)
        bucket = &ivector_table[ino];
        if (!bucket->virt_irq) {
                bucket->virt_irq = virt_irq_alloc(__irq(bucket));
-               irq_desc[bucket->virt_irq].chip = &sun4u_irq;
+               set_irq_chip(bucket->virt_irq, &sun4u_irq);
        }
 
-       desc = irq_desc + bucket->virt_irq;
-       if (unlikely(desc->handler_data))
+       data = get_irq_chip_data(bucket->virt_irq);
+       if (unlikely(data))
                goto out;
 
        data = kzalloc(sizeof(struct irq_handler_data), GFP_ATOMIC);
@@ -446,7 +479,7 @@ unsigned int build_irq(int inofixup, unsigned long iclr, unsigned long imap)
                prom_printf("IRQ: kzalloc(irq_handler_data) failed.\n");
                prom_halt();
        }
-       desc->handler_data = data;
+       set_irq_chip_data(bucket->virt_irq, data);
 
        data->imap  = imap;
        data->iclr  = iclr;
@@ -460,7 +493,6 @@ unsigned int sun4v_build_irq(u32 devhandle, unsigned int devino)
        struct ino_bucket *bucket;
        struct irq_handler_data *data;
        unsigned long sysino;
-       irq_desc_t *desc;
 
        BUG_ON(tlb_type != hypervisor);
 
@@ -468,11 +500,11 @@ unsigned int sun4v_build_irq(u32 devhandle, unsigned int devino)
        bucket = &ivector_table[sysino];
        if (!bucket->virt_irq) {
                bucket->virt_irq = virt_irq_alloc(__irq(bucket));
-               irq_desc[bucket->virt_irq].chip = &sun4v_irq;
+               set_irq_chip(bucket->virt_irq, &sun4v_irq);
        }
 
-       desc = irq_desc + bucket->virt_irq;
-       if (unlikely(desc->handler_data))
+       data = get_irq_chip_data(bucket->virt_irq);
+       if (unlikely(data))
                goto out;
 
        data = kzalloc(sizeof(struct irq_handler_data), GFP_ATOMIC);
@@ -480,7 +512,7 @@ unsigned int sun4v_build_irq(u32 devhandle, unsigned int devino)
                prom_printf("IRQ: kzalloc(irq_handler_data) failed.\n");
                prom_halt();
        }
-       desc->handler_data = data;
+       set_irq_chip_data(bucket->virt_irq, data);
 
        /* Catch accidental accesses to these things.  IMAP/ICLR handling
         * is done by hypervisor calls on sun4v platforms, not by direct
@@ -493,6 +525,56 @@ out:
        return bucket->virt_irq;
 }
 
+#ifdef CONFIG_PCI_MSI
+unsigned int sun4v_build_msi(u32 devhandle, unsigned int *virt_irq_p,
+                            unsigned int msi_start, unsigned int msi_end)
+{
+       struct ino_bucket *bucket;
+       struct irq_handler_data *data;
+       unsigned long sysino;
+       unsigned int devino;
+
+       BUG_ON(tlb_type != hypervisor);
+
+       /* Find a free devino in the given range.  */
+       for (devino = msi_start; devino < msi_end; devino++) {
+               sysino = sun4v_devino_to_sysino(devhandle, devino);
+               bucket = &ivector_table[sysino];
+               if (!bucket->virt_irq)
+                       break;
+       }
+       if (devino >= msi_end)
+               return 0;
+
+       sysino = sun4v_devino_to_sysino(devhandle, devino);
+       bucket = &ivector_table[sysino];
+       bucket->virt_irq = virt_irq_alloc(__irq(bucket));
+       *virt_irq_p = bucket->virt_irq;
+       set_irq_chip(bucket->virt_irq, &sun4v_msi);
+
+       data = get_irq_chip_data(bucket->virt_irq);
+       if (unlikely(data))
+               return devino;
+
+       data = kzalloc(sizeof(struct irq_handler_data), GFP_ATOMIC);
+       if (unlikely(!data)) {
+               prom_printf("IRQ: kzalloc(irq_handler_data) failed.\n");
+               prom_halt();
+       }
+       set_irq_chip_data(bucket->virt_irq, data);
+
+       data->imap = ~0UL;
+       data->iclr = ~0UL;
+
+       return devino;
+}
+
+void sun4v_destroy_msi(unsigned int virt_irq)
+{
+       virt_irq_free(virt_irq);
+}
+#endif
+
 void ack_bad_irq(unsigned int virt_irq)
 {
        struct ino_bucket *bucket = virt_irq_to_bucket(virt_irq);
index dfc41cd4bb5d06f690fa47080e8a6dcbecb3c65e..6b740eb6fe7e45915a0e4372cf496036b3d3fb23 100644 (file)
@@ -13,6 +13,8 @@
 #include <linux/capability.h>
 #include <linux/errno.h>
 #include <linux/smp_lock.h>
+#include <linux/msi.h>
+#include <linux/irq.h>
 #include <linux/init.h>
 
 #include <asm/uaccess.h>
@@ -646,4 +648,37 @@ int pci_domain_nr(struct pci_bus *pbus)
 }
 EXPORT_SYMBOL(pci_domain_nr);
 
+#ifdef CONFIG_PCI_MSI
+int arch_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *desc)
+{
+       struct pcidev_cookie *pcp = pdev->sysdata;
+       struct pci_pbm_info *pbm = pcp->pbm;
+       struct pci_controller_info *p = pbm->parent;
+       int virt_irq, err;
+
+       if (!pbm->msi_num || !p->setup_msi_irq)
+               return -EINVAL;
+
+       err = p->setup_msi_irq(&virt_irq, pdev, desc);
+       if (err < 0)
+               return err;
+
+       return virt_irq;
+}
+
+void arch_teardown_msi_irq(unsigned int virt_irq)
+{
+       struct msi_desc *entry = get_irq_data(virt_irq);
+       struct pci_dev *pdev = entry->dev;
+       struct pcidev_cookie *pcp = pdev->sysdata;
+       struct pci_pbm_info *pbm = pcp->pbm;
+       struct pci_controller_info *p = pbm->parent;
+
+       if (!pbm->msi_num || !p->setup_msi_irq)
+               return;
+
+       return p->teardown_msi_irq(virt_irq, pdev);
+}
+#endif /* !(CONFIG_PCI_MSI) */
+
 #endif /* !(CONFIG_PCI) */
index 827ae30aa4971e5306e1f8c0ed6db494e65b71ec..5a92cb90ebe009d18fb7f1a61656d48bd6ab42c1 100644 (file)
@@ -7,6 +7,8 @@
 #include <linux/string.h>
 #include <linux/slab.h>
 #include <linux/init.h>
+#include <linux/pci.h>
+#include <linux/device.h>
 
 #include <asm/pbm.h>
 #include <asm/prom.h>
@@ -129,6 +131,20 @@ static void __init fixup_obp_assignments(struct pci_dev *pdev,
        }
 }
 
+static ssize_t
+show_pciobppath_attr(struct device * dev, struct device_attribute * attr, char * buf)
+{
+       struct pci_dev *pdev;
+       struct pcidev_cookie *sysdata;
+
+       pdev = to_pci_dev(dev);
+       sysdata = pdev->sysdata;
+
+       return snprintf (buf, PAGE_SIZE, "%s\n", sysdata->prom_node->full_name);
+}
+
+static DEVICE_ATTR(obppath, S_IRUSR | S_IRGRP | S_IROTH, show_pciobppath_attr, NULL);
+
 /* Fill in the PCI device cookie sysdata for the given
  * PCI device.  This cookie is the means by which one
  * can get to OBP and PCI controller specific information
@@ -142,7 +158,7 @@ static void __init pdev_cookie_fillin(struct pci_pbm_info *pbm,
        struct pcidev_cookie *pcp;
        struct device_node *dp;
        struct property *prop;
-       int nregs, len;
+       int nregs, len, err;
 
        dp = find_device_prom_node(pbm, pdev, bus_node,
                                   &pregs, &nregs);
@@ -215,6 +231,13 @@ static void __init pdev_cookie_fillin(struct pci_pbm_info *pbm,
        fixup_obp_assignments(pdev, pcp);
 
        pdev->sysdata = pcp;
+
+       /* we don't really care if we can create this file or not,
+        * but we need to assign the result of the call or the world will fall
+        * under alien invasion and everybody will be frozen on a spaceship
+        * ready to be eaten on alpha centauri by some green and jelly humanoid.
+        */
+       err = sysfs_create_file(&pdev->dev.kobj, &dev_attr_obppath.attr);
 }
 
 void __init pci_fill_in_pbm_cookies(struct pci_bus *pbus,
index 6b04794b7a971bab494b7837748c6bc741bc7e5b..ec22cd61ec8ce8eeab6689a6de6ff4d04efc948d 100644 (file)
@@ -10,6 +10,8 @@
 #include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/percpu.h>
+#include <linux/irq.h>
+#include <linux/msi.h>
 
 #include <asm/pbm.h>
 #include <asm/iommu.h>
@@ -1074,6 +1076,443 @@ static void pci_sun4v_get_bus_range(struct pci_pbm_info *pbm)
 
 }
 
+#ifdef CONFIG_PCI_MSI
+struct pci_sun4v_msiq_entry {
+       u64             version_type;
+#define MSIQ_VERSION_MASK              0xffffffff00000000UL
+#define MSIQ_VERSION_SHIFT             32
+#define MSIQ_TYPE_MASK                 0x00000000000000ffUL
+#define MSIQ_TYPE_SHIFT                        0
+#define MSIQ_TYPE_NONE                 0x00
+#define MSIQ_TYPE_MSG                  0x01
+#define MSIQ_TYPE_MSI32                        0x02
+#define MSIQ_TYPE_MSI64                        0x03
+#define MSIQ_TYPE_INTX                 0x08
+#define MSIQ_TYPE_NONE2                        0xff
+
+       u64             intx_sysino;
+       u64             reserved1;
+       u64             stick;
+       u64             req_id;  /* bus/device/func */
+#define MSIQ_REQID_BUS_MASK            0xff00UL
+#define MSIQ_REQID_BUS_SHIFT           8
+#define MSIQ_REQID_DEVICE_MASK         0x00f8UL
+#define MSIQ_REQID_DEVICE_SHIFT                3
+#define MSIQ_REQID_FUNC_MASK           0x0007UL
+#define MSIQ_REQID_FUNC_SHIFT          0
+
+       u64             msi_address;
+
+       /* The format of this value is message type dependant.
+        * For MSI bits 15:0 are the data from the MSI packet.
+        * For MSI-X bits 31:0 are the data from the MSI packet.
+        * For MSG, the message code and message routing code where:
+        *      bits 39:32 is the bus/device/fn of the msg target-id
+        *      bits 18:16 is the message routing code
+        *      bits 7:0 is the message code
+        * For INTx the low order 2-bits are:
+        *      00 - INTA
+        *      01 - INTB
+        *      10 - INTC
+        *      11 - INTD
+        */
+       u64             msi_data;
+
+       u64             reserved2;
+};
+
+/* For now this just runs as a pre-handler for the real interrupt handler.
+ * So we just walk through the queue and ACK all the entries, update the
+ * head pointer, and return.
+ *
+ * In the longer term it would be nice to do something more integrated
+ * wherein we can pass in some of this MSI info to the drivers.  This
+ * would be most useful for PCIe fabric error messages, although we could
+ * invoke those directly from the loop here in order to pass the info around.
+ */
+static void pci_sun4v_msi_prehandler(unsigned int ino, void *data1, void *data2)
+{
+       struct pci_pbm_info *pbm = data1;
+       struct pci_sun4v_msiq_entry *base, *ep;
+       unsigned long msiqid, orig_head, head, type, err;
+
+       msiqid = (unsigned long) data2;
+
+       head = 0xdeadbeef;
+       err = pci_sun4v_msiq_gethead(pbm->devhandle, msiqid, &head);
+       if (unlikely(err))
+               goto hv_error_get;
+
+       if (unlikely(head >= (pbm->msiq_ent_count * sizeof(struct pci_sun4v_msiq_entry))))
+               goto bad_offset;
+
+       head /= sizeof(struct pci_sun4v_msiq_entry);
+       orig_head = head;
+       base = (pbm->msi_queues + ((msiqid - pbm->msiq_first) *
+                                  (pbm->msiq_ent_count *
+                                   sizeof(struct pci_sun4v_msiq_entry))));
+       ep = &base[head];
+       while ((ep->version_type & MSIQ_TYPE_MASK) != 0) {
+               type = (ep->version_type & MSIQ_TYPE_MASK) >> MSIQ_TYPE_SHIFT;
+               if (unlikely(type != MSIQ_TYPE_MSI32 &&
+                            type != MSIQ_TYPE_MSI64))
+                       goto bad_type;
+
+               pci_sun4v_msi_setstate(pbm->devhandle,
+                                      ep->msi_data /* msi_num */,
+                                      HV_MSISTATE_IDLE);
+
+               /* Clear the entry.  */
+               ep->version_type &= ~MSIQ_TYPE_MASK;
+
+               /* Go to next entry in ring.  */
+               head++;
+               if (head >= pbm->msiq_ent_count)
+                       head = 0;
+               ep = &base[head];
+       }
+
+       if (likely(head != orig_head)) {
+               /* ACK entries by updating head pointer.  */
+               head *= sizeof(struct pci_sun4v_msiq_entry);
+               err = pci_sun4v_msiq_sethead(pbm->devhandle, msiqid, head);
+               if (unlikely(err))
+                       goto hv_error_set;
+       }
+       return;
+
+hv_error_set:
+       printk(KERN_EMERG "MSI: Hypervisor set head gives error %lu\n", err);
+       goto hv_error_cont;
+
+hv_error_get:
+       printk(KERN_EMERG "MSI: Hypervisor get head gives error %lu\n", err);
+
+hv_error_cont:
+       printk(KERN_EMERG "MSI: devhandle[%x] msiqid[%lx] head[%lu]\n",
+              pbm->devhandle, msiqid, head);
+       return;
+
+bad_offset:
+       printk(KERN_EMERG "MSI: Hypervisor gives bad offset %lx max(%lx)\n",
+              head, pbm->msiq_ent_count * sizeof(struct pci_sun4v_msiq_entry));
+       return;
+
+bad_type:
+       printk(KERN_EMERG "MSI: Entry has bad type %lx\n", type);
+       return;
+}
+
+static int msi_bitmap_alloc(struct pci_pbm_info *pbm)
+{
+       unsigned long size, bits_per_ulong;
+
+       bits_per_ulong = sizeof(unsigned long) * 8;
+       size = (pbm->msi_num + (bits_per_ulong - 1)) & ~(bits_per_ulong - 1);
+       size /= 8;
+       BUG_ON(size % sizeof(unsigned long));
+
+       pbm->msi_bitmap = kzalloc(size, GFP_KERNEL);
+       if (!pbm->msi_bitmap)
+               return -ENOMEM;
+
+       return 0;
+}
+
+static void msi_bitmap_free(struct pci_pbm_info *pbm)
+{
+       kfree(pbm->msi_bitmap);
+       pbm->msi_bitmap = NULL;
+}
+
+static int msi_queue_alloc(struct pci_pbm_info *pbm)
+{
+       unsigned long q_size, alloc_size, pages, order;
+       int i;
+
+       q_size = pbm->msiq_ent_count * sizeof(struct pci_sun4v_msiq_entry);
+       alloc_size = (pbm->msiq_num * q_size);
+       order = get_order(alloc_size);
+       pages = __get_free_pages(GFP_KERNEL | __GFP_COMP, order);
+       if (pages == 0UL) {
+               printk(KERN_ERR "MSI: Cannot allocate MSI queues (o=%lu).\n",
+                      order);
+               return -ENOMEM;
+       }
+       memset((char *)pages, 0, PAGE_SIZE << order);
+       pbm->msi_queues = (void *) pages;
+
+       for (i = 0; i < pbm->msiq_num; i++) {
+               unsigned long err, base = __pa(pages + (i * q_size));
+               unsigned long ret1, ret2;
+
+               err = pci_sun4v_msiq_conf(pbm->devhandle,
+                                         pbm->msiq_first + i,
+                                         base, pbm->msiq_ent_count);
+               if (err) {
+                       printk(KERN_ERR "MSI: msiq register fails (err=%lu)\n",
+                              err);
+                       goto h_error;
+               }
+
+               err = pci_sun4v_msiq_info(pbm->devhandle,
+                                         pbm->msiq_first + i,
+                                         &ret1, &ret2);
+               if (err) {
+                       printk(KERN_ERR "MSI: Cannot read msiq (err=%lu)\n",
+                              err);
+                       goto h_error;
+               }
+               if (ret1 != base || ret2 != pbm->msiq_ent_count) {
+                       printk(KERN_ERR "MSI: Bogus qconf "
+                              "expected[%lx:%x] got[%lx:%lx]\n",
+                              base, pbm->msiq_ent_count,
+                              ret1, ret2);
+                       goto h_error;
+               }
+       }
+
+       return 0;
+
+h_error:
+       free_pages(pages, order);
+       return -EINVAL;
+}
+
+static void pci_sun4v_msi_init(struct pci_pbm_info *pbm)
+{
+       u32 *val;
+       int len;
+
+       val = of_get_property(pbm->prom_node, "#msi-eqs", &len);
+       if (!val || len != 4)
+               goto no_msi;
+       pbm->msiq_num = *val;
+       if (pbm->msiq_num) {
+               struct msiq_prop {
+                       u32 first_msiq;
+                       u32 num_msiq;
+                       u32 first_devino;
+               } *mqp;
+               struct msi_range_prop {
+                       u32 first_msi;
+                       u32 num_msi;
+               } *mrng;
+               struct addr_range_prop {
+                       u32 msi32_high;
+                       u32 msi32_low;
+                       u32 msi32_len;
+                       u32 msi64_high;
+                       u32 msi64_low;
+                       u32 msi64_len;
+               } *arng;
+
+               val = of_get_property(pbm->prom_node, "msi-eq-size", &len);
+               if (!val || len != 4)
+                       goto no_msi;
+
+               pbm->msiq_ent_count = *val;
+
+               mqp = of_get_property(pbm->prom_node,
+                                     "msi-eq-to-devino", &len);
+               if (!mqp || len != sizeof(struct msiq_prop))
+                       goto no_msi;
+
+               pbm->msiq_first = mqp->first_msiq;
+               pbm->msiq_first_devino = mqp->first_devino;
+
+               val = of_get_property(pbm->prom_node, "#msi", &len);
+               if (!val || len != 4)
+                       goto no_msi;
+               pbm->msi_num = *val;
+
+               mrng = of_get_property(pbm->prom_node, "msi-ranges", &len);
+               if (!mrng || len != sizeof(struct msi_range_prop))
+                       goto no_msi;
+               pbm->msi_first = mrng->first_msi;
+
+               val = of_get_property(pbm->prom_node, "msi-data-mask", &len);
+               if (!val || len != 4)
+                       goto no_msi;
+               pbm->msi_data_mask = *val;
+
+               val = of_get_property(pbm->prom_node, "msix-data-width", &len);
+               if (!val || len != 4)
+                       goto no_msi;
+               pbm->msix_data_width = *val;
+
+               arng = of_get_property(pbm->prom_node, "msi-address-ranges",
+                                      &len);
+               if (!arng || len != sizeof(struct addr_range_prop))
+                       goto no_msi;
+               pbm->msi32_start = ((u64)arng->msi32_high << 32) |
+                       (u64) arng->msi32_low;
+               pbm->msi64_start = ((u64)arng->msi64_high << 32) |
+                       (u64) arng->msi64_low;
+               pbm->msi32_len = arng->msi32_len;
+               pbm->msi64_len = arng->msi64_len;
+
+               if (msi_bitmap_alloc(pbm))
+                       goto no_msi;
+
+               if (msi_queue_alloc(pbm)) {
+                       msi_bitmap_free(pbm);
+                       goto no_msi;
+               }
+
+               printk(KERN_INFO "%s: MSI Queue first[%u] num[%u] count[%u] "
+                      "devino[0x%x]\n",
+                      pbm->name,
+                      pbm->msiq_first, pbm->msiq_num,
+                      pbm->msiq_ent_count,
+                      pbm->msiq_first_devino);
+               printk(KERN_INFO "%s: MSI first[%u] num[%u] mask[0x%x] "
+                      "width[%u]\n",
+                      pbm->name,
+                      pbm->msi_first, pbm->msi_num, pbm->msi_data_mask,
+                      pbm->msix_data_width);
+               printk(KERN_INFO "%s: MSI addr32[0x%lx:0x%x] "
+                      "addr64[0x%lx:0x%x]\n",
+                      pbm->name,
+                      pbm->msi32_start, pbm->msi32_len,
+                      pbm->msi64_start, pbm->msi64_len);
+               printk(KERN_INFO "%s: MSI queues at RA [%p]\n",
+                      pbm->name,
+                      pbm->msi_queues);
+       }
+
+       return;
+
+no_msi:
+       pbm->msiq_num = 0;
+       printk(KERN_INFO "%s: No MSI support.\n", pbm->name);
+}
+
+static int alloc_msi(struct pci_pbm_info *pbm)
+{
+       int i;
+
+       for (i = 0; i < pbm->msi_num; i++) {
+               if (!test_and_set_bit(i, pbm->msi_bitmap))
+                       return i + pbm->msi_first;
+       }
+
+       return -ENOENT;
+}
+
+static void free_msi(struct pci_pbm_info *pbm, int msi_num)
+{
+       msi_num -= pbm->msi_first;
+       clear_bit(msi_num, pbm->msi_bitmap);
+}
+
+static int pci_sun4v_setup_msi_irq(unsigned int *virt_irq_p,
+                                  struct pci_dev *pdev,
+                                  struct msi_desc *entry)
+{
+       struct pcidev_cookie *pcp = pdev->sysdata;
+       struct pci_pbm_info *pbm = pcp->pbm;
+       unsigned long devino, msiqid;
+       struct msi_msg msg;
+       int msi_num, err;
+
+       *virt_irq_p = 0;
+
+       msi_num = alloc_msi(pbm);
+       if (msi_num < 0)
+               return msi_num;
+
+       devino = sun4v_build_msi(pbm->devhandle, virt_irq_p,
+                                pbm->msiq_first_devino,
+                                (pbm->msiq_first_devino +
+                                 pbm->msiq_num));
+       err = -ENOMEM;
+       if (!devino)
+               goto out_err;
+
+       set_irq_msi(*virt_irq_p, entry);
+
+       msiqid = ((devino - pbm->msiq_first_devino) +
+                 pbm->msiq_first);
+
+       err = -EINVAL;
+       if (pci_sun4v_msiq_setstate(pbm->devhandle, msiqid, HV_MSIQSTATE_IDLE))
+       if (err)
+               goto out_err;
+
+       if (pci_sun4v_msiq_setvalid(pbm->devhandle, msiqid, HV_MSIQ_VALID))
+               goto out_err;
+
+       if (pci_sun4v_msi_setmsiq(pbm->devhandle,
+                                 msi_num, msiqid,
+                                 (entry->msi_attrib.is_64 ?
+                                  HV_MSITYPE_MSI64 : HV_MSITYPE_MSI32)))
+               goto out_err;
+
+       if (pci_sun4v_msi_setstate(pbm->devhandle, msi_num, HV_MSISTATE_IDLE))
+               goto out_err;
+
+       if (pci_sun4v_msi_setvalid(pbm->devhandle, msi_num, HV_MSIVALID_VALID))
+               goto out_err;
+
+       pcp->msi_num = msi_num;
+
+       if (entry->msi_attrib.is_64) {
+               msg.address_hi = pbm->msi64_start >> 32;
+               msg.address_lo = pbm->msi64_start & 0xffffffff;
+       } else {
+               msg.address_hi = 0;
+               msg.address_lo = pbm->msi32_start;
+       }
+       msg.data = msi_num;
+       write_msi_msg(*virt_irq_p, &msg);
+
+       irq_install_pre_handler(*virt_irq_p,
+                               pci_sun4v_msi_prehandler,
+                               pbm, (void *) msiqid);
+
+       return 0;
+
+out_err:
+       free_msi(pbm, msi_num);
+       sun4v_destroy_msi(*virt_irq_p);
+       *virt_irq_p = 0;
+       return err;
+
+}
+
+static void pci_sun4v_teardown_msi_irq(unsigned int virt_irq,
+                                      struct pci_dev *pdev)
+{
+       struct pcidev_cookie *pcp = pdev->sysdata;
+       struct pci_pbm_info *pbm = pcp->pbm;
+       unsigned long msiqid, err;
+       unsigned int msi_num;
+
+       msi_num = pcp->msi_num;
+       err = pci_sun4v_msi_getmsiq(pbm->devhandle, msi_num, &msiqid);
+       if (err) {
+               printk(KERN_ERR "%s: getmsiq gives error %lu\n",
+                      pbm->name, err);
+               return;
+       }
+
+       pci_sun4v_msi_setvalid(pbm->devhandle, msi_num, HV_MSIVALID_INVALID);
+       pci_sun4v_msiq_setvalid(pbm->devhandle, msiqid, HV_MSIQ_INVALID);
+
+       free_msi(pbm, msi_num);
+
+       /* The sun4v_destroy_msi() will liberate the devino and thus the MSIQ
+        * allocation.
+        */
+       sun4v_destroy_msi(virt_irq);
+}
+#else /* CONFIG_PCI_MSI */
+static void pci_sun4v_msi_init(struct pci_pbm_info *pbm)
+{
+}
+#endif /* !(CONFIG_PCI_MSI) */
+
 static void pci_sun4v_pbm_init(struct pci_controller_info *p, struct device_node *dp, u32 devhandle)
 {
        struct pci_pbm_info *pbm;
@@ -1119,6 +1558,7 @@ static void pci_sun4v_pbm_init(struct pci_controller_info *p, struct device_node
 
        pci_sun4v_get_bus_range(pbm);
        pci_sun4v_iommu_init(pbm);
+       pci_sun4v_msi_init(pbm);
 
        pdev_htab_populate(pbm);
 }
@@ -1187,6 +1627,10 @@ void sun4v_pci_init(struct device_node *dp, char *model_name)
        p->scan_bus = pci_sun4v_scan_bus;
        p->base_address_update = pci_sun4v_base_address_update;
        p->resource_adjust = pci_sun4v_resource_adjust;
+#ifdef CONFIG_PCI_MSI
+       p->setup_msi_irq = pci_sun4v_setup_msi_irq;
+       p->teardown_msi_irq = pci_sun4v_teardown_msi_irq;
+#endif
        p->pci_ops = &pci_sun4v_ops;
 
        /* Like PSYCHO and SCHIZO we have a 2GB aligned area
index 884d25f6158dad36a58c6c4c30365c910530d7a1..8e9fc3a5b4f52d68120d360fa0d18ca6f0e9b2a7 100644 (file)
@@ -28,4 +28,65 @@ extern int pci_sun4v_config_put(unsigned long devhandle,
                                unsigned long size,
                                unsigned long data);
 
+extern unsigned long pci_sun4v_msiq_conf(unsigned long devhandle,
+                                        unsigned long msiqid,
+                                        unsigned long msiq_paddr,
+                                        unsigned long num_entries);
+extern unsigned long pci_sun4v_msiq_info(unsigned long devhandle,
+                                        unsigned long msiqid,
+                                        unsigned long *msiq_paddr,
+                                        unsigned long *num_entries);
+extern unsigned long pci_sun4v_msiq_getvalid(unsigned long devhandle,
+                                            unsigned long msiqid,
+                                            unsigned long *valid);
+extern unsigned long pci_sun4v_msiq_setvalid(unsigned long devhandle,
+                                            unsigned long msiqid,
+                                            unsigned long valid);
+extern unsigned long pci_sun4v_msiq_getstate(unsigned long devhandle,
+                                            unsigned long msiqid,
+                                            unsigned long *state);
+extern unsigned long pci_sun4v_msiq_setstate(unsigned long devhandle,
+                                            unsigned long msiqid,
+                                            unsigned long state);
+extern unsigned long pci_sun4v_msiq_gethead(unsigned long devhandle,
+                                            unsigned long msiqid,
+                                            unsigned long *head);
+extern unsigned long pci_sun4v_msiq_sethead(unsigned long devhandle,
+                                            unsigned long msiqid,
+                                            unsigned long head);
+extern unsigned long pci_sun4v_msiq_gettail(unsigned long devhandle,
+                                            unsigned long msiqid,
+                                            unsigned long *head);
+extern unsigned long pci_sun4v_msi_getvalid(unsigned long devhandle,
+                                           unsigned long msinum,
+                                           unsigned long *valid);
+extern unsigned long pci_sun4v_msi_setvalid(unsigned long devhandle,
+                                           unsigned long msinum,
+                                           unsigned long valid);
+extern unsigned long pci_sun4v_msi_getmsiq(unsigned long devhandle,
+                                          unsigned long msinum,
+                                          unsigned long *msiq);
+extern unsigned long pci_sun4v_msi_setmsiq(unsigned long devhandle,
+                                          unsigned long msinum,
+                                          unsigned long msiq,
+                                          unsigned long msitype);
+extern unsigned long pci_sun4v_msi_getstate(unsigned long devhandle,
+                                           unsigned long msinum,
+                                           unsigned long *state);
+extern unsigned long pci_sun4v_msi_setstate(unsigned long devhandle,
+                                           unsigned long msinum,
+                                           unsigned long state);
+extern unsigned long pci_sun4v_msg_getmsiq(unsigned long devhandle,
+                                          unsigned long msinum,
+                                          unsigned long *msiq);
+extern unsigned long pci_sun4v_msg_setmsiq(unsigned long devhandle,
+                                          unsigned long msinum,
+                                          unsigned long msiq);
+extern unsigned long pci_sun4v_msg_getvalid(unsigned long devhandle,
+                                           unsigned long msinum,
+                                           unsigned long *valid);
+extern unsigned long pci_sun4v_msg_setvalid(unsigned long devhandle,
+                                           unsigned long msinum,
+                                           unsigned long valid);
+
 #endif /* !(_PCI_SUN4V_H) */
index 6604fdbf746cc44b2c410013563a87e27ae84ee3..ecb81f389b0689ff3518448813a1532e96e50af5 100644 (file)
@@ -93,3 +93,269 @@ pci_sun4v_config_put:
         mov    -1, %o1
 1:     retl
         mov    %o1, %o0
+
+       /* %o0: devhandle
+        * %o1: msiqid
+        * %o2: msiq phys address
+        * %o3: num entries
+        *
+        * returns %o0: status
+        *
+        * status will be zero if the operation completed
+        * successfully, else -1 if not
+        */
+       .globl  pci_sun4v_msiq_conf
+pci_sun4v_msiq_conf:
+       mov     HV_FAST_PCI_MSIQ_CONF, %o5
+       ta      HV_FAST_TRAP
+       retl
+        mov    %o0, %o0
+
+       /* %o0: devhandle
+        * %o1: msiqid
+        * %o2: &msiq_phys_addr
+        * %o3: &msiq_num_entries
+        *
+        * returns %o0: status
+        */
+       .globl  pci_sun4v_msiq_info
+pci_sun4v_msiq_info:
+       mov     %o2, %o4
+       mov     HV_FAST_PCI_MSIQ_INFO, %o5
+       ta      HV_FAST_TRAP
+       stx     %o1, [%o4]
+       stx     %o2, [%o3]
+       retl
+        mov    %o0, %o0
+
+       /* %o0: devhandle
+        * %o1: msiqid
+        * %o2: &valid
+        *
+        * returns %o0: status
+        */
+       .globl  pci_sun4v_msiq_getvalid
+pci_sun4v_msiq_getvalid:
+       mov     HV_FAST_PCI_MSIQ_GETVALID, %o5
+       ta      HV_FAST_TRAP
+       stx     %o1, [%o2]
+       retl
+        mov    %o0, %o0
+
+       /* %o0: devhandle
+        * %o1: msiqid
+        * %o2: valid
+        *
+        * returns %o0: status
+        */
+       .globl  pci_sun4v_msiq_setvalid
+pci_sun4v_msiq_setvalid:
+       mov     HV_FAST_PCI_MSIQ_SETVALID, %o5
+       ta      HV_FAST_TRAP
+       retl
+        mov    %o0, %o0
+
+       /* %o0: devhandle
+        * %o1: msiqid
+        * %o2: &state
+        *
+        * returns %o0: status
+        */
+       .globl  pci_sun4v_msiq_getstate
+pci_sun4v_msiq_getstate:
+       mov     HV_FAST_PCI_MSIQ_GETSTATE, %o5
+       ta      HV_FAST_TRAP
+       stx     %o1, [%o2]
+       retl
+        mov    %o0, %o0
+
+       /* %o0: devhandle
+        * %o1: msiqid
+        * %o2: state
+        *
+        * returns %o0: status
+        */
+       .globl  pci_sun4v_msiq_setstate
+pci_sun4v_msiq_setstate:
+       mov     HV_FAST_PCI_MSIQ_SETSTATE, %o5
+       ta      HV_FAST_TRAP
+       retl
+        mov    %o0, %o0
+
+       /* %o0: devhandle
+        * %o1: msiqid
+        * %o2: &head
+        *
+        * returns %o0: status
+        */
+       .globl  pci_sun4v_msiq_gethead
+pci_sun4v_msiq_gethead:
+       mov     HV_FAST_PCI_MSIQ_GETHEAD, %o5
+       ta      HV_FAST_TRAP
+       stx     %o1, [%o2]
+       retl
+        mov    %o0, %o0
+
+       /* %o0: devhandle
+        * %o1: msiqid
+        * %o2: head
+        *
+        * returns %o0: status
+        */
+       .globl  pci_sun4v_msiq_sethead
+pci_sun4v_msiq_sethead:
+       mov     HV_FAST_PCI_MSIQ_SETHEAD, %o5
+       ta      HV_FAST_TRAP
+       retl
+        mov    %o0, %o0
+
+       /* %o0: devhandle
+        * %o1: msiqid
+        * %o2: &tail
+        *
+        * returns %o0: status
+        */
+       .globl  pci_sun4v_msiq_gettail
+pci_sun4v_msiq_gettail:
+       mov     HV_FAST_PCI_MSIQ_GETTAIL, %o5
+       ta      HV_FAST_TRAP
+       stx     %o1, [%o2]
+       retl
+        mov    %o0, %o0
+
+       /* %o0: devhandle
+        * %o1: msinum
+        * %o2: &valid
+        *
+        * returns %o0: status
+        */
+       .globl  pci_sun4v_msi_getvalid
+pci_sun4v_msi_getvalid:
+       mov     HV_FAST_PCI_MSI_GETVALID, %o5
+       ta      HV_FAST_TRAP
+       stx     %o1, [%o2]
+       retl
+        mov    %o0, %o0
+
+       /* %o0: devhandle
+        * %o1: msinum
+        * %o2: valid
+        *
+        * returns %o0: status
+        */
+       .globl  pci_sun4v_msi_setvalid
+pci_sun4v_msi_setvalid:
+       mov     HV_FAST_PCI_MSI_SETVALID, %o5
+       ta      HV_FAST_TRAP
+       retl
+        mov    %o0, %o0
+
+       /* %o0: devhandle
+        * %o1: msinum
+        * %o2: &msiq
+        *
+        * returns %o0: status
+        */
+       .globl  pci_sun4v_msi_getmsiq
+pci_sun4v_msi_getmsiq:
+       mov     HV_FAST_PCI_MSI_GETMSIQ, %o5
+       ta      HV_FAST_TRAP
+       stx     %o1, [%o2]
+       retl
+        mov    %o0, %o0
+
+       /* %o0: devhandle
+        * %o1: msinum
+        * %o2: msitype
+        * %o3: msiq
+        *
+        * returns %o0: status
+        */
+       .globl  pci_sun4v_msi_setmsiq
+pci_sun4v_msi_setmsiq:
+       mov     HV_FAST_PCI_MSI_SETMSIQ, %o5
+       ta      HV_FAST_TRAP
+       retl
+        mov    %o0, %o0
+
+       /* %o0: devhandle
+        * %o1: msinum
+        * %o2: &state
+        *
+        * returns %o0: status
+        */
+       .globl  pci_sun4v_msi_getstate
+pci_sun4v_msi_getstate:
+       mov     HV_FAST_PCI_MSI_GETSTATE, %o5
+       ta      HV_FAST_TRAP
+       stx     %o1, [%o2]
+       retl
+        mov    %o0, %o0
+
+       /* %o0: devhandle
+        * %o1: msinum
+        * %o2: state
+        *
+        * returns %o0: status
+        */
+       .globl  pci_sun4v_msi_setstate
+pci_sun4v_msi_setstate:
+       mov     HV_FAST_PCI_MSI_SETSTATE, %o5
+       ta      HV_FAST_TRAP
+       retl
+        mov    %o0, %o0
+
+       /* %o0: devhandle
+        * %o1: msinum
+        * %o2: &msiq
+        *
+        * returns %o0: status
+        */
+       .globl  pci_sun4v_msg_getmsiq
+pci_sun4v_msg_getmsiq:
+       mov     HV_FAST_PCI_MSG_GETMSIQ, %o5
+       ta      HV_FAST_TRAP
+       stx     %o1, [%o2]
+       retl
+        mov    %o0, %o0
+
+       /* %o0: devhandle
+        * %o1: msinum
+        * %o2: msiq
+        *
+        * returns %o0: status
+        */
+       .globl  pci_sun4v_msg_setmsiq
+pci_sun4v_msg_setmsiq:
+       mov     HV_FAST_PCI_MSG_SETMSIQ, %o5
+       ta      HV_FAST_TRAP
+       retl
+        mov    %o0, %o0
+
+       /* %o0: devhandle
+        * %o1: msinum
+        * %o2: &valid
+        *
+        * returns %o0: status
+        */
+       .globl  pci_sun4v_msg_getvalid
+pci_sun4v_msg_getvalid:
+       mov     HV_FAST_PCI_MSG_GETVALID, %o5
+       ta      HV_FAST_TRAP
+       stx     %o1, [%o2]
+       retl
+        mov    %o0, %o0
+
+       /* %o0: devhandle
+        * %o1: msinum
+        * %o2: valid
+        *
+        * returns %o0: status
+        */
+       .globl  pci_sun4v_msg_setvalid
+pci_sun4v_msg_setvalid:
+       mov     HV_FAST_PCI_MSG_SETVALID, %o5
+       ta      HV_FAST_TRAP
+       retl
+        mov    %o0, %o0
+
index 3f619ead22cc89a70ed5905e782a041153626463..a05e43d517554b5a81befdef2f074e05283270f4 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/termios.h>
+#include <linux/tty.h>
 #include <linux/ioctl.h>
 #include <linux/route.h>
 #include <linux/sockios.h>
index e27cb71bd8e2c09a20bfe7d50b379c80b39abe0a..7876a02262852399ee3c27efa1d135d366feb528 100644 (file)
@@ -459,70 +459,6 @@ asmlinkage long compat_sys_sysfs(int option, u32 arg1, u32 arg2)
        return sys_sysfs(option, arg1, arg2);
 }
 
-struct sysinfo32 {
-        s32 uptime;
-        u32 loads[3];
-        u32 totalram;
-        u32 freeram;
-        u32 sharedram;
-        u32 bufferram;
-        u32 totalswap;
-        u32 freeswap;
-        unsigned short procs;
-       unsigned short pad;
-       u32 totalhigh;
-       u32 freehigh;
-       u32 mem_unit;
-       char _f[20-2*sizeof(int)-sizeof(int)];
-};
-
-asmlinkage long sys32_sysinfo(struct sysinfo32 __user *info)
-{
-       struct sysinfo s;
-       int ret, err;
-       int bitcount = 0;
-       mm_segment_t old_fs = get_fs ();
-       
-       set_fs(KERNEL_DS);
-       ret = sys_sysinfo((struct sysinfo __user *) &s);
-       set_fs(old_fs);
-       /* Check to see if any memory value is too large for 32-bit and
-         * scale down if needed.
-         */
-       if ((s.totalram >> 32) || (s.totalswap >> 32)) {
-               while (s.mem_unit < PAGE_SIZE) {
-                       s.mem_unit <<= 1;
-                       bitcount++;
-               }
-               s.totalram >>= bitcount;
-               s.freeram >>= bitcount;
-               s.sharedram >>= bitcount;
-               s.bufferram >>= bitcount;
-               s.totalswap >>= bitcount;
-               s.freeswap >>= bitcount;
-               s.totalhigh >>= bitcount;
-               s.freehigh >>= bitcount;
-       }
-
-       err = put_user (s.uptime, &info->uptime);
-       err |= __put_user (s.loads[0], &info->loads[0]);
-       err |= __put_user (s.loads[1], &info->loads[1]);
-       err |= __put_user (s.loads[2], &info->loads[2]);
-       err |= __put_user (s.totalram, &info->totalram);
-       err |= __put_user (s.freeram, &info->freeram);
-       err |= __put_user (s.sharedram, &info->sharedram);
-       err |= __put_user (s.bufferram, &info->bufferram);
-       err |= __put_user (s.totalswap, &info->totalswap);
-       err |= __put_user (s.freeswap, &info->freeswap);
-       err |= __put_user (s.procs, &info->procs);
-       err |= __put_user (s.totalhigh, &info->totalhigh);
-       err |= __put_user (s.freehigh, &info->freehigh);
-       err |= __put_user (s.mem_unit, &info->mem_unit);
-       if (err)
-               return -EFAULT;
-       return ret;
-}
-
 asmlinkage long compat_sys_sched_rr_get_interval(compat_pid_t pid, struct compat_timespec __user *interval)
 {
        struct timespec t;
index 9a8026797ac04c368db63eab8a43dcf445d2b0a8..948b7d2d5874f37030c85b69026a1046f2ba10c4 100644 (file)
@@ -61,7 +61,7 @@ sys_call_table32:
        .word sys32_epoll_wait, sys32_ioprio_set, sys_getppid, sys32_sigaction, sys_sgetmask
 /*200*/        .word sys32_ssetmask, sys_sigsuspend, compat_sys_newlstat, sys_uselib, compat_sys_old_readdir
        .word sys32_readahead, sys32_socketcall, sys32_syslog, sys32_lookup_dcookie, sys32_fadvise64
-/*210*/        .word sys32_fadvise64_64, sys32_tgkill, sys32_waitpid, sys_swapoff, sys32_sysinfo
+/*210*/        .word sys32_fadvise64_64, sys32_tgkill, sys32_waitpid, sys_swapoff, compat_sys_sysinfo
        .word sys32_ipc, sys32_sigreturn, sys_clone, sys32_ioprio_get, compat_sys_adjtimex
 /*220*/        .word sys32_sigprocmask, sys_ni_syscall, sys32_delete_module, sys_ni_syscall, sys32_getpgid
        .word sys32_bdflush, sys32_sysfs, sys_nis_syscall, sys32_setfsuid16, sys32_setfsgid16
index 4a6063f33e7a4155e084cd50ba58a2617f3fa3c3..13fa2a2e4513b75cdae8052b544d5a96bf134c29 100644 (file)
@@ -81,10 +81,14 @@ SECTIONS
   __sun4v_2insn_patch = .;
   .sun4v_2insn_patch : { *(.sun4v_2insn_patch) }
   __sun4v_2insn_patch_end = .;
+
+#ifdef CONFIG_BLK_DEV_INITRD
   . = ALIGN(8192); 
   __initramfs_start = .;
   .init.ramfs : { *(.init.ramfs) }
   __initramfs_end = .;
+#endif
+
   . = ALIGN(8192);
   __per_cpu_start = .;
   .data.percpu  : { *(.data.percpu) }
index 054822a3e05ec6d64f9fead97c692a86f87fdc46..09d434f41e4b37059cf7e6fa1d724f1695e25469 100644 (file)
@@ -416,7 +416,7 @@ void show_mem(void)
        printk("Free swap:       %6ldkB\n",
               nr_swap_pages << (PAGE_SHIFT-10));
        printk("%ld pages of RAM\n", num_physpages);
-       printk("%d free pages\n", nr_free_pages());
+       printk("%lu free pages\n", nr_free_pages());
 }
 
 void mmu_info(struct seq_file *m)
@@ -1593,7 +1593,7 @@ void __init mem_init(void)
        initpages = (((unsigned long) __init_end) - ((unsigned long) __init_begin));
        initpages = PAGE_ALIGN(initpages) >> PAGE_SHIFT;
 
-       printk("Memory: %uk available (%ldk kernel code, %ldk data, %ldk init) [%016lx,%016lx]\n",
+       printk("Memory: %luk available (%ldk kernel code, %ldk data, %ldk init) [%016lx,%016lx]\n",
               nr_free_pages() << (PAGE_SHIFT-10),
               codepages << (PAGE_SHIFT-10),
               datapages << (PAGE_SHIFT-10), 
index d32a80e6668c08c008714d8c0ef1f26ce6a4645b..b3a21ba77cd2a40f9784d3e5d86fe53dfb1fed67 100644 (file)
@@ -16,6 +16,9 @@ config MMU
        bool
        default y
 
+config NO_IOMEM
+       def_bool y
+
 mainmenu "Linux/Usermode Kernel Configuration"
 
 config ISA
index 7d4190e5565498c6eea6dce02fc3cc092a65b384..7b8baf146accc411487cb3c098db8825f0b56759 100644 (file)
 #include "line.h"
 #include "os.h"
 
-/* XXX: could well be moved to somewhere else, if needed. */
-static int my_printf(const char * fmt, ...)
-       __attribute__ ((format (printf, 1, 2)));
-
-static int my_printf(const char * fmt, ...)
-{
-       /* Yes, can be called on atomic context.*/
-       char *buf = kmalloc(4096, GFP_ATOMIC);
-       va_list args;
-       int r;
-
-       if (!buf) {
-               /* We print directly fmt.
-                * Yes, yes, yes, feel free to complain. */
-               r = strlen(fmt);
-       } else {
-               va_start(args, fmt);
-               r = vsprintf(buf, fmt, args);
-               va_end(args);
-               fmt = buf;
-       }
-
-       if (r)
-               r = os_write_file(1, fmt, r);
-       return r;
-
-}
-
 #ifdef CONFIG_NOCONFIG_CHAN
-/* Despite its name, there's no added trailing newline. */
-static int my_puts(const char * buf)
-{
-       return os_write_file(1, buf, strlen(buf));
-}
-
-static void *not_configged_init(char *str, int device, struct chan_opts *opts)
+static void *not_configged_init(char *str, int device,
+                               const struct chan_opts *opts)
 {
-       my_puts("Using a channel type which is configured out of "
+       printk("Using a channel type which is configured out of "
               "UML\n");
        return NULL;
 }
@@ -64,34 +31,34 @@ static void *not_configged_init(char *str, int device, struct chan_opts *opts)
 static int not_configged_open(int input, int output, int primary, void *data,
                              char **dev_out)
 {
-       my_puts("Using a channel type which is configured out of "
+       printk("Using a channel type which is configured out of "
               "UML\n");
        return -ENODEV;
 }
 
 static void not_configged_close(int fd, void *data)
 {
-       my_puts("Using a channel type which is configured out of "
+       printk("Using a channel type which is configured out of "
               "UML\n");
 }
 
 static int not_configged_read(int fd, char *c_out, void *data)
 {
-       my_puts("Using a channel type which is configured out of "
+       printk("Using a channel type which is configured out of "
               "UML\n");
        return -EIO;
 }
 
 static int not_configged_write(int fd, const char *buf, int len, void *data)
 {
-       my_puts("Using a channel type which is configured out of "
+       printk("Using a channel type which is configured out of "
               "UML\n");
        return -EIO;
 }
 
 static int not_configged_console_write(int fd, const char *buf, int len)
 {
-       my_puts("Using a channel type which is configured out of "
+       printk("Using a channel type which is configured out of "
               "UML\n");
        return -EIO;
 }
@@ -99,14 +66,14 @@ static int not_configged_console_write(int fd, const char *buf, int len)
 static int not_configged_window_size(int fd, void *data, unsigned short *rows,
                                     unsigned short *cols)
 {
-       my_puts("Using a channel type which is configured out of "
+       printk("Using a channel type which is configured out of "
               "UML\n");
        return -ENODEV;
 }
 
 static void not_configged_free(void *data)
 {
-       my_puts("Using a channel type which is configured out of "
+       printk("Using a channel type which is configured out of "
               "UML\n");
 }
 
@@ -255,15 +222,28 @@ void enable_chan(struct line *line)
        }
 }
 
+/* Items are added in IRQ context, when free_irq can't be called, and
+ * removed in process context, when it can.
+ * This handles interrupt sources which disappear, and which need to
+ * be permanently disabled.  This is discovered in IRQ context, but
+ * the freeing of the IRQ must be done later.
+ */
+static DEFINE_SPINLOCK(irqs_to_free_lock);
 static LIST_HEAD(irqs_to_free);
 
 void free_irqs(void)
 {
        struct chan *chan;
+       LIST_HEAD(list);
+       struct list_head *ele;
 
-       while(!list_empty(&irqs_to_free)){
-               chan = list_entry(irqs_to_free.next, struct chan, free_list);
-               list_del(&chan->free_list);
+       spin_lock_irq(&irqs_to_free_lock);
+       list_splice_init(&irqs_to_free, &list);
+       INIT_LIST_HEAD(&irqs_to_free);
+       spin_unlock_irq(&irqs_to_free_lock);
+
+       list_for_each(ele, &list){
+               chan = list_entry(ele, struct chan, free_list);
 
                if(chan->input)
                        free_irq(chan->line->driver->read_irq, chan);
@@ -279,7 +259,9 @@ static void close_one_chan(struct chan *chan, int delay_free_irq)
                return;
 
        if(delay_free_irq){
+               spin_lock_irq(&irqs_to_free_lock);
                list_add(&chan->free_list, &irqs_to_free);
+               spin_unlock_irq(&irqs_to_free_lock);
        }
        else {
                if(chan->input)
@@ -372,8 +354,7 @@ int console_write_chan(struct list_head *chans, const char *buf, int len)
        return ret;
 }
 
-int console_open_chan(struct line *line, struct console *co,
-                     const struct chan_opts *opts)
+int console_open_chan(struct line *line, struct console *co)
 {
        int err;
 
@@ -381,7 +362,7 @@ int console_open_chan(struct line *line, struct console *co,
        if(err)
                return err;
 
-       printk("Console initialized on /dev/%s%d\n",co->name,co->index);
+       printk("Console initialized on /dev/%s%d\n", co->name, co->index);
        return 0;
 }
 
@@ -534,7 +515,7 @@ static const struct chan_type chan_table[] = {
 };
 
 static struct chan *parse_chan(struct line *line, char *str, int device,
-                              const struct chan_opts *opts)
+                              const struct chan_opts *opts, char **error_out)
 {
        const struct chan_type *entry;
        const struct chan_ops *ops;
@@ -553,19 +534,21 @@ static struct chan *parse_chan(struct line *line, char *str, int device,
                }
        }
        if(ops == NULL){
-               my_printf("parse_chan couldn't parse \"%s\"\n",
-                      str);
+               *error_out = "No match for configured backends";
                return NULL;
        }
-       if(ops->init == NULL)
-               return NULL;
+
        data = (*ops->init)(str, device, opts);
-       if(data == NULL)
+       if(data == NULL){
+               *error_out = "Configuration failed";
                return NULL;
+       }
 
        chan = kmalloc(sizeof(*chan), GFP_ATOMIC);
-       if(chan == NULL)
+       if(chan == NULL){
+               *error_out = "Memory allocation failed";
                return NULL;
+       }
        *chan = ((struct chan) { .list          = LIST_HEAD_INIT(chan->list),
                                 .free_list     =
                                        LIST_HEAD_INIT(chan->free_list),
@@ -582,7 +565,7 @@ static struct chan *parse_chan(struct line *line, char *str, int device,
 }
 
 int parse_chan_pair(char *str, struct line *line, int device,
-                   const struct chan_opts *opts)
+                   const struct chan_opts *opts, char **error_out)
 {
        struct list_head *chans = &line->chan_list;
        struct chan *new, *chan;
@@ -599,14 +582,14 @@ int parse_chan_pair(char *str, struct line *line, int device,
                in = str;
                *out = '\0';
                out++;
-               new = parse_chan(line, in, device, opts);
+               new = parse_chan(line, in, device, opts, error_out);
                if(new == NULL)
                        return -1;
 
                new->input = 1;
                list_add(&new->list, chans);
 
-               new = parse_chan(line, out, device, opts);
+               new = parse_chan(line, out, device, opts, error_out);
                if(new == NULL)
                        return -1;
 
@@ -614,7 +597,7 @@ int parse_chan_pair(char *str, struct line *line, int device,
                new->output = 1;
        }
        else {
-               new = parse_chan(line, str, device, opts);
+               new = parse_chan(line, str, device, opts, error_out);
                if(new == NULL)
                        return -1;
 
index 64ff22aa077bdb3686fe33e655914630af45dd44..73c5caa7a150ea1a6757aaa2bfea26b00bc6a771 100644 (file)
@@ -9,10 +9,10 @@
  *     modify it under the terms of the GNU General Public License
  *     as published by the Free Software Foundation; either version
  *     2 of the License, or (at your option) any later version.
- *     
- *     Neither Alan Cox nor CymruNet Ltd. admit liability nor provide 
- *     warranty for any of this software. This material is provided 
- *     "AS-IS" and at no charge.       
+ *
+ *     Neither Alan Cox nor CymruNet Ltd. admit liability nor provide
+ *     warranty for any of this software. This material is provided
+ *     "AS-IS" and at no charge.
  *
  *     (c) Copyright 1995    Alan Cox <alan@lxorguk.ukuu.org.uk>
  *
  *     Made SMP safe for 2.3.x
  *
  *  20011127 Joel Becker (jlbec@evilplan.org>
- *     Added soft_noboot; Allows testing the softdog trigger without 
+ *     Added soft_noboot; Allows testing the softdog trigger without
  *     requiring a recompile.
  *     Added WDIOC_GETTIMEOUT and WDIOC_SETTIMOUT.
  */
+
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/reboot.h>
 #include <linux/smp_lock.h>
 #include <linux/init.h>
+#include <linux/spinlock.h>
 #include <asm/uaccess.h>
 #include "mconsole.h"
 
 MODULE_LICENSE("GPL");
 
-/* Locked by the BKL in harddog_open and harddog_release */
+static DEFINE_SPINLOCK(lock);
 static int timer_alive;
 static int harddog_in_fd = -1;
 static int harddog_out_fd = -1;
@@ -57,18 +58,18 @@ static int harddog_out_fd = -1;
 /*
  *     Allow only one person to hold it open
  */
+
 extern int start_watchdog(int *in_fd_ret, int *out_fd_ret, char *sock);
 
 static int harddog_open(struct inode *inode, struct file *file)
 {
-       int err;
+       int err = -EBUSY;
        char *sock = NULL;
 
-       lock_kernel();
+       spin_lock(&lock);
        if(timer_alive)
-               return -EBUSY;
-#ifdef CONFIG_HARDDOG_NOWAYOUT  
+               goto err;
+#ifdef CONFIG_HARDDOG_NOWAYOUT
        __module_get(THIS_MODULE);
 #endif
 
@@ -76,11 +77,15 @@ static int harddog_open(struct inode *inode, struct file *file)
        sock = mconsole_notify_socket();
 #endif
        err = start_watchdog(&harddog_in_fd, &harddog_out_fd, sock);
-       if(err) return(err);
+       if(err)
+               goto err;
 
        timer_alive = 1;
-       unlock_kernel();
+       spin_unlock(&lock);
        return nonseekable_open(inode, file);
+err:
+       spin_unlock(&lock);
+       return err;
 }
 
 extern void stop_watchdog(int in_fd, int out_fd);
@@ -90,14 +95,16 @@ static int harddog_release(struct inode *inode, struct file *file)
        /*
         *      Shut off the timer.
         */
-       lock_kernel();
+
+       spin_lock(&lock);
 
        stop_watchdog(harddog_in_fd, harddog_out_fd);
        harddog_in_fd = -1;
        harddog_out_fd = -1;
 
        timer_alive=0;
-       unlock_kernel();
+       spin_unlock(&lock);
+
        return 0;
 }
 
@@ -110,7 +117,7 @@ static ssize_t harddog_write(struct file *file, const char __user *data, size_t
         *      Refresh the timer.
         */
        if(len)
-               return(ping_watchdog(harddog_out_fd));
+               return ping_watchdog(harddog_out_fd);
        return 0;
 }
 
@@ -134,7 +141,7 @@ static int harddog_ioctl(struct inode *inode, struct file *file,
                case WDIOC_GETBOOTSTATUS:
                        return put_user(0,(int __user *)argp);
                case WDIOC_KEEPALIVE:
-                       return(ping_watchdog(harddog_out_fd));
+                       return ping_watchdog(harddog_out_fd);
        }
 }
 
@@ -165,7 +172,7 @@ static int __init harddog_init(void)
 
        printk(banner);
 
-       return(0);
+       return 0;
 }
 
 static void __exit harddog_exit(void)
@@ -175,14 +182,3 @@ static void __exit harddog_exit(void)
 
 module_init(harddog_init);
 module_exit(harddog_exit);
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
index def013b5a3c7a5ec373dae711829b4ae10f76349..c495ecf263b14862b9b9227679416abbf0f0d032 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
  * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
  * Licensed under the GPL
  */
@@ -38,7 +38,7 @@ int start_watchdog(int *in_fd_ret, int *out_fd_ret, char *sock)
        int in_fds[2], out_fds[2], pid, n, err;
        char pid_buf[sizeof("nnnnn\0")], c;
        char *pid_args[] = { "/usr/bin/uml_watchdog", "-pid", pid_buf, NULL };
-       char *mconsole_args[] = { "/usr/bin/uml_watchdog", "-mconsole", NULL, 
+       char *mconsole_args[] = { "/usr/bin/uml_watchdog", "-mconsole", NULL,
                                  NULL };
        char **args = NULL;
 
@@ -96,7 +96,7 @@ int start_watchdog(int *in_fd_ret, int *out_fd_ret, char *sock)
        }
        *in_fd_ret = in_fds[0];
        *out_fd_ret = out_fds[1];
-       return(0);
+       return 0;
 
  out_close_in:
        os_close_file(in_fds[0]);
@@ -105,7 +105,7 @@ int start_watchdog(int *in_fd_ret, int *out_fd_ret, char *sock)
        os_close_file(out_fds[0]);
        os_close_file(out_fds[1]);
  out:
-       return(err);
+       return err;
 }
 
 void stop_watchdog(int in_fd, int out_fd)
@@ -123,20 +123,9 @@ int ping_watchdog(int fd)
        if(n != sizeof(c)){
                printk("ping_watchdog - write failed, err = %d\n", -n);
                if(n < 0)
-                       return(n);
-               return(-EIO);
+                       return n;
+               return -EIO;
        }
        return 1;
 
 }
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
index a0d148ea63d6bfa7b8bf8a1ffaceeff6b72ad477..10e08a8c17c3149cc346529a1c61bb6f6b241cff 100644 (file)
 #include "os.h"
 
 struct hostaudio_state {
-  int fd;
+       int fd;
 };
 
 struct hostmixer_state {
-  int fd;
+       int fd;
 };
 
 #define HOSTAUDIO_DEV_DSP "/dev/sound/dsp"
 #define HOSTAUDIO_DEV_MIXER "/dev/sound/mixer"
 
-/* Only changed from linux_main at boot time */
-char *dsp = HOSTAUDIO_DEV_DSP;
-char *mixer = HOSTAUDIO_DEV_MIXER;
+/* Changed either at boot time or module load time.  At boot, this is
+ * single-threaded; at module load, multiple modules would each have
+ * their own copy of these variables.
+ */
+static char *dsp = HOSTAUDIO_DEV_DSP;
+static char *mixer = HOSTAUDIO_DEV_MIXER;
 
 #define DSP_HELP \
 "    This is used to specify the host dsp device to the hostaudio driver.\n" \
@@ -69,12 +72,12 @@ MODULE_PARM_DESC(mixer, MIXER_HELP);
 static ssize_t hostaudio_read(struct file *file, char __user *buffer,
                              size_t count, loff_t *ppos)
 {
-        struct hostaudio_state *state = file->private_data;
+       struct hostaudio_state *state = file->private_data;
        void *kbuf;
        int err;
 
 #ifdef DEBUG
-        printk("hostaudio: read called, count = %d\n", count);
+       printk("hostaudio: read called, count = %d\n", count);
 #endif
 
        kbuf = kmalloc(count, GFP_KERNEL);
@@ -88,7 +91,7 @@ static ssize_t hostaudio_read(struct file *file, char __user *buffer,
        if(copy_to_user(buffer, kbuf, err))
                err = -EFAULT;
 
- out:
+out:
        kfree(kbuf);
        return(err);
 }
@@ -96,12 +99,12 @@ static ssize_t hostaudio_read(struct file *file, char __user *buffer,
 static ssize_t hostaudio_write(struct file *file, const char __user *buffer,
                               size_t count, loff_t *ppos)
 {
-        struct hostaudio_state *state = file->private_data;
+       struct hostaudio_state *state = file->private_data;
        void *kbuf;
        int err;
 
 #ifdef DEBUG
-        printk("hostaudio: write called, count = %d\n", count);
+       printk("hostaudio: write called, count = %d\n", count);
 #endif
 
        kbuf = kmalloc(count, GFP_KERNEL);
@@ -125,24 +128,24 @@ static ssize_t hostaudio_write(struct file *file, const char __user *buffer,
 static unsigned int hostaudio_poll(struct file *file, 
                                   struct poll_table_struct *wait)
 {
-        unsigned int mask = 0;
+       unsigned int mask = 0;
 
 #ifdef DEBUG
-        printk("hostaudio: poll called (unimplemented)\n");
+       printk("hostaudio: poll called (unimplemented)\n");
 #endif
 
-        return(mask);
+       return(mask);
 }
 
 static int hostaudio_ioctl(struct inode *inode, struct file *file, 
                           unsigned int cmd, unsigned long arg)
 {
-        struct hostaudio_state *state = file->private_data;
+       struct hostaudio_state *state = file->private_data;
        unsigned long data = 0;
        int err;
 
 #ifdef DEBUG
-        printk("hostaudio: ioctl called, cmd = %u\n", cmd);
+       printk("hostaudio: ioctl called, cmd = %u\n", cmd);
 #endif
        switch(cmd){
        case SNDCTL_DSP_SPEED:
@@ -179,42 +182,40 @@ static int hostaudio_ioctl(struct inode *inode, struct file *file,
 
 static int hostaudio_open(struct inode *inode, struct file *file)
 {
-        struct hostaudio_state *state;
-        int r = 0, w = 0;
-        int ret;
+       struct hostaudio_state *state;
+       int r = 0, w = 0;
+       int ret;
 
 #ifdef DEBUG
-        printk("hostaudio: open called (host: %s)\n", dsp);
+       printk("hostaudio: open called (host: %s)\n", dsp);
 #endif
 
-        state = kmalloc(sizeof(struct hostaudio_state), GFP_KERNEL);
-        if(state == NULL)
+       state = kmalloc(sizeof(struct hostaudio_state), GFP_KERNEL);
+       if(state == NULL)
                return(-ENOMEM);
 
-        if(file->f_mode & FMODE_READ) r = 1;
-        if(file->f_mode & FMODE_WRITE) w = 1;
+       if(file->f_mode & FMODE_READ) r = 1;
+       if(file->f_mode & FMODE_WRITE) w = 1;
 
        ret = os_open_file(dsp, of_set_rw(OPENFLAGS(), r, w), 0);
-        if(ret < 0){
+       if(ret < 0){
                kfree(state);
                return(ret);
-        }
-
+       }
        state->fd = ret;
-        file->private_data = state;
-        return(0);
+       file->private_data = state;
+       return(0);
 }
 
 static int hostaudio_release(struct inode *inode, struct file *file)
 {
-        struct hostaudio_state *state = file->private_data;
+       struct hostaudio_state *state = file->private_data;
 
 #ifdef DEBUG
-        printk("hostaudio: release called\n");
+       printk("hostaudio: release called\n");
 #endif
-
-               os_close_file(state->fd);
-        kfree(state);
+       os_close_file(state->fd);
+       kfree(state);
 
        return(0);
 }
@@ -224,10 +225,10 @@ static int hostaudio_release(struct inode *inode, struct file *file)
 static int hostmixer_ioctl_mixdev(struct inode *inode, struct file *file, 
                                  unsigned int cmd, unsigned long arg)
 {
-        struct hostmixer_state *state = file->private_data;
+       struct hostmixer_state *state = file->private_data;
 
 #ifdef DEBUG
-        printk("hostmixer: ioctl called\n");
+       printk("hostmixer: ioctl called\n");
 #endif
 
        return(os_ioctl_generic(state->fd, cmd, arg));
@@ -235,68 +236,67 @@ static int hostmixer_ioctl_mixdev(struct inode *inode, struct file *file,
 
 static int hostmixer_open_mixdev(struct inode *inode, struct file *file)
 {
-        struct hostmixer_state *state;
-        int r = 0, w = 0;
-        int ret;
+       struct hostmixer_state *state;
+       int r = 0, w = 0;
+       int ret;
 
 #ifdef DEBUG
-        printk("hostmixer: open called (host: %s)\n", mixer);
+       printk("hostmixer: open called (host: %s)\n", mixer);
 #endif
 
-        state = kmalloc(sizeof(struct hostmixer_state), GFP_KERNEL);
-        if(state == NULL) return(-ENOMEM);
+       state = kmalloc(sizeof(struct hostmixer_state), GFP_KERNEL);
+       if(state == NULL) return(-ENOMEM);
 
-        if(file->f_mode & FMODE_READ) r = 1;
-        if(file->f_mode & FMODE_WRITE) w = 1;
+       if(file->f_mode & FMODE_READ) r = 1;
+       if(file->f_mode & FMODE_WRITE) w = 1;
 
        ret = os_open_file(mixer, of_set_rw(OPENFLAGS(), r, w), 0);
         
-        if(ret < 0){
+       if(ret < 0){
                printk("hostaudio_open_mixdev failed to open '%s', err = %d\n",
                       dsp, -ret);
                kfree(state);
                return(ret);
-        }
+       }
 
-        file->private_data = state;
-        return(0);
+       file->private_data = state;
+       return(0);
 }
 
 static int hostmixer_release(struct inode *inode, struct file *file)
 {
-        struct hostmixer_state *state = file->private_data;
+       struct hostmixer_state *state = file->private_data;
 
 #ifdef DEBUG
-        printk("hostmixer: release called\n");
+       printk("hostmixer: release called\n");
 #endif
 
-               os_close_file(state->fd);
-        kfree(state);
+       os_close_file(state->fd);
+       kfree(state);
 
        return(0);
 }
 
-
 /* kernel module operations */
 
 static const struct file_operations hostaudio_fops = {
-        .owner          = THIS_MODULE,
-        .llseek         = no_llseek,
-        .read           = hostaudio_read,
-        .write          = hostaudio_write,
-        .poll           = hostaudio_poll,
-        .ioctl          = hostaudio_ioctl,
-        .mmap           = NULL,
-        .open           = hostaudio_open,
-        .release        = hostaudio_release,
+       .owner          = THIS_MODULE,
+       .llseek         = no_llseek,
+       .read           = hostaudio_read,
+       .write          = hostaudio_write,
+       .poll           = hostaudio_poll,
+       .ioctl          = hostaudio_ioctl,
+       .mmap           = NULL,
+       .open           = hostaudio_open,
+       .release        = hostaudio_release,
 };
 
 static const struct file_operations hostmixer_fops = {
-        .owner          = THIS_MODULE,
-        .llseek         = no_llseek,
-        .ioctl          = hostmixer_ioctl_mixdev,
-        .open           = hostmixer_open_mixdev,
-        .release        = hostmixer_release,
+       .owner          = THIS_MODULE,
+       .llseek         = no_llseek,
+       .ioctl          = hostmixer_ioctl_mixdev,
+       .open           = hostmixer_open_mixdev,
+       .release        = hostmixer_release,
 };
 
 struct {
@@ -310,42 +310,31 @@ MODULE_LICENSE("GPL");
 
 static int __init hostaudio_init_module(void)
 {
-        printk(KERN_INFO "UML Audio Relay (host dsp = %s, host mixer = %s)\n",
+       printk(KERN_INFO "UML Audio Relay (host dsp = %s, host mixer = %s)\n",
               dsp, mixer);
 
        module_data.dev_audio = register_sound_dsp(&hostaudio_fops, -1);
-        if(module_data.dev_audio < 0){
-                printk(KERN_ERR "hostaudio: couldn't register DSP device!\n");
-                return -ENODEV;
-        }
+       if(module_data.dev_audio < 0){
+               printk(KERN_ERR "hostaudio: couldn't register DSP device!\n");
+               return -ENODEV;
+       }
 
        module_data.dev_mixer = register_sound_mixer(&hostmixer_fops, -1);
-        if(module_data.dev_mixer < 0){
-                printk(KERN_ERR "hostmixer: couldn't register mixer "
+       if(module_data.dev_mixer < 0){
+               printk(KERN_ERR "hostmixer: couldn't register mixer "
                       "device!\n");
-                unregister_sound_dsp(module_data.dev_audio);
-                return -ENODEV;
-        }
+               unregister_sound_dsp(module_data.dev_audio);
+               return -ENODEV;
+       }
 
-        return 0;
+       return 0;
 }
 
 static void __exit hostaudio_cleanup_module (void)
 {
-       unregister_sound_mixer(module_data.dev_mixer);
-       unregister_sound_dsp(module_data.dev_audio);
+       unregister_sound_mixer(module_data.dev_mixer);
+       unregister_sound_dsp(module_data.dev_audio);
 }
 
 module_init(hostaudio_init_module);
 module_exit(hostaudio_cleanup_module);
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
index 83301e1ef67cbe24dbe6ee73f70b21c756ff87f8..0e1e9a20a4d67b032f59f910d6adafa5a760978d 100644 (file)
@@ -191,7 +191,6 @@ void line_flush_buffer(struct tty_struct *tty)
        /*XXX: copied from line_write, verify if it is correct!*/
        if(tty->stopped)
                return;
-               //return 0;
 
        spin_lock_irqsave(&line->lock, flags);
        err = flush_buffer(line);
@@ -421,42 +420,55 @@ int line_setup_irq(int fd, int input, int output, struct line *line, void *data)
        return err;
 }
 
+/* Normally, a driver like this can rely mostly on the tty layer
+ * locking, particularly when it comes to the driver structure.
+ * However, in this case, mconsole requests can come in "from the
+ * side", and race with opens and closes.
+ *
+ * mconsole config requests will want to be sure the device isn't in
+ * use, and get_config, open, and close will want a stable
+ * configuration.  The checking and modification of the configuration
+ * is done under a spinlock.  Checking whether the device is in use is
+ * line->tty->count > 1, also under the spinlock.
+ *
+ * tty->count serves to decide whether the device should be enabled or
+ * disabled on the host.  If it's equal to 1, then we are doing the
+ * first open or last close.  Otherwise, open and close just return.
+ */
+
 int line_open(struct line *lines, struct tty_struct *tty)
 {
-       struct line *line;
+       struct line *line = &lines[tty->index];
        int err = -ENODEV;
 
-       line = &lines[tty->index];
-       tty->driver_data = line;
+       spin_lock(&line->count_lock);
+       if(!line->valid)
+               goto out_unlock;
 
-       /* The IRQ which takes this lock is not yet enabled and won't be run
-        * before the end, so we don't need to use spin_lock_irq.*/
-       spin_lock(&line->lock);
+       err = 0;
+       if(tty->count > 1)
+               goto out_unlock;
+
+       spin_unlock(&line->count_lock);
 
        tty->driver_data = line;
        line->tty = tty;
-       if(!line->valid)
-               goto out;
 
-       if(tty->count == 1){
-               /* Here the device is opened, if necessary, and interrupt
-                * is registered.
-                */
-               enable_chan(line);
-               INIT_DELAYED_WORK(&line->task, line_timer_cb);
+       enable_chan(line);
+       INIT_DELAYED_WORK(&line->task, line_timer_cb);
 
-               if(!line->sigio){
-                       chan_enable_winch(&line->chan_list, tty);
-                       line->sigio = 1;
-               }
-
-               chan_window_size(&line->chan_list, &tty->winsize.ws_row,
-                                &tty->winsize.ws_col);
+       if(!line->sigio){
+               chan_enable_winch(&line->chan_list, tty);
+               line->sigio = 1;
        }
 
-       err = 0;
-out:
-       spin_unlock(&line->lock);
+       chan_window_size(&line->chan_list, &tty->winsize.ws_row,
+                        &tty->winsize.ws_col);
+
+       return err;
+
+out_unlock:
+       spin_unlock(&line->count_lock);
        return err;
 }
 
@@ -466,25 +478,36 @@ void line_close(struct tty_struct *tty, struct file * filp)
 {
        struct line *line = tty->driver_data;
 
-       /* XXX: I assume this should be called in process context, not with
-         *  interrupts disabled!
-         */
-       spin_lock_irq(&line->lock);
+       /* If line_open fails (and tty->driver_data is never set),
+        * tty_open will call line_close.  So just return in this case.
+        */
+       if(line == NULL)
+               return;
 
        /* We ignore the error anyway! */
        flush_buffer(line);
 
-       if(tty->count == 1){
-               line->tty = NULL;
-               tty->driver_data = NULL;
+       spin_lock(&line->count_lock);
+       if(!line->valid)
+               goto out_unlock;
 
-               if(line->sigio){
-                       unregister_winch(tty);
-                       line->sigio = 0;
-               }
+       if(tty->count > 1)
+               goto out_unlock;
+
+       spin_unlock(&line->count_lock);
+
+       line->tty = NULL;
+       tty->driver_data = NULL;
+
+       if(line->sigio){
+               unregister_winch(tty);
+               line->sigio = 0;
         }
 
-       spin_unlock_irq(&line->lock);
+       return;
+
+out_unlock:
+       spin_unlock(&line->count_lock);
 }
 
 void close_lines(struct line *lines, int nlines)
@@ -495,14 +518,44 @@ void close_lines(struct line *lines, int nlines)
                close_chan(&lines[i].chan_list, 0);
 }
 
+static int setup_one_line(struct line *lines, int n, char *init, int init_prio,
+                         char **error_out)
+{
+       struct line *line = &lines[n];
+       int err = -EINVAL;
+
+       spin_lock(&line->count_lock);
+
+       if(line->tty != NULL){
+               *error_out = "Device is already open";
+               goto out;
+       }
+
+       if (line->init_pri <= init_prio){
+               line->init_pri = init_prio;
+               if (!strcmp(init, "none"))
+                       line->valid = 0;
+               else {
+                       line->init_str = init;
+                       line->valid = 1;
+               }
+       }
+       err = 0;
+out:
+       spin_unlock(&line->count_lock);
+       return err;
+}
+
 /* Common setup code for both startup command line and mconsole initialization.
  * @lines contains the array (of size @num) to modify;
  * @init is the setup string;
+ * @error_out is an error string in the case of failure;
  */
 
-int line_setup(struct line *lines, unsigned int num, char *init)
+int line_setup(struct line *lines, unsigned int num, char *init,
+              char **error_out)
 {
-       int i, n;
+       int i, n, err;
        char *end;
 
        if(*init == '=') {
@@ -513,73 +566,56 @@ int line_setup(struct line *lines, unsigned int num, char *init)
        else {
                n = simple_strtoul(init, &end, 0);
                if(*end != '='){
-                       printk(KERN_ERR "line_setup failed to parse \"%s\"\n",
-                              init);
-                       return 0;
+                       *error_out = "Couldn't parse device number";
+                       return -EINVAL;
                }
                init = end;
        }
        init++;
 
        if (n >= (signed int) num) {
-               printk("line_setup - %d out of range ((0 ... %d) allowed)\n",
-                      n, num - 1);
-               return 0;
+               *error_out = "Device number out of range";
+               return -EINVAL;
        }
        else if (n >= 0){
-               if (lines[n].tty != NULL) {
-                       printk("line_setup - device %d is open\n", n);
-                       return 0;
-               }
-               if (lines[n].init_pri <= INIT_ONE){
-                       lines[n].init_pri = INIT_ONE;
-                       if (!strcmp(init, "none"))
-                               lines[n].valid = 0;
-                       else {
-                               lines[n].init_str = init;
-                               lines[n].valid = 1;
-                       }
-               }
+               err = setup_one_line(lines, n, init, INIT_ONE, error_out);
+               if(err)
+                       return err;
        }
        else {
                for(i = 0; i < num; i++){
-                       if(lines[i].init_pri <= INIT_ALL){
-                               lines[i].init_pri = INIT_ALL;
-                               if(!strcmp(init, "none")) lines[i].valid = 0;
-                               else {
-                                       lines[i].init_str = init;
-                                       lines[i].valid = 1;
-                               }
-                       }
+                       err = setup_one_line(lines, i, init, INIT_ALL,
+                                            error_out);
+                       if(err)
+                               return err;
                }
        }
        return n == -1 ? num : n;
 }
 
 int line_config(struct line *lines, unsigned int num, char *str,
-               const struct chan_opts *opts)
+               const struct chan_opts *opts, char **error_out)
 {
        struct line *line;
        char *new;
        int n;
 
        if(*str == '='){
-               printk("line_config - can't configure all devices from "
-                      "mconsole\n");
-               return 1;
+               *error_out = "Can't configure all devices from mconsole";
+               return -EINVAL;
        }
 
        new = kstrdup(str, GFP_KERNEL);
        if(new == NULL){
-               printk("line_config - kstrdup failed\n");
-               return 1;
+               *error_out = "Failed to allocate memory";
+               return -ENOMEM;
        }
-       n = line_setup(lines, num, new);
+       n = line_setup(lines, num, new, error_out);
        if(n < 0)
-               return 1;
+               return n;
 
        line = &lines[n];
-       return parse_chan_pair(line->init_str, line, n, opts);
+       return parse_chan_pair(line->init_str, line, n, opts, error_out);
 }
 
 int line_get_config(char *name, struct line *lines, unsigned int num, char *str,
@@ -602,13 +638,13 @@ int line_get_config(char *name, struct line *lines, unsigned int num, char *str,
 
        line = &lines[dev];
 
-       spin_lock(&line->lock);
+       spin_lock(&line->count_lock);
        if(!line->valid)
                CONFIG_CHUNK(str, size, n, "none", 1);
        else if(line->tty == NULL)
                CONFIG_CHUNK(str, size, n, line->init_str, 1);
        else n = chan_config_string(&line->chan_list, str, size, error_out);
-       spin_unlock(&line->lock);
+       spin_unlock(&line->count_lock);
 
        return n;
 }
@@ -628,22 +664,21 @@ int line_id(char **str, int *start_out, int *end_out)
         return n;
 }
 
-int line_remove(struct line *lines, unsigned int num, int n)
+int line_remove(struct line *lines, unsigned int num, int n, char **error_out)
 {
        int err;
        char config[sizeof("conxxxx=none\0")];
 
        sprintf(config, "%d=none", n);
-       err = line_setup(lines, num, config);
+       err = line_setup(lines, num, config, error_out);
        if(err >= 0)
                err = 0;
        return err;
 }
 
-struct tty_driver *line_register_devfs(struct lines *set,
-                                      struct line_driver *line_driver,
-                                      const struct tty_operations *ops,
-                                      struct line *lines, int nlines)
+struct tty_driver *register_lines(struct line_driver *line_driver,
+                                 const struct tty_operations *ops,
+                                 struct line *lines, int nlines)
 {
        int i;
        struct tty_driver *driver = alloc_tty_driver(nlines);
@@ -683,6 +718,7 @@ static LIST_HEAD(winch_handlers);
 void lines_init(struct line *lines, int nlines, struct chan_opts *opts)
 {
        struct line *line;
+       char *error;
        int i;
 
        for(i = 0; i < nlines; i++){
@@ -696,8 +732,9 @@ void lines_init(struct line *lines, int nlines, struct chan_opts *opts)
                if(line->init_str == NULL)
                        printk("lines_init - kstrdup returned NULL\n");
 
-               if(parse_chan_pair(line->init_str, line, i, opts)){
-                       printk("parse_chan_pair failed for device %d\n", i);
+               if(parse_chan_pair(line->init_str, line, i, opts, &error)){
+                       printk("parse_chan_pair failed for device %d : %s\n",
+                              i, error);
                        line->valid = 0;
                }
        }
index 96f0189327af58260bcbfe14e304faf67cfe513c..178b2eff4a8ce836b5286aae5e32429480a2cf66 100644 (file)
@@ -33,7 +33,6 @@
 #include "irq_user.h"
 #include "init.h"
 #include "os.h"
-#include "umid.h"
 #include "irq_kern.h"
 #include "choose-mode.h"
 
@@ -337,13 +336,15 @@ void mconsole_stop(struct mc_request *req)
        mconsole_reply(req, "", 0, 0);
 }
 
-/* This list is populated by __initcall routines. */
-
+static DEFINE_SPINLOCK(mc_devices_lock);
 static LIST_HEAD(mconsole_devices);
 
 void mconsole_register_dev(struct mc_device *new)
 {
+       spin_lock(&mc_devices_lock);
+       BUG_ON(!list_empty(&new->list));
        list_add(&new->list, &mconsole_devices);
+       spin_unlock(&mc_devices_lock);
 }
 
 static struct mc_device *mconsole_find_dev(char *name)
@@ -367,18 +368,21 @@ struct unplugged_pages {
        void *pages[UNPLUGGED_PER_PAGE];
 };
 
+static DECLARE_MUTEX(plug_mem_mutex);
 static unsigned long long unplugged_pages_count = 0;
-static struct list_head unplugged_pages = LIST_HEAD_INIT(unplugged_pages);
+static LIST_HEAD(unplugged_pages);
 static int unplug_index = UNPLUGGED_PER_PAGE;
 
-static int mem_config(char *str)
+static int mem_config(char *str, char **error_out)
 {
        unsigned long long diff;
        int err = -EINVAL, i, add;
        char *ret;
 
-       if(str[0] != '=')
+       if(str[0] != '='){
+               *error_out = "Expected '=' after 'mem'";
                goto out;
+       }
 
        str++;
        if(str[0] == '-')
@@ -386,15 +390,21 @@ static int mem_config(char *str)
        else if(str[0] == '+'){
                add = 1;
        }
-       else goto out;
+       else {
+               *error_out = "Expected increment to start with '-' or '+'";
+               goto out;
+       }
 
        str++;
        diff = memparse(str, &ret);
-       if(*ret != '\0')
+       if(*ret != '\0'){
+               *error_out = "Failed to parse memory increment";
                goto out;
+       }
 
        diff /= PAGE_SIZE;
 
+       down(&plug_mem_mutex);
        for(i = 0; i < diff; i++){
                struct unplugged_pages *unplugged;
                void *addr;
@@ -435,11 +445,14 @@ static int mem_config(char *str)
                                unplugged = list_entry(entry,
                                                       struct unplugged_pages,
                                                       list);
-                               unplugged->pages[unplug_index++] = addr;
                                err = os_drop_memory(addr, PAGE_SIZE);
-                               if(err)
+                               if(err){
                                        printk("Failed to release memory - "
                                               "errno = %d\n", err);
+                                       *error_out = "Failed to release memory";
+                                       goto out_unlock;
+                               }
+                               unplugged->pages[unplug_index++] = addr;
                        }
 
                        unplugged_pages_count++;
@@ -447,6 +460,8 @@ static int mem_config(char *str)
        }
 
        err = 0;
+out_unlock:
+       up(&plug_mem_mutex);
 out:
        return err;
 }
@@ -470,12 +485,14 @@ static int mem_id(char **str, int *start_out, int *end_out)
        return 0;
 }
 
-static int mem_remove(int n)
+static int mem_remove(int n, char **error_out)
 {
+       *error_out = "Memory doesn't support the remove operation";
        return -EBUSY;
 }
 
 static struct mc_device mem_mc = {
+       .list           = LIST_HEAD_INIT(mem_mc.list),
        .name           = "mem",
        .config         = mem_config,
        .get_config     = mem_get_config,
@@ -542,7 +559,7 @@ static void mconsole_get_config(int (*get_config)(char *, char *, int,
 void mconsole_config(struct mc_request *req)
 {
        struct mc_device *dev;
-       char *ptr = req->request.data, *name;
+       char *ptr = req->request.data, *name, *error_string = "";
        int err;
 
        ptr += strlen("config");
@@ -559,8 +576,8 @@ void mconsole_config(struct mc_request *req)
                ptr++;
 
        if(*ptr == '='){
-               err = (*dev->config)(name);
-               mconsole_reply(req, "", err, 0);
+               err = (*dev->config)(name, &error_string);
+               mconsole_reply(req, error_string, err, 0);
        }
        else mconsole_get_config(dev->get_config, req, name);
 }
@@ -595,13 +612,16 @@ void mconsole_remove(struct mc_request *req)
                goto out;
        }
 
-       err = (*dev->remove)(n);
+       err_msg = NULL;
+       err = (*dev->remove)(n, &err_msg);
        switch(err){
        case -ENODEV:
-               err_msg = "Device doesn't exist";
+               if(err_msg == NULL)
+                       err_msg = "Device doesn't exist";
                break;
        case -EBUSY:
-               err_msg = "Device is currently open";
+               if(err_msg == NULL)
+                       err_msg = "Device is currently open";
                break;
        default:
                break;
@@ -615,7 +635,7 @@ struct mconsole_output {
        struct mc_request *req;
 };
 
-static DEFINE_SPINLOCK(console_lock);
+static DEFINE_SPINLOCK(client_lock);
 static LIST_HEAD(clients);
 static char console_buf[MCONSOLE_MAX_DATA];
 static int console_index = 0;
@@ -670,16 +690,18 @@ static void with_console(struct mc_request *req, void (*proc)(void *),
        unsigned long flags;
 
        entry.req = req;
+       spin_lock_irqsave(&client_lock, flags);
        list_add(&entry.list, &clients);
-       spin_lock_irqsave(&console_lock, flags);
+       spin_unlock_irqrestore(&client_lock, flags);
 
        (*proc)(arg);
 
        mconsole_reply_len(req, console_buf, console_index, 0, 0);
        console_index = 0;
 
-       spin_unlock_irqrestore(&console_lock, flags);
+       spin_lock_irqsave(&client_lock, flags);
        list_del(&entry.list);
+       spin_unlock_irqrestore(&client_lock, flags);
 }
 
 #ifdef CONFIG_MAGIC_SYSRQ
index 75aef6f7ef6e22dd9669f55f707021cd4f539d10..f02634fbf32ad0e95be61d11c7d911f11a318cd0 100644 (file)
@@ -16,7 +16,7 @@
 #include "user.h"
 #include "sysdep/ptrace.h"
 #include "mconsole.h"
-#include "umid.h"
+#include "os.h"
 #include "user_util.h"
 
 static struct mconsole_command commands[] = {
index afe3d427ddfae510b29135453dcfa3217252c308..04e31f86c10afb88f21002b7b0eb8c261e3490a9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and 
+ * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and
  * James Leu (jleu@mindspring.net).
  * Copyright (C) 2001 by various other people who didn't put their name here.
  * Licensed under the GPL.
@@ -91,8 +91,8 @@ irqreturn_t uml_net_interrupt(int irq, void *dev_id)
        spin_lock(&lp->lock);
        while((err = uml_net_rx(dev)) > 0) ;
        if(err < 0) {
-               printk(KERN_ERR 
-                      "Device '%s' read returned %d, shutting it down\n", 
+               printk(KERN_ERR
+                      "Device '%s' read returned %d, shutting it down\n",
                       dev->name, err);
                /* dev_close can't be called in interrupt context, and takes
                 * again lp->lock.
@@ -108,7 +108,7 @@ irqreturn_t uml_net_interrupt(int irq, void *dev_id)
 
 out:
        spin_unlock(&lp->lock);
-       return(IRQ_HANDLED);
+       return IRQ_HANDLED;
 }
 
 static int uml_net_open(struct net_device *dev)
@@ -159,7 +159,7 @@ out:
 static int uml_net_close(struct net_device *dev)
 {
        struct uml_net_private *lp = dev->priv;
-       
+
        netif_stop_queue(dev);
 
        free_irq(dev->irq, dev);
@@ -194,7 +194,7 @@ static int uml_net_start_xmit(struct sk_buff *skb, struct net_device *dev)
 
                /* this is normally done in the interrupt when tx finishes */
                netif_wake_queue(dev);
-       } 
+       }
        else if(len == 0){
                netif_start_queue(dev);
                lp->stats.tx_dropped++;
@@ -239,7 +239,7 @@ static int uml_net_set_mac(struct net_device *dev, void *addr)
        set_ether_mac(dev, hwaddr->sa_data);
        spin_unlock_irq(&lp->lock);
 
-       return(0);
+       return 0;
 }
 
 static int uml_net_change_mtu(struct net_device *dev, int new_mtu)
@@ -333,7 +333,7 @@ static int eth_configure(int n, void *init, char *mac,
        struct uml_net_private *lp;
        int save, err, size;
 
-       size = transport->private_size + sizeof(struct uml_net_private) + 
+       size = transport->private_size + sizeof(struct uml_net_private) +
                sizeof(((struct uml_net_private *) 0)->user);
 
        device = kzalloc(sizeof(*device), GFP_KERNEL);
@@ -438,7 +438,7 @@ static int eth_configure(int n, void *init, char *mac,
        lp->tl.function = uml_net_user_timer_expire;
        memcpy(lp->mac, device->mac, sizeof(lp->mac));
 
-       if (transport->user->init) 
+       if (transport->user->init)
                (*transport->user->init)(&lp->user, dev);
 
        set_ether_mac(dev, device->mac);
@@ -460,38 +460,36 @@ static struct uml_net *find_device(int n)
        device = NULL;
  out:
        spin_unlock(&devices_lock);
-       return(device);
+       return device;
 }
 
-static int eth_parse(char *str, int *index_out, char **str_out)
+static int eth_parse(char *str, int *index_out, char **str_out,
+                    char **error_out)
 {
        char *end;
-       int n;
+       int n, err = -EINVAL;;
 
        n = simple_strtoul(str, &end, 0);
        if(end == str){
-               printk(KERN_ERR "eth_setup: Failed to parse '%s'\n", str);
-               return(1);
-       }
-       if(n < 0){
-               printk(KERN_ERR "eth_setup: device %d is negative\n", n);
-               return(1);
+               *error_out = "Bad device number";
+               return err;
        }
+
        str = end;
        if(*str != '='){
-               printk(KERN_ERR 
-                      "eth_setup: expected '=' after device number\n");
-               return(1);
+               *error_out = "Expected '=' after device number";
+               return err;
        }
+
        str++;
        if(find_device(n)){
-               printk(KERN_ERR "eth_setup: Device %d already configured\n",
-                      n);
-               return(1);
+               *error_out = "Device already configured";
+               return err;
        }
-       if(index_out) *index_out = n;
+
+       *index_out = n;
        *str_out = str;
-       return(0);
+       return 0;
 }
 
 struct eth_init {
@@ -500,13 +498,11 @@ struct eth_init {
        int index;
 };
 
-/* Filled in at boot time.  Will need locking if the transports become
- * modular.
- */
-struct list_head transports = LIST_HEAD_INIT(transports);
+static DEFINE_SPINLOCK(transports_lock);
+static LIST_HEAD(transports);
 
 /* Filled in during early boot */
-struct list_head eth_cmd_line = LIST_HEAD_INIT(eth_cmd_line);
+static LIST_HEAD(eth_cmd_line);
 
 static int check_transport(struct transport *transport, char *eth, int n,
                           void **init_out, char **mac_out)
@@ -515,23 +511,23 @@ static int check_transport(struct transport *transport, char *eth, int n,
 
        len = strlen(transport->name);
        if(strncmp(eth, transport->name, len))
-               return(0);
+               return 0;
 
        eth += len;
        if(*eth == ',')
                eth++;
        else if(*eth != '\0')
-               return(0);
+               return 0;
 
        *init_out = kmalloc(transport->setup_size, GFP_KERNEL);
        if(*init_out == NULL)
-               return(1);
+               return 1;
 
        if(!transport->setup(eth, mac_out, *init_out)){
                kfree(*init_out);
                *init_out = NULL;
        }
-       return(1);
+       return 1;
 }
 
 void register_transport(struct transport *new)
@@ -542,7 +538,10 @@ void register_transport(struct transport *new)
        char *mac = NULL;
        int match;
 
+       spin_lock(&transports_lock);
+       BUG_ON(!list_empty(&new->list));
        list_add(&new->list, &transports);
+       spin_unlock(&transports_lock);
 
        list_for_each_safe(ele, next, &eth_cmd_line){
                eth = list_entry(ele, struct eth_init, list);
@@ -564,7 +563,9 @@ static int eth_setup_common(char *str, int index)
        struct transport *transport;
        void *init;
        char *mac = NULL;
+       int found = 0;
 
+       spin_lock(&transports_lock);
        list_for_each(ele, &transports){
                transport = list_entry(ele, struct transport, list);
                if(!check_transport(transport, str, index, &init, &mac))
@@ -573,19 +574,26 @@ static int eth_setup_common(char *str, int index)
                        eth_configure(index, init, mac, transport);
                        kfree(init);
                }
-               return(1);
+               found = 1;
+               break;
        }
-       return(0);
+
+       spin_unlock(&transports_lock);
+       return found;
 }
 
 static int eth_setup(char *str)
 {
        struct eth_init *new;
+       char *error;
        int n, err;
 
-       err = eth_parse(str, &n, &str);
-       if(err)
+       err = eth_parse(str, &n, &str, &error);
+       if(err){
+               printk(KERN_ERR "eth_setup - Couldn't parse '%s' : %s\n",
+                      str, error);
                return 1;
+       }
 
        new = alloc_bootmem(sizeof(*new));
        if (new == NULL){
@@ -607,38 +615,24 @@ __uml_help(eth_setup,
 "    Configure a network device.\n\n"
 );
 
-#if 0
-static int eth_init(void)
-{
-       struct list_head *ele, *next;
-       struct eth_init *eth;
-
-       list_for_each_safe(ele, next, &eth_cmd_line){
-               eth = list_entry(ele, struct eth_init, list);
-
-               if(eth_setup_common(eth->init, eth->index))
-                       list_del(&eth->list);
-       }
-       
-       return(1);
-}
-__initcall(eth_init);
-#endif
-
-static int net_config(char *str)
+static int net_config(char *str, char **error_out)
 {
        int n, err;
 
-       err = eth_parse(str, &n, &str);
-       if(err) return(err);
+       err = eth_parse(str, &n, &str, error_out);
+       if(err)
+               return err;
 
+       /* This string is broken up and the pieces used by the underlying
+        * driver.  So, it is freed only if eth_setup_common fails.
+        */
        str = kstrdup(str, GFP_KERNEL);
        if(str == NULL){
-               printk(KERN_ERR "net_config failed to strdup string\n");
-               return(-1);
+               *error_out = "net_config failed to strdup string";
+               return -ENOMEM;
        }
        err = !eth_setup_common(str, n);
-       if(err) 
+       if(err)
                kfree(str);
        return(err);
 }
@@ -658,7 +652,7 @@ static int net_id(char **str, int *start_out, int *end_out)
         return n;
 }
 
-static int net_remove(int n)
+static int net_remove(int n, char **error_out)
 {
        struct uml_net *device;
        struct net_device *dev;
@@ -671,7 +665,7 @@ static int net_remove(int n)
        dev = device->dev;
        lp = dev->priv;
        if(lp->fd > 0)
-                return -EBUSY;
+               return -EBUSY;
        if(lp->remove != NULL) (*lp->remove)(&lp->user);
        unregister_netdev(dev);
        platform_device_unregister(&device->pdev);
@@ -683,10 +677,11 @@ static int net_remove(int n)
 }
 
 static struct mc_device net_mc = {
+       .list           = LIST_HEAD_INIT(net_mc.list),
        .name           = "eth",
        .config         = net_config,
        .get_config     = NULL,
-        .id            = net_id,
+       .id             = net_id,
        .remove         = net_remove,
 };
 
@@ -699,7 +694,8 @@ static int uml_inetaddr_event(struct notifier_block *this, unsigned long event,
        void (*proc)(unsigned char *, unsigned char *, void *);
        unsigned char addr_buf[4], netmask_buf[4];
 
-       if(dev->open != uml_net_open) return(NOTIFY_DONE);
+       if(dev->open != uml_net_open)
+               return NOTIFY_DONE;
 
        lp = dev->priv;
 
@@ -717,9 +713,10 @@ static int uml_inetaddr_event(struct notifier_block *this, unsigned long event,
                memcpy(netmask_buf, &ifa->ifa_mask, sizeof(netmask_buf));
                (*proc)(addr_buf, netmask_buf, &lp->user);
        }
-       return(NOTIFY_DONE);
+       return NOTIFY_DONE;
 }
 
+/* uml_net_init shouldn't be called twice on two CPUs at the same time */
 struct notifier_block uml_inetaddr_notifier = {
        .notifier_call          = uml_inetaddr_event,
 };
@@ -727,7 +724,7 @@ struct notifier_block uml_inetaddr_notifier = {
 static int uml_net_init(void)
 {
        struct list_head *ele;
-       struct uml_net_private *lp;     
+       struct uml_net_private *lp;
        struct in_device *ip;
        struct in_ifaddr *in;
 
@@ -738,18 +735,21 @@ static int uml_net_init(void)
         * didn't get a chance to run for them.  This fakes it so that
         * addresses which have already been set up get handled properly.
         */
+       spin_lock(&opened_lock);
        list_for_each(ele, &opened){
                lp = list_entry(ele, struct uml_net_private, list);
                ip = lp->dev->ip_ptr;
-               if(ip == NULL) continue;
+               if(ip == NULL)
+                       continue;
                in = ip->ifa_list;
                while(in != NULL){
                        uml_inetaddr_event(NULL, NETDEV_UP, in);
                        in = in->ifa_next;
                }
-       }       
+       }
+       spin_unlock(&opened_lock);
 
-       return(0);
+       return 0;
 }
 
 __initcall(uml_net_init);
@@ -759,13 +759,16 @@ static void close_devices(void)
        struct list_head *ele;
        struct uml_net_private *lp;
 
+       spin_lock(&opened_lock);
        list_for_each(ele, &opened){
                lp = list_entry(ele, struct uml_net_private, list);
                free_irq(lp->dev->irq, lp->dev);
                if((lp->close != NULL) && (lp->fd >= 0))
                        (*lp->close)(lp->fd, &lp->user);
-               if(lp->remove != NULL) (*lp->remove)(&lp->user);
+               if(lp->remove != NULL)
+                       (*lp->remove)(&lp->user);
        }
+       spin_unlock(&opened_lock);
 }
 
 __uml_exitcall(close_devices);
@@ -783,8 +786,8 @@ struct sk_buff *ether_adjust_skb(struct sk_buff *skb, int extra)
        return(skb);
 }
 
-void iter_addresses(void *d, void (*cb)(unsigned char *, unsigned char *, 
-                                       void *), 
+void iter_addresses(void *d, void (*cb)(unsigned char *, unsigned char *,
+                                       void *),
                    void *arg)
 {
        struct net_device *dev = d;
@@ -809,11 +812,11 @@ int dev_netmask(void *d, void *m)
        struct in_ifaddr *in;
        __be32 *mask_out = m;
 
-       if(ip == NULL) 
+       if(ip == NULL)
                return(1);
 
        in = ip->ifa_list;
-       if(in == NULL) 
+       if(in == NULL)
                return(1);
 
        *mask_out = in->ifa_mask;
@@ -827,7 +830,7 @@ void *get_output_buffer(int *len_out)
        ret = (void *) __get_free_pages(GFP_KERNEL, 0);
        if(ret) *len_out = PAGE_SIZE;
        else *len_out = 0;
-       return(ret);
+       return ret;
 }
 
 void free_output_buffer(void *buffer)
@@ -835,7 +838,7 @@ void free_output_buffer(void *buffer)
        free_pages((unsigned long) buffer, 0);
 }
 
-int tap_setup_common(char *str, char *type, char **dev_name, char **mac_out, 
+int tap_setup_common(char *str, char *type, char **dev_name, char **mac_out,
                     char **gate_addr)
 {
        char *remain;
@@ -854,14 +857,3 @@ unsigned short eth_protocol(struct sk_buff *skb)
 {
        return(eth_type_trans(skb, skb->dev));
 }
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
index 6dfe632f1c14d9a64ebc9a279a65025eefba2ac7..1c8efd95c421946ab5e7e56db518395c1847378b 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
  * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
  * Licensed under the GPL
  */
@@ -55,9 +55,9 @@ static irqreturn_t pipe_interrupt(int irq, void *data)
        fd = os_rcv_fd(conn->socket[0], &conn->helper_pid);
        if(fd < 0){
                if(fd == -EAGAIN)
-                       return(IRQ_NONE);
+                       return IRQ_NONE;
 
-               printk(KERN_ERR "pipe_interrupt : os_rcv_fd returned %d\n", 
+               printk(KERN_ERR "pipe_interrupt : os_rcv_fd returned %d\n",
                       -fd);
                os_close_file(conn->fd);
        }
@@ -68,7 +68,7 @@ static irqreturn_t pipe_interrupt(int irq, void *data)
        list_add(&conn->list, &conn->port->connections);
 
        complete(&conn->port->done);
-       return(IRQ_HANDLED);
+       return IRQ_HANDLED;
 }
 
 #define NO_WAITER_MSG \
@@ -97,14 +97,14 @@ static int port_accept(struct port_list *port)
                       "connection\n");
                goto out_close;
        }
-       *conn = ((struct connection) 
+       *conn = ((struct connection)
                { .list         = LIST_HEAD_INIT(conn->list),
                  .fd           = fd,
                  .socket       = { socket[0], socket[1] },
                  .telnetd_pid  = pid,
                  .port         = port });
 
-       if(um_request_irq(TELNETD_IRQ, socket[0], IRQ_READ, pipe_interrupt, 
+       if(um_request_irq(TELNETD_IRQ, socket[0], IRQ_READ, pipe_interrupt,
                          IRQF_DISABLED | IRQF_SHARED | IRQF_SAMPLE_RANDOM,
                          "telnetd", conn)){
                printk(KERN_ERR "port_accept : failed to get IRQ for "
@@ -117,20 +117,20 @@ static int port_accept(struct port_list *port)
                printk("No one waiting for port\n");
        }
        list_add(&conn->list, &port->pending);
-       return(1);
+       return 1;
 
  out_free:
        kfree(conn);
  out_close:
        os_close_file(fd);
-       if(pid != -1) 
+       if(pid != -1)
                os_kill_process(pid, 1);
  out:
-       return(ret);
-} 
+       return ret;
+}
 
-DECLARE_MUTEX(ports_sem);
-struct list_head ports = LIST_HEAD_INIT(ports);
+static DECLARE_MUTEX(ports_sem);
+static LIST_HEAD(ports);
 
 void port_work_proc(struct work_struct *unused)
 {
@@ -158,8 +158,8 @@ static irqreturn_t port_interrupt(int irq, void *data)
 
        port->has_connection = 1;
        schedule_work(&port_work);
-       return(IRQ_HANDLED);
-} 
+       return IRQ_HANDLED;
+}
 
 void *port_data(int port_num)
 {
@@ -185,14 +185,14 @@ void *port_data(int port_num)
                       port_num, -fd);
                goto out_free;
        }
-       if(um_request_irq(ACCEPT_IRQ, fd, IRQ_READ, port_interrupt, 
-                         IRQF_DISABLED | IRQF_SHARED | IRQF_SAMPLE_RANDOM, "port",
-                         port)){
+       if(um_request_irq(ACCEPT_IRQ, fd, IRQ_READ, port_interrupt,
+                         IRQF_DISABLED | IRQF_SHARED | IRQF_SAMPLE_RANDOM,
+                         "port", port)){
                printk(KERN_ERR "Failed to get IRQ for port %d\n", port_num);
                goto out_close;
        }
 
-       *port = ((struct port_list) 
+       *port = ((struct port_list)
                { .list                 = LIST_HEAD_INIT(port->list),
                  .wait_count           = ATOMIC_INIT(0),
                  .has_connection       = 0,
@@ -222,7 +222,7 @@ void *port_data(int port_num)
        os_close_file(fd);
  out:
        up(&ports_sem);
-       return(dev);
+       return dev;
 }
 
 int port_wait(void *data)
@@ -232,15 +232,15 @@ int port_wait(void *data)
        struct port_list *port = dev->port;
        int fd;
 
-        atomic_inc(&port->wait_count);
+       atomic_inc(&port->wait_count);
        while(1){
                fd = -ERESTARTSYS;
-                if(wait_for_completion_interruptible(&port->done))
-                        goto out;
+               if(wait_for_completion_interruptible(&port->done))
+                       goto out;
 
                spin_lock(&port->lock);
 
-               conn = list_entry(port->connections.next, struct connection, 
+               conn = list_entry(port->connections.next, struct connection,
                                  list);
                list_del(&conn->list);
                spin_unlock(&port->lock);
@@ -248,12 +248,12 @@ int port_wait(void *data)
                os_shutdown_socket(conn->socket[0], 1, 1);
                os_close_file(conn->socket[0]);
                os_shutdown_socket(conn->socket[1], 1, 1);
-               os_close_file(conn->socket[1]); 
+               os_close_file(conn->socket[1]);
 
                /* This is done here because freeing an IRQ can't be done
                 * within the IRQ handler.  So, pipe_interrupt always ups
                 * the semaphore regardless of whether it got a successful
-                * connection.  Then we loop here throwing out failed 
+                * connection.  Then we loop here throwing out failed
                 * connections until a good one is found.
                 */
                free_irq(TELNETD_IRQ, conn);
index bc6afaf74c1a8123ace69f94c5d2d9a340bc6347..80508023054f27bfc493827eeb3e53cbc864f7b0 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
  * Copyright (C) 2001 Jeff Dike (jdike@karaya.com)
  * Licensed under the GPL
  */
@@ -38,18 +38,18 @@ static void *port_init(char *str, int device, const struct chan_opts *opts)
        if(*str != ':'){
                printk("port_init : channel type 'port' must specify a "
                       "port number\n");
-               return(NULL);
+               return NULL;
        }
        str++;
        port = strtoul(str, &end, 0);
        if((*end != '\0') || (end == str)){
                printk("port_init : couldn't parse port '%s'\n", str);
-               return(NULL);
+               return NULL;
        }
 
        kern_data = port_data(port);
        if(kern_data == NULL)
-               return(NULL);
+               return NULL;
 
        data = um_kmalloc(sizeof(*data));
        if(data == NULL)
@@ -59,10 +59,10 @@ static void *port_init(char *str, int device, const struct chan_opts *opts)
                                      .kernel_data      = kern_data });
        sprintf(data->dev, "%d", port);
 
-       return(data);
+       return data;
  err:
        port_kern_free(kern_data);
-       return(NULL);
+       return NULL;
 }
 
 static void port_free(void *d)
@@ -83,14 +83,14 @@ static int port_open(int input, int output, int primary, void *d,
        if((fd >= 0) && data->raw){
                CATCH_EINTR(err = tcgetattr(fd, &data->tt));
                if(err)
-                       return(err);
+                       return err;
 
                err = raw(fd);
                if(err)
-                       return(err);
+                       return err;
        }
        *dev_out = data->dev;
-       return(fd);
+       return fd;
 }
 
 static void port_close(int fd, void *d)
@@ -120,8 +120,8 @@ int port_listen_fd(int port)
        int fd, err, arg;
 
        fd = socket(PF_INET, SOCK_STREAM, 0);
-       if(fd == -1) 
-               return(-errno);
+       if(fd == -1)
+               return -errno;
 
        arg = 1;
        if(setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &arg, sizeof(arg)) < 0){
@@ -136,7 +136,7 @@ int port_listen_fd(int port)
                err = -errno;
                goto out;
        }
-  
+
        if(listen(fd, 1) < 0){
                err = -errno;
                goto out;
@@ -146,10 +146,10 @@ int port_listen_fd(int port)
        if(err < 0)
                goto out;
 
-       return(fd);
+       return fd;
  out:
        os_close_file(fd);
-       return(err);
+       return err;
 }
 
 struct port_pre_exec_data {
@@ -173,13 +173,13 @@ void port_pre_exec(void *arg)
 int port_connection(int fd, int *socket, int *pid_out)
 {
        int new, err;
-       char *argv[] = { "/usr/sbin/in.telnetd", "-L", 
+       char *argv[] = { "/usr/sbin/in.telnetd", "-L",
                         "/usr/lib/uml/port-helper", NULL };
        struct port_pre_exec_data data;
 
        new = os_accept_connection(fd);
        if(new < 0)
-               return(new);
+               return new;
 
        err = os_pipe(socket, 0, 0);
        if(err < 0)
@@ -190,29 +190,18 @@ int port_connection(int fd, int *socket, int *pid_out)
                  .pipe_fd              = socket[1] });
 
        err = run_helper(port_pre_exec, &data, argv, NULL);
-       if(err < 0) 
+       if(err < 0)
                goto out_shutdown;
 
        *pid_out = err;
-       return(new);
+       return new;
 
  out_shutdown:
        os_shutdown_socket(socket[0], 1, 1);
        os_close_file(socket[0]);
-       os_shutdown_socket(socket[1], 1, 1);    
+       os_shutdown_socket(socket[1], 1, 1);
        os_close_file(socket[1]);
  out_close:
        os_close_file(new);
-       return(err);
+       return err;
 }
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
index 73b2bdd6d2d3b867165e116b7a1b430f34096c9b..e942e836f9954335651fc3c2b6587c2bd7d7e888 100644 (file)
@@ -78,6 +78,7 @@ static const struct file_operations rng_chrdev_ops = {
        .read           = rng_dev_read,
 };
 
+/* rng_init shouldn't be called more than once at boot time */
 static struct miscdevice rng_miscdev = {
        RNG_MISCDEV_MINOR,
        RNG_MODULE_NAME,
index ed9c59082d0df56806248e7928d4a953d524d15e..fc22b9bd91530548a72cd0b6aad1afde5b00d3e6 100644 (file)
@@ -38,6 +38,7 @@ static void ssl_announce(char *dev_name, int dev)
               dev_name);
 }
 
+/* Almost const, except that xterm_title may be changed in an initcall */
 static struct chan_opts opts = {
        .announce       = ssl_announce,
        .xterm_title    = "Serial Line #%d",
@@ -46,10 +47,12 @@ static struct chan_opts opts = {
        .in_kernel      = 1,
 };
 
-static int ssl_config(char *str);
+static int ssl_config(char *str, char **error_out);
 static int ssl_get_config(char *dev, char *str, int size, char **error_out);
-static int ssl_remove(int n);
+static int ssl_remove(int n, char **error_out);
 
+
+/* Const, except for .mc.list */
 static struct line_driver driver = {
        .name                   = "UML serial line",
        .device_name            = "ttyS",
@@ -61,9 +64,8 @@ static struct line_driver driver = {
        .read_irq_name          = "ssl",
        .write_irq              = SSL_WRITE_IRQ,
        .write_irq_name         = "ssl-write",
-       .symlink_from           = "serial",
-       .symlink_to             = "tts",
        .mc  = {
+               .list           = LIST_HEAD_INIT(driver.mc.list),
                .name           = "ssl",
                .config         = ssl_config,
                .get_config     = ssl_get_config,
@@ -72,17 +74,16 @@ static struct line_driver driver = {
        },
 };
 
-/* The array is initialized by line_init, which is an initcall.  The 
- * individual elements are protected by individual semaphores.
+/* The array is initialized by line_init, at initcall time.  The
+ * elements are locked individually as needed.
  */
 static struct line serial_lines[NR_PORTS] =
        { [0 ... NR_PORTS - 1] = LINE_INIT(CONFIG_SSL_CHAN, &driver) };
 
-static struct lines lines = LINES_INIT(NR_PORTS);
-
-static int ssl_config(char *str)
+static int ssl_config(char *str, char **error_out)
 {
-       return line_config(serial_lines, ARRAY_SIZE(serial_lines), str, &opts);
+       return line_config(serial_lines, ARRAY_SIZE(serial_lines), str, &opts,
+                          error_out);
 }
 
 static int ssl_get_config(char *dev, char *str, int size, char **error_out)
@@ -91,9 +92,10 @@ static int ssl_get_config(char *dev, char *str, int size, char **error_out)
                               size, error_out);
 }
 
-static int ssl_remove(int n)
+static int ssl_remove(int n, char **error_out)
 {
-       return line_remove(serial_lines, ARRAY_SIZE(serial_lines), n);
+       return line_remove(serial_lines, ARRAY_SIZE(serial_lines), n,
+                          error_out);
 }
 
 static int ssl_open(struct tty_struct *tty, struct file *filp)
@@ -168,9 +170,10 @@ static int ssl_console_setup(struct console *co, char *options)
 {
        struct line *line = &serial_lines[co->index];
 
-       return console_open_chan(line, co, &opts);
+       return console_open_chan(line, co);
 }
 
+/* No locking for register_console call - relies on single-threaded initcalls */
 static struct console ssl_cons = {
        .name           = "ttyS",
        .write          = ssl_console_write,
@@ -186,9 +189,8 @@ static int ssl_init(void)
 
        printk(KERN_INFO "Initializing software serial port version %d\n",
               ssl_version);
-       ssl_driver = line_register_devfs(&lines, &driver, &ssl_ops,
-                                        serial_lines,
-                                        ARRAY_SIZE(serial_lines));
+       ssl_driver = register_lines(&driver, &ssl_ops, serial_lines,
+                                   ARRAY_SIZE(serial_lines));
 
        lines_init(serial_lines, ARRAY_SIZE(serial_lines), &opts);
 
@@ -212,7 +214,15 @@ __uml_exitcall(ssl_exit);
 
 static int ssl_chan_setup(char *str)
 {
-       return line_setup(serial_lines, ARRAY_SIZE(serial_lines), str);
+       char *error;
+       int ret;
+
+       ret = line_setup(serial_lines, ARRAY_SIZE(serial_lines), str, &error);
+       if(ret < 0)
+               printk(KERN_ERR "Failed to set up serial line with "
+                      "configuration string \"%s\" : %s\n", str, error);
+
+       return 1;
 }
 
 __setup("ssl", ssl_chan_setup);
index 7a4897e27f42784054bb674fb29e8664f17a5af9..7ff0b0fc37e73eff2875fe4ae0db633570181b66 100644 (file)
@@ -30,8 +30,6 @@
 
 #define MAX_TTYS (16)
 
-/* ----------------------------------------------------------------------------- */
-
 /* Referenced only by tty_driver below - presumably it's locked correctly
  * by the tty driver.
  */
@@ -44,6 +42,7 @@ void stdio_announce(char *dev_name, int dev)
               dev_name);
 }
 
+/* Almost const, except that xterm_title may be changed in an initcall */
 static struct chan_opts opts = {
        .announce       = stdio_announce,
        .xterm_title    = "Virtual Console #%d",
@@ -52,10 +51,12 @@ static struct chan_opts opts = {
        .in_kernel      = 1,
 };
 
-static int con_config(char *str);
+static int con_config(char *str, char **error_out);
 static int con_get_config(char *dev, char *str, int size, char **error_out);
-static int con_remove(int n);
+static int con_remove(int n, char **con_remove);
+
 
+/* Const, except for .mc.list */
 static struct line_driver driver = {
        .name                   = "UML console",
        .device_name            = "tty",
@@ -67,9 +68,8 @@ static struct line_driver driver = {
        .read_irq_name          = "console",
        .write_irq              = CONSOLE_WRITE_IRQ,
        .write_irq_name         = "console-write",
-       .symlink_from           = "ttys",
-       .symlink_to             = "vc",
        .mc  = {
+               .list           = LIST_HEAD_INIT(driver.mc.list),
                .name           = "con",
                .config         = con_config,
                .get_config     = con_get_config,
@@ -78,18 +78,16 @@ static struct line_driver driver = {
        },
 };
 
-static struct lines console_lines = LINES_INIT(MAX_TTYS);
-
-/* The array is initialized by line_init, which is an initcall.  The 
- * individual elements are protected by individual semaphores.
+/* The array is initialized by line_init, at initcall time.  The
+ * elements are locked individually as needed.
  */
-struct line vts[MAX_TTYS] = { LINE_INIT(CONFIG_CON_ZERO_CHAN, &driver),
-                             [ 1 ... MAX_TTYS - 1 ] =
-                             LINE_INIT(CONFIG_CON_CHAN, &driver) };
+static struct line vts[MAX_TTYS] = { LINE_INIT(CONFIG_CON_ZERO_CHAN, &driver),
+                                    [ 1 ... MAX_TTYS - 1 ] =
+                                    LINE_INIT(CONFIG_CON_CHAN, &driver) };
 
-static int con_config(char *str)
+static int con_config(char *str, char **error_out)
 {
-       return line_config(vts, ARRAY_SIZE(vts), str, &opts);
+       return line_config(vts, ARRAY_SIZE(vts), str, &opts, error_out);
 }
 
 static int con_get_config(char *dev, char *str, int size, char **error_out)
@@ -97,9 +95,9 @@ static int con_get_config(char *dev, char *str, int size, char **error_out)
        return line_get_config(dev, vts, ARRAY_SIZE(vts), str, size, error_out);
 }
 
-static int con_remove(int n)
+static int con_remove(int n, char **error_out)
 {
-       return line_remove(vts, ARRAY_SIZE(vts), n);
+       return line_remove(vts, ARRAY_SIZE(vts), n, error_out);
 }
 
 static int con_open(struct tty_struct *tty, struct file *filp)
@@ -146,9 +144,10 @@ static int uml_console_setup(struct console *co, char *options)
 {
        struct line *line = &vts[co->index];
 
-       return console_open_chan(line, co, &opts);
+       return console_open_chan(line, co);
 }
 
+/* No locking for register_console call - relies on single-threaded initcalls */
 static struct console stdiocons = {
        .name           = "tty",
        .write          = uml_console_write,
@@ -156,16 +155,14 @@ static struct console stdiocons = {
        .setup          = uml_console_setup,
        .flags          = CON_PRINTBUFFER,
        .index          = -1,
-       .data           = &vts,
 };
 
 int stdio_init(void)
 {
        char *new_title;
 
-       console_driver = line_register_devfs(&console_lines, &driver,
-                                            &console_ops, vts,
-                                            ARRAY_SIZE(vts));
+       console_driver = register_lines(&driver, &console_ops, vts,
+                                       ARRAY_SIZE(vts));
        if (console_driver == NULL)
                return -1;
        printk(KERN_INFO "Initialized stdio console driver\n");
@@ -192,7 +189,15 @@ __uml_exitcall(console_exit);
 
 static int console_chan_setup(char *str)
 {
-       return line_setup(vts, ARRAY_SIZE(vts), str);
+       char *error;
+       int ret;
+
+       ret = line_setup(vts, ARRAY_SIZE(vts), str, &error);
+       if(ret < 0)
+               printk(KERN_ERR "Failed to set up console with "
+                      "configuration string \"%s\" : %s\n", str, error);
+
+       return 1;
 }
 __setup("con", console_chan_setup);
 __channel_help(console_chan_setup, "con");
index 49c047b75cc556cbda484a5c6166d23d5b137f7c..f98d26e513813483dc27681ce75f180e7566f4ae 100644 (file)
@@ -56,6 +56,7 @@
 enum ubd_req { UBD_READ, UBD_WRITE };
 
 struct io_thread_req {
+       struct request *req;
        enum ubd_req op;
        int fds[2];
        unsigned long offsets[2];
@@ -106,10 +107,6 @@ static inline void ubd_set_bit(__u64 bit, unsigned char *data)
 
 #define DRIVER_NAME "uml-blkdev"
 
-/* Can be taken in interrupt context, and is passed to the block layer to lock
- * the request queue. Kernel side code knows that. */
-static DEFINE_SPINLOCK(ubd_io_lock);
-
 static DEFINE_MUTEX(ubd_lock);
 
 /* XXX - this made sense in 2.4 days, now it's only used as a boolean, and
@@ -132,12 +129,8 @@ static struct block_device_operations ubd_blops = {
        .getgeo         = ubd_getgeo,
 };
 
-/* Protected by the queue_lock */
-static request_queue_t *ubd_queue;
-
 /* Protected by ubd_lock */
 static int fake_major = MAJOR_NR;
-
 static struct gendisk *ubd_gendisk[MAX_DEV];
 static struct gendisk *fake_gendisk[MAX_DEV];
 
@@ -148,10 +141,6 @@ static struct gendisk *fake_gendisk[MAX_DEV];
 #define OPEN_FLAGS ((struct openflags) { .r = 1, .w = 1, .s = 0, .c = 0, \
                                         .cl = 1 })
 #endif
-
-/* Not protected - changed only in ubd_setup_common and then only to
- * to enable O_SYNC.
- */
 static struct openflags global_openflags = OPEN_FLAGS;
 
 struct cow {
@@ -178,6 +167,8 @@ struct ubd {
        unsigned no_cow:1;
        struct cow cow;
        struct platform_device pdev;
+       struct request_queue *queue;
+       spinlock_t lock;
 };
 
 #define DEFAULT_COW { \
@@ -198,8 +189,10 @@ struct ubd {
         .no_cow =               0, \
        .shared =               0, \
         .cow =                 DEFAULT_COW, \
+       .lock =                 SPIN_LOCK_UNLOCKED,     \
 }
 
+/* Protected by ubd_lock */
 struct ubd ubd_devs[MAX_DEV] = { [ 0 ... MAX_DEV - 1 ] = DEFAULT_UBD };
 
 /* Only changed by fake_ide_setup which is a setup */
@@ -242,7 +235,6 @@ static void make_ide_entries(char *dev_name)
 
        ent = create_proc_entry("media", S_IFREG|S_IRUGO, dir);
        if(!ent) return;
-       ent->nlink = 1;
        ent->data = NULL;
        ent->read_proc = proc_ide_read_media;
        ent->write_proc = NULL;
@@ -286,12 +278,12 @@ static int parse_unit(char **ptr)
  * otherwise, the str pointer is used (and owned) inside ubd_devs array, so it
  * should not be freed on exit.
  */
-static int ubd_setup_common(char *str, int *index_out)
+static int ubd_setup_common(char *str, int *index_out, char **error_out)
 {
        struct ubd *ubd_dev;
        struct openflags flags = global_openflags;
        char *backing_file;
-       int n, err, i;
+       int n, err = 0, i;
 
        if(index_out) *index_out = -1;
        n = *str;
@@ -302,56 +294,55 @@ static int ubd_setup_common(char *str, int *index_out)
                str++;
                if(!strcmp(str, "sync")){
                        global_openflags = of_sync(global_openflags);
-                       return(0);
+                       goto out1;
                }
+
+               err = -EINVAL;
                major = simple_strtoul(str, &end, 0);
                if((*end != '\0') || (end == str)){
-                       printk(KERN_ERR
-                              "ubd_setup : didn't parse major number\n");
-                       return(1);
+                       *error_out = "Didn't parse major number";
+                       goto out1;
                }
 
-               err = 1;
-               mutex_lock(&ubd_lock);
-               if(fake_major != MAJOR_NR){
-                       printk(KERN_ERR "Can't assign a fake major twice\n");
-                       goto out1;
-               }
+               mutex_lock(&ubd_lock);
+               if(fake_major != MAJOR_NR){
+                       *error_out = "Can't assign a fake major twice";
+                       goto out1;
+               }
 
-               fake_major = major;
+               fake_major = major;
 
                printk(KERN_INFO "Setting extra ubd major number to %d\n",
                       major);
-               err = 0;
-       out1:
-               mutex_unlock(&ubd_lock);
-               return(err);
+               err = 0;
+       out1:
+               mutex_unlock(&ubd_lock);
+               return err;
        }
 
        n = parse_unit(&str);
        if(n < 0){
-               printk(KERN_ERR "ubd_setup : couldn't parse unit number "
-                      "'%s'\n", str);
-               return(1);
+               *error_out = "Couldn't parse device number";
+               return -EINVAL;
        }
        if(n >= MAX_DEV){
-               printk(KERN_ERR "ubd_setup : index %d out of range "
-                      "(%d devices, from 0 to %d)\n", n, MAX_DEV, MAX_DEV - 1);
-               return(1);
+               *error_out = "Device number out of range";
+               return 1;
        }
 
-       err = 1;
+       err = -EBUSY;
        mutex_lock(&ubd_lock);
 
        ubd_dev = &ubd_devs[n];
        if(ubd_dev->file != NULL){
-               printk(KERN_ERR "ubd_setup : device already configured\n");
+               *error_out = "Device is already configured";
                goto out;
        }
 
        if (index_out)
                *index_out = n;
 
+       err = -EINVAL;
        for (i = 0; i < sizeof("rscd="); i++) {
                switch (*str) {
                case 'r':
@@ -370,47 +361,54 @@ static int ubd_setup_common(char *str, int *index_out)
                        str++;
                        goto break_loop;
                default:
-                       printk(KERN_ERR "ubd_setup : Expected '=' or flag letter (r, s, c, or d)\n");
+                       *error_out = "Expected '=' or flag letter "
+                               "(r, s, c, or d)";
                        goto out;
                }
                str++;
        }
 
-        if (*str == '=')
-               printk(KERN_ERR "ubd_setup : Too many flags specified\n");
-        else
-               printk(KERN_ERR "ubd_setup : Expected '='\n");
+       if (*str == '=')
+               *error_out = "Too many flags specified";
+       else
+               *error_out = "Missing '='";
        goto out;
 
 break_loop:
-       err = 0;
        backing_file = strchr(str, ',');
 
-       if (!backing_file) {
+       if (backing_file == NULL)
                backing_file = strchr(str, ':');
-       }
 
-       if(backing_file){
-               if(ubd_dev->no_cow)
-                       printk(KERN_ERR "Can't specify both 'd' and a "
-                              "cow file\n");
+       if(backing_file != NULL){
+               if(ubd_dev->no_cow){
+                       *error_out = "Can't specify both 'd' and a cow file";
+                       goto out;
+               }
                else {
                        *backing_file = '\0';
                        backing_file++;
                }
        }
+       err = 0;
        ubd_dev->file = str;
        ubd_dev->cow.file = backing_file;
        ubd_dev->boot_openflags = flags;
 out:
        mutex_unlock(&ubd_lock);
-       return(err);
+       return err;
 }
 
 static int ubd_setup(char *str)
 {
-       ubd_setup_common(str, NULL);
-       return(1);
+       char *error;
+       int err;
+
+       err = ubd_setup_common(str, NULL, &error);
+       if(err)
+               printk(KERN_ERR "Failed to initialize device with \"%s\" : "
+                      "%s\n", str, error);
+       return 1;
 }
 
 __setup("ubd", ubd_setup);
@@ -422,7 +420,7 @@ __uml_help(ubd_setup,
 "    use either a ':' or a ',': the first one allows writing things like;\n"
 "      ubd0=~/Uml/root_cow:~/Uml/root_backing_file\n"
 "    while with a ',' the shell would not expand the 2nd '~'.\n"
-"    When using only one filename, UML will detect whether to thread it like\n"
+"    When using only one filename, UML will detect whether to treat it like\n"
 "    a COW file or a backing file. To override this detection, add the 'd'\n"
 "    flag:\n"
 "      ubd0d=BackingFile\n"
@@ -471,12 +469,6 @@ static void do_ubd_request(request_queue_t * q);
 /* Only changed by ubd_init, which is an initcall. */
 int thread_fd = -1;
 
-/* Changed by ubd_handler, which is serialized because interrupts only
- * happen on CPU 0.
- * XXX: currently unused.
- */
-static int intr_count = 0;
-
 /* call ubd_finish if you need to serialize */
 static void __ubd_finish(struct request *req, int error)
 {
@@ -499,36 +491,38 @@ static void __ubd_finish(struct request *req, int error)
  * spin_lock_irq()/spin_lock_irqsave() */
 static inline void ubd_finish(struct request *req, int error)
 {
-       spin_lock(&ubd_io_lock);
+       struct ubd *dev = req->rq_disk->private_data;
+
+       spin_lock(&dev->lock);
        __ubd_finish(req, error);
-       spin_unlock(&ubd_io_lock);
+       spin_unlock(&dev->lock);
 }
 
 /* XXX - move this inside ubd_intr. */
-/* Called without ubd_io_lock held, and only in interrupt context. */
+/* Called without dev->lock held, and only in interrupt context. */
 static void ubd_handler(void)
 {
        struct io_thread_req req;
-       struct request *rq = elv_next_request(ubd_queue);
+       struct request *rq;
+       struct ubd *dev;
        int n;
 
        do_ubd = 0;
-       intr_count++;
        n = os_read_file(thread_fd, &req, sizeof(req));
        if(n != sizeof(req)){
                printk(KERN_ERR "Pid %d - spurious interrupt in ubd_handler, "
                       "err = %d\n", os_getpid(), -n);
-               spin_lock(&ubd_io_lock);
-               end_request(rq, 0);
-               spin_unlock(&ubd_io_lock);
                return;
        }
 
+       rq = req.req;
+       dev = rq->rq_disk->private_data;
+
        ubd_finish(rq, req.error);
-       reactivate_fd(thread_fd, UBD_IRQ);      
-       spin_lock(&ubd_io_lock);
-       do_ubd_request(ubd_queue);
-       spin_unlock(&ubd_io_lock);
+       reactivate_fd(thread_fd, UBD_IRQ);
+       spin_lock(&dev->lock);
+       do_ubd_request(dev->queue);
+       spin_unlock(&dev->lock);
 }
 
 static irqreturn_t ubd_intr(int irq, void *dev)
@@ -632,8 +626,7 @@ static int ubd_open_dev(struct ubd *ubd_dev)
 }
 
 static int ubd_disk_register(int major, u64 size, int unit,
-                       struct gendisk **disk_out)
-                       
+                            struct gendisk **disk_out)
 {
        struct gendisk *disk;
 
@@ -659,7 +652,7 @@ static int ubd_disk_register(int major, u64 size, int unit,
        }
 
        disk->private_data = &ubd_devs[unit];
-       disk->queue = ubd_queue;
+       disk->queue = ubd_devs[unit].queue;
        add_disk(disk);
 
        *disk_out = disk;
@@ -668,28 +661,39 @@ static int ubd_disk_register(int major, u64 size, int unit,
 
 #define ROUND_BLOCK(n) ((n + ((1 << 9) - 1)) & (-1 << 9))
 
-static int ubd_add(int n)
+static int ubd_add(int n, char **error_out)
 {
        struct ubd *ubd_dev = &ubd_devs[n];
-       int err;
+       int err = 0;
 
-       err = -ENODEV;
        if(ubd_dev->file == NULL)
                goto out;
 
        err = ubd_file_size(ubd_dev, &ubd_dev->size);
-       if(err < 0)
+       if(err < 0){
+               *error_out = "Couldn't determine size of device's file";
                goto out;
+       }
 
        ubd_dev->size = ROUND_BLOCK(ubd_dev->size);
 
-       err = ubd_disk_register(MAJOR_NR, ubd_dev->size, n, &ubd_gendisk[n]);
-       if(err)
+       err = -ENOMEM;
+       ubd_dev->queue = blk_init_queue(do_ubd_request, &ubd_dev->lock);
+       if (ubd_dev->queue == NULL) {
+               *error_out = "Failed to initialize device queue";
                goto out;
+       }
+       ubd_dev->queue->queuedata = ubd_dev;
+
+       err = ubd_disk_register(MAJOR_NR, ubd_dev->size, n, &ubd_gendisk[n]);
+       if(err){
+               *error_out = "Failed to register device";
+               goto out_cleanup;
+       }
 
        if(fake_major != MAJOR_NR)
                ubd_disk_register(fake_major, ubd_dev->size, n,
-                            &fake_gendisk[n]);
+                                 &fake_gendisk[n]);
 
        /* perhaps this should also be under the "if (fake_major)" above */
        /* using the fake_disk->disk_name and also the fakehd_set name */
@@ -699,30 +703,37 @@ static int ubd_add(int n)
        err = 0;
 out:
        return err;
+
+out_cleanup:
+       blk_cleanup_queue(ubd_dev->queue);
+       goto out;
 }
 
-static int ubd_config(char *str)
+static int ubd_config(char *str, char **error_out)
 {
        int n, ret;
 
+       /* This string is possibly broken up and stored, so it's only
+        * freed if ubd_setup_common fails, or if only general options
+        * were set.
+        */
        str = kstrdup(str, GFP_KERNEL);
        if (str == NULL) {
-               printk(KERN_ERR "ubd_config failed to strdup string\n");
-               ret = 1;
-               goto out;
+               *error_out = "Failed to allocate memory";
+               return -ENOMEM;
        }
-       ret = ubd_setup_common(str, &n);
-       if (ret) {
-               ret = -1;
+
+       ret = ubd_setup_common(str, &n, error_out);
+       if (ret)
                goto err_free;
-       }
+
        if (n == -1) {
                ret = 0;
                goto err_free;
        }
 
        mutex_lock(&ubd_lock);
-       ret = ubd_add(n);
+       ret = ubd_add(n, error_out);
        if (ret)
                ubd_devs[n].file = NULL;
        mutex_unlock(&ubd_lock);
@@ -777,7 +788,7 @@ static int ubd_id(char **str, int *start_out, int *end_out)
         return n;
 }
 
-static int ubd_remove(int n)
+static int ubd_remove(int n, char **error_out)
 {
        struct ubd *ubd_dev;
        int err = -ENODEV;
@@ -807,6 +818,7 @@ static int ubd_remove(int n)
                fake_gendisk[n] = NULL;
        }
 
+       blk_cleanup_queue(ubd_dev->queue);
        platform_device_unregister(&ubd_dev->pdev);
        *ubd_dev = ((struct ubd) DEFAULT_UBD);
        err = 0;
@@ -815,8 +827,11 @@ out:
        return err;
 }
 
-/* All these are called by mconsole in process context and without ubd-specific locks. */
+/* All these are called by mconsole in process context and without
+ * ubd-specific locks.  The structure itself is const except for .list.
+ */
 static struct mc_device ubd_mc = {
+       .list           = LIST_HEAD_INIT(ubd_mc.list),
        .name           = "ubd",
        .config         = ubd_config,
        .get_config     = ubd_get_config,
@@ -836,13 +851,17 @@ static int __init ubd0_init(void)
 {
        struct ubd *ubd_dev = &ubd_devs[0];
 
+       mutex_lock(&ubd_lock);
        if(ubd_dev->file == NULL)
                ubd_dev->file = "root_fs";
+       mutex_unlock(&ubd_lock);
+
        return(0);
 }
 
 __initcall(ubd0_init);
 
+/* Used in ubd_init, which is an initcall */
 static struct platform_driver ubd_driver = {
        .driver = {
                .name  = DRIVER_NAME,
@@ -851,17 +870,12 @@ static struct platform_driver ubd_driver = {
 
 static int __init ubd_init(void)
 {
-        int i;
+       char *error;
+       int i, err;
 
        if (register_blkdev(MAJOR_NR, "ubd"))
                return -1;
 
-       ubd_queue = blk_init_queue(do_ubd_request, &ubd_io_lock);
-       if (!ubd_queue) {
-               unregister_blkdev(MAJOR_NR, "ubd");
-               return -1;
-       }
-               
        if (fake_major != MAJOR_NR) {
                char name[sizeof("ubd_nnn\0")];
 
@@ -870,8 +884,14 @@ static int __init ubd_init(void)
                        return -1;
        }
        platform_driver_register(&ubd_driver);
-       for (i = 0; i < MAX_DEV; i++)
-               ubd_add(i);
+       mutex_lock(&ubd_lock);
+       for (i = 0; i < MAX_DEV; i++){
+               err = ubd_add(i, &error);
+               if(err)
+                       printk(KERN_ERR "Failed to initialize ubd device %d :"
+                              "%s\n", i, error);
+       }
+       mutex_unlock(&ubd_lock);
        return 0;
 }
 
@@ -1003,7 +1023,7 @@ static void cowify_req(struct io_thread_req *req, unsigned long *bitmap,
                           req->bitmap_words, bitmap_len);
 }
 
-/* Called with ubd_io_lock held */
+/* Called with dev->lock held */
 static int prepare_request(struct request *req, struct io_thread_req *io_req)
 {
        struct gendisk *disk = req->rq_disk;
@@ -1022,6 +1042,7 @@ static int prepare_request(struct request *req, struct io_thread_req *io_req)
        offset = ((__u64) req->sector) << 9;
        len = req->current_nr_sectors << 9;
 
+       io_req->req = req;
        io_req->fds[0] = (ubd_dev->cow.file != NULL) ? ubd_dev->cow.fd : ubd_dev->fd;
        io_req->fds[1] = ubd_dev->fd;
        io_req->cow_offset = -1;
@@ -1043,7 +1064,7 @@ static int prepare_request(struct request *req, struct io_thread_req *io_req)
        return(0);
 }
 
-/* Called with ubd_io_lock held */
+/* Called with dev->lock held */
 static void do_ubd_request(request_queue_t *q)
 {
        struct io_thread_req io_req;
@@ -1102,7 +1123,7 @@ static int ubd_ioctl(struct inode * inode, struct file * file,
                                 sizeof(ubd_id)))
                        return(-EFAULT);
                return(0);
-               
+
        case CDROMVOLREAD:
                if(copy_from_user(&volume, (char __user *) arg, sizeof(volume)))
                        return(-EFAULT);
index 9003a343e1484691880fb6ebf20cf0963609f7d6..c4b41bb1035f6f8ef10a193b92bea717650711fc 100644 (file)
@@ -30,14 +30,13 @@ struct chan {
 extern void chan_interrupt(struct list_head *chans, struct delayed_work *task,
                           struct tty_struct *tty, int irq);
 extern int parse_chan_pair(char *str, struct line *line, int device,
-                          const struct chan_opts *opts);
+                          const struct chan_opts *opts, char **error_out);
 extern int open_chan(struct list_head *chans);
 extern int write_chan(struct list_head *chans, const char *buf, int len,
                             int write_irq);
 extern int console_write_chan(struct list_head *chans, const char *buf, 
                              int len);
-extern int console_open_chan(struct line *line, struct console *co,
-                            const struct chan_opts *opts);
+extern int console_open_chan(struct line *line, struct console *co);
 extern void deactivate_chan(struct list_head *chans, int irq);
 extern void reactivate_chan(struct list_head *chans, int irq);
 extern void chan_enable_winch(struct list_head *chans, struct tty_struct *tty);
index a795547a1dbdb5217563457761bd0f13c2a557e4..38f16d812e7c29d230aa6d72086ef2f3329b40eb 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
  * Copyright (C) 2000, 2001 Jeff Dike (jdike@karaya.com)
  * Licensed under the GPL
  */
@@ -9,11 +9,11 @@
 #include "init.h"
 
 struct chan_opts {
-       void (*announce)(char *dev_name, int dev);
+       void (*const announce)(char *dev_name, int dev);
        char *xterm_title;
-       int raw;
-       unsigned long tramp_stack;
-       int in_kernel;
+       const int raw;
+       const unsigned long tramp_stack;
+       const int in_kernel;
 };
 
 enum chan_init_pri { INIT_STATIC, INIT_ALL, INIT_ONE };
@@ -54,14 +54,3 @@ __uml_help(fn, prefix "[0-9]*=<channel description>\n" \
 );
 
 #endif
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
index cec9fcc57bf51f5169cbee6cf7fdc6f60555d5f8..173af029d12b6ec9280c28acbe851ad5b1f7443d 100644 (file)
@@ -61,7 +61,6 @@ extern int set_signals(int enable);
 extern void force_sigbus(void);
 extern int pid_to_processor_id(int pid);
 extern void deliver_signals(void *t);
-extern int next_syscall_index(int max);
 extern int next_trap_index(int max);
 extern void default_idle(void);
 extern void finish_fork(void);
@@ -88,7 +87,6 @@ extern void timer_irq(union uml_pt_regs *regs);
 extern void unprotect_stack(unsigned long stack);
 extern void do_uml_exitcalls(void);
 extern int attach_debugger(int idle_pid, int pid, int stop);
-extern void bad_segv(struct faultinfo fi, unsigned long ip);
 extern int config_gdb(char *str);
 extern int remove_gdb(void);
 extern char *uml_strdup(char *string);
@@ -104,8 +102,6 @@ extern int clear_user_proc(void *buf, int size);
 extern int copy_to_user_proc(void *to, void *from, int size);
 extern int copy_from_user_proc(void *to, void *from, int size);
 extern int strlen_user_proc(char *str);
-extern void bus_handler(int sig, union uml_pt_regs *regs);
-extern void winch(int sig, union uml_pt_regs *regs);
 extern long execute_syscall(void *r);
 extern int smp_sigio_handler(void);
 extern void *get_current(void);
@@ -120,7 +116,6 @@ extern void time_init_kern(void);
 
 /* Are we disallowed to sleep? Used to choose between GFP_KERNEL and GFP_ATOMIC. */
 extern int __cant_sleep(void);
-extern void segv_handler(int sig, union uml_pt_regs *regs);
 extern void sigio_handler(int sig, union uml_pt_regs *regs);
 
 #endif
index 5f232ae89fbb8440a7dd4b4830011bb401f437d4..1223f2c844b4085c798e79400419bcb718dc979c 100644 (file)
 #include "linux/tty.h"
 #include "linux/interrupt.h"
 #include "linux/spinlock.h"
+#include "linux/mutex.h"
 #include "chan_user.h"
 #include "mconsole_kern.h"
 
+/* There's only one modifiable field in this - .mc.list */
 struct line_driver {
-       char *name;
-       char *device_name;
-       short major;
-       short minor_start;
-       short type;
-       short subtype;
-       int read_irq;
-       char *read_irq_name;
-       int write_irq;
-       char *write_irq_name;
-       char *symlink_from;
-       char *symlink_to;
+       const char *name;
+       const char *device_name;
+       const short major;
+       const short minor_start;
+       const short type;
+       const short subtype;
+       const int read_irq;
+       const char *read_irq_name;
+       const int write_irq;
+       const char *write_irq_name;
        struct mc_device mc;
 };
 
 struct line {
        struct tty_struct *tty;
+       spinlock_t count_lock;
+       int valid;
+
        char *init_str;
        int init_pri;
        struct list_head chan_list;
-       int valid;
-       int count;
-       int throttled;
+
        /*This lock is actually, mostly, local to*/
        spinlock_t lock;
-
+       int throttled;
        /* Yes, this is a real circular buffer.
         * XXX: And this should become a struct kfifo!
         *
@@ -57,22 +58,17 @@ struct line {
 };
 
 #define LINE_INIT(str, d) \
-       { .init_str =   str, \
+       { .count_lock = SPIN_LOCK_UNLOCKED, \
+         .init_str =   str,    \
          .init_pri =   INIT_STATIC, \
          .valid =      1, \
          .lock =       SPIN_LOCK_UNLOCKED, \
          .driver =     d }
 
-struct lines {
-       int num;
-};
-
-#define LINES_INIT(n) {  .num =        n }
-
 extern void line_close(struct tty_struct *tty, struct file * filp);
 extern int line_open(struct line *lines, struct tty_struct *tty);
 extern int line_setup(struct line *lines, unsigned int sizeof_lines,
-                     char *init);
+                     char *init, char **error_out);
 extern int line_write(struct tty_struct *tty, const unsigned char *buf,
                      int len);
 extern void line_put_char(struct tty_struct *tty, unsigned char ch);
@@ -90,17 +86,18 @@ extern char *add_xterm_umid(char *base);
 extern int line_setup_irq(int fd, int input, int output, struct line *line,
                          void *data);
 extern void line_close_chan(struct line *line);
-extern struct tty_driver * line_register_devfs(struct lines *set,
-                                              struct line_driver *line_driver,
-                                              const struct tty_operations *driver,
-                                              struct line *lines, int nlines);
+extern struct tty_driver *register_lines(struct line_driver *line_driver,
+                                        const struct tty_operations *driver,
+                                        struct line *lines, int nlines);
 extern void lines_init(struct line *lines, int nlines, struct chan_opts *opts);
 extern void close_lines(struct line *lines, int nlines);
 
 extern int line_config(struct line *lines, unsigned int sizeof_lines,
-                      char *str, const struct chan_opts *opts);
+                      char *str, const struct chan_opts *opts,
+                      char **error_out);
 extern int line_id(char **str, int *start_out, int *end_out);
-extern int line_remove(struct line *lines, unsigned int sizeof_lines, int n);
+extern int line_remove(struct line *lines, unsigned int sizeof_lines, int n,
+                      char **error_out);
 extern int line_get_config(char *dev, struct line *lines,
                           unsigned int sizeof_lines, char *str,
                           int size, char **error_out);
index 1ea6d928e1cd2a5794057cebac2fa6636363048d..d2fe07e78958cb521c4aa3e439581da596b85efe 100644 (file)
@@ -18,10 +18,10 @@ struct mconsole_entry {
 struct mc_device {
        struct list_head list;
        char *name;
-       int (*config)(char *);
+       int (*config)(char *, char **);
        int (*get_config)(char *, char *, int, char **);
-        int (*id)(char **, int *, int *);
-       int (*remove)(int);
+       int (*id)(char **, int *, int *);
+       int (*remove)(int, char **);
 };
 
 #define CONFIG_CHUNK(str, size, current, chunk, end) \
@@ -50,14 +50,3 @@ static inline void mconsole_register_dev(struct mc_device *new)
 #endif
 
 #endif
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
index 218f8b47fdcd7ea80543acca85bc4e2b0bd9e972..125ab42df18a4e53ec77319991df474a890092cc 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
  * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
  * Licensed under the GPL
  */
@@ -36,7 +36,7 @@ struct uml_net_private {
        void (*remove)(void *);
        int (*read)(int, struct sk_buff **skb, struct uml_net_private *);
        int (*write)(int, struct sk_buff **skb, struct uml_net_private *);
-       
+
        void (*add_address)(unsigned char *, unsigned char *, void *);
        void (*delete_address)(unsigned char *, unsigned char *, void *);
        int (*set_mtu)(int mtu, void *);
@@ -52,18 +52,18 @@ struct net_kern_info {
 
 struct transport {
        struct list_head list;
-       char *name;
-       int (*setup)(char *, char **, void *);
+       const char *name;
+       int (* const setup)(char *, char **, void *);
        const struct net_user_info *user;
        const struct net_kern_info *kern;
-       int private_size;
-       int setup_size;
+       const int private_size;
+       const int setup_size;
 };
 
 extern struct net_device *ether_init(int);
 extern unsigned short ether_protocol(struct sk_buff *);
 extern struct sk_buff *ether_adjust_skb(struct sk_buff *skb, int extra);
-extern int tap_setup_common(char *str, char *type, char **dev_name, 
+extern int tap_setup_common(char *str, char *type, char **dev_name,
                            char **mac_out, char **gate_addr);
 extern void register_transport(struct transport *new);
 extern unsigned short eth_protocol(struct sk_buff *skb);
index 13a86bd383d3355fdaf4b30e9703b4968fb58ff8..8629bd1914925aba5d78f4348221c796fc323920 100644 (file)
@@ -137,7 +137,6 @@ extern int os_new_tty_pgrp(int fd, int pid);
 extern int os_get_ifname(int fd, char *namebuf);
 extern int os_set_slip(int fd);
 extern int os_set_owner(int fd, int pid);
-extern int os_sigio_async(int master, int slave);
 extern int os_mode_fd(int fd, int mode);
 
 extern int os_seek_file(int fd, __u64 offset);
@@ -341,4 +340,6 @@ extern void maybe_sigio_broken(int fd, int read);
 extern void sig_handler_common_skas(int sig, void *sc_ptr);
 extern void user_signal(int sig, union uml_pt_regs *regs, int pid);
 
+extern int os_arch_prctl(int pid, int code, unsigned long *addr);
+
 #endif
index fe99ea163c2e68eab0be8e7cecd183132a53e5e1..434f1a9ae4b354621f01d82eb3965cc8645af989 100644 (file)
@@ -12,14 +12,3 @@ extern void sigio_lock(void);
 extern void sigio_unlock(void);
 
 #endif
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
index e36d9e0f51058dc88f730701bcde3b72037a4816..d441eac936b9830014e4ec650562d10f262dc0f8 100644 (file)
@@ -9,13 +9,3 @@
 extern int make_tempfile(const char *template, char **tempname, int do_unlink);
 
 #endif
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
diff --git a/arch/um/include/umid.h b/arch/um/include/umid.h
deleted file mode 100644 (file)
index 11373c8..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (C) 2001 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#ifndef __UMID_H__
-#define __UMID_H__
-
-extern int umid_file_name(char *name, char *buf, int len);
-
-#endif
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
index 6fa63a2a89e3855df6d351229cdca896c6c3a8f7..c5cf4a0827b0f130b20578c1a5c4fa0167249728 100644 (file)
@@ -7,7 +7,7 @@ extra-y := vmlinux.lds
 clean-files :=
 
 obj-y = config.o exec.o exitcode.o init_task.o irq.o ksyms.o mem.o \
-       physmem.o process.o ptrace.o reboot.o resource.o sigio.o \
+       physmem.o process.o ptrace.o reboot.o sigio.o \
        signal.o smp.o syscall.o sysrq.o time.o tlb.o trap.o uaccess.o \
        um_arch.o umid.o
 
index 8d56ec6cca79606e8ee8d075e455e1f2b8d532d6..121166400e25a01917df9452560e2fc12bfba882 100644 (file)
@@ -39,9 +39,9 @@ static long execve1(char *file, char __user * __user *argv,
                    char __user *__user *env)
 {
         long error;
+#ifdef CONFIG_TTY_LOG
        struct tty_struct *tty;
 
-#ifdef CONFIG_TTY_LOG
        mutex_lock(&tty_mutex);
        tty = get_current_tty();
        if (tty)
index 5c1e611f628d548fed1716c75d5537c39d6b8cc4..50a288bb875a87ec10e977db3f366358c15d29d8 100644 (file)
@@ -79,7 +79,7 @@ skip:
        return 0;
 }
 
-struct irq_fd *active_fds = NULL;
+static struct irq_fd *active_fds = NULL;
 static struct irq_fd **last_irq_ptr = &active_fds;
 
 extern void free_irqs(void);
@@ -124,8 +124,8 @@ int activate_fd(int irq, int fd, int type, void *dev_id)
        if (err < 0)
                goto out;
 
-       new_fd = um_kmalloc(sizeof(*new_fd));
        err = -ENOMEM;
+       new_fd = kmalloc(sizeof(struct irq_fd), GFP_KERNEL);
        if (new_fd == NULL)
                goto out;
 
@@ -176,9 +176,8 @@ int activate_fd(int irq, int fd, int type, void *dev_id)
                 */
                spin_unlock_irqrestore(&irq_lock, flags);
                kfree(tmp_pfd);
-               tmp_pfd = NULL;
 
-               tmp_pfd = um_kmalloc(n);
+               tmp_pfd = kmalloc(n, GFP_KERNEL);
                if (tmp_pfd == NULL)
                        goto out_kfree;
 
index c95855ba6ab576f7063f3bdf825efb8182a13b9a..e85d65deea0db9c46f16085c8f168e56e4a475c5 100644 (file)
@@ -24,8 +24,9 @@
 #include "init.h"
 #include "kern_constants.h"
 
-/* Changed during early boot */
+/* allocated in paging_init, zeroed in mem_init, and unchanged thereafter */
 unsigned long *empty_zero_page = NULL;
+/* allocated in paging_init and unchanged thereafter */
 unsigned long *empty_bad_page = NULL;
 pgd_t swapper_pg_dir[PTRS_PER_PGD];
 unsigned long long highmem;
@@ -65,8 +66,8 @@ void mem_init(void)
 {
        max_low_pfn = (high_physmem - uml_physmem) >> PAGE_SHIFT;
 
-        /* clear the zero-page */
-        memset((void *) empty_zero_page, 0, PAGE_SIZE);
+       /* clear the zero-page */
+       memset((void *) empty_zero_page, 0, PAGE_SIZE);
 
        /* Map in the area just after the brk now that kmalloc is about
         * to be turned on.
@@ -253,8 +254,10 @@ struct page *arch_validate(struct page *page, gfp_t mask, int order)
        int i;
 
  again:
-       if(page == NULL) return(page);
-       if(PageHighMem(page)) return(page);
+       if(page == NULL)
+               return page;
+       if(PageHighMem(page))
+               return page;
 
        addr = (unsigned long) page_address(page);
        for(i = 0; i < (1 << order); i++){
@@ -263,13 +266,15 @@ struct page *arch_validate(struct page *page, gfp_t mask, int order)
                                     sizeof(zero),
                                     &current->thread.fault_addr,
                                     &current->thread.fault_catcher)){
-                       if(!(mask & __GFP_WAIT)) return(NULL);
+                       if(!(mask & __GFP_WAIT))
+                               return NULL;
                        else break;
                }
                addr += PAGE_SIZE;
        }
 
-       if(i == (1 << order)) return(page);
+       if(i == (1 << order))
+               return page;
        page = alloc_pages(mask, order);
        goto again;
 }
@@ -283,7 +288,6 @@ void free_initmem(void)
 }
 
 #ifdef CONFIG_BLK_DEV_INITRD
-
 void free_initrd_mem(unsigned long start, unsigned long end)
 {
        if (start < end)
@@ -296,37 +300,36 @@ void free_initrd_mem(unsigned long start, unsigned long end)
                totalram_pages++;
        }
 }
-       
 #endif
 
 void show_mem(void)
 {
-        int pfn, total = 0, reserved = 0;
-        int shared = 0, cached = 0;
-        int highmem = 0;
+       int pfn, total = 0, reserved = 0;
+       int shared = 0, cached = 0;
+       int highmem = 0;
        struct page *page;
 
-        printk("Mem-info:\n");
-        show_free_areas();
-        printk("Free swap:       %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
-        pfn = max_mapnr;
-        while(pfn-- > 0) {
+       printk("Mem-info:\n");
+       show_free_areas();
+       printk("Free swap:       %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
+       pfn = max_mapnr;
+       while(pfn-- > 0) {
                page = pfn_to_page(pfn);
-                total++;
-                if(PageHighMem(page))
-                        highmem++;
-                if(PageReserved(page))
-                        reserved++;
-                else if(PageSwapCache(page))
-                        cached++;
-                else if(page_count(page))
-                        shared += page_count(page) - 1;
-        }
-        printk("%d pages of RAM\n", total);
-        printk("%d pages of HIGHMEM\n", highmem);
-        printk("%d reserved pages\n", reserved);
-        printk("%d pages shared\n", shared);
-        printk("%d pages swap cached\n", cached);
+               total++;
+               if(PageHighMem(page))
+                       highmem++;
+               if(PageReserved(page))
+                       reserved++;
+               else if(PageSwapCache(page))
+                       cached++;
+               else if(page_count(page))
+                       shared += page_count(page) - 1;
+       }
+       printk("%d pages of RAM\n", total);
+       printk("%d pages of HIGHMEM\n", highmem);
+       printk("%d reserved pages\n", reserved);
+       printk("%d pages shared\n", shared);
+       printk("%d pages swap cached\n", cached);
 }
 
 /*
@@ -362,28 +365,7 @@ pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
 struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address)
 {
        struct page *pte;
-   
+
        pte = alloc_page(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO);
        return pte;
 }
-
-struct iomem_region *iomem_regions = NULL;
-int iomem_size = 0;
-
-extern int parse_iomem(char *str, int *add) __init;
-
-__uml_setup("iomem=", parse_iomem,
-"iomem=<name>,<file>\n"
-"    Configure <file> as an IO memory region named <name>.\n\n"
-);
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
index abafa64b8727ecef4e0b35f04fbcae7d7551662a..638f3b5f6094a362968bca5c241a97a34cfe92fb 100644 (file)
@@ -40,7 +40,7 @@ static struct rb_node **find_rb(void *virt)
        while(*n != NULL){
                d = rb_entry(*n, struct phys_desc, rb);
                if(d->virt == virt)
-                       return(n);
+                       return n;
 
                if(d->virt > virt)
                        n = &(*n)->rb_left;
@@ -48,7 +48,7 @@ static struct rb_node **find_rb(void *virt)
                        n = &(*n)->rb_right;
        }
 
-       return(n);
+       return n;
 }
 
 static struct phys_desc *find_phys_mapping(void *virt)
@@ -56,9 +56,9 @@ static struct phys_desc *find_phys_mapping(void *virt)
        struct rb_node **n = find_rb(virt);
 
        if(*n == NULL)
-               return(NULL);
+               return NULL;
 
-       return(rb_entry(*n, struct phys_desc, rb));
+       return rb_entry(*n, struct phys_desc, rb);
 }
 
 static void insert_phys_mapping(struct phys_desc *desc)
@@ -89,10 +89,10 @@ static struct desc_mapping *find_mapping(int fd)
        list_for_each(ele, &descriptor_mappings){
                desc = list_entry(ele, struct desc_mapping, list);
                if(desc->fd == fd)
-                       return(desc);
+                       return desc;
        }
 
-       return(NULL);
+       return NULL;
 }
 
 static struct desc_mapping *descriptor_mapping(int fd)
@@ -101,11 +101,11 @@ static struct desc_mapping *descriptor_mapping(int fd)
 
        desc = find_mapping(fd);
        if(desc != NULL)
-               return(desc);
+               return desc;
 
        desc = kmalloc(sizeof(*desc), GFP_ATOMIC);
        if(desc == NULL)
-               return(NULL);
+               return NULL;
 
        *desc = ((struct desc_mapping)
                { .fd =         fd,
@@ -113,7 +113,7 @@ static struct desc_mapping *descriptor_mapping(int fd)
                  .pages =      LIST_HEAD_INIT(desc->pages) });
        list_add(&desc->list, &descriptor_mappings);
 
-       return(desc);
+       return desc;
 }
 
 int physmem_subst_mapping(void *virt, int fd, __u64 offset, int w)
@@ -125,11 +125,11 @@ int physmem_subst_mapping(void *virt, int fd, __u64 offset, int w)
 
        fd_maps = descriptor_mapping(fd);
        if(fd_maps == NULL)
-               return(-ENOMEM);
+               return -ENOMEM;
 
        phys = __pa(virt);
        desc = find_phys_mapping(virt);
-       if(desc != NULL)
+       if(desc != NULL)
                panic("Address 0x%p is already substituted\n", virt);
 
        err = -ENOMEM;
@@ -155,7 +155,7 @@ int physmem_subst_mapping(void *virt, int fd, __u64 offset, int w)
        rb_erase(&desc->rb, &phys_mappings);
        kfree(desc);
  out:
-       return(err);
+       return err;
 }
 
 static int physmem_fd = -1;
@@ -182,10 +182,10 @@ int physmem_remove_mapping(void *virt)
        virt = (void *) ((unsigned long) virt & PAGE_MASK);
        desc = find_phys_mapping(virt);
        if(desc == NULL)
-               return(0);
+               return 0;
 
        remove_mapping(desc);
-       return(1);
+       return 1;
 }
 
 void physmem_forget_descriptor(int fd)
@@ -239,9 +239,9 @@ void arch_free_page(struct page *page, int order)
 
 int is_remapped(void *virt)
 {
-       struct phys_desc *desc = find_phys_mapping(virt);
+       struct phys_desc *desc = find_phys_mapping(virt);
 
-       return(desc != NULL);
+       return desc != NULL;
 }
 
 /* Changed during early boot */
@@ -276,7 +276,7 @@ int init_maps(unsigned long physmem, unsigned long iomem, unsigned long highmem)
        else map = alloc_bootmem_low_pages(total_len);
 
        if(map == NULL)
-               return(-ENOMEM);
+               return -ENOMEM;
 
        for(i = 0; i < total_pages; i++){
                p = &map[i];
@@ -286,7 +286,7 @@ int init_maps(unsigned long physmem, unsigned long iomem, unsigned long highmem)
        }
 
        max_mapnr = total_pages;
-       return(0);
+       return 0;
 }
 
 /* Changed during early boot */
@@ -296,7 +296,7 @@ unsigned long get_kmem_end(void)
 {
        if(kmem_top == 0)
                kmem_top = CHOOSE_MODE(kmem_end_tt, kmem_end_skas);
-       return(kmem_top);
+       return kmem_top;
 }
 
 void map_memory(unsigned long virt, unsigned long phys, unsigned long len,
@@ -379,7 +379,7 @@ int phys_mapping(unsigned long phys, __u64 *offset_out)
                *offset_out = phys - iomem_size;
        }
 
-       return(fd);
+       return fd;
 }
 
 static int __init uml_mem_setup(char *line, int *add)
@@ -398,6 +398,23 @@ __uml_setup("mem=", uml_mem_setup,
 "      Example: mem=64M\n\n"
 );
 
+extern int __init parse_iomem(char *str, int *add);
+
+__uml_setup("iomem=", parse_iomem,
+"iomem=<name>,<file>\n"
+"    Configure <file> as an IO memory region named <name>.\n\n"
+);
+
+/*
+ * This list is constructed in parse_iomem and addresses filled in in
+ * setup_iomem, both of which run during early boot.  Afterwards, it's
+ * unchanged.
+ */
+struct iomem_region *iomem_regions = NULL;
+
+/* Initialized in parse_iomem */
+int iomem_size = 0;
+
 unsigned long find_iomem(char *driver, unsigned long *len_out)
 {
        struct iomem_region *region = iomem_regions;
@@ -405,13 +422,13 @@ unsigned long find_iomem(char *driver, unsigned long *len_out)
        while(region != NULL){
                if(!strcmp(region->driver, driver)){
                        *len_out = region->size;
-                       return(region->virt);
+                       return region->virt;
                }
 
                region = region->next;
        }
 
-       return(0);
+       return 0;
 }
 
 int setup_iomem(void)
@@ -435,18 +452,7 @@ int setup_iomem(void)
                region = region->next;
        }
 
-       return(0);
+       return 0;
 }
 
 __initcall(setup_iomem);
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
index 9a77fb3c269d667d122c628fec3dd90d8fc4222a..627742d894347c7ca6eb51f989b1e4c259de0909 100644 (file)
@@ -18,6 +18,7 @@
 #include "kern_util.h"
 #include "skas_ptrace.h"
 #include "sysdep/ptrace.h"
+#include "os.h"
 
 static inline void set_singlestepping(struct task_struct *child, int on)
 {
@@ -240,6 +241,12 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
                ret = 0;
                break;
        }
+#endif
+#ifdef PTRACE_ARCH_PRCTL
+        case PTRACE_ARCH_PRCTL:
+                /* XXX Calls ptrace on the host - needs some SMP thinking */
+                ret = arch_prctl_skas(child, data, (void *) addr);
+                break;
 #endif
        default:
                ret = ptrace_request(child, request, addr, data);
diff --git a/arch/um/kernel/resource.c b/arch/um/kernel/resource.c
deleted file mode 100644 (file)
index 32188e1..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/* 
- * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#include "linux/pci.h"
-
-unsigned long resource_fixup(struct pci_dev * dev, struct resource * res,
-                            unsigned long start, unsigned long size)
-{
-       return start;
-}
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
index 2b0ab438301c8bae8f8f4c3a6fe951b71f72e1dd..89f9866a1354b8073cf5f015bd4b80e276b6e9a4 100644 (file)
@@ -23,7 +23,7 @@ static irqreturn_t sigio_interrupt(int irq, void *data)
 
        os_read_file(sigio_irq_fd, &c, sizeof(c));
        reactivate_fd(sigio_irq_fd, SIGIO_WRITE_IRQ);
-       return(IRQ_HANDLED);
+       return IRQ_HANDLED;
 }
 
 int write_sigio_irq(int fd)
@@ -36,12 +36,13 @@ int write_sigio_irq(int fd)
        if(err){
                printk("write_sigio_irq : um_request_irq failed, err = %d\n",
                       err);
-               return(-1);
+               return -1;
        }
        sigio_irq_fd = fd;
-       return(0);
+       return 0;
 }
 
+/* These are called from os-Linux/sigio.c to protect its pollfds arrays. */
 static DEFINE_SPINLOCK(sigio_spinlock);
 
 void sigio_lock(void)
index 0d2cce621134b98e315c958f6addd43a8d0d1bf1..7c18dfcd7d8eee3446457ca928a867136cf880e2 100644 (file)
@@ -14,13 +14,9 @@ unsigned long set_task_sizes_skas(unsigned long *task_size_out)
        unsigned long host_task_size = ROUND_4M((unsigned long)
                                                &host_task_size);
 
-#ifdef CONFIG_HOST_TASK_SIZE
-       *host_size_out = ROUND_4M(CONFIG_HOST_TASK_SIZE);
-       *task_size_out = CONFIG_HOST_TASK_SIZE;
-#else
        if (!skas_needs_stub)
                *task_size_out = host_task_size;
        else *task_size_out = CONFIG_STUB_START & PGDIR_MASK;
-#endif
+
        return host_task_size;
 }
index f5ed8624648b88f0b0022a5994f202361fea19fb..2828c52832275fffa7b013e86cb70ea4867363f9 100644 (file)
@@ -149,22 +149,6 @@ long sys_olduname(struct oldold_utsname __user * name)
        return error;
 }
 
-DEFINE_SPINLOCK(syscall_lock);
-
-static int syscall_index = 0;
-
-int next_syscall_index(int limit)
-{
-       int ret;
-
-       spin_lock(&syscall_lock);
-       ret = syscall_index;
-       if(++syscall_index == limit)
-               syscall_index = 0;
-       spin_unlock(&syscall_lock);
-       return(ret);
-}
-
 int kernel_execve(const char *filename, char *const argv[], char *const envp[])
 {
        mm_segment_t fs;
index 239c98054dec4292f3444783240bf28958f7a850..f9e02b31a97af3dde7bb23437013d6e628b85761 100644 (file)
@@ -50,7 +50,7 @@ void dump_stack(void)
 EXPORT_SYMBOL(dump_stack);
 
 /*Stolen from arch/i386/kernel/traps.c */
-static int kstack_depth_to_print = 24;
+static const int kstack_depth_to_print = 24;
 
 /* This recently started being used in arch-independent code too, as in
  * kernel/sched.c.*/
index 2e354b3ca060649bb0cbd8afef6633637dc357a8..b1f8b0752419d8514763d6ca297674e6e7ceb03e 100644 (file)
@@ -35,31 +35,31 @@ unsigned long long sched_clock(void)
        return (unsigned long long)jiffies_64 * (1000000000 / HZ);
 }
 
-static unsigned long long prev_nsecs;
+static unsigned long long prev_nsecs[NR_CPUS];
 #ifdef CONFIG_UML_REAL_TIME_CLOCK
-static long long delta               /* Deviation per interval */
+static long long delta[NR_CPUS];               /* Deviation per interval */
 #endif
 
 void timer_irq(union uml_pt_regs *regs)
 {
        unsigned long long ticks = 0;
-
 #ifdef CONFIG_UML_REAL_TIME_CLOCK
-       if(prev_nsecs){
+       int c = cpu();
+       if(prev_nsecs[c]){
                /* We've had 1 tick */
                unsigned long long nsecs = os_nsecs();
 
-               delta += nsecs - prev_nsecs;
-               prev_nsecs = nsecs;
+               delta[c] += nsecs - prev_nsecs[c];
+               prev_nsecs[c] = nsecs;
 
                /* Protect against the host clock being set backwards */
-               if(delta < 0)
-                       delta = 0;
+               if(delta[c] < 0)
+                       delta[c] = 0;
 
-               ticks += (delta * HZ) / BILLION;
-               delta -= (ticks * BILLION) / HZ;
+               ticks += (delta[c] * HZ) / BILLION;
+               delta[c] -= (ticks * BILLION) / HZ;
        }
-       else prev_nsecs = os_nsecs();
+       else prev_nsecs[c] = os_nsecs();
 #else
        ticks = 1;
 #endif
@@ -69,8 +69,8 @@ void timer_irq(union uml_pt_regs *regs)
        }
 }
 
+/* Protects local_offset */
 static DEFINE_SPINLOCK(timer_spinlock);
-
 static unsigned long long local_offset = 0;
 
 static inline unsigned long long get_time(void)
index b5f124a2f6ae843b48d33ca02c2a9800a695578d..26f15c4585747c3bf1d95fef79276e628b69c7f6 100644 (file)
@@ -128,7 +128,18 @@ out_of_memory:
        goto out;
 }
 
-void segv_handler(int sig, union uml_pt_regs *regs)
+static void bad_segv(struct faultinfo fi, unsigned long ip)
+{
+       struct siginfo si;
+
+       si.si_signo = SIGSEGV;
+       si.si_code = SEGV_ACCERR;
+       si.si_addr = (void __user *) FAULT_ADDRESS(fi);
+       current->thread.arch.faultinfo = fi;
+       force_sig_info(SIGSEGV, &si, current);
+}
+
+static void segv_handler(int sig, union uml_pt_regs *regs)
 {
        struct faultinfo * fi = UPT_FAULTINFO(regs);
 
@@ -205,17 +216,6 @@ unsigned long segv(struct faultinfo fi, unsigned long ip, int is_user, void *sc)
        return(0);
 }
 
-void bad_segv(struct faultinfo fi, unsigned long ip)
-{
-       struct siginfo si;
-
-       si.si_signo = SIGSEGV;
-       si.si_code = SEGV_ACCERR;
-       si.si_addr = (void __user *) FAULT_ADDRESS(fi);
-       current->thread.arch.faultinfo = fi;
-       force_sig_info(SIGSEGV, &si, current);
-}
-
 void relay_signal(int sig, union uml_pt_regs *regs)
 {
        if(arch_handle_signal(sig, regs))
@@ -232,14 +232,14 @@ void relay_signal(int sig, union uml_pt_regs *regs)
        force_sig(sig, current);
 }
 
-void bus_handler(int sig, union uml_pt_regs *regs)
+static void bus_handler(int sig, union uml_pt_regs *regs)
 {
        if(current->thread.fault_catcher != NULL)
                do_longjmp(current->thread.fault_catcher, 1);
        else relay_signal(sig, regs);
 }
 
-void winch(int sig, union uml_pt_regs *regs)
+static void winch(int sig, union uml_pt_regs *regs)
 {
        do_IRQ(WINCH_IRQ, regs);
 }
index 786e4edd86c51bb9f3a03766d22ec8eb7c8dc55f..8eba8f7dca683cefaebb04f51be819a3f8362e68 100644 (file)
@@ -139,7 +139,7 @@ static void config_gdb_cb(void *arg)
        init_proxy(debugger_pid, 0, 0);
 }
 
-int gdb_config(char *str)
+int gdb_config(char *str, char **error_out)
 {
        struct gdb_data data;
 
@@ -154,7 +154,7 @@ void remove_gdb_cb(void *unused)
        exit_debugger_cb(NULL);
 }
 
-int gdb_remove(int unused)
+int gdb_remove(int unused, char **error_out)
 {
        initial_thread_cb(remove_gdb_cb, NULL);
         return 0;
index 68e1bf63cd0ad2e453010bc384161dfb74e75699..03b06bc00771596d55856641de8963ebb9c16e8c 100644 (file)
@@ -8,10 +8,11 @@
 
 #ifdef CONFIG_MCONSOLE
 
-extern int gdb_config(char *str);
-extern int gdb_remove(int n);
+extern int gdb_config(char *str, char **error_out);
+extern int gdb_remove(int n, char **error_out);
 
 static struct mc_device gdb_mc = {
+       .list           = INIT_LIST_HEAD(gdb_mc.list),
        .name           = "gdb",
        .config         = gdb_config,
        .remove         = gdb_remove,
index 66f43c906821b46de035417fdb1ca042b47eecad..84e57f6da1d3f8c87ce2af810b62914ad551cdbb 100644 (file)
@@ -30,7 +30,6 @@
 #include "kern.h"
 #include "mem_user.h"
 #include "mem.h"
-#include "umid.h"
 #include "initrd.h"
 #include "init.h"
 #include "os.h"
index 4eaee823bfd2a4979a32295f2bba60c6f9e41ccb..039e16efcd5571a7a520f051cf5efa1c61c61b54 100644 (file)
@@ -16,8 +16,10 @@ static int __init set_umid_arg(char *name, int *add)
 {
        int err;
 
-       if(umid_inited)
+       if(umid_inited){
+               printf("umid already set\n");
                return 0;
+       }
 
        *add = 0;
        err = set_umid(name);
index f897140cc4ae2ec6e76bb3610a510017f4679a7c..6ff12743a0bdbe3e396e78b19ac667b52265c74b 100644 (file)
@@ -24,9 +24,6 @@ struct aio_thread_req {
        struct aio_context *aio;
 };
 
-static int aio_req_fd_r = -1;
-static int aio_req_fd_w = -1;
-
 #if defined(HAVE_AIO_ABI)
 #include <linux/aio_abi.h>
 
@@ -111,6 +108,7 @@ static int do_aio(aio_context_t ctx, enum aio_type type, int fd, char *buf,
        return err;
 }
 
+/* Initialized in an initcall and unchanged thereafter */
 static aio_context_t ctx = 0;
 
 static int aio_thread(void *arg)
@@ -137,7 +135,7 @@ static int aio_thread(void *arg)
                        err = os_write_file(reply_fd, &reply, sizeof(reply));
                        if(err != sizeof(reply))
                                printk("aio_thread - write failed, fd = %d, "
-                                      "err = %d\n", aio_req_fd_r, -err);
+                                      "err = %d\n", reply_fd, -err);
                }
        }
        return 0;
@@ -182,6 +180,11 @@ out:
        return err;
 }
 
+/* These are initialized in initcalls and not changed */
+static int aio_req_fd_r = -1;
+static int aio_req_fd_w = -1;
+static int aio_pid = -1;
+
 static int not_aio_thread(void *arg)
 {
        struct aio_thread_req req;
@@ -208,14 +211,12 @@ static int not_aio_thread(void *arg)
                err = os_write_file(req.aio->reply_fd, &reply, sizeof(reply));
                if(err != sizeof(reply))
                        printk("not_aio_thread - write failed, fd = %d, "
-                              "err = %d\n", aio_req_fd_r, -err);
+                              "err = %d\n", req.aio->reply_fd, -err);
        }
 
        return 0;
 }
 
-static int aio_pid = -1;
-
 static int init_aio_24(void)
 {
        unsigned long stack;
@@ -308,6 +309,7 @@ static int submit_aio_26(enum aio_type type, int io_fd, char *buf, int len,
 }
 #endif
 
+/* Initialized in an initcall and unchanged thereafter */
 static int aio_24 = DEFAULT_24_AIO;
 
 static int __init set_aio_24(char *name, int *add)
index 5a99dd3fbed0477bb7443eba1324e70f0dc4bcf4..3a8d7e3aae0a9e2cdc70d1bc547a8b636b614d29 100644 (file)
@@ -21,12 +21,11 @@ typedef Elf32_auxv_t elf_auxv_t;
 typedef Elf64_auxv_t elf_auxv_t;
 #endif
 
+/* These are initialized very early in boot and never changed */
 char * elf_aux_platform;
 long elf_aux_hwcap;
-
 unsigned long vsyscall_ehdr;
 unsigned long vsyscall_end;
-
 unsigned long __kernel_vsyscall;
 
 __init void scan_elf_aux( char **envp)
index 189fa677085a7880d9d8c7bdbcd4593de04a3ea1..371b4335f46dd2985fa852ef4a97abccc03080e5 100644 (file)
@@ -162,25 +162,6 @@ int os_set_owner(int fd, int pid)
        return 0;
 }
 
-/* FIXME? moved wholesale from sigio_user.c to get fcntls out of that file */
-int os_sigio_async(int master, int slave)
-{
-       int flags;
-
-       flags = fcntl(master, F_GETFL);
-       if(flags < 0)
-               return -errno;
-
-       if((fcntl(master, F_SETFL, flags | O_NONBLOCK | O_ASYNC) < 0) ||
-          (fcntl(master, F_SETOWN, os_getpid()) < 0))
-               return -errno;
-
-       if((fcntl(slave, F_SETFL, flags | O_NONBLOCK) < 0))
-               return -errno;
-
-       return(0);
-}
-
 int os_mode_fd(int fd, int mode)
 {
        int err;
index d46b818c1311258934679b82fdd0685afeaecbca..d1b61d474e0a0a535423f74b097b851bf0b05677 100644 (file)
 #include "os.h"
 #include "um_malloc.h"
 
+/*
+ * Locked by irq_lock in arch/um/kernel/irq.c.  Changed by os_create_pollfd
+ * and os_free_irq_by_cb, which are called under irq_lock.
+ */
 static struct pollfd *pollfds = NULL;
 static int pollfds_num = 0;
 static int pollfds_size = 0;
@@ -58,7 +62,7 @@ int os_create_pollfd(int fd, int events, void *tmp_pfd, int size_tmpfds)
        if (pollfds_num == pollfds_size) {
                if (size_tmpfds <= pollfds_size * sizeof(pollfds[0])) {
                        /* return min size needed for new pollfds area */
-                       return((pollfds_size + 1) * sizeof(pollfds[0]));
+                       return (pollfds_size + 1) * sizeof(pollfds[0]);
                }
 
                if (pollfds != NULL) {
index 4203681e508d0a680635347c53a2168fdd3a68be..f1ea169db85e174cf2d6998043bce9d655eef0cd 100644 (file)
 
 #include <sys/param.h>
 
+/* Modified by which_tmpdir, which is called during early boot */
 static char *default_tmpdir = "/tmp";
+
+/*
+ *  Modified when creating the physical memory file and when checking
+ * the tmp filesystem for usability, both happening during early boot.
+ */
 static char *tempdir = NULL;
 
 static void __init find_tempdir(void)
@@ -29,7 +35,8 @@ static void __init find_tempdir(void)
        int i;
        char *dir = NULL;
 
-       if(tempdir != NULL) return;     /* We've already been called */
+       if(tempdir != NULL) /* We've already been called */
+               return;
        for(i = 0; dirs[i]; i++){
                dir = getenv(dirs[i]);
                if((dir != NULL) && (*dir != '\0'))
@@ -83,6 +90,7 @@ static int next(int fd, char *buf, int size, char c)
        return 1;
 }
 
+/* which_tmpdir is called only during early boot */
 static int checked_tmpdir = 0;
 
 /* Look for a tmpfs mounted at /dev/shm.  I couldn't find a cleaner
@@ -186,7 +194,7 @@ int make_tempfile(const char *template, char **out_tempname, int do_unlink)
        } else {
                free(tempname);
        }
-       return(fd);
+       return fd;
 out:
        free(tempname);
        return -1;
@@ -231,7 +239,7 @@ int create_tmp_file(unsigned long long len)
                exit(1);
        }
 
-       return(fd);
+       return fd;
 }
 
 int create_mem_file(unsigned long long len)
@@ -245,7 +253,7 @@ int create_mem_file(unsigned long long len)
                errno = -err;
                perror("exec_close");
        }
-       return(fd);
+       return fd;
 }
 
 
index 7fe92680c7dd8de39fef42309818df27546ff17a..5178eba9afa54fa779ab3af327e82259768d7fbf 100644 (file)
@@ -54,7 +54,7 @@ static int ptrace_child(void *arg)
                perror("ptrace");
                os_kill_process(pid, 0);
        }
-       os_stop_process(pid);
+       kill(pid, SIGSTOP);
 
        /*This syscall will be intercepted by the parent. Don't call more than
         * once, please.*/
@@ -73,6 +73,34 @@ static int ptrace_child(void *arg)
        _exit(ret);
 }
 
+static void fatal_perror(char *str)
+{
+       perror(str);
+       exit(1);
+}
+
+static void fatal(char *fmt, ...)
+{
+       va_list list;
+
+       va_start(list, fmt);
+       vprintf(fmt, list);
+       va_end(list);
+       fflush(stdout);
+
+       exit(1);
+}
+
+static void non_fatal(char *fmt, ...)
+{
+       va_list list;
+
+       va_start(list, fmt);
+       vprintf(fmt, list);
+       va_end(list);
+       fflush(stdout);
+}
+
 static int start_ptraced_child(void **stack_out)
 {
        void *stack;
@@ -82,20 +110,20 @@ static int start_ptraced_child(void **stack_out)
        stack = mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC,
                     MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
        if(stack == MAP_FAILED)
-               panic("check_ptrace : mmap failed, errno = %d", errno);
+               fatal_perror("check_ptrace : mmap failed");
        sp = (unsigned long) stack + PAGE_SIZE - sizeof(void *);
        pid = clone(ptrace_child, (void *) sp, SIGCHLD, NULL);
        if(pid < 0)
-               panic("start_ptraced_child : clone failed, errno = %d", errno);
+               fatal_perror("start_ptraced_child : clone failed");
        CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED));
        if(n < 0)
-               panic("check_ptrace : clone failed, errno = %d", errno);
+               fatal_perror("check_ptrace : clone failed");
        if(!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGSTOP))
-               panic("check_ptrace : expected SIGSTOP, got status = %d",
+               fatal("check_ptrace : expected SIGSTOP, got status = %d",
                      status);
 
        *stack_out = stack;
-       return(pid);
+       return pid;
 }
 
 /* When testing for SYSEMU support, if it is one of the broken versions, we
@@ -105,34 +133,34 @@ static int start_ptraced_child(void **stack_out)
  * must work anyway!
  */
 static int stop_ptraced_child(int pid, void *stack, int exitcode,
-                             int mustpanic)
+                             int mustexit)
 {
        int status, n, ret = 0;
 
        if(ptrace(PTRACE_CONT, pid, 0, 0) < 0)
-               panic("check_ptrace : ptrace failed, errno = %d", errno);
+               fatal_perror("stop_ptraced_child : ptrace failed");
        CATCH_EINTR(n = waitpid(pid, &status, 0));
        if(!WIFEXITED(status) || (WEXITSTATUS(status) != exitcode)) {
                int exit_with = WEXITSTATUS(status);
                if (exit_with == 2)
-                       printf("check_ptrace : child exited with status 2. "
-                              "Serious trouble happening! Try updating your "
-                              "host skas patch!\nDisabling SYSEMU support.");
-               printf("check_ptrace : child exited with exitcode %d, while "
-                     "expecting %d; status 0x%x", exit_with,
-                     exitcode, status);
-               if (mustpanic)
-                       panic("\n");
-               else
-                       printf("\n");
+                       non_fatal("check_ptrace : child exited with status 2. "
+                                 "Serious trouble happening! Try updating "
+                                 "your host skas patch!\nDisabling SYSEMU "
+                                 "support.");
+               non_fatal("check_ptrace : child exited with exitcode %d, while "
+                         "expecting %d; status 0x%x\n", exit_with,
+                         exitcode, status);
+               if (mustexit)
+                       exit(1);
                ret = -1;
        }
 
        if(munmap(stack, PAGE_SIZE) < 0)
-               panic("check_ptrace : munmap failed, errno = %d", errno);
+               fatal_perror("check_ptrace : munmap failed");
        return ret;
 }
 
+/* Changed only during early boot */
 int ptrace_faultinfo = 1;
 int ptrace_ldt = 1;
 int proc_mm = 1;
@@ -160,6 +188,7 @@ __uml_setup("mode=skas0", mode_skas0_cmd_param,
                "    specify mode=tt. Note that this was recently added - on \n"
                "    older kernels you must use simply \"skas0\".\n\n");
 
+/* Changed only during early boot */
 static int force_sysemu_disabled = 0;
 
 static int __init nosysemu_cmd_param(char *str, int* add)
@@ -180,9 +209,9 @@ __uml_setup("nosysemu", nosysemu_cmd_param,
 static void __init check_sysemu(void)
 {
        void *stack;
-       int pid, n, status, count=0;
+       int pid, n, status, count=0;
 
-       printf("Checking syscall emulation patch for ptrace...");
+       non_fatal("Checking syscall emulation patch for ptrace...");
        sysemu_supported = 0;
        pid = start_ptraced_child(&stack);
 
@@ -191,31 +220,30 @@ static void __init check_sysemu(void)
 
        CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED));
        if (n < 0)
-               panic("check_sysemu : wait failed, errno = %d", errno);
+               fatal_perror("check_sysemu : wait failed");
        if(!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGTRAP))
-               panic("check_sysemu : expected SIGTRAP, "
-                     "got status = %d", status);
+               fatal("check_sysemu : expected SIGTRAP, got status = %d",
+                     status);
 
        n = ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_RET_OFFSET,
                   os_getpid());
        if(n < 0)
-               panic("check_sysemu : failed to modify system "
-                     "call return, errno = %d", errno);
+               fatal_perror("check_sysemu : failed to modify system call "
+                            "return");
 
        if (stop_ptraced_child(pid, stack, 0, 0) < 0)
                goto fail_stopped;
 
        sysemu_supported = 1;
-       printf("OK\n");
+       non_fatal("OK\n");
        set_using_sysemu(!force_sysemu_disabled);
 
-       printf("Checking advanced syscall emulation patch for ptrace...");
+       non_fatal("Checking advanced syscall emulation patch for ptrace...");
        pid = start_ptraced_child(&stack);
 
-       if(ptrace(PTRACE_OLDSETOPTIONS, pid, 0,
-                 (void *) PTRACE_O_TRACESYSGOOD) < 0)
-               panic("check_ptrace: PTRACE_OLDSETOPTIONS failed, errno = %d",
-                     errno);
+       if((ptrace(PTRACE_OLDSETOPTIONS, pid, 0,
+                  (void *) PTRACE_O_TRACESYSGOOD) < 0))
+               fatal_perror("check_ptrace: PTRACE_OLDSETOPTIONS failed");
 
        while(1){
                count++;
@@ -223,29 +251,30 @@ static void __init check_sysemu(void)
                        goto fail;
                CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED));
                if(n < 0)
-                       panic("check_ptrace : wait failed, errno = %d", errno);
+                       fatal_perror("check_ptrace : wait failed");
+
                if(WIFSTOPPED(status) && (WSTOPSIG(status) == (SIGTRAP|0x80))){
                        if (!count)
-                               panic("check_ptrace : SYSEMU_SINGLESTEP "
+                               fatal("check_ptrace : SYSEMU_SINGLESTEP "
                                      "doesn't singlestep");
                        n = ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_RET_OFFSET,
                                   os_getpid());
                        if(n < 0)
-                               panic("check_sysemu : failed to modify system "
-                                     "call return, errno = %d", errno);
+                               fatal_perror("check_sysemu : failed to modify "
+                                            "system call return");
                        break;
                }
                else if(WIFSTOPPED(status) && (WSTOPSIG(status) == SIGTRAP))
                        count++;
                else
-                       panic("check_ptrace : expected SIGTRAP or "
-                             "(SIGTRAP|0x80), got status = %d", status);
+                       fatal("check_ptrace : expected SIGTRAP or "
+                             "(SIGTRAP | 0x80), got status = %d", status);
        }
        if (stop_ptraced_child(pid, stack, 0, 0) < 0)
                goto fail_stopped;
 
        sysemu_supported = 2;
-       printf("OK\n");
+       non_fatal("OK\n");
 
        if ( !force_sysemu_disabled )
                set_using_sysemu(sysemu_supported);
@@ -254,7 +283,7 @@ static void __init check_sysemu(void)
 fail:
        stop_ptraced_child(pid, stack, 1, 0);
 fail_stopped:
-       printf("missing\n");
+       non_fatal("missing\n");
 }
 
 static void __init check_ptrace(void)
@@ -262,22 +291,25 @@ static void __init check_ptrace(void)
        void *stack;
        int pid, syscall, n, status;
 
-       printf("Checking that ptrace can change system call numbers...");
+       non_fatal("Checking that ptrace can change system call numbers...");
        pid = start_ptraced_child(&stack);
 
-       if(ptrace(PTRACE_OLDSETOPTIONS, pid, 0, (void *)PTRACE_O_TRACESYSGOOD) < 0)
-               panic("check_ptrace: PTRACE_OLDSETOPTIONS failed, errno = %d", errno);
+       if((ptrace(PTRACE_OLDSETOPTIONS, pid, 0,
+                  (void *) PTRACE_O_TRACESYSGOOD) < 0))
+               fatal_perror("check_ptrace: PTRACE_OLDSETOPTIONS failed");
 
        while(1){
                if(ptrace(PTRACE_SYSCALL, pid, 0, 0) < 0)
-                       panic("check_ptrace : ptrace failed, errno = %d",
-                             errno);
+                       fatal_perror("check_ptrace : ptrace failed");
+
                CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED));
                if(n < 0)
-                       panic("check_ptrace : wait failed, errno = %d", errno);
-               if(!WIFSTOPPED(status) || (WSTOPSIG(status) != (SIGTRAP|0x80)))
-                       panic("check_ptrace : expected (SIGTRAP|0x80), "
-                             "got status = %d", status);
+                       fatal_perror("check_ptrace : wait failed");
+
+               if(!WIFSTOPPED(status) ||
+                  (WSTOPSIG(status) != (SIGTRAP | 0x80)))
+                       fatal("check_ptrace : expected (SIGTRAP|0x80), "
+                              "got status = %d", status);
 
                syscall = ptrace(PTRACE_PEEKUSR, pid, PT_SYSCALL_NR_OFFSET,
                                 0);
@@ -285,13 +317,13 @@ static void __init check_ptrace(void)
                        n = ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_NR_OFFSET,
                                   __NR_getppid);
                        if(n < 0)
-                               panic("check_ptrace : failed to modify system "
-                                     "call, errno = %d", errno);
+                               fatal_perror("check_ptrace : failed to modify "
+                                            "system call");
                        break;
                }
        }
        stop_ptraced_child(pid, stack, 0, 1);
-       printf("OK\n");
+       non_fatal("OK\n");
        check_sysemu();
 }
 
@@ -350,22 +382,22 @@ static inline void check_skas3_ptrace_faultinfo(void)
        void *stack;
        int pid, n;
 
-       printf("  - PTRACE_FAULTINFO...");
+       non_fatal("  - PTRACE_FAULTINFO...");
        pid = start_ptraced_child(&stack);
 
        n = ptrace(PTRACE_FAULTINFO, pid, 0, &fi);
        if (n < 0) {
                ptrace_faultinfo = 0;
                if(errno == EIO)
-                       printf("not found\n");
+                       non_fatal("not found\n");
                else
                        perror("not found");
        }
        else {
                if (!ptrace_faultinfo)
-                       printf("found but disabled on command line\n");
+                       non_fatal("found but disabled on command line\n");
                else
-                       printf("found\n");
+                       non_fatal("found\n");
        }
 
        init_registers(pid);
@@ -383,13 +415,13 @@ static inline void check_skas3_ptrace_ldt(void)
                .ptr = ldtbuf,
                .bytecount = sizeof(ldtbuf)};
 
-       printf("  - PTRACE_LDT...");
+       non_fatal("  - PTRACE_LDT...");
        pid = start_ptraced_child(&stack);
 
        n = ptrace(PTRACE_LDT, pid, 0, (unsigned long) &ldt_op);
        if (n < 0) {
                if(errno == EIO)
-                       printf("not found\n");
+                       non_fatal("not found\n");
                else {
                        perror("not found");
                }
@@ -397,9 +429,9 @@ static inline void check_skas3_ptrace_ldt(void)
        }
        else {
                if(ptrace_ldt)
-                       printf("found\n");
+                       non_fatal("found\n");
                else
-                       printf("found, but use is disabled\n");
+                       non_fatal("found, but use is disabled\n");
        }
 
        stop_ptraced_child(pid, stack, 1, 1);
@@ -414,22 +446,22 @@ static inline void check_skas3_ptrace_ldt(void)
 
 static inline void check_skas3_proc_mm(void)
 {
-       printf("  - /proc/mm...");
-       if (os_access("/proc/mm", OS_ACC_W_OK) < 0) {
-               proc_mm = 0;
-               printf("not found\n");
+       non_fatal("  - /proc/mm...");
+       if (access("/proc/mm", W_OK) < 0) {
+               proc_mm = 0;
+               perror("not found");
        }
        else {
                if (!proc_mm)
-                       printf("found but disabled on command line\n");
+                       non_fatal("found but disabled on command line\n");
                else
-                       printf("found\n");
+                       non_fatal("found\n");
        }
 }
 
 int can_do_skas(void)
 {
-       printf("Checking for the skas3 patch in the host:\n");
+       non_fatal("Checking for the skas3 patch in the host:\n");
 
        check_skas3_proc_mm();
        check_skas3_ptrace_faultinfo();
@@ -443,16 +475,16 @@ int can_do_skas(void)
 #else
 int can_do_skas(void)
 {
-       return(0);
+       return 0;
 }
 #endif
 
 int __init parse_iomem(char *str, int *add)
 {
        struct iomem_region *new;
-       struct uml_stat buf;
+       struct stat64 buf;
        char *file, *driver;
-       int fd, err, size;
+       int fd, size;
 
        driver = str;
        file = strchr(str,',');
@@ -462,15 +494,14 @@ int __init parse_iomem(char *str, int *add)
        }
        *file = '\0';
        file++;
-       fd = os_open_file(file, of_rdwr(OPENFLAGS()), 0);
+       fd = open(file, O_RDWR, 0);
        if(fd < 0){
                os_print_error(fd, "parse_iomem - Couldn't open io file");
                goto out;
        }
 
-       err = os_stat_fd(fd, &buf);
-       if(err < 0){
-               os_print_error(err, "parse_iomem - cannot stat_fd file");
+       if(fstat64(fd, &buf) < 0){
+               perror("parse_iomem - cannot stat_fd file");
                goto out_close;
        }
 
@@ -480,7 +511,7 @@ int __init parse_iomem(char *str, int *add)
                goto out_close;
        }
 
-       size = (buf.ust_size + UM_KERN_PAGE_SIZE) & ~(UM_KERN_PAGE_SIZE - 1);
+       size = (buf.st_size + UM_KERN_PAGE_SIZE) & ~(UM_KERN_PAGE_SIZE - 1);
 
        *new = ((struct iomem_region) { .next           = iomem_regions,
                                        .driver         = driver,
@@ -491,11 +522,11 @@ int __init parse_iomem(char *str, int *add)
        iomem_regions = new;
        iomem_size += new->size + UM_KERN_PAGE_SIZE;
 
-       return(0);
+       return 0;
  out_close:
-       os_close_file(fd);
+       close(fd);
  out:
-       return(1);
+       return 1;
 }
 
 
@@ -526,6 +557,24 @@ static void openpty_cb(void *arg)
                info->err = -errno;
 }
 
+static int async_pty(int master, int slave)
+{
+       int flags;
+
+       flags = fcntl(master, F_GETFL);
+       if(flags < 0)
+               return -errno;
+
+       if((fcntl(master, F_SETFL, flags | O_NONBLOCK | O_ASYNC) < 0) ||
+          (fcntl(master, F_SETOWN, os_getpid()) < 0))
+               return -errno;
+
+       if((fcntl(slave, F_SETFL, flags | O_NONBLOCK) < 0))
+               return -errno;
+
+       return(0);
+}
+
 static void __init check_one_sigio(void (*proc)(int, int))
 {
        struct sigaction old, new;
@@ -551,7 +600,7 @@ static void __init check_one_sigio(void (*proc)(int, int))
        if (err < 0)
                panic("check_sigio : __raw failed, errno = %d\n", -err);
 
-       err = os_sigio_async(master, slave);
+       err = async_pty(master, slave);
        if(err < 0)
                panic("tty_fds : sigio_async failed, err = %d\n", -err);
 
index 7cd0369e02b3b82970727bec506038ecb3cfd00c..79cd93c8c5ed62d08ebe0d1d99461e4f98105f1c 100644 (file)
@@ -34,27 +34,27 @@ void init_thread_registers(union uml_pt_regs *to)
 int save_fp_registers(int pid, unsigned long *fp_regs)
 {
        if(ptrace(PTRACE_GETFPREGS, pid, 0, fp_regs) < 0)
-               return(-errno);
-       return(0);
+               return -errno;
+       return 0;
 }
 
 int restore_fp_registers(int pid, unsigned long *fp_regs)
 {
        if(ptrace(PTRACE_SETFPREGS, pid, 0, fp_regs) < 0)
-               return(-errno);
-       return(0);
+               return -errno;
+       return 0;
 }
 
 static int move_registers(int pid, int int_op, union uml_pt_regs *regs,
                          int fp_op, unsigned long *fp_regs)
 {
        if(ptrace(int_op, pid, 0, regs->skas.regs) < 0)
-               return(-errno);
+               return -errno;
 
        if(ptrace(fp_op, pid, 0, fp_regs) < 0)
-               return(-errno);
+               return -errno;
 
-       return(0);
+       return 0;
 }
 
 void save_registers(int pid, union uml_pt_regs *regs)
index f67842a7735b80b09b6a7f1fbb13a1f98861a630..7955e061a678aaf3d7f29143b3a6ed65257ad391 100644 (file)
@@ -3,7 +3,7 @@
 # Licensed under the GPL
 #
 
-obj-$(CONFIG_MODE_SKAS) = registers.o signal.o
+obj-$(CONFIG_MODE_SKAS) = registers.o prctl.o signal.o
 
 USER_OBJS := $(obj-y)
 
diff --git a/arch/um/os-Linux/sys-x86_64/prctl.c b/arch/um/os-Linux/sys-x86_64/prctl.c
new file mode 100644 (file)
index 0000000..9d34edd
--- /dev/null
@@ -0,0 +1,12 @@
+/*
+ * Copyright (C) 2007 Jeff Dike (jdike@{addtoit.com,linux.intel.com})
+ * Licensed under the GPL
+ */
+
+#include <sys/ptrace.h>
+#include <linux/ptrace.h>
+
+int os_arch_prctl(int pid, int code, unsigned long *addr)
+{
+        return ptrace(PTRACE_ARCH_PRCTL, pid, (unsigned long) addr, code);
+}
index cb8e8a2632803c75d1c90db8b0b73cbbc86b6d07..a2d7e0c603f798efe99beb39da79b35f3ca9199e 100644 (file)
@@ -27,12 +27,12 @@ static int move_registers(int pid, int int_op, int fp_op,
                          union uml_pt_regs *regs)
 {
        if(ptrace(int_op, pid, 0, regs->skas.regs) < 0)
-               return(-errno);
+               return -errno;
 
        if(ptrace(fp_op, pid, 0, regs->skas.fp) < 0)
-               return(-errno);
+               return -errno;
 
-       return(0);
+       return 0;
 }
 
 void save_registers(int pid, union uml_pt_regs *regs)
index 48092b95c8ab997b4914a072afcd17f0e1aa7eda..b462863f7172fda8b98b5ac41f0d6367faf9e9ec 100644 (file)
@@ -18,7 +18,7 @@
 #define UMID_LEN 64
 
 /* Changed by set_umid, which is run early in boot */
-char umid[UMID_LEN] = { 0 };
+static char umid[UMID_LEN] = { 0 };
 
 /* Changed by set_uml_dir and make_uml_dir, which are run early in boot */
 static char *uml_dir = UML_DIR;
@@ -235,6 +235,7 @@ int __init set_umid(char *name)
        return 0;
 }
 
+/* Changed in make_umid, which is called during early boot */
 static int umid_setup = 0;
 
 int __init make_umid(void)
index 147bbf05cbc2fbc2d71e395f038ac97ce0387902..55b66e09a98cce2437969f49fdc477e08bb92311 100644 (file)
@@ -71,8 +71,6 @@ int poke_user(struct task_struct *child, long addr, long data)
 
         if (addr < MAX_REG_OFFSET)
                 return putreg(child, addr, data);
-
-#if 0 /* Need x86_64 debugregs handling */
         else if((addr >= offsetof(struct user, u_debugreg[0])) &&
                 (addr <= offsetof(struct user, u_debugreg[7]))){
                 addr -= offsetof(struct user, u_debugreg[0]);
@@ -81,7 +79,6 @@ int poke_user(struct task_struct *child, long addr, long data)
                 child->thread.arch.debugregs[addr] = data;
                 return 0;
         }
-#endif
         return -EIO;
 }
 
@@ -119,14 +116,12 @@ int peek_user(struct task_struct *child, long addr, long data)
         if(addr < MAX_REG_OFFSET){
                 tmp = getreg(child, addr);
         }
-#if 0 /* Need x86_64 debugregs handling */
         else if((addr >= offsetof(struct user, u_debugreg[0])) &&
                 (addr <= offsetof(struct user, u_debugreg[7]))){
                 addr -= offsetof(struct user, u_debugreg[0]);
                 addr = addr >> 2;
                 tmp = child->thread.arch.debugregs[addr];
         }
-#endif
         return put_user(tmp, (unsigned long *) data);
 }
 
index 73ce4463f70c6f96b2cd94f000b69df5a0da95ff..01b91f9fa7893647454f2a843f22a729197d78cb 100644 (file)
@@ -16,6 +16,7 @@
 #include "asm/prctl.h" /* XXX This should get the constants from libc */
 #include "choose-mode.h"
 #include "kern.h"
+#include "os.h"
 
 asmlinkage long sys_uname64(struct new_utsname __user * name)
 {
@@ -58,40 +59,69 @@ static long arch_prctl_tt(int code, unsigned long addr)
 
 #ifdef CONFIG_MODE_SKAS
 
-/* XXX: Must also call arch_prctl in the host, beside saving the segment bases! */
-static long arch_prctl_skas(int code, unsigned long addr)
+long arch_prctl_skas(struct task_struct *task, int code,
+                     unsigned long __user *addr)
 {
-       long ret = 0;
+        unsigned long *ptr = addr, tmp;
+       long ret;
+       int pid = task->mm->context.skas.id.u.pid;
 
+       /*
+        * With ARCH_SET_FS (and ARCH_SET_GS is treated similarly to
+        * be safe), we need to call arch_prctl on the host because
+        * setting %fs may result in something else happening (like a
+        * GDT or thread.fs being set instead).  So, we let the host
+        * fiddle the registers and thread struct and restore the
+        * registers afterwards.
+        *
+        * So, the saved registers are stored to the process (this
+        * needed because a stub may have been the last thing to run),
+        * arch_prctl is run on the host, then the registers are read
+        * back.
+        */
        switch(code){
        case ARCH_SET_FS:
-               current->thread.regs.regs.skas.regs[FS_BASE / sizeof(unsigned long)] = addr;
-               break;
        case ARCH_SET_GS:
-               current->thread.regs.regs.skas.regs[GS_BASE / sizeof(unsigned long)] = addr;
+                restore_registers(pid, &current->thread.regs.regs);
+                break;
+        case ARCH_GET_FS:
+        case ARCH_GET_GS:
+                /*
+                 * With these two, we read to a local pointer and
+                 * put_user it to the userspace pointer that we were
+                 * given.  If addr isn't valid (because it hasn't been
+                 * faulted in or is just bogus), we want put_user to
+                 * fault it in (or return -EFAULT) instead of having
+                 * the host return -EFAULT.
+                 */
+                ptr = &tmp;
+        }
+
+        ret = os_arch_prctl(pid, code, ptr);
+        if(ret)
+                return ret;
+
+        switch(code){
+       case ARCH_SET_FS:
+       case ARCH_SET_GS:
+                save_registers(pid, &current->thread.regs.regs);
                break;
        case ARCH_GET_FS:
-               ret = put_user(current->thread.regs.regs.skas.
-                               regs[FS_BASE / sizeof(unsigned long)],
-                               (unsigned long __user *)addr);
+               ret = put_user(tmp, addr);
                break;
        case ARCH_GET_GS:
-               ret = put_user(current->thread.regs.regs.skas.
-                               regs[GS_BASE / sizeof(unsigned long)],
-                               (unsigned long __user *)addr);
+               ret = put_user(tmp, addr);
                break;
-       default:
-               ret = -EINVAL;
-               break;
        }
 
-       return(ret);
+       return ret;
 }
 #endif
 
 long sys_arch_prctl(int code, unsigned long addr)
 {
-       return(CHOOSE_MODE_PROC(arch_prctl_tt, arch_prctl_skas, code, addr));
+       return CHOOSE_MODE_PROC(arch_prctl_tt, arch_prctl_skas, current, code,
+                                (unsigned long __user *) addr);
 }
 
 long sys_clone(unsigned long clone_flags, unsigned long newsp,
@@ -105,5 +135,14 @@ long sys_clone(unsigned long clone_flags, unsigned long newsp,
        ret = do_fork(clone_flags, newsp, &current->thread.regs, 0, parent_tid,
                      child_tid);
        current->thread.forking = 0;
-       return(ret);
+       return ret;
+}
+
+void arch_switch_to_skas(struct task_struct *from, struct task_struct *to)
+{
+        if(to->thread.arch.fs == 0)
+                return;
+
+        arch_prctl_skas(to, ARCH_SET_FS, (void __user *) to->thread.arch.fs);
 }
+
index ce1bf1b81c431dcb859db4f25410a2758c226f19..febbc94be25fd423c890ac8f11d1859ca919217a 100644 (file)
@@ -1,14 +1,17 @@
 #include "linux/sched.h"
 
-void debug_arch_force_load_TLS(void)
-{
-}
-
 void clear_flushed_tls(struct task_struct *task)
 {
 }
 
 int arch_copy_tls(struct task_struct *t)
 {
+       /*
+        * If CLONE_SETTLS is set, we need to save the thread id
+        * (which is argument 5, child_tid, of clone) so it can be set
+        * during context switches.
+        */
+       t->thread.arch.fs = t->thread.regs.regs.skas.regs[R8 / sizeof(long)];
+
         return 0;
 }
index f0d4d72e560fe8e1b68700e6c87929da3239bae6..dbfab8fc9b49c2c4c6e620558401f57af2bedf50 100644 (file)
@@ -10,6 +10,9 @@ mainmenu "uClinux/v850 (w/o MMU) Kernel Configuration"
 config MMU
                bool
        default n
+config ZONE_DMA
+       bool
+       default y
 config RWSEM_GENERIC_SPINLOCK
        bool
        default y
index 40892d3e3c247ea2dbada930d4f65b5675f05993..0e429041a117606aa39674aa3d367ac684910a92 100644 (file)
@@ -114,7 +114,7 @@ static struct v850e_intc_irq_init irq_inits[] = {
        { "ST",  IRQ_INTST(0),  IRQ_INTST_NUM,  3, 5 },
        { 0 }
 };
-#define NUM_IRQ_INITS ((sizeof irq_inits / sizeof irq_inits[0]) - 1)
+#define NUM_IRQ_INITS (ARRAY_SIZE(irq_inits) - 1)
 
 static struct hw_interrupt_type hw_itypes[NUM_IRQ_INITS];
 
index 5352f8a5aa070191f9d0d027a0ac7bc420b10cb9..18437bc5c3ad29aa53eb221d0a1595aa7445aac2 100644 (file)
@@ -142,7 +142,7 @@ static struct v850e_intc_irq_init irq_inits[] = {
        { "ST",  IRQ_INTST(0),  IRQ_INTST_NUM,  3, 5 },
        { 0 }
 };
-#define NUM_IRQ_INITS ((sizeof irq_inits / sizeof irq_inits[0]) - 1)
+#define NUM_IRQ_INITS (ARRAY_SIZE(irq_inits) - 1)
 
 static struct hw_interrupt_type hw_itypes[NUM_IRQ_INITS];
 
index cb04a6954ccbc5d99b639d119bc36a50fa6f96ca..5c4923558a75c8f7b5620ccb7a5fb3f20df60f3a 100644 (file)
@@ -138,7 +138,7 @@ struct v850e_intc_irq_init irq_inits[] = {
        { "RPU", IRQ_RPU(0),    IRQ_RPU_NUM,    1, 6 },
        { 0 }
 };
-#define NUM_IRQ_INITS ((sizeof irq_inits / sizeof irq_inits[0]) - 1)
+#define NUM_IRQ_INITS (ARRAY_SIZE(irq_inits) - 1)
 
 struct hw_interrupt_type hw_itypes[NUM_IRQ_INITS];
 
index 25d636e79e6acfe59be1fc933632ad894e880a21..b2bcc251f65b8b1ec3c6c9a0d63845c25d99af69 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/irq.h>
 #include <linux/interrupt.h>
 #include <linux/signal.h>
+#include <linux/kernel.h>
 
 #include <asm/machdep.h>
 
@@ -36,7 +37,7 @@ struct used_gint {
        { 1, GBUS_INT_PRIORITY_HIGH },
        { 3, GBUS_INT_PRIORITY_LOW }
 };
-#define NUM_USED_GINTS (sizeof used_gint / sizeof used_gint[0])
+#define NUM_USED_GINTS ARRAY_SIZE(used_gint)
 
 /* A table of which GINT is used by each GBUS interrupts (they are
    assigned based on priority).  */
@@ -231,8 +232,7 @@ struct gbus_int_irq_init gbus_irq_inits[] __initdata = {
        { "GBUS_INT", IRQ_GBUS_INT(0), IRQ_GBUS_INT_NUM, 1, 6},
        { 0 }
 };
-#define NUM_GBUS_IRQ_INITS  \
-   ((sizeof gbus_irq_inits / sizeof gbus_irq_inits[0]) - 1)
+#define NUM_GBUS_IRQ_INITS (ARRAY_SIZE(gbus_irq_inits) - 1)
 
 static struct hw_interrupt_type gbus_hw_itypes[NUM_GBUS_IRQ_INITS];
 
index 2aa8ab0f7edcb4f1198ae67205b9f815fdb6beaa..143774de75e1a590ca83a82018f10706bfa09be5 100644 (file)
@@ -43,7 +43,7 @@ static struct v850e_intc_irq_init irq_inits[] = {
        { "ST",  IRQ_INTST(0),  IRQ_INTST_NUM,  4, 5 },
        { 0 }
 };
-#define NUM_IRQ_INITS ((sizeof irq_inits / sizeof irq_inits[0]) - 1)
+#define NUM_IRQ_INITS (ARRAY_SIZE(irq_inits) - 1)
 
 static struct hw_interrupt_type hw_itypes[NUM_IRQ_INITS];
 
index 14b0c8858aa46a8445dc44ee8f566316b0b04fbb..38be5c194f6b9a5ca782a2b71f07e66f60e0e7e3 100644 (file)
@@ -44,7 +44,7 @@ static struct v850e_intc_irq_init irq_inits[] = {
        { "UBTITO", IRQ_INTUBTITO(0), IRQ_INTUBTITO_NUM, 5, 4 },
        { 0 }
 };
-#define NUM_IRQ_INITS ((sizeof irq_inits / sizeof irq_inits[0]) - 1)
+#define NUM_IRQ_INITS (ARRAY_SIZE(irq_inits) - 1)
 
 static struct hw_interrupt_type hw_itypes[NUM_IRQ_INITS];
 
index 0f7f6cd705a2d1eae01fa817054e462a577ef917..43018e1edebd13b6bf84558ef32628c13056c0af 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/irq.h>
 #include <linux/fs.h>
 #include <linux/module.h>
+#include <linux/kernel.h>
 
 #include <asm/machdep.h>
 #include <asm/v850e_uart.h>
@@ -176,8 +177,7 @@ static struct gbus_int_irq_init gbus_irq_inits[] = {
 #endif
        { 0 }
 };
-#define NUM_GBUS_IRQ_INITS  \
-   ((sizeof gbus_irq_inits / sizeof gbus_irq_inits[0]) - 1)
+#define NUM_GBUS_IRQ_INITS (ARRAY_SIZE(gbus_irq_inits) - 1)
 
 static struct hw_interrupt_type gbus_hw_itypes[NUM_GBUS_IRQ_INITS];
 
index 35213fa9f7d829544c36e1223a6805df9cc4f004..35a4bd5515cb53c8903d612fc43ebda0a4cb5535 100644 (file)
@@ -70,8 +70,7 @@ static struct mb_pci_dev_irq mb_pci_dev_irqs[] = {
        /* PCI slot 2 */
        { 9,    IRQ_MB_A_PCI2(0),       1 }
 };
-#define NUM_MB_PCI_DEV_IRQS \
-  (sizeof mb_pci_dev_irqs / sizeof mb_pci_dev_irqs[0])
+#define NUM_MB_PCI_DEV_IRQS ARRAY_SIZE(mb_pci_dev_irqs)
 
 \f
 /* PCI configuration primitives.  */
index 3be355a029e27766c21f823661b435a524d06277..46803d48dffe2e5a14aec1c12813e8b6598f2465 100644 (file)
@@ -170,8 +170,7 @@ static struct cb_pic_irq_init cb_pic_irq_inits[] = {
        { "CB_EXTTM2",       IRQ_CB_EXTTM2,       1, 1, 6 },
        { 0 }
 };
-#define NUM_CB_PIC_IRQ_INITS  \
-   ((sizeof cb_pic_irq_inits / sizeof cb_pic_irq_inits[0]) - 1)
+#define NUM_CB_PIC_IRQ_INITS (ARRAY_SIZE(cb_pic_irq_inits) - 1)
 
 static struct hw_interrupt_type cb_pic_hw_itypes[NUM_CB_PIC_IRQ_INITS];
 static unsigned char cb_pic_active_irqs = 0;
index 290d506650166633a691aecd1c953cfeff75cd16..699248f92aae104d2a9091384a1798b5bfd73a42 100644 (file)
@@ -43,7 +43,7 @@ static struct v850e_intc_irq_init irq_inits[] = {
        { "ST",  IRQ_INTST(0),  IRQ_INTST_NUM,  1, 5 },
        { 0 }
 };
-#define NUM_IRQ_INITS ((sizeof irq_inits / sizeof irq_inits[0]) - 1)
+#define NUM_IRQ_INITS (ARRAY_SIZE(irq_inits) - 1)
 
 static struct hw_interrupt_type hw_itypes[NUM_IRQ_INITS];
 
index cd06f47c0ea7404bfd29f15f31e222ca9c2f5260..486e3a441c868d2ae97efd01fdab9d0e74de0b2e 100644 (file)
 
 #define TICK_SIZE      (tick_nsec / 1000)
 
-/*
- * Scheduler clock - returns current time in nanosec units.
- */
-unsigned long long sched_clock(void)
-{
-       return (unsigned long long)jiffies * (1000000000 / HZ);
-}
-
 /*
  * timer_interrupt() needs to keep up the real-time clock,
  * as well as call the "do_timer()" routine every clocktick
index 3a5fd07fe064cef52b7e0a7a0ec42bfb04192168..3563082212510b09eb92d922c2eedb28ea6d26ab 100644 (file)
                __root_fs_image_start = . ;                                   \
                *(.root)                                                      \
                __root_fs_image_end = . ;
+
+#ifdef CONFIG_BLK_DEV_INITRD
 /* The initramfs archive.  */
 #define INITRAMFS_CONTENTS                                                   \
                . = ALIGN (4) ;                                               \
                ___initramfs_start = . ;                                      \
                        *(.init.ramfs)                                        \
                ___initramfs_end = . ;
+#endif
+
 /* Where the initial bootmap (bitmap for the boot-time memory allocator) 
    should be place.  */
 #define BOOTMAP_CONTENTS                                                     \
index d4275537b25b6e8bc814f19215278da2633420f3..02dd39457bcf20cfb487dc1d34833427d714cce3 100644 (file)
@@ -44,6 +44,10 @@ config MMU
        bool
        default y
 
+config ZONE_DMA
+       bool
+       default y
+
 config ISA
        bool
 
index 5ce0bd486bbf35a90c31e4f9adb0cd918fb0f438..6efe04f3cbca8601bd39605d8e2085290953b73c 100644 (file)
@@ -300,12 +300,10 @@ int ia32_setup_arg_pages(struct linux_binprm *bprm, unsigned long stack_top,
                bprm->loader += stack_base;
        bprm->exec += stack_base;
 
-       mpnt = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
+       mpnt = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
        if (!mpnt) 
                return -ENOMEM; 
 
-       memset(mpnt, 0, sizeof(*mpnt));
-
        down_write(&mm->mmap_sem);
        {
                mpnt->vm_mm = mm;
index b4aa875e175becbaa59b27f6a1be2554b1f6aca1..5f32cf4de5fb56e54cd0f5210c10cc62e8306866 100644 (file)
@@ -515,7 +515,7 @@ ia32_sys_call_table:
        .quad sys32_vm86_warning        /* vm86old */ 
        .quad compat_sys_wait4
        .quad sys_swapoff               /* 115 */
-       .quad sys32_sysinfo
+       .quad compat_sys_sysinfo
        .quad sys32_ipc
        .quad sys_fsync
        .quad stub32_sigreturn
index c9bac3af29d6a746be28d38a241667e78593df3f..200fdde18d968e70ce5d7bf2832db7e683a4f448 100644 (file)
@@ -523,72 +523,6 @@ sys32_sysfs(int option, u32 arg1, u32 arg2)
        return sys_sysfs(option, arg1, arg2);
 }
 
-struct sysinfo32 {
-        s32 uptime;
-        u32 loads[3];
-        u32 totalram;
-        u32 freeram;
-        u32 sharedram;
-        u32 bufferram;
-        u32 totalswap;
-        u32 freeswap;
-        unsigned short procs;
-       unsigned short pad; 
-        u32 totalhigh;
-        u32 freehigh;
-        u32 mem_unit;
-        char _f[20-2*sizeof(u32)-sizeof(int)];
-};
-
-asmlinkage long
-sys32_sysinfo(struct sysinfo32 __user *info)
-{
-       struct sysinfo s;
-       int ret;
-       mm_segment_t old_fs = get_fs ();
-       int bitcount = 0;
-       
-       set_fs (KERNEL_DS);
-       ret = sys_sysinfo((struct sysinfo __user *)&s);
-       set_fs (old_fs);
-
-        /* Check to see if any memory value is too large for 32-bit and scale
-        *  down if needed
-        */
-       if ((s.totalram >> 32) || (s.totalswap >> 32)) {
-               while (s.mem_unit < PAGE_SIZE) {
-                       s.mem_unit <<= 1;
-                       bitcount++;
-               }
-               s.totalram >>= bitcount;
-               s.freeram >>= bitcount;
-               s.sharedram >>= bitcount;
-               s.bufferram >>= bitcount;
-               s.totalswap >>= bitcount;
-               s.freeswap >>= bitcount;
-               s.totalhigh >>= bitcount;
-               s.freehigh >>= bitcount;
-       }
-
-       if (!access_ok(VERIFY_WRITE, info, sizeof(struct sysinfo32)) ||
-           __put_user (s.uptime, &info->uptime) ||
-           __put_user (s.loads[0], &info->loads[0]) ||
-           __put_user (s.loads[1], &info->loads[1]) ||
-           __put_user (s.loads[2], &info->loads[2]) ||
-           __put_user (s.totalram, &info->totalram) ||
-           __put_user (s.freeram, &info->freeram) ||
-           __put_user (s.sharedram, &info->sharedram) ||
-           __put_user (s.bufferram, &info->bufferram) ||
-           __put_user (s.totalswap, &info->totalswap) ||
-           __put_user (s.freeswap, &info->freeswap) ||
-           __put_user (s.procs, &info->procs) ||
-           __put_user (s.totalhigh, &info->totalhigh) || 
-           __put_user (s.freehigh, &info->freehigh) ||
-           __put_user (s.mem_unit, &info->mem_unit))
-               return -EFAULT;
-       return 0;
-}
-                
 asmlinkage long
 sys32_sched_rr_get_interval(compat_pid_t pid, struct compat_timespec __user *interval)
 {
index 59f1fa1559151029d99f077d0861cd6bfd17392d..568ff0df89e7800412017c349e3e138aba5218fb 100644 (file)
@@ -18,68 +18,34 @@ extern unsigned char syscall32_syscall[], syscall32_syscall_end[];
 extern unsigned char syscall32_sysenter[], syscall32_sysenter_end[];
 extern int sysctl_vsyscall32;
 
-char *syscall32_page; 
+static struct page *syscall32_pages[1];
 static int use_sysenter = -1;
 
-static struct page *
-syscall32_nopage(struct vm_area_struct *vma, unsigned long adr, int *type)
-{
-       struct page *p = virt_to_page(adr - vma->vm_start + syscall32_page);
-       get_page(p);
-       return p;
-}
-
-/* Prevent VMA merging */
-static void syscall32_vma_close(struct vm_area_struct *vma)
-{
-}
-
-static struct vm_operations_struct syscall32_vm_ops = {
-       .close = syscall32_vma_close,
-       .nopage = syscall32_nopage,
-};
-
 struct linux_binprm;
 
 /* Setup a VMA at program startup for the vsyscall page */
 int syscall32_setup_pages(struct linux_binprm *bprm, int exstack)
 {
-       int npages = (VSYSCALL32_END - VSYSCALL32_BASE) >> PAGE_SHIFT;
-       struct vm_area_struct *vma;
        struct mm_struct *mm = current->mm;
        int ret;
 
-       vma = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
-       if (!vma)
-               return -ENOMEM;
-
-       memset(vma, 0, sizeof(struct vm_area_struct));
-       /* Could randomize here */
-       vma->vm_start = VSYSCALL32_BASE;
-       vma->vm_end = VSYSCALL32_END;
-       /* MAYWRITE to allow gdb to COW and set breakpoints */
-       vma->vm_flags = VM_READ|VM_EXEC|VM_MAYREAD|VM_MAYEXEC|VM_MAYWRITE;
+       down_write(&mm->mmap_sem);
        /*
+        * MAYWRITE to allow gdb to COW and set breakpoints
+        *
         * Make sure the vDSO gets into every core dump.
         * Dumping its contents makes post-mortem fully interpretable later
         * without matching up the same kernel and hardware config to see
         * what PC values meant.
         */
-       vma->vm_flags |= VM_ALWAYSDUMP;
-       vma->vm_flags |= mm->def_flags;
-       vma->vm_page_prot = protection_map[vma->vm_flags & 7];
-       vma->vm_ops = &syscall32_vm_ops;
-       vma->vm_mm = mm;
-
-       down_write(&mm->mmap_sem);
-       if ((ret = insert_vm_struct(mm, vma))) {
-               up_write(&mm->mmap_sem);
-               kmem_cache_free(vm_area_cachep, vma);
-               return ret;
-       }
-       mm->total_vm += npages;
+       /* Could randomize here */
+       ret = install_special_mapping(mm, VSYSCALL32_BASE, PAGE_SIZE,
+                                     VM_READ|VM_EXEC|
+                                     VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC|
+                                     VM_ALWAYSDUMP,
+                                     syscall32_pages);
        up_write(&mm->mmap_sem);
-       return 0;
+       return ret;
 }
 
 const char *arch_vma_name(struct vm_area_struct *vma)
@@ -92,9 +58,10 @@ const char *arch_vma_name(struct vm_area_struct *vma)
 
 static int __init init_syscall32(void)
 { 
-       syscall32_page = (void *)get_zeroed_page(GFP_KERNEL); 
+       char *syscall32_page = (void *)get_zeroed_page(GFP_KERNEL);
        if (!syscall32_page) 
                panic("Cannot allocate syscall32 page"); 
+       syscall32_pages[0] = virt_to_page(syscall32_page);
        if (use_sysenter > 0) {
                memcpy(syscall32_page, syscall32_sysenter,
                       syscall32_sysenter_end - syscall32_sysenter);
index fa09debad4b7c18b34966ebb3bd13bcca0937b9e..93c707257637cdea3b40eb472e7ab7baa442245f 100644 (file)
@@ -401,7 +401,6 @@ static __cpuinit int allocate_threshold_blocks(unsigned int cpu,
        b = kzalloc(sizeof(struct threshold_block), GFP_KERNEL);
        if (!b)
                return -ENOMEM;
-       memset(b, 0, sizeof(struct threshold_block));
 
        b->block = block;
        b->bank = bank;
@@ -490,7 +489,6 @@ static __cpuinit int threshold_create_bank(unsigned int cpu, unsigned int bank)
                err = -ENOMEM;
                goto out;
        }
-       memset(b, 0, sizeof(struct threshold_bank));
 
        kobject_set_name(&b->kobj, "threshold_bank%i", bank);
        b->kobj.parent = &per_cpu(device_mce, cpu).kobj;
index 1e54ddf2338d7347149a1d3300294ce5d07f88b9..c360c42252444ad83eb20165b4d5ae8967dd06c5 100644 (file)
@@ -192,10 +192,14 @@ SECTIONS
      from .altinstructions and .eh_frame */
   .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) { *(.exit.text) }
   .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) { *(.exit.data) }
+
+#ifdef CONFIG_BLK_DEV_INITRD
   . = ALIGN(4096);
   __initramfs_start = .;
   .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) { *(.init.ramfs) }
   __initramfs_end = .;
+#endif
+
     . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
   __per_cpu_start = .;
   .data.percpu  : AT(ADDR(.data.percpu) - LOAD_OFFSET) { *(.data.percpu) }
index a65fc6f1dcaff5ec3dd876a609a4f56fd3d7abf5..49e8cf2e06f8eca9d016386d8e91ec95c3de26b4 100644 (file)
@@ -69,27 +69,6 @@ static inline int notify_page_fault(enum die_val val, const char *str,
        return atomic_notifier_call_chain(&notify_page_fault_chain, val, &args);
 }
 
-void bust_spinlocks(int yes)
-{
-       int loglevel_save = console_loglevel;
-       if (yes) {
-               oops_in_progress = 1;
-       } else {
-#ifdef CONFIG_VT
-               unblank_screen();
-#endif
-               oops_in_progress = 0;
-               /*
-                * OK, the message is on the console.  Now we call printk()
-                * without oops_in_progress set so that printk will give klogd
-                * a poke.  Hold onto your hats...
-                */
-               console_loglevel = 15;          /* NMI oopser may have shut the console up */
-               printk(" ");
-               console_loglevel = loglevel_save;
-       }
-}
-
 /* Sometimes the CPU reports invalid exceptions on prefetch.
    Check that here and ignore.
    Opcode checker based on code by Richard Brunner */
index 2e74cb0b7807fd986fa4993e9baf4044f8c015f9..7fbb44bea37f85048ebb8c6c55e2a9063477083d 100644 (file)
@@ -7,6 +7,10 @@ config FRAME_POINTER
        bool
        default n
 
+config ZONE_DMA
+       bool
+       default y
+
 config XTENSA
        bool
        default y
@@ -42,6 +46,9 @@ config ARCH_HAS_ILOG2_U64
        bool
        default n
 
+config NO_IOPORT
+       def_bool y
+
 source "init/Kconfig"
 
 menu "Processor type and features"
index a350431363a0a8c56080c170ab5a7ff88db2c50d..22949be4a5d8cc3c5d62f93b8779a67c3ecd451f 100644 (file)
@@ -38,15 +38,6 @@ unsigned long ccount_nsec;           /* nsec per ccount increment */
 unsigned int last_ccount_stamp;
 static long last_rtc_update = 0;
 
-/*
- * Scheduler clock - returns current tim in nanosec units.
- */
-
-unsigned long long sched_clock(void)
-{
-       return (unsigned long long)jiffies * (1000000000 / HZ);
-}
-
 static irqreturn_t timer_interrupt(int irq, void *dev_id);
 static struct irqaction timer_irqaction = {
        .handler =      timer_interrupt,
index a36c104c3a5295a05e89a0ef1eaf1c0d27b8cfd1..ab6370054cee709cdfccff4850d6fcdefb24ce9d 100644 (file)
@@ -203,10 +203,12 @@ SECTIONS
   .data.percpu  : { *(.data.percpu) }
   __per_cpu_end = .;
 
+#ifdef CONFIG_BLK_DEV_INITRD
   . = ALIGN(4096);
   __initramfs_start =.;
   .init.ramfs : { *(.init.ramfs) }
   __initramfs_end = .;
+#endif
 
   /* We need this dummy segment here */
 
index d3679dd1d2201785e91194415d01736a16af54bc..d36b32ed22f4f7e5abf12112fbe95918115ae90f 100644 (file)
@@ -363,10 +363,9 @@ static int blk_trace_setup(request_queue_t *q, struct block_device *bdev,
        if (!bt->dropped_file)
                goto err;
 
-       bt->rchan = relay_open("trace", dir, buts.buf_size, buts.buf_nr, &blk_relay_callbacks);
+       bt->rchan = relay_open("trace", dir, buts.buf_size, buts.buf_nr, &blk_relay_callbacks, bt);
        if (!bt->rchan)
                goto err;
-       bt->rchan->private_data = bt;
 
        bt->act_mask = buts.act_mask;
        if (!bt->act_mask)
index f6962b64660ea67c6092c6303d7d52cd69bffbeb..e3f5eb9882cf4dfb403f6ca64f7262180b9db0fa 100644 (file)
@@ -61,7 +61,7 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user
                                }
                        }
                        /* all seems OK */
-                       add_partition(disk, part, start, length);
+                       add_partition(disk, part, start, length, ADDPART_FLAG_NONE);
                        mutex_unlock(&bdev->bd_mutex);
                        return 0;
                case BLKPG_DEL_PARTITION:
index fb6789725e1b681fc9cf67225b971baf2c2b10a3..38c293b987b77212bec48450dd1529d71a3f582f 100644 (file)
@@ -1264,7 +1264,7 @@ new_hw_segment:
        bio->bi_hw_segments = nr_hw_segs;
        bio->bi_flags |= (1 << BIO_SEG_VALID);
 }
-
+EXPORT_SYMBOL(blk_recount_segments);
 
 static int blk_phys_contig_segment(request_queue_t *q, struct bio *bio,
                                   struct bio *nxt)
index 918b4d845f935ba5dfa4be45f88134716845a7e5..086fcec44720cdd02f80b1539dac562caaea4476 100644 (file)
@@ -149,6 +149,15 @@ config CRYPTO_CBC
          CBC: Cipher Block Chaining mode
          This block cipher algorithm is required for IPSec.
 
+config CRYPTO_PCBC
+       tristate "PCBC support"
+       select CRYPTO_BLKCIPHER
+       select CRYPTO_MANAGER
+       default m
+       help
+         PCBC: Propagating Cipher Block Chaining mode
+         This block cipher algorithm is required for RxRPC.
+
 config CRYPTO_LRW
        tristate "LRW support (EXPERIMENTAL)"
        depends on EXPERIMENTAL
@@ -168,6 +177,13 @@ config CRYPTO_DES
        help
          DES cipher algorithm (FIPS 46-2), and Triple DES EDE (FIPS 46-3).
 
+config CRYPTO_FCRYPT
+       tristate "FCrypt cipher algorithm"
+       select CRYPTO_ALGAPI
+       select CRYPTO_BLKCIPHER
+       help
+         FCrypt algorithm used by RxRPC.
+
 config CRYPTO_BLOWFISH
        tristate "Blowfish cipher algorithm"
        select CRYPTO_ALGAPI
@@ -409,6 +425,21 @@ config CRYPTO_CRC32C
          See Castagnoli93.  This implementation uses lib/libcrc32c.
           Module will be crc32c.
 
+config CRYPTO_CAMELLIA
+       tristate "Camellia cipher algorithms"
+       depends on CRYPTO
+       select CRYPTO_ALGAPI
+       help
+         Camellia cipher algorithms module.
+
+         Camellia is a symmetric key block cipher developed jointly
+         at NTT and Mitsubishi Electric Corporation.
+
+         The Camellia specifies three key sizes: 128, 192 and 256 bits.
+
+         See also:
+         <https://info.isl.ntt.co.jp/crypt/eng/camellia/index_s.html>
+
 config CRYPTO_TEST
        tristate "Testing module"
        depends on m
index 60e3d24f61f56a28c9c2e91eb84a4cac05671366..12f93f578171daccd1bad404d8d28229bd450321 100644 (file)
@@ -27,13 +27,16 @@ obj-$(CONFIG_CRYPTO_TGR192) += tgr192.o
 obj-$(CONFIG_CRYPTO_GF128MUL) += gf128mul.o
 obj-$(CONFIG_CRYPTO_ECB) += ecb.o
 obj-$(CONFIG_CRYPTO_CBC) += cbc.o
+obj-$(CONFIG_CRYPTO_PCBC) += pcbc.o
 obj-$(CONFIG_CRYPTO_LRW) += lrw.o
 obj-$(CONFIG_CRYPTO_DES) += des.o
+obj-$(CONFIG_CRYPTO_FCRYPT) += fcrypt.o
 obj-$(CONFIG_CRYPTO_BLOWFISH) += blowfish.o
 obj-$(CONFIG_CRYPTO_TWOFISH) += twofish.o
 obj-$(CONFIG_CRYPTO_TWOFISH_COMMON) += twofish_common.o
 obj-$(CONFIG_CRYPTO_SERPENT) += serpent.o
 obj-$(CONFIG_CRYPTO_AES) += aes.o
+obj-$(CONFIG_CRYPTO_CAMELLIA) += camellia.o
 obj-$(CONFIG_CRYPTO_CAST5) += cast5.o
 obj-$(CONFIG_CRYPTO_CAST6) += cast6.o
 obj-$(CONFIG_CRYPTO_ARC4) += arc4.o
index c91530021e9ce6744b1382950eb9fed3d258d119..f7d2185b2c8fbac94cf6f6736b5f1a965f224bb9 100644 (file)
@@ -377,7 +377,8 @@ void crypto_drop_spawn(struct crypto_spawn *spawn)
 }
 EXPORT_SYMBOL_GPL(crypto_drop_spawn);
 
-struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn)
+struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn, u32 type,
+                                   u32 mask)
 {
        struct crypto_alg *alg;
        struct crypto_alg *alg2;
@@ -396,10 +397,18 @@ struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn)
                return ERR_PTR(-EAGAIN);
        }
 
-       tfm = __crypto_alloc_tfm(alg, 0);
+       tfm = ERR_PTR(-EINVAL);
+       if (unlikely((alg->cra_flags ^ type) & mask))
+               goto out_put_alg;
+
+       tfm = __crypto_alloc_tfm(alg, type, mask);
        if (IS_ERR(tfm))
-               crypto_mod_put(alg);
+               goto out_put_alg;
+
+       return tfm;
 
+out_put_alg:
+       crypto_mod_put(alg);
        return tfm;
 }
 EXPORT_SYMBOL_GPL(crypto_spawn_tfm);
index 8c446871cd5b13998294850338bb4ce93930f069..55af8bb0f0502eb7f80f3ed2c71fb21518319252 100644 (file)
@@ -212,31 +212,12 @@ struct crypto_alg *crypto_alg_mod_lookup(const char *name, u32 type, u32 mask)
 }
 EXPORT_SYMBOL_GPL(crypto_alg_mod_lookup);
 
-static int crypto_init_flags(struct crypto_tfm *tfm, u32 flags)
+static int crypto_init_ops(struct crypto_tfm *tfm, u32 type, u32 mask)
 {
-       tfm->crt_flags = flags & CRYPTO_TFM_REQ_MASK;
-       flags &= ~CRYPTO_TFM_REQ_MASK;
-       
-       switch (crypto_tfm_alg_type(tfm)) {
-       case CRYPTO_ALG_TYPE_CIPHER:
-               return crypto_init_cipher_flags(tfm, flags);
-               
-       case CRYPTO_ALG_TYPE_DIGEST:
-               return crypto_init_digest_flags(tfm, flags);
-               
-       case CRYPTO_ALG_TYPE_COMPRESS:
-               return crypto_init_compress_flags(tfm, flags);
-       }
-       
-       return 0;
-}
+       const struct crypto_type *type_obj = tfm->__crt_alg->cra_type;
 
-static int crypto_init_ops(struct crypto_tfm *tfm)
-{
-       const struct crypto_type *type = tfm->__crt_alg->cra_type;
-
-       if (type)
-               return type->init(tfm);
+       if (type_obj)
+               return type_obj->init(tfm, type, mask);
 
        switch (crypto_tfm_alg_type(tfm)) {
        case CRYPTO_ALG_TYPE_CIPHER:
@@ -285,29 +266,29 @@ static void crypto_exit_ops(struct crypto_tfm *tfm)
        }
 }
 
-static unsigned int crypto_ctxsize(struct crypto_alg *alg, int flags)
+static unsigned int crypto_ctxsize(struct crypto_alg *alg, u32 type, u32 mask)
 {
-       const struct crypto_type *type = alg->cra_type;
+       const struct crypto_type *type_obj = alg->cra_type;
        unsigned int len;
 
        len = alg->cra_alignmask & ~(crypto_tfm_ctx_alignment() - 1);
-       if (type)
-               return len + type->ctxsize(alg);
+       if (type_obj)
+               return len + type_obj->ctxsize(alg, type, mask);
 
        switch (alg->cra_flags & CRYPTO_ALG_TYPE_MASK) {
        default:
                BUG();
 
        case CRYPTO_ALG_TYPE_CIPHER:
-               len += crypto_cipher_ctxsize(alg, flags);
+               len += crypto_cipher_ctxsize(alg);
                break;
                
        case CRYPTO_ALG_TYPE_DIGEST:
-               len += crypto_digest_ctxsize(alg, flags);
+               len += crypto_digest_ctxsize(alg);
                break;
                
        case CRYPTO_ALG_TYPE_COMPRESS:
-               len += crypto_compress_ctxsize(alg, flags);
+               len += crypto_compress_ctxsize(alg);
                break;
        }
 
@@ -322,24 +303,21 @@ void crypto_shoot_alg(struct crypto_alg *alg)
 }
 EXPORT_SYMBOL_GPL(crypto_shoot_alg);
 
-struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg, u32 flags)
+struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg, u32 type,
+                                     u32 mask)
 {
        struct crypto_tfm *tfm = NULL;
        unsigned int tfm_size;
        int err = -ENOMEM;
 
-       tfm_size = sizeof(*tfm) + crypto_ctxsize(alg, flags);
+       tfm_size = sizeof(*tfm) + crypto_ctxsize(alg, type, mask);
        tfm = kzalloc(tfm_size, GFP_KERNEL);
        if (tfm == NULL)
                goto out_err;
 
        tfm->__crt_alg = alg;
 
-       err = crypto_init_flags(tfm, flags);
-       if (err)
-               goto out_free_tfm;
-               
-       err = crypto_init_ops(tfm);
+       err = crypto_init_ops(tfm, type, mask);
        if (err)
                goto out_free_tfm;
 
@@ -362,31 +340,6 @@ out:
 }
 EXPORT_SYMBOL_GPL(__crypto_alloc_tfm);
 
-struct crypto_tfm *crypto_alloc_tfm(const char *name, u32 flags)
-{
-       struct crypto_tfm *tfm = NULL;
-       int err;
-
-       do {
-               struct crypto_alg *alg;
-
-               alg = crypto_alg_mod_lookup(name, 0, CRYPTO_ALG_ASYNC);
-               err = PTR_ERR(alg);
-               if (IS_ERR(alg))
-                       continue;
-
-               tfm = __crypto_alloc_tfm(alg, flags);
-               err = 0;
-               if (IS_ERR(tfm)) {
-                       crypto_mod_put(alg);
-                       err = PTR_ERR(tfm);
-                       tfm = NULL;
-               }
-       } while (err == -EAGAIN && !signal_pending(current));
-
-       return tfm;
-}
-
 /*
  *     crypto_alloc_base - Locate algorithm and allocate transform
  *     @alg_name: Name of algorithm
@@ -420,7 +373,7 @@ struct crypto_tfm *crypto_alloc_base(const char *alg_name, u32 type, u32 mask)
                        goto err;
                }
 
-               tfm = __crypto_alloc_tfm(alg, 0);
+               tfm = __crypto_alloc_tfm(alg, type, mask);
                if (!IS_ERR(tfm))
                        return tfm;
 
@@ -466,7 +419,6 @@ void crypto_free_tfm(struct crypto_tfm *tfm)
        kfree(tfm);
 }
 
-EXPORT_SYMBOL_GPL(crypto_alloc_tfm);
 EXPORT_SYMBOL_GPL(crypto_free_tfm);
 
 int crypto_has_alg(const char *name, u32 type, u32 mask)
index 6e93004f2181ccb3f265994cf9806db528641796..b5befe8c3a96ee1a4c73b708823b76a2f9bb06bc 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <linux/crypto.h>
 #include <linux/errno.h>
+#include <linux/hardirq.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/scatterlist.h>
@@ -313,6 +314,9 @@ static int blkcipher_walk_first(struct blkcipher_desc *desc,
        struct crypto_blkcipher *tfm = desc->tfm;
        unsigned int alignmask = crypto_blkcipher_alignmask(tfm);
 
+       if (WARN_ON_ONCE(in_irq()))
+               return -EDEADLK;
+
        walk->nbytes = walk->total;
        if (unlikely(!walk->total))
                return 0;
@@ -345,7 +349,8 @@ static int setkey(struct crypto_tfm *tfm, const u8 *key,
        return cipher->setkey(tfm, key, keylen);
 }
 
-static unsigned int crypto_blkcipher_ctxsize(struct crypto_alg *alg)
+static unsigned int crypto_blkcipher_ctxsize(struct crypto_alg *alg, u32 type,
+                                            u32 mask)
 {
        struct blkcipher_alg *cipher = &alg->cra_blkcipher;
        unsigned int len = alg->cra_ctxsize;
@@ -358,7 +363,7 @@ static unsigned int crypto_blkcipher_ctxsize(struct crypto_alg *alg)
        return len;
 }
 
-static int crypto_init_blkcipher_ops(struct crypto_tfm *tfm)
+static int crypto_init_blkcipher_ops(struct crypto_tfm *tfm, u32 type, u32 mask)
 {
        struct blkcipher_tfm *crt = &tfm->crt_blkcipher;
        struct blkcipher_alg *alg = &tfm->__crt_alg->cra_blkcipher;
diff --git a/crypto/camellia.c b/crypto/camellia.c
new file mode 100644 (file)
index 0000000..6877ecf
--- /dev/null
@@ -0,0 +1,1801 @@
+/*
+ * Copyright (C) 2006
+ * NTT (Nippon Telegraph and Telephone Corporation).
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+/*
+ * Algorithm Specification
+ *  http://info.isl.ntt.co.jp/crypt/eng/camellia/specifications.html
+ */
+
+/*
+ *
+ * NOTE --- NOTE --- NOTE --- NOTE
+ * This implementation assumes that all memory addresses passed
+ * as parameters are four-byte aligned.
+ *
+ */
+
+#include <linux/crypto.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+
+
+#define CAMELLIA_MIN_KEY_SIZE        16
+#define CAMELLIA_MAX_KEY_SIZE        32
+#define CAMELLIA_BLOCK_SIZE 16
+#define CAMELLIA_TABLE_BYTE_LEN 272
+#define CAMELLIA_TABLE_WORD_LEN (CAMELLIA_TABLE_BYTE_LEN / 4)
+
+typedef u32 KEY_TABLE_TYPE[CAMELLIA_TABLE_WORD_LEN];
+
+
+/* key constants */
+
+#define CAMELLIA_SIGMA1L (0xA09E667FL)
+#define CAMELLIA_SIGMA1R (0x3BCC908BL)
+#define CAMELLIA_SIGMA2L (0xB67AE858L)
+#define CAMELLIA_SIGMA2R (0x4CAA73B2L)
+#define CAMELLIA_SIGMA3L (0xC6EF372FL)
+#define CAMELLIA_SIGMA3R (0xE94F82BEL)
+#define CAMELLIA_SIGMA4L (0x54FF53A5L)
+#define CAMELLIA_SIGMA4R (0xF1D36F1CL)
+#define CAMELLIA_SIGMA5L (0x10E527FAL)
+#define CAMELLIA_SIGMA5R (0xDE682D1DL)
+#define CAMELLIA_SIGMA6L (0xB05688C2L)
+#define CAMELLIA_SIGMA6R (0xB3E6C1FDL)
+
+struct camellia_ctx {
+       int key_length;
+       KEY_TABLE_TYPE key_table;
+};
+
+
+/*
+ *  macros
+ */
+
+
+# define GETU32(pt) (((u32)(pt)[0] << 24)      \
+                    ^ ((u32)(pt)[1] << 16)     \
+                    ^ ((u32)(pt)[2] <<  8)     \
+                    ^ ((u32)(pt)[3]))
+
+#define COPY4WORD(dst, src)                    \
+    do {                                       \
+       (dst)[0]=(src)[0];                      \
+       (dst)[1]=(src)[1];                      \
+       (dst)[2]=(src)[2];                      \
+       (dst)[3]=(src)[3];                      \
+    }while(0)
+
+#define SWAP4WORD(word)                                \
+    do {                                       \
+       CAMELLIA_SWAP4((word)[0]);              \
+       CAMELLIA_SWAP4((word)[1]);              \
+       CAMELLIA_SWAP4((word)[2]);              \
+       CAMELLIA_SWAP4((word)[3]);              \
+    }while(0)
+
+#define XOR4WORD(a, b)/* a = a ^ b */          \
+    do {                                       \
+       (a)[0]^=(b)[0];                         \
+       (a)[1]^=(b)[1];                         \
+       (a)[2]^=(b)[2];                         \
+       (a)[3]^=(b)[3];                         \
+    }while(0)
+
+#define XOR4WORD2(a, b, c)/* a = b ^ c */      \
+    do {                                       \
+       (a)[0]=(b)[0]^(c)[0];                   \
+       (a)[1]=(b)[1]^(c)[1];                   \
+       (a)[2]=(b)[2]^(c)[2];                   \
+       (a)[3]=(b)[3]^(c)[3];                   \
+    }while(0)
+
+#define CAMELLIA_SUBKEY_L(INDEX) (subkey[(INDEX)*2])
+#define CAMELLIA_SUBKEY_R(INDEX) (subkey[(INDEX)*2 + 1])
+
+/* rotation right shift 1byte */
+#define CAMELLIA_RR8(x) (((x) >> 8) + ((x) << 24))
+/* rotation left shift 1bit */
+#define CAMELLIA_RL1(x) (((x) << 1) + ((x) >> 31))
+/* rotation left shift 1byte */
+#define CAMELLIA_RL8(x) (((x) << 8) + ((x) >> 24))
+
+#define CAMELLIA_ROLDQ(ll, lr, rl, rr, w0, w1, bits)   \
+    do {                                               \
+       w0 = ll;                                        \
+       ll = (ll << bits) + (lr >> (32 - bits));        \
+       lr = (lr << bits) + (rl >> (32 - bits));        \
+       rl = (rl << bits) + (rr >> (32 - bits));        \
+       rr = (rr << bits) + (w0 >> (32 - bits));        \
+    } while(0)
+
+#define CAMELLIA_ROLDQo32(ll, lr, rl, rr, w0, w1, bits)        \
+    do {                                               \
+       w0 = ll;                                        \
+       w1 = lr;                                        \
+       ll = (lr << (bits - 32)) + (rl >> (64 - bits)); \
+       lr = (rl << (bits - 32)) + (rr >> (64 - bits)); \
+       rl = (rr << (bits - 32)) + (w0 >> (64 - bits)); \
+       rr = (w0 << (bits - 32)) + (w1 >> (64 - bits)); \
+    } while(0)
+
+#define CAMELLIA_SP1110(INDEX) (camellia_sp1110[(INDEX)])
+#define CAMELLIA_SP0222(INDEX) (camellia_sp0222[(INDEX)])
+#define CAMELLIA_SP3033(INDEX) (camellia_sp3033[(INDEX)])
+#define CAMELLIA_SP4404(INDEX) (camellia_sp4404[(INDEX)])
+
+#define CAMELLIA_F(xl, xr, kl, kr, yl, yr, il, ir, t0, t1)     \
+    do {                                                       \
+       il = xl ^ kl;                                           \
+       ir = xr ^ kr;                                           \
+       t0 = il >> 16;                                          \
+       t1 = ir >> 16;                                          \
+       yl = CAMELLIA_SP1110(ir & 0xff)                         \
+           ^ CAMELLIA_SP0222((t1 >> 8) & 0xff)                 \
+           ^ CAMELLIA_SP3033(t1 & 0xff)                        \
+           ^ CAMELLIA_SP4404((ir >> 8) & 0xff);                \
+       yr = CAMELLIA_SP1110((t0 >> 8) & 0xff)                  \
+           ^ CAMELLIA_SP0222(t0 & 0xff)                        \
+           ^ CAMELLIA_SP3033((il >> 8) & 0xff)                 \
+           ^ CAMELLIA_SP4404(il & 0xff);                       \
+       yl ^= yr;                                               \
+       yr = CAMELLIA_RR8(yr);                                  \
+       yr ^= yl;                                               \
+    } while(0)
+
+
+/*
+ * for speed up
+ *
+ */
+#define CAMELLIA_FLS(ll, lr, rl, rr, kll, klr, krl, krr, t0, t1, t2, t3) \
+    do {                                                               \
+       t0 = kll;                                                       \
+       t2 = krr;                                                       \
+       t0 &= ll;                                                       \
+       t2 |= rr;                                                       \
+       rl ^= t2;                                                       \
+       lr ^= CAMELLIA_RL1(t0);                                         \
+       t3 = krl;                                                       \
+       t1 = klr;                                                       \
+       t3 &= rl;                                                       \
+       t1 |= lr;                                                       \
+       ll ^= t1;                                                       \
+       rr ^= CAMELLIA_RL1(t3);                                         \
+    } while(0)
+
+#define CAMELLIA_ROUNDSM(xl, xr, kl, kr, yl, yr, il, ir, t0, t1)       \
+    do {                                                               \
+       ir =  CAMELLIA_SP1110(xr & 0xff);                               \
+       il =  CAMELLIA_SP1110((xl>>24) & 0xff);                         \
+       ir ^= CAMELLIA_SP0222((xr>>24) & 0xff);                         \
+       il ^= CAMELLIA_SP0222((xl>>16) & 0xff);                         \
+       ir ^= CAMELLIA_SP3033((xr>>16) & 0xff);                         \
+       il ^= CAMELLIA_SP3033((xl>>8) & 0xff);                          \
+       ir ^= CAMELLIA_SP4404((xr>>8) & 0xff);                          \
+       il ^= CAMELLIA_SP4404(xl & 0xff);                               \
+       il ^= kl;                                                       \
+       ir ^= il ^ kr;                                                  \
+       yl ^= ir;                                                       \
+       yr ^= CAMELLIA_RR8(il) ^ ir;                                    \
+    } while(0)
+
+/**
+ * Stuff related to the Camellia key schedule
+ */
+#define SUBL(x) subL[(x)]
+#define SUBR(x) subR[(x)]
+
+
+static const u32 camellia_sp1110[256] = {
+       0x70707000,0x82828200,0x2c2c2c00,0xececec00,
+       0xb3b3b300,0x27272700,0xc0c0c000,0xe5e5e500,
+       0xe4e4e400,0x85858500,0x57575700,0x35353500,
+       0xeaeaea00,0x0c0c0c00,0xaeaeae00,0x41414100,
+       0x23232300,0xefefef00,0x6b6b6b00,0x93939300,
+       0x45454500,0x19191900,0xa5a5a500,0x21212100,
+       0xededed00,0x0e0e0e00,0x4f4f4f00,0x4e4e4e00,
+       0x1d1d1d00,0x65656500,0x92929200,0xbdbdbd00,
+       0x86868600,0xb8b8b800,0xafafaf00,0x8f8f8f00,
+       0x7c7c7c00,0xebebeb00,0x1f1f1f00,0xcecece00,
+       0x3e3e3e00,0x30303000,0xdcdcdc00,0x5f5f5f00,
+       0x5e5e5e00,0xc5c5c500,0x0b0b0b00,0x1a1a1a00,
+       0xa6a6a600,0xe1e1e100,0x39393900,0xcacaca00,
+       0xd5d5d500,0x47474700,0x5d5d5d00,0x3d3d3d00,
+       0xd9d9d900,0x01010100,0x5a5a5a00,0xd6d6d600,
+       0x51515100,0x56565600,0x6c6c6c00,0x4d4d4d00,
+       0x8b8b8b00,0x0d0d0d00,0x9a9a9a00,0x66666600,
+       0xfbfbfb00,0xcccccc00,0xb0b0b000,0x2d2d2d00,
+       0x74747400,0x12121200,0x2b2b2b00,0x20202000,
+       0xf0f0f000,0xb1b1b100,0x84848400,0x99999900,
+       0xdfdfdf00,0x4c4c4c00,0xcbcbcb00,0xc2c2c200,
+       0x34343400,0x7e7e7e00,0x76767600,0x05050500,
+       0x6d6d6d00,0xb7b7b700,0xa9a9a900,0x31313100,
+       0xd1d1d100,0x17171700,0x04040400,0xd7d7d700,
+       0x14141400,0x58585800,0x3a3a3a00,0x61616100,
+       0xdedede00,0x1b1b1b00,0x11111100,0x1c1c1c00,
+       0x32323200,0x0f0f0f00,0x9c9c9c00,0x16161600,
+       0x53535300,0x18181800,0xf2f2f200,0x22222200,
+       0xfefefe00,0x44444400,0xcfcfcf00,0xb2b2b200,
+       0xc3c3c300,0xb5b5b500,0x7a7a7a00,0x91919100,
+       0x24242400,0x08080800,0xe8e8e800,0xa8a8a800,
+       0x60606000,0xfcfcfc00,0x69696900,0x50505000,
+       0xaaaaaa00,0xd0d0d000,0xa0a0a000,0x7d7d7d00,
+       0xa1a1a100,0x89898900,0x62626200,0x97979700,
+       0x54545400,0x5b5b5b00,0x1e1e1e00,0x95959500,
+       0xe0e0e000,0xffffff00,0x64646400,0xd2d2d200,
+       0x10101000,0xc4c4c400,0x00000000,0x48484800,
+       0xa3a3a300,0xf7f7f700,0x75757500,0xdbdbdb00,
+       0x8a8a8a00,0x03030300,0xe6e6e600,0xdadada00,
+       0x09090900,0x3f3f3f00,0xdddddd00,0x94949400,
+       0x87878700,0x5c5c5c00,0x83838300,0x02020200,
+       0xcdcdcd00,0x4a4a4a00,0x90909000,0x33333300,
+       0x73737300,0x67676700,0xf6f6f600,0xf3f3f300,
+       0x9d9d9d00,0x7f7f7f00,0xbfbfbf00,0xe2e2e200,
+       0x52525200,0x9b9b9b00,0xd8d8d800,0x26262600,
+       0xc8c8c800,0x37373700,0xc6c6c600,0x3b3b3b00,
+       0x81818100,0x96969600,0x6f6f6f00,0x4b4b4b00,
+       0x13131300,0xbebebe00,0x63636300,0x2e2e2e00,
+       0xe9e9e900,0x79797900,0xa7a7a700,0x8c8c8c00,
+       0x9f9f9f00,0x6e6e6e00,0xbcbcbc00,0x8e8e8e00,
+       0x29292900,0xf5f5f500,0xf9f9f900,0xb6b6b600,
+       0x2f2f2f00,0xfdfdfd00,0xb4b4b400,0x59595900,
+       0x78787800,0x98989800,0x06060600,0x6a6a6a00,
+       0xe7e7e700,0x46464600,0x71717100,0xbababa00,
+       0xd4d4d400,0x25252500,0xababab00,0x42424200,
+       0x88888800,0xa2a2a200,0x8d8d8d00,0xfafafa00,
+       0x72727200,0x07070700,0xb9b9b900,0x55555500,
+       0xf8f8f800,0xeeeeee00,0xacacac00,0x0a0a0a00,
+       0x36363600,0x49494900,0x2a2a2a00,0x68686800,
+       0x3c3c3c00,0x38383800,0xf1f1f100,0xa4a4a400,
+       0x40404000,0x28282800,0xd3d3d300,0x7b7b7b00,
+       0xbbbbbb00,0xc9c9c900,0x43434300,0xc1c1c100,
+       0x15151500,0xe3e3e300,0xadadad00,0xf4f4f400,
+       0x77777700,0xc7c7c700,0x80808000,0x9e9e9e00,
+};
+
+static const u32 camellia_sp0222[256] = {
+       0x00e0e0e0,0x00050505,0x00585858,0x00d9d9d9,
+       0x00676767,0x004e4e4e,0x00818181,0x00cbcbcb,
+       0x00c9c9c9,0x000b0b0b,0x00aeaeae,0x006a6a6a,
+       0x00d5d5d5,0x00181818,0x005d5d5d,0x00828282,
+       0x00464646,0x00dfdfdf,0x00d6d6d6,0x00272727,
+       0x008a8a8a,0x00323232,0x004b4b4b,0x00424242,
+       0x00dbdbdb,0x001c1c1c,0x009e9e9e,0x009c9c9c,
+       0x003a3a3a,0x00cacaca,0x00252525,0x007b7b7b,
+       0x000d0d0d,0x00717171,0x005f5f5f,0x001f1f1f,
+       0x00f8f8f8,0x00d7d7d7,0x003e3e3e,0x009d9d9d,
+       0x007c7c7c,0x00606060,0x00b9b9b9,0x00bebebe,
+       0x00bcbcbc,0x008b8b8b,0x00161616,0x00343434,
+       0x004d4d4d,0x00c3c3c3,0x00727272,0x00959595,
+       0x00ababab,0x008e8e8e,0x00bababa,0x007a7a7a,
+       0x00b3b3b3,0x00020202,0x00b4b4b4,0x00adadad,
+       0x00a2a2a2,0x00acacac,0x00d8d8d8,0x009a9a9a,
+       0x00171717,0x001a1a1a,0x00353535,0x00cccccc,
+       0x00f7f7f7,0x00999999,0x00616161,0x005a5a5a,
+       0x00e8e8e8,0x00242424,0x00565656,0x00404040,
+       0x00e1e1e1,0x00636363,0x00090909,0x00333333,
+       0x00bfbfbf,0x00989898,0x00979797,0x00858585,
+       0x00686868,0x00fcfcfc,0x00ececec,0x000a0a0a,
+       0x00dadada,0x006f6f6f,0x00535353,0x00626262,
+       0x00a3a3a3,0x002e2e2e,0x00080808,0x00afafaf,
+       0x00282828,0x00b0b0b0,0x00747474,0x00c2c2c2,
+       0x00bdbdbd,0x00363636,0x00222222,0x00383838,
+       0x00646464,0x001e1e1e,0x00393939,0x002c2c2c,
+       0x00a6a6a6,0x00303030,0x00e5e5e5,0x00444444,
+       0x00fdfdfd,0x00888888,0x009f9f9f,0x00656565,
+       0x00878787,0x006b6b6b,0x00f4f4f4,0x00232323,
+       0x00484848,0x00101010,0x00d1d1d1,0x00515151,
+       0x00c0c0c0,0x00f9f9f9,0x00d2d2d2,0x00a0a0a0,
+       0x00555555,0x00a1a1a1,0x00414141,0x00fafafa,
+       0x00434343,0x00131313,0x00c4c4c4,0x002f2f2f,
+       0x00a8a8a8,0x00b6b6b6,0x003c3c3c,0x002b2b2b,
+       0x00c1c1c1,0x00ffffff,0x00c8c8c8,0x00a5a5a5,
+       0x00202020,0x00898989,0x00000000,0x00909090,
+       0x00474747,0x00efefef,0x00eaeaea,0x00b7b7b7,
+       0x00151515,0x00060606,0x00cdcdcd,0x00b5b5b5,
+       0x00121212,0x007e7e7e,0x00bbbbbb,0x00292929,
+       0x000f0f0f,0x00b8b8b8,0x00070707,0x00040404,
+       0x009b9b9b,0x00949494,0x00212121,0x00666666,
+       0x00e6e6e6,0x00cecece,0x00ededed,0x00e7e7e7,
+       0x003b3b3b,0x00fefefe,0x007f7f7f,0x00c5c5c5,
+       0x00a4a4a4,0x00373737,0x00b1b1b1,0x004c4c4c,
+       0x00919191,0x006e6e6e,0x008d8d8d,0x00767676,
+       0x00030303,0x002d2d2d,0x00dedede,0x00969696,
+       0x00262626,0x007d7d7d,0x00c6c6c6,0x005c5c5c,
+       0x00d3d3d3,0x00f2f2f2,0x004f4f4f,0x00191919,
+       0x003f3f3f,0x00dcdcdc,0x00797979,0x001d1d1d,
+       0x00525252,0x00ebebeb,0x00f3f3f3,0x006d6d6d,
+       0x005e5e5e,0x00fbfbfb,0x00696969,0x00b2b2b2,
+       0x00f0f0f0,0x00313131,0x000c0c0c,0x00d4d4d4,
+       0x00cfcfcf,0x008c8c8c,0x00e2e2e2,0x00757575,
+       0x00a9a9a9,0x004a4a4a,0x00575757,0x00848484,
+       0x00111111,0x00454545,0x001b1b1b,0x00f5f5f5,
+       0x00e4e4e4,0x000e0e0e,0x00737373,0x00aaaaaa,
+       0x00f1f1f1,0x00dddddd,0x00595959,0x00141414,
+       0x006c6c6c,0x00929292,0x00545454,0x00d0d0d0,
+       0x00787878,0x00707070,0x00e3e3e3,0x00494949,
+       0x00808080,0x00505050,0x00a7a7a7,0x00f6f6f6,
+       0x00777777,0x00939393,0x00868686,0x00838383,
+       0x002a2a2a,0x00c7c7c7,0x005b5b5b,0x00e9e9e9,
+       0x00eeeeee,0x008f8f8f,0x00010101,0x003d3d3d,
+};
+
+static const u32 camellia_sp3033[256] = {
+       0x38003838,0x41004141,0x16001616,0x76007676,
+       0xd900d9d9,0x93009393,0x60006060,0xf200f2f2,
+       0x72007272,0xc200c2c2,0xab00abab,0x9a009a9a,
+       0x75007575,0x06000606,0x57005757,0xa000a0a0,
+       0x91009191,0xf700f7f7,0xb500b5b5,0xc900c9c9,
+       0xa200a2a2,0x8c008c8c,0xd200d2d2,0x90009090,
+       0xf600f6f6,0x07000707,0xa700a7a7,0x27002727,
+       0x8e008e8e,0xb200b2b2,0x49004949,0xde00dede,
+       0x43004343,0x5c005c5c,0xd700d7d7,0xc700c7c7,
+       0x3e003e3e,0xf500f5f5,0x8f008f8f,0x67006767,
+       0x1f001f1f,0x18001818,0x6e006e6e,0xaf00afaf,
+       0x2f002f2f,0xe200e2e2,0x85008585,0x0d000d0d,
+       0x53005353,0xf000f0f0,0x9c009c9c,0x65006565,
+       0xea00eaea,0xa300a3a3,0xae00aeae,0x9e009e9e,
+       0xec00ecec,0x80008080,0x2d002d2d,0x6b006b6b,
+       0xa800a8a8,0x2b002b2b,0x36003636,0xa600a6a6,
+       0xc500c5c5,0x86008686,0x4d004d4d,0x33003333,
+       0xfd00fdfd,0x66006666,0x58005858,0x96009696,
+       0x3a003a3a,0x09000909,0x95009595,0x10001010,
+       0x78007878,0xd800d8d8,0x42004242,0xcc00cccc,
+       0xef00efef,0x26002626,0xe500e5e5,0x61006161,
+       0x1a001a1a,0x3f003f3f,0x3b003b3b,0x82008282,
+       0xb600b6b6,0xdb00dbdb,0xd400d4d4,0x98009898,
+       0xe800e8e8,0x8b008b8b,0x02000202,0xeb00ebeb,
+       0x0a000a0a,0x2c002c2c,0x1d001d1d,0xb000b0b0,
+       0x6f006f6f,0x8d008d8d,0x88008888,0x0e000e0e,
+       0x19001919,0x87008787,0x4e004e4e,0x0b000b0b,
+       0xa900a9a9,0x0c000c0c,0x79007979,0x11001111,
+       0x7f007f7f,0x22002222,0xe700e7e7,0x59005959,
+       0xe100e1e1,0xda00dada,0x3d003d3d,0xc800c8c8,
+       0x12001212,0x04000404,0x74007474,0x54005454,
+       0x30003030,0x7e007e7e,0xb400b4b4,0x28002828,
+       0x55005555,0x68006868,0x50005050,0xbe00bebe,
+       0xd000d0d0,0xc400c4c4,0x31003131,0xcb00cbcb,
+       0x2a002a2a,0xad00adad,0x0f000f0f,0xca00caca,
+       0x70007070,0xff00ffff,0x32003232,0x69006969,
+       0x08000808,0x62006262,0x00000000,0x24002424,
+       0xd100d1d1,0xfb00fbfb,0xba00baba,0xed00eded,
+       0x45004545,0x81008181,0x73007373,0x6d006d6d,
+       0x84008484,0x9f009f9f,0xee00eeee,0x4a004a4a,
+       0xc300c3c3,0x2e002e2e,0xc100c1c1,0x01000101,
+       0xe600e6e6,0x25002525,0x48004848,0x99009999,
+       0xb900b9b9,0xb300b3b3,0x7b007b7b,0xf900f9f9,
+       0xce00cece,0xbf00bfbf,0xdf00dfdf,0x71007171,
+       0x29002929,0xcd00cdcd,0x6c006c6c,0x13001313,
+       0x64006464,0x9b009b9b,0x63006363,0x9d009d9d,
+       0xc000c0c0,0x4b004b4b,0xb700b7b7,0xa500a5a5,
+       0x89008989,0x5f005f5f,0xb100b1b1,0x17001717,
+       0xf400f4f4,0xbc00bcbc,0xd300d3d3,0x46004646,
+       0xcf00cfcf,0x37003737,0x5e005e5e,0x47004747,
+       0x94009494,0xfa00fafa,0xfc00fcfc,0x5b005b5b,
+       0x97009797,0xfe00fefe,0x5a005a5a,0xac00acac,
+       0x3c003c3c,0x4c004c4c,0x03000303,0x35003535,
+       0xf300f3f3,0x23002323,0xb800b8b8,0x5d005d5d,
+       0x6a006a6a,0x92009292,0xd500d5d5,0x21002121,
+       0x44004444,0x51005151,0xc600c6c6,0x7d007d7d,
+       0x39003939,0x83008383,0xdc00dcdc,0xaa00aaaa,
+       0x7c007c7c,0x77007777,0x56005656,0x05000505,
+       0x1b001b1b,0xa400a4a4,0x15001515,0x34003434,
+       0x1e001e1e,0x1c001c1c,0xf800f8f8,0x52005252,
+       0x20002020,0x14001414,0xe900e9e9,0xbd00bdbd,
+       0xdd00dddd,0xe400e4e4,0xa100a1a1,0xe000e0e0,
+       0x8a008a8a,0xf100f1f1,0xd600d6d6,0x7a007a7a,
+       0xbb00bbbb,0xe300e3e3,0x40004040,0x4f004f4f,
+};
+
+static const u32 camellia_sp4404[256] = {
+       0x70700070,0x2c2c002c,0xb3b300b3,0xc0c000c0,
+       0xe4e400e4,0x57570057,0xeaea00ea,0xaeae00ae,
+       0x23230023,0x6b6b006b,0x45450045,0xa5a500a5,
+       0xeded00ed,0x4f4f004f,0x1d1d001d,0x92920092,
+       0x86860086,0xafaf00af,0x7c7c007c,0x1f1f001f,
+       0x3e3e003e,0xdcdc00dc,0x5e5e005e,0x0b0b000b,
+       0xa6a600a6,0x39390039,0xd5d500d5,0x5d5d005d,
+       0xd9d900d9,0x5a5a005a,0x51510051,0x6c6c006c,
+       0x8b8b008b,0x9a9a009a,0xfbfb00fb,0xb0b000b0,
+       0x74740074,0x2b2b002b,0xf0f000f0,0x84840084,
+       0xdfdf00df,0xcbcb00cb,0x34340034,0x76760076,
+       0x6d6d006d,0xa9a900a9,0xd1d100d1,0x04040004,
+       0x14140014,0x3a3a003a,0xdede00de,0x11110011,
+       0x32320032,0x9c9c009c,0x53530053,0xf2f200f2,
+       0xfefe00fe,0xcfcf00cf,0xc3c300c3,0x7a7a007a,
+       0x24240024,0xe8e800e8,0x60600060,0x69690069,
+       0xaaaa00aa,0xa0a000a0,0xa1a100a1,0x62620062,
+       0x54540054,0x1e1e001e,0xe0e000e0,0x64640064,
+       0x10100010,0x00000000,0xa3a300a3,0x75750075,
+       0x8a8a008a,0xe6e600e6,0x09090009,0xdddd00dd,
+       0x87870087,0x83830083,0xcdcd00cd,0x90900090,
+       0x73730073,0xf6f600f6,0x9d9d009d,0xbfbf00bf,
+       0x52520052,0xd8d800d8,0xc8c800c8,0xc6c600c6,
+       0x81810081,0x6f6f006f,0x13130013,0x63630063,
+       0xe9e900e9,0xa7a700a7,0x9f9f009f,0xbcbc00bc,
+       0x29290029,0xf9f900f9,0x2f2f002f,0xb4b400b4,
+       0x78780078,0x06060006,0xe7e700e7,0x71710071,
+       0xd4d400d4,0xabab00ab,0x88880088,0x8d8d008d,
+       0x72720072,0xb9b900b9,0xf8f800f8,0xacac00ac,
+       0x36360036,0x2a2a002a,0x3c3c003c,0xf1f100f1,
+       0x40400040,0xd3d300d3,0xbbbb00bb,0x43430043,
+       0x15150015,0xadad00ad,0x77770077,0x80800080,
+       0x82820082,0xecec00ec,0x27270027,0xe5e500e5,
+       0x85850085,0x35350035,0x0c0c000c,0x41410041,
+       0xefef00ef,0x93930093,0x19190019,0x21210021,
+       0x0e0e000e,0x4e4e004e,0x65650065,0xbdbd00bd,
+       0xb8b800b8,0x8f8f008f,0xebeb00eb,0xcece00ce,
+       0x30300030,0x5f5f005f,0xc5c500c5,0x1a1a001a,
+       0xe1e100e1,0xcaca00ca,0x47470047,0x3d3d003d,
+       0x01010001,0xd6d600d6,0x56560056,0x4d4d004d,
+       0x0d0d000d,0x66660066,0xcccc00cc,0x2d2d002d,
+       0x12120012,0x20200020,0xb1b100b1,0x99990099,
+       0x4c4c004c,0xc2c200c2,0x7e7e007e,0x05050005,
+       0xb7b700b7,0x31310031,0x17170017,0xd7d700d7,
+       0x58580058,0x61610061,0x1b1b001b,0x1c1c001c,
+       0x0f0f000f,0x16160016,0x18180018,0x22220022,
+       0x44440044,0xb2b200b2,0xb5b500b5,0x91910091,
+       0x08080008,0xa8a800a8,0xfcfc00fc,0x50500050,
+       0xd0d000d0,0x7d7d007d,0x89890089,0x97970097,
+       0x5b5b005b,0x95950095,0xffff00ff,0xd2d200d2,
+       0xc4c400c4,0x48480048,0xf7f700f7,0xdbdb00db,
+       0x03030003,0xdada00da,0x3f3f003f,0x94940094,
+       0x5c5c005c,0x02020002,0x4a4a004a,0x33330033,
+       0x67670067,0xf3f300f3,0x7f7f007f,0xe2e200e2,
+       0x9b9b009b,0x26260026,0x37370037,0x3b3b003b,
+       0x96960096,0x4b4b004b,0xbebe00be,0x2e2e002e,
+       0x79790079,0x8c8c008c,0x6e6e006e,0x8e8e008e,
+       0xf5f500f5,0xb6b600b6,0xfdfd00fd,0x59590059,
+       0x98980098,0x6a6a006a,0x46460046,0xbaba00ba,
+       0x25250025,0x42420042,0xa2a200a2,0xfafa00fa,
+       0x07070007,0x55550055,0xeeee00ee,0x0a0a000a,
+       0x49490049,0x68680068,0x38380038,0xa4a400a4,
+       0x28280028,0x7b7b007b,0xc9c900c9,0xc1c100c1,
+       0xe3e300e3,0xf4f400f4,0xc7c700c7,0x9e9e009e,
+};
+
+
+
+static void camellia_setup128(const unsigned char *key, u32 *subkey)
+{
+       u32 kll, klr, krl, krr;
+       u32 il, ir, t0, t1, w0, w1;
+       u32 kw4l, kw4r, dw, tl, tr;
+       u32 subL[26];
+       u32 subR[26];
+
+       /**
+        *  k == kll || klr || krl || krr (|| is concatination)
+        */
+       kll = GETU32(key     );
+       klr = GETU32(key +  4);
+       krl = GETU32(key +  8);
+       krr = GETU32(key + 12);
+       /**
+        * generate KL dependent subkeys
+        */
+       /* kw1 */
+       SUBL(0) = kll; SUBR(0) = klr;
+       /* kw2 */
+       SUBL(1) = krl; SUBR(1) = krr;
+       /* rotation left shift 15bit */
+       CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 15);
+       /* k3 */
+       SUBL(4) = kll; SUBR(4) = klr;
+       /* k4 */
+       SUBL(5) = krl; SUBR(5) = krr;
+       /* rotation left shift 15+30bit */
+       CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 30);
+       /* k7 */
+       SUBL(10) = kll; SUBR(10) = klr;
+       /* k8 */
+       SUBL(11) = krl; SUBR(11) = krr;
+       /* rotation left shift 15+30+15bit */
+       CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 15);
+       /* k10 */
+       SUBL(13) = krl; SUBR(13) = krr;
+       /* rotation left shift 15+30+15+17 bit */
+       CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 17);
+       /* kl3 */
+       SUBL(16) = kll; SUBR(16) = klr;
+       /* kl4 */
+       SUBL(17) = krl; SUBR(17) = krr;
+       /* rotation left shift 15+30+15+17+17 bit */
+       CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 17);
+       /* k13 */
+       SUBL(18) = kll; SUBR(18) = klr;
+       /* k14 */
+       SUBL(19) = krl; SUBR(19) = krr;
+       /* rotation left shift 15+30+15+17+17+17 bit */
+       CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 17);
+       /* k17 */
+       SUBL(22) = kll; SUBR(22) = klr;
+       /* k18 */
+       SUBL(23) = krl; SUBR(23) = krr;
+
+       /* generate KA */
+       kll = SUBL(0); klr = SUBR(0);
+       krl = SUBL(1); krr = SUBR(1);
+       CAMELLIA_F(kll, klr,
+                  CAMELLIA_SIGMA1L, CAMELLIA_SIGMA1R,
+                  w0, w1, il, ir, t0, t1);
+       krl ^= w0; krr ^= w1;
+       CAMELLIA_F(krl, krr,
+                  CAMELLIA_SIGMA2L, CAMELLIA_SIGMA2R,
+                  kll, klr, il, ir, t0, t1);
+       /* current status == (kll, klr, w0, w1) */
+       CAMELLIA_F(kll, klr,
+                  CAMELLIA_SIGMA3L, CAMELLIA_SIGMA3R,
+                  krl, krr, il, ir, t0, t1);
+       krl ^= w0; krr ^= w1;
+       CAMELLIA_F(krl, krr,
+                  CAMELLIA_SIGMA4L, CAMELLIA_SIGMA4R,
+                  w0, w1, il, ir, t0, t1);
+       kll ^= w0; klr ^= w1;
+
+       /* generate KA dependent subkeys */
+       /* k1, k2 */
+       SUBL(2) = kll; SUBR(2) = klr;
+       SUBL(3) = krl; SUBR(3) = krr;
+       CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 15);
+       /* k5,k6 */
+       SUBL(6) = kll; SUBR(6) = klr;
+       SUBL(7) = krl; SUBR(7) = krr;
+       CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 15);
+       /* kl1, kl2 */
+       SUBL(8) = kll; SUBR(8) = klr;
+       SUBL(9) = krl; SUBR(9) = krr;
+       CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 15);
+       /* k9 */
+       SUBL(12) = kll; SUBR(12) = klr;
+       CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 15);
+       /* k11, k12 */
+       SUBL(14) = kll; SUBR(14) = klr;
+       SUBL(15) = krl; SUBR(15) = krr;
+       CAMELLIA_ROLDQo32(kll, klr, krl, krr, w0, w1, 34);
+       /* k15, k16 */
+       SUBL(20) = kll; SUBR(20) = klr;
+       SUBL(21) = krl; SUBR(21) = krr;
+       CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 17);
+       /* kw3, kw4 */
+       SUBL(24) = kll; SUBR(24) = klr;
+       SUBL(25) = krl; SUBR(25) = krr;
+
+
+       /* absorb kw2 to other subkeys */
+       /* round 2 */
+       SUBL(3) ^= SUBL(1); SUBR(3) ^= SUBR(1);
+       /* round 4 */
+       SUBL(5) ^= SUBL(1); SUBR(5) ^= SUBR(1);
+       /* round 6 */
+       SUBL(7) ^= SUBL(1); SUBR(7) ^= SUBR(1);
+       SUBL(1) ^= SUBR(1) & ~SUBR(9);
+       dw = SUBL(1) & SUBL(9),
+               SUBR(1) ^= CAMELLIA_RL1(dw); /* modified for FLinv(kl2) */
+       /* round 8 */
+       SUBL(11) ^= SUBL(1); SUBR(11) ^= SUBR(1);
+       /* round 10 */
+       SUBL(13) ^= SUBL(1); SUBR(13) ^= SUBR(1);
+       /* round 12 */
+       SUBL(15) ^= SUBL(1); SUBR(15) ^= SUBR(1);
+       SUBL(1) ^= SUBR(1) & ~SUBR(17);
+       dw = SUBL(1) & SUBL(17),
+               SUBR(1) ^= CAMELLIA_RL1(dw); /* modified for FLinv(kl4) */
+       /* round 14 */
+       SUBL(19) ^= SUBL(1); SUBR(19) ^= SUBR(1);
+       /* round 16 */
+       SUBL(21) ^= SUBL(1); SUBR(21) ^= SUBR(1);
+       /* round 18 */
+       SUBL(23) ^= SUBL(1); SUBR(23) ^= SUBR(1);
+       /* kw3 */
+       SUBL(24) ^= SUBL(1); SUBR(24) ^= SUBR(1);
+
+       /* absorb kw4 to other subkeys */
+       kw4l = SUBL(25); kw4r = SUBR(25);
+       /* round 17 */
+       SUBL(22) ^= kw4l; SUBR(22) ^= kw4r;
+       /* round 15 */
+       SUBL(20) ^= kw4l; SUBR(20) ^= kw4r;
+       /* round 13 */
+       SUBL(18) ^= kw4l; SUBR(18) ^= kw4r;
+       kw4l ^= kw4r & ~SUBR(16);
+       dw = kw4l & SUBL(16),
+               kw4r ^= CAMELLIA_RL1(dw); /* modified for FL(kl3) */
+       /* round 11 */
+       SUBL(14) ^= kw4l; SUBR(14) ^= kw4r;
+       /* round 9 */
+       SUBL(12) ^= kw4l; SUBR(12) ^= kw4r;
+       /* round 7 */
+       SUBL(10) ^= kw4l; SUBR(10) ^= kw4r;
+       kw4l ^= kw4r & ~SUBR(8);
+       dw = kw4l & SUBL(8),
+               kw4r ^= CAMELLIA_RL1(dw); /* modified for FL(kl1) */
+       /* round 5 */
+       SUBL(6) ^= kw4l; SUBR(6) ^= kw4r;
+       /* round 3 */
+       SUBL(4) ^= kw4l; SUBR(4) ^= kw4r;
+       /* round 1 */
+       SUBL(2) ^= kw4l; SUBR(2) ^= kw4r;
+       /* kw1 */
+       SUBL(0) ^= kw4l; SUBR(0) ^= kw4r;
+
+
+       /* key XOR is end of F-function */
+       CAMELLIA_SUBKEY_L(0) = SUBL(0) ^ SUBL(2);/* kw1 */
+       CAMELLIA_SUBKEY_R(0) = SUBR(0) ^ SUBR(2);
+       CAMELLIA_SUBKEY_L(2) = SUBL(3);       /* round 1 */
+       CAMELLIA_SUBKEY_R(2) = SUBR(3);
+       CAMELLIA_SUBKEY_L(3) = SUBL(2) ^ SUBL(4); /* round 2 */
+       CAMELLIA_SUBKEY_R(3) = SUBR(2) ^ SUBR(4);
+       CAMELLIA_SUBKEY_L(4) = SUBL(3) ^ SUBL(5); /* round 3 */
+       CAMELLIA_SUBKEY_R(4) = SUBR(3) ^ SUBR(5);
+       CAMELLIA_SUBKEY_L(5) = SUBL(4) ^ SUBL(6); /* round 4 */
+       CAMELLIA_SUBKEY_R(5) = SUBR(4) ^ SUBR(6);
+       CAMELLIA_SUBKEY_L(6) = SUBL(5) ^ SUBL(7); /* round 5 */
+       CAMELLIA_SUBKEY_R(6) = SUBR(5) ^ SUBR(7);
+       tl = SUBL(10) ^ (SUBR(10) & ~SUBR(8));
+       dw = tl & SUBL(8),  /* FL(kl1) */
+               tr = SUBR(10) ^ CAMELLIA_RL1(dw);
+       CAMELLIA_SUBKEY_L(7) = SUBL(6) ^ tl; /* round 6 */
+       CAMELLIA_SUBKEY_R(7) = SUBR(6) ^ tr;
+       CAMELLIA_SUBKEY_L(8) = SUBL(8);       /* FL(kl1) */
+       CAMELLIA_SUBKEY_R(8) = SUBR(8);
+       CAMELLIA_SUBKEY_L(9) = SUBL(9);       /* FLinv(kl2) */
+       CAMELLIA_SUBKEY_R(9) = SUBR(9);
+       tl = SUBL(7) ^ (SUBR(7) & ~SUBR(9));
+       dw = tl & SUBL(9),  /* FLinv(kl2) */
+               tr = SUBR(7) ^ CAMELLIA_RL1(dw);
+       CAMELLIA_SUBKEY_L(10) = tl ^ SUBL(11); /* round 7 */
+       CAMELLIA_SUBKEY_R(10) = tr ^ SUBR(11);
+       CAMELLIA_SUBKEY_L(11) = SUBL(10) ^ SUBL(12); /* round 8 */
+       CAMELLIA_SUBKEY_R(11) = SUBR(10) ^ SUBR(12);
+       CAMELLIA_SUBKEY_L(12) = SUBL(11) ^ SUBL(13); /* round 9 */
+       CAMELLIA_SUBKEY_R(12) = SUBR(11) ^ SUBR(13);
+       CAMELLIA_SUBKEY_L(13) = SUBL(12) ^ SUBL(14); /* round 10 */
+       CAMELLIA_SUBKEY_R(13) = SUBR(12) ^ SUBR(14);
+       CAMELLIA_SUBKEY_L(14) = SUBL(13) ^ SUBL(15); /* round 11 */
+       CAMELLIA_SUBKEY_R(14) = SUBR(13) ^ SUBR(15);
+       tl = SUBL(18) ^ (SUBR(18) & ~SUBR(16));
+       dw = tl & SUBL(16), /* FL(kl3) */
+               tr = SUBR(18) ^ CAMELLIA_RL1(dw);
+       CAMELLIA_SUBKEY_L(15) = SUBL(14) ^ tl; /* round 12 */
+       CAMELLIA_SUBKEY_R(15) = SUBR(14) ^ tr;
+       CAMELLIA_SUBKEY_L(16) = SUBL(16);     /* FL(kl3) */
+       CAMELLIA_SUBKEY_R(16) = SUBR(16);
+       CAMELLIA_SUBKEY_L(17) = SUBL(17);     /* FLinv(kl4) */
+       CAMELLIA_SUBKEY_R(17) = SUBR(17);
+       tl = SUBL(15) ^ (SUBR(15) & ~SUBR(17));
+       dw = tl & SUBL(17), /* FLinv(kl4) */
+               tr = SUBR(15) ^ CAMELLIA_RL1(dw);
+       CAMELLIA_SUBKEY_L(18) = tl ^ SUBL(19); /* round 13 */
+       CAMELLIA_SUBKEY_R(18) = tr ^ SUBR(19);
+       CAMELLIA_SUBKEY_L(19) = SUBL(18) ^ SUBL(20); /* round 14 */
+       CAMELLIA_SUBKEY_R(19) = SUBR(18) ^ SUBR(20);
+       CAMELLIA_SUBKEY_L(20) = SUBL(19) ^ SUBL(21); /* round 15 */
+       CAMELLIA_SUBKEY_R(20) = SUBR(19) ^ SUBR(21);
+       CAMELLIA_SUBKEY_L(21) = SUBL(20) ^ SUBL(22); /* round 16 */
+       CAMELLIA_SUBKEY_R(21) = SUBR(20) ^ SUBR(22);
+       CAMELLIA_SUBKEY_L(22) = SUBL(21) ^ SUBL(23); /* round 17 */
+       CAMELLIA_SUBKEY_R(22) = SUBR(21) ^ SUBR(23);
+       CAMELLIA_SUBKEY_L(23) = SUBL(22);     /* round 18 */
+       CAMELLIA_SUBKEY_R(23) = SUBR(22);
+       CAMELLIA_SUBKEY_L(24) = SUBL(24) ^ SUBL(23); /* kw3 */
+       CAMELLIA_SUBKEY_R(24) = SUBR(24) ^ SUBR(23);
+
+       /* apply the inverse of the last half of P-function */
+       dw = CAMELLIA_SUBKEY_L(2) ^ CAMELLIA_SUBKEY_R(2),
+               dw = CAMELLIA_RL8(dw);/* round 1 */
+       CAMELLIA_SUBKEY_R(2) = CAMELLIA_SUBKEY_L(2) ^ dw,
+               CAMELLIA_SUBKEY_L(2) = dw;
+       dw = CAMELLIA_SUBKEY_L(3) ^ CAMELLIA_SUBKEY_R(3),
+               dw = CAMELLIA_RL8(dw);/* round 2 */
+       CAMELLIA_SUBKEY_R(3) = CAMELLIA_SUBKEY_L(3) ^ dw,
+               CAMELLIA_SUBKEY_L(3) = dw;
+       dw = CAMELLIA_SUBKEY_L(4) ^ CAMELLIA_SUBKEY_R(4),
+               dw = CAMELLIA_RL8(dw);/* round 3 */
+       CAMELLIA_SUBKEY_R(4) = CAMELLIA_SUBKEY_L(4) ^ dw,
+               CAMELLIA_SUBKEY_L(4) = dw;
+       dw = CAMELLIA_SUBKEY_L(5) ^ CAMELLIA_SUBKEY_R(5),
+               dw = CAMELLIA_RL8(dw);/* round 4 */
+       CAMELLIA_SUBKEY_R(5) = CAMELLIA_SUBKEY_L(5) ^ dw,
+               CAMELLIA_SUBKEY_L(5) = dw;
+       dw = CAMELLIA_SUBKEY_L(6) ^ CAMELLIA_SUBKEY_R(6),
+               dw = CAMELLIA_RL8(dw);/* round 5 */
+       CAMELLIA_SUBKEY_R(6) = CAMELLIA_SUBKEY_L(6) ^ dw,
+               CAMELLIA_SUBKEY_L(6) = dw;
+       dw = CAMELLIA_SUBKEY_L(7) ^ CAMELLIA_SUBKEY_R(7),
+               dw = CAMELLIA_RL8(dw);/* round 6 */
+       CAMELLIA_SUBKEY_R(7) = CAMELLIA_SUBKEY_L(7) ^ dw,
+               CAMELLIA_SUBKEY_L(7) = dw;
+       dw = CAMELLIA_SUBKEY_L(10) ^ CAMELLIA_SUBKEY_R(10),
+               dw = CAMELLIA_RL8(dw);/* round 7 */
+       CAMELLIA_SUBKEY_R(10) = CAMELLIA_SUBKEY_L(10) ^ dw,
+               CAMELLIA_SUBKEY_L(10) = dw;
+       dw = CAMELLIA_SUBKEY_L(11) ^ CAMELLIA_SUBKEY_R(11),
+               dw = CAMELLIA_RL8(dw);/* round 8 */
+       CAMELLIA_SUBKEY_R(11) = CAMELLIA_SUBKEY_L(11) ^ dw,
+               CAMELLIA_SUBKEY_L(11) = dw;
+       dw = CAMELLIA_SUBKEY_L(12) ^ CAMELLIA_SUBKEY_R(12),
+               dw = CAMELLIA_RL8(dw);/* round 9 */
+       CAMELLIA_SUBKEY_R(12) = CAMELLIA_SUBKEY_L(12) ^ dw,
+               CAMELLIA_SUBKEY_L(12) = dw;
+       dw = CAMELLIA_SUBKEY_L(13) ^ CAMELLIA_SUBKEY_R(13),
+               dw = CAMELLIA_RL8(dw);/* round 10 */
+       CAMELLIA_SUBKEY_R(13) = CAMELLIA_SUBKEY_L(13) ^ dw,
+               CAMELLIA_SUBKEY_L(13) = dw;
+       dw = CAMELLIA_SUBKEY_L(14) ^ CAMELLIA_SUBKEY_R(14),
+               dw = CAMELLIA_RL8(dw);/* round 11 */
+       CAMELLIA_SUBKEY_R(14) = CAMELLIA_SUBKEY_L(14) ^ dw,
+               CAMELLIA_SUBKEY_L(14) = dw;
+       dw = CAMELLIA_SUBKEY_L(15) ^ CAMELLIA_SUBKEY_R(15),
+               dw = CAMELLIA_RL8(dw);/* round 12 */
+       CAMELLIA_SUBKEY_R(15) = CAMELLIA_SUBKEY_L(15) ^ dw,
+               CAMELLIA_SUBKEY_L(15) = dw;
+       dw = CAMELLIA_SUBKEY_L(18) ^ CAMELLIA_SUBKEY_R(18),
+               dw = CAMELLIA_RL8(dw);/* round 13 */
+       CAMELLIA_SUBKEY_R(18) = CAMELLIA_SUBKEY_L(18) ^ dw,
+               CAMELLIA_SUBKEY_L(18) = dw;
+       dw = CAMELLIA_SUBKEY_L(19) ^ CAMELLIA_SUBKEY_R(19),
+               dw = CAMELLIA_RL8(dw);/* round 14 */
+       CAMELLIA_SUBKEY_R(19) = CAMELLIA_SUBKEY_L(19) ^ dw,
+               CAMELLIA_SUBKEY_L(19) = dw;
+       dw = CAMELLIA_SUBKEY_L(20) ^ CAMELLIA_SUBKEY_R(20),
+               dw = CAMELLIA_RL8(dw);/* round 15 */
+       CAMELLIA_SUBKEY_R(20) = CAMELLIA_SUBKEY_L(20) ^ dw,
+               CAMELLIA_SUBKEY_L(20) = dw;
+       dw = CAMELLIA_SUBKEY_L(21) ^ CAMELLIA_SUBKEY_R(21),
+               dw = CAMELLIA_RL8(dw);/* round 16 */
+       CAMELLIA_SUBKEY_R(21) = CAMELLIA_SUBKEY_L(21) ^ dw,
+               CAMELLIA_SUBKEY_L(21) = dw;
+       dw = CAMELLIA_SUBKEY_L(22) ^ CAMELLIA_SUBKEY_R(22),
+               dw = CAMELLIA_RL8(dw);/* round 17 */
+       CAMELLIA_SUBKEY_R(22) = CAMELLIA_SUBKEY_L(22) ^ dw,
+               CAMELLIA_SUBKEY_L(22) = dw;
+       dw = CAMELLIA_SUBKEY_L(23) ^ CAMELLIA_SUBKEY_R(23),
+               dw = CAMELLIA_RL8(dw);/* round 18 */
+       CAMELLIA_SUBKEY_R(23) = CAMELLIA_SUBKEY_L(23) ^ dw,
+               CAMELLIA_SUBKEY_L(23) = dw;
+
+       return;
+}
+
+
+static void camellia_setup256(const unsigned char *key, u32 *subkey)
+{
+       u32 kll,klr,krl,krr;           /* left half of key */
+       u32 krll,krlr,krrl,krrr;       /* right half of key */
+       u32 il, ir, t0, t1, w0, w1;    /* temporary variables */
+       u32 kw4l, kw4r, dw, tl, tr;
+       u32 subL[34];
+       u32 subR[34];
+
+       /**
+        *  key = (kll || klr || krl || krr || krll || krlr || krrl || krrr)
+        *  (|| is concatination)
+        */
+
+       kll  = GETU32(key     );
+       klr  = GETU32(key +  4);
+       krl  = GETU32(key +  8);
+       krr  = GETU32(key + 12);
+       krll = GETU32(key + 16);
+       krlr = GETU32(key + 20);
+       krrl = GETU32(key + 24);
+       krrr = GETU32(key + 28);
+
+       /* generate KL dependent subkeys */
+       /* kw1 */
+       SUBL(0) = kll; SUBR(0) = klr;
+       /* kw2 */
+       SUBL(1) = krl; SUBR(1) = krr;
+       CAMELLIA_ROLDQo32(kll, klr, krl, krr, w0, w1, 45);
+       /* k9 */
+       SUBL(12) = kll; SUBR(12) = klr;
+       /* k10 */
+       SUBL(13) = krl; SUBR(13) = krr;
+       CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 15);
+       /* kl3 */
+       SUBL(16) = kll; SUBR(16) = klr;
+       /* kl4 */
+       SUBL(17) = krl; SUBR(17) = krr;
+       CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 17);
+       /* k17 */
+       SUBL(22) = kll; SUBR(22) = klr;
+       /* k18 */
+       SUBL(23) = krl; SUBR(23) = krr;
+       CAMELLIA_ROLDQo32(kll, klr, krl, krr, w0, w1, 34);
+       /* k23 */
+       SUBL(30) = kll; SUBR(30) = klr;
+       /* k24 */
+       SUBL(31) = krl; SUBR(31) = krr;
+
+       /* generate KR dependent subkeys */
+       CAMELLIA_ROLDQ(krll, krlr, krrl, krrr, w0, w1, 15);
+       /* k3 */
+       SUBL(4) = krll; SUBR(4) = krlr;
+       /* k4 */
+       SUBL(5) = krrl; SUBR(5) = krrr;
+       CAMELLIA_ROLDQ(krll, krlr, krrl, krrr, w0, w1, 15);
+       /* kl1 */
+       SUBL(8) = krll; SUBR(8) = krlr;
+       /* kl2 */
+       SUBL(9) = krrl; SUBR(9) = krrr;
+       CAMELLIA_ROLDQ(krll, krlr, krrl, krrr, w0, w1, 30);
+       /* k13 */
+       SUBL(18) = krll; SUBR(18) = krlr;
+       /* k14 */
+       SUBL(19) = krrl; SUBR(19) = krrr;
+       CAMELLIA_ROLDQo32(krll, krlr, krrl, krrr, w0, w1, 34);
+       /* k19 */
+       SUBL(26) = krll; SUBR(26) = krlr;
+       /* k20 */
+       SUBL(27) = krrl; SUBR(27) = krrr;
+       CAMELLIA_ROLDQo32(krll, krlr, krrl, krrr, w0, w1, 34);
+
+       /* generate KA */
+       kll = SUBL(0) ^ krll; klr = SUBR(0) ^ krlr;
+       krl = SUBL(1) ^ krrl; krr = SUBR(1) ^ krrr;
+       CAMELLIA_F(kll, klr,
+                  CAMELLIA_SIGMA1L, CAMELLIA_SIGMA1R,
+                  w0, w1, il, ir, t0, t1);
+       krl ^= w0; krr ^= w1;
+       CAMELLIA_F(krl, krr,
+                  CAMELLIA_SIGMA2L, CAMELLIA_SIGMA2R,
+                  kll, klr, il, ir, t0, t1);
+       kll ^= krll; klr ^= krlr;
+       CAMELLIA_F(kll, klr,
+                  CAMELLIA_SIGMA3L, CAMELLIA_SIGMA3R,
+                  krl, krr, il, ir, t0, t1);
+       krl ^= w0 ^ krrl; krr ^= w1 ^ krrr;
+       CAMELLIA_F(krl, krr,
+                  CAMELLIA_SIGMA4L, CAMELLIA_SIGMA4R,
+                  w0, w1, il, ir, t0, t1);
+       kll ^= w0; klr ^= w1;
+
+       /* generate KB */
+       krll ^= kll; krlr ^= klr;
+       krrl ^= krl; krrr ^= krr;
+       CAMELLIA_F(krll, krlr,
+                  CAMELLIA_SIGMA5L, CAMELLIA_SIGMA5R,
+                  w0, w1, il, ir, t0, t1);
+       krrl ^= w0; krrr ^= w1;
+       CAMELLIA_F(krrl, krrr,
+                  CAMELLIA_SIGMA6L, CAMELLIA_SIGMA6R,
+                  w0, w1, il, ir, t0, t1);
+       krll ^= w0; krlr ^= w1;
+
+       /* generate KA dependent subkeys */
+       CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 15);
+       /* k5 */
+       SUBL(6) = kll; SUBR(6) = klr;
+       /* k6 */
+       SUBL(7) = krl; SUBR(7) = krr;
+       CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 30);
+       /* k11 */
+       SUBL(14) = kll; SUBR(14) = klr;
+       /* k12 */
+       SUBL(15) = krl; SUBR(15) = krr;
+       /* rotation left shift 32bit */
+       /* kl5 */
+       SUBL(24) = klr; SUBR(24) = krl;
+       /* kl6 */
+       SUBL(25) = krr; SUBR(25) = kll;
+       /* rotation left shift 49 from k11,k12 -> k21,k22 */
+       CAMELLIA_ROLDQo32(kll, klr, krl, krr, w0, w1, 49);
+       /* k21 */
+       SUBL(28) = kll; SUBR(28) = klr;
+       /* k22 */
+       SUBL(29) = krl; SUBR(29) = krr;
+
+       /* generate KB dependent subkeys */
+       /* k1 */
+       SUBL(2) = krll; SUBR(2) = krlr;
+       /* k2 */
+       SUBL(3) = krrl; SUBR(3) = krrr;
+       CAMELLIA_ROLDQ(krll, krlr, krrl, krrr, w0, w1, 30);
+       /* k7 */
+       SUBL(10) = krll; SUBR(10) = krlr;
+       /* k8 */
+       SUBL(11) = krrl; SUBR(11) = krrr;
+       CAMELLIA_ROLDQ(krll, krlr, krrl, krrr, w0, w1, 30);
+       /* k15 */
+       SUBL(20) = krll; SUBR(20) = krlr;
+       /* k16 */
+       SUBL(21) = krrl; SUBR(21) = krrr;
+       CAMELLIA_ROLDQo32(krll, krlr, krrl, krrr, w0, w1, 51);
+       /* kw3 */
+       SUBL(32) = krll; SUBR(32) = krlr;
+       /* kw4 */
+       SUBL(33) = krrl; SUBR(33) = krrr;
+
+       /* absorb kw2 to other subkeys */
+       /* round 2 */
+       SUBL(3) ^= SUBL(1); SUBR(3) ^= SUBR(1);
+       /* round 4 */
+       SUBL(5) ^= SUBL(1); SUBR(5) ^= SUBR(1);
+       /* round 6 */
+       SUBL(7) ^= SUBL(1); SUBR(7) ^= SUBR(1);
+       SUBL(1) ^= SUBR(1) & ~SUBR(9);
+       dw = SUBL(1) & SUBL(9),
+               SUBR(1) ^= CAMELLIA_RL1(dw); /* modified for FLinv(kl2) */
+       /* round 8 */
+       SUBL(11) ^= SUBL(1); SUBR(11) ^= SUBR(1);
+       /* round 10 */
+       SUBL(13) ^= SUBL(1); SUBR(13) ^= SUBR(1);
+       /* round 12 */
+       SUBL(15) ^= SUBL(1); SUBR(15) ^= SUBR(1);
+       SUBL(1) ^= SUBR(1) & ~SUBR(17);
+       dw = SUBL(1) & SUBL(17),
+               SUBR(1) ^= CAMELLIA_RL1(dw); /* modified for FLinv(kl4) */
+       /* round 14 */
+       SUBL(19) ^= SUBL(1); SUBR(19) ^= SUBR(1);
+       /* round 16 */
+       SUBL(21) ^= SUBL(1); SUBR(21) ^= SUBR(1);
+       /* round 18 */
+       SUBL(23) ^= SUBL(1); SUBR(23) ^= SUBR(1);
+       SUBL(1) ^= SUBR(1) & ~SUBR(25);
+       dw = SUBL(1) & SUBL(25),
+               SUBR(1) ^= CAMELLIA_RL1(dw); /* modified for FLinv(kl6) */
+       /* round 20 */
+       SUBL(27) ^= SUBL(1); SUBR(27) ^= SUBR(1);
+       /* round 22 */
+       SUBL(29) ^= SUBL(1); SUBR(29) ^= SUBR(1);
+       /* round 24 */
+       SUBL(31) ^= SUBL(1); SUBR(31) ^= SUBR(1);
+       /* kw3 */
+       SUBL(32) ^= SUBL(1); SUBR(32) ^= SUBR(1);
+
+
+       /* absorb kw4 to other subkeys */
+       kw4l = SUBL(33); kw4r = SUBR(33);
+       /* round 23 */
+       SUBL(30) ^= kw4l; SUBR(30) ^= kw4r;
+       /* round 21 */
+       SUBL(28) ^= kw4l; SUBR(28) ^= kw4r;
+       /* round 19 */
+       SUBL(26) ^= kw4l; SUBR(26) ^= kw4r;
+       kw4l ^= kw4r & ~SUBR(24);
+       dw = kw4l & SUBL(24),
+               kw4r ^= CAMELLIA_RL1(dw); /* modified for FL(kl5) */
+       /* round 17 */
+       SUBL(22) ^= kw4l; SUBR(22) ^= kw4r;
+       /* round 15 */
+       SUBL(20) ^= kw4l; SUBR(20) ^= kw4r;
+       /* round 13 */
+       SUBL(18) ^= kw4l; SUBR(18) ^= kw4r;
+       kw4l ^= kw4r & ~SUBR(16);
+       dw = kw4l & SUBL(16),
+               kw4r ^= CAMELLIA_RL1(dw); /* modified for FL(kl3) */
+       /* round 11 */
+       SUBL(14) ^= kw4l; SUBR(14) ^= kw4r;
+       /* round 9 */
+       SUBL(12) ^= kw4l; SUBR(12) ^= kw4r;
+       /* round 7 */
+       SUBL(10) ^= kw4l; SUBR(10) ^= kw4r;
+       kw4l ^= kw4r & ~SUBR(8);
+       dw = kw4l & SUBL(8),
+               kw4r ^= CAMELLIA_RL1(dw); /* modified for FL(kl1) */
+       /* round 5 */
+       SUBL(6) ^= kw4l; SUBR(6) ^= kw4r;
+       /* round 3 */
+       SUBL(4) ^= kw4l; SUBR(4) ^= kw4r;
+       /* round 1 */
+       SUBL(2) ^= kw4l; SUBR(2) ^= kw4r;
+       /* kw1 */
+       SUBL(0) ^= kw4l; SUBR(0) ^= kw4r;
+
+       /* key XOR is end of F-function */
+       CAMELLIA_SUBKEY_L(0) = SUBL(0) ^ SUBL(2);/* kw1 */
+       CAMELLIA_SUBKEY_R(0) = SUBR(0) ^ SUBR(2);
+       CAMELLIA_SUBKEY_L(2) = SUBL(3);       /* round 1 */
+       CAMELLIA_SUBKEY_R(2) = SUBR(3);
+       CAMELLIA_SUBKEY_L(3) = SUBL(2) ^ SUBL(4); /* round 2 */
+       CAMELLIA_SUBKEY_R(3) = SUBR(2) ^ SUBR(4);
+       CAMELLIA_SUBKEY_L(4) = SUBL(3) ^ SUBL(5); /* round 3 */
+       CAMELLIA_SUBKEY_R(4) = SUBR(3) ^ SUBR(5);
+       CAMELLIA_SUBKEY_L(5) = SUBL(4) ^ SUBL(6); /* round 4 */
+       CAMELLIA_SUBKEY_R(5) = SUBR(4) ^ SUBR(6);
+       CAMELLIA_SUBKEY_L(6) = SUBL(5) ^ SUBL(7); /* round 5 */
+       CAMELLIA_SUBKEY_R(6) = SUBR(5) ^ SUBR(7);
+       tl = SUBL(10) ^ (SUBR(10) & ~SUBR(8));
+       dw = tl & SUBL(8),  /* FL(kl1) */
+               tr = SUBR(10) ^ CAMELLIA_RL1(dw);
+       CAMELLIA_SUBKEY_L(7) = SUBL(6) ^ tl; /* round 6 */
+       CAMELLIA_SUBKEY_R(7) = SUBR(6) ^ tr;
+       CAMELLIA_SUBKEY_L(8) = SUBL(8);       /* FL(kl1) */
+       CAMELLIA_SUBKEY_R(8) = SUBR(8);
+       CAMELLIA_SUBKEY_L(9) = SUBL(9);       /* FLinv(kl2) */
+       CAMELLIA_SUBKEY_R(9) = SUBR(9);
+       tl = SUBL(7) ^ (SUBR(7) & ~SUBR(9));
+       dw = tl & SUBL(9),  /* FLinv(kl2) */
+               tr = SUBR(7) ^ CAMELLIA_RL1(dw);
+       CAMELLIA_SUBKEY_L(10) = tl ^ SUBL(11); /* round 7 */
+       CAMELLIA_SUBKEY_R(10) = tr ^ SUBR(11);
+       CAMELLIA_SUBKEY_L(11) = SUBL(10) ^ SUBL(12); /* round 8 */
+       CAMELLIA_SUBKEY_R(11) = SUBR(10) ^ SUBR(12);
+       CAMELLIA_SUBKEY_L(12) = SUBL(11) ^ SUBL(13); /* round 9 */
+       CAMELLIA_SUBKEY_R(12) = SUBR(11) ^ SUBR(13);
+       CAMELLIA_SUBKEY_L(13) = SUBL(12) ^ SUBL(14); /* round 10 */
+       CAMELLIA_SUBKEY_R(13) = SUBR(12) ^ SUBR(14);
+       CAMELLIA_SUBKEY_L(14) = SUBL(13) ^ SUBL(15); /* round 11 */
+       CAMELLIA_SUBKEY_R(14) = SUBR(13) ^ SUBR(15);
+       tl = SUBL(18) ^ (SUBR(18) & ~SUBR(16));
+       dw = tl & SUBL(16), /* FL(kl3) */
+               tr = SUBR(18) ^ CAMELLIA_RL1(dw);
+       CAMELLIA_SUBKEY_L(15) = SUBL(14) ^ tl; /* round 12 */
+       CAMELLIA_SUBKEY_R(15) = SUBR(14) ^ tr;
+       CAMELLIA_SUBKEY_L(16) = SUBL(16);     /* FL(kl3) */
+       CAMELLIA_SUBKEY_R(16) = SUBR(16);
+       CAMELLIA_SUBKEY_L(17) = SUBL(17);     /* FLinv(kl4) */
+       CAMELLIA_SUBKEY_R(17) = SUBR(17);
+       tl = SUBL(15) ^ (SUBR(15) & ~SUBR(17));
+       dw = tl & SUBL(17), /* FLinv(kl4) */
+               tr = SUBR(15) ^ CAMELLIA_RL1(dw);
+       CAMELLIA_SUBKEY_L(18) = tl ^ SUBL(19); /* round 13 */
+       CAMELLIA_SUBKEY_R(18) = tr ^ SUBR(19);
+       CAMELLIA_SUBKEY_L(19) = SUBL(18) ^ SUBL(20); /* round 14 */
+       CAMELLIA_SUBKEY_R(19) = SUBR(18) ^ SUBR(20);
+       CAMELLIA_SUBKEY_L(20) = SUBL(19) ^ SUBL(21); /* round 15 */
+       CAMELLIA_SUBKEY_R(20) = SUBR(19) ^ SUBR(21);
+       CAMELLIA_SUBKEY_L(21) = SUBL(20) ^ SUBL(22); /* round 16 */
+       CAMELLIA_SUBKEY_R(21) = SUBR(20) ^ SUBR(22);
+       CAMELLIA_SUBKEY_L(22) = SUBL(21) ^ SUBL(23); /* round 17 */
+       CAMELLIA_SUBKEY_R(22) = SUBR(21) ^ SUBR(23);
+       tl = SUBL(26) ^ (SUBR(26)
+                        & ~SUBR(24));
+       dw = tl & SUBL(24), /* FL(kl5) */
+               tr = SUBR(26) ^ CAMELLIA_RL1(dw);
+       CAMELLIA_SUBKEY_L(23) = SUBL(22) ^ tl; /* round 18 */
+       CAMELLIA_SUBKEY_R(23) = SUBR(22) ^ tr;
+       CAMELLIA_SUBKEY_L(24) = SUBL(24);     /* FL(kl5) */
+       CAMELLIA_SUBKEY_R(24) = SUBR(24);
+       CAMELLIA_SUBKEY_L(25) = SUBL(25);     /* FLinv(kl6) */
+       CAMELLIA_SUBKEY_R(25) = SUBR(25);
+       tl = SUBL(23) ^ (SUBR(23) &
+                        ~SUBR(25));
+       dw = tl & SUBL(25), /* FLinv(kl6) */
+               tr = SUBR(23) ^ CAMELLIA_RL1(dw);
+       CAMELLIA_SUBKEY_L(26) = tl ^ SUBL(27); /* round 19 */
+       CAMELLIA_SUBKEY_R(26) = tr ^ SUBR(27);
+       CAMELLIA_SUBKEY_L(27) = SUBL(26) ^ SUBL(28); /* round 20 */
+       CAMELLIA_SUBKEY_R(27) = SUBR(26) ^ SUBR(28);
+       CAMELLIA_SUBKEY_L(28) = SUBL(27) ^ SUBL(29); /* round 21 */
+       CAMELLIA_SUBKEY_R(28) = SUBR(27) ^ SUBR(29);
+       CAMELLIA_SUBKEY_L(29) = SUBL(28) ^ SUBL(30); /* round 22 */
+       CAMELLIA_SUBKEY_R(29) = SUBR(28) ^ SUBR(30);
+       CAMELLIA_SUBKEY_L(30) = SUBL(29) ^ SUBL(31); /* round 23 */
+       CAMELLIA_SUBKEY_R(30) = SUBR(29) ^ SUBR(31);
+       CAMELLIA_SUBKEY_L(31) = SUBL(30);     /* round 24 */
+       CAMELLIA_SUBKEY_R(31) = SUBR(30);
+       CAMELLIA_SUBKEY_L(32) = SUBL(32) ^ SUBL(31); /* kw3 */
+       CAMELLIA_SUBKEY_R(32) = SUBR(32) ^ SUBR(31);
+
+       /* apply the inverse of the last half of P-function */
+       dw = CAMELLIA_SUBKEY_L(2) ^ CAMELLIA_SUBKEY_R(2),
+               dw = CAMELLIA_RL8(dw);/* round 1 */
+       CAMELLIA_SUBKEY_R(2) = CAMELLIA_SUBKEY_L(2) ^ dw,
+               CAMELLIA_SUBKEY_L(2) = dw;
+       dw = CAMELLIA_SUBKEY_L(3) ^ CAMELLIA_SUBKEY_R(3),
+               dw = CAMELLIA_RL8(dw);/* round 2 */
+       CAMELLIA_SUBKEY_R(3) = CAMELLIA_SUBKEY_L(3) ^ dw,
+               CAMELLIA_SUBKEY_L(3) = dw;
+       dw = CAMELLIA_SUBKEY_L(4) ^ CAMELLIA_SUBKEY_R(4),
+               dw = CAMELLIA_RL8(dw);/* round 3 */
+       CAMELLIA_SUBKEY_R(4) = CAMELLIA_SUBKEY_L(4) ^ dw,
+               CAMELLIA_SUBKEY_L(4) = dw;
+       dw = CAMELLIA_SUBKEY_L(5) ^ CAMELLIA_SUBKEY_R(5),
+               dw = CAMELLIA_RL8(dw);/* round 4 */
+       CAMELLIA_SUBKEY_R(5) = CAMELLIA_SUBKEY_L(5) ^ dw,
+       CAMELLIA_SUBKEY_L(5) = dw;
+       dw = CAMELLIA_SUBKEY_L(6) ^ CAMELLIA_SUBKEY_R(6),
+               dw = CAMELLIA_RL8(dw);/* round 5 */
+       CAMELLIA_SUBKEY_R(6) = CAMELLIA_SUBKEY_L(6) ^ dw,
+               CAMELLIA_SUBKEY_L(6) = dw;
+       dw = CAMELLIA_SUBKEY_L(7) ^ CAMELLIA_SUBKEY_R(7),
+               dw = CAMELLIA_RL8(dw);/* round 6 */
+       CAMELLIA_SUBKEY_R(7) = CAMELLIA_SUBKEY_L(7) ^ dw,
+               CAMELLIA_SUBKEY_L(7) = dw;
+       dw = CAMELLIA_SUBKEY_L(10) ^ CAMELLIA_SUBKEY_R(10),
+               dw = CAMELLIA_RL8(dw);/* round 7 */
+       CAMELLIA_SUBKEY_R(10) = CAMELLIA_SUBKEY_L(10) ^ dw,
+               CAMELLIA_SUBKEY_L(10) = dw;
+       dw = CAMELLIA_SUBKEY_L(11) ^ CAMELLIA_SUBKEY_R(11),
+           dw = CAMELLIA_RL8(dw);/* round 8 */
+       CAMELLIA_SUBKEY_R(11) = CAMELLIA_SUBKEY_L(11) ^ dw,
+               CAMELLIA_SUBKEY_L(11) = dw;
+       dw = CAMELLIA_SUBKEY_L(12) ^ CAMELLIA_SUBKEY_R(12),
+               dw = CAMELLIA_RL8(dw);/* round 9 */
+       CAMELLIA_SUBKEY_R(12) = CAMELLIA_SUBKEY_L(12) ^ dw,
+               CAMELLIA_SUBKEY_L(12) = dw;
+       dw = CAMELLIA_SUBKEY_L(13) ^ CAMELLIA_SUBKEY_R(13),
+               dw = CAMELLIA_RL8(dw);/* round 10 */
+       CAMELLIA_SUBKEY_R(13) = CAMELLIA_SUBKEY_L(13) ^ dw,
+               CAMELLIA_SUBKEY_L(13) = dw;
+       dw = CAMELLIA_SUBKEY_L(14) ^ CAMELLIA_SUBKEY_R(14),
+               dw = CAMELLIA_RL8(dw);/* round 11 */
+       CAMELLIA_SUBKEY_R(14) = CAMELLIA_SUBKEY_L(14) ^ dw,
+               CAMELLIA_SUBKEY_L(14) = dw;
+       dw = CAMELLIA_SUBKEY_L(15) ^ CAMELLIA_SUBKEY_R(15),
+               dw = CAMELLIA_RL8(dw);/* round 12 */
+       CAMELLIA_SUBKEY_R(15) = CAMELLIA_SUBKEY_L(15) ^ dw,
+               CAMELLIA_SUBKEY_L(15) = dw;
+       dw = CAMELLIA_SUBKEY_L(18) ^ CAMELLIA_SUBKEY_R(18),
+               dw = CAMELLIA_RL8(dw);/* round 13 */
+       CAMELLIA_SUBKEY_R(18) = CAMELLIA_SUBKEY_L(18) ^ dw,
+               CAMELLIA_SUBKEY_L(18) = dw;
+       dw = CAMELLIA_SUBKEY_L(19) ^ CAMELLIA_SUBKEY_R(19),
+               dw = CAMELLIA_RL8(dw);/* round 14 */
+       CAMELLIA_SUBKEY_R(19) = CAMELLIA_SUBKEY_L(19) ^ dw,
+               CAMELLIA_SUBKEY_L(19) = dw;
+       dw = CAMELLIA_SUBKEY_L(20) ^ CAMELLIA_SUBKEY_R(20),
+               dw = CAMELLIA_RL8(dw);/* round 15 */
+       CAMELLIA_SUBKEY_R(20) = CAMELLIA_SUBKEY_L(20) ^ dw,
+               CAMELLIA_SUBKEY_L(20) = dw;
+       dw = CAMELLIA_SUBKEY_L(21) ^ CAMELLIA_SUBKEY_R(21),
+               dw = CAMELLIA_RL8(dw);/* round 16 */
+       CAMELLIA_SUBKEY_R(21) = CAMELLIA_SUBKEY_L(21) ^ dw,
+               CAMELLIA_SUBKEY_L(21) = dw;
+       dw = CAMELLIA_SUBKEY_L(22) ^ CAMELLIA_SUBKEY_R(22),
+               dw = CAMELLIA_RL8(dw);/* round 17 */
+       CAMELLIA_SUBKEY_R(22) = CAMELLIA_SUBKEY_L(22) ^ dw,
+               CAMELLIA_SUBKEY_L(22) = dw;
+       dw = CAMELLIA_SUBKEY_L(23) ^ CAMELLIA_SUBKEY_R(23),
+               dw = CAMELLIA_RL8(dw);/* round 18 */
+       CAMELLIA_SUBKEY_R(23) = CAMELLIA_SUBKEY_L(23) ^ dw,
+               CAMELLIA_SUBKEY_L(23) = dw;
+       dw = CAMELLIA_SUBKEY_L(26) ^ CAMELLIA_SUBKEY_R(26),
+               dw = CAMELLIA_RL8(dw);/* round 19 */
+       CAMELLIA_SUBKEY_R(26) = CAMELLIA_SUBKEY_L(26) ^ dw,
+               CAMELLIA_SUBKEY_L(26) = dw;
+       dw = CAMELLIA_SUBKEY_L(27) ^ CAMELLIA_SUBKEY_R(27),
+               dw = CAMELLIA_RL8(dw);/* round 20 */
+       CAMELLIA_SUBKEY_R(27) = CAMELLIA_SUBKEY_L(27) ^ dw,
+               CAMELLIA_SUBKEY_L(27) = dw;
+       dw = CAMELLIA_SUBKEY_L(28) ^ CAMELLIA_SUBKEY_R(28),
+               dw = CAMELLIA_RL8(dw);/* round 21 */
+       CAMELLIA_SUBKEY_R(28) = CAMELLIA_SUBKEY_L(28) ^ dw,
+               CAMELLIA_SUBKEY_L(28) = dw;
+       dw = CAMELLIA_SUBKEY_L(29) ^ CAMELLIA_SUBKEY_R(29),
+               dw = CAMELLIA_RL8(dw);/* round 22 */
+       CAMELLIA_SUBKEY_R(29) = CAMELLIA_SUBKEY_L(29) ^ dw,
+               CAMELLIA_SUBKEY_L(29) = dw;
+       dw = CAMELLIA_SUBKEY_L(30) ^ CAMELLIA_SUBKEY_R(30),
+               dw = CAMELLIA_RL8(dw);/* round 23 */
+       CAMELLIA_SUBKEY_R(30) = CAMELLIA_SUBKEY_L(30) ^ dw,
+               CAMELLIA_SUBKEY_L(30) = dw;
+       dw = CAMELLIA_SUBKEY_L(31) ^ CAMELLIA_SUBKEY_R(31),
+               dw = CAMELLIA_RL8(dw);/* round 24 */
+       CAMELLIA_SUBKEY_R(31) = CAMELLIA_SUBKEY_L(31) ^ dw,
+               CAMELLIA_SUBKEY_L(31) = dw;
+
+       return;
+}
+
+static void camellia_setup192(const unsigned char *key, u32 *subkey)
+{
+       unsigned char kk[32];
+       u32 krll, krlr, krrl,krrr;
+
+       memcpy(kk, key, 24);
+       memcpy((unsigned char *)&krll, key+16,4);
+       memcpy((unsigned char *)&krlr, key+20,4);
+       krrl = ~krll;
+       krrr = ~krlr;
+       memcpy(kk+24, (unsigned char *)&krrl, 4);
+       memcpy(kk+28, (unsigned char *)&krrr, 4);
+       camellia_setup256(kk, subkey);
+       return;
+}
+
+
+/**
+ * Stuff related to camellia encryption/decryption
+ */
+static void camellia_encrypt128(const u32 *subkey, __be32 *io_text)
+{
+       u32 il,ir,t0,t1;               /* temporary valiables */
+
+       u32 io[4];
+
+       io[0] = be32_to_cpu(io_text[0]);
+       io[1] = be32_to_cpu(io_text[1]);
+       io[2] = be32_to_cpu(io_text[2]);
+       io[3] = be32_to_cpu(io_text[3]);
+
+       /* pre whitening but absorb kw2*/
+       io[0] ^= CAMELLIA_SUBKEY_L(0);
+       io[1] ^= CAMELLIA_SUBKEY_R(0);
+       /* main iteration */
+
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(2),CAMELLIA_SUBKEY_R(2),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(3),CAMELLIA_SUBKEY_R(3),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(4),CAMELLIA_SUBKEY_R(4),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(5),CAMELLIA_SUBKEY_R(5),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(6),CAMELLIA_SUBKEY_R(6),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(7),CAMELLIA_SUBKEY_R(7),
+                        io[0],io[1],il,ir,t0,t1);
+
+       CAMELLIA_FLS(io[0],io[1],io[2],io[3],
+                    CAMELLIA_SUBKEY_L(8),CAMELLIA_SUBKEY_R(8),
+                    CAMELLIA_SUBKEY_L(9),CAMELLIA_SUBKEY_R(9),
+                    t0,t1,il,ir);
+
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(10),CAMELLIA_SUBKEY_R(10),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(11),CAMELLIA_SUBKEY_R(11),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(12),CAMELLIA_SUBKEY_R(12),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(13),CAMELLIA_SUBKEY_R(13),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(14),CAMELLIA_SUBKEY_R(14),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(15),CAMELLIA_SUBKEY_R(15),
+                        io[0],io[1],il,ir,t0,t1);
+
+       CAMELLIA_FLS(io[0],io[1],io[2],io[3],
+                    CAMELLIA_SUBKEY_L(16),CAMELLIA_SUBKEY_R(16),
+                    CAMELLIA_SUBKEY_L(17),CAMELLIA_SUBKEY_R(17),
+                    t0,t1,il,ir);
+
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(18),CAMELLIA_SUBKEY_R(18),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(19),CAMELLIA_SUBKEY_R(19),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(20),CAMELLIA_SUBKEY_R(20),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(21),CAMELLIA_SUBKEY_R(21),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(22),CAMELLIA_SUBKEY_R(22),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(23),CAMELLIA_SUBKEY_R(23),
+                        io[0],io[1],il,ir,t0,t1);
+
+       /* post whitening but kw4 */
+       io[2] ^= CAMELLIA_SUBKEY_L(24);
+       io[3] ^= CAMELLIA_SUBKEY_R(24);
+
+       t0 = io[0];
+       t1 = io[1];
+       io[0] = io[2];
+       io[1] = io[3];
+       io[2] = t0;
+       io[3] = t1;
+
+       io_text[0] = cpu_to_be32(io[0]);
+       io_text[1] = cpu_to_be32(io[1]);
+       io_text[2] = cpu_to_be32(io[2]);
+       io_text[3] = cpu_to_be32(io[3]);
+
+       return;
+}
+
+static void camellia_decrypt128(const u32 *subkey, __be32 *io_text)
+{
+       u32 il,ir,t0,t1;               /* temporary valiables */
+
+       u32 io[4];
+
+       io[0] = be32_to_cpu(io_text[0]);
+       io[1] = be32_to_cpu(io_text[1]);
+       io[2] = be32_to_cpu(io_text[2]);
+       io[3] = be32_to_cpu(io_text[3]);
+
+       /* pre whitening but absorb kw2*/
+       io[0] ^= CAMELLIA_SUBKEY_L(24);
+       io[1] ^= CAMELLIA_SUBKEY_R(24);
+
+       /* main iteration */
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(23),CAMELLIA_SUBKEY_R(23),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(22),CAMELLIA_SUBKEY_R(22),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(21),CAMELLIA_SUBKEY_R(21),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(20),CAMELLIA_SUBKEY_R(20),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(19),CAMELLIA_SUBKEY_R(19),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(18),CAMELLIA_SUBKEY_R(18),
+                        io[0],io[1],il,ir,t0,t1);
+
+       CAMELLIA_FLS(io[0],io[1],io[2],io[3],
+                    CAMELLIA_SUBKEY_L(17),CAMELLIA_SUBKEY_R(17),
+                    CAMELLIA_SUBKEY_L(16),CAMELLIA_SUBKEY_R(16),
+                    t0,t1,il,ir);
+
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(15),CAMELLIA_SUBKEY_R(15),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(14),CAMELLIA_SUBKEY_R(14),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(13),CAMELLIA_SUBKEY_R(13),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(12),CAMELLIA_SUBKEY_R(12),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(11),CAMELLIA_SUBKEY_R(11),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(10),CAMELLIA_SUBKEY_R(10),
+                        io[0],io[1],il,ir,t0,t1);
+
+       CAMELLIA_FLS(io[0],io[1],io[2],io[3],
+                    CAMELLIA_SUBKEY_L(9),CAMELLIA_SUBKEY_R(9),
+                    CAMELLIA_SUBKEY_L(8),CAMELLIA_SUBKEY_R(8),
+                    t0,t1,il,ir);
+
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(7),CAMELLIA_SUBKEY_R(7),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(6),CAMELLIA_SUBKEY_R(6),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(5),CAMELLIA_SUBKEY_R(5),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(4),CAMELLIA_SUBKEY_R(4),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(3),CAMELLIA_SUBKEY_R(3),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(2),CAMELLIA_SUBKEY_R(2),
+                        io[0],io[1],il,ir,t0,t1);
+
+       /* post whitening but kw4 */
+       io[2] ^= CAMELLIA_SUBKEY_L(0);
+       io[3] ^= CAMELLIA_SUBKEY_R(0);
+
+       t0 = io[0];
+       t1 = io[1];
+       io[0] = io[2];
+       io[1] = io[3];
+       io[2] = t0;
+       io[3] = t1;
+
+       io_text[0] = cpu_to_be32(io[0]);
+       io_text[1] = cpu_to_be32(io[1]);
+       io_text[2] = cpu_to_be32(io[2]);
+       io_text[3] = cpu_to_be32(io[3]);
+
+       return;
+}
+
+
+/**
+ * stuff for 192 and 256bit encryption/decryption
+ */
+static void camellia_encrypt256(const u32 *subkey, __be32 *io_text)
+{
+       u32 il,ir,t0,t1;           /* temporary valiables */
+
+       u32 io[4];
+
+       io[0] = be32_to_cpu(io_text[0]);
+       io[1] = be32_to_cpu(io_text[1]);
+       io[2] = be32_to_cpu(io_text[2]);
+       io[3] = be32_to_cpu(io_text[3]);
+
+       /* pre whitening but absorb kw2*/
+       io[0] ^= CAMELLIA_SUBKEY_L(0);
+       io[1] ^= CAMELLIA_SUBKEY_R(0);
+
+       /* main iteration */
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(2),CAMELLIA_SUBKEY_R(2),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(3),CAMELLIA_SUBKEY_R(3),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(4),CAMELLIA_SUBKEY_R(4),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(5),CAMELLIA_SUBKEY_R(5),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(6),CAMELLIA_SUBKEY_R(6),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(7),CAMELLIA_SUBKEY_R(7),
+                        io[0],io[1],il,ir,t0,t1);
+
+       CAMELLIA_FLS(io[0],io[1],io[2],io[3],
+                    CAMELLIA_SUBKEY_L(8),CAMELLIA_SUBKEY_R(8),
+                    CAMELLIA_SUBKEY_L(9),CAMELLIA_SUBKEY_R(9),
+                    t0,t1,il,ir);
+
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(10),CAMELLIA_SUBKEY_R(10),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(11),CAMELLIA_SUBKEY_R(11),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(12),CAMELLIA_SUBKEY_R(12),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(13),CAMELLIA_SUBKEY_R(13),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(14),CAMELLIA_SUBKEY_R(14),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(15),CAMELLIA_SUBKEY_R(15),
+                        io[0],io[1],il,ir,t0,t1);
+
+       CAMELLIA_FLS(io[0],io[1],io[2],io[3],
+                    CAMELLIA_SUBKEY_L(16),CAMELLIA_SUBKEY_R(16),
+                    CAMELLIA_SUBKEY_L(17),CAMELLIA_SUBKEY_R(17),
+                    t0,t1,il,ir);
+
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(18),CAMELLIA_SUBKEY_R(18),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(19),CAMELLIA_SUBKEY_R(19),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(20),CAMELLIA_SUBKEY_R(20),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(21),CAMELLIA_SUBKEY_R(21),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(22),CAMELLIA_SUBKEY_R(22),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(23),CAMELLIA_SUBKEY_R(23),
+                        io[0],io[1],il,ir,t0,t1);
+
+       CAMELLIA_FLS(io[0],io[1],io[2],io[3],
+                    CAMELLIA_SUBKEY_L(24),CAMELLIA_SUBKEY_R(24),
+                    CAMELLIA_SUBKEY_L(25),CAMELLIA_SUBKEY_R(25),
+                    t0,t1,il,ir);
+
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(26),CAMELLIA_SUBKEY_R(26),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(27),CAMELLIA_SUBKEY_R(27),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(28),CAMELLIA_SUBKEY_R(28),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(29),CAMELLIA_SUBKEY_R(29),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(30),CAMELLIA_SUBKEY_R(30),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(31),CAMELLIA_SUBKEY_R(31),
+                        io[0],io[1],il,ir,t0,t1);
+
+       /* post whitening but kw4 */
+       io[2] ^= CAMELLIA_SUBKEY_L(32);
+       io[3] ^= CAMELLIA_SUBKEY_R(32);
+
+       t0 = io[0];
+       t1 = io[1];
+       io[0] = io[2];
+       io[1] = io[3];
+       io[2] = t0;
+       io[3] = t1;
+
+       io_text[0] = cpu_to_be32(io[0]);
+       io_text[1] = cpu_to_be32(io[1]);
+       io_text[2] = cpu_to_be32(io[2]);
+       io_text[3] = cpu_to_be32(io[3]);
+
+       return;
+}
+
+
+static void camellia_decrypt256(const u32 *subkey, __be32 *io_text)
+{
+       u32 il,ir,t0,t1;           /* temporary valiables */
+
+       u32 io[4];
+
+       io[0] = be32_to_cpu(io_text[0]);
+       io[1] = be32_to_cpu(io_text[1]);
+       io[2] = be32_to_cpu(io_text[2]);
+       io[3] = be32_to_cpu(io_text[3]);
+
+       /* pre whitening but absorb kw2*/
+       io[0] ^= CAMELLIA_SUBKEY_L(32);
+       io[1] ^= CAMELLIA_SUBKEY_R(32);
+
+       /* main iteration */
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(31),CAMELLIA_SUBKEY_R(31),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(30),CAMELLIA_SUBKEY_R(30),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(29),CAMELLIA_SUBKEY_R(29),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(28),CAMELLIA_SUBKEY_R(28),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(27),CAMELLIA_SUBKEY_R(27),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(26),CAMELLIA_SUBKEY_R(26),
+                        io[0],io[1],il,ir,t0,t1);
+
+       CAMELLIA_FLS(io[0],io[1],io[2],io[3],
+                    CAMELLIA_SUBKEY_L(25),CAMELLIA_SUBKEY_R(25),
+                    CAMELLIA_SUBKEY_L(24),CAMELLIA_SUBKEY_R(24),
+                    t0,t1,il,ir);
+
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(23),CAMELLIA_SUBKEY_R(23),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(22),CAMELLIA_SUBKEY_R(22),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(21),CAMELLIA_SUBKEY_R(21),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(20),CAMELLIA_SUBKEY_R(20),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(19),CAMELLIA_SUBKEY_R(19),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(18),CAMELLIA_SUBKEY_R(18),
+                        io[0],io[1],il,ir,t0,t1);
+
+       CAMELLIA_FLS(io[0],io[1],io[2],io[3],
+                    CAMELLIA_SUBKEY_L(17),CAMELLIA_SUBKEY_R(17),
+                    CAMELLIA_SUBKEY_L(16),CAMELLIA_SUBKEY_R(16),
+                    t0,t1,il,ir);
+
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(15),CAMELLIA_SUBKEY_R(15),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(14),CAMELLIA_SUBKEY_R(14),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(13),CAMELLIA_SUBKEY_R(13),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(12),CAMELLIA_SUBKEY_R(12),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(11),CAMELLIA_SUBKEY_R(11),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(10),CAMELLIA_SUBKEY_R(10),
+                        io[0],io[1],il,ir,t0,t1);
+
+       CAMELLIA_FLS(io[0],io[1],io[2],io[3],
+                    CAMELLIA_SUBKEY_L(9),CAMELLIA_SUBKEY_R(9),
+                    CAMELLIA_SUBKEY_L(8),CAMELLIA_SUBKEY_R(8),
+                    t0,t1,il,ir);
+
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(7),CAMELLIA_SUBKEY_R(7),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(6),CAMELLIA_SUBKEY_R(6),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(5),CAMELLIA_SUBKEY_R(5),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(4),CAMELLIA_SUBKEY_R(4),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(3),CAMELLIA_SUBKEY_R(3),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(2),CAMELLIA_SUBKEY_R(2),
+                        io[0],io[1],il,ir,t0,t1);
+
+       /* post whitening but kw4 */
+       io[2] ^= CAMELLIA_SUBKEY_L(0);
+       io[3] ^= CAMELLIA_SUBKEY_R(0);
+
+       t0 = io[0];
+       t1 = io[1];
+       io[0] = io[2];
+       io[1] = io[3];
+       io[2] = t0;
+       io[3] = t1;
+
+       io_text[0] = cpu_to_be32(io[0]);
+       io_text[1] = cpu_to_be32(io[1]);
+       io_text[2] = cpu_to_be32(io[2]);
+       io_text[3] = cpu_to_be32(io[3]);
+
+       return;
+}
+
+
+static int
+camellia_set_key(struct crypto_tfm *tfm, const u8 *in_key,
+                unsigned int key_len)
+{
+       struct camellia_ctx *cctx = crypto_tfm_ctx(tfm);
+       const unsigned char *key = (const unsigned char *)in_key;
+       u32 *flags = &tfm->crt_flags;
+
+       if (key_len != 16 && key_len != 24 && key_len != 32) {
+               *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
+               return -EINVAL;
+       }
+
+       cctx->key_length = key_len;
+
+       switch(key_len) {
+       case 16:
+               camellia_setup128(key, cctx->key_table);
+               break;
+       case 24:
+               camellia_setup192(key, cctx->key_table);
+               break;
+       case 32:
+               camellia_setup256(key, cctx->key_table);
+               break;
+       default:
+               break;
+       }
+
+       return 0;
+}
+
+
+static void camellia_encrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in)
+{
+       const struct camellia_ctx *cctx = crypto_tfm_ctx(tfm);
+       const __be32 *src = (const __be32 *)in;
+       __be32 *dst = (__be32 *)out;
+
+       __be32 tmp[4];
+
+       memcpy(tmp, src, CAMELLIA_BLOCK_SIZE);
+
+       switch (cctx->key_length) {
+       case 16:
+               camellia_encrypt128(cctx->key_table, tmp);
+               break;
+       case 24:
+               /* fall through */
+       case 32:
+               camellia_encrypt256(cctx->key_table, tmp);
+               break;
+       default:
+               break;
+       }
+
+       memcpy(dst, tmp, CAMELLIA_BLOCK_SIZE);
+}
+
+
+static void camellia_decrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in)
+{
+       const struct camellia_ctx *cctx = crypto_tfm_ctx(tfm);
+       const __be32 *src = (const __be32 *)in;
+       __be32 *dst = (__be32 *)out;
+
+       __be32 tmp[4];
+
+       memcpy(tmp, src, CAMELLIA_BLOCK_SIZE);
+
+       switch (cctx->key_length) {
+       case 16:
+               camellia_decrypt128(cctx->key_table, tmp);
+               break;
+       case 24:
+               /* fall through */
+       case 32:
+               camellia_decrypt256(cctx->key_table, tmp);
+               break;
+       default:
+               break;
+       }
+
+       memcpy(dst, tmp, CAMELLIA_BLOCK_SIZE);
+}
+
+
+static struct crypto_alg camellia_alg = {
+       .cra_name               =       "camellia",
+       .cra_driver_name        =       "camellia-generic",
+       .cra_priority           =       100,
+       .cra_flags              =       CRYPTO_ALG_TYPE_CIPHER,
+       .cra_blocksize          =       CAMELLIA_BLOCK_SIZE,
+       .cra_ctxsize            =       sizeof(struct camellia_ctx),
+       .cra_alignmask          =       3,
+       .cra_module             =       THIS_MODULE,
+       .cra_list               =       LIST_HEAD_INIT(camellia_alg.cra_list),
+       .cra_u                  =       {
+               .cipher = {
+                       .cia_min_keysize        =       CAMELLIA_MIN_KEY_SIZE,
+                       .cia_max_keysize        =       CAMELLIA_MAX_KEY_SIZE,
+                       .cia_setkey             =       camellia_set_key,
+                       .cia_encrypt            =       camellia_encrypt,
+                       .cia_decrypt            =       camellia_decrypt
+               }
+       }
+};
+
+static int __init camellia_init(void)
+{
+       return crypto_register_alg(&camellia_alg);
+}
+
+
+static void __exit camellia_fini(void)
+{
+       crypto_unregister_alg(&camellia_alg);
+}
+
+
+module_init(camellia_init);
+module_exit(camellia_fini);
+
+
+MODULE_DESCRIPTION("Camellia Cipher Algorithm");
+MODULE_LICENSE("GPL");
index f5542b4db387eea82b90e023da20e8e94dbe4ffb..136fea7e700095542c585cbb7cae9c16b64eb667 100644 (file)
@@ -243,6 +243,7 @@ static int crypto_cbc_init_tfm(struct crypto_tfm *tfm)
        struct crypto_instance *inst = (void *)tfm->__crt_alg;
        struct crypto_spawn *spawn = crypto_instance_ctx(inst);
        struct crypto_cbc_ctx *ctx = crypto_tfm_ctx(tfm);
+       struct crypto_cipher *cipher;
 
        switch (crypto_tfm_alg_blocksize(tfm)) {
        case 8:
@@ -260,11 +261,11 @@ static int crypto_cbc_init_tfm(struct crypto_tfm *tfm)
                        ctx->xor = xor_quad;
        }
 
-       tfm = crypto_spawn_tfm(spawn);
-       if (IS_ERR(tfm))
-               return PTR_ERR(tfm);
+       cipher = crypto_spawn_cipher(spawn);
+       if (IS_ERR(cipher))
+               return PTR_ERR(cipher);
 
-       ctx->child = crypto_cipher_cast(tfm);
+       ctx->child = cipher;
        return 0;
 }
 
index 9e03701cfdcc692efb33ee2d682eff02d5dd10a9..333aab2f027717fc96672ed74662d1c25d72b2ce 100644 (file)
  * any later version.
  *
  */
-#include <linux/compiler.h>
+
 #include <linux/kernel.h>
 #include <linux/crypto.h>
 #include <linux/errno.h>
-#include <linux/mm.h>
-#include <linux/slab.h>
+#include <linux/scatterlist.h>
 #include <linux/string.h>
-#include <asm/scatterlist.h>
 #include "internal.h"
-#include "scatterwalk.h"
-
-struct cipher_alg_compat {
-       unsigned int cia_min_keysize;
-       unsigned int cia_max_keysize;
-       int (*cia_setkey)(struct crypto_tfm *tfm, const u8 *key,
-                         unsigned int keylen);
-       void (*cia_encrypt)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
-       void (*cia_decrypt)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
-
-       unsigned int (*cia_encrypt_ecb)(const struct cipher_desc *desc,
-                                       u8 *dst, const u8 *src,
-                                       unsigned int nbytes);
-       unsigned int (*cia_decrypt_ecb)(const struct cipher_desc *desc,
-                                       u8 *dst, const u8 *src,
-                                       unsigned int nbytes);
-       unsigned int (*cia_encrypt_cbc)(const struct cipher_desc *desc,
-                                       u8 *dst, const u8 *src,
-                                       unsigned int nbytes);
-       unsigned int (*cia_decrypt_cbc)(const struct cipher_desc *desc,
-                                       u8 *dst, const u8 *src,
-                                       unsigned int nbytes);
-};
-
-static inline void xor_64(u8 *a, const u8 *b)
-{
-       ((u32 *)a)[0] ^= ((u32 *)b)[0];
-       ((u32 *)a)[1] ^= ((u32 *)b)[1];
-}
-
-static inline void xor_128(u8 *a, const u8 *b)
-{
-       ((u32 *)a)[0] ^= ((u32 *)b)[0];
-       ((u32 *)a)[1] ^= ((u32 *)b)[1];
-       ((u32 *)a)[2] ^= ((u32 *)b)[2];
-       ((u32 *)a)[3] ^= ((u32 *)b)[3];
-}
-
-static unsigned int crypt_slow(const struct cipher_desc *desc,
-                              struct scatter_walk *in,
-                              struct scatter_walk *out, unsigned int bsize)
-{
-       unsigned long alignmask = crypto_tfm_alg_alignmask(desc->tfm);
-       u8 buffer[bsize * 2 + alignmask];
-       u8 *src = (u8 *)ALIGN((unsigned long)buffer, alignmask + 1);
-       u8 *dst = src + bsize;
-
-       scatterwalk_copychunks(src, in, bsize, 0);
-       desc->prfn(desc, dst, src, bsize);
-       scatterwalk_copychunks(dst, out, bsize, 1);
-
-       return bsize;
-}
-
-static inline unsigned int crypt_fast(const struct cipher_desc *desc,
-                                     struct scatter_walk *in,
-                                     struct scatter_walk *out,
-                                     unsigned int nbytes, u8 *tmp)
-{
-       u8 *src, *dst;
-       u8 *real_src, *real_dst;
-
-       real_src = scatterwalk_map(in, 0);
-       real_dst = scatterwalk_map(out, 1);
-
-       src = real_src;
-       dst = scatterwalk_samebuf(in, out) ? src : real_dst;
-
-       if (tmp) {
-               memcpy(tmp, src, nbytes);
-               src = tmp;
-               dst = tmp;
-       }
-
-       nbytes = desc->prfn(desc, dst, src, nbytes);
-
-       if (tmp)
-               memcpy(real_dst, tmp, nbytes);
-
-       scatterwalk_unmap(real_src, 0);
-       scatterwalk_unmap(real_dst, 1);
-
-       scatterwalk_advance(in, nbytes);
-       scatterwalk_advance(out, nbytes);
-
-       return nbytes;
-}
-
-/* 
- * Generic encrypt/decrypt wrapper for ciphers, handles operations across
- * multiple page boundaries by using temporary blocks.  In user context,
- * the kernel is given a chance to schedule us once per page.
- */
-static int crypt(const struct cipher_desc *desc,
-                struct scatterlist *dst,
-                struct scatterlist *src,
-                unsigned int nbytes)
-{
-       struct scatter_walk walk_in, walk_out;
-       struct crypto_tfm *tfm = desc->tfm;
-       const unsigned int bsize = crypto_tfm_alg_blocksize(tfm);
-       unsigned int alignmask = crypto_tfm_alg_alignmask(tfm);
-       unsigned long buffer = 0;
-
-       if (!nbytes)
-               return 0;
-
-       if (nbytes % bsize) {
-               tfm->crt_flags |= CRYPTO_TFM_RES_BAD_BLOCK_LEN;
-               return -EINVAL;
-       }
-
-       scatterwalk_start(&walk_in, src);
-       scatterwalk_start(&walk_out, dst);
-
-       for(;;) {
-               unsigned int n = nbytes;
-               u8 *tmp = NULL;
-
-               if (!scatterwalk_aligned(&walk_in, alignmask) ||
-                   !scatterwalk_aligned(&walk_out, alignmask)) {
-                       if (!buffer) {
-                               buffer = __get_free_page(GFP_ATOMIC);
-                               if (!buffer)
-                                       n = 0;
-                       }
-                       tmp = (u8 *)buffer;
-               }
-
-               n = scatterwalk_clamp(&walk_in, n);
-               n = scatterwalk_clamp(&walk_out, n);
-
-               if (likely(n >= bsize))
-                       n = crypt_fast(desc, &walk_in, &walk_out, n, tmp);
-               else
-                       n = crypt_slow(desc, &walk_in, &walk_out, bsize);
-
-               nbytes -= n;
-
-               scatterwalk_done(&walk_in, 0, nbytes);
-               scatterwalk_done(&walk_out, 1, nbytes);
-
-               if (!nbytes)
-                       break;
-
-               crypto_yield(tfm->crt_flags);
-       }
-
-       if (buffer)
-               free_page(buffer);
-
-       return 0;
-}
-
-static int crypt_iv_unaligned(struct cipher_desc *desc,
-                             struct scatterlist *dst,
-                             struct scatterlist *src,
-                             unsigned int nbytes)
-{
-       struct crypto_tfm *tfm = desc->tfm;
-       unsigned long alignmask = crypto_tfm_alg_alignmask(tfm);
-       u8 *iv = desc->info;
-
-       if (unlikely(((unsigned long)iv & alignmask))) {
-               unsigned int ivsize = tfm->crt_cipher.cit_ivsize;
-               u8 buffer[ivsize + alignmask];
-               u8 *tmp = (u8 *)ALIGN((unsigned long)buffer, alignmask + 1);
-               int err;
-
-               desc->info = memcpy(tmp, iv, ivsize);
-               err = crypt(desc, dst, src, nbytes);
-               memcpy(iv, tmp, ivsize);
-
-               return err;
-       }
-
-       return crypt(desc, dst, src, nbytes);
-}
-
-static unsigned int cbc_process_encrypt(const struct cipher_desc *desc,
-                                       u8 *dst, const u8 *src,
-                                       unsigned int nbytes)
-{
-       struct crypto_tfm *tfm = desc->tfm;
-       void (*xor)(u8 *, const u8 *) = tfm->crt_u.cipher.cit_xor_block;
-       int bsize = crypto_tfm_alg_blocksize(tfm);
-
-       void (*fn)(struct crypto_tfm *, u8 *, const u8 *) = desc->crfn;
-       u8 *iv = desc->info;
-       unsigned int done = 0;
-
-       nbytes -= bsize;
-
-       do {
-               xor(iv, src);
-               fn(tfm, dst, iv);
-               memcpy(iv, dst, bsize);
-
-               src += bsize;
-               dst += bsize;
-       } while ((done += bsize) <= nbytes);
-
-       return done;
-}
-
-static unsigned int cbc_process_decrypt(const struct cipher_desc *desc,
-                                       u8 *dst, const u8 *src,
-                                       unsigned int nbytes)
-{
-       struct crypto_tfm *tfm = desc->tfm;
-       void (*xor)(u8 *, const u8 *) = tfm->crt_u.cipher.cit_xor_block;
-       int bsize = crypto_tfm_alg_blocksize(tfm);
-       unsigned long alignmask = crypto_tfm_alg_alignmask(desc->tfm);
-
-       u8 stack[src == dst ? bsize + alignmask : 0];
-       u8 *buf = (u8 *)ALIGN((unsigned long)stack, alignmask + 1);
-       u8 **dst_p = src == dst ? &buf : &dst;
-
-       void (*fn)(struct crypto_tfm *, u8 *, const u8 *) = desc->crfn;
-       u8 *iv = desc->info;
-       unsigned int done = 0;
-
-       nbytes -= bsize;
-
-       do {
-               u8 *tmp_dst = *dst_p;
-
-               fn(tfm, tmp_dst, src);
-               xor(tmp_dst, iv);
-               memcpy(iv, src, bsize);
-               if (tmp_dst != dst)
-                       memcpy(dst, tmp_dst, bsize);
-
-               src += bsize;
-               dst += bsize;
-       } while ((done += bsize) <= nbytes);
-
-       return done;
-}
-
-static unsigned int ecb_process(const struct cipher_desc *desc, u8 *dst,
-                               const u8 *src, unsigned int nbytes)
-{
-       struct crypto_tfm *tfm = desc->tfm;
-       int bsize = crypto_tfm_alg_blocksize(tfm);
-       void (*fn)(struct crypto_tfm *, u8 *, const u8 *) = desc->crfn;
-       unsigned int done = 0;
-
-       nbytes -= bsize;
-
-       do {
-               fn(tfm, dst, src);
-
-               src += bsize;
-               dst += bsize;
-       } while ((done += bsize) <= nbytes);
-
-       return done;
-}
 
 static int setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen)
 {
@@ -293,122 +32,6 @@ static int setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen)
                return cia->cia_setkey(tfm, key, keylen);
 }
 
-static int ecb_encrypt(struct crypto_tfm *tfm,
-                      struct scatterlist *dst,
-                       struct scatterlist *src, unsigned int nbytes)
-{
-       struct cipher_desc desc;
-       struct cipher_alg_compat *cipher = (void *)&tfm->__crt_alg->cra_cipher;
-
-       desc.tfm = tfm;
-       desc.crfn = cipher->cia_encrypt;
-       desc.prfn = cipher->cia_encrypt_ecb ?: ecb_process;
-
-       return crypt(&desc, dst, src, nbytes);
-}
-
-static int ecb_decrypt(struct crypto_tfm *tfm,
-                       struct scatterlist *dst,
-                       struct scatterlist *src,
-                      unsigned int nbytes)
-{
-       struct cipher_desc desc;
-       struct cipher_alg_compat *cipher = (void *)&tfm->__crt_alg->cra_cipher;
-
-       desc.tfm = tfm;
-       desc.crfn = cipher->cia_decrypt;
-       desc.prfn = cipher->cia_decrypt_ecb ?: ecb_process;
-
-       return crypt(&desc, dst, src, nbytes);
-}
-
-static int cbc_encrypt(struct crypto_tfm *tfm,
-                       struct scatterlist *dst,
-                       struct scatterlist *src,
-                      unsigned int nbytes)
-{
-       struct cipher_desc desc;
-       struct cipher_alg_compat *cipher = (void *)&tfm->__crt_alg->cra_cipher;
-
-       desc.tfm = tfm;
-       desc.crfn = cipher->cia_encrypt;
-       desc.prfn = cipher->cia_encrypt_cbc ?: cbc_process_encrypt;
-       desc.info = tfm->crt_cipher.cit_iv;
-
-       return crypt(&desc, dst, src, nbytes);
-}
-
-static int cbc_encrypt_iv(struct crypto_tfm *tfm,
-                          struct scatterlist *dst,
-                          struct scatterlist *src,
-                          unsigned int nbytes, u8 *iv)
-{
-       struct cipher_desc desc;
-       struct cipher_alg_compat *cipher = (void *)&tfm->__crt_alg->cra_cipher;
-
-       desc.tfm = tfm;
-       desc.crfn = cipher->cia_encrypt;
-       desc.prfn = cipher->cia_encrypt_cbc ?: cbc_process_encrypt;
-       desc.info = iv;
-
-       return crypt_iv_unaligned(&desc, dst, src, nbytes);
-}
-
-static int cbc_decrypt(struct crypto_tfm *tfm,
-                       struct scatterlist *dst,
-                       struct scatterlist *src,
-                      unsigned int nbytes)
-{
-       struct cipher_desc desc;
-       struct cipher_alg_compat *cipher = (void *)&tfm->__crt_alg->cra_cipher;
-
-       desc.tfm = tfm;
-       desc.crfn = cipher->cia_decrypt;
-       desc.prfn = cipher->cia_decrypt_cbc ?: cbc_process_decrypt;
-       desc.info = tfm->crt_cipher.cit_iv;
-
-       return crypt(&desc, dst, src, nbytes);
-}
-
-static int cbc_decrypt_iv(struct crypto_tfm *tfm,
-                          struct scatterlist *dst,
-                          struct scatterlist *src,
-                          unsigned int nbytes, u8 *iv)
-{
-       struct cipher_desc desc;
-       struct cipher_alg_compat *cipher = (void *)&tfm->__crt_alg->cra_cipher;
-
-       desc.tfm = tfm;
-       desc.crfn = cipher->cia_decrypt;
-       desc.prfn = cipher->cia_decrypt_cbc ?: cbc_process_decrypt;
-       desc.info = iv;
-
-       return crypt_iv_unaligned(&desc, dst, src, nbytes);
-}
-
-static int nocrypt(struct crypto_tfm *tfm,
-                   struct scatterlist *dst,
-                   struct scatterlist *src,
-                  unsigned int nbytes)
-{
-       return -ENOSYS;
-}
-
-static int nocrypt_iv(struct crypto_tfm *tfm,
-                      struct scatterlist *dst,
-                      struct scatterlist *src,
-                      unsigned int nbytes, u8 *iv)
-{
-       return -ENOSYS;
-}
-
-int crypto_init_cipher_flags(struct crypto_tfm *tfm, u32 flags)
-{
-       u32 mode = flags & CRYPTO_TFM_MODE_MASK;
-       tfm->crt_cipher.cit_mode = mode ? mode : CRYPTO_TFM_MODE_ECB;
-       return 0;
-}
-
 static void cipher_crypt_unaligned(void (*fn)(struct crypto_tfm *, u8 *,
                                              const u8 *),
                                   struct crypto_tfm *tfm,
@@ -454,7 +77,6 @@ static void cipher_decrypt_unaligned(struct crypto_tfm *tfm,
 
 int crypto_init_cipher_ops(struct crypto_tfm *tfm)
 {
-       int ret = 0;
        struct cipher_tfm *ops = &tfm->crt_cipher;
        struct cipher_alg *cipher = &tfm->__crt_alg->cra_cipher;
 
@@ -464,70 +86,7 @@ int crypto_init_cipher_ops(struct crypto_tfm *tfm)
        ops->cit_decrypt_one = crypto_tfm_alg_alignmask(tfm) ?
                cipher_decrypt_unaligned : cipher->cia_decrypt;
 
-       switch (tfm->crt_cipher.cit_mode) {
-       case CRYPTO_TFM_MODE_ECB:
-               ops->cit_encrypt = ecb_encrypt;
-               ops->cit_decrypt = ecb_decrypt;
-               ops->cit_encrypt_iv = nocrypt_iv;
-               ops->cit_decrypt_iv = nocrypt_iv;
-               break;
-               
-       case CRYPTO_TFM_MODE_CBC:
-               ops->cit_encrypt = cbc_encrypt;
-               ops->cit_decrypt = cbc_decrypt;
-               ops->cit_encrypt_iv = cbc_encrypt_iv;
-               ops->cit_decrypt_iv = cbc_decrypt_iv;
-               break;
-               
-       case CRYPTO_TFM_MODE_CFB:
-               ops->cit_encrypt = nocrypt;
-               ops->cit_decrypt = nocrypt;
-               ops->cit_encrypt_iv = nocrypt_iv;
-               ops->cit_decrypt_iv = nocrypt_iv;
-               break;
-       
-       case CRYPTO_TFM_MODE_CTR:
-               ops->cit_encrypt = nocrypt;
-               ops->cit_decrypt = nocrypt;
-               ops->cit_encrypt_iv = nocrypt_iv;
-               ops->cit_decrypt_iv = nocrypt_iv;
-               break;
-
-       default:
-               BUG();
-       }
-       
-       if (ops->cit_mode == CRYPTO_TFM_MODE_CBC) {
-               unsigned long align;
-               unsigned long addr;
-               
-               switch (crypto_tfm_alg_blocksize(tfm)) {
-               case 8:
-                       ops->cit_xor_block = xor_64;
-                       break;
-                       
-               case 16:
-                       ops->cit_xor_block = xor_128;
-                       break;
-                       
-               default:
-                       printk(KERN_WARNING "%s: block size %u not supported\n",
-                              crypto_tfm_alg_name(tfm),
-                              crypto_tfm_alg_blocksize(tfm));
-                       ret = -EINVAL;
-                       goto out;
-               }
-               
-               ops->cit_ivsize = crypto_tfm_alg_blocksize(tfm);
-               align = crypto_tfm_alg_alignmask(tfm) + 1;
-               addr = (unsigned long)crypto_tfm_ctx(tfm);
-               addr = ALIGN(addr, align);
-               addr += ALIGN(tfm->__crt_alg->cra_ctxsize, align);
-               ops->cit_iv = (void *)addr;
-       }
-
-out:   
-       return ret;
+       return 0;
 }
 
 void crypto_exit_cipher_ops(struct crypto_tfm *tfm)
index eca182aa33808dd1e54964ff838a91287d2081ea..0a6570048c1efb6ffaf6199662e4e33ee7ae9010 100644 (file)
@@ -34,11 +34,6 @@ static int crypto_decompress(struct crypto_tfm *tfm,
                                                           dlen);
 }
 
-int crypto_init_compress_flags(struct crypto_tfm *tfm, u32 flags)
-{
-       return flags ? -EINVAL : 0;
-}
-
 int crypto_init_compress_ops(struct crypto_tfm *tfm)
 {
        struct compress_tfm *ops = &tfm->crt_compress;
index 8f4593268ce0bf5c5ef2e9e47d8ab72789adb842..1bf7414aeb9e4e212beda804cf270aa310548c5d 100644 (file)
@@ -14,7 +14,9 @@
 
 #include <linux/mm.h>
 #include <linux/errno.h>
+#include <linux/hardirq.h>
 #include <linux/highmem.h>
+#include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/scatterlist.h>
 
@@ -29,8 +31,8 @@ static int init(struct hash_desc *desc)
        return 0;
 }
 
-static int update(struct hash_desc *desc,
-                 struct scatterlist *sg, unsigned int nbytes)
+static int update2(struct hash_desc *desc,
+                  struct scatterlist *sg, unsigned int nbytes)
 {
        struct crypto_tfm *tfm = crypto_hash_tfm(desc->tfm);
        unsigned int alignmask = crypto_tfm_alg_alignmask(tfm);
@@ -81,6 +83,14 @@ static int update(struct hash_desc *desc,
        return 0;
 }
 
+static int update(struct hash_desc *desc,
+                 struct scatterlist *sg, unsigned int nbytes)
+{
+       if (WARN_ON_ONCE(in_irq()))
+               return -EDEADLK;
+       return update2(desc, sg, nbytes);
+}
+
 static int final(struct hash_desc *desc, u8 *out)
 {
        struct crypto_tfm *tfm = crypto_hash_tfm(desc->tfm);
@@ -118,16 +128,14 @@ static int setkey(struct crypto_hash *hash, const u8 *key, unsigned int keylen)
 static int digest(struct hash_desc *desc,
                  struct scatterlist *sg, unsigned int nbytes, u8 *out)
 {
+       if (WARN_ON_ONCE(in_irq()))
+               return -EDEADLK;
+
        init(desc);
-       update(desc, sg, nbytes);
+       update2(desc, sg, nbytes);
        return final(desc, out);
 }
 
-int crypto_init_digest_flags(struct crypto_tfm *tfm, u32 flags)
-{
-       return flags ? -EINVAL : 0;
-}
-
 int crypto_init_digest_ops(struct crypto_tfm *tfm)
 {
        struct hash_tfm *ops = &tfm->crt_hash;
index f239aa9c4017834a7a193530386f0dc924a3fcbf..839a0aed8c229c26631ff56032165a19295a0531 100644 (file)
@@ -99,12 +99,13 @@ static int crypto_ecb_init_tfm(struct crypto_tfm *tfm)
        struct crypto_instance *inst = (void *)tfm->__crt_alg;
        struct crypto_spawn *spawn = crypto_instance_ctx(inst);
        struct crypto_ecb_ctx *ctx = crypto_tfm_ctx(tfm);
+       struct crypto_cipher *cipher;
 
-       tfm = crypto_spawn_tfm(spawn);
-       if (IS_ERR(tfm))
-               return PTR_ERR(tfm);
+       cipher = crypto_spawn_cipher(spawn);
+       if (IS_ERR(cipher))
+               return PTR_ERR(cipher);
 
-       ctx->child = crypto_cipher_cast(tfm);
+       ctx->child = cipher;
        return 0;
 }
 
diff --git a/crypto/fcrypt.c b/crypto/fcrypt.c
new file mode 100644 (file)
index 0000000..9c2bb53
--- /dev/null
@@ -0,0 +1,423 @@
+/* FCrypt encryption algorithm
+ *
+ * Copyright (C) 2006 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowells@redhat.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ *
+ * Based on code:
+ *
+ * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan
+ * (Royal Institute of Technology, Stockholm, Sweden).
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the Institute nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <asm/byteorder.h>
+#include <linux/bitops.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/crypto.h>
+
+#define ROUNDS 16
+
+struct fcrypt_ctx {
+       u32 sched[ROUNDS];
+};
+
+/* Rotate right two 32 bit numbers as a 56 bit number */
+#define ror56(hi, lo, n)                                       \
+do {                                                           \
+       u32 t = lo & ((1 << n) - 1);                            \
+       lo = (lo >> n) | ((hi & ((1 << n) - 1)) << (32 - n));   \
+       hi = (hi >> n) | (t << (24-n));                         \
+} while(0)
+
+/* Rotate right one 64 bit number as a 56 bit number */
+#define ror56_64(k, n)                                         \
+do {                                                           \
+       k = (k >> n) | ((k & ((1 << n) - 1)) << (56 - n));      \
+} while(0)
+
+/*
+ * Sboxes for Feistel network derived from
+ * /afs/transarc.com/public/afsps/afs.rel31b.export-src/rxkad/sboxes.h
+ */
+#undef Z
+#define Z(x) __constant_be32_to_cpu(x << 3)
+static const u32 sbox0[256] = {
+       Z(0xea), Z(0x7f), Z(0xb2), Z(0x64), Z(0x9d), Z(0xb0), Z(0xd9), Z(0x11),
+       Z(0xcd), Z(0x86), Z(0x86), Z(0x91), Z(0x0a), Z(0xb2), Z(0x93), Z(0x06),
+       Z(0x0e), Z(0x06), Z(0xd2), Z(0x65), Z(0x73), Z(0xc5), Z(0x28), Z(0x60),
+       Z(0xf2), Z(0x20), Z(0xb5), Z(0x38), Z(0x7e), Z(0xda), Z(0x9f), Z(0xe3),
+       Z(0xd2), Z(0xcf), Z(0xc4), Z(0x3c), Z(0x61), Z(0xff), Z(0x4a), Z(0x4a),
+       Z(0x35), Z(0xac), Z(0xaa), Z(0x5f), Z(0x2b), Z(0xbb), Z(0xbc), Z(0x53),
+       Z(0x4e), Z(0x9d), Z(0x78), Z(0xa3), Z(0xdc), Z(0x09), Z(0x32), Z(0x10),
+       Z(0xc6), Z(0x6f), Z(0x66), Z(0xd6), Z(0xab), Z(0xa9), Z(0xaf), Z(0xfd),
+       Z(0x3b), Z(0x95), Z(0xe8), Z(0x34), Z(0x9a), Z(0x81), Z(0x72), Z(0x80),
+       Z(0x9c), Z(0xf3), Z(0xec), Z(0xda), Z(0x9f), Z(0x26), Z(0x76), Z(0x15),
+       Z(0x3e), Z(0x55), Z(0x4d), Z(0xde), Z(0x84), Z(0xee), Z(0xad), Z(0xc7),
+       Z(0xf1), Z(0x6b), Z(0x3d), Z(0xd3), Z(0x04), Z(0x49), Z(0xaa), Z(0x24),
+       Z(0x0b), Z(0x8a), Z(0x83), Z(0xba), Z(0xfa), Z(0x85), Z(0xa0), Z(0xa8),
+       Z(0xb1), Z(0xd4), Z(0x01), Z(0xd8), Z(0x70), Z(0x64), Z(0xf0), Z(0x51),
+       Z(0xd2), Z(0xc3), Z(0xa7), Z(0x75), Z(0x8c), Z(0xa5), Z(0x64), Z(0xef),
+       Z(0x10), Z(0x4e), Z(0xb7), Z(0xc6), Z(0x61), Z(0x03), Z(0xeb), Z(0x44),
+       Z(0x3d), Z(0xe5), Z(0xb3), Z(0x5b), Z(0xae), Z(0xd5), Z(0xad), Z(0x1d),
+       Z(0xfa), Z(0x5a), Z(0x1e), Z(0x33), Z(0xab), Z(0x93), Z(0xa2), Z(0xb7),
+       Z(0xe7), Z(0xa8), Z(0x45), Z(0xa4), Z(0xcd), Z(0x29), Z(0x63), Z(0x44),
+       Z(0xb6), Z(0x69), Z(0x7e), Z(0x2e), Z(0x62), Z(0x03), Z(0xc8), Z(0xe0),
+       Z(0x17), Z(0xbb), Z(0xc7), Z(0xf3), Z(0x3f), Z(0x36), Z(0xba), Z(0x71),
+       Z(0x8e), Z(0x97), Z(0x65), Z(0x60), Z(0x69), Z(0xb6), Z(0xf6), Z(0xe6),
+       Z(0x6e), Z(0xe0), Z(0x81), Z(0x59), Z(0xe8), Z(0xaf), Z(0xdd), Z(0x95),
+       Z(0x22), Z(0x99), Z(0xfd), Z(0x63), Z(0x19), Z(0x74), Z(0x61), Z(0xb1),
+       Z(0xb6), Z(0x5b), Z(0xae), Z(0x54), Z(0xb3), Z(0x70), Z(0xff), Z(0xc6),
+       Z(0x3b), Z(0x3e), Z(0xc1), Z(0xd7), Z(0xe1), Z(0x0e), Z(0x76), Z(0xe5),
+       Z(0x36), Z(0x4f), Z(0x59), Z(0xc7), Z(0x08), Z(0x6e), Z(0x82), Z(0xa6),
+       Z(0x93), Z(0xc4), Z(0xaa), Z(0x26), Z(0x49), Z(0xe0), Z(0x21), Z(0x64),
+       Z(0x07), Z(0x9f), Z(0x64), Z(0x81), Z(0x9c), Z(0xbf), Z(0xf9), Z(0xd1),
+       Z(0x43), Z(0xf8), Z(0xb6), Z(0xb9), Z(0xf1), Z(0x24), Z(0x75), Z(0x03),
+       Z(0xe4), Z(0xb0), Z(0x99), Z(0x46), Z(0x3d), Z(0xf5), Z(0xd1), Z(0x39),
+       Z(0x72), Z(0x12), Z(0xf6), Z(0xba), Z(0x0c), Z(0x0d), Z(0x42), Z(0x2e)
+};
+
+#undef Z
+#define Z(x) __constant_be32_to_cpu((x << 27) | (x >> 5))
+static const u32 sbox1[256] = {
+       Z(0x77), Z(0x14), Z(0xa6), Z(0xfe), Z(0xb2), Z(0x5e), Z(0x8c), Z(0x3e),
+       Z(0x67), Z(0x6c), Z(0xa1), Z(0x0d), Z(0xc2), Z(0xa2), Z(0xc1), Z(0x85),
+       Z(0x6c), Z(0x7b), Z(0x67), Z(0xc6), Z(0x23), Z(0xe3), Z(0xf2), Z(0x89),
+       Z(0x50), Z(0x9c), Z(0x03), Z(0xb7), Z(0x73), Z(0xe6), Z(0xe1), Z(0x39),
+       Z(0x31), Z(0x2c), Z(0x27), Z(0x9f), Z(0xa5), Z(0x69), Z(0x44), Z(0xd6),
+       Z(0x23), Z(0x83), Z(0x98), Z(0x7d), Z(0x3c), Z(0xb4), Z(0x2d), Z(0x99),
+       Z(0x1c), Z(0x1f), Z(0x8c), Z(0x20), Z(0x03), Z(0x7c), Z(0x5f), Z(0xad),
+       Z(0xf4), Z(0xfa), Z(0x95), Z(0xca), Z(0x76), Z(0x44), Z(0xcd), Z(0xb6),
+       Z(0xb8), Z(0xa1), Z(0xa1), Z(0xbe), Z(0x9e), Z(0x54), Z(0x8f), Z(0x0b),
+       Z(0x16), Z(0x74), Z(0x31), Z(0x8a), Z(0x23), Z(0x17), Z(0x04), Z(0xfa),
+       Z(0x79), Z(0x84), Z(0xb1), Z(0xf5), Z(0x13), Z(0xab), Z(0xb5), Z(0x2e),
+       Z(0xaa), Z(0x0c), Z(0x60), Z(0x6b), Z(0x5b), Z(0xc4), Z(0x4b), Z(0xbc),
+       Z(0xe2), Z(0xaf), Z(0x45), Z(0x73), Z(0xfa), Z(0xc9), Z(0x49), Z(0xcd),
+       Z(0x00), Z(0x92), Z(0x7d), Z(0x97), Z(0x7a), Z(0x18), Z(0x60), Z(0x3d),
+       Z(0xcf), Z(0x5b), Z(0xde), Z(0xc6), Z(0xe2), Z(0xe6), Z(0xbb), Z(0x8b),
+       Z(0x06), Z(0xda), Z(0x08), Z(0x15), Z(0x1b), Z(0x88), Z(0x6a), Z(0x17),
+       Z(0x89), Z(0xd0), Z(0xa9), Z(0xc1), Z(0xc9), Z(0x70), Z(0x6b), Z(0xe5),
+       Z(0x43), Z(0xf4), Z(0x68), Z(0xc8), Z(0xd3), Z(0x84), Z(0x28), Z(0x0a),
+       Z(0x52), Z(0x66), Z(0xa3), Z(0xca), Z(0xf2), Z(0xe3), Z(0x7f), Z(0x7a),
+       Z(0x31), Z(0xf7), Z(0x88), Z(0x94), Z(0x5e), Z(0x9c), Z(0x63), Z(0xd5),
+       Z(0x24), Z(0x66), Z(0xfc), Z(0xb3), Z(0x57), Z(0x25), Z(0xbe), Z(0x89),
+       Z(0x44), Z(0xc4), Z(0xe0), Z(0x8f), Z(0x23), Z(0x3c), Z(0x12), Z(0x52),
+       Z(0xf5), Z(0x1e), Z(0xf4), Z(0xcb), Z(0x18), Z(0x33), Z(0x1f), Z(0xf8),
+       Z(0x69), Z(0x10), Z(0x9d), Z(0xd3), Z(0xf7), Z(0x28), Z(0xf8), Z(0x30),
+       Z(0x05), Z(0x5e), Z(0x32), Z(0xc0), Z(0xd5), Z(0x19), Z(0xbd), Z(0x45),
+       Z(0x8b), Z(0x5b), Z(0xfd), Z(0xbc), Z(0xe2), Z(0x5c), Z(0xa9), Z(0x96),
+       Z(0xef), Z(0x70), Z(0xcf), Z(0xc2), Z(0x2a), Z(0xb3), Z(0x61), Z(0xad),
+       Z(0x80), Z(0x48), Z(0x81), Z(0xb7), Z(0x1d), Z(0x43), Z(0xd9), Z(0xd7),
+       Z(0x45), Z(0xf0), Z(0xd8), Z(0x8a), Z(0x59), Z(0x7c), Z(0x57), Z(0xc1),
+       Z(0x79), Z(0xc7), Z(0x34), Z(0xd6), Z(0x43), Z(0xdf), Z(0xe4), Z(0x78),
+       Z(0x16), Z(0x06), Z(0xda), Z(0x92), Z(0x76), Z(0x51), Z(0xe1), Z(0xd4),
+       Z(0x70), Z(0x03), Z(0xe0), Z(0x2f), Z(0x96), Z(0x91), Z(0x82), Z(0x80)
+};
+
+#undef Z
+#define Z(x) __constant_be32_to_cpu(x << 11)
+static const u32 sbox2[256] = {
+       Z(0xf0), Z(0x37), Z(0x24), Z(0x53), Z(0x2a), Z(0x03), Z(0x83), Z(0x86),
+       Z(0xd1), Z(0xec), Z(0x50), Z(0xf0), Z(0x42), Z(0x78), Z(0x2f), Z(0x6d),
+       Z(0xbf), Z(0x80), Z(0x87), Z(0x27), Z(0x95), Z(0xe2), Z(0xc5), Z(0x5d),
+       Z(0xf9), Z(0x6f), Z(0xdb), Z(0xb4), Z(0x65), Z(0x6e), Z(0xe7), Z(0x24),
+       Z(0xc8), Z(0x1a), Z(0xbb), Z(0x49), Z(0xb5), Z(0x0a), Z(0x7d), Z(0xb9),
+       Z(0xe8), Z(0xdc), Z(0xb7), Z(0xd9), Z(0x45), Z(0x20), Z(0x1b), Z(0xce),
+       Z(0x59), Z(0x9d), Z(0x6b), Z(0xbd), Z(0x0e), Z(0x8f), Z(0xa3), Z(0xa9),
+       Z(0xbc), Z(0x74), Z(0xa6), Z(0xf6), Z(0x7f), Z(0x5f), Z(0xb1), Z(0x68),
+       Z(0x84), Z(0xbc), Z(0xa9), Z(0xfd), Z(0x55), Z(0x50), Z(0xe9), Z(0xb6),
+       Z(0x13), Z(0x5e), Z(0x07), Z(0xb8), Z(0x95), Z(0x02), Z(0xc0), Z(0xd0),
+       Z(0x6a), Z(0x1a), Z(0x85), Z(0xbd), Z(0xb6), Z(0xfd), Z(0xfe), Z(0x17),
+       Z(0x3f), Z(0x09), Z(0xa3), Z(0x8d), Z(0xfb), Z(0xed), Z(0xda), Z(0x1d),
+       Z(0x6d), Z(0x1c), Z(0x6c), Z(0x01), Z(0x5a), Z(0xe5), Z(0x71), Z(0x3e),
+       Z(0x8b), Z(0x6b), Z(0xbe), Z(0x29), Z(0xeb), Z(0x12), Z(0x19), Z(0x34),
+       Z(0xcd), Z(0xb3), Z(0xbd), Z(0x35), Z(0xea), Z(0x4b), Z(0xd5), Z(0xae),
+       Z(0x2a), Z(0x79), Z(0x5a), Z(0xa5), Z(0x32), Z(0x12), Z(0x7b), Z(0xdc),
+       Z(0x2c), Z(0xd0), Z(0x22), Z(0x4b), Z(0xb1), Z(0x85), Z(0x59), Z(0x80),
+       Z(0xc0), Z(0x30), Z(0x9f), Z(0x73), Z(0xd3), Z(0x14), Z(0x48), Z(0x40),
+       Z(0x07), Z(0x2d), Z(0x8f), Z(0x80), Z(0x0f), Z(0xce), Z(0x0b), Z(0x5e),
+       Z(0xb7), Z(0x5e), Z(0xac), Z(0x24), Z(0x94), Z(0x4a), Z(0x18), Z(0x15),
+       Z(0x05), Z(0xe8), Z(0x02), Z(0x77), Z(0xa9), Z(0xc7), Z(0x40), Z(0x45),
+       Z(0x89), Z(0xd1), Z(0xea), Z(0xde), Z(0x0c), Z(0x79), Z(0x2a), Z(0x99),
+       Z(0x6c), Z(0x3e), Z(0x95), Z(0xdd), Z(0x8c), Z(0x7d), Z(0xad), Z(0x6f),
+       Z(0xdc), Z(0xff), Z(0xfd), Z(0x62), Z(0x47), Z(0xb3), Z(0x21), Z(0x8a),
+       Z(0xec), Z(0x8e), Z(0x19), Z(0x18), Z(0xb4), Z(0x6e), Z(0x3d), Z(0xfd),
+       Z(0x74), Z(0x54), Z(0x1e), Z(0x04), Z(0x85), Z(0xd8), Z(0xbc), Z(0x1f),
+       Z(0x56), Z(0xe7), Z(0x3a), Z(0x56), Z(0x67), Z(0xd6), Z(0xc8), Z(0xa5),
+       Z(0xf3), Z(0x8e), Z(0xde), Z(0xae), Z(0x37), Z(0x49), Z(0xb7), Z(0xfa),
+       Z(0xc8), Z(0xf4), Z(0x1f), Z(0xe0), Z(0x2a), Z(0x9b), Z(0x15), Z(0xd1),
+       Z(0x34), Z(0x0e), Z(0xb5), Z(0xe0), Z(0x44), Z(0x78), Z(0x84), Z(0x59),
+       Z(0x56), Z(0x68), Z(0x77), Z(0xa5), Z(0x14), Z(0x06), Z(0xf5), Z(0x2f),
+       Z(0x8c), Z(0x8a), Z(0x73), Z(0x80), Z(0x76), Z(0xb4), Z(0x10), Z(0x86)
+};
+
+#undef Z
+#define Z(x) __constant_be32_to_cpu(x << 19)
+static const u32 sbox3[256] = {
+       Z(0xa9), Z(0x2a), Z(0x48), Z(0x51), Z(0x84), Z(0x7e), Z(0x49), Z(0xe2),
+       Z(0xb5), Z(0xb7), Z(0x42), Z(0x33), Z(0x7d), Z(0x5d), Z(0xa6), Z(0x12),
+       Z(0x44), Z(0x48), Z(0x6d), Z(0x28), Z(0xaa), Z(0x20), Z(0x6d), Z(0x57),
+       Z(0xd6), Z(0x6b), Z(0x5d), Z(0x72), Z(0xf0), Z(0x92), Z(0x5a), Z(0x1b),
+       Z(0x53), Z(0x80), Z(0x24), Z(0x70), Z(0x9a), Z(0xcc), Z(0xa7), Z(0x66),
+       Z(0xa1), Z(0x01), Z(0xa5), Z(0x41), Z(0x97), Z(0x41), Z(0x31), Z(0x82),
+       Z(0xf1), Z(0x14), Z(0xcf), Z(0x53), Z(0x0d), Z(0xa0), Z(0x10), Z(0xcc),
+       Z(0x2a), Z(0x7d), Z(0xd2), Z(0xbf), Z(0x4b), Z(0x1a), Z(0xdb), Z(0x16),
+       Z(0x47), Z(0xf6), Z(0x51), Z(0x36), Z(0xed), Z(0xf3), Z(0xb9), Z(0x1a),
+       Z(0xa7), Z(0xdf), Z(0x29), Z(0x43), Z(0x01), Z(0x54), Z(0x70), Z(0xa4),
+       Z(0xbf), Z(0xd4), Z(0x0b), Z(0x53), Z(0x44), Z(0x60), Z(0x9e), Z(0x23),
+       Z(0xa1), Z(0x18), Z(0x68), Z(0x4f), Z(0xf0), Z(0x2f), Z(0x82), Z(0xc2),
+       Z(0x2a), Z(0x41), Z(0xb2), Z(0x42), Z(0x0c), Z(0xed), Z(0x0c), Z(0x1d),
+       Z(0x13), Z(0x3a), Z(0x3c), Z(0x6e), Z(0x35), Z(0xdc), Z(0x60), Z(0x65),
+       Z(0x85), Z(0xe9), Z(0x64), Z(0x02), Z(0x9a), Z(0x3f), Z(0x9f), Z(0x87),
+       Z(0x96), Z(0xdf), Z(0xbe), Z(0xf2), Z(0xcb), Z(0xe5), Z(0x6c), Z(0xd4),
+       Z(0x5a), Z(0x83), Z(0xbf), Z(0x92), Z(0x1b), Z(0x94), Z(0x00), Z(0x42),
+       Z(0xcf), Z(0x4b), Z(0x00), Z(0x75), Z(0xba), Z(0x8f), Z(0x76), Z(0x5f),
+       Z(0x5d), Z(0x3a), Z(0x4d), Z(0x09), Z(0x12), Z(0x08), Z(0x38), Z(0x95),
+       Z(0x17), Z(0xe4), Z(0x01), Z(0x1d), Z(0x4c), Z(0xa9), Z(0xcc), Z(0x85),
+       Z(0x82), Z(0x4c), Z(0x9d), Z(0x2f), Z(0x3b), Z(0x66), Z(0xa1), Z(0x34),
+       Z(0x10), Z(0xcd), Z(0x59), Z(0x89), Z(0xa5), Z(0x31), Z(0xcf), Z(0x05),
+       Z(0xc8), Z(0x84), Z(0xfa), Z(0xc7), Z(0xba), Z(0x4e), Z(0x8b), Z(0x1a),
+       Z(0x19), Z(0xf1), Z(0xa1), Z(0x3b), Z(0x18), Z(0x12), Z(0x17), Z(0xb0),
+       Z(0x98), Z(0x8d), Z(0x0b), Z(0x23), Z(0xc3), Z(0x3a), Z(0x2d), Z(0x20),
+       Z(0xdf), Z(0x13), Z(0xa0), Z(0xa8), Z(0x4c), Z(0x0d), Z(0x6c), Z(0x2f),
+       Z(0x47), Z(0x13), Z(0x13), Z(0x52), Z(0x1f), Z(0x2d), Z(0xf5), Z(0x79),
+       Z(0x3d), Z(0xa2), Z(0x54), Z(0xbd), Z(0x69), Z(0xc8), Z(0x6b), Z(0xf3),
+       Z(0x05), Z(0x28), Z(0xf1), Z(0x16), Z(0x46), Z(0x40), Z(0xb0), Z(0x11),
+       Z(0xd3), Z(0xb7), Z(0x95), Z(0x49), Z(0xcf), Z(0xc3), Z(0x1d), Z(0x8f),
+       Z(0xd8), Z(0xe1), Z(0x73), Z(0xdb), Z(0xad), Z(0xc8), Z(0xc9), Z(0xa9),
+       Z(0xa1), Z(0xc2), Z(0xc5), Z(0xe3), Z(0xba), Z(0xfc), Z(0x0e), Z(0x25)
+};
+
+/*
+ * This is a 16 round Feistel network with permutation F_ENCRYPT
+ */
+#define F_ENCRYPT(R, L, sched)                                         \
+do {                                                                   \
+       union lc4 { u32 l; u8 c[4]; } u;                                \
+       u.l = sched ^ R;                                                \
+       L ^= sbox0[u.c[0]] ^ sbox1[u.c[1]] ^ sbox2[u.c[2]] ^ sbox3[u.c[3]]; \
+} while(0)
+
+/*
+ * encryptor
+ */
+static void fcrypt_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
+{
+       const struct fcrypt_ctx *ctx = crypto_tfm_ctx(tfm);
+       struct {
+               u32 l, r;
+       } X;
+
+       memcpy(&X, src, sizeof(X));
+
+       F_ENCRYPT(X.r, X.l, ctx->sched[0x0]);
+       F_ENCRYPT(X.l, X.r, ctx->sched[0x1]);
+       F_ENCRYPT(X.r, X.l, ctx->sched[0x2]);
+       F_ENCRYPT(X.l, X.r, ctx->sched[0x3]);
+       F_ENCRYPT(X.r, X.l, ctx->sched[0x4]);
+       F_ENCRYPT(X.l, X.r, ctx->sched[0x5]);
+       F_ENCRYPT(X.r, X.l, ctx->sched[0x6]);
+       F_ENCRYPT(X.l, X.r, ctx->sched[0x7]);
+       F_ENCRYPT(X.r, X.l, ctx->sched[0x8]);
+       F_ENCRYPT(X.l, X.r, ctx->sched[0x9]);
+       F_ENCRYPT(X.r, X.l, ctx->sched[0xa]);
+       F_ENCRYPT(X.l, X.r, ctx->sched[0xb]);
+       F_ENCRYPT(X.r, X.l, ctx->sched[0xc]);
+       F_ENCRYPT(X.l, X.r, ctx->sched[0xd]);
+       F_ENCRYPT(X.r, X.l, ctx->sched[0xe]);
+       F_ENCRYPT(X.l, X.r, ctx->sched[0xf]);
+
+       memcpy(dst, &X, sizeof(X));
+}
+
+/*
+ * decryptor
+ */
+static void fcrypt_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
+{
+       const struct fcrypt_ctx *ctx = crypto_tfm_ctx(tfm);
+       struct {
+               u32 l, r;
+       } X;
+
+       memcpy(&X, src, sizeof(X));
+
+       F_ENCRYPT(X.l, X.r, ctx->sched[0xf]);
+       F_ENCRYPT(X.r, X.l, ctx->sched[0xe]);
+       F_ENCRYPT(X.l, X.r, ctx->sched[0xd]);
+       F_ENCRYPT(X.r, X.l, ctx->sched[0xc]);
+       F_ENCRYPT(X.l, X.r, ctx->sched[0xb]);
+       F_ENCRYPT(X.r, X.l, ctx->sched[0xa]);
+       F_ENCRYPT(X.l, X.r, ctx->sched[0x9]);
+       F_ENCRYPT(X.r, X.l, ctx->sched[0x8]);
+       F_ENCRYPT(X.l, X.r, ctx->sched[0x7]);
+       F_ENCRYPT(X.r, X.l, ctx->sched[0x6]);
+       F_ENCRYPT(X.l, X.r, ctx->sched[0x5]);
+       F_ENCRYPT(X.r, X.l, ctx->sched[0x4]);
+       F_ENCRYPT(X.l, X.r, ctx->sched[0x3]);
+       F_ENCRYPT(X.r, X.l, ctx->sched[0x2]);
+       F_ENCRYPT(X.l, X.r, ctx->sched[0x1]);
+       F_ENCRYPT(X.r, X.l, ctx->sched[0x0]);
+
+       memcpy(dst, &X, sizeof(X));
+}
+
+/*
+ * Generate a key schedule from key, the least significant bit in each key byte
+ * is parity and shall be ignored. This leaves 56 significant bits in the key
+ * to scatter over the 16 key schedules. For each schedule extract the low
+ * order 32 bits and use as schedule, then rotate right by 11 bits.
+ */
+static int fcrypt_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen)
+{
+       struct fcrypt_ctx *ctx = crypto_tfm_ctx(tfm);
+
+#if BITS_PER_LONG == 64  /* the 64-bit version can also be used for 32-bit
+                         * kernels - it seems to be faster but the code is
+                         * larger */
+
+       u64 k;  /* k holds all 56 non-parity bits */
+
+       /* discard the parity bits */
+       k = (*key++) >> 1;
+       k <<= 7;
+       k |= (*key++) >> 1;
+       k <<= 7;
+       k |= (*key++) >> 1;
+       k <<= 7;
+       k |= (*key++) >> 1;
+       k <<= 7;
+       k |= (*key++) >> 1;
+       k <<= 7;
+       k |= (*key++) >> 1;
+       k <<= 7;
+       k |= (*key++) >> 1;
+       k <<= 7;
+       k |= (*key) >> 1;
+
+       /* Use lower 32 bits for schedule, rotate by 11 each round (16 times) */
+       ctx->sched[0x0] = be32_to_cpu(k); ror56_64(k, 11);
+       ctx->sched[0x1] = be32_to_cpu(k); ror56_64(k, 11);
+       ctx->sched[0x2] = be32_to_cpu(k); ror56_64(k, 11);
+       ctx->sched[0x3] = be32_to_cpu(k); ror56_64(k, 11);
+       ctx->sched[0x4] = be32_to_cpu(k); ror56_64(k, 11);
+       ctx->sched[0x5] = be32_to_cpu(k); ror56_64(k, 11);
+       ctx->sched[0x6] = be32_to_cpu(k); ror56_64(k, 11);
+       ctx->sched[0x7] = be32_to_cpu(k); ror56_64(k, 11);
+       ctx->sched[0x8] = be32_to_cpu(k); ror56_64(k, 11);
+       ctx->sched[0x9] = be32_to_cpu(k); ror56_64(k, 11);
+       ctx->sched[0xa] = be32_to_cpu(k); ror56_64(k, 11);
+       ctx->sched[0xb] = be32_to_cpu(k); ror56_64(k, 11);
+       ctx->sched[0xc] = be32_to_cpu(k); ror56_64(k, 11);
+       ctx->sched[0xd] = be32_to_cpu(k); ror56_64(k, 11);
+       ctx->sched[0xe] = be32_to_cpu(k); ror56_64(k, 11);
+       ctx->sched[0xf] = be32_to_cpu(k);
+
+       return 0;
+#else
+       u32 hi, lo;             /* hi is upper 24 bits and lo lower 32, total 56 */
+
+       /* discard the parity bits */
+       lo = (*key++) >> 1;
+       lo <<= 7;
+       lo |= (*key++) >> 1;
+       lo <<= 7;
+       lo |= (*key++) >> 1;
+       lo <<= 7;
+       lo |= (*key++) >> 1;
+       hi = lo >> 4;
+       lo &= 0xf;
+       lo <<= 7;
+       lo |= (*key++) >> 1;
+       lo <<= 7;
+       lo |= (*key++) >> 1;
+       lo <<= 7;
+       lo |= (*key++) >> 1;
+       lo <<= 7;
+       lo |= (*key) >> 1;
+
+       /* Use lower 32 bits for schedule, rotate by 11 each round (16 times) */
+       ctx->sched[0x0] = be32_to_cpu(lo); ror56(hi, lo, 11);
+       ctx->sched[0x1] = be32_to_cpu(lo); ror56(hi, lo, 11);
+       ctx->sched[0x2] = be32_to_cpu(lo); ror56(hi, lo, 11);
+       ctx->sched[0x3] = be32_to_cpu(lo); ror56(hi, lo, 11);
+       ctx->sched[0x4] = be32_to_cpu(lo); ror56(hi, lo, 11);
+       ctx->sched[0x5] = be32_to_cpu(lo); ror56(hi, lo, 11);
+       ctx->sched[0x6] = be32_to_cpu(lo); ror56(hi, lo, 11);
+       ctx->sched[0x7] = be32_to_cpu(lo); ror56(hi, lo, 11);
+       ctx->sched[0x8] = be32_to_cpu(lo); ror56(hi, lo, 11);
+       ctx->sched[0x9] = be32_to_cpu(lo); ror56(hi, lo, 11);
+       ctx->sched[0xa] = be32_to_cpu(lo); ror56(hi, lo, 11);
+       ctx->sched[0xb] = be32_to_cpu(lo); ror56(hi, lo, 11);
+       ctx->sched[0xc] = be32_to_cpu(lo); ror56(hi, lo, 11);
+       ctx->sched[0xd] = be32_to_cpu(lo); ror56(hi, lo, 11);
+       ctx->sched[0xe] = be32_to_cpu(lo); ror56(hi, lo, 11);
+       ctx->sched[0xf] = be32_to_cpu(lo);
+       return 0;
+#endif
+}
+
+static struct crypto_alg fcrypt_alg = {
+       .cra_name               =       "fcrypt",
+       .cra_flags              =       CRYPTO_ALG_TYPE_CIPHER,
+       .cra_blocksize          =       8,
+       .cra_ctxsize            =       sizeof(struct fcrypt_ctx),
+       .cra_module             =       THIS_MODULE,
+       .cra_alignmask          =       3,
+       .cra_list               =       LIST_HEAD_INIT(fcrypt_alg.cra_list),
+       .cra_u                  =       { .cipher = {
+       .cia_min_keysize        =       8,
+       .cia_max_keysize        =       8,
+       .cia_setkey             =       fcrypt_setkey,
+       .cia_encrypt            =       fcrypt_encrypt,
+       .cia_decrypt            =       fcrypt_decrypt } }
+};
+
+static int __init init(void)
+{
+       return crypto_register_alg(&fcrypt_alg);
+}
+
+static void __exit fini(void)
+{
+       crypto_unregister_alg(&fcrypt_alg);
+}
+
+module_init(init);
+module_exit(fini);
+
+MODULE_LICENSE("Dual BSD/GPL");
+MODULE_DESCRIPTION("FCrypt Cipher Algorithm");
+MODULE_AUTHOR("David Howells <dhowells@redhat.com>");
index cdec23d885fed5630ddec0c347869d507b50fae5..12c4514f3478df49786e7fe36009bb1e4fa95fd6 100644 (file)
 
 #include "internal.h"
 
-static unsigned int crypto_hash_ctxsize(struct crypto_alg *alg)
+static unsigned int crypto_hash_ctxsize(struct crypto_alg *alg, u32 type,
+                                       u32 mask)
 {
        return alg->cra_ctxsize;
 }
 
-static int crypto_init_hash_ops(struct crypto_tfm *tfm)
+static int crypto_init_hash_ops(struct crypto_tfm *tfm, u32 type, u32 mask)
 {
        struct hash_tfm *crt = &tfm->crt_hash;
        struct hash_alg *alg = &tfm->__crt_alg->cra_hash;
index b521bcd2b2c6036f155bc23641d41df877baca18..44187c5ee5933cbf9195ec799d337053ef0e0b8e 100644 (file)
@@ -172,15 +172,16 @@ static int hmac_digest(struct hash_desc *pdesc, struct scatterlist *sg,
 
 static int hmac_init_tfm(struct crypto_tfm *tfm)
 {
+       struct crypto_hash *hash;
        struct crypto_instance *inst = (void *)tfm->__crt_alg;
        struct crypto_spawn *spawn = crypto_instance_ctx(inst);
        struct hmac_ctx *ctx = hmac_ctx(__crypto_hash_cast(tfm));
 
-       tfm = crypto_spawn_tfm(spawn);
-       if (IS_ERR(tfm))
-               return PTR_ERR(tfm);
+       hash = crypto_spawn_hash(spawn);
+       if (IS_ERR(hash))
+               return PTR_ERR(hash);
 
-       ctx->child = crypto_hash_cast(tfm);
+       ctx->child = hash;
        return 0;
 }
 
index 2da6ad4f3593a064a035e9ba796c2c530a269876..60acad9788c50104b7e627aafbb3cd4c0ab57998 100644 (file)
@@ -83,8 +83,7 @@ static inline void crypto_exit_proc(void)
 { }
 #endif
 
-static inline unsigned int crypto_digest_ctxsize(struct crypto_alg *alg,
-                                                int flags)
+static inline unsigned int crypto_digest_ctxsize(struct crypto_alg *alg)
 {
        unsigned int len = alg->cra_ctxsize;
 
@@ -96,23 +95,12 @@ static inline unsigned int crypto_digest_ctxsize(struct crypto_alg *alg,
        return len;
 }
 
-static inline unsigned int crypto_cipher_ctxsize(struct crypto_alg *alg,
-                                                int flags)
+static inline unsigned int crypto_cipher_ctxsize(struct crypto_alg *alg)
 {
-       unsigned int len = alg->cra_ctxsize;
-       
-       switch (flags & CRYPTO_TFM_MODE_MASK) {
-       case CRYPTO_TFM_MODE_CBC:
-               len = ALIGN(len, (unsigned long)alg->cra_alignmask + 1);
-               len += alg->cra_blocksize;
-               break;
-       }
-
-       return len;
+       return alg->cra_ctxsize;
 }
 
-static inline unsigned int crypto_compress_ctxsize(struct crypto_alg *alg,
-                                                  int flags)
+static inline unsigned int crypto_compress_ctxsize(struct crypto_alg *alg)
 {
        return alg->cra_ctxsize;
 }
@@ -121,10 +109,6 @@ struct crypto_alg *crypto_mod_get(struct crypto_alg *alg);
 struct crypto_alg *__crypto_alg_lookup(const char *name, u32 type, u32 mask);
 struct crypto_alg *crypto_alg_mod_lookup(const char *name, u32 type, u32 mask);
 
-int crypto_init_digest_flags(struct crypto_tfm *tfm, u32 flags);
-int crypto_init_cipher_flags(struct crypto_tfm *tfm, u32 flags);
-int crypto_init_compress_flags(struct crypto_tfm *tfm, u32 flags);
-
 int crypto_init_digest_ops(struct crypto_tfm *tfm);
 int crypto_init_cipher_ops(struct crypto_tfm *tfm);
 int crypto_init_compress_ops(struct crypto_tfm *tfm);
@@ -136,7 +120,8 @@ void crypto_exit_compress_ops(struct crypto_tfm *tfm);
 void crypto_larval_error(const char *name, u32 type, u32 mask);
 
 void crypto_shoot_alg(struct crypto_alg *alg);
-struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg, u32 flags);
+struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg, u32 type,
+                                     u32 mask);
 
 int crypto_register_instance(struct crypto_template *tmpl,
                             struct crypto_instance *inst);
index 56642586d84f733b547e1a8ebef539de4a93e760..b4105080ac7aa9d5886ea28772cfea6101197d27 100644 (file)
@@ -201,21 +201,22 @@ static int decrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
 
 static int init_tfm(struct crypto_tfm *tfm)
 {
+       struct crypto_cipher *cipher;
        struct crypto_instance *inst = (void *)tfm->__crt_alg;
        struct crypto_spawn *spawn = crypto_instance_ctx(inst);
        struct priv *ctx = crypto_tfm_ctx(tfm);
        u32 *flags = &tfm->crt_flags;
 
-       tfm = crypto_spawn_tfm(spawn);
-       if (IS_ERR(tfm))
-               return PTR_ERR(tfm);
+       cipher = crypto_spawn_cipher(spawn);
+       if (IS_ERR(cipher))
+               return PTR_ERR(cipher);
 
-       if (crypto_tfm_alg_blocksize(tfm) != 16) {
+       if (crypto_cipher_blocksize(cipher) != 16) {
                *flags |= CRYPTO_TFM_RES_BAD_BLOCK_LEN;
                return -EINVAL;
        }
 
-       ctx->child = crypto_cipher_cast(tfm);
+       ctx->child = cipher;
        return 0;
 }
 
diff --git a/crypto/pcbc.c b/crypto/pcbc.c
new file mode 100644 (file)
index 0000000..5174d7f
--- /dev/null
@@ -0,0 +1,349 @@
+/*
+ * PCBC: Propagating Cipher Block Chaining mode
+ *
+ * Copyright (C) 2006 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowells@redhat.com)
+ *
+ * Derived from cbc.c
+ * - Copyright (c) 2006 Herbert Xu <herbert@gondor.apana.org.au>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ */
+
+#include <crypto/algapi.h>
+#include <linux/err.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/scatterlist.h>
+#include <linux/slab.h>
+
+struct crypto_pcbc_ctx {
+       struct crypto_cipher *child;
+       void (*xor)(u8 *dst, const u8 *src, unsigned int bs);
+};
+
+static int crypto_pcbc_setkey(struct crypto_tfm *parent, const u8 *key,
+                             unsigned int keylen)
+{
+       struct crypto_pcbc_ctx *ctx = crypto_tfm_ctx(parent);
+       struct crypto_cipher *child = ctx->child;
+       int err;
+
+       crypto_cipher_clear_flags(child, CRYPTO_TFM_REQ_MASK);
+       crypto_cipher_set_flags(child, crypto_tfm_get_flags(parent) &
+                               CRYPTO_TFM_REQ_MASK);
+       err = crypto_cipher_setkey(child, key, keylen);
+       crypto_tfm_set_flags(parent, crypto_cipher_get_flags(child) &
+                            CRYPTO_TFM_RES_MASK);
+       return err;
+}
+
+static int crypto_pcbc_encrypt_segment(struct blkcipher_desc *desc,
+                                      struct blkcipher_walk *walk,
+                                      struct crypto_cipher *tfm,
+                                      void (*xor)(u8 *, const u8 *,
+                                                  unsigned int))
+{
+       void (*fn)(struct crypto_tfm *, u8 *, const u8 *) =
+               crypto_cipher_alg(tfm)->cia_encrypt;
+       int bsize = crypto_cipher_blocksize(tfm);
+       unsigned int nbytes = walk->nbytes;
+       u8 *src = walk->src.virt.addr;
+       u8 *dst = walk->dst.virt.addr;
+       u8 *iv = walk->iv;
+
+       do {
+               xor(iv, src, bsize);
+               fn(crypto_cipher_tfm(tfm), dst, iv);
+               memcpy(iv, dst, bsize);
+               xor(iv, src, bsize);
+
+               src += bsize;
+               dst += bsize;
+       } while ((nbytes -= bsize) >= bsize);
+
+       return nbytes;
+}
+
+static int crypto_pcbc_encrypt_inplace(struct blkcipher_desc *desc,
+                                      struct blkcipher_walk *walk,
+                                      struct crypto_cipher *tfm,
+                                      void (*xor)(u8 *, const u8 *,
+                                                  unsigned int))
+{
+       void (*fn)(struct crypto_tfm *, u8 *, const u8 *) =
+               crypto_cipher_alg(tfm)->cia_encrypt;
+       int bsize = crypto_cipher_blocksize(tfm);
+       unsigned int nbytes = walk->nbytes;
+       u8 *src = walk->src.virt.addr;
+       u8 *iv = walk->iv;
+       u8 tmpbuf[bsize];
+
+       do {
+               memcpy(tmpbuf, src, bsize);
+               xor(iv, tmpbuf, bsize);
+               fn(crypto_cipher_tfm(tfm), src, iv);
+               memcpy(iv, src, bsize);
+               xor(iv, tmpbuf, bsize);
+
+               src += bsize;
+       } while ((nbytes -= bsize) >= bsize);
+
+       memcpy(walk->iv, iv, bsize);
+
+       return nbytes;
+}
+
+static int crypto_pcbc_encrypt(struct blkcipher_desc *desc,
+                              struct scatterlist *dst, struct scatterlist *src,
+                              unsigned int nbytes)
+{
+       struct blkcipher_walk walk;
+       struct crypto_blkcipher *tfm = desc->tfm;
+       struct crypto_pcbc_ctx *ctx = crypto_blkcipher_ctx(tfm);
+       struct crypto_cipher *child = ctx->child;
+       void (*xor)(u8 *, const u8 *, unsigned int bs) = ctx->xor;
+       int err;
+
+       blkcipher_walk_init(&walk, dst, src, nbytes);
+       err = blkcipher_walk_virt(desc, &walk);
+
+       while ((nbytes = walk.nbytes)) {
+               if (walk.src.virt.addr == walk.dst.virt.addr)
+                       nbytes = crypto_pcbc_encrypt_inplace(desc, &walk, child,
+                                                            xor);
+               else
+                       nbytes = crypto_pcbc_encrypt_segment(desc, &walk, child,
+                                                            xor);
+               err = blkcipher_walk_done(desc, &walk, nbytes);
+       }
+
+       return err;
+}
+
+static int crypto_pcbc_decrypt_segment(struct blkcipher_desc *desc,
+                                      struct blkcipher_walk *walk,
+                                      struct crypto_cipher *tfm,
+                                      void (*xor)(u8 *, const u8 *,
+                                                  unsigned int))
+{
+       void (*fn)(struct crypto_tfm *, u8 *, const u8 *) =
+               crypto_cipher_alg(tfm)->cia_decrypt;
+       int bsize = crypto_cipher_blocksize(tfm);
+       unsigned int nbytes = walk->nbytes;
+       u8 *src = walk->src.virt.addr;
+       u8 *dst = walk->dst.virt.addr;
+       u8 *iv = walk->iv;
+
+       do {
+               fn(crypto_cipher_tfm(tfm), dst, src);
+               xor(dst, iv, bsize);
+               memcpy(iv, src, bsize);
+               xor(iv, dst, bsize);
+
+               src += bsize;
+               dst += bsize;
+       } while ((nbytes -= bsize) >= bsize);
+
+       memcpy(walk->iv, iv, bsize);
+
+       return nbytes;
+}
+
+static int crypto_pcbc_decrypt_inplace(struct blkcipher_desc *desc,
+                                      struct blkcipher_walk *walk,
+                                      struct crypto_cipher *tfm,
+                                      void (*xor)(u8 *, const u8 *,
+                                                  unsigned int))
+{
+       void (*fn)(struct crypto_tfm *, u8 *, const u8 *) =
+               crypto_cipher_alg(tfm)->cia_decrypt;
+       int bsize = crypto_cipher_blocksize(tfm);
+       unsigned int nbytes = walk->nbytes;
+       u8 *src = walk->src.virt.addr;
+       u8 *iv = walk->iv;
+       u8 tmpbuf[bsize];
+
+       do {
+               memcpy(tmpbuf, src, bsize);
+               fn(crypto_cipher_tfm(tfm), src, src);
+               xor(src, iv, bsize);
+               memcpy(iv, tmpbuf, bsize);
+               xor(iv, src, bsize);
+
+               src += bsize;
+       } while ((nbytes -= bsize) >= bsize);
+
+       memcpy(walk->iv, iv, bsize);
+
+       return nbytes;
+}
+
+static int crypto_pcbc_decrypt(struct blkcipher_desc *desc,
+                              struct scatterlist *dst, struct scatterlist *src,
+                              unsigned int nbytes)
+{
+       struct blkcipher_walk walk;
+       struct crypto_blkcipher *tfm = desc->tfm;
+       struct crypto_pcbc_ctx *ctx = crypto_blkcipher_ctx(tfm);
+       struct crypto_cipher *child = ctx->child;
+       void (*xor)(u8 *, const u8 *, unsigned int bs) = ctx->xor;
+       int err;
+
+       blkcipher_walk_init(&walk, dst, src, nbytes);
+       err = blkcipher_walk_virt(desc, &walk);
+
+       while ((nbytes = walk.nbytes)) {
+               if (walk.src.virt.addr == walk.dst.virt.addr)
+                       nbytes = crypto_pcbc_decrypt_inplace(desc, &walk, child,
+                                                            xor);
+               else
+                       nbytes = crypto_pcbc_decrypt_segment(desc, &walk, child,
+                                                            xor);
+               err = blkcipher_walk_done(desc, &walk, nbytes);
+       }
+
+       return err;
+}
+
+static void xor_byte(u8 *a, const u8 *b, unsigned int bs)
+{
+       do {
+               *a++ ^= *b++;
+       } while (--bs);
+}
+
+static void xor_quad(u8 *dst, const u8 *src, unsigned int bs)
+{
+       u32 *a = (u32 *)dst;
+       u32 *b = (u32 *)src;
+
+       do {
+               *a++ ^= *b++;
+       } while ((bs -= 4));
+}
+
+static void xor_64(u8 *a, const u8 *b, unsigned int bs)
+{
+       ((u32 *)a)[0] ^= ((u32 *)b)[0];
+       ((u32 *)a)[1] ^= ((u32 *)b)[1];
+}
+
+static void xor_128(u8 *a, const u8 *b, unsigned int bs)
+{
+       ((u32 *)a)[0] ^= ((u32 *)b)[0];
+       ((u32 *)a)[1] ^= ((u32 *)b)[1];
+       ((u32 *)a)[2] ^= ((u32 *)b)[2];
+       ((u32 *)a)[3] ^= ((u32 *)b)[3];
+}
+
+static int crypto_pcbc_init_tfm(struct crypto_tfm *tfm)
+{
+       struct crypto_instance *inst = (void *)tfm->__crt_alg;
+       struct crypto_spawn *spawn = crypto_instance_ctx(inst);
+       struct crypto_pcbc_ctx *ctx = crypto_tfm_ctx(tfm);
+       struct crypto_cipher *cipher;
+
+       switch (crypto_tfm_alg_blocksize(tfm)) {
+       case 8:
+               ctx->xor = xor_64;
+               break;
+
+       case 16:
+               ctx->xor = xor_128;
+               break;
+
+       default:
+               if (crypto_tfm_alg_blocksize(tfm) % 4)
+                       ctx->xor = xor_byte;
+               else
+                       ctx->xor = xor_quad;
+       }
+
+       cipher = crypto_spawn_cipher(spawn);
+       if (IS_ERR(cipher))
+               return PTR_ERR(cipher);
+
+       ctx->child = cipher;
+       return 0;
+}
+
+static void crypto_pcbc_exit_tfm(struct crypto_tfm *tfm)
+{
+       struct crypto_pcbc_ctx *ctx = crypto_tfm_ctx(tfm);
+       crypto_free_cipher(ctx->child);
+}
+
+static struct crypto_instance *crypto_pcbc_alloc(void *param, unsigned int len)
+{
+       struct crypto_instance *inst;
+       struct crypto_alg *alg;
+
+       alg = crypto_get_attr_alg(param, len, CRYPTO_ALG_TYPE_CIPHER,
+                                 CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_ASYNC);
+       if (IS_ERR(alg))
+               return ERR_PTR(PTR_ERR(alg));
+
+       inst = crypto_alloc_instance("pcbc", alg);
+       if (IS_ERR(inst))
+               goto out_put_alg;
+
+       inst->alg.cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER;
+       inst->alg.cra_priority = alg->cra_priority;
+       inst->alg.cra_blocksize = alg->cra_blocksize;
+       inst->alg.cra_alignmask = alg->cra_alignmask;
+       inst->alg.cra_type = &crypto_blkcipher_type;
+
+       if (!(alg->cra_blocksize % 4))
+               inst->alg.cra_alignmask |= 3;
+       inst->alg.cra_blkcipher.ivsize = alg->cra_blocksize;
+       inst->alg.cra_blkcipher.min_keysize = alg->cra_cipher.cia_min_keysize;
+       inst->alg.cra_blkcipher.max_keysize = alg->cra_cipher.cia_max_keysize;
+
+       inst->alg.cra_ctxsize = sizeof(struct crypto_pcbc_ctx);
+
+       inst->alg.cra_init = crypto_pcbc_init_tfm;
+       inst->alg.cra_exit = crypto_pcbc_exit_tfm;
+
+       inst->alg.cra_blkcipher.setkey = crypto_pcbc_setkey;
+       inst->alg.cra_blkcipher.encrypt = crypto_pcbc_encrypt;
+       inst->alg.cra_blkcipher.decrypt = crypto_pcbc_decrypt;
+
+out_put_alg:
+       crypto_mod_put(alg);
+       return inst;
+}
+
+static void crypto_pcbc_free(struct crypto_instance *inst)
+{
+       crypto_drop_spawn(crypto_instance_ctx(inst));
+       kfree(inst);
+}
+
+static struct crypto_template crypto_pcbc_tmpl = {
+       .name = "pcbc",
+       .alloc = crypto_pcbc_alloc,
+       .free = crypto_pcbc_free,
+       .module = THIS_MODULE,
+};
+
+static int __init crypto_pcbc_module_init(void)
+{
+       return crypto_register_template(&crypto_pcbc_tmpl);
+}
+
+static void __exit crypto_pcbc_module_exit(void)
+{
+       crypto_unregister_template(&crypto_pcbc_tmpl);
+}
+
+module_init(crypto_pcbc_module_init);
+module_exit(crypto_pcbc_module_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("PCBC block cipher algorithm");
index d671e8942b1f7d2c774a46a56aada52bf76dca39..f5e9da319ece70cf6823a94947c3ee4f08273d89 100644 (file)
@@ -12,6 +12,7 @@
  * Software Foundation; either version 2 of the License, or (at your option)
  * any later version.
  *
+ * 2006-12-07 Added SHA384 HMAC and SHA512 HMAC tests
  * 2004-08-09 Added cipher speed tests (Reyk Floeter <reyk@vantronix.net>)
  * 2003-09-14 Rewritten by Kartikey Mahendra Bhatt
  *
@@ -71,7 +72,8 @@ static char *check[] = {
        "des", "md5", "des3_ede", "rot13", "sha1", "sha256", "blowfish",
        "twofish", "serpent", "sha384", "sha512", "md4", "aes", "cast6",
        "arc4", "michael_mic", "deflate", "crc32c", "tea", "xtea",
-       "khazad", "wp512", "wp384", "wp256", "tnepres", "xeta", NULL
+       "khazad", "wp512", "wp384", "wp256", "tnepres", "xeta",  "fcrypt",
+       "camellia", NULL
 };
 
 static void hexdump(unsigned char *buf, unsigned int len)
@@ -765,7 +767,7 @@ static void test_deflate(void)
        memcpy(tvmem, deflate_comp_tv_template, tsize);
        tv = (void *)tvmem;
 
-       tfm = crypto_alloc_tfm("deflate", 0);
+       tfm = crypto_alloc_comp("deflate", 0, CRYPTO_ALG_ASYNC);
        if (tfm == NULL) {
                printk("failed to load transform for deflate\n");
                return;
@@ -964,6 +966,26 @@ static void do_test(void)
                test_cipher("ecb(xeta)", DECRYPT, xeta_dec_tv_template,
                            XETA_DEC_TEST_VECTORS);
 
+               //FCrypt
+               test_cipher("pcbc(fcrypt)", ENCRYPT, fcrypt_pcbc_enc_tv_template,
+                           FCRYPT_ENC_TEST_VECTORS);
+               test_cipher("pcbc(fcrypt)", DECRYPT, fcrypt_pcbc_dec_tv_template,
+                           FCRYPT_DEC_TEST_VECTORS);
+
+               //CAMELLIA
+               test_cipher("ecb(camellia)", ENCRYPT,
+                           camellia_enc_tv_template,
+                           CAMELLIA_ENC_TEST_VECTORS);
+               test_cipher("ecb(camellia)", DECRYPT,
+                           camellia_dec_tv_template,
+                           CAMELLIA_DEC_TEST_VECTORS);
+               test_cipher("cbc(camellia)", ENCRYPT,
+                           camellia_cbc_enc_tv_template,
+                           CAMELLIA_CBC_ENC_TEST_VECTORS);
+               test_cipher("cbc(camellia)", DECRYPT,
+                           camellia_cbc_dec_tv_template,
+                           CAMELLIA_CBC_DEC_TEST_VECTORS);
+
                test_hash("sha384", sha384_tv_template, SHA384_TEST_VECTORS);
                test_hash("sha512", sha512_tv_template, SHA512_TEST_VECTORS);
                test_hash("wp512", wp512_tv_template, WP512_TEST_VECTORS);
@@ -980,6 +1002,10 @@ static void do_test(void)
                          HMAC_SHA1_TEST_VECTORS);
                test_hash("hmac(sha256)", hmac_sha256_tv_template,
                          HMAC_SHA256_TEST_VECTORS);
+               test_hash("hmac(sha384)", hmac_sha384_tv_template,
+                         HMAC_SHA384_TEST_VECTORS);
+               test_hash("hmac(sha512)", hmac_sha512_tv_template,
+                         HMAC_SHA512_TEST_VECTORS);
 
                test_hash("xcbc(aes)", aes_xcbc128_tv_template,
                          XCBC_AES_TEST_VECTORS);
@@ -1177,6 +1203,28 @@ static void do_test(void)
                            XETA_DEC_TEST_VECTORS);
                break;
 
+       case 31:
+               test_cipher("pcbc(fcrypt)", ENCRYPT, fcrypt_pcbc_enc_tv_template,
+                           FCRYPT_ENC_TEST_VECTORS);
+               test_cipher("pcbc(fcrypt)", DECRYPT, fcrypt_pcbc_dec_tv_template,
+                           FCRYPT_DEC_TEST_VECTORS);
+               break;
+
+       case 32:
+               test_cipher("ecb(camellia)", ENCRYPT,
+                           camellia_enc_tv_template,
+                           CAMELLIA_ENC_TEST_VECTORS);
+               test_cipher("ecb(camellia)", DECRYPT,
+                           camellia_dec_tv_template,
+                           CAMELLIA_DEC_TEST_VECTORS);
+               test_cipher("cbc(camellia)", ENCRYPT,
+                           camellia_cbc_enc_tv_template,
+                           CAMELLIA_CBC_ENC_TEST_VECTORS);
+               test_cipher("cbc(camellia)", DECRYPT,
+                           camellia_cbc_dec_tv_template,
+                           CAMELLIA_CBC_DEC_TEST_VECTORS);
+               break;
+
        case 100:
                test_hash("hmac(md5)", hmac_md5_tv_template,
                          HMAC_MD5_TEST_VECTORS);
@@ -1192,6 +1240,16 @@ static void do_test(void)
                          HMAC_SHA256_TEST_VECTORS);
                break;
 
+       case 103:
+               test_hash("hmac(sha384)", hmac_sha384_tv_template,
+                         HMAC_SHA384_TEST_VECTORS);
+               break;
+
+       case 104:
+               test_hash("hmac(sha512)", hmac_sha512_tv_template,
+                         HMAC_SHA512_TEST_VECTORS);
+               break;
+
 
        case 200:
                test_cipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0,
@@ -1260,6 +1318,17 @@ static void do_test(void)
                                  des_speed_template);
                break;
 
+       case 205:
+               test_cipher_speed("ecb(camellia)", ENCRYPT, sec, NULL, 0,
+                               camellia_speed_template);
+               test_cipher_speed("ecb(camellia)", DECRYPT, sec, NULL, 0,
+                               camellia_speed_template);
+               test_cipher_speed("cbc(camellia)", ENCRYPT, sec, NULL, 0,
+                               camellia_speed_template);
+               test_cipher_speed("cbc(camellia)", DECRYPT, sec, NULL, 0,
+                               camellia_speed_template);
+               break;
+
        case 300:
                /* fall through */
 
index 48a81362cb851b7e0c9163191d2a61e14ca6d2ab..887527bd5bc6613260075f3bc9e3b850953ddcbf 100644 (file)
@@ -12,6 +12,7 @@
  * Software Foundation; either version 2 of the License, or (at your option)
  * any later version.
  *
+ * 2006-12-07 Added SHA384 HMAC and SHA512 HMAC tests
  * 2004-08-09 Cipher speed tests by Reyk Floeter <reyk@vantronix.net>
  * 2003-09-14 Changes by Kartikey Mahendra Bhatt
  *
@@ -27,7 +28,7 @@
 
 struct hash_testvec {
        /* only used with keyed hash algorithms */
-       char key[128] __attribute__ ((__aligned__(4)));
+       char key[132] __attribute__ ((__aligned__(4)));
        char plaintext[240];
        char digest[MAX_DIGEST_SIZE];
        unsigned char tap[MAX_TAP];
@@ -1001,6 +1002,248 @@ static struct hash_testvec aes_xcbc128_tv_template[] = {
        }
 };
 
+/*
+ * SHA384 HMAC test vectors from RFC4231
+ */
+
+#define HMAC_SHA384_TEST_VECTORS       4
+
+static struct hash_testvec hmac_sha384_tv_template[] = {
+       {
+               .key    = { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
+                           0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
+                           0x0b, 0x0b, 0x0b, 0x0b }, // (20 bytes)
+               .ksize  = 20,
+               .plaintext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65 }, // ("Hi There")
+               .psize  = 8,
+               .digest = { 0xaf, 0xd0, 0x39, 0x44, 0xd8, 0x48, 0x95, 0x62,
+                           0x6b, 0x08, 0x25, 0xf4, 0xab, 0x46, 0x90, 0x7f,
+                           0x15, 0xf9, 0xda, 0xdb, 0xe4, 0x10, 0x1e, 0xc6,
+                           0x82, 0xaa, 0x03, 0x4c, 0x7c, 0xeb, 0xc5, 0x9c,
+                           0xfa, 0xea, 0x9e, 0xa9, 0x07, 0x6e, 0xde, 0x7f,
+                           0x4a, 0xf1, 0x52, 0xe8, 0xb2, 0xfa, 0x9c, 0xb6 },
+       }, {
+               .key    = { 0x4a, 0x65, 0x66, 0x65 }, // ("Jefe")
+               .ksize  = 4,
+               .plaintext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20,
+                              0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20, // ("what do ya want ")
+                              0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68,
+                              0x69, 0x6e, 0x67, 0x3f }, // ("for nothing?")
+               .psize  = 28,
+               .digest = { 0xaf, 0x45, 0xd2, 0xe3, 0x76, 0x48, 0x40, 0x31,
+                           0x61, 0x7f, 0x78, 0xd2, 0xb5, 0x8a, 0x6b, 0x1b,
+                           0x9c, 0x7e, 0xf4, 0x64, 0xf5, 0xa0, 0x1b, 0x47,
+                           0xe4, 0x2e, 0xc3, 0x73, 0x63, 0x22, 0x44, 0x5e,
+                           0x8e, 0x22, 0x40, 0xca, 0x5e, 0x69, 0xe2, 0xc7,
+                           0x8b, 0x32, 0x39, 0xec, 0xfa, 0xb2, 0x16, 0x49 },
+               .np     = 4,
+               .tap    = { 7, 7, 7, 7 }
+       }, {
+               .key    = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa }, // (131 bytes)
+               .ksize  = 131,
+               .plaintext = { 0x54, 0x65, 0x73, 0x74, 0x20, 0x55, 0x73, 0x69,
+                              0x6e, 0x67, 0x20, 0x4c, 0x61, 0x72, 0x67, 0x65, // ("Test Using Large")
+                              0x72, 0x20, 0x54, 0x68, 0x61, 0x6e, 0x20, 0x42,
+                              0x6c, 0x6f, 0x63, 0x6b, 0x2d, 0x53, 0x69, 0x7a, // ("r Than Block-Siz")
+                              0x65, 0x20, 0x4b, 0x65, 0x79, 0x20, 0x2d, 0x20,
+                              0x48, 0x61, 0x73, 0x68, 0x20, 0x4b, 0x65, 0x79, // ("e Key - Hash Key")
+                              0x20, 0x46, 0x69, 0x72, 0x73, 0x74 }, // (" First")
+               .psize  = 54,
+               .digest = { 0x4e, 0xce, 0x08, 0x44, 0x85, 0x81, 0x3e, 0x90,
+                           0x88, 0xd2, 0xc6, 0x3a, 0x04, 0x1b, 0xc5, 0xb4,
+                           0x4f, 0x9e, 0xf1, 0x01, 0x2a, 0x2b, 0x58, 0x8f,
+                           0x3c, 0xd1, 0x1f, 0x05, 0x03, 0x3a, 0xc4, 0xc6,
+                           0x0c, 0x2e, 0xf6, 0xab, 0x40, 0x30, 0xfe, 0x82,
+                           0x96, 0x24, 0x8d, 0xf1, 0x63, 0xf4, 0x49, 0x52 },
+       }, {
+               .key    = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa }, // (131 bytes)
+               .ksize  = 131,
+               .plaintext = { 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20,
+                              0x61, 0x20, 0x74, 0x65, 0x73, 0x74, 0x20, 0x75, // ("This is a test u")
+                              0x73, 0x69, 0x6e, 0x67, 0x20, 0x61, 0x20, 0x6c,
+                              0x61, 0x72, 0x67, 0x65, 0x72, 0x20, 0x74, 0x68, // ("sing a larger th")
+                              0x61, 0x6e, 0x20, 0x62, 0x6c, 0x6f, 0x63, 0x6b,
+                              0x2d, 0x73, 0x69, 0x7a, 0x65, 0x20, 0x6b, 0x65, // ("an block-size ke")
+                              0x79, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x61, 0x20,
+                              0x6c, 0x61, 0x72, 0x67, 0x65, 0x72, 0x20, 0x74, // ("y and a larger t")
+                              0x68, 0x61, 0x6e, 0x20, 0x62, 0x6c, 0x6f, 0x63,
+                              0x6b, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x20, 0x64, // ("han block-size d")
+                              0x61, 0x74, 0x61, 0x2e, 0x20, 0x54, 0x68, 0x65,
+                              0x20, 0x6b, 0x65, 0x79, 0x20, 0x6e, 0x65, 0x65, // ("ata. The key nee")
+                              0x64, 0x73, 0x20, 0x74, 0x6f, 0x20, 0x62, 0x65,
+                              0x20, 0x68, 0x61, 0x73, 0x68, 0x65, 0x64, 0x20, // ("ds to be hashed ")
+                              0x62, 0x65, 0x66, 0x6f, 0x72, 0x65, 0x20, 0x62,
+                              0x65, 0x69, 0x6e, 0x67, 0x20, 0x75, 0x73, 0x65, // ("before being use")
+                              0x64, 0x20, 0x62, 0x79, 0x20, 0x74, 0x68, 0x65,
+                              0x20, 0x48, 0x4d, 0x41, 0x43, 0x20, 0x61, 0x6c, // ("d by the HMAC al")
+                              0x67, 0x6f, 0x72, 0x69, 0x74, 0x68, 0x6d, 0x2e }, // ("gorithm.")
+               .psize  = 152,
+               .digest = { 0x66, 0x17, 0x17, 0x8e, 0x94, 0x1f, 0x02, 0x0d,
+                           0x35, 0x1e, 0x2f, 0x25, 0x4e, 0x8f, 0xd3, 0x2c,
+                           0x60, 0x24, 0x20, 0xfe, 0xb0, 0xb8, 0xfb, 0x9a,
+                           0xdc, 0xce, 0xbb, 0x82, 0x46, 0x1e, 0x99, 0xc5,
+                           0xa6, 0x78, 0xcc, 0x31, 0xe7, 0x99, 0x17, 0x6d,
+                           0x38, 0x60, 0xe6, 0x11, 0x0c, 0x46, 0x52, 0x3e },
+       },
+};
+
+/*
+ * SHA512 HMAC test vectors from RFC4231
+ */
+
+#define HMAC_SHA512_TEST_VECTORS       4
+
+static struct hash_testvec hmac_sha512_tv_template[] = {
+       {
+               .key    = { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
+                           0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
+                           0x0b, 0x0b, 0x0b, 0x0b }, // (20 bytes)
+               .ksize  = 20,
+               .plaintext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65 }, // ("Hi There")
+               .psize  = 8,
+               .digest = { 0x87, 0xaa, 0x7c, 0xde, 0xa5, 0xef, 0x61, 0x9d,
+                           0x4f, 0xf0, 0xb4, 0x24, 0x1a, 0x1d, 0x6c, 0xb0,
+                           0x23, 0x79, 0xf4, 0xe2, 0xce, 0x4e, 0xc2, 0x78,
+                           0x7a, 0xd0, 0xb3, 0x05, 0x45, 0xe1, 0x7c, 0xde,
+                           0xda, 0xa8, 0x33, 0xb7, 0xd6, 0xb8, 0xa7, 0x02,
+                           0x03, 0x8b, 0x27, 0x4e, 0xae, 0xa3, 0xf4, 0xe4,
+                           0xbe, 0x9d, 0x91, 0x4e, 0xeb, 0x61, 0xf1, 0x70,
+                           0x2e, 0x69, 0x6c, 0x20, 0x3a, 0x12, 0x68, 0x54 },
+       }, {
+               .key    = { 0x4a, 0x65, 0x66, 0x65 }, // ("Jefe")
+               .ksize  = 4,
+               .plaintext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20,
+                              0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20, // ("what do ya want ")
+                              0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68,
+                              0x69, 0x6e, 0x67, 0x3f }, // ("for nothing?")
+               .psize  = 28,
+               .digest = { 0x16, 0x4b, 0x7a, 0x7b, 0xfc, 0xf8, 0x19, 0xe2,
+                           0xe3, 0x95, 0xfb, 0xe7, 0x3b, 0x56, 0xe0, 0xa3,
+                           0x87, 0xbd, 0x64, 0x22, 0x2e, 0x83, 0x1f, 0xd6,
+                           0x10, 0x27, 0x0c, 0xd7, 0xea, 0x25, 0x05, 0x54,
+                           0x97, 0x58, 0xbf, 0x75, 0xc0, 0x5a, 0x99, 0x4a,
+                           0x6d, 0x03, 0x4f, 0x65, 0xf8, 0xf0, 0xe6, 0xfd,
+                           0xca, 0xea, 0xb1, 0xa3, 0x4d, 0x4a, 0x6b, 0x4b,
+                           0x63, 0x6e, 0x07, 0x0a, 0x38, 0xbc, 0xe7, 0x37 },
+               .np     = 4,
+               .tap    = { 7, 7, 7, 7 }
+       }, {
+               .key    = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa }, // (131 bytes)
+               .ksize  = 131,
+               .plaintext = { 0x54, 0x65, 0x73, 0x74, 0x20, 0x55, 0x73, 0x69,
+                              0x6e, 0x67, 0x20, 0x4c, 0x61, 0x72, 0x67, 0x65, // ("Test Using Large")
+                              0x72, 0x20, 0x54, 0x68, 0x61, 0x6e, 0x20, 0x42,
+                              0x6c, 0x6f, 0x63, 0x6b, 0x2d, 0x53, 0x69, 0x7a, // ("r Than Block-Siz")
+                              0x65, 0x20, 0x4b, 0x65, 0x79, 0x20, 0x2d, 0x20,
+                              0x48, 0x61, 0x73, 0x68, 0x20, 0x4b, 0x65, 0x79, // ("e Key - Hash Key")
+                              0x20, 0x46, 0x69, 0x72, 0x73, 0x74 }, // (" First")
+               .psize  = 54,
+               .digest = { 0x80, 0xb2, 0x42, 0x63, 0xc7, 0xc1, 0xa3, 0xeb,
+                           0xb7, 0x14, 0x93, 0xc1, 0xdd, 0x7b, 0xe8, 0xb4,
+                           0x9b, 0x46, 0xd1, 0xf4, 0x1b, 0x4a, 0xee, 0xc1,
+                           0x12, 0x1b, 0x01, 0x37, 0x83, 0xf8, 0xf3, 0x52,
+                           0x6b, 0x56, 0xd0, 0x37, 0xe0, 0x5f, 0x25, 0x98,
+                           0xbd, 0x0f, 0xd2, 0x21, 0x5d, 0x6a, 0x1e, 0x52,
+                           0x95, 0xe6, 0x4f, 0x73, 0xf6, 0x3f, 0x0a, 0xec,
+                           0x8b, 0x91, 0x5a, 0x98, 0x5d, 0x78, 0x65, 0x98 },
+       }, {
+               .key    = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                           0xaa, 0xaa, 0xaa }, // (131 bytes)
+               .ksize  = 131,
+               .plaintext = { 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20,
+                              0x61, 0x20, 0x74, 0x65, 0x73, 0x74, 0x20, 0x75, // ("This is a test u")
+                              0x73, 0x69, 0x6e, 0x67, 0x20, 0x61, 0x20, 0x6c,
+                              0x61, 0x72, 0x67, 0x65, 0x72, 0x20, 0x74, 0x68, // ("sing a larger th")
+                              0x61, 0x6e, 0x20, 0x62, 0x6c, 0x6f, 0x63, 0x6b,
+                              0x2d, 0x73, 0x69, 0x7a, 0x65, 0x20, 0x6b, 0x65, // ("an block-size ke")
+                              0x79, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x61, 0x20,
+                              0x6c, 0x61, 0x72, 0x67, 0x65, 0x72, 0x20, 0x74, // ("y and a larger t")
+                              0x68, 0x61, 0x6e, 0x20, 0x62, 0x6c, 0x6f, 0x63,
+                              0x6b, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x20, 0x64, // ("han block-size d")
+                              0x61, 0x74, 0x61, 0x2e, 0x20, 0x54, 0x68, 0x65,
+                              0x20, 0x6b, 0x65, 0x79, 0x20, 0x6e, 0x65, 0x65, // ("ata. The key nee")
+                              0x64, 0x73, 0x20, 0x74, 0x6f, 0x20, 0x62, 0x65,
+                              0x20, 0x68, 0x61, 0x73, 0x68, 0x65, 0x64, 0x20, // ("ds to be hashed ")
+                              0x62, 0x65, 0x66, 0x6f, 0x72, 0x65, 0x20, 0x62,
+                              0x65, 0x69, 0x6e, 0x67, 0x20, 0x75, 0x73, 0x65, // ("before being use")
+                              0x64, 0x20, 0x62, 0x79, 0x20, 0x74, 0x68, 0x65,
+                              0x20, 0x48, 0x4d, 0x41, 0x43, 0x20, 0x61, 0x6c, // ("d by the HMAC al")
+                              0x67, 0x6f, 0x72, 0x69, 0x74, 0x68, 0x6d, 0x2e }, // ("gorithm.")
+               .psize  = 152,
+               .digest = { 0xe3, 0x7b, 0x6a, 0x77, 0x5d, 0xc8, 0x7d, 0xba,
+                           0xa4, 0xdf, 0xa9, 0xf9, 0x6e, 0x5e, 0x3f, 0xfd,
+                           0xde, 0xbd, 0x71, 0xf8, 0x86, 0x72, 0x89, 0x86,
+                           0x5d, 0xf5, 0xa3, 0x2d, 0x20, 0xcd, 0xc9, 0x44,
+                           0xb6, 0x02, 0x2c, 0xac, 0x3c, 0x49, 0x82, 0xb1,
+                           0x0d, 0x5e, 0xeb, 0x55, 0xc3, 0xe4, 0xde, 0x15,
+                           0x13, 0x46, 0x76, 0xfb, 0x6d, 0xe0, 0x44, 0x60,
+                           0x65, 0xc9, 0x74, 0x40, 0xfa, 0x8c, 0x6a, 0x58 },
+       },
+};
+
 /*
  * DES test vectors.
  */
@@ -3316,6 +3559,278 @@ static struct cipher_testvec xeta_dec_tv_template[] = {
        }
 };
 
+/* 
+ * FCrypt test vectors 
+ */
+#define FCRYPT_ENC_TEST_VECTORS        ARRAY_SIZE(fcrypt_pcbc_enc_tv_template)
+#define FCRYPT_DEC_TEST_VECTORS        ARRAY_SIZE(fcrypt_pcbc_dec_tv_template)
+
+static struct cipher_testvec fcrypt_pcbc_enc_tv_template[] = {
+       { /* http://www.openafs.org/pipermail/openafs-devel/2000-December/005320.html */
+               .key    = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
+               .klen   = 8,
+               .iv     = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
+               .input  = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
+               .ilen   = 8,
+               .result = { 0x0E, 0x09, 0x00, 0xC7, 0x3E, 0xF7, 0xED, 0x41 },
+               .rlen   = 8,
+       }, {
+               .key    = { 0x11, 0x44, 0x77, 0xAA, 0xDD, 0x00, 0x33, 0x66 },
+               .klen   = 8,
+               .iv     = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
+               .input  = { 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0 },
+               .ilen   = 8,
+               .result = { 0xD8, 0xED, 0x78, 0x74, 0x77, 0xEC, 0x06, 0x80 },
+               .rlen   = 8,
+       }, { /* From Arla */
+               .key    = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87 },
+               .klen   = 8,
+               .iv     = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
+               .input  = "The quick brown fox jumps over the lazy dogs.\0\0",
+               .ilen   = 48,
+               .result = { 0x00, 0xf0, 0xe,  0x11, 0x75, 0xe6, 0x23, 0x82,
+                           0xee, 0xac, 0x98, 0x62, 0x44, 0x51, 0xe4, 0x84,
+                           0xc3, 0x59, 0xd8, 0xaa, 0x64, 0x60, 0xae, 0xf7,
+                           0xd2, 0xd9, 0x13, 0x79, 0x72, 0xa3, 0x45, 0x03,
+                           0x23, 0xb5, 0x62, 0xd7, 0x0c, 0xf5, 0x27, 0xd1,
+                           0xf8, 0x91, 0x3c, 0xac, 0x44, 0x22, 0x92, 0xef },
+               .rlen   = 48,
+       }, {
+               .key    = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
+               .klen   = 8,
+               .iv     = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87 },
+               .input  = "The quick brown fox jumps over the lazy dogs.\0\0",
+               .ilen   = 48,
+               .result = { 0xca, 0x90, 0xf5, 0x9d, 0xcb, 0xd4, 0xd2, 0x3c,
+                           0x01, 0x88, 0x7f, 0x3e, 0x31, 0x6e, 0x62, 0x9d,
+                           0xd8, 0xe0, 0x57, 0xa3, 0x06, 0x3a, 0x42, 0x58,
+                           0x2a, 0x28, 0xfe, 0x72, 0x52, 0x2f, 0xdd, 0xe0,
+                           0x19, 0x89, 0x09, 0x1c, 0x2a, 0x8e, 0x8c, 0x94,
+                           0xfc, 0xc7, 0x68, 0xe4, 0x88, 0xaa, 0xde, 0x0f },
+               .rlen   = 48,
+       }, { /* split-page version */
+               .key    = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
+               .klen   = 8,
+               .iv     = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87 },
+               .input  = "The quick brown fox jumps over the lazy dogs.\0\0",
+               .ilen   = 48,
+               .result = { 0xca, 0x90, 0xf5, 0x9d, 0xcb, 0xd4, 0xd2, 0x3c,
+                           0x01, 0x88, 0x7f, 0x3e, 0x31, 0x6e, 0x62, 0x9d,
+                           0xd8, 0xe0, 0x57, 0xa3, 0x06, 0x3a, 0x42, 0x58,
+                           0x2a, 0x28, 0xfe, 0x72, 0x52, 0x2f, 0xdd, 0xe0,
+                           0x19, 0x89, 0x09, 0x1c, 0x2a, 0x8e, 0x8c, 0x94,
+                           0xfc, 0xc7, 0x68, 0xe4, 0x88, 0xaa, 0xde, 0x0f },
+               .rlen   = 48,
+               .np     = 2,
+               .tap    = { 20, 28 },
+       }
+};
+
+static struct cipher_testvec fcrypt_pcbc_dec_tv_template[] = {
+       { /* http://www.openafs.org/pipermail/openafs-devel/2000-December/005320.html */
+               .key    = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
+               .klen   = 8,
+               .iv     = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
+               .input  = { 0x0E, 0x09, 0x00, 0xC7, 0x3E, 0xF7, 0xED, 0x41 },
+               .ilen   = 8,
+               .result = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
+               .rlen   = 8,
+       }, {
+               .key    = { 0x11, 0x44, 0x77, 0xAA, 0xDD, 0x00, 0x33, 0x66 },
+               .klen   = 8,
+               .iv     = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
+               .input  = { 0xD8, 0xED, 0x78, 0x74, 0x77, 0xEC, 0x06, 0x80 },
+               .ilen   = 8,
+               .result = { 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0 },
+               .rlen   = 8,
+       }, { /* From Arla */
+               .key    = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87 },
+               .klen   = 8,
+               .iv     = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
+               .input  = { 0x00, 0xf0, 0xe,  0x11, 0x75, 0xe6, 0x23, 0x82,
+                           0xee, 0xac, 0x98, 0x62, 0x44, 0x51, 0xe4, 0x84,
+                           0xc3, 0x59, 0xd8, 0xaa, 0x64, 0x60, 0xae, 0xf7,
+                           0xd2, 0xd9, 0x13, 0x79, 0x72, 0xa3, 0x45, 0x03,
+                           0x23, 0xb5, 0x62, 0xd7, 0x0c, 0xf5, 0x27, 0xd1,
+                           0xf8, 0x91, 0x3c, 0xac, 0x44, 0x22, 0x92, 0xef },
+               .ilen   = 48,
+               .result = "The quick brown fox jumps over the lazy dogs.\0\0",
+               .rlen   = 48,
+       }, {
+               .key    = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
+               .klen   = 8,
+               .iv     = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87 },
+               .input  = { 0xca, 0x90, 0xf5, 0x9d, 0xcb, 0xd4, 0xd2, 0x3c,
+                           0x01, 0x88, 0x7f, 0x3e, 0x31, 0x6e, 0x62, 0x9d,
+                           0xd8, 0xe0, 0x57, 0xa3, 0x06, 0x3a, 0x42, 0x58,
+                           0x2a, 0x28, 0xfe, 0x72, 0x52, 0x2f, 0xdd, 0xe0,
+                           0x19, 0x89, 0x09, 0x1c, 0x2a, 0x8e, 0x8c, 0x94,
+                           0xfc, 0xc7, 0x68, 0xe4, 0x88, 0xaa, 0xde, 0x0f },
+               .ilen   = 48,
+               .result = "The quick brown fox jumps over the lazy dogs.\0\0",
+               .rlen   = 48,
+       }, { /* split-page version */
+               .key    = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
+               .klen   = 8,
+               .iv     = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87 },
+               .input  = { 0xca, 0x90, 0xf5, 0x9d, 0xcb, 0xd4, 0xd2, 0x3c,
+                           0x01, 0x88, 0x7f, 0x3e, 0x31, 0x6e, 0x62, 0x9d,
+                           0xd8, 0xe0, 0x57, 0xa3, 0x06, 0x3a, 0x42, 0x58,
+                           0x2a, 0x28, 0xfe, 0x72, 0x52, 0x2f, 0xdd, 0xe0,
+                           0x19, 0x89, 0x09, 0x1c, 0x2a, 0x8e, 0x8c, 0x94,
+                           0xfc, 0xc7, 0x68, 0xe4, 0x88, 0xaa, 0xde, 0x0f },
+               .ilen   = 48,
+               .result = "The quick brown fox jumps over the lazy dogs.\0\0",
+               .rlen   = 48,
+               .np     = 2,
+               .tap    = { 20, 28 },
+       }
+};
+
+/*
+ * CAMELLIA test vectors.
+ */
+#define CAMELLIA_ENC_TEST_VECTORS 3
+#define CAMELLIA_DEC_TEST_VECTORS 3
+#define CAMELLIA_CBC_ENC_TEST_VECTORS 2
+#define CAMELLIA_CBC_DEC_TEST_VECTORS 2
+
+static struct cipher_testvec camellia_enc_tv_template[] = {
+       {
+               .key    = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
+                           0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
+               .klen   = 16,
+               .input  = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
+                           0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
+               .ilen   = 16,
+               .result = { 0x67, 0x67, 0x31, 0x38, 0x54, 0x96, 0x69, 0x73,
+                           0x08, 0x57, 0x06, 0x56, 0x48, 0xea, 0xbe, 0x43 },
+               .rlen   = 16,
+       }, {
+               .key    = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
+                           0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
+                           0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 },
+               .klen   = 24,
+               .input  = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
+                           0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
+               .ilen   = 16,
+               .result = { 0xb4, 0x99, 0x34, 0x01, 0xb3, 0xe9, 0x96, 0xf8,
+                           0x4e, 0xe5, 0xce, 0xe7, 0xd7, 0x9b, 0x09, 0xb9 },
+               .rlen   = 16,
+       }, {
+               .key    = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
+                           0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
+                           0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
+                           0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
+               .klen   = 32,
+               .input  = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
+                           0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
+               .ilen   = 16,
+               .result = { 0x9a, 0xcc, 0x23, 0x7d, 0xff, 0x16, 0xd7, 0x6c,
+                           0x20, 0xef, 0x7c, 0x91, 0x9e, 0x3a, 0x75, 0x09 },
+               .rlen   = 16,
+       },
+};
+
+static struct cipher_testvec camellia_dec_tv_template[] = {
+       {
+               .key    = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
+                           0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
+               .klen   = 16,
+               .input  = { 0x67, 0x67, 0x31, 0x38, 0x54, 0x96, 0x69, 0x73,
+                           0x08, 0x57, 0x06, 0x56, 0x48, 0xea, 0xbe, 0x43 },
+               .ilen   = 16,
+               .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
+                           0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
+               .rlen   = 16,
+       }, {
+               .key    = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
+                           0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
+                           0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 },
+               .klen   = 24,
+               .input  = { 0xb4, 0x99, 0x34, 0x01, 0xb3, 0xe9, 0x96, 0xf8,
+                           0x4e, 0xe5, 0xce, 0xe7, 0xd7, 0x9b, 0x09, 0xb9 },
+               .ilen   = 16,
+               .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
+                           0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
+               .rlen   = 16,
+       }, {
+               .key    = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
+                           0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
+                           0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
+                           0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
+               .klen   = 32,
+               .input  = { 0x9a, 0xcc, 0x23, 0x7d, 0xff, 0x16, 0xd7, 0x6c,
+                           0x20, 0xef, 0x7c, 0x91, 0x9e, 0x3a, 0x75, 0x09 },
+               .ilen   = 16,
+               .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
+                           0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
+               .rlen   = 16,
+       },
+};
+
+static struct cipher_testvec camellia_cbc_enc_tv_template[] = {
+       {
+               .key    = { 0x06, 0xa9, 0x21, 0x40, 0x36, 0xb8, 0xa1, 0x5b,
+                           0x51, 0x2e, 0x03, 0xd5, 0x34, 0x12, 0x00, 0x06 },
+               .klen   = 16,
+               .iv     = { 0x3d, 0xaf, 0xba, 0x42, 0x9d, 0x9e, 0xb4, 0x30,
+                           0xb4, 0x22, 0xda, 0x80, 0x2c, 0x9f, 0xac, 0x41 },
+               .input  = { "Single block msg" },
+               .ilen   = 16,
+               .result = { 0xea, 0x32, 0x12, 0x76, 0x3b, 0x50, 0x10, 0xe7,
+                           0x18, 0xf6, 0xfd, 0x5d, 0xf6, 0x8f, 0x13, 0x51 },
+               .rlen   = 16,
+       }, {
+               .key    = { 0xc2, 0x86, 0x69, 0x6d, 0x88, 0x7c, 0x9a, 0xa0,
+                           0x61, 0x1b, 0xbb, 0x3e, 0x20, 0x25, 0xa4, 0x5a },
+               .klen   = 16,
+               .iv     = { 0x56, 0x2e, 0x17, 0x99, 0x6d, 0x09, 0x3d, 0x28,
+                           0xdd, 0xb3, 0xba, 0x69, 0x5a, 0x2e, 0x6f, 0x58 },
+               .input  = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+                           0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+                           0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+                           0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
+               .ilen   = 32,
+               .result = { 0xa5, 0xdf, 0x6e, 0x50, 0xda, 0x70, 0x6c, 0x01,
+                           0x4a, 0xab, 0xf3, 0xf2, 0xd6, 0xfc, 0x6c, 0xfd,
+                           0x19, 0xb4, 0x3e, 0x57, 0x1c, 0x02, 0x5e, 0xa0,
+                           0x15, 0x78, 0xe0, 0x5e, 0xf2, 0xcb, 0x87, 0x16 },
+               .rlen   = 32,
+       },
+};
+
+static struct cipher_testvec camellia_cbc_dec_tv_template[] = {
+       {
+               .key    = { 0x06, 0xa9, 0x21, 0x40, 0x36, 0xb8, 0xa1, 0x5b,
+                           0x51, 0x2e, 0x03, 0xd5, 0x34, 0x12, 0x00, 0x06 },
+               .klen   = 16,
+               .iv     = { 0x3d, 0xaf, 0xba, 0x42, 0x9d, 0x9e, 0xb4, 0x30,
+                           0xb4, 0x22, 0xda, 0x80, 0x2c, 0x9f, 0xac, 0x41 },
+               .input  = { 0xea, 0x32, 0x12, 0x76, 0x3b, 0x50, 0x10, 0xe7,
+                           0x18, 0xf6, 0xfd, 0x5d, 0xf6, 0x8f, 0x13, 0x51 },
+               .ilen   = 16,
+               .result = { "Single block msg" },
+               .rlen   = 16,
+       }, {
+               .key    = { 0xc2, 0x86, 0x69, 0x6d, 0x88, 0x7c, 0x9a, 0xa0,
+                           0x61, 0x1b, 0xbb, 0x3e, 0x20, 0x25, 0xa4, 0x5a },
+               .klen   = 16,
+               .iv     = { 0x56, 0x2e, 0x17, 0x99, 0x6d, 0x09, 0x3d, 0x28,
+                           0xdd, 0xb3, 0xba, 0x69, 0x5a, 0x2e, 0x6f, 0x58 },
+               .input = { 0xa5, 0xdf, 0x6e, 0x50, 0xda, 0x70, 0x6c, 0x01,
+                           0x4a, 0xab, 0xf3, 0xf2, 0xd6, 0xfc, 0x6c, 0xfd,
+                           0x19, 0xb4, 0x3e, 0x57, 0x1c, 0x02, 0x5e, 0xa0,
+                           0x15, 0x78, 0xe0, 0x5e, 0xf2, 0xcb, 0x87, 0x16 },
+               .ilen   = 32,
+               .result = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+                           0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+                           0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+                           0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
+               .rlen   = 32,
+       },
+};
+
 /*
  * Compression stuff.
  */
@@ -3769,4 +4284,25 @@ static struct hash_speed generic_hash_speed_template[] = {
        {  .blen = 0,   .plen = 0, }
 };
 
+static struct cipher_speed camellia_speed_template[] = {
+      { .klen = 16, .blen = 16, },
+      { .klen = 16, .blen = 64, },
+      { .klen = 16, .blen = 256, },
+      { .klen = 16, .blen = 1024, },
+      { .klen = 16, .blen = 8192, },
+      { .klen = 24, .blen = 16, },
+      { .klen = 24, .blen = 64, },
+      { .klen = 24, .blen = 256, },
+      { .klen = 24, .blen = 1024, },
+      { .klen = 24, .blen = 8192, },
+      { .klen = 32, .blen = 16, },
+      { .klen = 32, .blen = 64, },
+      { .klen = 32, .blen = 256, },
+      { .klen = 32, .blen = 1024, },
+      { .klen = 32, .blen = 8192, },
+
+      /* End marker */
+      {  .klen = 0, .blen = 0, }
+};
+
 #endif /* _CRYPTO_TCRYPT_H */
index 9347eb6bcf69dec5a971be9a9c805b6e548cc94d..53e8ccbf0f5f514d9023431d9e15a47e53ed705e 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <linux/crypto.h>
 #include <linux/err.h>
+#include <linux/hardirq.h>
 #include <linux/kernel.h>
 #include <linux/mm.h>
 #include <linux/rtnetlink.h>
@@ -47,7 +48,7 @@ static u_int32_t ks[12] = {0x01010101, 0x01010101, 0x01010101, 0x01010101,
  * +------------------------
  */
 struct crypto_xcbc_ctx {
-       struct crypto_tfm *child;
+       struct crypto_cipher *child;
        u8 *odds;
        u8 *prev;
        u8 *key;
@@ -75,8 +76,7 @@ static int _crypto_xcbc_digest_setkey(struct crypto_hash *parent,
        if ((err = crypto_cipher_setkey(ctx->child, ctx->key, ctx->keylen)))
            return err;
 
-       ctx->child->__crt_alg->cra_cipher.cia_encrypt(ctx->child, key1,
-                       ctx->consts);
+       crypto_cipher_encrypt_one(ctx->child, key1, ctx->consts);
 
        return crypto_cipher_setkey(ctx->child, key1, bs);
 }
@@ -86,7 +86,7 @@ static int crypto_xcbc_digest_setkey(struct crypto_hash *parent,
 {
        struct crypto_xcbc_ctx *ctx = crypto_hash_ctx_aligned(parent);
 
-       if (keylen != crypto_tfm_alg_blocksize(ctx->child))
+       if (keylen != crypto_cipher_blocksize(ctx->child))
                return -EINVAL;
 
        ctx->keylen = keylen;
@@ -108,13 +108,13 @@ static int crypto_xcbc_digest_init(struct hash_desc *pdesc)
        return 0;
 }
 
-static int crypto_xcbc_digest_update(struct hash_desc *pdesc,
-                                    struct scatterlist *sg,
-                                    unsigned int nbytes)
+static int crypto_xcbc_digest_update2(struct hash_desc *pdesc,
+                                     struct scatterlist *sg,
+                                     unsigned int nbytes)
 {
        struct crypto_hash *parent = pdesc->tfm;
        struct crypto_xcbc_ctx *ctx = crypto_hash_ctx_aligned(parent);
-       struct crypto_tfm *tfm = ctx->child;
+       struct crypto_cipher *tfm = ctx->child;
        int bs = crypto_hash_blocksize(parent);
        unsigned int i = 0;
 
@@ -142,7 +142,7 @@ static int crypto_xcbc_digest_update(struct hash_desc *pdesc,
                                        offset += len;
 
                                crypto_kunmap(p, 0);
-                               crypto_yield(tfm->crt_flags);
+                               crypto_yield(pdesc->flags);
                                continue;
                        }
 
@@ -152,7 +152,7 @@ static int crypto_xcbc_digest_update(struct hash_desc *pdesc,
                        p += bs - ctx->len;
 
                        ctx->xor(ctx->prev, ctx->odds, bs);
-                       tfm->__crt_alg->cra_cipher.cia_encrypt(tfm, ctx->prev, ctx->prev);
+                       crypto_cipher_encrypt_one(tfm, ctx->prev, ctx->prev);
 
                        /* clearing the length */
                        ctx->len = 0;
@@ -160,7 +160,8 @@ static int crypto_xcbc_digest_update(struct hash_desc *pdesc,
                        /* encrypting the rest of data */
                        while (len > bs) {
                                ctx->xor(ctx->prev, p, bs);
-                               tfm->__crt_alg->cra_cipher.cia_encrypt(tfm, ctx->prev, ctx->prev);
+                               crypto_cipher_encrypt_one(tfm, ctx->prev,
+                                                         ctx->prev);
                                p += bs;
                                len -= bs;
                        }
@@ -171,7 +172,7 @@ static int crypto_xcbc_digest_update(struct hash_desc *pdesc,
                                ctx->len = len;
                        }
                        crypto_kunmap(p, 0);
-                       crypto_yield(tfm->crt_flags);
+                       crypto_yield(pdesc->flags);
                        slen -= min(slen, ((unsigned int)(PAGE_SIZE)) - offset);
                        offset = 0;
                        pg++;
@@ -183,11 +184,20 @@ static int crypto_xcbc_digest_update(struct hash_desc *pdesc,
        return 0;
 }
 
+static int crypto_xcbc_digest_update(struct hash_desc *pdesc,
+                                    struct scatterlist *sg,
+                                    unsigned int nbytes)
+{
+       if (WARN_ON_ONCE(in_irq()))
+               return -EDEADLK;
+       return crypto_xcbc_digest_update2(pdesc, sg, nbytes);
+}
+
 static int crypto_xcbc_digest_final(struct hash_desc *pdesc, u8 *out)
 {
        struct crypto_hash *parent = pdesc->tfm;
        struct crypto_xcbc_ctx *ctx = crypto_hash_ctx_aligned(parent);
-       struct crypto_tfm *tfm = ctx->child;
+       struct crypto_cipher *tfm = ctx->child;
        int bs = crypto_hash_blocksize(parent);
        int err = 0;
 
@@ -197,13 +207,14 @@ static int crypto_xcbc_digest_final(struct hash_desc *pdesc, u8 *out)
                if ((err = crypto_cipher_setkey(tfm, ctx->key, ctx->keylen)) != 0)
                        return err;
 
-               tfm->__crt_alg->cra_cipher.cia_encrypt(tfm, key2, (const u8*)(ctx->consts+bs));
+               crypto_cipher_encrypt_one(tfm, key2,
+                                         (u8 *)(ctx->consts + bs));
 
                ctx->xor(ctx->prev, ctx->odds, bs);
                ctx->xor(ctx->prev, key2, bs);
                _crypto_xcbc_digest_setkey(parent, ctx);
 
-               tfm->__crt_alg->cra_cipher.cia_encrypt(tfm, out, ctx->prev);
+               crypto_cipher_encrypt_one(tfm, out, ctx->prev);
        } else {
                u8 key3[bs];
                unsigned int rlen;
@@ -218,14 +229,15 @@ static int crypto_xcbc_digest_final(struct hash_desc *pdesc, u8 *out)
                if ((err = crypto_cipher_setkey(tfm, ctx->key, ctx->keylen)) != 0)
                        return err;
 
-               tfm->__crt_alg->cra_cipher.cia_encrypt(tfm, key3, (const u8*)(ctx->consts+bs*2));
+               crypto_cipher_encrypt_one(tfm, key3,
+                                         (u8 *)(ctx->consts + bs * 2));
 
                ctx->xor(ctx->prev, ctx->odds, bs);
                ctx->xor(ctx->prev, key3, bs);
 
                _crypto_xcbc_digest_setkey(parent, ctx);
 
-               tfm->__crt_alg->cra_cipher.cia_encrypt(tfm, out, ctx->prev);
+               crypto_cipher_encrypt_one(tfm, out, ctx->prev);
        }
 
        return 0;
@@ -234,21 +246,25 @@ static int crypto_xcbc_digest_final(struct hash_desc *pdesc, u8 *out)
 static int crypto_xcbc_digest(struct hash_desc *pdesc,
                  struct scatterlist *sg, unsigned int nbytes, u8 *out)
 {
+       if (WARN_ON_ONCE(in_irq()))
+               return -EDEADLK;
+
        crypto_xcbc_digest_init(pdesc);
-       crypto_xcbc_digest_update(pdesc, sg, nbytes);
+       crypto_xcbc_digest_update2(pdesc, sg, nbytes);
        return crypto_xcbc_digest_final(pdesc, out);
 }
 
 static int xcbc_init_tfm(struct crypto_tfm *tfm)
 {
+       struct crypto_cipher *cipher;
        struct crypto_instance *inst = (void *)tfm->__crt_alg;
        struct crypto_spawn *spawn = crypto_instance_ctx(inst);
        struct crypto_xcbc_ctx *ctx = crypto_hash_ctx_aligned(__crypto_hash_cast(tfm));
        int bs = crypto_hash_blocksize(__crypto_hash_cast(tfm));
 
-       tfm = crypto_spawn_tfm(spawn);
-       if (IS_ERR(tfm))
-               return PTR_ERR(tfm);
+       cipher = crypto_spawn_cipher(spawn);
+       if (IS_ERR(cipher))
+               return PTR_ERR(cipher);
 
        switch(bs) {
        case 16:
@@ -258,7 +274,7 @@ static int xcbc_init_tfm(struct crypto_tfm *tfm)
                return -EINVAL;
        }
 
-       ctx->child = crypto_cipher_cast(tfm);
+       ctx->child = cipher;
        ctx->odds = (u8*)(ctx+1);
        ctx->prev = ctx->odds + bs;
        ctx->key = ctx->prev + bs;
index e7da9fa724ec5f50aa70040df67c10c2d7cbf2fe..050323fd79e9ae78f4f528ce260e08a8ec89f38b 100644 (file)
@@ -80,6 +80,8 @@ source "drivers/rtc/Kconfig"
 
 source "drivers/dma/Kconfig"
 
+source "drivers/auxdisplay/Kconfig"
+
 source "drivers/kvm/Kconfig"
 
 endmenu
index 0dd96d1afd39246bb3e625c60b9f30bd386305a4..3a718f51350ed53e369609efb7086581656f7aca 100644 (file)
@@ -30,7 +30,7 @@ obj-$(CONFIG_PARPORT)         += parport/
 obj-y                          += base/ block/ misc/ mfd/ net/ media/
 obj-$(CONFIG_NUBUS)            += nubus/
 obj-$(CONFIG_ATM)              += atm/
-obj-$(CONFIG_PPC_PMAC)         += macintosh/
+obj-y                          += macintosh/
 obj-$(CONFIG_IDE)              += ide/
 obj-$(CONFIG_FC4)              += fc4/
 obj-$(CONFIG_SCSI)             += scsi/
@@ -38,6 +38,7 @@ obj-$(CONFIG_ATA)             += ata/
 obj-$(CONFIG_FUSION)           += message/
 obj-$(CONFIG_IEEE1394)         += ieee1394/
 obj-y                          += cdrom/
+obj-y                          += auxdisplay/
 obj-$(CONFIG_MTD)              += mtd/
 obj-$(CONFIG_SPI)              += spi/
 obj-$(CONFIG_PCCARD)           += pcmcia/
index 667fa1dfa1a361188607e82ce919b6528f270781..91082ce6f5d1de0e158704401c45d46590336afa 100644 (file)
@@ -296,7 +296,7 @@ static int bay_add(acpi_handle handle, int id)
        /*
         * Initialize bay device structure
         */
-       new_bay = kzalloc(GFP_ATOMIC, sizeof(*new_bay));
+       new_bay = kzalloc(sizeof(*new_bay), GFP_ATOMIC);
        INIT_LIST_HEAD(&new_bay->list);
        new_bay->handle = handle;
        new_bay->name = (char *)nbuffer.pointer;
index 1c94b43d2c9b0fd6696ce44fb7837953cd051500..3747457fee7a1f2180dbf0abf96281494c3ff050 100644 (file)
@@ -41,12 +41,12 @@ config SATA_SVW
          If unsure, say N.
 
 config ATA_PIIX
-       tristate "Intel PIIX/ICH SATA support"
+       tristate "Intel ESB, ICH, PIIX3, PIIX4 PATA/SATA support"
        depends on PCI
        help
          This option enables support for ICH5/6/7/8 Serial ATA
-         and support for PATA on the Intel PIIX3/PIIX4/ICH series
-         PATA host controllers.
+         and support for PATA on the Intel ESB/ICH/PIIX3/PIIX4 series
+         host controllers.
 
          If unsure, say N.
 
@@ -116,11 +116,14 @@ config SATA_SIL24
          If unsure, say N.
 
 config SATA_SIS
-       tristate "SiS 964/180 SATA support"
+       tristate "SiS 964/965/966/180 SATA support"
        depends on PCI
+       select PATA_SIS
        help
-         This option enables support for SiS Serial ATA 964/180.
-
+         This option enables support for SiS Serial ATA on 
+         SiS 964/965/966/180 and Parallel ATA on SiS 180.
+         The PATA support for SiS 180 requires additionally to
+         enable the PATA_SIS driver in the config.
          If unsure, say N.
 
 config SATA_ULI
@@ -147,6 +150,12 @@ config SATA_VITESSE
 
          If unsure, say N.
 
+config SATA_INIC162X
+       tristate "Initio 162x SATA support (HIGHLY EXPERIMENTAL)"
+       depends on PCI && EXPERIMENTAL
+       help
+         This option enables support for Initio 162x Serial ATA.
+
 config SATA_INTEL_COMBINED
        bool
        depends on IDE=y && !BLK_DEV_IDE_SATA && (SATA_AHCI || ATA_PIIX)
@@ -296,7 +305,7 @@ config PATA_ISAPNP
          If unsure, say N.
 
 config PATA_IT821X
-       tristate "IT821x PATA support (Experimental)"
+       tristate "IT8211/2 PATA support (Experimental)"
        depends on PCI && EXPERIMENTAL
        help
          This option enables support for the ITE 8211 and 8212
@@ -305,6 +314,15 @@ config PATA_IT821X
 
          If unsure, say N.
 
+config PATA_IT8213
+       tristate "IT8213 PATA support (Experimental)"
+       depends on PCI && EXPERIMENTAL
+       help
+         This option enables support for the ITE 821 PATA
+          controllers via the new ATA layer.
+
+         If unsure, say N.
+
 config PATA_JMICRON
        tristate "JMicron PATA support"
        depends on PCI
@@ -341,6 +359,15 @@ config PATA_MARVELL
 
          If unsure, say N.
 
+config PATA_MPC52xx
+       tristate "Freescale MPC52xx SoC internal IDE"
+       depends on PPC_MPC52xx
+       help
+         This option enables support for integrated IDE controller
+         of the Freescale MPC52xx SoC.
+
+         If unsure, say N.
+
 config PATA_MPIIX
        tristate "Intel PATA MPIIX support"
        depends on PCI
index bc3d81ae757e64e9b98869a3ef1204e420553400..cd096f0c78a105c2e9a9e605e0acdc3aed82af89 100644 (file)
@@ -15,6 +15,7 @@ obj-$(CONFIG_SATA_SX4)                += sata_sx4.o
 obj-$(CONFIG_SATA_NV)          += sata_nv.o
 obj-$(CONFIG_SATA_ULI)         += sata_uli.o
 obj-$(CONFIG_SATA_MV)          += sata_mv.o
+obj-$(CONFIG_SATA_INIC162X)    += sata_inic162x.o
 obj-$(CONFIG_PDC_ADMA)         += pdc_adma.o
 
 obj-$(CONFIG_PATA_ALI)         += pata_ali.o
@@ -33,11 +34,13 @@ obj-$(CONFIG_PATA_HPT3X2N)  += pata_hpt3x2n.o
 obj-$(CONFIG_PATA_HPT3X3)      += pata_hpt3x3.o
 obj-$(CONFIG_PATA_ISAPNP)      += pata_isapnp.o
 obj-$(CONFIG_PATA_IT821X)      += pata_it821x.o
+obj-$(CONFIG_PATA_IT8213)      += pata_it8213.o
 obj-$(CONFIG_PATA_JMICRON)     += pata_jmicron.o
 obj-$(CONFIG_PATA_NETCELL)     += pata_netcell.o
 obj-$(CONFIG_PATA_NS87410)     += pata_ns87410.o
 obj-$(CONFIG_PATA_OPTI)                += pata_opti.o
 obj-$(CONFIG_PATA_OPTIDMA)     += pata_optidma.o
+obj-$(CONFIG_PATA_MPC52xx)     += pata_mpc52xx.o
 obj-$(CONFIG_PATA_MARVELL)     += pata_marvell.o
 obj-$(CONFIG_PATA_MPIIX)       += pata_mpiix.o
 obj-$(CONFIG_PATA_OLDPIIX)     += pata_oldpiix.o
index 48616c6fee9d6c30d36f206b60b98707020e0cc8..92cdb0c5171f3a35fe347e02bf36bc60c12e2135 100644 (file)
@@ -45,7 +45,6 @@
 #include <scsi/scsi_host.h>
 #include <scsi/scsi_cmnd.h>
 #include <linux/libata.h>
-#include <asm/io.h>
 
 #define DRV_NAME       "ahci"
 #define DRV_VERSION    "2.0"
@@ -166,9 +165,6 @@ enum {
        PORT_CMD_ICC_PARTIAL    = (0x2 << 28), /* Put i/f in partial state */
        PORT_CMD_ICC_SLUMBER    = (0x6 << 28), /* Put i/f in slumber state */
 
-       /* hpriv->flags bits */
-       AHCI_FLAG_MSI           = (1 << 0),
-
        /* ap->flags bits */
        AHCI_FLAG_NO_NCQ                = (1 << 24),
        AHCI_FLAG_IGN_IRQ_IF_ERR        = (1 << 25), /* ignore IRQ_IF_ERR */
@@ -191,7 +187,6 @@ struct ahci_sg {
 };
 
 struct ahci_host_priv {
-       unsigned long           flags;
        u32                     cap;    /* cache of HOST_CAP register */
        u32                     port_map; /* cache of HOST_PORTS_IMPL reg */
 };
@@ -229,7 +224,6 @@ static int ahci_port_suspend(struct ata_port *ap, pm_message_t mesg);
 static int ahci_port_resume(struct ata_port *ap);
 static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg);
 static int ahci_pci_device_resume(struct pci_dev *pdev);
-static void ahci_remove_one (struct pci_dev *pdev);
 
 static struct scsi_host_template ahci_sht = {
        .module                 = THIS_MODULE,
@@ -266,6 +260,8 @@ static const struct ata_port_operations ahci_ops = {
 
        .irq_handler            = ahci_interrupt,
        .irq_clear              = ahci_irq_clear,
+       .irq_on                 = ata_dummy_irq_on,
+       .irq_ack                = ata_dummy_irq_ack,
 
        .scr_read               = ahci_scr_read,
        .scr_write              = ahci_scr_write,
@@ -297,6 +293,8 @@ static const struct ata_port_operations ahci_vt8251_ops = {
 
        .irq_handler            = ahci_interrupt,
        .irq_clear              = ahci_irq_clear,
+       .irq_on                 = ata_dummy_irq_on,
+       .irq_ack                = ata_dummy_irq_ack,
 
        .scr_read               = ahci_scr_read,
        .scr_write              = ahci_scr_write,
@@ -431,7 +429,7 @@ static const struct pci_device_id ahci_pci_tbl[] = {
 
        /* Generic, PCI class code for AHCI */
        { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
-         0x010601, 0xffffff, board_ahci },
+         PCI_CLASS_STORAGE_SATA_AHCI, 0xffffff, board_ahci },
 
        { }     /* terminate list */
 };
@@ -441,9 +439,9 @@ static struct pci_driver ahci_pci_driver = {
        .name                   = DRV_NAME,
        .id_table               = ahci_pci_tbl,
        .probe                  = ahci_init_one,
+       .remove                 = ata_pci_remove_one,
        .suspend                = ahci_pci_device_suspend,
        .resume                 = ahci_pci_device_resume,
-       .remove                 = ahci_remove_one,
 };
 
 
@@ -452,16 +450,12 @@ static inline int ahci_nr_ports(u32 cap)
        return (cap & 0x1f) + 1;
 }
 
-static inline unsigned long ahci_port_base_ul (unsigned long base, unsigned int port)
+static inline void __iomem *ahci_port_base(void __iomem *base,
+                                          unsigned int port)
 {
        return base + 0x100 + (port * 0x80);
 }
 
-static inline void __iomem *ahci_port_base (void __iomem *base, unsigned int port)
-{
-       return (void __iomem *) ahci_port_base_ul((unsigned long)base, port);
-}
-
 static u32 ahci_scr_read (struct ata_port *ap, unsigned int sc_reg_in)
 {
        unsigned int sc_reg;
@@ -475,7 +469,7 @@ static u32 ahci_scr_read (struct ata_port *ap, unsigned int sc_reg_in)
                return 0xffffffffU;
        }
 
-       return readl((void __iomem *) ap->ioaddr.scr_addr + (sc_reg * 4));
+       return readl(ap->ioaddr.scr_addr + (sc_reg * 4));
 }
 
 
@@ -493,7 +487,7 @@ static void ahci_scr_write (struct ata_port *ap, unsigned int sc_reg_in,
                return;
        }
 
-       writel(val, (void __iomem *) ap->ioaddr.scr_addr + (sc_reg * 4));
+       writel(val, ap->ioaddr.scr_addr + (sc_reg * 4));
 }
 
 static void ahci_start_engine(void __iomem *port_mmio)
@@ -735,7 +729,7 @@ static void ahci_init_controller(void __iomem *mmio, struct pci_dev *pdev,
 
 static unsigned int ahci_dev_classify(struct ata_port *ap)
 {
-       void __iomem *port_mmio = (void __iomem *) ap->ioaddr.cmd_addr;
+       void __iomem *port_mmio = ap->ioaddr.cmd_addr;
        struct ata_taskfile tf;
        u32 tmp;
 
@@ -763,7 +757,7 @@ static void ahci_fill_cmd_slot(struct ahci_port_priv *pp, unsigned int tag,
 
 static int ahci_clo(struct ata_port *ap)
 {
-       void __iomem *port_mmio = (void __iomem *) ap->ioaddr.cmd_addr;
+       void __iomem *port_mmio = ap->ioaddr.cmd_addr;
        struct ahci_host_priv *hpriv = ap->host->private_data;
        u32 tmp;
 
@@ -785,7 +779,7 @@ static int ahci_clo(struct ata_port *ap)
 static int ahci_softreset(struct ata_port *ap, unsigned int *class)
 {
        struct ahci_port_priv *pp = ap->private_data;
-       void __iomem *mmio = ap->host->mmio_base;
+       void __iomem *mmio = ap->host->iomap[AHCI_PCI_BAR];
        void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
        const u32 cmd_fis_len = 5; /* five dwords */
        const char *reason = NULL;
@@ -893,7 +887,7 @@ static int ahci_hardreset(struct ata_port *ap, unsigned int *class)
        struct ahci_port_priv *pp = ap->private_data;
        u8 *d2h_fis = pp->rx_fis + RX_FIS_D2H_REG;
        struct ata_taskfile tf;
-       void __iomem *mmio = ap->host->mmio_base;
+       void __iomem *mmio = ap->host->iomap[AHCI_PCI_BAR];
        void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
        int rc;
 
@@ -921,7 +915,7 @@ static int ahci_hardreset(struct ata_port *ap, unsigned int *class)
 
 static int ahci_vt8251_hardreset(struct ata_port *ap, unsigned int *class)
 {
-       void __iomem *mmio = ap->host->mmio_base;
+       void __iomem *mmio = ap->host->iomap[AHCI_PCI_BAR];
        void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
        int rc;
 
@@ -946,7 +940,7 @@ static int ahci_vt8251_hardreset(struct ata_port *ap, unsigned int *class)
 
 static void ahci_postreset(struct ata_port *ap, unsigned int *class)
 {
-       void __iomem *port_mmio = (void __iomem *) ap->ioaddr.cmd_addr;
+       void __iomem *port_mmio = ap->ioaddr.cmd_addr;
        u32 new_tmp, tmp;
 
        ata_std_postreset(ap, class);
@@ -965,7 +959,7 @@ static void ahci_postreset(struct ata_port *ap, unsigned int *class)
 
 static u8 ahci_check_status(struct ata_port *ap)
 {
-       void __iomem *mmio = (void __iomem *) ap->ioaddr.cmd_addr;
+       void __iomem *mmio = ap->ioaddr.cmd_addr;
 
        return readl(mmio + PORT_TFDATA) & 0xFF;
 }
@@ -1111,7 +1105,7 @@ static void ahci_error_intr(struct ata_port *ap, u32 irq_stat)
 
 static void ahci_host_intr(struct ata_port *ap)
 {
-       void __iomem *mmio = ap->host->mmio_base;
+       void __iomem *mmio = ap->host->iomap[AHCI_PCI_BAR];
        void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
        struct ata_eh_info *ehi = &ap->eh_info;
        struct ahci_port_priv *pp = ap->private_data;
@@ -1173,7 +1167,7 @@ static void ahci_host_intr(struct ata_port *ap)
                 * dangerous, we need to know more about them.  Print
                 * more of it.
                 */
-               const u32 *f = pp->rx_fis + RX_FIS_SDB;
+               const __le32 *f = pp->rx_fis + RX_FIS_SDB;
 
                ata_port_printk(ap, KERN_INFO, "Spurious SDB FIS during NCQ "
                                "issue=0x%x SAct=0x%x FIS=%08x:%08x%s\n",
@@ -1209,7 +1203,7 @@ static irqreturn_t ahci_interrupt(int irq, void *dev_instance)
        VPRINTK("ENTER\n");
 
        hpriv = host->private_data;
-       mmio = host->mmio_base;
+       mmio = host->iomap[AHCI_PCI_BAR];
 
        /* sigh.  0xffffffff is a valid return from h/w */
        irq_stat = readl(mmio + HOST_IRQ_STAT);
@@ -1254,7 +1248,7 @@ static irqreturn_t ahci_interrupt(int irq, void *dev_instance)
 static unsigned int ahci_qc_issue(struct ata_queued_cmd *qc)
 {
        struct ata_port *ap = qc->ap;
-       void __iomem *port_mmio = (void __iomem *) ap->ioaddr.cmd_addr;
+       void __iomem *port_mmio = ap->ioaddr.cmd_addr;
 
        if (qc->tf.protocol == ATA_PROT_NCQ)
                writel(1 << qc->tag, port_mmio + PORT_SCR_ACT);
@@ -1266,7 +1260,7 @@ static unsigned int ahci_qc_issue(struct ata_queued_cmd *qc)
 
 static void ahci_freeze(struct ata_port *ap)
 {
-       void __iomem *mmio = ap->host->mmio_base;
+       void __iomem *mmio = ap->host->iomap[AHCI_PCI_BAR];
        void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
 
        /* turn IRQ off */
@@ -1275,7 +1269,7 @@ static void ahci_freeze(struct ata_port *ap)
 
 static void ahci_thaw(struct ata_port *ap)
 {
-       void __iomem *mmio = ap->host->mmio_base;
+       void __iomem *mmio = ap->host->iomap[AHCI_PCI_BAR];
        void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
        u32 tmp;
 
@@ -1290,7 +1284,7 @@ static void ahci_thaw(struct ata_port *ap)
 
 static void ahci_error_handler(struct ata_port *ap)
 {
-       void __iomem *mmio = ap->host->mmio_base;
+       void __iomem *mmio = ap->host->iomap[AHCI_PCI_BAR];
        void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
 
        if (!(ap->pflags & ATA_PFLAG_FROZEN)) {
@@ -1306,7 +1300,7 @@ static void ahci_error_handler(struct ata_port *ap)
 
 static void ahci_vt8251_error_handler(struct ata_port *ap)
 {
-       void __iomem *mmio = ap->host->mmio_base;
+       void __iomem *mmio = ap->host->iomap[AHCI_PCI_BAR];
        void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
 
        if (!(ap->pflags & ATA_PFLAG_FROZEN)) {
@@ -1323,7 +1317,7 @@ static void ahci_vt8251_error_handler(struct ata_port *ap)
 static void ahci_post_internal_cmd(struct ata_queued_cmd *qc)
 {
        struct ata_port *ap = qc->ap;
-       void __iomem *mmio = ap->host->mmio_base;
+       void __iomem *mmio = ap->host->iomap[AHCI_PCI_BAR];
        void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
 
        if (qc->flags & ATA_QCFLAG_FAILED)
@@ -1340,7 +1334,7 @@ static int ahci_port_suspend(struct ata_port *ap, pm_message_t mesg)
 {
        struct ahci_host_priv *hpriv = ap->host->private_data;
        struct ahci_port_priv *pp = ap->private_data;
-       void __iomem *mmio = ap->host->mmio_base;
+       void __iomem *mmio = ap->host->iomap[AHCI_PCI_BAR];
        void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
        const char *emsg = NULL;
        int rc;
@@ -1361,7 +1355,7 @@ static int ahci_port_resume(struct ata_port *ap)
 {
        struct ahci_port_priv *pp = ap->private_data;
        struct ahci_host_priv *hpriv = ap->host->private_data;
-       void __iomem *mmio = ap->host->mmio_base;
+       void __iomem *mmio = ap->host->iomap[AHCI_PCI_BAR];
        void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
 
        ahci_power_up(port_mmio, hpriv->cap);
@@ -1373,7 +1367,7 @@ static int ahci_port_resume(struct ata_port *ap)
 static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg)
 {
        struct ata_host *host = dev_get_drvdata(&pdev->dev);
-       void __iomem *mmio = host->mmio_base;
+       void __iomem *mmio = host->iomap[AHCI_PCI_BAR];
        u32 ctl;
 
        if (mesg.event == PM_EVENT_SUSPEND) {
@@ -1394,10 +1388,12 @@ static int ahci_pci_device_resume(struct pci_dev *pdev)
 {
        struct ata_host *host = dev_get_drvdata(&pdev->dev);
        struct ahci_host_priv *hpriv = host->private_data;
-       void __iomem *mmio = host->mmio_base;
+       void __iomem *mmio = host->iomap[AHCI_PCI_BAR];
        int rc;
 
-       ata_pci_device_do_resume(pdev);
+       rc = ata_pci_device_do_resume(pdev);
+       if (rc)
+               return rc;
 
        if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) {
                rc = ahci_reset_controller(mmio, pdev);
@@ -1418,29 +1414,24 @@ static int ahci_port_start(struct ata_port *ap)
        struct device *dev = ap->host->dev;
        struct ahci_host_priv *hpriv = ap->host->private_data;
        struct ahci_port_priv *pp;
-       void __iomem *mmio = ap->host->mmio_base;
+       void __iomem *mmio = ap->host->iomap[AHCI_PCI_BAR];
        void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
        void *mem;
        dma_addr_t mem_dma;
        int rc;
 
-       pp = kmalloc(sizeof(*pp), GFP_KERNEL);
+       pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL);
        if (!pp)
                return -ENOMEM;
-       memset(pp, 0, sizeof(*pp));
 
        rc = ata_pad_alloc(ap, dev);
-       if (rc) {
-               kfree(pp);
+       if (rc)
                return rc;
-       }
 
-       mem = dma_alloc_coherent(dev, AHCI_PORT_PRIV_DMA_SZ, &mem_dma, GFP_KERNEL);
-       if (!mem) {
-               ata_pad_free(ap, dev);
-               kfree(pp);
+       mem = dmam_alloc_coherent(dev, AHCI_PORT_PRIV_DMA_SZ, &mem_dma,
+                                 GFP_KERNEL);
+       if (!mem)
                return -ENOMEM;
-       }
        memset(mem, 0, AHCI_PORT_PRIV_DMA_SZ);
 
        /*
@@ -1482,10 +1473,8 @@ static int ahci_port_start(struct ata_port *ap)
 
 static void ahci_port_stop(struct ata_port *ap)
 {
-       struct device *dev = ap->host->dev;
        struct ahci_host_priv *hpriv = ap->host->private_data;
-       struct ahci_port_priv *pp = ap->private_data;
-       void __iomem *mmio = ap->host->mmio_base;
+       void __iomem *mmio = ap->host->iomap[AHCI_PCI_BAR];
        void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
        const char *emsg = NULL;
        int rc;
@@ -1494,19 +1483,13 @@ static void ahci_port_stop(struct ata_port *ap)
        rc = ahci_deinit_port(port_mmio, hpriv->cap, &emsg);
        if (rc)
                ata_port_printk(ap, KERN_WARNING, "%s (%d)\n", emsg, rc);
-
-       ap->private_data = NULL;
-       dma_free_coherent(dev, AHCI_PORT_PRIV_DMA_SZ,
-                         pp->cmd_slot, pp->cmd_slot_dma);
-       ata_pad_free(ap, dev);
-       kfree(pp);
 }
 
-static void ahci_setup_port(struct ata_ioports *port, unsigned long base,
+static void ahci_setup_port(struct ata_ioports *port, void __iomem *base,
                            unsigned int port_idx)
 {
        VPRINTK("ENTER, base==0x%lx, port_idx %u\n", base, port_idx);
-       base = ahci_port_base_ul(base, port_idx);
+       base = ahci_port_base(base, port_idx);
        VPRINTK("base now==0x%lx\n", base);
 
        port->cmd_addr          = base;
@@ -1519,7 +1502,7 @@ static int ahci_host_init(struct ata_probe_ent *probe_ent)
 {
        struct ahci_host_priv *hpriv = probe_ent->private_data;
        struct pci_dev *pdev = to_pci_dev(probe_ent->dev);
-       void __iomem *mmio = probe_ent->mmio_base;
+       void __iomem *mmio = probe_ent->iomap[AHCI_PCI_BAR];
        unsigned int i, cap_n_ports, using_dac;
        int rc;
 
@@ -1586,7 +1569,7 @@ static int ahci_host_init(struct ata_probe_ent *probe_ent)
        }
 
        for (i = 0; i < probe_ent->n_ports; i++)
-               ahci_setup_port(&probe_ent->port[i], (unsigned long) mmio, i);
+               ahci_setup_port(&probe_ent->port[i], mmio, i);
 
        ahci_init_controller(mmio, pdev, probe_ent->n_ports,
                             probe_ent->port_flags, hpriv);
@@ -1600,7 +1583,7 @@ static void ahci_print_info(struct ata_probe_ent *probe_ent)
 {
        struct ahci_host_priv *hpriv = probe_ent->private_data;
        struct pci_dev *pdev = to_pci_dev(probe_ent->dev);
-       void __iomem *mmio = probe_ent->mmio_base;
+       void __iomem *mmio = probe_ent->iomap[AHCI_PCI_BAR];
        u32 vers, cap, impl, speed;
        const char *speed_s;
        u16 cc;
@@ -1619,11 +1602,11 @@ static void ahci_print_info(struct ata_probe_ent *probe_ent)
                speed_s = "?";
 
        pci_read_config_word(pdev, 0x0a, &cc);
-       if (cc == 0x0101)
+       if (cc == PCI_CLASS_STORAGE_IDE)
                scc_s = "IDE";
-       else if (cc == 0x0106)
+       else if (cc == PCI_CLASS_STORAGE_SATA)
                scc_s = "SATA";
-       else if (cc == 0x0104)
+       else if (cc == PCI_CLASS_STORAGE_RAID)
                scc_s = "RAID";
        else
                scc_s = "unknown";
@@ -1667,15 +1650,13 @@ static void ahci_print_info(struct ata_probe_ent *probe_ent)
                );
 }
 
-static int ahci_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
+static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
        static int printed_version;
-       struct ata_probe_ent *probe_ent = NULL;
-       struct ahci_host_priv *hpriv;
-       unsigned long base;
-       void __iomem *mmio_base;
        unsigned int board_idx = (unsigned int) ent->driver_data;
-       int have_msi, pci_dev_busy = 0;
+       struct device *dev = &pdev->dev;
+       struct ata_probe_ent *probe_ent;
+       struct ahci_host_priv *hpriv;
        int rc;
 
        VPRINTK("ENTER\n");
@@ -1685,57 +1666,36 @@ static int ahci_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
        if (!printed_version++)
                dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
 
-       /* JMicron-specific fixup: make sure we're in AHCI mode */
-       /* This is protected from races with ata_jmicron by the pci probe
-          locking */
        if (pdev->vendor == PCI_VENDOR_ID_JMICRON) {
-               /* AHCI enable, AHCI on function 0 */
-               pci_write_config_byte(pdev, 0x41, 0xa1);
-               /* Function 1 is the PATA controller */
+               /* Function 1 is the PATA controller except on the 368, where
+                  we are not AHCI anyway */
                if (PCI_FUNC(pdev->devfn))
                        return -ENODEV;
        }
 
-       rc = pci_enable_device(pdev);
+       rc = pcim_enable_device(pdev);
        if (rc)
                return rc;
 
-       rc = pci_request_regions(pdev, DRV_NAME);
-       if (rc) {
-               pci_dev_busy = 1;
-               goto err_out;
-       }
+       rc = pcim_iomap_regions(pdev, 1 << AHCI_PCI_BAR, DRV_NAME);
+       if (rc == -EBUSY)
+               pcim_pin_device(pdev);
+       if (rc)
+               return rc;
 
-       if (pci_enable_msi(pdev) == 0)
-               have_msi = 1;
-       else {
+       if (pci_enable_msi(pdev))
                pci_intx(pdev, 1);
-               have_msi = 0;
-       }
 
-       probe_ent = kmalloc(sizeof(*probe_ent), GFP_KERNEL);
-       if (probe_ent == NULL) {
-               rc = -ENOMEM;
-               goto err_out_msi;
-       }
+       probe_ent = devm_kzalloc(dev, sizeof(*probe_ent), GFP_KERNEL);
+       if (probe_ent == NULL)
+               return -ENOMEM;
 
-       memset(probe_ent, 0, sizeof(*probe_ent));
        probe_ent->dev = pci_dev_to_dev(pdev);
        INIT_LIST_HEAD(&probe_ent->node);
 
-       mmio_base = pci_iomap(pdev, AHCI_PCI_BAR, 0);
-       if (mmio_base == NULL) {
-               rc = -ENOMEM;
-               goto err_out_free_ent;
-       }
-       base = (unsigned long) mmio_base;
-
-       hpriv = kmalloc(sizeof(*hpriv), GFP_KERNEL);
-       if (!hpriv) {
-               rc = -ENOMEM;
-               goto err_out_iounmap;
-       }
-       memset(hpriv, 0, sizeof(*hpriv));
+       hpriv = devm_kzalloc(dev, sizeof(*hpriv), GFP_KERNEL);
+       if (!hpriv)
+               return -ENOMEM;
 
        probe_ent->sht          = ahci_port_info[board_idx].sht;
        probe_ent->port_flags   = ahci_port_info[board_idx].flags;
@@ -1745,16 +1705,13 @@ static int ahci_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
 
                probe_ent->irq = pdev->irq;
                probe_ent->irq_flags = IRQF_SHARED;
-       probe_ent->mmio_base = mmio_base;
+       probe_ent->iomap = pcim_iomap_table(pdev);
        probe_ent->private_data = hpriv;
 
-       if (have_msi)
-               hpriv->flags |= AHCI_FLAG_MSI;
-
        /* initialize adapter */
        rc = ahci_host_init(probe_ent);
        if (rc)
-               goto err_out_hpriv;
+               return rc;
 
        if (!(probe_ent->port_flags & AHCI_FLAG_NO_NCQ) &&
            (hpriv->cap & HOST_CAP_NCQ))
@@ -1762,62 +1719,11 @@ static int ahci_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
 
        ahci_print_info(probe_ent);
 
-       /* FIXME: check ata_device_add return value */
-       ata_device_add(probe_ent);
-       kfree(probe_ent);
+       if (!ata_device_add(probe_ent))
+               return -ENODEV;
 
+       devm_kfree(dev, probe_ent);
        return 0;
-
-err_out_hpriv:
-       kfree(hpriv);
-err_out_iounmap:
-       pci_iounmap(pdev, mmio_base);
-err_out_free_ent:
-       kfree(probe_ent);
-err_out_msi:
-       if (have_msi)
-               pci_disable_msi(pdev);
-       else
-               pci_intx(pdev, 0);
-       pci_release_regions(pdev);
-err_out:
-       if (!pci_dev_busy)
-               pci_disable_device(pdev);
-       return rc;
-}
-
-static void ahci_remove_one (struct pci_dev *pdev)
-{
-       struct device *dev = pci_dev_to_dev(pdev);
-       struct ata_host *host = dev_get_drvdata(dev);
-       struct ahci_host_priv *hpriv = host->private_data;
-       unsigned int i;
-       int have_msi;
-
-       for (i = 0; i < host->n_ports; i++)
-               ata_port_detach(host->ports[i]);
-
-       have_msi = hpriv->flags & AHCI_FLAG_MSI;
-       free_irq(host->irq, host);
-
-       for (i = 0; i < host->n_ports; i++) {
-               struct ata_port *ap = host->ports[i];
-
-               ata_scsi_release(ap->scsi_host);
-               scsi_host_put(ap->scsi_host);
-       }
-
-       kfree(hpriv);
-       pci_iounmap(pdev, host->mmio_base);
-       kfree(host);
-
-       if (have_msi)
-               pci_disable_msi(pdev);
-       else
-               pci_intx(pdev, 0);
-       pci_release_regions(pdev);
-       pci_disable_device(pdev);
-       dev_set_drvdata(dev, NULL);
 }
 
 static int __init ahci_init(void)
index 24af56081b5d86a4ab2ae2736cacfb5dc038d836..be66ea08da551f16fa76459510e8cc75fa65f0f1 100644 (file)
@@ -79,7 +79,7 @@ static int generic_set_mode(struct ata_port *ap, struct ata_device **unused)
 
        /* Bits 5 and 6 indicate if DMA is active on master/slave */
        if (ap->ioaddr.bmdma_addr)
-               dma_enabled = inb(ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
+               dma_enabled = ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
 
        for (i = 0; i < ATA_MAX_DEVICES; i++) {
                struct ata_device *dev = &ap->device[i];
@@ -138,7 +138,7 @@ static struct ata_port_operations generic_port_ops = {
        .bmdma_stop     = ata_bmdma_stop,
        .bmdma_status   = ata_bmdma_status,
 
-       .data_xfer      = ata_pio_data_xfer,
+       .data_xfer      = ata_data_xfer,
 
        .freeze         = ata_bmdma_freeze,
        .thaw           = ata_bmdma_thaw,
@@ -150,10 +150,10 @@ static struct ata_port_operations generic_port_ops = {
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 static int all_generic_ide;            /* Set to claim all devices */
index 47701b286f8b6e2a124392c8b8b2befe27051139..4d716c7347e70c9bf8195db78ec5377a605db57d 100644 (file)
@@ -118,7 +118,7 @@ enum {
        PIIX_80C_SEC            = (1 << 7) | (1 << 6),
 
        /* controller IDs */
-       piix_pata_33            = 0,    /* PIIX3 or 4 at 33Mhz */
+       piix_pata_33            = 0,    /* PIIX4 at 33Mhz */
        ich_pata_33             = 1,    /* ICH up to UDMA 33 only */
        ich_pata_66             = 2,    /* ICH up to 66 Mhz */
        ich_pata_100            = 3,    /* ICH up to UDMA 100 */
@@ -128,6 +128,7 @@ enum {
        ich6_sata_ahci          = 7,
        ich6m_sata_ahci         = 8,
        ich8_sata_ahci          = 9,
+       piix_pata_mwdma         = 10,   /* PIIX3 MWDMA only */
 
        /* constants for mapping table */
        P0                      = 0,  /* port 0 */
@@ -153,7 +154,6 @@ struct piix_host_priv {
 
 static int piix_init_one (struct pci_dev *pdev,
                                    const struct pci_device_id *ent);
-static void piix_host_stop(struct ata_host *host);
 static void piix_pata_error_handler(struct ata_port *ap);
 static void ich_pata_error_handler(struct ata_port *ap);
 static void piix_sata_error_handler(struct ata_port *ap);
@@ -164,7 +164,8 @@ static void ich_set_dmamode (struct ata_port *ap, struct ata_device *adev);
 static unsigned int in_module_init = 1;
 
 static const struct pci_device_id piix_pci_tbl[] = {
-#ifdef ATA_ENABLE_PATA
+       /* Intel PIIX3 for the 430HX etc */
+       { 0x8086, 0x7010, PCI_ANY_ID, PCI_ANY_ID, 0, 0, piix_pata_mwdma },
        /* Intel PIIX4 for the 430TX/440BX/MX chipset: UDMA 33 */
        /* Also PIIX4E (fn3 rev 2) and PIIX4M (fn3 rev 3) */
        { 0x8086, 0x7111, PCI_ANY_ID, PCI_ANY_ID, 0, 0, piix_pata_33 },
@@ -202,7 +203,6 @@ static const struct pci_device_id piix_pci_tbl[] = {
        /* ICH7/7-R (i945, i975) UDMA 100*/
        { 0x8086, 0x27DF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_133 },
        { 0x8086, 0x269E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
-#endif
 
        /* NOTE: The following PCI ids must be kept in sync with the
         * list in drivers/pci/quirks.c.
@@ -297,7 +297,7 @@ static const struct ata_port_operations piix_pata_ops = {
        .bmdma_status           = ata_bmdma_status,
        .qc_prep                = ata_qc_prep,
        .qc_issue               = ata_qc_issue_prot,
-       .data_xfer              = ata_pio_data_xfer,
+       .data_xfer              = ata_data_xfer,
 
        .freeze                 = ata_bmdma_freeze,
        .thaw                   = ata_bmdma_thaw,
@@ -306,10 +306,10 @@ static const struct ata_port_operations piix_pata_ops = {
 
        .irq_handler            = ata_interrupt,
        .irq_clear              = ata_bmdma_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
 
        .port_start             = ata_port_start,
-       .port_stop              = ata_port_stop,
-       .host_stop              = piix_host_stop,
 };
 
 static const struct ata_port_operations ich_pata_ops = {
@@ -330,7 +330,7 @@ static const struct ata_port_operations ich_pata_ops = {
        .bmdma_status           = ata_bmdma_status,
        .qc_prep                = ata_qc_prep,
        .qc_issue               = ata_qc_issue_prot,
-       .data_xfer              = ata_pio_data_xfer,
+       .data_xfer              = ata_data_xfer,
 
        .freeze                 = ata_bmdma_freeze,
        .thaw                   = ata_bmdma_thaw,
@@ -339,10 +339,10 @@ static const struct ata_port_operations ich_pata_ops = {
 
        .irq_handler            = ata_interrupt,
        .irq_clear              = ata_bmdma_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
 
        .port_start             = ata_port_start,
-       .port_stop              = ata_port_stop,
-       .host_stop              = piix_host_stop,
 };
 
 static const struct ata_port_operations piix_sata_ops = {
@@ -360,7 +360,7 @@ static const struct ata_port_operations piix_sata_ops = {
        .bmdma_status           = ata_bmdma_status,
        .qc_prep                = ata_qc_prep,
        .qc_issue               = ata_qc_issue_prot,
-       .data_xfer              = ata_pio_data_xfer,
+       .data_xfer              = ata_data_xfer,
 
        .freeze                 = ata_bmdma_freeze,
        .thaw                   = ata_bmdma_thaw,
@@ -369,10 +369,10 @@ static const struct ata_port_operations piix_sata_ops = {
 
        .irq_handler            = ata_interrupt,
        .irq_clear              = ata_bmdma_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
 
        .port_start             = ata_port_start,
-       .port_stop              = ata_port_stop,
-       .host_stop              = piix_host_stop,
 };
 
 static const struct piix_map_db ich5_map_db = {
@@ -441,7 +441,7 @@ static const struct piix_map_db *piix_map_db_table[] = {
 };
 
 static struct ata_port_info piix_port_info[] = {
-       /* piix_pata_33: 0:  PIIX3 or 4 at 33MHz */
+       /* piix_pata_33: 0:  PIIX4 at 33MHz */
        {
                .sht            = &piix_sht,
                .flags          = PIIX_PATA_FLAGS,
@@ -543,6 +543,14 @@ static struct ata_port_info piix_port_info[] = {
                .port_ops       = &piix_sata_ops,
        },
 
+       /* piix_pata_mwdma: 10:  PIIX3 MWDMA only */
+       {
+               .sht            = &piix_sht,
+               .flags          = PIIX_PATA_FLAGS,
+               .pio_mask       = 0x1f, /* pio0-4 */
+               .mwdma_mask     = 0x06, /* mwdma1-2 ?? CHECK 0 should be ok but slow */
+               .port_ops       = &piix_pata_ops,
+       },
 };
 
 static struct pci_bits piix_enable_bits[] = {
@@ -569,6 +577,7 @@ struct ich_laptop {
 static const struct ich_laptop ich_laptop[] = {
        /* devid, subvendor, subdev */
        { 0x27DF, 0x0005, 0x0280 },     /* ICH7 on Acer 5602WLMi */
+       { 0x27DF, 0x1025, 0x0110 },     /* ICH7 on Acer 3682WLMi */
        /* end marker */
        { 0, }
 };
@@ -632,7 +641,7 @@ static int piix_pata_prereset(struct ata_port *ap)
 
        if (!pci_test_config_bits(pdev, &piix_enable_bits[ap->port_no]))
                return -ENOENT;
-               
+
        ap->cbl = ATA_CBL_PATA40;
        return ata_std_prereset(ap);
 }
@@ -776,7 +785,7 @@ static void do_pata_set_dmamode (struct ata_port *ap, struct ata_device *adev, i
        u16 master_data;
        u8 speed                = adev->dma_mode;
        int devid               = adev->devno + 2 * ap->port_no;
-       u8 udma_enable;
+       u8 udma_enable          = 0;
 
        static const     /* ISP  RTC */
        u8 timings[][2] = { { 0, 0 },
@@ -786,7 +795,8 @@ static void do_pata_set_dmamode (struct ata_port *ap, struct ata_device *adev, i
                            { 2, 3 }, };
 
        pci_read_config_word(dev, master_port, &master_data);
-       pci_read_config_byte(dev, 0x48, &udma_enable);
+       if (ap->udma_mask)
+               pci_read_config_byte(dev, 0x48, &udma_enable);
 
        if (speed >= XFER_UDMA_0) {
                unsigned int udma = adev->dma_mode - XFER_UDMA_0;
@@ -1059,6 +1069,7 @@ static void __devinit piix_init_sata_map(struct pci_dev *pdev,
 static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
 {
        static int printed_version;
+       struct device *dev = &pdev->dev;
        struct ata_port_info port_info[2];
        struct ata_port_info *ppinfo[2] = { &port_info[0], &port_info[1] };
        struct piix_host_priv *hpriv;
@@ -1072,7 +1083,7 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
        if (!in_module_init)
                return -ENODEV;
 
-       hpriv = kzalloc(sizeof(*hpriv), GFP_KERNEL);
+       hpriv = devm_kzalloc(dev, sizeof(*hpriv), GFP_KERNEL);
        if (!hpriv)
                return -ENOMEM;
 
@@ -1122,15 +1133,6 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
        return ata_pci_init_one(pdev, ppinfo, 2);
 }
 
-static void piix_host_stop(struct ata_host *host)
-{
-       struct piix_host_priv *hpriv = host->private_data;
-
-       ata_host_stop(host);
-
-       kfree(hpriv);
-}
-
 static int __init piix_init(void)
 {
        int rc;
index 667acd283364503c328fd4dcd7c1dbadc2ac5d85..25d8d3f778a1c980f5537f64648ef69d0d3a911b 100644 (file)
@@ -59,6 +59,9 @@
 
 #include "libata.h"
 
+#define DRV_VERSION    "2.10"  /* must be exactly four chars */
+
+
 /* debounce timing parameters in msecs { interval, duration, timeout } */
 const unsigned long sata_deb_timing_normal[]           = {   5,  100, 2000 };
 const unsigned long sata_deb_timing_hotplug[]          = {  25,  500, 2000 };
@@ -598,51 +601,7 @@ void ata_dev_disable(struct ata_device *dev)
 }
 
 /**
- *     ata_pio_devchk - PATA device presence detection
- *     @ap: ATA channel to examine
- *     @device: Device to examine (starting at zero)
- *
- *     This technique was originally described in
- *     Hale Landis's ATADRVR (www.ata-atapi.com), and
- *     later found its way into the ATA/ATAPI spec.
- *
- *     Write a pattern to the ATA shadow registers,
- *     and if a device is present, it will respond by
- *     correctly storing and echoing back the
- *     ATA shadow register contents.
- *
- *     LOCKING:
- *     caller.
- */
-
-static unsigned int ata_pio_devchk(struct ata_port *ap,
-                                  unsigned int device)
-{
-       struct ata_ioports *ioaddr = &ap->ioaddr;
-       u8 nsect, lbal;
-
-       ap->ops->dev_select(ap, device);
-
-       outb(0x55, ioaddr->nsect_addr);
-       outb(0xaa, ioaddr->lbal_addr);
-
-       outb(0xaa, ioaddr->nsect_addr);
-       outb(0x55, ioaddr->lbal_addr);
-
-       outb(0x55, ioaddr->nsect_addr);
-       outb(0xaa, ioaddr->lbal_addr);
-
-       nsect = inb(ioaddr->nsect_addr);
-       lbal = inb(ioaddr->lbal_addr);
-
-       if ((nsect == 0x55) && (lbal == 0xaa))
-               return 1;       /* we found a device */
-
-       return 0;               /* nothing found */
-}
-
-/**
- *     ata_mmio_devchk - PATA device presence detection
+ *     ata_devchk - PATA device presence detection
  *     @ap: ATA channel to examine
  *     @device: Device to examine (starting at zero)
  *
@@ -659,25 +618,24 @@ static unsigned int ata_pio_devchk(struct ata_port *ap,
  *     caller.
  */
 
-static unsigned int ata_mmio_devchk(struct ata_port *ap,
-                                   unsigned int device)
+static unsigned int ata_devchk(struct ata_port *ap, unsigned int device)
 {
        struct ata_ioports *ioaddr = &ap->ioaddr;
        u8 nsect, lbal;
 
        ap->ops->dev_select(ap, device);
 
-       writeb(0x55, (void __iomem *) ioaddr->nsect_addr);
-       writeb(0xaa, (void __iomem *) ioaddr->lbal_addr);
+       iowrite8(0x55, ioaddr->nsect_addr);
+       iowrite8(0xaa, ioaddr->lbal_addr);
 
-       writeb(0xaa, (void __iomem *) ioaddr->nsect_addr);
-       writeb(0x55, (void __iomem *) ioaddr->lbal_addr);
+       iowrite8(0xaa, ioaddr->nsect_addr);
+       iowrite8(0x55, ioaddr->lbal_addr);
 
-       writeb(0x55, (void __iomem *) ioaddr->nsect_addr);
-       writeb(0xaa, (void __iomem *) ioaddr->lbal_addr);
+       iowrite8(0x55, ioaddr->nsect_addr);
+       iowrite8(0xaa, ioaddr->lbal_addr);
 
-       nsect = readb((void __iomem *) ioaddr->nsect_addr);
-       lbal = readb((void __iomem *) ioaddr->lbal_addr);
+       nsect = ioread8(ioaddr->nsect_addr);
+       lbal = ioread8(ioaddr->lbal_addr);
 
        if ((nsect == 0x55) && (lbal == 0xaa))
                return 1;       /* we found a device */
@@ -685,27 +643,6 @@ static unsigned int ata_mmio_devchk(struct ata_port *ap,
        return 0;               /* nothing found */
 }
 
-/**
- *     ata_devchk - PATA device presence detection
- *     @ap: ATA channel to examine
- *     @device: Device to examine (starting at zero)
- *
- *     Dispatch ATA device presence detection, depending
- *     on whether we are using PIO or MMIO to talk to the
- *     ATA shadow registers.
- *
- *     LOCKING:
- *     caller.
- */
-
-static unsigned int ata_devchk(struct ata_port *ap,
-                                   unsigned int device)
-{
-       if (ap->flags & ATA_FLAG_MMIO)
-               return ata_mmio_devchk(ap, device);
-       return ata_pio_devchk(ap, device);
-}
-
 /**
  *     ata_dev_classify - determine device type based on ATA-spec signature
  *     @tf: ATA taskfile register set for device to be identified
@@ -923,11 +860,7 @@ void ata_std_dev_select (struct ata_port *ap, unsigned int device)
        else
                tmp = ATA_DEVICE_OBS | ATA_DEV1;
 
-       if (ap->flags & ATA_FLAG_MMIO) {
-               writeb(tmp, (void __iomem *) ap->ioaddr.device_addr);
-       } else {
-               outb(tmp, ap->ioaddr.device_addr);
-       }
+       iowrite8(tmp, ap->ioaddr.device_addr);
        ata_pause(ap);          /* needed; also flushes, for mmio */
 }
 
@@ -1156,7 +1089,7 @@ void ata_port_flush_task(struct ata_port *ap)
                ata_port_printk(ap, KERN_DEBUG, "%s: EXIT\n", __FUNCTION__);
 }
 
-void ata_qc_complete_internal(struct ata_queued_cmd *qc)
+static void ata_qc_complete_internal(struct ata_queued_cmd *qc)
 {
        struct completion *waiting = qc->private_data;
 
@@ -1249,7 +1182,6 @@ unsigned ata_exec_internal_sg(struct ata_device *dev,
                        buflen += sg[i].length;
 
                ata_sg_init(qc, sg, n_elem);
-               qc->nsect = buflen / ATA_SECT_SIZE;
                qc->nbytes = buflen;
        }
 
@@ -1292,7 +1224,7 @@ unsigned ata_exec_internal_sg(struct ata_device *dev,
        if (ap->ops->post_internal_cmd)
                ap->ops->post_internal_cmd(qc);
 
-       if (qc->flags & ATA_QCFLAG_FAILED && !qc->err_mask) {
+       if ((qc->flags & ATA_QCFLAG_FAILED) && !qc->err_mask) {
                if (ata_msg_warn(ap))
                        ata_dev_printk(dev, KERN_WARNING,
                                "zero err_mask for failed "
@@ -1608,6 +1540,8 @@ int ata_dev_configure(struct ata_device *dev)
        const u16 *id = dev->id;
        unsigned int xfer_mask;
        char revbuf[7];         /* XYZ-99\0 */
+       char fwrevbuf[ATA_ID_FW_REV_LEN+1];
+       char modelbuf[ATA_ID_PROD_LEN+1];
        int rc;
 
        if (!ata_dev_enabled(dev) && ata_msg_info(ap)) {
@@ -1662,6 +1596,16 @@ int ata_dev_configure(struct ata_device *dev)
 
                dev->n_sectors = ata_id_n_sectors(id);
 
+               /* SCSI only uses 4-char revisions, dump full 8 chars from ATA */
+               ata_id_c_string(dev->id, fwrevbuf, ATA_ID_FW_REV,
+                               sizeof(fwrevbuf));
+
+               ata_id_c_string(dev->id, modelbuf, ATA_ID_PROD,
+                               sizeof(modelbuf));
+
+               if (dev->id[59] & 0x100)
+                       dev->multi_count = dev->id[59] & 0xff;
+
                if (ata_id_has_lba(id)) {
                        const char *lba_desc;
                        char ncq_desc[20];
@@ -1681,13 +1625,16 @@ int ata_dev_configure(struct ata_device *dev)
                        ata_dev_config_ncq(dev, ncq_desc, sizeof(ncq_desc));
 
                        /* print device info to dmesg */
-                       if (ata_msg_drv(ap) && print_info)
-                               ata_dev_printk(dev, KERN_INFO, "%s, "
-                                       "max %s, %Lu sectors: %s %s\n",
-                                       revbuf,
-                                       ata_mode_string(xfer_mask),
+                       if (ata_msg_drv(ap) && print_info) {
+                               ata_dev_printk(dev, KERN_INFO,
+                                       "%s: %s, %s, max %s\n",
+                                       revbuf, modelbuf, fwrevbuf,
+                                       ata_mode_string(xfer_mask));
+                               ata_dev_printk(dev, KERN_INFO,
+                                       "%Lu sectors, multi %u: %s %s\n",
                                        (unsigned long long)dev->n_sectors,
-                                       lba_desc, ncq_desc);
+                                       dev->multi_count, lba_desc, ncq_desc);
+                       }
                } else {
                        /* CHS */
 
@@ -1704,22 +1651,17 @@ int ata_dev_configure(struct ata_device *dev)
                        }
 
                        /* print device info to dmesg */
-                       if (ata_msg_drv(ap) && print_info)
-                               ata_dev_printk(dev, KERN_INFO, "%s, "
-                                       "max %s, %Lu sectors: CHS %u/%u/%u\n",
-                                       revbuf,
-                                       ata_mode_string(xfer_mask),
-                                       (unsigned long long)dev->n_sectors,
-                                       dev->cylinders, dev->heads,
-                                       dev->sectors);
-               }
-
-               if (dev->id[59] & 0x100) {
-                       dev->multi_count = dev->id[59] & 0xff;
-                       if (ata_msg_drv(ap) && print_info)
+                       if (ata_msg_drv(ap) && print_info) {
                                ata_dev_printk(dev, KERN_INFO,
-                                       "ata%u: dev %u multi count %u\n",
-                                       ap->id, dev->devno, dev->multi_count);
+                                       "%s: %s, %s, max %s\n",
+                                       revbuf, modelbuf, fwrevbuf,
+                                       ata_mode_string(xfer_mask));
+                               ata_dev_printk(dev, KERN_INFO, 
+                                       "%Lu sectors, multi %u, CHS %u/%u/%u\n",
+                                       (unsigned long long)dev->n_sectors,
+                                       dev->multi_count, dev->cylinders,
+                                       dev->heads, dev->sectors);
+                       }
                }
 
                dev->cdb_len = 16;
@@ -2391,6 +2333,10 @@ static int ata_dev_set_mode(struct ata_device *dev)
                dev->flags |= ATA_DFLAG_PIO;
 
        err_mask = ata_dev_set_xfermode(dev);
+       /* Old CFA may refuse this command, which is just fine */
+       if (dev->xfer_shift == ATA_SHIFT_PIO && ata_id_is_cfa(dev->id))
+               err_mask &= ~AC_ERR_DEV;
+
        if (err_mask) {
                ata_dev_printk(dev, KERN_ERR, "failed to set xfermode "
                               "(err_mask=0x%x)\n", err_mask);
@@ -2493,7 +2439,7 @@ int ata_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev)
        for (i = 0; i < ATA_MAX_DEVICES; i++) {
                dev = &ap->device[i];
 
-               /* don't udpate suspended devices' xfer mode */
+               /* don't update suspended devices' xfer mode */
                if (!ata_dev_ready(dev))
                        continue;
 
@@ -2614,13 +2560,8 @@ static void ata_bus_post_reset(struct ata_port *ap, unsigned int devmask)
                u8 nsect, lbal;
 
                ap->ops->dev_select(ap, 1);
-               if (ap->flags & ATA_FLAG_MMIO) {
-                       nsect = readb((void __iomem *) ioaddr->nsect_addr);
-                       lbal = readb((void __iomem *) ioaddr->lbal_addr);
-               } else {
-                       nsect = inb(ioaddr->nsect_addr);
-                       lbal = inb(ioaddr->lbal_addr);
-               }
+               nsect = ioread8(ioaddr->nsect_addr);
+               lbal = ioread8(ioaddr->lbal_addr);
                if ((nsect == 1) && (lbal == 1))
                        break;
                if (time_after(jiffies, timeout)) {
@@ -2648,19 +2589,11 @@ static unsigned int ata_bus_softreset(struct ata_port *ap,
        DPRINTK("ata%u: bus reset via SRST\n", ap->id);
 
        /* software reset.  causes dev0 to be selected */
-       if (ap->flags & ATA_FLAG_MMIO) {
-               writeb(ap->ctl, (void __iomem *) ioaddr->ctl_addr);
-               udelay(20);     /* FIXME: flush */
-               writeb(ap->ctl | ATA_SRST, (void __iomem *) ioaddr->ctl_addr);
-               udelay(20);     /* FIXME: flush */
-               writeb(ap->ctl, (void __iomem *) ioaddr->ctl_addr);
-       } else {
-               outb(ap->ctl, ioaddr->ctl_addr);
-               udelay(10);
-               outb(ap->ctl | ATA_SRST, ioaddr->ctl_addr);
-               udelay(10);
-               outb(ap->ctl, ioaddr->ctl_addr);
-       }
+       iowrite8(ap->ctl, ioaddr->ctl_addr);
+       udelay(20);     /* FIXME: flush */
+       iowrite8(ap->ctl | ATA_SRST, ioaddr->ctl_addr);
+       udelay(20);     /* FIXME: flush */
+       iowrite8(ap->ctl, ioaddr->ctl_addr);
 
        /* spec mandates ">= 2ms" before checking status.
         * We wait 150ms, because that was the magic delay used for
@@ -2745,8 +2678,7 @@ void ata_bus_reset(struct ata_port *ap)
                ap->device[1].class = ata_dev_try_classify(ap, 1, &err);
 
        /* re-enable interrupts */
-       if (ap->ioaddr.ctl_addr)        /* FIXME: hack. create a hook instead */
-               ata_irq_on(ap);
+       ap->ops->irq_on(ap);
 
        /* is double-select really necessary? */
        if (ap->device[1].class != ATA_DEV_NONE)
@@ -2761,10 +2693,7 @@ void ata_bus_reset(struct ata_port *ap)
 
        if (ap->flags & (ATA_FLAG_SATA_RESET | ATA_FLAG_SRST)) {
                /* set up device control for ATA_FLAG_SATA_RESET */
-               if (ap->flags & ATA_FLAG_MMIO)
-                       writeb(ap->ctl, (void __iomem *) ioaddr->ctl_addr);
-               else
-                       outb(ap->ctl, ioaddr->ctl_addr);
+               iowrite8(ap->ctl, ioaddr->ctl_addr);
        }
 
        DPRINTK("EXIT\n");
@@ -3098,6 +3027,9 @@ int sata_std_hardreset(struct ata_port *ap, unsigned int *class)
                return 0;
        }
 
+       /* wait a while before checking status, see SRST for more info */
+       msleep(150);
+
        if (ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT)) {
                ata_port_printk(ap, KERN_ERR,
                                "COMRESET failed (device not ready)\n");
@@ -3138,11 +3070,8 @@ void ata_std_postreset(struct ata_port *ap, unsigned int *classes)
                sata_scr_write(ap, SCR_ERROR, serror);
 
        /* re-enable interrupts */
-       if (!ap->ops->error_handler) {
-               /* FIXME: hack. create a hook instead */
-               if (ap->ioaddr.ctl_addr)
-                       ata_irq_on(ap);
-       }
+       if (!ap->ops->error_handler)
+               ap->ops->irq_on(ap);
 
        /* is double-select really necessary? */
        if (classes[0] != ATA_DEV_NONE)
@@ -3157,12 +3086,8 @@ void ata_std_postreset(struct ata_port *ap, unsigned int *classes)
        }
 
        /* set up device control */
-       if (ap->ioaddr.ctl_addr) {
-               if (ap->flags & ATA_FLAG_MMIO)
-                       writeb(ap->ctl, (void __iomem *) ap->ioaddr.ctl_addr);
-               else
-                       outb(ap->ctl, ap->ioaddr.ctl_addr);
-       }
+       if (ap->ioaddr.ctl_addr)
+               iowrite8(ap->ctl, ap->ioaddr.ctl_addr);
 
        DPRINTK("EXIT\n");
 }
@@ -3187,7 +3112,8 @@ static int ata_dev_same_device(struct ata_device *dev, unsigned int new_class,
                               const u16 *new_id)
 {
        const u16 *old_id = dev->id;
-       unsigned char model[2][41], serial[2][21];
+       unsigned char model[2][ATA_ID_PROD_LEN + 1];
+       unsigned char serial[2][ATA_ID_SERNO_LEN + 1];
        u64 new_n_sectors;
 
        if (dev->class != new_class) {
@@ -3196,10 +3122,10 @@ static int ata_dev_same_device(struct ata_device *dev, unsigned int new_class,
                return 0;
        }
 
-       ata_id_c_string(old_id, model[0], ATA_ID_PROD_OFS, sizeof(model[0]));
-       ata_id_c_string(new_id, model[1], ATA_ID_PROD_OFS, sizeof(model[1]));
-       ata_id_c_string(old_id, serial[0], ATA_ID_SERNO_OFS, sizeof(serial[0]));
-       ata_id_c_string(new_id, serial[1], ATA_ID_SERNO_OFS, sizeof(serial[1]));
+       ata_id_c_string(old_id, model[0], ATA_ID_PROD, sizeof(model[0]));
+       ata_id_c_string(new_id, model[1], ATA_ID_PROD, sizeof(model[1]));
+       ata_id_c_string(old_id, serial[0], ATA_ID_SERNO, sizeof(serial[0]));
+       ata_id_c_string(new_id, serial[1], ATA_ID_SERNO, sizeof(serial[1]));
        new_n_sectors = ata_id_n_sectors(new_id);
 
        if (strcmp(model[0], model[1])) {
@@ -3324,37 +3250,20 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = {
        { }
 };
 
-static int ata_strim(char *s, size_t len)
-{
-       len = strnlen(s, len);
-
-       /* ATAPI specifies that empty space is blank-filled; remove blanks */
-       while ((len > 0) && (s[len - 1] == ' ')) {
-               len--;
-               s[len] = 0;
-       }
-       return len;
-}
-
 unsigned long ata_device_blacklisted(const struct ata_device *dev)
 {
-       unsigned char model_num[40];
-       unsigned char model_rev[16];
-       unsigned int nlen, rlen;
+       unsigned char model_num[ATA_ID_PROD_LEN + 1];
+       unsigned char model_rev[ATA_ID_FW_REV_LEN + 1];
        const struct ata_blacklist_entry *ad = ata_device_blacklist;
 
-       ata_id_string(dev->id, model_num, ATA_ID_PROD_OFS,
-                         sizeof(model_num));
-       ata_id_string(dev->id, model_rev, ATA_ID_FW_REV_OFS,
-                         sizeof(model_rev));
-       nlen = ata_strim(model_num, sizeof(model_num));
-       rlen = ata_strim(model_rev, sizeof(model_rev));
+       ata_id_c_string(dev->id, model_num, ATA_ID_PROD, sizeof(model_num));
+       ata_id_c_string(dev->id, model_rev, ATA_ID_FW_REV, sizeof(model_rev));
 
        while (ad->model_num) {
-               if (!strncmp(ad->model_num, model_num, nlen)) {
+               if (!strcmp(ad->model_num, model_num)) {
                        if (ad->model_rev == NULL)
                                return ad->horkage;
-                       if (!strncmp(ad->model_rev, model_rev, rlen))
+                       if (!strcmp(ad->model_rev, model_rev))
                                return ad->horkage;
                }
                ad++;
@@ -3894,53 +3803,7 @@ void swap_buf_le16(u16 *buf, unsigned int buf_words)
 }
 
 /**
- *     ata_mmio_data_xfer - Transfer data by MMIO
- *     @adev: device for this I/O
- *     @buf: data buffer
- *     @buflen: buffer length
- *     @write_data: read/write
- *
- *     Transfer data from/to the device data register by MMIO.
- *
- *     LOCKING:
- *     Inherited from caller.
- */
-
-void ata_mmio_data_xfer(struct ata_device *adev, unsigned char *buf,
-                       unsigned int buflen, int write_data)
-{
-       struct ata_port *ap = adev->ap;
-       unsigned int i;
-       unsigned int words = buflen >> 1;
-       u16 *buf16 = (u16 *) buf;
-       void __iomem *mmio = (void __iomem *)ap->ioaddr.data_addr;
-
-       /* Transfer multiple of 2 bytes */
-       if (write_data) {
-               for (i = 0; i < words; i++)
-                       writew(le16_to_cpu(buf16[i]), mmio);
-       } else {
-               for (i = 0; i < words; i++)
-                       buf16[i] = cpu_to_le16(readw(mmio));
-       }
-
-       /* Transfer trailing 1 byte, if any. */
-       if (unlikely(buflen & 0x01)) {
-               u16 align_buf[1] = { 0 };
-               unsigned char *trailing_buf = buf + buflen - 1;
-
-               if (write_data) {
-                       memcpy(align_buf, trailing_buf, 1);
-                       writew(le16_to_cpu(align_buf[0]), mmio);
-               } else {
-                       align_buf[0] = cpu_to_le16(readw(mmio));
-                       memcpy(trailing_buf, align_buf, 1);
-               }
-       }
-}
-
-/**
- *     ata_pio_data_xfer - Transfer data by PIO
+ *     ata_data_xfer - Transfer data by PIO
  *     @adev: device to target
  *     @buf: data buffer
  *     @buflen: buffer length
@@ -3951,18 +3814,17 @@ void ata_mmio_data_xfer(struct ata_device *adev, unsigned char *buf,
  *     LOCKING:
  *     Inherited from caller.
  */
-
-void ata_pio_data_xfer(struct ata_device *adev, unsigned char *buf,
-                      unsigned int buflen, int write_data)
+void ata_data_xfer(struct ata_device *adev, unsigned char *buf,
+                  unsigned int buflen, int write_data)
 {
        struct ata_port *ap = adev->ap;
        unsigned int words = buflen >> 1;
 
        /* Transfer multiple of 2 bytes */
        if (write_data)
-               outsw(ap->ioaddr.data_addr, buf, words);
+               iowrite16_rep(ap->ioaddr.data_addr, buf, words);
        else
-               insw(ap->ioaddr.data_addr, buf, words);
+               ioread16_rep(ap->ioaddr.data_addr, buf, words);
 
        /* Transfer trailing 1 byte, if any. */
        if (unlikely(buflen & 0x01)) {
@@ -3971,16 +3833,16 @@ void ata_pio_data_xfer(struct ata_device *adev, unsigned char *buf,
 
                if (write_data) {
                        memcpy(align_buf, trailing_buf, 1);
-                       outw(le16_to_cpu(align_buf[0]), ap->ioaddr.data_addr);
+                       iowrite16(le16_to_cpu(align_buf[0]), ap->ioaddr.data_addr);
                } else {
-                       align_buf[0] = cpu_to_le16(inw(ap->ioaddr.data_addr));
+                       align_buf[0] = cpu_to_le16(ioread16(ap->ioaddr.data_addr));
                        memcpy(trailing_buf, align_buf, 1);
                }
        }
 }
 
 /**
- *     ata_pio_data_xfer_noirq - Transfer data by PIO
+ *     ata_data_xfer_noirq - Transfer data by PIO
  *     @adev: device to target
  *     @buf: data buffer
  *     @buflen: buffer length
@@ -3992,13 +3854,12 @@ void ata_pio_data_xfer(struct ata_device *adev, unsigned char *buf,
  *     LOCKING:
  *     Inherited from caller.
  */
-
-void ata_pio_data_xfer_noirq(struct ata_device *adev, unsigned char *buf,
-                                   unsigned int buflen, int write_data)
+void ata_data_xfer_noirq(struct ata_device *adev, unsigned char *buf,
+                        unsigned int buflen, int write_data)
 {
        unsigned long flags;
        local_irq_save(flags);
-       ata_pio_data_xfer(adev, buf, buflen, write_data);
+       ata_data_xfer(adev, buf, buflen, write_data);
        local_irq_restore(flags);
 }
 
@@ -4022,11 +3883,11 @@ static void ata_pio_sector(struct ata_queued_cmd *qc)
        unsigned int offset;
        unsigned char *buf;
 
-       if (qc->cursect == (qc->nsect - 1))
+       if (qc->curbytes == qc->nbytes - ATA_SECT_SIZE)
                ap->hsm_task_state = HSM_ST_LAST;
 
        page = sg[qc->cursg].page;
-       offset = sg[qc->cursg].offset + qc->cursg_ofs * ATA_SECT_SIZE;
+       offset = sg[qc->cursg].offset + qc->cursg_ofs;
 
        /* get the current page and offset */
        page = nth_page(page, (offset >> PAGE_SHIFT));
@@ -4051,10 +3912,10 @@ static void ata_pio_sector(struct ata_queued_cmd *qc)
                ap->ops->data_xfer(qc->dev, buf + offset, ATA_SECT_SIZE, do_write);
        }
 
-       qc->cursect++;
-       qc->cursg_ofs++;
+       qc->curbytes += ATA_SECT_SIZE;
+       qc->cursg_ofs += ATA_SECT_SIZE;
 
-       if ((qc->cursg_ofs * ATA_SECT_SIZE) == (&sg[qc->cursg])->length) {
+       if (qc->cursg_ofs == (&sg[qc->cursg])->length) {
                qc->cursg++;
                qc->cursg_ofs = 0;
        }
@@ -4079,7 +3940,8 @@ static void ata_pio_sectors(struct ata_queued_cmd *qc)
 
                WARN_ON(qc->dev->multi_count == 0);
 
-               nsect = min(qc->nsect - qc->cursect, qc->dev->multi_count);
+               nsect = min((qc->nbytes - qc->curbytes) / ATA_SECT_SIZE,
+                           qc->dev->multi_count);
                while (nsect--)
                        ata_pio_sector(qc);
        } else
@@ -4320,7 +4182,7 @@ static void ata_hsm_qc_complete(struct ata_queued_cmd *qc, int in_wq)
                        qc = ata_qc_from_tag(ap, qc->tag);
                        if (qc) {
                                if (likely(!(qc->err_mask & AC_ERR_HSM))) {
-                                       ata_irq_on(ap);
+                                       ap->ops->irq_on(ap);
                                        ata_qc_complete(qc);
                                } else
                                        ata_port_freeze(ap);
@@ -4336,7 +4198,7 @@ static void ata_hsm_qc_complete(struct ata_queued_cmd *qc, int in_wq)
        } else {
                if (in_wq) {
                        spin_lock_irqsave(ap->lock, flags);
-                       ata_irq_on(ap);
+                       ap->ops->irq_on(ap);
                        ata_qc_complete(qc);
                        spin_unlock_irqrestore(ap->lock, flags);
                } else
@@ -5161,7 +5023,7 @@ idle_irq:
 
 #ifdef ATA_IRQ_TRAP
        if ((ap->stats.idle_irq % 1000) == 0) {
-               ata_irq_ack(ap, 0); /* debug trap */
+               ap->ops->irq_ack(ap, 0); /* debug trap */
                ata_port_printk(ap, KERN_WARNING, "irq trap\n");
                return 1;
        }
@@ -5502,54 +5364,25 @@ void ata_host_resume(struct ata_host *host)
  *     LOCKING:
  *     Inherited from caller.
  */
-
-int ata_port_start (struct ata_port *ap)
+int ata_port_start(struct ata_port *ap)
 {
        struct device *dev = ap->dev;
        int rc;
 
-       ap->prd = dma_alloc_coherent(dev, ATA_PRD_TBL_SZ, &ap->prd_dma, GFP_KERNEL);
+       ap->prd = dmam_alloc_coherent(dev, ATA_PRD_TBL_SZ, &ap->prd_dma,
+                                     GFP_KERNEL);
        if (!ap->prd)
                return -ENOMEM;
 
        rc = ata_pad_alloc(ap, dev);
-       if (rc) {
-               dma_free_coherent(dev, ATA_PRD_TBL_SZ, ap->prd, ap->prd_dma);
+       if (rc)
                return rc;
-       }
-
-       DPRINTK("prd alloc, virt %p, dma %llx\n", ap->prd, (unsigned long long) ap->prd_dma);
 
+       DPRINTK("prd alloc, virt %p, dma %llx\n", ap->prd,
+               (unsigned long long)ap->prd_dma);
        return 0;
 }
 
-
-/**
- *     ata_port_stop - Undo ata_port_start()
- *     @ap: Port to shut down
- *
- *     Frees the PRD table.
- *
- *     May be used as the port_stop() entry in ata_port_operations.
- *
- *     LOCKING:
- *     Inherited from caller.
- */
-
-void ata_port_stop (struct ata_port *ap)
-{
-       struct device *dev = ap->dev;
-
-       dma_free_coherent(dev, ATA_PRD_TBL_SZ, ap->prd, ap->prd_dma);
-       ata_pad_free(ap, dev);
-}
-
-void ata_host_stop (struct ata_host *host)
-{
-       if (host->mmio_base)
-               iounmap(host->mmio_base);
-}
-
 /**
  *     ata_dev_init - Initialize an ata_device structure
  *     @dev: Device structure to initialize
@@ -5723,6 +5556,27 @@ static struct ata_port * ata_port_add(const struct ata_probe_ent *ent,
        return ap;
 }
 
+static void ata_host_release(struct device *gendev, void *res)
+{
+       struct ata_host *host = dev_get_drvdata(gendev);
+       int i;
+
+       for (i = 0; i < host->n_ports; i++) {
+               struct ata_port *ap = host->ports[i];
+
+               if (!ap)
+                       continue;
+
+               if (ap->ops->port_stop)
+                       ap->ops->port_stop(ap);
+
+               scsi_host_put(ap->scsi_host);
+       }
+
+       if (host->ops->host_stop)
+               host->ops->host_stop(host);
+}
+
 /**
  *     ata_sas_host_init - Initialize a host struct
  *     @host:  host to initialize
@@ -5770,22 +5624,28 @@ int ata_device_add(const struct ata_probe_ent *ent)
        int rc;
 
        DPRINTK("ENTER\n");
-       
+
        if (ent->irq == 0) {
                dev_printk(KERN_ERR, dev, "is not available: No interrupt assigned.\n");
                return 0;
        }
+
+       if (!devres_open_group(dev, ata_device_add, GFP_KERNEL))
+               return 0;
+
        /* alloc a container for our list of ATA ports (buses) */
-       host = kzalloc(sizeof(struct ata_host) +
-                      (ent->n_ports * sizeof(void *)), GFP_KERNEL);
+       host = devres_alloc(ata_host_release, sizeof(struct ata_host) +
+                           (ent->n_ports * sizeof(void *)), GFP_KERNEL);
        if (!host)
-               return 0;
+               goto err_out;
+       devres_add(dev, host);
+       dev_set_drvdata(dev, host);
 
        ata_host_init(host, dev, ent->_host_flags, ent->port_ops);
        host->n_ports = ent->n_ports;
        host->irq = ent->irq;
        host->irq2 = ent->irq2;
-       host->mmio_base = ent->mmio_base;
+       host->iomap = ent->iomap;
        host->private_data = ent->private_data;
 
        /* register each port bound to this device */
@@ -5823,8 +5683,8 @@ int ata_device_add(const struct ata_probe_ent *ent)
                                (ap->pio_mask << ATA_SHIFT_PIO);
 
                /* print per-port info to dmesg */
-               ata_port_printk(ap, KERN_INFO, "%cATA max %s cmd 0x%lX "
-                               "ctl 0x%lX bmdma 0x%lX irq %d\n",
+               ata_port_printk(ap, KERN_INFO, "%cATA max %s cmd 0x%p "
+                               "ctl 0x%p bmdma 0x%p irq %d\n",
                                ap->flags & ATA_FLAG_SATA ? 'S' : 'P',
                                ata_mode_string(xfer_mode_mask),
                                ap->ioaddr.cmd_addr,
@@ -5837,8 +5697,8 @@ int ata_device_add(const struct ata_probe_ent *ent)
        }
 
        /* obtain irq, that may be shared between channels */
-       rc = request_irq(ent->irq, ent->port_ops->irq_handler, ent->irq_flags,
-                        DRV_NAME, host);
+       rc = devm_request_irq(dev, ent->irq, ent->port_ops->irq_handler,
+                             ent->irq_flags, DRV_NAME, host);
        if (rc) {
                dev_printk(KERN_ERR, dev, "irq %lu request failed: %d\n",
                           ent->irq, rc);
@@ -5851,15 +5711,19 @@ int ata_device_add(const struct ata_probe_ent *ent)
                   so trap it now */
                BUG_ON(ent->irq == ent->irq2);
 
-               rc = request_irq(ent->irq2, ent->port_ops->irq_handler, ent->irq_flags,
-                        DRV_NAME, host);
+               rc = devm_request_irq(dev, ent->irq2,
+                               ent->port_ops->irq_handler, ent->irq_flags,
+                               DRV_NAME, host);
                if (rc) {
                        dev_printk(KERN_ERR, dev, "irq %lu request failed: %d\n",
                                   ent->irq2, rc);
-                       goto err_out_free_irq;
+                       goto err_out;
                }
        }
 
+       /* resource acquisition complete */
+       devres_remove_group(dev, ata_device_add);
+
        /* perform each probe synchronously */
        DPRINTK("probe begin\n");
        for (i = 0; i < host->n_ports; i++) {
@@ -5928,24 +5792,13 @@ int ata_device_add(const struct ata_probe_ent *ent)
                ata_scsi_scan_host(ap);
        }
 
-       dev_set_drvdata(dev, host);
-
        VPRINTK("EXIT, returning %u\n", ent->n_ports);
        return ent->n_ports; /* success */
 
-err_out_free_irq:
-       free_irq(ent->irq, host);
-err_out:
-       for (i = 0; i < host->n_ports; i++) {
-               struct ata_port *ap = host->ports[i];
-               if (ap) {
-                       ap->ops->port_stop(ap);
-                       scsi_host_put(ap->scsi_host);
-               }
-       }
-
-       kfree(host);
-       VPRINTK("EXIT, returning 0\n");
+ err_out:
+       devres_release_group(dev, ata_device_add);
+       dev_set_drvdata(dev, NULL);
+       VPRINTK("EXIT, returning %d\n", rc);
        return 0;
 }
 
@@ -6008,76 +5861,20 @@ void ata_port_detach(struct ata_port *ap)
 }
 
 /**
- *     ata_host_remove - PCI layer callback for device removal
- *     @host: ATA host set that was removed
+ *     ata_host_detach - Detach all ports of an ATA host
+ *     @host: Host to detach
  *
- *     Unregister all objects associated with this host set. Free those
- *     objects.
+ *     Detach all ports of @host.
  *
  *     LOCKING:
- *     Inherited from calling layer (may sleep).
+ *     Kernel thread context (may sleep).
  */
-
-void ata_host_remove(struct ata_host *host)
+void ata_host_detach(struct ata_host *host)
 {
-       unsigned int i;
+       int i;
 
        for (i = 0; i < host->n_ports; i++)
                ata_port_detach(host->ports[i]);
-
-       free_irq(host->irq, host);
-       if (host->irq2)
-               free_irq(host->irq2, host);
-
-       for (i = 0; i < host->n_ports; i++) {
-               struct ata_port *ap = host->ports[i];
-
-               ata_scsi_release(ap->scsi_host);
-
-               if ((ap->flags & ATA_FLAG_NO_LEGACY) == 0) {
-                       struct ata_ioports *ioaddr = &ap->ioaddr;
-
-                       /* FIXME: Add -ac IDE pci mods to remove these special cases */
-                       if (ioaddr->cmd_addr == ATA_PRIMARY_CMD)
-                               release_region(ATA_PRIMARY_CMD, 8);
-                       else if (ioaddr->cmd_addr == ATA_SECONDARY_CMD)
-                               release_region(ATA_SECONDARY_CMD, 8);
-               }
-
-               scsi_host_put(ap->scsi_host);
-       }
-
-       if (host->ops->host_stop)
-               host->ops->host_stop(host);
-
-       kfree(host);
-}
-
-/**
- *     ata_scsi_release - SCSI layer callback hook for host unload
- *     @shost: libata host to be unloaded
- *
- *     Performs all duties necessary to shut down a libata port...
- *     Kill port kthread, disable port, and release resources.
- *
- *     LOCKING:
- *     Inherited from SCSI layer.
- *
- *     RETURNS:
- *     One.
- */
-
-int ata_scsi_release(struct Scsi_Host *shost)
-{
-       struct ata_port *ap = ata_shost_to_port(shost);
-
-       DPRINTK("ENTER\n");
-
-       ap->ops->port_disable(ap);
-       ap->ops->port_stop(ap);
-
-       DPRINTK("EXIT\n");
-       return 1;
 }
 
 struct ata_probe_ent *
@@ -6085,7 +5882,11 @@ ata_probe_ent_alloc(struct device *dev, const struct ata_port_info *port)
 {
        struct ata_probe_ent *probe_ent;
 
-       probe_ent = kzalloc(sizeof(*probe_ent), GFP_KERNEL);
+       /* XXX - the following if can go away once all LLDs are managed */
+       if (!list_empty(&dev->devres_head))
+               probe_ent = devm_kzalloc(dev, sizeof(*probe_ent), GFP_KERNEL);
+       else
+               probe_ent = kzalloc(sizeof(*probe_ent), GFP_KERNEL);
        if (!probe_ent) {
                printk(KERN_ERR DRV_NAME "(%s): out of memory\n",
                       kobject_name(&(dev->kobj)));
@@ -6135,37 +5936,23 @@ void ata_std_ports(struct ata_ioports *ioaddr)
 
 #ifdef CONFIG_PCI
 
-void ata_pci_host_stop (struct ata_host *host)
-{
-       struct pci_dev *pdev = to_pci_dev(host->dev);
-
-       pci_iounmap(pdev, host->mmio_base);
-}
-
 /**
  *     ata_pci_remove_one - PCI layer callback for device removal
  *     @pdev: PCI device that was removed
  *
- *     PCI layer indicates to libata via this hook that
- *     hot-unplug or module unload event has occurred.
- *     Handle this by unregistering all objects associated
- *     with this PCI device.  Free those objects.  Then finally
- *     release PCI resources and disable device.
+ *     PCI layer indicates to libata via this hook that hot-unplug or
+ *     module unload event has occurred.  Detach all ports.  Resource
+ *     release is handled via devres.
  *
  *     LOCKING:
  *     Inherited from PCI layer (may sleep).
  */
-
-void ata_pci_remove_one (struct pci_dev *pdev)
+void ata_pci_remove_one(struct pci_dev *pdev)
 {
        struct device *dev = pci_dev_to_dev(pdev);
        struct ata_host *host = dev_get_drvdata(dev);
 
-       ata_host_remove(host);
-
-       pci_release_regions(pdev);
-       pci_disable_device(pdev);
-       dev_set_drvdata(dev, NULL);
+       ata_host_detach(host);
 }
 
 /* move to PCI subsystem */
@@ -6212,12 +5999,22 @@ void ata_pci_device_do_suspend(struct pci_dev *pdev, pm_message_t mesg)
        }
 }
 
-void ata_pci_device_do_resume(struct pci_dev *pdev)
+int ata_pci_device_do_resume(struct pci_dev *pdev)
 {
+       int rc;
+
        pci_set_power_state(pdev, PCI_D0);
        pci_restore_state(pdev);
-       pci_enable_device(pdev);
+
+       rc = pcim_enable_device(pdev);
+       if (rc) {
+               dev_printk(KERN_ERR, &pdev->dev,
+                          "failed to enable device after resume (%d)\n", rc);
+               return rc;
+       }
+
        pci_set_master(pdev);
+       return 0;
 }
 
 int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg)
@@ -6237,10 +6034,12 @@ int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg)
 int ata_pci_device_resume(struct pci_dev *pdev)
 {
        struct ata_host *host = dev_get_drvdata(&pdev->dev);
+       int rc;
 
-       ata_pci_device_do_resume(pdev);
-       ata_host_resume(host);
-       return 0;
+       rc = ata_pci_device_do_resume(pdev);
+       if (rc == 0)
+               ata_host_resume(host);
+       return rc;
 }
 #endif /* CONFIG_PCI */
 
@@ -6386,8 +6185,7 @@ EXPORT_SYMBOL_GPL(ata_std_bios_param);
 EXPORT_SYMBOL_GPL(ata_std_ports);
 EXPORT_SYMBOL_GPL(ata_host_init);
 EXPORT_SYMBOL_GPL(ata_device_add);
-EXPORT_SYMBOL_GPL(ata_port_detach);
-EXPORT_SYMBOL_GPL(ata_host_remove);
+EXPORT_SYMBOL_GPL(ata_host_detach);
 EXPORT_SYMBOL_GPL(ata_sg_init);
 EXPORT_SYMBOL_GPL(ata_sg_init_one);
 EXPORT_SYMBOL_GPL(ata_hsm_move);
@@ -6404,12 +6202,9 @@ EXPORT_SYMBOL_GPL(ata_check_status);
 EXPORT_SYMBOL_GPL(ata_altstatus);
 EXPORT_SYMBOL_GPL(ata_exec_command);
 EXPORT_SYMBOL_GPL(ata_port_start);
-EXPORT_SYMBOL_GPL(ata_port_stop);
-EXPORT_SYMBOL_GPL(ata_host_stop);
 EXPORT_SYMBOL_GPL(ata_interrupt);
-EXPORT_SYMBOL_GPL(ata_mmio_data_xfer);
-EXPORT_SYMBOL_GPL(ata_pio_data_xfer);
-EXPORT_SYMBOL_GPL(ata_pio_data_xfer_noirq);
+EXPORT_SYMBOL_GPL(ata_data_xfer);
+EXPORT_SYMBOL_GPL(ata_data_xfer_noirq);
 EXPORT_SYMBOL_GPL(ata_qc_prep);
 EXPORT_SYMBOL_GPL(ata_noop_qc_prep);
 EXPORT_SYMBOL_GPL(ata_bmdma_setup);
@@ -6446,7 +6241,6 @@ EXPORT_SYMBOL_GPL(ata_scsi_queuecmd);
 EXPORT_SYMBOL_GPL(ata_scsi_slave_config);
 EXPORT_SYMBOL_GPL(ata_scsi_slave_destroy);
 EXPORT_SYMBOL_GPL(ata_scsi_change_queue_depth);
-EXPORT_SYMBOL_GPL(ata_scsi_release);
 EXPORT_SYMBOL_GPL(ata_host_intr);
 EXPORT_SYMBOL_GPL(sata_scr_valid);
 EXPORT_SYMBOL_GPL(sata_scr_read);
@@ -6467,7 +6261,6 @@ EXPORT_SYMBOL_GPL(ata_timing_merge);
 
 #ifdef CONFIG_PCI
 EXPORT_SYMBOL_GPL(pci_test_config_bits);
-EXPORT_SYMBOL_GPL(ata_pci_host_stop);
 EXPORT_SYMBOL_GPL(ata_pci_init_native_mode);
 EXPORT_SYMBOL_GPL(ata_pci_init_one);
 EXPORT_SYMBOL_GPL(ata_pci_remove_one);
@@ -6491,3 +6284,7 @@ EXPORT_SYMBOL_GPL(ata_eh_thaw_port);
 EXPORT_SYMBOL_GPL(ata_eh_qc_complete);
 EXPORT_SYMBOL_GPL(ata_eh_qc_retry);
 EXPORT_SYMBOL_GPL(ata_do_eh);
+EXPORT_SYMBOL_GPL(ata_irq_on);
+EXPORT_SYMBOL_GPL(ata_dummy_irq_on);
+EXPORT_SYMBOL_GPL(ata_irq_ack);
+EXPORT_SYMBOL_GPL(ata_dummy_irq_ack);
index 748435807d689cbc8ac3aa511576dc87e656b427..52c85af7fe9912492cd9353a4d92f78e3a600e9c 100644 (file)
@@ -1443,15 +1443,10 @@ static void ata_eh_report(struct ata_port *ap)
                };
                struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag);
                struct ata_taskfile *cmd = &qc->tf, *res = &qc->result_tf;
-               unsigned int nbytes;
 
                if (!(qc->flags & ATA_QCFLAG_FAILED) || !qc->err_mask)
                        continue;
 
-               nbytes = qc->nbytes;
-               if (!nbytes)
-                       nbytes = qc->nsect << 9;
-
                ata_dev_printk(qc->dev, KERN_ERR,
                        "cmd %02x/%02x:%02x:%02x:%02x:%02x/%02x:%02x:%02x:%02x:%02x/%02x "
                        "tag %d cdb 0x%x data %u %s\n         "
@@ -1461,7 +1456,7 @@ static void ata_eh_report(struct ata_port *ap)
                        cmd->lbal, cmd->lbam, cmd->lbah,
                        cmd->hob_feature, cmd->hob_nsect,
                        cmd->hob_lbal, cmd->hob_lbam, cmd->hob_lbah,
-                       cmd->device, qc->tag, qc->cdb[0], nbytes,
+                       cmd->device, qc->tag, qc->cdb[0], qc->nbytes,
                        dma_str[qc->dma_dir],
                        res->command, res->feature, res->nsect,
                        res->lbal, res->lbam, res->lbah,
index 73902d335767b4a8404d2e5b7fb1b3503ddd9798..0009818a4306e7fb5e18c717f81d57256ebda337 100644 (file)
@@ -148,6 +148,45 @@ int ata_std_bios_param(struct scsi_device *sdev, struct block_device *bdev,
        return 0;
 }
 
+/**
+ *     ata_get_identity - Handler for HDIO_GET_IDENTITY ioctl
+ *     @sdev: SCSI device to get identify data for
+ *     @arg: User buffer area for identify data
+ *
+ *     LOCKING:
+ *     Defined by the SCSI layer.  We don't really care.
+ *
+ *     RETURNS:
+ *     Zero on success, negative errno on error.
+ */
+static int ata_get_identity(struct scsi_device *sdev, void __user *arg)
+{
+       struct ata_port *ap = ata_shost_to_port(sdev->host);
+       struct ata_device *dev = ata_scsi_find_dev(ap, sdev);
+       u16 __user *dst = arg;
+       char buf[40];
+
+       if (!dev)
+               return -ENOMSG;
+
+       if (copy_to_user(dst, dev->id, ATA_ID_WORDS * sizeof(u16)))
+               return -EFAULT;
+
+       ata_id_string(dev->id, buf, ATA_ID_PROD, ATA_ID_PROD_LEN);
+       if (copy_to_user(dst + ATA_ID_PROD, buf, ATA_ID_PROD_LEN))
+               return -EFAULT;
+
+       ata_id_string(dev->id, buf, ATA_ID_FW_REV, ATA_ID_FW_REV_LEN);
+       if (copy_to_user(dst + ATA_ID_FW_REV, buf, ATA_ID_FW_REV_LEN))
+               return -EFAULT;
+
+       ata_id_string(dev->id, buf, ATA_ID_SERNO, ATA_ID_SERNO_LEN);
+       if (copy_to_user(dst + ATA_ID_SERNO, buf, ATA_ID_SERNO_LEN))
+               return -EFAULT;
+
+       return 0;
+}
+
 /**
  *     ata_cmd_ioctl - Handler for HDIO_DRIVE_CMD ioctl
  *     @scsidev: Device to which we are issuing command
@@ -159,7 +198,6 @@ int ata_std_bios_param(struct scsi_device *sdev, struct block_device *bdev,
  *     RETURNS:
  *     Zero on success, negative errno on error.
  */
-
 int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg)
 {
        int rc = 0;
@@ -359,6 +397,9 @@ int ata_scsi_ioctl(struct scsi_device *scsidev, int cmd, void __user *arg)
                        return -EINVAL;
                return 0;
 
+       case HDIO_GET_IDENTITY:
+               return ata_get_identity(scsidev, arg);
+
        case HDIO_DRIVE_CMD:
                if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO))
                        return -EACCES;
@@ -397,9 +438,9 @@ int ata_scsi_ioctl(struct scsi_device *scsidev, int cmd, void __user *arg)
  *     RETURNS:
  *     Command allocated, or %NULL if none available.
  */
-struct ata_queued_cmd *ata_scsi_qc_new(struct ata_device *dev,
-                                      struct scsi_cmnd *cmd,
-                                      void (*done)(struct scsi_cmnd *))
+static struct ata_queued_cmd *ata_scsi_qc_new(struct ata_device *dev,
+                                             struct scsi_cmnd *cmd,
+                                             void (*done)(struct scsi_cmnd *))
 {
        struct ata_queued_cmd *qc;
 
@@ -435,7 +476,7 @@ struct ata_queued_cmd *ata_scsi_qc_new(struct ata_device *dev,
  *     LOCKING:
  *     inherited from caller
  */
-void ata_dump_status(unsigned id, struct ata_taskfile *tf)
+static void ata_dump_status(unsigned id, struct ata_taskfile *tf)
 {
        u8 stat = tf->command, err = tf->feature;
 
@@ -610,8 +651,8 @@ int ata_scsi_device_resume(struct scsi_device *sdev)
  *     LOCKING:
  *     spin_lock_irqsave(host lock)
  */
-void ata_to_sense_error(unsigned id, u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc,
-                       u8 *ascq, int verbose)
+static void ata_to_sense_error(unsigned id, u8 drv_stat, u8 drv_err, u8 *sk,
+                              u8 *asc, u8 *ascq, int verbose)
 {
        int i;
 
@@ -1359,7 +1400,7 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc)
                goto nothing_to_do;
 
        qc->flags |= ATA_QCFLAG_IO;
-       qc->nsect = n_block;
+       qc->nbytes = n_block * ATA_SECT_SIZE;
 
        rc = ata_build_rw_tf(&qc->tf, qc->dev, block, n_block, tf_flags,
                             qc->tag);
@@ -1698,8 +1739,8 @@ unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf,
 
        if (buflen > 35) {
                memcpy(&rbuf[8], "ATA     ", 8);
-               ata_id_string(args->id, &rbuf[16], ATA_ID_PROD_OFS, 16);
-               ata_id_string(args->id, &rbuf[32], ATA_ID_FW_REV_OFS, 4);
+               ata_id_string(args->id, &rbuf[16], ATA_ID_PROD, 16);
+               ata_id_string(args->id, &rbuf[32], ATA_ID_FW_REV, 4);
                if (rbuf[32] == 0 || rbuf[32] == ' ')
                        memcpy(&rbuf[32], "n/a ", 4);
        }
@@ -1768,13 +1809,13 @@ unsigned int ata_scsiop_inq_80(struct ata_scsi_args *args, u8 *rbuf,
                0,
                0x80,                   /* this page code */
                0,
-               ATA_SERNO_LEN,          /* page len */
+               ATA_ID_SERNO_LEN,       /* page len */
        };
        memcpy(rbuf, hdr, sizeof(hdr));
 
-       if (buflen > (ATA_SERNO_LEN + 4 - 1))
+       if (buflen > (ATA_ID_SERNO_LEN + 4 - 1))
                ata_id_string(args->id, (unsigned char *) &rbuf[4],
-                             ATA_ID_SERNO_OFS, ATA_SERNO_LEN);
+                             ATA_ID_SERNO, ATA_ID_SERNO_LEN);
 
        return 0;
 }
@@ -1799,19 +1840,18 @@ unsigned int ata_scsiop_inq_83(struct ata_scsi_args *args, u8 *rbuf,
 {
        int num;
        const int sat_model_serial_desc_len = 68;
-       const int ata_model_byte_len = 40;
 
        rbuf[1] = 0x83;                 /* this page code */
        num = 4;
 
-       if (buflen > (ATA_SERNO_LEN + num + 3)) {
+       if (buflen > (ATA_ID_SERNO_LEN + num + 3)) {
                /* piv=0, assoc=lu, code_set=ACSII, designator=vendor */
                rbuf[num + 0] = 2;
-               rbuf[num + 3] = ATA_SERNO_LEN;
+               rbuf[num + 3] = ATA_ID_SERNO_LEN;
                num += 4;
                ata_id_string(args->id, (unsigned char *) rbuf + num,
-                             ATA_ID_SERNO_OFS, ATA_SERNO_LEN);
-               num += ATA_SERNO_LEN;
+                             ATA_ID_SERNO, ATA_ID_SERNO_LEN);
+               num += ATA_ID_SERNO_LEN;
        }
        if (buflen > (sat_model_serial_desc_len + num + 3)) {
                /* SAT defined lu model and serial numbers descriptor */
@@ -1823,11 +1863,11 @@ unsigned int ata_scsiop_inq_83(struct ata_scsi_args *args, u8 *rbuf,
                memcpy(rbuf + num, "ATA     ", 8);
                num += 8;
                ata_id_string(args->id, (unsigned char *) rbuf + num,
-                             ATA_ID_PROD_OFS, ata_model_byte_len);
-               num += ata_model_byte_len;
+                             ATA_ID_PROD, ATA_ID_PROD_LEN);
+               num += ATA_ID_PROD_LEN;
                ata_id_string(args->id, (unsigned char *) rbuf + num,
-                             ATA_ID_SERNO_OFS, ATA_SERNO_LEN);
-               num += ATA_SERNO_LEN;
+                             ATA_ID_SERNO, ATA_ID_SERNO_LEN);
+               num += ATA_ID_SERNO_LEN;
        }
        rbuf[3] = num - 4;    /* page len (assume less than 256 bytes) */
        return 0;
@@ -1955,15 +1995,15 @@ static unsigned int ata_msense_rw_recovery(u8 **ptr_io, const u8 *last)
  */
 static int ata_dev_supports_fua(u16 *id)
 {
-       unsigned char model[41], fw[9];
+       unsigned char model[ATA_ID_PROD_LEN + 1], fw[ATA_ID_FW_REV_LEN + 1];
 
        if (!libata_fua)
                return 0;
        if (!ata_id_has_fua(id))
                return 0;
 
-       ata_id_c_string(id, model, ATA_ID_PROD_OFS, sizeof(model));
-       ata_id_c_string(id, fw, ATA_ID_FW_REV_OFS, sizeof(fw));
+       ata_id_c_string(id, model, ATA_ID_PROD, sizeof(model));
+       ata_id_c_string(id, fw, ATA_ID_FW_REV, sizeof(fw));
 
        if (strcmp(model, "Maxtor"))
                return 1;
@@ -2661,7 +2701,7 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc)
         * TODO: find out if we need to do more here to
         *       cover scatter/gather case.
         */
-       qc->nsect = scmd->request_bufflen / ATA_SECT_SIZE;
+       qc->nbytes = scmd->request_bufflen;
 
        /* request result TF */
        qc->flags |= ATA_QCFLAG_RESULT_TF;
@@ -3059,7 +3099,8 @@ void ata_scsi_hotplug(struct work_struct *work)
        for (i = 0; i < ATA_MAX_DEVICES; i++) {
                struct ata_device *dev = &ap->device[i];
                if (ata_dev_enabled(dev) && !dev->sdev) {
-                       queue_delayed_work(ata_aux_wq, &ap->hotplug_task, HZ);
+                       queue_delayed_work(ata_aux_wq, &ap->hotplug_task,
+                               round_jiffies_relative(HZ));
                        break;
                }
        }
@@ -3264,7 +3305,8 @@ EXPORT_SYMBOL_GPL(ata_sas_port_init);
 
 void ata_sas_port_destroy(struct ata_port *ap)
 {
-       ap->ops->port_stop(ap);
+       if (ap->ops->port_stop)
+               ap->ops->port_stop(ap);
        kfree(ap);
 }
 EXPORT_SYMBOL_GPL(ata_sas_port_destroy);
index 12c88c588039d4224b5c544cc8fcf55af11ead23..16bc3e35bdd4e196eae43be264a1e758dfcf84d9 100644 (file)
@@ -56,10 +56,7 @@ u8 ata_irq_on(struct ata_port *ap)
        ap->ctl &= ~ATA_NIEN;
        ap->last_ctl = ap->ctl;
 
-       if (ap->flags & ATA_FLAG_MMIO)
-               writeb(ap->ctl, (void __iomem *) ioaddr->ctl_addr);
-       else
-               outb(ap->ctl, ioaddr->ctl_addr);
+       iowrite8(ap->ctl, ioaddr->ctl_addr);
        tmp = ata_wait_idle(ap);
 
        ap->ops->irq_clear(ap);
@@ -67,92 +64,74 @@ u8 ata_irq_on(struct ata_port *ap)
        return tmp;
 }
 
+u8 ata_dummy_irq_on (struct ata_port *ap)      { return 0; }
+
 /**
- *     ata_tf_load_pio - send taskfile registers to host controller
- *     @ap: Port to which output is sent
- *     @tf: ATA taskfile register set
+ *     ata_irq_ack - Acknowledge a device interrupt.
+ *     @ap: Port on which interrupts are enabled.
  *
- *     Outputs ATA taskfile to standard ATA host controller.
+ *     Wait up to 10 ms for legacy IDE device to become idle (BUSY
+ *     or BUSY+DRQ clear).  Obtain dma status and port status from
+ *     device.  Clear the interrupt.  Return port status.
  *
  *     LOCKING:
- *     Inherited from caller.
  */
 
-static void ata_tf_load_pio(struct ata_port *ap, const struct ata_taskfile *tf)
+u8 ata_irq_ack(struct ata_port *ap, unsigned int chk_drq)
 {
-       struct ata_ioports *ioaddr = &ap->ioaddr;
-       unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR;
+       unsigned int bits = chk_drq ? ATA_BUSY | ATA_DRQ : ATA_BUSY;
+       u8 host_stat, post_stat, status;
 
-       if (tf->ctl != ap->last_ctl) {
-               outb(tf->ctl, ioaddr->ctl_addr);
-               ap->last_ctl = tf->ctl;
-               ata_wait_idle(ap);
-       }
+       status = ata_busy_wait(ap, bits, 1000);
+       if (status & bits)
+               if (ata_msg_err(ap))
+                       printk(KERN_ERR "abnormal status 0x%X\n", status);
 
-       if (is_addr && (tf->flags & ATA_TFLAG_LBA48)) {
-               outb(tf->hob_feature, ioaddr->feature_addr);
-               outb(tf->hob_nsect, ioaddr->nsect_addr);
-               outb(tf->hob_lbal, ioaddr->lbal_addr);
-               outb(tf->hob_lbam, ioaddr->lbam_addr);
-               outb(tf->hob_lbah, ioaddr->lbah_addr);
-               VPRINTK("hob: feat 0x%X nsect 0x%X, lba 0x%X 0x%X 0x%X\n",
-                       tf->hob_feature,
-                       tf->hob_nsect,
-                       tf->hob_lbal,
-                       tf->hob_lbam,
-                       tf->hob_lbah);
-       }
+       /* get controller status; clear intr, err bits */
+       host_stat = ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS);
+       iowrite8(host_stat | ATA_DMA_INTR | ATA_DMA_ERR,
+                ap->ioaddr.bmdma_addr + ATA_DMA_STATUS);
 
-       if (is_addr) {
-               outb(tf->feature, ioaddr->feature_addr);
-               outb(tf->nsect, ioaddr->nsect_addr);
-               outb(tf->lbal, ioaddr->lbal_addr);
-               outb(tf->lbam, ioaddr->lbam_addr);
-               outb(tf->lbah, ioaddr->lbah_addr);
-               VPRINTK("feat 0x%X nsect 0x%X lba 0x%X 0x%X 0x%X\n",
-                       tf->feature,
-                       tf->nsect,
-                       tf->lbal,
-                       tf->lbam,
-                       tf->lbah);
-       }
+       post_stat = ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS);
 
-       if (tf->flags & ATA_TFLAG_DEVICE) {
-               outb(tf->device, ioaddr->device_addr);
-               VPRINTK("device 0x%X\n", tf->device);
-       }
+       if (ata_msg_intr(ap))
+               printk(KERN_INFO "%s: irq ack: host_stat 0x%X, new host_stat 0x%X, drv_stat 0x%X\n",
+                       __FUNCTION__,
+                       host_stat, post_stat, status);
 
-       ata_wait_idle(ap);
+       return status;
 }
 
+u8 ata_dummy_irq_ack(struct ata_port *ap, unsigned int chk_drq) { return 0; }
+
 /**
- *     ata_tf_load_mmio - send taskfile registers to host controller
+ *     ata_tf_load - send taskfile registers to host controller
  *     @ap: Port to which output is sent
  *     @tf: ATA taskfile register set
  *
- *     Outputs ATA taskfile to standard ATA host controller using MMIO.
+ *     Outputs ATA taskfile to standard ATA host controller.
  *
  *     LOCKING:
  *     Inherited from caller.
  */
 
-static void ata_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf)
+void ata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf)
 {
        struct ata_ioports *ioaddr = &ap->ioaddr;
        unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR;
 
        if (tf->ctl != ap->last_ctl) {
-               writeb(tf->ctl, (void __iomem *) ap->ioaddr.ctl_addr);
+               iowrite8(tf->ctl, ioaddr->ctl_addr);
                ap->last_ctl = tf->ctl;
                ata_wait_idle(ap);
        }
 
        if (is_addr && (tf->flags & ATA_TFLAG_LBA48)) {
-               writeb(tf->hob_feature, (void __iomem *) ioaddr->feature_addr);
-               writeb(tf->hob_nsect, (void __iomem *) ioaddr->nsect_addr);
-               writeb(tf->hob_lbal, (void __iomem *) ioaddr->lbal_addr);
-               writeb(tf->hob_lbam, (void __iomem *) ioaddr->lbam_addr);
-               writeb(tf->hob_lbah, (void __iomem *) ioaddr->lbah_addr);
+               iowrite8(tf->hob_feature, ioaddr->feature_addr);
+               iowrite8(tf->hob_nsect, ioaddr->nsect_addr);
+               iowrite8(tf->hob_lbal, ioaddr->lbal_addr);
+               iowrite8(tf->hob_lbam, ioaddr->lbam_addr);
+               iowrite8(tf->hob_lbah, ioaddr->lbah_addr);
                VPRINTK("hob: feat 0x%X nsect 0x%X, lba 0x%X 0x%X 0x%X\n",
                        tf->hob_feature,
                        tf->hob_nsect,
@@ -162,11 +141,11 @@ static void ata_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf)
        }
 
        if (is_addr) {
-               writeb(tf->feature, (void __iomem *) ioaddr->feature_addr);
-               writeb(tf->nsect, (void __iomem *) ioaddr->nsect_addr);
-               writeb(tf->lbal, (void __iomem *) ioaddr->lbal_addr);
-               writeb(tf->lbam, (void __iomem *) ioaddr->lbam_addr);
-               writeb(tf->lbah, (void __iomem *) ioaddr->lbah_addr);
+               iowrite8(tf->feature, ioaddr->feature_addr);
+               iowrite8(tf->nsect, ioaddr->nsect_addr);
+               iowrite8(tf->lbal, ioaddr->lbal_addr);
+               iowrite8(tf->lbam, ioaddr->lbam_addr);
+               iowrite8(tf->lbah, ioaddr->lbah_addr);
                VPRINTK("feat 0x%X nsect 0x%X lba 0x%X 0x%X 0x%X\n",
                        tf->feature,
                        tf->nsect,
@@ -176,108 +155,34 @@ static void ata_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf)
        }
 
        if (tf->flags & ATA_TFLAG_DEVICE) {
-               writeb(tf->device, (void __iomem *) ioaddr->device_addr);
+               iowrite8(tf->device, ioaddr->device_addr);
                VPRINTK("device 0x%X\n", tf->device);
        }
 
        ata_wait_idle(ap);
 }
 
-
-/**
- *     ata_tf_load - send taskfile registers to host controller
- *     @ap: Port to which output is sent
- *     @tf: ATA taskfile register set
- *
- *     Outputs ATA taskfile to standard ATA host controller using MMIO
- *     or PIO as indicated by the ATA_FLAG_MMIO flag.
- *     Writes the control, feature, nsect, lbal, lbam, and lbah registers.
- *     Optionally (ATA_TFLAG_LBA48) writes hob_feature, hob_nsect,
- *     hob_lbal, hob_lbam, and hob_lbah.
- *
- *     This function waits for idle (!BUSY and !DRQ) after writing
- *     registers.  If the control register has a new value, this
- *     function also waits for idle after writing control and before
- *     writing the remaining registers.
- *
- *     May be used as the tf_load() entry in ata_port_operations.
- *
- *     LOCKING:
- *     Inherited from caller.
- */
-void ata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf)
-{
-       if (ap->flags & ATA_FLAG_MMIO)
-               ata_tf_load_mmio(ap, tf);
-       else
-               ata_tf_load_pio(ap, tf);
-}
-
 /**
- *     ata_exec_command_pio - issue ATA command to host controller
- *     @ap: port to which command is being issued
- *     @tf: ATA taskfile register set
- *
- *     Issues PIO write to ATA command register, with proper
- *     synchronization with interrupt handler / other threads.
- *
- *     LOCKING:
- *     spin_lock_irqsave(host lock)
- */
-
-static void ata_exec_command_pio(struct ata_port *ap, const struct ata_taskfile *tf)
-{
-       DPRINTK("ata%u: cmd 0x%X\n", ap->id, tf->command);
-
-               outb(tf->command, ap->ioaddr.command_addr);
-       ata_pause(ap);
-}
-
-
-/**
- *     ata_exec_command_mmio - issue ATA command to host controller
+ *     ata_exec_command - issue ATA command to host controller
  *     @ap: port to which command is being issued
  *     @tf: ATA taskfile register set
  *
- *     Issues MMIO write to ATA command register, with proper
- *     synchronization with interrupt handler / other threads.
- *
- *     FIXME: missing write posting for 400nS delay enforcement
+ *     Issues ATA command, with proper synchronization with interrupt
+ *     handler / other threads.
  *
  *     LOCKING:
  *     spin_lock_irqsave(host lock)
  */
-
-static void ata_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf)
+void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf)
 {
        DPRINTK("ata%u: cmd 0x%X\n", ap->id, tf->command);
 
-               writeb(tf->command, (void __iomem *) ap->ioaddr.command_addr);
+       iowrite8(tf->command, ap->ioaddr.command_addr);
        ata_pause(ap);
 }
 
-
-/**
- *     ata_exec_command - issue ATA command to host controller
- *     @ap: port to which command is being issued
- *     @tf: ATA taskfile register set
- *
- *     Issues PIO/MMIO write to ATA command register, with proper
- *     synchronization with interrupt handler / other threads.
- *
- *     LOCKING:
- *     spin_lock_irqsave(host lock)
- */
-void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf)
-{
-       if (ap->flags & ATA_FLAG_MMIO)
-               ata_exec_command_mmio(ap, tf);
-       else
-               ata_exec_command_pio(ap, tf);
-}
-
 /**
- *     ata_tf_read_pio - input device's ATA taskfile shadow registers
+ *     ata_tf_read - input device's ATA taskfile shadow registers
  *     @ap: Port from which input is read
  *     @tf: ATA taskfile register set for storing input
  *
@@ -287,121 +192,28 @@ void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf)
  *     LOCKING:
  *     Inherited from caller.
  */
-
-static void ata_tf_read_pio(struct ata_port *ap, struct ata_taskfile *tf)
-{
-       struct ata_ioports *ioaddr = &ap->ioaddr;
-
-       tf->command = ata_check_status(ap);
-       tf->feature = inb(ioaddr->error_addr);
-       tf->nsect = inb(ioaddr->nsect_addr);
-       tf->lbal = inb(ioaddr->lbal_addr);
-       tf->lbam = inb(ioaddr->lbam_addr);
-       tf->lbah = inb(ioaddr->lbah_addr);
-       tf->device = inb(ioaddr->device_addr);
-
-       if (tf->flags & ATA_TFLAG_LBA48) {
-               outb(tf->ctl | ATA_HOB, ioaddr->ctl_addr);
-               tf->hob_feature = inb(ioaddr->error_addr);
-               tf->hob_nsect = inb(ioaddr->nsect_addr);
-               tf->hob_lbal = inb(ioaddr->lbal_addr);
-               tf->hob_lbam = inb(ioaddr->lbam_addr);
-               tf->hob_lbah = inb(ioaddr->lbah_addr);
-       }
-}
-
-/**
- *     ata_tf_read_mmio - input device's ATA taskfile shadow registers
- *     @ap: Port from which input is read
- *     @tf: ATA taskfile register set for storing input
- *
- *     Reads ATA taskfile registers for currently-selected device
- *     into @tf via MMIO.
- *
- *     LOCKING:
- *     Inherited from caller.
- */
-
-static void ata_tf_read_mmio(struct ata_port *ap, struct ata_taskfile *tf)
+void ata_tf_read(struct ata_port *ap, struct ata_taskfile *tf)
 {
        struct ata_ioports *ioaddr = &ap->ioaddr;
 
        tf->command = ata_check_status(ap);
-       tf->feature = readb((void __iomem *)ioaddr->error_addr);
-       tf->nsect = readb((void __iomem *)ioaddr->nsect_addr);
-       tf->lbal = readb((void __iomem *)ioaddr->lbal_addr);
-       tf->lbam = readb((void __iomem *)ioaddr->lbam_addr);
-       tf->lbah = readb((void __iomem *)ioaddr->lbah_addr);
-       tf->device = readb((void __iomem *)ioaddr->device_addr);
+       tf->feature = ioread8(ioaddr->error_addr);
+       tf->nsect = ioread8(ioaddr->nsect_addr);
+       tf->lbal = ioread8(ioaddr->lbal_addr);
+       tf->lbam = ioread8(ioaddr->lbam_addr);
+       tf->lbah = ioread8(ioaddr->lbah_addr);
+       tf->device = ioread8(ioaddr->device_addr);
 
        if (tf->flags & ATA_TFLAG_LBA48) {
-               writeb(tf->ctl | ATA_HOB, (void __iomem *) ap->ioaddr.ctl_addr);
-               tf->hob_feature = readb((void __iomem *)ioaddr->error_addr);
-               tf->hob_nsect = readb((void __iomem *)ioaddr->nsect_addr);
-               tf->hob_lbal = readb((void __iomem *)ioaddr->lbal_addr);
-               tf->hob_lbam = readb((void __iomem *)ioaddr->lbam_addr);
-               tf->hob_lbah = readb((void __iomem *)ioaddr->lbah_addr);
+               iowrite8(tf->ctl | ATA_HOB, ioaddr->ctl_addr);
+               tf->hob_feature = ioread8(ioaddr->error_addr);
+               tf->hob_nsect = ioread8(ioaddr->nsect_addr);
+               tf->hob_lbal = ioread8(ioaddr->lbal_addr);
+               tf->hob_lbam = ioread8(ioaddr->lbam_addr);
+               tf->hob_lbah = ioread8(ioaddr->lbah_addr);
        }
 }
 
-
-/**
- *     ata_tf_read - input device's ATA taskfile shadow registers
- *     @ap: Port from which input is read
- *     @tf: ATA taskfile register set for storing input
- *
- *     Reads ATA taskfile registers for currently-selected device
- *     into @tf.
- *
- *     Reads nsect, lbal, lbam, lbah, and device.  If ATA_TFLAG_LBA48
- *     is set, also reads the hob registers.
- *
- *     May be used as the tf_read() entry in ata_port_operations.
- *
- *     LOCKING:
- *     Inherited from caller.
- */
-void ata_tf_read(struct ata_port *ap, struct ata_taskfile *tf)
-{
-       if (ap->flags & ATA_FLAG_MMIO)
-               ata_tf_read_mmio(ap, tf);
-       else
-               ata_tf_read_pio(ap, tf);
-}
-
-/**
- *     ata_check_status_pio - Read device status reg & clear interrupt
- *     @ap: port where the device is
- *
- *     Reads ATA taskfile status register for currently-selected device
- *     and return its value. This also clears pending interrupts
- *      from this device
- *
- *     LOCKING:
- *     Inherited from caller.
- */
-static u8 ata_check_status_pio(struct ata_port *ap)
-{
-       return inb(ap->ioaddr.status_addr);
-}
-
-/**
- *     ata_check_status_mmio - Read device status reg & clear interrupt
- *     @ap: port where the device is
- *
- *     Reads ATA taskfile status register for currently-selected device
- *     via MMIO and return its value. This also clears pending interrupts
- *      from this device
- *
- *     LOCKING:
- *     Inherited from caller.
- */
-static u8 ata_check_status_mmio(struct ata_port *ap)
-{
-               return readb((void __iomem *) ap->ioaddr.status_addr);
-}
-
-
 /**
  *     ata_check_status - Read device status reg & clear interrupt
  *     @ap: port where the device is
@@ -410,19 +222,14 @@ static u8 ata_check_status_mmio(struct ata_port *ap)
  *     and return its value. This also clears pending interrupts
  *      from this device
  *
- *     May be used as the check_status() entry in ata_port_operations.
- *
  *     LOCKING:
  *     Inherited from caller.
  */
 u8 ata_check_status(struct ata_port *ap)
 {
-       if (ap->flags & ATA_FLAG_MMIO)
-               return ata_check_status_mmio(ap);
-       return ata_check_status_pio(ap);
+       return ioread8(ap->ioaddr.status_addr);
 }
 
-
 /**
  *     ata_altstatus - Read device alternate status reg
  *     @ap: port where the device is
@@ -441,58 +248,52 @@ u8 ata_altstatus(struct ata_port *ap)
        if (ap->ops->check_altstatus)
                return ap->ops->check_altstatus(ap);
 
-       if (ap->flags & ATA_FLAG_MMIO)
-               return readb((void __iomem *)ap->ioaddr.altstatus_addr);
-       return inb(ap->ioaddr.altstatus_addr);
+       return ioread8(ap->ioaddr.altstatus_addr);
 }
 
 /**
- *     ata_bmdma_setup_mmio - Set up PCI IDE BMDMA transaction
+ *     ata_bmdma_setup - Set up PCI IDE BMDMA transaction
  *     @qc: Info associated with this ATA transaction.
  *
  *     LOCKING:
  *     spin_lock_irqsave(host lock)
  */
-
-static void ata_bmdma_setup_mmio (struct ata_queued_cmd *qc)
+void ata_bmdma_setup(struct ata_queued_cmd *qc)
 {
        struct ata_port *ap = qc->ap;
        unsigned int rw = (qc->tf.flags & ATA_TFLAG_WRITE);
        u8 dmactl;
-       void __iomem *mmio = (void __iomem *) ap->ioaddr.bmdma_addr;
 
        /* load PRD table addr. */
        mb();   /* make sure PRD table writes are visible to controller */
-       writel(ap->prd_dma, mmio + ATA_DMA_TABLE_OFS);
+       iowrite32(ap->prd_dma, ap->ioaddr.bmdma_addr + ATA_DMA_TABLE_OFS);
 
        /* specify data direction, triple-check start bit is clear */
-       dmactl = readb(mmio + ATA_DMA_CMD);
+       dmactl = ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
        dmactl &= ~(ATA_DMA_WR | ATA_DMA_START);
        if (!rw)
                dmactl |= ATA_DMA_WR;
-       writeb(dmactl, mmio + ATA_DMA_CMD);
+       iowrite8(dmactl, ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
 
        /* issue r/w command */
        ap->ops->exec_command(ap, &qc->tf);
 }
 
 /**
- *     ata_bmdma_start_mmio - Start a PCI IDE BMDMA transaction
+ *     ata_bmdma_start - Start a PCI IDE BMDMA transaction
  *     @qc: Info associated with this ATA transaction.
  *
  *     LOCKING:
  *     spin_lock_irqsave(host lock)
  */
-
-static void ata_bmdma_start_mmio (struct ata_queued_cmd *qc)
+void ata_bmdma_start (struct ata_queued_cmd *qc)
 {
        struct ata_port *ap = qc->ap;
-       void __iomem *mmio = (void __iomem *) ap->ioaddr.bmdma_addr;
        u8 dmactl;
 
        /* start host DMA transaction */
-       dmactl = readb(mmio + ATA_DMA_CMD);
-       writeb(dmactl | ATA_DMA_START, mmio + ATA_DMA_CMD);
+       dmactl = ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
+       iowrite8(dmactl | ATA_DMA_START, ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
 
        /* Strictly, one may wish to issue a readb() here, to
         * flush the mmio write.  However, control also passes
@@ -507,96 +308,6 @@ static void ata_bmdma_start_mmio (struct ata_queued_cmd *qc)
         */
 }
 
-/**
- *     ata_bmdma_setup_pio - Set up PCI IDE BMDMA transaction (PIO)
- *     @qc: Info associated with this ATA transaction.
- *
- *     LOCKING:
- *     spin_lock_irqsave(host lock)
- */
-
-static void ata_bmdma_setup_pio (struct ata_queued_cmd *qc)
-{
-       struct ata_port *ap = qc->ap;
-       unsigned int rw = (qc->tf.flags & ATA_TFLAG_WRITE);
-       u8 dmactl;
-
-       /* load PRD table addr. */
-       outl(ap->prd_dma, ap->ioaddr.bmdma_addr + ATA_DMA_TABLE_OFS);
-
-       /* specify data direction, triple-check start bit is clear */
-       dmactl = inb(ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
-       dmactl &= ~(ATA_DMA_WR | ATA_DMA_START);
-       if (!rw)
-               dmactl |= ATA_DMA_WR;
-       outb(dmactl, ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
-
-       /* issue r/w command */
-       ap->ops->exec_command(ap, &qc->tf);
-}
-
-/**
- *     ata_bmdma_start_pio - Start a PCI IDE BMDMA transaction (PIO)
- *     @qc: Info associated with this ATA transaction.
- *
- *     LOCKING:
- *     spin_lock_irqsave(host lock)
- */
-
-static void ata_bmdma_start_pio (struct ata_queued_cmd *qc)
-{
-       struct ata_port *ap = qc->ap;
-       u8 dmactl;
-
-       /* start host DMA transaction */
-       dmactl = inb(ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
-       outb(dmactl | ATA_DMA_START,
-            ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
-}
-
-
-/**
- *     ata_bmdma_start - Start a PCI IDE BMDMA transaction
- *     @qc: Info associated with this ATA transaction.
- *
- *     Writes the ATA_DMA_START flag to the DMA command register.
- *
- *     May be used as the bmdma_start() entry in ata_port_operations.
- *
- *     LOCKING:
- *     spin_lock_irqsave(host lock)
- */
-void ata_bmdma_start(struct ata_queued_cmd *qc)
-{
-       if (qc->ap->flags & ATA_FLAG_MMIO)
-               ata_bmdma_start_mmio(qc);
-       else
-               ata_bmdma_start_pio(qc);
-}
-
-
-/**
- *     ata_bmdma_setup - Set up PCI IDE BMDMA transaction
- *     @qc: Info associated with this ATA transaction.
- *
- *     Writes address of PRD table to device's PRD Table Address
- *     register, sets the DMA control register, and calls
- *     ops->exec_command() to start the transfer.
- *
- *     May be used as the bmdma_setup() entry in ata_port_operations.
- *
- *     LOCKING:
- *     spin_lock_irqsave(host lock)
- */
-void ata_bmdma_setup(struct ata_queued_cmd *qc)
-{
-       if (qc->ap->flags & ATA_FLAG_MMIO)
-               ata_bmdma_setup_mmio(qc);
-       else
-               ata_bmdma_setup_pio(qc);
-}
-
-
 /**
  *     ata_bmdma_irq_clear - Clear PCI IDE BMDMA interrupt.
  *     @ap: Port associated with this ATA transaction.
@@ -608,23 +319,16 @@ void ata_bmdma_setup(struct ata_queued_cmd *qc)
  *     LOCKING:
  *     spin_lock_irqsave(host lock)
  */
-
 void ata_bmdma_irq_clear(struct ata_port *ap)
 {
-       if (!ap->ioaddr.bmdma_addr)
+       void __iomem *mmio = ap->ioaddr.bmdma_addr;
+
+       if (!mmio)
                return;
 
-       if (ap->flags & ATA_FLAG_MMIO) {
-               void __iomem *mmio =
-                     ((void __iomem *) ap->ioaddr.bmdma_addr) + ATA_DMA_STATUS;
-               writeb(readb(mmio), mmio);
-       } else {
-               unsigned long addr = ap->ioaddr.bmdma_addr + ATA_DMA_STATUS;
-               outb(inb(addr), addr);
-       }
+       iowrite8(ioread8(mmio + ATA_DMA_STATUS), mmio + ATA_DMA_STATUS);
 }
 
-
 /**
  *     ata_bmdma_status - Read PCI IDE BMDMA status
  *     @ap: Port associated with this ATA transaction.
@@ -636,19 +340,11 @@ void ata_bmdma_irq_clear(struct ata_port *ap)
  *     LOCKING:
  *     spin_lock_irqsave(host lock)
  */
-
 u8 ata_bmdma_status(struct ata_port *ap)
 {
-       u8 host_stat;
-       if (ap->flags & ATA_FLAG_MMIO) {
-               void __iomem *mmio = (void __iomem *) ap->ioaddr.bmdma_addr;
-               host_stat = readb(mmio + ATA_DMA_STATUS);
-       } else
-               host_stat = inb(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS);
-       return host_stat;
+       return ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS);
 }
 
-
 /**
  *     ata_bmdma_stop - Stop PCI IDE BMDMA transfer
  *     @qc: Command we are ending DMA for
@@ -660,21 +356,14 @@ u8 ata_bmdma_status(struct ata_port *ap)
  *     LOCKING:
  *     spin_lock_irqsave(host lock)
  */
-
 void ata_bmdma_stop(struct ata_queued_cmd *qc)
 {
        struct ata_port *ap = qc->ap;
-       if (ap->flags & ATA_FLAG_MMIO) {
-               void __iomem *mmio = (void __iomem *) ap->ioaddr.bmdma_addr;
+       void __iomem *mmio = ap->ioaddr.bmdma_addr;
 
-               /* clear start/stop bit */
-               writeb(readb(mmio + ATA_DMA_CMD) & ~ATA_DMA_START,
-                       mmio + ATA_DMA_CMD);
-       } else {
-               /* clear start/stop bit */
-               outb(inb(ap->ioaddr.bmdma_addr + ATA_DMA_CMD) & ~ATA_DMA_START,
-                       ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
-       }
+       /* clear start/stop bit */
+       iowrite8(ioread8(mmio + ATA_DMA_CMD) & ~ATA_DMA_START,
+                mmio + ATA_DMA_CMD);
 
        /* one-PIO-cycle guaranteed wait, per spec, for HDMA1:0 transition */
        ata_altstatus(ap);        /* dummy read */
@@ -696,10 +385,7 @@ void ata_bmdma_freeze(struct ata_port *ap)
        ap->ctl |= ATA_NIEN;
        ap->last_ctl = ap->ctl;
 
-       if (ap->flags & ATA_FLAG_MMIO)
-               writeb(ap->ctl, (void __iomem *)ioaddr->ctl_addr);
-       else
-               outb(ap->ctl, ioaddr->ctl_addr);
+       iowrite8(ap->ctl, ioaddr->ctl_addr);
 
        /* Under certain circumstances, some controllers raise IRQ on
         * ATA_NIEN manipulation.  Also, many controllers fail to mask
@@ -724,8 +410,7 @@ void ata_bmdma_thaw(struct ata_port *ap)
        /* clear & re-enable interrupts */
        ata_chk_status(ap);
        ap->ops->irq_clear(ap);
-       if (ap->ioaddr.ctl_addr)        /* FIXME: hack. create a hook instead */
-               ata_irq_on(ap);
+       ap->ops->irq_on(ap);
 }
 
 /**
@@ -775,7 +460,7 @@ void ata_bmdma_drive_eh(struct ata_port *ap, ata_prereset_fn_t prereset,
                 * really a timeout event, adjust error mask and
                 * cancel frozen state.
                 */
-               if (qc->err_mask == AC_ERR_TIMEOUT && host_stat & ATA_DMA_ERR) {
+               if (qc->err_mask == AC_ERR_TIMEOUT && (host_stat & ATA_DMA_ERR)) {
                        qc->err_mask = AC_ERR_HOST_BUS;
                        thaw = 1;
                }
@@ -832,6 +517,21 @@ void ata_bmdma_post_internal_cmd(struct ata_queued_cmd *qc)
 }
 
 #ifdef CONFIG_PCI
+
+static int ata_resources_present(struct pci_dev *pdev, int port)
+{
+       int i;
+       
+       /* Check the PCI resources for this channel are enabled */
+       port = port * 2;
+       for (i = 0; i < 2; i ++) {
+               if (pci_resource_start(pdev, port + i) == 0 ||
+                       pci_resource_len(pdev, port + i) == 0)
+               return 0;
+       }
+       return 1;
+}
+               
 /**
  *     ata_pci_init_native_mode - Initialize native-mode driver
  *     @pdev:  pci device to be initialized
@@ -853,45 +553,62 @@ void ata_bmdma_post_internal_cmd(struct ata_queued_cmd *qc)
 struct ata_probe_ent *
 ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int ports)
 {
-       struct ata_probe_ent *probe_ent =
-               ata_probe_ent_alloc(pci_dev_to_dev(pdev), port[0]);
-       int p = 0;
-       unsigned long bmdma;
+       struct ata_probe_ent *probe_ent;
+       int i, p = 0;
+       void __iomem * const *iomap;
+
+       /* iomap BARs */
+       for (i = 0; i < 4; i++) {
+               if (pcim_iomap(pdev, i, 0) == NULL) {
+                       dev_printk(KERN_ERR, &pdev->dev,
+                                  "failed to iomap PCI BAR %d\n", i);
+                       return NULL;
+               }
+       }
 
+       pcim_iomap(pdev, 4, 0); /* may fail */
+       iomap = pcim_iomap_table(pdev);
+
+       /* alloc and init probe_ent */
+       probe_ent = ata_probe_ent_alloc(pci_dev_to_dev(pdev), port[0]);
        if (!probe_ent)
                return NULL;
 
        probe_ent->irq = pdev->irq;
        probe_ent->irq_flags = IRQF_SHARED;
+       
+       /* Discard disabled ports. Some controllers show their
+          unused channels this way */
+       if (ata_resources_present(pdev, 0) == 0)
+               ports &= ~ATA_PORT_PRIMARY;
+       if (ata_resources_present(pdev, 1) == 0)
+               ports &= ~ATA_PORT_SECONDARY;
 
        if (ports & ATA_PORT_PRIMARY) {
-               probe_ent->port[p].cmd_addr = pci_resource_start(pdev, 0);
+               probe_ent->port[p].cmd_addr = iomap[0];
                probe_ent->port[p].altstatus_addr =
-               probe_ent->port[p].ctl_addr =
-                       pci_resource_start(pdev, 1) | ATA_PCI_CTL_OFS;
-               bmdma = pci_resource_start(pdev, 4);
-               if (bmdma) {
+               probe_ent->port[p].ctl_addr = (void __iomem *)
+                       ((unsigned long)iomap[1] | ATA_PCI_CTL_OFS);
+               if (iomap[4]) {
                        if ((!(port[p]->flags & ATA_FLAG_IGN_SIMPLEX)) &&
-                           (inb(bmdma + 2) & 0x80))
+                           (ioread8(iomap[4] + 2) & 0x80))
                                probe_ent->_host_flags |= ATA_HOST_SIMPLEX;
-                       probe_ent->port[p].bmdma_addr = bmdma;
+                       probe_ent->port[p].bmdma_addr = iomap[4];
                }
                ata_std_ports(&probe_ent->port[p]);
                p++;
        }
 
        if (ports & ATA_PORT_SECONDARY) {
-               probe_ent->port[p].cmd_addr = pci_resource_start(pdev, 2);
+               probe_ent->port[p].cmd_addr = iomap[2];
                probe_ent->port[p].altstatus_addr =
-               probe_ent->port[p].ctl_addr =
-                       pci_resource_start(pdev, 3) | ATA_PCI_CTL_OFS;
-               bmdma = pci_resource_start(pdev, 4);
-               if (bmdma) {
-                       bmdma += 8;
+               probe_ent->port[p].ctl_addr = (void __iomem *)
+                       ((unsigned long)iomap[3] | ATA_PCI_CTL_OFS);
+               if (iomap[4]) {
                        if ((!(port[p]->flags & ATA_FLAG_IGN_SIMPLEX)) &&
-                           (inb(bmdma + 2) & 0x80))
+                           (ioread8(iomap[4] + 10) & 0x80))
                                probe_ent->_host_flags |= ATA_HOST_SIMPLEX;
-                       probe_ent->port[p].bmdma_addr = bmdma;
+                       probe_ent->port[p].bmdma_addr = iomap[4] + 8;
                }
                ata_std_ports(&probe_ent->port[p]);
                probe_ent->pinfo2 = port[1];
@@ -902,13 +619,29 @@ ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int
        return probe_ent;
 }
 
-
 static struct ata_probe_ent *ata_pci_init_legacy_port(struct pci_dev *pdev,
                                struct ata_port_info **port, int port_mask)
 {
        struct ata_probe_ent *probe_ent;
-       unsigned long bmdma = pci_resource_start(pdev, 4);
+       void __iomem *iomap[5] = { }, *bmdma;
+
+       if (port_mask & ATA_PORT_PRIMARY) {
+               iomap[0] = devm_ioport_map(&pdev->dev, ATA_PRIMARY_CMD, 8);
+               iomap[1] = devm_ioport_map(&pdev->dev, ATA_PRIMARY_CTL, 1);
+               if (!iomap[0] || !iomap[1])
+                       return NULL;
+       }
+
+       if (port_mask & ATA_PORT_SECONDARY) {
+               iomap[2] = devm_ioport_map(&pdev->dev, ATA_SECONDARY_CMD, 8);
+               iomap[3] = devm_ioport_map(&pdev->dev, ATA_SECONDARY_CTL, 1);
+               if (!iomap[2] || !iomap[3])
+                       return NULL;
+       }
 
+       bmdma = pcim_iomap(pdev, 4, 16); /* may fail */
+
+       /* alloc and init probe_ent */
        probe_ent = ata_probe_ent_alloc(pci_dev_to_dev(pdev), port[0]);
        if (!probe_ent)
                return NULL;
@@ -918,13 +651,13 @@ static struct ata_probe_ent *ata_pci_init_legacy_port(struct pci_dev *pdev,
 
        if (port_mask & ATA_PORT_PRIMARY) {
                probe_ent->irq = ATA_PRIMARY_IRQ(pdev);
-               probe_ent->port[0].cmd_addr = ATA_PRIMARY_CMD;
+               probe_ent->port[0].cmd_addr = iomap[0];
                probe_ent->port[0].altstatus_addr =
-               probe_ent->port[0].ctl_addr = ATA_PRIMARY_CTL;
+               probe_ent->port[0].ctl_addr = iomap[1];
                if (bmdma) {
                        probe_ent->port[0].bmdma_addr = bmdma;
                        if ((!(port[0]->flags & ATA_FLAG_IGN_SIMPLEX)) &&
-                           (inb(bmdma + 2) & 0x80))
+                           (ioread8(bmdma + 2) & 0x80))
                                probe_ent->_host_flags |= ATA_HOST_SIMPLEX;
                }
                ata_std_ports(&probe_ent->port[0]);
@@ -936,13 +669,13 @@ static struct ata_probe_ent *ata_pci_init_legacy_port(struct pci_dev *pdev,
                        probe_ent->irq2 = ATA_SECONDARY_IRQ(pdev);
                else
                        probe_ent->irq = ATA_SECONDARY_IRQ(pdev);
-               probe_ent->port[1].cmd_addr = ATA_SECONDARY_CMD;
+               probe_ent->port[1].cmd_addr = iomap[2];
                probe_ent->port[1].altstatus_addr =
-               probe_ent->port[1].ctl_addr = ATA_SECONDARY_CTL;
+               probe_ent->port[1].ctl_addr = iomap[3];
                if (bmdma) {
                        probe_ent->port[1].bmdma_addr = bmdma + 8;
                        if ((!(port[1]->flags & ATA_FLAG_IGN_SIMPLEX)) &&
-                           (inb(bmdma + 10) & 0x80))
+                           (ioread8(bmdma + 10) & 0x80))
                                probe_ent->_host_flags |= ATA_HOST_SIMPLEX;
                }
                ata_std_ports(&probe_ent->port[1]);
@@ -984,15 +717,18 @@ static struct ata_probe_ent *ata_pci_init_legacy_port(struct pci_dev *pdev,
 int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
                      unsigned int n_ports)
 {
+       struct device *dev = &pdev->dev;
        struct ata_probe_ent *probe_ent = NULL;
        struct ata_port_info *port[2];
        u8 mask;
        unsigned int legacy_mode = 0;
-       int disable_dev_on_err = 1;
        int rc;
 
        DPRINTK("ENTER\n");
 
+       if (!devres_open_group(dev, NULL, GFP_KERNEL))
+               return -ENOMEM;
+
        BUG_ON(n_ports < 1 || n_ports > 2);
 
        port[0] = port_info[0];
@@ -1009,9 +745,9 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
           boot for the primary video which is BIOS enabled
          */
 
-       rc = pci_enable_device(pdev);
+       rc = pcim_enable_device(pdev);
        if (rc)
-               return rc;
+               goto err_out;
 
        if ((pdev->class >> 8) == PCI_CLASS_STORAGE_IDE) {
                u8 tmp8;
@@ -1027,7 +763,8 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
                   left a device in compatibility mode */
                if (legacy_mode) {
                        printk(KERN_ERR "ata: Compatibility mode ATA is not supported on this platform, skipping.\n");
-                       return -EOPNOTSUPP;
+                       rc = -EOPNOTSUPP;
+                       goto err_out;
                }
 #endif
        }
@@ -1035,13 +772,13 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
        if (!legacy_mode) {
                rc = pci_request_regions(pdev, DRV_NAME);
                if (rc) {
-                       disable_dev_on_err = 0;
+                       pcim_pin_device(pdev);
                        goto err_out;
                }
        } else {
                /* Deal with combined mode hack. This side of the logic all
                   goes away once the combined mode hack is killed in 2.6.21 */
-               if (!request_region(ATA_PRIMARY_CMD, 8, "libata")) {
+               if (!devm_request_region(dev, ATA_PRIMARY_CMD, 8, "libata")) {
                        struct resource *conflict, res;
                        res.start = ATA_PRIMARY_CMD;
                        res.end = ATA_PRIMARY_CMD + 8 - 1;
@@ -1051,7 +788,7 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
                        if (!strcmp(conflict->name, "libata"))
                                legacy_mode |= ATA_PORT_PRIMARY;
                        else {
-                               disable_dev_on_err = 0;
+                               pcim_pin_device(pdev);
                                printk(KERN_WARNING "ata: 0x%0X IDE port busy\n" \
                                                    "ata: conflict with %s\n",
                                                    ATA_PRIMARY_CMD,
@@ -1060,7 +797,7 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
                } else
                        legacy_mode |= ATA_PORT_PRIMARY;
 
-               if (!request_region(ATA_SECONDARY_CMD, 8, "libata")) {
+               if (!devm_request_region(dev, ATA_SECONDARY_CMD, 8, "libata")) {
                        struct resource *conflict, res;
                        res.start = ATA_SECONDARY_CMD;
                        res.end = ATA_SECONDARY_CMD + 8 - 1;
@@ -1070,7 +807,7 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
                        if (!strcmp(conflict->name, "libata"))
                                legacy_mode |= ATA_PORT_SECONDARY;
                        else {
-                               disable_dev_on_err = 0;
+                               pcim_pin_device(pdev);
                                printk(KERN_WARNING "ata: 0x%X IDE port busy\n" \
                                                    "ata: conflict with %s\n",
                                                    ATA_SECONDARY_CMD,
@@ -1090,16 +827,16 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
        /* we have legacy mode, but all ports are unavailable */
        if (legacy_mode == (1 << 3)) {
                rc = -EBUSY;
-               goto err_out_regions;
+               goto err_out;
        }
 
        /* TODO: If we get no DMA mask we should fall back to PIO */
        rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
        if (rc)
-               goto err_out_regions;
+               goto err_out;
        rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK);
        if (rc)
-               goto err_out_regions;
+               goto err_out;
 
        if (legacy_mode) {
                probe_ent = ata_pci_init_legacy_port(pdev, port, legacy_mode);
@@ -1111,40 +848,22 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
        }
        if (!probe_ent) {
                rc = -ENOMEM;
-               goto err_out_regions;
+               goto err_out;
        }
 
        pci_set_master(pdev);
 
        if (!ata_device_add(probe_ent)) {
                rc = -ENODEV;
-               goto err_out_ent;
+               goto err_out;
        }
 
-       kfree(probe_ent);
-
+       devm_kfree(dev, probe_ent);
+       devres_remove_group(dev, NULL);
        return 0;
 
-err_out_ent:
-       kfree(probe_ent);
-err_out_regions:
-       /* All this conditional stuff is needed for the combined mode hack
-          until 2.6.21 when it can go */
-       if (legacy_mode) {
-               pci_release_region(pdev, 4);
-               if (legacy_mode & ATA_PORT_PRIMARY) {
-                       release_region(ATA_PRIMARY_CMD, 8);
-                       pci_release_region(pdev, 1);
-               }
-               if (legacy_mode & ATA_PORT_SECONDARY) {
-                       release_region(ATA_SECONDARY_CMD, 8);
-                       pci_release_region(pdev, 3);
-               }
-       } else
-               pci_release_regions(pdev);
 err_out:
-       if (disable_dev_on_err)
-               pci_disable_device(pdev);
+       devres_release_group(dev, NULL);
        return rc;
 }
 
index 81ae41d5f23f04a4447c7b40bf7d347d5ef2b30c..06ccf230e3c2b97308879b87ef93b98d504902b4 100644 (file)
@@ -29,7 +29,6 @@
 #define __LIBATA_H__
 
 #define DRV_NAME       "libata"
-#define DRV_VERSION    "2.00"  /* must be exactly four chars */
 
 struct ata_scsi_args {
        struct ata_device       *dev;
@@ -136,4 +135,7 @@ extern void ata_qc_schedule_eh(struct ata_queued_cmd *qc);
 /* libata-sff.c */
 extern u8 ata_irq_on(struct ata_port *ap);
 
+/* pata_sis.c */
+extern struct ata_port_info sis_info133;
+
 #endif /* __LIBATA_H__ */
index c5d61d1911a53624ee50dfe145357c7ff5514dd8..ab44d18850f6eed706b0576624c8d92359ef13e0 100644 (file)
@@ -153,11 +153,11 @@ static void ali_early_error_handler(struct ata_port *ap)
 
 static unsigned long ali_20_filter(const struct ata_port *ap, struct ata_device *adev, unsigned long mask)
 {
-       char model_num[40];
+       char model_num[ATA_ID_PROD_LEN + 1];
        /* No DMA on anything but a disk for now */
        if (adev->class != ATA_DEV_ATA)
                mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA);
-       ata_id_string(adev->id, model_num, ATA_ID_PROD_OFS, sizeof(model_num));
+       ata_id_c_string(adev->id, model_num, ATA_ID_PROD, sizeof(model_num));
        if (strstr(model_num, "WDC"))
                return mask &= ~ATA_MASK_UDMA;
        return ata_pci_default_filter(ap, adev, mask);
@@ -370,14 +370,14 @@ static struct ata_port_operations ali_early_port_ops = {
        .qc_prep        = ata_qc_prep,
        .qc_issue       = ata_qc_issue_prot,
 
-       .data_xfer      = ata_pio_data_xfer,
+       .data_xfer      = ata_data_xfer,
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 /*
@@ -411,14 +411,14 @@ static struct ata_port_operations ali_20_port_ops = {
        .qc_prep        = ata_qc_prep,
        .qc_issue       = ata_qc_issue_prot,
 
-       .data_xfer      = ata_pio_data_xfer,
+       .data_xfer      = ata_data_xfer,
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 /*
@@ -449,14 +449,14 @@ static struct ata_port_operations ali_c2_port_ops = {
        .qc_prep        = ata_qc_prep,
        .qc_issue       = ata_qc_issue_prot,
 
-       .data_xfer      = ata_pio_data_xfer,
+       .data_xfer      = ata_data_xfer,
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 /*
@@ -486,14 +486,14 @@ static struct ata_port_operations ali_c5_port_ops = {
        .qc_prep        = ata_qc_prep,
        .qc_issue       = ata_qc_issue_prot,
 
-       .data_xfer      = ata_pio_data_xfer,
+       .data_xfer      = ata_data_xfer,
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 
@@ -504,7 +504,7 @@ static struct ata_port_operations ali_c5_port_ops = {
  *     Perform the setup on the device that must be done both at boot
  *     and at resume time.
  */
+
 static void ali_init_chipset(struct pci_dev *pdev)
 {
        u8 rev, tmp;
@@ -655,7 +655,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
                port_info[0] = port_info[1] = &info_c5;
 
        ali_init_chipset(pdev);
-       
+
        isa_bridge = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, NULL);
        if (isa_bridge && rev >= 0x20 && rev < 0xC2) {
                /* Are we paired with a UDMA capable chip */
index a6b330089f227f0fe62204f001b23cb3c97fef87..619e44b04032ea0bada67d42ff73b81b81fb6893 100644 (file)
@@ -362,14 +362,14 @@ static struct ata_port_operations amd33_port_ops = {
        .qc_prep        = ata_qc_prep,
        .qc_issue       = ata_qc_issue_prot,
 
-       .data_xfer      = ata_pio_data_xfer,
+       .data_xfer      = ata_data_xfer,
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 static struct ata_port_operations amd66_port_ops = {
@@ -396,14 +396,14 @@ static struct ata_port_operations amd66_port_ops = {
        .qc_prep        = ata_qc_prep,
        .qc_issue       = ata_qc_issue_prot,
 
-       .data_xfer      = ata_pio_data_xfer,
+       .data_xfer      = ata_data_xfer,
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 static struct ata_port_operations amd100_port_ops = {
@@ -430,14 +430,14 @@ static struct ata_port_operations amd100_port_ops = {
        .qc_prep        = ata_qc_prep,
        .qc_issue       = ata_qc_issue_prot,
 
-       .data_xfer      = ata_pio_data_xfer,
+       .data_xfer      = ata_data_xfer,
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 static struct ata_port_operations amd133_port_ops = {
@@ -464,14 +464,14 @@ static struct ata_port_operations amd133_port_ops = {
        .qc_prep        = ata_qc_prep,
        .qc_issue       = ata_qc_issue_prot,
 
-       .data_xfer      = ata_pio_data_xfer,
+       .data_xfer      = ata_data_xfer,
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 static struct ata_port_operations nv100_port_ops = {
@@ -498,14 +498,14 @@ static struct ata_port_operations nv100_port_ops = {
        .qc_prep        = ata_qc_prep,
        .qc_issue       = ata_qc_issue_prot,
 
-       .data_xfer      = ata_pio_data_xfer,
+       .data_xfer      = ata_data_xfer,
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 static struct ata_port_operations nv133_port_ops = {
@@ -532,14 +532,14 @@ static struct ata_port_operations nv133_port_ops = {
        .qc_prep        = ata_qc_prep,
        .qc_issue       = ata_qc_issue_prot,
 
-       .data_xfer      = ata_pio_data_xfer,
+       .data_xfer      = ata_data_xfer,
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 static int amd_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
index 37bc1323bda7aad0aff65f3aa7b95cc8fb889069..21c30282717ccafea9a541f9173552467bec932a 100644 (file)
@@ -341,14 +341,14 @@ static const struct ata_port_operations artop6210_ops = {
        .qc_prep                = ata_qc_prep,
        .qc_issue               = ata_qc_issue_prot,
 
-       .data_xfer              = ata_pio_data_xfer,
+       .data_xfer              = ata_data_xfer,
 
        .irq_handler            = ata_interrupt,
        .irq_clear              = ata_bmdma_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
 
        .port_start             = ata_port_start,
-       .port_stop              = ata_port_stop,
-       .host_stop              = ata_host_stop,
 };
 
 static const struct ata_port_operations artop6260_ops = {
@@ -373,14 +373,14 @@ static const struct ata_port_operations artop6260_ops = {
        .bmdma_status           = ata_bmdma_status,
        .qc_prep                = ata_qc_prep,
        .qc_issue               = ata_qc_issue_prot,
-       .data_xfer              = ata_pio_data_xfer,
+       .data_xfer              = ata_data_xfer,
 
        .irq_handler            = ata_interrupt,
        .irq_clear              = ata_bmdma_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
 
        .port_start             = ata_port_start,
-       .port_stop              = ata_port_stop,
-       .host_stop              = ata_host_stop,
 };
 
 
index 504e1dbfffd7d9d6581fe4432c8e266bcd70730e..c3eb40c91c80435c0fefda38c4159cd7eebec136 100644 (file)
@@ -252,14 +252,14 @@ static struct ata_port_operations atiixp_port_ops = {
        .qc_prep        = ata_qc_prep,
        .qc_issue       = ata_qc_issue_prot,
 
-       .data_xfer      = ata_pio_data_xfer,
+       .data_xfer      = ata_data_xfer,
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 static int atiixp_init_one(struct pci_dev *dev, const struct pci_device_id *id)
index 449162cbf93ef13477bbecaff90e23fdbf8df585..da098282b5f6ddab91d7bb358324a1613bf02bcd 100644 (file)
@@ -313,14 +313,14 @@ static struct ata_port_operations cmd64x_port_ops = {
        .qc_prep        = ata_qc_prep,
        .qc_issue       = ata_qc_issue_prot,
 
-       .data_xfer      = ata_pio_data_xfer,
+       .data_xfer      = ata_data_xfer,
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 static struct ata_port_operations cmd646r1_port_ops = {
@@ -347,14 +347,14 @@ static struct ata_port_operations cmd646r1_port_ops = {
        .qc_prep        = ata_qc_prep,
        .qc_issue       = ata_qc_issue_prot,
 
-       .data_xfer      = ata_pio_data_xfer,
+       .data_xfer      = ata_data_xfer,
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 static struct ata_port_operations cmd648_port_ops = {
@@ -381,14 +381,14 @@ static struct ata_port_operations cmd648_port_ops = {
        .qc_prep        = ata_qc_prep,
        .qc_issue       = ata_qc_issue_prot,
 
-       .data_xfer      = ata_pio_data_xfer,
+       .data_xfer      = ata_data_xfer,
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 static int cmd64x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
index 9f165a8e032d4dca1df88447d9b56935f36a32d0..1ce8fcfd7826e08c32c90c130125c6013c7cb895 100644 (file)
@@ -99,9 +99,9 @@ static void cs5520_set_timings(struct ata_port *ap, struct ata_device *adev, int
 static void cs5520_enable_dma(struct ata_port *ap, struct ata_device *adev)
 {
        /* Set the DMA enable/disable flag */
-       u8 reg = inb(ap->ioaddr.bmdma_addr + 0x02);
+       u8 reg = ioread8(ap->ioaddr.bmdma_addr + 0x02);
        reg |= 1<<(adev->devno + 5);
-       outb(reg, ap->ioaddr.bmdma_addr + 0x02);
+       iowrite8(reg, ap->ioaddr.bmdma_addr + 0x02);
 }
 
 /**
@@ -193,19 +193,20 @@ static struct ata_port_operations cs5520_port_ops = {
        .bmdma_status           = ata_bmdma_status,
        .qc_prep                = ata_qc_prep,
        .qc_issue               = ata_qc_issue_prot,
-       .data_xfer              = ata_pio_data_xfer,
+       .data_xfer              = ata_data_xfer,
 
        .irq_handler            = ata_interrupt,
        .irq_clear              = ata_bmdma_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
 
        .port_start             = ata_port_start,
-       .port_stop              = ata_port_stop,
-       .host_stop              = ata_host_stop,
 };
 
 static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_device_id *id)
 {
        u8 pcicfg;
+       void *iomap[5];
        static struct ata_probe_ent probe[2];
        int ports = 0;
 
@@ -236,6 +237,16 @@ static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_devic
                return -ENODEV;
        }
 
+       /* Map IO ports */
+       iomap[0] = devm_ioport_map(&dev->dev, 0x1F0, 8);
+       iomap[1] = devm_ioport_map(&dev->dev, 0x3F6, 1);
+       iomap[2] = devm_ioport_map(&dev->dev, 0x170, 8);
+       iomap[3] = devm_ioport_map(&dev->dev, 0x376, 1);
+       iomap[4] = pcim_iomap(dev, 2, 0);
+
+       if (!iomap[0] || !iomap[1] || !iomap[2] || !iomap[3] || !iomap[4])
+               return -ENOMEM;
+
        /* We have to do our own plumbing as the PCI setup for this
           chipset is non-standard so we can't punt to the libata code */
 
@@ -249,10 +260,10 @@ static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_devic
        probe[0].irq_flags = 0;
        probe[0].port_flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST;
        probe[0].n_ports = 1;
-       probe[0].port[0].cmd_addr = 0x1F0;
-       probe[0].port[0].ctl_addr = 0x3F6;
-       probe[0].port[0].altstatus_addr = 0x3F6;
-       probe[0].port[0].bmdma_addr = pci_resource_start(dev, 2);
+       probe[0].port[0].cmd_addr = iomap[0];
+       probe[0].port[0].ctl_addr = iomap[1];
+       probe[0].port[0].altstatus_addr = iomap[1];
+       probe[0].port[0].bmdma_addr = iomap[4];
 
        /* The secondary lurks at different addresses but is otherwise
           the same beastie */
@@ -260,10 +271,10 @@ static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_devic
        probe[1] = probe[0];
        INIT_LIST_HEAD(&probe[1].node);
        probe[1].irq = 15;
-       probe[1].port[0].cmd_addr = 0x170;
-       probe[1].port[0].ctl_addr = 0x376;
-       probe[1].port[0].altstatus_addr = 0x376;
-       probe[1].port[0].bmdma_addr = pci_resource_start(dev, 2) + 8;
+       probe[1].port[0].cmd_addr = iomap[2];
+       probe[1].port[0].ctl_addr = iomap[3];
+       probe[1].port[0].altstatus_addr = iomap[3];
+       probe[1].port[0].bmdma_addr = iomap[4] + 8;
 
        /* Let libata fill in the port details */
        ata_std_ports(&probe[0].port[0]);
@@ -294,7 +305,7 @@ static void __devexit cs5520_remove_one(struct pci_dev *pdev)
        struct device *dev = pci_dev_to_dev(pdev);
        struct ata_host *host = dev_get_drvdata(dev);
 
-       ata_host_remove(host);
+       ata_host_detach(host);
        dev_set_drvdata(dev, NULL);
 }
 
@@ -305,7 +316,7 @@ static void __devexit cs5520_remove_one(struct pci_dev *pdev)
  *     Do any reconfiguration work needed by a resume from RAM. We need
  *     to restore DMA mode support on BIOSen which disabled it
  */
+
 static int cs5520_reinit_one(struct pci_dev *pdev)
 {
        u8 pcicfg;
index b1ca207e3545dcdce0b828806ded54db5a39891e..3d7b7d87ec6f3a49647a0b5a6a9ab0ff4e4703bf 100644 (file)
 #define DRV_NAME       "pata_cs5530"
 #define DRV_VERSION    "0.7.1"
 
+static void __iomem *cs5530_port_base(struct ata_port *ap)
+{
+       unsigned long bmdma = (unsigned long)ap->ioaddr.bmdma_addr;
+
+       return (void __iomem *)((bmdma & ~0x0F) + 0x20 + 0x10 * ap->port_no);
+}
+
 /**
  *     cs5530_set_piomode              -       PIO setup
  *     @ap: ATA interface
@@ -52,19 +59,19 @@ static void cs5530_set_piomode(struct ata_port *ap, struct ata_device *adev)
                {0x00009172, 0x00012171, 0x00020080, 0x00032010, 0x00040010},
                {0xd1329172, 0x71212171, 0x30200080, 0x20102010, 0x00100010}
        };
-       unsigned long base = ( ap->ioaddr.bmdma_addr & ~0x0F) + 0x20 + 0x10 * ap->port_no;
+       void __iomem *base = cs5530_port_base(ap);
        u32 tuning;
        int format;
 
        /* Find out which table to use */
-       tuning = inl(base + 0x04);
+       tuning = ioread32(base + 0x04);
        format = (tuning & 0x80000000UL) ? 1 : 0;
 
        /* Now load the right timing register */
        if (adev->devno)
                base += 0x08;
 
-       outl(cs5530_pio_timings[format][adev->pio_mode - XFER_PIO_0], base);
+       iowrite32(cs5530_pio_timings[format][adev->pio_mode - XFER_PIO_0], base);
 }
 
 /**
@@ -79,12 +86,12 @@ static void cs5530_set_piomode(struct ata_port *ap, struct ata_device *adev)
 
 static void cs5530_set_dmamode(struct ata_port *ap, struct ata_device *adev)
 {
-       unsigned long base = ( ap->ioaddr.bmdma_addr & ~0x0F) + 0x20 + 0x10 * ap->port_no;
+       void __iomem *base = cs5530_port_base(ap);
        u32 tuning, timing = 0;
        u8 reg;
 
        /* Find out which table to use */
-       tuning = inl(base + 0x04);
+       tuning = ioread32(base + 0x04);
 
        switch(adev->dma_mode) {
                case XFER_UDMA_0:
@@ -105,20 +112,20 @@ static void cs5530_set_dmamode(struct ata_port *ap, struct ata_device *adev)
        /* Merge in the PIO format bit */
        timing |= (tuning & 0x80000000UL);
        if (adev->devno == 0) /* Master */
-               outl(timing, base + 0x04);
+               iowrite32(timing, base + 0x04);
        else {
                if (timing & 0x00100000)
                        tuning |= 0x00100000;   /* UDMA for both */
                else
                        tuning &= ~0x00100000;  /* MWDMA for both */
-               outl(tuning, base + 0x04);
-               outl(timing, base + 0x0C);
+               iowrite32(tuning, base + 0x04);
+               iowrite32(timing, base + 0x0C);
        }
 
        /* Set the DMA capable bit in the BMDMA area */
-       reg = inb(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS);
+       reg = ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS);
        reg |= (1 << (5 + adev->devno));
-       outb(reg, ap->ioaddr.bmdma_addr + ATA_DMA_STATUS);
+       iowrite8(reg, ap->ioaddr.bmdma_addr + ATA_DMA_STATUS);
 
        /* Remember the last DMA setup we did */
 
@@ -210,14 +217,14 @@ static struct ata_port_operations cs5530_port_ops = {
        .qc_prep        = ata_qc_prep,
        .qc_issue       = cs5530_qc_issue_prot,
 
-       .data_xfer      = ata_pio_data_xfer,
+       .data_xfer      = ata_data_xfer,
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 static struct dmi_system_id palmax_dmi_table[] = {
@@ -247,7 +254,7 @@ static int cs5530_is_palmax(void)
  *     Perform the chip initialisation work that is shared between both
  *     setup and resume paths
  */
+
 static int cs5530_init_chip(void)
 {
        struct pci_dev *master_0 = NULL, *cs5530_0 = NULL, *dev = NULL;
@@ -357,11 +364,11 @@ static int cs5530_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
                .port_ops = &cs5530_port_ops
        };
        static struct ata_port_info *port_info[2] = { &info, &info };
-       
+
        /* Chip initialisation */
        if (cs5530_init_chip())
                return -ENODEV;
-               
+
        if (cs5530_is_palmax())
                port_info[1] = &info_palmax_secondary;
 
@@ -376,7 +383,7 @@ static int cs5530_reinit_one(struct pci_dev *pdev)
                BUG();
        return ata_pci_device_resume(pdev);
 }
-       
+
 static const struct pci_device_id cs5530[] = {
        { PCI_VDEVICE(CYRIX, PCI_DEVICE_ID_CYRIX_5530_IDE), },
 
index e3efec4ffc79ada787f54d8b612b6cf1db294168..17bc693cc5149b34e69e74879da4635d4aeb0046 100644 (file)
@@ -214,14 +214,14 @@ static struct ata_port_operations cs5535_port_ops = {
        .qc_prep        = ata_qc_prep,
        .qc_issue       = ata_qc_issue_prot,
 
-       .data_xfer      = ata_pio_data_xfer,
+       .data_xfer      = ata_data_xfer,
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 /**
index e2a95699bae7ff293ef1eb29fa5d859db3ccefd8..63f48f08763db323bc7e76984f5e1a6f6a62274c 100644 (file)
@@ -165,14 +165,14 @@ static struct ata_port_operations cy82c693_port_ops = {
        .qc_prep        = ata_qc_prep,
        .qc_issue       = ata_qc_issue_prot,
 
-       .data_xfer      = ata_pio_data_xfer,
+       .data_xfer      = ata_data_xfer,
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 static int cy82c693_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
index edf8a63f50af3afe6b54d93a0deffa5da252dcb7..c19b6a8a7dc6c5afc6b433f6e2746cffb5edfa91 100644 (file)
@@ -261,14 +261,14 @@ static const struct ata_port_operations efar_ops = {
        .bmdma_status           = ata_bmdma_status,
        .qc_prep                = ata_qc_prep,
        .qc_issue               = ata_qc_issue_prot,
-       .data_xfer              = ata_pio_data_xfer,
+       .data_xfer              = ata_data_xfer,
 
        .irq_handler            = ata_interrupt,
        .irq_clear              = ata_bmdma_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
 
        .port_start             = ata_port_start,
-       .port_stop              = ata_port_stop,
-       .host_stop              = ata_host_stop,
 };
 
 
index 2663599a7c02fb041f7e1ac0485164af6ee706f4..27d724b5eea2c138a54c5314290f3b031fdf4a9f 100644 (file)
@@ -151,23 +151,13 @@ static const char *bad_ata66_3[] = {
 
 static int hpt_dma_blacklisted(const struct ata_device *dev, char *modestr, const char *list[])
 {
-       unsigned char model_num[40];
-       char *s;
-       unsigned int len;
+       unsigned char model_num[ATA_ID_PROD_LEN + 1];
        int i = 0;
 
-       ata_id_string(dev->id, model_num, ATA_ID_PROD_OFS, sizeof(model_num));
-       s = &model_num[0];
-       len = strnlen(s, sizeof(model_num));
+       ata_id_c_string(dev->id, model_num, ATA_ID_PROD, sizeof(model_num));
 
-       /* ATAPI specifies that empty space is blank-filled; remove blanks */
-       while ((len > 0) && (s[len - 1] == ' ')) {
-               len--;
-               s[len] = 0;
-       }
-
-       while(list[i] != NULL) {
-               if (!strncmp(list[i], s, len)) {
+       while (list[i] != NULL) {
+               if (!strcmp(list[i], model_num)) {
                        printk(KERN_WARNING DRV_NAME ": %s is not supported for %s.\n",
                                modestr, list[i]);
                        return 1;
@@ -232,7 +222,7 @@ static int hpt36x_pre_reset(struct ata_port *ap)
 
        if (!pci_test_config_bits(pdev, &hpt36x_enable_bits[ap->port_no]))
                return -ENOENT;
-               
+
        pci_read_config_byte(pdev, 0x5A, &ata66);
        if (ata66 & (1 << ap->port_no))
                ap->cbl = ATA_CBL_PATA40;
@@ -371,14 +361,14 @@ static struct ata_port_operations hpt366_port_ops = {
        .qc_prep        = ata_qc_prep,
        .qc_issue       = ata_qc_issue_prot,
 
-       .data_xfer      = ata_pio_data_xfer,
+       .data_xfer      = ata_data_xfer,
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 /**
index dfb306057cf465c9e5f48eff8abdb55e633e6f6a..4ffc392052c02f1a2dfb4769d06cace005e84abd 100644 (file)
@@ -349,24 +349,13 @@ static u32 hpt37x_find_mode(struct ata_port *ap, int speed)
 
 static int hpt_dma_blacklisted(const struct ata_device *dev, char *modestr, const char *list[])
 {
-       unsigned char model_num[40];
-       char *s;
-       unsigned int len;
+       unsigned char model_num[ATA_ID_PROD_LEN + 1];
        int i = 0;
 
-       ata_id_string(dev->id, model_num, ATA_ID_PROD_OFS,
-                         sizeof(model_num));
-       s = &model_num[0];
-       len = strnlen(s, sizeof(model_num));
+       ata_id_c_string(dev->id, model_num, ATA_ID_PROD, sizeof(model_num));
 
-       /* ATAPI specifies that empty space is blank-filled; remove blanks */
-       while ((len > 0) && (s[len - 1] == ' ')) {
-               len--;
-               s[len] = 0;
-       }
-
-       while(list[i] != NULL) {
-               if (!strncmp(list[i], s, len)) {
+       while (list[i] != NULL) {
+               if (!strcmp(list[i], model_num)) {
                        printk(KERN_WARNING DRV_NAME ": %s is not supported for %s.\n",
                                modestr, list[i]);
                        return 1;
@@ -459,7 +448,7 @@ static int hpt37x_pre_reset(struct ata_port *ap)
        };
        if (!pci_test_config_bits(pdev, &hpt37x_enable_bits[ap->port_no]))
                return -ENOENT;
-               
+
        pci_read_config_byte(pdev, 0x5B, &scr2);
        pci_write_config_byte(pdev, 0x5B, scr2 & ~0x01);
        /* Cable register now active */
@@ -504,7 +493,7 @@ static int hpt374_pre_reset(struct ata_port *ap)
 
        if (!pci_test_config_bits(pdev, &hpt37x_enable_bits[ap->port_no]))
                return -ENOENT;
-               
+
        /* Do the extra channel work */
        pci_read_config_word(pdev, 0x52, &mcr3);
        pci_read_config_word(pdev, 0x56, &mcr6);
@@ -645,24 +634,24 @@ static void hpt370_bmdma_stop(struct ata_queued_cmd *qc)
 {
        struct ata_port *ap = qc->ap;
        struct pci_dev *pdev = to_pci_dev(ap->host->dev);
-       u8 dma_stat = inb(ap->ioaddr.bmdma_addr + 2);
+       u8 dma_stat = ioread8(ap->ioaddr.bmdma_addr + 2);
        u8 dma_cmd;
-       unsigned long bmdma = ap->ioaddr.bmdma_addr;
+       void __iomem *bmdma = ap->ioaddr.bmdma_addr;
 
        if (dma_stat & 0x01) {
                udelay(20);
-               dma_stat = inb(bmdma + 2);
+               dma_stat = ioread8(bmdma + 2);
        }
        if (dma_stat & 0x01) {
                /* Clear the engine */
                pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37);
                udelay(10);
                /* Stop DMA */
-               dma_cmd = inb(bmdma );
-               outb(dma_cmd & 0xFE, bmdma);
+               dma_cmd = ioread8(bmdma );
+               iowrite8(dma_cmd & 0xFE, bmdma);
                /* Clear Error */
-               dma_stat = inb(bmdma + 2);
-               outb(dma_stat | 0x06 , bmdma + 2);
+               dma_stat = ioread8(bmdma + 2);
+               iowrite8(dma_stat | 0x06 , bmdma + 2);
                /* Clear the engine */
                pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37);
                udelay(10);
@@ -807,14 +796,14 @@ static struct ata_port_operations hpt370_port_ops = {
        .qc_prep        = ata_qc_prep,
        .qc_issue       = ata_qc_issue_prot,
 
-       .data_xfer      = ata_pio_data_xfer,
+       .data_xfer      = ata_data_xfer,
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 /*
@@ -846,14 +835,14 @@ static struct ata_port_operations hpt370a_port_ops = {
        .qc_prep        = ata_qc_prep,
        .qc_issue       = ata_qc_issue_prot,
 
-       .data_xfer      = ata_pio_data_xfer,
+       .data_xfer      = ata_data_xfer,
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 /*
@@ -886,14 +875,14 @@ static struct ata_port_operations hpt372_port_ops = {
        .qc_prep        = ata_qc_prep,
        .qc_issue       = ata_qc_issue_prot,
 
-       .data_xfer      = ata_pio_data_xfer,
+       .data_xfer      = ata_data_xfer,
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 /*
@@ -926,14 +915,14 @@ static struct ata_port_operations hpt374_port_ops = {
        .qc_prep        = ata_qc_prep,
        .qc_issue       = ata_qc_issue_prot,
 
-       .data_xfer      = ata_pio_data_xfer,
+       .data_xfer      = ata_data_xfer,
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 /**
index 886fab9aa62c5cdaec19c0036e3b32eb1cf3148c..65f2e180e7fa285644e9bf38522d39846da446b5 100644 (file)
@@ -263,26 +263,26 @@ static void hpt3x2n_bmdma_stop(struct ata_queued_cmd *qc)
 
 static void hpt3x2n_set_clock(struct ata_port *ap, int source)
 {
-       unsigned long bmdma = ap->ioaddr.bmdma_addr;
+       void __iomem *bmdma = ap->ioaddr.bmdma_addr;
 
        /* Tristate the bus */
-       outb(0x80, bmdma+0x73);
-       outb(0x80, bmdma+0x77);
+       iowrite8(0x80, bmdma+0x73);
+       iowrite8(0x80, bmdma+0x77);
 
        /* Switch clock and reset channels */
-       outb(source, bmdma+0x7B);
-       outb(0xC0, bmdma+0x79);
+       iowrite8(source, bmdma+0x7B);
+       iowrite8(0xC0, bmdma+0x79);
 
        /* Reset state machines */
-       outb(0x37, bmdma+0x70);
-       outb(0x37, bmdma+0x74);
+       iowrite8(0x37, bmdma+0x70);
+       iowrite8(0x37, bmdma+0x74);
 
        /* Complete reset */
-       outb(0x00, bmdma+0x79);
+       iowrite8(0x00, bmdma+0x79);
 
        /* Reconnect channels to bus */
-       outb(0x00, bmdma+0x73);
-       outb(0x00, bmdma+0x77);
+       iowrite8(0x00, bmdma+0x73);
+       iowrite8(0x00, bmdma+0x77);
 }
 
 /* Check if our partner interface is busy */
@@ -373,14 +373,14 @@ static struct ata_port_operations hpt3x2n_port_ops = {
        .qc_prep        = ata_qc_prep,
        .qc_issue       = hpt3x2n_qc_issue_prot,
 
-       .data_xfer      = ata_pio_data_xfer,
+       .data_xfer      = ata_data_xfer,
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 /**
index 5f1d385eb592da1f2c9d6a4c8cb382afc9b6f7b0..483ce7c12c9ac61da2e614e2f798ceb983abbaef 100644 (file)
@@ -148,14 +148,14 @@ static struct ata_port_operations hpt3x3_port_ops = {
        .qc_prep        = ata_qc_prep,
        .qc_issue       = ata_qc_issue_prot,
 
-       .data_xfer      = ata_pio_data_xfer,
+       .data_xfer      = ata_data_xfer,
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 /**
@@ -164,7 +164,7 @@ static struct ata_port_operations hpt3x3_port_ops = {
  *
  *     Perform the setup required at boot and on resume.
  */
+
 static void hpt3x3_init_chipset(struct pci_dev *dev)
 {
        u16 cmd;
index a97d55ae95c9e6809e450befd37fdf5df32bc98e..1bf5ec18b2e31490b350eb041773f04b265ad099 100644 (file)
@@ -53,14 +53,14 @@ static struct ata_port_operations isapnp_port_ops = {
        .qc_prep        = ata_qc_prep,
        .qc_issue       = ata_qc_issue_prot,
 
-       .data_xfer      = ata_pio_data_xfer,
+       .data_xfer      = ata_data_xfer,
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 /**
@@ -75,6 +75,7 @@ static struct ata_port_operations isapnp_port_ops = {
 static int isapnp_init_one(struct pnp_dev *idev, const struct pnp_device_id *dev_id)
 {
        struct ata_probe_ent ae;
+       void __iomem *cmd_addr, *ctl_addr;
 
        if (pnp_port_valid(idev, 0) == 0)
                return -ENODEV;
@@ -83,6 +84,10 @@ static int isapnp_init_one(struct pnp_dev *idev, const struct pnp_device_id *dev
        if (pnp_irq_valid(idev, 0) == 0)
                return -ENODEV;
 
+       cmd_addr = devm_ioport_map(&idev->dev, pnp_port_start(idev, 0), 8);
+       if (!cmd_addr)
+               return -ENOMEM;
+
        memset(&ae, 0, sizeof(struct ata_probe_ent));
        INIT_LIST_HEAD(&ae.node);
        ae.dev = &idev->dev;
@@ -93,11 +98,13 @@ static int isapnp_init_one(struct pnp_dev *idev, const struct pnp_device_id *dev
        ae.irq = pnp_irq(idev, 0);
        ae.irq_flags = 0;
        ae.port_flags = ATA_FLAG_SLAVE_POSS;
-       ae.port[0].cmd_addr = pnp_port_start(idev, 0);
+       ae.port[0].cmd_addr = cmd_addr;
 
        if (pnp_port_valid(idev, 1) == 0) {
-               ae.port[0].altstatus_addr = pnp_port_start(idev, 1);
-               ae.port[0].ctl_addr = pnp_port_start(idev, 1);
+               ctl_addr = devm_ioport_map(&idev->dev,
+                                          pnp_port_start(idev, 1), 1);
+               ae.port[0].altstatus_addr = ctl_addr;
+               ae.port[0].ctl_addr = ctl_addr;
                ae.port_flags |= ATA_FLAG_SRST;
        }
        ata_std_ports(&ae.port[0]);
@@ -120,7 +127,7 @@ static void isapnp_remove_one(struct pnp_dev *idev)
        struct device *dev = &idev->dev;
        struct ata_host *host = dev_get_drvdata(dev);
 
-       ata_host_remove(host);
+       ata_host_detach(host);
        dev_set_drvdata(dev, NULL);
 }
 
diff --git a/drivers/ata/pata_it8213.c b/drivers/ata/pata_it8213.c
new file mode 100644 (file)
index 0000000..7eac869
--- /dev/null
@@ -0,0 +1,354 @@
+/*
+ *    pata_it8213.c - iTE Tech. Inc.  IT8213 PATA driver
+ *
+ *    The IT8213 is a very Intel ICH like device for timing purposes, having
+ *    a similar register layout and the same split clock arrangement. Cable
+ *    detection is different, and it does not have slave channels or all the
+ *    clutter of later ICH/SATA setups.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/pci.h>
+#include <linux/init.h>
+#include <linux/blkdev.h>
+#include <linux/delay.h>
+#include <linux/device.h>
+#include <scsi/scsi_host.h>
+#include <linux/libata.h>
+#include <linux/ata.h>
+
+#define DRV_NAME       "pata_it8213"
+#define DRV_VERSION    "0.0.2"
+
+/**
+ *     it8213_pre_reset        -       check for 40/80 pin
+ *     @ap: Port
+ *
+ *     Perform cable detection for the 8213 ATA interface. This is
+ *     different to the PIIX arrangement
+ */
+
+static int it8213_pre_reset(struct ata_port *ap)
+{
+       static const struct pci_bits it8213_enable_bits[] = {
+               { 0x41U, 1U, 0x80UL, 0x80UL },  /* port 0 */
+       };
+
+       struct pci_dev *pdev = to_pci_dev(ap->host->dev);
+       u8 tmp;
+
+       if (!pci_test_config_bits(pdev, &it8213_enable_bits[ap->port_no]))
+               return -ENOENT;
+
+       pci_read_config_byte(pdev, 0x42, &tmp);
+       if (tmp & 2)    /* The initial docs are incorrect */
+               ap->cbl = ATA_CBL_PATA40;
+       else
+               ap->cbl = ATA_CBL_PATA80;
+       return ata_std_prereset(ap);
+}
+
+/**
+ *     it8213_probe_reset - Probe specified port on PATA host controller
+ *     @ap: Port to probe
+ *
+ *     LOCKING:
+ *     None (inherited from caller).
+ */
+
+static void it8213_error_handler(struct ata_port *ap)
+{
+       ata_bmdma_drive_eh(ap, it8213_pre_reset, ata_std_softreset, NULL, ata_std_postreset);
+}
+
+/**
+ *     it8213_set_piomode - Initialize host controller PATA PIO timings
+ *     @ap: Port whose timings we are configuring
+ *     @adev: um
+ *
+ *     Set PIO mode for device, in host controller PCI config space.
+ *
+ *     LOCKING:
+ *     None (inherited from caller).
+ */
+
+static void it8213_set_piomode (struct ata_port *ap, struct ata_device *adev)
+{
+       unsigned int pio        = adev->pio_mode - XFER_PIO_0;
+       struct pci_dev *dev     = to_pci_dev(ap->host->dev);
+       unsigned int idetm_port= ap->port_no ? 0x42 : 0x40;
+       u16 idetm_data;
+       int control = 0;
+
+       /*
+        *      See Intel Document 298600-004 for the timing programing rules
+        *      for PIIX/ICH. The 8213 is a clone so very similar
+        */
+
+       static const     /* ISP  RTC */
+       u8 timings[][2] = { { 0, 0 },
+                           { 0, 0 },
+                           { 1, 0 },
+                           { 2, 1 },
+                           { 2, 3 }, };
+
+       if (pio > 2)
+               control |= 1;   /* TIME1 enable */
+       if (ata_pio_need_iordy(adev))   /* PIO 3/4 require IORDY */
+               control |= 2;   /* IORDY enable */
+       /* Bit 2 is set for ATAPI on the IT8213 - reverse of ICH/PIIX */
+       if (adev->class != ATA_DEV_ATA)
+               control |= 4;
+
+       pci_read_config_word(dev, idetm_port, &idetm_data);
+
+       /* Enable PPE, IE and TIME as appropriate */
+
+       if (adev->devno == 0) {
+               idetm_data &= 0xCCF0;
+               idetm_data |= control;
+               idetm_data |= (timings[pio][0] << 12) |
+                       (timings[pio][1] << 8);
+       } else {
+               u8 slave_data;
+
+               idetm_data &= 0xCC0F;
+               idetm_data |= (control << 4);
+
+               /* Slave timing in seperate register */
+               pci_read_config_byte(dev, 0x44, &slave_data);
+               slave_data &= 0xF0;
+               slave_data |= ((timings[pio][0] << 2) | timings[pio][1]) << 4;
+               pci_write_config_byte(dev, 0x44, slave_data);
+       }
+
+       idetm_data |= 0x4000;   /* Ensure SITRE is enabled */
+       pci_write_config_word(dev, idetm_port, idetm_data);
+}
+
+/**
+ *     it8213_set_dmamode - Initialize host controller PATA DMA timings
+ *     @ap: Port whose timings we are configuring
+ *     @adev: Device to program
+ *
+ *     Set UDMA/MWDMA mode for device, in host controller PCI config space.
+ *     This device is basically an ICH alike.
+ *
+ *     LOCKING:
+ *     None (inherited from caller).
+ */
+
+static void it8213_set_dmamode (struct ata_port *ap, struct ata_device *adev)
+{
+       struct pci_dev *dev     = to_pci_dev(ap->host->dev);
+       u16 master_data;
+       u8 speed                = adev->dma_mode;
+       int devid               = adev->devno;
+       u8 udma_enable;
+
+       static const     /* ISP  RTC */
+       u8 timings[][2] = { { 0, 0 },
+                           { 0, 0 },
+                           { 1, 0 },
+                           { 2, 1 },
+                           { 2, 3 }, };
+
+       pci_read_config_word(dev, 0x40, &master_data);
+       pci_read_config_byte(dev, 0x48, &udma_enable);
+
+       if (speed >= XFER_UDMA_0) {
+               unsigned int udma = adev->dma_mode - XFER_UDMA_0;
+               u16 udma_timing;
+               u16 ideconf;
+               int u_clock, u_speed;
+
+               /* Clocks follow the PIIX style */
+               u_speed = min(2 - (udma & 1), udma);
+               if (udma == 5)
+                       u_clock = 0x1000;       /* 100Mhz */
+               else if (udma > 2)
+                       u_clock = 1;            /* 66Mhz */
+               else
+                       u_clock = 0;            /* 33Mhz */
+
+               udma_enable |= (1 << devid);
+
+               /* Load the UDMA mode number */
+               pci_read_config_word(dev, 0x4A, &udma_timing);
+               udma_timing &= ~(3 << (4 * devid));
+               udma_timing |= (udma & 3) << (4 * devid);
+               pci_write_config_word(dev, 0x4A, udma_timing);
+
+               /* Load the clock selection */
+               pci_read_config_word(dev, 0x54, &ideconf);
+               ideconf &= ~(0x1001 << devid);
+               ideconf |= u_clock << devid;
+               pci_write_config_word(dev, 0x54, ideconf);
+       } else {
+               /*
+                * MWDMA is driven by the PIO timings. We must also enable
+                * IORDY unconditionally along with TIME1. PPE has already
+                * been set when the PIO timing was set.
+                */
+               unsigned int mwdma      = adev->dma_mode - XFER_MW_DMA_0;
+               unsigned int control;
+               u8 slave_data;
+               static const unsigned int needed_pio[3] = {
+                       XFER_PIO_0, XFER_PIO_3, XFER_PIO_4
+               };
+               int pio = needed_pio[mwdma] - XFER_PIO_0;
+
+               control = 3;    /* IORDY|TIME1 */
+
+               /* If the drive MWDMA is faster than it can do PIO then
+                  we must force PIO into PIO0 */
+
+               if (adev->pio_mode < needed_pio[mwdma])
+                       /* Enable DMA timing only */
+                       control |= 8;   /* PIO cycles in PIO0 */
+
+               if (devid) {    /* Slave */
+                       master_data &= 0xFF4F;  /* Mask out IORDY|TIME1|DMAONLY */
+                       master_data |= control << 4;
+                       pci_read_config_byte(dev, 0x44, &slave_data);
+                       slave_data &= (0x0F + 0xE1 * ap->port_no);
+                       /* Load the matching timing */
+                       slave_data |= ((timings[pio][0] << 2) | timings[pio][1]) << (ap->port_no ? 4 : 0);
+                       pci_write_config_byte(dev, 0x44, slave_data);
+               } else {        /* Master */
+                       master_data &= 0xCCF4;  /* Mask out IORDY|TIME1|DMAONLY
+                                                  and master timing bits */
+                       master_data |= control;
+                       master_data |=
+                               (timings[pio][0] << 12) |
+                               (timings[pio][1] << 8);
+               }
+               udma_enable &= ~(1 << devid);
+               pci_write_config_word(dev, 0x40, master_data);
+       }
+       pci_write_config_byte(dev, 0x48, udma_enable);
+}
+
+static struct scsi_host_template it8213_sht = {
+       .module                 = THIS_MODULE,
+       .name                   = DRV_NAME,
+       .ioctl                  = ata_scsi_ioctl,
+       .queuecommand           = ata_scsi_queuecmd,
+       .can_queue              = ATA_DEF_QUEUE,
+       .this_id                = ATA_SHT_THIS_ID,
+       .sg_tablesize           = LIBATA_MAX_PRD,
+       .max_sectors            = ATA_MAX_SECTORS,
+       .cmd_per_lun            = ATA_SHT_CMD_PER_LUN,
+       .emulated               = ATA_SHT_EMULATED,
+       .use_clustering         = ATA_SHT_USE_CLUSTERING,
+       .proc_name              = DRV_NAME,
+       .dma_boundary           = ATA_DMA_BOUNDARY,
+       .slave_configure        = ata_scsi_slave_config,
+       .bios_param             = ata_std_bios_param,
+       .resume                 = ata_scsi_device_resume,
+       .suspend                = ata_scsi_device_suspend,
+};
+
+static const struct ata_port_operations it8213_ops = {
+       .port_disable           = ata_port_disable,
+       .set_piomode            = it8213_set_piomode,
+       .set_dmamode            = it8213_set_dmamode,
+       .mode_filter            = ata_pci_default_filter,
+
+       .tf_load                = ata_tf_load,
+       .tf_read                = ata_tf_read,
+       .check_status           = ata_check_status,
+       .exec_command           = ata_exec_command,
+       .dev_select             = ata_std_dev_select,
+
+       .freeze                 = ata_bmdma_freeze,
+       .thaw                   = ata_bmdma_thaw,
+       .error_handler          = it8213_error_handler,
+       .post_internal_cmd      = ata_bmdma_post_internal_cmd,
+
+       .bmdma_setup            = ata_bmdma_setup,
+       .bmdma_start            = ata_bmdma_start,
+       .bmdma_stop             = ata_bmdma_stop,
+       .bmdma_status           = ata_bmdma_status,
+       .qc_prep                = ata_qc_prep,
+       .qc_issue               = ata_qc_issue_prot,
+       .data_xfer              = ata_data_xfer,
+
+       .irq_handler            = ata_interrupt,
+       .irq_clear              = ata_bmdma_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
+
+       .port_start             = ata_port_start,
+};
+
+
+/**
+ *     it8213_init_one - Register 8213 ATA PCI device with kernel services
+ *     @pdev: PCI device to register
+ *     @ent: Entry in it8213_pci_tbl matching with @pdev
+ *
+ *     Called from kernel PCI layer.
+ *
+ *     LOCKING:
+ *     Inherited from PCI layer (may sleep).
+ *
+ *     RETURNS:
+ *     Zero on success, or -ERRNO value.
+ */
+
+static int it8213_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
+{
+       static int printed_version;
+       static struct ata_port_info info = {
+               .sht            = &it8213_sht,
+               .flags          = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
+               .pio_mask       = 0x1f, /* pio0-4 */
+               .mwdma_mask     = 0x07, /* mwdma0-2 */
+               .udma_mask      = 0x1f, /* UDMA 100 */
+               .port_ops       = &it8213_ops,
+       };
+       static struct ata_port_info *port_info[2] = { &info, &info };
+
+       if (!printed_version++)
+               dev_printk(KERN_DEBUG, &pdev->dev,
+                          "version " DRV_VERSION "\n");
+
+       /* Current IT8213 stuff is single port */
+       return ata_pci_init_one(pdev, port_info, 1);
+}
+
+static const struct pci_device_id it8213_pci_tbl[] = {
+       { PCI_VDEVICE(ITE, PCI_DEVICE_ID_ITE_8213), },
+
+       { }     /* terminate list */
+};
+
+static struct pci_driver it8213_pci_driver = {
+       .name                   = DRV_NAME,
+       .id_table               = it8213_pci_tbl,
+       .probe                  = it8213_init_one,
+       .remove                 = ata_pci_remove_one,
+       .suspend                = ata_pci_device_suspend,
+       .resume                 = ata_pci_device_resume,
+};
+
+static int __init it8213_init(void)
+{
+       return pci_register_driver(&it8213_pci_driver);
+}
+
+static void __exit it8213_exit(void)
+{
+       pci_unregister_driver(&it8213_pci_driver);
+}
+
+module_init(it8213_init);
+module_exit(it8213_exit);
+
+MODULE_AUTHOR("Alan Cox");
+MODULE_DESCRIPTION("SCSI low-level driver for the ITE 8213");
+MODULE_LICENSE("GPL");
+MODULE_DEVICE_TABLE(pci, it8213_pci_tbl);
+MODULE_VERSION(DRV_VERSION);
index e8afd486434a6d1ce92a3e4b56bf5b08572f8823..73394c75be4254fac5c0624c7b0ea23747279fdc 100644 (file)
@@ -492,7 +492,7 @@ static int it821x_smart_set_mode(struct ata_port *ap, struct ata_device **unused
        /* Bits 5 and 6 indicate if DMA is active on master/slave */
        /* It is possible that BMDMA isn't allocated */
        if (ap->ioaddr.bmdma_addr)
-               dma_enabled = inb(ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
+               dma_enabled = ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
 
        for (i = 0; i < ATA_MAX_DEVICES; i++) {
                struct ata_device *dev = &ap->device[i];
@@ -531,23 +531,9 @@ static int it821x_smart_set_mode(struct ata_port *ap, struct ata_device **unused
 
 static void it821x_dev_config(struct ata_port *ap, struct ata_device *adev)
 {
-       unsigned char model_num[40];
-       char *s;
-       unsigned int len;
-
-       /* This block ought to be a library routine as it is in several
-          drivers now */
-
-       ata_id_string(adev->id, model_num, ATA_ID_PROD_OFS,
-                         sizeof(model_num));
-       s = &model_num[0];
-       len = strnlen(s, sizeof(model_num));
-
-       /* ATAPI specifies that empty space is blank-filled; remove blanks */
-       while ((len > 0) && (s[len - 1] == ' ')) {
-               len--;
-               s[len] = 0;
-       }
+       unsigned char model_num[ATA_ID_PROD_LEN + 1];
+
+       ata_id_c_string(adev->id, model_num, ATA_ID_PROD, sizeof(model_num));
 
        if (adev->max_sectors > 255)
                adev->max_sectors = 255;
@@ -608,14 +594,10 @@ static int it821x_port_start(struct ata_port *ap)
        if (ret < 0)
                return ret;
 
-       ap->private_data = kmalloc(sizeof(struct it821x_dev), GFP_KERNEL);
-       if (ap->private_data == NULL) {
-               ata_port_stop(ap);
+       itdev = devm_kzalloc(&pdev->dev, sizeof(struct it821x_dev), GFP_KERNEL);
+       if (itdev == NULL)
                return -ENOMEM;
-       }
-
-       itdev = ap->private_data;
-       memset(itdev, 0, sizeof(struct it821x_dev));
+       ap->private_data = itdev;
 
        pci_read_config_byte(pdev, 0x50, &conf);
 
@@ -646,20 +628,6 @@ static int it821x_port_start(struct ata_port *ap)
        return 0;
 }
 
-/**
- *     it821x_port_stop        -       port shutdown
- *     @ap: ATA port being removed
- *
- *     Release the private objects we added in it821x_port_start
- */
-
-static void it821x_port_stop(struct ata_port *ap) {
-       kfree(ap->private_data);
-       ap->private_data = NULL;        /* We want an OOPS if we reuse this
-                                          too late! */
-       ata_port_stop(ap);
-}
-
 static struct scsi_host_template it821x_sht = {
        .module                 = THIS_MODULE,
        .name                   = DRV_NAME,
@@ -706,14 +674,14 @@ static struct ata_port_operations it821x_smart_port_ops = {
        .qc_prep        = ata_qc_prep,
        .qc_issue       = it821x_smart_qc_issue_prot,
 
-       .data_xfer      = ata_pio_data_xfer,
+       .data_xfer      = ata_data_xfer,
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = it821x_port_start,
-       .port_stop      = it821x_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 static struct ata_port_operations it821x_passthru_port_ops = {
@@ -742,14 +710,14 @@ static struct ata_port_operations it821x_passthru_port_ops = {
        .qc_prep        = ata_qc_prep,
        .qc_issue       = it821x_passthru_qc_issue_prot,
 
-       .data_xfer      = ata_pio_data_xfer,
+       .data_xfer      = ata_data_xfer,
 
        .irq_clear      = ata_bmdma_irq_clear,
        .irq_handler    = ata_interrupt,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = it821x_port_start,
-       .port_stop      = it821x_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 static void __devinit it821x_disable_raid(struct pci_dev *pdev)
index 23b8aab3ebd8f876fff754736cb0b18bad8f1b7d..3222ac7b945d43637295ed8f9d349df8ce937367 100644 (file)
@@ -95,14 +95,6 @@ static void ixp4xx_irq_clear(struct ata_port *ap)
 {
 }
 
-static void ixp4xx_host_stop (struct ata_host *host)
-{
-       struct ixp4xx_pata_data *data = host->dev->platform_data;
-
-       iounmap(data->cs0);
-       iounmap(data->cs1);
-}
-
 static struct scsi_host_template ixp4xx_sht = {
        .module                 = THIS_MODULE,
        .name                   = DRV_NAME,
@@ -139,10 +131,10 @@ static struct ata_port_operations ixp4xx_port_ops = {
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ixp4xx_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ixp4xx_host_stop,
 
        .phy_reset      = ixp4xx_phy_reset,
 };
@@ -150,9 +142,9 @@ static struct ata_port_operations ixp4xx_port_ops = {
 static void ixp4xx_setup_port(struct ata_ioports *ioaddr,
                                struct ixp4xx_pata_data *data)
 {
-       ioaddr->cmd_addr        = (unsigned long) data->cs0;
-       ioaddr->altstatus_addr  = (unsigned long) data->cs1 + 0x06;
-       ioaddr->ctl_addr        = (unsigned long) data->cs1 + 0x06;
+       ioaddr->cmd_addr        = data->cs0;
+       ioaddr->altstatus_addr  = data->cs1 + 0x06;
+       ioaddr->ctl_addr        = data->cs1 + 0x06;
 
        ata_std_ports(ioaddr);
 
@@ -162,19 +154,19 @@ static void ixp4xx_setup_port(struct ata_ioports *ioaddr,
         * ixp4xx in little endian mode.
         */
 
-       ioaddr->data_addr       ^= 0x02;
-       ioaddr->cmd_addr        ^= 0x03;
-       ioaddr->altstatus_addr  ^= 0x03;
-       ioaddr->ctl_addr        ^= 0x03;
-       ioaddr->error_addr      ^= 0x03;
-       ioaddr->feature_addr    ^= 0x03;
-       ioaddr->nsect_addr      ^= 0x03;
-       ioaddr->lbal_addr       ^= 0x03;
-       ioaddr->lbam_addr       ^= 0x03;
-       ioaddr->lbah_addr       ^= 0x03;
-       ioaddr->device_addr     ^= 0x03;
-       ioaddr->status_addr     ^= 0x03;
-       ioaddr->command_addr    ^= 0x03;
+       *(unsigned long *)&ioaddr->data_addr            ^= 0x02;
+       *(unsigned long *)&ioaddr->cmd_addr             ^= 0x03;
+       *(unsigned long *)&ioaddr->altstatus_addr       ^= 0x03;
+       *(unsigned long *)&ioaddr->ctl_addr             ^= 0x03;
+       *(unsigned long *)&ioaddr->error_addr           ^= 0x03;
+       *(unsigned long *)&ioaddr->feature_addr         ^= 0x03;
+       *(unsigned long *)&ioaddr->nsect_addr           ^= 0x03;
+       *(unsigned long *)&ioaddr->lbal_addr            ^= 0x03;
+       *(unsigned long *)&ioaddr->lbam_addr            ^= 0x03;
+       *(unsigned long *)&ioaddr->lbah_addr            ^= 0x03;
+       *(unsigned long *)&ioaddr->device_addr          ^= 0x03;
+       *(unsigned long *)&ioaddr->status_addr          ^= 0x03;
+       *(unsigned long *)&ioaddr->command_addr         ^= 0x03;
 #endif
 }
 
@@ -195,8 +187,8 @@ static __devinit int ixp4xx_pata_probe(struct platform_device *pdev)
 
        pdev->dev.coherent_dma_mask = DMA_32BIT_MASK;
 
-       data->cs0 = ioremap(cs0->start, 0x1000);
-       data->cs1 = ioremap(cs1->start, 0x1000);
+       data->cs0 = devm_ioremap(&pdev->dev, cs0->start, 0x1000);
+       data->cs1 = devm_ioremap(&pdev->dev, cs1->start, 0x1000);
 
        irq = platform_get_irq(pdev, 0);
        if (irq)
@@ -238,7 +230,7 @@ static __devexit int ixp4xx_pata_remove(struct platform_device *dev)
 {
        struct ata_host *host = platform_get_drvdata(dev);
 
-       ata_host_remove(host);
+       ata_host_detach(host);
        platform_set_drvdata(dev, NULL);
 
        return 0;
index d50264af284811d164b231f4a4d01e352b8751d0..7a635dd326f85825d044a957d906a827497145c6 100644 (file)
@@ -161,16 +161,16 @@ static const struct ata_port_operations jmicron_ops = {
        .bmdma_status           = ata_bmdma_status,
        .qc_prep                = ata_qc_prep,
        .qc_issue               = ata_qc_issue_prot,
-       .data_xfer              = ata_pio_data_xfer,
+       .data_xfer              = ata_data_xfer,
 
        /* IRQ-related hooks */
        .irq_handler            = ata_interrupt,
        .irq_clear              = ata_bmdma_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
 
        /* Generic PATA PCI ATA helpers */
        .port_start             = ata_port_start,
-       .port_stop              = ata_port_stop,
-       .host_stop              = ata_host_stop,
 };
 
 
@@ -221,7 +221,7 @@ static int jmicron_init_one (struct pci_dev *pdev, const struct pci_device_id *i
 static int jmicron_reinit_one(struct pci_dev *pdev)
 {
        u32 reg;
-       
+
        switch(pdev->device) {
                case PCI_DEVICE_ID_JMICRON_JMB368:
                        break;
index 581cb33c6f456df927ac4ba2f88a601dc042b50e..4223e10de6a0aed4ecf8c4f3cba57e179901910a 100644 (file)
@@ -164,14 +164,14 @@ static struct ata_port_operations simple_port_ops = {
        .qc_prep        = ata_qc_prep,
        .qc_issue       = ata_qc_issue_prot,
 
-       .data_xfer      = ata_pio_data_xfer_noirq,
+       .data_xfer      = ata_data_xfer_noirq,
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 static struct ata_port_operations legacy_port_ops = {
@@ -189,14 +189,14 @@ static struct ata_port_operations legacy_port_ops = {
        .qc_prep        = ata_qc_prep,
        .qc_issue       = ata_qc_issue_prot,
 
-       .data_xfer      = ata_pio_data_xfer_noirq,
+       .data_xfer      = ata_data_xfer_noirq,
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 /*
@@ -257,31 +257,33 @@ static void pdc_data_xfer_vlb(struct ata_device *adev, unsigned char *buf, unsig
                local_irq_save(flags);
 
                /* Perform the 32bit I/O synchronization sequence */
-               inb(ap->ioaddr.nsect_addr);
-               inb(ap->ioaddr.nsect_addr);
-               inb(ap->ioaddr.nsect_addr);
+               ioread8(ap->ioaddr.nsect_addr);
+               ioread8(ap->ioaddr.nsect_addr);
+               ioread8(ap->ioaddr.nsect_addr);
 
                /* Now the data */
 
                if (write_data)
-                       outsl(ap->ioaddr.data_addr, buf, buflen >> 2);
+                       iowrite32_rep(ap->ioaddr.data_addr, buf, buflen >> 2);
                else
-                       insl(ap->ioaddr.data_addr, buf, buflen >> 2);
+                       ioread32_rep(ap->ioaddr.data_addr, buf, buflen >> 2);
 
                if (unlikely(slop)) {
                        u32 pad;
                        if (write_data) {
                                memcpy(&pad, buf + buflen - slop, slop);
-                               outl(le32_to_cpu(pad), ap->ioaddr.data_addr);
+                               pad = le32_to_cpu(pad);
+                               iowrite32(pad, ap->ioaddr.data_addr);
                        } else {
-                               pad = cpu_to_le16(inl(ap->ioaddr.data_addr));
+                               pad = ioread32(ap->ioaddr.data_addr);
+                               pad = cpu_to_le16(pad);
                                memcpy(buf + buflen - slop, &pad, slop);
                        }
                }
                local_irq_restore(flags);
        }
        else
-               ata_pio_data_xfer_noirq(adev, buf, buflen, write_data);
+               ata_data_xfer_noirq(adev, buf, buflen, write_data);
 }
 
 static struct ata_port_operations pdc20230_port_ops = {
@@ -303,10 +305,10 @@ static struct ata_port_operations pdc20230_port_ops = {
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 /*
@@ -332,8 +334,8 @@ static void ht6560a_set_piomode(struct ata_port *ap, struct ata_device *adev)
        inb(0x3E6);
        inb(0x3E6);
 
-       outb(recover << 4 | active, ap->ioaddr.device_addr);
-       inb(ap->ioaddr.status_addr);
+       iowrite8(recover << 4 | active, ap->ioaddr.device_addr);
+       ioread8(ap->ioaddr.status_addr);
 }
 
 static struct ata_port_operations ht6560a_port_ops = {
@@ -351,14 +353,14 @@ static struct ata_port_operations ht6560a_port_ops = {
        .qc_prep        = ata_qc_prep,
        .qc_issue       = ata_qc_issue_prot,
 
-       .data_xfer      = ata_pio_data_xfer,    /* Check vlb/noirq */
+       .data_xfer      = ata_data_xfer,        /* Check vlb/noirq */
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 /*
@@ -387,7 +389,7 @@ static void ht6560b_set_piomode(struct ata_port *ap, struct ata_device *adev)
        inb(0x3E6);
        inb(0x3E6);
 
-       outb(recover << 4 | active, ap->ioaddr.device_addr);
+       iowrite8(recover << 4 | active, ap->ioaddr.device_addr);
 
        if (adev->class != ATA_DEV_ATA) {
                u8 rconf = inb(0x3E6);
@@ -396,7 +398,7 @@ static void ht6560b_set_piomode(struct ata_port *ap, struct ata_device *adev)
                        outb(rconf, 0x3E6);
                }
        }
-       inb(ap->ioaddr.status_addr);
+       ioread8(ap->ioaddr.status_addr);
 }
 
 static struct ata_port_operations ht6560b_port_ops = {
@@ -414,14 +416,14 @@ static struct ata_port_operations ht6560b_port_ops = {
        .qc_prep        = ata_qc_prep,
        .qc_issue       = ata_qc_issue_prot,
 
-       .data_xfer      = ata_pio_data_xfer,    /* FIXME: Check 32bit and noirq */
+       .data_xfer      = ata_data_xfer,        /* FIXME: Check 32bit and noirq */
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 /*
@@ -464,12 +466,12 @@ static void opti82c611a_set_piomode(struct ata_port *ap, struct ata_device *adev
        u8 rc;
 
        /* Enter configuration mode */
-       inw(ap->ioaddr.error_addr);
-       inw(ap->ioaddr.error_addr);
-       outb(3, ap->ioaddr.nsect_addr);
+       ioread16(ap->ioaddr.error_addr);
+       ioread16(ap->ioaddr.error_addr);
+       iowrite8(3, ap->ioaddr.nsect_addr);
 
        /* Read VLB clock strapping */
-       clock = 1000000000 / khz[inb(ap->ioaddr.lbah_addr) & 0x03];
+       clock = 1000000000 / khz[ioread8(ap->ioaddr.lbah_addr) & 0x03];
 
        /* Get the timing data in cycles */
        ata_timing_compute(adev, adev->pio_mode, &t, clock, 1000);
@@ -487,33 +489,33 @@ static void opti82c611a_set_piomode(struct ata_port *ap, struct ata_device *adev
        setup = FIT(t.setup, 1, 4) - 1;
 
        /* Select the right timing bank for write timing */
-       rc = inb(ap->ioaddr.lbal_addr);
+       rc = ioread8(ap->ioaddr.lbal_addr);
        rc &= 0x7F;
        rc |= (adev->devno << 7);
-       outb(rc, ap->ioaddr.lbal_addr);
+       iowrite8(rc, ap->ioaddr.lbal_addr);
 
        /* Write the timings */
-       outb(active << 4 | recover, ap->ioaddr.error_addr);
+       iowrite8(active << 4 | recover, ap->ioaddr.error_addr);
 
        /* Select the right bank for read timings, also
           load the shared timings for address */
-       rc = inb(ap->ioaddr.device_addr);
+       rc = ioread8(ap->ioaddr.device_addr);
        rc &= 0xC0;
        rc |= adev->devno;      /* Index select */
        rc |= (setup << 4) | 0x04;
-       outb(rc, ap->ioaddr.device_addr);
+       iowrite8(rc, ap->ioaddr.device_addr);
 
        /* Load the read timings */
-       outb(active << 4 | recover, ap->ioaddr.data_addr);
+       iowrite8(active << 4 | recover, ap->ioaddr.data_addr);
 
        /* Ensure the timing register mode is right */
-       rc = inb (ap->ioaddr.lbal_addr);
+       rc = ioread8(ap->ioaddr.lbal_addr);
        rc &= 0x73;
        rc |= 0x84;
-       outb(rc, ap->ioaddr.lbal_addr);
+       iowrite8(rc, ap->ioaddr.lbal_addr);
 
        /* Exit command mode */
-       outb(0x83,  ap->ioaddr.nsect_addr);
+       iowrite8(0x83,  ap->ioaddr.nsect_addr);
 }
 
 
@@ -532,14 +534,14 @@ static struct ata_port_operations opti82c611a_port_ops = {
        .qc_prep        = ata_qc_prep,
        .qc_issue       = ata_qc_issue_prot,
 
-       .data_xfer      = ata_pio_data_xfer,
+       .data_xfer      = ata_data_xfer,
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 /*
@@ -563,9 +565,9 @@ static void opti82c46x_set_piomode(struct ata_port *ap, struct ata_device *adev)
        sysclk = opti_syscfg(0xAC) & 0xC0;      /* BIOS set */
 
        /* Enter configuration mode */
-       inw(ap->ioaddr.error_addr);
-       inw(ap->ioaddr.error_addr);
-       outb(3, ap->ioaddr.nsect_addr);
+       ioread16(ap->ioaddr.error_addr);
+       ioread16(ap->ioaddr.error_addr);
+       iowrite8(3, ap->ioaddr.nsect_addr);
 
        /* Read VLB clock strapping */
        clock = 1000000000 / khz[sysclk];
@@ -586,33 +588,33 @@ static void opti82c46x_set_piomode(struct ata_port *ap, struct ata_device *adev)
        setup = FIT(t.setup, 1, 4) - 1;
 
        /* Select the right timing bank for write timing */
-       rc = inb(ap->ioaddr.lbal_addr);
+       rc = ioread8(ap->ioaddr.lbal_addr);
        rc &= 0x7F;
        rc |= (adev->devno << 7);
-       outb(rc, ap->ioaddr.lbal_addr);
+       iowrite8(rc, ap->ioaddr.lbal_addr);
 
        /* Write the timings */
-       outb(active << 4 | recover, ap->ioaddr.error_addr);
+       iowrite8(active << 4 | recover, ap->ioaddr.error_addr);
 
        /* Select the right bank for read timings, also
           load the shared timings for address */
-       rc = inb(ap->ioaddr.device_addr);
+       rc = ioread8(ap->ioaddr.device_addr);
        rc &= 0xC0;
        rc |= adev->devno;      /* Index select */
        rc |= (setup << 4) | 0x04;
-       outb(rc, ap->ioaddr.device_addr);
+       iowrite8(rc, ap->ioaddr.device_addr);
 
        /* Load the read timings */
-       outb(active << 4 | recover, ap->ioaddr.data_addr);
+       iowrite8(active << 4 | recover, ap->ioaddr.data_addr);
 
        /* Ensure the timing register mode is right */
-       rc = inb (ap->ioaddr.lbal_addr);
+       rc = ioread8(ap->ioaddr.lbal_addr);
        rc &= 0x73;
        rc |= 0x84;
-       outb(rc, ap->ioaddr.lbal_addr);
+       iowrite8(rc, ap->ioaddr.lbal_addr);
 
        /* Exit command mode */
-       outb(0x83,  ap->ioaddr.nsect_addr);
+       iowrite8(0x83,  ap->ioaddr.nsect_addr);
 
        /* We need to know this for quad device on the MVB */
        ap->host->private_data = ap;
@@ -662,14 +664,14 @@ static struct ata_port_operations opti82c46x_port_ops = {
        .qc_prep        = ata_qc_prep,
        .qc_issue       = opti82c46x_qc_issue_prot,
 
-       .data_xfer      = ata_pio_data_xfer,
+       .data_xfer      = ata_data_xfer,
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 
@@ -689,21 +691,26 @@ static __init int legacy_init_one(int port, unsigned long io, unsigned long ctrl
        struct legacy_data *ld = &legacy_data[nr_legacy_host];
        struct ata_probe_ent ae;
        struct platform_device *pdev;
-       int ret = -EBUSY;
        struct ata_port_operations *ops = &legacy_port_ops;
+       void __iomem *io_addr, *ctrl_addr;
        int pio_modes = pio_mask;
        u32 mask = (1 << port);
-
-       if (request_region(io, 8, "pata_legacy") == NULL)
-               return -EBUSY;
-       if (request_region(ctrl, 1, "pata_legacy") == NULL)
-               goto fail_io;
+       int ret;
 
        pdev = platform_device_register_simple(DRV_NAME, nr_legacy_host, NULL, 0);
-       if (IS_ERR(pdev)) {
-               ret = PTR_ERR(pdev);
-               goto fail_dev;
-       }
+       if (IS_ERR(pdev))
+               return PTR_ERR(pdev);
+
+       ret = -EBUSY;
+       if (devm_request_region(&pdev->dev, io, 8, "pata_legacy") == NULL ||
+           devm_request_region(&pdev->dev, ctrl, 1, "pata_legacy") == NULL)
+               goto fail;
+
+       ret = -ENOMEM;
+       io_addr = devm_ioport_map(&pdev->dev, io, 8);
+       ctrl_addr = devm_ioport_map(&pdev->dev, ctrl, 1);
+       if (!io_addr || !ctrl_addr)
+               goto fail;
 
        if (ht6560a & mask) {
                ops = &ht6560a_port_ops;
@@ -770,27 +777,22 @@ static __init int legacy_init_one(int port, unsigned long io, unsigned long ctrl
        ae.irq = irq;
        ae.irq_flags = 0;
        ae.port_flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST;
-       ae.port[0].cmd_addr = io;
-       ae.port[0].altstatus_addr = ctrl;
-       ae.port[0].ctl_addr =   ctrl;
+       ae.port[0].cmd_addr = io_addr;
+       ae.port[0].altstatus_addr = ctrl_addr;
+       ae.port[0].ctl_addr = ctrl_addr;
        ata_std_ports(&ae.port[0]);
        ae.private_data = ld;
 
-       ret = ata_device_add(&ae);
-       if (ret == 0) {
-               ret = -ENODEV;
+       ret = -ENODEV;
+       if (!ata_device_add(&ae))
                goto fail;
-       }
+
        legacy_host[nr_legacy_host++] = dev_get_drvdata(&pdev->dev);
        ld->platform_dev = pdev;
        return 0;
 
 fail:
        platform_device_unregister(pdev);
-fail_dev:
-       release_region(ctrl, 1);
-fail_io:
-       release_region(io, 8);
        return ret;
 }
 
@@ -923,15 +925,11 @@ static __exit void legacy_exit(void)
 
        for (i = 0; i < nr_legacy_host; i++) {
                struct legacy_data *ld = &legacy_data[i];
-               struct ata_port *ap =legacy_host[i]->ports[0];
-               unsigned long io = ap->ioaddr.cmd_addr;
-               unsigned long ctrl = ap->ioaddr.ctl_addr;
-               ata_host_remove(legacy_host[i]);
+
+               ata_host_detach(legacy_host[i]);
                platform_device_unregister(ld->platform_dev);
                if (ld->timing)
                        release_region(ld->timing, 2);
-               release_region(io, 8);
-               release_region(ctrl, 1);
        }
 }
 
index 1c810ea0025374bbb7df98a5da47960690d9d730..13a70ac6f1dc2f536b132229ac7706aa87e7d6e5 100644 (file)
@@ -45,10 +45,10 @@ static int marvell_pre_reset(struct ata_port *ap)
        for(i = 0; i <= 0x0F; i++)
                printk("%02X:%02X ", i, readb(barp + i));
        printk("\n");
-       
+
        devices = readl(barp + 0x0C);
        pci_iounmap(pdev, barp);
-       
+
        if ((pdev->device == 0x6145) && (ap->port_no == 0) &&
            (!(devices & 0x10)))        /* PATA enable ? */
                return -ENOENT;
@@ -57,7 +57,7 @@ static int marvell_pre_reset(struct ata_port *ap)
        switch(ap->port_no)
        {
        case 0:
-               if (inb(ap->ioaddr.bmdma_addr + 1) & 1)
+               if (ioread8(ap->ioaddr.bmdma_addr + 1) & 1)
                        ap->cbl = ATA_CBL_PATA40;
                else
                        ap->cbl = ATA_CBL_PATA80;
@@ -129,16 +129,16 @@ static const struct ata_port_operations marvell_ops = {
        .bmdma_status           = ata_bmdma_status,
        .qc_prep                = ata_qc_prep,
        .qc_issue               = ata_qc_issue_prot,
-       .data_xfer              = ata_pio_data_xfer,
+       .data_xfer              = ata_data_xfer,
 
        /* Timeout handling */
        .irq_handler            = ata_interrupt,
        .irq_clear              = ata_bmdma_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
 
        /* Generic PATA PCI ATA helpers */
        .port_start             = ata_port_start,
-       .port_stop              = ata_port_stop,
-       .host_stop              = ata_host_stop,
 };
 
 
diff --git a/drivers/ata/pata_mpc52xx.c b/drivers/ata/pata_mpc52xx.c
new file mode 100644 (file)
index 0000000..d7378df
--- /dev/null
@@ -0,0 +1,538 @@
+/*
+ * drivers/ata/pata_mpc52xx.c
+ *
+ * libata driver for the Freescale MPC52xx on-chip IDE interface
+ *
+ * Copyright (C) 2006 Sylvain Munaut <tnt@246tNt.com>
+ * Copyright (C) 2003 Mipsys - Benjamin Herrenschmidt
+ *
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2. This program is licensed "as is" without any warranty of any
+ * kind, whether express or implied.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/delay.h>
+#include <linux/libata.h>
+
+#include <asm/types.h>
+#include <asm/prom.h>
+#include <asm/of_platform.h>
+#include <asm/mpc52xx.h>
+
+
+#define DRV_NAME       "mpc52xx_ata"
+#define DRV_VERSION    "0.1.0"
+
+
+/* Private structures used by the driver */
+struct mpc52xx_ata_timings {
+       u32     pio1;
+       u32     pio2;
+};
+
+struct mpc52xx_ata_priv {
+       unsigned int                    ipb_period;
+       struct mpc52xx_ata __iomem *    ata_regs;
+       int                             ata_irq;
+       struct mpc52xx_ata_timings      timings[2];
+       int                             csel;
+};
+
+
+/* ATAPI-4 PIO specs (in ns) */
+static const int ataspec_t0[5]    = {600, 383, 240, 180, 120};
+static const int ataspec_t1[5]    = { 70,  50,  30,  30,  25};
+static const int ataspec_t2_8[5]  = {290, 290, 290,  80,  70};
+static const int ataspec_t2_16[5] = {165, 125, 100,  80,  70};
+static const int ataspec_t2i[5]   = {  0,   0,   0,  70,  25};
+static const int ataspec_t4[5]    = { 30,  20,  15,  10,  10};
+static const int ataspec_ta[5]    = { 35,  35,  35,  35,  35};
+
+#define CALC_CLKCYC(c,v) ((((v)+(c)-1)/(c)))
+
+
+/* Bit definitions inside the registers */
+#define MPC52xx_ATA_HOSTCONF_SMR       0x80000000UL /* State machine reset */
+#define MPC52xx_ATA_HOSTCONF_FR                0x40000000UL /* FIFO Reset */
+#define MPC52xx_ATA_HOSTCONF_IE                0x02000000UL /* Enable interrupt in PIO */
+#define MPC52xx_ATA_HOSTCONF_IORDY     0x01000000UL /* Drive supports IORDY protocol */
+
+#define MPC52xx_ATA_HOSTSTAT_TIP       0x80000000UL /* Transaction in progress */
+#define MPC52xx_ATA_HOSTSTAT_UREP      0x40000000UL /* UDMA Read Extended Pause */
+#define MPC52xx_ATA_HOSTSTAT_RERR      0x02000000UL /* Read Error */
+#define MPC52xx_ATA_HOSTSTAT_WERR      0x01000000UL /* Write Error */
+
+#define MPC52xx_ATA_FIFOSTAT_EMPTY     0x01 /* FIFO Empty */
+
+#define MPC52xx_ATA_DMAMODE_WRITE      0x01 /* Write DMA */
+#define MPC52xx_ATA_DMAMODE_READ       0x02 /* Read DMA */
+#define MPC52xx_ATA_DMAMODE_UDMA       0x04 /* UDMA enabled */
+#define MPC52xx_ATA_DMAMODE_IE         0x08 /* Enable drive interrupt to CPU in DMA mode */
+#define MPC52xx_ATA_DMAMODE_FE         0x10 /* FIFO Flush enable in Rx mode */
+#define MPC52xx_ATA_DMAMODE_FR         0x20 /* FIFO Reset */
+#define MPC52xx_ATA_DMAMODE_HUT                0x40 /* Host UDMA burst terminate */
+
+
+/* Structure of the hardware registers */
+struct mpc52xx_ata {
+
+       /* Host interface registers */
+       u32 config;             /* ATA + 0x00 Host configuration */
+       u32 host_status;        /* ATA + 0x04 Host controller status */
+       u32 pio1;               /* ATA + 0x08 PIO Timing 1 */
+       u32 pio2;               /* ATA + 0x0c PIO Timing 2 */
+       u32 mdma1;              /* ATA + 0x10 MDMA Timing 1 */
+       u32 mdma2;              /* ATA + 0x14 MDMA Timing 2 */
+       u32 udma1;              /* ATA + 0x18 UDMA Timing 1 */
+       u32 udma2;              /* ATA + 0x1c UDMA Timing 2 */
+       u32 udma3;              /* ATA + 0x20 UDMA Timing 3 */
+       u32 udma4;              /* ATA + 0x24 UDMA Timing 4 */
+       u32 udma5;              /* ATA + 0x28 UDMA Timing 5 */
+       u32 share_cnt;          /* ATA + 0x2c ATA share counter */
+       u32 reserved0[3];
+
+       /* FIFO registers */
+       u32 fifo_data;          /* ATA + 0x3c */
+       u8  fifo_status_frame;  /* ATA + 0x40 */
+       u8  fifo_status;        /* ATA + 0x41 */
+       u16 reserved7[1];
+       u8  fifo_control;       /* ATA + 0x44 */
+       u8  reserved8[5];
+       u16 fifo_alarm;         /* ATA + 0x4a */
+       u16 reserved9;
+       u16 fifo_rdp;           /* ATA + 0x4e */
+       u16 reserved10;
+       u16 fifo_wrp;           /* ATA + 0x52 */
+       u16 reserved11;
+       u16 fifo_lfrdp;         /* ATA + 0x56 */
+       u16 reserved12;
+       u16 fifo_lfwrp;         /* ATA + 0x5a */
+
+       /* Drive TaskFile registers */
+       u8  tf_control;         /* ATA + 0x5c TASKFILE Control/Alt Status */
+       u8  reserved13[3];
+       u16 tf_data;            /* ATA + 0x60 TASKFILE Data */
+       u16 reserved14;
+       u8  tf_features;        /* ATA + 0x64 TASKFILE Features/Error */
+       u8  reserved15[3];
+       u8  tf_sec_count;       /* ATA + 0x68 TASKFILE Sector Count */
+       u8  reserved16[3];
+       u8  tf_sec_num;         /* ATA + 0x6c TASKFILE Sector Number */
+       u8  reserved17[3];
+       u8  tf_cyl_low;         /* ATA + 0x70 TASKFILE Cylinder Low */
+       u8  reserved18[3];
+       u8  tf_cyl_high;        /* ATA + 0x74 TASKFILE Cylinder High */
+       u8  reserved19[3];
+       u8  tf_dev_head;        /* ATA + 0x78 TASKFILE Device/Head */
+       u8  reserved20[3];
+       u8  tf_command;         /* ATA + 0x7c TASKFILE Command/Status */
+       u8  dma_mode;           /* ATA + 0x7d ATA Host DMA Mode configuration */
+       u8  reserved21[2];
+};
+
+
+/* ======================================================================== */
+/* Aux fns                                                                  */
+/* ======================================================================== */
+
+
+/* MPC52xx low level hw control */
+
+static int
+mpc52xx_ata_compute_pio_timings(struct mpc52xx_ata_priv *priv, int dev, int pio)
+{
+       struct mpc52xx_ata_timings *timing = &priv->timings[dev];
+       unsigned int ipb_period = priv->ipb_period;
+       unsigned int t0, t1, t2_8, t2_16, t2i, t4, ta;
+
+       if ((pio<0) || (pio>4))
+               return -EINVAL;
+
+       t0      = CALC_CLKCYC(ipb_period, 1000 * ataspec_t0[pio]);
+       t1      = CALC_CLKCYC(ipb_period, 1000 * ataspec_t1[pio]);
+       t2_8    = CALC_CLKCYC(ipb_period, 1000 * ataspec_t2_8[pio]);
+       t2_16   = CALC_CLKCYC(ipb_period, 1000 * ataspec_t2_16[pio]);
+       t2i     = CALC_CLKCYC(ipb_period, 1000 * ataspec_t2i[pio]);
+       t4      = CALC_CLKCYC(ipb_period, 1000 * ataspec_t4[pio]);
+       ta      = CALC_CLKCYC(ipb_period, 1000 * ataspec_ta[pio]);
+
+       timing->pio1 = (t0 << 24) | (t2_8 << 16) | (t2_16 << 8) | (t2i);
+       timing->pio2 = (t4 << 24) | (t1 << 16) | (ta << 8);
+
+       return 0;
+}
+
+static void
+mpc52xx_ata_apply_timings(struct mpc52xx_ata_priv *priv, int device)
+{
+       struct mpc52xx_ata __iomem *regs = priv->ata_regs;
+       struct mpc52xx_ata_timings *timing = &priv->timings[device];
+
+       out_be32(&regs->pio1,  timing->pio1);
+       out_be32(&regs->pio2,  timing->pio2);
+       out_be32(&regs->mdma1, 0);
+       out_be32(&regs->mdma2, 0);
+       out_be32(&regs->udma1, 0);
+       out_be32(&regs->udma2, 0);
+       out_be32(&regs->udma3, 0);
+       out_be32(&regs->udma4, 0);
+       out_be32(&regs->udma5, 0);
+
+       priv->csel = device;
+}
+
+static int
+mpc52xx_ata_hw_init(struct mpc52xx_ata_priv *priv)
+{
+       struct mpc52xx_ata __iomem *regs = priv->ata_regs;
+       int tslot;
+
+       /* Clear share_cnt (all sample code do this ...) */
+       out_be32(&regs->share_cnt, 0);
+
+       /* Configure and reset host */
+       out_be32(&regs->config,
+                       MPC52xx_ATA_HOSTCONF_IE |
+                       MPC52xx_ATA_HOSTCONF_IORDY |
+                       MPC52xx_ATA_HOSTCONF_SMR |
+                       MPC52xx_ATA_HOSTCONF_FR);
+
+       udelay(10);
+
+       out_be32(&regs->config,
+                       MPC52xx_ATA_HOSTCONF_IE |
+                       MPC52xx_ATA_HOSTCONF_IORDY);
+
+       /* Set the time slot to 1us */
+       tslot = CALC_CLKCYC(priv->ipb_period, 1000000);
+       out_be32(&regs->share_cnt, tslot << 16 );
+
+       /* Init timings to PIO0 */
+       memset(priv->timings, 0x00, 2*sizeof(struct mpc52xx_ata_timings));
+
+       mpc52xx_ata_compute_pio_timings(priv, 0, 0);
+       mpc52xx_ata_compute_pio_timings(priv, 1, 0);
+
+       mpc52xx_ata_apply_timings(priv, 0);
+
+       return 0;
+}
+
+
+/* ======================================================================== */
+/* libata driver                                                            */
+/* ======================================================================== */
+
+static void
+mpc52xx_ata_set_piomode(struct ata_port *ap, struct ata_device *adev)
+{
+       struct mpc52xx_ata_priv *priv = ap->host->private_data;
+       int pio, rv;
+
+       pio = adev->pio_mode - XFER_PIO_0;
+
+       rv = mpc52xx_ata_compute_pio_timings(priv, adev->devno, pio);
+
+       if (rv) {
+               printk(KERN_ERR DRV_NAME
+                       ": Trying to select invalid PIO mode %d\n", pio);
+               return;
+       }
+
+       mpc52xx_ata_apply_timings(priv, adev->devno);
+}
+static void
+mpc52xx_ata_dev_select(struct ata_port *ap, unsigned int device)
+{
+       struct mpc52xx_ata_priv *priv = ap->host->private_data;
+
+       if (device != priv->csel)
+               mpc52xx_ata_apply_timings(priv, device);
+
+       ata_std_dev_select(ap,device);
+}
+
+static void
+mpc52xx_ata_error_handler(struct ata_port *ap)
+{
+       ata_bmdma_drive_eh(ap, ata_std_prereset, ata_std_softreset, NULL,
+                       ata_std_postreset);
+}
+
+
+
+static struct scsi_host_template mpc52xx_ata_sht = {
+       .module                 = THIS_MODULE,
+       .name                   = DRV_NAME,
+       .ioctl                  = ata_scsi_ioctl,
+       .queuecommand           = ata_scsi_queuecmd,
+       .can_queue              = ATA_DEF_QUEUE,
+       .this_id                = ATA_SHT_THIS_ID,
+       .sg_tablesize           = LIBATA_MAX_PRD,
+       .max_sectors            = ATA_MAX_SECTORS,
+       .cmd_per_lun            = ATA_SHT_CMD_PER_LUN,
+       .emulated               = ATA_SHT_EMULATED,
+       .use_clustering         = ATA_SHT_USE_CLUSTERING,
+       .proc_name              = DRV_NAME,
+       .dma_boundary           = ATA_DMA_BOUNDARY,
+       .slave_configure        = ata_scsi_slave_config,
+       .bios_param             = ata_std_bios_param,
+};
+
+static struct ata_port_operations mpc52xx_ata_port_ops = {
+       .port_disable           = ata_port_disable,
+       .set_piomode            = mpc52xx_ata_set_piomode,
+       .dev_select             = mpc52xx_ata_dev_select,
+       .tf_load                = ata_tf_load,
+       .tf_read                = ata_tf_read,
+       .check_status           = ata_check_status,
+       .exec_command           = ata_exec_command,
+       .freeze                 = ata_bmdma_freeze,
+       .thaw                   = ata_bmdma_thaw,
+       .error_handler          = mpc52xx_ata_error_handler,
+       .qc_prep                = ata_qc_prep,
+       .qc_issue               = ata_qc_issue_prot,
+       .data_xfer              = ata_data_xfer,
+       .irq_handler            = ata_interrupt,
+       .irq_clear              = ata_bmdma_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
+       .port_start             = ata_port_start,
+};
+
+static struct ata_probe_ent mpc52xx_ata_probe_ent = {
+       .port_ops       = &mpc52xx_ata_port_ops,
+       .sht            = &mpc52xx_ata_sht,
+       .n_ports        = 1,
+       .pio_mask       = 0x1f,         /* Up to PIO4 */
+       .mwdma_mask     = 0x00,         /* No MWDMA   */
+       .udma_mask      = 0x00,         /* No UDMA    */
+       .port_flags     = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
+       .irq_flags      = 0,
+};
+
+static int __devinit
+mpc52xx_ata_init_one(struct device *dev, struct mpc52xx_ata_priv *priv)
+{
+       struct ata_probe_ent *ae = &mpc52xx_ata_probe_ent;
+       struct ata_ioports *aio = &ae->port[0];
+       int rv;
+
+       INIT_LIST_HEAD(&ae->node);
+       ae->dev = dev;
+       ae->irq = priv->ata_irq;
+
+       aio->cmd_addr           = 0;    /* Don't have a classic reg block */
+       aio->altstatus_addr     = &priv->ata_regs->tf_control;
+       aio->ctl_addr           = &priv->ata_regs->tf_control;
+       aio->data_addr          = &priv->ata_regs->tf_data;
+       aio->error_addr         = &priv->ata_regs->tf_features;
+       aio->feature_addr       = &priv->ata_regs->tf_features;
+       aio->nsect_addr         = &priv->ata_regs->tf_sec_count;
+       aio->lbal_addr          = &priv->ata_regs->tf_sec_num;
+       aio->lbam_addr          = &priv->ata_regs->tf_cyl_low;
+       aio->lbah_addr          = &priv->ata_regs->tf_cyl_high;
+       aio->device_addr        = &priv->ata_regs->tf_dev_head;
+       aio->status_addr        = &priv->ata_regs->tf_command;
+       aio->command_addr       = &priv->ata_regs->tf_command;
+
+       ae->private_data = priv;
+
+       rv = ata_device_add(ae);
+
+       return rv ? 0 : -EINVAL;
+}
+
+static struct mpc52xx_ata_priv *
+mpc52xx_ata_remove_one(struct device *dev)
+{
+       struct ata_host *host = dev_get_drvdata(dev);
+       struct mpc52xx_ata_priv *priv = host->private_data;
+
+       ata_host_detach(host);
+
+       return priv;
+}
+
+
+/* ======================================================================== */
+/* OF Platform driver                                                       */
+/* ======================================================================== */
+
+static int __devinit
+mpc52xx_ata_probe(struct of_device *op, const struct of_device_id *match)
+{
+       unsigned int ipb_freq;
+       struct resource res_mem;
+       int ata_irq = NO_IRQ;
+       struct mpc52xx_ata __iomem *ata_regs;
+       struct mpc52xx_ata_priv *priv;
+       int rv;
+
+       /* Get ipb frequency */
+       ipb_freq = mpc52xx_find_ipb_freq(op->node);
+       if (!ipb_freq) {
+               printk(KERN_ERR DRV_NAME ": "
+                       "Unable to find IPB Bus frequency\n" );
+               return -ENODEV;
+       }
+
+       /* Get IRQ and register */
+       rv = of_address_to_resource(op->node, 0, &res_mem);
+       if (rv) {
+               printk(KERN_ERR DRV_NAME ": "
+                       "Error while parsing device node resource\n" );
+               return rv;
+       }
+
+       ata_irq = irq_of_parse_and_map(op->node, 0);
+       if (ata_irq == NO_IRQ) {
+               printk(KERN_ERR DRV_NAME ": "
+                       "Error while mapping the irq\n");
+               return -EINVAL;
+       }
+
+       /* Request mem region */
+       if (!devm_request_mem_region(&op->dev, res_mem.start,
+                                    sizeof(struct mpc52xx_ata), DRV_NAME)) {
+               printk(KERN_ERR DRV_NAME ": "
+                       "Error while requesting mem region\n");
+               rv = -EBUSY;
+               goto err;
+       }
+
+       /* Remap registers */
+       ata_regs = devm_ioremap(&op->dev, res_mem.start,
+                               sizeof(struct mpc52xx_ata));
+       if (!ata_regs) {
+               printk(KERN_ERR DRV_NAME ": "
+                       "Error while mapping register set\n");
+               rv = -ENOMEM;
+               goto err;
+       }
+
+       /* Prepare our private structure */
+       priv = devm_kzalloc(&op->dev, sizeof(struct mpc52xx_ata_priv),
+                           GFP_ATOMIC);
+       if (!priv) {
+               printk(KERN_ERR DRV_NAME ": "
+                       "Error while allocating private structure\n");
+               rv = -ENOMEM;
+               goto err;
+       }
+
+       priv->ipb_period = 1000000000 / (ipb_freq / 1000);
+       priv->ata_regs = ata_regs;
+       priv->ata_irq = ata_irq;
+       priv->csel = -1;
+
+       /* Init the hw */
+       rv = mpc52xx_ata_hw_init(priv);
+       if (rv) {
+               printk(KERN_ERR DRV_NAME ": Error during HW init\n");
+               goto err;
+       }
+
+       /* Register ourselves to libata */
+       rv = mpc52xx_ata_init_one(&op->dev, priv);
+       if (rv) {
+               printk(KERN_ERR DRV_NAME ": "
+                       "Error while registering to ATA layer\n");
+               return rv;
+       }
+
+       /* Done */
+       return 0;
+
+       /* Error path */
+err:
+       irq_dispose_mapping(ata_irq);
+       return rv;
+}
+
+static int
+mpc52xx_ata_remove(struct of_device *op)
+{
+       struct mpc52xx_ata_priv *priv;
+
+       priv = mpc52xx_ata_remove_one(&op->dev);
+       irq_dispose_mapping(priv->ata_irq);
+
+       return 0;
+}
+
+
+#ifdef CONFIG_PM
+
+static int
+mpc52xx_ata_suspend(struct of_device *op, pm_message_t state)
+{
+       return 0;       /* FIXME : What to do here ? */
+}
+
+static int
+mpc52xx_ata_resume(struct of_device *op)
+{
+       return 0;       /* FIXME : What to do here ? */
+}
+
+#endif
+
+
+static struct of_device_id mpc52xx_ata_of_match[] = {
+       {
+               .compatible = "mpc5200-ata",
+       },
+       {
+               .compatible = "mpc52xx-ata",
+       },
+       {},
+};
+
+
+static struct of_platform_driver mpc52xx_ata_of_platform_driver = {
+       .owner          = THIS_MODULE,
+       .name           = DRV_NAME,
+       .match_table    = mpc52xx_ata_of_match,
+       .probe          = mpc52xx_ata_probe,
+       .remove         = mpc52xx_ata_remove,
+#ifdef CONFIG_PM
+       .suspend        = mpc52xx_ata_suspend,
+       .resume         = mpc52xx_ata_resume,
+#endif
+       .driver         = {
+               .name   = DRV_NAME,
+               .owner  = THIS_MODULE,
+       },
+};
+
+
+/* ======================================================================== */
+/* Module                                                                   */
+/* ======================================================================== */
+
+static int __init
+mpc52xx_ata_init(void)
+{
+       printk(KERN_INFO "ata: MPC52xx IDE/ATA libata driver\n");
+       return of_register_platform_driver(&mpc52xx_ata_of_platform_driver);
+}
+
+static void __exit
+mpc52xx_ata_exit(void)
+{
+       of_unregister_platform_driver(&mpc52xx_ata_of_platform_driver);
+}
+
+module_init(mpc52xx_ata_init);
+module_exit(mpc52xx_ata_exit);
+
+MODULE_AUTHOR("Sylvain Munaut <tnt@246tNt.com>");
+MODULE_DESCRIPTION("Freescale MPC52xx IDE/ATA libata driver");
+MODULE_LICENSE("GPL");
+MODULE_DEVICE_TABLE(of, mpc52xx_ata_of_match);
+MODULE_VERSION(DRV_VERSION);
+
index 4ccca938675e754a295d78d2c9510662627e1563..ca8c965179b13a05f308e5bae65d7efc1ff798fc 100644 (file)
@@ -35,7 +35,7 @@
 #include <linux/libata.h>
 
 #define DRV_NAME "pata_mpiix"
-#define DRV_VERSION "0.7.3"
+#define DRV_VERSION "0.7.5"
 
 enum {
        IDETIM = 0x6C,          /* IDE control register */
@@ -49,12 +49,9 @@ enum {
 static int mpiix_pre_reset(struct ata_port *ap)
 {
        struct pci_dev *pdev = to_pci_dev(ap->host->dev);
-       static const struct pci_bits mpiix_enable_bits[] = {
-               { 0x6D, 1, 0x80, 0x80 },
-               { 0x6F, 1, 0x80, 0x80 }
-       };
+       static const struct pci_bits mpiix_enable_bits = { 0x6D, 1, 0x80, 0x80 };
 
-       if (!pci_test_config_bits(pdev, &mpiix_enable_bits[ap->port_no]))
+       if (!pci_test_config_bits(pdev, &mpiix_enable_bits))
                return -ENOENT;
        ap->cbl = ATA_CBL_PATA40;
        return ata_std_prereset(ap);
@@ -80,8 +77,8 @@ static void mpiix_error_handler(struct ata_port *ap)
  *     @adev: ATA device
  *
  *     Called to do the PIO mode setup. The MPIIX allows us to program the
- *     IORDY sample point (2-5 clocks), recovery 1-4 clocks and whether
- *     prefetching or iordy are used.
+ *     IORDY sample point (2-5 clocks), recovery (1-4 clocks) and whether
+ *     prefetching or IORDY are used.
  *
  *     This would get very ugly because we can only program timing for one
  *     device at a time, the other gets PIO0. Fortunately libata calls
@@ -103,18 +100,19 @@ static void mpiix_set_piomode(struct ata_port *ap, struct ata_device *adev)
                            { 2, 3 }, };
 
        pci_read_config_word(pdev, IDETIM, &idetim);
-       /* Mask the IORDY/TIME/PPE0 bank for this device */
+
+       /* Mask the IORDY/TIME/PPE for this device */
        if (adev->class == ATA_DEV_ATA)
-               control |= PPE;         /* PPE enable for disk */
+               control |= PPE;         /* Enable prefetch/posting for disk */
        if (ata_pio_need_iordy(adev))
-               control |= IORDY;       /* IORDY */
-       if (pio > 0)
+               control |= IORDY;
+       if (pio > 1)
                control |= FTIM;        /* This drive is on the fast timing bank */
 
        /* Mask out timing and clear both TIME bank selects */
        idetim &= 0xCCEE;
-       idetim &= ~(0x07  << (2 * adev->devno));
-       idetim |= (control << (2 * adev->devno));
+       idetim &= ~(0x07  << (4 * adev->devno));
+       idetim |= control << (4 * adev->devno);
 
        idetim |= (timings[pio][0] << 12) | (timings[pio][1] << 8);
        pci_write_config_word(pdev, IDETIM, idetim);
@@ -188,23 +186,24 @@ static struct ata_port_operations mpiix_port_ops = {
 
        .qc_prep        = ata_qc_prep,
        .qc_issue       = mpiix_qc_issue_prot,
-       .data_xfer      = ata_pio_data_xfer,
+       .data_xfer      = ata_data_xfer,
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 static int mpiix_init_one(struct pci_dev *dev, const struct pci_device_id *id)
 {
        /* Single threaded by the PCI probe logic */
-       static struct ata_probe_ent probe[2];
+       static struct ata_probe_ent probe;
        static int printed_version;
+       void __iomem *cmd_addr, *ctl_addr;
        u16 idetim;
-       int enabled;
+       int irq;
 
        if (!printed_version++)
                dev_printk(KERN_DEBUG, &dev->dev, "version " DRV_VERSION "\n");
@@ -217,65 +216,49 @@ static int mpiix_init_one(struct pci_dev *dev, const struct pci_device_id *id)
        if (!(idetim & ENABLED))
                return -ENODEV;
 
+       /* See if it's primary or secondary channel... */
+       if (!(idetim & SECONDARY)) {
+               irq = 14;
+               cmd_addr = devm_ioport_map(&dev->dev, 0x1F0, 8);
+               ctl_addr = devm_ioport_map(&dev->dev, 0x3F6, 1);
+       } else {
+               irq = 15;
+               cmd_addr = devm_ioport_map(&dev->dev, 0x170, 8);
+               ctl_addr = devm_ioport_map(&dev->dev, 0x376, 1);
+       }
+
+       if (!cmd_addr || !ctl_addr)
+               return -ENOMEM;
+
        /* We do our own plumbing to avoid leaking special cases for whacko
           ancient hardware into the core code. There are two issues to
           worry about.  #1 The chip is a bridge so if in legacy mode and
           without BARs set fools the setup.  #2 If you pci_disable_device
           the MPIIX your box goes castors up */
 
-       INIT_LIST_HEAD(&probe[0].node);
-       probe[0].dev = pci_dev_to_dev(dev);
-       probe[0].port_ops = &mpiix_port_ops;
-       probe[0].sht = &mpiix_sht;
-       probe[0].pio_mask = 0x1F;
-       probe[0].irq = 14;
-       probe[0].irq_flags = SA_SHIRQ;
-       probe[0].port_flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST;
-       probe[0].n_ports = 1;
-       probe[0].port[0].cmd_addr = 0x1F0;
-       probe[0].port[0].ctl_addr = 0x3F6;
-       probe[0].port[0].altstatus_addr = 0x3F6;
-
-       /* The secondary lurks at different addresses but is otherwise
-          the same beastie */
-
-       INIT_LIST_HEAD(&probe[1].node);
-       probe[1] = probe[0];
-       probe[1].irq = 15;
-       probe[1].port[0].cmd_addr = 0x170;
-       probe[1].port[0].ctl_addr = 0x376;
-       probe[1].port[0].altstatus_addr = 0x376;
+       INIT_LIST_HEAD(&probe.node);
+       probe.dev = pci_dev_to_dev(dev);
+       probe.port_ops = &mpiix_port_ops;
+       probe.sht = &mpiix_sht;
+       probe.pio_mask = 0x1F;
+       probe.irq_flags = SA_SHIRQ;
+       probe.port_flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST;
+       probe.n_ports = 1;
+
+       probe.irq = irq;
+       probe.port[0].cmd_addr = cmd_addr;
+       probe.port[0].ctl_addr = ctl_addr;
+       probe.port[0].altstatus_addr = ctl_addr;
 
        /* Let libata fill in the port details */
-       ata_std_ports(&probe[0].port[0]);
-       ata_std_ports(&probe[1].port[0]);
+       ata_std_ports(&probe.port[0]);
 
        /* Now add the port that is active */
-       enabled = (idetim & SECONDARY) ? 1 : 0;
-
-       if (ata_device_add(&probe[enabled]))
+       if (ata_device_add(&probe))
                return 0;
        return -ENODEV;
 }
 
-/**
- *     mpiix_remove_one        -       device unload
- *     @pdev: PCI device being removed
- *
- *     Handle an unplug/unload event for a PCI device. Unload the
- *     PCI driver but do not use the default handler as we *MUST NOT*
- *     disable the device as it has other functions.
- */
-
-static void __devexit mpiix_remove_one(struct pci_dev *pdev)
-{
-       struct device *dev = pci_dev_to_dev(pdev);
-       struct ata_host *host = dev_get_drvdata(dev);
-
-       ata_host_remove(host);
-       dev_set_drvdata(dev, NULL);
-}
-
 static const struct pci_device_id mpiix[] = {
        { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82371MX), },
 
@@ -286,7 +269,7 @@ static struct pci_driver mpiix_pci_driver = {
        .name           = DRV_NAME,
        .id_table       = mpiix,
        .probe          = mpiix_init_one,
-       .remove         = mpiix_remove_one,
+       .remove         = ata_pci_remove_one,
        .suspend        = ata_pci_device_suspend,
        .resume         = ata_pci_device_resume,
 };
index cf7fe037471c3e94660f97655885d53646a0295f..e8393e19be47d94b9c06b13e2a16ca157b9c9cce 100644 (file)
@@ -89,16 +89,16 @@ static const struct ata_port_operations netcell_ops = {
        .bmdma_status           = ata_bmdma_status,
        .qc_prep                = ata_qc_prep,
        .qc_issue               = ata_qc_issue_prot,
-       .data_xfer              = ata_pio_data_xfer,
+       .data_xfer              = ata_data_xfer,
 
        /* IRQ-related hooks */
        .irq_handler            = ata_interrupt,
        .irq_clear              = ata_bmdma_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
 
        /* Generic PATA PCI ATA helpers */
        .port_start             = ata_port_start,
-       .port_stop              = ata_port_stop,
-       .host_stop              = ata_host_stop,
 };
 
 
index c3032eb9010dfa4b6405f44f3daea6bb7477b469..3d1fa487c48606aa0ac745f4b023ad8a818aff4c 100644 (file)
@@ -179,14 +179,14 @@ static struct ata_port_operations ns87410_port_ops = {
        .qc_prep        = ata_qc_prep,
        .qc_issue       = ns87410_qc_issue_prot,
 
-       .data_xfer      = ata_pio_data_xfer,
+       .data_xfer      = ata_data_xfer,
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 static int ns87410_init_one(struct pci_dev *dev, const struct pci_device_id *id)
index 10ac3cc10181cbd5b48cd45dcac06f6637797bc6..45215aa05e72b92a8b2b7d3c7be6804d5e2cbd0c 100644 (file)
@@ -25,7 +25,7 @@
 #include <linux/ata.h>
 
 #define DRV_NAME       "pata_oldpiix"
-#define DRV_VERSION    "0.5.2"
+#define DRV_VERSION    "0.5.3"
 
 /**
  *     oldpiix_pre_reset               -       probe begin
@@ -94,19 +94,21 @@ static void oldpiix_set_piomode (struct ata_port *ap, struct ata_device *adev)
                            { 2, 1 },
                            { 2, 3 }, };
 
-       if (pio > 2)
-               control |= 1;   /* TIME1 enable */
+       if (pio > 1)
+               control |= 1;   /* TIME */
        if (ata_pio_need_iordy(adev))
-               control |= 2;   /* IE IORDY */
+               control |= 2;   /* IE */
 
-       /* Intel specifies that the PPE functionality is for disk only */
+       /* Intel specifies that the prefetch/posting is for disk only */
        if (adev->class == ATA_DEV_ATA)
-               control |= 4;   /* PPE enable */
+               control |= 4;   /* PPE */
 
        pci_read_config_word(dev, idetm_port, &idetm_data);
 
-       /* Enable PPE, IE and TIME as appropriate. Clear the other
-          drive timing bits */
+       /*
+        * Set PPE, IE and TIME as appropriate.
+        * Clear the other drive's timing bits.
+        */
        if (adev->devno == 0) {
                idetm_data &= 0xCCE0;
                idetm_data |= control;
@@ -259,14 +261,14 @@ static const struct ata_port_operations oldpiix_pata_ops = {
        .bmdma_status           = ata_bmdma_status,
        .qc_prep                = ata_qc_prep,
        .qc_issue               = oldpiix_qc_issue_prot,
-       .data_xfer              = ata_pio_data_xfer,
+       .data_xfer              = ata_data_xfer,
 
        .irq_handler            = ata_interrupt,
        .irq_clear              = ata_bmdma_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
 
        .port_start             = ata_port_start,
-       .port_stop              = ata_port_stop,
-       .host_stop              = ata_host_stop,
 };
 
 
index c2988b0aa8ea07f30f73054ab97e5729ed733ecd..da1aa148b37d9f69b5d91c88b57608f1e7d65461 100644 (file)
@@ -95,18 +95,18 @@ static void opti_error_handler(struct ata_port *ap)
 
 static void opti_write_reg(struct ata_port *ap, u8 val, int reg)
 {
-       unsigned long regio = ap->ioaddr.cmd_addr;
+       void __iomem *regio = ap->ioaddr.cmd_addr;
 
        /* These 3 unlock the control register access */
-       inw(regio + 1);
-       inw(regio + 1);
-       outb(3, regio + 2);
+       ioread16(regio + 1);
+       ioread16(regio + 1);
+       iowrite8(3, regio + 2);
 
        /* Do the I/O */
-       outb(val, regio + reg);
+       iowrite8(val, regio + reg);
 
        /* Relock */
-       outb(0x83, regio + 2);
+       iowrite8(0x83, regio + 2);
 }
 
 /**
@@ -124,7 +124,7 @@ static void opti_set_piomode(struct ata_port *ap, struct ata_device *adev)
        struct ata_device *pair = ata_dev_pair(adev);
        int clock;
        int pio = adev->pio_mode - XFER_PIO_0;
-       unsigned long regio = ap->ioaddr.cmd_addr;
+       void __iomem *regio = ap->ioaddr.cmd_addr;
        u8 addr;
 
        /* Address table precomputed with prefetch off and a DCLK of 2 */
@@ -137,8 +137,8 @@ static void opti_set_piomode(struct ata_port *ap, struct ata_device *adev)
                { 0x58, 0x44, 0x32, 0x22, 0x21 }
        };
 
-       outb(0xff, regio + 5);
-       clock = inw(regio + 5) & 1;
+       iowrite8(0xff, regio + 5);
+       clock = ioread16(regio + 5) & 1;
 
        /*
         *      As with many controllers the address setup time is shared
@@ -205,14 +205,14 @@ static struct ata_port_operations opti_port_ops = {
        .qc_prep        = ata_qc_prep,
        .qc_issue       = ata_qc_issue_prot,
 
-       .data_xfer      = ata_pio_data_xfer,
+       .data_xfer      = ata_data_xfer,
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 static int opti_init_one(struct pci_dev *dev, const struct pci_device_id *id)
index 80d111c569dc25db5fc74d76e199a31bf3c28a03..d80b36e209cc52bc6de595d414caecb32163a975 100644 (file)
@@ -91,12 +91,12 @@ static void optidma_error_handler(struct ata_port *ap)
 
 static void optidma_unlock(struct ata_port *ap)
 {
-       unsigned long regio = ap->ioaddr.cmd_addr;
+       void __iomem *regio = ap->ioaddr.cmd_addr;
 
        /* These 3 unlock the control register access */
-       inw(regio + 1);
-       inw(regio + 1);
-       outb(3, regio + 2);
+       ioread16(regio + 1);
+       ioread16(regio + 1);
+       iowrite8(3, regio + 2);
 }
 
 /**
@@ -108,10 +108,10 @@ static void optidma_unlock(struct ata_port *ap)
 
 static void optidma_lock(struct ata_port *ap)
 {
-       unsigned long regio = ap->ioaddr.cmd_addr;
+       void __iomem *regio = ap->ioaddr.cmd_addr;
 
        /* Relock */
-       outb(0x83, regio + 2);
+       iowrite8(0x83, regio + 2);
 }
 
 /**
@@ -133,7 +133,7 @@ static void optidma_set_mode(struct ata_port *ap, struct ata_device *adev, u8 mo
        struct ata_device *pair = ata_dev_pair(adev);
        int pio = adev->pio_mode - XFER_PIO_0;
        int dma = adev->dma_mode - XFER_MW_DMA_0;
-       unsigned long regio = ap->ioaddr.cmd_addr;
+       void __iomem *regio = ap->ioaddr.cmd_addr;
        u8 addr;
 
        /* Address table precomputed with a DCLK of 2 */
@@ -178,20 +178,20 @@ static void optidma_set_mode(struct ata_port *ap, struct ata_device *adev, u8 mo
 
        /* Commence primary programming sequence */
        /* First we load the device number into the timing select */
-       outb(adev->devno, regio + MISC_REG);
+       iowrite8(adev->devno, regio + MISC_REG);
        /* Now we load the data timings into read data/write data */
        if (mode < XFER_MW_DMA_0) {
-               outb(data_rec_timing[pci_clock][pio], regio + READ_REG);
-               outb(data_rec_timing[pci_clock][pio], regio + WRITE_REG);
+               iowrite8(data_rec_timing[pci_clock][pio], regio + READ_REG);
+               iowrite8(data_rec_timing[pci_clock][pio], regio + WRITE_REG);
        } else if (mode < XFER_UDMA_0) {
-               outb(dma_data_rec_timing[pci_clock][dma], regio + READ_REG);
-               outb(dma_data_rec_timing[pci_clock][dma], regio + WRITE_REG);
+               iowrite8(dma_data_rec_timing[pci_clock][dma], regio + READ_REG);
+               iowrite8(dma_data_rec_timing[pci_clock][dma], regio + WRITE_REG);
        }
        /* Finally we load the address setup into the misc register */
-       outb(addr | adev->devno, regio + MISC_REG);
+       iowrite8(addr | adev->devno, regio + MISC_REG);
 
        /* Programming sequence complete, timing 0 dev 0, timing 1 dev 1 */
-       outb(0x85, regio + CNTRL_REG);
+       iowrite8(0x85, regio + CNTRL_REG);
 
        /* Switch back to IDE mode */
        optidma_lock(ap);
@@ -389,14 +389,14 @@ static struct ata_port_operations optidma_port_ops = {
        .qc_prep        = ata_qc_prep,
        .qc_issue       = ata_qc_issue_prot,
 
-       .data_xfer      = ata_pio_data_xfer,
+       .data_xfer      = ata_data_xfer,
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 static struct ata_port_operations optiplus_port_ops = {
@@ -424,14 +424,14 @@ static struct ata_port_operations optiplus_port_ops = {
        .qc_prep        = ata_qc_prep,
        .qc_issue       = ata_qc_issue_prot,
 
-       .data_xfer      = ata_pio_data_xfer,
+       .data_xfer      = ata_data_xfer,
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 /**
index 9ed7f58424a3a31214fb3b436f00510cb07a9264..acfc09f9abd9cc8b56b2cf8d6adc73878dbd6d77 100644 (file)
@@ -88,14 +88,14 @@ static struct ata_port_operations pcmcia_port_ops = {
        .qc_prep        = ata_qc_prep,
        .qc_issue       = ata_qc_issue_prot,
 
-       .data_xfer      = ata_pio_data_xfer_noirq,
+       .data_xfer      = ata_data_xfer_noirq,
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 #define CS_CHECK(fn, ret) \
@@ -123,6 +123,7 @@ static int pcmcia_init_one(struct pcmcia_device *pdev)
        cistpl_cftable_entry_t *cfg;
        int pass, last_ret = 0, last_fn = 0, is_kme = 0, ret = -ENOMEM;
        unsigned long io_base, ctl_base;
+       void __iomem *io_addr, *ctl_addr;
 
        info = kzalloc(sizeof(*info), GFP_KERNEL);
        if (info == NULL)
@@ -233,10 +234,17 @@ next_entry:
        CS_CHECK(RequestIRQ, pcmcia_request_irq(pdev, &pdev->irq));
        CS_CHECK(RequestConfiguration, pcmcia_request_configuration(pdev, &pdev->conf));
 
+       /* iomap */
+       ret = -ENOMEM;
+       io_addr = devm_ioport_map(&pdev->dev, io_base, 8);
+       ctl_addr = devm_ioport_map(&pdev->dev, ctl_base, 1);
+       if (!io_addr || !ctl_addr)
+               goto failed;
+
        /* Success. Disable the IRQ nIEN line, do quirks */
-       outb(0x02, ctl_base);
+       iowrite8(0x02, ctl_addr);
        if (is_kme)
-               outb(0x81, ctl_base + 0x01);
+               iowrite8(0x81, ctl_addr + 0x01);
 
        /* FIXME: Could be more ports at base + 0x10 but we only deal with
           one right now */
@@ -258,11 +266,12 @@ next_entry:
        ae.irq = pdev->irq.AssignedIRQ;
        ae.irq_flags = SA_SHIRQ;
        ae.port_flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST;
-       ae.port[0].cmd_addr = io_base;
-       ae.port[0].altstatus_addr = ctl_base;
-       ae.port[0].ctl_addr = ctl_base;
+       ae.port[0].cmd_addr = io_addr;
+       ae.port[0].altstatus_addr = ctl_addr;
+       ae.port[0].ctl_addr = ctl_addr;
        ata_std_ports(&ae.port[0]);
 
+       ret = -ENODEV;
        if (ata_device_add(&ae) == 0)
                goto failed;
 
@@ -298,7 +307,7 @@ static void pcmcia_remove_one(struct pcmcia_device *pdev)
                /* If we have attached the device to the ATA layer, detach it */
                if (info->ndev) {
                        struct ata_host *host = dev_get_drvdata(dev);
-                       ata_host_remove(host);
+                       ata_host_detach(host);
                        dev_set_drvdata(dev, NULL);
                }
                info->ndev = 0;
index 76dd1c935dbd34449b78d49bbea80dc0587fca45..ffa7f47fbb2086357f7028edab9d43000b021add 100644 (file)
@@ -33,7 +33,6 @@
 #include <scsi/scsi_host.h>
 #include <scsi/scsi_cmnd.h>
 #include <linux/libata.h>
-#include <asm/io.h>
 
 #define DRV_NAME       "pata_pdc2027x"
 #define DRV_VERSION    "0.74-ac5"
@@ -46,6 +45,8 @@
 #endif
 
 enum {
+       PDC_MMIO_BAR            = 5,
+
        PDC_UDMA_100            = 0,
        PDC_UDMA_133            = 1,
 
@@ -62,7 +63,6 @@ enum {
 };
 
 static int pdc2027x_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
-static void pdc2027x_remove_one(struct pci_dev *pdev);
 static void pdc2027x_error_handler(struct ata_port *ap);
 static void pdc2027x_set_piomode(struct ata_port *ap, struct ata_device *adev);
 static void pdc2027x_set_dmamode(struct ata_port *ap, struct ata_device *adev);
@@ -123,7 +123,7 @@ static struct pci_driver pdc2027x_pci_driver = {
        .name                   = DRV_NAME,
        .id_table               = pdc2027x_pci_tbl,
        .probe                  = pdc2027x_init_one,
-       .remove                 = __devexit_p(pdc2027x_remove_one),
+       .remove                 = ata_pci_remove_one,
 };
 
 static struct scsi_host_template pdc2027x_sht = {
@@ -160,7 +160,7 @@ static struct ata_port_operations pdc2027x_pata100_ops = {
        .bmdma_status           = ata_bmdma_status,
        .qc_prep                = ata_qc_prep,
        .qc_issue               = ata_qc_issue_prot,
-       .data_xfer              = ata_mmio_data_xfer,
+       .data_xfer              = ata_data_xfer,
 
        .freeze                 = ata_bmdma_freeze,
        .thaw                   = ata_bmdma_thaw,
@@ -169,10 +169,10 @@ static struct ata_port_operations pdc2027x_pata100_ops = {
 
        .irq_handler            = ata_interrupt,
        .irq_clear              = ata_bmdma_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
 
        .port_start             = ata_port_start,
-       .port_stop              = ata_port_stop,
-       .host_stop              = ata_pci_host_stop,
 };
 
 static struct ata_port_operations pdc2027x_pata133_ops = {
@@ -194,7 +194,7 @@ static struct ata_port_operations pdc2027x_pata133_ops = {
        .bmdma_status           = ata_bmdma_status,
        .qc_prep                = ata_qc_prep,
        .qc_issue               = ata_qc_issue_prot,
-       .data_xfer              = ata_mmio_data_xfer,
+       .data_xfer              = ata_data_xfer,
 
        .freeze                 = ata_bmdma_freeze,
        .thaw                   = ata_bmdma_thaw,
@@ -203,10 +203,10 @@ static struct ata_port_operations pdc2027x_pata133_ops = {
 
        .irq_handler            = ata_interrupt,
        .irq_clear              = ata_bmdma_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
 
        .port_start             = ata_port_start,
-       .port_stop              = ata_port_stop,
-       .host_stop              = ata_pci_host_stop,
 };
 
 static struct ata_port_info pdc2027x_port_info[] = {
@@ -245,7 +245,7 @@ MODULE_DEVICE_TABLE(pci, pdc2027x_pci_tbl);
  */
 static inline void __iomem *port_mmio(struct ata_port *ap, unsigned int offset)
 {
-       return ap->host->mmio_base + ap->port_no * 0x100 + offset;
+       return ap->host->iomap[PDC_MMIO_BAR] + ap->port_no * 0x100 + offset;
 }
 
 /**
@@ -526,18 +526,19 @@ static int pdc2027x_check_atapi_dma(struct ata_queued_cmd *qc)
 
 static long pdc_read_counter(struct ata_probe_ent *probe_ent)
 {
+       void __iomem *mmio_base = probe_ent->iomap[PDC_MMIO_BAR];
        long counter;
        int retry = 1;
        u32 bccrl, bccrh, bccrlv, bccrhv;
 
 retry:
-       bccrl = readl(probe_ent->mmio_base + PDC_BYTE_COUNT) & 0xffff;
-       bccrh = readl(probe_ent->mmio_base + PDC_BYTE_COUNT + 0x100) & 0xffff;
+       bccrl = readl(mmio_base + PDC_BYTE_COUNT) & 0xffff;
+       bccrh = readl(mmio_base + PDC_BYTE_COUNT + 0x100) & 0xffff;
        rmb();
 
        /* Read the counter values again for verification */
-       bccrlv = readl(probe_ent->mmio_base + PDC_BYTE_COUNT) & 0xffff;
-       bccrhv = readl(probe_ent->mmio_base + PDC_BYTE_COUNT + 0x100) & 0xffff;
+       bccrlv = readl(mmio_base + PDC_BYTE_COUNT) & 0xffff;
+       bccrhv = readl(mmio_base + PDC_BYTE_COUNT + 0x100) & 0xffff;
        rmb();
 
        counter = (bccrh << 15) | bccrl;
@@ -568,7 +569,7 @@ retry:
  */
 static void pdc_adjust_pll(struct ata_probe_ent *probe_ent, long pll_clock, unsigned int board_idx)
 {
-
+       void __iomem *mmio_base = probe_ent->iomap[PDC_MMIO_BAR];
        u16 pll_ctl;
        long pll_clock_khz = pll_clock / 1000;
        long pout_required = board_idx? PDC_133_MHZ:PDC_100_MHZ;
@@ -587,7 +588,7 @@ static void pdc_adjust_pll(struct ata_probe_ent *probe_ent, long pll_clock, unsi
        /* Show the current clock value of PLL control register
         * (maybe already configured by the firmware)
         */
-       pll_ctl = readw(probe_ent->mmio_base + PDC_PLL_CTL);
+       pll_ctl = readw(mmio_base + PDC_PLL_CTL);
 
        PDPRINTK("pll_ctl[%X]\n", pll_ctl);
 #endif
@@ -627,8 +628,8 @@ static void pdc_adjust_pll(struct ata_probe_ent *probe_ent, long pll_clock, unsi
 
        PDPRINTK("Writing pll_ctl[%X]\n", pll_ctl);
 
-       writew(pll_ctl, probe_ent->mmio_base + PDC_PLL_CTL);
-       readw(probe_ent->mmio_base + PDC_PLL_CTL); /* flush */
+       writew(pll_ctl, mmio_base + PDC_PLL_CTL);
+       readw(mmio_base + PDC_PLL_CTL); /* flush */
 
        /* Wait the PLL circuit to be stable */
        mdelay(30);
@@ -638,7 +639,7 @@ static void pdc_adjust_pll(struct ata_probe_ent *probe_ent, long pll_clock, unsi
         *  Show the current clock value of PLL control register
         * (maybe configured by the firmware)
         */
-       pll_ctl = readw(probe_ent->mmio_base + PDC_PLL_CTL);
+       pll_ctl = readw(mmio_base + PDC_PLL_CTL);
 
        PDPRINTK("pll_ctl[%X]\n", pll_ctl);
 #endif
@@ -654,6 +655,7 @@ static void pdc_adjust_pll(struct ata_probe_ent *probe_ent, long pll_clock, unsi
  */
 static long pdc_detect_pll_input_clock(struct ata_probe_ent *probe_ent)
 {
+       void __iomem *mmio_base = probe_ent->iomap[PDC_MMIO_BAR];
        u32 scr;
        long start_count, end_count;
        long pll_clock;
@@ -662,10 +664,10 @@ static long pdc_detect_pll_input_clock(struct ata_probe_ent *probe_ent)
        start_count = pdc_read_counter(probe_ent);
 
        /* Start the test mode */
-       scr = readl(probe_ent->mmio_base + PDC_SYS_CTL);
+       scr = readl(mmio_base + PDC_SYS_CTL);
        PDPRINTK("scr[%X]\n", scr);
-       writel(scr | (0x01 << 14), probe_ent->mmio_base + PDC_SYS_CTL);
-       readl(probe_ent->mmio_base + PDC_SYS_CTL); /* flush */
+       writel(scr | (0x01 << 14), mmio_base + PDC_SYS_CTL);
+       readl(mmio_base + PDC_SYS_CTL); /* flush */
 
        /* Let the counter run for 100 ms. */
        mdelay(100);
@@ -674,10 +676,10 @@ static long pdc_detect_pll_input_clock(struct ata_probe_ent *probe_ent)
        end_count = pdc_read_counter(probe_ent);
 
        /* Stop the test mode */
-       scr = readl(probe_ent->mmio_base + PDC_SYS_CTL);
+       scr = readl(mmio_base + PDC_SYS_CTL);
        PDPRINTK("scr[%X]\n", scr);
-       writel(scr & ~(0x01 << 14), probe_ent->mmio_base + PDC_SYS_CTL);
-       readl(probe_ent->mmio_base + PDC_SYS_CTL); /* flush */
+       writel(scr & ~(0x01 << 14), mmio_base + PDC_SYS_CTL);
+       readl(mmio_base + PDC_SYS_CTL); /* flush */
 
        /* calculate the input clock in Hz */
        pll_clock = (start_count - end_count) * 10;
@@ -722,7 +724,7 @@ static int pdc_hardware_init(struct pci_dev *pdev, struct ata_probe_ent *pe, uns
  * @port: ata ioports to setup
  * @base: base address
  */
-static void pdc_ata_setup_port(struct ata_ioports *port, unsigned long base)
+static void pdc_ata_setup_port(struct ata_ioports *port, void __iomem *base)
 {
        port->cmd_addr          =
        port->data_addr         = base;
@@ -755,48 +757,37 @@ static int __devinit pdc2027x_init_one(struct pci_dev *pdev, const struct pci_de
        static int printed_version;
        unsigned int board_idx = (unsigned int) ent->driver_data;
 
-       struct ata_probe_ent *probe_ent = NULL;
-       unsigned long base;
+       struct ata_probe_ent *probe_ent;
        void __iomem *mmio_base;
        int rc;
 
        if (!printed_version++)
                dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
 
-       rc = pci_enable_device(pdev);
+       rc = pcim_enable_device(pdev);
        if (rc)
                return rc;
 
-       rc = pci_request_regions(pdev, DRV_NAME);
+       rc = pcim_iomap_regions(pdev, 1 << PDC_MMIO_BAR, DRV_NAME);
        if (rc)
-               goto err_out;
+               return rc;
 
        rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
        if (rc)
-               goto err_out_regions;
+               return rc;
 
        rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK);
        if (rc)
-               goto err_out_regions;
+               return rc;
 
        /* Prepare the probe entry */
-       probe_ent = kzalloc(sizeof(*probe_ent), GFP_KERNEL);
-       if (probe_ent == NULL) {
-               rc = -ENOMEM;
-               goto err_out_regions;
-       }
+       probe_ent = devm_kzalloc(&pdev->dev, sizeof(*probe_ent), GFP_KERNEL);
+       if (probe_ent == NULL)
+               return -ENOMEM;
 
        probe_ent->dev = pci_dev_to_dev(pdev);
        INIT_LIST_HEAD(&probe_ent->node);
 
-       mmio_base = pci_iomap(pdev, 5, 0);
-       if (!mmio_base) {
-               rc = -ENOMEM;
-               goto err_out_free_ent;
-       }
-
-       base = (unsigned long) mmio_base;
-
        probe_ent->sht          = pdc2027x_port_info[board_idx].sht;
        probe_ent->port_flags   = pdc2027x_port_info[board_idx].flags;
        probe_ent->pio_mask     = pdc2027x_port_info[board_idx].pio_mask;
@@ -806,12 +797,14 @@ static int __devinit pdc2027x_init_one(struct pci_dev *pdev, const struct pci_de
 
                probe_ent->irq = pdev->irq;
                probe_ent->irq_flags = SA_SHIRQ;
-       probe_ent->mmio_base = mmio_base;
+       probe_ent->iomap = pcim_iomap_table(pdev);
 
-       pdc_ata_setup_port(&probe_ent->port[0], base + 0x17c0);
-       probe_ent->port[0].bmdma_addr = base + 0x1000;
-       pdc_ata_setup_port(&probe_ent->port[1], base + 0x15c0);
-       probe_ent->port[1].bmdma_addr = base + 0x1008;
+       mmio_base = probe_ent->iomap[PDC_MMIO_BAR];
+
+       pdc_ata_setup_port(&probe_ent->port[0], mmio_base + 0x17c0);
+       probe_ent->port[0].bmdma_addr = mmio_base + 0x1000;
+       pdc_ata_setup_port(&probe_ent->port[1], mmio_base + 0x15c0);
+       probe_ent->port[1].bmdma_addr = mmio_base + 0x1008;
 
        probe_ent->n_ports = 2;
 
@@ -820,32 +813,13 @@ static int __devinit pdc2027x_init_one(struct pci_dev *pdev, const struct pci_de
 
        /* initialize adapter */
        if (pdc_hardware_init(pdev, probe_ent, board_idx) != 0)
-               goto err_out_free_ent;
+               return -EIO;
 
-       ata_device_add(probe_ent);
-       kfree(probe_ent);
+       if (!ata_device_add(probe_ent))
+               return -ENODEV;
 
+       devm_kfree(&pdev->dev, probe_ent);
        return 0;
-
-err_out_free_ent:
-       kfree(probe_ent);
-err_out_regions:
-       pci_release_regions(pdev);
-err_out:
-       pci_disable_device(pdev);
-       return rc;
-}
-
-/**
- * pdc2027x_remove_one - Called to remove a single instance of the
- * adapter.
- *
- * @dev: The PCI device to remove.
- * FIXME: module load/unload not working yet
- */
-static void __devexit pdc2027x_remove_one(struct pci_dev *pdev)
-{
-       ata_pci_remove_one(pdev);
 }
 
 /**
index ad691b9e77434d94bc5491ec250304eb573e970a..6dd63413a523475c82f45cd5c03746b9b13c01b2 100644 (file)
@@ -170,17 +170,17 @@ static void pdc2026x_bmdma_start(struct ata_queued_cmd *qc)
        struct ata_taskfile *tf = &qc->tf;
        int sel66 = ap->port_no ? 0x08: 0x02;
 
-       unsigned long master = ap->host->ports[0]->ioaddr.bmdma_addr;
-       unsigned long clock = master + 0x11;
-       unsigned long atapi_reg = master + 0x20 + (4 * ap->port_no);
+       void __iomem *master = ap->host->ports[0]->ioaddr.bmdma_addr;
+       void __iomem *clock = master + 0x11;
+       void __iomem *atapi_reg = master + 0x20 + (4 * ap->port_no);
 
        u32 len;
 
        /* Check we keep host level locking here */
        if (adev->dma_mode >= XFER_UDMA_2)
-               outb(inb(clock) | sel66, clock);
+               iowrite8(ioread8(clock) | sel66, clock);
        else
-               outb(inb(clock) & ~sel66, clock);
+               iowrite8(ioread8(clock) & ~sel66, clock);
 
        /* The DMA clocks may have been trashed by a reset. FIXME: make conditional
           and move to qc_issue ? */
@@ -189,17 +189,14 @@ static void pdc2026x_bmdma_start(struct ata_queued_cmd *qc)
        /* Cases the state machine will not complete correctly without help */
        if ((tf->flags & ATA_TFLAG_LBA48) ||  tf->protocol == ATA_PROT_ATAPI_DMA)
        {
-               if (tf->flags & ATA_TFLAG_LBA48)
-                       len = qc->nsect * 512;
-               else
-                       len = qc->nbytes;
+               len = qc->nbytes;
 
                if (tf->flags & ATA_TFLAG_WRITE)
                        len |= 0x06000000;
                else
                        len |= 0x05000000;
 
-               outl(len, atapi_reg);
+               iowrite32(len, atapi_reg);
        }
 
        /* Activate DMA */
@@ -222,19 +219,19 @@ static void pdc2026x_bmdma_stop(struct ata_queued_cmd *qc)
 
        int sel66 = ap->port_no ? 0x08: 0x02;
        /* The clock bits are in the same register for both channels */
-       unsigned long master = ap->host->ports[0]->ioaddr.bmdma_addr;
-       unsigned long clock = master + 0x11;
-       unsigned long atapi_reg = master + 0x20 + (4 * ap->port_no);
+       void __iomem *master = ap->host->ports[0]->ioaddr.bmdma_addr;
+       void __iomem *clock = master + 0x11;
+       void __iomem *atapi_reg = master + 0x20 + (4 * ap->port_no);
 
        /* Cases the state machine will not complete correctly */
        if (tf->protocol == ATA_PROT_ATAPI_DMA || ( tf->flags & ATA_TFLAG_LBA48)) {
-               outl(0, atapi_reg);
-               outb(inb(clock) & ~sel66, clock);
+               iowrite32(0, atapi_reg);
+               iowrite8(ioread8(clock) & ~sel66, clock);
        }
        /* Check we keep host level locking here */
        /* Flip back to 33Mhz for PIO */
        if (adev->dma_mode >= XFER_UDMA_2)
-               outb(inb(clock) & ~sel66, clock);
+               iowrite8(ioread8(clock) & ~sel66, clock);
 
        ata_bmdma_stop(qc);
 }
@@ -297,14 +294,14 @@ static struct ata_port_operations pdc2024x_port_ops = {
 
        .qc_prep        = ata_qc_prep,
        .qc_issue       = ata_qc_issue_prot,
-       .data_xfer      = ata_pio_data_xfer,
+       .data_xfer      = ata_data_xfer,
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 static struct ata_port_operations pdc2026x_port_ops = {
@@ -331,14 +328,14 @@ static struct ata_port_operations pdc2026x_port_ops = {
 
        .qc_prep        = ata_qc_prep,
        .qc_issue       = ata_qc_issue_prot,
-       .data_xfer      = ata_pio_data_xfer,
+       .data_xfer      = ata_data_xfer,
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 static int pdc202xx_init_one(struct pci_dev *dev, const struct pci_device_id *id)
index 40ae11cbfda43b5f43207aa6a3e6d8983e873ba5..479a326114e0ca4132740f2e619a793a9ef5046b 100644 (file)
@@ -47,23 +47,6 @@ static int pata_platform_set_mode(struct ata_port *ap, struct ata_device **unuse
        return 0;
 }
 
-static void pata_platform_host_stop(struct ata_host *host)
-{
-       int i;
-
-       /*
-        * Unmap the bases for MMIO
-        */
-       for (i = 0; i < host->n_ports; i++) {
-               struct ata_port *ap = host->ports[i];
-
-               if (ap->flags & ATA_FLAG_MMIO) {
-                       iounmap((void __iomem *)ap->ioaddr.ctl_addr);
-                       iounmap((void __iomem *)ap->ioaddr.cmd_addr);
-               }
-       }
-}
-
 static struct scsi_host_template pata_platform_sht = {
        .module                 = THIS_MODULE,
        .name                   = DRV_NAME,
@@ -100,14 +83,14 @@ static struct ata_port_operations pata_platform_port_ops = {
        .qc_prep                = ata_qc_prep,
        .qc_issue               = ata_qc_issue_prot,
 
-       .data_xfer              = ata_pio_data_xfer_noirq,
+       .data_xfer              = ata_data_xfer_noirq,
 
        .irq_handler            = ata_interrupt,
        .irq_clear              = ata_bmdma_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
 
        .port_start             = ata_port_start,
-       .port_stop              = ata_port_stop,
-       .host_stop              = pata_platform_host_stop
 };
 
 static void pata_platform_setup_port(struct ata_ioports *ioaddr,
@@ -153,7 +136,6 @@ static int __devinit pata_platform_probe(struct platform_device *pdev)
        struct resource *io_res, *ctl_res;
        struct ata_probe_ent ae;
        unsigned int mmio;
-       int ret;
 
        /*
         * Simple resource validation ..
@@ -207,46 +189,29 @@ static int __devinit pata_platform_probe(struct platform_device *pdev)
         * Handle the MMIO case
         */
        if (mmio) {
-               ae.port_flags |= ATA_FLAG_MMIO;
-
-               ae.port[0].cmd_addr = (unsigned long)ioremap(io_res->start,
+               ae.port[0].cmd_addr = devm_ioremap(&pdev->dev, io_res->start,
                                io_res->end - io_res->start + 1);
-               if (unlikely(!ae.port[0].cmd_addr)) {
-                       dev_err(&pdev->dev, "failed to remap IO base\n");
-                       return -ENXIO;
-               }
-
-               ae.port[0].ctl_addr = (unsigned long)ioremap(ctl_res->start,
+               ae.port[0].ctl_addr = devm_ioremap(&pdev->dev, ctl_res->start,
                                ctl_res->end - ctl_res->start + 1);
-               if (unlikely(!ae.port[0].ctl_addr)) {
-                       dev_err(&pdev->dev, "failed to remap CTL base\n");
-                       ret = -ENXIO;
-                       goto bad_remap;
-               }
        } else {
-               ae.port[0].cmd_addr = io_res->start;
-               ae.port[0].ctl_addr = ctl_res->start;
+               ae.port[0].cmd_addr = devm_ioport_map(&pdev->dev, io_res->start,
+                               io_res->end - io_res->start + 1);
+               ae.port[0].ctl_addr = devm_ioport_map(&pdev->dev, ctl_res->start,
+                               ctl_res->end - ctl_res->start + 1);
+       }
+       if (!ae.port[0].cmd_addr || !ae.port[0].ctl_addr) {
+               dev_err(&pdev->dev, "failed to map IO/CTL base\n");
+               return -ENOMEM;
        }
 
        ae.port[0].altstatus_addr = ae.port[0].ctl_addr;
 
        pata_platform_setup_port(&ae.port[0], pdev->dev.platform_data);
 
-       if (unlikely(ata_device_add(&ae) == 0)) {
-               ret = -ENODEV;
-               goto add_failed;
-       }
+       if (unlikely(ata_device_add(&ae) == 0))
+               return -ENODEV;
 
        return 0;
-
-add_failed:
-       if (ae.port[0].ctl_addr && mmio)
-               iounmap((void __iomem *)ae.port[0].ctl_addr);
-bad_remap:
-       if (ae.port[0].cmd_addr && mmio)
-               iounmap((void __iomem *)ae.port[0].cmd_addr);
-
-       return ret;
 }
 
 /**
@@ -261,7 +226,7 @@ static int __devexit pata_platform_remove(struct platform_device *pdev)
        struct device *dev = &pdev->dev;
        struct ata_host *host = dev_get_drvdata(dev);
 
-       ata_host_remove(host);
+       ata_host_detach(host);
        dev_set_drvdata(dev, NULL);
 
        return 0;
index afc0d990e7d6debecea9da3768e39cdc5c2e8364..1b3b4ed8eb194b22a606007561e7bc6e0a2fab69 100644 (file)
@@ -131,22 +131,24 @@ static void qdi_data_xfer(struct ata_device *adev, unsigned char *buf, unsigned
 
        if (ata_id_has_dword_io(adev->id)) {
                if (write_data)
-                       outsl(ap->ioaddr.data_addr, buf, buflen >> 2);
+                       iowrite32_rep(ap->ioaddr.data_addr, buf, buflen >> 2);
                else
-                       insl(ap->ioaddr.data_addr, buf, buflen >> 2);
+                       ioread32_rep(ap->ioaddr.data_addr, buf, buflen >> 2);
 
                if (unlikely(slop)) {
                        u32 pad;
                        if (write_data) {
                                memcpy(&pad, buf + buflen - slop, slop);
-                               outl(le32_to_cpu(pad), ap->ioaddr.data_addr);
+                               pad = le32_to_cpu(pad);
+                               iowrite32(pad, ap->ioaddr.data_addr);
                        } else {
-                               pad = cpu_to_le32(inl(ap->ioaddr.data_addr));
+                               pad = ioread32(ap->ioaddr.data_addr);
+                               pad = cpu_to_le32(pad);
                                memcpy(buf + buflen - slop, &pad, slop);
                        }
                }
        } else
-               ata_pio_data_xfer(adev, buf, buflen, write_data);
+               ata_data_xfer(adev, buf, buflen, write_data);
 }
 
 static struct scsi_host_template qdi_sht = {
@@ -189,10 +191,10 @@ static struct ata_port_operations qdi6500_port_ops = {
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 static struct ata_port_operations qdi6580_port_ops = {
@@ -217,10 +219,10 @@ static struct ata_port_operations qdi6580_port_ops = {
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 /**
@@ -238,10 +240,9 @@ static __init int qdi_init_one(unsigned long port, int type, unsigned long io, i
 {
        struct ata_probe_ent ae;
        struct platform_device *pdev;
+       void __iomem *io_addr, *ctl_addr;
        int ret;
 
-       unsigned long ctrl = io + 0x206;
-
        /*
         *      Fill in a probe structure first of all
         */
@@ -250,6 +251,12 @@ static __init int qdi_init_one(unsigned long port, int type, unsigned long io, i
        if (IS_ERR(pdev))
                return PTR_ERR(pdev);
 
+       ret = -ENOMEM;
+       io_addr = devm_ioport_map(&pdev->dev, io, 8);
+       ctl_addr = devm_ioport_map(&pdev->dev, io + 0x206, 1);
+       if (!io_addr || !ctl_addr)
+               goto fail;
+
        memset(&ae, 0, sizeof(struct ata_probe_ent));
        INIT_LIST_HEAD(&ae.node);
        ae.dev = &pdev->dev;
@@ -267,9 +274,9 @@ static __init int qdi_init_one(unsigned long port, int type, unsigned long io, i
        ae.irq = irq;
        ae.irq_flags = 0;
        ae.port_flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST;
-       ae.port[0].cmd_addr = io;
-       ae.port[0].altstatus_addr = ctrl;
-       ae.port[0].ctl_addr =   ctrl;
+       ae.port[0].cmd_addr = io_addr;
+       ae.port[0].altstatus_addr = ctl_addr;
+       ae.port[0].ctl_addr = ctl_addr;
        ata_std_ports(&ae.port[0]);
 
        /*
@@ -282,14 +289,17 @@ static __init int qdi_init_one(unsigned long port, int type, unsigned long io, i
        qdi_data[nr_qdi_host].platform_dev = pdev;
 
        printk(KERN_INFO DRV_NAME": qd%d at 0x%lx.\n", type, io);
-       ret = ata_device_add(&ae);
-       if (ret == 0) {
-               platform_device_unregister(pdev);
-               return -ENODEV;
-       }
+
+       ret = -ENODEV;
+       if (!ata_device_add(&ae))
+               goto fail;
 
        qdi_host[nr_qdi_host++] = dev_get_drvdata(&pdev->dev);
        return 0;
+
+ fail:
+       platform_device_unregister(pdev);
+       return ret;
 }
 
 /**
@@ -382,7 +392,7 @@ static __exit void qdi_exit(void)
        int i;
 
        for (i = 0; i < nr_qdi_host; i++) {
-               ata_host_remove(qdi_host[i]);
+               ata_host_detach(qdi_host[i]);
                /* Free the control resource. The 6580 dual channel has the resources
                 * claimed as a pair of 2 byte resources so we need no special cases...
                 */
index 065541d034ad200e1cce593545920cf03dbad7f7..0d1e571ef6333572aa19df27b3588691c894cf7f 100644 (file)
@@ -255,14 +255,14 @@ static const struct ata_port_operations radisys_pata_ops = {
        .bmdma_status           = ata_bmdma_status,
        .qc_prep                = ata_qc_prep,
        .qc_issue               = radisys_qc_issue_prot,
-       .data_xfer              = ata_pio_data_xfer,
+       .data_xfer              = ata_data_xfer,
 
        .irq_handler            = ata_interrupt,
        .irq_clear              = ata_bmdma_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
 
        .port_start             = ata_port_start,
-       .port_stop              = ata_port_stop,
-       .host_stop              = ata_host_stop,
 };
 
 
index cec0729225e1a62eb77b0a371b429d6aaa2a6508..71a2bac09e0d90ee7638d9ecc129d7ef1141b5d7 100644 (file)
@@ -115,7 +115,7 @@ static struct ata_port_operations rz1000_port_ops = {
        .qc_prep        = ata_qc_prep,
        .qc_issue       = ata_qc_issue_prot,
 
-       .data_xfer      = ata_pio_data_xfer,
+       .data_xfer      = ata_data_xfer,
 
        .freeze         = ata_bmdma_freeze,
        .thaw           = ata_bmdma_thaw,
@@ -124,10 +124,10 @@ static struct ata_port_operations rz1000_port_ops = {
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 static int rz1000_fifo_disable(struct pci_dev *pdev)
index a3b35bc5039492edae8e1bc35f2759c7d5949096..58e42fbd14f939f9104758a044cda7b2f077ee72 100644 (file)
@@ -220,14 +220,14 @@ static struct ata_port_operations sc1200_port_ops = {
        .qc_prep        = ata_qc_prep,
        .qc_issue       = sc1200_qc_issue_prot,
 
-       .data_xfer      = ata_pio_data_xfer,
+       .data_xfer      = ata_data_xfer,
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 /**
index f02b6a3b0f10fed4dd1b30eecc7cf93b6cee0a88..ad5b43fef3d1a94914d090fc88476ed100a0e2a1 100644 (file)
@@ -218,25 +218,18 @@ static unsigned long serverworks_osb4_filter(const struct ata_port *ap, struct a
 static unsigned long serverworks_csb_filter(const struct ata_port *ap, struct ata_device *adev, unsigned long mask)
 {
        const char *p;
-       char model_num[40];
-       int len, i;
+       char model_num[ATA_ID_PROD_LEN + 1];
+       int i;
 
        /* Disk, UDMA */
        if (adev->class != ATA_DEV_ATA)
                return ata_pci_default_filter(ap, adev, mask);
 
        /* Actually do need to check */
-       ata_id_string(adev->id, model_num, ATA_ID_PROD_OFS, sizeof(model_num));
-       /* Precuationary - why not do this in the libata core ?? */
+       ata_id_c_string(adev->id, model_num, ATA_ID_PROD, sizeof(model_num));
 
-       len = strlen(model_num);
-       while ((len > 0) && (model_num[len - 1] == ' ')) {
-               len--;
-               model_num[len] = 0;
-       }
-
-       for(i = 0; (p = csb_bad_ata100[i]) != NULL; i++) {
-               if (!strncmp(p, model_num, len))
+       for (i = 0; (p = csb_bad_ata100[i]) != NULL; i++) {
+               if (!strcmp(p, model_num))
                        mask &= ~(0x1F << ATA_SHIFT_UDMA);
        }
        return ata_pci_default_filter(ap, adev, mask);
@@ -355,14 +348,14 @@ static struct ata_port_operations serverworks_osb4_port_ops = {
        .qc_prep        = ata_qc_prep,
        .qc_issue       = ata_qc_issue_prot,
 
-       .data_xfer      = ata_pio_data_xfer,
+       .data_xfer      = ata_data_xfer,
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 static struct ata_port_operations serverworks_csb_port_ops = {
@@ -390,14 +383,14 @@ static struct ata_port_operations serverworks_csb_port_ops = {
        .qc_prep        = ata_qc_prep,
        .qc_issue       = ata_qc_issue_prot,
 
-       .data_xfer      = ata_pio_data_xfer,
+       .data_xfer      = ata_data_xfer,
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 static int serverworks_fixup_osb4(struct pci_dev *pdev)
@@ -559,7 +552,7 @@ static int serverworks_reinit_one(struct pci_dev *pdev)
 {
        /* Force master latency timer to 64 PCI clocks */
        pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x40);
-       
+
        switch (pdev->device)
        {
                case PCI_DEVICE_ID_SERVERWORKS_OSB4IDE:
index e8dfd8fc3ff782caf72b3550261e008d02aeae51..ed79fabe025c1e5beed1811da7a447d07205f873 100644 (file)
@@ -252,14 +252,14 @@ static struct ata_port_operations sil680_port_ops = {
        .qc_prep        = ata_qc_prep,
        .qc_issue       = ata_qc_issue_prot,
 
-       .data_xfer      = ata_pio_data_xfer,
+       .data_xfer      = ata_data_xfer,
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 /**
@@ -270,7 +270,7 @@ static struct ata_port_operations sil680_port_ops = {
  *     is powered up on boot and when we resume in case we resumed from RAM.
  *     Returns the final clock settings.
  */
+
 static u8 sil680_init_chip(struct pci_dev *pdev)
 {
        u32 class_rev   = 0;
index 916cedb3d75548457064ae26efb09ead0f62095f..560103d55b2e9a09e784ea6882fc0d0fc5e7149a 100644 (file)
@@ -32,7 +32,9 @@
 #include <scsi/scsi_host.h>
 #include <linux/libata.h>
 #include <linux/ata.h>
+#include "libata.h"
 
+#undef DRV_NAME                /* already defined in libata.h, for libata-core */
 #define DRV_NAME       "pata_sis"
 #define DRV_VERSION    "0.4.5"
 
@@ -43,6 +45,34 @@ struct sis_chipset {
           up code later */
 };
 
+struct sis_laptop {
+       u16 device;
+       u16 subvendor;
+       u16 subdevice;
+};
+
+static const struct sis_laptop sis_laptop[] = {
+       /* devid, subvendor, subdev */
+       { 0x5513, 0x1043, 0x1107 },     /* ASUS A6K */
+       /* end marker */
+       { 0, }
+};
+
+static int sis_short_ata40(struct pci_dev *dev)
+{
+       const struct sis_laptop *lap = &sis_laptop[0];
+
+       while (lap->device) {
+               if (lap->device == dev->device &&
+                   lap->subvendor == dev->subsystem_vendor &&
+                   lap->subdevice == dev->subsystem_device)
+                       return 1;
+               lap++;
+       }
+
+       return 0;
+}
+
 /**
  *     sis_port_base           -       return PCI configuration base for dev
  *     @adev: device
@@ -79,7 +109,7 @@ static int sis_133_pre_reset(struct ata_port *ap)
 
        /* The top bit of this register is the cable detect bit */
        pci_read_config_word(pdev, 0x50 + 2 * ap->port_no, &tmp);
-       if (tmp & 0x8000)
+       if ((tmp & 0x8000) && !sis_short_ata40(pdev))
                ap->cbl = ATA_CBL_PATA40;
        else
                ap->cbl = ATA_CBL_PATA80;
@@ -127,7 +157,7 @@ static int sis_66_pre_reset(struct ata_port *ap)
        /* Older chips keep cable detect in bits 4/5 of reg 0x48 */
        pci_read_config_byte(pdev, 0x48, &tmp);
        tmp >>= ap->port_no;
-       if (tmp & 0x10)
+       if ((tmp & 0x10) && !sis_short_ata40(pdev))
                ap->cbl = ATA_CBL_PATA40;
        else
                ap->cbl = ATA_CBL_PATA80;
@@ -573,14 +603,14 @@ static const struct ata_port_operations sis_133_ops = {
        .bmdma_status           = ata_bmdma_status,
        .qc_prep                = ata_qc_prep,
        .qc_issue               = ata_qc_issue_prot,
-       .data_xfer              = ata_pio_data_xfer,
+       .data_xfer              = ata_data_xfer,
 
        .irq_handler            = ata_interrupt,
        .irq_clear              = ata_bmdma_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
 
        .port_start             = ata_port_start,
-       .port_stop              = ata_port_stop,
-       .host_stop              = ata_host_stop,
 };
 
 static const struct ata_port_operations sis_133_early_ops = {
@@ -606,14 +636,14 @@ static const struct ata_port_operations sis_133_early_ops = {
        .bmdma_status           = ata_bmdma_status,
        .qc_prep                = ata_qc_prep,
        .qc_issue               = ata_qc_issue_prot,
-       .data_xfer              = ata_pio_data_xfer,
+       .data_xfer              = ata_data_xfer,
 
        .irq_handler            = ata_interrupt,
        .irq_clear              = ata_bmdma_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
 
        .port_start             = ata_port_start,
-       .port_stop              = ata_port_stop,
-       .host_stop              = ata_host_stop,
 };
 
 static const struct ata_port_operations sis_100_ops = {
@@ -640,14 +670,14 @@ static const struct ata_port_operations sis_100_ops = {
        .bmdma_status           = ata_bmdma_status,
        .qc_prep                = ata_qc_prep,
        .qc_issue               = ata_qc_issue_prot,
-       .data_xfer              = ata_pio_data_xfer,
+       .data_xfer              = ata_data_xfer,
 
        .irq_handler            = ata_interrupt,
        .irq_clear              = ata_bmdma_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
 
        .port_start             = ata_port_start,
-       .port_stop              = ata_port_stop,
-       .host_stop              = ata_host_stop,
 };
 
 static const struct ata_port_operations sis_66_ops = {
@@ -673,14 +703,14 @@ static const struct ata_port_operations sis_66_ops = {
        .bmdma_status           = ata_bmdma_status,
        .qc_prep                = ata_qc_prep,
        .qc_issue               = ata_qc_issue_prot,
-       .data_xfer              = ata_pio_data_xfer,
+       .data_xfer              = ata_data_xfer,
 
        .irq_handler            = ata_interrupt,
        .irq_clear              = ata_bmdma_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
 
        .port_start             = ata_port_start,
-       .port_stop              = ata_port_stop,
-       .host_stop              = ata_host_stop,
 };
 
 static const struct ata_port_operations sis_old_ops = {
@@ -706,14 +736,14 @@ static const struct ata_port_operations sis_old_ops = {
        .bmdma_status           = ata_bmdma_status,
        .qc_prep                = ata_qc_prep,
        .qc_issue               = ata_qc_issue_prot,
-       .data_xfer              = ata_pio_data_xfer,
+       .data_xfer              = ata_data_xfer,
 
        .irq_handler            = ata_interrupt,
        .irq_clear              = ata_bmdma_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
 
        .port_start             = ata_port_start,
-       .port_stop              = ata_port_stop,
-       .host_stop              = ata_host_stop,
 };
 
 static struct ata_port_info sis_info = {
@@ -753,7 +783,7 @@ static struct ata_port_info sis_info100_early = {
        .pio_mask       = 0x1f, /* pio0-4 */
        .port_ops       = &sis_66_ops,
 };
-static struct ata_port_info sis_info133 = {
+struct ata_port_info sis_info133 = {
        .sht            = &sis_sht,
        .flags          = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
        .pio_mask       = 0x1f, /* pio0-4 */
@@ -768,6 +798,8 @@ static struct ata_port_info sis_info133_early = {
        .port_ops       = &sis_133_early_ops,
 };
 
+/* Privately shared with the SiS180 SATA driver, not for use elsewhere */
+EXPORT_SYMBOL_GPL(sis_info133);
 
 static void sis_fixup(struct pci_dev *pdev, struct sis_chipset *sis)
 {
@@ -847,7 +879,7 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
        struct sis_chipset *chipset = NULL;
 
        static struct sis_chipset sis_chipsets[] = {
-       
+
                { 0x0968, &sis_info133 },
                { 0x0966, &sis_info133 },
                { 0x0965, &sis_info133 },
index e94f515ef54b6468199a78d92d5fc77e52e935de..f2fa158d07ca3fc57f9daa7388707d42ab52cf3e 100644 (file)
@@ -139,13 +139,13 @@ static void sl82c105_set_dmamode(struct ata_port *ap, struct ata_device *adev)
 {
        switch(adev->dma_mode) {
                case XFER_MW_DMA_0:
-                       sl82c105_configure_piomode(ap, adev, 1);
+                       sl82c105_configure_piomode(ap, adev, 0);
                        break;
                case XFER_MW_DMA_1:
                        sl82c105_configure_piomode(ap, adev, 3);
                        break;
                case XFER_MW_DMA_2:
-                       sl82c105_configure_piomode(ap, adev, 3);
+                       sl82c105_configure_piomode(ap, adev, 4);
                        break;
                default:
                        BUG();
@@ -262,14 +262,14 @@ static struct ata_port_operations sl82c105_port_ops = {
        .qc_prep        = ata_qc_prep,
        .qc_issue       = ata_qc_issue_prot,
 
-       .data_xfer      = ata_pio_data_xfer,
+       .data_xfer      = ata_data_xfer,
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 /**
index a142971f13074071612e3326a2119813eb4e2a5e..453ab90b721e5576057ef77ee8a64cce6b1b09cc 100644 (file)
@@ -221,14 +221,14 @@ static struct ata_port_operations triflex_port_ops = {
        .qc_prep        = ata_qc_prep,
        .qc_issue       = ata_qc_issue_prot,
 
-       .data_xfer      = ata_pio_data_xfer,
+       .data_xfer      = ata_data_xfer,
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 static int triflex_init_one(struct pci_dev *dev, const struct pci_device_id *id)
index f0b6c3b7142931a30cb3524a033fb021393a2c47..220fcd6c549296b82154b6f3d7b5a5da1953b337 100644 (file)
@@ -334,14 +334,14 @@ static struct ata_port_operations via_port_ops = {
        .qc_prep        = ata_qc_prep,
        .qc_issue       = ata_qc_issue_prot,
 
-       .data_xfer      = ata_pio_data_xfer,
+       .data_xfer      = ata_data_xfer,
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 static struct ata_port_operations via_port_ops_noirq = {
@@ -369,14 +369,14 @@ static struct ata_port_operations via_port_ops_noirq = {
        .qc_prep        = ata_qc_prep,
        .qc_issue       = ata_qc_issue_prot,
 
-       .data_xfer      = ata_pio_data_xfer_noirq,
+       .data_xfer      = ata_data_xfer_noirq,
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 /**
@@ -391,11 +391,11 @@ static struct ata_port_operations via_port_ops_noirq = {
 static void via_config_fifo(struct pci_dev *pdev, unsigned int flags)
 {
        u8 enable;
-       
+
        /* 0x40 low bits indicate enabled channels */
        pci_read_config_byte(pdev, 0x40 , &enable);
        enable &= 3;
-       
+
        if (flags & VIA_SET_FIFO) {
                static const u8 fifo_setting[4] = {0x00, 0x60, 0x00, 0x20};
                u8 fifo;
@@ -516,7 +516,7 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
 
        /* Initialise the FIFO for the enabled channels. */
        via_config_fifo(pdev, config->flags);
-       
+
        /* Clock set up */
        switch(config->flags & VIA_UDMA) {
                case VIA_UDMA_NONE:
@@ -575,7 +575,7 @@ static int via_reinit_one(struct pci_dev *pdev)
        u32 timing;
        struct ata_host *host = dev_get_drvdata(&pdev->dev);
        const struct via_isa_bridge *config = host->private_data;
-       
+
        via_config_fifo(pdev, config->flags);
 
        if ((config->flags & VIA_UDMA) == VIA_UDMA_66) {
@@ -590,7 +590,7 @@ static int via_reinit_one(struct pci_dev *pdev)
                timing &= ~0x80008;
                pci_write_config_dword(pdev, 0x50, timing);
        }
-       return ata_pci_device_resume(pdev);     
+       return ata_pci_device_resume(pdev);
 }
 
 static const struct pci_device_id via[] = {
index 5d1f518e1cc7ab1d119e08f372004a28afbc840c..0888b4f19f4c900467a158fa0d1bd6c03ad9210a 100644 (file)
@@ -5,7 +5,7 @@
  *    Support for the Winbond 83759A when operating in advanced mode.
  *    Multichip mode is not currently supported.
  */
+
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/pci.h>
@@ -69,7 +69,7 @@ static void winbond_set_piomode(struct ata_port *ap, struct ata_device *adev)
        int timing = 0x88 + (ap->port_no * 4) + (adev->devno * 2);
 
        reg = winbond_readcfg(winbond->config, 0x81);
-       
+
        /* Get the timing data in cycles */
        if (reg & 0x40)         /* Fast VLB bus, assume 50MHz */
                ata_timing_compute(adev, adev->pio_mode, &t, 20000, 1000);
@@ -80,9 +80,9 @@ static void winbond_set_piomode(struct ata_port *ap, struct ata_device *adev)
        recovery = (FIT(t.recover, 1, 15) + 1) & 0x0F;
        timing = (active << 4) | recovery;
        winbond_writecfg(winbond->config, timing, reg);
-       
+
        /* Load the setup timing */
-       
+
        reg = 0x35;
        if (adev->class != ATA_DEV_ATA)
                reg |= 0x08;    /* FIFO off */
@@ -100,22 +100,24 @@ static void winbond_data_xfer(struct ata_device *adev, unsigned char *buf, unsig
 
        if (ata_id_has_dword_io(adev->id)) {
                if (write_data)
-                       outsl(ap->ioaddr.data_addr, buf, buflen >> 2);
+                       iowrite32_rep(ap->ioaddr.data_addr, buf, buflen >> 2);
                else
-                       insl(ap->ioaddr.data_addr, buf, buflen >> 2);
+                       ioread32_rep(ap->ioaddr.data_addr, buf, buflen >> 2);
 
                if (unlikely(slop)) {
                        u32 pad;
                        if (write_data) {
                                memcpy(&pad, buf + buflen - slop, slop);
-                               outl(le32_to_cpu(pad), ap->ioaddr.data_addr);
+                               pad = le32_to_cpu(pad);
+                               iowrite32(pad, ap->ioaddr.data_addr);
                        } else {
-                               pad = cpu_to_le16(inl(ap->ioaddr.data_addr));
+                               pad = ioread32(ap->ioaddr.data_addr);
+                               pad = cpu_to_le16(pad);
                                memcpy(buf + buflen - slop, &pad, slop);
                        }
                }
        } else
-               ata_pio_data_xfer(adev, buf, buflen, write_data);
+               ata_data_xfer(adev, buf, buflen, write_data);
 }
 
 static struct scsi_host_template winbond_sht = {
@@ -158,10 +160,10 @@ static struct ata_port_operations winbond_port_ops = {
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 /**
@@ -194,13 +196,15 @@ static __init int winbond_init_one(unsigned long port)
        winbond_writecfg(port, 0x85, reg);
 
        reg = winbond_readcfg(port, 0x81);
-       
+
        if (!(reg & 0x03))              /* Disabled */
                return 0;
 
        for (i = 0; i < 2 ; i ++) {
+               unsigned long cmd_port = 0x1F0 - (0x80 * i);
+               void __iomem *cmd_addr, *ctl_addr;
 
-               if (reg & (1 << i)) {           
+               if (reg & (1 << i)) {
                        /*
                         *      Fill in a probe structure first of all
                         */
@@ -209,6 +213,13 @@ static __init int winbond_init_one(unsigned long port)
                        if (IS_ERR(pdev))
                                return PTR_ERR(pdev);
 
+                       cmd_addr = devm_ioport_map(&pdev->dev, cmd_port, 8);
+                       ctl_addr = devm_ioport_map(&pdev->dev, cmd_port + 0x0206, 1);
+                       if (!cmd_addr || !ctl_addr) {
+                               platform_device_unregister(pdev);
+                               return -ENOMEM;
+                       }
+
                        memset(&ae, 0, sizeof(struct ata_probe_ent));
                        INIT_LIST_HEAD(&ae.node);
                        ae.dev = &pdev->dev;
@@ -217,14 +228,14 @@ static __init int winbond_init_one(unsigned long port)
                        ae.pio_mask = 0x1F;
 
                        ae.sht = &winbond_sht;
-       
+
                        ae.n_ports = 1;
                        ae.irq = 14 + i;
                        ae.irq_flags = 0;
                        ae.port_flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST;
-                       ae.port[0].cmd_addr = 0x1F0 - (0x80 * i);
-                       ae.port[0].altstatus_addr = ae.port[0].cmd_addr + 0x0206;
-                       ae.port[0].ctl_addr = ae.port[0].altstatus_addr;
+                       ae.port[0].cmd_addr = cmd_addr;
+                       ae.port[0].altstatus_addr = ctl_addr;
+                       ae.port[0].ctl_addr = ctl_addr;
                        ata_std_ports(&ae.port[0]);
                        /*
                         *      Hook in a private data structure per channel
@@ -257,7 +268,7 @@ static __init int winbond_init(void)
 
        int ct = 0;
        int i;
-       
+
        if (probe_winbond == 0)
                return -ENODEV;
 
@@ -288,7 +299,7 @@ static __exit void winbond_exit(void)
        int i;
 
        for (i = 0; i < nr_winbond_host; i++) {
-               ata_host_remove(winbond_host[i]);
+               ata_host_detach(winbond_host[i]);
                release_region(winbond_data[i].config, 2);
                platform_device_unregister(winbond_data[i].platform_dev);
        }
index 90786d7a20bbbfde234167b64ef86a4f0a8fa16b..b4ed8ce553e6845156cb0bb0b2fb542cb2b471e8 100644 (file)
@@ -42,7 +42,6 @@
 #include <linux/sched.h>
 #include <linux/device.h>
 #include <scsi/scsi_host.h>
-#include <asm/io.h>
 #include <linux/libata.h>
 
 #define DRV_NAME       "pdc_adma"
 #define ADMA_ATA_REGS(base,port_no)    ((base) + ((port_no) * 0x40))
 
 /* macro to calculate base address for ADMA regs */
-#define ADMA_REGS(base,port_no)        ((base) + 0x80 + ((port_no) * 0x20))
+#define ADMA_REGS(base,port_no)                ((base) + 0x80 + ((port_no) * 0x20))
+
+/* macro to obtain addresses from ata_host */
+#define ADMA_HOST_REGS(host,port_no) \
+       ADMA_REGS((host)->iomap[ADMA_MMIO_BAR], port_no)
 
 enum {
+       ADMA_MMIO_BAR           = 4,
+
        ADMA_PORTS              = 2,
        ADMA_CPB_BYTES          = 40,
        ADMA_PRD_BYTES          = LIBATA_MAX_PRD * 16,
@@ -167,9 +172,11 @@ static const struct ata_port_operations adma_ata_ops = {
        .qc_prep                = adma_qc_prep,
        .qc_issue               = adma_qc_issue,
        .eng_timeout            = adma_eng_timeout,
-       .data_xfer              = ata_mmio_data_xfer,
+       .data_xfer              = ata_data_xfer,
        .irq_handler            = adma_intr,
        .irq_clear              = adma_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
        .port_start             = adma_port_start,
        .port_stop              = adma_port_stop,
        .host_stop              = adma_host_stop,
@@ -235,11 +242,10 @@ static void adma_reset_engine(void __iomem *chan)
 static void adma_reinit_engine(struct ata_port *ap)
 {
        struct adma_port_priv *pp = ap->private_data;
-       void __iomem *mmio_base = ap->host->mmio_base;
-       void __iomem *chan = ADMA_REGS(mmio_base, ap->port_no);
+       void __iomem *chan = ADMA_HOST_REGS(ap->host, ap->port_no);
 
        /* mask/clear ATA interrupts */
-       writeb(ATA_NIEN, (void __iomem *)ap->ioaddr.ctl_addr);
+       writeb(ATA_NIEN, ap->ioaddr.ctl_addr);
        ata_check_status(ap);
 
        /* reset the ADMA engine */
@@ -263,7 +269,7 @@ static void adma_reinit_engine(struct ata_port *ap)
 
 static inline void adma_enter_reg_mode(struct ata_port *ap)
 {
-       void __iomem *chan = ADMA_REGS(ap->host->mmio_base, ap->port_no);
+       void __iomem *chan = ADMA_HOST_REGS(ap->host, ap->port_no);
 
        writew(aPIOMD4, chan + ADMA_CONTROL);
        readb(chan + ADMA_STATUS);      /* flush */
@@ -410,7 +416,7 @@ static void adma_qc_prep(struct ata_queued_cmd *qc)
 static inline void adma_packet_start(struct ata_queued_cmd *qc)
 {
        struct ata_port *ap = qc->ap;
-       void __iomem *chan = ADMA_REGS(ap->host->mmio_base, ap->port_no);
+       void __iomem *chan = ADMA_HOST_REGS(ap->host, ap->port_no);
 
        VPRINTK("ENTER, ap %p\n", ap);
 
@@ -443,13 +449,12 @@ static unsigned int adma_qc_issue(struct ata_queued_cmd *qc)
 static inline unsigned int adma_intr_pkt(struct ata_host *host)
 {
        unsigned int handled = 0, port_no;
-       u8 __iomem *mmio_base = host->mmio_base;
 
        for (port_no = 0; port_no < host->n_ports; ++port_no) {
                struct ata_port *ap = host->ports[port_no];
                struct adma_port_priv *pp;
                struct ata_queued_cmd *qc;
-               void __iomem *chan = ADMA_REGS(mmio_base, port_no);
+               void __iomem *chan = ADMA_HOST_REGS(host, port_no);
                u8 status = readb(chan + ADMA_STATUS);
 
                if (status == 0)
@@ -523,7 +528,7 @@ static irqreturn_t adma_intr(int irq, void *dev_instance)
        return IRQ_RETVAL(handled);
 }
 
-static void adma_ata_setup_port(struct ata_ioports *port, unsigned long base)
+static void adma_ata_setup_port(struct ata_ioports *port, void __iomem *base)
 {
        port->cmd_addr          =
        port->data_addr         = base + 0x000;
@@ -550,48 +555,28 @@ static int adma_port_start(struct ata_port *ap)
        if (rc)
                return rc;
        adma_enter_reg_mode(ap);
-       rc = -ENOMEM;
-       pp = kzalloc(sizeof(*pp), GFP_KERNEL);
+       pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL);
        if (!pp)
-               goto err_out;
-       pp->pkt = dma_alloc_coherent(dev, ADMA_PKT_BYTES, &pp->pkt_dma,
-                                                               GFP_KERNEL);
+               return -ENOMEM;
+       pp->pkt = dmam_alloc_coherent(dev, ADMA_PKT_BYTES, &pp->pkt_dma,
+                                     GFP_KERNEL);
        if (!pp->pkt)
-               goto err_out_kfree;
+               return -ENOMEM;
        /* paranoia? */
        if ((pp->pkt_dma & 7) != 0) {
                printk("bad alignment for pp->pkt_dma: %08x\n",
                                                (u32)pp->pkt_dma);
-               dma_free_coherent(dev, ADMA_PKT_BYTES,
-                                               pp->pkt, pp->pkt_dma);
-               goto err_out_kfree;
+               return -ENOMEM;
        }
        memset(pp->pkt, 0, ADMA_PKT_BYTES);
        ap->private_data = pp;
        adma_reinit_engine(ap);
        return 0;
-
-err_out_kfree:
-       kfree(pp);
-err_out:
-       ata_port_stop(ap);
-       return rc;
 }
 
 static void adma_port_stop(struct ata_port *ap)
 {
-       struct device *dev = ap->host->dev;
-       struct adma_port_priv *pp = ap->private_data;
-
-       adma_reset_engine(ADMA_REGS(ap->host->mmio_base, ap->port_no));
-       if (pp != NULL) {
-               ap->private_data = NULL;
-               if (pp->pkt != NULL)
-                       dma_free_coherent(dev, ADMA_PKT_BYTES,
-                                       pp->pkt, pp->pkt_dma);
-               kfree(pp);
-       }
-       ata_port_stop(ap);
+       adma_reset_engine(ADMA_HOST_REGS(ap->host, ap->port_no));
 }
 
 static void adma_host_stop(struct ata_host *host)
@@ -599,16 +584,14 @@ static void adma_host_stop(struct ata_host *host)
        unsigned int port_no;
 
        for (port_no = 0; port_no < ADMA_PORTS; ++port_no)
-               adma_reset_engine(ADMA_REGS(host->mmio_base, port_no));
-
-       ata_pci_host_stop(host);
+               adma_reset_engine(ADMA_HOST_REGS(host, port_no));
 }
 
 static void adma_host_init(unsigned int chip_id,
                                struct ata_probe_ent *probe_ent)
 {
        unsigned int port_no;
-       void __iomem *mmio_base = probe_ent->mmio_base;
+       void __iomem *mmio_base = probe_ent->iomap[ADMA_MMIO_BAR];
 
        /* enable/lock aGO operation */
        writeb(7, mmio_base + ADMA_MODE_LOCK);
@@ -638,7 +621,7 @@ static int adma_set_dma_masks(struct pci_dev *pdev, void __iomem *mmio_base)
 }
 
 static int adma_ata_init_one(struct pci_dev *pdev,
-                               const struct pci_device_id *ent)
+                            const struct pci_device_id *ent)
 {
        static int printed_version;
        struct ata_probe_ent *probe_ent = NULL;
@@ -649,34 +632,25 @@ static int adma_ata_init_one(struct pci_dev *pdev,
        if (!printed_version++)
                dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
 
-       rc = pci_enable_device(pdev);
+       rc = pcim_enable_device(pdev);
        if (rc)
                return rc;
 
-       rc = pci_request_regions(pdev, DRV_NAME);
-       if (rc)
-               goto err_out;
-
-       if ((pci_resource_flags(pdev, 4) & IORESOURCE_MEM) == 0) {
-               rc = -ENODEV;
-               goto err_out_regions;
-       }
+       if ((pci_resource_flags(pdev, 4) & IORESOURCE_MEM) == 0)
+               return -ENODEV;
 
-       mmio_base = pci_iomap(pdev, 4, 0);
-       if (mmio_base == NULL) {
-               rc = -ENOMEM;
-               goto err_out_regions;
-       }
+       rc = pcim_iomap_regions(pdev, 1 << ADMA_MMIO_BAR, DRV_NAME);
+       if (rc)
+               return rc;
+       mmio_base = pcim_iomap_table(pdev)[ADMA_MMIO_BAR];
 
        rc = adma_set_dma_masks(pdev, mmio_base);
        if (rc)
-               goto err_out_iounmap;
+               return rc;
 
-       probe_ent = kzalloc(sizeof(*probe_ent), GFP_KERNEL);
-       if (probe_ent == NULL) {
-               rc = -ENOMEM;
-               goto err_out_iounmap;
-       }
+       probe_ent = devm_kzalloc(&pdev->dev, sizeof(*probe_ent), GFP_KERNEL);
+       if (probe_ent == NULL)
+               return -ENOMEM;
 
        probe_ent->dev = pci_dev_to_dev(pdev);
        INIT_LIST_HEAD(&probe_ent->node);
@@ -690,12 +664,12 @@ static int adma_ata_init_one(struct pci_dev *pdev,
 
        probe_ent->irq          = pdev->irq;
        probe_ent->irq_flags    = IRQF_SHARED;
-       probe_ent->mmio_base    = mmio_base;
        probe_ent->n_ports      = ADMA_PORTS;
+       probe_ent->iomap        = pcim_iomap_table(pdev);
 
        for (port_no = 0; port_no < probe_ent->n_ports; ++port_no) {
                adma_ata_setup_port(&probe_ent->port[port_no],
-                       ADMA_ATA_REGS((unsigned long)mmio_base, port_no));
+                                   ADMA_ATA_REGS(mmio_base, port_no));
        }
 
        pci_set_master(pdev);
@@ -703,19 +677,11 @@ static int adma_ata_init_one(struct pci_dev *pdev,
        /* initialize adapter */
        adma_host_init(board_idx, probe_ent);
 
-       rc = ata_device_add(probe_ent);
-       kfree(probe_ent);
-       if (rc != ADMA_PORTS)
-               goto err_out_iounmap;
-       return 0;
+       if (!ata_device_add(probe_ent))
+               return -ENODEV;
 
-err_out_iounmap:
-       pci_iounmap(pdev, mmio_base);
-err_out_regions:
-       pci_release_regions(pdev);
-err_out:
-       pci_disable_device(pdev);
-       return rc;
+       devm_kfree(&pdev->dev, probe_ent);
+       return 0;
 }
 
 static int __init adma_ata_init(void)
diff --git a/drivers/ata/sata_inic162x.c b/drivers/ata/sata_inic162x.c
new file mode 100644 (file)
index 0000000..c5335f4
--- /dev/null
@@ -0,0 +1,781 @@
+/*
+ * sata_inic162x.c - Driver for Initio 162x SATA controllers
+ *
+ * Copyright 2006  SUSE Linux Products GmbH
+ * Copyright 2006  Tejun Heo <teheo@novell.com>
+ *
+ * This file is released under GPL v2.
+ *
+ * This controller is eccentric and easily locks up if something isn't
+ * right.  Documentation is available at initio's website but it only
+ * documents registers (not programming model).
+ *
+ * - ATA disks work.
+ * - Hotplug works.
+ * - ATAPI read works but burning doesn't.  This thing is really
+ *   peculiar about ATAPI and I couldn't figure out how ATAPI PIO and
+ *   ATAPI DMA WRITE should be programmed.  If you've got a clue, be
+ *   my guest.
+ * - Both STR and STD work.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/pci.h>
+#include <scsi/scsi_host.h>
+#include <linux/libata.h>
+#include <linux/blkdev.h>
+#include <scsi/scsi_device.h>
+
+#define DRV_NAME       "sata_inic162x"
+#define DRV_VERSION    "0.1"
+
+enum {
+       MMIO_BAR                = 5,
+
+       NR_PORTS                = 2,
+
+       HOST_CTL                = 0x7c,
+       HOST_STAT               = 0x7e,
+       HOST_IRQ_STAT           = 0xbc,
+       HOST_IRQ_MASK           = 0xbe,
+
+       PORT_SIZE               = 0x40,
+
+       /* registers for ATA TF operation */
+       PORT_TF                 = 0x00,
+       PORT_ALT_STAT           = 0x08,
+       PORT_IRQ_STAT           = 0x09,
+       PORT_IRQ_MASK           = 0x0a,
+       PORT_PRD_CTL            = 0x0b,
+       PORT_PRD_ADDR           = 0x0c,
+       PORT_PRD_XFERLEN        = 0x10,
+
+       /* IDMA register */
+       PORT_IDMA_CTL           = 0x14,
+
+       PORT_SCR                = 0x20,
+
+       /* HOST_CTL bits */
+       HCTL_IRQOFF             = (1 << 8),  /* global IRQ off */
+       HCTL_PWRDWN             = (1 << 13), /* power down PHYs */
+       HCTL_SOFTRST            = (1 << 13), /* global reset (no phy reset) */
+       HCTL_RPGSEL             = (1 << 15), /* register page select */
+
+       HCTL_KNOWN_BITS         = HCTL_IRQOFF | HCTL_PWRDWN | HCTL_SOFTRST |
+                                 HCTL_RPGSEL,
+
+       /* HOST_IRQ_(STAT|MASK) bits */
+       HIRQ_PORT0              = (1 << 0),
+       HIRQ_PORT1              = (1 << 1),
+       HIRQ_SOFT               = (1 << 14),
+       HIRQ_GLOBAL             = (1 << 15), /* STAT only */
+
+       /* PORT_IRQ_(STAT|MASK) bits */
+       PIRQ_OFFLINE            = (1 << 0),  /* device unplugged */
+       PIRQ_ONLINE             = (1 << 1),  /* device plugged */
+       PIRQ_COMPLETE           = (1 << 2),  /* completion interrupt */
+       PIRQ_FATAL              = (1 << 3),  /* fatal error */
+       PIRQ_ATA                = (1 << 4),  /* ATA interrupt */
+       PIRQ_REPLY              = (1 << 5),  /* reply FIFO not empty */
+       PIRQ_PENDING            = (1 << 7),  /* port IRQ pending (STAT only) */
+
+       PIRQ_ERR                = PIRQ_OFFLINE | PIRQ_ONLINE | PIRQ_FATAL,
+
+       PIRQ_MASK_DMA_READ      = PIRQ_REPLY | PIRQ_ATA,
+       PIRQ_MASK_OTHER         = PIRQ_REPLY | PIRQ_COMPLETE,
+       PIRQ_MASK_FREEZE        = 0xff,
+
+       /* PORT_PRD_CTL bits */
+       PRD_CTL_START           = (1 << 0),
+       PRD_CTL_WR              = (1 << 3),
+       PRD_CTL_DMAEN           = (1 << 7),  /* DMA enable */
+
+       /* PORT_IDMA_CTL bits */
+       IDMA_CTL_RST_ATA        = (1 << 2),  /* hardreset ATA bus */
+       IDMA_CTL_RST_IDMA       = (1 << 5),  /* reset IDMA machinary */
+       IDMA_CTL_GO             = (1 << 7),  /* IDMA mode go */
+       IDMA_CTL_ATA_NIEN       = (1 << 8),  /* ATA IRQ disable */
+};
+
+struct inic_host_priv {
+       u16     cached_hctl;
+};
+
+struct inic_port_priv {
+       u8      dfl_prdctl;
+       u8      cached_prdctl;
+       u8      cached_pirq_mask;
+};
+
+static int inic_slave_config(struct scsi_device *sdev)
+{
+       /* This controller is braindamaged.  dma_boundary is 0xffff
+        * like others but it will lock up the whole machine HARD if
+        * 65536 byte PRD entry is fed.  Reduce maximum segment size.
+        */
+       blk_queue_max_segment_size(sdev->request_queue, 65536 - 512);
+
+       return ata_scsi_slave_config(sdev);
+}
+
+static struct scsi_host_template inic_sht = {
+       .module                 = THIS_MODULE,
+       .name                   = DRV_NAME,
+       .ioctl                  = ata_scsi_ioctl,
+       .queuecommand           = ata_scsi_queuecmd,
+       .can_queue              = ATA_DEF_QUEUE,
+       .this_id                = ATA_SHT_THIS_ID,
+       .sg_tablesize           = LIBATA_MAX_PRD,
+       .cmd_per_lun            = ATA_SHT_CMD_PER_LUN,
+       .emulated               = ATA_SHT_EMULATED,
+       .use_clustering         = ATA_SHT_USE_CLUSTERING,
+       .proc_name              = DRV_NAME,
+       .dma_boundary           = ATA_DMA_BOUNDARY,
+       .slave_configure        = inic_slave_config,
+       .slave_destroy          = ata_scsi_slave_destroy,
+       .bios_param             = ata_std_bios_param,
+       .suspend                = ata_scsi_device_suspend,
+       .resume                 = ata_scsi_device_resume,
+};
+
+static const int scr_map[] = {
+       [SCR_STATUS]    = 0,
+       [SCR_ERROR]     = 1,
+       [SCR_CONTROL]   = 2,
+};
+
+static void __iomem * inic_port_base(struct ata_port *ap)
+{
+       return ap->host->iomap[MMIO_BAR] + ap->port_no * PORT_SIZE;
+}
+
+static void __inic_set_pirq_mask(struct ata_port *ap, u8 mask)
+{
+       void __iomem *port_base = inic_port_base(ap);
+       struct inic_port_priv *pp = ap->private_data;
+
+       writeb(mask, port_base + PORT_IRQ_MASK);
+       pp->cached_pirq_mask = mask;
+}
+
+static void inic_set_pirq_mask(struct ata_port *ap, u8 mask)
+{
+       struct inic_port_priv *pp = ap->private_data;
+
+       if (pp->cached_pirq_mask != mask)
+               __inic_set_pirq_mask(ap, mask);
+}
+
+static void inic_reset_port(void __iomem *port_base)
+{
+       void __iomem *idma_ctl = port_base + PORT_IDMA_CTL;
+       u16 ctl;
+
+       ctl = readw(idma_ctl);
+       ctl &= ~(IDMA_CTL_RST_IDMA | IDMA_CTL_ATA_NIEN | IDMA_CTL_GO);
+
+       /* mask IRQ and assert reset */
+       writew(ctl | IDMA_CTL_RST_IDMA | IDMA_CTL_ATA_NIEN, idma_ctl);
+       readw(idma_ctl); /* flush */
+
+       /* give it some time */
+       msleep(1);
+
+       /* release reset */
+       writew(ctl | IDMA_CTL_ATA_NIEN, idma_ctl);
+
+       /* clear irq */
+       writeb(0xff, port_base + PORT_IRQ_STAT);
+
+       /* reenable ATA IRQ, turn off IDMA mode */
+       writew(ctl, idma_ctl);
+}
+
+static u32 inic_scr_read(struct ata_port *ap, unsigned sc_reg)
+{
+       void __iomem *scr_addr = (void __iomem *)ap->ioaddr.scr_addr;
+       void __iomem *addr;
+       u32 val;
+
+       if (unlikely(sc_reg >= ARRAY_SIZE(scr_map)))
+               return 0xffffffffU;
+
+       addr = scr_addr + scr_map[sc_reg] * 4;
+       val = readl(scr_addr + scr_map[sc_reg] * 4);
+
+       /* this controller has stuck DIAG.N, ignore it */
+       if (sc_reg == SCR_ERROR)
+               val &= ~SERR_PHYRDY_CHG;
+       return val;
+}
+
+static void inic_scr_write(struct ata_port *ap, unsigned sc_reg, u32 val)
+{
+       void __iomem *scr_addr = (void __iomem *)ap->ioaddr.scr_addr;
+       void __iomem *addr;
+
+       if (unlikely(sc_reg >= ARRAY_SIZE(scr_map)))
+               return;
+
+       addr = scr_addr + scr_map[sc_reg] * 4;
+       writel(val, scr_addr + scr_map[sc_reg] * 4);
+}
+
+/*
+ * In TF mode, inic162x is very similar to SFF device.  TF registers
+ * function the same.  DMA engine behaves similary using the same PRD
+ * format as BMDMA but different command register, interrupt and event
+ * notification methods are used.  The following inic_bmdma_*()
+ * functions do the impedance matching.
+ */
+static void inic_bmdma_setup(struct ata_queued_cmd *qc)
+{
+       struct ata_port *ap = qc->ap;
+       struct inic_port_priv *pp = ap->private_data;
+       void __iomem *port_base = inic_port_base(ap);
+       int rw = qc->tf.flags & ATA_TFLAG_WRITE;
+
+       /* make sure device sees PRD table writes */
+       wmb();
+
+       /* load transfer length */
+       writel(qc->nbytes, port_base + PORT_PRD_XFERLEN);
+
+       /* turn on DMA and specify data direction */
+       pp->cached_prdctl = pp->dfl_prdctl | PRD_CTL_DMAEN;
+       if (!rw)
+               pp->cached_prdctl |= PRD_CTL_WR;
+       writeb(pp->cached_prdctl, port_base + PORT_PRD_CTL);
+
+       /* issue r/w command */
+       ap->ops->exec_command(ap, &qc->tf);
+}
+
+static void inic_bmdma_start(struct ata_queued_cmd *qc)
+{
+       struct ata_port *ap = qc->ap;
+       struct inic_port_priv *pp = ap->private_data;
+       void __iomem *port_base = inic_port_base(ap);
+
+       /* start host DMA transaction */
+       pp->cached_prdctl |= PRD_CTL_START;
+       writeb(pp->cached_prdctl, port_base + PORT_PRD_CTL);
+}
+
+static void inic_bmdma_stop(struct ata_queued_cmd *qc)
+{
+       struct ata_port *ap = qc->ap;
+       struct inic_port_priv *pp = ap->private_data;
+       void __iomem *port_base = inic_port_base(ap);
+
+       /* stop DMA engine */
+       writeb(pp->dfl_prdctl, port_base + PORT_PRD_CTL);
+}
+
+static u8 inic_bmdma_status(struct ata_port *ap)
+{
+       /* event is already verified by the interrupt handler */
+       return ATA_DMA_INTR;
+}
+
+static void inic_irq_clear(struct ata_port *ap)
+{
+       /* noop */
+}
+
+static void inic_host_intr(struct ata_port *ap)
+{
+       void __iomem *port_base = inic_port_base(ap);
+       struct ata_eh_info *ehi = &ap->eh_info;
+       u8 irq_stat;
+
+       /* fetch and clear irq */
+       irq_stat = readb(port_base + PORT_IRQ_STAT);
+       writeb(irq_stat, port_base + PORT_IRQ_STAT);
+
+       if (likely(!(irq_stat & PIRQ_ERR))) {
+               struct ata_queued_cmd *qc = ata_qc_from_tag(ap, ap->active_tag);
+
+               if (unlikely(!qc || (qc->tf.flags & ATA_TFLAG_POLLING))) {
+                       ata_chk_status(ap);     /* clear ATA interrupt */
+                       return;
+               }
+
+               if (likely(ata_host_intr(ap, qc)))
+                       return;
+
+               ata_chk_status(ap);     /* clear ATA interrupt */
+               ata_port_printk(ap, KERN_WARNING, "unhandled "
+                               "interrupt, irq_stat=%x\n", irq_stat);
+               return;
+       }
+
+       /* error */
+       ata_ehi_push_desc(ehi, "irq_stat=0x%x", irq_stat);
+
+       if (irq_stat & (PIRQ_OFFLINE | PIRQ_ONLINE)) {
+               ata_ehi_hotplugged(ehi);
+               ata_port_freeze(ap);
+       } else
+               ata_port_abort(ap);
+}
+
+static irqreturn_t inic_interrupt(int irq, void *dev_instance)
+{
+       struct ata_host *host = dev_instance;
+       void __iomem *mmio_base = host->iomap[MMIO_BAR];
+       u16 host_irq_stat;
+       int i, handled = 0;;
+
+       host_irq_stat = readw(mmio_base + HOST_IRQ_STAT);
+
+       if (unlikely(!(host_irq_stat & HIRQ_GLOBAL)))
+               goto out;
+
+       spin_lock(&host->lock);
+
+       for (i = 0; i < NR_PORTS; i++) {
+               struct ata_port *ap = host->ports[i];
+
+               if (!(host_irq_stat & (HIRQ_PORT0 << i)))
+                       continue;
+
+               if (likely(ap && !(ap->flags & ATA_FLAG_DISABLED))) {
+                       inic_host_intr(ap);
+                       handled++;
+               } else {
+                       if (ata_ratelimit())
+                               dev_printk(KERN_ERR, host->dev, "interrupt "
+                                          "from disabled port %d (0x%x)\n",
+                                          i, host_irq_stat);
+               }
+       }
+
+       spin_unlock(&host->lock);
+
+ out:
+       return IRQ_RETVAL(handled);
+}
+
+static unsigned int inic_qc_issue(struct ata_queued_cmd *qc)
+{
+       struct ata_port *ap = qc->ap;
+
+       /* ATA IRQ doesn't wait for DMA transfer completion and vice
+        * versa.  Mask IRQ selectively to detect command completion.
+        * Without it, ATA DMA read command can cause data corruption.
+        *
+        * Something similar might be needed for ATAPI writes.  I
+        * tried a lot of combinations but couldn't find the solution.
+        */
+       if (qc->tf.protocol == ATA_PROT_DMA &&
+           !(qc->tf.flags & ATA_TFLAG_WRITE))
+               inic_set_pirq_mask(ap, PIRQ_MASK_DMA_READ);
+       else
+               inic_set_pirq_mask(ap, PIRQ_MASK_OTHER);
+
+       /* Issuing a command to yet uninitialized port locks up the
+        * controller.  Most of the time, this happens for the first
+        * command after reset which are ATA and ATAPI IDENTIFYs.
+        * Fast fail if stat is 0x7f or 0xff for those commands.
+        */
+       if (unlikely(qc->tf.command == ATA_CMD_ID_ATA ||
+                    qc->tf.command == ATA_CMD_ID_ATAPI)) {
+               u8 stat = ata_chk_status(ap);
+               if (stat == 0x7f || stat == 0xff)
+                       return AC_ERR_HSM;
+       }
+
+       return ata_qc_issue_prot(qc);
+}
+
+static void inic_freeze(struct ata_port *ap)
+{
+       void __iomem *port_base = inic_port_base(ap);
+
+       __inic_set_pirq_mask(ap, PIRQ_MASK_FREEZE);
+
+       ata_chk_status(ap);
+       writeb(0xff, port_base + PORT_IRQ_STAT);
+
+       readb(port_base + PORT_IRQ_STAT); /* flush */
+}
+
+static void inic_thaw(struct ata_port *ap)
+{
+       void __iomem *port_base = inic_port_base(ap);
+
+       ata_chk_status(ap);
+       writeb(0xff, port_base + PORT_IRQ_STAT);
+
+       __inic_set_pirq_mask(ap, PIRQ_MASK_OTHER);
+
+       readb(port_base + PORT_IRQ_STAT); /* flush */
+}
+
+/*
+ * SRST and SControl hardreset don't give valid signature on this
+ * controller.  Only controller specific hardreset mechanism works.
+ */
+static int inic_hardreset(struct ata_port *ap, unsigned int *class)
+{
+       void __iomem *port_base = inic_port_base(ap);
+       void __iomem *idma_ctl = port_base + PORT_IDMA_CTL;
+       const unsigned long *timing = sata_ehc_deb_timing(&ap->eh_context);
+       u16 val;
+       int rc;
+
+       /* hammer it into sane state */
+       inic_reset_port(port_base);
+
+       val = readw(idma_ctl);
+       writew(val | IDMA_CTL_RST_ATA, idma_ctl);
+       readw(idma_ctl);        /* flush */
+       msleep(1);
+       writew(val & ~IDMA_CTL_RST_ATA, idma_ctl);
+
+       rc = sata_phy_resume(ap, timing);
+       if (rc) {
+               ata_port_printk(ap, KERN_WARNING, "failed to resume "
+                               "link after reset (errno=%d)\n", rc);
+               return rc;
+       }
+
+       *class = ATA_DEV_NONE;
+       if (ata_port_online(ap)) {
+               struct ata_taskfile tf;
+
+               /* wait a while before checking status */
+               msleep(150);
+
+               if (ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT)) {
+                       ata_port_printk(ap, KERN_WARNING,
+                                       "device busy after hardreset\n");
+                       return -EIO;
+               }
+
+               ata_tf_read(ap, &tf);
+               *class = ata_dev_classify(&tf);
+               if (*class == ATA_DEV_UNKNOWN)
+                       *class = ATA_DEV_NONE;
+       }
+
+       return 0;
+}
+
+static void inic_error_handler(struct ata_port *ap)
+{
+       void __iomem *port_base = inic_port_base(ap);
+       struct inic_port_priv *pp = ap->private_data;
+       unsigned long flags;
+
+       /* reset PIO HSM and stop DMA engine */
+       inic_reset_port(port_base);
+
+       spin_lock_irqsave(ap->lock, flags);
+       ap->hsm_task_state = HSM_ST_IDLE;
+       writeb(pp->dfl_prdctl, port_base + PORT_PRD_CTL);
+       spin_unlock_irqrestore(ap->lock, flags);
+
+       /* PIO and DMA engines have been stopped, perform recovery */
+       ata_do_eh(ap, ata_std_prereset, NULL, inic_hardreset,
+                 ata_std_postreset);
+}
+
+static void inic_post_internal_cmd(struct ata_queued_cmd *qc)
+{
+       /* make DMA engine forget about the failed command */
+       if (qc->err_mask)
+               inic_reset_port(inic_port_base(qc->ap));
+}
+
+static void inic_dev_config(struct ata_port *ap, struct ata_device *dev)
+{
+       /* inic can only handle upto LBA28 max sectors */
+       if (dev->max_sectors > ATA_MAX_SECTORS)
+               dev->max_sectors = ATA_MAX_SECTORS;
+}
+
+static void init_port(struct ata_port *ap)
+{
+       void __iomem *port_base = inic_port_base(ap);
+
+       /* Setup PRD address */
+       writel(ap->prd_dma, port_base + PORT_PRD_ADDR);
+}
+
+static int inic_port_resume(struct ata_port *ap)
+{
+       init_port(ap);
+       return 0;
+}
+
+static int inic_port_start(struct ata_port *ap)
+{
+       void __iomem *port_base = inic_port_base(ap);
+       struct inic_port_priv *pp;
+       u8 tmp;
+       int rc;
+
+       /* alloc and initialize private data */
+       pp = devm_kzalloc(ap->host->dev, sizeof(*pp), GFP_KERNEL);
+       if (!pp)
+               return -ENOMEM;
+       ap->private_data = pp;
+
+       /* default PRD_CTL value, DMAEN, WR and START off */
+       tmp = readb(port_base + PORT_PRD_CTL);
+       tmp &= ~(PRD_CTL_DMAEN | PRD_CTL_WR | PRD_CTL_START);
+       pp->dfl_prdctl = tmp;
+
+       /* Alloc resources */
+       rc = ata_port_start(ap);
+       if (rc) {
+               kfree(pp);
+               return rc;
+       }
+
+       init_port(ap);
+
+       return 0;
+}
+
+static struct ata_port_operations inic_port_ops = {
+       .port_disable           = ata_port_disable,
+       .tf_load                = ata_tf_load,
+       .tf_read                = ata_tf_read,
+       .check_status           = ata_check_status,
+       .exec_command           = ata_exec_command,
+       .dev_select             = ata_std_dev_select,
+
+       .scr_read               = inic_scr_read,
+       .scr_write              = inic_scr_write,
+
+       .bmdma_setup            = inic_bmdma_setup,
+       .bmdma_start            = inic_bmdma_start,
+       .bmdma_stop             = inic_bmdma_stop,
+       .bmdma_status           = inic_bmdma_status,
+
+       .irq_handler            = inic_interrupt,
+       .irq_clear              = inic_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
+
+       .qc_prep                = ata_qc_prep,
+       .qc_issue               = inic_qc_issue,
+       .data_xfer              = ata_data_xfer,
+
+       .freeze                 = inic_freeze,
+       .thaw                   = inic_thaw,
+       .error_handler          = inic_error_handler,
+       .post_internal_cmd      = inic_post_internal_cmd,
+       .dev_config             = inic_dev_config,
+
+       .port_resume            = inic_port_resume,
+
+       .port_start             = inic_port_start,
+};
+
+static struct ata_port_info inic_port_info = {
+       .sht                    = &inic_sht,
+       /* For some reason, ATA_PROT_ATAPI is broken on this
+        * controller, and no, PIO_POLLING does't fix it.  It somehow
+        * manages to report the wrong ireason and ignoring ireason
+        * results in machine lock up.  Tell libata to always prefer
+        * DMA.
+        */
+       .flags                  = ATA_FLAG_SATA | ATA_FLAG_PIO_DMA,
+       .pio_mask               = 0x1f, /* pio0-4 */
+       .mwdma_mask             = 0x07, /* mwdma0-2 */
+       .udma_mask              = 0x7f, /* udma0-6 */
+       .port_ops               = &inic_port_ops
+};
+
+static int init_controller(void __iomem *mmio_base, u16 hctl)
+{
+       int i;
+       u16 val;
+
+       hctl &= ~HCTL_KNOWN_BITS;
+
+       /* Soft reset whole controller.  Spec says reset duration is 3
+        * PCI clocks, be generous and give it 10ms.
+        */
+       writew(hctl | HCTL_SOFTRST, mmio_base + HOST_CTL);
+       readw(mmio_base + HOST_CTL); /* flush */
+
+       for (i = 0; i < 10; i++) {
+               msleep(1);
+               val = readw(mmio_base + HOST_CTL);
+               if (!(val & HCTL_SOFTRST))
+                       break;
+       }
+
+       if (val & HCTL_SOFTRST)
+               return -EIO;
+
+       /* mask all interrupts and reset ports */
+       for (i = 0; i < NR_PORTS; i++) {
+               void __iomem *port_base = mmio_base + i * PORT_SIZE;
+
+               writeb(0xff, port_base + PORT_IRQ_MASK);
+               inic_reset_port(port_base);
+       }
+
+       /* port IRQ is masked now, unmask global IRQ */
+       writew(hctl & ~HCTL_IRQOFF, mmio_base + HOST_CTL);
+       val = readw(mmio_base + HOST_IRQ_MASK);
+       val &= ~(HIRQ_PORT0 | HIRQ_PORT1);
+       writew(val, mmio_base + HOST_IRQ_MASK);
+
+       return 0;
+}
+
+static int inic_pci_device_resume(struct pci_dev *pdev)
+{
+       struct ata_host *host = dev_get_drvdata(&pdev->dev);
+       struct inic_host_priv *hpriv = host->private_data;
+       void __iomem *mmio_base = host->iomap[MMIO_BAR];
+       int rc;
+
+       ata_pci_device_do_resume(pdev);
+
+       if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) {
+               printk("XXX\n");
+               rc = init_controller(mmio_base, hpriv->cached_hctl);
+               if (rc)
+                       return rc;
+       }
+
+       ata_host_resume(host);
+
+       return 0;
+}
+
+static int inic_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
+{
+       static int printed_version;
+       struct ata_port_info *pinfo = &inic_port_info;
+       struct ata_probe_ent *probe_ent;
+       struct inic_host_priv *hpriv;
+       void __iomem * const *iomap;
+       int i, rc;
+
+       if (!printed_version++)
+               dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
+
+       rc = pcim_enable_device(pdev);
+       if (rc)
+               return rc;
+
+       rc = pci_request_regions(pdev, DRV_NAME);
+       if (rc)
+               return rc;
+
+       rc = pcim_iomap_regions(pdev, 0x3f, DRV_NAME);
+       if (rc)
+               return rc;
+       iomap = pcim_iomap_table(pdev);
+
+       /* Set dma_mask.  This devices doesn't support 64bit addressing. */
+       rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
+       if (rc) {
+               dev_printk(KERN_ERR, &pdev->dev,
+                          "32-bit DMA enable failed\n");
+               return rc;
+       }
+
+       rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
+       if (rc) {
+               dev_printk(KERN_ERR, &pdev->dev,
+                          "32-bit consistent DMA enable failed\n");
+               return rc;
+       }
+
+       probe_ent = devm_kzalloc(&pdev->dev, sizeof(*probe_ent), GFP_KERNEL);
+       hpriv = devm_kzalloc(&pdev->dev, sizeof(*hpriv), GFP_KERNEL);
+       if (!probe_ent || !hpriv)
+               return -ENOMEM;
+
+       probe_ent->dev = &pdev->dev;
+       INIT_LIST_HEAD(&probe_ent->node);
+
+       probe_ent->sht                  = pinfo->sht;
+       probe_ent->port_flags           = pinfo->flags;
+       probe_ent->pio_mask             = pinfo->pio_mask;
+       probe_ent->mwdma_mask           = pinfo->mwdma_mask;
+       probe_ent->udma_mask            = pinfo->udma_mask;
+       probe_ent->port_ops             = pinfo->port_ops;
+       probe_ent->n_ports              = NR_PORTS;
+
+       probe_ent->irq = pdev->irq;
+       probe_ent->irq_flags = SA_SHIRQ;
+
+       probe_ent->iomap = iomap;
+
+       for (i = 0; i < NR_PORTS; i++) {
+               struct ata_ioports *port = &probe_ent->port[i];
+               void __iomem *port_base = iomap[MMIO_BAR] + i * PORT_SIZE;
+
+               port->cmd_addr = iomap[2 * i];
+               port->altstatus_addr =
+               port->ctl_addr = (void __iomem *)
+                       ((unsigned long)iomap[2 * i + 1] | ATA_PCI_CTL_OFS);
+               port->scr_addr = port_base + PORT_SCR;
+
+               ata_std_ports(port);
+       }
+
+       probe_ent->private_data = hpriv;
+       hpriv->cached_hctl = readw(iomap[MMIO_BAR] + HOST_CTL);
+
+       rc = init_controller(iomap[MMIO_BAR], hpriv->cached_hctl);
+       if (rc) {
+               dev_printk(KERN_ERR, &pdev->dev,
+                          "failed to initialize controller\n");
+               return rc;
+       }
+
+       pci_set_master(pdev);
+
+       if (!ata_device_add(probe_ent))
+               return -ENODEV;
+
+       devm_kfree(&pdev->dev, probe_ent);
+
+       return 0;
+}
+
+static const struct pci_device_id inic_pci_tbl[] = {
+       { PCI_VDEVICE(INIT, 0x1622), },
+       { },
+};
+
+static struct pci_driver inic_pci_driver = {
+       .name           = DRV_NAME,
+       .id_table       = inic_pci_tbl,
+       .suspend        = ata_pci_device_suspend,
+       .resume         = inic_pci_device_resume,
+       .probe          = inic_init_one,
+       .remove         = ata_pci_remove_one,
+};
+
+static int __init inic_init(void)
+{
+       return pci_register_driver(&inic_pci_driver);
+}
+
+static void __exit inic_exit(void)
+{
+       pci_unregister_driver(&inic_pci_driver);
+}
+
+MODULE_AUTHOR("Tejun Heo");
+MODULE_DESCRIPTION("low-level driver for Initio 162x SATA");
+MODULE_LICENSE("GPL v2");
+MODULE_DEVICE_TABLE(pci, inic_pci_tbl);
+MODULE_VERSION(DRV_VERSION);
+
+module_init(inic_init);
+module_exit(inic_exit);
index aae0b5201c1edb109a750ab717416a567126a220..769eca52442c73706d1eda322f8859352d9df423 100644 (file)
@@ -34,7 +34,6 @@
 #include <scsi/scsi_host.h>
 #include <scsi/scsi_cmnd.h>
 #include <linux/libata.h>
-#include <asm/io.h>
 
 #define DRV_NAME       "sata_mv"
 #define DRV_VERSION    "0.7"
@@ -342,7 +341,6 @@ static u32 mv5_scr_read(struct ata_port *ap, unsigned int sc_reg_in);
 static void mv5_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val);
 static void mv_phy_reset(struct ata_port *ap);
 static void __mv_phy_reset(struct ata_port *ap, int can_sleep);
-static void mv_host_stop(struct ata_host *host);
 static int mv_port_start(struct ata_port *ap);
 static void mv_port_stop(struct ata_port *ap);
 static void mv_qc_prep(struct ata_queued_cmd *qc);
@@ -406,19 +404,20 @@ static const struct ata_port_operations mv5_ops = {
 
        .qc_prep                = mv_qc_prep,
        .qc_issue               = mv_qc_issue,
-       .data_xfer              = ata_mmio_data_xfer,
+       .data_xfer              = ata_data_xfer,
 
        .eng_timeout            = mv_eng_timeout,
 
        .irq_handler            = mv_interrupt,
        .irq_clear              = mv_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
 
        .scr_read               = mv5_scr_read,
        .scr_write              = mv5_scr_write,
 
        .port_start             = mv_port_start,
        .port_stop              = mv_port_stop,
-       .host_stop              = mv_host_stop,
 };
 
 static const struct ata_port_operations mv6_ops = {
@@ -434,19 +433,20 @@ static const struct ata_port_operations mv6_ops = {
 
        .qc_prep                = mv_qc_prep,
        .qc_issue               = mv_qc_issue,
-       .data_xfer              = ata_mmio_data_xfer,
+       .data_xfer              = ata_data_xfer,
 
        .eng_timeout            = mv_eng_timeout,
 
        .irq_handler            = mv_interrupt,
        .irq_clear              = mv_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
 
        .scr_read               = mv_scr_read,
        .scr_write              = mv_scr_write,
 
        .port_start             = mv_port_start,
        .port_stop              = mv_port_stop,
-       .host_stop              = mv_host_stop,
 };
 
 static const struct ata_port_operations mv_iie_ops = {
@@ -462,19 +462,20 @@ static const struct ata_port_operations mv_iie_ops = {
 
        .qc_prep                = mv_qc_prep_iie,
        .qc_issue               = mv_qc_issue,
-       .data_xfer              = ata_mmio_data_xfer,
+       .data_xfer              = ata_data_xfer,
 
        .eng_timeout            = mv_eng_timeout,
 
        .irq_handler            = mv_interrupt,
        .irq_clear              = mv_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
 
        .scr_read               = mv_scr_read,
        .scr_write              = mv_scr_write,
 
        .port_start             = mv_port_start,
        .port_stop              = mv_port_stop,
-       .host_stop              = mv_host_stop,
 };
 
 static const struct ata_port_info mv_port_info[] = {
@@ -620,7 +621,7 @@ static inline void __iomem *mv_port_base(void __iomem *base, unsigned int port)
 
 static inline void __iomem *mv_ap_base(struct ata_port *ap)
 {
-       return mv_port_base(ap->host->mmio_base, ap->port_no);
+       return mv_port_base(ap->host->iomap[MV_PRIMARY_BAR], ap->port_no);
 }
 
 static inline int mv_get_hc_count(unsigned long port_flags)
@@ -809,35 +810,6 @@ static void mv_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val)
        }
 }
 
-/**
- *      mv_host_stop - Host specific cleanup/stop routine.
- *      @host: host data structure
- *
- *      Disable ints, cleanup host memory, call general purpose
- *      host_stop.
- *
- *      LOCKING:
- *      Inherited from caller.
- */
-static void mv_host_stop(struct ata_host *host)
-{
-       struct mv_host_priv *hpriv = host->private_data;
-       struct pci_dev *pdev = to_pci_dev(host->dev);
-
-       if (hpriv->hp_flags & MV_HP_FLAG_MSI) {
-               pci_disable_msi(pdev);
-       } else {
-               pci_intx(pdev, 0);
-       }
-       kfree(hpriv);
-       ata_host_stop(host);
-}
-
-static inline void mv_priv_free(struct mv_port_priv *pp, struct device *dev)
-{
-       dma_free_coherent(dev, MV_PORT_PRIV_DMA_SZ, pp->crpb, pp->crpb_dma);
-}
-
 static void mv_edma_cfg(struct mv_host_priv *hpriv, void __iomem *port_mmio)
 {
        u32 cfg = readl(port_mmio + EDMA_CFG_OFS);
@@ -883,22 +855,21 @@ static int mv_port_start(struct ata_port *ap)
        void __iomem *port_mmio = mv_ap_base(ap);
        void *mem;
        dma_addr_t mem_dma;
-       int rc = -ENOMEM;
+       int rc;
 
-       pp = kmalloc(sizeof(*pp), GFP_KERNEL);
+       pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL);
        if (!pp)
-               goto err_out;
-       memset(pp, 0, sizeof(*pp));
+               return -ENOMEM;
 
-       mem = dma_alloc_coherent(dev, MV_PORT_PRIV_DMA_SZ, &mem_dma,
-                                GFP_KERNEL);
+       mem = dmam_alloc_coherent(dev, MV_PORT_PRIV_DMA_SZ, &mem_dma,
+                                 GFP_KERNEL);
        if (!mem)
-               goto err_out_pp;
+               return -ENOMEM;
        memset(mem, 0, MV_PORT_PRIV_DMA_SZ);
 
        rc = ata_pad_alloc(ap, dev);
        if (rc)
-               goto err_out_priv;
+               return rc;
 
        /* First item in chunk of DMA memory:
         * 32-slot command request table (CRQB), 32 bytes each in size
@@ -951,13 +922,6 @@ static int mv_port_start(struct ata_port *ap)
         */
        ap->private_data = pp;
        return 0;
-
-err_out_priv:
-       mv_priv_free(pp, dev);
-err_out_pp:
-       kfree(pp);
-err_out:
-       return rc;
 }
 
 /**
@@ -971,18 +935,11 @@ err_out:
  */
 static void mv_port_stop(struct ata_port *ap)
 {
-       struct device *dev = ap->host->dev;
-       struct mv_port_priv *pp = ap->private_data;
        unsigned long flags;
 
        spin_lock_irqsave(&ap->host->lock, flags);
        mv_stop_dma(ap);
        spin_unlock_irqrestore(&ap->host->lock, flags);
-
-       ap->private_data = NULL;
-       ata_pad_free(ap, dev);
-       mv_priv_free(pp, dev);
-       kfree(pp);
 }
 
 /**
@@ -1348,7 +1305,7 @@ static void mv_err_intr(struct ata_port *ap, int reset_allowed)
  */
 static void mv_host_intr(struct ata_host *host, u32 relevant, unsigned int hc)
 {
-       void __iomem *mmio = host->mmio_base;
+       void __iomem *mmio = host->iomap[MV_PRIMARY_BAR];
        void __iomem *hc_mmio = mv_hc_base(mmio, hc);
        struct ata_queued_cmd *qc;
        u32 hc_irq_cause;
@@ -1391,8 +1348,7 @@ static void mv_host_intr(struct ata_host *host, u32 relevant, unsigned int hc)
                } else {
                        /* PIO: check for device (drive) interrupt */
                        if ((DEV_IRQ << hard_port) & hc_irq_cause) {
-                               ata_status = readb((void __iomem *)
-                                          ap->ioaddr.status_addr);
+                               ata_status = readb(ap->ioaddr.status_addr);
                                handled = 1;
                                /* ignore spurious intr if drive still BUSY */
                                if (ata_status & ATA_BUSY) {
@@ -1452,7 +1408,7 @@ static irqreturn_t mv_interrupt(int irq, void *dev_instance)
 {
        struct ata_host *host = dev_instance;
        unsigned int hc, handled = 0, n_hcs;
-       void __iomem *mmio = host->mmio_base;
+       void __iomem *mmio = host->iomap[MV_PRIMARY_BAR];
        struct mv_host_priv *hpriv;
        u32 irq_stat;
 
@@ -1528,22 +1484,24 @@ static unsigned int mv5_scr_offset(unsigned int sc_reg_in)
 
 static u32 mv5_scr_read(struct ata_port *ap, unsigned int sc_reg_in)
 {
-       void __iomem *mmio = mv5_phy_base(ap->host->mmio_base, ap->port_no);
+       void __iomem *mmio = ap->host->iomap[MV_PRIMARY_BAR];
+       void __iomem *addr = mv5_phy_base(mmio, ap->port_no);
        unsigned int ofs = mv5_scr_offset(sc_reg_in);
 
        if (ofs != 0xffffffffU)
-               return readl(mmio + ofs);
+               return readl(addr + ofs);
        else
                return (u32) ofs;
 }
 
 static void mv5_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val)
 {
-       void __iomem *mmio = mv5_phy_base(ap->host->mmio_base, ap->port_no);
+       void __iomem *mmio = ap->host->iomap[MV_PRIMARY_BAR];
+       void __iomem *addr = mv5_phy_base(mmio, ap->port_no);
        unsigned int ofs = mv5_scr_offset(sc_reg_in);
 
        if (ofs != 0xffffffffU)
-               writelfl(val, mmio + ofs);
+               writelfl(val, addr + ofs);
 }
 
 static void mv5_reset_bus(struct pci_dev *pdev, void __iomem *mmio)
@@ -1905,7 +1863,7 @@ static void mv_channel_reset(struct mv_host_priv *hpriv, void __iomem *mmio,
 static void mv_stop_and_reset(struct ata_port *ap)
 {
        struct mv_host_priv *hpriv = ap->host->private_data;
-       void __iomem *mmio = ap->host->mmio_base;
+       void __iomem *mmio = ap->host->iomap[MV_PRIMARY_BAR];
 
        mv_stop_dma(ap);
 
@@ -2003,10 +1961,10 @@ comreset_retry:
                        break;
        }
 
-       tf.lbah = readb((void __iomem *) ap->ioaddr.lbah_addr);
-       tf.lbam = readb((void __iomem *) ap->ioaddr.lbam_addr);
-       tf.lbal = readb((void __iomem *) ap->ioaddr.lbal_addr);
-       tf.nsect = readb((void __iomem *) ap->ioaddr.nsect_addr);
+       tf.lbah = readb(ap->ioaddr.lbah_addr);
+       tf.lbam = readb(ap->ioaddr.lbam_addr);
+       tf.lbal = readb(ap->ioaddr.lbal_addr);
+       tf.nsect = readb(ap->ioaddr.nsect_addr);
 
        dev->class = ata_dev_classify(&tf);
        if (!ata_dev_enabled(dev)) {
@@ -2038,17 +1996,17 @@ static void mv_phy_reset(struct ata_port *ap)
  */
 static void mv_eng_timeout(struct ata_port *ap)
 {
+       void __iomem *mmio = ap->host->iomap[MV_PRIMARY_BAR];
        struct ata_queued_cmd *qc;
        unsigned long flags;
 
        ata_port_printk(ap, KERN_ERR, "Entering mv_eng_timeout\n");
        DPRINTK("All regs @ start of eng_timeout\n");
-       mv_dump_all_regs(ap->host->mmio_base, ap->port_no,
-                        to_pci_dev(ap->host->dev));
+       mv_dump_all_regs(mmio, ap->port_no, to_pci_dev(ap->host->dev));
 
        qc = ata_qc_from_tag(ap, ap->active_tag);
         printk(KERN_ERR "mmio_base %p ap %p qc %p scsi_cmnd %p &cmnd %p\n",
-              ap->host->mmio_base, ap, qc, qc->scsicmd, &qc->scsicmd->cmnd);
+              mmio, ap, qc, qc->scsicmd, &qc->scsicmd->cmnd);
 
        spin_lock_irqsave(&ap->host->lock, flags);
        mv_err_intr(ap, 0);
@@ -2076,7 +2034,7 @@ static void mv_eng_timeout(struct ata_port *ap)
  */
 static void mv_port_init(struct ata_ioports *port,  void __iomem *port_mmio)
 {
-       unsigned long shd_base = (unsigned long) port_mmio + SHD_BLK_OFS;
+       void __iomem *shd_base = port_mmio + SHD_BLK_OFS;
        unsigned serr_ofs;
 
        /* PIO related setup
@@ -2224,7 +2182,7 @@ static int mv_init_host(struct pci_dev *pdev, struct ata_probe_ent *probe_ent,
                        unsigned int board_idx)
 {
        int rc = 0, n_hc, port, hc;
-       void __iomem *mmio = probe_ent->mmio_base;
+       void __iomem *mmio = probe_ent->iomap[MV_PRIMARY_BAR];
        struct mv_host_priv *hpriv = probe_ent->private_data;
 
        /* global interrupt mask */
@@ -2342,49 +2300,36 @@ static void mv_print_info(struct ata_probe_ent *probe_ent)
 static int mv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
        static int printed_version = 0;
-       struct ata_probe_ent *probe_ent = NULL;
+       struct device *dev = &pdev->dev;
+       struct ata_probe_ent *probe_ent;
        struct mv_host_priv *hpriv;
        unsigned int board_idx = (unsigned int)ent->driver_data;
-       void __iomem *mmio_base;
-       int pci_dev_busy = 0, rc;
+       int rc;
 
        if (!printed_version++)
                dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n");
 
-       rc = pci_enable_device(pdev);
-       if (rc) {
+       rc = pcim_enable_device(pdev);
+       if (rc)
                return rc;
-       }
        pci_set_master(pdev);
 
-       rc = pci_request_regions(pdev, DRV_NAME);
-       if (rc) {
-               pci_dev_busy = 1;
-               goto err_out;
-       }
+       rc = pcim_iomap_regions(pdev, 1 << MV_PRIMARY_BAR, DRV_NAME);
+       if (rc == -EBUSY)
+               pcim_pin_device(pdev);
+       if (rc)
+               return rc;
 
-       probe_ent = kmalloc(sizeof(*probe_ent), GFP_KERNEL);
-       if (probe_ent == NULL) {
-               rc = -ENOMEM;
-               goto err_out_regions;
-       }
+       probe_ent = devm_kzalloc(dev, sizeof(*probe_ent), GFP_KERNEL);
+       if (probe_ent == NULL)
+               return -ENOMEM;
 
-       memset(probe_ent, 0, sizeof(*probe_ent));
        probe_ent->dev = pci_dev_to_dev(pdev);
        INIT_LIST_HEAD(&probe_ent->node);
 
-       mmio_base = pci_iomap(pdev, MV_PRIMARY_BAR, 0);
-       if (mmio_base == NULL) {
-               rc = -ENOMEM;
-               goto err_out_free_ent;
-       }
-
-       hpriv = kmalloc(sizeof(*hpriv), GFP_KERNEL);
-       if (!hpriv) {
-               rc = -ENOMEM;
-               goto err_out_iounmap;
-       }
-       memset(hpriv, 0, sizeof(*hpriv));
+       hpriv = devm_kzalloc(dev, sizeof(*hpriv), GFP_KERNEL);
+       if (!hpriv)
+               return -ENOMEM;
 
        probe_ent->sht = mv_port_info[board_idx].sht;
        probe_ent->port_flags = mv_port_info[board_idx].flags;
@@ -2394,53 +2339,26 @@ static int mv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 
        probe_ent->irq = pdev->irq;
        probe_ent->irq_flags = IRQF_SHARED;
-       probe_ent->mmio_base = mmio_base;
+       probe_ent->iomap = pcim_iomap_table(pdev);
        probe_ent->private_data = hpriv;
 
        /* initialize adapter */
        rc = mv_init_host(pdev, probe_ent, board_idx);
-       if (rc) {
-               goto err_out_hpriv;
-       }
+       if (rc)
+               return rc;
 
        /* Enable interrupts */
-       if (msi && pci_enable_msi(pdev) == 0) {
-               hpriv->hp_flags |= MV_HP_FLAG_MSI;
-       } else {
+       if (msi && !pci_enable_msi(pdev))
                pci_intx(pdev, 1);
-       }
 
        mv_dump_pci_cfg(pdev, 0x68);
        mv_print_info(probe_ent);
 
-       if (ata_device_add(probe_ent) == 0) {
-               rc = -ENODEV;           /* No devices discovered */
-               goto err_out_dev_add;
-       }
+       if (ata_device_add(probe_ent) == 0)
+               return -ENODEV;
 
-       kfree(probe_ent);
+       devm_kfree(dev, probe_ent);
        return 0;
-
-err_out_dev_add:
-       if (MV_HP_FLAG_MSI & hpriv->hp_flags) {
-               pci_disable_msi(pdev);
-       } else {
-               pci_intx(pdev, 0);
-       }
-err_out_hpriv:
-       kfree(hpriv);
-err_out_iounmap:
-       pci_iounmap(pdev, mmio_base);
-err_out_free_ent:
-       kfree(probe_ent);
-err_out_regions:
-       pci_release_regions(pdev);
-err_out:
-       if (!pci_dev_busy) {
-               pci_disable_device(pdev);
-       }
-
-       return rc;
 }
 
 static int __init mv_init(void)
index f7a963eb1f028ea77a7ce4576d64c3c595faa574..095ef1b2cd0e92b1e7dc3dd75a1a4f3760438c2f 100644 (file)
 #include <linux/libata.h>
 
 #define DRV_NAME                       "sata_nv"
-#define DRV_VERSION                    "3.2"
+#define DRV_VERSION                    "3.3"
 
 #define NV_ADMA_DMA_BOUNDARY           0xffffffffUL
 
 enum {
+       NV_MMIO_BAR                     = 5,
+
        NV_PORTS                        = 2,
        NV_PIO_MASK                     = 0x1f,
        NV_MWDMA_MASK                   = 0x07,
@@ -213,12 +215,21 @@ struct nv_adma_port_priv {
        dma_addr_t              cpb_dma;
        struct nv_adma_prd      *aprd;
        dma_addr_t              aprd_dma;
+       void __iomem *          ctl_block;
+       void __iomem *          gen_block;
+       void __iomem *          notifier_clear_block;
        u8                      flags;
 };
 
+struct nv_host_priv {
+       unsigned long           type;
+};
+
 #define NV_ADMA_CHECK_INTR(GCTL, PORT) ((GCTL) & ( 1 << (19 + (12 * (PORT)))))
 
 static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent);
+static void nv_remove_one (struct pci_dev *pdev);
+static int nv_pci_device_resume(struct pci_dev *pdev);
 static void nv_ck804_host_stop(struct ata_host *host);
 static irqreturn_t nv_generic_interrupt(int irq, void *dev_instance);
 static irqreturn_t nv_nf2_interrupt(int irq, void *dev_instance);
@@ -239,6 +250,8 @@ static irqreturn_t nv_adma_interrupt(int irq, void *dev_instance);
 static void nv_adma_irq_clear(struct ata_port *ap);
 static int nv_adma_port_start(struct ata_port *ap);
 static void nv_adma_port_stop(struct ata_port *ap);
+static int nv_adma_port_suspend(struct ata_port *ap, pm_message_t mesg);
+static int nv_adma_port_resume(struct ata_port *ap);
 static void nv_adma_error_handler(struct ata_port *ap);
 static void nv_adma_host_stop(struct ata_host *host);
 static void nv_adma_bmdma_setup(struct ata_queued_cmd *qc);
@@ -284,7 +297,9 @@ static struct pci_driver nv_pci_driver = {
        .name                   = DRV_NAME,
        .id_table               = nv_pci_tbl,
        .probe                  = nv_init_one,
-       .remove                 = ata_pci_remove_one,
+       .suspend                = ata_pci_device_suspend,
+       .resume                 = nv_pci_device_resume,
+       .remove                 = nv_remove_one,
 };
 
 static struct scsi_host_template nv_sht = {
@@ -303,6 +318,8 @@ static struct scsi_host_template nv_sht = {
        .slave_configure        = ata_scsi_slave_config,
        .slave_destroy          = ata_scsi_slave_destroy,
        .bios_param             = ata_std_bios_param,
+       .suspend                = ata_scsi_device_suspend,
+       .resume                 = ata_scsi_device_resume,
 };
 
 static struct scsi_host_template nv_adma_sht = {
@@ -321,6 +338,8 @@ static struct scsi_host_template nv_adma_sht = {
        .slave_configure        = nv_adma_slave_config,
        .slave_destroy          = ata_scsi_slave_destroy,
        .bios_param             = ata_std_bios_param,
+       .suspend                = ata_scsi_device_suspend,
+       .resume                 = ata_scsi_device_resume,
 };
 
 static const struct ata_port_operations nv_generic_ops = {
@@ -340,14 +359,14 @@ static const struct ata_port_operations nv_generic_ops = {
        .thaw                   = ata_bmdma_thaw,
        .error_handler          = nv_error_handler,
        .post_internal_cmd      = ata_bmdma_post_internal_cmd,
-       .data_xfer              = ata_pio_data_xfer,
+       .data_xfer              = ata_data_xfer,
        .irq_handler            = nv_generic_interrupt,
        .irq_clear              = ata_bmdma_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
        .scr_read               = nv_scr_read,
        .scr_write              = nv_scr_write,
        .port_start             = ata_port_start,
-       .port_stop              = ata_port_stop,
-       .host_stop              = ata_pci_host_stop,
 };
 
 static const struct ata_port_operations nv_nf2_ops = {
@@ -367,14 +386,14 @@ static const struct ata_port_operations nv_nf2_ops = {
        .thaw                   = nv_nf2_thaw,
        .error_handler          = nv_error_handler,
        .post_internal_cmd      = ata_bmdma_post_internal_cmd,
-       .data_xfer              = ata_pio_data_xfer,
+       .data_xfer              = ata_data_xfer,
        .irq_handler            = nv_nf2_interrupt,
        .irq_clear              = ata_bmdma_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
        .scr_read               = nv_scr_read,
        .scr_write              = nv_scr_write,
        .port_start             = ata_port_start,
-       .port_stop              = ata_port_stop,
-       .host_stop              = ata_pci_host_stop,
 };
 
 static const struct ata_port_operations nv_ck804_ops = {
@@ -394,13 +413,14 @@ static const struct ata_port_operations nv_ck804_ops = {
        .thaw                   = nv_ck804_thaw,
        .error_handler          = nv_error_handler,
        .post_internal_cmd      = ata_bmdma_post_internal_cmd,
-       .data_xfer              = ata_pio_data_xfer,
+       .data_xfer              = ata_data_xfer,
        .irq_handler            = nv_ck804_interrupt,
        .irq_clear              = ata_bmdma_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
        .scr_read               = nv_scr_read,
        .scr_write              = nv_scr_write,
        .port_start             = ata_port_start,
-       .port_stop              = ata_port_stop,
        .host_stop              = nv_ck804_host_stop,
 };
 
@@ -422,13 +442,17 @@ static const struct ata_port_operations nv_adma_ops = {
        .thaw                   = nv_ck804_thaw,
        .error_handler          = nv_adma_error_handler,
        .post_internal_cmd      = nv_adma_bmdma_stop,
-       .data_xfer              = ata_mmio_data_xfer,
+       .data_xfer              = ata_data_xfer,
        .irq_handler            = nv_adma_interrupt,
        .irq_clear              = nv_adma_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
        .scr_read               = nv_scr_read,
        .scr_write              = nv_scr_write,
        .port_start             = nv_adma_port_start,
        .port_stop              = nv_adma_port_stop,
+       .port_suspend           = nv_adma_port_suspend,
+       .port_resume            = nv_adma_port_resume,
        .host_stop              = nv_adma_host_stop,
 };
 
@@ -467,6 +491,7 @@ static struct ata_port_info nv_port_info[] = {
        {
                .sht            = &nv_adma_sht,
                .flags          = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
+                                 ATA_FLAG_HRST_TO_RESUME |
                                  ATA_FLAG_MMIO | ATA_FLAG_NCQ,
                .pio_mask       = NV_PIO_MASK,
                .mwdma_mask     = NV_MWDMA_MASK,
@@ -483,57 +508,72 @@ MODULE_VERSION(DRV_VERSION);
 
 static int adma_enabled = 1;
 
-static inline void __iomem *__nv_adma_ctl_block(void __iomem *mmio,
-                                               unsigned int port_no)
-{
-       mmio += NV_ADMA_PORT + port_no * NV_ADMA_PORT_SIZE;
-       return mmio;
-}
-
-static inline void __iomem *nv_adma_ctl_block(struct ata_port *ap)
-{
-       return __nv_adma_ctl_block(ap->host->mmio_base, ap->port_no);
-}
-
-static inline void __iomem *nv_adma_gen_block(struct ata_port *ap)
-{
-       return (ap->host->mmio_base + NV_ADMA_GEN);
-}
-
-static inline void __iomem *nv_adma_notifier_clear_block(struct ata_port *ap)
-{
-       return (nv_adma_gen_block(ap) + NV_ADMA_NOTIFIER_CLEAR + (4 * ap->port_no));
-}
-
 static void nv_adma_register_mode(struct ata_port *ap)
 {
-       void __iomem *mmio = nv_adma_ctl_block(ap);
        struct nv_adma_port_priv *pp = ap->private_data;
-       u16 tmp;
+       void __iomem *mmio = pp->ctl_block;
+       u16 tmp, status;
+       int count = 0;
 
        if (pp->flags & NV_ADMA_PORT_REGISTER_MODE)
                return;
 
+       status = readw(mmio + NV_ADMA_STAT);
+       while(!(status & NV_ADMA_STAT_IDLE) && count < 20) {
+               ndelay(50);
+               status = readw(mmio + NV_ADMA_STAT);
+               count++;
+       }
+       if(count == 20)
+               ata_port_printk(ap, KERN_WARNING,
+                       "timeout waiting for ADMA IDLE, stat=0x%hx\n",
+                       status);
+
        tmp = readw(mmio + NV_ADMA_CTL);
        writew(tmp & ~NV_ADMA_CTL_GO, mmio + NV_ADMA_CTL);
 
+       count = 0;
+       status = readw(mmio + NV_ADMA_STAT);
+       while(!(status & NV_ADMA_STAT_LEGACY) && count < 20) {
+               ndelay(50);
+               status = readw(mmio + NV_ADMA_STAT);
+               count++;
+       }
+       if(count == 20)
+               ata_port_printk(ap, KERN_WARNING,
+                        "timeout waiting for ADMA LEGACY, stat=0x%hx\n",
+                        status);
+
        pp->flags |= NV_ADMA_PORT_REGISTER_MODE;
 }
 
 static void nv_adma_mode(struct ata_port *ap)
 {
-       void __iomem *mmio = nv_adma_ctl_block(ap);
        struct nv_adma_port_priv *pp = ap->private_data;
-       u16 tmp;
+       void __iomem *mmio = pp->ctl_block;
+       u16 tmp, status;
+       int count = 0;
 
        if (!(pp->flags & NV_ADMA_PORT_REGISTER_MODE))
                return;
-               
+
        WARN_ON(pp->flags & NV_ADMA_ATAPI_SETUP_COMPLETE);
 
        tmp = readw(mmio + NV_ADMA_CTL);
        writew(tmp | NV_ADMA_CTL_GO, mmio + NV_ADMA_CTL);
 
+       status = readw(mmio + NV_ADMA_STAT);
+       while(((status & NV_ADMA_STAT_LEGACY) ||
+             !(status & NV_ADMA_STAT_IDLE)) && count < 20) {
+               ndelay(50);
+               status = readw(mmio + NV_ADMA_STAT);
+               count++;
+       }
+       if(count == 20)
+               ata_port_printk(ap, KERN_WARNING,
+                       "timeout waiting for ADMA LEGACY clear and IDLE, stat=0x%hx\n",
+                       status);
+
        pp->flags &= ~NV_ADMA_PORT_REGISTER_MODE;
 }
 
@@ -568,7 +608,7 @@ static int nv_adma_slave_config(struct scsi_device *sdev)
                /* Subtract 1 since an extra entry may be needed for padding, see
                   libata-scsi.c */
                sg_tablesize = LIBATA_MAX_PRD - 1;
-               
+
                /* Since the legacy DMA engine is in use, we need to disable ADMA
                   on the port. */
                adma_enable = 0;
@@ -580,7 +620,7 @@ static int nv_adma_slave_config(struct scsi_device *sdev)
                sg_tablesize = NV_ADMA_SGTBL_TOTAL_LEN;
                adma_enable = 1;
        }
-       
+
        pci_read_config_dword(pdev, NV_MCP_SATA_CFG_20, &current_reg);
 
        if(ap->port_no == 1)
@@ -589,7 +629,7 @@ static int nv_adma_slave_config(struct scsi_device *sdev)
        else
                config_mask = NV_MCP_SATA_CFG_20_PORT0_EN |
                              NV_MCP_SATA_CFG_20_PORT0_PWB_EN;
-       
+
        if(adma_enable) {
                new_reg = current_reg | config_mask;
                pp->flags &= ~NV_ADMA_ATAPI_SETUP_COMPLETE;
@@ -598,10 +638,10 @@ static int nv_adma_slave_config(struct scsi_device *sdev)
                new_reg = current_reg & ~config_mask;
                pp->flags |= NV_ADMA_ATAPI_SETUP_COMPLETE;
        }
-       
+
        if(current_reg != new_reg)
                pci_write_config_dword(pdev, NV_MCP_SATA_CFG_20, new_reg);
-       
+
        blk_queue_bounce_limit(sdev->request_queue, bounce_limit);
        blk_queue_segment_boundary(sdev->request_queue, segment_boundary);
        blk_queue_max_hw_segments(sdev->request_queue, sg_tablesize);
@@ -648,53 +688,62 @@ static unsigned int nv_adma_tf_to_cpb(struct ata_taskfile *tf, __le16 *cpb)
        return idx;
 }
 
-static void nv_adma_check_cpb(struct ata_port *ap, int cpb_num, int force_err)
+static int nv_adma_check_cpb(struct ata_port *ap, int cpb_num, int force_err)
 {
        struct nv_adma_port_priv *pp = ap->private_data;
-       int complete = 0, have_err = 0;
        u8 flags = pp->cpb[cpb_num].resp_flags;
 
        VPRINTK("CPB %d, flags=0x%x\n", cpb_num, flags);
 
-       if (flags & NV_CPB_RESP_DONE) {
-               VPRINTK("CPB flags done, flags=0x%x\n", flags);
-               complete = 1;
-       }
-       if (flags & NV_CPB_RESP_ATA_ERR) {
-               ata_port_printk(ap, KERN_ERR, "CPB flags ATA err, flags=0x%x\n", flags);
-               have_err = 1;
-               complete = 1;
-       }
-       if (flags & NV_CPB_RESP_CMD_ERR) {
-               ata_port_printk(ap, KERN_ERR, "CPB flags CMD err, flags=0x%x\n", flags);
-               have_err = 1;
-               complete = 1;
-       }
-       if (flags & NV_CPB_RESP_CPB_ERR) {
-               ata_port_printk(ap, KERN_ERR, "CPB flags CPB err, flags=0x%x\n", flags);
-               have_err = 1;
-               complete = 1;
+       if (unlikely((force_err ||
+                    flags & (NV_CPB_RESP_ATA_ERR |
+                             NV_CPB_RESP_CMD_ERR |
+                             NV_CPB_RESP_CPB_ERR)))) {
+               struct ata_eh_info *ehi = &ap->eh_info;
+               int freeze = 0;
+
+               ata_ehi_clear_desc(ehi);
+               ata_ehi_push_desc(ehi, "CPB resp_flags 0x%x", flags );
+               if (flags & NV_CPB_RESP_ATA_ERR) {
+                       ata_ehi_push_desc(ehi, ": ATA error");
+                       ehi->err_mask |= AC_ERR_DEV;
+               } else if (flags & NV_CPB_RESP_CMD_ERR) {
+                       ata_ehi_push_desc(ehi, ": CMD error");
+                       ehi->err_mask |= AC_ERR_DEV;
+               } else if (flags & NV_CPB_RESP_CPB_ERR) {
+                       ata_ehi_push_desc(ehi, ": CPB error");
+                       ehi->err_mask |= AC_ERR_SYSTEM;
+                       freeze = 1;
+               } else {
+                       /* notifier error, but no error in CPB flags? */
+                       ehi->err_mask |= AC_ERR_OTHER;
+                       freeze = 1;
+               }
+               /* Kill all commands. EH will determine what actually failed. */
+               if (freeze)
+                       ata_port_freeze(ap);
+               else
+                       ata_port_abort(ap);
+               return 1;
        }
-       if(complete || force_err)
-       {
+
+       if (flags & NV_CPB_RESP_DONE) {
                struct ata_queued_cmd *qc = ata_qc_from_tag(ap, cpb_num);
-               if(likely(qc)) {
-                       u8 ata_status = 0;
-                       /* Only use the ATA port status for non-NCQ commands.
+               VPRINTK("CPB flags done, flags=0x%x\n", flags);
+               if (likely(qc)) {
+                       /* Grab the ATA port status for non-NCQ commands.
                           For NCQ commands the current status may have nothing to do with
                           the command just completed. */
-                       if(qc->tf.protocol != ATA_PROT_NCQ)
-                               ata_status = readb(nv_adma_ctl_block(ap) + (ATA_REG_STATUS * 4));
-
-                       if(have_err || force_err)
-                               ata_status |= ATA_ERR;
-
-                       qc->err_mask |= ac_err_mask(ata_status);
+                       if (qc->tf.protocol != ATA_PROT_NCQ) {
+                               u8 ata_status = readb(pp->ctl_block + (ATA_REG_STATUS * 4));
+                               qc->err_mask |= ac_err_mask(ata_status);
+                       }
                        DPRINTK("Completing qc from tag %d with err_mask %u\n",cpb_num,
                                qc->err_mask);
                        ata_qc_complete(qc);
                }
        }
+       return 0;
 }
 
 static int nv_host_intr(struct ata_port *ap, u8 irq_stat)
@@ -735,15 +784,14 @@ static irqreturn_t nv_adma_interrupt(int irq, void *dev_instance)
 
                if (ap && !(ap->flags & ATA_FLAG_DISABLED)) {
                        struct nv_adma_port_priv *pp = ap->private_data;
-                       void __iomem *mmio = nv_adma_ctl_block(ap);
+                       void __iomem *mmio = pp->ctl_block;
                        u16 status;
                        u32 gen_ctl;
-                       int have_global_err = 0;
                        u32 notifier, notifier_error;
 
                        /* if in ATA register mode, use standard ata interrupt handler */
                        if (pp->flags & NV_ADMA_PORT_REGISTER_MODE) {
-                               u8 irq_stat = readb(host->mmio_base + NV_INT_STATUS_CK804)
+                               u8 irq_stat = readb(host->iomap[NV_MMIO_BAR] + NV_INT_STATUS_CK804)
                                        >> (NV_INT_PORT_SHIFT * i);
                                if(ata_tag_valid(ap->active_tag))
                                        /** NV_INT_DEV indication seems unreliable at times
@@ -758,7 +806,7 @@ static irqreturn_t nv_adma_interrupt(int irq, void *dev_instance)
                        notifier_error = readl(mmio + NV_ADMA_NOTIFIER_ERROR);
                        notifier_clears[i] = notifier | notifier_error;
 
-                       gen_ctl = readl(nv_adma_gen_block(ap) + NV_ADMA_GEN_CTL);
+                       gen_ctl = readl(pp->gen_block + NV_ADMA_GEN_CTL);
 
                        if( !NV_ADMA_CHECK_INTR(gen_ctl, ap->port_no) && !notifier &&
                            !notifier_error)
@@ -774,52 +822,60 @@ static irqreturn_t nv_adma_interrupt(int irq, void *dev_instance)
                        readw(mmio + NV_ADMA_STAT); /* flush posted write */
                        rmb();
 
-                       /* freeze if hotplugged */
-                       if (unlikely(status & (NV_ADMA_STAT_HOTPLUG | NV_ADMA_STAT_HOTUNPLUG))) {
-                               ata_port_printk(ap, KERN_NOTICE, "Hotplug event, freezing\n");
+                       handled++; /* irq handled if we got here */
+
+                       /* freeze if hotplugged or controller error */
+                       if (unlikely(status & (NV_ADMA_STAT_HOTPLUG |
+                                              NV_ADMA_STAT_HOTUNPLUG |
+                                              NV_ADMA_STAT_TIMEOUT))) {
+                               struct ata_eh_info *ehi = &ap->eh_info;
+
+                               ata_ehi_clear_desc(ehi);
+                               ata_ehi_push_desc(ehi, "ADMA status 0x%08x", status );
+                               if (status & NV_ADMA_STAT_TIMEOUT) {
+                                       ehi->err_mask |= AC_ERR_SYSTEM;
+                                       ata_ehi_push_desc(ehi, ": timeout");
+                               } else if (status & NV_ADMA_STAT_HOTPLUG) {
+                                       ata_ehi_hotplugged(ehi);
+                                       ata_ehi_push_desc(ehi, ": hotplug");
+                               } else if (status & NV_ADMA_STAT_HOTUNPLUG) {
+                                       ata_ehi_hotplugged(ehi);
+                                       ata_ehi_push_desc(ehi, ": hot unplug");
+                               }
                                ata_port_freeze(ap);
-                               handled++;
                                continue;
                        }
 
-                       if (status & NV_ADMA_STAT_TIMEOUT) {
-                               ata_port_printk(ap, KERN_ERR, "timeout, stat=0x%x\n", status);
-                               have_global_err = 1;
-                       }
-                       if (status & NV_ADMA_STAT_CPBERR) {
-                               ata_port_printk(ap, KERN_ERR, "CPB error, stat=0x%x\n", status);
-                               have_global_err = 1;
-                       }
-                       if ((status & NV_ADMA_STAT_DONE) || have_global_err) {
+                       if (status & (NV_ADMA_STAT_DONE |
+                                     NV_ADMA_STAT_CPBERR)) {
                                /** Check CPBs for completed commands */
 
-                               if(ata_tag_valid(ap->active_tag))
+                               if (ata_tag_valid(ap->active_tag)) {
                                        /* Non-NCQ command */
-                                       nv_adma_check_cpb(ap, ap->active_tag, have_global_err ||
-                                               (notifier_error & (1 << ap->active_tag)));
-                               else {
-                                       int pos;
+                                       nv_adma_check_cpb(ap, ap->active_tag,
+                                               notifier_error & (1 << ap->active_tag));
+                               else {
+                                       int pos, error = 0;
                                        u32 active = ap->sactive;
-                                       while( (pos = ffs(active)) ) {
+
+                                       while ((pos = ffs(active)) && !error) {
                                                pos--;
-                                               nv_adma_check_cpb(ap, pos, have_global_err ||
-                                                       (notifier_error & (1 << pos)) );
+                                               error = nv_adma_check_cpb(ap, pos,
+                                                       notifier_error & (1 << pos) );
                                                active &= ~(1 << pos );
                                        }
                                }
                        }
-
-                       handled++; /* irq handled if we got here */
                }
        }
-       
+
        if(notifier_clears[0] || notifier_clears[1]) {
                /* Note: Both notifier clear registers must be written
                   if either is set, even if one is zero, according to NVIDIA. */
-               writel(notifier_clears[0], 
-                       nv_adma_notifier_clear_block(host->ports[0]));
-               writel(notifier_clears[1], 
-                       nv_adma_notifier_clear_block(host->ports[1]));
+               struct nv_adma_port_priv *pp = host->ports[0]->private_data;
+               writel(notifier_clears[0], pp->notifier_clear_block);
+               pp = host->ports[1]->private_data;
+               writel(notifier_clears[1], pp->notifier_clear_block);
        }
 
        spin_unlock(&host->lock);
@@ -829,19 +885,20 @@ static irqreturn_t nv_adma_interrupt(int irq, void *dev_instance)
 
 static void nv_adma_irq_clear(struct ata_port *ap)
 {
-       void __iomem *mmio = nv_adma_ctl_block(ap);
+       struct nv_adma_port_priv *pp = ap->private_data;
+       void __iomem *mmio = pp->ctl_block;
        u16 status = readw(mmio + NV_ADMA_STAT);
        u32 notifier = readl(mmio + NV_ADMA_NOTIFIER);
        u32 notifier_error = readl(mmio + NV_ADMA_NOTIFIER_ERROR);
-       unsigned long dma_stat_addr = ap->ioaddr.bmdma_addr + ATA_DMA_STATUS;
+       void __iomem *dma_stat_addr = ap->ioaddr.bmdma_addr + ATA_DMA_STATUS;
 
        /* clear ADMA status */
        writew(status, mmio + NV_ADMA_STAT);
        writel(notifier | notifier_error,
-              nv_adma_notifier_clear_block(ap));
+              pp->notifier_clear_block);
 
        /** clear legacy status */
-       outb(inb(dma_stat_addr), dma_stat_addr);
+       iowrite8(ioread8(dma_stat_addr), dma_stat_addr);
 }
 
 static void nv_adma_bmdma_setup(struct ata_queued_cmd *qc)
@@ -857,15 +914,15 @@ static void nv_adma_bmdma_setup(struct ata_queued_cmd *qc)
        }
 
        /* load PRD table addr. */
-       outl(ap->prd_dma, ap->ioaddr.bmdma_addr + ATA_DMA_TABLE_OFS);
+       iowrite32(ap->prd_dma, ap->ioaddr.bmdma_addr + ATA_DMA_TABLE_OFS);
 
        /* specify data direction, triple-check start bit is clear */
-       dmactl = inb(ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
+       dmactl = ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
        dmactl &= ~(ATA_DMA_WR | ATA_DMA_START);
        if (!rw)
                dmactl |= ATA_DMA_WR;
 
-       outb(dmactl, ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
+       iowrite8(dmactl, ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
 
        /* issue r/w command */
        ata_exec_command(ap, &qc->tf);
@@ -883,9 +940,9 @@ static void nv_adma_bmdma_start(struct ata_queued_cmd *qc)
        }
 
        /* start host DMA transaction */
-       dmactl = inb(ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
-       outb(dmactl | ATA_DMA_START,
-            ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
+       dmactl = ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
+       iowrite8(dmactl | ATA_DMA_START,
+                ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
 }
 
 static void nv_adma_bmdma_stop(struct ata_queued_cmd *qc)
@@ -897,8 +954,8 @@ static void nv_adma_bmdma_stop(struct ata_queued_cmd *qc)
                return;
 
        /* clear start/stop bit */
-       outb(inb(ap->ioaddr.bmdma_addr + ATA_DMA_CMD) & ~ATA_DMA_START,
-               ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
+       iowrite8(ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_CMD) & ~ATA_DMA_START,
+                ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
 
        /* one-PIO-cycle guaranteed wait, per spec, for HDMA1:0 transition */
        ata_altstatus(ap);        /* dummy read */
@@ -910,7 +967,7 @@ static u8 nv_adma_bmdma_status(struct ata_port *ap)
 
        WARN_ON(!(pp->flags & NV_ADMA_PORT_REGISTER_MODE));
 
-       return inb(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS);
+       return ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS);
 }
 
 static int nv_adma_port_start(struct ata_port *ap)
@@ -920,7 +977,7 @@ static int nv_adma_port_start(struct ata_port *ap)
        int rc;
        void *mem;
        dma_addr_t mem_dma;
-       void __iomem *mmio = nv_adma_ctl_block(ap);
+       void __iomem *mmio;
        u16 tmp;
 
        VPRINTK("ENTER\n");
@@ -929,19 +986,21 @@ static int nv_adma_port_start(struct ata_port *ap)
        if (rc)
                return rc;
 
-       pp = kzalloc(sizeof(*pp), GFP_KERNEL);
-       if (!pp) {
-               rc = -ENOMEM;
-               goto err_out;
-       }
-
-       mem = dma_alloc_coherent(dev, NV_ADMA_PORT_PRIV_DMA_SZ,
-                                &mem_dma, GFP_KERNEL);
-
-       if (!mem) {
-               rc = -ENOMEM;
-               goto err_out_kfree;
-       }
+       pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL);
+       if (!pp)
+               return -ENOMEM;
+
+       mmio = ap->host->iomap[NV_MMIO_BAR] + NV_ADMA_PORT +
+              ap->port_no * NV_ADMA_PORT_SIZE;
+       pp->ctl_block = mmio;
+       pp->gen_block = ap->host->iomap[NV_MMIO_BAR] + NV_ADMA_GEN;
+       pp->notifier_clear_block = pp->gen_block +
+              NV_ADMA_NOTIFIER_CLEAR + (4 * ap->port_no);
+
+       mem = dmam_alloc_coherent(dev, NV_ADMA_PORT_PRIV_DMA_SZ,
+                                 &mem_dma, GFP_KERNEL);
+       if (!mem)
+               return -ENOMEM;
        memset(mem, 0, NV_ADMA_PORT_PRIV_DMA_SZ);
 
        /*
@@ -975,9 +1034,9 @@ static int nv_adma_port_start(struct ata_port *ap)
        /* clear CPB fetch count */
        writew(0, mmio + NV_ADMA_CPB_COUNT);
 
-       /* clear GO for register mode */
+       /* clear GO for register mode, enable interrupt */
        tmp = readw(mmio + NV_ADMA_CTL);
-       writew(tmp & ~NV_ADMA_CTL_GO, mmio + NV_ADMA_CTL);
+       writew( (tmp & ~NV_ADMA_CTL_GO) | NV_ADMA_CTL_AIEN, mmio + NV_ADMA_CTL);
 
        tmp = readw(mmio + NV_ADMA_CTL);
        writew(tmp | NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL);
@@ -987,53 +1046,89 @@ static int nv_adma_port_start(struct ata_port *ap)
        readl( mmio + NV_ADMA_CTL );    /* flush posted write */
 
        return 0;
-
-err_out_kfree:
-       kfree(pp);
-err_out:
-       ata_port_stop(ap);
-       return rc;
 }
 
 static void nv_adma_port_stop(struct ata_port *ap)
 {
-       struct device *dev = ap->host->dev;
        struct nv_adma_port_priv *pp = ap->private_data;
-       void __iomem *mmio = nv_adma_ctl_block(ap);
+       void __iomem *mmio = pp->ctl_block;
 
        VPRINTK("ENTER\n");
+       writew(0, mmio + NV_ADMA_CTL);
+}
+
+static int nv_adma_port_suspend(struct ata_port *ap, pm_message_t mesg)
+{
+       struct nv_adma_port_priv *pp = ap->private_data;
+       void __iomem *mmio = pp->ctl_block;
 
+       /* Go to register mode - clears GO */
+       nv_adma_register_mode(ap);
+
+       /* clear CPB fetch count */
+       writew(0, mmio + NV_ADMA_CPB_COUNT);
+
+       /* disable interrupt, shut down port */
        writew(0, mmio + NV_ADMA_CTL);
 
-       ap->private_data = NULL;
-       dma_free_coherent(dev, NV_ADMA_PORT_PRIV_DMA_SZ, pp->cpb, pp->cpb_dma);
-       kfree(pp);
-       ata_port_stop(ap);
+       return 0;
 }
 
+static int nv_adma_port_resume(struct ata_port *ap)
+{
+       struct nv_adma_port_priv *pp = ap->private_data;
+       void __iomem *mmio = pp->ctl_block;
+       u16 tmp;
+
+       /* set CPB block location */
+       writel(pp->cpb_dma & 0xFFFFFFFF,        mmio + NV_ADMA_CPB_BASE_LOW);
+       writel((pp->cpb_dma >> 16 ) >> 16,      mmio + NV_ADMA_CPB_BASE_HIGH);
+
+       /* clear any outstanding interrupt conditions */
+       writew(0xffff, mmio + NV_ADMA_STAT);
+
+       /* initialize port variables */
+       pp->flags |= NV_ADMA_PORT_REGISTER_MODE;
+
+       /* clear CPB fetch count */
+       writew(0, mmio + NV_ADMA_CPB_COUNT);
+
+       /* clear GO for register mode, enable interrupt */
+       tmp = readw(mmio + NV_ADMA_CTL);
+       writew((tmp & ~NV_ADMA_CTL_GO) | NV_ADMA_CTL_AIEN, mmio + NV_ADMA_CTL);
+
+       tmp = readw(mmio + NV_ADMA_CTL);
+       writew(tmp | NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL);
+       readl( mmio + NV_ADMA_CTL );    /* flush posted write */
+       udelay(1);
+       writew(tmp & ~NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL);
+       readl( mmio + NV_ADMA_CTL );    /* flush posted write */
+
+       return 0;
+}
 
 static void nv_adma_setup_port(struct ata_probe_ent *probe_ent, unsigned int port)
 {
-       void __iomem *mmio = probe_ent->mmio_base;
+       void __iomem *mmio = probe_ent->iomap[NV_MMIO_BAR];
        struct ata_ioports *ioport = &probe_ent->port[port];
 
        VPRINTK("ENTER\n");
 
        mmio += NV_ADMA_PORT + port * NV_ADMA_PORT_SIZE;
 
-       ioport->cmd_addr        = (unsigned long) mmio;
-       ioport->data_addr       = (unsigned long) mmio + (ATA_REG_DATA * 4);
+       ioport->cmd_addr        = mmio;
+       ioport->data_addr       = mmio + (ATA_REG_DATA * 4);
        ioport->error_addr      =
-       ioport->feature_addr    = (unsigned long) mmio + (ATA_REG_ERR * 4);
-       ioport->nsect_addr      = (unsigned long) mmio + (ATA_REG_NSECT * 4);
-       ioport->lbal_addr       = (unsigned long) mmio + (ATA_REG_LBAL * 4);
-       ioport->lbam_addr       = (unsigned long) mmio + (ATA_REG_LBAM * 4);
-       ioport->lbah_addr       = (unsigned long) mmio + (ATA_REG_LBAH * 4);
-       ioport->device_addr     = (unsigned long) mmio + (ATA_REG_DEVICE * 4);
+       ioport->feature_addr    = mmio + (ATA_REG_ERR * 4);
+       ioport->nsect_addr      = mmio + (ATA_REG_NSECT * 4);
+       ioport->lbal_addr       = mmio + (ATA_REG_LBAL * 4);
+       ioport->lbam_addr       = mmio + (ATA_REG_LBAM * 4);
+       ioport->lbah_addr       = mmio + (ATA_REG_LBAH * 4);
+       ioport->device_addr     = mmio + (ATA_REG_DEVICE * 4);
        ioport->status_addr     =
-       ioport->command_addr    = (unsigned long) mmio + (ATA_REG_STATUS * 4);
+       ioport->command_addr    = mmio + (ATA_REG_STATUS * 4);
        ioport->altstatus_addr  =
-       ioport->ctl_addr        = (unsigned long) mmio + 0x20;
+       ioport->ctl_addr        = mmio + 0x20;
 }
 
 static int nv_adma_host_init(struct ata_probe_ent *probe_ent)
@@ -1056,15 +1151,6 @@ static int nv_adma_host_init(struct ata_probe_ent *probe_ent)
        for (i = 0; i < probe_ent->n_ports; i++)
                nv_adma_setup_port(probe_ent, i);
 
-       for (i = 0; i < probe_ent->n_ports; i++) {
-               void __iomem *mmio = __nv_adma_ctl_block(probe_ent->mmio_base, i);
-               u16 tmp;
-
-               /* enable interrupt, clear reset if not already clear */
-               tmp = readw(mmio + NV_ADMA_CTL);
-               writew(tmp | NV_ADMA_CTL_AIEN, mmio + NV_ADMA_CTL);
-       }
-
        return 0;
 }
 
@@ -1110,18 +1196,31 @@ static void nv_adma_fill_sg(struct ata_queued_cmd *qc, struct nv_adma_cpb *cpb)
                cpb->next_aprd = cpu_to_le64(((u64)(pp->aprd_dma + NV_ADMA_SGTBL_SZ * qc->tag)));
 }
 
+static int nv_adma_use_reg_mode(struct ata_queued_cmd *qc)
+{
+       struct nv_adma_port_priv *pp = qc->ap->private_data;
+
+       /* ADMA engine can only be used for non-ATAPI DMA commands,
+          or interrupt-driven no-data commands. */
+       if((pp->flags & NV_ADMA_ATAPI_SETUP_COMPLETE) ||
+          (qc->tf.flags & ATA_TFLAG_POLLING))
+               return 1;
+
+       if((qc->flags & ATA_QCFLAG_DMAMAP) ||
+          (qc->tf.protocol == ATA_PROT_NODATA))
+               return 0;
+
+       return 1;
+}
+
 static void nv_adma_qc_prep(struct ata_queued_cmd *qc)
 {
        struct nv_adma_port_priv *pp = qc->ap->private_data;
        struct nv_adma_cpb *cpb = &pp->cpb[qc->tag];
        u8 ctl_flags = NV_CPB_CTL_CPB_VALID |
-                      NV_CPB_CTL_APRD_VALID |
                       NV_CPB_CTL_IEN;
 
-       VPRINTK("qc->flags = 0x%lx\n", qc->flags);
-
-       if (!(qc->flags & ATA_QCFLAG_DMAMAP) ||
-            (pp->flags & NV_ADMA_ATAPI_SETUP_COMPLETE)) {
+       if (nv_adma_use_reg_mode(qc)) {
                nv_adma_register_mode(qc->ap);
                ata_qc_prep(qc);
                return;
@@ -1137,9 +1236,15 @@ static void nv_adma_qc_prep(struct ata_queued_cmd *qc)
        if (qc->tf.protocol == ATA_PROT_NCQ)
                ctl_flags |= NV_CPB_CTL_QUEUE | NV_CPB_CTL_FPDMA;
 
+       VPRINTK("qc->flags = 0x%lx\n", qc->flags);
+
        nv_adma_tf_to_cpb(&qc->tf, cpb->tf);
 
-       nv_adma_fill_sg(qc, cpb);
+       if(qc->flags & ATA_QCFLAG_DMAMAP) {
+               nv_adma_fill_sg(qc, cpb);
+               ctl_flags |= NV_CPB_CTL_APRD_VALID;
+       } else
+               memset(&cpb->aprd[0], 0, sizeof(struct nv_adma_prd) * 5);
 
        /* Be paranoid and don't let the device see NV_CPB_CTL_CPB_VALID until we are
           finished filling in all of the contents */
@@ -1150,14 +1255,13 @@ static void nv_adma_qc_prep(struct ata_queued_cmd *qc)
 static unsigned int nv_adma_qc_issue(struct ata_queued_cmd *qc)
 {
        struct nv_adma_port_priv *pp = qc->ap->private_data;
-       void __iomem *mmio = nv_adma_ctl_block(qc->ap);
+       void __iomem *mmio = pp->ctl_block;
 
        VPRINTK("ENTER\n");
 
-       if (!(qc->flags & ATA_QCFLAG_DMAMAP) ||
-            (pp->flags & NV_ADMA_ATAPI_SETUP_COMPLETE)) {
+       if (nv_adma_use_reg_mode(qc)) {
                /* use ATA register mode */
-               VPRINTK("no dmamap or ATAPI, using ATA register mode: 0x%lx\n", qc->flags);
+               VPRINTK("using ATA register mode: 0x%lx\n", qc->flags);
                nv_adma_register_mode(qc->ap);
                return ata_qc_issue_prot(qc);
        } else
@@ -1229,7 +1333,7 @@ static irqreturn_t nv_nf2_interrupt(int irq, void *dev_instance)
        irqreturn_t ret;
 
        spin_lock(&host->lock);
-       irq_stat = inb(host->ports[0]->ioaddr.scr_addr + NV_INT_STATUS);
+       irq_stat = ioread8(host->ports[0]->ioaddr.scr_addr + NV_INT_STATUS);
        ret = nv_do_interrupt(host, irq_stat);
        spin_unlock(&host->lock);
 
@@ -1243,7 +1347,7 @@ static irqreturn_t nv_ck804_interrupt(int irq, void *dev_instance)
        irqreturn_t ret;
 
        spin_lock(&host->lock);
-       irq_stat = readb(host->mmio_base + NV_INT_STATUS_CK804);
+       irq_stat = readb(host->iomap[NV_MMIO_BAR] + NV_INT_STATUS_CK804);
        ret = nv_do_interrupt(host, irq_stat);
        spin_unlock(&host->lock);
 
@@ -1255,7 +1359,7 @@ static u32 nv_scr_read (struct ata_port *ap, unsigned int sc_reg)
        if (sc_reg > SCR_CONTROL)
                return 0xffffffffU;
 
-       return ioread32((void __iomem *)ap->ioaddr.scr_addr + (sc_reg * 4));
+       return ioread32(ap->ioaddr.scr_addr + (sc_reg * 4));
 }
 
 static void nv_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val)
@@ -1263,36 +1367,36 @@ static void nv_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val)
        if (sc_reg > SCR_CONTROL)
                return;
 
-       iowrite32(val, (void __iomem *)ap->ioaddr.scr_addr + (sc_reg * 4));
+       iowrite32(val, ap->ioaddr.scr_addr + (sc_reg * 4));
 }
 
 static void nv_nf2_freeze(struct ata_port *ap)
 {
-       unsigned long scr_addr = ap->host->ports[0]->ioaddr.scr_addr;
+       void __iomem *scr_addr = ap->host->ports[0]->ioaddr.scr_addr;
        int shift = ap->port_no * NV_INT_PORT_SHIFT;
        u8 mask;
 
-       mask = inb(scr_addr + NV_INT_ENABLE);
+       mask = ioread8(scr_addr + NV_INT_ENABLE);
        mask &= ~(NV_INT_ALL << shift);
-       outb(mask, scr_addr + NV_INT_ENABLE);
+       iowrite8(mask, scr_addr + NV_INT_ENABLE);
 }
 
 static void nv_nf2_thaw(struct ata_port *ap)
 {
-       unsigned long scr_addr = ap->host->ports[0]->ioaddr.scr_addr;
+       void __iomem *scr_addr = ap->host->ports[0]->ioaddr.scr_addr;
        int shift = ap->port_no * NV_INT_PORT_SHIFT;
        u8 mask;
 
-       outb(NV_INT_ALL << shift, scr_addr + NV_INT_STATUS);
+       iowrite8(NV_INT_ALL << shift, scr_addr + NV_INT_STATUS);
 
-       mask = inb(scr_addr + NV_INT_ENABLE);
+       mask = ioread8(scr_addr + NV_INT_ENABLE);
        mask |= (NV_INT_MASK << shift);
-       outb(mask, scr_addr + NV_INT_ENABLE);
+       iowrite8(mask, scr_addr + NV_INT_ENABLE);
 }
 
 static void nv_ck804_freeze(struct ata_port *ap)
 {
-       void __iomem *mmio_base = ap->host->mmio_base;
+       void __iomem *mmio_base = ap->host->iomap[NV_MMIO_BAR];
        int shift = ap->port_no * NV_INT_PORT_SHIFT;
        u8 mask;
 
@@ -1303,7 +1407,7 @@ static void nv_ck804_freeze(struct ata_port *ap)
 
 static void nv_ck804_thaw(struct ata_port *ap)
 {
-       void __iomem *mmio_base = ap->host->mmio_base;
+       void __iomem *mmio_base = ap->host->iomap[NV_MMIO_BAR];
        int shift = ap->port_no * NV_INT_PORT_SHIFT;
        u8 mask;
 
@@ -1335,32 +1439,13 @@ static void nv_adma_error_handler(struct ata_port *ap)
 {
        struct nv_adma_port_priv *pp = ap->private_data;
        if(!(pp->flags & NV_ADMA_PORT_REGISTER_MODE)) {
-               void __iomem *mmio = nv_adma_ctl_block(ap);
+               void __iomem *mmio = pp->ctl_block;
                int i;
                u16 tmp;
 
-               u32 notifier = readl(mmio + NV_ADMA_NOTIFIER);
-               u32 notifier_error = readl(mmio + NV_ADMA_NOTIFIER_ERROR);
-               u32 gen_ctl = readl(nv_adma_gen_block(ap) + NV_ADMA_GEN_CTL);
-               u32 status = readw(mmio + NV_ADMA_STAT);
-
-               ata_port_printk(ap, KERN_ERR, "EH in ADMA mode, notifier 0x%X "
-                       "notifier_error 0x%X gen_ctl 0x%X status 0x%X\n",
-                       notifier, notifier_error, gen_ctl, status);
-
-               for( i=0;i<NV_ADMA_MAX_CPBS;i++) {
-                       struct nv_adma_cpb *cpb = &pp->cpb[i];
-                       if( cpb->ctl_flags || cpb->resp_flags )
-                               ata_port_printk(ap, KERN_ERR,
-                                       "CPB %d: ctl_flags 0x%x, resp_flags 0x%x\n",
-                                       i, cpb->ctl_flags, cpb->resp_flags);
-               }
-
                /* Push us back into port register mode for error handling. */
                nv_adma_register_mode(ap);
 
-               ata_port_printk(ap, KERN_ERR, "Resetting port\n");
-
                /* Mark all of the CPBs as invalid to prevent them from being executed */
                for( i=0;i<NV_ADMA_MAX_CPBS;i++)
                        pp->cpb[i].ctl_flags &= ~NV_CPB_CTL_CPB_VALID;
@@ -1386,10 +1471,10 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
        static int printed_version = 0;
        struct ata_port_info *ppi[2];
        struct ata_probe_ent *probe_ent;
-       int pci_dev_busy = 0;
+       struct nv_host_priv *hpriv;
        int rc;
        u32 bar;
-       unsigned long base;
+       void __iomem *base;
        unsigned long type = ent->driver_data;
        int mask_set = 0;
 
@@ -1400,17 +1485,17 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
                if (pci_resource_start(pdev, bar) == 0)
                        return -ENODEV;
 
-       if (    !printed_version++)
+       if (!printed_version++)
                dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
 
-       rc = pci_enable_device(pdev);
+       rc = pcim_enable_device(pdev);
        if (rc)
-               goto err_out;
+               return rc;
 
        rc = pci_request_regions(pdev, DRV_NAME);
        if (rc) {
-               pci_dev_busy = 1;
-               goto err_out_disable;
+               pcim_pin_device(pdev);
+               return rc;
        }
 
        if(type >= CK804 && adma_enabled) {
@@ -1424,27 +1509,31 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
        if(!mask_set) {
                rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
                if (rc)
-                       goto err_out_regions;
+                       return rc;
                rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK);
                if (rc)
-                       goto err_out_regions;
+                       return rc;
        }
 
        rc = -ENOMEM;
 
+       hpriv = devm_kzalloc(&pdev->dev, sizeof(*hpriv), GFP_KERNEL);
+       if (!hpriv)
+               return -ENOMEM;
+
        ppi[0] = ppi[1] = &nv_port_info[type];
        probe_ent = ata_pci_init_native_mode(pdev, ppi, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY);
        if (!probe_ent)
-               goto err_out_regions;
+               return -ENOMEM;
 
-       probe_ent->mmio_base = pci_iomap(pdev, 5, 0);
-       if (!probe_ent->mmio_base) {
-               rc = -EIO;
-               goto err_out_free_ent;
-       }
+       if (!pcim_iomap(pdev, NV_MMIO_BAR, 0))
+               return -EIO;
+       probe_ent->iomap = pcim_iomap_table(pdev);
 
-       base = (unsigned long)probe_ent->mmio_base;
+       probe_ent->private_data = hpriv;
+       hpriv->type = type;
 
+       base = probe_ent->iomap[NV_MMIO_BAR];
        probe_ent->port[0].scr_addr = base + NV_PORT0_SCR_REG_OFFSET;
        probe_ent->port[1].scr_addr = base + NV_PORT1_SCR_REG_OFFSET;
 
@@ -1462,28 +1551,72 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
        if (type == ADMA) {
                rc = nv_adma_host_init(probe_ent);
                if (rc)
-                       goto err_out_iounmap;
+                       return rc;
        }
 
        rc = ata_device_add(probe_ent);
        if (rc != NV_PORTS)
-               goto err_out_iounmap;
-
-       kfree(probe_ent);
+               return -ENODEV;
 
+       devm_kfree(&pdev->dev, probe_ent);
        return 0;
+}
 
-err_out_iounmap:
-       pci_iounmap(pdev, probe_ent->mmio_base);
-err_out_free_ent:
-       kfree(probe_ent);
-err_out_regions:
-       pci_release_regions(pdev);
-err_out_disable:
-       if (!pci_dev_busy)
-               pci_disable_device(pdev);
-err_out:
-       return rc;
+static void nv_remove_one (struct pci_dev *pdev)
+{
+       struct ata_host *host = dev_get_drvdata(&pdev->dev);
+       struct nv_host_priv *hpriv = host->private_data;
+
+       ata_pci_remove_one(pdev);
+       kfree(hpriv);
+}
+
+static int nv_pci_device_resume(struct pci_dev *pdev)
+{
+       struct ata_host *host = dev_get_drvdata(&pdev->dev);
+       struct nv_host_priv *hpriv = host->private_data;
+       int rc;
+
+       rc = ata_pci_device_do_resume(pdev);
+       if(rc)
+               return rc;
+
+       if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) {
+               if(hpriv->type >= CK804) {
+                       u8 regval;
+
+                       pci_read_config_byte(pdev, NV_MCP_SATA_CFG_20, &regval);
+                       regval |= NV_MCP_SATA_CFG_20_SATA_SPACE_EN;
+                       pci_write_config_byte(pdev, NV_MCP_SATA_CFG_20, regval);
+               }
+               if(hpriv->type == ADMA) {
+                       u32 tmp32;
+                       struct nv_adma_port_priv *pp;
+                       /* enable/disable ADMA on the ports appropriately */
+                       pci_read_config_dword(pdev, NV_MCP_SATA_CFG_20, &tmp32);
+
+                       pp = host->ports[0]->private_data;
+                       if(pp->flags & NV_ADMA_ATAPI_SETUP_COMPLETE)
+                               tmp32 &= ~(NV_MCP_SATA_CFG_20_PORT0_EN |
+                                          NV_MCP_SATA_CFG_20_PORT0_PWB_EN);
+                       else
+                               tmp32 |=  (NV_MCP_SATA_CFG_20_PORT0_EN |
+                                          NV_MCP_SATA_CFG_20_PORT0_PWB_EN);
+                       pp = host->ports[1]->private_data;
+                       if(pp->flags & NV_ADMA_ATAPI_SETUP_COMPLETE)
+                               tmp32 &= ~(NV_MCP_SATA_CFG_20_PORT1_EN |
+                                          NV_MCP_SATA_CFG_20_PORT1_PWB_EN);
+                       else
+                               tmp32 |=  (NV_MCP_SATA_CFG_20_PORT1_EN |
+                                          NV_MCP_SATA_CFG_20_PORT1_PWB_EN);
+
+                       pci_write_config_dword(pdev, NV_MCP_SATA_CFG_20, tmp32);
+               }
+       }
+
+       ata_host_resume(host);
+
+       return 0;
 }
 
 static void nv_ck804_host_stop(struct ata_host *host)
@@ -1495,25 +1628,13 @@ static void nv_ck804_host_stop(struct ata_host *host)
        pci_read_config_byte(pdev, NV_MCP_SATA_CFG_20, &regval);
        regval &= ~NV_MCP_SATA_CFG_20_SATA_SPACE_EN;
        pci_write_config_byte(pdev, NV_MCP_SATA_CFG_20, regval);
-
-       ata_pci_host_stop(host);
 }
 
 static void nv_adma_host_stop(struct ata_host *host)
 {
        struct pci_dev *pdev = to_pci_dev(host->dev);
-       int i;
        u32 tmp32;
 
-       for (i = 0; i < host->n_ports; i++) {
-               void __iomem *mmio = __nv_adma_ctl_block(host->mmio_base, i);
-               u16 tmp;
-
-               /* disable interrupt */
-               tmp = readw(mmio + NV_ADMA_CTL);
-               writew(tmp & ~NV_ADMA_CTL_AIEN, mmio + NV_ADMA_CTL);
-       }
-
        /* disable ADMA on the ports */
        pci_read_config_dword(pdev, NV_MCP_SATA_CFG_20, &tmp32);
        tmp32 &= ~(NV_MCP_SATA_CFG_20_PORT0_EN |
index f055874a6ec5d303a11960fe88605c8975e7923c..3be4cc338d7bd6b6265a3d9aad5d75caab68df2d 100644 (file)
 #include <linux/interrupt.h>
 #include <linux/sched.h>
 #include <linux/device.h>
+#include <scsi/scsi.h>
 #include <scsi/scsi_host.h>
 #include <scsi/scsi_cmnd.h>
 #include <linux/libata.h>
-#include <asm/io.h>
 #include "sata_promise.h"
 
 #define DRV_NAME       "sata_promise"
 
 
 enum {
+       PDC_MMIO_BAR            = 3,
+
+       /* register offsets */
+       PDC_FEATURE             = 0x04, /* Feature/Error reg (per port) */
+       PDC_SECTOR_COUNT        = 0x08, /* Sector count reg (per port) */
+       PDC_SECTOR_NUMBER       = 0x0C, /* Sector number reg (per port) */
+       PDC_CYLINDER_LOW        = 0x10, /* Cylinder low reg (per port) */
+       PDC_CYLINDER_HIGH       = 0x14, /* Cylinder high reg (per port) */
+       PDC_DEVICE              = 0x18, /* Device/Head reg (per port) */
+       PDC_COMMAND             = 0x1C, /* Command/status reg (per port) */
+       PDC_ALTSTATUS           = 0x38, /* Alternate-status/device-control reg (per port) */
        PDC_PKT_SUBMIT          = 0x40, /* Command packet pointer addr */
        PDC_INT_SEQMASK         = 0x40, /* Mask of asserted SEQ INTs */
        PDC_FLASH_CTL           = 0x44, /* Flash control register */
@@ -71,13 +82,23 @@ enum {
 
        PDC_HAS_PATA            = (1 << 1), /* PDC20375/20575 has PATA */
 
+       /* Sequence counter control registers bit definitions */
+       PDC_SEQCNTRL_INT_MASK   = (1 << 5), /* Sequence Interrupt Mask */
+
+       /* Feature register values */
+       PDC_FEATURE_ATAPI_PIO   = 0x00, /* ATAPI data xfer by PIO */
+       PDC_FEATURE_ATAPI_DMA   = 0x01, /* ATAPI data xfer by DMA */
+
+       /* Device/Head register values */
+       PDC_DEVICE_SATA         = 0xE0, /* Device/Head value for SATA devices */
+
        /* PDC_CTLSTAT bit definitions */
        PDC_DMA_ENABLE          = (1 << 7),
        PDC_IRQ_DISABLE         = (1 << 10),
        PDC_RESET               = (1 << 11), /* HDMA reset */
 
        PDC_COMMON_FLAGS        = ATA_FLAG_NO_LEGACY |
-                                 ATA_FLAG_MMIO | ATA_FLAG_NO_ATAPI |
+                                 ATA_FLAG_MMIO |
                                  ATA_FLAG_PIO_POLLING,
 
        /* hp->flags bits */
@@ -92,6 +113,7 @@ struct pdc_port_priv {
 
 struct pdc_host_priv {
        unsigned long           flags;
+       unsigned long           port_flags[ATA_MAX_PORTS];
 };
 
 static u32 pdc_sata_scr_read (struct ata_port *ap, unsigned int sc_reg);
@@ -100,14 +122,14 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
 static irqreturn_t pdc_interrupt (int irq, void *dev_instance);
 static void pdc_eng_timeout(struct ata_port *ap);
 static int pdc_port_start(struct ata_port *ap);
-static void pdc_port_stop(struct ata_port *ap);
 static void pdc_pata_phy_reset(struct ata_port *ap);
 static void pdc_qc_prep(struct ata_queued_cmd *qc);
 static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf);
 static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf);
+static int pdc_check_atapi_dma(struct ata_queued_cmd *qc);
+static int pdc_old_check_atapi_dma(struct ata_queued_cmd *qc);
 static void pdc_irq_clear(struct ata_port *ap);
 static unsigned int pdc_qc_issue_prot(struct ata_queued_cmd *qc);
-static void pdc_host_stop(struct ata_host *host);
 static void pdc_freeze(struct ata_port *ap);
 static void pdc_thaw(struct ata_port *ap);
 static void pdc_error_handler(struct ata_port *ap);
@@ -139,6 +161,34 @@ static const struct ata_port_operations pdc_sata_ops = {
        .check_status           = ata_check_status,
        .exec_command           = pdc_exec_command_mmio,
        .dev_select             = ata_std_dev_select,
+       .check_atapi_dma        = pdc_check_atapi_dma,
+
+       .qc_prep                = pdc_qc_prep,
+       .qc_issue               = pdc_qc_issue_prot,
+       .freeze                 = pdc_freeze,
+       .thaw                   = pdc_thaw,
+       .error_handler          = pdc_error_handler,
+       .post_internal_cmd      = pdc_post_internal_cmd,
+       .data_xfer              = ata_data_xfer,
+       .irq_handler            = pdc_interrupt,
+       .irq_clear              = pdc_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
+
+       .scr_read               = pdc_sata_scr_read,
+       .scr_write              = pdc_sata_scr_write,
+       .port_start             = pdc_port_start,
+};
+
+/* First-generation chips need a more restrictive ->check_atapi_dma op */
+static const struct ata_port_operations pdc_old_sata_ops = {
+       .port_disable           = ata_port_disable,
+       .tf_load                = pdc_tf_load_mmio,
+       .tf_read                = ata_tf_read,
+       .check_status           = ata_check_status,
+       .exec_command           = pdc_exec_command_mmio,
+       .dev_select             = ata_std_dev_select,
+       .check_atapi_dma        = pdc_old_check_atapi_dma,
 
        .qc_prep                = pdc_qc_prep,
        .qc_issue               = pdc_qc_issue_prot,
@@ -146,15 +196,15 @@ static const struct ata_port_operations pdc_sata_ops = {
        .thaw                   = pdc_thaw,
        .error_handler          = pdc_error_handler,
        .post_internal_cmd      = pdc_post_internal_cmd,
-       .data_xfer              = ata_mmio_data_xfer,
+       .data_xfer              = ata_data_xfer,
        .irq_handler            = pdc_interrupt,
        .irq_clear              = pdc_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
 
        .scr_read               = pdc_sata_scr_read,
        .scr_write              = pdc_sata_scr_write,
        .port_start             = pdc_port_start,
-       .port_stop              = pdc_port_stop,
-       .host_stop              = pdc_host_stop,
 };
 
 static const struct ata_port_operations pdc_pata_ops = {
@@ -164,30 +214,31 @@ static const struct ata_port_operations pdc_pata_ops = {
        .check_status           = ata_check_status,
        .exec_command           = pdc_exec_command_mmio,
        .dev_select             = ata_std_dev_select,
+       .check_atapi_dma        = pdc_check_atapi_dma,
 
        .phy_reset              = pdc_pata_phy_reset,
 
        .qc_prep                = pdc_qc_prep,
        .qc_issue               = pdc_qc_issue_prot,
-       .data_xfer              = ata_mmio_data_xfer,
+       .data_xfer              = ata_data_xfer,
        .eng_timeout            = pdc_eng_timeout,
        .irq_handler            = pdc_interrupt,
        .irq_clear              = pdc_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
 
        .port_start             = pdc_port_start,
-       .port_stop              = pdc_port_stop,
-       .host_stop              = pdc_host_stop,
 };
 
 static const struct ata_port_info pdc_port_info[] = {
        /* board_2037x */
        {
                .sht            = &pdc_ata_sht,
-               .flags          = PDC_COMMON_FLAGS | ATA_FLAG_SATA,
+               .flags          = PDC_COMMON_FLAGS,
                .pio_mask       = 0x1f, /* pio0-4 */
                .mwdma_mask     = 0x07, /* mwdma0-2 */
                .udma_mask      = 0x7f, /* udma0-6 ; FIXME */
-               .port_ops       = &pdc_sata_ops,
+               .port_ops       = &pdc_old_sata_ops,
        },
 
        /* board_20319 */
@@ -197,7 +248,7 @@ static const struct ata_port_info pdc_port_info[] = {
                .pio_mask       = 0x1f, /* pio0-4 */
                .mwdma_mask     = 0x07, /* mwdma0-2 */
                .udma_mask      = 0x7f, /* udma0-6 ; FIXME */
-               .port_ops       = &pdc_sata_ops,
+               .port_ops       = &pdc_old_sata_ops,
        },
 
        /* board_20619 */
@@ -213,7 +264,7 @@ static const struct ata_port_info pdc_port_info[] = {
        /* board_2057x */
        {
                .sht            = &pdc_ata_sht,
-               .flags          = PDC_COMMON_FLAGS | ATA_FLAG_SATA,
+               .flags          = PDC_COMMON_FLAGS,
                .pio_mask       = 0x1f, /* pio0-4 */
                .mwdma_mask     = 0x07, /* mwdma0-2 */
                .udma_mask      = 0x7f, /* udma0-6 ; FIXME */
@@ -271,21 +322,22 @@ static int pdc_port_start(struct ata_port *ap)
        struct pdc_port_priv *pp;
        int rc;
 
+       /* fix up port flags and cable type for SATA+PATA chips */
+       ap->flags |= hp->port_flags[ap->port_no];
+       if (ap->flags & ATA_FLAG_SATA)
+               ap->cbl = ATA_CBL_SATA;
+
        rc = ata_port_start(ap);
        if (rc)
                return rc;
 
-       pp = kzalloc(sizeof(*pp), GFP_KERNEL);
-       if (!pp) {
-               rc = -ENOMEM;
-               goto err_out;
-       }
+       pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL);
+       if (!pp)
+               return -ENOMEM;
 
-       pp->pkt = dma_alloc_coherent(dev, 128, &pp->pkt_dma, GFP_KERNEL);
-       if (!pp->pkt) {
-               rc = -ENOMEM;
-               goto err_out_kfree;
-       }
+       pp->pkt = dmam_alloc_coherent(dev, 128, &pp->pkt_dma, GFP_KERNEL);
+       if (!pp->pkt)
+               return -ENOMEM;
 
        ap->private_data = pp;
 
@@ -300,40 +352,11 @@ static int pdc_port_start(struct ata_port *ap)
        }
 
        return 0;
-
-err_out_kfree:
-       kfree(pp);
-err_out:
-       ata_port_stop(ap);
-       return rc;
-}
-
-
-static void pdc_port_stop(struct ata_port *ap)
-{
-       struct device *dev = ap->host->dev;
-       struct pdc_port_priv *pp = ap->private_data;
-
-       ap->private_data = NULL;
-       dma_free_coherent(dev, 128, pp->pkt, pp->pkt_dma);
-       kfree(pp);
-       ata_port_stop(ap);
 }
 
-
-static void pdc_host_stop(struct ata_host *host)
-{
-       struct pdc_host_priv *hp = host->private_data;
-
-       ata_pci_host_stop(host);
-
-       kfree(hp);
-}
-
-
 static void pdc_reset_port(struct ata_port *ap)
 {
-       void __iomem *mmio = (void __iomem *) ap->ioaddr.cmd_addr + PDC_CTLSTAT;
+       void __iomem *mmio = ap->ioaddr.cmd_addr + PDC_CTLSTAT;
        unsigned int i;
        u32 tmp;
 
@@ -377,18 +400,102 @@ static void pdc_pata_phy_reset(struct ata_port *ap)
 
 static u32 pdc_sata_scr_read (struct ata_port *ap, unsigned int sc_reg)
 {
-       if (sc_reg > SCR_CONTROL)
+       if (sc_reg > SCR_CONTROL || ap->cbl != ATA_CBL_SATA)
                return 0xffffffffU;
-       return readl((void __iomem *) ap->ioaddr.scr_addr + (sc_reg * 4));
+       return readl(ap->ioaddr.scr_addr + (sc_reg * 4));
 }
 
 
 static void pdc_sata_scr_write (struct ata_port *ap, unsigned int sc_reg,
                               u32 val)
 {
-       if (sc_reg > SCR_CONTROL)
+       if (sc_reg > SCR_CONTROL || ap->cbl != ATA_CBL_SATA)
                return;
-       writel(val, (void __iomem *) ap->ioaddr.scr_addr + (sc_reg * 4));
+       writel(val, ap->ioaddr.scr_addr + (sc_reg * 4));
+}
+
+static void pdc_atapi_pkt(struct ata_queued_cmd *qc)
+{
+       struct ata_port *ap = qc->ap;
+       dma_addr_t sg_table = ap->prd_dma;
+       unsigned int cdb_len = qc->dev->cdb_len;
+       u8 *cdb = qc->cdb;
+       struct pdc_port_priv *pp = ap->private_data;
+       u8 *buf = pp->pkt;
+       u32 *buf32 = (u32 *) buf;
+       unsigned int dev_sel, feature, nbytes;
+
+       /* set control bits (byte 0), zero delay seq id (byte 3),
+        * and seq id (byte 2)
+        */
+       switch (qc->tf.protocol) {
+       case ATA_PROT_ATAPI_DMA:
+               if (!(qc->tf.flags & ATA_TFLAG_WRITE))
+                       buf32[0] = cpu_to_le32(PDC_PKT_READ);
+               else
+                       buf32[0] = 0;
+               break;
+       case ATA_PROT_ATAPI_NODATA:
+               buf32[0] = cpu_to_le32(PDC_PKT_NODATA);
+               break;
+       default:
+               BUG();
+               break;
+       }
+       buf32[1] = cpu_to_le32(sg_table);       /* S/G table addr */
+       buf32[2] = 0;                           /* no next-packet */
+
+       /* select drive */
+       if (sata_scr_valid(ap)) {
+               dev_sel = PDC_DEVICE_SATA;
+       } else {
+               dev_sel = ATA_DEVICE_OBS;
+               if (qc->dev->devno != 0)
+                       dev_sel |= ATA_DEV1;
+       }
+       buf[12] = (1 << 5) | ATA_REG_DEVICE;
+       buf[13] = dev_sel;
+       buf[14] = (1 << 5) | ATA_REG_DEVICE | PDC_PKT_CLEAR_BSY;
+       buf[15] = dev_sel; /* once more, waiting for BSY to clear */
+
+       buf[16] = (1 << 5) | ATA_REG_NSECT;
+       buf[17] = 0x00;
+       buf[18] = (1 << 5) | ATA_REG_LBAL;
+       buf[19] = 0x00;
+
+       /* set feature and byte counter registers */
+       if (qc->tf.protocol != ATA_PROT_ATAPI_DMA) {
+               feature = PDC_FEATURE_ATAPI_PIO;
+               /* set byte counter register to real transfer byte count */
+               nbytes = qc->nbytes;
+               if (nbytes > 0xffff)
+                       nbytes = 0xffff;
+       } else {
+               feature = PDC_FEATURE_ATAPI_DMA;
+               /* set byte counter register to 0 */
+               nbytes = 0;
+       }
+       buf[20] = (1 << 5) | ATA_REG_FEATURE;
+       buf[21] = feature;
+       buf[22] = (1 << 5) | ATA_REG_BYTEL;
+       buf[23] = nbytes & 0xFF;
+       buf[24] = (1 << 5) | ATA_REG_BYTEH;
+       buf[25] = (nbytes >> 8) & 0xFF;
+
+       /* send ATAPI packet command 0xA0 */
+       buf[26] = (1 << 5) | ATA_REG_CMD;
+       buf[27] = ATA_CMD_PACKET;
+
+       /* select drive and check DRQ */
+       buf[28] = (1 << 5) | ATA_REG_DEVICE | PDC_PKT_WAIT_DRDY;
+       buf[29] = dev_sel;
+
+       /* we can represent cdb lengths 2/4/6/8/10/12/14/16 */
+       BUG_ON(cdb_len & ~0x1E);
+
+       /* append the CDB as the final part */
+       buf[30] = (((cdb_len >> 1) & 7) << 5) | ATA_REG_DATA | PDC_LAST_REG;
+       memcpy(buf+31, cdb, cdb_len);
 }
 
 static void pdc_qc_prep(struct ata_queued_cmd *qc)
@@ -415,6 +522,17 @@ static void pdc_qc_prep(struct ata_queued_cmd *qc)
                pdc_pkt_footer(&qc->tf, pp->pkt, i);
                break;
 
+       case ATA_PROT_ATAPI:
+               ata_qc_prep(qc);
+               break;
+
+       case ATA_PROT_ATAPI_DMA:
+               ata_qc_prep(qc);
+               /*FALLTHROUGH*/
+       case ATA_PROT_ATAPI_NODATA:
+               pdc_atapi_pkt(qc);
+               break;
+
        default:
                break;
        }
@@ -517,7 +635,7 @@ static inline unsigned int pdc_host_intr( struct ata_port *ap,
 {
        unsigned int handled = 0;
        u32 tmp;
-       void __iomem *mmio = (void __iomem *) ap->ioaddr.cmd_addr + PDC_GLOBAL_CTL;
+       void __iomem *mmio = ap->ioaddr.cmd_addr + PDC_GLOBAL_CTL;
 
        tmp = readl(mmio);
        if (tmp & PDC_ERR_MASK) {
@@ -528,6 +646,8 @@ static inline unsigned int pdc_host_intr( struct ata_port *ap,
        switch (qc->tf.protocol) {
        case ATA_PROT_DMA:
        case ATA_PROT_NODATA:
+       case ATA_PROT_ATAPI_DMA:
+       case ATA_PROT_ATAPI_NODATA:
                qc->err_mask |= ac_err_mask(ata_wait_idle(ap));
                ata_qc_complete(qc);
                handled = 1;
@@ -544,7 +664,7 @@ static inline unsigned int pdc_host_intr( struct ata_port *ap,
 static void pdc_irq_clear(struct ata_port *ap)
 {
        struct ata_host *host = ap->host;
-       void __iomem *mmio = host->mmio_base;
+       void __iomem *mmio = host->iomap[PDC_MMIO_BAR];
 
        readl(mmio + PDC_INT_SEQMASK);
 }
@@ -560,12 +680,12 @@ static irqreturn_t pdc_interrupt (int irq, void *dev_instance)
 
        VPRINTK("ENTER\n");
 
-       if (!host || !host->mmio_base) {
+       if (!host || !host->iomap[PDC_MMIO_BAR]) {
                VPRINTK("QUICK EXIT\n");
                return IRQ_NONE;
        }
 
-       mmio_base = host->mmio_base;
+       mmio_base = host->iomap[PDC_MMIO_BAR];
 
        /* reading should also clear interrupts */
        mask = readl(mmio_base + PDC_INT_SEQMASK);
@@ -610,32 +730,34 @@ static inline void pdc_packet_start(struct ata_queued_cmd *qc)
 {
        struct ata_port *ap = qc->ap;
        struct pdc_port_priv *pp = ap->private_data;
+       void __iomem *mmio = ap->host->iomap[PDC_MMIO_BAR];
        unsigned int port_no = ap->port_no;
        u8 seq = (u8) (port_no + 1);
 
        VPRINTK("ENTER, ap %p\n", ap);
 
-       writel(0x00000001, ap->host->mmio_base + (seq * 4));
-       readl(ap->host->mmio_base + (seq * 4)); /* flush */
+       writel(0x00000001, mmio + (seq * 4));
+       readl(mmio + (seq * 4));        /* flush */
 
        pp->pkt[2] = seq;
        wmb();                  /* flush PRD, pkt writes */
-       writel(pp->pkt_dma, (void __iomem *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT);
-       readl((void __iomem *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT); /* flush */
+       writel(pp->pkt_dma, ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT);
+       readl(ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT); /* flush */
 }
 
 static unsigned int pdc_qc_issue_prot(struct ata_queued_cmd *qc)
 {
        switch (qc->tf.protocol) {
+       case ATA_PROT_ATAPI_NODATA:
+               if (qc->dev->flags & ATA_DFLAG_CDB_INTR)
+                       break;
+               /*FALLTHROUGH*/
+       case ATA_PROT_ATAPI_DMA:
        case ATA_PROT_DMA:
        case ATA_PROT_NODATA:
                pdc_packet_start(qc);
                return 0;
 
-       case ATA_PROT_ATAPI_DMA:
-               BUG();
-               break;
-
        default:
                break;
        }
@@ -658,8 +780,44 @@ static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile
        ata_exec_command(ap, tf);
 }
 
+static int pdc_check_atapi_dma(struct ata_queued_cmd *qc)
+{
+       u8 *scsicmd = qc->scsicmd->cmnd;
+       int pio = 1; /* atapi dma off by default */
+
+       /* Whitelist commands that may use DMA. */
+       switch (scsicmd[0]) {
+       case WRITE_12:
+       case WRITE_10:
+       case WRITE_6:
+       case READ_12:
+       case READ_10:
+       case READ_6:
+       case 0xad: /* READ_DVD_STRUCTURE */
+       case 0xbe: /* READ_CD */
+               pio = 0;
+       }
+       /* -45150 (FFFF4FA2) to -1 (FFFFFFFF) shall use PIO mode */
+       if (scsicmd[0] == WRITE_10) {
+               unsigned int lba;
+               lba = (scsicmd[2] << 24) | (scsicmd[3] << 16) | (scsicmd[4] << 8) | scsicmd[5];
+               if (lba >= 0xFFFF4FA2)
+                       pio = 1;
+       }
+       return pio;
+}
 
-static void pdc_ata_setup_port(struct ata_ioports *port, unsigned long base)
+static int pdc_old_check_atapi_dma(struct ata_queued_cmd *qc)
+{
+       struct ata_port *ap = qc->ap;
+
+       /* First generation chips cannot use ATAPI DMA on SATA ports */
+       if (sata_scr_valid(ap))
+               return 1;
+       return pdc_check_atapi_dma(qc);
+}
+
+static void pdc_ata_setup_port(struct ata_ioports *port, void __iomem *base)
 {
        port->cmd_addr          = base;
        port->data_addr         = base;
@@ -679,7 +837,7 @@ static void pdc_ata_setup_port(struct ata_ioports *port, unsigned long base)
 
 static void pdc_host_init(unsigned int chip_id, struct ata_probe_ent *pe)
 {
-       void __iomem *mmio = pe->mmio_base;
+       void __iomem *mmio = pe->iomap[PDC_MMIO_BAR];
        struct pdc_host_priv *hp = pe->private_data;
        int hotplug_offset;
        u32 tmp;
@@ -733,55 +891,43 @@ static void pdc_host_init(unsigned int chip_id, struct ata_probe_ent *pe)
 static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
 {
        static int printed_version;
-       struct ata_probe_ent *probe_ent = NULL;
+       struct ata_probe_ent *probe_ent;
        struct pdc_host_priv *hp;
-       unsigned long base;
-       void __iomem *mmio_base;
+       void __iomem *base;
        unsigned int board_idx = (unsigned int) ent->driver_data;
-       int pci_dev_busy = 0;
        int rc;
+       u8 tmp;
 
        if (!printed_version++)
                dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
 
-       rc = pci_enable_device(pdev);
+       rc = pcim_enable_device(pdev);
        if (rc)
                return rc;
 
-       rc = pci_request_regions(pdev, DRV_NAME);
-       if (rc) {
-               pci_dev_busy = 1;
-               goto err_out;
-       }
+       rc = pcim_iomap_regions(pdev, 1 << PDC_MMIO_BAR, DRV_NAME);
+       if (rc == -EBUSY)
+               pcim_pin_device(pdev);
+       if (rc)
+               return rc;
 
        rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
        if (rc)
-               goto err_out_regions;
+               return rc;
        rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK);
        if (rc)
-               goto err_out_regions;
+               return rc;
 
-       probe_ent = kzalloc(sizeof(*probe_ent), GFP_KERNEL);
-       if (probe_ent == NULL) {
-               rc = -ENOMEM;
-               goto err_out_regions;
-       }
+       probe_ent = devm_kzalloc(&pdev->dev, sizeof(*probe_ent), GFP_KERNEL);
+       if (probe_ent == NULL)
+               return -ENOMEM;
 
        probe_ent->dev = pci_dev_to_dev(pdev);
        INIT_LIST_HEAD(&probe_ent->node);
 
-       mmio_base = pci_iomap(pdev, 3, 0);
-       if (mmio_base == NULL) {
-               rc = -ENOMEM;
-               goto err_out_free_ent;
-       }
-       base = (unsigned long) mmio_base;
-
-       hp = kzalloc(sizeof(*hp), GFP_KERNEL);
-       if (hp == NULL) {
-               rc = -ENOMEM;
-               goto err_out_free_ent;
-       }
+       hp = devm_kzalloc(&pdev->dev, sizeof(*hp), GFP_KERNEL);
+       if (hp == NULL)
+               return -ENOMEM;
 
        probe_ent->private_data = hp;
 
@@ -794,7 +940,9 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
 
                probe_ent->irq = pdev->irq;
                probe_ent->irq_flags = IRQF_SHARED;
-       probe_ent->mmio_base = mmio_base;
+       probe_ent->iomap = pcim_iomap_table(pdev);
+
+       base = probe_ent->iomap[PDC_MMIO_BAR];
 
        pdc_ata_setup_port(&probe_ent->port[0], base + 0x200);
        pdc_ata_setup_port(&probe_ent->port[1], base + 0x280);
@@ -820,7 +968,17 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
                hp->flags |= PDC_FLAG_GEN_II;
                /* Fall through */
        case board_2037x:
-               probe_ent->n_ports = 2;
+               /* TX2plus boards also have a PATA port */
+               tmp = readb(base + PDC_FLASH_CTL+1);
+               if (!(tmp & 0x80)) {
+                       probe_ent->n_ports = 3;
+                       pdc_ata_setup_port(&probe_ent->port[2], base + 0x300);
+                       hp->port_flags[2] = ATA_FLAG_SLAVE_POSS;
+                       printk(KERN_INFO DRV_NAME " PATA port found\n");
+               } else
+                       probe_ent->n_ports = 2;
+               hp->port_flags[0] = ATA_FLAG_SATA;
+               hp->port_flags[1] = ATA_FLAG_SATA;
                break;
        case board_20619:
                probe_ent->n_ports = 4;
@@ -841,22 +999,11 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
        /* initialize adapter */
        pdc_host_init(board_idx, probe_ent);
 
-       /* FIXME: Need any other frees than hp? */
        if (!ata_device_add(probe_ent))
-               kfree(hp);
-
-       kfree(probe_ent);
+               return -ENODEV;
 
+       devm_kfree(&pdev->dev, probe_ent);
        return 0;
-
-err_out_free_ent:
-       kfree(probe_ent);
-err_out_regions:
-       pci_release_regions(pdev);
-err_out:
-       if (!pci_dev_busy)
-               pci_disable_device(pdev);
-       return rc;
 }
 
 
index 710909df4eaf18a7e846d29f1f20d945318b7542..bfa35ede655178d5cabb13e3d07ea602a705321d 100644 (file)
 #include <linux/sched.h>
 #include <linux/device.h>
 #include <scsi/scsi_host.h>
-#include <asm/io.h>
 #include <linux/libata.h>
 
 #define DRV_NAME       "sata_qstor"
 #define DRV_VERSION    "0.06"
 
 enum {
+       QS_MMIO_BAR             = 4,
+
        QS_PORTS                = 4,
        QS_MAX_PRD              = LIBATA_MAX_PRD,
        QS_CPB_ORDER            = 6,
@@ -117,7 +118,6 @@ static int qs_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *en
 static irqreturn_t qs_intr (int irq, void *dev_instance);
 static int qs_port_start(struct ata_port *ap);
 static void qs_host_stop(struct ata_host *host);
-static void qs_port_stop(struct ata_port *ap);
 static void qs_phy_reset(struct ata_port *ap);
 static void qs_qc_prep(struct ata_queued_cmd *qc);
 static unsigned int qs_qc_issue(struct ata_queued_cmd *qc);
@@ -157,14 +157,15 @@ static const struct ata_port_operations qs_ata_ops = {
        .phy_reset              = qs_phy_reset,
        .qc_prep                = qs_qc_prep,
        .qc_issue               = qs_qc_issue,
-       .data_xfer              = ata_mmio_data_xfer,
+       .data_xfer              = ata_data_xfer,
        .eng_timeout            = qs_eng_timeout,
        .irq_handler            = qs_intr,
        .irq_clear              = qs_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
        .scr_read               = qs_scr_read,
        .scr_write              = qs_scr_write,
        .port_start             = qs_port_start,
-       .port_stop              = qs_port_stop,
        .host_stop              = qs_host_stop,
        .bmdma_stop             = qs_bmdma_stop,
        .bmdma_status           = qs_bmdma_status,
@@ -197,6 +198,11 @@ static struct pci_driver qs_ata_pci_driver = {
        .remove                 = ata_pci_remove_one,
 };
 
+static void __iomem *qs_mmio_base(struct ata_host *host)
+{
+       return host->iomap[QS_MMIO_BAR];
+}
+
 static int qs_check_atapi_dma(struct ata_queued_cmd *qc)
 {
        return 1;       /* ATAPI DMA not supported */
@@ -219,7 +225,7 @@ static void qs_irq_clear(struct ata_port *ap)
 
 static inline void qs_enter_reg_mode(struct ata_port *ap)
 {
-       u8 __iomem *chan = ap->host->mmio_base + (ap->port_no * 0x4000);
+       u8 __iomem *chan = qs_mmio_base(ap->host) + (ap->port_no * 0x4000);
 
        writeb(QS_CTR0_REG, chan + QS_CCT_CTR0);
        readb(chan + QS_CCT_CTR0);        /* flush */
@@ -227,7 +233,7 @@ static inline void qs_enter_reg_mode(struct ata_port *ap)
 
 static inline void qs_reset_channel_logic(struct ata_port *ap)
 {
-       u8 __iomem *chan = ap->host->mmio_base + (ap->port_no * 0x4000);
+       u8 __iomem *chan = qs_mmio_base(ap->host) + (ap->port_no * 0x4000);
 
        writeb(QS_CTR1_RCHN, chan + QS_CCT_CTR1);
        readb(chan + QS_CCT_CTR0);        /* flush */
@@ -257,14 +263,14 @@ static u32 qs_scr_read (struct ata_port *ap, unsigned int sc_reg)
 {
        if (sc_reg > SCR_CONTROL)
                return ~0U;
-       return readl((void __iomem *)(ap->ioaddr.scr_addr + (sc_reg * 8)));
+       return readl(ap->ioaddr.scr_addr + (sc_reg * 8));
 }
 
 static void qs_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val)
 {
        if (sc_reg > SCR_CONTROL)
                return;
-       writel(val, (void __iomem *)(ap->ioaddr.scr_addr + (sc_reg * 8)));
+       writel(val, ap->ioaddr.scr_addr + (sc_reg * 8));
 }
 
 static unsigned int qs_fill_sg(struct ata_queued_cmd *qc)
@@ -325,7 +331,7 @@ static void qs_qc_prep(struct ata_queued_cmd *qc)
        /* host control block (HCB) */
        buf[ 0] = QS_HCB_HDR;
        buf[ 1] = hflags;
-       *(__le32 *)(&buf[ 4]) = cpu_to_le32(qc->nsect * ATA_SECT_SIZE);
+       *(__le32 *)(&buf[ 4]) = cpu_to_le32(qc->nbytes);
        *(__le32 *)(&buf[ 8]) = cpu_to_le32(nelem);
        addr = ((u64)pp->pkt_dma) + QS_CPB_BYTES;
        *(__le64 *)(&buf[16]) = cpu_to_le64(addr);
@@ -341,7 +347,7 @@ static void qs_qc_prep(struct ata_queued_cmd *qc)
 static inline void qs_packet_start(struct ata_queued_cmd *qc)
 {
        struct ata_port *ap = qc->ap;
-       u8 __iomem *chan = ap->host->mmio_base + (ap->port_no * 0x4000);
+       u8 __iomem *chan = qs_mmio_base(ap->host) + (ap->port_no * 0x4000);
 
        VPRINTK("ENTER, ap %p\n", ap);
 
@@ -378,7 +384,7 @@ static inline unsigned int qs_intr_pkt(struct ata_host *host)
 {
        unsigned int handled = 0;
        u8 sFFE;
-       u8 __iomem *mmio_base = host->mmio_base;
+       u8 __iomem *mmio_base = qs_mmio_base(host);
 
        do {
                u32 sff0 = readl(mmio_base + QS_HST_SFF);
@@ -470,7 +476,7 @@ static irqreturn_t qs_intr(int irq, void *dev_instance)
        return IRQ_RETVAL(handled);
 }
 
-static void qs_ata_setup_port(struct ata_ioports *port, unsigned long base)
+static void qs_ata_setup_port(struct ata_ioports *port, void __iomem *base)
 {
        port->cmd_addr          =
        port->data_addr         = base + 0x400;
@@ -492,7 +498,7 @@ static int qs_port_start(struct ata_port *ap)
 {
        struct device *dev = ap->host->dev;
        struct qs_port_priv *pp;
-       void __iomem *mmio_base = ap->host->mmio_base;
+       void __iomem *mmio_base = qs_mmio_base(ap->host);
        void __iomem *chan = mmio_base + (ap->port_no * 0x4000);
        u64 addr;
        int rc;
@@ -501,17 +507,13 @@ static int qs_port_start(struct ata_port *ap)
        if (rc)
                return rc;
        qs_enter_reg_mode(ap);
-       pp = kzalloc(sizeof(*pp), GFP_KERNEL);
-       if (!pp) {
-               rc = -ENOMEM;
-               goto err_out;
-       }
-       pp->pkt = dma_alloc_coherent(dev, QS_PKT_BYTES, &pp->pkt_dma,
-                                                               GFP_KERNEL);
-       if (!pp->pkt) {
-               rc = -ENOMEM;
-               goto err_out_kfree;
-       }
+       pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL);
+       if (!pp)
+               return -ENOMEM;
+       pp->pkt = dmam_alloc_coherent(dev, QS_PKT_BYTES, &pp->pkt_dma,
+                                     GFP_KERNEL);
+       if (!pp->pkt)
+               return -ENOMEM;
        memset(pp->pkt, 0, QS_PKT_BYTES);
        ap->private_data = pp;
 
@@ -519,43 +521,19 @@ static int qs_port_start(struct ata_port *ap)
        writel((u32) addr,        chan + QS_CCF_CPBA);
        writel((u32)(addr >> 32), chan + QS_CCF_CPBA + 4);
        return 0;
-
-err_out_kfree:
-       kfree(pp);
-err_out:
-       ata_port_stop(ap);
-       return rc;
-}
-
-static void qs_port_stop(struct ata_port *ap)
-{
-       struct device *dev = ap->host->dev;
-       struct qs_port_priv *pp = ap->private_data;
-
-       if (pp != NULL) {
-               ap->private_data = NULL;
-               if (pp->pkt != NULL)
-                       dma_free_coherent(dev, QS_PKT_BYTES, pp->pkt,
-                                                               pp->pkt_dma);
-               kfree(pp);
-       }
-       ata_port_stop(ap);
 }
 
 static void qs_host_stop(struct ata_host *host)
 {
-       void __iomem *mmio_base = host->mmio_base;
-       struct pci_dev *pdev = to_pci_dev(host->dev);
+       void __iomem *mmio_base = qs_mmio_base(host);
 
        writeb(0, mmio_base + QS_HCT_CTRL); /* disable host interrupts */
        writeb(QS_CNFG3_GSRST, mmio_base + QS_HCF_CNFG3); /* global reset */
-
-       pci_iounmap(pdev, mmio_base);
 }
 
 static void qs_host_init(unsigned int chip_id, struct ata_probe_ent *pe)
 {
-       void __iomem *mmio_base = pe->mmio_base;
+       void __iomem *mmio_base = pe->iomap[QS_MMIO_BAR];
        unsigned int port_no;
 
        writeb(0, mmio_base + QS_HCT_CTRL); /* disable host interrupts */
@@ -630,44 +608,34 @@ static int qs_ata_init_one(struct pci_dev *pdev,
                                const struct pci_device_id *ent)
 {
        static int printed_version;
-       struct ata_probe_ent *probe_ent = NULL;
-       void __iomem *mmio_base;
+       struct ata_probe_ent *probe_ent;
+       void __iomem * const *iomap;
        unsigned int board_idx = (unsigned int) ent->driver_data;
        int rc, port_no;
 
        if (!printed_version++)
                dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
 
-       rc = pci_enable_device(pdev);
+       rc = pcim_enable_device(pdev);
        if (rc)
                return rc;
 
-       rc = pci_request_regions(pdev, DRV_NAME);
-       if (rc)
-               goto err_out;
-
-       if ((pci_resource_flags(pdev, 4) & IORESOURCE_MEM) == 0) {
-               rc = -ENODEV;
-               goto err_out_regions;
-       }
+       if ((pci_resource_flags(pdev, QS_MMIO_BAR) & IORESOURCE_MEM) == 0)
+               return -ENODEV;
 
-       mmio_base = pci_iomap(pdev, 4, 0);
-       if (mmio_base == NULL) {
-               rc = -ENOMEM;
-               goto err_out_regions;
-       }
+       rc = pcim_iomap_regions(pdev, 1 << QS_MMIO_BAR, DRV_NAME);
+       if (rc)
+               return rc;
+       iomap = pcim_iomap_table(pdev);
 
-       rc = qs_set_dma_masks(pdev, mmio_base);
+       rc = qs_set_dma_masks(pdev, iomap[QS_MMIO_BAR]);
        if (rc)
-               goto err_out_iounmap;
+               return rc;
 
-       probe_ent = kmalloc(sizeof(*probe_ent), GFP_KERNEL);
-       if (probe_ent == NULL) {
-               rc = -ENOMEM;
-               goto err_out_iounmap;
-       }
+       probe_ent = devm_kzalloc(&pdev->dev, sizeof(*probe_ent), GFP_KERNEL);
+       if (probe_ent == NULL)
+               return -ENOMEM;
 
-       memset(probe_ent, 0, sizeof(*probe_ent));
        probe_ent->dev = pci_dev_to_dev(pdev);
        INIT_LIST_HEAD(&probe_ent->node);
 
@@ -680,12 +648,12 @@ static int qs_ata_init_one(struct pci_dev *pdev,
 
        probe_ent->irq          = pdev->irq;
        probe_ent->irq_flags    = IRQF_SHARED;
-       probe_ent->mmio_base    = mmio_base;
+       probe_ent->iomap        = iomap;
        probe_ent->n_ports      = QS_PORTS;
 
        for (port_no = 0; port_no < probe_ent->n_ports; ++port_no) {
-               unsigned long chan = (unsigned long)mmio_base +
-                                                       (port_no * 0x4000);
+               void __iomem *chan =
+                       probe_ent->iomap[QS_MMIO_BAR] + (port_no * 0x4000);
                qs_ata_setup_port(&probe_ent->port[port_no], chan);
        }
 
@@ -694,19 +662,11 @@ static int qs_ata_init_one(struct pci_dev *pdev,
        /* initialize adapter */
        qs_host_init(board_idx, probe_ent);
 
-       rc = ata_device_add(probe_ent);
-       kfree(probe_ent);
-       if (rc != QS_PORTS)
-               goto err_out_iounmap;
-       return 0;
+       if (ata_device_add(probe_ent) != QS_PORTS)
+               return -EIO;
 
-err_out_iounmap:
-       pci_iounmap(pdev, mmio_base);
-err_out_regions:
-       pci_release_regions(pdev);
-err_out:
-       pci_disable_device(pdev);
-       return rc;
+       devm_kfree(&pdev->dev, probe_ent);
+       return 0;
 }
 
 static int __init qs_ata_init(void)
index 7808d0369d91e2a59907080c7372bd5c7b2b11c9..dca3d3749f0626cbc2d79798ecda01502b1452e3 100644 (file)
@@ -49,6 +49,8 @@
 #define DRV_VERSION    "2.0"
 
 enum {
+       SIL_MMIO_BAR            = 5,
+
        /*
         * host flags
         */
@@ -200,18 +202,18 @@ static const struct ata_port_operations sil_ops = {
        .bmdma_status           = ata_bmdma_status,
        .qc_prep                = ata_qc_prep,
        .qc_issue               = ata_qc_issue_prot,
-       .data_xfer              = ata_mmio_data_xfer,
+       .data_xfer              = ata_data_xfer,
        .freeze                 = sil_freeze,
        .thaw                   = sil_thaw,
        .error_handler          = ata_bmdma_error_handler,
        .post_internal_cmd      = ata_bmdma_post_internal_cmd,
        .irq_handler            = sil_interrupt,
        .irq_clear              = ata_bmdma_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
        .scr_read               = sil_scr_read,
        .scr_write              = sil_scr_write,
        .port_start             = ata_port_start,
-       .port_stop              = ata_port_stop,
-       .host_stop              = ata_pci_host_stop,
 };
 
 static const struct ata_port_info sil_port_info[] = {
@@ -297,7 +299,8 @@ static void sil_post_set_mode (struct ata_port *ap)
 {
        struct ata_host *host = ap->host;
        struct ata_device *dev;
-       void __iomem *addr = host->mmio_base + sil_port[ap->port_no].xfer_mode;
+       void __iomem *mmio_base = host->iomap[SIL_MMIO_BAR];
+       void __iomem *addr = mmio_base + sil_port[ap->port_no].xfer_mode;
        u32 tmp, dev_mode[2];
        unsigned int i;
 
@@ -320,9 +323,9 @@ static void sil_post_set_mode (struct ata_port *ap)
        readl(addr);    /* flush */
 }
 
-static inline unsigned long sil_scr_addr(struct ata_port *ap, unsigned int sc_reg)
+static inline void __iomem *sil_scr_addr(struct ata_port *ap, unsigned int sc_reg)
 {
-       unsigned long offset = ap->ioaddr.scr_addr;
+       void __iomem *offset = ap->ioaddr.scr_addr;
 
        switch (sc_reg) {
        case SCR_STATUS:
@@ -341,7 +344,7 @@ static inline unsigned long sil_scr_addr(struct ata_port *ap, unsigned int sc_re
 
 static u32 sil_scr_read (struct ata_port *ap, unsigned int sc_reg)
 {
-       void __iomem *mmio = (void __iomem *) sil_scr_addr(ap, sc_reg);
+       void __iomem *mmio = sil_scr_addr(ap, sc_reg);
        if (mmio)
                return readl(mmio);
        return 0xffffffffU;
@@ -349,7 +352,7 @@ static u32 sil_scr_read (struct ata_port *ap, unsigned int sc_reg)
 
 static void sil_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val)
 {
-       void __iomem *mmio = (void __iomem *) sil_scr_addr(ap, sc_reg);
+       void __iomem *mmio = sil_scr_addr(ap, sc_reg);
        if (mmio)
                writel(val, mmio);
 }
@@ -444,7 +447,7 @@ static void sil_host_intr(struct ata_port *ap, u32 bmdma2)
 static irqreturn_t sil_interrupt(int irq, void *dev_instance)
 {
        struct ata_host *host = dev_instance;
-       void __iomem *mmio_base = host->mmio_base;
+       void __iomem *mmio_base = host->iomap[SIL_MMIO_BAR];
        int handled = 0;
        int i;
 
@@ -476,7 +479,7 @@ static irqreturn_t sil_interrupt(int irq, void *dev_instance)
 
 static void sil_freeze(struct ata_port *ap)
 {
-       void __iomem *mmio_base = ap->host->mmio_base;
+       void __iomem *mmio_base = ap->host->iomap[SIL_MMIO_BAR];
        u32 tmp;
 
        /* global IRQ mask doesn't block SATA IRQ, turn off explicitly */
@@ -491,7 +494,7 @@ static void sil_freeze(struct ata_port *ap)
 
 static void sil_thaw(struct ata_port *ap)
 {
-       void __iomem *mmio_base = ap->host->mmio_base;
+       void __iomem *mmio_base = ap->host->iomap[SIL_MMIO_BAR];
        u32 tmp;
 
        /* clear IRQ */
@@ -541,9 +544,9 @@ static void sil_dev_config(struct ata_port *ap, struct ata_device *dev)
 {
        int print_info = ap->eh_context.i.flags & ATA_EHI_PRINTINFO;
        unsigned int n, quirks = 0;
-       unsigned char model_num[41];
+       unsigned char model_num[ATA_ID_PROD_LEN + 1];
 
-       ata_id_c_string(dev->id, model_num, ATA_ID_PROD_OFS, sizeof(model_num));
+       ata_id_c_string(dev->id, model_num, ATA_ID_PROD, sizeof(model_num));
 
        for (n = 0; sil_blacklist[n].product; n++)
                if (!strcmp(sil_blacklist[n].product, model_num)) {
@@ -621,38 +624,35 @@ static void sil_init_controller(struct pci_dev *pdev,
 static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
 {
        static int printed_version;
-       struct ata_probe_ent *probe_ent = NULL;
-       unsigned long base;
+       struct device *dev = &pdev->dev;
+       struct ata_probe_ent *probe_ent;
        void __iomem *mmio_base;
        int rc;
        unsigned int i;
-       int pci_dev_busy = 0;
 
        if (!printed_version++)
                dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
 
-       rc = pci_enable_device(pdev);
+       rc = pcim_enable_device(pdev);
        if (rc)
                return rc;
 
-       rc = pci_request_regions(pdev, DRV_NAME);
-       if (rc) {
-               pci_dev_busy = 1;
-               goto err_out;
-       }
+       rc = pcim_iomap_regions(pdev, 1 << SIL_MMIO_BAR, DRV_NAME);
+       if (rc == -EBUSY)
+               pcim_pin_device(pdev);
+       if (rc)
+               return rc;
 
        rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
        if (rc)
-               goto err_out_regions;
+               return rc;
        rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK);
        if (rc)
-               goto err_out_regions;
+               return rc;
 
-       probe_ent = kzalloc(sizeof(*probe_ent), GFP_KERNEL);
-       if (probe_ent == NULL) {
-               rc = -ENOMEM;
-               goto err_out_regions;
-       }
+       probe_ent = devm_kzalloc(dev, sizeof(*probe_ent), GFP_KERNEL);
+       if (probe_ent == NULL)
+               return -ENOMEM;
 
        INIT_LIST_HEAD(&probe_ent->node);
        probe_ent->dev = pci_dev_to_dev(pdev);
@@ -666,22 +666,16 @@ static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
                probe_ent->irq_flags = IRQF_SHARED;
        probe_ent->port_flags = sil_port_info[ent->driver_data].flags;
 
-       mmio_base = pci_iomap(pdev, 5, 0);
-       if (mmio_base == NULL) {
-               rc = -ENOMEM;
-               goto err_out_free_ent;
-       }
-
-       probe_ent->mmio_base = mmio_base;
+       probe_ent->iomap = pcim_iomap_table(pdev);
 
-       base = (unsigned long) mmio_base;
+       mmio_base = probe_ent->iomap[SIL_MMIO_BAR];
 
        for (i = 0; i < probe_ent->n_ports; i++) {
-               probe_ent->port[i].cmd_addr = base + sil_port[i].tf;
+               probe_ent->port[i].cmd_addr = mmio_base + sil_port[i].tf;
                probe_ent->port[i].altstatus_addr =
-               probe_ent->port[i].ctl_addr = base + sil_port[i].ctl;
-               probe_ent->port[i].bmdma_addr = base + sil_port[i].bmdma;
-               probe_ent->port[i].scr_addr = base + sil_port[i].scr;
+               probe_ent->port[i].ctl_addr = mmio_base + sil_port[i].ctl;
+               probe_ent->port[i].bmdma_addr = mmio_base + sil_port[i].bmdma;
+               probe_ent->port[i].scr_addr = mmio_base + sil_port[i].scr;
                ata_std_ports(&probe_ent->port[i]);
        }
 
@@ -690,30 +684,25 @@ static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
 
        pci_set_master(pdev);
 
-       /* FIXME: check ata_device_add return value */
-       ata_device_add(probe_ent);
-       kfree(probe_ent);
+       if (!ata_device_add(probe_ent))
+               return -ENODEV;
 
+       devm_kfree(dev, probe_ent);
        return 0;
-
-err_out_free_ent:
-       kfree(probe_ent);
-err_out_regions:
-       pci_release_regions(pdev);
-err_out:
-       if (!pci_dev_busy)
-               pci_disable_device(pdev);
-       return rc;
 }
 
 #ifdef CONFIG_PM
 static int sil_pci_device_resume(struct pci_dev *pdev)
 {
        struct ata_host *host = dev_get_drvdata(&pdev->dev);
+       int rc;
+
+       rc = ata_pci_device_do_resume(pdev);
+       if (rc)
+               return rc;
 
-       ata_pci_device_do_resume(pdev);
        sil_init_controller(pdev, host->n_ports, host->ports[0]->flags,
-                           host->mmio_base);
+                           host->iomap[SIL_MMIO_BAR]);
        ata_host_resume(host);
 
        return 0;
index 5aa288d2fb867fb2130a0ced4b599cb61f0afeaa..e65e8d55da3e9b36dea407bc6993b724a8ebf1db 100644 (file)
@@ -28,7 +28,6 @@
 #include <scsi/scsi_host.h>
 #include <scsi/scsi_cmnd.h>
 #include <linux/libata.h>
-#include <asm/io.h>
 
 #define DRV_NAME       "sata_sil24"
 #define DRV_VERSION    "0.3"
@@ -61,6 +60,9 @@ struct sil24_port_multiplier {
 };
 
 enum {
+       SIL24_HOST_BAR          = 0,
+       SIL24_PORT_BAR          = 2,
+
        /*
         * Global controller registers (128 bytes @ BAR0)
         */
@@ -321,12 +323,6 @@ struct sil24_port_priv {
        struct ata_taskfile tf;                 /* Cached taskfile registers */
 };
 
-/* ap->host->private_data */
-struct sil24_host_priv {
-       void __iomem *host_base;        /* global controller control (128 bytes @BAR0) */
-       void __iomem *port_base;        /* port registers (4 * 8192 bytes @BAR2) */
-};
-
 static void sil24_dev_config(struct ata_port *ap, struct ata_device *dev);
 static u8 sil24_check_status(struct ata_port *ap);
 static u32 sil24_scr_read(struct ata_port *ap, unsigned sc_reg);
@@ -341,8 +337,6 @@ static void sil24_thaw(struct ata_port *ap);
 static void sil24_error_handler(struct ata_port *ap);
 static void sil24_post_internal_cmd(struct ata_queued_cmd *qc);
 static int sil24_port_start(struct ata_port *ap);
-static void sil24_port_stop(struct ata_port *ap);
-static void sil24_host_stop(struct ata_host *host);
 static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
 #ifdef CONFIG_PM
 static int sil24_pci_device_resume(struct pci_dev *pdev);
@@ -362,7 +356,7 @@ static struct pci_driver sil24_pci_driver = {
        .name                   = DRV_NAME,
        .id_table               = sil24_pci_tbl,
        .probe                  = sil24_init_one,
-       .remove                 = ata_pci_remove_one, /* safe? */
+       .remove                 = ata_pci_remove_one,
 #ifdef CONFIG_PM
        .suspend                = ata_pci_device_suspend,
        .resume                 = sil24_pci_device_resume,
@@ -406,6 +400,8 @@ static const struct ata_port_operations sil24_ops = {
 
        .irq_handler            = sil24_interrupt,
        .irq_clear              = sil24_irq_clear,
+       .irq_on                 = ata_dummy_irq_on,
+       .irq_ack                = ata_dummy_irq_ack,
 
        .scr_read               = sil24_scr_read,
        .scr_write              = sil24_scr_write,
@@ -416,8 +412,6 @@ static const struct ata_port_operations sil24_ops = {
        .post_internal_cmd      = sil24_post_internal_cmd,
 
        .port_start             = sil24_port_start,
-       .port_stop              = sil24_port_stop,
-       .host_stop              = sil24_host_stop,
 };
 
 /*
@@ -467,7 +461,7 @@ static int sil24_tag(int tag)
 
 static void sil24_dev_config(struct ata_port *ap, struct ata_device *dev)
 {
-       void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr;
+       void __iomem *port = ap->ioaddr.cmd_addr;
 
        if (dev->cdb_len == 16)
                writel(PORT_CS_CDB16, port + PORT_CTRL_STAT);
@@ -478,7 +472,7 @@ static void sil24_dev_config(struct ata_port *ap, struct ata_device *dev)
 static inline void sil24_update_tf(struct ata_port *ap)
 {
        struct sil24_port_priv *pp = ap->private_data;
-       void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr;
+       void __iomem *port = ap->ioaddr.cmd_addr;
        struct sil24_prb __iomem *prb = port;
        u8 fis[6 * 4];
 
@@ -501,7 +495,7 @@ static int sil24_scr_map[] = {
 
 static u32 sil24_scr_read(struct ata_port *ap, unsigned sc_reg)
 {
-       void __iomem *scr_addr = (void __iomem *)ap->ioaddr.scr_addr;
+       void __iomem *scr_addr = ap->ioaddr.scr_addr;
        if (sc_reg < ARRAY_SIZE(sil24_scr_map)) {
                void __iomem *addr;
                addr = scr_addr + sil24_scr_map[sc_reg] * 4;
@@ -512,7 +506,7 @@ static u32 sil24_scr_read(struct ata_port *ap, unsigned sc_reg)
 
 static void sil24_scr_write(struct ata_port *ap, unsigned sc_reg, u32 val)
 {
-       void __iomem *scr_addr = (void __iomem *)ap->ioaddr.scr_addr;
+       void __iomem *scr_addr = ap->ioaddr.scr_addr;
        if (sc_reg < ARRAY_SIZE(sil24_scr_map)) {
                void __iomem *addr;
                addr = scr_addr + sil24_scr_map[sc_reg] * 4;
@@ -528,7 +522,7 @@ static void sil24_tf_read(struct ata_port *ap, struct ata_taskfile *tf)
 
 static int sil24_init_port(struct ata_port *ap)
 {
-       void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr;
+       void __iomem *port = ap->ioaddr.cmd_addr;
        u32 tmp;
 
        writel(PORT_CS_INIT, port + PORT_CTRL_STAT);
@@ -544,7 +538,7 @@ static int sil24_init_port(struct ata_port *ap)
 
 static int sil24_softreset(struct ata_port *ap, unsigned int *class)
 {
-       void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr;
+       void __iomem *port = ap->ioaddr.cmd_addr;
        struct sil24_port_priv *pp = ap->private_data;
        struct sil24_prb *prb = &pp->cmd_block[0].ata.prb;
        dma_addr_t paddr = pp->cmd_block_dma;
@@ -604,7 +598,7 @@ static int sil24_softreset(struct ata_port *ap, unsigned int *class)
 
 static int sil24_hardreset(struct ata_port *ap, unsigned int *class)
 {
-       void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr;
+       void __iomem *port = ap->ioaddr.cmd_addr;
        const char *reason;
        int tout_msec, rc;
        u32 tmp;
@@ -721,7 +715,7 @@ static unsigned int sil24_qc_issue(struct ata_queued_cmd *qc)
 {
        struct ata_port *ap = qc->ap;
        struct sil24_port_priv *pp = ap->private_data;
-       void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr;
+       void __iomem *port = ap->ioaddr.cmd_addr;
        unsigned int tag = sil24_tag(qc->tag);
        dma_addr_t paddr;
        void __iomem *activate;
@@ -742,7 +736,7 @@ static void sil24_irq_clear(struct ata_port *ap)
 
 static void sil24_freeze(struct ata_port *ap)
 {
-       void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr;
+       void __iomem *port = ap->ioaddr.cmd_addr;
 
        /* Port-wide IRQ mask in HOST_CTRL doesn't really work, clear
         * PORT_IRQ_ENABLE instead.
@@ -752,7 +746,7 @@ static void sil24_freeze(struct ata_port *ap)
 
 static void sil24_thaw(struct ata_port *ap)
 {
-       void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr;
+       void __iomem *port = ap->ioaddr.cmd_addr;
        u32 tmp;
 
        /* clear IRQ */
@@ -765,7 +759,7 @@ static void sil24_thaw(struct ata_port *ap)
 
 static void sil24_error_intr(struct ata_port *ap)
 {
-       void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr;
+       void __iomem *port = ap->ioaddr.cmd_addr;
        struct ata_eh_info *ehi = &ap->eh_info;
        int freeze = 0;
        u32 irq_stat;
@@ -843,7 +837,7 @@ static void sil24_finish_qc(struct ata_queued_cmd *qc)
 
 static inline void sil24_host_intr(struct ata_port *ap)
 {
-       void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr;
+       void __iomem *port = ap->ioaddr.cmd_addr;
        u32 slot_stat, qc_active;
        int rc;
 
@@ -878,12 +872,12 @@ static inline void sil24_host_intr(struct ata_port *ap)
 static irqreturn_t sil24_interrupt(int irq, void *dev_instance)
 {
        struct ata_host *host = dev_instance;
-       struct sil24_host_priv *hpriv = host->private_data;
+       void __iomem *host_base = host->iomap[SIL24_HOST_BAR];
        unsigned handled = 0;
        u32 status;
        int i;
 
-       status = readl(hpriv->host_base + HOST_IRQ_STAT);
+       status = readl(host_base + HOST_IRQ_STAT);
 
        if (status == 0xffffffff) {
                printk(KERN_ERR DRV_NAME ": IRQ status == 0xffffffff, "
@@ -938,13 +932,6 @@ static void sil24_post_internal_cmd(struct ata_queued_cmd *qc)
                sil24_init_port(ap);
 }
 
-static inline void sil24_cblk_free(struct sil24_port_priv *pp, struct device *dev)
-{
-       const size_t cb_size = sizeof(*pp->cmd_block) * SIL24_MAX_CMDS;
-
-       dma_free_coherent(dev, cb_size, pp->cmd_block, pp->cmd_block_dma);
-}
-
 static int sil24_port_start(struct ata_port *ap)
 {
        struct device *dev = ap->host->dev;
@@ -952,22 +939,22 @@ static int sil24_port_start(struct ata_port *ap)
        union sil24_cmd_block *cb;
        size_t cb_size = sizeof(*cb) * SIL24_MAX_CMDS;
        dma_addr_t cb_dma;
-       int rc = -ENOMEM;
+       int rc;
 
-       pp = kzalloc(sizeof(*pp), GFP_KERNEL);
+       pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL);
        if (!pp)
-               goto err_out;
+               return -ENOMEM;
 
        pp->tf.command = ATA_DRDY;
 
-       cb = dma_alloc_coherent(dev, cb_size, &cb_dma, GFP_KERNEL);
+       cb = dmam_alloc_coherent(dev, cb_size, &cb_dma, GFP_KERNEL);
        if (!cb)
-               goto err_out_pp;
+               return -ENOMEM;
        memset(cb, 0, cb_size);
 
        rc = ata_pad_alloc(ap, dev);
        if (rc)
-               goto err_out_pad;
+               return rc;
 
        pp->cmd_block = cb;
        pp->cmd_block_dma = cb_dma;
@@ -975,33 +962,6 @@ static int sil24_port_start(struct ata_port *ap)
        ap->private_data = pp;
 
        return 0;
-
-err_out_pad:
-       sil24_cblk_free(pp, dev);
-err_out_pp:
-       kfree(pp);
-err_out:
-       return rc;
-}
-
-static void sil24_port_stop(struct ata_port *ap)
-{
-       struct device *dev = ap->host->dev;
-       struct sil24_port_priv *pp = ap->private_data;
-
-       sil24_cblk_free(pp, dev);
-       ata_pad_free(ap, dev);
-       kfree(pp);
-}
-
-static void sil24_host_stop(struct ata_host *host)
-{
-       struct sil24_host_priv *hpriv = host->private_data;
-       struct pci_dev *pdev = to_pci_dev(host->dev);
-
-       pci_iounmap(pdev, hpriv->host_base);
-       pci_iounmap(pdev, hpriv->port_base);
-       kfree(hpriv);
 }
 
 static void sil24_init_controller(struct pci_dev *pdev, int n_ports,
@@ -1066,43 +1026,32 @@ static void sil24_init_controller(struct pci_dev *pdev, int n_ports,
 static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
        static int printed_version = 0;
+       struct device *dev = &pdev->dev;
        unsigned int board_id = (unsigned int)ent->driver_data;
        struct ata_port_info *pinfo = &sil24_port_info[board_id];
-       struct ata_probe_ent *probe_ent = NULL;
-       struct sil24_host_priv *hpriv = NULL;
-       void __iomem *host_base = NULL;
-       void __iomem *port_base = NULL;
+       struct ata_probe_ent *probe_ent;
+       void __iomem *host_base;
+       void __iomem *port_base;
        int i, rc;
        u32 tmp;
 
        if (!printed_version++)
                dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
 
-       rc = pci_enable_device(pdev);
+       rc = pcim_enable_device(pdev);
        if (rc)
                return rc;
 
-       rc = pci_request_regions(pdev, DRV_NAME);
+       rc = pcim_iomap_regions(pdev,
+                               (1 << SIL24_HOST_BAR) | (1 << SIL24_PORT_BAR),
+                               DRV_NAME);
        if (rc)
-               goto out_disable;
-
-       rc = -ENOMEM;
-       /* map mmio registers */
-       host_base = pci_iomap(pdev, 0, 0);
-       if (!host_base)
-               goto out_free;
-       port_base = pci_iomap(pdev, 2, 0);
-       if (!port_base)
-               goto out_free;
-
-       /* allocate & init probe_ent and hpriv */
-       probe_ent = kzalloc(sizeof(*probe_ent), GFP_KERNEL);
-       if (!probe_ent)
-               goto out_free;
+               return rc;
 
-       hpriv = kzalloc(sizeof(*hpriv), GFP_KERNEL);
-       if (!hpriv)
-               goto out_free;
+       /* allocate & init probe_ent */
+       probe_ent = devm_kzalloc(dev, sizeof(*probe_ent), GFP_KERNEL);
+       if (!probe_ent)
+               return -ENOMEM;
 
        probe_ent->dev = pci_dev_to_dev(pdev);
        INIT_LIST_HEAD(&probe_ent->node);
@@ -1117,10 +1066,10 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 
        probe_ent->irq = pdev->irq;
        probe_ent->irq_flags = IRQF_SHARED;
-       probe_ent->private_data = hpriv;
+       probe_ent->iomap = pcim_iomap_table(pdev);
 
-       hpriv->host_base = host_base;
-       hpriv->port_base = port_base;
+       host_base = probe_ent->iomap[SIL24_HOST_BAR];
+       port_base = probe_ent->iomap[SIL24_PORT_BAR];
 
        /*
         * Configure the device
@@ -1132,7 +1081,7 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
                        if (rc) {
                                dev_printk(KERN_ERR, &pdev->dev,
                                           "64-bit DMA enable failed\n");
-                               goto out_free;
+                               return rc;
                        }
                }
        } else {
@@ -1140,13 +1089,13 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
                if (rc) {
                        dev_printk(KERN_ERR, &pdev->dev,
                                   "32-bit DMA enable failed\n");
-                       goto out_free;
+                       return rc;
                }
                rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
                if (rc) {
                        dev_printk(KERN_ERR, &pdev->dev,
                                   "32-bit consistent DMA enable failed\n");
-                       goto out_free;
+                       return rc;
                }
        }
 
@@ -1162,11 +1111,10 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
        }
 
        for (i = 0; i < probe_ent->n_ports; i++) {
-               unsigned long portu =
-                       (unsigned long)port_base + i * PORT_REGS_SIZE;
+               void __iomem *port = port_base + i * PORT_REGS_SIZE;
 
-               probe_ent->port[i].cmd_addr = portu;
-               probe_ent->port[i].scr_addr = portu + PORT_SCONTROL;
+               probe_ent->port[i].cmd_addr = port;
+               probe_ent->port[i].scr_addr = port + PORT_SCONTROL;
 
                ata_std_ports(&probe_ent->port[i]);
        }
@@ -1176,38 +1124,30 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 
        pci_set_master(pdev);
 
-       /* FIXME: check ata_device_add return value */
-       ata_device_add(probe_ent);
+       if (!ata_device_add(probe_ent))
+               return -ENODEV;
 
-       kfree(probe_ent);
+       devm_kfree(dev, probe_ent);
        return 0;
-
- out_free:
-       if (host_base)
-               pci_iounmap(pdev, host_base);
-       if (port_base)
-               pci_iounmap(pdev, port_base);
-       kfree(probe_ent);
-       kfree(hpriv);
-       pci_release_regions(pdev);
- out_disable:
-       pci_disable_device(pdev);
-       return rc;
 }
 
 #ifdef CONFIG_PM
 static int sil24_pci_device_resume(struct pci_dev *pdev)
 {
        struct ata_host *host = dev_get_drvdata(&pdev->dev);
-       struct sil24_host_priv *hpriv = host->private_data;
+       void __iomem *host_base = host->iomap[SIL24_HOST_BAR];
+       void __iomem *port_base = host->iomap[SIL24_PORT_BAR];
+       int rc;
 
-       ata_pci_device_do_resume(pdev);
+       rc = ata_pci_device_do_resume(pdev);
+       if (rc)
+               return rc;
 
        if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND)
-               writel(HOST_CTRL_GLOBAL_RST, hpriv->host_base + HOST_CTRL);
+               writel(HOST_CTRL_GLOBAL_RST, host_base + HOST_CTRL);
 
        sil24_init_controller(pdev, host->n_ports, host->ports[0]->flags,
-                             hpriv->host_base, hpriv->port_base);
+                             host_base, port_base);
 
        ata_host_resume(host);
 
index 9c25a1e91730c19578c624a01e953c617c24e808..49c9e2bd706f9ad1f9367f78d481c1fb8139f668 100644 (file)
 #include <linux/device.h>
 #include <scsi/scsi_host.h>
 #include <linux/libata.h>
+#include "libata.h"
 
+#undef DRV_NAME                /* already defined in libata.h, for libata-core */
 #define DRV_NAME       "sata_sis"
-#define DRV_VERSION    "0.6"
+#define DRV_VERSION    "0.7"
 
 enum {
        sis_180                 = 0,
@@ -67,9 +69,12 @@ static u32 sis_scr_read (struct ata_port *ap, unsigned int sc_reg);
 static void sis_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val);
 
 static const struct pci_device_id sis_pci_tbl[] = {
-       { PCI_VDEVICE(SI, 0x180), sis_180 },
-       { PCI_VDEVICE(SI, 0x181), sis_180 },
-       { PCI_VDEVICE(SI, 0x182), sis_180 },
+       { PCI_VDEVICE(SI, 0x0180), sis_180 },           /* SiS 964/180 */
+       { PCI_VDEVICE(SI, 0x0181), sis_180 },           /* SiS 964/180 */
+       { PCI_VDEVICE(SI, 0x0182), sis_180 },           /* SiS 965/965L */
+       { PCI_VDEVICE(SI, 0x0183), sis_180 },           /* SiS 965/965L */
+       { PCI_VDEVICE(SI, 0x1182), sis_180 },           /* SiS 966/966L */
+       { PCI_VDEVICE(SI, 0x1183), sis_180 },           /* SiS 966/966L */
 
        { }     /* terminate list */
 };
@@ -112,18 +117,18 @@ static const struct ata_port_operations sis_ops = {
        .bmdma_status           = ata_bmdma_status,
        .qc_prep                = ata_qc_prep,
        .qc_issue               = ata_qc_issue_prot,
-       .data_xfer              = ata_pio_data_xfer,
+       .data_xfer              = ata_data_xfer,
        .freeze                 = ata_bmdma_freeze,
        .thaw                   = ata_bmdma_thaw,
        .error_handler          = ata_bmdma_error_handler,
        .post_internal_cmd      = ata_bmdma_post_internal_cmd,
        .irq_handler            = ata_interrupt,
        .irq_clear              = ata_bmdma_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
        .scr_read               = sis_scr_read,
        .scr_write              = sis_scr_write,
        .port_start             = ata_port_start,
-       .port_stop              = ata_port_stop,
-       .host_stop              = ata_host_stop,
 };
 
 static struct ata_port_info sis_port_info = {
@@ -135,31 +140,42 @@ static struct ata_port_info sis_port_info = {
        .port_ops       = &sis_ops,
 };
 
-
 MODULE_AUTHOR("Uwe Koziolek");
 MODULE_DESCRIPTION("low-level driver for Silicon Integratad Systems SATA controller");
 MODULE_LICENSE("GPL");
 MODULE_DEVICE_TABLE(pci, sis_pci_tbl);
 MODULE_VERSION(DRV_VERSION);
 
-static unsigned int get_scr_cfg_addr(unsigned int port_no, unsigned int sc_reg, int device)
+static unsigned int get_scr_cfg_addr(struct ata_port *ap, unsigned int sc_reg)
 {
+       struct pci_dev *pdev = to_pci_dev(ap->host->dev);
        unsigned int addr = SIS_SCR_BASE + (4 * sc_reg);
+       u8 pmr;
 
-       if (port_no)  {
-               if (device == 0x182)
-                       addr += SIS182_SATA1_OFS;
-               else
-                       addr += SIS180_SATA1_OFS;
+       if (ap->port_no)  {
+               switch (pdev->device) {
+                       case 0x0180:
+                       case 0x0181:
+                               pci_read_config_byte(pdev, SIS_PMR, &pmr);
+                               if ((pmr & SIS_PMR_COMBINED) == 0)
+                                       addr += SIS180_SATA1_OFS;
+                               break;
+
+                       case 0x0182:
+                       case 0x0183:
+                       case 0x1182:
+                       case 0x1183:
+                               addr += SIS182_SATA1_OFS;
+                               break;
+               }
        }
-
        return addr;
 }
 
 static u32 sis_scr_cfg_read (struct ata_port *ap, unsigned int sc_reg)
 {
        struct pci_dev *pdev = to_pci_dev(ap->host->dev);
-       unsigned int cfg_addr = get_scr_cfg_addr(ap->port_no, sc_reg, pdev->device);
+       unsigned int cfg_addr = get_scr_cfg_addr(ap, sc_reg);
        u32 val, val2 = 0;
        u8 pmr;
 
@@ -170,26 +186,28 @@ static u32 sis_scr_cfg_read (struct ata_port *ap, unsigned int sc_reg)
 
        pci_read_config_dword(pdev, cfg_addr, &val);
 
-       if ((pdev->device == 0x182) || (pmr & SIS_PMR_COMBINED))
+       if ((pdev->device == 0x0182) || (pdev->device == 0x0183) || (pdev->device == 0x1182) ||
+           (pdev->device == 0x1183) || (pmr & SIS_PMR_COMBINED))
                pci_read_config_dword(pdev, cfg_addr+0x10, &val2);
 
        return (val|val2) &  0xfffffffb; /* avoid problems with powerdowned ports */
 }
 
-static void sis_scr_cfg_write (struct ata_port *ap, unsigned int scr, u32 val)
+static void sis_scr_cfg_write (struct ata_port *ap, unsigned int sc_reg, u32 val)
 {
        struct pci_dev *pdev = to_pci_dev(ap->host->dev);
-       unsigned int cfg_addr = get_scr_cfg_addr(ap->port_no, scr, pdev->device);
+       unsigned int cfg_addr = get_scr_cfg_addr(ap, sc_reg);
        u8 pmr;
 
-       if (scr == SCR_ERROR) /* doesn't exist in PCI cfg space */
+       if (sc_reg == SCR_ERROR) /* doesn't exist in PCI cfg space */
                return;
 
        pci_read_config_byte(pdev, SIS_PMR, &pmr);
 
        pci_write_config_dword(pdev, cfg_addr, val);
 
-       if ((pdev->device == 0x182) || (pmr & SIS_PMR_COMBINED))
+       if ((pdev->device == 0x0182) || (pdev->device == 0x0183) || (pdev->device == 0x1182) ||
+           (pdev->device == 0x1183) || (pmr & SIS_PMR_COMBINED))
                pci_write_config_dword(pdev, cfg_addr+0x10, val);
 }
 
@@ -207,10 +225,11 @@ static u32 sis_scr_read (struct ata_port *ap, unsigned int sc_reg)
 
        pci_read_config_byte(pdev, SIS_PMR, &pmr);
 
-       val = inl(ap->ioaddr.scr_addr + (sc_reg * 4));
+       val = ioread32(ap->ioaddr.scr_addr + (sc_reg * 4));
 
-       if ((pdev->device == 0x182) || (pmr & SIS_PMR_COMBINED))
-               val2 = inl(ap->ioaddr.scr_addr + (sc_reg * 4) + 0x10);
+       if ((pdev->device == 0x0182) || (pdev->device == 0x0183) || (pdev->device == 0x1182) ||
+           (pdev->device == 0x1183) || (pmr & SIS_PMR_COMBINED))
+               val2 = ioread32(ap->ioaddr.scr_addr + (sc_reg * 4) + 0x10);
 
        return (val | val2) &  0xfffffffb;
 }
@@ -228,9 +247,10 @@ static void sis_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val)
        if (ap->flags & SIS_FLAG_CFGSCR)
                sis_scr_cfg_write(ap, sc_reg, val);
        else {
-               outl(val, ap->ioaddr.scr_addr + (sc_reg * 4));
-               if ((pdev->device == 0x182) || (pmr & SIS_PMR_COMBINED))
-                       outl(val, ap->ioaddr.scr_addr + (sc_reg * 4)+0x10);
+               iowrite32(val, ap->ioaddr.scr_addr + (sc_reg * 4));
+               if ((pdev->device == 0x0182) || (pdev->device == 0x0183) || (pdev->device == 0x1182) ||
+                   (pdev->device == 0x1183) || (pmr & SIS_PMR_COMBINED))
+                       iowrite32(val, ap->ioaddr.scr_addr + (sc_reg * 4)+0x10);
        }
 }
 
@@ -241,29 +261,28 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
        int rc;
        u32 genctl, val;
        struct ata_port_info pi = sis_port_info, *ppi[2] = { &pi, &pi };
-       int pci_dev_busy = 0;
        u8 pmr;
-       u8 port2_start;
+       u8 port2_start = 0x20;
 
        if (!printed_version++)
                dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n");
 
-       rc = pci_enable_device(pdev);
+       rc = pcim_enable_device(pdev);
        if (rc)
                return rc;
 
        rc = pci_request_regions(pdev, DRV_NAME);
        if (rc) {
-               pci_dev_busy = 1;
-               goto err_out;
+               pcim_pin_device(pdev);
+               return rc;
        }
 
        rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
        if (rc)
-               goto err_out_regions;
+               return rc;
        rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK);
        if (rc)
-               goto err_out_regions;
+               return rc;
 
        /* check and see if the SCRs are in IO space or PCI cfg space */
        pci_read_config_dword(pdev, SIS_GENCTL, &genctl);
@@ -282,60 +301,79 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
        }
 
        pci_read_config_byte(pdev, SIS_PMR, &pmr);
-       if (ent->device != 0x182) {
+       switch (ent->device) {
+       case 0x0180:
+       case 0x0181:
+
+               /* The PATA-handling is provided by pata_sis */
+               switch (pmr & 0x30) {
+               case 0x10:
+                       ppi[1] = &sis_info133;
+                       break;
+                       
+               case 0x30:
+                       ppi[0] = &sis_info133;
+                       break;
+               }
                if ((pmr & SIS_PMR_COMBINED) == 0) {
                        dev_printk(KERN_INFO, &pdev->dev,
                                   "Detected SiS 180/181/964 chipset in SATA mode\n");
                        port2_start = 64;
-               }
-               else {
+               } else {
                        dev_printk(KERN_INFO, &pdev->dev,
                                   "Detected SiS 180/181 chipset in combined mode\n");
                        port2_start=0;
                        pi.flags |= ATA_FLAG_SLAVE_POSS;
                }
-       }
-       else {
+               break;
+
+       case 0x0182:
+       case 0x0183:
                pci_read_config_dword ( pdev, 0x6C, &val);
                if (val & (1L << 31)) {
                        dev_printk(KERN_INFO, &pdev->dev, "Detected SiS 182/965 chipset\n");
                        pi.flags |= ATA_FLAG_SLAVE_POSS;
-               }
-               else
+               } else {
                        dev_printk(KERN_INFO, &pdev->dev, "Detected SiS 182/965L chipset\n");
-               port2_start = 0x20;
+               }
+               break;
+
+       case 0x1182:
+       case 0x1183:
+               pci_read_config_dword(pdev, 0x64, &val);
+               if (val & 0x10000000) {
+                       dev_printk(KERN_INFO, &pdev->dev, "Detected SiS 1182/1183/966L SATA controller\n");
+               } else {
+                       dev_printk(KERN_INFO, &pdev->dev, "Detected SiS 1182/1183/966 SATA controller\n");
+                       pi.flags |= ATA_FLAG_SLAVE_POSS;
+               }
+               break;
        }
 
        probe_ent = ata_pci_init_native_mode(pdev, ppi, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY);
-       if (!probe_ent) {
-               rc = -ENOMEM;
-               goto err_out_regions;
-       }
+       if (!probe_ent)
+               return -ENOMEM;
 
        if (!(probe_ent->port_flags & SIS_FLAG_CFGSCR)) {
-               probe_ent->port[0].scr_addr =
-                       pci_resource_start(pdev, SIS_SCR_PCI_BAR);
-               probe_ent->port[1].scr_addr =
-                       pci_resource_start(pdev, SIS_SCR_PCI_BAR) + port2_start;
+               void *mmio;
+
+               mmio = pcim_iomap(pdev, SIS_SCR_PCI_BAR, 0);
+               if (!mmio)
+                       return -ENOMEM;
+
+               probe_ent->port[0].scr_addr = mmio;
+               probe_ent->port[1].scr_addr = mmio + port2_start;
        }
 
        pci_set_master(pdev);
        pci_intx(pdev, 1);
 
-       /* FIXME: check ata_device_add return value */
-       ata_device_add(probe_ent);
-       kfree(probe_ent);
+       if (!ata_device_add(probe_ent))
+               return -EIO;
 
+       devm_kfree(&pdev->dev, probe_ent);
        return 0;
 
-err_out_regions:
-       pci_release_regions(pdev);
-
-err_out:
-       if (!pci_dev_busy)
-               pci_disable_device(pdev);
-       return rc;
-
 }
 
 static int __init sis_init(void)
@@ -350,4 +388,3 @@ static void __exit sis_exit(void)
 
 module_init(sis_init);
 module_exit(sis_exit);
-
index 46d8a94669b4401735daf626508c12981847b302..4e4289994204ea0409c982ae66cc15a9862051fd 100644 (file)
@@ -116,7 +116,7 @@ static u32 k2_sata_scr_read (struct ata_port *ap, unsigned int sc_reg)
 {
        if (sc_reg > SCR_CONTROL)
                return 0xffffffffU;
-       return readl((void *) ap->ioaddr.scr_addr + (sc_reg * 4));
+       return readl((void __iomem *) ap->ioaddr.scr_addr + (sc_reg * 4));
 }
 
 
@@ -125,7 +125,7 @@ static void k2_sata_scr_write (struct ata_port *ap, unsigned int sc_reg,
 {
        if (sc_reg > SCR_CONTROL)
                return;
-       writel(val, (void *) ap->ioaddr.scr_addr + (sc_reg * 4));
+       writel(val, (void __iomem *) ap->ioaddr.scr_addr + (sc_reg * 4));
 }
 
 
@@ -135,31 +135,31 @@ static void k2_sata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf)
        unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR;
 
        if (tf->ctl != ap->last_ctl) {
-               writeb(tf->ctl, (void __iomem *) ioaddr->ctl_addr);
+               writeb(tf->ctl, ioaddr->ctl_addr);
                ap->last_ctl = tf->ctl;
                ata_wait_idle(ap);
        }
        if (is_addr && (tf->flags & ATA_TFLAG_LBA48)) {
                writew(tf->feature | (((u16)tf->hob_feature) << 8),
-                      (void __iomem *) ioaddr->feature_addr);
+                      ioaddr->feature_addr);
                writew(tf->nsect | (((u16)tf->hob_nsect) << 8),
-                      (void __iomem *) ioaddr->nsect_addr);
+                      ioaddr->nsect_addr);
                writew(tf->lbal | (((u16)tf->hob_lbal) << 8),
-                      (void __iomem *) ioaddr->lbal_addr);
+                      ioaddr->lbal_addr);
                writew(tf->lbam | (((u16)tf->hob_lbam) << 8),
-                      (void __iomem *) ioaddr->lbam_addr);
+                      ioaddr->lbam_addr);
                writew(tf->lbah | (((u16)tf->hob_lbah) << 8),
-                      (void __iomem *) ioaddr->lbah_addr);
+                      ioaddr->lbah_addr);
        } else if (is_addr) {
-               writew(tf->feature, (void __iomem *) ioaddr->feature_addr);
-               writew(tf->nsect, (void __iomem *) ioaddr->nsect_addr);
-               writew(tf->lbal, (void __iomem *) ioaddr->lbal_addr);
-               writew(tf->lbam, (void __iomem *) ioaddr->lbam_addr);
-               writew(tf->lbah, (void __iomem *) ioaddr->lbah_addr);
+               writew(tf->feature, ioaddr->feature_addr);
+               writew(tf->nsect, ioaddr->nsect_addr);
+               writew(tf->lbal, ioaddr->lbal_addr);
+               writew(tf->lbam, ioaddr->lbam_addr);
+               writew(tf->lbah, ioaddr->lbah_addr);
        }
 
        if (tf->flags & ATA_TFLAG_DEVICE)
-               writeb(tf->device, (void __iomem *) ioaddr->device_addr);
+               writeb(tf->device, ioaddr->device_addr);
 
        ata_wait_idle(ap);
 }
@@ -171,12 +171,12 @@ static void k2_sata_tf_read(struct ata_port *ap, struct ata_taskfile *tf)
        u16 nsect, lbal, lbam, lbah, feature;
 
        tf->command = k2_stat_check_status(ap);
-       tf->device = readw((void __iomem *)ioaddr->device_addr);
-       feature = readw((void __iomem *)ioaddr->error_addr);
-       nsect = readw((void __iomem *)ioaddr->nsect_addr);
-       lbal = readw((void __iomem *)ioaddr->lbal_addr);
-       lbam = readw((void __iomem *)ioaddr->lbam_addr);
-       lbah = readw((void __iomem *)ioaddr->lbah_addr);
+       tf->device = readw(ioaddr->device_addr);
+       feature = readw(ioaddr->error_addr);
+       nsect = readw(ioaddr->nsect_addr);
+       lbal = readw(ioaddr->lbal_addr);
+       lbam = readw(ioaddr->lbam_addr);
+       lbah = readw(ioaddr->lbah_addr);
 
        tf->feature = feature;
        tf->nsect = nsect;
@@ -262,7 +262,7 @@ static void k2_bmdma_start_mmio (struct ata_queued_cmd *qc)
 
 static u8 k2_stat_check_status(struct ata_port *ap)
 {
-               return readl((void *) ap->ioaddr.status_addr);
+               return readl((void __iomem *) ap->ioaddr.status_addr);
 }
 
 #ifdef CONFIG_PPC_OF
@@ -349,21 +349,21 @@ static const struct ata_port_operations k2_sata_ops = {
        .bmdma_status           = ata_bmdma_status,
        .qc_prep                = ata_qc_prep,
        .qc_issue               = ata_qc_issue_prot,
-       .data_xfer              = ata_mmio_data_xfer,
+       .data_xfer              = ata_data_xfer,
        .freeze                 = ata_bmdma_freeze,
        .thaw                   = ata_bmdma_thaw,
        .error_handler          = ata_bmdma_error_handler,
        .post_internal_cmd      = ata_bmdma_post_internal_cmd,
        .irq_handler            = ata_interrupt,
        .irq_clear              = ata_bmdma_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
        .scr_read               = k2_sata_scr_read,
        .scr_write              = k2_sata_scr_write,
        .port_start             = ata_port_start,
-       .port_stop              = ata_port_stop,
-       .host_stop              = ata_pci_host_stop,
 };
 
-static void k2_sata_setup_port(struct ata_ioports *port, unsigned long base)
+static void k2_sata_setup_port(struct ata_ioports *port, void __iomem *base)
 {
        port->cmd_addr          = base + K2_SATA_TF_CMD_OFFSET;
        port->data_addr         = base + K2_SATA_TF_DATA_OFFSET;
@@ -386,12 +386,11 @@ static void k2_sata_setup_port(struct ata_ioports *port, unsigned long base)
 static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
 {
        static int printed_version;
-       struct ata_probe_ent *probe_ent = NULL;
-       unsigned long base;
+       struct device *dev = &pdev->dev;
+       struct ata_probe_ent *probe_ent;
        void __iomem *mmio_base;
        const struct k2_board_info *board_info =
                        &k2_board_info[ent->driver_data];
-       int pci_dev_busy = 0;
        int rc;
        int i;
 
@@ -402,7 +401,7 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
         * If this driver happens to only be useful on Apple's K2, then
         * we should check that here as it has a normal Serverworks ID
         */
-       rc = pci_enable_device(pdev);
+       rc = pcim_enable_device(pdev);
        if (rc)
                return rc;
        /*
@@ -412,48 +411,27 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
        if (pci_resource_len(pdev, 5) == 0)
                return -ENODEV;
 
-       /* Request PCI regions */
-       rc = pci_request_regions(pdev, DRV_NAME);
-       if (rc) {
-               pci_dev_busy = 1;
-               goto err_out;
-       }
+       /* Request and iomap PCI regions */
+       rc = pcim_iomap_regions(pdev, 1 << 5, DRV_NAME);
+       if (rc == -EBUSY)
+               pcim_pin_device(pdev);
+       if (rc)
+               return rc;
 
        rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
        if (rc)
-               goto err_out_regions;
+               return rc;
        rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK);
        if (rc)
-               goto err_out_regions;
+               return rc;
 
-       probe_ent = kmalloc(sizeof(*probe_ent), GFP_KERNEL);
-       if (probe_ent == NULL) {
-               rc = -ENOMEM;
-               goto err_out_regions;
-       }
+       probe_ent = devm_kzalloc(dev, sizeof(*probe_ent), GFP_KERNEL);
+       if (probe_ent == NULL)
+               return -ENOMEM;
 
-       memset(probe_ent, 0, sizeof(*probe_ent));
        probe_ent->dev = pci_dev_to_dev(pdev);
        INIT_LIST_HEAD(&probe_ent->node);
 
-       mmio_base = pci_iomap(pdev, 5, 0);
-       if (mmio_base == NULL) {
-               rc = -ENOMEM;
-               goto err_out_free_ent;
-       }
-       base = (unsigned long) mmio_base;
-
-       /* Clear a magic bit in SCR1 according to Darwin, those help
-        * some funky seagate drives (though so far, those were already
-        * set by the firmware on the machines I had access to)
-        */
-       writel(readl(mmio_base + K2_SATA_SICR1_OFFSET) & ~0x00040000,
-              mmio_base + K2_SATA_SICR1_OFFSET);
-
-       /* Clear SATA error & interrupts we don't use */
-       writel(0xffffffff, mmio_base + K2_SATA_SCR_ERROR_OFFSET);
-       writel(0x0, mmio_base + K2_SATA_SIM_OFFSET);
-
        probe_ent->sht = &k2_sata_sht;
        probe_ent->port_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
                                ATA_FLAG_MMIO | board_info->port_flags;
@@ -461,7 +439,7 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
        probe_ent->n_ports = 4;
        probe_ent->irq = pdev->irq;
        probe_ent->irq_flags = IRQF_SHARED;
-       probe_ent->mmio_base = mmio_base;
+       probe_ent->iomap = pcim_iomap_table(pdev);
 
        /* We don't care much about the PIO/UDMA masks, but the core won't like us
         * if we don't fill these
@@ -470,28 +448,33 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
        probe_ent->mwdma_mask = 0x7;
        probe_ent->udma_mask = 0x7f;
 
+       mmio_base = probe_ent->iomap[5];
+
        /* different controllers have different number of ports - currently 4 or 8 */
        /* All ports are on the same function. Multi-function device is no
         * longer available. This should not be seen in any system. */
        for (i = 0; i < board_info->n_ports; i++)
-               k2_sata_setup_port(&probe_ent->port[i], base + i * K2_SATA_PORT_OFFSET);
+               k2_sata_setup_port(&probe_ent->port[i],
+                                  mmio_base + i * K2_SATA_PORT_OFFSET);
+
+       /* Clear a magic bit in SCR1 according to Darwin, those help
+        * some funky seagate drives (though so far, those were already
+        * set by the firmware on the machines I had access to)
+        */
+       writel(readl(mmio_base + K2_SATA_SICR1_OFFSET) & ~0x00040000,
+              mmio_base + K2_SATA_SICR1_OFFSET);
+
+       /* Clear SATA error & interrupts we don't use */
+       writel(0xffffffff, mmio_base + K2_SATA_SCR_ERROR_OFFSET);
+       writel(0x0, mmio_base + K2_SATA_SIM_OFFSET);
 
        pci_set_master(pdev);
 
-       /* FIXME: check ata_device_add return value */
-       ata_device_add(probe_ent);
-       kfree(probe_ent);
+       if (!ata_device_add(probe_ent))
+               return -ENODEV;
 
+       devm_kfree(dev, probe_ent);
        return 0;
-
-err_out_free_ent:
-       kfree(probe_ent);
-err_out_regions:
-       pci_release_regions(pdev);
-err_out:
-       if (!pci_dev_busy)
-               pci_disable_device(pdev);
-       return rc;
 }
 
 /* 0x240 is device ID for Apple K2 device
index ae7992de4b08ff44c0b668899ca3f5fce3f2aee2..06e87a37738239d7b8b427673cf1ac005fa00f27 100644 (file)
@@ -42,7 +42,6 @@
 #include <scsi/scsi_host.h>
 #include <scsi/scsi_cmnd.h>
 #include <linux/libata.h>
-#include <asm/io.h>
 #include "sata_promise.h"
 
 #define DRV_NAME       "sata_sx4"
@@ -50,6 +49,9 @@
 
 
 enum {
+       PDC_MMIO_BAR            = 3,
+       PDC_DIMM_BAR            = 4,
+
        PDC_PRD_TBL             = 0x44, /* Direct command DMA table addr */
 
        PDC_PKT_SUBMIT          = 0x40, /* Command packet pointer addr */
@@ -138,8 +140,6 @@ struct pdc_port_priv {
 };
 
 struct pdc_host_priv {
-       void                    __iomem *dimm_mmio;
-
        unsigned int            doing_hdma;
        unsigned int            hdma_prod;
        unsigned int            hdma_cons;
@@ -156,11 +156,9 @@ static irqreturn_t pdc20621_interrupt (int irq, void *dev_instance);
 static void pdc_eng_timeout(struct ata_port *ap);
 static void pdc_20621_phy_reset (struct ata_port *ap);
 static int pdc_port_start(struct ata_port *ap);
-static void pdc_port_stop(struct ata_port *ap);
 static void pdc20621_qc_prep(struct ata_queued_cmd *qc);
 static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf);
 static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf);
-static void pdc20621_host_stop(struct ata_host *host);
 static unsigned int pdc20621_dimm_init(struct ata_probe_ent *pe);
 static int pdc20621_detect_dimm(struct ata_probe_ent *pe);
 static unsigned int pdc20621_i2c_read(struct ata_probe_ent *pe,
@@ -205,13 +203,13 @@ static const struct ata_port_operations pdc_20621_ops = {
        .phy_reset              = pdc_20621_phy_reset,
        .qc_prep                = pdc20621_qc_prep,
        .qc_issue               = pdc20621_qc_issue_prot,
-       .data_xfer              = ata_mmio_data_xfer,
+       .data_xfer              = ata_data_xfer,
        .eng_timeout            = pdc_eng_timeout,
        .irq_handler            = pdc20621_interrupt,
        .irq_clear              = pdc20621_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
        .port_start             = pdc_port_start,
-       .port_stop              = pdc_port_stop,
-       .host_stop              = pdc20621_host_stop,
 };
 
 static const struct ata_port_info pdc_port_info[] = {
@@ -243,18 +241,6 @@ static struct pci_driver pdc_sata_pci_driver = {
 };
 
 
-static void pdc20621_host_stop(struct ata_host *host)
-{
-       struct pci_dev *pdev = to_pci_dev(host->dev);
-       struct pdc_host_priv *hpriv = host->private_data;
-       void __iomem *dimm_mmio = hpriv->dimm_mmio;
-
-       pci_iounmap(pdev, dimm_mmio);
-       kfree(hpriv);
-
-       pci_iounmap(pdev, host->mmio_base);
-}
-
 static int pdc_port_start(struct ata_port *ap)
 {
        struct device *dev = ap->host->dev;
@@ -265,43 +251,19 @@ static int pdc_port_start(struct ata_port *ap)
        if (rc)
                return rc;
 
-       pp = kmalloc(sizeof(*pp), GFP_KERNEL);
-       if (!pp) {
-               rc = -ENOMEM;
-               goto err_out;
-       }
-       memset(pp, 0, sizeof(*pp));
+       pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL);
+       if (!pp)
+               return -ENOMEM;
 
-       pp->pkt = dma_alloc_coherent(dev, 128, &pp->pkt_dma, GFP_KERNEL);
-       if (!pp->pkt) {
-               rc = -ENOMEM;
-               goto err_out_kfree;
-       }
+       pp->pkt = dmam_alloc_coherent(dev, 128, &pp->pkt_dma, GFP_KERNEL);
+       if (!pp->pkt)
+               return -ENOMEM;
 
        ap->private_data = pp;
 
        return 0;
-
-err_out_kfree:
-       kfree(pp);
-err_out:
-       ata_port_stop(ap);
-       return rc;
-}
-
-
-static void pdc_port_stop(struct ata_port *ap)
-{
-       struct device *dev = ap->host->dev;
-       struct pdc_port_priv *pp = ap->private_data;
-
-       ap->private_data = NULL;
-       dma_free_coherent(dev, 128, pp->pkt, pp->pkt_dma);
-       kfree(pp);
-       ata_port_stop(ap);
 }
 
-
 static void pdc_20621_phy_reset (struct ata_port *ap)
 {
        VPRINTK("ENTER\n");
@@ -452,9 +414,8 @@ static void pdc20621_dma_prep(struct ata_queued_cmd *qc)
        struct scatterlist *sg;
        struct ata_port *ap = qc->ap;
        struct pdc_port_priv *pp = ap->private_data;
-       void __iomem *mmio = ap->host->mmio_base;
-       struct pdc_host_priv *hpriv = ap->host->private_data;
-       void __iomem *dimm_mmio = hpriv->dimm_mmio;
+       void __iomem *mmio = ap->host->iomap[PDC_MMIO_BAR];
+       void __iomem *dimm_mmio = ap->host->iomap[PDC_DIMM_BAR];
        unsigned int portno = ap->port_no;
        unsigned int i, idx, total_len = 0, sgt_len;
        u32 *buf = (u32 *) &pp->dimm_buf[PDC_DIMM_HEADER_SZ];
@@ -513,9 +474,8 @@ static void pdc20621_nodata_prep(struct ata_queued_cmd *qc)
 {
        struct ata_port *ap = qc->ap;
        struct pdc_port_priv *pp = ap->private_data;
-       void __iomem *mmio = ap->host->mmio_base;
-       struct pdc_host_priv *hpriv = ap->host->private_data;
-       void __iomem *dimm_mmio = hpriv->dimm_mmio;
+       void __iomem *mmio = ap->host->iomap[PDC_MMIO_BAR];
+       void __iomem *dimm_mmio = ap->host->iomap[PDC_DIMM_BAR];
        unsigned int portno = ap->port_no;
        unsigned int i;
 
@@ -565,7 +525,7 @@ static void __pdc20621_push_hdma(struct ata_queued_cmd *qc,
 {
        struct ata_port *ap = qc->ap;
        struct ata_host *host = ap->host;
-       void __iomem *mmio = host->mmio_base;
+       void __iomem *mmio = host->iomap[PDC_MMIO_BAR];
 
        /* hard-code chip #0 */
        mmio += PDC_CHIP0_OFS;
@@ -619,8 +579,7 @@ static void pdc20621_dump_hdma(struct ata_queued_cmd *qc)
 {
        struct ata_port *ap = qc->ap;
        unsigned int port_no = ap->port_no;
-       struct pdc_host_priv *hpriv = ap->host->private_data;
-       void *dimm_mmio = hpriv->dimm_mmio;
+       void __iomem *dimm_mmio = ap->host->iomap[PDC_DIMM_BAR];
 
        dimm_mmio += (port_no * PDC_DIMM_WINDOW_STEP);
        dimm_mmio += PDC_DIMM_HOST_PKT;
@@ -639,7 +598,7 @@ static void pdc20621_packet_start(struct ata_queued_cmd *qc)
        struct ata_port *ap = qc->ap;
        struct ata_host *host = ap->host;
        unsigned int port_no = ap->port_no;
-       void __iomem *mmio = host->mmio_base;
+       void __iomem *mmio = host->iomap[PDC_MMIO_BAR];
        unsigned int rw = (qc->tf.flags & ATA_TFLAG_WRITE);
        u8 seq = (u8) (port_no + 1);
        unsigned int port_ofs;
@@ -668,8 +627,8 @@ static void pdc20621_packet_start(struct ata_queued_cmd *qc)
                readl(mmio + PDC_20621_SEQCTL + (seq * 4));     /* flush */
 
                writel(port_ofs + PDC_DIMM_ATA_PKT,
-                      (void __iomem *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT);
-               readl((void __iomem *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT);
+                      ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT);
+               readl(ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT);
                VPRINTK("submitted ofs 0x%x (%u), seq %u\n",
                        port_ofs + PDC_DIMM_ATA_PKT,
                        port_ofs + PDC_DIMM_ATA_PKT,
@@ -747,8 +706,8 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap,
                        writel(0x00000001, mmio + PDC_20621_SEQCTL + (seq * 4));
                        readl(mmio + PDC_20621_SEQCTL + (seq * 4));
                        writel(port_ofs + PDC_DIMM_ATA_PKT,
-                              (void __iomem *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT);
-                       readl((void __iomem *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT);
+                              ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT);
+                       readl(ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT);
                }
 
                /* step two - execute ATA command */
@@ -781,7 +740,7 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap,
 static void pdc20621_irq_clear(struct ata_port *ap)
 {
        struct ata_host *host = ap->host;
-       void __iomem *mmio = host->mmio_base;
+       void __iomem *mmio = host->iomap[PDC_MMIO_BAR];
 
        mmio += PDC_CHIP0_OFS;
 
@@ -799,12 +758,12 @@ static irqreturn_t pdc20621_interrupt (int irq, void *dev_instance)
 
        VPRINTK("ENTER\n");
 
-       if (!host || !host->mmio_base) {
+       if (!host || !host->iomap[PDC_MMIO_BAR]) {
                VPRINTK("QUICK EXIT\n");
                return IRQ_NONE;
        }
 
-       mmio_base = host->mmio_base;
+       mmio_base = host->iomap[PDC_MMIO_BAR];
 
        /* reading should also clear interrupts */
        mmio_base += PDC_CHIP0_OFS;
@@ -905,7 +864,7 @@ static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile
 }
 
 
-static void pdc_sata_setup_port(struct ata_ioports *port, unsigned long base)
+static void pdc_sata_setup_port(struct ata_ioports *port, void __iomem *base)
 {
        port->cmd_addr          = base;
        port->data_addr         = base;
@@ -931,9 +890,8 @@ static void pdc20621_get_from_dimm(struct ata_probe_ent *pe, void *psource,
        u16 idx;
        u8 page_mask;
        long dist;
-       void __iomem *mmio = pe->mmio_base;
-       struct pdc_host_priv *hpriv = pe->private_data;
-       void __iomem *dimm_mmio = hpriv->dimm_mmio;
+       void __iomem *mmio = pe->iomap[PDC_MMIO_BAR];
+       void __iomem *dimm_mmio = pe->iomap[PDC_DIMM_BAR];
 
        /* hard-code chip #0 */
        mmio += PDC_CHIP0_OFS;
@@ -987,9 +945,8 @@ static void pdc20621_put_to_dimm(struct ata_probe_ent *pe, void *psource,
        u16 idx;
        u8 page_mask;
        long dist;
-       void __iomem *mmio = pe->mmio_base;
-       struct pdc_host_priv *hpriv = pe->private_data;
-       void __iomem *dimm_mmio = hpriv->dimm_mmio;
+       void __iomem *mmio = pe->iomap[PDC_MMIO_BAR];
+       void __iomem *dimm_mmio = pe->iomap[PDC_DIMM_BAR];
 
        /* hard-code chip #0 */
        mmio += PDC_CHIP0_OFS;
@@ -1034,7 +991,7 @@ static void pdc20621_put_to_dimm(struct ata_probe_ent *pe, void *psource,
 static unsigned int pdc20621_i2c_read(struct ata_probe_ent *pe, u32 device,
                                      u32 subaddr, u32 *pdata)
 {
-       void __iomem *mmio = pe->mmio_base;
+       void __iomem *mmio = pe->iomap[PDC_MMIO_BAR];
        u32 i2creg  = 0;
        u32 status;
        u32 count =0;
@@ -1093,7 +1050,7 @@ static int pdc20621_prog_dimm0(struct ata_probe_ent *pe)
        u32 data = 0;
        int size, i;
        u8 bdimmsize;
-       void __iomem *mmio = pe->mmio_base;
+       void __iomem *mmio = pe->iomap[PDC_MMIO_BAR];
        static const struct {
                unsigned int reg;
                unsigned int ofs;
@@ -1155,8 +1112,8 @@ static int pdc20621_prog_dimm0(struct ata_probe_ent *pe)
 static unsigned int pdc20621_prog_dimm_global(struct ata_probe_ent *pe)
 {
        u32 data, spd0;
-       int error, i;
-       void __iomem *mmio = pe->mmio_base;
+       int error, i;
+       void __iomem *mmio = pe->iomap[PDC_MMIO_BAR];
 
        /* hard-code chip #0 */
        mmio += PDC_CHIP0_OFS;
@@ -1210,7 +1167,7 @@ static unsigned int pdc20621_dimm_init(struct ata_probe_ent *pe)
        u32 ticks=0;
        u32 clock=0;
        u32 fparam=0;
-       void __iomem *mmio = pe->mmio_base;
+       void __iomem *mmio = pe->iomap[PDC_MMIO_BAR];
 
        /* hard-code chip #0 */
        mmio += PDC_CHIP0_OFS;
@@ -1334,7 +1291,7 @@ static unsigned int pdc20621_dimm_init(struct ata_probe_ent *pe)
 static void pdc_20621_init(struct ata_probe_ent *pe)
 {
        u32 tmp;
-       void __iomem *mmio = pe->mmio_base;
+       void __iomem *mmio = pe->iomap[PDC_MMIO_BAR];
 
        /* hard-code chip #0 */
        mmio += PDC_CHIP0_OFS;
@@ -1365,67 +1322,43 @@ static void pdc_20621_init(struct ata_probe_ent *pe)
 static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
 {
        static int printed_version;
-       struct ata_probe_ent *probe_ent = NULL;
-       unsigned long base;
-       void __iomem *mmio_base;
-       void __iomem *dimm_mmio = NULL;
-       struct pdc_host_priv *hpriv = NULL;
+       struct ata_probe_ent *probe_ent;
+       void __iomem *base;
+       struct pdc_host_priv *hpriv;
        unsigned int board_idx = (unsigned int) ent->driver_data;
-       int pci_dev_busy = 0;
        int rc;
 
        if (!printed_version++)
                dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
 
-       rc = pci_enable_device(pdev);
+       rc = pcim_enable_device(pdev);
        if (rc)
                return rc;
 
-       rc = pci_request_regions(pdev, DRV_NAME);
-       if (rc) {
-               pci_dev_busy = 1;
-               goto err_out;
-       }
+       rc = pcim_iomap_regions(pdev, (1 << PDC_MMIO_BAR) | (1 << PDC_DIMM_BAR),
+                               DRV_NAME);
+       if (rc == -EBUSY)
+               pcim_pin_device(pdev);
+       if (rc)
+               return rc;
 
        rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
        if (rc)
-               goto err_out_regions;
+               return rc;
        rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK);
        if (rc)
-               goto err_out_regions;
+               return rc;
 
-       probe_ent = kmalloc(sizeof(*probe_ent), GFP_KERNEL);
-       if (probe_ent == NULL) {
-               rc = -ENOMEM;
-               goto err_out_regions;
-       }
+       probe_ent = devm_kzalloc(&pdev->dev, sizeof(*probe_ent), GFP_KERNEL);
+       if (probe_ent == NULL)
+               return -ENOMEM;
 
-       memset(probe_ent, 0, sizeof(*probe_ent));
        probe_ent->dev = pci_dev_to_dev(pdev);
        INIT_LIST_HEAD(&probe_ent->node);
 
-       mmio_base = pci_iomap(pdev, 3, 0);
-       if (mmio_base == NULL) {
-               rc = -ENOMEM;
-               goto err_out_free_ent;
-       }
-       base = (unsigned long) mmio_base;
-
-       hpriv = kmalloc(sizeof(*hpriv), GFP_KERNEL);
-       if (!hpriv) {
-               rc = -ENOMEM;
-               goto err_out_iounmap;
-       }
-       memset(hpriv, 0, sizeof(*hpriv));
-
-       dimm_mmio = pci_iomap(pdev, 4, 0);
-       if (!dimm_mmio) {
-               kfree(hpriv);
-               rc = -ENOMEM;
-               goto err_out_iounmap;
-       }
-
-       hpriv->dimm_mmio = dimm_mmio;
+       hpriv = devm_kzalloc(&pdev->dev, sizeof(*hpriv), GFP_KERNEL);
+       if (!hpriv)
+               return -ENOMEM;
 
        probe_ent->sht          = pdc_port_info[board_idx].sht;
        probe_ent->port_flags   = pdc_port_info[board_idx].flags;
@@ -1436,10 +1369,10 @@ static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *
 
                probe_ent->irq = pdev->irq;
                probe_ent->irq_flags = IRQF_SHARED;
-       probe_ent->mmio_base = mmio_base;
+       probe_ent->iomap = pcim_iomap_table(pdev);
 
        probe_ent->private_data = hpriv;
-       base += PDC_CHIP0_OFS;
+       base = probe_ent->iomap[PDC_MMIO_BAR] + PDC_CHIP0_OFS;
 
        probe_ent->n_ports = 4;
        pdc_sata_setup_port(&probe_ent->port[0], base + 0x200);
@@ -1451,31 +1384,15 @@ static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *
 
        /* initialize adapter */
        /* initialize local dimm */
-       if (pdc20621_dimm_init(probe_ent)) {
-               rc = -ENOMEM;
-               goto err_out_iounmap_dimm;
-       }
+       if (pdc20621_dimm_init(probe_ent))
+               return -ENOMEM;
        pdc_20621_init(probe_ent);
 
-       /* FIXME: check ata_device_add return value */
-       ata_device_add(probe_ent);
-       kfree(probe_ent);
+       if (!ata_device_add(probe_ent))
+               return -ENODEV;
 
+       devm_kfree(&pdev->dev, probe_ent);
        return 0;
-
-err_out_iounmap_dimm:          /* only get to this label if 20621 */
-       kfree(hpriv);
-       pci_iounmap(pdev, dimm_mmio);
-err_out_iounmap:
-       pci_iounmap(pdev, mmio_base);
-err_out_free_ent:
-       kfree(probe_ent);
-err_out_regions:
-       pci_release_regions(pdev);
-err_out:
-       if (!pci_dev_busy)
-               pci_disable_device(pdev);
-       return rc;
 }
 
 
index a43aec62d505deeca00cf4ed20483eba931fc2cb..80131eec68f4cfe95aa028c2533b9cc883f92d87 100644 (file)
@@ -108,7 +108,7 @@ static const struct ata_port_operations uli_ops = {
        .bmdma_status           = ata_bmdma_status,
        .qc_prep                = ata_qc_prep,
        .qc_issue               = ata_qc_issue_prot,
-       .data_xfer              = ata_pio_data_xfer,
+       .data_xfer              = ata_data_xfer,
 
        .freeze                 = ata_bmdma_freeze,
        .thaw                   = ata_bmdma_thaw,
@@ -117,13 +117,13 @@ static const struct ata_port_operations uli_ops = {
 
        .irq_handler            = ata_interrupt,
        .irq_clear              = ata_bmdma_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
 
        .scr_read               = uli_scr_read,
        .scr_write              = uli_scr_write,
 
        .port_start             = ata_port_start,
-       .port_stop              = ata_port_stop,
-       .host_stop              = ata_host_stop,
 };
 
 static struct ata_port_info uli_port_info = {
@@ -189,62 +189,60 @@ static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
        struct ata_port_info *ppi[2];
        int rc;
        unsigned int board_idx = (unsigned int) ent->driver_data;
-       int pci_dev_busy = 0;
        struct uli_priv *hpriv;
+       void __iomem * const *iomap;
 
        if (!printed_version++)
                dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n");
 
-       rc = pci_enable_device(pdev);
+       rc = pcim_enable_device(pdev);
        if (rc)
                return rc;
 
        rc = pci_request_regions(pdev, DRV_NAME);
        if (rc) {
-               pci_dev_busy = 1;
-               goto err_out;
+               pcim_pin_device(pdev);
+               return rc;
        }
 
        rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
        if (rc)
-               goto err_out_regions;
+               return rc;
        rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK);
        if (rc)
-               goto err_out_regions;
+               return rc;
 
        ppi[0] = ppi[1] = &uli_port_info;
        probe_ent = ata_pci_init_native_mode(pdev, ppi, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY);
-       if (!probe_ent) {
-               rc = -ENOMEM;
-               goto err_out_regions;
-       }
+       if (!probe_ent)
+               return -ENOMEM;
 
-       hpriv = kzalloc(sizeof(*hpriv), GFP_KERNEL);
-       if (!hpriv) {
-               rc = -ENOMEM;
-               goto err_out_probe_ent;
-       }
+       hpriv = devm_kzalloc(&pdev->dev, sizeof(*hpriv), GFP_KERNEL);
+       if (!hpriv)
+               return -ENOMEM;
 
        probe_ent->private_data = hpriv;
 
+       iomap = pcim_iomap_table(pdev);
+
        switch (board_idx) {
        case uli_5287:
                hpriv->scr_cfg_addr[0] = ULI5287_BASE;
                hpriv->scr_cfg_addr[1] = ULI5287_BASE + ULI5287_OFFS;
                        probe_ent->n_ports = 4;
 
-                       probe_ent->port[2].cmd_addr = pci_resource_start(pdev, 0) + 8;
+               probe_ent->port[2].cmd_addr = iomap[0] + 8;
                probe_ent->port[2].altstatus_addr =
-               probe_ent->port[2].ctl_addr =
-                       (pci_resource_start(pdev, 1) | ATA_PCI_CTL_OFS) + 4;
-               probe_ent->port[2].bmdma_addr = pci_resource_start(pdev, 4) + 16;
+               probe_ent->port[2].ctl_addr = (void __iomem *)
+                       ((unsigned long)iomap[1] | ATA_PCI_CTL_OFS) + 4;
+               probe_ent->port[2].bmdma_addr = iomap[4] + 16;
                hpriv->scr_cfg_addr[2] = ULI5287_BASE + ULI5287_OFFS*4;
 
-               probe_ent->port[3].cmd_addr = pci_resource_start(pdev, 2) + 8;
+               probe_ent->port[3].cmd_addr = iomap[2] + 8;
                probe_ent->port[3].altstatus_addr =
-               probe_ent->port[3].ctl_addr =
-                       (pci_resource_start(pdev, 3) | ATA_PCI_CTL_OFS) + 4;
-               probe_ent->port[3].bmdma_addr = pci_resource_start(pdev, 4) + 24;
+               probe_ent->port[3].ctl_addr = (void __iomem *)
+                       ((unsigned long)iomap[3] | ATA_PCI_CTL_OFS) + 4;
+               probe_ent->port[3].bmdma_addr = iomap[4] + 24;
                hpriv->scr_cfg_addr[3] = ULI5287_BASE + ULI5287_OFFS*5;
 
                ata_std_ports(&probe_ent->port[2]);
@@ -269,21 +267,11 @@ static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
        pci_set_master(pdev);
        pci_intx(pdev, 1);
 
-       /* FIXME: check ata_device_add return value */
-       ata_device_add(probe_ent);
-       kfree(probe_ent);
+       if (!ata_device_add(probe_ent))
+               return -ENODEV;
 
+       devm_kfree(&pdev->dev, probe_ent);
        return 0;
-
-err_out_probe_ent:
-       kfree(probe_ent);
-err_out_regions:
-       pci_release_regions(pdev);
-err_out:
-       if (!pci_dev_busy)
-               pci_disable_device(pdev);
-       return rc;
-
 }
 
 static int __init uli_init(void)
index d3d5c0d57032f029024e3077d475573a523c1c4c..baca6d79bb0bc426eda80fe358555a35c246981e 100644 (file)
@@ -44,7 +44,6 @@
 #include <linux/device.h>
 #include <scsi/scsi_host.h>
 #include <linux/libata.h>
-#include <asm/io.h>
 
 #define DRV_NAME       "sata_via"
 #define DRV_VERSION    "2.0"
@@ -59,11 +58,14 @@ enum {
        SATA_INT_GATE           = 0x41, /* SATA interrupt gating */
        SATA_NATIVE_MODE        = 0x42, /* Native mode enable */
        SATA_PATA_SHARING       = 0x49, /* PATA/SATA sharing func ctrl */
-
+       PATA_UDMA_TIMING        = 0xB3, /* PATA timing for DMA/ cable detect */
+       PATA_PIO_TIMING         = 0xAB, /* PATA timing register */
+       
        PORT0                   = (1 << 1),
        PORT1                   = (1 << 0),
        ALL_PORTS               = PORT0 | PORT1,
-       N_PORTS                 = 2,
+       PATA_PORT               = 2,    /* PATA is port 2 */
+       N_PORTS                 = 3,
 
        NATIVE_MODE_ALL         = (1 << 7) | (1 << 6) | (1 << 5) | (1 << 4),
 
@@ -76,6 +78,11 @@ static u32 svia_scr_read (struct ata_port *ap, unsigned int sc_reg);
 static void svia_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val);
 static void svia_noop_freeze(struct ata_port *ap);
 static void vt6420_error_handler(struct ata_port *ap);
+static void vt6421_sata_error_handler(struct ata_port *ap);
+static void vt6421_pata_error_handler(struct ata_port *ap);
+static void vt6421_set_pio_mode(struct ata_port *ap, struct ata_device *adev);
+static void vt6421_set_dma_mode(struct ata_port *ap, struct ata_device *adev);
+static int vt6421_port_start(struct ata_port *ap);
 
 static const struct pci_device_id svia_pci_tbl[] = {
        { PCI_VDEVICE(VIA, 0x5337), vt6420 },
@@ -127,7 +134,7 @@ static const struct ata_port_operations vt6420_sata_ops = {
 
        .qc_prep                = ata_qc_prep,
        .qc_issue               = ata_qc_issue_prot,
-       .data_xfer              = ata_pio_data_xfer,
+       .data_xfer              = ata_data_xfer,
 
        .freeze                 = svia_noop_freeze,
        .thaw                   = ata_bmdma_thaw,
@@ -136,15 +143,49 @@ static const struct ata_port_operations vt6420_sata_ops = {
 
        .irq_handler            = ata_interrupt,
        .irq_clear              = ata_bmdma_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
 
        .port_start             = ata_port_start,
-       .port_stop              = ata_port_stop,
-       .host_stop              = ata_host_stop,
 };
 
-static const struct ata_port_operations vt6421_sata_ops = {
+static const struct ata_port_operations vt6421_pata_ops = {
        .port_disable           = ata_port_disable,
+       
+       .set_piomode            = vt6421_set_pio_mode,
+       .set_dmamode            = vt6421_set_dma_mode,
+
+       .tf_load                = ata_tf_load,
+       .tf_read                = ata_tf_read,
+       .check_status           = ata_check_status,
+       .exec_command           = ata_exec_command,
+       .dev_select             = ata_std_dev_select,
+
+       .bmdma_setup            = ata_bmdma_setup,
+       .bmdma_start            = ata_bmdma_start,
+       .bmdma_stop             = ata_bmdma_stop,
+       .bmdma_status           = ata_bmdma_status,
+
+       .qc_prep                = ata_qc_prep,
+       .qc_issue               = ata_qc_issue_prot,
+       .data_xfer              = ata_data_xfer,
+
+       .freeze                 = ata_bmdma_freeze,
+       .thaw                   = ata_bmdma_thaw,
+       .error_handler          = vt6421_pata_error_handler,
+       .post_internal_cmd      = ata_bmdma_post_internal_cmd,
 
+       .irq_handler            = ata_interrupt,
+       .irq_clear              = ata_bmdma_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
+
+       .port_start             = vt6421_port_start,
+};
+
+static const struct ata_port_operations vt6421_sata_ops = {
+       .port_disable           = ata_port_disable,
+       
        .tf_load                = ata_tf_load,
        .tf_read                = ata_tf_read,
        .check_status           = ata_check_status,
@@ -158,22 +199,22 @@ static const struct ata_port_operations vt6421_sata_ops = {
 
        .qc_prep                = ata_qc_prep,
        .qc_issue               = ata_qc_issue_prot,
-       .data_xfer              = ata_pio_data_xfer,
+       .data_xfer              = ata_data_xfer,
 
        .freeze                 = ata_bmdma_freeze,
        .thaw                   = ata_bmdma_thaw,
-       .error_handler          = ata_bmdma_error_handler,
+       .error_handler          = vt6421_sata_error_handler,
        .post_internal_cmd      = ata_bmdma_post_internal_cmd,
 
        .irq_handler            = ata_interrupt,
        .irq_clear              = ata_bmdma_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
 
        .scr_read               = svia_scr_read,
        .scr_write              = svia_scr_write,
 
-       .port_start             = ata_port_start,
-       .port_stop              = ata_port_stop,
-       .host_stop              = ata_host_stop,
+       .port_start             = vt6421_port_start,
 };
 
 static struct ata_port_info vt6420_port_info = {
@@ -195,14 +236,14 @@ static u32 svia_scr_read (struct ata_port *ap, unsigned int sc_reg)
 {
        if (sc_reg > SCR_CONTROL)
                return 0xffffffffU;
-       return inl(ap->ioaddr.scr_addr + (4 * sc_reg));
+       return ioread32(ap->ioaddr.scr_addr + (4 * sc_reg));
 }
 
 static void svia_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val)
 {
        if (sc_reg > SCR_CONTROL)
                return;
-       outl(val, ap->ioaddr.scr_addr + (4 * sc_reg));
+       iowrite32(val, ap->ioaddr.scr_addr + (4 * sc_reg));
 }
 
 static void svia_noop_freeze(struct ata_port *ap)
@@ -289,6 +330,61 @@ static void vt6420_error_handler(struct ata_port *ap)
                                  NULL, ata_std_postreset);
 }
 
+static int vt6421_pata_prereset(struct ata_port *ap)
+{
+       struct pci_dev *pdev = to_pci_dev(ap->host->dev);
+       u8 tmp;
+
+       pci_read_config_byte(pdev, PATA_UDMA_TIMING, &tmp);
+       if (tmp & 0x10)
+               ap->cbl = ATA_CBL_PATA40;
+       else
+               ap->cbl = ATA_CBL_PATA80;
+       return 0;
+}
+
+static void vt6421_pata_error_handler(struct ata_port *ap)
+{
+       return ata_bmdma_drive_eh(ap, vt6421_pata_prereset, ata_std_softreset,
+                                 NULL, ata_std_postreset);
+}
+
+static int vt6421_sata_prereset(struct ata_port *ap)
+{
+       ap->cbl = ATA_CBL_SATA;
+       return 0;
+}
+
+static void vt6421_sata_error_handler(struct ata_port *ap)
+{
+       return ata_bmdma_drive_eh(ap, vt6421_sata_prereset, ata_std_softreset,
+                                 NULL, ata_std_postreset);
+}
+
+static void vt6421_set_pio_mode(struct ata_port *ap, struct ata_device *adev)
+{
+       struct pci_dev *pdev = to_pci_dev(ap->host->dev);
+       static const u8 pio_bits[] = { 0xA8, 0x65, 0x65, 0x31, 0x20 };
+       pci_write_config_byte(pdev, PATA_PIO_TIMING, pio_bits[adev->pio_mode - XFER_PIO_0]);
+}
+
+static void vt6421_set_dma_mode(struct ata_port *ap, struct ata_device *adev)
+{
+       struct pci_dev *pdev = to_pci_dev(ap->host->dev);
+       static const u8 udma_bits[] = { 0xEE, 0xE8, 0xE6, 0xE4, 0xE2, 0xE1, 0xE0, 0xE0 };
+       pci_write_config_byte(pdev, PATA_UDMA_TIMING, udma_bits[adev->pio_mode - XFER_UDMA_0]);
+}
+
+static int vt6421_port_start(struct ata_port *ap)
+{
+       if (ap->port_no == PATA_PORT) {
+               ap->ops = &vt6421_pata_ops;
+               ap->mwdma_mask = 0;
+               ap->flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_NO_LEGACY | ATA_FLAG_SRST;
+       }
+       return ata_port_start(ap);
+}
+
 static const unsigned int svia_bar_sizes[] = {
        8, 4, 8, 4, 16, 256
 };
@@ -297,31 +393,28 @@ static const unsigned int vt6421_bar_sizes[] = {
        16, 16, 16, 16, 32, 128
 };
 
-static unsigned long svia_scr_addr(unsigned long addr, unsigned int port)
+static void __iomem * svia_scr_addr(void __iomem *addr, unsigned int port)
 {
        return addr + (port * 128);
 }
 
-static unsigned long vt6421_scr_addr(unsigned long addr, unsigned int port)
+static void __iomem * vt6421_scr_addr(void __iomem *addr, unsigned int port)
 {
        return addr + (port * 64);
 }
 
 static void vt6421_init_addrs(struct ata_probe_ent *probe_ent,
-                             struct pci_dev *pdev,
-                             unsigned int port)
+                             void __iomem * const *iomap, unsigned int port)
 {
-       unsigned long reg_addr = pci_resource_start(pdev, port);
-       unsigned long bmdma_addr = pci_resource_start(pdev, 4) + (port * 8);
-       unsigned long scr_addr;
+       void __iomem *reg_addr = iomap[port];
+       void __iomem *bmdma_addr = iomap[4] + (port * 8);
 
        probe_ent->port[port].cmd_addr = reg_addr;
        probe_ent->port[port].altstatus_addr =
-       probe_ent->port[port].ctl_addr = (reg_addr + 8) | ATA_PCI_CTL_OFS;
+       probe_ent->port[port].ctl_addr = (void __iomem *)
+               ((unsigned long)(reg_addr + 8) | ATA_PCI_CTL_OFS);
        probe_ent->port[port].bmdma_addr = bmdma_addr;
-
-       scr_addr = vt6421_scr_addr(pci_resource_start(pdev, 5), port);
-       probe_ent->port[port].scr_addr = scr_addr;
+       probe_ent->port[port].scr_addr = vt6421_scr_addr(iomap[5], port);
 
        ata_std_ports(&probe_ent->port[port]);
 }
@@ -330,16 +423,16 @@ static struct ata_probe_ent *vt6420_init_probe_ent(struct pci_dev *pdev)
 {
        struct ata_probe_ent *probe_ent;
        struct ata_port_info *ppi[2];
-       
+       void __iomem * const *iomap;
+
        ppi[0] = ppi[1] = &vt6420_port_info;
        probe_ent = ata_pci_init_native_mode(pdev, ppi, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY);
        if (!probe_ent)
                return NULL;
 
-       probe_ent->port[0].scr_addr =
-               svia_scr_addr(pci_resource_start(pdev, 5), 0);
-       probe_ent->port[1].scr_addr =
-               svia_scr_addr(pci_resource_start(pdev, 5), 1);
+       iomap = pcim_iomap_table(pdev);
+       probe_ent->port[0].scr_addr = svia_scr_addr(iomap[5], 0);
+       probe_ent->port[1].scr_addr = svia_scr_addr(iomap[5], 1);
 
        return probe_ent;
 }
@@ -349,7 +442,7 @@ static struct ata_probe_ent *vt6421_init_probe_ent(struct pci_dev *pdev)
        struct ata_probe_ent *probe_ent;
        unsigned int i;
 
-       probe_ent = kmalloc(sizeof(*probe_ent), GFP_KERNEL);
+       probe_ent = devm_kzalloc(&pdev->dev, sizeof(*probe_ent), GFP_KERNEL);
        if (!probe_ent)
                return NULL;
 
@@ -368,7 +461,7 @@ static struct ata_probe_ent *vt6421_init_probe_ent(struct pci_dev *pdev)
        probe_ent->udma_mask    = 0x7f;
 
        for (i = 0; i < N_PORTS; i++)
-               vt6421_init_addrs(probe_ent, pdev, i);
+               vt6421_init_addrs(probe_ent, pcim_iomap_table(pdev), i);
 
        return probe_ent;
 }
@@ -420,20 +513,19 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
        struct ata_probe_ent *probe_ent;
        int board_id = (int) ent->driver_data;
        const int *bar_sizes;
-       int pci_dev_busy = 0;
        u8 tmp8;
 
        if (!printed_version++)
                dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
 
-       rc = pci_enable_device(pdev);
+       rc = pcim_enable_device(pdev);
        if (rc)
                return rc;
 
-       rc = pci_request_regions(pdev, DRV_NAME);
+       rc = pcim_iomap_regions(pdev, 0x1f, DRV_NAME);
        if (rc) {
-               pci_dev_busy = 1;
-               goto err_out;
+               pcim_pin_device(pdev);
+               return rc;
        }
 
        if (board_id == vt6420) {
@@ -442,8 +534,7 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
                        dev_printk(KERN_ERR, &pdev->dev,
                                   "SATA master/slave not supported (0x%x)\n",
                                   (int) tmp8);
-                       rc = -EIO;
-                       goto err_out_regions;
+                       return -EIO;
                }
 
                bar_sizes = &svia_bar_sizes[0];
@@ -459,16 +550,15 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
                                i,
                                (unsigned long long)pci_resource_start(pdev, i),
                                (unsigned long long)pci_resource_len(pdev, i));
-                       rc = -ENODEV;
-                       goto err_out_regions;
+                       return -ENODEV;
                }
 
        rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
        if (rc)
-               goto err_out_regions;
+               return rc;
        rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK);
        if (rc)
-               goto err_out_regions;
+               return rc;
 
        if (board_id == vt6420)
                probe_ent = vt6420_init_probe_ent(pdev);
@@ -477,26 +567,18 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
 
        if (!probe_ent) {
                dev_printk(KERN_ERR, &pdev->dev, "out of memory\n");
-               rc = -ENOMEM;
-               goto err_out_regions;
+               return -ENOMEM;
        }
 
        svia_configure(pdev);
 
        pci_set_master(pdev);
 
-       /* FIXME: check ata_device_add return value */
-       ata_device_add(probe_ent);
-       kfree(probe_ent);
+       if (!ata_device_add(probe_ent))
+               return -ENODEV;
 
+       devm_kfree(&pdev->dev, probe_ent);
        return 0;
-
-err_out_regions:
-       pci_release_regions(pdev);
-err_out:
-       if (!pci_dev_busy)
-               pci_disable_device(pdev);
-       return rc;
 }
 
 static int __init svia_init(void)
@@ -511,4 +593,3 @@ static void __exit svia_exit(void)
 
 module_init(svia_init);
 module_exit(svia_exit);
-
index 0fa1b89f76d588fac3745d4d008712162b6c267d..3d9daf231115b46c1e7385d2c41ac1b00da31d4a 100644 (file)
@@ -50,6 +50,8 @@
 #define DRV_VERSION    "2.0"
 
 enum {
+       VSC_MMIO_BAR                    = 0,
+
        /* Interrupt register offsets (from chip base address) */
        VSC_SATA_INT_STAT_OFFSET        = 0x00,
        VSC_SATA_INT_MASK_OFFSET        = 0x04,
@@ -96,7 +98,6 @@ enum {
                              VSC_SATA_INT_PHY_CHANGE),
 };
 
-
 #define is_vsc_sata_int_err(port_idx, int_status) \
         (int_status & (VSC_SATA_INT_ERROR << (8 * port_idx)))
 
@@ -105,7 +106,7 @@ static u32 vsc_sata_scr_read (struct ata_port *ap, unsigned int sc_reg)
 {
        if (sc_reg > SCR_CONTROL)
                return 0xffffffffU;
-       return readl((void __iomem *) ap->ioaddr.scr_addr + (sc_reg * 4));
+       return readl(ap->ioaddr.scr_addr + (sc_reg * 4));
 }
 
 
@@ -114,7 +115,7 @@ static void vsc_sata_scr_write (struct ata_port *ap, unsigned int sc_reg,
 {
        if (sc_reg > SCR_CONTROL)
                return;
-       writel(val, (void __iomem *) ap->ioaddr.scr_addr + (sc_reg * 4));
+       writel(val, ap->ioaddr.scr_addr + (sc_reg * 4));
 }
 
 
@@ -123,7 +124,7 @@ static void vsc_intr_mask_update(struct ata_port *ap, u8 ctl)
        void __iomem *mask_addr;
        u8 mask;
 
-       mask_addr = ap->host->mmio_base +
+       mask_addr = ap->host->iomap[VSC_MMIO_BAR] +
                VSC_SATA_INT_MASK_OFFSET + ap->port_no;
        mask = readb(mask_addr);
        if (ctl & ATA_NIEN)
@@ -150,25 +151,25 @@ static void vsc_sata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf)
        }
        if (is_addr && (tf->flags & ATA_TFLAG_LBA48)) {
                writew(tf->feature | (((u16)tf->hob_feature) << 8),
-                      (void __iomem *) ioaddr->feature_addr);
+                      ioaddr->feature_addr);
                writew(tf->nsect | (((u16)tf->hob_nsect) << 8),
-                      (void __iomem *) ioaddr->nsect_addr);
+                      ioaddr->nsect_addr);
                writew(tf->lbal | (((u16)tf->hob_lbal) << 8),
-                      (void __iomem *) ioaddr->lbal_addr);
+                      ioaddr->lbal_addr);
                writew(tf->lbam | (((u16)tf->hob_lbam) << 8),
-                      (void __iomem *) ioaddr->lbam_addr);
+                      ioaddr->lbam_addr);
                writew(tf->lbah | (((u16)tf->hob_lbah) << 8),
-                      (void __iomem *) ioaddr->lbah_addr);
+                      ioaddr->lbah_addr);
        } else if (is_addr) {
-               writew(tf->feature, (void __iomem *) ioaddr->feature_addr);
-               writew(tf->nsect, (void __iomem *) ioaddr->nsect_addr);
-               writew(tf->lbal, (void __iomem *) ioaddr->lbal_addr);
-               writew(tf->lbam, (void __iomem *) ioaddr->lbam_addr);
-               writew(tf->lbah, (void __iomem *) ioaddr->lbah_addr);
+               writew(tf->feature, ioaddr->feature_addr);
+               writew(tf->nsect, ioaddr->nsect_addr);
+               writew(tf->lbal, ioaddr->lbal_addr);
+               writew(tf->lbam, ioaddr->lbam_addr);
+               writew(tf->lbah, ioaddr->lbah_addr);
        }
 
        if (tf->flags & ATA_TFLAG_DEVICE)
-               writeb(tf->device, (void __iomem *) ioaddr->device_addr);
+               writeb(tf->device, ioaddr->device_addr);
 
        ata_wait_idle(ap);
 }
@@ -180,12 +181,12 @@ static void vsc_sata_tf_read(struct ata_port *ap, struct ata_taskfile *tf)
        u16 nsect, lbal, lbam, lbah, feature;
 
        tf->command = ata_check_status(ap);
-       tf->device = readw((void __iomem *) ioaddr->device_addr);
-       feature = readw((void __iomem *) ioaddr->error_addr);
-       nsect = readw((void __iomem *) ioaddr->nsect_addr);
-       lbal = readw((void __iomem *) ioaddr->lbal_addr);
-       lbam = readw((void __iomem *) ioaddr->lbam_addr);
-       lbah = readw((void __iomem *) ioaddr->lbah_addr);
+       tf->device = readw(ioaddr->device_addr);
+       feature = readw(ioaddr->error_addr);
+       nsect = readw(ioaddr->nsect_addr);
+       lbal = readw(ioaddr->lbal_addr);
+       lbam = readw(ioaddr->lbam_addr);
+       lbah = readw(ioaddr->lbah_addr);
 
        tf->feature = feature;
        tf->nsect = nsect;
@@ -217,7 +218,8 @@ static irqreturn_t vsc_sata_interrupt (int irq, void *dev_instance)
 
        spin_lock(&host->lock);
 
-       int_status = readl(host->mmio_base + VSC_SATA_INT_STAT_OFFSET);
+       int_status = readl(host->iomap[VSC_MMIO_BAR] +
+                          VSC_SATA_INT_STAT_OFFSET);
 
        for (i = 0; i < host->n_ports; i++) {
                if (int_status & ((u32) 0xFF << (8 * i))) {
@@ -301,21 +303,22 @@ static const struct ata_port_operations vsc_sata_ops = {
        .bmdma_status           = ata_bmdma_status,
        .qc_prep                = ata_qc_prep,
        .qc_issue               = ata_qc_issue_prot,
-       .data_xfer              = ata_mmio_data_xfer,
+       .data_xfer              = ata_data_xfer,
        .freeze                 = ata_bmdma_freeze,
        .thaw                   = ata_bmdma_thaw,
        .error_handler          = ata_bmdma_error_handler,
        .post_internal_cmd      = ata_bmdma_post_internal_cmd,
        .irq_handler            = vsc_sata_interrupt,
        .irq_clear              = ata_bmdma_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
        .scr_read               = vsc_sata_scr_read,
        .scr_write              = vsc_sata_scr_write,
        .port_start             = ata_port_start,
-       .port_stop              = ata_port_stop,
-       .host_stop              = ata_pci_host_stop,
 };
 
-static void __devinit vsc_sata_setup_port(struct ata_ioports *port, unsigned long base)
+static void __devinit vsc_sata_setup_port(struct ata_ioports *port,
+                                         void __iomem *base)
 {
        port->cmd_addr          = base + VSC_SATA_TF_CMD_OFFSET;
        port->data_addr         = base + VSC_SATA_TF_DATA_OFFSET;
@@ -332,80 +335,70 @@ static void __devinit vsc_sata_setup_port(struct ata_ioports *port, unsigned lon
        port->ctl_addr          = base + VSC_SATA_TF_CTL_OFFSET;
        port->bmdma_addr        = base + VSC_SATA_DMA_CMD_OFFSET;
        port->scr_addr          = base + VSC_SATA_SCR_STATUS_OFFSET;
-       writel(0, (void __iomem *) base + VSC_SATA_UP_DESCRIPTOR_OFFSET);
-       writel(0, (void __iomem *) base + VSC_SATA_UP_DATA_BUFFER_OFFSET);
+       writel(0, base + VSC_SATA_UP_DESCRIPTOR_OFFSET);
+       writel(0, base + VSC_SATA_UP_DATA_BUFFER_OFFSET);
 }
 
 
 static int __devinit vsc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
 {
        static int printed_version;
-       struct ata_probe_ent *probe_ent = NULL;
-       unsigned long base;
-       int pci_dev_busy = 0;
+       struct ata_probe_ent *probe_ent;
        void __iomem *mmio_base;
        int rc;
 
        if (!printed_version++)
                dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
 
-       rc = pci_enable_device(pdev);
+       rc = pcim_enable_device(pdev);
        if (rc)
                return rc;
 
        /*
         * Check if we have needed resource mapped.
         */
-       if (pci_resource_len(pdev, 0) == 0) {
-               rc = -ENODEV;
-               goto err_out;
-       }
+       if (pci_resource_len(pdev, 0) == 0)
+               return -ENODEV;
 
-       rc = pci_request_regions(pdev, DRV_NAME);
-       if (rc) {
-               pci_dev_busy = 1;
-               goto err_out;
-       }
+       rc = pcim_iomap_regions(pdev, 1 << VSC_MMIO_BAR, DRV_NAME);
+       if (rc == -EBUSY)
+               pcim_pin_device(pdev);
+       if (rc)
+               return rc;
 
        /*
         * Use 32 bit DMA mask, because 64 bit address support is poor.
         */
        rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
        if (rc)
-               goto err_out_regions;
+               return rc;
        rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
        if (rc)
-               goto err_out_regions;
+               return rc;
 
-       probe_ent = kmalloc(sizeof(*probe_ent), GFP_KERNEL);
-       if (probe_ent == NULL) {
-               rc = -ENOMEM;
-               goto err_out_regions;
-       }
-       memset(probe_ent, 0, sizeof(*probe_ent));
+       probe_ent = devm_kzalloc(&pdev->dev, sizeof(*probe_ent), GFP_KERNEL);
+       if (probe_ent == NULL)
+               return -ENOMEM;
        probe_ent->dev = pci_dev_to_dev(pdev);
        INIT_LIST_HEAD(&probe_ent->node);
 
-       mmio_base = pci_iomap(pdev, 0, 0);
-       if (mmio_base == NULL) {
-               rc = -ENOMEM;
-               goto err_out_free_ent;
-       }
-       base = (unsigned long) mmio_base;
-
        /*
         * Due to a bug in the chip, the default cache line size can't be used
         */
        pci_write_config_byte(pdev, PCI_CACHE_LINE_SIZE, 0x80);
 
+       if (pci_enable_msi(pdev) == 0)
+               pci_intx(pdev, 0);
+       else
+               probe_ent->irq_flags = IRQF_SHARED;
+
        probe_ent->sht = &vsc_sata_sht;
        probe_ent->port_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
                                ATA_FLAG_MMIO;
        probe_ent->port_ops = &vsc_sata_ops;
        probe_ent->n_ports = 4;
        probe_ent->irq = pdev->irq;
-       probe_ent->irq_flags = IRQF_SHARED;
-       probe_ent->mmio_base = mmio_base;
+       probe_ent->iomap = pcim_iomap_table(pdev);
 
        /* We don't care much about the PIO/UDMA masks, but the core won't like us
         * if we don't fill these
@@ -414,11 +407,13 @@ static int __devinit vsc_sata_init_one (struct pci_dev *pdev, const struct pci_d
        probe_ent->mwdma_mask = 0x07;
        probe_ent->udma_mask = 0x7f;
 
+       mmio_base = probe_ent->iomap[VSC_MMIO_BAR];
+
        /* We have 4 ports per PCI function */
-       vsc_sata_setup_port(&probe_ent->port[0], base + 1 * VSC_SATA_PORT_OFFSET);
-       vsc_sata_setup_port(&probe_ent->port[1], base + 2 * VSC_SATA_PORT_OFFSET);
-       vsc_sata_setup_port(&probe_ent->port[2], base + 3 * VSC_SATA_PORT_OFFSET);
-       vsc_sata_setup_port(&probe_ent->port[3], base + 4 * VSC_SATA_PORT_OFFSET);
+       vsc_sata_setup_port(&probe_ent->port[0], mmio_base + 1 * VSC_SATA_PORT_OFFSET);
+       vsc_sata_setup_port(&probe_ent->port[1], mmio_base + 2 * VSC_SATA_PORT_OFFSET);
+       vsc_sata_setup_port(&probe_ent->port[2], mmio_base + 3 * VSC_SATA_PORT_OFFSET);
+       vsc_sata_setup_port(&probe_ent->port[3], mmio_base + 4 * VSC_SATA_PORT_OFFSET);
 
        pci_set_master(pdev);
 
@@ -430,20 +425,11 @@ static int __devinit vsc_sata_init_one (struct pci_dev *pdev, const struct pci_d
         */
        pci_write_config_dword(pdev, 0x98, 0);
 
-       /* FIXME: check ata_device_add return value */
-       ata_device_add(probe_ent);
-       kfree(probe_ent);
+       if (!ata_device_add(probe_ent))
+               return -ENODEV;
 
+       devm_kfree(&pdev->dev, probe_ent);
        return 0;
-
-err_out_free_ent:
-       kfree(probe_ent);
-err_out_regions:
-       pci_release_regions(pdev);
-err_out:
-       if (!pci_dev_busy)
-               pci_disable_device(pdev);
-       return rc;
 }
 
 static const struct pci_device_id vsc_sata_pci_tbl[] = {
index 5aab7bd473ac9325d5e327597ec474d059199184..8fccf018f165502f6d70b35bb9bad0f784344c20 100644 (file)
@@ -912,7 +912,6 @@ static int start_rx(struct atm_dev *dev)
                free_page((unsigned long) eni_dev->free_list);
                return -ENOMEM;
        }
-       memset(eni_dev->rx_map,0,PAGE_SIZE);
        eni_dev->rx_mult = DEFAULT_RX_MULT;
        eni_dev->fast = eni_dev->last_fast = NULL;
        eni_dev->slow = eni_dev->last_slow = NULL;
diff --git a/drivers/auxdisplay/Kconfig b/drivers/auxdisplay/Kconfig
new file mode 100644 (file)
index 0000000..0300e7f
--- /dev/null
@@ -0,0 +1,109 @@
+#
+# For a description of the syntax of this configuration file,
+# see Documentation/kbuild/kconfig-language.txt.
+#
+# Auxiliary display drivers configuration.
+#
+
+menu "Auxiliary Display support"
+
+config KS0108
+       tristate "KS0108 LCD Controller"
+       depends on PARPORT_PC
+       default n
+       ---help---
+         If you have a LCD controlled by one or more KS0108
+         controllers, say Y. You will need also another more specific
+         driver for your LCD.
+
+         Depends on Parallel Port support. If you say Y at
+         parport, you will be able to compile this as a module (M)
+         and built-in as well (Y).
+
+         To compile this as a module, choose M here:
+         the module will be called ks0108.
+
+         If unsure, say N.
+
+config KS0108_PORT
+       hex "Parallel port where the LCD is connected"
+       depends on KS0108
+       default 0x378
+       ---help---
+         The address of the parallel port where the LCD is connected.
+
+         The first  standard parallel port address is 0x378.
+         The second standard parallel port address is 0x278.
+         The third  standard parallel port address is 0x3BC.
+
+         You can specify a different address if you need.
+
+         If you don't know what I'm talking about, load the parport module,
+         and execute "dmesg" or "cat /proc/ioports". You can see there how
+         many parallel ports are present and which address each one has.
+
+         Usually you only need to use 0x378.
+
+         If you compile this as a module, you can still override this
+         using the module parameters.
+
+config KS0108_DELAY
+       int "Delay between each control writing (microseconds)"
+       depends on KS0108
+       default "2"
+       ---help---
+         Amount of time the ks0108 should wait between each control write
+         to the parallel port.
+
+         If your driver seems to miss random writings, increment this.
+
+         If you don't know what I'm talking about, ignore it.
+
+         If you compile this as a module, you can still override this
+         value using the module parameters.
+
+config CFAG12864B
+       tristate "CFAG12864B LCD"
+       depends on X86
+       depends on FB
+       depends on KS0108
+       default n
+       ---help---
+         If you have a Crystalfontz 128x64 2-color LCD, cfag12864b Series,
+         say Y. You also need the ks0108 LCD Controller driver.
+
+         For help about how to wire your LCD to the parallel port,
+         check Documentation/auxdisplay/cfag12864b
+
+         Depends on the x86 arch and the framebuffer support.
+
+         The LCD framebuffer driver can be attached to a console.
+         It will work fine. However, you can't attach it to the fbdev driver
+         of the xorg server.
+
+         To compile this as a module, choose M here:
+         the modules will be called cfag12864b and cfag12864bfb.
+
+         If unsure, say N.
+
+config CFAG12864B_RATE
+       int "Refresh rate (hertz)"
+       depends on CFAG12864B
+       default "20"
+       ---help---
+         Refresh rate of the LCD.
+
+         As the LCD is not memory mapped, the driver has to make the work by
+         software. This means you should be careful setting this value higher.
+         If your CPUs are really slow or you feel the system is slowed down,
+         decrease the value.
+
+         Be careful modifying this value to a very high value:
+         You can freeze the computer, or the LCD maybe can't draw as fast as you
+         are requesting.
+
+         If you don't know what I'm talking about, ignore it.
+
+         If you compile this as a module, you can still override this
+         value using the module parameters.
+endmenu
diff --git a/drivers/auxdisplay/Makefile b/drivers/auxdisplay/Makefile
new file mode 100644 (file)
index 0000000..8a8936a
--- /dev/null
@@ -0,0 +1,6 @@
+#
+# Makefile for the kernel auxiliary displays device drivers.
+#
+
+obj-$(CONFIG_KS0108)           += ks0108.o
+obj-$(CONFIG_CFAG12864B)       += cfag12864b.o cfag12864bfb.o
diff --git a/drivers/auxdisplay/cfag12864b.c b/drivers/auxdisplay/cfag12864b.c
new file mode 100644 (file)
index 0000000..889583d
--- /dev/null
@@ -0,0 +1,383 @@
+/*
+ *    Filename: cfag12864b.c
+ *     Version: 0.1.0
+ * Description: cfag12864b LCD driver
+ *     License: GPLv2
+ *     Depends: ks0108
+ *
+ *      Author: Copyright (C) Miguel Ojeda Sandonis <maxextreme@gmail.com>
+ *        Date: 2006-10-31
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/fs.h>
+#include <linux/cdev.h>
+#include <linux/delay.h>
+#include <linux/device.h>
+#include <linux/jiffies.h>
+#include <linux/mutex.h>
+#include <linux/uaccess.h>
+#include <linux/vmalloc.h>
+#include <linux/workqueue.h>
+#include <linux/ks0108.h>
+#include <linux/cfag12864b.h>
+
+
+#define CFAG12864B_NAME "cfag12864b"
+
+/*
+ * Module Parameters
+ */
+
+static unsigned int cfag12864b_rate = CONFIG_CFAG12864B_RATE;
+module_param(cfag12864b_rate, uint, S_IRUGO);
+MODULE_PARM_DESC(cfag12864b_rate,
+       "Refresh rate (hertzs)");
+
+unsigned int cfag12864b_getrate(void)
+{
+       return cfag12864b_rate;
+}
+
+/*
+ * cfag12864b Commands
+ *
+ *     E = Enable signal
+ *             Everytime E switch from low to high,
+ *             cfag12864b/ks0108 reads the command/data.
+ *
+ *     CS1 = First ks0108controller.
+ *             If high, the first ks0108 controller receives commands/data.
+ *
+ *     CS2 = Second ks0108 controller
+ *             If high, the second ks0108 controller receives commands/data.
+ *
+ *     DI = Data/Instruction
+ *             If low, cfag12864b will expect commands.
+ *             If high, cfag12864b will expect data.
+ *
+ */
+
+#define bit(n) (((unsigned char)1)<<(n))
+
+#define CFAG12864B_BIT_E       (0)
+#define CFAG12864B_BIT_CS1     (2)
+#define CFAG12864B_BIT_CS2     (1)
+#define CFAG12864B_BIT_DI      (3)
+
+static unsigned char cfag12864b_state;
+
+static void cfag12864b_set(void)
+{
+       ks0108_writecontrol(cfag12864b_state);
+}
+
+static void cfag12864b_setbit(unsigned char state, unsigned char n)
+{
+       if (state)
+               cfag12864b_state |= bit(n);
+       else
+               cfag12864b_state &= ~bit(n);
+}
+
+static void cfag12864b_e(unsigned char state)
+{
+       cfag12864b_setbit(state, CFAG12864B_BIT_E);
+       cfag12864b_set();
+}
+
+static void cfag12864b_cs1(unsigned char state)
+{
+       cfag12864b_setbit(state, CFAG12864B_BIT_CS1);
+}
+
+static void cfag12864b_cs2(unsigned char state)
+{
+       cfag12864b_setbit(state, CFAG12864B_BIT_CS2);
+}
+
+static void cfag12864b_di(unsigned char state)
+{
+       cfag12864b_setbit(state, CFAG12864B_BIT_DI);
+}
+
+static void cfag12864b_setcontrollers(unsigned char first,
+       unsigned char second)
+{
+       if (first)
+               cfag12864b_cs1(0);
+       else
+               cfag12864b_cs1(1);
+
+       if (second)
+               cfag12864b_cs2(0);
+       else
+               cfag12864b_cs2(1);
+}
+
+static void cfag12864b_controller(unsigned char which)
+{
+       if (which == 0)
+               cfag12864b_setcontrollers(1, 0);
+       else if (which == 1)
+               cfag12864b_setcontrollers(0, 1);
+}
+
+static void cfag12864b_displaystate(unsigned char state)
+{
+       cfag12864b_di(0);
+       cfag12864b_e(1);
+       ks0108_displaystate(state);
+       cfag12864b_e(0);
+}
+
+static void cfag12864b_address(unsigned char address)
+{
+       cfag12864b_di(0);
+       cfag12864b_e(1);
+       ks0108_address(address);
+       cfag12864b_e(0);
+}
+
+static void cfag12864b_page(unsigned char page)
+{
+       cfag12864b_di(0);
+       cfag12864b_e(1);
+       ks0108_page(page);
+       cfag12864b_e(0);
+}
+
+static void cfag12864b_startline(unsigned char startline)
+{
+       cfag12864b_di(0);
+       cfag12864b_e(1);
+       ks0108_startline(startline);
+       cfag12864b_e(0);
+}
+
+static void cfag12864b_writebyte(unsigned char byte)
+{
+       cfag12864b_di(1);
+       cfag12864b_e(1);
+       ks0108_writedata(byte);
+       cfag12864b_e(0);
+}
+
+static void cfag12864b_nop(void)
+{
+       cfag12864b_startline(0);
+}
+
+/*
+ * cfag12864b Internal Commands
+ */
+
+static void cfag12864b_on(void)
+{
+       cfag12864b_setcontrollers(1, 1);
+       cfag12864b_displaystate(1);
+}
+
+static void cfag12864b_off(void)
+{
+       cfag12864b_setcontrollers(1, 1);
+       cfag12864b_displaystate(0);
+}
+
+static void cfag12864b_clear(void)
+{
+       unsigned char i, j;
+
+       cfag12864b_setcontrollers(1, 1);
+       for (i = 0; i < CFAG12864B_PAGES; i++) {
+               cfag12864b_page(i);
+               cfag12864b_address(0);
+               for (j = 0; j < CFAG12864B_ADDRESSES; j++)
+                       cfag12864b_writebyte(0);
+       }
+}
+
+/*
+ * Update work
+ */
+
+unsigned char *cfag12864b_buffer;
+static unsigned char *cfag12864b_cache;
+static DEFINE_MUTEX(cfag12864b_mutex);
+static unsigned char cfag12864b_updating;
+static void cfag12864b_update(struct work_struct *delayed_work);
+static struct workqueue_struct *cfag12864b_workqueue;
+static DECLARE_DELAYED_WORK(cfag12864b_work, cfag12864b_update);
+
+static void cfag12864b_queue(void)
+{
+       queue_delayed_work(cfag12864b_workqueue, &cfag12864b_work,
+               HZ / cfag12864b_rate);
+}
+
+unsigned char cfag12864b_enable(void)
+{
+       unsigned char ret;
+
+       mutex_lock(&cfag12864b_mutex);
+
+       if (!cfag12864b_updating) {
+               cfag12864b_updating = 1;
+               cfag12864b_queue();
+               ret = 0;
+       } else
+               ret = 1;
+
+       mutex_unlock(&cfag12864b_mutex);
+
+       return ret;
+}
+
+void cfag12864b_disable(void)
+{
+       mutex_lock(&cfag12864b_mutex);
+
+       if (cfag12864b_updating) {
+               cfag12864b_updating = 0;
+               cancel_delayed_work(&cfag12864b_work);
+               flush_workqueue(cfag12864b_workqueue);
+       }
+
+       mutex_unlock(&cfag12864b_mutex);
+}
+
+unsigned char cfag12864b_isenabled(void)
+{
+       return cfag12864b_updating;
+}
+
+static void cfag12864b_update(struct work_struct *work)
+{
+       unsigned char c;
+       unsigned short i, j, k, b;
+
+       if (memcmp(cfag12864b_cache, cfag12864b_buffer, CFAG12864B_SIZE)) {
+               for (i = 0; i < CFAG12864B_CONTROLLERS; i++) {
+                       cfag12864b_controller(i);
+                       cfag12864b_nop();
+                       for (j = 0; j < CFAG12864B_PAGES; j++) {
+                               cfag12864b_page(j);
+                               cfag12864b_nop();
+                               cfag12864b_address(0);
+                               cfag12864b_nop();
+                               for (k = 0; k < CFAG12864B_ADDRESSES; k++) {
+                                       for (c = 0, b = 0; b < 8; b++)
+                                               if (cfag12864b_buffer
+                                                       [i * CFAG12864B_ADDRESSES / 8
+                                                       + k / 8 + (j * 8 + b) *
+                                                       CFAG12864B_WIDTH / 8]
+                                                       & bit(k % 8))
+                                                       c |= bit(b);
+                                       cfag12864b_writebyte(c);
+                               }
+                       }
+               }
+
+               memcpy(cfag12864b_cache, cfag12864b_buffer, CFAG12864B_SIZE);
+       }
+
+       if (cfag12864b_updating)
+               cfag12864b_queue();
+}
+
+/*
+ * cfag12864b Exported Symbols
+ */
+
+EXPORT_SYMBOL_GPL(cfag12864b_buffer);
+EXPORT_SYMBOL_GPL(cfag12864b_getrate);
+EXPORT_SYMBOL_GPL(cfag12864b_enable);
+EXPORT_SYMBOL_GPL(cfag12864b_disable);
+EXPORT_SYMBOL_GPL(cfag12864b_isenabled);
+
+/*
+ * Module Init & Exit
+ */
+
+static int __init cfag12864b_init(void)
+{
+       int ret = -EINVAL;
+
+       if (PAGE_SIZE < CFAG12864B_SIZE) {
+               printk(KERN_ERR CFAG12864B_NAME ": ERROR: "
+                       "page size (%i) < cfag12864b size (%i)\n",
+                       (unsigned int)PAGE_SIZE, CFAG12864B_SIZE);
+               ret = -ENOMEM;
+               goto none;
+       }
+
+       cfag12864b_buffer = (unsigned char *) __get_free_page(GFP_KERNEL);
+       if (cfag12864b_buffer == NULL) {
+               printk(KERN_ERR CFAG12864B_NAME ": ERROR: "
+                       "can't get a free page\n");
+               ret = -ENOMEM;
+               goto none;
+       }
+
+       cfag12864b_cache = kmalloc(sizeof(unsigned char) *
+               CFAG12864B_SIZE, GFP_KERNEL);
+       if (cfag12864b_buffer == NULL) {
+               printk(KERN_ERR CFAG12864B_NAME ": ERROR: "
+                       "can't alloc cache buffer (%i bytes)\n",
+                       CFAG12864B_SIZE);
+               ret = -ENOMEM;
+               goto bufferalloced;
+       }
+
+       cfag12864b_workqueue = create_singlethread_workqueue(CFAG12864B_NAME);
+       if (cfag12864b_workqueue == NULL)
+               goto cachealloced;
+
+       memset(cfag12864b_buffer, 0, CFAG12864B_SIZE);
+
+       cfag12864b_clear();
+       cfag12864b_on();
+
+       return 0;
+
+cachealloced:
+       kfree(cfag12864b_cache);
+
+bufferalloced:
+       free_page((unsigned long) cfag12864b_buffer);
+
+none:
+       return ret;
+}
+
+static void __exit cfag12864b_exit(void)
+{
+       cfag12864b_disable();
+       cfag12864b_off();
+       destroy_workqueue(cfag12864b_workqueue);
+       kfree(cfag12864b_cache);
+       free_page((unsigned long) cfag12864b_buffer);
+}
+
+module_init(cfag12864b_init);
+module_exit(cfag12864b_exit);
+
+MODULE_LICENSE("GPL v2");
+MODULE_AUTHOR("Miguel Ojeda Sandonis <maxextreme@gmail.com>");
+MODULE_DESCRIPTION("cfag12864b LCD driver");
diff --git a/drivers/auxdisplay/cfag12864bfb.c b/drivers/auxdisplay/cfag12864bfb.c
new file mode 100644 (file)
index 0000000..94765e7
--- /dev/null
@@ -0,0 +1,180 @@
+/*
+ *    Filename: cfag12864bfb.c
+ *     Version: 0.1.0
+ * Description: cfag12864b LCD framebuffer driver
+ *     License: GPLv2
+ *     Depends: cfag12864b
+ *
+ *      Author: Copyright (C) Miguel Ojeda Sandonis <maxextreme@gmail.com>
+ *        Date: 2006-10-31
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/delay.h>
+#include <linux/errno.h>
+#include <linux/fb.h>
+#include <linux/mm.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+#include <linux/string.h>
+#include <linux/uaccess.h>
+#include <linux/cfag12864b.h>
+
+#define CFAG12864BFB_NAME "cfag12864bfb"
+
+static struct fb_fix_screeninfo cfag12864bfb_fix __initdata = {
+       .id = "cfag12864b",
+       .type = FB_TYPE_PACKED_PIXELS,
+       .visual = FB_VISUAL_MONO10,
+       .xpanstep = 0,
+       .ypanstep = 0,
+       .ywrapstep = 0,
+       .line_length = CFAG12864B_WIDTH / 8,
+       .accel = FB_ACCEL_NONE,
+};
+
+static struct fb_var_screeninfo cfag12864bfb_var __initdata = {
+       .xres = CFAG12864B_WIDTH,
+       .yres = CFAG12864B_HEIGHT,
+       .xres_virtual = CFAG12864B_WIDTH,
+       .yres_virtual = CFAG12864B_HEIGHT,
+       .bits_per_pixel = 1,
+       .red = { 0, 1, 0 },
+       .green = { 0, 1, 0 },
+       .blue = { 0, 1, 0 },
+       .left_margin = 0,
+       .right_margin = 0,
+       .upper_margin = 0,
+       .lower_margin = 0,
+       .vmode = FB_VMODE_NONINTERLACED,
+};
+
+static int cfag12864bfb_mmap(struct fb_info *info, struct vm_area_struct *vma)
+{
+       return vm_insert_page(vma, vma->vm_start,
+               virt_to_page(cfag12864b_buffer));
+}
+
+static struct fb_ops cfag12864bfb_ops = {
+       .owner = THIS_MODULE,
+       .fb_fillrect = cfb_fillrect,
+       .fb_copyarea = cfb_copyarea,
+       .fb_imageblit = cfb_imageblit,
+       .fb_mmap = cfag12864bfb_mmap,
+};
+
+static int __init cfag12864bfb_probe(struct platform_device *device)
+{
+       int ret = -EINVAL;
+       struct fb_info *info = framebuffer_alloc(0, &device->dev);
+
+       if (!info)
+               goto none;
+
+       info->screen_base = (char __iomem *) cfag12864b_buffer;
+       info->screen_size = CFAG12864B_SIZE;
+       info->fbops = &cfag12864bfb_ops;
+       info->fix = cfag12864bfb_fix;
+       info->var = cfag12864bfb_var;
+       info->pseudo_palette = NULL;
+       info->par = NULL;
+       info->flags = FBINFO_FLAG_DEFAULT;
+
+       if (register_framebuffer(info) < 0)
+               goto fballoced;
+
+       platform_set_drvdata(device, info);
+
+       printk(KERN_INFO "fb%d: %s frame buffer device\n", info->node,
+               info->fix.id);
+
+       return 0;
+
+fballoced:
+       framebuffer_release(info);
+
+none:
+       return ret;
+}
+
+static int cfag12864bfb_remove(struct platform_device *device)
+{
+       struct fb_info *info = platform_get_drvdata(device);
+
+       if (info) {
+               unregister_framebuffer(info);
+               framebuffer_release(info);
+       }
+
+       return 0;
+}
+
+static struct platform_driver cfag12864bfb_driver = {
+       .probe  = cfag12864bfb_probe,
+       .remove = cfag12864bfb_remove,
+       .driver = {
+               .name   = CFAG12864BFB_NAME,
+       },
+};
+
+static struct platform_device *cfag12864bfb_device;
+
+static int __init cfag12864bfb_init(void)
+{
+       int ret;
+
+       if (cfag12864b_enable()) {
+               printk(KERN_ERR CFAG12864BFB_NAME ": ERROR: "
+                       "can't enable cfag12864b refreshing (being used)\n");
+               return -ENODEV;
+       }
+
+       ret = platform_driver_register(&cfag12864bfb_driver);
+
+       if (!ret) {
+               cfag12864bfb_device =
+                       platform_device_alloc(CFAG12864BFB_NAME, 0);
+
+               if (cfag12864bfb_device)
+                       ret = platform_device_add(cfag12864bfb_device);
+               else
+                       ret = -ENOMEM;
+
+               if (ret) {
+                       platform_device_put(cfag12864bfb_device);
+                       platform_driver_unregister(&cfag12864bfb_driver);
+               }
+       }
+
+       return ret;
+}
+
+static void __exit cfag12864bfb_exit(void)
+{
+       platform_device_unregister(cfag12864bfb_device);
+       platform_driver_unregister(&cfag12864bfb_driver);
+       cfag12864b_disable();
+}
+
+module_init(cfag12864bfb_init);
+module_exit(cfag12864bfb_exit);
+
+MODULE_LICENSE("GPL v2");
+MODULE_AUTHOR("Miguel Ojeda Sandonis <maxextreme@gmail.com>");
+MODULE_DESCRIPTION("cfag12864b LCD framebuffer driver");
diff --git a/drivers/auxdisplay/ks0108.c b/drivers/auxdisplay/ks0108.c
new file mode 100644 (file)
index 0000000..a637575
--- /dev/null
@@ -0,0 +1,166 @@
+/*
+ *    Filename: ks0108.c
+ *     Version: 0.1.0
+ * Description: ks0108 LCD Controller driver
+ *     License: GPLv2
+ *     Depends: parport
+ *
+ *      Author: Copyright (C) Miguel Ojeda Sandonis <maxextreme@gmail.com>
+ *        Date: 2006-10-31
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/delay.h>
+#include <linux/fs.h>
+#include <linux/io.h>
+#include <linux/parport.h>
+#include <linux/uaccess.h>
+#include <linux/ks0108.h>
+
+#define KS0108_NAME "ks0108"
+
+/*
+ * Module Parameters
+ */
+
+static unsigned int ks0108_port = CONFIG_KS0108_PORT;
+module_param(ks0108_port, uint, S_IRUGO);
+MODULE_PARM_DESC(ks0108_port, "Parallel port where the LCD is connected");
+
+static unsigned int ks0108_delay = CONFIG_KS0108_DELAY;
+module_param(ks0108_delay, uint, S_IRUGO);
+MODULE_PARM_DESC(ks0108_delay, "Delay between each control writing (microseconds)");
+
+/*
+ * Device
+ */
+
+static struct parport *ks0108_parport;
+static struct pardevice *ks0108_pardevice;
+
+/*
+ * ks0108 Exported Commands (don't lock)
+ *
+ *   You _should_ lock in the top driver: This functions _should not_
+ *   get race conditions in any way. Locking for each byte here would be
+ *   so slow and useless.
+ *
+ *   There are not bit definitions because they are not flags,
+ *   just arbitrary combinations defined by the documentation for each
+ *   function in the ks0108 LCD controller. If you want to know what means
+ *   a specific combination, look at the function's name.
+ *
+ *   The ks0108_writecontrol bits need to be reverted ^(0,1,3) because
+ *   the parallel port also revert them using a "not" logic gate.
+ */
+
+#define bit(n) (((unsigned char)1)<<(n))
+
+void ks0108_writedata(unsigned char byte)
+{
+       parport_write_data(ks0108_parport, byte);
+}
+
+void ks0108_writecontrol(unsigned char byte)
+{
+       udelay(ks0108_delay);
+       parport_write_control(ks0108_parport, byte ^ (bit(0) | bit(1) | bit(3)));
+}
+
+void ks0108_displaystate(unsigned char state)
+{
+       ks0108_writedata((state ? bit(0) : 0) | bit(1) | bit(2) | bit(3) | bit(4) | bit(5));
+}
+
+void ks0108_startline(unsigned char startline)
+{
+       ks0108_writedata(min(startline,(unsigned char)63) | bit(6) | bit(7));
+}
+
+void ks0108_address(unsigned char address)
+{
+       ks0108_writedata(min(address,(unsigned char)63) | bit(6));
+}
+
+void ks0108_page(unsigned char page)
+{
+       ks0108_writedata(min(page,(unsigned char)7) | bit(3) | bit(4) | bit(5) | bit(7));
+}
+
+EXPORT_SYMBOL_GPL(ks0108_writedata);
+EXPORT_SYMBOL_GPL(ks0108_writecontrol);
+EXPORT_SYMBOL_GPL(ks0108_displaystate);
+EXPORT_SYMBOL_GPL(ks0108_startline);
+EXPORT_SYMBOL_GPL(ks0108_address);
+EXPORT_SYMBOL_GPL(ks0108_page);
+
+/*
+ * Module Init & Exit
+ */
+
+static int __init ks0108_init(void)
+{
+       int result;
+       int ret = -EINVAL;
+
+       ks0108_parport = parport_find_base(ks0108_port);
+       if (ks0108_parport == NULL) {
+               printk(KERN_ERR KS0108_NAME ": ERROR: "
+                       "parport didn't find %i port\n", ks0108_port);
+               goto none;
+       }
+
+       ks0108_pardevice = parport_register_device(ks0108_parport, KS0108_NAME,
+               NULL, NULL, NULL, PARPORT_DEV_EXCL, NULL);
+       if (ks0108_pardevice == NULL) {
+               printk(KERN_ERR KS0108_NAME ": ERROR: "
+                       "parport didn't register new device\n");
+               goto none;
+       }
+
+       result = parport_claim(ks0108_pardevice);
+       if (result != 0) {
+               printk(KERN_ERR KS0108_NAME ": ERROR: "
+                       "can't claim %i parport, maybe in use\n", ks0108_port);
+               ret = result;
+               goto registered;
+       }
+
+       return 0;
+
+registered:
+       parport_unregister_device(ks0108_pardevice);
+
+none:
+       return ret;
+}
+
+static void __exit ks0108_exit(void)
+{
+       parport_release(ks0108_pardevice);
+       parport_unregister_device(ks0108_pardevice);
+}
+
+module_init(ks0108_init);
+module_exit(ks0108_exit);
+
+MODULE_LICENSE("GPL v2");
+MODULE_AUTHOR("Miguel Ojeda Sandonis <maxextreme@gmail.com>");
+MODULE_DESCRIPTION("ks0108 LCD Controller driver");
+
index 1429f3a2629e60003e575bb02c5dd6fe97470e3c..5d6312e3349062cee54d204163bb5407d300a1bb 100644 (file)
@@ -37,6 +37,18 @@ config DEBUG_DRIVER
 
          If you are unsure about this, say N here.
 
+config DEBUG_DEVRES
+       bool "Managed device resources verbose debug messages"
+       depends on DEBUG_KERNEL
+       help
+         This option enables kernel parameter devres.log. If set to
+         non-zero, devres debug messages are printed. Select this if
+         you are having a problem with devres or want to debug
+         resource management for a managed device. devres.log can be
+         switched on and off from sysfs node.
+
+         If you are unsure about this, Say N here.
+
 config SYS_HYPERVISOR
        bool
        default n
index 7bbb9eeda235efb5dd307eb1d5e89dfa552f550a..e9eb7382ac3ac26b9c0c0ccae636da25bf4e1fa0 100644 (file)
@@ -3,6 +3,7 @@
 obj-y                  := core.o sys.o bus.o dd.o \
                           driver.o class.o platform.o \
                           cpu.o firmware.o init.o map.o dmapool.o \
+                          dma-mapping.o devres.o \
                           attribute_container.o transport_class.o
 obj-y                  += power/
 obj-$(CONFIG_ISA)      += isa.o
index d26644a59537f5a708226652f7a82edc713ed216..de7e1442ce60e73c4ab73fa6359b6ce2cba9572e 100644 (file)
@@ -44,3 +44,4 @@ struct class_device_attribute *to_class_dev_attr(struct attribute *_attr)
 
 extern char *make_class_name(const char *name, struct kobject *kobj);
 
+extern void devres_release_all(struct device *dev);
index e13614241c9eeed951141d285bb5d8e041ded23c..a8ac34ba610716a4fc5c4193920a3d44a4697ccd 100644 (file)
@@ -428,6 +428,8 @@ void device_initialize(struct device *dev)
        INIT_LIST_HEAD(&dev->dma_pools);
        INIT_LIST_HEAD(&dev->node);
        init_MUTEX(&dev->sem);
+       spin_lock_init(&dev->devres_lock);
+       INIT_LIST_HEAD(&dev->devres_head);
        device_init_wakeup(dev, 0);
        set_dev_node(dev, -1);
 }
index b5bf243d9cd6a26afc47eabb2990cf2d4cf13884..6a48824e43ff6559ff386d4eb23c301e5293d753 100644 (file)
@@ -112,6 +112,7 @@ static int really_probe(void *void_data)
        atomic_inc(&probe_count);
        pr_debug("%s: Probing driver %s with device %s\n",
                 drv->bus->name, drv->name, dev->bus_id);
+       WARN_ON(!list_empty(&dev->devres_head));
 
        dev->driver = drv;
        if (driver_sysfs_add(dev)) {
@@ -137,6 +138,7 @@ static int really_probe(void *void_data)
        goto done;
 
 probe_failed:
+       devres_release_all(dev);
        driver_sysfs_remove(dev);
        dev->driver = NULL;
 
@@ -327,6 +329,7 @@ static void __device_release_driver(struct device * dev)
                        dev->bus->remove(dev);
                else if (drv->remove)
                        drv->remove(dev);
+               devres_release_all(dev);
                dev->driver = NULL;
                put_driver(drv);
        }
diff --git a/drivers/base/devres.c b/drivers/base/devres.c
new file mode 100644 (file)
index 0000000..e177c95
--- /dev/null
@@ -0,0 +1,644 @@
+/*
+ * drivers/base/devres.c - device resource management
+ *
+ * Copyright (c) 2006  SUSE Linux Products GmbH
+ * Copyright (c) 2006  Tejun Heo <teheo@suse.de>
+ *
+ * This file is released under the GPLv2.
+ */
+
+#include <linux/device.h>
+#include <linux/module.h>
+
+struct devres_node {
+       struct list_head                entry;
+       dr_release_t                    release;
+#ifdef CONFIG_DEBUG_DEVRES
+       const char                      *name;
+       size_t                          size;
+#endif
+};
+
+struct devres {
+       struct devres_node              node;
+       /* -- 3 pointers */
+       unsigned long long              data[]; /* guarantee ull alignment */
+};
+
+struct devres_group {
+       struct devres_node              node[2];
+       void                            *id;
+       int                             color;
+       /* -- 8 pointers */
+};
+
+#ifdef CONFIG_DEBUG_DEVRES
+static int log_devres = 0;
+module_param_named(log, log_devres, int, S_IRUGO | S_IWUSR);
+
+static void set_node_dbginfo(struct devres_node *node, const char *name,
+                            size_t size)
+{
+       node->name = name;
+       node->size = size;
+}
+
+static void devres_log(struct device *dev, struct devres_node *node,
+                      const char *op)
+{
+       if (unlikely(log_devres))
+               dev_printk(KERN_ERR, dev, "DEVRES %3s %p %s (%lu bytes)\n",
+                          op, node, node->name, (unsigned long)node->size);
+}
+#else /* CONFIG_DEBUG_DEVRES */
+#define set_node_dbginfo(node, n, s)   do {} while (0)
+#define devres_log(dev, node, op)      do {} while (0)
+#endif /* CONFIG_DEBUG_DEVRES */
+
+/*
+ * Release functions for devres group.  These callbacks are used only
+ * for identification.
+ */
+static void group_open_release(struct device *dev, void *res)
+{
+       /* noop */
+}
+
+static void group_close_release(struct device *dev, void *res)
+{
+       /* noop */
+}
+
+static struct devres_group * node_to_group(struct devres_node *node)
+{
+       if (node->release == &group_open_release)
+               return container_of(node, struct devres_group, node[0]);
+       if (node->release == &group_close_release)
+               return container_of(node, struct devres_group, node[1]);
+       return NULL;
+}
+
+static __always_inline struct devres * alloc_dr(dr_release_t release,
+                                               size_t size, gfp_t gfp)
+{
+       size_t tot_size = sizeof(struct devres) + size;
+       struct devres *dr;
+
+       dr = kmalloc_track_caller(tot_size, gfp);
+       if (unlikely(!dr))
+               return NULL;
+
+       memset(dr, 0, tot_size);
+       INIT_LIST_HEAD(&dr->node.entry);
+       dr->node.release = release;
+       return dr;
+}
+
+static void add_dr(struct device *dev, struct devres_node *node)
+{
+       devres_log(dev, node, "ADD");
+       BUG_ON(!list_empty(&node->entry));
+       list_add_tail(&node->entry, &dev->devres_head);
+}
+
+/**
+ * devres_alloc - Allocate device resource data
+ * @release: Release function devres will be associated with
+ * @size: Allocation size
+ * @gfp: Allocation flags
+ *
+ * allocate devres of @size bytes.  The allocated area is zeroed, then
+ * associated with @release.  The returned pointer can be passed to
+ * other devres_*() functions.
+ *
+ * RETURNS:
+ * Pointer to allocated devres on success, NULL on failure.
+ */
+#ifdef CONFIG_DEBUG_DEVRES
+void * __devres_alloc(dr_release_t release, size_t size, gfp_t gfp,
+                     const char *name)
+{
+       struct devres *dr;
+
+       dr = alloc_dr(release, size, gfp);
+       if (unlikely(!dr))
+               return NULL;
+       set_node_dbginfo(&dr->node, name, size);
+       return dr->data;
+}
+EXPORT_SYMBOL_GPL(__devres_alloc);
+#else
+void * devres_alloc(dr_release_t release, size_t size, gfp_t gfp)
+{
+       struct devres *dr;
+
+       dr = alloc_dr(release, size, gfp);
+       if (unlikely(!dr))
+               return NULL;
+       return dr->data;
+}
+EXPORT_SYMBOL_GPL(devres_alloc);
+#endif
+
+/**
+ * devres_free - Free device resource data
+ * @res: Pointer to devres data to free
+ *
+ * Free devres created with devres_alloc().
+ */
+void devres_free(void *res)
+{
+       if (res) {
+               struct devres *dr = container_of(res, struct devres, data);
+
+               BUG_ON(!list_empty(&dr->node.entry));
+               kfree(dr);
+       }
+}
+EXPORT_SYMBOL_GPL(devres_free);
+
+/**
+ * devres_add - Register device resource
+ * @dev: Device to add resource to
+ * @res: Resource to register
+ *
+ * Register devres @res to @dev.  @res should have been allocated
+ * using devres_alloc().  On driver detach, the associated release
+ * function will be invoked and devres will be freed automatically.
+ */
+void devres_add(struct device *dev, void *res)
+{
+       struct devres *dr = container_of(res, struct devres, data);
+       unsigned long flags;
+
+       spin_lock_irqsave(&dev->devres_lock, flags);
+       add_dr(dev, &dr->node);
+       spin_unlock_irqrestore(&dev->devres_lock, flags);
+}
+EXPORT_SYMBOL_GPL(devres_add);
+
+static struct devres *find_dr(struct device *dev, dr_release_t release,
+                             dr_match_t match, void *match_data)
+{
+       struct devres_node *node;
+
+       list_for_each_entry_reverse(node, &dev->devres_head, entry) {
+               struct devres *dr = container_of(node, struct devres, node);
+
+               if (node->release != release)
+                       continue;
+               if (match && !match(dev, dr->data, match_data))
+                       continue;
+               return dr;
+       }
+
+       return NULL;
+}
+
+/**
+ * devres_find - Find device resource
+ * @dev: Device to lookup resource from
+ * @release: Look for resources associated with this release function
+ * @match: Match function (optional)
+ * @match_data: Data for the match function
+ *
+ * Find the latest devres of @dev which is associated with @release
+ * and for which @match returns 1.  If @match is NULL, it's considered
+ * to match all.
+ *
+ * RETURNS:
+ * Pointer to found devres, NULL if not found.
+ */
+void * devres_find(struct device *dev, dr_release_t release,
+                  dr_match_t match, void *match_data)
+{
+       struct devres *dr;
+       unsigned long flags;
+
+       spin_lock_irqsave(&dev->devres_lock, flags);
+       dr = find_dr(dev, release, match, match_data);
+       spin_unlock_irqrestore(&dev->devres_lock, flags);
+
+       if (dr)
+               return dr->data;
+       return NULL;
+}
+EXPORT_SYMBOL_GPL(devres_find);
+
+/**
+ * devres_get - Find devres, if non-existent, add one atomically
+ * @dev: Device to lookup or add devres for
+ * @new_res: Pointer to new initialized devres to add if not found
+ * @match: Match function (optional)
+ * @match_data: Data for the match function
+ *
+ * Find the latest devres of @dev which has the same release function
+ * as @new_res and for which @match return 1.  If found, @new_res is
+ * freed; otherwise, @new_res is added atomically.
+ *
+ * RETURNS:
+ * Pointer to found or added devres.
+ */
+void * devres_get(struct device *dev, void *new_res,
+                 dr_match_t match, void *match_data)
+{
+       struct devres *new_dr = container_of(new_res, struct devres, data);
+       struct devres *dr;
+       unsigned long flags;
+
+       spin_lock_irqsave(&dev->devres_lock, flags);
+       dr = find_dr(dev, new_dr->node.release, match, match_data);
+       if (!dr) {
+               add_dr(dev, &new_dr->node);
+               dr = new_dr;
+               new_dr = NULL;
+       }
+       spin_unlock_irqrestore(&dev->devres_lock, flags);
+       devres_free(new_dr);
+
+       return dr->data;
+}
+EXPORT_SYMBOL_GPL(devres_get);
+
+/**
+ * devres_remove - Find a device resource and remove it
+ * @dev: Device to find resource from
+ * @release: Look for resources associated with this release function
+ * @match: Match function (optional)
+ * @match_data: Data for the match function
+ *
+ * Find the latest devres of @dev associated with @release and for
+ * which @match returns 1.  If @match is NULL, it's considered to
+ * match all.  If found, the resource is removed atomically and
+ * returned.
+ *
+ * RETURNS:
+ * Pointer to removed devres on success, NULL if not found.
+ */
+void * devres_remove(struct device *dev, dr_release_t release,
+                    dr_match_t match, void *match_data)
+{
+       struct devres *dr;
+       unsigned long flags;
+
+       spin_lock_irqsave(&dev->devres_lock, flags);
+       dr = find_dr(dev, release, match, match_data);
+       if (dr) {
+               list_del_init(&dr->node.entry);
+               devres_log(dev, &dr->node, "REM");
+       }
+       spin_unlock_irqrestore(&dev->devres_lock, flags);
+
+       if (dr)
+               return dr->data;
+       return NULL;
+}
+EXPORT_SYMBOL_GPL(devres_remove);
+
+/**
+ * devres_destroy - Find a device resource and destroy it
+ * @dev: Device to find resource from
+ * @release: Look for resources associated with this release function
+ * @match: Match function (optional)
+ * @match_data: Data for the match function
+ *
+ * Find the latest devres of @dev associated with @release and for
+ * which @match returns 1.  If @match is NULL, it's considered to
+ * match all.  If found, the resource is removed atomically and freed.
+ *
+ * RETURNS:
+ * 0 if devres is found and freed, -ENOENT if not found.
+ */
+int devres_destroy(struct device *dev, dr_release_t release,
+                  dr_match_t match, void *match_data)
+{
+       void *res;
+
+       res = devres_remove(dev, release, match, match_data);
+       if (unlikely(!res))
+               return -ENOENT;
+
+       devres_free(res);
+       return 0;
+}
+EXPORT_SYMBOL_GPL(devres_destroy);
+
+static int remove_nodes(struct device *dev,
+                       struct list_head *first, struct list_head *end,
+                       struct list_head *todo)
+{
+       int cnt = 0, nr_groups = 0;
+       struct list_head *cur;
+
+       /* First pass - move normal devres entries to @todo and clear
+        * devres_group colors.
+        */
+       cur = first;
+       while (cur != end) {
+               struct devres_node *node;
+               struct devres_group *grp;
+
+               node = list_entry(cur, struct devres_node, entry);
+               cur = cur->next;
+
+               grp = node_to_group(node);
+               if (grp) {
+                       /* clear color of group markers in the first pass */
+                       grp->color = 0;
+                       nr_groups++;
+               } else {
+                       /* regular devres entry */
+                       if (&node->entry == first)
+                               first = first->next;
+                       list_move_tail(&node->entry, todo);
+                       cnt++;
+               }
+       }
+
+       if (!nr_groups)
+               return cnt;
+
+       /* Second pass - Scan groups and color them.  A group gets
+        * color value of two iff the group is wholly contained in
+        * [cur, end).  That is, for a closed group, both opening and
+        * closing markers should be in the range, while just the
+        * opening marker is enough for an open group.
+        */
+       cur = first;
+       while (cur != end) {
+               struct devres_node *node;
+               struct devres_group *grp;
+
+               node = list_entry(cur, struct devres_node, entry);
+               cur = cur->next;
+
+               grp = node_to_group(node);
+               BUG_ON(!grp || list_empty(&grp->node[0].entry));
+
+               grp->color++;
+               if (list_empty(&grp->node[1].entry))
+                       grp->color++;
+
+               BUG_ON(grp->color <= 0 || grp->color > 2);
+               if (grp->color == 2) {
+                       /* No need to update cur or end.  The removed
+                        * nodes are always before both.
+                        */
+                       list_move_tail(&grp->node[0].entry, todo);
+                       list_del_init(&grp->node[1].entry);
+               }
+       }
+
+       return cnt;
+}
+
+static int release_nodes(struct device *dev, struct list_head *first,
+                        struct list_head *end, unsigned long flags)
+{
+       LIST_HEAD(todo);
+       int cnt;
+       struct devres *dr, *tmp;
+
+       cnt = remove_nodes(dev, first, end, &todo);
+
+       spin_unlock_irqrestore(&dev->devres_lock, flags);
+
+       /* Release.  Note that both devres and devres_group are
+        * handled as devres in the following loop.  This is safe.
+        */
+       list_for_each_entry_safe_reverse(dr, tmp, &todo, node.entry) {
+               devres_log(dev, &dr->node, "REL");
+               dr->node.release(dev, dr->data);
+               kfree(dr);
+       }
+
+       return cnt;
+}
+
+/**
+ * devres_release_all - Release all resources
+ * @dev: Device to release resources for
+ *
+ * Release all resources associated with @dev.  This function is
+ * called on driver detach.
+ */
+int devres_release_all(struct device *dev)
+{
+       unsigned long flags;
+
+       spin_lock_irqsave(&dev->devres_lock, flags);
+       return release_nodes(dev, dev->devres_head.next, &dev->devres_head,
+                            flags);
+}
+
+/**
+ * devres_open_group - Open a new devres group
+ * @dev: Device to open devres group for
+ * @id: Separator ID
+ * @gfp: Allocation flags
+ *
+ * Open a new devres group for @dev with @id.  For @id, using a
+ * pointer to an object which won't be used for another group is
+ * recommended.  If @id is NULL, address-wise unique ID is created.
+ *
+ * RETURNS:
+ * ID of the new group, NULL on failure.
+ */
+void * devres_open_group(struct device *dev, void *id, gfp_t gfp)
+{
+       struct devres_group *grp;
+       unsigned long flags;
+
+       grp = kmalloc(sizeof(*grp), gfp);
+       if (unlikely(!grp))
+               return NULL;
+
+       grp->node[0].release = &group_open_release;
+       grp->node[1].release = &group_close_release;
+       INIT_LIST_HEAD(&grp->node[0].entry);
+       INIT_LIST_HEAD(&grp->node[1].entry);
+       set_node_dbginfo(&grp->node[0], "grp<", 0);
+       set_node_dbginfo(&grp->node[1], "grp>", 0);
+       grp->id = grp;
+       if (id)
+               grp->id = id;
+
+       spin_lock_irqsave(&dev->devres_lock, flags);
+       add_dr(dev, &grp->node[0]);
+       spin_unlock_irqrestore(&dev->devres_lock, flags);
+       return grp->id;
+}
+EXPORT_SYMBOL_GPL(devres_open_group);
+
+/* Find devres group with ID @id.  If @id is NULL, look for the latest. */
+static struct devres_group * find_group(struct device *dev, void *id)
+{
+       struct devres_node *node;
+
+       list_for_each_entry_reverse(node, &dev->devres_head, entry) {
+               struct devres_group *grp;
+
+               if (node->release != &group_open_release)
+                       continue;
+
+               grp = container_of(node, struct devres_group, node[0]);
+
+               if (id) {
+                       if (grp->id == id)
+                               return grp;
+               } else if (list_empty(&grp->node[1].entry))
+                       return grp;
+       }
+
+       return NULL;
+}
+
+/**
+ * devres_close_group - Close a devres group
+ * @dev: Device to close devres group for
+ * @id: ID of target group, can be NULL
+ *
+ * Close the group identified by @id.  If @id is NULL, the latest open
+ * group is selected.
+ */
+void devres_close_group(struct device *dev, void *id)
+{
+       struct devres_group *grp;
+       unsigned long flags;
+
+       spin_lock_irqsave(&dev->devres_lock, flags);
+
+       grp = find_group(dev, id);
+       if (grp)
+               add_dr(dev, &grp->node[1]);
+       else
+               WARN_ON(1);
+
+       spin_unlock_irqrestore(&dev->devres_lock, flags);
+}
+EXPORT_SYMBOL_GPL(devres_close_group);
+
+/**
+ * devres_remove_group - Remove a devres group
+ * @dev: Device to remove group for
+ * @id: ID of target group, can be NULL
+ *
+ * Remove the group identified by @id.  If @id is NULL, the latest
+ * open group is selected.  Note that removing a group doesn't affect
+ * any other resources.
+ */
+void devres_remove_group(struct device *dev, void *id)
+{
+       struct devres_group *grp;
+       unsigned long flags;
+
+       spin_lock_irqsave(&dev->devres_lock, flags);
+
+       grp = find_group(dev, id);
+       if (grp) {
+               list_del_init(&grp->node[0].entry);
+               list_del_init(&grp->node[1].entry);
+               devres_log(dev, &grp->node[0], "REM");
+       } else
+               WARN_ON(1);
+
+       spin_unlock_irqrestore(&dev->devres_lock, flags);
+
+       kfree(grp);
+}
+EXPORT_SYMBOL_GPL(devres_remove_group);
+
+/**
+ * devres_release_group - Release resources in a devres group
+ * @dev: Device to release group for
+ * @id: ID of target group, can be NULL
+ *
+ * Release all resources in the group identified by @id.  If @id is
+ * NULL, the latest open group is selected.  The selected group and
+ * groups properly nested inside the selected group are removed.
+ *
+ * RETURNS:
+ * The number of released non-group resources.
+ */
+int devres_release_group(struct device *dev, void *id)
+{
+       struct devres_group *grp;
+       unsigned long flags;
+       int cnt = 0;
+
+       spin_lock_irqsave(&dev->devres_lock, flags);
+
+       grp = find_group(dev, id);
+       if (grp) {
+               struct list_head *first = &grp->node[0].entry;
+               struct list_head *end = &dev->devres_head;
+
+               if (!list_empty(&grp->node[1].entry))
+                       end = grp->node[1].entry.next;
+
+               cnt = release_nodes(dev, first, end, flags);
+       } else {
+               WARN_ON(1);
+               spin_unlock_irqrestore(&dev->devres_lock, flags);
+       }
+
+       return cnt;
+}
+EXPORT_SYMBOL_GPL(devres_release_group);
+
+/*
+ * Managed kzalloc/kfree
+ */
+static void devm_kzalloc_release(struct device *dev, void *res)
+{
+       /* noop */
+}
+
+static int devm_kzalloc_match(struct device *dev, void *res, void *data)
+{
+       return res == data;
+}
+
+/**
+ * devm_kzalloc - Managed kzalloc
+ * @dev: Device to allocate memory for
+ * @size: Allocation size
+ * @gfp: Allocation gfp flags
+ *
+ * Managed kzalloc.  Memory allocated with this function is
+ * automatically freed on driver detach.  Like all other devres
+ * resources, guaranteed alignment is unsigned long long.
+ *
+ * RETURNS:
+ * Pointer to allocated memory on success, NULL on failure.
+ */
+void * devm_kzalloc(struct device *dev, size_t size, gfp_t gfp)
+{
+       struct devres *dr;
+
+       /* use raw alloc_dr for kmalloc caller tracing */
+       dr = alloc_dr(devm_kzalloc_release, size, gfp);
+       if (unlikely(!dr))
+               return NULL;
+
+       set_node_dbginfo(&dr->node, "devm_kzalloc_release", size);
+       devres_add(dev, dr->data);
+       return dr->data;
+}
+EXPORT_SYMBOL_GPL(devm_kzalloc);
+
+/**
+ * devm_kfree - Managed kfree
+ * @dev: Device this memory belongs to
+ * @p: Memory to free
+ *
+ * Free memory allocated with dev_kzalloc().
+ */
+void devm_kfree(struct device *dev, void *p)
+{
+       int rc;
+
+       rc = devres_destroy(dev, devm_kzalloc_release, devm_kzalloc_match, p);
+       WARN_ON(rc);
+}
+EXPORT_SYMBOL_GPL(devm_kfree);
diff --git a/drivers/base/dma-mapping.c b/drivers/base/dma-mapping.c
new file mode 100644 (file)
index 0000000..ca9186f
--- /dev/null
@@ -0,0 +1,218 @@
+/*
+ * drivers/base/dma-mapping.c - arch-independent dma-mapping routines
+ *
+ * Copyright (c) 2006  SUSE Linux Products GmbH
+ * Copyright (c) 2006  Tejun Heo <teheo@suse.de>
+ *
+ * This file is released under the GPLv2.
+ */
+
+#include <linux/dma-mapping.h>
+
+/*
+ * Managed DMA API
+ */
+struct dma_devres {
+       size_t          size;
+       void            *vaddr;
+       dma_addr_t      dma_handle;
+};
+
+static void dmam_coherent_release(struct device *dev, void *res)
+{
+       struct dma_devres *this = res;
+
+       dma_free_coherent(dev, this->size, this->vaddr, this->dma_handle);
+}
+
+static void dmam_noncoherent_release(struct device *dev, void *res)
+{
+       struct dma_devres *this = res;
+
+       dma_free_noncoherent(dev, this->size, this->vaddr, this->dma_handle);
+}
+
+static int dmam_match(struct device *dev, void *res, void *match_data)
+{
+       struct dma_devres *this = res, *match = match_data;
+
+       if (this->vaddr == match->vaddr) {
+               WARN_ON(this->size != match->size ||
+                       this->dma_handle != match->dma_handle);
+               return 1;
+       }
+       return 0;
+}
+
+/**
+ * dmam_alloc_coherent - Managed dma_alloc_coherent()
+ * @dev: Device to allocate coherent memory for
+ * @size: Size of allocation
+ * @dma_handle: Out argument for allocated DMA handle
+ * @gfp: Allocation flags
+ *
+ * Managed dma_alloc_coherent().  Memory allocated using this function
+ * will be automatically released on driver detach.
+ *
+ * RETURNS:
+ * Pointer to allocated memory on success, NULL on failure.
+ */
+void * dmam_alloc_coherent(struct device *dev, size_t size,
+                          dma_addr_t *dma_handle, gfp_t gfp)
+{
+       struct dma_devres *dr;
+       void *vaddr;
+
+       dr = devres_alloc(dmam_coherent_release, sizeof(*dr), gfp);
+       if (!dr)
+               return NULL;
+
+       vaddr = dma_alloc_coherent(dev, size, dma_handle, gfp);
+       if (!vaddr) {
+               devres_free(dr);
+               return NULL;
+       }
+
+       dr->vaddr = vaddr;
+       dr->dma_handle = *dma_handle;
+       dr->size = size;
+
+       devres_add(dev, dr);
+
+       return vaddr;
+}
+EXPORT_SYMBOL(dmam_alloc_coherent);
+
+/**
+ * dmam_free_coherent - Managed dma_free_coherent()
+ * @dev: Device to free coherent memory for
+ * @size: Size of allocation
+ * @vaddr: Virtual address of the memory to free
+ * @dma_handle: DMA handle of the memory to free
+ *
+ * Managed dma_free_coherent().
+ */
+void dmam_free_coherent(struct device *dev, size_t size, void *vaddr,
+                       dma_addr_t dma_handle)
+{
+       struct dma_devres match_data = { size, vaddr, dma_handle };
+
+       dma_free_coherent(dev, size, vaddr, dma_handle);
+       WARN_ON(devres_destroy(dev, dmam_coherent_release, dmam_match,
+                              &match_data));
+}
+EXPORT_SYMBOL(dmam_free_coherent);
+
+/**
+ * dmam_alloc_non_coherent - Managed dma_alloc_non_coherent()
+ * @dev: Device to allocate non_coherent memory for
+ * @size: Size of allocation
+ * @dma_handle: Out argument for allocated DMA handle
+ * @gfp: Allocation flags
+ *
+ * Managed dma_alloc_non_coherent().  Memory allocated using this
+ * function will be automatically released on driver detach.
+ *
+ * RETURNS:
+ * Pointer to allocated memory on success, NULL on failure.
+ */
+void *dmam_alloc_noncoherent(struct device *dev, size_t size,
+                            dma_addr_t *dma_handle, gfp_t gfp)
+{
+       struct dma_devres *dr;
+       void *vaddr;
+
+       dr = devres_alloc(dmam_noncoherent_release, sizeof(*dr), gfp);
+       if (!dr)
+               return NULL;
+
+       vaddr = dma_alloc_noncoherent(dev, size, dma_handle, gfp);
+       if (!vaddr) {
+               devres_free(dr);
+               return NULL;
+       }
+
+       dr->vaddr = vaddr;
+       dr->dma_handle = *dma_handle;
+       dr->size = size;
+
+       devres_add(dev, dr);
+
+       return vaddr;
+}
+EXPORT_SYMBOL(dmam_alloc_noncoherent);
+
+/**
+ * dmam_free_coherent - Managed dma_free_noncoherent()
+ * @dev: Device to free noncoherent memory for
+ * @size: Size of allocation
+ * @vaddr: Virtual address of the memory to free
+ * @dma_handle: DMA handle of the memory to free
+ *
+ * Managed dma_free_noncoherent().
+ */
+void dmam_free_noncoherent(struct device *dev, size_t size, void *vaddr,
+                          dma_addr_t dma_handle)
+{
+       struct dma_devres match_data = { size, vaddr, dma_handle };
+
+       dma_free_noncoherent(dev, size, vaddr, dma_handle);
+       WARN_ON(!devres_destroy(dev, dmam_noncoherent_release, dmam_match,
+                               &match_data));
+}
+EXPORT_SYMBOL(dmam_free_noncoherent);
+
+#ifdef ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY
+
+static void dmam_coherent_decl_release(struct device *dev, void *res)
+{
+       dma_release_declared_memory(dev);
+}
+
+/**
+ * dmam_declare_coherent_memory - Managed dma_declare_coherent_memory()
+ * @dev: Device to declare coherent memory for
+ * @bus_addr: Bus address of coherent memory to be declared
+ * @device_addr: Device address of coherent memory to be declared
+ * @size: Size of coherent memory to be declared
+ * @flags: Flags
+ *
+ * Managed dma_declare_coherent_memory().
+ *
+ * RETURNS:
+ * 0 on success, -errno on failure.
+ */
+int dmam_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
+                                dma_addr_t device_addr, size_t size, int flags)
+{
+       void *res;
+       int rc;
+
+       res = devres_alloc(dmam_coherent_decl_release, 0, GFP_KERNEL);
+       if (!res)
+               return -ENOMEM;
+
+       rc = dma_declare_coherent_memory(dev, bus_addr, device_addr, size,
+                                        flags);
+       if (rc == 0)
+               devres_add(dev, res);
+       else
+               devres_free(res);
+
+       return rc;
+}
+EXPORT_SYMBOL(dmam_declare_coherent_memory);
+
+/**
+ * dmam_release_declared_memory - Managed dma_release_declared_memory().
+ * @dev: Device to release declared coherent memory for
+ *
+ * Managed dmam_release_declared_memory().
+ */
+void dmam_release_declared_memory(struct device *dev)
+{
+       WARN_ON(devres_destroy(dev, dmam_coherent_decl_release, NULL, NULL));
+}
+EXPORT_SYMBOL(dmam_release_declared_memory);
+
+#endif
index f95d502772740d9fa653379f185e002742d9abf4..cd467c9f33b35e760e20759284bf35d0839e94f2 100644 (file)
@@ -415,8 +415,67 @@ dma_pool_free (struct dma_pool *pool, void *vaddr, dma_addr_t dma)
        spin_unlock_irqrestore (&pool->lock, flags);
 }
 
+/*
+ * Managed DMA pool
+ */
+static void dmam_pool_release(struct device *dev, void *res)
+{
+       struct dma_pool *pool = *(struct dma_pool **)res;
+
+       dma_pool_destroy(pool);
+}
+
+static int dmam_pool_match(struct device *dev, void *res, void *match_data)
+{
+       return *(struct dma_pool **)res == match_data;
+}
+
+/**
+ * dmam_pool_create - Managed dma_pool_create()
+ * @name: name of pool, for diagnostics
+ * @dev: device that will be doing the DMA
+ * @size: size of the blocks in this pool.
+ * @align: alignment requirement for blocks; must be a power of two
+ * @allocation: returned blocks won't cross this boundary (or zero)
+ *
+ * Managed dma_pool_create().  DMA pool created with this function is
+ * automatically destroyed on driver detach.
+ */
+struct dma_pool *dmam_pool_create(const char *name, struct device *dev,
+                                 size_t size, size_t align, size_t allocation)
+{
+       struct dma_pool **ptr, *pool;
+
+       ptr = devres_alloc(dmam_pool_release, sizeof(*ptr), GFP_KERNEL);
+       if (!ptr)
+               return NULL;
+
+       pool = *ptr = dma_pool_create(name, dev, size, align, allocation);
+       if (pool)
+               devres_add(dev, ptr);
+       else
+               devres_free(ptr);
+
+       return pool;
+}
+
+/**
+ * dmam_pool_destroy - Managed dma_pool_destroy()
+ * @pool: dma pool that will be destroyed
+ *
+ * Managed dma_pool_destroy().
+ */
+void dmam_pool_destroy(struct dma_pool *pool)
+{
+       struct device *dev = pool->dev;
+
+       dma_pool_destroy(pool);
+       WARN_ON(devres_destroy(dev, dmam_pool_release, dmam_pool_match, pool));
+}
 
 EXPORT_SYMBOL (dma_pool_create);
 EXPORT_SYMBOL (dma_pool_destroy);
 EXPORT_SYMBOL (dma_pool_alloc);
 EXPORT_SYMBOL (dma_pool_free);
+EXPORT_SYMBOL (dmam_pool_create);
+EXPORT_SYMBOL (dmam_pool_destroy);
index 001e6f6b9c1bf085130f3f286b2a45d1116abf62..475e33f76e0d3cefa8690e56ad046c17574c1231 100644 (file)
@@ -40,13 +40,8 @@ static ssize_t node_read_meminfo(struct sys_device * dev, char * buf)
        int n;
        int nid = dev->id;
        struct sysinfo i;
-       unsigned long inactive;
-       unsigned long active;
-       unsigned long free;
 
        si_meminfo_node(&i, nid);
-       __get_zone_counts(&active, &inactive, &free, NODE_DATA(nid));
-
 
        n = sprintf(buf, "\n"
                       "Node %d MemTotal:     %8lu kB\n"
@@ -74,8 +69,8 @@ static ssize_t node_read_meminfo(struct sys_device * dev, char * buf)
                       nid, K(i.totalram),
                       nid, K(i.freeram),
                       nid, K(i.totalram - i.freeram),
-                      nid, K(active),
-                      nid, K(inactive),
+                      nid, node_page_state(nid, NR_ACTIVE),
+                      nid, node_page_state(nid, NR_INACTIVE),
 #ifdef CONFIG_HIGHMEM
                       nid, K(i.totalhigh),
                       nid, K(i.freehigh),
index 8d81a3a64c078bb4d2523ac51c2ef6ad6c10e7dc..6ad28dfb146908ec490b1c3657e70dcca75604b8 100644 (file)
@@ -177,7 +177,7 @@ static void DAC960_AnnounceDriver(DAC960_Controller_T *Controller)
   DAC960_Failure prints a standardized error message, and then returns false.
 */
 
-static boolean DAC960_Failure(DAC960_Controller_T *Controller,
+static bool DAC960_Failure(DAC960_Controller_T *Controller,
                              unsigned char *ErrorMessage)
 {
   DAC960_Error("While configuring DAC960 PCI RAID Controller at\n",
@@ -206,7 +206,7 @@ static boolean DAC960_Failure(DAC960_Controller_T *Controller,
   that are passed in.
  */
 
-static boolean init_dma_loaf(struct pci_dev *dev, struct dma_loaf *loaf,
+static bool init_dma_loaf(struct pci_dev *dev, struct dma_loaf *loaf,
                                                                 size_t len)
 {
        void *cpu_addr;
@@ -250,7 +250,7 @@ static void free_dma_loaf(struct pci_dev *dev, struct dma_loaf *loaf_handle)
   failure.
 */
 
-static boolean DAC960_CreateAuxiliaryStructures(DAC960_Controller_T *Controller)
+static bool DAC960_CreateAuxiliaryStructures(DAC960_Controller_T *Controller)
 {
   int CommandAllocationLength, CommandAllocationGroupSize;
   int CommandsRemaining = 0, CommandIdentifier, CommandGroupByteCount;
@@ -790,7 +790,7 @@ static void DAC960_ExecuteCommand(DAC960_Command_T *Command)
   on failure.
 */
 
-static boolean DAC960_V1_ExecuteType3(DAC960_Controller_T *Controller,
+static bool DAC960_V1_ExecuteType3(DAC960_Controller_T *Controller,
                                      DAC960_V1_CommandOpcode_T CommandOpcode,
                                      dma_addr_t DataDMA)
 {
@@ -814,7 +814,7 @@ static boolean DAC960_V1_ExecuteType3(DAC960_Controller_T *Controller,
   on failure.
 */
 
-static boolean DAC960_V1_ExecuteType3B(DAC960_Controller_T *Controller,
+static bool DAC960_V1_ExecuteType3B(DAC960_Controller_T *Controller,
                                       DAC960_V1_CommandOpcode_T CommandOpcode,
                                       unsigned char CommandOpcode2,
                                       dma_addr_t DataDMA)
@@ -840,7 +840,7 @@ static boolean DAC960_V1_ExecuteType3B(DAC960_Controller_T *Controller,
   on failure.
 */
 
-static boolean DAC960_V1_ExecuteType3D(DAC960_Controller_T *Controller,
+static bool DAC960_V1_ExecuteType3D(DAC960_Controller_T *Controller,
                                       DAC960_V1_CommandOpcode_T CommandOpcode,
                                       unsigned char Channel,
                                       unsigned char TargetID,
@@ -870,7 +870,7 @@ static boolean DAC960_V1_ExecuteType3D(DAC960_Controller_T *Controller,
   Return data in The controller's HealthStatusBuffer, which is dma-able memory
 */
 
-static boolean DAC960_V2_GeneralInfo(DAC960_Controller_T *Controller)
+static bool DAC960_V2_GeneralInfo(DAC960_Controller_T *Controller)
 {
   DAC960_Command_T *Command = DAC960_AllocateCommand(Controller);
   DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox;
@@ -908,7 +908,7 @@ static boolean DAC960_V2_GeneralInfo(DAC960_Controller_T *Controller)
   memory buffer.
 */
 
-static boolean DAC960_V2_NewControllerInfo(DAC960_Controller_T *Controller)
+static bool DAC960_V2_NewControllerInfo(DAC960_Controller_T *Controller)
 {
   DAC960_Command_T *Command = DAC960_AllocateCommand(Controller);
   DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox;
@@ -946,7 +946,7 @@ static boolean DAC960_V2_NewControllerInfo(DAC960_Controller_T *Controller)
   Data is returned in the controller's V2.NewLogicalDeviceInformation
 */
 
-static boolean DAC960_V2_NewLogicalDeviceInfo(DAC960_Controller_T *Controller,
+static bool DAC960_V2_NewLogicalDeviceInfo(DAC960_Controller_T *Controller,
                                           unsigned short LogicalDeviceNumber)
 {
   DAC960_Command_T *Command = DAC960_AllocateCommand(Controller);
@@ -997,7 +997,7 @@ static boolean DAC960_V2_NewLogicalDeviceInfo(DAC960_Controller_T *Controller,
 
 */
 
-static boolean DAC960_V2_NewPhysicalDeviceInfo(DAC960_Controller_T *Controller,
+static bool DAC960_V2_NewPhysicalDeviceInfo(DAC960_Controller_T *Controller,
                                            unsigned char Channel,
                                            unsigned char TargetID,
                                            unsigned char LogicalUnit)
@@ -1082,7 +1082,7 @@ static void DAC960_V2_ConstructNewUnitSerialNumber(
   memory buffer.
 */
 
-static boolean DAC960_V2_NewInquiryUnitSerialNumber(DAC960_Controller_T *Controller,
+static bool DAC960_V2_NewInquiryUnitSerialNumber(DAC960_Controller_T *Controller,
                        int Channel, int TargetID, int LogicalUnit)
 {
       DAC960_Command_T *Command;
@@ -1110,7 +1110,7 @@ static boolean DAC960_V2_NewInquiryUnitSerialNumber(DAC960_Controller_T *Control
   success and false on failure.
 */
 
-static boolean DAC960_V2_DeviceOperation(DAC960_Controller_T *Controller,
+static bool DAC960_V2_DeviceOperation(DAC960_Controller_T *Controller,
                                         DAC960_V2_IOCTL_Opcode_T IOCTL_Opcode,
                                         DAC960_V2_OperationDevice_T
                                           OperationDevice)
@@ -1142,7 +1142,7 @@ static boolean DAC960_V2_DeviceOperation(DAC960_Controller_T *Controller,
   other dma mapped memory.
 */
 
-static boolean DAC960_V1_EnableMemoryMailboxInterface(DAC960_Controller_T
+static bool DAC960_V1_EnableMemoryMailboxInterface(DAC960_Controller_T
                                                      *Controller)
 {
   void __iomem *ControllerBaseAddress = Controller->BaseAddress;
@@ -1348,7 +1348,7 @@ skip_mailboxes:
   the structures that are contained in that region.
 */
 
-static boolean DAC960_V2_EnableMemoryMailboxInterface(DAC960_Controller_T
+static bool DAC960_V2_EnableMemoryMailboxInterface(DAC960_Controller_T
                                                      *Controller)
 {
   void __iomem *ControllerBaseAddress = Controller->BaseAddress;
@@ -1526,7 +1526,7 @@ static boolean DAC960_V2_EnableMemoryMailboxInterface(DAC960_Controller_T
   from DAC960 V1 Firmware Controllers and initializes the Controller structure.
 */
 
-static boolean DAC960_V1_ReadControllerConfiguration(DAC960_Controller_T
+static bool DAC960_V1_ReadControllerConfiguration(DAC960_Controller_T
                                                     *Controller)
 {
   DAC960_V1_Enquiry2_T *Enquiry2;
@@ -1767,7 +1767,7 @@ static boolean DAC960_V1_ReadControllerConfiguration(DAC960_Controller_T
   from DAC960 V2 Firmware Controllers and initializes the Controller structure.
 */
 
-static boolean DAC960_V2_ReadControllerConfiguration(DAC960_Controller_T
+static bool DAC960_V2_ReadControllerConfiguration(DAC960_Controller_T
                                                     *Controller)
 {
   DAC960_V2_ControllerInfo_T *ControllerInfo =
@@ -1898,7 +1898,7 @@ static boolean DAC960_V2_ReadControllerConfiguration(DAC960_Controller_T
   for Controller.
 */
 
-static boolean DAC960_ReportControllerConfiguration(DAC960_Controller_T
+static bool DAC960_ReportControllerConfiguration(DAC960_Controller_T
                                                    *Controller)
 {
   DAC960_Info("Configuring Mylex %s PCI RAID Controller\n",
@@ -1947,7 +1947,7 @@ static boolean DAC960_ReportControllerConfiguration(DAC960_Controller_T
   Controller.
 */
 
-static boolean DAC960_V1_ReadDeviceConfiguration(DAC960_Controller_T
+static bool DAC960_V1_ReadDeviceConfiguration(DAC960_Controller_T
                                                 *Controller)
 {
   struct dma_loaf local_dma;
@@ -2095,7 +2095,7 @@ static boolean DAC960_V1_ReadDeviceConfiguration(DAC960_Controller_T
   device connected to Controller.
 */
 
-static boolean DAC960_V2_ReadDeviceConfiguration(DAC960_Controller_T
+static bool DAC960_V2_ReadDeviceConfiguration(DAC960_Controller_T
                                                 *Controller)
 {
   unsigned char Channel = 0, TargetID = 0, LogicalUnit = 0;
@@ -2219,7 +2219,7 @@ static void DAC960_SanitizeInquiryData(DAC960_SCSI_Inquiry_T
   Information for DAC960 V1 Firmware Controllers.
 */
 
-static boolean DAC960_V1_ReportDeviceConfiguration(DAC960_Controller_T
+static bool DAC960_V1_ReportDeviceConfiguration(DAC960_Controller_T
                                                   *Controller)
 {
   int LogicalDriveNumber, Channel, TargetID;
@@ -2316,7 +2316,7 @@ static boolean DAC960_V1_ReportDeviceConfiguration(DAC960_Controller_T
   Information for DAC960 V2 Firmware Controllers.
 */
 
-static boolean DAC960_V2_ReportDeviceConfiguration(DAC960_Controller_T
+static bool DAC960_V2_ReportDeviceConfiguration(DAC960_Controller_T
                                                   *Controller)
 {
   int PhysicalDeviceIndex, LogicalDriveNumber;
@@ -2501,7 +2501,7 @@ static boolean DAC960_V2_ReportDeviceConfiguration(DAC960_Controller_T
   associated with Controller.
 */
 
-static boolean DAC960_RegisterBlockDevice(DAC960_Controller_T *Controller)
+static bool DAC960_RegisterBlockDevice(DAC960_Controller_T *Controller)
 {
   int MajorNumber = DAC960_MAJOR + Controller->ControllerNumber;
   int n;
@@ -2582,7 +2582,7 @@ static void DAC960_ComputeGenericDiskInfo(DAC960_Controller_T *Controller)
   It returns true for fatal errors and false otherwise.
 */
 
-static boolean DAC960_ReportErrorStatus(DAC960_Controller_T *Controller,
+static bool DAC960_ReportErrorStatus(DAC960_Controller_T *Controller,
                                        unsigned char ErrorStatus,
                                        unsigned char Parameter0,
                                        unsigned char Parameter1)
@@ -3048,7 +3048,7 @@ Failure:
   DAC960_InitializeController initializes Controller.
 */
 
-static boolean 
+static bool 
 DAC960_InitializeController(DAC960_Controller_T *Controller)
 {
   if (DAC960_ReadControllerConfiguration(Controller) &&
@@ -3445,8 +3445,8 @@ static void DAC960_RequestFunction(struct request_queue *RequestQueue)
   individual Buffer.
 */
 
-static inline boolean DAC960_ProcessCompletedRequest(DAC960_Command_T *Command,
-                                                boolean SuccessfulIO)
+static inline bool DAC960_ProcessCompletedRequest(DAC960_Command_T *Command,
+                                                bool SuccessfulIO)
 {
        struct request *Request = Command->Request;
        int UpToDate;
@@ -3572,7 +3572,7 @@ static void DAC960_V1_ProcessCompletedCommand(DAC960_Command_T *Command)
   else if (CommandType == DAC960_ReadRetryCommand ||
           CommandType == DAC960_WriteRetryCommand)
     {
-      boolean normal_completion;
+      bool normal_completion;
 #ifdef FORCE_RETRY_FAILURE_DEBUG
       static int retry_count = 1;
 #endif
@@ -4659,7 +4659,7 @@ static void DAC960_V2_ProcessCompletedCommand(DAC960_Command_T *Command)
   else if (CommandType == DAC960_ReadRetryCommand ||
           CommandType == DAC960_WriteRetryCommand)
     {
-      boolean normal_completion;
+      bool normal_completion;
 
 #ifdef FORCE_RETRY_FAILURE_DEBUG
       static int retry_count = 1;
@@ -5632,7 +5632,7 @@ static void DAC960_MonitoringTimerFunction(unsigned long TimerData)
        &Controller->V2.ControllerInformation;
       unsigned int StatusChangeCounter =
        Controller->V2.HealthStatusBuffer->StatusChangeCounter;
-      boolean ForceMonitoringCommand = false;
+      bool ForceMonitoringCommand = false;
       if (time_after(jiffies, Controller->SecondaryMonitoringTime
          + DAC960_SecondaryMonitoringInterval))
        {
@@ -5696,7 +5696,7 @@ static void DAC960_MonitoringTimerFunction(unsigned long TimerData)
   necessary.  It returns true if there is enough room and false otherwise.
 */
 
-static boolean DAC960_CheckStatusBuffer(DAC960_Controller_T *Controller,
+static bool DAC960_CheckStatusBuffer(DAC960_Controller_T *Controller,
                                        unsigned int ByteCount)
 {
   unsigned char *NewStatusBuffer;
@@ -5744,7 +5744,7 @@ static void DAC960_Message(DAC960_MessageLevel_T MessageLevel,
                           ...)
 {
   static unsigned char Buffer[DAC960_LineBufferSize];
-  static boolean BeginningOfLine = true;
+  static bool BeginningOfLine = true;
   va_list Arguments;
   int Length = 0;
   va_start(Arguments, Controller);
@@ -5837,7 +5837,7 @@ static void DAC960_Message(DAC960_MessageLevel_T MessageLevel,
   Channel and TargetID and returns true on success and false on failure.
 */
 
-static boolean DAC960_ParsePhysicalDevice(DAC960_Controller_T *Controller,
+static bool DAC960_ParsePhysicalDevice(DAC960_Controller_T *Controller,
                                          char *UserCommandString,
                                          unsigned char *Channel,
                                          unsigned char *TargetID)
@@ -5870,7 +5870,7 @@ static boolean DAC960_ParsePhysicalDevice(DAC960_Controller_T *Controller,
   returns true on success and false on failure.
 */
 
-static boolean DAC960_ParseLogicalDrive(DAC960_Controller_T *Controller,
+static bool DAC960_ParseLogicalDrive(DAC960_Controller_T *Controller,
                                        char *UserCommandString,
                                        unsigned char *LogicalDriveNumber)
 {
@@ -5951,7 +5951,7 @@ static void DAC960_V1_SetDeviceState(DAC960_Controller_T *Controller,
   Controllers.
 */
 
-static boolean DAC960_V1_ExecuteUserCommand(DAC960_Controller_T *Controller,
+static bool DAC960_V1_ExecuteUserCommand(DAC960_Controller_T *Controller,
                                            unsigned char *UserCommand)
 {
   DAC960_Command_T *Command;
@@ -6166,7 +6166,7 @@ failure:
   on failure.
 */
 
-static boolean DAC960_V2_TranslatePhysicalDevice(DAC960_Command_T *Command,
+static bool DAC960_V2_TranslatePhysicalDevice(DAC960_Command_T *Command,
                                                 unsigned char Channel,
                                                 unsigned char TargetID,
                                                 unsigned short
@@ -6213,7 +6213,7 @@ static boolean DAC960_V2_TranslatePhysicalDevice(DAC960_Command_T *Command,
   Controllers.
 */
 
-static boolean DAC960_V2_ExecuteUserCommand(DAC960_Controller_T *Controller,
+static bool DAC960_V2_ExecuteUserCommand(DAC960_Controller_T *Controller,
                                            unsigned char *UserCommand)
 {
   DAC960_Command_T *Command;
index 6148073532b2951ec9172f6ea0fc069fec58baa0..f5e2436c39aa08936494f5867ef1e30b70796490 100644 (file)
 #define DAC690_V1_PciDmaMask   0xffffffff
 #define DAC690_V2_PciDmaMask   0xffffffffffffffffULL
 
-/*
-  Define a Boolean data type.
-*/
-
-typedef bool boolean;
-
-
 /*
   Define a 32/64 bit I/O Address data type.
 */
@@ -139,25 +132,25 @@ typedef struct DAC960_SCSI_Inquiry
   unsigned char PeripheralDeviceType:5;                        /* Byte 0 Bits 0-4 */
   unsigned char PeripheralQualifier:3;                 /* Byte 0 Bits 5-7 */
   unsigned char DeviceTypeModifier:7;                  /* Byte 1 Bits 0-6 */
-  boolean RMB:1;                                       /* Byte 1 Bit 7 */
+  bool RMB:1;                                          /* Byte 1 Bit 7 */
   unsigned char ANSI_ApprovedVersion:3;                        /* Byte 2 Bits 0-2 */
   unsigned char ECMA_Version:3;                                /* Byte 2 Bits 3-5 */
   unsigned char ISO_Version:2;                         /* Byte 2 Bits 6-7 */
   unsigned char ResponseDataFormat:4;                  /* Byte 3 Bits 0-3 */
   unsigned char :2;                                    /* Byte 3 Bits 4-5 */
-  boolean TrmIOP:1;                                    /* Byte 3 Bit 6 */
-  boolean AENC:1;                                      /* Byte 3 Bit 7 */
+  bool TrmIOP:1;                                       /* Byte 3 Bit 6 */
+  bool AENC:1;                                         /* Byte 3 Bit 7 */
   unsigned char AdditionalLength;                      /* Byte 4 */
   unsigned char :8;                                    /* Byte 5 */
   unsigned char :8;                                    /* Byte 6 */
-  boolean SftRe:1;                                     /* Byte 7 Bit 0 */
-  boolean CmdQue:1;                                    /* Byte 7 Bit 1 */
-  boolean :1;                                          /* Byte 7 Bit 2 */
-  boolean Linked:1;                                    /* Byte 7 Bit 3 */
-  boolean Sync:1;                                      /* Byte 7 Bit 4 */
-  boolean WBus16:1;                                    /* Byte 7 Bit 5 */
-  boolean WBus32:1;                                    /* Byte 7 Bit 6 */
-  boolean RelAdr:1;                                    /* Byte 7 Bit 7 */
+  bool SftRe:1;                                                /* Byte 7 Bit 0 */
+  bool CmdQue:1;                                       /* Byte 7 Bit 1 */
+  bool :1;                                             /* Byte 7 Bit 2 */
+  bool Linked:1;                                       /* Byte 7 Bit 3 */
+  bool Sync:1;                                         /* Byte 7 Bit 4 */
+  bool WBus16:1;                                       /* Byte 7 Bit 5 */
+  bool WBus32:1;                                       /* Byte 7 Bit 6 */
+  bool RelAdr:1;                                       /* Byte 7 Bit 7 */
   unsigned char VendorIdentification[8];               /* Bytes 8-15 */
   unsigned char ProductIdentification[16];             /* Bytes 16-31 */
   unsigned char ProductRevisionLevel[4];               /* Bytes 32-35 */
@@ -215,13 +208,13 @@ DAC960_SCSI_RequestSenseKey_T;
 typedef struct DAC960_SCSI_RequestSense
 {
   unsigned char ErrorCode:7;                           /* Byte 0 Bits 0-6 */
-  boolean Valid:1;                                     /* Byte 0 Bit 7 */
+  bool Valid:1;                                                /* Byte 0 Bit 7 */
   unsigned char SegmentNumber;                         /* Byte 1 */
   DAC960_SCSI_RequestSenseKey_T SenseKey:4;            /* Byte 2 Bits 0-3 */
   unsigned char :1;                                    /* Byte 2 Bit 4 */
-  boolean ILI:1;                                       /* Byte 2 Bit 5 */
-  boolean EOM:1;                                       /* Byte 2 Bit 6 */
-  boolean Filemark:1;                                  /* Byte 2 Bit 7 */
+  bool ILI:1;                                          /* Byte 2 Bit 5 */
+  bool EOM:1;                                          /* Byte 2 Bit 6 */
+  bool Filemark:1;                                     /* Byte 2 Bit 7 */
   unsigned char Information[4];                                /* Bytes 3-6 */
   unsigned char AdditionalSenseLength;                 /* Byte 7 */
   unsigned char CommandSpecificInformation[4];         /* Bytes 8-11 */
@@ -381,8 +374,8 @@ typedef struct DAC960_V1_Enquiry
   unsigned int LogicalDriveSizes[32];                  /* Bytes 4-131 */
   unsigned short FlashAge;                             /* Bytes 132-133 */
   struct {
-    boolean DeferredWriteError:1;                      /* Byte 134 Bit 0 */
-    boolean BatteryLow:1;                              /* Byte 134 Bit 1 */
+    bool DeferredWriteError:1;                         /* Byte 134 Bit 0 */
+    bool BatteryLow:1;                                 /* Byte 134 Bit 1 */
     unsigned char :6;                                  /* Byte 134 Bits 2-7 */
   } StatusFlags;
   unsigned char :8;                                    /* Byte 135 */
@@ -410,7 +403,7 @@ typedef struct DAC960_V1_Enquiry
   unsigned char RebuildCount;                          /* Byte 150 */
   struct {
     unsigned char :3;                                  /* Byte 151 Bits 0-2 */
-    boolean BatteryBackupUnitPresent:1;                        /* Byte 151 Bit 3 */
+    bool BatteryBackupUnitPresent:1;                   /* Byte 151 Bit 3 */
     unsigned char :3;                                  /* Byte 151 Bits 4-6 */
     unsigned char :1;                                  /* Byte 151 Bit 7 */
   } MiscFlags;
@@ -492,8 +485,8 @@ typedef struct DAC960_V1_Enquiry2
       DAC960_V1_ErrorCorrection_ECC =          0x2,
       DAC960_V1_ErrorCorrection_Last =         0x7
     } __attribute__ ((packed)) ErrorCorrection:3;      /* Byte 40 Bits 3-5 */
-    boolean FastPageMode:1;                            /* Byte 40 Bit 6 */
-    boolean LowPowerMemory:1;                          /* Byte 40 Bit 7 */
+    bool FastPageMode:1;                               /* Byte 40 Bit 6 */
+    bool LowPowerMemory:1;                             /* Byte 40 Bit 7 */
     unsigned char :8;                                  /* Bytes 41 */
   } MemoryType;
   unsigned short ClockSpeed;                           /* Bytes 42-43 */
@@ -538,7 +531,7 @@ typedef struct DAC960_V1_Enquiry2
       DAC960_V1_Ultra =                                0x1,
       DAC960_V1_Ultra2 =                       0x2
     } __attribute__ ((packed)) BusSpeed:2;             /* Byte 106 Bits 2-3 */
-    boolean Differential:1;                            /* Byte 106 Bit 4 */
+    bool Differential:1;                               /* Byte 106 Bit 4 */
     unsigned char :3;                                  /* Byte 106 Bits 5-7 */
   } SCSICapability;
   unsigned char :8;                                    /* Byte 107 */
@@ -554,10 +547,10 @@ typedef struct DAC960_V1_Enquiry2
   } __attribute__ ((packed)) FaultManagementType;      /* Byte 114 */
   unsigned char :8;                                    /* Byte 115 */
   struct {
-    boolean Clustering:1;                              /* Byte 116 Bit 0 */
-    boolean MylexOnlineRAIDExpansion:1;                        /* Byte 116 Bit 1 */
-    boolean ReadAhead:1;                               /* Byte 116 Bit 2 */
-    boolean BackgroundInitialization:1;                        /* Byte 116 Bit 3 */
+    bool Clustering:1;                                 /* Byte 116 Bit 0 */
+    bool MylexOnlineRAIDExpansion:1;                   /* Byte 116 Bit 1 */
+    bool ReadAhead:1;                                  /* Byte 116 Bit 2 */
+    bool BackgroundInitialization:1;                   /* Byte 116 Bit 3 */
     unsigned int :28;                                  /* Bytes 116-119 */
   } FirmwareFeatures;
   unsigned int :32;                                    /* Bytes 120-123 */
@@ -589,7 +582,7 @@ typedef struct DAC960_V1_LogicalDriveInformation
   unsigned int LogicalDriveSize;                       /* Bytes 0-3 */
   DAC960_V1_LogicalDriveState_T LogicalDriveState;     /* Byte 4 */
   unsigned char RAIDLevel:7;                           /* Byte 5 Bits 0-6 */
-  boolean WriteBack:1;                                 /* Byte 5 Bit 7 */
+  bool WriteBack:1;                                    /* Byte 5 Bit 7 */
   unsigned short :16;                                  /* Bytes 6-7 */
 }
 DAC960_V1_LogicalDriveInformation_T;
@@ -630,13 +623,13 @@ typedef struct DAC960_V1_EventLogEntry
   unsigned char :2;                                    /* Byte 3 Bits 6-7 */
   unsigned short SequenceNumber;                       /* Bytes 4-5 */
   unsigned char ErrorCode:7;                           /* Byte 6 Bits 0-6 */
-  boolean Valid:1;                                     /* Byte 6 Bit 7 */
+  bool Valid:1;                                                /* Byte 6 Bit 7 */
   unsigned char SegmentNumber;                         /* Byte 7 */
   DAC960_SCSI_RequestSenseKey_T SenseKey:4;            /* Byte 8 Bits 0-3 */
   unsigned char :1;                                    /* Byte 8 Bit 4 */
-  boolean ILI:1;                                       /* Byte 8 Bit 5 */
-  boolean EOM:1;                                       /* Byte 8 Bit 6 */
-  boolean Filemark:1;                                  /* Byte 8 Bit 7 */
+  bool ILI:1;                                          /* Byte 8 Bit 5 */
+  bool EOM:1;                                          /* Byte 8 Bit 6 */
+  bool Filemark:1;                                     /* Byte 8 Bit 7 */
   unsigned char Information[4];                                /* Bytes 9-12 */
   unsigned char AdditionalSenseLength;                 /* Byte 13 */
   unsigned char CommandSpecificInformation[4];         /* Bytes 14-17 */
@@ -670,7 +663,7 @@ DAC960_V1_PhysicalDeviceState_T;
 
 typedef struct DAC960_V1_DeviceState
 {
-  boolean Present:1;                                   /* Byte 0 Bit 0 */
+  bool Present:1;                                      /* Byte 0 Bit 0 */
   unsigned char :7;                                    /* Byte 0 Bits 1-7 */
   enum {
     DAC960_V1_OtherType =                      0x0,
@@ -678,12 +671,12 @@ typedef struct DAC960_V1_DeviceState
     DAC960_V1_SequentialType =                 0x2,
     DAC960_V1_CDROM_or_WORM_Type =             0x3
     } __attribute__ ((packed)) DeviceType:2;           /* Byte 1 Bits 0-1 */
-  boolean :1;                                          /* Byte 1 Bit 2 */
-  boolean Fast20:1;                                    /* Byte 1 Bit 3 */
-  boolean Sync:1;                                      /* Byte 1 Bit 4 */
-  boolean Fast:1;                                      /* Byte 1 Bit 5 */
-  boolean Wide:1;                                      /* Byte 1 Bit 6 */
-  boolean TaggedQueuingSupported:1;                    /* Byte 1 Bit 7 */
+  bool :1;                                             /* Byte 1 Bit 2 */
+  bool Fast20:1;                                       /* Byte 1 Bit 3 */
+  bool Sync:1;                                         /* Byte 1 Bit 4 */
+  bool Fast:1;                                         /* Byte 1 Bit 5 */
+  bool Wide:1;                                         /* Byte 1 Bit 6 */
+  bool TaggedQueuingSupported:1;                       /* Byte 1 Bit 7 */
   DAC960_V1_PhysicalDeviceState_T DeviceState;         /* Byte 2 */
   unsigned char :8;                                    /* Byte 3 */
   unsigned char SynchronousMultiplier;                 /* Byte 4 */
@@ -765,15 +758,15 @@ DAC960_V1_ErrorTable_T;
 typedef struct DAC960_V1_Config2
 {
   unsigned char :1;                                    /* Byte 0 Bit 0 */
-  boolean ActiveNegationEnabled:1;                     /* Byte 0 Bit 1 */
+  bool ActiveNegationEnabled:1;                                /* Byte 0 Bit 1 */
   unsigned char :5;                                    /* Byte 0 Bits 2-6 */
-  boolean NoRescanIfResetReceivedDuringScan:1;         /* Byte 0 Bit 7 */
-  boolean StorageWorksSupportEnabled:1;                        /* Byte 1 Bit 0 */
-  boolean HewlettPackardSupportEnabled:1;              /* Byte 1 Bit 1 */
-  boolean NoDisconnectOnFirstCommand:1;                        /* Byte 1 Bit 2 */
+  bool NoRescanIfResetReceivedDuringScan:1;            /* Byte 0 Bit 7 */
+  bool StorageWorksSupportEnabled:1;                   /* Byte 1 Bit 0 */
+  bool HewlettPackardSupportEnabled:1;                 /* Byte 1 Bit 1 */
+  bool NoDisconnectOnFirstCommand:1;                   /* Byte 1 Bit 2 */
   unsigned char :2;                                    /* Byte 1 Bits 3-4 */
-  boolean AEMI_ARM:1;                                  /* Byte 1 Bit 5 */
-  boolean AEMI_OFM:1;                                  /* Byte 1 Bit 6 */
+  bool AEMI_ARM:1;                                     /* Byte 1 Bit 5 */
+  bool AEMI_OFM:1;                                     /* Byte 1 Bit 6 */
   unsigned char :1;                                    /* Byte 1 Bit 7 */
   enum {
     DAC960_V1_OEMID_Mylex =                    0x00,
@@ -787,13 +780,13 @@ typedef struct DAC960_V1_Config2
   unsigned char PhysicalSector;                                /* Byte 4 */
   unsigned char LogicalSector;                         /* Byte 5 */
   unsigned char BlockFactor;                           /* Byte 6 */
-  boolean ReadAheadEnabled:1;                          /* Byte 7 Bit 0 */
-  boolean LowBIOSDelay:1;                              /* Byte 7 Bit 1 */
+  bool ReadAheadEnabled:1;                             /* Byte 7 Bit 0 */
+  bool LowBIOSDelay:1;                                 /* Byte 7 Bit 1 */
   unsigned char :2;                                    /* Byte 7 Bits 2-3 */
-  boolean ReassignRestrictedToOneSector:1;             /* Byte 7 Bit 4 */
+  bool ReassignRestrictedToOneSector:1;                        /* Byte 7 Bit 4 */
   unsigned char :1;                                    /* Byte 7 Bit 5 */
-  boolean ForceUnitAccessDuringWriteRecovery:1;                /* Byte 7 Bit 6 */
-  boolean EnableLeftSymmetricRAID5Algorithm:1;         /* Byte 7 Bit 7 */
+  bool ForceUnitAccessDuringWriteRecovery:1;           /* Byte 7 Bit 6 */
+  bool EnableLeftSymmetricRAID5Algorithm:1;            /* Byte 7 Bit 7 */
   unsigned char DefaultRebuildRate;                    /* Byte 8 */
   unsigned char :8;                                    /* Byte 9 */
   unsigned char BlocksPerCacheLine;                    /* Byte 10 */
@@ -805,10 +798,10 @@ typedef struct DAC960_V1_Config2
       DAC960_V1_Sync_5MHz =                    0x2,
       DAC960_V1_Sync_10or20MHz =               0x3     /* Byte 11 Bits 0-1 */
     } __attribute__ ((packed)) Speed:2;
-    boolean Force8Bit:1;                               /* Byte 11 Bit 2 */
-    boolean DisableFast20:1;                           /* Byte 11 Bit 3 */
+    bool Force8Bit:1;                                  /* Byte 11 Bit 2 */
+    bool DisableFast20:1;                              /* Byte 11 Bit 3 */
     unsigned char :3;                                  /* Byte 11 Bits 4-6 */
-    boolean EnableTaggedQueuing:1;                     /* Byte 11 Bit 7 */
+    bool EnableTaggedQueuing:1;                                /* Byte 11 Bit 7 */
   } __attribute__ ((packed)) ChannelParameters[6];     /* Bytes 12-17 */
   unsigned char SCSIInitiatorID;                       /* Byte 18 */
   unsigned char :8;                                    /* Byte 19 */
@@ -819,8 +812,8 @@ typedef struct DAC960_V1_Config2
   unsigned char SimultaneousDeviceSpinUpCount;         /* Byte 21 */
   unsigned char SecondsDelayBetweenSpinUps;            /* Byte 22 */
   unsigned char Reserved1[29];                         /* Bytes 23-51 */
-  boolean BIOSDisabled:1;                              /* Byte 52 Bit 0 */
-  boolean CDROMBootEnabled:1;                          /* Byte 52 Bit 1 */
+  bool BIOSDisabled:1;                                 /* Byte 52 Bit 0 */
+  bool CDROMBootEnabled:1;                             /* Byte 52 Bit 1 */
   unsigned char :3;                                    /* Byte 52 Bits 2-4 */
   enum {
     DAC960_V1_Geometry_128_32 =                        0x0,
@@ -849,7 +842,7 @@ typedef struct DAC960_V1_DCDB
     DAC960_V1_DCDB_DataTransferSystemToDevice = 2,
     DAC960_V1_DCDB_IllegalDataTransfer =       3
   } __attribute__ ((packed)) Direction:2;               /* Byte 1 Bits 0-1 */
-  boolean EarlyStatus:1;                                /* Byte 1 Bit 2 */
+  bool EarlyStatus:1;                                   /* Byte 1 Bit 2 */
   unsigned char :1;                                     /* Byte 1 Bit 3 */
   enum {
     DAC960_V1_DCDB_Timeout_24_hours =          0,
@@ -857,8 +850,8 @@ typedef struct DAC960_V1_DCDB
     DAC960_V1_DCDB_Timeout_60_seconds =                2,
     DAC960_V1_DCDB_Timeout_10_minutes =                3
   } __attribute__ ((packed)) Timeout:2;                         /* Byte 1 Bits 4-5 */
-  boolean NoAutomaticRequestSense:1;                    /* Byte 1 Bit 6 */
-  boolean DisconnectPermitted:1;                        /* Byte 1 Bit 7 */
+  bool NoAutomaticRequestSense:1;                       /* Byte 1 Bit 6 */
+  bool DisconnectPermitted:1;                           /* Byte 1 Bit 7 */
   unsigned short TransferLength;                        /* Bytes 2-3 */
   DAC960_BusAddress32_T BusAddress;                     /* Bytes 4-7 */
   unsigned char CDBLength:4;                            /* Byte 8 Bits 0-3 */
@@ -920,7 +913,7 @@ typedef union DAC960_V1_CommandMailbox
     DAC960_V1_CommandIdentifier_T CommandIdentifier;   /* Byte 1 */
     unsigned char Dummy1[5];                           /* Bytes 2-6 */
     unsigned char LogicalDriveNumber:6;                        /* Byte 7 Bits 0-6 */
-    boolean AutoRestore:1;                             /* Byte 7 Bit 7 */
+    bool AutoRestore:1;                                        /* Byte 7 Bit 7 */
     unsigned char Dummy2[8];                           /* Bytes 8-15 */
   } __attribute__ ((packed)) Type3C;
   struct {
@@ -1070,9 +1063,9 @@ typedef struct DAC960_V2_MemoryType
     DAC960_V2_MemoryType_SDRAM =               0x04,
     DAC960_V2_MemoryType_Last =                        0x1F
   } __attribute__ ((packed)) MemoryType:5;             /* Byte 0 Bits 0-4 */
-  boolean :1;                                          /* Byte 0 Bit 5 */
-  boolean MemoryParity:1;                              /* Byte 0 Bit 6 */
-  boolean MemoryECC:1;                                 /* Byte 0 Bit 7 */
+  bool :1;                                             /* Byte 0 Bit 5 */
+  bool MemoryParity:1;                                 /* Byte 0 Bit 6 */
+  bool MemoryECC:1;                                    /* Byte 0 Bit 7 */
 }
 DAC960_V2_MemoryType_T;
 
@@ -1187,13 +1180,13 @@ typedef struct DAC960_V2_ControllerInfo
   unsigned char OEM_Code;                              /* Byte 131 */
   unsigned char VendorName[16];                                /* Bytes 132-147 */
   /* Other Physical/Controller/Operation Information */
-  boolean BBU_Present:1;                               /* Byte 148 Bit 0 */
-  boolean ActiveActiveClusteringMode:1;                        /* Byte 148 Bit 1 */
+  bool BBU_Present:1;                                  /* Byte 148 Bit 0 */
+  bool ActiveActiveClusteringMode:1;                   /* Byte 148 Bit 1 */
   unsigned char :6;                                    /* Byte 148 Bits 2-7 */
   unsigned char :8;                                    /* Byte 149 */
   unsigned short :16;                                  /* Bytes 150-151 */
   /* Physical Device Scan Information */
-  boolean PhysicalScanActive:1;                                /* Byte 152 Bit 0 */
+  bool PhysicalScanActive:1;                           /* Byte 152 Bit 0 */
   unsigned char :7;                                    /* Byte 152 Bits 1-7 */
   unsigned char PhysicalDeviceChannelNumber;           /* Byte 153 */
   unsigned char PhysicalDeviceTargetID;                        /* Byte 154 */
@@ -1305,8 +1298,8 @@ typedef struct DAC960_V2_ControllerInfo
   unsigned int FreeIOP;                                        /* Bytes 468-471 */
   unsigned short MaximumCombLengthInBlocks;            /* Bytes 472-473 */
   unsigned short NumberOfConfigurationGroups;          /* Bytes 474-475 */
-  boolean InstallationAbortStatus:1;                   /* Byte 476 Bit 0 */
-  boolean MaintenanceModeStatus:1;                     /* Byte 476 Bit 1 */
+  bool InstallationAbortStatus:1;                      /* Byte 476 Bit 0 */
+  bool MaintenanceModeStatus:1;                                /* Byte 476 Bit 1 */
   unsigned int :24;                                    /* Bytes 476-479 */
   unsigned char Reserved10[32];                                /* Bytes 480-511 */
   unsigned char Reserved11[512];                       /* Bytes 512-1023 */
@@ -1357,33 +1350,33 @@ typedef struct DAC960_V2_LogicalDeviceInfo
       DAC960_V2_IntelligentWriteCacheEnabled = 0x3,
       DAC960_V2_WriteCache_Last =              0x7
     } __attribute__ ((packed)) WriteCache:3;           /* Byte 8 Bits 3-5 */
-    boolean :1;                                                /* Byte 8 Bit 6 */
-    boolean LogicalDeviceInitialized:1;                        /* Byte 8 Bit 7 */
+    bool :1;                                           /* Byte 8 Bit 6 */
+    bool LogicalDeviceInitialized:1;                   /* Byte 8 Bit 7 */
   } LogicalDeviceControl;                              /* Byte 8 */
   /* Logical Device Operations Status */
-  boolean ConsistencyCheckInProgress:1;                        /* Byte 9 Bit 0 */
-  boolean RebuildInProgress:1;                         /* Byte 9 Bit 1 */
-  boolean BackgroundInitializationInProgress:1;                /* Byte 9 Bit 2 */
-  boolean ForegroundInitializationInProgress:1;                /* Byte 9 Bit 3 */
-  boolean DataMigrationInProgress:1;                   /* Byte 9 Bit 4 */
-  boolean PatrolOperationInProgress:1;                 /* Byte 9 Bit 5 */
+  bool ConsistencyCheckInProgress:1;                   /* Byte 9 Bit 0 */
+  bool RebuildInProgress:1;                            /* Byte 9 Bit 1 */
+  bool BackgroundInitializationInProgress:1;           /* Byte 9 Bit 2 */
+  bool ForegroundInitializationInProgress:1;           /* Byte 9 Bit 3 */
+  bool DataMigrationInProgress:1;                      /* Byte 9 Bit 4 */
+  bool PatrolOperationInProgress:1;                    /* Byte 9 Bit 5 */
   unsigned char :2;                                    /* Byte 9 Bits 6-7 */
   unsigned char RAID5WriteUpdate;                      /* Byte 10 */
   unsigned char RAID5Algorithm;                                /* Byte 11 */
   unsigned short LogicalDeviceNumber;                  /* Bytes 12-13 */
   /* BIOS Info */
-  boolean BIOSDisabled:1;                              /* Byte 14 Bit 0 */
-  boolean CDROMBootEnabled:1;                          /* Byte 14 Bit 1 */
-  boolean DriveCoercionEnabled:1;                      /* Byte 14 Bit 2 */
-  boolean WriteSameDisabled:1;                         /* Byte 14 Bit 3 */
-  boolean HBA_ModeEnabled:1;                           /* Byte 14 Bit 4 */
+  bool BIOSDisabled:1;                                 /* Byte 14 Bit 0 */
+  bool CDROMBootEnabled:1;                             /* Byte 14 Bit 1 */
+  bool DriveCoercionEnabled:1;                         /* Byte 14 Bit 2 */
+  bool WriteSameDisabled:1;                            /* Byte 14 Bit 3 */
+  bool HBA_ModeEnabled:1;                              /* Byte 14 Bit 4 */
   enum {
     DAC960_V2_Geometry_128_32 =                        0x0,
     DAC960_V2_Geometry_255_63 =                        0x1,
     DAC960_V2_Geometry_Reserved1 =             0x2,
     DAC960_V2_Geometry_Reserved2 =             0x3
   } __attribute__ ((packed)) DriveGeometry:2;          /* Byte 14 Bits 5-6 */
-  boolean SuperReadAheadEnabled:1;                     /* Byte 14 Bit 7 */
+  bool SuperReadAheadEnabled:1;                                /* Byte 14 Bit 7 */
   unsigned char :8;                                    /* Byte 15 */
   /* Error Counters */
   unsigned short SoftErrors;                           /* Bytes 16-17 */
@@ -1446,13 +1439,13 @@ typedef struct DAC960_V2_PhysicalDeviceInfo
   unsigned char TargetID;                              /* Byte 2 */
   unsigned char LogicalUnit;                           /* Byte 3 */
   /* Configuration Status Bits */
-  boolean PhysicalDeviceFaultTolerant:1;               /* Byte 4 Bit 0 */
-  boolean PhysicalDeviceConnected:1;                   /* Byte 4 Bit 1 */
-  boolean PhysicalDeviceLocalToController:1;           /* Byte 4 Bit 2 */
+  bool PhysicalDeviceFaultTolerant:1;                  /* Byte 4 Bit 0 */
+  bool PhysicalDeviceConnected:1;                      /* Byte 4 Bit 1 */
+  bool PhysicalDeviceLocalToController:1;              /* Byte 4 Bit 2 */
   unsigned char :5;                                    /* Byte 4 Bits 3-7 */
   /* Multiple Host/Controller Status Bits */
-  boolean RemoteHostSystemDead:1;                      /* Byte 5 Bit 0 */
-  boolean RemoteControllerDead:1;                      /* Byte 5 Bit 1 */
+  bool RemoteHostSystemDead:1;                         /* Byte 5 Bit 0 */
+  bool RemoteControllerDead:1;                         /* Byte 5 Bit 1 */
   unsigned char :6;                                    /* Byte 5 Bits 2-7 */
   DAC960_V2_PhysicalDeviceState_T PhysicalDeviceState; /* Byte 6 */
   unsigned char NegotiatedDataWidthBits;               /* Byte 7 */
@@ -1464,12 +1457,12 @@ typedef struct DAC960_V2_PhysicalDeviceInfo
   unsigned char NetworkAddress[16];                    /* Bytes 16-31 */
   unsigned short MaximumTags;                          /* Bytes 32-33 */
   /* Physical Device Operations Status */
-  boolean ConsistencyCheckInProgress:1;                        /* Byte 34 Bit 0 */
-  boolean RebuildInProgress:1;                         /* Byte 34 Bit 1 */
-  boolean MakingDataConsistentInProgress:1;            /* Byte 34 Bit 2 */
-  boolean PhysicalDeviceInitializationInProgress:1;    /* Byte 34 Bit 3 */
-  boolean DataMigrationInProgress:1;                   /* Byte 34 Bit 4 */
-  boolean PatrolOperationInProgress:1;                 /* Byte 34 Bit 5 */
+  bool ConsistencyCheckInProgress:1;                   /* Byte 34 Bit 0 */
+  bool RebuildInProgress:1;                            /* Byte 34 Bit 1 */
+  bool MakingDataConsistentInProgress:1;               /* Byte 34 Bit 2 */
+  bool PhysicalDeviceInitializationInProgress:1;       /* Byte 34 Bit 3 */
+  bool DataMigrationInProgress:1;                      /* Byte 34 Bit 4 */
+  bool PatrolOperationInProgress:1;                    /* Byte 34 Bit 5 */
   unsigned char :2;                                    /* Byte 34 Bits 6-7 */
   unsigned char LongOperationStatus;                   /* Byte 35 */
   unsigned char ParityErrors;                          /* Byte 36 */
@@ -1555,14 +1548,14 @@ DAC960_V2_Event_T;
 
 typedef struct DAC960_V2_CommandControlBits
 {
-  boolean ForceUnitAccess:1;                           /* Byte 0 Bit 0 */
-  boolean DisablePageOut:1;                            /* Byte 0 Bit 1 */
-  boolean :1;                                          /* Byte 0 Bit 2 */
-  boolean AdditionalScatterGatherListMemory:1;         /* Byte 0 Bit 3 */
-  boolean DataTransferControllerToHost:1;              /* Byte 0 Bit 4 */
-  boolean :1;                                          /* Byte 0 Bit 5 */
-  boolean NoAutoRequestSense:1;                                /* Byte 0 Bit 6 */
-  boolean DisconnectProhibited:1;                      /* Byte 0 Bit 7 */
+  bool ForceUnitAccess:1;                              /* Byte 0 Bit 0 */
+  bool DisablePageOut:1;                               /* Byte 0 Bit 1 */
+  bool :1;                                             /* Byte 0 Bit 2 */
+  bool AdditionalScatterGatherListMemory:1;            /* Byte 0 Bit 3 */
+  bool DataTransferControllerToHost:1;                 /* Byte 0 Bit 4 */
+  bool :1;                                             /* Byte 0 Bit 5 */
+  bool NoAutoRequestSense:1;                           /* Byte 0 Bit 6 */
+  bool DisconnectProhibited:1;                         /* Byte 0 Bit 7 */
 }
 DAC960_V2_CommandControlBits_T;
 
@@ -1825,8 +1818,8 @@ typedef union DAC960_V2_CommandMailbox
     DAC960_V2_CommandTimeout_T CommandTimeout;         /* Byte 19 */
     unsigned char RequestSenseSize;                    /* Byte 20 */
     unsigned char IOCTL_Opcode;                                /* Byte 21 */
-    boolean RestoreConsistency:1;                      /* Byte 22 Bit 0 */
-    boolean InitializedAreaOnly:1;                     /* Byte 22 Bit 1 */
+    bool RestoreConsistency:1;                         /* Byte 22 Bit 0 */
+    bool InitializedAreaOnly:1;                                /* Byte 22 Bit 1 */
     unsigned char :6;                                  /* Byte 22 Bits 2-7 */
     unsigned char Reserved[9];                         /* Bytes 23-31 */
     DAC960_V2_DataTransferMemoryAddress_T
@@ -2190,7 +2183,7 @@ typedef union DAC960_V1_StatusMailbox
   struct {
     DAC960_V1_CommandIdentifier_T CommandIdentifier;   /* Byte 0 */
     unsigned char :7;                                  /* Byte 1 Bits 0-6 */
-    boolean Valid:1;                                   /* Byte 1 Bit 7 */
+    bool Valid:1;                                      /* Byte 1 Bit 7 */
     DAC960_V1_CommandStatus_T CommandStatus;           /* Bytes 2-3 */
   } Fields;
 }
@@ -2322,12 +2315,12 @@ typedef struct DAC960_Controller
   unsigned long ShutdownMonitoringTimer;
   unsigned long LastProgressReportTime;
   unsigned long LastCurrentStatusTime;
-  boolean ControllerInitialized;
-  boolean MonitoringCommandDeferred;
-  boolean EphemeralProgressMessage;
-  boolean DriveSpinUpMessageDisplayed;
-  boolean MonitoringAlertMode;
-  boolean SuppressEnclosureMessages;
+  bool ControllerInitialized;
+  bool MonitoringCommandDeferred;
+  bool EphemeralProgressMessage;
+  bool DriveSpinUpMessageDisplayed;
+  bool MonitoringAlertMode;
+  bool SuppressEnclosureMessages;
   struct timer_list MonitoringTimer;
   struct gendisk *disks[DAC960_MaxLogicalDrives];
   struct pci_pool *ScatterGatherPool;
@@ -2342,11 +2335,11 @@ typedef struct DAC960_Controller
   DAC960_Command_T InitialCommand;
   DAC960_Command_T *Commands[DAC960_MaxDriverQueueDepth];
   struct proc_dir_entry *ControllerProcEntry;
-  boolean LogicalDriveInitiallyAccessible[DAC960_MaxLogicalDrives];
+  bool LogicalDriveInitiallyAccessible[DAC960_MaxLogicalDrives];
   void (*QueueCommand)(DAC960_Command_T *Command);
-  boolean (*ReadControllerConfiguration)(struct DAC960_Controller *);
-  boolean (*ReadDeviceConfiguration)(struct DAC960_Controller *);
-  boolean (*ReportDeviceConfiguration)(struct DAC960_Controller *);
+  bool (*ReadControllerConfiguration)(struct DAC960_Controller *);
+  bool (*ReadDeviceConfiguration)(struct DAC960_Controller *);
+  bool (*ReportDeviceConfiguration)(struct DAC960_Controller *);
   void (*QueueReadWriteCommand)(DAC960_Command_T *Command);
   union {
     struct {
@@ -2359,21 +2352,21 @@ typedef struct DAC960_Controller
       unsigned short OldEventLogSequenceNumber;
       unsigned short DeviceStateChannel;
       unsigned short DeviceStateTargetID;
-      boolean DualModeMemoryMailboxInterface;
-      boolean BackgroundInitializationStatusSupported;
-      boolean SAFTE_EnclosureManagementEnabled;
-      boolean NeedLogicalDriveInformation;
-      boolean NeedErrorTableInformation;
-      boolean NeedDeviceStateInformation;
-      boolean NeedDeviceInquiryInformation;
-      boolean NeedDeviceSerialNumberInformation;
-      boolean NeedRebuildProgress;
-      boolean NeedConsistencyCheckProgress;
-      boolean NeedBackgroundInitializationStatus;
-      boolean StartDeviceStateScan;
-      boolean RebuildProgressFirst;
-      boolean RebuildFlagPending;
-      boolean RebuildStatusPending;
+      bool DualModeMemoryMailboxInterface;
+      bool BackgroundInitializationStatusSupported;
+      bool SAFTE_EnclosureManagementEnabled;
+      bool NeedLogicalDriveInformation;
+      bool NeedErrorTableInformation;
+      bool NeedDeviceStateInformation;
+      bool NeedDeviceInquiryInformation;
+      bool NeedDeviceSerialNumberInformation;
+      bool NeedRebuildProgress;
+      bool NeedConsistencyCheckProgress;
+      bool NeedBackgroundInitializationStatus;
+      bool StartDeviceStateScan;
+      bool RebuildProgressFirst;
+      bool RebuildFlagPending;
+      bool RebuildStatusPending;
 
       dma_addr_t       FirstCommandMailboxDMA;
       DAC960_V1_CommandMailbox_T *FirstCommandMailbox;
@@ -2432,17 +2425,17 @@ typedef struct DAC960_Controller
       dma_addr_t NewInquiryUnitSerialNumberDMA;
 
       int DeviceResetCount[DAC960_V1_MaxChannels][DAC960_V1_MaxTargets];
-      boolean DirectCommandActive[DAC960_V1_MaxChannels][DAC960_V1_MaxTargets];
+      bool DirectCommandActive[DAC960_V1_MaxChannels][DAC960_V1_MaxTargets];
     } V1;
     struct {
       unsigned int StatusChangeCounter;
       unsigned int NextEventSequenceNumber;
       unsigned int PhysicalDeviceIndex;
-      boolean NeedLogicalDeviceInformation;
-      boolean NeedPhysicalDeviceInformation;
-      boolean NeedDeviceSerialNumberInformation;
-      boolean StartLogicalDeviceInformationScan;
-      boolean StartPhysicalDeviceInformationScan;
+      bool NeedLogicalDeviceInformation;
+      bool NeedPhysicalDeviceInformation;
+      bool NeedDeviceSerialNumberInformation;
+      bool StartLogicalDeviceInformationScan;
+      bool StartPhysicalDeviceInformationScan;
       struct pci_pool *RequestSensePool;
 
       dma_addr_t       FirstCommandMailboxDMA;
@@ -2487,7 +2480,7 @@ typedef struct DAC960_Controller
 
       DAC960_V2_PhysicalDevice_T
        LogicalDriveToVirtualDevice[DAC960_MaxLogicalDrives];
-      boolean LogicalDriveFoundDuringScan[DAC960_MaxLogicalDrives];
+      bool LogicalDriveFoundDuringScan[DAC960_MaxLogicalDrives];
     } V2;
   } FW;
   unsigned char ProgressBuffer[DAC960_ProgressBufferSize];
@@ -2572,17 +2565,17 @@ typedef union DAC960_GEM_InboundDoorBellRegister
   unsigned int All;
   struct {
     unsigned int :24;
-    boolean HardwareMailboxNewCommand:1;
-    boolean AcknowledgeHardwareMailboxStatus:1;
-    boolean GenerateInterrupt:1;
-    boolean ControllerReset:1;
-    boolean MemoryMailboxNewCommand:1;
+    bool HardwareMailboxNewCommand:1;
+    bool AcknowledgeHardwareMailboxStatus:1;
+    bool GenerateInterrupt:1;
+    bool ControllerReset:1;
+    bool MemoryMailboxNewCommand:1;
     unsigned int :3;
   } Write;
   struct {
     unsigned int :24;
-    boolean HardwareMailboxFull:1;
-    boolean InitializationInProgress:1;
+    bool HardwareMailboxFull:1;
+    bool InitializationInProgress:1;
     unsigned int :6;
   } Read;
 }
@@ -2596,14 +2589,14 @@ typedef union DAC960_GEM_OutboundDoorBellRegister
   unsigned int All;
   struct {
     unsigned int :24;
-    boolean AcknowledgeHardwareMailboxInterrupt:1;
-    boolean AcknowledgeMemoryMailboxInterrupt:1;
+    bool AcknowledgeHardwareMailboxInterrupt:1;
+    bool AcknowledgeMemoryMailboxInterrupt:1;
     unsigned int :6;
   } Write;
   struct {
     unsigned int :24;
-    boolean HardwareMailboxStatusAvailable:1;
-    boolean MemoryMailboxStatusAvailable:1;
+    bool HardwareMailboxStatusAvailable:1;
+    bool MemoryMailboxStatusAvailable:1;
     unsigned int :6;
   } Read;
 }
@@ -2635,7 +2628,7 @@ typedef union DAC960_GEM_ErrorStatusRegister
   struct {
     unsigned int :24;
     unsigned int :5;
-    boolean ErrorStatusPending:1;
+    bool ErrorStatusPending:1;
     unsigned int :2;
   } Bits;
 }
@@ -2697,7 +2690,7 @@ void DAC960_GEM_MemoryMailboxNewCommand(void __iomem *ControllerBaseAddress)
 }
 
 static inline
-boolean DAC960_GEM_HardwareMailboxFullP(void __iomem *ControllerBaseAddress)
+bool DAC960_GEM_HardwareMailboxFullP(void __iomem *ControllerBaseAddress)
 {
   DAC960_GEM_InboundDoorBellRegister_T InboundDoorBellRegister;
   InboundDoorBellRegister.All =
@@ -2707,7 +2700,7 @@ boolean DAC960_GEM_HardwareMailboxFullP(void __iomem *ControllerBaseAddress)
 }
 
 static inline
-boolean DAC960_GEM_InitializationInProgressP(void __iomem *ControllerBaseAddress)
+bool DAC960_GEM_InitializationInProgressP(void __iomem *ControllerBaseAddress)
 {
   DAC960_GEM_InboundDoorBellRegister_T InboundDoorBellRegister;
   InboundDoorBellRegister.All =
@@ -2748,7 +2741,7 @@ void DAC960_GEM_AcknowledgeInterrupt(void __iomem *ControllerBaseAddress)
 }
 
 static inline
-boolean DAC960_GEM_HardwareMailboxStatusAvailableP(void __iomem *ControllerBaseAddress)
+bool DAC960_GEM_HardwareMailboxStatusAvailableP(void __iomem *ControllerBaseAddress)
 {
   DAC960_GEM_OutboundDoorBellRegister_T OutboundDoorBellRegister;
   OutboundDoorBellRegister.All =
@@ -2758,7 +2751,7 @@ boolean DAC960_GEM_HardwareMailboxStatusAvailableP(void __iomem *ControllerBaseA
 }
 
 static inline
-boolean DAC960_GEM_MemoryMailboxStatusAvailableP(void __iomem *ControllerBaseAddress)
+bool DAC960_GEM_MemoryMailboxStatusAvailableP(void __iomem *ControllerBaseAddress)
 {
   DAC960_GEM_OutboundDoorBellRegister_T OutboundDoorBellRegister;
   OutboundDoorBellRegister.All =
@@ -2790,7 +2783,7 @@ void DAC960_GEM_DisableInterrupts(void __iomem *ControllerBaseAddress)
 }
 
 static inline
-boolean DAC960_GEM_InterruptsEnabledP(void __iomem *ControllerBaseAddress)
+bool DAC960_GEM_InterruptsEnabledP(void __iomem *ControllerBaseAddress)
 {
   DAC960_GEM_InterruptMaskRegister_T InterruptMaskRegister;
   InterruptMaskRegister.All =
@@ -2834,7 +2827,7 @@ DAC960_GEM_ReadCommandStatus(void __iomem *ControllerBaseAddress)
   return readw(ControllerBaseAddress + DAC960_GEM_CommandStatusOffset + 2);
 }
 
-static inline boolean
+static inline bool
 DAC960_GEM_ReadErrorStatus(void __iomem *ControllerBaseAddress,
                          unsigned char *ErrorStatus,
                          unsigned char *Parameter0,
@@ -2882,16 +2875,16 @@ typedef union DAC960_BA_InboundDoorBellRegister
 {
   unsigned char All;
   struct {
-    boolean HardwareMailboxNewCommand:1;               /* Bit 0 */
-    boolean AcknowledgeHardwareMailboxStatus:1;                /* Bit 1 */
-    boolean GenerateInterrupt:1;                       /* Bit 2 */
-    boolean ControllerReset:1;                         /* Bit 3 */
-    boolean MemoryMailboxNewCommand:1;                 /* Bit 4 */
+    bool HardwareMailboxNewCommand:1;                  /* Bit 0 */
+    bool AcknowledgeHardwareMailboxStatus:1;           /* Bit 1 */
+    bool GenerateInterrupt:1;                          /* Bit 2 */
+    bool ControllerReset:1;                            /* Bit 3 */
+    bool MemoryMailboxNewCommand:1;                    /* Bit 4 */
     unsigned char :3;                                  /* Bits 5-7 */
   } Write;
   struct {
-    boolean HardwareMailboxEmpty:1;                    /* Bit 0 */
-    boolean InitializationNotInProgress:1;             /* Bit 1 */
+    bool HardwareMailboxEmpty:1;                       /* Bit 0 */
+    bool InitializationNotInProgress:1;                        /* Bit 1 */
     unsigned char :6;                                  /* Bits 2-7 */
   } Read;
 }
@@ -2906,13 +2899,13 @@ typedef union DAC960_BA_OutboundDoorBellRegister
 {
   unsigned char All;
   struct {
-    boolean AcknowledgeHardwareMailboxInterrupt:1;     /* Bit 0 */
-    boolean AcknowledgeMemoryMailboxInterrupt:1;       /* Bit 1 */
+    bool AcknowledgeHardwareMailboxInterrupt:1;                /* Bit 0 */
+    bool AcknowledgeMemoryMailboxInterrupt:1;          /* Bit 1 */
     unsigned char :6;                                  /* Bits 2-7 */
   } Write;
   struct {
-    boolean HardwareMailboxStatusAvailable:1;          /* Bit 0 */
-    boolean MemoryMailboxStatusAvailable:1;            /* Bit 1 */
+    bool HardwareMailboxStatusAvailable:1;             /* Bit 0 */
+    bool MemoryMailboxStatusAvailable:1;               /* Bit 1 */
     unsigned char :6;                                  /* Bits 2-7 */
   } Read;
 }
@@ -2928,8 +2921,8 @@ typedef union DAC960_BA_InterruptMaskRegister
   unsigned char All;
   struct {
     unsigned int :2;                                   /* Bits 0-1 */
-    boolean DisableInterrupts:1;                       /* Bit 2 */
-    boolean DisableInterruptsI2O:1;                    /* Bit 3 */
+    bool DisableInterrupts:1;                          /* Bit 2 */
+    bool DisableInterruptsI2O:1;                       /* Bit 3 */
     unsigned int :4;                                   /* Bits 4-7 */
   } Bits;
 }
@@ -2945,7 +2938,7 @@ typedef union DAC960_BA_ErrorStatusRegister
   unsigned char All;
   struct {
     unsigned int :2;                                   /* Bits 0-1 */
-    boolean ErrorStatusPending:1;                      /* Bit 2 */
+    bool ErrorStatusPending:1;                         /* Bit 2 */
     unsigned int :5;                                   /* Bits 3-7 */
   } Bits;
 }
@@ -3008,7 +3001,7 @@ void DAC960_BA_MemoryMailboxNewCommand(void __iomem *ControllerBaseAddress)
 }
 
 static inline
-boolean DAC960_BA_HardwareMailboxFullP(void __iomem *ControllerBaseAddress)
+bool DAC960_BA_HardwareMailboxFullP(void __iomem *ControllerBaseAddress)
 {
   DAC960_BA_InboundDoorBellRegister_T InboundDoorBellRegister;
   InboundDoorBellRegister.All =
@@ -3017,7 +3010,7 @@ boolean DAC960_BA_HardwareMailboxFullP(void __iomem *ControllerBaseAddress)
 }
 
 static inline
-boolean DAC960_BA_InitializationInProgressP(void __iomem *ControllerBaseAddress)
+bool DAC960_BA_InitializationInProgressP(void __iomem *ControllerBaseAddress)
 {
   DAC960_BA_InboundDoorBellRegister_T InboundDoorBellRegister;
   InboundDoorBellRegister.All =
@@ -3057,7 +3050,7 @@ void DAC960_BA_AcknowledgeInterrupt(void __iomem *ControllerBaseAddress)
 }
 
 static inline
-boolean DAC960_BA_HardwareMailboxStatusAvailableP(void __iomem *ControllerBaseAddress)
+bool DAC960_BA_HardwareMailboxStatusAvailableP(void __iomem *ControllerBaseAddress)
 {
   DAC960_BA_OutboundDoorBellRegister_T OutboundDoorBellRegister;
   OutboundDoorBellRegister.All =
@@ -3066,7 +3059,7 @@ boolean DAC960_BA_HardwareMailboxStatusAvailableP(void __iomem *ControllerBaseAd
 }
 
 static inline
-boolean DAC960_BA_MemoryMailboxStatusAvailableP(void __iomem *ControllerBaseAddress)
+bool DAC960_BA_MemoryMailboxStatusAvailableP(void __iomem *ControllerBaseAddress)
 {
   DAC960_BA_OutboundDoorBellRegister_T OutboundDoorBellRegister;
   OutboundDoorBellRegister.All =
@@ -3097,7 +3090,7 @@ void DAC960_BA_DisableInterrupts(void __iomem *ControllerBaseAddress)
 }
 
 static inline
-boolean DAC960_BA_InterruptsEnabledP(void __iomem *ControllerBaseAddress)
+bool DAC960_BA_InterruptsEnabledP(void __iomem *ControllerBaseAddress)
 {
   DAC960_BA_InterruptMaskRegister_T InterruptMaskRegister;
   InterruptMaskRegister.All =
@@ -3140,7 +3133,7 @@ DAC960_BA_ReadCommandStatus(void __iomem *ControllerBaseAddress)
   return readw(ControllerBaseAddress + DAC960_BA_CommandStatusOffset + 2);
 }
 
-static inline boolean
+static inline bool
 DAC960_BA_ReadErrorStatus(void __iomem *ControllerBaseAddress,
                          unsigned char *ErrorStatus,
                          unsigned char *Parameter0,
@@ -3188,16 +3181,16 @@ typedef union DAC960_LP_InboundDoorBellRegister
 {
   unsigned char All;
   struct {
-    boolean HardwareMailboxNewCommand:1;               /* Bit 0 */
-    boolean AcknowledgeHardwareMailboxStatus:1;                /* Bit 1 */
-    boolean GenerateInterrupt:1;                       /* Bit 2 */
-    boolean ControllerReset:1;                         /* Bit 3 */
-    boolean MemoryMailboxNewCommand:1;                 /* Bit 4 */
+    bool HardwareMailboxNewCommand:1;                  /* Bit 0 */
+    bool AcknowledgeHardwareMailboxStatus:1;           /* Bit 1 */
+    bool GenerateInterrupt:1;                          /* Bit 2 */
+    bool ControllerReset:1;                            /* Bit 3 */
+    bool MemoryMailboxNewCommand:1;                    /* Bit 4 */
     unsigned char :3;                                  /* Bits 5-7 */
   } Write;
   struct {
-    boolean HardwareMailboxFull:1;                     /* Bit 0 */
-    boolean InitializationInProgress:1;                        /* Bit 1 */
+    bool HardwareMailboxFull:1;                                /* Bit 0 */
+    bool InitializationInProgress:1;                   /* Bit 1 */
     unsigned char :6;                                  /* Bits 2-7 */
   } Read;
 }
@@ -3212,13 +3205,13 @@ typedef union DAC960_LP_OutboundDoorBellRegister
 {
   unsigned char All;
   struct {
-    boolean AcknowledgeHardwareMailboxInterrupt:1;     /* Bit 0 */
-    boolean AcknowledgeMemoryMailboxInterrupt:1;       /* Bit 1 */
+    bool AcknowledgeHardwareMailboxInterrupt:1;                /* Bit 0 */
+    bool AcknowledgeMemoryMailboxInterrupt:1;          /* Bit 1 */
     unsigned char :6;                                  /* Bits 2-7 */
   } Write;
   struct {
-    boolean HardwareMailboxStatusAvailable:1;          /* Bit 0 */
-    boolean MemoryMailboxStatusAvailable:1;            /* Bit 1 */
+    bool HardwareMailboxStatusAvailable:1;             /* Bit 0 */
+    bool MemoryMailboxStatusAvailable:1;               /* Bit 1 */
     unsigned char :6;                                  /* Bits 2-7 */
   } Read;
 }
@@ -3234,7 +3227,7 @@ typedef union DAC960_LP_InterruptMaskRegister
   unsigned char All;
   struct {
     unsigned int :2;                                   /* Bits 0-1 */
-    boolean DisableInterrupts:1;                       /* Bit 2 */
+    bool DisableInterrupts:1;                          /* Bit 2 */
     unsigned int :5;                                   /* Bits 3-7 */
   } Bits;
 }
@@ -3250,7 +3243,7 @@ typedef union DAC960_LP_ErrorStatusRegister
   unsigned char All;
   struct {
     unsigned int :2;                                   /* Bits 0-1 */
-    boolean ErrorStatusPending:1;                      /* Bit 2 */
+    bool ErrorStatusPending:1;                         /* Bit 2 */
     unsigned int :5;                                   /* Bits 3-7 */
   } Bits;
 }
@@ -3313,7 +3306,7 @@ void DAC960_LP_MemoryMailboxNewCommand(void __iomem *ControllerBaseAddress)
 }
 
 static inline
-boolean DAC960_LP_HardwareMailboxFullP(void __iomem *ControllerBaseAddress)
+bool DAC960_LP_HardwareMailboxFullP(void __iomem *ControllerBaseAddress)
 {
   DAC960_LP_InboundDoorBellRegister_T InboundDoorBellRegister;
   InboundDoorBellRegister.All =
@@ -3322,7 +3315,7 @@ boolean DAC960_LP_HardwareMailboxFullP(void __iomem *ControllerBaseAddress)
 }
 
 static inline
-boolean DAC960_LP_InitializationInProgressP(void __iomem *ControllerBaseAddress)
+bool DAC960_LP_InitializationInProgressP(void __iomem *ControllerBaseAddress)
 {
   DAC960_LP_InboundDoorBellRegister_T InboundDoorBellRegister;
   InboundDoorBellRegister.All =
@@ -3362,7 +3355,7 @@ void DAC960_LP_AcknowledgeInterrupt(void __iomem *ControllerBaseAddress)
 }
 
 static inline
-boolean DAC960_LP_HardwareMailboxStatusAvailableP(void __iomem *ControllerBaseAddress)
+bool DAC960_LP_HardwareMailboxStatusAvailableP(void __iomem *ControllerBaseAddress)
 {
   DAC960_LP_OutboundDoorBellRegister_T OutboundDoorBellRegister;
   OutboundDoorBellRegister.All =
@@ -3371,7 +3364,7 @@ boolean DAC960_LP_HardwareMailboxStatusAvailableP(void __iomem *ControllerBaseAd
 }
 
 static inline
-boolean DAC960_LP_MemoryMailboxStatusAvailableP(void __iomem *ControllerBaseAddress)
+bool DAC960_LP_MemoryMailboxStatusAvailableP(void __iomem *ControllerBaseAddress)
 {
   DAC960_LP_OutboundDoorBellRegister_T OutboundDoorBellRegister;
   OutboundDoorBellRegister.All =
@@ -3400,7 +3393,7 @@ void DAC960_LP_DisableInterrupts(void __iomem *ControllerBaseAddress)
 }
 
 static inline
-boolean DAC960_LP_InterruptsEnabledP(void __iomem *ControllerBaseAddress)
+bool DAC960_LP_InterruptsEnabledP(void __iomem *ControllerBaseAddress)
 {
   DAC960_LP_InterruptMaskRegister_T InterruptMaskRegister;
   InterruptMaskRegister.All =
@@ -3442,7 +3435,7 @@ DAC960_LP_ReadCommandStatus(void __iomem *ControllerBaseAddress)
   return readw(ControllerBaseAddress + DAC960_LP_CommandStatusOffset + 2);
 }
 
-static inline boolean
+static inline bool
 DAC960_LP_ReadErrorStatus(void __iomem *ControllerBaseAddress,
                          unsigned char *ErrorStatus,
                          unsigned char *Parameter0,
@@ -3502,16 +3495,16 @@ typedef union DAC960_LA_InboundDoorBellRegister
 {
   unsigned char All;
   struct {
-    boolean HardwareMailboxNewCommand:1;               /* Bit 0 */
-    boolean AcknowledgeHardwareMailboxStatus:1;                /* Bit 1 */
-    boolean GenerateInterrupt:1;                       /* Bit 2 */
-    boolean ControllerReset:1;                         /* Bit 3 */
-    boolean MemoryMailboxNewCommand:1;                 /* Bit 4 */
+    bool HardwareMailboxNewCommand:1;                  /* Bit 0 */
+    bool AcknowledgeHardwareMailboxStatus:1;           /* Bit 1 */
+    bool GenerateInterrupt:1;                          /* Bit 2 */
+    bool ControllerReset:1;                            /* Bit 3 */
+    bool MemoryMailboxNewCommand:1;                    /* Bit 4 */
     unsigned char :3;                                  /* Bits 5-7 */
   } Write;
   struct {
-    boolean HardwareMailboxEmpty:1;                    /* Bit 0 */
-    boolean InitializationNotInProgress:1;             /* Bit 1 */
+    bool HardwareMailboxEmpty:1;                       /* Bit 0 */
+    bool InitializationNotInProgress:1;                /* Bit 1 */
     unsigned char :6;                                  /* Bits 2-7 */
   } Read;
 }
@@ -3526,13 +3519,13 @@ typedef union DAC960_LA_OutboundDoorBellRegister
 {
   unsigned char All;
   struct {
-    boolean AcknowledgeHardwareMailboxInterrupt:1;     /* Bit 0 */
-    boolean AcknowledgeMemoryMailboxInterrupt:1;       /* Bit 1 */
+    bool AcknowledgeHardwareMailboxInterrupt:1;                /* Bit 0 */
+    bool AcknowledgeMemoryMailboxInterrupt:1;          /* Bit 1 */
     unsigned char :6;                                  /* Bits 2-7 */
   } Write;
   struct {
-    boolean HardwareMailboxStatusAvailable:1;          /* Bit 0 */
-    boolean MemoryMailboxStatusAvailable:1;            /* Bit 1 */
+    bool HardwareMailboxStatusAvailable:1;             /* Bit 0 */
+    bool MemoryMailboxStatusAvailable:1;               /* Bit 1 */
     unsigned char :6;                                  /* Bits 2-7 */
   } Read;
 }
@@ -3548,7 +3541,7 @@ typedef union DAC960_LA_InterruptMaskRegister
   unsigned char All;
   struct {
     unsigned char :2;                                  /* Bits 0-1 */
-    boolean DisableInterrupts:1;                       /* Bit 2 */
+    bool DisableInterrupts:1;                          /* Bit 2 */
     unsigned char :5;                                  /* Bits 3-7 */
   } Bits;
 }
@@ -3564,7 +3557,7 @@ typedef union DAC960_LA_ErrorStatusRegister
   unsigned char All;
   struct {
     unsigned int :2;                                   /* Bits 0-1 */
-    boolean ErrorStatusPending:1;                      /* Bit 2 */
+    bool ErrorStatusPending:1;                         /* Bit 2 */
     unsigned int :5;                                   /* Bits 3-7 */
   } Bits;
 }
@@ -3627,7 +3620,7 @@ void DAC960_LA_MemoryMailboxNewCommand(void __iomem *ControllerBaseAddress)
 }
 
 static inline
-boolean DAC960_LA_HardwareMailboxFullP(void __iomem *ControllerBaseAddress)
+bool DAC960_LA_HardwareMailboxFullP(void __iomem *ControllerBaseAddress)
 {
   DAC960_LA_InboundDoorBellRegister_T InboundDoorBellRegister;
   InboundDoorBellRegister.All =
@@ -3636,7 +3629,7 @@ boolean DAC960_LA_HardwareMailboxFullP(void __iomem *ControllerBaseAddress)
 }
 
 static inline
-boolean DAC960_LA_InitializationInProgressP(void __iomem *ControllerBaseAddress)
+bool DAC960_LA_InitializationInProgressP(void __iomem *ControllerBaseAddress)
 {
   DAC960_LA_InboundDoorBellRegister_T InboundDoorBellRegister;
   InboundDoorBellRegister.All =
@@ -3676,7 +3669,7 @@ void DAC960_LA_AcknowledgeInterrupt(void __iomem *ControllerBaseAddress)
 }
 
 static inline
-boolean DAC960_LA_HardwareMailboxStatusAvailableP(void __iomem *ControllerBaseAddress)
+bool DAC960_LA_HardwareMailboxStatusAvailableP(void __iomem *ControllerBaseAddress)
 {
   DAC960_LA_OutboundDoorBellRegister_T OutboundDoorBellRegister;
   OutboundDoorBellRegister.All =
@@ -3685,7 +3678,7 @@ boolean DAC960_LA_HardwareMailboxStatusAvailableP(void __iomem *ControllerBaseAd
 }
 
 static inline
-boolean DAC960_LA_MemoryMailboxStatusAvailableP(void __iomem *ControllerBaseAddress)
+bool DAC960_LA_MemoryMailboxStatusAvailableP(void __iomem *ControllerBaseAddress)
 {
   DAC960_LA_OutboundDoorBellRegister_T OutboundDoorBellRegister;
   OutboundDoorBellRegister.All =
@@ -3714,7 +3707,7 @@ void DAC960_LA_DisableInterrupts(void __iomem *ControllerBaseAddress)
 }
 
 static inline
-boolean DAC960_LA_InterruptsEnabledP(void __iomem *ControllerBaseAddress)
+bool DAC960_LA_InterruptsEnabledP(void __iomem *ControllerBaseAddress)
 {
   DAC960_LA_InterruptMaskRegister_T InterruptMaskRegister;
   InterruptMaskRegister.All =
@@ -3763,7 +3756,7 @@ DAC960_LA_ReadStatusRegister(void __iomem *ControllerBaseAddress)
   return readw(ControllerBaseAddress + DAC960_LA_StatusRegisterOffset);
 }
 
-static inline boolean
+static inline bool
 DAC960_LA_ReadErrorStatus(void __iomem *ControllerBaseAddress,
                          unsigned char *ErrorStatus,
                          unsigned char *Parameter0,
@@ -3822,16 +3815,16 @@ typedef union DAC960_PG_InboundDoorBellRegister
 {
   unsigned int All;
   struct {
-    boolean HardwareMailboxNewCommand:1;               /* Bit 0 */
-    boolean AcknowledgeHardwareMailboxStatus:1;                /* Bit 1 */
-    boolean GenerateInterrupt:1;                       /* Bit 2 */
-    boolean ControllerReset:1;                         /* Bit 3 */
-    boolean MemoryMailboxNewCommand:1;                 /* Bit 4 */
+    bool HardwareMailboxNewCommand:1;                  /* Bit 0 */
+    bool AcknowledgeHardwareMailboxStatus:1;           /* Bit 1 */
+    bool GenerateInterrupt:1;                          /* Bit 2 */
+    bool ControllerReset:1;                            /* Bit 3 */
+    bool MemoryMailboxNewCommand:1;                    /* Bit 4 */
     unsigned int :27;                                  /* Bits 5-31 */
   } Write;
   struct {
-    boolean HardwareMailboxFull:1;                     /* Bit 0 */
-    boolean InitializationInProgress:1;                        /* Bit 1 */
+    bool HardwareMailboxFull:1;                                /* Bit 0 */
+    bool InitializationInProgress:1;                   /* Bit 1 */
     unsigned int :30;                                  /* Bits 2-31 */
   } Read;
 }
@@ -3846,13 +3839,13 @@ typedef union DAC960_PG_OutboundDoorBellRegister
 {
   unsigned int All;
   struct {
-    boolean AcknowledgeHardwareMailboxInterrupt:1;     /* Bit 0 */
-    boolean AcknowledgeMemoryMailboxInterrupt:1;       /* Bit 1 */
+    bool AcknowledgeHardwareMailboxInterrupt:1;                /* Bit 0 */
+    bool AcknowledgeMemoryMailboxInterrupt:1;          /* Bit 1 */
     unsigned int :30;                                  /* Bits 2-31 */
   } Write;
   struct {
-    boolean HardwareMailboxStatusAvailable:1;          /* Bit 0 */
-    boolean MemoryMailboxStatusAvailable:1;            /* Bit 1 */
+    bool HardwareMailboxStatusAvailable:1;             /* Bit 0 */
+    bool MemoryMailboxStatusAvailable:1;               /* Bit 1 */
     unsigned int :30;                                  /* Bits 2-31 */
   } Read;
 }
@@ -3868,7 +3861,7 @@ typedef union DAC960_PG_InterruptMaskRegister
   unsigned int All;
   struct {
     unsigned int MessageUnitInterruptMask1:2;          /* Bits 0-1 */
-    boolean DisableInterrupts:1;                       /* Bit 2 */
+    bool DisableInterrupts:1;                          /* Bit 2 */
     unsigned int MessageUnitInterruptMask2:5;          /* Bits 3-7 */
     unsigned int Reserved0:24;                         /* Bits 8-31 */
   } Bits;
@@ -3885,7 +3878,7 @@ typedef union DAC960_PG_ErrorStatusRegister
   unsigned char All;
   struct {
     unsigned int :2;                                   /* Bits 0-1 */
-    boolean ErrorStatusPending:1;                      /* Bit 2 */
+    bool ErrorStatusPending:1;                         /* Bit 2 */
     unsigned int :5;                                   /* Bits 3-7 */
   } Bits;
 }
@@ -3948,7 +3941,7 @@ void DAC960_PG_MemoryMailboxNewCommand(void __iomem *ControllerBaseAddress)
 }
 
 static inline
-boolean DAC960_PG_HardwareMailboxFullP(void __iomem *ControllerBaseAddress)
+bool DAC960_PG_HardwareMailboxFullP(void __iomem *ControllerBaseAddress)
 {
   DAC960_PG_InboundDoorBellRegister_T InboundDoorBellRegister;
   InboundDoorBellRegister.All =
@@ -3957,7 +3950,7 @@ boolean DAC960_PG_HardwareMailboxFullP(void __iomem *ControllerBaseAddress)
 }
 
 static inline
-boolean DAC960_PG_InitializationInProgressP(void __iomem *ControllerBaseAddress)
+bool DAC960_PG_InitializationInProgressP(void __iomem *ControllerBaseAddress)
 {
   DAC960_PG_InboundDoorBellRegister_T InboundDoorBellRegister;
   InboundDoorBellRegister.All =
@@ -3997,7 +3990,7 @@ void DAC960_PG_AcknowledgeInterrupt(void __iomem *ControllerBaseAddress)
 }
 
 static inline
-boolean DAC960_PG_HardwareMailboxStatusAvailableP(void __iomem *ControllerBaseAddress)
+bool DAC960_PG_HardwareMailboxStatusAvailableP(void __iomem *ControllerBaseAddress)
 {
   DAC960_PG_OutboundDoorBellRegister_T OutboundDoorBellRegister;
   OutboundDoorBellRegister.All =
@@ -4006,7 +3999,7 @@ boolean DAC960_PG_HardwareMailboxStatusAvailableP(void __iomem *ControllerBaseAd
 }
 
 static inline
-boolean DAC960_PG_MemoryMailboxStatusAvailableP(void __iomem *ControllerBaseAddress)
+bool DAC960_PG_MemoryMailboxStatusAvailableP(void __iomem *ControllerBaseAddress)
 {
   DAC960_PG_OutboundDoorBellRegister_T OutboundDoorBellRegister;
   OutboundDoorBellRegister.All =
@@ -4039,7 +4032,7 @@ void DAC960_PG_DisableInterrupts(void __iomem *ControllerBaseAddress)
 }
 
 static inline
-boolean DAC960_PG_InterruptsEnabledP(void __iomem *ControllerBaseAddress)
+bool DAC960_PG_InterruptsEnabledP(void __iomem *ControllerBaseAddress)
 {
   DAC960_PG_InterruptMaskRegister_T InterruptMaskRegister;
   InterruptMaskRegister.All =
@@ -4088,7 +4081,7 @@ DAC960_PG_ReadStatusRegister(void __iomem *ControllerBaseAddress)
   return readw(ControllerBaseAddress + DAC960_PG_StatusRegisterOffset);
 }
 
-static inline boolean
+static inline bool
 DAC960_PG_ReadErrorStatus(void __iomem *ControllerBaseAddress,
                          unsigned char *ErrorStatus,
                          unsigned char *Parameter0,
@@ -4147,15 +4140,15 @@ typedef union DAC960_PD_InboundDoorBellRegister
 {
   unsigned char All;
   struct {
-    boolean NewCommand:1;                              /* Bit 0 */
-    boolean AcknowledgeStatus:1;                       /* Bit 1 */
-    boolean GenerateInterrupt:1;                       /* Bit 2 */
-    boolean ControllerReset:1;                         /* Bit 3 */
+    bool NewCommand:1;                                 /* Bit 0 */
+    bool AcknowledgeStatus:1;                          /* Bit 1 */
+    bool GenerateInterrupt:1;                          /* Bit 2 */
+    bool ControllerReset:1;                            /* Bit 3 */
     unsigned char :4;                                  /* Bits 4-7 */
   } Write;
   struct {
-    boolean MailboxFull:1;                             /* Bit 0 */
-    boolean InitializationInProgress:1;                        /* Bit 1 */
+    bool MailboxFull:1;                                        /* Bit 0 */
+    bool InitializationInProgress:1;                   /* Bit 1 */
     unsigned char :6;                                  /* Bits 2-7 */
   } Read;
 }
@@ -4170,11 +4163,11 @@ typedef union DAC960_PD_OutboundDoorBellRegister
 {
   unsigned char All;
   struct {
-    boolean AcknowledgeInterrupt:1;                    /* Bit 0 */
+    bool AcknowledgeInterrupt:1;                       /* Bit 0 */
     unsigned char :7;                                  /* Bits 1-7 */
   } Write;
   struct {
-    boolean StatusAvailable:1;                         /* Bit 0 */
+    bool StatusAvailable:1;                            /* Bit 0 */
     unsigned char :7;                                  /* Bits 1-7 */
   } Read;
 }
@@ -4189,7 +4182,7 @@ typedef union DAC960_PD_InterruptEnableRegister
 {
   unsigned char All;
   struct {
-    boolean EnableInterrupts:1;                                /* Bit 0 */
+    bool EnableInterrupts:1;                           /* Bit 0 */
     unsigned char :7;                                  /* Bits 1-7 */
   } Bits;
 }
@@ -4205,7 +4198,7 @@ typedef union DAC960_PD_ErrorStatusRegister
   unsigned char All;
   struct {
     unsigned int :2;                                   /* Bits 0-1 */
-    boolean ErrorStatusPending:1;                      /* Bit 2 */
+    bool ErrorStatusPending:1;                         /* Bit 2 */
     unsigned int :5;                                   /* Bits 3-7 */
   } Bits;
 }
@@ -4258,7 +4251,7 @@ void DAC960_PD_ControllerReset(void __iomem *ControllerBaseAddress)
 }
 
 static inline
-boolean DAC960_PD_MailboxFullP(void __iomem *ControllerBaseAddress)
+bool DAC960_PD_MailboxFullP(void __iomem *ControllerBaseAddress)
 {
   DAC960_PD_InboundDoorBellRegister_T InboundDoorBellRegister;
   InboundDoorBellRegister.All =
@@ -4267,7 +4260,7 @@ boolean DAC960_PD_MailboxFullP(void __iomem *ControllerBaseAddress)
 }
 
 static inline
-boolean DAC960_PD_InitializationInProgressP(void __iomem *ControllerBaseAddress)
+bool DAC960_PD_InitializationInProgressP(void __iomem *ControllerBaseAddress)
 {
   DAC960_PD_InboundDoorBellRegister_T InboundDoorBellRegister;
   InboundDoorBellRegister.All =
@@ -4286,7 +4279,7 @@ void DAC960_PD_AcknowledgeInterrupt(void __iomem *ControllerBaseAddress)
 }
 
 static inline
-boolean DAC960_PD_StatusAvailableP(void __iomem *ControllerBaseAddress)
+bool DAC960_PD_StatusAvailableP(void __iomem *ControllerBaseAddress)
 {
   DAC960_PD_OutboundDoorBellRegister_T OutboundDoorBellRegister;
   OutboundDoorBellRegister.All =
@@ -4315,7 +4308,7 @@ void DAC960_PD_DisableInterrupts(void __iomem *ControllerBaseAddress)
 }
 
 static inline
-boolean DAC960_PD_InterruptsEnabledP(void __iomem *ControllerBaseAddress)
+bool DAC960_PD_InterruptsEnabledP(void __iomem *ControllerBaseAddress)
 {
   DAC960_PD_InterruptEnableRegister_T InterruptEnableRegister;
   InterruptEnableRegister.All =
@@ -4350,7 +4343,7 @@ DAC960_PD_ReadStatusRegister(void __iomem *ControllerBaseAddress)
   return readw(ControllerBaseAddress + DAC960_PD_StatusRegisterOffset);
 }
 
-static inline boolean
+static inline bool
 DAC960_PD_ReadErrorStatus(void __iomem *ControllerBaseAddress,
                          unsigned char *ErrorStatus,
                          unsigned char *Parameter0,
index 58c1debf86f1c7271ed84bce7cf1ea097c878725..cacb1c816e355503757c84c745d00f9a3c81e185 100644 (file)
@@ -417,8 +417,10 @@ config BLK_DEV_INITRD
          etc. See <file:Documentation/initrd.txt> for details.
 
          If RAM disk support (BLK_DEV_RAM) is also included, this
-         also enables initial RAM disk (initrd) support.
+         also enables initial RAM disk (initrd) support and adds
+         15 Kbytes (more on some other architectures) to the kernel size.
 
+         If unsure say Y.
 
 config CDROM_PKTCDVD
        tristate "Packet writing on CD/DVD media"
index c0d2854dd097e8b9bb4673d14923d5eb778d1391..28cf3082d4423fa4e0b0727ecc02ef61a1f27fa7 100644 (file)
@@ -2,14 +2,8 @@
 # PARIDE configuration
 #
 # PARIDE doesn't need PARPORT, but if PARPORT is configured as a module,
-# PARIDE must also be a module.  The bogus CONFIG_PARIDE_PARPORT option
-# controls the choices given to the user ...
+# PARIDE must also be a module.
 # PARIDE only supports PC style parports. Tough for USB or other parports...
-config PARIDE_PARPORT
-       tristate
-       depends on PARIDE!=n
-       default m if PARPORT_PC=m
-       default y if PARPORT_PC!=m
 
 comment "Parallel IDE high-level drivers"
        depends on PARIDE
index 62462190e07e877634053cf20e41643c8ea227cf..c0e89490e3d5c97427eaf2eeb15c42bb672b037f 100644 (file)
@@ -190,15 +190,6 @@ static struct attribute *kobj_pkt_attrs_wqueue[] = {
        NULL
 };
 
-/* declares a char buffer[64] _dbuf, copies data from
- * _b with length _l into it and ensures that _dbuf ends
- * with a \0 character.
- */
-#define DECLARE_BUF_AS_STRING(_dbuf, _b, _l) \
-       char _dbuf[64]; int dlen = (_l) < 0 ? 0 : (_l); \
-       if (dlen >= sizeof(_dbuf)) dlen = sizeof(_dbuf)-1; \
-       memcpy(_dbuf, _b, dlen); _dbuf[dlen] = 0
-
 static ssize_t kobj_pkt_show(struct kobject *kobj,
                        struct attribute *attr, char *data)
 {
@@ -264,9 +255,8 @@ static ssize_t kobj_pkt_store(struct kobject *kobj,
 {
        struct pktcdvd_device *pd = to_pktcdvdkobj(kobj)->pd;
        int val;
-       DECLARE_BUF_AS_STRING(dbuf, data, len); /* ensure sscanf scans a string */
 
-       if (strcmp(attr->name, "reset") == 0 && dlen > 0) {
+       if (strcmp(attr->name, "reset") == 0 && len > 0) {
                pd->stats.pkt_started = 0;
                pd->stats.pkt_ended = 0;
                pd->stats.secs_w = 0;
@@ -274,7 +264,7 @@ static ssize_t kobj_pkt_store(struct kobject *kobj,
                pd->stats.secs_r = 0;
 
        } else if (strcmp(attr->name, "congestion_off") == 0
-                  && sscanf(dbuf, "%d", &val) == 1) {
+                  && sscanf(data, "%d", &val) == 1) {
                spin_lock(&pd->lock);
                pd->write_congestion_off = val;
                init_write_congestion_marks(&pd->write_congestion_off,
@@ -282,7 +272,7 @@ static ssize_t kobj_pkt_store(struct kobject *kobj,
                spin_unlock(&pd->lock);
 
        } else if (strcmp(attr->name, "congestion_on") == 0
-                  && sscanf(dbuf, "%d", &val) == 1) {
+                  && sscanf(data, "%d", &val) == 1) {
                spin_lock(&pd->lock);
                pd->write_congestion_on = val;
                init_write_congestion_marks(&pd->write_congestion_off,
@@ -369,8 +359,7 @@ static ssize_t class_pktcdvd_store_add(struct class *c, const char *buf,
                                        size_t count)
 {
        unsigned int major, minor;
-       DECLARE_BUF_AS_STRING(dbuf, buf, count);
-       if (sscanf(dbuf, "%u:%u", &major, &minor) == 2) {
+       if (sscanf(buf, "%u:%u", &major, &minor) == 2) {
                pkt_setup_dev(MKDEV(major, minor), NULL);
                return count;
        }
@@ -381,8 +370,7 @@ static ssize_t class_pktcdvd_store_remove(struct class *c, const char *buf,
                                        size_t count)
 {
        unsigned int major, minor;
-       DECLARE_BUF_AS_STRING(dbuf, buf, count);
-       if (sscanf(dbuf, "%u:%u", &major, &minor) == 2) {
+       if (sscanf(buf, "%u:%u", &major, &minor) == 2) {
                pkt_remove_dev(MKDEV(major, minor));
                return count;
        }
@@ -1377,7 +1365,7 @@ try_next_bio:
                        && pd->bio_queue_size <= pd->write_congestion_off);
        spin_unlock(&pd->lock);
        if (wakeup)
-               blk_clear_queue_congested(pd->disk->queue, WRITE);
+               clear_bdi_congested(&pd->disk->queue->backing_dev_info, WRITE);
 
        pkt->sleep_time = max(PACKET_WAIT_TIME, 1);
        pkt_set_state(pkt, PACKET_WAITING_STATE);
@@ -2598,7 +2586,7 @@ static int pkt_make_request(request_queue_t *q, struct bio *bio)
        spin_lock(&pd->lock);
        if (pd->write_congestion_on > 0
            && pd->bio_queue_size >= pd->write_congestion_on) {
-               blk_set_queue_congested(q, WRITE);
+               set_bdi_congested(&q->backing_dev_info, WRITE);
                do {
                        spin_unlock(&pd->lock);
                        congestion_wait(WRITE, HZ);
index d08bb4ee130751efee0b36bb4b380d491064b28f..d0a6dc53213c00ecb5e22c7b5933c9789c195e30 100644 (file)
@@ -191,7 +191,7 @@ config MOXA_INTELLIO
          module will be called moxa.
 
 config MOXA_SMARTIO
-       tristate "Moxa SmartIO support"
+       tristate "Moxa SmartIO support (OBSOLETE)"
        depends on SERIAL_NONSTANDARD
        help
          Say Y here if you have a Moxa SmartIO multiport serial card.
@@ -202,7 +202,7 @@ config MOXA_SMARTIO
          here.
 
 config MOXA_SMARTIO_NEW
-       tristate "Moxa SmartIO support v. 2.0 (EXPERIMENTAL)"
+       tristate "Moxa SmartIO support v. 2.0"
        depends on SERIAL_NONSTANDARD && (PCI || EISA || ISA)
        help
          Say Y here if you have a Moxa SmartIO multiport serial card and/or
index 0326ca1a848a10e492740bf8e7e3baf0cd992d3d..ae8567cc529c3bd998d57ea2d8efaa3018ece311 100644 (file)
@@ -60,6 +60,8 @@ obj-$(CONFIG_BRIQ_PANEL)      += briq_panel.o
 obj-$(CONFIG_PRINTER)          += lp.o
 obj-$(CONFIG_TIPAR)            += tipar.o
 
+obj-$(CONFIG_APM_EMULATION)    += apm-emulation.o
+
 obj-$(CONFIG_DTLK)             += dtlk.o
 obj-$(CONFIG_R3964)            += n_r3964.o
 obj-$(CONFIG_APPLICOM)         += applicom.o
index feb4ac802a0d1e44f8fef6d24a7e7638a0d3b563..0e2b72f2b8871d96f124581bba1ee724c2f936c0 100644 (file)
@@ -527,10 +527,8 @@ static void do_softint(unsigned long private_)
        if (!tty)
                return;
 
-       if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP, &info->event)) {
+       if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP, &info->event))
                tty_wakeup(tty);
-               wake_up_interruptible(&tty->write_wait);
-       }
 }
 
 /*
@@ -904,8 +902,7 @@ static int rs_write(struct tty_struct * tty, const unsigned char *buf, int count
        if (!info->xmit.buf)
                return 0;
 
-       local_save_flags(flags);
-       local_irq_disable();
+       local_irq_save(flags);
        while (1) {
                c = CIRC_SPACE_TO_END(info->xmit.head,
                                      info->xmit.tail,
@@ -968,7 +965,6 @@ static void rs_flush_buffer(struct tty_struct *tty)
        local_irq_save(flags);
        info->xmit.head = info->xmit.tail = 0;
        local_irq_restore(flags);
-       wake_up_interruptible(&tty->write_wait);
        tty_wakeup(tty);
 }
 
similarity index 99%
rename from arch/arm/kernel/apm.c
rename to drivers/char/apm-emulation.c
index 2c37b70b17ab45087ff7c43d30aea6006d3f4e81..179c7a3b6e750390d1fad74211d3b5e8d42fec1d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * bios-less APM driver for ARM Linux 
+ * bios-less APM driver for ARM Linux
  *  Jamey Hicks <jamey@crl.dec.com>
  *  adapted from the APM BIOS driver for Linux by Stephen Rothwell (sfr@linuxcare.com)
  *
@@ -19,6 +19,7 @@
 #include <linux/capability.h>
 #include <linux/sched.h>
 #include <linux/pm.h>
+#include <linux/apm-emulation.h>
 #include <linux/device.h>
 #include <linux/kernel.h>
 #include <linux/list.h>
@@ -27,7 +28,6 @@
 #include <linux/kthread.h>
 #include <linux/delay.h>
 
-#include <asm/apm.h> /* apm_power_info */
 #include <asm/system.h>
 
 /*
@@ -225,7 +225,7 @@ static void apm_suspend(void)
        list_for_each_entry(as, &apm_user_list, list) {
                if (as->suspend_state == SUSPEND_WAIT ||
                    as->suspend_state == SUSPEND_ACKED) {
-                       as->suspend_result = err;
+                       as->suspend_result = err;
                        as->suspend_state = SUSPEND_DONE;
                }
        }
@@ -529,7 +529,7 @@ static int apm_get_info(char *buf, char **start, off_t fpos, int length)
                     info.battery_flag, info.battery_life,
                     info.time, units);
 
-       return ret;
+       return ret;
 }
 #endif
 
index 3ffa0807754c34313f9288299552f97df2c8468f..363beb16572911ff18963e0eae785318e58890ae 100644 (file)
@@ -4488,7 +4488,6 @@ static void cy_flush_buffer(struct tty_struct *tty)
                CY_UNLOCK(info, flags);
        }
        tty_wakeup(tty);
-       wake_up_interruptible(&tty->write_wait);
 }                              /* cy_flush_buffer */
 
 /*
index a0f822c9d74def65e14f97fb319d782b305ef19d..88fc24fc43928674ef24647a394a2348cd18c082 100644 (file)
@@ -844,7 +844,6 @@ static void pc_flush_buffer(struct tty_struct *tty)
        fepcmd(ch, STOUT, (unsigned) tail, 0, 0, 0);
        memoff(ch);
        spin_unlock_irqrestore(&epca_lock, flags);
-       wake_up_interruptible(&tty->write_wait);
        tty_wakeup(tty);
 } /* End pc_flush_buffer */
 
@@ -1795,7 +1794,6 @@ static void doevent(int crd)
                                { /* Begin if LOWWAIT */
                                        ch->statusflags &= ~LOWWAIT;
                                        tty_wakeup(tty);
-                                       wake_up_interruptible(&tty->write_wait);
                                } /* End if LOWWAIT */
                        } else if (event & EMPTYTX_IND)  { /* Begin EMPTYTX_IND */
                                /* This event is generated by setup_empty_event */
@@ -1803,7 +1801,6 @@ static void doevent(int crd)
                                if (ch->statusflags & EMPTYWAIT)  { /* Begin if EMPTYWAIT */
                                        ch->statusflags &= ~EMPTYWAIT;
                                        tty_wakeup(tty);
-                                       wake_up_interruptible(&tty->write_wait);
                                } /* End if EMPTYWAIT */
                        } /* End EMPTYTX_IND */
                } /* End if valid tty */
index e769811e74172d36bff0d845a9fab7327299b158..337bbcdcf13dfb84642ea646c975bc7abe99a07c 100644 (file)
@@ -382,7 +382,6 @@ void gs_flush_buffer(struct tty_struct *tty)
        port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
        spin_unlock_irqrestore (&port->driver_lock, flags);
 
-       wake_up_interruptible(&tty->write_wait);
        tty_wakeup(tty);
        func_exit ();
 }
index 78045767ec33691d7b8b89770c00f5f39b935f48..88b9d338da5352bb5acd5be3222c95aa3b6c479a 100644 (file)
@@ -1373,15 +1373,7 @@ ip2_owake( PTTY tp)
        ip2trace (CHANN, ITRC_SICMD, 10, 2, tp->flags,
                        (1 << TTY_DO_WRITE_WAKEUP) );
 
-       wake_up_interruptible ( &tp->write_wait );
-       if ( ( tp->flags & (1 << TTY_DO_WRITE_WAKEUP) ) 
-         && tp->ldisc.write_wakeup )
-       {
-               (tp->ldisc.write_wakeup) ( tp );
-
-               ip2trace (CHANN, ITRC_SICMD, 11, 0 );
-
-       }
+       tty_wakeup(tp);
 }
 
 static inline void
index 53582b53da95c449a9cb730f1b93734793139c30..3aff5e99b674360bad4fa42407d70a9d594656e4 100644 (file)
@@ -406,13 +406,14 @@ static void clean_up_interface_data(ipmi_smi_t intf)
        free_smi_msg_list(&intf->waiting_msgs);
        free_recv_msg_list(&intf->waiting_events);
 
-       /* Wholesale remove all the entries from the list in the
-        * interface and wait for RCU to know that none are in use. */
+       /*
+        * Wholesale remove all the entries from the list in the
+        * interface and wait for RCU to know that none are in use.
+        */
        mutex_lock(&intf->cmd_rcvrs_mutex);
-       list_add_rcu(&list, &intf->cmd_rcvrs);
-       list_del_rcu(&intf->cmd_rcvrs);
+       INIT_LIST_HEAD(&list);
+       list_splice_init_rcu(&intf->cmd_rcvrs, &list, synchronize_rcu);
        mutex_unlock(&intf->cmd_rcvrs_mutex);
-       synchronize_rcu();
 
        list_for_each_entry_safe(rcvr, rcvr2, &list, link)
                kfree(rcvr);
@@ -451,7 +452,7 @@ int ipmi_smi_watcher_register(struct ipmi_smi_watcher *watcher)
        mutex_lock(&ipmi_interfaces_mutex);
 
        /* Build a list of things to deliver. */
-       list_for_each_entry_rcu(intf, &ipmi_interfaces, link) {
+       list_for_each_entry(intf, &ipmi_interfaces, link) {
                if (intf->intf_num == -1)
                        continue;
                e = kmalloc(sizeof(*e), GFP_KERNEL);
@@ -1886,7 +1887,6 @@ int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name,
                kfree(entry);
                rv = -ENOMEM;
        } else {
-               file->nlink = 1;
                file->data = data;
                file->read_proc = read_proc;
                file->write_proc = write_proc;
@@ -2760,9 +2760,15 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
                synchronize_rcu();
                kref_put(&intf->refcount, intf_free);
        } else {
-               /* After this point the interface is legal to use. */
+               /*
+                * Keep memory order straight for RCU readers.  Make
+                * sure everything else is committed to memory before
+                * setting intf_num to mark the interface valid.
+                */
+               smp_wmb();
                intf->intf_num = i;
                mutex_unlock(&ipmi_interfaces_mutex);
+               /* After this point the interface is legal to use. */
                call_smi_watchers(i, intf->si_dev);
                mutex_unlock(&smi_watchers_mutex);
        }
@@ -3923,6 +3929,14 @@ static void send_panic_events(char *str)
                        /* Interface was not ready yet. */
                        continue;
 
+               /*
+                * intf_num is used as an marker to tell if the
+                * interface is valid.  Thus we need a read barrier to
+                * make sure data fetched before checking intf_num
+                * won't be used.
+                */
+               smp_rmb();
+
                /* First job here is to figure out where to send the
                   OEM events.  There's no way in IPMI to send OEM
                   events using an event send command, so we have to
index 01084abffddf66070e1c5b97847e8fc893f59f16..43ab9edc76f540ce254f07f827e00414bd70abc2 100644 (file)
@@ -183,7 +183,7 @@ static DEFINE_TIMER(tx, isicom_tx, 0, 0);
 /*   baud index mappings from linux defns to isi */
 
 static signed char linuxb_to_isib[] = {
-       -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 13, 15, 16, 17, 18, 19
+       -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 13, 15, 16, 17, 18, 19, 20, 21
 };
 
 struct isi_board {
@@ -213,8 +213,6 @@ struct      isi_port {
        struct tty_struct       * tty;
        wait_queue_head_t       close_wait;
        wait_queue_head_t       open_wait;
-       struct work_struct      hangup_tq;
-       struct work_struct      bh_tqueue;
        unsigned char           * xmit_buf;
        int                     xmit_head;
        int                     xmit_tail;
@@ -510,7 +508,7 @@ static void isicom_tx(unsigned long _data)
                if (port->xmit_cnt <= 0)
                        port->status &= ~ISI_TXOK;
                if (port->xmit_cnt <= WAKEUP_CHARS)
-                       schedule_work(&port->bh_tqueue);
+                       tty_wakeup(tty);
                unlock_card(&isi_card[card]);
        }
 
@@ -524,21 +522,6 @@ sched_again:
        mod_timer(&tx, jiffies + msecs_to_jiffies(10));
 }
 
-/*     Interrupt handlers      */
-
-
-static void isicom_bottomhalf(struct work_struct *work)
-{
-       struct isi_port *port = container_of(work, struct isi_port, bh_tqueue);
-       struct tty_struct *tty = port->tty;
-
-       if (!tty)
-               return;
-
-       tty_wakeup(tty);
-       wake_up_interruptible(&tty->write_wait);
-}
-
 /*
  *     Main interrupt handler routine
  */
@@ -557,6 +540,11 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id)
                return IRQ_NONE;
 
        base = card->base;
+
+       /* did the card interrupt us? */
+       if (!(inw(base + 0x0e) & 0x02))
+               return IRQ_NONE;
+
        spin_lock(&card->card_lock);
 
        /*
@@ -581,6 +569,7 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id)
        port = card->ports + channel;
        if (!(port->flags & ASYNC_INITIALIZED)) {
                outw(0x0000, base+0x04); /* enable interrupts */
+               spin_unlock(&card->card_lock);
                return IRQ_HANDLED;
        }
 
@@ -609,7 +598,7 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id)
                                                pr_dbg("interrupt: DCD->low.\n"
                                                        );
                                                port->status &= ~ISI_DCD;
-                                               schedule_work(&port->hangup_tq);
+                                               tty_hangup(tty);
                                        }
                                } else if (header & ISI_DCD) {
                                /* Carrier has been detected */
@@ -631,7 +620,7 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id)
                                                /* start tx ing */
                                                port->status |= (ISI_TXOK
                                                        | ISI_CTS);
-                                               schedule_work(&port->bh_tqueue);
+                                               tty_wakeup(tty);
                                        }
                                } else if (!(header & ISI_CTS)) {
                                        port->tty->hw_stopped = 1;
@@ -695,6 +684,7 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id)
                tty_flip_buffer_push(tty);
        }
        outw(0x0000, base+0x04); /* enable interrupts */
+       spin_unlock(&card->card_lock);
 
        return IRQ_HANDLED;
 }
@@ -720,7 +710,8 @@ static void isicom_config_port(struct isi_port *port)
                 *  respectively.
                 */
 
-               if (baud < 1 || baud > 2)
+               /* 1,2,3,4 => 57.6, 115.2, 230, 460 kbps resp. */
+               if (baud < 1 || baud > 4)
                        port->tty->termios->c_cflag &= ~CBAUDEX;
                else
                        baud += 15;
@@ -736,6 +727,10 @@ static void isicom_config_port(struct isi_port *port)
                        baud++; /*  57.6 Kbps */
                if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
                        baud +=2; /*  115  Kbps */
+               if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
+                       baud += 3; /* 230 kbps*/
+               if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
+                       baud += 4; /* 460 kbps*/
        }
        if (linuxb_to_isib[baud] == -1) {
                /* hang up */
@@ -1460,17 +1455,6 @@ static void isicom_start(struct tty_struct *tty)
        port->status |= ISI_TXOK;
 }
 
-/* hangup et all */
-static void do_isicom_hangup(struct work_struct *work)
-{
-       struct isi_port *port = container_of(work, struct isi_port, hangup_tq);
-       struct tty_struct *tty;
-
-       tty = port->tty;
-       if (tty)
-               tty_hangup(tty);
-}
-
 static void isicom_hangup(struct tty_struct *tty)
 {
        struct isi_port *port = tty->driver_data;
@@ -1503,7 +1487,6 @@ static void isicom_flush_buffer(struct tty_struct *tty)
        port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
        spin_unlock_irqrestore(&card->card_lock, flags);
 
-       wake_up_interruptible(&tty->write_wait);
        tty_wakeup(tty);
 }
 
@@ -1536,7 +1519,7 @@ static int __devinit reset_card(struct pci_dev *pdev,
 {
        struct isi_board *board = pci_get_drvdata(pdev);
        unsigned long base = board->base;
-       unsigned int portcount = 0;
+       unsigned int sig, portcount = 0;
        int retval = 0;
 
        dev_dbg(&pdev->dev, "ISILoad:Resetting Card%d at 0x%lx\n", card + 1,
@@ -1544,27 +1527,35 @@ static int __devinit reset_card(struct pci_dev *pdev,
 
        inw(base + 0x8);
 
-       mdelay(10);
+       msleep(10);
 
        outw(0, base + 0x8); /* Reset */
 
-       msleep(3000);
+       msleep(1000);
 
-       *signature = inw(base + 0x4) & 0xff;
+       sig = inw(base + 0x4) & 0xff;
+
+       if (sig != 0xa5 && sig != 0xbb && sig != 0xcc && sig != 0xdd &&
+                       sig != 0xee) {
+               dev_warn(&pdev->dev, "ISILoad:Card%u reset failure (Possible "
+                       "bad I/O Port Address 0x%lx).\n", card + 1, base);
+               dev_dbg(&pdev->dev, "Sig=0x%x\n", sig);
+               retval = -EIO;
+               goto end;
+       }
+
+       msleep(10);
 
        portcount = inw(base + 0x2);
-       if (!(inw(base + 0xe) & 0x1) || ((portcount != 0) &&
-                       (portcount != 4) && (portcount != 8))) {
-               dev_dbg(&pdev->dev, "base+0x2=0x%lx, base+0xe=0x%lx\n",
-                       inw(base + 0x2), inw(base + 0xe));
-               dev_err(&pdev->dev, "ISILoad:PCI Card%d reset failure "
-                       "(Possible bad I/O Port Address 0x%lx).\n",
-                       card + 1, base);
+       if (!inw(base + 0xe) & 0x1 || (portcount != 0 && portcount != 4 &&
+                               portcount != 8 && portcount != 16)) {
+               dev_err(&pdev->dev, "ISILoad:PCI Card%d reset failure.",
+                       card + 1);
                retval = -EIO;
                goto end;
        }
 
-       switch (*signature) {
+       switch (sig) {
        case 0xa5:
        case 0xbb:
        case 0xdd:
@@ -1572,16 +1563,13 @@ static int __devinit reset_card(struct pci_dev *pdev,
                board->shift_count = 12;
                break;
        case 0xcc:
+       case 0xee:
                board->port_count = 16;
                board->shift_count = 11;
                break;
-       default:
-               dev_warn(&pdev->dev, "ISILoad:Card%d reset failure (Possible "
-                       "bad I/O Port Address 0x%lx).\n", card + 1, base);
-               dev_dbg(&pdev->dev, "Sig=0x%lx\n", signature);
-               retval = -EIO;
        }
        dev_info(&pdev->dev, "-Done\n");
+       *signature = sig;
 
 end:
        return retval;
@@ -1757,7 +1745,7 @@ end:
 /*
  *     Insmod can set static symbols so keep these static
  */
-static int card;
+static unsigned int card_count;
 
 static int __devinit isicom_probe(struct pci_dev *pdev,
        const struct pci_device_id *ent)
@@ -1767,7 +1755,7 @@ static int __devinit isicom_probe(struct pci_dev *pdev,
        u8 pciirq;
        struct isi_board *board = NULL;
 
-       if (card >= BOARD_COUNT)
+       if (card_count >= BOARD_COUNT)
                goto err;
 
        ioaddr = pci_resource_start(pdev, 3);
@@ -1785,7 +1773,7 @@ static int __devinit isicom_probe(struct pci_dev *pdev,
        board->index = index;
        board->base = ioaddr;
        board->irq = pciirq;
-       card++;
+       card_count++;
 
        pci_set_drvdata(pdev, board);
 
@@ -1795,7 +1783,7 @@ static int __devinit isicom_probe(struct pci_dev *pdev,
                        "will be disabled.\n", board->base, board->base + 15,
                        index + 1);
                retval = -EBUSY;
-               goto err;
+               goto errdec;
        }
 
        retval = request_irq(board->irq, isicom_interrupt,
@@ -1824,8 +1812,10 @@ errunri:
        free_irq(board->irq, board);
 errunrr:
        pci_release_region(pdev, 3);
-err:
+errdec:
        board->base = 0;
+       card_count--;
+err:
        return retval;
 }
 
@@ -1839,6 +1829,8 @@ static void __devexit isicom_remove(struct pci_dev *pdev)
 
        free_irq(board->irq, board);
        pci_release_region(pdev, 3);
+       board->base = 0;
+       card_count--;
 }
 
 static int __init isicom_init(void)
@@ -1846,8 +1838,6 @@ static int __init isicom_init(void)
        int retval, idx, channel;
        struct isi_port *port;
 
-       card = 0;
-
        for(idx = 0; idx < BOARD_COUNT; idx++) {
                port = &isi_ports[idx * 16];
                isi_card[idx].ports = port;
@@ -1858,8 +1848,6 @@ static int __init isicom_init(void)
                        port->channel = channel;
                        port->close_delay = 50 * HZ/100;
                        port->closing_wait = 3000 * HZ/100;
-                       INIT_WORK(&port->hangup_tq, do_isicom_hangup);
-                       INIT_WORK(&port->bh_tqueue, isicom_bottomhalf);
                        port->status = 0;
                        init_waitqueue_head(&port->open_wait);
                        init_waitqueue_head(&port->close_wait);
index 68645d35187325baa50e8f5c6aec932469b5d67f..7b279d1de4a2eac8d6781269eb4b52f738d5cc5a 100644 (file)
@@ -2424,7 +2424,6 @@ static int stli_hostcmd(struct stlibrd *brdp, struct stliport *portp)
                        if (tty != NULL) {
                                tty_wakeup(tty);
                                EBRDENABLE(brdp);
-                               wake_up_interruptible(&tty->write_wait);
                        }
                }
 
index 7a6c1c0b7a95861f9e4a70c4d6dca302491e5987..c654a3e0c697b36f008b934a8ed276bb6c110373 100644 (file)
@@ -595,15 +595,9 @@ static void fn_spawn_con(struct vc_data *vc)
 
 static void fn_SAK(struct vc_data *vc)
 {
-       struct tty_struct *tty = vc->vc_tty;
-
-       /*
-        * SAK should also work in all raw modes and reset
-        * them properly.
-        */
-       if (tty)
-               do_SAK(tty);
-       reset_vc(vc);
+       struct work_struct *SAK_work = &vc_cons[fg_console].SAK_work;
+       PREPARE_WORK(SAK_work, vc_SAK);
+       schedule_work(SAK_work);
 }
 
 static void fn_null(struct vc_data *vc)
index f391a24a1b442c1e8eb4aaf1c1857d015dfdc89b..7dbaee8d940296a5617af40e029b39ff2824d4e7 100644 (file)
  *      it under the terms of the GNU General Public License as published by
  *      the Free Software Foundation; either version 2 of the License, or
  *      (at your option) any later version.
- *
- *      This program is distributed in the hope that it will be useful,
- *      but WITHOUT ANY WARRANTY; without even the implied warranty of
- *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *      GNU General Public License for more details.
- *
- *      You should have received a copy of the GNU General Public License
- *      along with this program; if not, write to the Free Software
- *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
 /*
 #include <asm/io.h>
 #include <asm/uaccess.h>
 
-#define                MOXA_VERSION            "5.1k"
+#define MOXA_VERSION           "5.1k"
 
-#define MOXAMAJOR       172
-#define MOXACUMAJOR     173
+#define MOXAMAJOR              172
+#define MOXACUMAJOR            173
 
-#define put_to_user(arg1, arg2) put_user(arg1, (unsigned long *)arg2)
-#define get_from_user(arg1, arg2) get_user(arg1, (unsigned int *)arg2)
-
-#define MAX_BOARDS             4       /* Don't change this value */
+#define MAX_BOARDS             4       /* Don't change this value */
 #define MAX_PORTS_PER_BOARD    32      /* Don't change this value */
-#define MAX_PORTS              128     /* Don't change this value */
+#define MAX_PORTS              (MAX_BOARDS * MAX_PORTS_PER_BOARD)
 
 /*
  *    Define the Moxa PCI vendor and device IDs.
  */
-#define MOXA_BUS_TYPE_ISA              0
-#define MOXA_BUS_TYPE_PCI              1
-
-#ifndef        PCI_VENDOR_ID_MOXA
-#define        PCI_VENDOR_ID_MOXA      0x1393
-#endif
-#ifndef PCI_DEVICE_ID_CP204J
-#define PCI_DEVICE_ID_CP204J   0x2040
-#endif
-#ifndef PCI_DEVICE_ID_C218
-#define PCI_DEVICE_ID_C218     0x2180
-#endif
-#ifndef PCI_DEVICE_ID_C320
-#define PCI_DEVICE_ID_C320     0x3200
-#endif
+#define MOXA_BUS_TYPE_ISA      0
+#define MOXA_BUS_TYPE_PCI      1
 
 enum {
        MOXA_BOARD_C218_PCI = 1,
@@ -105,47 +80,56 @@ static char *moxa_brdname[] =
 
 #ifdef CONFIG_PCI
 static struct pci_device_id moxa_pcibrds[] = {
-       { PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_C218, PCI_ANY_ID, PCI_ANY_ID, 
-         0, 0, MOXA_BOARD_C218_PCI },
-       { PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_C320, PCI_ANY_ID, PCI_ANY_ID, 
-         0, 0, MOXA_BOARD_C320_PCI },
-       { PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_CP204J, PCI_ANY_ID, PCI_ANY_ID, 
-         0, 0, MOXA_BOARD_CP204J },
+       { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_C218),
+               .driver_data = MOXA_BOARD_C218_PCI },
+       { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_C320),
+               .driver_data = MOXA_BOARD_C320_PCI },
+       { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP204J),
+               .driver_data = MOXA_BOARD_CP204J },
        { 0 }
 };
 MODULE_DEVICE_TABLE(pci, moxa_pcibrds);
 #endif /* CONFIG_PCI */
 
-typedef struct _moxa_isa_board_conf {
+struct moxa_isa_board_conf {
        int boardType;
        int numPorts;
        unsigned long baseAddr;
-} moxa_isa_board_conf;
+};
 
-static moxa_isa_board_conf moxa_isa_boards[] =
+static struct moxa_isa_board_conf moxa_isa_boards[] =
 {
 /*       {MOXA_BOARD_C218_ISA,8,0xDC000}, */
 };
 
-typedef struct _moxa_pci_devinfo {
-       ushort busNum;
-       ushort devNum;
-       struct pci_dev *pdev;
-} moxa_pci_devinfo;
-
-typedef struct _moxa_board_conf {
+static struct moxa_board_conf {
        int boardType;
        int numPorts;
        unsigned long baseAddr;
        int busType;
-       moxa_pci_devinfo pciInfo;
-} moxa_board_conf;
 
-static moxa_board_conf moxa_boards[MAX_BOARDS];
-static void __iomem *moxaBaseAddr[MAX_BOARDS];
-static int loadstat[MAX_BOARDS];
+       int loadstat;
+
+       void __iomem *basemem;
+       void __iomem *intNdx;
+       void __iomem *intPend;
+       void __iomem *intTable;
+} moxa_boards[MAX_BOARDS];
+
+struct mxser_mstatus {
+       tcflag_t cflag;
+       int cts;
+       int dsr;
+       int ri;
+       int dcd;
+};
+
+struct moxaq_str {
+       int inq;
+       int outq;
+};
 
-struct moxa_str {
+struct moxa_port {
        int type;
        int port;
        int close_delay;
@@ -159,18 +143,18 @@ struct moxa_str {
        int cflag;
        wait_queue_head_t open_wait;
        wait_queue_head_t close_wait;
-       struct work_struct tqueue;
-};
 
-struct mxser_mstatus {
-       tcflag_t cflag;
-       int cts;
-       int dsr;
-       int ri;
-       int dcd;
-};
+       struct timer_list emptyTimer;
 
-static struct mxser_mstatus GMStatus[MAX_PORTS];
+       char chkPort;
+       char lineCtrl;
+       void __iomem *tableAddr;
+       long curBaud;
+       char DCDState;
+       char lowChkFlag;
+
+       ushort breakCnt;
+};
 
 /* statusflags */
 #define TXSTOPPED      0x1
@@ -178,25 +162,17 @@ static struct mxser_mstatus GMStatus[MAX_PORTS];
 #define EMPTYWAIT      0x4
 #define THROTTLE       0x8
 
-/* event */
-#define MOXA_EVENT_HANGUP      1
-
 #define SERIAL_DO_RESTART
 
-
-#define SERIAL_TYPE_NORMAL     1
-
 #define WAKEUP_CHARS           256
 
-#define PORTNO(x)              ((x)->index)
-
 static int verbose = 0;
 static int ttymajor = MOXAMAJOR;
 /* Variables for insmod */
 #ifdef MODULE
-static int baseaddr[]  =       {0, 0, 0, 0};
-static int type[]      =       {0, 0, 0, 0};
-static int numports[]  =       {0, 0, 0, 0};
+static int baseaddr[4];
+static int type[4];
+static int numports[4];
 #endif
 
 MODULE_AUTHOR("William Chen");
@@ -210,19 +186,9 @@ module_param_array(numports, int, NULL, 0);
 module_param(ttymajor, int, 0);
 module_param(verbose, bool, 0644);
 
-static struct tty_driver *moxaDriver;
-static struct moxa_str moxaChannels[MAX_PORTS];
-static unsigned char *moxaXmitBuff;
-static int moxaTimer_on;
-static struct timer_list moxaTimer;
-static int moxaEmptyTimer_on[MAX_PORTS];
-static struct timer_list moxaEmptyTimer[MAX_PORTS];
-static struct semaphore moxaBuffSem;
-
 /*
  * static functions:
  */
-static void do_moxa_softint(struct work_struct *);
 static int moxa_open(struct tty_struct *, struct file *);
 static void moxa_close(struct tty_struct *, struct file *);
 static int moxa_write(struct tty_struct *, const unsigned char *, int);
@@ -244,11 +210,11 @@ static int moxa_tiocmset(struct tty_struct *tty, struct file *file,
 static void moxa_poll(unsigned long);
 static void set_tty_param(struct tty_struct *);
 static int block_till_ready(struct tty_struct *, struct file *,
-                           struct moxa_str *);
+                           struct moxa_port *);
 static void setup_empty_event(struct tty_struct *);
 static void check_xmit_empty(unsigned long);
-static void shut_down(struct moxa_str *);
-static void receive_data(struct moxa_str *);
+static void shut_down(struct moxa_port *);
+static void receive_data(struct moxa_port *);
 /*
  * moxa board interface functions:
  */
@@ -278,8 +244,8 @@ static void MoxaPortTxDisable(int);
 static void MoxaPortTxEnable(int);
 static int MoxaPortResetBrkCnt(int);
 static void MoxaPortSendBreak(int, int);
-static int moxa_get_serial_info(struct moxa_str *, struct serial_struct __user *);
-static int moxa_set_serial_info(struct moxa_str *, struct serial_struct __user *);
+static int moxa_get_serial_info(struct moxa_port *, struct serial_struct __user *);
+static int moxa_set_serial_info(struct moxa_port *, struct serial_struct __user *);
 static void MoxaSetFifo(int port, int enable);
 
 static const struct tty_operations moxa_ops = {
@@ -302,12 +268,41 @@ static const struct tty_operations moxa_ops = {
        .tiocmset = moxa_tiocmset,
 };
 
+static struct tty_driver *moxaDriver;
+static struct moxa_port moxa_ports[MAX_PORTS];
+static DEFINE_TIMER(moxaTimer, moxa_poll, 0, 0);
 static DEFINE_SPINLOCK(moxa_lock);
 
 #ifdef CONFIG_PCI
-static int moxa_get_PCI_conf(struct pci_dev *p, int board_type, moxa_board_conf * board)
+static int __devinit moxa_pci_probe(struct pci_dev *pdev,
+               const struct pci_device_id *ent)
 {
-       board->baseAddr = pci_resource_start (p, 2);
+       struct moxa_board_conf *board;
+       unsigned int i;
+       int board_type = ent->driver_data;
+       int retval;
+
+       retval = pci_enable_device(pdev);
+       if (retval)
+               goto err;
+
+       for (i = 0; i < MAX_BOARDS; i++)
+               if (moxa_boards[i].basemem == NULL)
+                       break;
+
+       retval = -ENODEV;
+       if (i >= MAX_BOARDS) {
+               if (verbose)
+                       printk("More than %d MOXA Intellio family boards "
+                               "found. Board is ignored.\n", MAX_BOARDS);
+               goto err;
+       }
+
+       board = &moxa_boards[i];
+       board->basemem = pci_iomap(pdev, 2, 0x4000);
+       if (board->basemem == NULL)
+               goto err;
+
        board->boardType = board_type;
        switch (board_type) {
        case MOXA_BOARD_C218_ISA:
@@ -323,27 +318,40 @@ static int moxa_get_PCI_conf(struct pci_dev *p, int board_type, moxa_board_conf
                break;
        }
        board->busType = MOXA_BUS_TYPE_PCI;
-       board->pciInfo.busNum = p->bus->number;
-       board->pciInfo.devNum = p->devfn >> 3;
-       board->pciInfo.pdev = p;
-       /* don't lose the reference in the next pci_get_device iteration */
-       pci_dev_get(p);
+
+       pci_set_drvdata(pdev, board);
 
        return (0);
+err:
+       return retval;
 }
+
+static void __devexit moxa_pci_remove(struct pci_dev *pdev)
+{
+       struct moxa_board_conf *brd = pci_get_drvdata(pdev);
+
+       pci_iounmap(pdev, brd->basemem);
+       brd->basemem = NULL;
+}
+
+static struct pci_driver moxa_pci_driver = {
+       .name = "moxa",
+       .id_table = moxa_pcibrds,
+       .probe = moxa_pci_probe,
+       .remove = __devexit_p(moxa_pci_remove)
+};
 #endif /* CONFIG_PCI */
 
 static int __init moxa_init(void)
 {
-       int i, numBoards;
-       struct moxa_str *ch;
+       int i, numBoards, retval = 0;
+       struct moxa_port *ch;
 
        printk(KERN_INFO "MOXA Intellio family driver version %s\n", MOXA_VERSION);
        moxaDriver = alloc_tty_driver(MAX_PORTS + 1);
        if (!moxaDriver)
                return -ENOMEM;
 
-       init_MUTEX(&moxaBuffSem);
        moxaDriver->owner = THIS_MODULE;
        moxaDriver->name = "ttyMX";
        moxaDriver->major = ttymajor;
@@ -351,40 +359,25 @@ static int __init moxa_init(void)
        moxaDriver->type = TTY_DRIVER_TYPE_SERIAL;
        moxaDriver->subtype = SERIAL_TYPE_NORMAL;
        moxaDriver->init_termios = tty_std_termios;
-       moxaDriver->init_termios.c_iflag = 0;
-       moxaDriver->init_termios.c_oflag = 0;
        moxaDriver->init_termios.c_cflag = B9600 | CS8 | CREAD | CLOCAL | HUPCL;
-       moxaDriver->init_termios.c_lflag = 0;
        moxaDriver->init_termios.c_ispeed = 9600;
        moxaDriver->init_termios.c_ospeed = 9600;
        moxaDriver->flags = TTY_DRIVER_REAL_RAW;
        tty_set_operations(moxaDriver, &moxa_ops);
 
-       moxaXmitBuff = NULL;
-
-       for (i = 0, ch = moxaChannels; i < MAX_PORTS; i++, ch++) {
+       for (i = 0, ch = moxa_ports; i < MAX_PORTS; i++, ch++) {
                ch->type = PORT_16550A;
                ch->port = i;
-               INIT_WORK(&ch->tqueue, do_moxa_softint);
-               ch->tty = NULL;
                ch->close_delay = 5 * HZ / 10;
                ch->closing_wait = 30 * HZ;
-               ch->count = 0;
-               ch->blocked_open = 0;
                ch->cflag = B9600 | CS8 | CREAD | CLOCAL | HUPCL;
                init_waitqueue_head(&ch->open_wait);
                init_waitqueue_head(&ch->close_wait);
-       }
 
-       for (i = 0; i < MAX_BOARDS; i++) {
-               moxa_boards[i].boardType = 0;
-               moxa_boards[i].numPorts = 0;
-               moxa_boards[i].baseAddr = 0;
-               moxa_boards[i].busType = 0;
-               moxa_boards[i].pciInfo.busNum = 0;
-               moxa_boards[i].pciInfo.devNum = 0;
+               setup_timer(&ch->emptyTimer, check_xmit_empty,
+                               (unsigned long)ch);
        }
-       MoxaDriverInit();
+
        printk("Tty devices major number = %d\n", ttymajor);
 
        if (tty_register_driver(moxaDriver)) {
@@ -392,18 +385,8 @@ static int __init moxa_init(void)
                put_tty_driver(moxaDriver);
                return -1;
        }
-       for (i = 0; i < MAX_PORTS; i++) {
-               init_timer(&moxaEmptyTimer[i]);
-               moxaEmptyTimer[i].function = check_xmit_empty;
-               moxaEmptyTimer[i].data = (unsigned long) & moxaChannels[i];
-               moxaEmptyTimer_on[i] = 0;
-       }
 
-       init_timer(&moxaTimer);
-       moxaTimer.function = moxa_poll;
-       moxaTimer.expires = jiffies + (HZ / 50);
-       moxaTimer_on = 1;
-       add_timer(&moxaTimer);
+       mod_timer(&moxaTimer, jiffies + HZ / 50);
 
        /* Find the boards defined in source code */
        numBoards = 0;
@@ -451,35 +434,22 @@ static int __init moxa_init(void)
                }
        }
 #endif
-       /* Find PCI boards here */
+
 #ifdef CONFIG_PCI
-       {
-               struct pci_dev *p = NULL;
-               int n = ARRAY_SIZE(moxa_pcibrds) - 1;
-               i = 0;
-               while (i < n) {
-                       while ((p = pci_get_device(moxa_pcibrds[i].vendor, moxa_pcibrds[i].device, p))!=NULL)
-                       {
-                               if (pci_enable_device(p))
-                                       continue;
-                               if (numBoards >= MAX_BOARDS) {
-                                       if (verbose)
-                                               printk("More than %d MOXA Intellio family boards found. Board is ignored.", MAX_BOARDS);
-                               } else {
-                                       moxa_get_PCI_conf(p, moxa_pcibrds[i].driver_data,
-                                               &moxa_boards[numBoards]);
-                                       numBoards++;
-                               }
-                       }
-                       i++;
-               }
+       retval = pci_register_driver(&moxa_pci_driver);
+       if (retval) {
+               printk(KERN_ERR "Can't register moxa pci driver!\n");
+               if (numBoards)
+                       retval = 0;
        }
 #endif
+
        for (i = 0; i < numBoards; i++) {
-               moxaBaseAddr[i] = ioremap((unsigned long) moxa_boards[i].baseAddr, 0x4000);
+               moxa_boards[i].basemem = ioremap(moxa_boards[i].baseAddr,
+                               0x4000);
        }
 
-       return (0);
+       return retval;
 }
 
 static void __exit moxa_exit(void)
@@ -489,23 +459,22 @@ static void __exit moxa_exit(void)
        if (verbose)
                printk("Unloading module moxa ...\n");
 
-       if (moxaTimer_on)
-               del_timer(&moxaTimer);
+       del_timer_sync(&moxaTimer);
 
        for (i = 0; i < MAX_PORTS; i++)
-               if (moxaEmptyTimer_on[i])
-                       del_timer(&moxaEmptyTimer[i]);
+               del_timer_sync(&moxa_ports[i].emptyTimer);
 
        if (tty_unregister_driver(moxaDriver))
                printk("Couldn't unregister MOXA Intellio family serial driver\n");
        put_tty_driver(moxaDriver);
 
-       for (i = 0; i < MAX_BOARDS; i++) {
-               if (moxaBaseAddr[i])
-                       iounmap(moxaBaseAddr[i]);
-               if (moxa_boards[i].busType == MOXA_BUS_TYPE_PCI)
-                       pci_dev_put(moxa_boards[i].pciInfo.pdev);
-       }
+#ifdef CONFIG_PCI
+       pci_unregister_driver(&moxa_pci_driver);
+#endif
+
+       for (i = 0; i < MAX_BOARDS; i++)
+               if (moxa_boards[i].basemem)
+                       iounmap(moxa_boards[i].basemem);
 
        if (verbose)
                printk("Done\n");
@@ -514,28 +483,13 @@ static void __exit moxa_exit(void)
 module_init(moxa_init);
 module_exit(moxa_exit);
 
-static void do_moxa_softint(struct work_struct *work)
-{
-       struct moxa_str *ch = container_of(work, struct moxa_str, tqueue);
-       struct tty_struct *tty;
-
-       if (ch && (tty = ch->tty)) {
-               if (test_and_clear_bit(MOXA_EVENT_HANGUP, &ch->event)) {
-                       tty_hangup(tty);        /* FIXME: module removal race here - AKPM */
-                       wake_up_interruptible(&ch->open_wait);
-                       ch->asyncflags &= ~ASYNC_NORMAL_ACTIVE;
-               }
-       }
-}
-
 static int moxa_open(struct tty_struct *tty, struct file *filp)
 {
-       struct moxa_str *ch;
+       struct moxa_port *ch;
        int port;
        int retval;
-       unsigned long page;
 
-       port = PORTNO(tty);
+       port = tty->index;
        if (port == MAX_PORTS) {
                return (0);
        }
@@ -543,23 +497,8 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
                tty->driver_data = NULL;
                return (-ENODEV);
        }
-       down(&moxaBuffSem);
-       if (!moxaXmitBuff) {
-               page = get_zeroed_page(GFP_KERNEL);
-               if (!page) {
-                       up(&moxaBuffSem);
-                       return (-ENOMEM);
-               }
-               /* This test is guarded by the BuffSem so no longer needed
-                  delete me in 2.5 */
-               if (moxaXmitBuff)
-                       free_page(page);
-               else
-                       moxaXmitBuff = (unsigned char *) page;
-       }
-       up(&moxaBuffSem);
 
-       ch = &moxaChannels[port];
+       ch = &moxa_ports[port];
        ch->count++;
        tty->driver_data = ch;
        ch->tty = tty;
@@ -585,10 +524,10 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
 
 static void moxa_close(struct tty_struct *tty, struct file *filp)
 {
-       struct moxa_str *ch;
+       struct moxa_port *ch;
        int port;
 
-       port = PORTNO(tty);
+       port = tty->index;
        if (port == MAX_PORTS) {
                return;
        }
@@ -605,7 +544,7 @@ static void moxa_close(struct tty_struct *tty, struct file *filp)
        if (tty_hung_up_p(filp)) {
                return;
        }
-       ch = (struct moxa_str *) tty->driver_data;
+       ch = (struct moxa_port *) tty->driver_data;
 
        if ((tty->count == 1) && (ch->count != 1)) {
                printk("moxa_close: bad serial port count; tty->count is 1, "
@@ -626,8 +565,7 @@ static void moxa_close(struct tty_struct *tty, struct file *filp)
        if (ch->asyncflags & ASYNC_INITIALIZED) {
                setup_empty_event(tty);
                tty_wait_until_sent(tty, 30 * HZ);      /* 30 seconds timeout */
-               moxaEmptyTimer_on[ch->port] = 0;
-               del_timer(&moxaEmptyTimer[ch->port]);
+               del_timer_sync(&moxa_ports[ch->port].emptyTimer);
        }
        shut_down(ch);
        MoxaPortFlushData(port, 2);
@@ -652,11 +590,11 @@ static void moxa_close(struct tty_struct *tty, struct file *filp)
 static int moxa_write(struct tty_struct *tty,
                      const unsigned char *buf, int count)
 {
-       struct moxa_str *ch;
+       struct moxa_port *ch;
        int len, port;
        unsigned long flags;
 
-       ch = (struct moxa_str *) tty->driver_data;
+       ch = (struct moxa_port *) tty->driver_data;
        if (ch == NULL)
                return (0);
        port = ch->port;
@@ -675,11 +613,11 @@ static int moxa_write(struct tty_struct *tty,
 
 static int moxa_write_room(struct tty_struct *tty)
 {
-       struct moxa_str *ch;
+       struct moxa_port *ch;
 
        if (tty->stopped)
                return (0);
-       ch = (struct moxa_str *) tty->driver_data;
+       ch = (struct moxa_port *) tty->driver_data;
        if (ch == NULL)
                return (0);
        return (MoxaPortTxFree(ch->port));
@@ -687,7 +625,7 @@ static int moxa_write_room(struct tty_struct *tty)
 
 static void moxa_flush_buffer(struct tty_struct *tty)
 {
-       struct moxa_str *ch = (struct moxa_str *) tty->driver_data;
+       struct moxa_port *ch = (struct moxa_port *) tty->driver_data;
 
        if (ch == NULL)
                return;
@@ -698,7 +636,7 @@ static void moxa_flush_buffer(struct tty_struct *tty)
 static int moxa_chars_in_buffer(struct tty_struct *tty)
 {
        int chars;
-       struct moxa_str *ch = (struct moxa_str *) tty->driver_data;
+       struct moxa_port *ch = (struct moxa_port *) tty->driver_data;
 
        /*
         * Sigh...I have to check if driver_data is NULL here, because
@@ -730,17 +668,16 @@ static void moxa_flush_chars(struct tty_struct *tty)
 
 static void moxa_put_char(struct tty_struct *tty, unsigned char c)
 {
-       struct moxa_str *ch;
+       struct moxa_port *ch;
        int port;
        unsigned long flags;
 
-       ch = (struct moxa_str *) tty->driver_data;
+       ch = (struct moxa_port *) tty->driver_data;
        if (ch == NULL)
                return;
        port = ch->port;
        spin_lock_irqsave(&moxa_lock, flags);
-       moxaXmitBuff[0] = c;
-       MoxaPortWriteData(port, moxaXmitBuff, 1);
+       MoxaPortWriteData(port, &c, 1);
        spin_unlock_irqrestore(&moxa_lock, flags);
        /************************************************
        if ( !(ch->statusflags & LOWWAIT) && (MoxaPortTxFree(port) <= 100) )
@@ -750,11 +687,11 @@ static void moxa_put_char(struct tty_struct *tty, unsigned char c)
 
 static int moxa_tiocmget(struct tty_struct *tty, struct file *file)
 {
-       struct moxa_str *ch = (struct moxa_str *) tty->driver_data;
+       struct moxa_port *ch = (struct moxa_port *) tty->driver_data;
        int port;
        int flag = 0, dtr, rts;
 
-       port = PORTNO(tty);
+       port = tty->index;
        if ((port != MAX_PORTS) && (!ch))
                return (-EINVAL);
 
@@ -776,11 +713,11 @@ static int moxa_tiocmget(struct tty_struct *tty, struct file *file)
 static int moxa_tiocmset(struct tty_struct *tty, struct file *file,
                         unsigned int set, unsigned int clear)
 {
-       struct moxa_str *ch = (struct moxa_str *) tty->driver_data;
+       struct moxa_port *ch = (struct moxa_port *) tty->driver_data;
        int port;
        int dtr, rts;
 
-       port = PORTNO(tty);
+       port = tty->index;
        if ((port != MAX_PORTS) && (!ch))
                return (-EINVAL);
 
@@ -800,12 +737,12 @@ static int moxa_tiocmset(struct tty_struct *tty, struct file *file,
 static int moxa_ioctl(struct tty_struct *tty, struct file *file,
                      unsigned int cmd, unsigned long arg)
 {
-       struct moxa_str *ch = (struct moxa_str *) tty->driver_data;
+       struct moxa_port *ch = (struct moxa_port *) tty->driver_data;
        register int port;
        void __user *argp = (void __user *)arg;
        int retval;
 
-       port = PORTNO(tty);
+       port = tty->index;
        if ((port != MAX_PORTS) && (!ch))
                return (-EINVAL);
 
@@ -853,14 +790,14 @@ static int moxa_ioctl(struct tty_struct *tty, struct file *file,
 
 static void moxa_throttle(struct tty_struct *tty)
 {
-       struct moxa_str *ch = (struct moxa_str *) tty->driver_data;
+       struct moxa_port *ch = (struct moxa_port *) tty->driver_data;
 
        ch->statusflags |= THROTTLE;
 }
 
 static void moxa_unthrottle(struct tty_struct *tty)
 {
-       struct moxa_str *ch = (struct moxa_str *) tty->driver_data;
+       struct moxa_port *ch = (struct moxa_port *) tty->driver_data;
 
        ch->statusflags &= ~THROTTLE;
 }
@@ -868,7 +805,7 @@ static void moxa_unthrottle(struct tty_struct *tty)
 static void moxa_set_termios(struct tty_struct *tty,
                             struct ktermios *old_termios)
 {
-       struct moxa_str *ch = (struct moxa_str *) tty->driver_data;
+       struct moxa_port *ch = (struct moxa_port *) tty->driver_data;
 
        if (ch == NULL)
                return;
@@ -880,7 +817,7 @@ static void moxa_set_termios(struct tty_struct *tty,
 
 static void moxa_stop(struct tty_struct *tty)
 {
-       struct moxa_str *ch = (struct moxa_str *) tty->driver_data;
+       struct moxa_port *ch = (struct moxa_port *) tty->driver_data;
 
        if (ch == NULL)
                return;
@@ -891,7 +828,7 @@ static void moxa_stop(struct tty_struct *tty)
 
 static void moxa_start(struct tty_struct *tty)
 {
-       struct moxa_str *ch = (struct moxa_str *) tty->driver_data;
+       struct moxa_port *ch = (struct moxa_port *) tty->driver_data;
 
        if (ch == NULL)
                return;
@@ -905,7 +842,7 @@ static void moxa_start(struct tty_struct *tty)
 
 static void moxa_hangup(struct tty_struct *tty)
 {
-       struct moxa_str *ch = (struct moxa_str *) tty->driver_data;
+       struct moxa_port *ch = (struct moxa_port *) tty->driver_data;
 
        moxa_flush_buffer(tty);
        shut_down(ch);
@@ -919,24 +856,20 @@ static void moxa_hangup(struct tty_struct *tty)
 static void moxa_poll(unsigned long ignored)
 {
        register int card;
-       struct moxa_str *ch;
+       struct moxa_port *ch;
        struct tty_struct *tp;
        int i, ports;
 
-       moxaTimer_on = 0;
        del_timer(&moxaTimer);
 
        if (MoxaDriverPoll() < 0) {
-               moxaTimer.function = moxa_poll;
-               moxaTimer.expires = jiffies + (HZ / 50);
-               moxaTimer_on = 1;
-               add_timer(&moxaTimer);
+               mod_timer(&moxaTimer, jiffies + HZ / 50);
                return;
        }
        for (card = 0; card < MAX_BOARDS; card++) {
                if ((ports = MoxaPortsOfCard(card)) <= 0)
                        continue;
-               ch = &moxaChannels[card * MAX_PORTS_PER_BOARD];
+               ch = &moxa_ports[card * MAX_PORTS_PER_BOARD];
                for (i = 0; i < ports; i++, ch++) {
                        if ((ch->asyncflags & ASYNC_INITIALIZED) == 0)
                                continue;
@@ -962,18 +895,16 @@ static void moxa_poll(unsigned long ignored)
                                        if (MoxaPortDCDON(ch->port))
                                                wake_up_interruptible(&ch->open_wait);
                                        else {
-                                               set_bit(MOXA_EVENT_HANGUP, &ch->event);
-                                               schedule_work(&ch->tqueue);
+                                               tty_hangup(tp);
+                                               wake_up_interruptible(&ch->open_wait);
+                                               ch->asyncflags &= ~ASYNC_NORMAL_ACTIVE;
                                        }
                                }
                        }
                }
        }
 
-       moxaTimer.function = moxa_poll;
-       moxaTimer.expires = jiffies + (HZ / 50);
-       moxaTimer_on = 1;
-       add_timer(&moxaTimer);
+       mod_timer(&moxaTimer, jiffies + HZ / 50);
 }
 
 /******************************************************************************/
@@ -981,10 +912,10 @@ static void moxa_poll(unsigned long ignored)
 static void set_tty_param(struct tty_struct *tty)
 {
        register struct ktermios *ts;
-       struct moxa_str *ch;
+       struct moxa_port *ch;
        int rts, cts, txflow, rxflow, xany;
 
-       ch = (struct moxa_str *) tty->driver_data;
+       ch = (struct moxa_port *) tty->driver_data;
        ts = tty->termios;
        if (ts->c_cflag & CLOCAL)
                ch->asyncflags &= ~ASYNC_CHECK_CD;
@@ -1004,7 +935,7 @@ static void set_tty_param(struct tty_struct *tty)
 }
 
 static int block_till_ready(struct tty_struct *tty, struct file *filp,
-                           struct moxa_str *ch)
+                           struct moxa_port *ch)
 {
        DECLARE_WAITQUEUE(wait,current);
        unsigned long flags;
@@ -1095,40 +1026,33 @@ static int block_till_ready(struct tty_struct *tty, struct file *filp,
 
 static void setup_empty_event(struct tty_struct *tty)
 {
-       struct moxa_str *ch = tty->driver_data;
+       struct moxa_port *ch = tty->driver_data;
        unsigned long flags;
 
        spin_lock_irqsave(&moxa_lock, flags);
        ch->statusflags |= EMPTYWAIT;
-       moxaEmptyTimer_on[ch->port] = 0;
-       del_timer(&moxaEmptyTimer[ch->port]);
-       moxaEmptyTimer[ch->port].expires = jiffies + HZ;
-       moxaEmptyTimer_on[ch->port] = 1;
-       add_timer(&moxaEmptyTimer[ch->port]);
+       mod_timer(&moxa_ports[ch->port].emptyTimer, jiffies + HZ);
        spin_unlock_irqrestore(&moxa_lock, flags);
 }
 
 static void check_xmit_empty(unsigned long data)
 {
-       struct moxa_str *ch;
+       struct moxa_port *ch;
 
-       ch = (struct moxa_str *) data;
-       moxaEmptyTimer_on[ch->port] = 0;
-       del_timer(&moxaEmptyTimer[ch->port]);
+       ch = (struct moxa_port *) data;
+       del_timer_sync(&moxa_ports[ch->port].emptyTimer);
        if (ch->tty && (ch->statusflags & EMPTYWAIT)) {
                if (MoxaPortTxQueue(ch->port) == 0) {
                        ch->statusflags &= ~EMPTYWAIT;
                        tty_wakeup(ch->tty);
                        return;
                }
-               moxaEmptyTimer[ch->port].expires = jiffies + HZ;
-               moxaEmptyTimer_on[ch->port] = 1;
-               add_timer(&moxaEmptyTimer[ch->port]);
+               mod_timer(&moxa_ports[ch->port].emptyTimer, jiffies + HZ);
        } else
                ch->statusflags &= ~EMPTYWAIT;
 }
 
-static void shut_down(struct moxa_str *ch)
+static void shut_down(struct moxa_port *ch)
 {
        struct tty_struct *tp;
 
@@ -1148,7 +1072,7 @@ static void shut_down(struct moxa_str *ch)
        ch->asyncflags &= ~ASYNC_INITIALIZED;
 }
 
-static void receive_data(struct moxa_str *ch)
+static void receive_data(struct moxa_port *ch)
 {
        struct tty_struct *tp;
        struct ktermios *ts;
@@ -1465,35 +1389,21 @@ static void receive_data(struct moxa_str *ch)
 /*
  *    Query
  */
-#define QueryPort      MAX_PORTS
-
-
 
 struct mon_str {
        int tick;
        int rxcnt[MAX_PORTS];
        int txcnt[MAX_PORTS];
 };
-typedef struct mon_str mon_st;
 
 #define        DCD_changed     0x01
 #define        DCD_oldstate    0x80
 
 static unsigned char moxaBuff[10240];
-static void __iomem *moxaIntNdx[MAX_BOARDS];
-static void __iomem *moxaIntPend[MAX_BOARDS];
-static void __iomem *moxaIntTable[MAX_BOARDS];
-static char moxaChkPort[MAX_PORTS];
-static char moxaLineCtrl[MAX_PORTS];
-static void __iomem *moxaTableAddr[MAX_PORTS];
-static long moxaCurBaud[MAX_PORTS];
-static char moxaDCDState[MAX_PORTS];
-static char moxaLowChkFlag[MAX_PORTS];
 static int moxaLowWaterChk;
 static int moxaCard;
-static mon_st moxaLog;
-static int moxaFuncTout;
-static ushort moxaBreakCnt[MAX_PORTS];
+static struct mon_str moxaLog;
+static int moxaFuncTout = HZ / 2;
 
 static void moxadelay(int);
 static void moxafunc(void __iomem *, int, ushort);
@@ -1514,16 +1424,18 @@ static int moxaloadc320(int, void __iomem *, int, int *);
  *****************************************************************************/
 void MoxaDriverInit(void)
 {
-       int i;
+       struct moxa_port *p;
+       unsigned int i;
 
        moxaFuncTout = HZ / 2;  /* 500 mini-seconds */
        moxaCard = 0;
        moxaLog.tick = 0;
        moxaLowWaterChk = 0;
        for (i = 0; i < MAX_PORTS; i++) {
-               moxaChkPort[i] = 0;
-               moxaLowChkFlag[i] = 0;
-               moxaLineCtrl[i] = 0;
+               p = &moxa_ports[i];
+               p->chkPort = 0;
+               p->lowChkFlag = 0;
+               p->lineCtrl = 0;
                moxaLog.rxcnt[i] = 0;
                moxaLog.txcnt[i] = 0;
        }
@@ -1545,19 +1457,12 @@ void MoxaDriverInit(void)
 #define MOXA_GET_CUMAJOR        (MOXA + 64)
 #define MOXA_GETMSTATUS         (MOXA + 65)
 
-
-struct moxaq_str {
-       int inq;
-       int outq;
-};
-
 struct dl_str {
        char __user *buf;
        int len;
        int cardno;
 };
 
-static struct moxaq_str temp_queue[MAX_PORTS];
 static struct dl_str dltmp;
 
 void MoxaPortFlushData(int port, int mode)
@@ -1565,10 +1470,10 @@ void MoxaPortFlushData(int port, int mode)
        void __iomem *ofsAddr;
        if ((mode < 0) || (mode > 2))
                return;
-       ofsAddr = moxaTableAddr[port];
+       ofsAddr = moxa_ports[port].tableAddr;
        moxafunc(ofsAddr, FC_FlushQueue, mode);
        if (mode != 1) {
-               moxaLowChkFlag[port] = 0;
+               moxa_ports[port].lowChkFlag = 0;
                low_water_check(ofsAddr);
        }
 }
@@ -1580,7 +1485,7 @@ int MoxaDriverIoctl(unsigned int cmd, unsigned long arg, int port)
        int MoxaPortTxQueue(int), MoxaPortRxQueue(int);
        void __user *argp = (void __user *)arg;
 
-       if (port == QueryPort) {
+       if (port == MAX_PORTS) {
                if ((cmd != MOXA_GET_CONF) && (cmd != MOXA_INIT_DRIVER) &&
                    (cmd != MOXA_LOAD_BIOS) && (cmd != MOXA_FIND_BOARD) && (cmd != MOXA_LOAD_C320B) &&
                 (cmd != MOXA_LOAD_CODE) && (cmd != MOXA_GETDATACOUNT) &&
@@ -1590,7 +1495,8 @@ int MoxaDriverIoctl(unsigned int cmd, unsigned long arg, int port)
        }
        switch (cmd) {
        case MOXA_GET_CONF:
-               if(copy_to_user(argp, &moxa_boards, MAX_BOARDS * sizeof(moxa_board_conf)))
+               if(copy_to_user(argp, &moxa_boards, MAX_BOARDS *
+                               sizeof(struct moxa_board_conf)))
                        return -EFAULT;
                return (0);
        case MOXA_INIT_DRIVER:
@@ -1599,23 +1505,27 @@ int MoxaDriverIoctl(unsigned int cmd, unsigned long arg, int port)
                return (0);
        case MOXA_GETDATACOUNT:
                moxaLog.tick = jiffies;
-               if(copy_to_user(argp, &moxaLog, sizeof(mon_st)))
+               if(copy_to_user(argp, &moxaLog, sizeof(struct mon_str)))
                        return -EFAULT;
                return (0);
        case MOXA_FLUSH_QUEUE:
                MoxaPortFlushData(port, arg);
                return (0);
-       case MOXA_GET_IOQUEUE:
-               for (i = 0; i < MAX_PORTS; i++) {
-                       if (moxaChkPort[i]) {
-                               temp_queue[i].inq = MoxaPortRxQueue(i);
-                               temp_queue[i].outq = MoxaPortTxQueue(i);
+       case MOXA_GET_IOQUEUE: {
+               struct moxaq_str __user *argm = argp;
+               struct moxaq_str tmp;
+
+               for (i = 0; i < MAX_PORTS; i++, argm++) {
+                       memset(&tmp, 0, sizeof(tmp));
+                       if (moxa_ports[i].chkPort) {
+                               tmp.inq = MoxaPortRxQueue(i);
+                               tmp.outq = MoxaPortTxQueue(i);
                        }
+                       if (copy_to_user(argm, &tmp, sizeof(tmp)))
+                               return -EFAULT;
                }
-               if(copy_to_user(argp, temp_queue, sizeof(struct moxaq_str) * MAX_PORTS))
-                       return -EFAULT;
                return (0);
-       case MOXA_GET_OQUEUE:
+       case MOXA_GET_OQUEUE:
                i = MoxaPortTxQueue(port);
                return put_user(i, (unsigned long __user *)argp);
        case MOXA_GET_IQUEUE:
@@ -1630,33 +1540,36 @@ int MoxaDriverIoctl(unsigned int cmd, unsigned long arg, int port)
                if(copy_to_user(argp, &i, sizeof(int)))
                        return -EFAULT;
                return 0;
-       case MOXA_GETMSTATUS:
-               for (i = 0; i < MAX_PORTS; i++) {
-                       GMStatus[i].ri = 0;
-                       GMStatus[i].dcd = 0;
-                       GMStatus[i].dsr = 0;
-                       GMStatus[i].cts = 0;
-                       if (!moxaChkPort[i]) {
-                               continue;
+       case MOXA_GETMSTATUS: {
+               struct mxser_mstatus __user *argm = argp;
+               struct mxser_mstatus tmp;
+               struct moxa_port *p;
+
+               for (i = 0; i < MAX_PORTS; i++, argm++) {
+                       p = &moxa_ports[i];
+                       memset(&tmp, 0, sizeof(tmp));
+                       if (!p->chkPort) {
+                               goto copy;
                        } else {
-                               status = MoxaPortLineStatus(moxaChannels[i].port);
+                               status = MoxaPortLineStatus(p->port);
                                if (status & 1)
-                                       GMStatus[i].cts = 1;
+                                       tmp.cts = 1;
                                if (status & 2)
-                                       GMStatus[i].dsr = 1;
+                                       tmp.dsr = 1;
                                if (status & 4)
-                                       GMStatus[i].dcd = 1;
+                                       tmp.dcd = 1;
                        }
 
-                       if (!moxaChannels[i].tty || !moxaChannels[i].tty->termios)
-                               GMStatus[i].cflag = moxaChannels[i].cflag;
+                       if (!p->tty || !p->tty->termios)
+                               tmp.cflag = p->cflag;
                        else
-                               GMStatus[i].cflag = moxaChannels[i].tty->termios->c_cflag;
+                               tmp.cflag = p->tty->termios->c_cflag;
+copy:
+                       if (copy_to_user(argm, &tmp, sizeof(tmp)))
+                               return -EFAULT;
                }
-               if(copy_to_user(argp, GMStatus, sizeof(struct mxser_mstatus) * MAX_PORTS))
-                       return -EFAULT;
                return 0;
-       default:
+       default:
                return (-ENOIOCTLCMD);
        case MOXA_LOAD_BIOS:
        case MOXA_FIND_BOARD:
@@ -1694,6 +1607,7 @@ int MoxaDriverIoctl(unsigned int cmd, unsigned long arg, int port)
 
 int MoxaDriverPoll(void)
 {
+       struct moxa_board_conf *brd;
        register ushort temp;
        register int card;
        void __iomem *ofsAddr;
@@ -1703,43 +1617,44 @@ int MoxaDriverPoll(void)
        if (moxaCard == 0)
                return (-1);
        for (card = 0; card < MAX_BOARDS; card++) {
-               if (loadstat[card] == 0)
+               brd = &moxa_boards[card];
+               if (brd->loadstat == 0)
                        continue;
-               if ((ports = moxa_boards[card].numPorts) == 0)
+               if ((ports = brd->numPorts) == 0)
                        continue;
-               if (readb(moxaIntPend[card]) == 0xff) {
-                       ip = moxaIntTable[card] + readb(moxaIntNdx[card]);
+               if (readb(brd->intPend) == 0xff) {
+                       ip = brd->intTable + readb(brd->intNdx);
                        p = card * MAX_PORTS_PER_BOARD;
                        ports <<= 1;
                        for (port = 0; port < ports; port += 2, p++) {
                                if ((temp = readw(ip + port)) != 0) {
                                        writew(0, ip + port);
-                                       ofsAddr = moxaTableAddr[p];
+                                       ofsAddr = moxa_ports[p].tableAddr;
                                        if (temp & IntrTx)
                                                writew(readw(ofsAddr + HostStat) & ~WakeupTx, ofsAddr + HostStat);
                                        if (temp & IntrBreak) {
-                                               moxaBreakCnt[p]++;
+                                               moxa_ports[p].breakCnt++;
                                        }
                                        if (temp & IntrLine) {
                                                if (readb(ofsAddr + FlagStat) & DCD_state) {
-                                                       if ((moxaDCDState[p] & DCD_oldstate) == 0)
-                                                               moxaDCDState[p] = (DCD_oldstate |
+                                                       if ((moxa_ports[p].DCDState & DCD_oldstate) == 0)
+                                                               moxa_ports[p].DCDState = (DCD_oldstate |
                                                                                   DCD_changed);
                                                } else {
-                                                       if (moxaDCDState[p] & DCD_oldstate)
-                                                               moxaDCDState[p] = DCD_changed;
+                                                       if (moxa_ports[p].DCDState & DCD_oldstate)
+                                                               moxa_ports[p].DCDState = DCD_changed;
                                                }
                                        }
                                }
                        }
-                       writeb(0, moxaIntPend[card]);
+                       writeb(0, brd->intPend);
                }
                if (moxaLowWaterChk) {
                        p = card * MAX_PORTS_PER_BOARD;
                        for (port = 0; port < ports; port++, p++) {
-                               if (moxaLowChkFlag[p]) {
-                                       moxaLowChkFlag[p] = 0;
-                                       ofsAddr = moxaTableAddr[p];
+                               if (moxa_ports[p].lowChkFlag) {
+                                       moxa_ports[p].lowChkFlag = 0;
+                                       ofsAddr = moxa_ports[p].tableAddr;
                                        low_water_check(ofsAddr);
                                }
                        }
@@ -1767,9 +1682,7 @@ int MoxaPortsOfCard(int cardno)
  *     2.  MoxaPortEnable(int port);                                        *
  *     3.  MoxaPortDisable(int port);                                       *
  *     4.  MoxaPortGetMaxBaud(int port);                                    *
- *     5.  MoxaPortGetCurBaud(int port);                                    *
  *     6.  MoxaPortSetBaud(int port, long baud);                            *
- *     7.  MoxaPortSetMode(int port, int databit, int stopbit, int parity); *
  *     8.  MoxaPortSetTermio(int port, unsigned char *termio);              *
  *     9.  MoxaPortGetLineOut(int port, int *dtrState, int *rtsState);      *
  *     10. MoxaPortLineCtrl(int port, int dtrState, int rtsState);          *
@@ -1780,18 +1693,12 @@ int MoxaPortsOfCard(int cardno)
  *     15. MoxaPortFlushData(int port, int mode);                           *
  *     16. MoxaPortWriteData(int port, unsigned char * buffer, int length); *
  *     17. MoxaPortReadData(int port, struct tty_struct *tty);              *
- *     18. MoxaPortTxBufSize(int port);                                     *
- *     19. MoxaPortRxBufSize(int port);                                     *
  *     20. MoxaPortTxQueue(int port);                                       *
  *     21. MoxaPortTxFree(int port);                                        *
  *     22. MoxaPortRxQueue(int port);                                       *
- *     23. MoxaPortRxFree(int port);                                        *
  *     24. MoxaPortTxDisable(int port);                                     *
  *     25. MoxaPortTxEnable(int port);                                      *
- *     26. MoxaPortGetBrkCnt(int port);                                     *
  *     27. MoxaPortResetBrkCnt(int port);                                   *
- *     28. MoxaPortSetXonXoff(int port, int xonValue, int xoffValue);       *
- *     29. MoxaPortIsTxHold(int port);                                      *
  *     30. MoxaPortSendBreak(int port, int ticks);                          *
  *****************************************************************************/
 /*
@@ -1878,15 +1785,6 @@ int MoxaPortsOfCard(int cardno)
  *                      38400/57600/115200 bps
  *
  *
- *      Function 9:     Get the current baud rate of this port.
- *      Syntax:
- *      long MoxaPortGetCurBaud(int port);
- *           int port           : port number (0 - 127)
- *
- *           return:    0       : this port is invalid
- *                      50 - 115200 bps
- *
- *
  *      Function 10:    Setting baud rate of this port.
  *      Syntax:
  *      long MoxaPortSetBaud(int port, long baud);
@@ -1900,18 +1798,6 @@ int MoxaPortsOfCard(int cardno)
  *                                    baud rate will be the maximun baud rate.
  *
  *
- *      Function 11:    Setting the data-bits/stop-bits/parity of this port
- *      Syntax:
- *      int  MoxaPortSetMode(int port, int databits, int stopbits, int parity);
- *           int port           : port number (0 - 127)
- *           int databits       : data bits (8/7/6/5)
- *           int stopbits       : stop bits (2/1/0, 0 show 1.5 stop bits)
- int parity     : parity (0:None,1:Odd,2:Even,3:Mark,4:Space)
- *
- *           return:    -1      : invalid parameter
- *                      0       : setting O.K.
- *
- *
  *      Function 12:    Configure the port.
  *      Syntax:
  *      int  MoxaPortSetTermio(int port, struct ktermios *termio, speed_t baud);
@@ -2016,22 +1902,6 @@ int MoxaPortsOfCard(int cardno)
  *           return:    0 - length      : real read data length
  *
  *
- *      Function 22:    Get the Tx buffer size of this port
- *      Syntax:
- *      int  MoxaPortTxBufSize(int port);
- *           int port           : port number (0 - 127)
- *
- *           return:    ..      : Tx buffer size
- *
- *
- *      Function 23:    Get the Rx buffer size of this port
- *      Syntax:
- *      int  MoxaPortRxBufSize(int port);
- *           int port           : port number (0 - 127)
- *
- *           return:    ..      : Rx buffer size
- *
- *
  *      Function 24:    Get the Tx buffer current queued data bytes
  *      Syntax:
  *      int  MoxaPortTxQueue(int port);
@@ -2056,14 +1926,6 @@ int MoxaPortsOfCard(int cardno)
  *           return:    ..      : Rx buffer current queued data bytes
  *
  *
- *      Function 27:    Get the Rx buffer current free space
- *      Syntax:
- *      int  MoxaPortRxFree(int port);
- *           int port           : port number (0 - 127)
- *
- *           return:    ..      : Rx buffer current free space
- *
- *
  *      Function 28:    Disable port data transmission.
  *      Syntax:
  *      void MoxaPortTxDisable(int port);
@@ -2076,14 +1938,6 @@ int MoxaPortsOfCard(int cardno)
  *           int port           : port number (0 - 127)
  *
  *
- *      Function 30:    Get the received BREAK signal count.
- *      Syntax:
- *      int  MoxaPortGetBrkCnt(int port);
- *           int port           : port number (0 - 127)
- *
- *           return:    0 - ..  : BREAK signal count
- *
- *
  *      Function 31:    Get the received BREAK signal count and reset it.
  *      Syntax:
  *      int  MoxaPortResetBrkCnt(int port);
@@ -2092,25 +1946,6 @@ int MoxaPortsOfCard(int cardno)
  *           return:    0 - ..  : BREAK signal count
  *
  *
- *      Function 32:    Set the S/W flow control new XON/XOFF value, default
- *                      XON is 0x11 & XOFF is 0x13.
- *      Syntax:
- *      void MoxaPortSetXonXoff(int port, int xonValue, int xoffValue);
- *           int port           : port number (0 - 127)
- *           int xonValue       : new XON value (0 - 255)
- *           int xoffValue      : new XOFF value (0 - 255)
- *
- *
- *      Function 33:    Check this port's transmission is hold by remote site
- *                      because the flow control.
- *      Syntax:
- *      int  MoxaPortIsTxHold(int port);
- *           int port           : port number (0 - 127)
- *
- *           return:    0       : normal
- *                      1       : hold by remote site
- *
- *
  *      Function 34:    Send out a BREAK signal.
  *      Syntax:
  *      void MoxaPortSendBreak(int port, int ms100);
@@ -2125,7 +1960,7 @@ int MoxaPortIsValid(int port)
 
        if (moxaCard == 0)
                return (0);
-       if (moxaChkPort[port] == 0)
+       if (moxa_ports[port].chkPort == 0)
                return (0);
        return (1);
 }
@@ -2136,9 +1971,9 @@ void MoxaPortEnable(int port)
        int MoxaPortLineStatus(int);
        short lowwater = 512;
 
-       ofsAddr = moxaTableAddr[port];
+       ofsAddr = moxa_ports[port].tableAddr;
        writew(lowwater, ofsAddr + Low_water);
-       moxaBreakCnt[port] = 0;
+       moxa_ports[port].breakCnt = 0;
        if ((moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_ISA) ||
            (moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_PCI)) {
                moxafunc(ofsAddr, FC_SetBreakIrq, 0);
@@ -2155,7 +1990,7 @@ void MoxaPortEnable(int port)
 
 void MoxaPortDisable(int port)
 {
-       void __iomem *ofsAddr = moxaTableAddr[port];
+       void __iomem *ofsAddr = moxa_ports[port].tableAddr;
 
        moxafunc(ofsAddr, FC_SetFlowCtl, 0);    /* disable flow control */
        moxafunc(ofsAddr, FC_ClrLineIrq, Magic_code);
@@ -2181,7 +2016,7 @@ long MoxaPortSetBaud(int port, long baud)
 
        if ((baud < 50L) || ((max = MoxaPortGetMaxBaud(port)) == 0))
                return (0);
-       ofsAddr = moxaTableAddr[port];
+       ofsAddr = moxa_ports[port].tableAddr;
        if (baud > max)
                baud = max;
        if (max == 38400L)
@@ -2193,7 +2028,7 @@ long MoxaPortSetBaud(int port, long baud)
        val = clock / baud;
        moxafunc(ofsAddr, FC_SetBaud, val);
        baud = clock / val;
-       moxaCurBaud[port] = baud;
+       moxa_ports[port].curBaud = baud;
        return (baud);
 }
 
@@ -2203,9 +2038,9 @@ int MoxaPortSetTermio(int port, struct ktermios *termio, speed_t baud)
        tcflag_t cflag;
        tcflag_t mode = 0;
 
-       if (moxaChkPort[port] == 0 || termio == 0)
+       if (moxa_ports[port].chkPort == 0 || termio == 0)
                return (-1);
-       ofsAddr = moxaTableAddr[port];
+       ofsAddr = moxa_ports[port].tableAddr;
        cflag = termio->c_cflag;        /* termio->c_cflag */
 
        mode = termio->c_cflag & CSIZE;
@@ -2259,13 +2094,13 @@ int MoxaPortGetLineOut(int port, int *dtrState, int *rtsState)
        if (!MoxaPortIsValid(port))
                return (-1);
        if (dtrState) {
-               if (moxaLineCtrl[port] & DTR_ON)
+               if (moxa_ports[port].lineCtrl & DTR_ON)
                        *dtrState = 1;
                else
                        *dtrState = 0;
        }
        if (rtsState) {
-               if (moxaLineCtrl[port] & RTS_ON)
+               if (moxa_ports[port].lineCtrl & RTS_ON)
                        *rtsState = 1;
                else
                        *rtsState = 0;
@@ -2278,13 +2113,13 @@ void MoxaPortLineCtrl(int port, int dtr, int rts)
        void __iomem *ofsAddr;
        int mode;
 
-       ofsAddr = moxaTableAddr[port];
+       ofsAddr = moxa_ports[port].tableAddr;
        mode = 0;
        if (dtr)
                mode |= DTR_ON;
        if (rts)
                mode |= RTS_ON;
-       moxaLineCtrl[port] = mode;
+       moxa_ports[port].lineCtrl = mode;
        moxafunc(ofsAddr, FC_LineControl, mode);
 }
 
@@ -2293,7 +2128,7 @@ void MoxaPortFlowCtrl(int port, int rts, int cts, int txflow, int rxflow, int tx
        void __iomem *ofsAddr;
        int mode;
 
-       ofsAddr = moxaTableAddr[port];
+       ofsAddr = moxa_ports[port].tableAddr;
        mode = 0;
        if (rts)
                mode |= RTS_FlowCtl;
@@ -2313,7 +2148,7 @@ int MoxaPortLineStatus(int port)
        void __iomem *ofsAddr;
        int val;
 
-       ofsAddr = moxaTableAddr[port];
+       ofsAddr = moxa_ports[port].tableAddr;
        if ((moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_ISA) ||
            (moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_PCI)) {
                moxafunc(ofsAddr, FC_LineStatus, 0);
@@ -2324,11 +2159,11 @@ int MoxaPortLineStatus(int port)
        val &= 0x0B;
        if (val & 8) {
                val |= 4;
-               if ((moxaDCDState[port] & DCD_oldstate) == 0)
-                       moxaDCDState[port] = (DCD_oldstate | DCD_changed);
+               if ((moxa_ports[port].DCDState & DCD_oldstate) == 0)
+                       moxa_ports[port].DCDState = (DCD_oldstate | DCD_changed);
        } else {
-               if (moxaDCDState[port] & DCD_oldstate)
-                       moxaDCDState[port] = DCD_changed;
+               if (moxa_ports[port].DCDState & DCD_oldstate)
+                       moxa_ports[port].DCDState = DCD_changed;
        }
        val &= 7;
        return (val);
@@ -2338,10 +2173,10 @@ int MoxaPortDCDChange(int port)
 {
        int n;
 
-       if (moxaChkPort[port] == 0)
+       if (moxa_ports[port].chkPort == 0)
                return (0);
-       n = moxaDCDState[port];
-       moxaDCDState[port] &= ~DCD_changed;
+       n = moxa_ports[port].DCDState;
+       moxa_ports[port].DCDState &= ~DCD_changed;
        n &= DCD_changed;
        return (n);
 }
@@ -2350,32 +2185,15 @@ int MoxaPortDCDON(int port)
 {
        int n;
 
-       if (moxaChkPort[port] == 0)
+       if (moxa_ports[port].chkPort == 0)
                return (0);
-       if (moxaDCDState[port] & DCD_oldstate)
+       if (moxa_ports[port].DCDState & DCD_oldstate)
                n = 1;
        else
                n = 0;
        return (n);
 }
 
-
-/*
-   int MoxaDumpMem(int port, unsigned char * buffer, int len)
-   {
-   int          i;
-   unsigned long                baseAddr,ofsAddr,ofs;
-
-   baseAddr = moxaBaseAddr[port / MAX_PORTS_PER_BOARD];
-   ofs = baseAddr + DynPage_addr + pageofs;
-   if (len > 0x2000L)
-   len = 0x2000L;
-   for (i = 0; i < len; i++)
-   buffer[i] = readb(ofs+i);
-   }
- */
-
-
 int MoxaPortWriteData(int port, unsigned char * buffer, int len)
 {
        int c, total, i;
@@ -2385,8 +2203,8 @@ int MoxaPortWriteData(int port, unsigned char * buffer, int len)
        ushort pageno, pageofs, bufhead;
        void __iomem *baseAddr, *ofsAddr, *ofs;
 
-       ofsAddr = moxaTableAddr[port];
-       baseAddr = moxaBaseAddr[port / MAX_PORTS_PER_BOARD];
+       ofsAddr = moxa_ports[port].tableAddr;
+       baseAddr = moxa_boards[port / MAX_PORTS_PER_BOARD].basemem;
        tx_mask = readw(ofsAddr + TX_mask);
        spage = readw(ofsAddr + Page_txb);
        epage = readw(ofsAddr + EndPage_txb);
@@ -2448,8 +2266,8 @@ int MoxaPortReadData(int port, struct tty_struct *tty)
        ushort pageno, bufhead;
        void __iomem *baseAddr, *ofsAddr, *ofs;
 
-       ofsAddr = moxaTableAddr[port];
-       baseAddr = moxaBaseAddr[port / MAX_PORTS_PER_BOARD];
+       ofsAddr = moxa_ports[port].tableAddr;
+       baseAddr = moxa_boards[port / MAX_PORTS_PER_BOARD].basemem;
        head = readw(ofsAddr + RXrptr);
        tail = readw(ofsAddr + RXwptr);
        rx_mask = readw(ofsAddr + RX_mask);
@@ -2504,7 +2322,7 @@ int MoxaPortReadData(int port, struct tty_struct *tty)
        }
        if ((readb(ofsAddr + FlagStat) & Xoff_state) && (remain < LowWater)) {
                moxaLowWaterChk = 1;
-               moxaLowChkFlag[port] = 1;
+               moxa_ports[port].lowChkFlag = 1;
        }
        return (total);
 }
@@ -2516,7 +2334,7 @@ int MoxaPortTxQueue(int port)
        ushort rptr, wptr, mask;
        int len;
 
-       ofsAddr = moxaTableAddr[port];
+       ofsAddr = moxa_ports[port].tableAddr;
        rptr = readw(ofsAddr + TXrptr);
        wptr = readw(ofsAddr + TXwptr);
        mask = readw(ofsAddr + TX_mask);
@@ -2530,7 +2348,7 @@ int MoxaPortTxFree(int port)
        ushort rptr, wptr, mask;
        int len;
 
-       ofsAddr = moxaTableAddr[port];
+       ofsAddr = moxa_ports[port].tableAddr;
        rptr = readw(ofsAddr + TXrptr);
        wptr = readw(ofsAddr + TXwptr);
        mask = readw(ofsAddr + TX_mask);
@@ -2544,7 +2362,7 @@ int MoxaPortRxQueue(int port)
        ushort rptr, wptr, mask;
        int len;
 
-       ofsAddr = moxaTableAddr[port];
+       ofsAddr = moxa_ports[port].tableAddr;
        rptr = readw(ofsAddr + RXrptr);
        wptr = readw(ofsAddr + RXwptr);
        mask = readw(ofsAddr + RX_mask);
@@ -2557,7 +2375,7 @@ void MoxaPortTxDisable(int port)
 {
        void __iomem *ofsAddr;
 
-       ofsAddr = moxaTableAddr[port];
+       ofsAddr = moxa_ports[port].tableAddr;
        moxafunc(ofsAddr, FC_SetXoffState, Magic_code);
 }
 
@@ -2565,7 +2383,7 @@ void MoxaPortTxEnable(int port)
 {
        void __iomem *ofsAddr;
 
-       ofsAddr = moxaTableAddr[port];
+       ofsAddr = moxa_ports[port].tableAddr;
        moxafunc(ofsAddr, FC_SetXonState, Magic_code);
 }
 
@@ -2573,8 +2391,8 @@ void MoxaPortTxEnable(int port)
 int MoxaPortResetBrkCnt(int port)
 {
        ushort cnt;
-       cnt = moxaBreakCnt[port];
-       moxaBreakCnt[port] = 0;
+       cnt = moxa_ports[port].breakCnt;
+       moxa_ports[port].breakCnt = 0;
        return (cnt);
 }
 
@@ -2583,7 +2401,7 @@ void MoxaPortSendBreak(int port, int ms100)
 {
        void __iomem *ofsAddr;
 
-       ofsAddr = moxaTableAddr[port];
+       ofsAddr = moxa_ports[port].tableAddr;
        if (ms100) {
                moxafunc(ofsAddr, FC_SendBreak, Magic_code);
                moxadelay(ms100 * (HZ / 10));
@@ -2594,7 +2412,7 @@ void MoxaPortSendBreak(int port, int ms100)
        moxafunc(ofsAddr, FC_StopBreak, Magic_code);
 }
 
-static int moxa_get_serial_info(struct moxa_str *info,
+static int moxa_get_serial_info(struct moxa_port *info,
                                struct serial_struct __user *retinfo)
 {
        struct serial_struct tmp;
@@ -2616,7 +2434,7 @@ static int moxa_get_serial_info(struct moxa_str *info,
 }
 
 
-static int moxa_set_serial_info(struct moxa_str *info,
+static int moxa_set_serial_info(struct moxa_port *info,
                                struct serial_struct __user *new_info)
 {
        struct serial_struct new_serial;
@@ -2713,7 +2531,7 @@ static int moxaloadbios(int cardno, unsigned char __user *tmp, int len)
 
        if(copy_from_user(moxaBuff, tmp, len))
                return -EFAULT;
-       baseAddr = moxaBaseAddr[cardno];
+       baseAddr = moxa_boards[cardno].basemem;
        writeb(HW_reset, baseAddr + Control_reg);       /* reset */
        moxadelay(1);           /* delay 10 ms */
        for (i = 0; i < 4096; i++)
@@ -2729,7 +2547,7 @@ static int moxafindcard(int cardno)
        void __iomem *baseAddr;
        ushort tmp;
 
-       baseAddr = moxaBaseAddr[cardno];
+       baseAddr = moxa_boards[cardno].basemem;
        switch (moxa_boards[cardno].boardType) {
        case MOXA_BOARD_C218_ISA:
        case MOXA_BOARD_C218_PCI:
@@ -2762,7 +2580,7 @@ static int moxaload320b(int cardno, unsigned char __user *tmp, int len)
                return -EINVAL;
        if(copy_from_user(moxaBuff, tmp, len))
                return -EFAULT;
-       baseAddr = moxaBaseAddr[cardno];
+       baseAddr = moxa_boards[cardno].basemem;
        writew(len - 7168 - 2, baseAddr + C320bapi_len);
        writeb(1, baseAddr + Control_reg);      /* Select Page 1 */
        for (i = 0; i < 7168; i++)
@@ -2780,7 +2598,7 @@ static int moxaloadcode(int cardno, unsigned char __user *tmp, int len)
 
        if(copy_from_user(moxaBuff, tmp, len))
                return -EFAULT;
-       baseAddr = moxaBaseAddr[cardno];
+       baseAddr = moxa_boards[cardno].basemem;
        switch (moxa_boards[cardno].boardType) {
        case MOXA_BOARD_C218_ISA:
        case MOXA_BOARD_C218_PCI:
@@ -2790,11 +2608,13 @@ static int moxaloadcode(int cardno, unsigned char __user *tmp, int len)
                        return (retval);
                port = cardno * MAX_PORTS_PER_BOARD;
                for (i = 0; i < moxa_boards[cardno].numPorts; i++, port++) {
-                       moxaChkPort[port] = 1;
-                       moxaCurBaud[port] = 9600L;
-                       moxaDCDState[port] = 0;
-                       moxaTableAddr[port] = baseAddr + Extern_table + Extern_size * i;
-                       ofsAddr = moxaTableAddr[port];
+                       struct moxa_port *p = &moxa_ports[port];
+
+                       p->chkPort = 1;
+                       p->curBaud = 9600L;
+                       p->DCDState = 0;
+                       p->tableAddr = baseAddr + Extern_table + Extern_size * i;
+                       ofsAddr = p->tableAddr;
                        writew(C218rx_mask, ofsAddr + RX_mask);
                        writew(C218tx_mask, ofsAddr + TX_mask);
                        writew(C218rx_spage + i * C218buf_pageno, ofsAddr + Page_rxb);
@@ -2812,11 +2632,13 @@ static int moxaloadcode(int cardno, unsigned char __user *tmp, int len)
                        return (retval);
                port = cardno * MAX_PORTS_PER_BOARD;
                for (i = 0; i < moxa_boards[cardno].numPorts; i++, port++) {
-                       moxaChkPort[port] = 1;
-                       moxaCurBaud[port] = 9600L;
-                       moxaDCDState[port] = 0;
-                       moxaTableAddr[port] = baseAddr + Extern_table + Extern_size * i;
-                       ofsAddr = moxaTableAddr[port];
+                       struct moxa_port *p = &moxa_ports[port];
+
+                       p->chkPort = 1;
+                       p->curBaud = 9600L;
+                       p->DCDState = 0;
+                       p->tableAddr = baseAddr + Extern_table + Extern_size * i;
+                       ofsAddr = p->tableAddr;
                        if (moxa_boards[cardno].numPorts == 8) {
                                writew(C320p8rx_mask, ofsAddr + RX_mask);
                                writew(C320p8tx_mask, ofsAddr + TX_mask);
@@ -2852,7 +2674,7 @@ static int moxaloadcode(int cardno, unsigned char __user *tmp, int len)
                }
                break;
        }
-       loadstat[cardno] = 1;
+       moxa_boards[cardno].loadstat = 1;
        return (0);
 }
 
@@ -2926,9 +2748,9 @@ static int moxaloadc218(int cardno, void __iomem *baseAddr, int len)
                return (-1);
        }
        moxaCard = 1;
-       moxaIntNdx[cardno] = baseAddr + IRQindex;
-       moxaIntPend[cardno] = baseAddr + IRQpending;
-       moxaIntTable[cardno] = baseAddr + IRQtable;
+       moxa_boards[cardno].intNdx = baseAddr + IRQindex;
+       moxa_boards[cardno].intPend = baseAddr + IRQpending;
+       moxa_boards[cardno].intTable = baseAddr + IRQtable;
        return (0);
 }
 
@@ -3021,25 +2843,15 @@ static int moxaloadc320(int cardno, void __iomem *baseAddr, int len, int *numPor
        if (readw(baseAddr + Magic_no) != Magic_code)
                return (-102);
        moxaCard = 1;
-       moxaIntNdx[cardno] = baseAddr + IRQindex;
-       moxaIntPend[cardno] = baseAddr + IRQpending;
-       moxaIntTable[cardno] = baseAddr + IRQtable;
+       moxa_boards[cardno].intNdx = baseAddr + IRQindex;
+       moxa_boards[cardno].intPend = baseAddr + IRQpending;
+       moxa_boards[cardno].intTable = baseAddr + IRQtable;
        return (0);
 }
 
-#if 0
-long MoxaPortGetCurBaud(int port)
-{
-
-       if (moxaChkPort[port] == 0)
-               return (0);
-       return (moxaCurBaud[port]);
-}
-#endif  /*  0  */
-
 static void MoxaSetFifo(int port, int enable)
 {
-       void __iomem *ofsAddr = moxaTableAddr[port];
+       void __iomem *ofsAddr = moxa_ports[port].tableAddr;
 
        if (!enable) {
                moxafunc(ofsAddr, FC_SetRxFIFOTrig, 0);
@@ -3049,132 +2861,3 @@ static void MoxaSetFifo(int port, int enable)
                moxafunc(ofsAddr, FC_SetTxFIFOCnt, 16);
        }
 }
-
-#if 0
-int MoxaPortSetMode(int port, int databits, int stopbits, int parity)
-{
-       void __iomem *ofsAddr;
-       int val;
-
-       val = 0;
-       switch (databits) {
-       case 5:
-               val |= 0;
-               break;
-       case 6:
-               val |= 1;
-               break;
-       case 7:
-               val |= 2;
-               break;
-       case 8:
-               val |= 3;
-               break;
-       default:
-               return (-1);
-       }
-       switch (stopbits) {
-       case 0:
-               val |= 0;
-               break;          /* stop bits 1.5 */
-       case 1:
-               val |= 0;
-               break;
-       case 2:
-               val |= 4;
-               break;
-       default:
-               return (-1);
-       }
-       switch (parity) {
-       case 0:
-               val |= 0x00;
-               break;          /* None  */
-       case 1:
-               val |= 0x08;
-               break;          /* Odd   */
-       case 2:
-               val |= 0x18;
-               break;          /* Even  */
-       case 3:
-               val |= 0x28;
-               break;          /* Mark  */
-       case 4:
-               val |= 0x38;
-               break;          /* Space */
-       default:
-               return (-1);
-       }
-       ofsAddr = moxaTableAddr[port];
-       moxafunc(ofsAddr, FC_SetMode, val);
-       return (0);
-}
-
-int MoxaPortTxBufSize(int port)
-{
-       void __iomem *ofsAddr;
-       int size;
-
-       ofsAddr = moxaTableAddr[port];
-       size = readw(ofsAddr + TX_mask);
-       return (size);
-}
-
-int MoxaPortRxBufSize(int port)
-{
-       void __iomem *ofsAddr;
-       int size;
-
-       ofsAddr = moxaTableAddr[port];
-       size = readw(ofsAddr + RX_mask);
-       return (size);
-}
-
-int MoxaPortRxFree(int port)
-{
-       void __iomem *ofsAddr;
-       ushort rptr, wptr, mask;
-       int len;
-
-       ofsAddr = moxaTableAddr[port];
-       rptr = readw(ofsAddr + RXrptr);
-       wptr = readw(ofsAddr + RXwptr);
-       mask = readw(ofsAddr + RX_mask);
-       len = mask - ((wptr - rptr) & mask);
-       return (len);
-}
-int MoxaPortGetBrkCnt(int port)
-{
-       return (moxaBreakCnt[port]);
-}
-
-void MoxaPortSetXonXoff(int port, int xonValue, int xoffValue)
-{
-       void __iomem *ofsAddr;
-
-       ofsAddr = moxaTableAddr[port];
-       writew(xonValue, ofsAddr + FuncArg);
-       writew(xoffValue, ofsAddr + FuncArg1);
-       writew(FC_SetXonXoff, ofsAddr + FuncCode);
-       wait_finish(ofsAddr);
-}
-
-int MoxaPortIsTxHold(int port)
-{
-       void __iomem *ofsAddr;
-       int val;
-
-       ofsAddr = moxaTableAddr[port];
-       if ((moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_ISA) ||
-           (moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_PCI)) {
-               moxafunc(ofsAddr, FC_GetCCSR, 0);
-               val = readw(ofsAddr + FuncArg);
-               if (val & 0x04)
-                       return (1);
-       } else {
-               if (readw(ofsAddr + FlagStat) & Tx_flowOff)
-                       return (1);
-       }
-       return (0);
-}
-#endif
index 83f604b19290706f3a04577c463a4cfeec029a0a..a61fb6da5d03f0b757b93c45893f01a8d031ddc8 100644 (file)
@@ -321,8 +321,6 @@ struct mxser_struct {
        unsigned long event;
        int count;              /* # of fd on device */
        int blocked_open;       /* # of blocked opens */
-       long session;           /* Session of opening process */
-       long pgrp;              /* pgrp of opening process */
        unsigned char *xmit_buf;
        int xmit_head;
        int xmit_tail;
@@ -1001,15 +999,12 @@ static int mxser_open(struct tty_struct *tty, struct file *filp)
                mxser_change_speed(info, NULL);
        }
 
-       info->session = process_session(current);
-       info->pgrp = process_group(current);
-
        /*
        status = mxser_get_msr(info->base, 0, info->port);
        mxser_check_modem_status(info, status);
        */
 
-/* unmark here for very high baud rate (ex. 921600 bps) used */
+       /* unmark here for very high baud rate (ex. 921600 bps) used */
        tty->low_latency = 1;
        return 0;
 }
@@ -1254,9 +1249,7 @@ static void mxser_flush_buffer(struct tty_struct *tty)
        spin_unlock_irqrestore(&info->slock, flags);
        /* above added by shinhay */
 
-       wake_up_interruptible(&tty->write_wait);
-       if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && tty->ldisc.write_wakeup)
-               (tty->ldisc.write_wakeup) (tty);
+       tty_wakeup(tty);
 }
 
 static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg)
index 7e188a4d602a7060915a89eda89d95533bfc2636..9fe28497eae9ed51b8780673cd111456b1ff8aec 100644 (file)
 
 #define READ_MOXA_MUST_GDL(baseio)     inb((baseio)+MOXA_MUST_GDL_REGISTER)
 
-
-#ifndef INIT_WORK
-#define INIT_WORK(_work, _func, _data){        \
-       _data->tqueue.routine = _func;\
-       _data->tqueue.data = _data;\
-       }
-#endif
-
 #endif
index 1bb030b3a51a6ec3017cf2d21537ceef4f6f1fbf..9af07e4999d5f0cac406a3f2200adad82b27dcca 100644 (file)
 
 #include "mxser_new.h"
 
-#define        MXSER_VERSION   "2.0"
+#define        MXSER_VERSION   "2.0.1"         /* 1.9.15 */
 #define        MXSERMAJOR       174
 #define        MXSERCUMAJOR     175
 
-#define        MXSER_EVENT_TXLOW       1
-
 #define MXSER_BOARDS           4       /* Max. boards */
 #define MXSER_PORTS_PER_BOARD  8       /* Max. ports per board */
 #define MXSER_PORTS            (MXSER_BOARDS * MXSER_PORTS_PER_BOARD)
-#define MXSER_ISR_PASS_LIMIT   99999L
+#define MXSER_ISR_PASS_LIMIT   100
 
 #define        MXSER_ERR_IOADDR        -1
 #define        MXSER_ERR_IRQ           -2
 #define        MXSER_ERR_IRQ_CONFLIT   -3
 #define        MXSER_ERR_VECTOR        -4
 
+/*CheckIsMoxaMust return value*/
+#define MOXA_OTHER_UART                0x00
+#define MOXA_MUST_MU150_HWID   0x01
+#define MOXA_MUST_MU860_HWID   0x02
+
 #define WAKEUP_CHARS           256
 
 #define UART_MCR_AFE           0x20
@@ -176,6 +179,18 @@ static struct pci_device_id mxser_pcibrds[] = {
 };
 MODULE_DEVICE_TABLE(pci, mxser_pcibrds);
 
+static int mxvar_baud_table[] = {
+       0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400,
+       4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800, 921600
+};
+static unsigned int mxvar_baud_table1[] = {
+       0, B50, B75, B110, B134, B150, B200, B300, B600, B1200, B1800, B2400,
+       B4800, B9600, B19200, B38400, B57600, B115200, B230400, B460800, B921600
+};
+#define BAUD_TABLE_NO ARRAY_SIZE(mxvar_baud_table)
+
+#define B_SPEC B2000000
+
 static int ioaddr[MXSER_BOARDS] = { 0, 0, 0, 0 };
 static int ttymajor = MXSERMAJOR;
 static int calloutmajor = MXSERCUMAJOR;
@@ -237,8 +252,7 @@ struct mxser_port {
        long realbaud;
        int type;               /* UART type */
        int flags;              /* defined in tty.h */
-       long session;           /* Session of opening process */
-       long pgrp;              /* pgrp of opening process */
+       int speed;
 
        int x_char;             /* xon/xoff character */
        int IER;                /* Interrupt Enable Register */
@@ -267,14 +281,11 @@ struct mxser_port {
        int xmit_cnt;
 
        struct ktermios normal_termios;
-       struct ktermios callout_termios;
 
        struct mxser_mon mon_data;
 
        spinlock_t slock;
-       struct work_struct tqueue;
        wait_queue_head_t open_wait;
-       wait_queue_head_t close_wait;
        wait_queue_head_t delta_msr_wait;
 };
 
@@ -313,10 +324,9 @@ static int mxvar_diagflag;
 static unsigned char mxser_msr[MXSER_PORTS + 1];
 static struct mxser_mon_ext mon_data_ext;
 static int mxser_set_baud_method[MXSER_PORTS + 1];
-static spinlock_t gm_lock;
 
 #ifdef CONFIG_PCI
-static int CheckIsMoxaMust(int io)
+static int __devinit CheckIsMoxaMust(int io)
 {
        u8 oldmcr, hwid;
        int i;
@@ -360,15 +370,6 @@ static void process_txrx_fifo(struct mxser_port *info)
                        }
 }
 
-static void mxser_do_softint(struct work_struct *work)
-{
-       struct mxser_port *info = container_of(work, struct mxser_port, tqueue);
-       struct tty_struct *tty = info->tty;
-
-       if (test_and_clear_bit(MXSER_EVENT_TXLOW, &info->event))
-               tty_wakeup(tty);
-}
-
 static unsigned char mxser_get_msr(int baseaddr, int mode, int port)
 {
        unsigned char status = 0;
@@ -456,10 +457,10 @@ static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp,
 
 static int mxser_set_baud(struct mxser_port *info, long newspd)
 {
+       unsigned int i;
        int quot = 0;
        unsigned char cval;
        int ret = 0;
-       unsigned long flags;
 
        if (!info->tty || !info->tty->termios)
                return ret;
@@ -471,29 +472,34 @@ static int mxser_set_baud(struct mxser_port *info, long newspd)
                return 0;
 
        info->realbaud = newspd;
-       if (newspd == 134) {
-               quot = (2 * info->baud_base / 269);
-       } else if (newspd) {
-               quot = info->baud_base / newspd;
-               if (quot == 0)
-                       quot = 1;
+       for (i = 0; i < BAUD_TABLE_NO; i++)
+              if (newspd == mxvar_baud_table[i])
+                      break;
+       if (i == BAUD_TABLE_NO) {
+               quot = info->baud_base / info->speed;
+               if (info->speed <= 0 || info->speed > info->max_baud)
+                       quot = 0;
        } else {
-               quot = 0;
+               if (newspd == 134) {
+                       quot = (2 * info->baud_base / 269);
+               } else if (newspd) {
+                       quot = info->baud_base / newspd;
+                       if (quot == 0)
+                               quot = 1;
+               } else {
+                       quot = 0;
+               }
        }
 
        info->timeout = ((info->xmit_fifo_size * HZ * 10 * quot) / info->baud_base);
        info->timeout += HZ / 50;       /* Add .02 seconds of slop */
 
        if (quot) {
-               spin_lock_irqsave(&info->slock, flags);
                info->MCR |= UART_MCR_DTR;
                outb(info->MCR, info->ioaddr + UART_MCR);
-               spin_unlock_irqrestore(&info->slock, flags);
        } else {
-               spin_lock_irqsave(&info->slock, flags);
                info->MCR &= ~UART_MCR_DTR;
                outb(info->MCR, info->ioaddr + UART_MCR);
-               spin_unlock_irqrestore(&info->slock, flags);
                return ret;
        }
 
@@ -505,6 +511,18 @@ static int mxser_set_baud(struct mxser_port *info, long newspd)
        outb(quot >> 8, info->ioaddr + UART_DLM);       /* MS of divisor */
        outb(cval, info->ioaddr + UART_LCR);    /* reset DLAB */
 
+       if (i == BAUD_TABLE_NO) {
+               quot = info->baud_base % info->speed;
+               quot *= 8;
+               if ((quot % info->speed) > (info->speed / 2)) {
+                       quot /= info->speed;
+                       quot++;
+               } else {
+                       quot /= info->speed;
+               }
+               SET_MOXA_MUST_ENUM_VALUE(info->ioaddr, quot);
+       } else
+               SET_MOXA_MUST_ENUM_VALUE(info->ioaddr, 0);
 
        return ret;
 }
@@ -520,7 +538,6 @@ static int mxser_change_speed(struct mxser_port *info,
        int ret = 0;
        unsigned char status;
        long baud;
-       unsigned long flags;
 
        if (!info->tty || !info->tty->termios)
                return ret;
@@ -529,7 +546,10 @@ static int mxser_change_speed(struct mxser_port *info,
                return ret;
 
        if (mxser_set_baud_method[info->tty->index] == 0) {
-               baud = tty_get_baud_rate(info->tty);
+               if ((cflag & CBAUD) == B_SPEC)
+                       baud = info->speed;
+               else
+                       baud = tty_get_baud_rate(info->tty);
                mxser_set_baud(info, baud);
        }
 
@@ -612,8 +632,8 @@ static int mxser_change_speed(struct mxser_port *info,
                                                outb(info->IER, info->ioaddr +
                                                                UART_IER);
                                        }
-                                       set_bit(MXSER_EVENT_TXLOW, &info->event);
-                                       schedule_work(&info->tqueue);                           }
+                                       tty_wakeup(info->tty);
+                               }
                        } else {
                                if (!(status & UART_MSR_CTS)) {
                                        info->tty->hw_stopped = 1;
@@ -668,7 +688,6 @@ static int mxser_change_speed(struct mxser_port *info,
                }
        }
        if (info->board->chip_flag) {
-               spin_lock_irqsave(&info->slock, flags);
                SET_MOXA_MUST_XON1_VALUE(info->ioaddr, START_CHAR(info->tty));
                SET_MOXA_MUST_XOFF1_VALUE(info->ioaddr, STOP_CHAR(info->tty));
                if (I_IXON(info->tty)) {
@@ -681,7 +700,6 @@ static int mxser_change_speed(struct mxser_port *info,
                } else {
                        DISABLE_MOXA_MUST_TX_SOFTWARE_FLOW_CONTROL(info->ioaddr);
                }
-               spin_unlock_irqrestore(&info->slock, flags);
        }
 
 
@@ -708,7 +726,6 @@ static void mxser_check_modem_status(struct mxser_port *port, int status)
        if ((port->flags & ASYNC_CHECK_CD) && (status & UART_MSR_DDCD)) {
                if (status & UART_MSR_DCD)
                        wake_up_interruptible(&port->open_wait);
-               schedule_work(&port->tqueue);
        }
 
        if (port->flags & ASYNC_CTS_FLOW) {
@@ -724,8 +741,7 @@ static void mxser_check_modem_status(struct mxser_port *port, int status)
                                        outb(port->IER, port->ioaddr +
                                                        UART_IER);
                                }
-                               set_bit(MXSER_EVENT_TXLOW, &port->event);
-                               schedule_work(&port->tqueue);
+                               tty_wakeup(port->tty);
                        }
                } else {
                        if (!(status & UART_MSR_CTS)) {
@@ -836,10 +852,10 @@ static int mxser_startup(struct mxser_port *info)
        /*
         * and set the speed of the serial port
         */
-       spin_unlock_irqrestore(&info->slock, flags);
        mxser_change_speed(info, NULL);
-
        info->flags |= ASYNC_INITIALIZED;
+       spin_unlock_irqrestore(&info->slock, flags);
+
        return 0;
 }
 
@@ -909,11 +925,9 @@ static void mxser_shutdown(struct mxser_port *info)
 static int mxser_open(struct tty_struct *tty, struct file *filp)
 {
        struct mxser_port *info;
+       unsigned long flags;
        int retval, line;
 
-       /* initialize driver_data in case something fails */
-       tty->driver_data = NULL;
-
        line = tty->index;
        if (line == MXSER_PORTS)
                return 0;
@@ -928,7 +942,9 @@ static int mxser_open(struct tty_struct *tty, struct file *filp)
        /*
         * Start up serial port
         */
+       spin_lock_irqsave(&info->slock, flags);
        info->count++;
+       spin_unlock_irqrestore(&info->slock, flags);
        retval = mxser_startup(info);
        if (retval)
                return retval;
@@ -937,17 +953,6 @@ static int mxser_open(struct tty_struct *tty, struct file *filp)
        if (retval)
                return retval;
 
-       if ((info->count == 1) && (info->flags & ASYNC_SPLIT_TERMIOS)) {
-               if (tty->driver->subtype == SERIAL_TYPE_NORMAL)
-                       *tty->termios = info->normal_termios;
-               else
-                       *tty->termios = info->callout_termios;
-               mxser_change_speed(info, NULL);
-       }
-
-       info->session = process_session(current);
-       info->pgrp = process_group(current);
-
        /* unmark here for very high baud rate (ex. 921600 bps) used */
        tty->low_latency = 1;
        return 0;
@@ -1054,8 +1059,6 @@ static void mxser_close(struct tty_struct *tty, struct file *filp)
        }
 
        info->flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CLOSING);
-       wake_up_interruptible(&info->close_wait);
-
 }
 
 static int mxser_write(struct tty_struct *tty, const unsigned char *buf, int count)
@@ -1222,6 +1225,7 @@ static int mxser_set_serial_info(struct mxser_port *info,
                struct serial_struct __user *new_info)
 {
        struct serial_struct new_serial;
+       unsigned long sl_flags;
        unsigned int flags;
        int retval = 0;
 
@@ -1264,8 +1268,11 @@ static int mxser_set_serial_info(struct mxser_port *info,
        process_txrx_fifo(info);
 
        if (info->flags & ASYNC_INITIALIZED) {
-               if (flags != (info->flags & ASYNC_SPD_MASK))
+               if (flags != (info->flags & ASYNC_SPD_MASK)) {
+                       spin_lock_irqsave(&info->slock, sl_flags);
                        mxser_change_speed(info, NULL);
+                       spin_unlock_irqrestore(&info->slock, sl_flags);
+               }
        } else
                retval = mxser_startup(info);
 
@@ -1373,11 +1380,10 @@ static int mxser_tiocmset(struct tty_struct *tty, struct file *file,
        return 0;
 }
 
-static int mxser_program_mode(int port)
+static int __init mxser_program_mode(int port)
 {
        int id, i, j, n;
 
-       spin_lock(&gm_lock);
        outb(0, port);
        outb(0, port);
        outb(0, port);
@@ -1385,7 +1391,6 @@ static int mxser_program_mode(int port)
        (void)inb(port);
        outb(0, port);
        (void)inb(port);
-       spin_unlock(&gm_lock);
 
        id = inb(port + 1) & 0x1F;
        if ((id != C168_ASIC_ID) &&
@@ -1410,7 +1415,7 @@ static int mxser_program_mode(int port)
        return id;
 }
 
-static void mxser_normal_mode(int port)
+static void __init mxser_normal_mode(int port)
 {
        int i, n;
 
@@ -1443,7 +1448,7 @@ static void mxser_normal_mode(int port)
 #define EN0_PORT       0x010   /* Rcv missed frame error counter RD */
 #define ENC_PAGE0      0x000   /* Select page 0 of chip registers   */
 #define ENC_PAGE3      0x0C0   /* Select page 3 of chip registers   */
-static int mxser_read_register(int port, unsigned short *regs)
+static int __init mxser_read_register(int port, unsigned short *regs)
 {
        int i, k, value, id;
        unsigned int j;
@@ -1644,6 +1649,7 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file,
        struct serial_icounter_struct __user *p_cuser;
        unsigned long templ;
        unsigned long flags;
+       unsigned int i;
        void __user *argp = (void __user *)arg;
        int retval;
 
@@ -1682,6 +1688,36 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file,
                return 0;
        }
 
+       if (cmd == MOXA_SET_SPECIAL_BAUD_RATE) {
+               int speed;
+
+               if (get_user(speed, (int __user *)argp))
+                       return -EFAULT;
+               if (speed <= 0 || speed > info->max_baud)
+                       return -EFAULT;
+               if (!info->tty || !info->tty->termios || !info->ioaddr)
+                       return 0;
+               info->tty->termios->c_cflag &= ~(CBAUD | CBAUDEX);
+               for (i = 0; i < BAUD_TABLE_NO; i++)
+                       if (speed == mxvar_baud_table[i])
+                               break;
+               if (i == BAUD_TABLE_NO) {
+                       info->tty->termios->c_cflag |= B_SPEC;
+               } else if (speed != 0)
+                       info->tty->termios->c_cflag |= mxvar_baud_table1[i];
+
+               info->speed = speed;
+               spin_lock_irqsave(&info->slock, flags);
+               mxser_change_speed(info, NULL);
+               spin_unlock_irqrestore(&info->slock, flags);
+
+               return 0;
+       } else if (cmd == MOXA_GET_SPECIAL_BAUD_RATE) {
+               if (copy_to_user(argp, &info->speed, sizeof(int)))
+                    return -EFAULT;
+               return 0;
+       }
+
        if (cmd != TIOCGSERIAL && cmd != TIOCMIWAIT && cmd != TIOCGICOUNT &&
                        test_bit(TTY_IO_ERROR, &tty->flags))
                return -EIO;
@@ -1799,7 +1835,9 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file,
                long baud;
                if (get_user(baud, (long __user *)argp))
                        return -EFAULT;
+               spin_lock_irqsave(&info->slock, flags);
                mxser_set_baud(info, baud);
+               spin_unlock_irqrestore(&info->slock, flags);
                return 0;
        }
        case MOXA_ASPP_GETBAUD:
@@ -1976,7 +2014,9 @@ static void mxser_set_termios(struct tty_struct *tty, struct ktermios *old_termi
        if ((tty->termios->c_cflag != old_termios->c_cflag) ||
                        (RELEVANT_IFLAG(tty->termios->c_iflag) != RELEVANT_IFLAG(old_termios->c_iflag))) {
 
+               spin_lock_irqsave(&info->slock, flags);
                mxser_change_speed(info, old_termios);
+               spin_unlock_irqrestore(&info->slock, flags);
 
                if ((old_termios->c_cflag & CRTSCTS) &&
                                !(tty->termios->c_cflag & CRTSCTS)) {
@@ -2066,7 +2106,7 @@ static void mxser_wait_until_sent(struct tty_struct *tty, int timeout)
 /*
  * This routine is called by tty_hangup() when a hangup is signaled.
  */
-void mxser_hangup(struct tty_struct *tty)
+static void mxser_hangup(struct tty_struct *tty)
 {
        struct mxser_port *info = tty->driver_data;
 
@@ -2105,9 +2145,6 @@ static void mxser_receive_chars(struct mxser_port *port, int *status)
        int cnt = 0;
        int recv_room;
        int max = 256;
-       unsigned long flags;
-
-       spin_lock_irqsave(&port->slock, flags);
 
        recv_room = tty->receive_room;
        if ((recv_room == 0) && (!port->ldisc_stop_rx))
@@ -2169,7 +2206,8 @@ intr_old:
                                } else if (*status & UART_LSR_OE) {
                                        flag = TTY_OVERRUN;
                                        port->icount.overrun++;
-                               }
+                               } else
+                                       flag = TTY_BREAK;
                        }
                        tty_insert_flip_char(tty, ch, flag);
                        cnt++;
@@ -2191,7 +2229,6 @@ end_intr:
        mxvar_log.rxcnt[port->tty->index] += cnt;
        port->mon_data.rxcnt += cnt;
        port->mon_data.up_rxcnt += cnt;
-       spin_unlock_irqrestore(&port->slock, flags);
 
        tty_flip_buffer_push(tty);
 }
@@ -2199,9 +2236,6 @@ end_intr:
 static void mxser_transmit_chars(struct mxser_port *port)
 {
        int count, cnt;
-       unsigned long flags;
-
-       spin_lock_irqsave(&port->slock, flags);
 
        if (port->x_char) {
                outb(port->x_char, port->ioaddr + UART_TX);
@@ -2210,11 +2244,11 @@ static void mxser_transmit_chars(struct mxser_port *port)
                port->mon_data.txcnt++;
                port->mon_data.up_txcnt++;
                port->icount.tx++;
-               goto unlock;
+               return;
        }
 
        if (port->xmit_buf == 0)
-               goto unlock;
+               return;
 
        if ((port->xmit_cnt <= 0) || port->tty->stopped ||
                        (port->tty->hw_stopped &&
@@ -2222,7 +2256,7 @@ static void mxser_transmit_chars(struct mxser_port *port)
                        (!port->board->chip_flag))) {
                port->IER &= ~UART_IER_THRI;
                outb(port->IER, port->ioaddr + UART_IER);
-               goto unlock;
+               return;
        }
 
        cnt = port->xmit_cnt;
@@ -2240,16 +2274,13 @@ static void mxser_transmit_chars(struct mxser_port *port)
        port->mon_data.up_txcnt += (cnt - port->xmit_cnt);
        port->icount.tx += (cnt - port->xmit_cnt);
 
-       if (port->xmit_cnt < WAKEUP_CHARS) {
-               set_bit(MXSER_EVENT_TXLOW, &port->event);
-               schedule_work(&port->tqueue);
-       }
+       if (port->xmit_cnt < WAKEUP_CHARS)
+               tty_wakeup(port->tty);
+
        if (port->xmit_cnt <= 0) {
                port->IER &= ~UART_IER_THRI;
                outb(port->IER, port->ioaddr + UART_IER);
        }
-unlock:
-       spin_unlock_irqrestore(&port->slock, flags);
 }
 
 /*
@@ -2261,8 +2292,7 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id)
        struct mxser_board *brd = NULL;
        struct mxser_port *port;
        int max, irqbits, bits, msr;
-       int pass_counter = 0;
-       unsigned int int_cnt;
+       unsigned int int_cnt, pass_counter = 0;
        int handled = IRQ_NONE;
 
        for (i = 0; i < MXSER_BOARDS; i++)
@@ -2276,7 +2306,7 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id)
        if (brd == NULL)
                goto irq_stop;
        max = brd->info->nports;
-       while (1) {
+       while (pass_counter++ < MXSER_ISR_PASS_LIMIT) {
                irqbits = inb(brd->vector) & brd->vector_mask;
                if (irqbits == brd->vector_mask)
                        break;
@@ -2290,12 +2320,16 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id)
                        port = &brd->ports[i];
 
                        int_cnt = 0;
+                       spin_lock(&port->slock);
                        do {
                                iir = inb(port->ioaddr + UART_IIR);
                                if (iir & UART_IIR_NO_INT)
                                        break;
                                iir &= MOXA_MUST_IIR_MASK;
-                               if (!port->tty) {
+                               if (!port->tty ||
+                                               (port->flags & ASYNC_CLOSING) ||
+                                               !(port->flags &
+                                                       ASYNC_INITIALIZED)) {
                                        status = inb(port->ioaddr + UART_LSR);
                                        outb(0x27, port->ioaddr + UART_FCR);
                                        inb(port->ioaddr + UART_MSR);
@@ -2341,9 +2375,8 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id)
                                                mxser_transmit_chars(port);
                                }
                        } while (int_cnt++ < MXSER_ISR_PASS_LIMIT);
+                       spin_unlock(&port->slock);
                }
-               if (pass_counter++ > MXSER_ISR_PASS_LIMIT)
-                       break;  /* Prevent infinite loops */
        }
 
 irq_stop:
@@ -2385,7 +2418,6 @@ static void mxser_release_res(struct mxser_board *brd, struct pci_dev *pdev,
 #ifdef CONFIG_PCI
                pci_release_region(pdev, 2);
                pci_release_region(pdev, 3);
-               pci_dev_put(pdev);
 #endif
        } else {
                release_region(brd->ports[0].ioaddr, 8 * brd->info->nports);
@@ -2420,11 +2452,10 @@ static int __devinit mxser_initbrd(struct mxser_board *brd,
                info->custom_divisor = info->baud_base * 16;
                info->close_delay = 5 * HZ / 10;
                info->closing_wait = 30 * HZ;
-               INIT_WORK(&info->tqueue, mxser_do_softint);
                info->normal_termios = mxvar_sdriver->init_termios;
                init_waitqueue_head(&info->open_wait);
-               init_waitqueue_head(&info->close_wait);
                init_waitqueue_head(&info->delta_msr_wait);
+               info->speed = 9600;
                memset(&info->mon_data, 0, sizeof(struct mxser_mon));
                info->err_shadow = 0;
                spin_lock_init(&info->slock);
@@ -2433,22 +2464,17 @@ static int __devinit mxser_initbrd(struct mxser_board *brd,
                outb(inb(info->ioaddr + UART_IER) & 0xf0,
                        info->ioaddr + UART_IER);
        }
-       /*
-        * Allocate the IRQ if necessary
-        */
 
-       retval = request_irq(brd->irq, mxser_interrupt,
-                       (brd->ports[0].flags & ASYNC_SHARE_IRQ) ? IRQF_SHARED :
-                       IRQF_DISABLED, "mxser", brd);
+       retval = request_irq(brd->irq, mxser_interrupt, IRQF_SHARED, "mxser",
+                       brd);
        if (retval) {
                printk(KERN_ERR "Board %s: Request irq failed, IRQ (%d) may "
                        "conflict with another device.\n",
                        brd->info->name, brd->irq);
                /* We hold resources, we need to release them. */
                mxser_release_res(brd, pdev, 0);
-               return retval;
        }
-       return 0;
+       return retval;
 }
 
 static int __init mxser_get_ISA_conf(int cap, struct mxser_board *brd)
@@ -2633,8 +2659,9 @@ static int __devinit mxser_probe(struct pci_dev *pdev,
        }
 
        /* mxser_initbrd will hook ISR. */
-       if (mxser_initbrd(brd, pdev) < 0)
-               goto err_relvec;
+       retval = mxser_initbrd(brd, pdev);
+       if (retval)
+               goto err_null;
 
        for (i = 0; i < brd->info->nports; i++)
                tty_register_device(mxvar_sdriver, brd->idx + i, &pdev->dev);
@@ -2642,10 +2669,9 @@ static int __devinit mxser_probe(struct pci_dev *pdev,
        pci_set_drvdata(pdev, brd);
 
        return 0;
-err_relvec:
-       pci_release_region(pdev, 3);
 err_relio:
        pci_release_region(pdev, 2);
+err_null:
        brd->info = NULL;
 err:
        return retval;
@@ -2663,6 +2689,7 @@ static void __devexit mxser_remove(struct pci_dev *pdev)
                tty_unregister_device(mxvar_sdriver, brd->idx + i);
 
        mxser_release_res(brd, pdev, 1);
+       brd->info = NULL;
 }
 
 static struct pci_driver mxser_driver = {
@@ -2684,7 +2711,6 @@ static int __init mxser_module_init(void)
        mxvar_sdriver = alloc_tty_driver(MXSER_PORTS + 1);
        if (!mxvar_sdriver)
                return -ENOMEM;
-       spin_lock_init(&gm_lock);
 
        printk(KERN_INFO "MOXA Smartio/Industio family driver version %s\n",
                MXSER_VERSION);
index a08f0ecb09ba76deaba83d8aff1ed691621ca850..d42f7766c65292cf83f4eb44eb1bbf6ae1ab5ed3 100644 (file)
 #define RS422_MODE             2
 #define RS485_4WIRE_MODE       3
 #define OP_MODE_MASK           3
-// above add by Victor Yu. 01-05-2004
-
-#define TTY_THRESHOLD_THROTTLE  128
-
-#define LO_WATER               (TTY_FLIPBUF_SIZE)
-#define HI_WATER               (TTY_FLIPBUF_SIZE*2*3/4)
-
-// added by James. 03-11-2004.
-#define MOXA_SDS_GETICOUNTER   (MOXA + 68)
-#define MOXA_SDS_RSTICOUNTER   (MOXA + 69)
-// (above) added by James.
 
+#define MOXA_SDS_RSTICOUNTER   (MOXA + 69)
 #define MOXA_ASPP_OQUEUE       (MOXA + 70)
 #define MOXA_ASPP_SETBAUD      (MOXA + 71)
 #define MOXA_ASPP_GETBAUD      (MOXA + 72)
@@ -45,7 +35,8 @@
 #define MOXA_ASPP_LSTATUS      (MOXA + 74)
 #define MOXA_ASPP_MON_EXT      (MOXA + 75)
 #define MOXA_SET_BAUD_METHOD   (MOXA + 76)
-
+#define MOXA_SET_SPECIAL_BAUD_RATE     (MOXA + 77)
+#define MOXA_GET_SPECIAL_BAUD_RATE     (MOXA + 78)
 
 /* --------------------------------------------------- */
 
 #define NPPI_NOTIFY_SW_OVERRUN 0x08
 #define NPPI_NOTIFY_BREAK      0x10
 
-#define NPPI_NOTIFY_CTSHOLD         0x01       // Tx hold by CTS low
-#define NPPI_NOTIFY_DSRHOLD         0x02       // Tx hold by DSR low
-#define NPPI_NOTIFY_XOFFHOLD        0x08       // Tx hold by Xoff received
-#define NPPI_NOTIFY_XOFFXENT        0x10       // Xoff Sent
-
-//CheckIsMoxaMust return value
-#define MOXA_OTHER_UART                        0x00
-#define MOXA_MUST_MU150_HWID           0x01
-#define MOXA_MUST_MU860_HWID           0x02
-
-// follow just for Moxa Must chip define.
-//
-// when LCR register (offset 0x03) write following value,
-// the Must chip will enter enchance mode. And write value
-// on EFR (offset 0x02) bit 6,7 to change bank.
+#define NPPI_NOTIFY_CTSHOLD         0x01       /* Tx hold by CTS low */
+#define NPPI_NOTIFY_DSRHOLD         0x02       /* Tx hold by DSR low */
+#define NPPI_NOTIFY_XOFFHOLD        0x08       /* Tx hold by Xoff received */
+#define NPPI_NOTIFY_XOFFXENT        0x10       /* Xoff Sent */
+
+/* follow just for Moxa Must chip define. */
+/* */
+/* when LCR register (offset 0x03) write following value, */
+/* the Must chip will enter enchance mode. And write value */
+/* on EFR (offset 0x02) bit 6,7 to change bank. */
 #define MOXA_MUST_ENTER_ENCHANCE       0xBF
 
-// when enhance mode enable, access on general bank register
+/* when enhance mode enable, access on general bank register */
 #define MOXA_MUST_GDL_REGISTER         0x07
 #define MOXA_MUST_GDL_MASK             0x7F
 #define MOXA_MUST_GDL_HAS_BAD_DATA     0x80
 
-#define MOXA_MUST_LSR_RERR             0x80    // error in receive FIFO
-// enchance register bank select and enchance mode setting register
-// when LCR register equal to 0xBF
+#define MOXA_MUST_LSR_RERR             0x80    /* error in receive FIFO */
+/* enchance register bank select and enchance mode setting register */
+/* when LCR register equal to 0xBF */
 #define MOXA_MUST_EFR_REGISTER         0x02
-// enchance mode enable
+/* enchance mode enable */
 #define MOXA_MUST_EFR_EFRB_ENABLE      0x10
-// enchance reister bank set 0, 1, 2
+/* enchance reister bank set 0, 1, 2 */
 #define MOXA_MUST_EFR_BANK0            0x00
 #define MOXA_MUST_EFR_BANK1            0x40
 #define MOXA_MUST_EFR_BANK2            0x80
 #define MOXA_MUST_EFR_BANK3            0xC0
 #define MOXA_MUST_EFR_BANK_MASK                0xC0
 
-// set XON1 value register, when LCR=0xBF and change to bank0
+/* set XON1 value register, when LCR=0xBF and change to bank0 */
 #define MOXA_MUST_XON1_REGISTER                0x04
 
-// set XON2 value register, when LCR=0xBF and change to bank0
+/* set XON2 value register, when LCR=0xBF and change to bank0 */
 #define MOXA_MUST_XON2_REGISTER                0x05
 
-// set XOFF1 value register, when LCR=0xBF and change to bank0
+/* set XOFF1 value register, when LCR=0xBF and change to bank0 */
 #define MOXA_MUST_XOFF1_REGISTER       0x06
 
-// set XOFF2 value register, when LCR=0xBF and change to bank0
+/* set XOFF2 value register, when LCR=0xBF and change to bank0 */
 #define MOXA_MUST_XOFF2_REGISTER       0x07
 
 #define MOXA_MUST_RBRTL_REGISTER       0x04
 #define MOXA_MUST_ECR_REGISTER         0x06
 #define MOXA_MUST_CSR_REGISTER         0x07
 
-// good data mode enable
+/* good data mode enable */
 #define MOXA_MUST_FCR_GDA_MODE_ENABLE  0x20
-// only good data put into RxFIFO
+/* only good data put into RxFIFO */
 #define MOXA_MUST_FCR_GDA_ONLY_ENABLE  0x10
 
-// enable CTS interrupt
+/* enable CTS interrupt */
 #define MOXA_MUST_IER_ECTSI            0x80
-// enable RTS interrupt
+/* enable RTS interrupt */
 #define MOXA_MUST_IER_ERTSI            0x40
-// enable Xon/Xoff interrupt
+/* enable Xon/Xoff interrupt */
 #define MOXA_MUST_IER_XINT             0x20
-// enable GDA interrupt
+/* enable GDA interrupt */
 #define MOXA_MUST_IER_EGDAI            0x10
 
 #define MOXA_MUST_RECV_ISR             (UART_IER_RDI | MOXA_MUST_IER_EGDAI)
 
-// GDA interrupt pending
+/* GDA interrupt pending */
 #define MOXA_MUST_IIR_GDA              0x1C
 #define MOXA_MUST_IIR_RDA              0x04
 #define MOXA_MUST_IIR_RTO              0x0C
 #define MOXA_MUST_IIR_LSR              0x06
 
-// recieved Xon/Xoff or specical interrupt pending
+/* recieved Xon/Xoff or specical interrupt pending */
 #define MOXA_MUST_IIR_XSC              0x10
 
-// RTS/CTS change state interrupt pending
+/* RTS/CTS change state interrupt pending */
 #define MOXA_MUST_IIR_RTSCTS           0x20
 #define MOXA_MUST_IIR_MASK             0x3E
 
 #define MOXA_MUST_MCR_XON_ANY          0x80
 #define MOXA_MUST_MCR_TX_XON           0x08
 
-
-// software flow control on chip mask value
+/* software flow control on chip mask value */
 #define MOXA_MUST_EFR_SF_MASK          0x0F
-// send Xon1/Xoff1
+/* send Xon1/Xoff1 */
 #define MOXA_MUST_EFR_SF_TX1           0x08
-// send Xon2/Xoff2
+/* send Xon2/Xoff2 */
 #define MOXA_MUST_EFR_SF_TX2           0x04
-// send Xon1,Xon2/Xoff1,Xoff2
+/* send Xon1,Xon2/Xoff1,Xoff2 */
 #define MOXA_MUST_EFR_SF_TX12          0x0C
-// don't send Xon/Xoff
+/* don't send Xon/Xoff */
 #define MOXA_MUST_EFR_SF_TX_NO         0x00
-// Tx software flow control mask
+/* Tx software flow control mask */
 #define MOXA_MUST_EFR_SF_TX_MASK       0x0C
-// don't receive Xon/Xoff
+/* don't receive Xon/Xoff */
 #define MOXA_MUST_EFR_SF_RX_NO         0x00
-// receive Xon1/Xoff1
+/* receive Xon1/Xoff1 */
 #define MOXA_MUST_EFR_SF_RX1           0x02
-// receive Xon2/Xoff2
+/* receive Xon2/Xoff2 */
 #define MOXA_MUST_EFR_SF_RX2           0x01
-// receive Xon1,Xon2/Xoff1,Xoff2
+/* receive Xon1,Xon2/Xoff1,Xoff2 */
 #define MOXA_MUST_EFR_SF_RX12          0x03
-// Rx software flow control mask
+/* Rx software flow control mask */
 #define MOXA_MUST_EFR_SF_RX_MASK       0x03
 
-//#define MOXA_MUST_MIN_XOFFLIMIT               66
-//#define MOXA_MUST_MIN_XONLIMIT                20
-//#define ID1_RX_TRIG                   120
-
-
-#define CHECK_MOXA_MUST_XOFFLIMIT(info) {      \
-       if ( (info)->IsMoxaMustChipFlag &&      \
-        (info)->HandFlow.XoffLimit < MOXA_MUST_MIN_XOFFLIMIT ) {       \
-               (info)->HandFlow.XoffLimit = MOXA_MUST_MIN_XOFFLIMIT;   \
-               (info)->HandFlow.XonLimit = MOXA_MUST_MIN_XONLIMIT;     \
-       }       \
-}
-
-#define ENABLE_MOXA_MUST_ENCHANCE_MODE(baseio) { \
-       u8      __oldlcr, __efr;        \
-       __oldlcr = inb((baseio)+UART_LCR);      \
+#define ENABLE_MOXA_MUST_ENCHANCE_MODE(baseio) do {            \
+       u8      __oldlcr, __efr;                                \
+       __oldlcr = inb((baseio)+UART_LCR);                      \
        outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);      \
-       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);   \
-       __efr |= MOXA_MUST_EFR_EFRB_ENABLE;     \
-       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);   \
-       outb(__oldlcr, (baseio)+UART_LCR);      \
-}
-
-#define DISABLE_MOXA_MUST_ENCHANCE_MODE(baseio) {      \
-       u8      __oldlcr, __efr;        \
-       __oldlcr = inb((baseio)+UART_LCR);      \
+       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);           \
+       __efr |= MOXA_MUST_EFR_EFRB_ENABLE;                     \
+       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);           \
+       outb(__oldlcr, (baseio)+UART_LCR);                      \
+} while (0)
+
+#define DISABLE_MOXA_MUST_ENCHANCE_MODE(baseio) do {           \
+       u8      __oldlcr, __efr;                                \
+       __oldlcr = inb((baseio)+UART_LCR);                      \
        outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);      \
-       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);   \
-       __efr &= ~MOXA_MUST_EFR_EFRB_ENABLE;    \
-       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);   \
-       outb(__oldlcr, (baseio)+UART_LCR);      \
-}
-
-#define SET_MOXA_MUST_XON1_VALUE(baseio, Value) {      \
-       u8      __oldlcr, __efr;        \
-       __oldlcr = inb((baseio)+UART_LCR);      \
+       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);           \
+       __efr &= ~MOXA_MUST_EFR_EFRB_ENABLE;                    \
+       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);           \
+       outb(__oldlcr, (baseio)+UART_LCR);                      \
+} while (0)
+
+#define SET_MOXA_MUST_XON1_VALUE(baseio, Value) do {           \
+       u8      __oldlcr, __efr;                                \
+       __oldlcr = inb((baseio)+UART_LCR);                      \
        outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);      \
-       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);   \
-       __efr &= ~MOXA_MUST_EFR_BANK_MASK;      \
-       __efr |= MOXA_MUST_EFR_BANK0;   \
-       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);   \
+       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);           \
+       __efr &= ~MOXA_MUST_EFR_BANK_MASK;                      \
+       __efr |= MOXA_MUST_EFR_BANK0;                           \
+       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);           \
        outb((u8)(Value), (baseio)+MOXA_MUST_XON1_REGISTER);    \
-       outb(__oldlcr, (baseio)+UART_LCR);      \
-}
+       outb(__oldlcr, (baseio)+UART_LCR);                      \
+} while (0)
 
-#define SET_MOXA_MUST_XON2_VALUE(baseio, Value) {      \
-       u8      __oldlcr, __efr;        \
-       __oldlcr = inb((baseio)+UART_LCR);      \
+#define SET_MOXA_MUST_XOFF1_VALUE(baseio, Value) do {          \
+       u8      __oldlcr, __efr;                                \
+       __oldlcr = inb((baseio)+UART_LCR);                      \
        outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);      \
-       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);   \
-       __efr &= ~MOXA_MUST_EFR_BANK_MASK;      \
-       __efr |= MOXA_MUST_EFR_BANK0;   \
-       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);   \
-       outb((u8)(Value), (baseio)+MOXA_MUST_XON2_REGISTER);    \
-       outb(__oldlcr, (baseio)+UART_LCR);      \
-}
-
-#define SET_MOXA_MUST_XOFF1_VALUE(baseio, Value) {     \
-       u8      __oldlcr, __efr;        \
-       __oldlcr = inb((baseio)+UART_LCR);      \
-       outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);      \
-       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);   \
-       __efr &= ~MOXA_MUST_EFR_BANK_MASK;      \
-       __efr |= MOXA_MUST_EFR_BANK0;   \
-       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);   \
+       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);           \
+       __efr &= ~MOXA_MUST_EFR_BANK_MASK;                      \
+       __efr |= MOXA_MUST_EFR_BANK0;                           \
+       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);           \
        outb((u8)(Value), (baseio)+MOXA_MUST_XOFF1_REGISTER);   \
-       outb(__oldlcr, (baseio)+UART_LCR);      \
-}
+       outb(__oldlcr, (baseio)+UART_LCR);                      \
+} while (0)
 
-#define SET_MOXA_MUST_XOFF2_VALUE(baseio, Value) {     \
-       u8      __oldlcr, __efr;        \
-       __oldlcr = inb((baseio)+UART_LCR);      \
-       outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);      \
-       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);   \
-       __efr &= ~MOXA_MUST_EFR_BANK_MASK;      \
-       __efr |= MOXA_MUST_EFR_BANK0;   \
-       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);   \
-       outb((u8)(Value), (baseio)+MOXA_MUST_XOFF2_REGISTER);   \
-       outb(__oldlcr, (baseio)+UART_LCR);      \
-}
-
-#define SET_MOXA_MUST_RBRTL_VALUE(baseio, Value) {     \
-       u8      __oldlcr, __efr;        \
-       __oldlcr = inb((baseio)+UART_LCR);      \
-       outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);      \
-       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);   \
-       __efr &= ~MOXA_MUST_EFR_BANK_MASK;      \
-       __efr |= MOXA_MUST_EFR_BANK1;   \
-       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);   \
-       outb((u8)(Value), (baseio)+MOXA_MUST_RBRTL_REGISTER);   \
-       outb(__oldlcr, (baseio)+UART_LCR);      \
-}
-
-#define SET_MOXA_MUST_RBRTH_VALUE(baseio, Value) {     \
-       u8      __oldlcr, __efr;        \
-       __oldlcr = inb((baseio)+UART_LCR);      \
-       outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);      \
-       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);   \
-       __efr &= ~MOXA_MUST_EFR_BANK_MASK;      \
-       __efr |= MOXA_MUST_EFR_BANK1;   \
-       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);   \
-       outb((u8)(Value), (baseio)+MOXA_MUST_RBRTH_REGISTER);   \
-       outb(__oldlcr, (baseio)+UART_LCR);      \
-}
-
-#define SET_MOXA_MUST_RBRTI_VALUE(baseio, Value) {     \
-       u8      __oldlcr, __efr;        \
-       __oldlcr = inb((baseio)+UART_LCR);      \
-       outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);      \
-       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);   \
-       __efr &= ~MOXA_MUST_EFR_BANK_MASK;      \
-       __efr |= MOXA_MUST_EFR_BANK1;   \
-       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);   \
-       outb((u8)(Value), (baseio)+MOXA_MUST_RBRTI_REGISTER);   \
-       outb(__oldlcr, (baseio)+UART_LCR);      \
-}
-
-#define SET_MOXA_MUST_THRTL_VALUE(baseio, Value) {     \
-       u8      __oldlcr, __efr;        \
-       __oldlcr = inb((baseio)+UART_LCR);      \
-       outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);      \
-       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);   \
-       __efr &= ~MOXA_MUST_EFR_BANK_MASK;      \
-       __efr |= MOXA_MUST_EFR_BANK1;   \
-       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);   \
-       outb((u8)(Value), (baseio)+MOXA_MUST_THRTL_REGISTER);   \
-       outb(__oldlcr, (baseio)+UART_LCR);      \
-}
-
-//#define MOXA_MUST_RBRL_VALUE  4
-#define SET_MOXA_MUST_FIFO_VALUE(info) {       \
-       u8      __oldlcr, __efr;        \
-       __oldlcr = inb((info)->ioaddr+UART_LCR);        \
-       outb(MOXA_MUST_ENTER_ENCHANCE, (info)->ioaddr+UART_LCR);        \
+#define SET_MOXA_MUST_FIFO_VALUE(info) do {                    \
+       u8      __oldlcr, __efr;                                \
+       __oldlcr = inb((info)->ioaddr+UART_LCR);                \
+       outb(MOXA_MUST_ENTER_ENCHANCE, (info)->ioaddr+UART_LCR);\
        __efr = inb((info)->ioaddr+MOXA_MUST_EFR_REGISTER);     \
-       __efr &= ~MOXA_MUST_EFR_BANK_MASK;      \
-       __efr |= MOXA_MUST_EFR_BANK1;   \
+       __efr &= ~MOXA_MUST_EFR_BANK_MASK;                      \
+       __efr |= MOXA_MUST_EFR_BANK1;                           \
        outb(__efr, (info)->ioaddr+MOXA_MUST_EFR_REGISTER);     \
-       outb((u8)((info)->rx_high_water), (info)->ioaddr+MOXA_MUST_RBRTH_REGISTER);     \
-       outb((u8)((info)->rx_trigger), (info)->ioaddr+MOXA_MUST_RBRTI_REGISTER);        \
-       outb((u8)((info)->rx_low_water), (info)->ioaddr+MOXA_MUST_RBRTL_REGISTER);      \
-       outb(__oldlcr, (info)->ioaddr+UART_LCR);        \
-}
-
-
-
-#define SET_MOXA_MUST_ENUM_VALUE(baseio, Value) {      \
-       u8      __oldlcr, __efr;        \
-       __oldlcr = inb((baseio)+UART_LCR);      \
+       outb((u8)((info)->rx_high_water), (info)->ioaddr+       \
+                       MOXA_MUST_RBRTH_REGISTER);              \
+       outb((u8)((info)->rx_trigger), (info)->ioaddr+          \
+                       MOXA_MUST_RBRTI_REGISTER);              \
+       outb((u8)((info)->rx_low_water), (info)->ioaddr+        \
+                       MOXA_MUST_RBRTL_REGISTER);              \
+       outb(__oldlcr, (info)->ioaddr+UART_LCR);                \
+} while (0)
+
+#define SET_MOXA_MUST_ENUM_VALUE(baseio, Value) do {           \
+       u8      __oldlcr, __efr;                                \
+       __oldlcr = inb((baseio)+UART_LCR);                      \
        outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);      \
-       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);   \
-       __efr &= ~MOXA_MUST_EFR_BANK_MASK;      \
-       __efr |= MOXA_MUST_EFR_BANK2;   \
-       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);   \
+       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);           \
+       __efr &= ~MOXA_MUST_EFR_BANK_MASK;                      \
+       __efr |= MOXA_MUST_EFR_BANK2;                           \
+       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);           \
        outb((u8)(Value), (baseio)+MOXA_MUST_ENUM_REGISTER);    \
-       outb(__oldlcr, (baseio)+UART_LCR);      \
-}
+       outb(__oldlcr, (baseio)+UART_LCR);                      \
+} while (0)
 
-#define GET_MOXA_MUST_HARDWARE_ID(baseio, pId) {       \
-       u8      __oldlcr, __efr;        \
-       __oldlcr = inb((baseio)+UART_LCR);      \
-       outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);      \
-       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);   \
-       __efr &= ~MOXA_MUST_EFR_BANK_MASK;      \
-       __efr |= MOXA_MUST_EFR_BANK2;   \
-       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);   \
-       *pId = inb((baseio)+MOXA_MUST_HWID_REGISTER);   \
-       outb(__oldlcr, (baseio)+UART_LCR);      \
-}
-
-#define SET_MOXA_MUST_NO_SOFTWARE_FLOW_CONTROL(baseio) {       \
-       u8      __oldlcr, __efr;        \
-       __oldlcr = inb((baseio)+UART_LCR);      \
-       outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);      \
-       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);   \
-       __efr &= ~MOXA_MUST_EFR_SF_MASK;        \
-       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);   \
-       outb(__oldlcr, (baseio)+UART_LCR);      \
-}
-
-#define SET_MOXA_MUST_JUST_TX_SOFTWARE_FLOW_CONTROL(baseio) {  \
-       u8      __oldlcr, __efr;        \
-       __oldlcr = inb((baseio)+UART_LCR);      \
+#define GET_MOXA_MUST_HARDWARE_ID(baseio, pId) do {            \
+       u8      __oldlcr, __efr;                                \
+       __oldlcr = inb((baseio)+UART_LCR);                      \
        outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);      \
-       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);   \
-       __efr &= ~MOXA_MUST_EFR_SF_MASK;        \
-       __efr |= MOXA_MUST_EFR_SF_TX1;  \
-       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);   \
-       outb(__oldlcr, (baseio)+UART_LCR);      \
-}
-
-#define ENABLE_MOXA_MUST_TX_SOFTWARE_FLOW_CONTROL(baseio) {    \
-       u8      __oldlcr, __efr;        \
-       __oldlcr = inb((baseio)+UART_LCR);      \
+       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);           \
+       __efr &= ~MOXA_MUST_EFR_BANK_MASK;                      \
+       __efr |= MOXA_MUST_EFR_BANK2;                           \
+       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);           \
+       *pId = inb((baseio)+MOXA_MUST_HWID_REGISTER);           \
+       outb(__oldlcr, (baseio)+UART_LCR);                      \
+} while (0)
+
+#define SET_MOXA_MUST_NO_SOFTWARE_FLOW_CONTROL(baseio) do {    \
+       u8      __oldlcr, __efr;                                \
+       __oldlcr = inb((baseio)+UART_LCR);                      \
        outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);      \
-       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);   \
-       __efr &= ~MOXA_MUST_EFR_SF_TX_MASK;     \
-       __efr |= MOXA_MUST_EFR_SF_TX1;  \
-       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);   \
-       outb(__oldlcr, (baseio)+UART_LCR);      \
-}
-
-#define DISABLE_MOXA_MUST_TX_SOFTWARE_FLOW_CONTROL(baseio) {   \
-       u8      __oldlcr, __efr;        \
-       __oldlcr = inb((baseio)+UART_LCR);      \
+       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);           \
+       __efr &= ~MOXA_MUST_EFR_SF_MASK;                        \
+       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);           \
+       outb(__oldlcr, (baseio)+UART_LCR);                      \
+} while (0)
+
+#define ENABLE_MOXA_MUST_TX_SOFTWARE_FLOW_CONTROL(baseio) do { \
+       u8      __oldlcr, __efr;                                \
+       __oldlcr = inb((baseio)+UART_LCR);                      \
        outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);      \
-       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);   \
-       __efr &= ~MOXA_MUST_EFR_SF_TX_MASK;     \
-       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);   \
-       outb(__oldlcr, (baseio)+UART_LCR);      \
-}
-
-#define SET_MOXA_MUST_JUST_RX_SOFTWARE_FLOW_CONTROL(baseio) {  \
-       u8      __oldlcr, __efr;        \
-       __oldlcr = inb((baseio)+UART_LCR);      \
+       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);           \
+       __efr &= ~MOXA_MUST_EFR_SF_TX_MASK;                     \
+       __efr |= MOXA_MUST_EFR_SF_TX1;                          \
+       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);           \
+       outb(__oldlcr, (baseio)+UART_LCR);                      \
+} while (0)
+
+#define DISABLE_MOXA_MUST_TX_SOFTWARE_FLOW_CONTROL(baseio) do {        \
+       u8      __oldlcr, __efr;                                \
+       __oldlcr = inb((baseio)+UART_LCR);                      \
        outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);      \
-       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);   \
-       __efr &= ~MOXA_MUST_EFR_SF_MASK;        \
-       __efr |= MOXA_MUST_EFR_SF_RX1;  \
-       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);   \
-       outb(__oldlcr, (baseio)+UART_LCR);      \
-}
-
-#define ENABLE_MOXA_MUST_RX_SOFTWARE_FLOW_CONTROL(baseio) {    \
-       u8      __oldlcr, __efr;        \
-       __oldlcr = inb((baseio)+UART_LCR);      \
+       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);           \
+       __efr &= ~MOXA_MUST_EFR_SF_TX_MASK;                     \
+       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);           \
+       outb(__oldlcr, (baseio)+UART_LCR);                      \
+} while (0)
+
+#define ENABLE_MOXA_MUST_RX_SOFTWARE_FLOW_CONTROL(baseio) do { \
+       u8      __oldlcr, __efr;                                \
+       __oldlcr = inb((baseio)+UART_LCR);                      \
        outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);      \
-       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);   \
-       __efr &= ~MOXA_MUST_EFR_SF_RX_MASK;     \
-       __efr |= MOXA_MUST_EFR_SF_RX1;  \
-       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);   \
-       outb(__oldlcr, (baseio)+UART_LCR);      \
-}
-
-#define DISABLE_MOXA_MUST_RX_SOFTWARE_FLOW_CONTROL(baseio) {   \
-       u8      __oldlcr, __efr;        \
-       __oldlcr = inb((baseio)+UART_LCR);      \
+       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);           \
+       __efr &= ~MOXA_MUST_EFR_SF_RX_MASK;                     \
+       __efr |= MOXA_MUST_EFR_SF_RX1;                          \
+       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);           \
+       outb(__oldlcr, (baseio)+UART_LCR);                      \
+} while (0)
+
+#define DISABLE_MOXA_MUST_RX_SOFTWARE_FLOW_CONTROL(baseio) do {        \
+       u8      __oldlcr, __efr;                                \
+       __oldlcr = inb((baseio)+UART_LCR);                      \
        outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);      \
-       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);   \
-       __efr &= ~MOXA_MUST_EFR_SF_RX_MASK;     \
-       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);   \
-       outb(__oldlcr, (baseio)+UART_LCR);      \
-}
-
-#define ENABLE_MOXA_MUST_TX_RX_SOFTWARE_FLOW_CONTROL(baseio) { \
-       u8      __oldlcr, __efr;        \
-       __oldlcr = inb((baseio)+UART_LCR);      \
-       outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR);      \
-       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);   \
-       __efr &= ~MOXA_MUST_EFR_SF_MASK;        \
-       __efr |= (MOXA_MUST_EFR_SF_RX1|MOXA_MUST_EFR_SF_TX1);   \
-       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);   \
-       outb(__oldlcr, (baseio)+UART_LCR);      \
-}
-
-#define ENABLE_MOXA_MUST_XON_ANY_FLOW_CONTROL(baseio) {        \
-       u8      __oldmcr;       \
-       __oldmcr = inb((baseio)+UART_MCR);      \
-       __oldmcr |= MOXA_MUST_MCR_XON_ANY;      \
-       outb(__oldmcr, (baseio)+UART_MCR);      \
-}
-
-#define DISABLE_MOXA_MUST_XON_ANY_FLOW_CONTROL(baseio) {       \
-       u8      __oldmcr;       \
-       __oldmcr = inb((baseio)+UART_MCR);      \
-       __oldmcr &= ~MOXA_MUST_MCR_XON_ANY;     \
-       outb(__oldmcr, (baseio)+UART_MCR);      \
-}
-
-#define READ_MOXA_MUST_GDL(baseio)     inb((baseio)+MOXA_MUST_GDL_REGISTER)
-
-
-#ifndef INIT_WORK
-#define INIT_WORK(_work, _func, _data){        \
-       _data->tqueue.routine = _func;\
-       _data->tqueue.data = _data;\
-       }
-#endif
+       __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER);           \
+       __efr &= ~MOXA_MUST_EFR_SF_RX_MASK;                     \
+       outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER);           \
+       outb(__oldlcr, (baseio)+UART_LCR);                      \
+} while (0)
 
 #endif
index dc6d4184145769b403122715154aa7470886ea00..fab1b7d42858ad5a258863a84b43cf12e150f500 100644 (file)
 #include <linux/slab.h>
 #include <linux/tty.h>
 #include <linux/errno.h>
-#include <linux/string.h>   /* used in new tty drivers */
-#include <linux/signal.h>   /* used in new tty drivers */
+#include <linux/string.h>      /* used in new tty drivers */
+#include <linux/signal.h>      /* used in new tty drivers */
 #include <linux/ioctl.h>
 #include <linux/n_r3964.h>
 #include <linux/poll.h>
 #include <linux/init.h>
 #include <asm/uaccess.h>
 
-
-//#define DEBUG_QUEUE
+/*#define DEBUG_QUEUE*/
 
 /* Log successful handshake and protocol operations  */
-//#define DEBUG_PROTO_S
+/*#define DEBUG_PROTO_S*/
 
 /* Log handshake and protocol errors: */
-//#define DEBUG_PROTO_E
+/*#define DEBUG_PROTO_E*/
 
 /* Log Linediscipline operations (open, close, read, write...): */
-//#define DEBUG_LDISC
+/*#define DEBUG_LDISC*/
 
 /* Log module and memory operations (init, cleanup; kmalloc, kfree): */
-//#define DEBUG_MODUL
+/*#define DEBUG_MODUL*/
 
 /* Macro helpers for debug output: */
-#define TRACE(format, args...) printk("r3964: " format "\n" , ## args);
+#define TRACE(format, args...) printk("r3964: " format "\n" , ## args)
 
 #ifdef DEBUG_MODUL
-#define TRACE_M(format, args...) printk("r3964: " format "\n" , ## args);
+#define TRACE_M(format, args...) printk("r3964: " format "\n" , ## args)
 #else
-#define TRACE_M(fmt, arg...) /**/
+#define TRACE_M(fmt, arg...) do {} while (0)
 #endif
-
 #ifdef DEBUG_PROTO_S
-#define TRACE_PS(format, args...) printk("r3964: " format "\n" , ## args);
+#define TRACE_PS(format, args...) printk("r3964: " format "\n" , ## args)
 #else
-#define TRACE_PS(fmt, arg...) /**/
+#define TRACE_PS(fmt, arg...) do {} while (0)
 #endif
-
 #ifdef DEBUG_PROTO_E
-#define TRACE_PE(format, args...) printk("r3964: " format "\n" , ## args);
+#define TRACE_PE(format, args...) printk("r3964: " format "\n" , ## args)
 #else
-#define TRACE_PE(fmt, arg...) /**/
+#define TRACE_PE(fmt, arg...) do {} while (0)
 #endif
-
 #ifdef DEBUG_LDISC
-#define TRACE_L(format, args...) printk("r3964: " format "\n" , ## args);
+#define TRACE_L(format, args...) printk("r3964: " format "\n" , ## args)
 #else
-#define TRACE_L(fmt, arg...) /**/
+#define TRACE_L(fmt, arg...) do {} while (0)
 #endif
-
 #ifdef DEBUG_QUEUE
-#define TRACE_Q(format, args...) printk("r3964: " format "\n" , ## args);
+#define TRACE_Q(format, args...) printk("r3964: " format "\n" , ## args)
 #else
-#define TRACE_Q(fmt, arg...) /**/
+#define TRACE_Q(fmt, arg...) do {} while (0)
 #endif
-
 static void add_tx_queue(struct r3964_info *, struct r3964_block_header *);
 static void remove_from_tx_queue(struct r3964_info *pInfo, int error_code);
 static void put_char(struct r3964_info *pInfo, unsigned char ch);
@@ -126,937 +120,830 @@ static void receive_char(struct r3964_info *pInfo, const unsigned char c);
 static void receive_error(struct r3964_info *pInfo, const char flag);
 static void on_timeout(unsigned long priv);
 static int enable_signals(struct r3964_info *pInfo, struct pid *pid, int arg);
-static int read_telegram(struct r3964_info *pInfo, struct pid *pid, unsigned char __user *buf);
+static int read_telegram(struct r3964_info *pInfo, struct pid *pid,
+               unsigned char __user * buf);
 static void add_msg(struct r3964_client_info *pClient, int msg_id, int arg,
-             int error_code, struct r3964_block_header *pBlock);
-static struct r3964_message* remove_msg(struct r3964_info *pInfo, 
-             struct r3964_client_info *pClient);
-static void remove_client_block(struct r3964_info *pInfo, 
-                struct r3964_client_info *pClient);
+               int error_code, struct r3964_block_header *pBlock);
+static struct r3964_message *remove_msg(struct r3964_info *pInfo,
+               struct r3964_client_info *pClient);
+static void remove_client_block(struct r3964_info *pInfo,
+               struct r3964_client_info *pClient);
 
-static int  r3964_open(struct tty_struct *tty);
+static int r3964_open(struct tty_struct *tty);
 static void r3964_close(struct tty_struct *tty);
 static ssize_t r3964_read(struct tty_struct *tty, struct file *file,
-                     unsigned char __user *buf, size_t nr);
-static ssize_t r3964_write(struct tty_struct * tty, struct file * file,
-                      const unsigned char * buf, size_t nr);
-static int r3964_ioctl(struct tty_struct * tty, struct file * file,
-                       unsigned int cmd, unsigned long arg);
-static void r3964_set_termios(struct tty_struct *tty, struct ktermios * old);
-static unsigned int r3964_poll(struct tty_struct * tty, struct file * file,
-                     struct poll_table_struct  *wait);
+               unsigned char __user * buf, size_t nr);
+static ssize_t r3964_write(struct tty_struct *tty, struct file *file,
+               const unsigned char *buf, size_t nr);
+static int r3964_ioctl(struct tty_struct *tty, struct file *file,
+               unsigned int cmd, unsigned long arg);
+static void r3964_set_termios(struct tty_struct *tty, struct ktermios *old);
+static unsigned int r3964_poll(struct tty_struct *tty, struct file *file,
+               struct poll_table_struct *wait);
 static void r3964_receive_buf(struct tty_struct *tty, const unsigned char *cp,
-                              char *fp, int count);
+               char *fp, int count);
 
 static struct tty_ldisc tty_ldisc_N_R3964 = {
-       .owner   = THIS_MODULE,
-       .magic  = TTY_LDISC_MAGIC, 
-       .name   = "R3964",
-       .open   = r3964_open,
-       .close  = r3964_close,
-       .read   = r3964_read,
-       .write  = r3964_write,
-       .ioctl  = r3964_ioctl,
+       .owner = THIS_MODULE,
+       .magic = TTY_LDISC_MAGIC,
+       .name = "R3964",
+       .open = r3964_open,
+       .close = r3964_close,
+       .read = r3964_read,
+       .write = r3964_write,
+       .ioctl = r3964_ioctl,
        .set_termios = r3964_set_termios,
-       .poll   = r3964_poll,            
+       .poll = r3964_poll,
        .receive_buf = r3964_receive_buf,
 };
 
-
-
 static void dump_block(const unsigned char *block, unsigned int length)
 {
-   unsigned int i,j;
-   char linebuf[16*3+1];
-   
-   for(i=0;i<length;i+=16)
-   {
-      for(j=0;(j<16) && (j+i<length);j++)
-      {
-         sprintf(linebuf+3*j,"%02x ",block[i+j]);
-      }
-      linebuf[3*j]='\0';
-      TRACE_PS("%s",linebuf);
-   }
+       unsigned int i, j;
+       char linebuf[16 * 3 + 1];
+
+       for (i = 0; i < length; i += 16) {
+               for (j = 0; (j < 16) && (j + i < length); j++) {
+                       sprintf(linebuf + 3 * j, "%02x ", block[i + j]);
+               }
+               linebuf[3 * j] = '\0';
+               TRACE_PS("%s", linebuf);
+       }
 }
 
-         
-
-
 /*************************************************************
  * Driver initialisation
  *************************************************************/
 
-
 /*************************************************************
  * Module support routines
  *************************************************************/
 
 static void __exit r3964_exit(void)
 {
-   int status;
-   
-   TRACE_M ("cleanup_module()");
-
-   status=tty_unregister_ldisc(N_R3964);
-   
-   if(status!=0)
-   {
-      printk(KERN_ERR "r3964: error unregistering linediscipline: %d\n", status);
-   }
-   else
-   {
-      TRACE_L("linediscipline successfully unregistered");
-   }
-   
+       int status;
+
+       TRACE_M("cleanup_module()");
+
+       status = tty_unregister_ldisc(N_R3964);
+
+       if (status != 0) {
+               printk(KERN_ERR "r3964: error unregistering linediscipline: "
+                               "%d\n", status);
+       } else {
+               TRACE_L("linediscipline successfully unregistered");
+       }
 }
 
 static int __init r3964_init(void)
 {
-   int status;
-   
-   printk ("r3964: Philips r3964 Driver $Revision: 1.10 $\n");
-
-   /*
-    * Register the tty line discipline
-    */
-   
-   status = tty_register_ldisc (N_R3964, &tty_ldisc_N_R3964);
-   if (status == 0)
-     {
-       TRACE_L("line discipline %d registered", N_R3964);
-       TRACE_L("flags=%x num=%x", tty_ldisc_N_R3964.flags, 
-               tty_ldisc_N_R3964.num);
-       TRACE_L("open=%p", tty_ldisc_N_R3964.open);
-       TRACE_L("tty_ldisc_N_R3964 = %p", &tty_ldisc_N_R3964);
-     }
-   else
-     {
-       printk (KERN_ERR "r3964: error registering line discipline: %d\n", status);
-     }
-   return status;
+       int status;
+
+       printk("r3964: Philips r3964 Driver $Revision: 1.10 $\n");
+
+       /*
+        * Register the tty line discipline
+        */
+
+       status = tty_register_ldisc(N_R3964, &tty_ldisc_N_R3964);
+       if (status == 0) {
+               TRACE_L("line discipline %d registered", N_R3964);
+               TRACE_L("flags=%x num=%x", tty_ldisc_N_R3964.flags,
+                       tty_ldisc_N_R3964.num);
+               TRACE_L("open=%p", tty_ldisc_N_R3964.open);
+               TRACE_L("tty_ldisc_N_R3964 = %p", &tty_ldisc_N_R3964);
+       } else {
+               printk(KERN_ERR "r3964: error registering line discipline: "
+                               "%d\n", status);
+       }
+       return status;
 }
 
 module_init(r3964_init);
 module_exit(r3964_exit);
 
-
 /*************************************************************
  * Protocol implementation routines
  *************************************************************/
 
-static void add_tx_queue(struct r3964_info *pInfo, struct r3964_block_header *pHeader)
+static void add_tx_queue(struct r3964_info *pInfo,
+                        struct r3964_block_header *pHeader)
 {
-   unsigned long flags;
-   
-   spin_lock_irqsave(&pInfo->lock, flags);
-
-   pHeader->next = NULL;
-
-   if(pInfo->tx_last == NULL)
-   {
-      pInfo->tx_first = pInfo->tx_last = pHeader;
-   }
-   else
-   {
-      pInfo->tx_last->next = pHeader;
-      pInfo->tx_last = pHeader;
-   }
-   
-   spin_unlock_irqrestore(&pInfo->lock, flags);
-
-   TRACE_Q("add_tx_queue %p, length %d, tx_first = %p", 
-          pHeader, pHeader->length, pInfo->tx_first );
+       unsigned long flags;
+
+       spin_lock_irqsave(&pInfo->lock, flags);
+
+       pHeader->next = NULL;
+
+       if (pInfo->tx_last == NULL) {
+               pInfo->tx_first = pInfo->tx_last = pHeader;
+       } else {
+               pInfo->tx_last->next = pHeader;
+               pInfo->tx_last = pHeader;
+       }
+
+       spin_unlock_irqrestore(&pInfo->lock, flags);
+
+       TRACE_Q("add_tx_queue %p, length %d, tx_first = %p",
+               pHeader, pHeader->length, pInfo->tx_first);
 }
 
 static void remove_from_tx_queue(struct r3964_info *pInfo, int error_code)
 {
-   struct r3964_block_header *pHeader;
-   unsigned long flags;
+       struct r3964_block_header *pHeader;
+       unsigned long flags;
 #ifdef DEBUG_QUEUE
-   struct r3964_block_header *pDump;
+       struct r3964_block_header *pDump;
 #endif
-   
-   pHeader = pInfo->tx_first;
 
-   if(pHeader==NULL)
-      return;
+       pHeader = pInfo->tx_first;
+
+       if (pHeader == NULL)
+               return;
 
 #ifdef DEBUG_QUEUE
-   printk("r3964: remove_from_tx_queue: %p, length %u - ",
-          pHeader, pHeader->length );
-   for(pDump=pHeader;pDump;pDump=pDump->next)
-        printk("%p ", pDump);
-   printk("\n");
+       printk("r3964: remove_from_tx_queue: %p, length %u - ",
+               pHeader, pHeader->length);
+       for (pDump = pHeader; pDump; pDump = pDump->next)
+               printk("%p ", pDump);
+       printk("\n");
 #endif
 
+       if (pHeader->owner) {
+               if (error_code) {
+                       add_msg(pHeader->owner, R3964_MSG_ACK, 0,
+                               error_code, NULL);
+               } else {
+                       add_msg(pHeader->owner, R3964_MSG_ACK, pHeader->length,
+                               error_code, NULL);
+               }
+               wake_up_interruptible(&pInfo->read_wait);
+       }
+
+       spin_lock_irqsave(&pInfo->lock, flags);
+
+       pInfo->tx_first = pHeader->next;
+       if (pInfo->tx_first == NULL) {
+               pInfo->tx_last = NULL;
+       }
+
+       spin_unlock_irqrestore(&pInfo->lock, flags);
+
+       kfree(pHeader);
+       TRACE_M("remove_from_tx_queue - kfree %p", pHeader);
 
-   if(pHeader->owner)
-   {
-      if(error_code)
-      {
-          add_msg(pHeader->owner, R3964_MSG_ACK, 0, 
-                  error_code, NULL);
-      }
-      else
-      {
-          add_msg(pHeader->owner, R3964_MSG_ACK, pHeader->length, 
-                  error_code, NULL);
-      }
-      wake_up_interruptible (&pInfo->read_wait);
-   }
-
-   spin_lock_irqsave(&pInfo->lock, flags);
-
-   pInfo->tx_first = pHeader->next;
-   if(pInfo->tx_first==NULL)
-   {
-      pInfo->tx_last = NULL;
-   }
-
-   spin_unlock_irqrestore(&pInfo->lock, flags);
-
-   kfree(pHeader);
-   TRACE_M("remove_from_tx_queue - kfree %p",pHeader);
-
-   TRACE_Q("remove_from_tx_queue: tx_first = %p, tx_last = %p",
-          pInfo->tx_first, pInfo->tx_last );
+       TRACE_Q("remove_from_tx_queue: tx_first = %p, tx_last = %p",
+               pInfo->tx_first, pInfo->tx_last);
 }
 
-static void add_rx_queue(struct r3964_info *pInfo, struct r3964_block_header *pHeader)
+static void add_rx_queue(struct r3964_info *pInfo,
+                        struct r3964_block_header *pHeader)
 {
-   unsigned long flags;
-   
-   spin_lock_irqsave(&pInfo->lock, flags);
-
-   pHeader->next = NULL;
-
-   if(pInfo->rx_last == NULL)
-   {
-      pInfo->rx_first = pInfo->rx_last = pHeader;
-   }
-   else
-   {
-      pInfo->rx_last->next = pHeader;
-      pInfo->rx_last = pHeader;
-   }
-   pInfo->blocks_in_rx_queue++;
-   
-   spin_unlock_irqrestore(&pInfo->lock, flags);
-
-   TRACE_Q("add_rx_queue: %p, length = %d, rx_first = %p, count = %d",
-          pHeader, pHeader->length,
-          pInfo->rx_first, pInfo->blocks_in_rx_queue);
+       unsigned long flags;
+
+       spin_lock_irqsave(&pInfo->lock, flags);
+
+       pHeader->next = NULL;
+
+       if (pInfo->rx_last == NULL) {
+               pInfo->rx_first = pInfo->rx_last = pHeader;
+       } else {
+               pInfo->rx_last->next = pHeader;
+               pInfo->rx_last = pHeader;
+       }
+       pInfo->blocks_in_rx_queue++;
+
+       spin_unlock_irqrestore(&pInfo->lock, flags);
+
+       TRACE_Q("add_rx_queue: %p, length = %d, rx_first = %p, count = %d",
+               pHeader, pHeader->length,
+               pInfo->rx_first, pInfo->blocks_in_rx_queue);
 }
 
 static void remove_from_rx_queue(struct r3964_info *pInfo,
-                 struct r3964_block_header *pHeader)
+                                struct r3964_block_header *pHeader)
 {
-   unsigned long flags;
-   struct r3964_block_header *pFind;
-   
-   if(pHeader==NULL)
-      return;
-
-   TRACE_Q("remove_from_rx_queue: rx_first = %p, rx_last = %p, count = %d",
-          pInfo->rx_first, pInfo->rx_last, pInfo->blocks_in_rx_queue );
-   TRACE_Q("remove_from_rx_queue: %p, length %u",
-          pHeader, pHeader->length );
-
-   spin_lock_irqsave(&pInfo->lock, flags);
-
-   if(pInfo->rx_first == pHeader)
-   {
-      /* Remove the first block in the linked list: */
-      pInfo->rx_first = pHeader->next;
-      
-      if(pInfo->rx_first==NULL)
-      {
-         pInfo->rx_last = NULL;
-      }
-      pInfo->blocks_in_rx_queue--;
-   }
-   else 
-   {
-      /* Find block to remove: */
-      for(pFind=pInfo->rx_first; pFind; pFind=pFind->next)
-      {
-         if(pFind->next == pHeader) 
-         {
-            /* Got it. */
-            pFind->next = pHeader->next;
-            pInfo->blocks_in_rx_queue--;
-            if(pFind->next==NULL)
-            {
-               /* Oh, removed the last one! */
-               pInfo->rx_last = pFind;
-            }
-            break;
-         }
-      }
-   }
-
-   spin_unlock_irqrestore(&pInfo->lock, flags);
-
-   kfree(pHeader);
-   TRACE_M("remove_from_rx_queue - kfree %p",pHeader);
-
-   TRACE_Q("remove_from_rx_queue: rx_first = %p, rx_last = %p, count = %d",
-          pInfo->rx_first, pInfo->rx_last, pInfo->blocks_in_rx_queue );
+       unsigned long flags;
+       struct r3964_block_header *pFind;
+
+       if (pHeader == NULL)
+               return;
+
+       TRACE_Q("remove_from_rx_queue: rx_first = %p, rx_last = %p, count = %d",
+               pInfo->rx_first, pInfo->rx_last, pInfo->blocks_in_rx_queue);
+       TRACE_Q("remove_from_rx_queue: %p, length %u",
+               pHeader, pHeader->length);
+
+       spin_lock_irqsave(&pInfo->lock, flags);
+
+       if (pInfo->rx_first == pHeader) {
+               /* Remove the first block in the linked list: */
+               pInfo->rx_first = pHeader->next;
+
+               if (pInfo->rx_first == NULL) {
+                       pInfo->rx_last = NULL;
+               }
+               pInfo->blocks_in_rx_queue--;
+       } else {
+               /* Find block to remove: */
+               for (pFind = pInfo->rx_first; pFind; pFind = pFind->next) {
+                       if (pFind->next == pHeader) {
+                               /* Got it. */
+                               pFind->next = pHeader->next;
+                               pInfo->blocks_in_rx_queue--;
+                               if (pFind->next == NULL) {
+                                       /* Oh, removed the last one! */
+                                       pInfo->rx_last = pFind;
+                               }
+                               break;
+                       }
+               }
+       }
+
+       spin_unlock_irqrestore(&pInfo->lock, flags);
+
+       kfree(pHeader);
+       TRACE_M("remove_from_rx_queue - kfree %p", pHeader);
+
+       TRACE_Q("remove_from_rx_queue: rx_first = %p, rx_last = %p, count = %d",
+               pInfo->rx_first, pInfo->rx_last, pInfo->blocks_in_rx_queue);
 }
 
 static void put_char(struct r3964_info *pInfo, unsigned char ch)
 {
-   struct tty_struct *tty = pInfo->tty;
+       struct tty_struct *tty = pInfo->tty;
 
-   if(tty==NULL)
-      return;
+       if (tty == NULL)
+               return;
 
-   if(tty->driver->put_char)
-   {
-      tty->driver->put_char(tty, ch);
-   }
-   pInfo->bcc ^= ch;
+       if (tty->driver->put_char) {
+               tty->driver->put_char(tty, ch);
+       }
+       pInfo->bcc ^= ch;
 }
 
 static void flush(struct r3964_info *pInfo)
 {
-   struct tty_struct *tty = pInfo->tty;
+       struct tty_struct *tty = pInfo->tty;
 
-   if(tty==NULL)
-      return;
+       if (tty == NULL)
+               return;
 
-   if(tty->driver->flush_chars)
-   {
-      tty->driver->flush_chars(tty);
-   }
+       if (tty->driver->flush_chars) {
+               tty->driver->flush_chars(tty);
+       }
 }
 
 static void trigger_transmit(struct r3964_info *pInfo)
 {
-   unsigned long flags;
-   
+       unsigned long flags;
 
-   spin_lock_irqsave(&pInfo->lock, flags);
+       spin_lock_irqsave(&pInfo->lock, flags);
 
-   if((pInfo->state == R3964_IDLE) && (pInfo->tx_first!=NULL))
-   {
-      pInfo->state = R3964_TX_REQUEST;
-      pInfo->nRetry=0;
-      pInfo->flags &= ~R3964_ERROR;
-      mod_timer(&pInfo->tmr, jiffies + R3964_TO_QVZ);
+       if ((pInfo->state == R3964_IDLE) && (pInfo->tx_first != NULL)) {
+               pInfo->state = R3964_TX_REQUEST;
+               pInfo->nRetry = 0;
+               pInfo->flags &= ~R3964_ERROR;
+               mod_timer(&pInfo->tmr, jiffies + R3964_TO_QVZ);
 
-      spin_unlock_irqrestore(&pInfo->lock, flags);
+               spin_unlock_irqrestore(&pInfo->lock, flags);
 
-      TRACE_PS("trigger_transmit - sent STX");
+               TRACE_PS("trigger_transmit - sent STX");
 
-      put_char(pInfo, STX);
-      flush(pInfo);
+               put_char(pInfo, STX);
+               flush(pInfo);
 
-      pInfo->bcc = 0;
-   }
-   else
-   {
-      spin_unlock_irqrestore(&pInfo->lock, flags);
-   }
+               pInfo->bcc = 0;
+       } else {
+               spin_unlock_irqrestore(&pInfo->lock, flags);
+       }
 }
 
 static void retry_transmit(struct r3964_info *pInfo)
 {
-   if(pInfo->nRetry<R3964_MAX_RETRIES)
-   {
-      TRACE_PE("transmission failed. Retry #%d", 
-             pInfo->nRetry);
-      pInfo->bcc = 0;
-      put_char(pInfo, STX);
-      flush(pInfo);
-      pInfo->state = R3964_TX_REQUEST;
-      pInfo->nRetry++;
-      mod_timer(&pInfo->tmr, jiffies + R3964_TO_QVZ);
-   }
-   else
-   {
-      TRACE_PE("transmission failed after %d retries", 
-             R3964_MAX_RETRIES);
-
-      remove_from_tx_queue(pInfo, R3964_TX_FAIL);
-      
-      put_char(pInfo, NAK);
-      flush(pInfo);
-      pInfo->state = R3964_IDLE;
-
-      trigger_transmit(pInfo);
-   }
+       if (pInfo->nRetry < R3964_MAX_RETRIES) {
+               TRACE_PE("transmission failed. Retry #%d", pInfo->nRetry);
+               pInfo->bcc = 0;
+               put_char(pInfo, STX);
+               flush(pInfo);
+               pInfo->state = R3964_TX_REQUEST;
+               pInfo->nRetry++;
+               mod_timer(&pInfo->tmr, jiffies + R3964_TO_QVZ);
+       } else {
+               TRACE_PE("transmission failed after %d retries",
+                        R3964_MAX_RETRIES);
+
+               remove_from_tx_queue(pInfo, R3964_TX_FAIL);
+
+               put_char(pInfo, NAK);
+               flush(pInfo);
+               pInfo->state = R3964_IDLE;
+
+               trigger_transmit(pInfo);
+       }
 }
 
-
 static void transmit_block(struct r3964_info *pInfo)
 {
-   struct tty_struct *tty = pInfo->tty;
-   struct r3964_block_header *pBlock = pInfo->tx_first;
-   int room=0;
-
-   if((tty==NULL) || (pBlock==NULL))
-   {
-      return;
-   }
-
-   if(tty->driver->write_room)
-      room=tty->driver->write_room(tty);
-
-   TRACE_PS("transmit_block %p, room %d, length %d", 
-          pBlock, room, pBlock->length);
-   
-   while(pInfo->tx_position < pBlock->length)
-   {
-      if(room<2)
-         break;
-      if(pBlock->data[pInfo->tx_position]==DLE)
-      {
-         /* send additional DLE char: */
-         put_char(pInfo, DLE);
-      }
-      put_char(pInfo, pBlock->data[pInfo->tx_position++]);
-      
-      room--;
-   }
-
-   if((pInfo->tx_position == pBlock->length) && (room>=3))
-   {
-      put_char(pInfo, DLE);
-      put_char(pInfo, ETX);
-      if(pInfo->flags & R3964_BCC)
-      {
-         put_char(pInfo, pInfo->bcc);
-      }
-      pInfo->state = R3964_WAIT_FOR_TX_ACK;
-      mod_timer(&pInfo->tmr, jiffies + R3964_TO_QVZ);
-   }
-   flush(pInfo);
+       struct tty_struct *tty = pInfo->tty;
+       struct r3964_block_header *pBlock = pInfo->tx_first;
+       int room = 0;
+
+       if ((tty == NULL) || (pBlock == NULL)) {
+               return;
+       }
+
+       if (tty->driver->write_room)
+               room = tty->driver->write_room(tty);
+
+       TRACE_PS("transmit_block %p, room %d, length %d",
+                pBlock, room, pBlock->length);
+
+       while (pInfo->tx_position < pBlock->length) {
+               if (room < 2)
+                       break;
+
+               if (pBlock->data[pInfo->tx_position] == DLE) {
+                       /* send additional DLE char: */
+                       put_char(pInfo, DLE);
+               }
+               put_char(pInfo, pBlock->data[pInfo->tx_position++]);
+
+               room--;
+       }
+
+       if ((pInfo->tx_position == pBlock->length) && (room >= 3)) {
+               put_char(pInfo, DLE);
+               put_char(pInfo, ETX);
+               if (pInfo->flags & R3964_BCC) {
+                       put_char(pInfo, pInfo->bcc);
+               }
+               pInfo->state = R3964_WAIT_FOR_TX_ACK;
+               mod_timer(&pInfo->tmr, jiffies + R3964_TO_QVZ);
+       }
+       flush(pInfo);
 }
 
 static void on_receive_block(struct r3964_info *pInfo)
 {
-   unsigned int length;
-   struct r3964_client_info *pClient;
-   struct r3964_block_header *pBlock;
-   
-   length=pInfo->rx_position;
-
-   /* compare byte checksum characters: */
-   if(pInfo->flags & R3964_BCC)
-   {
-      if(pInfo->bcc!=pInfo->last_rx)
-      {
-         TRACE_PE("checksum error - got %x but expected %x",
-                pInfo->last_rx, pInfo->bcc);
-         pInfo->flags |= R3964_CHECKSUM;
-      }
-   }
-
-   /* check for errors (parity, overrun,...): */
-   if(pInfo->flags & R3964_ERROR)
-   {
-      TRACE_PE("on_receive_block - transmission failed error %x",
-             pInfo->flags & R3964_ERROR);
-      
-      put_char(pInfo, NAK);
-      flush(pInfo);
-      if(pInfo->nRetry<R3964_MAX_RETRIES)
-      {
-         pInfo->state=R3964_WAIT_FOR_RX_REPEAT;
-         pInfo->nRetry++;
-        mod_timer(&pInfo->tmr, jiffies + R3964_TO_RX_PANIC);
-      }
-      else
-      {
-         TRACE_PE("on_receive_block - failed after max retries");
-         pInfo->state=R3964_IDLE;
-      }
-      return;
-   }
-
-   
-   /* received block; submit DLE: */
-   put_char(pInfo, DLE);
-   flush(pInfo);
-   del_timer_sync(&pInfo->tmr);
-   TRACE_PS(" rx success: got %d chars", length);
-
-   /* prepare struct r3964_block_header: */
-   pBlock = kmalloc(length+sizeof(struct r3964_block_header), GFP_KERNEL);
-   TRACE_M("on_receive_block - kmalloc %p",pBlock);
-
-   if(pBlock==NULL)
-      return;
-
-   pBlock->length = length;
-   pBlock->data   = ((unsigned char*)pBlock)+sizeof(struct r3964_block_header);
-   pBlock->locks  = 0;
-   pBlock->next   = NULL;
-   pBlock->owner  = NULL;
-
-   memcpy(pBlock->data, pInfo->rx_buf, length);
-
-   /* queue block into rx_queue: */
-   add_rx_queue(pInfo, pBlock);
-
-   /* notify attached client processes: */
-   for(pClient=pInfo->firstClient; pClient; pClient=pClient->next)
-   {
-      if(pClient->sig_flags & R3964_SIG_DATA)
-      {
-         add_msg(pClient, R3964_MSG_DATA, length, R3964_OK, pBlock);
-      }
-   }
-   wake_up_interruptible (&pInfo->read_wait);
-   
-   pInfo->state = R3964_IDLE;
-
-   trigger_transmit(pInfo);
-}
+       unsigned int length;
+       struct r3964_client_info *pClient;
+       struct r3964_block_header *pBlock;
+
+       length = pInfo->rx_position;
+
+       /* compare byte checksum characters: */
+       if (pInfo->flags & R3964_BCC) {
+               if (pInfo->bcc != pInfo->last_rx) {
+                       TRACE_PE("checksum error - got %x but expected %x",
+                                pInfo->last_rx, pInfo->bcc);
+                       pInfo->flags |= R3964_CHECKSUM;
+               }
+       }
+
+       /* check for errors (parity, overrun,...): */
+       if (pInfo->flags & R3964_ERROR) {
+               TRACE_PE("on_receive_block - transmission failed error %x",
+                        pInfo->flags & R3964_ERROR);
+
+               put_char(pInfo, NAK);
+               flush(pInfo);
+               if (pInfo->nRetry < R3964_MAX_RETRIES) {
+                       pInfo->state = R3964_WAIT_FOR_RX_REPEAT;
+                       pInfo->nRetry++;
+                       mod_timer(&pInfo->tmr, jiffies + R3964_TO_RX_PANIC);
+               } else {
+                       TRACE_PE("on_receive_block - failed after max retries");
+                       pInfo->state = R3964_IDLE;
+               }
+               return;
+       }
+
+       /* received block; submit DLE: */
+       put_char(pInfo, DLE);
+       flush(pInfo);
+       del_timer_sync(&pInfo->tmr);
+       TRACE_PS(" rx success: got %d chars", length);
+
+       /* prepare struct r3964_block_header: */
+       pBlock = kmalloc(length + sizeof(struct r3964_block_header),
+                       GFP_KERNEL);
+       TRACE_M("on_receive_block - kmalloc %p", pBlock);
+
+       if (pBlock == NULL)
+               return;
+
+       pBlock->length = length;
+       pBlock->data = ((unsigned char *)pBlock) +
+                       sizeof(struct r3964_block_header);
+       pBlock->locks = 0;
+       pBlock->next = NULL;
+       pBlock->owner = NULL;
+
+       memcpy(pBlock->data, pInfo->rx_buf, length);
+
+       /* queue block into rx_queue: */
+       add_rx_queue(pInfo, pBlock);
+
+       /* notify attached client processes: */
+       for (pClient = pInfo->firstClient; pClient; pClient = pClient->next) {
+               if (pClient->sig_flags & R3964_SIG_DATA) {
+                       add_msg(pClient, R3964_MSG_DATA, length, R3964_OK,
+                               pBlock);
+               }
+       }
+       wake_up_interruptible(&pInfo->read_wait);
 
+       pInfo->state = R3964_IDLE;
+
+       trigger_transmit(pInfo);
+}
 
 static void receive_char(struct r3964_info *pInfo, const unsigned char c)
 {
-   switch(pInfo->state)
-   {
-      case R3964_TX_REQUEST:
-         if(c==DLE)
-         {
-            TRACE_PS("TX_REQUEST - got DLE");
-
-            pInfo->state = R3964_TRANSMITTING;
-            pInfo->tx_position = 0;
-            
-            transmit_block(pInfo);
-         }
-         else if(c==STX)
-         {
-            if(pInfo->nRetry==0)
-            {
-               TRACE_PE("TX_REQUEST - init conflict");
-               if(pInfo->priority == R3964_SLAVE)
-               {
-                  goto start_receiving;
-               }
-            } 
-            else 
-            {
-               TRACE_PE("TX_REQUEST - secondary init conflict!?"
-                        " Switching to SLAVE mode for next rx.");
-               goto start_receiving;
-            }
-         }
-         else
-         {
-            TRACE_PE("TX_REQUEST - char != DLE: %x", c);
-            retry_transmit(pInfo);
-         }
-         break;
-      case R3964_TRANSMITTING:
-         if(c==NAK)
-         {
-            TRACE_PE("TRANSMITTING - got NAK");
-            retry_transmit(pInfo);
-         }
-         else
-         {
-            TRACE_PE("TRANSMITTING - got invalid char");
-            pInfo->state = R3964_WAIT_ZVZ_BEFORE_TX_RETRY;
-           mod_timer(&pInfo->tmr, jiffies + R3964_TO_ZVZ);
-         }
-         break;
-      case R3964_WAIT_FOR_TX_ACK:
-         if(c==DLE)
-         {
-            TRACE_PS("WAIT_FOR_TX_ACK - got DLE");
-            remove_from_tx_queue(pInfo, R3964_OK);
-            
-            pInfo->state = R3964_IDLE;
-            trigger_transmit(pInfo);
-         }
-         else
-         {
-            retry_transmit(pInfo);
-         }
-         break;
-      case R3964_WAIT_FOR_RX_REPEAT:
-         /* FALLTROUGH */
-      case R3964_IDLE:
-         if(c==STX)
-         {
-            /* Prevent rx_queue from overflow: */
-            if(pInfo->blocks_in_rx_queue >= R3964_MAX_BLOCKS_IN_RX_QUEUE)
-            {
-               TRACE_PE("IDLE - got STX but no space in rx_queue!");
-               pInfo->state=R3964_WAIT_FOR_RX_BUF;
-              mod_timer(&pInfo->tmr, jiffies + R3964_TO_NO_BUF);
-               break;
-            }
+       switch (pInfo->state) {
+       case R3964_TX_REQUEST:
+               if (c == DLE) {
+                       TRACE_PS("TX_REQUEST - got DLE");
+
+                       pInfo->state = R3964_TRANSMITTING;
+                       pInfo->tx_position = 0;
+
+                       transmit_block(pInfo);
+               } else if (c == STX) {
+                       if (pInfo->nRetry == 0) {
+                               TRACE_PE("TX_REQUEST - init conflict");
+                               if (pInfo->priority == R3964_SLAVE) {
+                                       goto start_receiving;
+                               }
+                       } else {
+                               TRACE_PE("TX_REQUEST - secondary init "
+                                       "conflict!? Switching to SLAVE mode "
+                                       "for next rx.");
+                               goto start_receiving;
+                       }
+               } else {
+                       TRACE_PE("TX_REQUEST - char != DLE: %x", c);
+                       retry_transmit(pInfo);
+               }
+               break;
+       case R3964_TRANSMITTING:
+               if (c == NAK) {
+                       TRACE_PE("TRANSMITTING - got NAK");
+                       retry_transmit(pInfo);
+               } else {
+                       TRACE_PE("TRANSMITTING - got invalid char");
+
+                       pInfo->state = R3964_WAIT_ZVZ_BEFORE_TX_RETRY;
+                       mod_timer(&pInfo->tmr, jiffies + R3964_TO_ZVZ);
+               }
+               break;
+       case R3964_WAIT_FOR_TX_ACK:
+               if (c == DLE) {
+                       TRACE_PS("WAIT_FOR_TX_ACK - got DLE");
+                       remove_from_tx_queue(pInfo, R3964_OK);
+
+                       pInfo->state = R3964_IDLE;
+                       trigger_transmit(pInfo);
+               } else {
+                       retry_transmit(pInfo);
+               }
+               break;
+       case R3964_WAIT_FOR_RX_REPEAT:
+               /* FALLTROUGH */
+       case R3964_IDLE:
+               if (c == STX) {
+                       /* Prevent rx_queue from overflow: */
+                       if (pInfo->blocks_in_rx_queue >=
+                           R3964_MAX_BLOCKS_IN_RX_QUEUE) {
+                               TRACE_PE("IDLE - got STX but no space in "
+                                               "rx_queue!");
+                               pInfo->state = R3964_WAIT_FOR_RX_BUF;
+                               mod_timer(&pInfo->tmr,
+                                         jiffies + R3964_TO_NO_BUF);
+                               break;
+                       }
 start_receiving:
-            /* Ok, start receiving: */
-            TRACE_PS("IDLE - got STX");
-            pInfo->rx_position = 0;
-            pInfo->last_rx = 0;
-            pInfo->flags &= ~R3964_ERROR;
-            pInfo->state=R3964_RECEIVING;
-           mod_timer(&pInfo->tmr, jiffies + R3964_TO_ZVZ);
-           pInfo->nRetry = 0;
-            put_char(pInfo, DLE);
-            flush(pInfo);
-            pInfo->bcc = 0;
-         }
-         break;
-      case R3964_RECEIVING:
-         if(pInfo->rx_position < RX_BUF_SIZE)
-         {
-            pInfo->bcc ^= c;
-            
-            if(c==DLE)
-            {
-               if(pInfo->last_rx==DLE)
-               {
-                  pInfo->last_rx = 0;
-                  goto char_to_buf;
-               }
-               pInfo->last_rx = DLE;
-               break;
-            } 
-            else if((c==ETX) && (pInfo->last_rx==DLE))
-            {
-               if(pInfo->flags & R3964_BCC)
-               {
-                  pInfo->state = R3964_WAIT_FOR_BCC;
-                 mod_timer(&pInfo->tmr, jiffies + R3964_TO_ZVZ);
-               }
-               else 
-               {
-                  on_receive_block(pInfo);
-               }
-            }
-            else
-            {
-               pInfo->last_rx = c;
+                       /* Ok, start receiving: */
+                       TRACE_PS("IDLE - got STX");
+                       pInfo->rx_position = 0;
+                       pInfo->last_rx = 0;
+                       pInfo->flags &= ~R3964_ERROR;
+                       pInfo->state = R3964_RECEIVING;
+                       mod_timer(&pInfo->tmr, jiffies + R3964_TO_ZVZ);
+                       pInfo->nRetry = 0;
+                       put_char(pInfo, DLE);
+                       flush(pInfo);
+                       pInfo->bcc = 0;
+               }
+               break;
+       case R3964_RECEIVING:
+               if (pInfo->rx_position < RX_BUF_SIZE) {
+                       pInfo->bcc ^= c;
+
+                       if (c == DLE) {
+                               if (pInfo->last_rx == DLE) {
+                                       pInfo->last_rx = 0;
+                                       goto char_to_buf;
+                               }
+                               pInfo->last_rx = DLE;
+                               break;
+                       } else if ((c == ETX) && (pInfo->last_rx == DLE)) {
+                               if (pInfo->flags & R3964_BCC) {
+                                       pInfo->state = R3964_WAIT_FOR_BCC;
+                                       mod_timer(&pInfo->tmr,
+                                                 jiffies + R3964_TO_ZVZ);
+                               } else {
+                                       on_receive_block(pInfo);
+                               }
+                       } else {
+                               pInfo->last_rx = c;
 char_to_buf:
-               pInfo->rx_buf[pInfo->rx_position++] = c;
-              mod_timer(&pInfo->tmr, jiffies + R3964_TO_ZVZ);
-            }
-         }
-        /* else: overflow-msg? BUF_SIZE>MTU; should not happen? */ 
-         break;
-      case R3964_WAIT_FOR_BCC:
-         pInfo->last_rx = c;
-         on_receive_block(pInfo);
-         break;
-   }
+                               pInfo->rx_buf[pInfo->rx_position++] = c;
+                               mod_timer(&pInfo->tmr, jiffies + R3964_TO_ZVZ);
+                       }
+               }
+               /* else: overflow-msg? BUF_SIZE>MTU; should not happen? */
+               break;
+       case R3964_WAIT_FOR_BCC:
+               pInfo->last_rx = c;
+               on_receive_block(pInfo);
+               break;
+       }
 }
 
 static void receive_error(struct r3964_info *pInfo, const char flag)
 {
-    switch (flag) 
-    {
-    case TTY_NORMAL:
-        break;
-    case TTY_BREAK:
-        TRACE_PE("received break")
-        pInfo->flags |= R3964_BREAK;
-        break;
-    case TTY_PARITY:
-        TRACE_PE("parity error")
-        pInfo->flags |= R3964_PARITY;
-        break;
-    case TTY_FRAME:
-        TRACE_PE("frame error")
-        pInfo->flags |= R3964_FRAME;
-        break;
-    case TTY_OVERRUN:
-        TRACE_PE("frame overrun")
-        pInfo->flags |= R3964_OVERRUN;
-        break;
-    default:
-        TRACE_PE("receive_error - unknown flag %d", flag);
-        pInfo->flags |= R3964_UNKNOWN;
-        break;
-    }
+       switch (flag) {
+       case TTY_NORMAL:
+               break;
+       case TTY_BREAK:
+               TRACE_PE("received break");
+               pInfo->flags |= R3964_BREAK;
+               break;
+       case TTY_PARITY:
+               TRACE_PE("parity error");
+               pInfo->flags |= R3964_PARITY;
+               break;
+       case TTY_FRAME:
+               TRACE_PE("frame error");
+               pInfo->flags |= R3964_FRAME;
+               break;
+       case TTY_OVERRUN:
+               TRACE_PE("frame overrun");
+               pInfo->flags |= R3964_OVERRUN;
+               break;
+       default:
+               TRACE_PE("receive_error - unknown flag %d", flag);
+               pInfo->flags |= R3964_UNKNOWN;
+               break;
+       }
 }
 
 static void on_timeout(unsigned long priv)
 {
-   struct r3964_info *pInfo = (void *)priv;
-
-   switch(pInfo->state)
-   {
-      case R3964_TX_REQUEST:
-         TRACE_PE("TX_REQUEST - timeout");
-         retry_transmit(pInfo);
-         break;
-      case R3964_WAIT_ZVZ_BEFORE_TX_RETRY:
-         put_char(pInfo, NAK);
-         flush(pInfo);
-         retry_transmit(pInfo);
-         break;
-      case R3964_WAIT_FOR_TX_ACK:
-         TRACE_PE("WAIT_FOR_TX_ACK - timeout");
-         retry_transmit(pInfo);
-         break;
-      case R3964_WAIT_FOR_RX_BUF:
-         TRACE_PE("WAIT_FOR_RX_BUF - timeout");
-         put_char(pInfo, NAK);
-         flush(pInfo);
-         pInfo->state=R3964_IDLE;
-         break;
-      case R3964_RECEIVING:
-         TRACE_PE("RECEIVING - timeout after %d chars", 
-                  pInfo->rx_position);
-         put_char(pInfo, NAK);
-         flush(pInfo);
-         pInfo->state=R3964_IDLE;
-         break;
-      case R3964_WAIT_FOR_RX_REPEAT:
-         TRACE_PE("WAIT_FOR_RX_REPEAT - timeout");
-         pInfo->state=R3964_IDLE;
-         break;
-      case R3964_WAIT_FOR_BCC:
-         TRACE_PE("WAIT_FOR_BCC - timeout");
-         put_char(pInfo, NAK);
-         flush(pInfo);
-         pInfo->state=R3964_IDLE;
-         break;
-   }
+       struct r3964_info *pInfo = (void *)priv;
+
+       switch (pInfo->state) {
+       case R3964_TX_REQUEST:
+               TRACE_PE("TX_REQUEST - timeout");
+               retry_transmit(pInfo);
+               break;
+       case R3964_WAIT_ZVZ_BEFORE_TX_RETRY:
+               put_char(pInfo, NAK);
+               flush(pInfo);
+               retry_transmit(pInfo);
+               break;
+       case R3964_WAIT_FOR_TX_ACK:
+               TRACE_PE("WAIT_FOR_TX_ACK - timeout");
+               retry_transmit(pInfo);
+               break;
+       case R3964_WAIT_FOR_RX_BUF:
+               TRACE_PE("WAIT_FOR_RX_BUF - timeout");
+               put_char(pInfo, NAK);
+               flush(pInfo);
+               pInfo->state = R3964_IDLE;
+               break;
+       case R3964_RECEIVING:
+               TRACE_PE("RECEIVING - timeout after %d chars",
+                        pInfo->rx_position);
+               put_char(pInfo, NAK);
+               flush(pInfo);
+               pInfo->state = R3964_IDLE;
+               break;
+       case R3964_WAIT_FOR_RX_REPEAT:
+               TRACE_PE("WAIT_FOR_RX_REPEAT - timeout");
+               pInfo->state = R3964_IDLE;
+               break;
+       case R3964_WAIT_FOR_BCC:
+               TRACE_PE("WAIT_FOR_BCC - timeout");
+               put_char(pInfo, NAK);
+               flush(pInfo);
+               pInfo->state = R3964_IDLE;
+               break;
+       }
 }
 
-static struct r3964_client_info *findClient(
-  struct r3964_info *pInfo, struct pid *pid)
+static struct r3964_client_info *findClient(struct r3964_info *pInfo,
+               struct pid *pid)
 {
-   struct r3964_client_info *pClient;
-   
-   for(pClient=pInfo->firstClient; pClient; pClient=pClient->next)
-   {
-      if(pClient->pid == pid)
-      {
-         return pClient;
-      }
-   }
-   return NULL;
+       struct r3964_client_info *pClient;
+
+       for (pClient = pInfo->firstClient; pClient; pClient = pClient->next) {
+               if (pClient->pid == pid) {
+                       return pClient;
+               }
+       }
+       return NULL;
 }
 
 static int enable_signals(struct r3964_info *pInfo, struct pid *pid, int arg)
 {
-   struct r3964_client_info *pClient;
-   struct r3964_client_info **ppClient;
-   struct r3964_message *pMsg;
-   
-   if((arg & R3964_SIG_ALL)==0)
-   {
-      /* Remove client from client list */
-      for(ppClient=&pInfo->firstClient; *ppClient; ppClient=&(*ppClient)->next)
-      {
-         pClient = *ppClient;
-         
-         if(pClient->pid == pid)
-         {
-            TRACE_PS("removing client %d from client list", pid_nr(pid));
-            *ppClient = pClient->next;
-            while(pClient->msg_count)
-            {
-               pMsg=remove_msg(pInfo, pClient);
-               if(pMsg)
-               {
-                  kfree(pMsg);
-                  TRACE_M("enable_signals - msg kfree %p",pMsg);
-               }
-            }
-           put_pid(pClient->pid);
-            kfree(pClient);
-            TRACE_M("enable_signals - kfree %p",pClient);
-            return 0;
-         }
-      }
-      return -EINVAL;
-   }
-   else
-   {
-      pClient=findClient(pInfo, pid);
-      if(pClient)
-      {
-         /* update signal options */
-         pClient->sig_flags=arg;
-      } 
-      else 
-      {
-         /* add client to client list */
-         pClient=kmalloc(sizeof(struct r3964_client_info), GFP_KERNEL);
-         TRACE_M("enable_signals - kmalloc %p",pClient);
-         if(pClient==NULL)
-            return -ENOMEM;
-
-         TRACE_PS("add client %d to client list", pid_nr(pid));
-        spin_lock_init(&pClient->lock);
-         pClient->sig_flags=arg;
-         pClient->pid = get_pid(pid);
-         pClient->next=pInfo->firstClient;
-         pClient->first_msg = NULL;
-         pClient->last_msg = NULL;
-         pClient->next_block_to_read = NULL;
-         pClient->msg_count = 0;
-         pInfo->firstClient=pClient;
-      }
-   }
-
-   return 0;
+       struct r3964_client_info *pClient;
+       struct r3964_client_info **ppClient;
+       struct r3964_message *pMsg;
+
+       if ((arg & R3964_SIG_ALL) == 0) {
+               /* Remove client from client list */
+               for (ppClient = &pInfo->firstClient; *ppClient;
+                    ppClient = &(*ppClient)->next) {
+                       pClient = *ppClient;
+
+                       if (pClient->pid == pid) {
+                               TRACE_PS("removing client %d from client list",
+                                        pid_nr(pid));
+                               *ppClient = pClient->next;
+                               while (pClient->msg_count) {
+                                       pMsg = remove_msg(pInfo, pClient);
+                                       if (pMsg) {
+                                               kfree(pMsg);
+                                               TRACE_M("enable_signals - msg "
+                                                       "kfree %p", pMsg);
+                                       }
+                               }
+                               put_pid(pClient->pid);
+                               kfree(pClient);
+                               TRACE_M("enable_signals - kfree %p", pClient);
+                               return 0;
+                       }
+               }
+               return -EINVAL;
+       } else {
+               pClient = findClient(pInfo, pid);
+               if (pClient) {
+                       /* update signal options */
+                       pClient->sig_flags = arg;
+               } else {
+                       /* add client to client list */
+                       pClient = kmalloc(sizeof(struct r3964_client_info),
+                                       GFP_KERNEL);
+                       TRACE_M("enable_signals - kmalloc %p", pClient);
+                       if (pClient == NULL)
+                               return -ENOMEM;
+
+                       TRACE_PS("add client %d to client list", pid_nr(pid));
+                       spin_lock_init(&pClient->lock);
+                       pClient->sig_flags = arg;
+                       pClient->pid = get_pid(pid);
+                       pClient->next = pInfo->firstClient;
+                       pClient->first_msg = NULL;
+                       pClient->last_msg = NULL;
+                       pClient->next_block_to_read = NULL;
+                       pClient->msg_count = 0;
+                       pInfo->firstClient = pClient;
+               }
+       }
+
+       return 0;
 }
 
-static int read_telegram(struct r3964_info *pInfo, struct pid *pid, unsigned char __user *buf)
+static int read_telegram(struct r3964_info *pInfo, struct pid *pid,
+                        unsigned char __user * buf)
 {
-    struct r3964_client_info *pClient;
-    struct r3964_block_header *block;
-
-    if(!buf)
-    {
-        return -EINVAL;
-    }
-
-    pClient=findClient(pInfo,pid);
-    if(pClient==NULL)
-    {
-       return -EINVAL;
-    }
-    
-    block=pClient->next_block_to_read;
-    if(!block)
-    {
-       return 0;
-    }
-    else
-    {
-      if (copy_to_user (buf, block->data, block->length))
-       return -EFAULT;
-
-       remove_client_block(pInfo, pClient);
-       return block->length;
-    }
-
-    return -EINVAL;
+       struct r3964_client_info *pClient;
+       struct r3964_block_header *block;
+
+       if (!buf) {
+               return -EINVAL;
+       }
+
+       pClient = findClient(pInfo, pid);
+       if (pClient == NULL) {
+               return -EINVAL;
+       }
+
+       block = pClient->next_block_to_read;
+       if (!block) {
+               return 0;
+       } else {
+               if (copy_to_user(buf, block->data, block->length))
+                       return -EFAULT;
+
+               remove_client_block(pInfo, pClient);
+               return block->length;
+       }
+
+       return -EINVAL;
 }
 
 static void add_msg(struct r3964_client_info *pClient, int msg_id, int arg,
-             int error_code, struct r3964_block_header *pBlock)
+               int error_code, struct r3964_block_header *pBlock)
 {
-   struct r3964_message *pMsg;
-   unsigned long flags;
-   
-   if(pClient->msg_count<R3964_MAX_MSG_COUNT-1)
-   {
+       struct r3964_message *pMsg;
+       unsigned long flags;
+
+       if (pClient->msg_count < R3964_MAX_MSG_COUNT - 1) {
 queue_the_message:
 
-      pMsg = kmalloc(sizeof(struct r3964_message),
-                    error_code?GFP_ATOMIC:GFP_KERNEL);
-      TRACE_M("add_msg - kmalloc %p",pMsg);
-      if(pMsg==NULL) {
-         return;
-      }
-
-      spin_lock_irqsave(&pClient->lock, flags);
-
-      pMsg->msg_id = msg_id;
-      pMsg->arg    = arg;
-      pMsg->error_code = error_code;
-      pMsg->block  = pBlock;
-      pMsg->next   = NULL;
-      
-      if(pClient->last_msg==NULL)
-      {
-         pClient->first_msg=pClient->last_msg=pMsg;
-      }
-      else
-      {
-         pClient->last_msg->next = pMsg;
-         pClient->last_msg=pMsg;
-      }
-
-      pClient->msg_count++;
-
-      if(pBlock!=NULL)
-      {
-         pBlock->locks++;
-      }
-      spin_unlock_irqrestore(&pClient->lock, flags);
-   }
-   else
-   {
-      if((pClient->last_msg->msg_id == R3964_MSG_ACK)
-                && (pClient->last_msg->error_code==R3964_OVERFLOW))
-      {
-         pClient->last_msg->arg++;
-                TRACE_PE("add_msg - inc prev OVERFLOW-msg");
-      }
-      else
-      {
-         msg_id = R3964_MSG_ACK;
-         arg = 0;
-                error_code = R3964_OVERFLOW;
-         pBlock = NULL;
-                TRACE_PE("add_msg - queue OVERFLOW-msg");
-         goto queue_the_message;
-      }
-   }
-   /* Send SIGIO signal to client process: */
-   if(pClient->sig_flags & R3964_USE_SIGIO)
-   {
-      kill_pid(pClient->pid, SIGIO, 1);
-   }
+               pMsg = kmalloc(sizeof(struct r3964_message),
+                               error_code ? GFP_ATOMIC : GFP_KERNEL);
+               TRACE_M("add_msg - kmalloc %p", pMsg);
+               if (pMsg == NULL) {
+                       return;
+               }
+
+               spin_lock_irqsave(&pClient->lock, flags);
+
+               pMsg->msg_id = msg_id;
+               pMsg->arg = arg;
+               pMsg->error_code = error_code;
+               pMsg->block = pBlock;
+               pMsg->next = NULL;
+
+               if (pClient->last_msg == NULL) {
+                       pClient->first_msg = pClient->last_msg = pMsg;
+               } else {
+                       pClient->last_msg->next = pMsg;
+                       pClient->last_msg = pMsg;
+               }
+
+               pClient->msg_count++;
+
+               if (pBlock != NULL) {
+                       pBlock->locks++;
+               }
+               spin_unlock_irqrestore(&pClient->lock, flags);
+       } else {
+               if ((pClient->last_msg->msg_id == R3964_MSG_ACK)
+                   && (pClient->last_msg->error_code == R3964_OVERFLOW)) {
+                       pClient->last_msg->arg++;
+                       TRACE_PE("add_msg - inc prev OVERFLOW-msg");
+               } else {
+                       msg_id = R3964_MSG_ACK;
+                       arg = 0;
+                       error_code = R3964_OVERFLOW;
+                       pBlock = NULL;
+                       TRACE_PE("add_msg - queue OVERFLOW-msg");
+                       goto queue_the_message;
+               }
+       }
+       /* Send SIGIO signal to client process: */
+       if (pClient->sig_flags & R3964_USE_SIGIO) {
+               kill_pid(pClient->pid, SIGIO, 1);
+       }
 }
 
 static struct r3964_message *remove_msg(struct r3964_info *pInfo,
-                       struct r3964_client_info *pClient)
+                                       struct r3964_client_info *pClient)
 {
-   struct r3964_message *pMsg=NULL;
-   unsigned long flags;
-
-   if(pClient->first_msg)
-   {
-      spin_lock_irqsave(&pClient->lock, flags);
-
-      pMsg = pClient->first_msg;
-      pClient->first_msg = pMsg->next;
-      if(pClient->first_msg==NULL)
-      {
-         pClient->last_msg = NULL;
-      }
-      
-      pClient->msg_count--;
-      if(pMsg->block)
-      {
-        remove_client_block(pInfo, pClient);
-        pClient->next_block_to_read = pMsg->block;
-      }
-      spin_unlock_irqrestore(&pClient->lock, flags);
-   }
-   return pMsg;
+       struct r3964_message *pMsg = NULL;
+       unsigned long flags;
+
+       if (pClient->first_msg) {
+               spin_lock_irqsave(&pClient->lock, flags);
+
+               pMsg = pClient->first_msg;
+               pClient->first_msg = pMsg->next;
+               if (pClient->first_msg == NULL) {
+                       pClient->last_msg = NULL;
+               }
+
+               pClient->msg_count--;
+               if (pMsg->block) {
+                       remove_client_block(pInfo, pClient);
+                       pClient->next_block_to_read = pMsg->block;
+               }
+               spin_unlock_irqrestore(&pClient->lock, flags);
+       }
+       return pMsg;
 }
 
-static void remove_client_block(struct r3964_info *pInfo, 
-                struct r3964_client_info *pClient)
+static void remove_client_block(struct r3964_info *pInfo,
+                               struct r3964_client_info *pClient)
 {
-    struct r3964_block_header *block;
-
-    TRACE_PS("remove_client_block PID %d", pid_nr(pClient->pid));
-
-    block=pClient->next_block_to_read;
-    if(block)
-    {
-        block->locks--;
-        if(block->locks==0)
-        {
-            remove_from_rx_queue(pInfo, block);
-        }
-    }
-    pClient->next_block_to_read = NULL;
-}
+       struct r3964_block_header *block;
+
+       TRACE_PS("remove_client_block PID %d", pid_nr(pClient->pid));
 
+       block = pClient->next_block_to_read;
+       if (block) {
+               block->locks--;
+               if (block->locks == 0) {
+                       remove_from_rx_queue(pInfo, block);
+               }
+       }
+       pClient->next_block_to_read = NULL;
+}
 
 /*************************************************************
  * Line discipline routines
@@ -1064,342 +951,320 @@ static void remove_client_block(struct r3964_info *pInfo,
 
 static int r3964_open(struct tty_struct *tty)
 {
-   struct r3964_info *pInfo;
-   
-   TRACE_L("open");
-   TRACE_L("tty=%p, PID=%d, disc_data=%p", 
-          tty, current->pid, tty->disc_data);
-   
-   pInfo=kmalloc(sizeof(struct r3964_info), GFP_KERNEL); 
-   TRACE_M("r3964_open - info kmalloc %p",pInfo);
-
-   if(!pInfo)
-   {
-      printk(KERN_ERR "r3964: failed to alloc info structure\n");
-      return -ENOMEM;
-   }
-
-   pInfo->rx_buf = kmalloc(RX_BUF_SIZE, GFP_KERNEL);
-   TRACE_M("r3964_open - rx_buf kmalloc %p",pInfo->rx_buf);
-
-   if(!pInfo->rx_buf)
-   {
-      printk(KERN_ERR "r3964: failed to alloc receive buffer\n");
-      kfree(pInfo);
-      TRACE_M("r3964_open - info kfree %p",pInfo);
-      return -ENOMEM;
-   }
-   
-   pInfo->tx_buf = kmalloc(TX_BUF_SIZE, GFP_KERNEL);
-   TRACE_M("r3964_open - tx_buf kmalloc %p",pInfo->tx_buf);
-
-   if(!pInfo->tx_buf)
-   {
-      printk(KERN_ERR "r3964: failed to alloc transmit buffer\n");
-      kfree(pInfo->rx_buf);
-      TRACE_M("r3964_open - rx_buf kfree %p",pInfo->rx_buf);
-      kfree(pInfo);
-      TRACE_M("r3964_open - info kfree %p",pInfo);
-      return -ENOMEM;
-   }
-
-   spin_lock_init(&pInfo->lock);
-   pInfo->tty = tty;
-   init_waitqueue_head (&pInfo->read_wait);
-   pInfo->priority = R3964_MASTER;
-   pInfo->rx_first = pInfo->rx_last = NULL;
-   pInfo->tx_first = pInfo->tx_last = NULL;
-   pInfo->rx_position = 0;
-   pInfo->tx_position = 0;
-   pInfo->last_rx = 0;
-   pInfo->blocks_in_rx_queue = 0;
-   pInfo->firstClient=NULL;
-   pInfo->state=R3964_IDLE;
-   pInfo->flags = R3964_DEBUG;
-   pInfo->nRetry = 0;
-   
-   tty->disc_data = pInfo;
-   tty->receive_room = 65536;
-
-   init_timer(&pInfo->tmr);
-   pInfo->tmr.data = (unsigned long)pInfo;
-   pInfo->tmr.function = on_timeout;
-
-   return 0;
+       struct r3964_info *pInfo;
+
+       TRACE_L("open");
+       TRACE_L("tty=%p, PID=%d, disc_data=%p",
+               tty, current->pid, tty->disc_data);
+
+       pInfo = kmalloc(sizeof(struct r3964_info), GFP_KERNEL);
+       TRACE_M("r3964_open - info kmalloc %p", pInfo);
+
+       if (!pInfo) {
+               printk(KERN_ERR "r3964: failed to alloc info structure\n");
+               return -ENOMEM;
+       }
+
+       pInfo->rx_buf = kmalloc(RX_BUF_SIZE, GFP_KERNEL);
+       TRACE_M("r3964_open - rx_buf kmalloc %p", pInfo->rx_buf);
+
+       if (!pInfo->rx_buf) {
+               printk(KERN_ERR "r3964: failed to alloc receive buffer\n");
+               kfree(pInfo);
+               TRACE_M("r3964_open - info kfree %p", pInfo);
+               return -ENOMEM;
+       }
+
+       pInfo->tx_buf = kmalloc(TX_BUF_SIZE, GFP_KERNEL);
+       TRACE_M("r3964_open - tx_buf kmalloc %p", pInfo->tx_buf);
+
+       if (!pInfo->tx_buf) {
+               printk(KERN_ERR "r3964: failed to alloc transmit buffer\n");
+               kfree(pInfo->rx_buf);
+               TRACE_M("r3964_open - rx_buf kfree %p", pInfo->rx_buf);
+               kfree(pInfo);
+               TRACE_M("r3964_open - info kfree %p", pInfo);
+               return -ENOMEM;
+       }
+
+       spin_lock_init(&pInfo->lock);
+       pInfo->tty = tty;
+       init_waitqueue_head(&pInfo->read_wait);
+       pInfo->priority = R3964_MASTER;
+       pInfo->rx_first = pInfo->rx_last = NULL;
+       pInfo->tx_first = pInfo->tx_last = NULL;
+       pInfo->rx_position = 0;
+       pInfo->tx_position = 0;
+       pInfo->last_rx = 0;
+       pInfo->blocks_in_rx_queue = 0;
+       pInfo->firstClient = NULL;
+       pInfo->state = R3964_IDLE;
+       pInfo->flags = R3964_DEBUG;
+       pInfo->nRetry = 0;
+
+       tty->disc_data = pInfo;
+       tty->receive_room = 65536;
+
+       init_timer(&pInfo->tmr);
+       pInfo->tmr.data = (unsigned long)pInfo;
+       pInfo->tmr.function = on_timeout;
+
+       return 0;
 }
 
 static void r3964_close(struct tty_struct *tty)
 {
-   struct r3964_info *pInfo=(struct r3964_info*)tty->disc_data;
-   struct r3964_client_info *pClient, *pNext;
-   struct r3964_message *pMsg;
-   struct r3964_block_header *pHeader, *pNextHeader;
-   unsigned long flags;
-
-   TRACE_L("close");
-
-    /*
-     * Make sure that our task queue isn't activated.  If it
-     * is, take it out of the linked list.
-     */
-    del_timer_sync(&pInfo->tmr);
-
-   /* Remove client-structs and message queues: */
-    pClient=pInfo->firstClient;
-    while(pClient)
-    {
-       pNext=pClient->next;
-       while(pClient->msg_count)
-       {
-          pMsg=remove_msg(pInfo, pClient);
-          if(pMsg)
-          {
-             kfree(pMsg);
-             TRACE_M("r3964_close - msg kfree %p",pMsg);
-          }
-       }
-       put_pid(pClient->pid);
-       kfree(pClient);
-       TRACE_M("r3964_close - client kfree %p",pClient);
-       pClient=pNext;
-    }
-    /* Remove jobs from tx_queue: */
-        spin_lock_irqsave(&pInfo->lock, flags);
-       pHeader=pInfo->tx_first;
-       pInfo->tx_first=pInfo->tx_last=NULL;
+       struct r3964_info *pInfo = (struct r3964_info *)tty->disc_data;
+       struct r3964_client_info *pClient, *pNext;
+       struct r3964_message *pMsg;
+       struct r3964_block_header *pHeader, *pNextHeader;
+       unsigned long flags;
+
+       TRACE_L("close");
+
+       /*
+        * Make sure that our task queue isn't activated.  If it
+        * is, take it out of the linked list.
+        */
+       del_timer_sync(&pInfo->tmr);
+
+       /* Remove client-structs and message queues: */
+       pClient = pInfo->firstClient;
+       while (pClient) {
+               pNext = pClient->next;
+               while (pClient->msg_count) {
+                       pMsg = remove_msg(pInfo, pClient);
+                       if (pMsg) {
+                               kfree(pMsg);
+                               TRACE_M("r3964_close - msg kfree %p", pMsg);
+                       }
+               }
+               put_pid(pClient->pid);
+               kfree(pClient);
+               TRACE_M("r3964_close - client kfree %p", pClient);
+               pClient = pNext;
+       }
+       /* Remove jobs from tx_queue: */
+       spin_lock_irqsave(&pInfo->lock, flags);
+       pHeader = pInfo->tx_first;
+       pInfo->tx_first = pInfo->tx_last = NULL;
        spin_unlock_irqrestore(&pInfo->lock, flags);
-       
-    while(pHeader)
-       {
-          pNextHeader=pHeader->next;
-          kfree(pHeader);
-          pHeader=pNextHeader;
+
+       while (pHeader) {
+               pNextHeader = pHeader->next;
+               kfree(pHeader);
+               pHeader = pNextHeader;
        }
 
-    /* Free buffers: */
-    wake_up_interruptible(&pInfo->read_wait);
-    kfree(pInfo->rx_buf);
-    TRACE_M("r3964_close - rx_buf kfree %p",pInfo->rx_buf);
-    kfree(pInfo->tx_buf);
-    TRACE_M("r3964_close - tx_buf kfree %p",pInfo->tx_buf);
-    kfree(pInfo);
-    TRACE_M("r3964_close - info kfree %p",pInfo);
+       /* Free buffers: */
+       wake_up_interruptible(&pInfo->read_wait);
+       kfree(pInfo->rx_buf);
+       TRACE_M("r3964_close - rx_buf kfree %p", pInfo->rx_buf);
+       kfree(pInfo->tx_buf);
+       TRACE_M("r3964_close - tx_buf kfree %p", pInfo->tx_buf);
+       kfree(pInfo);
+       TRACE_M("r3964_close - info kfree %p", pInfo);
 }
 
 static ssize_t r3964_read(struct tty_struct *tty, struct file *file,
-                         unsigned char __user *buf, size_t nr)
+                         unsigned char __user * buf, size_t nr)
 {
-   struct r3964_info *pInfo=(struct r3964_info*)tty->disc_data;
-   struct r3964_client_info *pClient;
-   struct r3964_message *pMsg;
-   struct r3964_client_message theMsg;
-   DECLARE_WAITQUEUE (wait, current);
-   
-   int count;
-   
-   TRACE_L("read()");
-   pClient=findClient(pInfo, task_pid(current));
-   if(pClient)
-   {
-      pMsg = remove_msg(pInfo, pClient);
-      if(pMsg==NULL)
-      {
-                /* no messages available. */
-         if (file->f_flags & O_NONBLOCK)
-                {
-            return -EAGAIN;
-                }
-         /* block until there is a message: */
-         add_wait_queue(&pInfo->read_wait, &wait);
+       struct r3964_info *pInfo = (struct r3964_info *)tty->disc_data;
+       struct r3964_client_info *pClient;
+       struct r3964_message *pMsg;
+       struct r3964_client_message theMsg;
+       DECLARE_WAITQUEUE(wait, current);
+
+       int count;
+
+       TRACE_L("read()");
+
+       pClient = findClient(pInfo, task_pid(current));
+       if (pClient) {
+               pMsg = remove_msg(pInfo, pClient);
+               if (pMsg == NULL) {
+                       /* no messages available. */
+                       if (file->f_flags & O_NONBLOCK) {
+                               return -EAGAIN;
+                       }
+                       /* block until there is a message: */
+                       add_wait_queue(&pInfo->read_wait, &wait);
 repeat:
-         current->state = TASK_INTERRUPTIBLE;
-         pMsg = remove_msg(pInfo, pClient);
-        if (!pMsg && !signal_pending(current))
-                {
-            schedule();
-            goto repeat;
-         }
-         current->state = TASK_RUNNING;
-         remove_wait_queue(&pInfo->read_wait, &wait);
-      }
-      
-      /* If we still haven't got a message, we must have been signalled */
-
-      if (!pMsg) return -EINTR;
-
-      /* deliver msg to client process: */
-      theMsg.msg_id = pMsg->msg_id;
-      theMsg.arg    = pMsg->arg;
-      theMsg.error_code = pMsg->error_code;
-      count = sizeof(struct r3964_client_message);
-
-      kfree(pMsg);
-      TRACE_M("r3964_read - msg kfree %p",pMsg);
-
-      if (copy_to_user(buf,&theMsg, count))
-       return -EFAULT;
-
-      TRACE_PS("read - return %d", count);
-      return count;
-   }
-   return -EPERM;
+                       current->state = TASK_INTERRUPTIBLE;
+                       pMsg = remove_msg(pInfo, pClient);
+                       if (!pMsg && !signal_pending(current)) {
+                               schedule();
+                               goto repeat;
+                       }
+                       current->state = TASK_RUNNING;
+                       remove_wait_queue(&pInfo->read_wait, &wait);
+               }
+
+               /* If we still haven't got a message, we must have been signalled */
+
+               if (!pMsg)
+                       return -EINTR;
+
+               /* deliver msg to client process: */
+               theMsg.msg_id = pMsg->msg_id;
+               theMsg.arg = pMsg->arg;
+               theMsg.error_code = pMsg->error_code;
+               count = sizeof(struct r3964_client_message);
+
+               kfree(pMsg);
+               TRACE_M("r3964_read - msg kfree %p", pMsg);
+
+               if (copy_to_user(buf, &theMsg, count))
+                       return -EFAULT;
+
+               TRACE_PS("read - return %d", count);
+               return count;
+       }
+       return -EPERM;
 }
 
-static ssize_t r3964_write(struct tty_struct * tty, struct file * file,
+static ssize_t r3964_write(struct tty_struct *tty, struct file *file,
                           const unsigned char *data, size_t count)
 {
-   struct r3964_info *pInfo=(struct r3964_info*)tty->disc_data;
-   struct r3964_block_header *pHeader;
-   struct r3964_client_info *pClient;
-   unsigned char *new_data;
-   
-   TRACE_L("write request, %d characters", count);
+       struct r3964_info *pInfo = (struct r3964_info *)tty->disc_data;
+       struct r3964_block_header *pHeader;
+       struct r3964_client_info *pClient;
+       unsigned char *new_data;
+
+       TRACE_L("write request, %d characters", count);
 /* 
  * Verify the pointers 
  */
 
-   if(!pInfo)
-      return -EIO;
+       if (!pInfo)
+               return -EIO;
 
 /*
  * Ensure that the caller does not wish to send too much.
  */
-   if (count > R3964_MTU) 
-   {
-      if (pInfo->flags & R3964_DEBUG)
-      {
-         TRACE_L (KERN_WARNING
-                 "r3964_write: truncating user packet "
-                 "from %u to mtu %d", count, R3964_MTU);
-      }
-      count = R3964_MTU;
-   }
+       if (count > R3964_MTU) {
+               if (pInfo->flags & R3964_DEBUG) {
+                       TRACE_L(KERN_WARNING "r3964_write: truncating user "
+                               "packet from %u to mtu %d", count, R3964_MTU);
+               }
+               count = R3964_MTU;
+       }
 /*
  * Allocate a buffer for the data and copy it from the buffer with header prepended
  */
-   new_data = kmalloc (count+sizeof(struct r3964_block_header), GFP_KERNEL);
-   TRACE_M("r3964_write - kmalloc %p",new_data);
-   if (new_data == NULL) {
-      if (pInfo->flags & R3964_DEBUG)
-      {
-         printk (KERN_ERR
-               "r3964_write: no memory\n");
-      }
-      return -ENOSPC;
-   }
-   
-   pHeader = (struct r3964_block_header *)new_data;
-   pHeader->data = new_data + sizeof(struct r3964_block_header);
-   pHeader->length = count;
-   pHeader->locks = 0;
-   pHeader->owner = NULL;
-   
-   pClient=findClient(pInfo, task_pid(current));
-   if(pClient)
-   {
-      pHeader->owner = pClient;
-   }
-
-   memcpy(pHeader->data, data, count); /* We already verified this */
-
-   if(pInfo->flags & R3964_DEBUG)
-   {
-      dump_block(pHeader->data, count);
-   }
+       new_data = kmalloc(count + sizeof(struct r3964_block_header),
+                       GFP_KERNEL);
+       TRACE_M("r3964_write - kmalloc %p", new_data);
+       if (new_data == NULL) {
+               if (pInfo->flags & R3964_DEBUG) {
+                       printk(KERN_ERR "r3964_write: no memory\n");
+               }
+               return -ENOSPC;
+       }
+
+       pHeader = (struct r3964_block_header *)new_data;
+       pHeader->data = new_data + sizeof(struct r3964_block_header);
+       pHeader->length = count;
+       pHeader->locks = 0;
+       pHeader->owner = NULL;
+
+       pClient = findClient(pInfo, task_pid(current));
+       if (pClient) {
+               pHeader->owner = pClient;
+       }
+
+       memcpy(pHeader->data, data, count);     /* We already verified this */
+
+       if (pInfo->flags & R3964_DEBUG) {
+               dump_block(pHeader->data, count);
+       }
 
 /*
  * Add buffer to transmit-queue:
  */
-   add_tx_queue(pInfo, pHeader);
-   trigger_transmit(pInfo);
-   
-   return 0;
+       add_tx_queue(pInfo, pHeader);
+       trigger_transmit(pInfo);
+
+       return 0;
 }
 
-static int r3964_ioctl(struct tty_struct * tty, struct file * file,
-               unsigned int cmd, unsigned long arg)
+static int r3964_ioctl(struct tty_struct *tty, struct file *file,
+               unsigned int cmd, unsigned long arg)
 {
-   struct r3964_info *pInfo=(struct r3964_info*)tty->disc_data;
-   if(pInfo==NULL)
-      return -EINVAL;
-   switch(cmd)
-   {
-      case R3964_ENABLE_SIGNALS:
-         return enable_signals(pInfo, task_pid(current), arg);
-      case R3964_SETPRIORITY:
-         if(arg<R3964_MASTER || arg>R3964_SLAVE)
-            return -EINVAL;
-         pInfo->priority = arg & 0xff;
-         return 0;
-      case R3964_USE_BCC:
-             if(arg)
-            pInfo->flags |= R3964_BCC;
-         else
-            pInfo->flags &= ~R3964_BCC;
-         return 0;
-      case R3964_READ_TELEGRAM:
-         return read_telegram(pInfo, task_pid(current), (unsigned char __user *)arg);
-      default:
-         return -ENOIOCTLCMD;
-   }
+       struct r3964_info *pInfo = (struct r3964_info *)tty->disc_data;
+       if (pInfo == NULL)
+               return -EINVAL;
+       switch (cmd) {
+       case R3964_ENABLE_SIGNALS:
+               return enable_signals(pInfo, task_pid(current), arg);
+       case R3964_SETPRIORITY:
+               if (arg < R3964_MASTER || arg > R3964_SLAVE)
+                       return -EINVAL;
+               pInfo->priority = arg & 0xff;
+               return 0;
+       case R3964_USE_BCC:
+               if (arg)
+                       pInfo->flags |= R3964_BCC;
+               else
+                       pInfo->flags &= ~R3964_BCC;
+               return 0;
+       case R3964_READ_TELEGRAM:
+               return read_telegram(pInfo, task_pid(current),
+                               (unsigned char __user *)arg);
+       default:
+               return -ENOIOCTLCMD;
+       }
 }
 
-static void r3964_set_termios(struct tty_struct *tty, struct ktermios * old)
+static void r3964_set_termios(struct tty_struct *tty, struct ktermios *old)
 {
-   TRACE_L("set_termios");
+       TRACE_L("set_termios");
 }
 
 /* Called without the kernel lock held - fine */
-static unsigned int r3964_poll(struct tty_struct * tty, struct file * file,
-                     struct poll_table_struct *wait)
+static unsigned int r3964_poll(struct tty_struct *tty, struct file *file,
+                       struct poll_table_struct *wait)
 {
-   struct r3964_info *pInfo=(struct r3964_info*)tty->disc_data;
-   struct r3964_client_info *pClient;
-   struct r3964_message *pMsg=NULL;
-   unsigned long flags;
-   int result = POLLOUT;
-
-   TRACE_L("POLL");
-
-   pClient=findClient(pInfo, task_pid(current));
-   if(pClient)
-     {
-       poll_wait(file, &pInfo->read_wait, wait);
-       spin_lock_irqsave(&pInfo->lock, flags);
-       pMsg=pClient->first_msg;
-       spin_unlock_irqrestore(&pInfo->lock, flags);
-       if(pMsg)
-          result |= POLLIN | POLLRDNORM;
-     }
-   else
-     {
-       result = -EINVAL;
-     }
-   return result;
+       struct r3964_info *pInfo = (struct r3964_info *)tty->disc_data;
+       struct r3964_client_info *pClient;
+       struct r3964_message *pMsg = NULL;
+       unsigned long flags;
+       int result = POLLOUT;
+
+       TRACE_L("POLL");
+
+       pClient = findClient(pInfo, task_pid(current));
+       if (pClient) {
+               poll_wait(file, &pInfo->read_wait, wait);
+               spin_lock_irqsave(&pInfo->lock, flags);
+               pMsg = pClient->first_msg;
+               spin_unlock_irqrestore(&pInfo->lock, flags);
+               if (pMsg)
+                       result |= POLLIN | POLLRDNORM;
+       } else {
+               result = -EINVAL;
+       }
+       return result;
 }
 
 static void r3964_receive_buf(struct tty_struct *tty, const unsigned char *cp,
-                              char *fp, int count)
+                       char *fp, int count)
 {
-   struct r3964_info *pInfo=(struct r3964_info*)tty->disc_data;
-    const unsigned char *p;
-    char *f, flags = 0;
-    int i;
-
-    for (i=count, p = cp, f = fp; i; i--, p++) {
-        if (f)
-            flags = *f++;
-        if(flags==TTY_NORMAL)
-        {
-            receive_char(pInfo, *p);
-        }
-        else
-        {
-            receive_error(pInfo, flags);
-        }
-        
-    }
+       struct r3964_info *pInfo = (struct r3964_info *)tty->disc_data;
+       const unsigned char *p;
+       char *f, flags = 0;
+       int i;
+
+       for (i = count, p = cp, f = fp; i; i--, p++) {
+               if (f)
+                       flags = *f++;
+               if (flags == TTY_NORMAL) {
+                       receive_char(pInfo, *p);
+               } else {
+                       receive_error(pInfo, flags);
+               }
+
+       }
 }
 
 MODULE_LICENSE("GPL");
index f108c136800a2ef3b2fcb990cc3d8aabf83b6ffe..4ab2c98f978cb5eab5321c3a3a7cde9ae6addfca 100644 (file)
@@ -887,10 +887,8 @@ static void bh_transmit(MGSLPC_INFO *info)
        if (debug_level >= DEBUG_LEVEL_BH)
                printk("bh_transmit() entry on %s\n", info->device_name);
 
-       if (tty) {
+       if (tty)
                tty_wakeup(tty);
-               wake_up_interruptible(&tty->write_wait);
-       }
 }
 
 static void bh_status(MGSLPC_INFO *info)
index 645e20a06ece382149b0f0eff59812aeed1d6a59..1f0d7c60c94420fb98fd23791bc38ba1b8266b37 100644 (file)
@@ -154,7 +154,7 @@ static int raw_ctl_ioctl(struct inode *inode, struct file *filp,
                        goto out;
                }
 
-               if (rq.raw_minor < 0 || rq.raw_minor >= MAX_RAW_MINORS) {
+               if (rq.raw_minor <= 0 || rq.raw_minor >= MAX_RAW_MINORS) {
                        err = -EINVAL;
                        goto out;
                }
index eeda40c5e189067a547e1db2a5670a6756fc5a74..ebc76342712c1485da63b58eb01d83be38e34a4d 100644 (file)
@@ -162,13 +162,8 @@ void RIOTxEnable(char *en)
 
        rio_spin_unlock_irqrestore(&PortP->portSem, flags);
 
-       if (PortP->gs.xmit_cnt <= (PortP->gs.wakeup_chars + 2 * PKT_MAX_DATA_LEN)) {
-               rio_dprintk(RIO_DEBUG_INTR, "Waking up.... ldisc:%d (%d/%d)....", (int) (PortP->gs.tty->flags & (1 << TTY_DO_WRITE_WAKEUP)), PortP->gs.wakeup_chars, PortP->gs.xmit_cnt);
-               if ((PortP->gs.tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && PortP->gs.tty->ldisc.write_wakeup)
-                       (PortP->gs.tty->ldisc.write_wakeup) (PortP->gs.tty);
-               rio_dprintk(RIO_DEBUG_INTR, "(%d/%d)\n", PortP->gs.wakeup_chars, PortP->gs.xmit_cnt);
-               wake_up_interruptible(&PortP->gs.tty->write_wait);
-       }
+       if (PortP->gs.xmit_cnt <= (PortP->gs.wakeup_chars + 2 * PKT_MAX_DATA_LEN))
+               tty_wakeup(PortP->gs.tty);
 
 }
 
index e2a94bfb2a436dd5d24e68fb8388721351a6acdb..70145254fb9dff9af8acedcc169f791acdc00446 100644 (file)
@@ -1229,7 +1229,6 @@ static void rc_flush_buffer(struct tty_struct *tty)
        port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
        restore_flags(flags);
        
-       wake_up_interruptible(&tty->write_wait);
        tty_wakeup(tty);
 }
 
@@ -1570,10 +1569,8 @@ static void do_softint(struct work_struct *ugly_api)
        if(!(tty = port->tty)) 
                return;
 
-       if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP, &port->event)) {
+       if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP, &port->event))
                tty_wakeup(tty);
-               wake_up_interruptible(&tty->write_wait);
-       }
 }
 
 static const struct tty_operations riscom_ops = {
index e94a62e30fc4f5c01be2343a28468675ba9ca8c8..106f225e745fa72f07a8689f11eff4f1b0bdcb06 100644 (file)
@@ -474,7 +474,6 @@ static void rp_do_transmit(struct r_port *info)
 
        if (info->xmit_cnt < WAKEUP_CHARS) {
                tty_wakeup(tty);
-               wake_up_interruptible(&tty->write_wait);
 #ifdef ROCKETPORT_HAVE_POLL_WAIT
                wake_up_interruptible(&tty->poll_wait);
 #endif
@@ -1772,7 +1771,6 @@ static int rp_write(struct tty_struct *tty,
 end:
        if (info->xmit_cnt < WAKEUP_CHARS) {
                tty_wakeup(tty);
-               wake_up_interruptible(&tty->write_wait);
 #ifdef ROCKETPORT_HAVE_POLL_WAIT
                wake_up_interruptible(&tty->poll_wait);
 #endif
@@ -1841,7 +1839,6 @@ static void rp_flush_buffer(struct tty_struct *tty)
        info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
        spin_unlock_irqrestore(&info->slock, flags);
 
-       wake_up_interruptible(&tty->write_wait);
 #ifdef ROCKETPORT_HAVE_POLL_WAIT
        wake_up_interruptible(&tty->poll_wait);
 #endif
index af50d32ae2c75a97fef06148de07d97c5713ef24..5fd314adc1f28d864805bea180d2f87a77d06741 100644 (file)
@@ -111,12 +111,13 @@ u_char initial_console_speed;
 
 /* This is the per-port data structure */
 struct cyclades_port cy_port[] = {
-      /* CARD#  */
-        {-1 },      /* ttyS0 */
-        {-1 },      /* ttyS1 */
-        {-1 },      /* ttyS2 */
-        {-1 },      /* ttyS3 */
+       /* CARD#  */
+       {-1},                   /* ttyS0 */
+       {-1},                   /* ttyS1 */
+       {-1},                   /* ttyS2 */
+       {-1},                   /* ttyS3 */
 };
+
 #define NR_PORTS        ARRAY_SIZE(cy_port)
 
 /*
@@ -128,42 +129,46 @@ struct cyclades_port cy_port[] = {
  *                                                  HI            VHI
  */
 static int baud_table[] = {
-           0,    50,    75,   110,   134,   150,   200,   300,   600,  1200,
-        1800,  2400,  4800,  9600, 19200, 38400, 57600, 76800,115200,150000,
-        0};
+       0, 50, 75, 110, 134, 150, 200, 300, 600, 1200,
+       1800, 2400, 4800, 9600, 19200, 38400, 57600, 76800, 115200, 150000,
+       0
+};
 
 #if 0
-static char baud_co[] = {  /* 25 MHz clock option table */
-        /* value =>    00    01   02    03    04 */
-        /* divide by    8    32   128   512  2048 */
-        0x00,  0x04,  0x04,  0x04,  0x04,  0x04,  0x03,  0x03,  0x03,  0x02,
-        0x02,  0x02,  0x01,  0x01,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00};
+static char baud_co[] = {      /* 25 MHz clock option table */
+       /* value =>    00    01   02    03    04 */
+       /* divide by    8    32   128   512  2048 */
+       0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, 0x02,
+       0x02, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
 
-static char baud_bpr[] = {  /* 25 MHz baud rate period table */
-        0x00,  0xf5,  0xa3,  0x6f,  0x5c,  0x51,  0xf5,  0xa3,  0x51,  0xa3,
-        0x6d,  0x51,  0xa3,  0x51,  0xa3,  0x51,  0x36,  0x29,  0x1b,  0x15};
+static char baud_bpr[] = {     /* 25 MHz baud rate period table */
+       0x00, 0xf5, 0xa3, 0x6f, 0x5c, 0x51, 0xf5, 0xa3, 0x51, 0xa3,
+       0x6d, 0x51, 0xa3, 0x51, 0xa3, 0x51, 0x36, 0x29, 0x1b, 0x15
+};
 #endif
 
 /* I think 166 brd clocks 2401 at 20MHz.... */
 
 /* These values are written directly to tcor, and >> 5 for writing to rcor */
-static u_char baud_co[] = {  /* 20 MHz clock option table */
-        0x00,  0x80,  0x80,  0x80,  0x80,  0x80,  0x80,  0x60,  0x60,  0x40,
-        0x40,  0x40,  0x20,  0x20,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00};
+static u_char baud_co[] = {    /* 20 MHz clock option table */
+       0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x60, 0x60, 0x40,
+       0x40, 0x40, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
 
 /* These values written directly to tbpr/rbpr */
-static u_char baud_bpr[] = {  /* 20 MHz baud rate period table */
-        0x00,  0xc0,  0x80,  0x58,  0x6c,  0x40,  0xc0,  0x81,  0x40,  0x81,
-        0x57,  0x40,  0x81,  0x40,  0x81,  0x40,  0x2b,  0x20,  0x15,  0x10};
-
-static u_char baud_cor4[] = {  /* receive threshold */
-        0x0a,  0x0a,  0x0a,  0x0a,  0x0a,  0x0a,  0x0a,  0x0a,  0x0a,  0x0a,
-        0x0a,  0x0a,  0x0a,  0x09,  0x09,  0x08,  0x08,  0x08,  0x08,  0x07};
-
+static u_char baud_bpr[] = {   /* 20 MHz baud rate period table */
+       0x00, 0xc0, 0x80, 0x58, 0x6c, 0x40, 0xc0, 0x81, 0x40, 0x81,
+       0x57, 0x40, 0x81, 0x40, 0x81, 0x40, 0x2b, 0x20, 0x15, 0x10
+};
 
+static u_char baud_cor4[] = {  /* receive threshold */
+       0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a,
+       0x0a, 0x0a, 0x0a, 0x09, 0x09, 0x08, 0x08, 0x08, 0x08, 0x07
+};
 
 static void shutdown(struct cyclades_port *);
-static int startup (struct cyclades_port *);
+static int startup(struct cyclades_port *);
 static void cy_throttle(struct tty_struct *);
 static void cy_unthrottle(struct tty_struct *);
 static void config_setup(struct cyclades_port *);
@@ -174,16 +179,16 @@ static void show_status(int);
 
 #ifdef CONFIG_REMOTE_DEBUG
 static void debug_setup(void);
-void queueDebugChar (int c);
+void queueDebugChar(int c);
 int getDebugChar(void);
 
 #define DEBUG_PORT     1
 #define DEBUG_LEN      256
 
 typedef struct {
-       int     in;
-       int     out;
-       unsigned char   buf[DEBUG_LEN];
+       int in;
+       int out;
+       unsigned char buf[DEBUG_LEN];
 } debugq;
 
 debugq debugiq;
@@ -196,7 +201,7 @@ debugq debugiq;
  * delay, but this wild guess will do for now.
  */
 
-void my_udelay (long us)
+void my_udelay(long us)
 {
        u_char x;
        volatile u_char *p = &x;
@@ -207,62 +212,73 @@ void my_udelay (long us)
                        x |= *p;
 }
 
-static inline int
-serial_paranoia_check(struct cyclades_port *info, char *name,
-                     const char *routine)
+static inline int serial_paranoia_check(struct cyclades_port *info, char *name,
+               const char *routine)
 {
 #ifdef SERIAL_PARANOIA_CHECK
-    static const char *badmagic =
-       "Warning: bad magic number for serial struct (%s) in %s\n";
-    static const char *badinfo =
-       "Warning: null cyclades_port for (%s) in %s\n";
-    static const char *badrange =
-       "Warning: cyclades_port out of range for (%s) in %s\n";
-
-    if (!info) {
-       printk(badinfo, name, routine);
-       return 1;
-    }
-
-    if( (long)info < (long)(&cy_port[0])
-    || (long)(&cy_port[NR_PORTS]) < (long)info ){
-       printk(badrange, name, routine);
-       return 1;
-    }
-
-    if (info->magic != CYCLADES_MAGIC) {
-       printk(badmagic, name, routine);
-       return 1;
-    }
+       if (!info) {
+               printk("Warning: null cyclades_port for (%s) in %s\n", name,
+                               routine);
+               return 1;
+       }
+
+       if ((long)info < (long)(&cy_port[0])
+           || (long)(&cy_port[NR_PORTS]) < (long)info) {
+               printk("Warning: cyclades_port out of range for (%s) in %s\n",
+                               name, routine);
+               return 1;
+       }
+
+       if (info->magic != CYCLADES_MAGIC) {
+               printk("Warning: bad magic number for serial struct (%s) in "
+                               "%s\n", name, routine);
+               return 1;
+       }
 #endif
        return 0;
-} /* serial_paranoia_check */
+}                              /* serial_paranoia_check */
 
 #if 0
 /* The following diagnostic routines allow the driver to spew
    information on the screen, even (especially!) during interrupts.
  */
-void
-SP(char *data){
-  unsigned long flags;
-    local_irq_save(flags);
-        console_print(data);
-    local_irq_restore(flags);
+void SP(char *data)
+{
+       unsigned long flags;
+       local_irq_save(flags);
+       console_print(data);
+       local_irq_restore(flags);
 }
+
 char scrn[2];
-void
-CP(char data){
-  unsigned long flags;
-    local_irq_save(flags);
-        scrn[0] = data;
-        console_print(scrn);
-    local_irq_restore(flags);
-}/* CP */
+void CP(char data)
+{
+       unsigned long flags;
+       local_irq_save(flags);
+       scrn[0] = data;
+       console_print(scrn);
+       local_irq_restore(flags);
+}                              /* CP */
 
-void CP1(int data) { (data<10)?  CP(data+'0'): CP(data+'A'-10); }/* CP1 */
-void CP2(int data) { CP1((data>>4) & 0x0f); CP1( data & 0x0f); }/* CP2 */
-void CP4(int data) { CP2((data>>8) & 0xff); CP2(data & 0xff); }/* CP4 */
-void CP8(long data) { CP4((data>>16) & 0xffff); CP4(data & 0xffff); }/* CP8 */
+void CP1(int data)
+{
+       (data < 10) ? CP(data + '0') : CP(data + 'A' - 10);
+}                              /* CP1 */
+void CP2(int data)
+{
+       CP1((data >> 4) & 0x0f);
+       CP1(data & 0x0f);
+}                              /* CP2 */
+void CP4(int data)
+{
+       CP2((data >> 8) & 0xff);
+       CP2(data & 0xff);
+}                              /* CP4 */
+void CP8(long data)
+{
+       CP4((data >> 16) & 0xffff);
+       CP4(data & 0xffff);
+}                              /* CP8 */
 #endif
 
 /* This routine waits up to 1000 micro-seconds for the previous
@@ -270,87 +286,78 @@ void CP8(long data) { CP4((data>>16) & 0xffff); CP4(data & 0xffff); }/* CP8 */
    new command.  An error is returned if the previous command
    didn't finish within the time limit.
  */
-u_short
-write_cy_cmd(volatile u_char *base_addr, u_char cmd)
+u_short write_cy_cmd(volatile u_char * base_addr, u_char cmd)
 {
-  unsigned long flags;
-  volatile int  i;
+       unsigned long flags;
+       volatile int i;
 
-    local_irq_save(flags);
+       local_irq_save(flags);
        /* Check to see that the previous command has completed */
-       for(i = 0 ; i < 100 ; i++){
-           if (base_addr[CyCCR] == 0){
-               break;
-           }
-           my_udelay(10L);
+       for (i = 0; i < 100; i++) {
+               if (base_addr[CyCCR] == 0) {
+                       break;
+               }
+               my_udelay(10L);
        }
        /* if the CCR never cleared, the previous command
-           didn't finish within the "reasonable time" */
-       if ( i == 10 ) {
-           local_irq_restore(flags);
-           return (-1);
+          didn't finish within the "reasonable time" */
+       if (i == 10) {
+               local_irq_restore(flags);
+               return (-1);
        }
 
        /* Issue the new command */
        base_addr[CyCCR] = cmd;
-    local_irq_restore(flags);
-    return(0);
-} /* write_cy_cmd */
-
+       local_irq_restore(flags);
+       return (0);
+}                              /* write_cy_cmd */
 
 /* cy_start and cy_stop provide software output flow control as a
    function of XON/XOFF, software CTS, and other such stuff. */
 
-static void
-cy_stop(struct tty_struct *tty)
+static void cy_stop(struct tty_struct *tty)
 {
-  struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
-  volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
-  int channel;
-  unsigned long flags;
+       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+       volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
+       int channel;
+       unsigned long flags;
 
 #ifdef SERIAL_DEBUG_OTHER
-    printk("cy_stop %s\n", tty->name); /* */
+       printk("cy_stop %s\n", tty->name);      /* */
 #endif
 
-    if (serial_paranoia_check(info, tty->name, "cy_stop"))
-       return;
-       
-    channel = info->line;
+       if (serial_paranoia_check(info, tty->name, "cy_stop"))
+               return;
 
-    local_irq_save(flags);
-        base_addr[CyCAR] = (u_char)(channel); /* index channel */
-        base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy);
-    local_irq_restore(flags);
+       channel = info->line;
 
-    return;
-} /* cy_stop */
+       local_irq_save(flags);
+       base_addr[CyCAR] = (u_char) (channel);  /* index channel */
+       base_addr[CyIER] &= ~(CyTxMpty | CyTxRdy);
+       local_irq_restore(flags);
+}                              /* cy_stop */
 
-static void
-cy_start(struct tty_struct *tty)
+static void cy_start(struct tty_struct *tty)
 {
-  struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
-  volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
-  int channel;
-  unsigned long flags;
+       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+       volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
+       int channel;
+       unsigned long flags;
 
 #ifdef SERIAL_DEBUG_OTHER
-    printk("cy_start %s\n", tty->name); /* */
+       printk("cy_start %s\n", tty->name);     /* */
 #endif
 
-    if (serial_paranoia_check(info, tty->name, "cy_start"))
-       return;
-       
-    channel = info->line;
+       if (serial_paranoia_check(info, tty->name, "cy_start"))
+               return;
 
-    local_irq_save(flags);
-        base_addr[CyCAR] = (u_char)(channel);
-        base_addr[CyIER] |= CyTxMpty;
-    local_irq_restore(flags);
-
-    return;
-} /* cy_start */
+       channel = info->line;
 
+       local_irq_save(flags);
+       base_addr[CyCAR] = (u_char) (channel);
+       base_addr[CyIER] |= CyTxMpty;
+       local_irq_restore(flags);
+}                              /* cy_start */
 
 /*
  * This routine is used by the interrupt handler to schedule
@@ -358,332 +365,332 @@ cy_start(struct tty_struct *tty)
  * (also known as the "bottom half").  This can be called any
  * number of times for any channel without harm.
  */
-static inline void
-cy_sched_event(struct cyclades_port *info, int event)
+static inline void cy_sched_event(struct cyclades_port *info, int event)
 {
-    info->event |= 1 << event; /* remember what kind of event and who */
-    schedule_work(&info->tqueue);
-} /* cy_sched_event */
-
+       info->event |= 1 << event;      /* remember what kind of event and who */
+       schedule_work(&info->tqueue);
+}                              /* cy_sched_event */
 
 /* The real interrupt service routines are called
    whenever the card wants its hand held--chars
    received, out buffer empty, modem change, etc.
  */
-static irqreturn_t
-cd2401_rxerr_interrupt(int irq, void *dev_id)
+static irqreturn_t cd2401_rxerr_interrupt(int irq, void *dev_id)
 {
-    struct tty_struct *tty;
-    struct cyclades_port *info;
-    volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
-    unsigned char err, rfoc;
-    int channel;
-    char data;
-
-    /* determine the channel and change to that context */
-    channel = (u_short ) (base_addr[CyLICR] >> 2);
-    info = &cy_port[channel];
-    info->last_active = jiffies;
-
-    if ((err = base_addr[CyRISR]) & CyTIMEOUT) {
-       /* This is a receive timeout interrupt, ignore it */
-       base_addr[CyREOIR] = CyNOTRANS;
-       return IRQ_HANDLED;
-    }
-
-    /* Read a byte of data if there is any - assume the error
-     * is associated with this character */
+       struct tty_struct *tty;
+       struct cyclades_port *info;
+       volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
+       unsigned char err, rfoc;
+       int channel;
+       char data;
+
+       /* determine the channel and change to that context */
+       channel = (u_short) (base_addr[CyLICR] >> 2);
+       info = &cy_port[channel];
+       info->last_active = jiffies;
+
+       if ((err = base_addr[CyRISR]) & CyTIMEOUT) {
+               /* This is a receive timeout interrupt, ignore it */
+               base_addr[CyREOIR] = CyNOTRANS;
+               return IRQ_HANDLED;
+       }
 
-    if ((rfoc = base_addr[CyRFOC]) != 0)
-       data = base_addr[CyRDR];
-    else
-       data = 0;
+       /* Read a byte of data if there is any - assume the error
+        * is associated with this character */
 
-    /* if there is nowhere to put the data, discard it */
-    if(info->tty == 0) {
+       if ((rfoc = base_addr[CyRFOC]) != 0)
+               data = base_addr[CyRDR];
+       else
+               data = 0;
+
+       /* if there is nowhere to put the data, discard it */
+       if (info->tty == 0) {
+               base_addr[CyREOIR] = rfoc ? 0 : CyNOTRANS;
+               return IRQ_HANDLED;
+       } else {                /* there is an open port for this data */
+               tty = info->tty;
+               if (err & info->ignore_status_mask) {
+                       base_addr[CyREOIR] = rfoc ? 0 : CyNOTRANS;
+                       return IRQ_HANDLED;
+               }
+               if (tty_buffer_request_room(tty, 1) != 0) {
+                       if (err & info->read_status_mask) {
+                               if (err & CyBREAK) {
+                                       tty_insert_flip_char(tty, data,
+                                                            TTY_BREAK);
+                                       if (info->flags & ASYNC_SAK) {
+                                               do_SAK(tty);
+                                       }
+                               } else if (err & CyFRAME) {
+                                       tty_insert_flip_char(tty, data,
+                                                            TTY_FRAME);
+                               } else if (err & CyPARITY) {
+                                       tty_insert_flip_char(tty, data,
+                                                            TTY_PARITY);
+                               } else if (err & CyOVERRUN) {
+                                       tty_insert_flip_char(tty, 0,
+                                                            TTY_OVERRUN);
+                                       /*
+                                          If the flip buffer itself is
+                                          overflowing, we still loose
+                                          the next incoming character.
+                                        */
+                                       if (tty_buffer_request_room(tty, 1) !=
+                                           0) {
+                                               tty_insert_flip_char(tty, data,
+                                                                    TTY_FRAME);
+                                       }
+                                       /* These two conditions may imply */
+                                       /* a normal read should be done. */
+                                       /* else if(data & CyTIMEOUT) */
+                                       /* else if(data & CySPECHAR) */
+                               } else {
+                                       tty_insert_flip_char(tty, 0,
+                                                            TTY_NORMAL);
+                               }
+                       } else {
+                               tty_insert_flip_char(tty, data, TTY_NORMAL);
+                       }
+               } else {
+                       /* there was a software buffer overrun
+                          and nothing could be done about it!!! */
+               }
+       }
+       tty_schedule_flip(tty);
+       /* end of service */
        base_addr[CyREOIR] = rfoc ? 0 : CyNOTRANS;
        return IRQ_HANDLED;
-    }
-    else { /* there is an open port for this data */
-       tty = info->tty;
-       if(err & info->ignore_status_mask){
-           base_addr[CyREOIR] = rfoc ? 0 : CyNOTRANS;
-           return IRQ_HANDLED;
-       }
-       if (tty_buffer_request_room(tty, 1) != 0){
-           if (err & info->read_status_mask){
-               if(err & CyBREAK){
-                   tty_insert_flip_char(tty, data, TTY_BREAK);
-                   if (info->flags & ASYNC_SAK){
-                       do_SAK(tty);
-                   }
-               }else if(err & CyFRAME){
-                   tty_insert_flip_char(tty, data, TTY_FRAME);
-               }else if(err & CyPARITY){
-                   tty_insert_flip_char(tty, data, TTY_PARITY);
-               }else if(err & CyOVERRUN){
-                   tty_insert_flip_char(tty, 0, TTY_OVERRUN);
-                   /*
-                      If the flip buffer itself is
-                      overflowing, we still loose
-                      the next incoming character.
-                    */
-                   if (tty_buffer_request_room(tty, 1) != 0){
-                       tty_insert_flip_char(tty, data, TTY_FRAME);
-                   }
-               /* These two conditions may imply */
-               /* a normal read should be done. */
-               /* else if(data & CyTIMEOUT) */
-               /* else if(data & CySPECHAR) */
-               }else{
-                   tty_insert_flip_char(tty, 0, TTY_NORMAL);
-               }
-           }else{
-               tty_insert_flip_char(tty, data, TTY_NORMAL);
-           }
-       }else{
-           /* there was a software buffer overrun
-              and nothing could be done about it!!! */
-       }
-    }
-    tty_schedule_flip(tty);
-    /* end of service */
-    base_addr[CyREOIR] = rfoc ? 0 : CyNOTRANS;
-    return IRQ_HANDLED;
-} /* cy_rxerr_interrupt */
-
-static irqreturn_t
-cd2401_modem_interrupt(int irq, void *dev_id)
+}                              /* cy_rxerr_interrupt */
+
+static irqreturn_t cd2401_modem_interrupt(int irq, void *dev_id)
 {
-    struct cyclades_port *info;
-    volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
-    int channel;
-    int mdm_change;
-    int mdm_status;
-
-
-    /* determine the channel and change to that context */
-    channel = (u_short ) (base_addr[CyLICR] >> 2);
-    info = &cy_port[channel];
-    info->last_active = jiffies;
-
-    mdm_change = base_addr[CyMISR];
-    mdm_status = base_addr[CyMSVR1];
-
-    if(info->tty == 0){ /* nowhere to put the data, ignore it */
-       ;
-    }else{
-       if((mdm_change & CyDCD)
-       && (info->flags & ASYNC_CHECK_CD)){
-           if(mdm_status & CyDCD){
+       struct cyclades_port *info;
+       volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
+       int channel;
+       int mdm_change;
+       int mdm_status;
+
+       /* determine the channel and change to that context */
+       channel = (u_short) (base_addr[CyLICR] >> 2);
+       info = &cy_port[channel];
+       info->last_active = jiffies;
+
+       mdm_change = base_addr[CyMISR];
+       mdm_status = base_addr[CyMSVR1];
+
+       if (info->tty == 0) {   /* nowhere to put the data, ignore it */
+               ;
+       } else {
+               if ((mdm_change & CyDCD)
+                   && (info->flags & ASYNC_CHECK_CD)) {
+                       if (mdm_status & CyDCD) {
 /* CP('!'); */
-               cy_sched_event(info, Cy_EVENT_OPEN_WAKEUP);
-           } else {
+                               cy_sched_event(info, Cy_EVENT_OPEN_WAKEUP);
+                       } else {
 /* CP('@'); */
-               cy_sched_event(info, Cy_EVENT_HANGUP);
-           }
-       }
-       if((mdm_change & CyCTS)
-       && (info->flags & ASYNC_CTS_FLOW)){
-           if(info->tty->stopped){
-               if(mdm_status & CyCTS){
-                   /* !!! cy_start isn't used because... */
-                   info->tty->stopped = 0;
-                   base_addr[CyIER] |= CyTxMpty;
-                   cy_sched_event(info, Cy_EVENT_WRITE_WAKEUP);
+                               cy_sched_event(info, Cy_EVENT_HANGUP);
+                       }
                }
-           }else{
-               if(!(mdm_status & CyCTS)){
-                   /* !!! cy_stop isn't used because... */
-                   info->tty->stopped = 1;
-                   base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy);
+               if ((mdm_change & CyCTS)
+                   && (info->flags & ASYNC_CTS_FLOW)) {
+                       if (info->tty->stopped) {
+                               if (mdm_status & CyCTS) {
+                                       /* !!! cy_start isn't used because... */
+                                       info->tty->stopped = 0;
+                                       base_addr[CyIER] |= CyTxMpty;
+                                       cy_sched_event(info,
+                                                      Cy_EVENT_WRITE_WAKEUP);
+                               }
+                       } else {
+                               if (!(mdm_status & CyCTS)) {
+                                       /* !!! cy_stop isn't used because... */
+                                       info->tty->stopped = 1;
+                                       base_addr[CyIER] &=
+                                           ~(CyTxMpty | CyTxRdy);
+                               }
+                       }
+               }
+               if (mdm_status & CyDSR) {
                }
-           }
-       }
-       if(mdm_status & CyDSR){
        }
-    }
-    base_addr[CyMEOIR] = 0;
-    return IRQ_HANDLED;
-} /* cy_modem_interrupt */
+       base_addr[CyMEOIR] = 0;
+       return IRQ_HANDLED;
+}                              /* cy_modem_interrupt */
 
-static irqreturn_t
-cd2401_tx_interrupt(int irq, void *dev_id)
+static irqreturn_t cd2401_tx_interrupt(int irq, void *dev_id)
 {
-    struct cyclades_port *info;
-    volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
-    int channel;
-    int char_count, saved_cnt;
-    int outch;
+       struct cyclades_port *info;
+       volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
+       int channel;
+       int char_count, saved_cnt;
+       int outch;
 
-    /* determine the channel and change to that context */
-    channel = (u_short ) (base_addr[CyLICR] >> 2);
+       /* determine the channel and change to that context */
+       channel = (u_short) (base_addr[CyLICR] >> 2);
 
 #ifdef CONFIG_REMOTE_DEBUG
-    if (channel == DEBUG_PORT) {
-       panic ("TxInt on debug port!!!");
-    }
+       if (channel == DEBUG_PORT) {
+               panic("TxInt on debug port!!!");
+       }
 #endif
 
-    info = &cy_port[channel];
+       info = &cy_port[channel];
 
-    /* validate the port number (as configured and open) */
-    if( (channel < 0) || (NR_PORTS <= channel) ){
-       base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy);
-       base_addr[CyTEOIR] = CyNOTRANS;
-       return IRQ_HANDLED;
-    }
-    info->last_active = jiffies;
-    if(info->tty == 0){
-       base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy);
-        if (info->xmit_cnt < WAKEUP_CHARS) {
-           cy_sched_event(info, Cy_EVENT_WRITE_WAKEUP);
-        }
-       base_addr[CyTEOIR] = CyNOTRANS;
-       return IRQ_HANDLED;
-    }
-
-    /* load the on-chip space available for outbound data */
-    saved_cnt = char_count = base_addr[CyTFTC];
-
-    if(info->x_char) { /* send special char */
-       outch = info->x_char;
-       base_addr[CyTDR] = outch;
-       char_count--;
-       info->x_char = 0;
-    }
-
-    if (info->x_break){
-       /*  The Cirrus chip requires the "Embedded Transmit
-           Commands" of start break, delay, and end break
-           sequences to be sent.  The duration of the
-           break is given in TICs, which runs at HZ
-           (typically 100) and the PPR runs at 200 Hz,
-           so the delay is duration * 200/HZ, and thus a
-           break can run from 1/100 sec to about 5/4 sec.
-           Need to check these values - RGH 141095.
-        */
-       base_addr[CyTDR] = 0; /* start break */
-       base_addr[CyTDR] = 0x81;
-       base_addr[CyTDR] = 0; /* delay a bit */
-       base_addr[CyTDR] = 0x82;
-       base_addr[CyTDR] = info->x_break*200/HZ;
-       base_addr[CyTDR] = 0; /* terminate break */
-       base_addr[CyTDR] = 0x83;
-       char_count -= 7;
-       info->x_break = 0;
-    }
-
-    while (char_count > 0){
-       if (!info->xmit_cnt){
-           base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy);
-           break;
-       }
-       if (info->xmit_buf == 0){
-           base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy);
-           break;
-       }
-       if (info->tty->stopped || info->tty->hw_stopped){
-           base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy);
-           break;
-       }
-       /* Because the Embedded Transmit Commands have been
-          enabled, we must check to see if the escape
-          character, NULL, is being sent.  If it is, we
-          must ensure that there is room for it to be
-          doubled in the output stream.  Therefore we
-          no longer advance the pointer when the character
-          is fetched, but rather wait until after the check
-          for a NULL output character. (This is necessary
-          because there may not be room for the two chars
-          needed to send a NULL.
-        */
-       outch = info->xmit_buf[info->xmit_tail];
-       if( outch ){
-           info->xmit_cnt--;
-           info->xmit_tail = (info->xmit_tail + 1)
-                                     & (PAGE_SIZE - 1);
-           base_addr[CyTDR] = outch;
-           char_count--;
-       }else{
-           if(char_count > 1){
-               info->xmit_cnt--;
-               info->xmit_tail = (info->xmit_tail + 1)
-                                         & (PAGE_SIZE - 1);
+       /* validate the port number (as configured and open) */
+       if ((channel < 0) || (NR_PORTS <= channel)) {
+               base_addr[CyIER] &= ~(CyTxMpty | CyTxRdy);
+               base_addr[CyTEOIR] = CyNOTRANS;
+               return IRQ_HANDLED;
+       }
+       info->last_active = jiffies;
+       if (info->tty == 0) {
+               base_addr[CyIER] &= ~(CyTxMpty | CyTxRdy);
+               if (info->xmit_cnt < WAKEUP_CHARS) {
+                       cy_sched_event(info, Cy_EVENT_WRITE_WAKEUP);
+               }
+               base_addr[CyTEOIR] = CyNOTRANS;
+               return IRQ_HANDLED;
+       }
+
+       /* load the on-chip space available for outbound data */
+       saved_cnt = char_count = base_addr[CyTFTC];
+
+       if (info->x_char) {     /* send special char */
+               outch = info->x_char;
                base_addr[CyTDR] = outch;
-               base_addr[CyTDR] = 0;
                char_count--;
-               char_count--;
-           }else{
-               break;
-           }
+               info->x_char = 0;
        }
-    }
 
-    if (info->xmit_cnt < WAKEUP_CHARS) {
-       cy_sched_event(info, Cy_EVENT_WRITE_WAKEUP);
-    }
-    base_addr[CyTEOIR] = (char_count != saved_cnt) ? 0 : CyNOTRANS;
-    return IRQ_HANDLED;
-} /* cy_tx_interrupt */
+       if (info->x_break) {
+               /*  The Cirrus chip requires the "Embedded Transmit
+                  Commands" of start break, delay, and end break
+                  sequences to be sent.  The duration of the
+                  break is given in TICs, which runs at HZ
+                  (typically 100) and the PPR runs at 200 Hz,
+                  so the delay is duration * 200/HZ, and thus a
+                  break can run from 1/100 sec to about 5/4 sec.
+                  Need to check these values - RGH 141095.
+                */
+               base_addr[CyTDR] = 0;   /* start break */
+               base_addr[CyTDR] = 0x81;
+               base_addr[CyTDR] = 0;   /* delay a bit */
+               base_addr[CyTDR] = 0x82;
+               base_addr[CyTDR] = info->x_break * 200 / HZ;
+               base_addr[CyTDR] = 0;   /* terminate break */
+               base_addr[CyTDR] = 0x83;
+               char_count -= 7;
+               info->x_break = 0;
+       }
+
+       while (char_count > 0) {
+               if (!info->xmit_cnt) {
+                       base_addr[CyIER] &= ~(CyTxMpty | CyTxRdy);
+                       break;
+               }
+               if (info->xmit_buf == 0) {
+                       base_addr[CyIER] &= ~(CyTxMpty | CyTxRdy);
+                       break;
+               }
+               if (info->tty->stopped || info->tty->hw_stopped) {
+                       base_addr[CyIER] &= ~(CyTxMpty | CyTxRdy);
+                       break;
+               }
+               /* Because the Embedded Transmit Commands have been
+                  enabled, we must check to see if the escape
+                  character, NULL, is being sent.  If it is, we
+                  must ensure that there is room for it to be
+                  doubled in the output stream.  Therefore we
+                  no longer advance the pointer when the character
+                  is fetched, but rather wait until after the check
+                  for a NULL output character. (This is necessary
+                  because there may not be room for the two chars
+                  needed to send a NULL.
+                */
+               outch = info->xmit_buf[info->xmit_tail];
+               if (outch) {
+                       info->xmit_cnt--;
+                       info->xmit_tail = (info->xmit_tail + 1)
+                           & (PAGE_SIZE - 1);
+                       base_addr[CyTDR] = outch;
+                       char_count--;
+               } else {
+                       if (char_count > 1) {
+                               info->xmit_cnt--;
+                               info->xmit_tail = (info->xmit_tail + 1)
+                                   & (PAGE_SIZE - 1);
+                               base_addr[CyTDR] = outch;
+                               base_addr[CyTDR] = 0;
+                               char_count--;
+                               char_count--;
+                       } else {
+                               break;
+                       }
+               }
+       }
+
+       if (info->xmit_cnt < WAKEUP_CHARS) {
+               cy_sched_event(info, Cy_EVENT_WRITE_WAKEUP);
+       }
+       base_addr[CyTEOIR] = (char_count != saved_cnt) ? 0 : CyNOTRANS;
+       return IRQ_HANDLED;
+}                              /* cy_tx_interrupt */
 
-static irqreturn_t
-cd2401_rx_interrupt(int irq, void *dev_id)
+static irqreturn_t cd2401_rx_interrupt(int irq, void *dev_id)
 {
-    struct tty_struct *tty;
-    struct cyclades_port *info;
-    volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
-    int channel;
-    char data;
-    int char_count;
-    int save_cnt;
-    int len;
-
-    /* determine the channel and change to that context */
-    channel = (u_short ) (base_addr[CyLICR] >> 2);
-    info = &cy_port[channel];
-    info->last_active = jiffies;
-    save_cnt = char_count = base_addr[CyRFOC];
+       struct tty_struct *tty;
+       struct cyclades_port *info;
+       volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
+       int channel;
+       char data;
+       int char_count;
+       int save_cnt;
+       int len;
+
+       /* determine the channel and change to that context */
+       channel = (u_short) (base_addr[CyLICR] >> 2);
+       info = &cy_port[channel];
+       info->last_active = jiffies;
+       save_cnt = char_count = base_addr[CyRFOC];
 
 #ifdef CONFIG_REMOTE_DEBUG
-    if (channel == DEBUG_PORT) {
-       while (char_count--) {
-            data = base_addr[CyRDR];
-           queueDebugChar(data);
-       }
-    }
-    else
+       if (channel == DEBUG_PORT) {
+               while (char_count--) {
+                       data = base_addr[CyRDR];
+                       queueDebugChar(data);
+               }
+       } else
 #endif
-    /* if there is nowhere to put the data, discard it */
-    if(info->tty == 0){
-       while(char_count--){
-           data = base_addr[CyRDR];
-       }
-    }else{ /* there is an open port for this data */
-       tty = info->tty;
-       /* load # characters available from the chip */
+               /* if there is nowhere to put the data, discard it */
+       if (info->tty == 0) {
+               while (char_count--) {
+                       data = base_addr[CyRDR];
+               }
+       } else {                /* there is an open port for this data */
+               tty = info->tty;
+               /* load # characters available from the chip */
 
 #ifdef CYCLOM_ENABLE_MONITORING
-       ++info->mon.int_count;
-       info->mon.char_count += char_count;
-       if (char_count > info->mon.char_max)
-           info->mon.char_max = char_count;
-       info->mon.char_last = char_count;
-#endif
-       len = tty_buffer_request_room(tty, char_count);
-       while(len--){
-           data = base_addr[CyRDR];
-           tty_insert_flip_char(tty, data, TTY_NORMAL);
+               ++info->mon.int_count;
+               info->mon.char_count += char_count;
+               if (char_count > info->mon.char_max)
+                       info->mon.char_max = char_count;
+               info->mon.char_last = char_count;
+#endif
+               len = tty_buffer_request_room(tty, char_count);
+               while (len--) {
+                       data = base_addr[CyRDR];
+                       tty_insert_flip_char(tty, data, TTY_NORMAL);
 #ifdef CYCLOM_16Y_HACK
-           udelay(10L);
+                       udelay(10L);
 #endif
-        }
-       tty_schedule_flip(tty);
-    }
-    /* end of service */
-    base_addr[CyREOIR] = save_cnt ? 0 : CyNOTRANS;
-    return IRQ_HANDLED;
-} /* cy_rx_interrupt */
+               }
+               tty_schedule_flip(tty);
+       }
+       /* end of service */
+       base_addr[CyREOIR] = save_cnt ? 0 : CyNOTRANS;
+       return IRQ_HANDLED;
+}                              /* cy_rx_interrupt */
 
 /*
  * This routine is used to handle the "bottom half" processing for the
@@ -705,192 +712,188 @@ cd2401_rx_interrupt(int irq, void *dev_id)
  * structure) to the bottom half of the driver.  Previous kernels
  * had to poll every port to see if that port needed servicing.
  */
-static void
-do_softint(struct work_struct *ugly_api)
+static void do_softint(struct work_struct *ugly_api)
 {
-  struct cyclades_port *info = container_of(ugly_api, struct cyclades_port, tqueue);
-  struct tty_struct    *tty;
-
-    tty = info->tty;
-    if (!tty)
-       return;
+       struct cyclades_port *info =
+           container_of(ugly_api, struct cyclades_port, tqueue);
+       struct tty_struct *tty;
 
-    if (test_and_clear_bit(Cy_EVENT_HANGUP, &info->event)) {
-       tty_hangup(info->tty);
-       wake_up_interruptible(&info->open_wait);
-       info->flags &= ~ASYNC_NORMAL_ACTIVE;
-    }
-    if (test_and_clear_bit(Cy_EVENT_OPEN_WAKEUP, &info->event)) {
-       wake_up_interruptible(&info->open_wait);
-    }
-    if (test_and_clear_bit(Cy_EVENT_WRITE_WAKEUP, &info->event)) {
-       tty_wakeup(tty);
-    }
-} /* do_softint */
+       tty = info->tty;
+       if (!tty)
+               return;
 
+       if (test_and_clear_bit(Cy_EVENT_HANGUP, &info->event)) {
+               tty_hangup(info->tty);
+               wake_up_interruptible(&info->open_wait);
+               info->flags &= ~ASYNC_NORMAL_ACTIVE;
+       }
+       if (test_and_clear_bit(Cy_EVENT_OPEN_WAKEUP, &info->event)) {
+               wake_up_interruptible(&info->open_wait);
+       }
+       if (test_and_clear_bit(Cy_EVENT_WRITE_WAKEUP, &info->event)) {
+               tty_wakeup(tty);
+       }
+}                              /* do_softint */
 
 /* This is called whenever a port becomes active;
    interrupts are enabled and DTR & RTS are turned on.
  */
-static int
-startup(struct cyclades_port * info)
+static int startup(struct cyclades_port *info)
 {
-  unsigned long flags;
-  volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
-  int channel;
+       unsigned long flags;
+       volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
+       int channel;
 
-    if (info->flags & ASYNC_INITIALIZED){
-       return 0;
-    }
+       if (info->flags & ASYNC_INITIALIZED) {
+               return 0;
+       }
 
-    if (!info->type){
-       if (info->tty){
-           set_bit(TTY_IO_ERROR, &info->tty->flags);
+       if (!info->type) {
+               if (info->tty) {
+                       set_bit(TTY_IO_ERROR, &info->tty->flags);
+               }
+               return 0;
        }
-       return 0;
-    }
-    if (!info->xmit_buf){
-       info->xmit_buf = (unsigned char *) get_zeroed_page (GFP_KERNEL);
-       if (!info->xmit_buf){
-           return -ENOMEM;
+       if (!info->xmit_buf) {
+               info->xmit_buf = (unsigned char *)get_zeroed_page(GFP_KERNEL);
+               if (!info->xmit_buf) {
+                       return -ENOMEM;
+               }
        }
-    }
 
-    config_setup(info);
+       config_setup(info);
 
-    channel = info->line;
+       channel = info->line;
 
 #ifdef SERIAL_DEBUG_OPEN
-    printk("startup channel %d\n", channel);
+       printk("startup channel %d\n", channel);
 #endif
 
-    local_irq_save(flags);
-       base_addr[CyCAR] = (u_char)channel;
-       write_cy_cmd(base_addr,CyENB_RCVR|CyENB_XMTR);
+       local_irq_save(flags);
+       base_addr[CyCAR] = (u_char) channel;
+       write_cy_cmd(base_addr, CyENB_RCVR | CyENB_XMTR);
 
-       base_addr[CyCAR] = (u_char)channel; /* !!! Is this needed? */
+       base_addr[CyCAR] = (u_char) channel;    /* !!! Is this needed? */
        base_addr[CyMSVR1] = CyRTS;
 /* CP('S');CP('1'); */
        base_addr[CyMSVR2] = CyDTR;
 
 #ifdef SERIAL_DEBUG_DTR
-        printk("cyc: %d: raising DTR\n", __LINE__);
-        printk("     status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]);
+       printk("cyc: %d: raising DTR\n", __LINE__);
+       printk("     status: 0x%x, 0x%x\n", base_addr[CyMSVR1],
+              base_addr[CyMSVR2]);
 #endif
 
        base_addr[CyIER] |= CyRxData;
        info->flags |= ASYNC_INITIALIZED;
 
-       if (info->tty){
-           clear_bit(TTY_IO_ERROR, &info->tty->flags);
+       if (info->tty) {
+               clear_bit(TTY_IO_ERROR, &info->tty->flags);
        }
        info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
 
-    local_irq_restore(flags);
+       local_irq_restore(flags);
 
 #ifdef SERIAL_DEBUG_OPEN
-    printk(" done\n");
+       printk(" done\n");
 #endif
-    return 0;
-} /* startup */
+       return 0;
+}                              /* startup */
 
-void
-start_xmit( struct cyclades_port *info )
+void start_xmit(struct cyclades_port *info)
 {
-  unsigned long flags;
-  volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
-  int channel;
+       unsigned long flags;
+       volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
+       int channel;
 
-    channel = info->line;
-    local_irq_save(flags);
+       channel = info->line;
+       local_irq_save(flags);
        base_addr[CyCAR] = channel;
        base_addr[CyIER] |= CyTxMpty;
-    local_irq_restore(flags);
-} /* start_xmit */
+       local_irq_restore(flags);
+}                              /* start_xmit */
 
 /*
  * This routine shuts down a serial port; interrupts are disabled,
  * and DTR is dropped if the hangup on close termio flag is on.
  */
-static void
-shutdown(struct cyclades_port * info)
+static void shutdown(struct cyclades_port *info)
 {
-  unsigned long flags;
-  volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
-  int channel;
+       unsigned long flags;
+       volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
+       int channel;
 
-    if (!(info->flags & ASYNC_INITIALIZED)){
+       if (!(info->flags & ASYNC_INITIALIZED)) {
 /* CP('$'); */
-       return;
-    }
+               return;
+       }
 
-    channel = info->line;
+       channel = info->line;
 
 #ifdef SERIAL_DEBUG_OPEN
-    printk("shutdown channel %d\n", channel);
+       printk("shutdown channel %d\n", channel);
 #endif
 
-    /* !!! REALLY MUST WAIT FOR LAST CHARACTER TO BE
-       SENT BEFORE DROPPING THE LINE !!!  (Perhaps
-       set some flag that is read when XMTY happens.)
-       Other choices are to delay some fixed interval
-       or schedule some later processing.
-     */
-    local_irq_save(flags);
-       if (info->xmit_buf){
-           free_page((unsigned long) info->xmit_buf);
-           info->xmit_buf = NULL;
+       /* !!! REALLY MUST WAIT FOR LAST CHARACTER TO BE
+          SENT BEFORE DROPPING THE LINE !!!  (Perhaps
+          set some flag that is read when XMTY happens.)
+          Other choices are to delay some fixed interval
+          or schedule some later processing.
+        */
+       local_irq_save(flags);
+       if (info->xmit_buf) {
+               free_page((unsigned long)info->xmit_buf);
+               info->xmit_buf = NULL;
        }
 
-       base_addr[CyCAR] = (u_char)channel;
+       base_addr[CyCAR] = (u_char) channel;
        if (!info->tty || (info->tty->termios->c_cflag & HUPCL)) {
-           base_addr[CyMSVR1] = 0;
+               base_addr[CyMSVR1] = 0;
 /* CP('C');CP('1'); */
-           base_addr[CyMSVR2] = 0;
+               base_addr[CyMSVR2] = 0;
 #ifdef SERIAL_DEBUG_DTR
-            printk("cyc: %d: dropping DTR\n", __LINE__);
-            printk("     status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]);
+               printk("cyc: %d: dropping DTR\n", __LINE__);
+               printk("     status: 0x%x, 0x%x\n", base_addr[CyMSVR1],
+                      base_addr[CyMSVR2]);
 #endif
-        }
-       write_cy_cmd(base_addr,CyDIS_RCVR);
-         /* it may be appropriate to clear _XMIT at
-           some later date (after testing)!!! */
+       }
+       write_cy_cmd(base_addr, CyDIS_RCVR);
+       /* it may be appropriate to clear _XMIT at
+          some later date (after testing)!!! */
 
-       if (info->tty){
-           set_bit(TTY_IO_ERROR, &info->tty->flags);
+       if (info->tty) {
+               set_bit(TTY_IO_ERROR, &info->tty->flags);
        }
        info->flags &= ~ASYNC_INITIALIZED;
-    local_irq_restore(flags);
+       local_irq_restore(flags);
 
 #ifdef SERIAL_DEBUG_OPEN
-    printk(" done\n");
+       printk(" done\n");
 #endif
-    return;
-} /* shutdown */
+}                              /* shutdown */
 
 /*
  * This routine finds or computes the various line characteristics.
  */
-static void
-config_setup(struct cyclades_port * info)
+static void config_setup(struct cyclades_port *info)
 {
-  unsigned long flags;
-  volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
-  int channel;
-  unsigned cflag;
-  int   i;
-  unsigned char ti, need_init_chan = 0;
-
-    if (!info->tty || !info->tty->termios){
-        return;
-    }
-    if (info->line == -1){
-        return;
-    }
-    cflag = info->tty->termios->c_cflag;
-
-    /* baud rate */
-    i = cflag & CBAUD;
+       unsigned long flags;
+       volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
+       int channel;
+       unsigned cflag;
+       int i;
+       unsigned char ti, need_init_chan = 0;
+
+       if (!info->tty || !info->tty->termios) {
+               return;
+       }
+       if (info->line == -1) {
+               return;
+       }
+       cflag = info->tty->termios->c_cflag;
+
+       /* baud rate */
+       i = cflag & CBAUD;
 #ifdef CBAUDEX
 /* Starting with kernel 1.1.65, there is direct support for
    higher baud rates.  The following code supports those
@@ -900,120 +903,123 @@ config_setup(struct cyclades_port * info)
    is still the possibility of supporting 75 kbit/sec with
    the Cyclades board.)
  */
-    if (i & CBAUDEX) {
-       if (i == B57600)
-           i = 16;
-       else if(i == B115200) 
-           i = 18;
+       if (i & CBAUDEX) {
+               if (i == B57600)
+                       i = 16;
+               else if (i == B115200)
+                       i = 18;
 #ifdef B78600
-       else if(i == B78600) 
-           i = 17;
+               else if (i == B78600)
+                       i = 17;
 #endif
-       else
-           info->tty->termios->c_cflag &= ~CBAUDEX;
-    }
-#endif
-    if (i == 15) {
-           if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
-                   i += 1;
-           if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
-                   i += 3;
-    }
-    /* Don't ever change the speed of the console port.  It will
-     * run at the speed specified in bootinfo, or at 19.2K */
-    /* Actually, it should run at whatever speed 166Bug was using */
-    /* Note info->timeout isn't used at present */
-    if (info != serial_console_info) {
-       info->tbpr = baud_bpr[i]; /* Tx BPR */
-       info->tco = baud_co[i]; /* Tx CO */
-       info->rbpr = baud_bpr[i]; /* Rx BPR */
-       info->rco = baud_co[i] >> 5; /* Rx CO */
-       if (baud_table[i] == 134) {
-            info->timeout = (info->xmit_fifo_size*HZ*30/269) + 2;
-            /* get it right for 134.5 baud */
-       } else if (baud_table[i]) {
-            info->timeout = (info->xmit_fifo_size*HZ*15/baud_table[i]) + 2;
-        /* this needs to be propagated into the card info */
+               else
+                       info->tty->termios->c_cflag &= ~CBAUDEX;
+       }
+#endif
+       if (i == 15) {
+               if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
+                       i += 1;
+               if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
+                       i += 3;
+       }
+       /* Don't ever change the speed of the console port.  It will
+        * run at the speed specified in bootinfo, or at 19.2K */
+       /* Actually, it should run at whatever speed 166Bug was using */
+       /* Note info->timeout isn't used at present */
+       if (info != serial_console_info) {
+               info->tbpr = baud_bpr[i];       /* Tx BPR */
+               info->tco = baud_co[i]; /* Tx CO */
+               info->rbpr = baud_bpr[i];       /* Rx BPR */
+               info->rco = baud_co[i] >> 5;    /* Rx CO */
+               if (baud_table[i] == 134) {
+                       info->timeout =
+                           (info->xmit_fifo_size * HZ * 30 / 269) + 2;
+                       /* get it right for 134.5 baud */
+               } else if (baud_table[i]) {
+                       info->timeout =
+                           (info->xmit_fifo_size * HZ * 15 / baud_table[i]) +
+                           2;
+                       /* this needs to be propagated into the card info */
+               } else {
+                       info->timeout = 0;
+               }
+       }
+       /* By tradition (is it a standard?) a baud rate of zero
+          implies the line should be/has been closed.  A bit
+          later in this routine such a test is performed. */
+
+       /* byte size and parity */
+       info->cor7 = 0;
+       info->cor6 = 0;
+       info->cor5 = 0;
+       info->cor4 = (info->default_threshold ? info->default_threshold : baud_cor4[i]);        /* receive threshold */
+       /* Following two lines added 101295, RGH. */
+       /* It is obviously wrong to access CyCORx, and not info->corx here,
+        * try and remember to fix it later! */
+       channel = info->line;
+       base_addr[CyCAR] = (u_char) channel;
+       if (C_CLOCAL(info->tty)) {
+               if (base_addr[CyIER] & CyMdmCh)
+                       base_addr[CyIER] &= ~CyMdmCh;   /* without modem intr */
+               /* ignore 1->0 modem transitions */
+               if (base_addr[CyCOR4] & (CyDSR | CyCTS | CyDCD))
+                       base_addr[CyCOR4] &= ~(CyDSR | CyCTS | CyDCD);
+               /* ignore 0->1 modem transitions */
+               if (base_addr[CyCOR5] & (CyDSR | CyCTS | CyDCD))
+                       base_addr[CyCOR5] &= ~(CyDSR | CyCTS | CyDCD);
        } else {
-            info->timeout = 0;
-       }
-    }
-    /* By tradition (is it a standard?) a baud rate of zero
-       implies the line should be/has been closed.  A bit
-       later in this routine such a test is performed. */
-
-    /* byte size and parity */
-    info->cor7 = 0;
-    info->cor6 = 0;
-    info->cor5 = 0;
-    info->cor4 = (info->default_threshold
-                 ? info->default_threshold
-                 : baud_cor4[i]); /* receive threshold */
-    /* Following two lines added 101295, RGH. */
-    /* It is obviously wrong to access CyCORx, and not info->corx here,
-     * try and remember to fix it later! */
-    channel = info->line;
-    base_addr[CyCAR] = (u_char)channel;
-    if (C_CLOCAL(info->tty)) {
-       if (base_addr[CyIER] & CyMdmCh)
-           base_addr[CyIER] &= ~CyMdmCh; /* without modem intr */
-                              /* ignore 1->0 modem transitions */
-       if (base_addr[CyCOR4] & (CyDSR|CyCTS|CyDCD))
-           base_addr[CyCOR4] &= ~(CyDSR|CyCTS|CyDCD);
-                              /* ignore 0->1 modem transitions */
-       if (base_addr[CyCOR5] & (CyDSR|CyCTS|CyDCD))
-           base_addr[CyCOR5] &= ~(CyDSR|CyCTS|CyDCD);
-    } else {
-       if ((base_addr[CyIER] & CyMdmCh) != CyMdmCh)
-           base_addr[CyIER] |= CyMdmCh; /* with modem intr */
-                              /* act on 1->0 modem transitions */
-       if ((base_addr[CyCOR4] & (CyDSR|CyCTS|CyDCD)) != (CyDSR|CyCTS|CyDCD))
-           base_addr[CyCOR4] |= CyDSR|CyCTS|CyDCD;
-                              /* act on 0->1 modem transitions */
-       if ((base_addr[CyCOR5] & (CyDSR|CyCTS|CyDCD)) != (CyDSR|CyCTS|CyDCD))
-           base_addr[CyCOR5] |= CyDSR|CyCTS|CyDCD;
-    }
-    info->cor3 = (cflag & CSTOPB) ? Cy_2_STOP : Cy_1_STOP;
-    info->cor2 = CyETC;
-    switch(cflag & CSIZE){
-    case CS5:
-        info->cor1 = Cy_5_BITS;
-        break;
-    case CS6:
-        info->cor1 = Cy_6_BITS;
-        break;
-    case CS7:
-        info->cor1 = Cy_7_BITS;
-        break;
-    case CS8:
-        info->cor1 = Cy_8_BITS;
-        break;
-    }
-    if (cflag & PARENB){
-        if (cflag & PARODD){
-            info->cor1 |= CyPARITY_O;
-        }else{
-            info->cor1 |= CyPARITY_E;
-        }
-    }else{
-        info->cor1 |= CyPARITY_NONE;
-    }
-       
-    /* CTS flow control flag */
+               if ((base_addr[CyIER] & CyMdmCh) != CyMdmCh)
+                       base_addr[CyIER] |= CyMdmCh;    /* with modem intr */
+               /* act on 1->0 modem transitions */
+               if ((base_addr[CyCOR4] & (CyDSR | CyCTS | CyDCD)) !=
+                   (CyDSR | CyCTS | CyDCD))
+                       base_addr[CyCOR4] |= CyDSR | CyCTS | CyDCD;
+               /* act on 0->1 modem transitions */
+               if ((base_addr[CyCOR5] & (CyDSR | CyCTS | CyDCD)) !=
+                   (CyDSR | CyCTS | CyDCD))
+                       base_addr[CyCOR5] |= CyDSR | CyCTS | CyDCD;
+       }
+       info->cor3 = (cflag & CSTOPB) ? Cy_2_STOP : Cy_1_STOP;
+       info->cor2 = CyETC;
+       switch (cflag & CSIZE) {
+       case CS5:
+               info->cor1 = Cy_5_BITS;
+               break;
+       case CS6:
+               info->cor1 = Cy_6_BITS;
+               break;
+       case CS7:
+               info->cor1 = Cy_7_BITS;
+               break;
+       case CS8:
+               info->cor1 = Cy_8_BITS;
+               break;
+       }
+       if (cflag & PARENB) {
+               if (cflag & PARODD) {
+                       info->cor1 |= CyPARITY_O;
+               } else {
+                       info->cor1 |= CyPARITY_E;
+               }
+       } else {
+               info->cor1 |= CyPARITY_NONE;
+       }
+
+       /* CTS flow control flag */
 #if 0
-    /* Don't complcate matters for now! RGH 141095 */
-    if (cflag & CRTSCTS){
-       info->flags |= ASYNC_CTS_FLOW;
-       info->cor2 |= CyCtsAE;
-    }else{
-       info->flags &= ~ASYNC_CTS_FLOW;
-       info->cor2 &= ~CyCtsAE;
-    }
-#endif
-    if (cflag & CLOCAL)
-       info->flags &= ~ASYNC_CHECK_CD;
-    else
-       info->flags |= ASYNC_CHECK_CD;
+       /* Don't complcate matters for now! RGH 141095 */
+       if (cflag & CRTSCTS) {
+               info->flags |= ASYNC_CTS_FLOW;
+               info->cor2 |= CyCtsAE;
+       } else {
+               info->flags &= ~ASYNC_CTS_FLOW;
+               info->cor2 &= ~CyCtsAE;
+       }
+#endif
+       if (cflag & CLOCAL)
+               info->flags &= ~ASYNC_CHECK_CD;
+       else
+               info->flags |= ASYNC_CHECK_CD;
 
      /***********************************************
        The hardware option, CyRtsAO, presents RTS when
@@ -1025,149 +1031,146 @@ config_setup(struct cyclades_port * info)
        cable.  Contact Marcio Saito for details.
      ***********************************************/
 
-    channel = info->line;
+       channel = info->line;
 
-    local_irq_save(flags);
-       base_addr[CyCAR] = (u_char)channel;
+       local_irq_save(flags);
+       base_addr[CyCAR] = (u_char) channel;
 
        /* CyCMR set once only in mvme167_init_serial() */
        if (base_addr[CyLICR] != channel << 2)
-           base_addr[CyLICR] = channel << 2;
+               base_addr[CyLICR] = channel << 2;
        if (base_addr[CyLIVR] != 0x5c)
-           base_addr[CyLIVR] = 0x5c;
+               base_addr[CyLIVR] = 0x5c;
 
-       /* tx and rx baud rate */
+       /* tx and rx baud rate */
 
        if (base_addr[CyCOR1] != info->cor1)
-           need_init_chan = 1;
+               need_init_chan = 1;
        if (base_addr[CyTCOR] != info->tco)
-           base_addr[CyTCOR] = info->tco;
+               base_addr[CyTCOR] = info->tco;
        if (base_addr[CyTBPR] != info->tbpr)
-           base_addr[CyTBPR] = info->tbpr;
+               base_addr[CyTBPR] = info->tbpr;
        if (base_addr[CyRCOR] != info->rco)
-           base_addr[CyRCOR] = info->rco;
+               base_addr[CyRCOR] = info->rco;
        if (base_addr[CyRBPR] != info->rbpr)
-           base_addr[CyRBPR] = info->rbpr;
+               base_addr[CyRBPR] = info->rbpr;
 
        /* set line characteristics  according configuration */
 
        if (base_addr[CySCHR1] != START_CHAR(info->tty))
-           base_addr[CySCHR1] = START_CHAR(info->tty);
+               base_addr[CySCHR1] = START_CHAR(info->tty);
        if (base_addr[CySCHR2] != STOP_CHAR(info->tty))
-           base_addr[CySCHR2] = STOP_CHAR(info->tty);
+               base_addr[CySCHR2] = STOP_CHAR(info->tty);
        if (base_addr[CySCRL] != START_CHAR(info->tty))
-           base_addr[CySCRL] = START_CHAR(info->tty);
+               base_addr[CySCRL] = START_CHAR(info->tty);
        if (base_addr[CySCRH] != START_CHAR(info->tty))
-           base_addr[CySCRH] = START_CHAR(info->tty);
+               base_addr[CySCRH] = START_CHAR(info->tty);
        if (base_addr[CyCOR1] != info->cor1)
-           base_addr[CyCOR1] = info->cor1;
+               base_addr[CyCOR1] = info->cor1;
        if (base_addr[CyCOR2] != info->cor2)
-           base_addr[CyCOR2] = info->cor2;
+               base_addr[CyCOR2] = info->cor2;
        if (base_addr[CyCOR3] != info->cor3)
-           base_addr[CyCOR3] = info->cor3;
+               base_addr[CyCOR3] = info->cor3;
        if (base_addr[CyCOR4] != info->cor4)
-           base_addr[CyCOR4] = info->cor4;
+               base_addr[CyCOR4] = info->cor4;
        if (base_addr[CyCOR5] != info->cor5)
-           base_addr[CyCOR5] = info->cor5;
+               base_addr[CyCOR5] = info->cor5;
        if (base_addr[CyCOR6] != info->cor6)
-           base_addr[CyCOR6] = info->cor6;
+               base_addr[CyCOR6] = info->cor6;
        if (base_addr[CyCOR7] != info->cor7)
-           base_addr[CyCOR7] = info->cor7;
+               base_addr[CyCOR7] = info->cor7;
 
        if (need_init_chan)
-           write_cy_cmd(base_addr,CyINIT_CHAN);
+               write_cy_cmd(base_addr, CyINIT_CHAN);
 
-       base_addr[CyCAR] = (u_char)channel; /* !!! Is this needed? */
+       base_addr[CyCAR] = (u_char) channel;    /* !!! Is this needed? */
 
        /* 2ms default rx timeout */
        ti = info->default_timeout ? info->default_timeout : 0x02;
        if (base_addr[CyRTPRL] != ti)
-           base_addr[CyRTPRL] = ti;
+               base_addr[CyRTPRL] = ti;
        if (base_addr[CyRTPRH] != 0)
-           base_addr[CyRTPRH] = 0;
+               base_addr[CyRTPRH] = 0;
 
        /* Set up RTS here also ????? RGH 141095 */
-       if(i == 0){ /* baud rate is zero, turn off line */
-           if ((base_addr[CyMSVR2] & CyDTR) == CyDTR)
-               base_addr[CyMSVR2] = 0;
+       if (i == 0) {           /* baud rate is zero, turn off line */
+               if ((base_addr[CyMSVR2] & CyDTR) == CyDTR)
+                       base_addr[CyMSVR2] = 0;
 #ifdef SERIAL_DEBUG_DTR
-            printk("cyc: %d: dropping DTR\n", __LINE__);
-            printk("     status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]);
+               printk("cyc: %d: dropping DTR\n", __LINE__);
+               printk("     status: 0x%x, 0x%x\n", base_addr[CyMSVR1],
+                      base_addr[CyMSVR2]);
 #endif
-       }else{
-           if ((base_addr[CyMSVR2] & CyDTR) != CyDTR)
-               base_addr[CyMSVR2] = CyDTR;
+       } else {
+               if ((base_addr[CyMSVR2] & CyDTR) != CyDTR)
+                       base_addr[CyMSVR2] = CyDTR;
 #ifdef SERIAL_DEBUG_DTR
-            printk("cyc: %d: raising DTR\n", __LINE__);
-            printk("     status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]);
+               printk("cyc: %d: raising DTR\n", __LINE__);
+               printk("     status: 0x%x, 0x%x\n", base_addr[CyMSVR1],
+                      base_addr[CyMSVR2]);
 #endif
        }
 
-       if (info->tty){
-           clear_bit(TTY_IO_ERROR, &info->tty->flags);
+       if (info->tty) {
+               clear_bit(TTY_IO_ERROR, &info->tty->flags);
        }
 
-    local_irq_restore(flags);
-
-} /* config_setup */
+       local_irq_restore(flags);
 
+}                              /* config_setup */
 
-static void
-cy_put_char(struct tty_struct *tty, unsigned char ch)
+static void cy_put_char(struct tty_struct *tty, unsigned char ch)
 {
-  struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
-  unsigned long flags;
+       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+       unsigned long flags;
 
 #ifdef SERIAL_DEBUG_IO
-    printk("cy_put_char %s(0x%02x)\n", tty->name, ch);
+       printk("cy_put_char %s(0x%02x)\n", tty->name, ch);
 #endif
 
-    if (serial_paranoia_check(info, tty->name, "cy_put_char"))
-       return;
+       if (serial_paranoia_check(info, tty->name, "cy_put_char"))
+               return;
 
-    if (!info->xmit_buf)
-       return;
+       if (!info->xmit_buf)
+               return;
 
-    local_irq_save(flags);
+       local_irq_save(flags);
        if (info->xmit_cnt >= PAGE_SIZE - 1) {
-           local_irq_restore(flags);
-           return;
+               local_irq_restore(flags);
+               return;
        }
 
        info->xmit_buf[info->xmit_head++] = ch;
        info->xmit_head &= PAGE_SIZE - 1;
        info->xmit_cnt++;
-    local_irq_restore(flags);
-} /* cy_put_char */
-
+       local_irq_restore(flags);
+}                              /* cy_put_char */
 
-static void
-cy_flush_chars(struct tty_struct *tty)
+static void cy_flush_chars(struct tty_struct *tty)
 {
-  struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
-  unsigned long flags;
-  volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
-  int channel;
-                               
+       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+       unsigned long flags;
+       volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
+       int channel;
+
 #ifdef SERIAL_DEBUG_IO
-    printk("cy_flush_chars %s\n", tty->name); /* */
+       printk("cy_flush_chars %s\n", tty->name);       /* */
 #endif
 
-    if (serial_paranoia_check(info, tty->name, "cy_flush_chars"))
-       return;
+       if (serial_paranoia_check(info, tty->name, "cy_flush_chars"))
+               return;
 
-    if (info->xmit_cnt <= 0 || tty->stopped
-    || tty->hw_stopped || !info->xmit_buf)
-       return;
+       if (info->xmit_cnt <= 0 || tty->stopped
+           || tty->hw_stopped || !info->xmit_buf)
+               return;
 
-    channel = info->line;
+       channel = info->line;
 
-    local_irq_save(flags);
+       local_irq_save(flags);
        base_addr[CyCAR] = channel;
        base_addr[CyIER] |= CyTxMpty;
-    local_irq_restore(flags);
-} /* cy_flush_chars */
-
+       local_irq_restore(flags);
+}                              /* cy_flush_chars */
 
 /* This routine gets called when tty_write has put something into
     the write_queue.  If the port is not already transmitting stuff,
@@ -1175,650 +1178,616 @@ cy_flush_chars(struct tty_struct *tty)
     routine will then ensure that the characters are sent.  If the
     port is already active, there is no need to kick it.
  */
-static int
-cy_write(struct tty_struct * tty,
-           const unsigned char *buf, int count)
+static int cy_write(struct tty_struct *tty, const unsigned char *buf, int count)
 {
-  struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
-  unsigned long flags;
-  int c, total = 0;
+       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+       unsigned long flags;
+       int c, total = 0;
 
 #ifdef SERIAL_DEBUG_IO
-    printk("cy_write %s\n", tty->name); /* */
+       printk("cy_write %s\n", tty->name);     /* */
 #endif
 
-    if (serial_paranoia_check(info, tty->name, "cy_write")){
-       return 0;
-    }
-       
-    if (!info->xmit_buf){
-        return 0;
-    }
-
-    while (1) {
-           local_irq_save(flags);
-           c = min_t(int, count, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1,
-                                     SERIAL_XMIT_SIZE - info->xmit_head));
-           if (c <= 0) {
-                   local_irq_restore(flags);
-                   break;
-           }
-
-           memcpy(info->xmit_buf + info->xmit_head, buf, c);
-           info->xmit_head = (info->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
-           info->xmit_cnt += c;
-           local_irq_restore(flags);
-
-           buf += c;
-           count -= c;
-           total += c;
-    }
-
-    if (info->xmit_cnt
-    && !tty->stopped
-    && !tty->hw_stopped ) {
-        start_xmit(info);
-    }
-    return total;
-} /* cy_write */
+       if (serial_paranoia_check(info, tty->name, "cy_write")) {
+               return 0;
+       }
 
+       if (!info->xmit_buf) {
+               return 0;
+       }
 
-static int
-cy_write_room(struct tty_struct *tty)
+       while (1) {
+               local_irq_save(flags);
+               c = min_t(int, count, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1,
+                                         SERIAL_XMIT_SIZE - info->xmit_head));
+               if (c <= 0) {
+                       local_irq_restore(flags);
+                       break;
+               }
+
+               memcpy(info->xmit_buf + info->xmit_head, buf, c);
+               info->xmit_head =
+                   (info->xmit_head + c) & (SERIAL_XMIT_SIZE - 1);
+               info->xmit_cnt += c;
+               local_irq_restore(flags);
+
+               buf += c;
+               count -= c;
+               total += c;
+       }
+
+       if (info->xmit_cnt && !tty->stopped && !tty->hw_stopped) {
+               start_xmit(info);
+       }
+       return total;
+}                              /* cy_write */
+
+static int cy_write_room(struct tty_struct *tty)
 {
-  struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
-  int  ret;
-                               
+       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+       int ret;
+
 #ifdef SERIAL_DEBUG_IO
-    printk("cy_write_room %s\n", tty->name); /* */
+       printk("cy_write_room %s\n", tty->name);        /* */
 #endif
 
-    if (serial_paranoia_check(info, tty->name, "cy_write_room"))
-       return 0;
-    ret = PAGE_SIZE - info->xmit_cnt - 1;
-    if (ret < 0)
-       ret = 0;
-    return ret;
-} /* cy_write_room */
-
+       if (serial_paranoia_check(info, tty->name, "cy_write_room"))
+               return 0;
+       ret = PAGE_SIZE - info->xmit_cnt - 1;
+       if (ret < 0)
+               ret = 0;
+       return ret;
+}                              /* cy_write_room */
 
-static int
-cy_chars_in_buffer(struct tty_struct *tty)
+static int cy_chars_in_buffer(struct tty_struct *tty)
 {
-  struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
-                               
+       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+
 #ifdef SERIAL_DEBUG_IO
-    printk("cy_chars_in_buffer %s %d\n", tty->name, info->xmit_cnt); /* */
+       printk("cy_chars_in_buffer %s %d\n", tty->name, info->xmit_cnt);        /* */
 #endif
 
-    if (serial_paranoia_check(info, tty->name, "cy_chars_in_buffer"))
-       return 0;
-
-    return info->xmit_cnt;
-} /* cy_chars_in_buffer */
+       if (serial_paranoia_check(info, tty->name, "cy_chars_in_buffer"))
+               return 0;
 
+       return info->xmit_cnt;
+}                              /* cy_chars_in_buffer */
 
-static void
-cy_flush_buffer(struct tty_struct *tty)
+static void cy_flush_buffer(struct tty_struct *tty)
 {
-  struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
-  unsigned long flags;
-                               
+       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+       unsigned long flags;
+
 #ifdef SERIAL_DEBUG_IO
-    printk("cy_flush_buffer %s\n", tty->name); /* */
+       printk("cy_flush_buffer %s\n", tty->name);      /* */
 #endif
 
-    if (serial_paranoia_check(info, tty->name, "cy_flush_buffer"))
-       return;
-    local_irq_save(flags);
+       if (serial_paranoia_check(info, tty->name, "cy_flush_buffer"))
+               return;
+       local_irq_save(flags);
        info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
-    local_irq_restore(flags);
-    tty_wakeup(tty);
-} /* cy_flush_buffer */
-
+       local_irq_restore(flags);
+       tty_wakeup(tty);
+}                              /* cy_flush_buffer */
 
 /* This routine is called by the upper-layer tty layer to signal
    that incoming characters should be throttled or that the
    throttle should be released.
  */
-static void
-cy_throttle(struct tty_struct * tty)
+static void cy_throttle(struct tty_struct *tty)
 {
-  struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
-  unsigned long flags;
-  volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
-  int channel;
+       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+       unsigned long flags;
+       volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
+       int channel;
 
 #ifdef SERIAL_DEBUG_THROTTLE
-  char buf[64];
-       
-    printk("throttle %s: %d....\n", tty_name(tty, buf),
-          tty->ldisc.chars_in_buffer(tty));
-    printk("cy_throttle %s\n", tty->name);
+       char buf[64];
+
+       printk("throttle %s: %d....\n", tty_name(tty, buf),
+              tty->ldisc.chars_in_buffer(tty));
+       printk("cy_throttle %s\n", tty->name);
 #endif
 
-    if (serial_paranoia_check(info, tty->name, "cy_nthrottle")){
-           return;
-    }
+       if (serial_paranoia_check(info, tty->name, "cy_nthrottle")) {
+               return;
+       }
 
-    if (I_IXOFF(tty)) {
-       info->x_char = STOP_CHAR(tty);
-           /* Should use the "Send Special Character" feature!!! */
-    }
+       if (I_IXOFF(tty)) {
+               info->x_char = STOP_CHAR(tty);
+               /* Should use the "Send Special Character" feature!!! */
+       }
 
-    channel = info->line;
+       channel = info->line;
 
-    local_irq_save(flags);
-       base_addr[CyCAR] = (u_char)channel;
+       local_irq_save(flags);
+       base_addr[CyCAR] = (u_char) channel;
        base_addr[CyMSVR1] = 0;
-    local_irq_restore(flags);
-
-    return;
-} /* cy_throttle */
-
+       local_irq_restore(flags);
+}                              /* cy_throttle */
 
-static void
-cy_unthrottle(struct tty_struct * tty)
+static void cy_unthrottle(struct tty_struct *tty)
 {
-  struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
-  unsigned long flags;
-  volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
-  int channel;
+       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+       unsigned long flags;
+       volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
+       int channel;
 
 #ifdef SERIAL_DEBUG_THROTTLE
-  char buf[64];
-       
-    printk("throttle %s: %d....\n", tty_name(tty, buf),
-          tty->ldisc.chars_in_buffer(tty));
-    printk("cy_unthrottle %s\n", tty->name);
+       char buf[64];
+
+       printk("throttle %s: %d....\n", tty_name(tty, buf),
+              tty->ldisc.chars_in_buffer(tty));
+       printk("cy_unthrottle %s\n", tty->name);
 #endif
 
-    if (serial_paranoia_check(info, tty->name, "cy_nthrottle")){
-           return;
-    }
+       if (serial_paranoia_check(info, tty->name, "cy_nthrottle")) {
+               return;
+       }
 
-    if (I_IXOFF(tty)) {
-       info->x_char = START_CHAR(tty);
-       /* Should use the "Send Special Character" feature!!! */
-    }
+       if (I_IXOFF(tty)) {
+               info->x_char = START_CHAR(tty);
+               /* Should use the "Send Special Character" feature!!! */
+       }
 
-    channel = info->line;
+       channel = info->line;
 
-    local_irq_save(flags);
-       base_addr[CyCAR] = (u_char)channel;
+       local_irq_save(flags);
+       base_addr[CyCAR] = (u_char) channel;
        base_addr[CyMSVR1] = CyRTS;
-    local_irq_restore(flags);
-
-    return;
-} /* cy_unthrottle */
+       local_irq_restore(flags);
+}                              /* cy_unthrottle */
 
 static int
-get_serial_info(struct cyclades_port * info,
-                           struct serial_struct __user * retinfo)
+get_serial_info(struct cyclades_port *info,
+               struct serial_struct __user * retinfo)
 {
-  struct serial_struct tmp;
+       struct serial_struct tmp;
 
 /* CP('g'); */
-    if (!retinfo)
-            return -EFAULT;
-    memset(&tmp, 0, sizeof(tmp));
-    tmp.type = info->type;
-    tmp.line = info->line;
-    tmp.port = info->line;
-    tmp.irq = 0;
-    tmp.flags = info->flags;
-    tmp.baud_base = 0;          /*!!!*/
-    tmp.close_delay = info->close_delay;
-    tmp.custom_divisor = 0;     /*!!!*/
-    tmp.hub6 = 0;               /*!!!*/
-    return copy_to_user(retinfo,&tmp,sizeof(*retinfo)) ? -EFAULT : 0;
-} /* get_serial_info */
+       if (!retinfo)
+               return -EFAULT;
+       memset(&tmp, 0, sizeof(tmp));
+       tmp.type = info->type;
+       tmp.line = info->line;
+       tmp.port = info->line;
+       tmp.irq = 0;
+       tmp.flags = info->flags;
+       tmp.baud_base = 0;      /*!!! */
+       tmp.close_delay = info->close_delay;
+       tmp.custom_divisor = 0; /*!!! */
+       tmp.hub6 = 0;           /*!!! */
+       return copy_to_user(retinfo, &tmp, sizeof(*retinfo)) ? -EFAULT : 0;
+}                              /* get_serial_info */
 
 static int
-set_serial_info(struct cyclades_port * info,
-                           struct serial_struct __user * new_info)
+set_serial_info(struct cyclades_port *info,
+               struct serial_struct __user * new_info)
 {
-  struct serial_struct new_serial;
-  struct cyclades_port old_info;
+       struct serial_struct new_serial;
+       struct cyclades_port old_info;
 
 /* CP('s'); */
-    if (!new_info)
-           return -EFAULT;
-    if (copy_from_user(&new_serial,new_info,sizeof(new_serial)))
-           return -EFAULT;
-    old_info = *info;
+       if (!new_info)
+               return -EFAULT;
+       if (copy_from_user(&new_serial, new_info, sizeof(new_serial)))
+               return -EFAULT;
+       old_info = *info;
+
+       if (!capable(CAP_SYS_ADMIN)) {
+               if ((new_serial.close_delay != info->close_delay) ||
+                   ((new_serial.flags & ASYNC_FLAGS & ~ASYNC_USR_MASK) !=
+                    (info->flags & ASYNC_FLAGS & ~ASYNC_USR_MASK)))
+                       return -EPERM;
+               info->flags = ((info->flags & ~ASYNC_USR_MASK) |
+                              (new_serial.flags & ASYNC_USR_MASK));
+               goto check_and_exit;
+       }
 
-    if (!capable(CAP_SYS_ADMIN)) {
-           if ((new_serial.close_delay != info->close_delay) ||
-               ((new_serial.flags & ASYNC_FLAGS & ~ASYNC_USR_MASK) !=
-                (info->flags & ASYNC_FLAGS & ~ASYNC_USR_MASK)))
-                   return -EPERM;
-           info->flags = ((info->flags & ~ASYNC_USR_MASK) |
-                          (new_serial.flags & ASYNC_USR_MASK));
-           goto check_and_exit;
-    }
+       /*
+        * OK, past this point, all the error checking has been done.
+        * At this point, we start making changes.....
+        */
 
+       info->flags = ((info->flags & ~ASYNC_FLAGS) |
+                      (new_serial.flags & ASYNC_FLAGS));
+       info->close_delay = new_serial.close_delay;
 
-    /*
-     * OK, past this point, all the error checking has been done.
-     * At this point, we start making changes.....
-     */
+check_and_exit:
+       if (info->flags & ASYNC_INITIALIZED) {
+               config_setup(info);
+               return 0;
+       }
+       return startup(info);
+}                              /* set_serial_info */
 
-    info->flags = ((info->flags & ~ASYNC_FLAGS) |
-                   (new_serial.flags & ASYNC_FLAGS));
-    info->close_delay = new_serial.close_delay;
+static int cy_tiocmget(struct tty_struct *tty, struct file *file)
+{
+       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+       int channel;
+       volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
+       unsigned long flags;
+       unsigned char status;
 
+       channel = info->line;
 
-check_and_exit:
-    if (info->flags & ASYNC_INITIALIZED){
-       config_setup(info);
-       return 0;
-    }else{
-        return startup(info);
-    }
-} /* set_serial_info */
+       local_irq_save(flags);
+       base_addr[CyCAR] = (u_char) channel;
+       status = base_addr[CyMSVR1] | base_addr[CyMSVR2];
+       local_irq_restore(flags);
 
-static int
-cy_tiocmget(struct tty_struct *tty, struct file *file)
-{
-  struct cyclades_port * info = (struct cyclades_port *)tty->driver_data;
-  int channel;
-  volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
-  unsigned long flags;
-  unsigned char status;
-
-    channel = info->line;
-
-    local_irq_save(flags);
-        base_addr[CyCAR] = (u_char)channel;
-        status = base_addr[CyMSVR1] | base_addr[CyMSVR2];
-    local_irq_restore(flags);
-
-    return    ((status  & CyRTS) ? TIOCM_RTS : 0)
-            | ((status  & CyDTR) ? TIOCM_DTR : 0)
-            | ((status  & CyDCD) ? TIOCM_CAR : 0)
-            | ((status  & CyDSR) ? TIOCM_DSR : 0)
-            | ((status  & CyCTS) ? TIOCM_CTS : 0);
-} /* cy_tiocmget */
+       return ((status & CyRTS) ? TIOCM_RTS : 0)
+           | ((status & CyDTR) ? TIOCM_DTR : 0)
+           | ((status & CyDCD) ? TIOCM_CAR : 0)
+           | ((status & CyDSR) ? TIOCM_DSR : 0)
+           | ((status & CyCTS) ? TIOCM_CTS : 0);
+}                              /* cy_tiocmget */
 
 static int
 cy_tiocmset(struct tty_struct *tty, struct file *file,
            unsigned int set, unsigned int clear)
 {
-  struct cyclades_port * info = (struct cyclades_port *)tty->driver_data;
-  int channel;
-  volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
-  unsigned long flags;
-         
-    channel = info->line;
-
-       if (set & TIOCM_RTS){
-           local_irq_save(flags);
-               base_addr[CyCAR] = (u_char)channel;
+       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+       int channel;
+       volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
+       unsigned long flags;
+
+       channel = info->line;
+
+       if (set & TIOCM_RTS) {
+               local_irq_save(flags);
+               base_addr[CyCAR] = (u_char) channel;
                base_addr[CyMSVR1] = CyRTS;
-           local_irq_restore(flags);
+               local_irq_restore(flags);
        }
-       if (set & TIOCM_DTR){
-           local_irq_save(flags);
-           base_addr[CyCAR] = (u_char)channel;
+       if (set & TIOCM_DTR) {
+               local_irq_save(flags);
+               base_addr[CyCAR] = (u_char) channel;
 /* CP('S');CP('2'); */
-           base_addr[CyMSVR2] = CyDTR;
+               base_addr[CyMSVR2] = CyDTR;
 #ifdef SERIAL_DEBUG_DTR
-            printk("cyc: %d: raising DTR\n", __LINE__);
-            printk("     status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]);
+               printk("cyc: %d: raising DTR\n", __LINE__);
+               printk("     status: 0x%x, 0x%x\n", base_addr[CyMSVR1],
+                      base_addr[CyMSVR2]);
 #endif
-           local_irq_restore(flags);
+               local_irq_restore(flags);
        }
 
-       if (clear & TIOCM_RTS){
-           local_irq_save(flags);
-               base_addr[CyCAR] = (u_char)channel;
+       if (clear & TIOCM_RTS) {
+               local_irq_save(flags);
+               base_addr[CyCAR] = (u_char) channel;
                base_addr[CyMSVR1] = 0;
-           local_irq_restore(flags);
+               local_irq_restore(flags);
        }
-       if (clear & TIOCM_DTR){
-           local_irq_save(flags);
-           base_addr[CyCAR] = (u_char)channel;
+       if (clear & TIOCM_DTR) {
+               local_irq_save(flags);
+               base_addr[CyCAR] = (u_char) channel;
 /* CP('C');CP('2'); */
-           base_addr[CyMSVR2] = 0;
+               base_addr[CyMSVR2] = 0;
 #ifdef SERIAL_DEBUG_DTR
-            printk("cyc: %d: dropping DTR\n", __LINE__);
-            printk("     status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]);
+               printk("cyc: %d: dropping DTR\n", __LINE__);
+               printk("     status: 0x%x, 0x%x\n", base_addr[CyMSVR1],
+                      base_addr[CyMSVR2]);
 #endif
-           local_irq_restore(flags);
+               local_irq_restore(flags);
        }
 
-    return 0;
-} /* set_modem_info */
-
-static void
-send_break( struct cyclades_port * info, int duration)
-{ /* Let the transmit ISR take care of this (since it
-     requires stuffing characters into the output stream).
-   */
-    info->x_break = duration;
-    if (!info->xmit_cnt ) {
-       start_xmit(info);
-    }
-} /* send_break */
+       return 0;
+}                              /* set_modem_info */
+
+static void send_break(struct cyclades_port *info, int duration)
+{                              /* Let the transmit ISR take care of this (since it
+                                  requires stuffing characters into the output stream).
+                                */
+       info->x_break = duration;
+       if (!info->xmit_cnt) {
+               start_xmit(info);
+       }
+}                              /* send_break */
 
 static int
-get_mon_info(struct cyclades_port * info, struct cyclades_monitor __user * mon)
+get_mon_info(struct cyclades_port *info, struct cyclades_monitor __user * mon)
 {
 
-   if (copy_to_user(mon, &info->mon, sizeof(struct cyclades_monitor)))
-          return -EFAULT;
-   info->mon.int_count  = 0;
-   info->mon.char_count = 0;
-   info->mon.char_max   = 0;
-   info->mon.char_last  = 0;
-   return 0;
+       if (copy_to_user(mon, &info->mon, sizeof(struct cyclades_monitor)))
+               return -EFAULT;
+       info->mon.int_count = 0;
+       info->mon.char_count = 0;
+       info->mon.char_max = 0;
+       info->mon.char_last = 0;
+       return 0;
 }
 
-static int
-set_threshold(struct cyclades_port * info, unsigned long __user *arg)
+static int set_threshold(struct cyclades_port *info, unsigned long __user * arg)
 {
-   volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
-   unsigned long value;
-   int channel;
-   
-   if (get_user(value, arg))
-          return -EFAULT;
-
-   channel = info->line;
-   info->cor4 &= ~CyREC_FIFO;
-   info->cor4 |= value & CyREC_FIFO;
-   base_addr[CyCOR4] = info->cor4;
-   return 0;
+       volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
+       unsigned long value;
+       int channel;
+
+       if (get_user(value, arg))
+               return -EFAULT;
+
+       channel = info->line;
+       info->cor4 &= ~CyREC_FIFO;
+       info->cor4 |= value & CyREC_FIFO;
+       base_addr[CyCOR4] = info->cor4;
+       return 0;
 }
 
 static int
-get_threshold(struct cyclades_port * info, unsigned long __user *value)
+get_threshold(struct cyclades_port *info, unsigned long __user * value)
 {
-   volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
-   int channel;
-   unsigned long tmp;
-   
-   channel = info->line;
-
-   tmp = base_addr[CyCOR4] & CyREC_FIFO;
-   return put_user(tmp,value);
+       volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
+       int channel;
+       unsigned long tmp;
+
+       channel = info->line;
+
+       tmp = base_addr[CyCOR4] & CyREC_FIFO;
+       return put_user(tmp, value);
 }
 
 static int
-set_default_threshold(struct cyclades_port * info, unsigned long __user *arg)
+set_default_threshold(struct cyclades_port *info, unsigned long __user * arg)
 {
-   unsigned long value;
+       unsigned long value;
 
-   if (get_user(value, arg))
-       return -EFAULT;
+       if (get_user(value, arg))
+               return -EFAULT;
 
-   info->default_threshold = value & 0x0f;
-   return 0;
+       info->default_threshold = value & 0x0f;
+       return 0;
 }
 
 static int
-get_default_threshold(struct cyclades_port * info, unsigned long __user *value)
+get_default_threshold(struct cyclades_port *info, unsigned long __user * value)
 {
-   return put_user(info->default_threshold,value);
+       return put_user(info->default_threshold, value);
 }
 
-static int
-set_timeout(struct cyclades_port * info, unsigned long __user *arg)
+static int set_timeout(struct cyclades_port *info, unsigned long __user * arg)
 {
-   volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
-   int channel;
-   unsigned long value;
-
-   if (get_user(value, arg))
-          return -EFAULT;
-   
-   channel = info->line;
-
-   base_addr[CyRTPRL] = value & 0xff;
-   base_addr[CyRTPRH] = (value >> 8) & 0xff;
-   return 0;
+       volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
+       int channel;
+       unsigned long value;
+
+       if (get_user(value, arg))
+               return -EFAULT;
+
+       channel = info->line;
+
+       base_addr[CyRTPRL] = value & 0xff;
+       base_addr[CyRTPRH] = (value >> 8) & 0xff;
+       return 0;
 }
 
-static int
-get_timeout(struct cyclades_port * info, unsigned long __user *value)
+static int get_timeout(struct cyclades_port *info, unsigned long __user * value)
 {
-   volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
-   int channel;
-   unsigned long tmp;
-   
-   channel = info->line;
-
-   tmp = base_addr[CyRTPRL];
-   return put_user(tmp,value);
+       volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
+       int channel;
+       unsigned long tmp;
+
+       channel = info->line;
+
+       tmp = base_addr[CyRTPRL];
+       return put_user(tmp, value);
 }
 
-static int
-set_default_timeout(struct cyclades_port * info, unsigned long value)
+static int set_default_timeout(struct cyclades_port *info, unsigned long value)
 {
-   info->default_timeout = value & 0xff;
-   return 0;
+       info->default_timeout = value & 0xff;
+       return 0;
 }
 
 static int
-get_default_timeout(struct cyclades_port * info, unsigned long __user *value)
+get_default_timeout(struct cyclades_port *info, unsigned long __user * value)
 {
-   return put_user(info->default_timeout,value);
+       return put_user(info->default_timeout, value);
 }
 
 static int
-cy_ioctl(struct tty_struct *tty, struct file * file,
-            unsigned int cmd, unsigned long arg)
+cy_ioctl(struct tty_struct *tty, struct file *file,
+        unsigned int cmd, unsigned long arg)
 {
-  unsigned long val;
-  struct cyclades_port * info = (struct cyclades_port *)tty->driver_data;
-  int ret_val = 0;
-  void __user *argp = (void __user *)arg;
+       unsigned long val;
+       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+       int ret_val = 0;
+       void __user *argp = (void __user *)arg;
 
 #ifdef SERIAL_DEBUG_OTHER
-    printk("cy_ioctl %s, cmd = %x arg = %lx\n", tty->name, cmd, arg); /* */
-#endif
-
-    switch (cmd) {
-        case CYGETMON:
-            ret_val = get_mon_info(info, argp);
-           break;
-        case CYGETTHRESH:
-           ret_val = get_threshold(info, argp);
-           break;
-        case CYSETTHRESH:
-            ret_val = set_threshold(info, argp);
-           break;
-        case CYGETDEFTHRESH:
-           ret_val = get_default_threshold(info, argp);
-           break;
-        case CYSETDEFTHRESH:
-            ret_val = set_default_threshold(info, argp);
-           break;
-        case CYGETTIMEOUT:
-           ret_val = get_timeout(info, argp);
-           break;
-        case CYSETTIMEOUT:
-            ret_val = set_timeout(info, argp);
-           break;
-        case CYGETDEFTIMEOUT:
-           ret_val = get_default_timeout(info, argp);
-           break;
-        case CYSETDEFTIMEOUT:
-            ret_val = set_default_timeout(info, (unsigned long)arg);
-           break;
-        case TCSBRK:    /* SVID version: non-zero arg --> no break */
-           ret_val = tty_check_change(tty);
-           if (ret_val)
-                   break;
-            tty_wait_until_sent(tty,0);
-            if (!arg)
-                send_break(info, HZ/4); /* 1/4 second */
-            break;
-        case TCSBRKP:   /* support for POSIX tcsendbreak() */
-           ret_val = tty_check_change(tty);
-           if (ret_val)
+       printk("cy_ioctl %s, cmd = %x arg = %lx\n", tty->name, cmd, arg);       /* */
+#endif
+
+       switch (cmd) {
+       case CYGETMON:
+               ret_val = get_mon_info(info, argp);
+               break;
+       case CYGETTHRESH:
+               ret_val = get_threshold(info, argp);
+               break;
+       case CYSETTHRESH:
+               ret_val = set_threshold(info, argp);
+               break;
+       case CYGETDEFTHRESH:
+               ret_val = get_default_threshold(info, argp);
+               break;
+       case CYSETDEFTHRESH:
+               ret_val = set_default_threshold(info, argp);
+               break;
+       case CYGETTIMEOUT:
+               ret_val = get_timeout(info, argp);
+               break;
+       case CYSETTIMEOUT:
+               ret_val = set_timeout(info, argp);
+               break;
+       case CYGETDEFTIMEOUT:
+               ret_val = get_default_timeout(info, argp);
+               break;
+       case CYSETDEFTIMEOUT:
+               ret_val = set_default_timeout(info, (unsigned long)arg);
+               break;
+       case TCSBRK:            /* SVID version: non-zero arg --> no break */
+               ret_val = tty_check_change(tty);
+               if (ret_val)
+                       break;
+               tty_wait_until_sent(tty, 0);
+               if (!arg)
+                       send_break(info, HZ / 4);       /* 1/4 second */
+               break;
+       case TCSBRKP:           /* support for POSIX tcsendbreak() */
+               ret_val = tty_check_change(tty);
+               if (ret_val)
+                       break;
+               tty_wait_until_sent(tty, 0);
+               send_break(info, arg ? arg * (HZ / 10) : HZ / 4);
                break;
-            tty_wait_until_sent(tty,0);
-            send_break(info, arg ? arg*(HZ/10) : HZ/4);
-            break;
 
 /* The following commands are incompletely implemented!!! */
-        case TIOCGSOFTCAR:
-            ret_val = put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long __user *) argp);
-            break;
-        case TIOCSSOFTCAR:
-            ret_val = get_user(val, (unsigned long __user *) argp);
-           if (ret_val)
-                   break;
-            tty->termios->c_cflag =
-                    ((tty->termios->c_cflag & ~CLOCAL) | (val ? CLOCAL : 0));
-            break;
-        case TIOCGSERIAL:
-            ret_val = get_serial_info(info, argp);
-            break;
-        case TIOCSSERIAL:
-            ret_val = set_serial_info(info, argp);
-            break;
-        default:
-           ret_val = -ENOIOCTLCMD;
-    }
+       case TIOCGSOFTCAR:
+               ret_val =
+                   put_user(C_CLOCAL(tty) ? 1 : 0,
+                            (unsigned long __user *)argp);
+               break;
+       case TIOCSSOFTCAR:
+               ret_val = get_user(val, (unsigned long __user *)argp);
+               if (ret_val)
+                       break;
+               tty->termios->c_cflag =
+                   ((tty->termios->c_cflag & ~CLOCAL) | (val ? CLOCAL : 0));
+               break;
+       case TIOCGSERIAL:
+               ret_val = get_serial_info(info, argp);
+               break;
+       case TIOCSSERIAL:
+               ret_val = set_serial_info(info, argp);
+               break;
+       default:
+               ret_val = -ENOIOCTLCMD;
+       }
 
 #ifdef SERIAL_DEBUG_OTHER
-    printk("cy_ioctl done\n");
+       printk("cy_ioctl done\n");
 #endif
 
-    return ret_val;
-} /* cy_ioctl */
-
+       return ret_val;
+}                              /* cy_ioctl */
 
-
-
-static void
-cy_set_termios(struct tty_struct *tty, struct ktermios * old_termios)
+static void cy_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
 {
-  struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
 
 #ifdef SERIAL_DEBUG_OTHER
-    printk("cy_set_termios %s\n", tty->name);
+       printk("cy_set_termios %s\n", tty->name);
 #endif
 
-    if (tty->termios->c_cflag == old_termios->c_cflag)
-        return;
-    config_setup(info);
+       if (tty->termios->c_cflag == old_termios->c_cflag)
+               return;
+       config_setup(info);
 
-    if ((old_termios->c_cflag & CRTSCTS) &&
-        !(tty->termios->c_cflag & CRTSCTS)) {
-            tty->stopped = 0;
-            cy_start(tty);
-    }
+       if ((old_termios->c_cflag & CRTSCTS) &&
+           !(tty->termios->c_cflag & CRTSCTS)) {
+               tty->stopped = 0;
+               cy_start(tty);
+       }
 #ifdef tytso_patch_94Nov25_1726
-    if (!(old_termios->c_cflag & CLOCAL) &&
-        (tty->termios->c_cflag & CLOCAL))
-            wake_up_interruptible(&info->open_wait);
+       if (!(old_termios->c_cflag & CLOCAL) &&
+           (tty->termios->c_cflag & CLOCAL))
+               wake_up_interruptible(&info->open_wait);
 #endif
+}                              /* cy_set_termios */
 
-    return;
-} /* cy_set_termios */
-
-
-static void
-cy_close(struct tty_struct * tty, struct file * filp)
+static void cy_close(struct tty_struct *tty, struct file *filp)
 {
-  struct cyclades_port * info = (struct cyclades_port *)tty->driver_data;
+       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
 
 /* CP('C'); */
 #ifdef SERIAL_DEBUG_OTHER
-    printk("cy_close %s\n", tty->name);
+       printk("cy_close %s\n", tty->name);
 #endif
 
-    if (!info
-    || serial_paranoia_check(info, tty->name, "cy_close")){
-        return;
-    }
+       if (!info || serial_paranoia_check(info, tty->name, "cy_close")) {
+               return;
+       }
 #ifdef SERIAL_DEBUG_OPEN
-    printk("cy_close %s, count = %d\n", tty->name, info->count);
-#endif
-
-    if ((tty->count == 1) && (info->count != 1)) {
-       /*
-        * Uh, oh.  tty->count is 1, which means that the tty
-        * structure will be freed.  Info->count should always
-        * be one in these conditions.  If it's greater than
-        * one, we've got real problems, since it means the
-        * serial port won't be shutdown.
-        */
-       printk("cy_close: bad serial port count; tty->count is 1, "
-          "info->count is %d\n", info->count);
-       info->count = 1;
-    }
+       printk("cy_close %s, count = %d\n", tty->name, info->count);
+#endif
+
+       if ((tty->count == 1) && (info->count != 1)) {
+               /*
+                * Uh, oh.  tty->count is 1, which means that the tty
+                * structure will be freed.  Info->count should always
+                * be one in these conditions.  If it's greater than
+                * one, we've got real problems, since it means the
+                * serial port won't be shutdown.
+                */
+               printk("cy_close: bad serial port count; tty->count is 1, "
+                      "info->count is %d\n", info->count);
+               info->count = 1;
+       }
 #ifdef SERIAL_DEBUG_COUNT
-    printk("cyc: %d: decrementing count to %d\n", __LINE__, info->count - 1);
+       printk("cyc: %d: decrementing count to %d\n", __LINE__,
+              info->count - 1);
 #endif
-    if (--info->count < 0) {
-       printk("cy_close: bad serial port count for ttys%d: %d\n",
-              info->line, info->count);
+       if (--info->count < 0) {
+               printk("cy_close: bad serial port count for ttys%d: %d\n",
+                      info->line, info->count);
 #ifdef SERIAL_DEBUG_COUNT
-    printk("cyc: %d: setting count to 0\n", __LINE__);
+               printk("cyc: %d: setting count to 0\n", __LINE__);
 #endif
-       info->count = 0;
-    }
-    if (info->count)
-       return;
-    info->flags |= ASYNC_CLOSING;
-    if (info->flags & ASYNC_INITIALIZED)
-       tty_wait_until_sent(tty, 3000); /* 30 seconds timeout */
-    shutdown(info);
-    if (tty->driver->flush_buffer)
-       tty->driver->flush_buffer(tty);
-    tty_ldisc_flush(tty);
-    info->event = 0;
-    info->tty = NULL;
-    if (info->blocked_open) {
-       if (info->close_delay) {
-           msleep_interruptible(jiffies_to_msecs(info->close_delay));
+               info->count = 0;
        }
-       wake_up_interruptible(&info->open_wait);
-    }
-    info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
-    wake_up_interruptible(&info->close_wait);
+       if (info->count)
+               return;
+       info->flags |= ASYNC_CLOSING;
+       if (info->flags & ASYNC_INITIALIZED)
+               tty_wait_until_sent(tty, 3000); /* 30 seconds timeout */
+       shutdown(info);
+       if (tty->driver->flush_buffer)
+               tty->driver->flush_buffer(tty);
+       tty_ldisc_flush(tty);
+       info->event = 0;
+       info->tty = NULL;
+       if (info->blocked_open) {
+               if (info->close_delay) {
+                       msleep_interruptible(jiffies_to_msecs
+                                            (info->close_delay));
+               }
+               wake_up_interruptible(&info->open_wait);
+       }
+       info->flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CLOSING);
+       wake_up_interruptible(&info->close_wait);
 
 #ifdef SERIAL_DEBUG_OTHER
-    printk("cy_close done\n");
+       printk("cy_close done\n");
 #endif
-
-    return;
-} /* cy_close */
+}                              /* cy_close */
 
 /*
  * cy_hangup() --- called by tty_hangup() when a hangup is signaled.
  */
-void
-cy_hangup(struct tty_struct *tty)
+void cy_hangup(struct tty_struct *tty)
 {
-  struct cyclades_port * info = (struct cyclades_port *)tty->driver_data;
-       
+       struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
+
 #ifdef SERIAL_DEBUG_OTHER
-    printk("cy_hangup %s\n", tty->name); /* */
+       printk("cy_hangup %s\n", tty->name);    /* */
 #endif
 
-    if (serial_paranoia_check(info, tty->name, "cy_hangup"))
-       return;
-    
-    shutdown(info);
+       if (serial_paranoia_check(info, tty->name, "cy_hangup"))
+               return;
+
+       shutdown(info);
 #if 0
-    info->event = 0;
-    info->count = 0;
+       info->event = 0;
+       info->count = 0;
 #ifdef SERIAL_DEBUG_COUNT
-    printk("cyc: %d: setting count to 0\n", __LINE__);
+       printk("cyc: %d: setting count to 0\n", __LINE__);
 #endif
-    info->tty = 0;
+       info->tty = 0;
 #endif
-    info->flags &= ~ASYNC_NORMAL_ACTIVE;
-    wake_up_interruptible(&info->open_wait);
-} /* cy_hangup */
-
-
+       info->flags &= ~ASYNC_NORMAL_ACTIVE;
+       wake_up_interruptible(&info->open_wait);
+}                              /* cy_hangup */
 
 /*
  * ------------------------------------------------------------
@@ -1827,177 +1796,180 @@ cy_hangup(struct tty_struct *tty)
  */
 
 static int
-block_til_ready(struct tty_struct *tty, struct file * filp,
-                           struct cyclades_port *info)
+block_til_ready(struct tty_struct *tty, struct file *filp,
+               struct cyclades_port *info)
 {
-  DECLARE_WAITQUEUE(wait, current);
-  unsigned long flags;
-  int channel;
-  int retval;
-  volatile u_char *base_addr = (u_char *)BASE_ADDR;
-
-    /*
-     * If the device is in the middle of being closed, then block
-     * until it's done, and then try again.
-     */
-    if (info->flags & ASYNC_CLOSING) {
-       interruptible_sleep_on(&info->close_wait);
-       if (info->flags & ASYNC_HUP_NOTIFY){
-           return -EAGAIN;
-       }else{
-           return -ERESTARTSYS;
-       }
-    }
-
-    /*
-     * If non-blocking mode is set, then make the check up front
-     * and then exit.
-     */
-    if (filp->f_flags & O_NONBLOCK) {
-       info->flags |= ASYNC_NORMAL_ACTIVE;
-       return 0;
-    }
-
-    /*
-     * Block waiting for the carrier detect and the line to become
-     * free (i.e., not in use by the callout).  While we are in
-     * this loop, info->count is dropped by one, so that
-     * cy_close() knows when to free things.  We restore it upon
-     * exit, either normal or abnormal.
-     */
-    retval = 0;
-    add_wait_queue(&info->open_wait, &wait);
+       DECLARE_WAITQUEUE(wait, current);
+       unsigned long flags;
+       int channel;
+       int retval;
+       volatile u_char *base_addr = (u_char *) BASE_ADDR;
+
+       /*
+        * If the device is in the middle of being closed, then block
+        * until it's done, and then try again.
+        */
+       if (info->flags & ASYNC_CLOSING) {
+               interruptible_sleep_on(&info->close_wait);
+               if (info->flags & ASYNC_HUP_NOTIFY) {
+                       return -EAGAIN;
+               } else {
+                       return -ERESTARTSYS;
+               }
+       }
+
+       /*
+        * If non-blocking mode is set, then make the check up front
+        * and then exit.
+        */
+       if (filp->f_flags & O_NONBLOCK) {
+               info->flags |= ASYNC_NORMAL_ACTIVE;
+               return 0;
+       }
+
+       /*
+        * Block waiting for the carrier detect and the line to become
+        * free (i.e., not in use by the callout).  While we are in
+        * this loop, info->count is dropped by one, so that
+        * cy_close() knows when to free things.  We restore it upon
+        * exit, either normal or abnormal.
+        */
+       retval = 0;
+       add_wait_queue(&info->open_wait, &wait);
 #ifdef SERIAL_DEBUG_OPEN
-    printk("block_til_ready before block: %s, count = %d\n",
-          tty->name, info->count);/**/
+       printk("block_til_ready before block: %s, count = %d\n",
+              tty->name, info->count);
+       /**/
 #endif
-    info->count--;
+           info->count--;
 #ifdef SERIAL_DEBUG_COUNT
-    printk("cyc: %d: decrementing count to %d\n", __LINE__, info->count);
+       printk("cyc: %d: decrementing count to %d\n", __LINE__, info->count);
 #endif
-    info->blocked_open++;
+       info->blocked_open++;
 
-    channel = info->line;
+       channel = info->line;
 
-    while (1) {
-       local_irq_save(flags);
-       base_addr[CyCAR] = (u_char)channel;
-       base_addr[CyMSVR1] = CyRTS;
+       while (1) {
+               local_irq_save(flags);
+               base_addr[CyCAR] = (u_char) channel;
+               base_addr[CyMSVR1] = CyRTS;
 /* CP('S');CP('4'); */
-       base_addr[CyMSVR2] = CyDTR;
+               base_addr[CyMSVR2] = CyDTR;
 #ifdef SERIAL_DEBUG_DTR
-       printk("cyc: %d: raising DTR\n", __LINE__);
-       printk("     status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]);
-#endif
-       local_irq_restore(flags);
-       set_current_state(TASK_INTERRUPTIBLE);
-       if (tty_hung_up_p(filp)
-       || !(info->flags & ASYNC_INITIALIZED) ){
-           if (info->flags & ASYNC_HUP_NOTIFY) {
-               retval = -EAGAIN;
-           }else{
-               retval = -ERESTARTSYS;
-           }
-           break;
-       }
-       local_irq_save(flags);
-           base_addr[CyCAR] = (u_char)channel;
+               printk("cyc: %d: raising DTR\n", __LINE__);
+               printk("     status: 0x%x, 0x%x\n", base_addr[CyMSVR1],
+                      base_addr[CyMSVR2]);
+#endif
+               local_irq_restore(flags);
+               set_current_state(TASK_INTERRUPTIBLE);
+               if (tty_hung_up_p(filp)
+                   || !(info->flags & ASYNC_INITIALIZED)) {
+                       if (info->flags & ASYNC_HUP_NOTIFY) {
+                               retval = -EAGAIN;
+                       } else {
+                               retval = -ERESTARTSYS;
+                       }
+                       break;
+               }
+               local_irq_save(flags);
+               base_addr[CyCAR] = (u_char) channel;
 /* CP('L');CP1(1 && C_CLOCAL(tty)); CP1(1 && (base_addr[CyMSVR1] & CyDCD) ); */
-           if (!(info->flags & ASYNC_CLOSING)
-           && (C_CLOCAL(tty)
-               || (base_addr[CyMSVR1] & CyDCD))) {
-                   local_irq_restore(flags);
-                   break;
-           }
-       local_irq_restore(flags);
-       if (signal_pending(current)) {
-           retval = -ERESTARTSYS;
-           break;
-       }
+               if (!(info->flags & ASYNC_CLOSING)
+                   && (C_CLOCAL(tty)
+                       || (base_addr[CyMSVR1] & CyDCD))) {
+                       local_irq_restore(flags);
+                       break;
+               }
+               local_irq_restore(flags);
+               if (signal_pending(current)) {
+                       retval = -ERESTARTSYS;
+                       break;
+               }
 #ifdef SERIAL_DEBUG_OPEN
-       printk("block_til_ready blocking: %s, count = %d\n",
-              tty->name, info->count);/**/
-#endif
-       schedule();
-    }
-    current->state = TASK_RUNNING;
-    remove_wait_queue(&info->open_wait, &wait);
-    if (!tty_hung_up_p(filp)){
-       info->count++;
+               printk("block_til_ready blocking: %s, count = %d\n",
+                      tty->name, info->count);
+               /**/
+#endif
+                   schedule();
+       }
+       current->state = TASK_RUNNING;
+       remove_wait_queue(&info->open_wait, &wait);
+       if (!tty_hung_up_p(filp)) {
+               info->count++;
 #ifdef SERIAL_DEBUG_COUNT
-    printk("cyc: %d: incrementing count to %d\n", __LINE__, info->count);
+               printk("cyc: %d: incrementing count to %d\n", __LINE__,
+                      info->count);
 #endif
-    }
-    info->blocked_open--;
+       }
+       info->blocked_open--;
 #ifdef SERIAL_DEBUG_OPEN
-    printk("block_til_ready after blocking: %s, count = %d\n",
-          tty->name, info->count);/**/
+       printk("block_til_ready after blocking: %s, count = %d\n",
+              tty->name, info->count);
+       /**/
 #endif
-    if (retval)
-           return retval;
-    info->flags |= ASYNC_NORMAL_ACTIVE;
-    return 0;
-} /* block_til_ready */
+           if (retval)
+               return retval;
+       info->flags |= ASYNC_NORMAL_ACTIVE;
+       return 0;
+}                              /* block_til_ready */
 
 /*
  * This routine is called whenever a serial port is opened.  It
  * performs the serial-specific initialization for the tty structure.
  */
-int
-cy_open(struct tty_struct *tty, struct file * filp)
+int cy_open(struct tty_struct *tty, struct file *filp)
 {
-  struct cyclades_port  *info;
-  int retval, line;
+       struct cyclades_port *info;
+       int retval, line;
 
 /* CP('O'); */
-    line = tty->index;
-    if ((line < 0) || (NR_PORTS <= line)){
-        return -ENODEV;
-    }
-    info = &cy_port[line];
-    if (info->line < 0){
-        return -ENODEV;
-    }
+       line = tty->index;
+       if ((line < 0) || (NR_PORTS <= line)) {
+               return -ENODEV;
+       }
+       info = &cy_port[line];
+       if (info->line < 0) {
+               return -ENODEV;
+       }
 #ifdef SERIAL_DEBUG_OTHER
-    printk("cy_open %s\n", tty->name); /* */
+       printk("cy_open %s\n", tty->name);      /* */
 #endif
-    if (serial_paranoia_check(info, tty->name, "cy_open")){
-        return -ENODEV;
-    }
+       if (serial_paranoia_check(info, tty->name, "cy_open")) {
+               return -ENODEV;
+       }
 #ifdef SERIAL_DEBUG_OPEN
-    printk("cy_open %s, count = %d\n", tty->name, info->count);/**/
+       printk("cy_open %s, count = %d\n", tty->name, info->count);
+       /**/
 #endif
-    info->count++;
+           info->count++;
 #ifdef SERIAL_DEBUG_COUNT
-    printk("cyc: %d: incrementing count to %d\n", __LINE__, info->count);
+       printk("cyc: %d: incrementing count to %d\n", __LINE__, info->count);
 #endif
-    tty->driver_data = info;
-    info->tty = tty;
+       tty->driver_data = info;
+       info->tty = tty;
 
-    /*
-     * Start up serial port
-     */
-    retval = startup(info);
-    if (retval){
-       return retval;
-    }
+       /*
+        * Start up serial port
+        */
+       retval = startup(info);
+       if (retval) {
+               return retval;
+       }
 
-    retval = block_til_ready(tty, filp, info);
-    if (retval) {
+       retval = block_til_ready(tty, filp, info);
+       if (retval) {
 #ifdef SERIAL_DEBUG_OPEN
-       printk("cy_open returning after block_til_ready with %d\n",
-              retval);
+               printk("cy_open returning after block_til_ready with %d\n",
+                      retval);
 #endif
-       return retval;
-    }
-
+               return retval;
+       }
 #ifdef SERIAL_DEBUG_OPEN
-    printk("cy_open done\n");/**/
+       printk("cy_open done\n");
+       /**/
 #endif
-    return 0;
-} /* cy_open */
-
-
+           return 0;
+}                              /* cy_open */
 
 /*
  * ---------------------------------------------------------------------
@@ -2012,11 +1984,10 @@ cy_open(struct tty_struct *tty, struct file * filp)
  * number, and identifies which options were configured into this
  * driver.
  */
-static void
-show_version(void)
+static void show_version(void)
 {
-    printk("MVME166/167 cd2401 driver\n");
-} /* show_version */
+       printk("MVME166/167 cd2401 driver\n");
+}                              /* show_version */
 
 /* initialize chips on card -- return number of valid
    chips (which is number of ports/4) */
@@ -2030,10 +2001,9 @@ show_version(void)
  * ... I wonder what I should do if this fails ...
  */
 
-void
-mvme167_serial_console_setup(int cflag)
+void mvme167_serial_console_setup(int cflag)
 {
-       volatile unsigned char* base_addr = (u_char *)BASE_ADDR;
+       volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
        int ch;
        u_char spd;
        u_char rcor, rbpr, badspeed = 0;
@@ -2062,21 +2032,21 @@ mvme167_serial_console_setup(int cflag)
 
        /* OK, we have chosen a speed, now reset and reinitialise */
 
-        my_udelay(20000L);     /* Allow time for any active o/p to complete */
-        if(base_addr[CyCCR] != 0x00){
-            local_irq_restore(flags);
-            /* printk(" chip is never idle (CCR != 0)\n"); */
-            return;
-        }
+       my_udelay(20000L);      /* Allow time for any active o/p to complete */
+       if (base_addr[CyCCR] != 0x00) {
+               local_irq_restore(flags);
+               /* printk(" chip is never idle (CCR != 0)\n"); */
+               return;
+       }
 
-        base_addr[CyCCR] = CyCHIP_RESET;       /* Reset the chip */
-        my_udelay(1000L);
+       base_addr[CyCCR] = CyCHIP_RESET;        /* Reset the chip */
+       my_udelay(1000L);
 
-        if(base_addr[CyGFRCR] == 0x00){
-            local_irq_restore(flags);
-            /* printk(" chip is not responding (GFRCR stayed 0)\n"); */
-            return;
-        }
+       if (base_addr[CyGFRCR] == 0x00) {
+               local_irq_restore(flags);
+               /* printk(" chip is not responding (GFRCR stayed 0)\n"); */
+               return;
+       }
 
        /*
         * System clock is 20Mhz, divided by 2048, so divide by 10 for a 1.0ms
@@ -2085,9 +2055,9 @@ mvme167_serial_console_setup(int cflag)
 
        base_addr[CyTPR] = 10;
 
-       base_addr[CyPILR1] = 0x01;    /* Interrupt level for modem change */
-       base_addr[CyPILR2] = 0x02;    /* Interrupt level for tx ints */
-       base_addr[CyPILR3] = 0x03;    /* Interrupt level for rx ints */
+       base_addr[CyPILR1] = 0x01;      /* Interrupt level for modem change */
+       base_addr[CyPILR2] = 0x02;      /* Interrupt level for tx ints */
+       base_addr[CyPILR3] = 0x03;      /* Interrupt level for rx ints */
 
        /*
         * Attempt to set up all channels to something reasonable, and
@@ -2095,11 +2065,11 @@ mvme167_serial_console_setup(int cflag)
         * the ammount of fiddling we have to do in normal running.
         */
 
-       for (ch = 3; ch >= 0 ; ch--) {
-               base_addr[CyCAR] = (u_char)ch;
+       for (ch = 3; ch >= 0; ch--) {
+               base_addr[CyCAR] = (u_char) ch;
                base_addr[CyIER] = 0;
                base_addr[CyCMR] = CyASYNC;
-               base_addr[CyLICR] = (u_char)ch << 2;
+               base_addr[CyLICR] = (u_char) ch << 2;
                base_addr[CyLIVR] = 0x5c;
                base_addr[CyTCOR] = baud_co[spd];
                base_addr[CyTBPR] = baud_bpr[spd];
@@ -2118,29 +2088,30 @@ mvme167_serial_console_setup(int cflag)
                base_addr[CyCOR7] = 0;
                base_addr[CyRTPRL] = 2;
                base_addr[CyRTPRH] = 0;
-               base_addr[CyMSVR1] = 0;
-               base_addr[CyMSVR2] = 0;
-               write_cy_cmd(base_addr,CyINIT_CHAN|CyDIS_RCVR|CyDIS_XMTR);
+               base_addr[CyMSVR1] = 0;
+               base_addr[CyMSVR2] = 0;
+               write_cy_cmd(base_addr, CyINIT_CHAN | CyDIS_RCVR | CyDIS_XMTR);
        }
 
        /*
         * Now do specials for channel zero....
         */
 
-        base_addr[CyMSVR1] = CyRTS;
-        base_addr[CyMSVR2] = CyDTR;
+       base_addr[CyMSVR1] = CyRTS;
+       base_addr[CyMSVR2] = CyDTR;
        base_addr[CyIER] = CyRxData;
-       write_cy_cmd(base_addr,CyENB_RCVR|CyENB_XMTR);
+       write_cy_cmd(base_addr, CyENB_RCVR | CyENB_XMTR);
 
        local_irq_restore(flags);
 
        my_udelay(20000L);      /* Let it all settle down */
 
-        printk("CD2401 initialised,  chip is rev 0x%02x\n", base_addr[CyGFRCR]);
+       printk("CD2401 initialised,  chip is rev 0x%02x\n", base_addr[CyGFRCR]);
        if (badspeed)
-               printk("  WARNING:  Failed to identify line speed, rcor=%02x,rbpr=%02x\n",
-                                       rcor >> 5, rbpr);
-} /* serial_console_init */
+               printk
+                   ("  WARNING:  Failed to identify line speed, rcor=%02x,rbpr=%02x\n",
+                    rcor >> 5, rbpr);
+}                              /* serial_console_init */
 
 static const struct tty_operations cy_ops = {
        .open = cy_open,
@@ -2161,6 +2132,7 @@ static const struct tty_operations cy_ops = {
        .tiocmget = cy_tiocmget,
        .tiocmset = cy_tiocmset,
 };
+
 /* The serial driver boot-time initialization code!
     Hardware I/O ports are mapped to character special devices on a
     first found, first allocated manner.  That is, this code searches
@@ -2177,214 +2149,214 @@ static const struct tty_operations cy_ops = {
     If there are more cards with more ports than have been statically
     allocated above, a warning is printed and the extra ports are ignored.
  */
-static int __init
-serial167_init(void)
+static int __init serial167_init(void)
 {
-  struct cyclades_port *info;
-  int ret = 0;
-  int good_ports = 0;
-  int port_num = 0;
-  int index;
-  int DefSpeed;
+       struct cyclades_port *info;
+       int ret = 0;
+       int good_ports = 0;
+       int port_num = 0;
+       int index;
+       int DefSpeed;
 #ifdef notyet
-  struct sigaction sa;
+       struct sigaction sa;
 #endif
 
-    if (!(mvme16x_config &MVME16x_CONFIG_GOT_CD2401))
-       return 0;
+       if (!(mvme16x_config & MVME16x_CONFIG_GOT_CD2401))
+               return 0;
 
-    cy_serial_driver = alloc_tty_driver(NR_PORTS);
-    if (!cy_serial_driver)
-       return -ENOMEM;
+       cy_serial_driver = alloc_tty_driver(NR_PORTS);
+       if (!cy_serial_driver)
+               return -ENOMEM;
 
 #if 0
-scrn[1] = '\0';
+       scrn[1] = '\0';
 #endif
 
-    show_version();
+       show_version();
 
-    /* Has "console=0,9600n8" been used in bootinfo to change speed? */
-    if (serial_console_cflag)
-       DefSpeed = serial_console_cflag & 0017;
-    else {
-       DefSpeed = initial_console_speed;
-       serial_console_info = &cy_port[0];
-       serial_console_cflag = DefSpeed | CS8;
+       /* Has "console=0,9600n8" been used in bootinfo to change speed? */
+       if (serial_console_cflag)
+               DefSpeed = serial_console_cflag & 0017;
+       else {
+               DefSpeed = initial_console_speed;
+               serial_console_info = &cy_port[0];
+               serial_console_cflag = DefSpeed | CS8;
 #if 0
-       serial_console = 64; /*callout_driver.minor_start*/
-#endif
-    }
-
-    /* Initialize the tty_driver structure */
-    
-    cy_serial_driver->owner = THIS_MODULE;
-    cy_serial_driver->name = "ttyS";
-    cy_serial_driver->major = TTY_MAJOR;
-    cy_serial_driver->minor_start = 64;
-    cy_serial_driver->type = TTY_DRIVER_TYPE_SERIAL;
-    cy_serial_driver->subtype = SERIAL_TYPE_NORMAL;
-    cy_serial_driver->init_termios = tty_std_termios;
-    cy_serial_driver->init_termios.c_cflag =
-           B9600 | CS8 | CREAD | HUPCL | CLOCAL;
-    cy_serial_driver->flags = TTY_DRIVER_REAL_RAW;
-    tty_set_operations(cy_serial_driver, &cy_ops);
+               serial_console = 64;    /*callout_driver.minor_start */
+#endif
+       }
 
-    ret = tty_register_driver(cy_serial_driver);
-    if (ret) {
-           printk(KERN_ERR "Couldn't register MVME166/7 serial driver\n");
-           put_tty_driver(cy_serial_driver);
-           return ret;
-    }
+       /* Initialize the tty_driver structure */
 
-    port_num = 0;
-    info = cy_port;
-    for (index = 0; index < 1; index++) {
+       cy_serial_driver->owner = THIS_MODULE;
+       cy_serial_driver->name = "ttyS";
+       cy_serial_driver->major = TTY_MAJOR;
+       cy_serial_driver->minor_start = 64;
+       cy_serial_driver->type = TTY_DRIVER_TYPE_SERIAL;
+       cy_serial_driver->subtype = SERIAL_TYPE_NORMAL;
+       cy_serial_driver->init_termios = tty_std_termios;
+       cy_serial_driver->init_termios.c_cflag =
+           B9600 | CS8 | CREAD | HUPCL | CLOCAL;
+       cy_serial_driver->flags = TTY_DRIVER_REAL_RAW;
+       tty_set_operations(cy_serial_driver, &cy_ops);
+
+       ret = tty_register_driver(cy_serial_driver);
+       if (ret) {
+               printk(KERN_ERR "Couldn't register MVME166/7 serial driver\n");
+               put_tty_driver(cy_serial_driver);
+               return ret;
+       }
 
-       good_ports = 4;
+       port_num = 0;
+       info = cy_port;
+       for (index = 0; index < 1; index++) {
 
-       if(port_num < NR_PORTS){
-           while( good_ports-- && port_num < NR_PORTS){
+               good_ports = 4;
+
+               if (port_num < NR_PORTS) {
+                       while (good_ports-- && port_num < NR_PORTS) {
                /*** initialize port ***/
-               info->magic = CYCLADES_MAGIC;
-               info->type = PORT_CIRRUS;
-               info->card = index;
-               info->line = port_num;
-               info->flags = STD_COM_FLAGS;
-               info->tty = NULL;
-               info->xmit_fifo_size = 12;
-               info->cor1 = CyPARITY_NONE|Cy_8_BITS;
-               info->cor2 = CyETC;
-               info->cor3 = Cy_1_STOP;
-               info->cor4 = 0x08; /* _very_ small receive threshold */
-               info->cor5 = 0;
-               info->cor6 = 0;
-               info->cor7 = 0;
-               info->tbpr = baud_bpr[DefSpeed]; /* Tx BPR */
-               info->tco = baud_co[DefSpeed]; /* Tx CO */
-               info->rbpr = baud_bpr[DefSpeed]; /* Rx BPR */
-               info->rco = baud_co[DefSpeed] >> 5; /* Rx CO */
-               info->close_delay = 0;
-               info->x_char = 0;
-               info->event = 0;
-               info->count = 0;
+                               info->magic = CYCLADES_MAGIC;
+                               info->type = PORT_CIRRUS;
+                               info->card = index;
+                               info->line = port_num;
+                               info->flags = STD_COM_FLAGS;
+                               info->tty = NULL;
+                               info->xmit_fifo_size = 12;
+                               info->cor1 = CyPARITY_NONE | Cy_8_BITS;
+                               info->cor2 = CyETC;
+                               info->cor3 = Cy_1_STOP;
+                               info->cor4 = 0x08;      /* _very_ small receive threshold */
+                               info->cor5 = 0;
+                               info->cor6 = 0;
+                               info->cor7 = 0;
+                               info->tbpr = baud_bpr[DefSpeed];        /* Tx BPR */
+                               info->tco = baud_co[DefSpeed];  /* Tx CO */
+                               info->rbpr = baud_bpr[DefSpeed];        /* Rx BPR */
+                               info->rco = baud_co[DefSpeed] >> 5;     /* Rx CO */
+                               info->close_delay = 0;
+                               info->x_char = 0;
+                               info->event = 0;
+                               info->count = 0;
 #ifdef SERIAL_DEBUG_COUNT
-    printk("cyc: %d: setting count to 0\n", __LINE__);
-#endif
-               info->blocked_open = 0;
-               info->default_threshold = 0;
-               info->default_timeout = 0;
-               INIT_WORK(&info->tqueue, do_softint);
-               init_waitqueue_head(&info->open_wait);
-               init_waitqueue_head(&info->close_wait);
-               /* info->session */
-               /* info->pgrp */
+                               printk("cyc: %d: setting count to 0\n",
+                                      __LINE__);
+#endif
+                               info->blocked_open = 0;
+                               info->default_threshold = 0;
+                               info->default_timeout = 0;
+                               INIT_WORK(&info->tqueue, do_softint);
+                               init_waitqueue_head(&info->open_wait);
+                               init_waitqueue_head(&info->close_wait);
+                               /* info->session */
+                               /* info->pgrp */
 /*** !!!!!!!! this may expose new bugs !!!!!!!!! *********/
-               info->read_status_mask = CyTIMEOUT| CySPECHAR| CyBREAK
-                                       | CyPARITY| CyFRAME| CyOVERRUN;
-               /* info->timeout */
-
-               printk("ttyS%d ", info->line);
-               port_num++;info++;
-               if(!(port_num & 7)){
-                   printk("\n               ");
+                               info->read_status_mask =
+                                   CyTIMEOUT | CySPECHAR | CyBREAK | CyPARITY |
+                                   CyFRAME | CyOVERRUN;
+                               /* info->timeout */
+
+                               printk("ttyS%d ", info->line);
+                               port_num++;
+                               info++;
+                               if (!(port_num & 7)) {
+                                       printk("\n               ");
+                               }
+                       }
                }
-           }
-       }
-       printk("\n");
-    }
-    while( port_num < NR_PORTS){
-       info->line = -1;
-       port_num++;info++;
-    }
+               printk("\n");
+       }
+       while (port_num < NR_PORTS) {
+               info->line = -1;
+               port_num++;
+               info++;
+       }
 #ifdef CONFIG_REMOTE_DEBUG
-    debug_setup();
-#endif
-    ret = request_irq(MVME167_IRQ_SER_ERR, cd2401_rxerr_interrupt, 0,
-                               "cd2401_errors", cd2401_rxerr_interrupt);
-    if (ret) {
-           printk(KERN_ERR "Could't get cd2401_errors IRQ");
-           goto cleanup_serial_driver;
-    }
-
-    ret = request_irq(MVME167_IRQ_SER_MODEM, cd2401_modem_interrupt, 0,
-                               "cd2401_modem", cd2401_modem_interrupt);
-    if (ret) {
-           printk(KERN_ERR "Could't get cd2401_modem IRQ");
-           goto cleanup_irq_cd2401_errors;
-    }
-
-    ret = request_irq(MVME167_IRQ_SER_TX, cd2401_tx_interrupt, 0,
-                               "cd2401_txints", cd2401_tx_interrupt);
-    if (ret) {
-           printk(KERN_ERR "Could't get cd2401_txints IRQ");
-           goto cleanup_irq_cd2401_modem;
-    }
-
-    ret = request_irq(MVME167_IRQ_SER_RX, cd2401_rx_interrupt, 0,
-                               "cd2401_rxints", cd2401_rx_interrupt);
-    if (ret) {
-           printk(KERN_ERR "Could't get cd2401_rxints IRQ");
-           goto cleanup_irq_cd2401_txints;
-    }
-
-    /* Now we have registered the interrupt handlers, allow the interrupts */
-
-    pcc2chip[PccSCCMICR] = 0x15;               /* Serial ints are level 5 */
-    pcc2chip[PccSCCTICR] = 0x15;
-    pcc2chip[PccSCCRICR] = 0x15;
-
-    pcc2chip[PccIMLR] = 3;                     /* Allow PCC2 ints above 3!? */
-
-    return 0;
+       debug_setup();
+#endif
+       ret = request_irq(MVME167_IRQ_SER_ERR, cd2401_rxerr_interrupt, 0,
+                         "cd2401_errors", cd2401_rxerr_interrupt);
+       if (ret) {
+               printk(KERN_ERR "Could't get cd2401_errors IRQ");
+               goto cleanup_serial_driver;
+       }
+
+       ret = request_irq(MVME167_IRQ_SER_MODEM, cd2401_modem_interrupt, 0,
+                         "cd2401_modem", cd2401_modem_interrupt);
+       if (ret) {
+               printk(KERN_ERR "Could't get cd2401_modem IRQ");
+               goto cleanup_irq_cd2401_errors;
+       }
+
+       ret = request_irq(MVME167_IRQ_SER_TX, cd2401_tx_interrupt, 0,
+                         "cd2401_txints", cd2401_tx_interrupt);
+       if (ret) {
+               printk(KERN_ERR "Could't get cd2401_txints IRQ");
+               goto cleanup_irq_cd2401_modem;
+       }
+
+       ret = request_irq(MVME167_IRQ_SER_RX, cd2401_rx_interrupt, 0,
+                         "cd2401_rxints", cd2401_rx_interrupt);
+       if (ret) {
+               printk(KERN_ERR "Could't get cd2401_rxints IRQ");
+               goto cleanup_irq_cd2401_txints;
+       }
+
+       /* Now we have registered the interrupt handlers, allow the interrupts */
+
+       pcc2chip[PccSCCMICR] = 0x15;    /* Serial ints are level 5 */
+       pcc2chip[PccSCCTICR] = 0x15;
+       pcc2chip[PccSCCRICR] = 0x15;
+
+       pcc2chip[PccIMLR] = 3;  /* Allow PCC2 ints above 3!? */
+
+       return 0;
 cleanup_irq_cd2401_txints:
-    free_irq(MVME167_IRQ_SER_TX, cd2401_tx_interrupt);
+       free_irq(MVME167_IRQ_SER_TX, cd2401_tx_interrupt);
 cleanup_irq_cd2401_modem:
-    free_irq(MVME167_IRQ_SER_MODEM, cd2401_modem_interrupt);
+       free_irq(MVME167_IRQ_SER_MODEM, cd2401_modem_interrupt);
 cleanup_irq_cd2401_errors:
-    free_irq(MVME167_IRQ_SER_ERR, cd2401_rxerr_interrupt);
+       free_irq(MVME167_IRQ_SER_ERR, cd2401_rxerr_interrupt);
 cleanup_serial_driver:
-    if (tty_unregister_driver(cy_serial_driver))
-           printk(KERN_ERR "Couldn't unregister MVME166/7 serial driver\n");
-    put_tty_driver(cy_serial_driver);
-    return ret;
-} /* serial167_init */
+       if (tty_unregister_driver(cy_serial_driver))
+               printk(KERN_ERR
+                      "Couldn't unregister MVME166/7 serial driver\n");
+       put_tty_driver(cy_serial_driver);
+       return ret;
+}                              /* serial167_init */
 
 module_init(serial167_init);
 
-
 #ifdef CYCLOM_SHOW_STATUS
-static void
-show_status(int line_num)
+static void show_status(int line_num)
 {
-  volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
-  int channel;
-  struct cyclades_port * info;
-  unsigned long flags;
-
-    info = &cy_port[line_num];
-    channel = info->line;
-    printk("  channel %d\n", channel);/**/
-
-    printk(" cy_port\n");
-    printk("  card line flags = %d %d %x\n",
-                 info->card, info->line, info->flags);
-    printk("  *tty read_status_mask timeout xmit_fifo_size = %lx %x %x %x\n",
-                 (long)info->tty, info->read_status_mask,
-                 info->timeout, info->xmit_fifo_size);
-    printk("  cor1,cor2,cor3,cor4,cor5,cor6,cor7 = %x %x %x %x %x %x %x\n",
-             info->cor1, info->cor2, info->cor3, info->cor4, info->cor5,
-                       info->cor6, info->cor7);
-    printk("  tbpr,tco,rbpr,rco = %d %d %d %d\n",
-             info->tbpr, info->tco, info->rbpr, info->rco);
-    printk("  close_delay event count = %d %d %d\n",
-             info->close_delay, info->event, info->count);
-    printk("  x_char blocked_open = %x %x\n",
-             info->x_char, info->blocked_open);
-    printk("  open_wait = %lx %lx %lx\n",
-             (long)info->open_wait);
-
-
-    local_irq_save(flags);
+       volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
+       int channel;
+       struct cyclades_port *info;
+       unsigned long flags;
+
+       info = &cy_port[line_num];
+       channel = info->line;
+       printk("  channel %d\n", channel);
+       /**/ printk(" cy_port\n");
+       printk("  card line flags = %d %d %x\n",
+              info->card, info->line, info->flags);
+       printk
+           ("  *tty read_status_mask timeout xmit_fifo_size = %lx %x %x %x\n",
+            (long)info->tty, info->read_status_mask, info->timeout,
+            info->xmit_fifo_size);
+       printk("  cor1,cor2,cor3,cor4,cor5,cor6,cor7 = %x %x %x %x %x %x %x\n",
+              info->cor1, info->cor2, info->cor3, info->cor4, info->cor5,
+              info->cor6, info->cor7);
+       printk("  tbpr,tco,rbpr,rco = %d %d %d %d\n", info->tbpr, info->tco,
+              info->rbpr, info->rco);
+       printk("  close_delay event count = %d %d %d\n", info->close_delay,
+              info->event, info->count);
+       printk("  x_char blocked_open = %x %x\n", info->x_char,
+              info->blocked_open);
+       printk("  open_wait = %lx %lx %lx\n", (long)info->open_wait);
+
+       local_irq_save(flags);
 
 /* Global Registers */
 
@@ -2398,7 +2370,7 @@ show_status(int line_num)
        printk(" CyMIR %x\n", base_addr[CyMIR]);
        printk(" CyTPR %x\n", base_addr[CyTPR]);
 
-       base_addr[CyCAR] = (u_char)channel;
+       base_addr[CyCAR] = (u_char) channel;
 
 /* Virtual Registers */
 
@@ -2442,11 +2414,10 @@ show_status(int line_num)
        printk(" CyTBPR %x\n", base_addr[CyTBPR]);
        printk(" CyTCOR %x\n", base_addr[CyTCOR]);
 
-    local_irq_restore(flags);
-} /* show_status */
+       local_irq_restore(flags);
+}                              /* show_status */
 #endif
 
-
 #if 0
 /* Dummy routine in mvme16x/config.c for now */
 
@@ -2459,61 +2430,67 @@ void console_setup(char *str, int *ints)
        int cflag = 0;
 
        /* Sanity check. */
-       if (ints[0] > 3 || ints[1] > 3) return;
+       if (ints[0] > 3 || ints[1] > 3)
+               return;
 
        /* Get baud, bits and parity */
        baud = 2400;
        bits = 8;
        parity = 'n';
-       if (ints[2]) baud = ints[2];
+       if (ints[2])
+               baud = ints[2];
        if ((s = strchr(str, ','))) {
                do {
                        s++;
-               } while(*s >= '0' && *s <= '9');
-               if (*s) parity = *s++;
-               if (*s) bits   = *s - '0';
+               } while (*s >= '0' && *s <= '9');
+               if (*s)
+                       parity = *s++;
+               if (*s)
+                       bits = *s - '0';
        }
 
        /* Now construct a cflag setting. */
-       switch(baud) {
-               case 1200:
-                       cflag |= B1200;
-                       break;
-               case 9600:
-                       cflag |= B9600;
-                       break;
-               case 19200:
-                       cflag |= B19200;
-                       break;
-               case 38400:
-                       cflag |= B38400;
-                       break;
-               case 2400:
-               default:
-                       cflag |= B2400;
-                       break;
+       switch (baud) {
+       case 1200:
+               cflag |= B1200;
+               break;
+       case 9600:
+               cflag |= B9600;
+               break;
+       case 19200:
+               cflag |= B19200;
+               break;
+       case 38400:
+               cflag |= B38400;
+               break;
+       case 2400:
+       default:
+               cflag |= B2400;
+               break;
        }
-       switch(bits) {
-               case 7:
-                       cflag |= CS7;
-                       break;
-               default:
-               case 8:
-                       cflag |= CS8;
-                       break;
+       switch (bits) {
+       case 7:
+               cflag |= CS7;
+               break;
+       default:
+       case 8:
+               cflag |= CS8;
+               break;
        }
-       switch(parity) {
-               case 'o': case 'O':
-                       cflag |= PARODD;
-                       break;
-               case 'e': case 'E':
-                       cflag |= PARENB;
-                       break;
+       switch (parity) {
+       case 'o':
+       case 'O':
+               cflag |= PARODD;
+               break;
+       case 'e':
+       case 'E':
+               cflag |= PARENB;
+               break;
        }
 
        serial_console_info = &cy_port[ints[1]];
        serial_console_cflag = cflag;
-       serial_console = ints[1] + 64; /*callout_driver.minor_start*/
+       serial_console = ints[1] + 64;  /*callout_driver.minor_start */
 }
 #endif
 
@@ -2532,9 +2509,10 @@ void console_setup(char *str, int *ints)
  * The console must be locked when we get here.
  */
 
-void serial167_console_write(struct console *co, const char *str, unsigned count)
+void serial167_console_write(struct console *co, const char *str,
+                            unsigned count)
 {
-       volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
+       volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
        unsigned long flags;
        volatile u_char sink;
        u_char ier;
@@ -2547,7 +2525,7 @@ void serial167_console_write(struct console *co, const char *str, unsigned count
        /* Ensure transmitter is enabled! */
 
        port = 0;
-       base_addr[CyCAR] = (u_char)port;
+       base_addr[CyCAR] = (u_char) port;
        while (base_addr[CyCCR])
                ;
        base_addr[CyCCR] = CyENB_XMTR;
@@ -2556,8 +2534,7 @@ void serial167_console_write(struct console *co, const char *str, unsigned count
        base_addr[CyIER] = CyTxMpty;
 
        while (1) {
-               if (pcc2chip[PccSCCTICR] & 0x20)
-               {
+               if (pcc2chip[PccSCCTICR] & 0x20) {
                        /* We have a Tx int. Acknowledge it */
                        sink = pcc2chip[PccTPIACKR];
                        if ((base_addr[CyLICR] >> 2) == port) {
@@ -2571,18 +2548,15 @@ void serial167_console_write(struct console *co, const char *str, unsigned count
                                        str++;
                                        i++;
                                        do_lf = 0;
-                               }
-                               else if (*str == '\n') {
+                               } else if (*str == '\n') {
                                        base_addr[CyTDR] = '\r';
                                        do_lf = 1;
-                               }
-                               else {
+                               } else {
                                        base_addr[CyTDR] = *str++;
                                        i++;
                                }
                                base_addr[CyTEOIR] = 0;
-                       }
-                       else
+                       } else
                                base_addr[CyTEOIR] = CyNOTRANS;
                }
        }
@@ -2592,45 +2566,44 @@ void serial167_console_write(struct console *co, const char *str, unsigned count
        local_irq_restore(flags);
 }
 
-static struct tty_driver *serial167_console_device(struct console *c, int *index)
+static struct tty_driver *serial167_console_device(struct console *c,
+                                                  int *index)
 {
        *index = c->index;
        return cy_serial_driver;
 }
 
-
 static int __init serial167_console_setup(struct console *co, char *options)
 {
        return 0;
 }
 
-
 static struct console sercons = {
-       .name           = "ttyS",
-       .write          = serial167_console_write,
-       .device         = serial167_console_device,
-       .setup          = serial167_console_setup,
-       .flags          = CON_PRINTBUFFER,
-       .index          = -1,
+       .name = "ttyS",
+       .write = serial167_console_write,
+       .device = serial167_console_device,
+       .setup = serial167_console_setup,
+       .flags = CON_PRINTBUFFER,
+       .index = -1,
 };
 
-
 static int __init serial167_console_init(void)
 {
        if (vme_brdtype == VME_TYPE_MVME166 ||
-                       vme_brdtype == VME_TYPE_MVME167 ||
-                       vme_brdtype == VME_TYPE_MVME177) {
+           vme_brdtype == VME_TYPE_MVME167 ||
+           vme_brdtype == VME_TYPE_MVME177) {
                mvme167_serial_console_setup(0);
                register_console(&sercons);
        }
        return 0;
 }
+
 console_initcall(serial167_console_init);
 
 #ifdef CONFIG_REMOTE_DEBUG
-void putDebugChar (int c)
+void putDebugChar(int c)
 {
-       volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
+       volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
        unsigned long flags;
        volatile u_char sink;
        u_char ier;
@@ -2641,7 +2614,7 @@ void putDebugChar (int c)
        /* Ensure transmitter is enabled! */
 
        port = DEBUG_PORT;
-       base_addr[CyCAR] = (u_char)port;
+       base_addr[CyCAR] = (u_char) port;
        while (base_addr[CyCCR])
                ;
        base_addr[CyCCR] = CyENB_XMTR;
@@ -2650,16 +2623,14 @@ void putDebugChar (int c)
        base_addr[CyIER] = CyTxMpty;
 
        while (1) {
-               if (pcc2chip[PccSCCTICR] & 0x20)
-               {
+               if (pcc2chip[PccSCCTICR] & 0x20) {
                        /* We have a Tx int. Acknowledge it */
                        sink = pcc2chip[PccTPIACKR];
                        if ((base_addr[CyLICR] >> 2) == port) {
                                base_addr[CyTDR] = c;
                                base_addr[CyTEOIR] = 0;
                                break;
-                       }
-                       else
+                       } else
                                base_addr[CyTEOIR] = CyNOTRANS;
                }
        }
@@ -2671,7 +2642,7 @@ void putDebugChar (int c)
 
 int getDebugChar()
 {
-       volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
+       volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
        unsigned long flags;
        volatile u_char sink;
        u_char ier;
@@ -2693,7 +2664,7 @@ int getDebugChar()
        /* Ensure receiver is enabled! */
 
        port = DEBUG_PORT;
-       base_addr[CyCAR] = (u_char)port;
+       base_addr[CyCAR] = (u_char) port;
 #if 0
        while (base_addr[CyCCR])
                ;
@@ -2703,31 +2674,30 @@ int getDebugChar()
        base_addr[CyIER] = CyRxData;
 
        while (1) {
-               if (pcc2chip[PccSCCRICR] & 0x20)
-               {
+               if (pcc2chip[PccSCCRICR] & 0x20) {
                        /* We have a Rx int. Acknowledge it */
                        sink = pcc2chip[PccRPIACKR];
                        if ((base_addr[CyLICR] >> 2) == port) {
                                int cnt = base_addr[CyRFOC];
-                               while (cnt-- > 0)
-                               {
+                               while (cnt-- > 0) {
                                        c = base_addr[CyRDR];
                                        if (c == 0)
-                                               printk ("!! debug char is null (cnt=%d) !!", cnt);
+                                               printk
+                                                   ("!! debug char is null (cnt=%d) !!",
+                                                    cnt);
                                        else
-                                               queueDebugChar (c);
+                                               queueDebugChar(c);
                                }
                                base_addr[CyREOIR] = 0;
                                i = debugiq.out;
                                if (i == debugiq.in)
-                                       panic ("Debug input queue empty!");
+                                       panic("Debug input queue empty!");
                                c = debugiq.buf[i];
                                if (++i == DEBUG_LEN)
                                        i = 0;
                                debugiq.out = i;
                                break;
-                       }
-                       else
+                       } else
                                base_addr[CyREOIR] = CyNOTRANS;
                }
        }
@@ -2739,7 +2709,7 @@ int getDebugChar()
        return (c);
 }
 
-void queueDebugChar (int c)
+void queueDebugChar(int c)
 {
        int i;
 
@@ -2751,73 +2721,71 @@ void queueDebugChar (int c)
                debugiq.in = i;
 }
 
-static void
-debug_setup()
+static void debug_setup()
 {
-  unsigned long flags;
-  volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
-  int   i, cflag;
+       unsigned long flags;
+       volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
+       int i, cflag;
 
-    cflag = B19200;
+       cflag = B19200;
 
-    local_irq_save(flags);
+       local_irq_save(flags);
 
-    for (i = 0; i < 4; i++)
-    {
-       base_addr[CyCAR] = i;
-       base_addr[CyLICR] = i << 2;
-    }
+       for (i = 0; i < 4; i++) {
+               base_addr[CyCAR] = i;
+               base_addr[CyLICR] = i << 2;
+       }
 
-    debugiq.in = debugiq.out = 0;
+       debugiq.in = debugiq.out = 0;
 
-    base_addr[CyCAR] = DEBUG_PORT;
+       base_addr[CyCAR] = DEBUG_PORT;
 
-    /* baud rate */
-    i = cflag & CBAUD;
+       /* baud rate */
+       i = cflag & CBAUD;
 
-    base_addr[CyIER] = 0;
+       base_addr[CyIER] = 0;
 
-    base_addr[CyCMR] = CyASYNC;
-    base_addr[CyLICR] = DEBUG_PORT << 2;
-    base_addr[CyLIVR] = 0x5c;
+       base_addr[CyCMR] = CyASYNC;
+       base_addr[CyLICR] = DEBUG_PORT << 2;
+       base_addr[CyLIVR] = 0x5c;
 
-    /* tx and rx baud rate */
+       /* tx and rx baud rate */
 
-    base_addr[CyTCOR] = baud_co[i];
-    base_addr[CyTBPR] = baud_bpr[i];
-    base_addr[CyRCOR] = baud_co[i] >> 5;
-    base_addr[CyRBPR] = baud_bpr[i];
+       base_addr[CyTCOR] = baud_co[i];
+       base_addr[CyTBPR] = baud_bpr[i];
+       base_addr[CyRCOR] = baud_co[i] >> 5;
+       base_addr[CyRBPR] = baud_bpr[i];
 
-    /* set line characteristics  according configuration */
+       /* set line characteristics  according configuration */
 
-    base_addr[CySCHR1] = 0;
-    base_addr[CySCHR2] = 0;
-    base_addr[CySCRL] = 0;
-    base_addr[CySCRH] = 0;
-    base_addr[CyCOR1] = Cy_8_BITS | CyPARITY_NONE;
-    base_addr[CyCOR2] = 0;
-    base_addr[CyCOR3] = Cy_1_STOP;
-    base_addr[CyCOR4] = baud_cor4[i];
-    base_addr[CyCOR5] = 0;
-    base_addr[CyCOR6] = 0;
-    base_addr[CyCOR7] = 0;
+       base_addr[CySCHR1] = 0;
+       base_addr[CySCHR2] = 0;
+       base_addr[CySCRL] = 0;
+       base_addr[CySCRH] = 0;
+       base_addr[CyCOR1] = Cy_8_BITS | CyPARITY_NONE;
+       base_addr[CyCOR2] = 0;
+       base_addr[CyCOR3] = Cy_1_STOP;
+       base_addr[CyCOR4] = baud_cor4[i];
+       base_addr[CyCOR5] = 0;
+       base_addr[CyCOR6] = 0;
+       base_addr[CyCOR7] = 0;
 
-    write_cy_cmd(base_addr,CyINIT_CHAN);
-    write_cy_cmd(base_addr,CyENB_RCVR);
+       write_cy_cmd(base_addr, CyINIT_CHAN);
+       write_cy_cmd(base_addr, CyENB_RCVR);
 
-    base_addr[CyCAR] = DEBUG_PORT; /* !!! Is this needed? */
+       base_addr[CyCAR] = DEBUG_PORT;  /* !!! Is this needed? */
 
-    base_addr[CyRTPRL] = 2;
-    base_addr[CyRTPRH] = 0;
+       base_addr[CyRTPRL] = 2;
+       base_addr[CyRTPRH] = 0;
 
-    base_addr[CyMSVR1] = CyRTS;
-    base_addr[CyMSVR2] = CyDTR;
+       base_addr[CyMSVR1] = CyRTS;
+       base_addr[CyMSVR2] = CyDTR;
 
-    base_addr[CyIER] = CyRxData;
+       base_addr[CyIER] = CyRxData;
 
-    local_irq_restore(flags);
+       local_irq_restore(flags);
 
-} /* debug_setup */
+}                              /* debug_setup */
 
 #endif
 
index 20946f5127e0ca97b8b902fe3e22ae464722bcbf..92043c8f23554137d3f6c0a1c7c750049a12030e 100644 (file)
@@ -2350,10 +2350,8 @@ static void do_softint(struct work_struct *work)
                return;
        }
 
-       if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP, &port->event)) {
+       if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP, &port->event))
                tty_wakeup(tty);
-               //wake_up_interruptible(&tty->write_wait);
-       }
 
        func_exit();
 }
index 3fa625db9e4b133b6caf258ed442d2675dad18c5..bf76db1342c5883efe06d6f56230f8ea482f8c95 100644 (file)
@@ -1148,10 +1148,8 @@ static void mgsl_bh_transmit(struct mgsl_struct *info)
                printk( "%s(%d):mgsl_bh_transmit() entry on %s\n",
                        __FILE__,__LINE__,info->device_name);
 
-       if (tty) {
+       if (tty)
                tty_wakeup(tty);
-               wake_up_interruptible(&tty->write_wait);
-       }
 
        /* if transmitter idle and loopmode_send_done_requested
         * then start echoing RxD to TxD
@@ -2340,7 +2338,6 @@ static void mgsl_flush_buffer(struct tty_struct *tty)
        del_timer(&info->tx_timer);     
        spin_unlock_irqrestore(&info->irq_spinlock,flags);
        
-       wake_up_interruptible(&tty->write_wait);
        tty_wakeup(tty);
 }
 
index 792c79c315e00292abc21e7febea957c171506c0..54af763518fefde65774091d6dc8591c025f53c1 100644 (file)
@@ -1045,7 +1045,6 @@ static void flush_buffer(struct tty_struct *tty)
                info->tx_count = 0;
        spin_unlock_irqrestore(&info->lock,flags);
 
-       wake_up_interruptible(&tty->write_wait);
        tty_wakeup(tty);
 }
 
@@ -1933,10 +1932,8 @@ static void bh_transmit(struct slgt_info *info)
        struct tty_struct *tty = info->tty;
 
        DBGBH(("%s bh_transmit\n", info->device_name));
-       if (tty) {
+       if (tty)
                tty_wakeup(tty);
-               wake_up_interruptible(&tty->write_wait);
-       }
 }
 
 static void dsr_change(struct slgt_info *info)
index 8f4d67afe5bf99fe1daea30940640b2c1cbbbe72..ebde4e55233560eacc7513de2571e3b0213a3c47 100644 (file)
@@ -1258,7 +1258,6 @@ static void flush_buffer(struct tty_struct *tty)
        del_timer(&info->tx_timer);
        spin_unlock_irqrestore(&info->lock,flags);
 
-       wake_up_interruptible(&tty->write_wait);
        tty_wakeup(tty);
 }
 
@@ -2127,10 +2126,8 @@ void bh_transmit(SLMP_INFO *info)
                printk( "%s(%d):%s bh_transmit() entry\n",
                        __FILE__,__LINE__,info->device_name);
 
-       if (tty) {
+       if (tty)
                tty_wakeup(tty);
-               wake_up_interruptible(&tty->write_wait);
-       }
 }
 
 void bh_status(SLMP_INFO *info)
index 7fd3cd5ddf2190269e206383ece44c481a889f78..3757610b7835d4952e992563821293e6cc781fcd 100644 (file)
@@ -88,9 +88,9 @@ static struct sysrq_key_op sysrq_loglevel_op = {
 #ifdef CONFIG_VT
 static void sysrq_handle_SAK(int key, struct tty_struct *tty)
 {
-       if (tty)
-               do_SAK(tty);
-       reset_vc(vc_cons[fg_console].d);
+       struct work_struct *SAK_work = &vc_cons[fg_console].SAK_work;
+       PREPARE_WORK(SAK_work, vc_SAK);
+       schedule_work(SAK_work);
 }
 static struct sysrq_key_op sysrq_SAK_op = {
        .handler        = sysrq_handle_SAK,
index 07067c31c4ec7344237ce33165e85760b88afebb..c346ec5a3dc9e3eff49a992cc074f61a6bef9786 100644 (file)
@@ -68,6 +68,7 @@
 #include <linux/init.h>
 #include <linux/stat.h>
 #include <linux/proc_fs.h>
+#include <linux/seq_file.h>
 
 #include <linux/toshiba.h>
 
@@ -298,12 +299,10 @@ static int tosh_ioctl(struct inode *ip, struct file *fp, unsigned int cmd,
  * Print the information for /proc/toshiba
  */
 #ifdef CONFIG_PROC_FS
-static int tosh_get_info(char *buffer, char **start, off_t fpos, int length)
+static int proc_toshiba_show(struct seq_file *m, void *v)
 {
-       char *temp;
        int key;
 
-       temp = buffer;
        key = tosh_fn_status();
 
        /* Arguments
@@ -314,8 +313,7 @@ static int tosh_get_info(char *buffer, char **start, off_t fpos, int length)
             4) BIOS date (in SCI date format)
             5) Fn Key status
        */
-
-       temp += sprintf(temp, "1.1 0x%04x %d.%d %d.%d 0x%04x 0x%02x\n",
+       seq_printf(m, "1.1 0x%04x %d.%d %d.%d 0x%04x 0x%02x\n",
                tosh_id,
                (tosh_sci & 0xff00)>>8,
                tosh_sci & 0xff,
@@ -323,9 +321,21 @@ static int tosh_get_info(char *buffer, char **start, off_t fpos, int length)
                tosh_bios & 0xff,
                tosh_date,
                key);
+       return 0;
+}
 
-       return temp-buffer;
+static int proc_toshiba_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, proc_toshiba_show, NULL);
 }
+
+static const struct file_operations proc_toshiba_fops = {
+       .owner          = THIS_MODULE,
+       .open           = proc_toshiba_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
 #endif
 
 
@@ -508,10 +518,15 @@ static int __init toshiba_init(void)
                return retval;
 
 #ifdef CONFIG_PROC_FS
-       /* register the proc entry */
-       if (create_proc_info_entry("toshiba", 0, NULL, tosh_get_info) == NULL) {
-               misc_deregister(&tosh_device);
-               return -ENOMEM;
+       {
+               struct proc_dir_entry *pde;
+
+               pde = create_proc_entry("toshiba", 0, NULL);
+               if (!pde) {
+                       misc_deregister(&tosh_device);
+                       return -ENOMEM;
+               }
+               pde->proc_fops = &proc_toshiba_fops;
        }
 #endif
 
index 47a6eacb10bc4c0c49dc54357be1f7adf9e36fd7..558ca927e32b1ebd4d9a7ea0c5b5b41b028b696b 100644 (file)
@@ -154,7 +154,7 @@ static int tty_release(struct inode *, struct file *);
 int tty_ioctl(struct inode * inode, struct file * file,
              unsigned int cmd, unsigned long arg);
 static int tty_fasync(int fd, struct file * filp, int on);
-static void release_mem(struct tty_struct *tty, int idx);
+static void release_tty(struct tty_struct *tty, int idx);
 
 /**
  *     alloc_tty_struct        -       allocate a tty object
@@ -1612,7 +1612,6 @@ void start_tty(struct tty_struct *tty)
 
        /* If we have a running line discipline it may need kicking */
        tty_wakeup(tty);
-       wake_up_interruptible(&tty->write_wait);
 }
 
 EXPORT_SYMBOL(start_tty);
@@ -2003,7 +2002,7 @@ static int init_dev(struct tty_driver *driver, int idx,
 
        /* 
         * All structures have been allocated, so now we install them.
-        * Failures after this point use release_mem to clean up, so 
+        * Failures after this point use release_tty to clean up, so
         * there's no need to null out the local pointers.
         */
        if (!(driver->flags & TTY_DRIVER_DEVPTS_MEM)) {
@@ -2024,8 +2023,8 @@ static int init_dev(struct tty_driver *driver, int idx,
 
        /* 
         * Structures all installed ... call the ldisc open routines.
-        * If we fail here just call release_mem to clean up.  No need
-        * to decrement the use counts, as release_mem doesn't care.
+        * If we fail here just call release_tty to clean up.  No need
+        * to decrement the use counts, as release_tty doesn't care.
         */
 
        if (tty->ldisc.open) {
@@ -2095,17 +2094,17 @@ fail_no_mem:
        retval = -ENOMEM;
        goto end_init;
 
-       /* call the tty release_mem routine to clean out this slot */
+       /* call the tty release_tty routine to clean out this slot */
 release_mem_out:
        if (printk_ratelimit())
                printk(KERN_INFO "init_dev: ldisc open failed, "
                                 "clearing slot %d\n", idx);
-       release_mem(tty, idx);
+       release_tty(tty, idx);
        goto end_init;
 }
 
 /**
- *     release_mem             -       release tty structure memory
+ *     release_one_tty         -       release tty structure memory
  *
  *     Releases memory associated with a tty structure, and clears out the
  *     driver table slots. This function is called when a device is no longer
@@ -2117,37 +2116,14 @@ release_mem_out:
  *     of ttys that the driver keeps.
  *             FIXME: should we require tty_mutex is held here ??
  */
-
-static void release_mem(struct tty_struct *tty, int idx)
+static void release_one_tty(struct tty_struct *tty, int idx)
 {
-       struct tty_struct *o_tty;
-       struct ktermios *tp;
        int devpts = tty->driver->flags & TTY_DRIVER_DEVPTS_MEM;
-
-       if ((o_tty = tty->link) != NULL) {
-               if (!devpts)
-                       o_tty->driver->ttys[idx] = NULL;
-               if (o_tty->driver->flags & TTY_DRIVER_RESET_TERMIOS) {
-                       tp = o_tty->termios;
-                       if (!devpts)
-                               o_tty->driver->termios[idx] = NULL;
-                       kfree(tp);
-
-                       tp = o_tty->termios_locked;
-                       if (!devpts)
-                               o_tty->driver->termios_locked[idx] = NULL;
-                       kfree(tp);
-               }
-               o_tty->magic = 0;
-               o_tty->driver->refcount--;
-               file_list_lock();
-               list_del_init(&o_tty->tty_files);
-               file_list_unlock();
-               free_tty_struct(o_tty);
-       }
+       struct ktermios *tp;
 
        if (!devpts)
                tty->driver->ttys[idx] = NULL;
+
        if (tty->driver->flags & TTY_DRIVER_RESET_TERMIOS) {
                tp = tty->termios;
                if (!devpts)
@@ -2160,15 +2136,39 @@ static void release_mem(struct tty_struct *tty, int idx)
                kfree(tp);
        }
 
+
        tty->magic = 0;
        tty->driver->refcount--;
+
        file_list_lock();
        list_del_init(&tty->tty_files);
        file_list_unlock();
-       module_put(tty->driver->owner);
+
        free_tty_struct(tty);
 }
 
+/**
+ *     release_tty             -       release tty structure memory
+ *
+ *     Release both @tty and a possible linked partner (think pty pair),
+ *     and decrement the refcount of the backing module.
+ *
+ *     Locking:
+ *             tty_mutex - sometimes only
+ *             takes the file list lock internally when working on the list
+ *     of ttys that the driver keeps.
+ *             FIXME: should we require tty_mutex is held here ??
+ */
+static void release_tty(struct tty_struct *tty, int idx)
+{
+       struct tty_driver *driver = tty->driver;
+
+       if (tty->link)
+               release_one_tty(tty->link, idx);
+       release_one_tty(tty, idx);
+       module_put(driver->owner);
+}
+
 /*
  * Even releasing the tty structures is a tricky business.. We have
  * to be very careful that the structures are all released at the
@@ -2436,10 +2436,10 @@ static void release_dev(struct file * filp)
                tty_set_termios_ldisc(o_tty,N_TTY); 
        }
        /*
-        * The release_mem function takes care of the details of clearing
+        * The release_tty function takes care of the details of clearing
         * the slots and preserving the termios structure.
         */
-       release_mem(tty, idx);
+       release_tty(tty, idx);
 
 #ifdef CONFIG_UNIX98_PTYS
        /* Make this pty number available for reallocation */
@@ -3324,10 +3324,8 @@ int tty_ioctl(struct inode * inode, struct file * file,
  * Nasty bug: do_SAK is being called in interrupt context.  This can
  * deadlock.  We punt it up to process context.  AKPM - 16Mar2001
  */
-static void __do_SAK(struct work_struct *work)
+void __do_SAK(struct tty_struct *tty)
 {
-       struct tty_struct *tty =
-               container_of(work, struct tty_struct, SAK_work);
 #ifdef TTY_SOFT_SAK
        tty_hangup(tty);
 #else
@@ -3394,6 +3392,13 @@ static void __do_SAK(struct work_struct *work)
 #endif
 }
 
+static void do_SAK_work(struct work_struct *work)
+{
+       struct tty_struct *tty =
+               container_of(work, struct tty_struct, SAK_work);
+       __do_SAK(tty);
+}
+
 /*
  * The tq handling here is a little racy - tty->SAK_work may already be queued.
  * Fortunately we don't need to worry, because if ->SAK_work is already queued,
@@ -3404,7 +3409,7 @@ void do_SAK(struct tty_struct *tty)
 {
        if (!tty)
                return;
-       PREPARE_WORK(&tty->SAK_work, __do_SAK);
+       PREPARE_WORK(&tty->SAK_work, do_SAK_work);
        schedule_work(&tty->SAK_work);
 }
 
index dee47f40c6a3878656f5bcacddcabd98c34da676..fd471cb3338fbd1d008c936f5d44cfe5691a952b 100644 (file)
@@ -225,7 +225,7 @@ EXPORT_SYMBOL(tty_termios_input_baud_rate);
 
 /**
  *     tty_termios_encode_baud_rate
- *     @termios: termios structure
+ *     @termios: ktermios structure holding user requested state
  *     @ispeed: input speed
  *     @ospeed: output speed
  *
@@ -233,7 +233,10 @@ EXPORT_SYMBOL(tty_termios_input_baud_rate);
  *     used as a library helper for drivers os that they can report back
  *     the actual speed selected when it differs from the speed requested
  *
- *     For now input and output speed must agree.
+ *     For maximal back compatibility with legacy SYS5/POSIX *nix behaviour
+ *     we need to carefully set the bits when the user does not get the
+ *     desired speed. We allow small margins and preserve as much of possible
+ *     of the input intent to keep compatiblity.
  *
  *     Locking: Caller should hold termios lock. This is already held
  *     when calling this function from the driver termios handler.
@@ -242,32 +245,44 @@ EXPORT_SYMBOL(tty_termios_input_baud_rate);
 void tty_termios_encode_baud_rate(struct ktermios *termios, speed_t ibaud, speed_t obaud)
 {
        int i = 0;
-       int ifound = 0, ofound = 0;
+       int ifound = -1, ofound = -1;
+       int iclose = ibaud/50, oclose = obaud/50;
+       int ibinput = 0;
 
        termios->c_ispeed = ibaud;
        termios->c_ospeed = obaud;
 
+       /* If the user asked for a precise weird speed give a precise weird
+          answer. If they asked for a Bfoo speed they many have problems
+          digesting non-exact replies so fuzz a bit */
+
+       if ((termios->c_cflag & CBAUD) == BOTHER)
+               oclose = 0;
+       if (((termios->c_cflag >> IBSHIFT) & CBAUD) == BOTHER)
+               iclose = 0;
+       if ((termios->c_cflag >> IBSHIFT) & CBAUD)
+               ibinput = 1;    /* An input speed was specified */
+
        termios->c_cflag &= ~CBAUD;
-       /* Identical speed means no input encoding (ie B0 << IBSHIFT)*/
-       if (termios->c_ispeed == termios->c_ospeed)
-               ifound = 1;
 
        do {
-               if (obaud == baud_table[i]) {
+               if (obaud - oclose >= baud_table[i] && obaud + oclose <= baud_table[i]) {
                        termios->c_cflag |= baud_bits[i];
-                       ofound = 1;
-                       /* So that if ibaud == obaud we don't set it */
-                       continue;
+                       ofound = i;
                }
-               if (ibaud == baud_table[i]) {
-                       termios->c_cflag |= (baud_bits[i] << IBSHIFT);
-                       ifound = 1;
+               if (ibaud - iclose >= baud_table[i] && ibaud + iclose <= baud_table[i]) {
+                       /* For the case input == output don't set IBAUD bits if the user didn't do so */
+                       if (ofound != i || ibinput)
+                               termios->c_cflag |= (baud_bits[i] << IBSHIFT);
+                       ifound = i;
                }
        }
        while(++i < n_baud_table);
-       if (!ofound)
+       if (ofound == -1)
                termios->c_cflag |= BOTHER;
-       if (!ifound)
+       /* Set exact input bits only if the input and output differ or the
+          user already did */
+       if (ifound == -1 && (ibaud != obaud  || ibinput))
                termios->c_cflag |= (BOTHER << IBSHIFT);
 }
 
index 06c32a3e3ca42603df7470008711d9cc7b4fa5e1..13299b8fdbd673218e01494982d5c0e8df50d9c2 100644 (file)
@@ -136,9 +136,6 @@ const struct consw *conswitchp;
 #define DEFAULT_BELL_PITCH     750
 #define DEFAULT_BELL_DURATION  (HZ/8)
 
-extern void vcs_make_sysfs(struct tty_struct *tty);
-extern void vcs_remove_sysfs(struct tty_struct *tty);
-
 struct vc vc_cons [MAX_NR_CONSOLES];
 
 #ifndef VT_SINGLE_DRIVER
index dc8368ebb1ac932c2a8b18427b7197bdab371d82..3a5d301e783b062617f3e7043b42670e33ca2be2 100644 (file)
@@ -672,7 +672,8 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
                vc->vt_mode = tmp;
                /* the frsig is ignored, so we set it to 0 */
                vc->vt_mode.frsig = 0;
-               put_pid(xchg(&vc->vt_pid, get_pid(task_pid(current))));
+               put_pid(vc->vt_pid);
+               vc->vt_pid = get_pid(task_pid(current));
                /* no switch is required -- saw@shade.msu.ru */
                vc->vt_newvt = -1;
                release_console_sem();
@@ -1063,12 +1064,35 @@ void reset_vc(struct vc_data *vc)
        vc->vt_mode.relsig = 0;
        vc->vt_mode.acqsig = 0;
        vc->vt_mode.frsig = 0;
-       put_pid(xchg(&vc->vt_pid, NULL));
+       put_pid(vc->vt_pid);
+       vc->vt_pid = NULL;
        vc->vt_newvt = -1;
        if (!in_interrupt())    /* Via keyboard.c:SAK() - akpm */
                reset_palette(vc);
 }
 
+void vc_SAK(struct work_struct *work)
+{
+       struct vc *vc_con =
+               container_of(work, struct vc, SAK_work);
+       struct vc_data *vc;
+       struct tty_struct *tty;
+
+       acquire_console_sem();
+       vc = vc_con->d;
+       if (vc) {
+               tty = vc->vc_tty;
+               /*
+                * SAK should also work in all raw modes and reset
+                * them properly.
+                */
+               if (tty)
+                       __do_SAK(tty);
+               reset_vc(vc);
+       }
+       release_console_sem();
+}
+
 /*
  * Performs the back end of a vt switch
  */
index 276577d08fba2f0f2791c1c1a03de69ad8feb5c2..4d730fdbd528cac4f84d78997045771a930d7b7b 100644 (file)
@@ -325,7 +325,7 @@ static int zf_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
                        return put_user(0, p);
 
                case WDIOC_KEEPALIVE:
-                       zf_ping(0);
+                       zf_ping(NULL);
                        break;
 
                default:
index 43a68398656f57f5c208897229de8249a557bc8e..31ea405f2eeb5fbe8d8fdb94b0f785f58729208f 100644 (file)
@@ -457,7 +457,7 @@ static struct pci_driver geode_aes_driver = {
 static int __init
 geode_aes_init(void)
 {
-       return pci_module_init(&geode_aes_driver);
+       return pci_register_driver(&geode_aes_driver);
 }
 
 static void __exit
index 5c261e1f92b271e17094b05242c93959503dbad4..d8806e4f182984c841603d8d3d365c77d98c6cec 100644 (file)
@@ -233,6 +233,8 @@ edd_show_interface(struct edd_device *edev, char *buf)
 
 /**
  * edd_show_raw_data() - copies raw data to buffer for userspace to parse
+ * @edev: target edd_device
+ * @buf: output buffer
  *
  * Returns: number of bytes written, or -EINVAL on failure
  */
@@ -634,8 +636,8 @@ static decl_subsys(edd,&ktype_edd,NULL);
 
 /**
  * edd_dev_is_type() - is this EDD device a 'type' device?
- * @edev
- * @type - a host bus or interface identifier string per the EDD spec
+ * @edev: target edd_device
+ * @type: a host bus or interface identifier string per the EDD spec
  *
  * Returns 1 (TRUE) if it is a 'type' device, 0 otherwise.
  */
@@ -657,7 +659,7 @@ edd_dev_is_type(struct edd_device *edev, const char *type)
 
 /**
  * edd_get_pci_dev() - finds pci_dev that matches edev
- * @edev - edd_device
+ * @edev: edd_device
  *
  * Returns pci_dev if found, or NULL
  */
index f126aa4851346563b0e75fc6b2ee1db42e8746c6..18210164e307621c7edf41b3f51d221988b0899d 100644 (file)
@@ -153,7 +153,7 @@ int ams_input_init(void)
 }
 
 /* Call with ams_info.lock held! */
-void ams_input_exit()
+void ams_input_exit(void)
 {
        ams_input_disable();
        device_remove_file(&ams_info.of_dev->dev, &dev_attr_joystick);
index aa049dab3d95c17609f3a1d54621f18a01896749..ad49bd823ebd11548696e43c66ee7392ac5a8306 100644 (file)
@@ -413,7 +413,6 @@ void ide_add_proc_entries(struct proc_dir_entry *dir, ide_proc_entry_t *p, void
        while (p->name != NULL) {
                ent = create_proc_entry(p->name, p->mode, dir);
                if (!ent) return;
-               ent->nlink = 1;
                ent->data = data;
                ent->read_proc = p->read_proc;
                ent->write_proc = p->write_proc;
diff --git a/drivers/ieee1394/.gitignore b/drivers/ieee1394/.gitignore
deleted file mode 100644 (file)
index 33da10a..0000000
+++ /dev/null
@@ -1 +0,0 @@
-oui.c
index e7d56573fe5627fcd4c35b13d1d4f973b6248d09..b8a47342cd2ca33c08ccf20180e66f44c754d331 100644 (file)
@@ -35,20 +35,6 @@ config IEEE1394_VERBOSEDEBUG
          Say Y if you really want or need the debugging output, everyone
          else says N.
 
-config IEEE1394_OUI_DB
-       bool "OUI Database built-in (deprecated)"
-       depends on IEEE1394
-       help
-         If you say Y here, then an OUI list (vendor unique ID's) will be
-         compiled into the ieee1394 module. This doesn't really do much
-         except being able to display the vendor of a hardware node. The
-         downside is that it adds about 300k to the size of the module,
-         or kernel (depending on whether you compile ieee1394 as a
-         module, or static in the kernel).
-
-         This option is not needed for userspace programs like gscanbus
-         to show this information.
-
 config IEEE1394_EXTRA_CONFIG_ROMS
        bool "Build in extra config rom entries for certain functionality"
        depends on IEEE1394
@@ -66,13 +52,6 @@ config IEEE1394_CONFIG_ROM_IP1394
          with MacOSX and WinXP IP-over-1394), enable this option and the
          eth1394 option below.
 
-config IEEE1394_EXPORT_FULL_API
-       bool "Export all symbols of ieee1394's API (deprecated)"
-       depends on IEEE1394
-       default n
-       help
-         This option will be removed soon.  Don't worry, say N.
-
 comment "Device Drivers"
        depends on IEEE1394
 
index d9650d3d77a004b383637217db95d21e8f46a164..489c133664d5a1d7c9db7bbdf40dc244704402c4 100644 (file)
@@ -5,9 +5,6 @@
 ieee1394-objs := ieee1394_core.o ieee1394_transactions.o hosts.o \
                 highlevel.o csr.o nodemgr.o dma.o iso.o \
                 csr1212.o config_roms.o
-ifdef CONFIG_IEEE1394_OUI_DB
-ieee1394-objs += oui.o
-endif
 
 obj-$(CONFIG_IEEE1394) += ieee1394.o
 obj-$(CONFIG_IEEE1394_PCILYNX) += pcilynx.o
@@ -18,10 +15,3 @@ obj-$(CONFIG_IEEE1394_SBP2) += sbp2.o
 obj-$(CONFIG_IEEE1394_DV1394) += dv1394.o
 obj-$(CONFIG_IEEE1394_ETH1394) += eth1394.o
 
-quiet_cmd_oui2c = OUI2C   $@
-      cmd_oui2c = $(CONFIG_SHELL) $(srctree)/$(src)/oui2c.sh < $< > $@
-
-targets := oui.c
-$(obj)/oui.o: $(obj)/oui.c
-$(obj)/oui.c: $(src)/oui.db $(src)/oui2c.sh FORCE
-       $(call if_changed,oui2c)
index 586f71e7346a5e7d8fcfbbcb06a4bac543cf7124..c28f639823d238c187f31daca9552f88c6ec188b 100644 (file)
 #define __D (1 << CSR1212_KV_TYPE_DIRECTORY)
 #define __L (1 << CSR1212_KV_TYPE_LEAF)
 static const u_int8_t csr1212_key_id_type_map[0x30] = {
-       0,                      /* Reserved */
+       __C,                    /* used by Apple iSight */
        __D | __L,              /* Descriptor */
        __I | __D | __L,        /* Bus_Dependent_Info */
        __I | __D | __L,        /* Vendor */
        __I,                    /* Hardware_Version */
        0, 0,                   /* Reserved */
-       __D | __L,              /* Module */
-       0, 0, 0, 0,             /* Reserved */
+       __D | __L | __I,        /* Module */
+       __I, 0, 0, 0,           /* used by Apple iSight, Reserved */
        __I,                    /* Node_Capabilities */
        __L,                    /* EUI_64 */
        0, 0, 0,                /* Reserved */
@@ -1234,6 +1234,12 @@ static int csr1212_parse_bus_info_block(struct csr1212_csr *csr)
                                         csr->private);
                if (ret != CSR1212_SUCCESS)
                        return ret;
+
+               /* check ROM header's info_length */
+               if (i == 0 &&
+                   CSR1212_BE32_TO_CPU(csr->cache_head->data[0]) >> 24 !=
+                   bytes_to_quads(csr->bus_info_len) - 1)
+                       return CSR1212_EINVAL;
        }
 
        bi = (struct csr1212_bus_info_block_img*)csr->cache_head->data;
@@ -1250,9 +1256,6 @@ static int csr1212_parse_bus_info_block(struct csr1212_csr *csr)
                        return ret;
        }
 
-       if (bytes_to_quads(csr->bus_info_len - sizeof(csr1212_quad_t)) != bi->length)
-               return CSR1212_EINVAL;
-
 #if 0
        /* Apparently there are too many differnt wrong implementations of the
         * CRC algorithm that verifying them is moot. */
index 1084da4d88a9d68799954ecac8e0a70eedf9b9d2..55d6ae664fd621639815a6c06b266e4348a19cc3 100644 (file)
@@ -2255,49 +2255,37 @@ static int dv1394_init(struct ti_ohci *ohci, enum pal_or_ntsc format, enum modes
        return 0;
 }
 
-static void dv1394_un_init(struct video_card *video)
+static void dv1394_remove_host(struct hpsb_host *host)
 {
-       /* obviously nobody has the driver open at this point */
-       do_dv1394_shutdown(video, 1);
-       kfree(video);
-}
-
-
-static void dv1394_remove_host (struct hpsb_host *host)
-{
-       struct video_card *video;
+       struct video_card *video, *tmp_video;
        unsigned long flags;
-       int id = host->id;
+       int found_ohci_card = 0;
 
-       /* We only work with the OHCI-1394 driver */
-       if (strcmp(host->driver->name, OHCI1394_DRIVER_NAME))
-               return;
-
-       /* find the corresponding video_cards */
        do {
-               struct video_card *tmp_vid;
-
                video = NULL;
-
                spin_lock_irqsave(&dv1394_cards_lock, flags);
-               list_for_each_entry(tmp_vid, &dv1394_cards, list) {
-                       if ((tmp_vid->id >> 2) == id) {
-                               list_del(&tmp_vid->list);
-                               video = tmp_vid;
+               list_for_each_entry(tmp_video, &dv1394_cards, list) {
+                       if ((tmp_video->id >> 2) == host->id) {
+                               list_del(&tmp_video->list);
+                               video = tmp_video;
+                               found_ohci_card = 1;
                                break;
                        }
                }
                spin_unlock_irqrestore(&dv1394_cards_lock, flags);
 
-               if (video)
-                       dv1394_un_init(video);
-       } while (video != NULL);
+               if (video) {
+                       do_dv1394_shutdown(video, 1);
+                       kfree(video);
+               }
+       } while (video);
 
-       class_device_destroy(hpsb_protocol_class,
-               MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_DV1394 * 16 + (id<<2)));
+       if (found_ohci_card)
+               class_device_destroy(hpsb_protocol_class, MKDEV(IEEE1394_MAJOR,
+                          IEEE1394_MINOR_BLOCK_DV1394 * 16 + (host->id << 2)));
 }
 
-static void dv1394_add_host (struct hpsb_host *host)
+static void dv1394_add_host(struct hpsb_host *host)
 {
        struct ti_ohci *ohci;
        int id = host->id;
index ee82a5320bf7b5c353db56485c2b1ab31f673b33..32a1309219384537a21b8f8a6f972affb5a7d33b 100644 (file)
@@ -190,14 +190,19 @@ int hpsb_add_host(struct hpsb_host *host)
 {
        if (hpsb_default_host_entry(host))
                return -ENOMEM;
-
        hpsb_add_extra_config_roms(host);
-
        highlevel_add_host(host);
-
        return 0;
 }
 
+void hpsb_resume_host(struct hpsb_host *host)
+{
+       if (host->driver->set_hw_config_rom)
+               host->driver->set_hw_config_rom(host,
+                                               host->csr.rom->bus_info_data);
+       host->driver->devctl(host, RESET_BUS, SHORT_RESET);
+}
+
 void hpsb_remove_host(struct hpsb_host *host)
 {
        host->is_shutdown = 1;
@@ -206,9 +211,7 @@ void hpsb_remove_host(struct hpsb_host *host)
        flush_scheduled_work();
 
        host->driver = &dummy_driver;
-
        highlevel_remove_host(host);
-
        hpsb_remove_extra_config_roms(host);
 
        class_device_unregister(&host->class_dev);
index d553e38c95432c95d593d764472626b4e22f6a30..4bf4fb7f67b741dc12471c92f899aa433307ef13 100644 (file)
@@ -61,9 +61,9 @@ struct hpsb_host {
        struct device device;
        struct class_device class_dev;
 
-       int update_config_rom;
        struct delayed_work delayed_reset;
-       unsigned int config_roms;
+       unsigned config_roms:31;
+       unsigned update_config_rom:1;
 
        struct list_head addr_space;
        u64 low_addr_space;     /* upper bound of physical DMA area */
@@ -200,7 +200,8 @@ struct hpsb_host_driver {
 struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra,
                                  struct device *dev);
 int hpsb_add_host(struct hpsb_host *host);
-void hpsb_remove_host(struct hpsb_host *h);
+void hpsb_resume_host(struct hpsb_host *host);
+void hpsb_remove_host(struct hpsb_host *host);
 
 /* Updates the configuration rom image of a host.  rom_version must be the
  * current version, otherwise it will fail with return value -1. If this
index 9a48ca20d1fd0dfdc788a6c78f465340f378b601..1521e57e124bb63119b705804f8ff81d41ed77ed 100644 (file)
@@ -1178,6 +1178,7 @@ module_exit(ieee1394_cleanup);
 /** hosts.c **/
 EXPORT_SYMBOL(hpsb_alloc_host);
 EXPORT_SYMBOL(hpsb_add_host);
+EXPORT_SYMBOL(hpsb_resume_host);
 EXPORT_SYMBOL(hpsb_remove_host);
 EXPORT_SYMBOL(hpsb_update_config_rom_image);
 
@@ -1195,10 +1196,6 @@ EXPORT_SYMBOL(hpsb_selfid_complete);
 EXPORT_SYMBOL(hpsb_packet_sent);
 EXPORT_SYMBOL(hpsb_packet_received);
 EXPORT_SYMBOL_GPL(hpsb_disable_irm);
-#ifdef CONFIG_IEEE1394_EXPORT_FULL_API
-EXPORT_SYMBOL(hpsb_send_phy_config);
-EXPORT_SYMBOL(hpsb_send_packet_and_wait);
-#endif
 
 /** ieee1394_transactions.c **/
 EXPORT_SYMBOL(hpsb_get_tlabel);
@@ -1229,20 +1226,12 @@ EXPORT_SYMBOL(hpsb_set_hostinfo_key);
 EXPORT_SYMBOL(hpsb_get_hostinfo_bykey);
 EXPORT_SYMBOL(hpsb_set_hostinfo);
 EXPORT_SYMBOL(highlevel_host_reset);
-#ifdef CONFIG_IEEE1394_EXPORT_FULL_API
-EXPORT_SYMBOL(highlevel_add_host);
-EXPORT_SYMBOL(highlevel_remove_host);
-#endif
 
 /** nodemgr.c **/
 EXPORT_SYMBOL(hpsb_node_fill_packet);
 EXPORT_SYMBOL(hpsb_node_write);
 EXPORT_SYMBOL(__hpsb_register_protocol);
 EXPORT_SYMBOL(hpsb_unregister_protocol);
-#ifdef CONFIG_IEEE1394_EXPORT_FULL_API
-EXPORT_SYMBOL(ieee1394_bus_type);
-EXPORT_SYMBOL(nodemgr_for_each_host);
-#endif
 
 /** csr.c **/
 EXPORT_SYMBOL(hpsb_update_config_rom);
@@ -1287,13 +1276,3 @@ EXPORT_SYMBOL(csr1212_read);
 EXPORT_SYMBOL(csr1212_parse_keyval);
 EXPORT_SYMBOL(_csr1212_read_keyval);
 EXPORT_SYMBOL(_csr1212_destroy_keyval);
-#ifdef CONFIG_IEEE1394_EXPORT_FULL_API
-EXPORT_SYMBOL(csr1212_create_csr);
-EXPORT_SYMBOL(csr1212_init_local_csr);
-EXPORT_SYMBOL(csr1212_new_immediate);
-EXPORT_SYMBOL(csr1212_associate_keyval);
-EXPORT_SYMBOL(csr1212_new_string_descriptor_leaf);
-EXPORT_SYMBOL(csr1212_destroy_csr);
-EXPORT_SYMBOL(csr1212_generate_csr_image);
-EXPORT_SYMBOL(csr1212_parse_csr);
-#endif
index 61307ca296ae4745c26c2242d24aae238c2361a5..ba9faeff4793a0a5891493380ff6fb3b5e3278fb 100644 (file)
@@ -41,22 +41,6 @@ struct nodemgr_csr_info {
 };
 
 
-static char *nodemgr_find_oui_name(int oui)
-{
-#ifdef CONFIG_IEEE1394_OUI_DB
-       extern struct oui_list_struct {
-               int oui;
-               char *name;
-       } oui_list[];
-       int i;
-
-       for (i = 0; oui_list[i].name; i++)
-               if (oui_list[i].oui == oui)
-                       return oui_list[i].name;
-#endif
-       return NULL;
-}
-
 /*
  * Correct the speed map entry.  This is necessary
  *  - for nodes with link speed < phy speed,
@@ -274,7 +258,6 @@ static struct device_driver nodemgr_mid_layer_driver = {
 struct device nodemgr_dev_template_host = {
        .bus            = &ieee1394_bus_type,
        .release        = nodemgr_release_host,
-       .driver         = &nodemgr_mid_layer_driver,
 };
 
 
@@ -473,11 +456,9 @@ fw_attr(ne, struct node_entry, nodeid, unsigned int, "0x%04x\n")
 
 fw_attr(ne, struct node_entry, vendor_id, unsigned int, "0x%06x\n")
 fw_attr_td(ne, struct node_entry, vendor_name_kv)
-fw_attr(ne, struct node_entry, vendor_oui, const char *, "%s\n")
 
 fw_attr(ne, struct node_entry, guid, unsigned long long, "0x%016Lx\n")
 fw_attr(ne, struct node_entry, guid_vendor_id, unsigned int, "0x%06x\n")
-fw_attr(ne, struct node_entry, guid_vendor_oui, const char *, "%s\n")
 fw_attr(ne, struct node_entry, in_limbo, int, "%d\n");
 
 static struct device_attribute *const fw_ne_attrs[] = {
@@ -503,7 +484,6 @@ fw_attr(ud, struct unit_directory, model_id, unsigned int, "0x%06x\n")
 fw_attr(ud, struct unit_directory, specifier_id, unsigned int, "0x%06x\n")
 fw_attr(ud, struct unit_directory, version, unsigned int, "0x%06x\n")
 fw_attr_td(ud, struct unit_directory, vendor_name_kv)
-fw_attr(ud, struct unit_directory, vendor_oui, const char *, "%s\n")
 fw_attr_td(ud, struct unit_directory, model_name_kv)
 
 static struct device_attribute *const fw_ud_attrs[] = {
@@ -865,7 +845,6 @@ static struct node_entry *nodemgr_create_node(octlet_t guid, struct csr1212_csr
 
        ne->guid = guid;
        ne->guid_vendor_id = (guid >> 40) & 0xffffff;
-       ne->guid_vendor_oui = nodemgr_find_oui_name(ne->guid_vendor_id);
        ne->csr = csr;
 
        memcpy(&ne->device, &nodemgr_dev_template_ne,
@@ -885,9 +864,6 @@ static struct node_entry *nodemgr_create_node(octlet_t guid, struct csr1212_csr
                goto fail_classdevreg;
        get_device(&ne->device);
 
-       if (ne->guid_vendor_oui &&
-           device_create_file(&ne->device, &dev_attr_ne_guid_vendor_oui))
-               goto fail_addoiu;
        nodemgr_create_ne_dev_files(ne);
 
        nodemgr_update_bus_options(ne);
@@ -898,8 +874,6 @@ static struct node_entry *nodemgr_create_node(octlet_t guid, struct csr1212_csr
 
        return ne;
 
-fail_addoiu:
-       put_device(&ne->device);
 fail_classdevreg:
        device_unregister(&ne->device);
 fail_devreg:
@@ -975,15 +949,10 @@ static void nodemgr_register_device(struct node_entry *ne,
                goto fail_classdevreg;
        get_device(&ud->device);
 
-       if (ud->vendor_oui &&
-           device_create_file(&ud->device, &dev_attr_ud_vendor_oui))
-               goto fail_addoui;
        nodemgr_create_ud_dev_files(ud);
 
        return;
 
-fail_addoui:
-       put_device(&ud->device);
 fail_classdevreg:
        device_unregister(&ud->device);
 fail_devreg:
@@ -1020,9 +989,6 @@ static struct unit_directory *nodemgr_process_unit_directory
                        if (kv->key.type == CSR1212_KV_TYPE_IMMEDIATE) {
                                ud->vendor_id = kv->value.immediate;
                                ud->flags |= UNIT_DIRECTORY_VENDOR_ID;
-
-                               if (ud->vendor_id)
-                                       ud->vendor_oui = nodemgr_find_oui_name(ud->vendor_id);
                        }
                        break;
 
@@ -1153,9 +1119,6 @@ static void nodemgr_process_root_directory(struct host_info *hi, struct node_ent
                switch (kv->key.id) {
                case CSR1212_KV_ID_VENDOR:
                        ne->vendor_id = kv->value.immediate;
-
-                       if (ne->vendor_id)
-                               ne->vendor_oui = nodemgr_find_oui_name(ne->vendor_id);
                        break;
 
                case CSR1212_KV_ID_NODE_CAPABILITIES:
@@ -1183,9 +1146,6 @@ static void nodemgr_process_root_directory(struct host_info *hi, struct node_ent
                last_key_id = kv->key.id;
        }
 
-       if (ne->vendor_oui &&
-           device_create_file(&ne->device, &dev_attr_ne_vendor_oui))
-               goto fail;
        if (ne->vendor_name_kv &&
            device_create_file(&ne->device, &dev_attr_ne_vendor_name_kv))
                goto fail;
@@ -1889,22 +1849,31 @@ int init_ieee1394_nodemgr(void)
 
        error = class_register(&nodemgr_ne_class);
        if (error)
-               return error;
-
+               goto fail_ne;
        error = class_register(&nodemgr_ud_class);
-       if (error) {
-               class_unregister(&nodemgr_ne_class);
-               return error;
-       }
+       if (error)
+               goto fail_ud;
        error = driver_register(&nodemgr_mid_layer_driver);
+       if (error)
+               goto fail_ml;
+       /* This driver is not used if nodemgr is off (disable_nodemgr=1). */
+       nodemgr_dev_template_host.driver = &nodemgr_mid_layer_driver;
+
        hpsb_register_highlevel(&nodemgr_highlevel);
        return 0;
+
+fail_ml:
+       class_unregister(&nodemgr_ud_class);
+fail_ud:
+       class_unregister(&nodemgr_ne_class);
+fail_ne:
+       return error;
 }
 
 void cleanup_ieee1394_nodemgr(void)
 {
        hpsb_unregister_highlevel(&nodemgr_highlevel);
-
+       driver_unregister(&nodemgr_mid_layer_driver);
        class_unregister(&nodemgr_ud_class);
        class_unregister(&nodemgr_ne_class);
 }
index e25cbadb8be0144e4a1bea0326c23b96bcfce16f..4147303ad448dcb0b9ce4771bba34a0330e53a20 100644 (file)
@@ -70,7 +70,6 @@ struct unit_directory {
 
        quadlet_t vendor_id;
        struct csr1212_keyval *vendor_name_kv;
-       const char *vendor_oui;
 
        quadlet_t model_id;
        struct csr1212_keyval *model_name_kv;
@@ -93,7 +92,6 @@ struct unit_directory {
 struct node_entry {
        u64 guid;                       /* GUID of this node */
        u32 guid_vendor_id;             /* Top 24bits of guid */
-       const char *guid_vendor_oui;    /* OUI name of guid vendor id */
 
        struct hpsb_host *host;         /* Host this node is attached to */
        nodeid_t nodeid;                /* NodeID */
@@ -104,7 +102,6 @@ struct node_entry {
        /* The following is read from the config rom */
        u32 vendor_id;
        struct csr1212_keyval *vendor_name_kv;
-       const char *vendor_oui;
 
        u32 capabilities;
 
index 628130a58af3fe9205750bdf4b68eb225815fbaa..5729e412cc4aaeeb76621a0eb1848e5280eef4ab 100644 (file)
@@ -3281,14 +3281,11 @@ static int __devinit ohci1394_pci_probe(struct pci_dev *dev,
                PRINT(KERN_WARNING, "PCI resource length of 0x%llx too small!",
                      (unsigned long long)pci_resource_len(dev, 0));
 
-       /* Seems PCMCIA handles this internally. Not sure why. Seems
-        * pretty bogus to force a driver to special case this.  */
-#ifndef PCMCIA
-       if (!request_mem_region (ohci_base, OHCI1394_REGISTER_SIZE, OHCI1394_DRIVER_NAME))
+       if (!request_mem_region(ohci_base, OHCI1394_REGISTER_SIZE,
+                               OHCI1394_DRIVER_NAME))
                FAIL(-ENOMEM, "MMIO resource (0x%llx - 0x%llx) unavailable",
                        (unsigned long long)ohci_base,
                        (unsigned long long)ohci_base + OHCI1394_REGISTER_SIZE);
-#endif
        ohci->init_state = OHCI_INIT_HAVE_MEM_REGION;
 
        ohci->registers = ioremap(ohci_base, OHCI1394_REGISTER_SIZE);
@@ -3509,10 +3506,8 @@ static void ohci1394_pci_remove(struct pci_dev *pdev)
                iounmap(ohci->registers);
 
        case OHCI_INIT_HAVE_MEM_REGION:
-#ifndef PCMCIA
                release_mem_region(pci_resource_start(ohci->dev, 0),
                                   OHCI1394_REGISTER_SIZE);
-#endif
 
 #ifdef CONFIG_PPC_PMAC
        /* On UniNorth, power down the cable and turn off the chip clock
@@ -3541,9 +3536,6 @@ static int ohci1394_pci_suspend(struct pci_dev *pdev, pm_message_t state)
        int err;
        struct ti_ohci *ohci = pci_get_drvdata(pdev);
 
-       printk(KERN_INFO "%s does not fully support suspend and resume yet\n",
-              OHCI1394_DRIVER_NAME);
-
        if (!ohci) {
                printk(KERN_ERR "%s: tried to suspend nonexisting host\n",
                       OHCI1394_DRIVER_NAME);
@@ -3630,15 +3622,14 @@ static int ohci1394_pci_resume(struct pci_dev *pdev)
        mdelay(50);
        ohci_initialize(ohci);
 
+       hpsb_resume_host(ohci->host);
        return 0;
 }
 #endif /* CONFIG_PM */
 
-#define PCI_CLASS_FIREWIRE_OHCI     ((PCI_CLASS_SERIAL_FIREWIRE << 8) | 0x10)
-
 static struct pci_device_id ohci1394_pci_tbl[] = {
        {
-               .class =        PCI_CLASS_FIREWIRE_OHCI,
+               .class =        PCI_CLASS_SERIAL_FIREWIRE_OHCI,
                .class_mask =   PCI_ANY_ID,
                .vendor =       PCI_ANY_ID,
                .device =       PCI_ANY_ID,
diff --git a/drivers/ieee1394/oui.db b/drivers/ieee1394/oui.db
deleted file mode 100644 (file)
index 592c8a6..0000000
+++ /dev/null
@@ -1,7048 +0,0 @@
-000000 XEROX CORPORATION
-000001 XEROX CORPORATION
-000002 XEROX CORPORATION
-000003 XEROX CORPORATION
-000004 XEROX CORPORATION
-000005 XEROX CORPORATION
-000006 XEROX CORPORATION
-000007 XEROX CORPORATION
-000008 XEROX CORPORATION
-000009 XEROX CORPORATION
-00000A OMRON TATEISI ELECTRONICS CO.
-00000B MATRIX CORPORATION
-00000C CISCO SYSTEMS, INC.
-00000D FIBRONICS LTD.
-00000E FUJITSU LIMITED
-00000F NEXT, INC.
-000010 SYTEK INC.
-000011 NORMEREL SYSTEMES
-000012 INFORMATION TECHNOLOGY LIMITED
-000013 CAMEX
-000014 NETRONIX
-000015 DATAPOINT CORPORATION
-000016 DU PONT PIXEL SYSTEMS     .
-000017 TEKELEC
-000018 WEBSTER COMPUTER CORPORATION
-000019 APPLIED DYNAMICS INTERNATIONAL
-00001A ADVANCED MICRO DEVICES
-00001B NOVELL INC.
-00001C BELL TECHNOLOGIES
-00001D CABLETRON SYSTEMS, INC.
-00001E TELSIST INDUSTRIA ELECTRONICA
-00001F Telco Systems, Inc.
-000020 DATAINDUSTRIER DIAB AB
-000021 SUREMAN COMP. & COMMUN. CORP.
-000022 VISUAL TECHNOLOGY INC.
-000023 ABB INDUSTRIAL SYSTEMS AB
-000024 CONNECT AS
-000025 RAMTEK CORP.
-000026 SHA-KEN CO., LTD.
-000027 JAPAN RADIO COMPANY
-000028 PRODIGY SYSTEMS CORPORATION
-000029 IMC NETWORKS CORP.
-00002A TRW - SEDD/INP
-00002B CRISP AUTOMATION, INC
-00002C AUTOTOTE LIMITED
-00002D CHROMATICS INC
-00002E SOCIETE EVIRA
-00002F TIMEPLEX INC.
-000030 VG LABORATORY SYSTEMS LTD
-000031 QPSX COMMUNICATIONS PTY LTD
-000032 Marconi plc
-000033 EGAN MACHINERY COMPANY
-000034 NETWORK RESOURCES CORPORATION
-000035 SPECTRAGRAPHICS CORPORATION
-000036 ATARI CORPORATION
-000037 OXFORD METRICS LIMITED
-000038 CSS LABS
-000039 TOSHIBA CORPORATION
-00003A CHYRON CORPORATION
-00003B i Controls, Inc.
-00003C AUSPEX SYSTEMS INC.
-00003D UNISYS
-00003E SIMPACT
-00003F SYNTREX, INC.
-000040 APPLICON, INC.
-000041 ICE CORPORATION
-000042 METIER MANAGEMENT SYSTEMS LTD.
-000043 MICRO TECHNOLOGY
-000044 CASTELLE CORPORATION
-000045 FORD AEROSPACE & COMM. CORP.
-000046 OLIVETTI NORTH AMERICA
-000047 NICOLET INSTRUMENTS CORP.
-000048 SEIKO EPSON CORPORATION
-000049 APRICOT COMPUTERS, LTD
-00004A ADC CODENOLL TECHNOLOGY CORP.
-00004B ICL DATA OY
-00004C NEC CORPORATION
-00004D DCI CORPORATION
-00004E AMPEX CORPORATION
-00004F LOGICRAFT, INC.
-000050 RADISYS CORPORATION
-000051 HOB ELECTRONIC GMBH & CO. KG
-000052 Intrusion.com, Inc.
-000053 COMPUCORP
-000054 MODICON, INC.
-000055 COMMISSARIAT A L`ENERGIE ATOM.
-000056 DR. B. STRUCK
-000057 SCITEX CORPORATION LTD.
-000058 RACORE COMPUTER PRODUCTS INC.
-000059 HELLIGE GMBH
-00005A SysKonnect GmbH
-00005B ELTEC ELEKTRONIK AG
-00005C TELEMATICS INTERNATIONAL INC.
-00005D CS TELECOM
-00005E USC INFORMATION SCIENCES INST
-00005F SUMITOMO ELECTRIC IND., LTD.
-000060 KONTRON ELEKTRONIK GMBH
-000061 GATEWAY COMMUNICATIONS
-000062 BULL HN INFORMATION SYSTEMS
-000063 DR.ING.SEUFERT GMBH
-000064 YOKOGAWA DIGITAL COMPUTER CORP
-000065 NETWORK ASSOCIATES, INC.
-000066 TALARIS SYSTEMS, INC.
-000067 SOFT * RITE, INC.
-000068 ROSEMOUNT CONTROLS
-000069 CONCORD COMMUNICATIONS INC
-00006A COMPUTER CONSOLES INC.
-00006B SILICON GRAPHICS INC./MIPS
-00006D CRAY COMMUNICATIONS, LTD.
-00006E ARTISOFT, INC.
-00006F Madge Ltd.
-000070 HCL LIMITED
-000071 ADRA SYSTEMS INC.
-000072 MINIWARE TECHNOLOGY
-000073 SIECOR CORPORATION
-000074 RICOH COMPANY LTD.
-000075 Nortel Networks
-000076 ABEKAS VIDEO SYSTEM
-000077 INTERPHASE CORPORATION
-000078 LABTAM LIMITED
-000079 NETWORTH INCORPORATED
-00007A DANA COMPUTER INC.
-00007B RESEARCH MACHINES
-00007C AMPERE INCORPORATED
-00007D SUN MICROSYSTEMS, INC.
-00007E CLUSTRIX CORPORATION
-00007F LINOTYPE-HELL AG
-000080 CRAY COMMUNICATIONS A/S
-000081 BAY NETWORKS
-000082 LECTRA SYSTEMES SA
-000083 TADPOLE TECHNOLOGY PLC
-000084 SUPERNET
-000085 CANON INC.
-000086 MEGAHERTZ CORPORATION
-000087 HITACHI, LTD.
-000088 COMPUTER NETWORK TECH. CORP.
-000089 CAYMAN SYSTEMS INC.
-00008A DATAHOUSE INFORMATION SYSTEMS
-00008B INFOTRON
-00008C Alloy Computer Products (Australia) Pty Ltd
-00008D VERDIX CORPORATION
-00008E SOLBOURNE COMPUTER, INC.
-00008F RAYTHEON COMPANY
-000090 MICROCOM
-000091 ANRITSU CORPORATION
-000092 COGENT DATA TECHNOLOGIES
-000093 PROTEON INC.
-000094 ASANTE TECHNOLOGIES
-000095 SONY TEKTRONIX CORP.
-000096 MARCONI ELECTRONICS LTD.
-000097 EPOCH SYSTEMS
-000098 CROSSCOMM CORPORATION
-000099 MTX, INC.
-00009A RC COMPUTER A/S
-00009B INFORMATION INTERNATIONAL, INC
-00009C ROLM MIL-SPEC COMPUTERS
-00009D LOCUS COMPUTING CORPORATION
-00009E MARLI S.A.
-00009F AMERISTAR TECHNOLOGIES INC.
-0000A0 TOKYO SANYO ELECTRIC CO. LTD.
-0000A1 MARQUETTE ELECTRIC CO.
-0000A2 BAY NETWORKS
-0000A3 NETWORK APPLICATION TECHNOLOGY
-0000A4 ACORN COMPUTERS LIMITED
-0000A5 COMPATIBLE SYSTEMS CORP.
-0000A6 NETWORK GENERAL CORPORATION
-0000A7 NETWORK COMPUTING DEVICES INC.
-0000A8 STRATUS COMPUTER INC.
-0000A9 NETWORK SYSTEMS CORP.
-0000AA XEROX CORPORATION
-0000AB LOGIC MODELING CORPORATION
-0000AC CONWARE COMPUTER CONSULTING
-0000AD BRUKER INSTRUMENTS INC.
-0000AE DASSAULT ELECTRONIQUE
-0000AF NUCLEAR DATA INSTRUMENTATION
-0000B0 RND-RAD NETWORK DEVICES
-0000B1 ALPHA MICROSYSTEMS INC.
-0000B2 TELEVIDEO SYSTEMS, INC.
-0000B3 CIMLINC INCORPORATED
-0000B4 EDIMAX COMPUTER COMPANY
-0000B5 DATABILITY SOFTWARE SYS. INC.
-0000B6 MICRO-MATIC RESEARCH
-0000B7 DOVE COMPUTER CORPORATION
-0000B8 SEIKOSHA CO., LTD.
-0000B9 MCDONNELL DOUGLAS COMPUTER SYS
-0000BA SIIG, INC.
-0000BB TRI-DATA
-0000BC ALLEN-BRADLEY CO. INC.
-0000BD MITSUBISHI CABLE COMPANY
-0000BE THE NTI GROUP
-0000BF SYMMETRIC COMPUTER SYSTEMS
-0000C0 WESTERN DIGITAL CORPORATION
-0000C1 Madge Ltd.
-0000C2 INFORMATION PRESENTATION TECH.
-0000C3 HARRIS CORP COMPUTER SYS DIV
-0000C4 WATERS DIV. OF MILLIPORE
-0000C5 FARALLON COMPUTING/NETOPIA
-0000C6 EON SYSTEMS
-0000C7 ARIX CORPORATION
-0000C8 ALTOS COMPUTER SYSTEMS
-0000C9 EMULEX CORPORATION
-0000CA APPLITEK
-0000CB COMPU-SHACK ELECTRONIC GMBH
-0000CC DENSAN CO., LTD.
-0000CD Allied Telesyn Research Ltd.
-0000CE MEGADATA CORP.
-0000CF HAYES MICROCOMPUTER PRODUCTS
-0000D0 DEVELCON ELECTRONICS LTD.
-0000D1 ADAPTEC INCORPORATED
-0000D2 SBE, INC.
-0000D3 WANG LABORATORIES INC.
-0000D4 PURE DATA LTD.
-0000D5 MICROGNOSIS INTERNATIONAL
-0000D6 PUNCH LINE HOLDING
-0000D7 DARTMOUTH COLLEGE
-0000D8 NOVELL, INC.
-0000D9 NIPPON TELEGRAPH & TELEPHONE
-0000DA ATEX
-0000DB BRITISH TELECOMMUNICATIONS PLC
-0000DC HAYES MICROCOMPUTER PRODUCTS
-0000DD TCL INCORPORATED
-0000DE CETIA
-0000DF BELL & HOWELL PUB SYS DIV
-0000E0 QUADRAM CORP.
-0000E1 GRID SYSTEMS
-0000E2 ACER TECHNOLOGIES CORP.
-0000E3 INTEGRATED MICRO PRODUCTS LTD
-0000E4 IN2 GROUPE INTERTECHNIQUE
-0000E5 SIGMEX LTD.
-0000E6 APTOR PRODUITS DE COMM INDUST
-0000E7 STAR GATE TECHNOLOGIES
-0000E8 ACCTON TECHNOLOGY CORP.
-0000E9 ISICAD, INC.
-0000EA UPNOD AB
-0000EB MATSUSHITA COMM. IND. CO. LTD.
-0000EC MICROPROCESS
-0000ED APRIL
-0000EE NETWORK DESIGNERS, LTD.
-0000EF KTI
-0000F0 SAMSUNG ELECTRONICS CO., LTD.
-0000F1 MAGNA COMPUTER CORPORATION
-0000F2 SPIDER COMMUNICATIONS
-0000F3 GANDALF DATA LIMITED
-0000F4 ALLIED TELESYN INTERNATIONAL
-0000F5 DIAMOND SALES LIMITED
-0000F6 APPLIED MICROSYSTEMS CORP.
-0000F7 YOUTH KEEP ENTERPRISE CO LTD
-0000F8 DIGITAL EQUIPMENT CORPORATION
-0000F9 QUOTRON SYSTEMS INC.
-0000FA MICROSAGE COMPUTER SYSTEMS INC
-0000FB RECHNER ZUR KOMMUNIKATION
-0000FC MEIKO
-0000FD HIGH LEVEL HARDWARE
-0000FE ANNAPOLIS MICRO SYSTEMS
-0000FF CAMTEC ELECTRONICS LTD.
-000100 EQUIP'TRANS
-000102 3COM CORPORATION
-000103 3COM CORPORATION
-000104 DVICO Co., Ltd.
-000105 BECKHOFF GmbH
-000106 Tews Datentechnik GmbH
-000107 Leiser GmbH
-000108 AVLAB Technology, Inc.
-000109 Nagano Japan Radio Co., Ltd.
-00010A CIS TECHNOLOGY INC.
-00010B Space CyberLink, Inc.
-00010C System Talks Inc.
-00010D CORECO, INC.
-00010E Bri-Link Technologies Co., Ltd
-00010F Nishan Systems, Inc.
-000110 Gotham Networks
-000111 iDigm Inc.
-000112 Shark Multimedia Inc.
-000113 OLYMPUS CORPORATION
-000114 KANDA TSUSHIN KOGYO CO., LTD.
-000115 EXTRATECH CORPORATION
-000116 Netspect Technologies, Inc.
-000117 CANAL +
-000118 EZ Digital Co., Ltd.
-000119 Action Controls Pty. Ltd.
-00011A EEH DataLink GmbH
-00011B Unizone Technologies, Inc.
-00011C Universal Talkware Corporation
-00011D Centillium Communications
-00011E Precidia Technologies, Inc.
-00011F RC Networks, Inc.
-000120 OSCILLOQUARTZ S.A.
-000121 RapidStream Inc.
-000122 Trend Communications, Ltd.
-000123 DIGITAL ELECTRONICS CORP.
-000124 Acer Incorporated
-000125 YAESU MUSEN CO., LTD.
-000126 PAC Labs
-000127 The OPEN Group Limited
-000128 EnjoyWeb, Inc.
-000129 DFI Inc.
-00012A Telematica Sistems Inteligente
-00012B TELENET Co., Ltd.
-00012C Aravox Technologies, Inc.
-00012D Komodo Technology
-00012E PC Partner Ltd.
-00012F Twinhead International Corp
-000130 Extreme Networks
-000131 Detection Systems, Inc.
-000132 Dranetz - BMI
-000133 KYOWA Electronic Instruments C
-000134 SIG Positec Systems AG
-000135 KDC Corp.
-000136 CyberTAN Technology, Inc.
-000137 IT Farm Corporation
-000138 XAVi Technologies Corp.
-000139 Point Multimedia Systems
-00013A SHELCAD COMMUNICATIONS, LTD.
-00013B BNA SYSTEMS
-00013C TIW SYSTEMS
-00013D RiscStation Ltd.
-00013E Ascom Tateco AB
-00013F Neighbor World Co., Ltd.
-000140 Sendtek Corporation
-000141 CABLE PRINT
-000142 Cisco Systems, Inc.
-000143 Cisco Systems, Inc.
-000144 Cereva Networks, Inc.
-000145 WINSYSTEMS, INC.
-000146 Tesco Controls, Inc.
-000147 Zhone Technologies
-000148 X-traWeb Inc.
-000149 T.D.T. Transfer Data Test GmbH
-00014A SONY COMPUTER SCIENCE LABS., I
-00014B Ennovate Networks, Inc.
-00014C Berkeley Process Control
-00014D Shin Kin Enterprises Co., Ltd
-00014E WIN Enterprises, Inc.
-00014F LUMINOUS Networks, Inc.
-000150 GILAT COMMUNICATIONS, LTD.
-000151 Ensemble Communications
-000152 CHROMATEK INC.
-000153 ARCHTEK TELECOM CORPORATION
-000154 G3M Corporation
-000155 Promise Technology, Inc.
-000156 FIREWIREDIRECT.COM, INC.
-000157 SYSWAVE CO., LTD
-000158 Electro Industries/Gauge Tech
-000159 S1 Corporation
-00015A Digital Video Broadcasting
-00015B ITALTEL S.p.A/RF-UP-I
-00015C CADANT INC.
-00015D Sun Microsystems, Inc
-00015E BEST TECHNOLOGY CO., LTD.
-00015F DIGITAL DESIGN GmbH
-000160 ELMEX Co., LTD.
-000161 Meta Machine Technology
-000162 Cygnet Technologies, Inc.
-000163 Cisco Systems, Inc.
-000164 Cisco Systems, Inc.
-000165 AirSwitch Corporation
-000166 TC GROUP A/S
-000167 HIOKI E.E. CORPORATION
-000168 VITANA CORPORATION
-000169 Celestix Networks Pte Ltd.
-00016A ALITEC
-00016B LightChip, Inc.
-00016C FOXCONN
-00016D CarrierComm Inc.
-00016E Conklin Corporation
-00016F HAITAI ELECTRONICS CO., LTD.
-000170 ESE Embedded System Engineer'g
-000171 Allied Data Technologies
-000172 TechnoLand Co., LTD.
-000173 JNI Corporation
-000174 CyberOptics Corporation
-000175 Radiant Communications Corp.
-000176 Orient Silver Enterprises
-000177 EDSL
-000178 MARGI Systems, Inc.
-000179 WIRELESS TECHNOLOGY, INC.
-00017A Chengdu Maipu Electric Industrial Co., Ltd.
-00017B Heidelberger Druckmaschinen AG
-00017C AG-E GmbH
-00017D ThermoQuest
-00017E ADTEK System Science Co., Ltd.
-00017F Experience Music Project
-000180 AOpen, Inc.
-000181 Nortel Networks
-000182 DICA TECHNOLOGIES AG
-000183 ANITE TELECOMS
-000184 SIEB & MEYER AG
-000185 Aloka Co., Ltd.
-000186 DISCH GmbH
-000187 i2SE GmbH
-000188 LXCO Technologies ag
-000189 Refraction Technology, Inc.
-00018A ROI COMPUTER AG
-00018B NetLinks Co., Ltd.
-00018C Mega Vision
-00018D AudeSi Technologies
-00018E Logitec Corporation
-00018F Kenetec, Inc.
-000190 SMK-M
-000191 SYRED Data Systems
-000192 Texas Digital Systems
-000193 Hanbyul Telecom Co., Ltd.
-000194 Capital Equipment Corporation
-000195 Sena Technologies, Inc.
-000196 Cisco Systems, Inc.
-000197 Cisco Systems, Inc.
-000198 Darim Vision
-000199 HeiSei Electronics
-00019A LEUNIG GmbH
-00019B Kyoto Microcomputer Co., Ltd.
-00019C JDS Uniphase Inc.
-00019D E-Control Systems, Inc.
-00019E ESS Technology, Inc.
-00019F Phonex Broadband
-0001A0 Infinilink Corporation
-0001A1 Mag-Tek, Inc.
-0001A2 Logical Co., Ltd.
-0001A3 GENESYS LOGIC, INC.
-0001A4 Microlink Corporation
-0001A5 Nextcomm, Inc.
-0001A6 Scientific-Atlanta Arcodan A/S
-0001A7 UNEX TECHNOLOGY CORPORATION
-0001A8 Welltech Computer Co., Ltd.
-0001A9 BMW AG
-0001AA Airspan Communications, Ltd.
-0001AB Main Street Networks
-0001AC Sitara Networks, Inc.
-0001AD Coach Master International  d.b.a. CMI Worldwide, Inc.
-0001AE Trex Enterprises
-0001AF Motorola Computer Group
-0001B0 Fulltek Technology Co., Ltd.
-0001B1 General Bandwidth
-0001B2 Digital Processing Systems, Inc.
-0001B3 Precision Electronic Manufacturing
-0001B4 Wayport, Inc.
-0001B5 Turin Networks, Inc.
-0001B6 SAEJIN T&M Co., Ltd.
-0001B7 Centos, Inc.
-0001B8 Netsensity, Inc.
-0001B9 SKF Condition Monitoring
-0001BA IC-Net, Inc.
-0001BB Frequentis
-0001BC Brains Corporation
-0001BD Peterson Electro-Musical Products, Inc.
-0001BE Gigalink Co., Ltd.
-0001BF Teleforce Co., Ltd.
-0001C0 CompuLab, Ltd.
-0001C1 Vitesse Semiconductor Corporation
-0001C2 ARK Research Corp.
-0001C3 Acromag, Inc.
-0001C4 NeoWave, Inc.
-0001C5 Simpler Networks
-0001C6 Quarry Technologies
-0001C7 Cisco Systems, Inc.
-0001C8 THOMAS CONRAD CORP.
-0001C8 CONRAD CORP.
-0001C9 Cisco Systems, Inc.
-0001CA Geocast Network Systems, Inc.
-0001CB NetGame, Ltd.
-0001CC Japan Total Design Communication Co., Ltd.
-0001CD ARtem
-0001CE Custom Micro Products, Ltd.
-0001CF Alpha Data Parallel Systems, Ltd.
-0001D0 VitalPoint, Inc.
-0001D1 CoNet Communications, Inc.
-0001D2 MacPower Peripherals, Ltd.
-0001D3 PAXCOMM, Inc.
-0001D4 Leisure Time, Inc.
-0001D5 HAEDONG INFO & COMM CO., LTD
-0001D6 MAN Roland Druckmaschinen AG
-0001D7 F5 Networks, Inc.
-0001D8 Teltronics, Inc.
-0001D9 Sigma, Inc.
-0001DA WINCOMM Corporation
-0001DB Freecom Technologies GmbH
-0001DC Activetelco
-0001DD Avail Networks
-0001DE Trango Systems, Inc.
-0001DF ISDN Communications, Ltd.
-0001E0 Fast Systems, Inc.
-0001E1 Kinpo Electronics, Inc.
-0001E2 Ando Electric Corporation
-0001E3 Siemens AG
-0001E4 Sitera, Inc.
-0001E5 Supernet, Inc.
-0001E6 Hewlett-Packard Company
-0001E7 Hewlett-Packard Company
-0001E8 Force10 Networks, Inc.
-0001E9 Litton Marine Systems B.V.
-0001EA Cirilium Corp.
-0001EB C-COM Corporation
-0001EC Ericsson Group
-0001ED SETA Corp.
-0001EE Comtrol Europe, Ltd.
-0001EF Camtel Technology Corp.
-0001F0 Tridium, Inc.
-0001F1 Innovative Concepts, Inc.
-0001F2 Mark of the Unicorn, Inc.
-0001F3 QPS, Inc.
-0001F4 Enterasys Networks
-0001F5 ERIM S.A.
-0001F6 Association of Musical Electronics Industry
-0001F7 Image Display Systems, Inc.
-0001F8 Adherent Systems, Ltd.
-0001F9 TeraGlobal Communications Corp.
-0001FA HOROSCAS
-0001FB DoTop Technology, Inc.
-0001FC Keyence Corporation
-0001FD Digital Voice Systems, Inc.
-0001FE DIGITAL EQUIPMENT CORPORATION
-0001FF Data Direct Networks, Inc.
-000200 Net & Sys Co., Ltd.
-000201 IFM Electronic gmbh
-000202 Amino Communications, Ltd.
-000203 Woonsang Telecom, Inc.
-000204 Bodmann Industries Elektronik GmbH
-000205 Hitachi Denshi, Ltd.
-000206 Telital R&D Denmark A/S
-000207 VisionGlobal Network Corp.
-000208 Unify Networks, Inc.
-000209 Shenzhen SED Information Technology Co., Ltd.
-00020A Gefran Spa
-00020B Native Networks, Inc.
-00020C Metro-Optix
-00020D Micronpc.com
-00020E Laurel Networks, Inc.
-00020F AATR
-000210 Fenecom
-000211 Nature Worldwide Technology Corp.
-000212 SierraCom
-000213 S.D.E.L.
-000214 DTVRO
-000215 Cotas Computer Technology A/B
-000216 Cisco Systems, Inc.
-000217 Cisco Systems, Inc.
-000218 Advanced Scientific Corp
-000219 Paralon Technologies
-00021A Zuma Networks
-00021B Kollmorgen-Servotronix
-00021C Network Elements, Inc.
-00021D Data General Communication Ltd.
-00021E SIMTEL S.R.L.
-00021F Aculab PLC
-000220 Canon Aptex, Inc.
-000221 DSP Application, Ltd.
-000222 Chromisys, Inc.
-000223 ClickTV
-000224 Lantern Communications, Inc.
-000225 Certus Technology, Inc.
-000226 XESystems, Inc.
-000227 ESD GmbH
-000228 Necsom, Ltd.
-000229 Adtec Corporation
-00022A Asound Electronic
-00022B Tamura Electric Works, Ltd.
-00022C ABB Bomem, Inc.
-00022D Agere Systems
-00022E TEAC Corp. R& D
-00022F P-Cube, Ltd.
-000230 Intersoft Electronics
-000231 Ingersoll-Rand
-000232 Avision, Inc.
-000233 Mantra Communications, Inc.
-000234 Imperial Technology, Inc.
-000235 Paragon Networks International
-000236 INIT GmbH
-000237 Cosmo Research Corp.
-000238 Serome Technology, Inc.
-000239 Visicom
-00023A ZSK Stickmaschinen GmbH
-00023B Redback Networks
-00023C Creative Technology, Ltd.
-00023D NuSpeed, Inc.
-00023E Selta Telematica S.p.a
-00023F Compal Electronics, Inc.
-000240 Seedek Co., Ltd.
-000241 Amer.com
-000242 Videoframe Systems
-000243 Raysis Co., Ltd.
-000244 SURECOM Technology Co.
-000245 Lampus Co, Ltd.
-000246 All-Win Tech Co., Ltd.
-000247 Great Dragon Information Technology (Group) Co., Ltd.
-000248 Pilz GmbH & Co.
-000249 Aviv Infocom Co, Ltd.
-00024A Cisco Systems, Inc.
-00024B Cisco Systems, Inc.
-00024C SiByte, Inc.
-00024D Mannesman Dematic Colby Pty. Ltd.
-00024E Datacard Group
-00024F IPM Datacom S.R.L.
-000250 Geyser Networks, Inc.
-000251 Soma Networks
-000252 Carrier Corporation
-000253 Televideo, Inc.
-000254 WorldGate
-000255 IBM Corporation
-000256 Alpha Processor, Inc.
-000257 Microcom Corp.
-000258 Flying Packets Communications
-000259 Tsann Kuen China (Shanghai)Enterprise Co., Ltd. IT Group
-00025A Catena Networks
-00025B Cambridge Silicon Radio
-00025C SCI Systems (Kunshan) Co., Ltd.
-00025D Calix Networks
-00025E High Technology Ltd
-00025F Nortel Networks
-000260 Accordion Networks, Inc.
-000261 i3 Micro Technology AB
-000262 Soyo Group Soyo Com Tech Co., Ltd
-000263 UPS Manufacturing SRL
-000264 AudioRamp.com
-000265 Virditech Co. Ltd.
-000266 Thermalogic Corporation
-000267 NODE RUNNER, INC.
-000268 Harris Government Communications
-000269 Nadatel Co., Ltd
-00026A Cocess Telecom Co., Ltd.
-00026B BCM Computers Co., Ltd.
-00026C Philips CFT
-00026D Adept Telecom
-00026E NeGeN Access, Inc.
-00026F Senao International Co., Ltd.
-000270 Crewave Co., Ltd.
-000271 Vpacket Communications
-000272 CC&C Technologies, Inc.
-000273 Coriolis Networks
-000274 Tommy Technologies Corp.
-000275 SMART Technologies, Inc.
-000276 Primax Electronics Ltd.
-000277 Cash Systemes Industrie
-000278 Samsung Electro-Mechanics Co., Ltd.
-000279 Control Applications, Ltd.
-00027A IOI Technology Corporation
-00027B Amplify Net, Inc.
-00027C Trilithic, Inc.
-00027D Cisco Systems, Inc.
-00027E Cisco Systems, Inc.
-00027F ask-technologies.com
-000280 Mu Net, Inc.
-000281 Madge Ltd.
-000282 ViaClix, Inc.
-000283 Spectrum Controls, Inc.
-000284 Alstom T&D P&C
-000285 Riverstone Networks
-000286 Occam Networks
-000287 Adapcom
-000288 GLOBAL VILLAGE COMMUNICATION
-000289 DNE Technologies
-00028A Ambit Microsystems Corporation
-00028B VDSL Systems OY
-00028C Micrel-Synergy Semiconductor
-00028D Movita Technologies, Inc.
-00028E Rapid 5 Networks, Inc.
-00028F Globetek, Inc.
-000290 Woorigisool, Inc.
-000291 Open Network Co., Ltd.
-000292 Logic Innovations, Inc.
-000293 Solid Data Systems
-000294 Tokyo Sokushin Co., Ltd.
-000295 IP.Access Limited
-000296 Lectron Co,. Ltd.
-000297 C-COR.net
-000298 Broadframe Corporation
-000299 Apex, Inc.
-00029A Storage Apps
-00029B Kreatel Communications AB
-00029C 3COM
-00029D Merix Corp.
-00029E Information Equipment Co., Ltd.
-00029F L-3 Communication Aviation Recorders
-0002A0 Flatstack Ltd.
-0002A1 World Wide Packets
-0002A2 Hilscher GmbH
-0002A3 ABB Power Automation
-0002A4 AddPac Technology Co., Ltd.
-0002A5 Compaq Computer Corporation
-0002A6 Effinet Systems Co., Ltd.
-0002A7 Vivace Networks
-0002A8 Air Link Technology
-0002A9 RACOM, s.r.o.
-0002AA PLcom Co., Ltd.
-0002AB CTC Union Technologies Co., Ltd.
-0002AC 3PAR data
-0002AD Pentax Corpotation
-0002AE Scannex Electronics Ltd.
-0002AF TeleCruz Technology, Inc.
-0002B0 Hokubu Communication & Industrial Co., Ltd.
-0002B1 Anritsu, Ltd.
-0002B2 Cablevision
-0002B3 Intel Corporation
-0002B4 DAPHNE
-0002B5 Avnet, Inc.
-0002B6 Acrosser Technology Co., Ltd.
-0002B7 Watanabe Electric Industry Co., Ltd.
-0002B8 WHI KONSULT AB
-0002B9 Cisco Systems, Inc.
-0002BA Cisco Systems, Inc.
-0002BB Continuous Computing
-0002BC LVL 7 Systems, Inc.
-0002BD Bionet Co., Ltd.
-0002BE Totsu Engineering, Inc.
-0002BF dotRocket, Inc.
-0002C0 Bencent Tzeng Industry Co., Ltd.
-0002C1 Innovative Electronic Designs, Inc.
-0002C2 Net Vision Telecom
-0002C3 Arelnet Ltd.
-0002C4 Vector International BUBA
-0002C5 Evertz Microsystems Ltd.
-0002C6 Data Track Technology PLC
-0002C7 ALPS ELECTRIC Co., Ltd.
-0002C8 Technocom Communications Technology (pte) Ltd
-0002C9 Mellanox Technologies
-0002CA EndPoints, Inc.
-0002CB TriState Ltd.
-0002CC M.C.C.I
-0002CD TeleDream, Inc.
-0002CE FoxJet, Inc.
-0002CF ZyGate Communications, Inc.
-0002D0 Comdial Corporation
-0002D1 Vivotek, Inc.
-0002D2 Workstation AG
-0002D3 NetBotz, Inc.
-0002D4 PDA Peripherals, Inc.
-0002D5 ACR
-0002D6 NICE Systems
-0002D7 EMPEG Ltd
-0002D8 BRECIS Communications Corporation
-0002D9 Reliable Controls
-0002DA ExiO Communications, Inc.
-0002DB NETSEC
-0002DC Fujitsu General Limited
-0002DD Bromax Communications, Ltd.
-0002DE Astrodesign, Inc.
-0002DF Net Com Systems, Inc.
-0002E0 ETAS GmbH
-0002E1 Integrated Network Corporation
-0002E2 NDC Infared Engineering
-0002E3 LITE-ON Communications, Inc.
-0002E4 JC HYUN Systems, Inc.
-0002E5 Timeware Ltd.
-0002E6 Gould Instrument Systems, Inc.
-0002E7 CAB GmbH & Co KG
-0002E8 E.D.&A.
-0002E9 CS Systemes De Securite - C3S
-0002EA Videonics, Inc.
-0002EB Pico Communications
-0002EC Maschoff Design Engineering
-0002ED DXO Telecom Co., Ltd.
-0002EE Nokia Danmark A/S
-0002EF CCC Network Systems Group Ltd.
-0002F0 AME Optimedia Technology Co., Ltd.
-0002F1 Pinetron Co., Ltd.
-0002F2 eDevice, Inc.
-0002F3 Media Serve Co., Ltd.
-0002F4 PCTEL, Inc.
-0002F5 VIVE Synergies, Inc.
-0002F6 Equipe Communications
-0002F7 ARM
-0002F8 SEAKR Engineering, Inc.
-0002F9 Mimos Semiconductor SDN BHD
-0002FA DX Antenna Co., Ltd.
-0002FB Baumuller Aulugen-Systemtechnik GmbH
-0002FC Cisco Systems, Inc.
-0002FD Cisco Systems, Inc.
-0002FE Viditec, Inc.
-0002FF Handan BroadInfoCom
-000300 NetContinuum, Inc.
-000301 Avantas Networks Corporation
-000302 Oasys Telecom, Inc.
-000303 JAMA Electronics Co., Ltd.
-000304 Pacific Broadband Communications
-000305 Smart Network Devices GmbH
-000306 Fusion In Tech Co., Ltd.
-000307 Secure Works, Inc.
-000308 AM Communications, Inc.
-000309 Texcel Technology PLC
-00030A Argus Technologies
-00030B Hunter Technology, Inc.
-00030C Telesoft Technologies Ltd.
-00030D Uniwill Computer Corp.
-00030E Core Communications Co., Ltd.
-00030F Digital China (Shanghai) Networks Ltd.
-000310 Link Evolution Corp.
-000311 Micro Technology Co., Ltd.
-000312 TR-Systemtechnik GmbH
-000313 Access Media SPA
-000314 Teleware Network Systems
-000315 Cidco Incorporated
-000316 Nobell Communications, Inc.
-000317 Merlin Systems, Inc.
-000318 Cyras Systems, Inc.
-000319 Infineon AG
-00031A Beijing Broad Telecom Ltd., China
-00031B Cellvision Systems, Inc.
-00031C Svenska Hardvarufabriken AB
-00031D Taiwan Commate Computer, Inc.
-00031E Optranet, Inc.
-00031F Condev Ltd.
-000320 Xpeed, Inc.
-000321 Reco Research Co., Ltd.
-000322 IDIS Co., Ltd.
-000323 Cornet Technology, Inc.
-000324 SANYO Multimedia Tottori Co., Ltd.
-000325 Arima Computer Corp.
-000326 Iwasaki Information Systems Co., Ltd.
-000327 ACT'L
-000328 Mace Group, Inc.
-000329 F3, Inc.
-00032A UniData Communication Systems, Inc.
-00032B GAI Datenfunksysteme GmbH
-00032C ABB Industrie AG
-00032D IBASE Technology, Inc.
-00032E Scope Information Management, Ltd.
-00032F Global Sun Technology, Inc.
-000330 Imagenics, Co., Ltd.
-000331 Cisco Systems, Inc.
-000332 Cisco Systems, Inc.
-000333 Digitel Co., Ltd.
-000334 Newport Electronics
-000335 Mirae Technology
-000336 Zetes Technologies
-000337 Vaone, Inc.
-000338 Oak Technology
-000339 Eurologic Systems, Ltd.
-00033A Silicon Wave, Inc.
-00033B TAMI Tech Co., Ltd.
-00033C Daiden Co., Ltd.
-00033D ILSHin Lab
-00033E Tateyama System Laboratory Co., Ltd.
-00033F BigBand Networks, Ltd.
-000340 Floware Wireless Systems, Ltd.
-000341 Axon Digital Design
-000342 Nortel Networks
-000343 Martin Professional A/S
-000344 Tietech.Co., Ltd.
-000345 Routrek Networks Corporation
-000346 Hitachi Kokusai Electric, Inc.
-000347 Intel Corporation
-000348 Norscan Instruments, Ltd.
-000349 Vidicode Datacommunicatie B.V.
-00034A RIAS Corporation
-00034B Nortel Networks
-00034C Shanghai DigiVision Technology Co., Ltd.
-00034D Chiaro Networks, Ltd.
-00034E Pos Data Company, Ltd.
-00034F Sur-Gard Security
-000350 BTICINO SPA
-000351 Diebold, Inc.
-000352 Colubris Networks
-000353 Mitac, Inc.
-000354 Fiber Logic Communications
-000355 TeraBeam Internet Systems
-000356 Wincor Nixdorf GmbH & Co KG
-000357 Intervoice-Brite, Inc.
-000358 iCable System Co., Ltd.
-000359 DigitalSis
-00035A Photron Limited
-00035B BridgeWave Communications
-00035C Saint Song Corp.
-00035D Bosung Hi-Net Co., Ltd.
-00035E Metropolitan Area Networks, Inc.
-00035F Prueftechnik Condition Monitoring GmbH & Co. KG
-000360 PAC Interactive Technology, Inc.
-000361 Widcomm, Inc.
-000362 Vodtel Communications, Inc.
-000363 Miraesys Co., Ltd.
-000364 Scenix Semiconductor, Inc.
-000365 Kira Information & Communications, Ltd.
-000366 ASM Pacific Technology
-000367 Jasmine Networks, Inc.
-000368 Embedone Co., Ltd.
-000369 Nippon Antenna Co., Ltd.
-00036A Mainnet, Ltd.
-00036B Cisco Systems, Inc.
-00036C Cisco Systems, Inc.
-00036D Runtop, Inc.
-00036E Nicon Systems (Pty) Limited
-00036F Telsey SPA
-000370 NXTV, Inc.
-000371 Acomz Networks Corp.
-000372 ULAN
-000373 Aselsan A.S
-000374 Hunter Watertech
-000375 NetMedia, Inc.
-000376 Graphtec Technology, Inc.
-000377 Gigabit Wireless
-000378 HUMAX Co., Ltd.
-000379 Proscend Communications, Inc.
-00037A Taiyo Yuden Co., Ltd.
-00037B IDEC IZUMI Corporation
-00037C Coax Media
-00037D Stellcom
-00037E PORTech Communications, Inc.
-00037F Atheros Communications, Inc.
-000380 SSH Communications Security Corp.
-000381 Ingenico International
-000382 A-One Co., Ltd.
-000383 Metera Networks, Inc.
-000384 AETA
-000385 Actelis Networks, Inc.
-000386 Ho Net, Inc.
-000387 Blaze Network Products
-000388 Fastfame Technology Co., Ltd.
-000389 Plantronics
-00038A America Online, Inc.
-00038B PLUS-ONE I&T, Inc.
-00038C Total Impact
-00038D PCS Revenue Control Systems, Inc.
-00038E Atoga Systems, Inc.
-00038F Weinschel Corporation
-000390 Digital Video Communications, Inc.
-000392 Hyundai Teletek Co., Ltd.
-000393 Apple Computer, Inc.
-000394 Connect One
-000395 California Amplifier
-000396 EZ Cast Co., Ltd.
-000397 Watchfront Electronics
-000398 WISI
-000399 Dongju Informations & Communications Co., Ltd.
-00039A nSine, Ltd.
-00039B NetChip Technology, Inc.
-00039C OptiMight Communications, Inc.
-00039D BENQ CORPORATION
-00039E Tera System Co., Ltd.
-00039F Cisco Systems, Inc.
-0003A0 Cisco Systems, Inc.
-0003A1 HIPER Information & Communication, Inc.
-0003A2 Catapult Communications
-0003A3 MAVIX, Ltd.
-0003A4 Data Storage and Information Management
-0003A5 Medea Corporation
-0003A7 Unixtar Technology, Inc.
-0003A8 IDOT Computers, Inc.
-0003A9 AXCENT Media AG
-0003AA Watlow
-0003AB Bridge Information Systems
-0003AC Fronius Schweissmaschinen
-0003AD Emerson Energy Systems AB
-0003AE Allied Advanced Manufacturing Pte, Ltd.
-0003AF Paragea Communications
-0003B0 Xsense Technology Corp.
-0003B1 Abbott Laboratories HPD
-0003B2 Radware
-0003B3 IA Link Systems Co., Ltd.
-0003B4 Macrotek International Corp.
-0003B5 Entra Technology Co.
-0003B6 QSI Corporation
-0003B7 ZACCESS Systems
-0003B8 NetKit Solutions, LLC
-0003B9 Hualong Telecom Co., Ltd.
-0003BA Sun Microsystems
-0003BB Signal Communications Limited
-0003BC COT GmbH
-0003BD OmniCluster Technologies, Inc.
-0003BE Netility
-0003BF Centerpoint Broadband Technologies, Inc.
-0003C0 RFTNC Co., Ltd.
-0003C1 Packet Dynamics Ltd
-0003C2 Solphone K.K.
-0003C3 Micronik Multimedia
-0003C4 Tomra Systems ASA
-0003C5 Mobotix AG
-0003C6 ICUE Systems, Inc.
-0003C7 hopf Elektronik GmbH
-0003C8 CML Emergency Services
-0003C9 TECOM Co., Ltd.
-0003CA MTS Systems Corp.
-0003CB Nippon Systems Development Co., Ltd.
-0003CC Momentum Computer, Inc.
-0003CD Clovertech, Inc.
-0003CE ETEN Technologies, Inc.
-0003CF Muxcom, Inc.
-0003D0 KOANKEISO Co., Ltd.
-0003D1 Takaya Corporation
-0003D2 Crossbeam Systems, Inc.
-0003D3 Internet Energy Systems, Inc.
-0003D4 Alloptic, Inc.
-0003D5 Advanced Communications Co., Ltd.
-0003D6 RADVision, Ltd.
-0003D7 NextNet Wireless, Inc.
-0003D8 iMPath Networks, Inc.
-0003D9 Secheron SA
-0003DA Takamisawa Cybernetics Co., Ltd.
-0003DB Apogee Electronics Corp.
-0003DC Lexar Media, Inc.
-0003DD Comark Corp.
-0003DE OTC Wireless
-0003DF Desana Systems
-0003E0 RadioFrame Networks, Inc.
-0003E1 Winmate Communication, Inc.
-0003E2 Comspace Corporation
-0003E3 Cisco Systems, Inc.
-0003E4 Cisco Systems, Inc.
-0003E5 Hermstedt SG
-0003E6 Entone Technologies, Inc.
-0003E7 Logostek Co. Ltd.
-0003E8 Wavelength Digital Limited
-0003E9 Akara Canada, Inc.
-0003EA Mega System Technologies, Inc.
-0003EB Atrica
-0003EC ICG Research, Inc.
-0003ED Shinkawa Electric Co., Ltd.
-0003EE MKNet Corporation
-0003EF Oneline AG
-0003F0 Redfern Broadband Networks
-0003F1 Cicada Semiconductor, Inc.
-0003F2 Seneca Networks
-0003F3 Dazzle Multimedia, Inc.
-0003F4 NetBurner
-0003F5 Chip2Chip
-0003F6 Allegro Networks, Inc.
-0003F7 Plast-Control GmbH
-0003F8 SanCastle Technologies, Inc.
-0003F9 Pleiades Communications, Inc.
-0003FA TiMetra Networks
-0003FB Toko Seiki Company, Ltd.
-0003FC Intertex Data AB
-0003FD Cisco Systems, Inc.
-0003FE Cisco Systems, Inc.
-0003FF Connectix
-000400 LEXMARK INTERNATIONAL, INC.
-000401 Osaki Electric Co., Ltd.
-000402 Nexsan Technologies, Ltd.
-000403 Nexsi Corporation
-000404 Makino Milling Machine Co., Ltd.
-000405 ACN Technologies
-000406 Fa. Metabox AG
-000407 Topcon Positioning Systems, Inc.
-000408 Sanko Electronics Co., Ltd.
-000409 Cratos Networks
-00040A Sage Systems
-00040B 3com Europe Ltd.
-00040C KANNO Work's Ltd.
-00040D Avaya, Inc.
-00040E AVM GmbH
-00040F Asus Network Technologies, Inc.
-000410 Spinnaker Networks, Inc.
-000411 Inkra Networks, Inc.
-000412 WaveSmith Networks, Inc.
-000413 SNOM Technology AG
-000414 Umezawa Musen Denki Co., Ltd.
-000415 Rasteme Systems Co., Ltd.
-000416 Parks S/A Comunicacoes Digitais
-000417 ELAU AG
-000418 Teltronic S.A.U.
-000419 Fibercycle Networks, Inc.
-00041A ines GmbH
-00041B Digital Interfaces Ltd.
-00041C ipDialog, Inc.
-00041D Corega of America
-00041E Shikoku Instrumentation Co., Ltd.
-00041F Sony Computer Entertainment, Inc.
-000420 Slim Devices, Inc.
-000421 Ocular Networks
-000422 Gordon Kapes, Inc.
-000423 Intel Corporation
-000424 TMC s.r.l.
-000425 Atmel Corporation
-000426 Autosys
-000427 Cisco Systems, Inc.
-000428 Cisco Systems, Inc.
-000429 Pixord Corporation
-00042A Wireless Networks, Inc.
-00042B IT Access Co., Ltd.
-00042C Minet, Inc.
-00042D Sarian Systems, Ltd.
-00042E Netous Technologies, Ltd.
-00042F International Communications Products, Inc.
-000430 Netgem
-000431 GlobalStreams, Inc.
-000432 Voyetra Turtle Beach, Inc.
-000433 Cyberboard A/S
-000434 Accelent Systems, Inc.
-000435 Comptek International, Inc.
-000436 ELANsat Technologies, Inc.
-000437 Powin Information Technology, Inc.
-000438 Nortel Networks
-000439 Rosco Entertainment Technology, Inc.
-00043A Intelligent Telecommunications, Inc.
-00043B Lava Computer Mfg., Inc.
-00043C SONOS Co., Ltd.
-00043D INDEL AG
-00043E Telencomm
-00043F Electronic Systems Technology, Inc.
-000440 cyberPIXIE, Inc.
-000441 Half Dome Systems, Inc.
-000442 NACT
-000443 Agilent Technologies, Inc.
-000444 Western Multiplex Corporation
-000445 LMS Skalar Instruments GmbH
-000446 CYZENTECH Co., Ltd.
-000447 Acrowave Systems Co., Ltd.
-000448 Polaroid Professional Imaging
-000449 Mapletree Networks
-00044A iPolicy Networks, Inc.
-00044B NVIDIA
-00044C JENOPTIK
-00044D Cisco Systems, Inc.
-00044E Cisco Systems, Inc.
-00044F Leukhardt Systemelektronik GmbH
-000450 DMD Computers SRL
-000451 Medrad, Inc.
-000452 RocketLogix, Inc.
-000453 YottaYotta, Inc.
-000454 Quadriga UK
-000455 ANTARA.net
-000456 PipingHot Networks
-000457 Universal Access Technology, Inc.
-000458 Fusion X Co., Ltd.
-000459 Veristar Corporation
-00045A The Linksys Group, Inc.
-00045B Techsan Electronics Co., Ltd.
-00045C Mobiwave Pte Ltd
-00045D BEKA Elektronik
-00045E PolyTrax Information Technology AG
-00045F Evalue Technology, Inc.
-000460 Knilink Technology, Inc.
-000461 EPOX Computer Co., Ltd.
-000462 DAKOS Data & Communication Co., Ltd.
-000463 Bosch Security Systems
-000464 Fantasma Networks, Inc.
-000465 i.s.t isdn-support technik GmbH
-000466 ARMITEL Co.
-000467 Wuhan Research Institute of MII
-000468 Vivity, Inc.
-000469 Innocom, Inc.
-00046A Navini Networks
-00046B Palm Wireless, Inc.
-00046C Cyber Technology Co., Ltd.
-00046D Cisco Systems, Inc.
-00046E Cisco Systems, Inc.
-00046F Digitel S/A Industria Eletronica
-000470 ipUnplugged AB
-000471 IPrad
-000472 Telelynx, Inc.
-000473 Photonex Corporation
-000474 LEGRAND
-000475 3 Com Corporation
-000476 3 Com Corporation
-000477 Scalant Systems, Inc.
-000478 G. Star Technology Corporation
-000479 Radius Co., Ltd.
-00047A AXXESSIT ASA
-00047B Schlumberger
-00047C Skidata AG
-00047D Pelco
-00047E NKF Electronics
-00047F Chr. Mayr GmbH & Co. KG
-000480 Foundry Networks, Inc.
-000481 Econolite Control Products, Inc.
-000482 Medialogic Corp.
-000483 Deltron Technology, Inc.
-000484 Amann GmbH
-000485 PicoLight
-000486 ITTC, University of Kansas
-000487 Cogency Semiconductor, Inc.
-000488 Eurotherm Action Incorporated.
-000489 YAFO Networks, Inc.
-00048A Temia Vertriebs GmbH
-00048B Poscon Corporation
-00048C Nayna Networks, Inc.
-00048D Tone Commander Systems, Inc.
-00048E Ohm Tech Labs, Inc.
-00048F TD Systems Corp.
-000490 Optical Access
-000491 Technovision, Inc.
-000492 Hive Internet, Ltd.
-000493 Tsinghua Unisplendour Co., Ltd.
-000494 Breezecom, Ltd.
-000495 Tejas Networks
-000496 Extreme Networks
-000497 MacroSystem Digital Video AG
-000499 Chino Corporation
-00049A Cisco Systems, Inc.
-00049B Cisco Systems, Inc.
-00049C Surgient Networks, Inc.
-00049D Ipanema Technologies
-00049E Wirelink Co., Ltd.
-00049F Metrowerks
-0004A0 Verity Instruments, Inc.
-0004A1 Pathway Connectivity
-0004A2 L.S.I. Japan Co., Ltd.
-0004A3 Microchip Technology, Inc.
-0004A4 NetEnabled, Inc.
-0004A5 Barco Projection Systems NV
-0004A6 SAF Tehnika Ltd.
-0004A7 FabiaTech Corporation
-0004A8 Broadmax Technologies, Inc.
-0004A9 SandStream Technologies, Inc.
-0004AA Jetstream Communications
-0004AB Comverse Network Systems, Inc.
-0004AC IBM CORP.
-0004AD Malibu Networks
-0004AE Liquid Metronics
-0004AF Digital Fountain, Inc.
-0004B0 ELESIGN Co., Ltd.
-0004B1 Signal Technology, Inc.
-0004B2 ESSEGI SRL
-0004B3 Videotek, Inc.
-0004B4 CIAC
-0004B5 Equitrac Corporation
-0004B6 Stratex Networks, Inc.
-0004B7 AMB i.t. Holding
-0004B8 Kumahira Co., Ltd.
-0004B9 S.I. Soubou, Inc.
-0004BA KDD Media Will Corporation
-0004BB Bardac Corporation
-0004BC Giantec, Inc.
-0004BD Motorola BCS
-0004BE OptXCon, Inc.
-0004BF VersaLogic Corp.
-0004C0 Cisco Systems, Inc.
-0004C1 Cisco Systems, Inc.
-0004C2 Magnipix, Inc.
-0004C3 CASTOR Informatique
-0004C4 Allen & Heath Limited
-0004C5 ASE Technologies, USA
-0004C6 Yamaha Motor Co., Ltd.
-0004C7 NetMount
-0004C8 LIBA Maschinenfabrik GmbH
-0004C9 Micro Electron Co., Ltd.
-0004CA FreeMs Corp.
-0004CB Tdsoft Communication, Ltd.
-0004CC Peek Traffic B.V.
-0004CD Informedia Research Group
-0004CE Patria Ailon
-0004CF Seagate Technology
-0004D0 Softlink s.r.o.
-0004D1 Drew Technologies, Inc.
-0004D2 Adcon Telemetry AG
-0004D3 Toyokeiki Co., Ltd.
-0004D4 Proview Electronics Co., Ltd.
-0004D5 Hitachi Communication Systems, Inc.
-0004D6 Takagi Industrial Co., Ltd.
-0004D7 Omitec Instrumentation Ltd.
-0004D8 IPWireless, Inc.
-0004D9 Titan Electronics, Inc.
-0004DA Relax Technology, Inc.
-0004DB Tellus Group Corp.
-0004DC Nortel Networks
-0004DD Cisco Systems, Inc.
-0004DE Cisco Systems, Inc.
-0004DF Teracom Telematica Ltda.
-0004E0 Procket Networks
-0004E1 Infinior Microsystems
-0004E2 SMC Networks, Inc.
-0004E3 Accton Technology Corp.
-0004E4 Daeryung Ind., Inc.
-0004E5 Glonet Systems, Inc.
-0004E6 Banyan Network Private Limited
-0004E7 Lightpointe Communications, Inc
-0004E8 IER, Inc.
-0004E9 Infiniswitch Corporation
-0004EA Hewlett-Packard Company
-0004EB Paxonet Communications, Inc.
-0004EC Memobox SA
-0004ED Billion Electric Co., Ltd.
-0004EE Lincoln Electric Company
-0004EF Polestar Corp.
-0004F0 International Computers, Ltd
-0004F1 WhereNet
-0004F2 Circa Communications, Ltd.
-0004F3 FS FORTH-SYSTEME GmbH
-0004F4 Infinite Electronics Inc.
-0004F5 SnowShore Networks, Inc.
-0004F6 Amphus
-0004F7 Omega Band, Inc.
-0004F8 QUALICABLE TV Industria E Com., Ltda
-0004F9 Xtera Communications, Inc.
-0004FA MIST Inc.
-0004FB Commtech, Inc.
-0004FC Stratus Computer (DE), Inc.
-0004FD Japan Control Engineering Co., Ltd.
-0004FE Pelago Networks
-0004FF Acronet Co., Ltd.
-000500 Cisco Systems, Inc.
-000501 Cisco Systems, Inc.
-000502 APPLE COMPUTER
-000503 ICONAG
-000504 Naray Information & Communication Enterprise
-000505 Systems Integration Solutions, Inc.
-000506 Reddo Networks AB
-000507 Fine Appliance Corp.
-000508 Inetcam, Inc.
-000509 AVOC Nishimura Ltd.
-00050A ICS Spa
-00050B SICOM Systems, Inc.
-00050C Network Photonics, Inc.
-00050D Midstream Technologies, Inc.
-00050E 3ware, Inc.
-00050F Tanaka S/S Ltd.
-000510 Infinite Shanghai Communication Terminals Ltd.
-000511 Complementary Technologies Ltd
-000512 MeshNetworks, Inc.
-000513 VTLinx Multimedia Systems, Inc.
-000514 KDT Systems Co., Ltd.
-000515 Nuark Co., Ltd.
-000516 SMART Modular Technologies
-000517 Shellcomm, Inc.
-000518 Jupiters Technology
-000519 Siemens Building Technologies AG,
-00051A 3Com Europe Ltd.
-00051B Magic Control Technology Corporation
-00051C Xnet Technology Corp.
-00051D Airocon, Inc.
-00051E Brocade Communications Systems, Inc.
-00051F Taijin Media Co., Ltd.
-000520 Smartronix, Inc.
-000521 Control Microsystems
-000522 LEA*D Corporation, Inc.
-000523 AVL List GmbH
-000524 BTL System (HK) Limited
-000525 Puretek Industrial Co., Ltd.
-000526 IPAS GmbH
-000527 SJ Tek Co. Ltd
-000528 New Focus, Inc.
-000529 Shanghai Broadan Communication Technology Co., Ltd
-00052A Ikegami Tsushinki Co., Ltd.
-00052B HORIBA, Ltd.
-00052C Supreme Magic Corporation
-00052D Zoltrix International Limited
-00052E Cinta Networks
-00052F Leviton Voice and Data
-000530 Andiamo Systems, Inc.
-000531 Cisco Systems, Inc.
-000532 Cisco Systems, Inc.
-000533 Sanera Systems, Inc.
-000534 Northstar Engineering Ltd.
-000535 Chip PC Ltd.
-000536 Danam Communications, Inc.
-000537 Nets Technology Co., Ltd.
-000538 Merilus, Inc.
-000539 A Brand New World in Sweden AB
-00053A Willowglen Services Pte Ltd
-00053B Harbour Networks Ltd., Co. Beijing
-00053C Xircom
-00053D Agere Systems
-00053E KID Systeme GmbH
-00053F VisionTek, Inc.
-000540 FAST Corporation
-000541 Advanced Systems Co., Ltd.
-000542 Otari, Inc.
-000543 IQ Wireless GmbH
-000544 Valley Technologies, Inc.
-000545 Internet Photonics
-000546 K-Solutions Inc.
-000547 Starent Networks
-000548 Disco Corporation
-000549 Salira Optical Network Systems
-00054A Ario Data Networks, Inc.
-00054B Micro Innovation AG
-00054C RF Innovations Pty Ltd
-00054D Brans Technologies, Inc.
-00054E Philips Components
-000550 Digi-Tech Communications Limited
-000551 F & S Elektronik Systeme GmbH
-000552 Xycotec Computer GmbH
-000553 DVC Company, Inc.
-000554 Rangestar Wireless
-000555 Japan Cash Machine Co., Ltd.
-000556 360 Systems
-000557 Agile TV Corporation
-000558 Synchronous, Inc.
-000559 Intracom S.A.
-00055A Power Dsine Ltd.
-00055B Charles Industries, Ltd.
-00055C Kowa Company, Ltd.
-00055D D-Link Systems, Inc.
-00055E Cisco Systems, Inc.
-00055F Cisco Systems, Inc.
-000560 LEADER COMM.CO., LTD
-000561 nac Image Technology, Inc.
-000562 Digital View Limited
-000563 J-Works, Inc.
-000564 Tsinghua Bitway Co., Ltd.
-000565 Tailyn Communication Company Ltd.
-000566 Secui.com Corporation
-000567 Etymonic Design, Inc.
-000568 Piltofish Networks AB
-000569 VMWARE, Inc.
-00056A Heuft Systemtechnik GmbH
-00056B C.P. Technology Co., Ltd.
-00056C Hung Chang Co., Ltd.
-00056D Pacific Corporation
-00056E National Enhance Technology, Inc.
-00056F Innomedia Technologies Pvt. Ltd.
-000570 Baydel Ltd.
-000571 Seiwa Electronics Co.
-000572 Deonet Co., Ltd.
-000573 Cisco Systems, Inc.
-000574 Cisco Systems, Inc.
-000575 CDS-Electronics BV
-000576 NSM Technology Ltd.
-000577 SM Information & Communication
-000579 Universal Control Solution Corp.
-00057A Hatteras Networks
-00057B Chung Nam Electronic Co., Ltd.
-00057C RCO Security AB
-00057D Sun Communications, Inc.
-00057E Eckelmann Steuerungstechnik GmbH
-00057F Acqis Technology
-000580 Fibrolan Ltd.
-000581 Snell & Wilcox Ltd.
-000582 ClearCube Technology
-000583 ImageCom Limited
-000584 AbsoluteValue Systems, Inc.
-000585 Juniper Networks, Inc.
-000586 Lucent Technologies
-000587 Locus, Incorporated
-000588 Sensoria Corp.
-000589 National Datacomputer
-00058A Netcom Co., Ltd.
-00058B IPmental, Inc.
-00058C Opentech Inc.
-00058D Lynx Photonic Networks, Inc.
-00058E Flextronics International GmbH & Co. Nfg. KG
-00058F CLCsoft co.
-000590 Swissvoice Ltd.
-000591 Active Silicon Ltd.
-000592 Pultek Corp.
-000593 Grammar Engine Inc.
-000594 IXXAT Automation GmbH
-000595 Alesis Corporation
-000596 Genotech Co., Ltd.
-000597 Eagle Traffic Control Systems
-000598 CRONOS S.r.l.
-000599 DRS Test and Energy Management or DRS-TEM
-00059A Cisco Systems, Inc.
-00059B Cisco Systems, Inc.
-00059C Kleinknecht GmbH, Ing. Buero
-00059D Daniel Computing Systems, Inc.
-00059E Zinwell Corporation
-00059F Yotta Networks, Inc.
-0005A0 MOBILINE Kft.
-0005A1 Zenocom
-0005A2 CELOX Networks
-0005A3 QEI, Inc.
-0005A4 Lucid Voice Ltd.
-0005A5 KOTT
-0005A6 Extron Electronics
-0005A7 Hyperchip, Inc.
-0005A8 WYLE ELECTRONICS
-0005A9 Princeton Networks, Inc.
-0005AA Moore Industries International Inc.
-0005AB Cyber Fone, Inc.
-0005AC Northern Digital, Inc.
-0005AD Topspin Communications, Inc.
-0005AE Mediaport USA
-0005AF InnoScan Computing A/S
-0005B0 Korea Computer Technology Co., Ltd.
-0005B1 ASB Technology BV
-0005B2 Medison Co., Ltd.
-0005B3 Asahi-Engineering Co., Ltd.
-0005B4 Aceex Corporation
-0005B5 Broadcom Technologies
-0005B6 INSYS Microelectronics GmbH
-0005B7 Arbor Technology Corp.
-0005B8 Electronic Design Associates, Inc.
-0005B9 Airvana, Inc.
-0005BA Area Netwoeks, Inc.
-0005BB Myspace AB
-0005BC Resorsys Ltd.
-0005BD ROAX BV
-0005BE Kongsberg Seatex AS
-0005BF JustEzy Technology, Inc.
-0005C0 Digital Network Alacarte Co., Ltd.
-0005C1 A-Kyung Motion, Inc.
-0005C2 Soronti, Inc.
-0005C3 Pacific Instruments, Inc.
-0005C4 Telect, Inc.
-0005C5 Flaga HF
-0005C6 Triz Communications
-0005C7 I/F-COM A/S
-0005C8 VERYTECH
-0005C9 LG Innotek
-0005CA Hitron Technology, Inc.
-0005CB ROIS Technologies, Inc.
-0005CC Sumtel Communications, Inc.
-0005CD Denon, Ltd.
-0005CE Prolink Microsystems Corporation
-0005CF Thunder River Technologies, Inc.
-0005D0 Solinet Systems
-0005D1 Metavector Technologies
-0005D2 DAP Technologies
-0005D3 eProduction Solutions, Inc.
-0005D4 FutureSmart Networks, Inc.
-0005D5 Speedcom Wireless
-0005D6 Titan Wireless
-0005D7 Vista Imaging, Inc.
-0005D8 Arescom, Inc.
-0005D9 Techno Valley, Inc.
-0005DA Apex Automationstechnik
-0005DB Nentec GmbH
-0005DC Cisco Systems, Inc.
-0005DD Cisco Systems, Inc.
-0005DE Gi Fone Korea, Inc.
-0005DF Electronic Innovation, Inc.
-0005E0 Empirix Corp.
-0005E1 Trellis Photonics, Ltd.
-0005E2 Creativ Network Technologies
-0005E3 LightSand Communications, Inc.
-0005E4 Red Lion Controls L.P.
-0005E5 Renishaw PLC
-0005E6 Egenera, Inc.
-0005E7 Netrake Corp.
-0005E8 TurboWave, Inc.
-0005E9 Unicess Network, Inc.
-0005EA Rednix
-0005EB Blue Ridge Networks, Inc.
-0005EC Mosaic Systems Inc.
-0005ED Technikum Joanneum GmbH
-0005EE BEWATOR Group
-0005EF ADOIR Digital Technology
-0005F0 SATEC
-0005F1 Vrcom, Inc.
-0005F2 Power R, Inc.
-0005F3 Weboyn
-0005F4 System Base Co., Ltd.
-0005F5 OYO Geospace Corp.
-0005F6 Young Chang Co. Ltd.
-0005F7 Analog Devices, Inc.
-0005F8 Real Time Access, Inc.
-0005F9 TOA Corporation
-0005FA IPOptical, Inc.
-0005FB ShareGate, Inc.
-0005FC Schenck Pegasus Corp.
-0005FD PacketLight Networks Ltd.
-0005FE Traficon N.V.
-0005FF SNS Solutions, Inc.
-000600 Tokyo Electronic Industry Co., Ltd.
-000601 Otanikeiki Co., Ltd.
-000602 Cirkitech Electronics Co.
-000603 Baker Hughes Inc.
-000604 @Track Communications, Inc.
-000605 Inncom International, Inc.
-000606 RapidWAN, Inc.
-000607 Omni Directional Control Technology Inc.
-000608 At-Sky SAS
-000609 Crossport Systems
-00060A Blue2space
-00060B Paceline Systems Corporation
-00060C Melco Industries, Inc.
-00060D Wave7 Optics
-00060E IGYS Systems, Inc.
-00060F Narad Networks Inc
-000610 Abeona Networks Inc
-000611 Zeus Wireless, Inc.
-000612 Accusys, Inc.
-000613 Kawasaki Microelectronics Incorporated
-000614 Prism Holdings
-000615 Kimoto Electric Co., Ltd.
-000616 Tel Net Co., Ltd.
-000617 Redswitch Inc.
-000618 DigiPower Manufacturing Inc.
-000619 Connection Technology Systems
-00061A Zetari Inc.
-00061B Portable Systems, IBM Japan Co, Ltd
-00061C Hoshino Metal Industries, Ltd.
-00061D MIP Telecom, Inc.
-00061E Maxan Systems
-00061F Vision Components GmbH
-000620 Serial System Ltd.
-000621 Hinox, Co., Ltd.
-000622 Chung Fu Chen Yeh Enterprise Corp.
-000623 MGE UPS Systems France
-000624 Gentner Communications Corp.
-000625 The Linksys Group, Inc.
-000626 MWE GmbH
-000627 Uniwide Technologies, Inc.
-000628 Cisco Systems, Inc.
-000629 IBM CORPORATION
-00062A Cisco Systems, Inc.
-00062B INTRASERVER TECHNOLOGY
-00062C Network Robots, Inc.
-00062D TouchStar Technologies, L.L.C.
-00062E Aristos Logic Corp.
-00062F Pivotech Systems Inc.
-000630 Adtranz Sweden
-000631 Optical Solutions, Inc.
-000632 Mesco Engineering GmbH
-000633 Heimann Biometric Systems GmbH
-000634 GTE Airfone Inc.
-000635 PacketAir Networks, Inc.
-000636 Jedai Broadband Networks
-000637 Toptrend-Meta Information (ShenZhen) Inc.
-000638 Sungjin C&C Co., Ltd.
-000639 Newtec
-00063A Dura Micro, Inc.
-00063B Arcturus Networks, Inc.
-00063C NMI Electronics Ltd
-00063D Microwave Data Systems Inc.
-00063E Opthos Inc.
-00063F Everex Communications Inc.
-000640 White Rock Networks
-000641 ITCN
-000642 Genetel Systems Inc.
-000643 SONO Computer Co., Ltd.
-000644 NEIX Inc.
-000645 Meisei Electric Co. Ltd.
-000646 ShenZhen XunBao Network Technology Co Ltd
-000647 Etrali S.A.
-000648 Seedsware, Inc.
-000649 Quante
-00064A Honeywell Co., Ltd. (KOREA)
-00064B Alexon Co., Ltd.
-00064C Invicta Networks, Inc.
-00064D Sencore
-00064E Broad Net Technology Inc.
-00064F PRO-NETS Technology Corporation
-000650 Tiburon Networks, Inc.
-000651 Aspen Networks Inc.
-000652 Cisco Systems, Inc.
-000653 Cisco Systems, Inc.
-000654 Maxxio Technologies
-000655 Yipee, Inc.
-000656 Tactel AB
-000657 Market Central, Inc.
-000658 Helmut Fischer GmbH & Co. KG
-000659 EAL (Apeldoorn) B.V.
-00065A Strix Systems
-00065B Dell Computer Corp.
-00065C Malachite Technologies, Inc.
-00065D Heidelberg Web Systems
-00065E Photuris, Inc.
-00065F ECI Telecom - NGTS Ltd.
-000660 NADEX Co., Ltd.
-000661 NIA Home Technologies Corp.
-000662 MBM Technology Ltd.
-000663 Human Technology Co., Ltd.
-000664 Fostex Corporation
-000665 Sunny Giken, Inc.
-000666 Roving Networks
-000667 Tripp Lite
-000668 Vicon Industries Inc.
-000669 Datasound Laboratories Ltd
-00066A InfiniCon Systems, Inc.
-00066B Sysmex Corporation
-00066C Robinson Corporation
-00066D Compuprint S.P.A.
-00066E Delta Electronics, Inc.
-00066F Korea Data Systems
-000670 Upponetti Oy
-000671 Softing AG
-000672 Netezza
-000673 Optelecom, Inc.
-000674 Spectrum Control, Inc.
-000675 Banderacom, Inc.
-000676 Novra Technologies Inc.
-000677 SICK AG
-000678 Marantz Japan, Inc.
-000679 Konami Corporation
-00067A JMP Systems
-00067B Toplink C&C Corporation
-00067C CISCO SYSTEMS, INC.
-00067D Takasago Ltd.
-00067E WinCom Systems, Inc.
-00067F Rearden Steel Technologies
-000680 Card Access, Inc.
-000681 Goepel Electronic GmbH
-000682 Convedia
-000683 Bravara Communications, Inc.
-000684 Biacore AB
-000685 NetNearU Corporation
-000686 ZARDCOM Co., Ltd.
-000687 Omnitron Systems Technology, Inc.
-000688 Telways Communication Co., Ltd.
-000689 yLez Technologies Pte Ltd
-00068A NeuronNet Co. Ltd. R&D Center
-00068B AirRunner Technologies, Inc.
-00068C 3Com Corporation
-00068D SANgate Systems
-00068E HID Corporation
-00068F Telemonitor, Inc.
-000690 Euracom Communication GmbH
-000691 PT Inovacao
-000692 Intruvert Networks, Inc.
-000693 Flexus Computer Technology, Inc.
-000694 Mobillian Corporation
-000695 Ensure Technologies, Inc.
-000696 Advent Networks
-000697 R & D Center
-000698 egnite Software GmbH
-000699 Vida Design Co.
-00069A e & Tel
-00069B AVT Audio Video Technologies GmbH
-00069C Transmode Systems AB
-00069D Petards Mobile Intelligence
-00069E UNIQA, Inc.
-00069F Kuokoa Networks
-0006A0 Mx Imaging
-0006A1 Celsian Technologies, Inc.
-0006A2 Microtune, Inc.
-0006A3 Bitran Corporation
-0006A4 INNOWELL Corp.
-0006A5 PINON Corp.
-0006A6 Artistic Licence (UK) Ltd
-0006A7 Primarion
-0006A8 KC Technology, Inc.
-0006A9 Universal Instruments Corp.
-0006AA Miltope Corporation
-0006AB W-Link Systems, Inc.
-0006AC Intersoft Co.
-0006AD KB Electronics Ltd.
-0006AE Himachal Futuristic Communications Ltd
-0006B0 Comtech EF Data Corp.
-0006B1 Sonicwall
-0006B2 Linxtek Co.
-0006B3 Diagraph Corporation
-0006B4 Vorne Industries, Inc.
-0006B5 Luminent, Inc.
-0006B6 Nir-Or Israel Ltd.
-0006B7 TELEM GmbH
-0006B8 Bandspeed Pty Ltd
-0006B9 A5TEK Corp.
-0006BA Westwave Communications
-0006BB ATI Technologies Inc.
-0006BC Macrolink, Inc.
-0006BD BNTECHNOLOGY Co., Ltd.
-0006BE Baumer Optronic GmbH
-0006BF Accella Technologies Co., Ltd.
-0006C0 United Internetworks, Inc.
-0006C1 CISCO SYSTEMS, INC.
-0006C2 Smartmatic Corporation
-0006C3 Schindler Elevators Ltd.
-0006C4 Piolink Inc.
-0006C5 INNOVI Technologies Limited
-0006C6 lesswire AG
-0006C7 RFNET Technologies Pte Ltd (S)
-0006C8 Sumitomo Metal Micro Devices, Inc.
-0006C9 Technical Marketing Research, Inc.
-0006CA American Computer & Digital Components, Inc. (ACDC)
-0006CB Jotron Electronics A/S
-0006CC JMI Electronics Co., Ltd.
-0006CD CreoScitex Corporation Ltd.
-0006CE DATENO
-0006CF Thales Avionics In-Flight Systems, LLC
-0006D0 Elgar Electronics Corp.
-0006D1 Tahoe Networks, Inc.
-0006D2 Tundra Semiconductor Corp.
-0006D3 Alpha Telecom, Inc. U.S.A.
-0006D4 Interactive Objects, Inc.
-0006D5 Diamond Systems Corp.
-0006D6 Cisco Systems, Inc.
-0006D7 Cisco Systems, Inc.
-0006D8 Maple Optical Systems
-0006D9 IPM-Net S.p.A.
-0006DA ITRAN Communications Ltd.
-0006DB ICHIPS Co., Ltd.
-0006DC Syabas Technology (Amquest)
-0006DD AT & T Laboratories - Cambridge Ltd
-0006DE Flash Technology
-0006DF AIDONIC Corporation
-0006E0 MAT Co., Ltd.
-0006E1 Techno Trade s.a
-0006E2 Ceemax Technology Co., Ltd.
-0006E3 Quantitative Imaging Corporation
-0006E4 Citel Technologies Ltd.
-0006E5 Fujian Newland Computer Ltd. Co.
-0006E6 DongYang Telecom Co., Ltd.
-0006E7 Bit Blitz Communications Inc.
-0006E8 Optical Network Testing, Inc.
-0006E9 Intime Corp.
-0006EA ELZET80 Mikrocomputer GmbH&Co. KG
-0006EB Global Data
-0006EC M/A COM Private Radio System Inc.
-0006ED Inara Networks
-0006EE Shenyang Neu-era Information & Technology Stock Co., Ltd
-0006EF Maxxan Systems, Inc.
-0006F0 Digeo, Inc.
-0006F1 Optillion
-0006F2 Platys Communications
-0006F3 AcceLight Networks
-0006F4 Prime Electronics & Satellitics Inc.
-0006F9 Mitsui Zosen Systems Research Inc.
-0006FA IP SQUARE Co, Ltd.
-0006FB Hitachi Printing Solutions, Ltd.
-0006FC Fnet Co., Ltd.
-0006FD Comjet Information Systems Corp.
-0006FE Celion Networks, Inc.
-0006FF Sheba Systems Co., Ltd.
-000700 Zettamedia Korea
-000701 RACAL-DATACOM
-000702 Varian Medical Systems
-000703 CSEE Transport
-000705 Endress & Hauser GmbH & Co
-000706 Sanritz Corporation
-000707 Interalia Inc.
-000708 Bitrage Inc.
-000709 Westerstrand Urfabrik AB
-00070A Unicom Automation Co., Ltd.
-00070B Octal, SA
-00070C SVA-Intrusion.com Co. Ltd.
-00070D Cisco Systems Inc.
-00070E Cisco Systems Inc.
-00070F Fujant, Inc.
-000710 Adax, Inc.
-000711 Acterna
-000712 JAL Information Technology
-000713 IP One, Inc.
-000714 Brightcom
-000715 General Research of Electronics, Inc.
-000716 J & S Marine Ltd.
-000717 Wieland Electric GmbH
-000718 iCanTek Co., Ltd.
-000719 Mobiis Co., Ltd.
-00071A Finedigital Inc.
-00071B Position Technology Inc.
-00071C AT&T Fixed Wireless Services
-00071D Satelsa Sistemas Y Aplicaciones De Telecomunicaciones, S.A.
-00071E Tri-M Engineering / Nupak Dev. Corp.
-00071F European Systems Integration
-000720 Trutzschler GmbH & Co. KG
-000721 Formac Elektronik GmbH
-000722 Nielsen Media Research
-000723 ELCON Systemtechnik GmbH
-000724 Telemax Co., Ltd.
-000725 Bematech International Corp.
-000727 Zi Corporation (HK) Ltd.
-000728 Neo Telecom
-000729 Kistler Instrumente AG
-00072A Innovance Networks
-00072B Jung Myung Telecom Co., Ltd.
-00072C Fabricom
-00072D CNSystems
-00072E North Node AB
-00072F Instransa, Inc.
-000730 Hutchison OPTEL Telecom Technology Co., Ltd.
-000731 Spiricon, Inc.
-000732 AAEON Technology Inc.
-000733 DANCONTROL Engineering
-000734 ONStor, Inc.
-000735 Flarion Technologies, Inc.
-000736 Data Video Technologies Co., Ltd.
-000737 Soriya Co. Ltd.
-000738 Young Technology Co., Ltd.
-000739 Motion Media Technology Ltd.
-00073A Inventel Systemes
-00073B Tenovis GmbH & Co KG
-00073C Telecom Design
-00073D Nanjing Postel Telecommunications Co., Ltd.
-00073E China Great-Wall Computer Shenzhen Co., Ltd.
-00073F Woojyun Systec Co., Ltd.
-000740 Melco Inc.
-000741 Sierra Automated Systems
-000742 Current Technologies
-000743 Chelsio Communications
-000744 Unico, Inc.
-000745 Radlan Computer Communications Ltd.
-000746 Interlink BT, LLC
-000747 Mecalc
-000748 The Imaging Source Europe
-000749 CENiX Inc.
-00074A Carl Valentin GmbH
-00074B Daihen Corporation
-00074C Beicom Inc.
-00074D Zebra Technologies Corp.
-00074E Naughty boy co., Ltd.
-00074F Cisco Systems, Inc.
-000750 Cisco Systems, Inc.
-000751 m.u.t. - GmbH
-000752 Rhythm Watch Co., Ltd.
-000753 Beijing Qxcomm Technology Co., Ltd.
-000754 Xyterra Computing, Inc.
-000755 Lafon SA
-000756 Juyoung Telecom
-000757 Topcall International AG
-000758 Dragonwave
-000759 Boris Manufacturing Corp.
-00075A Air Products and Chemicals, Inc.
-00075B Gibson Guitars
-00075C ENCAD, Inc.
-00075D Celleritas Inc.
-00075E Pulsar Technologies, Inc.
-00075F VCS Video Communication Systems AG
-000760 TOMIS Information & Telecom Corp.
-000761 Logitech SA
-000762 Group Sense Limited
-000763 Sunniwell Cyber Tech. Co., Ltd.
-000764 YoungWoo Telecom Co. Ltd.
-000765 Jade Quantum Technologies, Inc.
-000766 Chou Chin Industrial Co., Ltd.
-000767 Yuxing Electronics Company Limited
-000768 Danfoss A/S
-000769 Italiana Macchi SpA
-00076A NEXTEYE Co., Ltd.
-00076B Stralfors AB
-00076C Daehanet, Inc.
-00076D Flexlight Networks
-00076E Sinetica Corporation Ltd.
-00076F Synoptics Limited
-000770 Locusnetworks Corporation
-000771 Embedded System Corporation
-000772 Alcatel Shanghai Bell Co., Ltd.
-000773 Ascom Powerline Communications Ltd.
-000774 GuangZhou Thinker Technology Co. Ltd.
-000775 Valence Semiconductor, Inc.
-000776 Federal APD
-000777 Motah Ltd.
-000778 GERSTEL GmbH & Co. KG
-000779 Sungil Telecom Co., Ltd.
-00077A Infoware System Co., Ltd.
-00077B Millimetrix Broadband Networks
-00077C OnTime Networks
-00077E Elrest GmbH
-00077F J Communications Co., Ltd.
-000780 Bluegiga Technologies OY
-000781 Itron Inc.
-000782 Nauticus Networks, Inc.
-000783 SynCom Network, Inc.
-000784 Cisco Systems Inc.
-000785 Cisco Systems Inc.
-000786 Wireless Networks Inc.
-000787 Idea System Co., Ltd.
-000788 Clipcomm, Inc.
-000789 Eastel Systems Corporation
-00078A Mentor Data System Inc.
-00078B Wegener Communications, Inc.
-00078C Elektronikspecialisten i Borlange AB
-00078D NetEngines Ltd.
-00078E Garz & Friche GmbH
-00078F Emkay Innovative Products
-000790 Tri-M Technologies (s) Limited
-000791 International Data Communications, Inc.
-000792 Suetron Electronic GmbH
-000794 Simple Devices, Inc.
-000795 Elitegroup Computer System Co. (ECS)
-000796 LSI Systems, Inc.
-000797 Netpower Co., Ltd.
-000798 Selea SRL
-000799 Tipping Point Technologies, Inc.
-00079A SmartSight Networks Inc.
-00079B Aurora Networks
-00079C Golden Electronics Technology Co., Ltd.
-00079D Musashi Co., Ltd.
-00079E Ilinx Co., Ltd.
-00079F Action Digital Inc.
-0007A0 e-Watch Inc.
-0007A1 VIASYS Healthcare GmbH
-0007A2 Opteon Corporation
-0007A3 Ositis Software, Inc.
-0007A4 GN Netcom Ltd.
-0007A5 Y.D.K Co. Ltd.
-0007A6 Home Automation, Inc.
-0007A7 A-Z Inc.
-0007A8 Haier Group Technologies Ltd.
-0007A9 Novasonics
-0007AA Quantum Data Inc.
-0007AC Eolring
-0007AD Pentacon GmbH Foto-und Feinwerktechnik
-0007AE Layer N Networks
-0007AF N-Tron Corp.
-0007B0 Office Details, Inc.
-0007B1 Equator Technologies
-0007B2 Transaccess S.A.
-0007B3 Cisco Systems Inc.
-0007B4 Cisco Systems Inc.
-0007B5 Any One Wireless Ltd.
-0007B6 Telecom Technology Ltd.
-0007B7 Samurai Ind. Prods Eletronicos Ltda
-0007B8 American Predator Corp.
-0007B9 Ginganet Corporation
-0007BA Xebeo Communications, Inc.
-0007BB Candera Inc.
-0007BC Identix Inc.
-0007BD Radionet Ltd.
-0007BE DataLogic SpA
-0007BF Armillaire Technologies, Inc.
-0007C0 NetZerver Inc.
-0007C1 Overture Networks, Inc.
-0007C2 Netsys Telecom
-0007C3 Cirpack
-0007C4 JEAN Co. Ltd.
-0007C5 Gcom, Inc.
-0007C6 VDS Vosskuhler GmbH
-0007C7 Synectics Systems Limited
-0007C8 Brain21, Inc.
-0007C9 Technol Seven Co., Ltd.
-0007CA Creatix Polymedia Ges Fur Kommunikaitonssysteme
-0007CB Freebox SA
-0007CC Kaba Benzing GmbH
-0007CD NMTEL Co., Ltd.
-0007CE Cabletime Limited
-0007CF Anoto AB
-0007D0 Automat Engenharia de Automaoa Ltda.
-0007D1 Spectrum Signal Processing Inc.
-0007D2 Logopak Systeme
-0007D3 Stork Digital Imaging B.V.
-0007D4 Zhejiang Yutong Network Communication Co Ltd.
-0007D5 3e Technologies Int;., Inc.
-0007D6 Commil Ltd.
-0007D7 Caporis Networks AG
-0007D8 Hitron Systems Inc.
-0007D9 Splicecom
-0007DA Neuro Telecom Co., Ltd.
-0007DB Kirana Networks, Inc.
-0007DC Atek Co, Ltd.
-0007DD Cradle Technologies
-0007DE eCopilt AB
-0007DF Vbrick Systems Inc.
-0007E0 Palm Inc.
-0007E1 WIS Communications Co. Ltd.
-0007E2 Bitworks, Inc.
-0007E3 Navcom Technology, Inc.
-0007E4 SoftRadio Co., Ltd.
-0007E5 Coup Corporation
-0007E6 edgeflow Canada Inc.
-0007E7 FreeWave Technologies
-0007E8 St. Bernard Software
-0007E9 Intel Corporation
-0007EA Massana, Inc.
-0007EB Cisco Systems Inc.
-0007EC Cisco Systems Inc.
-0007ED Altera Corporation
-0007EE telco Informationssysteme GmbH
-0007EF Lockheed Martin Tactical Systems
-0007F0 LogiSync Corporation
-0007F1 TeraBurst Networks Inc.
-0007F2 IOA Corporation
-0007F3 Think Engine Networks
-0007F4 Eletex Co., Ltd.
-0007F5 Bridgeco Co AG
-0007F6 Qqest Software Systems
-0007F7 Galtronics
-0007F8 ITDevices, Inc.
-0007F9 Phonetics, Inc.
-0007FA ITT Co., Ltd.
-0007FB Giga Stream UMTS Technologies GmbH
-0007FC Adept Systems Inc.
-0007FD LANergy Ltd.
-0007FE Rigaku Corporation
-0007FF Gluon Networks
-000800 MULTITECH SYSTEMS, INC.
-000801 HighSpeed Surfing Inc.
-000802 Compaq Computer Corporation
-000803 Cos Tron
-000804 ICA Inc.
-000805 Techno-Holon Corporation
-000806 Raonet Systems, Inc.
-000807 Access Devices Limited
-000808 PPT Vision, Inc.
-000809 Systemonic AG
-00080A Espera-Werke GmbH
-00080B Birka BPA Informationssystem AB
-00080C VDA elettronica SrL
-00080D Toshiba
-00080E Motorola, BCS
-00080F Proximion Fiber Optics AB
-000810 Key Technology, Inc.
-000811 VOIX Corporation
-000812 GM-2 Corporation
-000813 Diskbank, Inc.
-000814 TIL Technologies
-000815 CATS Co., Ltd.
-000816 Bluetags A/S
-000817 EmergeCore Networks LLC
-000818 Pixelworks, Inc.
-000819 Banksys
-00081A Sanrad Intelligence Storage Communications (2000) Ltd.
-00081B Windigo Systems
-00081C @pos.com
-00081D Ipsil, Incorporated
-00081E Repeatit AB
-00081F Pou Yuen Tech Corp. Ltd.
-000820 Cisco Systems Inc.
-000821 Cisco Systems Inc.
-000822 InPro Comm
-000823 Texa Corp.
-000824 Promatek Industries Ltd.
-000825 Acme Packet
-000826 Colorado Med Tech
-000827 Pirelli Cables & Systems
-000828 Koei Engineering Ltd.
-000829 Aval Nagasaki Corporation
-00082A Powerwallz Network Security
-00082B Wooksung Electronics, Inc.
-00082C Homag AG
-00082D Indus Teqsite Private Limited
-00082E Multitone Electronics PLC
-00084E DivergeNet, Inc.
-00084F Qualstar Corporation
-000850 Arizona Instrument Corp.
-000851 Canadian Bank Note Company, Ltd.
-000852 Davolink Co. Inc.
-000853 Schleicher GmbH & Co. Relaiswerke KG
-000854 Netronix, Inc.
-000855 NASA-Goddard Space Flight Center
-000856 Gamatronic Electronic Industries Ltd.
-000857 Polaris Networks, Inc.
-000858 Novatechnology Inc.
-000859 ShenZhen Unitone Electronics Co., Ltd.
-00085A IntiGate Inc.
-00085B Hanbit Electronics Co., Ltd.
-00085C Shanghai Dare Technologies Co. Ltd.
-00085D Aastra
-00085E PCO AG
-00085F Picanol N.V.
-000860 LodgeNet Entertainment Corp.
-000861 SoftEnergy Co., Ltd.
-000862 NEC Eluminant Technologies, Inc.
-000863 Entrisphere Inc.
-000864 Fasy S.p.A.
-000865 JASCOM CO., LTD
-000866 DSX Access Systems, Inc.
-000867 Uptime Devices
-000868 PurOptix
-000869 Command-e Technology Co.,Ltd.
-00086A Industrie Technik IPS GmbH
-00086B MIPSYS
-00086C Plasmon LMS
-00086D Missouri FreeNet
-00086E Hyglo AB
-00086F Resources Computer Network Ltd.
-000870 Rasvia Systems, Inc.
-000871 NORTHDATA Co., Ltd.
-000872 Sorenson Technologies, Inc.
-000873 DAP Design B.V.
-000874 Dell Computer Corp.
-000875 Acorp Electronics Corp.
-000876 SDSystem
-000877 Liebert HIROSS S.p.A.
-000878 Benchmark Storage Innovations
-000879 CEM Corporation
-00087A Wipotec GmbH
-00087B RTX Telecom A/S
-00087C Cisco Systems, Inc.
-00087D Cisco Systems Inc.
-00087E Bon Electro-Telecom Inc.
-00087F SPAUN electronic GmbH & Co. KG
-000880 BroadTel Canada Communications inc.
-000881 DIGITAL HANDS CO.,LTD.
-000882 SIGMA CORPORATION
-000883 Hewlett-Packard Company
-000884 Index Braille AB
-000885 EMS Dr. Thomas Wuensche
-000886 Hansung Teliann, Inc.
-000887 Maschinenfabrik Reinhausen GmbH
-000888 OULLIM Information Technology Inc,.
-000889 Echostar Technologies Corp
-00088A Minds@Work
-00088B Tropic Networks Inc.
-00088C Quanta Network Systems Inc.
-00088D Sigma-Links Inc.
-00088E Nihon Computer Co., Ltd.
-00088F ADVANCED DIGITAL TECHNOLOGY
-000890 AVILINKS SA
-000891 Lyan Inc.
-000892 EM Solutions
-000894 InnoVISION Multimedia Ltd.
-000895 DIRC Technologie GmbH & Co.KG
-000896 Printronix, Inc.
-000897 Quake Technologies
-000898 Gigabit Optics Corporation
-000899 Netbind, Inc.
-00089A Alcatel Microelectronics
-00089B ICP Electronics Inc.
-00089C Elecs Industry Co., Ltd.
-00089D UHD-Elektronik
-00089E Beijing Enter-Net co.LTD
-00089F EFM Networks
-0008A0 Stotz Feinmesstechnik GmbH
-0008A1 CNet Technology Inc.
-0008A2 ADI Engineering, Inc.
-0008A3 Cisco Systems
-0008A4 Cisco Systems
-0008A5 Peninsula Systems Inc.
-0008A6 Multiware & Image Co., Ltd.
-0008A7 iLogic Inc.
-0008A8 Systec Co., Ltd.
-0008A9 SangSang Technology, Inc.
-0008AA KARAM
-0008AB EnerLinx.com, Inc.
-0008AD Toyo-Linx Co., Ltd.
-0008AE Packetfront
-0008AF Novatec Corporation
-0008B0 BKtel communications GmbH
-0008B1 ProQuent Systems
-0008B2 SHENZHEN COMPASS TECHNOLOGY DEVELOPMENT CO.,LTD
-0008B3 Fastwel
-0008B4 SYSPOL
-0008B5 TAI GUEN ENTERPRISE CO., LTD
-0008B6 RouteFree, Inc.
-0008B7 HIT Incorporated
-0008B8 E.F. Johnson
-0008B9 KAON MEDIA Co., Ltd.
-0008BA Erskine Systems Ltd
-0008BB NetExcell
-0008BC Ilevo AB
-0008BD TEPG-US
-0008BE XENPAK MSA Group
-0008BF Aptus Elektronik AB
-0008C0 ASA SYSTEMS
-0008C1 Avistar Communications Corporation
-0008C2 Cisco Systems
-0008C3 Contex A/S
-0008C4 Hikari Co.,Ltd.
-0008C5 Liontech Co., Ltd.
-0008C6 Philips Consumer Communications
-0008C7 COMPAQ COMPUTER CORPORATION
-0008C8 Soneticom, Inc.
-0008C9 TechniSat Digital GmbH
-0008CA TwinHan Technology Co.,Ltd
-0008CB Zeta Broadband Inc.
-0008CC Remotec, Inc.
-0008CD With-Net Inc
-0008CF Nippon Koei Power Systems Co., Ltd.
-0008D0 Musashi Engineering Co., LTD.
-0008D1 KAREL INC.
-0008D2 ZOOM Networks Inc.
-0008D3 Hercules Technologies S.A.
-0008D4 IneoQuest Technologies, Inc
-0008D5 Vanguard Managed Solutions
-0008D6 HASSNET Inc.
-0008D7 HOW CORPORATION
-0008D8 Dowkey Microwave
-0008D9 Mitadenshi Co.,LTD
-0008DA SofaWare Technologies Ltd.
-0008DB Corrigent Systems
-0008DC Wiznet
-0008DD Telena Communications, Inc.
-0008DE 3UP Systems
-0008DF Alistel Inc.
-0008E0 ATO Technology Ltd.
-0008E1 Barix AG
-0008E2 Cisco Systems
-0008E3 Cisco Systems
-0008E4 Envenergy Inc
-0008E5 IDK Corporation
-0008E6 Littlefeet
-0008E7 SHI ControlSystems,Ltd.
-0008E8 Excel Master Ltd.
-0008E9 NextGig
-0008EA Motion Control Engineering, Inc
-0008EB ROMWin Co.,Ltd.
-0008EC Zonu, Inc.
-0008ED ST&T Instrument Corp.
-0008EE Logic Product Development
-0008EF DIBAL,S.A.
-0008F0 Next Generation Systems, Inc.
-0008F1 Voltaire
-0008F2 C&S Technology
-0008F3 WANY
-0008F4 Bluetake Technology Co., Ltd.
-0008F5 YESTECHNOLOGY Co.,Ltd.
-0008F6 SUMITOMO ELECTRIC HIGHTECHS.co.,ltd.
-0008F7 Hitachi Ltd, Semiconductor &amp; Integrated Circuits Gr
-0008F8 Guardall Ltd
-0008F9 Padcom, Inc.
-0008FA Karl E.Brinkmann GmbH
-0008FB SonoSite, Inc.
-0008FC Gigaphoton Inc.
-0008FD BlueKorea Co., Ltd.
-0008FE UNIK C&C Co.,Ltd.
-0008FF Trilogy Broadcast (Holdings) Ltd
-000900 TMT
-000901 Shenzhen Shixuntong Information & Technoligy Co
-000902 Redline Communications Inc.
-000903 Panasas, Inc
-000904 MONDIAL electronic
-000905 iTEC Technologies Ltd.
-000906 Esteem Networks
-000907 Chrysalis Development
-000908 VTech Technology Corp.
-000909 Telenor Connect A/S
-00090A SnedFar Technology Co., Ltd.
-00090B MTL  Instruments PLC
-00090C Mayekawa Mfg. Co. Ltd.
-00090D LEADER ELECTRONICS CORP.
-00090E Helix Technology Inc.
-00090F Fortinet Inc.
-000910 Simple Access Inc.
-000911 Cisco Systems
-000912 Cisco Systems
-000914 COMPUTROLS INC.
-000915 CAS Corp.
-000916 Listman Home Technologies, Inc.
-000917 WEM Technology Inc
-000918 SAMSUNG TECHWIN CO.,LTD
-000919 MDS Gateways
-00091A Macat Optics & Electronics Co., Ltd.
-00091B Digital Generation Inc.
-00091C CacheVision, Inc
-00091D Proteam Computer Corporation
-00091E Firstech Technology Corp.
-00091F A&amp;D Co., Ltd.
-000920 EpoX COMPUTER CO.,LTD.
-000921 Planmeca Oy
-000922 Touchless Sensor Technology AG
-000923 Heaman System Co., Ltd
-000924 Telebau GmbH
-000925 VSN Systemen BV
-000926 YODA COMMUNICATIONS, INC.
-000927 TOYOKEIKI CO.,LTD.
-000928 Telecore Inc
-000929 Sanyo Industries (UK) Limited
-00092A MYTECS Co.,Ltd.
-00092B iQstor Networks, Inc.
-00092C Hitpoint Inc.
-00092D High Tech Computer, Corp.
-00092E B&Tech System Inc.
-00092F Akom Technology Corporation
-000930 AeroConcierge Inc.
-000931 Future Internet, Inc.
-000932 Omnilux
-000933 OPTOVALLEY Co. Ltd.
-000934 Dream-Multimedia-Tv GmbH
-000935 Sandvine Incorporated
-000936 Ipetronik GmbH & Co.KG
-000937 Inventec Appliance Corp
-000938 Allot Communications
-000939 ShibaSoku Co.,Ltd.
-00093A Molex Fiber Optics
-00093B HYUNDAI NETWORKS INC.
-00093C Jacques Technologies P/L
-00093D Newisys,Inc.
-00093E C&I Technologies
-00093F Double-Win Enterpirse CO., LTD
-000940 AGFEO GmbH & Co. KG
-000941 Allied Telesis K.K.
-000942 CRESCO, LTD.
-000943 Cisco Systems
-000944 Cisco Systems
-000945 Palmmicro Communications Inc
-000946 Cluster Labs GmbH
-000947 Aztek, Inc.
-000948 Vista Control Systems, Corp.
-000949 Glyph Technologies Inc.
-00094A Homenet Communications
-00094B FillFactory NV
-00094C Communication Weaver Co.,Ltd.
-00094D Braintree Communications Pty Ltd
-00094E BARTECH SYSTEMS INTERNATIONAL, INC
-00094F elmegt GmbH & Co. KG
-000950 Independent Storage Corporation
-000951 Apogee Instruments, Inc
-000952 Auerswald GmbH & Co. KG
-000953 Linkage System Integration Co.Ltd.
-000954 AMiT spol. s. r. o.
-000955 Young Generation International Corp.
-000956 Network Systems Group, Ltd. (NSG)
-000957 Supercaller, Inc.
-000958 INTELNET S.A.
-000959 Sitecsoft
-00095A RACEWOOD TECHNOLOGY
-00095B Netgear, Inc.
-00095C Philips Medical Systems - Cardiac and Monitoring Systems (CM
-00095D Dialogue Technology Corp.
-00095E Masstech Group Inc.
-00095F Telebyte, Inc.
-000960 YOZAN Inc.
-000961 Switchgear and Instrumentation Ltd
-000962 Filetrac AS
-000963 Dominion Lasercom Inc.
-000964 Hi-Techniques
-000966 Thales Navigation
-000967 Tachyon, Inc
-000968 TECHNOVENTURE, INC.
-000969 Meret Optical Communications
-00096A Cloverleaf Communications Inc.
-00096B IBM Corporation
-00096C Imedia Semiconductor Corp.
-00096D Powernet Technologies Corp.
-00096E GIANT ELECTRONICS LTD.
-00096F Beijing Zhongqing Elegant Tech. Corp.,Limited
-000970 Vibration Research Corporation
-000971 Time Management, Inc.
-000972 Securebase,Inc
-000973 Lenten Technology Co., Ltd.
-000974 Innopia Technologies, Inc.
-000975 fSONA Communications Corporation
-000976 Datasoft ISDN Systems GmbH
-000977 Brunner Elektronik AG
-000978 AIJI System Co., Ltd.
-000979 Advanced Television Systems Committee, Inc.
-00097A Louis Design Labs.
-00097B Cisco Systems
-00097C Cisco Systems
-00097D SecWell Networks Oy
-00097E IMI TECHNOLOGY CO., LTD
-00097F Vsecure 2000 LTD.
-000980 Power Zenith Inc.
-000981 Newport Networks
-000982 Loewe Opta GmbH
-000983 Gvision Incorporated
-000984 MyCasa Network Inc.
-000985 Auto Telecom Company
-000986 Metalink LTD.
-000987 NISHI NIPPON ELECTRIC WIRE & CABLE CO.,LTD.
-000988 Nudian Electron Co., Ltd.
-000989 VividLogic Inc.
-00098A EqualLogic Inc
-00098B Entropic Communications, Inc.
-00098C Possio AB
-00098D DCT Ltd (Digital Communication Technologies Ltd)
-00098E ipcas GmbH
-00098F Cetacean Networks
-000990 ACKSYS Communications & systems
-000991 GE Fanuc Automation Manufacturing, Inc.
-000992 InterEpoch Technology,INC.
-000993 Visteon Corporation
-000994 Cronyx Engineering
-000995 Castle Technology Ltd
-000996 RDI
-000997 Nortel Networks
-000998 Capinfo Company Limited
-000999 CP GEORGES RENAULT
-00099A ELMO COMPANY, LIMITED
-00099B Western Telematic Inc.
-00099C Naval Research Laboratory
-00099D Haliplex Communications
-00099E Testech, Inc.
-00099F VIDEX INC.
-0009A0 Microtechno Corporation
-0009A1 Telewise Communications, Inc.
-0009A2 Interface Co., Ltd.
-0009A3 Leadfly Techologies Corp. Ltd.
-0009A4 HARTEC Corporation
-0009A5 HANSUNG ELETRONIC INDUSTRIES DEVELOPMENT CO., LTD
-0009A6 Ignis Optics, Inc.
-0009A7 Bang & Olufsen A/S
-0009A8 Eastmode Pte Ltd
-0009A9 Ikanos Communications
-0009AA Data Comm for Business, Inc.
-0009AB Netcontrol Oy
-0009AC LANVOICE
-0009AD HYUNDAI SYSCOMM, INC.
-0009AE OKANO ELECTRIC CO.,LTD
-0009AF e-generis
-0009B0 Onkyo Corporation
-0009B1 Kanematsu Electronics, Ltd.
-0009B2 L&F Inc.
-0009B3 MCM Systems Ltd
-0009B4 KISAN TELECOM CO., LTD.
-0009B5 3J Tech. Co., Ltd.
-0009B6 Cisco Systems
-0009B7 Cisco Systems
-0009B8 Entise Systems
-0009B9 Action Imaging Solutions
-0009BA MAKU Informationstechik GmbH
-0009BB MathStar, Inc.
-0009BC Digital Safety Technologies Inc.
-0009BD Epygi Technologies, Ltd.
-0009BE Mamiya-OP Co.,Ltd.
-0009BF Nintendo Co.,Ltd.
-0009C0 6WIND
-0009C1 PROCES-DATA A/S
-0009C3 NETAS
-0009C4 Medicore Co., Ltd
-0009C5 KINGENE Technology Corporation
-0009C6 Visionics Corporation
-0009C7 Movistec
-0009C8 SINAGAWA TSUSHIN KEISOU SERVICE
-0009C9 BlueWINC Co., Ltd.
-0009CA iMaxNetworks(Shenzhen)Limited.
-0009CB HBrain
-0009CC Moog GmbH
-0009CD HUDSON SOFT CO.,LTD.
-0009CE SpaceBridge Semiconductor Corp.
-0009CF iAd GmbH
-0009D0 Versatel Networks
-0009D1 SERANOA NETWORKS INC
-0009D2 Mai Logic Inc.
-0009D3 Western DataCom Co., Inc.
-0009D4 Transtech Networks
-0009D5 Signal Communication, Inc.
-0009D6 KNC One GmbH
-0009D7 DC Security Products
-0009D9 Neoscale Systems, Inc
-0009DA Control Module Inc.
-0009DB eSpace
-0009DC Galaxis Technology AG
-0009DD Mavin Technology Inc.
-0009DE Samjin Information & Communications Co., Ltd.
-0009DF Vestel Komunikasyon Sanayi ve Ticaret A.S.
-0009E0 XEMICS S.A.
-0009E1 Gemtek Technology Co., Ltd.
-0009E2 Sinbon Electronics Co., Ltd.
-0009E3 Angel Iglesias S.A.
-0009E4 K Tech Infosystem Inc.
-0009E5 Hottinger Baldwin Messtechnik GmbH
-0009E6 Cyber Switching Inc.
-0009E7 ADC Techonology
-0009E8 Cisco Systems
-0009E9 Cisco Systems
-0009EA YEM Inc.
-0009EB HuMANDATA LTD.
-0009EC Daktronics, Inc.
-0009ED CipherOptics
-0009EE MEIKYO ELECTRIC CO.,LTD
-0009EF Vocera Communications
-0009F0 Shimizu Technology Inc.
-0009F1 Yamaki Electric Corporation
-0009F2 Cohu, Inc., Electronics Division
-0009F3 WELL Communication Corp.
-0009F4 Alcon Laboratories, Inc.
-0009F5 Emerson Network Power Co.,Ltd
-0009F6 Shenzhen Eastern Digital Tech Ltd.
-0009F7 SED, a division of Calian
-0009F8 UNIMO TECHNOLOGY CO., LTD.
-0009F9 ART JAPAN CO., LTD.
-0009FB Philips Medizinsysteme Boeblingen GmbH
-0009FC IPFLEX Inc.
-0009FD Ubinetics Limited
-0009FE Daisy Technologies, Inc.
-0009FF X.net 2000 GmbH
-000A00 Mediatek Corp.
-000A01 SOHOware, Inc.
-000A02 ANNSO CO., LTD.
-000A03 ENDESA SERVICIOS, S.L.
-000A04 3Com Europe Ltd
-000A05 Widax Corp.
-000A06 Teledex LLC
-000A07 WebWayOne Ltd
-000A08 ALPINE ELECTRONICS, INC.
-000A09 TaraCom Integrated Products, Inc.
-000A0A SUNIX Co., Ltd.
-000A0B Sealevel Systems, Inc.
-000A0C Scientific Research Corporation
-000A0D MergeOptics GmbH
-000A0E Invivo Research Inc.
-000A0F Ilryung Telesys, Inc
-000A10 FAST media integrations AG
-000A11 ExPet Technologies, Inc
-000A12 Azylex Technology, Inc
-000A13 Silent Witness
-000A14 TECO a.s.
-000A15 Silicon Data, Inc
-000A16 Lassen Research
-000A17 NESTAR COMMUNICATIONS, INC
-000A18 Vichel Inc.
-000A19 Valere Power, Inc.
-000A1A Imerge Ltd
-000A1B Stream Labs
-000A1C Bridge Information Co., Ltd.
-000A1D Optical Communications Products Inc.
-000A1E Red-M (Communications) Limited
-000A1F ART WARE Telecommunication Co., Ltd.
-000A20 SVA Networks, Inc.
-000A21 Integra Telecom Co. Ltd
-000A22 Amperion Inc
-000A23 Parama Networks Inc
-000A24 Octave Communications
-000A25 CERAGON NETWORKS
-000A26 CEIA S.p.A.
-000A27 Apple Computer, Inc.
-000A28 Motorola
-000A29 Pan Dacom Networking AG
-000A2A QSI Systems Inc.
-000A2B Etherstuff
-000A2C Active Tchnology Corporation
-000A2E MAPLE NETWORKS CO., LTD
-000A2F Artnix Inc.
-000A30 Johnson Controls-ASG
-000A31 HCV Wireless
-000A32 Xsido Corporation
-000A33 Sierra Logic, Inc.
-000A34 Identicard Systems Incorporated
-000A35 Xilinx
-000A36 Synelec Telecom Multimedia
-000A37 Procera Networks, Inc.
-000A38 Netlock Technologies, Inc.
-000A39 LoPA Information Technology
-000A3A J-THREE INTERNATIONAL Holding Co., Ltd.
-000A3B GCT Semiconductor, Inc
-000A3C Enerpoint Ltd.
-000A3D Elo Sistemas Eletronicos S.A.
-000A3E EADS Telecom
-000A3F Data East Corporation
-000A40 Crown Audio
-000A41 Cisco Systems
-000A42 Cisco Systems
-000A43 Chunghwa Telecom Co., Ltd.
-000A44 Avery Dennison Deutschland GmbH
-000A45 Audio-Technica Corp.
-000A46 ARO Controls SAS
-000A47 Allied Vision Technologies
-000A48 Albatron Technology
-000A49 Acopia Networks
-000A4A Targa Systems Ltd.
-000A4B DataPower Technology, Inc.
-000A4C Molecular Devices Corporation
-000A4D Noritz Corporation
-000A4E UNITEK Electronics INC.
-000A4F Brain Boxes Limited
-000A50 REMOTEK CORPORATION
-000A51 GyroSignal Technology Co., Ltd.
-000A52 Venitek Co. Ltd.
-000A53 Intronics, Incorporated
-000A54 Laguna Hills, Inc.
-000A55 MARKEM Corporation
-000A56 HITACHI Maxell Ltd.
-000A57 Hewlett-Packard Company - Standards
-000A58 Ingenieur-Buero Freyer & Siegel
-000A59 HW server
-000A5A GreenNET Technologies Co.,Ltd.
-000A5B Power-One as
-000A5C Carel s.p.a.
-000A5D PUC Founder (MSC) Berhad
-000A5E 3COM Corporation
-000A5F almedio inc.
-000A60 Autostar Technology Pte Ltd
-000A61 Cellinx Systems Inc.
-000A62 Crinis Networks, Inc.
-000A63 DHD GmbH
-000A64 Eracom Technologies
-000A65 GentechMedia.co.,ltd.
-000A66 MITSUBISHI ELECTRIC SYSTEM & SERVICE CO.,LTD.
-000A67 OngCorp
-000A68 SolarFlare Communications, Inc.
-000A69 SUNNY bell Technology Co., Ltd.
-000A6A SVM Microwaves s.r.o.
-000A6B Tadiran Telecom Business Systems LTD
-000A6C Walchem Corporation
-000A6D EKS Elektronikservice GmbH
-000A6E Broadcast Technology Limited
-000A6F ZyTera Technologies Inc.
-000A70 MPLS Forum
-000A71 Avrio Technologies, Inc
-000A72 SimpleTech, Inc.
-000A73 Scientific Atlanta
-000A74 Manticom Networks Inc.
-000A75 Cat Electronics
-000A76 Beida Jade Bird Huaguang Technology Co.,Ltd
-000A77 Bluewire Technologies LLC
-000A78 OLITEC
-000A79 corega K.K.
-000A7A Kyoritsu Electric Co., Ltd.
-000A7B Cornelius Consult
-000A7C Tecton Ltd
-000A7D Valo, Inc.
-000A7E The Advantage Group
-000A7F Teradon Industries, Inc
-000A80 Telkonet Inc.
-000A81 TEIMA Audiotex S.L.
-000A82 TATSUTA SYSTEM ELECTRONICS CO.,LTD.
-000A83 SALTO SYSTEMS S.L.
-000A84 Rainsun Enterprise Co., Ltd.
-000A85 PLAT'C2,Inc
-000A86 Lenze
-000A87 Integrated Micromachines Inc.
-000A88 InCypher S.A.
-000A89 Creval Systems, Inc.
-000A8A Cisco Systems
-000A8B Cisco Systems
-000A8C Guardware Systems Ltd.
-000A8D EUROTHERM LIMITED
-000A8E Invacom Ltd
-000A8F Aska International Inc.
-000A90 Bayside Interactive, Inc.
-000A91 HemoCue AB
-000A92 Presonus Corporation
-000A93 W2 Networks, Inc.
-000A94 ShangHai cellink CO., LTD
-000A95 Apple Computer, Inc.
-000A96 MEWTEL TECHNOLOGY INC.
-000A97 SONICblue, Inc.
-000A98 M+F Gwinner GmbH & Co
-000A99 Dataradio Inc.
-000A9A Aiptek International Inc
-000A9B Towa Meccs Corporation
-000A9C Server Technology, Inc.
-000A9D King Young Technology Co. Ltd.
-000A9E BroadWeb Corportation
-000A9F Pannaway Technologies, Inc.
-000AA0 Cedar Point Communications
-000AA1 V V S Limited
-000AA2 SYSTEK INC.
-000AA3 SHIMAFUJI ELECTRIC CO.,LTD.
-000AA4 SHANGHAI SURVEILLANCE TECHNOLOGY CO,LTD
-000AA5 MAXLINK INDUSTRIES LIMITED
-000AA6 Hochiki Corporation
-000AA7 FEI Company
-000AA8 ePipe Pty. Ltd.
-000AA9 Brooks Automation GmbH
-000AAA AltiGen Communications Inc.
-000AAB TOYOTA MACS, INC.
-000AAC TerraTec Electronic GmbH
-000AAD Stargames Corporation
-000AAE Rosemount Process Analytical
-000AAF Pipal Systems
-000AB0 LOYTEC electronics GmbH
-000AB1 GENETEC Corporation
-000AB2 Fresnel Wireless Systems
-000AB3 Fa. GIRA
-000AB4 ETIC Telecommunications
-000AB5 Digital Electronic Network
-000AB6 COMPUNETIX, INC
-000AB7 Cisco Systems
-000AB8 Cisco Systems
-000AB9 Astera Technologies Corp.
-000ABA Arcon Technology Limited
-000ABB Taiwan Secom Co,. Ltd
-000ABC Seabridge Ltd.
-000ABD Rupprecht & Patashnick Co.
-000ABE OPNET Technologies CO., LTD.
-000ABF HIROTA SS
-000AC0 Fuyoh Video Industry CO., LTD.
-000AC1 Futuretel
-000AC2 FiberHome Telecommunication Technologies CO.,LTD
-000AC3 eM Technics Co., Ltd.
-000AC4 Daewoo Teletech Co., Ltd
-000AC5 Color Kinetics
-000AC7 Unication Group
-000AC8 ZPSYS CO.,LTD. (Planning&Management)
-000AC9 Zambeel Inc
-000ACA YOKOYAMA SHOKAI CO.,Ltd.
-000ACB XPAK MSA Group
-000ACC Winnow Networks, Inc.
-000ACD Sunrich Technology Limited
-000ACE RADIANTECH, INC.
-000ACF PROVIDEO Multimedia Co. Ltd.
-000AD0 Niigata Develoment Center,  F.I.T. Co., Ltd.
-000AD1 MWS
-000AD2 JEPICO Corporation
-000AD3 INITECH Co., Ltd
-000AD4 CoreBell Systems Inc.
-000AD5 Brainchild Electronic Co., Ltd.
-000AD6 BeamReach Networks
-000AD8 IPCserv Technology Corp.
-000AD9 Sony Ericsson Mobile Communications AB
-000ADB SkyPilot Network, Inc
-000ADC RuggedCom Inc.
-000ADD InSciTek Microsystems, Inc.
-000ADE Happy Communication Co., Ltd.
-000ADF Gennum Corporation
-000AE0 Fujitsu Softek
-000AE1 EG Technology
-000AE2 Binatone Electronics International, Ltd
-000AE3 YANG MEI TECHNOLOGY CO., LTD
-000AE4 Wistron Corp.
-000AE5 ScottCare Corporation
-000AE6 Elitegroup Computer System Co. (ECS)
-000AE7 ELIOP S.A.
-000AE8 Cathay Roxus Information Technology Co. LTD
-000AE9 AirVast Technology Inc.
-000AEA ADAM ELEKTRONIK LTD.STI.
-000AEB Shenzhen Tp-link Technology Co; Ltd.
-000AEC Koatsu Gas Kogyo Co., Ltd.
-000AED HARTING Vending G.m.b.H. & CO KG
-000AEE GCD Hard- & Software GmbH
-000AEF OTRUM ASA
-000AF0 SHIN-OH ELECTRONICS CO., LTD. R&D
-000AF1 Clarity Design, Inc.
-000AF2 NeoAxiom Corp.
-000AF3 Cisco Systems
-000AF4 Cisco Systems
-000AF5 Airgo Networks, Inc.
-000AF6 Computer Process Controls
-000AF7 Broadcom Corp.
-000AF8 American Telecare Inc.
-000AFA Traverse Technologies Australia
-000AFB Ambri Limited
-000AFC Core Tec Communications, LLC
-000AFD Viking Electronic Services
-000AFE NovaPal Ltd
-000AFF Kilchherr Elektronik AG
-000B00 FUJIAN START COMPUTER EQUIPMENT CO.,LTD
-000B01 DAIICHI ELECTRONICS CO., LTD.
-000B02 Dallmeier electronic
-000B03 Taekwang Industrial Co., Ltd
-000B04 Volktek Corporation
-000B05 Pacific Broadband Networks
-000B06 Motorola BCS
-000B07 Voxpath Networks
-000B08 Pillar Data Systems
-000B09 Ifoundry Systems Singapore
-000B0A dBm Optics
-000B0B Corrent Corporation
-000B0C Agile Systems Inc.
-000B0D Air2U, Inc.
-000B0E Trapeze Networks
-000B0F Nyquist Industrial Control BV
-000B10 11wave Technonlogy Co.,Ltd
-000B11 HIMEJI ABC TRADING CO.,LTD.
-000B13 ZETRON INC
-000B14 ViewSonic Corporation
-000B15 Platypus Technology
-000B16 Communication Machinery Corporation
-000B17 MKS Instruments
-000B19 Vernier Networks, Inc.
-000B1A Teltone Corporation
-000B1B Systronix, Inc.
-000B1D LayerZero Power Systems, Inc.
-000B1E KAPPA opto-electronics GmbH
-000B1F I CON Computer Co.
-000B20 Hirata corporation
-000B21 G-Star Communications Inc.
-000B22 Environmental Systems and Services
-000B23 Efficient Networks, Inc.
-000B24 AirLogic
-000B25 Aeluros
-000B26 Wetek Corporation
-000B27 Scion Corporation
-000B28 Quatech Inc.
-000B29 LG Industrial Systems Co.,Ltd.
-000B2A HOWTEL Co., Ltd.
-000B2B HOSTNET CORPORATION
-000B2C Eiki Industrial Co. Ltd.
-000B2D Danfoss Inc.
-000B2E Cal-Comp Electronics (Thailand) Public Company Limited Taipe
-000B2F bplan GmbH
-000B30 Beijing Gongye Science & Technology Co.,Ltd
-000B31 Yantai ZhiYang Scientific and technology industry CO., LTD
-000B32 VORMETRIC, INC.
-000B33 Vivato
-000B34 ShangHai Broadband Technologies CO.LTD
-000B35 Quad Bit System co., Ltd.
-000B36 Productivity Systems, Inc.
-000B37 MANUFACTURE DES MONTRES ROLEX SA
-000B38 Knuerr AG
-000B39 Keisoku Giken Co.,Ltd.
-000B3A Fortel DTV, Inc.
-000B3B devolo AG
-000B3C Cygnal Integrated Products, Inc.
-000B3D CONTAL OK Ltd.
-000B3E BittWare, Inc
-000B3F Anthology Solutions Inc.
-000B40 OpNext Inc.
-000B41 Ing. Buero Dr. Beutlhauser
-000B42 commax Co., Ltd.
-000B43 Microscan Systems, Inc.
-000B44 Concord IDea Corp.
-000B45 Cisco
-000B46 Cisco
-000B47 Advanced Energy
-000B48 sofrel
-000B49 RF-Link System Inc.
-000B4A Visimetrics (UK) Ltd
-000B4B VISIOWAVE SA
-000B4C Clarion (M) Sdn Bhd
-000B4D Emuzed
-000B4E VertexRSI Antenna Products Division
-000B4F Verifone, INC.
-000B50 Oxygnet
-000B51 Micetek International Inc.
-000B52 JOYMAX ELECTRONICS CORP.
-000B53 INITIUM Co., Ltd.
-000B54 BiTMICRO Networks, Inc.
-000B55 ADInstruments
-000B56 Cybernetics
-000B57 Silicon Laboratories
-000B58 Astronautics C.A  LTD
-000B59 ScriptPro, LLC
-000B5A HyperEdge
-000B5B Rincon Research Corporation
-000B5C Newtech Co.,Ltd
-000B5D FUJITSU LIMITED
-000B5E ATMAVA Ltd
-000B5F Cisco Systems
-000B60 Cisco Systems
-000B61 Friedrich Lütze GmbH &Co.
-000B62 Ingenieurbüro Ingo Mohnen
-000B64 Kieback & Peter GmbH & Co KG
-000B65 Sy.A.C. srl
-000B66 Teralink Communications
-000B67 Topview Technology Corporation
-000B68 Addvalue Communications Pte Ltd
-000B69 Franke Finland Oy
-000B6A Asiarock Incorporation
-000B6B Wistron Neweb Corp.
-000B6C Sychip Inc.
-000B6D SOLECTRON JAPAN NAKANIIDA
-000B6E Neff Instrument Corp.
-000B6F Media Streaming Networks Inc
-000B70 Load Technology, Inc.
-000B71 Litchfield Communications Inc.
-000B72 Lawo AG
-000B73 Kodeos Communications
-000B74 Kingwave Technology Co., Ltd.
-000B75 Iosoft Ltd.
-000B76 ET&T Co. Ltd.
-000B77 Cogent Systems, Inc.
-000B78 TAIFATECH INC.
-000B79 X-COM, Inc.
-000B7B Test-Um Inc.
-000B7C Telex Communications
-000B7D SOLOMON EXTREME INTERNATIONAL LTD.
-000B7E SAGINOMIYA Seisakusho Inc.
-000B7F OmniWerks
-000B81 Kaparel Corporation
-000B82 Grandstream Networks, Inc.
-000B83 DATAWATT B.V.
-000B84 BODET
-000B85 Airespace, Inc.
-000B86 Aruba Networks
-000B87 American Reliance Inc.
-000B88 Vidisco ltd.
-000B89 Top Global Technology, Ltd.
-000B8A MITEQ Inc.
-000B8B KERAJET, S.A.
-000B8C flextronics israel
-000B8D Avvio Networks
-000B8E Ascent Corporation
-000B8F AKITA ELECTRONICS SYSTEMS CO.,LTD.
-000B90 Covaro Networks, Inc.
-000B91 Aglaia Gesellschaft für Bildverarbeitung und Kommunikation m
-000B92 Ascom Danmark A/S
-000B93 Barmag Electronic
-000B94 Digital Monitoring Products, Inc.
-000B95 eBet Gaming Systems Pty Ltd
-000B96 Innotrac Diagnostics Oy
-000B97 Matsushita Electric Industrial Co.,Ltd.
-000B98 NiceTechVision
-000B99 SensAble Technologies, Inc.
-000B9A Shanghai Ulink Telecom Equipment Co. Ltd.
-000B9B Sirius System Co, Ltd.
-000B9C TriBeam Technologies, Inc.
-000B9D TwinMOS Technologies Inc.
-000B9E Yasing Technology Corp.
-000B9F Neue ELSA GmbH
-000BA0 T&L Information Inc.
-000BA1 SYSCOM Ltd.
-000BA2 Sumitomo Electric Networks, Inc
-000BA3 Siemens AG, I&S
-000BA4 Shiron Satellite Communications Ltd. (1996)
-000BA5 Quasar Cipta Mandiri, PT
-000BA6 Miyakawa Electric Works Ltd.
-000BA7 Maranti Networks
-000BA8 HANBACK ELECTRONICS CO., LTD.
-000BAA Aiphone co.,Ltd
-000BAB Advantech Technology (CHINA) Co., Ltd.
-000BAC 3Com Europe Ltd.
-000BAD PC-PoS Inc.
-000BAE Vitals System Inc.
-000BB0 Sysnet Telematica srl
-000BB1 Super Star Technology Co., Ltd.
-000BB2 SMALLBIG TECHNOLOGY
-000BB3 RiT technologies Ltd.
-000BB4 RDC Semiconductor Inc.,
-000BB5 nStor Technologies, Inc.
-000BB6 Mototech Inc.
-000BB7 Micro Systems Co.,Ltd.
-000BB8 Kihoku Electronic Co.
-000BB9 Imsys AB
-000BBA Harmonic Broadband Access Networks
-000BBB Etin Systems Co., Ltd
-000BBC En Garde Systems, Inc.
-000BBD Connexionz Limited
-000BBE Cisco Systems
-000BBF Cisco Systems
-000BC0 China IWNComm Co., Ltd.
-000BC1 Bay Microsystems, Inc.
-000BC2 Corinex Communication Corp.
-000BC3 Multiplex, Inc.
-000BC4 BIOTRONIK GmbH & Co
-000BC5 SMC Networks, Inc.
-000BC6 ISAC, Inc.
-000BC7 ICET S.p.A.
-000BC8 AirFlow Networks
-000BC9 Electroline Equipment
-000BCA DATAVAN International Corporation
-000BCB Fagor Automation , S. Coop
-000BCC JUSAN, S.A.
-000BCD Compaq (HP)
-000BCE Free2move AB
-000BCF AGFA NDT INC.
-000BD0 XiMeta Technology Americas Inc.
-000BD1 Aeronix, Inc.
-000BD2 Remopro Technology Inc.
-000BD3 cd3o
-000BD4 Beijing Wise Technology & Science Development Co.Ltd
-000BD5 Nvergence, Inc.
-000BD6 Paxton Access Ltd
-000BD7 MBB Gelma GmbH
-000BD8 Industrial Scientific Corp.
-000BD9 General Hydrogen
-000BDA EyeCross Co.,Inc.
-000BDB Dell ESG PCBA Test
-000BDC AKCP
-000BDD TOHOKU RICOH Co., LTD.
-000BDF Shenzhen RouterD Networks Limited
-000BE0 SercoNet Ltd.
-000BE2 Lumenera Corporation
-000BE3 Key Stream Co., Ltd.
-000BE4 Hosiden Corporation
-000BE5 HIMS Korea Co., Ltd.
-000BE6 Datel Electronics
-000BE7 COMFLUX TECHNOLOGY INC.
-000BE8 AOIP
-000BEA Zultys Technologies
-000BEB Systegra AG
-000BEC NIPPON ELECTRIC INSTRUMENT, INC.
-000BED ELM Inc.
-000BEE inc.jet, Incorporated
-000BEF Code Corporation
-000BF0 MoTEX Products Co., Ltd.
-000BF1 LAP Laser Applikations
-000BF2 Chih-Kan Technology Co., Ltd.
-000BF3 BAE SYSTEMS
-000BF5 Shanghai Sibo Telecom Technology Co.,Ltd
-000BF6 Nitgen Co., Ltd
-000BF7 NIDEK CO.,LTD
-000BF8 Infinera
-000BF9 Gemstone communications, Inc.
-000BFB D-NET International Corporation
-000BFC Cisco Systems
-000BFD Cisco Systems
-000BFE CASTEL Broadband Limited
-000BFF Berkeley Camera Engineering
-000C00 BEB Industrie-Elektronik AG
-000C01 Abatron AG
-000C02 ABB Oy
-000C03 HDMI Licensing, LLC
-000C04 Tecnova
-000C05 RPA Reserch Co., Ltd.
-000C06 Nixvue Systems  Pte Ltd
-000C07 Iftest AG
-000C08 HUMEX Technologies Corp.
-000C09 Hitachi IE Systems Co., Ltd
-000C0A Guangdong Province Electronic Technology Research Institute
-000C0B Broadbus Technologies
-000C0C APPRO TECHNOLOGY INC.
-000C0D Communications & Power Industries / Satcom Division
-000C0E XtremeSpectrum, Inc.
-000C0F Techno-One Co., Ltd
-000C10 PNI Corporation
-000C11 NIPPON DEMPA CO.,LTD.
-000C12 Micro-Optronic-Messtechnik GmbH
-000C13 MediaQ
-000C14 Diagnostic Instruments, Inc.
-000C15 CyberPower Systems, Inc.
-000C16 Concorde Microsystems Inc.
-000C17 AJA Video Systems Inc
-000C18 Zenisu Keisoku Inc.
-000C19 Telio Communications GmbH
-000C1A Quest Technical Solutions Inc.
-000C1B ORACOM Co, Ltd.
-000C1C MicroWeb Co., Ltd.
-000C1D Mettler & Fuchs AG
-000C1E Global Cache
-000C1F Glimmerglass Networks
-000C20 Fi WIn, Inc.
-000C21 Faculty of Science and Technology, Keio University
-000C22 Double D Electronics Ltd
-000C23 Beijing Lanchuan Tech. Co., Ltd.
-000C25 Allied Telesyn Networks
-000C26 Weintek Labs. Inc.
-000C27 Sammy Corporation
-000C28 RIFATRON
-000C29 VMware, Inc.
-000C2A OCTTEL Communication Co., Ltd.
-000C2B ELIAS Technology, Inc.
-000C2C Enwiser Inc.
-000C2D FullWave Technology Co., Ltd.
-000C2E Openet information technology(shenzhen) Co., Ltd.
-000C2F SeorimTechnology Co.,Ltd.
-000C30 Cisco
-000C31 Cisco
-000C32 Avionic Design Development GmbH
-000C33 Compucase Enterprise Co. Ltd.
-000C34 Vixen Co., Ltd.
-000C35 KaVo Dental GmbH & Co. KG
-000C36 SHARP TAKAYA ELECTRONICS INDUSTRY CO.,LTD.
-000C37 Geomation, Inc.
-000C38 TelcoBridges Inc.
-000C39 Sentinel Wireless Inc.
-000C3A Oxance
-000C3B Orion Electric Co., Ltd.
-000C3C MediaChorus, Inc.
-000C3D Glsystech Co., Ltd.
-000C3E Crest Audio
-000C3F Cogent Defence & Security Networks,
-000C40 Altech Controls
-000C41 The Linksys Group, Inc.
-000C42 Routerboard.com
-000C43 Ralink Technology, Corp.
-000C44 Automated Interfaces, Inc.
-000C45 Animation Technologies Inc.
-000C46 Allied Telesyn Inc.
-000C47 SK Teletech(R&D Planning Team)
-000C48 QoStek Corporation
-000C49 Dangaard Telecom RTC Division A/S
-000C4A Cygnus Microsystems Private Limited
-000C4B Cheops Elektronik
-000C4C Arcor AG&Co.
-000C4D ACRA CONTROL
-000C4E Winbest Technology CO,LT
-000C4F UDTech Japan Corporation
-000C50 Seagate Technology
-000C51 Scientific Technologies Inc.
-000C52 Roll Systems Inc.
-000C54 Pedestal Networks, Inc
-000C55 Microlink Communications Inc.
-000C56 Megatel Computer (1986) Corp.
-000C57 MACKIE Engineering Services Belgium BVBA
-000C58 M&S Systems
-000C59 Indyme Electronics, Inc.
-000C5A IBSmm Industrieelektronik Multimedia
-000C5B HANWANG TECHNOLOGY CO.,LTD
-000C5C GTN Systems B.V.
-000C5D CHIC TECHNOLOGY (CHINA) CORP.
-000C5F Avtec, Inc.
-000C60 ACM Systems
-000C61 AC Tech corporation DBA Advanced Digital
-000C62 ABB Automation Technology Products AB, Control
-000C63 Zenith Electronics Corporation
-000C64 X2 MSA Group
-000C65 Sunin Telecom
-000C66 Pronto Networks Inc
-000C67 OYO ELECTRIC CO.,LTD
-000C68 Oasis Semiconductor, Inc.
-000C69 National Radio Astronomy Observatory
-000C6A MBARI
-000C6B Kurz Industrie-Elektronik GmbH
-000C6C Elgato Systems LLC
-000C6D BOC Edwards
-000C6E ASUSTEK COMPUTER INC.
-000C6F Amtek system co.,LTD.
-000C70 ACC GmbH
-000C71 Wybron, Inc
-000C72 Tempearl Industrial Co., Ltd.
-000C73 TELSON ELECTRONICS CO., LTD
-000C74 RIVERTEC CORPORATION
-000C75 Oriental integrated electronics. LTD
-000C76 MICRO-STAR INTERNATIONAL CO., LTD.
-000C77 Life Racing Ltd
-000C78 In-Tech Electronics Limited
-000C79 Extel Communications P/L
-000C7A DaTARIUS Technologies GmbH
-000C7B ALPHA PROJECT Co.,Ltd.
-000C7C Internet Information Image Inc.
-000C7D TEIKOKU ELECTRIC MFG. CO., LTD
-000C7E Tellium Incorporated
-000C7F synertronixx GmbH
-000C80 Opelcomm Inc.
-000C81 Nulec Industries Pty Ltd
-000C82 NETWORK TECHNOLOGIES INC
-000C83 Logical Solutions
-000C84 Eazix, Inc.
-000C85 Cisco Systems
-000C86 Cisco Systems
-000C87 ATI
-000C88 Apache Micro Peripherals, Inc.
-000C89 AC Electric Vehicles, Ltd.
-000C8A Bose Corporation
-000C8B Connect Tech Inc
-000C8C KODICOM CO.,LTD.
-000C8D MATRIX VISION GmbH
-000C8E Mentor Engineering Inc
-000C8F Nergal s.r.l.
-000C90 Octasic Inc.
-000C91 Riverhead Networks Inc.
-000C92 WolfVision Gmbh
-000C93 Xeline Co., Ltd.
-000C94 United Electronic Industries, Inc.
-000C95 PrimeNet
-000C96 OQO, Inc.
-000C97 NV ADB TTV Technologies SA
-000C98 LETEK Communications Inc.
-000C99 HITEL LINK Co.,Ltd
-000C9A Hitech Electronics Corp.
-000C9B EE Solutions, Inc
-000C9C Chongho information & communications
-000C9D AirWalk Communications, Inc.
-000C9E MemoryLink Corp.
-000C9F NKE Corporation
-000CA0 StorCase Technology, Inc.
-000CA1 SIGMACOM Co., LTD.
-000CA2 Scopus Network Technologies Ltd
-000CA3 Rancho Technology, Inc.
-000CA4 Prompttec Product Management GmbH
-000CA6 Mintera Corporation
-000CA7 Metro (Suzhou) Technologies Co., Ltd.
-000CA8 Garuda Networks Corporation
-000CA9 Ebtron Inc.
-000CAA Cubic Transportation Systems Inc
-000CAB COMMEND International
-000CAC Citizen Watch Co., Ltd.
-000CAD BTU International
-000CAE Ailocom Oy
-000CAF TRI TERM CO.,LTD.
-000CB0 Star Semiconductor Corporation
-000CB1 Salland Engineering (Europe) BV
-000CB2 safei Co., Ltd.
-000CB3 ROUND Co.,Ltd.
-000CB4 Propagate Networks, Inc
-000CB5 Premier Technolgies, Inc
-000CB6 NANJING SEU MOBILE & INTERNET TECHNOLOGY CO.,LTD
-000CB7 Nanjing Huazhuo Electronics Co., Ltd.
-000CB8 MEDION AG
-000CB9 LEA
-000CBA Jamex
-000CBB ISKRAEMECO
-000CBC Iscutum
-000CBD Interface Masters, Inc
-000CBF Holy Stone Ent. Co., Ltd.
-000CC0 Genera Oy
-000CC1 Cooper Industries Inc.
-000CC3 BeWAN systems
-000CC4 Tiptel AG
-000CC5 Nextlink Co., Ltd.
-000CC6 Ka-Ro electronics GmbH
-000CC7 Intelligent Computer Solutions Inc.
-000CC8 Integrated Digital Systems, Inc.
-000CC9 ILWOO DATA & TECHNOLOGY CO.,LTD
-000CCA Hitachi Global Storage Technologies
-000CCB Design Combus Ltd
-000CCC Bluesoft Ltd.
-000CCD IEC - TC57
-000CCE Cisco Systems
-000CCF Cisco Systems
-000CD0 Symetrix
-000CD1 SFOM Technology Corp.
-000CD2 Schaffner EMV AG
-000CD3 Prettl Elektronik Radeberg GmbH
-000CD4 Positron Public Safety Systems inc.
-000CD5 Passave Inc.
-000CD6 PARTNER TECH
-000CD7 Nallatech Ltd
-000CD8 M. K. Juchheim GmbH & Co
-000CD9 Itcare Co., Ltd
-000CDA FreeHand Systems, Inc.
-000CDB Foundry Networks
-000CDC BECS Technology, Inc
-000CDD AOS Technologies AG
-000CDE ABB STOTZ-KONTAKT GmbH
-000CDF PULNiX America, Inc
-000CE0 Trek Diagnostics Inc.
-000CE1 The Open Group
-000CE2 Rolls-Royce
-000CE3 Option International N.V.
-000CE4 NeuroCom International, Inc.
-000CE5 Motorola BCS
-000CE6 Meru Networks Inc
-000CE7 MediaTek Inc.
-000CE8 GuangZhou AnJuBao Co., Ltd
-000CE9 BLOOMBERG L.P.
-000CEA aphona Kommunikationssysteme
-000CEB CNMP Networks, Inc.
-000CEC Spectracom Corp.
-000CED Real Digital Media
-000CEE Q-Networks
-000CEF Open Networks Engineering Ltd
-000CF0 M & N GmbH
-000CF1 Intel Corporation
-000CF2 GAMESA EÓLICA
-000CF3 CALL IMAGE SA
-000CF4 AKATSUKI ELECTRIC MFG.CO.,LTD.
-000CF5 InfoExpress
-000CF6 Sitecom Europe BV
-000CF7 Nortel Networks
-000CF8 Nortel Networks
-000CF9 ITT Flygt AB
-000CFA Digital Systems Corp
-000CFB Korea Network Systems
-000CFC S2io Technologies Corp
-000CFE Grand Electronic Co., Ltd
-000CFF MRO-TEK LIMITED
-000D00 Seaway Networks Inc.
-000D01 P&E Microcomputer Systems, Inc.
-000D02 NEC Access Technica,Ltd
-000D03 Matrics, Inc.
-000D04 Foxboro Eckardt Development GmbH
-000D05 cybernet manufacturing inc.
-000D06 Compulogic Limited
-000D07 Calrec Audio Ltd
-000D08 AboveCable, Inc.
-000D09 Yuehua(Zhuhai) Electronic CO. LTD
-000D0A Projectiondesign as
-000D0B Melco Inc.
-000D0C MDI Security Systems
-000D0D ITSupported, LLC
-000D0E Inqnet Systems, Inc.
-000D0F Finlux Ltd
-000D10 Embedtronics Oy
-000D11 DENTSPLY - Gendex
-000D12 AXELL Corporation
-000D13 Wilhelm Rutenbeck GmbH&Co.
-000D14 Vtech Innovation LP dba Advanced American Telephones
-000D15 Voipac s.r.o.
-000D16 UHS Systems Pty Ltd
-000D17 Turbo Networks Co.Ltd
-000D18 Sunitec Enterprise Co., Ltd.
-000D19 ROBE Show lighting
-000D1A Mustek System Inc.
-000D1B Kyoto Electronics Manufacturing Co., Ltd.
-000D1C I2E TELECOM
-000D1D HIGH-TEK HARNESS ENT. CO., LTD.
-000D1E Control Techniques
-000D1F AV Digital
-000D20 ASAHIKASEI TECHNOSYSTEM CO.,LTD.
-000D21 WISCORE Inc.
-000D22 Unitronics
-000D23 Smart Solution, Inc
-000D24 SENTEC E&E CO., LTD.
-000D25 SANDEN CORPORATION
-000D26 Primagraphics Limited
-000D27 MICROPLEX Printware AG
-000D28 Cisco
-000D29 Cisco
-000D2A Scanmatic AS
-000D2B Racal Instruments
-000D2C Patapsco Designs Ltd
-000D2D NCT Deutschland GmbH
-000D2E Matsushita Avionics Systems Corporation
-000D2F AIN Comm.Tech.Co., LTD
-000D30 IceFyre Semiconductor
-000D31 Compellent Technologies, Inc.
-000D32 DispenseSource, Inc.
-000D33 Prediwave Corp.
-000D34 Shell International Exploration and Production, Inc.
-000D35 PAC International Ltd
-000D36 Wu Han Routon Electronic Co., Ltd
-000D37 WIPLUG
-000D38 NISSIN INC.
-000D39 Network Electronics
-000D3A Microsoft Corp.
-000D3B Microelectronics Technology Inc.
-000D3C i.Tech Dynamic Ltd
-000D3E APLUX Communications Ltd.
-000D3F VXI Technology
-000D40 Verint Loronix Video Solutions
-000D41 Siemens AG ICM MP UC RD IT KLF1
-000D42 Newbest Development Limited
-000D43 DRS Tactical Systems Inc.
-000D45 Tottori SANYO Electric Co., Ltd.
-000D46 Eurotherm Drives, Ltd.
-000D47 Collex
-000D48 AEWIN Technologies Co., Ltd.
-000D49 Triton Systems of Delaware, Inc.
-000D4A Steag ETA-Optik
-000D4B Roku, LLC
-000D4C Outline Electronics Ltd.
-000D4D Ninelanes
-000D4E NDR Co.,LTD.
-000D4F Kenwood Corporation
-000D50 Galazar Networks
-000D51 DIVR Systems, Inc.
-000D52 Comart system
-000D53 Beijing 5w Communication Corp.
-000D54 3Com Europe Ltd
-000D55 SANYCOM Technology Co.,Ltd
-000D56 Dell PCBA Test
-000D57 Fujitsu I-Network Systems Limited.
-000D59 Amity Systems, Inc.
-000D5A Tiesse SpA
-000D5B Smart Empire Investments Limited
-000D5C Robert Bosch GmbH, VT-ATMO
-000D5D Raritan Computer, Inc
-000D5E NEC CustomTechnica, Ltd.
-000D5F Minds Inc
-000D60 IBM Corporation
-000D61 Giga-Byte Technology Co., Ltd.
-000D62 Funkwerk Dabendorf GmbH
-000D63 DENT Instruments, Inc.
-000D64 COMAG Handels AG
-000D65 Cisco Systems
-000D66 Cisco Systems
-000D67 BelAir Networks Inc.
-000D68 Vinci Systems, Inc.
-000D69 TMT&D Corporation
-000D6A Redwood Technologies LTD
-000D6B Mita-Teknik A/S
-000D6C M-Audio
-000D6D K-Tech Devices Corp.
-000D6E K-Patents Oy
-000D6F Ember Corporation
-000D70 Datamax Corporation
-000D71 boca systems
-000D72 2Wire, Inc
-000D73 Technical Support, Inc.
-000D74 Sand Network Systems, Inc.
-000D75 Kobian Pte Ltd - Taiwan Branch
-000D76 Hokuto Denshi Co,. Ltd.
-000D77 FalconStor Software
-000D78 Engineering & Security
-000D79 Dynamic Solutions Co,.Ltd.
-000D7A DiGATTO Asia Pacific Pte Ltd
-000D7B Consensys Computers Inc.
-000D7C Codian Ltd
-000D7D Afco Systems
-000D7E Axiowave Networks, Inc.
-000D7F MIDAS  COMMUNICATION TECHNOLOGIES PTE LTD ( Foreign Branch)
-000D80 Online Development Inc
-000D81 Pepperl+Fuchs GmbH
-000D82 PHS srl
-000D83 Sanmina-SCI Hungary  Ltd.
-000D84 Seodu Inchip, Inc.
-000D85 Tapwave, Inc.
-000D86 Huber + Suhner AG
-000D87 Elitegroup Computer System Co. (ECS)
-000D88 D-Link Corporation
-000D89 Bils Technology Inc
-000D8A Winners Electronics Co., Ltd.
-000D8B T&D Corporation
-000D8C Shanghai Wedone Digital Ltd. CO.
-000D8D ProLinx Communication Gateways, Inc.
-000D8E Koden Electronics Co., Ltd.
-000D8F King Tsushin Kogyo Co., LTD.
-000D90 Factum Electronics AB
-000D91 Eclipse (HQ Espana) S.L.
-000D92 Arima Communication Corporation
-000D93 Apple Computer
-000D94 AFAR Communications,Inc
-000D96 Vtera Technology Inc.
-000D97 Tropos Networks, Inc.
-000D98 S.W.A.C. Schmitt-Walter Automation Consult GmbH
-000D99 Orbital Sciences Corp.; Launch Systems Group
-000D9A INFOTEC LTD
-000D9C Elan GmbH & Co KG
-000D9D Hewlett Packard
-000D9E TOKUDEN OHIZUMI SEISAKUSYO Co.,Ltd.
-000D9F RF Micro Devices
-000DA0 NEDAP N.V.
-000DA1 MIRAE ITS Co.,LTD.
-000DA2 Infrant Technologies, Inc.
-000DA3 Emerging Technologies Limited
-000DA4 DOSCH & AMAND SYSTEMS AG
-000DA5 Fabric7 Systems, Inc
-000DA6 Universal Switching Corporation
-000DA8 Teletronics Technology Corporation
-000DA9 T.E.A.M. S.L.
-000DAA S.A.Tehnology co.,Ltd.
-000DAB Parker Hannifin GmbH Electromechanical Division Europe
-000DAC Japan CBM Corporation
-000DAD Dataprobe Inc
-000DAE SAMSUNG HEAVY INDUSTRIES CO., LTD.
-000DAF Plexus Corp (UK) Ltd
-000DB0 Olym-tech Co.,Ltd.
-000DB1 Japan Network Service Co., Ltd.
-000DB2 Ammasso, Inc.
-000DB3 SDO Communication Corperation
-000DB4 NETASQ
-000DB5 GLOBALSAT TECHNOLOGY CORPORATION
-000DB6 Teknovus, Inc.
-000DB7 SANKO ELECTRIC CO,.LTD
-000DB8 SCHILLER AG
-000DB9 PC Engines GmbH
-000DBA Océ Document Technologies GmbH
-000DBB Nippon Dentsu Co.,Ltd.
-000DBC Cisco Systems
-000DBD Cisco Systems
-000DBE Bel Fuse Europe Ltd.,UK
-000DBF TekTone Sound & Signal Mfg., Inc.
-000DC0 Spagat AS
-000DC1 SafeWeb Inc
-000DC3 First Communication, Inc.
-000DC4 Emcore Corporation
-000DC5 EchoStar International Corporation
-000DC6 DigiRose Technology Co., Ltd.
-000DC7 COSMIC ENGINEERING INC.
-000DC8 AirMagnet, Inc
-000DC9 THALES Elektronik Systeme GmbH
-000DCA Tait Electronics
-000DCB Petcomkorea Co., Ltd.
-000DCC NEOSMART Corp.
-000DCD GROUPE TXCOM
-000DCE Dynavac Technology Pte Ltd
-000DCF Cidra Corp.
-000DD0 TetraTec Instruments GmbH
-000DD1 Stryker Corporation
-000DD2 Simrad Optronics ASA
-000DD3 SAMWOO Telecommunication Co.,Ltd.
-000DD4 Revivio Inc.
-000DD5 O'RITE TECHNOLOGY CO.,LTD
-000DD7 Bright
-000DD8 BBN
-000DD9 Anton Paar GmbH
-000DDA ALLIED TELESIS K.K.
-000DDB AIRWAVE TECHNOLOGIES INC.
-000DDC VAC
-000DDD PROFÝLO TELRA ELEKTRONÝK SANAYÝ VE TÝCARET A.Þ.
-000DDE Joyteck Co., Ltd.
-000DDF Japan Image & Network Inc.
-000DE0 ICPDAS Co.,LTD
-000DE1 Control Products, Inc.
-000DE2 CMZ Sistemi Elettronici
-000DE3 AT Sweden AB
-000DE4 DIGINICS, Inc.
-000DE5 Samsung Thales
-000DE6 YOUNGBO ENGINEERING CO.,LTD
-000DE7 Snap-on OEM Group
-000DE8 Nasaco Electronics Pte. Ltd
-000DE9 Napatech Aps
-000DEA Kingtel Telecommunication Corp.
-000DEB CompXs Limited
-000DEC Cisco Systems
-000DED Cisco Systems
-000DEF Soc. Coop. Bilanciai
-000DF0 QCOM TECHNOLOGY INC.
-000DF1 IONIX INC.
-000DF3 Asmax Solutions
-000DF4 Watertek Co.
-000DF5 Teletronics International Inc.
-000DF6 Technology Thesaurus Corp.
-000DF7 Space Dynamics Lab
-000DF8 ORGA Kartensysteme GmbH
-000DF9 NDS Limited
-000DFA Micro Control Systems Ltd.
-000DFB Komax AG
-000DFC ITFOR Inc. resarch and development
-000DFD Huges Hi-Tech Inc.,
-000DFE Hauppauge Computer Works, Inc.
-000DFF CHENMING MOLD INDUSTRY CORP.
-000E01 ASIP Technologies Inc.
-000E02 Advantech AMT Inc.
-000E03 Aarohi Communications, Inc.
-000E05 WIRELESS MATRIX CORP.
-000E06 Team Simoco Ltd
-000E07 Sony Ericsson Mobile Communications AB
-000E08 Sipura Technology, Inc.
-000E09 Shenzhen Coship Software Co.,LTD.
-000E0B Netac Technology Co., Ltd.
-000E0C Intel Corporation
-000E0D HESCH Schröder GmbH
-000E0E ESA elettronica S.P.A.
-000E0F ERMME
-000E11 BDT Büro- und Datentechnik GmbH & Co. KG
-000E12 Adaptive Micro Systems Inc.
-000E13 Accu-Sort Systems inc.
-000E14 Visionary Solutions, Inc.
-000E15 Tadlys LTD
-000E16 SouthWing
-000E18 MyA Technology
-000E19 LogicaCMG Pty Ltd
-000E1B IAV GmbH
-000E1C Hach Company
-000E1F TCL Networks Equipment Co., Ltd.
-000E20 PalmSource, Inc.
-000E21 MTU Friedrichshafen GmbH
-000E23 Incipient, Inc.
-000E25 Hannae Technology Co., Ltd
-000E26 Gincom Technology Corp.
-000E27 Crere Networks, Inc.
-000E28 Dynamic Ratings P/L
-000E29 Shester Communications Inc
-000E2B Safari Technologies
-000E2C Netcodec co.
-000E2D Hyundai Digital Technology Co.,Ltd.
-000E2E Edimax Technology Co., Ltd.
-000E2F Disetronic Medical Systems AG
-000E30 AERAS Networks, Inc.
-000E31 Olympus BioSystems GmbH
-000E32 Kontron Medical
-000E33 Shuko Electronics Co.,Ltd
-000E34 NexxGenCity
-000E35 Intel Corp
-000E36 HEINESYS, Inc.
-000E37 Harms & Wende GmbH & Co.KG
-000E38 Cisco Systems
-000E39 Cisco Systems
-000E3A Cirrus Logic
-000E3B Hawking Technologies, Inc.
-000E3C TransAct Technoloiges Inc.
-000E3D Televic N.V.
-000E3E Sun Optronics Inc
-000E3F Soronti, Inc.
-000E40 Nortel Networks
-000E41 NIHON MECHATRONICS CO.,LTD.
-000E42 Motic Incoporation Ltd.
-000E43 G-Tek Electronics Sdn. Bhd.
-000E44 Digital 5, Inc.
-000E45 Beijing Newtry Electronic Technology Ltd
-000E46 Niigata Seimitsu Co.,Ltd.
-000E47 NCI System Co.,Ltd.
-000E48 Lipman TransAction Solutions
-000E49 Forsway Scandinavia AB
-000E4A Changchun Huayu WEBPAD Co.,LTD
-000E4B atrium c and i
-000E4C Bermai Inc.
-000E4D Numesa Inc.
-000E4E Waveplus Technology Co., Ltd.
-000E4F Trajet GmbH
-000E50 Thomson Multi Media
-000E51 tecna elettronica srl
-000E52 Optium Corporation
-000E53 AV TECH CORPORATION
-000E54 AlphaCell Wireless Ltd.
-000E55 AUVITRAN
-000E56 4G Systems GmbH
-000E57 Iworld Networking, Inc.
-000E58 Rincon Networks
-000E5A TELEFIELD inc.
-000E5B ParkerVision - Direct2Data
-000E5C Motorola BCS
-000E5D Com-X Networks
-000E5E Beijing Raisecom Science & Technology Development Co.,Ltd
-000E5F activ-net GmbH & Co. KG
-000E60 360SUN Digital Broadband Corporation
-000E61 MICROTROL LIMITED
-000E62 Nortel Networks
-000E63 Lemke Diagnostics GmbH
-000E64 Elphel, Inc
-000E65 TransCore
-000E66 Hitachi Advanced Digital, Inc.
-000E67 Eltis Microelectronics Ltd.
-000E68 E-TOP Network Technology Inc.
-000E69 China Electric Power Research Institute
-000E6A 3COM EUROPE LTD
-000E6B Janitza electronics GmbH
-000E6C Device Drivers Limited
-000E6D Murata Manufacturing Co., Ltd.
-000E6E MICRELEC  ELECTRONICS S.A
-000E6F IRIS Corporation Berhad
-000E70 in2 Networks
-000E71 Gemstar Technology Development Ltd.
-000E72 CTS electronics
-000E73 Tpack A/S
-000E74 Solar Telecom. Tech
-000E75 New York Air Brake Corp.
-000E76 GEMSOC INNOVISION INC.
-000E77 Decru, Inc.
-000E78 Amtelco
-000E79 Ample Communications Inc.
-000E7B Toshiba
-000E7D Electronics Line 3000 Ltd.
-000E7E Comprog Oy
-000E7F Hewlett Packard
-000E81 Instant802 Networks Inc.
-000E82 Commtech Wireless
-000E83 Cisco Systems
-000E84 Cisco Systems
-000E85 Catalyst Enterprises, Inc.
-000E86 Alcatel North America
-000E87 adp Gauselmann GmbH
-000E88 VIDEOTRON CORP.
-000E89 CLEMATIC
-000E8A Avara Technologies Pty. Ltd.
-000E8B Astarte Technology Co, Ltd.
-000E8C Siemens AG A&D ET
-000E8D Systems in Progress Holding GmbH
-000E8E SparkLAN Communications, Inc.
-000E8F Sercomm Corp.
-000E90 PONICO CORP.
-000E92 Millinet Co., Ltd.
-000E93 Milénio 3 Sistemas Electrónicos, Lda.
-000E94 Maas International BV
-000E95 Fujiya Denki Seisakusho Co.,Ltd.
-000E96 Cubic Defense Applications, Inc.
-000E97 Ultracker Technology CO., Inc
-000E98 Vitec CC, INC.
-000E99 Spectrum Digital, Inc
-000E9A BOE TECHNOLOGY GROUP CO.,LTD
-000E9C Pemstar
-000E9D Video Networks Ltd
-000E9E Topfield Co., Ltd
-000E9F TEMIC SDS GmbH
-000EA0 NetKlass Technology Inc.
-000EA1 Formosa Teletek Corporation
-000EA2 CyberGuard Corporation
-000EA3 CNCR-IT CO.,LTD,HangZhou P.R.CHINA
-000EA4 Certance Inc.
-000EA5 BLIP Systems
-000EA6 ASUSTEK COMPUTER INC.
-000EA7 Endace Inc Ltd.
-000EA8 United Technologists Europe Limited
-000EA9 Shanghai Xun Shi Communications Equipment Ltd. Co.
-000EAC MINTRON ENTERPRISE CO., LTD.
-000EAD Metanoia Technologies, Inc.
-000EAE GAWELL TECHNOLOGIES CORP.
-000EAF CASTEL
-000EB0 Solutions Radio BV
-000EB1 Newcotech,Ltd
-000EB2 Micro-Research Finland Oy
-000EB3 LeftHand Networks
-000EB4 GUANGZHOU GAOKE COMMUNICATIONS TECHNOLOGY CO.LTD.
-000EB5 Ecastle Electronics Co., Ltd.
-000EB6 Riverbed Technology, Inc.
-000EB7 Knovative, Inc.
-000EB8 Iiga co.,Ltd
-000EB9 HASHIMOTO Electronics Industry Co.,Ltd.
-000EBA HANMI SEMICONDUCTOR CO., LTD.
-000EBB Everbee Networks
-000EBC Cullmann GmbH
-000EBD Burdick, a Quinton Compny
-000EBE B&B Electronics Manufacturing Co.
-000EC0 Nortel Networks
-000EC1 MYNAH Technologies
-000EC2 Lowrance Electronics, Inc.
-000EC3 Logic Controls, Inc.
-000EC4 Iskra Transmission d.d.
-000EC6 ASIX ELECTRONICS CORP.
-000EC7 Appeal Telecom Co.,Ltd.
-000EC8 Zoran Corporation
-000EC9 YOKO Technology Corp.
-000ECB VineSys Technology
-000ECC Tableau
-000ECD SKOV A/S
-000ECE S.I.T.T.I. S.p.A.
-000ECF PROFIBUS Nutzerorganisation e.V.
-000ED0 Privaris, Inc.
-000ED1 Osaka Micro Computer.
-000ED2 Filtronic plc
-000ED3 Epicenter, Inc.
-000ED4 CRESITT INDUSTRIE
-000ED5 COPAN Systems Inc.
-000ED6 Cisco Systems
-000ED7 Cisco Systems
-000ED8 Aktino, Inc.
-000ED9 Aksys, Ltd.
-000EDA C-TECH UNITED CORP.
-000EDB XiNCOM Corp.
-000EDC Tellion INC.
-000EDD SHURE INCORPORATED
-000EDE REMEC, Inc.
-000EDF PLX Technology
-000EE0 Mcharge
-000EE1 ExtremeSpeed Inc.
-000EE2 Custom Engineering S.p.A.
-000EE3 Chiyu Technology Co.,Ltd
-000EE5 bitWallet, Inc.
-000EE6 Adimos Systems LTD
-000EE7 AAC ELECTRONICS CORP.
-000EE8 zioncom
-000EE9 WayTech Development, Inc.
-000EEA Shadong Luneng Jicheng Electronics,Co.,Ltd
-000EEB Sandmartin(zhong shan)Electronics Co.,Ltd
-000EEC Orban
-000EED Nokia Danmark A/S
-000EEE Muco Industrie BV
-000EF0 Festo AG & Co. KG
-000EF1 EZQUEST INC.
-000EF3 Smarthome
-000EF4 Shenzhen Kasda Digital Technology Co.,Ltd
-000EF5 iPAC Technology Co., Ltd.
-000EF6 E-TEN Information Systems Co., Ltd.
-000EF7 Vulcan Portals Inc
-000EF8 SBC ASI
-000EF9 REA Elektronik GmbH
-000EFA Optoway Technology Incorporation
-000EFB Macey Enterprises
-000EFC JTAG Technologies B.V.
-000EFD FUJI PHOTO OPTICAL CO., LTD.
-000EFE EndRun Technologies LLC
-000EFF Megasolution,Inc.
-000F00 Legra Systems, Inc.
-000F01 DIGITALKS INC
-000F02 Digicube Technology Co., Ltd
-000F03 COM&C CO., LTD
-000F04 cim-usa inc
-000F05 3B SYSTEM INC.
-000F06 Nortel Networks
-000F07 Mangrove Systems, Inc.
-000F08 Indagon Oy
-000F0B Kentima Technologies AB
-000F0C SYNCHRONIC ENGINEERING
-000F0D Hunt Electronic Co., Ltd.
-000F0E WaveSplitter Technologies, Inc.
-000F0F Real ID Technology Co., Ltd.
-000F10 RDM Corporation
-000F11 Prodrive B.V.
-000F12 Panasonic AVC Networks Germany GmbH
-000F13 Nisca corporation
-000F14 Mindray Co., Ltd.
-000F15 Kjaerulff1 A/S
-000F16 JAY HOW TECHNOLOGY CO.,
-000F17 Insta Elektro GmbH
-000F18 Industrial Control Systems
-000F19 Guidant Corporation
-000F1A Gaming Support B.V.
-000F1B Ego Systems Inc.
-000F1C DigitAll World Co., Ltd
-000F1D Cosmo Techs Co., Ltd.
-000F1E Chengdu KT Electric Co.of High & New Technology
-000F1F WW PCBA Test
-000F20 WW Ops
-000F21 Scientific Atlanta, Inc
-000F22 Helius, Inc.
-000F23 Cisco Systems
-000F24 Cisco Systems
-000F25 AimValley B.V.
-000F26 WorldAccxx  LLC
-000F27 TEAL Electronics, Inc.
-000F28 Itronix Corporation
-000F29 Augmentix Corporation
-000F2A Cableware Electronics
-000F2B GREENBELL SYSTEMS
-000F2C Uplogix, Inc.
-001000 CABLE TELEVISION LABORATORIES, INC.
-001001 MCK COMMUNICATIONS
-001002 ACTIA
-001003 IMATRON, INC.
-001004 THE BRANTLEY COILE COMPANY,INC
-001005 UEC COMMERCIAL
-001006 Thales Contact Solutions Ltd.
-001007 CISCO SYSTEMS, INC.
-001008 VIENNA SYSTEMS CORPORATION
-001009 HORO QUARTZ
-00100A WILLIAMS COMMUNICATIONS GROUP
-00100B CISCO SYSTEMS, INC.
-00100C ITO CO., LTD.
-00100D CISCO SYSTEMS, INC.
-00100E MICRO LINEAR COPORATION
-00100F INDUSTRIAL CPU SYSTEMS
-001010 INITIO CORPORATION
-001011 CISCO SYSTEMS, INC.
-001012 PROCESSOR SYSTEMS (I) PVT LTD
-001013 INDUSTRIAL COMPUTER SOURCE
-001014 CISCO SYSTEMS, INC.
-001015 OOmon Inc.
-001016 T.SQWARE
-001017 MICOS GmbH
-001018 BROADCOM CORPORATION
-001019 SIRONA DENTAL SYSTEMS GmbH & Co. KG
-00101A PictureTel Corp.
-00101B CORNET TECHNOLOGY, INC.
-00101C OHM TECHNOLOGIES INTL, LLC
-00101D WINBOND ELECTRONICS CORP.
-00101E MATSUSHITA ELECTRONIC INSTRUMENTS CORP.
-00101F CISCO SYSTEMS, INC.
-001020 WELCH ALLYN, DATA COLLECTION
-001021 ENCANTO NETWORKS, INC.
-001022 SatCom Media Corporation
-001023 FLOWWISE NETWORKS, INC.
-001024 NAGOYA ELECTRIC WORKS CO., LTD
-001025 GRAYHILL INC.
-001026 ACCELERATED NETWORKS, INC.
-001027 L-3 COMMUNICATIONS EAST
-001028 COMPUTER TECHNICA, INC.
-001029 CISCO SYSTEMS, INC.
-00102A ZF MICROSYSTEMS, INC.
-00102B UMAX DATA SYSTEMS, INC.
-00102C Lasat Networks A/S
-00102D HITACHI SOFTWARE ENGINEERING
-00102E NETWORK SYSTEMS & TECHNOLOGIES PVT. LTD.
-00102F CISCO SYSTEMS, INC.
-001030 Wi-LAN, Inc.
-001031 OBJECTIVE COMMUNICATIONS, INC.
-001032 ALTA TECHNOLOGY
-001033 ACCESSLAN COMMUNICATIONS, INC.
-001034 GNP Computers
-001035 ELITEGROUP COMPUTER SYSTEMS CO., LTD
-001036 INTER-TEL INTEGRATED SYSTEMS
-001037 CYQ've Technology Co., Ltd.
-001038 MICRO RESEARCH INSTITUTE, INC.
-001039 Vectron Systems AG
-00103A DIAMOND NETWORK TECH
-00103B HIPPI NETWORKING FORUM
-00103C IC ENSEMBLE, INC.
-00103D PHASECOM, LTD.
-00103E NETSCHOOLS CORPORATION
-00103F TOLLGRADE COMMUNICATIONS, INC.
-001040 INTERMEC CORPORATION
-001041 BRISTOL BABCOCK, INC.
-001042 AlacriTech
-001043 A2 CORPORATION
-001044 InnoLabs Corporation
-001045 Nortel Networks
-001046 ALCORN MCBRIDE INC.
-001047 ECHO ELETRIC CO. LTD.
-001048 HTRC AUTOMATION, INC.
-001049 SHORELINE TELEWORKS, INC.
-00104A THE PARVUC CORPORATION
-00104B 3COM CORPORATION
-00104C COMPUTER ACCESS TECHNOLOGY
-00104D SURTEC INDUSTRIES, INC.
-00104E CEOLOGIC
-00104F STORAGE TECHNOLOGY CORPORATION
-001050 RION CO., LTD.
-001051 CMICRO CORPORATION
-001052 METTLER-TOLEDO (ALBSTADT) GMBH
-001053 COMPUTER TECHNOLOGY CORP.
-001054 CISCO SYSTEMS, INC.
-001055 FUJITSU MICROELECTRONICS, INC.
-001056 SODICK CO., LTD.
-001057 Rebel.com, Inc.
-001058 ArrowPoint Communications
-001059 DIABLO RESEARCH CO. LLC
-00105A 3COM CORPORATION
-00105B NET INSIGHT AB
-00105C QUANTUM DESIGNS (H.K.) LTD.
-00105D Draeger Medical
-00105E HEKIMIAN LABORATORIES, INC.
-00105F IN-SNEC
-001060 BILLIONTON SYSTEMS, INC.
-001061 HOSTLINK CORP.
-001062 NX SERVER, ILNC.
-001063 STARGUIDE DIGITAL NETWORKS
-001064 DIGITAL EQUIPMENT CORP.
-001065 RADYNE CORPORATION
-001066 ADVANCED CONTROL SYSTEMS, INC.
-001067 REDBACK NETWORKS, INC.
-001068 COMOS TELECOM
-001069 HELIOSS COMMUNICATIONS, INC.
-00106A DIGITAL MICROWAVE CORPORATION
-00106B SONUS NETWORKS, INC.
-00106C INFRATEC PLUS GmbH
-00106D INTEGRITY COMMUNICATIONS, INC.
-00106E TADIRAN COM. LTD.
-00106F TRENTON TECHNOLOGY INC.
-001070 CARADON TREND LTD.
-001071 ADVANET INC.
-001072 GVN TECHNOLOGIES, INC.
-001073 TECHNOBOX, INC.
-001074 ATEN INTERNATIONAL CO., LTD.
-001075 Maxtor Corporation
-001076 EUREM GmbH
-001077 SAF DRIVE SYSTEMS, LTD.
-001078 NUERA COMMUNICATIONS, INC.
-001079 CISCO SYSTEMS, INC.
-00107A AmbiCom, Inc.
-00107B CISCO SYSTEMS, INC.
-00107C P-COM, INC.
-00107D AURORA COMMUNICATIONS, LTD.
-00107E BACHMANN ELECTRONIC GmbH
-00107F CRESTRON ELECTRONICS, INC.
-001080 METAWAVE COMMUNICATIONS
-001081 DPS, INC.
-001082 JNA TELECOMMUNICATIONS LIMITED
-001083 HEWLETT-PACKARD COMPANY
-001084 K-BOT COMMUNICATIONS
-001085 POLARIS COMMUNICATIONS, INC.
-001086 ATTO TECHNOLOGY, INC.
-001087 Xstreamis PLC
-001088 AMERICAN NETWORKS INC.
-001089 WebSonic
-00108A TeraLogic, Inc.
-00108B LASERANIMATION SOLLINGER GmbH
-00108C FUJITSU TELECOMMUNICATIONS EUROPE, LTD.
-00108D JOHNSON CONTROLS, INC.
-00108E HUGH SYMONS CONCEPT Technologies Ltd.
-00108F RAPTOR SYSTEMS
-001090 CIMETRICS, INC.
-001091 NO WIRES NEEDED BV
-001092 NETCORE INC.
-001093 CMS COMPUTERS, LTD.
-001094 Performance Analysis Broadband, Spirent plc
-001095 Thomson Multimedia, Inc.
-001096 TRACEWELL SYSTEMS, INC.
-001097 WinNet Metropolitan Communications Systems, Inc.
-001098 STARNET TECHNOLOGIES, INC.
-001099 InnoMedia, Inc.
-00109A NETLINE
-00109B VIXEL CORPORATION
-00109C M-SYSTEM CO., LTD.
-00109D CLARINET SYSTEMS, INC.
-00109E AWARE, INC.
-00109F PAVO, INC.
-0010A0 INNOVEX TECHNOLOGIES, INC.
-0010A1 KENDIN SEMICONDUCTOR, INC.
-0010A2 TNS
-0010A3 OMNITRONIX, INC.
-0010A4 XIRCOM
-0010A5 OXFORD INSTRUMENTS
-0010A6 CISCO SYSTEMS, INC.
-0010A7 UNEX TECHNOLOGY CORPORATION
-0010A8 RELIANCE COMPUTER CORP.
-0010A9 ADHOC TECHNOLOGIES
-0010AA MEDIA4, INC.
-0010AB KOITO INDUSTRIES, LTD.
-0010AC IMCI TECHNOLOGIES
-0010AD SOFTRONICS USB, INC.
-0010AE SHINKO ELECTRIC INDUSTRIES CO.
-0010AF TAC SYSTEMS, INC.
-0010B0 MERIDIAN TECHNOLOGY CORP.
-0010B1 FOR-A CO., LTD.
-0010B2 COACTIVE AESTHETICS
-0010B3 NOKIA MULTIMEDIA TERMINALS
-0010B4 ATMOSPHERE NETWORKS
-0010B5 ACCTON TECHNOLOGY CORPORATION
-0010B6 ENTRATA COMMUNICATIONS CORP.
-0010B7 COYOTE TECHNOLOGIES, LLC
-0010B8 ISHIGAKI COMPUTER SYSTEM CO.
-0010B9 MAXTOR CORP.
-0010BA MARTINHO-DAVIS SYSTEMS, INC.
-0010BB DATA & INFORMATION TECHNOLOGY
-0010BC Aastra Telecom
-0010BD THE TELECOMMUNICATION TECHNOLOGY COMMITTEE
-0010BE TELEXIS CORP.
-0010BF InterAir Wireless
-0010C0 ARMA, INC.
-0010C1 OI ELECTRIC CO., LTD.
-0010C2 WILLNET, INC.
-0010C3 CSI-CONTROL SYSTEMS
-0010C4 MEDIA LINKS CO., LTD.
-0010C5 PROTOCOL TECHNOLOGIES, INC.
-0010C6 USI
-0010C7 DATA TRANSMISSION NETWORK
-0010C8 COMMUNICATIONS ELECTRONICS SECURITY GROUP
-0010C9 MITSUBISHI ELECTRONICS LOGISTIC SUPPORT CO.
-0010CA INTEGRAL ACCESS
-0010CB FACIT K.K.
-0010CC CLP COMPUTER LOGISTIK PLANUNG GmbH
-0010CD INTERFACE CONCEPT
-0010CE VOLAMP, LTD.
-0010CF FIBERLANE COMMUNICATIONS
-0010D0 WITCOM, LTD.
-0010D1 Top Layer Networks, Inc.
-0010D2 NITTO TSUSHINKI CO., LTD
-0010D3 GRIPS ELECTRONIC GMBH
-0010D4 STORAGE COMPUTER CORPORATION
-0010D5 IMASDE CANARIAS, S.A.
-0010D6 ITT - A/CD
-0010D7 ARGOSY RESEARCH INC.
-0010D8 CALISTA
-0010D9 IBM JAPAN, FUJISAWA MT+D
-0010DA MOTION ENGINEERING, INC.
-0010DB NetScreen Technologies, Inc.
-0010DC MICRO-STAR INTERNATIONAL CO., LTD.
-0010DD ENABLE SEMICONDUCTOR, INC.
-0010DE INTERNATIONAL DATACASTING CORPORATION
-0010DF RISE COMPUTER INC.
-0010E0 COBALT MICROSERVER, INC.
-0010E1 S.I. TECH, INC.
-0010E2 ArrayComm, Inc.
-0010E3 COMPAQ COMPUTER CORPORATION
-0010E4 NSI CORPORATION
-0010E5 SOLECTRON TEXAS
-0010E6 APPLIED INTELLIGENT SYSTEMS, INC.
-0010E7 BreezeCom
-0010E8 TELOCITY, INCORPORATED
-0010E9 RAIDTEC LTD.
-0010EA ADEPT TECHNOLOGY
-0010EB SELSIUS SYSTEMS, INC.
-0010EC RPCG, LLC
-0010ED SUNDANCE TECHNOLOGY, INC.
-0010EE CTI PRODUCTS, INC.
-0010EF DBTEL INCORPORATED
-0010F1 I-O CORPORATION
-0010F2 ANTEC
-0010F3 Nexcom International Co., Ltd.
-0010F4 VERTICAL NETWORKS, INC.
-0010F5 AMHERST SYSTEMS, INC.
-0010F6 CISCO SYSTEMS, INC.
-0010F7 IRIICHI TECHNOLOGIES Inc.
-0010F8 KENWOOD TMI CORPORATION
-0010F9 UNIQUE SYSTEMS, INC.
-0010FA ZAYANTE, INC.
-0010FB ZIDA TECHNOLOGIES LIMITED
-0010FC BROADBAND NETWORKS, INC.
-0010FD COCOM A/S
-0010FE DIGITAL EQUIPMENT CORPORATION
-0010FF CISCO SYSTEMS, INC.
-001C7C PERQ SYSTEMS CORPORATION
-002000 LEXMARK INTERNATIONAL, INC.
-002001 DSP SOLUTIONS, INC.
-002002 SERITECH ENTERPRISE CO., LTD.
-002003 PIXEL POWER LTD.
-002004 YAMATAKE-HONEYWELL CO., LTD.
-002005 SIMPLE TECHNOLOGY
-002006 GARRETT COMMUNICATIONS, INC.
-002007 SFA, INC.
-002008 CABLE & COMPUTER TECHNOLOGY
-002009 PACKARD BELL ELEC., INC.
-00200A SOURCE-COMM CORP.
-00200B OCTAGON SYSTEMS CORP.
-00200C ADASTRA SYSTEMS CORP.
-00200D CARL ZEISS
-00200E SATELLITE TECHNOLOGY MGMT, INC
-00200F TANBAC CO., LTD.
-002010 JEOL SYSTEM TECHNOLOGY CO. LTD
-002011 CANOPUS CO., LTD.
-002012 CAMTRONICS MEDICAL SYSTEMS
-002013 DIVERSIFIED TECHNOLOGY, INC.
-002014 GLOBAL VIEW CO., LTD.
-002015 ACTIS COMPUTER SA
-002016 SHOWA ELECTRIC WIRE & CABLE CO
-002017 ORBOTECH
-002018 CIS TECHNOLOGY INC.
-002019 OHLER GmbH
-00201A N-BASE SWITCH COMMUNICATIONS
-00201B NORTHERN TELECOM/NETWORK
-00201C EXCEL, INC.
-00201D KATANA PRODUCTS
-00201E NETQUEST CORPORATION
-00201F BEST POWER TECHNOLOGY, INC.
-002020 MEGATRON COMPUTER INDUSTRIES PTY, LTD.
-002021 ALGORITHMS SOFTWARE PVT. LTD.
-002022 TEKNIQUE, INC.
-002023 T.C. TECHNOLOGIES PTY. LTD
-002024 PACIFIC COMMUNICATION SCIENCES
-002025 CONTROL TECHNOLOGY, INC.
-002026 AMKLY SYSTEMS, INC.
-002027 MING FORTUNE INDUSTRY CO., LTD
-002028 WEST EGG SYSTEMS, INC.
-002029 TELEPROCESSING PRODUCTS, INC.
-00202A N.V. DZINE
-00202B ADVANCED TELECOMMUNICATIONS MODULES, LTD.
-00202C WELLTRONIX CO., LTD.
-00202D TAIYO CORPORATION
-00202E DAYSTAR DIGITAL
-00202F ZETA COMMUNICATIONS, LTD.
-002030 ANALOG & DIGITAL SYSTEMS
-002031 ERTEC GmbH
-002032 ALCATEL TAISEL
-002033 SYNAPSE TECHNOLOGIES, INC.
-002034 ROTEC INDUSTRIEAUTOMATION GMBH
-002035 IBM CORPORATION
-002036 BMC SOFTWARE
-002037 SEAGATE TECHNOLOGY
-002038 VME MICROSYSTEMS INTERNATIONAL CORPORATION
-002039 SCINETS
-00203A DIGITAL BI0METRICS INC.
-00203B WISDM LTD.
-00203C EUROTIME AB
-00203D NOVAR ELECTRONICS CORPORATION
-00203E LogiCan Technologies, Inc.
-00203F JUKI CORPORATION
-002040 Motorola Broadband Communications Sector
-002041 DATA NET
-002042 DATAMETRICS CORP.
-002043 NEURON COMPANY LIMITED
-002044 GENITECH PTY LTD
-002045 ION Networks, Inc.
-002046 CIPRICO, INC.
-002047 STEINBRECHER CORP.
-002048 Marconi Communications
-002049 COMTRON, INC.
-00204A PRONET GMBH
-00204B AUTOCOMPUTER CO., LTD.
-00204C MITRON COMPUTER PTE LTD.
-00204D INOVIS GMBH
-00204E NETWORK SECURITY SYSTEMS, INC.
-00204F DEUTSCHE AEROSPACE AG
-002050 KOREA COMPUTER INC.
-002051 Verilink Corporation
-002052 RAGULA SYSTEMS
-002053 HUNTSVILLE MICROSYSTEMS, INC.
-002054 EASTERN RESEARCH, INC.
-002055 ALTECH CO., LTD.
-002056 NEOPRODUCTS
-002057 TITZE DATENTECHNIK GmbH
-002058 ALLIED SIGNAL INC.
-002059 MIRO COMPUTER PRODUCTS AG
-00205A COMPUTER IDENTICS
-00205B SKYLINE TECHNOLOGY
-00205C InterNet Systems of Florida, Inc.
-00205D NANOMATIC OY
-00205E CASTLE ROCK, INC.
-00205F GAMMADATA COMPUTER GMBH
-002060 ALCATEL ITALIA S.p.A.
-002061 DYNATECH COMMUNICATIONS, INC.
-002062 SCORPION LOGIC, LTD.
-002063 WIPRO INFOTECH LTD.
-002064 PROTEC MICROSYSTEMS, INC.
-002065 SUPERNET NETWORKING INC.
-002066 GENERAL MAGIC, INC.
-002068 ISDYNE
-002069 ISDN SYSTEMS CORPORATION
-00206A OSAKA COMPUTER CORP.
-00206B KONICA MINOLTA HOLDINGS, INC.
-00206C EVERGREEN TECHNOLOGY CORP.
-00206D DATA RACE, INC.
-00206E XACT, INC.
-00206F FLOWPOINT CORPORATION
-002070 HYNET, LTD.
-002071 IBR GMBH
-002072 WORKLINK INNOVATIONS
-002073 FUSION SYSTEMS CORPORATION
-002074 SUNGWOON SYSTEMS
-002075 MOTOROLA COMMUNICATION ISRAEL
-002076 REUDO CORPORATION
-002077 KARDIOS SYSTEMS CORP.
-002078 RUNTOP, INC.
-002079 MIKRON GMBH
-00207A WiSE Communications, Inc.
-00207B Intel Corporation
-00207C AUTEC GmbH
-00207D ADVANCED COMPUTER APPLICATIONS
-00207E FINECOM Co., Ltd.
-00207F KYOEI SANGYO CO., LTD.
-002080 SYNERGY (UK) LTD.
-002081 TITAN ELECTRONICS
-002082 ONEAC CORPORATION
-002083 PRESTICOM INCORPORATED
-002084 OCE PRINTING SYSTEMS, GMBH
-002085 EXIDE ELECTRONICS
-002086 MICROTECH ELECTRONICS LIMITED
-002087 MEMOTEC COMMUNICATIONS CORP.
-002088 GLOBAL VILLAGE COMMUNICATION
-002089 T3PLUS NETWORKING, INC.
-00208A SONIX COMMUNICATIONS, LTD.
-00208B LAPIS TECHNOLOGIES, INC.
-00208C GALAXY NETWORKS, INC.
-00208D CMD TECHNOLOGY
-00208E CHEVIN SOFTWARE ENG. LTD.
-00208F ECI TELECOM LTD.
-002090 ADVANCED COMPRESSION TECHNOLOGY, INC.
-002091 J125, NATIONAL SECURITY AGENCY
-002092 CHESS ENGINEERING B.V.
-002093 LANDINGS TECHNOLOGY CORP.
-002094 CUBIX CORPORATION
-002095 RIVA ELECTRONICS
-002096 Invensys
-002097 APPLIED SIGNAL TECHNOLOGY
-002098 HECTRONIC AB
-002099 BON ELECTRIC CO., LTD.
-00209A THE 3DO COMPANY
-00209B ERSAT ELECTRONIC GMBH
-00209C PRIMARY ACCESS CORP.
-00209D LIPPERT AUTOMATIONSTECHNIK
-00209E BROWN'S OPERATING SYSTEM SERVICES, LTD.
-00209F MERCURY COMPUTER SYSTEMS, INC.
-0020A0 OA LABORATORY CO., LTD.
-0020A1 DOVATRON
-0020A2 GALCOM NETWORKING LTD.
-0020A3 DIVICOM INC.
-0020A4 MULTIPOINT NETWORKS
-0020A5 API ENGINEERING
-0020A6 PROXIM, INC.
-0020A7 PAIRGAIN TECHNOLOGIES, INC.
-0020A8 SAST TECHNOLOGY CORP.
-0020A9 WHITE HORSE INDUSTRIAL
-0020AA DIGIMEDIA VISION LTD.
-0020AB MICRO INDUSTRIES CORP.
-0020AC INTERFLEX DATENSYSTEME GMBH
-0020AD LINQ SYSTEMS
-0020AE ORNET DATA COMMUNICATION TECH.
-0020AF 3COM CORPORATION
-0020B0 GATEWAY DEVICES, INC.
-0020B1 COMTECH RESEARCH INC.
-0020B2 GKD Gesellschaft Fur Kommunikation Und Datentechnik
-0020B3 SCLTEC COMMUNICATIONS SYSTEMS
-0020B4 TERMA ELEKTRONIK AS
-0020B5 YASKAWA ELECTRIC CORPORATION
-0020B6 AGILE NETWORKS, INC.
-0020B7 NAMAQUA COMPUTERWARE
-0020B8 PRIME OPTION, INC.
-0020B9 METRICOM, INC.
-0020BA CENTER FOR HIGH PERFORMANCE
-0020BB ZAX CORPORATION
-0020BC JTEC PTY LTD.
-0020BD NIOBRARA R & D CORPORATION
-0020BE LAN ACCESS CORP.
-0020BF AEHR TEST SYSTEMS
-0020C0 PULSE ELECTRONICS, INC.
-0020C1 TAIKO ELECTRIC WORKS, LTD.
-0020C2 TEXAS MEMORY SYSTEMS, INC.
-0020C3 COUNTER SOLUTIONS LTD.
-0020C4 INET,INC.
-0020C5 EAGLE TECHNOLOGY
-0020C6 NECTEC
-0020C7 AKAI Professional M.I. Corp.
-0020C8 LARSCOM INCORPORATED
-0020C9 VICTRON BV
-0020CA DIGITAL OCEAN
-0020CB PRETEC ELECTRONICS CORP.
-0020CC DIGITAL SERVICES, LTD.
-0020CD HYBRID NETWORKS, INC.
-0020CE LOGICAL DESIGN GROUP, INC.
-0020CF TEST & MEASUREMENT SYSTEMS INC
-0020D0 VERSALYNX CORPORATION
-0020D1 MICROCOMPUTER SYSTEMS (M) SDN.
-0020D2 RAD DATA COMMUNICATIONS, LTD.
-0020D3 OST (OUEST STANDARD TELEMATIQU
-0020D4 CABLETRON - ZEITTNET INC.
-0020D5 VIPA GMBH
-0020D6 BREEZECOM
-0020D7 JAPAN MINICOMPUTER SYSTEMS CO., Ltd.
-0020D8 Nortel Networks
-0020D9 PANASONIC TECHNOLOGIES, INC./MIECO-US
-0020DA XYLAN CORPORATION
-0020DB XNET TECHNOLOGY, INC.
-0020DC DENSITRON TAIWAN LTD.
-0020DD Cybertec Pty Ltd
-0020DE JAPAN DIGITAL LABORAT'Y CO.LTD
-0020DF KYOSAN ELECTRIC MFG. CO., LTD.
-0020E0 PREMAX ELECTRONICS, INC.
-0020E1 ALAMAR ELECTRONICS
-0020E2 INFORMATION RESOURCE ENGINEERING
-0020E3 MCD KENCOM CORPORATION
-0020E4 HSING TECH ENTERPRISE CO., LTD
-0020E5 APEX DATA, INC.
-0020E6 LIDKOPING MACHINE TOOLS AB
-0020E7 B&W NUCLEAR SERVICE COMPANY
-0020E8 DATATREK CORPORATION
-0020E9 DANTEL
-0020EA EFFICIENT NETWORKS, INC.
-0020EB CINCINNATI MICROWAVE, INC.
-0020EC TECHWARE SYSTEMS CORP.
-0020ED GIGA-BYTE TECHNOLOGY CO., LTD.
-0020EE GTECH CORPORATION
-0020EF USC CORPORATION
-0020F0 UNIVERSAL MICROELECTRONICS CO.
-0020F1 ALTOS INDIA LIMITED
-0020F2 SUN MICROSYSTEMS, INC.
-0020F3 RAYNET CORPORATION
-0020F4 SPECTRIX CORPORATION
-0020F5 PANDATEL AG
-0020F6 NET TEK  AND KARLNET, INC.
-0020F7 CYBERDATA
-0020F8 CARRERA COMPUTERS, INC.
-0020F9 PARALINK NETWORKS, INC.
-0020FA GDE SYSTEMS, INC.
-0020FB OCTEL COMMUNICATIONS CORP.
-0020FC MATROX
-0020FD ITV TECHNOLOGIES, INC.
-0020FE TOPWARE INC. / GRAND COMPUTER
-0020FF SYMMETRICAL TECHNOLOGIES
-003000 ALLWELL TECHNOLOGY CORP.
-003001 SMP
-003002 Expand Networks
-003003 Phasys Ltd.
-003004 LEADTEK RESEARCH INC.
-003005 Fujitsu Siemens Computers
-003006 SUPERPOWER COMPUTER
-003007 OPTI, INC.
-003008 AVIO DIGITAL, INC.
-003009 Tachion Networks, Inc.
-00300A AZTECH SYSTEMS LTD.
-00300B mPHASE Technologies, Inc.
-00300C CONGRUENCY, LTD.
-00300D MMC Technology, Inc.
-00300E Klotz Digital AG
-00300F IMT - Information Management T
-003010 VISIONETICS INTERNATIONAL
-003011 HMS FIELDBUS SYSTEMS AB
-003012 DIGITAL ENGINEERING LTD.
-003013 NEC Corporation
-003014 DIVIO, INC.
-003015 CP CLARE CORP.
-003016 ISHIDA CO., LTD.
-003017 TERASTACK LTD.
-003018 Jetway Information Co., Ltd.
-003019 CISCO SYSTEMS, INC.
-00301A SMARTBRIDGES PTE. LTD.
-00301B SHUTTLE, INC.
-00301C ALTVATER AIRDATA SYSTEMS
-00301D SKYSTREAM, INC.
-00301E 3COM Europe Ltd.
-00301F OPTICAL NETWORKS, INC.
-003020 TSI, Inc..
-003021 HSING TECH. ENTERPRISE CO.,LTD
-003022 Fong Kai Industrial Co., Ltd.
-003023 COGENT COMPUTER SYSTEMS, INC.
-003024 CISCO SYSTEMS, INC.
-003025 CHECKOUT COMPUTER SYSTEMS, LTD
-003026 HEITEL
-003027 KERBANGO, INC.
-003028 FASE Saldatura srl
-003029 OPICOM
-00302A SOUTHERN INFORMATION
-00302B INALP NETWORKS, INC.
-00302C SYLANTRO SYSTEMS CORPORATION
-00302D QUANTUM BRIDGE COMMUNICATIONS
-00302E Hoft & Wessel AG
-00302F Smiths Industries
-003030 HARMONIX CORPORATION
-003031 LIGHTWAVE COMMUNICATIONS, INC.
-003032 MagicRam, Inc.
-003033 ORIENT TELECOM CO., LTD.
-003036 RMP ELEKTRONIKSYSTEME GMBH
-003037 Packard Bell Nec Services
-003038 XCP, INC.
-003039 SOFTBOOK PRESS
-00303A MAATEL
-00303B PowerCom Technology
-00303C ONNTO CORP.
-00303D IVA CORPORATION
-00303E Radcom Ltd.
-00303F TurboComm Tech Inc.
-003040 CISCO SYSTEMS, INC.
-003041 SAEJIN T & M CO., LTD.
-003042 DeTeWe-Deutsche Telephonwerke
-003043 IDREAM TECHNOLOGIES, PTE. LTD.
-003044 Portsmith LLC
-003045 Village Networks, Inc. (VNI)
-003046 Controlled Electronic Manageme
-003047 NISSEI ELECTRIC CO., LTD.
-003048 Supermicro Computer, Inc.
-003049 BRYANT TECHNOLOGY, LTD.
-00304A FRAUNHOFER INSTITUTE IMS
-00304B ORBACOM SYSTEMS, INC.
-00304C APPIAN COMMUNICATIONS, INC.
-00304D ESI
-00304E BUSTEC PRODUCTION LTD.
-00304F PLANET Technology Corporation
-003050 Versa Technology
-003051 ORBIT AVIONIC & COMMUNICATION
-003052 ELASTIC NETWORKS
-003053 Basler AG
-003054 CASTLENET TECHNOLOGY, INC.
-003055 Hitachi Semiconductor America,
-003056 Beck IPC GmbH
-003057 E-Tel Corporation
-003058 API MOTION
-003059 DIGITAL-LOGIC AG
-00305A TELGEN CORPORATION
-00305B MODULE DEPARTMENT
-00305C SMAR Laboratories Corp.
-00305D DIGITRA SYSTEMS, INC.
-00305E Abelko Innovation
-00305F IMACON APS
-003060 STARMATIX, INC.
-003061 MobyTEL
-003062 PATH 1 NETWORK TECHNOL'S INC.
-003063 SANTERA SYSTEMS, INC.
-003064 ADLINK TECHNOLOGY, INC.
-003065 APPLE COMPUTER, INC.
-003066 DIGITAL WIRELESS CORPORATION
-003067 BIOSTAR MICROTECH INT'L CORP.
-003068 CYBERNETICS TECH. CO., LTD.
-003069 IMPACCT TECHNOLOGY CORP.
-00306A PENTA MEDIA CO., LTD.
-00306B CMOS SYSTEMS, INC.
-00306C Hitex Holding GmbH
-00306D LUCENT TECHNOLOGIES
-00306E HEWLETT PACKARD
-00306F SEYEON TECH. CO., LTD.
-003070 1Net Corporation
-003071 Cisco Systems, Inc.
-003072 INTELLIBYTE INC.
-003073 International Microsystems, In
-003074 EQUIINET LTD.
-003075 ADTECH
-003076 Akamba Corporation
-003077 ONPREM NETWORKS
-003078 Cisco Systems, Inc.
-003079 CQOS, INC.
-00307A Advanced Technology & Systems
-00307B Cisco Systems, Inc.
-00307C ADID SA
-00307D GRE AMERICA, INC.
-00307E Redflex Communication Systems
-00307F IRLAN LTD.
-003080 CISCO SYSTEMS, INC.
-003081 ALTOS C&C
-003082 TAIHAN ELECTRIC WIRE CO., LTD.
-003083 Ivron Systems
-003084 ALLIED TELESYN INTERNAIONAL
-003085 CISCO SYSTEMS, INC.
-003086 Transistor Devices, Inc.
-003087 VEGA GRIESHABER KG
-003088 Siara Systems, Inc.
-003089 Spectrapoint Wireless, LLC
-00308A NICOTRA SISTEMI S.P.A
-00308B Brix Networks
-00308C ADVANCED DIGITAL INFORMATION
-00308D PINNACLE SYSTEMS, INC.
-00308E CROSS MATCH TECHNOLOGIES, INC.
-00308F MICRILOR, Inc.
-003090 CYRA TECHNOLOGIES, INC.
-003091 TAIWAN FIRST LINE ELEC. CORP.
-003092 ModuNORM GmbH
-003093 SONNET TECHNOLOGIES, INC.
-003094 Cisco Systems, Inc.
-003095 Procomp Informatics, Ltd.
-003096 CISCO SYSTEMS, INC.
-003097 EXOMATIC AB
-003098 Global Converging Technologies
-003099 BOENIG UND KALLENBACH OHG
-00309A ASTRO TERRA CORP.
-00309B Smartware
-00309C Timing Applications, Inc.
-00309D Nimble Microsystems, Inc.
-00309E WORKBIT CORPORATION.
-00309F AMBER NETWORKS
-0030A0 TYCO SUBMARINE SYSTEMS, LTD.
-0030A1 WEBGATE Inc.
-0030A2 Lightner Engineering
-0030A3 CISCO SYSTEMS, INC.
-0030A4 Woodwind Communications System
-0030A5 ACTIVE POWER
-0030A6 VIANET TECHNOLOGIES, LTD.
-0030A7 SCHWEITZER ENGINEERING
-0030A8 OL'E COMMUNICATIONS, INC.
-0030A9 Netiverse, Inc.
-0030AA AXUS MICROSYSTEMS, INC.
-0030AB DELTA NETWORKS, INC.
-0030AC Systeme Lauer GmbH & Co., Ltd.
-0030AD SHANGHAI COMMUNICATION
-0030AE Times N System, Inc.
-0030AF Honeywell GmbH
-0030B0 Convergenet Technologies
-0030B1 GOC GESELLSCHAFT FUR OPTISCHE
-0030B2 WESCAM - HEALDSBURG
-0030B3 San Valley Systems, Inc.
-0030B4 INTERSIL CORP.
-0030B5 Tadiran Microwave Networks
-0030B6 CISCO SYSTEMS, INC.
-0030B7 Teletrol Systems, Inc.
-0030B8 RiverDelta Networks
-0030B9 ECTEL
-0030BA AC&T SYSTEM CO., LTD.
-0030BB CacheFlow, Inc.
-0030BC Optronic AG
-0030BD BELKIN COMPONENTS
-0030BE City-Net Technology, Inc.
-0030BF MULTIDATA GMBH
-0030C0 Lara Technology, Inc.
-0030C1 HEWLETT-PACKARD
-0030C2 COMONE
-0030C3 FLUECKIGER ELEKTRONIK AG
-0030C4 Niigata Canotec Co., Inc.
-0030C5 CADENCE DESIGN SYSTEMS
-0030C6 CONTROL SOLUTIONS, INC.
-0030C7 MACROMATE CORP.
-0030C8 GAD LINE, LTD.
-0030C9 LuxN, N
-0030CA Discovery Com
-0030CB OMNI FLOW COMPUTERS, INC.
-0030CC Tenor Networks, Inc.
-0030CD CONEXANT SYSTEMS, INC.
-0030CE Zaffire
-0030CF TWO TECHNOLOGIES, INC.
-0030D1 INOVA CORPORATION
-0030D2 WIN TECHNOLOGIES, CO., LTD.
-0030D3 Agilent Technologies
-0030D4 COMTIER
-0030D5 DResearch GmbH
-0030D6 MSC VERTRIEBS GMBH
-0030D7 Innovative Systems, L.L.C.
-0030D8 SITEK
-0030D9 DATACORE SOFTWARE CORP.
-0030DA COMTREND CO.
-0030DB Mindready Solutions, Inc.
-0030DC RIGHTECH CORPORATION
-0030DD INDIGITA CORPORATION
-0030DE WAGO Kontakttechnik GmbH
-0030DF KB/TEL TELECOMUNICACIONES
-0030E0 OXFORD SEMICONDUCTOR LTD.
-0030E1 ACROTRON SYSTEMS, INC.
-0030E2 GARNET SYSTEMS CO., LTD.
-0030E3 SEDONA NETWORKS CORP.
-0030E4 CHIYODA SYSTEM RIKEN
-0030E5 Amper Datos S.A.
-0030E6 SIEMENS MEDICAL SYSTEMS
-0030E7 CNF MOBILE SOLUTIONS, INC.
-0030E8 ENSIM CORP.
-0030E9 GMA COMMUNICATION MANUFACT'G
-0030EA TeraForce Technology Corporation
-0030EB TURBONET COMMUNICATIONS, INC.
-0030EC BORGARDT
-0030ED Expert Magnetics Corp.
-0030EE DSG Technology, Inc.
-0030EF NEON TECHNOLOGY, INC.
-0030F0 Uniform Industrial Corp.
-0030F1 Accton Technology Corp.
-0030F2 CISCO SYSTEMS, INC.
-0030F3 At Work Computers
-0030F4 STARDOT TECHNOLOGIES
-0030F5 Wild Lab. Ltd.
-0030F6 SECURELOGIX CORPORATION
-0030F7 RAMIX INC.
-0030F8 Dynapro Systems, Inc.
-0030F9 Sollae Systems Co., Ltd.
-0030FA TELICA, INC.
-0030FB AZS Technology AG
-0030FC Terawave Communications, Inc.
-0030FD INTEGRATED SYSTEMS DESIGN
-0030FE DSA GmbH
-0030FF DATAFAB SYSTEMS, INC.
-004000 PCI COMPONENTES DA AMZONIA LTD
-004001 ZYXEL COMMUNICATIONS, INC.
-004002 PERLE SYSTEMS LIMITED
-004003 WESTINGHOUSE PROCESS CONTROL
-004004 ICM CO. LTD.
-004005 ANI COMMUNICATIONS INC.
-004006 SAMPO TECHNOLOGY CORPORATION
-004007 TELMAT INFORMATIQUE
-004008 A PLUS INFO CORPORATION
-004009 TACHIBANA TECTRON CO., LTD.
-00400A PIVOTAL TECHNOLOGIES, INC.
-00400B CISCO SYSTEMS, INC.
-00400C GENERAL MICRO SYSTEMS, INC.
-00400D LANNET DATA COMMUNICATIONS,LTD
-00400E MEMOTEC COMMUNICATIONS, INC.
-00400F DATACOM TECHNOLOGIES
-004010 SONIC SYSTEMS, INC.
-004011 ANDOVER CONTROLS CORPORATION
-004012 WINDATA, INC.
-004013 NTT DATA COMM. SYSTEMS CORP.
-004014 COMSOFT GMBH
-004015 ASCOM INFRASYS AG
-004016 HADAX ELECTRONICS, INC.
-004017 XCD INC.
-004018 ADOBE SYSTEMS, INC.
-004019 AEON SYSTEMS, INC.
-00401A FUJI ELECTRIC CO., LTD.
-00401B PRINTER SYSTEMS CORP.
-00401C AST RESEARCH, INC.
-00401D INVISIBLE SOFTWARE, INC.
-00401E ICC
-00401F COLORGRAPH LTD
-004020 PINACL COMMUNICATION
-004021 RASTER GRAPHICS
-004022 KLEVER COMPUTERS, INC.
-004023 LOGIC CORPORATION
-004024 COMPAC INC.
-004025 MOLECULAR DYNAMICS
-004026 MELCO, INC.
-004027 SMC MASSACHUSETTS, INC.
-004028 NETCOMM LIMITED
-004029 COMPEX
-00402A CANOGA-PERKINS
-00402B TRIGEM COMPUTER, INC.
-00402C ISIS DISTRIBUTED SYSTEMS, INC.
-00402D HARRIS ADACOM CORPORATION
-00402E PRECISION SOFTWARE, INC.
-00402F XLNT DESIGNS INC.
-004030 GK COMPUTER
-004031 KOKUSAI ELECTRIC CO., LTD
-004032 DIGITAL COMMUNICATIONS
-004033 ADDTRON TECHNOLOGY CO., LTD.
-004034 BUSTEK CORPORATION
-004035 OPCOM
-004036 TRIBE COMPUTER WORKS, INC.
-004037 SEA-ILAN, INC.
-004038 TALENT ELECTRIC INCORPORATED
-004039 OPTEC DAIICHI DENKO CO., LTD.
-00403A IMPACT TECHNOLOGIES
-00403B SYNERJET INTERNATIONAL CORP.
-00403C FORKS, INC.
-00403D TERADATA
-00403E RASTER OPS CORPORATION
-00403F SSANGYONG COMPUTER SYSTEMS
-004040 RING ACCESS, INC.
-004041 FUJIKURA LTD.
-004042 N.A.T. GMBH
-004043 NOKIA TELECOMMUNICATIONS
-004044 QNIX COMPUTER CO., LTD.
-004045 TWINHEAD CORPORATION
-004046 UDC RESEARCH LIMITED
-004047 WIND RIVER SYSTEMS
-004048 SMD INFORMATICA S.A.
-004049 TEGIMENTA AG
-00404A WEST AUSTRALIAN DEPARTMENT
-00404B MAPLE COMPUTER SYSTEMS
-00404C HYPERTEC PTY LTD.
-00404D TELECOMMUNICATIONS TECHNIQUES
-00404E FLUENT, INC.
-00404F SPACE & NAVAL WARFARE SYSTEMS
-004050 IRONICS, INCORPORATED
-004051 GRACILIS, INC.
-004052 STAR TECHNOLOGIES, INC.
-004053 AMPRO COMPUTERS
-004054 CONNECTION MACHINES SERVICES
-004055 METRONIX GMBH
-004056 MCM JAPAN LTD.
-004057 LOCKHEED - SANDERS
-004058 KRONOS, INC.
-004059 YOSHIDA KOGYO K. K.
-00405A GOLDSTAR INFORMATION & COMM.
-00405B FUNASSET LIMITED
-00405C FUTURE SYSTEMS, INC.
-00405D STAR-TEK, INC.
-00405E NORTH HILLS ISRAEL
-00405F AFE COMPUTERS LTD.
-004060 COMENDEC LTD
-004061 DATATECH ENTERPRISES CO., LTD.
-004062 E-SYSTEMS, INC./GARLAND DIV.
-004063 VIA TECHNOLOGIES, INC.
-004064 KLA INSTRUMENTS CORPORATION
-004065 GTE SPACENET
-004066 HITACHI CABLE, LTD.
-004067 OMNIBYTE CORPORATION
-004068 EXTENDED SYSTEMS
-004069 LEMCOM SYSTEMS, INC.
-00406A KENTEK INFORMATION SYSTEMS,INC
-00406B SYSGEN
-00406C COPERNIQUE
-00406D LANCO, INC.
-00406E COROLLARY, INC.
-00406F SYNC RESEARCH INC.
-004070 INTERWARE CO., LTD.
-004071 ATM COMPUTER GMBH
-004072 Applied Innovation Inc.
-004073 BASS ASSOCIATES
-004074 CABLE AND WIRELESS
-004075 M-TRADE (UK) LTD
-004076 Sun Conversion Technologies
-004077 MAXTON TECHNOLOGY CORPORATION
-004078 WEARNES AUTOMATION PTE LTD
-004079 JUKO MANUFACTURE COMPANY, LTD.
-00407A SOCIETE D'EXPLOITATION DU CNIT
-00407B SCIENTIFIC ATLANTA
-00407C QUME CORPORATION
-00407D EXTENSION TECHNOLOGY CORP.
-00407E EVERGREEN SYSTEMS, INC.
-00407F FLIR Systems
-004080 ATHENIX CORPORATION
-004081 MANNESMANN SCANGRAPHIC GMBH
-004082 LABORATORY EQUIPMENT CORP.
-004083 TDA INDUSTRIA DE PRODUTOS
-004084 HONEYWELL INC.
-004085 SAAB INSTRUMENTS AB
-004086 MICHELS & KLEBERHOFF COMPUTER
-004087 UBITREX CORPORATION
-004088 MOBIUS TECHNOLOGIES, INC.
-004089 MEIDENSHA CORPORATION
-00408A TPS TELEPROCESSING SYS. GMBH
-00408B RAYLAN CORPORATION
-00408C AXIS COMMUNICATIONS AB
-00408D THE GOODYEAR TIRE & RUBBER CO.
-00408E DIGILOG, INC.
-00408F WM-DATA MINFO AB
-004090 ANSEL COMMUNICATIONS
-004091 PROCOMP INDUSTRIA ELETRONICA
-004092 ASP COMPUTER PRODUCTS, INC.
-004093 PAXDATA NETWORKS LTD.
-004094 SHOGRAPHICS, INC.
-004095 R.P.T. INTERGROUPS INT'L LTD.
-004096 Aironet Wireless Communication
-004097 DATEX DIVISION OF
-004098 DRESSLER GMBH & CO.
-004099 NEWGEN SYSTEMS CORP.
-00409A NETWORK EXPRESS, INC.
-00409B HAL COMPUTER SYSTEMS INC.
-00409C TRANSWARE
-00409D DIGIBOARD, INC.
-00409E CONCURRENT TECHNOLOGIES  LTD.
-00409F LANCAST/CASAT TECHNOLOGY, INC.
-0040A0 GOLDSTAR CO., LTD.
-0040A1 ERGO COMPUTING
-0040A2 KINGSTAR TECHNOLOGY INC.
-0040A3 MICROUNITY SYSTEMS ENGINEERING
-0040A4 ROSE ELECTRONICS
-0040A5 CLINICOMP INTL.
-0040A6 Cray, Inc.
-0040A7 ITAUTEC PHILCO S.A.
-0040A8 IMF INTERNATIONAL LTD.
-0040A9 DATACOM INC.
-0040AA VALMET AUTOMATION INC.
-0040AB ROLAND DG CORPORATION
-0040AC SUPER WORKSTATION, INC.
-0040AD SMA REGELSYSTEME GMBH
-0040AE DELTA CONTROLS, INC.
-0040AF DIGITAL PRODUCTS, INC.
-0040B0 BYTEX CORPORATION, ENGINEERING
-0040B1 CODONICS INC.
-0040B2 SYSTEMFORSCHUNG
-0040B3 PAR MICROSYSTEMS CORPORATION
-0040B4 NEXTCOM K.K.
-0040B5 VIDEO TECHNOLOGY COMPUTERS LTD
-0040B6 COMPUTERM  CORPORATION
-0040B7 STEALTH COMPUTER SYSTEMS
-0040B8 IDEA ASSOCIATES
-0040B9 MACQ ELECTRONIQUE SA
-0040BA ALLIANT COMPUTER SYSTEMS CORP.
-0040BB GOLDSTAR CABLE CO., LTD.
-0040BC ALGORITHMICS LTD.
-0040BD STARLIGHT NETWORKS, INC.
-0040BE BOEING DEFENSE & SPACE
-0040BF CHANNEL SYSTEMS INTERN'L INC.
-0040C0 VISTA CONTROLS CORPORATION
-0040C1 BIZERBA-WERKE WILHEIM KRAUT
-0040C2 APPLIED COMPUTING DEVICES
-0040C3 FISCHER AND PORTER CO.
-0040C4 KINKEI SYSTEM CORPORATION
-0040C5 MICOM COMMUNICATIONS INC.
-0040C6 FIBERNET RESEARCH, INC.
-0040C7 RUBY TECH CORPORATION
-0040C8 MILAN TECHNOLOGY CORPORATION
-0040C9 NCUBE
-0040CA FIRST INTERNAT'L COMPUTER, INC
-0040CB LANWAN TECHNOLOGIES
-0040CC SILCOM MANUF'G TECHNOLOGY INC.
-0040CD TERA MICROSYSTEMS, INC.
-0040CE NET-SOURCE, INC.
-0040CF STRAWBERRY TREE, INC.
-0040D0 MITAC INTERNATIONAL CORP.
-0040D1 FUKUDA DENSHI CO., LTD.
-0040D2 PAGINE CORPORATION
-0040D3 KIMPSION INTERNATIONAL CORP.
-0040D4 GAGE TALKER CORP.
-0040D5 SARTORIUS AG
-0040D6 LOCAMATION B.V.
-0040D7 STUDIO GEN INC.
-0040D8 OCEAN OFFICE AUTOMATION LTD.
-0040D9 AMERICAN MEGATRENDS INC.
-0040DA TELSPEC LTD
-0040DB ADVANCED TECHNICAL SOLUTIONS
-0040DC TRITEC ELECTRONIC GMBH
-0040DD HONG TECHNOLOGIES
-0040DE ELETTRONICA SAN GIORGIO
-0040DF DIGALOG SYSTEMS, INC.
-0040E0 ATOMWIDE LTD.
-0040E1 MARNER INTERNATIONAL, INC.
-0040E2 MESA RIDGE TECHNOLOGIES, INC.
-0040E3 QUIN SYSTEMS LTD
-0040E4 E-M TECHNOLOGY, INC.
-0040E5 SYBUS CORPORATION
-0040E6 C.A.E.N.
-0040E7 ARNOS INSTRUMENTS & COMPUTER
-0040E8 CHARLES RIVER DATA SYSTEMS,INC
-0040E9 ACCORD SYSTEMS, INC.
-0040EA PLAIN TREE SYSTEMS INC
-0040EB MARTIN MARIETTA CORPORATION
-0040EC MIKASA SYSTEM ENGINEERING
-0040ED NETWORK CONTROLS INT'NATL INC.
-0040EE OPTIMEM
-0040EF HYPERCOM, INC.
-0040F0 MICRO SYSTEMS, INC.
-0040F1 CHUO ELECTRONICS CO., LTD.
-0040F2 JANICH & KLASS COMPUTERTECHNIK
-0040F3 NETCOR
-0040F4 CAMEO COMMUNICATIONS, INC.
-0040F5 OEM ENGINES
-0040F6 KATRON COMPUTERS INC.
-0040F7 POLAROID MEDICAL IMAGING SYS.
-0040F8 SYSTEMHAUS DISCOM
-0040F9 COMBINET
-0040FA MICROBOARDS, INC.
-0040FB CASCADE COMMUNICATIONS CORP.
-0040FC IBR COMPUTER TECHNIK GMBH
-0040FD LXE
-0040FE SYMPLEX COMMUNICATIONS
-0040FF TELEBIT CORPORATION
-004252 RLX Technologies
-005000 NEXO COMMUNICATIONS, INC.
-005001 YAMASHITA SYSTEMS CORP.
-005002 OMNISEC AG
-005003 GRETAG MACBETH AG
-005004 3COM CORPORATION
-005006 TAC AB
-005007 SIEMENS TELECOMMUNICATION SYSTEMS LIMITED
-005008 TIVA MICROCOMPUTER CORP. (TMC)
-005009 PHILIPS BROADBAND NETWORKS
-00500A IRIS TECHNOLOGIES, INC.
-00500B CISCO SYSTEMS, INC.
-00500C e-Tek Labs, Inc.
-00500D SATORI ELECTORIC CO., LTD.
-00500E CHROMATIS NETWORKS, INC.
-00500F CISCO SYSTEMS, INC.
-005010 NovaNET Learning, Inc.
-005012 CBL - GMBH
-005013 Chaparral Network Storage
-005014 CISCO SYSTEMS, INC.
-005015 BRIGHT STAR ENGINEERING
-005016 SST/WOODHEAD INDUSTRIES
-005017 RSR S.R.L.
-005018 ADVANCED MULTIMEDIA INTERNET TECHNOLOGY INC.
-005019 SPRING TIDE NETWORKS, INC.
-00501A UISIQN
-00501B ABL CANADA, INC.
-00501C JATOM SYSTEMS, INC.
-00501E Miranda Technologies, Inc.
-00501F MRG SYSTEMS, LTD.
-005020 MEDIASTAR CO., LTD.
-005021 EIS INTERNATIONAL, INC.
-005022 ZONET TECHNOLOGY, INC.
-005023 PG DESIGN ELECTRONICS, INC.
-005024 NAVIC SYSTEMS, INC.
-005026 COSYSTEMS, INC.
-005027 GENICOM CORPORATION
-005028 AVAL COMMUNICATIONS
-005029 1394 PRINTER WORKING GROUP
-00502A CISCO SYSTEMS, INC.
-00502B GENRAD LTD.
-00502C SOYO COMPUTER, INC.
-00502D ACCEL, INC.
-00502E CAMBEX CORPORATION
-00502F TollBridge Technologies, Inc.
-005030 FUTURE PLUS SYSTEMS
-005031 AEROFLEX LABORATORIES, INC.
-005032 PICAZO COMMUNICATIONS, INC.
-005033 MAYAN NETWORKS
-005036 NETCAM, LTD.
-005037 KOGA ELECTRONICS CO.
-005038 DAIN TELECOM CO., LTD.
-005039 MARINER NETWORKS
-00503A DATONG ELECTRONICS LTD.
-00503B MEDIAFIRE CORPORATION
-00503C TSINGHUA NOVEL ELECTRONICS
-00503E CISCO SYSTEMS, INC.
-00503F ANCHOR GAMES
-005040 EMWARE, INC.
-005041 CTX OPTO ELECTRONIC CORP.
-005042 SCI MANUFACTURING SINGAPORE PTE, LTD.
-005043 MARVELL SEMICONDUCTOR, INC.
-005044 ASACA CORPORATION
-005045 RIOWORKS SOLUTIONS, INC.
-005046 MENICX INTERNATIONAL CO., LTD.
-005048 INFOLIBRIA
-005049 ELLACOYA NETWORKS, INC.
-00504A ELTECO A.S.
-00504B BARCONET N.V.
-00504C GALIL MOTION CONTROL, INC.
-00504D TOKYO ELECTRON DEVICE LTD.
-00504E SIERRA MONITOR CORP.
-00504F OLENCOM ELECTRONICS
-005050 CISCO SYSTEMS, INC.
-005051 IWATSU ELECTRIC CO., LTD.
-005052 TIARA NETWORKS, INC.
-005053 CISCO SYSTEMS, INC.
-005054 CISCO SYSTEMS, INC.
-005055 DOMS A/S
-005056 VMWare, Inc.
-005057 BROADBAND ACCESS SYSTEMS
-005058 VEGASTREAM LIMITED
-005059 SUITE TECHNOLOGY SYSTEMS NETWORK
-00505A NETWORK ALCHEMY, INC.
-00505B KAWASAKI LSI U.S.A., INC.
-00505C TUNDO CORPORATION
-00505E DIGITEK MICROLOGIC S.A.
-00505F BRAND INNOVATORS
-005060 TANDBERG TELECOM AS
-005062 KOUWELL ELECTRONICS CORP.  **
-005063 OY COMSEL SYSTEM AB
-005064 CAE ELECTRONICS
-005065 DENSEI-LAMBAD Co., Ltd.
-005066 AtecoM GmbH advanced telecomunication modules
-005067 AEROCOMM, INC.
-005068 ELECTRONIC INDUSTRIES ASSOCIATION
-005069 PixStream Incorporated
-00506A EDEVA, INC.
-00506B SPX-ATEG
-00506C G & L BEIJER ELECTRONICS AB
-00506D VIDEOJET SYSTEMS
-00506E CORDER ENGINEERING CORPORATION
-00506F G-CONNECT
-005070 CHAINTECH COMPUTER CO., LTD.
-005071 AIWA CO., LTD.
-005072 CORVIS CORPORATION
-005073 CISCO SYSTEMS, INC.
-005074 ADVANCED HI-TECH CORP.
-005075 KESTREL SOLUTIONS
-005076 IBM
-005077 PROLIFIC TECHNOLOGY, INC.
-005078 MEGATON HOUSE, LTD.
-00507A XPEED, INC.
-00507B MERLOT COMMUNICATIONS
-00507C VIDEOCON AG
-00507D IFP
-00507E NEWER TECHNOLOGY
-00507F DrayTek Corp.
-005080 CISCO SYSTEMS, INC.
-005081 MURATA MACHINERY, LTD.
-005082 FORESSON CORPORATION
-005083 GILBARCO, INC.
-005084 ATL PRODUCTS
-005086 TELKOM SA, LTD.
-005087 TERASAKI ELECTRIC CO., LTD.
-005088 AMANO CORPORATION
-005089 SAFETY MANAGEMENT SYSTEMS
-00508B COMPAQ COMPUTER CORPORATION
-00508C RSI SYSTEMS
-00508D ABIT COMPUTER CORPORATION
-00508E OPTIMATION, INC.
-00508F ASITA TECHNOLOGIES INT'L LTD.
-005090 DCTRI
-005091 NETACCESS, INC.
-005092 RIGAKU INDUSTRIAL CORPORATION
-005093 BOEING
-005094 PACE MICRO TECHNOLOGY PLC
-005095 PERACOM NETWORKS
-005096 SALIX TECHNOLOGIES, INC.
-005097 MMC-EMBEDDED COMPUTERTECHNIK GmbH
-005098 GLOBALOOP, LTD.
-005099 3COM EUROPE, LTD.
-00509A TAG ELECTRONIC SYSTEMS
-00509B SWITCHCORE AB
-00509C BETA RESEARCH
-00509D THE INDUSTREE B.V.
-00509E Les Technologies SoftAcoustik Inc.
-00509F HORIZON COMPUTER
-0050A0 DELTA COMPUTER SYSTEMS, INC.
-0050A1 CARLO GAVAZZI, INC.
-0050A2 CISCO SYSTEMS, INC.
-0050A3 TransMedia Communications, Inc.
-0050A4 IO TECH, INC.
-0050A5 CAPITOL BUSINESS SYSTEMS, LTD.
-0050A6 OPTRONICS
-0050A7 CISCO SYSTEMS, INC.
-0050A8 OpenCon Systems, Inc.
-0050A9 MOLDAT WIRELESS TECHNOLGIES
-0050AA KONICA MINOLTA HOLDINGS, INC.
-0050AB NALTEC, INC.
-0050AC MAPLE COMPUTER CORPORATION
-0050AD CommUnique Wireless Corp.
-0050AE IWAKI ELECTRONICS CO., LTD.
-0050AF INTERGON, INC.
-0050B0 TECHNOLOGY ATLANTA CORPORATION
-0050B1 GIDDINGS & LEWIS
-0050B2 BRODEL AUTOMATION
-0050B3 VOICEBOARD CORPORATION
-0050B4 SATCHWELL CONTROL SYSTEMS, LTD
-0050B5 FICHET-BAUCHE
-0050B6 GOOD WAY IND. CO., LTD.
-0050B7 BOSER TECHNOLOGY CO., LTD.
-0050B8 INOVA COMPUTERS GMBH & CO. KG
-0050B9 XITRON TECHNOLOGIES, INC.
-0050BA D-LINK
-0050BB CMS TECHNOLOGIES
-0050BC HAMMER STORAGE SOLUTIONS
-0050BD CISCO SYSTEMS, INC.
-0050BE FAST MULTIMEDIA AG
-0050BF MOTOTECH INC.
-0050C0 GATAN, INC.
-0050C1 GEMFLEX NETWORKS, LTD.
-0050C2 IEEE REGISTRATION AUTHORITY
-0050C4 IMD
-0050C5 ADS TECHNOLOGIES, INC.
-0050C6 LOOP TELECOMMUNICATION INTERNATIONAL, INC.
-0050C8 ADDONICS COMMUNICATIONS, INC.
-0050C9 MASPRO DENKOH CORP.
-0050CA NET TO NET TECHNOLOGIES
-0050CB JETTER
-0050CC XYRATEX
-0050CD DIGIANSWER A/S
-0050CE LG INTERNATIONAL CORP.
-0050CF VANLINK COMMUNICATION TECHNOLOGY RESEARCH INSTITUTE
-0050D0 MINERVA SYSTEMS
-0050D1 CISCO SYSTEMS, INC.
-0050D2 BAE Systems Canada, Inc.
-0050D3 DIGITAL AUDIO PROCESSING PTY. LTD.
-0050D4 JOOHONG INFORMATION &
-0050D5 AD SYSTEMS CORP.
-0050D6 ATLAS COPCO TOOLS AB
-0050D7 TELSTRAT
-0050D8 UNICORN COMPUTER CORP.
-0050D9 ENGETRON-ENGENHARIA ELETRONICA IND. e COM. LTDA
-0050DA 3COM CORPORATION
-0050DB CONTEMPORARY CONTROL
-0050DC TAS TELEFONBAU A. SCHWABE GMBH & CO. KG
-0050DD SERRA SOLDADURA, S.A.
-0050DE SIGNUM SYSTEMS CORP.
-0050DF AirFiber, Inc.
-0050E1 NS TECH ELECTRONICS SDN BHD
-0050E2 CISCO SYSTEMS, INC.
-0050E3 Terayon Communications Systems
-0050E4 APPLE COMPUTER, INC.
-0050E6 HAKUSAN CORPORATION
-0050E7 PARADISE INNOVATIONS (ASIA)
-0050E8 NOMADIX INC.
-0050EA XEL COMMUNICATIONS, INC.
-0050EB ALPHA-TOP CORPORATION
-0050EC OLICOM A/S
-0050ED ANDA NETWORKS
-0050EE TEK DIGITEL CORPORATION
-0050EF SPE Systemhaus GmbH
-0050F0 CISCO SYSTEMS, INC.
-0050F1 LIBIT SIGNAL PROCESSING, LTD.
-0050F2 MICROSOFT CORP.
-0050F3 GLOBAL NET INFORMATION CO., Ltd.
-0050F4 SIGMATEK GMBH & CO. KG
-0050F6 PAN-INTERNATIONAL INDUSTRIAL CORP.
-0050F7 VENTURE MANUFACTURING (SINGAPORE) LTD.
-0050F8 ENTREGA TECHNOLOGIES, INC.
-0050FA OXTEL, LTD.
-0050FB VSK ELECTRONICS
-0050FC EDIMAX TECHNOLOGY CO., LTD.
-0050FD VISIONCOMM CO., LTD.
-0050FE PCTVnet ASA
-0050FF HAKKO ELECTRONICS CO., LTD.
-006000 XYCOM INC.
-006001 InnoSys, Inc.
-006002 SCREEN SUBTITLING SYSTEMS, LTD
-006003 TERAOKA WEIGH SYSTEM PTE, LTD.
-006004 COMPUTADORES MODULARES SA
-006005 FEEDBACK DATA LTD.
-006006 SOTEC CO., LTD
-006007 ACRES GAMING, INC.
-006008 3COM CORPORATION
-006009 CISCO SYSTEMS, INC.
-00600A SORD COMPUTER CORPORATION
-00600B LOGWARE GmbH
-00600C APPLIED DATA SYSTEMS, INC.
-00600D Digital Logic GmbH
-00600E WAVENET INTERNATIONAL, INC.
-00600F WESTELL, INC.
-006010 NETWORK MACHINES, INC.
-006011 CRYSTAL SEMICONDUCTOR CORP.
-006012 POWER COMPUTING CORPORATION
-006013 NETSTAL MASCHINEN AG
-006014 EDEC CO., LTD.
-006015 NET2NET CORPORATION
-006016 CLARIION
-006017 TOKIMEC INC.
-006018 STELLAR ONE CORPORATION
-006019 Roche Diagnostics
-00601A KEITHLEY INSTRUMENTS
-00601B MESA ELECTRONICS
-00601C TELXON CORPORATION
-00601D LUCENT TECHNOLOGIES
-00601E SOFTLAB, INC.
-00601F STALLION TECHNOLOGIES
-006020 PIVOTAL NETWORKING, INC.
-006021 DSC CORPORATION
-006022 VICOM SYSTEMS, INC.
-006023 PERICOM SEMICONDUCTOR CORP.
-006024 GRADIENT TECHNOLOGIES, INC.
-006025 ACTIVE IMAGING PLC
-006026 VIKING COMPONENTS, INC.
-006027 Superior Modular Products
-006028 MACROVISION CORPORATION
-006029 CARY PERIPHERALS INC.
-00602A SYMICRON COMPUTER COMMUNICATIONS, LTD.
-00602B PEAK AUDIO
-00602C LINX Data Terminals, Inc.
-00602D ALERTON TECHNOLOGIES, INC.
-00602E CYCLADES CORPORATION
-00602F CISCO SYSTEMS, INC.
-006030 VILLAGE TRONIC ENTWICKLUNG
-006031 HRK SYSTEMS
-006032 I-CUBE, INC.
-006033 ACUITY IMAGING, INC.
-006034 ROBERT BOSCH GmbH
-006035 DALLAS SEMICONDUCTOR, INC.
-006036 AUSTRIAN RESEARCH CENTER SEIBERSDORF
-006037 PHILIPS SEMICONDUCTORS
-006038 Nortel Networks
-006039 SanCom Technology, Inc.
-00603A QUICK CONTROLS LTD.
-00603B AMTEC spa
-00603C HAGIWARA SYS-COM CO., LTD.
-00603D 3CX
-00603E CISCO SYSTEMS, INC.
-00603F PATAPSCO DESIGNS
-006040 NETRO CORP.
-006041 Yokogawa Electric Corporation
-006042 TKS (USA), INC.
-006043 ComSoft Systems, Inc.
-006044 LITTON/POLY-SCIENTIFIC
-006045 PATHLIGHT TECHNOLOGIES
-006046 VMETRO, INC.
-006047 CISCO SYSTEMS, INC.
-006048 EMC CORPORATION
-006049 VINA TECHNOLOGIES
-00604A SAIC IDEAS GROUP
-00604B BIODATA GmbH
-00604C SAT
-00604D MMC NETWORKS, INC.
-00604E CYCLE COMPUTER CORPORATION, INC.
-00604F SUZUKI MFG. CO., LTD.
-006050 INTERNIX INC.
-006051 QUALITY SEMICONDUCTOR
-006052 PERIPHERALS ENTERPRISE CO., Ltd.
-006053 TOYODA MACHINE WORKS, LTD.
-006054 CONTROLWARE GMBH
-006055 CORNELL UNIVERSITY
-006056 NETWORK TOOLS, INC.
-006057 MURATA MANUFACTURING CO., LTD.
-006058 COPPER MOUNTAIN COMMUNICATIONS, INC.
-006059 TECHNICAL COMMUNICATIONS CORP.
-00605A CELCORE, INC.
-00605B IntraServer Technology, Inc.
-00605C CISCO SYSTEMS, INC.
-00605D SCANIVALVE CORP.
-00605E LIBERTY TECHNOLOGY NETWORKING
-00605F NIPPON UNISOFT CORPORATION
-006060 DAWNING TECHNOLOGIES, INC.
-006061 WHISTLE COMMUNICATIONS CORP.
-006062 TELESYNC, INC.
-006063 PSION DACOM PLC.
-006064 NETCOMM LIMITED
-006065 BERNECKER & RAINER INDUSTRIE-ELEKTRONIC GmbH
-006066 LACROIX TECHNOLGIE
-006067 ACER NETXUS INC.
-006068 EICON TECHNOLOGY CORPORATION
-006069 BROCADE COMMUNICATIONS SYSTEMS, Inc.
-00606A MITSUBISHI WIRELESS COMMUNICATIONS. INC.
-00606B Synclayer Inc.
-00606C ARESCOM
-00606D DIGITAL EQUIPMENT CORP.
-00606E DAVICOM SEMICONDUCTOR, INC.
-00606F CLARION CORPORATION OF AMERICA
-006070 CISCO SYSTEMS, INC.
-006071 MIDAS LAB, INC.
-006072 VXL INSTRUMENTS, LIMITED
-006073 REDCREEK COMMUNICATIONS, INC.
-006074 QSC AUDIO PRODUCTS
-006075 PENTEK, INC.
-006076 SCHLUMBERGER TECHNOLOGIES RETAIL PETROLEUM SYSTEMS
-006077 PRISA NETWORKS
-006078 POWER MEASUREMENT LTD.
-006079 Mainstream Data, Inc.
-00607A DVS GmbH
-00607B FORE SYSTEMS, INC.
-00607C WaveAccess, Ltd.
-00607D SENTIENT NETWORKS INC.
-00607E GIGALABS, INC.
-00607F AURORA TECHNOLOGIES, INC.
-006080 MICROTRONIX DATACOM LTD.
-006081 TV/COM INTERNATIONAL
-006082 NOVALINK TECHNOLOGIES, INC.
-006083 CISCO SYSTEMS, INC.
-006084 DIGITAL VIDEO
-006085 Storage Concepts
-006086 LOGIC REPLACEMENT TECH. LTD.
-006087 KANSAI ELECTRIC CO., LTD.
-006088 WHITE MOUNTAIN DSP, INC.
-006089 XATA
-00608A CITADEL COMPUTER
-00608B ConferTech International
-00608C 3COM CORPORATION
-00608D UNIPULSE CORP.
-00608E HE ELECTRONICS, TECHNOLOGIE & SYSTEMTECHNIK GmbH
-00608F TEKRAM TECHNOLOGY CO., LTD.
-006090 ABLE COMMUNICATIONS, INC.
-006091 FIRST PACIFIC NETWORKS, INC.
-006092 MICRO/SYS, INC.
-006093 VARIAN
-006094 IBM CORP.
-006095 ACCU-TIME SYSTEMS, INC.
-006096 T.S. MICROTECH INC.
-006097 3COM CORPORATION
-006098 HT COMMUNICATIONS
-006099 LAN MEDIA CORPORATION
-00609A NJK TECHNO CO.
-00609B ASTRO-MED, INC.
-00609C Perkin-Elmer Incorporated
-00609D PMI FOOD EQUIPMENT GROUP
-00609E ASC X3 - INFORMATION TECHNOLOGY STANDARDS SECRETARIATS
-00609F PHAST CORPORATION
-0060A0 SWITCHED NETWORK TECHNOLOGIES, INC.
-0060A1 VPNet, Inc.
-0060A2 NIHON UNISYS LIMITED CO.
-0060A3 CONTINUUM TECHNOLOGY CORP.
-0060A4 GRINAKER SYSTEM TECHNOLOGIES
-0060A5 PERFORMANCE TELECOM CORP.
-0060A6 PARTICLE MEASURING SYSTEMS
-0060A7 MICROSENS GmbH & CO. KG
-0060A8 TIDOMAT AB
-0060A9 GESYTEC MbH
-0060AA INTELLIGENT DEVICES INC. (IDI)
-0060AB LARSCOM INCORPORATED
-0060AC RESILIENCE CORPORATION
-0060AD MegaChips Corporation
-0060AE TRIO INFORMATION SYSTEMS AB
-0060AF PACIFIC MICRO DATA, INC.
-0060B0 HEWLETT-PACKARD CO.
-0060B1 INPUT/OUTPUT, INC.
-0060B2 PROCESS CONTROL CORP.
-0060B3 Z-COM, INC.
-0060B4 GLENAYRE R&D INC.
-0060B5 KEBA GmbH
-0060B6 LAND COMPUTER CO., LTD.
-0060B7 CHANNELMATIC, INC.
-0060B8 CORELIS INC.
-0060B9 NITSUKO CORPORATION
-0060BA SAHARA NETWORKS, INC.
-0060BB CABLETRON - NETLINK, INC.
-0060BC KeunYoung Electronics & Communication Co., Ltd.
-0060BD HUBBELL-PULSECOM
-0060BE WEBTRONICS
-0060BF MACRAIGOR SYSTEMS, INC.
-0060C0 NERA AS
-0060C1 WaveSpan Corporation
-0060C2 MPL AG
-0060C3 NETVISION CORPORATION
-0060C4 SOLITON SYSTEMS K.K.
-0060C5 ANCOT CORP.
-0060C6 DCS AG
-0060C7 AMATI COMMUNICATIONS CORP.
-0060C8 KUKA WELDING SYSTEMS & ROBOTS
-0060C9 ControlNet, Inc.
-0060CA HARMONIC SYSTEMS INCORPORATED
-0060CB HITACHI ZOSEN CORPORATION
-0060CC EMTRAK, INCORPORATED
-0060CD VideoServer, Inc.
-0060CE ACCLAIM COMMUNICATIONS
-0060CF ALTEON NETWORKS, INC.
-0060D0 SNMP RESEARCH INCORPORATED
-0060D1 CASCADE COMMUNICATIONS
-0060D2 LUCENT TECHNOLOGIES TAIWAN TELECOMMUNICATIONS CO., LTD.
-0060D3 AT&T
-0060D4 ELDAT COMMUNICATION LTD.
-0060D5 MIYACHI TECHNOS CORP.
-0060D6 NovAtel Wireless Technologies Ltd.
-0060D7 ECOLE POLYTECHNIQUE FEDERALE DE LAUSANNE (EPFL)
-0060D8 ELMIC SYSTEMS, INC.
-0060D9 TRANSYS NETWORKS INC.
-0060DA JBM ELECTRONICS CO.
-0060DB NTP ELEKTRONIK A/S
-0060DC TOYO COMMUNICATION EQUIPMENT Co., Ltd.
-0060DD MYRICOM, INC.
-0060DE KAYSER-THREDE GmbH
-0060DF CNT Corporation
-0060E0 AXIOM TECHNOLOGY CO., LTD.
-0060E1 ORCKIT COMMUNICATIONS LTD.
-0060E2 QUEST ENGINEERING & DEVELOPMENT
-0060E3 ARBIN INSTRUMENTS
-0060E4 COMPUSERVE, INC.
-0060E5 FUJI AUTOMATION CO., LTD.
-0060E6 SHOMITI SYSTEMS INCORPORATED
-0060E7 RANDATA
-0060E8 HITACHI COMPUTER PRODUCTS (AMERICA), INC.
-0060E9 ATOP TECHNOLOGIES, INC.
-0060EA StreamLogic
-0060EB FOURTHTRACK SYSTEMS
-0060EC HERMARY OPTO ELECTRONICS INC.
-0060ED RICARDO TEST AUTOMATION LTD.
-0060EE APOLLO
-0060EF FLYTECH TECHNOLOGY CO., LTD.
-0060F0 JOHNSON & JOHNSON MEDICAL, INC
-0060F1 EXP COMPUTER, INC.
-0060F2 LASERGRAPHICS, INC.
-0060F3 Performance Analysis Broadband, Spirent plc
-0060F4 ADVANCED COMPUTER SOLUTIONS, Inc.
-0060F5 ICON WEST, INC.
-0060F6 NEXTEST COMMUNICATIONS PRODUCTS, INC.
-0060F7 DATAFUSION SYSTEMS
-0060F8 Loran International Technologies Inc.
-0060F9 DIAMOND LANE COMMUNICATIONS
-0060FA EDUCATIONAL TECHNOLOGY RESOURCES, INC.
-0060FB PACKETEER, INC.
-0060FC CONSERVATION THROUGH INNOVATION LTD.
-0060FD NetICs, Inc.
-0060FE LYNX SYSTEM DEVELOPERS, INC.
-0060FF QuVis, Inc.
-0070B0 M/A-COM INC. COMPANIES
-0070B3 DATA RECALL LTD.
-008000 MULTITECH SYSTEMS, INC.
-008001 PERIPHONICS CORPORATION
-008002 SATELCOM (UK) LTD
-008003 HYTEC ELECTRONICS LTD.
-008004 ANTLOW COMMUNICATIONS, LTD.
-008005 CACTUS COMPUTER INC.
-008006 COMPUADD CORPORATION
-008007 DLOG NC-SYSTEME
-008008 DYNATECH COMPUTER SYSTEMS
-008009 JUPITER SYSTEMS, INC.
-00800A JAPAN COMPUTER CORP.
-00800B CSK CORPORATION
-00800C VIDECOM LIMITED
-00800D VOSSWINKEL F.U.
-00800E ATLANTIX CORPORATION
-00800F STANDARD MICROSYSTEMS
-008010 COMMODORE INTERNATIONAL
-008011 DIGITAL SYSTEMS INT'L. INC.
-008012 INTEGRATED MEASUREMENT SYSTEMS
-008013 THOMAS-CONRAD CORPORATION
-008014 ESPRIT SYSTEMS
-008015 SEIKO SYSTEMS, INC.
-008016 WANDEL AND GOLTERMANN
-008017 PFU LIMITED
-008018 KOBE STEEL, LTD.
-008019 DAYNA COMMUNICATIONS, INC.
-00801A BELL ATLANTIC
-00801B KODIAK TECHNOLOGY
-00801C NEWPORT SYSTEMS SOLUTIONS
-00801D INTEGRATED INFERENCE MACHINES
-00801E XINETRON, INC.
-00801F KRUPP ATLAS ELECTRONIK GMBH
-008020 NETWORK PRODUCTS
-008021 Alcatel Canada Inc.
-008022 SCAN-OPTICS
-008023 INTEGRATED BUSINESS NETWORKS
-008024 KALPANA, INC.
-008025 STOLLMANN GMBH
-008026 NETWORK PRODUCTS CORPORATION
-008027 ADAPTIVE SYSTEMS, INC.
-008028 TRADPOST (HK) LTD
-008029 EAGLE TECHNOLOGY, INC.
-00802A TEST SYSTEMS & SIMULATIONS INC
-00802B INTEGRATED MARKETING CO
-00802C THE SAGE GROUP PLC
-00802D XYLOGICS INC
-00802E CASTLE ROCK COMPUTING
-00802F NATIONAL INSTRUMENTS CORP.
-008030 NEXUS ELECTRONICS
-008031 BASYS, CORP.
-008032 ACCESS CO., LTD.
-008033 FORMATION, INC.
-008034 SMT GOUPIL
-008035 TECHNOLOGY WORKS, INC.
-008036 REFLEX MANUFACTURING SYSTEMS
-008037 Ericsson Group
-008038 DATA RESEARCH & APPLICATIONS
-008039 ALCATEL STC AUSTRALIA
-00803A VARITYPER, INC.
-00803B APT COMMUNICATIONS, INC.
-00803C TVS ELECTRONICS LTD
-00803D SURIGIKEN CO.,  LTD.
-00803E SYNERNETICS
-00803F TATUNG COMPANY
-008040 JOHN FLUKE MANUFACTURING CO.
-008041 VEB KOMBINAT ROBOTRON
-008042 FORCE COMPUTERS
-008043 NETWORLD, INC.
-008044 SYSTECH COMPUTER CORP.
-008045 MATSUSHITA ELECTRIC IND. CO
-008046 UNIVERSITY OF TORONTO
-008047 IN-NET CORP.
-008048 COMPEX INCORPORATED
-008049 NISSIN ELECTRIC CO., LTD.
-00804A PRO-LOG
-00804B EAGLE TECHNOLOGIES PTY.LTD.
-00804C CONTEC CO., LTD.
-00804D CYCLONE MICROSYSTEMS, INC.
-00804E APEX COMPUTER COMPANY
-00804F DAIKIN INDUSTRIES, LTD.
-008050 ZIATECH CORPORATION
-008051 FIBERMUX
-008052 TECHNICALLY ELITE CONCEPTS
-008053 INTELLICOM, INC.
-008054 FRONTIER TECHNOLOGIES CORP.
-008055 FERMILAB
-008056 SPHINX ELEKTRONIK GMBH
-008057 ADSOFT, LTD.
-008058 PRINTER SYSTEMS CORPORATION
-008059 STANLEY ELECTRIC CO., LTD
-00805A TULIP COMPUTERS INTERNAT'L B.V
-00805B CONDOR SYSTEMS, INC.
-00805C AGILIS CORPORATION
-00805D CANSTAR
-00805E LSI LOGIC CORPORATION
-00805F COMPAQ COMPUTER CORPORATION
-008060 NETWORK INTERFACE CORPORATION
-008061 LITTON SYSTEMS, INC.
-008062 INTERFACE  CO.
-008063 RICHARD HIRSCHMANN GMBH & CO.
-008064 WYSE TECHNOLOGY
-008065 CYBERGRAPHIC SYSTEMS PTY LTD.
-008066 ARCOM CONTROL SYSTEMS, LTD.
-008067 SQUARE D COMPANY
-008068 YAMATECH SCIENTIFIC LTD.
-008069 COMPUTONE SYSTEMS
-00806A ERI (EMPAC RESEARCH INC.)
-00806B SCHMID TELECOMMUNICATION
-00806C CEGELEC PROJECTS LTD
-00806D CENTURY SYSTEMS CORP.
-00806E NIPPON STEEL CORPORATION
-00806F ONELAN LTD.
-008070 COMPUTADORAS MICRON
-008071 SAI TECHNOLOGY
-008072 MICROPLEX SYSTEMS LTD.
-008073 DWB ASSOCIATES
-008074 FISHER CONTROLS
-008075 PARSYTEC GMBH
-008076 MCNC
-008077 BROTHER INDUSTRIES, LTD.
-008078 PRACTICAL PERIPHERALS, INC.
-008079 MICROBUS DESIGNS LTD.
-00807A AITECH SYSTEMS LTD.
-00807B ARTEL COMMUNICATIONS CORP.
-00807C FIBERCOM, INC.
-00807D EQUINOX SYSTEMS INC.
-00807E SOUTHERN PACIFIC LTD.
-00807F DY-4 INCORPORATED
-008080 DATAMEDIA CORPORATION
-008081 KENDALL SQUARE RESEARCH CORP.
-008082 PEP MODULAR COMPUTERS GMBH
-008083 AMDAHL
-008084 THE CLOUD INC.
-008085 H-THREE SYSTEMS CORPORATION
-008086 COMPUTER GENERATION INC.
-008087 OKI ELECTRIC INDUSTRY CO., LTD
-008088 VICTOR COMPANY OF JAPAN, LTD.
-008089 TECNETICS (PTY) LTD.
-00808A SUMMIT MICROSYSTEMS CORP.
-00808B DACOLL LIMITED
-00808C NetScout Systems, Inc.
-00808D WESTCOAST TECHNOLOGY B.V.
-00808E RADSTONE TECHNOLOGY
-00808F C. ITOH ELECTRONICS, INC.
-008090 MICROTEK INTERNATIONAL, INC.
-008091 TOKYO ELECTRIC CO.,LTD
-008092 JAPAN COMPUTER INDUSTRY, INC.
-008093 XYRON CORPORATION
-008094 ALFA LAVAL AUTOMATION AB
-008095 BASIC MERTON HANDELSGES.M.B.H.
-008096 HUMAN DESIGNED SYSTEMS, INC.
-008097 CENTRALP AUTOMATISMES
-008098 TDK CORPORATION
-008099 KLOCKNER MOELLER IPC
-00809A NOVUS NETWORKS LTD
-00809B JUSTSYSTEM CORPORATION
-00809C LUXCOM, INC.
-00809D Commscraft Ltd.
-00809E DATUS GMBH
-00809F ALCATEL BUSINESS SYSTEMS
-0080A0 EDISA HEWLETT PACKARD S/A
-0080A1 MICROTEST, INC.
-0080A2 CREATIVE ELECTRONIC SYSTEMS
-0080A3 LANTRONIX
-0080A4 LIBERTY ELECTRONICS
-0080A5 SPEED INTERNATIONAL
-0080A6 REPUBLIC TECHNOLOGY, INC.
-0080A7 MEASUREX CORP.
-0080A8 VITACOM CORPORATION
-0080A9 CLEARPOINT RESEARCH
-0080AA MAXPEED
-0080AB DUKANE NETWORK INTEGRATION
-0080AC IMLOGIX, DIVISION OF GENESYS
-0080AD CNET TECHNOLOGY, INC.
-0080AE HUGHES NETWORK SYSTEMS
-0080AF ALLUMER CO., LTD.
-0080B0 ADVANCED INFORMATION
-0080B1 SOFTCOM A/S
-0080B2 NETWORK EQUIPMENT TECHNOLOGIES
-0080B3 AVAL DATA CORPORATION
-0080B4 SOPHIA SYSTEMS
-0080B5 UNITED NETWORKS INC.
-0080B6 THEMIS COMPUTER
-0080B7 STELLAR COMPUTER
-0080B8 BUG, INCORPORATED
-0080B9 ARCHE TECHNOLIGIES INC.
-0080BA SPECIALIX (ASIA) PTE, LTD
-0080BB HUGHES LAN SYSTEMS
-0080BC HITACHI ENGINEERING CO., LTD
-0080BD THE FURUKAWA ELECTRIC CO., LTD
-0080BE ARIES RESEARCH
-0080BF TAKAOKA ELECTRIC MFG. CO. LTD.
-0080C0 PENRIL DATACOMM
-0080C1 LANEX CORPORATION
-0080C2 IEEE 802.1 COMMITTEE
-0080C3 BICC INFORMATION SYSTEMS & SVC
-0080C4 DOCUMENT TECHNOLOGIES, INC.
-0080C5 NOVELLCO DE MEXICO
-0080C6 NATIONAL DATACOMM CORPORATION
-0080C7 XIRCOM
-0080C8 D-LINK SYSTEMS, INC.
-0080C9 ALBERTA MICROELECTRONIC CENTRE
-0080CA NETCOM RESEARCH INCORPORATED
-0080CB FALCO DATA PRODUCTS
-0080CC MICROWAVE BYPASS SYSTEMS
-0080CD MICRONICS COMPUTER, INC.
-0080CE BROADCAST TELEVISION SYSTEMS
-0080CF EMBEDDED PERFORMANCE INC.
-0080D0 COMPUTER PERIPHERALS, INC.
-0080D1 KIMTRON CORPORATION
-0080D2 SHINNIHONDENKO CO., LTD.
-0080D3 SHIVA CORP.
-0080D4 CHASE RESEARCH LTD.
-0080D5 CADRE TECHNOLOGIES
-0080D6 NUVOTECH, INC.
-0080D7 Fantum Engineering
-0080D8 NETWORK PERIPHERALS INC.
-0080D9 EMK ELEKTRONIK
-0080DA BRUEL & KJAER
-0080DB GRAPHON CORPORATION
-0080DC PICKER INTERNATIONAL
-0080DD GMX INC/GIMIX
-0080DE GIPSI S.A.
-0080DF ADC CODENOLL TECHNOLOGY CORP.
-0080E0 XTP SYSTEMS, INC.
-0080E1 STMICROELECTRONICS
-0080E2 T.D.I. CO., LTD.
-0080E3 CORAL NETWORK CORPORATION
-0080E4 NORTHWEST DIGITAL SYSTEMS, INC
-0080E5 MYLEX CORPORATION
-0080E6 PEER NETWORKS, INC.
-0080E7 LYNWOOD SCIENTIFIC DEV. LTD.
-0080E8 CUMULUS CORPORATIION
-0080E9 Madge Ltd.
-0080EA ADVA Optical Networking Ltd.
-0080EB COMPCONTROL B.V.
-0080EC SUPERCOMPUTING SOLUTIONS, INC.
-0080ED IQ TECHNOLOGIES, INC.
-0080EE THOMSON CSF
-0080EF RATIONAL
-0080F0 Panasonic Communications Co., Ltd.
-0080F1 OPUS SYSTEMS
-0080F2 RAYCOM SYSTEMS INC
-0080F3 SUN ELECTRONICS CORP.
-0080F4 TELEMECANIQUE ELECTRIQUE
-0080F5 QUANTEL LTD
-0080F6 SYNERGY MICROSYSTEMS
-0080F7 ZENITH ELECTRONICS
-0080F8 MIZAR, INC.
-0080F9 HEURIKON CORPORATION
-0080FA RWT GMBH
-0080FB BVM LIMITED
-0080FC AVATAR CORPORATION
-0080FD EXSCEED CORPRATION
-0080FE AZURE TECHNOLOGIES, INC.
-0080FF SOC. DE TELEINFORMATIQUE RTC
-009000 DIAMOND MULTIMEDIA
-009001 NISHIMU ELECTRONICS INDUSTRIES CO., LTD.
-009002 ALLGON AB
-009003 APLIO
-009004 3COM EUROPE LTD.
-009005 PROTECH SYSTEMS CO., LTD.
-009006 HAMAMATSU PHOTONICS K.K.
-009007 DOMEX TECHNOLOGY CORP.
-009008 HanA Systems Inc.
-009009 i Controls, Inc.
-00900A PROTON ELECTRONIC INDUSTRIAL CO., LTD.
-00900B LANNER ELECTRONICS, INC.
-00900C CISCO SYSTEMS, INC.
-00900D OVERLAND DATA INC.
-00900E HANDLINK TECHNOLOGIES, INC.
-00900F KAWASAKI HEAVY INDUSTRIES, LTD
-009010 SIMULATION LABORATORIES, INC.
-009011 WAVTrace, Inc.
-009012 GLOBESPAN SEMICONDUCTOR, INC.
-009013 SAMSAN CORP.
-009014 ROTORK INSTRUMENTS, LTD.
-009015 CENTIGRAM COMMUNICATIONS CORP.
-009016 ZAC
-009017 ZYPCOM, INC.
-009018 ITO ELECTRIC INDUSTRY CO, LTD.
-009019 HERMES ELECTRONICS CO., LTD.
-00901A UNISPHERE SOLUTIONS
-00901B DIGITAL CONTROLS
-00901C mps Software Gmbh
-00901D PEC (NZ) LTD.
-00901E SELESTA INGEGNE RIA S.P.A.
-00901F ADTEC PRODUCTIONS, INC.
-009020 PHILIPS ANALYTICAL X-RAY B.V.
-009021 CISCO SYSTEMS, INC.
-009022 IVEX
-009023 ZILOG INC.
-009024 PIPELINKS, INC.
-009025 VISION SYSTEMS LTD. PTY
-009026 ADVANCED SWITCHING COMMUNICATIONS, INC.
-009027 INTEL CORPORATION
-009028 NIPPON SIGNAL CO., LTD.
-009029 CRYPTO AG
-00902A COMMUNICATION DEVICES, INC.
-00902B CISCO SYSTEMS, INC.
-00902C DATA & CONTROL EQUIPMENT LTD.
-00902D DATA ELECTRONICS (AUST.) PTY, LTD.
-00902E NAMCO LIMITED
-00902F NETCORE SYSTEMS, INC.
-009030 HONEYWELL-DATING
-009031 MYSTICOM, LTD.
-009032 PELCOMBE GROUP LTD.
-009033 INNOVAPHONE GmbH
-009034 IMAGIC, INC.
-009035 ALPHA TELECOM, INC.
-009036 ens, inc.
-009037 ACUCOMM, INC.
-009038 FOUNTAIN TECHNOLOGIES, INC.
-009039 SHASTA NETWORKS
-00903A NIHON MEDIA TOOL INC.
-00903B TriEMS Research Lab, Inc.
-00903C ATLANTIC NETWORK SYSTEMS
-00903D BIOPAC SYSTEMS, INC.
-00903E N.V. PHILIPS INDUSTRIAL ACTIVITIES
-00903F AZTEC RADIOMEDIA
-009040 Siemens Network Convergence LLC
-009041 APPLIED DIGITAL ACCESS
-009042 ECCS, Inc.
-009043 NICHIBEI DENSHI CO., LTD.
-009044 ASSURED DIGITAL, INC.
-009045 Marconi Communications
-009046 DEXDYNE, LTD.
-009047 GIGA FAST E. LTD.
-009048 ZEAL CORPORATION
-009049 ENTRIDIA CORPORATION
-00904A CONCUR SYSTEM TECHNOLOGIES
-00904B GemTek Technology Co., Ltd.
-00904C EPIGRAM, INC.
-00904D SPEC S.A.
-00904E DELEM BV
-00904F ABB POWER T&D COMPANY, INC.
-009050 TELESTE OY
-009051 ULTIMATE TECHNOLOGY CORP.
-009052 SELCOM ELETTRONICA S.R.L.
-009053 DAEWOO ELECTRONICS CO., LTD.
-009054 INNOVATIVE SEMICONDUCTORS, INC
-009055 PARKER HANNIFIN CORPORATION COMPUMOTOR DIVISION
-009056 TELESTREAM, INC.
-009057 AANetcom, Inc.
-009058 Ultra Electronics Ltd., Command and Control Systems
-009059 TELECOM DEVICE K.K.
-00905A DEARBORN GROUP, INC.
-00905B RAYMOND AND LAE ENGINEERING
-00905C EDMI
-00905D NETCOM SICHERHEITSTECHNIK GmbH
-00905E RAULAND-BORG CORPORATION
-00905F CISCO SYSTEMS, INC.
-009060 SYSTEM CREATE CORP.
-009061 PACIFIC RESEARCH & ENGINEERING CORPORATION
-009062 ICP VORTEX COMPUTERSYSTEME GmbH
-009063 COHERENT COMMUNICATIONS SYSTEMS CORPORATION
-009064 THOMSON BROADCAST SYSTEMS
-009065 FINISAR CORPORATION
-009066 Troika Networks, Inc.
-009067 WalkAbout Computers, Inc.
-009068 DVT CORP.
-009069 JUNIPER NETWORKS, INC.
-00906A TURNSTONE SYSTEMS, INC.
-00906B APPLIED RESOURCES, INC.
-00906C GWT GLOBAL WEIGHING TECHNOLOGIES GmbH
-00906D CISCO SYSTEMS, INC.
-00906E PRAXON, INC.
-00906F CISCO SYSTEMS, INC.
-009070 NEO NETWORKS, INC.
-009071 Applied Innovation Inc.
-009072 SIMRAD AS
-009073 GAIO TECHNOLOGY
-009074 ARGON NETWORKS, INC.
-009075 NEC DO BRASIL S.A.
-009076 FMT AIRCRAFT GATE SUPPORT SYSTEMS AB
-009077 ADVANCED FIBRE COMMUNICATIONS
-009078 MER TELEMANAGEMENT SOLUTIONS, LTD.
-009079 ClearOne, Inc.
-00907A SPECTRALINK CORP.
-00907B E-TECH, INC.
-00907C DIGITALCAST, INC.
-00907D Lake Communications
-00907E VETRONIX CORP.
-00907F WatchGuard Technologies, Inc.
-009080 NOT LIMITED, INC.
-009081 ALOHA NETWORKS, INC.
-009082 FORCE INSTITUTE
-009083 TURBO COMMUNICATION, INC.
-009084 ATECH SYSTEM
-009085 GOLDEN ENTERPRISES, INC.
-009086 CISCO SYSTEMS, INC.
-009087 ITIS
-009088 BAXALL SECURITY LTD.
-009089 SOFTCOM MICROSYSTEMS, INC.
-00908A BAYLY COMMUNICATIONS, INC.
-00908B CELL COMPUTING, INC.
-00908C ETREND ELECTRONICS, INC.
-00908D VICKERS ELECTRONICS SYSTEMS
-00908E Nortel Networks Broadband Access
-00908F AUDIO CODES LTD.
-009090 I-BUS
-009091 DigitalScape, Inc.
-009092 CISCO SYSTEMS, INC.
-009093 NANAO CORPORATION
-009094 OSPREY TECHNOLOGIES, INC.
-009095 UNIVERSAL AVIONICS
-009096 ASKEY COMPUTER CORP.
-009097 SYCAMORE NETWORKS
-009098 SBC DESIGNS, INC.
-009099 ALLIED TELESIS, K.K.
-00909A ONE WORLD SYSTEMS, INC.
-00909B MARKPOINT AB
-00909C Terayon Communications Systems
-00909D GSE SYSTEMS, INC.
-00909E Critical IO, LLC
-00909F DIGI-DATA CORPORATION
-0090A0 8X8 INC.
-0090A1 FLYING PIG SYSTEMS, LTD.
-0090A2 CYBERTAN TECHNOLOGY, INC.
-0090A3 Corecess Inc.
-0090A4 ALTIGA NETWORKS
-0090A5 SPECTRA LOGIC
-0090A6 CISCO SYSTEMS, INC.
-0090A7 CLIENTEC CORPORATION
-0090A8 NineTiles Networks, Ltd.
-0090A9 WESTERN DIGITAL
-0090AA INDIGO ACTIVE VISION SYSTEMS LIMITED
-0090AB CISCO SYSTEMS, INC.
-0090AC OPTIVISION, INC.
-0090AD ASPECT ELECTRONICS, INC.
-0090AE ITALTEL S.p.A.
-0090AF J. MORITA MFG. CORP.
-0090B0 VADEM
-0090B1 CISCO SYSTEMS, INC.
-0090B2 AVICI SYSTEMS INC.
-0090B3 AGRANAT SYSTEMS
-0090B4 WILLOWBROOK TECHNOLOGIES
-0090B5 NIKON CORPORATION
-0090B6 FIBEX SYSTEMS
-0090B7 DIGITAL LIGHTWAVE, INC.
-0090B8 ROHDE & SCHWARZ GMBH & CO. KG
-0090B9 BERAN INSTRUMENTS LTD.
-0090BA VALID NETWORKS, INC.
-0090BB TAINET COMMUNICATION SYSTEM Corp.
-0090BC TELEMANN CO., LTD.
-0090BD OMNIA COMMUNICATIONS, INC.
-0090BE IBC/INTEGRATED BUSINESS COMPUTERS
-0090BF CISCO SYSTEMS, INC.
-0090C0 K.J. LAW ENGINEERS, INC.
-0090C1 Peco II, Inc.
-0090C2 JK microsystems, Inc.
-0090C3 TOPIC SEMICONDUCTOR CORP.
-0090C4 JAVELIN SYSTEMS, INC.
-0090C5 INTERNET MAGIC, INC.
-0090C6 OPTIM SYSTEMS, INC.
-0090C7 ICOM INC.
-0090C8 WAVERIDER COMMUNICATIONS (CANADA) INC.
-0090C9 DPAC Technologies
-0090CA ACCORD VIDEO TELECOMMUNICATIONS, LTD.
-0090CB Wireless OnLine, Inc.
-0090CC PLANET COMMUNICATIONS, INC.
-0090CD ENT-EMPRESA NACIONAL DE TELECOMMUNICACOES, S.A.
-0090CE TETRA GmbH
-0090CF NORTEL
-0090D0 Thomson Belgium
-0090D1 LEICHU ENTERPRISE CO., LTD.
-0090D2 ARTEL VIDEO SYSTEMS
-0090D3 GIESECKE & DEVRIENT GmbH
-0090D4 BindView Development Corp.
-0090D5 EUPHONIX, INC.
-0090D6 CRYSTAL GROUP
-0090D7 NetBoost Corp.
-0090D8 WHITECROSS SYSTEMS
-0090D9 CISCO SYSTEMS, INC.
-0090DA DYNARC, INC.
-0090DB NEXT LEVEL COMMUNICATIONS
-0090DC TECO INFORMATION SYSTEMS
-0090DD THE MIHARU COMMUNICATIONS CO., LTD.
-0090DE CARDKEY SYSTEMS, INC.
-0090DF MITSUBISHI CHEMICAL AMERICA, INC.
-0090E0 SYSTRAN CORP.
-0090E1 TELENA S.P.A.
-0090E2 DISTRIBUTED PROCESSING TECHNOLOGY
-0090E3 AVEX ELECTRONICS INC.
-0090E4 NEC AMERICA, INC.
-0090E5 TEKNEMA, INC.
-0090E6 ACER LABORATORIES, INC.
-0090E7 HORSCH ELEKTRONIK AG
-0090E8 MOXA TECHNOLOGIES CORP., LTD.
-0090E9 JANZ COMPUTER AG
-0090EA ALPHA TECHNOLOGIES, INC.
-0090EB SENTRY TELECOM SYSTEMS
-0090EC PYRESCOM
-0090ED CENTRAL SYSTEM RESEARCH CO., LTD.
-0090EE PERSONAL COMMUNICATIONS TECHNOLOGIES
-0090EF INTEGRIX, INC.
-0090F0 HARMONIC LIGHTWAVES, LTD.
-0090F1 DOT HILL SYSTEMS CORPORATION
-0090F2 CISCO SYSTEMS, INC.
-0090F3 ASPECT COMMUNICATIONS
-0090F4 LIGHTNING INSTRUMENTATION
-0090F5 CLEVO CO.
-0090F6 ESCALATE NETWORKS, INC.
-0090F7 NBASE COMMUNICATIONS LTD.
-0090F8 MEDIATRIX TELECOM
-0090F9 LEITCH
-0090FA GigaNet, Inc.
-0090FB PORTWELL, INC.
-0090FC NETWORK COMPUTING DEVICES
-0090FD CopperCom, Inc.
-0090FE ELECOM CO., LTD.  (LANEED DIV.)
-0090FF TELLUS TECHNOLOGY INC.
-0091D6 Crystal Group, Inc.
-009D8E CARDIAC RECORDERS, INC.
-00A000 CENTILLION NETWORKS, INC.
-00A001 WATKINS-JOHNSON COMPANY
-00A002 LEEDS & NORTHRUP AUSTRALIA PTY LTD
-00A003 STAEFA CONTROL SYSTEM
-00A004 NETPOWER, INC.
-00A005 DANIEL INSTRUMENTS, LTD.
-00A006 IMAGE DATA PROCESSING SYSTEM GROUP
-00A007 APEXX TECHNOLOGY, INC.
-00A008 NETCORP
-00A009 WHITETREE NETWORK
-00A00A R.D.C. COMMUNICATION
-00A00B COMPUTEX CO., LTD.
-00A00C KINGMAX TECHNOLOGY, INC.
-00A00D THE PANDA PROJECT
-00A00E VISUAL NETWORKS, INC.
-00A00F Broadband Technologies
-00A010 SYSLOGIC DATENTECHNIK AG
-00A011 MUTOH INDUSTRIES LTD.
-00A012 B.A.T.M. ADVANCED TECHNOLOGIES
-00A013 TELTREND LTD.
-00A014 CSIR
-00A015 WYLE
-00A016 MICROPOLIS CORP.
-00A017 J B M CORPORATION
-00A018 CREATIVE CONTROLLERS, INC.
-00A019 NEBULA CONSULTANTS, INC.
-00A01A BINAR ELEKTRONIK AB
-00A01B PREMISYS COMMUNICATIONS, INC.
-00A01C NASCENT NETWORKS CORPORATION
-00A01D SIXNET
-00A01E EST CORPORATION
-00A01F TRICORD SYSTEMS, INC.
-00A020 CITICORP/TTI
-00A021 GENERAL DYNAMICS-
-00A022 CENTRE FOR DEVELOPMENT OF ADVANCED COMPUTING
-00A023 APPLIED CREATIVE TECHNOLOGY, INC.
-00A024 3COM CORPORATION
-00A025 REDCOM LABS INC.
-00A026 TELDAT, S.A.
-00A027 FIREPOWER SYSTEMS, INC.
-00A028 CONNER PERIPHERALS
-00A029 COULTER CORPORATION
-00A02A TRANCELL SYSTEMS
-00A02B TRANSITIONS RESEARCH CORP.
-00A02C interWAVE Communications
-00A02D 1394 Trade Association
-00A02E BRAND COMMUNICATIONS, LTD.
-00A02F PIRELLI CAVI
-00A030 CAPTOR NV/SA
-00A031 HAZELTINE CORPORATION, MS 1-17
-00A032 GES SINGAPORE PTE. LTD.
-00A033 imc MeBsysteme GmbH
-00A034 AXEL
-00A035 CYLINK CORPORATION
-00A036 APPLIED NETWORK TECHNOLOGY
-00A037 DATASCOPE CORPORATION
-00A038 EMAIL ELECTRONICS
-00A039 ROSS TECHNOLOGY, INC.
-00A03A KUBOTEK CORPORATION
-00A03B TOSHIN ELECTRIC CO., LTD.
-00A03C EG&G NUCLEAR INSTRUMENTS
-00A03D OPTO-22
-00A03E ATM FORUM
-00A03F COMPUTER SOCIETY MICROPROCESSOR & MICROPROCESSOR STANDARDS C
-00A040 APPLE COMPUTER
-00A041 LEYBOLD-INFICON
-00A042 SPUR PRODUCTS CORP.
-00A043 AMERICAN TECHNOLOGY LABS, INC.
-00A044 NTT IT CO., LTD.
-00A045 PHOENIX CONTACT GMBH & CO.
-00A046 SCITEX CORP. LTD.
-00A047 INTEGRATED FITNESS CORP.
-00A048 QUESTECH, LTD.
-00A049 DIGITECH INDUSTRIES, INC.
-00A04A NISSHIN ELECTRIC CO., LTD.
-00A04B TFL LAN INC.
-00A04C INNOVATIVE SYSTEMS & TECHNOLOGIES, INC.
-00A04D EDA INSTRUMENTS, INC.
-00A04E VOELKER TECHNOLOGIES, INC.
-00A04F AMERITEC CORP.
-00A050 CYPRESS SEMICONDUCTOR
-00A051 ANGIA COMMUNICATIONS. INC.
-00A052 STANILITE ELECTRONICS PTY. LTD
-00A053 COMPACT DEVICES, INC.
-00A055 Data Device Corporation
-00A056 MICROPROSS
-00A057 LANCOM Systems GmbH
-00A058 GLORY, LTD.
-00A059 HAMILTON HALLMARK
-00A05A KOFAX IMAGE PRODUCTS
-00A05B MARQUIP, INC.
-00A05C INVENTORY CONVERSION, INC./
-00A05D CS COMPUTER SYSTEME GmbH
-00A05E MYRIAD LOGIC INC.
-00A05F BTG ENGINEERING BV
-00A060 ACER PERIPHERALS, INC.
-00A061 PURITAN BENNETT
-00A062 AES PRODATA
-00A063 JRL SYSTEMS, INC.
-00A064 KVB/ANALECT
-00A065 NEXLAND, INC.
-00A066 ISA CO., LTD.
-00A067 NETWORK SERVICES GROUP
-00A068 BHP LIMITED
-00A069 Symmetricom, Inc.
-00A06A Verilink Corporation
-00A06B DMS DORSCH MIKROSYSTEM GMBH
-00A06C SHINDENGEN ELECTRIC MFG. CO., LTD.
-00A06D MANNESMANN TALLY CORPORATION
-00A06E AUSTRON, INC.
-00A06F THE APPCON GROUP, INC.
-00A070 COASTCOM
-00A071 VIDEO LOTTERY TECHNOLOGIES,INC
-00A072 OVATION SYSTEMS LTD.
-00A073 COM21, INC.
-00A074 PERCEPTION TECHNOLOGY
-00A075 MICRON TECHNOLOGY, INC.
-00A076 CARDWARE LAB, INC.
-00A077 FUJITSU NEXION, INC.
-00A078 Marconi Communications
-00A079 ALPS ELECTRIC (USA), INC.
-00A07A ADVANCED PERIPHERALS TECHNOLOGIES, INC.
-00A07B DAWN COMPUTER INCORPORATION
-00A07C TONYANG NYLON CO., LTD.
-00A07D SEEQ TECHNOLOGY, INC.
-00A07E AVID TECHNOLOGY, INC.
-00A07F GSM-SYNTEL, LTD.
-00A080 ANTARES MICROSYSTEMS
-00A081 ALCATEL DATA NETWORKS
-00A082 NKT ELEKTRONIK A/S
-00A083 ASIMMPHONY TURKEY
-00A084 DATAPLEX PTY. LTD.
-00A086 AMBER WAVE SYSTEMS, INC.
-00A087 Zarlink Semiconductor Ltd.
-00A088 ESSENTIAL COMMUNICATIONS
-00A089 XPOINT TECHNOLOGIES, INC.
-00A08A BROOKTROUT TECHNOLOGY, INC.
-00A08B ASTON ELECTRONIC DESIGNS LTD.
-00A08C MultiMedia LANs, Inc.
-00A08D JACOMO CORPORATION
-00A08E Nokia Internet Communications
-00A08F DESKNET SYSTEMS, INC.
-00A090 TimeStep Corporation
-00A091 APPLICOM INTERNATIONAL
-00A092 H. BOLLMANN MANUFACTURERS, LTD
-00A093 B/E AEROSPACE, Inc.
-00A094 COMSAT CORPORATION
-00A095 ACACIA NETWORKS, INC.
-00A096 MITUMI ELECTRIC CO., LTD.
-00A097 JC INFORMATION SYSTEMS
-00A098 NETWORK APPLIANCE CORP.
-00A099 K-NET LTD.
-00A09A NIHON KOHDEN AMERICA
-00A09B QPSX COMMUNICATIONS, LTD.
-00A09C Xyplex, Inc.
-00A09D JOHNATHON FREEMAN TECHNOLOGIES
-00A09E ICTV
-00A09F COMMVISION CORP.
-00A0A0 COMPACT DATA, LTD.
-00A0A1 EPIC DATA INC.
-00A0A2 DIGICOM S.P.A.
-00A0A3 RELIABLE POWER METERS
-00A0A4 MICROS SYSTEMS, INC.
-00A0A5 TEKNOR MICROSYSTEME, INC.
-00A0A6 M.I. SYSTEMS, K.K.
-00A0A7 VORAX CORPORATION
-00A0A8 RENEX CORPORATION
-00A0A9 GN NETTEST (CANADA) NAVTEL DIVISION
-00A0AA SPACELABS MEDICAL
-00A0AB NETCS INFORMATIONSTECHNIK GMBH
-00A0AC GILAT SATELLITE NETWORKS, LTD.
-00A0AD MARCONI SPA
-00A0AE NUCOM SYSTEMS, INC.
-00A0AF WMS INDUSTRIES
-00A0B0 I-O DATA DEVICE, INC.
-00A0B1 FIRST VIRTUAL CORPORATION
-00A0B2 SHIMA SEIKI
-00A0B3 ZYKRONIX
-00A0B4 TEXAS MICROSYSTEMS, INC.
-00A0B5 3H TECHNOLOGY
-00A0B6 SANRITZ AUTOMATION CO., LTD.
-00A0B7 CORDANT, INC.
-00A0B8 SYMBIOS LOGIC INC.
-00A0B9 EAGLE TECHNOLOGY, INC.
-00A0BA PATTON ELECTRONICS CO.
-00A0BB HILAN GMBH
-00A0BC VIASAT, INCORPORATED
-00A0BD I-TECH CORP.
-00A0BE INTEGRATED CIRCUIT SYSTEMS, INC. COMMUNICATIONS GROUP
-00A0BF WIRELESS DATA GROUP MOTOROLA
-00A0C0 DIGITAL LINK CORP.
-00A0C1 ORTIVUS MEDICAL AB
-00A0C2 R.A. SYSTEMS CO., LTD.
-00A0C3 UNICOMPUTER GMBH
-00A0C4 CRISTIE ELECTRONICS LTD.
-00A0C5 ZYXEL COMMUNICATION
-00A0C6 QUALCOMM INCORPORATED
-00A0C7 TADIRAN TELECOMMUNICATIONS
-00A0C8 ADTRAN INC.
-00A0C9 INTEL CORPORATION - HF1-06
-00A0CA FUJITSU DENSO LTD.
-00A0CB ARK TELECOMMUNICATIONS, INC.
-00A0CC LITE-ON COMMUNICATIONS, INC.
-00A0CD DR. JOHANNES HEIDENHAIN GmbH
-00A0CE ASTROCOM CORPORATION
-00A0CF SOTAS, INC.
-00A0D0 TEN X TECHNOLOGY, INC.
-00A0D1 INVENTEC CORPORATION
-00A0D2 ALLIED TELESIS INTERNATIONAL CORPORATION
-00A0D3 INSTEM COMPUTER SYSTEMS, LTD.
-00A0D4 RADIOLAN,  INC.
-00A0D5 SIERRA WIRELESS INC.
-00A0D6 SBE, INC.
-00A0D7 KASTEN CHASE APPLIED RESEARCH
-00A0D8 SPECTRA - TEK
-00A0D9 CONVEX COMPUTER CORPORATION
-00A0DA INTEGRATED SYSTEMS Technology, Inc.
-00A0DB FISHER & PAYKEL PRODUCTION
-00A0DC O.N. ELECTRONIC CO., LTD.
-00A0DD AZONIX CORPORATION
-00A0DE YAMAHA CORPORATION
-00A0DF STS TECHNOLOGIES, INC.
-00A0E0 TENNYSON TECHNOLOGIES PTY LTD
-00A0E1 WESTPORT RESEARCH ASSOCIATES, INC.
-00A0E2 KEISOKU GIKEN CORP.
-00A0E3 XKL SYSTEMS CORP.
-00A0E4 OPTIQUEST
-00A0E5 NHC COMMUNICATIONS
-00A0E6 DIALOGIC CORPORATION
-00A0E7 CENTRAL DATA CORPORATION
-00A0E8 REUTERS HOLDINGS PLC
-00A0E9 ELECTRONIC RETAILING SYSTEMS INTERNATIONAL
-00A0EA ETHERCOM CORP.
-00A0EB Encore Networks
-00A0EC TRANSMITTON LTD.
-00A0ED PRI AUTOMATION
-00A0EE NASHOBA NETWORKS
-00A0EF LUCIDATA LTD.
-00A0F0 TORONTO MICROELECTRONICS INC.
-00A0F1 MTI
-00A0F2 INFOTEK COMMUNICATIONS, INC.
-00A0F3 STAUBLI
-00A0F4 GE
-00A0F5 RADGUARD LTD.
-00A0F6 AutoGas Systems Inc.
-00A0F7 V.I COMPUTER CORP.
-00A0F8 SYMBOL TECHNOLOGIES, INC.
-00A0F9 BINTEC COMMUNICATIONS GMBH
-00A0FA Marconi Communication GmbH
-00A0FB TORAY ENGINEERING CO., LTD.
-00A0FC IMAGE SCIENCES, INC.
-00A0FD SCITEX DIGITAL PRINTING, INC.
-00A0FE BOSTON TECHNOLOGY, INC.
-00A0FF TELLABS OPERATIONS, INC.
-00AA00 INTEL CORPORATION
-00AA01 INTEL CORPORATION
-00AA02 INTEL CORPORATION
-00AA3C OLIVETTI TELECOM SPA (OLTECO)
-00B009 Grass Valley Group
-00B017 InfoGear Technology Corp.
-00B019 Casi-Rusco
-00B01C Westport Technologies
-00B01E Rantic Labs, Inc.
-00B02A ORSYS GmbH
-00B02D ViaGate Technologies, Inc.
-00B03B HiQ Networks
-00B048 Marconi Communications Inc.
-00B04A Cisco Systems, Inc.
-00B052 Intellon Corporation
-00B064 Cisco Systems, Inc.
-00B069 Honewell Oy
-00B06D Jones Futurex Inc.
-00B080 Mannesmann Ipulsys B.V.
-00B086 LocSoft Limited
-00B08E Cisco Systems, Inc.
-00B091 Transmeta Corp.
-00B094 Alaris, Inc.
-00B09A Morrow Technologies Corp.
-00B09D Point Grey Research Inc.
-00B0AC SIAE-Microelettronica S.p.A.
-00B0AE Symmetricom
-00B0B3 Xstreamis PLC
-00B0C2 Cisco Systems, Inc.
-00B0C7 Tellabs Operations, Inc.
-00B0CE TECHNOLOGY RESCUE
-00B0D0 Dell Computer Corp.
-00B0DB Nextcell, Inc.
-00B0DF Reliable Data Technology, Inc.
-00B0E7 British Federal Ltd.
-00B0EC EACEM
-00B0EE Ajile Systems, Inc.
-00B0F0 CALY NETWORKS
-00B0F5 NetWorth Technologies, Inc.
-00BB01 OCTOTHORPE CORP.
-00BBF0 UNGERMANN-BASS INC.
-00C000 LANOPTICS, LTD.
-00C001 DIATEK PATIENT MANAGMENT
-00C002 SERCOMM CORPORATION
-00C003 GLOBALNET COMMUNICATIONS
-00C004 JAPAN BUSINESS COMPUTER CO.LTD
-00C005 LIVINGSTON ENTERPRISES, INC.
-00C006 NIPPON AVIONICS CO., LTD.
-00C007 PINNACLE DATA SYSTEMS, INC.
-00C008 SECO SRL
-00C009 KT TECHNOLOGY (S) PTE LTD
-00C00A MICRO CRAFT
-00C00B NORCONTROL A.S.
-00C00C RELIA TECHNOLGIES
-00C00D ADVANCED LOGIC RESEARCH, INC.
-00C00E PSITECH, INC.
-00C00F QUANTUM SOFTWARE SYSTEMS LTD.
-00C010 HIRAKAWA HEWTECH CORP.
-00C011 INTERACTIVE COMPUTING DEVICES
-00C012 NETSPAN CORPORATION
-00C013 NETRIX
-00C014 TELEMATICS CALABASAS INT'L,INC
-00C015 NEW MEDIA CORPORATION
-00C016 ELECTRONIC THEATRE CONTROLS
-00C017 FORTE NETWORKS
-00C018 LANART CORPORATION
-00C019 LEAP TECHNOLOGY, INC.
-00C01A COROMETRICS MEDICAL SYSTEMS
-00C01B SOCKET COMMUNICATIONS, INC.
-00C01C INTERLINK COMMUNICATIONS LTD.
-00C01D GRAND JUNCTION NETWORKS, INC.
-00C01E LA FRANCAISE DES JEUX
-00C01F S.E.R.C.E.L.
-00C020 ARCO ELECTRONIC, CONTROL LTD.
-00C021 NETEXPRESS
-00C022 LASERMASTER TECHNOLOGIES, INC.
-00C023 TUTANKHAMON ELECTRONICS
-00C024 EDEN SISTEMAS DE COMPUTACAO SA
-00C025 DATAPRODUCTS CORPORATION
-00C026 LANS TECHNOLOGY CO., LTD.
-00C027 CIPHER SYSTEMS, INC.
-00C028 JASCO CORPORATION
-00C029 Nexans Deutschland AG - ANS
-00C02A OHKURA ELECTRIC CO., LTD.
-00C02B GERLOFF GESELLSCHAFT FUR
-00C02C CENTRUM COMMUNICATIONS, INC.
-00C02D FUJI PHOTO FILM CO., LTD.
-00C02E NETWIZ
-00C02F OKUMA CORPORATION
-00C030 INTEGRATED ENGINEERING B. V.
-00C031 DESIGN RESEARCH SYSTEMS, INC.
-00C032 I-CUBED LIMITED
-00C033 TELEBIT COMMUNICATIONS APS
-00C034 TRANSACTION NETWORK
-00C035 QUINTAR COMPANY
-00C036 RAYTECH ELECTRONIC CORP.
-00C037 DYNATEM
-00C038 RASTER IMAGE PROCESSING SYSTEM
-00C039 TDK SEMICONDUCTOR CORPORATION
-00C03A MEN-MIKRO ELEKTRONIK GMBH
-00C03B MULTIACCESS COMPUTING CORP.
-00C03C TOWER TECH S.R.L.
-00C03D WIESEMANN & THEIS GMBH
-00C03E FA. GEBR. HELLER GMBH
-00C03F STORES AUTOMATED SYSTEMS, INC.
-00C040 ECCI
-00C041 DIGITAL TRANSMISSION SYSTEMS
-00C042 DATALUX CORP.
-00C043 STRATACOM
-00C044 EMCOM CORPORATION
-00C045 ISOLATION SYSTEMS, LTD.
-00C046 KEMITRON LTD.
-00C047 UNIMICRO SYSTEMS, INC.
-00C048 BAY TECHNICAL ASSOCIATES
-00C049 U.S. ROBOTICS, INC.
-00C04A GROUP 2000 AG
-00C04B CREATIVE MICROSYSTEMS
-00C04C DEPARTMENT OF FOREIGN AFFAIRS
-00C04D MITEC, INC.
-00C04E COMTROL CORPORATION
-00C04F DELL COMPUTER CORPORATION
-00C050 TOYO DENKI SEIZO K.K.
-00C051 ADVANCED INTEGRATION RESEARCH
-00C052 BURR-BROWN
-00C053 DAVOX CORPORATION
-00C054 NETWORK PERIPHERALS, LTD.
-00C055 MODULAR COMPUTING TECHNOLOGIES
-00C056 SOMELEC
-00C057 MYCO ELECTRONICS
-00C058 DATAEXPERT CORP.
-00C059 NIPPON DENSO CO., LTD.
-00C05A SEMAPHORE COMMUNICATIONS CORP.
-00C05B NETWORKS NORTHWEST, INC.
-00C05C ELONEX PLC
-00C05D L&N TECHNOLOGIES
-00C05E VARI-LITE, INC.
-00C05F FINE-PAL COMPANY LIMITED
-00C060 ID SCANDINAVIA AS
-00C061 SOLECTEK CORPORATION
-00C062 IMPULSE TECHNOLOGY
-00C063 MORNING STAR TECHNOLOGIES, INC
-00C064 GENERAL DATACOMM IND. INC.
-00C065 SCOPE COMMUNICATIONS, INC.
-00C066 DOCUPOINT, INC.
-00C067 UNITED BARCODE INDUSTRIES
-00C068 PHILIP DRAKE ELECTRONICS LTD.
-00C069 Axxcelera Broadband Wireless
-00C06A ZAHNER-ELEKTRIK GMBH & CO. KG
-00C06B OSI PLUS CORPORATION
-00C06C SVEC COMPUTER CORP.
-00C06D BOCA RESEARCH, INC.
-00C06E HAFT TECHNOLOGY, INC.
-00C06F KOMATSU LTD.
-00C070 SECTRA SECURE-TRANSMISSION AB
-00C071 AREANEX COMMUNICATIONS, INC.
-00C072 KNX LTD.
-00C073 XEDIA CORPORATION
-00C074 TOYODA AUTOMATIC LOOM
-00C075 XANTE CORPORATION
-00C076 I-DATA INTERNATIONAL A-S
-00C077 DAEWOO TELECOM LTD.
-00C078 COMPUTER SYSTEMS ENGINEERING
-00C079 FONSYS CO.,LTD.
-00C07A PRIVA B.V.
-00C07B ASCEND COMMUNICATIONS, INC.
-00C07C HIGHTECH INFORMATION
-00C07D RISC DEVELOPMENTS LTD.
-00C07E KUBOTA CORPORATION ELECTRONIC
-00C07F NUPON COMPUTING CORP.
-00C080 NETSTAR, INC.
-00C081 METRODATA LTD.
-00C082 MOORE PRODUCTS CO.
-00C083 TRACE MOUNTAIN PRODUCTS, INC.
-00C084 DATA LINK CORP. LTD.
-00C085 ELECTRONICS FOR IMAGING, INC.
-00C086 THE LYNK CORPORATION
-00C087 UUNET TECHNOLOGIES, INC.
-00C088 EKF ELEKTRONIK GMBH
-00C089 TELINDUS DISTRIBUTION
-00C08A LAUTERBACH DATENTECHNIK GMBH
-00C08B RISQ MODULAR SYSTEMS, INC.
-00C08C PERFORMANCE TECHNOLOGIES, INC.
-00C08D TRONIX PRODUCT DEVELOPMENT
-00C08E NETWORK INFORMATION TECHNOLOGY
-00C08F MATSUSHITA ELECTRIC WORKS, LTD
-00C090 PRAIM S.R.L.
-00C091 JABIL CIRCUIT, INC.
-00C092 MENNEN MEDICAL INC.
-00C093 ALTA RESEARCH CORP.
-00C094 VMX INC.
-00C095 ZNYX
-00C096 TAMURA CORPORATION
-00C097 ARCHIPEL SA
-00C098 CHUNTEX ELECTRONIC CO., LTD.
-00C099 YOSHIKI INDUSTRIAL CO.,LTD.
-00C09A PHOTONICS CORPORATION
-00C09B RELIANCE COMM/TEC, R-TEC
-00C09C TOA ELECTRONIC LTD.
-00C09D DISTRIBUTED SYSTEMS INT'L, INC
-00C09E CACHE COMPUTERS, INC.
-00C09F QUANTA COMPUTER, INC.
-00C0A0 ADVANCE MICRO RESEARCH, INC.
-00C0A1 TOKYO DENSHI SEKEI CO.
-00C0A2 INTERMEDIUM A/S
-00C0A3 DUAL ENTERPRISES CORPORATION
-00C0A4 UNIGRAF OY
-00C0A5 DICKENS DATA SYSTEMS
-00C0A6 EXICOM AUSTRALIA PTY. LTD
-00C0A7 SEEL LTD.
-00C0A8 GVC CORPORATION
-00C0A9 BARRON MCCANN LTD.
-00C0AA SILICON VALLEY COMPUTER
-00C0AB Telco Systems, Inc.
-00C0AC GAMBIT COMPUTER COMMUNICATIONS
-00C0AD MARBEN COMMUNICATION SYSTEMS
-00C0AE TOWERCOM CO. INC. DBA PC HOUSE
-00C0AF TEKLOGIX INC.
-00C0B0 GCC TECHNOLOGIES,INC.
-00C0B1 GENIUS NET CO.
-00C0B2 NORAND CORPORATION
-00C0B3 COMSTAT DATACOMM CORPORATION
-00C0B4 MYSON TECHNOLOGY, INC.
-00C0B5 CORPORATE NETWORK SYSTEMS,INC.
-00C0B6 Snap Appliance, Inc.
-00C0B7 AMERICAN POWER CONVERSION CORP
-00C0B8 FRASER'S HILL LTD.
-00C0B9 FUNK SOFTWARE, INC.
-00C0BA NETVANTAGE
-00C0BB FORVAL CREATIVE, INC.
-00C0BC TELECOM AUSTRALIA/CSSC
-00C0BD INEX TECHNOLOGIES, INC.
-00C0BE ALCATEL - SEL
-00C0BF TECHNOLOGY CONCEPTS, LTD.
-00C0C0 SHORE MICROSYSTEMS, INC.
-00C0C1 QUAD/GRAPHICS, INC.
-00C0C2 INFINITE NETWORKS LTD.
-00C0C3 ACUSON COMPUTED SONOGRAPHY
-00C0C4 COMPUTER OPERATIONAL
-00C0C5 SID INFORMATICA
-00C0C6 PERSONAL MEDIA CORP.
-00C0C7 SPARKTRUM MICROSYSTEMS, INC.
-00C0C8 MICRO BYTE PTY. LTD.
-00C0C9 ELSAG BAILEY PROCESS
-00C0CA ALFA, INC.
-00C0CB CONTROL TECHNOLOGY CORPORATION
-00C0CC TELESCIENCES CO SYSTEMS, INC.
-00C0CD COMELTA, S.A.
-00C0CE CEI SYSTEMS & ENGINEERING PTE
-00C0CF IMATRAN VOIMA OY
-00C0D0 RATOC SYSTEM INC.
-00C0D1 COMTREE TECHNOLOGY CORPORATION
-00C0D2 SYNTELLECT, INC.
-00C0D3 OLYMPUS IMAGE SYSTEMS, INC.
-00C0D4 AXON NETWORKS, INC.
-00C0D5 QUANCOM ELECTRONIC GMBH
-00C0D6 J1 SYSTEMS, INC.
-00C0D7 TAIWAN TRADING CENTER DBA
-00C0D8 UNIVERSAL DATA SYSTEMS
-00C0D9 QUINTE NETWORK CONFIDENTIALITY
-00C0DA NICE SYSTEMS LTD.
-00C0DB IPC CORPORATION (PTE) LTD.
-00C0DC EOS TECHNOLOGIES, INC.
-00C0DD QLogic Corporation
-00C0DE ZCOMM, INC.
-00C0DF KYE Systems Corp.
-00C0E0 DSC COMMUNICATION CORP.
-00C0E1 SONIC SOLUTIONS
-00C0E2 CALCOMP, INC.
-00C0E3 OSITECH COMMUNICATIONS, INC.
-00C0E4 SIEMENS BUILDING
-00C0E5 GESPAC, S.A.
-00C0E6 Verilink Corporation
-00C0E7 FIBERDATA AB
-00C0E8 PLEXCOM, INC.
-00C0E9 OAK SOLUTIONS, LTD.
-00C0EA ARRAY TECHNOLOGY LTD.
-00C0EB SEH COMPUTERTECHNIK GMBH
-00C0EC DAUPHIN TECHNOLOGY
-00C0ED US ARMY ELECTRONIC
-00C0EE KYOCERA CORPORATION
-00C0EF ABIT CORPORATION
-00C0F0 KINGSTON TECHNOLOGY CORP.
-00C0F1 SHINKO ELECTRIC CO., LTD.
-00C0F2 TRANSITION NETWORKS
-00C0F3 NETWORK COMMUNICATIONS CORP.
-00C0F4 INTERLINK SYSTEM CO., LTD.
-00C0F5 METACOMP, INC.
-00C0F6 CELAN TECHNOLOGY INC.
-00C0F7 ENGAGE COMMUNICATION, INC.
-00C0F8 ABOUT COMPUTING INC.
-00C0F9 HARRIS AND JEFFRIES, INC.
-00C0FA CANARY COMMUNICATIONS, INC.
-00C0FB ADVANCED TECHNOLOGY LABS
-00C0FC ELASTIC REALITY, INC.
-00C0FD PROSUM
-00C0FE APTEC COMPUTER SYSTEMS, INC.
-00C0FF DOT HILL SYSTEMS CORPORATION
-00CBBD Cambridge Broadband Ltd.
-00CF1C COMMUNICATION MACHINERY CORP.
-00D000 FERRAN SCIENTIFIC, INC.
-00D001 VST TECHNOLOGIES, INC.
-00D002 DITECH CORPORATION
-00D003 COMDA ENTERPRISES CORP.
-00D004 PENTACOM LTD.
-00D005 ZHS ZEITMANAGEMENTSYSTEME
-00D006 CISCO SYSTEMS, INC.
-00D007 MIC ASSOCIATES, INC.
-00D008 MACTELL CORPORATION
-00D009 HSING TECH. ENTERPRISE CO. LTD
-00D00A LANACCESS TELECOM S.A.
-00D00B RHK TECHNOLOGY, INC.
-00D00C SNIJDER MICRO SYSTEMS
-00D00D MICROMERITICS INSTRUMENT
-00D00E PLURIS, INC.
-00D00F SPEECH DESIGN GMBH
-00D010 CONVERGENT NETWORKS, INC.
-00D011 PRISM VIDEO, INC.
-00D012 GATEWORKS CORP.
-00D013 PRIMEX AEROSPACE COMPANY
-00D014 ROOT, INC.
-00D015 UNIVEX MICROTECHNOLOGY CORP.
-00D016 SCM MICROSYSTEMS, INC.
-00D017 SYNTECH INFORMATION CO., LTD.
-00D018 QWES. COM, INC.
-00D019 DAINIPPON SCREEN CORPORATE
-00D01A URMET SUD S.P.A.
-00D01B MIMAKI ENGINEERING CO., LTD.
-00D01C SBS TECHNOLOGIES,
-00D01D FURUNO ELECTRIC CO., LTD.
-00D01E PINGTEL CORP.
-00D01F CTAM PTY. LTD.
-00D020 AIM SYSTEM, INC.
-00D021 REGENT ELECTRONICS CORP.
-00D022 INCREDIBLE TECHNOLOGIES, INC.
-00D023 INFORTREND TECHNOLOGY, INC.
-00D024 Cognex Corporation
-00D025 XROSSTECH, INC.
-00D026 HIRSCHMANN AUSTRIA GMBH
-00D027 APPLIED AUTOMATION, INC.
-00D028 OMNEON VIDEO NETWORKS
-00D029 WAKEFERN FOOD CORPORATION
-00D02A Voxent Systems Ltd.
-00D02B JETCELL, INC.
-00D02C CAMPBELL SCIENTIFIC, INC.
-00D02D ADEMCO
-00D02E COMMUNICATION AUTOMATION CORP.
-00D02F VLSI TECHNOLOGY INC.
-00D030 SAFETRAN SYSTEMS CORP.
-00D031 INDUSTRIAL LOGIC CORPORATION
-00D032 YANO ELECTRIC CO., LTD.
-00D033 DALIAN DAXIAN NETWORK
-00D034 ORMEC SYSTEMS CORP.
-00D035 BEHAVIOR TECH. COMPUTER CORP.
-00D036 TECHNOLOGY ATLANTA CORP.
-00D037 PHILIPS-DVS-LO BDR
-00D038 FIVEMERE, LTD.
-00D039 UTILICOM, INC.
-00D03A ZONEWORX, INC.
-00D03B VISION PRODUCTS PTY. LTD.
-00D03C Vieo, Inc.
-00D03D GALILEO TECHNOLOGY, LTD.
-00D03E ROCKETCHIPS, INC.
-00D03F AMERICAN COMMUNICATION
-00D040 SYSMATE CO., LTD.
-00D041 AMIGO TECHNOLOGY CO., LTD.
-00D042 MAHLO GMBH & CO. UG
-00D043 ZONAL RETAIL DATA SYSTEMS
-00D044 ALIDIAN NETWORKS, INC.
-00D045 KVASER AB
-00D046 DOLBY LABORATORIES, INC.
-00D047 XN TECHNOLOGIES
-00D048 ECTON, INC.
-00D049 IMPRESSTEK CO., LTD.
-00D04A PRESENCE TECHNOLOGY GMBH
-00D04B LA CIE GROUP S.A.
-00D04C EUROTEL TELECOM LTD.
-00D04D DIV OF RESEARCH & STATISTICS
-00D04E LOGIBAG
-00D04F BITRONICS, INC.
-00D050 ISKRATEL
-00D051 O2 MICRO, INC.
-00D052 ASCEND COMMUNICATIONS, INC.
-00D053 CONNECTED SYSTEMS
-00D054 SAS INSTITUTE INC.
-00D055 KATHREIN-WERKE KG
-00D056 SOMAT CORPORATION
-00D057 ULTRAK, INC.
-00D058 CISCO SYSTEMS, INC.
-00D059 AMBIT MICROSYSTEMS CORP.
-00D05A SYMBIONICS, LTD.
-00D05B ACROLOOP MOTION CONTROL
-00D05C TECHNOTREND SYSTEMTECHNIK GMBH
-00D05D INTELLIWORXX, INC.
-00D05E STRATABEAM TECHNOLOGY, INC.
-00D05F VALCOM, INC.
-00D060 PANASONIC EUROPEAN
-00D061 TREMON ENTERPRISES CO., LTD.
-00D062 DIGIGRAM
-00D063 CISCO SYSTEMS, INC.
-00D064 MULTITEL
-00D065 TOKO ELECTRIC
-00D066 WINTRISS ENGINEERING CORP.
-00D067 CAMPIO COMMUNICATIONS
-00D068 IWILL CORPORATION
-00D069 TECHNOLOGIC SYSTEMS
-00D06A LINKUP SYSTEMS CORPORATION
-00D06B SR TELECOM INC.
-00D06C SHAREWAVE, INC.
-00D06D ACRISON, INC.
-00D06E TRENDVIEW RECORDERS LTD.
-00D06F KMC CONTROLS
-00D070 LONG WELL ELECTRONICS CORP.
-00D071 ECHELON CORP.
-00D072 BROADLOGIC
-00D073 ACN ADVANCED COMMUNICATIONS
-00D074 TAQUA SYSTEMS, INC.
-00D075 ALARIS MEDICAL SYSTEMS, INC.
-00D076 MERRILL LYNCH & CO., INC.
-00D077 LUCENT TECHNOLOGIES
-00D078 ELTEX OF SWEDEN AB
-00D079 CISCO SYSTEMS, INC.
-00D07A AMAQUEST COMPUTER CORP.
-00D07B COMCAM INTERNATIONAL LTD.
-00D07C KOYO ELECTRONICS INC. CO.,LTD.
-00D07D COSINE COMMUNICATIONS
-00D07E KEYCORP LTD.
-00D07F STRATEGY & TECHNOLOGY, LIMITED
-00D080 EXABYTE CORPORATION
-00D081 REAL TIME DEVICES USA, INC.
-00D082 IOWAVE INC.
-00D083 INVERTEX, INC.
-00D084 NEXCOMM SYSTEMS, INC.
-00D085 OTIS ELEVATOR COMPANY
-00D086 FOVEON, INC.
-00D087 MICROFIRST INC.
-00D088 Terayon Communications Systems
-00D089 DYNACOLOR, INC.
-00D08A PHOTRON USA
-00D08B ADVA Limited
-00D08C GENOA TECHNOLOGY, INC.
-00D08D PHOENIX GROUP, INC.
-00D08E NVISION INC.
-00D08F ARDENT TECHNOLOGIES, INC.
-00D090 CISCO SYSTEMS, INC.
-00D091 SMARTSAN SYSTEMS, INC.
-00D092 GLENAYRE WESTERN MULTIPLEX
-00D093 TQ - COMPONENTS GMBH
-00D094 TIMELINE VISTA, INC.
-00D095 XYLAN CORPORATION
-00D096 3COM EUROPE LTD.
-00D097 CISCO SYSTEMS, INC.
-00D098 Photon Dynamics Canada Inc.
-00D099 ELCARD OY
-00D09A FILANET CORPORATION
-00D09B SPECTEL LTD.
-00D09C KAPADIA COMMUNICATIONS
-00D09D VERIS INDUSTRIES
-00D09E 2WIRE, INC.
-00D09F NOVTEK TEST SYSTEMS
-00D0A0 MIPS DENMARK
-00D0A1 OSKAR VIERLING GMBH + CO. KG
-00D0A2 INTEGRATED DEVICE
-00D0A3 VOCAL DATA, INC.
-00D0A4 ALANTRO COMMUNICATIONS
-00D0A5 AMERICAN ARIUM
-00D0A6 LANBIRD TECHNOLOGY CO., LTD.
-00D0A7 TOKYO SOKKI KENKYUJO CO., LTD.
-00D0A8 NETWORK ENGINES, INC.
-00D0A9 SHINANO KENSHI CO., LTD.
-00D0AA CHASE COMMUNICATIONS
-00D0AB DELTAKABEL TELECOM CV
-00D0AC GRAYSON WIRELESS
-00D0AD TL INDUSTRIES
-00D0AE ORESIS COMMUNICATIONS, INC.
-00D0AF CUTLER-HAMMER, INC.
-00D0B0 BITSWITCH LTD.
-00D0B1 OMEGA ELECTRONICS SA
-00D0B2 XIOTECH CORPORATION
-00D0B3 DRS FLIGHT SAFETY AND
-00D0B4 KATSUJIMA CO., LTD.
-00D0B5 IPricot formerly DotCom
-00D0B6 CRESCENT NETWORKS, INC.
-00D0B7 INTEL CORPORATION
-00D0B8 IOMEGA CORP.
-00D0B9 MICROTEK INTERNATIONAL, INC.
-00D0BA CISCO SYSTEMS, INC.
-00D0BB CISCO SYSTEMS, INC.
-00D0BC CISCO SYSTEMS, INC.
-00D0BD SICAN GMBH
-00D0BE EMUTEC INC.
-00D0BF PIVOTAL TECHNOLOGIES
-00D0C0 CISCO SYSTEMS, INC.
-00D0C1 HARMONIC DATA SYSTEMS, LTD.
-00D0C2 BALTHAZAR TECHNOLOGY AB
-00D0C3 VIVID TECHNOLOGY PTE, LTD.
-00D0C4 TERATECH CORPORATION
-00D0C5 COMPUTATIONAL SYSTEMS, INC.
-00D0C6 THOMAS & BETTS CORP.
-00D0C7 PATHWAY, INC.
-00D0C8 I/O CONSULTING A/S
-00D0C9 ADVANTECH CO., LTD.
-00D0CA INTRINSYC SOFTWARE INC.
-00D0CB DASAN CO., LTD.
-00D0CC TECHNOLOGIES LYRE INC.
-00D0CD ATAN TECHNOLOGY INC.
-00D0CE ASYST ELECTRONIC
-00D0CF MORETON BAY
-00D0D0 ZHONGXING TELECOM LTD.
-00D0D1 SIROCCO SYSTEMS, INC.
-00D0D2 EPILOG CORPORATION
-00D0D3 CISCO SYSTEMS, INC.
-00D0D4 V-BITS, INC.
-00D0D5 GRUNDIG AG
-00D0D6 AETHRA TELECOMUNICAZIONI
-00D0D7 B2C2, INC.
-00D0D8 3Com Corporation
-00D0D9 DEDICATED MICROCOMPUTERS
-00D0DA TAICOM DATA SYSTEMS CO., LTD.
-00D0DB MCQUAY INTERNATIONAL
-00D0DC MODULAR MINING SYSTEMS, INC.
-00D0DD SUNRISE TELECOM, INC.
-00D0DE PHILIPS MULTIMEDIA NETWORK
-00D0DF KUZUMI ELECTRONICS, INC.
-00D0E0 DOOIN ELECTRONICS CO.
-00D0E1 AVIONITEK ISRAEL INC.
-00D0E2 MRT MICRO, INC.
-00D0E3 ELE-CHEM ENGINEERING CO., LTD.
-00D0E4 CISCO SYSTEMS, INC.
-00D0E5 SOLIDUM SYSTEMS CORP.
-00D0E6 IBOND INC.
-00D0E7 VCON TELECOMMUNICATION LTD.
-00D0E8 MAC SYSTEM CO., LTD.
-00D0E9 ADVANTAGE CENTURY
-00D0EA NEXTONE COMMUNICATIONS, INC.
-00D0EB LIGHTERA NETWORKS, INC.
-00D0EC NAKAYO TELECOMMUNICATIONS, INC
-00D0ED XIOX
-00D0EE DICTAPHONE CORPORATION
-00D0EF IGT
-00D0F0 CONVISION TECHNOLOGY GMBH
-00D0F1 SEGA ENTERPRISES, LTD.
-00D0F2 MONTEREY NETWORKS
-00D0F3 SOLARI DI UDINE SPA
-00D0F4 CARINTHIAN TECH INSTITUTE
-00D0F5 ORANGE MICRO, INC.
-00D0F6 Alcatel Canada
-00D0F7 NEXT NETS CORPORATION
-00D0F8 FUJIAN STAR TERMINAL
-00D0F9 ACUTE COMMUNICATIONS CORP.
-00D0FA RACAL GUARDATA
-00D0FB TEK MICROSYSTEMS, INCORPORATED
-00D0FC GRANITE MICROSYSTEMS
-00D0FD OPTIMA TELE.COM, INC.
-00D0FE ASTRAL POINT
-00D0FF CISCO SYSTEMS, INC.
-00DD00 UNGERMANN-BASS INC.
-00DD01 UNGERMANN-BASS INC.
-00DD02 UNGERMANN-BASS INC.
-00DD03 UNGERMANN-BASS INC.
-00DD04 UNGERMANN-BASS INC.
-00DD05 UNGERMANN-BASS INC.
-00DD06 UNGERMANN-BASS INC.
-00DD07 UNGERMANN-BASS INC.
-00DD08 UNGERMANN-BASS INC.
-00DD09 UNGERMANN-BASS INC.
-00DD0A UNGERMANN-BASS INC.
-00DD0B UNGERMANN-BASS INC.
-00DD0C UNGERMANN-BASS INC.
-00DD0D UNGERMANN-BASS INC.
-00DD0E UNGERMANN-BASS INC.
-00DD0F UNGERMANN-BASS INC.
-00E000 FUJITSU, LTD
-00E001 STRAND LIGHTING LIMITED
-00E002 CROSSROADS SYSTEMS, INC.
-00E003 NOKIA WIRELESS BUSINESS COMMUN
-00E004 PMC-SIERRA, INC.
-00E005 TECHNICAL CORP.
-00E006 SILICON INTEGRATED SYS. CORP.
-00E007 NETWORK ALCHEMY LTD.
-00E008 AMAZING CONTROLS! INC.
-00E009 MARATHON TECHNOLOGIES CORP.
-00E00A DIBA, INC.
-00E00B ROOFTOP COMMUNICATIONS CORP.
-00E00C MOTOROLA
-00E00D RADIANT SYSTEMS
-00E00E AVALON IMAGING SYSTEMS, INC.
-00E00F SHANGHAI BAUD DATA
-00E010 HESS SB-AUTOMATENBAU GmbH
-00E011 UNIDEN SAN DIEGO R&D CENTER, INC.
-00E012 PLUTO TECHNOLOGIES INTERNATIONAL INC.
-00E013 EASTERN ELECTRONIC CO., LTD.
-00E014 CISCO SYSTEMS, INC.
-00E015 HEIWA CORPORATION
-00E016 RAPID CITY COMMUNICATIONS
-00E017 EXXACT GmbH
-00E018 ASUSTEK COMPUTER INC.
-00E019 ING. GIORDANO ELETTRONICA
-00E01A COMTEC SYSTEMS. CO., LTD.
-00E01B SPHERE COMMUNICATIONS, INC.
-00E01C MOBILITY ELECTRONICSY
-00E01D WebTV NETWORKS, INC.
-00E01E CISCO SYSTEMS, INC.
-00E01F AVIDIA Systems, Inc.
-00E020 TECNOMEN OY
-00E021 FREEGATE CORP.
-00E022 MediaLight, Inc.
-00E023 TELRAD
-00E024 GADZOOX NETWORKS
-00E025 dit CO., LTD.
-00E026 EASTMAN KODAK CO.
-00E027 DUX, INC.
-00E028 APTIX CORPORATION
-00E029 STANDARD MICROSYSTEMS CORP.
-00E02A TANDBERG TELEVISION AS
-00E02B EXTREME NETWORKS
-00E02C AST COMPUTER
-00E02D InnoMediaLogic, Inc.
-00E02E SPC ELECTRONICS CORPORATION
-00E02F MCNS HOLDINGS, L.P.
-00E030 MELITA INTERNATIONAL CORP.
-00E031 HAGIWARA ELECTRIC CO., LTD.
-00E032 MISYS FINANCIAL SYSTEMS, LTD.
-00E033 E.E.P.D. GmbH
-00E034 CISCO SYSTEMS, INC.
-00E035 LOUGHBOROUGH SOUND IMAGES, PLC
-00E036 PIONEER CORPORATION
-00E037 CENTURY CORPORATION
-00E038 PROXIMA CORPORATION
-00E039 PARADYNE CORP.
-00E03A CABLETRON SYSTEMS, INC.
-00E03B PROMINET CORPORATION
-00E03C AdvanSys
-00E03D FOCON ELECTRONIC SYSTEMS A/S
-00E03E ALFATECH, INC.
-00E03F JATON CORPORATION
-00E040 DeskStation Technology, Inc.
-00E041 CSPI
-00E042 Pacom Systems Ltd.
-00E043 VitalCom
-00E044 LSICS CORPORATION
-00E045 TOUCHWAVE, INC.
-00E046 BENTLY NEVADA CORP.
-00E047 INFOCUS SYSTEMS
-00E048 SDL COMMUNICATIONS, INC.
-00E049 MICROWI ELECTRONIC GmbH
-00E04A ENHANCED MESSAGING SYSTEMS, INC
-00E04B JUMP INDUSTRIELLE COMPUTERTECHNIK GmbH
-00E04C REALTEK SEMICONDUCTOR CORP.
-00E04D INTERNET INITIATIVE JAPAN, INC
-00E04E SANYO DENKI CO., LTD.
-00E04F CISCO SYSTEMS, INC.
-00E050 EXECUTONE INFORMATION SYSTEMS, INC.
-00E051 TALX CORPORATION
-00E052 FOUNDRY NETWORKS, INC.
-00E053 CELLPORT LABS, INC.
-00E054 KODAI HITEC CO., LTD.
-00E055 INGENIERIA ELECTRONICA COMERCIAL INELCOM S.A.
-00E056 HOLONTECH CORPORATION
-00E057 HAN MICROTELECOM. CO., LTD.
-00E058 PHASE ONE DENMARK A/S
-00E059 CONTROLLED ENVIRONMENTS, LTD.
-00E05A GALEA NETWORK SECURITY
-00E05B WEST END SYSTEMS CORP.
-00E05C MATSUSHITA KOTOBUKI ELECTRONICS INDUSTRIES, LTD.
-00E05D UNITEC CO., LTD.
-00E05E JAPAN AVIATION ELECTRONICS INDUSTRY, LTD.
-00E05F e-Net, Inc.
-00E060 SHERWOOD
-00E061 EdgePoint Networks, Inc.
-00E062 HOST ENGINEERING
-00E063 CABLETRON - YAGO SYSTEMS, INC.
-00E064 SAMSUNG ELECTRONICS
-00E065 OPTICAL ACCESS INTERNATIONAL
-00E066 ProMax Systems, Inc.
-00E067 eac AUTOMATION-CONSULTING GmbH
-00E068 MERRIMAC SYSTEMS INC.
-00E069 JAYCOR
-00E06A KAPSCH AG
-00E06B W&G SPECIAL PRODUCTS
-00E06C AEP Systems International Ltd
-00E06D COMPUWARE CORPORATION
-00E06E FAR SYSTEMS S.p.A.
-00E06F Terayon Communications Systems
-00E070 DH TECHNOLOGY
-00E071 EPIS MICROCOMPUTER
-00E072 LYNK
-00E073 NATIONAL AMUSEMENT NETWORK, INC.
-00E074 TIERNAN COMMUNICATIONS, INC.
-00E075 Verilink Corporation
-00E076 DEVELOPMENT CONCEPTS, INC.
-00E077 WEBGEAR, INC.
-00E078 BERKELEY NETWORKS
-00E079 A.T.N.R.
-00E07A MIKRODIDAKT AB
-00E07B BAY NETWORKS
-00E07C METTLER-TOLEDO, INC.
-00E07D NETRONIX, INC.
-00E07E WALT DISNEY IMAGINEERING
-00E07F LOGISTISTEM s.r.l.
-00E080 CONTROL RESOURCES CORPORATION
-00E081 TYAN COMPUTER CORP.
-00E082 ANERMA
-00E083 JATO TECHNOLOGIES, INC.
-00E084 COMPULITE R&D
-00E085 GLOBAL MAINTECH, INC.
-00E086 CYBEX COMPUTER PRODUCTS
-00E087 LeCroy - Networking Productions Division
-00E088 LTX CORPORATION
-00E089 ION Networks, Inc.
-00E08A GEC AVERY, LTD.
-00E08B QLogic Corp.
-00E08C NEOPARADIGM LABS, INC.
-00E08D PRESSURE SYSTEMS, INC.
-00E08E UTSTARCOM
-00E08F CISCO SYSTEMS, INC.
-00E090 BECKMAN LAB. AUTOMATION DIV.
-00E091 LG ELECTRONICS, INC.
-00E092 ADMTEK INCORPORATED
-00E093 ACKFIN NETWORKS
-00E094 OSAI SRL
-00E095 ADVANCED-VISION TECHNOLGIES CORP.
-00E096 SHIMADZU CORPORATION
-00E097 CARRIER ACCESS CORPORATION
-00E098 AboCom Systems, Inc.
-00E099 SAMSON AG
-00E09A POSITRON INDUSTRIES, INC.
-00E09B ENGAGE NETWORKS, INC.
-00E09C MII
-00E09D SARNOFF CORPORATION
-00E09E QUANTUM CORPORATION
-00E09F PIXEL VISION
-00E0A0 WILTRON CO.
-00E0A1 HIMA PAUL HILDEBRANDT GmbH Co. KG
-00E0A2 MICROSLATE INC.
-00E0A3 CISCO SYSTEMS, INC.
-00E0A4 ESAOTE S.p.A.
-00E0A5 ComCore Semiconductor, Inc.
-00E0A6 TELOGY NETWORKS, INC.
-00E0A7 IPC INFORMATION SYSTEMS, INC.
-00E0A8 SAT GmbH & Co.
-00E0A9 FUNAI ELECTRIC CO., LTD.
-00E0AA ELECTROSONIC LTD.
-00E0AB DIMAT S.A.
-00E0AC MIDSCO, INC.
-00E0AD EES TECHNOLOGY, LTD.
-00E0AE XAQTI CORPORATION
-00E0AF GENERAL DYNAMICS INFORMATION SYSTEMS
-00E0B0 CISCO SYSTEMS, INC.
-00E0B1 PACKET ENGINES, INC.
-00E0B2 TELMAX COMMUNICATIONS CORP.
-00E0B3 EtherWAN Systems, Inc.
-00E0B4 TECHNO SCOPE CO., LTD.
-00E0B5 ARDENT COMMUNICATIONS CORP.
-00E0B6 Entrada Networks
-00E0B7 PI GROUP, LTD.
-00E0B8 GATEWAY 2000
-00E0B9 BYAS SYSTEMS
-00E0BA BERGHOF AUTOMATIONSTECHNIK GmbH
-00E0BB NBX CORPORATION
-00E0BC SYMON COMMUNICATIONS, INC.
-00E0BD INTERFACE SYSTEMS, INC.
-00E0BE GENROCO INTERNATIONAL, INC.
-00E0BF TORRENT NETWORKING TECHNOLOGIES CORP.
-00E0C0 SEIWA ELECTRIC MFG. CO., LTD.
-00E0C1 MEMOREX TELEX JAPAN, LTD.
-00E0C2 NECSY S.p.A.
-00E0C3 SAKAI SYSTEM DEVELOPMENT CORP.
-00E0C4 HORNER ELECTRIC, INC.
-00E0C5 BCOM ELECTRONICS INC.
-00E0C6 LINK2IT, L.L.C.
-00E0C7 EUROTECH SRL
-00E0C8 VIRTUAL ACCESS, LTD.
-00E0C9 AutomatedLogic Corporation
-00E0CA BEST DATA PRODUCTS
-00E0CB RESON, INC.
-00E0CC HERO SYSTEMS, LTD.
-00E0CD SENSIS CORPORATION
-00E0CE ARN
-00E0CF INTEGRATED DEVICE TECHNOLOGY, INC.
-00E0D0 NETSPEED, INC.
-00E0D1 TELSIS LIMITED
-00E0D2 VERSANET COMMUNICATIONS, INC.
-00E0D3 DATENTECHNIK GmbH
-00E0D4 EXCELLENT COMPUTER
-00E0D5 ARCXEL TECHNOLOGIES, INC.
-00E0D6 COMPUTER & COMMUNICATION RESEARCH LAB.
-00E0D7 SUNSHINE ELECTRONICS, INC.
-00E0D8 LANBit Computer, Inc.
-00E0D9 TAZMO CO., LTD.
-00E0DA ASSURED ACCESS TECHNOLOGY, INC.
-00E0DB ViaVideo Communications, Inc.
-00E0DC NEXWARE CORP.
-00E0DD ZENITH ELECTRONICS CORPORATION
-00E0DE DATAX NV
-00E0DF KE KOMMUNIKATIONS-ELECTRONIK
-00E0E0 SI ELECTRONICS, LTD.
-00E0E1 G2 NETWORKS, INC.
-00E0E2 INNOVA CORP.
-00E0E3 SK-ELEKTRONIK GmbH
-00E0E4 FANUC ROBOTICS NORTH AMERICA, Inc.
-00E0E5 CINCO NETWORKS, INC.
-00E0E6 INCAA DATACOM B.V.
-00E0E7 RAYTHEON E-SYSTEMS, INC.
-00E0E8 GRETACODER Data Systems AG
-00E0E9 DATA LABS, INC.
-00E0EA INNOVAT COMMUNICATIONS, INC.
-00E0EB DIGICOM SYSTEMS, INCORPORATED
-00E0EC CELESTICA INC.
-00E0ED SILICOM, LTD.
-00E0EE MAREL HF
-00E0EF DIONEX
-00E0F0 ABLER TECHNOLOGY, INC.
-00E0F1 THAT CORPORATION
-00E0F2 ARLOTTO COMNET, INC.
-00E0F3 WebSprint Communications, Inc.
-00E0F4 INSIDE Technology A/S
-00E0F5 TELES AG
-00E0F6 DECISION EUROPE
-00E0F7 CISCO SYSTEMS, INC.
-00E0F8 DICNA CONTROL AB
-00E0F9 CISCO SYSTEMS, INC.
-00E0FA TRL TECHNOLOGY, LTD.
-00E0FB LEIGHTRONIX, INC.
-00E0FC HUAWEI TECHNOLOGIES CO., LTD.
-00E0FD A-TREND TECHNOLOGY CO., LTD.
-00E0FE CISCO SYSTEMS, INC.
-00E0FF SECURITY DYNAMICS TECHNOLOGIES, Inc.
-00E6D3 NIXDORF COMPUTER CORP.
-020701 RACAL-DATACOM
-021C7C PERQ SYSTEMS CORPORATION
-026086 LOGIC REPLACEMENT TECH. LTD.
-02608C 3COM CORPORATION
-027001 RACAL-DATACOM
-0270B0 M/A-COM INC. COMPANIES
-0270B3 DATA RECALL LTD
-029D8E CARDIAC RECORDERS INC.
-02AA3C OLIVETTI TELECOMM SPA (OLTECO)
-02BB01 OCTOTHORPE CORP.
-02C08C 3COM CORPORATION
-02CF1C COMMUNICATION MACHINERY CORP.
-02E6D3 NIXDORF COMPUTER CORPORATION
-040AE0 XMIT AG COMPUTER NETWORKS
-04E0C4 TRIUMPH-ADLER AG
-080001 COMPUTERVISION CORPORATION
-080002 BRIDGE COMMUNICATIONS INC.
-080003 ADVANCED COMPUTER COMM.
-080004 CROMEMCO INCORPORATED
-080005 SYMBOLICS INC.
-080006 SIEMENS AG
-080007 APPLE COMPUTER INC.
-080008 BOLT BERANEK AND NEWMAN INC.
-080009 HEWLETT PACKARD
-08000A NESTAR SYSTEMS INCORPORATED
-08000B UNISYS CORPORATION
-08000C MIKLYN DEVELOPMENT CO.
-08000D INTERNATIONAL COMPUTERS LTD.
-08000E NCR CORPORATION
-08000F MITEL CORPORATION
-080011 TEKTRONIX INC.
-080012 BELL ATLANTIC INTEGRATED SYST.
-080013 EXXON
-080014 EXCELAN
-080015 STC BUSINESS SYSTEMS
-080016 BARRISTER INFO SYS CORP
-080017 NATIONAL SEMICONDUCTOR
-080018 PIRELLI FOCOM NETWORKS
-080019 GENERAL ELECTRIC CORPORATION
-08001A TIARA/ 10NET
-08001B DATA GENERAL
-08001C KDD-KOKUSAI DEBNSIN DENWA CO.
-08001D ABLE COMMUNICATIONS INC.
-08001E APOLLO COMPUTER INC.
-08001F SHARP CORPORATION
-080020 SUN MICROSYSTEMS INC.
-080021 3M COMPANY
-080022 NBI INC.
-080023 Panasonic Communications Co., Ltd.
-080024 10NET COMMUNICATIONS/DCA
-080025 CONTROL DATA
-080026 NORSK DATA A.S.
-080027 CADMUS COMPUTER SYSTEMS
-080028 Texas Instruments
-080029 MEGATEK CORPORATION
-08002A MOSAIC TECHNOLOGIES INC.
-08002B DIGITAL EQUIPMENT CORPORATION
-08002C BRITTON LEE INC.
-08002D LAN-TEC INC.
-08002E METAPHOR COMPUTER SYSTEMS
-08002F PRIME COMPUTER INC.
-080030 NETWORK RESEARCH CORPORATION
-080030 CERN
-080030 ROYAL MELBOURNE INST OF TECH
-080031 LITTLE MACHINES INC.
-080032 TIGAN INCORPORATED
-080033 BAUSCH & LOMB
-080034 FILENET CORPORATION
-080035 MICROFIVE CORPORATION
-080036 INTERGRAPH CORPORATION
-080037 FUJI-XEROX CO. LTD.
-080038 CII HONEYWELL BULL
-080039 SPIDER SYSTEMS LIMITED
-08003A ORCATECH INC.
-08003B TORUS SYSTEMS LIMITED
-08003C SCHLUMBERGER WELL SERVICES
-08003D CADNETIX CORPORATIONS
-08003E CODEX CORPORATION
-08003F FRED KOSCHARA ENTERPRISES
-080040 FERRANTI COMPUTER SYS. LIMITED
-080041 RACAL-MILGO INFORMATION SYS..
-080042 JAPAN MACNICS CORP.
-080043 PIXEL COMPUTER INC.
-080044 DAVID SYSTEMS INC.
-080045 CONCURRENT COMPUTER CORP.
-080046 SONY CORPORATION LTD.
-080047 SEQUENT COMPUTER SYSTEMS INC.
-080048 EUROTHERM GAUGING SYSTEMS
-080049 UNIVATION
-08004A BANYAN SYSTEMS INC.
-08004B PLANNING RESEARCH CORP.
-08004C HYDRA COMPUTER SYSTEMS INC.
-08004D CORVUS SYSTEMS INC.
-08004E 3COM EUROPE LTD.
-08004F CYGNET SYSTEMS
-080050 DAISY SYSTEMS CORP.
-080051 EXPERDATA
-080052 INSYSTEC
-080053 MIDDLE EAST TECH. UNIVERSITY
-080055 STANFORD TELECOMM. INC.
-080056 STANFORD LINEAR ACCEL. CENTER
-080057 EVANS & SUTHERLAND
-080058 SYSTEMS CONCEPTS
-080059 A/S MYCRON
-08005A IBM CORPORATION
-08005B VTA TECHNOLOGIES INC.
-08005C FOUR PHASE SYSTEMS
-08005D GOULD INC.
-08005E COUNTERPOINT COMPUTER INC.
-08005F SABER TECHNOLOGY CORP.
-080060 INDUSTRIAL NETWORKING INC.
-080061 JAROGATE LTD.
-080062 GENERAL DYNAMICS
-080063 PLESSEY
-080064 AUTOPHON AG
-080065 GENRAD INC.
-080066 AGFA CORPORATION
-080067 COMDESIGN
-080068 RIDGE COMPUTERS
-080069 SILICON GRAPHICS INC.
-08006A ATT BELL LABORATORIES
-08006B ACCEL TECHNOLOGIES INC.
-08006C SUNTEK TECHNOLOGY INT'L
-08006D WHITECHAPEL COMPUTER WORKS
-08006E MASSCOMP
-08006F PHILIPS APELDOORN B.V.
-080070 MITSUBISHI ELECTRIC CORP.
-080071 MATRA (DSIE)
-080072 XEROX CORP UNIV GRANT PROGRAM
-080073 TECMAR INC.
-080074 CASIO COMPUTER CO. LTD.
-080075 DANSK DATA ELECTRONIK
-080076 PC LAN TECHNOLOGIES
-080077 TSL COMMUNICATIONS LTD.
-080078 ACCELL CORPORATION
-080079 THE DROID WORKS
-08007A INDATA
-08007B SANYO ELECTRIC CO. LTD.
-08007C VITALINK COMMUNICATIONS CORP.
-08007E AMALGAMATED WIRELESS(AUS) LTD
-08007F CARNEGIE-MELLON UNIVERSITY
-080080 AES DATA INC.
-080081 ,ASTECH INC.
-080082 VERITAS SOFTWARE
-080083 Seiko Instruments Inc.
-080084 TOMEN ELECTRONICS CORP.
-080085 ELXSI
-080086 KONICA MINOLTA HOLDINGS, INC.
-080087 XYPLEX
-080088 MCDATA CORPORATION
-080089 KINETICS
-08008A PERFORMANCE TECHNOLOGY
-08008B PYRAMID TECHNOLOGY CORP.
-08008C NETWORK RESEARCH CORPORATION
-08008D XYVISION INC.
-08008E TANDEM COMPUTERS
-08008F CHIPCOM CORPORATION
-080090 SONOMA SYSTEMS
-081443 UNIBRAIN S.A.
-08BBCC AK-NORD EDV VERTRIEBSGES. mbH
-10005A IBM CORPORATION
-1000E8 NATIONAL SEMICONDUCTOR
-800010 ATT BELL LABORATORIES
-A06A00 Verilink Corporation
-AA0000 DIGITAL EQUIPMENT CORPORATION
-AA0001 DIGITAL EQUIPMENT CORPORATION
-AA0002 DIGITAL EQUIPMENT CORPORATION
-AA0003 DIGITAL EQUIPMENT CORPORATION
-AA0004 DIGITAL EQUIPMENT CORPORATION
diff --git a/drivers/ieee1394/oui2c.sh b/drivers/ieee1394/oui2c.sh
deleted file mode 100644 (file)
index b9d0e8f..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/bin/sh
-
-cat <<EOF
-/* Generated file for OUI database */
-
-
-#ifdef CONFIG_IEEE1394_OUI_DB
-struct oui_list_struct {
-       int oui;
-       char *name;
-} oui_list[] = {
-EOF
-
-while read oui name; do
-       echo "  { 0x$oui, \"$name\" },"
-done
-
-cat <<EOF
-};
-
-#endif /* CONFIG_IEEE1394_OUI_DB */
-EOF
index ad2108f27a04783643b84b4b9beb663e3e6f5cdd..a77a832828c84220d6d504c9be4d55101e5754ea 100644 (file)
@@ -636,27 +636,32 @@ static int state_initialized(struct file_info *fi, struct pending_request *req)
 
        case RAW1394_REQ_SET_CARD:
                spin_lock_irqsave(&host_info_lock, flags);
-               if (req->req.misc < host_count) {
-                       list_for_each_entry(hi, &host_info_list, list) {
-                               if (!req->req.misc--)
-                                       break;
-                       }
-                       get_device(&hi->host->device);  // XXX Need to handle failure case
-                       list_add_tail(&fi->list, &hi->file_info_list);
-                       fi->host = hi->host;
-                       fi->state = connected;
-
-                       req->req.error = RAW1394_ERROR_NONE;
-                       req->req.generation = get_hpsb_generation(fi->host);
-                       req->req.misc = (fi->host->node_id << 16)
-                           | fi->host->node_count;
-                       if (fi->protocol_version > 3) {
-                               req->req.misc |=
-                                   NODEID_TO_NODE(fi->host->irm_id) << 8;
-                       }
-               } else {
+               if (req->req.misc >= host_count) {
                        req->req.error = RAW1394_ERROR_INVALID_ARG;
+                       goto out_set_card;
                }
+               list_for_each_entry(hi, &host_info_list, list)
+                       if (!req->req.misc--)
+                               break;
+               get_device(&hi->host->device); /* FIXME handle failure case */
+               list_add_tail(&fi->list, &hi->file_info_list);
+
+               /* prevent unloading of the host's low-level driver */
+               if (!try_module_get(hi->host->driver->owner)) {
+                       req->req.error = RAW1394_ERROR_ABORTED;
+                       goto out_set_card;
+               }
+               WARN_ON(fi->host);
+               fi->host = hi->host;
+               fi->state = connected;
+
+               req->req.error = RAW1394_ERROR_NONE;
+               req->req.generation = get_hpsb_generation(fi->host);
+               req->req.misc = (fi->host->node_id << 16)
+                               | fi->host->node_count;
+               if (fi->protocol_version > 3)
+                       req->req.misc |= NODEID_TO_NODE(fi->host->irm_id) << 8;
+out_set_card:
                spin_unlock_irqrestore(&host_info_lock, flags);
 
                req->req.length = 0;
@@ -2955,6 +2960,11 @@ static int raw1394_release(struct inode *inode, struct file *file)
                put_device(&fi->host->device);
        }
 
+       spin_lock_irqsave(&host_info_lock, flags);
+       if (fi->host)
+               module_put(fi->host->driver->owner);
+       spin_unlock_irqrestore(&host_info_lock, flags);
+
        kfree(fi);
 
        return 0;
index 4325aac7733d090f4708e5a0adf947d537d1e531..4edfff46b1e60a8801ef4a1a87a7598a758fd0cd 100644 (file)
@@ -51,7 +51,6 @@
  * Grep for inline FIXME comments below.
  */
 
-#include <linux/blkdev.h>
 #include <linux/compiler.h>
 #include <linux/delay.h>
 #include <linux/device.h>
@@ -304,10 +303,11 @@ static struct scsi_host_template sbp2_shost_template = {
        .use_clustering          = ENABLE_CLUSTERING,
        .cmd_per_lun             = SBP2_MAX_CMDS,
        .can_queue               = SBP2_MAX_CMDS,
-       .emulated                = 1,
        .sdev_attrs              = sbp2_sysfs_sdev_attrs,
 };
 
+/* for match-all entries in sbp2_workarounds_table */
+#define SBP2_ROM_VALUE_WILDCARD 0x1000000
 
 /*
  * List of devices with known bugs.
@@ -329,22 +329,14 @@ static const struct {
        },
        /* Initio bridges, actually only needed for some older ones */ {
                .firmware_revision      = 0x000200,
+               .model_id               = SBP2_ROM_VALUE_WILDCARD,
                .workarounds            = SBP2_WORKAROUND_INQUIRY_36,
        },
        /* Symbios bridge */ {
                .firmware_revision      = 0xa0b800,
+               .model_id               = SBP2_ROM_VALUE_WILDCARD,
                .workarounds            = SBP2_WORKAROUND_128K_MAX_TRANS,
        },
-       /*
-        * Note about the following Apple iPod blacklist entries:
-        *
-        * There are iPods (2nd gen, 3rd gen) with model_id==0.  Since our
-        * matching logic treats 0 as a wildcard, we cannot match this ID
-        * without rewriting the matching routine.  Fortunately these iPods
-        * do not feature the read_capacity bug according to one report.
-        * Read_capacity behaviour as well as model_id could change due to
-        * Apple-supplied firmware updates though.
-        */
        /* iPod 4th generation */ {
                .firmware_revision      = 0x0a2700,
                .model_id               = 0x000021,
@@ -1307,11 +1299,13 @@ static void sbp2_parse_unit_directory(struct sbp2_lu *lu,
 
        if (!(workarounds & SBP2_WORKAROUND_OVERRIDE))
                for (i = 0; i < ARRAY_SIZE(sbp2_workarounds_table); i++) {
-                       if (sbp2_workarounds_table[i].firmware_revision &&
+                       if (sbp2_workarounds_table[i].firmware_revision !=
+                           SBP2_ROM_VALUE_WILDCARD &&
                            sbp2_workarounds_table[i].firmware_revision !=
                            (firmware_revision & 0xffff00))
                                continue;
-                       if (sbp2_workarounds_table[i].model_id &&
+                       if (sbp2_workarounds_table[i].model_id !=
+                           SBP2_ROM_VALUE_WILDCARD &&
                            sbp2_workarounds_table[i].model_id != ud->model_id)
                                continue;
                        workarounds |= sbp2_workarounds_table[i].workarounds;
@@ -2017,7 +2011,6 @@ static int sbp2scsi_slave_configure(struct scsi_device *sdev)
 {
        struct sbp2_lu *lu = (struct sbp2_lu *)sdev->host->hostdata[0];
 
-       blk_queue_dma_alignment(sdev->request_queue, (512 - 1));
        sdev->use_10_for_rw = 1;
 
        if (sdev->type == TYPE_ROM)
index 598b19fc5989da426d87510031cd6e4bb105d5d4..f4d1ec00af652372b1ed37a5a5ffa2401e5dc2d8 100644 (file)
@@ -489,6 +489,9 @@ static void wakeup_dma_ir_ctx(unsigned long l)
                        reset_ir_status(d, i);
                        d->buffer_status[d->buffer_prg_assignment[i]] = VIDEO1394_BUFFER_READY;
                        do_gettimeofday(&d->buffer_time[d->buffer_prg_assignment[i]]);
+                       dma_region_sync_for_cpu(&d->dma,
+                               d->buffer_prg_assignment[i] * d->buf_size,
+                               d->buf_size);
                }
        }
 
@@ -1096,6 +1099,8 @@ static long video1394_ioctl(struct file *file,
                        DBGMSG(ohci->host->id, "Starting iso transmit DMA ctx=%d",
                               d->ctx);
                        put_timestamp(ohci, d, d->last_buffer);
+                       dma_region_sync_for_device(&d->dma,
+                               v.buffer * d->buf_size, d->buf_size);
 
                        /* Tell the controller where the first program is */
                        reg_write(ohci, d->cmdPtr,
@@ -1111,6 +1116,9 @@ static long video1394_ioctl(struct file *file,
                                      "Waking up iso transmit dma ctx=%d",
                                      d->ctx);
                                put_timestamp(ohci, d, d->last_buffer);
+                               dma_region_sync_for_device(&d->dma,
+                                       v.buffer * d->buf_size, d->buf_size);
+
                                reg_write(ohci, d->ctrlSet, 0x1000);
                        }
                }
index 9291a86ca0537f279868ded87046d69a6ad18b5f..6ebfa27e4e16edadbe3a44e803a20c264dbb916d 100644 (file)
@@ -134,14 +134,13 @@ struct ib_cq *ehca_create_cq(struct ib_device *device, int cqe,
        if (cqe >= 0xFFFFFFFF - 64 - additional_cqe)
                return ERR_PTR(-EINVAL);
 
-       my_cq = kmem_cache_alloc(cq_cache, GFP_KERNEL);
+       my_cq = kmem_cache_zalloc(cq_cache, GFP_KERNEL);
        if (!my_cq) {
                ehca_err(device, "Out of memory for ehca_cq struct device=%p",
                         device);
                return ERR_PTR(-ENOMEM);
        }
 
-       memset(my_cq, 0, sizeof(struct ehca_cq));
        memset(&param, 0, sizeof(struct ehca_alloc_cq_parms));
 
        spin_lock_init(&my_cq->spinlock);
index cfb362a1029caa979394fed9bc8fc54be60812ca..d22ab563633f0ed10c7cb476e5ebe5deec452ed0 100644 (file)
@@ -53,9 +53,8 @@ static struct ehca_mr *ehca_mr_new(void)
 {
        struct ehca_mr *me;
 
-       me = kmem_cache_alloc(mr_cache, GFP_KERNEL);
+       me = kmem_cache_zalloc(mr_cache, GFP_KERNEL);
        if (me) {
-               memset(me, 0, sizeof(struct ehca_mr));
                spin_lock_init(&me->mrlock);
        } else
                ehca_gen_err("alloc failed");
@@ -72,9 +71,8 @@ static struct ehca_mw *ehca_mw_new(void)
 {
        struct ehca_mw *me;
 
-       me = kmem_cache_alloc(mw_cache, GFP_KERNEL);
+       me = kmem_cache_zalloc(mw_cache, GFP_KERNEL);
        if (me) {
-               memset(me, 0, sizeof(struct ehca_mw));
                spin_lock_init(&me->mwlock);
        } else
                ehca_gen_err("alloc failed");
index d5345e5b3cd661a0de94104fb16bd4f1fca33c76..79d0591a80431eb487fad97590f1ecfa83f531b1 100644 (file)
@@ -50,14 +50,13 @@ struct ib_pd *ehca_alloc_pd(struct ib_device *device,
 {
        struct ehca_pd *pd;
 
-       pd = kmem_cache_alloc(pd_cache, GFP_KERNEL);
+       pd = kmem_cache_zalloc(pd_cache, GFP_KERNEL);
        if (!pd) {
                ehca_err(device, "device=%p context=%p out of memory",
                         device, context);
                return ERR_PTR(-ENOMEM);
        }
 
-       memset(pd, 0, sizeof(struct ehca_pd));
        pd->ownpid = current->tgid;
 
        /*
index 95efef921f1d9fed9543ca5b0f889af9c4f74862..df0516f2437989c2cf4d5c6faea9095de26332bf 100644 (file)
@@ -450,13 +450,12 @@ struct ib_qp *ehca_create_qp(struct ib_pd *pd,
        if (pd->uobject && udata)
                context = pd->uobject->context;
 
-       my_qp = kmem_cache_alloc(qp_cache, GFP_KERNEL);
+       my_qp = kmem_cache_zalloc(qp_cache, GFP_KERNEL);
        if (!my_qp) {
                ehca_err(pd->device, "pd=%p not enough memory to alloc qp", pd);
                return ERR_PTR(-ENOMEM);
        }
 
-       memset(my_qp, 0, sizeof(struct ehca_qp));
        memset (&parms, 0, sizeof(struct ehca_alloc_qp_parms));
        spin_lock_init(&my_qp->spinlock_s);
        spin_lock_init(&my_qp->spinlock_r);
index 0a7d1ab60e6d81832e70e037255dd0cbb27efa1b..89e37283c83689a9896b7beee38bc6491939e6de 100644 (file)
@@ -567,7 +567,7 @@ void iser_rcv_completion(struct iser_desc *rx_desc,
        opcode = hdr->opcode & ISCSI_OPCODE_MASK;
 
        if (opcode == ISCSI_OP_SCSI_CMD_RSP) {
-               itt = hdr->itt & ISCSI_ITT_MASK; /* mask out cid and age bits */
+               itt = get_itt(hdr->itt); /* mask out cid and age bits */
                if (!(itt < session->cmds_max))
                        iser_err("itt can't be matched to task!!!"
                                 "conn %p opcode %d cmds_max %d itt %d\n",
@@ -625,7 +625,7 @@ void iser_snd_completion(struct iser_desc *tx_desc)
                /* this arithmetic is legal by libiscsi dd_data allocation */
                mtask = (void *) ((long)(void *)tx_desc -
                                  sizeof(struct iscsi_mgmt_task));
-               if (mtask->hdr->itt == cpu_to_be32(ISCSI_RESERVED_TAG)) {
+               if (mtask->hdr->itt == RESERVED_ITT) {
                        struct iscsi_session *session = conn->session;
 
                        spin_lock(&conn->session->lock);
index f68dbe6f7f04634ca7bf63688555de65be85f7f0..7b7a546323cfc1c2d65fea2663d1f3f50399f78e 100644 (file)
@@ -151,7 +151,6 @@ static int ns558_isa_probe(int io)
                return -ENOMEM;
        }
 
-       memset(ns558, 0, sizeof(struct ns558));
        ns558->io = io;
        ns558->size = 1 << i;
        ns558->gameport = port;
index 4358a0a78eaa1f1e949296d82bd4e5464a344af3..c7db4032ef02e5a09f4ddd98fd93d28753c96935 100644 (file)
@@ -83,7 +83,7 @@
 
 
 struct ucb1400 {
-       ac97_t                  *ac97;
+       struct snd_ac97         *ac97;
        struct input_dev        *ts_idev;
 
        int                     irq;
index b5e7f9c7d74e6bd5bac9c0e1126259fa1700038e..63e51dd6debe2a9b279ebb1281852a606f9d3301 100644 (file)
@@ -257,10 +257,10 @@ static inline void dump_urb(enum debuglevel level, const char *tag,
                        urb->transfer_flags);
                gig_dbg(level,
                        "  transfer_buffer=0x%08lx[%d], actual_length=%d, "
-                       "bandwidth=%d, setup_packet=0x%08lx,",
+                       "setup_packet=0x%08lx,",
                        (unsigned long) urb->transfer_buffer,
                        urb->transfer_buffer_length, urb->actual_length,
-                       urb->bandwidth, (unsigned long) urb->setup_packet);
+                       (unsigned long) urb->setup_packet);
                gig_dbg(level,
                        "  start_frame=%d, number_of_packets=%d, interval=%d, "
                        "error_count=%d,",
index 458b6462f93779c489440ecce018ead677145d5c..f13de20947e0bf74f74fe6d2aa43129818e5b4f8 100644 (file)
@@ -599,19 +599,9 @@ out:
 static void if_wake(unsigned long data)
 {
        struct cardstate *cs = (struct cardstate *) data;
-       struct tty_struct *tty;
-
-       tty = cs->tty;
-       if (!tty)
-               return;
-
-       if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
-           tty->ldisc.write_wakeup) {
-               gig_dbg(DEBUG_IF, "write wakeup call");
-               tty->ldisc.write_wakeup(tty);
-       }
 
-       wake_up_interruptible(&tty->write_wait);
+       if (cs->tty)
+               tty_wakeup(cs->tty);
 }
 
 /*** interface to common ***/
index fc80afe555b9e9063229dca25739aa5b33afe29a..ea5f30d4a5a23377bd2527211081b6bd0ff3e278 100644 (file)
@@ -1261,7 +1261,6 @@ isdn_tty_flush_buffer(struct tty_struct *tty)
        }
        isdn_tty_cleanup_xmit(info);
        info->xmit_count = 0;
-       wake_up_interruptible(&tty->write_wait);
        tty_wakeup(tty);
 }
 
index b10972ed0c9f260d298f30e539cf154938cade53..099f0afd394d16cf84fee390aa8b42fe6ec22fa4 100644 (file)
@@ -62,7 +62,7 @@ static struct kvm_stats_debugfs_item {
        { "halt_exits", &kvm_stat.halt_exits },
        { "request_irq", &kvm_stat.request_irq_exits },
        { "irq_exits", &kvm_stat.irq_exits },
-       { 0, 0 }
+       { NULL, NULL }
 };
 
 static struct dentry *debugfs_dir;
@@ -205,7 +205,7 @@ static struct kvm_vcpu *vcpu_load(struct kvm *kvm, int vcpu_slot)
        mutex_lock(&vcpu->mutex);
        if (unlikely(!vcpu->vmcs)) {
                mutex_unlock(&vcpu->mutex);
-               return 0;
+               return NULL;
        }
        return kvm_arch_ops->vcpu_load(vcpu);
 }
@@ -257,9 +257,9 @@ static void kvm_free_physmem_slot(struct kvm_memory_slot *free,
        if (!dont || free->dirty_bitmap != dont->dirty_bitmap)
                vfree(free->dirty_bitmap);
 
-       free->phys_mem = 0;
+       free->phys_mem = NULL;
        free->npages = 0;
-       free->dirty_bitmap = 0;
+       free->dirty_bitmap = NULL;
 }
 
 static void kvm_free_physmem(struct kvm *kvm)
@@ -267,7 +267,7 @@ static void kvm_free_physmem(struct kvm *kvm)
        int i;
 
        for (i = 0; i < kvm->nmemslots; ++i)
-               kvm_free_physmem_slot(&kvm->memslots[i], 0);
+               kvm_free_physmem_slot(&kvm->memslots[i], NULL);
 }
 
 static void kvm_free_vcpu(struct kvm_vcpu *vcpu)
@@ -640,11 +640,11 @@ raced:
 
        /* Deallocate if slot is being removed */
        if (!npages)
-               new.phys_mem = 0;
+               new.phys_mem = NULL;
 
        /* Free page dirty bitmap if unneeded */
        if (!(new.flags & KVM_MEM_LOG_DIRTY_PAGES))
-               new.dirty_bitmap = 0;
+               new.dirty_bitmap = NULL;
 
        r = -ENOMEM;
 
@@ -799,14 +799,14 @@ struct kvm_memory_slot *gfn_to_memslot(struct kvm *kvm, gfn_t gfn)
                    && gfn < memslot->base_gfn + memslot->npages)
                        return memslot;
        }
-       return 0;
+       return NULL;
 }
 EXPORT_SYMBOL_GPL(gfn_to_memslot);
 
 void mark_page_dirty(struct kvm *kvm, gfn_t gfn)
 {
        int i;
-       struct kvm_memory_slot *memslot = 0;
+       struct kvm_memory_slot *memslot = NULL;
        unsigned long rel_gfn;
 
        for (i = 0; i < kvm->nmemslots; ++i) {
@@ -1778,6 +1778,7 @@ static long kvm_dev_ioctl(struct file *filp,
                          unsigned int ioctl, unsigned long arg)
 {
        struct kvm *kvm = filp->private_data;
+       void __user *argp = (void __user *)arg;
        int r = -EINVAL;
 
        switch (ioctl) {
@@ -1794,12 +1795,12 @@ static long kvm_dev_ioctl(struct file *filp,
                struct kvm_run kvm_run;
 
                r = -EFAULT;
-               if (copy_from_user(&kvm_run, (void *)arg, sizeof kvm_run))
+               if (copy_from_user(&kvm_run, argp, sizeof kvm_run))
                        goto out;
                r = kvm_dev_ioctl_run(kvm, &kvm_run);
                if (r < 0 &&  r != -EINTR)
                        goto out;
-               if (copy_to_user((void *)arg, &kvm_run, sizeof kvm_run)) {
+               if (copy_to_user(argp, &kvm_run, sizeof kvm_run)) {
                        r = -EFAULT;
                        goto out;
                }
@@ -1809,13 +1810,13 @@ static long kvm_dev_ioctl(struct file *filp,
                struct kvm_regs kvm_regs;
 
                r = -EFAULT;
-               if (copy_from_user(&kvm_regs, (void *)arg, sizeof kvm_regs))
+               if (copy_from_user(&kvm_regs, argp, sizeof kvm_regs))
                        goto out;
                r = kvm_dev_ioctl_get_regs(kvm, &kvm_regs);
                if (r)
                        goto out;
                r = -EFAULT;
-               if (copy_to_user((void *)arg, &kvm_regs, sizeof kvm_regs))
+               if (copy_to_user(argp, &kvm_regs, sizeof kvm_regs))
                        goto out;
                r = 0;
                break;
@@ -1824,7 +1825,7 @@ static long kvm_dev_ioctl(struct file *filp,
                struct kvm_regs kvm_regs;
 
                r = -EFAULT;
-               if (copy_from_user(&kvm_regs, (void *)arg, sizeof kvm_regs))
+               if (copy_from_user(&kvm_regs, argp, sizeof kvm_regs))
                        goto out;
                r = kvm_dev_ioctl_set_regs(kvm, &kvm_regs);
                if (r)
@@ -1836,13 +1837,13 @@ static long kvm_dev_ioctl(struct file *filp,
                struct kvm_sregs kvm_sregs;
 
                r = -EFAULT;
-               if (copy_from_user(&kvm_sregs, (void *)arg, sizeof kvm_sregs))
+               if (copy_from_user(&kvm_sregs, argp, sizeof kvm_sregs))
                        goto out;
                r = kvm_dev_ioctl_get_sregs(kvm, &kvm_sregs);
                if (r)
                        goto out;
                r = -EFAULT;
-               if (copy_to_user((void *)arg, &kvm_sregs, sizeof kvm_sregs))
+               if (copy_to_user(argp, &kvm_sregs, sizeof kvm_sregs))
                        goto out;
                r = 0;
                break;
@@ -1851,7 +1852,7 @@ static long kvm_dev_ioctl(struct file *filp,
                struct kvm_sregs kvm_sregs;
 
                r = -EFAULT;
-               if (copy_from_user(&kvm_sregs, (void *)arg, sizeof kvm_sregs))
+               if (copy_from_user(&kvm_sregs, argp, sizeof kvm_sregs))
                        goto out;
                r = kvm_dev_ioctl_set_sregs(kvm, &kvm_sregs);
                if (r)
@@ -1863,13 +1864,13 @@ static long kvm_dev_ioctl(struct file *filp,
                struct kvm_translation tr;
 
                r = -EFAULT;
-               if (copy_from_user(&tr, (void *)arg, sizeof tr))
+               if (copy_from_user(&tr, argp, sizeof tr))
                        goto out;
                r = kvm_dev_ioctl_translate(kvm, &tr);
                if (r)
                        goto out;
                r = -EFAULT;
-               if (copy_to_user((void *)arg, &tr, sizeof tr))
+               if (copy_to_user(argp, &tr, sizeof tr))
                        goto out;
                r = 0;
                break;
@@ -1878,7 +1879,7 @@ static long kvm_dev_ioctl(struct file *filp,
                struct kvm_interrupt irq;
 
                r = -EFAULT;
-               if (copy_from_user(&irq, (void *)arg, sizeof irq))
+               if (copy_from_user(&irq, argp, sizeof irq))
                        goto out;
                r = kvm_dev_ioctl_interrupt(kvm, &irq);
                if (r)
@@ -1890,7 +1891,7 @@ static long kvm_dev_ioctl(struct file *filp,
                struct kvm_debug_guest dbg;
 
                r = -EFAULT;
-               if (copy_from_user(&dbg, (void *)arg, sizeof dbg))
+               if (copy_from_user(&dbg, argp, sizeof dbg))
                        goto out;
                r = kvm_dev_ioctl_debug_guest(kvm, &dbg);
                if (r)
@@ -1902,7 +1903,7 @@ static long kvm_dev_ioctl(struct file *filp,
                struct kvm_memory_region kvm_mem;
 
                r = -EFAULT;
-               if (copy_from_user(&kvm_mem, (void *)arg, sizeof kvm_mem))
+               if (copy_from_user(&kvm_mem, argp, sizeof kvm_mem))
                        goto out;
                r = kvm_dev_ioctl_set_memory_region(kvm, &kvm_mem);
                if (r)
@@ -1913,7 +1914,7 @@ static long kvm_dev_ioctl(struct file *filp,
                struct kvm_dirty_log log;
 
                r = -EFAULT;
-               if (copy_from_user(&log, (void *)arg, sizeof log))
+               if (copy_from_user(&log, argp, sizeof log))
                        goto out;
                r = kvm_dev_ioctl_get_dirty_log(kvm, &log);
                if (r)
@@ -1921,13 +1922,13 @@ static long kvm_dev_ioctl(struct file *filp,
                break;
        }
        case KVM_GET_MSRS:
-               r = msr_io(kvm, (void __user *)arg, get_msr, 1);
+               r = msr_io(kvm, argp, get_msr, 1);
                break;
        case KVM_SET_MSRS:
-               r = msr_io(kvm, (void __user *)arg, do_set_msr, 0);
+               r = msr_io(kvm, argp, do_set_msr, 0);
                break;
        case KVM_GET_MSR_INDEX_LIST: {
-               struct kvm_msr_list __user *user_msr_list = (void __user *)arg;
+               struct kvm_msr_list __user *user_msr_list = argp;
                struct kvm_msr_list msr_list;
                unsigned n;
 
@@ -2014,7 +2015,7 @@ static int kvm_reboot(struct notifier_block *notifier, unsigned long val,
                 * in vmx root mode.
                 */
                printk(KERN_INFO "kvm: exiting hardware virtualization\n");
-               on_each_cpu(kvm_arch_ops->hardware_disable, 0, 0, 1);
+               on_each_cpu(kvm_arch_ops->hardware_disable, NULL, 0, 1);
        }
        return NOTIFY_OK;
 }
@@ -2028,7 +2029,7 @@ static __init void kvm_init_debug(void)
 {
        struct kvm_stats_debugfs_item *p;
 
-       debugfs_dir = debugfs_create_dir("kvm", 0);
+       debugfs_dir = debugfs_create_dir("kvm", NULL);
        for (p = debugfs_entries; p->name; ++p)
                p->dentry = debugfs_create_u32(p->name, 0444, debugfs_dir,
                                               p->data);
@@ -2069,7 +2070,7 @@ int kvm_init_arch(struct kvm_arch_ops *ops, struct module *module)
        if (r < 0)
            return r;
 
-       on_each_cpu(kvm_arch_ops->hardware_enable, 0, 0, 1);
+       on_each_cpu(kvm_arch_ops->hardware_enable, NULL, 0, 1);
        register_reboot_notifier(&kvm_reboot_notifier);
 
        kvm_chardev_ops.owner = module;
@@ -2084,7 +2085,7 @@ int kvm_init_arch(struct kvm_arch_ops *ops, struct module *module)
 
 out_free:
        unregister_reboot_notifier(&kvm_reboot_notifier);
-       on_each_cpu(kvm_arch_ops->hardware_disable, 0, 0, 1);
+       on_each_cpu(kvm_arch_ops->hardware_disable, NULL, 0, 1);
        kvm_arch_ops->hardware_unsetup();
        return r;
 }
@@ -2094,7 +2095,7 @@ void kvm_exit_arch(void)
        misc_deregister(&kvm_dev);
 
        unregister_reboot_notifier(&kvm_reboot_notifier);
-       on_each_cpu(kvm_arch_ops->hardware_disable, 0, 0, 1);
+       on_each_cpu(kvm_arch_ops->hardware_disable, NULL, 0, 1);
        kvm_arch_ops->hardware_unsetup();
        kvm_arch_ops = NULL;
 }
index 22c426cd8cb2a842274b0a005f01c42001fe430f..be793770f31b3045cef6beb7c70ec6d6864fa3f1 100644 (file)
@@ -333,7 +333,7 @@ static void rmap_desc_remove_entry(struct kvm_vcpu *vcpu,
        for (j = RMAP_EXT - 1; !desc->shadow_ptes[j] && j > i; --j)
                ;
        desc->shadow_ptes[i] = desc->shadow_ptes[j];
-       desc->shadow_ptes[j] = 0;
+       desc->shadow_ptes[j] = NULL;
        if (j != 0)
                return;
        if (!prev_desc && !desc->more)
index c79df79307ed0dc0d7dae54409bb8274475d4bc7..85f61dd1e9367a4129edd43fecbc6b9b524a0717 100644 (file)
@@ -274,7 +274,7 @@ static void svm_hardware_disable(void *garbage)
                wrmsrl(MSR_VM_HSAVE_PA, 0);
                rdmsrl(MSR_EFER, efer);
                wrmsrl(MSR_EFER, efer & ~MSR_EFER_SVME_MASK);
-               per_cpu(svm_data, raw_smp_processor_id()) = 0;
+               per_cpu(svm_data, raw_smp_processor_id()) = NULL;
                __free_page(svm_data->save_area);
                kfree(svm_data);
        }
@@ -642,7 +642,7 @@ static struct vmcb_seg *svm_seg(struct kvm_vcpu *vcpu, int seg)
        case VCPU_SREG_LDTR: return &save->ldtr;
        }
        BUG();
-       return 0;
+       return NULL;
 }
 
 static u64 svm_get_segment_base(struct kvm_vcpu *vcpu, int seg)
@@ -934,7 +934,7 @@ static int io_get_override(struct kvm_vcpu *vcpu,
                return 0;
 
        *addr_override = 0;
-       *seg = 0;
+       *seg = NULL;
        for (i = 0; i < ins_length; i++)
                switch (inst[i]) {
                case 0xf0:
@@ -1087,7 +1087,7 @@ static int cpuid_interception(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
 
 static int emulate_on_interception(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
 {
-       if (emulate_instruction(vcpu, 0, 0, 0) != EMULATE_DONE)
+       if (emulate_instruction(vcpu, NULL, 0, 0) != EMULATE_DONE)
                printk(KERN_ERR "%s: failed\n", __FUNCTION__);
        return 1;
 }
index 54c35c0b31815670dd56cbc54b18826e1ea6f80d..27e05a77e21a5645e07dada6717609822de7aea5 100644 (file)
@@ -98,7 +98,7 @@ static struct vmx_msr_entry *find_msr_entry(struct kvm_vcpu *vcpu, u32 msr)
        for (i = 0; i < vcpu->nmsrs; ++i)
                if (vcpu->guest_msrs[i].index == msr)
                        return &vcpu->guest_msrs[i];
-       return 0;
+       return NULL;
 }
 
 static void vmcs_clear(struct vmcs *vmcs)
index a9e747c3979131179d6304755c693c815a2661f0..1a86387e23be2ebd541ad6fef1fbdff2949896fa 100644 (file)
@@ -1,6 +1,6 @@
 
 menu "Macintosh device drivers"
-       depends on PPC || MAC
+       depends on PPC || MAC || X86
 
 config ADB
        bool "Apple Desktop Bus (ADB) support"
index 5ed41fe84e576689d0a44c004e9414b1e13ed92b..f83fad2a3ff451ec8702e9048f94521cf56a1c98 100644 (file)
@@ -171,11 +171,11 @@ static void rackmeter_setup_dbdma(struct rackmeter *rm)
        /* Make sure dbdma is reset */
        DBDMA_DO_RESET(rm->dma_regs);
 
-       pr_debug("rackmeter: mark offset=0x%lx\n",
+       pr_debug("rackmeter: mark offset=0x%zx\n",
                 offsetof(struct rackmeter_dma, mark));
-       pr_debug("rackmeter: buf1 offset=0x%lx\n",
+       pr_debug("rackmeter: buf1 offset=0x%zx\n",
                 offsetof(struct rackmeter_dma, buf1));
-       pr_debug("rackmeter: buf2 offset=0x%lx\n",
+       pr_debug("rackmeter: buf2 offset=0x%zx\n",
                 offsetof(struct rackmeter_dma, buf2));
 
        /* Prepare 4 dbdma commands for the 2 buffers */
index 8ca75e52f637021ea33f49d3c6a4175506313ecc..eb6653f69ce4dfc60111d5e34d9cbfd2fade4a1b 100644 (file)
@@ -516,7 +516,6 @@ static int __init via_pmu_dev_init(void)
                                        proc_get_irqstats, NULL);
                proc_pmu_options = create_proc_entry("options", 0600, proc_pmu_root);
                if (proc_pmu_options) {
-                       proc_pmu_options->nlink = 1;
                        proc_pmu_options->read_proc = proc_read_options;
                        proc_pmu_options->write_proc = proc_write_options;
                }
index 11108165e26420a6f8a3eabb8794e1e0ad833754..5554adaa58f9be01d37bc5623f63384c084e69de 100644 (file)
@@ -666,7 +666,7 @@ static void bitmap_file_put(struct bitmap *bitmap)
 
        if (file) {
                struct inode *inode = file->f_path.dentry->d_inode;
-               invalidate_inode_pages(inode->i_mapping);
+               invalidate_mapping_pages(inode->i_mapping, 0, -1);
                fput(file);
        }
 }
@@ -1160,6 +1160,22 @@ int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sect
                        return 0;
                }
 
+               if (unlikely((*bmc & COUNTER_MAX) == COUNTER_MAX)) {
+                       DEFINE_WAIT(__wait);
+                       /* note that it is safe to do the prepare_to_wait
+                        * after the test as long as we do it before dropping
+                        * the spinlock.
+                        */
+                       prepare_to_wait(&bitmap->overflow_wait, &__wait,
+                                       TASK_UNINTERRUPTIBLE);
+                       spin_unlock_irq(&bitmap->lock);
+                       bitmap->mddev->queue
+                               ->unplug_fn(bitmap->mddev->queue);
+                       schedule();
+                       finish_wait(&bitmap->overflow_wait, &__wait);
+                       continue;
+               }
+
                switch(*bmc) {
                case 0:
                        bitmap_file_set_bit(bitmap, offset);
@@ -1169,7 +1185,7 @@ int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sect
                case 1:
                        *bmc = 2;
                }
-               BUG_ON((*bmc & COUNTER_MAX) == COUNTER_MAX);
+
                (*bmc)++;
 
                spin_unlock_irq(&bitmap->lock);
@@ -1207,6 +1223,9 @@ void bitmap_endwrite(struct bitmap *bitmap, sector_t offset, unsigned long secto
                if (!success && ! (*bmc & NEEDED_MASK))
                        *bmc |= NEEDED_MASK;
 
+               if ((*bmc & COUNTER_MAX) == COUNTER_MAX)
+                       wake_up(&bitmap->overflow_wait);
+
                (*bmc)--;
                if (*bmc <= 2) {
                        set_page_attr(bitmap,
@@ -1431,6 +1450,7 @@ int bitmap_create(mddev_t *mddev)
        spin_lock_init(&bitmap->lock);
        atomic_set(&bitmap->pending_writes, 0);
        init_waitqueue_head(&bitmap->write_wait);
+       init_waitqueue_head(&bitmap->overflow_wait);
 
        bitmap->mddev = mddev;
 
index 467c16982d02e541bc47f4e32c0c90939fb68d52..11c3d7bfa797e8777c5b2bdf47d9ec6f68c7da74 100644 (file)
@@ -2620,7 +2620,7 @@ static struct bio *remove_bio_from_retry(raid5_conf_t *conf)
        }
        bi = conf->retry_read_aligned_list;
        if(bi) {
-               conf->retry_read_aligned = bi->bi_next;
+               conf->retry_read_aligned_list = bi->bi_next;
                bi->bi_next = NULL;
                bi->bi_phys_segments = 1; /* biased count of active stripes */
                bi->bi_hw_segments = 0; /* count of processed stripes */
@@ -2669,6 +2669,27 @@ static int raid5_align_endio(struct bio *bi, unsigned int bytes, int error)
        return 0;
 }
 
+static int bio_fits_rdev(struct bio *bi)
+{
+       request_queue_t *q = bdev_get_queue(bi->bi_bdev);
+
+       if ((bi->bi_size>>9) > q->max_sectors)
+               return 0;
+       blk_recount_segments(q, bi);
+       if (bi->bi_phys_segments > q->max_phys_segments ||
+           bi->bi_hw_segments > q->max_hw_segments)
+               return 0;
+
+       if (q->merge_bvec_fn)
+               /* it's too hard to apply the merge_bvec_fn at this stage,
+                * just just give up
+                */
+               return 0;
+
+       return 1;
+}
+
+
 static int chunk_aligned_read(request_queue_t *q, struct bio * raid_bio)
 {
        mddev_t *mddev = q->queuedata;
@@ -2715,6 +2736,13 @@ static int chunk_aligned_read(request_queue_t *q, struct bio * raid_bio)
                align_bi->bi_flags &= ~(1 << BIO_SEG_VALID);
                align_bi->bi_sector += rdev->data_offset;
 
+               if (!bio_fits_rdev(align_bi)) {
+                       /* too big in some way */
+                       bio_put(align_bi);
+                       rdev_dec_pending(rdev, mddev);
+                       return 0;
+               }
+
                spin_lock_irq(&conf->device_lock);
                wait_event_lock_irq(conf->wait_for_stripe,
                                    conf->quiesce == 0,
@@ -3107,7 +3135,9 @@ static int  retry_aligned_read(raid5_conf_t *conf, struct bio *raid_bio)
        last_sector = raid_bio->bi_sector + (raid_bio->bi_size>>9);
 
        for (; logical_sector < last_sector;
-            logical_sector += STRIPE_SECTORS, scnt++) {
+            logical_sector += STRIPE_SECTORS,
+                    sector += STRIPE_SECTORS,
+                    scnt++) {
 
                if (scnt < raid_bio->bi_hw_segments)
                        /* already done this stripe */
@@ -3123,7 +3153,13 @@ static int  retry_aligned_read(raid5_conf_t *conf, struct bio *raid_bio)
                }
 
                set_bit(R5_ReadError, &sh->dev[dd_idx].flags);
-               add_stripe_bio(sh, raid_bio, dd_idx, 0);
+               if (!add_stripe_bio(sh, raid_bio, dd_idx, 0)) {
+                       release_stripe(sh);
+                       raid_bio->bi_hw_segments = scnt;
+                       conf->retry_read_aligned = raid_bio;
+                       return handled;
+               }
+
                handle_stripe(sh, NULL);
                release_stripe(sh);
                handled++;
index f51e02fe3655c2942777ebc6dc114c1ffc47d79e..0e948a5c5a03481d56cefc9844db22a6590c4592 100644 (file)
@@ -698,7 +698,6 @@ IR_KEYTAB_TYPE ir_codes_pinnacle_grey[IR_KEYTAB_SIZE] = {
        [ 0x29 ] = KEY_TEXT,
        [ 0x2a ] = KEY_MEDIA,
        [ 0x18 ] = KEY_EPG,
-       [ 0x27 ] = KEY_RECORD,
 };
 
 EXPORT_SYMBOL_GPL(ir_codes_pinnacle_grey);
index 7243337b771a5031b54ec861d1cd6fc1e7e25d25..bdd6301d2a47dc6515f172fb37d03a94de528958 100644 (file)
@@ -1072,7 +1072,7 @@ static int usbvision_v4l2_ioctl(struct inode *inode, struct file *file,
 }
 
 
-static ssize_t usbvision_v4l2_read(struct file *file, char *buf,
+static ssize_t usbvision_v4l2_read(struct file *file, char __user *buf,
                      size_t count, loff_t *ppos)
 {
        struct video_device *dev = video_devdata(file);
index 862a984c2155c6d8a739f54f4007f90b1a20f13b..e10a9ee25fc508d30685ba8f8bdf51f114baf857 100644 (file)
@@ -562,7 +562,6 @@ jpg_fbuffer_alloc (struct file *file)
                        jpg_fbuffer_free(file);
                        return -ENOBUFS;
                }
-               memset((void *) mem, 0, PAGE_SIZE);
                fh->jpg_buffers.buffer[i].frag_tab = (u32 *) mem;
                fh->jpg_buffers.buffer[i].frag_tab_bus =
                    virt_to_bus((void *) mem);
index 89bba277da5f9c81f1ba2a72c70a903bc1b288c7..bedae4ad3f74f1d916a0e2a7b555e39474244b31 100644 (file)
@@ -42,7 +42,7 @@ config SGI_IOC4
 
 config TIFM_CORE
        tristate "TI Flash Media interface support (EXPERIMENTAL)"
-       depends on EXPERIMENTAL
+       depends on EXPERIMENTAL && PCI
        help
          If you want support for Texas Instruments(R) Flash Media adapters
          you should select this option and then also choose an appropriate
index ea9d5f233c83037568350a82224d5870bda6a7ba..6a51e99a8079995adfb9183a0af21108eb0705ff 100644 (file)
@@ -72,11 +72,9 @@ static int hdpu_nexus_probe(struct platform_device *pdev)
                printk("Could not map slot id\n");
        hdpu_slot_id = create_proc_entry("sky_slot_id", 0666, &proc_root);
        hdpu_slot_id->read_proc = hdpu_slot_id_read;
-       hdpu_slot_id->nlink = 1;
 
        hdpu_chassis_id = create_proc_entry("sky_chassis_id", 0666, &proc_root);
        hdpu_chassis_id->read_proc = hdpu_chassis_id_read;
-       hdpu_chassis_id->nlink = 1;
        return 0;
 }
 
index b995a15b7526a43d12439ce955fb91579d4cff72..6a5a05d1f3923d81ee54ce2df63a0e2fca7f4d37 100644 (file)
@@ -309,7 +309,7 @@ ioc4_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
                ret = -ENODEV;
                goto out_pci;
        }
-       if (!request_region(idd->idd_bar0, sizeof(struct ioc4_misc_regs),
+       if (!request_mem_region(idd->idd_bar0, sizeof(struct ioc4_misc_regs),
                            "ioc4_misc")) {
                printk(KERN_WARNING
                       "%s: Unable to request IOC4 misc region "
@@ -379,7 +379,7 @@ ioc4_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
        return 0;
 
 out_misc_region:
-       release_region(idd->idd_bar0, sizeof(struct ioc4_misc_regs));
+       release_mem_region(idd->idd_bar0, sizeof(struct ioc4_misc_regs));
 out_pci:
        kfree(idd);
 out_idd:
@@ -418,7 +418,7 @@ ioc4_remove(struct pci_dev *pdev)
                       "Device removal may be incomplete.\n",
                       __FUNCTION__, pci_name(idd->idd_pdev));
        }
-       release_region(idd->idd_bar0, sizeof(struct ioc4_misc_regs));
+       release_mem_region(idd->idd_bar0, sizeof(struct ioc4_misc_regs));
 
        /* Disable IOC4 and relinquish */
        pci_disable_device(pdev);
index db9d7df75ae0640c763f4a7167d6cd8ac42c147c..552b7957a92a1ad1ea284aedf0e02ad36d102a1c 100644 (file)
@@ -108,8 +108,8 @@ static struct jprobe lkdtm;
 static int lkdtm_parse_commandline(void);
 static void lkdtm_handler(void);
 
-static char* cpoint_name = INVALID;
-static char* cpoint_type = NONE;
+static char* cpoint_name;
+static char* cpoint_type;
 static int cpoint_count = DEFAULT_COUNT;
 static int recur_count = REC_NUM_DEFAULT;
 
index 4224686fdf2a16b73b8e531fc795e867dcc71c51..12af9c718764e36fcbad74fa37c01aa9d37544c4 100644 (file)
@@ -111,7 +111,7 @@ config MMC_IMX
 
 config MMC_TIFM_SD
        tristate "TI Flash Media MMC/SD Interface support  (EXPERIMENTAL)"
-       depends on MMC && EXPERIMENTAL
+       depends on MMC && EXPERIMENTAL && PCI
        select TIFM_CORE
        help
          Say Y here if you want to be able to access MMC/SD cards with
index 6d917a4daa9db24b4d9e7cb23281e1842cef9283..f9f2ce7806b0b3edc21a5d6763736f56329a4ee8 100644 (file)
@@ -278,7 +278,8 @@ static void block2mtd_free_device(struct block2mtd_dev *dev)
        kfree(dev->mtd.name);
 
        if (dev->blkdev) {
-               invalidate_inode_pages(dev->blkdev->bd_inode->i_mapping);
+               invalidate_mapping_pages(dev->blkdev->bd_inode->i_mapping,
+                                       0, -1);
                close_bdev_excl(dev->blkdev);
        }
 
index 7e34c4f07b70723668d27a4baa2c48d1a1c8a011..bc7e906571d38ec85ccad529f5858e403f80cbd1 100644 (file)
@@ -600,8 +600,7 @@ el2_block_input(struct net_device *dev, int count, struct sk_buff *skb, int ring
            count -= semi_count;
            memcpy_fromio(skb->data + semi_count, base + ei_status.priv, count);
        } else {
-               /* Packet is in one chunk -- we can copy + cksum. */
-               eth_io_copy_and_sum(skb, base + ring_offset, count, 0);
+               memcpy_fromio(skb->data, base + ring_offset, count);
        }
        return;
     }
index ad92b6a76ee64bb8108eef5e0db2d8663ad3c672..38f41a593b1269961e8ce8040751c644a46fa9f6 100644 (file)
@@ -2335,6 +2335,17 @@ config QLA3XXX
          To compile this driver as a module, choose M here: the module
          will be called qla3xxx.
 
+config ATL1
+       tristate "Attansic L1 Gigabit Ethernet support (EXPERIMENTAL)"
+       depends on NET_PCI && PCI && EXPERIMENTAL
+       select CRC32
+       select MII
+       help
+         This driver supports the Attansic L1 gigabit ethernet adapter.
+
+         To compile this driver as a module, choose M here.  The module
+         will be called atl1.
+
 endmenu
 
 #
@@ -2534,7 +2545,7 @@ config RIONET_RX_SIZE
 
 config FDDI
        bool "FDDI driver support"
-       depends on (PCI || EISA)
+       depends on (PCI || EISA || TC)
        help
          Fiber Distributed Data Interface is a high speed local area network
          design; essentially a replacement for high speed Ethernet. FDDI can
@@ -2544,11 +2555,31 @@ config FDDI
          will say N.
 
 config DEFXX
-       tristate "Digital DEFEA and DEFPA adapter support"
-       depends on FDDI && (PCI || EISA)
-       help
-         This is support for the DIGITAL series of EISA (DEFEA) and PCI
-         (DEFPA) controllers which can connect you to a local FDDI network.
+       tristate "Digital DEFTA/DEFEA/DEFPA adapter support"
+       depends on FDDI && (PCI || EISA || TC)
+       ---help---
+         This is support for the DIGITAL series of TURBOchannel (DEFTA),
+         EISA (DEFEA) and PCI (DEFPA) controllers which can connect you
+         to a local FDDI network.
+
+         To compile this driver as a module, choose M here: the module
+         will be called defxx.  If unsure, say N.
+
+config DEFXX_MMIO
+       bool
+       prompt "Use MMIO instead of PIO" if PCI || EISA
+       depends on DEFXX
+       default n if PCI || EISA
+       default y
+       ---help---
+         This instructs the driver to use EISA or PCI memory-mapped I/O
+         (MMIO) as appropriate instead of programmed I/O ports (PIO).
+         Enabling this gives an improvement in processing time in parts
+         of the driver, but it may cause problems with EISA (DEFEA)
+         adapters.  TURBOchannel does not have the concept of I/O ports,
+         so MMIO is always used for these (DEFTA) adapters.
+
+         If unsure, say N.
 
 config SKFP
        tristate "SysKonnect FDDI PCI support"
index 0878e3df51746e74c4302190535173e36ae4d23b..33af833667da3751b9bf85ce6bc3535a26b1d5bd 100644 (file)
@@ -9,6 +9,7 @@ obj-$(CONFIG_CHELSIO_T1) += chelsio/
 obj-$(CONFIG_CHELSIO_T3) += cxgb3/
 obj-$(CONFIG_EHEA) += ehea/
 obj-$(CONFIG_BONDING) += bonding/
+obj-$(CONFIG_ATL1) += atl1/
 obj-$(CONFIG_GIANFAR) += gianfar_driver.o
 
 gianfar_driver-objs := gianfar.o \
index c01f87f5bed77b4f6d93cb5cf013a73f6f9e7122..644c408515df9b643823557ce7459b985164d2a7 100644 (file)
@@ -327,8 +327,7 @@ static void ac_block_input(struct net_device *dev, int count, struct sk_buff *sk
                memcpy_fromio(skb->data + semi_count,
                                ei_status.mem + TX_PAGES*256, count);
        } else {
-               /* Packet is in one chunk -- we can copy + cksum. */
-               eth_io_copy_and_sum(skb, start, count, 0);
+               memcpy_fromio(skb->data, start, count);
        }
 }
 
diff --git a/drivers/net/atl1/Makefile b/drivers/net/atl1/Makefile
new file mode 100644 (file)
index 0000000..a6b707e
--- /dev/null
@@ -0,0 +1,2 @@
+obj-$(CONFIG_ATL1)     += atl1.o
+atl1-y                 += atl1_main.o atl1_hw.o atl1_ethtool.o atl1_param.o
diff --git a/drivers/net/atl1/atl1.h b/drivers/net/atl1/atl1.h
new file mode 100644 (file)
index 0000000..b1c6034
--- /dev/null
@@ -0,0 +1,283 @@
+/*
+ * Copyright(c) 2005 - 2006 Attansic Corporation. All rights reserved.
+ * Copyright(c) 2006 Chris Snook <csnook@redhat.com>
+ * Copyright(c) 2006 Jay Cliburn <jcliburn@gmail.com>
+ *
+ * Derived from Intel e1000 driver
+ * Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59
+ * Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+#ifndef _ATL1_H_
+#define _ATL1_H_
+
+#include <linux/types.h>
+#include <linux/if_vlan.h>
+
+#include "atl1_hw.h"
+
+/* function prototypes needed by multiple files */
+s32 atl1_up(struct atl1_adapter *adapter);
+void atl1_down(struct atl1_adapter *adapter);
+int atl1_reset(struct atl1_adapter *adapter);
+s32 atl1_setup_ring_resources(struct atl1_adapter *adapter);
+void atl1_free_ring_resources(struct atl1_adapter *adapter);
+
+extern char atl1_driver_name[];
+extern char atl1_driver_version[];
+extern const struct ethtool_ops atl1_ethtool_ops;
+
+struct atl1_adapter;
+
+#define ATL1_MAX_INTR          3
+
+#define ATL1_DEFAULT_TPD       256
+#define ATL1_MAX_TPD           1024
+#define ATL1_MIN_TPD           64
+#define ATL1_DEFAULT_RFD       512
+#define ATL1_MIN_RFD           128
+#define ATL1_MAX_RFD           2048
+
+#define ATL1_GET_DESC(R, i, type)      (&(((type *)((R)->desc))[i]))
+#define ATL1_RFD_DESC(R, i)    ATL1_GET_DESC(R, i, struct rx_free_desc)
+#define ATL1_TPD_DESC(R, i)    ATL1_GET_DESC(R, i, struct tx_packet_desc)
+#define ATL1_RRD_DESC(R, i)    ATL1_GET_DESC(R, i, struct rx_return_desc)
+
+/*
+ * Some workarounds require millisecond delays and are run during interrupt
+ * context.  Most notably, when establishing link, the phy may need tweaking
+ * but cannot process phy register reads/writes faster than millisecond
+ * intervals...and we establish link due to a "link status change" interrupt.
+ */
+
+/*
+ * wrapper around a pointer to a socket buffer,
+ * so a DMA handle can be stored along with the buffer
+ */
+struct atl1_buffer {
+       struct sk_buff *skb;
+       u16 length;
+       u16 alloced;
+       dma_addr_t dma;
+};
+
+#define MAX_TX_BUF_LEN         0x3000  /* 12KB */
+
+struct atl1_tpd_ring {
+       void *desc;             /* pointer to the descriptor ring memory */
+       dma_addr_t dma;         /* physical adress of the descriptor ring */
+       u16 size;               /* length of descriptor ring in bytes */
+       u16 count;              /* number of descriptors in the ring */
+       u16 hw_idx;             /* hardware index */
+       atomic_t next_to_clean;
+       atomic_t next_to_use;
+       struct atl1_buffer *buffer_info;
+};
+
+struct atl1_rfd_ring {
+       void *desc;
+       dma_addr_t dma;
+       u16 size;
+       u16 count;
+       atomic_t next_to_use;
+       u16 next_to_clean;
+       struct atl1_buffer *buffer_info;
+};
+
+struct atl1_rrd_ring {
+       void *desc;
+       dma_addr_t dma;
+       unsigned int size;
+       u16 count;
+       u16 next_to_use;
+       atomic_t next_to_clean;
+};
+
+struct atl1_ring_header {
+       void *desc;             /* pointer to the descriptor ring memory */
+       dma_addr_t dma;         /* physical adress of the descriptor ring */
+       unsigned int size;      /* length of descriptor ring in bytes */
+};
+
+struct atl1_cmb {
+       struct coals_msg_block *cmb;
+       dma_addr_t dma;
+};
+
+struct atl1_smb {
+       struct stats_msg_block *smb;
+       dma_addr_t dma;
+};
+
+/* Statistics counters */
+struct atl1_sft_stats {
+       u64 rx_packets;
+       u64 tx_packets;
+       u64 rx_bytes;
+       u64 tx_bytes;
+       u64 multicast;
+       u64 collisions;
+       u64 rx_errors;
+       u64 rx_length_errors;
+       u64 rx_crc_errors;
+       u64 rx_frame_errors;
+       u64 rx_fifo_errors;
+       u64 rx_missed_errors;
+       u64 tx_errors;
+       u64 tx_fifo_errors;
+       u64 tx_aborted_errors;
+       u64 tx_window_errors;
+       u64 tx_carrier_errors;
+
+       u64 tx_pause;           /* num Pause packet transmitted. */
+       u64 excecol;            /* num tx packets aborted due to excessive collisions. */
+       u64 deffer;             /* num deferred tx packets */
+       u64 scc;                /* num packets subsequently transmitted successfully w/ single prior collision. */
+       u64 mcc;                /* num packets subsequently transmitted successfully w/ multiple prior collisions. */
+       u64 latecol;            /* num tx packets  w/ late collisions. */
+       u64 tx_underun;         /* num tx packets aborted due to transmit FIFO underrun, or TRD FIFO underrun */
+       u64 tx_trunc;           /* num tx packets truncated due to size exceeding MTU, regardless whether truncated by Selene or not. (The name doesn't really reflect the meaning in this case.) */
+       u64 rx_pause;           /* num Pause packets received. */
+       u64 rx_rrd_ov;
+       u64 rx_trunc;
+};
+
+/* board specific private data structure */
+#define ATL1_REGS_LEN  8
+
+/* Structure containing variables used by the shared code */
+struct atl1_hw {
+       u8 __iomem *hw_addr;
+       struct atl1_adapter *back;
+       enum atl1_dma_order dma_ord;
+       enum atl1_dma_rcb rcb_value;
+       enum atl1_dma_req_block dmar_block;
+       enum atl1_dma_req_block dmaw_block;
+       u8 preamble_len;
+       u8 max_retry;           /* Retransmission maximum, after which the packet will be discarded */
+       u8 jam_ipg;             /* IPG to start JAM for collision based flow control in half-duplex mode. In units of 8-bit time */
+       u8 ipgt;                /* Desired back to back inter-packet gap. The default is 96-bit time */
+       u8 min_ifg;             /* Minimum number of IFG to enforce in between RX frames. Frame gap below such IFP is dropped */
+       u8 ipgr1;               /* 64bit Carrier-Sense window */
+       u8 ipgr2;               /* 96-bit IPG window */
+       u8 tpd_burst;           /* Number of TPD to prefetch in cache-aligned burst. Each TPD is 16 bytes long */
+       u8 rfd_burst;           /* Number of RFD to prefetch in cache-aligned burst. Each RFD is 12 bytes long */
+       u8 rfd_fetch_gap;
+       u8 rrd_burst;           /* Threshold number of RRDs that can be retired in a burst. Each RRD is 16 bytes long */
+       u8 tpd_fetch_th;
+       u8 tpd_fetch_gap;
+       u16 tx_jumbo_task_th;
+       u16 txf_burst;          /* Number of data bytes to read in a cache-aligned burst. Each SRAM entry is
+                                  8 bytes long */
+       u16 rx_jumbo_th;        /* Jumbo packet size for non-VLAN packet. VLAN packets should add 4 bytes */
+       u16 rx_jumbo_lkah;
+       u16 rrd_ret_timer;      /* RRD retirement timer. Decrement by 1 after every 512ns passes. */
+       u16 lcol;               /* Collision Window */
+
+       u16 cmb_tpd;
+       u16 cmb_rrd;
+       u16 cmb_rx_timer;
+       u16 cmb_tx_timer;
+       u32 smb_timer;
+       u16 media_type;
+       u16 autoneg_advertised;
+       u16 pci_cmd_word;
+
+       u16 mii_autoneg_adv_reg;
+       u16 mii_1000t_ctrl_reg;
+
+       u32 mem_rang;
+       u32 txcw;
+       u32 max_frame_size;
+       u32 min_frame_size;
+       u32 mc_filter_type;
+       u32 num_mc_addrs;
+       u32 collision_delta;
+       u32 tx_packet_delta;
+       u16 phy_spd_default;
+
+       u16 dev_rev;
+       u8 revision_id;
+
+       /* spi flash */
+       u8 flash_vendor;
+
+       u8 dma_fairness;
+       u8 mac_addr[ETH_ALEN];
+       u8 perm_mac_addr[ETH_ALEN];
+
+       /* bool phy_preamble_sup; */
+       bool phy_configured;
+};
+
+struct atl1_adapter {
+       /* OS defined structs */
+       struct net_device *netdev;
+       struct pci_dev *pdev;
+       struct net_device_stats net_stats;
+       struct atl1_sft_stats soft_stats;
+
+       struct vlan_group *vlgrp;
+       u32 rx_buffer_len;
+       u32 wol;
+       u16 link_speed;
+       u16 link_duplex;
+       spinlock_t lock;
+       atomic_t irq_sem;
+       struct work_struct tx_timeout_task;
+       struct work_struct link_chg_task;
+       struct work_struct pcie_dma_to_rst_task;
+       struct timer_list watchdog_timer;
+       struct timer_list phy_config_timer;
+       bool phy_timer_pending;
+
+       bool mac_disabled;
+
+       /* All descriptor rings' memory */
+       struct atl1_ring_header ring_header;
+
+       /* TX */
+       struct atl1_tpd_ring tpd_ring;
+       spinlock_t mb_lock;
+
+       /* RX */
+       struct atl1_rfd_ring rfd_ring;
+       struct atl1_rrd_ring rrd_ring;
+       u64 hw_csum_err;
+       u64 hw_csum_good;
+
+       u32 gorcl;
+       u64 gorcl_old;
+
+       /* Interrupt Moderator timer ( 2us resolution) */
+       u16 imt;
+       /* Interrupt Clear timer (2us resolution) */
+       u16 ict;
+
+       /* MII interface info */
+       struct mii_if_info mii;
+
+       /* structs defined in atl1_hw.h */
+       u32 bd_number;          /* board number */
+       bool pci_using_64;
+       struct atl1_hw hw;
+       struct atl1_smb smb;
+       struct atl1_cmb cmb;
+
+       u32 pci_state[16];
+};
+
+#endif /* _ATL1_H_ */
diff --git a/drivers/net/atl1/atl1_ethtool.c b/drivers/net/atl1/atl1_ethtool.c
new file mode 100644 (file)
index 0000000..c11c277
--- /dev/null
@@ -0,0 +1,508 @@
+/*
+ * Copyright(c) 2005 - 2006 Attansic Corporation. All rights reserved.
+ * Copyright(c) 2006 Chris Snook <csnook@redhat.com>
+ * Copyright(c) 2006 Jay Cliburn <jcliburn@gmail.com>
+ *
+ * Derived from Intel e1000 driver
+ * Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59
+ * Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+#include <linux/types.h>
+#include <linux/pci.h>
+#include <linux/ethtool.h>
+#include <linux/netdevice.h>
+#include <linux/mii.h>
+#include <asm/uaccess.h>
+
+#include "atl1.h"
+
+struct atl1_stats {
+       char stat_string[ETH_GSTRING_LEN];
+       int sizeof_stat;
+       int stat_offset;
+};
+
+#define ATL1_STAT(m) sizeof(((struct atl1_adapter *)0)->m), \
+       offsetof(struct atl1_adapter, m)
+
+static struct atl1_stats atl1_gstrings_stats[] = {
+       {"rx_packets", ATL1_STAT(soft_stats.rx_packets)},
+       {"tx_packets", ATL1_STAT(soft_stats.tx_packets)},
+       {"rx_bytes", ATL1_STAT(soft_stats.rx_bytes)},
+       {"tx_bytes", ATL1_STAT(soft_stats.tx_bytes)},
+       {"rx_errors", ATL1_STAT(soft_stats.rx_errors)},
+       {"tx_errors", ATL1_STAT(soft_stats.tx_errors)},
+       {"rx_dropped", ATL1_STAT(net_stats.rx_dropped)},
+       {"tx_dropped", ATL1_STAT(net_stats.tx_dropped)},
+       {"multicast", ATL1_STAT(soft_stats.multicast)},
+       {"collisions", ATL1_STAT(soft_stats.collisions)},
+       {"rx_length_errors", ATL1_STAT(soft_stats.rx_length_errors)},
+       {"rx_over_errors", ATL1_STAT(soft_stats.rx_missed_errors)},
+       {"rx_crc_errors", ATL1_STAT(soft_stats.rx_crc_errors)},
+       {"rx_frame_errors", ATL1_STAT(soft_stats.rx_frame_errors)},
+       {"rx_fifo_errors", ATL1_STAT(soft_stats.rx_fifo_errors)},
+       {"rx_missed_errors", ATL1_STAT(soft_stats.rx_missed_errors)},
+       {"tx_aborted_errors", ATL1_STAT(soft_stats.tx_aborted_errors)},
+       {"tx_carrier_errors", ATL1_STAT(soft_stats.tx_carrier_errors)},
+       {"tx_fifo_errors", ATL1_STAT(soft_stats.tx_fifo_errors)},
+       {"tx_window_errors", ATL1_STAT(soft_stats.tx_window_errors)},
+       {"tx_abort_exce_coll", ATL1_STAT(soft_stats.excecol)},
+       {"tx_abort_late_coll", ATL1_STAT(soft_stats.latecol)},
+       {"tx_deferred_ok", ATL1_STAT(soft_stats.deffer)},
+       {"tx_single_coll_ok", ATL1_STAT(soft_stats.scc)},
+       {"tx_multi_coll_ok", ATL1_STAT(soft_stats.mcc)},
+       {"tx_underun", ATL1_STAT(soft_stats.tx_underun)},
+       {"tx_trunc", ATL1_STAT(soft_stats.tx_trunc)},
+       {"tx_pause", ATL1_STAT(soft_stats.tx_pause)},
+       {"rx_pause", ATL1_STAT(soft_stats.rx_pause)},
+       {"rx_rrd_ov", ATL1_STAT(soft_stats.rx_rrd_ov)},
+       {"rx_trunc", ATL1_STAT(soft_stats.rx_trunc)}
+};
+
+static void atl1_get_ethtool_stats(struct net_device *netdev,
+                               struct ethtool_stats *stats, u64 *data)
+{
+       struct atl1_adapter *adapter = netdev_priv(netdev);
+       int i;
+       char *p;
+
+       for (i = 0; i < ARRAY_SIZE(atl1_gstrings_stats); i++) {
+               p = (char *)adapter+atl1_gstrings_stats[i].stat_offset;
+               data[i] = (atl1_gstrings_stats[i].sizeof_stat ==
+                       sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
+       }
+
+}
+
+static int atl1_get_stats_count(struct net_device *netdev)
+{
+       return ARRAY_SIZE(atl1_gstrings_stats);
+}
+
+static int atl1_get_settings(struct net_device *netdev,
+                               struct ethtool_cmd *ecmd)
+{
+       struct atl1_adapter *adapter = netdev_priv(netdev);
+       struct atl1_hw *hw = &adapter->hw;
+
+       ecmd->supported = (SUPPORTED_10baseT_Half |
+                          SUPPORTED_10baseT_Full |
+                          SUPPORTED_100baseT_Half |
+                          SUPPORTED_100baseT_Full |
+                          SUPPORTED_1000baseT_Full |
+                          SUPPORTED_Autoneg | SUPPORTED_TP);
+       ecmd->advertising = ADVERTISED_TP;
+       if (hw->media_type == MEDIA_TYPE_AUTO_SENSOR ||
+           hw->media_type == MEDIA_TYPE_1000M_FULL) {
+               ecmd->advertising |= ADVERTISED_Autoneg;
+               if (hw->media_type == MEDIA_TYPE_AUTO_SENSOR) {
+                       ecmd->advertising |= ADVERTISED_Autoneg;
+                       ecmd->advertising |=
+                           (ADVERTISED_10baseT_Half |
+                            ADVERTISED_10baseT_Full |
+                            ADVERTISED_100baseT_Half |
+                            ADVERTISED_100baseT_Full |
+                            ADVERTISED_1000baseT_Full);
+               }
+               else
+                       ecmd->advertising |= (ADVERTISED_1000baseT_Full);
+       }
+       ecmd->port = PORT_TP;
+       ecmd->phy_address = 0;
+       ecmd->transceiver = XCVR_INTERNAL;
+
+       if (netif_carrier_ok(adapter->netdev)) {
+               u16 link_speed, link_duplex;
+               atl1_get_speed_and_duplex(hw, &link_speed, &link_duplex);
+               ecmd->speed = link_speed;
+               if (link_duplex == FULL_DUPLEX)
+                       ecmd->duplex = DUPLEX_FULL;
+               else
+                       ecmd->duplex = DUPLEX_HALF;
+       } else {
+               ecmd->speed = -1;
+               ecmd->duplex = -1;
+       }
+       if (hw->media_type == MEDIA_TYPE_AUTO_SENSOR ||
+           hw->media_type == MEDIA_TYPE_1000M_FULL)
+               ecmd->autoneg = AUTONEG_ENABLE;
+       else
+               ecmd->autoneg = AUTONEG_DISABLE;
+
+       return 0;
+}
+
+static int atl1_set_settings(struct net_device *netdev,
+                               struct ethtool_cmd *ecmd)
+{
+       struct atl1_adapter *adapter = netdev_priv(netdev);
+       struct atl1_hw *hw = &adapter->hw;
+       u16 phy_data;
+       int ret_val = 0;
+       u16 old_media_type = hw->media_type;
+
+       if (netif_running(adapter->netdev)) {
+               printk(KERN_DEBUG "%s: ethtool shutting down adapter\n",
+                       atl1_driver_name);
+               atl1_down(adapter);
+       }
+
+       if (ecmd->autoneg == AUTONEG_ENABLE)
+               hw->media_type = MEDIA_TYPE_AUTO_SENSOR;
+       else {
+               if (ecmd->speed == SPEED_1000) {
+                       if (ecmd->duplex != DUPLEX_FULL) {
+                               printk(KERN_WARNING
+                                      "%s: can't force to 1000M half duplex\n",
+                                       atl1_driver_name);
+                               ret_val = -EINVAL;
+                               goto exit_sset;
+                       }
+                       hw->media_type = MEDIA_TYPE_1000M_FULL;
+               } else if (ecmd->speed == SPEED_100) {
+                       if (ecmd->duplex == DUPLEX_FULL) {
+                               hw->media_type = MEDIA_TYPE_100M_FULL;
+                       } else
+                               hw->media_type = MEDIA_TYPE_100M_HALF;
+               } else {
+                       if (ecmd->duplex == DUPLEX_FULL)
+                               hw->media_type = MEDIA_TYPE_10M_FULL;
+                       else
+                               hw->media_type = MEDIA_TYPE_10M_HALF;
+               }
+       }
+       switch (hw->media_type) {
+       case MEDIA_TYPE_AUTO_SENSOR:
+               ecmd->advertising =
+                   ADVERTISED_10baseT_Half |
+                   ADVERTISED_10baseT_Full |
+                   ADVERTISED_100baseT_Half |
+                   ADVERTISED_100baseT_Full |
+                   ADVERTISED_1000baseT_Full |
+                   ADVERTISED_Autoneg | ADVERTISED_TP;
+               break;
+       case MEDIA_TYPE_1000M_FULL:
+               ecmd->advertising =
+                   ADVERTISED_1000baseT_Full |
+                   ADVERTISED_Autoneg | ADVERTISED_TP;
+               break;
+       default:
+               ecmd->advertising = 0;
+               break;
+       }
+       if (atl1_phy_setup_autoneg_adv(hw)) {
+               ret_val = -EINVAL;
+               printk(KERN_WARNING
+                       "%s: invalid ethtool speed/duplex setting\n",
+                       atl1_driver_name);
+               goto exit_sset;
+       }
+       if (hw->media_type == MEDIA_TYPE_AUTO_SENSOR ||
+           hw->media_type == MEDIA_TYPE_1000M_FULL)
+               phy_data = MII_CR_RESET | MII_CR_AUTO_NEG_EN;
+       else {
+               switch (hw->media_type) {
+               case MEDIA_TYPE_100M_FULL:
+                       phy_data =
+                           MII_CR_FULL_DUPLEX | MII_CR_SPEED_100 |
+                           MII_CR_RESET;
+                       break;
+               case MEDIA_TYPE_100M_HALF:
+                       phy_data = MII_CR_SPEED_100 | MII_CR_RESET;
+                       break;
+               case MEDIA_TYPE_10M_FULL:
+                       phy_data =
+                           MII_CR_FULL_DUPLEX | MII_CR_SPEED_10 | MII_CR_RESET;
+                       break;
+               default:        /* MEDIA_TYPE_10M_HALF: */
+                       phy_data = MII_CR_SPEED_10 | MII_CR_RESET;
+                       break;
+               }
+       }
+       atl1_write_phy_reg(hw, MII_BMCR, phy_data);
+exit_sset:
+       if (ret_val)
+               hw->media_type = old_media_type;
+
+       if (netif_running(adapter->netdev)) {
+               printk(KERN_DEBUG "%s: ethtool starting adapter\n",
+                       atl1_driver_name);
+               atl1_up(adapter);
+       } else if (!ret_val) {
+               printk(KERN_DEBUG "%s: ethtool resetting adapter\n",
+                       atl1_driver_name);
+               atl1_reset(adapter);
+       }
+       return ret_val;
+}
+
+static void atl1_get_drvinfo(struct net_device *netdev,
+                               struct ethtool_drvinfo *drvinfo)
+{
+       struct atl1_adapter *adapter = netdev_priv(netdev);
+
+       strncpy(drvinfo->driver, atl1_driver_name, sizeof(drvinfo->driver));
+       strncpy(drvinfo->version, atl1_driver_version,
+               sizeof(drvinfo->version));
+       strncpy(drvinfo->fw_version, "N/A", sizeof(drvinfo->fw_version));
+       strncpy(drvinfo->bus_info, pci_name(adapter->pdev),
+               sizeof(drvinfo->bus_info));
+       drvinfo->eedump_len = ATL1_EEDUMP_LEN;
+}
+
+static void atl1_get_wol(struct net_device *netdev,
+                           struct ethtool_wolinfo *wol)
+{
+       struct atl1_adapter *adapter = netdev_priv(netdev);
+
+       wol->supported = WAKE_UCAST | WAKE_MCAST | WAKE_BCAST | WAKE_MAGIC;
+       wol->wolopts = 0;
+       if (adapter->wol & ATL1_WUFC_EX)
+               wol->wolopts |= WAKE_UCAST;
+       if (adapter->wol & ATL1_WUFC_MC)
+               wol->wolopts |= WAKE_MCAST;
+       if (adapter->wol & ATL1_WUFC_BC)
+               wol->wolopts |= WAKE_BCAST;
+       if (adapter->wol & ATL1_WUFC_MAG)
+               wol->wolopts |= WAKE_MAGIC;
+       return;
+}
+
+static int atl1_set_wol(struct net_device *netdev,
+                       struct ethtool_wolinfo *wol)
+{
+       struct atl1_adapter *adapter = netdev_priv(netdev);
+
+       if (wol->wolopts & (WAKE_PHY | WAKE_ARP | WAKE_MAGICSECURE))
+               return -EOPNOTSUPP;
+       adapter->wol = 0;
+       if (wol->wolopts & WAKE_UCAST)
+               adapter->wol |= ATL1_WUFC_EX;
+       if (wol->wolopts & WAKE_MCAST)
+               adapter->wol |= ATL1_WUFC_MC;
+       if (wol->wolopts & WAKE_BCAST)
+               adapter->wol |= ATL1_WUFC_BC;
+       if (wol->wolopts & WAKE_MAGIC)
+               adapter->wol |= ATL1_WUFC_MAG;
+       return 0;
+}
+
+static void atl1_get_ringparam(struct net_device *netdev,
+                           struct ethtool_ringparam *ring)
+{
+       struct atl1_adapter *adapter = netdev_priv(netdev);
+       struct atl1_tpd_ring *txdr = &adapter->tpd_ring;
+       struct atl1_rfd_ring *rxdr = &adapter->rfd_ring;
+
+       ring->rx_max_pending = ATL1_MAX_RFD;
+       ring->tx_max_pending = ATL1_MAX_TPD;
+       ring->rx_mini_max_pending = 0;
+       ring->rx_jumbo_max_pending = 0;
+       ring->rx_pending = rxdr->count;
+       ring->tx_pending = txdr->count;
+       ring->rx_mini_pending = 0;
+       ring->rx_jumbo_pending = 0;
+}
+
+static int atl1_set_ringparam(struct net_device *netdev,
+                               struct ethtool_ringparam *ring)
+{
+       struct atl1_adapter *adapter = netdev_priv(netdev);
+       struct atl1_tpd_ring *tpdr = &adapter->tpd_ring;
+       struct atl1_rrd_ring *rrdr = &adapter->rrd_ring;
+       struct atl1_rfd_ring *rfdr = &adapter->rfd_ring;
+
+       struct atl1_tpd_ring tpd_old, tpd_new;
+       struct atl1_rfd_ring rfd_old, rfd_new;
+       struct atl1_rrd_ring rrd_old, rrd_new;
+       struct atl1_ring_header rhdr_old, rhdr_new;
+       int err;
+
+       tpd_old = adapter->tpd_ring;
+       rfd_old = adapter->rfd_ring;
+       rrd_old = adapter->rrd_ring;
+       rhdr_old = adapter->ring_header;
+
+       if (netif_running(adapter->netdev))
+               atl1_down(adapter);
+
+       rfdr->count = (u16) max(ring->rx_pending, (u32) ATL1_MIN_RFD);
+       rfdr->count = rfdr->count > ATL1_MAX_RFD ? ATL1_MAX_RFD :
+                       rfdr->count;
+       rfdr->count = (rfdr->count + 3) & ~3;
+       rrdr->count = rfdr->count;
+
+       tpdr->count = (u16) max(ring->tx_pending, (u32) ATL1_MIN_TPD);
+       tpdr->count = tpdr->count > ATL1_MAX_TPD ? ATL1_MAX_TPD :
+                       tpdr->count;
+       tpdr->count = (tpdr->count + 3) & ~3;
+
+       if (netif_running(adapter->netdev)) {
+               /* try to get new resources before deleting old */
+               err = atl1_setup_ring_resources(adapter);
+               if (err)
+                       goto err_setup_ring;
+
+               /*
+                * save the new, restore the old in order to free it,
+                * then restore the new back again
+                */
+
+               rfd_new = adapter->rfd_ring;
+               rrd_new = adapter->rrd_ring;
+               tpd_new = adapter->tpd_ring;
+               rhdr_new = adapter->ring_header;
+               adapter->rfd_ring = rfd_old;
+               adapter->rrd_ring = rrd_old;
+               adapter->tpd_ring = tpd_old;
+               adapter->ring_header = rhdr_old;
+               atl1_free_ring_resources(adapter);
+               adapter->rfd_ring = rfd_new;
+               adapter->rrd_ring = rrd_new;
+               adapter->tpd_ring = tpd_new;
+               adapter->ring_header = rhdr_new;
+
+               err = atl1_up(adapter);
+               if (err)
+                       return err;
+       }
+       return 0;
+
+err_setup_ring:
+       adapter->rfd_ring = rfd_old;
+       adapter->rrd_ring = rrd_old;
+       adapter->tpd_ring = tpd_old;
+       adapter->ring_header = rhdr_old;
+       atl1_up(adapter);
+       return err;
+}
+
+static void atl1_get_pauseparam(struct net_device *netdev,
+                            struct ethtool_pauseparam *epause)
+{
+       struct atl1_adapter *adapter = netdev_priv(netdev);
+       struct atl1_hw *hw = &adapter->hw;
+
+       if (hw->media_type == MEDIA_TYPE_AUTO_SENSOR ||
+           hw->media_type == MEDIA_TYPE_1000M_FULL) {
+               epause->autoneg = AUTONEG_ENABLE;
+       } else {
+               epause->autoneg = AUTONEG_DISABLE;
+       }
+       epause->rx_pause = 1;
+       epause->tx_pause = 1;
+}
+
+static int atl1_set_pauseparam(struct net_device *netdev,
+                            struct ethtool_pauseparam *epause)
+{
+       struct atl1_adapter *adapter = netdev_priv(netdev);
+       struct atl1_hw *hw = &adapter->hw;
+
+       if (hw->media_type == MEDIA_TYPE_AUTO_SENSOR ||
+           hw->media_type == MEDIA_TYPE_1000M_FULL) {
+               epause->autoneg = AUTONEG_ENABLE;
+       } else {
+               epause->autoneg = AUTONEG_DISABLE;
+       }
+
+       epause->rx_pause = 1;
+       epause->tx_pause = 1;
+
+       return 0;
+}
+
+static u32 atl1_get_rx_csum(struct net_device *netdev)
+{
+       return 1;
+}
+
+static void atl1_get_strings(struct net_device *netdev, u32 stringset,
+                               u8 *data)
+{
+       u8 *p = data;
+       int i;
+
+       switch (stringset) {
+       case ETH_SS_STATS:
+               for (i = 0; i < ARRAY_SIZE(atl1_gstrings_stats); i++) {
+                       memcpy(p, atl1_gstrings_stats[i].stat_string,
+                               ETH_GSTRING_LEN);
+                       p += ETH_GSTRING_LEN;
+               }
+               break;
+       }
+}
+
+static int atl1_nway_reset(struct net_device *netdev)
+{
+       struct atl1_adapter *adapter = netdev_priv(netdev);
+       struct atl1_hw *hw = &adapter->hw;
+
+       if (netif_running(netdev)) {
+               u16 phy_data;
+               atl1_down(adapter);
+
+               if (hw->media_type == MEDIA_TYPE_AUTO_SENSOR ||
+                       hw->media_type == MEDIA_TYPE_1000M_FULL) {
+                       phy_data = MII_CR_RESET | MII_CR_AUTO_NEG_EN;
+               } else {
+                       switch (hw->media_type) {
+                       case MEDIA_TYPE_100M_FULL:
+                               phy_data = MII_CR_FULL_DUPLEX |
+                                       MII_CR_SPEED_100 | MII_CR_RESET;
+                               break;
+                       case MEDIA_TYPE_100M_HALF:
+                               phy_data = MII_CR_SPEED_100 | MII_CR_RESET;
+                               break;
+                       case MEDIA_TYPE_10M_FULL:
+                               phy_data = MII_CR_FULL_DUPLEX |
+                                       MII_CR_SPEED_10 | MII_CR_RESET;
+                               break;
+                       default:  /* MEDIA_TYPE_10M_HALF */
+                               phy_data = MII_CR_SPEED_10 | MII_CR_RESET;
+                       }
+               }
+               atl1_write_phy_reg(hw, MII_BMCR, phy_data);
+               atl1_up(adapter);
+       }
+       return 0;
+}
+
+const struct ethtool_ops atl1_ethtool_ops = {
+       .get_settings           = atl1_get_settings,
+       .set_settings           = atl1_set_settings,
+       .get_drvinfo            = atl1_get_drvinfo,
+       .get_wol                = atl1_get_wol,
+       .set_wol                = atl1_set_wol,
+       .get_ringparam          = atl1_get_ringparam,
+       .set_ringparam          = atl1_set_ringparam,
+       .get_pauseparam         = atl1_get_pauseparam,
+       .set_pauseparam         = atl1_set_pauseparam,
+       .get_rx_csum            = atl1_get_rx_csum,
+       .get_tx_csum            = ethtool_op_get_tx_csum,
+       .set_tx_csum            = ethtool_op_set_tx_hw_csum,
+       .get_link               = ethtool_op_get_link,
+       .get_sg                 = ethtool_op_get_sg,
+       .set_sg                 = ethtool_op_set_sg,
+       .get_strings            = atl1_get_strings,
+       .nway_reset             = atl1_nway_reset,
+       .get_ethtool_stats      = atl1_get_ethtool_stats,
+       .get_stats_count        = atl1_get_stats_count,
+       .get_tso                = ethtool_op_get_tso,
+       .set_tso                = ethtool_op_set_tso,
+};
diff --git a/drivers/net/atl1/atl1_hw.c b/drivers/net/atl1/atl1_hw.c
new file mode 100644 (file)
index 0000000..08b2d78
--- /dev/null
@@ -0,0 +1,718 @@
+/*
+ * Copyright(c) 2005 - 2006 Attansic Corporation. All rights reserved.
+ * Copyright(c) 2006 Chris Snook <csnook@redhat.com>
+ * Copyright(c) 2006 Jay Cliburn <jcliburn@gmail.com>
+ * 
+ * Derived from Intel e1000 driver
+ * Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved.
+ * 
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ * 
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ * 
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59
+ * Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+#include <linux/types.h>
+#include <linux/pci.h>
+#include <linux/delay.h>
+#include <linux/if_vlan.h>
+#include <linux/etherdevice.h>
+#include <linux/crc32.h>
+#include <asm/byteorder.h>
+
+#include "atl1.h"
+
+/*
+ * Reset the transmit and receive units; mask and clear all interrupts.
+ * hw - Struct containing variables accessed by shared code
+ * return : ATL1_SUCCESS  or  idle status (if error)
+ */
+s32 atl1_reset_hw(struct atl1_hw *hw)
+{
+       u32 icr;
+       int i;
+
+       /* 
+        * Clear Interrupt mask to stop board from generating
+        * interrupts & Clear any pending interrupt events 
+        */
+       /*
+        * iowrite32(0, hw->hw_addr + REG_IMR);
+        * iowrite32(0xffffffff, hw->hw_addr + REG_ISR);
+        */
+
+       /*
+        * Issue Soft Reset to the MAC.  This will reset the chip's
+        * transmit, receive, DMA.  It will not effect
+        * the current PCI configuration.  The global reset bit is self-
+        * clearing, and should clear within a microsecond.
+        */
+       iowrite32(MASTER_CTRL_SOFT_RST, hw->hw_addr + REG_MASTER_CTRL);
+       ioread32(hw->hw_addr + REG_MASTER_CTRL);
+
+       iowrite16(1, hw->hw_addr + REG_GPHY_ENABLE);
+       ioread16(hw->hw_addr + REG_GPHY_ENABLE);
+
+       msleep(1);              /* delay about 1ms */
+
+       /* Wait at least 10ms for All module to be Idle */
+       for (i = 0; i < 10; i++) {
+               icr = ioread32(hw->hw_addr + REG_IDLE_STATUS);
+               if (!icr)
+                       break;
+               msleep(1);      /* delay 1 ms */
+               cpu_relax();    /* FIXME: is this still the right way to do this? */
+       }
+
+       if (icr) {
+               printk (KERN_DEBUG "icr = %x\n", icr); 
+               return icr;
+       }
+
+       return ATL1_SUCCESS;
+}
+
+/* function about EEPROM
+ *
+ * check_eeprom_exist
+ * return 0 if eeprom exist
+ */
+static int atl1_check_eeprom_exist(struct atl1_hw *hw)
+{
+       u32 value;
+       value = ioread32(hw->hw_addr + REG_SPI_FLASH_CTRL);
+       if (value & SPI_FLASH_CTRL_EN_VPD) {
+               value &= ~SPI_FLASH_CTRL_EN_VPD;
+               iowrite32(value, hw->hw_addr + REG_SPI_FLASH_CTRL);
+       }
+
+       value = ioread16(hw->hw_addr + REG_PCIE_CAP_LIST);
+       return ((value & 0xFF00) == 0x6C00) ? 0 : 1;
+}
+
+static bool atl1_read_eeprom(struct atl1_hw *hw, u32 offset, u32 *p_value)
+{
+       int i;
+       u32 control;
+
+       if (offset & 3)
+               return false;   /* address do not align */
+
+       iowrite32(0, hw->hw_addr + REG_VPD_DATA);
+       control = (offset & VPD_CAP_VPD_ADDR_MASK) << VPD_CAP_VPD_ADDR_SHIFT;
+       iowrite32(control, hw->hw_addr + REG_VPD_CAP);
+       ioread32(hw->hw_addr + REG_VPD_CAP);
+
+       for (i = 0; i < 10; i++) {
+               msleep(2);
+               control = ioread32(hw->hw_addr + REG_VPD_CAP);
+               if (control & VPD_CAP_VPD_FLAG)
+                       break;
+       }
+       if (control & VPD_CAP_VPD_FLAG) {
+               *p_value = ioread32(hw->hw_addr + REG_VPD_DATA);
+               return true;
+       }
+       return false;           /* timeout */
+}
+
+/*
+ * Reads the value from a PHY register
+ * hw - Struct containing variables accessed by shared code
+ * reg_addr - address of the PHY register to read
+ */
+s32 atl1_read_phy_reg(struct atl1_hw *hw, u16 reg_addr, u16 *phy_data)
+{
+       u32 val;
+       int i;
+
+       val = ((u32) (reg_addr & MDIO_REG_ADDR_MASK)) << MDIO_REG_ADDR_SHIFT |
+               MDIO_START | MDIO_SUP_PREAMBLE | MDIO_RW | MDIO_CLK_25_4 <<
+               MDIO_CLK_SEL_SHIFT;
+       iowrite32(val, hw->hw_addr + REG_MDIO_CTRL);
+       ioread32(hw->hw_addr + REG_MDIO_CTRL);
+
+       for (i = 0; i < MDIO_WAIT_TIMES; i++) {
+               udelay(2);
+               val = ioread32(hw->hw_addr + REG_MDIO_CTRL);
+               if (!(val & (MDIO_START | MDIO_BUSY)))
+                       break;
+       }
+       if (!(val & (MDIO_START | MDIO_BUSY))) {
+               *phy_data = (u16) val;
+               return ATL1_SUCCESS;
+       }
+       return ATL1_ERR_PHY;
+}
+
+#define CUSTOM_SPI_CS_SETUP    2
+#define CUSTOM_SPI_CLK_HI      2
+#define CUSTOM_SPI_CLK_LO      2
+#define CUSTOM_SPI_CS_HOLD     2
+#define CUSTOM_SPI_CS_HI       3
+
+static bool atl1_spi_read(struct atl1_hw *hw, u32 addr, u32 *buf)
+{
+       int i;
+       u32 value;
+
+       iowrite32(0, hw->hw_addr + REG_SPI_DATA);
+       iowrite32(addr, hw->hw_addr + REG_SPI_ADDR);
+
+       value = SPI_FLASH_CTRL_WAIT_READY |
+           (CUSTOM_SPI_CS_SETUP & SPI_FLASH_CTRL_CS_SETUP_MASK) <<
+           SPI_FLASH_CTRL_CS_SETUP_SHIFT | (CUSTOM_SPI_CLK_HI &
+                                            SPI_FLASH_CTRL_CLK_HI_MASK) <<
+           SPI_FLASH_CTRL_CLK_HI_SHIFT | (CUSTOM_SPI_CLK_LO &
+                                          SPI_FLASH_CTRL_CLK_LO_MASK) <<
+           SPI_FLASH_CTRL_CLK_LO_SHIFT | (CUSTOM_SPI_CS_HOLD &
+                                          SPI_FLASH_CTRL_CS_HOLD_MASK) <<
+           SPI_FLASH_CTRL_CS_HOLD_SHIFT | (CUSTOM_SPI_CS_HI &
+                                           SPI_FLASH_CTRL_CS_HI_MASK) <<
+           SPI_FLASH_CTRL_CS_HI_SHIFT | (1 & SPI_FLASH_CTRL_INS_MASK) <<
+           SPI_FLASH_CTRL_INS_SHIFT;
+
+       iowrite32(value, hw->hw_addr + REG_SPI_FLASH_CTRL);
+
+       value |= SPI_FLASH_CTRL_START;
+       iowrite32(value, hw->hw_addr + REG_SPI_FLASH_CTRL);
+       ioread32(hw->hw_addr + REG_SPI_FLASH_CTRL);
+
+       for (i = 0; i < 10; i++) {
+               msleep(1);      /* 1ms */
+               value = ioread32(hw->hw_addr + REG_SPI_FLASH_CTRL);
+               if (!(value & SPI_FLASH_CTRL_START))
+                       break;
+       }
+
+       if (value & SPI_FLASH_CTRL_START)
+               return false;
+
+       *buf = ioread32(hw->hw_addr + REG_SPI_DATA);
+
+       return true;
+}
+
+/*
+ * get_permanent_address
+ * return 0 if get valid mac address, 
+ */
+static int atl1_get_permanent_address(struct atl1_hw *hw)
+{
+       u32 addr[2];
+       u32 i, control;
+       u16 reg;
+       u8 eth_addr[ETH_ALEN];
+       bool key_valid;
+
+       if (is_valid_ether_addr(hw->perm_mac_addr))
+               return 0;
+
+       /* init */
+       addr[0] = addr[1] = 0;
+
+       if (!atl1_check_eeprom_exist(hw)) {     /* eeprom exist */
+               reg = 0;
+               key_valid = false;
+               /* Read out all EEPROM content */
+               i = 0;
+               while (1) {
+                       if (atl1_read_eeprom(hw, i + 0x100, &control)) {
+                               if (key_valid) {
+                                       if (reg == REG_MAC_STA_ADDR)
+                                               addr[0] = control;
+                                       else if (reg == (REG_MAC_STA_ADDR + 4))
+                                               addr[1] = control;
+                                       key_valid = false;
+                               } else if ((control & 0xff) == 0x5A) {
+                                       key_valid = true;
+                                       reg = (u16) (control >> 16);
+                               } else
+                                       break;  /* assume data end while encount an invalid KEYWORD */
+                       } else
+                               break;  /* read error */
+                       i += 4;
+               }
+
+/*
+ * The following 2 lines are the Attansic originals.  Saving for posterity.
+ *             *(u32 *) & eth_addr[2] = LONGSWAP(addr[0]);
+ *             *(u16 *) & eth_addr[0] = SHORTSWAP(*(u16 *) & addr[1]);
+ */
+               *(u32 *) & eth_addr[2] = swab32(addr[0]);
+               *(u16 *) & eth_addr[0] = swab16(*(u16 *) & addr[1]);
+
+               if (is_valid_ether_addr(eth_addr)) {
+                       memcpy(hw->perm_mac_addr, eth_addr, ETH_ALEN);
+                       return 0;
+               }
+               return 1;
+       }
+
+       /* see if SPI FLAGS exist ? */
+       addr[0] = addr[1] = 0;
+       reg = 0;
+       key_valid = false;
+       i = 0;
+       while (1) {
+               if (atl1_spi_read(hw, i + 0x1f000, &control)) {
+                       if (key_valid) {
+                               if (reg == REG_MAC_STA_ADDR)
+                                       addr[0] = control;
+                               else if (reg == (REG_MAC_STA_ADDR + 4))
+                                       addr[1] = control;
+                               key_valid = false;
+                       } else if ((control & 0xff) == 0x5A) {
+                               key_valid = true;
+                               reg = (u16) (control >> 16);
+                       } else
+                               break;  /* data end */
+               } else
+                       break;  /* read error */
+               i += 4;
+       }
+
+/*
+ * The following 2 lines are the Attansic originals.  Saving for posterity.
+ *     *(u32 *) & eth_addr[2] = LONGSWAP(addr[0]);
+ *     *(u16 *) & eth_addr[0] = SHORTSWAP(*(u16 *) & addr[1]);
+ */
+       *(u32 *) & eth_addr[2] = swab32(addr[0]);
+       *(u16 *) & eth_addr[0] = swab16(*(u16 *) & addr[1]);
+       if (is_valid_ether_addr(eth_addr)) {
+               memcpy(hw->perm_mac_addr, eth_addr, ETH_ALEN);
+               return 0;
+       }
+       return 1;
+}
+
+/*
+ * Reads the adapter's MAC address from the EEPROM 
+ * hw - Struct containing variables accessed by shared code
+ */
+s32 atl1_read_mac_addr(struct atl1_hw *hw)
+{
+       u16 i;
+
+       if (atl1_get_permanent_address(hw))
+               random_ether_addr(hw->perm_mac_addr);
+
+       for (i = 0; i < ETH_ALEN; i++)
+               hw->mac_addr[i] = hw->perm_mac_addr[i];
+       return ATL1_SUCCESS;
+}
+
+/*
+ * Hashes an address to determine its location in the multicast table
+ * hw - Struct containing variables accessed by shared code
+ * mc_addr - the multicast address to hash
+ *
+ * atl1_hash_mc_addr
+ *  purpose
+ *      set hash value for a multicast address
+ *      hash calcu processing :
+ *          1. calcu 32bit CRC for multicast address
+ *          2. reverse crc with MSB to LSB
+ */
+u32 atl1_hash_mc_addr(struct atl1_hw *hw, u8 *mc_addr)
+{
+       u32 crc32, value = 0;
+       int i;
+
+       crc32 = ether_crc_le(6, mc_addr);
+       crc32 = ~crc32;
+       for (i = 0; i < 32; i++)
+               value |= (((crc32 >> i) & 1) << (31 - i));
+
+       return value;
+}
+
+/*
+ * Sets the bit in the multicast table corresponding to the hash value.
+ * hw - Struct containing variables accessed by shared code
+ * hash_value - Multicast address hash value
+ */
+void atl1_hash_set(struct atl1_hw *hw, u32 hash_value)
+{
+       u32 hash_bit, hash_reg;
+       u32 mta;
+
+       /*
+        * The HASH Table  is a register array of 2 32-bit registers.
+        * It is treated like an array of 64 bits.  We want to set
+        * bit BitArray[hash_value]. So we figure out what register
+        * the bit is in, read it, OR in the new bit, then write
+        * back the new value.  The register is determined by the
+        * upper 7 bits of the hash value and the bit within that
+        * register are determined by the lower 5 bits of the value.
+        */
+       hash_reg = (hash_value >> 31) & 0x1;
+       hash_bit = (hash_value >> 26) & 0x1F;
+       mta = ioread32((hw + REG_RX_HASH_TABLE) + (hash_reg << 2));
+       mta |= (1 << hash_bit);
+       iowrite32(mta, (hw->hw_addr + REG_RX_HASH_TABLE) + (hash_reg << 2));
+}
+
+/*
+ * Writes a value to a PHY register
+ * hw - Struct containing variables accessed by shared code
+ * reg_addr - address of the PHY register to write
+ * data - data to write to the PHY
+ */
+s32 atl1_write_phy_reg(struct atl1_hw *hw, u32 reg_addr, u16 phy_data)
+{
+       int i;
+       u32 val;
+
+       val = ((u32) (phy_data & MDIO_DATA_MASK)) << MDIO_DATA_SHIFT |
+           (reg_addr & MDIO_REG_ADDR_MASK) << MDIO_REG_ADDR_SHIFT |
+           MDIO_SUP_PREAMBLE |
+           MDIO_START | MDIO_CLK_25_4 << MDIO_CLK_SEL_SHIFT;
+       iowrite32(val, hw->hw_addr + REG_MDIO_CTRL);
+       ioread32(hw->hw_addr + REG_MDIO_CTRL);
+
+       for (i = 0; i < MDIO_WAIT_TIMES; i++) {
+               udelay(2);
+               val = ioread32(hw->hw_addr + REG_MDIO_CTRL);
+               if (!(val & (MDIO_START | MDIO_BUSY)))
+                       break;
+       }
+
+       if (!(val & (MDIO_START | MDIO_BUSY)))
+               return ATL1_SUCCESS;
+
+       return ATL1_ERR_PHY;
+}
+
+/*
+ * Make L001's PHY out of Power Saving State (bug)
+ * hw - Struct containing variables accessed by shared code
+ * when power on, L001's PHY always on Power saving State
+ * (Gigabit Link forbidden)
+ */
+static s32 atl1_phy_leave_power_saving(struct atl1_hw *hw)
+{
+       s32 ret;
+       ret = atl1_write_phy_reg(hw, 29, 0x0029);
+       if (ret)
+               return ret;
+       return atl1_write_phy_reg(hw, 30, 0);
+}
+
+/*
+ *TODO: do something or get rid of this
+ */
+s32 atl1_phy_enter_power_saving(struct atl1_hw *hw)
+{
+/*    s32 ret_val;
+ *    u16 phy_data;
+ */
+
+/*
+    ret_val = atl1_write_phy_reg(hw, ...);
+    ret_val = atl1_write_phy_reg(hw, ...);
+    ....
+*/
+       return ATL1_SUCCESS;
+}
+
+/*
+ * Resets the PHY and make all config validate
+ * hw - Struct containing variables accessed by shared code
+ *
+ * Sets bit 15 and 12 of the MII Control regiser (for F001 bug)
+ */
+static s32 atl1_phy_reset(struct atl1_hw *hw)
+{
+       s32 ret_val;
+       u16 phy_data;
+
+       if (hw->media_type == MEDIA_TYPE_AUTO_SENSOR ||
+           hw->media_type == MEDIA_TYPE_1000M_FULL)
+               phy_data = MII_CR_RESET | MII_CR_AUTO_NEG_EN;
+       else {
+               switch (hw->media_type) {
+               case MEDIA_TYPE_100M_FULL:
+                       phy_data =
+                           MII_CR_FULL_DUPLEX | MII_CR_SPEED_100 |
+                           MII_CR_RESET;
+                       break;
+               case MEDIA_TYPE_100M_HALF:
+                       phy_data = MII_CR_SPEED_100 | MII_CR_RESET;
+                       break;
+               case MEDIA_TYPE_10M_FULL:
+                       phy_data =
+                           MII_CR_FULL_DUPLEX | MII_CR_SPEED_10 | MII_CR_RESET;
+                       break;
+               default:        /* MEDIA_TYPE_10M_HALF: */
+                       phy_data = MII_CR_SPEED_10 | MII_CR_RESET;
+                       break;
+               }
+       }
+
+       ret_val = atl1_write_phy_reg(hw, MII_BMCR, phy_data);
+       if (ret_val) {
+               u32 val;
+               int i;
+               /* pcie serdes link may be down! */
+               printk(KERN_DEBUG "%s: autoneg caused pcie phy link down\n", 
+                       atl1_driver_name);
+
+               for (i = 0; i < 25; i++) {
+                       msleep(1);
+                       val = ioread32(hw->hw_addr + REG_MDIO_CTRL);
+                       if (!(val & (MDIO_START | MDIO_BUSY)))
+                               break;
+               }
+
+               if ((val & (MDIO_START | MDIO_BUSY)) != 0) {
+                       printk(KERN_WARNING 
+                               "%s: pcie link down at least for 25ms\n", 
+                               atl1_driver_name);
+                       return ret_val;
+               }
+       }
+       return ATL1_SUCCESS;
+}
+
+/*
+ * Configures PHY autoneg and flow control advertisement settings
+ * hw - Struct containing variables accessed by shared code
+ */
+s32 atl1_phy_setup_autoneg_adv(struct atl1_hw *hw)
+{
+       s32 ret_val;
+       s16 mii_autoneg_adv_reg;
+       s16 mii_1000t_ctrl_reg;
+
+       /* Read the MII Auto-Neg Advertisement Register (Address 4). */
+       mii_autoneg_adv_reg = MII_AR_DEFAULT_CAP_MASK;
+
+       /* Read the MII 1000Base-T Control Register (Address 9). */
+       mii_1000t_ctrl_reg = MII_AT001_CR_1000T_DEFAULT_CAP_MASK;
+
+       /*
+        * First we clear all the 10/100 mb speed bits in the Auto-Neg
+        * Advertisement Register (Address 4) and the 1000 mb speed bits in
+        * the  1000Base-T Control Register (Address 9).
+        */
+       mii_autoneg_adv_reg &= ~MII_AR_SPEED_MASK;
+       mii_1000t_ctrl_reg &= ~MII_AT001_CR_1000T_SPEED_MASK;
+
+       /*
+        * Need to parse media_type  and set up
+        * the appropriate PHY registers.
+        */
+       switch (hw->media_type) {
+       case MEDIA_TYPE_AUTO_SENSOR:
+               mii_autoneg_adv_reg |= (MII_AR_10T_HD_CAPS |
+                                       MII_AR_10T_FD_CAPS |
+                                       MII_AR_100TX_HD_CAPS |
+                                       MII_AR_100TX_FD_CAPS);
+               mii_1000t_ctrl_reg |= MII_AT001_CR_1000T_FD_CAPS;
+               break;
+
+       case MEDIA_TYPE_1000M_FULL:
+               mii_1000t_ctrl_reg |= MII_AT001_CR_1000T_FD_CAPS;
+               break;
+
+       case MEDIA_TYPE_100M_FULL:
+               mii_autoneg_adv_reg |= MII_AR_100TX_FD_CAPS;
+               break;
+
+       case MEDIA_TYPE_100M_HALF:
+               mii_autoneg_adv_reg |= MII_AR_100TX_HD_CAPS;
+               break;
+
+       case MEDIA_TYPE_10M_FULL:
+               mii_autoneg_adv_reg |= MII_AR_10T_FD_CAPS;
+               break;
+
+       default:
+               mii_autoneg_adv_reg |= MII_AR_10T_HD_CAPS;
+               break;
+       }
+
+       /* flow control fixed to enable all */
+       mii_autoneg_adv_reg |= (MII_AR_ASM_DIR | MII_AR_PAUSE);
+
+       hw->mii_autoneg_adv_reg = mii_autoneg_adv_reg;
+       hw->mii_1000t_ctrl_reg = mii_1000t_ctrl_reg;
+
+       ret_val = atl1_write_phy_reg(hw, MII_ADVERTISE, mii_autoneg_adv_reg);
+       if (ret_val)
+               return ret_val;
+
+       ret_val = atl1_write_phy_reg(hw, MII_AT001_CR, mii_1000t_ctrl_reg);
+       if (ret_val)
+               return ret_val;
+
+       return ATL1_SUCCESS;
+}
+
+/*
+ * Configures link settings.
+ * hw - Struct containing variables accessed by shared code
+ * Assumes the hardware has previously been reset and the
+ * transmitter and receiver are not enabled.
+ */
+static s32 atl1_setup_link(struct atl1_hw *hw)
+{
+       s32 ret_val;
+
+       /*
+        * Options:
+        *  PHY will advertise value(s) parsed from
+        *  autoneg_advertised and fc
+        *  no matter what autoneg is , We will not wait link result.
+        */
+       ret_val = atl1_phy_setup_autoneg_adv(hw);
+       if (ret_val) {
+               printk(KERN_DEBUG "%s: error setting up autonegotiation\n", 
+                       atl1_driver_name);
+               return ret_val;
+       }
+       /* SW.Reset , En-Auto-Neg if needed */
+       ret_val = atl1_phy_reset(hw);
+       if (ret_val) {
+               printk(KERN_DEBUG "%s: error resetting the phy\n", 
+                       atl1_driver_name);
+               return ret_val;
+       }
+       hw->phy_configured = true;
+       return ret_val;
+}
+
+static struct atl1_spi_flash_dev flash_table[] = {
+/*     MFR_NAME  WRSR  READ  PRGM  WREN  WRDI  RDSR  RDID  SECTOR_ERASE CHIP_ERASE */
+       {"Atmel", 0x00, 0x03, 0x02, 0x06, 0x04, 0x05, 0x15, 0x52,        0x62},
+       {"SST",   0x01, 0x03, 0x02, 0x06, 0x04, 0x05, 0x90, 0x20,        0x60},
+       {"ST",    0x01, 0x03, 0x02, 0x06, 0x04, 0x05, 0xAB, 0xD8,        0xC7},
+};
+
+static void atl1_init_flash_opcode(struct atl1_hw *hw)
+{
+       if (hw->flash_vendor >= sizeof(flash_table) / sizeof(flash_table[0]))
+               hw->flash_vendor = 0;   /* ATMEL */
+
+       /* Init OP table */
+       iowrite8(flash_table[hw->flash_vendor].cmd_program,
+               hw->hw_addr + REG_SPI_FLASH_OP_PROGRAM);
+       iowrite8(flash_table[hw->flash_vendor].cmd_sector_erase,
+               hw->hw_addr + REG_SPI_FLASH_OP_SC_ERASE);
+       iowrite8(flash_table[hw->flash_vendor].cmd_chip_erase,
+               hw->hw_addr + REG_SPI_FLASH_OP_CHIP_ERASE);
+       iowrite8(flash_table[hw->flash_vendor].cmd_rdid,
+               hw->hw_addr + REG_SPI_FLASH_OP_RDID);
+       iowrite8(flash_table[hw->flash_vendor].cmd_wren,
+               hw->hw_addr + REG_SPI_FLASH_OP_WREN);
+       iowrite8(flash_table[hw->flash_vendor].cmd_rdsr,
+               hw->hw_addr + REG_SPI_FLASH_OP_RDSR);
+       iowrite8(flash_table[hw->flash_vendor].cmd_wrsr,
+               hw->hw_addr + REG_SPI_FLASH_OP_WRSR);
+       iowrite8(flash_table[hw->flash_vendor].cmd_read,
+               hw->hw_addr + REG_SPI_FLASH_OP_READ);
+}
+
+/*
+ * Performs basic configuration of the adapter.
+ * hw - Struct containing variables accessed by shared code
+ * Assumes that the controller has previously been reset and is in a
+ * post-reset uninitialized state. Initializes multicast table, 
+ * and  Calls routines to setup link
+ * Leaves the transmit and receive units disabled and uninitialized.
+ */
+s32 atl1_init_hw(struct atl1_hw *hw)
+{
+       u32 ret_val = 0;
+
+       /* Zero out the Multicast HASH table */
+       iowrite32(0, hw->hw_addr + REG_RX_HASH_TABLE);
+       /* clear the old settings from the multicast hash table */
+       iowrite32(0, (hw->hw_addr + REG_RX_HASH_TABLE) + (1 << 2));
+
+       atl1_init_flash_opcode(hw);
+
+       if (!hw->phy_configured) {
+               /* enable GPHY LinkChange Interrrupt */
+               ret_val = atl1_write_phy_reg(hw, 18, 0xC00);
+               if (ret_val)
+                       return ret_val;
+               /* make PHY out of power-saving state */
+               ret_val = atl1_phy_leave_power_saving(hw);
+               if (ret_val)
+                       return ret_val;
+               /* Call a subroutine to configure the link */
+               ret_val = atl1_setup_link(hw);
+       }
+       return ret_val;
+}
+
+/*
+ * Detects the current speed and duplex settings of the hardware.
+ * hw - Struct containing variables accessed by shared code
+ * speed - Speed of the connection
+ * duplex - Duplex setting of the connection
+ */
+s32 atl1_get_speed_and_duplex(struct atl1_hw *hw, u16 *speed, u16 *duplex)
+{
+       s32 ret_val;
+       u16 phy_data;
+
+       /* ; --- Read   PHY Specific Status Register (17) */
+       ret_val = atl1_read_phy_reg(hw, MII_AT001_PSSR, &phy_data);
+       if (ret_val)
+               return ret_val;
+
+       if (!(phy_data & MII_AT001_PSSR_SPD_DPLX_RESOLVED))
+               return ATL1_ERR_PHY_RES;
+
+       switch (phy_data & MII_AT001_PSSR_SPEED) {
+       case MII_AT001_PSSR_1000MBS:
+               *speed = SPEED_1000;
+               break;
+       case MII_AT001_PSSR_100MBS:
+               *speed = SPEED_100;
+               break;
+       case MII_AT001_PSSR_10MBS:
+               *speed = SPEED_10;
+               break;
+       default:
+               printk(KERN_DEBUG "%s: error getting speed\n", 
+                       atl1_driver_name);
+               return ATL1_ERR_PHY_SPEED;
+               break;
+       }
+       if (phy_data & MII_AT001_PSSR_DPLX)
+               *duplex = FULL_DUPLEX;
+       else
+               *duplex = HALF_DUPLEX;
+
+       return ATL1_SUCCESS;
+}
+
+void atl1_set_mac_addr(struct atl1_hw *hw)
+{
+       u32 value;
+       /*
+        * 00-0B-6A-F6-00-DC
+        * 0:  6AF600DC   1: 000B
+        * low dword
+        */
+       value = (((u32) hw->mac_addr[2]) << 24) |
+           (((u32) hw->mac_addr[3]) << 16) |
+           (((u32) hw->mac_addr[4]) << 8) | (((u32) hw->mac_addr[5]));
+       iowrite32(value, hw->hw_addr + REG_MAC_STA_ADDR);
+       /* high dword */
+       value = (((u32) hw->mac_addr[0]) << 8) | (((u32) hw->mac_addr[1]));
+       iowrite32(value, (hw->hw_addr + REG_MAC_STA_ADDR) + (1 << 2));
+}
diff --git a/drivers/net/atl1/atl1_hw.h b/drivers/net/atl1/atl1_hw.h
new file mode 100644 (file)
index 0000000..100c09c
--- /dev/null
@@ -0,0 +1,951 @@
+/*
+ * Copyright(c) 2005 - 2006 Attansic Corporation. All rights reserved.
+ * Copyright(c) 2006 Chris Snook <csnook@redhat.com>
+ * Copyright(c) 2006 Jay Cliburn <jcliburn@gmail.com>
+ *
+ * Derived from Intel e1000 driver
+ * Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59
+ * Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * There are a lot of defines in here that are unused and/or have cryptic
+ * names.  Please leave them alone, as they're the closest thing we have
+ * to a spec from Attansic at present. *ahem* -- CHS
+ */
+
+#ifndef _ATL1_HW_H_
+#define _ATL1_HW_H_
+
+#include <linux/types.h>
+#include <linux/mii.h>
+
+struct atl1_adapter;
+struct atl1_hw;
+
+/* function prototypes needed by multiple files */
+s32 atl1_phy_setup_autoneg_adv(struct atl1_hw *hw);
+s32 atl1_write_phy_reg(struct atl1_hw *hw, u32 reg_addr, u16 phy_data);
+s32 atl1_get_speed_and_duplex(struct atl1_hw *hw, u16 *speed, u16 *duplex);
+s32 atl1_read_mac_addr(struct atl1_hw *hw);
+s32 atl1_init_hw(struct atl1_hw *hw);
+s32 atl1_get_speed_and_duplex(struct atl1_hw *hw, u16 *speed, u16 *duplex);
+s32 atl1_set_speed_and_duplex(struct atl1_hw *hw, u16 speed, u16 duplex);
+u32 atl1_hash_mc_addr(struct atl1_hw *hw, u8 *mc_addr);
+void atl1_hash_set(struct atl1_hw *hw, u32 hash_value);
+s32 atl1_read_phy_reg(struct atl1_hw *hw, u16 reg_addr, u16 *phy_data);
+void atl1_set_mac_addr(struct atl1_hw *hw);
+s32 atl1_phy_enter_power_saving(struct atl1_hw *hw);
+s32 atl1_reset_hw(struct atl1_hw *hw);
+void atl1_check_options(struct atl1_adapter *adapter);
+
+/* register definitions */
+#define REG_PCIE_CAP_LIST                      0x58
+
+#define REG_VPD_CAP                            0x6C
+#define VPD_CAP_ID_MASK                                0xff
+#define VPD_CAP_ID_SHIFT                       0
+#define VPD_CAP_NEXT_PTR_MASK                  0xFF
+#define VPD_CAP_NEXT_PTR_SHIFT                 8
+#define VPD_CAP_VPD_ADDR_MASK                  0x7FFF
+#define VPD_CAP_VPD_ADDR_SHIFT                 16
+#define VPD_CAP_VPD_FLAG                       0x80000000
+
+#define REG_VPD_DATA                           0x70
+
+#define REG_SPI_FLASH_CTRL                     0x200
+#define SPI_FLASH_CTRL_STS_NON_RDY             0x1
+#define SPI_FLASH_CTRL_STS_WEN                 0x2
+#define SPI_FLASH_CTRL_STS_WPEN                        0x80
+#define SPI_FLASH_CTRL_DEV_STS_MASK            0xFF
+#define SPI_FLASH_CTRL_DEV_STS_SHIFT           0
+#define SPI_FLASH_CTRL_INS_MASK                        0x7
+#define SPI_FLASH_CTRL_INS_SHIFT               8
+#define SPI_FLASH_CTRL_START                   0x800
+#define SPI_FLASH_CTRL_EN_VPD                  0x2000
+#define SPI_FLASH_CTRL_LDSTART                 0x8000
+#define SPI_FLASH_CTRL_CS_HI_MASK              0x3
+#define SPI_FLASH_CTRL_CS_HI_SHIFT             16
+#define SPI_FLASH_CTRL_CS_HOLD_MASK            0x3
+#define SPI_FLASH_CTRL_CS_HOLD_SHIFT           18
+#define SPI_FLASH_CTRL_CLK_LO_MASK             0x3
+#define SPI_FLASH_CTRL_CLK_LO_SHIFT            20
+#define SPI_FLASH_CTRL_CLK_HI_MASK             0x3
+#define SPI_FLASH_CTRL_CLK_HI_SHIFT            22
+#define SPI_FLASH_CTRL_CS_SETUP_MASK           0x3
+#define SPI_FLASH_CTRL_CS_SETUP_SHIFT          24
+#define SPI_FLASH_CTRL_EROM_PGSZ_MASK          0x3
+#define SPI_FLASH_CTRL_EROM_PGSZ_SHIFT         26
+#define SPI_FLASH_CTRL_WAIT_READY              0x10000000
+
+#define REG_SPI_ADDR                           0x204
+
+#define REG_SPI_DATA                           0x208
+
+#define REG_SPI_FLASH_CONFIG                   0x20C
+#define SPI_FLASH_CONFIG_LD_ADDR_MASK          0xFFFFFF
+#define SPI_FLASH_CONFIG_LD_ADDR_SHIFT         0
+#define SPI_FLASH_CONFIG_VPD_ADDR_MASK         0x3
+#define SPI_FLASH_CONFIG_VPD_ADDR_SHIFT                24
+#define SPI_FLASH_CONFIG_LD_EXIST              0x4000000
+
+#define REG_SPI_FLASH_OP_PROGRAM               0x210
+#define REG_SPI_FLASH_OP_SC_ERASE              0x211
+#define REG_SPI_FLASH_OP_CHIP_ERASE            0x212
+#define REG_SPI_FLASH_OP_RDID                  0x213
+#define REG_SPI_FLASH_OP_WREN                  0x214
+#define REG_SPI_FLASH_OP_RDSR                  0x215
+#define REG_SPI_FLASH_OP_WRSR                  0x216
+#define REG_SPI_FLASH_OP_READ                  0x217
+
+#define REG_TWSI_CTRL                          0x218
+#define TWSI_CTRL_LD_OFFSET_MASK               0xFF
+#define TWSI_CTRL_LD_OFFSET_SHIFT              0
+#define TWSI_CTRL_LD_SLV_ADDR_MASK             0x7
+#define TWSI_CTRL_LD_SLV_ADDR_SHIFT            8
+#define TWSI_CTRL_SW_LDSTART                   0x800
+#define TWSI_CTRL_HW_LDSTART                   0x1000
+#define TWSI_CTRL_SMB_SLV_ADDR_MASK            0x7F
+#define TWSI_CTRL_SMB_SLV_ADDR_SHIFT           15
+#define TWSI_CTRL_LD_EXIST                     0x400000
+#define TWSI_CTRL_READ_FREQ_SEL_MASK           0x3
+#define TWSI_CTRL_READ_FREQ_SEL_SHIFT          23
+#define TWSI_CTRL_FREQ_SEL_100K                        0
+#define TWSI_CTRL_FREQ_SEL_200K                        1
+#define TWSI_CTRL_FREQ_SEL_300K                        2
+#define TWSI_CTRL_FREQ_SEL_400K                        3
+#define TWSI_CTRL_SMB_SLV_ADDR
+#define TWSI_CTRL_WRITE_FREQ_SEL_MASK          0x3
+#define TWSI_CTRL_WRITE_FREQ_SEL_SHIFT         24
+
+#define REG_PCIE_DEV_MISC_CTRL                 0x21C
+#define PCIE_DEV_MISC_CTRL_EXT_PIPE            0x2
+#define PCIE_DEV_MISC_CTRL_RETRY_BUFDIS                0x1
+#define PCIE_DEV_MISC_CTRL_SPIROM_EXIST                0x4
+#define PCIE_DEV_MISC_CTRL_SERDES_ENDIAN       0x8
+#define PCIE_DEV_MISC_CTRL_SERDES_SEL_DIN      0x10
+
+/* Selene Master Control Register */
+#define REG_MASTER_CTRL                                0x1400
+#define MASTER_CTRL_SOFT_RST                   0x1
+#define MASTER_CTRL_MTIMER_EN                  0x2
+#define MASTER_CTRL_ITIMER_EN                  0x4
+#define MASTER_CTRL_MANUAL_INT                 0x8
+#define MASTER_CTRL_REV_NUM_SHIFT              16
+#define MASTER_CTRL_REV_NUM_MASK               0xff
+#define MASTER_CTRL_DEV_ID_SHIFT               24
+#define MASTER_CTRL_DEV_ID_MASK                        0xff
+
+/* Timer Initial Value Register */
+#define REG_MANUAL_TIMER_INIT                  0x1404
+
+/* IRQ ModeratorTimer Initial Value Register */
+#define REG_IRQ_MODU_TIMER_INIT                        0x1408
+
+#define REG_GPHY_ENABLE                                0x140C
+
+/* IRQ Anti-Lost Timer Initial Value Register */
+#define REG_CMBDISDMA_TIMER                    0x140E
+
+/* Block IDLE Status Register */
+#define REG_IDLE_STATUS                                0x1410
+#define IDLE_STATUS_RXMAC                      1
+#define IDLE_STATUS_TXMAC                      2
+#define IDLE_STATUS_RXQ                                4
+#define IDLE_STATUS_TXQ                                8
+#define IDLE_STATUS_DMAR                       0x10
+#define IDLE_STATUS_DMAW                       0x20
+#define IDLE_STATUS_SMB                                0x40
+#define IDLE_STATUS_CMB                                0x80
+
+/* MDIO Control Register */
+#define REG_MDIO_CTRL                          0x1414
+#define MDIO_DATA_MASK                         0xffff
+#define MDIO_DATA_SHIFT                                0
+#define MDIO_REG_ADDR_MASK                     0x1f
+#define MDIO_REG_ADDR_SHIFT                    16
+#define MDIO_RW                                        0x200000
+#define MDIO_SUP_PREAMBLE                      0x400000
+#define MDIO_START                             0x800000
+#define MDIO_CLK_SEL_SHIFT                     24
+#define MDIO_CLK_25_4                          0
+#define MDIO_CLK_25_6                          2
+#define MDIO_CLK_25_8                          3
+#define MDIO_CLK_25_10                         4
+#define MDIO_CLK_25_14                         5
+#define MDIO_CLK_25_20                         6
+#define MDIO_CLK_25_28                         7
+#define MDIO_BUSY                              0x8000000
+#define MDIO_WAIT_TIMES                                30
+
+/* MII PHY Status Register */
+#define REG_PHY_STATUS                         0x1418
+
+/* BIST Control and Status Register0 (for the Packet Memory) */
+#define REG_BIST0_CTRL                         0x141c
+#define BIST0_NOW                              0x1
+#define BIST0_SRAM_FAIL                                0x2
+#define BIST0_FUSE_FLAG                                0x4
+#define REG_BIST1_CTRL                         0x1420
+#define BIST1_NOW                              0x1
+#define BIST1_SRAM_FAIL                                0x2
+#define BIST1_FUSE_FLAG                                0x4
+
+/* MAC Control Register */
+#define REG_MAC_CTRL                           0x1480
+#define MAC_CTRL_TX_EN                         1
+#define MAC_CTRL_RX_EN                         2
+#define MAC_CTRL_TX_FLOW                       4
+#define MAC_CTRL_RX_FLOW                       8
+#define MAC_CTRL_LOOPBACK                      0x10
+#define MAC_CTRL_DUPLX                         0x20
+#define MAC_CTRL_ADD_CRC                       0x40
+#define MAC_CTRL_PAD                           0x80
+#define MAC_CTRL_LENCHK                                0x100
+#define MAC_CTRL_HUGE_EN                       0x200
+#define MAC_CTRL_PRMLEN_SHIFT                  10
+#define MAC_CTRL_PRMLEN_MASK                   0xf
+#define MAC_CTRL_RMV_VLAN                      0x4000
+#define MAC_CTRL_PROMIS_EN                     0x8000
+#define MAC_CTRL_TX_PAUSE                      0x10000
+#define MAC_CTRL_SCNT                          0x20000
+#define MAC_CTRL_SRST_TX                       0x40000
+#define MAC_CTRL_TX_SIMURST                    0x80000
+#define MAC_CTRL_SPEED_SHIFT                   20
+#define MAC_CTRL_SPEED_MASK                    0x300000
+#define MAC_CTRL_SPEED_1000                    2
+#define MAC_CTRL_SPEED_10_100                  1
+#define MAC_CTRL_DBG_TX_BKPRESURE              0x400000
+#define MAC_CTRL_TX_HUGE                       0x800000
+#define MAC_CTRL_RX_CHKSUM_EN                  0x1000000
+#define MAC_CTRL_MC_ALL_EN                     0x2000000
+#define MAC_CTRL_BC_EN                         0x4000000
+#define MAC_CTRL_DBG                           0x8000000
+
+/* MAC IPG/IFG Control Register */
+#define REG_MAC_IPG_IFG                                0x1484
+#define MAC_IPG_IFG_IPGT_SHIFT                 0
+#define MAC_IPG_IFG_IPGT_MASK                  0x7f
+#define MAC_IPG_IFG_MIFG_SHIFT                 8
+#define MAC_IPG_IFG_MIFG_MASK                  0xff
+#define MAC_IPG_IFG_IPGR1_SHIFT                        16
+#define MAC_IPG_IFG_IPGR1_MASK                 0x7f
+#define MAC_IPG_IFG_IPGR2_SHIFT                        24
+#define MAC_IPG_IFG_IPGR2_MASK                 0x7f
+
+/* MAC STATION ADDRESS */
+#define REG_MAC_STA_ADDR                       0x1488
+
+/* Hash table for multicast address */
+#define REG_RX_HASH_TABLE                      0x1490
+
+/* MAC Half-Duplex Control Register */
+#define REG_MAC_HALF_DUPLX_CTRL                        0x1498
+#define MAC_HALF_DUPLX_CTRL_LCOL_SHIFT         0
+#define MAC_HALF_DUPLX_CTRL_LCOL_MASK          0x3ff
+#define MAC_HALF_DUPLX_CTRL_RETRY_SHIFT                12
+#define MAC_HALF_DUPLX_CTRL_RETRY_MASK         0xf
+#define MAC_HALF_DUPLX_CTRL_EXC_DEF_EN         0x10000
+#define MAC_HALF_DUPLX_CTRL_NO_BACK_C          0x20000
+#define MAC_HALF_DUPLX_CTRL_NO_BACK_P          0x40000
+#define MAC_HALF_DUPLX_CTRL_ABEBE              0x80000
+#define MAC_HALF_DUPLX_CTRL_ABEBT_SHIFT                20
+#define MAC_HALF_DUPLX_CTRL_ABEBT_MASK         0xf
+#define MAC_HALF_DUPLX_CTRL_JAMIPG_SHIFT       24
+#define MAC_HALF_DUPLX_CTRL_JAMIPG_MASK                0xf
+
+/* Maximum Frame Length Control Register */
+#define REG_MTU                                        0x149c
+
+/* Wake-On-Lan control register */
+#define REG_WOL_CTRL                           0x14a0
+#define WOL_PATTERN_EN                         0x00000001
+#define WOL_PATTERN_PME_EN                     0x00000002
+#define WOL_MAGIC_EN                           0x00000004
+#define WOL_MAGIC_PME_EN                       0x00000008
+#define WOL_LINK_CHG_EN                                0x00000010
+#define WOL_LINK_CHG_PME_EN                    0x00000020
+#define WOL_PATTERN_ST                         0x00000100
+#define WOL_MAGIC_ST                           0x00000200
+#define WOL_LINKCHG_ST                         0x00000400
+#define WOL_CLK_SWITCH_EN                      0x00008000
+#define WOL_PT0_EN                             0x00010000
+#define WOL_PT1_EN                             0x00020000
+#define WOL_PT2_EN                             0x00040000
+#define WOL_PT3_EN                             0x00080000
+#define WOL_PT4_EN                             0x00100000
+#define WOL_PT5_EN                             0x00200000
+#define WOL_PT6_EN                             0x00400000
+
+/* WOL Length ( 2 DWORD ) */
+#define REG_WOL_PATTERN_LEN                    0x14a4
+#define WOL_PT_LEN_MASK                                0x7f
+#define WOL_PT0_LEN_SHIFT                      0
+#define WOL_PT1_LEN_SHIFT                      8
+#define WOL_PT2_LEN_SHIFT                      16
+#define WOL_PT3_LEN_SHIFT                      24
+#define WOL_PT4_LEN_SHIFT                      0
+#define WOL_PT5_LEN_SHIFT                      8
+#define WOL_PT6_LEN_SHIFT                      16
+
+/* Internal SRAM Partition Register */
+#define REG_SRAM_RFD_ADDR                      0x1500
+#define REG_SRAM_RFD_LEN                       (REG_SRAM_RFD_ADDR+ 4)
+#define REG_SRAM_RRD_ADDR                      (REG_SRAM_RFD_ADDR+ 8)
+#define REG_SRAM_RRD_LEN                       (REG_SRAM_RFD_ADDR+12)
+#define REG_SRAM_TPD_ADDR                      (REG_SRAM_RFD_ADDR+16)
+#define REG_SRAM_TPD_LEN                       (REG_SRAM_RFD_ADDR+20)
+#define REG_SRAM_TRD_ADDR                      (REG_SRAM_RFD_ADDR+24)
+#define REG_SRAM_TRD_LEN                       (REG_SRAM_RFD_ADDR+28)
+#define REG_SRAM_RXF_ADDR                      (REG_SRAM_RFD_ADDR+32)
+#define REG_SRAM_RXF_LEN                       (REG_SRAM_RFD_ADDR+36)
+#define REG_SRAM_TXF_ADDR                      (REG_SRAM_RFD_ADDR+40)
+#define REG_SRAM_TXF_LEN                       (REG_SRAM_RFD_ADDR+44)
+#define REG_SRAM_TCPH_PATH_ADDR                        (REG_SRAM_RFD_ADDR+48)
+#define SRAM_TCPH_ADDR_MASK                    0x0fff
+#define SRAM_TCPH_ADDR_SHIFT                   0
+#define SRAM_PATH_ADDR_MASK                    0x0fff
+#define SRAM_PATH_ADDR_SHIFT                   16
+
+/* Load Ptr Register */
+#define REG_LOAD_PTR                           (REG_SRAM_RFD_ADDR+52)
+
+/* Descriptor Control register */
+#define REG_DESC_BASE_ADDR_HI                  0x1540
+#define REG_DESC_RFD_ADDR_LO                   (REG_DESC_BASE_ADDR_HI+4)
+#define REG_DESC_RRD_ADDR_LO                   (REG_DESC_BASE_ADDR_HI+8)
+#define REG_DESC_TPD_ADDR_LO                   (REG_DESC_BASE_ADDR_HI+12)
+#define REG_DESC_CMB_ADDR_LO                   (REG_DESC_BASE_ADDR_HI+16)
+#define REG_DESC_SMB_ADDR_LO                   (REG_DESC_BASE_ADDR_HI+20)
+#define REG_DESC_RFD_RRD_RING_SIZE             (REG_DESC_BASE_ADDR_HI+24)
+#define DESC_RFD_RING_SIZE_MASK                        0x7ff
+#define DESC_RFD_RING_SIZE_SHIFT               0
+#define DESC_RRD_RING_SIZE_MASK                        0x7ff
+#define DESC_RRD_RING_SIZE_SHIFT               16
+#define REG_DESC_TPD_RING_SIZE                 (REG_DESC_BASE_ADDR_HI+28)
+#define DESC_TPD_RING_SIZE_MASK                        0x3ff
+#define DESC_TPD_RING_SIZE_SHIFT               0
+
+/* TXQ Control Register */
+#define REG_TXQ_CTRL                           0x1580
+#define TXQ_CTRL_TPD_BURST_NUM_SHIFT           0
+#define TXQ_CTRL_TPD_BURST_NUM_MASK            0x1f
+#define TXQ_CTRL_EN                            0x20
+#define TXQ_CTRL_ENH_MODE                      0x40
+#define TXQ_CTRL_TPD_FETCH_TH_SHIFT            8
+#define TXQ_CTRL_TPD_FETCH_TH_MASK             0x3f
+#define TXQ_CTRL_TXF_BURST_NUM_SHIFT           16
+#define TXQ_CTRL_TXF_BURST_NUM_MASK            0xffff
+
+/* Jumbo packet Threshold for task offload */
+#define REG_TX_JUMBO_TASK_TH_TPD_IPG           0x1584
+#define TX_JUMBO_TASK_TH_MASK                  0x7ff
+#define TX_JUMBO_TASK_TH_SHIFT                 0
+#define TX_TPD_MIN_IPG_MASK                    0x1f
+#define TX_TPD_MIN_IPG_SHIFT                   16
+
+/* RXQ Control Register */
+#define REG_RXQ_CTRL                           0x15a0
+#define RXQ_CTRL_RFD_BURST_NUM_SHIFT           0
+#define RXQ_CTRL_RFD_BURST_NUM_MASK            0xff
+#define RXQ_CTRL_RRD_BURST_THRESH_SHIFT                8
+#define RXQ_CTRL_RRD_BURST_THRESH_MASK         0xff
+#define RXQ_CTRL_RFD_PREF_MIN_IPG_SHIFT                16
+#define RXQ_CTRL_RFD_PREF_MIN_IPG_MASK         0x1f
+#define RXQ_CTRL_CUT_THRU_EN                   0x40000000
+#define RXQ_CTRL_EN                            0x80000000
+
+/* Rx jumbo packet threshold and rrd  retirement timer */
+#define REG_RXQ_JMBOSZ_RRDTIM                  (REG_RXQ_CTRL+ 4)
+#define RXQ_JMBOSZ_TH_MASK                     0x7ff
+#define RXQ_JMBOSZ_TH_SHIFT                    0
+#define RXQ_JMBO_LKAH_MASK                     0xf
+#define RXQ_JMBO_LKAH_SHIFT                    11
+#define RXQ_RRD_TIMER_MASK                     0xffff
+#define RXQ_RRD_TIMER_SHIFT                    16
+
+/* RFD flow control register */
+#define REG_RXQ_RXF_PAUSE_THRESH               (REG_RXQ_CTRL+ 8)
+#define RXQ_RXF_PAUSE_TH_HI_SHIFT              16
+#define RXQ_RXF_PAUSE_TH_HI_MASK               0xfff
+#define RXQ_RXF_PAUSE_TH_LO_SHIFT              0
+#define RXQ_RXF_PAUSE_TH_LO_MASK               0xfff
+
+/* RRD flow control register */
+#define REG_RXQ_RRD_PAUSE_THRESH               (REG_RXQ_CTRL+12)
+#define RXQ_RRD_PAUSE_TH_HI_SHIFT              0
+#define RXQ_RRD_PAUSE_TH_HI_MASK               0xfff
+#define RXQ_RRD_PAUSE_TH_LO_SHIFT              16
+#define RXQ_RRD_PAUSE_TH_LO_MASK               0xfff
+
+/* DMA Engine Control Register */
+#define REG_DMA_CTRL                           0x15c0
+#define DMA_CTRL_DMAR_IN_ORDER                 0x1
+#define DMA_CTRL_DMAR_ENH_ORDER                        0x2
+#define DMA_CTRL_DMAR_OUT_ORDER                        0x4
+#define DMA_CTRL_RCB_VALUE                     0x8
+#define DMA_CTRL_DMAR_BURST_LEN_SHIFT          4
+#define DMA_CTRL_DMAR_BURST_LEN_MASK           7
+#define DMA_CTRL_DMAW_BURST_LEN_SHIFT          7
+#define DMA_CTRL_DMAW_BURST_LEN_MASK           7
+#define DMA_CTRL_DMAR_EN                               0x400
+#define DMA_CTRL_DMAW_EN                               0x800
+
+/* CMB/SMB Control Register */
+#define REG_CSMB_CTRL                          0x15d0
+#define CSMB_CTRL_CMB_NOW                      1
+#define CSMB_CTRL_SMB_NOW                      2
+#define CSMB_CTRL_CMB_EN                       4
+#define CSMB_CTRL_SMB_EN                       8
+
+/* CMB DMA Write Threshold Register */
+#define REG_CMB_WRITE_TH                       (REG_CSMB_CTRL+ 4)
+#define CMB_RRD_TH_SHIFT                       0
+#define CMB_RRD_TH_MASK                                0x7ff
+#define CMB_TPD_TH_SHIFT                       16
+#define CMB_TPD_TH_MASK                                0x7ff
+
+/* RX/TX count-down timer to trigger CMB-write. 2us resolution. */
+#define REG_CMB_WRITE_TIMER                    (REG_CSMB_CTRL+ 8)
+#define CMB_RX_TM_SHIFT                                0
+#define CMB_RX_TM_MASK                         0xffff
+#define CMB_TX_TM_SHIFT                                16
+#define CMB_TX_TM_MASK                         0xffff
+
+/* Number of packet received since last CMB write */
+#define REG_CMB_RX_PKT_CNT                     (REG_CSMB_CTRL+12)
+
+/* Number of packet transmitted since last CMB write */
+#define REG_CMB_TX_PKT_CNT                     (REG_CSMB_CTRL+16)
+
+/* SMB auto DMA timer register */
+#define REG_SMB_TIMER                          (REG_CSMB_CTRL+20)
+
+/* Mailbox Register */
+#define REG_MAILBOX                            0x15f0
+#define MB_RFD_PROD_INDX_SHIFT                 0
+#define MB_RFD_PROD_INDX_MASK                  0x7ff
+#define MB_RRD_CONS_INDX_SHIFT                 11
+#define MB_RRD_CONS_INDX_MASK                  0x7ff
+#define MB_TPD_PROD_INDX_SHIFT                 22
+#define MB_TPD_PROD_INDX_MASK                  0x3ff
+
+/* Interrupt Status Register */
+#define REG_ISR                                        0x1600
+#define ISR_SMB                                        1
+#define ISR_TIMER                              2
+#define ISR_MANUAL                             4
+#define ISR_RXF_OV                             8
+#define ISR_RFD_UNRUN                          0x10
+#define ISR_RRD_OV                             0x20
+#define ISR_TXF_UNRUN                          0x40
+#define ISR_LINK                               0x80
+#define ISR_HOST_RFD_UNRUN                     0x100
+#define ISR_HOST_RRD_OV                                0x200
+#define ISR_DMAR_TO_RST                                0x400
+#define ISR_DMAW_TO_RST                                0x800
+#define ISR_GPHY                               0x1000
+#define ISR_RX_PKT                             0x10000
+#define ISR_TX_PKT                             0x20000
+#define ISR_TX_DMA                             0x40000
+#define ISR_RX_DMA                             0x80000
+#define ISR_CMB_RX                             0x100000
+#define ISR_CMB_TX                             0x200000
+#define ISR_MAC_RX                             0x400000
+#define ISR_MAC_TX                             0x800000
+#define ISR_UR_DETECTED                                0x1000000
+#define ISR_FERR_DETECTED                      0x2000000
+#define ISR_NFERR_DETECTED                     0x4000000
+#define ISR_CERR_DETECTED                      0x8000000
+#define ISR_PHY_LINKDOWN                       0x10000000
+#define ISR_DIS_SMB                            0x20000000
+#define ISR_DIS_DMA                            0x40000000
+#define ISR_DIS_INT                            0x80000000
+
+/* Interrupt Mask Register */
+#define REG_IMR                                        0x1604
+
+/* Normal Interrupt mask  */
+#define IMR_NORMAL_MASK        (\
+       ISR_SMB         |\
+       ISR_GPHY        |\
+       ISR_PHY_LINKDOWN|\
+       ISR_DMAR_TO_RST |\
+       ISR_DMAW_TO_RST |\
+       ISR_CMB_TX      |\
+       ISR_CMB_RX      )
+
+/* Debug Interrupt Mask  (enable all interrupt) */
+#define IMR_DEBUG_MASK (\
+       ISR_SMB         |\
+       ISR_TIMER       |\
+       ISR_MANUAL      |\
+       ISR_RXF_OV      |\
+       ISR_RFD_UNRUN   |\
+       ISR_RRD_OV      |\
+       ISR_TXF_UNRUN   |\
+       ISR_LINK        |\
+       ISR_CMB_TX      |\
+       ISR_CMB_RX      |\
+       ISR_RX_PKT      |\
+       ISR_TX_PKT      |\
+       ISR_MAC_RX      |\
+       ISR_MAC_TX      )
+
+/* Interrupt Status Register */
+#define REG_RFD_RRD_IDX                                0x1800
+#define REG_TPD_IDX                            0x1804
+
+/*  MII definition */
+/* PHY Common Register */
+#define MII_AT001_CR                                   0x09
+#define MII_AT001_SR                                   0x0A
+#define MII_AT001_ESR                                  0x0F
+#define MII_AT001_PSCR                                 0x10
+#define MII_AT001_PSSR                                 0x11
+
+/* PHY Control Register */
+#define MII_CR_SPEED_SELECT_MSB                                0x0040  /* bits 6,13: 10=1000, 01=100, 00=10 */
+#define MII_CR_COLL_TEST_ENABLE                                0x0080  /* Collision test enable */
+#define MII_CR_FULL_DUPLEX                             0x0100  /* FDX =1, half duplex =0 */
+#define MII_CR_RESTART_AUTO_NEG                                0x0200  /* Restart auto negotiation */
+#define MII_CR_ISOLATE                                 0x0400  /* Isolate PHY from MII */
+#define MII_CR_POWER_DOWN                              0x0800  /* Power down */
+#define MII_CR_AUTO_NEG_EN                             0x1000  /* Auto Neg Enable */
+#define MII_CR_SPEED_SELECT_LSB                                0x2000  /* bits 6,13: 10=1000, 01=100, 00=10 */
+#define MII_CR_LOOPBACK                                        0x4000  /* 0 = normal, 1 = loopback */
+#define MII_CR_RESET                                   0x8000  /* 0 = normal, 1 = PHY reset */
+#define MII_CR_SPEED_MASK                              0x2040
+#define MII_CR_SPEED_1000                              0x0040
+#define MII_CR_SPEED_100                               0x2000
+#define MII_CR_SPEED_10                                        0x0000
+
+/* PHY Status Register */
+#define MII_SR_EXTENDED_CAPS                           0x0001  /* Extended register capabilities */
+#define MII_SR_JABBER_DETECT                           0x0002  /* Jabber Detected */
+#define MII_SR_LINK_STATUS                             0x0004  /* Link Status 1 = link */
+#define MII_SR_AUTONEG_CAPS                            0x0008  /* Auto Neg Capable */
+#define MII_SR_REMOTE_FAULT                            0x0010  /* Remote Fault Detect */
+#define MII_SR_AUTONEG_COMPLETE                                0x0020  /* Auto Neg Complete */
+#define MII_SR_PREAMBLE_SUPPRESS                       0x0040  /* Preamble may be suppressed */
+#define MII_SR_EXTENDED_STATUS                         0x0100  /* Ext. status info in Reg 0x0F */
+#define MII_SR_100T2_HD_CAPS                           0x0200  /* 100T2 Half Duplex Capable */
+#define MII_SR_100T2_FD_CAPS                           0x0400  /* 100T2 Full Duplex Capable */
+#define MII_SR_10T_HD_CAPS                             0x0800  /* 10T   Half Duplex Capable */
+#define MII_SR_10T_FD_CAPS                             0x1000  /* 10T   Full Duplex Capable */
+#define MII_SR_100X_HD_CAPS                            0x2000  /* 100X  Half Duplex Capable */
+#define MII_SR_100X_FD_CAPS                            0x4000  /* 100X  Full Duplex Capable */
+#define MII_SR_100T4_CAPS                              0x8000  /* 100T4 Capable */
+
+/* Link partner ability register. */
+#define MII_LPA_SLCT                                   0x001f  /* Same as advertise selector  */
+#define MII_LPA_10HALF                                 0x0020  /* Can do 10mbps half-duplex   */
+#define MII_LPA_10FULL                                 0x0040  /* Can do 10mbps full-duplex   */
+#define MII_LPA_100HALF                                        0x0080  /* Can do 100mbps half-duplex  */
+#define MII_LPA_100FULL                                        0x0100  /* Can do 100mbps full-duplex  */
+#define MII_LPA_100BASE4                               0x0200  /* 100BASE-T4  */
+#define MII_LPA_PAUSE                                  0x0400  /* PAUSE */
+#define MII_LPA_ASYPAUSE                               0x0800  /* Asymmetrical PAUSE */
+#define MII_LPA_RFAULT                                 0x2000  /* Link partner faulted        */
+#define MII_LPA_LPACK                                  0x4000  /* Link partner acked us       */
+#define MII_LPA_NPAGE                                  0x8000  /* Next page bit               */
+
+/* Autoneg Advertisement Register */
+#define MII_AR_SELECTOR_FIELD                          0x0001  /* indicates IEEE 802.3 CSMA/CD */
+#define MII_AR_10T_HD_CAPS                             0x0020  /* 10T   Half Duplex Capable */
+#define MII_AR_10T_FD_CAPS                             0x0040  /* 10T   Full Duplex Capable */
+#define MII_AR_100TX_HD_CAPS                           0x0080  /* 100TX Half Duplex Capable */
+#define MII_AR_100TX_FD_CAPS                           0x0100  /* 100TX Full Duplex Capable */
+#define MII_AR_100T4_CAPS                              0x0200  /* 100T4 Capable */
+#define MII_AR_PAUSE                                   0x0400  /* Pause operation desired */
+#define MII_AR_ASM_DIR                                 0x0800  /* Asymmetric Pause Direction bit */
+#define MII_AR_REMOTE_FAULT                            0x2000  /* Remote Fault detected */
+#define MII_AR_NEXT_PAGE                               0x8000  /* Next Page ability supported */
+#define MII_AR_SPEED_MASK                              0x01E0
+#define MII_AR_DEFAULT_CAP_MASK                                0x0DE0
+
+/* 1000BASE-T Control Register */
+#define MII_AT001_CR_1000T_HD_CAPS                     0x0100  /* Advertise 1000T HD capability */
+#define MII_AT001_CR_1000T_FD_CAPS                     0x0200  /* Advertise 1000T FD capability  */
+#define MII_AT001_CR_1000T_REPEATER_DTE                        0x0400  /* 1=Repeater/switch device port, 0=DTE device */
+#define MII_AT001_CR_1000T_MS_VALUE                    0x0800  /* 1=Configure PHY as Master, 0=Configure PHY as Slave */
+#define MII_AT001_CR_1000T_MS_ENABLE                   0x1000  /* 1=Master/Slave manual config value, 0=Automatic Master/Slave config */
+#define MII_AT001_CR_1000T_TEST_MODE_NORMAL            0x0000  /* Normal Operation */
+#define MII_AT001_CR_1000T_TEST_MODE_1                 0x2000  /* Transmit Waveform test */
+#define MII_AT001_CR_1000T_TEST_MODE_2                 0x4000  /* Master Transmit Jitter test */
+#define MII_AT001_CR_1000T_TEST_MODE_3                 0x6000  /* Slave Transmit Jitter test */
+#define MII_AT001_CR_1000T_TEST_MODE_4                 0x8000  /* Transmitter Distortion test */
+#define MII_AT001_CR_1000T_SPEED_MASK                  0x0300
+#define MII_AT001_CR_1000T_DEFAULT_CAP_MASK            0x0300
+
+/* 1000BASE-T Status Register */
+#define MII_AT001_SR_1000T_LP_HD_CAPS                  0x0400  /* LP is 1000T HD capable */
+#define MII_AT001_SR_1000T_LP_FD_CAPS                  0x0800  /* LP is 1000T FD capable */
+#define MII_AT001_SR_1000T_REMOTE_RX_STATUS            0x1000  /* Remote receiver OK */
+#define MII_AT001_SR_1000T_LOCAL_RX_STATUS             0x2000  /* Local receiver OK */
+#define MII_AT001_SR_1000T_MS_CONFIG_RES               0x4000  /* 1=Local TX is Master, 0=Slave */
+#define MII_AT001_SR_1000T_MS_CONFIG_FAULT             0x8000  /* Master/Slave config fault */
+#define MII_AT001_SR_1000T_REMOTE_RX_STATUS_SHIFT      12
+#define MII_AT001_SR_1000T_LOCAL_RX_STATUS_SHIFT       13
+
+/* Extended Status Register */
+#define MII_AT001_ESR_1000T_HD_CAPS                    0x1000  /* 1000T HD capable */
+#define MII_AT001_ESR_1000T_FD_CAPS                    0x2000  /* 1000T FD capable */
+#define MII_AT001_ESR_1000X_HD_CAPS                    0x4000  /* 1000X HD capable */
+#define MII_AT001_ESR_1000X_FD_CAPS                    0x8000  /* 1000X FD capable */
+
+/* AT001 PHY Specific Control Register */
+#define MII_AT001_PSCR_JABBER_DISABLE                  0x0001  /* 1=Jabber Function disabled */
+#define MII_AT001_PSCR_POLARITY_REVERSAL               0x0002  /* 1=Polarity Reversal enabled */
+#define MII_AT001_PSCR_SQE_TEST                                0x0004  /* 1=SQE Test enabled */
+#define MII_AT001_PSCR_MAC_POWERDOWN                   0x0008
+#define MII_AT001_PSCR_CLK125_DISABLE                  0x0010  /* 1=CLK125 low, 0=CLK125 toggling */
+#define MII_AT001_PSCR_MDI_MANUAL_MODE                 0x0000  /* MDI Crossover Mode bits 6:5, Manual MDI configuration */
+#define MII_AT001_PSCR_MDIX_MANUAL_MODE                        0x0020  /* Manual MDIX configuration */
+#define MII_AT001_PSCR_AUTO_X_1000T                    0x0040  /* 1000BASE-T: Auto crossover, 100BASE-TX/10BASE-T: MDI Mode */
+#define MII_AT001_PSCR_AUTO_X_MODE                     0x0060  /* Auto crossover enabled all speeds. */
+#define MII_AT001_PSCR_10BT_EXT_DIST_ENABLE            0x0080  /* 1=Enable Extended 10BASE-T distance (Lower 10BASE-T RX Threshold), 0=Normal 10BASE-T RX Threshold */
+#define MII_AT001_PSCR_MII_5BIT_ENABLE                 0x0100  /* 1=5-Bit interface in 100BASE-TX, 0=MII interface in 100BASE-TX */
+#define MII_AT001_PSCR_SCRAMBLER_DISABLE               0x0200  /* 1=Scrambler disable */
+#define MII_AT001_PSCR_FORCE_LINK_GOOD                 0x0400  /* 1=Force link good */
+#define MII_AT001_PSCR_ASSERT_CRS_ON_TX                        0x0800  /* 1=Assert CRS on Transmit */
+#define MII_AT001_PSCR_POLARITY_REVERSAL_SHIFT         1
+#define MII_AT001_PSCR_AUTO_X_MODE_SHIFT               5
+#define MII_AT001_PSCR_10BT_EXT_DIST_ENABLE_SHIFT      7
+
+/* AT001 PHY Specific Status Register */
+#define MII_AT001_PSSR_SPD_DPLX_RESOLVED               0x0800  /* 1=Speed & Duplex resolved */
+#define MII_AT001_PSSR_DPLX                            0x2000  /* 1=Duplex 0=Half Duplex */
+#define MII_AT001_PSSR_SPEED                           0xC000  /* Speed, bits 14:15 */
+#define MII_AT001_PSSR_10MBS                           0x0000  /* 00=10Mbs */
+#define MII_AT001_PSSR_100MBS                          0x4000  /* 01=100Mbs */
+#define MII_AT001_PSSR_1000MBS                         0x8000  /* 10=1000Mbs */
+
+/* PCI Command Register Bit Definitions */
+#define PCI_REG_COMMAND                                        0x04    /* PCI Command Register */
+#define CMD_IO_SPACE                                   0x0001
+#define CMD_MEMORY_SPACE                               0x0002
+#define CMD_BUS_MASTER                                 0x0004
+
+/* Wake Up Filter Control */
+#define ATL1_WUFC_LNKC 0x00000001      /* Link Status Change Wakeup Enable */
+#define ATL1_WUFC_MAG  0x00000002      /* Magic Packet Wakeup Enable */
+#define ATL1_WUFC_EX   0x00000004      /* Directed Exact Wakeup Enable */
+#define ATL1_WUFC_MC   0x00000008      /* Multicast Wakeup Enable */
+#define ATL1_WUFC_BC   0x00000010      /* Broadcast Wakeup Enable */
+
+/* Error Codes */
+#define ATL1_SUCCESS                   0
+#define ATL1_ERR_EEPROM                        1
+#define ATL1_ERR_PHY                   2
+#define ATL1_ERR_CONFIG                        3
+#define ATL1_ERR_PARAM                 4
+#define ATL1_ERR_MAC_TYPE              5
+#define ATL1_ERR_PHY_TYPE              6
+#define ATL1_ERR_PHY_SPEED             7
+#define ATL1_ERR_PHY_RES               8
+
+#define SPEED_0                0xffff
+#define SPEED_10       10
+#define SPEED_100      100
+#define SPEED_1000     1000
+#define HALF_DUPLEX    1
+#define FULL_DUPLEX    2
+
+#define MEDIA_TYPE_AUTO_SENSOR 0
+#define MEDIA_TYPE_1000M_FULL  1
+#define MEDIA_TYPE_100M_FULL   2
+#define MEDIA_TYPE_100M_HALF   3
+#define MEDIA_TYPE_10M_FULL    4
+#define MEDIA_TYPE_10M_HALF    5
+
+#define ADVERTISE_10_HALF              0x0001
+#define ADVERTISE_10_FULL              0x0002
+#define ADVERTISE_100_HALF             0x0004
+#define ADVERTISE_100_FULL             0x0008
+#define ADVERTISE_1000_HALF            0x0010
+#define ADVERTISE_1000_FULL            0x0020
+#define AUTONEG_ADVERTISE_SPEED_DEFAULT        0x002F  /* Everything but 1000-Half */
+#define AUTONEG_ADVERTISE_10_100_ALL   0x000F  /* All 10/100 speeds */
+#define AUTONEG_ADVERTISE_10_ALL       0x0003  /* 10Mbps Full & Half speeds */
+
+/* The size (in bytes) of a ethernet packet */
+#define ENET_HEADER_SIZE               14
+#define MAXIMUM_ETHERNET_FRAME_SIZE    1518    /* with FCS */
+#define MINIMUM_ETHERNET_FRAME_SIZE    64      /* with FCS */
+#define ETHERNET_FCS_SIZE              4
+#define MAX_JUMBO_FRAME_SIZE           0x2800
+
+#define PHY_AUTO_NEG_TIME      45      /* 4.5 Seconds */
+#define PHY_FORCE_TIME         20      /* 2.0 Seconds */
+
+/* For checksumming , the sum of all words in the EEPROM should equal 0xBABA */
+#define EEPROM_SUM             0xBABA
+
+#define ATL1_EEDUMP_LEN                48
+
+/* Statistics counters collected by the MAC */
+struct stats_msg_block {
+       /* rx */
+       u32 rx_ok;              /* The number of good packet received. */
+       u32 rx_bcast;           /* The number of good broadcast packet received. */
+       u32 rx_mcast;           /* The number of good multicast packet received. */
+       u32 rx_pause;           /* The number of Pause packet received. */
+       u32 rx_ctrl;            /* The number of Control packet received other than Pause frame. */
+       u32 rx_fcs_err;         /* The number of packets with bad FCS. */
+       u32 rx_len_err;         /* The number of packets with mismatch of length field and actual size. */
+       u32 rx_byte_cnt;        /* The number of bytes of good packet received. FCS is NOT included. */
+       u32 rx_runt;            /* The number of packets received that are less than 64 byte long and with good FCS. */
+       u32 rx_frag;            /* The number of packets received that are less than 64 byte long and with bad FCS. */
+       u32 rx_sz_64;           /* The number of good and bad packets received that are 64 byte long. */
+       u32 rx_sz_65_127;       /* The number of good and bad packets received that are between 65 and 127-byte long. */
+       u32 rx_sz_128_255;      /* The number of good and bad packets received that are between 128 and 255-byte long. */
+       u32 rx_sz_256_511;      /* The number of good and bad packets received that are between 256 and 511-byte long. */
+       u32 rx_sz_512_1023;     /* The number of good and bad packets received that are between 512 and 1023-byte long. */
+       u32 rx_sz_1024_1518;    /* The number of good and bad packets received that are between 1024 and 1518-byte long. */
+       u32 rx_sz_1519_max;     /* The number of good and bad packets received that are between 1519-byte and MTU. */
+       u32 rx_sz_ov;           /* The number of good and bad packets received that are more than MTU size šC truncated by Selene. */
+       u32 rx_rxf_ov;          /* The number of frame dropped due to occurrence of RX FIFO overflow. */
+       u32 rx_rrd_ov;          /* The number of frame dropped due to occurrence of RRD overflow. */
+       u32 rx_align_err;       /* Alignment Error */
+       u32 rx_bcast_byte_cnt;  /* The byte count of broadcast packet received, excluding FCS. */
+       u32 rx_mcast_byte_cnt;  /* The byte count of multicast packet received, excluding FCS. */
+       u32 rx_err_addr;        /* The number of packets dropped due to address filtering. */
+
+       /* tx */
+       u32 tx_ok;              /* The number of good packet transmitted. */
+       u32 tx_bcast;           /* The number of good broadcast packet transmitted. */
+       u32 tx_mcast;           /* The number of good multicast packet transmitted. */
+       u32 tx_pause;           /* The number of Pause packet transmitted. */
+       u32 tx_exc_defer;       /* The number of packets transmitted with excessive deferral. */
+       u32 tx_ctrl;            /* The number of packets transmitted is a control frame, excluding Pause frame. */
+       u32 tx_defer;           /* The number of packets transmitted that is deferred. */
+       u32 tx_byte_cnt;        /* The number of bytes of data transmitted. FCS is NOT included. */
+       u32 tx_sz_64;           /* The number of good and bad packets transmitted that are 64 byte long. */
+       u32 tx_sz_65_127;       /* The number of good and bad packets transmitted that are between 65 and 127-byte long. */
+       u32 tx_sz_128_255;      /* The number of good and bad packets transmitted that are between 128 and 255-byte long. */
+       u32 tx_sz_256_511;      /* The number of good and bad packets transmitted that are between 256 and 511-byte long. */
+       u32 tx_sz_512_1023;     /* The number of good and bad packets transmitted that are between 512 and 1023-byte long. */
+       u32 tx_sz_1024_1518;    /* The number of good and bad packets transmitted that are between 1024 and 1518-byte long. */
+       u32 tx_sz_1519_max;     /* The number of good and bad packets transmitted that are between 1519-byte and MTU. */
+       u32 tx_1_col;           /* The number of packets subsequently transmitted successfully with a single prior collision. */
+       u32 tx_2_col;           /* The number of packets subsequently transmitted successfully with multiple prior collisions. */
+       u32 tx_late_col;        /* The number of packets transmitted with late collisions. */
+       u32 tx_abort_col;       /* The number of transmit packets aborted due to excessive collisions. */
+       u32 tx_underrun;        /* The number of transmit packets aborted due to transmit FIFO underrun, or TRD FIFO underrun */
+       u32 tx_rd_eop;          /* The number of times that read beyond the EOP into the next frame area when TRD was not written timely */
+       u32 tx_len_err;         /* The number of transmit packets with length field does NOT match the actual frame size. */
+       u32 tx_trunc;           /* The number of transmit packets truncated due to size exceeding MTU. */
+       u32 tx_bcast_byte;      /* The byte count of broadcast packet transmitted, excluding FCS. */
+       u32 tx_mcast_byte;      /* The byte count of multicast packet transmitted, excluding FCS. */
+       u32 smb_updated;        /* 1: SMB Updated. This is used by software as the indication of the statistics update.
+                                * Software should clear this bit as soon as retrieving the statistics information. */
+};
+
+/* Coalescing Message Block */
+struct coals_msg_block {
+       u32 int_stats;          /* interrupt status */
+       u16 rrd_prod_idx;       /* TRD Producer Index. */
+       u16 rfd_cons_idx;       /* RFD Consumer Index. */
+       u16 update;             /* Selene sets this bit every time it DMA the CMB to host memory.
+                                * Software supposes to clear this bit when CMB information is processed. */
+       u16 tpd_cons_idx;       /* TPD Consumer Index. */
+};
+
+/* RRD descriptor */
+struct rx_return_desc {
+       u8 num_buf;             /* Number of RFD buffers used by the received packet */
+       u8 resved;
+       u16 buf_indx;           /* RFD Index of the first buffer */
+       union {
+               u32 valid;
+               struct {
+                       u16 rx_chksum;
+                       u16 pkt_size;
+               } xsum_sz;
+       } xsz;
+
+       u16 pkt_flg;            /* Packet flags */
+       u16 err_flg;            /* Error flags */
+       u16 resved2;
+       u16 vlan_tag;           /* VLAN TAG */
+};
+
+#define PACKET_FLAG_ETH_TYPE   0x0080
+#define PACKET_FLAG_VLAN_INS   0x0100
+#define PACKET_FLAG_ERR                0x0200
+#define PACKET_FLAG_IPV4       0x0400
+#define PACKET_FLAG_UDP                0x0800
+#define PACKET_FLAG_TCP                0x1000
+#define PACKET_FLAG_BCAST      0x2000
+#define PACKET_FLAG_MCAST      0x4000
+#define PACKET_FLAG_PAUSE      0x8000
+
+#define ERR_FLAG_CRC           0x0001
+#define ERR_FLAG_CODE          0x0002
+#define ERR_FLAG_DRIBBLE       0x0004
+#define ERR_FLAG_RUNT          0x0008
+#define ERR_FLAG_OV            0x0010
+#define ERR_FLAG_TRUNC         0x0020
+#define ERR_FLAG_IP_CHKSUM     0x0040
+#define ERR_FLAG_L4_CHKSUM     0x0080
+#define ERR_FLAG_LEN           0x0100
+#define ERR_FLAG_DES_ADDR      0x0200
+
+/* RFD descriptor */
+struct rx_free_desc {
+       __le64 buffer_addr;     /* Address of the descriptor's data buffer */
+       __le16 buf_len;         /* Size of the receive buffer in host memory, in byte */
+       u16 coalese;            /* Update consumer index to host after the reception of this frame */
+       /* __attribute__ ((packed)) is required */
+} __attribute__ ((packed));
+
+/* tsopu defines */
+#define TSO_PARAM_BUFLEN_MASK           0x3FFF
+#define TSO_PARAM_BUFLEN_SHIFT          0
+#define TSO_PARAM_DMAINT_MASK           0x0001
+#define TSO_PARAM_DMAINT_SHIFT          14
+#define TSO_PARAM_PKTNT_MASK            0x0001
+#define TSO_PARAM_PKTINT_SHIFT          15
+#define TSO_PARAM_VLANTAG_MASK          0xFFFF
+#define TSO_PARAM_VLAN_SHIFT            16
+
+/* tsopl defines */
+#define TSO_PARAM_EOP_MASK              0x0001
+#define TSO_PARAM_EOP_SHIFT             0
+#define TSO_PARAM_COALESCE_MASK         0x0001
+#define TSO_PARAM_COALESCE_SHIFT        1
+#define TSO_PARAM_INSVLAG_MASK          0x0001
+#define TSO_PARAM_INSVLAG_SHIFT         2
+#define TSO_PARAM_CUSTOMCKSUM_MASK      0x0001
+#define TSO_PARAM_CUSTOMCKSUM_SHIFT     3
+#define TSO_PARAM_SEGMENT_MASK          0x0001
+#define TSO_PARAM_SEGMENT_SHIFT         4
+#define TSO_PARAM_IPCKSUM_MASK          0x0001
+#define TSO_PARAM_IPCKSUM_SHIFT         5
+#define TSO_PARAM_TCPCKSUM_MASK         0x0001
+#define TSO_PARAM_TCPCKSUM_SHIFT        6
+#define TSO_PARAM_UDPCKSUM_MASK         0x0001
+#define TSO_PARAM_UDPCKSUM_SHIFT        7
+#define TSO_PARAM_VLANTAGGED_MASK       0x0001
+#define TSO_PARAM_VLANTAGGED_SHIFT      8
+#define TSO_PARAM_ETHTYPE_MASK          0x0001
+#define TSO_PARAM_ETHTYPE_SHIFT         9
+#define TSO_PARAM_IPHL_MASK             0x000F
+#define TSO_PARAM_IPHL_SHIFT            10
+#define TSO_PARAM_TCPHDRLEN_MASK        0x000F
+#define TSO_PARAM_TCPHDRLEN_SHIFT       14
+#define TSO_PARAM_HDRFLAG_MASK          0x0001
+#define TSO_PARAM_HDRFLAG_SHIFT         18
+#define TSO_PARAM_MSS_MASK              0x1FFF
+#define TSO_PARAM_MSS_SHIFT             19
+
+/* csumpu defines */
+#define CSUM_PARAM_BUFLEN_MASK          0x3FFF
+#define CSUM_PARAM_BUFLEN_SHIFT         0
+#define CSUM_PARAM_DMAINT_MASK          0x0001
+#define CSUM_PARAM_DMAINT_SHIFT         14
+#define CSUM_PARAM_PKTINT_MASK          0x0001
+#define CSUM_PARAM_PKTINT_SHIFT         15
+#define CSUM_PARAM_VALANTAG_MASK        0xFFFF
+#define CSUM_PARAM_VALAN_SHIFT          16
+
+/* csumpl defines*/
+#define CSUM_PARAM_EOP_MASK             0x0001
+#define CSUM_PARAM_EOP_SHIFT            0
+#define CSUM_PARAM_COALESCE_MASK        0x0001
+#define CSUM_PARAM_COALESCE_SHIFT       1
+#define CSUM_PARAM_INSVLAG_MASK         0x0001
+#define CSUM_PARAM_INSVLAG_SHIFT        2
+#define CSUM_PARAM_CUSTOMCKSUM_MASK     0x0001
+#define CSUM_PARAM_CUSTOMCKSUM_SHIFT    3
+#define CSUM_PARAM_SEGMENT_MASK         0x0001
+#define CSUM_PARAM_SEGMENT_SHIFT        4
+#define CSUM_PARAM_IPCKSUM_MASK         0x0001
+#define CSUM_PARAM_IPCKSUM_SHIFT        5
+#define CSUM_PARAM_TCPCKSUM_MASK        0x0001
+#define CSUM_PARAM_TCPCKSUM_SHIFT       6
+#define CSUM_PARAM_UDPCKSUM_MASK        0x0001
+#define CSUM_PARAM_UDPCKSUM_SHIFT       7
+#define CSUM_PARAM_VLANTAGGED_MASK      0x0001
+#define CSUM_PARAM_VLANTAGGED_SHIFT     8
+#define CSUM_PARAM_ETHTYPE_MASK         0x0001
+#define CSUM_PARAM_ETHTYPE_SHIFT        9
+#define CSUM_PARAM_IPHL_MASK            0x000F
+#define CSUM_PARAM_IPHL_SHIFT           10
+#define CSUM_PARAM_PLOADOFFSET_MASK     0x00FF
+#define CSUM_PARAM_PLOADOFFSET_SHIFT    16
+#define CSUM_PARAM_XSUMOFFSET_MASK      0x00FF
+#define CSUM_PARAM_XSUMOFFSET_SHIFT     24
+
+/* TPD descriptor */
+struct tso_param {
+        /* The order of these declarations is important -- don't change it */
+        u32 tsopu;      /* tso_param upper word */
+        u32 tsopl;      /* tso_param lower word */
+};
+
+struct csum_param {
+        /* The order of these declarations is important -- don't change it */
+        u32 csumpu;     /* csum_param upper word */
+        u32 csumpl;     /* csum_param lower word */
+};
+
+union tpd_descr {
+       u64 data;
+       struct csum_param csum;
+       struct tso_param tso;
+};
+
+struct tx_packet_desc {
+       __le64 buffer_addr;
+       union tpd_descr desc;
+};
+
+/* DMA Order Settings */
+enum atl1_dma_order {
+       atl1_dma_ord_in = 1,
+       atl1_dma_ord_enh = 2,
+       atl1_dma_ord_out = 4
+};
+
+enum atl1_dma_rcb {
+       atl1_rcb_64 = 0,
+       atl1_rcb_128 = 1
+};
+
+enum atl1_dma_req_block {
+       atl1_dma_req_128 = 0,
+       atl1_dma_req_256 = 1,
+       atl1_dma_req_512 = 2,
+       atl1_dam_req_1024 = 3,
+       atl1_dam_req_2048 = 4,
+       atl1_dma_req_4096 = 5
+};
+
+struct atl1_spi_flash_dev {
+       const char *manu_name;  /* manufacturer id */
+       /* op-code */
+       u8 cmd_wrsr;
+       u8 cmd_read;
+       u8 cmd_program;
+       u8 cmd_wren;
+       u8 cmd_wrdi;
+       u8 cmd_rdsr;
+       u8 cmd_rdid;
+       u8 cmd_sector_erase;
+       u8 cmd_chip_erase;
+};
+
+#endif /* _ATL1_HW_H_ */
diff --git a/drivers/net/atl1/atl1_main.c b/drivers/net/atl1/atl1_main.c
new file mode 100644 (file)
index 0000000..6655640
--- /dev/null
@@ -0,0 +1,2468 @@
+/*
+ * Copyright(c) 2005 - 2006 Attansic Corporation. All rights reserved.
+ * Copyright(c) 2006 Chris Snook <csnook@redhat.com>
+ * Copyright(c) 2006 Jay Cliburn <jcliburn@gmail.com>
+ *
+ * Derived from Intel e1000 driver
+ * Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59
+ * Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The full GNU General Public License is included in this distribution in the
+ * file called COPYING.
+ *
+ * Contact Information:
+ * Xiong Huang <xiong_huang@attansic.com>
+ * Attansic Technology Corp. 3F 147, Xianzheng 9th Road, Zhubei,
+ * Xinzhu  302, TAIWAN, REPUBLIC OF CHINA
+ *
+ * Chris Snook <csnook@redhat.com>
+ * Jay Cliburn <jcliburn@gmail.com>
+ *
+ * This version is adapted from the Attansic reference driver for
+ * inclusion in the Linux kernel.  It is currently under heavy development.
+ * A very incomplete list of things that need to be dealt with:
+ *
+ * TODO:
+ * Fix TSO; tx performance is horrible with TSO enabled.
+ * Wake on LAN.
+ * Add more ethtool functions, including set ring parameters.
+ * Fix abstruse irq enable/disable condition described here:
+ *     http://marc.theaimsgroup.com/?l=linux-netdev&m=116398508500553&w=2
+ *
+ * NEEDS TESTING:
+ * VLAN
+ * multicast
+ * promiscuous mode
+ * interrupt coalescing
+ * SMP torture testing
+ */
+
+#include <linux/types.h>
+#include <linux/netdevice.h>
+#include <linux/pci.h>
+#include <linux/spinlock.h>
+#include <linux/slab.h>
+#include <linux/string.h>
+#include <linux/skbuff.h>
+#include <linux/etherdevice.h>
+#include <linux/if_vlan.h>
+#include <linux/irqreturn.h>
+#include <linux/workqueue.h>
+#include <linux/timer.h>
+#include <linux/jiffies.h>
+#include <linux/hardirq.h>
+#include <linux/interrupt.h>
+#include <linux/irqflags.h>
+#include <linux/dma-mapping.h>
+#include <linux/net.h>
+#include <linux/pm.h>
+#include <linux/in.h>
+#include <linux/ip.h>
+#include <linux/tcp.h>
+#include <linux/compiler.h>
+#include <linux/delay.h>
+#include <linux/mii.h>
+#include <net/checksum.h>
+
+#include <asm/atomic.h>
+#include <asm/byteorder.h>
+
+#include "atl1.h"
+
+#define RUN_REALTIME 0
+#define DRIVER_VERSION "2.0.6"
+
+char atl1_driver_name[] = "atl1";
+static const char atl1_driver_string[] = "Attansic L1 Ethernet Network Driver";
+static const char atl1_copyright[] = "Copyright(c) 2005-2006 Attansic Corporation.";
+char atl1_driver_version[] = DRIVER_VERSION;
+
+MODULE_AUTHOR
+    ("Attansic Corporation <xiong_huang@attansic.com>, Chris Snook <csnook@redhat.com>, Jay Cliburn <jcliburn@gmail.com>");
+MODULE_DESCRIPTION("Attansic 1000M Ethernet Network Driver");
+MODULE_LICENSE("GPL");
+MODULE_VERSION(DRIVER_VERSION);
+
+/*
+ * atl1_pci_tbl - PCI Device ID Table
+ */
+static const struct pci_device_id atl1_pci_tbl[] = {
+       {PCI_DEVICE(PCI_VENDOR_ID_ATTANSIC, 0x1048)},
+       /* required last entry */
+       {0,}
+};
+
+MODULE_DEVICE_TABLE(pci, atl1_pci_tbl);
+
+/*
+ * atl1_sw_init - Initialize general software structures (struct atl1_adapter)
+ * @adapter: board private structure to initialize
+ *
+ * atl1_sw_init initializes the Adapter private data structure.
+ * Fields are initialized based on PCI device information and
+ * OS network device settings (MTU size).
+ */
+static int __devinit atl1_sw_init(struct atl1_adapter *adapter)
+{
+       struct atl1_hw *hw = &adapter->hw;
+       struct net_device *netdev = adapter->netdev;
+       struct pci_dev *pdev = adapter->pdev;
+
+       /* PCI config space info */
+       pci_read_config_byte(pdev, PCI_REVISION_ID, &hw->revision_id);
+
+       hw->max_frame_size = netdev->mtu + ENET_HEADER_SIZE + ETHERNET_FCS_SIZE;
+       hw->min_frame_size = MINIMUM_ETHERNET_FRAME_SIZE;
+
+       adapter->wol = 0;
+       adapter->rx_buffer_len = (hw->max_frame_size + 7) & ~7;
+       adapter->ict = 50000;   /* 100ms */
+       adapter->link_speed = SPEED_0;  /* hardware init */
+       adapter->link_duplex = FULL_DUPLEX;
+
+       hw->phy_configured = false;
+       hw->preamble_len = 7;
+       hw->ipgt = 0x60;
+       hw->min_ifg = 0x50;
+       hw->ipgr1 = 0x40;
+       hw->ipgr2 = 0x60;
+       hw->max_retry = 0xf;
+       hw->lcol = 0x37;
+       hw->jam_ipg = 7;
+       hw->rfd_burst = 8;
+       hw->rrd_burst = 8;
+       hw->rfd_fetch_gap = 1;
+       hw->rx_jumbo_th = adapter->rx_buffer_len / 8;
+       hw->rx_jumbo_lkah = 1;
+       hw->rrd_ret_timer = 16;
+       hw->tpd_burst = 4;
+       hw->tpd_fetch_th = 16;
+       hw->txf_burst = 0x100;
+       hw->tx_jumbo_task_th = (hw->max_frame_size + 7) >> 3;
+       hw->tpd_fetch_gap = 1;
+       hw->rcb_value = atl1_rcb_64;
+       hw->dma_ord = atl1_dma_ord_enh;
+       hw->dmar_block = atl1_dma_req_256;
+       hw->dmaw_block = atl1_dma_req_256;
+       hw->cmb_rrd = 4;
+       hw->cmb_tpd = 4;
+       hw->cmb_rx_timer = 1;   /* about 2us */
+       hw->cmb_tx_timer = 1;   /* about 2us */
+       hw->smb_timer = 100000; /* about 200ms */
+
+       atomic_set(&adapter->irq_sem, 0);
+       spin_lock_init(&adapter->lock);
+       spin_lock_init(&adapter->mb_lock);
+
+       return 0;
+}
+
+/*
+ * atl1_setup_mem_resources - allocate Tx / RX descriptor resources
+ * @adapter: board private structure
+ *
+ * Return 0 on success, negative on failure
+ */
+s32 atl1_setup_ring_resources(struct atl1_adapter *adapter)
+{
+       struct atl1_tpd_ring *tpd_ring = &adapter->tpd_ring;
+       struct atl1_rfd_ring *rfd_ring = &adapter->rfd_ring;
+       struct atl1_rrd_ring *rrd_ring = &adapter->rrd_ring;
+       struct atl1_ring_header *ring_header = &adapter->ring_header;
+       struct pci_dev *pdev = adapter->pdev;
+       int size;
+       u8 offset = 0;
+
+       size = sizeof(struct atl1_buffer) * (tpd_ring->count + rfd_ring->count);
+       tpd_ring->buffer_info = kzalloc(size, GFP_KERNEL);
+       if (unlikely(!tpd_ring->buffer_info)) {
+               printk(KERN_WARNING "%s: kzalloc failed , size = D%d\n",
+                       atl1_driver_name, size);
+               goto err_nomem;
+       }
+       rfd_ring->buffer_info =
+           (struct atl1_buffer *)(tpd_ring->buffer_info + tpd_ring->count);
+
+       /* real ring DMA buffer */
+       ring_header->size = size = sizeof(struct tx_packet_desc) *
+                                       tpd_ring->count
+           + sizeof(struct rx_free_desc) * rfd_ring->count
+           + sizeof(struct rx_return_desc) * rrd_ring->count
+           + sizeof(struct coals_msg_block)
+           + sizeof(struct stats_msg_block)
+           + 40;               /* "40: for 8 bytes align" huh? -- CHS */
+
+       ring_header->desc = pci_alloc_consistent(pdev, ring_header->size,
+                                               &ring_header->dma);
+       if (unlikely(!ring_header->desc)) {
+               printk(KERN_WARNING
+                       "%s: pci_alloc_consistent failed, size = D%d\n",
+                       atl1_driver_name, size);
+               goto err_nomem;
+       }
+
+       memset(ring_header->desc, 0, ring_header->size);
+
+       /* init TPD ring */
+       tpd_ring->dma = ring_header->dma;
+       offset = (tpd_ring->dma & 0x7) ? (8 - (ring_header->dma & 0x7)) : 0;
+       tpd_ring->dma += offset;
+       tpd_ring->desc = (u8 *) ring_header->desc + offset;
+       tpd_ring->size = sizeof(struct tx_packet_desc) * tpd_ring->count;
+       atomic_set(&tpd_ring->next_to_use, 0);
+       atomic_set(&tpd_ring->next_to_clean, 0);
+
+       /* init RFD ring */
+       rfd_ring->dma = tpd_ring->dma + tpd_ring->size;
+       offset = (rfd_ring->dma & 0x7) ? (8 - (rfd_ring->dma & 0x7)) : 0;
+       rfd_ring->dma += offset;
+       rfd_ring->desc = (u8 *) tpd_ring->desc + (tpd_ring->size + offset);
+       rfd_ring->size = sizeof(struct rx_free_desc) * rfd_ring->count;
+       rfd_ring->next_to_clean = 0;
+       /* rfd_ring->next_to_use = rfd_ring->count - 1; */
+       atomic_set(&rfd_ring->next_to_use, 0);
+
+       /* init RRD ring */
+       rrd_ring->dma = rfd_ring->dma + rfd_ring->size;
+       offset = (rrd_ring->dma & 0x7) ? (8 - (rrd_ring->dma & 0x7)) : 0;
+       rrd_ring->dma += offset;
+       rrd_ring->desc = (u8 *) rfd_ring->desc + (rfd_ring->size + offset);
+       rrd_ring->size = sizeof(struct rx_return_desc) * rrd_ring->count;
+       rrd_ring->next_to_use = 0;
+       atomic_set(&rrd_ring->next_to_clean, 0);
+
+       /* init CMB */
+       adapter->cmb.dma = rrd_ring->dma + rrd_ring->size;
+       offset = (adapter->cmb.dma & 0x7) ? (8 - (adapter->cmb.dma & 0x7)) : 0;
+       adapter->cmb.dma += offset;
+       adapter->cmb.cmb =
+           (struct coals_msg_block *) ((u8 *) rrd_ring->desc +
+                                  (rrd_ring->size + offset));
+
+       /* init SMB */
+       adapter->smb.dma = adapter->cmb.dma + sizeof(struct coals_msg_block);
+       offset = (adapter->smb.dma & 0x7) ? (8 - (adapter->smb.dma & 0x7)) : 0;
+       adapter->smb.dma += offset;
+       adapter->smb.smb = (struct stats_msg_block *)
+           ((u8 *) adapter->cmb.cmb + (sizeof(struct coals_msg_block) + offset));
+
+       return ATL1_SUCCESS;
+
+err_nomem:
+       kfree(tpd_ring->buffer_info);
+       return -ENOMEM;
+}
+
+/*
+ * atl1_irq_enable - Enable default interrupt generation settings
+ * @adapter: board private structure
+ */
+static void atl1_irq_enable(struct atl1_adapter *adapter)
+{
+       if (likely(!atomic_dec_and_test(&adapter->irq_sem)))
+               iowrite32(IMR_NORMAL_MASK, adapter->hw.hw_addr + REG_IMR);
+}
+
+static void atl1_clear_phy_int(struct atl1_adapter *adapter)
+{
+       u16 phy_data;
+       unsigned long flags;
+
+       spin_lock_irqsave(&adapter->lock, flags);
+       atl1_read_phy_reg(&adapter->hw, 19, &phy_data);
+       spin_unlock_irqrestore(&adapter->lock, flags);
+}
+
+static void atl1_inc_smb(struct atl1_adapter *adapter)
+{
+       struct stats_msg_block *smb = adapter->smb.smb;
+
+       /* Fill out the OS statistics structure */
+       adapter->soft_stats.rx_packets += smb->rx_ok;
+       adapter->soft_stats.tx_packets += smb->tx_ok;
+       adapter->soft_stats.rx_bytes += smb->rx_byte_cnt;
+       adapter->soft_stats.tx_bytes += smb->tx_byte_cnt;
+       adapter->soft_stats.multicast += smb->rx_mcast;
+       adapter->soft_stats.collisions += (smb->tx_1_col +
+                                          smb->tx_2_col * 2 +
+                                          smb->tx_late_col +
+                                          smb->tx_abort_col *
+                                          adapter->hw.max_retry);
+
+       /* Rx Errors */
+       adapter->soft_stats.rx_errors += (smb->rx_frag +
+                                         smb->rx_fcs_err +
+                                         smb->rx_len_err +
+                                         smb->rx_sz_ov +
+                                         smb->rx_rxf_ov +
+                                         smb->rx_rrd_ov + smb->rx_align_err);
+       adapter->soft_stats.rx_fifo_errors += smb->rx_rxf_ov;
+       adapter->soft_stats.rx_length_errors += smb->rx_len_err;
+       adapter->soft_stats.rx_crc_errors += smb->rx_fcs_err;
+       adapter->soft_stats.rx_frame_errors += smb->rx_align_err;
+       adapter->soft_stats.rx_missed_errors += (smb->rx_rrd_ov +
+                                                smb->rx_rxf_ov);
+
+       adapter->soft_stats.rx_pause += smb->rx_pause;
+       adapter->soft_stats.rx_rrd_ov += smb->rx_rrd_ov;
+       adapter->soft_stats.rx_trunc += smb->rx_sz_ov;
+
+       /* Tx Errors */
+       adapter->soft_stats.tx_errors += (smb->tx_late_col +
+                                         smb->tx_abort_col +
+                                         smb->tx_underrun + smb->tx_trunc);
+       adapter->soft_stats.tx_fifo_errors += smb->tx_underrun;
+       adapter->soft_stats.tx_aborted_errors += smb->tx_abort_col;
+       adapter->soft_stats.tx_window_errors += smb->tx_late_col;
+
+       adapter->soft_stats.excecol += smb->tx_abort_col;
+       adapter->soft_stats.deffer += smb->tx_defer;
+       adapter->soft_stats.scc += smb->tx_1_col;
+       adapter->soft_stats.mcc += smb->tx_2_col;
+       adapter->soft_stats.latecol += smb->tx_late_col;
+       adapter->soft_stats.tx_underun += smb->tx_underrun;
+       adapter->soft_stats.tx_trunc += smb->tx_trunc;
+       adapter->soft_stats.tx_pause += smb->tx_pause;
+
+       adapter->net_stats.rx_packets = adapter->soft_stats.rx_packets;
+       adapter->net_stats.tx_packets = adapter->soft_stats.tx_packets;
+       adapter->net_stats.rx_bytes = adapter->soft_stats.rx_bytes;
+       adapter->net_stats.tx_bytes = adapter->soft_stats.tx_bytes;
+       adapter->net_stats.multicast = adapter->soft_stats.multicast;
+       adapter->net_stats.collisions = adapter->soft_stats.collisions;
+       adapter->net_stats.rx_errors = adapter->soft_stats.rx_errors;
+       adapter->net_stats.rx_over_errors =
+           adapter->soft_stats.rx_missed_errors;
+       adapter->net_stats.rx_length_errors =
+           adapter->soft_stats.rx_length_errors;
+       adapter->net_stats.rx_crc_errors = adapter->soft_stats.rx_crc_errors;
+       adapter->net_stats.rx_frame_errors =
+           adapter->soft_stats.rx_frame_errors;
+       adapter->net_stats.rx_fifo_errors = adapter->soft_stats.rx_fifo_errors;
+       adapter->net_stats.rx_missed_errors =
+           adapter->soft_stats.rx_missed_errors;
+       adapter->net_stats.tx_errors = adapter->soft_stats.tx_errors;
+       adapter->net_stats.tx_fifo_errors = adapter->soft_stats.tx_fifo_errors;
+       adapter->net_stats.tx_aborted_errors =
+           adapter->soft_stats.tx_aborted_errors;
+       adapter->net_stats.tx_window_errors =
+           adapter->soft_stats.tx_window_errors;
+       adapter->net_stats.tx_carrier_errors =
+           adapter->soft_stats.tx_carrier_errors;
+}
+
+static void atl1_rx_checksum(struct atl1_adapter *adapter,
+                                       struct rx_return_desc *rrd,
+                                       struct sk_buff *skb)
+{
+       skb->ip_summed = CHECKSUM_NONE;
+
+       if (unlikely(rrd->pkt_flg & PACKET_FLAG_ERR)) {
+               if (rrd->err_flg & (ERR_FLAG_CRC | ERR_FLAG_TRUNC |
+                                       ERR_FLAG_CODE | ERR_FLAG_OV)) {
+                       adapter->hw_csum_err++;
+                       printk(KERN_DEBUG "%s: rx checksum error\n",
+                               atl1_driver_name);
+                       return;
+               }
+       }
+
+       /* not IPv4 */
+       if (!(rrd->pkt_flg & PACKET_FLAG_IPV4))
+               /* checksum is invalid, but it's not an IPv4 pkt, so ok */
+               return;
+
+       /* IPv4 packet */
+       if (likely(!(rrd->err_flg &
+               (ERR_FLAG_IP_CHKSUM | ERR_FLAG_L4_CHKSUM)))) {
+               skb->ip_summed = CHECKSUM_UNNECESSARY;
+               adapter->hw_csum_good++;
+               return;
+       }
+
+       /* IPv4, but hardware thinks its checksum is wrong */
+       printk(KERN_DEBUG "%s: hw csum wrong pkt_flag:%x, err_flag:%x\n",
+               atl1_driver_name, rrd->pkt_flg, rrd->err_flg);
+       skb->ip_summed = CHECKSUM_COMPLETE;
+       skb->csum = htons(rrd->xsz.xsum_sz.rx_chksum);
+       adapter->hw_csum_err++;
+       return;
+}
+
+/*
+ * atl1_alloc_rx_buffers - Replace used receive buffers
+ * @adapter: address of board private structure
+ */
+static u16 atl1_alloc_rx_buffers(struct atl1_adapter *adapter)
+{
+       struct atl1_rfd_ring *rfd_ring = &adapter->rfd_ring;
+       struct net_device *netdev = adapter->netdev;
+       struct pci_dev *pdev = adapter->pdev;
+       struct page *page;
+       unsigned long offset;
+       struct atl1_buffer *buffer_info, *next_info;
+       struct sk_buff *skb;
+       u16 num_alloc = 0;
+       u16 rfd_next_to_use, next_next;
+       struct rx_free_desc *rfd_desc;
+
+       next_next = rfd_next_to_use = atomic_read(&rfd_ring->next_to_use);
+       if (++next_next == rfd_ring->count)
+               next_next = 0;
+       buffer_info = &rfd_ring->buffer_info[rfd_next_to_use];
+       next_info = &rfd_ring->buffer_info[next_next];
+
+       while (!buffer_info->alloced && !next_info->alloced) {
+               if (buffer_info->skb) {
+                       buffer_info->alloced = 1;
+                       goto next;
+               }
+
+               rfd_desc = ATL1_RFD_DESC(rfd_ring, rfd_next_to_use);
+
+               skb = dev_alloc_skb(adapter->rx_buffer_len + NET_IP_ALIGN);
+               if (unlikely(!skb)) {   /* Better luck next round */
+                       adapter->net_stats.rx_dropped++;
+                       break;
+               }
+
+               /*
+                * Make buffer alignment 2 beyond a 16 byte boundary
+                * this will result in a 16 byte aligned IP header after
+                * the 14 byte MAC header is removed
+                */
+               skb_reserve(skb, NET_IP_ALIGN);
+               skb->dev = netdev;
+
+               buffer_info->alloced = 1;
+               buffer_info->skb = skb;
+               buffer_info->length = (u16) adapter->rx_buffer_len;
+               page = virt_to_page(skb->data);
+               offset = (unsigned long)skb->data & ~PAGE_MASK;
+               buffer_info->dma = pci_map_page(pdev, page, offset,
+                                               adapter->rx_buffer_len,
+                                               PCI_DMA_FROMDEVICE);
+               rfd_desc->buffer_addr = cpu_to_le64(buffer_info->dma);
+               rfd_desc->buf_len = cpu_to_le16(adapter->rx_buffer_len);
+               rfd_desc->coalese = 0;
+
+next:
+               rfd_next_to_use = next_next;
+               if (unlikely(++next_next == rfd_ring->count))
+                       next_next = 0;
+
+               buffer_info = &rfd_ring->buffer_info[rfd_next_to_use];
+               next_info = &rfd_ring->buffer_info[next_next];
+               num_alloc++;
+       }
+
+       if (num_alloc) {
+               /*
+                * Force memory writes to complete before letting h/w
+                * know there are new descriptors to fetch.  (Only
+                * applicable for weak-ordered memory model archs,
+                * such as IA-64).
+                */
+               wmb();
+               atomic_set(&rfd_ring->next_to_use, (int)rfd_next_to_use);
+       }
+       return num_alloc;
+}
+
+static void atl1_intr_rx(struct atl1_adapter *adapter)
+{
+       int i, count;
+       u16 length;
+       u16 rrd_next_to_clean;
+       u32 value;
+       struct atl1_rfd_ring *rfd_ring = &adapter->rfd_ring;
+       struct atl1_rrd_ring *rrd_ring = &adapter->rrd_ring;
+       struct atl1_buffer *buffer_info;
+       struct rx_return_desc *rrd;
+       struct sk_buff *skb;
+
+       count = 0;
+
+       rrd_next_to_clean = atomic_read(&rrd_ring->next_to_clean);
+
+       while (1) {
+               rrd = ATL1_RRD_DESC(rrd_ring, rrd_next_to_clean);
+               i = 1;
+               if (likely(rrd->xsz.valid)) {   /* packet valid */
+chk_rrd:
+                       /* check rrd status */
+                       if (likely(rrd->num_buf == 1))
+                               goto rrd_ok;
+
+                       /* rrd seems to be bad */
+                       if (unlikely(i-- > 0)) {
+                               /* rrd may not be DMAed completely */
+                               printk(KERN_DEBUG
+                                       "%s: RRD may not be DMAed completely\n",
+                                       atl1_driver_name);
+                               udelay(1);
+                               goto chk_rrd;
+                       }
+                       /* bad rrd */
+                       printk(KERN_DEBUG "%s: bad RRD\n", atl1_driver_name);
+                       /* see if update RFD index */
+                       if (rrd->num_buf > 1) {
+                               u16 num_buf;
+                               num_buf =
+                                   (rrd->xsz.xsum_sz.pkt_size +
+                                    adapter->rx_buffer_len -
+                                    1) / adapter->rx_buffer_len;
+                               if (rrd->num_buf == num_buf) {
+                                       /* clean alloc flag for bad rrd */
+                                       while (rfd_ring->next_to_clean !=
+                                              (rrd->buf_indx + num_buf)) {
+                                               rfd_ring->buffer_info[rfd_ring->
+                                                                     next_to_clean].alloced = 0;
+                                               if (++rfd_ring->next_to_clean ==
+                                                   rfd_ring->count) {
+                                                       rfd_ring->
+                                                           next_to_clean = 0;
+                                               }
+                                       }
+                               }
+                       }
+
+                       /* update rrd */
+                       rrd->xsz.valid = 0;
+                       if (++rrd_next_to_clean == rrd_ring->count)
+                               rrd_next_to_clean = 0;
+                       count++;
+                       continue;
+               } else {        /* current rrd still not be updated */
+
+                       break;
+               }
+rrd_ok:
+               /* clean alloc flag for bad rrd */
+               while (rfd_ring->next_to_clean != rrd->buf_indx) {
+                       rfd_ring->buffer_info[rfd_ring->next_to_clean].alloced =
+                           0;
+                       if (++rfd_ring->next_to_clean == rfd_ring->count)
+                               rfd_ring->next_to_clean = 0;
+               }
+
+               buffer_info = &rfd_ring->buffer_info[rrd->buf_indx];
+               if (++rfd_ring->next_to_clean == rfd_ring->count)
+                       rfd_ring->next_to_clean = 0;
+
+               /* update rrd next to clean */
+               if (++rrd_next_to_clean == rrd_ring->count)
+                       rrd_next_to_clean = 0;
+               count++;
+
+               if (unlikely(rrd->pkt_flg & PACKET_FLAG_ERR)) {
+                       if (!(rrd->err_flg &
+                               (ERR_FLAG_IP_CHKSUM | ERR_FLAG_L4_CHKSUM
+                               | ERR_FLAG_LEN))) {
+                               /* packet error, don't need upstream */
+                               buffer_info->alloced = 0;
+                               rrd->xsz.valid = 0;
+                               continue;
+                       }
+               }
+
+               /* Good Receive */
+               pci_unmap_page(adapter->pdev, buffer_info->dma,
+                              buffer_info->length, PCI_DMA_FROMDEVICE);
+               skb = buffer_info->skb;
+               length = le16_to_cpu(rrd->xsz.xsum_sz.pkt_size);
+
+               skb_put(skb, length - ETHERNET_FCS_SIZE);
+
+               /* Receive Checksum Offload */
+               atl1_rx_checksum(adapter, rrd, skb);
+               skb->protocol = eth_type_trans(skb, adapter->netdev);
+
+               if (adapter->vlgrp && (rrd->pkt_flg & PACKET_FLAG_VLAN_INS)) {
+                       u16 vlan_tag = (rrd->vlan_tag >> 4) |
+                                       ((rrd->vlan_tag & 7) << 13) |
+                                       ((rrd->vlan_tag & 8) << 9);
+                       vlan_hwaccel_rx(skb, adapter->vlgrp, vlan_tag);
+               } else
+                       netif_rx(skb);
+
+               /* let protocol layer free skb */
+               buffer_info->skb = NULL;
+               buffer_info->alloced = 0;
+               rrd->xsz.valid = 0;
+
+               adapter->netdev->last_rx = jiffies;
+       }
+
+       atomic_set(&rrd_ring->next_to_clean, rrd_next_to_clean);
+
+       atl1_alloc_rx_buffers(adapter);
+
+       /* update mailbox ? */
+       if (count) {
+               u32 tpd_next_to_use;
+               u32 rfd_next_to_use;
+               u32 rrd_next_to_clean;
+
+               spin_lock(&adapter->mb_lock);
+
+               tpd_next_to_use = atomic_read(&adapter->tpd_ring.next_to_use);
+               rfd_next_to_use =
+                   atomic_read(&adapter->rfd_ring.next_to_use);
+               rrd_next_to_clean =
+                   atomic_read(&adapter->rrd_ring.next_to_clean);
+               value = ((rfd_next_to_use & MB_RFD_PROD_INDX_MASK) <<
+                       MB_RFD_PROD_INDX_SHIFT) |
+                        ((rrd_next_to_clean & MB_RRD_CONS_INDX_MASK) <<
+                       MB_RRD_CONS_INDX_SHIFT) |
+                        ((tpd_next_to_use & MB_TPD_PROD_INDX_MASK) <<
+                       MB_TPD_PROD_INDX_SHIFT);
+               iowrite32(value, adapter->hw.hw_addr + REG_MAILBOX);
+               spin_unlock(&adapter->mb_lock);
+       }
+}
+
+static void atl1_intr_tx(struct atl1_adapter *adapter)
+{
+       struct atl1_tpd_ring *tpd_ring = &adapter->tpd_ring;
+       struct atl1_buffer *buffer_info;
+       u16 sw_tpd_next_to_clean;
+       u16 cmb_tpd_next_to_clean;
+       u8 update = 0;
+
+       sw_tpd_next_to_clean = atomic_read(&tpd_ring->next_to_clean);
+       cmb_tpd_next_to_clean = le16_to_cpu(adapter->cmb.cmb->tpd_cons_idx);
+
+       while (cmb_tpd_next_to_clean != sw_tpd_next_to_clean) {
+               struct tx_packet_desc *tpd;
+               update = 1;
+               tpd = ATL1_TPD_DESC(tpd_ring, sw_tpd_next_to_clean);
+               buffer_info = &tpd_ring->buffer_info[sw_tpd_next_to_clean];
+               if (buffer_info->dma) {
+                       pci_unmap_page(adapter->pdev, buffer_info->dma,
+                                      buffer_info->length, PCI_DMA_TODEVICE);
+                       buffer_info->dma = 0;
+               }
+
+               if (buffer_info->skb) {
+                       dev_kfree_skb_irq(buffer_info->skb);
+                       buffer_info->skb = NULL;
+               }
+               tpd->buffer_addr = 0;
+               tpd->desc.data = 0;
+
+               if (++sw_tpd_next_to_clean == tpd_ring->count)
+                       sw_tpd_next_to_clean = 0;
+       }
+       atomic_set(&tpd_ring->next_to_clean, sw_tpd_next_to_clean);
+
+       if (netif_queue_stopped(adapter->netdev)
+           && netif_carrier_ok(adapter->netdev))
+               netif_wake_queue(adapter->netdev);
+}
+
+static void atl1_check_for_link(struct atl1_adapter *adapter)
+{
+       struct net_device *netdev = adapter->netdev;
+       u16 phy_data = 0;
+
+       spin_lock(&adapter->lock);
+       adapter->phy_timer_pending = false;
+       atl1_read_phy_reg(&adapter->hw, MII_BMSR, &phy_data);
+       atl1_read_phy_reg(&adapter->hw, MII_BMSR, &phy_data);
+       spin_unlock(&adapter->lock);
+
+       /* notify upper layer link down ASAP */
+       if (!(phy_data & BMSR_LSTATUS)) {       /* Link Down */
+               if (netif_carrier_ok(netdev)) { /* old link state: Up */
+                       printk(KERN_INFO "%s: %s link is down\n",
+                              atl1_driver_name, netdev->name);
+                       adapter->link_speed = SPEED_0;
+                       netif_carrier_off(netdev);
+                       netif_stop_queue(netdev);
+               }
+       }
+       schedule_work(&adapter->link_chg_task);
+}
+
+/*
+ * atl1_intr - Interrupt Handler
+ * @irq: interrupt number
+ * @data: pointer to a network interface device structure
+ * @pt_regs: CPU registers structure
+ */
+static irqreturn_t atl1_intr(int irq, void *data)
+{
+       /*struct atl1_adapter *adapter = ((struct net_device *)data)->priv;*/
+       struct atl1_adapter *adapter = netdev_priv(data);
+       u32 status;
+       u8 update_rx;
+       int max_ints = 10;
+
+       status = adapter->cmb.cmb->int_stats;
+       if (!status)
+               return IRQ_NONE;
+
+       update_rx = 0;
+
+       do {
+               /* clear CMB interrupt status at once */
+               adapter->cmb.cmb->int_stats = 0;
+
+               if (status & ISR_GPHY)  /* clear phy status */
+                       atl1_clear_phy_int(adapter);
+
+               /* clear ISR status, and Enable CMB DMA/Disable Interrupt */
+               iowrite32(status | ISR_DIS_INT, adapter->hw.hw_addr + REG_ISR);
+
+               /* check if SMB intr */
+               if (status & ISR_SMB)
+                       atl1_inc_smb(adapter);
+
+               /* check if PCIE PHY Link down */
+               if (status & ISR_PHY_LINKDOWN) {
+                       printk(KERN_DEBUG "%s: pcie phy link down %x\n",
+                               atl1_driver_name, status);
+                       if (netif_running(adapter->netdev)) {   /* reset MAC */
+                               iowrite32(0, adapter->hw.hw_addr + REG_IMR);
+                               schedule_work(&adapter->pcie_dma_to_rst_task);
+                               return IRQ_HANDLED;
+                       }
+               }
+
+               /* check if DMA read/write error ? */
+               if (status & (ISR_DMAR_TO_RST | ISR_DMAW_TO_RST)) {
+                       printk(KERN_DEBUG
+                               "%s: pcie DMA r/w error (status = 0x%x)\n",
+                               atl1_driver_name, status);
+                       iowrite32(0, adapter->hw.hw_addr + REG_IMR);
+                       schedule_work(&adapter->pcie_dma_to_rst_task);
+                       return IRQ_HANDLED;
+               }
+
+               /* link event */
+               if (status & ISR_GPHY) {
+                       adapter->soft_stats.tx_carrier_errors++;
+                       atl1_check_for_link(adapter);
+               }
+
+               /* transmit event */
+               if (status & ISR_CMB_TX)
+                       atl1_intr_tx(adapter);
+
+               /* rx exception */
+               if (unlikely(status & (ISR_RXF_OV | ISR_RFD_UNRUN |
+                               ISR_RRD_OV | ISR_HOST_RFD_UNRUN |
+                               ISR_HOST_RRD_OV | ISR_CMB_RX))) {
+                       if (status &
+                           (ISR_RXF_OV | ISR_RFD_UNRUN | ISR_RRD_OV |
+                            ISR_HOST_RFD_UNRUN | ISR_HOST_RRD_OV))
+                               printk(KERN_INFO
+                                       "%s: rx exception: status = 0x%x\n",
+                                       atl1_driver_name, status);
+                       atl1_intr_rx(adapter);
+               }
+
+               if (--max_ints < 0)
+                       break;
+
+       } while ((status = adapter->cmb.cmb->int_stats));
+
+       /* re-enable Interrupt */
+       iowrite32(ISR_DIS_SMB | ISR_DIS_DMA, adapter->hw.hw_addr + REG_ISR);
+       return IRQ_HANDLED;
+}
+
+/*
+ * atl1_set_multi - Multicast and Promiscuous mode set
+ * @netdev: network interface device structure
+ *
+ * The set_multi entry point is called whenever the multicast address
+ * list or the network interface flags are updated.  This routine is
+ * responsible for configuring the hardware for proper multicast,
+ * promiscuous mode, and all-multi behavior.
+ */
+static void atl1_set_multi(struct net_device *netdev)
+{
+       struct atl1_adapter *adapter = netdev_priv(netdev);
+       struct atl1_hw *hw = &adapter->hw;
+       struct dev_mc_list *mc_ptr;
+       u32 rctl;
+       u32 hash_value;
+
+       /* Check for Promiscuous and All Multicast modes */
+       rctl = ioread32(hw->hw_addr + REG_MAC_CTRL);
+       if (netdev->flags & IFF_PROMISC)
+               rctl |= MAC_CTRL_PROMIS_EN;
+       else if (netdev->flags & IFF_ALLMULTI) {
+               rctl |= MAC_CTRL_MC_ALL_EN;
+               rctl &= ~MAC_CTRL_PROMIS_EN;
+       } else
+               rctl &= ~(MAC_CTRL_PROMIS_EN | MAC_CTRL_MC_ALL_EN);
+
+       iowrite32(rctl, hw->hw_addr + REG_MAC_CTRL);
+
+       /* clear the old settings from the multicast hash table */
+       iowrite32(0, hw->hw_addr + REG_RX_HASH_TABLE);
+       iowrite32(0, (hw->hw_addr + REG_RX_HASH_TABLE) + (1 << 2));
+
+       /* compute mc addresses' hash value ,and put it into hash table */
+       for (mc_ptr = netdev->mc_list; mc_ptr; mc_ptr = mc_ptr->next) {
+               hash_value = atl1_hash_mc_addr(hw, mc_ptr->dmi_addr);
+               atl1_hash_set(hw, hash_value);
+       }
+}
+
+static void atl1_setup_mac_ctrl(struct atl1_adapter *adapter)
+{
+       u32 value;
+       struct atl1_hw *hw = &adapter->hw;
+       struct net_device *netdev = adapter->netdev;
+       /* Config MAC CTRL Register */
+       value = MAC_CTRL_TX_EN | MAC_CTRL_RX_EN;
+       /* duplex */
+       if (FULL_DUPLEX == adapter->link_duplex)
+               value |= MAC_CTRL_DUPLX;
+       /* speed */
+       value |= ((u32) ((SPEED_1000 == adapter->link_speed) ?
+                        MAC_CTRL_SPEED_1000 : MAC_CTRL_SPEED_10_100) <<
+                 MAC_CTRL_SPEED_SHIFT);
+       /* flow control */
+       value |= (MAC_CTRL_TX_FLOW | MAC_CTRL_RX_FLOW);
+       /* PAD & CRC */
+       value |= (MAC_CTRL_ADD_CRC | MAC_CTRL_PAD);
+       /* preamble length */
+       value |= (((u32) adapter->hw.preamble_len
+                  & MAC_CTRL_PRMLEN_MASK) << MAC_CTRL_PRMLEN_SHIFT);
+       /* vlan */
+       if (adapter->vlgrp)
+               value |= MAC_CTRL_RMV_VLAN;
+       /* rx checksum
+          if (adapter->rx_csum)
+          value |= MAC_CTRL_RX_CHKSUM_EN;
+        */
+       /* filter mode */
+       value |= MAC_CTRL_BC_EN;
+       if (netdev->flags & IFF_PROMISC)
+               value |= MAC_CTRL_PROMIS_EN;
+       else if (netdev->flags & IFF_ALLMULTI)
+               value |= MAC_CTRL_MC_ALL_EN;
+       /* value |= MAC_CTRL_LOOPBACK; */
+       iowrite32(value, hw->hw_addr + REG_MAC_CTRL);
+}
+
+static u32 atl1_check_link(struct atl1_adapter *adapter)
+{
+       struct atl1_hw *hw = &adapter->hw;
+       struct net_device *netdev = adapter->netdev;
+       u32 ret_val;
+       u16 speed, duplex, phy_data;
+       int reconfig = 0;
+
+       /* MII_BMSR must read twice */
+       atl1_read_phy_reg(hw, MII_BMSR, &phy_data);
+       atl1_read_phy_reg(hw, MII_BMSR, &phy_data);
+       if (!(phy_data & BMSR_LSTATUS)) {       /* link down */
+               if (netif_carrier_ok(netdev)) { /* old link state: Up */
+                       printk(KERN_INFO "%s: link is down\n",
+                               atl1_driver_name);
+                       adapter->link_speed = SPEED_0;
+                       netif_carrier_off(netdev);
+                       netif_stop_queue(netdev);
+               }
+               return ATL1_SUCCESS;
+       }
+
+       /* Link Up */
+       ret_val = atl1_get_speed_and_duplex(hw, &speed, &duplex);
+       if (ret_val)
+               return ret_val;
+
+       switch (hw->media_type) {
+       case MEDIA_TYPE_1000M_FULL:
+               if (speed != SPEED_1000 || duplex != FULL_DUPLEX)
+                       reconfig = 1;
+               break;
+       case MEDIA_TYPE_100M_FULL:
+               if (speed != SPEED_100 || duplex != FULL_DUPLEX)
+                       reconfig = 1;
+               break;
+       case MEDIA_TYPE_100M_HALF:
+               if (speed != SPEED_100 || duplex != HALF_DUPLEX)
+                       reconfig = 1;
+               break;
+       case MEDIA_TYPE_10M_FULL:
+               if (speed != SPEED_10 || duplex != FULL_DUPLEX)
+                       reconfig = 1;
+               break;
+       case MEDIA_TYPE_10M_HALF:
+               if (speed != SPEED_10 || duplex != HALF_DUPLEX)
+                       reconfig = 1;
+               break;
+       }
+
+       /* link result is our setting */
+       if (!reconfig) {
+               if (adapter->link_speed != speed
+                   || adapter->link_duplex != duplex) {
+                       adapter->link_speed = speed;
+                       adapter->link_duplex = duplex;
+                       atl1_setup_mac_ctrl(adapter);
+                       printk(KERN_INFO "%s: %s link is up %d Mbps %s\n",
+                              atl1_driver_name, netdev->name,
+                              adapter->link_speed,
+                              adapter->link_duplex ==
+                              FULL_DUPLEX ? "full duplex" : "half duplex");
+               }
+               if (!netif_carrier_ok(netdev)) {        /* Link down -> Up */
+                       netif_carrier_on(netdev);
+                       netif_wake_queue(netdev);
+               }
+               return ATL1_SUCCESS;
+       }
+
+       /* change orignal link status */
+       if (netif_carrier_ok(netdev)) {
+               adapter->link_speed = SPEED_0;
+               netif_carrier_off(netdev);
+               netif_stop_queue(netdev);
+       }
+
+       if (hw->media_type != MEDIA_TYPE_AUTO_SENSOR &&
+           hw->media_type != MEDIA_TYPE_1000M_FULL) {
+               switch (hw->media_type) {
+               case MEDIA_TYPE_100M_FULL:
+                       phy_data = MII_CR_FULL_DUPLEX | MII_CR_SPEED_100 |
+                                  MII_CR_RESET;
+                       break;
+               case MEDIA_TYPE_100M_HALF:
+                       phy_data = MII_CR_SPEED_100 | MII_CR_RESET;
+                       break;
+               case MEDIA_TYPE_10M_FULL:
+                       phy_data =
+                           MII_CR_FULL_DUPLEX | MII_CR_SPEED_10 | MII_CR_RESET;
+                       break;
+               default:        /* MEDIA_TYPE_10M_HALF: */
+                       phy_data = MII_CR_SPEED_10 | MII_CR_RESET;
+                       break;
+               }
+               atl1_write_phy_reg(hw, MII_BMCR, phy_data);
+               return ATL1_SUCCESS;
+       }
+
+       /* auto-neg, insert timer to re-config phy */
+       if (!adapter->phy_timer_pending) {
+               adapter->phy_timer_pending = true;
+               mod_timer(&adapter->phy_config_timer, jiffies + 3 * HZ);
+       }
+
+       return ATL1_SUCCESS;
+}
+
+static void set_flow_ctrl_old(struct atl1_adapter *adapter)
+{
+       u32 hi, lo, value;
+
+       /* RFD Flow Control */
+       value = adapter->rfd_ring.count;
+       hi = value / 16;
+       if (hi < 2)
+               hi = 2;
+       lo = value * 7 / 8;
+
+       value = ((hi & RXQ_RXF_PAUSE_TH_HI_MASK) << RXQ_RXF_PAUSE_TH_HI_SHIFT) |
+           ((lo & RXQ_RXF_PAUSE_TH_LO_MASK) << RXQ_RXF_PAUSE_TH_LO_SHIFT);
+       iowrite32(value, adapter->hw.hw_addr + REG_RXQ_RXF_PAUSE_THRESH);
+
+       /* RRD Flow Control */
+       value = adapter->rrd_ring.count;
+       lo = value / 16;
+       hi = value * 7 / 8;
+       if (lo < 2)
+               lo = 2;
+       value = ((hi & RXQ_RRD_PAUSE_TH_HI_MASK) << RXQ_RRD_PAUSE_TH_HI_SHIFT) |
+           ((lo & RXQ_RRD_PAUSE_TH_LO_MASK) << RXQ_RRD_PAUSE_TH_LO_SHIFT);
+       iowrite32(value, adapter->hw.hw_addr + REG_RXQ_RRD_PAUSE_THRESH);
+}
+
+static void set_flow_ctrl_new(struct atl1_hw *hw)
+{
+       u32 hi, lo, value;
+
+       /* RXF Flow Control */
+       value = ioread32(hw->hw_addr + REG_SRAM_RXF_LEN);
+       lo = value / 16;
+       if (lo < 192)
+               lo = 192;
+       hi = value * 7 / 8;
+       if (hi < lo)
+               hi = lo + 16;
+       value = ((hi & RXQ_RXF_PAUSE_TH_HI_MASK) << RXQ_RXF_PAUSE_TH_HI_SHIFT) |
+           ((lo & RXQ_RXF_PAUSE_TH_LO_MASK) << RXQ_RXF_PAUSE_TH_LO_SHIFT);
+       iowrite32(value, hw->hw_addr + REG_RXQ_RXF_PAUSE_THRESH);
+
+       /* RRD Flow Control */
+       value = ioread32(hw->hw_addr + REG_SRAM_RRD_LEN);
+       lo = value / 8;
+       hi = value * 7 / 8;
+       if (lo < 2)
+               lo = 2;
+       if (hi < lo)
+               hi = lo + 3;
+       value = ((hi & RXQ_RRD_PAUSE_TH_HI_MASK) << RXQ_RRD_PAUSE_TH_HI_SHIFT) |
+           ((lo & RXQ_RRD_PAUSE_TH_LO_MASK) << RXQ_RRD_PAUSE_TH_LO_SHIFT);
+       iowrite32(value, hw->hw_addr + REG_RXQ_RRD_PAUSE_THRESH);
+}
+
+/*
+ * atl1_configure - Configure Transmit&Receive Unit after Reset
+ * @adapter: board private structure
+ *
+ * Configure the Tx /Rx unit of the MAC after a reset.
+ */
+static u32 atl1_configure(struct atl1_adapter *adapter)
+{
+       struct atl1_hw *hw = &adapter->hw;
+       u32 value;
+
+       /* clear interrupt status */
+       iowrite32(0xffffffff, adapter->hw.hw_addr + REG_ISR);
+
+       /* set MAC Address */
+       value = (((u32) hw->mac_addr[2]) << 24) |
+               (((u32) hw->mac_addr[3]) << 16) |
+               (((u32) hw->mac_addr[4]) << 8) |
+               (((u32) hw->mac_addr[5]));
+       iowrite32(value, hw->hw_addr + REG_MAC_STA_ADDR);
+       value = (((u32) hw->mac_addr[0]) << 8) | (((u32) hw->mac_addr[1]));
+       iowrite32(value, hw->hw_addr + (REG_MAC_STA_ADDR + 4));
+
+       /* tx / rx ring */
+
+       /* HI base address */
+       iowrite32((u32) ((adapter->tpd_ring.dma & 0xffffffff00000000ULL) >> 32),
+               hw->hw_addr + REG_DESC_BASE_ADDR_HI);
+       /* LO base address */
+       iowrite32((u32) (adapter->rfd_ring.dma & 0x00000000ffffffffULL),
+               hw->hw_addr + REG_DESC_RFD_ADDR_LO);
+       iowrite32((u32) (adapter->rrd_ring.dma & 0x00000000ffffffffULL),
+               hw->hw_addr + REG_DESC_RRD_ADDR_LO);
+       iowrite32((u32) (adapter->tpd_ring.dma & 0x00000000ffffffffULL),
+               hw->hw_addr + REG_DESC_TPD_ADDR_LO);
+       iowrite32((u32) (adapter->cmb.dma & 0x00000000ffffffffULL),
+               hw->hw_addr + REG_DESC_CMB_ADDR_LO);
+       iowrite32((u32) (adapter->smb.dma & 0x00000000ffffffffULL),
+               hw->hw_addr + REG_DESC_SMB_ADDR_LO);
+
+       /* element count */
+       value = adapter->rrd_ring.count;
+       value <<= 16;
+       value += adapter->rfd_ring.count;
+       iowrite32(value, hw->hw_addr + REG_DESC_RFD_RRD_RING_SIZE);
+       iowrite32(adapter->tpd_ring.count, hw->hw_addr + REG_DESC_TPD_RING_SIZE);
+
+       /* Load Ptr */
+       iowrite32(1, hw->hw_addr + REG_LOAD_PTR);
+
+       /* config Mailbox */
+       value = ((atomic_read(&adapter->tpd_ring.next_to_use)
+                 & MB_TPD_PROD_INDX_MASK) << MB_TPD_PROD_INDX_SHIFT) |
+           ((atomic_read(&adapter->rrd_ring.next_to_clean)
+             & MB_RRD_CONS_INDX_MASK) << MB_RRD_CONS_INDX_SHIFT) |
+           ((atomic_read(&adapter->rfd_ring.next_to_use)
+             & MB_RFD_PROD_INDX_MASK) << MB_RFD_PROD_INDX_SHIFT);
+       iowrite32(value, hw->hw_addr + REG_MAILBOX);
+
+       /* config IPG/IFG */
+       value = (((u32) hw->ipgt & MAC_IPG_IFG_IPGT_MASK)
+                << MAC_IPG_IFG_IPGT_SHIFT) |
+           (((u32) hw->min_ifg & MAC_IPG_IFG_MIFG_MASK)
+            << MAC_IPG_IFG_MIFG_SHIFT) |
+           (((u32) hw->ipgr1 & MAC_IPG_IFG_IPGR1_MASK)
+            << MAC_IPG_IFG_IPGR1_SHIFT) |
+           (((u32) hw->ipgr2 & MAC_IPG_IFG_IPGR2_MASK)
+            << MAC_IPG_IFG_IPGR2_SHIFT);
+       iowrite32(value, hw->hw_addr + REG_MAC_IPG_IFG);
+
+       /* config  Half-Duplex Control */
+       value = ((u32) hw->lcol & MAC_HALF_DUPLX_CTRL_LCOL_MASK) |
+           (((u32) hw->max_retry & MAC_HALF_DUPLX_CTRL_RETRY_MASK)
+            << MAC_HALF_DUPLX_CTRL_RETRY_SHIFT) |
+           MAC_HALF_DUPLX_CTRL_EXC_DEF_EN |
+           (0xa << MAC_HALF_DUPLX_CTRL_ABEBT_SHIFT) |
+           (((u32) hw->jam_ipg & MAC_HALF_DUPLX_CTRL_JAMIPG_MASK)
+            << MAC_HALF_DUPLX_CTRL_JAMIPG_SHIFT);
+       iowrite32(value, hw->hw_addr + REG_MAC_HALF_DUPLX_CTRL);
+
+       /* set Interrupt Moderator Timer */
+       iowrite16(adapter->imt, hw->hw_addr + REG_IRQ_MODU_TIMER_INIT);
+       iowrite32(MASTER_CTRL_ITIMER_EN, hw->hw_addr + REG_MASTER_CTRL);
+
+       /* set Interrupt Clear Timer */
+       iowrite16(adapter->ict, hw->hw_addr + REG_CMBDISDMA_TIMER);
+
+       /* set MTU, 4 : VLAN */
+       iowrite32(hw->max_frame_size + 4, hw->hw_addr + REG_MTU);
+
+       /* jumbo size & rrd retirement timer */
+       value = (((u32) hw->rx_jumbo_th & RXQ_JMBOSZ_TH_MASK)
+                << RXQ_JMBOSZ_TH_SHIFT) |
+           (((u32) hw->rx_jumbo_lkah & RXQ_JMBO_LKAH_MASK)
+            << RXQ_JMBO_LKAH_SHIFT) |
+           (((u32) hw->rrd_ret_timer & RXQ_RRD_TIMER_MASK)
+            << RXQ_RRD_TIMER_SHIFT);
+       iowrite32(value, hw->hw_addr + REG_RXQ_JMBOSZ_RRDTIM);
+
+       /* Flow Control */
+       switch (hw->dev_rev) {
+       case 0x8001:
+       case 0x9001:
+       case 0x9002:
+       case 0x9003:
+               set_flow_ctrl_old(adapter);
+               break;
+       default:
+               set_flow_ctrl_new(hw);
+               break;
+       }
+
+       /* config TXQ */
+       value = (((u32) hw->tpd_burst & TXQ_CTRL_TPD_BURST_NUM_MASK)
+                << TXQ_CTRL_TPD_BURST_NUM_SHIFT) |
+           (((u32) hw->txf_burst & TXQ_CTRL_TXF_BURST_NUM_MASK)
+            << TXQ_CTRL_TXF_BURST_NUM_SHIFT) |
+           (((u32) hw->tpd_fetch_th & TXQ_CTRL_TPD_FETCH_TH_MASK)
+            << TXQ_CTRL_TPD_FETCH_TH_SHIFT) | TXQ_CTRL_ENH_MODE | TXQ_CTRL_EN;
+       iowrite32(value, hw->hw_addr + REG_TXQ_CTRL);
+
+       /* min tpd fetch gap & tx jumbo packet size threshold for taskoffload */
+       value = (((u32) hw->tx_jumbo_task_th & TX_JUMBO_TASK_TH_MASK)
+                << TX_JUMBO_TASK_TH_SHIFT) |
+           (((u32) hw->tpd_fetch_gap & TX_TPD_MIN_IPG_MASK)
+            << TX_TPD_MIN_IPG_SHIFT);
+       iowrite32(value, hw->hw_addr + REG_TX_JUMBO_TASK_TH_TPD_IPG);
+
+       /* config RXQ */
+       value = (((u32) hw->rfd_burst & RXQ_CTRL_RFD_BURST_NUM_MASK)
+                << RXQ_CTRL_RFD_BURST_NUM_SHIFT) |
+           (((u32) hw->rrd_burst & RXQ_CTRL_RRD_BURST_THRESH_MASK)
+            << RXQ_CTRL_RRD_BURST_THRESH_SHIFT) |
+           (((u32) hw->rfd_fetch_gap & RXQ_CTRL_RFD_PREF_MIN_IPG_MASK)
+            << RXQ_CTRL_RFD_PREF_MIN_IPG_SHIFT) |
+           RXQ_CTRL_CUT_THRU_EN | RXQ_CTRL_EN;
+       iowrite32(value, hw->hw_addr + REG_RXQ_CTRL);
+
+       /* config DMA Engine */
+       value = ((((u32) hw->dmar_block) & DMA_CTRL_DMAR_BURST_LEN_MASK)
+                << DMA_CTRL_DMAR_BURST_LEN_SHIFT) |
+           ((((u32) hw->dmaw_block) & DMA_CTRL_DMAR_BURST_LEN_MASK)
+            << DMA_CTRL_DMAR_BURST_LEN_SHIFT) |
+           DMA_CTRL_DMAR_EN | DMA_CTRL_DMAW_EN;
+       value |= (u32) hw->dma_ord;
+       if (atl1_rcb_128 == hw->rcb_value)
+               value |= DMA_CTRL_RCB_VALUE;
+       iowrite32(value, hw->hw_addr + REG_DMA_CTRL);
+
+       /* config CMB / SMB */
+       value = hw->cmb_rrd | ((u32) hw->cmb_tpd << 16);
+       iowrite32(value, hw->hw_addr + REG_CMB_WRITE_TH);
+       value = hw->cmb_rx_timer | ((u32) hw->cmb_tx_timer << 16);
+       iowrite32(value, hw->hw_addr + REG_CMB_WRITE_TIMER);
+       iowrite32(hw->smb_timer, hw->hw_addr + REG_SMB_TIMER);
+
+       /* --- enable CMB / SMB */
+       value = CSMB_CTRL_CMB_EN | CSMB_CTRL_SMB_EN;
+       iowrite32(value, hw->hw_addr + REG_CSMB_CTRL);
+
+       value = ioread32(adapter->hw.hw_addr + REG_ISR);
+       if (unlikely((value & ISR_PHY_LINKDOWN) != 0))
+               value = 1;      /* config failed */
+       else
+               value = 0;
+
+       /* clear all interrupt status */
+       iowrite32(0x3fffffff, adapter->hw.hw_addr + REG_ISR);
+       iowrite32(0, adapter->hw.hw_addr + REG_ISR);
+       return value;
+}
+
+/*
+ * atl1_irq_disable - Mask off interrupt generation on the NIC
+ * @adapter: board private structure
+ */
+static void atl1_irq_disable(struct atl1_adapter *adapter)
+{
+       atomic_inc(&adapter->irq_sem);
+       iowrite32(0, adapter->hw.hw_addr + REG_IMR);
+       ioread32(adapter->hw.hw_addr + REG_IMR);
+       synchronize_irq(adapter->pdev->irq);
+}
+
+static void atl1_vlan_rx_register(struct net_device *netdev,
+                               struct vlan_group *grp)
+{
+       struct atl1_adapter *adapter = netdev_priv(netdev);
+       unsigned long flags;
+       u32 ctrl;
+
+       spin_lock_irqsave(&adapter->lock, flags);
+       /* atl1_irq_disable(adapter); */
+       adapter->vlgrp = grp;
+
+       if (grp) {
+               /* enable VLAN tag insert/strip */
+               ctrl = ioread32(adapter->hw.hw_addr + REG_MAC_CTRL);
+               ctrl |= MAC_CTRL_RMV_VLAN;
+               iowrite32(ctrl, adapter->hw.hw_addr + REG_MAC_CTRL);
+       } else {
+               /* disable VLAN tag insert/strip */
+               ctrl = ioread32(adapter->hw.hw_addr + REG_MAC_CTRL);
+               ctrl &= ~MAC_CTRL_RMV_VLAN;
+               iowrite32(ctrl, adapter->hw.hw_addr + REG_MAC_CTRL);
+       }
+
+       /* atl1_irq_enable(adapter); */
+       spin_unlock_irqrestore(&adapter->lock, flags);
+}
+
+/* FIXME: justify or remove -- CHS */
+static void atl1_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
+{
+       /* We don't do Vlan filtering */
+       return;
+}
+
+/* FIXME: this looks wrong too -- CHS */
+static void atl1_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
+{
+       struct atl1_adapter *adapter = netdev_priv(netdev);
+       unsigned long flags;
+
+       spin_lock_irqsave(&adapter->lock, flags);
+       /* atl1_irq_disable(adapter); */
+       if (adapter->vlgrp)
+               adapter->vlgrp->vlan_devices[vid] = NULL;
+       /* atl1_irq_enable(adapter); */
+       spin_unlock_irqrestore(&adapter->lock, flags);
+       /* We don't do Vlan filtering */
+       return;
+}
+
+static void atl1_restore_vlan(struct atl1_adapter *adapter)
+{
+       atl1_vlan_rx_register(adapter->netdev, adapter->vlgrp);
+       if (adapter->vlgrp) {
+               u16 vid;
+               for (vid = 0; vid < VLAN_GROUP_ARRAY_LEN; vid++) {
+                       if (!adapter->vlgrp->vlan_devices[vid])
+                               continue;
+                       atl1_vlan_rx_add_vid(adapter->netdev, vid);
+               }
+       }
+}
+
+static u16 tpd_avail(struct atl1_tpd_ring *tpd_ring)
+{
+       u16 next_to_clean = atomic_read(&tpd_ring->next_to_clean);
+       u16 next_to_use = atomic_read(&tpd_ring->next_to_use);
+       return ((next_to_clean >
+                next_to_use) ? next_to_clean - next_to_use -
+               1 : tpd_ring->count + next_to_clean - next_to_use - 1);
+}
+
+static int atl1_tso(struct atl1_adapter *adapter, struct sk_buff *skb,
+                        struct tso_param *tso)
+{
+       /* We enter this function holding a spinlock. */
+       u8 ipofst;
+       int err;
+
+       if (skb_shinfo(skb)->gso_size) {
+               if (skb_header_cloned(skb)) {
+                       err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC);
+                       if (unlikely(err))
+                               return err;
+               }
+
+               if (skb->protocol == ntohs(ETH_P_IP)) {
+                       skb->nh.iph->tot_len = 0;
+                       skb->nh.iph->check = 0;
+                       skb->h.th->check =
+                           ~csum_tcpudp_magic(skb->nh.iph->saddr,
+                                              skb->nh.iph->daddr, 0,
+                                              IPPROTO_TCP, 0);
+                       ipofst = skb->nh.raw - skb->data;
+                       if (ipofst != ENET_HEADER_SIZE) /* 802.3 frame */
+                               tso->tsopl |= 1 << TSO_PARAM_ETHTYPE_SHIFT;
+
+                       tso->tsopl |= (skb->nh.iph->ihl &
+                               CSUM_PARAM_IPHL_MASK) << CSUM_PARAM_IPHL_SHIFT;
+                       tso->tsopl |= ((skb->h.th->doff << 2) &
+                               TSO_PARAM_TCPHDRLEN_MASK) << TSO_PARAM_TCPHDRLEN_SHIFT;
+                       tso->tsopl |= (skb_shinfo(skb)->gso_size &
+                               TSO_PARAM_MSS_MASK) << TSO_PARAM_MSS_SHIFT;
+                       tso->tsopl |= 1 << TSO_PARAM_IPCKSUM_SHIFT;
+                       tso->tsopl |= 1 << TSO_PARAM_TCPCKSUM_SHIFT;
+                       tso->tsopl |= 1 << TSO_PARAM_SEGMENT_SHIFT;
+                       return true;
+               }
+       }
+       return false;
+}
+
+static int atl1_tx_csum(struct atl1_adapter *adapter, struct sk_buff *skb,
+                       struct csum_param *csum)
+{
+       u8 css, cso;
+
+       if (likely(skb->ip_summed == CHECKSUM_PARTIAL)) {
+               cso = skb->h.raw - skb->data;
+               css = (skb->h.raw + skb->csum) - skb->data;
+               if (unlikely(cso & 0x1)) {
+                       printk(KERN_DEBUG "%s: payload offset != even number\n",
+                               atl1_driver_name);
+                       return -1;
+               }
+               csum->csumpl |= (cso & CSUM_PARAM_PLOADOFFSET_MASK) <<
+                       CSUM_PARAM_PLOADOFFSET_SHIFT;
+               csum->csumpl |= (css & CSUM_PARAM_XSUMOFFSET_MASK) <<
+                       CSUM_PARAM_XSUMOFFSET_SHIFT;
+               csum->csumpl |= 1 << CSUM_PARAM_CUSTOMCKSUM_SHIFT;
+               return true;
+       }
+
+       return true;
+}
+
+static void atl1_tx_map(struct atl1_adapter *adapter,
+                               struct sk_buff *skb, bool tcp_seg)
+{
+       /* We enter this function holding a spinlock. */
+       struct atl1_tpd_ring *tpd_ring = &adapter->tpd_ring;
+       struct atl1_buffer *buffer_info;
+       struct page *page;
+       int first_buf_len = skb->len;
+       unsigned long offset;
+       unsigned int nr_frags;
+       unsigned int f;
+       u16 tpd_next_to_use;
+       u16 proto_hdr_len;
+       u16 i, m, len12;
+
+       first_buf_len -= skb->data_len;
+       nr_frags = skb_shinfo(skb)->nr_frags;
+       tpd_next_to_use = atomic_read(&tpd_ring->next_to_use);
+       buffer_info = &tpd_ring->buffer_info[tpd_next_to_use];
+       if (unlikely(buffer_info->skb))
+               BUG();
+       buffer_info->skb = NULL;        /* put skb in last TPD */
+
+       if (tcp_seg) {
+               /* TSO/GSO */
+               proto_hdr_len =
+                   ((skb->h.raw - skb->data) + (skb->h.th->doff << 2));
+               buffer_info->length = proto_hdr_len;
+               page = virt_to_page(skb->data);
+               offset = (unsigned long)skb->data & ~PAGE_MASK;
+               buffer_info->dma = pci_map_page(adapter->pdev, page,
+                                               offset, proto_hdr_len,
+                                               PCI_DMA_TODEVICE);
+
+               if (++tpd_next_to_use == tpd_ring->count)
+                       tpd_next_to_use = 0;
+
+               if (first_buf_len > proto_hdr_len) {
+                       len12 = first_buf_len - proto_hdr_len;
+                       m = (len12 + MAX_TX_BUF_LEN - 1) / MAX_TX_BUF_LEN;
+                       for (i = 0; i < m; i++) {
+                               buffer_info =
+                                   &tpd_ring->buffer_info[tpd_next_to_use];
+                               buffer_info->skb = NULL;
+                               buffer_info->length =
+                                   (MAX_TX_BUF_LEN >=
+                                    len12) ? MAX_TX_BUF_LEN : len12;
+                               len12 -= buffer_info->length;
+                               page = virt_to_page(skb->data +
+                                                (proto_hdr_len +
+                                                 i * MAX_TX_BUF_LEN));
+                               offset = (unsigned long)(skb->data +
+                                                       (proto_hdr_len +
+                                                       i * MAX_TX_BUF_LEN)) &
+                                                       ~PAGE_MASK;
+                               buffer_info->dma =
+                                   pci_map_page(adapter->pdev, page, offset,
+                                                buffer_info->length,
+                                                PCI_DMA_TODEVICE);
+                               if (++tpd_next_to_use == tpd_ring->count)
+                                       tpd_next_to_use = 0;
+                       }
+               }
+       } else {
+               /* not TSO/GSO */
+               buffer_info->length = first_buf_len;
+               page = virt_to_page(skb->data);
+               offset = (unsigned long)skb->data & ~PAGE_MASK;
+               buffer_info->dma = pci_map_page(adapter->pdev, page,
+                                               offset, first_buf_len,
+                                               PCI_DMA_TODEVICE);
+               if (++tpd_next_to_use == tpd_ring->count)
+                       tpd_next_to_use = 0;
+       }
+
+       for (f = 0; f < nr_frags; f++) {
+               struct skb_frag_struct *frag;
+               u16 lenf, i, m;
+
+               frag = &skb_shinfo(skb)->frags[f];
+               lenf = frag->size;
+
+               m = (lenf + MAX_TX_BUF_LEN - 1) / MAX_TX_BUF_LEN;
+               for (i = 0; i < m; i++) {
+                       buffer_info = &tpd_ring->buffer_info[tpd_next_to_use];
+                       if (unlikely(buffer_info->skb))
+                               BUG();
+                       buffer_info->skb = NULL;
+                       buffer_info->length =
+                           (lenf > MAX_TX_BUF_LEN) ? MAX_TX_BUF_LEN : lenf;
+                       lenf -= buffer_info->length;
+                       buffer_info->dma =
+                           pci_map_page(adapter->pdev, frag->page,
+                                        frag->page_offset + i * MAX_TX_BUF_LEN,
+                                        buffer_info->length, PCI_DMA_TODEVICE);
+
+                       if (++tpd_next_to_use == tpd_ring->count)
+                               tpd_next_to_use = 0;
+               }
+       }
+
+       /* last tpd's buffer-info */
+       buffer_info->skb = skb;
+}
+
+static void atl1_tx_queue(struct atl1_adapter *adapter, int count,
+                              union tpd_descr *descr)
+{
+       /* We enter this function holding a spinlock. */
+       struct atl1_tpd_ring *tpd_ring = &adapter->tpd_ring;
+       int j;
+       u32 val;
+       struct atl1_buffer *buffer_info;
+       struct tx_packet_desc *tpd;
+       u16 tpd_next_to_use = atomic_read(&tpd_ring->next_to_use);
+
+       for (j = 0; j < count; j++) {
+               buffer_info = &tpd_ring->buffer_info[tpd_next_to_use];
+               tpd = ATL1_TPD_DESC(&adapter->tpd_ring, tpd_next_to_use);
+               tpd->desc.csum.csumpu = descr->csum.csumpu;
+               tpd->desc.csum.csumpl = descr->csum.csumpl;
+               tpd->desc.tso.tsopu = descr->tso.tsopu;
+               tpd->desc.tso.tsopl = descr->tso.tsopl;
+               tpd->buffer_addr = cpu_to_le64(buffer_info->dma);
+               tpd->desc.data = descr->data;
+               tpd->desc.csum.csumpu |= (cpu_to_le16(buffer_info->length) &
+                       CSUM_PARAM_BUFLEN_MASK) << CSUM_PARAM_BUFLEN_SHIFT;
+
+               val = (descr->tso.tsopl >> TSO_PARAM_SEGMENT_SHIFT) &
+                       TSO_PARAM_SEGMENT_MASK;
+               if (val && !j)
+                       tpd->desc.tso.tsopl |= 1 << TSO_PARAM_HDRFLAG_SHIFT;
+
+               if (j == (count - 1))
+                       tpd->desc.csum.csumpl |= 1 << CSUM_PARAM_EOP_SHIFT;
+
+               if (++tpd_next_to_use == tpd_ring->count)
+                       tpd_next_to_use = 0;
+       }
+       /*
+        * Force memory writes to complete before letting h/w
+        * know there are new descriptors to fetch.  (Only
+        * applicable for weak-ordered memory model archs,
+        * such as IA-64).
+        */
+       wmb();
+
+       atomic_set(&tpd_ring->next_to_use, (int)tpd_next_to_use);
+}
+
+static void atl1_update_mailbox(struct atl1_adapter *adapter)
+{
+       unsigned long flags;
+       u32 tpd_next_to_use;
+       u32 rfd_next_to_use;
+       u32 rrd_next_to_clean;
+       u32 value;
+
+       spin_lock_irqsave(&adapter->mb_lock, flags);
+
+       tpd_next_to_use = atomic_read(&adapter->tpd_ring.next_to_use);
+       rfd_next_to_use = atomic_read(&adapter->rfd_ring.next_to_use);
+       rrd_next_to_clean = atomic_read(&adapter->rrd_ring.next_to_clean);
+
+       value = ((rfd_next_to_use & MB_RFD_PROD_INDX_MASK) <<
+               MB_RFD_PROD_INDX_SHIFT) |
+               ((rrd_next_to_clean & MB_RRD_CONS_INDX_MASK) <<
+               MB_RRD_CONS_INDX_SHIFT) |
+               ((tpd_next_to_use & MB_TPD_PROD_INDX_MASK) <<
+               MB_TPD_PROD_INDX_SHIFT);
+       iowrite32(value, adapter->hw.hw_addr + REG_MAILBOX);
+
+       spin_unlock_irqrestore(&adapter->mb_lock, flags);
+}
+
+static int atl1_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
+{
+       struct atl1_adapter *adapter = netdev_priv(netdev);
+       int len = skb->len;
+       int tso;
+       int count = 1;
+       int ret_val;
+       u32 val;
+       union tpd_descr param;
+       u16 frag_size;
+       u16 vlan_tag;
+       unsigned long flags;
+       unsigned int nr_frags = 0;
+       unsigned int mss = 0;
+       unsigned int f;
+       unsigned int proto_hdr_len;
+
+       len -= skb->data_len;
+
+       if (unlikely(skb->len == 0)) {
+               dev_kfree_skb_any(skb);
+               return NETDEV_TX_OK;
+       }
+
+       param.data = 0;
+       param.tso.tsopu = 0;
+       param.tso.tsopl = 0;
+       param.csum.csumpu = 0;
+       param.csum.csumpl = 0;
+
+       /* nr_frags will be nonzero if we're doing scatter/gather (SG) */
+       nr_frags = skb_shinfo(skb)->nr_frags;
+       for (f = 0; f < nr_frags; f++) {
+               frag_size = skb_shinfo(skb)->frags[f].size;
+               if (frag_size)
+                       count +=
+                           (frag_size + MAX_TX_BUF_LEN - 1) / MAX_TX_BUF_LEN;
+       }
+
+       /* mss will be nonzero if we're doing segment offload (TSO/GSO) */
+       mss = skb_shinfo(skb)->gso_size;
+       if (mss) {
+               if (skb->protocol == ntohs(ETH_P_IP)) {
+                       proto_hdr_len = ((skb->h.raw - skb->data) +
+                                        (skb->h.th->doff << 2));
+                       if (unlikely(proto_hdr_len > len)) {
+                               dev_kfree_skb_any(skb);
+                               return NETDEV_TX_OK;
+                       }
+                       /* need additional TPD ? */
+                       if (proto_hdr_len != len)
+                               count += (len - proto_hdr_len +
+                                       MAX_TX_BUF_LEN - 1) / MAX_TX_BUF_LEN;
+               }
+       }
+
+       local_irq_save(flags);
+       if (!spin_trylock(&adapter->lock)) {
+               /* Can't get lock - tell upper layer to requeue */
+               local_irq_restore(flags);
+               printk(KERN_DEBUG "%s: TX locked\n", atl1_driver_name);
+               return NETDEV_TX_LOCKED;
+       }
+
+       if (tpd_avail(&adapter->tpd_ring) < count) {
+               /* not enough descriptors */
+               netif_stop_queue(netdev);
+               spin_unlock_irqrestore(&adapter->lock, flags);
+               printk(KERN_DEBUG "%s: TX busy\n", atl1_driver_name);
+               return NETDEV_TX_BUSY;
+       }
+
+       param.data = 0;
+
+       if (adapter->vlgrp && vlan_tx_tag_present(skb)) {
+               vlan_tag = vlan_tx_tag_get(skb);
+               vlan_tag = (vlan_tag << 4) | (vlan_tag >> 13) |
+                       ((vlan_tag >> 9) & 0x8);
+               param.csum.csumpl |= 1 << CSUM_PARAM_INSVLAG_SHIFT;
+               param.csum.csumpu |= (vlan_tag & CSUM_PARAM_VALANTAG_MASK) <<
+                       CSUM_PARAM_VALAN_SHIFT;
+       }
+
+       tso = atl1_tso(adapter, skb, &param.tso);
+       if (tso < 0) {
+               spin_unlock_irqrestore(&adapter->lock, flags);
+               dev_kfree_skb_any(skb);
+               return NETDEV_TX_OK;
+       }
+
+       if (!tso) {
+               ret_val = atl1_tx_csum(adapter, skb, &param.csum);
+               if (ret_val < 0) {
+                       spin_unlock_irqrestore(&adapter->lock, flags);
+                       dev_kfree_skb_any(skb);
+                       return NETDEV_TX_OK;
+               }
+       }
+
+       val = (param.csum.csumpl >> CSUM_PARAM_SEGMENT_SHIFT) &
+               CSUM_PARAM_SEGMENT_MASK;
+       atl1_tx_map(adapter, skb, 1 == val);
+       atl1_tx_queue(adapter, count, &param);
+       netdev->trans_start = jiffies;
+       spin_unlock_irqrestore(&adapter->lock, flags);
+       atl1_update_mailbox(adapter);
+       return NETDEV_TX_OK;
+}
+
+/*
+ * atl1_get_stats - Get System Network Statistics
+ * @netdev: network interface device structure
+ *
+ * Returns the address of the device statistics structure.
+ * The statistics are actually updated from the timer callback.
+ */
+static struct net_device_stats *atl1_get_stats(struct net_device *netdev)
+{
+       struct atl1_adapter *adapter = netdev_priv(netdev);
+       return &adapter->net_stats;
+}
+
+/*
+ * atl1_clean_rx_ring - Free RFD Buffers
+ * @adapter: board private structure
+ */
+static void atl1_clean_rx_ring(struct atl1_adapter *adapter)
+{
+       struct atl1_rfd_ring *rfd_ring = &adapter->rfd_ring;
+       struct atl1_rrd_ring *rrd_ring = &adapter->rrd_ring;
+       struct atl1_buffer *buffer_info;
+       struct pci_dev *pdev = adapter->pdev;
+       unsigned long size;
+       unsigned int i;
+
+       /* Free all the Rx ring sk_buffs */
+       for (i = 0; i < rfd_ring->count; i++) {
+               buffer_info = &rfd_ring->buffer_info[i];
+               if (buffer_info->dma) {
+                       pci_unmap_page(pdev,
+                                       buffer_info->dma,
+                                       buffer_info->length,
+                                       PCI_DMA_FROMDEVICE);
+                       buffer_info->dma = 0;
+               }
+               if (buffer_info->skb) {
+                       dev_kfree_skb(buffer_info->skb);
+                       buffer_info->skb = NULL;
+               }
+       }
+
+       size = sizeof(struct atl1_buffer) * rfd_ring->count;
+       memset(rfd_ring->buffer_info, 0, size);
+
+       /* Zero out the descriptor ring */
+       memset(rfd_ring->desc, 0, rfd_ring->size);
+
+       rfd_ring->next_to_clean = 0;
+       atomic_set(&rfd_ring->next_to_use, 0);
+
+       rrd_ring->next_to_use = 0;
+       atomic_set(&rrd_ring->next_to_clean, 0);
+}
+
+/*
+ * atl1_clean_tx_ring - Free Tx Buffers
+ * @adapter: board private structure
+ */
+static void atl1_clean_tx_ring(struct atl1_adapter *adapter)
+{
+       struct atl1_tpd_ring *tpd_ring = &adapter->tpd_ring;
+       struct atl1_buffer *buffer_info;
+       struct pci_dev *pdev = adapter->pdev;
+       unsigned long size;
+       unsigned int i;
+
+       /* Free all the Tx ring sk_buffs */
+       for (i = 0; i < tpd_ring->count; i++) {
+               buffer_info = &tpd_ring->buffer_info[i];
+               if (buffer_info->dma) {
+                       pci_unmap_page(pdev, buffer_info->dma,
+                                      buffer_info->length, PCI_DMA_TODEVICE);
+                       buffer_info->dma = 0;
+               }
+       }
+
+       for (i = 0; i < tpd_ring->count; i++) {
+               buffer_info = &tpd_ring->buffer_info[i];
+               if (buffer_info->skb) {
+                       dev_kfree_skb_any(buffer_info->skb);
+                       buffer_info->skb = NULL;
+               }
+       }
+
+       size = sizeof(struct atl1_buffer) * tpd_ring->count;
+       memset(tpd_ring->buffer_info, 0, size);
+
+       /* Zero out the descriptor ring */
+       memset(tpd_ring->desc, 0, tpd_ring->size);
+
+       atomic_set(&tpd_ring->next_to_use, 0);
+       atomic_set(&tpd_ring->next_to_clean, 0);
+}
+
+/*
+ * atl1_free_ring_resources - Free Tx / RX descriptor Resources
+ * @adapter: board private structure
+ *
+ * Free all transmit software resources
+ */
+void atl1_free_ring_resources(struct atl1_adapter *adapter)
+{
+       struct pci_dev *pdev = adapter->pdev;
+       struct atl1_tpd_ring *tpd_ring = &adapter->tpd_ring;
+       struct atl1_rfd_ring *rfd_ring = &adapter->rfd_ring;
+       struct atl1_rrd_ring *rrd_ring = &adapter->rrd_ring;
+       struct atl1_ring_header *ring_header = &adapter->ring_header;
+
+       atl1_clean_tx_ring(adapter);
+       atl1_clean_rx_ring(adapter);
+
+       kfree(tpd_ring->buffer_info);
+       pci_free_consistent(pdev, ring_header->size, ring_header->desc,
+                           ring_header->dma);
+
+       tpd_ring->buffer_info = NULL;
+       tpd_ring->desc = NULL;
+       tpd_ring->dma = 0;
+
+       rfd_ring->buffer_info = NULL;
+       rfd_ring->desc = NULL;
+       rfd_ring->dma = 0;
+
+       rrd_ring->desc = NULL;
+       rrd_ring->dma = 0;
+}
+
+s32 atl1_up(struct atl1_adapter *adapter)
+{
+       struct net_device *netdev = adapter->netdev;
+       int err;
+       int irq_flags = IRQF_SAMPLE_RANDOM;
+
+       /* hardware has been reset, we need to reload some things */
+       atl1_set_multi(netdev);
+       atl1_restore_vlan(adapter);
+       err = atl1_alloc_rx_buffers(adapter);
+       if (unlikely(!err))             /* no RX BUFFER allocated */
+               return -ENOMEM;
+
+       if (unlikely(atl1_configure(adapter))) {
+               err = -EIO;
+               goto err_up;
+       }
+
+       err = pci_enable_msi(adapter->pdev);
+       if (err) {
+               dev_info(&adapter->pdev->dev,
+                       "Unable to enable MSI: %d\n", err);
+               irq_flags |= IRQF_SHARED;
+       }
+
+       err = request_irq(adapter->pdev->irq, &atl1_intr, irq_flags,
+                       netdev->name, netdev);
+       if (unlikely(err))
+               goto err_up;
+
+       mod_timer(&adapter->watchdog_timer, jiffies);
+       atl1_irq_enable(adapter);
+       atl1_check_link(adapter);
+       return 0;
+
+       /* FIXME: unreachable code! -- CHS */
+       /* free irq disable any interrupt */
+       iowrite32(0, adapter->hw.hw_addr + REG_IMR);
+       free_irq(adapter->pdev->irq, netdev);
+
+err_up:
+       pci_disable_msi(adapter->pdev);
+       /* free rx_buffers */
+       atl1_clean_rx_ring(adapter);
+       return err;
+}
+
+void atl1_down(struct atl1_adapter *adapter)
+{
+       struct net_device *netdev = adapter->netdev;
+
+       del_timer_sync(&adapter->watchdog_timer);
+       del_timer_sync(&adapter->phy_config_timer);
+       adapter->phy_timer_pending = false;
+
+       atl1_irq_disable(adapter);
+       free_irq(adapter->pdev->irq, netdev);
+       pci_disable_msi(adapter->pdev);
+       atl1_reset_hw(&adapter->hw);
+       adapter->cmb.cmb->int_stats = 0;
+
+       adapter->link_speed = SPEED_0;
+       adapter->link_duplex = -1;
+       netif_carrier_off(netdev);
+       netif_stop_queue(netdev);
+
+       atl1_clean_tx_ring(adapter);
+       atl1_clean_rx_ring(adapter);
+}
+
+/*
+ * atl1_change_mtu - Change the Maximum Transfer Unit
+ * @netdev: network interface device structure
+ * @new_mtu: new value for maximum frame size
+ *
+ * Returns 0 on success, negative on failure
+ */
+static int atl1_change_mtu(struct net_device *netdev, int new_mtu)
+{
+       struct atl1_adapter *adapter = netdev_priv(netdev);
+       int old_mtu = netdev->mtu;
+       int max_frame = new_mtu + ENET_HEADER_SIZE + ETHERNET_FCS_SIZE;
+
+       if ((max_frame < MINIMUM_ETHERNET_FRAME_SIZE) ||
+           (max_frame > MAX_JUMBO_FRAME_SIZE)) {
+               printk(KERN_WARNING "%s: invalid MTU setting\n",
+                       atl1_driver_name);
+               return -EINVAL;
+       }
+
+       adapter->hw.max_frame_size = max_frame;
+       adapter->hw.tx_jumbo_task_th = (max_frame + 7) >> 3;
+       adapter->rx_buffer_len = (max_frame + 7) & ~7;
+       adapter->hw.rx_jumbo_th = adapter->rx_buffer_len / 8;
+
+       netdev->mtu = new_mtu;
+       if ((old_mtu != new_mtu) && netif_running(netdev)) {
+               atl1_down(adapter);
+               atl1_up(adapter);
+       }
+
+       return 0;
+}
+
+/*
+ * atl1_set_mac - Change the Ethernet Address of the NIC
+ * @netdev: network interface device structure
+ * @p: pointer to an address structure
+ *
+ * Returns 0 on success, negative on failure
+ */
+static int atl1_set_mac(struct net_device *netdev, void *p)
+{
+       struct atl1_adapter *adapter = netdev_priv(netdev);
+       struct sockaddr *addr = p;
+
+       if (netif_running(netdev))
+               return -EBUSY;
+
+       if (!is_valid_ether_addr(addr->sa_data))
+               return -EADDRNOTAVAIL;
+
+       memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
+       memcpy(adapter->hw.mac_addr, addr->sa_data, netdev->addr_len);
+
+       atl1_set_mac_addr(&adapter->hw);
+       return 0;
+}
+
+/*
+ * atl1_watchdog - Timer Call-back
+ * @data: pointer to netdev cast into an unsigned long
+ */
+static void atl1_watchdog(unsigned long data)
+{
+       struct atl1_adapter *adapter = (struct atl1_adapter *)data;
+
+       /* Reset the timer */
+       mod_timer(&adapter->watchdog_timer, jiffies + 2 * HZ);
+}
+
+static int mdio_read(struct net_device *netdev, int phy_id, int reg_num)
+{
+       struct atl1_adapter *adapter = netdev_priv(netdev);
+       u16 result;
+
+       atl1_read_phy_reg(&adapter->hw, reg_num & 0x1f, &result);
+
+       return result;
+}
+
+static void mdio_write(struct net_device *netdev, int phy_id, int reg_num, int val)
+{
+       struct atl1_adapter *adapter = netdev_priv(netdev);
+
+       atl1_write_phy_reg(&adapter->hw, reg_num, val);
+}
+
+/*
+ * atl1_mii_ioctl -
+ * @netdev:
+ * @ifreq:
+ * @cmd:
+ */
+static int atl1_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
+{
+       struct atl1_adapter *adapter = netdev_priv(netdev);
+       unsigned long flags;
+       int retval;
+
+       if (!netif_running(netdev))
+               return -EINVAL;
+
+       spin_lock_irqsave(&adapter->lock, flags);
+       retval = generic_mii_ioctl(&adapter->mii, if_mii(ifr), cmd, NULL);
+       spin_unlock_irqrestore(&adapter->lock, flags);
+
+       return retval;
+}
+
+/*
+ * atl1_ioctl -
+ * @netdev:
+ * @ifreq:
+ * @cmd:
+ */
+static int atl1_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
+{
+       switch (cmd) {
+       case SIOCGMIIPHY:
+       case SIOCGMIIREG:
+       case SIOCSMIIREG:
+               return atl1_mii_ioctl(netdev, ifr, cmd);
+       default:
+               return -EOPNOTSUPP;
+       }
+}
+
+/*
+ * atl1_tx_timeout - Respond to a Tx Hang
+ * @netdev: network interface device structure
+ */
+static void atl1_tx_timeout(struct net_device *netdev)
+{
+       struct atl1_adapter *adapter = netdev_priv(netdev);
+       /* Do the reset outside of interrupt context */
+       schedule_work(&adapter->tx_timeout_task);
+}
+
+/*
+ * atl1_phy_config - Timer Call-back
+ * @data: pointer to netdev cast into an unsigned long
+ */
+static void atl1_phy_config(unsigned long data)
+{
+       struct atl1_adapter *adapter = (struct atl1_adapter *)data;
+       struct atl1_hw *hw = &adapter->hw;
+       unsigned long flags;
+
+       spin_lock_irqsave(&adapter->lock, flags);
+       adapter->phy_timer_pending = false;
+       atl1_write_phy_reg(hw, MII_ADVERTISE, hw->mii_autoneg_adv_reg);
+       atl1_write_phy_reg(hw, MII_AT001_CR, hw->mii_1000t_ctrl_reg);
+       atl1_write_phy_reg(hw, MII_BMCR, MII_CR_RESET | MII_CR_AUTO_NEG_EN);
+       spin_unlock_irqrestore(&adapter->lock, flags);
+}
+
+int atl1_reset(struct atl1_adapter *adapter)
+{
+       int ret;
+
+       ret = atl1_reset_hw(&adapter->hw);
+       if (ret != ATL1_SUCCESS)
+               return ret;
+       return atl1_init_hw(&adapter->hw);
+}
+
+/*
+ * atl1_open - Called when a network interface is made active
+ * @netdev: network interface device structure
+ *
+ * Returns 0 on success, negative value on failure
+ *
+ * The open entry point is called when a network interface is made
+ * active by the system (IFF_UP).  At this point all resources needed
+ * for transmit and receive operations are allocated, the interrupt
+ * handler is registered with the OS, the watchdog timer is started,
+ * and the stack is notified that the interface is ready.
+ */
+static int atl1_open(struct net_device *netdev)
+{
+       struct atl1_adapter *adapter = netdev_priv(netdev);
+       int err;
+
+       /* allocate transmit descriptors */
+       err = atl1_setup_ring_resources(adapter);
+       if (err)
+               return err;
+
+       err = atl1_up(adapter);
+       if (err)
+               goto err_up;
+
+       return 0;
+
+err_up:
+       atl1_reset(adapter);
+       return err;
+}
+
+/*
+ * atl1_close - Disables a network interface
+ * @netdev: network interface device structure
+ *
+ * Returns 0, this is not allowed to fail
+ *
+ * The close entry point is called when an interface is de-activated
+ * by the OS.  The hardware is still under the drivers control, but
+ * needs to be disabled.  A global MAC reset is issued to stop the
+ * hardware, and all transmit and receive resources are freed.
+ */
+static int atl1_close(struct net_device *netdev)
+{
+       struct atl1_adapter *adapter = netdev_priv(netdev);
+       atl1_down(adapter);
+       atl1_free_ring_resources(adapter);
+       return 0;
+}
+
+/*
+ * If TPD Buffer size equal to 0, PCIE DMAR_TO_INT
+ * will assert. We do soft reset <0x1400=1> according
+ * with the SPEC. BUT, it seemes that PCIE or DMA
+ * state-machine will not be reset. DMAR_TO_INT will
+ * assert again and again.
+ */
+static void atl1_tx_timeout_task(struct work_struct *work)
+{
+       struct atl1_adapter *adapter =
+               container_of(work, struct atl1_adapter, tx_timeout_task);
+       struct net_device *netdev = adapter->netdev;
+
+       netif_device_detach(netdev);
+       atl1_down(adapter);
+       atl1_up(adapter);
+       netif_device_attach(netdev);
+}
+
+/*
+ * atl1_link_chg_task - deal with link change event Out of interrupt context
+ */
+static void atl1_link_chg_task(struct work_struct *work)
+{
+       struct atl1_adapter *adapter =
+               container_of(work, struct atl1_adapter, link_chg_task);
+       unsigned long flags;
+
+       spin_lock_irqsave(&adapter->lock, flags);
+       atl1_check_link(adapter);
+       spin_unlock_irqrestore(&adapter->lock, flags);
+}
+
+/*
+ * atl1_pcie_patch - Patch for PCIE module
+ */
+static void atl1_pcie_patch(struct atl1_adapter *adapter)
+{
+       u32 value;
+       value = 0x6500;
+       iowrite32(value, adapter->hw.hw_addr + 0x12FC);
+       /* pcie flow control mode change */
+       value = ioread32(adapter->hw.hw_addr + 0x1008);
+       value |= 0x8000;
+       iowrite32(value, adapter->hw.hw_addr + 0x1008);
+}
+
+/*
+ * When ACPI resume on some VIA MotherBoard, the Interrupt Disable bit/0x400
+ * on PCI Command register is disable.
+ * The function enable this bit.
+ * Brackett, 2006/03/15
+ */
+static void atl1_via_workaround(struct atl1_adapter *adapter)
+{
+       unsigned long value;
+
+       value = ioread16(adapter->hw.hw_addr + PCI_COMMAND);
+       if (value & PCI_COMMAND_INTX_DISABLE)
+               value &= ~PCI_COMMAND_INTX_DISABLE;
+       iowrite32(value, adapter->hw.hw_addr + PCI_COMMAND);
+}
+
+/*
+ * atl1_probe - Device Initialization Routine
+ * @pdev: PCI device information struct
+ * @ent: entry in atl1_pci_tbl
+ *
+ * Returns 0 on success, negative on failure
+ *
+ * atl1_probe initializes an adapter identified by a pci_dev structure.
+ * The OS initialization, configuring of the adapter private structure,
+ * and a hardware reset occur.
+ */
+static int __devinit atl1_probe(struct pci_dev *pdev,
+                             const struct pci_device_id *ent)
+{
+       struct net_device *netdev;
+       struct atl1_adapter *adapter;
+       static int cards_found = 0;
+       bool pci_using_64 = true;
+       int err;
+
+       err = pci_enable_device(pdev);
+       if (err)
+               return err;
+
+       err = pci_set_dma_mask(pdev, DMA_64BIT_MASK);
+       if (err) {
+               err = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
+               if (err) {
+                       printk(KERN_DEBUG
+                               "%s: no usable DMA configuration, aborting\n",
+                               atl1_driver_name);
+                       goto err_dma;
+               }
+               pci_using_64 = false;
+       }
+       /* Mark all PCI regions associated with PCI device
+        * pdev as being reserved by owner atl1_driver_name
+        */
+       err = pci_request_regions(pdev, atl1_driver_name);
+       if (err)
+               goto err_request_regions;
+
+       /* Enables bus-mastering on the device and calls
+        * pcibios_set_master to do the needed arch specific settings
+        */
+       pci_set_master(pdev);
+
+       netdev = alloc_etherdev(sizeof(struct atl1_adapter));
+       if (!netdev) {
+               err = -ENOMEM;
+               goto err_alloc_etherdev;
+       }
+       SET_MODULE_OWNER(netdev);
+       SET_NETDEV_DEV(netdev, &pdev->dev);
+
+       pci_set_drvdata(pdev, netdev);
+       adapter = netdev_priv(netdev);
+       adapter->netdev = netdev;
+       adapter->pdev = pdev;
+       adapter->hw.back = adapter;
+
+       adapter->hw.hw_addr = pci_iomap(pdev, 0, 0);
+       if (!adapter->hw.hw_addr) {
+               err = -EIO;
+               goto err_pci_iomap;
+       }
+       /* get device revision number */
+       adapter->hw.dev_rev = ioread16(adapter->hw.hw_addr + (REG_MASTER_CTRL + 2));
+
+       /* set default ring resource counts */
+       adapter->rfd_ring.count = adapter->rrd_ring.count = ATL1_DEFAULT_RFD;
+       adapter->tpd_ring.count = ATL1_DEFAULT_TPD;
+
+       adapter->mii.dev = netdev;
+       adapter->mii.mdio_read = mdio_read;
+       adapter->mii.mdio_write = mdio_write;
+       adapter->mii.phy_id_mask = 0x1f;
+       adapter->mii.reg_num_mask = 0x1f;
+
+       netdev->open = &atl1_open;
+       netdev->stop = &atl1_close;
+       netdev->hard_start_xmit = &atl1_xmit_frame;
+       netdev->get_stats = &atl1_get_stats;
+       netdev->set_multicast_list = &atl1_set_multi;
+       netdev->set_mac_address = &atl1_set_mac;
+       netdev->change_mtu = &atl1_change_mtu;
+       netdev->do_ioctl = &atl1_ioctl;
+       netdev->tx_timeout = &atl1_tx_timeout;
+       netdev->watchdog_timeo = 5 * HZ;
+       netdev->vlan_rx_register = atl1_vlan_rx_register;
+       netdev->vlan_rx_add_vid = atl1_vlan_rx_add_vid;
+       netdev->vlan_rx_kill_vid = atl1_vlan_rx_kill_vid;
+       netdev->ethtool_ops = &atl1_ethtool_ops;
+       adapter->bd_number = cards_found;
+       adapter->pci_using_64 = pci_using_64;
+
+       /* setup the private structure */
+       err = atl1_sw_init(adapter);
+       if (err)
+               goto err_common;
+
+       netdev->features = NETIF_F_HW_CSUM;
+       netdev->features |= NETIF_F_SG;
+       netdev->features |= (NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX);
+
+       /*
+        * FIXME - Until tso performance gets fixed, disable the feature.
+        * Enable it with ethtool -K if desired.
+        */
+       /* netdev->features |= NETIF_F_TSO; */
+
+       if (pci_using_64)
+               netdev->features |= NETIF_F_HIGHDMA;
+
+       netdev->features |= NETIF_F_LLTX;
+
+       /*
+        * patch for some L1 of old version,
+        * the final version of L1 may not need these
+        * patches
+        */
+       /* atl1_pcie_patch(adapter); */
+
+       /* really reset GPHY core */
+       iowrite16(0, adapter->hw.hw_addr + REG_GPHY_ENABLE);
+
+       /*
+        * reset the controller to
+        * put the device in a known good starting state
+        */
+       if (atl1_reset_hw(&adapter->hw)) {
+               err = -EIO;
+               goto err_common;
+       }
+
+       /* copy the MAC address out of the EEPROM */
+       atl1_read_mac_addr(&adapter->hw);
+       memcpy(netdev->dev_addr, adapter->hw.mac_addr, netdev->addr_len);
+
+       if (!is_valid_ether_addr(netdev->dev_addr)) {
+               err = -EIO;
+               goto err_common;
+       }
+
+       atl1_check_options(adapter);
+
+       /* pre-init the MAC, and setup link */
+       err = atl1_init_hw(&adapter->hw);
+       if (err) {
+               err = -EIO;
+               goto err_common;
+       }
+
+       atl1_pcie_patch(adapter);
+       /* assume we have no link for now */
+       netif_carrier_off(netdev);
+       netif_stop_queue(netdev);
+
+       init_timer(&adapter->watchdog_timer);
+       adapter->watchdog_timer.function = &atl1_watchdog;
+       adapter->watchdog_timer.data = (unsigned long)adapter;
+
+       init_timer(&adapter->phy_config_timer);
+       adapter->phy_config_timer.function = &atl1_phy_config;
+       adapter->phy_config_timer.data = (unsigned long)adapter;
+       adapter->phy_timer_pending = false;
+
+       INIT_WORK(&adapter->tx_timeout_task, atl1_tx_timeout_task);
+
+       INIT_WORK(&adapter->link_chg_task, atl1_link_chg_task);
+
+       INIT_WORK(&adapter->pcie_dma_to_rst_task, atl1_tx_timeout_task);
+
+       err = register_netdev(netdev);
+       if (err)
+               goto err_common;
+
+       cards_found++;
+       atl1_via_workaround(adapter);
+       return 0;
+
+err_common:
+       pci_iounmap(pdev, adapter->hw.hw_addr);
+err_pci_iomap:
+       free_netdev(netdev);
+err_alloc_etherdev:
+       pci_release_regions(pdev);
+err_dma:
+err_request_regions:
+       pci_disable_device(pdev);
+       return err;
+}
+
+/*
+ * atl1_remove - Device Removal Routine
+ * @pdev: PCI device information struct
+ *
+ * atl1_remove is called by the PCI subsystem to alert the driver
+ * that it should release a PCI device.  The could be caused by a
+ * Hot-Plug event, or because the driver is going to be removed from
+ * memory.
+ */
+static void __devexit atl1_remove(struct pci_dev *pdev)
+{
+       struct net_device *netdev = pci_get_drvdata(pdev);
+       struct atl1_adapter *adapter;
+       /* Device not available. Return. */
+       if (!netdev)
+               return;
+
+       adapter = netdev_priv(netdev);
+       iowrite16(0, adapter->hw.hw_addr + REG_GPHY_ENABLE);
+       unregister_netdev(netdev);
+       pci_iounmap(pdev, adapter->hw.hw_addr);
+       pci_release_regions(pdev);
+       free_netdev(netdev);
+       pci_disable_device(pdev);
+}
+
+#ifdef CONFIG_PM
+static int atl1_suspend(struct pci_dev *pdev, pm_message_t state)
+{
+       struct net_device *netdev = pci_get_drvdata(pdev);
+       struct atl1_adapter *adapter = netdev_priv(netdev);
+       struct atl1_hw *hw = &adapter->hw;
+       u32 ctrl = 0;
+       u32 wufc = adapter->wol;
+
+       netif_device_detach(netdev);
+       if (netif_running(netdev))
+               atl1_down(adapter);
+
+       atl1_read_phy_reg(hw, MII_BMSR, (u16 *) & ctrl);
+       atl1_read_phy_reg(hw, MII_BMSR, (u16 *) & ctrl);
+       if (ctrl & BMSR_LSTATUS)
+               wufc &= ~ATL1_WUFC_LNKC;
+
+       /* reduce speed to 10/100M */
+       if (wufc) {
+               atl1_phy_enter_power_saving(hw);
+               /* if resume, let driver to re- setup link */
+               hw->phy_configured = false;
+               atl1_set_mac_addr(hw);
+               atl1_set_multi(netdev);
+
+               ctrl = 0;
+               /* turn on magic packet wol */
+               if (wufc & ATL1_WUFC_MAG)
+                       ctrl = WOL_MAGIC_EN | WOL_MAGIC_PME_EN;
+
+               /* turn on Link change WOL */
+               if (wufc & ATL1_WUFC_LNKC)
+                       ctrl |= (WOL_LINK_CHG_EN | WOL_LINK_CHG_PME_EN);
+               iowrite32(ctrl, hw->hw_addr + REG_WOL_CTRL);
+
+               /* turn on all-multi mode if wake on multicast is enabled */
+               ctrl = ioread32(hw->hw_addr + REG_MAC_CTRL);
+               ctrl &= ~MAC_CTRL_DBG;
+               ctrl &= ~MAC_CTRL_PROMIS_EN;
+               if (wufc & ATL1_WUFC_MC)
+                       ctrl |= MAC_CTRL_MC_ALL_EN;
+               else
+                       ctrl &= ~MAC_CTRL_MC_ALL_EN;
+
+               /* turn on broadcast mode if wake on-BC is enabled */
+               if (wufc & ATL1_WUFC_BC)
+                       ctrl |= MAC_CTRL_BC_EN;
+               else
+                       ctrl &= ~MAC_CTRL_BC_EN;
+
+               /* enable RX */
+               ctrl |= MAC_CTRL_RX_EN;
+               iowrite32(ctrl, hw->hw_addr + REG_MAC_CTRL);
+               pci_enable_wake(pdev, PCI_D3hot, 1);
+               pci_enable_wake(pdev, PCI_D3cold, 1);   /* 4 == D3 cold */
+       } else {
+               iowrite32(0, hw->hw_addr + REG_WOL_CTRL);
+               pci_enable_wake(pdev, PCI_D3hot, 0);
+               pci_enable_wake(pdev, PCI_D3cold, 0);   /* 4 == D3 cold */
+       }
+
+       pci_save_state(pdev);
+       pci_disable_device(pdev);
+
+       pci_set_power_state(pdev, PCI_D3hot);
+
+       return 0;
+}
+
+static int atl1_resume(struct pci_dev *pdev)
+{
+       struct net_device *netdev = pci_get_drvdata(pdev);
+       struct atl1_adapter *adapter = netdev_priv(netdev);
+       u32 ret_val;
+
+       pci_set_power_state(pdev, 0);
+       pci_restore_state(pdev);
+
+       ret_val = pci_enable_device(pdev);
+       pci_enable_wake(pdev, PCI_D3hot, 0);
+       pci_enable_wake(pdev, PCI_D3cold, 0);
+
+       iowrite32(0, adapter->hw.hw_addr + REG_WOL_CTRL);
+       atl1_reset(adapter);
+
+       if (netif_running(netdev))
+               atl1_up(adapter);
+       netif_device_attach(netdev);
+
+       atl1_via_workaround(adapter);
+
+       return 0;
+}
+#else
+#define atl1_suspend NULL
+#define atl1_resume NULL
+#endif
+
+static struct pci_driver atl1_driver = {
+       .name = atl1_driver_name,
+       .id_table = atl1_pci_tbl,
+       .probe = atl1_probe,
+       .remove = __devexit_p(atl1_remove),
+       /* Power Managment Hooks */
+       /* probably broken right now -- CHS */
+       .suspend = atl1_suspend,
+       .resume = atl1_resume
+};
+
+/*
+ * atl1_exit_module - Driver Exit Cleanup Routine
+ *
+ * atl1_exit_module is called just before the driver is removed
+ * from memory.
+ */
+static void __exit atl1_exit_module(void)
+{
+       pci_unregister_driver(&atl1_driver);
+}
+
+/*
+ * atl1_init_module - Driver Registration Routine
+ *
+ * atl1_init_module is the first routine called when the driver is
+ * loaded. All it does is register with the PCI subsystem.
+ */
+static int __init atl1_init_module(void)
+{
+       printk(KERN_INFO "%s - version %s\n", atl1_driver_string, DRIVER_VERSION);
+       printk(KERN_INFO "%s\n", atl1_copyright);
+       return pci_register_driver(&atl1_driver);
+}
+
+module_init(atl1_init_module);
+module_exit(atl1_exit_module);
diff --git a/drivers/net/atl1/atl1_param.c b/drivers/net/atl1/atl1_param.c
new file mode 100644 (file)
index 0000000..c407214
--- /dev/null
@@ -0,0 +1,206 @@
+/*
+ * Copyright(c) 2005 - 2006 Attansic Corporation. All rights reserved.
+ * Copyright(c) 2006 Chris Snook <csnook@redhat.com>
+ * Copyright(c) 2006 Jay Cliburn <jcliburn@gmail.com>
+ *
+ * Derived from Intel e1000 driver
+ * Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59
+ * Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+#include <linux/types.h>
+#include <linux/pci.h>
+#include <linux/moduleparam.h>
+#include "atl1.h"
+
+/*
+ * This is the only thing that needs to be changed to adjust the
+ * maximum number of ports that the driver can manage.
+ */
+#define ATL1_MAX_NIC 4
+
+#define OPTION_UNSET    -1
+#define OPTION_DISABLED 0
+#define OPTION_ENABLED  1
+
+#define ATL1_PARAM_INIT { [0 ... ATL1_MAX_NIC] = OPTION_UNSET }
+
+/*
+ * Interrupt Moderate Timer in units of 2 us
+ *
+ * Valid Range: 10-65535
+ *
+ * Default Value: 100 (200us)
+ */
+static int __devinitdata int_mod_timer[ATL1_MAX_NIC+1] = ATL1_PARAM_INIT;
+static int num_int_mod_timer = 0;
+module_param_array_named(int_mod_timer, int_mod_timer, int, &num_int_mod_timer, 0);
+MODULE_PARM_DESC(int_mod_timer, "Interrupt moderator timer");
+
+/*
+ * flash_vendor
+ *
+ * Valid Range: 0-2
+ *
+ * 0 - Atmel
+ * 1 - SST
+ * 2 - ST
+ *
+ * Default Value: 0
+ */
+static int __devinitdata flash_vendor[ATL1_MAX_NIC+1] = ATL1_PARAM_INIT;
+static int num_flash_vendor = 0;
+module_param_array_named(flash_vendor, flash_vendor, int, &num_flash_vendor, 0);
+MODULE_PARM_DESC(flash_vendor, "SPI flash vendor");
+
+#define DEFAULT_INT_MOD_CNT    100     /* 200us */
+#define MAX_INT_MOD_CNT                65000
+#define MIN_INT_MOD_CNT                50
+
+#define FLASH_VENDOR_DEFAULT   0
+#define FLASH_VENDOR_MIN       0
+#define FLASH_VENDOR_MAX       2
+
+struct atl1_option {
+       enum { enable_option, range_option, list_option } type;
+       char *name;
+       char *err;
+       int def;
+       union {
+               struct {        /* range_option info */
+                       int min;
+                       int max;
+               } r;
+               struct {        /* list_option info */
+                       int nr;
+                       struct atl1_opt_list {
+                               int i;
+                               char *str;
+                       } *p;
+               } l;
+       } arg;
+};
+
+static int __devinit atl1_validate_option(int *value, struct atl1_option *opt)
+{
+       if (*value == OPTION_UNSET) {
+               *value = opt->def;
+               return 0;
+       }
+
+       switch (opt->type) {
+       case enable_option:
+               switch (*value) {
+               case OPTION_ENABLED:
+                       printk(KERN_INFO "%s: %s Enabled\n", atl1_driver_name,
+                               opt->name);
+                       return 0;
+               case OPTION_DISABLED:
+                       printk(KERN_INFO "%s: %s Disabled\n", atl1_driver_name,
+                               opt->name);
+                       return 0;
+               }
+               break;
+       case range_option:
+               if (*value >= opt->arg.r.min && *value <= opt->arg.r.max) {
+                       printk(KERN_INFO "%s: %s set to %i\n",
+                               atl1_driver_name, opt->name, *value);
+                       return 0;
+               }
+               break;
+       case list_option:{
+                       int i;
+                       struct atl1_opt_list *ent;
+
+                       for (i = 0; i < opt->arg.l.nr; i++) {
+                               ent = &opt->arg.l.p[i];
+                               if (*value == ent->i) {
+                                       if (ent->str[0] != '\0')
+                                               printk(KERN_INFO "%s: %s\n",
+                                                      atl1_driver_name, ent->str);
+                                       return 0;
+                               }
+                       }
+               }
+               break;
+
+       default:
+               break;
+       }
+
+       printk(KERN_INFO "%s: invalid %s specified (%i) %s\n",
+              atl1_driver_name, opt->name, *value, opt->err);
+       *value = opt->def;
+       return -1;
+}
+
+/*
+ * atl1_check_options - Range Checking for Command Line Parameters
+ * @adapter: board private structure
+ *
+ * This routine checks all command line parameters for valid user
+ * input.  If an invalid value is given, or if no user specified
+ * value exists, a default value is used.  The final value is stored
+ * in a variable in the adapter structure.
+ */
+void __devinit atl1_check_options(struct atl1_adapter *adapter)
+{
+       int bd = adapter->bd_number;
+       if (bd >= ATL1_MAX_NIC) {
+               printk(KERN_NOTICE "%s: warning: no configuration for board #%i\n",
+                       atl1_driver_name, bd);
+               printk(KERN_NOTICE "%s: using defaults for all values\n",
+                       atl1_driver_name);
+       }
+       {                       /* Interrupt Moderate Timer */
+               struct atl1_option opt = {
+                       .type = range_option,
+                       .name = "Interrupt Moderator Timer",
+                       .err = "using default of "
+                               __MODULE_STRING(DEFAULT_INT_MOD_CNT),
+                       .def = DEFAULT_INT_MOD_CNT,
+                       .arg = {.r =
+                               {.min = MIN_INT_MOD_CNT,.max = MAX_INT_MOD_CNT}}
+               };
+               int val;
+               if (num_int_mod_timer > bd) {
+                       val = int_mod_timer[bd];
+                       atl1_validate_option(&val, &opt);
+                       adapter->imt = (u16) val;
+               } else
+                       adapter->imt = (u16) (opt.def);
+       }
+
+       {                       /* Flash Vendor */
+               struct atl1_option opt = {
+                       .type = range_option,
+                       .name = "SPI Flash Vendor",
+                       .err = "using default of "
+                               __MODULE_STRING(FLASH_VENDOR_DEFAULT),
+                       .def = DEFAULT_INT_MOD_CNT,
+                       .arg = {.r =
+                               {.min = FLASH_VENDOR_MIN,.max =
+                                FLASH_VENDOR_MAX}}
+               };
+               int val;
+               if (num_flash_vendor > bd) {
+                       val = flash_vendor[bd];
+                       atl1_validate_option(&val, &opt);
+                       adapter->hw.flash_vendor = (u8) val;
+               } else
+                       adapter->hw.flash_vendor = (u8) (opt.def);
+       }
+}
index 32923162179ef8b45948149972343744144694ec..217a2eedee0aafc143e5533aff617b70693927cb 100644 (file)
@@ -184,7 +184,7 @@ static int tlb_initialize(struct bonding *bond)
 
        spin_lock_init(&(bond_info->tx_hashtbl_lock));
 
-       new_hashtbl = kmalloc(size, GFP_KERNEL);
+       new_hashtbl = kzalloc(size, GFP_KERNEL);
        if (!new_hashtbl) {
                printk(KERN_ERR DRV_NAME
                       ": %s: Error: Failed to allocate TLB hash table\n",
@@ -195,8 +195,6 @@ static int tlb_initialize(struct bonding *bond)
 
        bond_info->tx_hashtbl = new_hashtbl;
 
-       memset(bond_info->tx_hashtbl, 0, size);
-
        for (i = 0; i < TLB_HASH_TABLE_SIZE; i++) {
                tlb_init_table_entry(&bond_info->tx_hashtbl[i], 1);
        }
index d3801a00d3d5152f6009024bb41248db950dc43f..8ce8fec615bad67d99a7e6ad9e288cd5fe5ec5dc 100644 (file)
@@ -1343,14 +1343,12 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
                        "inaccurate.\n", bond_dev->name, slave_dev->name);
        }
 
-       new_slave = kmalloc(sizeof(struct slave), GFP_KERNEL);
+       new_slave = kzalloc(sizeof(struct slave), GFP_KERNEL);
        if (!new_slave) {
                res = -ENOMEM;
                goto err_undo_flags;
        }
 
-       memset(new_slave, 0, sizeof(struct slave));
-
        /* save slave's original flags before calling
         * netdev_set_master and dev_open
         */
index dfa035a1ad45b6f54165d9f368f9302715f006b7..c67f7d3c2f92a8195ca2f5f2837526452b759d1e 100644 (file)
@@ -74,8 +74,6 @@ enum {
 
 #define EEPROM_MAGIC 0x38E2F10C
 
-#define to_net_dev(class) container_of(class, struct net_device, class_dev)
-
 #define CH_DEVICE(devid, ssid, idx) \
        { PCI_VENDOR_ID_CHELSIO, devid, PCI_ANY_ID, ssid, 0, 0, idx }
 
@@ -434,11 +432,12 @@ static int setup_sge_qsets(struct adapter *adap)
        return 0;
 }
 
-static ssize_t attr_show(struct class_device *cd, char *buf,
+static ssize_t attr_show(struct device *d, struct device_attribute *attr,
+                        char *buf,
                         ssize_t(*format) (struct adapter *, char *))
 {
        ssize_t len;
-       struct adapter *adap = to_net_dev(cd)->priv;
+       struct adapter *adap = to_net_dev(d)->priv;
 
        /* Synchronize with ioctls that may shut down the device */
        rtnl_lock();
@@ -447,14 +446,15 @@ static ssize_t attr_show(struct class_device *cd, char *buf,
        return len;
 }
 
-static ssize_t attr_store(struct class_device *cd, const char *buf, size_t len,
+static ssize_t attr_store(struct device *d, struct device_attribute *attr,
+                         const char *buf, size_t len,
                          ssize_t(*set) (struct adapter *, unsigned int),
                          unsigned int min_val, unsigned int max_val)
 {
        char *endp;
        ssize_t ret;
        unsigned int val;
-       struct adapter *adap = to_net_dev(cd)->priv;
+       struct adapter *adap = to_net_dev(d)->priv;
 
        if (!capable(CAP_NET_ADMIN))
                return -EPERM;
@@ -476,9 +476,10 @@ static ssize_t format_##name(struct adapter *adap, char *buf) \
 { \
        return sprintf(buf, "%u\n", val_expr); \
 } \
-static ssize_t show_##name(struct class_device *cd, char *buf) \
+static ssize_t show_##name(struct device *d, struct device_attribute *attr, \
+                          char *buf) \
 { \
-       return attr_show(cd, buf, format_##name); \
+       return attr_show(d, attr, buf, format_##name); \
 }
 
 static ssize_t set_nfilters(struct adapter *adap, unsigned int val)
@@ -493,10 +494,10 @@ static ssize_t set_nfilters(struct adapter *adap, unsigned int val)
        return 0;
 }
 
-static ssize_t store_nfilters(struct class_device *cd, const char *buf,
-                             size_t len)
+static ssize_t store_nfilters(struct device *d, struct device_attribute *attr,
+                             const char *buf, size_t len)
 {
-       return attr_store(cd, buf, len, set_nfilters, 0, ~0);
+       return attr_store(d, attr, buf, len, set_nfilters, 0, ~0);
 }
 
 static ssize_t set_nservers(struct adapter *adap, unsigned int val)
@@ -509,38 +510,39 @@ static ssize_t set_nservers(struct adapter *adap, unsigned int val)
        return 0;
 }
 
-static ssize_t store_nservers(struct class_device *cd, const char *buf,
-                             size_t len)
+static ssize_t store_nservers(struct device *d, struct device_attribute *attr,
+                             const char *buf, size_t len)
 {
-       return attr_store(cd, buf, len, set_nservers, 0, ~0);
+       return attr_store(d, attr, buf, len, set_nservers, 0, ~0);
 }
 
 #define CXGB3_ATTR_R(name, val_expr) \
 CXGB3_SHOW(name, val_expr) \
-static CLASS_DEVICE_ATTR(name, S_IRUGO, show_##name, NULL)
+static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL)
 
 #define CXGB3_ATTR_RW(name, val_expr, store_method) \
 CXGB3_SHOW(name, val_expr) \
-static CLASS_DEVICE_ATTR(name, S_IRUGO | S_IWUSR, show_##name, store_method)
+static DEVICE_ATTR(name, S_IRUGO | S_IWUSR, show_##name, store_method)
 
 CXGB3_ATTR_R(cam_size, t3_mc5_size(&adap->mc5));
 CXGB3_ATTR_RW(nfilters, adap->params.mc5.nfilters, store_nfilters);
 CXGB3_ATTR_RW(nservers, adap->params.mc5.nservers, store_nservers);
 
 static struct attribute *cxgb3_attrs[] = {
-       &class_device_attr_cam_size.attr,
-       &class_device_attr_nfilters.attr,
-       &class_device_attr_nservers.attr,
+       &dev_attr_cam_size.attr,
+       &dev_attr_nfilters.attr,
+       &dev_attr_nservers.attr,
        NULL
 };
 
 static struct attribute_group cxgb3_attr_group = {.attrs = cxgb3_attrs };
 
-static ssize_t tm_attr_show(struct class_device *cd, char *buf, int sched)
+static ssize_t tm_attr_show(struct device *d, struct device_attribute *attr,
+                           char *buf, int sched)
 {
        ssize_t len;
        unsigned int v, addr, bpt, cpt;
-       struct adapter *adap = to_net_dev(cd)->priv;
+       struct adapter *adap = to_net_dev(d)->priv;
 
        addr = A_TP_TX_MOD_Q1_Q0_RATE_LIMIT - sched / 2;
        rtnl_lock();
@@ -560,13 +562,13 @@ static ssize_t tm_attr_show(struct class_device *cd, char *buf, int sched)
        return len;
 }
 
-static ssize_t tm_attr_store(struct class_device *cd, const char *buf,
-                            size_t len, int sched)
+static ssize_t tm_attr_store(struct device *d, struct device_attribute *attr,
+                            const char *buf, size_t len, int sched)
 {
        char *endp;
        ssize_t ret;
        unsigned int val;
-       struct adapter *adap = to_net_dev(cd)->priv;
+       struct adapter *adap = to_net_dev(d)->priv;
 
        if (!capable(CAP_NET_ADMIN))
                return -EPERM;
@@ -584,15 +586,17 @@ static ssize_t tm_attr_store(struct class_device *cd, const char *buf,
 }
 
 #define TM_ATTR(name, sched) \
-static ssize_t show_##name(struct class_device *cd, char *buf) \
+static ssize_t show_##name(struct device *d, struct device_attribute *attr, \
+                          char *buf) \
 { \
-       return tm_attr_show(cd, buf, sched); \
+       return tm_attr_show(d, attr, buf, sched); \
 } \
-static ssize_t store_##name(struct class_device *cd, const char *buf, size_t len) \
+static ssize_t store_##name(struct device *d, struct device_attribute *attr, \
+                           const char *buf, size_t len) \
 { \
-       return tm_attr_store(cd, buf, len, sched); \
+       return tm_attr_store(d, attr, buf, len, sched); \
 } \
-static CLASS_DEVICE_ATTR(name, S_IRUGO | S_IWUSR, show_##name, store_##name)
+static DEVICE_ATTR(name, S_IRUGO | S_IWUSR, show_##name, store_##name)
 
 TM_ATTR(sched0, 0);
 TM_ATTR(sched1, 1);
@@ -604,14 +608,14 @@ TM_ATTR(sched6, 6);
 TM_ATTR(sched7, 7);
 
 static struct attribute *offload_attrs[] = {
-       &class_device_attr_sched0.attr,
-       &class_device_attr_sched1.attr,
-       &class_device_attr_sched2.attr,
-       &class_device_attr_sched3.attr,
-       &class_device_attr_sched4.attr,
-       &class_device_attr_sched5.attr,
-       &class_device_attr_sched6.attr,
-       &class_device_attr_sched7.attr,
+       &dev_attr_sched0.attr,
+       &dev_attr_sched1.attr,
+       &dev_attr_sched2.attr,
+       &dev_attr_sched3.attr,
+       &dev_attr_sched4.attr,
+       &dev_attr_sched5.attr,
+       &dev_attr_sched6.attr,
+       &dev_attr_sched7.attr,
        NULL
 };
 
@@ -836,7 +840,7 @@ static int offload_open(struct net_device *dev)
        init_smt(adapter);
 
        /* Never mind if the next step fails */
-       sysfs_create_group(&tdev->lldev->class_dev.kobj, &offload_attr_group);
+       sysfs_create_group(&tdev->lldev->dev.kobj, &offload_attr_group);
 
        /* Call back all registered clients */
        cxgb3_add_clients(tdev);
@@ -861,7 +865,7 @@ static int offload_close(struct t3cdev *tdev)
        /* Call back all registered clients */
        cxgb3_remove_clients(tdev);
 
-       sysfs_remove_group(&tdev->lldev->class_dev.kobj, &offload_attr_group);
+       sysfs_remove_group(&tdev->lldev->dev.kobj, &offload_attr_group);
 
        tdev->lldev = NULL;
        cxgb3_set_dummy_ops(tdev);
@@ -2420,7 +2424,7 @@ static int __devinit init_one(struct pci_dev *pdev,
        else if (msi > 0 && pci_enable_msi(pdev) == 0)
                adapter->flags |= USING_MSI;
 
-       err = sysfs_create_group(&adapter->port[0]->class_dev.kobj,
+       err = sysfs_create_group(&adapter->port[0]->dev.kobj,
                                 &cxgb3_attr_group);
 
        print_port_info(adapter, ai);
@@ -2452,7 +2456,7 @@ static void __devexit remove_one(struct pci_dev *pdev)
                struct adapter *adapter = dev->priv;
 
                t3_sge_stop(adapter);
-               sysfs_remove_group(&adapter->port[0]->class_dev.kobj,
+               sysfs_remove_group(&adapter->port[0]->dev.kobj,
                                   &cxgb3_attr_group);
 
                for_each_port(adapter, i)
index c3a02d613382c245d016648eb2e7d18d38224340..c6b72664318571f81d5ad09b3f0c3f6600bf21f4 100644 (file)
@@ -396,7 +396,7 @@ static int rx_offload_blackhole(struct t3cdev *dev, struct sk_buff **skbs,
                                int n)
 {
        CH_ERR(tdev2adap(dev), "%d unexpected offload packets, first data %u\n",
-              n, ntohl(*(u32 *)skbs[0]->data));
+              n, ntohl(*(__be32 *)skbs[0]->data));
        while (n--)
                dev_kfree_skb_any(skbs[n]);
        return 0;
@@ -755,7 +755,7 @@ static int do_trace(struct t3cdev *dev, struct sk_buff *skb)
 {
        struct cpl_trace_pkt *p = cplhdr(skb);
 
-       skb->protocol = 0xffff;
+       skb->protocol = htons(0xffff);
        skb->dev = dev->lldev;
        skb_pull(skb, sizeof(*p));
        skb->mac.raw = skb->data;
index dc3ab3b5c8cb8ef48aca9a586e86b566bde0c9b9..07d2731c1aa8f45e04b0c86a9c20744603b5fc50 100644 (file)
  *
  * Abstract:
  *   A Linux device driver supporting the Digital Equipment Corporation
- *   FDDI EISA and PCI controller families.  Supported adapters include:
+ *   FDDI TURBOchannel, EISA and PCI controller families.  Supported
+ *   adapters include:
  *
- *             DEC FDDIcontroller/EISA (DEFEA)
- *             DEC FDDIcontroller/PCI  (DEFPA)
+ *             DEC FDDIcontroller/TURBOchannel (DEFTA)
+ *             DEC FDDIcontroller/EISA         (DEFEA)
+ *             DEC FDDIcontroller/PCI          (DEFPA)
  *
  * The original author:
  *   LVS       Lawrence V. Stefani <lstefani@yahoo.com>
  *             14 Aug 2004     macro           Fix device names reported.
  *             14 Jun 2005     macro           Use irqreturn_t.
  *             23 Oct 2006     macro           Big-endian host support.
+ *             14 Dec 2006     macro           TURBOchannel support.
  */
 
 /* Include files */
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/string.h>
-#include <linux/errno.h>
-#include <linux/ioport.h>
-#include <linux/slab.h>
-#include <linux/interrupt.h>
-#include <linux/pci.h>
+#include <linux/bitops.h>
 #include <linux/delay.h>
+#include <linux/dma-mapping.h>
+#include <linux/eisa.h>
+#include <linux/errno.h>
+#include <linux/fddidevice.h>
 #include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/ioport.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
 #include <linux/netdevice.h>
-#include <linux/fddidevice.h>
+#include <linux/pci.h>
 #include <linux/skbuff.h>
-#include <linux/bitops.h>
+#include <linux/slab.h>
+#include <linux/string.h>
+#include <linux/tc.h>
 
 #include <asm/byteorder.h>
 #include <asm/io.h>
 
 /* Version information string should be updated prior to each new release!  */
 #define DRV_NAME "defxx"
-#define DRV_VERSION "v1.09"
-#define DRV_RELDATE "2006/10/23"
+#define DRV_VERSION "v1.10"
+#define DRV_RELDATE "2006/12/14"
 
 static char version[] __devinitdata =
        DRV_NAME ": " DRV_VERSION " " DRV_RELDATE
@@ -235,12 +240,41 @@ static char version[] __devinitdata =
  */
 #define NEW_SKB_SIZE (PI_RCV_DATA_K_SIZE_MAX+128)
 
+#define __unused __attribute__ ((unused))
+
+#ifdef CONFIG_PCI
+#define DFX_BUS_PCI(dev) (dev->bus == &pci_bus_type)
+#else
+#define DFX_BUS_PCI(dev) 0
+#endif
+
+#ifdef CONFIG_EISA
+#define DFX_BUS_EISA(dev) (dev->bus == &eisa_bus_type)
+#else
+#define DFX_BUS_EISA(dev) 0
+#endif
+
+#ifdef CONFIG_TC
+#define DFX_BUS_TC(dev) (dev->bus == &tc_bus_type)
+#else
+#define DFX_BUS_TC(dev) 0
+#endif
+
+#ifdef CONFIG_DEFXX_MMIO
+#define DFX_MMIO 1
+#else
+#define DFX_MMIO 0
+#endif
+
 /* Define module-wide (static) routines */
 
 static void            dfx_bus_init(struct net_device *dev);
+static void            dfx_bus_uninit(struct net_device *dev);
 static void            dfx_bus_config_check(DFX_board_t *bp);
 
-static int             dfx_driver_init(struct net_device *dev, const char *print_name);
+static int             dfx_driver_init(struct net_device *dev,
+                                       const char *print_name,
+                                       resource_size_t bar_start);
 static int             dfx_adap_init(DFX_board_t *bp, int get_buffers);
 
 static int             dfx_open(struct net_device *dev);
@@ -273,13 +307,13 @@ static void               dfx_xmt_flush(DFX_board_t *bp);
 
 /* Define module-wide (static) variables */
 
-static struct net_device *root_dfx_eisa_dev;
+static struct pci_driver dfx_pci_driver;
+static struct eisa_driver dfx_eisa_driver;
+static struct tc_driver dfx_tc_driver;
 
 
 /*
  * =======================
- * = dfx_port_write_byte =
- * = dfx_port_read_byte         =
  * = dfx_port_write_long =
  * = dfx_port_read_long  =
  * =======================
@@ -291,12 +325,11 @@ static struct net_device *root_dfx_eisa_dev;
  *   None
  *
  * Arguments:
- *   bp     - pointer to board information
- *   offset - register offset from base I/O address
- *   data   - for dfx_port_write_byte and dfx_port_write_long, this
- *                       is a value to write.
- *                       for dfx_port_read_byte and dfx_port_read_byte, this
- *                       is a pointer to store the read value.
+ *   bp                - pointer to board information
+ *   offset    - register offset from base I/O address
+ *   data      - for dfx_port_write_long, this is a value to write;
+ *               for dfx_port_read_long, this is a pointer to store
+ *               the read value
  *
  * Functional Description:
  *   These routines perform the correct operation to read or write
@@ -310,7 +343,7 @@ static struct net_device *root_dfx_eisa_dev;
  *   registers using the register offsets defined in DEFXX.H.
  *
  *   PCI port block base addresses are assigned by the PCI BIOS or system
- *      firmware.  There is one 128 byte port block which can be accessed.  It
+ *   firmware.  There is one 128 byte port block which can be accessed.  It
  *   allows for I/O mapping of both PDQ and PFI registers using the register
  *   offsets defined in DEFXX.H.
  *
@@ -318,7 +351,7 @@ static struct net_device *root_dfx_eisa_dev;
  *   None
  *
  * Assumptions:
- *   bp->base_addr is a valid base I/O address for this adapter.
+ *   bp->base is a valid base I/O address for this adapter.
  *   offset is a valid register offset for this adapter.
  *
  * Side Effects:
@@ -329,69 +362,135 @@ static struct net_device *root_dfx_eisa_dev;
  *   advantage of strict data type checking.
  */
 
-static inline void dfx_port_write_byte(
-       DFX_board_t     *bp,
-       int                     offset,
-       u8                      data
-       )
+static inline void dfx_writel(DFX_board_t *bp, int offset, u32 data)
+{
+       writel(data, bp->base.mem + offset);
+       mb();
+}
 
-       {
-       u16 port = bp->base_addr + offset;
+static inline void dfx_outl(DFX_board_t *bp, int offset, u32 data)
+{
+       outl(data, bp->base.port + offset);
+}
 
-       outb(data, port);
-       }
+static void dfx_port_write_long(DFX_board_t *bp, int offset, u32 data)
+{
+       struct device __unused *bdev = bp->bus_dev;
+       int dfx_bus_tc = DFX_BUS_TC(bdev);
+       int dfx_use_mmio = DFX_MMIO || dfx_bus_tc;
 
-static inline void dfx_port_read_byte(
-       DFX_board_t     *bp,
-       int                     offset,
-       u8                      *data
-       )
+       if (dfx_use_mmio)
+               dfx_writel(bp, offset, data);
+       else
+               dfx_outl(bp, offset, data);
+}
 
-       {
-       u16 port = bp->base_addr + offset;
 
-       *data = inb(port);
-       }
+static inline void dfx_readl(DFX_board_t *bp, int offset, u32 *data)
+{
+       mb();
+       *data = readl(bp->base.mem + offset);
+}
 
-static inline void dfx_port_write_long(
-       DFX_board_t     *bp,
-       int                     offset,
-       u32                     data
-       )
+static inline void dfx_inl(DFX_board_t *bp, int offset, u32 *data)
+{
+       *data = inl(bp->base.port + offset);
+}
 
-       {
-       u16 port = bp->base_addr + offset;
+static void dfx_port_read_long(DFX_board_t *bp, int offset, u32 *data)
+{
+       struct device __unused *bdev = bp->bus_dev;
+       int dfx_bus_tc = DFX_BUS_TC(bdev);
+       int dfx_use_mmio = DFX_MMIO || dfx_bus_tc;
 
-       outl(data, port);
-       }
+       if (dfx_use_mmio)
+               dfx_readl(bp, offset, data);
+       else
+               dfx_inl(bp, offset, data);
+}
 
-static inline void dfx_port_read_long(
-       DFX_board_t     *bp,
-       int                     offset,
-       u32                     *data
-       )
 
-       {
-       u16 port = bp->base_addr + offset;
+/*
+ * ================
+ * = dfx_get_bars =
+ * ================
+ *
+ * Overview:
+ *   Retrieves the address range used to access control and status
+ *   registers.
+ *
+ * Returns:
+ *   None
+ *
+ * Arguments:
+ *   bdev      - pointer to device information
+ *   bar_start - pointer to store the start address
+ *   bar_len   - pointer to store the length of the area
+ *
+ * Assumptions:
+ *   I am sure there are some.
+ *
+ * Side Effects:
+ *   None
+ */
+static void dfx_get_bars(struct device *bdev,
+                        resource_size_t *bar_start, resource_size_t *bar_len)
+{
+       int dfx_bus_pci = DFX_BUS_PCI(bdev);
+       int dfx_bus_eisa = DFX_BUS_EISA(bdev);
+       int dfx_bus_tc = DFX_BUS_TC(bdev);
+       int dfx_use_mmio = DFX_MMIO || dfx_bus_tc;
 
-       *data = inl(port);
-       }
+       if (dfx_bus_pci) {
+               int num = dfx_use_mmio ? 0 : 1;
 
+               *bar_start = pci_resource_start(to_pci_dev(bdev), num);
+               *bar_len = pci_resource_len(to_pci_dev(bdev), num);
+       }
+       if (dfx_bus_eisa) {
+               unsigned long base_addr = to_eisa_device(bdev)->base_addr;
+               resource_size_t bar;
+
+               if (dfx_use_mmio) {
+                       bar = inb(base_addr + PI_ESIC_K_MEM_ADD_CMP_2);
+                       bar <<= 8;
+                       bar |= inb(base_addr + PI_ESIC_K_MEM_ADD_CMP_1);
+                       bar <<= 8;
+                       bar |= inb(base_addr + PI_ESIC_K_MEM_ADD_CMP_0);
+                       bar <<= 16;
+                       *bar_start = bar;
+                       bar = inb(base_addr + PI_ESIC_K_MEM_ADD_MASK_2);
+                       bar <<= 8;
+                       bar |= inb(base_addr + PI_ESIC_K_MEM_ADD_MASK_1);
+                       bar <<= 8;
+                       bar |= inb(base_addr + PI_ESIC_K_MEM_ADD_MASK_0);
+                       bar <<= 16;
+                       *bar_len = (bar | PI_MEM_ADD_MASK_M) + 1;
+               } else {
+                       *bar_start = base_addr;
+                       *bar_len = PI_ESIC_K_CSR_IO_LEN;
+               }
+       }
+       if (dfx_bus_tc) {
+               *bar_start = to_tc_dev(bdev)->resource.start +
+                            PI_TC_K_CSR_OFFSET;
+               *bar_len = PI_TC_K_CSR_LEN;
+       }
+}
 
 /*
- * =============
- * = dfx_init_one_pci_or_eisa =
- * =============
+ * ================
+ * = dfx_register =
+ * ================
  *
  * Overview:
- *   Initializes a supported FDDI EISA or PCI controller
+ *   Initializes a supported FDDI controller
  *
  * Returns:
  *   Condition code
  *
  * Arguments:
- *   pdev - pointer to pci device information (NULL for EISA)
- *   ioaddr - pointer to port (NULL for PCI)
+ *   bdev - pointer to device information
  *
  * Functional Description:
  *
@@ -407,56 +506,74 @@ static inline void dfx_port_read_long(
  *   initialized and the board resources are read and stored in
  *   the device structure.
  */
-static int __devinit dfx_init_one_pci_or_eisa(struct pci_dev *pdev, long ioaddr)
+static int __devinit dfx_register(struct device *bdev)
 {
        static int version_disp;
-       char *print_name = DRV_NAME;
+       int dfx_bus_pci = DFX_BUS_PCI(bdev);
+       int dfx_bus_tc = DFX_BUS_TC(bdev);
+       int dfx_use_mmio = DFX_MMIO || dfx_bus_tc;
+       char *print_name = bdev->bus_id;
        struct net_device *dev;
        DFX_board_t       *bp;                  /* board pointer */
+       resource_size_t bar_start = 0;          /* pointer to port */
+       resource_size_t bar_len = 0;            /* resource length */
        int alloc_size;                         /* total buffer size used */
-       int err;
+       struct resource *region;
+       int err = 0;
 
        if (!version_disp) {    /* display version info if adapter is found */
                version_disp = 1;       /* set display flag to TRUE so that */
                printk(version);        /* we only display this string ONCE */
        }
 
-       if (pdev != NULL)
-               print_name = pci_name(pdev);
-
        dev = alloc_fddidev(sizeof(*bp));
        if (!dev) {
-               printk(KERN_ERR "%s: unable to allocate fddidev, aborting\n",
+               printk(KERN_ERR "%s: Unable to allocate fddidev, aborting\n",
                       print_name);
                return -ENOMEM;
        }
 
        /* Enable PCI device. */
-       if (pdev != NULL) {
-               err = pci_enable_device (pdev);
-               if (err) goto err_out;
-               ioaddr = pci_resource_start (pdev, 1);
+       if (dfx_bus_pci && pci_enable_device(to_pci_dev(bdev))) {
+               printk(KERN_ERR "%s: Cannot enable PCI device, aborting\n",
+                      print_name);
+               goto err_out;
        }
 
        SET_MODULE_OWNER(dev);
-       if (pdev != NULL)
-               SET_NETDEV_DEV(dev, &pdev->dev);
+       SET_NETDEV_DEV(dev, bdev);
+
+       bp = netdev_priv(dev);
+       bp->bus_dev = bdev;
+       dev_set_drvdata(bdev, dev);
 
-       bp = dev->priv;
+       dfx_get_bars(bdev, &bar_start, &bar_len);
 
-       if (!request_region(ioaddr,
-                           pdev ? PFI_K_CSR_IO_LEN : PI_ESIC_K_CSR_IO_LEN,
-                           print_name)) {
+       if (dfx_use_mmio)
+               region = request_mem_region(bar_start, bar_len, print_name);
+       else
+               region = request_region(bar_start, bar_len, print_name);
+       if (!region) {
                printk(KERN_ERR "%s: Cannot reserve I/O resource "
-                      "0x%x @ 0x%lx, aborting\n", print_name,
-                      pdev ? PFI_K_CSR_IO_LEN : PI_ESIC_K_CSR_IO_LEN, ioaddr);
+                      "0x%lx @ 0x%lx, aborting\n",
+                      print_name, (long)bar_len, (long)bar_start);
                err = -EBUSY;
-               goto err_out;
+               goto err_out_disable;
        }
 
-       /* Initialize new device structure */
+       /* Set up I/O base address. */
+       if (dfx_use_mmio) {
+               bp->base.mem = ioremap_nocache(bar_start, bar_len);
+               if (!bp->base.mem) {
+                       printk(KERN_ERR "%s: Cannot map MMIO\n", print_name);
+                       goto err_out_region;
+               }
+       } else {
+               bp->base.port = bar_start;
+               dev->base_addr = bar_start;
+       }
 
-       dev->base_addr                  = ioaddr; /* save port (I/O) base address */
+       /* Initialize new device structure */
 
        dev->get_stats                  = dfx_ctl_get_stats;
        dev->open                       = dfx_open;
@@ -465,22 +582,12 @@ static int __devinit dfx_init_one_pci_or_eisa(struct pci_dev *pdev, long ioaddr)
        dev->set_multicast_list         = dfx_ctl_set_multicast_list;
        dev->set_mac_address            = dfx_ctl_set_mac_address;
 
-       if (pdev == NULL) {
-               /* EISA board */
-               bp->bus_type = DFX_BUS_TYPE_EISA;
-               bp->next = root_dfx_eisa_dev;
-               root_dfx_eisa_dev = dev;
-       } else {
-               /* PCI board */
-               bp->bus_type = DFX_BUS_TYPE_PCI;
-               bp->pci_dev = pdev;
-               pci_set_drvdata (pdev, dev);
-               pci_set_master (pdev);
-       }
+       if (dfx_bus_pci)
+               pci_set_master(to_pci_dev(bdev));
 
-       if (dfx_driver_init(dev, print_name) != DFX_K_SUCCESS) {
+       if (dfx_driver_init(dev, print_name, bar_start) != DFX_K_SUCCESS) {
                err = -ENODEV;
-               goto err_out_region;
+               goto err_out_unmap;
        }
 
        err = register_netdev(dev);
@@ -499,44 +606,28 @@ err_out_kfree:
                     sizeof(PI_CONSUMER_BLOCK) +
                     (PI_ALIGN_K_DESC_BLK - 1);
        if (bp->kmalloced)
-               pci_free_consistent(pdev, alloc_size,
-                                   bp->kmalloced, bp->kmalloced_dma);
+               dma_free_coherent(bdev, alloc_size,
+                                 bp->kmalloced, bp->kmalloced_dma);
+
+err_out_unmap:
+       if (dfx_use_mmio)
+               iounmap(bp->base.mem);
+
 err_out_region:
-       release_region(ioaddr, pdev ? PFI_K_CSR_IO_LEN : PI_ESIC_K_CSR_IO_LEN);
+       if (dfx_use_mmio)
+               release_mem_region(bar_start, bar_len);
+       else
+               release_region(bar_start, bar_len);
+
+err_out_disable:
+       if (dfx_bus_pci)
+               pci_disable_device(to_pci_dev(bdev));
+
 err_out:
        free_netdev(dev);
        return err;
 }
 
-static int __devinit dfx_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
-{
-       return dfx_init_one_pci_or_eisa(pdev, 0);
-}
-
-static int __init dfx_eisa_init(void)
-{
-       int rc = -ENODEV;
-       int i;                  /* used in for loops */
-       u16 port;               /* temporary I/O (port) address */
-       u32 slot_id;            /* EISA hardware (slot) ID read from adapter */
-
-       DBG_printk("In dfx_eisa_init...\n");
-
-       /* Scan for FDDI EISA controllers */
-
-       for (i=0; i < DFX_MAX_EISA_SLOTS; i++)          /* only scan for up to 16 EISA slots */
-       {
-               port = (i << 12) + PI_ESIC_K_SLOT_ID;   /* port = I/O address for reading slot ID */
-               slot_id = inl(port);                                    /* read EISA HW (slot) ID */
-               if ((slot_id & 0xF0FFFFFF) == DEFEA_PRODUCT_ID)
-               {
-                       port = (i << 12);                                       /* recalc base addr */
-
-                       if (dfx_init_one_pci_or_eisa(NULL, port) == 0) rc = 0;
-               }
-       }
-       return rc;
-}
 
 /*
  * ================
@@ -544,7 +635,7 @@ static int __init dfx_eisa_init(void)
  * ================
  *
  * Overview:
- *   Initializes EISA and PCI controller bus-specific logic.
+ *   Initializes the bus-specific controller logic.
  *
  * Returns:
  *   None
@@ -560,7 +651,7 @@ static int __init dfx_eisa_init(void)
  *   None
  *
  * Assumptions:
- *   dev->base_addr has already been set with the proper
+ *   bp->base has already been set with the proper
  *      base I/O address for this device.
  *
  * Side Effects:
@@ -571,87 +662,103 @@ static int __init dfx_eisa_init(void)
 
 static void __devinit dfx_bus_init(struct net_device *dev)
 {
-       DFX_board_t *bp = dev->priv;
-       u8                      val;    /* used for I/O read/writes */
+       DFX_board_t *bp = netdev_priv(dev);
+       struct device *bdev = bp->bus_dev;
+       int dfx_bus_pci = DFX_BUS_PCI(bdev);
+       int dfx_bus_eisa = DFX_BUS_EISA(bdev);
+       int dfx_bus_tc = DFX_BUS_TC(bdev);
+       int dfx_use_mmio = DFX_MMIO || dfx_bus_tc;
+       u8 val;
 
        DBG_printk("In dfx_bus_init...\n");
 
-       /*
-        * Initialize base I/O address field in bp structure
-        *
-        * Note: bp->base_addr is the same as dev->base_addr.
-        *               It's useful because often we'll need to read
-        *               or write registers where we already have the
-        *               bp pointer instead of the dev pointer.  Having
-        *               the base address in the bp structure will
-        *               save a pointer dereference.
-        *
-        *               IMPORTANT!! This field must be defined before
-        *               any of the dfx_port_* inline functions are
-        *               called.
-        */
-
-       bp->base_addr = dev->base_addr;
-
-       /* And a pointer back to the net_device struct */
+       /* Initialize a pointer back to the net_device struct */
        bp->dev = dev;
 
        /* Initialize adapter based on bus type */
 
-       if (bp->bus_type == DFX_BUS_TYPE_EISA)
-               {
-               /* Get the interrupt level from the ESIC chip */
-
-               dfx_port_read_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, &val);
-               switch ((val & PI_CONFIG_STAT_0_M_IRQ) >> PI_CONFIG_STAT_0_V_IRQ)
-                       {
-                       case PI_CONFIG_STAT_0_IRQ_K_9:
-                               dev->irq = 9;
-                               break;
-
-                       case PI_CONFIG_STAT_0_IRQ_K_10:
-                               dev->irq = 10;
-                               break;
+       if (dfx_bus_tc)
+               dev->irq = to_tc_dev(bdev)->interrupt;
+       if (dfx_bus_eisa) {
+               unsigned long base_addr = to_eisa_device(bdev)->base_addr;
 
-                       case PI_CONFIG_STAT_0_IRQ_K_11:
-                               dev->irq = 11;
-                               break;
+               /* Get the interrupt level from the ESIC chip.  */
+               val = inb(base_addr + PI_ESIC_K_IO_CONFIG_STAT_0);
+               val &= PI_CONFIG_STAT_0_M_IRQ;
+               val >>= PI_CONFIG_STAT_0_V_IRQ;
 
-                       case PI_CONFIG_STAT_0_IRQ_K_15:
-                               dev->irq = 15;
-                               break;
-                       }
-
-               /* Enable access to I/O on the board by writing 0x03 to Function Control Register */
+               switch (val) {
+               case PI_CONFIG_STAT_0_IRQ_K_9:
+                       dev->irq = 9;
+                       break;
 
-               dfx_port_write_byte(bp, PI_ESIC_K_FUNCTION_CNTRL, PI_ESIC_K_FUNCTION_CNTRL_IO_ENB);
+               case PI_CONFIG_STAT_0_IRQ_K_10:
+                       dev->irq = 10;
+                       break;
 
-               /* Set the I/O decode range of the board */
+               case PI_CONFIG_STAT_0_IRQ_K_11:
+                       dev->irq = 11;
+                       break;
 
-               val = ((dev->base_addr >> 12) << PI_IO_CMP_V_SLOT);
-               dfx_port_write_byte(bp, PI_ESIC_K_IO_CMP_0_1, val);
-               dfx_port_write_byte(bp, PI_ESIC_K_IO_CMP_1_1, val);
+               case PI_CONFIG_STAT_0_IRQ_K_15:
+                       dev->irq = 15;
+                       break;
+               }
 
-               /* Enable access to rest of module (including PDQ and packet memory) */
+               /*
+                * Enable memory decoding (MEMCS0) and/or port decoding
+                * (IOCS1/IOCS0) as appropriate in Function Control
+                * Register.  One of the port chip selects seems to be
+                * used for the Burst Holdoff register, but this bit of
+                * documentation is missing and as yet it has not been
+                * determined which of the two.  This is also the reason
+                * the size of the decoded port range is twice as large
+                * as one required by the PDQ.
+                */
 
-               dfx_port_write_byte(bp, PI_ESIC_K_SLOT_CNTRL, PI_SLOT_CNTRL_M_ENB);
+               /* Set the decode range of the board.  */
+               val = ((bp->base.port >> 12) << PI_IO_CMP_V_SLOT);
+               outb(base_addr + PI_ESIC_K_IO_ADD_CMP_0_1, val);
+               outb(base_addr + PI_ESIC_K_IO_ADD_CMP_0_0, 0);
+               outb(base_addr + PI_ESIC_K_IO_ADD_CMP_1_1, val);
+               outb(base_addr + PI_ESIC_K_IO_ADD_CMP_1_0, 0);
+               val = PI_ESIC_K_CSR_IO_LEN - 1;
+               outb(base_addr + PI_ESIC_K_IO_ADD_MASK_0_1, (val >> 8) & 0xff);
+               outb(base_addr + PI_ESIC_K_IO_ADD_MASK_0_0, val & 0xff);
+               outb(base_addr + PI_ESIC_K_IO_ADD_MASK_1_1, (val >> 8) & 0xff);
+               outb(base_addr + PI_ESIC_K_IO_ADD_MASK_1_0, val & 0xff);
+
+               /* Enable the decoders.  */
+               val = PI_FUNCTION_CNTRL_M_IOCS1 | PI_FUNCTION_CNTRL_M_IOCS0;
+               if (dfx_use_mmio)
+                       val |= PI_FUNCTION_CNTRL_M_MEMCS0;
+               outb(base_addr + PI_ESIC_K_FUNCTION_CNTRL, val);
 
                /*
-                * Map PDQ registers into I/O space.  This is done by clearing a bit
-                * in Burst Holdoff register.
+                * Enable access to the rest of the module
+                * (including PDQ and packet memory).
                 */
+               val = PI_SLOT_CNTRL_M_ENB;
+               outb(base_addr + PI_ESIC_K_SLOT_CNTRL, val);
 
-               dfx_port_read_byte(bp, PI_ESIC_K_BURST_HOLDOFF, &val);
-               dfx_port_write_byte(bp, PI_ESIC_K_BURST_HOLDOFF, (val & ~PI_BURST_HOLDOFF_M_MEM_MAP));
+               /*
+                * Map PDQ registers into memory or port space.  This is
+                * done with a bit in the Burst Holdoff register.
+                */
+               val = inb(base_addr + PI_DEFEA_K_BURST_HOLDOFF);
+               if (dfx_use_mmio)
+                       val |= PI_BURST_HOLDOFF_V_MEM_MAP;
+               else
+                       val &= ~PI_BURST_HOLDOFF_V_MEM_MAP;
+               outb(base_addr + PI_DEFEA_K_BURST_HOLDOFF, val);
 
                /* Enable interrupts at EISA bus interface chip (ESIC) */
-
-               dfx_port_read_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, &val);
-               dfx_port_write_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, (val | PI_CONFIG_STAT_0_M_INT_ENB));
-               }
-       else
-               {
-               struct pci_dev *pdev = bp->pci_dev;
+               val = inb(base_addr + PI_ESIC_K_IO_CONFIG_STAT_0);
+               val |= PI_CONFIG_STAT_0_M_INT_ENB;
+               outb(base_addr + PI_ESIC_K_IO_CONFIG_STAT_0, val);
+       }
+       if (dfx_bus_pci) {
+               struct pci_dev *pdev = to_pci_dev(bdev);
 
                /* Get the interrupt level from the PCI Configuration Table */
 
@@ -660,17 +767,70 @@ static void __devinit dfx_bus_init(struct net_device *dev)
                /* Check Latency Timer and set if less than minimal */
 
                pci_read_config_byte(pdev, PCI_LATENCY_TIMER, &val);
-               if (val < PFI_K_LAT_TIMER_MIN)  /* if less than min, override with default */
-                       {
+               if (val < PFI_K_LAT_TIMER_MIN) {
                        val = PFI_K_LAT_TIMER_DEF;
                        pci_write_config_byte(pdev, PCI_LATENCY_TIMER, val);
-                       }
+               }
 
                /* Enable interrupts at PCI bus interface chip (PFI) */
+               val = PFI_MODE_M_PDQ_INT_ENB | PFI_MODE_M_DMA_ENB;
+               dfx_port_write_long(bp, PFI_K_REG_MODE_CTRL, val);
+       }
+}
 
-               dfx_port_write_long(bp, PFI_K_REG_MODE_CTRL, (PFI_MODE_M_PDQ_INT_ENB | PFI_MODE_M_DMA_ENB));
-               }
+/*
+ * ==================
+ * = dfx_bus_uninit =
+ * ==================
+ *
+ * Overview:
+ *   Uninitializes the bus-specific controller logic.
+ *
+ * Returns:
+ *   None
+ *
+ * Arguments:
+ *   dev - pointer to device information
+ *
+ * Functional Description:
+ *   Perform bus-specific logic uninitialization.
+ *
+ * Return Codes:
+ *   None
+ *
+ * Assumptions:
+ *   bp->base has already been set with the proper
+ *      base I/O address for this device.
+ *
+ * Side Effects:
+ *   Interrupts are disabled at the adapter bus-specific logic.
+ */
+
+static void __devinit dfx_bus_uninit(struct net_device *dev)
+{
+       DFX_board_t *bp = netdev_priv(dev);
+       struct device *bdev = bp->bus_dev;
+       int dfx_bus_pci = DFX_BUS_PCI(bdev);
+       int dfx_bus_eisa = DFX_BUS_EISA(bdev);
+       u8 val;
+
+       DBG_printk("In dfx_bus_uninit...\n");
+
+       /* Uninitialize adapter based on bus type */
+
+       if (dfx_bus_eisa) {
+               unsigned long base_addr = to_eisa_device(bdev)->base_addr;
+
+               /* Disable interrupts at EISA bus interface chip (ESIC) */
+               val = inb(base_addr + PI_ESIC_K_IO_CONFIG_STAT_0);
+               val &= ~PI_CONFIG_STAT_0_M_INT_ENB;
+               outb(base_addr + PI_ESIC_K_IO_CONFIG_STAT_0, val);
+       }
+       if (dfx_bus_pci) {
+               /* Disable interrupts at PCI bus interface chip (PFI) */
+               dfx_port_write_long(bp, PFI_K_REG_MODE_CTRL, 0);
        }
+}
 
 
 /*
@@ -705,18 +865,16 @@ static void __devinit dfx_bus_init(struct net_device *dev)
 
 static void __devinit dfx_bus_config_check(DFX_board_t *bp)
 {
+       struct device __unused *bdev = bp->bus_dev;
+       int dfx_bus_eisa = DFX_BUS_EISA(bdev);
        int     status;                         /* return code from adapter port control call */
-       u32     slot_id;                        /* EISA-bus hardware id (DEC3001, DEC3002,...) */
        u32     host_data;                      /* LW data returned from port control call */
 
        DBG_printk("In dfx_bus_config_check...\n");
 
        /* Configuration check only valid for EISA adapter */
 
-       if (bp->bus_type == DFX_BUS_TYPE_EISA)
-               {
-               dfx_port_read_long(bp, PI_ESIC_K_SLOT_ID, &slot_id);
-
+       if (dfx_bus_eisa) {
                /*
                 * First check if revision 2 EISA controller.  Rev. 1 cards used
                 * PDQ revision B, so no workaround needed in this case.  Rev. 3
@@ -724,14 +882,11 @@ static void __devinit dfx_bus_config_check(DFX_board_t *bp)
                 * case, either.  Only Rev. 2 cards used either Rev. D or E
                 * chips, so we must verify the chip revision on Rev. 2 cards.
                 */
-
-               if (slot_id == DEFEA_PROD_ID_2)
-                       {
+               if (to_eisa_device(bdev)->id.driver_data == DEFEA_PROD_ID_2) {
                        /*
-                        * Revision 2 FDDI EISA controller found, so let's check PDQ
-                        * revision of adapter.
+                        * Revision 2 FDDI EISA controller found,
+                        * so let's check PDQ revision of adapter.
                         */
-
                        status = dfx_hw_port_ctrl_req(bp,
                                                                                        PI_PCTRL_M_SUB_CMD,
                                                                                        PI_SUB_CMD_K_PDQ_REV_GET,
@@ -805,13 +960,20 @@ static void __devinit dfx_bus_config_check(DFX_board_t *bp)
  */
 
 static int __devinit dfx_driver_init(struct net_device *dev,
-                                    const char *print_name)
+                                    const char *print_name,
+                                    resource_size_t bar_start)
 {
-       DFX_board_t *bp = dev->priv;
-       int                     alloc_size;                     /* total buffer size needed */
-       char            *top_v, *curr_v;        /* virtual addrs into memory block */
-       dma_addr_t              top_p, curr_p;          /* physical addrs into memory block */
-       u32                     data;                           /* host data register value */
+       DFX_board_t *bp = netdev_priv(dev);
+       struct device *bdev = bp->bus_dev;
+       int dfx_bus_pci = DFX_BUS_PCI(bdev);
+       int dfx_bus_eisa = DFX_BUS_EISA(bdev);
+       int dfx_bus_tc = DFX_BUS_TC(bdev);
+       int dfx_use_mmio = DFX_MMIO || dfx_bus_tc;
+       int alloc_size;                 /* total buffer size needed */
+       char *top_v, *curr_v;           /* virtual addrs into memory block */
+       dma_addr_t top_p, curr_p;       /* physical addrs into memory block */
+       u32 data, le32;                 /* host data register value */
+       char *board_name = NULL;
 
        DBG_printk("In dfx_driver_init...\n");
 
@@ -860,8 +1022,8 @@ static int __devinit dfx_driver_init(struct net_device *dev,
                       print_name);
                return(DFX_K_FAILURE);
        }
-       data = cpu_to_le32(data);
-       memcpy(&bp->factory_mac_addr[0], &data, sizeof(u32));
+       le32 = cpu_to_le32(data);
+       memcpy(&bp->factory_mac_addr[0], &le32, sizeof(u32));
 
        if (dfx_hw_port_ctrl_req(bp, PI_PCTRL_M_MLA, PI_PDATA_A_MLA_K_HI, 0,
                                 &data) != DFX_K_SUCCESS) {
@@ -869,8 +1031,8 @@ static int __devinit dfx_driver_init(struct net_device *dev,
                       print_name);
                return(DFX_K_FAILURE);
        }
-       data = cpu_to_le32(data);
-       memcpy(&bp->factory_mac_addr[4], &data, sizeof(u16));
+       le32 = cpu_to_le32(data);
+       memcpy(&bp->factory_mac_addr[4], &le32, sizeof(u16));
 
        /*
         * Set current address to factory address
@@ -880,20 +1042,18 @@ static int __devinit dfx_driver_init(struct net_device *dev,
         */
 
        memcpy(dev->dev_addr, bp->factory_mac_addr, FDDI_K_ALEN);
-       if (bp->bus_type == DFX_BUS_TYPE_EISA)
-               printk("%s: DEFEA at I/O addr = 0x%lX, IRQ = %d, "
-                      "Hardware addr = %02X-%02X-%02X-%02X-%02X-%02X\n",
-                      print_name, dev->base_addr, dev->irq,
-                      dev->dev_addr[0], dev->dev_addr[1],
-                      dev->dev_addr[2], dev->dev_addr[3],
-                      dev->dev_addr[4], dev->dev_addr[5]);
-       else
-               printk("%s: DEFPA at I/O addr = 0x%lX, IRQ = %d, "
-                      "Hardware addr = %02X-%02X-%02X-%02X-%02X-%02X\n",
-                      print_name, dev->base_addr, dev->irq,
-                      dev->dev_addr[0], dev->dev_addr[1],
-                      dev->dev_addr[2], dev->dev_addr[3],
-                      dev->dev_addr[4], dev->dev_addr[5]);
+       if (dfx_bus_tc)
+               board_name = "DEFTA";
+       if (dfx_bus_eisa)
+               board_name = "DEFEA";
+       if (dfx_bus_pci)
+               board_name = "DEFPA";
+       pr_info("%s: %s at %saddr = 0x%llx, IRQ = %d, "
+               "Hardware addr = %02X-%02X-%02X-%02X-%02X-%02X\n",
+               print_name, board_name, dfx_use_mmio ? "" : "I/O ",
+               (long long)bar_start, dev->irq,
+               dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
+               dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]);
 
        /*
         * Get memory for descriptor block, consumer block, and other buffers
@@ -908,8 +1068,9 @@ static int __devinit dfx_driver_init(struct net_device *dev,
 #endif
                                        sizeof(PI_CONSUMER_BLOCK) +
                                        (PI_ALIGN_K_DESC_BLK - 1);
-       bp->kmalloced = top_v = pci_alloc_consistent(bp->pci_dev, alloc_size,
-                                                    &bp->kmalloced_dma);
+       bp->kmalloced = top_v = dma_alloc_coherent(bp->bus_dev, alloc_size,
+                                                  &bp->kmalloced_dma,
+                                                  GFP_ATOMIC);
        if (top_v == NULL) {
                printk("%s: Could not allocate memory for host buffers "
                       "and structures!\n", print_name);
@@ -1219,14 +1380,15 @@ static int dfx_adap_init(DFX_board_t *bp, int get_buffers)
 
 static int dfx_open(struct net_device *dev)
 {
+       DFX_board_t *bp = netdev_priv(dev);
        int ret;
-       DFX_board_t     *bp = dev->priv;
 
        DBG_printk("In dfx_open...\n");
 
        /* Register IRQ - support shared interrupts by passing device ptr */
 
-       ret = request_irq(dev->irq, dfx_interrupt, IRQF_SHARED, dev->name, dev);
+       ret = request_irq(dev->irq, dfx_interrupt, IRQF_SHARED, dev->name,
+                         dev);
        if (ret) {
                printk(KERN_ERR "%s: Requested IRQ %d is busy\n", dev->name, dev->irq);
                return ret;
@@ -1309,7 +1471,7 @@ static int dfx_open(struct net_device *dev)
 
 static int dfx_close(struct net_device *dev)
 {
-       DFX_board_t     *bp = dev->priv;
+       DFX_board_t *bp = netdev_priv(dev);
 
        DBG_printk("In dfx_close...\n");
 
@@ -1645,7 +1807,7 @@ static void dfx_int_type_0_process(DFX_board_t    *bp)
 
 static void dfx_int_common(struct net_device *dev)
 {
-       DFX_board_t     *bp = dev->priv;
+       DFX_board_t *bp = netdev_priv(dev);
        PI_UINT32       port_status;            /* Port Status register */
 
        /* Process xmt interrupts - frequent case, so always call this routine */
@@ -1715,18 +1877,16 @@ static void dfx_int_common(struct net_device *dev)
 
 static irqreturn_t dfx_interrupt(int irq, void *dev_id)
 {
-       struct net_device       *dev = dev_id;
-       DFX_board_t             *bp;    /* private board structure pointer */
-
-       /* Get board pointer only if device structure is valid */
-
-       bp = dev->priv;
-
-       /* See if we're already servicing an interrupt */
+       struct net_device *dev = dev_id;
+       DFX_board_t *bp = netdev_priv(dev);
+       struct device *bdev = bp->bus_dev;
+       int dfx_bus_pci = DFX_BUS_PCI(bdev);
+       int dfx_bus_eisa = DFX_BUS_EISA(bdev);
+       int dfx_bus_tc = DFX_BUS_TC(bdev);
 
        /* Service adapter interrupts */
 
-       if (bp->bus_type == DFX_BUS_TYPE_PCI) {
+       if (dfx_bus_pci) {
                u32 status;
 
                dfx_port_read_long(bp, PFI_K_REG_STATUS, &status);
@@ -1750,10 +1910,12 @@ static irqreturn_t dfx_interrupt(int irq, void *dev_id)
                                     PFI_MODE_M_DMA_ENB));
 
                spin_unlock(&bp->lock);
-       } else {
+       }
+       if (dfx_bus_eisa) {
+               unsigned long base_addr = to_eisa_device(bdev)->base_addr;
                u8 status;
 
-               dfx_port_read_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, &status);
+               status = inb(base_addr + PI_ESIC_K_IO_CONFIG_STAT_0);
                if (!(status & PI_CONFIG_STAT_0_M_PEND))
                        return IRQ_NONE;
 
@@ -1761,15 +1923,35 @@ static irqreturn_t dfx_interrupt(int irq, void *dev_id)
 
                /* Disable interrupts at the ESIC */
                status &= ~PI_CONFIG_STAT_0_M_INT_ENB;
-               dfx_port_write_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, status);
+               outb(base_addr + PI_ESIC_K_IO_CONFIG_STAT_0, status);
 
                /* Call interrupt service routine for this adapter */
                dfx_int_common(dev);
 
                /* Reenable interrupts at the ESIC */
-               dfx_port_read_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, &status);
+               status = inb(base_addr + PI_ESIC_K_IO_CONFIG_STAT_0);
                status |= PI_CONFIG_STAT_0_M_INT_ENB;
-               dfx_port_write_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, status);
+               outb(base_addr + PI_ESIC_K_IO_CONFIG_STAT_0, status);
+
+               spin_unlock(&bp->lock);
+       }
+       if (dfx_bus_tc) {
+               u32 status;
+
+               dfx_port_read_long(bp, PI_PDQ_K_REG_PORT_STATUS, &status);
+               if (!(status & (PI_PSTATUS_M_RCV_DATA_PENDING |
+                               PI_PSTATUS_M_XMT_DATA_PENDING |
+                               PI_PSTATUS_M_SMT_HOST_PENDING |
+                               PI_PSTATUS_M_UNSOL_PENDING |
+                               PI_PSTATUS_M_CMD_RSP_PENDING |
+                               PI_PSTATUS_M_CMD_REQ_PENDING |
+                               PI_PSTATUS_M_TYPE_0_PENDING)))
+                       return IRQ_NONE;
+
+               spin_lock(&bp->lock);
+
+               /* Call interrupt service routine for this adapter */
+               dfx_int_common(dev);
 
                spin_unlock(&bp->lock);
        }
@@ -1823,7 +2005,7 @@ static irqreturn_t dfx_interrupt(int irq, void *dev_id)
 
 static struct net_device_stats *dfx_ctl_get_stats(struct net_device *dev)
        {
-       DFX_board_t     *bp = dev->priv;
+       DFX_board_t *bp = netdev_priv(dev);
 
        /* Fill the bp->stats structure with driver-maintained counters */
 
@@ -2009,8 +2191,8 @@ static struct net_device_stats *dfx_ctl_get_stats(struct net_device *dev)
  */
 
 static void dfx_ctl_set_multicast_list(struct net_device *dev)
-       {
-       DFX_board_t                     *bp = dev->priv;
+{
+       DFX_board_t *bp = netdev_priv(dev);
        int                                     i;                      /* used as index in for loop */
        struct dev_mc_list      *dmi;           /* ptr to multicast addr entry */
 
@@ -2124,8 +2306,8 @@ static void dfx_ctl_set_multicast_list(struct net_device *dev)
 
 static int dfx_ctl_set_mac_address(struct net_device *dev, void *addr)
        {
-       DFX_board_t             *bp = dev->priv;
        struct sockaddr *p_sockaddr = (struct sockaddr *)addr;
+       DFX_board_t *bp = netdev_priv(dev);
 
        /* Copy unicast address to driver-maintained structs and update count */
 
@@ -2764,9 +2946,9 @@ static int dfx_rcv_init(DFX_board_t *bp, int get_buffers)
 
                        my_skb_align(newskb, 128);
                        bp->descr_block_virt->rcv_data[i + j].long_1 =
-                               (u32)pci_map_single(bp->pci_dev, newskb->data,
+                               (u32)dma_map_single(bp->bus_dev, newskb->data,
                                                    NEW_SKB_SIZE,
-                                                   PCI_DMA_FROMDEVICE);
+                                                   DMA_FROM_DEVICE);
                        /*
                         * p_rcv_buff_va is only used inside the
                         * kernel so we put the skb pointer here.
@@ -2880,17 +3062,17 @@ static void dfx_rcv_queue_process(
 
                                                my_skb_align(newskb, 128);
                                                skb = (struct sk_buff *)bp->p_rcv_buff_va[entry];
-                                               pci_unmap_single(bp->pci_dev,
+                                               dma_unmap_single(bp->bus_dev,
                                                        bp->descr_block_virt->rcv_data[entry].long_1,
                                                        NEW_SKB_SIZE,
-                                                       PCI_DMA_FROMDEVICE);
+                                                       DMA_FROM_DEVICE);
                                                skb_reserve(skb, RCV_BUFF_K_PADDING);
                                                bp->p_rcv_buff_va[entry] = (char *)newskb;
                                                bp->descr_block_virt->rcv_data[entry].long_1 =
-                                                       (u32)pci_map_single(bp->pci_dev,
+                                                       (u32)dma_map_single(bp->bus_dev,
                                                                newskb->data,
                                                                NEW_SKB_SIZE,
-                                                               PCI_DMA_FROMDEVICE);
+                                                               DMA_FROM_DEVICE);
                                        } else
                                                skb = NULL;
                                } else
@@ -3010,7 +3192,7 @@ static int dfx_xmt_queue_pkt(
        )
 
        {
-       DFX_board_t             *bp = dev->priv;
+       DFX_board_t             *bp = netdev_priv(dev);
        u8                      prod;                           /* local transmit producer index */
        PI_XMT_DESCR            *p_xmt_descr;           /* ptr to transmit descriptor block entry */
        XMT_DRIVER_DESCR        *p_xmt_drv_descr;       /* ptr to transmit driver descriptor */
@@ -3116,8 +3298,8 @@ static int dfx_xmt_queue_pkt(
         */
 
        p_xmt_descr->long_0     = (u32) (PI_XMT_DESCR_M_SOP | PI_XMT_DESCR_M_EOP | ((skb->len) << PI_XMT_DESCR_V_SEG_LEN));
-       p_xmt_descr->long_1 = (u32)pci_map_single(bp->pci_dev, skb->data,
-                                                 skb->len, PCI_DMA_TODEVICE);
+       p_xmt_descr->long_1 = (u32)dma_map_single(bp->bus_dev, skb->data,
+                                                 skb->len, DMA_TO_DEVICE);
 
        /*
         * Verify that descriptor is actually available
@@ -3220,10 +3402,10 @@ static int dfx_xmt_done(DFX_board_t *bp)
 
                /* Return skb to operating system */
                comp = bp->rcv_xmt_reg.index.xmt_comp;
-               pci_unmap_single(bp->pci_dev,
+               dma_unmap_single(bp->bus_dev,
                                 bp->descr_block_virt->xmt_data[comp].long_1,
                                 p_xmt_drv_descr->p_skb->len,
-                                PCI_DMA_TODEVICE);
+                                DMA_TO_DEVICE);
                dev_kfree_skb_irq(p_xmt_drv_descr->p_skb);
 
                /*
@@ -3344,10 +3526,10 @@ static void dfx_xmt_flush( DFX_board_t *bp )
 
                /* Return skb to operating system */
                comp = bp->rcv_xmt_reg.index.xmt_comp;
-               pci_unmap_single(bp->pci_dev,
+               dma_unmap_single(bp->bus_dev,
                                 bp->descr_block_virt->xmt_data[comp].long_1,
                                 p_xmt_drv_descr->p_skb->len,
-                                PCI_DMA_TODEVICE);
+                                DMA_TO_DEVICE);
                dev_kfree_skb(p_xmt_drv_descr->p_skb);
 
                /* Increment transmit error counter */
@@ -3375,13 +3557,44 @@ static void dfx_xmt_flush( DFX_board_t *bp )
        bp->cons_block_virt->xmt_rcv_data = prod_cons;
        }
 
-static void __devexit dfx_remove_one_pci_or_eisa(struct pci_dev *pdev, struct net_device *dev)
+/*
+ * ==================
+ * = dfx_unregister =
+ * ==================
+ *
+ * Overview:
+ *   Shuts down an FDDI controller
+ *
+ * Returns:
+ *   Condition code
+ *
+ * Arguments:
+ *   bdev - pointer to device information
+ *
+ * Functional Description:
+ *
+ * Return Codes:
+ *   None
+ *
+ * Assumptions:
+ *   It compiles so it should work :-( (PCI cards do :-)
+ *
+ * Side Effects:
+ *   Device structures for FDDI adapters (fddi0, fddi1, etc) are
+ *   freed.
+ */
+static void __devexit dfx_unregister(struct device *bdev)
 {
-       DFX_board_t     *bp = dev->priv;
+       struct net_device *dev = dev_get_drvdata(bdev);
+       DFX_board_t *bp = netdev_priv(dev);
+       int dfx_bus_pci = DFX_BUS_PCI(bdev);
+       int dfx_bus_tc = DFX_BUS_TC(bdev);
+       int dfx_use_mmio = DFX_MMIO || dfx_bus_tc;
+       resource_size_t bar_start = 0;          /* pointer to port */
+       resource_size_t bar_len = 0;            /* resource length */
        int             alloc_size;             /* total buffer size used */
 
        unregister_netdev(dev);
-       release_region(dev->base_addr,  pdev ? PFI_K_CSR_IO_LEN : PI_ESIC_K_CSR_IO_LEN );
 
        alloc_size = sizeof(PI_DESCR_BLOCK) +
                     PI_CMD_REQ_K_SIZE_MAX + PI_CMD_RSP_K_SIZE_MAX +
@@ -3391,78 +3604,141 @@ static void __devexit dfx_remove_one_pci_or_eisa(struct pci_dev *pdev, struct ne
                     sizeof(PI_CONSUMER_BLOCK) +
                     (PI_ALIGN_K_DESC_BLK - 1);
        if (bp->kmalloced)
-               pci_free_consistent(pdev, alloc_size, bp->kmalloced,
-                                   bp->kmalloced_dma);
+               dma_free_coherent(bdev, alloc_size,
+                                 bp->kmalloced, bp->kmalloced_dma);
+
+       dfx_bus_uninit(dev);
+
+       dfx_get_bars(bdev, &bar_start, &bar_len);
+       if (dfx_use_mmio) {
+               iounmap(bp->base.mem);
+               release_mem_region(bar_start, bar_len);
+       } else
+               release_region(bar_start, bar_len);
+
+       if (dfx_bus_pci)
+               pci_disable_device(to_pci_dev(bdev));
+
        free_netdev(dev);
 }
 
-static void __devexit dfx_remove_one (struct pci_dev *pdev)
-{
-       struct net_device *dev = pci_get_drvdata(pdev);
 
-       dfx_remove_one_pci_or_eisa(pdev, dev);
-       pci_set_drvdata(pdev, NULL);
-}
+static int __devinit __unused dfx_dev_register(struct device *);
+static int __devexit __unused dfx_dev_unregister(struct device *);
 
-static struct pci_device_id dfx_pci_tbl[] = {
-       { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_FDDI, PCI_ANY_ID, PCI_ANY_ID, },
-       { 0, }
+#ifdef CONFIG_PCI
+static int __devinit dfx_pci_register(struct pci_dev *,
+                                     const struct pci_device_id *);
+static void __devexit dfx_pci_unregister(struct pci_dev *);
+
+static struct pci_device_id dfx_pci_table[] = {
+       { PCI_DEVICE(PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_FDDI) },
+       { }
 };
-MODULE_DEVICE_TABLE(pci, dfx_pci_tbl);
+MODULE_DEVICE_TABLE(pci, dfx_pci_table);
 
-static struct pci_driver dfx_driver = {
+static struct pci_driver dfx_pci_driver = {
        .name           = "defxx",
-       .probe          = dfx_init_one,
-       .remove         = __devexit_p(dfx_remove_one),
-       .id_table       = dfx_pci_tbl,
+       .id_table       = dfx_pci_table,
+       .probe          = dfx_pci_register,
+       .remove         = __devexit_p(dfx_pci_unregister),
 };
 
-static int dfx_have_pci;
-static int dfx_have_eisa;
-
+static __devinit int dfx_pci_register(struct pci_dev *pdev,
+                                     const struct pci_device_id *ent)
+{
+       return dfx_register(&pdev->dev);
+}
 
-static void __exit dfx_eisa_cleanup(void)
+static void __devexit dfx_pci_unregister(struct pci_dev *pdev)
 {
-       struct net_device *dev = root_dfx_eisa_dev;
+       dfx_unregister(&pdev->dev);
+}
+#endif /* CONFIG_PCI */
+
+#ifdef CONFIG_EISA
+static struct eisa_device_id dfx_eisa_table[] = {
+        { "DEC3001", DEFEA_PROD_ID_1 },
+        { "DEC3002", DEFEA_PROD_ID_2 },
+        { "DEC3003", DEFEA_PROD_ID_3 },
+        { "DEC3004", DEFEA_PROD_ID_4 },
+        { }
+};
+MODULE_DEVICE_TABLE(eisa, dfx_eisa_table);
+
+static struct eisa_driver dfx_eisa_driver = {
+       .id_table       = dfx_eisa_table,
+       .driver         = {
+               .name   = "defxx",
+               .bus    = &eisa_bus_type,
+               .probe  = dfx_dev_register,
+               .remove = __devexit_p(dfx_dev_unregister),
+       },
+};
+#endif /* CONFIG_EISA */
+
+#ifdef CONFIG_TC
+static struct tc_device_id const dfx_tc_table[] = {
+       { "DEC     ", "PMAF-FA " },
+       { "DEC     ", "PMAF-FD " },
+       { "DEC     ", "PMAF-FS " },
+       { "DEC     ", "PMAF-FU " },
+       { }
+};
+MODULE_DEVICE_TABLE(tc, dfx_tc_table);
+
+static struct tc_driver dfx_tc_driver = {
+       .id_table       = dfx_tc_table,
+       .driver         = {
+               .name   = "defxx",
+               .bus    = &tc_bus_type,
+               .probe  = dfx_dev_register,
+               .remove = __devexit_p(dfx_dev_unregister),
+       },
+};
+#endif /* CONFIG_TC */
 
-       while (dev)
-       {
-               struct net_device *tmp;
-               DFX_board_t *bp;
+static int __devinit __unused dfx_dev_register(struct device *dev)
+{
+       int status;
 
-               bp = (DFX_board_t*)dev->priv;
-               tmp = bp->next;
-               dfx_remove_one_pci_or_eisa(NULL, dev);
-               dev = tmp;
-       }
+       status = dfx_register(dev);
+       if (!status)
+               get_device(dev);
+       return status;
 }
 
-static int __init dfx_init(void)
+static int __devexit __unused dfx_dev_unregister(struct device *dev)
 {
-       int rc_pci, rc_eisa;
-
-       rc_pci = pci_register_driver(&dfx_driver);
-       if (rc_pci >= 0) dfx_have_pci = 1;
+       put_device(dev);
+       dfx_unregister(dev);
+       return 0;
+}
 
-       rc_eisa = dfx_eisa_init();
-       if (rc_eisa >= 0) dfx_have_eisa = 1;
 
-       return ((rc_eisa < 0) ? 0 : rc_eisa)  + ((rc_pci < 0) ? 0 : rc_pci);
+static int __devinit dfx_init(void)
+{
+       int status;
+
+       status = pci_register_driver(&dfx_pci_driver);
+       if (!status)
+               status = eisa_driver_register(&dfx_eisa_driver);
+       if (!status)
+               status = tc_register_driver(&dfx_tc_driver);
+       return status;
 }
 
-static void __exit dfx_cleanup(void)
+static void __devexit dfx_cleanup(void)
 {
-       if (dfx_have_pci)
-               pci_unregister_driver(&dfx_driver);
-       if (dfx_have_eisa)
-               dfx_eisa_cleanup();
-
+       tc_unregister_driver(&dfx_tc_driver);
+       eisa_driver_unregister(&dfx_eisa_driver);
+       pci_unregister_driver(&dfx_pci_driver);
 }
 
 module_init(dfx_init);
 module_exit(dfx_cleanup);
 MODULE_AUTHOR("Lawrence V. Stefani");
-MODULE_DESCRIPTION("DEC FDDIcontroller EISA/PCI (DEFEA/DEFPA) driver "
+MODULE_DESCRIPTION("DEC FDDIcontroller TC/EISA/PCI (DEFTA/DEFEA/DEFPA) driver "
                   DRV_VERSION " " DRV_RELDATE);
 MODULE_LICENSE("GPL");
 
index 2ce8f97253ebb2106745b7a0ad6dc637a775e0d9..19a6f64df1984b77d85046895fb39d92e584b1b5 100644 (file)
@@ -26,6 +26,7 @@
  *             12-Sep-96       LVS             Removed packet request header pointers.
  *             04 Aug 2003     macro           Converted to the DMA API.
  *             23 Oct 2006     macro           Big-endian host support.
+ *             14 Dec 2006     macro           TURBOchannel support.
  */
 
 #ifndef _DEFXX_H_
@@ -1471,9 +1472,17 @@ typedef union
 
 #endif /* __BIG_ENDIAN */
 
+/* Define TC PDQ CSR offset and length */
+
+#define PI_TC_K_CSR_OFFSET             0x100000
+#define PI_TC_K_CSR_LEN                        0x40            /* 64 bytes */
+
 /* Define EISA controller register offsets */
 
-#define PI_ESIC_K_BURST_HOLDOFF                0x040
+#define PI_ESIC_K_CSR_IO_LEN           0x80            /* 128 bytes */
+
+#define PI_DEFEA_K_BURST_HOLDOFF       0x040
+
 #define PI_ESIC_K_SLOT_ID              0xC80
 #define PI_ESIC_K_SLOT_CNTRL           0xC84
 #define PI_ESIC_K_MEM_ADD_CMP_0        0xC85
@@ -1488,14 +1497,14 @@ typedef union
 #define PI_ESIC_K_MEM_ADD_LO_CMP_0     0xC8E
 #define PI_ESIC_K_MEM_ADD_LO_CMP_1     0xC8F
 #define PI_ESIC_K_MEM_ADD_LO_CMP_2     0xC90
-#define PI_ESIC_K_IO_CMP_0_0           0xC91
-#define PI_ESIC_K_IO_CMP_0_1           0xC92
-#define PI_ESIC_K_IO_CMP_1_0           0xC93
-#define PI_ESIC_K_IO_CMP_1_1           0xC94
-#define PI_ESIC_K_IO_CMP_2_0           0xC95
-#define PI_ESIC_K_IO_CMP_2_1           0xC96
-#define PI_ESIC_K_IO_CMP_3_0           0xC97
-#define PI_ESIC_K_IO_CMP_3_1           0xC98
+#define PI_ESIC_K_IO_ADD_CMP_0_0       0xC91
+#define PI_ESIC_K_IO_ADD_CMP_0_1       0xC92
+#define PI_ESIC_K_IO_ADD_CMP_1_0       0xC93
+#define PI_ESIC_K_IO_ADD_CMP_1_1       0xC94
+#define PI_ESIC_K_IO_ADD_CMP_2_0       0xC95
+#define PI_ESIC_K_IO_ADD_CMP_2_1       0xC96
+#define PI_ESIC_K_IO_ADD_CMP_3_0       0xC97
+#define PI_ESIC_K_IO_ADD_CMP_3_1       0xC98
 #define PI_ESIC_K_IO_ADD_MASK_0_0      0xC99
 #define PI_ESIC_K_IO_ADD_MASK_0_1      0xC9A
 #define PI_ESIC_K_IO_ADD_MASK_1_0      0xC9B
@@ -1518,11 +1527,16 @@ typedef union
 #define PI_ESIC_K_INPUT_PORT           0xCAC
 #define PI_ESIC_K_OUTPUT_PORT          0xCAD
 #define PI_ESIC_K_FUNCTION_CNTRL       0xCAE
-#define PI_ESIC_K_CSR_IO_LEN           PI_ESIC_K_FUNCTION_CNTRL+1      /* always last reg + 1 */
 
-/* Define the value all drivers must write to the function control register. */
+/* Define the bits in the function control register. */
 
-#define PI_ESIC_K_FUNCTION_CNTRL_IO_ENB        0x03
+#define PI_FUNCTION_CNTRL_M_IOCS0      0x01
+#define PI_FUNCTION_CNTRL_M_IOCS1      0x02
+#define PI_FUNCTION_CNTRL_M_IOCS2      0x04
+#define PI_FUNCTION_CNTRL_M_IOCS3      0x08
+#define PI_FUNCTION_CNTRL_M_MEMCS0     0x10
+#define PI_FUNCTION_CNTRL_M_MEMCS1     0x20
+#define PI_FUNCTION_CNTRL_M_DMA                0x80
 
 /* Define the bits in the slot control register. */
 
@@ -1540,6 +1554,10 @@ typedef union
 #define PI_BURST_HOLDOFF_V_RESERVED    1
 #define PI_BURST_HOLDOFF_V_MEM_MAP     0
 
+/* Define the implicit mask of the Memory Address Mask Register.  */
+
+#define PI_MEM_ADD_MASK_M              0x3ff
+
 /*
  * Define the fields in the IO Compare registers.
  * The driver must initialize the slot field with the slot ID shifted by the
@@ -1577,6 +1595,7 @@ typedef union
 #define DEFEA_PROD_ID_1                0x0130A310              /* DEC product 300, rev 1       */
 #define DEFEA_PROD_ID_2                0x0230A310              /* DEC product 300, rev 2       */
 #define DEFEA_PROD_ID_3                0x0330A310              /* DEC product 300, rev 3       */
+#define DEFEA_PROD_ID_4                0x0430A310              /* DEC product 300, rev 4       */
 
 /**********************************************/
 /* Digital PFI Specification v1.0 Definitions */
@@ -1633,12 +1652,6 @@ typedef union
 #define PFI_STATUS_V_FIFO_EMPTY                 1
 #define PFI_STATUS_V_DMA_IN_PROGRESS 0
 
-#define DFX_MAX_EISA_SLOTS             16                      /* maximum number of EISA slots to scan */
-#define DFX_MAX_NUM_BOARDS             8                       /* maximum number of adapters supported */
-
-#define DFX_BUS_TYPE_PCI               0                       /* type code for DEC FDDIcontroller/PCI */
-#define DFX_BUS_TYPE_EISA              1                       /* type code for DEC FDDIcontroller/EISA */
-
 #define DFX_FC_PRH2_PRH1_PRH0          0x54003820      /* Packet Request Header bytes + FC */
 #define DFX_PRH0_BYTE                  0x20            /* Packet Request Header byte 0 */
 #define DFX_PRH1_BYTE                  0x38            /* Packet Request Header byte 1 */
@@ -1756,10 +1769,11 @@ typedef struct DFX_board_tag
        /* Store device, bus-specific, and parameter information for this adapter */
 
        struct net_device               *dev;                                           /* pointer to device structure */
-       struct net_device               *next;
-       u32                             bus_type;                                       /* bus type (0 == PCI, 1 == EISA) */
-       u16                             base_addr;                                      /* base I/O address (same as dev->base_addr) */
-       struct pci_dev *                pci_dev;
+       union {
+               void __iomem *mem;
+               int port;
+       } base;                                                                         /* base address */
+       struct device                   *bus_dev;
        u32                             full_duplex_enb;                                /* FDDI Full Duplex enable (1 == on, 2 == off) */
        u32                             req_ttrt;                                       /* requested TTRT value (in 80ns units) */
        u32                             burst_size;                                     /* adapter burst size (enumerated) */
index c62d9c6363c60c94093ee2a1a0cac86ec8ed02b1..b2b0a96218ca9a339e11500f7da6c2a9cc732a7a 100644 (file)
@@ -355,8 +355,7 @@ e21_block_input(struct net_device *dev, int count, struct sk_buff *skb, int ring
 
        mem_on(ioaddr, shared_mem, (ring_offset>>8));
 
-       /* Packet is always in one chunk -- we can copy + cksum. */
-       eth_io_copy_and_sum(skb, ei_status.mem + (ring_offset & 0xff), count, 0);
+       memcpy_fromio(skb->data, ei_status.mem + (ring_offset & 0xff), count);
 
        mem_off(ioaddr);
 }
index 2d2ea94a00bb72cd7568d4a4f2d185be068aec8b..822e5bfd1a716836b2e7d125dcdf944b5a524810 100644 (file)
@@ -375,7 +375,7 @@ static void es_block_input(struct net_device *dev, int count, struct sk_buff *sk
                memcpy_fromio(skb->data + semi_count, ei_status.mem, count);
        } else {
                /* Packet is in one chunk. */
-               eth_io_copy_and_sum(skb, xfer_start, count, 0);
+               memcpy_fromio(skb->data, xfer_start, count);
        }
 }
 
index 24f6050fbf33ab71106224320e51da2a35758031..8ca57a0a4c11acb47ece31b99bac91e8887d4066 100644 (file)
@@ -49,6 +49,7 @@
 #include <linux/skbuff.h>
 #include <linux/platform_device.h>
 #include <linux/dma-mapping.h>
+#include <linux/bitrev.h>
 
 #include <asm/bootinfo.h>
 #include <asm/system.h>
index b3bf86422734a07eb7ec37da30bd1cd1acdb0b95..d98e53efa2ef56158a8d0ea63fbcbda2dba08096 100644 (file)
@@ -2780,7 +2780,6 @@ static const struct ethtool_ops mv643xx_ethtool_ops = {
        .get_link               = mv643xx_eth_get_link,
        .get_sg                 = ethtool_op_get_sg,
        .set_sg                 = ethtool_op_set_sg,
-       .get_strings            = mv643xx_get_strings,
        .get_stats_count        = mv643xx_get_stats_count,
        .get_ethtool_stats      = mv643xx_get_ethtool_stats,
        .get_strings            = mv643xx_get_strings,
index c6de566188e4d6db66667b1855031d90b9dc8524..0986f6c843e6974d87298c3b5f87d444d594858f 100644 (file)
@@ -83,7 +83,7 @@ struct ppp_file {
        int             dead;           /* unit/channel has been shut down */
 };
 
-#define PF_TO_X(pf, X)         ((X *)((char *)(pf) - offsetof(X, file)))
+#define PF_TO_X(pf, X)         container_of(pf, X, file)
 
 #define PF_TO_PPP(pf)          PF_TO_X(pf, struct ppp)
 #define PF_TO_CHANNEL(pf)      PF_TO_X(pf, struct channel)
index 577babd4c9386559001b725e030f9b56b878a894..5598d86380b430a3853fe613b9a36cda9e022dd2 100644 (file)
@@ -2016,7 +2016,7 @@ static int rtl8169_alloc_rx_skb(struct pci_dev *pdev, struct sk_buff **sk_buff,
        if (!skb)
                goto err_out;
 
-       skb_reserve(skb, (align - 1) & (u32)skb->data);
+       skb_reserve(skb, (align - 1) & (unsigned long)skb->data);
        *sk_buff = skb;
 
        mapping = pci_map_single(pdev, skb->data, rx_buf_sz,
@@ -2487,7 +2487,7 @@ static inline int rtl8169_try_rx_copy(struct sk_buff **sk_buff, int pkt_size,
 
                skb = dev_alloc_skb(pkt_size + align);
                if (skb) {
-                       skb_reserve(skb, (align - 1) & (u32)skb->data);
+                       skb_reserve(skb, (align - 1) & (unsigned long)skb->data);
                        eth_copy_and_sum(skb, sk_buff[0]->data, pkt_size, 0);
                        *sk_buff = skb;
                        rtl8169_mark_to_asic(desc, rx_buf_sz);
index 639fbc0f16f3f8d8d1832d3bfca7ce436433e784..8646b64994abadee6b2e38bcf0b7fe4209d1d6da 100644 (file)
@@ -7298,7 +7298,7 @@ static void update_L3L4_header(struct s2io_nic *sp, struct lro *lro)
 {
        struct iphdr *ip = lro->iph;
        struct tcphdr *tcp = lro->tcph;
-       u16 nchk;
+       __sum16 nchk;
        struct stat_block *statinfo = sp->mac_control.stats_info;
        DBG_PRINT(INFO_DBG,"%s: Been here...\n", __FUNCTION__);
 
index a5e1a513deb53039d1ac97e0514d3fe940bd382d..0de0c65f945aba87f90760557adca24bb49173ed 100644 (file)
@@ -727,12 +727,12 @@ struct lro {
        struct iphdr    *iph;
        struct tcphdr   *tcph;
        u32             tcp_next_seq;
-       u32             tcp_ack;
+       __be32          tcp_ack;
        int             total_len;
        int             frags_len;
        int             sg_num;
        int             in_use;
-       u16             window;
+       __be16          window;
        u32             cur_tsval;
        u32             cur_tsecr;
        u8              saw_ts;
@@ -1005,7 +1005,7 @@ static int s2io_set_swapper(struct s2io_nic * sp);
 static void s2io_card_down(struct s2io_nic *nic);
 static int s2io_card_up(struct s2io_nic *nic);
 static int get_xena_rev_id(struct pci_dev *pdev);
-static int wait_for_cmd_complete(void *addr, u64 busy_bit);
+static int wait_for_cmd_complete(void __iomem *addr, u64 busy_bit);
 static int s2io_add_isr(struct s2io_nic * sp);
 static void s2io_rem_isr(struct s2io_nic * sp);
 
index a0806d262fc6530c1e72c2c75b14a999cc74e529..2f4b1de7a2b403dba05d2decc326ae4a9d83ad40 100644 (file)
@@ -1343,15 +1343,12 @@ static int __init slip_init(void)
        printk(KERN_INFO "SLIP linefill/keepalive option.\n");
 #endif
 
-       slip_devs = kmalloc(sizeof(struct net_device *)*slip_maxdev, GFP_KERNEL);
+       slip_devs = kzalloc(sizeof(struct net_device *)*slip_maxdev, GFP_KERNEL);
        if (!slip_devs) {
                printk(KERN_ERR "SLIP: Can't allocate slip devices array!  Uaargh! (-> No SLIP available)\n");
                return -ENOMEM;
        }
 
-       /* Clear the pointer array, we allocate devices when we need them */
-       memset(slip_devs, 0, sizeof(struct net_device *)*slip_maxdev);
-
        /* Fill in our line protocol discipline, and register it */
        if ((status = tty_register_ldisc(N_SLIP, &sl_ldisc)) != 0)  {
                printk(KERN_ERR "SLIP: can't register line discipline (err = %d)\n", status);
index 7122932eac905135332303191c014787b1ce8c51..ae1ae343beedfd13981e10cb80e3854558086977 100644 (file)
@@ -482,8 +482,7 @@ static void ultramca_block_input(struct net_device *dev, int count, struct sk_bu
                count -= semi_count;
                memcpy_fromio(skb->data + semi_count, ei_status.mem + TX_PAGES * 256, count);
        } else {
-               /* Packet is in one chunk -- we can copy + cksum. */
-               eth_io_copy_and_sum(skb, xfer_start, count, 0);
+               memcpy_fromio(skb->data, xfer_start, count);
        }
 
 }
index d70bc979534669ba60eb49109ad73797bcb00cdd..a52b22d7db657776700a3f9029fd7b43e7d144f9 100644 (file)
@@ -454,8 +454,7 @@ ultra_block_input(struct net_device *dev, int count, struct sk_buff *skb, int ri
                count -= semi_count;
                memcpy_fromio(skb->data + semi_count, ei_status.mem + TX_PAGES * 256, count);
        } else {
-               /* Packet is in one chunk -- we can copy + cksum. */
-               eth_io_copy_and_sum(skb, xfer_start, count, 0);
+               memcpy_fromio(skb->data, xfer_start, count);
        }
 
        outb(0x00, dev->base_addr - ULTRA_NIC_OFFSET);  /* Disable memory. */
index 2c5319c62fa50c520f1762880b7cea57f15aef4d..88a30e56c64ce50c0d62057dc3e9560cf0e4725d 100644 (file)
@@ -395,8 +395,7 @@ static void ultra32_block_input(struct net_device *dev,
                        memcpy_fromio(skb->data + semi_count, ei_status.mem + TX_PAGES * 256, count);
                }
        } else {
-               /* Packet is in one chunk -- we can copy + cksum. */
-               eth_io_copy_and_sum(skb, xfer_start, count, 0);
+               memcpy_fromio(skb->data, xfer_start, count);
        }
 }
 
index bf6ff39e02bbc035e2da03992be4c3661d07fa1c..64ed8ff5b03ac6038e4d54fecee1dea85529bf22 100644 (file)
@@ -1907,7 +1907,7 @@ spider_net_stop(struct net_device *netdev)
        spider_net_write_reg(card, SPIDER_NET_GHIINT2MSK, 0);
 
        /* free_irq(netdev->irq, netdev);*/
-       free_irq(to_pci_dev(netdev->class_dev.dev)->irq, netdev);
+       free_irq(to_pci_dev(netdev->dev.parent)->irq, netdev);
 
        spider_net_write_reg(card, SPIDER_NET_GDTDMACCNTR,
                             SPIDER_NET_DMA_TX_FEND_VALUE);
index 135c0987deaeeb25a0793a4e0925b1bfb3f1fe89..e136bae619705d19cd243d7f57f5d096d2ef8421 100644 (file)
@@ -3380,7 +3380,7 @@ next_pkt:
                }
 next_pkt_nopost:
                sw_idx++;
-               sw_idx %= TG3_RX_RCB_RING_SIZE(tp);
+               sw_idx &= (TG3_RX_RCB_RING_SIZE(tp) - 1);
 
                /* Refresh hw_idx to see if there is new work */
                if (sw_idx == hw_idx) {
index abb8611c5a916b7d3e12223cdfbfeeb30920e523..31c97a6591a44cdc3b10b3f5f5ac0fb7f3f500e9 100644 (file)
@@ -1709,75 +1709,13 @@ static void adjust_link(struct net_device *dev)
                if (mii_info->speed != ugeth->oldspeed) {
                        switch (mii_info->speed) {
                        case 1000:
-#ifdef CONFIG_PPC_MPC836x
-/* FIXME: This code is for 100Mbs BUG fixing,
-remove this when it is fixed!!! */
-                               if (ugeth->ug_info->enet_interface ==
-                                   ENET_1000_GMII)
-                               /* Run the commands which initialize the PHY */
-                               {
-                                       tempval =
-                                           (u32) mii_info->mdio_read(ugeth->
-                                               dev, mii_info->mii_id, 0x1b);
-                                       tempval |= 0x000f;
-                                       mii_info->mdio_write(ugeth->dev,
-                                               mii_info->mii_id, 0x1b,
-                                               (u16) tempval);
-                                       tempval =
-                                           (u32) mii_info->mdio_read(ugeth->
-                                               dev, mii_info->mii_id,
-                                               MII_BMCR);
-                                       mii_info->mdio_write(ugeth->dev,
-                                               mii_info->mii_id, MII_BMCR,
-                                               (u16) (tempval | BMCR_RESET));
-                               } else if (ugeth->ug_info->enet_interface ==
-                                          ENET_1000_RGMII)
-                               /* Run the commands which initialize the PHY */
-                               {
-                                       tempval =
-                                           (u32) mii_info->mdio_read(ugeth->
-                                               dev, mii_info->mii_id, 0x1b);
-                                       tempval = (tempval & ~0x000f) | 0x000b;
-                                       mii_info->mdio_write(ugeth->dev,
-                                               mii_info->mii_id, 0x1b,
-                                               (u16) tempval);
-                                       tempval =
-                                           (u32) mii_info->mdio_read(ugeth->
-                                               dev, mii_info->mii_id,
-                                               MII_BMCR);
-                                       mii_info->mdio_write(ugeth->dev,
-                                               mii_info->mii_id, MII_BMCR,
-                                               (u16) (tempval | BMCR_RESET));
-                               }
-                               msleep(4000);
-#endif                         /* CONFIG_MPC8360 */
-                               adjust_enet_interface(ugeth);
+                               ugeth->ug_info->enet_interface = ENET_1000_RGMII;
                                break;
                        case 100:
-                       case 10:
-#ifdef CONFIG_PPC_MPC836x
-/* FIXME: This code is for 100Mbs BUG fixing,
-remove this lines when it will be fixed!!! */
                                ugeth->ug_info->enet_interface = ENET_100_RGMII;
-                               tempval =
-                                   (u32) mii_info->mdio_read(ugeth->dev,
-                                                             mii_info->mii_id,
-                                                             0x1b);
-                               tempval = (tempval & ~0x000f) | 0x000b;
-                               mii_info->mdio_write(ugeth->dev,
-                                                    mii_info->mii_id, 0x1b,
-                                                    (u16) tempval);
-                               tempval =
-                                   (u32) mii_info->mdio_read(ugeth->dev,
-                                                             mii_info->mii_id,
-                                                             MII_BMCR);
-                               mii_info->mdio_write(ugeth->dev,
-                                                    mii_info->mii_id, MII_BMCR,
-                                                    (u16) (tempval |
-                                                           BMCR_RESET));
-                               msleep(4000);
-#endif                         /* CONFIG_MPC8360 */
-                               adjust_enet_interface(ugeth);
+                               break;
+                       case 10:
+                               ugeth->ug_info->enet_interface = ENET_10_RGMII;
                                break;
                        default:
                                ugeth_warn
@@ -1785,6 +1723,7 @@ remove this lines when it will be fixed!!! */
                                     dev->name, mii_info->speed);
                                break;
                        }
+                       adjust_enet_interface(ugeth);
 
                        ugeth_info("%s: Speed %dBT", dev->name,
                                   mii_info->speed);
@@ -4133,6 +4072,7 @@ static int ucc_geth_probe(struct of_device* ofdev, const struct of_device_id *ma
        static int mii_mng_configured = 0;
        const phandle *ph;
        const unsigned int *prop;
+       const void *mac_addr;
 
        ugeth_vdbg("%s: IN", __FUNCTION__);
 
@@ -4258,7 +4198,12 @@ static int ucc_geth_probe(struct of_device* ofdev, const struct of_device_id *ma
 
        ugeth->ug_info = ug_info;
        ugeth->dev = dev;
-       memcpy(dev->dev_addr, get_property(np, "mac-address", NULL), 6);
+
+       mac_addr = get_property(np, "mac-address", NULL);
+       if (mac_addr == NULL)
+               mac_addr = get_property(np, "local-mac-address", NULL);
+       if (mac_addr)
+               memcpy(dev->dev_addr, mac_addr, 6);
 
        return 0;
 }
index 3c86592ce03c0d18b8eb6953bbfc7a17981147e9..6fda6d88be499d1ce0e79ccc98eb0818f8f713dd 100644 (file)
@@ -376,6 +376,8 @@ static int marvell_init(struct ugeth_mii_info *mii_info)
        ugphy_vdbg("%s: IN", __FUNCTION__);
 
        ucc_geth_phy_write(mii_info, 0x14, 0x0cd2);
+       ucc_geth_phy_write(mii_info, 0x1b,
+               (ucc_geth_phy_read(mii_info, 0x1b) & ~0x000f) | 0x000b);
        ucc_geth_phy_write(mii_info, MII_BMCR,
                  ucc_geth_phy_read(mii_info, MII_BMCR) | BMCR_RESET);
        msleep(4000);
index 79b2d5454d6b3f8e163a60f019331e459dd608ce..bc156b51678ac18bf3225d3b817ac773793f689d 100644 (file)
@@ -101,8 +101,8 @@ typedef struct port_s {
 typedef struct card_s {
        int type;               /* RSV, X21, etc. */
        int n_ports;            /* 1 or 2 ports */
-       u8* __iomem rambase;    /* buffer memory base (virtual) */
-       u8* __iomem scabase;    /* SCA memory base (virtual) */
+       u8 __iomem *rambase;    /* buffer memory base (virtual) */
+       u8 __iomem *scabase;    /* SCA memory base (virtual) */
        plx9050 __iomem *plxbase; /* PLX registers memory base (virtual) */
        u32 init_ctrl_value;    /* Saved value - 9050 bug workaround */
        u16 rx_ring_buffers;    /* number of buffers in a ring */
@@ -134,7 +134,7 @@ typedef struct card_s {
 static void pc300_set_iface(port_t *port)
 {
        card_t *card = port->card;
-       u32* init_ctrl = &card->plxbase->init_ctrl;
+       u32 __iomem * init_ctrl = &card->plxbase->init_ctrl;
        u16 msci = get_msci(port);
        u8 rxs = port->rxs & CLK_BRG_MASK;
        u8 txs = port->txs & CLK_BRG_MASK;
@@ -393,7 +393,7 @@ static int __devinit pc300_pci_init_one(struct pci_dev *pdev,
 
        /* PLX PCI 9050 workaround for local configuration register read bug */
        pci_write_config_dword(pdev, PCI_BASE_ADDRESS_0, scaphys);
-       card->init_ctrl_value = readl(&((plx9050*)card->scabase)->init_ctrl);
+       card->init_ctrl_value = readl(&((plx9050 __iomem *)card->scabase)->init_ctrl);
        pci_write_config_dword(pdev, PCI_BASE_ADDRESS_0, plxphys);
 
        /* Reset PLX */
@@ -519,10 +519,10 @@ static struct pci_device_id pc300_pci_tbl[] __devinitdata = {
 
 
 static struct pci_driver pc300_pci_driver = {
-       name:           "PC300",
-       id_table:       pc300_pci_tbl,
-       probe:          pc300_pci_init_one,
-       remove:         pc300_pci_remove_one,
+       .name =          "PC300",
+       .id_table =      pc300_pci_tbl,
+       .probe =         pc300_pci_init_one,
+       .remove =        pc300_pci_remove_one,
 };
 
 
index 7f38012b9c92e2ddb094f3c53240c90850744563..a0326818ff2f815853f29871bb3b735750995e6a 100644 (file)
@@ -433,7 +433,7 @@ wd_block_input(struct net_device *dev, int count, struct sk_buff *skb, int ring_
                memcpy_fromio(skb->data + semi_count, ei_status.mem + TX_PAGES * 256, count);
        } else {
                /* Packet is in one chunk -- we can copy + cksum. */
-               eth_io_copy_and_sum(skb, xfer_start, count, 0);
+               memcpy_fromio(skb->data, xfer_start, count);
        }
 
        /* Turn off 16 bit access so that reboot works.  ISA brain-damage */
index 8dac2ba82bb95ee748d6b69d5f56e02f4b30e329..9a731c101d102ed11305372a6416b9b92ac3d76c 100644 (file)
@@ -252,7 +252,6 @@ static int __init led_create_procfs(void)
        proc_pdc_root->owner = THIS_MODULE;
        ent = create_proc_entry("led", S_IFREG|S_IRUGO|S_IWUSR, proc_pdc_root);
        if (!ent) return -1;
-       ent->nlink = 1;
        ent->data = (void *)LED_NOLCD; /* LED */
        ent->read_proc = led_proc_read;
        ent->write_proc = led_proc_write;
@@ -262,7 +261,6 @@ static int __init led_create_procfs(void)
        {
                ent = create_proc_entry("lcd", S_IFREG|S_IRUGO|S_IWUSR, proc_pdc_root);
                if (!ent) return -1;
-               ent->nlink = 1;
                ent->data = (void *)LED_HASLCD; /* LCD */
                ent->read_proc = led_proc_read;
                ent->write_proc = led_proc_write;
index 3cfb0a3575e660938abc6070c9048563ddd7c287..5ea5bc70cb8215cf078bd38fe77ba82f34e80554 100644 (file)
@@ -4,7 +4,7 @@
 config PCI_MSI
        bool "Message Signaled Interrupts (MSI and MSI-X)"
        depends on PCI
-       depends on (X86_LOCAL_APIC && X86_IO_APIC) || IA64
+       depends on (X86_LOCAL_APIC && X86_IO_APIC) || IA64 || SPARC64
        help
           This allows device drivers to enable MSI (Message Signaled
           Interrupts).  Message Signaled Interrupts enable a device to
index 84c757ba06644e618a1d925c8d4e99007ef40cbe..8b44cff2c1767f3bef0287eb394b68c9988b9d60 100644 (file)
@@ -744,6 +744,104 @@ int pci_enable_device(struct pci_dev *dev)
        return pci_enable_device_bars(dev, (1 << PCI_NUM_RESOURCES) - 1);
 }
 
+/*
+ * Managed PCI resources.  This manages device on/off, intx/msi/msix
+ * on/off and BAR regions.  pci_dev itself records msi/msix status, so
+ * there's no need to track it separately.  pci_devres is initialized
+ * when a device is enabled using managed PCI device enable interface.
+ */
+struct pci_devres {
+       unsigned int disable:1;
+       unsigned int orig_intx:1;
+       unsigned int restore_intx:1;
+       u32 region_mask;
+};
+
+static void pcim_release(struct device *gendev, void *res)
+{
+       struct pci_dev *dev = container_of(gendev, struct pci_dev, dev);
+       struct pci_devres *this = res;
+       int i;
+
+       if (dev->msi_enabled)
+               pci_disable_msi(dev);
+       if (dev->msix_enabled)
+               pci_disable_msix(dev);
+
+       for (i = 0; i < DEVICE_COUNT_RESOURCE; i++)
+               if (this->region_mask & (1 << i))
+                       pci_release_region(dev, i);
+
+       if (this->restore_intx)
+               pci_intx(dev, this->orig_intx);
+
+       if (this->disable)
+               pci_disable_device(dev);
+}
+
+static struct pci_devres * get_pci_dr(struct pci_dev *pdev)
+{
+       struct pci_devres *dr, *new_dr;
+
+       dr = devres_find(&pdev->dev, pcim_release, NULL, NULL);
+       if (dr)
+               return dr;
+
+       new_dr = devres_alloc(pcim_release, sizeof(*new_dr), GFP_KERNEL);
+       if (!new_dr)
+               return NULL;
+       return devres_get(&pdev->dev, new_dr, NULL, NULL);
+}
+
+static struct pci_devres * find_pci_dr(struct pci_dev *pdev)
+{
+       if (pci_is_managed(pdev))
+               return devres_find(&pdev->dev, pcim_release, NULL, NULL);
+       return NULL;
+}
+
+/**
+ * pcim_enable_device - Managed pci_enable_device()
+ * @pdev: PCI device to be initialized
+ *
+ * Managed pci_enable_device().
+ */
+int pcim_enable_device(struct pci_dev *pdev)
+{
+       struct pci_devres *dr;
+       int rc;
+
+       dr = get_pci_dr(pdev);
+       if (unlikely(!dr))
+               return -ENOMEM;
+       WARN_ON(!!dr->disable);
+
+       rc = pci_enable_device(pdev);
+       if (!rc) {
+               pdev->is_managed = 1;
+               dr->disable = 1;
+       }
+       return rc;
+}
+
+/**
+ * pcim_pin_device - Pin managed PCI device
+ * @pdev: PCI device to pin
+ *
+ * Pin managed PCI device @pdev.  Pinned device won't be disabled on
+ * driver detach.  @pdev must have been enabled with
+ * pcim_enable_device().
+ */
+void pcim_pin_device(struct pci_dev *pdev)
+{
+       struct pci_devres *dr;
+
+       dr = find_pci_dr(pdev);
+       WARN_ON(!dr || !dr->disable);
+       if (dr)
+               dr->disable = 0;
+}
+
 /**
  * pcibios_disable_device - disable arch specific PCI resources for device dev
  * @dev: the PCI device to disable
@@ -767,8 +865,13 @@ void __attribute__ ((weak)) pcibios_disable_device (struct pci_dev *dev) {}
 void
 pci_disable_device(struct pci_dev *dev)
 {
+       struct pci_devres *dr;
        u16 pci_command;
 
+       dr = find_pci_dr(dev);
+       if (dr)
+               dr->disable = 0;
+
        if (atomic_sub_return(1, &dev->enable_cnt) != 0)
                return;
 
@@ -867,6 +970,8 @@ pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge)
  */
 void pci_release_region(struct pci_dev *pdev, int bar)
 {
+       struct pci_devres *dr;
+
        if (pci_resource_len(pdev, bar) == 0)
                return;
        if (pci_resource_flags(pdev, bar) & IORESOURCE_IO)
@@ -875,6 +980,10 @@ void pci_release_region(struct pci_dev *pdev, int bar)
        else if (pci_resource_flags(pdev, bar) & IORESOURCE_MEM)
                release_mem_region(pci_resource_start(pdev, bar),
                                pci_resource_len(pdev, bar));
+
+       dr = find_pci_dr(pdev);
+       if (dr)
+               dr->region_mask &= ~(1 << bar);
 }
 
 /**
@@ -893,6 +1002,8 @@ void pci_release_region(struct pci_dev *pdev, int bar)
  */
 int pci_request_region(struct pci_dev *pdev, int bar, const char *res_name)
 {
+       struct pci_devres *dr;
+
        if (pci_resource_len(pdev, bar) == 0)
                return 0;
                
@@ -906,7 +1017,11 @@ int pci_request_region(struct pci_dev *pdev, int bar, const char *res_name)
                                        pci_resource_len(pdev, bar), res_name))
                        goto err_out;
        }
-       
+
+       dr = find_pci_dr(pdev);
+       if (dr)
+               dr->region_mask |= 1 << bar;
+
        return 0;
 
 err_out:
@@ -1144,7 +1259,15 @@ pci_intx(struct pci_dev *pdev, int enable)
        }
 
        if (new != pci_command) {
+               struct pci_devres *dr;
+
                pci_write_config_word(pdev, PCI_COMMAND, new);
+
+               dr = find_pci_dr(pdev);
+               if (dr && !dr->restore_intx) {
+                       dr->restore_intx = 1;
+                       dr->orig_intx = !enable;
+               }
        }
 }
 
@@ -1226,6 +1349,8 @@ device_initcall(pci_init);
 EXPORT_SYMBOL_GPL(pci_restore_bars);
 EXPORT_SYMBOL(pci_enable_device_bars);
 EXPORT_SYMBOL(pci_enable_device);
+EXPORT_SYMBOL(pcim_enable_device);
+EXPORT_SYMBOL(pcim_pin_device);
 EXPORT_SYMBOL(pci_disable_device);
 EXPORT_SYMBOL(pci_find_capability);
 EXPORT_SYMBOL(pci_bus_find_capability);
index 11217bda4b9ef1c98003bd50f16d92a90c42db39..1e6eda25c0d82c800cf260a832209ee70899d9b7 100644 (file)
@@ -871,7 +871,7 @@ static void __devinit quirk_sb600_sata(struct pci_dev *pdev)
                pci_write_config_byte(pdev, 0xa, 6);
                pci_write_config_byte(pdev, 0x40, tmp);
 
-               pdev->class = 0x010601;
+               pdev->class = PCI_CLASS_STORAGE_SATA_AHCI;
        }
 }
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP600_SATA, quirk_sb600_sata);
index bbf025874d0c358cda4a2d6033b0876db3b2f1d5..4dbef07623764f421e2a01d7713d650b4df42aef 100644 (file)
@@ -722,7 +722,7 @@ static int __init init_m32r_pcc(void)
        /* Set up interrupt handler(s) */
 
        for (i = 0 ; i < pcc_sockets ; i++) {
-               socket[i].socket.dev.dev = &pcc_device.dev;
+               socket[i].socket.dev.parent = &pcc_device.dev;
                socket[i].socket.ops = &pcc_operations;
                socket[i].socket.resource_ops = &pccard_static_ops;
                socket[i].socket.owner = THIS_MODULE;
index 6b8c4cfd02a697a5f8e8f6dc68ab4ae7ed890b0d..31a633f6554769c46cd5676d13a758a104137738 100644 (file)
@@ -1,4 +1,3 @@
-extern struct bus_type pnp_bus_type;
 extern spinlock_t pnp_lock;
 void *pnp_alloc(long size);
 int pnp_interface_attach_device(struct pnp_dev *dev);
index 95b79685a9d1e1f72dbe6b36f68748c60c7bd034..3c2ab8394e3f987b71a555461e98c3c0b1a58e3e 100644 (file)
@@ -530,7 +530,6 @@ pnpbios_parse_compatible_ids(unsigned char *p, unsigned char *end, struct pnp_de
                        dev_id =  kzalloc(sizeof (struct pnp_id), GFP_KERNEL);
                        if (!dev_id)
                                return NULL;
-                       memset(dev_id, 0, sizeof(struct pnp_id));
                        pnpid32_to_pnpid(p[1] | p[2] << 8 | p[3] << 16 | p[4] << 24,id);
                        memcpy(&dev_id->id, id, 7);
                        pnp_add_id(dev_id, dev);
index 7bf7b2c88245358e023b1ddc8d97a19999b1a047..f935c1f71a583db4dff6d14937e972096717f0b7 100644 (file)
@@ -326,14 +326,17 @@ static struct rio_dev *rio_setup_device(struct rio_net *net,
        rio_mport_read_config_32(port, destid, hopcount, RIO_DST_OPS_CAR,
                                 &rdev->dst_ops);
 
-       if (rio_device_has_destid(port, rdev->src_ops, rdev->dst_ops)
-           && do_enum) {
-               rio_set_device_id(port, destid, hopcount, next_destid);
-               rdev->destid = next_destid++;
-               if (next_destid == port->host_deviceid)
-                       next_destid++;
+       if (rio_device_has_destid(port, rdev->src_ops, rdev->dst_ops)) {
+               if (do_enum) {
+                       rio_set_device_id(port, destid, hopcount, next_destid);
+                       rdev->destid = next_destid++;
+                       if (next_destid == port->host_deviceid)
+                               next_destid++;
+               } else
+                       rdev->destid = rio_get_device_id(port, destid, hopcount);
        } else
-               rdev->destid = rio_get_device_id(port, destid, hopcount);
+               /* Switch device has an associated destID */
+               rdev->destid = RIO_INVALID_DESTID;
 
        /* If a PE has both switch and other functions, show it as a switch */
        if (rio_is_switch(rdev)) {
@@ -347,7 +350,7 @@ static struct rio_dev *rio_setup_device(struct rio_net *net,
                }
                rswitch->switchid = next_switchid;
                rswitch->hopcount = hopcount;
-               rswitch->destid = 0xffff;
+               rswitch->destid = destid;
                /* Initialize switch route table */
                for (rdid = 0; rdid < RIO_MAX_ROUTE_ENTRIES; rdid++)
                        rswitch->route_table[rdid] = RIO_INVALID_ROUTE;
@@ -422,7 +425,7 @@ rio_sport_is_active(struct rio_mport *port, u16 destid, u8 hopcount, int sport)
 /**
  * rio_route_add_entry- Add a route entry to a switch routing table
  * @mport: Master port to send transaction
- * @rdev: Switch device
+ * @rswitch: Switch device
  * @table: Routing table ID
  * @route_destid: Destination ID to be routed
  * @route_port: Port number to be routed
@@ -434,18 +437,18 @@ rio_sport_is_active(struct rio_mport *port, u16 destid, u8 hopcount, int sport)
  * %RIO_GLOBAL_TABLE in @table. Returns %0 on success or %-EINVAL
  * on failure.
  */
-static int rio_route_add_entry(struct rio_mport *mport, struct rio_dev *rdev,
+static int rio_route_add_entry(struct rio_mport *mport, struct rio_switch *rswitch,
                               u16 table, u16 route_destid, u8 route_port)
 {
-       return rdev->rswitch->add_entry(mport, rdev->rswitch->destid,
-                                       rdev->rswitch->hopcount, table,
+       return rswitch->add_entry(mport, rswitch->destid,
+                                       rswitch->hopcount, table,
                                        route_destid, route_port);
 }
 
 /**
  * rio_route_get_entry- Read a route entry in a switch routing table
  * @mport: Master port to send transaction
- * @rdev: Switch device
+ * @rswitch: Switch device
  * @table: Routing table ID
  * @route_destid: Destination ID to be routed
  * @route_port: Pointer to read port number into
@@ -458,11 +461,11 @@ static int rio_route_add_entry(struct rio_mport *mport, struct rio_dev *rdev,
  * on failure.
  */
 static int
-rio_route_get_entry(struct rio_mport *mport, struct rio_dev *rdev, u16 table,
+rio_route_get_entry(struct rio_mport *mport, struct rio_switch *rswitch, u16 table,
                    u16 route_destid, u8 * route_port)
 {
-       return rdev->rswitch->get_entry(mport, rdev->rswitch->destid,
-                                       rdev->rswitch->hopcount, table,
+       return rswitch->get_entry(mport, rswitch->destid,
+                                       rswitch->hopcount, table,
                                        route_destid, route_port);
 }
 
@@ -552,6 +555,8 @@ static int rio_enum_peer(struct rio_net *net, struct rio_mport *port,
        int port_num;
        int num_ports;
        int cur_destid;
+       int sw_destid;
+       int sw_inport;
        struct rio_dev *rdev;
        u16 destid;
        int tmp;
@@ -594,15 +599,17 @@ static int rio_enum_peer(struct rio_net *net, struct rio_mport *port,
 
        if (rio_is_switch(rdev)) {
                next_switchid++;
+               sw_inport = rio_get_swpinfo_inport(port, RIO_ANY_DESTID, hopcount);
+               rio_route_add_entry(port, rdev->rswitch, RIO_GLOBAL_TABLE,
+                                   port->host_deviceid, sw_inport);
+               rdev->rswitch->route_table[port->host_deviceid] = sw_inport;
 
                for (destid = 0; destid < next_destid; destid++) {
-                       rio_route_add_entry(port, rdev, RIO_GLOBAL_TABLE,
-                                           destid, rio_get_swpinfo_inport(port,
-                                                                          RIO_ANY_DESTID,
-                                                                          hopcount));
-                       rdev->rswitch->route_table[destid] =
-                           rio_get_swpinfo_inport(port, RIO_ANY_DESTID,
-                                                  hopcount);
+                       if (destid == port->host_deviceid)
+                               continue;
+                       rio_route_add_entry(port, rdev->rswitch, RIO_GLOBAL_TABLE,
+                                           destid, sw_inport);
+                       rdev->rswitch->route_table[destid] = sw_inport;
                }
 
                num_ports =
@@ -610,9 +617,9 @@ static int rio_enum_peer(struct rio_net *net, struct rio_mport *port,
                pr_debug(
                    "RIO: found %s (vid %4.4x did %4.4x) with %d ports\n",
                    rio_name(rdev), rdev->vid, rdev->did, num_ports);
+               sw_destid = next_destid;
                for (port_num = 0; port_num < num_ports; port_num++) {
-                       if (rio_get_swpinfo_inport
-                           (port, RIO_ANY_DESTID, hopcount) == port_num)
+                       if (sw_inport == port_num)
                                continue;
 
                        cur_destid = next_destid;
@@ -622,7 +629,7 @@ static int rio_enum_peer(struct rio_net *net, struct rio_mport *port,
                                pr_debug(
                                    "RIO: scanning device on port %d\n",
                                    port_num);
-                               rio_route_add_entry(port, rdev,
+                               rio_route_add_entry(port, rdev->rswitch,
                                                    RIO_GLOBAL_TABLE,
                                                    RIO_ANY_DESTID, port_num);
 
@@ -633,7 +640,9 @@ static int rio_enum_peer(struct rio_net *net, struct rio_mport *port,
                                if (next_destid > cur_destid) {
                                        for (destid = cur_destid;
                                             destid < next_destid; destid++) {
-                                               rio_route_add_entry(port, rdev,
+                                               if (destid == port->host_deviceid)
+                                                       continue;
+                                               rio_route_add_entry(port, rdev->rswitch,
                                                                    RIO_GLOBAL_TABLE,
                                                                    destid,
                                                                    port_num);
@@ -641,10 +650,18 @@ static int rio_enum_peer(struct rio_net *net, struct rio_mport *port,
                                                    route_table[destid] =
                                                    port_num;
                                        }
-                                       rdev->rswitch->destid = cur_destid;
                                }
                        }
                }
+
+               /* Check for empty switch */
+               if (next_destid == sw_destid) {
+                       next_destid++;
+                       if (next_destid == port->host_deviceid)
+                               next_destid++;
+               }
+
+               rdev->rswitch->destid = sw_destid;
        } else
                pr_debug("RIO: found %s (vid %4.4x did %4.4x)\n",
                    rio_name(rdev), rdev->vid, rdev->did);
@@ -721,7 +738,7 @@ rio_disc_peer(struct rio_net *net, struct rio_mport *port, u16 destid,
                                    port_num);
                                for (ndestid = 0; ndestid < RIO_ANY_DESTID;
                                     ndestid++) {
-                                       rio_route_get_entry(port, rdev,
+                                       rio_route_get_entry(port, rdev->rswitch,
                                                            RIO_GLOBAL_TABLE,
                                                            ndestid,
                                                            &route_port);
@@ -797,6 +814,44 @@ static struct rio_net __devinit *rio_alloc_net(struct rio_mport *port)
        return net;
 }
 
+/**
+ * rio_update_route_tables- Updates route tables in switches
+ * @port: Master port associated with the RIO network
+ *
+ * For each enumerated device, ensure that each switch in a system
+ * has correct routing entries. Add routes for devices that where
+ * unknown dirung the first enumeration pass through the switch.
+ */
+static void rio_update_route_tables(struct rio_mport *port)
+{
+       struct rio_dev *rdev;
+       struct rio_switch *rswitch;
+       u8 sport;
+       u16 destid;
+
+       list_for_each_entry(rdev, &rio_devices, global_list) {
+
+               destid = (rio_is_switch(rdev))?rdev->rswitch->destid:rdev->destid;
+
+               list_for_each_entry(rswitch, &rio_switches, node) {
+
+                       if (rio_is_switch(rdev) && (rdev->rswitch == rswitch))
+                               continue;
+
+                       if (RIO_INVALID_ROUTE == rswitch->route_table[destid]) {
+
+                               sport = rio_get_swpinfo_inport(port,
+                                               rswitch->destid, rswitch->hopcount);
+
+                               if (rswitch->add_entry) {
+                                       rio_route_add_entry(port, rswitch, RIO_GLOBAL_TABLE, destid, sport);
+                                       rswitch->route_table[destid] = sport;
+                               }
+                       }
+               }
+       }
+}
+
 /**
  * rio_enum_mport- Start enumeration through a master port
  * @mport: Master port to send transactions
@@ -838,6 +893,7 @@ int rio_enum_mport(struct rio_mport *mport)
                        rc = -EBUSY;
                        goto out;
                }
+               rio_update_route_tables(mport);
                rio_clear_locks(mport);
        } else {
                printk(KERN_INFO "RIO: master port %d link inactive\n",
@@ -865,8 +921,8 @@ static void rio_build_route_tables(void)
            if (rio_is_switch(rdev))
                for (i = 0; i < RIO_MAX_ROUTE_ENTRIES; i++) {
                        if (rio_route_get_entry
-                           (rdev->net->hport, rdev, RIO_GLOBAL_TABLE, i,
-                            &sport) < 0)
+                           (rdev->net->hport, rdev->rswitch, RIO_GLOBAL_TABLE,
+                            i, &sport) < 0)
                                continue;
                        rdev->rswitch->route_table[i] = sport;
                }
index 09660e2ab051d6d9e9a313686fc894ca4cbfe6e3..4bbca500d3d212bf264ddff889da7c05b258b5f5 100644 (file)
@@ -1,4 +1,4 @@
-\#
+#
 # RTC class/drivers configuration
 #
 
@@ -95,6 +95,29 @@ config RTC_INTF_DEV_UIE_EMUL
 comment "RTC drivers"
        depends on RTC_CLASS
 
+# this 'CMOS' RTC driver is arch dependent because <asm-generic/rtc.h>
+# requires <asm/mc146818rtc.h> defining CMOS_READ/CMOS_WRITE, and a
+# global rtc_lock ... it's not yet just another platform_device.
+
+config RTC_DRV_CMOS
+       tristate "PC-style 'CMOS' real time clock"
+       depends on RTC_CLASS && (X86_PC || ALPHA || ARM26 || ARM \
+               || M32R || ATARI || POWERPC)
+       help
+         Say "yes" here to get direct support for the real time clock
+         found in every PC or ACPI-based system, and some other boards.
+         Specifically the original MC146818, compatibles like those in
+         PC south bridges, the DS12887 or M48T86, some multifunction
+         or LPC bus chips, and so on.
+
+         Your system will need to define the platform device used by
+         this driver, otherwise it won't be accessible.  This means
+         you can safely enable this driver if you don't know whether
+         or not your board has this kind of hardware.
+
+         This driver can also be built as a module. If so, the module
+         will be called rtc-cmos.
+
 config RTC_DRV_X1205
        tristate "Xicor/Intersil X1205"
        depends on RTC_CLASS && I2C
index e6beedacc96614ad329b82a9167d2e7b989e5de2..92bfe1b3a5faccb4122a7823cbf3720dc0d897eb 100644 (file)
@@ -15,6 +15,7 @@ obj-$(CONFIG_RTC_INTF_SYSFS)  += rtc-sysfs.o
 obj-$(CONFIG_RTC_INTF_PROC)    += rtc-proc.o
 obj-$(CONFIG_RTC_INTF_DEV)     += rtc-dev.o
 
+obj-$(CONFIG_RTC_DRV_CMOS)     += rtc-cmos.o
 obj-$(CONFIG_RTC_DRV_X1205)    += rtc-x1205.o
 obj-$(CONFIG_RTC_DRV_ISL1208)  += rtc-isl1208.o
 obj-$(CONFIG_RTC_DRV_TEST)     += rtc-test.o
diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
new file mode 100644 (file)
index 0000000..85bf795
--- /dev/null
@@ -0,0 +1,725 @@
+/*
+ * RTC class driver for "CMOS RTC":  PCs, ACPI, etc
+ *
+ * Copyright (C) 1996 Paul Gortmaker (drivers/char/rtc.c)
+ * Copyright (C) 2006 David Brownell (convert to new framework)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+/*
+ * The original "cmos clock" chip was an MC146818 chip, now obsolete.
+ * That defined the register interface now provided by all PCs, some
+ * non-PC systems, and incorporated into ACPI.  Modern PC chipsets
+ * integrate an MC146818 clone in their southbridge, and boards use
+ * that instead of discrete clones like the DS12887 or M48T86.  There
+ * are also clones that connect using the LPC bus.
+ *
+ * That register API is also used directly by various other drivers
+ * (notably for integrated NVRAM), infrastructure (x86 has code to
+ * bypass the RTC framework, directly reading the RTC during boot
+ * and updating minutes/seconds for systems using NTP synch) and
+ * utilities (like userspace 'hwclock', if no /dev node exists).
+ *
+ * So **ALL** calls to CMOS_READ and CMOS_WRITE must be done with
+ * interrupts disabled, holding the global rtc_lock, to exclude those
+ * other drivers and utilities on correctly configured systems.
+ */
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/spinlock.h>
+#include <linux/platform_device.h>
+#include <linux/mod_devicetable.h>
+
+/* this is for "generic access to PC-style RTC" using CMOS_READ/CMOS_WRITE */
+#include <asm-generic/rtc.h>
+
+
+struct cmos_rtc {
+       struct rtc_device       *rtc;
+       struct device           *dev;
+       int                     irq;
+       struct resource         *iomem;
+
+       u8                      suspend_ctrl;
+
+       /* newer hardware extends the original register set */
+       u8                      day_alrm;
+       u8                      mon_alrm;
+       u8                      century;
+};
+
+/* both platform and pnp busses use negative numbers for invalid irqs */
+#define is_valid_irq(n)                ((n) >= 0)
+
+static const char driver_name[] = "rtc_cmos";
+
+/*----------------------------------------------------------------*/
+
+static int cmos_read_time(struct device *dev, struct rtc_time *t)
+{
+       /* REVISIT:  if the clock has a "century" register, use
+        * that instead of the heuristic in get_rtc_time().
+        * That'll make Y3K compatility (year > 2070) easy!
+        */
+       get_rtc_time(t);
+       return 0;
+}
+
+static int cmos_set_time(struct device *dev, struct rtc_time *t)
+{
+       /* REVISIT:  set the "century" register if available
+        *
+        * NOTE: this ignores the issue whereby updating the seconds
+        * takes effect exactly 500ms after we write the register.
+        * (Also queueing and other delays before we get this far.)
+        */
+       return set_rtc_time(t);
+}
+
+static int cmos_read_alarm(struct device *dev, struct rtc_wkalrm *t)
+{
+       struct cmos_rtc *cmos = dev_get_drvdata(dev);
+       unsigned char   rtc_control;
+
+       if (!is_valid_irq(cmos->irq))
+               return -EIO;
+
+       /* Basic alarms only support hour, minute, and seconds fields.
+        * Some also support day and month, for alarms up to a year in
+        * the future.
+        */
+       t->time.tm_mday = -1;
+       t->time.tm_mon = -1;
+
+       spin_lock_irq(&rtc_lock);
+       t->time.tm_sec = CMOS_READ(RTC_SECONDS_ALARM);
+       t->time.tm_min = CMOS_READ(RTC_MINUTES_ALARM);
+       t->time.tm_hour = CMOS_READ(RTC_HOURS_ALARM);
+
+       if (cmos->day_alrm) {
+               t->time.tm_mday = CMOS_READ(cmos->day_alrm);
+               if (!t->time.tm_mday)
+                       t->time.tm_mday = -1;
+
+               if (cmos->mon_alrm) {
+                       t->time.tm_mon = CMOS_READ(cmos->mon_alrm);
+                       if (!t->time.tm_mon)
+                               t->time.tm_mon = -1;
+               }
+       }
+
+       rtc_control = CMOS_READ(RTC_CONTROL);
+       spin_unlock_irq(&rtc_lock);
+
+       /* REVISIT this assumes PC style usage:  always BCD */
+
+       if (((unsigned)t->time.tm_sec) < 0x60)
+               t->time.tm_sec = BCD2BIN(t->time.tm_sec);
+       else
+               t->time.tm_sec = -1;
+       if (((unsigned)t->time.tm_min) < 0x60)
+               t->time.tm_min = BCD2BIN(t->time.tm_min);
+       else
+               t->time.tm_min = -1;
+       if (((unsigned)t->time.tm_hour) < 0x24)
+               t->time.tm_hour = BCD2BIN(t->time.tm_hour);
+       else
+               t->time.tm_hour = -1;
+
+       if (cmos->day_alrm) {
+               if (((unsigned)t->time.tm_mday) <= 0x31)
+                       t->time.tm_mday = BCD2BIN(t->time.tm_mday);
+               else
+                       t->time.tm_mday = -1;
+               if (cmos->mon_alrm) {
+                       if (((unsigned)t->time.tm_mon) <= 0x12)
+                               t->time.tm_mon = BCD2BIN(t->time.tm_mon) - 1;
+                       else
+                               t->time.tm_mon = -1;
+               }
+       }
+       t->time.tm_year = -1;
+
+       t->enabled = !!(rtc_control & RTC_AIE);
+       t->pending = 0;
+
+       return 0;
+}
+
+static int cmos_set_alarm(struct device *dev, struct rtc_wkalrm *t)
+{
+       struct cmos_rtc *cmos = dev_get_drvdata(dev);
+       unsigned char   mon, mday, hrs, min, sec;
+       unsigned char   rtc_control, rtc_intr;
+
+       if (!is_valid_irq(cmos->irq))
+               return -EIO;
+
+       /* REVISIT this assumes PC style usage:  always BCD */
+
+       /* Writing 0xff means "don't care" or "match all".  */
+
+       mon = t->time.tm_mon;
+       mon = (mon < 12) ? BIN2BCD(mon) : 0xff;
+       mon++;
+
+       mday = t->time.tm_mday;
+       mday = (mday >= 1 && mday <= 31) ? BIN2BCD(mday) : 0xff;
+
+       hrs = t->time.tm_hour;
+       hrs = (hrs < 24) ? BIN2BCD(hrs) : 0xff;
+
+       min = t->time.tm_min;
+       min = (min < 60) ? BIN2BCD(min) : 0xff;
+
+       sec = t->time.tm_sec;
+       sec = (sec < 60) ? BIN2BCD(sec) : 0xff;
+
+       spin_lock_irq(&rtc_lock);
+
+       /* next rtc irq must not be from previous alarm setting */
+       rtc_control = CMOS_READ(RTC_CONTROL);
+       rtc_control &= ~RTC_AIE;
+       CMOS_WRITE(rtc_control, RTC_CONTROL);
+       rtc_intr = CMOS_READ(RTC_INTR_FLAGS);
+       if (rtc_intr)
+               rtc_update_irq(&cmos->rtc->class_dev, 1, rtc_intr);
+
+       /* update alarm */
+       CMOS_WRITE(hrs, RTC_HOURS_ALARM);
+       CMOS_WRITE(min, RTC_MINUTES_ALARM);
+       CMOS_WRITE(sec, RTC_SECONDS_ALARM);
+
+       /* the system may support an "enhanced" alarm */
+       if (cmos->day_alrm) {
+               CMOS_WRITE(mday, cmos->day_alrm);
+               if (cmos->mon_alrm)
+                       CMOS_WRITE(mon, cmos->mon_alrm);
+       }
+
+       if (t->enabled) {
+               rtc_control |= RTC_AIE;
+               CMOS_WRITE(rtc_control, RTC_CONTROL);
+               rtc_intr = CMOS_READ(RTC_INTR_FLAGS);
+               if (rtc_intr)
+                       rtc_update_irq(&cmos->rtc->class_dev, 1, rtc_intr);
+       }
+
+       spin_unlock_irq(&rtc_lock);
+
+       return 0;
+}
+
+static int cmos_set_freq(struct device *dev, int freq)
+{
+       struct cmos_rtc *cmos = dev_get_drvdata(dev);
+       int             f;
+       unsigned long   flags;
+
+       if (!is_valid_irq(cmos->irq))
+               return -ENXIO;
+
+       /* 0 = no irqs; 1 = 2^15 Hz ... 15 = 2^0 Hz */
+       f = ffs(freq);
+       if (f != 0) {
+               if (f-- > 16 || freq != (1 << f))
+                       return -EINVAL;
+               f = 16 - f;
+       }
+
+       spin_lock_irqsave(&rtc_lock, flags);
+       CMOS_WRITE(RTC_REF_CLCK_32KHZ | f, RTC_FREQ_SELECT);
+       spin_unlock_irqrestore(&rtc_lock, flags);
+
+       return 0;
+}
+
+#if defined(CONFIG_RTC_INTF_DEV) || defined(CONFIG_RTC_INTF_DEV_MODULE)
+
+static int
+cmos_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
+{
+       struct cmos_rtc *cmos = dev_get_drvdata(dev);
+       unsigned char   rtc_control, rtc_intr;
+       unsigned long   flags;
+
+       switch (cmd) {
+       case RTC_AIE_OFF:
+       case RTC_AIE_ON:
+       case RTC_UIE_OFF:
+       case RTC_UIE_ON:
+       case RTC_PIE_OFF:
+       case RTC_PIE_ON:
+               if (!is_valid_irq(cmos->irq))
+                       return -EINVAL;
+               break;
+       default:
+               return -ENOIOCTLCMD;
+       }
+
+       spin_lock_irqsave(&rtc_lock, flags);
+       rtc_control = CMOS_READ(RTC_CONTROL);
+       switch (cmd) {
+       case RTC_AIE_OFF:       /* alarm off */
+               rtc_control &= ~RTC_AIE;
+               break;
+       case RTC_AIE_ON:        /* alarm on */
+               rtc_control |= RTC_AIE;
+               break;
+       case RTC_UIE_OFF:       /* update off */
+               rtc_control &= ~RTC_UIE;
+               break;
+       case RTC_UIE_ON:        /* update on */
+               rtc_control |= RTC_UIE;
+               break;
+       case RTC_PIE_OFF:       /* periodic off */
+               rtc_control &= ~RTC_PIE;
+               break;
+       case RTC_PIE_ON:        /* periodic on */
+               rtc_control |= RTC_PIE;
+               break;
+       }
+       CMOS_WRITE(rtc_control, RTC_CONTROL);
+       rtc_intr = CMOS_READ(RTC_INTR_FLAGS);
+       if (rtc_intr)
+               rtc_update_irq(&cmos->rtc->class_dev, 1, rtc_intr);
+       spin_unlock_irqrestore(&rtc_lock, flags);
+       return 0;
+}
+
+#else
+#define        cmos_rtc_ioctl  NULL
+#endif
+
+#if defined(CONFIG_RTC_INTF_PROC) || defined(CONFIG_RTC_INTF_PROC_MODULE)
+
+static int cmos_procfs(struct device *dev, struct seq_file *seq)
+{
+       struct cmos_rtc *cmos = dev_get_drvdata(dev);
+       unsigned char   rtc_control, valid;
+
+       spin_lock_irq(&rtc_lock);
+       rtc_control = CMOS_READ(RTC_CONTROL);
+       valid = CMOS_READ(RTC_VALID);
+       spin_unlock_irq(&rtc_lock);
+
+       /* NOTE:  at least ICH6 reports battery status using a different
+        * (non-RTC) bit; and SQWE is ignored on many current systems.
+        */
+       return seq_printf(seq,
+                       "periodic_IRQ\t: %s\n"
+                       "update_IRQ\t: %s\n"
+                       // "square_wave\t: %s\n"
+                       // "BCD\t\t: %s\n"
+                       "DST_enable\t: %s\n"
+                       "periodic_freq\t: %d\n"
+                       "batt_status\t: %s\n",
+                       (rtc_control & RTC_PIE) ? "yes" : "no",
+                       (rtc_control & RTC_UIE) ? "yes" : "no",
+                       // (rtc_control & RTC_SQWE) ? "yes" : "no",
+                       // (rtc_control & RTC_DM_BINARY) ? "no" : "yes",
+                       (rtc_control & RTC_DST_EN) ? "yes" : "no",
+                       cmos->rtc->irq_freq,
+                       (valid & RTC_VRT) ? "okay" : "dead");
+}
+
+#else
+#define        cmos_procfs     NULL
+#endif
+
+static const struct rtc_class_ops cmos_rtc_ops = {
+       .ioctl          = cmos_rtc_ioctl,
+       .read_time      = cmos_read_time,
+       .set_time       = cmos_set_time,
+       .read_alarm     = cmos_read_alarm,
+       .set_alarm      = cmos_set_alarm,
+       .proc           = cmos_procfs,
+       .irq_set_freq   = cmos_set_freq,
+};
+
+/*----------------------------------------------------------------*/
+
+static struct cmos_rtc cmos_rtc;
+
+static irqreturn_t cmos_interrupt(int irq, void *p)
+{
+       u8              irqstat;
+
+       spin_lock(&rtc_lock);
+       irqstat = CMOS_READ(RTC_INTR_FLAGS);
+       spin_unlock(&rtc_lock);
+
+       if (irqstat) {
+               /* NOTE: irqstat may have e.g. RTC_PF set
+                * even when RTC_PIE is clear...
+                */
+               rtc_update_irq(p, 1, irqstat);
+               return IRQ_HANDLED;
+       } else
+               return IRQ_NONE;
+}
+
+#ifdef CONFIG_PNPACPI
+#define        is_pnpacpi()    1
+#define        INITSECTION
+
+#else
+#define        is_pnpacpi()    0
+#define        INITSECTION     __init
+#endif
+
+static int INITSECTION
+cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
+{
+       struct cmos_rtc_board_info      *info = dev->platform_data;
+       int                             retval = 0;
+       unsigned char                   rtc_control;
+
+       /* there can be only one ... */
+       if (cmos_rtc.dev)
+               return -EBUSY;
+
+       if (!ports)
+               return -ENODEV;
+
+       cmos_rtc.irq = rtc_irq;
+       cmos_rtc.iomem = ports;
+
+       /* For ACPI systems the info comes from the FADT.  On others,
+        * board specific setup provides it as appropriate.
+        */
+       if (info) {
+               cmos_rtc.day_alrm = info->rtc_day_alarm;
+               cmos_rtc.mon_alrm = info->rtc_mon_alarm;
+               cmos_rtc.century = info->rtc_century;
+       }
+
+       cmos_rtc.rtc = rtc_device_register(driver_name, dev,
+                               &cmos_rtc_ops, THIS_MODULE);
+       if (IS_ERR(cmos_rtc.rtc))
+               return PTR_ERR(cmos_rtc.rtc);
+
+       cmos_rtc.dev = dev;
+       dev_set_drvdata(dev, &cmos_rtc);
+
+       /* platform and pnp busses handle resources incompatibly.
+        *
+        * REVISIT for non-x86 systems we may need to handle io memory
+        * resources: ioremap them, and request_mem_region().
+        */
+       if (is_pnpacpi()) {
+               retval = request_resource(&ioport_resource, ports);
+               if (retval < 0) {
+                       dev_dbg(dev, "i/o registers already in use\n");
+                       goto cleanup0;
+               }
+       }
+       rename_region(ports, cmos_rtc.rtc->class_dev.class_id);
+
+       spin_lock_irq(&rtc_lock);
+
+       /* force periodic irq to CMOS reset default of 1024Hz;
+        *
+        * REVISIT it's been reported that at least one x86_64 ALI mobo
+        * doesn't use 32KHz here ... for portability we might need to
+        * do something about other clock frequencies.
+        */
+       CMOS_WRITE(RTC_REF_CLCK_32KHZ | 0x06, RTC_FREQ_SELECT);
+       cmos_rtc.rtc->irq_freq = 1024;
+
+       /* disable irqs.
+        *
+        * NOTE after changing RTC_xIE bits we always read INTR_FLAGS;
+        * allegedly some older rtcs need that to handle irqs properly
+        */
+       rtc_control = CMOS_READ(RTC_CONTROL);
+       rtc_control &= ~(RTC_PIE | RTC_AIE | RTC_UIE);
+       CMOS_WRITE(rtc_control, RTC_CONTROL);
+       CMOS_READ(RTC_INTR_FLAGS);
+
+       spin_unlock_irq(&rtc_lock);
+
+       /* FIXME teach the alarm code how to handle binary mode;
+        * <asm-generic/rtc.h> doesn't know 12-hour mode either.
+        */
+       if (!(rtc_control & RTC_24H) || (rtc_control & (RTC_DM_BINARY))) {
+               dev_dbg(dev, "only 24-hr BCD mode supported\n");
+               retval = -ENXIO;
+               goto cleanup1;
+       }
+
+       if (is_valid_irq(rtc_irq))
+               retval = request_irq(rtc_irq, cmos_interrupt, IRQF_DISABLED,
+                               cmos_rtc.rtc->class_dev.class_id,
+                               &cmos_rtc.rtc->class_dev);
+       if (retval < 0) {
+               dev_dbg(dev, "IRQ %d is already in use\n", rtc_irq);
+               goto cleanup1;
+       }
+
+       /* REVISIT optionally make 50 or 114 bytes NVRAM available,
+        * like rtc-ds1553, rtc-ds1742 ... this will often include
+        * registers for century, and day/month alarm.
+        */
+
+       pr_info("%s: alarms up to one %s%s\n",
+                       cmos_rtc.rtc->class_dev.class_id,
+                       is_valid_irq(rtc_irq)
+                               ?  (cmos_rtc.mon_alrm
+                                       ? "year"
+                                       : (cmos_rtc.day_alrm
+                                               ? "month" : "day"))
+                               : "no",
+                       cmos_rtc.century ? ", y3k" : ""
+                       );
+
+       return 0;
+
+cleanup1:
+       rename_region(ports, NULL);
+cleanup0:
+       rtc_device_unregister(cmos_rtc.rtc);
+       return retval;
+}
+
+static void cmos_do_shutdown(void)
+{
+       unsigned char   rtc_control;
+
+       spin_lock_irq(&rtc_lock);
+       rtc_control = CMOS_READ(RTC_CONTROL);
+       rtc_control &= ~(RTC_PIE|RTC_AIE|RTC_UIE);
+       CMOS_WRITE(rtc_control, RTC_CONTROL);
+       CMOS_READ(RTC_INTR_FLAGS);
+       spin_unlock_irq(&rtc_lock);
+}
+
+static void __exit cmos_do_remove(struct device *dev)
+{
+       struct cmos_rtc *cmos = dev_get_drvdata(dev);
+
+       cmos_do_shutdown();
+
+       if (is_pnpacpi())
+               release_resource(cmos->iomem);
+       rename_region(cmos->iomem, NULL);
+
+       if (is_valid_irq(cmos->irq))
+               free_irq(cmos->irq, &cmos_rtc.rtc->class_dev);
+
+       rtc_device_unregister(cmos_rtc.rtc);
+
+       cmos_rtc.dev = NULL;
+       dev_set_drvdata(dev, NULL);
+}
+
+#ifdef CONFIG_PM
+
+static int cmos_suspend(struct device *dev, pm_message_t mesg)
+{
+       struct cmos_rtc *cmos = dev_get_drvdata(dev);
+       int             do_wake = device_may_wakeup(dev);
+       unsigned char   tmp, irqstat;
+
+       /* only the alarm might be a wakeup event source */
+       spin_lock_irq(&rtc_lock);
+       cmos->suspend_ctrl = tmp = CMOS_READ(RTC_CONTROL);
+       if (tmp & (RTC_PIE|RTC_AIE|RTC_UIE)) {
+               if (do_wake)
+                       tmp &= ~(RTC_PIE|RTC_UIE);
+               else
+                       tmp &= ~(RTC_PIE|RTC_AIE|RTC_UIE);
+               CMOS_WRITE(tmp, RTC_CONTROL);
+               irqstat = CMOS_READ(RTC_INTR_FLAGS);
+       } else
+               irqstat = 0;
+       spin_unlock_irq(&rtc_lock);
+
+       if (irqstat)
+               rtc_update_irq(&cmos->rtc->class_dev, 1, irqstat);
+
+       /* ACPI HOOK:  enable ACPI_EVENT_RTC when (tmp & RTC_AIE)
+        * ... it'd be best if we could do that under rtc_lock.
+        */
+
+       pr_debug("%s: suspend%s, ctrl %02x\n",
+                       cmos_rtc.rtc->class_dev.class_id,
+                       (tmp & RTC_AIE) ? ", alarm may wake" : "",
+                       tmp);
+
+       return 0;
+}
+
+static int cmos_resume(struct device *dev)
+{
+       struct cmos_rtc *cmos = dev_get_drvdata(dev);
+       unsigned char   tmp = cmos->suspend_ctrl;
+
+       /* REVISIT:  a mechanism to resync the system clock (jiffies)
+        * on resume should be portable between platforms ...
+        */
+
+       /* re-enable any irqs previously active */
+       if (tmp & (RTC_PIE|RTC_AIE|RTC_UIE)) {
+
+               /* ACPI HOOK:  disable ACPI_EVENT_RTC when (tmp & RTC_AIE) */
+
+               spin_lock_irq(&rtc_lock);
+               CMOS_WRITE(tmp, RTC_CONTROL);
+               tmp = CMOS_READ(RTC_INTR_FLAGS);
+               spin_unlock_irq(&rtc_lock);
+               if (tmp)
+                       rtc_update_irq(&cmos->rtc->class_dev, 1, tmp);
+       }
+
+       pr_debug("%s: resume, ctrl %02x\n",
+                       cmos_rtc.rtc->class_dev.class_id,
+                       cmos->suspend_ctrl);
+
+
+       return 0;
+}
+
+#else
+#define        cmos_suspend    NULL
+#define        cmos_resume     NULL
+#endif
+
+/*----------------------------------------------------------------*/
+
+/* The "CMOS" RTC normally lives on the platform_bus.  On ACPI systems,
+ * the device node may alternatively be created as a PNP device.
+ */
+
+#ifdef CONFIG_PNPACPI
+
+#include <linux/pnp.h>
+
+static int __devinit
+cmos_pnp_probe(struct pnp_dev *pnp, const struct pnp_device_id *id)
+{
+       /* REVISIT paranoia argues for a shutdown notifier, since PNP
+        * drivers can't provide shutdown() methods to disable IRQs.
+        * Or better yet, fix PNP to allow those methods...
+        */
+       return cmos_do_probe(&pnp->dev,
+                       &pnp->res.port_resource[0],
+                       pnp->res.irq_resource[0].start);
+}
+
+static void __exit cmos_pnp_remove(struct pnp_dev *pnp)
+{
+       cmos_do_remove(&pnp->dev);
+}
+
+#ifdef CONFIG_PM
+
+static int cmos_pnp_suspend(struct pnp_dev *pnp, pm_message_t mesg)
+{
+       return cmos_suspend(&pnp->dev, mesg);
+}
+
+static int cmos_pnp_resume(struct pnp_dev *pnp)
+{
+       return cmos_resume(&pnp->dev);
+}
+
+#else
+#define        cmos_pnp_suspend        NULL
+#define        cmos_pnp_resume         NULL
+#endif
+
+
+static const struct pnp_device_id rtc_ids[] = {
+       { .id = "PNP0b00", },
+       { .id = "PNP0b01", },
+       { .id = "PNP0b02", },
+       { },
+};
+MODULE_DEVICE_TABLE(pnp, rtc_ids);
+
+static struct pnp_driver cmos_pnp_driver = {
+       .name           = (char *) driver_name,
+       .id_table       = rtc_ids,
+       .probe          = cmos_pnp_probe,
+       .remove         = __exit_p(cmos_pnp_remove),
+
+       /* flag ensures resume() gets called, and stops syslog spam */
+       .flags          = PNP_DRIVER_RES_DO_NOT_CHANGE,
+       .suspend        = cmos_pnp_suspend,
+       .resume         = cmos_pnp_resume,
+};
+
+static int __init cmos_init(void)
+{
+       return pnp_register_driver(&cmos_pnp_driver);
+}
+module_init(cmos_init);
+
+static void __exit cmos_exit(void)
+{
+       pnp_unregister_driver(&cmos_pnp_driver);
+}
+module_exit(cmos_exit);
+
+#else  /* no PNPACPI */
+
+/*----------------------------------------------------------------*/
+
+/* Platform setup should have set up an RTC device, when PNPACPI is
+ * unavailable ... this is the normal case, common even on PCs.
+ */
+
+static int __init cmos_platform_probe(struct platform_device *pdev)
+{
+       return cmos_do_probe(&pdev->dev,
+                       platform_get_resource(pdev, IORESOURCE_IO, 0),
+                       platform_get_irq(pdev, 0));
+}
+
+static int __exit cmos_platform_remove(struct platform_device *pdev)
+{
+       cmos_do_remove(&pdev->dev);
+       return 0;
+}
+
+static void cmos_platform_shutdown(struct platform_device *pdev)
+{
+       cmos_do_shutdown();
+}
+
+static struct platform_driver cmos_platform_driver = {
+       .remove         = __exit_p(cmos_platform_remove),
+       .shutdown       = cmos_platform_shutdown,
+       .driver = {
+               .name           = (char *) driver_name,
+               .suspend        = cmos_suspend,
+               .resume         = cmos_resume,
+       }
+};
+
+static int __init cmos_init(void)
+{
+       return platform_driver_probe(&cmos_platform_driver,
+                       cmos_platform_probe);
+}
+module_init(cmos_init);
+
+static void __exit cmos_exit(void)
+{
+       platform_driver_unregister(&cmos_platform_driver);
+}
+module_exit(cmos_exit);
+
+
+#endif /* !PNPACPI */
+
+MODULE_AUTHOR("David Brownell");
+MODULE_DESCRIPTION("Driver for PC-style 'CMOS' RTCs");
+MODULE_LICENSE("GPL");
index 94d3df62a5fa85834d440839bba21f6c3054958b..82f2ac87ccd4722c8a4f9dbef562ddae1f6f6064 100644 (file)
@@ -305,7 +305,7 @@ static int rtc_dev_ioctl(struct inode *inode, struct file *file,
 
        case RTC_IRQP_READ:
                if (ops->irq_set_freq)
-                       err = put_user(rtc->irq_freq, (unsigned long *) arg);
+                       err = put_user(rtc->irq_freq, (unsigned long __user *)uarg);
                break;
 
        case RTC_IRQP_SET:
index 4b72b8ef5d66feee8e6ab70a9a0f635d80a35376..038118bbfaea3f512c756414a68e5f27818a1d9c 100644 (file)
@@ -53,6 +53,25 @@ I2C_CLIENT_INSMOD;
 #define PCF8563_SC_LV          0x80 /* low voltage */
 #define PCF8563_MO_C           0x80 /* century */
 
+struct pcf8563 {
+       struct i2c_client client;
+       /*
+        * The meaning of MO_C bit varies by the chip type.
+        * From PCF8563 datasheet: this bit is toggled when the years
+        * register overflows from 99 to 00
+        *   0 indicates the century is 20xx
+        *   1 indicates the century is 19xx
+        * From RTC8564 datasheet: this bit indicates change of
+        * century. When the year digit data overflows from 99 to 00,
+        * this bit is set. By presetting it to 0 while still in the
+        * 20th century, it will be set in year 2000, ...
+        * There seems no reliable way to know how the system use this
+        * bit.  So let's do it heuristically, assuming we are live in
+        * 1970...2069.
+        */
+       int c_polarity; /* 0: MO_C=1 means 19xx, otherwise MO_C=1 means 20xx */
+};
+
 static int pcf8563_probe(struct i2c_adapter *adapter, int address, int kind);
 static int pcf8563_detach(struct i2c_client *client);
 
@@ -62,6 +81,7 @@ static int pcf8563_detach(struct i2c_client *client);
  */
 static int pcf8563_get_datetime(struct i2c_client *client, struct rtc_time *tm)
 {
+       struct pcf8563 *pcf8563 = container_of(client, struct pcf8563, client);
        unsigned char buf[13] = { PCF8563_REG_ST1 };
 
        struct i2c_msg msgs[] = {
@@ -94,8 +114,12 @@ static int pcf8563_get_datetime(struct i2c_client *client, struct rtc_time *tm)
        tm->tm_mday = BCD2BIN(buf[PCF8563_REG_DM] & 0x3F);
        tm->tm_wday = buf[PCF8563_REG_DW] & 0x07;
        tm->tm_mon = BCD2BIN(buf[PCF8563_REG_MO] & 0x1F) - 1; /* rtc mn 1-12 */
-       tm->tm_year = BCD2BIN(buf[PCF8563_REG_YR])
-               + (buf[PCF8563_REG_MO] & PCF8563_MO_C ? 0 : 100);
+       tm->tm_year = BCD2BIN(buf[PCF8563_REG_YR]);
+       if (tm->tm_year < 70)
+               tm->tm_year += 100;     /* assume we are in 1970...2069 */
+       /* detect the polarity heuristically. see note above. */
+       pcf8563->c_polarity = (buf[PCF8563_REG_MO] & PCF8563_MO_C) ?
+               (tm->tm_year >= 100) : (tm->tm_year < 100);
 
        dev_dbg(&client->dev, "%s: tm is secs=%d, mins=%d, hours=%d, "
                "mday=%d, mon=%d, year=%d, wday=%d\n",
@@ -114,6 +138,7 @@ static int pcf8563_get_datetime(struct i2c_client *client, struct rtc_time *tm)
 
 static int pcf8563_set_datetime(struct i2c_client *client, struct rtc_time *tm)
 {
+       struct pcf8563 *pcf8563 = container_of(client, struct pcf8563, client);
        int i, err;
        unsigned char buf[9];
 
@@ -135,7 +160,7 @@ static int pcf8563_set_datetime(struct i2c_client *client, struct rtc_time *tm)
 
        /* year and century */
        buf[PCF8563_REG_YR] = BIN2BCD(tm->tm_year % 100);
-       if (tm->tm_year < 100)
+       if (pcf8563->c_polarity ? (tm->tm_year >= 100) : (tm->tm_year < 100))
                buf[PCF8563_REG_MO] |= PCF8563_MO_C;
 
        buf[PCF8563_REG_DW] = tm->tm_wday & 0x07;
@@ -248,6 +273,7 @@ static struct i2c_driver pcf8563_driver = {
 
 static int pcf8563_probe(struct i2c_adapter *adapter, int address, int kind)
 {
+       struct pcf8563 *pcf8563;
        struct i2c_client *client;
        struct rtc_device *rtc;
 
@@ -260,11 +286,12 @@ static int pcf8563_probe(struct i2c_adapter *adapter, int address, int kind)
                goto exit;
        }
 
-       if (!(client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL))) {
+       if (!(pcf8563 = kzalloc(sizeof(struct pcf8563), GFP_KERNEL))) {
                err = -ENOMEM;
                goto exit;
        }
 
+       client = &pcf8563->client;
        client->addr = address;
        client->driver = &pcf8563_driver;
        client->adapter = adapter;
@@ -301,7 +328,7 @@ exit_detach:
        i2c_detach_client(client);
 
 exit_kfree:
-       kfree(client);
+       kfree(pcf8563);
 
 exit:
        return err;
@@ -309,6 +336,7 @@ exit:
 
 static int pcf8563_detach(struct i2c_client *client)
 {
+       struct pcf8563 *pcf8563 = container_of(client, struct pcf8563, client);
        int err;
        struct rtc_device *rtc = i2c_get_clientdata(client);
 
@@ -318,7 +346,7 @@ static int pcf8563_detach(struct i2c_client *client)
        if ((err = i2c_detach_client(client)))
                return err;
 
-       kfree(client);
+       kfree(pcf8563);
 
        return 0;
 }
index a138b1510093cc53a6538a99c47fe020da53518a..3a1a958fb5f2843a2132e1a487af739d06417915 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Character device driver for reading z/VM *MONITOR service records.
  *
- * Copyright (C) 2004 IBM Corporation, IBM Deutschland Entwicklung GmbH.
+ * Copyright 2004 IBM Corporation, IBM Deutschland Entwicklung GmbH.
  *
  * Author: Gerald Schaefer <geraldsc@de.ibm.com>
  */
@@ -22,7 +22,7 @@
 #include <asm/ebcdic.h>
 #include <asm/extmem.h>
 #include <linux/poll.h>
-#include "../net/iucv.h"
+#include <net/iucv/iucv.h>
 
 
 //#define MON_DEBUG                    /* Debug messages on/off */
@@ -50,14 +50,13 @@ static char mon_dcss_name[9] = "MONDCSS\0";
 struct mon_msg {
        u32 pos;
        u32 mca_offset;
-       iucv_MessagePending local_eib;
+       struct iucv_message msg;
        char msglim_reached;
        char replied_msglim;
 };
 
 struct mon_private {
-       u16 pathid;
-       iucv_handle_t iucv_handle;
+       struct iucv_path *path;
        struct mon_msg *msg_array[MON_MSGLIM];
        unsigned int   write_index;
        unsigned int   read_index;
@@ -75,8 +74,6 @@ static unsigned long mon_dcss_end;
 static DECLARE_WAIT_QUEUE_HEAD(mon_read_wait_queue);
 static DECLARE_WAIT_QUEUE_HEAD(mon_conn_wait_queue);
 
-static u8 iucv_host[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
-
 static u8 user_data_connect[16] = {
        /* Version code, must be 0x01 for shared mode */
        0x01,
@@ -100,8 +97,7 @@ static u8 user_data_sever[16] = {
  * Create the 8 bytes EBCDIC DCSS segment name from
  * an ASCII name, incl. padding
  */
-static inline void
-dcss_mkname(char *ascii_name, char *ebcdic_name)
+static inline void dcss_mkname(char *ascii_name, char *ebcdic_name)
 {
        int i;
 
@@ -119,8 +115,7 @@ dcss_mkname(char *ascii_name, char *ebcdic_name)
  * print appropriate error message for segment_load()/segment_type()
  * return code
  */
-static void
-mon_segment_warn(int rc, char* seg_name)
+static void mon_segment_warn(int rc, char* seg_name)
 {
        switch (rc) {
        case -ENOENT:
@@ -166,44 +161,37 @@ mon_segment_warn(int rc, char* seg_name)
        }
 }
 
-static inline unsigned long
-mon_mca_start(struct mon_msg *monmsg)
+static inline unsigned long mon_mca_start(struct mon_msg *monmsg)
 {
-       return monmsg->local_eib.ln1msg1.iprmmsg1_u32;
+       return *(u32 *) &monmsg->msg.rmmsg;
 }
 
-static inline unsigned long
-mon_mca_end(struct mon_msg *monmsg)
+static inline unsigned long mon_mca_end(struct mon_msg *monmsg)
 {
-       return monmsg->local_eib.ln1msg2.ipbfln1f;
+       return *(u32 *) &monmsg->msg.rmmsg[4];
 }
 
-static inline u8
-mon_mca_type(struct mon_msg *monmsg, u8 index)
+static inline u8 mon_mca_type(struct mon_msg *monmsg, u8 index)
 {
        return *((u8 *) mon_mca_start(monmsg) + monmsg->mca_offset + index);
 }
 
-static inline u32
-mon_mca_size(struct mon_msg *monmsg)
+static inline u32 mon_mca_size(struct mon_msg *monmsg)
 {
        return mon_mca_end(monmsg) - mon_mca_start(monmsg) + 1;
 }
 
-static inline u32
-mon_rec_start(struct mon_msg *monmsg)
+static inline u32 mon_rec_start(struct mon_msg *monmsg)
 {
        return *((u32 *) (mon_mca_start(monmsg) + monmsg->mca_offset + 4));
 }
 
-static inline u32
-mon_rec_end(struct mon_msg *monmsg)
+static inline u32 mon_rec_end(struct mon_msg *monmsg)
 {
        return *((u32 *) (mon_mca_start(monmsg) + monmsg->mca_offset + 8));
 }
 
-static inline int
-mon_check_mca(struct mon_msg *monmsg)
+static inline int mon_check_mca(struct mon_msg *monmsg)
 {
        if ((mon_rec_end(monmsg) <= mon_rec_start(monmsg)) ||
            (mon_rec_start(monmsg) < mon_dcss_start) ||
@@ -221,20 +209,17 @@ mon_check_mca(struct mon_msg *monmsg)
        return 0;
 }
 
-static inline int
-mon_send_reply(struct mon_msg *monmsg, struct mon_private *monpriv)
+static inline int mon_send_reply(struct mon_msg *monmsg,
+                                struct mon_private *monpriv)
 {
-       u8 prmmsg[8];
        int rc;
 
        P_DEBUG("read, REPLY: pathid = 0x%04X, msgid = 0x%08X, trgcls = "
                "0x%08X\n\n",
-               monmsg->local_eib.ippathid, monmsg->local_eib.ipmsgid,
-               monmsg->local_eib.iptrgcls);
-       rc = iucv_reply_prmmsg(monmsg->local_eib.ippathid,
-                               monmsg->local_eib.ipmsgid,
-                               monmsg->local_eib.iptrgcls,
-                               0, prmmsg);
+               monpriv->path->pathid, monmsg->msg.id, monmsg->msg.class);
+
+       rc = iucv_message_reply(monpriv->path, &monmsg->msg,
+                               IUCV_IPRMDATA, NULL, 0);
        atomic_dec(&monpriv->msglim_count);
        if (likely(!monmsg->msglim_reached)) {
                monmsg->pos = 0;
@@ -251,10 +236,19 @@ mon_send_reply(struct mon_msg *monmsg, struct mon_private *monpriv)
        return 0;
 }
 
-static inline struct mon_private *
-mon_alloc_mem(void)
+static inline void mon_free_mem(struct mon_private *monpriv)
+{
+       int i;
+
+       for (i = 0; i < MON_MSGLIM; i++)
+               if (monpriv->msg_array[i])
+                       kfree(monpriv->msg_array[i]);
+       kfree(monpriv);
+}
+
+static inline struct mon_private *mon_alloc_mem(void)
 {
-       int i,j;
+       int i;
        struct mon_private *monpriv;
 
        monpriv = kzalloc(sizeof(struct mon_private), GFP_KERNEL);
@@ -267,16 +261,15 @@ mon_alloc_mem(void)
                                                    GFP_KERNEL);
                if (!monpriv->msg_array[i]) {
                        P_ERROR("open, no memory for msg_array\n");
-                       for (j = 0; j < i; j++)
-                               kfree(monpriv->msg_array[j]);
+                       mon_free_mem(monpriv);
                        return NULL;
                }
        }
        return monpriv;
 }
 
-static inline void
-mon_read_debug(struct mon_msg *monmsg, struct mon_private *monpriv)
+static inline void mon_read_debug(struct mon_msg *monmsg,
+                                 struct mon_private *monpriv)
 {
 #ifdef MON_DEBUG
        u8 msg_type[2], mca_type;
@@ -284,7 +277,7 @@ mon_read_debug(struct mon_msg *monmsg, struct mon_private *monpriv)
 
        records_len = mon_rec_end(monmsg) - mon_rec_start(monmsg) + 1;
 
-       memcpy(msg_type, &monmsg->local_eib.iptrgcls, 2);
+       memcpy(msg_type, &monmsg->msg.class, 2);
        EBCASC(msg_type, 2);
        mca_type = mon_mca_type(monmsg, 0);
        EBCASC(&mca_type, 1);
@@ -292,8 +285,7 @@ mon_read_debug(struct mon_msg *monmsg, struct mon_private *monpriv)
        P_DEBUG("read, mon_read_index = %i, mon_write_index = %i\n",
                monpriv->read_index, monpriv->write_index);
        P_DEBUG("read, pathid = 0x%04X, msgid = 0x%08X, trgcls = 0x%08X\n",
-               monmsg->local_eib.ippathid, monmsg->local_eib.ipmsgid,
-               monmsg->local_eib.iptrgcls);
+               monpriv->path->pathid, monmsg->msg.id, monmsg->msg.class);
        P_DEBUG("read, msg_type = '%c%c', mca_type = '%c' / 0x%X / 0x%X\n",
                msg_type[0], msg_type[1], mca_type ? mca_type : 'X',
                mon_mca_type(monmsg, 1), mon_mca_type(monmsg, 2));
@@ -306,8 +298,7 @@ mon_read_debug(struct mon_msg *monmsg, struct mon_private *monpriv)
 #endif
 }
 
-static inline void
-mon_next_mca(struct mon_msg *monmsg)
+static inline void mon_next_mca(struct mon_msg *monmsg)
 {
        if (likely((mon_mca_size(monmsg) - monmsg->mca_offset) == 12))
                return;
@@ -316,8 +307,7 @@ mon_next_mca(struct mon_msg *monmsg)
        monmsg->pos = 0;
 }
 
-static inline struct mon_msg *
-mon_next_message(struct mon_private *monpriv)
+static inline struct mon_msg *mon_next_message(struct mon_private *monpriv)
 {
        struct mon_msg *monmsg;
 
@@ -342,39 +332,37 @@ mon_next_message(struct mon_private *monpriv)
 /******************************************************************************
  *                               IUCV handler                                 *
  *****************************************************************************/
-static void
-mon_iucv_ConnectionComplete(iucv_ConnectionComplete *eib, void *pgm_data)
+static void mon_iucv_path_complete(struct iucv_path *path, u8 ipuser[16])
 {
-       struct mon_private *monpriv = (struct mon_private *) pgm_data;
+       struct mon_private *monpriv = path->private;
 
        P_DEBUG("IUCV connection completed\n");
        P_DEBUG("IUCV ACCEPT (from *MONITOR): Version = 0x%02X, Event = "
                "0x%02X, Sample = 0x%02X\n",
-               eib->ipuser[0], eib->ipuser[1], eib->ipuser[2]);
+               ipuser[0], ipuser[1], ipuser[2]);
        atomic_set(&monpriv->iucv_connected, 1);
        wake_up(&mon_conn_wait_queue);
 }
 
-static void
-mon_iucv_ConnectionSevered(iucv_ConnectionSevered *eib, void *pgm_data)
+static void mon_iucv_path_severed(struct iucv_path *path, u8 ipuser[16])
 {
-       struct mon_private *monpriv = (struct mon_private *) pgm_data;
+       struct mon_private *monpriv = path->private;
 
-       P_ERROR("IUCV connection severed with rc = 0x%X\n",
-               (u8) eib->ipuser[0]);
+       P_ERROR("IUCV connection severed with rc = 0x%X\n", ipuser[0]);
+       iucv_path_sever(path, NULL);
        atomic_set(&monpriv->iucv_severed, 1);
        wake_up(&mon_conn_wait_queue);
        wake_up_interruptible(&mon_read_wait_queue);
 }
 
-static void
-mon_iucv_MessagePending(iucv_MessagePending *eib, void *pgm_data)
+static void mon_iucv_message_pending(struct iucv_path *path,
+                                    struct iucv_message *msg)
 {
-       struct mon_private *monpriv = (struct mon_private *) pgm_data;
+       struct mon_private *monpriv = path->private;
 
        P_DEBUG("IUCV message pending\n");
-       memcpy(&monpriv->msg_array[monpriv->write_index]->local_eib, eib,
-              sizeof(iucv_MessagePending));
+       memcpy(&monpriv->msg_array[monpriv->write_index]->msg,
+              msg, sizeof(*msg));
        if (atomic_inc_return(&monpriv->msglim_count) == MON_MSGLIM) {
                P_WARNING("IUCV message pending, message limit (%i) reached\n",
                          MON_MSGLIM);
@@ -385,54 +373,45 @@ mon_iucv_MessagePending(iucv_MessagePending *eib, void *pgm_data)
        wake_up_interruptible(&mon_read_wait_queue);
 }
 
-static iucv_interrupt_ops_t mon_iucvops = {
-       .ConnectionComplete = mon_iucv_ConnectionComplete,
-       .ConnectionSevered  = mon_iucv_ConnectionSevered,
-       .MessagePending     = mon_iucv_MessagePending,
+static struct iucv_handler monreader_iucv_handler = {
+       .path_complete   = mon_iucv_path_complete,
+       .path_severed    = mon_iucv_path_severed,
+       .message_pending = mon_iucv_message_pending,
 };
 
 /******************************************************************************
  *                               file operations                              *
  *****************************************************************************/
-static int
-mon_open(struct inode *inode, struct file *filp)
+static int mon_open(struct inode *inode, struct file *filp)
 {
-       int rc, i;
        struct mon_private *monpriv;
+       int rc;
 
        /*
         * only one user allowed
         */
+       rc = -EBUSY;
        if (test_and_set_bit(MON_IN_USE, &mon_in_use))
-               return -EBUSY;
+               goto out;
 
+       rc = -ENOMEM;
        monpriv = mon_alloc_mem();
        if (!monpriv)
-               return -ENOMEM;
+               goto out_use;
 
        /*
-        * Register with IUCV and connect to *MONITOR service
+        * Connect to *MONITOR service
         */
-       monpriv->iucv_handle = iucv_register_program("my_monreader    ",
-                                                       MON_SERVICE,
-                                                       NULL,
-                                                       &mon_iucvops,
-                                                       monpriv);
-       if (!monpriv->iucv_handle) {
-               P_ERROR("failed to register with iucv driver\n");
-               rc = -EIO;
-               goto out_error;
-       }
-       P_INFO("open, registered with IUCV\n");
-
-       rc = iucv_connect(&monpriv->pathid, MON_MSGLIM, user_data_connect,
-                         MON_SERVICE, iucv_host, IPRMDATA, NULL, NULL,
-                         monpriv->iucv_handle, NULL);
+       monpriv->path = iucv_path_alloc(MON_MSGLIM, IUCV_IPRMDATA, GFP_KERNEL);
+       if (!monpriv->path)
+               goto out_priv;
+       rc = iucv_path_connect(monpriv->path, &monreader_iucv_handler,
+                              MON_SERVICE, NULL, user_data_connect, monpriv);
        if (rc) {
                P_ERROR("iucv connection to *MONITOR failed with "
                        "IPUSER SEVER code = %i\n", rc);
                rc = -EIO;
-               goto out_unregister;
+               goto out_path;
        }
        /*
         * Wait for connection confirmation
@@ -444,24 +423,23 @@ mon_open(struct inode *inode, struct file *filp)
                atomic_set(&monpriv->iucv_severed, 0);
                atomic_set(&monpriv->iucv_connected, 0);
                rc = -EIO;
-               goto out_unregister;
+               goto out_path;
        }
        P_INFO("open, established connection to *MONITOR service\n\n");
        filp->private_data = monpriv;
        return nonseekable_open(inode, filp);
 
-out_unregister:
-       iucv_unregister_program(monpriv->iucv_handle);
-out_error:
-       for (i = 0; i < MON_MSGLIM; i++)
-               kfree(monpriv->msg_array[i]);
-       kfree(monpriv);
+out_path:
+       kfree(monpriv->path);
+out_priv:
+       mon_free_mem(monpriv);
+out_use:
        clear_bit(MON_IN_USE, &mon_in_use);
+out:
        return rc;
 }
 
-static int
-mon_close(struct inode *inode, struct file *filp)
+static int mon_close(struct inode *inode, struct file *filp)
 {
        int rc, i;
        struct mon_private *monpriv = filp->private_data;
@@ -469,18 +447,12 @@ mon_close(struct inode *inode, struct file *filp)
        /*
         * Close IUCV connection and unregister
         */
-       rc = iucv_sever(monpriv->pathid, user_data_sever);
+       rc = iucv_path_sever(monpriv->path, user_data_sever);
        if (rc)
                P_ERROR("close, iucv_sever failed with rc = %i\n", rc);
        else
                P_INFO("close, terminated connection to *MONITOR service\n");
 
-       rc = iucv_unregister_program(monpriv->iucv_handle);
-       if (rc)
-               P_ERROR("close, iucv_unregister failed with rc = %i\n", rc);
-       else
-               P_INFO("close, unregistered with IUCV\n");
-
        atomic_set(&monpriv->iucv_severed, 0);
        atomic_set(&monpriv->iucv_connected, 0);
        atomic_set(&monpriv->read_ready, 0);
@@ -495,8 +467,8 @@ mon_close(struct inode *inode, struct file *filp)
        return 0;
 }
 
-static ssize_t
-mon_read(struct file *filp, char __user *data, size_t count, loff_t *ppos)
+static ssize_t mon_read(struct file *filp, char __user *data,
+                       size_t count, loff_t *ppos)
 {
        struct mon_private *monpriv = filp->private_data;
        struct mon_msg *monmsg;
@@ -563,8 +535,7 @@ out_copy:
        return count;
 }
 
-static unsigned int
-mon_poll(struct file *filp, struct poll_table_struct *p)
+static unsigned int mon_poll(struct file *filp, struct poll_table_struct *p)
 {
        struct mon_private *monpriv = filp->private_data;
 
@@ -593,8 +564,7 @@ static struct miscdevice mon_dev = {
 /******************************************************************************
  *                              module init/exit                              *
  *****************************************************************************/
-static int __init
-mon_init(void)
+static int __init mon_init(void)
 {
        int rc;
 
@@ -603,22 +573,34 @@ mon_init(void)
                return -ENODEV;
        }
 
+       /*
+        * Register with IUCV and connect to *MONITOR service
+        */
+       rc = iucv_register(&monreader_iucv_handler, 1);
+       if (rc) {
+               P_ERROR("failed to register with iucv driver\n");
+               return rc;
+       }
+       P_INFO("open, registered with IUCV\n");
+
        rc = segment_type(mon_dcss_name);
        if (rc < 0) {
                mon_segment_warn(rc, mon_dcss_name);
-               return rc;
+               goto out_iucv;
        }
        if (rc != SEG_TYPE_SC) {
                P_ERROR("segment %s has unsupported type, should be SC\n",
                        mon_dcss_name);
-               return -EINVAL;
+               rc = -EINVAL;
+               goto out_iucv;
        }
 
        rc = segment_load(mon_dcss_name, SEGMENT_SHARED,
                          &mon_dcss_start, &mon_dcss_end);
        if (rc < 0) {
                mon_segment_warn(rc, mon_dcss_name);
-               return -EINVAL;
+               rc = -EINVAL;
+               goto out_iucv;
        }
        dcss_mkname(mon_dcss_name, &user_data_connect[8]);
 
@@ -634,14 +616,16 @@ mon_init(void)
 
 out:
        segment_unload(mon_dcss_name);
+out_iucv:
+       iucv_unregister(&monreader_iucv_handler, 1);
        return rc;
 }
 
-static void __exit
-mon_exit(void)
+static void __exit mon_exit(void)
 {
        segment_unload(mon_dcss_name);
        WARN_ON(misc_deregister(&mon_dev) != 0);
+       iucv_unregister(&monreader_iucv_handler, 1);
        return;
 }
 
index 4f894dc2373bbc68230f5c2cb9fe31c1f1b913a2..8432a76b961ed2932b8c318272eb38ff0beb3014 100644 (file)
@@ -3,7 +3,7 @@
  *     character device driver for reading z/VM system service records
  *
  *
- *     Copyright (C) 2004 IBM Corporation
+ *     Copyright 2004 IBM Corporation
  *     character device driver for reading z/VM system service records,
  *     Version 1.0
  *     Author(s): Xenia Tkatschow <xenia@us.ibm.com>
@@ -21,7 +21,7 @@
 #include <asm/cpcmd.h>
 #include <asm/debug.h>
 #include <asm/ebcdic.h>
-#include "../net/iucv.h"
+#include <net/iucv/iucv.h>
 #include <linux/kmod.h>
 #include <linux/cdev.h>
 #include <linux/device.h>
@@ -60,12 +60,11 @@ struct vmlogrdr_priv_t {
        char system_service[8];
        char internal_name[8];
        char recording_name[8];
-       u16 pathid;
+       struct iucv_path *path;
        int connection_established;
        int iucv_path_severed;
-       iucv_MessagePending local_interrupt_buffer;
+       struct iucv_message local_interrupt_buffer;
        atomic_t receive_ready;
-       iucv_handle_t iucv_handle;
        int minor_num;
        char * buffer;
        char * current_position;
@@ -97,37 +96,19 @@ static struct file_operations vmlogrdr_fops = {
 };
 
 
-static u8 iucvMagic[16] = {
-       0xF0, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
-       0xF0, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40
-};
+static void vmlogrdr_iucv_path_complete(struct iucv_path *, u8 ipuser[16]);
+static void vmlogrdr_iucv_path_severed(struct iucv_path *, u8 ipuser[16]);
+static void vmlogrdr_iucv_message_pending(struct iucv_path *,
+                                         struct iucv_message *);
 
 
-static u8 mask[] = {
-       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
+static struct iucv_handler vmlogrdr_iucv_handler = {
+       .path_complete   = vmlogrdr_iucv_path_complete,
+       .path_severed    = vmlogrdr_iucv_path_severed,
+       .message_pending = vmlogrdr_iucv_message_pending,
 };
 
 
-static u8 iucv_host[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-
-static void
-vmlogrdr_iucv_ConnectionComplete(iucv_ConnectionComplete *eib, void *pgm_data);
-static void
-vmlogrdr_iucv_ConnectionSevered(iucv_ConnectionSevered *eib, void *pgm_data);
-static void
-vmlogrdr_iucv_MessagePending(iucv_MessagePending *eib, void *pgm_data);
-
-
-static iucv_interrupt_ops_t vmlogrdr_iucvops = {
-       .ConnectionComplete = vmlogrdr_iucv_ConnectionComplete,
-       .ConnectionSevered  = vmlogrdr_iucv_ConnectionSevered,
-       .MessagePending     = vmlogrdr_iucv_MessagePending,
-};
-
 static DECLARE_WAIT_QUEUE_HEAD(conn_wait_queue);
 static DECLARE_WAIT_QUEUE_HEAD(read_wait_queue);
 
@@ -176,28 +157,29 @@ static struct cdev  *vmlogrdr_cdev = NULL;
 static int recording_class_AB;
 
 
-static void
-vmlogrdr_iucv_ConnectionComplete (iucv_ConnectionComplete * eib,
-                                  void * pgm_data)
+static void vmlogrdr_iucv_path_complete(struct iucv_path *path, u8 ipuser[16])
 {
-       struct vmlogrdr_priv_t * logptr = pgm_data;
+       struct vmlogrdr_priv_t * logptr = path->private;
+
        spin_lock(&logptr->priv_lock);
        logptr->connection_established = 1;
        spin_unlock(&logptr->priv_lock);
        wake_up(&conn_wait_queue);
-       return;
 }
 
 
-static void
-vmlogrdr_iucv_ConnectionSevered (iucv_ConnectionSevered * eib, void * pgm_data)
+static void vmlogrdr_iucv_path_severed(struct iucv_path *path, u8 ipuser[16])
 {
-       u8 reason = (u8) eib->ipuser[8];
-       struct vmlogrdr_priv_t * logptr = pgm_data;
+       struct vmlogrdr_priv_t * logptr = path->private;
+       u8 reason = (u8) ipuser[8];
 
        printk (KERN_ERR "vmlogrdr: connection severed with"
                " reason %i\n", reason);
 
+       iucv_path_sever(path, NULL);
+       kfree(path);
+       logptr->path = NULL;
+
        spin_lock(&logptr->priv_lock);
        logptr->connection_established = 0;
        logptr->iucv_path_severed = 1;
@@ -209,10 +191,10 @@ vmlogrdr_iucv_ConnectionSevered (iucv_ConnectionSevered * eib, void * pgm_data)
 }
 
 
-static void
-vmlogrdr_iucv_MessagePending (iucv_MessagePending * eib, void * pgm_data)
+static void vmlogrdr_iucv_message_pending(struct iucv_path *path,
+                                         struct iucv_message *msg)
 {
-       struct vmlogrdr_priv_t * logptr = pgm_data;
+       struct vmlogrdr_priv_t * logptr = path->private;
 
        /*
         * This function is the bottom half so it should be quick.
@@ -220,15 +202,15 @@ vmlogrdr_iucv_MessagePending (iucv_MessagePending * eib, void * pgm_data)
         * the usage count
         */
        spin_lock(&logptr->priv_lock);
-       memcpy(&(logptr->local_interrupt_buffer), eib, sizeof(*eib));
+       memcpy(&logptr->local_interrupt_buffer, msg, sizeof(*msg));
        atomic_inc(&logptr->receive_ready);
        spin_unlock(&logptr->priv_lock);
        wake_up_interruptible(&read_wait_queue);
 }
 
 
-static int
-vmlogrdr_get_recording_class_AB(void) {
+static int vmlogrdr_get_recording_class_AB(void)
+{
        char cp_command[]="QUERY COMMAND RECORDING ";
        char cp_response[80];
        char *tail;
@@ -258,8 +240,9 @@ vmlogrdr_get_recording_class_AB(void) {
 }
 
 
-static int
-vmlogrdr_recording(struct vmlogrdr_priv_t * logptr, int action, int purge) {
+static int vmlogrdr_recording(struct vmlogrdr_priv_t * logptr,
+                             int action, int purge)
+{
 
        char cp_command[80];
        char cp_response[160];
@@ -317,8 +300,7 @@ vmlogrdr_recording(struct vmlogrdr_priv_t * logptr, int action, int purge) {
 }
 
 
-static int
-vmlogrdr_open (struct inode *inode, struct file *filp)
+static int vmlogrdr_open (struct inode *inode, struct file *filp)
 {
        int dev_num = 0;
        struct vmlogrdr_priv_t * logptr = NULL;
@@ -328,10 +310,7 @@ vmlogrdr_open (struct inode *inode, struct file *filp)
        dev_num = iminor(inode);
        if (dev_num > MAXMINOR)
                return -ENODEV;
-
        logptr = &sys_ser[dev_num];
-       if (logptr == NULL)
-               return -ENODEV;
 
        /*
         * only allow for blocking reads to be open
@@ -344,52 +323,38 @@ vmlogrdr_open (struct inode *inode, struct file *filp)
        if (logptr->dev_in_use) {
                spin_unlock_bh(&logptr->priv_lock);
                return -EBUSY;
-       } else {
-               logptr->dev_in_use = 1;
-               spin_unlock_bh(&logptr->priv_lock);
        }
-
+       logptr->dev_in_use = 1;
+       logptr->connection_established = 0;
+       logptr->iucv_path_severed = 0;
        atomic_set(&logptr->receive_ready, 0);
        logptr->buffer_free = 1;
+       spin_unlock_bh(&logptr->priv_lock);
 
        /* set the file options */
        filp->private_data = logptr;
        filp->f_op = &vmlogrdr_fops;
 
        /* start recording for this service*/
-       ret=0;
-       if (logptr->autorecording)
+       if (logptr->autorecording) {
                ret = vmlogrdr_recording(logptr,1,logptr->autopurge);
-       if (ret)
-               printk (KERN_WARNING "vmlogrdr: failed to start "
-                       "recording automatically\n");
-
-       /* Register with iucv driver */
-       logptr->iucv_handle = iucv_register_program(iucvMagic,
-                       logptr->system_service, mask, &vmlogrdr_iucvops,
-                       logptr);
-
-       if (logptr->iucv_handle == NULL) {
-               printk (KERN_ERR "vmlogrdr: failed to register with"
-                       "iucv driver\n");
-               goto not_registered;
+               if (ret)
+                       printk (KERN_WARNING "vmlogrdr: failed to start "
+                               "recording automatically\n");
        }
 
        /* create connection to the system service */
-       spin_lock_bh(&logptr->priv_lock);
-       logptr->connection_established = 0;
-       logptr->iucv_path_severed = 0;
-       spin_unlock_bh(&logptr->priv_lock);
-
-       connect_rc = iucv_connect (&(logptr->pathid), 10, iucvMagic,
-                                       logptr->system_service, iucv_host, 0,
-                                       NULL, NULL,
-                                       logptr->iucv_handle, NULL);
+       logptr->path = iucv_path_alloc(10, 0, GFP_KERNEL);
+       if (!logptr->path)
+               goto out_dev;
+       connect_rc = iucv_path_connect(logptr->path, &vmlogrdr_iucv_handler,
+                                      logptr->system_service, NULL, NULL,
+                                      logptr);
        if (connect_rc) {
                printk (KERN_ERR "vmlogrdr: iucv connection to %s "
                        "failed with rc %i \n", logptr->system_service,
                        connect_rc);
-               goto not_connected;
+               goto out_path;
        }
 
        /* We've issued the connect and now we must wait for a
@@ -398,35 +363,28 @@ vmlogrdr_open (struct inode *inode, struct file *filp)
         */
        wait_event(conn_wait_queue, (logptr->connection_established)
                   || (logptr->iucv_path_severed));
-       if (logptr->iucv_path_severed) {
-               goto not_connected;
-       }
-
+       if (logptr->iucv_path_severed)
+               goto out_record;
        return nonseekable_open(inode, filp);
 
-not_connected:
-       iucv_unregister_program(logptr->iucv_handle);
-       logptr->iucv_handle = NULL;
-not_registered:
+out_record:
        if (logptr->autorecording)
                vmlogrdr_recording(logptr,0,logptr->autopurge);
+out_path:
+       kfree(logptr->path);    /* kfree(NULL) is ok. */
+       logptr->path = NULL;
+out_dev:
        logptr->dev_in_use = 0;
        return -EIO;
-
-
 }
 
 
-static int
-vmlogrdr_release (struct inode *inode, struct file *filp)
+static int vmlogrdr_release (struct inode *inode, struct file *filp)
 {
        int ret;
 
        struct vmlogrdr_priv_t * logptr = filp->private_data;
 
-       iucv_unregister_program(logptr->iucv_handle);
-       logptr->iucv_handle = NULL;
-
        if (logptr->autorecording) {
                ret = vmlogrdr_recording(logptr,0,logptr->autopurge);
                if (ret)
@@ -439,8 +397,8 @@ vmlogrdr_release (struct inode *inode, struct file *filp)
 }
 
 
-static int
-vmlogrdr_receive_data(struct vmlogrdr_priv_t *priv) {
+static int vmlogrdr_receive_data(struct vmlogrdr_priv_t *priv)
+{
        int rc, *temp;
        /* we need to keep track of two data sizes here:
         * The number of bytes we need to receive from iucv and
@@ -461,8 +419,7 @@ vmlogrdr_receive_data(struct vmlogrdr_priv_t *priv) {
                         * We need to return the total length of the record
                          * + size of FENCE in the first 4 bytes of the buffer.
                         */
-                       iucv_data_count =
-                               priv->local_interrupt_buffer.ln1msg2.ipbfln1f;
+                       iucv_data_count = priv->local_interrupt_buffer.length;
                        user_data_count = sizeof(int);
                        temp = (int*)priv->buffer;
                        *temp= iucv_data_count + sizeof(FENCE);
@@ -474,14 +431,10 @@ vmlogrdr_receive_data(struct vmlogrdr_priv_t *priv) {
                 */
                if (iucv_data_count > NET_BUFFER_SIZE)
                        iucv_data_count = NET_BUFFER_SIZE;
-               rc = iucv_receive(priv->pathid,
-                                 priv->local_interrupt_buffer.ipmsgid,
-                                 priv->local_interrupt_buffer.iptrgcls,
-                                 buffer,
-                                 iucv_data_count,
-                                 NULL,
-                                 NULL,
-                                 &priv->residual_length);
+               rc = iucv_message_receive(priv->path,
+                                         &priv->local_interrupt_buffer,
+                                         0, buffer, iucv_data_count,
+                                         &priv->residual_length);
                spin_unlock_bh(&priv->priv_lock);
                /* An rc of 5 indicates that the record was bigger then
                 * the buffer, which is OK for us. A 9 indicates that the
@@ -513,8 +466,8 @@ vmlogrdr_receive_data(struct vmlogrdr_priv_t *priv) {
 }
 
 
-static ssize_t
-vmlogrdr_read(struct file *filp, char __user *data, size_t count, loff_t * ppos)
+static ssize_t vmlogrdr_read(struct file *filp, char __user *data,
+                            size_t count, loff_t * ppos)
 {
        int rc;
        struct vmlogrdr_priv_t * priv = filp->private_data;
@@ -546,8 +499,10 @@ vmlogrdr_read(struct file *filp, char __user *data, size_t count, loff_t * ppos)
        return count;
 }
 
-static ssize_t
-vmlogrdr_autopurge_store(struct device * dev, struct device_attribute *attr, const char * buf, size_t count) {
+static ssize_t vmlogrdr_autopurge_store(struct device * dev,
+                                       struct device_attribute *attr,
+                                       const char * buf, size_t count)
+{
        struct vmlogrdr_priv_t *priv = dev->driver_data;
        ssize_t ret = count;
 
@@ -565,8 +520,10 @@ vmlogrdr_autopurge_store(struct device * dev, struct device_attribute *attr, con
 }
 
 
-static ssize_t
-vmlogrdr_autopurge_show(struct device *dev, struct device_attribute *attr, char *buf) {
+static ssize_t vmlogrdr_autopurge_show(struct device *dev,
+                                      struct device_attribute *attr,
+                                      char *buf)
+{
        struct vmlogrdr_priv_t *priv = dev->driver_data;
        return sprintf(buf, "%u\n", priv->autopurge);
 }
@@ -576,8 +533,10 @@ static DEVICE_ATTR(autopurge, 0644, vmlogrdr_autopurge_show,
                   vmlogrdr_autopurge_store);
 
 
-static ssize_t
-vmlogrdr_purge_store(struct device * dev, struct device_attribute *attr, const char * buf, size_t count) {
+static ssize_t vmlogrdr_purge_store(struct device * dev,
+                                   struct device_attribute *attr,
+                                   const char * buf, size_t count)
+{
 
        char cp_command[80];
        char cp_response[80];
@@ -617,9 +576,10 @@ vmlogrdr_purge_store(struct device * dev, struct device_attribute *attr, const c
 static DEVICE_ATTR(purge, 0200, NULL, vmlogrdr_purge_store);
 
 
-static ssize_t
-vmlogrdr_autorecording_store(struct device *dev, struct device_attribute *attr, const char *buf,
-                            size_t count) {
+static ssize_t vmlogrdr_autorecording_store(struct device *dev,
+                                           struct device_attribute *attr,
+                                           const char *buf, size_t count)
+{
        struct vmlogrdr_priv_t *priv = dev->driver_data;
        ssize_t ret = count;
 
@@ -637,8 +597,10 @@ vmlogrdr_autorecording_store(struct device *dev, struct device_attribute *attr,
 }
 
 
-static ssize_t
-vmlogrdr_autorecording_show(struct device *dev, struct device_attribute *attr, char *buf) {
+static ssize_t vmlogrdr_autorecording_show(struct device *dev,
+                                          struct device_attribute *attr,
+                                          char *buf)
+{
        struct vmlogrdr_priv_t *priv = dev->driver_data;
        return sprintf(buf, "%u\n", priv->autorecording);
 }
@@ -648,9 +610,10 @@ static DEVICE_ATTR(autorecording, 0644, vmlogrdr_autorecording_show,
                   vmlogrdr_autorecording_store);
 
 
-static ssize_t
-vmlogrdr_recording_store(struct device * dev, struct device_attribute *attr, const char * buf, size_t count) {
-
+static ssize_t vmlogrdr_recording_store(struct device * dev,
+                                       struct device_attribute *attr,
+                                       const char * buf, size_t count)
+{
        struct vmlogrdr_priv_t *priv = dev->driver_data;
        ssize_t ret;
 
@@ -675,8 +638,9 @@ vmlogrdr_recording_store(struct device * dev, struct device_attribute *attr, con
 static DEVICE_ATTR(recording, 0200, NULL, vmlogrdr_recording_store);
 
 
-static ssize_t
-vmlogrdr_recording_status_show(struct device_driver *driver, char *buf) {
+static ssize_t vmlogrdr_recording_status_show(struct device_driver *driver,
+                                             char *buf)
+{
 
        char cp_command[] = "QUERY RECORDING ";
        int len;
@@ -709,52 +673,63 @@ static struct device_driver vmlogrdr_driver = {
 };
 
 
-static int
-vmlogrdr_register_driver(void) {
+static int vmlogrdr_register_driver(void)
+{
        int ret;
 
+       /* Register with iucv driver */
+       ret = iucv_register(&vmlogrdr_iucv_handler, 1);
+       if (ret) {
+               printk (KERN_ERR "vmlogrdr: failed to register with"
+                       "iucv driver\n");
+               goto out;
+       }
+
        ret = driver_register(&vmlogrdr_driver);
        if (ret) {
                printk(KERN_ERR "vmlogrdr: failed to register driver.\n");
-               return ret;
+               goto out_iucv;
        }
 
        ret = driver_create_file(&vmlogrdr_driver,
                                 &driver_attr_recording_status);
        if (ret) {
                printk(KERN_ERR "vmlogrdr: failed to add driver attribute.\n");
-               goto unregdriver;
+               goto out_driver;
        }
 
        vmlogrdr_class = class_create(THIS_MODULE, "vmlogrdr");
        if (IS_ERR(vmlogrdr_class)) {
                printk(KERN_ERR "vmlogrdr: failed to create class.\n");
-               ret=PTR_ERR(vmlogrdr_class);
-               vmlogrdr_class=NULL;
-               goto unregattr;
+               ret = PTR_ERR(vmlogrdr_class);
+               vmlogrdr_class = NULL;
+               goto out_attr;
        }
        return 0;
 
-unregattr:
+out_attr:
        driver_remove_file(&vmlogrdr_driver, &driver_attr_recording_status);
-unregdriver:
+out_driver:
        driver_unregister(&vmlogrdr_driver);
+out_iucv:
+       iucv_unregister(&vmlogrdr_iucv_handler, 1);
+out:
        return ret;
 }
 
 
-static void
-vmlogrdr_unregister_driver(void) {
+static void vmlogrdr_unregister_driver(void)
+{
        class_destroy(vmlogrdr_class);
        vmlogrdr_class = NULL;
        driver_remove_file(&vmlogrdr_driver, &driver_attr_recording_status);
        driver_unregister(&vmlogrdr_driver);
-       return;
+       iucv_unregister(&vmlogrdr_iucv_handler, 1);
 }
 
 
-static int
-vmlogrdr_register_device(struct vmlogrdr_priv_t *priv) {
+static int vmlogrdr_register_device(struct vmlogrdr_priv_t *priv)
+{
        struct device *dev;
        int ret;
 
@@ -803,9 +778,10 @@ vmlogrdr_register_device(struct vmlogrdr_priv_t *priv) {
 }
 
 
-static int
-vmlogrdr_unregister_device(struct vmlogrdr_priv_t *priv ) {
-       class_device_destroy(vmlogrdr_class, MKDEV(vmlogrdr_major, priv->minor_num));
+static int vmlogrdr_unregister_device(struct vmlogrdr_priv_t *priv)
+{
+       class_device_destroy(vmlogrdr_class,
+                            MKDEV(vmlogrdr_major, priv->minor_num));
        if (priv->device != NULL) {
                sysfs_remove_group(&priv->device->kobj, &vmlogrdr_attr_group);
                device_unregister(priv->device);
@@ -815,8 +791,8 @@ vmlogrdr_unregister_device(struct vmlogrdr_priv_t *priv ) {
 }
 
 
-static int
-vmlogrdr_register_cdev(dev_t dev) {
+static int vmlogrdr_register_cdev(dev_t dev)
+{
        int rc = 0;
        vmlogrdr_cdev = cdev_alloc();
        if (!vmlogrdr_cdev) {
@@ -836,9 +812,10 @@ vmlogrdr_register_cdev(dev_t dev) {
 }
 
 
-static void
-vmlogrdr_cleanup(void) {
+static void vmlogrdr_cleanup(void)
+{
         int i;
+
        if (vmlogrdr_cdev) {
                cdev_del(vmlogrdr_cdev);
                vmlogrdr_cdev=NULL;
@@ -855,8 +832,7 @@ vmlogrdr_cleanup(void) {
 }
 
 
-static int
-vmlogrdr_init(void)
+static int vmlogrdr_init(void)
 {
        int rc;
        int i;
@@ -906,8 +882,7 @@ cleanup:
 }
 
 
-static void
-vmlogrdr_exit(void)
+static void vmlogrdr_exit(void)
 {
        vmlogrdr_cleanup();
        printk (KERN_INFO "vmlogrdr: driver unloaded\n");
index b9e59bc9435aea3e3c6ad0dea4e903cde728b21a..2c785148d21e5e060334bb9296da7a03baa2458b 100644 (file)
@@ -1063,7 +1063,6 @@ int __init zcrypt_api_init(void)
                rc = -ENOMEM;
                goto out_misc;
        }
-       zcrypt_entry->nlink = 1;
        zcrypt_entry->data = NULL;
        zcrypt_entry->read_proc = zcrypt_status_read;
        zcrypt_entry->write_proc = zcrypt_status_write;
index 52625153a4f09572b6311a1f2324e8f9add7b0f7..f98fa465df0a79b4ed45c68ea43a89e83cc4e072 100644 (file)
@@ -22,13 +22,6 @@ config CTC
          available.  This option is also available as a module which will be
          called ctc.ko.  If you do not know what it is, it's safe to say "Y".
 
-config IUCV
-       tristate "IUCV support (VM only)"
-       help
-         Select this option if you want to use inter-user communication
-         under VM or VIF. If unsure, say "Y" to enable a fast communication
-         link between VM guests.
-
 config NETIUCV
        tristate "IUCV network device support (VM only)"
        depends on IUCV && NETDEVICES
index 4777e36a922fca2481c31bce56f02ac76a45a1d4..bbe3ab2e93d9cff6b41deb0bd713a82c6394be86 100644 (file)
@@ -4,7 +4,6 @@
 
 ctc-objs := ctcmain.o ctcdbug.o
 
-obj-$(CONFIG_IUCV) += iucv.o
 obj-$(CONFIG_NETIUCV) += netiucv.o fsm.o
 obj-$(CONFIG_SMSGIUCV) += smsgiucv.o
 obj-$(CONFIG_CTC) += ctc.o fsm.o cu3088.o
diff --git a/drivers/s390/net/iucv.c b/drivers/s390/net/iucv.c
deleted file mode 100644 (file)
index 229aeb5..0000000
+++ /dev/null
@@ -1,2540 +0,0 @@
-/*
- * IUCV network driver
- *
- * Copyright (C) 2001 IBM Deutschland Entwicklung GmbH, IBM Corporation
- * Author(s):
- *    Original source:
- *      Alan Altmark (Alan_Altmark@us.ibm.com)  Sept. 2000
- *      Xenia Tkatschow (xenia@us.ibm.com)
- *    2Gb awareness and general cleanup:
- *      Fritz Elfert (elfert@de.ibm.com, felfert@millenux.com)
- *
- * Documentation used:
- *    The original source
- *    CP Programming Service, IBM document # SC24-5760
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/* #define DEBUG */
-
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-
-#include <linux/spinlock.h>
-#include <linux/kernel.h>
-#include <linux/slab.h>
-#include <linux/init.h>
-#include <linux/interrupt.h>
-#include <linux/list.h>
-#include <linux/errno.h>
-#include <linux/err.h>
-#include <linux/device.h>
-#include <asm/atomic.h>
-#include "iucv.h"
-#include <asm/io.h>
-#include <asm/s390_ext.h>
-#include <asm/ebcdic.h>
-#include <asm/smp.h>
-#include <asm/s390_rdev.h>
-
-/* FLAGS:
- * All flags are defined in the field IPFLAGS1 of each function
- * and can be found in CP Programming Services.
- * IPSRCCLS - Indicates you have specified a source class
- * IPFGMCL  - Indicates you have specified a target class
- * IPFGPID  - Indicates you have specified a pathid
- * IPFGMID  - Indicates you have specified a message ID
- * IPANSLST - Indicates that you are using an address list for
- *            reply data
- * IPBUFLST - Indicates that you are using an address list for
- *            message data
- */
-
-#define IPSRCCLS       0x01
-#define IPFGMCL         0x01
-#define IPFGPID         0x02
-#define IPFGMID         0x04
-#define IPANSLST        0x08
-#define IPBUFLST        0x40
-
-static int
-iucv_bus_match (struct device *dev, struct device_driver *drv)
-{
-       return 0;
-}
-
-struct bus_type iucv_bus = {
-       .name = "iucv",
-       .match = iucv_bus_match,
-};
-
-struct device *iucv_root;
-
-/* General IUCV interrupt structure */
-typedef struct {
-       __u16 ippathid;
-       __u8  res1;
-       __u8  iptype;
-       __u32 res2;
-       __u8  ipvmid[8];
-       __u8  res3[24];
-} iucv_GeneralInterrupt;
-
-static iucv_GeneralInterrupt *iucv_external_int_buffer = NULL;
-
-/* Spin Lock declaration */
-
-static DEFINE_SPINLOCK(iucv_lock);
-
-static int messagesDisabled = 0;
-
-/***************INTERRUPT HANDLING ***************/
-
-typedef struct {
-       struct list_head queue;
-       iucv_GeneralInterrupt data;
-} iucv_irqdata;
-
-static struct list_head  iucv_irq_queue;
-static DEFINE_SPINLOCK(iucv_irq_queue_lock);
-
-/*
- *Internal function prototypes
- */
-static void iucv_tasklet_handler(unsigned long);
-static void iucv_irq_handler(__u16);
-
-static DECLARE_TASKLET(iucv_tasklet,iucv_tasklet_handler,0);
-
-/************ FUNCTION ID'S ****************************/
-
-#define ACCEPT          10
-#define CONNECT         11
-#define DECLARE_BUFFER  12
-#define PURGE           9
-#define QUERY           0
-#define QUIESCE         13
-#define RECEIVE         5
-#define REJECT          8
-#define REPLY           6
-#define RESUME          14
-#define RETRIEVE_BUFFER 2
-#define SEND            4
-#define SETMASK         16
-#define SEVER           15
-
-/**
- * Structure: handler
- * members: list - list management.
- *          structure: id
- *             userid - 8 char array of machine identification
- *             user_data - 16 char array for user identification
- *             mask - 24 char array used to compare the 2 previous
- *          interrupt_table - vector of interrupt functions.
- *          pgm_data -  ulong, application data that is passed
- *                      to the interrupt handlers
-*/
-typedef struct handler_t {
-       struct list_head list;
-       struct {
-               __u8 userid[8];
-               __u8 user_data[16];
-               __u8 mask[24];
-       }                    id;
-       iucv_interrupt_ops_t *interrupt_table;
-       void                 *pgm_data;
-} handler;
-
-/**
- * iucv_handler_table: List of registered handlers.
- */
-static struct list_head iucv_handler_table;
-
-/**
- * iucv_pathid_table: an array of *handler pointing into
- *                    iucv_handler_table for fast indexing by pathid;
- */
-static handler **iucv_pathid_table;
-
-static unsigned long max_connections;
-
-/**
- * iucv_cpuid: contains the logical cpu number of the cpu which
- * has declared the iucv buffer by issuing DECLARE_BUFFER.
- * If no cpu has done the initialization iucv_cpuid contains -1.
- */
-static int iucv_cpuid = -1;
-/**
- * register_flag: is 0 when external interrupt has not been registered
- */
-static int register_flag;
-
-/****************FIVE 40-BYTE PARAMETER STRUCTURES******************/
-/* Data struct 1: iparml_control
- * Used for iucv_accept
- *          iucv_connect
- *          iucv_quiesce
- *          iucv_resume
- *          iucv_sever
- *          iucv_retrieve_buffer
- * Data struct 2: iparml_dpl     (data in parameter list)
- * Used for iucv_send_prmmsg
- *          iucv_send2way_prmmsg
- *          iucv_send2way_prmmsg_array
- *          iucv_reply_prmmsg
- * Data struct 3: iparml_db       (data in a buffer)
- * Used for iucv_receive
- *          iucv_receive_array
- *          iucv_reject
- *          iucv_reply
- *          iucv_reply_array
- *          iucv_send
- *          iucv_send_array
- *          iucv_send2way
- *          iucv_send2way_array
- *          iucv_declare_buffer
- * Data struct 4: iparml_purge
- * Used for iucv_purge
- *          iucv_query
- * Data struct 5: iparml_set_mask
- * Used for iucv_set_mask
- */
-
-typedef struct {
-       __u16 ippathid;
-       __u8  ipflags1;
-       __u8  iprcode;
-       __u16 ipmsglim;
-       __u16 res1;
-       __u8  ipvmid[8];
-       __u8  ipuser[16];
-       __u8  iptarget[8];
-} iparml_control;
-
-typedef struct {
-       __u16 ippathid;
-       __u8  ipflags1;
-       __u8  iprcode;
-       __u32 ipmsgid;
-       __u32 iptrgcls;
-       __u8  iprmmsg[8];
-       __u32 ipsrccls;
-       __u32 ipmsgtag;
-       __u32 ipbfadr2;
-       __u32 ipbfln2f;
-       __u32 res;
-} iparml_dpl;
-
-typedef struct {
-       __u16 ippathid;
-       __u8  ipflags1;
-       __u8  iprcode;
-       __u32 ipmsgid;
-       __u32 iptrgcls;
-       __u32 ipbfadr1;
-       __u32 ipbfln1f;
-       __u32 ipsrccls;
-       __u32 ipmsgtag;
-       __u32 ipbfadr2;
-       __u32 ipbfln2f;
-       __u32 res;
-} iparml_db;
-
-typedef struct {
-       __u16 ippathid;
-       __u8  ipflags1;
-       __u8  iprcode;
-       __u32 ipmsgid;
-       __u8  ipaudit[3];
-       __u8  res1[5];
-       __u32 res2;
-       __u32 ipsrccls;
-       __u32 ipmsgtag;
-       __u32 res3[3];
-} iparml_purge;
-
-typedef struct {
-       __u8  ipmask;
-       __u8  res1[2];
-       __u8  iprcode;
-       __u32 res2[9];
-} iparml_set_mask;
-
-typedef struct {
-       union {
-               iparml_control  p_ctrl;
-               iparml_dpl      p_dpl;
-               iparml_db       p_db;
-               iparml_purge    p_purge;
-               iparml_set_mask p_set_mask;
-       } param;
-       atomic_t in_use;
-       __u32    res;
-}  __attribute__ ((aligned(8))) iucv_param;
-#define PARAM_POOL_SIZE (PAGE_SIZE / sizeof(iucv_param))
-
-static iucv_param * iucv_param_pool;
-
-MODULE_AUTHOR("(C) 2001 IBM Corp. by Fritz Elfert (felfert@millenux.com)");
-MODULE_DESCRIPTION("Linux for S/390 IUCV lowlevel driver");
-MODULE_LICENSE("GPL");
-
-/*
- * Debugging stuff
- *******************************************************************************/
-
-
-#ifdef DEBUG
-static int debuglevel = 0;
-
-module_param(debuglevel, int, 0);
-MODULE_PARM_DESC(debuglevel,
- "Specifies the debug level (0=off ... 3=all)");
-
-static void
-iucv_dumpit(char *title, void *buf, int len)
-{
-       int i;
-       __u8 *p = (__u8 *)buf;
-
-       if (debuglevel < 3)
-               return;
-
-       printk(KERN_DEBUG "%s\n", title);
-       printk("  ");
-       for (i = 0; i < len; i++) {
-               if (!(i % 16) && i != 0)
-                       printk ("\n  ");
-               else if (!(i % 4) && i != 0)
-                       printk(" ");
-               printk("%02X", *p++);
-       }
-       if (len % 16)
-               printk ("\n");
-       return;
-}
-#define iucv_debug(lvl, fmt, args...) \
-do { \
-       if (debuglevel >= lvl) \
-               printk(KERN_DEBUG "%s: " fmt "\n", __FUNCTION__ , ## args); \
-} while (0)
-
-#else
-
-#define iucv_debug(lvl, fmt, args...)  do { } while (0)
-#define iucv_dumpit(title, buf, len)   do { } while (0)
-
-#endif
-
-/*
- * Internal functions
- *******************************************************************************/
-
-/**
- * print start banner
- */
-static void
-iucv_banner(void)
-{
-       printk(KERN_INFO "IUCV lowlevel driver initialized\n");
-}
-
-/**
- * iucv_init - Initialization
- *
- * Allocates and initializes various data structures.
- */
-static int
-iucv_init(void)
-{
-       int ret;
-
-       if (iucv_external_int_buffer)
-               return 0;
-
-       if (!MACHINE_IS_VM) {
-               printk(KERN_ERR "IUCV: IUCV connection needs VM as base\n");
-               return -EPROTONOSUPPORT;
-       }
-
-       ret = bus_register(&iucv_bus);
-       if (ret) {
-               printk(KERN_ERR "IUCV: failed to register bus.\n");
-               return ret;
-       }
-
-       iucv_root = s390_root_dev_register("iucv");
-       if (IS_ERR(iucv_root)) {
-               printk(KERN_ERR "IUCV: failed to register iucv root.\n");
-               bus_unregister(&iucv_bus);
-               return PTR_ERR(iucv_root);
-       }
-
-       /* Note: GFP_DMA used used to get memory below 2G */
-       iucv_external_int_buffer = kzalloc(sizeof(iucv_GeneralInterrupt),
-                                          GFP_KERNEL|GFP_DMA);
-       if (!iucv_external_int_buffer) {
-               printk(KERN_WARNING
-                      "%s: Could not allocate external interrupt buffer\n",
-                      __FUNCTION__);
-               s390_root_dev_unregister(iucv_root);
-               bus_unregister(&iucv_bus);
-               return -ENOMEM;
-       }
-
-       /* Initialize parameter pool */
-       iucv_param_pool = kzalloc(sizeof(iucv_param) * PARAM_POOL_SIZE,
-                                 GFP_KERNEL|GFP_DMA);
-       if (!iucv_param_pool) {
-               printk(KERN_WARNING "%s: Could not allocate param pool\n",
-                      __FUNCTION__);
-               kfree(iucv_external_int_buffer);
-               iucv_external_int_buffer = NULL;
-               s390_root_dev_unregister(iucv_root);
-               bus_unregister(&iucv_bus);
-               return -ENOMEM;
-       }
-
-       /* Initialize irq queue */
-       INIT_LIST_HEAD(&iucv_irq_queue);
-
-       /* Initialize handler table */
-       INIT_LIST_HEAD(&iucv_handler_table);
-
-       iucv_banner();
-       return 0;
-}
-
-/**
- * iucv_exit - De-Initialization
- *
- * Frees everything allocated from iucv_init.
- */
-static int iucv_retrieve_buffer (void);
-
-static void
-iucv_exit(void)
-{
-       iucv_retrieve_buffer();
-       kfree(iucv_external_int_buffer);
-       iucv_external_int_buffer = NULL;
-       kfree(iucv_param_pool);
-       iucv_param_pool = NULL;
-       s390_root_dev_unregister(iucv_root);
-       bus_unregister(&iucv_bus);
-       printk(KERN_INFO "IUCV lowlevel driver unloaded\n");
-}
-
-/**
- * grab_param: - Get a parameter buffer from the pre-allocated pool.
- *
- * This function searches for an unused element in the pre-allocated pool
- * of parameter buffers. If one is found, it marks it "in use" and returns
- * a pointer to it. The calling function is responsible for releasing it
- * when it has finished its usage.
- *
- * Returns: A pointer to iucv_param.
- */
-static __inline__ iucv_param *
-grab_param(void)
-{
-       iucv_param *ptr;
-        static int hint = 0;
-
-       ptr = iucv_param_pool + hint;
-       do {
-               ptr++;
-               if (ptr >= iucv_param_pool + PARAM_POOL_SIZE)
-                       ptr = iucv_param_pool;
-       } while (atomic_cmpxchg(&ptr->in_use, 0, 1) != 0);
-       hint = ptr - iucv_param_pool;
-
-       memset(&ptr->param, 0, sizeof(ptr->param));
-       return ptr;
-}
-
-/**
- * release_param - Release a parameter buffer.
- * @p: A pointer to a struct iucv_param, previously obtained by calling
- *     grab_param().
- *
- * This function marks the specified parameter buffer "unused".
- */
-static __inline__ void
-release_param(void *p)
-{
-       atomic_set(&((iucv_param *)p)->in_use, 0);
-}
-
-/**
- * iucv_add_handler: - Add a new handler
- * @new_handler: handle that is being entered into chain.
- *
- * Places new handle on iucv_handler_table, if identical handler is not
- * found.
- *
- * Returns: 0 on success, !0 on failure (handler already in chain).
- */
-static int
-iucv_add_handler (handler *new)
-{
-       ulong flags;
-
-       iucv_debug(1, "entering");
-       iucv_dumpit("handler:", new, sizeof(handler));
-
-       spin_lock_irqsave (&iucv_lock, flags);
-       if (!list_empty(&iucv_handler_table)) {
-               struct list_head *lh;
-
-               /**
-                * Search list for handler with identical id. If one
-                * is found, the new handler is _not_ added.
-                */
-               list_for_each(lh, &iucv_handler_table) {
-                       handler *h = list_entry(lh, handler, list);
-                       if (!memcmp(&new->id, &h->id, sizeof(h->id))) {
-                               iucv_debug(1, "ret 1");
-                               spin_unlock_irqrestore (&iucv_lock, flags);
-                               return 1;
-                       }
-               }
-       }
-       /**
-        * If we get here, no handler was found.
-        */
-       INIT_LIST_HEAD(&new->list);
-       list_add(&new->list, &iucv_handler_table);
-       spin_unlock_irqrestore (&iucv_lock, flags);
-
-       iucv_debug(1, "exiting");
-       return 0;
-}
-
-/**
- * b2f0:
- * @code: identifier of IUCV call to CP.
- * @parm: pointer to 40 byte iparml area passed to CP
- *
- * Calls CP to execute IUCV commands.
- *
- * Returns: return code from CP's IUCV call
- */
-static inline ulong b2f0(__u32 code, void *parm)
-{
-       register unsigned long reg0 asm ("0");
-       register unsigned long reg1 asm ("1");
-       iucv_dumpit("iparml before b2f0 call:", parm, sizeof(iucv_param));
-
-       reg0 = code;
-       reg1 = virt_to_phys(parm);
-       asm volatile(".long 0xb2f01000" : : "d" (reg0), "a" (reg1));
-
-       iucv_dumpit("iparml after b2f0 call:", parm, sizeof(iucv_param));
-
-       return (unsigned long)*((__u8 *)(parm + 3));
-}
-
-/*
- * Name: iucv_add_pathid
- * Purpose: Adds a path id to the system.
- * Input: pathid -  pathid that is going to be entered into system
- *        handle -  address of handler that the pathid will be associated
- *                with.
- *        pgm_data - token passed in by application.
- * Output: 0: successful addition of pathid
- *        - EINVAL - pathid entry is being used by another application
- *        - ENOMEM - storage allocation for a new pathid table failed
-*/
-static int
-__iucv_add_pathid(__u16 pathid, handler *handler)
-{
-
-       iucv_debug(1, "entering");
-
-       iucv_debug(1, "handler is pointing to %p", handler);
-
-       if (pathid > (max_connections - 1))
-               return -EINVAL;
-
-       if (iucv_pathid_table[pathid]) {
-               iucv_debug(1, "pathid entry is %p", iucv_pathid_table[pathid]);
-               printk(KERN_WARNING
-                      "%s: Pathid being used, error.\n", __FUNCTION__);
-               return -EINVAL;
-       }
-       iucv_pathid_table[pathid] = handler;
-
-       iucv_debug(1, "exiting");
-       return 0;
-}                              /* end of add_pathid function */
-
-static int
-iucv_add_pathid(__u16 pathid, handler *handler)
-{
-       ulong flags;
-       int rc;
-
-       spin_lock_irqsave (&iucv_lock, flags);
-       rc = __iucv_add_pathid(pathid, handler);
-       spin_unlock_irqrestore (&iucv_lock, flags);
-       return rc;
-}
-
-static void
-iucv_remove_pathid(__u16 pathid)
-{
-       ulong flags;
-
-       if (pathid > (max_connections - 1))
-               return;
-
-       spin_lock_irqsave (&iucv_lock, flags);
-       iucv_pathid_table[pathid] = NULL;
-       spin_unlock_irqrestore (&iucv_lock, flags);
-}
-
-/**
- * iucv_declare_buffer_cpuid
- * Register at VM for subsequent IUCV operations. This is executed
- * on the reserved CPU iucv_cpuid. Called from iucv_declare_buffer().
- */
-static void
-iucv_declare_buffer_cpuid (void *result)
-{
-       iparml_db *parm;
-
-       parm = (iparml_db *)grab_param();
-       parm->ipbfadr1 = virt_to_phys(iucv_external_int_buffer);
-       if ((*((ulong *)result) = b2f0(DECLARE_BUFFER, parm)) == 1)
-               *((ulong *)result) = parm->iprcode;
-       release_param(parm);
-}
-
-/**
- * iucv_retrieve_buffer_cpuid:
- * Unregister IUCV usage at VM. This is always executed on the same
- * cpu that registered the buffer to VM.
- * Called from iucv_retrieve_buffer().
- */
-static void
-iucv_retrieve_buffer_cpuid (void *cpu)
-{
-       iparml_control *parm;
-
-       parm = (iparml_control *)grab_param();
-       b2f0(RETRIEVE_BUFFER, parm);
-       release_param(parm);
-}
-
-/**
- * Name: iucv_declare_buffer
- * Purpose: Specifies the guests real address of an external
- *          interrupt.
- * Input: void
- * Output: iprcode - return code from b2f0 call
- */
-static int
-iucv_declare_buffer (void)
-{
-       unsigned long flags;
-       ulong b2f0_result;
-
-       iucv_debug(1, "entering");
-       b2f0_result = -ENODEV;
-       spin_lock_irqsave (&iucv_lock, flags);
-       if (iucv_cpuid == -1) {
-               /* Reserve any cpu for use by iucv. */
-               iucv_cpuid = smp_get_cpu(CPU_MASK_ALL);
-               spin_unlock_irqrestore (&iucv_lock, flags);
-               smp_call_function_on(iucv_declare_buffer_cpuid,
-                       &b2f0_result, 0, 1, iucv_cpuid);
-               if (b2f0_result) {
-                       smp_put_cpu(iucv_cpuid);
-                       iucv_cpuid = -1;
-               }
-               iucv_debug(1, "Address of EIB = %p", iucv_external_int_buffer);
-       } else {
-               spin_unlock_irqrestore (&iucv_lock, flags);
-               b2f0_result = 0;
-       }
-       iucv_debug(1, "exiting");
-       return b2f0_result;
-}
-
-/**
- * iucv_retrieve_buffer:
- *
- * Terminates all use of IUCV.
- * Returns: return code from CP
- */
-static int
-iucv_retrieve_buffer (void)
-{
-       iucv_debug(1, "entering");
-       if (iucv_cpuid != -1) {
-               smp_call_function_on(iucv_retrieve_buffer_cpuid,
-                                    NULL, 0, 1, iucv_cpuid);
-               /* Release the cpu reserved by iucv_declare_buffer. */
-               smp_put_cpu(iucv_cpuid);
-               iucv_cpuid = -1;
-       }
-       iucv_debug(1, "exiting");
-       return 0;
-}
-
-/**
- * iucv_remove_handler:
- * @users_handler: handler to be removed
- *
- * Remove handler when application unregisters.
- */
-static void
-iucv_remove_handler(handler *handler)
-{
-       unsigned long flags;
-
-       if ((!iucv_pathid_table) || (!handler))
-               return;
-
-       iucv_debug(1, "entering");
-
-       spin_lock_irqsave (&iucv_lock, flags);
-       list_del(&handler->list);
-       if (list_empty(&iucv_handler_table)) {
-               if (register_flag) {
-                       unregister_external_interrupt(0x4000, iucv_irq_handler);
-                       register_flag = 0;
-               }
-       }
-       spin_unlock_irqrestore (&iucv_lock, flags);
-
-       iucv_debug(1, "exiting");
-       return;
-}
-
-/**
- * iucv_register_program:
- * @pgmname:  user identification
- * @userid:   machine identification
- * @pgmmask:  Indicates which bits in the pgmname and userid combined will be
- *            used to determine who is given control.
- * @ops:      Address of interrupt handler table.
- * @pgm_data: Application data to be passed to interrupt handlers.
- *
- * Registers an application with IUCV.
- * Returns:
- *           The address of handler, or NULL on failure.
- * NOTE on pgmmask:
- *   If pgmname, userid and pgmmask are provided, pgmmask is entered into the
- *   handler as is.
- *   If pgmmask is NULL, the internal mask is set to all 0xff's
- *   When userid is NULL, the first 8 bytes of the internal mask are forced
- *   to 0x00.
- *   If pgmmask and userid are NULL, the first 8 bytes of the internal mask
- *   are forced to 0x00 and the last 16 bytes to 0xff.
- */
-
-iucv_handle_t
-iucv_register_program (__u8 pgmname[16],
-                      __u8 userid[8],
-                      __u8 pgmmask[24],
-                      iucv_interrupt_ops_t * ops, void *pgm_data)
-{
-       ulong rc = 0;           /* return code from function calls */
-       handler *new_handler;
-
-       iucv_debug(1, "entering");
-
-       if (ops == NULL) {
-               /* interrupt table is not defined */
-               printk(KERN_WARNING "%s: Interrupt table is not defined, "
-                      "exiting\n", __FUNCTION__);
-               return NULL;
-       }
-       if (!pgmname) {
-               printk(KERN_WARNING "%s: pgmname not provided\n", __FUNCTION__);
-               return NULL;
-       }
-
-       /* Allocate handler entry */
-       new_handler = kmalloc(sizeof(handler), GFP_ATOMIC);
-       if (new_handler == NULL) {
-               printk(KERN_WARNING "%s: storage allocation for new handler "
-                      "failed.\n", __FUNCTION__);
-               return NULL;
-       }
-
-       if (!iucv_pathid_table) {
-               if (iucv_init()) {
-                       kfree(new_handler);
-                       return NULL;
-               }
-
-               max_connections = iucv_query_maxconn();
-               iucv_pathid_table = kcalloc(max_connections, sizeof(handler *),
-                                       GFP_ATOMIC);
-               if (iucv_pathid_table == NULL) {
-                       printk(KERN_WARNING "%s: iucv_pathid_table storage "
-                              "allocation failed\n", __FUNCTION__);
-                       kfree(new_handler);
-                       return NULL;
-               }
-       }
-       memset(new_handler, 0, sizeof (handler));
-       memcpy(new_handler->id.user_data, pgmname,
-               sizeof (new_handler->id.user_data));
-       if (userid) {
-               memcpy (new_handler->id.userid, userid,
-                       sizeof (new_handler->id.userid));
-               ASCEBC (new_handler->id.userid,
-                       sizeof (new_handler->id.userid));
-               EBC_TOUPPER (new_handler->id.userid,
-                            sizeof (new_handler->id.userid));
-
-               if (pgmmask) {
-                       memcpy (new_handler->id.mask, pgmmask,
-                               sizeof (new_handler->id.mask));
-               } else {
-                       memset (new_handler->id.mask, 0xFF,
-                               sizeof (new_handler->id.mask));
-               }
-       } else {
-               if (pgmmask) {
-                       memcpy (new_handler->id.mask, pgmmask,
-                               sizeof (new_handler->id.mask));
-               } else {
-                       memset (new_handler->id.mask, 0xFF,
-                               sizeof (new_handler->id.mask));
-               }
-               memset (new_handler->id.userid, 0x00,
-                       sizeof (new_handler->id.userid));
-       }
-       /* fill in the rest of handler */
-       new_handler->pgm_data = pgm_data;
-       new_handler->interrupt_table = ops;
-
-       /*
-        * Check if someone else is registered with same pgmname, userid
-        * and mask. If someone is already registered with same pgmname,
-        * userid and mask, registration will fail and NULL will be returned
-        * to the application.
-        * If identical handler not found, then handler is added to list.
-        */
-       rc = iucv_add_handler(new_handler);
-       if (rc) {
-               printk(KERN_WARNING "%s: Someone already registered with same "
-                      "pgmname, userid, pgmmask\n", __FUNCTION__);
-               kfree (new_handler);
-               return NULL;
-       }
-
-       rc = iucv_declare_buffer();
-       if (rc) {
-               char *err = "Unknown";
-               iucv_remove_handler(new_handler);
-               kfree(new_handler);
-               switch(rc) {
-               case 0x03:
-                       err = "Directory error";
-                       break;
-               case 0x0a:
-                       err = "Invalid length";
-                       break;
-               case 0x13:
-                       err = "Buffer already exists";
-                       break;
-               case 0x3e:
-                       err = "Buffer overlap";
-                       break;
-               case 0x5c:
-                       err = "Paging or storage error";
-                       break;
-               }
-               printk(KERN_WARNING "%s: iucv_declare_buffer "
-                      "returned error 0x%02lx (%s)\n", __FUNCTION__, rc, err);
-               return NULL;
-       }
-       if (!register_flag) {
-               /* request the 0x4000 external interrupt */
-               rc = register_external_interrupt (0x4000, iucv_irq_handler);
-               if (rc) {
-                       iucv_remove_handler(new_handler);
-                       kfree (new_handler);
-                       printk(KERN_WARNING "%s: "
-                              "register_external_interrupt returned %ld\n",
-                              __FUNCTION__, rc);
-                       return NULL;
-
-               }
-               register_flag = 1;
-       }
-       iucv_debug(1, "exiting");
-       return new_handler;
-}                              /* end of register function */
-
-/**
- * iucv_unregister_program:
- * @handle: address of handler
- *
- * Unregister application with IUCV.
- * Returns:
- *   0 on success, -EINVAL, if specified handle is invalid.
- */
-
-int
-iucv_unregister_program (iucv_handle_t handle)
-{
-       handler *h = NULL;
-       struct list_head *lh;
-       int i;
-       ulong flags;
-
-       iucv_debug(1, "entering");
-       iucv_debug(1, "address of handler is %p", h);
-
-       /* Checking if handle is valid  */
-       spin_lock_irqsave (&iucv_lock, flags);
-       list_for_each(lh, &iucv_handler_table) {
-               if ((handler *)handle == list_entry(lh, handler, list)) {
-                       h = (handler *)handle;
-                       break;
-               }
-       }
-       if (!h) {
-               spin_unlock_irqrestore (&iucv_lock, flags);
-               if (handle)
-                       printk(KERN_WARNING
-                              "%s: Handler not found in iucv_handler_table.\n",
-                              __FUNCTION__);
-               else
-                       printk(KERN_WARNING
-                              "%s: NULL handle passed by application.\n",
-                              __FUNCTION__);
-               return -EINVAL;
-       }
-
-       /**
-        * First, walk thru iucv_pathid_table and sever any pathid which is
-        * still pointing to the handler to be removed.
-        */
-       for (i = 0; i < max_connections; i++)
-               if (iucv_pathid_table[i] == h) {
-                       spin_unlock_irqrestore (&iucv_lock, flags);
-                       iucv_sever(i, h->id.user_data);
-                       spin_lock_irqsave(&iucv_lock, flags);
-               }
-       spin_unlock_irqrestore (&iucv_lock, flags);
-
-       iucv_remove_handler(h);
-       kfree(h);
-
-       iucv_debug(1, "exiting");
-       return 0;
-}
-
-/**
- * iucv_accept:
- * @pathid:             Path identification number
- * @msglim_reqstd:      The number of outstanding messages requested.
- * @user_data:          Data specified by the iucv_connect function.
- * @flags1:             Contains options for this path.
- *     - IPPRTY (0x20)   Specifies if you want to send priority message.
- *     - IPRMDATA (0x80) Specifies whether your program can handle a message
- *                       in the parameter list.
- *     - IPQUSCE (0x40)  Specifies whether you want to quiesce the path being
- *                      established.
- * @handle:             Address of handler.
- * @pgm_data:           Application data passed to interrupt handlers.
- * @flags1_out:         Pointer to an int. If not NULL, on return the options for
- *                      the path are stored at the given location:
- *     - IPPRTY (0x20)  Indicates you may send a priority message.
- * @msglim:             Pointer to an __u16. If not NULL, on return the maximum
- *                      number of outstanding messages is stored at the given
- *                      location.
- *
- * This function is issued after the user receives a Connection Pending external
- * interrupt and now wishes to complete the IUCV communication path.
- * Returns:
- *   return code from CP
- */
-int
-iucv_accept(__u16 pathid, __u16 msglim_reqstd,
-            __u8 user_data[16], int flags1,
-            iucv_handle_t handle, void *pgm_data,
-            int *flags1_out, __u16 * msglim)
-{
-       ulong b2f0_result = 0;
-       ulong flags;
-       struct list_head *lh;
-       handler *h = NULL;
-       iparml_control *parm;
-
-       iucv_debug(1, "entering");
-       iucv_debug(1, "pathid = %d", pathid);
-
-       /* Checking if handle is valid  */
-       spin_lock_irqsave (&iucv_lock, flags);
-       list_for_each(lh, &iucv_handler_table) {
-               if ((handler *)handle == list_entry(lh, handler, list)) {
-                       h = (handler *)handle;
-                       break;
-               }
-       }
-       spin_unlock_irqrestore (&iucv_lock, flags);
-
-       if (!h) {
-               if (handle)
-                       printk(KERN_WARNING
-                              "%s: Handler not found in iucv_handler_table.\n",
-                              __FUNCTION__);
-               else
-                       printk(KERN_WARNING
-                              "%s: NULL handle passed by application.\n",
-                              __FUNCTION__);
-               return -EINVAL;
-       }
-
-       parm = (iparml_control *)grab_param();
-
-       parm->ippathid = pathid;
-       parm->ipmsglim = msglim_reqstd;
-       if (user_data)
-               memcpy(parm->ipuser, user_data, sizeof(parm->ipuser));
-
-       parm->ipflags1 = (__u8)flags1;
-       b2f0_result = b2f0(ACCEPT, parm);
-
-       if (!b2f0_result) {
-               if (msglim)
-                       *msglim = parm->ipmsglim;
-               if (pgm_data)
-                       h->pgm_data = pgm_data;
-               if (flags1_out)
-                       *flags1_out = (parm->ipflags1 & IPPRTY) ? IPPRTY : 0;
-       }
-       release_param(parm);
-
-       iucv_debug(1, "exiting");
-       return b2f0_result;
-}
-
-/**
- * iucv_connect:
- * @pathid:        Path identification number
- * @msglim_reqstd: Number of outstanding messages requested
- * @user_data:     16-byte user data
- * @userid:        8-byte of user identification
- * @system_name:   8-byte identifying the system name
- * @flags1:        Specifies options for this path:
- *     - IPPRTY (0x20)   Specifies if you want to send priority message.
- *     - IPRMDATA (0x80) Specifies whether your program can handle a message
- *                       in  the parameter list.
- *     - IPQUSCE (0x40)  Specifies whether you want to quiesce the path being
- *                       established.
- *     - IPLOCAL (0x01)  Allows an application to force the partner to be on the
- *                       local system. If local is specified then target class
- *                       cannot be specified.
- * @flags1_out:    Pointer to an int. If not NULL, on return the options for
- *                 the path are stored at the given location:
- *     - IPPRTY (0x20)   Indicates you may send a priority message.
- * @msglim:        Pointer to an __u16. If not NULL, on return the maximum
- *                 number of outstanding messages is stored at the given
- *                 location.
- * @handle:        Address of handler.
- * @pgm_data:      Application data to be passed to interrupt handlers.
- *
- * This function establishes an IUCV path. Although the connect may complete
- * successfully, you are not able to use the path until you receive an IUCV
- * Connection Complete external interrupt.
- * Returns: return code from CP, or one of the following
- *     - ENOMEM
- *     - return code from iucv_declare_buffer
- *     - EINVAL - invalid handle passed by application
- *     - EINVAL - pathid address is NULL
- *     - ENOMEM - pathid table storage allocation failed
- *     - return code from internal function add_pathid
- */
-int
-iucv_connect (__u16 *pathid, __u16 msglim_reqstd,
-             __u8 user_data[16], __u8 userid[8],
-             __u8 system_name[8], int flags1,
-             int *flags1_out, __u16 * msglim,
-             iucv_handle_t handle, void *pgm_data)
-{
-       iparml_control *parm;
-       iparml_control local_parm;
-       struct list_head *lh;
-       ulong b2f0_result = 0;
-       ulong flags;
-       int add_pathid_result = 0;
-       handler *h = NULL;
-       __u8 no_memory[16] = "NO MEMORY";
-
-       iucv_debug(1, "entering");
-
-       /* Checking if handle is valid  */
-       spin_lock_irqsave (&iucv_lock, flags);
-       list_for_each(lh, &iucv_handler_table) {
-               if ((handler *)handle == list_entry(lh, handler, list)) {
-                       h = (handler *)handle;
-                       break;
-               }
-       }
-       spin_unlock_irqrestore (&iucv_lock, flags);
-
-       if (!h) {
-               if (handle)
-                       printk(KERN_WARNING
-                              "%s: Handler not found in iucv_handler_table.\n",
-                              __FUNCTION__);
-               else
-                       printk(KERN_WARNING
-                              "%s: NULL handle passed by application.\n",
-                              __FUNCTION__);
-               return -EINVAL;
-       }
-
-       if (pathid == NULL) {
-               printk(KERN_WARNING "%s: NULL pathid pointer\n",
-                      __FUNCTION__);
-               return -EINVAL;
-       }
-
-       parm = (iparml_control *)grab_param();
-
-       parm->ipmsglim = msglim_reqstd;
-
-       if (user_data)
-               memcpy(parm->ipuser, user_data, sizeof(parm->ipuser));
-
-       if (userid) {
-               memcpy(parm->ipvmid, userid, sizeof(parm->ipvmid));
-               ASCEBC(parm->ipvmid, sizeof(parm->ipvmid));
-               EBC_TOUPPER(parm->ipvmid, sizeof(parm->ipvmid));
-       }
-
-       if (system_name) {
-               memcpy(parm->iptarget, system_name, sizeof(parm->iptarget));
-               ASCEBC(parm->iptarget, sizeof(parm->iptarget));
-               EBC_TOUPPER(parm->iptarget, sizeof(parm->iptarget));
-       }
-
-       /* In order to establish an IUCV connection, the procedure is:
-         *
-         * b2f0(CONNECT)
-         * take the ippathid from the b2f0 call
-         * register the handler to the ippathid
-         *
-         * Unfortunately, the ConnectionEstablished message gets sent after the
-         * b2f0(CONNECT) call but before the register is handled.
-         *
-         * In order for this race condition to be eliminated, the IUCV Control
-         * Interrupts must be disabled for the above procedure.
-         *
-         * David Kennedy <dkennedy@linuxcare.com>
-         */
-
-       /* Enable everything but IUCV Control messages */
-       iucv_setmask(~(AllInterrupts));
-       messagesDisabled = 1;
-
-       spin_lock_irqsave (&iucv_lock, flags);
-       parm->ipflags1 = (__u8)flags1;
-       b2f0_result = b2f0(CONNECT, parm);
-       memcpy(&local_parm, parm, sizeof(local_parm));
-       release_param(parm);
-       parm = &local_parm;
-       if (!b2f0_result)
-               add_pathid_result = __iucv_add_pathid(parm->ippathid, h);
-       spin_unlock_irqrestore (&iucv_lock, flags);
-
-       if (b2f0_result) {
-               iucv_setmask(~0);
-               messagesDisabled = 0;
-               return b2f0_result;
-       }
-
-       *pathid = parm->ippathid;
-
-       /* Enable everything again */
-       iucv_setmask(IUCVControlInterruptsFlag);
-
-       if (msglim)
-               *msglim = parm->ipmsglim;
-       if (flags1_out)
-               *flags1_out = (parm->ipflags1 & IPPRTY) ? IPPRTY : 0;
-
-       if (add_pathid_result) {
-               iucv_sever(*pathid, no_memory);
-               printk(KERN_WARNING "%s: add_pathid failed with rc ="
-                       " %d\n", __FUNCTION__, add_pathid_result);
-               return(add_pathid_result);
-       }
-
-       iucv_debug(1, "exiting");
-       return b2f0_result;
-}
-
-/**
- * iucv_purge:
- * @pathid: Path identification number
- * @msgid:  Message ID of message to purge.
- * @srccls: Message class of the message to purge.
- * @audit:  Pointer to an __u32. If not NULL, on return, information about
- *          asynchronous errors that may have affected the normal completion
- *          of this message ist stored at the given location.
- *
- * Cancels a message you have sent.
- * Returns: return code from CP
- */
-int
-iucv_purge (__u16 pathid, __u32 msgid, __u32 srccls, __u32 *audit)
-{
-       iparml_purge *parm;
-       ulong b2f0_result = 0;
-
-       iucv_debug(1, "entering");
-       iucv_debug(1, "pathid = %d", pathid);
-
-       parm = (iparml_purge *)grab_param();
-
-       parm->ipmsgid = msgid;
-       parm->ippathid = pathid;
-       parm->ipsrccls = srccls;
-       parm->ipflags1 |= (IPSRCCLS | IPFGMID | IPFGPID);
-       b2f0_result = b2f0(PURGE, parm);
-
-       if (!b2f0_result && audit) {
-               memcpy(audit, parm->ipaudit, sizeof(parm->ipaudit));
-               /* parm->ipaudit has only 3 bytes */
-               *audit >>= 8;
-       }
-
-       release_param(parm);
-
-       iucv_debug(1, "b2f0_result = %ld", b2f0_result);
-       iucv_debug(1, "exiting");
-       return b2f0_result;
-}
-
-/**
- * iucv_query_generic:
- * @want_maxconn: Flag, describing which value is to be returned.
- *
- * Helper function for iucv_query_maxconn() and iucv_query_bufsize().
- *
- * Returns: The buffersize, if want_maxconn is 0; the maximum number of
- *           connections, if want_maxconn is 1 or an error-code < 0 on failure.
- */
-static int
-iucv_query_generic(int want_maxconn)
-{
-       register unsigned long reg0 asm ("0");
-       register unsigned long reg1 asm ("1");
-       iparml_purge *parm = (iparml_purge *)grab_param();
-       int bufsize, maxconn;
-       int ccode;
-
-       /**
-        * Call b2f0 and store R0 (max buffer size),
-        * R1 (max connections) and CC.
-        */
-       reg0 = QUERY;
-       reg1 = virt_to_phys(parm);
-       asm volatile(
-               "       .long   0xb2f01000\n"
-               "       ipm     %0\n"
-               "       srl     %0,28\n"
-               : "=d" (ccode), "+d" (reg0), "+d" (reg1) : : "cc");
-       bufsize = reg0;
-       maxconn = reg1;
-       release_param(parm);
-
-       if (ccode)
-               return -EPERM;
-       if (want_maxconn)
-               return maxconn;
-       return bufsize;
-}
-
-/**
- * iucv_query_maxconn:
- *
- * Determines the maximum number of connections thay may be established.
- *
- * Returns: Maximum number of connections that can be.
- */
-ulong
-iucv_query_maxconn(void)
-{
-       return iucv_query_generic(1);
-}
-
-/**
- * iucv_query_bufsize:
- *
- * Determines the size of the external interrupt buffer.
- *
- * Returns: Size of external interrupt buffer.
- */
-ulong
-iucv_query_bufsize (void)
-{
-       return iucv_query_generic(0);
-}
-
-/**
- * iucv_quiesce:
- * @pathid:    Path identification number
- * @user_data: 16-byte user data
- *
- * Temporarily suspends incoming messages on an IUCV path.
- * You can later reactivate the path by invoking the iucv_resume function.
- * Returns: return code from CP
- */
-int
-iucv_quiesce (__u16 pathid, __u8 user_data[16])
-{
-       iparml_control *parm;
-       ulong b2f0_result = 0;
-
-       iucv_debug(1, "entering");
-       iucv_debug(1, "pathid = %d", pathid);
-
-       parm = (iparml_control *)grab_param();
-
-       memcpy(parm->ipuser, user_data, sizeof(parm->ipuser));
-       parm->ippathid = pathid;
-
-       b2f0_result = b2f0(QUIESCE, parm);
-       release_param(parm);
-
-       iucv_debug(1, "b2f0_result = %ld", b2f0_result);
-       iucv_debug(1, "exiting");
-
-       return b2f0_result;
-}
-
-/**
- * iucv_receive:
- * @pathid: Path identification number.
- * @buffer: Address of buffer to receive. Must be below 2G.
- * @buflen: Length of buffer to receive.
- * @msgid:  Specifies the message ID.
- * @trgcls: Specifies target class.
- * @flags1_out: Receives options for path on return.
- *    - IPNORPY (0x10)  Specifies whether a reply is required
- *    - IPPRTY (0x20)   Specifies if you want to send priority message
- *    - IPRMDATA (0x80) Specifies the data is contained in the parameter list
- * @residual_buffer: Receives the address of buffer updated by the number
- *                   of bytes you have received on return.
- * @residual_length: On return, receives one of the following values:
- *    - 0                          If the receive buffer is the same length as
- *                                 the message.
- *    - Remaining bytes in buffer  If the receive buffer is longer than the
- *                                 message.
- *    - Remaining bytes in message If the receive buffer is shorter than the
- *                                 message.
- *
- * This function receives messages that are being sent to you over established
- * paths.
- * Returns: return code from CP IUCV call; If the receive buffer is shorter
- *   than the message, always 5
- *   -EINVAL - buffer address is pointing to NULL
- */
-int
-iucv_receive (__u16 pathid, __u32 msgid, __u32 trgcls,
-             void *buffer, ulong buflen,
-             int *flags1_out, ulong * residual_buffer, ulong * residual_length)
-{
-       iparml_db *parm;
-       ulong b2f0_result;
-       int moved = 0;  /* number of bytes moved from parmlist to buffer */
-
-       iucv_debug(2, "entering");
-
-       if (!buffer)
-               return -EINVAL;
-
-       parm = (iparml_db *)grab_param();
-
-       parm->ipbfadr1 = (__u32) (addr_t) buffer;
-       parm->ipbfln1f = (__u32) ((ulong) buflen);
-       parm->ipmsgid = msgid;
-       parm->ippathid = pathid;
-       parm->iptrgcls = trgcls;
-       parm->ipflags1 = (IPFGPID | IPFGMID | IPFGMCL);
-
-       b2f0_result = b2f0(RECEIVE, parm);
-
-       if (!b2f0_result || b2f0_result == 5) {
-               if (flags1_out) {
-                       iucv_debug(2, "*flags1_out = %d", *flags1_out);
-                       *flags1_out = (parm->ipflags1 & (~0x07));
-                       iucv_debug(2, "*flags1_out = %d", *flags1_out);
-               }
-
-               if (!(parm->ipflags1 & IPRMDATA)) {     /*msg not in parmlist */
-                       if (residual_length)
-                               *residual_length = parm->ipbfln1f;
-
-                       if (residual_buffer)
-                               *residual_buffer = parm->ipbfadr1;
-               } else {
-                       moved = min_t (unsigned long, buflen, 8);
-
-                       memcpy ((char *) buffer,
-                               (char *) &parm->ipbfadr1, moved);
-
-                       if (buflen < 8)
-                               b2f0_result = 5;
-
-                       if (residual_length)
-                               *residual_length = abs (buflen - 8);
-
-                       if (residual_buffer)
-                               *residual_buffer = (ulong) (buffer + moved);
-               }
-       }
-       release_param(parm);
-
-       iucv_debug(2, "exiting");
-       return b2f0_result;
-}
-
-/*
- * Name: iucv_receive_array
- * Purpose: This function receives messages that are being sent to you
- *          over established paths.
- * Input: pathid - path identification number
- *        buffer - address of array of buffers
- *        buflen - total length of buffers
- *        msgid - specifies the message ID.
- *        trgcls - specifies target class
- * Output:
- *        flags1_out: Options for path.
- *          IPNORPY - 0x10 specifies whether a reply is required
- *          IPPRTY - 0x20 specifies if you want to send priority message
- *         IPRMDATA - 0x80 specifies the data is contained in the parameter list
- *       residual_buffer - address points to the current list entry IUCV
- *                         is working on.
- *       residual_length -
- *              Contains one of the following values, if the receive buffer is:
- *               The same length as the message, this field is zero.
- *               Longer than the message, this field contains the number of
- *                bytes remaining in the buffer.
- *               Shorter than the message, this field contains the residual
- *                count (that is, the number of bytes remaining in the
- *                message that does not fit into the buffer. In this case
- *               b2f0_result = 5.
- * Return: b2f0_result - return code from CP
- *         (-EINVAL) - buffer address is NULL
- */
-int
-iucv_receive_array (__u16 pathid,
-                   __u32 msgid, __u32 trgcls,
-                   iucv_array_t * buffer, ulong buflen,
-                   int *flags1_out,
-                   ulong * residual_buffer, ulong * residual_length)
-{
-       iparml_db *parm;
-       ulong b2f0_result;
-       int i = 0, moved = 0, need_to_move = 8, dyn_len;
-
-       iucv_debug(2, "entering");
-
-       if (!buffer)
-               return -EINVAL;
-
-       parm = (iparml_db *)grab_param();
-
-       parm->ipbfadr1 = (__u32) ((ulong) buffer);
-       parm->ipbfln1f = (__u32) buflen;
-       parm->ipmsgid = msgid;
-       parm->ippathid = pathid;
-       parm->iptrgcls = trgcls;
-       parm->ipflags1 = (IPBUFLST | IPFGPID | IPFGMID | IPFGMCL);
-
-       b2f0_result = b2f0(RECEIVE, parm);
-
-       if (!b2f0_result || b2f0_result == 5) {
-
-               if (flags1_out) {
-                       iucv_debug(2, "*flags1_out = %d", *flags1_out);
-                       *flags1_out = (parm->ipflags1 & (~0x07));
-                       iucv_debug(2, "*flags1_out = %d", *flags1_out);
-               }
-
-               if (!(parm->ipflags1 & IPRMDATA)) {     /*msg not in parmlist */
-
-                       if (residual_length)
-                               *residual_length = parm->ipbfln1f;
-
-                       if (residual_buffer)
-                               *residual_buffer = parm->ipbfadr1;
-
-               } else {
-                       /* copy msg from parmlist to users array. */
-
-                       while ((moved < 8) && (moved < buflen)) {
-                               dyn_len =
-                                   min_t (unsigned int,
-                                        (buffer + i)->length, need_to_move);
-
-                               memcpy ((char *)((ulong)((buffer + i)->address)),
-                                       ((char *) &parm->ipbfadr1) + moved,
-                                       dyn_len);
-
-                               moved += dyn_len;
-                               need_to_move -= dyn_len;
-
-                               (buffer + i)->address =
-                                       (__u32)
-                               ((ulong)(__u8 *) ((ulong)(buffer + i)->address)
-                                               + dyn_len);
-
-                               (buffer + i)->length -= dyn_len;
-                               i++;
-                       }
-
-                       if (need_to_move)       /* buflen < 8 bytes */
-                               b2f0_result = 5;
-
-                       if (residual_length)
-                               *residual_length = abs (buflen - 8);
-
-                       if (residual_buffer) {
-                               if (!moved)
-                                       *residual_buffer = (ulong) buffer;
-                               else
-                                       *residual_buffer =
-                                           (ulong) (buffer + (i - 1));
-                       }
-
-               }
-       }
-       release_param(parm);
-
-       iucv_debug(2, "exiting");
-       return b2f0_result;
-}
-
-/**
- * iucv_reject:
- * @pathid: Path identification number.
- * @msgid:  Message ID of the message to reject.
- * @trgcls: Target class of the message to reject.
- * Returns: return code from CP
- *
- * Refuses a specified message. Between the time you are notified of a
- * message and the time that you complete the message, the message may
- * be rejected.
- */
-int
-iucv_reject (__u16 pathid, __u32 msgid, __u32 trgcls)
-{
-       iparml_db *parm;
-       ulong b2f0_result = 0;
-
-       iucv_debug(1, "entering");
-       iucv_debug(1, "pathid = %d", pathid);
-
-       parm = (iparml_db *)grab_param();
-
-       parm->ippathid = pathid;
-       parm->ipmsgid = msgid;
-       parm->iptrgcls = trgcls;
-       parm->ipflags1 = (IPFGMCL | IPFGMID | IPFGPID);
-
-       b2f0_result = b2f0(REJECT, parm);
-       release_param(parm);
-
-       iucv_debug(1, "b2f0_result = %ld", b2f0_result);
-       iucv_debug(1, "exiting");
-
-       return b2f0_result;
-}
-
-/*
- * Name: iucv_reply
- * Purpose: This function responds to the two-way messages that you
- *          receive. You must identify completely the message to
- *          which you wish to reply. ie, pathid, msgid, and trgcls.
- * Input: pathid - path identification number
- *        msgid - specifies the message ID.
- *        trgcls - specifies target class
- *        flags1 - option for path
- *                 IPPRTY- 0x20 - specifies if you want to send priority message
- *        buffer - address of reply buffer
- *        buflen - length of reply buffer
- * Output: ipbfadr2 - Address of buffer updated by the number
- *                    of bytes you have moved.
- *         ipbfln2f - Contains one of the following values:
- *              If the answer buffer is the same length as the reply, this field
- *               contains zero.
- *              If the answer buffer is longer than the reply, this field contains
- *               the number of bytes remaining in the buffer.
- *              If the answer buffer is shorter than the reply, this field contains
- *               a residual count (that is, the number of bytes remianing in the
- *               reply that does not fit into the buffer. In this
- *                case b2f0_result = 5.
- * Return: b2f0_result - return code from CP
- *         (-EINVAL) - buffer address is NULL
- */
-int
-iucv_reply (__u16 pathid,
-           __u32 msgid, __u32 trgcls,
-           int flags1,
-           void *buffer, ulong buflen, ulong * ipbfadr2, ulong * ipbfln2f)
-{
-       iparml_db *parm;
-       ulong b2f0_result;
-
-       iucv_debug(2, "entering");
-
-       if (!buffer)
-               return -EINVAL;
-
-       parm = (iparml_db *)grab_param();
-
-       parm->ipbfadr2 = (__u32) ((ulong) buffer);
-       parm->ipbfln2f = (__u32) buflen;        /* length of message */
-       parm->ippathid = pathid;
-       parm->ipmsgid = msgid;
-       parm->iptrgcls = trgcls;
-       parm->ipflags1 = (__u8) flags1; /* priority message */
-
-       b2f0_result = b2f0(REPLY, parm);
-
-       if ((!b2f0_result) || (b2f0_result == 5)) {
-               if (ipbfadr2)
-                       *ipbfadr2 = parm->ipbfadr2;
-               if (ipbfln2f)
-                       *ipbfln2f = parm->ipbfln2f;
-       }
-       release_param(parm);
-
-       iucv_debug(2, "exiting");
-
-       return b2f0_result;
-}
-
-/*
- * Name: iucv_reply_array
- * Purpose: This function responds to the two-way messages that you
- *          receive. You must identify completely the message to
- *          which you wish to reply. ie, pathid, msgid, and trgcls.
- *          The array identifies a list of addresses and lengths of
- *          discontiguous buffers that contains the reply data.
- * Input: pathid - path identification number
- *        msgid - specifies the message ID.
- *        trgcls - specifies target class
- *        flags1 - option for path
- *                 IPPRTY- specifies if you want to send priority message
- *        buffer - address of array of reply buffers
- *        buflen - total length of reply buffers
- * Output: ipbfadr2 - Address of buffer which IUCV is currently working on.
- *         ipbfln2f - Contains one of the following values:
- *              If the answer buffer is the same length as the reply, this field
- *               contains zero.
- *              If the answer buffer is longer than the reply, this field contains
- *               the number of bytes remaining in the buffer.
- *              If the answer buffer is shorter than the reply, this field contains
- *               a residual count (that is, the number of bytes remianing in the
- *               reply that does not fit into the buffer. In this
- *               case b2f0_result = 5.
- * Return: b2f0_result - return code from CP
- *             (-EINVAL) - buffer address is NULL
-*/
-int
-iucv_reply_array (__u16 pathid,
-                 __u32 msgid, __u32 trgcls,
-                 int flags1,
-                 iucv_array_t * buffer,
-                 ulong buflen, ulong * ipbfadr2, ulong * ipbfln2f)
-{
-       iparml_db *parm;
-       ulong b2f0_result;
-
-       iucv_debug(2, "entering");
-
-       if (!buffer)
-               return -EINVAL;
-
-       parm = (iparml_db *)grab_param();
-
-       parm->ipbfadr2 = (__u32) ((ulong) buffer);
-       parm->ipbfln2f = buflen;        /* length of message */
-       parm->ippathid = pathid;
-       parm->ipmsgid = msgid;
-       parm->iptrgcls = trgcls;
-       parm->ipflags1 = (IPANSLST | flags1);
-
-       b2f0_result = b2f0(REPLY, parm);
-
-       if ((!b2f0_result) || (b2f0_result == 5)) {
-
-               if (ipbfadr2)
-                       *ipbfadr2 = parm->ipbfadr2;
-               if (ipbfln2f)
-                       *ipbfln2f = parm->ipbfln2f;
-       }
-       release_param(parm);
-
-       iucv_debug(2, "exiting");
-
-       return b2f0_result;
-}
-
-/*
- * Name: iucv_reply_prmmsg
- * Purpose: This function responds to the two-way messages that you
- *          receive. You must identify completely the message to
- *          which you wish to reply. ie, pathid, msgid, and trgcls.
- *          Prmmsg signifies the data is moved into the
- *          parameter list.
- * Input: pathid - path identification number
- *        msgid - specifies the message ID.
- *        trgcls - specifies target class
- *        flags1 - option for path
- *                 IPPRTY- specifies if you want to send priority message
- *        prmmsg - 8-bytes of data to be placed into the parameter
- *                 list.
- * Output: NA
- * Return: b2f0_result - return code from CP
-*/
-int
-iucv_reply_prmmsg (__u16 pathid,
-                  __u32 msgid, __u32 trgcls, int flags1, __u8 prmmsg[8])
-{
-       iparml_dpl *parm;
-       ulong b2f0_result;
-
-       iucv_debug(2, "entering");
-
-       parm = (iparml_dpl *)grab_param();
-
-       parm->ippathid = pathid;
-       parm->ipmsgid = msgid;
-       parm->iptrgcls = trgcls;
-       memcpy(parm->iprmmsg, prmmsg, sizeof (parm->iprmmsg));
-       parm->ipflags1 = (IPRMDATA | flags1);
-
-       b2f0_result = b2f0(REPLY, parm);
-       release_param(parm);
-
-       iucv_debug(2, "exiting");
-
-       return b2f0_result;
-}
-
-/**
- * iucv_resume:
- * @pathid:    Path identification number
- * @user_data: 16-byte of user data
- *
- * This function restores communication over a quiesced path.
- * Returns: return code from CP
- */
-int
-iucv_resume (__u16 pathid, __u8 user_data[16])
-{
-       iparml_control *parm;
-       ulong b2f0_result = 0;
-
-       iucv_debug(1, "entering");
-       iucv_debug(1, "pathid = %d", pathid);
-
-       parm = (iparml_control *)grab_param();
-
-       memcpy (parm->ipuser, user_data, sizeof (*user_data));
-       parm->ippathid = pathid;
-
-       b2f0_result = b2f0(RESUME, parm);
-       release_param(parm);
-
-       iucv_debug(1, "exiting");
-
-       return b2f0_result;
-}
-
-/*
- * Name: iucv_send
- * Purpose: sends messages
- * Input: pathid - ushort, pathid
- *        msgid  - ulong *, id of message returned to caller
- *        trgcls - ulong, target message class
- *        srccls - ulong, source message class
- *        msgtag - ulong, message tag
- *       flags1  - Contains options for this path.
- *             IPPRTY - Ox20 - specifies if you want to send a priority message.
- *        buffer - pointer to buffer
- *        buflen - ulong, length of buffer
- * Output: b2f0_result - return code from b2f0 call
- *         msgid - returns message id
- */
-int
-iucv_send (__u16 pathid, __u32 * msgid,
-          __u32 trgcls, __u32 srccls,
-          __u32 msgtag, int flags1, void *buffer, ulong buflen)
-{
-       iparml_db *parm;
-       ulong b2f0_result;
-
-       iucv_debug(2, "entering");
-
-       if (!buffer)
-               return -EINVAL;
-
-       parm = (iparml_db *)grab_param();
-
-       parm->ipbfadr1 = (__u32) ((ulong) buffer);
-       parm->ippathid = pathid;
-       parm->iptrgcls = trgcls;
-       parm->ipbfln1f = (__u32) buflen;        /* length of message */
-       parm->ipsrccls = srccls;
-       parm->ipmsgtag = msgtag;
-       parm->ipflags1 = (IPNORPY | flags1);    /* one way priority message */
-
-       b2f0_result = b2f0(SEND, parm);
-
-       if ((!b2f0_result) && (msgid))
-               *msgid = parm->ipmsgid;
-       release_param(parm);
-
-       iucv_debug(2, "exiting");
-
-       return b2f0_result;
-}
-
-/*
- * Name: iucv_send_array
- * Purpose: This function transmits data to another application.
- *          The contents of buffer is the address of the array of
- *          addresses and lengths of discontiguous buffers that hold
- *          the message text. This is a one-way message and the
- *          receiver will not reply to the message.
- * Input: pathid - path identification number
- *        trgcls - specifies target class
- *        srccls - specifies the source message class
- *        msgtag - specifies a tag to be associated witht the message
- *        flags1 - option for path
- *                 IPPRTY- specifies if you want to send priority message
- *        buffer - address of array of send buffers
- *        buflen - total length of send buffers
- * Output: msgid - specifies the message ID.
- * Return: b2f0_result - return code from CP
- *         (-EINVAL) - buffer address is NULL
- */
-int
-iucv_send_array (__u16 pathid,
-                __u32 * msgid,
-                __u32 trgcls,
-                __u32 srccls,
-                __u32 msgtag, int flags1, iucv_array_t * buffer, ulong buflen)
-{
-       iparml_db *parm;
-       ulong b2f0_result;
-
-       iucv_debug(2, "entering");
-
-       if (!buffer)
-               return -EINVAL;
-
-       parm = (iparml_db *)grab_param();
-
-       parm->ippathid = pathid;
-       parm->iptrgcls = trgcls;
-       parm->ipbfadr1 = (__u32) ((ulong) buffer);
-       parm->ipbfln1f = (__u32) buflen;        /* length of message */
-       parm->ipsrccls = srccls;
-       parm->ipmsgtag = msgtag;
-       parm->ipflags1 = (IPNORPY | IPBUFLST | flags1);
-       b2f0_result = b2f0(SEND, parm);
-
-       if ((!b2f0_result) && (msgid))
-               *msgid = parm->ipmsgid;
-       release_param(parm);
-
-       iucv_debug(2, "exiting");
-       return b2f0_result;
-}
-
-/*
- * Name: iucv_send_prmmsg
- * Purpose: This function transmits data to another application.
- *          Prmmsg specifies that the 8-bytes of data are to be moved
- *          into the parameter list. This is a one-way message and the
- *          receiver will not reply to the message.
- * Input: pathid - path identification number
- *        trgcls - specifies target class
- *        srccls - specifies the source message class
- *        msgtag - specifies a tag to be associated with the message
- *        flags1 - option for path
- *                 IPPRTY- specifies if you want to send priority message
- *        prmmsg - 8-bytes of data to be placed into parameter list
- * Output: msgid - specifies the message ID.
- * Return: b2f0_result - return code from CP
-*/
-int
-iucv_send_prmmsg (__u16 pathid,
-                 __u32 * msgid,
-                 __u32 trgcls,
-                 __u32 srccls, __u32 msgtag, int flags1, __u8 prmmsg[8])
-{
-       iparml_dpl *parm;
-       ulong b2f0_result;
-
-       iucv_debug(2, "entering");
-
-       parm = (iparml_dpl *)grab_param();
-
-       parm->ippathid = pathid;
-       parm->iptrgcls = trgcls;
-       parm->ipsrccls = srccls;
-       parm->ipmsgtag = msgtag;
-       parm->ipflags1 = (IPRMDATA | IPNORPY | flags1);
-       memcpy(parm->iprmmsg, prmmsg, sizeof(parm->iprmmsg));
-
-       b2f0_result = b2f0(SEND, parm);
-
-       if ((!b2f0_result) && (msgid))
-               *msgid = parm->ipmsgid;
-       release_param(parm);
-
-       iucv_debug(2, "exiting");
-
-       return b2f0_result;
-}
-
-/*
- * Name: iucv_send2way
- * Purpose: This function transmits data to another application.
- *          Data to be transmitted is in a buffer. The receiver
- *          of the send is expected to reply to the message and
- *          a buffer is provided into which IUCV moves the reply
- *          to this message.
- * Input: pathid - path identification number
- *        trgcls - specifies target class
- *        srccls - specifies the source message class
- *        msgtag - specifies a tag associated with the message
- *        flags1 - option for path
- *                 IPPRTY- specifies if you want to send priority message
- *        buffer - address of send buffer
- *        buflen - length of send buffer
- *        ansbuf - address of buffer to reply with
- *        anslen - length of buffer to reply with
- * Output: msgid - specifies the message ID.
- * Return: b2f0_result - return code from CP
- *         (-EINVAL) - buffer or ansbuf address is NULL
- */
-int
-iucv_send2way (__u16 pathid,
-              __u32 * msgid,
-              __u32 trgcls,
-              __u32 srccls,
-              __u32 msgtag,
-              int flags1,
-              void *buffer, ulong buflen, void *ansbuf, ulong anslen)
-{
-       iparml_db *parm;
-       ulong b2f0_result;
-
-       iucv_debug(2, "entering");
-
-       if (!buffer || !ansbuf)
-               return -EINVAL;
-
-       parm = (iparml_db *)grab_param();
-
-       parm->ippathid = pathid;
-       parm->iptrgcls = trgcls;
-       parm->ipbfadr1 = (__u32) ((ulong) buffer);
-       parm->ipbfln1f = (__u32) buflen;        /* length of message */
-       parm->ipbfadr2 = (__u32) ((ulong) ansbuf);
-       parm->ipbfln2f = (__u32) anslen;
-       parm->ipsrccls = srccls;
-       parm->ipmsgtag = msgtag;
-       parm->ipflags1 = flags1;        /* priority message */
-
-       b2f0_result = b2f0(SEND, parm);
-
-       if ((!b2f0_result) && (msgid))
-               *msgid = parm->ipmsgid;
-       release_param(parm);
-
-       iucv_debug(2, "exiting");
-
-       return b2f0_result;
-}
-
-/*
- * Name: iucv_send2way_array
- * Purpose: This function transmits data to another application.
- *          The contents of buffer is the address of the array of
- *          addresses and lengths of discontiguous buffers that hold
- *          the message text. The receiver of the send is expected to
- *          reply to the message and a buffer is provided into which
- *          IUCV moves the reply to this message.
- * Input: pathid - path identification number
- *        trgcls - specifies target class
- *        srccls - specifies the source message class
- *        msgtag - spcifies a tag to be associated with the message
- *        flags1 - option for path
- *                 IPPRTY- specifies if you want to send priority message
- *        buffer - address of array of send buffers
- *        buflen - total length of send buffers
- *        ansbuf - address of buffer to reply with
- *        anslen - length of buffer to reply with
- * Output: msgid - specifies the message ID.
- * Return: b2f0_result - return code from CP
- *         (-EINVAL) - buffer address is NULL
- */
-int
-iucv_send2way_array (__u16 pathid,
-                    __u32 * msgid,
-                    __u32 trgcls,
-                    __u32 srccls,
-                    __u32 msgtag,
-                    int flags1,
-                    iucv_array_t * buffer,
-                    ulong buflen, iucv_array_t * ansbuf, ulong anslen)
-{
-       iparml_db *parm;
-       ulong b2f0_result;
-
-       iucv_debug(2, "entering");
-
-       if (!buffer || !ansbuf)
-               return -EINVAL;
-
-       parm = (iparml_db *)grab_param();
-
-       parm->ippathid = pathid;
-       parm->iptrgcls = trgcls;
-       parm->ipbfadr1 = (__u32) ((ulong) buffer);
-       parm->ipbfln1f = (__u32) buflen;        /* length of message */
-       parm->ipbfadr2 = (__u32) ((ulong) ansbuf);
-       parm->ipbfln2f = (__u32) anslen;
-       parm->ipsrccls = srccls;
-       parm->ipmsgtag = msgtag;
-       parm->ipflags1 = (IPBUFLST | IPANSLST | flags1);
-       b2f0_result = b2f0(SEND, parm);
-       if ((!b2f0_result) && (msgid))
-               *msgid = parm->ipmsgid;
-       release_param(parm);
-
-       iucv_debug(2, "exiting");
-       return b2f0_result;
-}
-
-/*
- * Name: iucv_send2way_prmmsg
- * Purpose: This function transmits data to another application.
- *          Prmmsg specifies that the 8-bytes of data are to be moved
- *          into the parameter list. This is a two-way message and the
- *          receiver of the message is expected to reply. A buffer
- *          is provided into which IUCV moves the reply to this
- *          message.
- * Input: pathid - path identification number
- *        trgcls - specifies target class
- *        srccls - specifies the source message class
- *        msgtag - specifies a tag to be associated with the message
- *        flags1 - option for path
- *                 IPPRTY- specifies if you want to send priority message
- *        prmmsg - 8-bytes of data to be placed in parameter list
- *        ansbuf - address of buffer to reply with
- *        anslen - length of buffer to reply with
- * Output: msgid - specifies the message ID.
- * Return: b2f0_result - return code from CP
- *         (-EINVAL) - buffer address is NULL
-*/
-int
-iucv_send2way_prmmsg (__u16 pathid,
-                     __u32 * msgid,
-                     __u32 trgcls,
-                     __u32 srccls,
-                     __u32 msgtag,
-                     ulong flags1, __u8 prmmsg[8], void *ansbuf, ulong anslen)
-{
-       iparml_dpl *parm;
-       ulong b2f0_result;
-
-       iucv_debug(2, "entering");
-
-       if (!ansbuf)
-               return -EINVAL;
-
-       parm = (iparml_dpl *)grab_param();
-
-       parm->ippathid = pathid;
-       parm->iptrgcls = trgcls;
-       parm->ipsrccls = srccls;
-       parm->ipmsgtag = msgtag;
-       parm->ipbfadr2 = (__u32) ((ulong) ansbuf);
-       parm->ipbfln2f = (__u32) anslen;
-       parm->ipflags1 = (IPRMDATA | flags1);   /* message in prmlist */
-       memcpy(parm->iprmmsg, prmmsg, sizeof(parm->iprmmsg));
-
-       b2f0_result = b2f0(SEND, parm);
-
-       if ((!b2f0_result) && (msgid))
-               *msgid = parm->ipmsgid;
-       release_param(parm);
-
-       iucv_debug(2, "exiting");
-
-       return b2f0_result;
-}
-
-/*
- * Name: iucv_send2way_prmmsg_array
- * Purpose: This function transmits data to another application.
- *          Prmmsg specifies that the 8-bytes of data are to be moved
- *          into the parameter list. This is a two-way message and the
- *          receiver of the message is expected to reply. A buffer
- *          is provided into which IUCV moves the reply to this
- *          message. The contents of ansbuf is the address of the
- *          array of addresses and lengths of discontiguous buffers
- *          that contain the reply.
- * Input: pathid - path identification number
- *        trgcls - specifies target class
- *        srccls - specifies the source message class
- *        msgtag - specifies a tag to be associated with the message
- *        flags1 - option for path
- *                 IPPRTY- specifies if you want to send priority message
- *        prmmsg - 8-bytes of data to be placed into the parameter list
- *        ansbuf - address of buffer to reply with
- *        anslen - length of buffer to reply with
- * Output: msgid - specifies the message ID.
- * Return: b2f0_result - return code from CP
- *         (-EINVAL) - ansbuf address is NULL
- */
-int
-iucv_send2way_prmmsg_array (__u16 pathid,
-                           __u32 * msgid,
-                           __u32 trgcls,
-                           __u32 srccls,
-                           __u32 msgtag,
-                           int flags1,
-                           __u8 prmmsg[8],
-                           iucv_array_t * ansbuf, ulong anslen)
-{
-       iparml_dpl *parm;
-       ulong b2f0_result;
-
-       iucv_debug(2, "entering");
-
-       if (!ansbuf)
-               return -EINVAL;
-
-       parm = (iparml_dpl *)grab_param();
-
-       parm->ippathid = pathid;
-       parm->iptrgcls = trgcls;
-       parm->ipsrccls = srccls;
-       parm->ipmsgtag = msgtag;
-       parm->ipbfadr2 = (__u32) ((ulong) ansbuf);
-       parm->ipbfln2f = (__u32) anslen;
-       parm->ipflags1 = (IPRMDATA | IPANSLST | flags1);
-       memcpy(parm->iprmmsg, prmmsg, sizeof(parm->iprmmsg));
-       b2f0_result = b2f0(SEND, parm);
-       if ((!b2f0_result) && (msgid))
-               *msgid = parm->ipmsgid;
-       release_param(parm);
-
-       iucv_debug(2, "exiting");
-       return b2f0_result;
-}
-
-void
-iucv_setmask_cpuid (void *result)
-{
-        iparml_set_mask *parm;
-
-        iucv_debug(1, "entering");
-        parm = (iparml_set_mask *)grab_param();
-        parm->ipmask = *((__u8*)result);
-        *((ulong *)result) = b2f0(SETMASK, parm);
-        release_param(parm);
-
-        iucv_debug(1, "b2f0_result = %ld", *((ulong *)result));
-        iucv_debug(1, "exiting");
-}
-
-/*
- * Name: iucv_setmask
- * Purpose: This function enables or disables the following IUCV
- *          external interruptions: Nonpriority and priority message
- *          interrupts, nonpriority and priority reply interrupts.
- * Input: SetMaskFlag - options for interrupts
- *           0x80 - Nonpriority_MessagePendingInterruptsFlag
- *           0x40 - Priority_MessagePendingInterruptsFlag
- *           0x20 - Nonpriority_MessageCompletionInterruptsFlag
- *           0x10 - Priority_MessageCompletionInterruptsFlag
- *           0x08 - IUCVControlInterruptsFlag
- * Output: NA
- * Return: b2f0_result - return code from CP
-*/
-int
-iucv_setmask (int SetMaskFlag)
-{
-       union {
-               ulong result;
-               __u8  param;
-       } u;
-       int cpu;
-
-       u.param = SetMaskFlag;
-       cpu = get_cpu();
-       smp_call_function_on(iucv_setmask_cpuid, &u, 0, 1, iucv_cpuid);
-       put_cpu();
-
-       return u.result;
-}
-
-/**
- * iucv_sever:
- * @pathid:    Path identification number
- * @user_data: 16-byte of user data
- *
- * This function terminates an iucv path.
- * Returns: return code from CP
- */
-int
-iucv_sever(__u16 pathid, __u8 user_data[16])
-{
-       iparml_control *parm;
-       ulong b2f0_result = 0;
-
-       iucv_debug(1, "entering");
-       parm = (iparml_control *)grab_param();
-
-       memcpy(parm->ipuser, user_data, sizeof(parm->ipuser));
-       parm->ippathid = pathid;
-
-       b2f0_result = b2f0(SEVER, parm);
-
-       if (!b2f0_result)
-               iucv_remove_pathid(pathid);
-       release_param(parm);
-
-       iucv_debug(1, "exiting");
-       return b2f0_result;
-}
-
-/*
- * Interrupt Handlers
- *******************************************************************************/
-
-/**
- * iucv_irq_handler:
- * @regs: Current registers
- * @code: irq code
- *
- * Handles external interrupts coming in from CP.
- * Places the interrupt buffer on a queue and schedules iucv_tasklet_handler().
- */
-static void
-iucv_irq_handler(__u16 code)
-{
-       iucv_irqdata *irqdata;
-
-       irqdata = kmalloc(sizeof(iucv_irqdata), GFP_ATOMIC);
-       if (!irqdata) {
-               printk(KERN_WARNING "%s: out of memory\n", __FUNCTION__);
-               return;
-       }
-
-       memcpy(&irqdata->data, iucv_external_int_buffer,
-              sizeof(iucv_GeneralInterrupt));
-
-       spin_lock(&iucv_irq_queue_lock);
-       list_add_tail(&irqdata->queue, &iucv_irq_queue);
-       spin_unlock(&iucv_irq_queue_lock);
-
-       tasklet_schedule(&iucv_tasklet);
-}
-
-/**
- * iucv_do_int:
- * @int_buf: Pointer to copy of external interrupt buffer
- *
- * The workhorse for handling interrupts queued by iucv_irq_handler().
- * This function is called from the bottom half iucv_tasklet_handler().
- */
-static void
-iucv_do_int(iucv_GeneralInterrupt * int_buf)
-{
-       handler *h = NULL;
-       struct list_head *lh;
-       ulong flags;
-       iucv_interrupt_ops_t *interrupt = NULL; /* interrupt addresses */
-       __u8 temp_buff1[24], temp_buff2[24];    /* masked handler id. */
-       int rc = 0, j = 0;
-       __u8 no_listener[16] = "NO LISTENER";
-
-       iucv_debug(2, "entering, pathid %d, type %02X",
-                int_buf->ippathid, int_buf->iptype);
-       iucv_dumpit("External Interrupt Buffer:",
-                   int_buf, sizeof(iucv_GeneralInterrupt));
-
-       ASCEBC (no_listener, 16);
-
-       if (int_buf->iptype != 01) {
-               if ((int_buf->ippathid) > (max_connections - 1)) {
-                       printk(KERN_WARNING "%s: Got interrupt with pathid %d"
-                              " > max_connections (%ld)\n", __FUNCTION__,
-                              int_buf->ippathid, max_connections - 1);
-               } else {
-                       h = iucv_pathid_table[int_buf->ippathid];
-                       interrupt = h->interrupt_table;
-                       iucv_dumpit("Handler:", h, sizeof(handler));
-               }
-       }
-
-       /* end of if statement */
-       switch (int_buf->iptype) {
-               case 0x01:              /* connection pending */
-                       if (messagesDisabled) {
-                           iucv_setmask(~0);
-                           messagesDisabled = 0;
-                       }
-                       spin_lock_irqsave(&iucv_lock, flags);
-                       list_for_each(lh, &iucv_handler_table) {
-                               h = list_entry(lh, handler, list);
-                               memcpy(temp_buff1, &(int_buf->ipvmid), 24);
-                               memcpy(temp_buff2, &(h->id.userid), 24);
-                               for (j = 0; j < 24; j++) {
-                                       temp_buff1[j] &= (h->id.mask)[j];
-                                       temp_buff2[j] &= (h->id.mask)[j];
-                               }
-
-                               iucv_dumpit("temp_buff1:",
-                                           temp_buff1, sizeof(temp_buff1));
-                               iucv_dumpit("temp_buff2",
-                                           temp_buff2, sizeof(temp_buff2));
-
-                               if (!memcmp (temp_buff1, temp_buff2, 24)) {
-
-                                       iucv_debug(2,
-                                                  "found a matching handler");
-                                       break;
-                               } else
-                                       h = NULL;
-                       }
-                       spin_unlock_irqrestore (&iucv_lock, flags);
-                       if (h) {
-                               /* ADD PATH TO PATHID TABLE */
-                               rc = iucv_add_pathid(int_buf->ippathid, h);
-                               if (rc) {
-                                       iucv_sever (int_buf->ippathid,
-                                                   no_listener);
-                                       iucv_debug(1,
-                                                  "add_pathid failed, rc = %d",
-                                                  rc);
-                               } else {
-                                       interrupt = h->interrupt_table;
-                                       if (interrupt->ConnectionPending) {
-                                               EBCASC (int_buf->ipvmid, 8);
-                                               interrupt->ConnectionPending(
-                                                       (iucv_ConnectionPending *)int_buf,
-                                                       h->pgm_data);
-                                       } else
-                                               iucv_sever(int_buf->ippathid,
-                                                          no_listener);
-                               }
-                       } else
-                               iucv_sever(int_buf->ippathid, no_listener);
-                       break;
-
-               case 0x02:              /*connection complete */
-                       if (messagesDisabled) {
-                           iucv_setmask(~0);
-                           messagesDisabled = 0;
-                       }
-                       if (h) {
-                               if (interrupt->ConnectionComplete)
-                               {
-                                       interrupt->ConnectionComplete(
-                                               (iucv_ConnectionComplete *)int_buf,
-                                               h->pgm_data);
-                               }
-                               else
-                                       iucv_debug(1,
-                                                  "ConnectionComplete not called");
-                       } else
-                               iucv_sever(int_buf->ippathid, no_listener);
-                       break;
-
-               case 0x03:              /* connection severed */
-                       if (messagesDisabled) {
-                           iucv_setmask(~0);
-                           messagesDisabled = 0;
-                       }
-                       if (h) {
-                               if (interrupt->ConnectionSevered)
-                                       interrupt->ConnectionSevered(
-                                               (iucv_ConnectionSevered *)int_buf,
-                                               h->pgm_data);
-
-                               else
-                                       iucv_sever (int_buf->ippathid, no_listener);
-                       } else
-                               iucv_sever(int_buf->ippathid, no_listener);
-                       break;
-
-               case 0x04:              /* connection quiesced */
-                       if (messagesDisabled) {
-                           iucv_setmask(~0);
-                           messagesDisabled = 0;
-                       }
-                       if (h) {
-                               if (interrupt->ConnectionQuiesced)
-                                       interrupt->ConnectionQuiesced(
-                                               (iucv_ConnectionQuiesced *)int_buf,
-                                               h->pgm_data);
-                               else
-                                       iucv_debug(1,
-                                                  "ConnectionQuiesced not called");
-                       }
-                       break;
-
-               case 0x05:              /* connection resumed */
-                       if (messagesDisabled) {
-                           iucv_setmask(~0);
-                           messagesDisabled = 0;
-                       }
-                       if (h) {
-                               if (interrupt->ConnectionResumed)
-                                       interrupt->ConnectionResumed(
-                                               (iucv_ConnectionResumed *)int_buf,
-                                               h->pgm_data);
-                               else
-                                       iucv_debug(1,
-                                                  "ConnectionResumed not called");
-                       }
-                       break;
-
-               case 0x06:              /* priority message complete */
-               case 0x07:              /* nonpriority message complete */
-                       if (h) {
-                               if (interrupt->MessageComplete)
-                                       interrupt->MessageComplete(
-                                               (iucv_MessageComplete *)int_buf,
-                                               h->pgm_data);
-                               else
-                                       iucv_debug(2,
-                                                  "MessageComplete not called");
-                       }
-                       break;
-
-               case 0x08:              /* priority message pending  */
-               case 0x09:              /* nonpriority message pending  */
-                       if (h) {
-                               if (interrupt->MessagePending)
-                                       interrupt->MessagePending(
-                                               (iucv_MessagePending *) int_buf,
-                                               h->pgm_data);
-                               else
-                                       iucv_debug(2,
-                                                  "MessagePending not called");
-                       }
-                       break;
-               default:                /* unknown iucv type */
-                       printk(KERN_WARNING "%s: unknown iucv interrupt\n",
-                              __FUNCTION__);
-                       break;
-       }                       /* end switch */
-
-       iucv_debug(2, "exiting pathid %d, type %02X",
-                int_buf->ippathid, int_buf->iptype);
-
-       return;
-}
-
-/**
- * iucv_tasklet_handler:
- *
- * This function loops over the queue of irq buffers and runs iucv_do_int()
- * on every queue element.
- */
-static void
-iucv_tasklet_handler(unsigned long ignored)
-{
-       struct list_head head;
-       struct list_head *next;
-       ulong  flags;
-
-       spin_lock_irqsave(&iucv_irq_queue_lock, flags);
-       list_add(&head, &iucv_irq_queue);
-       list_del_init(&iucv_irq_queue);
-       spin_unlock_irqrestore (&iucv_irq_queue_lock, flags);
-
-       next = head.next;
-       while (next != &head) {
-               iucv_irqdata *p = list_entry(next, iucv_irqdata, queue);
-
-               next = next->next;
-               iucv_do_int(&p->data);
-               kfree(p);
-       }
-
-       return;
-}
-
-subsys_initcall(iucv_init);
-module_exit(iucv_exit);
-
-/**
- * Export all public stuff
- */
-EXPORT_SYMBOL (iucv_bus);
-EXPORT_SYMBOL (iucv_root);
-EXPORT_SYMBOL (iucv_accept);
-EXPORT_SYMBOL (iucv_connect);
-#if 0
-EXPORT_SYMBOL (iucv_purge);
-EXPORT_SYMBOL (iucv_query_maxconn);
-EXPORT_SYMBOL (iucv_query_bufsize);
-EXPORT_SYMBOL (iucv_quiesce);
-#endif
-EXPORT_SYMBOL (iucv_receive);
-#if 0
-EXPORT_SYMBOL (iucv_receive_array);
-#endif
-EXPORT_SYMBOL (iucv_reject);
-#if 0
-EXPORT_SYMBOL (iucv_reply);
-EXPORT_SYMBOL (iucv_reply_array);
-EXPORT_SYMBOL (iucv_resume);
-#endif
-EXPORT_SYMBOL (iucv_reply_prmmsg);
-EXPORT_SYMBOL (iucv_send);
-EXPORT_SYMBOL (iucv_send2way);
-EXPORT_SYMBOL (iucv_send2way_array);
-EXPORT_SYMBOL (iucv_send2way_prmmsg);
-EXPORT_SYMBOL (iucv_send2way_prmmsg_array);
-#if 0
-EXPORT_SYMBOL (iucv_send_array);
-EXPORT_SYMBOL (iucv_send_prmmsg);
-EXPORT_SYMBOL (iucv_setmask);
-#endif
-EXPORT_SYMBOL (iucv_sever);
-EXPORT_SYMBOL (iucv_register_program);
-EXPORT_SYMBOL (iucv_unregister_program);
diff --git a/drivers/s390/net/iucv.h b/drivers/s390/net/iucv.h
deleted file mode 100644 (file)
index 5b6b1b7..0000000
+++ /dev/null
@@ -1,849 +0,0 @@
-/*
- *  drivers/s390/net/iucv.h
- *    IUCV base support.
- *
- *  S390 version
- *    Copyright (C) 2000 IBM Corporation
- *    Author(s):Alan Altmark (Alan_Altmark@us.ibm.com)
- *             Xenia Tkatschow (xenia@us.ibm.com)
- *
- *
- * Functionality:
- * To explore any of the IUCV functions, one must first register
- * their program using iucv_register_program(). Once your program has
- * successfully completed a register, it can exploit the other functions.
- * For furthur reference on all IUCV functionality, refer to the
- * CP Programming Services book, also available on the web
- * thru www.ibm.com/s390/vm/pubs, manual # SC24-5760
- *
- *      Definition of Return Codes
- *      -All positive return codes including zero are reflected back
- *       from CP except for iucv_register_program. The definition of each
- *       return code can be found in CP Programming Services book.
- *       Also available on the web thru www.ibm.com/s390/vm/pubs, manual # SC24-5760
- *      - Return Code of:
- *             (-EINVAL) Invalid value
- *             (-ENOMEM) storage allocation failed
- *     pgmask defined in iucv_register_program will be set depending on input
- *     paramters.
- *
- */
-
-#include <linux/types.h>
-#include <asm/debug.h>
-
-/**
- * Debug Facility stuff
- */
-#define IUCV_DBF_SETUP_NAME "iucv_setup"
-#define IUCV_DBF_SETUP_LEN 32
-#define IUCV_DBF_SETUP_PAGES 2
-#define IUCV_DBF_SETUP_NR_AREAS 1
-#define IUCV_DBF_SETUP_LEVEL 3
-
-#define IUCV_DBF_DATA_NAME "iucv_data"
-#define IUCV_DBF_DATA_LEN 128
-#define IUCV_DBF_DATA_PAGES 2
-#define IUCV_DBF_DATA_NR_AREAS 1
-#define IUCV_DBF_DATA_LEVEL 2
-
-#define IUCV_DBF_TRACE_NAME "iucv_trace"
-#define IUCV_DBF_TRACE_LEN 16
-#define IUCV_DBF_TRACE_PAGES 4
-#define IUCV_DBF_TRACE_NR_AREAS 1
-#define IUCV_DBF_TRACE_LEVEL 3
-
-#define IUCV_DBF_TEXT(name,level,text) \
-       do { \
-               debug_text_event(iucv_dbf_##name,level,text); \
-       } while (0)
-
-#define IUCV_DBF_HEX(name,level,addr,len) \
-       do { \
-               debug_event(iucv_dbf_##name,level,(void*)(addr),len); \
-       } while (0)
-
-DECLARE_PER_CPU(char[256], iucv_dbf_txt_buf);
-
-#define IUCV_DBF_TEXT_(name,level,text...)                             \
-       do {                                                            \
-               char* iucv_dbf_txt_buf = get_cpu_var(iucv_dbf_txt_buf); \
-               sprintf(iucv_dbf_txt_buf, text);                        \
-               debug_text_event(iucv_dbf_##name,level,iucv_dbf_txt_buf); \
-               put_cpu_var(iucv_dbf_txt_buf);                          \
-       } while (0)
-
-#define IUCV_DBF_SPRINTF(name,level,text...) \
-       do { \
-               debug_sprintf_event(iucv_dbf_trace, level, ##text ); \
-               debug_sprintf_event(iucv_dbf_trace, level, text ); \
-       } while (0)
-
-/**
- * some more debug stuff
- */
-#define IUCV_HEXDUMP16(importance,header,ptr) \
-PRINT_##importance(header "%02x %02x %02x %02x  %02x %02x %02x %02x  " \
-                  "%02x %02x %02x %02x  %02x %02x %02x %02x\n", \
-                  *(((char*)ptr)),*(((char*)ptr)+1),*(((char*)ptr)+2), \
-                  *(((char*)ptr)+3),*(((char*)ptr)+4),*(((char*)ptr)+5), \
-                  *(((char*)ptr)+6),*(((char*)ptr)+7),*(((char*)ptr)+8), \
-                  *(((char*)ptr)+9),*(((char*)ptr)+10),*(((char*)ptr)+11), \
-                  *(((char*)ptr)+12),*(((char*)ptr)+13), \
-                  *(((char*)ptr)+14),*(((char*)ptr)+15)); \
-PRINT_##importance(header "%02x %02x %02x %02x  %02x %02x %02x %02x  " \
-                  "%02x %02x %02x %02x  %02x %02x %02x %02x\n", \
-                  *(((char*)ptr)+16),*(((char*)ptr)+17), \
-                  *(((char*)ptr)+18),*(((char*)ptr)+19), \
-                  *(((char*)ptr)+20),*(((char*)ptr)+21), \
-                  *(((char*)ptr)+22),*(((char*)ptr)+23), \
-                  *(((char*)ptr)+24),*(((char*)ptr)+25), \
-                  *(((char*)ptr)+26),*(((char*)ptr)+27), \
-                  *(((char*)ptr)+28),*(((char*)ptr)+29), \
-                  *(((char*)ptr)+30),*(((char*)ptr)+31));
-
-static inline void
-iucv_hex_dump(unsigned char *buf, size_t len)
-{
-       size_t i;
-
-       for (i = 0; i < len; i++) {
-               if (i && !(i % 16))
-                       printk("\n");
-               printk("%02x ", *(buf + i));
-       }
-       printk("\n");
-}
-/**
- * end of debug stuff
- */
-
-#define uchar  unsigned char
-#define ushort unsigned short
-#define ulong  unsigned long
-#define iucv_handle_t void *
-
-/* flags1:
- * All flags are defined in the field IPFLAGS1 of each function
- * and can be found in CP Programming Services.
- * IPLOCAL  - Indicates the connect can only be satisfied on the
- *            local system
- * IPPRTY   - Indicates a priority message
- * IPQUSCE  - Indicates you do not want to receive messages on a
- *            path until an iucv_resume is issued
- * IPRMDATA - Indicates that the message is in the parameter list
- */
-#define IPLOCAL        0x01
-#define IPPRTY                 0x20
-#define IPQUSCE                0x40
-#define IPRMDATA               0x80
-
-/* flags1_out:
- * All flags are defined in the output field of IPFLAGS1 for each function
- * and can be found in CP Programming Services.
- * IPNORPY - Specifies this is a one-way message and no reply is expected.
- * IPPRTY   - Indicates a priority message is permitted. Defined in flags1.
- */
-#define IPNORPY         0x10
-
-#define Nonpriority_MessagePendingInterruptsFlag         0x80
-#define Priority_MessagePendingInterruptsFlag            0x40
-#define Nonpriority_MessageCompletionInterruptsFlag      0x20
-#define Priority_MessageCompletionInterruptsFlag         0x10
-#define IUCVControlInterruptsFlag                        0x08
-#define AllInterrupts                                    0xf8
-/*
- * Mapping of external interrupt buffers should be used with the corresponding
- * interrupt types.
- * Names: iucv_ConnectionPending    ->  connection pending
- *        iucv_ConnectionComplete   ->  connection complete
- *        iucv_ConnectionSevered    ->  connection severed
- *        iucv_ConnectionQuiesced   ->  connection quiesced
- *        iucv_ConnectionResumed    ->  connection resumed
- *        iucv_MessagePending       ->  message pending
- *        iucv_MessageComplete      ->  message complete
- */
-typedef struct {
-       u16 ippathid;
-       uchar ipflags1;
-       uchar iptype;
-       u16 ipmsglim;
-       u16 res1;
-       uchar ipvmid[8];
-       uchar ipuser[16];
-       u32 res3;
-       uchar ippollfg;
-       uchar res4[3];
-} iucv_ConnectionPending;
-
-typedef struct {
-       u16 ippathid;
-       uchar ipflags1;
-       uchar iptype;
-       u16 ipmsglim;
-       u16 res1;
-       uchar res2[8];
-       uchar ipuser[16];
-       u32 res3;
-       uchar ippollfg;
-       uchar res4[3];
-} iucv_ConnectionComplete;
-
-typedef struct {
-       u16 ippathid;
-       uchar res1;
-       uchar iptype;
-       u32 res2;
-       uchar res3[8];
-       uchar ipuser[16];
-       u32 res4;
-       uchar ippollfg;
-       uchar res5[3];
-} iucv_ConnectionSevered;
-
-typedef struct {
-       u16 ippathid;
-       uchar res1;
-       uchar iptype;
-       u32 res2;
-       uchar res3[8];
-       uchar ipuser[16];
-       u32 res4;
-       uchar ippollfg;
-       uchar res5[3];
-} iucv_ConnectionQuiesced;
-
-typedef struct {
-       u16 ippathid;
-       uchar res1;
-       uchar iptype;
-       u32 res2;
-       uchar res3[8];
-       uchar ipuser[16];
-       u32 res4;
-       uchar ippollfg;
-       uchar res5[3];
-} iucv_ConnectionResumed;
-
-typedef struct {
-       u16 ippathid;
-       uchar ipflags1;
-       uchar iptype;
-       u32 ipmsgid;
-       u32 iptrgcls;
-       union u2 {
-               u32 iprmmsg1_u32;
-               uchar iprmmsg1[4];
-       } ln1msg1;
-       union u1 {
-               u32 ipbfln1f;
-               uchar iprmmsg2[4];
-       } ln1msg2;
-       u32 res1[3];
-       u32 ipbfln2f;
-       uchar ippollfg;
-       uchar res2[3];
-} iucv_MessagePending;
-
-typedef struct {
-       u16 ippathid;
-       uchar ipflags1;
-       uchar iptype;
-       u32 ipmsgid;
-       u32 ipaudit;
-       uchar iprmmsg[8];
-       u32 ipsrccls;
-       u32 ipmsgtag;
-       u32 res;
-       u32 ipbfln2f;
-       uchar ippollfg;
-       uchar res2[3];
-} iucv_MessageComplete;
-
-/*
- * iucv_interrupt_ops_t: Is a vector of functions that handle
- * IUCV interrupts.
- * Parameter list:
- *         eib - is a pointer to a 40-byte area described
- *               with one of the structures above.
- *         pgm_data - this data is strictly for the
- *                    interrupt handler that is passed by
- *                    the application. This may be an address
- *                    or token.
-*/
-typedef struct {
-       void (*ConnectionPending) (iucv_ConnectionPending * eib,
-                                  void *pgm_data);
-       void (*ConnectionComplete) (iucv_ConnectionComplete * eib,
-                                   void *pgm_data);
-       void (*ConnectionSevered) (iucv_ConnectionSevered * eib,
-                                  void *pgm_data);
-       void (*ConnectionQuiesced) (iucv_ConnectionQuiesced * eib,
-                                   void *pgm_data);
-       void (*ConnectionResumed) (iucv_ConnectionResumed * eib,
-                                  void *pgm_data);
-       void (*MessagePending) (iucv_MessagePending * eib, void *pgm_data);
-       void (*MessageComplete) (iucv_MessageComplete * eib, void *pgm_data);
-} iucv_interrupt_ops_t;
-
-/*
- *iucv_array_t : Defines buffer array.
- * Inside the array may be 31- bit addresses and 31-bit lengths.
-*/
-typedef struct {
-       u32 address;
-       u32 length;
-} iucv_array_t __attribute__ ((aligned (8)));
-
-extern struct bus_type iucv_bus;
-extern struct device *iucv_root;
-
-/*   -prototypes-    */
-/*
- * Name: iucv_register_program
- * Purpose: Registers an application with IUCV
- * Input: prmname - user identification
- *        userid  - machine identification
- *        pgmmask - indicates which bits in the prmname and userid combined will be
- *                 used to determine who is given control
- *        ops     - address of vector of interrupt handlers
- *        pgm_data- application data passed to interrupt handlers
- * Output: NA
- * Return: address of handler
- *         (0) - Error occurred, registration not completed.
- * NOTE: Exact cause of failure will be recorded in syslog.
-*/
-iucv_handle_t iucv_register_program (uchar pgmname[16],
-                                    uchar userid[8],
-                                    uchar pgmmask[24],
-                                    iucv_interrupt_ops_t * ops,
-                                    void *pgm_data);
-
-/*
- * Name: iucv_unregister_program
- * Purpose: Unregister application with IUCV
- * Input: address of handler
- * Output: NA
- * Return: (0) - Normal return
- *         (-EINVAL) - Internal error, wild pointer
-*/
-int iucv_unregister_program (iucv_handle_t handle);
-
-/*
- * Name: iucv_accept
- * Purpose: This function is issued after the user receives a Connection Pending external
- *          interrupt and now wishes to complete the IUCV communication path.
- * Input:  pathid - u16 , Path identification number
- *         msglim_reqstd - u16, The number of outstanding messages requested.
- *         user_data - uchar[16], Data specified by the iucv_connect function.
- *        flags1 - int, Contains options for this path.
- *           -IPPRTY   - 0x20- Specifies if you want to send priority message.
- *           -IPRMDATA - 0x80, Specifies whether your program can handle a message
- *             in  the parameter list.
- *           -IPQUSCE  - 0x40, Specifies whether you want to quiesce the path being
- *             established.
- *         handle - iucv_handle_t, Address of handler.
- *         pgm_data - void *, Application data passed to interrupt handlers.
- *         flags1_out - int * Contains information about the path
- *           - IPPRTY - 0x20, Indicates you may send priority messages.
- *         msglim - *u16, Number of outstanding messages.
- * Output: return code from CP IUCV call.
-*/
-
-int iucv_accept (u16 pathid,
-                u16 msglim_reqstd,
-                uchar user_data[16],
-                int flags1,
-                iucv_handle_t handle,
-                void *pgm_data, int *flags1_out, u16 * msglim);
-
-/*
- * Name: iucv_connect
- * Purpose: This function establishes an IUCV path. Although the connect may complete
- *         successfully, you are not able to use the path until you receive an IUCV
- *          Connection Complete external interrupt.
- * Input: pathid - u16 *, Path identification number
- *        msglim_reqstd - u16, Number of outstanding messages requested
- *        user_data - uchar[16], 16-byte user data
- *       userid - uchar[8], User identification
- *        system_name - uchar[8], 8-byte identifying the system name
- *       flags1 - int, Contains options for this path.
- *          -IPPRTY -   0x20, Specifies if you want to send priority message.
- *          -IPRMDATA - 0x80, Specifies whether your program can handle a message
- *              in  the parameter list.
- *          -IPQUSCE -  0x40, Specifies whether you want to quiesce the path being
- *             established.
- *          -IPLOCAL -  0X01, Allows an application to force the partner to be on
- *             the local system. If local is specified then target class cannot be
- *             specified.
- *        flags1_out - int * Contains information about the path
- *           - IPPRTY - 0x20, Indicates you may send priority messages.
- *        msglim - * u16, Number of outstanding messages
- *        handle - iucv_handle_t, Address of handler
- *        pgm_data - void *, Application data passed to interrupt handlers
- * Output: return code from CP IUCV call
- *         rc - return code from iucv_declare_buffer
- *         -EINVAL - Invalid handle passed by application
- *         -EINVAL - Pathid address is NULL
- *         add_pathid_result - Return code from internal function add_pathid
-*/
-int
-    iucv_connect (u16 * pathid,
-                 u16 msglim_reqstd,
-                 uchar user_data[16],
-                 uchar userid[8],
-                 uchar system_name[8],
-                 int flags1,
-                 int *flags1_out,
-                 u16 * msglim, iucv_handle_t handle, void *pgm_data);
-
-/*
- * Name: iucv_purge
- * Purpose: This function cancels a message that you have sent.
- * Input: pathid - Path identification number.
- *        msgid - Specifies the message ID of the message to be purged.
- *        srccls - Specifies the source message class.
- * Output: audit - Contains information about asynchronous error
- *                 that may have affected the normal completion
- *                 of this message.
- * Return: Return code from CP IUCV call.
-*/
-int iucv_purge (u16 pathid, u32 msgid, u32 srccls, __u32 *audit);
-/*
- * Name: iucv_query_maxconn
- * Purpose: This function determines the maximum number of communication paths you
- *         may establish.
- * Return:  maxconn - ulong, Maximum number of connection the virtual machine may
- *          establish.
-*/
-ulong iucv_query_maxconn (void);
-
-/*
- * Name: iucv_query_bufsize
- * Purpose: This function determines how large an external interrupt
- *          buffer IUCV requires to store information.
- * Return:  bufsize - ulong, Size of external interrupt buffer.
- */
-ulong iucv_query_bufsize (void);
-
-/*
- * Name: iucv_quiesce
- * Purpose: This function temporarily suspends incoming messages on an
- *          IUCV path. You can later reactivate the path by invoking
- *          the iucv_resume function.
- * Input: pathid - Path identification number
- *        user_data  - 16-bytes of user data
- * Output: NA
- * Return: Return code from CP IUCV call.
-*/
-int iucv_quiesce (u16 pathid, uchar user_data[16]);
-
-/*
- * Name: iucv_receive
- * Purpose: This function receives messages that are being sent to you
- *          over established paths. Data will be returned in buffer for length of
- *          buflen.
- * Input:
- *       pathid - Path identification number.
- *       buffer - Address of buffer to receive.
- *       buflen - Length of buffer to receive.
- *       msgid - Specifies the message ID.
- *       trgcls - Specifies target class.
- * Output:
- *      flags1_out: int *, Contains information about this path.
- *         IPNORPY - 0x10 Specifies this is a one-way message and no reply is
- *        expected.
- *         IPPRTY  - 0x20 Specifies if you want to send priority message.
- *         IPRMDATA - 0x80 specifies the data is contained in the parameter list
- *       residual_buffer - address of buffer updated by the number
- *                         of bytes you have received.
- *       residual_length -
- *              Contains one of the following values, if the receive buffer is:
- *               The same length as the message, this field is zero.
- *               Longer than the message, this field contains the number of
- *                bytes remaining in the buffer.
- *               Shorter than the message, this field contains the residual
- *                count (that is, the number of bytes remaining in the
- *                message that does not fit into the buffer. In this
- *                case b2f0_result = 5.
- * Return: Return code from CP IUCV call.
- *         (-EINVAL) - buffer address is pointing to NULL
-*/
-int iucv_receive (u16 pathid,
-                 u32 msgid,
-                 u32 trgcls,
-                 void *buffer,
-                 ulong buflen,
-                 int *flags1_out,
-                 ulong * residual_buffer, ulong * residual_length);
-
- /*
-  * Name: iucv_receive_array
-  * Purpose: This function receives messages that are being sent to you
-  *          over established paths. Data will be returned in first buffer for
-  *          length of first buffer.
-  * Input: pathid - Path identification number.
-  *        msgid - specifies the message ID.
-  *        trgcls - Specifies target class.
-  *        buffer - Address of array of buffers.
-  *        buflen - Total length of buffers.
-  * Output:
-  *        flags1_out: int *, Contains information about this path.
-  *          IPNORPY - 0x10 Specifies this is a one-way message and no reply is
-  *          expected.
-  *          IPPRTY  - 0x20 Specifies if you want to send priority message.
-  *          IPRMDATA - 0x80 specifies the data is contained in the parameter list
-  *       residual_buffer - address points to the current list entry IUCV
-  *                         is working on.
-  *       residual_length -
-  *              Contains one of the following values, if the receive buffer is:
-  *               The same length as the message, this field is zero.
-  *               Longer than the message, this field contains the number of
-  *                bytes remaining in the buffer.
-  *               Shorter than the message, this field contains the residual
-  *                count (that is, the number of bytes remaining in the
-  *                message that does not fit into the buffer. In this
-  *                case b2f0_result = 5.
-  * Return: Return code from CP IUCV call.
-  *         (-EINVAL) - Buffer address is NULL.
-  */
-int iucv_receive_array (u16 pathid,
-                       u32 msgid,
-                       u32 trgcls,
-                       iucv_array_t * buffer,
-                       ulong buflen,
-                       int *flags1_out,
-                       ulong * residual_buffer, ulong * residual_length);
-
-/*
- * Name: iucv_reject
- * Purpose: The reject function refuses a specified message. Between the
- *          time you are notified of a message and the time that you
- *          complete the message, the message may be rejected.
- * Input: pathid - Path identification number.
- *        msgid - Specifies the message ID.
- *        trgcls - Specifies target class.
- * Output: NA
- * Return: Return code from CP IUCV call.
-*/
-int iucv_reject (u16 pathid, u32 msgid, u32 trgcls);
-
-/*
- * Name: iucv_reply
- * Purpose: This function responds to the two-way messages that you
- *          receive. You must identify completely the message to
- *          which you wish to reply. ie, pathid, msgid, and trgcls.
- * Input: pathid - Path identification number.
- *        msgid - Specifies the message ID.
- *        trgcls - Specifies target class.
- *        flags1 - Option for path.
- *          IPPRTY- 0x20, Specifies if you want to send priority message.
- *        buffer - Address of reply buffer.
- *        buflen - Length of reply buffer.
- * Output: residual_buffer - Address of buffer updated by the number
- *                    of bytes you have moved.
- *         residual_length - Contains one of the following values:
- *             If the answer buffer is the same length as the reply, this field
- *              contains zero.
- *             If the answer buffer is longer than the reply, this field contains
- *              the number of bytes remaining in the buffer.
- *             If the answer buffer is shorter than the reply, this field contains
- *              a residual count (that is, the number of bytes remianing in the
- *              reply that does not fit into the buffer. In this
- *               case b2f0_result = 5.
- * Return: Return code from CP IUCV call.
- *         (-EINVAL) - Buffer address is NULL.
-*/
-int iucv_reply (u16 pathid,
-               u32 msgid,
-               u32 trgcls,
-               int flags1,
-               void *buffer, ulong buflen, ulong * residual_buffer,
-               ulong * residual_length);
-
-/*
- * Name: iucv_reply_array
- * Purpose: This function responds to the two-way messages that you
- *          receive. You must identify completely the message to
- *          which you wish to reply. ie, pathid, msgid, and trgcls.
- *          The array identifies a list of addresses and lengths of
- *          discontiguous buffers that contains the reply data.
- * Input: pathid - Path identification number
- *        msgid - Specifies the message ID.
- *        trgcls - Specifies target class.
- *        flags1 - Option for path.
- *          IPPRTY- 0x20, Specifies if you want to send priority message.
- *        buffer - Address of array of reply buffers.
- *        buflen - Total length of reply buffers.
- * Output: residual_buffer - Address of buffer which IUCV is currently working on.
- *         residual_length - Contains one of the following values:
- *              If the answer buffer is the same length as the reply, this field
- *               contains zero.
- *              If the answer buffer is longer than the reply, this field contains
- *               the number of bytes remaining in the buffer.
- *              If the answer buffer is shorter than the reply, this field contains
- *               a residual count (that is, the number of bytes remianing in the
- *               reply that does not fit into the buffer. In this
- *               case b2f0_result = 5.
- * Return: Return code from CP IUCV call.
- *         (-EINVAL) - Buffer address is NULL.
-*/
-int iucv_reply_array (u16 pathid,
-                     u32 msgid,
-                     u32 trgcls,
-                     int flags1,
-                     iucv_array_t * buffer,
-                     ulong buflen, ulong * residual_address,
-                     ulong * residual_length);
-
-/*
- * Name: iucv_reply_prmmsg
- * Purpose: This function responds to the two-way messages that you
- *          receive. You must identify completely the message to
- *          which you wish to reply. ie, pathid, msgid, and trgcls.
- *          Prmmsg signifies the data is moved into the
- *          parameter list.
- * Input: pathid - Path identification number.
- *        msgid - Specifies the message ID.
- *        trgcls - Specifies target class.
- *        flags1 - Option for path.
- *          IPPRTY- 0x20 Specifies if you want to send priority message.
- *        prmmsg - 8-bytes of data to be placed into the parameter.
- *                 list.
- * Output: NA
- * Return: Return code from CP IUCV call.
-*/
-int iucv_reply_prmmsg (u16 pathid,
-                      u32 msgid, u32 trgcls, int flags1, uchar prmmsg[8]);
-
-/*
- * Name: iucv_resume
- * Purpose: This function restores communications over a quiesced path
- * Input: pathid - Path identification number.
- *        user_data  - 16-bytes of user data.
- * Output: NA
- * Return: Return code from CP IUCV call.
-*/
-int iucv_resume (u16 pathid, uchar user_data[16]);
-
-/*
- * Name: iucv_send
- * Purpose: This function transmits data to another application.
- *          Data to be transmitted is in a buffer and this is a
- *          one-way message and the receiver will not reply to the
- *          message.
- * Input: pathid - Path identification number.
- *        trgcls - Specifies target class.
- *        srccls - Specifies the source message class.
- *        msgtag - Specifies a tag to be associated with the message.
- *        flags1 - Option for path.
- *          IPPRTY- 0x20 Specifies if you want to send priority message.
- *        buffer - Address of send buffer.
- *        buflen - Length of send buffer.
- * Output: msgid - Specifies the message ID.
- * Return: Return code from CP IUCV call.
- *         (-EINVAL) - Buffer address is NULL.
-*/
-int iucv_send (u16 pathid,
-              u32 * msgid,
-              u32 trgcls,
-              u32 srccls, u32 msgtag, int flags1, void *buffer, ulong buflen);
-
-/*
- * Name: iucv_send_array
- * Purpose: This function transmits data to another application.
- *          The contents of buffer is the address of the array of
- *          addresses and lengths of discontiguous buffers that hold
- *          the message text. This is a one-way message and the
- *          receiver will not reply to the message.
- * Input: pathid - Path identification number.
- *        trgcls - Specifies target class.
- *        srccls - Specifies the source message class.
- *        msgtag - Specifies a tag to be associated witht the message.
- *        flags1 - Option for path.
- *          IPPRTY- specifies if you want to send priority message.
- *        buffer - Address of array of send buffers.
- *        buflen - Total length of send buffers.
- * Output: msgid - Specifies the message ID.
- * Return: Return code from CP IUCV call.
- *         (-EINVAL) - Buffer address is NULL.
-*/
-int iucv_send_array (u16 pathid,
-                    u32 * msgid,
-                    u32 trgcls,
-                    u32 srccls,
-                    u32 msgtag,
-                    int flags1, iucv_array_t * buffer, ulong buflen);
-
-/*
- * Name: iucv_send_prmmsg
- * Purpose: This function transmits data to another application.
- *          Prmmsg specifies that the 8-bytes of data are to be moved
- *          into the parameter list. This is a one-way message and the
- *          receiver will not reply to the message.
- * Input: pathid - Path identification number.
- *        trgcls - Specifies target class.
- *        srccls - Specifies the source message class.
- *        msgtag - Specifies a tag to be associated with the message.
- *        flags1 - Option for path.
- *          IPPRTY- 0x20 specifies if you want to send priority message.
- *        prmmsg - 8-bytes of data to be placed into parameter list.
- * Output: msgid - Specifies the message ID.
- * Return: Return code from CP IUCV call.
-*/
-int iucv_send_prmmsg (u16 pathid,
-                     u32 * msgid,
-                     u32 trgcls,
-                     u32 srccls, u32 msgtag, int flags1, uchar prmmsg[8]);
-
-/*
- * Name: iucv_send2way
- * Purpose: This function transmits data to another application.
- *          Data to be transmitted is in a buffer. The receiver
- *          of the send is expected to reply to the message and
- *          a buffer is provided into which IUCV moves the reply
- *          to this message.
- * Input: pathid - Path identification number.
- *        trgcls - Specifies target class.
- *        srccls - Specifies the source message class.
- *        msgtag - Specifies a tag associated with the message.
- *        flags1 - Option for path.
- *          IPPRTY- 0x20 Specifies if you want to send priority message.
- *        buffer - Address of send buffer.
- *        buflen - Length of send buffer.
- *        ansbuf - Address of buffer into which IUCV moves the reply of
- *                 this message.
- *        anslen - Address of length of buffer.
- * Output: msgid - Specifies the message ID.
- * Return: Return code from CP IUCV call.
- *         (-EINVAL) - Buffer or ansbuf address is NULL.
-*/
-int iucv_send2way (u16 pathid,
-                  u32 * msgid,
-                  u32 trgcls,
-                  u32 srccls,
-                  u32 msgtag,
-                  int flags1,
-                  void *buffer, ulong buflen, void *ansbuf, ulong anslen);
-
-/*
- * Name: iucv_send2way_array
- * Purpose: This function transmits data to another application.
- *          The contents of buffer is the address of the array of
- *          addresses and lengths of discontiguous buffers that hold
- *          the message text. The receiver of the send is expected to
- *          reply to the message and a buffer is provided into which
- *          IUCV moves the reply to this message.
- * Input: pathid - Path identification number.
- *        trgcls - Specifies target class.
- *        srccls - Specifies the source message class.
- *        msgtag - Specifies a tag to be associated with the message.
- *        flags1 - Option for path.
- *          IPPRTY- 0x20 Specifies if you want to send priority message.
- *        buffer - Sddress of array of send buffers.
- *        buflen - Total length of send buffers.
- *        ansbuf - Address of array of buffer into which IUCV moves the reply
- *                 of this message.
- *        anslen - Address of length reply buffers.
- * Output: msgid - Specifies the message ID.
- * Return: Return code from CP IUCV call.
- *         (-EINVAL) - Buffer address is NULL.
-*/
-int iucv_send2way_array (u16 pathid,
-                        u32 * msgid,
-                        u32 trgcls,
-                        u32 srccls,
-                        u32 msgtag,
-                        int flags1,
-                        iucv_array_t * buffer,
-                        ulong buflen, iucv_array_t * ansbuf, ulong anslen);
-
-/*
- * Name: iucv_send2way_prmmsg
- * Purpose: This function transmits data to another application.
- *          Prmmsg specifies that the 8-bytes of data are to be moved
- *          into the parameter list. This is a two-way message and the
- *          receiver of the message is expected to reply. A buffer
- *          is provided into which IUCV moves the reply to this
- *          message.
- * Input: pathid - Rath identification number.
- *        trgcls - Specifies target class.
- *        srccls - Specifies the source message class.
- *        msgtag - Specifies a tag to be associated with the message.
- *        flags1 - Option for path.
- *          IPPRTY- 0x20 Specifies if you want to send priority message.
- *        prmmsg - 8-bytes of data to be placed in parameter list.
- *        ansbuf - Address of buffer into which IUCV moves the reply of
- *                 this message.
- *        anslen - Address of length of buffer.
- * Output: msgid - Specifies the message ID.
- * Return: Return code from CP IUCV call.
- *         (-EINVAL) - Buffer address is NULL.
-*/
-int iucv_send2way_prmmsg (u16 pathid,
-                         u32 * msgid,
-                         u32 trgcls,
-                         u32 srccls,
-                         u32 msgtag,
-                         ulong flags1,
-                         uchar prmmsg[8], void *ansbuf, ulong anslen);
-
-/*
- * Name: iucv_send2way_prmmsg_array
- * Purpose: This function transmits data to another application.
- *          Prmmsg specifies that the 8-bytes of data are to be moved
- *          into the parameter list. This is a two-way message and the
- *          receiver of the message is expected to reply. A buffer
- *          is provided into which IUCV moves the reply to this
- *          message. The contents of ansbuf is the address of the
- *          array of addresses and lengths of discontiguous buffers
- *          that contain the reply.
- * Input: pathid - Path identification number.
- *        trgcls - Specifies target class.
- *        srccls - Specifies the source message class.
- *        msgtag - Specifies a tag to be associated with the message.
- *        flags1 - Option for path.
- *          IPPRTY- 0x20 specifies if you want to send priority message.
- *        prmmsg - 8-bytes of data to be placed into the parameter list.
- *        ansbuf - Address of array of buffer into which IUCV moves the reply
- *                 of this message.
- *        anslen - Address of length of reply buffers.
- * Output: msgid - Specifies the message ID.
- * Return: Return code from CP IUCV call.
- *         (-EINVAL) - Ansbuf address is NULL.
-*/
-int iucv_send2way_prmmsg_array (u16 pathid,
-                               u32 * msgid,
-                               u32 trgcls,
-                               u32 srccls,
-                               u32 msgtag,
-                               int flags1,
-                               uchar prmmsg[8],
-                               iucv_array_t * ansbuf, ulong anslen);
-
-/*
- * Name: iucv_setmask
- * Purpose: This function enables or disables the following IUCV
- *          external interruptions: Nonpriority and priority message
- *          interrupts, nonpriority and priority reply interrupts.
- * Input: SetMaskFlag - options for interrupts
- *           0x80 - Nonpriority_MessagePendingInterruptsFlag
- *           0x40 - Priority_MessagePendingInterruptsFlag
- *           0x20 - Nonpriority_MessageCompletionInterruptsFlag
- *           0x10 - Priority_MessageCompletionInterruptsFlag
- *           0x08 - IUCVControlInterruptsFlag
- * Output: NA
- * Return: Return code from CP IUCV call.
-*/
-int iucv_setmask (int SetMaskFlag);
-
-/*
- * Name: iucv_sever
- * Purpose: This function terminates an IUCV path.
- * Input: pathid - Path identification number.
- *        user_data - 16-bytes of user data.
- * Output: NA
- * Return: Return code from CP IUCV call.
- *         (-EINVAL) - Interal error, wild pointer.
-*/
-int iucv_sever (u16 pathid, uchar user_data[16]);
index b97dd15bdb9a1ecb7d0b15b3c6ffcbc49ff12200..ecca1046714efd213f57fce49a69bca391faf047 100644 (file)
@@ -1511,8 +1511,7 @@ lcs_txbuffer_cb(struct lcs_channel *channel, struct lcs_buffer *buffer)
        LCS_DBF_TEXT(5, trace, "txbuffcb");
        /* Put buffer back to pool. */
        lcs_release_buffer(channel, buffer);
-       card = (struct lcs_card *)
-               ((char *) channel - offsetof(struct lcs_card, write));
+       card = container_of(channel, struct lcs_card, write);
        if (netif_queue_stopped(card->dev) && netif_carrier_ok(card->dev))
                netif_wake_queue(card->dev);
        spin_lock(&card->lock);
@@ -1810,8 +1809,7 @@ lcs_get_frames_cb(struct lcs_channel *channel, struct lcs_buffer *buffer)
                LCS_DBF_TEXT(4, trace, "-eiogpkt");
                return;
        }
-       card = (struct lcs_card *)
-               ((char *) channel - offsetof(struct lcs_card, read));
+       card = container_of(channel, struct lcs_card, read);
        offset = 0;
        while (lcs_hdr->offset != 0) {
                if (lcs_hdr->offset <= 0 ||
index 3346088f47e0b6bc2fc708726e2173bc9704493a..6387b483f2bfe32fb7c7875fa28fe5b742222e67 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * IUCV network driver
  *
- * Copyright (C) 2001 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ * Copyright 2001 IBM Deutschland Entwicklung GmbH, IBM Corporation
  * Author(s): Fritz Elfert (elfert@de.ibm.com, felfert@millenux.com)
  *
  * Sysfs integration and all bugs therein by Cornelia Huck
 #include <asm/io.h>
 #include <asm/uaccess.h>
 
-#include "iucv.h"
+#include <net/iucv/iucv.h>
 #include "fsm.h"
 
 MODULE_AUTHOR
     ("(C) 2001 IBM Corporation by Fritz Elfert (felfert@millenux.com)");
 MODULE_DESCRIPTION ("Linux for S/390 IUCV network driver");
 
+/**
+ * Debug Facility stuff
+ */
+#define IUCV_DBF_SETUP_NAME "iucv_setup"
+#define IUCV_DBF_SETUP_LEN 32
+#define IUCV_DBF_SETUP_PAGES 2
+#define IUCV_DBF_SETUP_NR_AREAS 1
+#define IUCV_DBF_SETUP_LEVEL 3
+
+#define IUCV_DBF_DATA_NAME "iucv_data"
+#define IUCV_DBF_DATA_LEN 128
+#define IUCV_DBF_DATA_PAGES 2
+#define IUCV_DBF_DATA_NR_AREAS 1
+#define IUCV_DBF_DATA_LEVEL 2
+
+#define IUCV_DBF_TRACE_NAME "iucv_trace"
+#define IUCV_DBF_TRACE_LEN 16
+#define IUCV_DBF_TRACE_PAGES 4
+#define IUCV_DBF_TRACE_NR_AREAS 1
+#define IUCV_DBF_TRACE_LEVEL 3
+
+#define IUCV_DBF_TEXT(name,level,text) \
+       do { \
+               debug_text_event(iucv_dbf_##name,level,text); \
+       } while (0)
+
+#define IUCV_DBF_HEX(name,level,addr,len) \
+       do { \
+               debug_event(iucv_dbf_##name,level,(void*)(addr),len); \
+       } while (0)
+
+DECLARE_PER_CPU(char[256], iucv_dbf_txt_buf);
+
+#define IUCV_DBF_TEXT_(name,level,text...)                             \
+       do {                                                            \
+               char* iucv_dbf_txt_buf = get_cpu_var(iucv_dbf_txt_buf); \
+               sprintf(iucv_dbf_txt_buf, text);                        \
+               debug_text_event(iucv_dbf_##name,level,iucv_dbf_txt_buf); \
+               put_cpu_var(iucv_dbf_txt_buf);                          \
+       } while (0)
+
+#define IUCV_DBF_SPRINTF(name,level,text...) \
+       do { \
+               debug_sprintf_event(iucv_dbf_trace, level, ##text ); \
+               debug_sprintf_event(iucv_dbf_trace, level, text ); \
+       } while (0)
+
+/**
+ * some more debug stuff
+ */
+#define IUCV_HEXDUMP16(importance,header,ptr) \
+PRINT_##importance(header "%02x %02x %02x %02x  %02x %02x %02x %02x  " \
+                  "%02x %02x %02x %02x  %02x %02x %02x %02x\n", \
+                  *(((char*)ptr)),*(((char*)ptr)+1),*(((char*)ptr)+2), \
+                  *(((char*)ptr)+3),*(((char*)ptr)+4),*(((char*)ptr)+5), \
+                  *(((char*)ptr)+6),*(((char*)ptr)+7),*(((char*)ptr)+8), \
+                  *(((char*)ptr)+9),*(((char*)ptr)+10),*(((char*)ptr)+11), \
+                  *(((char*)ptr)+12),*(((char*)ptr)+13), \
+                  *(((char*)ptr)+14),*(((char*)ptr)+15)); \
+PRINT_##importance(header "%02x %02x %02x %02x  %02x %02x %02x %02x  " \
+                  "%02x %02x %02x %02x  %02x %02x %02x %02x\n", \
+                  *(((char*)ptr)+16),*(((char*)ptr)+17), \
+                  *(((char*)ptr)+18),*(((char*)ptr)+19), \
+                  *(((char*)ptr)+20),*(((char*)ptr)+21), \
+                  *(((char*)ptr)+22),*(((char*)ptr)+23), \
+                  *(((char*)ptr)+24),*(((char*)ptr)+25), \
+                  *(((char*)ptr)+26),*(((char*)ptr)+27), \
+                  *(((char*)ptr)+28),*(((char*)ptr)+29), \
+                  *(((char*)ptr)+30),*(((char*)ptr)+31));
+
+static inline void iucv_hex_dump(unsigned char *buf, size_t len)
+{
+       size_t i;
+
+       for (i = 0; i < len; i++) {
+               if (i && !(i % 16))
+                       printk("\n");
+               printk("%02x ", *(buf + i));
+       }
+       printk("\n");
+}
 
 #define PRINTK_HEADER " iucv: "       /* for debugging */
 
@@ -73,6 +154,25 @@ static struct device_driver netiucv_driver = {
        .bus  = &iucv_bus,
 };
 
+static int netiucv_callback_connreq(struct iucv_path *,
+                                   u8 ipvmid[8], u8 ipuser[16]);
+static void netiucv_callback_connack(struct iucv_path *, u8 ipuser[16]);
+static void netiucv_callback_connrej(struct iucv_path *, u8 ipuser[16]);
+static void netiucv_callback_connsusp(struct iucv_path *, u8 ipuser[16]);
+static void netiucv_callback_connres(struct iucv_path *, u8 ipuser[16]);
+static void netiucv_callback_rx(struct iucv_path *, struct iucv_message *);
+static void netiucv_callback_txdone(struct iucv_path *, struct iucv_message *);
+
+static struct iucv_handler netiucv_handler = {
+       .path_pending     = netiucv_callback_connreq,
+       .path_complete    = netiucv_callback_connack,
+       .path_severed     = netiucv_callback_connrej,
+       .path_quiesced    = netiucv_callback_connsusp,
+       .path_resumed     = netiucv_callback_connres,
+       .message_pending  = netiucv_callback_rx,
+       .message_complete = netiucv_callback_txdone
+};
+
 /**
  * Per connection profiling data
  */
@@ -92,9 +192,8 @@ struct connection_profile {
  * Representation of one iucv connection
  */
 struct iucv_connection {
-       struct iucv_connection    *next;
-       iucv_handle_t             handle;
-       __u16                     pathid;
+       struct list_head          list;
+       struct iucv_path          *path;
        struct sk_buff            *rx_buff;
        struct sk_buff            *tx_buff;
        struct sk_buff_head       collect_queue;
@@ -112,12 +211,9 @@ struct iucv_connection {
 /**
  * Linked list of all connection structs.
  */
-struct iucv_connection_struct {
-       struct iucv_connection *iucv_connections;
-       rwlock_t iucv_rwlock;
-};
-
-static struct iucv_connection_struct iucv_conns;
+static struct list_head iucv_connection_list =
+       LIST_HEAD_INIT(iucv_connection_list);
+static rwlock_t iucv_connection_rwlock = RW_LOCK_UNLOCKED;
 
 /**
  * Representation of event-data for the
@@ -142,11 +238,11 @@ struct netiucv_priv {
 /**
  * Link level header for a packet.
  */
-typedef struct ll_header_t {
-       __u16 next;
-} ll_header;
+struct ll_header {
+       u16 next;
+};
 
-#define NETIUCV_HDRLEN           (sizeof(ll_header))
+#define NETIUCV_HDRLEN          (sizeof(struct ll_header))
 #define NETIUCV_BUFSIZE_MAX      32768
 #define NETIUCV_BUFSIZE_DEFAULT  NETIUCV_BUFSIZE_MAX
 #define NETIUCV_MTU_MAX          (NETIUCV_BUFSIZE_MAX - NETIUCV_HDRLEN)
@@ -158,35 +254,25 @@ typedef struct ll_header_t {
  * Compatibility macros for busy handling
  * of network devices.
  */
-static __inline__ void netiucv_clear_busy(struct net_device *dev)
+static inline void netiucv_clear_busy(struct net_device *dev)
 {
-       clear_bit(0, &(((struct netiucv_priv *)dev->priv)->tbusy));
+       struct netiucv_priv *priv = netdev_priv(dev);
+       clear_bit(0, &priv->tbusy);
        netif_wake_queue(dev);
 }
 
-static __inline__ int netiucv_test_and_set_busy(struct net_device *dev)
+static inline int netiucv_test_and_set_busy(struct net_device *dev)
 {
+       struct netiucv_priv *priv = netdev_priv(dev);
        netif_stop_queue(dev);
-       return test_and_set_bit(0, &((struct netiucv_priv *)dev->priv)->tbusy);
+       return test_and_set_bit(0, &priv->tbusy);
 }
 
-static __u8 iucv_host[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-static __u8 iucvMagic[16] = {
+static u8 iucvMagic[16] = {
        0xF0, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
        0xF0, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40
 };
 
-/**
- * This mask means the 16-byte IUCV "magic" and the origin userid must
- * match exactly as specified in order to give connection_pending()
- * control.
- */
-static __u8 netiucv_mask[] = {
-       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
-};
-
 /**
  * Convert an iucv userId to its printable
  * form (strip whitespace at end).
@@ -195,8 +281,7 @@ static __u8 netiucv_mask[] = {
  *
  * @returns The printable string (static data!!)
  */
-static __inline__ char *
-netiucv_printname(char *name)
+static inline char *netiucv_printname(char *name)
 {
        static char tmp[9];
        char *p = tmp;
@@ -379,8 +464,7 @@ static debug_info_t *iucv_dbf_trace = NULL;
 
 DEFINE_PER_CPU(char[256], iucv_dbf_txt_buf);
 
-static void
-iucv_unregister_dbf_views(void)
+static void iucv_unregister_dbf_views(void)
 {
        if (iucv_dbf_setup)
                debug_unregister(iucv_dbf_setup);
@@ -389,8 +473,7 @@ iucv_unregister_dbf_views(void)
        if (iucv_dbf_trace)
                debug_unregister(iucv_dbf_trace);
 }
-static int
-iucv_register_dbf_views(void)
+static int iucv_register_dbf_views(void)
 {
        iucv_dbf_setup = debug_register(IUCV_DBF_SETUP_NAME,
                                        IUCV_DBF_SETUP_PAGES,
@@ -422,125 +505,111 @@ iucv_register_dbf_views(void)
        return 0;
 }
 
-/**
+/*
  * Callback-wrappers, called from lowlevel iucv layer.
- *****************************************************************************/
+ */
 
-static void
-netiucv_callback_rx(iucv_MessagePending *eib, void *pgm_data)
+static void netiucv_callback_rx(struct iucv_path *path,
+                               struct iucv_message *msg)
 {
-       struct iucv_connection *conn = (struct iucv_connection *)pgm_data;
+       struct iucv_connection *conn = path->private;
        struct iucv_event ev;
 
        ev.conn = conn;
-       ev.data = (void *)eib;
-
+       ev.data = msg;
        fsm_event(conn->fsm, CONN_EVENT_RX, &ev);
 }
 
-static void
-netiucv_callback_txdone(iucv_MessageComplete *eib, void *pgm_data)
+static void netiucv_callback_txdone(struct iucv_path *path,
+                                   struct iucv_message *msg)
 {
-       struct iucv_connection *conn = (struct iucv_connection *)pgm_data;
+       struct iucv_connection *conn = path->private;
        struct iucv_event ev;
 
        ev.conn = conn;
-       ev.data = (void *)eib;
+       ev.data = msg;
        fsm_event(conn->fsm, CONN_EVENT_TXDONE, &ev);
 }
 
-static void
-netiucv_callback_connack(iucv_ConnectionComplete *eib, void *pgm_data)
+static void netiucv_callback_connack(struct iucv_path *path, u8 ipuser[16])
 {
-       struct iucv_connection *conn = (struct iucv_connection *)pgm_data;
-       struct iucv_event ev;
+       struct iucv_connection *conn = path->private;
 
-       ev.conn = conn;
-       ev.data = (void *)eib;
-       fsm_event(conn->fsm, CONN_EVENT_CONN_ACK, &ev);
+       fsm_event(conn->fsm, CONN_EVENT_CONN_ACK, conn);
 }
 
-static void
-netiucv_callback_connreq(iucv_ConnectionPending *eib, void *pgm_data)
+static int netiucv_callback_connreq(struct iucv_path *path,
+                                   u8 ipvmid[8], u8 ipuser[16])
 {
-       struct iucv_connection *conn = (struct iucv_connection *)pgm_data;
+       struct iucv_connection *conn = path->private;
        struct iucv_event ev;
+       int rc;
 
-       ev.conn = conn;
-       ev.data = (void *)eib;
-       fsm_event(conn->fsm, CONN_EVENT_CONN_REQ, &ev);
+       if (memcmp(iucvMagic, ipuser, sizeof(ipuser)))
+               /* ipuser must match iucvMagic. */
+               return -EINVAL;
+       rc = -EINVAL;
+       read_lock_bh(&iucv_connection_rwlock);
+       list_for_each_entry(conn, &iucv_connection_list, list) {
+               if (strncmp(ipvmid, conn->userid, 8))
+                       continue;
+               /* Found a matching connection for this path. */
+               conn->path = path;
+               ev.conn = conn;
+               ev.data = path;
+               fsm_event(conn->fsm, CONN_EVENT_CONN_REQ, &ev);
+               rc = 0;
+       }
+       read_unlock_bh(&iucv_connection_rwlock);
+       return rc;
 }
 
-static void
-netiucv_callback_connrej(iucv_ConnectionSevered *eib, void *pgm_data)
+static void netiucv_callback_connrej(struct iucv_path *path, u8 ipuser[16])
 {
-       struct iucv_connection *conn = (struct iucv_connection *)pgm_data;
-       struct iucv_event ev;
+       struct iucv_connection *conn = path->private;
 
-       ev.conn = conn;
-       ev.data = (void *)eib;
-       fsm_event(conn->fsm, CONN_EVENT_CONN_REJ, &ev);
+       fsm_event(conn->fsm, CONN_EVENT_CONN_REJ, conn);
 }
 
-static void
-netiucv_callback_connsusp(iucv_ConnectionQuiesced *eib, void *pgm_data)
+static void netiucv_callback_connsusp(struct iucv_path *path, u8 ipuser[16])
 {
-       struct iucv_connection *conn = (struct iucv_connection *)pgm_data;
-       struct iucv_event ev;
+       struct iucv_connection *conn = path->private;
 
-       ev.conn = conn;
-       ev.data = (void *)eib;
-       fsm_event(conn->fsm, CONN_EVENT_CONN_SUS, &ev);
+       fsm_event(conn->fsm, CONN_EVENT_CONN_SUS, conn);
 }
 
-static void
-netiucv_callback_connres(iucv_ConnectionResumed *eib, void *pgm_data)
+static void netiucv_callback_connres(struct iucv_path *path, u8 ipuser[16])
 {
-       struct iucv_connection *conn = (struct iucv_connection *)pgm_data;
-       struct iucv_event ev;
+       struct iucv_connection *conn = path->private;
 
-       ev.conn = conn;
-       ev.data = (void *)eib;
-       fsm_event(conn->fsm, CONN_EVENT_CONN_RES, &ev);
-}
-
-static iucv_interrupt_ops_t netiucv_ops = {
-       .ConnectionPending  = netiucv_callback_connreq,
-       .ConnectionComplete = netiucv_callback_connack,
-       .ConnectionSevered  = netiucv_callback_connrej,
-       .ConnectionQuiesced = netiucv_callback_connsusp,
-       .ConnectionResumed  = netiucv_callback_connres,
-       .MessagePending     = netiucv_callback_rx,
-       .MessageComplete    = netiucv_callback_txdone
-};
+       fsm_event(conn->fsm, CONN_EVENT_CONN_RES, conn);
+}
 
 /**
  * Dummy NOP action for all statemachines
  */
-static void
-fsm_action_nop(fsm_instance *fi, int event, void *arg)
+static void fsm_action_nop(fsm_instance *fi, int event, void *arg)
 {
 }
 
-/**
+/*
  * Actions of the connection statemachine
- *****************************************************************************/
+ */
 
 /**
- * Helper function for conn_action_rx()
- * Unpack a just received skb and hand it over to
- * upper layers.
+ * netiucv_unpack_skb
+ * @conn: The connection where this skb has been received.
+ * @pskb: The received skb.
  *
- * @param conn The connection where this skb has been received.
- * @param pskb The received skb.
+ * Unpack a just received skb and hand it over to upper layers.
+ * Helper function for conn_action_rx.
  */
-//static __inline__ void
-static void
-netiucv_unpack_skb(struct iucv_connection *conn, struct sk_buff *pskb)
+static void netiucv_unpack_skb(struct iucv_connection *conn,
+                              struct sk_buff *pskb)
 {
        struct net_device     *dev = conn->netdev;
-       struct netiucv_priv   *privptr = dev->priv;
-       __u16          offset = 0;
+       struct netiucv_priv   *privptr = netdev_priv(dev);
+       u16 offset = 0;
 
        skb_put(pskb, NETIUCV_HDRLEN);
        pskb->dev = dev;
@@ -549,7 +618,7 @@ netiucv_unpack_skb(struct iucv_connection *conn, struct sk_buff *pskb)
 
        while (1) {
                struct sk_buff *skb;
-               ll_header *header = (ll_header *)pskb->data;
+               struct ll_header *header = (struct ll_header *) pskb->data;
 
                if (!header->next)
                        break;
@@ -595,40 +664,37 @@ netiucv_unpack_skb(struct iucv_connection *conn, struct sk_buff *pskb)
        }
 }
 
-static void
-conn_action_rx(fsm_instance *fi, int event, void *arg)
+static void conn_action_rx(fsm_instance *fi, int event, void *arg)
 {
-       struct iucv_event *ev = (struct iucv_event *)arg;
+       struct iucv_event *ev = arg;
        struct iucv_connection *conn = ev->conn;
-       iucv_MessagePending *eib = (iucv_MessagePending *)ev->data;
-       struct netiucv_priv *privptr =(struct netiucv_priv *)conn->netdev->priv;
-
-       __u32 msglen = eib->ln1msg2.ipbfln1f;
+       struct iucv_message *msg = ev->data;
+       struct netiucv_priv *privptr = netdev_priv(conn->netdev);
        int rc;
 
        IUCV_DBF_TEXT(trace, 4, __FUNCTION__);
 
        if (!conn->netdev) {
-               /* FRITZ: How to tell iucv LL to drop the msg? */
+               iucv_message_reject(conn->path, msg);
                PRINT_WARN("Received data for unlinked connection\n");
                IUCV_DBF_TEXT(data, 2,
-                       "Received data for unlinked connection\n");
+                             "Received data for unlinked connection\n");
                return;
        }
-       if (msglen > conn->max_buffsize) {
-               /* FRITZ: How to tell iucv LL to drop the msg? */
+       if (msg->length > conn->max_buffsize) {
+               iucv_message_reject(conn->path, msg);
                privptr->stats.rx_dropped++;
                PRINT_WARN("msglen %d > max_buffsize %d\n",
-                       msglen, conn->max_buffsize);
+                          msg->length, conn->max_buffsize);
                IUCV_DBF_TEXT_(data, 2, "msglen %d > max_buffsize %d\n",
-                       msglen, conn->max_buffsize);
+                              msg->length, conn->max_buffsize);
                return;
        }
        conn->rx_buff->data = conn->rx_buff->tail = conn->rx_buff->head;
        conn->rx_buff->len = 0;
-       rc = iucv_receive(conn->pathid, eib->ipmsgid, eib->iptrgcls,
-                         conn->rx_buff->data, msglen, NULL, NULL, NULL);
-       if (rc || msglen < 5) {
+       rc = iucv_message_receive(conn->path, msg, 0, conn->rx_buff->data,
+                                 msg->length, NULL);
+       if (rc || msg->length < 5) {
                privptr->stats.rx_errors++;
                PRINT_WARN("iucv_receive returned %08x\n", rc);
                IUCV_DBF_TEXT_(data, 2, "rc %d from iucv_receive\n", rc);
@@ -637,26 +703,26 @@ conn_action_rx(fsm_instance *fi, int event, void *arg)
        netiucv_unpack_skb(conn, conn->rx_buff);
 }
 
-static void
-conn_action_txdone(fsm_instance *fi, int event, void *arg)
+static void conn_action_txdone(fsm_instance *fi, int event, void *arg)
 {
-       struct iucv_event *ev = (struct iucv_event *)arg;
+       struct iucv_event *ev = arg;
        struct iucv_connection *conn = ev->conn;
-       iucv_MessageComplete *eib = (iucv_MessageComplete *)ev->data;
+       struct iucv_message *msg = ev->data;
+       struct iucv_message txmsg;
        struct netiucv_priv *privptr = NULL;
-                                /* Shut up, gcc! skb is always below 2G. */
-       __u32 single_flag = eib->ipmsgtag;
-       __u32 txbytes = 0;
-       __u32 txpackets = 0;
-       __u32 stat_maxcq = 0;
+       u32 single_flag = msg->tag;
+       u32 txbytes = 0;
+       u32 txpackets = 0;
+       u32 stat_maxcq = 0;
        struct sk_buff *skb;
        unsigned long saveflags;
-       ll_header header;
+       struct ll_header header;
+       int rc;
 
        IUCV_DBF_TEXT(trace, 4, __FUNCTION__);
 
-       if (conn && conn->netdev && conn->netdev->priv)
-               privptr = (struct netiucv_priv *)conn->netdev->priv;
+       if (conn && conn->netdev)
+               privptr = netdev_priv(conn->netdev);
        conn->prof.tx_pending--;
        if (single_flag) {
                if ((skb = skb_dequeue(&conn->commit_queue))) {
@@ -688,56 +754,55 @@ conn_action_txdone(fsm_instance *fi, int event, void *arg)
                conn->prof.maxmulti = conn->collect_len;
        conn->collect_len = 0;
        spin_unlock_irqrestore(&conn->collect_lock, saveflags);
-       if (conn->tx_buff->len) {
-               int rc;
-
-               header.next = 0;
-               memcpy(skb_put(conn->tx_buff, NETIUCV_HDRLEN), &header,
-                      NETIUCV_HDRLEN);
+       if (conn->tx_buff->len == 0) {
+               fsm_newstate(fi, CONN_STATE_IDLE);
+               return;
+       }
 
-               conn->prof.send_stamp = xtime;
-               rc = iucv_send(conn->pathid, NULL, 0, 0, 0, 0,
+       header.next = 0;
+       memcpy(skb_put(conn->tx_buff, NETIUCV_HDRLEN), &header, NETIUCV_HDRLEN);
+       conn->prof.send_stamp = xtime;
+       txmsg.class = 0;
+       txmsg.tag = 0;
+       rc = iucv_message_send(conn->path, &txmsg, 0, 0,
                               conn->tx_buff->data, conn->tx_buff->len);
-               conn->prof.doios_multi++;
-               conn->prof.txlen += conn->tx_buff->len;
-               conn->prof.tx_pending++;
-               if (conn->prof.tx_pending > conn->prof.tx_max_pending)
-                       conn->prof.tx_max_pending = conn->prof.tx_pending;
-               if (rc) {
-                       conn->prof.tx_pending--;
-                       fsm_newstate(fi, CONN_STATE_IDLE);
-                       if (privptr)
-                               privptr->stats.tx_errors += txpackets;
-                       PRINT_WARN("iucv_send returned %08x\n", rc);
-                       IUCV_DBF_TEXT_(data, 2, "rc %d from iucv_send\n", rc);
-               } else {
-                       if (privptr) {
-                               privptr->stats.tx_packets += txpackets;
-                               privptr->stats.tx_bytes += txbytes;
-                       }
-                       if (stat_maxcq > conn->prof.maxcqueue)
-                               conn->prof.maxcqueue = stat_maxcq;
-               }
-       } else
+       conn->prof.doios_multi++;
+       conn->prof.txlen += conn->tx_buff->len;
+       conn->prof.tx_pending++;
+       if (conn->prof.tx_pending > conn->prof.tx_max_pending)
+               conn->prof.tx_max_pending = conn->prof.tx_pending;
+       if (rc) {
+               conn->prof.tx_pending--;
                fsm_newstate(fi, CONN_STATE_IDLE);
+               if (privptr)
+                       privptr->stats.tx_errors += txpackets;
+               PRINT_WARN("iucv_send returned %08x\n", rc);
+               IUCV_DBF_TEXT_(data, 2, "rc %d from iucv_send\n", rc);
+       } else {
+               if (privptr) {
+                       privptr->stats.tx_packets += txpackets;
+                       privptr->stats.tx_bytes += txbytes;
+               }
+               if (stat_maxcq > conn->prof.maxcqueue)
+                       conn->prof.maxcqueue = stat_maxcq;
+       }
 }
 
-static void
-conn_action_connaccept(fsm_instance *fi, int event, void *arg)
+static void conn_action_connaccept(fsm_instance *fi, int event, void *arg)
 {
-       struct iucv_event *ev = (struct iucv_event *)arg;
+       struct iucv_event *ev = arg;
        struct iucv_connection *conn = ev->conn;
-       iucv_ConnectionPending *eib = (iucv_ConnectionPending *)ev->data;
+       struct iucv_path *path = ev->data;
        struct net_device *netdev = conn->netdev;
-       struct netiucv_priv *privptr = (struct netiucv_priv *)netdev->priv;
+       struct netiucv_priv *privptr = netdev_priv(netdev);
        int rc;
-       __u16 msglimit;
-       __u8 udata[16];
 
        IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
 
-       rc = iucv_accept(eib->ippathid, NETIUCV_QUEUELEN_DEFAULT, udata, 0,
-                        conn->handle, conn, NULL, &msglimit);
+       conn->path = path;
+       path->msglim = NETIUCV_QUEUELEN_DEFAULT;
+       path->flags = 0;
+       rc = iucv_path_accept(path, &netiucv_handler, NULL, conn);
        if (rc) {
                PRINT_WARN("%s: IUCV accept failed with error %d\n",
                       netdev->name, rc);
@@ -745,183 +810,126 @@ conn_action_connaccept(fsm_instance *fi, int event, void *arg)
                return;
        }
        fsm_newstate(fi, CONN_STATE_IDLE);
-       conn->pathid = eib->ippathid;
-       netdev->tx_queue_len = msglimit;
+       netdev->tx_queue_len = conn->path->msglim;
        fsm_event(privptr->fsm, DEV_EVENT_CONUP, netdev);
 }
 
-static void
-conn_action_connreject(fsm_instance *fi, int event, void *arg)
+static void conn_action_connreject(fsm_instance *fi, int event, void *arg)
 {
-       struct iucv_event *ev = (struct iucv_event *)arg;
-       struct iucv_connection *conn = ev->conn;
-       struct net_device *netdev = conn->netdev;
-       iucv_ConnectionPending *eib = (iucv_ConnectionPending *)ev->data;
-       __u8 udata[16];
+       struct iucv_event *ev = arg;
+       struct iucv_path *path = ev->data;
 
        IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
-
-       iucv_sever(eib->ippathid, udata);
-       if (eib->ippathid != conn->pathid) {
-               PRINT_INFO("%s: IR Connection Pending; "
-                       "pathid %d does not match original pathid %d\n",
-                       netdev->name, eib->ippathid, conn->pathid);
-               IUCV_DBF_TEXT_(data, 2,
-                       "connreject: IR pathid %d, conn. pathid %d\n",
-                       eib->ippathid, conn->pathid);
-               iucv_sever(conn->pathid, udata);
-       }
+       iucv_path_sever(path, NULL);
 }
 
-static void
-conn_action_connack(fsm_instance *fi, int event, void *arg)
+static void conn_action_connack(fsm_instance *fi, int event, void *arg)
 {
-       struct iucv_event *ev = (struct iucv_event *)arg;
-       struct iucv_connection *conn = ev->conn;
-       iucv_ConnectionComplete *eib = (iucv_ConnectionComplete *)ev->data;
+       struct iucv_connection *conn = arg;
        struct net_device *netdev = conn->netdev;
-       struct netiucv_priv *privptr = (struct netiucv_priv *)netdev->priv;
+       struct netiucv_priv *privptr = netdev_priv(netdev);
 
        IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
-
        fsm_deltimer(&conn->timer);
        fsm_newstate(fi, CONN_STATE_IDLE);
-       if (eib->ippathid != conn->pathid) {
-               PRINT_INFO("%s: IR Connection Complete; "
-                       "pathid %d does not match original pathid %d\n",
-                       netdev->name, eib->ippathid, conn->pathid);
-               IUCV_DBF_TEXT_(data, 2,
-                       "connack: IR pathid %d, conn. pathid %d\n",
-                       eib->ippathid, conn->pathid);
-               conn->pathid = eib->ippathid;
-       }
-       netdev->tx_queue_len = eib->ipmsglim;
+       netdev->tx_queue_len = conn->path->msglim;
        fsm_event(privptr->fsm, DEV_EVENT_CONUP, netdev);
 }
 
-static void
-conn_action_conntimsev(fsm_instance *fi, int event, void *arg)
+static void conn_action_conntimsev(fsm_instance *fi, int event, void *arg)
 {
-       struct iucv_connection *conn = (struct iucv_connection *)arg;
-       __u8 udata[16];
+       struct iucv_connection *conn = arg;
 
        IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
-
        fsm_deltimer(&conn->timer);
-       iucv_sever(conn->pathid, udata);
+       iucv_path_sever(conn->path, NULL);
        fsm_newstate(fi, CONN_STATE_STARTWAIT);
 }
 
-static void
-conn_action_connsever(fsm_instance *fi, int event, void *arg)
+static void conn_action_connsever(fsm_instance *fi, int event, void *arg)
 {
-       struct iucv_event *ev = (struct iucv_event *)arg;
-       struct iucv_connection *conn = ev->conn;
+       struct iucv_connection *conn = arg;
        struct net_device *netdev = conn->netdev;
-       struct netiucv_priv *privptr = (struct netiucv_priv *)netdev->priv;
-       __u8 udata[16];
+       struct netiucv_priv *privptr = netdev_priv(netdev);
 
        IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
 
        fsm_deltimer(&conn->timer);
-       iucv_sever(conn->pathid, udata);
+       iucv_path_sever(conn->path, NULL);
        PRINT_INFO("%s: Remote dropped connection\n", netdev->name);
        IUCV_DBF_TEXT(data, 2,
-               "conn_action_connsever: Remote dropped connection\n");
+                     "conn_action_connsever: Remote dropped connection\n");
        fsm_newstate(fi, CONN_STATE_STARTWAIT);
        fsm_event(privptr->fsm, DEV_EVENT_CONDOWN, netdev);
 }
 
-static void
-conn_action_start(fsm_instance *fi, int event, void *arg)
+static void conn_action_start(fsm_instance *fi, int event, void *arg)
 {
-       struct iucv_event *ev = (struct iucv_event *)arg;
-       struct iucv_connection *conn = ev->conn;
-       __u16 msglimit;
+       struct iucv_connection *conn = arg;
        int rc;
 
        IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
 
-       if (!conn->handle) {
-               IUCV_DBF_TEXT(trace, 5, "calling iucv_register_program\n");
-               conn->handle =
-                       iucv_register_program(iucvMagic, conn->userid,
-                                             netiucv_mask,
-                                             &netiucv_ops, conn);
-               fsm_newstate(fi, CONN_STATE_STARTWAIT);
-               if (!conn->handle) {
-                       fsm_newstate(fi, CONN_STATE_REGERR);
-                       conn->handle = NULL;
-                       IUCV_DBF_TEXT(setup, 2,
-                               "NULL from iucv_register_program\n");
-                       return;
-               }
-
-               PRINT_DEBUG("%s('%s'): registered successfully\n",
-                        conn->netdev->name, conn->userid);
-       }
-
+       fsm_newstate(fi, CONN_STATE_STARTWAIT);
        PRINT_DEBUG("%s('%s'): connecting ...\n",
-                conn->netdev->name, conn->userid);
+                   conn->netdev->name, conn->userid);
 
-       /* We must set the state before calling iucv_connect because the callback
-        * handler could be called at any point after the connection request is
-        * sent */
+       /*
+        * We must set the state before calling iucv_connect because the
+        * callback handler could be called at any point after the connection
+        * request is sent
+        */
 
        fsm_newstate(fi, CONN_STATE_SETUPWAIT);
-       rc = iucv_connect(&(conn->pathid), NETIUCV_QUEUELEN_DEFAULT, iucvMagic,
-                         conn->userid, iucv_host, 0, NULL, &msglimit,
-                         conn->handle, conn);
+       conn->path = iucv_path_alloc(NETIUCV_QUEUELEN_DEFAULT, 0, GFP_KERNEL);
+       rc = iucv_path_connect(conn->path, &netiucv_handler, conn->userid,
+                              NULL, iucvMagic, conn);
        switch (rc) {
-               case 0:
-                       conn->netdev->tx_queue_len = msglimit;
-                       fsm_addtimer(&conn->timer, NETIUCV_TIMEOUT_5SEC,
-                               CONN_EVENT_TIMER, conn);
-                       return;
-               case 11:
-                       PRINT_INFO("%s: User %s is currently not available.\n",
-                              conn->netdev->name,
-                              netiucv_printname(conn->userid));
-                       fsm_newstate(fi, CONN_STATE_STARTWAIT);
-                       return;
-               case 12:
-                       PRINT_INFO("%s: User %s is currently not ready.\n",
-                              conn->netdev->name,
-                              netiucv_printname(conn->userid));
-                       fsm_newstate(fi, CONN_STATE_STARTWAIT);
-                       return;
-               case 13:
-                       PRINT_WARN("%s: Too many IUCV connections.\n",
-                              conn->netdev->name);
-                       fsm_newstate(fi, CONN_STATE_CONNERR);
-                       break;
-               case 14:
-                       PRINT_WARN(
-                              "%s: User %s has too many IUCV connections.\n",
-                              conn->netdev->name,
-                              netiucv_printname(conn->userid));
-                       fsm_newstate(fi, CONN_STATE_CONNERR);
-                       break;
-               case 15:
-                       PRINT_WARN(
-                              "%s: No IUCV authorization in CP directory.\n",
-                              conn->netdev->name);
-                       fsm_newstate(fi, CONN_STATE_CONNERR);
-                       break;
-               default:
-                       PRINT_WARN("%s: iucv_connect returned error %d\n",
-                              conn->netdev->name, rc);
-                       fsm_newstate(fi, CONN_STATE_CONNERR);
-                       break;
+       case 0:
+               conn->netdev->tx_queue_len = conn->path->msglim;
+               fsm_addtimer(&conn->timer, NETIUCV_TIMEOUT_5SEC,
+                            CONN_EVENT_TIMER, conn);
+               return;
+       case 11:
+               PRINT_INFO("%s: User %s is currently not available.\n",
+                          conn->netdev->name,
+                          netiucv_printname(conn->userid));
+               fsm_newstate(fi, CONN_STATE_STARTWAIT);
+               break;
+       case 12:
+               PRINT_INFO("%s: User %s is currently not ready.\n",
+                          conn->netdev->name,
+                          netiucv_printname(conn->userid));
+               fsm_newstate(fi, CONN_STATE_STARTWAIT);
+               break;
+       case 13:
+               PRINT_WARN("%s: Too many IUCV connections.\n",
+                          conn->netdev->name);
+               fsm_newstate(fi, CONN_STATE_CONNERR);
+               break;
+       case 14:
+               PRINT_WARN("%s: User %s has too many IUCV connections.\n",
+                          conn->netdev->name,
+                          netiucv_printname(conn->userid));
+               fsm_newstate(fi, CONN_STATE_CONNERR);
+               break;
+       case 15:
+               PRINT_WARN("%s: No IUCV authorization in CP directory.\n",
+                          conn->netdev->name);
+               fsm_newstate(fi, CONN_STATE_CONNERR);
+               break;
+       default:
+               PRINT_WARN("%s: iucv_connect returned error %d\n",
+                          conn->netdev->name, rc);
+               fsm_newstate(fi, CONN_STATE_CONNERR);
+               break;
        }
        IUCV_DBF_TEXT_(setup, 5, "iucv_connect rc is %d\n", rc);
-       IUCV_DBF_TEXT(trace, 5, "calling iucv_unregister_program\n");
-       iucv_unregister_program(conn->handle);
-       conn->handle = NULL;
+       kfree(conn->path);
+       conn->path = NULL;
 }
 
-static void
-netiucv_purge_skb_queue(struct sk_buff_head *q)
+static void netiucv_purge_skb_queue(struct sk_buff_head *q)
 {
        struct sk_buff *skb;
 
@@ -931,36 +939,34 @@ netiucv_purge_skb_queue(struct sk_buff_head *q)
        }
 }
 
-static void
-conn_action_stop(fsm_instance *fi, int event, void *arg)
+static void conn_action_stop(fsm_instance *fi, int event, void *arg)
 {
-       struct iucv_event *ev = (struct iucv_event *)arg;
+       struct iucv_event *ev = arg;
        struct iucv_connection *conn = ev->conn;
        struct net_device *netdev = conn->netdev;
-       struct netiucv_priv *privptr = (struct netiucv_priv *)netdev->priv;
+       struct netiucv_priv *privptr = netdev_priv(netdev);
 
        IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
 
        fsm_deltimer(&conn->timer);
        fsm_newstate(fi, CONN_STATE_STOPPED);
        netiucv_purge_skb_queue(&conn->collect_queue);
-       if (conn->handle)
-               IUCV_DBF_TEXT(trace, 5, "calling iucv_unregister_program\n");
-               iucv_unregister_program(conn->handle);
-       conn->handle = NULL;
+       if (conn->path) {
+               IUCV_DBF_TEXT(trace, 5, "calling iucv_path_sever\n");
+               iucv_path_sever(conn->path, iucvMagic);
+               kfree(conn->path);
+               conn->path = NULL;
+       }
        netiucv_purge_skb_queue(&conn->commit_queue);
        fsm_event(privptr->fsm, DEV_EVENT_CONDOWN, netdev);
 }
 
-static void
-conn_action_inval(fsm_instance *fi, int event, void *arg)
+static void conn_action_inval(fsm_instance *fi, int event, void *arg)
 {
-       struct iucv_event *ev = (struct iucv_event *)arg;
-       struct iucv_connection *conn = ev->conn;
+       struct iucv_connection *conn = arg;
        struct net_device *netdev = conn->netdev;
 
-       PRINT_WARN("%s: Cannot connect without username\n",
-              netdev->name);
+       PRINT_WARN("%s: Cannot connect without username\n", netdev->name);
        IUCV_DBF_TEXT(data, 2, "conn_action_inval called\n");
 }
 
@@ -999,29 +1005,27 @@ static const fsm_node conn_fsm[] = {
 static const int CONN_FSM_LEN = sizeof(conn_fsm) / sizeof(fsm_node);
 
 
-/**
+/*
  * Actions for interface - statemachine.
- *****************************************************************************/
+ */
 
 /**
- * Startup connection by sending CONN_EVENT_START to it.
+ * dev_action_start
+ * @fi: An instance of an interface statemachine.
+ * @event: The event, just happened.
+ * @arg: Generic pointer, casted from struct net_device * upon call.
  *
- * @param fi    An instance of an interface statemachine.
- * @param event The event, just happened.
- * @param arg   Generic pointer, casted from struct net_device * upon call.
+ * Startup connection by sending CONN_EVENT_START to it.
  */
-static void
-dev_action_start(fsm_instance *fi, int event, void *arg)
+static void dev_action_start(fsm_instance *fi, int event, void *arg)
 {
-       struct net_device   *dev = (struct net_device *)arg;
-       struct netiucv_priv *privptr = dev->priv;
-       struct iucv_event   ev;
+       struct net_device   *dev = arg;
+       struct netiucv_priv *privptr = netdev_priv(dev);
 
        IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
 
-       ev.conn = privptr->conn;
        fsm_newstate(fi, DEV_STATE_STARTWAIT);
-       fsm_event(privptr->conn->fsm, CONN_EVENT_START, &ev);
+       fsm_event(privptr->conn->fsm, CONN_EVENT_START, privptr->conn);
 }
 
 /**
@@ -1034,8 +1038,8 @@ dev_action_start(fsm_instance *fi, int event, void *arg)
 static void
 dev_action_stop(fsm_instance *fi, int event, void *arg)
 {
-       struct net_device   *dev = (struct net_device *)arg;
-       struct netiucv_priv *privptr = dev->priv;
+       struct net_device   *dev = arg;
+       struct netiucv_priv *privptr = netdev_priv(dev);
        struct iucv_event   ev;
 
        IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
@@ -1057,8 +1061,8 @@ dev_action_stop(fsm_instance *fi, int event, void *arg)
 static void
 dev_action_connup(fsm_instance *fi, int event, void *arg)
 {
-       struct net_device   *dev = (struct net_device *)arg;
-       struct netiucv_priv *privptr = dev->priv;
+       struct net_device   *dev = arg;
+       struct netiucv_priv *privptr = netdev_priv(dev);
 
        IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
 
@@ -1131,11 +1135,13 @@ static const int DEV_FSM_LEN = sizeof(dev_fsm) / sizeof(fsm_node);
  *
  * @return 0 on success, -ERRNO on failure. (Never fails.)
  */
-static int
-netiucv_transmit_skb(struct iucv_connection *conn, struct sk_buff *skb) {
+static int netiucv_transmit_skb(struct iucv_connection *conn,
+                               struct sk_buff *skb)
+{
+       struct iucv_message msg;
        unsigned long saveflags;
-       ll_header header;
-       int       rc = 0;
+       struct ll_header header;
+       int rc;
 
        if (fsm_getstate(conn->fsm) != CONN_STATE_IDLE) {
                int l = skb->len + NETIUCV_HDRLEN;
@@ -1145,11 +1151,12 @@ netiucv_transmit_skb(struct iucv_connection *conn, struct sk_buff *skb) {
                    (conn->max_buffsize - NETIUCV_HDRLEN)) {
                        rc = -EBUSY;
                        IUCV_DBF_TEXT(data, 2,
-                               "EBUSY from netiucv_transmit_skb\n");
+                                     "EBUSY from netiucv_transmit_skb\n");
                } else {
                        atomic_inc(&skb->users);
                        skb_queue_tail(&conn->collect_queue, skb);
                        conn->collect_len += l;
+                       rc = 0;
                }
                spin_unlock_irqrestore(&conn->collect_lock, saveflags);
        } else {
@@ -1188,9 +1195,10 @@ netiucv_transmit_skb(struct iucv_connection *conn, struct sk_buff *skb) {
                fsm_newstate(conn->fsm, CONN_STATE_TX);
                conn->prof.send_stamp = xtime;
 
-               rc = iucv_send(conn->pathid, NULL, 0, 0, 1 /* single_flag */,
-                       0, nskb->data, nskb->len);
-                              /* Shut up, gcc! nskb is always below 2G. */
+               msg.tag = 1;
+               msg.class = 0;
+               rc = iucv_message_send(conn->path, &msg, 0, 0,
+                                      nskb->data, nskb->len);
                conn->prof.doios_single++;
                conn->prof.txlen += skb->len;
                conn->prof.tx_pending++;
@@ -1200,7 +1208,7 @@ netiucv_transmit_skb(struct iucv_connection *conn, struct sk_buff *skb) {
                        struct netiucv_priv *privptr;
                        fsm_newstate(conn->fsm, CONN_STATE_IDLE);
                        conn->prof.tx_pending--;
-                       privptr = (struct netiucv_priv *)conn->netdev->priv;
+                       privptr = netdev_priv(conn->netdev);
                        if (privptr)
                                privptr->stats.tx_errors++;
                        if (copied)
@@ -1226,9 +1234,9 @@ netiucv_transmit_skb(struct iucv_connection *conn, struct sk_buff *skb) {
        return rc;
 }
 
-/**
+/*
  * Interface API for upper network layers
- *****************************************************************************/
+ */
 
 /**
  * Open an interface.
@@ -1238,9 +1246,11 @@ netiucv_transmit_skb(struct iucv_connection *conn, struct sk_buff *skb) {
  *
  * @return 0 on success, -ERRNO on failure. (Never fails.)
  */
-static int
-netiucv_open(struct net_device *dev) {
-       fsm_event(((struct netiucv_priv *)dev->priv)->fsm, DEV_EVENT_START,dev);
+static int netiucv_open(struct net_device *dev)
+{
+       struct netiucv_priv *priv = netdev_priv(dev);
+
+       fsm_event(priv->fsm, DEV_EVENT_START, dev);
        return 0;
 }
 
@@ -1252,9 +1262,11 @@ netiucv_open(struct net_device *dev) {
  *
  * @return 0 on success, -ERRNO on failure. (Never fails.)
  */
-static int
-netiucv_close(struct net_device *dev) {
-       fsm_event(((struct netiucv_priv *)dev->priv)->fsm, DEV_EVENT_STOP, dev);
+static int netiucv_close(struct net_device *dev)
+{
+       struct netiucv_priv *priv = netdev_priv(dev);
+
+       fsm_event(priv->fsm, DEV_EVENT_STOP, dev);
        return 0;
 }
 
@@ -1271,8 +1283,8 @@ netiucv_close(struct net_device *dev) {
  */
 static int netiucv_tx(struct sk_buff *skb, struct net_device *dev)
 {
-       int          rc = 0;
-       struct netiucv_priv *privptr = dev->priv;
+       struct netiucv_priv *privptr = netdev_priv(dev);
+       int rc;
 
        IUCV_DBF_TEXT(trace, 4, __FUNCTION__);
        /**
@@ -1312,40 +1324,41 @@ static int netiucv_tx(struct sk_buff *skb, struct net_device *dev)
                return -EBUSY;
        }
        dev->trans_start = jiffies;
-       if (netiucv_transmit_skb(privptr->conn, skb))
-               rc = 1;
+       rc = netiucv_transmit_skb(privptr->conn, skb) != 0;
        netiucv_clear_busy(dev);
        return rc;
 }
 
 /**
- * Returns interface statistics of a device.
+ * netiucv_stats
+ * @dev: Pointer to interface struct.
  *
- * @param dev Pointer to interface struct.
+ * Returns interface statistics of a device.
  *
- * @return Pointer to stats struct of this interface.
+ * Returns pointer to stats struct of this interface.
  */
-static struct net_device_stats *
-netiucv_stats (struct net_device * dev)
+static struct net_device_stats *netiucv_stats (struct net_device * dev)
 {
+       struct netiucv_priv *priv = netdev_priv(dev);
+
        IUCV_DBF_TEXT(trace, 5, __FUNCTION__);
-       return &((struct netiucv_priv *)dev->priv)->stats;
+       return &priv->stats;
 }
 
 /**
- * Sets MTU of an interface.
+ * netiucv_change_mtu
+ * @dev: Pointer to interface struct.
+ * @new_mtu: The new MTU to use for this interface.
  *
- * @param dev     Pointer to interface struct.
- * @param new_mtu The new MTU to use for this interface.
+ * Sets MTU of an interface.
  *
- * @return 0 on success, -EINVAL if MTU is out of valid range.
+ * Returns 0 on success, -EINVAL if MTU is out of valid range.
  *         (valid range is 576 .. NETIUCV_MTU_MAX).
  */
-static int
-netiucv_change_mtu (struct net_device * dev, int new_mtu)
+static int netiucv_change_mtu(struct net_device * dev, int new_mtu)
 {
        IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
-       if ((new_mtu < 576) || (new_mtu > NETIUCV_MTU_MAX)) {
+       if (new_mtu < 576 || new_mtu > NETIUCV_MTU_MAX) {
                IUCV_DBF_TEXT(setup, 2, "given MTU out of valid range\n");
                return -EINVAL;
        }
@@ -1353,12 +1366,12 @@ netiucv_change_mtu (struct net_device * dev, int new_mtu)
        return 0;
 }
 
-/**
+/*
  * attributes in sysfs
- *****************************************************************************/
+ */
 
-static ssize_t
-user_show (struct device *dev, struct device_attribute *attr, char *buf)
+static ssize_t user_show(struct device *dev, struct device_attribute *attr,
+                        char *buf)
 {
        struct netiucv_priv *priv = dev->driver_data;
 
@@ -1366,8 +1379,8 @@ user_show (struct device *dev, struct device_attribute *attr, char *buf)
        return sprintf(buf, "%s\n", netiucv_printname(priv->conn->userid));
 }
 
-static ssize_t
-user_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
+static ssize_t user_write(struct device *dev, struct device_attribute *attr,
+                         const char *buf, size_t count)
 {
        struct netiucv_priv *priv = dev->driver_data;
        struct net_device *ndev = priv->conn->netdev;
@@ -1375,80 +1388,70 @@ user_write (struct device *dev, struct device_attribute *attr, const char *buf,
        char    *tmp;
        char    username[9];
        int     i;
-       struct iucv_connection **clist = &iucv_conns.iucv_connections;
-       unsigned long flags;
+       struct iucv_connection *cp;
 
        IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
-       if (count>9) {
-               PRINT_WARN("netiucv: username too long (%d)!\n", (int)count);
+       if (count > 9) {
+               PRINT_WARN("netiucv: username too long (%d)!\n", (int) count);
                IUCV_DBF_TEXT_(setup, 2,
-                       "%d is length of username\n", (int)count);
+                              "%d is length of username\n", (int) count);
                return -EINVAL;
        }
 
        tmp = strsep((char **) &buf, "\n");
-       for (i=0, p=tmp; i<8 && *p; i++, p++) {
-               if (isalnum(*p) || (*p == '$'))
+       for (i = 0, p = tmp; i < 8 && *p; i++, p++) {
+               if (isalnum(*p) || (*p == '$')) {
                        username[i]= toupper(*p);
-               else if (*p == '\n') {
+                       continue;
+               }
+               if (*p == '\n') {
                        /* trailing lf, grr */
                        break;
-               } else {
-                       PRINT_WARN("netiucv: Invalid char %c in username!\n",
-                               *p);
-                       IUCV_DBF_TEXT_(setup, 2,
-                               "username: invalid character %c\n",
-                               *p);
-                       return -EINVAL;
                }
+               PRINT_WARN("netiucv: Invalid char %c in username!\n", *p);
+               IUCV_DBF_TEXT_(setup, 2,
+                              "username: invalid character %c\n", *p);
+               return -EINVAL;
        }
-       while (i<8)
+       while (i < 8)
                username[i++] = ' ';
        username[8] = '\0';
 
-       if (memcmp(username, priv->conn->userid, 9)) {
-               /* username changed */
-               if (ndev->flags & (IFF_UP | IFF_RUNNING)) {
-                       PRINT_WARN(
-                               "netiucv: device %s active, connected to %s\n",
-                               dev->bus_id, priv->conn->userid);
-                       PRINT_WARN("netiucv: user cannot be updated\n");
-                       IUCV_DBF_TEXT(setup, 2, "user_write: device active\n");
-                       return -EBUSY;
+       if (memcmp(username, priv->conn->userid, 9) &&
+           (ndev->flags & (IFF_UP | IFF_RUNNING))) {
+               /* username changed while the interface is active. */
+               PRINT_WARN("netiucv: device %s active, connected to %s\n",
+                          dev->bus_id, priv->conn->userid);
+               PRINT_WARN("netiucv: user cannot be updated\n");
+               IUCV_DBF_TEXT(setup, 2, "user_write: device active\n");
+               return -EBUSY;
+       }
+       read_lock_bh(&iucv_connection_rwlock);
+       list_for_each_entry(cp, &iucv_connection_list, list) {
+               if (!strncmp(username, cp->userid, 9) && cp->netdev != ndev) {
+                       read_unlock_bh(&iucv_connection_rwlock);
+                       PRINT_WARN("netiucv: Connection to %s already "
+                                  "exists\n", username);
+                       return -EEXIST;
                }
        }
-       read_lock_irqsave(&iucv_conns.iucv_rwlock, flags);
-       while (*clist) {
-                if (!strncmp(username, (*clist)->userid, 9) ||
-                   ((*clist)->netdev != ndev))
-                        break;
-                clist = &((*clist)->next);
-        }
-       read_unlock_irqrestore(&iucv_conns.iucv_rwlock, flags);
-        if (*clist) {
-                PRINT_WARN("netiucv: Connection to %s already exists\n",
-                        username);
-                return -EEXIST;
-        }
+       read_unlock_bh(&iucv_connection_rwlock);
        memcpy(priv->conn->userid, username, 9);
-
        return count;
-
 }
 
 static DEVICE_ATTR(user, 0644, user_show, user_write);
 
-static ssize_t
-buffer_show (struct device *dev, struct device_attribute *attr, char *buf)
-{
-       struct netiucv_priv *priv = dev->driver_data;
+static ssize_t buffer_show (struct device *dev, struct device_attribute *attr,
+                           char *buf)
+{      struct netiucv_priv *priv = dev->driver_data;
 
        IUCV_DBF_TEXT(trace, 5, __FUNCTION__);
        return sprintf(buf, "%d\n", priv->conn->max_buffsize);
 }
 
-static ssize_t
-buffer_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
+static ssize_t buffer_write (struct device *dev, struct device_attribute *attr,
+                            const char *buf, size_t count)
 {
        struct netiucv_priv *priv = dev->driver_data;
        struct net_device *ndev = priv->conn->netdev;
@@ -1502,8 +1505,8 @@ buffer_write (struct device *dev, struct device_attribute *attr, const char *buf
 
 static DEVICE_ATTR(buffer, 0644, buffer_show, buffer_write);
 
-static ssize_t
-dev_fsm_show (struct device *dev, struct device_attribute *attr, char *buf)
+static ssize_t dev_fsm_show (struct device *dev, struct device_attribute *attr,
+                            char *buf)
 {
        struct netiucv_priv *priv = dev->driver_data;
 
@@ -1513,8 +1516,8 @@ dev_fsm_show (struct device *dev, struct device_attribute *attr, char *buf)
 
 static DEVICE_ATTR(device_fsm_state, 0444, dev_fsm_show, NULL);
 
-static ssize_t
-conn_fsm_show (struct device *dev, struct device_attribute *attr, char *buf)
+static ssize_t conn_fsm_show (struct device *dev,
+                             struct device_attribute *attr, char *buf)
 {
        struct netiucv_priv *priv = dev->driver_data;
 
@@ -1524,8 +1527,8 @@ conn_fsm_show (struct device *dev, struct device_attribute *attr, char *buf)
 
 static DEVICE_ATTR(connection_fsm_state, 0444, conn_fsm_show, NULL);
 
-static ssize_t
-maxmulti_show (struct device *dev, struct device_attribute *attr, char *buf)
+static ssize_t maxmulti_show (struct device *dev,
+                             struct device_attribute *attr, char *buf)
 {
        struct netiucv_priv *priv = dev->driver_data;
 
@@ -1533,8 +1536,9 @@ maxmulti_show (struct device *dev, struct device_attribute *attr, char *buf)
        return sprintf(buf, "%ld\n", priv->conn->prof.maxmulti);
 }
 
-static ssize_t
-maxmulti_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
+static ssize_t maxmulti_write (struct device *dev,
+                              struct device_attribute *attr,
+                              const char *buf, size_t count)
 {
        struct netiucv_priv *priv = dev->driver_data;
 
@@ -1545,8 +1549,8 @@ maxmulti_write (struct device *dev, struct device_attribute *attr, const char *b
 
 static DEVICE_ATTR(max_tx_buffer_used, 0644, maxmulti_show, maxmulti_write);
 
-static ssize_t
-maxcq_show (struct device *dev, struct device_attribute *attr, char *buf)
+static ssize_t maxcq_show (struct device *dev, struct device_attribute *attr,
+                          char *buf)
 {
        struct netiucv_priv *priv = dev->driver_data;
 
@@ -1554,8 +1558,8 @@ maxcq_show (struct device *dev, struct device_attribute *attr, char *buf)
        return sprintf(buf, "%ld\n", priv->conn->prof.maxcqueue);
 }
 
-static ssize_t
-maxcq_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
+static ssize_t maxcq_write (struct device *dev, struct device_attribute *attr,
+                           const char *buf, size_t count)
 {
        struct netiucv_priv *priv = dev->driver_data;
 
@@ -1566,8 +1570,8 @@ maxcq_write (struct device *dev, struct device_attribute *attr, const char *buf,
 
 static DEVICE_ATTR(max_chained_skbs, 0644, maxcq_show, maxcq_write);
 
-static ssize_t
-sdoio_show (struct device *dev, struct device_attribute *attr, char *buf)
+static ssize_t sdoio_show (struct device *dev, struct device_attribute *attr,
+                          char *buf)
 {
        struct netiucv_priv *priv = dev->driver_data;
 
@@ -1575,8 +1579,8 @@ sdoio_show (struct device *dev, struct device_attribute *attr, char *buf)
        return sprintf(buf, "%ld\n", priv->conn->prof.doios_single);
 }
 
-static ssize_t
-sdoio_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
+static ssize_t sdoio_write (struct device *dev, struct device_attribute *attr,
+                           const char *buf, size_t count)
 {
        struct netiucv_priv *priv = dev->driver_data;
 
@@ -1587,8 +1591,8 @@ sdoio_write (struct device *dev, struct device_attribute *attr, const char *buf,
 
 static DEVICE_ATTR(tx_single_write_ops, 0644, sdoio_show, sdoio_write);
 
-static ssize_t
-mdoio_show (struct device *dev, struct device_attribute *attr, char *buf)
+static ssize_t mdoio_show (struct device *dev, struct device_attribute *attr,
+                          char *buf)
 {
        struct netiucv_priv *priv = dev->driver_data;
 
@@ -1596,8 +1600,8 @@ mdoio_show (struct device *dev, struct device_attribute *attr, char *buf)
        return sprintf(buf, "%ld\n", priv->conn->prof.doios_multi);
 }
 
-static ssize_t
-mdoio_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
+static ssize_t mdoio_write (struct device *dev, struct device_attribute *attr,
+                           const char *buf, size_t count)
 {
        struct netiucv_priv *priv = dev->driver_data;
 
@@ -1608,8 +1612,8 @@ mdoio_write (struct device *dev, struct device_attribute *attr, const char *buf,
 
 static DEVICE_ATTR(tx_multi_write_ops, 0644, mdoio_show, mdoio_write);
 
-static ssize_t
-txlen_show (struct device *dev, struct device_attribute *attr, char *buf)
+static ssize_t txlen_show (struct device *dev, struct device_attribute *attr,
+                          char *buf)
 {
        struct netiucv_priv *priv = dev->driver_data;
 
@@ -1617,8 +1621,8 @@ txlen_show (struct device *dev, struct device_attribute *attr, char *buf)
        return sprintf(buf, "%ld\n", priv->conn->prof.txlen);
 }
 
-static ssize_t
-txlen_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
+static ssize_t txlen_write (struct device *dev, struct device_attribute *attr,
+                           const char *buf, size_t count)
 {
        struct netiucv_priv *priv = dev->driver_data;
 
@@ -1629,8 +1633,8 @@ txlen_write (struct device *dev, struct device_attribute *attr, const char *buf,
 
 static DEVICE_ATTR(netto_bytes, 0644, txlen_show, txlen_write);
 
-static ssize_t
-txtime_show (struct device *dev, struct device_attribute *attr, char *buf)
+static ssize_t txtime_show (struct device *dev, struct device_attribute *attr,
+                           char *buf)
 {
        struct netiucv_priv *priv = dev->driver_data;
 
@@ -1638,8 +1642,8 @@ txtime_show (struct device *dev, struct device_attribute *attr, char *buf)
        return sprintf(buf, "%ld\n", priv->conn->prof.tx_time);
 }
 
-static ssize_t
-txtime_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
+static ssize_t txtime_write (struct device *dev, struct device_attribute *attr,
+                            const char *buf, size_t count)
 {
        struct netiucv_priv *priv = dev->driver_data;
 
@@ -1650,8 +1654,8 @@ txtime_write (struct device *dev, struct device_attribute *attr, const char *buf
 
 static DEVICE_ATTR(max_tx_io_time, 0644, txtime_show, txtime_write);
 
-static ssize_t
-txpend_show (struct device *dev, struct device_attribute *attr, char *buf)
+static ssize_t txpend_show (struct device *dev, struct device_attribute *attr,
+                           char *buf)
 {
        struct netiucv_priv *priv = dev->driver_data;
 
@@ -1659,8 +1663,8 @@ txpend_show (struct device *dev, struct device_attribute *attr, char *buf)
        return sprintf(buf, "%ld\n", priv->conn->prof.tx_pending);
 }
 
-static ssize_t
-txpend_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
+static ssize_t txpend_write (struct device *dev, struct device_attribute *attr,
+                            const char *buf, size_t count)
 {
        struct netiucv_priv *priv = dev->driver_data;
 
@@ -1671,8 +1675,8 @@ txpend_write (struct device *dev, struct device_attribute *attr, const char *buf
 
 static DEVICE_ATTR(tx_pending, 0644, txpend_show, txpend_write);
 
-static ssize_t
-txmpnd_show (struct device *dev, struct device_attribute *attr, char *buf)
+static ssize_t txmpnd_show (struct device *dev, struct device_attribute *attr,
+                           char *buf)
 {
        struct netiucv_priv *priv = dev->driver_data;
 
@@ -1680,8 +1684,8 @@ txmpnd_show (struct device *dev, struct device_attribute *attr, char *buf)
        return sprintf(buf, "%ld\n", priv->conn->prof.tx_max_pending);
 }
 
-static ssize_t
-txmpnd_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
+static ssize_t txmpnd_write (struct device *dev, struct device_attribute *attr,
+                            const char *buf, size_t count)
 {
        struct netiucv_priv *priv = dev->driver_data;
 
@@ -1721,8 +1725,7 @@ static struct attribute_group netiucv_stat_attr_group = {
        .attrs = netiucv_stat_attrs,
 };
 
-static inline int
-netiucv_add_files(struct device *dev)
+static inline int netiucv_add_files(struct device *dev)
 {
        int ret;
 
@@ -1736,18 +1739,16 @@ netiucv_add_files(struct device *dev)
        return ret;
 }
 
-static inline void
-netiucv_remove_files(struct device *dev)
+static inline void netiucv_remove_files(struct device *dev)
 {
        IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
        sysfs_remove_group(&dev->kobj, &netiucv_stat_attr_group);
        sysfs_remove_group(&dev->kobj, &netiucv_attr_group);
 }
 
-static int
-netiucv_register_device(struct net_device *ndev)
+static int netiucv_register_device(struct net_device *ndev)
 {
-       struct netiucv_priv *priv = ndev->priv;
+       struct netiucv_priv *priv = netdev_priv(ndev);
        struct device *dev = kzalloc(sizeof(struct device), GFP_KERNEL);
        int ret;
 
@@ -1786,8 +1787,7 @@ out_unreg:
        return ret;
 }
 
-static void
-netiucv_unregister_device(struct device *dev)
+static void netiucv_unregister_device(struct device *dev)
 {
        IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
        netiucv_remove_files(dev);
@@ -1798,107 +1798,89 @@ netiucv_unregister_device(struct device *dev)
  * Allocate and initialize a new connection structure.
  * Add it to the list of netiucv connections;
  */
-static struct iucv_connection *
-netiucv_new_connection(struct net_device *dev, char *username)
-{
-       unsigned long flags;
-       struct iucv_connection **clist = &iucv_conns.iucv_connections;
-       struct iucv_connection *conn =
-               kzalloc(sizeof(struct iucv_connection), GFP_KERNEL);
-
-       if (conn) {
-               skb_queue_head_init(&conn->collect_queue);
-               skb_queue_head_init(&conn->commit_queue);
-               spin_lock_init(&conn->collect_lock);
-               conn->max_buffsize = NETIUCV_BUFSIZE_DEFAULT;
-               conn->netdev = dev;
-
-               conn->rx_buff = alloc_skb(NETIUCV_BUFSIZE_DEFAULT,
-                                         GFP_KERNEL | GFP_DMA);
-               if (!conn->rx_buff) {
-                       kfree(conn);
-                       return NULL;
-               }
-               conn->tx_buff = alloc_skb(NETIUCV_BUFSIZE_DEFAULT,
-                                         GFP_KERNEL | GFP_DMA);
-               if (!conn->tx_buff) {
-                       kfree_skb(conn->rx_buff);
-                       kfree(conn);
-                       return NULL;
-               }
-               conn->fsm = init_fsm("netiucvconn", conn_state_names,
-                                    conn_event_names, NR_CONN_STATES,
-                                    NR_CONN_EVENTS, conn_fsm, CONN_FSM_LEN,
-                                    GFP_KERNEL);
-               if (!conn->fsm) {
-                       kfree_skb(conn->tx_buff);
-                       kfree_skb(conn->rx_buff);
-                       kfree(conn);
-                       return NULL;
-               }
-               fsm_settimer(conn->fsm, &conn->timer);
-               fsm_newstate(conn->fsm, CONN_STATE_INVALID);
-
-               if (username) {
-                       memcpy(conn->userid, username, 9);
-                       fsm_newstate(conn->fsm, CONN_STATE_STOPPED);
-               }
+static struct iucv_connection *netiucv_new_connection(struct net_device *dev,
+                                                     char *username)
+{
+       struct iucv_connection *conn;
 
-               write_lock_irqsave(&iucv_conns.iucv_rwlock, flags);
-               conn->next = *clist;
-               *clist = conn;
-               write_unlock_irqrestore(&iucv_conns.iucv_rwlock, flags);
+       conn = kzalloc(sizeof(*conn), GFP_KERNEL);
+       if (!conn)
+               goto out;
+       skb_queue_head_init(&conn->collect_queue);
+       skb_queue_head_init(&conn->commit_queue);
+       spin_lock_init(&conn->collect_lock);
+       conn->max_buffsize = NETIUCV_BUFSIZE_DEFAULT;
+       conn->netdev = dev;
+
+       conn->rx_buff = alloc_skb(conn->max_buffsize, GFP_KERNEL | GFP_DMA);
+       if (!conn->rx_buff)
+               goto out_conn;
+       conn->tx_buff = alloc_skb(conn->max_buffsize, GFP_KERNEL | GFP_DMA);
+       if (!conn->tx_buff)
+               goto out_rx;
+       conn->fsm = init_fsm("netiucvconn", conn_state_names,
+                            conn_event_names, NR_CONN_STATES,
+                            NR_CONN_EVENTS, conn_fsm, CONN_FSM_LEN,
+                            GFP_KERNEL);
+       if (!conn->fsm)
+               goto out_tx;
+
+       fsm_settimer(conn->fsm, &conn->timer);
+       fsm_newstate(conn->fsm, CONN_STATE_INVALID);
+
+       if (username) {
+               memcpy(conn->userid, username, 9);
+               fsm_newstate(conn->fsm, CONN_STATE_STOPPED);
        }
+
+       write_lock_bh(&iucv_connection_rwlock);
+       list_add_tail(&conn->list, &iucv_connection_list);
+       write_unlock_bh(&iucv_connection_rwlock);
        return conn;
+
+out_tx:
+       kfree_skb(conn->tx_buff);
+out_rx:
+       kfree_skb(conn->rx_buff);
+out_conn:
+       kfree(conn);
+out:
+       return NULL;
 }
 
 /**
  * Release a connection structure and remove it from the
  * list of netiucv connections.
  */
-static void
-netiucv_remove_connection(struct iucv_connection *conn)
+static void netiucv_remove_connection(struct iucv_connection *conn)
 {
-       struct iucv_connection **clist = &iucv_conns.iucv_connections;
-       unsigned long flags;
-
        IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
-       if (conn == NULL)
-               return;
-       write_lock_irqsave(&iucv_conns.iucv_rwlock, flags);
-       while (*clist) {
-               if (*clist == conn) {
-                       *clist = conn->next;
-                       write_unlock_irqrestore(&iucv_conns.iucv_rwlock, flags);
-                       if (conn->handle) {
-                               iucv_unregister_program(conn->handle);
-                               conn->handle = NULL;
-                       }
-                       fsm_deltimer(&conn->timer);
-                       kfree_fsm(conn->fsm);
-                       kfree_skb(conn->rx_buff);
-                       kfree_skb(conn->tx_buff);
-                       return;
-               }
-               clist = &((*clist)->next);
+       write_lock_bh(&iucv_connection_rwlock);
+       list_del_init(&conn->list);
+       write_unlock_bh(&iucv_connection_rwlock);
+       if (conn->path) {
+               iucv_path_sever(conn->path, iucvMagic);
+               kfree(conn->path);
+               conn->path = NULL;
        }
-       write_unlock_irqrestore(&iucv_conns.iucv_rwlock, flags);
+       fsm_deltimer(&conn->timer);
+       kfree_fsm(conn->fsm);
+       kfree_skb(conn->rx_buff);
+       kfree_skb(conn->tx_buff);
 }
 
 /**
  * Release everything of a net device.
  */
-static void
-netiucv_free_netdevice(struct net_device *dev)
+static void netiucv_free_netdevice(struct net_device *dev)
 {
-       struct netiucv_priv *privptr;
+       struct netiucv_priv *privptr = netdev_priv(dev);
 
        IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
 
        if (!dev)
                return;
 
-       privptr = (struct netiucv_priv *)dev->priv;
        if (privptr) {
                if (privptr->conn)
                        netiucv_remove_connection(privptr->conn);
@@ -1913,11 +1895,8 @@ netiucv_free_netdevice(struct net_device *dev)
 /**
  * Initialize a net device. (Called from kernel in alloc_netdev())
  */
-static void
-netiucv_setup_netdevice(struct net_device *dev)
+static void netiucv_setup_netdevice(struct net_device *dev)
 {
-        memset(dev->priv, 0, sizeof(struct netiucv_priv));
-
        dev->mtu                 = NETIUCV_MTU_DEFAULT;
        dev->hard_start_xmit     = netiucv_tx;
        dev->open                = netiucv_open;
@@ -1936,8 +1915,7 @@ netiucv_setup_netdevice(struct net_device *dev)
 /**
  * Allocate and initialize everything of a net device.
  */
-static struct net_device *
-netiucv_init_netdevice(char *username)
+static struct net_device *netiucv_init_netdevice(char *username)
 {
        struct netiucv_priv *privptr;
        struct net_device *dev;
@@ -1946,40 +1924,40 @@ netiucv_init_netdevice(char *username)
                           netiucv_setup_netdevice);
        if (!dev)
                return NULL;
-       if (dev_alloc_name(dev, dev->name) < 0) {
-               free_netdev(dev);
-               return NULL;
-       }
+       if (dev_alloc_name(dev, dev->name) < 0)
+               goto out_netdev;
 
-       privptr = (struct netiucv_priv *)dev->priv;
+       privptr = netdev_priv(dev);
        privptr->fsm = init_fsm("netiucvdev", dev_state_names,
                                dev_event_names, NR_DEV_STATES, NR_DEV_EVENTS,
                                dev_fsm, DEV_FSM_LEN, GFP_KERNEL);
-       if (!privptr->fsm) {
-               free_netdev(dev);
-               return NULL;
-       }
+       if (!privptr->fsm)
+               goto out_netdev;
+
        privptr->conn = netiucv_new_connection(dev, username);
        if (!privptr->conn) {
-               kfree_fsm(privptr->fsm);
-               free_netdev(dev);
                IUCV_DBF_TEXT(setup, 2, "NULL from netiucv_new_connection\n");
-               return NULL;
+               goto out_fsm;
        }
        fsm_newstate(privptr->fsm, DEV_STATE_STOPPED);
-
        return dev;
+
+out_fsm:
+       kfree_fsm(privptr->fsm);
+out_netdev:
+       free_netdev(dev);
+       return NULL;
 }
 
-static ssize_t
-conn_write(struct device_driver *drv, const char *buf, size_t count)
+static ssize_t conn_write(struct device_driver *drv,
+                         const char *buf, size_t count)
 {
-       char *p;
+       const char *p;
        char username[9];
-       int i, ret;
+       int i, rc;
        struct net_device *dev;
-       struct iucv_connection **clist = &iucv_conns.iucv_connections;
-       unsigned long flags;
+       struct netiucv_priv *priv;
+       struct iucv_connection *cp;
 
        IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
        if (count>9) {
@@ -1988,83 +1966,82 @@ conn_write(struct device_driver *drv, const char *buf, size_t count)
                return -EINVAL;
        }
 
-       for (i=0, p=(char *)buf; i<8 && *p; i++, p++) {
-               if (isalnum(*p) || (*p == '$'))
-                       username[i]= toupper(*p);
-               else if (*p == '\n') {
+       for (i = 0, p = buf; i < 8 && *p; i++, p++) {
+               if (isalnum(*p) || *p == '$') {
+                       username[i] = toupper(*p);
+                       continue;
+               }
+               if (*p == '\n')
                        /* trailing lf, grr */
                        break;
-               } else {
-                       PRINT_WARN("netiucv: Invalid character in username!\n");
-                       IUCV_DBF_TEXT_(setup, 2,
-                               "conn_write: invalid character %c\n", *p);
-                       return -EINVAL;
-               }
+               PRINT_WARN("netiucv: Invalid character in username!\n");
+               IUCV_DBF_TEXT_(setup, 2,
+                              "conn_write: invalid character %c\n", *p);
+               return -EINVAL;
        }
-       while (i<8)
+       while (i < 8)
                username[i++] = ' ';
        username[8] = '\0';
 
-       read_lock_irqsave(&iucv_conns.iucv_rwlock, flags);
-       while (*clist) {
-               if (!strncmp(username, (*clist)->userid, 9))
-                       break;
-               clist = &((*clist)->next);
-       }
-       read_unlock_irqrestore(&iucv_conns.iucv_rwlock, flags);
-       if (*clist) {
-               PRINT_WARN("netiucv: Connection to %s already exists\n",
-                       username);
-               return -EEXIST;
+       read_lock_bh(&iucv_connection_rwlock);
+       list_for_each_entry(cp, &iucv_connection_list, list) {
+               if (!strncmp(username, cp->userid, 9)) {
+                       read_unlock_bh(&iucv_connection_rwlock);
+                       PRINT_WARN("netiucv: Connection to %s already "
+                                  "exists\n", username);
+                       return -EEXIST;
+               }
        }
+       read_unlock_bh(&iucv_connection_rwlock);
+
        dev = netiucv_init_netdevice(username);
        if (!dev) {
-               PRINT_WARN(
-                      "netiucv: Could not allocate network device structure "
-                      "for user '%s'\n", netiucv_printname(username));
+               PRINT_WARN("netiucv: Could not allocate network device "
+                          "structure for user '%s'\n",
+                          netiucv_printname(username));
                IUCV_DBF_TEXT(setup, 2, "NULL from netiucv_init_netdevice\n");
                return -ENODEV;
        }
 
-       if ((ret = netiucv_register_device(dev))) {
+       rc = netiucv_register_device(dev);
+       if (rc) {
                IUCV_DBF_TEXT_(setup, 2,
-                       "ret %d from netiucv_register_device\n", ret);
+                       "ret %d from netiucv_register_device\n", rc);
                goto out_free_ndev;
        }
 
        /* sysfs magic */
-       SET_NETDEV_DEV(dev,
-                       (struct device*)((struct netiucv_priv*)dev->priv)->dev);
+       priv = netdev_priv(dev);
+       SET_NETDEV_DEV(dev, priv->dev);
 
-       if ((ret = register_netdev(dev))) {
-               netiucv_unregister_device((struct device*)
-                       ((struct netiucv_priv*)dev->priv)->dev);
-               goto out_free_ndev;
-       }
+       rc = register_netdev(dev);
+       if (rc)
+               goto out_unreg;
 
        PRINT_INFO("%s: '%s'\n", dev->name, netiucv_printname(username));
 
        return count;
 
+out_unreg:
+       netiucv_unregister_device(priv->dev);
 out_free_ndev:
        PRINT_WARN("netiucv: Could not register '%s'\n", dev->name);
        IUCV_DBF_TEXT(setup, 2, "conn_write: could not register\n");
        netiucv_free_netdevice(dev);
-       return ret;
+       return rc;
 }
 
 static DRIVER_ATTR(connection, 0200, NULL, conn_write);
 
-static ssize_t
-remove_write (struct device_driver *drv, const char *buf, size_t count)
+static ssize_t remove_write (struct device_driver *drv,
+                            const char *buf, size_t count)
 {
-       struct iucv_connection **clist = &iucv_conns.iucv_connections;
-       unsigned long flags;
+       struct iucv_connection *cp;
         struct net_device *ndev;
         struct netiucv_priv *priv;
         struct device *dev;
         char name[IFNAMSIZ];
-        char *p;
+       const char *p;
         int i;
 
         IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
@@ -2072,33 +2049,27 @@ remove_write (struct device_driver *drv, const char *buf, size_t count)
         if (count >= IFNAMSIZ)
                 count = IFNAMSIZ - 1;;
 
-        for (i=0, p=(char *)buf; i<count && *p; i++, p++) {
-                if ((*p == '\n') || (*p == ' ')) {
+       for (i = 0, p = buf; i < count && *p; i++, p++) {
+               if (*p == '\n' || *p == ' ')
                         /* trailing lf, grr */
                         break;
-                } else {
-                        name[i]=*p;
-                }
+               name[i] = *p;
         }
         name[i] = '\0';
 
-       read_lock_irqsave(&iucv_conns.iucv_rwlock, flags);
-        while (*clist) {
-                ndev = (*clist)->netdev;
-                priv = (struct netiucv_priv*)ndev->priv;
+       read_lock_bh(&iucv_connection_rwlock);
+       list_for_each_entry(cp, &iucv_connection_list, list) {
+               ndev = cp->netdev;
+               priv = netdev_priv(ndev);
                 dev = priv->dev;
-
-                if (strncmp(name, ndev->name, count)) {
-                        clist = &((*clist)->next);
-                        continue;
-                }
-               read_unlock_irqrestore(&iucv_conns.iucv_rwlock, flags);
+               if (strncmp(name, ndev->name, count))
+                       continue;
+               read_unlock_bh(&iucv_connection_rwlock);
                 if (ndev->flags & (IFF_UP | IFF_RUNNING)) {
-                        PRINT_WARN(
-                                "netiucv: net device %s active with peer %s\n",
-                                ndev->name, priv->conn->userid);
+                       PRINT_WARN("netiucv: net device %s active with peer "
+                                  "%s\n", ndev->name, priv->conn->userid);
                         PRINT_WARN("netiucv: %s cannot be removed\n",
-                                ndev->name);
+                                  ndev->name);
                        IUCV_DBF_TEXT(data, 2, "remove_write: still active\n");
                         return -EBUSY;
                 }
@@ -2106,7 +2077,7 @@ remove_write (struct device_driver *drv, const char *buf, size_t count)
                 netiucv_unregister_device(dev);
                 return count;
         }
-       read_unlock_irqrestore(&iucv_conns.iucv_rwlock, flags);
+       read_unlock_bh(&iucv_connection_rwlock);
         PRINT_WARN("netiucv: net device %s unknown\n", name);
        IUCV_DBF_TEXT(data, 2, "remove_write: unknown device\n");
         return -EINVAL;
@@ -2114,67 +2085,86 @@ remove_write (struct device_driver *drv, const char *buf, size_t count)
 
 static DRIVER_ATTR(remove, 0200, NULL, remove_write);
 
-static void
-netiucv_banner(void)
+static struct attribute * netiucv_drv_attrs[] = {
+       &driver_attr_connection.attr,
+       &driver_attr_remove.attr,
+       NULL,
+};
+
+static struct attribute_group netiucv_drv_attr_group = {
+       .attrs = netiucv_drv_attrs,
+};
+
+static void netiucv_banner(void)
 {
        PRINT_INFO("NETIUCV driver initialized\n");
 }
 
-static void __exit
-netiucv_exit(void)
+static void __exit netiucv_exit(void)
 {
+       struct iucv_connection *cp;
+       struct net_device *ndev;
+       struct netiucv_priv *priv;
+       struct device *dev;
+
        IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
-       while (iucv_conns.iucv_connections) {
-               struct net_device *ndev = iucv_conns.iucv_connections->netdev;
-               struct netiucv_priv *priv = (struct netiucv_priv*)ndev->priv;
-               struct device *dev = priv->dev;
+       while (!list_empty(&iucv_connection_list)) {
+               cp = list_entry(iucv_connection_list.next,
+                               struct iucv_connection, list);
+               list_del(&cp->list);
+               ndev = cp->netdev;
+               priv = netdev_priv(ndev);
+               dev = priv->dev;
 
                unregister_netdev(ndev);
                netiucv_unregister_device(dev);
        }
 
-       driver_remove_file(&netiucv_driver, &driver_attr_connection);
-       driver_remove_file(&netiucv_driver, &driver_attr_remove);
+       sysfs_remove_group(&netiucv_driver.kobj, &netiucv_drv_attr_group);
        driver_unregister(&netiucv_driver);
+       iucv_unregister(&netiucv_handler, 1);
        iucv_unregister_dbf_views();
 
        PRINT_INFO("NETIUCV driver unloaded\n");
        return;
 }
 
-static int __init
-netiucv_init(void)
+static int __init netiucv_init(void)
 {
-       int ret;
+       int rc;
 
-       ret = iucv_register_dbf_views();
-       if (ret) {
-               PRINT_WARN("netiucv_init failed, "
-                       "iucv_register_dbf_views rc = %d\n", ret);
-               return ret;
-       }
+       rc = iucv_register_dbf_views();
+       if (rc)
+               goto out;
+       rc = iucv_register(&netiucv_handler, 1);
+       if (rc)
+               goto out_dbf;
        IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
-       ret = driver_register(&netiucv_driver);
-       if (ret) {
+       rc = driver_register(&netiucv_driver);
+       if (rc) {
                PRINT_ERR("NETIUCV: failed to register driver.\n");
-               IUCV_DBF_TEXT_(setup, 2, "ret %d from driver_register\n", ret);
-               iucv_unregister_dbf_views();
-               return ret;
+               IUCV_DBF_TEXT_(setup, 2, "ret %d from driver_register\n", rc);
+               goto out_iucv;
        }
 
-       /* Add entry for specifying connections. */
-       ret = driver_create_file(&netiucv_driver, &driver_attr_connection);
-       if (!ret) {
-               ret = driver_create_file(&netiucv_driver, &driver_attr_remove);
-               netiucv_banner();
-               rwlock_init(&iucv_conns.iucv_rwlock);
-       } else {
-               PRINT_ERR("NETIUCV: failed to add driver attribute.\n");
-               IUCV_DBF_TEXT_(setup, 2, "ret %d from driver_create_file\n", ret);
-               driver_unregister(&netiucv_driver);
-               iucv_unregister_dbf_views();
+       rc = sysfs_create_group(&netiucv_driver.kobj, &netiucv_drv_attr_group);
+       if (rc) {
+               PRINT_ERR("NETIUCV: failed to add driver attributes.\n");
+               IUCV_DBF_TEXT_(setup, 2,
+                              "ret %d - netiucv_drv_attr_group\n", rc);
+               goto out_driver;
        }
-       return ret;
+       netiucv_banner();
+       return rc;
+
+out_driver:
+       driver_unregister(&netiucv_driver);
+out_iucv:
+       iucv_unregister(&netiucv_handler, 1);
+out_dbf:
+       iucv_unregister_dbf_views();
+out:
+       return rc;
 }
 
 module_init(netiucv_init);
index b8179c27ceb6e1971bb78568ef82707cec64c8a1..3ccca5871fdfc002a922e17fea4c4dcb574808cb 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * IUCV special message driver
  *
- * Copyright (C) 2003 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ * Copyright 2003 IBM Deutschland Entwicklung GmbH, IBM Corporation
  * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
  *
  * This program is free software; you can redistribute it and/or modify
 #include <linux/init.h>
 #include <linux/errno.h>
 #include <linux/device.h>
+#include <net/iucv/iucv.h>
 #include <asm/cpcmd.h>
 #include <asm/ebcdic.h>
-
-#include "iucv.h"
+#include "smsgiucv.h"
 
 struct smsg_callback {
        struct list_head list;
@@ -39,38 +39,46 @@ MODULE_AUTHOR
    ("(C) 2003 IBM Corporation by Martin Schwidefsky (schwidefsky@de.ibm.com)");
 MODULE_DESCRIPTION ("Linux for S/390 IUCV special message driver");
 
-static iucv_handle_t smsg_handle;
-static unsigned short smsg_pathid;
+static struct iucv_path *smsg_path;
+
 static DEFINE_SPINLOCK(smsg_list_lock);
 static struct list_head smsg_list = LIST_HEAD_INIT(smsg_list);
 
-static void
-smsg_connection_complete(iucv_ConnectionComplete *eib, void *pgm_data)
+static int smsg_path_pending(struct iucv_path *, u8 ipvmid[8], u8 ipuser[16]);
+static void smsg_message_pending(struct iucv_path *, struct iucv_message *);
+
+static struct iucv_handler smsg_handler = {
+       .path_pending    = smsg_path_pending,
+       .message_pending = smsg_message_pending,
+};
+
+static int smsg_path_pending(struct iucv_path *path, u8 ipvmid[8],
+                            u8 ipuser[16])
 {
+       if (strncmp(ipvmid, "*MSG    ", sizeof(ipvmid)) != 0)
+               return -EINVAL;
+       /* Path pending from *MSG. */
+       return iucv_path_accept(path, &smsg_handler, "SMSGIUCV        ", NULL);
 }
 
-
-static void
-smsg_message_pending(iucv_MessagePending *eib, void *pgm_data)
+static void smsg_message_pending(struct iucv_path *path,
+                                struct iucv_message *msg)
 {
        struct smsg_callback *cb;
-       unsigned char *msg;
+       unsigned char *buffer;
        unsigned char sender[9];
-       unsigned short len;
        int rc, i;
 
-       len = eib->ln1msg2.ipbfln1f;
-       msg = kmalloc(len + 1, GFP_ATOMIC|GFP_DMA);
-       if (!msg) {
-               iucv_reject(eib->ippathid, eib->ipmsgid, eib->iptrgcls);
+       buffer = kmalloc(msg->length + 1, GFP_ATOMIC | GFP_DMA);
+       if (!buffer) {
+               iucv_message_reject(path, msg);
                return;
        }
-       rc = iucv_receive(eib->ippathid, eib->ipmsgid, eib->iptrgcls,
-                         msg, len, NULL, NULL, NULL);
+       rc = iucv_message_receive(path, msg, 0, buffer, msg->length, NULL);
        if (rc == 0) {
-               msg[len] = 0;
-               EBCASC(msg, len);
-               memcpy(sender, msg, 8);
+               buffer[msg->length] = 0;
+               EBCASC(buffer, msg->length);
+               memcpy(sender, buffer, 8);
                sender[8] = 0;
                /* Remove trailing whitespace from the sender name. */
                for (i = 7; i >= 0; i--) {
@@ -80,27 +88,17 @@ smsg_message_pending(iucv_MessagePending *eib, void *pgm_data)
                }
                spin_lock(&smsg_list_lock);
                list_for_each_entry(cb, &smsg_list, list)
-                       if (strncmp(msg + 8, cb->prefix, cb->len) == 0) {
-                               cb->callback(sender, msg + 8);
+                       if (strncmp(buffer + 8, cb->prefix, cb->len) == 0) {
+                               cb->callback(sender, buffer + 8);
                                break;
                        }
                spin_unlock(&smsg_list_lock);
        }
-       kfree(msg);
+       kfree(buffer);
 }
 
-static iucv_interrupt_ops_t smsg_ops = {
-       .ConnectionComplete = smsg_connection_complete,
-       .MessagePending     = smsg_message_pending,
-};
-
-static struct device_driver smsg_driver = {
-       .name = "SMSGIUCV",
-       .bus  = &iucv_bus,
-};
-
-int
-smsg_register_callback(char *prefix, void (*callback)(char *from, char *str))
+int smsg_register_callback(char *prefix,
+                          void (*callback)(char *from, char *str))
 {
        struct smsg_callback *cb;
 
@@ -110,18 +108,18 @@ smsg_register_callback(char *prefix, void (*callback)(char *from, char *str))
        cb->prefix = prefix;
        cb->len = strlen(prefix);
        cb->callback = callback;
-       spin_lock(&smsg_list_lock);
+       spin_lock_bh(&smsg_list_lock);
        list_add_tail(&cb->list, &smsg_list);
-       spin_unlock(&smsg_list_lock);
+       spin_unlock_bh(&smsg_list_lock);
        return 0;
 }
 
-void
-smsg_unregister_callback(char *prefix, void (*callback)(char *from, char *str))
+void smsg_unregister_callback(char *prefix,
+                             void (*callback)(char *from, char *str))
 {
        struct smsg_callback *cb, *tmp;
 
-       spin_lock(&smsg_list_lock);
+       spin_lock_bh(&smsg_list_lock);
        cb = NULL;
        list_for_each_entry(tmp, &smsg_list, list)
                if (tmp->callback == callback &&
@@ -130,55 +128,58 @@ smsg_unregister_callback(char *prefix, void (*callback)(char *from, char *str))
                        list_del(&cb->list);
                        break;
                }
-       spin_unlock(&smsg_list_lock);
+       spin_unlock_bh(&smsg_list_lock);
        kfree(cb);
 }
 
-static void __exit
-smsg_exit(void)
+static struct device_driver smsg_driver = {
+       .name = "SMSGIUCV",
+       .bus  = &iucv_bus,
+};
+
+static void __exit smsg_exit(void)
 {
-       if (smsg_handle > 0) {
-               cpcmd("SET SMSG OFF", NULL, 0, NULL);
-               iucv_sever(smsg_pathid, NULL);
-               iucv_unregister_program(smsg_handle);
-               driver_unregister(&smsg_driver);
-       }
-       return;
+       cpcmd("SET SMSG IUCV", NULL, 0, NULL);
+       iucv_unregister(&smsg_handler, 1);
+       driver_unregister(&smsg_driver);
 }
 
-static int __init
-smsg_init(void)
+static int __init smsg_init(void)
 {
-       static unsigned char pgmmask[24] = {
-               0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-               0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-               0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
-       };
        int rc;
 
        rc = driver_register(&smsg_driver);
-       if (rc != 0) {
-               printk(KERN_ERR "SMSGIUCV: failed to register driver.\n");
-               return rc;
-       }
-       smsg_handle = iucv_register_program("SMSGIUCV        ", "*MSG    ",
-                                           pgmmask, &smsg_ops, NULL);
-       if (!smsg_handle) {
+       if (rc != 0)
+               goto out;
+       rc = iucv_register(&smsg_handler, 1);
+       if (rc) {
                printk(KERN_ERR "SMSGIUCV: failed to register to iucv");
-               driver_unregister(&smsg_driver);
-               return -EIO;    /* better errno ? */
+               rc = -EIO;      /* better errno ? */
+               goto out_driver;
+       }
+       smsg_path = iucv_path_alloc(255, 0, GFP_KERNEL);
+       if (!smsg_path) {
+               rc = -ENOMEM;
+               goto out_register;
        }
-       rc = iucv_connect (&smsg_pathid, 255, NULL, "*MSG    ", NULL, 0,
-                          NULL, NULL, smsg_handle, NULL);
+       rc = iucv_path_connect(smsg_path, &smsg_handler, "*MSG    ",
+                              NULL, NULL, NULL);
        if (rc) {
                printk(KERN_ERR "SMSGIUCV: failed to connect to *MSG");
-               iucv_unregister_program(smsg_handle);
-               driver_unregister(&smsg_driver);
-               smsg_handle = NULL;
-               return -EIO;
+               rc = -EIO;      /* better errno ? */
+               goto out_free;
        }
        cpcmd("SET SMSG IUCV", NULL, 0, NULL);
        return 0;
+
+out_free:
+       iucv_path_free(smsg_path);
+out_register:
+       iucv_unregister(&smsg_handler, 1);
+out_driver:
+       driver_unregister(&smsg_driver);
+out:
+       return rc;
 }
 
 module_init(smsg_init);
index 98fcbb3d5560bad9463109915e64f75222558853..6349dd617f85cdd8807288597feda9d0cf736834 100644 (file)
@@ -7,6 +7,7 @@
 #include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/pci.h>
+#include <linux/device.h>
 
 #include <asm/system.h>
 #include <asm/sbus.h>
 #include <asm/bpp.h>
 #include <asm/irq.h>
 
+static ssize_t
+show_sbusobppath_attr(struct device * dev, struct device_attribute * attr, char * buf)
+{
+       struct sbus_dev *sbus;
+
+       sbus = to_sbus_device(dev);
+
+       return snprintf (buf, PAGE_SIZE, "%s\n", sbus->ofdev.node->full_name);
+}
+
+static DEVICE_ATTR(obppath, S_IRUSR | S_IRGRP | S_IROTH, show_sbusobppath_attr, NULL);
+
 struct sbus_bus *sbus_root;
 
 static void __init fill_sbus_device(struct device_node *dp, struct sbus_dev *sdev)
 {
        unsigned long base;
        void *pval;
-       int len;
+       int len, err;
 
        sdev->prom_node = dp->node;
        strcpy(sdev->prom_name, dp->name);
@@ -66,6 +79,9 @@ static void __init fill_sbus_device(struct device_node *dp, struct sbus_dev *sde
        if (of_device_register(&sdev->ofdev) != 0)
                printk(KERN_DEBUG "sbus: device registration error for %s!\n",
                       dp->path_component_name);
+
+       /* WE HAVE BEEN INVADED BY ALIENS! */
+       err = sysfs_create_file(&sdev->ofdev.dev.kobj, &dev_attr_obppath.attr);
 }
 
 static void __init sbus_bus_ranges_init(struct device_node *dp, struct sbus_bus *sbus)
index 640536ef77dcc398ec663cfe39830ba3e2c41e6b..9c37943108792af5723ff0a394dee6888ea26571 100644 (file)
@@ -3099,7 +3099,6 @@ allocate_cmd (Scsi_Cmnd *cmd) {
         real = get_zeroed_page(GFP_ATOMIC);
         if (real == 0)
                return NULL;
-        memset((void *)real, 0, 4096);
         cache_push(virt_to_phys((void *)real), 4096);
         cache_clear(virt_to_phys((void *)real), 4096);
         kernel_set_cachemode((void *)real, 4096, IOMAP_NOCACHE_SER);
index 3c912ee29da0e1fa24091849d682bab5c164bfc3..8b5334c56f0a9668fb1f132b7a657cae329104e4 100644 (file)
@@ -528,12 +528,16 @@ void esp_bootup_reset(struct NCR_ESP *esp, struct ESP_regs *eregs)
 /* Allocate structure and insert basic data such as SCSI chip frequency
  * data and a pointer to the device
  */
-struct NCR_ESP* esp_allocate(struct scsi_host_template *tpnt, void *esp_dev)
+struct NCR_ESP* esp_allocate(struct scsi_host_template *tpnt, void *esp_dev,
+                            int hotplug)
 {
        struct NCR_ESP *esp, *elink;
        struct Scsi_Host *esp_host;
 
-       esp_host = scsi_register(tpnt, sizeof(struct NCR_ESP));
+       if (hotplug)
+               esp_host = scsi_host_alloc(tpnt, sizeof(struct NCR_ESP));
+       else
+               esp_host = scsi_register(tpnt, sizeof(struct NCR_ESP));
        if(!esp_host)
                panic("Cannot register ESP SCSI host");
        esp = (struct NCR_ESP *) esp_host->hostdata;
index 521e3f842cfd526e98fc451993f4080df00a4e06..d85cb73a9f69f217cdcf9e9c779bde8dc3da3947 100644 (file)
@@ -652,7 +652,7 @@ extern int nesps, esps_in_use, esps_running;
 
 /* External functions */
 extern void esp_bootup_reset(struct NCR_ESP *esp, struct ESP_regs *eregs);
-extern struct NCR_ESP *esp_allocate(struct scsi_host_template *, void *);
+extern struct NCR_ESP *esp_allocate(struct scsi_host_template *, void *, int);
 extern void esp_deallocate(struct NCR_ESP *);
 extern void esp_release(void);
 extern void esp_initialize(struct NCR_ESP *);
index da94e126ca832d5e4d157c65c3b34acaab20620c..0cd7eed9196c44eec8065fd71be58d9c2359af0c 100644 (file)
@@ -1052,10 +1052,9 @@ static inline struct asd_ascb *asd_ascb_alloc(struct asd_ha_struct *asd_ha,
        struct asd_ascb *ascb;
        unsigned long flags;
 
-       ascb = kmem_cache_alloc(asd_ascb_cache, gfp_flags);
+       ascb = kmem_cache_zalloc(asd_ascb_cache, gfp_flags);
 
        if (ascb) {
-               memset(ascb, 0, sizeof(*ascb));
                ascb->dma_scb.size = sizeof(struct scb);
                ascb->dma_scb.vaddr = dma_pool_alloc(asd_ha->scb_pool,
                                                     gfp_flags,
index 329a8f297b318fa1c76594e90e2dcf6e6d746f54..23f7c24ab8093124ab795d32f16e7210515fe700 100644 (file)
@@ -121,7 +121,8 @@ int __init blz1230_esp_detect(struct scsi_host_template *tpnt)
                 */
                address = ZTWO_VADDR(board);
                eregs = (struct ESP_regs *)(address + REAL_BLZ1230_ESP_ADDR);
-               esp = esp_allocate(tpnt, (void *)board+REAL_BLZ1230_ESP_ADDR);
+               esp = esp_allocate(tpnt, (void *)board + REAL_BLZ1230_ESP_ADDR,
+                                  0);
 
                esp_write(eregs->esp_cfg1, (ESP_CONFIG1_PENABLE | 7));
                udelay(5);
index b6c137b9735056985820216ce397a9e914f8d08b..b6203ec00961e3c1306631a29ecf1346afaffad5 100644 (file)
@@ -100,7 +100,7 @@ int __init blz2060_esp_detect(struct scsi_host_template *tpnt)
            unsigned long board = z->resource.start;
            if (request_mem_region(board+BLZ2060_ESP_ADDR,
                                   sizeof(struct ESP_regs), "NCR53C9x")) {
-               esp = esp_allocate(tpnt, (void *)board+BLZ2060_ESP_ADDR);
+               esp = esp_allocate(tpnt, (void *)board + BLZ2060_ESP_ADDR, 0);
 
                /* Do command transfer with programmed I/O */
                esp->do_pio_cmds = 1;
index 7c7cfb54e8976a9f1070ca412309798d3c2b8214..c6b98a42e89d837d4288979fcdb8258a71ee3a69 100644 (file)
@@ -126,7 +126,7 @@ int __init cyber_esp_detect(struct scsi_host_template *tpnt)
                                           sizeof(struct ESP_regs));
                        return 0;
                }
-               esp = esp_allocate(tpnt, (void *)board+CYBER_ESP_ADDR);
+               esp = esp_allocate(tpnt, (void *)board + CYBER_ESP_ADDR, 0);
 
                /* Do command transfer with programmed I/O */
                esp->do_pio_cmds = 1;
index d88cb9cf091e4a880b8e5e22daa419a4613326f4..e336e853e66fb03affd5524e6f37a74519ad401c 100644 (file)
@@ -98,7 +98,7 @@ int __init cyberII_esp_detect(struct scsi_host_template *tpnt)
                address = (unsigned long)ZTWO_VADDR(board);
                eregs = (struct ESP_regs *)(address + CYBERII_ESP_ADDR);
 
-               esp = esp_allocate(tpnt, (void *)board+CYBERII_ESP_ADDR);
+               esp = esp_allocate(tpnt, (void *)board + CYBERII_ESP_ADDR, 0);
 
                esp_write(eregs->esp_cfg1, (ESP_CONFIG1_PENABLE | 7));
                udelay(5);
index c29ccbc44693ab46079b652c617c2f72c147291b..d42ad663ffee83a60d7956854e6b493b00f42a61 100644 (file)
@@ -18,7 +18,7 @@
  * 20001005    - Initialization fixes for 2.4.0-test9
  *                       Florian Lohoff <flo@rfc822.org>
  *
- *     Copyright (C) 2002, 2003, 2005  Maciej W. Rozycki
+ *     Copyright (C) 2002, 2003, 2005, 2006  Maciej W. Rozycki
  */
 
 #include <linux/kernel.h>
@@ -30,6 +30,7 @@
 #include <linux/proc_fs.h>
 #include <linux/spinlock.h>
 #include <linux/stat.h>
+#include <linux/tc.h>
 
 #include <asm/dma.h>
 #include <asm/irq.h>
@@ -42,7 +43,6 @@
 #include <asm/dec/ioasic_ints.h>
 #include <asm/dec/machtype.h>
 #include <asm/dec/system.h>
-#include <asm/dec/tc.h>
 
 #define DEC_SCSI_SREG 0
 #define DEC_SCSI_DMAREG 0x40000
@@ -98,51 +98,33 @@ static irqreturn_t scsi_dma_merr_int(int, void *);
 static irqreturn_t scsi_dma_err_int(int, void *);
 static irqreturn_t scsi_dma_int(int, void *);
 
-static int dec_esp_detect(struct scsi_host_template * tpnt);
-
-static int dec_esp_release(struct Scsi_Host *shost)
-{
-       if (shost->irq)
-               free_irq(shost->irq, NULL);
-       if (shost->io_port && shost->n_io_port)
-               release_region(shost->io_port, shost->n_io_port);
-       scsi_unregister(shost);
-       return 0;
-}
-
-static struct scsi_host_template driver_template = {
-       .proc_name              = "dec_esp",
-       .proc_info              = esp_proc_info,
+static struct scsi_host_template dec_esp_template = {
+       .module                 = THIS_MODULE,
        .name                   = "NCR53C94",
-       .detect                 = dec_esp_detect,
-       .slave_alloc            = esp_slave_alloc,
-       .slave_destroy          = esp_slave_destroy,
-       .release                = dec_esp_release,
        .info                   = esp_info,
        .queuecommand           = esp_queue,
        .eh_abort_handler       = esp_abort,
        .eh_bus_reset_handler   = esp_reset,
+       .slave_alloc            = esp_slave_alloc,
+       .slave_destroy          = esp_slave_destroy,
+       .proc_info              = esp_proc_info,
+       .proc_name              = "dec_esp",
        .can_queue              = 7,
-       .this_id                = 7,
        .sg_tablesize           = SG_ALL,
        .cmd_per_lun            = 1,
        .use_clustering         = DISABLE_CLUSTERING,
 };
 
-
-#include "scsi_module.c"
+static struct NCR_ESP *dec_esp_platform;
 
 /***************************************************************** Detection */
-static int dec_esp_detect(struct scsi_host_template * tpnt)
+static int dec_esp_platform_probe(void)
 {
        struct NCR_ESP *esp;
-       struct ConfigDev *esp_dev;
-       int slot;
-       unsigned long mem_start;
+       int err = 0;
 
        if (IOASIC) {
-               esp_dev = 0;
-               esp = esp_allocate(tpnt, (void *) esp_dev);
+               esp = esp_allocate(&dec_esp_template, NULL, 1);
 
                /* Do command transfer with programmed I/O */
                esp->do_pio_cmds = 1;
@@ -200,112 +182,175 @@ static int dec_esp_detect(struct scsi_host_template * tpnt)
                /* Check for differential SCSI-bus */
                esp->diff = 0;
 
+               err = request_irq(esp->irq, esp_intr, IRQF_DISABLED,
+                                 "ncr53c94", esp->ehost);
+               if (err)
+                       goto err_alloc;
+               err = request_irq(dec_interrupt[DEC_IRQ_ASC_MERR],
+                                 scsi_dma_merr_int, IRQF_DISABLED,
+                                 "ncr53c94 error", esp->ehost);
+               if (err)
+                       goto err_irq;
+               err = request_irq(dec_interrupt[DEC_IRQ_ASC_ERR],
+                                 scsi_dma_err_int, IRQF_DISABLED,
+                                 "ncr53c94 overrun", esp->ehost);
+               if (err)
+                       goto err_irq_merr;
+               err = request_irq(dec_interrupt[DEC_IRQ_ASC_DMA], scsi_dma_int,
+                                 IRQF_DISABLED, "ncr53c94 dma", esp->ehost);
+               if (err)
+                       goto err_irq_err;
+
                esp_initialize(esp);
 
-               if (request_irq(esp->irq, esp_intr, IRQF_DISABLED,
-                               "ncr53c94", esp->ehost))
-                       goto err_dealloc;
-               if (request_irq(dec_interrupt[DEC_IRQ_ASC_MERR],
-                               scsi_dma_merr_int, IRQF_DISABLED,
-                               "ncr53c94 error", esp->ehost))
-                       goto err_free_irq;
-               if (request_irq(dec_interrupt[DEC_IRQ_ASC_ERR],
-                               scsi_dma_err_int, IRQF_DISABLED,
-                               "ncr53c94 overrun", esp->ehost))
-                       goto err_free_irq_merr;
-               if (request_irq(dec_interrupt[DEC_IRQ_ASC_DMA],
-                               scsi_dma_int, IRQF_DISABLED,
-                               "ncr53c94 dma", esp->ehost))
-                       goto err_free_irq_err;
+               err = scsi_add_host(esp->ehost, NULL);
+               if (err) {
+                       printk(KERN_ERR "ESP: Unable to register adapter\n");
+                       goto err_irq_dma;
+               }
+
+               scsi_scan_host(esp->ehost);
 
+               dec_esp_platform = esp;
        }
 
-       if (TURBOCHANNEL) {
-               while ((slot = search_tc_card("PMAZ-AA")) >= 0) {
-                       claim_tc_card(slot);
-
-                       esp_dev = 0;
-                       esp = esp_allocate(tpnt, (void *) esp_dev);
-
-                       mem_start = get_tc_base_addr(slot);
-
-                       /* Store base addr into esp struct */
-                       esp->slot = CPHYSADDR(mem_start);
-
-                       esp->dregs = 0;
-                       esp->eregs = (void *)CKSEG1ADDR(mem_start +
-                                                       DEC_SCSI_SREG);
-                       esp->do_pio_cmds = 1;
-
-                       /* Set the command buffer */
-                       esp->esp_command = (volatile unsigned char *) pmaz_cmd_buffer;
-
-                       /* get virtual dma address for command buffer */
-                       esp->esp_command_dvma = virt_to_phys(pmaz_cmd_buffer);
-
-                       esp->cfreq = get_tc_speed();
-
-                       esp->irq = get_tc_irq_nr(slot);
-
-                       /* Required functions */
-                       esp->dma_bytes_sent = &dma_bytes_sent;
-                       esp->dma_can_transfer = &dma_can_transfer;
-                       esp->dma_dump_state = &dma_dump_state;
-                       esp->dma_init_read = &pmaz_dma_init_read;
-                       esp->dma_init_write = &pmaz_dma_init_write;
-                       esp->dma_ints_off = &pmaz_dma_ints_off;
-                       esp->dma_ints_on = &pmaz_dma_ints_on;
-                       esp->dma_irq_p = &dma_irq_p;
-                       esp->dma_ports_p = &dma_ports_p;
-                       esp->dma_setup = &pmaz_dma_setup;
-
-                       /* Optional functions */
-                       esp->dma_barrier = 0;
-                       esp->dma_drain = &pmaz_dma_drain;
-                       esp->dma_invalidate = 0;
-                       esp->dma_irq_entry = 0;
-                       esp->dma_irq_exit = 0;
-                       esp->dma_poll = 0;
-                       esp->dma_reset = 0;
-                       esp->dma_led_off = 0;
-                       esp->dma_led_on = 0;
-
-                       esp->dma_mmu_get_scsi_one = pmaz_dma_mmu_get_scsi_one;
-                       esp->dma_mmu_get_scsi_sgl = 0;
-                       esp->dma_mmu_release_scsi_one = 0;
-                       esp->dma_mmu_release_scsi_sgl = 0;
-                       esp->dma_advance_sg = 0;
-
-                       if (request_irq(esp->irq, esp_intr, IRQF_DISABLED,
-                                        "PMAZ_AA", esp->ehost)) {
-                               esp_deallocate(esp);
-                               release_tc_card(slot);
-                               continue;
-                       }
-                       esp->scsi_id = 7;
-                       esp->diff = 0;
-                       esp_initialize(esp);
-               }
+       return 0;
+
+err_irq_dma:
+       free_irq(dec_interrupt[DEC_IRQ_ASC_DMA], esp->ehost);
+err_irq_err:
+       free_irq(dec_interrupt[DEC_IRQ_ASC_ERR], esp->ehost);
+err_irq_merr:
+       free_irq(dec_interrupt[DEC_IRQ_ASC_MERR], esp->ehost);
+err_irq:
+       free_irq(esp->irq, esp->ehost);
+err_alloc:
+       esp_deallocate(esp);
+       scsi_host_put(esp->ehost);
+       return err;
+}
+
+static int __init dec_esp_probe(struct device *dev)
+{
+       struct NCR_ESP *esp;
+       resource_size_t start, len;
+       int err;
+
+       esp = esp_allocate(&dec_esp_template,  NULL, 1);
+
+       dev_set_drvdata(dev, esp);
+
+       start = to_tc_dev(dev)->resource.start;
+       len = to_tc_dev(dev)->resource.end - start + 1;
+
+       if (!request_mem_region(start, len, dev->bus_id)) {
+               printk(KERN_ERR "%s: Unable to reserve MMIO resource\n",
+                      dev->bus_id);
+               err = -EBUSY;
+               goto err_alloc;
        }
 
-       if(nesps) {
-               printk("ESP: Total of %d ESP hosts found, %d actually in use.\n", nesps, esps_in_use);
-               esps_running = esps_in_use;
-               return esps_in_use;
+       /* Store base addr into esp struct.  */
+       esp->slot = start;
+
+       esp->dregs = 0;
+       esp->eregs = (void *)CKSEG1ADDR(start + DEC_SCSI_SREG);
+       esp->do_pio_cmds = 1;
+
+       /* Set the command buffer.  */
+       esp->esp_command = (volatile unsigned char *)pmaz_cmd_buffer;
+
+       /* Get virtual dma address for command buffer.  */
+       esp->esp_command_dvma = virt_to_phys(pmaz_cmd_buffer);
+
+       esp->cfreq = tc_get_speed(to_tc_dev(dev)->bus);
+
+       esp->irq = to_tc_dev(dev)->interrupt;
+
+       /* Required functions.  */
+       esp->dma_bytes_sent = &dma_bytes_sent;
+       esp->dma_can_transfer = &dma_can_transfer;
+       esp->dma_dump_state = &dma_dump_state;
+       esp->dma_init_read = &pmaz_dma_init_read;
+       esp->dma_init_write = &pmaz_dma_init_write;
+       esp->dma_ints_off = &pmaz_dma_ints_off;
+       esp->dma_ints_on = &pmaz_dma_ints_on;
+       esp->dma_irq_p = &dma_irq_p;
+       esp->dma_ports_p = &dma_ports_p;
+       esp->dma_setup = &pmaz_dma_setup;
+
+       /* Optional functions.  */
+       esp->dma_barrier = 0;
+       esp->dma_drain = &pmaz_dma_drain;
+       esp->dma_invalidate = 0;
+       esp->dma_irq_entry = 0;
+       esp->dma_irq_exit = 0;
+       esp->dma_poll = 0;
+       esp->dma_reset = 0;
+       esp->dma_led_off = 0;
+       esp->dma_led_on = 0;
+
+       esp->dma_mmu_get_scsi_one = pmaz_dma_mmu_get_scsi_one;
+       esp->dma_mmu_get_scsi_sgl = 0;
+       esp->dma_mmu_release_scsi_one = 0;
+       esp->dma_mmu_release_scsi_sgl = 0;
+       esp->dma_advance_sg = 0;
+
+       err = request_irq(esp->irq, esp_intr, IRQF_DISABLED, "PMAZ_AA",
+                         esp->ehost);
+       if (err) {
+               printk(KERN_ERR "%s: Unable to get IRQ %d\n",
+                      dev->bus_id, esp->irq);
+               goto err_resource;
+       }
+
+       esp->scsi_id = 7;
+       esp->diff = 0;
+       esp_initialize(esp);
+
+       err = scsi_add_host(esp->ehost, dev);
+       if (err) {
+               printk(KERN_ERR "%s: Unable to register adapter\n",
+                      dev->bus_id);
+               goto err_irq;
        }
+
+       scsi_scan_host(esp->ehost);
+
        return 0;
 
-err_free_irq_err:
-       free_irq(dec_interrupt[DEC_IRQ_ASC_ERR], scsi_dma_err_int);
-err_free_irq_merr:
-       free_irq(dec_interrupt[DEC_IRQ_ASC_MERR], scsi_dma_merr_int);
-err_free_irq:
-       free_irq(esp->irq, esp_intr);
-err_dealloc:
+err_irq:
+       free_irq(esp->irq, esp->ehost);
+
+err_resource:
+       release_mem_region(start, len);
+
+err_alloc:
        esp_deallocate(esp);
-       return 0;
+       scsi_host_put(esp->ehost);
+       return err;
+}
+
+static void __exit dec_esp_platform_remove(void)
+{
+       struct NCR_ESP *esp = dec_esp_platform;
+
+       free_irq(esp->irq, esp->ehost);
+       esp_deallocate(esp);
+       scsi_host_put(esp->ehost);
+       dec_esp_platform = NULL;
 }
 
+static void __exit dec_esp_remove(struct device *dev)
+{
+       struct NCR_ESP *esp = dev_get_drvdata(dev);
+
+       free_irq(esp->irq, esp->ehost);
+       esp_deallocate(esp);
+       scsi_host_put(esp->ehost);
+}
+
+
 /************************************************************* DMA Functions */
 static irqreturn_t scsi_dma_merr_int(int irq, void *dev_id)
 {
@@ -576,3 +621,67 @@ static void pmaz_dma_mmu_get_scsi_one(struct NCR_ESP *esp, struct scsi_cmnd * sp
 {
        sp->SCp.ptr = (char *)virt_to_phys(sp->request_buffer);
 }
+
+
+#ifdef CONFIG_TC
+static int __init dec_esp_tc_probe(struct device *dev);
+static int __exit dec_esp_tc_remove(struct device *dev);
+
+static const struct tc_device_id dec_esp_tc_table[] = {
+        { "DEC     ", "PMAZ-AA " },
+        { }
+};
+MODULE_DEVICE_TABLE(tc, dec_esp_tc_table);
+
+static struct tc_driver dec_esp_tc_driver = {
+        .id_table       = dec_esp_tc_table,
+        .driver         = {
+                .name   = "dec_esp",
+                .bus    = &tc_bus_type,
+                .probe  = dec_esp_tc_probe,
+                .remove = __exit_p(dec_esp_tc_remove),
+        },
+};
+
+static int __init dec_esp_tc_probe(struct device *dev)
+{
+       int status = dec_esp_probe(dev);
+       if (!status)
+               get_device(dev);
+       return status;
+}
+
+static int __exit dec_esp_tc_remove(struct device *dev)
+{
+       put_device(dev);
+       dec_esp_remove(dev);
+       return 0;
+}
+#endif
+
+static int __init dec_esp_init(void)
+{
+       int status;
+
+       status = tc_register_driver(&dec_esp_tc_driver);
+       if (!status)
+               dec_esp_platform_probe();
+
+       if (nesps) {
+               pr_info("ESP: Total of %d ESP hosts found, "
+                       "%d actually in use.\n", nesps, esps_in_use);
+               esps_running = esps_in_use;
+       }
+
+       return status;
+}
+
+static void __exit dec_esp_exit(void)
+{
+       dec_esp_platform_remove();
+       tc_unregister_driver(&dec_esp_tc_driver);
+}
+
+
+module_init(dec_esp_init);
+module_exit(dec_esp_exit);
index 2a1c5c22b9e0a9baa2f6ccf8e49e127576a38ecf..4266a2139b5fb25f02bf46966ffe94966fd98ec4 100644 (file)
@@ -142,7 +142,7 @@ int __init fastlane_esp_detect(struct scsi_host_template *tpnt)
                if (board < 0x1000000) {
                        goto err_release;
                }
-               esp = esp_allocate(tpnt, (void *)board+FASTLANE_ESP_ADDR);
+               esp = esp_allocate(tpnt, (void *)board + FASTLANE_ESP_ADDR, 0);
 
                /* Do command transfer with programmed I/O */
                esp->do_pio_cmds = 1;
index 43768408437705fd81184e7be9e3a6a5d7bba0bb..8f55e1431433bddc961869f9104177e01dc318a8 100644 (file)
@@ -1375,7 +1375,7 @@ iscsi_tcp_mtask_xmit(struct iscsi_conn *conn, struct iscsi_mgmt_task *mtask)
        }
 
        BUG_ON(tcp_mtask->xmstate != XMSTATE_IDLE);
-       if (mtask->hdr->itt == cpu_to_be32(ISCSI_RESERVED_TAG)) {
+       if (mtask->hdr->itt == RESERVED_ITT) {
                struct iscsi_session *session = conn->session;
 
                spin_lock_bh(&session->lock);
index bfac4441d89fdcad18132a6e9e8720774697d364..19dd4b962e18c140d78511b0b516a07db696b1b7 100644 (file)
@@ -75,7 +75,7 @@ static int jazz_esp_detect(struct scsi_host_template *tpnt)
      */
     if (1) {
        esp_dev = NULL;
-       esp = esp_allocate(tpnt, (void *) esp_dev);
+       esp = esp_allocate(tpnt, esp_dev, 0);
        
        /* Do command transfer with programmed I/O */
        esp->do_pio_cmds = 1;
index d37048c96eab5163231f04917408a6c418c25b79..7c75771c77ff4aa32559b0cfeab48626fe65d47e 100644 (file)
@@ -113,8 +113,7 @@ static void iscsi_prep_scsi_cmd_pdu(struct iscsi_cmd_task *ctask)
         hdr->opcode = ISCSI_OP_SCSI_CMD;
         hdr->flags = ISCSI_ATTR_SIMPLE;
         int_to_scsilun(sc->device->lun, (struct scsi_lun *)hdr->lun);
-        hdr->itt = ctask->itt | (conn->id << ISCSI_CID_SHIFT) |
-                         (session->age << ISCSI_AGE_SHIFT);
+        hdr->itt = build_itt(ctask->itt, conn->id, session->age);
         hdr->data_length = cpu_to_be32(sc->request_bufflen);
         hdr->cmdsn = cpu_to_be32(session->cmdsn);
         session->cmdsn++;
@@ -270,7 +269,7 @@ invalid_datalen:
                        goto out;
                }
 
-               senselen = be16_to_cpu(*(uint16_t *)data);
+               senselen = be16_to_cpu(*(__be16 *)data);
                if (datalen < senselen)
                        goto invalid_datalen;
 
@@ -338,7 +337,7 @@ static int iscsi_handle_reject(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
 
                if (ntoh24(reject->dlength) >= sizeof(struct iscsi_hdr)) {
                        memcpy(&rejected_pdu, data, sizeof(struct iscsi_hdr));
-                       itt = rejected_pdu.itt & ISCSI_ITT_MASK;
+                       itt = get_itt(rejected_pdu.itt);
                        printk(KERN_ERR "itt 0x%x had pdu (op 0x%x) rejected "
                                "due to DataDigest error.\n", itt,
                                rejected_pdu.opcode);
@@ -367,10 +366,10 @@ int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
        struct iscsi_mgmt_task *mtask;
        uint32_t itt;
 
-       if (hdr->itt != cpu_to_be32(ISCSI_RESERVED_TAG))
-               itt = hdr->itt & ISCSI_ITT_MASK;
+       if (hdr->itt != RESERVED_ITT)
+               itt = get_itt(hdr->itt);
        else
-               itt = hdr->itt;
+               itt = ~0U;
 
        if (itt < session->cmds_max) {
                ctask = session->cmds[itt];
@@ -440,7 +439,7 @@ int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
                        iscsi_tmf_rsp(conn, hdr);
                        break;
                case ISCSI_OP_NOOP_IN:
-                       if (hdr->ttt != ISCSI_RESERVED_TAG || datalen) {
+                       if (hdr->ttt != cpu_to_be32(ISCSI_RESERVED_TAG) || datalen) {
                                rc = ISCSI_ERR_PROTO;
                                break;
                        }
@@ -457,7 +456,7 @@ int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
                        rc = ISCSI_ERR_BAD_OPCODE;
                        break;
                }
-       } else if (itt == ISCSI_RESERVED_TAG) {
+       } else if (itt == ~0U) {
                rc = iscsi_check_assign_cmdsn(session,
                                             (struct iscsi_nopin*)hdr);
                if (rc)
@@ -470,7 +469,7 @@ int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
                                break;
                        }
 
-                       if (hdr->ttt == ISCSI_RESERVED_TAG)
+                       if (hdr->ttt == cpu_to_be32(ISCSI_RESERVED_TAG))
                                break;
 
                        if (iscsi_recv_pdu(conn->cls_conn, hdr, NULL, 0))
@@ -516,24 +515,24 @@ int iscsi_verify_itt(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
        struct iscsi_cmd_task *ctask;
        uint32_t itt;
 
-       if (hdr->itt != cpu_to_be32(ISCSI_RESERVED_TAG)) {
-               if ((hdr->itt & ISCSI_AGE_MASK) !=
+       if (hdr->itt != RESERVED_ITT) {
+               if (((__force u32)hdr->itt & ISCSI_AGE_MASK) !=
                    (session->age << ISCSI_AGE_SHIFT)) {
                        printk(KERN_ERR "iscsi: received itt %x expected "
-                               "session age (%x)\n", hdr->itt,
+                               "session age (%x)\n", (__force u32)hdr->itt,
                                session->age & ISCSI_AGE_MASK);
                        return ISCSI_ERR_BAD_ITT;
                }
 
-               if ((hdr->itt & ISCSI_CID_MASK) !=
+               if (((__force u32)hdr->itt & ISCSI_CID_MASK) !=
                    (conn->id << ISCSI_CID_SHIFT)) {
                        printk(KERN_ERR "iscsi: received itt %x, expected "
-                               "CID (%x)\n", hdr->itt, conn->id);
+                               "CID (%x)\n", (__force u32)hdr->itt, conn->id);
                        return ISCSI_ERR_BAD_ITT;
                }
-               itt = hdr->itt & ISCSI_ITT_MASK;
+               itt = get_itt(hdr->itt);
        } else
-               itt = hdr->itt;
+               itt = ~0U;
 
        if (itt < session->cmds_max) {
                ctask = session->cmds[itt];
@@ -896,9 +895,8 @@ iscsi_conn_send_generic(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
        /*
         * pre-format CmdSN for outgoing PDU.
         */
-       if (hdr->itt != cpu_to_be32(ISCSI_RESERVED_TAG)) {
-               hdr->itt = mtask->itt | (conn->id << ISCSI_CID_SHIFT) |
-                          (session->age << ISCSI_AGE_SHIFT);
+       if (hdr->itt != RESERVED_ITT) {
+               hdr->itt = build_itt(mtask->itt, conn->id, session->age);
                nop->cmdsn = cpu_to_be32(session->cmdsn);
                if (conn->c_stage == ISCSI_CONN_STARTED &&
                    !(hdr->opcode & ISCSI_OP_IMMEDIATE))
@@ -1064,7 +1062,7 @@ static int iscsi_exec_abort_task(struct scsi_cmnd *sc,
 
        spin_lock_bh(&session->lock);
        ctask->mtask = (struct iscsi_mgmt_task *)
-                       session->mgmt_cmds[(hdr->itt & ISCSI_ITT_MASK) -
+                       session->mgmt_cmds[get_itt(hdr->itt) -
                                        ISCSI_MGMT_ITT_OFFSET];
 
        if (conn->tmabort_state == TMABORT_INITIAL) {
index 3586fac9be9a03d2ff2cac73210348d8b75631ac..bcb49021b7e204acbbc432e4cb9cace197ca37af 100644 (file)
@@ -351,7 +351,7 @@ int mac_esp_detect(struct scsi_host_template * tpnt)
        for (chipnum = 0; chipnum < chipspresent; chipnum ++) {
                struct NCR_ESP * esp;
 
-               esp = esp_allocate(tpnt, (void *) NULL);
+               esp = esp_allocate(tpnt, NULL, 0);
                esp->eregs = (struct ESP_regs *) get_base(chipnum);
 
                esp->dma_irq_p = &esp_dafb_dma_irq_p;
index 998a8bbc1a4b748962f9787967bfebb647212883..d693d0f213956bb2a5d9f9bfd4c0e4791a63d95a 100644 (file)
@@ -122,7 +122,7 @@ static int mca_esp_detect(struct scsi_host_template *tpnt)
                if ((slot = mca_find_adapter(*id_to_check, 0)) !=
                  MCA_NOTFOUND) 
                {
-                       esp = esp_allocate(tpnt, (void *) NULL);
+                       esp = esp_allocate(tpnt, NULL, 0);
 
                        pos[0] = mca_read_stored_pos(slot, 2);
                        pos[1] = mca_read_stored_pos(slot, 3);
index c116a6ae3c54f21caa66f3ca26b69cbdae92b3e1..26a6d55faf3ec03a86b480687cceb00872f5365e 100644 (file)
@@ -133,7 +133,7 @@ int oktagon_esp_detect(struct scsi_host_template *tpnt)
                eregs = (struct ESP_regs *)(address + OKTAGON_ESP_ADDR);
 
                /* This line was 5 lines lower */
-               esp = esp_allocate(tpnt, (void *)board+OKTAGON_ESP_ADDR);
+               esp = esp_allocate(tpnt, (void *)board + OKTAGON_ESP_ADDR, 0);
 
                /* we have to shift the registers only one bit for oktagon */
                esp->shift = 1;
index 7d231106790308999b22b5276718cec47f369cb2..bd6bbf61adb8e082ed99a6407e232531677df892 100644 (file)
@@ -521,10 +521,10 @@ static void osst_init_aux(struct osst_tape * STp, int frame_type, int frame_seq_
                break;
          default: ; /* probably FILL */
        }
-       aux->filemark_cnt = ntohl(STp->filemark_cnt);
-       aux->phys_fm = ntohl(0xffffffff);
-       aux->last_mark_ppos = ntohl(STp->last_mark_ppos);
-       aux->last_mark_lbn  = ntohl(STp->last_mark_lbn);
+       aux->filemark_cnt = htonl(STp->filemark_cnt);
+       aux->phys_fm = htonl(0xffffffff);
+       aux->last_mark_ppos = htonl(STp->last_mark_ppos);
+       aux->last_mark_lbn  = htonl(STp->last_mark_lbn);
 }
 
 /*
index 1e426f5d0ed8a734357c58897ff7619609b7a046..2cc7b5a1606a089b0346d0e8d53a914929bdde8e 100644 (file)
@@ -288,11 +288,11 @@ typedef struct {
 #else
 #error "Please fix <asm/byteorder.h>"
 #endif
-        u16             max_speed;              /* Maximum speed supported in KBps */
+        __be16          max_speed;              /* Maximum speed supported in KBps */
         u8              reserved10, reserved11;
-        u16             ctl;                    /* Continuous Transfer Limit in blocks */
-        u16             speed;                  /* Current Speed, in KBps */
-        u16             buffer_size;            /* Buffer Size, in 512 bytes */
+        __be16          ctl;                    /* Continuous Transfer Limit in blocks */
+        __be16          speed;                  /* Current Speed, in KBps */
+        __be16          buffer_size;            /* Buffer Size, in 512 bytes */
         u8              reserved18, reserved19;
 } osst_capabilities_page_t;
 
@@ -352,8 +352,8 @@ typedef struct {
        u8              reserved2;
        u8              density;
        u8              reserved3,reserved4;
-       u16             segtrk;
-       u16             trks;
+       __be16          segtrk;
+       __be16          trks;
        u8              reserved5,reserved6,reserved7,reserved8,reserved9,reserved10;
 } osst_tape_paramtr_page_t;
 
@@ -369,18 +369,18 @@ typedef struct {
 typedef struct os_partition_s {
         __u8    partition_num;
         __u8    par_desc_ver;
-        __u16   wrt_pass_cntr;
-        __u32   first_frame_ppos;
-        __u32   last_frame_ppos;
-        __u32   eod_frame_ppos;
+        __be16  wrt_pass_cntr;
+        __be32  first_frame_ppos;
+        __be32  last_frame_ppos;
+        __be32  eod_frame_ppos;
 } os_partition_t;
 
 /*
  * DAT entry
  */
 typedef struct os_dat_entry_s {
-        __u32   blk_sz;
-        __u16   blk_cnt;
+        __be32  blk_sz;
+        __be16  blk_cnt;
         __u8    flags;
         __u8    reserved;
 } os_dat_entry_t;
@@ -412,23 +412,23 @@ typedef struct os_dat_s {
  * AUX
  */
 typedef struct os_aux_s {
-        __u32           format_id;              /* hardware compability AUX is based on */
+        __be32          format_id;              /* hardware compability AUX is based on */
         char            application_sig[4];     /* driver used to write this media */
-        __u32           hdwr;                   /* reserved */
-        __u32           update_frame_cntr;      /* for configuration frame */
+        __be32          hdwr;                   /* reserved */
+        __be32          update_frame_cntr;      /* for configuration frame */
         __u8            frame_type;
         __u8            frame_type_reserved;
         __u8            reserved_18_19[2];
         os_partition_t  partition;
         __u8            reserved_36_43[8];
-        __u32           frame_seq_num;
-        __u32           logical_blk_num_high;
-        __u32           logical_blk_num;
+        __be32          frame_seq_num;
+        __be32          logical_blk_num_high;
+        __be32          logical_blk_num;
         os_dat_t        dat;
         __u8            reserved188_191[4];
-        __u32           filemark_cnt;
-        __u32           phys_fm;
-        __u32           last_mark_ppos;
+        __be32          filemark_cnt;
+        __be32          phys_fm;
+        __be32          last_mark_ppos;
         __u8            reserved204_223[20];
 
         /*
@@ -436,8 +436,8 @@ typedef struct os_aux_s {
          *
          * Linux specific fields:
          */
-         __u32          next_mark_ppos;         /* when known, points to next marker */
-        __u32          last_mark_lbn;          /* storing log_blk_num of last mark is extends ADR spec */
+         __be32         next_mark_ppos;         /* when known, points to next marker */
+        __be32         last_mark_lbn;          /* storing log_blk_num of last mark is extends ADR spec */
          __u8           linux_specific[24];
 
         __u8            reserved_256_511[256];
@@ -450,19 +450,19 @@ typedef struct os_fm_tab_s {
        __u8            reserved_1;
        __u8            fm_tab_ent_sz;
        __u8            reserved_3;
-       __u16           fm_tab_ent_cnt;
+       __be16          fm_tab_ent_cnt;
        __u8            reserved6_15[10];
-       __u32           fm_tab_ent[OS_FM_TAB_MAX];
+       __be32          fm_tab_ent[OS_FM_TAB_MAX];
 } os_fm_tab_t;
 
 typedef struct os_ext_trk_ey_s {
        __u8            et_part_num;
        __u8            fmt;
-       __u16           fm_tab_off;
+       __be16          fm_tab_off;
        __u8            reserved4_7[4];
-       __u32           last_hlb_hi;
-       __u32           last_hlb;
-       __u32           last_pp;
+       __be32          last_hlb_hi;
+       __be32          last_hlb;
+       __be32          last_pp;
        __u8            reserved20_31[12];
 } os_ext_trk_ey_t;
 
@@ -479,17 +479,17 @@ typedef struct os_header_s {
         char            ident_str[8];
         __u8            major_rev;
         __u8            minor_rev;
-       __u16           ext_trk_tb_off;
+       __be16          ext_trk_tb_off;
         __u8            reserved12_15[4];
         __u8            pt_par_num;
         __u8            pt_reserved1_3[3];
         os_partition_t  partition[16];
-       __u32           cfg_col_width;
-       __u32           dat_col_width;
-       __u32           qfa_col_width;
+       __be32          cfg_col_width;
+       __be32          dat_col_width;
+       __be32          qfa_col_width;
        __u8            cartridge[16];
        __u8            reserved304_511[208];
-       __u32           old_filemark_list[16680/4];             /* in ADR 1.4 __u8 track_table[16680] */
+       __be32          old_filemark_list[16680/4];             /* in ADR 1.4 __u8 track_table[16680] */
        os_ext_trk_tb_t ext_track_tb;
        __u8            reserved17272_17735[464];
        os_fm_tab_t     dat_fm_tab;
index f02f48a882a97b4150a7afe9eb403f1ce7f293fb..a1cd6e6a292aa887216837b77b6f2dc744b1a12f 100644 (file)
@@ -388,10 +388,9 @@ int scsi_execute_async(struct scsi_device *sdev, const unsigned char *cmd,
        int err = 0;
        int write = (data_direction == DMA_TO_DEVICE);
 
-       sioc = kmem_cache_alloc(scsi_io_context_cache, gfp);
+       sioc = kmem_cache_zalloc(scsi_io_context_cache, gfp);
        if (!sioc)
                return DRIVER_ERROR << 24;
-       memset(sioc, 0, sizeof(*sioc));
 
        req = blk_get_request(sdev->request_queue, write, gfp);
        if (!req)
index 6b60536ac92b4bb11278eb2f8b9ae37519f649e4..80fb3f88af2edd937ebdf2df51e8f4efcca67ee3 100644 (file)
@@ -53,7 +53,7 @@ int sun3x_esp_detect(struct scsi_host_template *tpnt)
        struct ConfigDev *esp_dev;
 
        esp_dev = 0;
-       esp = esp_allocate(tpnt, (void *) esp_dev);
+       esp = esp_allocate(tpnt, esp_dev, 0);
 
        /* Do command transfer with DMA */
        esp->do_pio_cmds = 0;
index 5261f0af8b101bcf4e1149caebdb484bbe92aa70..2964ca9df5a010f9cebb264e4115d5a588e5c234 100644 (file)
@@ -920,12 +920,16 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags)
 #ifdef __i386__
                outb(0xff, 0x080);
 #endif
-               scratch2 = serial_inp(up, UART_IER);
+               /*
+                * Mask out IER[7:4] bits for test as some UARTs (e.g. TL
+                * 16C754B) allow only to modify them if an EFR bit is set.
+                */
+               scratch2 = serial_inp(up, UART_IER) & 0x0f;
                serial_outp(up, UART_IER, 0x0F);
 #ifdef __i386__
                outb(0, 0x080);
 #endif
-               scratch3 = serial_inp(up, UART_IER);
+               scratch3 = serial_inp(up, UART_IER) & 0x0f;
                serial_outp(up, UART_IER, scratch);
                if (scratch2 != 0 || scratch3 != 0x0F) {
                        /*
index 52e2e64c6649dc25379994f6b1b119bc2d3b768f..a2dac378bda9199a94eeb2a5793cd989df360458 100644 (file)
@@ -677,6 +677,13 @@ static struct pci_serial_quirk pci_serial_quirks[] = {
        /*
         * PLX
         */
+       {
+               .vendor         = PCI_VENDOR_ID_PLX,
+               .device         = PCI_DEVICE_ID_PLX_9030,
+               .subvendor      = PCI_SUBVENDOR_ID_PERLE,
+               .subdevice      = PCI_ANY_ID,
+               .setup          = pci_default_setup,
+       },
        {
                .vendor         = PCI_VENDOR_ID_PLX,
                .device         = PCI_DEVICE_ID_PLX_9050,
@@ -936,6 +943,7 @@ enum pci_board_num_t {
 
        pbn_b2_1_115200,
        pbn_b2_2_115200,
+       pbn_b2_4_115200,
        pbn_b2_8_115200,
 
        pbn_b2_1_460800,
@@ -1249,6 +1257,12 @@ static struct pciserial_board pci_boards[] __devinitdata = {
                .base_baud      = 115200,
                .uart_offset    = 8,
        },
+       [pbn_b2_4_115200] = {
+               .flags          = FL_BASE2,
+               .num_ports      = 4,
+               .base_baud      = 115200,
+               .uart_offset    = 8,
+       },
        [pbn_b2_8_115200] = {
                .flags          = FL_BASE2,
                .num_ports      = 8,
@@ -1990,6 +2004,10 @@ static struct pci_device_id serial_pci_tbl[] = {
        {       PCI_VENDOR_ID_PANACOM, PCI_DEVICE_ID_PANACOM_DUALMODEM,
                PCI_ANY_ID, PCI_ANY_ID, 0, 0,
                pbn_panacom2 },
+       {       PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9030,
+               PCI_VENDOR_ID_ESDGMBH,
+               PCI_DEVICE_ID_ESDGMBH_CPCIASIO4, 0, 0,
+               pbn_b2_4_115200 },
        {       PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9050,
                PCI_SUBVENDOR_ID_CHASE_PCIFAST,
                PCI_SUBDEVICE_ID_CHASE_PCIFAST4, 0, 0, 
@@ -2378,6 +2396,15 @@ static struct pci_device_id serial_pci_tbl[] = {
                PCI_ANY_ID, PCI_ANY_ID, 0, 0,   /* 135a.0811 */
                pbn_b2_2_115200 },
 
+       /*
+        * Perle PCI-RAS cards
+        */
+       {       PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9030,
+               PCI_SUBVENDOR_ID_PERLE, PCI_SUBDEVICE_ID_PCI_RAS4,
+               0, 0, pbn_b2_4_921600 },
+       {       PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9030,
+               PCI_SUBVENDOR_ID_PERLE, PCI_SUBDEVICE_ID_PCI_RAS8,
+               0, 0, pbn_b2_8_921600 },
        /*
         * These entries match devices with class COMMUNICATION_SERIAL,
         * COMMUNICATION_MODEM or COMMUNICATION_MULTISERIAL
index 2978c09860eeff81cbedebf0c52ca8e142bf946c..5cc6b91f8408d0c0fbc2e3bc00c7279643d71e84 100644 (file)
@@ -916,6 +916,11 @@ config SERIAL_TXX9
 config HAS_TXX9_SERIAL
        bool
 
+config SERIAL_TXX9_NR_UARTS
+       int "Maximum number of TMPTX39XX/49XX SIO ports"
+       depends on SERIAL_TXX9
+       default "6"
+
 config SERIAL_TXX9_CONSOLE
        bool "TMPTX39XX/49XX SIO Console support"
        depends on SERIAL_TXX9=y
index 42b050c46abed3c17572b1865e5ba9c2a3432dde..312bef6bd583ce92d1382cfb8bbefbb0ba834f32 100644 (file)
@@ -3173,12 +3173,8 @@ do_softint(void *private_)
        if (!tty)
                return;
 
-       if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP, &info->event)) {
-               if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
-                   tty->ldisc.write_wakeup)
-                       (tty->ldisc.write_wakeup)(tty);
-               wake_up_interruptible(&tty->write_wait);
-       }
+       if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP, &info->event))
+               tty_wakeup(tty);
 }
 
 static int
@@ -3798,11 +3794,7 @@ rs_flush_buffer(struct tty_struct *tty)
        info->xmit.head = info->xmit.tail = 0;
        restore_flags(flags);
 
-       wake_up_interruptible(&tty->write_wait);
-
-       if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
-           tty->ldisc.write_wakeup)
-               (tty->ldisc.write_wakeup)(tty);
+       tty_wakeup(tty);
 }
 
 /*
index c862f67c985af312b15f11d68cb29390688bfacb..f540212e7409fe79971c85bed38a93ea1ca4c988 100644 (file)
@@ -2685,7 +2685,7 @@ static int ioc4_serial_remove_one(struct ioc4_driver_data *idd)
                free_irq(control->ic_irq, soft);
                if (soft->is_ioc4_serial_addr) {
                        iounmap(soft->is_ioc4_serial_addr);
-                       release_region((unsigned long)
+                       release_mem_region((unsigned long)
                             soft->is_ioc4_serial_addr,
                                sizeof(struct ioc4_serial));
                }
@@ -2790,7 +2790,7 @@ ioc4_serial_attach_one(struct ioc4_driver_data *idd)
        /* request serial registers */
        tmp_addr1 = idd->idd_bar0 + IOC4_SERIAL_OFFSET;
 
-       if (!request_region(tmp_addr1, sizeof(struct ioc4_serial),
+       if (!request_mem_region(tmp_addr1, sizeof(struct ioc4_serial),
                                        "sioc4_uart")) {
                printk(KERN_WARNING
                        "ioc4 (%p): unable to get request region for "
@@ -2889,7 +2889,7 @@ out3:
 out2:
        if (serial)
                iounmap(serial);
-       release_region(tmp_addr1, sizeof(struct ioc4_serial));
+       release_mem_region(tmp_addr1, sizeof(struct ioc4_serial));
 out1:
 
        return ret;
index 7186a82c47595582dfe3de1dbac4b6bb283585ba..f4440d3293106a9d7930fe3b9a55e10e755dbb78 100644 (file)
@@ -37,6 +37,7 @@
  *     1.06    Do not insert a char caused previous overrun.
  *             Fix some spin_locks.
  *             Do not call uart_add_one_port for absent ports.
+ *     1.07    Use CONFIG_SERIAL_TXX9_NR_UARTS.  Cleanup.
  */
 
 #if defined(CONFIG_SERIAL_TXX9_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
@@ -58,9 +59,8 @@
 #include <linux/mutex.h>
 
 #include <asm/io.h>
-#include <asm/irq.h>
 
-static char *serial_version = "1.06";
+static char *serial_version = "1.07";
 static char *serial_name = "TX39/49 Serial driver";
 
 #define PASS_LIMIT     256
@@ -88,12 +88,7 @@ static char *serial_name = "TX39/49 Serial driver";
 /*
  * Number of serial ports
  */
-#ifdef ENABLE_SERIAL_TXX9_PCI
-#define NR_PCI_BOARDS  4
-#define UART_NR  (4 + NR_PCI_BOARDS)
-#else
-#define UART_NR  4
-#endif
+#define UART_NR  CONFIG_SERIAL_TXX9_NR_UARTS
 
 #define HIGH_BITS_OFFSET       ((sizeof(long)-sizeof(int))*8)
 
@@ -987,6 +982,7 @@ int __init early_serial_txx9_setup(struct uart_port *port)
 }
 
 #ifdef ENABLE_SERIAL_TXX9_PCI
+#ifdef CONFIG_PM
 /**
  *     serial_txx9_suspend_port - suspend one serial port
  *     @line:  serial line number
@@ -1008,6 +1004,7 @@ static void serial_txx9_resume_port(int line)
 {
        uart_resume_port(&serial_txx9_reg, &serial_txx9_ports[line].port);
 }
+#endif
 
 static DEFINE_MUTEX(serial_txx9_mutex);
 
@@ -1118,6 +1115,7 @@ static void __devexit pciserial_txx9_remove_one(struct pci_dev *dev)
        }
 }
 
+#ifdef CONFIG_PM
 static int pciserial_txx9_suspend_one(struct pci_dev *dev, pm_message_t state)
 {
        int line = (int)(long)pci_get_drvdata(dev);
@@ -1142,11 +1140,10 @@ static int pciserial_txx9_resume_one(struct pci_dev *dev)
        }
        return 0;
 }
+#endif
 
-static struct pci_device_id serial_txx9_pci_tbl[] = {
-       {       PCI_VENDOR_ID_TOSHIBA_2, PCI_DEVICE_ID_TOSHIBA_TC86C001_MISC,
-               PCI_ANY_ID, PCI_ANY_ID,
-               0, 0, 0 },
+static const struct pci_device_id serial_txx9_pci_tbl[] = {
+       { PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA_2, PCI_DEVICE_ID_TOSHIBA_TC86C001_MISC) },
        { 0, }
 };
 
@@ -1154,8 +1151,10 @@ static struct pci_driver serial_txx9_pci_driver = {
        .name           = "serial_txx9",
        .probe          = pciserial_txx9_init_one,
        .remove         = __devexit_p(pciserial_txx9_remove_one),
+#ifdef CONFIG_PM
        .suspend        = pciserial_txx9_suspend_one,
        .resume         = pciserial_txx9_resume_one,
+#endif
        .id_table       = serial_txx9_pci_tbl,
 };
 
index db8607e3d5318013a13b0fa94eee7707c6270e7b..f5051cf1a0c8ec0613d1b4c9d467fa099a5c1aa6 100644 (file)
@@ -256,7 +256,7 @@ static void ulite_release_port(struct uart_port *port)
 {
        release_mem_region(port->mapbase, ULITE_REGION);
        iounmap(port->membase);
-       port->membase = 0;
+       port->membase = NULL;
 }
 
 static int ulite_request_port(struct uart_port *port)
@@ -438,7 +438,7 @@ static int __devinit ulite_probe(struct platform_device *pdev)
        port->iotype    = UPIO_MEM;
        port->iobase    = 1; /* mark port in use */
        port->mapbase   = res->start;
-       port->membase   = 0;
+       port->membase   = NULL;
        port->ops       = &ulite_ops;
        port->irq       = res2->start;
        port->flags     = UPF_BOOT_AUTOCONF;
@@ -462,7 +462,7 @@ static int ulite_remove(struct platform_device *pdev)
                uart_remove_one_port(&ulite_uart_driver, port);
 
        /* mark port as free */
-       port->membase = 0;
+       port->membase = NULL;
 
        return 0;
 }
index cd6b65333b71a51660471128e4128dd8d90116dc..2dd6eed50aa06ef3721811d364d32086206ee437 100644 (file)
@@ -654,7 +654,7 @@ static int ioc3_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
                ret = -ENODEV;
                goto out_pci;
        }
-       if (!request_region(idd->pma, IOC3_PCI_SIZE, "ioc3")) {
+       if (!request_mem_region(idd->pma, IOC3_PCI_SIZE, "ioc3")) {
                printk(KERN_WARNING
                       "%s: Unable to request IOC3 region "
                       "for pci_dev %s.\n",
@@ -744,7 +744,7 @@ static int ioc3_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
        return 0;
 
 out_misc_region:
-       release_region(idd->pma, IOC3_PCI_SIZE);
+       release_mem_region(idd->pma, IOC3_PCI_SIZE);
 out_pci:
        kfree(idd);
 out_idd:
@@ -785,7 +785,7 @@ static void ioc3_remove(struct pci_dev *pdev)
        if(idd->dual_irq)
                free_irq(idd->irq_eth, (void *)idd);
        iounmap(idd->vma);
-       release_region(idd->pma, IOC3_PCI_SIZE);
+       release_mem_region(idd->pma, IOC3_PCI_SIZE);
 
        /* Disable IOC3 and relinquish */
        pci_disable_device(pdev);
index 83b5bd75ce2639a8747dfaabacb57402cda6bc94..9673426922114cacb1c70dcdda0f565955711d84 100644 (file)
@@ -4,7 +4,7 @@
 
 # Object file lists.
 
-obj-$(CONFIG_TC) += tc.o
+obj-$(CONFIG_TC) += tc.o tc-driver.o
 obj-$(CONFIG_ZS) += zs.o
 obj-$(CONFIG_VT) += lk201.o lk201-map.o lk201-remap.o
 
diff --git a/drivers/tc/tc-driver.c b/drivers/tc/tc-driver.c
new file mode 100644 (file)
index 0000000..16b5bae
--- /dev/null
@@ -0,0 +1,110 @@
+/*
+ *     TURBOchannel driver services.
+ *
+ *     Copyright (c) 2005  James Simmons
+ *     Copyright (c) 2006  Maciej W. Rozycki
+ *
+ *     Loosely based on drivers/dio/dio-driver.c and
+ *     drivers/pci/pci-driver.c.
+ *
+ *     This file is subject to the terms and conditions of the GNU
+ *     General Public License.  See the file "COPYING" in the main
+ *     directory of this archive for more details.
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/tc.h>
+
+/**
+ * tc_register_driver - register a new TC driver
+ * @drv: the driver structure to register
+ *
+ * Adds the driver structure to the list of registered drivers
+ * Returns a negative value on error, otherwise 0.
+ * If no error occurred, the driver remains registered even if
+ * no device was claimed during registration.
+ */
+int tc_register_driver(struct tc_driver *tdrv)
+{
+       return driver_register(&tdrv->driver);
+}
+EXPORT_SYMBOL(tc_register_driver);
+
+/**
+ * tc_unregister_driver - unregister a TC driver
+ * @drv: the driver structure to unregister
+ *
+ * Deletes the driver structure from the list of registered TC drivers,
+ * gives it a chance to clean up by calling its remove() function for
+ * each device it was responsible for, and marks those devices as
+ * driverless.
+ */
+void tc_unregister_driver(struct tc_driver *tdrv)
+{
+       driver_unregister(&tdrv->driver);
+}
+EXPORT_SYMBOL(tc_unregister_driver);
+
+/**
+ * tc_match_device - tell if a TC device structure has a matching
+ *                   TC device ID structure
+ * @tdrv: the TC driver to earch for matching TC device ID strings
+ * @tdev: the TC device structure to match against
+ *
+ * Used by a driver to check whether a TC device present in the
+ * system is in its list of supported devices.  Returns the matching
+ * tc_device_id structure or %NULL if there is no match.
+ */
+const struct tc_device_id *tc_match_device(struct tc_driver *tdrv,
+                                          struct tc_dev *tdev)
+{
+       const struct tc_device_id *id = tdrv->id_table;
+
+       if (id) {
+               while (id->name[0] || id->vendor[0]) {
+                       if (strcmp(tdev->name, id->name) == 0 &&
+                           strcmp(tdev->vendor, id->vendor) == 0)
+                               return id;
+                       id++;
+               }
+       }
+       return NULL;
+}
+EXPORT_SYMBOL(tc_match_device);
+
+/**
+ * tc_bus_match - Tell if a device structure has a matching
+ *                TC device ID structure
+ * @dev: the device structure to match against
+ * @drv: the device driver to search for matching TC device ID strings
+ *
+ * Used by a driver to check whether a TC device present in the
+ * system is in its list of supported devices.  Returns 1 if there
+ * is a match or 0 otherwise.
+ */
+static int tc_bus_match(struct device *dev, struct device_driver *drv)
+{
+       struct tc_dev *tdev = to_tc_dev(dev);
+       struct tc_driver *tdrv = to_tc_driver(drv);
+       const struct tc_device_id *id;
+
+       id = tc_match_device(tdrv, tdev);
+       if (id)
+               return 1;
+
+       return 0;
+}
+
+struct bus_type tc_bus_type = {
+       .name   = "tc",
+       .match  = tc_bus_match,
+};
+EXPORT_SYMBOL(tc_bus_type);
+
+static int __init tc_driver_init(void)
+{
+       return bus_register(&tc_bus_type);
+}
+
+postcore_initcall(tc_driver_init);
index 4a51e56f85b6b0a3d362bdd44317c2c484c84319..f77f62a4b325d3bb3c898efe42d397a17238114a 100644 (file)
 /*
- * tc-init: We assume the TURBOchannel to be up and running so
- * just probe for Modules and fill in the global data structure
- * tc_bus.
+ *     TURBOchannel bus services.
  *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
+ *     Copyright (c) Harald Koerfgen, 1998
+ *     Copyright (c) 2001, 2003, 2005, 2006  Maciej W. Rozycki
+ *     Copyright (c) 2005  James Simmons
  *
- * Copyright (c) Harald Koerfgen, 1998
- * Copyright (c) 2001, 2003, 2005  Maciej W. Rozycki
+ *     This file is subject to the terms and conditions of the GNU
+ *     General Public License.  See the file "COPYING" in the main
+ *     directory of this archive for more details.
  */
+#include <linux/compiler.h>
+#include <linux/errno.h>
 #include <linux/init.h>
+#include <linux/ioport.h>
 #include <linux/kernel.h>
+#include <linux/list.h>
 #include <linux/module.h>
 #include <linux/string.h>
+#include <linux/tc.h>
 #include <linux/types.h>
 
-#include <asm/addrspace.h>
-#include <asm/errno.h>
 #include <asm/io.h>
-#include <asm/paccess.h>
 
-#include <asm/dec/machtype.h>
-#include <asm/dec/prom.h>
-#include <asm/dec/tcinfo.h>
-#include <asm/dec/tcmodule.h>
-#include <asm/dec/interrupts.h>
-
-MODULE_LICENSE("GPL");
-slot_info tc_bus[MAX_SLOT];
-static int num_tcslots;
-static tcinfo *info;
+static struct tc_bus tc_bus = {
+       .name = "TURBOchannel",
+};
 
 /*
- * Interface to the world. Read comment in include/asm-mips/tc.h.
+ * Probing for TURBOchannel modules.
  */
-
-int search_tc_card(const char *name)
-{
-       int slot;
-       slot_info *sip;
-
-       for (slot = 0; slot < num_tcslots; slot++) {
-               sip = &tc_bus[slot];
-               if ((sip->flags & FREE) &&
-                   (strncmp(sip->name, name, strlen(name)) == 0)) {
-                       return slot;
-               }
-       }
-
-       return -ENODEV;
-}
-
-void claim_tc_card(int slot)
-{
-       if (tc_bus[slot].flags & IN_USE) {
-               printk("claim_tc_card: attempting to claim a card already in use\n");
-               return;
-       }
-       tc_bus[slot].flags &= ~FREE;
-       tc_bus[slot].flags |= IN_USE;
-}
-
-void release_tc_card(int slot)
+static void __init tc_bus_add_devices(struct tc_bus *tbus)
 {
-       if (tc_bus[slot].flags & FREE) {
-               printk("release_tc_card: "
-                      "attempting to release a card already free\n");
-               return;
-       }
-       tc_bus[slot].flags &= ~IN_USE;
-       tc_bus[slot].flags |= FREE;
-}
-
-unsigned long get_tc_base_addr(int slot)
-{
-       return tc_bus[slot].base_addr;
-}
-
-unsigned long get_tc_irq_nr(int slot)
-{
-       return tc_bus[slot].interrupt;
-}
-
-unsigned long get_tc_speed(void)
-{
-       return 100000 * (10000 / (unsigned long)info->clk_period);
-}
-
-/*
- * Probing for TURBOchannel modules
- */
-static void __init tc_probe(unsigned long startaddr, unsigned long size,
-                           int slots)
-{
-       unsigned long slotaddr;
+       resource_size_t slotsize = tbus->info.slot_size << 20;
+       resource_size_t extslotsize = tbus->ext_slot_size;
+       resource_size_t slotaddr;
+       resource_size_t extslotaddr;
+       resource_size_t devsize;
+       void __iomem *module;
+       struct tc_dev *tdev;
        int i, slot, err;
-       long offset;
        u8 pattern[4];
-       volatile u8 *module;
+       long offset;
 
-       for (slot = 0; slot < slots; slot++) {
-               slotaddr = startaddr + slot * size;
-               module = ioremap_nocache(slotaddr, size);
+       for (slot = 0; slot < tbus->num_tcslots; slot++) {
+               slotaddr = tbus->slot_base + slot * slotsize;
+               extslotaddr = tbus->ext_slot_base + slot * extslotsize;
+               module = ioremap_nocache(slotaddr, slotsize);
                BUG_ON(!module);
 
-               offset = OLDCARD;
+               offset = TC_OLDCARD;
 
                err = 0;
-               err |= get_dbe(pattern[0], module + OLDCARD + TC_PATTERN0);
-               err |= get_dbe(pattern[1], module + OLDCARD + TC_PATTERN1);
-               err |= get_dbe(pattern[2], module + OLDCARD + TC_PATTERN2);
-               err |= get_dbe(pattern[3], module + OLDCARD + TC_PATTERN3);
-               if (err) {
-                       iounmap(module);
-                       continue;
-               }
+               err |= tc_preadb(pattern + 0, module + offset + TC_PATTERN0);
+               err |= tc_preadb(pattern + 1, module + offset + TC_PATTERN1);
+               err |= tc_preadb(pattern + 2, module + offset + TC_PATTERN2);
+               err |= tc_preadb(pattern + 3, module + offset + TC_PATTERN3);
+               if (err)
+                       goto out_err;
 
                if (pattern[0] != 0x55 || pattern[1] != 0x00 ||
                    pattern[2] != 0xaa || pattern[3] != 0xff) {
-                       offset = NEWCARD;
+                       offset = TC_NEWCARD;
 
                        err = 0;
-                       err |= get_dbe(pattern[0], module + TC_PATTERN0);
-                       err |= get_dbe(pattern[1], module + TC_PATTERN1);
-                       err |= get_dbe(pattern[2], module + TC_PATTERN2);
-                       err |= get_dbe(pattern[3], module + TC_PATTERN3);
-                       if (err) {
-                               iounmap(module);
-                               continue;
-                       }
+                       err |= tc_preadb(pattern + 0,
+                                        module + offset + TC_PATTERN0);
+                       err |= tc_preadb(pattern + 1,
+                                        module + offset + TC_PATTERN1);
+                       err |= tc_preadb(pattern + 2,
+                                        module + offset + TC_PATTERN2);
+                       err |= tc_preadb(pattern + 3,
+                                        module + offset + TC_PATTERN3);
+                       if (err)
+                               goto out_err;
                }
 
                if (pattern[0] != 0x55 || pattern[1] != 0x00 ||
-                   pattern[2] != 0xaa || pattern[3] != 0xff) {
-                       iounmap(module);
-                       continue;
+                   pattern[2] != 0xaa || pattern[3] != 0xff)
+                       goto out_err;
+
+               /* Found a board, allocate it an entry in the list */
+               tdev = kzalloc(sizeof(*tdev), GFP_KERNEL);
+               if (!tdev) {
+                       printk(KERN_ERR "tc%x: unable to allocate tc_dev\n",
+                              slot);
+                       goto out_err;
                }
+               sprintf(tdev->dev.bus_id, "tc%x", slot);
+               tdev->bus = tbus;
+               tdev->dev.parent = &tbus->dev;
+               tdev->dev.bus = &tc_bus_type;
+               tdev->slot = slot;
 
-               tc_bus[slot].base_addr = slotaddr;
                for (i = 0; i < 8; i++) {
-                       tc_bus[slot].firmware[i] =
-                               module[TC_FIRM_VER + offset + 4 * i];
-                       tc_bus[slot].vendor[i] =
-                               module[TC_VENDOR + offset + 4 * i];
-                       tc_bus[slot].name[i] =
-                               module[TC_MODULE + offset + 4 * i];
+                       tdev->firmware[i] =
+                               readb(module + offset + TC_FIRM_VER + 4 * i);
+                       tdev->vendor[i] =
+                               readb(module + offset + TC_VENDOR + 4 * i);
+                       tdev->name[i] =
+                               readb(module + offset + TC_MODULE + 4 * i);
                }
-               tc_bus[slot].firmware[8] = 0;
-               tc_bus[slot].vendor[8] = 0;
-               tc_bus[slot].name[8] = 0;
-               /*
-                * Looks unneccesary, but we may change
-                * TC? in the future
-                */
-               switch (slot) {
-               case 0:
-                       tc_bus[slot].interrupt = dec_interrupt[DEC_IRQ_TC0];
-                       break;
-               case 1:
-                       tc_bus[slot].interrupt = dec_interrupt[DEC_IRQ_TC1];
-                       break;
-               case 2:
-                       tc_bus[slot].interrupt = dec_interrupt[DEC_IRQ_TC2];
-                       break;
-               /*
-                * Yuck! DS5000/200 onboard devices
-                */
-               case 5:
-                       tc_bus[slot].interrupt = dec_interrupt[DEC_IRQ_TC5];
-                       break;
-               case 6:
-                       tc_bus[slot].interrupt = dec_interrupt[DEC_IRQ_TC6];
-                       break;
-               default:
-                       tc_bus[slot].interrupt = -1;
-                       break;
+               tdev->firmware[8] = 0;
+               tdev->vendor[8] = 0;
+               tdev->name[8] = 0;
+
+               pr_info("%s: %s %s %s\n", tdev->dev.bus_id, tdev->vendor,
+                       tdev->name, tdev->firmware);
+
+               devsize = readb(module + offset + TC_SLOT_SIZE);
+               devsize <<= 22;
+               if (devsize <= slotsize) {
+                       tdev->resource.start = slotaddr;
+                       tdev->resource.end = slotaddr + devsize - 1;
+               } else if (devsize <= extslotsize) {
+                       tdev->resource.start = extslotaddr;
+                       tdev->resource.end = extslotaddr + devsize - 1;
+               } else {
+                       printk(KERN_ERR "%s: Cannot provide slot space "
+                              "(%dMiB required, up to %dMiB supported)\n",
+                              tdev->dev.bus_id, devsize >> 20,
+                              max(slotsize, extslotsize) >> 20);
+                       kfree(tdev);
+                       goto out_err;
                }
+               tdev->resource.name = tdev->name;
+               tdev->resource.flags = IORESOURCE_MEM;
+
+               tc_device_get_irq(tdev);
 
+               device_register(&tdev->dev);
+               list_add_tail(&tdev->node, &tbus->devices);
+
+out_err:
                iounmap(module);
        }
 }
 
 /*
- * the main entry
+ * The main entry.
  */
 static int __init tc_init(void)
 {
-       int tc_clock;
-       int i;
-       unsigned long slot0addr;
-       unsigned long slot_size;
-
-       if (!TURBOCHANNEL)
+       /* Initialize the TURBOchannel bus */
+       if (tc_bus_get_info(&tc_bus))
                return 0;
 
-       for (i = 0; i < MAX_SLOT; i++) {
-               tc_bus[i].base_addr = 0;
-               tc_bus[i].name[0] = 0;
-               tc_bus[i].vendor[0] = 0;
-               tc_bus[i].firmware[0] = 0;
-               tc_bus[i].interrupt = -1;
-               tc_bus[i].flags = FREE;
-       }
-
-       info = rex_gettcinfo();
-       slot0addr = CPHYSADDR((long)rex_slot_address(0));
-
-       switch (mips_machtype) {
-       case MACH_DS5000_200:
-               num_tcslots = 7;
-               break;
-       case MACH_DS5000_1XX:
-       case MACH_DS5000_2X0:
-       case MACH_DS5900:
-               num_tcslots = 3;
-               break;
-       case MACH_DS5000_XX:
-       default:
-               num_tcslots = 2;
-               break;
-       }
-
-       tc_clock = 10000 / info->clk_period;
-
-       if (info->slot_size && slot0addr) {
-               pr_info("TURBOchannel rev. %d at %d.%d MHz (with%s parity)\n",
-                       info->revision, tc_clock / 10, tc_clock % 10,
-                       info->parity ? "" : "out");
-
-               slot_size = info->slot_size << 20;
-
-               tc_probe(slot0addr, slot_size, num_tcslots);
-
-               for (i = 0; i < num_tcslots; i++) {
-                       if (!tc_bus[i].base_addr)
-                               continue;
-                       pr_info("    slot %d: %s %s %s\n", i, tc_bus[i].vendor,
-                               tc_bus[i].name, tc_bus[i].firmware);
+       INIT_LIST_HEAD(&tc_bus.devices);
+       strcpy(tc_bus.dev.bus_id, "tc");
+       device_register(&tc_bus.dev);
+
+       if (tc_bus.info.slot_size) {
+               unsigned int tc_clock = tc_get_speed(&tc_bus) / 100000;
+
+               pr_info("tc: TURBOchannel rev. %d at %d.%d MHz "
+                       "(with%s parity)\n", tc_bus.info.revision,
+                       tc_clock / 10, tc_clock % 10,
+                       tc_bus.info.parity ? "" : "out");
+
+               tc_bus.resource[0].start = tc_bus.slot_base;
+               tc_bus.resource[0].end = tc_bus.slot_base +
+                                        (tc_bus.info.slot_size << 20) *
+                                        tc_bus.num_tcslots - 1;
+               tc_bus.resource[0].name = tc_bus.name;
+               tc_bus.resource[0].flags = IORESOURCE_MEM;
+               if (request_resource(&iomem_resource,
+                                    &tc_bus.resource[0]) < 0) {
+                       printk(KERN_ERR "tc: Cannot reserve resource\n");
+                       return 0;
+               }
+               if (tc_bus.ext_slot_size) {
+                       tc_bus.resource[1].start = tc_bus.ext_slot_base;
+                       tc_bus.resource[1].end = tc_bus.ext_slot_base +
+                                                tc_bus.ext_slot_size *
+                                                tc_bus.num_tcslots - 1;
+                       tc_bus.resource[1].name = tc_bus.name;
+                       tc_bus.resource[1].flags = IORESOURCE_MEM;
+                       if (request_resource(&iomem_resource,
+                                            &tc_bus.resource[1]) < 0) {
+                               printk(KERN_ERR
+                                      "tc: Cannot reserve resource\n");
+                               release_resource(&tc_bus.resource[0]);
+                               return 0;
+                       }
                }
+
+               tc_bus_add_devices(&tc_bus);
        }
 
        return 0;
 }
 
 subsys_initcall(tc_init);
-
-EXPORT_SYMBOL(search_tc_card);
-EXPORT_SYMBOL(claim_tc_card);
-EXPORT_SYMBOL(release_tc_card);
-EXPORT_SYMBOL(get_tc_base_addr);
-EXPORT_SYMBOL(get_tc_irq_nr);
-EXPORT_SYMBOL(get_tc_speed);
index fc3197273663e93c48f975cded7c748727ad0370..3d72aa5cfc713bb3b66dbe3c6b49ee8ceb25d0df 100644 (file)
@@ -626,10 +626,8 @@ static void do_softint(unsigned long private_)
        if (!tty)
                return;
 
-       if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP, &info->event)) {
+       if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP, &info->event))
                tty_wakeup(tty);
-               wake_up_interruptible(&tty->write_wait);
-       }
 }
 
 static int zs_startup(struct dec_serial * info)
index f04a29a46646c8a38c13432674c62dea1c92b977..c6b6479fa4ddee3ec893288f85d7b66b38d27359 100644 (file)
@@ -1953,7 +1953,7 @@ static void invalidate_sub(struct lun *curlun)
        struct inode    *inode = filp->f_path.dentry->d_inode;
        unsigned long   rc;
 
-       rc = invalidate_inode_pages(inode->i_mapping);
+       rc = invalidate_mapping_pages(inode->i_mapping, 0, -1);
        VLDBG(curlun, "invalidate_inode_pages -> %ld\n", rc);
 }
 
index 408c3380d60203254b510c43a728da6214a42c7c..6ec8cf1a3ccb1cd14d39667231da28b36abdecdf 100644 (file)
@@ -1419,7 +1419,6 @@ int __devinit rndis_init (void)
                        return -EIO;
                }
 
-               rndis_connect_state [i]->nlink = 1;
                rndis_connect_state [i]->write_proc = rndis_proc_write;
                rndis_connect_state [i]->read_proc = rndis_proc_read;
                rndis_connect_state [i]->data = (void *)
index 371f194a9d39b051e2c086e99a3d382a21145990..4d781a2a9807874a1f65fe206a5f8c4a8278c0c4 100644 (file)
@@ -104,7 +104,7 @@ static int ps3_ehci_sb_probe(struct ps3_system_bus_device *dev)
        dev_dbg(&dev->core, "%s:%d: mmio mapped_addr %lxh\n", __func__,
                __LINE__, dev->m_region->lpar_addr);
 
-       result = ps3_alloc_io_irq(dev->interrupt_id, &virq);
+       result = ps3_alloc_io_irq(PS3_BINDING_CPU_ANY, dev->interrupt_id, &virq);
 
        if (result) {
                dev_dbg(&dev->core, "%s:%d: ps3_construct_io_irq(%d) failed.\n",
index ec0da0343be477868a0549b950afc937cf897d0d..46fa57a520d0d6b37a83c459bf1c2ec869369922 100644 (file)
@@ -677,10 +677,10 @@ static inline unsigned int ehci_readl (const struct ehci_hcd *ehci,
 {
 #ifdef CONFIG_USB_EHCI_BIG_ENDIAN_MMIO
        return ehci_big_endian_mmio(ehci) ?
-               readl_be((__force u32 *)regs) :
-               readl((__force u32 *)regs);
+               readl_be(regs) :
+               readl(regs);
 #else
-       return readl((__force u32 *)regs);
+       return readl(regs);
 #endif
 }
 
@@ -689,10 +689,10 @@ static inline void ehci_writel (const struct ehci_hcd *ehci,
 {
 #ifdef CONFIG_USB_EHCI_BIG_ENDIAN_MMIO
        ehci_big_endian_mmio(ehci) ?
-               writel_be(val, (__force u32 *)regs) :
-               writel(val, (__force u32 *)regs);
+               writel_be(val, regs) :
+               writel(val, regs);
 #else
-       writel(val, (__force u32 *)regs);
+       writel(val, regs);
 #endif
 }
 
index 282d82efc0b0a0e8280884ad7a041e3561b7bf80..f0ffb8907f292df3b9e39a32b92809e7ae498f06 100644 (file)
@@ -2163,9 +2163,8 @@ static void etrax_usb_add_to_bulk_sb_list(struct urb *urb, int epid)
 
        maxlen = usb_maxpacket(urb->dev, urb->pipe, usb_pipeout(urb->pipe));
 
-       sb_desc = (USB_SB_Desc_t*)kmem_cache_alloc(usb_desc_cache, SLAB_FLAG);
+       sb_desc = kmem_cache_zalloc(usb_desc_cache, SLAB_FLAG);
        assert(sb_desc != NULL);
-       memset(sb_desc, 0, sizeof(USB_SB_Desc_t));
 
 
        if (usb_pipeout(urb->pipe)) {
index 69d948b4a7014df1179b0f51bc3dc3c35fee20cb..62283a3926debe9fc0d929190c7b7d01b1a967b5 100644 (file)
@@ -107,7 +107,7 @@ static int ps3_ohci_sb_probe(struct ps3_system_bus_device *dev)
        dev_dbg(&dev->core, "%s:%d: mmio mapped_addr %lxh\n", __func__,
                __LINE__, dev->m_region->lpar_addr);
 
-       result = ps3_alloc_io_irq(dev->interrupt_id, &virq);
+       result = ps3_alloc_io_irq(PS3_BINDING_CPU_ANY, dev->interrupt_id, &virq);
 
        if (result) {
                dev_dbg(&dev->core, "%s:%d: ps3_construct_io_irq(%d) failed.\n",
index 0dafcda3729126320e46918e79411d2acc8a6555..c2b5ecfe5e9fa8ca88b33a28b792dd15e3a43fb8 100644 (file)
@@ -507,10 +507,10 @@ static inline unsigned int _ohci_readl (const struct ohci_hcd *ohci,
 {
 #ifdef CONFIG_USB_OHCI_BIG_ENDIAN_MMIO
        return big_endian_mmio(ohci) ?
-               readl_be ((__force u32 *)regs) :
-               readl ((__force u32 *)regs);
+               readl_be (regs) :
+               readl (regs);
 #else
-       return readl ((__force u32 *)regs);
+       return readl (regs);
 #endif
 }
 
@@ -519,10 +519,10 @@ static inline void _ohci_writel (const struct ohci_hcd *ohci,
 {
 #ifdef CONFIG_USB_OHCI_BIG_ENDIAN_MMIO
        big_endian_mmio(ohci) ?
-               writel_be (val, (__force u32 *)regs) :
-               writel (val, (__force u32 *)regs);
+               writel_be (val, regs) :
+               writel (val, regs);
 #else
-               writel (val, (__force u32 *)regs);
+               writel (val, regs);
 #endif
 }
 
index 2cbb239e63f8863688df8562805816d101b33754..68e66b33e7269bfd1ba3972aadaee6e64b09bd79 100644 (file)
@@ -624,12 +624,10 @@ static inline struct urb_priv *uhci_alloc_urb_priv(struct uhci_hcd *uhci,
 {
        struct urb_priv *urbp;
 
-       urbp = kmem_cache_alloc(uhci_up_cachep, GFP_ATOMIC);
+       urbp = kmem_cache_zalloc(uhci_up_cachep, GFP_ATOMIC);
        if (!urbp)
                return NULL;
 
-       memset((void *)urbp, 0, sizeof(*urbp));
-
        urbp->urb = urb;
        urb->hcpriv = urbp;
        
index a6f0f4d934dfd854f6a72550eb9c3b776bc08229..31e5fe363fdc0d2547309c99a8829375867b18f3 100644 (file)
        (((GL_MAX_PACKET_LEN + 4) * GL_MAX_TRANSMIT_PACKETS) + 4)
 
 struct gl_packet {
-       u32             packet_length;
+       __le32          packet_length;
        char            packet_data [1];
 };
 
 struct gl_header {
-       u32                     packet_count;
+       __le32                  packet_count;
        struct gl_packet        packets;
 };
 
@@ -85,15 +85,14 @@ static int genelink_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
        struct gl_packet        *packet;
        struct sk_buff          *gl_skb;
        u32                     size;
+       u32                     count;
 
        header = (struct gl_header *) skb->data;
 
        // get the packet count of the received skb
-       le32_to_cpus(&header->packet_count);
-       if ((header->packet_count > GL_MAX_TRANSMIT_PACKETS)
-                       || (header->packet_count < 0)) {
-               dbg("genelink: invalid received packet count %d",
-                       header->packet_count);
+       count = le32_to_cpu(header->packet_count);
+       if (count > GL_MAX_TRANSMIT_PACKETS) {
+               dbg("genelink: invalid received packet count %u", count);
                return 0;
        }
 
@@ -103,7 +102,7 @@ static int genelink_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
        // decrement the length for the packet count size 4 bytes
        skb_pull(skb, 4);
 
-       while (header->packet_count > 1) {
+       while (count > 1) {
                // get the packet length
                size = le32_to_cpu(packet->packet_length);
 
@@ -124,9 +123,8 @@ static int genelink_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
                }
 
                // advance to the next packet
-               packet = (struct gl_packet *)
-                       &packet->packet_data [size];
-               header->packet_count--;
+               packet = (struct gl_packet *)&packet->packet_data[size];
+               count--;
 
                // shift the data pointer to the next gl_packet
                skb_pull(skb, size + 4);
@@ -149,8 +147,8 @@ genelink_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
        int     length = skb->len;
        int     headroom = skb_headroom(skb);
        int     tailroom = skb_tailroom(skb);
-       u32     *packet_count;
-       u32     *packet_len;
+       __le32  *packet_count;
+       __le32  *packet_len;
 
        // FIXME:  magic numbers, bleech
        padlen = ((skb->len + (4 + 4*1)) % 64) ? 0 : 1;
@@ -172,7 +170,7 @@ genelink_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
        }
 
        // attach the packet count to the header
-       packet_count = (u32 *) skb_push(skb, (4 + 4*1));
+       packet_count = (__le32 *) skb_push(skb, (4 + 4*1));
        packet_len = packet_count + 1;
 
        *packet_count = cpu_to_le32(1);
index 06b4fffc189cf0c69389ee6176295088139dbdc9..3ec24870bca995edfd1c180ae7f1781c452ada5e 100644 (file)
@@ -170,13 +170,13 @@ static int cp2101_get_config(struct usb_serial_port* port, u8 request,
                unsigned int *data, int size)
 {
        struct usb_serial *serial = port->serial;
-       u32 *buf;
+       __le32 *buf;
        int result, i, length;
 
        /* Number of integers required to contain the array */
        length = (((size - 1) | 3) + 1)/4;
 
-       buf = kcalloc(length, sizeof(u32), GFP_KERNEL);
+       buf = kcalloc(length, sizeof(__le32), GFP_KERNEL);
        if (!buf) {
                dev_err(&port->dev, "%s - out of memory.\n", __FUNCTION__);
                return -ENOMEM;
@@ -216,13 +216,13 @@ static int cp2101_set_config(struct usb_serial_port* port, u8 request,
                unsigned int *data, int size)
 {
        struct usb_serial *serial = port->serial;
-       u32 *buf;
+       __le32 *buf;
        int result, i, length;
 
        /* Number of integers required to contain the array */
        length = (((size - 1) | 3) + 1)/4;
 
-       buf = kmalloc(length * sizeof(u32), GFP_KERNEL);
+       buf = kmalloc(length * sizeof(__le32), GFP_KERNEL);
        if (!buf) {
                dev_err(&port->dev, "%s - out of memory.\n",
                                __FUNCTION__);
index 0b0fb51bad3e597ca0b829a746693a6540cd670b..d78692c01cfa3ca9a75749ee9a3fec6f5e92762f 100644 (file)
@@ -616,15 +616,7 @@ static void digi_wakeup_write_lock(struct work_struct *work)
 
 static void digi_wakeup_write( struct usb_serial_port *port )
 {
-
-       struct tty_struct *tty = port->tty;
-
-
-       /* wake up port processes */
-       wake_up_interruptible( &port->write_wait );
-
-       /* wake up line discipline */
-       tty_wakeup(tty);
+       tty_wakeup(port->tty);
 }
 
 
index da514cb785b3a0bb87c16dfff4423fddad411301..dd0b66a6ed5d00825a93c571d867f31abd61a183 100644 (file)
@@ -182,13 +182,8 @@ static void keyspan_pda_wakeup_write(struct work_struct *work)
        struct keyspan_pda_private *priv =
                container_of(work, struct keyspan_pda_private, wakeup_work);
        struct usb_serial_port *port = priv->port;
-       struct tty_struct *tty = port->tty;
 
-       /* wake up port processes */
-       wake_up_interruptible( &port->write_wait );
-
-       /* wake up line discipline */
-       tty_wakeup(tty);
+       tty_wakeup(port->tty);
 }
 
 static void keyspan_pda_request_unthrottle(struct work_struct *work)
index 6109c6704a738299992d741dc31fd9f94baff433..2d588fb82573f998aa6b899dae13a84fceff4e1b 100644 (file)
@@ -269,18 +269,8 @@ static void mos7720_bulk_out_data_callback(struct urb *urb)
 
        tty = mos7720_port->port->tty;
 
-       if (tty && mos7720_port->open) {
-               /* let the tty driver wakeup if it has a special *
-                * write_wakeup function */
-               if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
-                    tty->ldisc.write_wakeup)
-                       (tty->ldisc.write_wakeup)(tty);
-
-               /* tell the tty driver that something has changed */
-               wake_up_interruptible(&tty->write_wait);
-       }
-
-       /* schedule_work(&mos7720_port->port->work); */
+       if (tty && mos7720_port->open)
+               tty_wakeup(tty);
 }
 
 /*
index b2264a87617bdfdde5587bd3cee5cc2de82edc87..c6cca859af452706ccc4bc756877df4e81af1fc3 100644 (file)
@@ -755,18 +755,8 @@ static void mos7840_bulk_out_data_callback(struct urb *urb)
 
        tty = mos7840_port->port->tty;
 
-       if (tty && mos7840_port->open) {
-               /* let the tty driver wakeup if it has a special *
-                * write_wakeup function                         */
-
-               if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP))
-                   && tty->ldisc.write_wakeup) {
-                       (tty->ldisc.write_wakeup) (tty);
-               }
-
-               /* tell the tty driver that something has changed */
-               wake_up_interruptible(&tty->write_wait);
-       }
+       if (tty && mos7840_port->open)
+               tty_wakeup(tty);
 
 }
 
index 4e83f01e894efe30b9cca2da83b6ff35b007e61b..45fe65d8d7a03d91de405314f052ac377fae2cb5 100644 (file)
@@ -1444,8 +1444,8 @@ config FB_PMAG_AA
          used mainly in the MIPS-based DECstation series.
 
 config FB_PMAG_BA
-       bool "PMAG-BA TURBOchannel framebuffer support"
-       depends on (FB = y) && TC
+       tristate "PMAG-BA TURBOchannel framebuffer support"
+       depends on FB && TC
        select FB_CFB_FILLRECT
        select FB_CFB_COPYAREA
        select FB_CFB_IMAGEBLIT
@@ -1454,8 +1454,8 @@ config FB_PMAG_BA
          used mainly in the MIPS-based DECstation series.
 
 config FB_PMAGB_B
-       bool "PMAGB-B TURBOchannel framebuffer support"
-       depends on (FB = y) && TC
+       tristate "PMAGB-B TURBOchannel framebuffer support"
+       depends on TC
        select FB_CFB_FILLRECT
        select FB_CFB_COPYAREA
        select FB_CFB_IMAGEBLIT
index f5361cd8ccce1359cd706d0e081a873b77235955..264d37243fadfde02a2952839d77cdd53697cb1f 100644 (file)
@@ -15,7 +15,8 @@
  *     Michael Engel <engel@unix-ag.org>,
  *     Karsten Merker <merker@linuxtag.org> and
  *     Harald Koerfgen.
- *     Copyright (c) 2005  Maciej W. Rozycki
+ *     Copyright (c) 2005, 2006  Maciej W. Rozycki
+ *     Copyright (c) 2005  James Simmons
  *
  *     This file is subject to the terms and conditions of the GNU General
  *     Public License.  See the file COPYING in the main directory of this
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/tc.h>
 #include <linux/types.h>
 
 #include <asm/io.h>
 #include <asm/system.h>
 
-#include <asm/dec/tc.h>
-
 #include <video/pmag-ba-fb.h>
 
 
 struct pmagbafb_par {
-       struct fb_info *next;
        volatile void __iomem *mmio;
        volatile u32 __iomem *dac;
-       int slot;
 };
 
 
-static struct fb_info *root_pmagbafb_dev;
-
 static struct fb_var_screeninfo pmagbafb_defined __initdata = {
        .xres           = 1024,
        .yres           = 864,
@@ -145,24 +141,19 @@ static void __init pmagbafb_erase_cursor(struct fb_info *info)
 }
 
 
-static int __init pmagbafb_init_one(int slot)
+static int __init pmagbafb_probe(struct device *dev)
 {
+       struct tc_dev *tdev = to_tc_dev(dev);
+       resource_size_t start, len;
        struct fb_info *info;
        struct pmagbafb_par *par;
-       unsigned long base_addr;
 
-       info = framebuffer_alloc(sizeof(struct pmagbafb_par), NULL);
+       info = framebuffer_alloc(sizeof(struct pmagbafb_par), dev);
        if (!info)
                return -ENOMEM;
 
        par = info->par;
-       par->slot = slot;
-       claim_tc_card(par->slot);
-
-       base_addr = get_tc_base_addr(par->slot);
-
-       par->next = root_pmagbafb_dev;
-       root_pmagbafb_dev = info;
+       dev_set_drvdata(dev, info);
 
        if (fb_alloc_cmap(&info->cmap, 256, 0) < 0)
                goto err_alloc;
@@ -172,15 +163,21 @@ static int __init pmagbafb_init_one(int slot)
        info->var = pmagbafb_defined;
        info->flags = FBINFO_DEFAULT;
 
+       /* Request the I/O MEM resource.  */
+       start = tdev->resource.start;
+       len = tdev->resource.end - start + 1;
+       if (!request_mem_region(start, len, dev->bus_id))
+               goto err_cmap;
+
        /* MMIO mapping setup.  */
-       info->fix.mmio_start = base_addr;
+       info->fix.mmio_start = start;
        par->mmio = ioremap_nocache(info->fix.mmio_start, info->fix.mmio_len);
        if (!par->mmio)
-               goto err_cmap;
+               goto err_resource;
        par->dac = par->mmio + PMAG_BA_BT459;
 
        /* Frame buffer mapping setup.  */
-       info->fix.smem_start = base_addr + PMAG_BA_FBMEM;
+       info->fix.smem_start = start + PMAG_BA_FBMEM;
        info->screen_base = ioremap_nocache(info->fix.smem_start,
                                            info->fix.smem_len);
        if (!info->screen_base)
@@ -192,8 +189,10 @@ static int __init pmagbafb_init_one(int slot)
        if (register_framebuffer(info) < 0)
                goto err_smem_map;
 
-       pr_info("fb%d: %s frame buffer device in slot %d\n",
-               info->node, info->fix.id, par->slot);
+       get_device(dev);
+
+       pr_info("fb%d: %s frame buffer device at %s\n",
+               info->node, info->fix.id, dev->bus_id);
 
        return 0;
 
@@ -204,54 +203,68 @@ err_smem_map:
 err_mmio_map:
        iounmap(par->mmio);
 
+err_resource:
+       release_mem_region(start, len);
+
 err_cmap:
        fb_dealloc_cmap(&info->cmap);
 
 err_alloc:
-       root_pmagbafb_dev = par->next;
-       release_tc_card(par->slot);
        framebuffer_release(info);
        return -ENXIO;
 }
 
-static void __exit pmagbafb_exit_one(void)
+static int __exit pmagbafb_remove(struct device *dev)
 {
-       struct fb_info *info = root_pmagbafb_dev;
+       struct tc_dev *tdev = to_tc_dev(dev);
+       struct fb_info *info = dev_get_drvdata(dev);
        struct pmagbafb_par *par = info->par;
+       resource_size_t start, len;
 
+       put_device(dev);
        unregister_framebuffer(info);
        iounmap(info->screen_base);
        iounmap(par->mmio);
+       start = tdev->resource.start;
+       len = tdev->resource.end - start + 1;
+       release_mem_region(start, len);
        fb_dealloc_cmap(&info->cmap);
-       root_pmagbafb_dev = par->next;
-       release_tc_card(par->slot);
        framebuffer_release(info);
+       return 0;
 }
 
 
 /*
- * Initialise the framebuffer.
+ * Initialize the framebuffer.
  */
+static const struct tc_device_id pmagbafb_tc_table[] = {
+       { "DEC     ", "PMAG-BA " },
+       { }
+};
+MODULE_DEVICE_TABLE(tc, pmagbafb_tc_table);
+
+static struct tc_driver pmagbafb_driver = {
+       .id_table       = pmagbafb_tc_table,
+       .driver         = {
+               .name   = "pmagbafb",
+               .bus    = &tc_bus_type,
+               .probe  = pmagbafb_probe,
+               .remove = __exit_p(pmagbafb_remove),
+       },
+};
+
 static int __init pmagbafb_init(void)
 {
-       int count = 0;
-       int slot;
-
+#ifndef MODULE
        if (fb_get_options("pmagbafb", NULL))
                return -ENXIO;
-
-       while ((slot = search_tc_card("PMAG-BA")) >= 0) {
-               if (pmagbafb_init_one(slot) < 0)
-                       break;
-               count++;
-       }
-       return (count > 0) ? 0 : -ENXIO;
+#endif
+       return tc_register_driver(&pmagbafb_driver);
 }
 
 static void __exit pmagbafb_exit(void)
 {
-       while (root_pmagbafb_dev)
-               pmagbafb_exit_one();
+       tc_unregister_driver(&pmagbafb_driver);
 }
 
 
index a06a064ad7575bf6cd9e0126d9f8312f95689d79..7a0ce7d5af6bf2c150d1d12cbe8760d5ba19e9be 100644 (file)
@@ -11,7 +11,7 @@
  *     Michael Engel <engel@unix-ag.org>,
  *     Karsten Merker <merker@linuxtag.org> and
  *     Harald Koerfgen.
- *     Copyright (c) 2005  Maciej W. Rozycki
+ *     Copyright (c) 2005, 2006  Maciej W. Rozycki
  *
  *     This file is subject to the terms and conditions of the GNU General
  *     Public License.  See the file COPYING in the main directory of this
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/tc.h>
 #include <linux/types.h>
 
 #include <asm/io.h>
 #include <asm/system.h>
 
-#include <asm/dec/tc.h>
-
 #include <video/pmagb-b-fb.h>
 
 
 struct pmagbbfb_par {
-       struct fb_info *next;
        volatile void __iomem *mmio;
        volatile void __iomem *smem;
        volatile u32 __iomem *sfb;
@@ -47,8 +45,6 @@ struct pmagbbfb_par {
 };
 
 
-static struct fb_info *root_pmagbbfb_dev;
-
 static struct fb_var_screeninfo pmagbbfb_defined __initdata = {
        .bits_per_pixel = 8,
        .red.length     = 8,
@@ -190,8 +186,9 @@ static void __init pmagbbfb_osc_setup(struct fb_info *info)
                69197, 66000, 65000, 50350, 36000, 32000, 25175
        };
        struct pmagbbfb_par *par = info->par;
+       struct tc_bus *tbus = to_tc_dev(info->device)->bus;
        u32 count0 = 8, count1 = 8, counttc = 16 * 256 + 8;
-       u32 freq0, freq1, freqtc = get_tc_speed() / 250;
+       u32 freq0, freq1, freqtc = tc_get_speed(tbus) / 250;
        int i, j;
 
        gp0_write(par, 0);                              /* select Osc0 */
@@ -249,26 +246,21 @@ static void __init pmagbbfb_osc_setup(struct fb_info *info)
 };
 
 
-static int __init pmagbbfb_init_one(int slot)
+static int __init pmagbbfb_probe(struct device *dev)
 {
-       char freq0[12], freq1[12];
+       struct tc_dev *tdev = to_tc_dev(dev);
+       resource_size_t start, len;
        struct fb_info *info;
        struct pmagbbfb_par *par;
-       unsigned long base_addr;
+       char freq0[12], freq1[12];
        u32 vid_base;
 
-       info = framebuffer_alloc(sizeof(struct pmagbbfb_par), NULL);
+       info = framebuffer_alloc(sizeof(struct pmagbbfb_par), dev);
        if (!info)
                return -ENOMEM;
 
        par = info->par;
-       par->slot = slot;
-       claim_tc_card(par->slot);
-
-       base_addr = get_tc_base_addr(par->slot);
-
-       par->next = root_pmagbbfb_dev;
-       root_pmagbbfb_dev = info;
+       dev_set_drvdata(dev, info);
 
        if (fb_alloc_cmap(&info->cmap, 256, 0) < 0)
                goto err_alloc;
@@ -278,16 +270,22 @@ static int __init pmagbbfb_init_one(int slot)
        info->var = pmagbbfb_defined;
        info->flags = FBINFO_DEFAULT;
 
+       /* Request the I/O MEM resource.  */
+       start = tdev->resource.start;
+       len = tdev->resource.end - start + 1;
+       if (!request_mem_region(start, len, dev->bus_id))
+               goto err_cmap;
+
        /* MMIO mapping setup.  */
-       info->fix.mmio_start = base_addr;
+       info->fix.mmio_start = start;
        par->mmio = ioremap_nocache(info->fix.mmio_start, info->fix.mmio_len);
        if (!par->mmio)
-               goto err_cmap;
+               goto err_resource;
        par->sfb = par->mmio + PMAGB_B_SFB;
        par->dac = par->mmio + PMAGB_B_BT459;
 
        /* Frame buffer mapping setup.  */
-       info->fix.smem_start = base_addr + PMAGB_B_FBMEM;
+       info->fix.smem_start = start + PMAGB_B_FBMEM;
        par->smem = ioremap_nocache(info->fix.smem_start, info->fix.smem_len);
        if (!par->smem)
                goto err_mmio_map;
@@ -302,13 +300,15 @@ static int __init pmagbbfb_init_one(int slot)
        if (register_framebuffer(info) < 0)
                goto err_smem_map;
 
+       get_device(dev);
+
        snprintf(freq0, sizeof(freq0), "%u.%03uMHz",
                 par->osc0 / 1000, par->osc0 % 1000);
        snprintf(freq1, sizeof(freq1), "%u.%03uMHz",
                 par->osc1 / 1000, par->osc1 % 1000);
 
-       pr_info("fb%d: %s frame buffer device in slot %d\n",
-               info->node, info->fix.id, par->slot);
+       pr_info("fb%d: %s frame buffer device at %s\n",
+               info->node, info->fix.id, dev->bus_id);
        pr_info("fb%d: Osc0: %s, Osc1: %s, Osc%u selected\n",
                info->node, freq0, par->osc1 ? freq1 : "disabled",
                par->osc1 != 0);
@@ -322,54 +322,68 @@ err_smem_map:
 err_mmio_map:
        iounmap(par->mmio);
 
+err_resource:
+       release_mem_region(start, len);
+
 err_cmap:
        fb_dealloc_cmap(&info->cmap);
 
 err_alloc:
-       root_pmagbbfb_dev = par->next;
-       release_tc_card(par->slot);
        framebuffer_release(info);
        return -ENXIO;
 }
 
-static void __exit pmagbbfb_exit_one(void)
+static int __exit pmagbbfb_remove(struct device *dev)
 {
-       struct fb_info *info = root_pmagbbfb_dev;
+       struct tc_dev *tdev = to_tc_dev(dev);
+       struct fb_info *info = dev_get_drvdata(dev);
        struct pmagbbfb_par *par = info->par;
+       resource_size_t start, len;
 
+       put_device(dev);
        unregister_framebuffer(info);
        iounmap(par->smem);
        iounmap(par->mmio);
+       start = tdev->resource.start;
+       len = tdev->resource.end - start + 1;
+       release_mem_region(start, len);
        fb_dealloc_cmap(&info->cmap);
-       root_pmagbbfb_dev = par->next;
-       release_tc_card(par->slot);
        framebuffer_release(info);
+       return 0;
 }
 
 
 /*
- * Initialise the framebuffer.
+ * Initialize the framebuffer.
  */
+static const struct tc_device_id pmagbbfb_tc_table[] = {
+       { "DEC     ", "PMAGB-BA" },
+       { }
+};
+MODULE_DEVICE_TABLE(tc, pmagbbfb_tc_table);
+
+static struct tc_driver pmagbbfb_driver = {
+       .id_table       = pmagbbfb_tc_table,
+       .driver         = {
+               .name   = "pmagbbfb",
+               .bus    = &tc_bus_type,
+               .probe  = pmagbbfb_probe,
+               .remove = __exit_p(pmagbbfb_remove),
+       },
+};
+
 static int __init pmagbbfb_init(void)
 {
-       int count = 0;
-       int slot;
-
+#ifndef MODULE
        if (fb_get_options("pmagbbfb", NULL))
                return -ENXIO;
-
-       while ((slot = search_tc_card("PMAGB-BA")) >= 0) {
-               if (pmagbbfb_init_one(slot) < 0)
-                       break;
-               count++;
-       }
-       return (count > 0) ? 0 : -ENXIO;
+#endif
+       return tc_register_driver(&pmagbbfb_driver);
 }
 
 static void __exit pmagbbfb_exit(void)
 {
-       while (root_pmagbbfb_dev)
-               pmagbbfb_exit_one();
+       tc_unregister_driver(&pmagbbfb_driver);
 }
 
 
index 0b07f6ae3367c286611695c9c7950c9afd2f0d56..48066ef3af05fa2356171a76932e8252b62b05e5 100644 (file)
@@ -110,9 +110,7 @@ struct sa1100fb_info {
 #endif
 };
 
-#define __type_entry(ptr,type,member) ((type *)((char *)(ptr)-offsetof(type,member)))
-
-#define TO_INF(ptr,member)     __type_entry(ptr,struct sa1100fb_info,member)
+#define TO_INF(ptr,member)     container_of(ptr,struct sa1100fb_info,member)
 
 #define SA1100_PALETTE_MODE_VAL(bpp)    (((bpp) & 0x018) << 9)
 
index 9f17b0cacdd02e42cf5e3c658a99e62f0738f120..6c78343cf69023e5220c6a50127b33325c0f1c97 100644 (file)
@@ -110,7 +110,7 @@ static int v9fs_file_lock(struct file *filp, int cmd, struct file_lock *fl)
 
        if ((IS_SETLK(cmd) || IS_SETLKW(cmd)) && fl->fl_type != F_UNLCK) {
                filemap_write_and_wait(inode->i_mapping);
-               invalidate_inode_pages(&inode->i_data);
+               invalidate_mapping_pages(&inode->i_data, 0, -1);
        }
 
        return res;
@@ -234,7 +234,7 @@ v9fs_file_write(struct file *filp, const char __user * data,
                total += result;
        } while (count);
 
-               invalidate_inode_pages2(inode->i_mapping);
+       invalidate_inode_pages2(inode->i_mapping);
        return total;
 }
 
index 9109ba1d6969e33ee180a9c4cec5bcd2339ca9f1..378767c07bf11f746d1387e11dcebc087912adbd 100644 (file)
@@ -585,17 +585,14 @@ static int v9fs_vfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
        if (IS_ERR(inode)) {
                err = PTR_ERR(inode);
                inode = NULL;
-               goto clean_up_fids;
+               v9fs_fid_destroy(vfid);
+               goto error;
        }
 
        dentry->d_op = &v9fs_dentry_operations;
        d_instantiate(dentry, inode);
        return 0;
 
-clean_up_fids:
-       if (vfid)
-               v9fs_fid_destroy(vfid);
-
 clean_up_dfid:
        v9fs_fid_clunk(v9ses, dfid);
 
index 5e8e9d9ccb331ffe1a88c32f402a70eefca4ad18..11c59329ed0647837604dbd0a832dd2935db226b 100644 (file)
@@ -674,12 +674,6 @@ config ZISOFS
          necessary to create such a filesystem.  Say Y here if you want to be
          able to read such compressed CD-ROMs.
 
-config ZISOFS_FS
-# for fs/nls/Config.in
-       tristate
-       depends on ZISOFS
-       default ISO9660_FS
-
 config UDF_FS
        tristate "UDF file system support"
        help
index 55991e4132a7f30f778a7f86862b8992c59bafca..0b4ee0a5c83e809f07ca6a0a049e9521226782c0 100644 (file)
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -132,7 +132,7 @@ static int aio_setup_ring(struct kioctx *ctx)
        dprintk("attempting mmap of %lu bytes\n", info->mmap_size);
        down_write(&ctx->mm->mmap_sem);
        info->mmap_base = do_mmap(NULL, 0, info->mmap_size, 
-                                 PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE,
+                                 PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE,
                                  0);
        if (IS_ERR((void *)info->mmap_base)) {
                up_write(&ctx->mm->mmap_sem);
@@ -211,11 +211,10 @@ static struct kioctx *ioctx_alloc(unsigned nr_events)
        if ((unsigned long)nr_events > aio_max_nr)
                return ERR_PTR(-EAGAIN);
 
-       ctx = kmem_cache_alloc(kioctx_cachep, GFP_KERNEL);
+       ctx = kmem_cache_zalloc(kioctx_cachep, GFP_KERNEL);
        if (!ctx)
                return ERR_PTR(-ENOMEM);
 
-       memset(ctx, 0, sizeof(*ctx));
        ctx->max_reqs = nr_events;
        mm = ctx->mm = current->mm;
        atomic_inc(&mm->mm_count);
index a4d933a51208c5bcbfdd182b2412c3b1d369c140..5810aa1339fdeb5d6d98dd857328998bcde733e5 100644 (file)
@@ -372,7 +372,7 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm,
        down_write(&current->mm->mmap_sem);
        current->mm->start_brk = do_mmap(NULL, 0, stack_size,
                                         PROT_READ | PROT_WRITE | PROT_EXEC,
-                                        MAP_PRIVATE | MAP_ANON | MAP_GROWSDOWN,
+                                        MAP_PRIVATE | MAP_ANONYMOUS | MAP_GROWSDOWN,
                                         0);
 
        if (IS_ERR_VALUE(current->mm->start_brk)) {
index ae8595d498569a72c6be2f4ce45d956326d33a9a..7b0265d7f3a84a88f537b8e9174a27e4c3e650b6 100644 (file)
@@ -419,7 +419,7 @@ static int load_flat_file(struct linux_binprm * bprm,
        unsigned long textpos = 0, datapos = 0, result;
        unsigned long realdatastart = 0;
        unsigned long text_len, data_len, bss_len, stack_len, flags;
-       unsigned long memp = 0; /* for finding the brk area */
+       unsigned long len, reallen, memp = 0;
        unsigned long extra, rlim;
        unsigned long *reloc = 0, *rp;
        struct inode *inode;
@@ -540,10 +540,18 @@ static int load_flat_file(struct linux_binprm * bprm,
                        goto err;
                }
 
+               len = data_len + extra + MAX_SHARED_LIBS * sizeof(unsigned long);
                down_write(&current->mm->mmap_sem);
-               realdatastart = do_mmap(0, 0, data_len + extra +
-                               MAX_SHARED_LIBS * sizeof(unsigned long),
-                               PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE, 0);
+               realdatastart = do_mmap(0, 0, len,
+                       PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE, 0);
+               /* Remap to use all availabe slack region space */
+               if (realdatastart && (realdatastart < (unsigned long)-4096)) {
+                       reallen = ksize(realdatastart);
+                       if (reallen > len) {
+                               realdatastart = do_mremap(realdatastart, len,
+                                       reallen, MREMAP_FIXED, realdatastart);
+                       }
+               }
                up_write(&current->mm->mmap_sem);
 
                if (realdatastart == 0 || realdatastart >= (unsigned long)-4096) {
@@ -584,11 +592,20 @@ static int load_flat_file(struct linux_binprm * bprm,
 
        } else {
 
+               len = text_len + data_len + extra + MAX_SHARED_LIBS * sizeof(unsigned long);
                down_write(&current->mm->mmap_sem);
-               textpos = do_mmap(0, 0, text_len + data_len + extra +
-                                       MAX_SHARED_LIBS * sizeof(unsigned long),
-                               PROT_READ | PROT_EXEC | PROT_WRITE, MAP_PRIVATE, 0);
+               textpos = do_mmap(0, 0, len,
+                       PROT_READ | PROT_EXEC | PROT_WRITE, MAP_PRIVATE, 0);
+               /* Remap to use all availabe slack region space */
+               if (textpos && (textpos < (unsigned long) -4096)) {
+                       reallen = ksize(textpos);
+                       if (reallen > len) {
+                               textpos = do_mremap(textpos, len, reallen,
+                                       MREMAP_FIXED, textpos);
+                       }
+               }
                up_write(&current->mm->mmap_sem);
+
                if (!textpos  || textpos >= (unsigned long) -4096) {
                        if (!textpos)
                                textpos = (unsigned long) -ENOMEM;
index 1ad674fd348c4bfe6f130bc9a958a3c38338619c..7ff6e9346faed9f149948b8756934afbf79b9af6 100644 (file)
@@ -78,6 +78,7 @@ EXPORT_SYMBOL(__lock_buffer);
 
 void fastcall unlock_buffer(struct buffer_head *bh)
 {
+       smp_mb__before_clear_bit();
        clear_buffer_locked(bh);
        smp_mb__after_clear_bit();
        wake_up_bit(&bh->b_state, BH_Lock);
@@ -345,7 +346,7 @@ void invalidate_bdev(struct block_device *bdev, int destroy_dirty_buffers)
         * We really want to use invalidate_inode_pages2() for
         * that, but not until that's cleaned up.
         */
-       invalidate_inode_pages(mapping);
+       invalidate_mapping_pages(mapping, 0, -1);
 }
 
 /*
index 1c82e9a7d7c8a799698e404e1b50b31031ac3021..db3b1a9c9a5b9d7ea36075a0d5e1d9df320ebb00 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/mm.h>
 #include <linux/sysctl.h>
 #include <linux/proc_fs.h>
+#include <linux/seq_file.h>
 #include <linux/slab.h>
 #include <linux/stat.h>
 #include <linux/ctype.h>
@@ -84,15 +85,11 @@ static int do_reset_coda_cache_inv_stats( ctl_table * table, int write,
        return 0;
 }
 
-static int coda_vfs_stats_get_info( char * buffer, char ** start,
-                                   off_t offset, int length)
+static int proc_vfs_stats_show(struct seq_file *m, void *v)
 {
-       int len=0;
-       off_t begin;
        struct coda_vfs_stats * ps = & coda_vfs_stat;
   
-  /* this works as long as we are below 1024 characters! */
-       len += sprintf( buffer,
+       seq_printf(m,
                        "Coda VFS statistics\n"
                        "===================\n\n"
                        "File Operations:\n"
@@ -132,28 +129,14 @@ static int coda_vfs_stats_get_info( char * buffer, char ** start,
                        ps->rmdir,
                        ps->rename,
                        ps->permission); 
-
-       begin = offset;
-       *start = buffer + begin;
-       len -= begin;
-
-       if ( len > length )
-               len = length;
-       if ( len < 0 )
-               len = 0;
-
-       return len;
+       return 0;
 }
 
-static int coda_cache_inv_stats_get_info( char * buffer, char ** start,
-                                         off_t offset, int length)
+static int proc_cache_inv_stats_show(struct seq_file *m, void *v)
 {
-       int len=0;
-       off_t begin;
        struct coda_cache_inv_stats * ps = & coda_cache_inv_stat;
   
-       /* this works as long as we are below 1024 characters! */
-       len += sprintf( buffer,
+       seq_printf(m,
                        "Coda cache invalidation statistics\n"
                        "==================================\n\n"
                        "flush\t\t%9d\n"
@@ -170,19 +153,35 @@ static int coda_cache_inv_stats_get_info( char * buffer, char ** start,
                        ps->zap_vnode,
                        ps->purge_fid,
                        ps->replace );
-  
-       begin = offset;
-       *start = buffer + begin;
-       len -= begin;
+       return 0;
+}
 
-       if ( len > length )
-               len = length;
-       if ( len < 0 )
-               len = 0;
+static int proc_vfs_stats_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, proc_vfs_stats_show, NULL);
+}
 
-       return len;
+static int proc_cache_inv_stats_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, proc_cache_inv_stats_show, NULL);
 }
 
+static const struct file_operations proc_vfs_stats_fops = {
+       .owner          = THIS_MODULE,
+       .open           = proc_vfs_stats_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
+
+static const struct file_operations proc_cache_inv_stats_fops = {
+       .owner          = THIS_MODULE,
+       .open           = proc_cache_inv_stats_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
+
 static ctl_table coda_table[] = {
        {CODA_TIMEOUT, "timeout", &coda_timeout, sizeof(int), 0644, NULL, &proc_dointvec},
        {CODA_HARD, "hard", &coda_hard, sizeof(int), 0644, NULL, &proc_dointvec},
@@ -212,9 +211,6 @@ static struct proc_dir_entry* proc_fs_coda;
 
 #endif
 
-#define coda_proc_create(name,get_info) \
-       create_proc_info_entry(name, 0, proc_fs_coda, get_info)
-
 void coda_sysctl_init(void)
 {
        reset_coda_vfs_stats();
@@ -223,9 +219,15 @@ void coda_sysctl_init(void)
 #ifdef CONFIG_PROC_FS
        proc_fs_coda = proc_mkdir("coda", proc_root_fs);
        if (proc_fs_coda) {
+               struct proc_dir_entry *pde;
+
                proc_fs_coda->owner = THIS_MODULE;
-               coda_proc_create("vfs_stats", coda_vfs_stats_get_info);
-               coda_proc_create("cache_inv_stats", coda_cache_inv_stats_get_info);
+               pde = create_proc_entry("vfs_stats", 0, proc_fs_coda);
+               if (pde)
+                       pde->proc_fops = &proc_vfs_stats_fops;
+               pde = create_proc_entry("cache_inv_stats", 0, proc_fs_coda);
+               if (pde)
+                       pde->proc_fops = &proc_cache_inv_stats_fops;
        }
 #endif
 
index 1814ba446809ac79ea6ab911a60ac42d1e36d33d..9371ee20995405ca32a9c36cf6b418412b64f0ce 100644 (file)
@@ -72,11 +72,10 @@ static struct configfs_dirent *configfs_new_dirent(struct configfs_dirent * pare
 {
        struct configfs_dirent * sd;
 
-       sd = kmem_cache_alloc(configfs_dir_cachep, GFP_KERNEL);
+       sd = kmem_cache_zalloc(configfs_dir_cachep, GFP_KERNEL);
        if (!sd)
                return NULL;
 
-       memset(sd, 0, sizeof(*sd));
        atomic_set(&sd->s_count, 1);
        INIT_LIST_HEAD(&sd->s_links);
        INIT_LIST_HEAD(&sd->s_children);
index f1efd17b2614b28cc0be7aff2e5f1fff8f65463f..07e0a122c32fcafe29546a2c02dabbcb93a019c9 100644 (file)
@@ -268,12 +268,12 @@ static void close_connection(struct connection *con, bool and_other)
 static int receive_from_sock(struct connection *con)
 {
        int ret = 0;
-       struct msghdr msg;
-       struct iovec iov[2];
-       mm_segment_t fs;
+       struct msghdr msg = {};
+       struct kvec iov[2];
        unsigned len;
        int r;
        int call_again_soon = 0;
+       int nvec;
 
        mutex_lock(&con->sock_mutex);
 
@@ -293,21 +293,13 @@ static int receive_from_sock(struct connection *con)
                cbuf_init(&con->cb, PAGE_CACHE_SIZE);
        }
 
-       msg.msg_control = NULL;
-       msg.msg_controllen = 0;
-       msg.msg_iovlen = 1;
-       msg.msg_iov = iov;
-       msg.msg_name = NULL;
-       msg.msg_namelen = 0;
-       msg.msg_flags = 0;
-
        /*
         * iov[0] is the bit of the circular buffer between the current end
         * point (cb.base + cb.len) and the end of the buffer.
         */
        iov[0].iov_len = con->cb.base - cbuf_data(&con->cb);
        iov[0].iov_base = page_address(con->rx_page) + cbuf_data(&con->cb);
-       iov[1].iov_len = 0;
+       nvec = 1;
 
        /*
         * iov[1] is the bit of the circular buffer between the start of the
@@ -317,15 +309,12 @@ static int receive_from_sock(struct connection *con)
                iov[0].iov_len = PAGE_CACHE_SIZE - cbuf_data(&con->cb);
                iov[1].iov_len = con->cb.base;
                iov[1].iov_base = page_address(con->rx_page);
-               msg.msg_iovlen = 2;
+               nvec = 2;
        }
        len = iov[0].iov_len + iov[1].iov_len;
 
-       fs = get_fs();
-       set_fs(get_ds());
-       r = ret = sock_recvmsg(con->sock, &msg, len,
+       r = ret = kernel_recvmsg(con->sock, &msg, iov, nvec, len,
                               MSG_DONTWAIT | MSG_NOSIGNAL);
-       set_fs(fs);
 
        if (ret <= 0)
                goto out_close;
index 5352b03ff5aa81f9af31c081965f7ae8dd81f90e..f858fef6e41cf32167b3b5d6634458fc62e8d1e7 100644 (file)
@@ -76,9 +76,7 @@ struct dlm_lkb *allocate_lkb(struct dlm_ls *ls)
 {
        struct dlm_lkb *lkb;
 
-       lkb = kmem_cache_alloc(lkb_cache, GFP_KERNEL);
-       if (lkb)
-               memset(lkb, 0, sizeof(*lkb));
+       lkb = kmem_cache_zalloc(lkb_cache, GFP_KERNEL);
        return lkb;
 }
 
index 0952cc474d9a57e08b495315200a73d9c93889e7..a561fb29e2037e9f238b269404b14da50fc087bd 100644 (file)
@@ -600,11 +600,10 @@ static struct dquot *get_empty_dquot(struct super_block *sb, int type)
 {
        struct dquot *dquot;
 
-       dquot = kmem_cache_alloc(dquot_cachep, GFP_NOFS);
+       dquot = kmem_cache_zalloc(dquot_cachep, GFP_NOFS);
        if(!dquot)
                return NODQUOT;
 
-       memset((caddr_t)dquot, 0, sizeof(struct dquot));
        mutex_init(&dquot->dq_lock);
        INIT_LIST_HEAD(&dquot->dq_free);
        INIT_LIST_HEAD(&dquot->dq_inuse);
index 4e4762389bdc560d993dfb42b3db9b664396e77f..03ea7696fe39435183b1b7a32770857fd39915c3 100644 (file)
@@ -20,7 +20,7 @@ static void drop_pagecache_sb(struct super_block *sb)
        list_for_each_entry(inode, &sb->s_inodes, i_sb_list) {
                if (inode->i_state & (I_FREEING|I_WILL_FREE))
                        continue;
-               invalidate_inode_pages(inode->i_mapping);
+               invalidate_mapping_pages(inode->i_mapping, 0, -1);
        }
        spin_unlock(&inode_lock);
 }
index 7196f50fe152f630f8d5b839fdfa32e3d2c4a5fd..75bbfae5508124d024215937bedd877b27b3ee28 100644 (file)
@@ -828,9 +828,7 @@ int ecryptfs_init_crypt_ctx(struct ecryptfs_crypt_stat *crypt_stat)
                mutex_unlock(&crypt_stat->cs_tfm_mutex);
                goto out;
        }
-       crypto_blkcipher_set_flags(crypt_stat->tfm,
-                                  (ECRYPTFS_DEFAULT_CHAINING_MODE
-                                   | CRYPTO_TFM_REQ_WEAK_KEY));
+       crypto_blkcipher_set_flags(crypt_stat->tfm, CRYPTO_TFM_REQ_WEAK_KEY);
        mutex_unlock(&crypt_stat->cs_tfm_mutex);
        rc = 0;
 out:
@@ -1334,13 +1332,13 @@ int ecryptfs_write_headers(struct dentry *ecryptfs_dentry,
                goto out;
        }
        /* Released in this function */
-       page_virt = kmem_cache_alloc(ecryptfs_header_cache_0, GFP_USER);
+       page_virt = kmem_cache_zalloc(ecryptfs_header_cache_0, GFP_USER);
        if (!page_virt) {
                ecryptfs_printk(KERN_ERR, "Out of memory\n");
                rc = -ENOMEM;
                goto out;
        }
-       memset(page_virt, 0, PAGE_CACHE_SIZE);
+
        rc = ecryptfs_write_headers_virt(page_virt, crypt_stat,
                                         ecryptfs_dentry);
        if (unlikely(rc)) {
index afb64bdbe6ad85d8faa5079f16c2c97cc098acba..0f897109759baa627ed07c087658e0185672de29 100644 (file)
@@ -176,7 +176,6 @@ ecryptfs_get_key_payload_data(struct key *key)
 #define ECRYPTFS_FILE_SIZE_BYTES 8
 #define ECRYPTFS_DEFAULT_CIPHER "aes"
 #define ECRYPTFS_DEFAULT_KEY_BYTES 16
-#define ECRYPTFS_DEFAULT_CHAINING_MODE CRYPTO_TFM_MODE_CBC
 #define ECRYPTFS_DEFAULT_HASH "md5"
 #define ECRYPTFS_TAG_3_PACKET_TYPE 0x8C
 #define ECRYPTFS_TAG_11_PACKET_TYPE 0xED
index c5a2e5298f155c0744f653ba8bbc6018f03179ed..779c3477d93c20f7020e3f93f94a4f57838569d7 100644 (file)
@@ -251,7 +251,7 @@ static int ecryptfs_open(struct inode *inode, struct file *file)
        int lower_flags;
 
        /* Released in ecryptfs_release or end of function if failure */
-       file_info = kmem_cache_alloc(ecryptfs_file_info_cache, GFP_KERNEL);
+       file_info = kmem_cache_zalloc(ecryptfs_file_info_cache, GFP_KERNEL);
        ecryptfs_set_file_private(file, file_info);
        if (!file_info) {
                ecryptfs_printk(KERN_ERR,
@@ -259,7 +259,6 @@ static int ecryptfs_open(struct inode *inode, struct file *file)
                rc = -ENOMEM;
                goto out;
        }
-       memset(file_info, 0, sizeof(*file_info));
        lower_dentry = ecryptfs_dentry_to_lower(ecryptfs_dentry);
        crypt_stat = &ecryptfs_inode_to_private(inode)->crypt_stat;
        mount_crypt_stat = &ecryptfs_superblock_to_private(
index 11f5e5076aefdfc28ab40359b0fee3cca291e871..d4f02f3e18d799ba3992a59a1fd4646cc6d41074 100644 (file)
@@ -361,8 +361,7 @@ static struct dentry *ecryptfs_lookup(struct inode *dir, struct dentry *dentry,
                goto out;
        }
        /* Released in this function */
-       page_virt =
-           (char *)kmem_cache_alloc(ecryptfs_header_cache_2,
+       page_virt = kmem_cache_zalloc(ecryptfs_header_cache_2,
                                     GFP_USER);
        if (!page_virt) {
                rc = -ENOMEM;
@@ -370,7 +369,7 @@ static struct dentry *ecryptfs_lookup(struct inode *dir, struct dentry *dentry,
                                "Cannot ecryptfs_kmalloc a page\n");
                goto out_dput;
        }
-       memset(page_virt, 0, PAGE_CACHE_SIZE);
+
        rc = ecryptfs_read_header_region(page_virt, lower_dentry, nd->mnt);
        crypt_stat = &ecryptfs_inode_to_private(dentry->d_inode)->crypt_stat;
        if (!ECRYPTFS_CHECK_FLAG(crypt_stat->flags, ECRYPTFS_POLICY_APPLIED))
index 745c0f1bfbbdcbd1a2bd4ff2db8848bc572df1fe..80bccd5ff8e6671908b528e408aa9427b2c7fbf4 100644 (file)
@@ -207,14 +207,12 @@ parse_tag_3_packet(struct ecryptfs_crypt_stat *crypt_stat,
        /* Released: wipe_auth_tok_list called in ecryptfs_parse_packet_set or
         * at end of function upon failure */
        auth_tok_list_item =
-           kmem_cache_alloc(ecryptfs_auth_tok_list_item_cache, GFP_KERNEL);
+           kmem_cache_zalloc(ecryptfs_auth_tok_list_item_cache, GFP_KERNEL);
        if (!auth_tok_list_item) {
                ecryptfs_printk(KERN_ERR, "Unable to allocate memory\n");
                rc = -ENOMEM;
                goto out;
        }
-       memset(auth_tok_list_item, 0,
-              sizeof(struct ecryptfs_auth_tok_list_item));
        (*new_auth_tok) = &auth_tok_list_item->auth_tok;
 
        /* check for body size - one to two bytes */
index d0541ae8faba9f4df3c6420aba382a5a497baf51..fe41ab1566eec58365deda7916d5f5469de014c9 100644 (file)
@@ -378,15 +378,13 @@ ecryptfs_fill_super(struct super_block *sb, void *raw_data, int silent)
 
        /* Released in ecryptfs_put_super() */
        ecryptfs_set_superblock_private(sb,
-                                       kmem_cache_alloc(ecryptfs_sb_info_cache,
+                                       kmem_cache_zalloc(ecryptfs_sb_info_cache,
                                                         GFP_KERNEL));
        if (!ecryptfs_superblock_to_private(sb)) {
                ecryptfs_printk(KERN_WARNING, "Out of memory\n");
                rc = -ENOMEM;
                goto out;
        }
-       memset(ecryptfs_superblock_to_private(sb), 0,
-              sizeof(struct ecryptfs_sb_info));
        sb->s_op = &ecryptfs_sops;
        /* Released through deactivate_super(sb) from get_sb_nodev */
        sb->s_root = d_alloc(NULL, &(const struct qstr) {
@@ -402,7 +400,7 @@ ecryptfs_fill_super(struct super_block *sb, void *raw_data, int silent)
        /* Released in d_release when dput(sb->s_root) is called */
        /* through deactivate_super(sb) from get_sb_nodev() */
        ecryptfs_set_dentry_private(sb->s_root,
-                                   kmem_cache_alloc(ecryptfs_dentry_info_cache,
+                                   kmem_cache_zalloc(ecryptfs_dentry_info_cache,
                                                     GFP_KERNEL));
        if (!ecryptfs_dentry_to_private(sb->s_root)) {
                ecryptfs_printk(KERN_ERR,
@@ -410,8 +408,6 @@ ecryptfs_fill_super(struct super_block *sb, void *raw_data, int silent)
                rc = -ENOMEM;
                goto out;
        }
-       memset(ecryptfs_dentry_to_private(sb->s_root), 0,
-              sizeof(struct ecryptfs_dentry_info));
        rc = 0;
 out:
        /* Should be able to rely on deactivate_super called from
index 11fe93f7363c9dfb0cd05f52992ac0e6dd6bba9c..7e36c6f6f538adaf0bf4559e6de3b49579141c8e 100644 (file)
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -405,12 +405,10 @@ int setup_arg_pages(struct linux_binprm *bprm,
                bprm->loader += stack_base;
        bprm->exec += stack_base;
 
-       mpnt = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
+       mpnt = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
        if (!mpnt)
                return -ENOMEM;
 
-       memset(mpnt, 0, sizeof(*mpnt));
-
        down_write(&mm->mmap_sem);
        {
                mpnt->vm_mm = mm;
index 0b02ba9642d2e817cb908f0ae10a37c6ae8366c4..e89bfc8cf957f73ae8de1682482464efcb7672ae 100644 (file)
@@ -368,6 +368,14 @@ struct ext2_dir_entry_2 * ext2_find_entry (struct inode * dir,
                }
                if (++n >= npages)
                        n = 0;
+               /* next page is past the blocks we've got */
+               if (unlikely(n > (dir->i_blocks >> (PAGE_CACHE_SHIFT - 9)))) {
+                       ext2_error(dir->i_sb, __FUNCTION__,
+                               "dir %lu size %lld exceeds block count %llu",
+                               dir->i_ino, dir->i_size,
+                               (unsigned long long)dir->i_blocks);
+                       goto out;
+               }
        } while (n != start);
 out:
        return NULL;
index 6347c2dbdd819ad405082e83cbaa2966be185d77..daaa243eee9b906e3eb22ef27da831a6b8c3e05d 100644 (file)
@@ -708,10 +708,14 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
                set_opt(sbi->s_mount_opt, GRPID);
        if (def_mount_opts & EXT2_DEFM_UID16)
                set_opt(sbi->s_mount_opt, NO_UID32);
+#ifdef CONFIG_EXT2_FS_XATTR
        if (def_mount_opts & EXT2_DEFM_XATTR_USER)
                set_opt(sbi->s_mount_opt, XATTR_USER);
+#endif
+#ifdef CONFIG_EXT2_FS_POSIX_ACL
        if (def_mount_opts & EXT2_DEFM_ACL)
                set_opt(sbi->s_mount_opt, POSIX_ACL);
+#endif
        
        if (le16_to_cpu(sbi->s_es->s_errors) == EXT2_ERRORS_PANIC)
                set_opt(sbi->s_mount_opt, ERRORS_PANIC);
index beaf25f5112fd9f427a393bac3b9f12b634e14de..8a824f4ce5c608d231a6862b5a1c86de167d0882 100644 (file)
@@ -947,7 +947,7 @@ out:
 static int ext3_get_block(struct inode *inode, sector_t iblock,
                        struct buffer_head *bh_result, int create)
 {
-       handle_t *handle = journal_current_handle();
+       handle_t *handle = ext3_journal_current_handle();
        int ret = 0;
        unsigned max_blocks = bh_result->b_size >> inode->i_blkbits;
 
@@ -1717,7 +1717,7 @@ static ssize_t ext3_direct_IO(int rw, struct kiocb *iocb,
        /*
         * Reacquire the handle: ext3_get_block() can restart the transaction
         */
-       handle = journal_current_handle();
+       handle = ext3_journal_current_handle();
 
 out_stop:
        if (handle) {
index 4df39c4315e170c64e12ca6755f456d6b19b1e39..a8e89328e66d1ca6754417afbf54696460b24797 100644 (file)
@@ -1618,21 +1618,6 @@ static int ext3_delete_entry (handle_t *handle,
        return -ENOENT;
 }
 
-/*
- * ext3_mark_inode_dirty is somewhat expensive, so unlike ext2 we
- * do not perform it in these functions.  We perform it at the call site,
- * if it is needed.
- */
-static inline void ext3_inc_count(handle_t *handle, struct inode *inode)
-{
-       inc_nlink(inode);
-}
-
-static inline void ext3_dec_count(handle_t *handle, struct inode *inode)
-{
-       drop_nlink(inode);
-}
-
 static int ext3_add_nondir(handle_t *handle,
                struct dentry *dentry, struct inode *inode)
 {
@@ -1642,7 +1627,7 @@ static int ext3_add_nondir(handle_t *handle,
                d_instantiate(dentry, inode);
                return 0;
        }
-       ext3_dec_count(handle, inode);
+       drop_nlink(inode);
        iput(inode);
        return err;
 }
@@ -2163,7 +2148,7 @@ retry:
                err = __page_symlink(inode, symname, l,
                                mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS);
                if (err) {
-                       ext3_dec_count(handle, inode);
+                       drop_nlink(inode);
                        ext3_mark_inode_dirty(handle, inode);
                        iput (inode);
                        goto out_stop;
@@ -2191,6 +2176,12 @@ static int ext3_link (struct dentry * old_dentry,
 
        if (inode->i_nlink >= EXT3_LINK_MAX)
                return -EMLINK;
+       /*
+        * Return -ENOENT if we've raced with unlink and i_nlink is 0.  Doing
+        * otherwise has the potential to corrupt the orphan inode list.
+        */
+       if (inode->i_nlink == 0)
+               return -ENOENT;
 
 retry:
        handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) +
@@ -2202,7 +2193,7 @@ retry:
                handle->h_sync = 1;
 
        inode->i_ctime = CURRENT_TIME_SEC;
-       ext3_inc_count(handle, inode);
+       inc_nlink(inode);
        atomic_inc(&inode->i_count);
 
        err = ext3_add_nondir(handle, dentry, inode);
index b34886734a44d0417221231ba454bd6aa5aba2a5..a0623a84a4b2a04db9653cd43ad3a69d77a63307 100644 (file)
@@ -1459,10 +1459,14 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
                set_opt(sbi->s_mount_opt, GRPID);
        if (def_mount_opts & EXT3_DEFM_UID16)
                set_opt(sbi->s_mount_opt, NO_UID32);
+#ifdef CONFIG_EXT3_FS_XATTR
        if (def_mount_opts & EXT3_DEFM_XATTR_USER)
                set_opt(sbi->s_mount_opt, XATTR_USER);
+#endif
+#ifdef CONFIG_EXT3_FS_POSIX_ACL
        if (def_mount_opts & EXT3_DEFM_ACL)
                set_opt(sbi->s_mount_opt, POSIX_ACL);
+#endif
        if ((def_mount_opts & EXT3_DEFM_JMODE) == EXT3_DEFM_JMODE_DATA)
                sbi->s_mount_opt |= EXT3_MOUNT_JOURNAL_DATA;
        else if ((def_mount_opts & EXT3_DEFM_JMODE) == EXT3_DEFM_JMODE_ORDERED)
@@ -2344,6 +2348,22 @@ static int ext3_remount (struct super_block * sb, int * flags, char * data)
                                err = -EROFS;
                                goto restore_opts;
                        }
+
+                       /*
+                        * If we have an unprocessed orphan list hanging
+                        * around from a previously readonly bdev mount,
+                        * require a full umount/remount for now.
+                        */
+                       if (es->s_last_orphan) {
+                               printk(KERN_WARNING "EXT3-fs: %s: couldn't "
+                                      "remount RDWR because of unprocessed "
+                                      "orphan inode list.  Please "
+                                      "umount/remount instead.\n",
+                                      sb->s_id);
+                               err = -EINVAL;
+                               goto restore_opts;
+                       }
+
                        /*
                         * Mounting a RDONLY partition read-write, so reread
                         * and store the current valid flag.  (It may have
index a127cc03c9fa2868739ded1b98c7cd6d0d7ecc8b..fbff4b9e122a91781f84cef27db159b9b8534746 100644 (file)
@@ -946,7 +946,7 @@ out:
 static int ext4_get_block(struct inode *inode, sector_t iblock,
                        struct buffer_head *bh_result, int create)
 {
-       handle_t *handle = journal_current_handle();
+       handle_t *handle = ext4_journal_current_handle();
        int ret = 0;
        unsigned max_blocks = bh_result->b_size >> inode->i_blkbits;
 
@@ -1716,7 +1716,7 @@ static ssize_t ext4_direct_IO(int rw, struct kiocb *iocb,
        /*
         * Reacquire the handle: ext4_get_block() can restart the transaction
         */
-       handle = journal_current_handle();
+       handle = ext4_journal_current_handle();
 
 out_stop:
        if (handle) {
index e5a74a5ac261f228ffaf4b057857f8d03f7a62c2..34b3448b40f91d608d80b4fb935e6fae218e35f8 100644 (file)
@@ -1616,21 +1616,6 @@ static int ext4_delete_entry (handle_t *handle,
        return -ENOENT;
 }
 
-/*
- * ext4_mark_inode_dirty is somewhat expensive, so unlike ext2 we
- * do not perform it in these functions.  We perform it at the call site,
- * if it is needed.
- */
-static inline void ext4_inc_count(handle_t *handle, struct inode *inode)
-{
-       inc_nlink(inode);
-}
-
-static inline void ext4_dec_count(handle_t *handle, struct inode *inode)
-{
-       drop_nlink(inode);
-}
-
 static int ext4_add_nondir(handle_t *handle,
                struct dentry *dentry, struct inode *inode)
 {
@@ -1640,7 +1625,7 @@ static int ext4_add_nondir(handle_t *handle,
                d_instantiate(dentry, inode);
                return 0;
        }
-       ext4_dec_count(handle, inode);
+       drop_nlink(inode);
        iput(inode);
        return err;
 }
@@ -2161,7 +2146,7 @@ retry:
                err = __page_symlink(inode, symname, l,
                                mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS);
                if (err) {
-                       ext4_dec_count(handle, inode);
+                       drop_nlink(inode);
                        ext4_mark_inode_dirty(handle, inode);
                        iput (inode);
                        goto out_stop;
@@ -2189,6 +2174,12 @@ static int ext4_link (struct dentry * old_dentry,
 
        if (inode->i_nlink >= EXT4_LINK_MAX)
                return -EMLINK;
+       /*
+        * Return -ENOENT if we've raced with unlink and i_nlink is 0.  Doing
+        * otherwise has the potential to corrupt the orphan inode list.
+        */
+       if (inode->i_nlink == 0)
+               return -ENOENT;
 
 retry:
        handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
@@ -2200,7 +2191,7 @@ retry:
                handle->h_sync = 1;
 
        inode->i_ctime = CURRENT_TIME_SEC;
-       ext4_inc_count(handle, inode);
+       inc_nlink(inode);
        atomic_inc(&inode->i_count);
 
        err = ext4_add_nondir(handle, dentry, inode);
index 486a641ca71b94fa0ed745a246d57285d01611e1..c63a18b574dd13326306b1129b0e7fe9b04cbe8b 100644 (file)
@@ -1518,10 +1518,14 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
                set_opt(sbi->s_mount_opt, GRPID);
        if (def_mount_opts & EXT4_DEFM_UID16)
                set_opt(sbi->s_mount_opt, NO_UID32);
+#ifdef CONFIG_EXT4DEV_FS_XATTR
        if (def_mount_opts & EXT4_DEFM_XATTR_USER)
                set_opt(sbi->s_mount_opt, XATTR_USER);
+#endif
+#ifdef CONFIG_EXT4DEV_FS_POSIX_ACL
        if (def_mount_opts & EXT4_DEFM_ACL)
                set_opt(sbi->s_mount_opt, POSIX_ACL);
+#endif
        if ((def_mount_opts & EXT4_DEFM_JMODE) == EXT4_DEFM_JMODE_DATA)
                sbi->s_mount_opt |= EXT4_MOUNT_JOURNAL_DATA;
        else if ((def_mount_opts & EXT4_DEFM_JMODE) == EXT4_DEFM_JMODE_ORDERED)
@@ -2419,6 +2423,22 @@ static int ext4_remount (struct super_block * sb, int * flags, char * data)
                                err = -EROFS;
                                goto restore_opts;
                        }
+
+                       /*
+                        * If we have an unprocessed orphan list hanging
+                        * around from a previously readonly bdev mount,
+                        * require a full umount/remount for now.
+                        */
+                       if (es->s_last_orphan) {
+                               printk(KERN_WARNING "EXT4-fs: %s: couldn't "
+                                      "remount RDWR because of unprocessed "
+                                      "orphan inode list.  Please "
+                                      "umount/remount instead.\n",
+                                      sb->s_id);
+                               err = -EINVAL;
+                               goto restore_opts;
+                       }
+
                        /*
                         * Mounting a RDONLY partition read-write, so reread
                         * and store the current valid flag.  (It may have
index f63efe1337ece4b2547bc62461436d1c84b58867..2fd06927e851674e14968cda55898ec832ab2ac0 100644 (file)
@@ -69,7 +69,7 @@ void fuse_finish_open(struct inode *inode, struct file *file,
        if (outarg->open_flags & FOPEN_DIRECT_IO)
                file->f_op = &fuse_direct_io_file_operations;
        if (!(outarg->open_flags & FOPEN_KEEP_CACHE))
-               invalidate_inode_pages(inode->i_mapping);
+               invalidate_mapping_pages(inode->i_mapping, 0, -1);
        ff->fh = outarg->fh;
        file->private_data = ff;
 }
index 12450d2b320e771b13b7191403e9c4dd1f8dbf82..220255110d768de88d500f5590345667a0e34f5a 100644 (file)
@@ -112,7 +112,7 @@ void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr)
 {
        struct fuse_conn *fc = get_fuse_conn(inode);
        if (S_ISREG(inode->i_mode) && i_size_read(inode) != attr->size)
-               invalidate_inode_pages(inode->i_mapping);
+               invalidate_mapping_pages(inode->i_mapping, 0, -1);
 
        inode->i_ino     = attr->ino;
        inode->i_mode    = (inode->i_mode & S_IFMT) + (attr->mode & 07777);
index 0e34d9918973126c710c227bf35197bac57c30cc..e62d4f620c5841c73b177f2022324b09442e1a13 100644 (file)
@@ -282,8 +282,7 @@ void gfs2_attach_bufdata(struct gfs2_glock *gl, struct buffer_head *bh,
                return;
        }
 
-       bd = kmem_cache_alloc(gfs2_bufdata_cachep, GFP_NOFS | __GFP_NOFAIL),
-       memset(bd, 0, sizeof(struct gfs2_bufdata));
+       bd = kmem_cache_zalloc(gfs2_bufdata_cachep, GFP_NOFS | __GFP_NOFAIL),
        bd->bd_bh = bh;
        bd->bd_gl = gl;
 
index 88099ab1a180121449cfc04d7ca3a0d26b9366ef..1445e3a56ed45695428a1633a344c2f5f6462d1b 100644 (file)
@@ -83,8 +83,6 @@
 
 /*======== HFS structures as they appear on the disk ========*/
 
-#define __packed __attribute__ ((packed))
-
 /* Pascal-style string of up to 31 characters */
 struct hfs_name {
        u8 len;
index 49205531a5006b0ce731908628c5d485afeed77c..fe99fe8db61a3cb279885cee2c73cf5743704604 100644 (file)
@@ -15,8 +15,6 @@
 
 #include <linux/types.h>
 
-#define __packed __attribute__ ((packed))
-
 /* Some constants */
 #define HFSPLUS_SECTOR_SIZE        512
 #define HFSPLUS_SECTOR_SHIFT         9
index 4f4cd132b571337b8145d2c7432056b6d92b8d61..e6bd553fdc4cf29214e6f2b3a7fe50817e9e8d80 100644 (file)
@@ -449,10 +449,13 @@ static int hugetlbfs_symlink(struct inode *dir,
 }
 
 /*
- * For direct-IO reads into hugetlb pages
+ * mark the head page dirty
  */
 static int hugetlbfs_set_page_dirty(struct page *page)
 {
+       struct page *head = (struct page *)page_private(page);
+
+       SetPageDirty(head);
        return 0;
 }
 
index bf21dc6d0dbd752d243a2d3b6d92d2d554dc0381..e6d93070f1402e249f9f1be017b4831033eab1a4 100644 (file)
@@ -414,7 +414,8 @@ static void prune_icache(int nr_to_scan)
                        __iget(inode);
                        spin_unlock(&inode_lock);
                        if (remove_inode_buffers(inode))
-                               reap += invalidate_inode_pages(&inode->i_data);
+                               reap += invalidate_mapping_pages(&inode->i_data,
+                                                               0, -1);
                        iput(inode);
                        spin_lock(&inode_lock);
 
@@ -709,7 +710,7 @@ EXPORT_SYMBOL(iunique);
 struct inode *igrab(struct inode *inode)
 {
        spin_lock(&inode_lock);
-       if (!(inode->i_state & (I_FREEING|I_WILL_FREE)))
+       if (!(inode->i_state & (I_FREEING|I_CLEAR|I_WILL_FREE)))
                __iget(inode);
        else
                /*
@@ -1160,11 +1161,9 @@ void touch_atime(struct vfsmount *mnt, struct dentry *dentry)
        struct inode *inode = dentry->d_inode;
        struct timespec now;
 
-       if (IS_RDONLY(inode))
-               return;
        if (inode->i_flags & S_NOATIME)
                return;
-       if (inode->i_sb->s_flags & MS_NOATIME)
+       if (IS_NOATIME(inode))
                return;
        if ((inode->i_sb->s_flags & MS_NODIRATIME) && S_ISDIR(inode->i_mode))
                return;
index 43baa1afa0218842ce0ded1007cec8d9f8c5ecf5..6ee20668850209157be503192066ae9d357d16dd 100644 (file)
@@ -296,7 +296,7 @@ jffs_setattr(struct dentry *dentry, struct iattr *iattr)
                inode->i_blocks = (inode->i_size + 511) >> 9;
 
                if (len) {
-                       invalidate_inode_pages(inode->i_mapping);
+                       invalidate_mapping_pages(inode->i_mapping, 0, -1);
                }
                inode->i_ctime = CURRENT_TIME_SEC;
                inode->i_mtime = inode->i_ctime;
@@ -1518,7 +1518,7 @@ jffs_file_write(struct file *filp, const char *buf, size_t count,
        }
        inode->i_ctime = inode->i_mtime = CURRENT_TIME_SEC;
        mark_inode_dirty(inode);
-       invalidate_inode_pages(inode->i_mapping);
+       invalidate_mapping_pages(inode->i_mapping, 0, -1);
 
  out_isem:
        return err;
index 5ef336c1103c2c4a4ecbb5c9bf96cf8923e15454..fd999cab7b57c07b7729aabb3d96d938e3d8f0d1 100644 (file)
@@ -53,9 +53,8 @@ static inline unsigned long hash(struct vfsmount *mnt, struct dentry *dentry)
 
 struct vfsmount *alloc_vfsmnt(const char *name)
 {
-       struct vfsmount *mnt = kmem_cache_alloc(mnt_cache, GFP_KERNEL);
+       struct vfsmount *mnt = kmem_cache_zalloc(mnt_cache, GFP_KERNEL);
        if (mnt) {
-               memset(mnt, 0, sizeof(struct vfsmount));
                atomic_set(&mnt->mnt_count, 1);
                INIT_LIST_HEAD(&mnt->mnt_hash);
                INIT_LIST_HEAD(&mnt->mnt_child);
index 3d73d94d93a7dd9321cdfe5d9750fcf25a836df5..ac32a2e8540c4fb2ac34c1c27286f1a0d624fbd1 100644 (file)
@@ -365,7 +365,7 @@ void delete_partition(struct gendisk *disk, int part)
        kobject_put(&p->kobj);
 }
 
-void add_partition(struct gendisk *disk, int part, sector_t start, sector_t len)
+void add_partition(struct gendisk *disk, int part, sector_t start, sector_t len, int flags)
 {
        struct hd_struct *p;
 
@@ -390,6 +390,15 @@ void add_partition(struct gendisk *disk, int part, sector_t start, sector_t len)
        if (!disk->part_uevent_suppress)
                kobject_uevent(&p->kobj, KOBJ_ADD);
        sysfs_create_link(&p->kobj, &block_subsys.kset.kobj, "subsystem");
+       if (flags & ADDPART_FLAG_WHOLEDISK) {
+               static struct attribute addpartattr = {
+                       .name = "whole_disk",
+                       .mode = S_IRUSR | S_IRGRP | S_IROTH,
+                       .owner = THIS_MODULE,
+               };
+
+               sysfs_create_file(&p->kobj, &addpartattr);
+       }
        partition_sysfs_add_subdir(p);
        disk->part[part-1] = p;
 }
@@ -543,9 +552,9 @@ int rescan_partitions(struct gendisk *disk, struct block_device *bdev)
                        printk(" %s: p%d exceeds device capacity\n",
                                disk->disk_name, p);
                }
-               add_partition(disk, p, from, size);
+               add_partition(disk, p, from, size, state->parts[p].flags);
 #ifdef CONFIG_BLK_DEV_MD
-               if (state->parts[p].flags)
+               if (state->parts[p].flags & ADDPART_FLAG_RAID)
                        md_autodetect_dev(bdev->bd_dev+p);
 #endif
        }
index 8c7af1777819e2b2d5cdeabc49ef87298ca89c19..4ccec4cd1367a304bac2c784d0ba7e794b3e98cc 100644 (file)
@@ -63,15 +63,25 @@ msdos_magic_present(unsigned char *p)
 #define AIX_LABEL_MAGIC4       0xC1
 static int aix_magic_present(unsigned char *p, struct block_device *bdev)
 {
+       struct partition *pt = (struct partition *) (p + 0x1be);
        Sector sect;
        unsigned char *d;
-       int ret = 0;
+       int slot, ret = 0;
 
-       if (p[0] != AIX_LABEL_MAGIC1 &&
-               p[1] != AIX_LABEL_MAGIC2 &&
-               p[2] != AIX_LABEL_MAGIC3 &&
-               p[3] != AIX_LABEL_MAGIC4)
+       if (!(p[0] == AIX_LABEL_MAGIC1 &&
+               p[1] == AIX_LABEL_MAGIC2 &&
+               p[2] == AIX_LABEL_MAGIC3 &&
+               p[3] == AIX_LABEL_MAGIC4))
                return 0;
+       /* Assume the partition table is valid if Linux partitions exists */
+       for (slot = 1; slot <= 4; slot++, pt++) {
+               if (pt->sys_ind == LINUX_SWAP_PARTITION ||
+                       pt->sys_ind == LINUX_RAID_PARTITION ||
+                       pt->sys_ind == LINUX_DATA_PARTITION ||
+                       pt->sys_ind == LINUX_LVM_PARTITION ||
+                       is_extended_partition(pt))
+                       return 0;
+       }
        d = read_dev_sector(bdev, 7, &sect);
        if (d) {
                if (d[0] == '_' && d[1] == 'L' && d[2] == 'V' && d[3] == 'M')
@@ -155,7 +165,7 @@ parse_extended(struct parsed_partitions *state, struct block_device *bdev,
 
                        put_partition(state, state->next, next, size);
                        if (SYS_IND(p) == LINUX_RAID_PARTITION)
-                               state->parts[state->next].flags = 1;
+                               state->parts[state->next].flags = ADDPART_FLAG_RAID;
                        loopct = 0;
                        if (++state->next == state->limit)
                                goto done;
index 6fa4ff8951042f8f0becd6318b5991668933de5b..ed5ac83fe83ab0f5ec0333b986b693e2ce70743f 100644 (file)
@@ -72,7 +72,7 @@ int sgi_partition(struct parsed_partitions *state, struct block_device *bdev)
                if (blocks) {
                        put_partition(state, slot, start, blocks);
                        if (be32_to_cpu(p->type) == LINUX_RAID_PARTITION)
-                               state->parts[slot].flags = 1;
+                               state->parts[slot].flags = ADDPART_FLAG_RAID;
                }
                slot++;
        }
index 0a5927c806ca7dbf2aaa244b577159b779a602d6..123f8b46c8ba7cfbfd3676b37b00a8fa07070e38 100644 (file)
@@ -80,8 +80,11 @@ int sun_partition(struct parsed_partitions *state, struct block_device *bdev)
                num_sectors = be32_to_cpu(p->num_sectors);
                if (num_sectors) {
                        put_partition(state, slot, st_sector, num_sectors);
+                       state->parts[slot].flags = 0;
                        if (label->infos[i].id == LINUX_RAID_PARTITION)
-                               state->parts[slot].flags = 1;
+                               state->parts[slot].flags |= ADDPART_FLAG_RAID;
+                       if (label->infos[i].id == SUN_WHOLE_DISK)
+                               state->parts[slot].flags |= ADDPART_FLAG_WHOLEDISK;
                }
                slot++;
        }
index 1a979ea3b379931973f79c4b70703df3f237c714..7fb37d6f2864859b82cb12062706f462af00ec28 100644 (file)
@@ -1810,17 +1810,21 @@ static int proc_base_fill_cache(struct file *filp, void *dirent, filldir_t filld
 static int proc_pid_io_accounting(struct task_struct *task, char *buffer)
 {
        return sprintf(buffer,
+#ifdef CONFIG_TASK_XACCT
                        "rchar: %llu\n"
                        "wchar: %llu\n"
                        "syscr: %llu\n"
                        "syscw: %llu\n"
+#endif
                        "read_bytes: %llu\n"
                        "write_bytes: %llu\n"
                        "cancelled_write_bytes: %llu\n",
+#ifdef CONFIG_TASK_XACCT
                        (unsigned long long)task->rchar,
                        (unsigned long long)task->wchar,
                        (unsigned long long)task->syscr,
                        (unsigned long long)task->syscw,
+#endif
                        (unsigned long long)task->ioac.read_bytes,
                        (unsigned long long)task->ioac.write_bytes,
                        (unsigned long long)task->ioac.cancelled_write_bytes);
index b37ce33f67eaf1c24b96bac8a2147e4ac94c2a08..5e2d4359c2927b6ad851a6607f5c955eec64d8ae 100644 (file)
@@ -121,16 +121,11 @@ static int meminfo_read_proc(char *page, char **start, off_t off,
 {
        struct sysinfo i;
        int len;
-       unsigned long inactive;
-       unsigned long active;
-       unsigned long free;
        unsigned long committed;
        unsigned long allowed;
        struct vmalloc_info vmi;
        long cached;
 
-       get_zone_counts(&active, &inactive, &free);
-
 /*
  * display in kilobytes.
  */
@@ -187,8 +182,8 @@ static int meminfo_read_proc(char *page, char **start, off_t off,
                K(i.bufferram),
                K(cached),
                K(total_swapcache_pages),
-               K(active),
-               K(inactive),
+               K(global_page_state(NR_ACTIVE)),
+               K(global_page_state(NR_INACTIVE)),
 #ifdef CONFIG_HIGHMEM
                K(i.totalhigh),
                K(i.freehigh),
@@ -672,7 +667,6 @@ void create_seq_entry(char *name, mode_t mode, const struct file_operations *f)
 
 void __init proc_misc_init(void)
 {
-       struct proc_dir_entry *entry;
        static struct {
                char *name;
                int (*read_proc)(char*,char**,off_t,int,int*,void*);
@@ -700,9 +694,12 @@ void __init proc_misc_init(void)
 
        /* And now for trickier ones */
 #ifdef CONFIG_PRINTK
-       entry = create_proc_entry("kmsg", S_IRUSR, &proc_root);
-       if (entry)
-               entry->proc_fops = &proc_kmsg_operations;
+       {
+               struct proc_dir_entry *entry;
+               entry = create_proc_entry("kmsg", S_IRUSR, &proc_root);
+               if (entry)
+                       entry->proc_fops = &proc_kmsg_operations;
+       }
 #endif
        create_seq_entry("devices", 0, &proc_devinfo_operations);
        create_seq_entry("cpuinfo", 0, &proc_cpuinfo_operations);
@@ -743,8 +740,11 @@ void __init proc_misc_init(void)
                proc_vmcore->proc_fops = &proc_vmcore_operations;
 #endif
 #ifdef CONFIG_MAGIC_SYSRQ
-       entry = create_proc_entry("sysrq-trigger", S_IWUSR, NULL);
-       if (entry)
-               entry->proc_fops = &proc_sysrq_trigger_operations;
+       {
+               struct proc_dir_entry *entry;
+               entry = create_proc_entry("sysrq-trigger", S_IWUSR, NULL);
+               if (entry)
+                       entry->proc_fops = &proc_sysrq_trigger_operations;
+       }
 #endif
 }
index 54ebbc84207f162f2f58a8d00a1e8403088d5fc0..b935a3dd4b6544cf8bbbd4ee5a26afe095d70273 100644 (file)
@@ -31,7 +31,7 @@ const struct address_space_operations ramfs_aops = {
        .readpage       = simple_readpage,
        .prepare_write  = simple_prepare_write,
        .commit_write   = simple_commit_write,
-       .set_page_dirty = __set_page_dirty_nobuffers,
+       .set_page_dirty = __set_page_dirty_no_writeback,
 };
 
 const struct file_operations ramfs_file_operations = {
index e9d6c47332826501c2857514c6ba334366856791..d05e09ac9a99763851d412688b04b9908ebeab25 100644 (file)
@@ -32,7 +32,7 @@ const struct address_space_operations ramfs_aops = {
        .readpage               = simple_readpage,
        .prepare_write          = simple_prepare_write,
        .commit_write           = simple_commit_write,
-       .set_page_dirty = __set_page_dirty_nobuffers,
+       .set_page_dirty         = __set_page_dirty_no_writeback,
 };
 
 const struct file_operations ramfs_file_operations = {
index 707ac21700d31d26ee85d85734e4c3138853dd70..bcb0ef2aae3d5f54588616102b0d220d1aa63d94 100644 (file)
@@ -274,9 +274,9 @@ ssize_t vfs_read(struct file *file, char __user *buf, size_t count, loff_t *pos)
                                ret = do_sync_read(file, buf, count, pos);
                        if (ret > 0) {
                                fsnotify_access(file->f_path.dentry);
-                               current->rchar += ret;
+                               add_rchar(current, ret);
                        }
-                       current->syscr++;
+                       inc_syscr(current);
                }
        }
 
@@ -332,9 +332,9 @@ ssize_t vfs_write(struct file *file, const char __user *buf, size_t count, loff_
                                ret = do_sync_write(file, buf, count, pos);
                        if (ret > 0) {
                                fsnotify_modify(file->f_path.dentry);
-                               current->wchar += ret;
+                               add_wchar(current, ret);
                        }
-                       current->syscw++;
+                       inc_syscw(current);
                }
        }
 
@@ -675,8 +675,8 @@ sys_readv(unsigned long fd, const struct iovec __user *vec, unsigned long vlen)
        }
 
        if (ret > 0)
-               current->rchar += ret;
-       current->syscr++;
+               add_rchar(current, ret);
+       inc_syscr(current);
        return ret;
 }
 
@@ -696,8 +696,8 @@ sys_writev(unsigned long fd, const struct iovec __user *vec, unsigned long vlen)
        }
 
        if (ret > 0)
-               current->wchar += ret;
-       current->syscw++;
+               add_wchar(current, ret);
+       inc_syscw(current);
        return ret;
 }
 
@@ -779,12 +779,12 @@ static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos,
        retval = in_file->f_op->sendfile(in_file, ppos, count, file_send_actor, out_file);
 
        if (retval > 0) {
-               current->rchar += retval;
-               current->wchar += retval;
+               add_rchar(current, retval);
+               add_wchar(current, retval);
        }
-       current->syscr++;
-       current->syscw++;
 
+       inc_syscr(current);
+       inc_syscw(current);
        if (*ppos > max)
                retval = -EOVERFLOW;
 
index a4bcae8a9aff23f0835e996427d38036afb73c47..42261dbdf60f172270dff8c70c1942c50a2ce0b3 100644 (file)
@@ -61,7 +61,7 @@ static struct smb_request *smb_do_alloc_request(struct smb_sb_info *server,
        struct smb_request *req;
        unsigned char *buf = NULL;
 
-       req = kmem_cache_alloc(req_cachep, GFP_KERNEL);
+       req = kmem_cache_zalloc(req_cachep, GFP_KERNEL);
        VERBOSE("allocating request: %p\n", req);
        if (!req)
                goto out;
@@ -74,7 +74,6 @@ static struct smb_request *smb_do_alloc_request(struct smb_sb_info *server,
                }
        }
 
-       memset(req, 0, sizeof(struct smb_request));
        req->rq_buffer = buf;
        req->rq_bufsize = bufsize;
        req->rq_server = server;
index 9dcdf556c99c1d2b68f9bde966f2b4d393b05555..9e95e7abaf699e88c585540373e59597295a1cfa 100644 (file)
@@ -37,11 +37,10 @@ static struct sysfs_dirent * __sysfs_new_dirent(void * element)
 {
        struct sysfs_dirent * sd;
 
-       sd = kmem_cache_alloc(sysfs_dir_cachep, GFP_KERNEL);
+       sd = kmem_cache_zalloc(sysfs_dir_cachep, GFP_KERNEL);
        if (!sd)
                return NULL;
 
-       memset(sd, 0, sizeof(*sd));
        atomic_set(&sd->s_count, 1);
        atomic_set(&sd->s_event, 1);
        INIT_LIST_HEAD(&sd->s_children);
index 433b6f68403a73bf73c43667e52eb3d97f96c4a0..a6c0ca9f48bff1ba6d087413a5accbdcaf1fa370 100644 (file)
@@ -106,12 +106,13 @@ static void ufs_check_page(struct page *page)
        char *kaddr = page_address(page);
        unsigned offs, rec_len;
        unsigned limit = PAGE_CACHE_SIZE;
+       const unsigned chunk_mask = UFS_SB(sb)->s_uspi->s_dirblksize - 1;
        struct ufs_dir_entry *p;
        char *error;
 
        if ((dir->i_size >> PAGE_CACHE_SHIFT) == page->index) {
                limit = dir->i_size & ~PAGE_CACHE_MASK;
-               if (limit & (UFS_SECTOR_SIZE - 1))
+               if (limit & chunk_mask)
                        goto Ebadsize;
                if (!limit)
                        goto out;
@@ -126,7 +127,7 @@ static void ufs_check_page(struct page *page)
                        goto Ealign;
                if (rec_len < UFS_DIR_REC_LEN(ufs_get_de_namlen(sb, p)))
                        goto Enamelen;
-               if (((offs + rec_len - 1) ^ offs) & ~(UFS_SECTOR_SIZE-1))
+               if (((offs + rec_len - 1) ^ offs) & ~chunk_mask)
                        goto Espan;
                if (fs32_to_cpu(sb, p->d_ino) > (UFS_SB(sb)->s_uspi->s_ipg *
                                                  UFS_SB(sb)->s_uspi->s_ncg))
@@ -310,6 +311,7 @@ int ufs_add_link(struct dentry *dentry, struct inode *inode)
        int namelen = dentry->d_name.len;
        struct super_block *sb = dir->i_sb;
        unsigned reclen = UFS_DIR_REC_LEN(namelen);
+       const unsigned int chunk_size = UFS_SB(sb)->s_uspi->s_dirblksize;
        unsigned short rec_len, name_len;
        struct page *page = NULL;
        struct ufs_dir_entry *de;
@@ -342,8 +344,8 @@ int ufs_add_link(struct dentry *dentry, struct inode *inode)
                        if ((char *)de == dir_end) {
                                /* We hit i_size */
                                name_len = 0;
-                               rec_len = UFS_SECTOR_SIZE;
-                               de->d_reclen = cpu_to_fs16(sb, UFS_SECTOR_SIZE);
+                               rec_len = chunk_size;
+                               de->d_reclen = cpu_to_fs16(sb, chunk_size);
                                de->d_ino = 0;
                                goto got_it;
                        }
@@ -431,7 +433,7 @@ ufs_readdir(struct file *filp, void *dirent, filldir_t filldir)
        unsigned int offset = pos & ~PAGE_CACHE_MASK;
        unsigned long n = pos >> PAGE_CACHE_SHIFT;
        unsigned long npages = ufs_dir_pages(inode);
-       unsigned chunk_mask = ~(UFS_SECTOR_SIZE - 1);
+       unsigned chunk_mask = ~(UFS_SB(sb)->s_uspi->s_dirblksize - 1);
        int need_revalidate = filp->f_version != inode->i_version;
        unsigned flags = UFS_SB(sb)->s_flags;
 
@@ -511,7 +513,7 @@ int ufs_delete_entry(struct inode *inode, struct ufs_dir_entry *dir,
        struct super_block *sb = inode->i_sb;
        struct address_space *mapping = page->mapping;
        char *kaddr = page_address(page);
-       unsigned from = ((char*)dir - kaddr) & ~(UFS_SECTOR_SIZE - 1);
+       unsigned from = ((char*)dir - kaddr) & ~(UFS_SB(sb)->s_uspi->s_dirblksize - 1);
        unsigned to = ((char*)dir - kaddr) + fs16_to_cpu(sb, dir->d_reclen);
        struct ufs_dir_entry *pde = NULL;
        struct ufs_dir_entry *de = (struct ufs_dir_entry *) (kaddr + from);
@@ -556,6 +558,7 @@ int ufs_make_empty(struct inode * inode, struct inode *dir)
        struct super_block * sb = dir->i_sb;
        struct address_space *mapping = inode->i_mapping;
        struct page *page = grab_cache_page(mapping, 0);
+       const unsigned int chunk_size = UFS_SB(sb)->s_uspi->s_dirblksize;
        struct ufs_dir_entry * de;
        char *base;
        int err;
@@ -563,7 +566,7 @@ int ufs_make_empty(struct inode * inode, struct inode *dir)
        if (!page)
                return -ENOMEM;
        kmap(page);
-       err = mapping->a_ops->prepare_write(NULL, page, 0, UFS_SECTOR_SIZE);
+       err = mapping->a_ops->prepare_write(NULL, page, 0, chunk_size);
        if (err) {
                unlock_page(page);
                goto fail;
@@ -584,11 +587,11 @@ int ufs_make_empty(struct inode * inode, struct inode *dir)
                ((char *)de + fs16_to_cpu(sb, de->d_reclen));
        de->d_ino = cpu_to_fs32(sb, dir->i_ino);
        ufs_set_de_type(sb, de, dir->i_mode);
-       de->d_reclen = cpu_to_fs16(sb, UFS_SECTOR_SIZE - UFS_DIR_REC_LEN(1));
+       de->d_reclen = cpu_to_fs16(sb, chunk_size - UFS_DIR_REC_LEN(1));
        ufs_set_de_namlen(sb, de, 2);
        strcpy (de->d_name, "..");
 
-       err = ufs_commit_chunk(page, 0, UFS_SECTOR_SIZE);
+       err = ufs_commit_chunk(page, 0, chunk_size);
 fail:
        kunmap(page);
        page_cache_release(page);
index 8a8e9382ec099a2b41d176c6dc391a316af7b80d..209be95e9d188385d2fc6cf25b1c18e61fb8b87a 100644 (file)
@@ -649,7 +649,7 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent)
                kmalloc (sizeof(struct ufs_sb_private_info), GFP_KERNEL);
        if (!uspi)
                goto failed;
-
+       uspi->s_dirblksize = UFS_SECTOR_SIZE;
        super_block_offset=UFS_SBLOCK;
 
        /* Keep 2Gig file limit. Some UFS variants need to override 
@@ -718,6 +718,7 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent)
                break;
        
        case UFS_MOUNT_UFSTYPE_NEXTSTEP:
+               /*TODO: check may be we need set special dir block size?*/
                UFSD("ufstype=nextstep\n");
                uspi->s_fsize = block_size = 1024;
                uspi->s_fmask = ~(1024 - 1);
@@ -733,6 +734,7 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent)
                break;
        
        case UFS_MOUNT_UFSTYPE_NEXTSTEP_CD:
+               /*TODO: check may be we need set special dir block size?*/
                UFSD("ufstype=nextstep-cd\n");
                uspi->s_fsize = block_size = 2048;
                uspi->s_fmask = ~(2048 - 1);
@@ -754,6 +756,7 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent)
                uspi->s_fshift = 10;
                uspi->s_sbsize = super_block_size = 2048;
                uspi->s_sbbase = 0;
+               uspi->s_dirblksize = 1024;
                flags |= UFS_DE_44BSD | UFS_UID_44BSD | UFS_ST_44BSD | UFS_CG_44BSD;
                if (!(sb->s_flags & MS_RDONLY)) {
                        if (!silent)
index 5d15af24573b9f90fa0e6f9bb6dc12bd6363a241..24bdcc8b63aa2c3eebd49cdf28e48ad2b2ac0ccd 100644 (file)
@@ -524,15 +524,6 @@ extern void outsb (unsigned long port, const void *src, unsigned long count);
 extern void outsw (unsigned long port, const void *src, unsigned long count);
 extern void outsl (unsigned long port, const void *src, unsigned long count);
 
-/*
- * XXX - We don't have csum_partial_copy_fromio() yet, so we cheat here and 
- * just copy it. The net code will then do the checksum later. Presently 
- * only used by some shared memory 8390 Ethernet cards anyway.
- */
-
-#define eth_io_copy_and_sum(skb,src,len,unused) \
-  memcpy_fromio((skb)->data,src,len)
-
 /*
  * The Alpha Jensen hardware for some rather strange reason puts
  * the RTC clock at 0x170 instead of 0x70. Probably due to some
index 5f24c755f577d9fc48add5c52300f377ed2690e4..90d7c35d286703a86a4f1c59061b2212b2de367d 100644 (file)
@@ -49,7 +49,6 @@
 #define MADV_DOFORK    11              /* do inherit across fork */
 
 /* compatibility flags */
-#define MAP_ANON       MAP_ANONYMOUS
 #define MAP_FILE       0
 
 #endif /* __ALPHA_MMAN_H__ */
index 48348fe34c19bc5b6ace3fbfe7a88838033577c9..651ebb141b24c802be33fe1020f42813b9ef3bdd 100644 (file)
@@ -1,6 +1,20 @@
 #ifndef __ALPHA_PERCPU_H
 #define __ALPHA_PERCPU_H
 
+/*
+ * Increase the per cpu area for Alpha so that
+ * modules using percpu area can load.
+ */
+#ifdef CONFIG_MODULES
+# define PERCPU_MODULE_RESERVE 8192
+#else
+# define PERCPU_MODULE_RESERVE 0
+#endif
+
+#define PERCPU_ENOUGH_ROOM \
+       (ALIGN(__per_cpu_end - __per_cpu_start, SMP_CACHE_BYTES) + \
+        PERCPU_MODULE_RESERVE)
+
 #include <asm-generic/percpu.h>
 
 #endif /* __ALPHA_PERCPU_H */
index 1cfd27f0ad7310278a062d602a7e24eccba4fb88..39e492c3bfa3fe33c78c20aa796c89888d6b702e 100644 (file)
@@ -66,24 +66,6 @@ struct termio {
 #define _VEOL2 6
 #define _VSWTC 7
 
-/* line disciplines */
-#define N_TTY          0
-#define N_SLIP         1
-#define N_MOUSE                2
-#define N_PPP          3
-#define N_STRIP                4
-#define N_AX25         5
-#define N_X25          6       /* X.25 async */
-#define N_6PACK                7
-#define N_MASC         8       /* Reserved for Mobitex module <kaz@cafe.net> */
-#define N_R3964                9       /* Reserved for Simatic R3964 module */
-#define N_PROFIBUS_FDL 10      /* Reserved for Profibus <Dave@mvhi.com> */
-#define N_IRDA         11      /* Linux IrDa - http://irda.sourceforge.net/ */
-#define N_SMSBLOCK     12      /* SMS block mode - for talking to GSM data cards about SMS messages */
-#define N_HDLC         13      /* synchronous HDLC */
-#define N_SYNC_PPP     14
-#define N_HCI          15  /* Bluetooth HCI UART */
-
 #ifdef __KERNEL__
 /*     eof=^D          eol=\0          eol2=\0         erase=del
        werase=^W       kill=^U         reprint=^R      sxtc=\0
index 0d517267fb63edf0d49809fd64c701629e2c1d41..b7b5414d9320d7289dad9b6142fa316ef9f2870e 100644 (file)
@@ -238,9 +238,6 @@ __ixp4xx_readsl(const volatile void __iomem *bus_addr, u32 *vaddr, u32 count)
 #define memcpy_fromio(a,c,l)           _memcpy_fromio((a),(c),(l))
 #define memcpy_toio(c,a,l)             _memcpy_toio((c),(a),(l))
 
-#define eth_io_copy_and_sum(s,c,l,b) \
-                               eth_copy_and_sum((s),__mem_pci(c),(l),(b))
-
 static inline int
 check_signature(const unsigned char __iomem *bus_addr, const unsigned char *signature,
                int length)
index 288f76b166d00709a73ce679e585cf2a7dcb266e..5f60b4220906858b50bf79cbc2d0b6687ffe250b 100644 (file)
@@ -182,9 +182,6 @@ extern void _memset_io(volatile void __iomem *, int, size_t);
 #define memcpy_fromio(a,c,l)   _memcpy_fromio((a),__mem_pci(c),(l))
 #define memcpy_toio(c,a,l)     _memcpy_toio(__mem_pci(c),(a),(l))
 
-#define eth_io_copy_and_sum(s,c,l,b) \
-                               eth_copy_and_sum((s),__mem_pci(c),(l),(b))
-
 #elif !defined(readb)
 
 #define readb(c)                       (__readwrite_bug("readb"),0)
@@ -194,8 +191,6 @@ extern void _memset_io(volatile void __iomem *, int, size_t);
 #define writew(v,c)                    __readwrite_bug("writew")
 #define writel(v,c)                    __readwrite_bug("writel")
 
-#define eth_io_copy_and_sum(s,c,l,b)   __readwrite_bug("eth_io_copy_and_sum")
-
 #define check_signature(io,sig,len)    (0)
 
 #endif /* __mem_pci */
index 861092fbaa53283953bd41c9dbb6e840bb42ff02..800ba5254dafef9bff57c98a19dcb599b0982cbc 100644 (file)
@@ -85,7 +85,6 @@ static inline void __raw_spin_unlock(raw_spinlock_t *lock)
  * Write locks are easy - we just set bit 31.  When unlocking, we can
  * just write zero since the lock is exclusively held.
  */
-#define rwlock_is_locked(x)    (*((volatile unsigned int *)(x)) != 0)
 
 static inline void __raw_write_lock(raw_rwlock_t *rw)
 {
index 7b8f5e8ae063a0ad03e806f943e81aa19ea6cec9..329c324c4040c9c3fcb0a1302465a4ed88d49209 100644 (file)
@@ -49,24 +49,6 @@ struct termio {
 
 /* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
 
-/* line disciplines */
-#define N_TTY          0
-#define N_SLIP         1
-#define N_MOUSE                2
-#define N_PPP          3
-#define N_STRIP                4
-#define N_AX25         5
-#define N_X25          6       /* X.25 async */
-#define N_6PACK                7
-#define N_MASC         8       /* Reserved for Mobitex module <kaz@cafe.net> */
-#define N_R3964                9       /* Reserved for Simatic R3964 module */
-#define N_PROFIBUS_FDL 10      /* Reserved for Profibus <Dave@mvhi.com> */
-#define N_IRDA         11      /* Linux IrDa - http://irda.sourceforge.net/ */
-#define N_SMSBLOCK     12      /* SMS block mode - for talking to GSM data cards about SMS messages */
-#define N_HDLC         13      /* synchronous HDLC */
-#define N_SYNC_PPP     14
-#define N_HCI          15  /* Bluetooth HCI UART */
-
 #ifdef __KERNEL__
 
 /*
index 5f420a0149f1d5dd133e17890d4a81ac2a8f0c74..c92df958802e304dd60fb92a8a92bbb1facf142b 100644 (file)
@@ -76,10 +76,10 @@ static inline void set_fs(mm_segment_t fs)
 
 /* We use 33-bit arithmetic here... */
 #define __range_ok(addr,size) ({ \
-       unsigned long flag, sum; \
+       unsigned long flag, roksum; \
        __chk_user_ptr(addr);   \
        __asm__("adds %1, %2, %3; sbcccs %1, %1, %0; movcc %0, #0" \
-               : "=&r" (flag), "=&r" (sum) \
+               : "=&r" (flag), "=&r" (roksum) \
                : "r" (addr), "Ir" (size), "0" (current_thread_info()->addr_limit) \
                : "cc"); \
        flag; })
index 7b8f5e8ae063a0ad03e806f943e81aa19ea6cec9..329c324c4040c9c3fcb0a1302465a4ed88d49209 100644 (file)
@@ -49,24 +49,6 @@ struct termio {
 
 /* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
 
-/* line disciplines */
-#define N_TTY          0
-#define N_SLIP         1
-#define N_MOUSE                2
-#define N_PPP          3
-#define N_STRIP                4
-#define N_AX25         5
-#define N_X25          6       /* X.25 async */
-#define N_6PACK                7
-#define N_MASC         8       /* Reserved for Mobitex module <kaz@cafe.net> */
-#define N_R3964                9       /* Reserved for Simatic R3964 module */
-#define N_PROFIBUS_FDL 10      /* Reserved for Profibus <Dave@mvhi.com> */
-#define N_IRDA         11      /* Linux IrDa - http://irda.sourceforge.net/ */
-#define N_SMSBLOCK     12      /* SMS block mode - for talking to GSM data cards about SMS messages */
-#define N_HDLC         13      /* synchronous HDLC */
-#define N_SYNC_PPP     14
-#define N_HCI          15  /* Bluetooth HCI UART */
-
 #ifdef __KERNEL__
 
 /*
index 19f798e338c974e17d317233950be3f4105af82a..ade76ec02995c96b48a4493aea5812523d3105af 100644 (file)
@@ -34,9 +34,9 @@ static inline void set_fs (mm_segment_t fs)
 }
 
 #define __range_ok(addr,size) ({                                       \
-       unsigned long flag, sum;                                        \
+       unsigned long flag, roksum;                                     \
        __asm__ __volatile__("subs %1, %0, %3; cmpcs %1, %2; movcs %0, #0" \
-               : "=&r" (flag), "=&r" (sum)                             \
+               : "=&r" (flag), "=&r" (roksum)                          \
                : "r" (addr), "Ir" (size), "0" (current_thread_info()->addr_limit)      \
                : "cc");                                                \
        flag; })
index ba85e04553d47b9f8b1f9a5e8db5d3e7cacc0329..3914d7b94ff4e7b6c7181f067df744c484ad7caa 100644 (file)
 #define GPIO_PIOB_BASE (GPIO_PIOA_BASE + 32)
 #define GPIO_PIOC_BASE (GPIO_PIOB_BASE + 32)
 #define GPIO_PIOD_BASE (GPIO_PIOC_BASE + 32)
+#define GPIO_PIOE_BASE (GPIO_PIOD_BASE + 32)
 
 #define GPIO_PIN_PA(N) (GPIO_PIOA_BASE + (N))
 #define GPIO_PIN_PB(N) (GPIO_PIOB_BASE + (N))
 #define GPIO_PIN_PC(N) (GPIO_PIOC_BASE + (N))
 #define GPIO_PIN_PD(N) (GPIO_PIOD_BASE + (N))
+#define GPIO_PIN_PE(N) (GPIO_PIOE_BASE + (N))
 
 #endif /* __ASM_ARCH_AT32AP7000_H__ */
diff --git a/include/asm-avr32/arch-at32ap/gpio.h b/include/asm-avr32/arch-at32ap/gpio.h
new file mode 100644 (file)
index 0000000..fcb756b
--- /dev/null
@@ -0,0 +1,27 @@
+#ifndef __ASM_AVR32_ARCH_GPIO_H
+#define __ASM_AVR32_ARCH_GPIO_H
+
+#include <linux/compiler.h>
+#include <asm/irq.h>
+
+
+/* Arch-neutral GPIO API */
+int __must_check gpio_request(unsigned int gpio, const char *label);
+void gpio_free(unsigned int gpio);
+
+int gpio_direction_input(unsigned int gpio);
+int gpio_direction_output(unsigned int gpio);
+int gpio_get_value(unsigned int gpio);
+void gpio_set_value(unsigned int gpio, int value);
+
+static inline int gpio_to_irq(unsigned int gpio)
+{
+       return gpio + GPIO_IRQ_BASE;
+}
+
+static inline int irq_to_gpio(unsigned int irq)
+{
+       return irq - GPIO_IRQ_BASE;
+}
+
+#endif /* __ASM_AVR32_ARCH_GPIO_H */
diff --git a/include/asm-avr32/arch-at32ap/irq.h b/include/asm-avr32/arch-at32ap/irq.h
new file mode 100644 (file)
index 0000000..5adffab
--- /dev/null
@@ -0,0 +1,14 @@
+#ifndef __ASM_AVR32_ARCH_IRQ_H
+#define __ASM_AVR32_ARCH_IRQ_H
+
+#define EIM_IRQ_BASE   NR_INTERNAL_IRQS
+#define NR_EIM_IRQS    32
+
+#define AT32_EXTINT(n) (EIM_IRQ_BASE + (n))
+
+#define GPIO_IRQ_BASE  (EIM_IRQ_BASE + NR_EIM_IRQS)
+#define NR_GPIO_IRQS   (5 * 32)
+
+#define NR_IRQS                (GPIO_IRQ_BASE + NR_GPIO_IRQS)
+
+#endif /* __ASM_AVR32_ARCH_IRQ_H */
index 83c690571322af286ec19d6163691c3402efd792..9930871decde1e61bbb522b9d9243759263f773c 100644 (file)
  *
  * The following flags determine the initial state of the pin.
  */
-#define AT32_GPIOF_PULLUP      0x00000001      /* Enable pull-up */
-#define AT32_GPIOF_OUTPUT      0x00000002      /* Enable output driver */
-#define AT32_GPIOF_HIGH                0x00000004      /* Set output high */
+#define AT32_GPIOF_PULLUP      0x00000001      /* (not-OUT) Enable pull-up */
+#define AT32_GPIOF_OUTPUT      0x00000002      /* (OUT) Enable output driver */
+#define AT32_GPIOF_HIGH                0x00000004      /* (OUT) Set output high */
+#define AT32_GPIOF_DEGLITCH    0x00000008      /* (IN) Filter glitches */
 
 void at32_select_periph(unsigned int pin, unsigned int periph,
                        unsigned long flags);
 void at32_select_gpio(unsigned int pin, unsigned long flags);
+void at32_reserve_pin(unsigned int pin);
 
 #endif /* __ASM_ARCH_PORTMUX_H__ */
index af9d53f0f5d2c12ec02207e2e38a12fe9b609524..4ddbfd2486af06412b32e7cf66af54ce1942d9e8 100644 (file)
@@ -38,7 +38,7 @@ __wsum csum_partial_copy_generic(const void *src, void *dst, int len,
  *     passed in an incorrect kernel address to one of these functions.
  *
  *     If you use these functions directly please don't forget the
- *     verify_area().
+ *     access_ok().
  */
 static inline
 __wsum csum_partial_copy_nocheck(const void *src, void *dst,
index 5c01e27f0b41d61ac58f3c49e9f2a38aabff1b4c..115813e48fe0c11005181dee7bda548ebad73bb6 100644 (file)
@@ -32,6 +32,14 @@ static inline int dma_set_mask(struct device *dev, u64 dma_mask)
        return 0;
 }
 
+/*
+ * dma_map_single can't fail as it is implemented now.
+ */
+static inline int dma_mapping_error(dma_addr_t addr)
+{
+       return 0;
+}
+
 /**
  * dma_alloc_coherent - allocate consistent memory for DMA
  * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
diff --git a/include/asm-avr32/gpio.h b/include/asm-avr32/gpio.h
new file mode 100644 (file)
index 0000000..19e8ccc
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef __ASM_AVR32_GPIO_H
+#define __ASM_AVR32_GPIO_H
+
+#include <asm/arch/gpio.h>
+
+#endif /* __ASM_AVR32_GPIO_H */
index f7e725707dd7de5980a27943a1cc20ed315485b6..83e6549d7783f0ab2bff22b1a4a94f822ccb16e7 100644 (file)
@@ -2,8 +2,12 @@
 #define __ASM_AVR32_IRQ_H
 
 #define NR_INTERNAL_IRQS       64
-#define NR_EXTERNAL_IRQS       64
-#define NR_IRQS                        (NR_INTERNAL_IRQS + NR_EXTERNAL_IRQS)
+
+#include <asm/arch/irq.h>
+
+#ifndef NR_IRQS
+#define NR_IRQS                        (NR_INTERNAL_IRQS)
+#endif
 
 #define irq_canonicalize(i)    (i)
 
index 2831b039b349c7428870657cb63c28fee052f2a8..9e255b9996393aa503290b865534198ec32e93ad 100644 (file)
@@ -23,7 +23,7 @@ typedef unsigned short  __kernel_ipc_pid_t;
 typedef unsigned int   __kernel_uid_t;
 typedef unsigned int   __kernel_gid_t;
 typedef unsigned long  __kernel_size_t;
-typedef int             __kernel_ssize_t;
+typedef long           __kernel_ssize_t;
 typedef int             __kernel_ptrdiff_t;
 typedef long            __kernel_time_t;
 typedef long            __kernel_suseconds_t;
index 615bc0639e5ceb5e5b15f2bd8bd527d8224c9470..0152aba35154b5a8b53644e1466f30cd3748296e 100644 (file)
@@ -46,24 +46,6 @@ struct termio {
 
 /* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
 
-/* line disciplines */
-#define N_TTY          0
-#define N_SLIP         1
-#define N_MOUSE                2
-#define N_PPP          3
-#define N_STRIP                4
-#define N_AX25         5
-#define N_X25          6       /* X.25 async */
-#define N_6PACK                7
-#define N_MASC         8       /* Reserved for Mobitex module <kaz@cafe.net> */
-#define N_R3964                9       /* Reserved for Simatic R3964 module */
-#define N_PROFIBUS_FDL 10      /* Reserved for Profibus <Dave@mvhi.com> */
-#define N_IRDA         11      /* Linux IR - http://irda.sourceforge.net/ */
-#define N_SMSBLOCK     12      /* SMS block mode - for talking to GSM data cards about SMS messages */
-#define N_HDLC         13      /* synchronous HDLC */
-#define N_SYNC_PPP     14      /* synchronous PPP */
-#define N_HCI          15  /* Bluetooth HCI UART */
-
 #ifdef __KERNEL__
 /*     intr=^C         quit=^\         erase=del       kill=^U
        eof=^D          vtime=\0        vmin=\1         sxtc=\0
index 821deb5a9d2893a1255b2bd85d25f8319a5ed87c..74a679e9098c43e07e8869635c81b2e936b3741c 100644 (file)
@@ -68,12 +68,6 @@ static inline void set_fs(mm_segment_t s)
 
 #define access_ok(type, addr, size) (likely(__range_ok(addr, size) == 0))
 
-static inline int
-verify_area(int type, const void __user *addr, unsigned long size)
-{
-       return access_ok(type, addr, size) ? 0 : -EFAULT;
-}
-
 /* Generic arbitrary sized copy. Return the number of bytes NOT copied */
 extern __kernel_size_t __copy_user(void *to, const void *from,
                                   __kernel_size_t n);
index 716c69bc58f89be19545b55d13a4d6d4cbe32614..d196dd6b2df3ffc4dc46512adab3ecdd9cf535db 100644 (file)
@@ -121,11 +121,6 @@ static inline void writel(unsigned int b, volatile void __iomem *addr)
 #define memcpy_fromio(a,b,c)   memcpy((a),(void *)(b),(c))
 #define memcpy_toio(a,b,c)     memcpy((void *)(a),(b),(c))
 
-/*
- * Again, CRIS does not require mem IO specific function.
- */
-
-#define eth_io_copy_and_sum(a,b,c,d)   eth_copy_and_sum((a),(void __force *)(b),(c),(d))
 
 /* The following is junk needed for the arch-independent code but which
  * we never use in the CRIS port
index a8e1e6cb7cd02f816823b22261808e53bbb290bd..27bfeca1b981a5b8fa343a76796aa38ef8f8c90e 100644 (file)
@@ -30,8 +30,7 @@ static inline int waking_non_zero(struct semaphore *sem)
        unsigned long flags;
        int ret = 0;
 
-       local_save_flags(flags);
-       local_irq_disable();
+       local_irq_save(flags);
        if (read(&sem->waking) > 0) {
                dec(&sem->waking);
                ret = 1;
@@ -46,8 +45,7 @@ static inline int waking_non_zero_interruptible(struct semaphore *sem,
        int ret = 0;
        unsigned long flags;
 
-       local_save_flags(flags);
-       local_irq_disable();
+       local_irq_save(flags);
        if (read(&sem->waking) > 0) {
                dec(&sem->waking);
                ret = 1;
@@ -64,8 +62,7 @@ static inline int waking_non_zero_trylock(struct semaphore *sem)
         int ret = 1;
        unsigned long flags;
 
-       local_save_flags(flags);
-       local_irq_disable();
+       local_irq_save(flags);
        if (read(&sem->waking) <= 0)
                inc(&sem->count);
        else {
index b869f6161aaa1c73e770fb2f238eecc7894654d9..fea0e8d57cb51883f5d0c31202ef33ed089f863d 100644 (file)
@@ -44,8 +44,7 @@ static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int siz
   /* since Etrax doesn't have any atomic xchg instructions, we need to disable
      irq's (if enabled) and do it with move.d's */
   unsigned long flags,temp;
-  local_save_flags(flags); /* save flags, including irq enable bit */
-  local_irq_disable();             /* shut off irq's */
+  local_irq_save(flags); /* save flags, including irq enable bit and shut off irqs */
   switch (size) {
   case 1:
     *((unsigned char *)&temp) = x;
index 5ce1023c5d7b0b1389e41468c3af8a8eafbfcb0e..c9dbd4d43368c897c73408d5bfff4a5334351a0c 100644 (file)
@@ -40,24 +40,6 @@ struct termio {
 
 /* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
 
-/* line disciplines */
-#define N_TTY          0
-#define N_SLIP         1
-#define N_MOUSE                2
-#define N_PPP          3
-#define N_STRIP                4
-#define N_AX25         5
-#define N_X25          6       /* X.25 async */
-#define N_6PACK                7
-#define N_MASC         8       /* Reserved for Mobitex module <kaz@cafe.net> */
-#define N_R3964                9       /* Reserved for Simatic R3964 module */
-#define N_PROFIBUS_FDL 10      /* Reserved for Profibus <Dave@mvhi.com> */
-#define N_IRDA         11      /* Linux IR - http://irda.sourceforge.net/ */
-#define N_SMSBLOCK     12      /* SMS block mode - for talking to GSM data cards about SMS messages */
-#define N_HDLC         13      /* synchronous HDLC */
-#define N_SYNC_PPP     14      /* synchronous PPP */
-#define N_BT           15      /* bluetooth */
-
 #ifdef __KERNEL__
 
 /*     intr=^C         quit=^\         erase=del       kill=^U
index 8840cf95e8ddc175c0795bf74579b938caea8d38..a62fb58723758faeef174533a1e867356f0da697 100644 (file)
@@ -51,24 +51,6 @@ struct termio {
 
 /* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
 
-/* line disciplines */
-#define N_TTY          0
-#define N_SLIP         1
-#define N_MOUSE                2
-#define N_PPP          3
-#define N_STRIP                4
-#define N_AX25         5
-#define N_X25          6       /* X.25 async */
-#define N_6PACK                7
-#define N_MASC         8       /* Reserved for Mobitex module <kaz@cafe.net> */
-#define N_R3964                9       /* Reserved for Simatic R3964 module */
-#define N_PROFIBUS_FDL 10      /* Reserved for Profibus <Dave@mvhi.com> */
-#define N_IRDA         11      /* Linux IrDa - http://irda.sourceforge.net/ */
-#define N_SMSBLOCK     12      /* SMS block mode - for talking to GSM data cards about SMS messages */
-#define N_HDLC         13      /* synchronous HDLC */
-#define N_SYNC_PPP     14
-#define N_HCI          15  /* Bluetooth HCI UART */
-
 #ifdef __KERNEL__
 #include <asm-generic/termios.h>
 #endif
index 8078cbd2c0163878b44ace538a39422082b60cb2..30d8d33491dddd86466dc2df917270d8499c5415 100644 (file)
@@ -54,7 +54,7 @@
 #define __page_to_pfn(pg)                                      \
 ({     struct page *__pg = (pg);                               \
        int __sec = page_to_section(__pg);                      \
-       __pg - __section_mem_map_addr(__nr_to_section(__sec));  \
+       (unsigned long)(__pg - __section_mem_map_addr(__nr_to_section(__sec))); \
 })
 
 #define __pfn_to_page(pfn)                             \
index 3b41d2bb70da36bfd8d09a16dfb3f3e4581445b5..5e3dde2ee5adf37f5ccd62fa11f9b3878bc5a653 100644 (file)
@@ -36,7 +36,6 @@
 #define MADV_DOFORK    11              /* do inherit across fork */
 
 /* compatibility flags */
-#define MAP_ANON       MAP_ANONYMOUS
 #define MAP_FILE       0
 
 #endif
index e2319f992af298c7f8eaff5d0ec945256647b406..fb2925d08c491e21acff0564e960520eac178bb1 100644 (file)
@@ -49,24 +49,6 @@ struct termio {
 
 /* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
 
-/* line disciplines */
-#define N_TTY          0
-#define N_SLIP         1
-#define N_MOUSE                2
-#define N_PPP          3
-#define N_STRIP                4
-#define N_AX25         5
-#define N_X25          6       /* X.25 async */
-#define N_6PACK                7
-#define N_MASC         8       /* Reserved for Mobitex module <kaz@cafe.net> */
-#define N_R3964                9       /* Reserved for Simatic R3964 module */
-#define N_PROFIBUS_FDL 10      /* Reserved for Profibus <Dave@mvhi.com> */
-#define N_IRDA         11      /* Linux IrDa - http://irda.sourceforge.net/ */
-#define N_SMSBLOCK     12      /* SMS block mode - for talking to GSM data cards about SMS messages */
-#define N_HDLC         13      /* synchronous HDLC */
-#define N_SYNC_PPP     14
-#define N_HCI          15  /* Bluetooth HCI UART */
-
 #ifdef __KERNEL__
 
 /*
index c57441bb290502c449e4217684711a3b11c34a3f..4dd272331361c7eb747305366810fc92c28b3b08 100644 (file)
@@ -211,12 +211,12 @@ static __inline__ int atomic_sub_return(int i, atomic_t *v)
 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
 
 /**
- * atomic_add_unless - add unless the number is a given value
+ * atomic_add_unless - add unless the number is already a given value
  * @v: pointer of type atomic_t
  * @a: the amount to add to v...
  * @u: ...unless v is equal to u.
  *
- * Atomically adds @a to @v, so long as it was not @u.
+ * Atomically adds @a to @v, so long as @v was not already @u.
  * Returns non-zero if @v was not @u, and zero otherwise.
  */
 #define atomic_add_unless(v, a, u)                             \
index 1c780fa1e762e966a6f6255dbf0e5bbf4a326e65..273b50629357bf15955b6c433a9d95f19af9dfbe 100644 (file)
@@ -371,7 +371,7 @@ static inline unsigned long ffz(unsigned long word)
  *
  * This is defined the same way as
  * the libc and compiler builtin ffs routines, therefore
- * differs in spirit from the above ffz (man ffs).
+ * differs in spirit from the above ffz() (man ffs).
  */
 static inline int ffs(int x)
 {
@@ -388,7 +388,7 @@ static inline int ffs(int x)
  * fls - find last bit set
  * @x: the word to search
  *
- * This is defined the same way as ffs.
+ * This is defined the same way as ffs().
  */
 static inline int fls(int x)
 {
index 86ff5e83be2f6d45d1a209fb30be7eea2192a3df..59fe616933c4f9da58cf7aabb5136b6fac2cf6e8 100644 (file)
@@ -218,12 +218,6 @@ static inline void memcpy_toio(volatile void __iomem *dst, const void *src, int
  */
 #define __ISA_IO_base ((char __iomem *)(PAGE_OFFSET))
 
-/*
- * Again, i386 does not require mem IO specific function.
- */
-
-#define eth_io_copy_and_sum(a,b,c,d)           eth_copy_and_sum((a),(void __force *)(b),(c),(d))
-
 /*
  *     Cache management
  *
index 03f548536d6b1f421cec52c2438eb36802af2bd0..7c99678a8f863ab546568bb31ae25ac82c15c1f7 100644 (file)
@@ -39,24 +39,6 @@ struct termio {
 
 /* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
 
-/* line disciplines */
-#define N_TTY          0
-#define N_SLIP         1
-#define N_MOUSE                2
-#define N_PPP          3
-#define N_STRIP                4
-#define N_AX25         5
-#define N_X25          6       /* X.25 async */
-#define N_6PACK                7
-#define N_MASC         8       /* Reserved for Mobitex module <kaz@cafe.net> */
-#define N_R3964                9       /* Reserved for Simatic R3964 module */
-#define N_PROFIBUS_FDL 10      /* Reserved for Profibus <Dave@mvhi.com> */
-#define N_IRDA         11      /* Linux IR - http://irda.sourceforge.net/ */
-#define N_SMSBLOCK     12      /* SMS block mode - for talking to GSM data cards about SMS messages */
-#define N_HDLC         13      /* synchronous HDLC */
-#define N_SYNC_PPP     14      /* synchronous PPP */
-#define N_HCI          15  /* Bluetooth HCI UART */
-
 #ifdef __KERNEL__
 #include <linux/module.h>
 
index eef5133b9ce2a03b73b5f4c73f0e771a12b52aa8..70829ae3ad527729cf49e79be5dcd247d1fd9eb5 100644 (file)
@@ -54,10 +54,10 @@ extern struct movsl_mask {
  * This needs 33-bit arithmetic. We have a carry...
  */
 #define __range_ok(addr,size) ({ \
-       unsigned long flag,sum; \
+       unsigned long flag,roksum; \
        __chk_user_ptr(addr); \
        asm("addl %3,%1 ; sbbl %0,%0; cmpl %1,%4; sbbl $0,%0" \
-               :"=&r" (flag), "=r" (sum) \
+               :"=&r" (flag), "=r" (roksum) \
                :"1" (addr),"g" ((int)(size)),"rm" (current_thread_info()->addr_limit.seg)); \
        flag; })
 
index 42c95693240cfb618e7a47ef98656699291110c8..08750c2d3607b0f479e978cac60627d3dc7e0262 100644 (file)
@@ -46,24 +46,6 @@ struct termio {
 
 /* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
 
-/* line disciplines */
-#define N_TTY          0
-#define N_SLIP         1
-#define N_MOUSE                2
-#define N_PPP          3
-#define N_STRIP                4
-#define N_AX25         5
-#define N_X25          6       /* X.25 async */
-#define N_6PACK                7
-#define N_MASC         8       /* Reserved for Mobitex module <kaz@cafe.net> */
-#define N_R3964                9       /* Reserved for Simatic R3964 module */
-#define N_PROFIBUS_FDL 10      /* Reserved for Profibus <Dave@mvhi.com> */
-#define N_IRDA         11      /* Linux IR - http://irda.sourceforge.net/ */
-#define N_SMSBLOCK     12      /* SMS block mode - for talking to GSM data cards about SMS msgs */
-#define N_HDLC         13      /* synchronous HDLC */
-#define N_SYNC_PPP     14      /* synchronous PPP */
-#define N_HCI          15  /* Bluetooth HCI UART */
-
 # ifdef __KERNEL__
 
 /*     intr=^C         quit=^\         erase=del       kill=^U
index 4619ba5c372ed2941bf42d4cb1a6198f5bf1eafb..9a4a5d20160addb3f1e07db032b24f347d3d75ad 100644 (file)
@@ -1,8 +1,6 @@
 #ifndef _ASM_M32R_A_OUT_H
 #define _ASM_M32R_A_OUT_H
 
-/* orig : i386 2.4.18 */
-
 struct exec
 {
   unsigned long a_info;                /* Use macros N_MAGIC, etc for access */
index 06a83dc94648f9508782f5a14fef081256dfd9d0..81782c122da451b16fa2b650f8fbfc99d68ac3a2 100644 (file)
@@ -1,4 +1,3 @@
-/* $Id$ */
 /*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
index 9a56f661bdb35ac9a359441e59ec2db615e6b564..f77214eff1368e858e207bae6c73dd763bda5780 100644 (file)
@@ -1,8 +1,6 @@
 #ifndef _ASM_M32R_BUGS_H
 #define _ASM_M32R_BUGS_H
 
-/* $Id$ */
-
 /*
  * This is included by init/main.c to check for architecture-dependent bugs.
  *
index 3c0b9a2e03bc828b2e3eba1d738586d5bb8e1d8c..10b2c1d11614995f12e23632efa0efbc690a3d6b 100644 (file)
@@ -1,8 +1,6 @@
 #ifndef _ASM_M32R_BYTEORDER_H
 #define _ASM_M32R_BYTEORDER_H
 
-/* $Id$ */
-
 #include <asm/types.h>
 
 #if !defined(__STRICT_ANSI__) || defined(__KERNEL__)
index 9c2b2d9998bc9e13397cb28cc9d21f91e3a42214..40b3ee98193dbf5177299ee1cfb82c673e749a7d 100644 (file)
@@ -1,8 +1,6 @@
 #ifndef _ASM_M32R_CACHE_H
 #define _ASM_M32R_CACHE_H
 
-/* $Id$ */
-
 /* L1 cache line size */
 #define L1_CACHE_SHIFT         4
 #define L1_CACHE_BYTES         (1 << L1_CACHE_SHIFT)
index 56961a9511b2cea9a7f46b04fedc912799c2e05c..78587c958146f84991740a920b7178388b41202a 100644 (file)
@@ -67,4 +67,3 @@ do {                                                          \
        memcpy(dst, src, len)
 
 #endif /* _ASM_M32R_CACHEFLUSH_H */
-
index c19d927ff22d5bd54ff355af2d0196a18edc8846..7859d864f2c24cc3b7e664dc424f469229a3dbe0 100644 (file)
@@ -1,8 +1,6 @@
 #ifndef _ASM_M32R_CURRENT_H
 #define _ASM_M32R_CURRENT_H
 
-/* $Id$ */
-
 #include <linux/thread_info.h>
 
 struct task_struct;
@@ -15,4 +13,3 @@ static __inline__ struct task_struct *get_current(void)
 #define current        (get_current())
 
 #endif /* _ASM_M32R_CURRENT_H */
-
index f285eaee7d2739db9989931e22909af47c564412..164448d23850ec312843ba722d7962822f05444d 100644 (file)
@@ -1,8 +1,6 @@
 #ifndef _ASM_M32R_DELAY_H
 #define _ASM_M32R_DELAY_H
 
-/* $Id$ */
-
 /*
  * Copyright (C) 1993 Linus Torvalds
  *
index 7263b013b67ee031b8b136654d0a561756ecc667..52f6a22dd232c5ddc18af72d76431e4d0cf447f7 100644 (file)
@@ -1,8 +1,6 @@
 #ifndef _ASM_M32R_DMA_H
 #define _ASM_M32R_DMA_H
 
-/* $Id$ */
-
 #include <asm/io.h>
 
 /*
index 7a98520194a79cf0d6901e06dfb603b3399eae84..777149262aada2d5abfcc13a1659f3458b6ee77c 100644 (file)
@@ -1,9 +1,6 @@
 #ifndef _ASM_M32R_ERRNO_H
 #define _ASM_M32R_ERRNO_H
 
-/* $Id$ */
-
 #include <asm-generic/errno.h>
 
 #endif /* _ASM_M32R_ERRNO_H */
-
index c82ebe8f250d6fadc84b913a1a48fc9af13bceab..4672a49e8760546f3b835d627359b9c0d62fd418 100644 (file)
@@ -1,8 +1,6 @@
 #ifndef _ASM_M32R_IDE_H
 #define _ASM_M32R_IDE_H
 
-/* $Id$ */
-
 /*
  *  linux/include/asm-m32r/ide.h
  *
@@ -15,6 +13,7 @@
 
 #ifdef __KERNEL__
 
+#include <asm/m32r.h>
 
 #ifndef MAX_HWIFS
 # ifdef CONFIG_BLK_DEV_IDEPCI
@@ -24,9 +23,6 @@
 # endif
 #endif
 
-#include <asm/m32r.h>
-
-
 #define IDE_ARCH_OBSOLETE_DEFAULTS
 
 static __inline__ int ide_default_irq(unsigned long base)
index b3508292246a65c8918c4679a196f06527d24e04..d23cfc45738a0c4bf3dc193f85114e811dfbda29 100644 (file)
@@ -1,10 +1,6 @@
 #ifndef __ARCH_M32R_IOCTLS_H__
 #define __ARCH_M32R_IOCTLS_H__
 
-/* $Id$ */
-
-/* orig : i386 2.5.67 */
-
 #include <asm/ioctl.h>
 
 /* 0x54 is just a magic number to make these relatively unique ('T') */
@@ -85,4 +81,3 @@
 #define TIOCSER_TEMT    0x01   /* Transmitter physically empty */
 
 #endif /* __ARCH_M32R_IOCTLS_H__ */
-
index 7c77fb0b1467291be0107d2cca24519c50570f8a..8d2d7c8ffdb02cf2518cf98e01b402fc749896d6 100644 (file)
@@ -1,10 +1,6 @@
 #ifndef _ASM_M32R_IPCBUF_H
 #define _ASM_M32R_IPCBUF_H
 
-/* $Id$ */
-
-/* orig : i386 2.4.18 */
-
 /*
  * The ipc64_perm structure for m32r architecture.
  * Note extra padding because this structure is passed back and forth
index 0524d89edb0f4709de3bdc42c5ecf00438f46d5e..fa94dc6410ea1129083a401f01558e5028e05c23 100644 (file)
@@ -1,9 +1,6 @@
 #ifndef __M32R_KMAP_TYPES_H
 #define __M32R_KMAP_TYPES_H
 
-/* Dummy header just to define km_type. */
-
-
 #ifdef CONFIG_DEBUG_HIGHMEM
 # define D(n) __KM_FENCE_##n ,
 #else
@@ -30,4 +27,3 @@ D(13) KM_TYPE_NR
 #undef D
 
 #endif /* __M32R_KMAP_TYPES_H */
-
index cbdbc5891445e25e88658f38bb5a3348eaf57a13..2dc89d68b6d943b4aec5b1366825d52eb4aad565 100644 (file)
@@ -1,3 +1,6 @@
+#ifndef _M32104UT_M32104UT_PLD_H
+#define _M32104UT_M32104UT_PLD_H
+
 /*
  * include/asm-m32r/m32104ut/m32104ut_pld.h
  *
  * this archive for more details.
  */
 
-#ifndef _M32104UT_M32104UT_PLD_H
-#define _M32104UT_M32104UT_PLD_H
-
-
 #if defined(CONFIG_PLAT_M32104UT)
 #define PLD_PLAT_BASE          0x02c00000
 #else
@@ -35,7 +34,7 @@
 #define __reg8
 #define __reg16
 #define __reg32
-#endif /* __ASSEMBLY__ */
+#endif /* __ASSEMBLY__ */
 
 /* CFC */
 #define        PLD_CFRSTCR             __reg16(PLD_BASE + 0x0000)
 #define PLD_SCTXB              __reg16(PLD_BASE + 0x3800c)
 #define PLD_SCRXB              __reg16(PLD_BASE + 0x3800e)
 
-#endif /* _M32104UT_M32104UT_PLD_H */
+#endif /* _M32104UT_M32104UT_PLD_H */
index f1e47ae1f891da668f3a5c1775ffc2faf9af6c84..aae810a4fb2c8bf480ccc5ab145d81d3813afac4 100644 (file)
@@ -1,3 +1,6 @@
+#ifndef _M32700UT_M32700UT_LAN_H
+#define _M32700UT_M32700UT_LAN_H
+
 /*
  * include/asm-m32r/m32700ut/m32700ut_lan.h
  *
@@ -8,14 +11,8 @@
  * This file is subject to the terms and conditions of the GNU General
  * Public License.  See the file "COPYING" in the main directory of
  * this archive for more details.
- *
- * $Id$
  */
 
-#ifndef _M32700UT_M32700UT_LAN_H
-#define _M32700UT_M32700UT_LAN_H
-
-
 #ifndef __ASSEMBLY__
 /*
  * C functions use non-cache address.
@@ -23,7 +20,7 @@
 #define M32700UT_LAN_BASE      (0x10000000 /* + NONCACHE_OFFSET */)
 #else
 #define M32700UT_LAN_BASE      (0x10000000 + NONCACHE_OFFSET)
-#endif /* __ASSEMBLY__ */
+#endif /* __ASSEMBLY__ */
 
 /* ICU
  *  ICUISTS:   status register
 #define PLDI2CSTS_BB           0x00000010
 #define PLDI2CSTS_NOACK                0x00000001      /* 0:ack, 1:noack */
 
-#endif /* _M32700UT_M32700UT_LAN_H */
+#endif /* _M32700UT_M32700UT_LAN_H */
index e41c4aa48b4cba16d10f8a2bab9a9feab574d3c9..4c2489079788eaabb26994b4d47fdf4c0919e789 100644 (file)
@@ -1,3 +1,6 @@
+#ifndef _M32700UT_M32700UT_LCD_H
+#define _M32700UT_M32700UT_LCD_H
+
 /*
  * include/asm-m32r/m32700ut/m32700ut_lcd.h
  *
@@ -8,14 +11,8 @@
  * This file is subject to the terms and conditions of the GNU General
  * Public License.  See the file "COPYING" in the main directory of
  * this archive for more details.
- *
- * $Id$
  */
 
-#ifndef _M32700UT_M32700UT_LCD_H
-#define _M32700UT_M32700UT_LCD_H
-
-
 #ifndef __ASSEMBLY__
 /*
  * C functions use non-cache address.
@@ -23,7 +20,7 @@
 #define M32700UT_LCD_BASE      (0x10000000 /* + NONCACHE_OFFSET */)
 #else
 #define M32700UT_LCD_BASE      (0x10000000 + NONCACHE_OFFSET)
-#endif /* __ASSEMBLY__ */
+#endif /* __ASSEMBLY__ */
 
 /*
  * ICU
@@ -55,4 +52,4 @@
 #define M32700UT_LCD_ICUCR19   __reg16(M32700UT_LCD_BASE + 0x300036)
 #define M32700UT_LCD_ICUCR21   __reg16(M32700UT_LCD_BASE + 0x30003a)
 
-#endif /* _M32700UT_M32700UT_LCD_H */
+#endif /* _M32700UT_M32700UT_LCD_H */
index a48c22c978ca14b9305cd3403b510c1d8392a727..d39121279a1a411ce4862268bca40e5daf42c574 100644 (file)
@@ -1,3 +1,6 @@
+#ifndef _M32700UT_M32700UT_PLD_H
+#define _M32700UT_M32700UT_PLD_H
+
 /*
  * include/asm-m32r/m32700ut/m32700ut_pld.h
  *
@@ -8,14 +11,8 @@
  * This file is subject to the terms and conditions of the GNU General
  * Public License.  See the file "COPYING" in the main directory of
  * this archive for more details.
- *
- * $Id$
  */
 
-#ifndef _M32700UT_M32700UT_PLD_H
-#define _M32700UT_M32700UT_PLD_H
-
-
 #if defined(CONFIG_PLAT_M32700UT_Alpha)
 #define PLD_PLAT_BASE          0x08c00000
 #elif defined(CONFIG_PLAT_M32700UT) || defined(CONFIG_PLAT_USRV)
@@ -37,7 +34,7 @@
 #define __reg8
 #define __reg16
 #define __reg32
-#endif /* __ASSEMBLY__ */
+#endif /* __ASSEMBLY__ */
 
 /* CFC */
 #define        PLD_CFRSTCR             __reg16(PLD_BASE + 0x0000)
 #define PLD_SCTXB              __reg16(PLD_BASE + 0x3800c)
 #define PLD_SCRXB              __reg16(PLD_BASE + 0x3800e)
 
-#endif /* _M32700UT_M32700UT_PLD.H */
+#endif /* _M32700UT_M32700UT_PLD.H */
index 56a2b12f2bfcfea5eeab087e6d67062e5cb6af80..2624c9db72555196c0926cded6369e77889695dd 100644 (file)
@@ -1,18 +1,17 @@
+#ifndef _MAPPI2_PLD_H
+#define _MAPPI2_PLD_H
+
 /*
  * include/asm-m32r/mappi2/mappi2_pld.h
  *
  * Definitions for Extended IO Logic on MAPPI2 board.
- *  based on m32700ut_pld.h by
+ *  based on m32700ut_pld.h
  *
  * This file is subject to the terms and conditions of the GNU General
  * Public License.  See the file "COPYING" in the main directory of
  * this archive for more details.
- *
  */
 
-#ifndef _MAPPI2_PLD_H
-#define _MAPPI2_PLD_H
-
 #ifndef __ASSEMBLY__
 /* FIXME:
  * Some C functions use non-cache address, so can't define non-cache address.
@@ -26,7 +25,7 @@
 #define __reg8
 #define __reg16
 #define __reg32
-#endif /* __ASSEMBLY__ */
+#endif /* __ASSEMBLY__ */
 
 /* CFC */
 #define        PLD_CFRSTCR             __reg16(PLD_BASE + 0x0000)
 
 #endif
 
-#endif /* _MAPPI2_PLD.H */
+#endif /* _MAPPI2_PLD.H */
index 92f10defaef8c7d5b1b93204eee3453240f4ce45..451c40ee70af88cd3bd648486d9e826bb07e11d0 100644 (file)
@@ -1,3 +1,6 @@
+#ifndef _MAPPI3_PLD_H
+#define _MAPPI3_PLD_H
+
 /*
  * include/asm-m32r/mappi3/mappi3_pld.h
  *
@@ -7,12 +10,8 @@
  * This file is subject to the terms and conditions of the GNU General
  * Public License.  See the file "COPYING" in the main directory of
  * this archive for more details.
- *
  */
 
-#ifndef _MAPPI3_PLD_H
-#define _MAPPI3_PLD_H
-
 #ifndef __ASSEMBLY__
 /* FIXME:
  * Some C functions use non-cache address, so can't define non-cache address.
@@ -26,7 +25,7 @@
 #define __reg8
 #define __reg16
 #define __reg32
-#endif /* __ASSEMBLY__ */
+#endif /* __ASSEMBLY__ */
 
 /* CFC */
 #define        PLD_CFRSTCR             __reg16(PLD_BASE + 0x0000)
 /* Reset Control */
 #define PLD_REBOOT             __reg16(PLD_BASE + 0x38000)
 
-#endif /* _MAPPI3_PLD.H */
+#endif /* _MAPPI3_PLD.H */
index 755601d053ccfc254d58c54d2a25357f0e68296d..aa1b7bf84f5115afabcb6a1f890e082a17ca3ab4 100644 (file)
@@ -7,7 +7,6 @@
 #include <asm/io.h>
 
 #ifndef RTC_PORT
-// #define RTC_PORT(x) (0x70 + (x))
 #define RTC_PORT(x)    ((x))
 #define RTC_ALWAYS_BCD 1       /* RTC operates in binary mode */
 #endif
@@ -26,7 +25,5 @@ outb_p((val),RTC_PORT(1)); \
 })
 
 #define RTC_IRQ 8
-#if 0
-#endif
 
 #endif /* _ASM_MC146818RTC_H */
index 695a860c024fb0bd6c286f5739516563af831795..516a8973b1302c177643915c35ee248f5631e987 100644 (file)
@@ -3,8 +3,6 @@
 
 #include <asm-generic/mman.h>
 
-/* orig : i386 2.6.0-test6 */
-
 #define MAP_GROWSDOWN  0x0100          /* stack-like segment */
 #define MAP_DENYWRITE  0x0800          /* ETXTBSY */
 #define MAP_EXECUTABLE 0x1000          /* mark it as an executable */
index cf3f6d78ac66ab13bc056b2f01f9389ad71a8ea5..d9bd724479cf0a078ea9b92fa4f73045468a8234 100644 (file)
@@ -1,13 +1,14 @@
 #ifndef _ASM_M32R_MMU_H
 #define _ASM_M32R_MMU_H
 
-
 #if !defined(CONFIG_MMU)
+
 typedef struct {
        struct vm_list_struct   *vmlist;
        unsigned long           end_brk;
 } mm_context_t;
-#else
+
+#else /* CONFIG_MMU */
 
 /* Default "unsigned long" context */
 #ifndef CONFIG_SMP
@@ -16,5 +17,6 @@ typedef unsigned long mm_context_t;
 typedef unsigned long mm_context_t[NR_CPUS];
 #endif
 
-#endif  /* CONFIG_MMU */
-#endif  /* _ASM_M32R_MMU_H */
+#endif /* CONFIG_MMU */
+
+#endif /* _ASM_M32R_MMU_H */
index 542302eb6bcbf97d9e1bd87474c4ce3bbd6ee145..1f40d4a0acf1a4acd6d0a3764f5b9f09b9439a78 100644 (file)
@@ -1,9 +1,7 @@
 #ifndef _ASM_M32R_MMU_CONTEXT_H
 #define _ASM_M32R_MMU_CONTEXT_H
-
 #ifdef __KERNEL__
 
-
 #include <asm/m32r.h>
 
 #define MMU_CONTEXT_ASID_MASK      (0x000000FF)
@@ -11,7 +9,6 @@
 #define MMU_CONTEXT_FIRST_VERSION  (0x00000100)
 #define NO_CONTEXT                 (0x00000000)
 
-
 #ifndef __ASSEMBLY__
 
 #include <asm/atomic.h>
@@ -147,7 +144,7 @@ static inline void switch_mm(struct mm_struct *prev,
 #define activate_mm(prev, next)        \
        switch_mm((prev), (next), NULL)
 
-#else
+#else /* not CONFIG_MMU */
 #define get_mmu_context(mm)             do { } while (0)
 #define init_new_context(tsk,mm)        (0)
 #define destroy_context(mm)             do { } while (0)
@@ -158,11 +155,9 @@ static inline void switch_mm(struct mm_struct *prev,
 #define deactivate_mm(mm,tsk)           do { } while (0)
 #define activate_mm(prev,next)          do { } while (0)
 #define enter_lazy_tlb(mm,tsk)          do { } while (0)
-#endif /* CONFIG_MMU */
-
+#endif /* not CONFIG_MMU */
 
 #endif /* not __ASSEMBLY__ */
 
 #endif /* __KERNEL__ */
-
 #endif /* _ASM_M32R_MMU_CONTEXT_H */
index 3f2541c92a7b06068c9debcb0256ec4864ae1a9c..eb73ee01121525c3a41be140ccf33dd9ee276d13 100644 (file)
@@ -1,8 +1,6 @@
 #ifndef _ASM_M32R_MODULE_H
 #define _ASM_M32R_MODULE_H
 
-/* $Id$ */
-
 struct mod_arch_specific { };
 
 #define Elf_Shdr       Elf32_Shdr
@@ -10,4 +8,3 @@ struct mod_arch_specific { };
 #define Elf_Ehdr       Elf32_Ehdr
 
 #endif /* _ASM_M32R_MODULE_H */
-
index 852ff52af4c2efb30668ecbf5828725eaaa9763c..0d5a877b813e4390c24edfe5e84ca007eb4df660 100644 (file)
@@ -1,10 +1,6 @@
 #ifndef _ASM_M32R_MSGBUF_H
 #define _ASM_M32R_MSGBUF_H
 
-/* $Id$ */
-
-/* orig : i386 2.4.18 */
-
 /*
  * The msqid64_ds structure for m32r architecture.
  * Note extra padding because this structure is passed back and forth
index 7172d3d2e2603aeacc839de4e6cff97637b75aae..210f8056b80532ca8e6a740b5e2895108006d0c9 100644 (file)
@@ -1,10 +1,6 @@
 #ifndef _ASM_M32R_NAMEI_H
 #define _ASM_M32R_NAMEI_H
 
-/* $Id$ */
-
-/* orig : i386 2.4.18 */
-
 /*
  * linux/include/asm-m32r/namei.h
  *
index f53e10187c03f377bf3504b7fb44b820453c5a3c..a5f18dd1ab20b4d1c077d95aff19e057eb51d6cf 100644 (file)
@@ -1,3 +1,6 @@
+#ifndef _OPSPUT_OPSPUT_LAN_H
+#define _OPSPUT_OPSPUT_LAN_H
+
 /*
  * include/asm-m32r/opsput/opsput_lan.h
  *
@@ -8,14 +11,8 @@
  * This file is subject to the terms and conditions of the GNU General
  * Public License.  See the file "COPYING" in the main directory of
  * this archive for more details.
- *
- * $Id: opsput_lan.h,v 1.1 2004/07/27 06:54:20 sakugawa Exp $
  */
 
-#ifndef _OPSPUT_OPSPUT_LAN_H
-#define _OPSPUT_OPSPUT_LAN_H
-
-
 #ifndef __ASSEMBLY__
 /*
  * C functions use non-cache address.
@@ -23,7 +20,7 @@
 #define OPSPUT_LAN_BASE        (0x10000000 /* + NONCACHE_OFFSET */)
 #else
 #define OPSPUT_LAN_BASE        (0x10000000 + NONCACHE_OFFSET)
-#endif /* __ASSEMBLY__ */
+#endif /* __ASSEMBLY__ */
 
 /* ICU
  *  ICUISTS:   status register
@@ -52,4 +49,4 @@
 #define OPSPUT_LAN_ICUCR1      __reg16(OPSPUT_LAN_BASE + 0xc0010)
 #define OPSPUT_LAN_ICUCR3      __reg16(OPSPUT_LAN_BASE + 0xc0014)
 
-#endif /* _OPSPUT_OPSPUT_LAN_H */
+#endif /* _OPSPUT_OPSPUT_LAN_H */
index 99f296e1b61b6ee4bc4da2bbaaba0a3eefcdb63e..369c9f0832a6a5dfff94acc871eea2dfc31452bb 100644 (file)
@@ -1,3 +1,6 @@
+#ifndef _OPSPUT_OPSPUT_LCD_H
+#define _OPSPUT_OPSPUT_LCD_H
+
 /*
  * include/asm-m32r/opsput/opsput_lcd.h
  *
@@ -8,14 +11,8 @@
  * This file is subject to the terms and conditions of the GNU General
  * Public License.  See the file "COPYING" in the main directory of
  * this archive for more details.
- *
- * $Id: opsput_lcd.h,v 1.1 2004/07/27 06:54:20 sakugawa Exp $
  */
 
-#ifndef _OPSPUT_OPSPUT_LCD_H
-#define _OPSPUT_OPSPUT_LCD_H
-
-
 #ifndef __ASSEMBLY__
 /*
  * C functions use non-cache address.
@@ -23,7 +20,7 @@
 #define OPSPUT_LCD_BASE        (0x10000000 /* + NONCACHE_OFFSET */)
 #else
 #define OPSPUT_LCD_BASE        (0x10000000 + NONCACHE_OFFSET)
-#endif /* __ASSEMBLY__ */
+#endif /* __ASSEMBLY__ */
 
 /*
  * ICU
@@ -55,4 +52,4 @@
 #define OPSPUT_LCD_ICUCR19     __reg16(OPSPUT_LCD_BASE + 0x300036)
 #define OPSPUT_LCD_ICUCR21     __reg16(OPSPUT_LCD_BASE + 0x30003a)
 
-#endif /* _OPSPUT_OPSPUT_LCD_H */
+#endif /* _OPSPUT_OPSPUT_LCD_H */
index a8d6452076f1576dd36c544082c4dcdc56b8056b..3f11ea1aac2d3605dc854be2e596e3b2490ed719 100644 (file)
@@ -1,3 +1,6 @@
+#ifndef _OPSPUT_OPSPUT_PLD_H
+#define _OPSPUT_OPSPUT_PLD_H
+
 /*
  * include/asm-m32r/opsput/opsput_pld.h
  *
@@ -8,14 +11,8 @@
  * This file is subject to the terms and conditions of the GNU General
  * Public License.  See the file "COPYING" in the main directory of
  * this archive for more details.
- *
- * $Id: opsput_pld.h,v 1.1 2004/07/27 06:54:20 sakugawa Exp $
  */
 
-#ifndef _OPSPUT_OPSPUT_PLD_H
-#define _OPSPUT_OPSPUT_PLD_H
-
-
 #define PLD_PLAT_BASE          0x1cc00000
 
 #ifndef __ASSEMBLY__
@@ -31,7 +28,7 @@
 #define __reg8
 #define __reg16
 #define __reg32
-#endif /* __ASSEMBLY__ */
+#endif /* __ASSEMBLY__ */
 
 /* CFC */
 #define        PLD_CFRSTCR             __reg16(PLD_BASE + 0x0000)
 #define PLD_SCTXB              __reg16(PLD_BASE + 0x3800c)
 #define PLD_SCRXB              __reg16(PLD_BASE + 0x3800e)
 
-#endif /* _OPSPUT_OPSPUT_PLD.H */
+#endif /* _OPSPUT_OPSPUT_PLD.H */
index 404a4c24007b3b4f5729c86ae90ba5fce8f8e50f..6f6ecf7d14a3550bafd331892704b75a0c51fe8c 100644 (file)
@@ -1,7 +1,6 @@
 #ifndef _ASM_M32R_PAGE_H
 #define _ASM_M32R_PAGE_H
 
-
 /* PAGE_SHIFT determines the page size */
 #define PAGE_SHIFT     12
 #define PAGE_SIZE      (1UL << PAGE_SHIFT)
@@ -57,9 +56,6 @@ typedef struct { unsigned long pgprot; } pgprot_t;
  * and CONFIG_HIGHMEM64G options in the kernel configuration.
  */
 
-
-/* This handles the memory map.. */
-
 #define __MEMORY_START  CONFIG_MEMORY_START
 #define __MEMORY_SIZE   CONFIG_MEMORY_SIZE
 
@@ -92,4 +88,3 @@ typedef struct { unsigned long pgprot; } pgprot_t;
 
 #endif /* __KERNEL__ */
 #endif /* _ASM_M32R_PAGE_H */
-
index 750b938ccb52a5b5459bf254601ce7eaaeeb66bd..3e14026e39cdaf2a479d1a09dabaf9c2d6b514b8 100644 (file)
@@ -1,10 +1,6 @@
 #ifndef _ASM_M32R_PARAM_H
 #define _ASM_M32R_PARAM_H
 
-/* $Id$ */
-
-/* orig : i386 2.5.67 */
-
 #ifdef __KERNEL__
 # define HZ            100             /* Internal kernel timer frequency */
 # define USER_HZ       100             /* .. some user interfaces are in "ticks" */
index 00d7b6f39a33fac151cf1b9ca28877e296901762..fe785d167db6142d2af839368874bca5665254ec 100644 (file)
@@ -1,8 +1,6 @@
 #ifndef _ASM_M32R_PCI_H
 #define _ASM_M32R_PCI_H
 
-/* $Id$ */
-
 #include <asm-generic/pci.h>
 
 #define PCI_DMA_BUS_IS_PHYS    (1)
index e09a86c3cadf44bf4266eece984c47dbf390b804..943ba63c1ebcf7bb365f541b75b05828429c6e54 100644 (file)
@@ -1,8 +1,6 @@
 #ifndef _ASM_M32R_PGALLOC_H
 #define _ASM_M32R_PGALLOC_H
 
-/* $Id$ */
-
 #include <linux/mm.h>
 
 #include <asm/io.h>
@@ -74,4 +72,3 @@ static __inline__ void pte_free(struct page *pte)
 #define check_pgt_cache()      do { } while (0)
 
 #endif /* _ASM_M32R_PGALLOC_H */
-
index 84152760e0b56e90847b9eb49c3772459afbdc09..750925726a10bc73b14b2dcc7f693a6ed141c24a 100644 (file)
@@ -1,9 +1,7 @@
 #ifndef _ASM_M32R_PGTABLE_2LEVEL_H
 #define _ASM_M32R_PGTABLE_2LEVEL_H
-
 #ifdef __KERNEL__
 
-
 /*
  * traditional M32R two-level paging structure:
  */
@@ -77,5 +75,4 @@ static inline pmd_t *pmd_offset(pgd_t * dir, unsigned long address)
 #define pgoff_to_pte(off)      ((pte_t) { (((off) & 0xef) << 2) | (((off) >> 7) << 10) | _PAGE_FILE })
 
 #endif /* __KERNEL__ */
-
 #endif /* _ASM_M32R_PGTABLE_2LEVEL_H */
index 47e7e85a3dc3f26b26dff2ca0d471752e1bd21e8..1caac65d208f244b327f9ea612562e5ebccc6c4b 100644 (file)
@@ -1,10 +1,6 @@
 #ifndef _ASM_M32R_POSIX_TYPES_H
 #define _ASM_M32R_POSIX_TYPES_H
 
-/* $Id$ */
-
-/* orig : i386, sh 2.4.18 */
-
 /*
  * This file is generally used by user-level software, so you need to
  * be a little careful about namespace pollution etc.  Also, we cannot
index 6b2b837c59782b910e3d679a3678f78296a4286f..0340633f3f4d23def1c11f78fa4184faa4df227f 100644 (file)
@@ -1,10 +1,6 @@
-/* $Id: rtc.h,v 1.1.1.1 2004/03/25 04:29:22 hitoshiy Exp $ */
-
 #ifndef __RTC_H__
 #define __RTC_H__
 
-
-
    /* Dallas DS1302 clock/calendar register numbers. */
 #  define RTC_SECONDS      0
 #  define RTC_MINUTES      1
index 09a10e43bf0f3bc7d3ae11a16f2a068262b0b0c5..c2de96cb69ed1940cf58510bfa6ec48977abbc66 100644 (file)
@@ -1,8 +1,6 @@
 #ifndef _ASM_M32R_SCATTERLIST_H
 #define _ASM_M32R_SCATTERLIST_H
 
-/* $Id$ */
-
 struct scatterlist {
     char *  address;    /* Location data is to be transferred to, NULL for
                          * highmem page */
index 6b969e53b8063b39a166ce8a041cf40fddb914ad..5e5d21c4908aed4efd88452abfe5a94032b8b1a6 100644 (file)
@@ -5,4 +5,3 @@
 #include <asm-generic/sections.h>
 
 #endif /* _M32R_SECTIONS_H */
-
index e45db68e6c2d79f751211c0dde863afc9e5cd45b..42b11aeb3249e630403fc0cb8702711624fd536a 100644 (file)
@@ -1,10 +1,6 @@
 #ifndef _ASM_M32R_SEGMENT_H
 #define _ASM_M32R_SEGMENT_H
 
-/* $Id$ */
-
-/* orig : i386 (2.4.18) */
-
 #define __KERNEL_CS    0x10
 #define __KERNEL_DS    0x18
 
index e69018e6ff711435ba9a9df5138ab491722d3778..c9873d6890e283cfd035a1d5be8b3e50981dc1ba 100644 (file)
@@ -1,10 +1,6 @@
 #ifndef _ASM_M32R_SEMBUF_H
 #define _ASM_M32R_SEMBUF_H
 
-/* $Id$ */
-
-/* orig : i386 2.4.18 */
-
 /*
  * The semid64_ds structure for m32r architecture.
  * Note extra padding because this structure is passed back and forth
index 6a0b32202d4e0ee901b3c93f44dcd87d7761a738..c637ab99239452f01ecd0ba853f7935f7299229a 100644 (file)
@@ -1,3 +1,6 @@
+#ifndef _ASM_M32R_SETUP_H
+#define _ASM_M32R_SETUP_H
+
 /*
  * This is set up by the setup-routine at boot-time
  */
@@ -32,3 +35,4 @@ extern unsigned long memory_end;
 
 #endif  /*  __KERNEL__  */
 
+#endif /* _ASM_M32R_SETUP_H */
index b84e897fa87bf6c41bf37ee62a5e43b1fd7f8363..b0cdf0aa7d654ca4a7aa8c0531323eed2c91eeaf 100644 (file)
@@ -1,10 +1,6 @@
 #ifndef _ASM_M32R_SHMBUF_H
 #define _ASM_M32R_SHMBUF_H
 
-/* $Id$ */
-
-/* orig : i386 2.4.18 */
-
 /*
  * The shmid64_ds structure for M32R architecture.
  * Note extra padding because this structure is passed back and forth
index db0019ba955d4458f64164f056cf2f1f7e15317a..35986d81a5285fd5aa23858513cf21b30e922ba7 100644 (file)
@@ -1,8 +1,6 @@
 #ifndef _ASM_M32R_SHMPARAM_H
 #define _ASM_M32R_SHMPARAM_H
 
-/* $Id$ */
-
 #define        SHMLBA PAGE_SIZE                 /* attach addr a multiple of this */
 
 #endif /* _ASM_M32R_SHMPARAM_H */
index 62537dc4dec903cd3f9cfdc1cb08f578df8c24c0..da4a9c36d09b9e224db4de75ff2f765acfb9cc64 100644 (file)
@@ -1,9 +1,6 @@
 #ifndef _ASM_M32R_SIGCONTEXT_H
 #define _ASM_M32R_SIGCONTEXT_H
 
-/* $Id$ */
-
-
 struct sigcontext {
        /* CPU registers */
        /* Saved main processor registers. */
index 482202f2e77fac5425fe2d8fba8be28d61ca188e..7d9cd9ebfd0e50c8d700b32f766835c61ab5fab8 100644 (file)
@@ -1,8 +1,6 @@
 #ifndef _M32R_SIGINFO_H
 #define _M32R_SIGINFO_H
 
-/* $Id$ */
-
 #include <asm-generic/siginfo.h>
 
 #endif /* _M32R_SIGINFO_H */
index 65423bed32b1cadecac621de7f19b460d22c793a..937258686ba54982ebb7b94149a513ba21090241 100644 (file)
@@ -1,10 +1,6 @@
 #ifndef _ASM_M32R_SIGNAL_H
 #define _ASM_M32R_SIGNAL_H
 
-/* $Id$ */
-
-/* orig : i386 2.4.18 */
-
 #include <linux/types.h>
 #include <linux/time.h>
 #include <linux/compiler.h>
index 650d2558c304c1e271e034c54246e8203f6bc3e5..abd937ac5239ae91503275cea548652bf020db23 100644 (file)
@@ -1,9 +1,6 @@
 #ifndef _ASM_M32R_SMP_H
 #define _ASM_M32R_SMP_H
 
-/* $Id$ */
-
-
 #ifdef CONFIG_SMP
 #ifndef __ASSEMBLY__
 
index 147a118442ac4fbd26d8af977a64533befe56842..f89962e231fedf296af9c4d3e76c55dc47f1da13 100644 (file)
@@ -1,8 +1,6 @@
 #ifndef _ASM_M32R_SOCKIOS_H
 #define _ASM_M32R_SOCKIOS_H
 
-/* $Id$ */
-
 /* Socket-level I/O control calls. */
 #define FIOSETOWN      0x8901
 #define SIOCSPGRP      0x8902
index 7e9941c45f4022e6ce30107de393a08e58c1eb92..83f52105c0e4a33f5ab282a78f9c25ce6f05a3bb 100644 (file)
@@ -20,4 +20,4 @@ typedef struct {
 
 #define __RAW_RW_LOCK_UNLOCKED         { RW_LOCK_BIAS }
 
-#endif
+#endif /* _ASM_M32R_SPINLOCK_TYPES_H */
index 05748fef4c8e232cf8069fa0eec7d62515a29313..da4518f82d6d31d71609d7a670924cbe79c88c2a 100644 (file)
@@ -1,10 +1,6 @@
 #ifndef _ASM_M32R_STAT_H
 #define _ASM_M32R_STAT_H
 
-/* $Id$ */
-
-/* orig : i386 2.4.18 */
-
 #include <asm/byteorder.h>
 
 struct __old_kernel_stat {
index cb54bcc2e677800bed20d8df4aced75e76e20d25..e61e2b0bfc1f4c423a84ca6e6c6b6de2905d4e24 100644 (file)
@@ -1,8 +1,6 @@
 #ifndef _ASM_M32R_STRING_H
 #define _ASM_M32R_STRING_H
 
-/* $Id$ */
-
 #define  __HAVE_ARCH_STRLEN
 extern size_t strlen(const char * s);
 
index d8d4b2c7a7d459400e4949203e68e4f39e70c28c..25f316f2b78dc8420efb405e94465fc56c81236f 100644 (file)
@@ -1,11 +1,8 @@
 #ifndef _ASM_M32R_SYSCALL_H
 #define _ASM_M32R_SYSCALL_H
 
-/* $Id$ */
-
 /* Definitions for the system call vector.  */
 #define SYSCALL_VECTOR          "2"
 #define SYSCALL_VECTOR_ADDRESS  "0xa0"
 
 #endif /* _ASM_M32R_SYSCALL_H */
-
index 4ce0619f6989024855782484766eb0adfa88cc78..99ee09889ff78578ca1c913e1c75a1ce4b65f319 100644 (file)
@@ -339,4 +339,4 @@ __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size)
 
 #define arch_align_stack(x) (x)
 
-#endif  /* _ASM_M32R_SYSTEM_H */
+#endif /* _ASM_M32R_SYSTEM_H */
index faf2bd0504c15153b84baa49ab3c507bdb738184..e402641dfbad20d8b2f5ac13711dcbf3fda54a2d 100644 (file)
@@ -1,8 +1,6 @@
 #ifndef _ASM_M32R_TERMBITS_H
 #define _ASM_M32R_TERMBITS_H
 
-/* $Id$ */
-
 #include <linux/posix_types.h>
 
 typedef unsigned char  cc_t;
@@ -184,4 +182,4 @@ struct ktermios {
 #define        TCSADRAIN       1
 #define        TCSAFLUSH       2
 
-#endif  /* _ASM_M32R_TERMBITS_H */
+#endif /* _ASM_M32R_TERMBITS_H */
index fc99d2e178d8c3c7878288e7ab09a2c2b1dcba1b..4943dd8db44de0e854a970ab6e92d54ccc2fb7d7 100644 (file)
@@ -1,8 +1,6 @@
 #ifndef _M32R_TERMIOS_H
 #define _M32R_TERMIOS_H
 
-/* orig : i386 2.6.0-test5 */
-
 #include <asm/termbits.h>
 #include <asm/ioctls.h>
 
@@ -41,24 +39,6 @@ struct termio {
 
 /* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
 
-/* line disciplines */
-#define N_TTY          0
-#define N_SLIP         1
-#define N_MOUSE                2
-#define N_PPP          3
-#define N_STRIP                4
-#define N_AX25         5
-#define N_X25          6       /* X.25 async */
-#define N_6PACK                7
-#define N_MASC         8       /* Reserved for Mobitex module <kaz@cafe.net> */
-#define N_R3964                9       /* Reserved for Simatic R3964 module */
-#define N_PROFIBUS_FDL 10      /* Reserved for Profibus <Dave@mvhi.com> */
-#define N_IRDA         11      /* Linux IR - http://irda.sourceforge.net/ */
-#define N_SMSBLOCK     12      /* SMS block mode - for talking to GSM data cards about SMS messages */
-#define N_HDLC         13      /* synchronous HDLC */
-#define N_SYNC_PPP     14      /* synchronous PPP */
-#define N_HCI          15  /* Bluetooth HCI UART */
-
 #ifdef __KERNEL__
 #include <linux/module.h>
 
index 019441c1d7a0ef4feaff5523a6435d58283057ab..bb9fe4feb12d51847cf0a42de2183699b270b41c 100644 (file)
@@ -1,15 +1,12 @@
 #ifndef _ASM_M32R_TIMEX_H
 #define _ASM_M32R_TIMEX_H
 
-/* $Id$ */
-
 /*
  * linux/include/asm-m32r/timex.h
  *
  * m32r architecture timex specifications
  */
 
-
 #define CLOCK_TICK_RATE        (CONFIG_BUS_CLOCK / CONFIG_TIMER_DIVIDE)
 #define CLOCK_TICK_FACTOR      20      /* Factor of both 1000000 and CLOCK_TICK_RATE */
 
index ae4494960593312b5c8d4813192c7f9e0639b421..3d37ac002bcc6e2a9329de1df0a644297aee9249 100644 (file)
@@ -98,4 +98,3 @@ static __inline__ void __flush_tlb_all(void)
 extern void update_mmu_cache(struct vm_area_struct *, unsigned long, pte_t);
 
 #endif /* _ASM_M32R_TLBFLUSH_H */
-
index fcf24c64c3ba4650d001dbf9dfa770583df51bed..27d3eb539c50ddf16bbea835d11fcd7359bbf703 100644 (file)
@@ -3,10 +3,6 @@
 
 #ifndef __ASSEMBLY__
 
-/* $Id$ */
-
-/* orig : i386 2.4.18 */
-
 typedef unsigned short umode_t;
 
 /*
@@ -59,4 +55,4 @@ typedef u64 dma64_addr_t;
 
 #endif /* __KERNEL__ */
 
-#endif  /* _ASM_M32R_TYPES_H */
+#endif /* _ASM_M32R_TYPES_H */
index 26e978c7e3b40a060c0d3e80f1ef41cf5923635a..bd8c83765a5c66361c8bfc35e0ee172ec5cd3f87 100644 (file)
@@ -68,7 +68,7 @@ static inline void set_fs(mm_segment_t s)
  * This needs 33-bit arithmetic. We have a carry...
  */
 #define __range_ok(addr,size) ({                                       \
-       unsigned long flag, sum;                                        \
+       unsigned long flag, roksum;                                     \
        __chk_user_ptr(addr);                                           \
        asm (                                                           \
                "       cmpu    %1, %1    ; clear cbit\n"               \
@@ -76,7 +76,7 @@ static inline void set_fs(mm_segment_t s)
                "       subx    %0, %0\n"                               \
                "       cmpu    %4, %1\n"                               \
                "       subx    %0, %5\n"                               \
-               : "=&r" (flag), "=r" (sum)                              \
+               : "=&r" (flag), "=r" (roksum)                           \
                : "1" (addr), "r" ((int)(size)),                        \
                  "r" (current_thread_info()->addr_limit.seg), "r" (0)  \
                : "cbit" );                                             \
index 2de709a5c53c16b91f2fb52fe0d4cb2e27484524..09324741eec39780f483212f00fda95b75c5ffa9 100644 (file)
@@ -1,8 +1,6 @@
 #ifndef _ASM_M32R_UCONTEXT_H
 #define _ASM_M32R_UCONTEXT_H
 
-/* orig : i386 2.4.18 */
-
 struct ucontext {
        unsigned long     uc_flags;
        struct ucontext  *uc_link;
index 3aef9ac8d3aa06ee716805fc4522563ee8607427..fccc180c3913ff84a67af1139d0bc43a3eeed3a5 100644 (file)
@@ -1,10 +1,6 @@
 #ifndef _ASM_M32R_UNALIGNED_H
 #define _ASM_M32R_UNALIGNED_H
 
-/* $Id$ */
-
-/* orig : generic 2.4.18 */
-
 /*
  * For the benefit of those who are trying to port Linux to another
  * architecture, here are some C-language equivalents.
@@ -12,7 +8,6 @@
 
 #include <asm/string.h>
 
-
 #define get_unaligned(ptr) \
   ({ __typeof__(*(ptr)) __tmp; memmove(&__tmp, (ptr), sizeof(*(ptr))); __tmp; })
 
@@ -21,5 +16,4 @@
      memmove((ptr), &__tmp, sizeof(*(ptr)));           \
      (void)0; })
 
-
-#endif  /* _ASM_M32R_UNALIGNED_H */
+#endif /* _ASM_M32R_UNALIGNED_H */
index 5b66bd3c6ed663cd6cb9d9dd4f7cba21eaec66f7..cbbd53762ea64f17e71ff772c2bc5429eb6cd14f 100644 (file)
@@ -1,8 +1,6 @@
 #ifndef _ASM_M32R_UNISTD_H
 #define _ASM_M32R_UNISTD_H
 
-/* $Id$ */
-
 /*
  * This file contains the system call numbers.
  */
index 1ad4ded8483b48a1af31452fe8b7a2370c1e3fba..035258d713d00f5ebb2508fda4261f956d7855e6 100644 (file)
@@ -1,12 +1,6 @@
 #ifndef _ASM_M32R_USER_H
 #define _ASM_M32R_USER_H
 
-/* $Id$ */
-
-/* orig : sh 2.4.18
- * mod  : remove fpu registers
- */
-
 #include <linux/types.h>
 #include <asm/ptrace.h>
 #include <asm/page.h>
index 533163447cc9d3f711d256c144bb6095b982b0f9..a1b63061c06fee0a28571f13d100f72e95fe8f4e 100644 (file)
@@ -1,8 +1,6 @@
 #ifndef _ASM_M32R_VGA_H
 #define _ASM_M32R_VGA_H
 
-/* $Id$ */
-
 /*
  *     Access to VGA videoram
  *
@@ -19,4 +17,4 @@
 #define vga_readb(x) (*(x))
 #define vga_writeb(x,y) (*(y) = (x))
 
-#endif  /* _ASM_M32R_VGA_H */
+#endif /* _ASM_M32R_VGA_H */
index fd960dc9bf7663f1758d5f4ed7f58356372d8c30..6d525259df3ed0e1effb85afc62ef886ca9c9fe2 100644 (file)
@@ -1,8 +1,6 @@
 #ifndef _ASM_M32R_XOR_H
 #define _ASM_M32R_XOR_H
 
-/* $Id$ */
-
 #include <asm-generic/xor.h>
 
 #endif  /* _ASM_M32R_XOR_H */
index 7ac6259b68dfbfeac50c5cb20304828b31e03395..ddfab96403cb93fdc1d6f4897cccaf0cc74672bf 100644 (file)
@@ -226,6 +226,21 @@ extern unsigned int fp_debugprint;
        .previous
 .endm
 
+/* work around binutils idiocy */
+old_gas=-1
+.irp    gas_ident.x .x
+old_gas=old_gas+1
+.endr
+.if !old_gas
+.irp   m b,w,l
+.macro getuser.\m src,dest,label,addr
+       getuser .\m,\src,\dest,\label,\addr
+.endm
+.macro putuser.\m src,dest,label,addr
+       putuser .\m,\src,\dest,\label,\addr
+.endm
+.endr
+.endif
 
 .macro movestack       nr,arg1,arg2,arg3,arg4,arg5
        .if     \nr
index 857f0c9a9120c650ed05ecbbf8e857dadf312449..00edabd7616869015ce4751f190de23483738d2b 100644 (file)
@@ -49,24 +49,6 @@ struct termio {
 
 /* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
 
-/* line disciplines */
-#define N_TTY          0
-#define N_SLIP         1
-#define N_MOUSE                2
-#define N_PPP          3
-#define N_STRIP                4
-#define N_AX25         5
-#define N_X25          6       /* X.25 async */
-#define N_6PACK                7
-#define N_MASC         8       /* Reserved for Mobitex module <kaz@cafe.net> */
-#define N_R3964                9       /* Reserved for Simatic R3964 module */
-#define N_PROFIBUS_FDL 10      /* Reserved for Profibus <Dave@mvhi.com> */
-#define N_IRDA         11      /* Linux IrDa - http://irda.sourceforge.net/ */
-#define N_SMSBLOCK     12      /* SMS block mode - for talking to GSM data cards about SMS messages */
-#define N_HDLC         13      /* synchronous HDLC */
-#define N_SYNC_PPP     14
-#define N_HCI          15  /* Bluetooth HCI UART */
-
 #ifdef __KERNEL__
 
 /*
index d7c0b109bd457c55d2baeb80132a1bad6b8f9ff6..8c56ccab4849ca0c86dfba77281d0e52d6ee0b4e 100644 (file)
@@ -1,8 +1,6 @@
 #ifndef _M68K_USER_H
 #define _M68K_USER_H
 
-#include <asm/page.h>
-
 /* Core file format: The core file is written in such a way that gdb
    can understand it and provide useful information to the user (under
    linux we use the 'trad-core' bfd).  There are quite a number of
index d7fa7d9c0e0f0c87c80e82366be1b800b6de01aa..7d6075d9b5cb8998faa785d68a8392dd2115ab00 100644 (file)
@@ -7,7 +7,6 @@
 
 #include <linux/compiler.h>
 #include <asm/byteorder.h>     /* swab32 */
-#include <asm/system.h>                /* save_flags */
 
 #ifdef __KERNEL__
 
diff --git a/include/asm-mips/apm.h b/include/asm-mips/apm.h
deleted file mode 100644 (file)
index 4b99ffc..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/* -*- linux-c -*-
- *
- * (C) 2003 zecke@handhelds.org
- *
- * GPL version 2
- *
- * based on arch/arm/kernel/apm.c
- * factor out the information needed by architectures to provide
- * apm status
- *
- *
- */
-#ifndef MIPS_ASM_SA1100_APM_H
-#define MIPS_ASM_SA1100_APM_H
-
-#include <linux/apm_bios.h>
-
-/*
- * This structure gets filled in by the machine specific 'get_power_status'
- * implementation.  Any fields which are not set default to a safe value.
- */
-struct apm_power_info {
-       unsigned char   ac_line_status;
-#define APM_AC_OFFLINE                 0
-#define APM_AC_ONLINE                  1
-#define APM_AC_BACKUP                  2
-#define APM_AC_UNKNOWN                 0xff
-
-       unsigned char   battery_status;
-#define APM_BATTERY_STATUS_HIGH                0
-#define APM_BATTERY_STATUS_LOW         1
-#define APM_BATTERY_STATUS_CRITICAL    2
-#define APM_BATTERY_STATUS_CHARGING    3
-#define APM_BATTERY_STATUS_NOT_PRESENT 4
-#define APM_BATTERY_STATUS_UNKNOWN     0xff
-
-       unsigned char   battery_flag;
-#define APM_BATTERY_FLAG_HIGH          (1 << 0)
-#define APM_BATTERY_FLAG_LOW           (1 << 1)
-#define APM_BATTERY_FLAG_CRITICAL      (1 << 2)
-#define APM_BATTERY_FLAG_CHARGING      (1 << 3)
-#define APM_BATTERY_FLAG_NOT_PRESENT   (1 << 7)
-#define APM_BATTERY_FLAG_UNKNOWN       0xff
-
-       int             battery_life;
-       int             time;
-       int             units;
-#define APM_UNITS_MINS                 0
-#define APM_UNITS_SECS                 1
-#define APM_UNITS_UNKNOWN              -1
-
-};
-
-/*
- * This allows machines to provide their own "apm get power status" function.
- */
-extern void (*apm_get_power_status)(struct apm_power_info *);
-
-/*
- * Queue an event (APM_SYS_SUSPEND or APM_CRITICAL_SUSPEND)
- */
-void apm_queue_event(apm_event_t event);
-
-#endif
index 78af51fbc797b247b67d0a8e3c3ee5f8af009382..b2afaccd68314c650cc8edfec35f55b1f5645480 100644 (file)
@@ -3,7 +3,7 @@
  *
  *     Generic DECstation/DECsystem bits.
  *
- *     Copyright (C) 2005  Maciej W. Rozycki
+ *     Copyright (C) 2005, 2006  Maciej W. Rozycki
  *
  *     This program is free software; you can redistribute it and/or
  *     modify it under the terms of the GNU General Public License
@@ -14,5 +14,6 @@
 #define __ASM_DEC_SYSTEM_H
 
 extern unsigned long dec_kn_slot_base, dec_kn_slot_size;
+extern int dec_tc_bus;
 
 #endif /* __ASM_DEC_SYSTEM_H */
diff --git a/include/asm-mips/dec/tc.h b/include/asm-mips/dec/tc.h
deleted file mode 100644 (file)
index 9cb51f2..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Interface to the TURBOchannel related routines
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (c) 1998 Harald Koerfgen
- */
-#ifndef __ASM_DEC_TC_H
-#define __ASM_DEC_TC_H
-
-/*
- * Search for a TURBOchannel Option Module
- * with a certain name. Returns slot number
- * of the first card not in use or -ENODEV
- * if none found.
- */
-extern int search_tc_card(const char *);
-/*
- * Marks the card in slot as used
- */
-extern void claim_tc_card(int);
-/*
- * Marks the card in slot as free
- */
-extern void release_tc_card(int);
-/*
- * Return base address of card in slot
- */
-extern unsigned long get_tc_base_addr(int);
-/*
- * Return interrupt number of slot
- */
-extern unsigned long get_tc_irq_nr(int);
-/*
- * Return TURBOchannel clock frequency in Hz
- */
-extern unsigned long get_tc_speed(void);
-
-#endif /* __ASM_DEC_TC_H */
diff --git a/include/asm-mips/dec/tcinfo.h b/include/asm-mips/dec/tcinfo.h
deleted file mode 100644 (file)
index cc23509..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Various TURBOchannel related stuff
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Information obtained through the get_tcinfo prom call
- * created from:
- *
- * TURBOchannel Firmware Specification
- *
- * EK-TCAAD-FS-004
- * from Digital Equipment Corporation
- *
- * Copyright (c) 1998 Harald Koerfgen
- */
-
-typedef struct {
-       int revision;
-       int clk_period;
-       int slot_size;
-       int io_timeout;
-       int dma_range;
-       int max_dma_burst;
-       int parity;
-       int reserved[4];
-} tcinfo;
-
-#define MAX_SLOT 7
-
-typedef struct {
-       unsigned long base_addr;
-       unsigned char name[9];
-       unsigned char vendor[9];
-       unsigned char firmware[9];
-       int interrupt;
-       int flags;
-} slot_info;
-
-/*
- * Values for flags
- */
-#define FREE   1<<0
-#define IN_USE 1<<1
-
-
diff --git a/include/asm-mips/dec/tcmodule.h b/include/asm-mips/dec/tcmodule.h
deleted file mode 100644 (file)
index 6268e89..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Offsets for the ROM header locations for
- * TURBOchannel cards
- *
- * created from:
- *
- * TURBOchannel Firmware Specification
- *
- * EK-TCAAD-FS-004
- * from Digital Equipment Corporation
- *
- * Jan.1998 Harald Koerfgen
- */
-#ifndef __ASM_DEC_TCMODULE_H
-#define __ASM_DEC_TCMODULE_H
-
-#define OLDCARD 0x3c0000
-#define NEWCARD 0x000000
-
-#define TC_ROM_WIDTH   0x3e0
-#define TC_ROM_STRIDE  0x3e4
-#define TC_ROM_SIZE    0x3e8
-#define TC_SLOT_SIZE   0x3ec
-#define TC_PATTERN0    0x3f0
-#define TC_PATTERN1    0x3f4
-#define TC_PATTERN2    0x3f8
-#define TC_PATTERN3    0x3fc
-#define TC_FIRM_VER    0x400
-#define TC_VENDOR      0x420
-#define TC_MODULE      0x440
-#define TC_FIRM_TYPE   0x460
-#define TC_FLAGS       0x470
-#define TC_ROM_OBJECTS 0x480
-
-#endif /* __ASM_DEC_TCMODULE_H */
index 67f081078904b0103d8d5bb3e15ad7f43a1f58b0..b6a2eb8166287c8b72b4e14e5157006254f50d3a 100644 (file)
@@ -555,12 +555,6 @@ extern void pci_iounmap(struct pci_dev *dev, void __iomem *);
  */
 #define __ISA_IO_base ((char *)(isa_slot_offset))
 
-/*
- * We don't have csum_partial_copy_fromio() yet, so we cheat here and
- * just copy it. The net code will then do the checksum later.
- */
-#define eth_io_copy_and_sum(skb,src,len,unused) memcpy_fromio((skb)->data,(src),(len))
-
 /*
  * The caches on some architectures aren't dma-coherent and have need to
  * handle this in software.  There are three types of operations that
index 046cf686bee7f74a773877ec658c29e8d8d10e2a..e4d6f1fb1cf765c5ca8e23c3e8438f39ebcc0e2d 100644 (file)
@@ -72,7 +72,6 @@
 #define MADV_DOFORK    11              /* do inherit across fork */
 
 /* compatibility flags */
-#define MAP_ANON       MAP_ANONYMOUS
 #define MAP_FILE       0
 
 #endif /* _ASM_MMAN_H */
index 4906204d34fe75edbf6dbfb8d71cf9a5fc000166..2ce07f4be369f3637de4e438fa3e274125feeff0 100644 (file)
@@ -87,24 +87,6 @@ struct termio {
 #define TIOCM_OUT2     0x4000
 #define TIOCM_LOOP     0x8000
 
-/* line disciplines */
-#define N_TTY          0
-#define N_SLIP         1
-#define N_MOUSE                2
-#define N_PPP          3
-#define N_STRIP                4
-#define N_AX25         5
-#define N_X25          6               /* X.25 async */
-#define N_6PACK                7
-#define N_MASC         8       /* Reserved fo Mobitex module <kaz@cafe.net> */
-#define N_R3964                9       /* Reserved for Simatic R3964 module */
-#define N_PROFIBUS_FDL 10      /* Reserved for Profibus <Dave@mvhi.com> */
-#define N_IRDA         11      /* Linux IrDa - http://irda.sourceforge.net/ */
-#define N_SMSBLOCK     12      /* SMS block mode - for talking to GSM data cards about SMS messages */
-#define N_HDLC         13      /* synchronous HDLC */
-#define N_SYNC_PPP     14      /* synchronous PPP */
-#define N_HCI          15      /* Bluetooth HCI UART */
-
 #ifdef __KERNEL__
 
 #include <linux/string.h>
index c1963ce19dd26df0fa7fd3977a0f6592e769dae6..ca46e7cc094044f2649a5274967e978d83ad72b0 100644 (file)
@@ -191,15 +191,6 @@ void memset_io(volatile void __iomem *addr, unsigned char val, int count);
 void memcpy_fromio(void *dst, const volatile void __iomem *src, int count);
 void memcpy_toio(volatile void __iomem *dst, const void *src, int count);
 
-/*
- * XXX - We don't have csum_partial_copy_fromio() yet, so we cheat here and 
- * just copy it. The net code will then do the checksum later. Presently 
- * only used by some shared memory 8390 Ethernet cards anyway.
- */
-
-#define eth_io_copy_and_sum(skb,src,len,unused) \
-  memcpy_fromio((skb)->data,(src),(len))
-
 /* Port-space IO */
 
 #define inb_p inb
index 0ef15ee0f17ef8e21eaaf394838ed3cd5e965bb3..defe752cc996011164ee1600bd04e67441561fed 100644 (file)
@@ -55,7 +55,6 @@
 #define MADV_64M_PAGES  26              /* Use 64 Megabyte pages */
 
 /* compatibility flags */
-#define MAP_ANON       MAP_ANONYMOUS
 #define MAP_FILE       0
 #define MAP_VARIABLE   0
 
index 6965e8f6c3e162ae653bed05d4a17ab97923b27b..5345b34204759d2dc257df39005757537fd4787a 100644 (file)
@@ -39,24 +39,6 @@ struct termio {
 
 /* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
 
-/* line disciplines */
-#define N_TTY          0
-#define N_SLIP         1
-#define N_MOUSE                2
-#define N_PPP          3
-#define N_STRIP                4
-#define N_AX25         5
-#define N_X25          6       /* X.25 async */
-#define N_6PACK                7
-#define N_MASC         8       /* Reserved for Mobitex module <kaz@cafe.net> */
-#define N_R3964                9       /* Reserved for Simatic R3964 module */
-#define N_PROFIBUS_FDL 10      /* Reserved for Profibus <Dave@mvhi.com> */
-#define N_IRDA         11      /* Linux IR - http://irda.sourceforge.net/ */
-#define N_SMSBLOCK     12      /* SMS block mode - for talking to GSM data cards about SMS messages */
-#define N_HDLC         13      /* synchronous HDLC */
-#define N_SYNC_PPP     14
-#define N_HCI          15  /* Bluetooth HCI UART */
-
 #ifdef __KERNEL__
 
 /*     intr=^C         quit=^\         erase=del       kill=^U
index 7f80a019b6a00310b572d3c57d5a955148b41e06..2c14fea07c8aa92ae9bc320553103dac8d255e67 100644 (file)
@@ -71,24 +71,6 @@ struct termio {
 #define _VEOL2 8
 #define _VSWTC 9
 
-/* line disciplines */
-#define N_TTY          0
-#define N_SLIP         1
-#define N_MOUSE                2
-#define N_PPP          3
-#define N_STRIP                4
-#define N_AX25         5
-#define N_X25          6       /* X.25 async */
-#define N_6PACK                7
-#define N_MASC         8       /* Reserved for Mobitex module <kaz@cafe.net> */
-#define N_R3964                9       /* Reserved for Simatic R3964 module */
-#define N_PROFIBUS_FDL 10      /* Reserved for Profibus <Dave@mvhi.com> */
-#define N_IRDA         11      /* Linux IrDa - http://www.cs.uit.no/~dagb/irda/irda.html */
-#define N_SMSBLOCK     12      /* SMS block mode - for talking to GSM data cards about SMS messages */
-#define N_HDLC         13      /* synchronous HDLC */
-#define N_SYNC_PPP     14
-#define N_HCI          15  /* Bluetooth HCI UART */
-
 #ifdef __KERNEL__
 /*                   ^C  ^\ del  ^U  ^D   1   0   0   0   0  ^W  ^R  ^Z  ^Q  ^S  ^V  ^U  */
 #define INIT_C_CC "\003\034\177\025\004\001\000\000\000\000\027\022\032\021\023\026\025" 
index ccf1a9bb2e435a819eba069c2ddb2ab387e5aa95..95d590423cf2d1fde47616bb4c09ee64022459ad 100644 (file)
@@ -358,8 +358,6 @@ static inline void memcpy_toio(volatile void __iomem *dst, const void *src, int
 }
 #endif
 
-#define eth_io_copy_and_sum(a,b,c,d)           eth_copy_and_sum((a),(void __force *)(void __iomem *)(b),(c),(d))
-
 /*
  * Map in an area of physical address space, for accessing
  * I/O devices etc.
index a4c2d550dad4268e97836bda9ea6d6f48416cf8a..dca6a6cc103f58e9bbc96de28edd3cc9d96200bd 100644 (file)
@@ -13,7 +13,6 @@
 
 #ifdef __KERNEL__
 
-#include <linux/vmalloc.h>
 #include <asm/page.h>
 
 #define IO_SPACE_LIMIT 0xffffffff
@@ -41,70 +40,6 @@ static inline void * phys_to_virt(unsigned long address)
         return __io_virt(address);
 }
 
-extern void * __ioremap(unsigned long offset, unsigned long size, unsigned long flags);
-
-static inline void * ioremap (unsigned long offset, unsigned long size)
-{
-        return __ioremap(offset, size, 0);
-}
-
-/*
- * This one maps high address device memory and turns off caching for that area.
- * it's useful if some control registers are in such an area and write combining
- * or read caching is not desirable:
- */
-static inline void * ioremap_nocache (unsigned long offset, unsigned long size)
-{
-        return __ioremap(offset, size, 0);
-}
-
-extern void iounmap(void *addr);
-
-/*
- * IO bus memory addresses are also 1:1 with the physical address
- */
-#define virt_to_bus virt_to_phys
-#define bus_to_virt phys_to_virt
-
-/*
- * readX/writeX() are used to access memory mapped devices. On some
- * architectures the memory mapped IO stuff needs to be accessed
- * differently.
- */
-
-#define readb(addr) (*(volatile unsigned char *) __io_virt(addr))
-#define readw(addr) (*(volatile unsigned short *) __io_virt(addr))
-#define readl(addr) (*(volatile unsigned int *) __io_virt(addr))
-#define readq(addr) (*(volatile unsigned long long *) __io_virt(addr))
-
-#define readb_relaxed(addr) readb(addr)
-#define readw_relaxed(addr) readw(addr)
-#define readl_relaxed(addr) readl(addr)
-#define readq_relaxed(addr) readq(addr)
-#define __raw_readb readb
-#define __raw_readw readw
-#define __raw_readl readl
-#define __raw_readq readq
-
-#define writeb(b,addr) (*(volatile unsigned char *) __io_virt(addr) = (b))
-#define writew(b,addr) (*(volatile unsigned short *) __io_virt(addr) = (b))
-#define writel(b,addr) (*(volatile unsigned int *) __io_virt(addr) = (b))
-#define writeq(b,addr) (*(volatile unsigned long long *) __io_virt(addr) = (b))
-#define __raw_writeb writeb
-#define __raw_writew writew
-#define __raw_writel writel
-#define __raw_writeq writeq
-
-#define memset_io(a,b,c)        memset(__io_virt(a),(b),(c))
-#define memcpy_fromio(a,b,c)    memcpy((a),__io_virt(b),(c))
-#define memcpy_toio(a,b,c)      memcpy(__io_virt(a),(b),(c))
-
-#define inb_p(addr) readb(addr)
-#define inb(addr) readb(addr)
-
-#define outb(x,addr) ((void) writeb(x,addr))
-#define outb_p(x,addr) outb(x,addr)
-
 #define mmiowb()       do { } while (0)
 
 /*
index 62b23caf370e09e7c70da9af92a10c373c7e1ed4..a3480e25eb4b3ff2af0f388227d924c8326ba1d6 100644 (file)
@@ -47,24 +47,6 @@ struct termio {
 
 /* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
 
-/* line disciplines */
-#define N_TTY          0
-#define N_SLIP         1
-#define N_MOUSE                2
-#define N_PPP          3
-#define N_STRIP                4
-#define N_AX25         5
-#define N_X25          6       /* X.25 async */
-#define N_6PACK                7
-#define N_MASC         8       /* Reserved for Mobitex module <kaz@cafe.net> */
-#define N_R3964                9       /* Reserved for Simatic R3964 module */
-#define N_PROFIBUS_FDL 10      /* Reserved for Profibus <Dave@mvhi.com> */
-#define N_IRDA         11      /* Linux IR - http://irda.sourceforge.net/ */
-#define N_SMSBLOCK     12      /* SMS block mode - for talking to GSM data cards about SMS messages */
-#define N_HDLC         13      /* synchronous HDLC */
-#define N_SYNC_PPP     14      /* synchronous PPP */
-#define N_HCI          15  /* Bluetooth HCI UART */
-
 #ifdef __KERNEL__
 
 /*     intr=^C         quit=^\         erase=del       kill=^U
diff --git a/include/asm-sh/apm.h b/include/asm-sh/apm.h
deleted file mode 100644 (file)
index 8b091e9..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2006 (c) Andriy Skulysh <askulysh@gmail.com>
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- */
-
-#ifndef __ASM_SH_APM_H
-#define __ASM_SH_APM_H
-
-#define APM_AC_OFFLINE                 0
-#define APM_AC_ONLINE                  1
-#define APM_AC_BACKUP                  2
-#define APM_AC_UNKNOWN                 0xff
-
-#define APM_BATTERY_STATUS_HIGH                0
-#define APM_BATTERY_STATUS_LOW         1
-#define APM_BATTERY_STATUS_CRITICAL    2
-#define APM_BATTERY_STATUS_CHARGING    3
-#define APM_BATTERY_STATUS_NOT_PRESENT 4
-#define APM_BATTERY_STATUS_UNKNOWN     0xff
-
-#define APM_BATTERY_LIFE_UNKNOWN       0xFFFF
-#define APM_BATTERY_LIFE_MINUTES       0x8000
-#define APM_BATTERY_LIFE_VALUE_MASK    0x7FFF
-
-#define APM_BATTERY_FLAG_HIGH          (1 << 0)
-#define APM_BATTERY_FLAG_LOW           (1 << 1)
-#define APM_BATTERY_FLAG_CRITICAL      (1 << 2)
-#define APM_BATTERY_FLAG_CHARGING      (1 << 3)
-#define APM_BATTERY_FLAG_NOT_PRESENT   (1 << 7)
-#define APM_BATTERY_FLAG_UNKNOWN       0xff
-
-#define APM_UNITS_MINS                 0
-#define APM_UNITS_SECS                 1
-#define APM_UNITS_UNKNOWN              -1
-
-
-extern int (*apm_get_info)(char *buf, char **start, off_t fpos, int length);
-extern int apm_suspended;
-
-void apm_queue_event(apm_event_t event);
-
-#endif
index 44edfd471443cd2682630040e1a4645bca99a914..e7c8f86ef8902b9ca28fb76896b21059d99181f2 100644 (file)
@@ -39,24 +39,6 @@ struct termio {
 
 /* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
 
-/* line disciplines */
-#define N_TTY          0
-#define N_SLIP         1
-#define N_MOUSE                2
-#define N_PPP          3
-#define N_STRIP                4
-#define N_AX25         5
-#define N_X25          6       /* X.25 async */
-#define N_6PACK                7
-#define N_MASC         8       /* Reserved for Mobitex module <kaz@cafe.net> */
-#define N_R3964                9       /* Reserved for Simatic R3964 module */
-#define N_PROFIBUS_FDL 10      /* Reserved for Profibus <Dave@mvhi.com> */
-#define N_IRDA         11      /* Linux IR - http://irda.sourceforge.net/ */
-#define N_SMSBLOCK     12      /* SMS block mode - for talking to GSM data cards about SMS messages */
-#define N_HDLC         13      /* synchronous HDLC */
-#define N_SYNC_PPP     14
-#define N_HCI          15  /* Bluetooth HCI UART */
-
 #ifdef __KERNEL__
 
 /*     intr=^C         quit=^\         erase=del       kill=^U
index 4a9c7fb411bc02b9d4bdb1abfcbaa592fa59f7cd..dc44e6ed3a7ccb55c1285b5979b716710945ca80 100644 (file)
@@ -50,24 +50,6 @@ struct termio {
 
 /* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
 
-/* line disciplines */
-#define N_TTY          0
-#define N_SLIP         1
-#define N_MOUSE                2
-#define N_PPP          3
-#define N_STRIP                4
-#define N_AX25         5
-#define N_X25          6       /* X.25 async */
-#define N_6PACK                7
-#define N_MASC         8       /* Reserved for Mobitex module <kaz@cafe.net> */
-#define N_R3964                9       /* Reserved for Simatic R3964 module */
-#define N_PROFIBUS_FDL 10      /* Reserved for Profibus <Dave@mvhi.com> */
-#define N_IRDA         11      /* Linux IR - http://www.cs.uit.no/~dagb/irda/irda.html */
-#define N_SMSBLOCK     12      /* SMS block mode - for talking to GSM data cards about SMS messages */
-#define N_HDLC         13      /* synchronous HDLC */
-#define N_SYNC_PPP     14
-#define N_HCI          15      /* Bluetooth HCI UART */
-
 #ifdef __KERNEL__
 
 /*     intr=^C         quit=^\         erase=del       kill=^U
index cab0b851b8b11164e8504313526603ffafaf410b..c23e74a0eaa8d4021c101a6bb4c3a5922ddfb4b2 100644 (file)
@@ -256,6 +256,35 @@ extern void iounmap(volatile void __iomem *addr);
 #define iowrite16(val,X)               writew(val,X)
 #define iowrite32(val,X)               writel(val,X)
 
+static inline void ioread8_rep(void __iomem *port, void *buf, unsigned long count)
+{
+       insb((unsigned long __force)port, buf, count);
+}
+static inline void ioread16_rep(void __iomem *port, void *buf, unsigned long count)
+{
+       insw((unsigned long __force)port, buf, count);
+}
+
+static inline void ioread32_rep(void __iomem *port, void *buf, unsigned long count)
+{
+       insl((unsigned long __force)port, buf, count);
+}
+
+static inline void iowrite8_rep(void __iomem *port, const void *buf, unsigned long count)
+{
+       outsb((unsigned long __force)port, buf, count);
+}
+
+static inline void iowrite16_rep(void __iomem *port, const void *buf, unsigned long count)
+{
+       outsw((unsigned long __force)port, buf, count);
+}
+
+static inline void iowrite32_rep(void __iomem *port, const void *buf, unsigned long count)
+{
+       outsl((unsigned long __force)port, buf, count);
+}
+
 /* Create a virtual mapping cookie for an IO port range */
 extern void __iomem *ioport_map(unsigned long port, unsigned int nr);
 extern void ioport_unmap(void __iomem *);
index d05f83c809893c404a9fc897fdf5164fbac6fbc9..d767f206ab33317988868a41a804d68054760019 100644 (file)
@@ -45,24 +45,6 @@ struct winsize {
        unsigned short ws_ypixel;
 };
 
-/* line disciplines */
-#define N_TTY          0
-#define N_SLIP         1
-#define N_MOUSE                2
-#define N_PPP          3
-#define N_STRIP                4
-#define N_AX25         5
-#define N_X25          6
-#define N_6PACK                7
-#define N_MASC         8       /* Reserved for Mobitex module <kaz@cafe.net> */
-#define N_R3964                9       /* Reserved for Simatic R3964 module */
-#define N_PROFIBUS_FDL 10      /* Reserved for Profibus <Dave@mvhi.com> */
-#define N_IRDA         11      /* Linux IrDa - http://irda.sourceforge.net/ */
-#define N_SMSBLOCK     12      /* SMS block mode - for talking to GSM data cards about SMS messages */
-#define N_HDLC         13      /* synchronous HDLC */
-#define N_SYNC_PPP     14      /* synchronous PPP */
-#define N_HCI          15  /* Bluetooth HCI UART */
-
 #ifdef __KERNEL__
 #include <linux/module.h>
 
index 905e59b4a737537bbfe835b5512aaadcdf0c6f4a..5d233b42fe135b87b51d9c2f3e1339554ce8e7f5 100644 (file)
@@ -46,6 +46,10 @@ extern void irq_install_pre_handler(int virt_irq,
 #define irq_canonicalize(irq)  (irq)
 extern unsigned int build_irq(int inofixup, unsigned long iclr, unsigned long imap);
 extern unsigned int sun4v_build_irq(u32 devhandle, unsigned int devino);
+extern unsigned int sun4v_build_msi(u32 devhandle, unsigned int *virt_irq_p,
+                                   unsigned int msi_devino_start,
+                                   unsigned int msi_devino_end);
+extern void sun4v_destroy_msi(unsigned int virt_irq);
 extern unsigned int sbus_build_irq(void *sbus, unsigned int ino);
 
 static __inline__ void set_softint(unsigned long bits)
index dcfa7629358c396c9e977447ee24f56b31cd799e..7a246d8a1828b7f98cea9d9b10ff21e9e862c485 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/pci.h>
 #include <linux/ioport.h>
 #include <linux/spinlock.h>
+#include <linux/msi.h>
 
 #include <asm/io.h>
 #include <asm/page.h>
@@ -177,6 +178,24 @@ struct pci_pbm_info {
        int                             is_66mhz_capable;
        int                             all_devs_66mhz;
 
+#ifdef CONFIG_PCI_MSI
+       /* MSI info.  */
+       u32                             msiq_num;
+       u32                             msiq_ent_count;
+       u32                             msiq_first;
+       u32                             msiq_first_devino;
+       u32                             msi_num;
+       u32                             msi_first;
+       u32                             msi_data_mask;
+       u32                             msix_data_width;
+       u64                             msi32_start;
+       u64                             msi64_start;
+       u32                             msi32_len;
+       u32                             msi64_len;
+       void                            *msi_queues;
+       unsigned long                   *msi_bitmap;
+#endif /* !(CONFIG_PCI_MSI) */
+
        /* This PBM's streaming buffer. */
        struct pci_strbuf               stc;
 
@@ -213,6 +232,12 @@ struct pci_controller_info {
        void (*base_address_update)(struct pci_dev *, int);
        void (*resource_adjust)(struct pci_dev *, struct resource *, struct resource *);
 
+#ifdef CONFIG_PCI_MSI
+       int (*setup_msi_irq)(unsigned int *virt_irq_p, struct pci_dev *pdev,
+                            struct msi_desc *entry);
+       void (*teardown_msi_irq)(unsigned int virt_irq, struct pci_dev *pdev);
+#endif
+
        /* Now things for the actual PCI bus probes. */
        struct pci_ops                  *pci_ops;
        unsigned int                    pci_first_busno;
@@ -231,6 +256,9 @@ struct pcidev_cookie {
        int num_prom_regs;
        struct linux_prom_pci_registers prom_assignments[PROMREG_MAX];
        int num_prom_assignments;
+#ifdef CONFIG_PCI_MSI
+       unsigned int                    msi_num;
+#endif
 };
 
 /* Currently these are the same across all PCI controllers
index ee26a071c67776074f9386249c8b3af040370077..f05d390993d5d4c953727a240577e28e6649efa2 100644 (file)
@@ -45,24 +45,6 @@ struct winsize {
        unsigned short ws_ypixel;
 };
 
-/* line disciplines */
-#define N_TTY          0
-#define N_SLIP         1
-#define N_MOUSE                2
-#define N_PPP          3
-#define N_STRIP                4
-#define N_AX25         5
-#define N_X25          6
-#define N_6PACK                7
-#define N_MASC         8       /* Reserved for Mobitex module <kaz@cafe.net> */
-#define N_R3964                9       /* Reserved for Simatic R3964 module */
-#define N_PROFIBUS_FDL 10      /* Reserved for Profibus <Dave@mvhi.com> */
-#define N_IRDA         11      /* Linux IrDa - http://irda.sourceforge.net/ */
-#define N_SMSBLOCK     12      /* SMS block mode - for talking to GSM data cards about SMS messages */
-#define N_HDLC         13      /* synchronous HDLC */
-#define N_SYNC_PPP     14      /* synchronous PPP */
-#define N_HCI          15  /* Bluetooth HCI UART */
-
 #ifdef __KERNEL__
 #include <linux/module.h>
 
index 99711134e477a2bae4a4ddb9c80961363b458f19..d3b90b7ac3e9820921272b12642f193803b142f5 100644 (file)
@@ -11,7 +11,7 @@ extern long elf_aux_hwcap;
 
 #define elf_check_arch(x) (1)
 
-#ifdef CONFIG_64_BIT
+#ifdef CONFIG_64BIT
 #define ELF_CLASS ELFCLASS64
 #else
 #define ELF_CLASS ELFCLASS32
index 10609af376c0339af5f22bafe48c918a2103a34f..31c2d4d685bd7692677db195bb4738642dea8459 100644 (file)
@@ -13,6 +13,7 @@
 struct arch_thread {
         unsigned long debugregs[8];
         int debugregs_seq;
+        unsigned long fs;
         struct faultinfo faultinfo;
 };
 
@@ -25,8 +26,9 @@ extern inline void rep_nop(void)
 #define cpu_relax()   rep_nop()
 
 #define INIT_ARCH_THREAD { .debugregs                  = { [ 0 ... 7 ] = 0 }, \
-                           .debugregs_seq      = 0, \
-                           .faultinfo          = { 0, 0, 0 } }
+                           .debugregs_seq      = 0,                           \
+                          .fs                  = 0, \
+                          .faultinfo           = { 0, 0, 0 } }
 
 static inline void arch_flush_thread(struct arch_thread *thread)
 {
index 03b4af4ac09a3c82509e93dc835ee84bb7f7d111..bf61d17de3f72d776a2f5ba3e6e1017c6884101d 100644 (file)
@@ -81,9 +81,10 @@ static inline void arch_switch_to_tt(struct task_struct *from,
 {
 }
 
-static inline void arch_switch_to_skas(struct task_struct *from,
-                                       struct task_struct *to)
-{
-}
+extern void arch_switch_to_skas(struct task_struct *from,
+                               struct task_struct *to);
+
+extern long arch_prctl_skas(struct task_struct *task, int code,
+                           unsigned long __user *addr);
 
 #endif
index 79e97b59806e1720cbd49e93b757fa3bfb9654d6..c2c2b1d5877618f49ce3b6a2829c340fa1e2b7a4 100644 (file)
@@ -39,24 +39,6 @@ struct termio {
 
 /* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
 
-/* line disciplines */
-#define N_TTY          0
-#define N_SLIP         1
-#define N_MOUSE                2
-#define N_PPP          3
-#define N_STRIP                4
-#define N_AX25         5
-#define N_X25          6       /* X.25 async */
-#define N_6PACK                7
-#define N_MASC         8       /* Reserved for Mobitex module <kaz@cafe.net> */
-#define N_R3964                9       /* Reserved for Simatic R3964 module */
-#define N_PROFIBUS_FDL 10      /* Reserved for Profibus <Dave@mvhi.com> */
-#define N_IRDA         11      /* Linux IR - http://irda.sourceforge.net/ */
-#define N_SMSBLOCK     12      /* SMS block mode - for talking to GSM data cards about SMS messages */
-#define N_HDLC         13      /* synchronous HDLC */
-#define N_SYNC_PPP     14      /* synchronous PPP */
-#define N_HCI          15  /* Bluetooth HCI UART */
-
 #ifdef __KERNEL__
 
 /*     intr=^C         quit=^\         erase=del       kill=^U
index 6ee9fadaaacb29a3a7cba086c37f4f7bd94e6eaf..f5d84bb7c9488c3281cc6e386bbc67e97abdd16f 100644 (file)
@@ -248,12 +248,6 @@ void memset_io(volatile void __iomem *a, int b, size_t c);
  */
 #define __ISA_IO_base ((char __iomem *)(PAGE_OFFSET))
 
-/*
- * Again, x86-64 does not require mem IO specific function.
- */
-
-#define eth_io_copy_and_sum(a,b,c,d)           eth_copy_and_sum((a),(void *)(b),(c),(d))
-
 /* Nothing to do */
 
 #define dma_cache_inv(_start,_size)            do { } while (0)
index 6d324b83897207f56f9e348bc6ef6feae8c553ef..a6d2ff5c69b76ea2a5941740dd2206cf45f03726 100644 (file)
@@ -81,7 +81,6 @@ extern void swap_low_mappings(void);
 extern void __show_regs(struct pt_regs * regs);
 extern void show_regs(struct pt_regs * regs);
 
-extern char *syscall32_page;
 extern void syscall32_cpu_init(void);
 
 extern void setup_node_bootmem(int nodeid, unsigned long start, unsigned long end);
index 443b225537f0bd61ecc4e18f22b5d0997a67bdb1..35ee59b78329853d78e13e45aad641a2daa2d033 100644 (file)
@@ -39,24 +39,6 @@ struct termio {
 
 /* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
 
-/* line disciplines */
-#define N_TTY          0
-#define N_SLIP         1
-#define N_MOUSE                2
-#define N_PPP          3
-#define N_STRIP                4
-#define N_AX25         5
-#define N_X25          6       /* X.25 async */
-#define N_6PACK                7
-#define N_MASC         8       /* Reserved for Mobitex module <kaz@cafe.net> */
-#define N_R3964                9       /* Reserved for Simatic R3964 module */
-#define N_PROFIBUS_FDL 10      /* Reserved for Profibus <Dave@mvhi.com> */
-#define N_IRDA         11      /* Linux IR - http://irda.sourceforge.net/ */
-#define N_SMSBLOCK     12      /* SMS block mode - for talking to GSM data cards about SMS messages */
-#define N_HDLC         13      /* synchronous HDLC */
-#define N_SYNC_PPP     14      /* synchronous PPP */
-#define N_HCI          15  /* Bluetooth HCI UART */
-
 #ifdef __KERNEL__
 
 /*     intr=^C         quit=^\         erase=del       kill=^U
index c0eac519840b2d1d15a4c0751d20293649bbe9b0..8079e29c14fd4ca1212bea28ac313b523a67b5d3 100644 (file)
  * Uhhuh, this needs 65-bit arithmetic. We have a carry..
  */
 #define __range_not_ok(addr,size) ({ \
-       unsigned long flag,sum; \
+       unsigned long flag,roksum; \
        __chk_user_ptr(addr); \
        asm("# range_ok\n\r" \
                "addq %3,%1 ; sbbq %0,%0 ; cmpq %1,%4 ; sbbq $0,%0"  \
-               :"=&r" (flag), "=r" (sum) \
+               :"=&r" (flag), "=r" (roksum) \
                :"1" (addr),"g" ((long)(size)),"g" (current_thread_info()->addr_limit.seg)); \
        flag; })
 
index ba394cbb48071b03ddc789f21bf80fef84d50eb1..9b92620c8a1ed262d3b10a9cb44dd0b746feacc8 100644 (file)
@@ -79,7 +79,6 @@
 #define MADV_DOFORK    11              /* do inherit across fork */
 
 /* compatibility flags */
-#define MAP_ANON       MAP_ANONYMOUS
 #define MAP_FILE       0
 
 #endif /* _XTENSA_MMAN_H */
index 83c6aed1d1154655e2a516b5fa2007e4f87e25f3..f14b42c8dac06b320363f88ea97863049397092e 100644 (file)
@@ -52,25 +52,6 @@ struct termio {
 
 /* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
 
-/* Line disciplines */
-
-#define N_TTY          0
-#define N_SLIP         1
-#define N_MOUSE                2
-#define N_PPP          3
-#define N_STRIP                4
-#define N_AX25         5
-#define N_X25          6       /* X.25 async */
-#define N_6PACK                7
-#define N_MASC         8       /* Reserved for Mobitex module <kaz@cafe.net> */
-#define N_R3964                9       /* Reserved for Simatic R3964 module */
-#define N_PROFIBUS_FDL 10      /* Reserved for Profibus <Dave@mvhi.com> */
-#define N_IRDA         11      /* Linux IR - http://irda.sourceforge.net/ */
-#define N_SMSBLOCK     12      /* SMS block mode - for talking to GSM data cards about SMS messages */
-#define N_HDLC         13      /* synchronous HDLC */
-#define N_SYNC_PPP     14
-#define N_HCI          15      /* Bluetooth HCI UART */
-
 #ifdef __KERNEL__
 
 /*     intr=^C         quit=^\         erase=del       kill=^U
index 5748aecdb414704c5baec50cac15fa5ee0d7b7a2..4e05e93ff6811248002485475e8a624fa1209cf1 100644 (file)
@@ -18,8 +18,8 @@ struct module;
 struct seq_file;
 
 struct crypto_type {
-       unsigned int (*ctxsize)(struct crypto_alg *alg);
-       int (*init)(struct crypto_tfm *tfm);
+       unsigned int (*ctxsize)(struct crypto_alg *alg, u32 type, u32 mask);
+       int (*init)(struct crypto_tfm *tfm, u32 type, u32 mask);
        void (*exit)(struct crypto_tfm *tfm);
        void (*show)(struct seq_file *m, struct crypto_alg *alg);
 };
@@ -93,7 +93,8 @@ struct crypto_template *crypto_lookup_template(const char *name);
 int crypto_init_spawn(struct crypto_spawn *spawn, struct crypto_alg *alg,
                      struct crypto_instance *inst);
 void crypto_drop_spawn(struct crypto_spawn *spawn);
-struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn);
+struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn, u32 type,
+                                   u32 mask);
 
 struct crypto_alg *crypto_get_attr_alg(void *param, unsigned int len,
                                       u32 type, u32 mask);
@@ -132,11 +133,28 @@ static inline void *crypto_blkcipher_ctx_aligned(struct crypto_blkcipher *tfm)
        return crypto_tfm_ctx_aligned(&tfm->base);
 }
 
+static inline struct crypto_cipher *crypto_spawn_cipher(
+       struct crypto_spawn *spawn)
+{
+       u32 type = CRYPTO_ALG_TYPE_CIPHER;
+       u32 mask = CRYPTO_ALG_TYPE_MASK;
+
+       return __crypto_cipher_cast(crypto_spawn_tfm(spawn, type, mask));
+}
+
 static inline struct cipher_alg *crypto_cipher_alg(struct crypto_cipher *tfm)
 {
        return &crypto_cipher_tfm(tfm)->__crt_alg->cra_cipher;
 }
 
+static inline struct crypto_hash *crypto_spawn_hash(struct crypto_spawn *spawn)
+{
+       u32 type = CRYPTO_ALG_TYPE_HASH;
+       u32 mask = CRYPTO_ALG_TYPE_HASH_MASK;
+
+       return __crypto_hash_cast(crypto_spawn_tfm(spawn, type, mask));
+}
+
 static inline void *crypto_hash_ctx_aligned(struct crypto_hash *tfm)
 {
        return crypto_tfm_ctx_aligned(&tfm->base);
index 683513e310de229e5b84d7ebf218fd0ca9b822ab..bb881c3219fa205434c92799d5a324d92ea6c003 100644 (file)
@@ -156,7 +156,6 @@ header-y += video_encoder.h
 header-y += videotext.h
 header-y += vt.h
 header-y += wireless.h
-header-y += xattr.h
 header-y += x25.h
 
 unifdef-y += acct.h
@@ -336,6 +335,7 @@ unifdef-y += wait.h
 unifdef-y += wanrouter.h
 unifdef-y += watchdog.h
 unifdef-y += wireless.h
+unifdef-y += xattr.h
 unifdef-y += xfrm.h
 
 objhdr-y += version.h
similarity index 93%
rename from include/asm-arm/apm.h
rename to include/linux/apm-emulation.h
index d09113b37e4ae28548c653c47f02fb927f3c4def..e6d800358dd6bb6653b1a78aa1b7ccd1e61cf083 100644 (file)
@@ -7,11 +7,9 @@
  * based on arch/arm/kernel/apm.c
  * factor out the information needed by architectures to provide
  * apm status
- *
- *
  */
-#ifndef ARM_ASM_SA1100_APM_H
-#define ARM_ASM_SA1100_APM_H
+#ifndef __LINUX_APM_EMULATION_H
+#define __LINUX_APM_EMULATION_H
 
 #include <linux/apm_bios.h>
 
@@ -61,4 +59,4 @@ extern void (*apm_get_power_status)(struct apm_power_info *);
  */
 void apm_queue_event(apm_event_t event);
 
-#endif
+#endif /* __LINUX_APM_EMULATION_H */
index 1df941648a573a449d6807917e7a8ab4207b5a03..18e401ff7eafb6ed6fee60693e65b1c35b3254a8 100644 (file)
@@ -44,9 +44,9 @@ enum {
        ATA_MAX_SECTORS_LBA48   = 65535,/* TODO: 65536? */
 
        ATA_ID_WORDS            = 256,
-       ATA_ID_SERNO_OFS        = 10,
-       ATA_ID_FW_REV_OFS       = 23,
-       ATA_ID_PROD_OFS         = 27,
+       ATA_ID_SERNO            = 10,
+       ATA_ID_FW_REV           = 23,
+       ATA_ID_PROD             = 27,
        ATA_ID_OLD_PIO_MODES    = 51,
        ATA_ID_FIELD_VALID      = 53,
        ATA_ID_MWDMA_MODES      = 63,
@@ -58,8 +58,11 @@ enum {
        ATA_ID_MAJOR_VER        = 80,
        ATA_ID_PIO4             = (1 << 1),
 
+       ATA_ID_SERNO_LEN        = 20,
+       ATA_ID_FW_REV_LEN       = 8,
+       ATA_ID_PROD_LEN         = 40,
+
        ATA_PCI_CTL_OFS         = 2,
-       ATA_SERNO_LEN           = 20,
        ATA_UDMA0               = (1 << 0),
        ATA_UDMA1               = ATA_UDMA0 | (1 << 1),
        ATA_UDMA2               = ATA_UDMA1 | (1 << 2),
@@ -296,6 +299,8 @@ struct ata_taskfile {
 #define ata_id_queue_depth(id) (((id)[75] & 0x1f) + 1)
 #define ata_id_removeable(id)  ((id)[0] & (1 << 7))
 #define ata_id_has_dword_io(id)        ((id)[50] & (1 << 0))
+#define ata_id_iordy_disable(id) ((id)[49] & (1 << 10))
+#define ata_id_has_iordy(id) ((id)[49] & (1 << 9))
 #define ata_id_u32(id,n)       \
        (((u32) (id)[(n) + 1] << 16) | ((u32) (id)[(n)]))
 #define ata_id_u64(id,n)       \
index ee108f9e9cb7a37092c46fe963c9945718ecc40d..231f4bdec730e2df575f8a99f9f1906d3ac012fd 100644 (file)
@@ -6,9 +6,7 @@
 #ifndef _LINUX_ATMARP_H
 #define _LINUX_ATMARP_H
 
-#ifdef __KERNEL__
 #include <linux/types.h>
-#endif
 #include <linux/atmapi.h>
 #include <linux/atmioc.h>
 
index 56499ab9e32ee9f1bb1a72adab6a856c781cb4a1..79bedddfd9ca15c02d9fa91793d24027fa5f6b8c 100644 (file)
@@ -1,7 +1,5 @@
 header-y += big_endian.h
 header-y += little_endian.h
-header-y += pdp_endian.h
 
 unifdef-y += generic.h
-unifdef-y += swabb.h
 unifdef-y += swab.h
diff --git a/include/linux/byteorder/pdp_endian.h b/include/linux/byteorder/pdp_endian.h
deleted file mode 100644 (file)
index 618631c..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-#ifndef _LINUX_BYTEORDER_PDP_ENDIAN_H
-#define _LINUX_BYTEORDER_PDP_ENDIAN_H
-
-/*
- * Could have been named NUXI-endian, but we use the same name as in glibc.
- * hopefully only the PDP and its evolutions (old VAXen in compatibility mode)
- * should ever use this braindead byteorder.
- * This file *should* work, but has not been tested.
- *
- * little-endian is 1234; big-endian is 4321; nuxi/pdp-endian is 3412
- *
- * I thought vaxen were NUXI-endian, but was told they were correct-endian
- * (little-endian), though indeed there existed NUXI-endian machines
- * (DEC PDP-11 and old VAXen in compatibility mode).
- * This makes this file a bit useless, but as a proof-of-concept.
- *
- * But what does a __u64 look like: is it 34127856 or 78563412 ???
- * I don't dare imagine! Hence, no 64-bit byteorder support yet.
- * Hopefully, there 64-bit pdp-endian support shouldn't ever be required.
- *
- */
-
-#ifndef __PDP_ENDIAN
-#define __PDP_ENDIAN 3412
-#endif
-#ifndef __PDP_ENDIAN_BITFIELD
-#define __PDP_ENDIAN_BITFIELD
-#endif
-
-#include <linux/byteorder/swab.h>
-#include <linux/byteorder/swabb.h>
-
-#define __constant_htonl(x) ___constant_swahb32((x))
-#define __constant_ntohl(x) ___constant_swahb32((x))
-#define __constant_htons(x) ___constant_swab16((x))
-#define __constant_ntohs(x) ___constant_swab16((x))
-#define __constant_cpu_to_le64(x) I DON'T KNOW
-#define __constant_le64_to_cpu(x) I DON'T KNOW
-#define __constant_cpu_to_le32(x) ___constant_swahw32((x))
-#define __constant_le32_to_cpu(x) ___constant_swahw32((x))
-#define __constant_cpu_to_le16(x) ((__u16)(x)
-#define __constant_le16_to_cpu(x) ((__u16)(x)
-#define __constant_cpu_to_be64(x) I DON'T KNOW
-#define __constant_be64_to_cpu(x) I DON'T KNOW
-#define __constant_cpu_to_be32(x) ___constant_swahb32((x))
-#define __constant_be32_to_cpu(x) ___constant_swahb32((x))
-#define __constant_cpu_to_be16(x) ___constant_swab16((x))
-#define __constant_be16_to_cpu(x) ___constant_swab16((x))
-#define __cpu_to_le64(x) I DON'T KNOW
-#define __le64_to_cpu(x) I DON'T KNOW
-#define __cpu_to_le32(x) ___swahw32((x))
-#define __le32_to_cpu(x) ___swahw32((x))
-#define __cpu_to_le16(x) ((__u16)(x)
-#define __le16_to_cpu(x) ((__u16)(x)
-#define __cpu_to_be64(x) I DON'T KNOW
-#define __be64_to_cpu(x) I DON'T KNOW
-#define __cpu_to_be32(x) __swahb32((x))
-#define __be32_to_cpu(x) __swahb32((x))
-#define __cpu_to_be16(x) __swab16((x))
-#define __be16_to_cpu(x) __swab16((x))
-#define __cpu_to_le64p(x) I DON'T KNOW
-#define __le64_to_cpup(x) I DON'T KNOW
-#define __cpu_to_le32p(x) ___swahw32p((x))
-#define __le32_to_cpup(x) ___swahw32p((x))
-#define __cpu_to_le16p(x) (*(__u16*)(x))
-#define __le16_to_cpup(x) (*(__u16*)(x))
-#define __cpu_to_be64p(x) I DON'T KNOW
-#define __be64_to_cpup(x) I DON'T KNOW
-#define __cpu_to_be32p(x) __swahb32p((x))
-#define __be32_to_cpup(x) __swahb32p((x))
-#define __cpu_to_be16p(x) __swab16p((x))
-#define __be16_to_cpup(x) __swab16p((x))
-#define __cpu_to_le64s(x) I DON'T KNOW
-#define __le64_to_cpus(x) I DON'T KNOW
-#define __cpu_to_le32s(x) ___swahw32s((x))
-#define __le32_to_cpus(x) ___swahw32s((x))
-#define __cpu_to_le16s(x) do {} while (0)
-#define __le16_to_cpus(x) do {} while (0)
-#define __cpu_to_be64s(x) I DON'T KNOW
-#define __be64_to_cpus(x) I DON'T KNOW
-#define __cpu_to_be32s(x) __swahb32s((x))
-#define __be32_to_cpus(x) __swahb32s((x))
-#define __cpu_to_be16s(x) __swab16s((x))
-#define __be16_to_cpus(x) __swab16s((x))
-
-#include <linux/byteorder/generic.h>
-
-#endif /* _LINUX_BYTEORDER_PDP_ENDIAN_H */
index ae5e5f914bf4a082b1f12e3956f4e868011710db..8c780c7d779e134fd9d42531b8f2e8d61b2badb4 100644 (file)
@@ -25,6 +25,8 @@
  *
  */
 
+#include <linux/types.h>
+
 #define ___swahw32(x) \
 ({ \
        __u32 __x = (x); \
 /*
  * Allow constant folding
  */
-#if defined(__GNUC__) && defined(__OPTIMIZE__)
-#  define __swahw32(x) \
+#define __swahw32(x) \
 (__builtin_constant_p((__u32)(x)) ? \
  ___swahw32((x)) : \
  __fswahw32((x)))
-#  define __swahb32(x) \
+#define __swahb32(x) \
 (__builtin_constant_p((__u32)(x)) ? \
  ___swahb32((x)) : \
  __fswahb32((x)))
-#else
-#  define __swahw32(x) __fswahw32(x)
-#  define __swahb32(x) __fswahb32(x)
-#endif /* OPTIMIZE */
 
 
 static inline __u32 __fswahw32(__u32 x)
@@ -128,13 +125,11 @@ static inline void __swahb32s(__u32 *addr)
  */
 #endif /* __BYTEORDER_HAS_U64__ */
 
-#if defined(__KERNEL__)
 #define swahw32 __swahw32
 #define swahb32 __swahb32
 #define swahw32p __swahw32p
 #define swahb32p __swahb32p
 #define swahw32s __swahw32s
 #define swahb32s __swahb32s
-#endif
 
 #endif /* _LINUX_BYTEORDER_SWABB_H */
diff --git a/include/linux/cfag12864b.h b/include/linux/cfag12864b.h
new file mode 100644 (file)
index 0000000..0bc45e6
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ *    Filename: cfag12864b.h
+ *     Version: 0.1.0
+ * Description: cfag12864b LCD driver header
+ *     License: GPLv2
+ *
+ *      Author: Copyright (C) Miguel Ojeda Sandonis <maxextreme@gmail.com>
+ *        Date: 2006-10-12
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+#ifndef _CFAG12864B_H_
+#define _CFAG12864B_H_
+
+#define CFAG12864B_WIDTH       (128)
+#define CFAG12864B_HEIGHT      (64)
+#define CFAG12864B_CONTROLLERS (2)
+#define CFAG12864B_PAGES       (8)
+#define CFAG12864B_ADDRESSES   (64)
+#define CFAG12864B_SIZE                ((CFAG12864B_CONTROLLERS) * \
+                               (CFAG12864B_PAGES) * \
+                               (CFAG12864B_ADDRESSES))
+
+/*
+ * The driver will blit this buffer to the LCD
+ *
+ * Its size is CFAG12864B_SIZE.
+ */
+extern unsigned char * cfag12864b_buffer;
+
+/*
+ * Get the refresh rate of the LCD
+ *
+ * Returns the refresh rate (hertzs).
+ */
+extern unsigned int cfag12864b_getrate(void);
+
+/*
+ * Enable refreshing
+ *
+ * Returns 0 if successful (anyone was using it),
+ * or != 0 if failed (someone is using it).
+ */
+extern unsigned char cfag12864b_enable(void);
+
+/*
+ * Disable refreshing
+ *
+ * You should call this only when you finish using the LCD.
+ */
+extern void cfag12864b_disable(void);
+
+/*
+ * Is enabled refreshing? (is anyone using the module?)
+ *
+ * Returns 0 if refreshing is not enabled (anyone is using it),
+ * or != 0 if refreshing is enabled (someone is using it).
+ *
+ * Useful for buffer read-only modules.
+ */
+extern unsigned char cfag12864b_isenabled(void);
+
+#endif /* _CFAG12864B_H_ */
+
index 6e1c44a935d411e5bbd5793b163d9082960d2196..9008eabb9c3ded7440e75c3d2b2c6c4c9c5f7e01 100644 (file)
 #define __inline__     __inline__      __attribute__((always_inline))
 #define __inline       __inline        __attribute__((always_inline))
 #define __deprecated                   __attribute__((deprecated))
+#define __packed                       __attribute__((packed))
+#define __weak                         __attribute__((weak))
+#define __naked                                __attribute__((naked))
+#define __noreturn                     __attribute__((noreturn))
+#define __pure                         __attribute__((pure))
+#define __aligned(x)                   __attribute__((aligned(x)))
+#define __printf(a,b)                  __attribute__((format(printf,a,b)))
 #define  noinline                      __attribute__((noinline))
 #define __attribute_pure__             __attribute__((pure))
 #define __attribute_const__            __attribute__((__const__))
index 7d0420274de00d26b86d6d986631860bb158d5d3..de25ee3b79196b1daa7d95ccb871f32652eb1a8a 100644 (file)
@@ -21,6 +21,7 @@ struct vc_data;
 struct console_font_op;
 struct console_font;
 struct module;
+struct tty_struct;
 
 /*
  * this is what the terminal answers to a ESC-Z or csi0c query.
@@ -132,6 +133,9 @@ static inline void resume_console(void) {}
 int mda_console_init(void);
 void prom_con_init(void);
 
+void vcs_make_sysfs(struct tty_struct *tty);
+void vcs_remove_sysfs(struct tty_struct *tty);
+
 /* Some debug stub to catch some of the obvious races in the VT code */
 #if 1
 #define WARN_CONSOLE_UNLOCKED()        WARN_ON(!is_console_locked() && !oops_in_progress)
index ed6c0fee1ac76fa5af1e0ed27c26a6b6fbc86395..a86162b26c0dde5a349a81129e67b74f1506d821 100644 (file)
@@ -11,6 +11,7 @@
 
 #include <linux/wait.h>
 #include <linux/vt.h>
+#include <linux/workqueue.h>
 
 struct vt_struct;
 
@@ -103,6 +104,7 @@ struct vc_data {
 
 struct vc {
        struct vc_data *d;
+       struct work_struct SAK_work;
 
        /* might add  scrmem, vt_struct, kbd  at some time,
           to have everything in one place - the disadvantage
@@ -110,6 +112,7 @@ struct vc {
 };
 
 extern struct vc vc_cons [MAX_NR_CONSOLES];
+extern void vc_SAK(struct work_struct *work);
 
 #define CUR_DEF                0
 #define CUR_NONE       1
index 4aa9046601da18e8c7d18a26b661197887bd6aec..779aa78ee64341135ae1b943e381c3e6dec8d32f 100644 (file)
 /*
  * Transform masks and values (for crt_flags).
  */
-#define CRYPTO_TFM_MODE_MASK           0x000000ff
 #define CRYPTO_TFM_REQ_MASK            0x000fff00
 #define CRYPTO_TFM_RES_MASK            0xfff00000
 
-#define CRYPTO_TFM_MODE_ECB            0x00000001
-#define CRYPTO_TFM_MODE_CBC            0x00000002
-#define CRYPTO_TFM_MODE_CFB            0x00000004
-#define CRYPTO_TFM_MODE_CTR            0x00000008
-
 #define CRYPTO_TFM_REQ_WEAK_KEY                0x00000100
 #define CRYPTO_TFM_REQ_MAY_SLEEP       0x00000200
 #define CRYPTO_TFM_RES_WEAK_KEY                0x00100000
 /*
  * Miscellaneous stuff.
  */
-#define CRYPTO_UNSPEC                  0
 #define CRYPTO_MAX_ALG_NAME            64
 
-#define CRYPTO_DIR_ENCRYPT             1
-#define CRYPTO_DIR_DECRYPT             0
-
 /*
  * The macro CRYPTO_MINALIGN_ATTR (along with the void * type in the actual
  * declaration) is used to ensure that the crypto_tfm context structure is
@@ -148,19 +138,6 @@ struct cipher_alg {
                          unsigned int keylen);
        void (*cia_encrypt)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
        void (*cia_decrypt)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
-
-       unsigned int (*cia_encrypt_ecb)(const struct cipher_desc *desc,
-                                       u8 *dst, const u8 *src,
-                                       unsigned int nbytes) __deprecated;
-       unsigned int (*cia_decrypt_ecb)(const struct cipher_desc *desc,
-                                       u8 *dst, const u8 *src,
-                                       unsigned int nbytes) __deprecated;
-       unsigned int (*cia_encrypt_cbc)(const struct cipher_desc *desc,
-                                       u8 *dst, const u8 *src,
-                                       unsigned int nbytes) __deprecated;
-       unsigned int (*cia_decrypt_cbc)(const struct cipher_desc *desc,
-                                       u8 *dst, const u8 *src,
-                                       unsigned int nbytes) __deprecated;
 };
 
 struct digest_alg {
@@ -243,11 +220,6 @@ int crypto_unregister_alg(struct crypto_alg *alg);
 #ifdef CONFIG_CRYPTO
 int crypto_has_alg(const char *name, u32 type, u32 mask);
 #else
-static inline int crypto_alg_available(const char *name, u32 flags)
-{
-       return 0;
-}
-
 static inline int crypto_has_alg(const char *name, u32 type, u32 mask)
 {
        return 0;
@@ -339,13 +311,18 @@ struct crypto_tfm {
        void *__crt_ctx[] CRYPTO_MINALIGN_ATTR;
 };
 
-#define crypto_cipher crypto_tfm
-#define crypto_comp crypto_tfm
-
 struct crypto_blkcipher {
        struct crypto_tfm base;
 };
 
+struct crypto_cipher {
+       struct crypto_tfm base;
+};
+
+struct crypto_comp {
+       struct crypto_tfm base;
+};
+
 struct crypto_hash {
        struct crypto_tfm base;
 };
@@ -395,40 +372,11 @@ static inline u32 crypto_tfm_alg_type(struct crypto_tfm *tfm)
        return tfm->__crt_alg->cra_flags & CRYPTO_ALG_TYPE_MASK;
 }
 
-static unsigned int crypto_tfm_alg_min_keysize(struct crypto_tfm *tfm)
-       __deprecated;
-static inline unsigned int crypto_tfm_alg_min_keysize(struct crypto_tfm *tfm)
-{
-       BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
-       return tfm->__crt_alg->cra_cipher.cia_min_keysize;
-}
-
-static unsigned int crypto_tfm_alg_max_keysize(struct crypto_tfm *tfm)
-       __deprecated;
-static inline unsigned int crypto_tfm_alg_max_keysize(struct crypto_tfm *tfm)
-{
-       BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
-       return tfm->__crt_alg->cra_cipher.cia_max_keysize;
-}
-
-static unsigned int crypto_tfm_alg_ivsize(struct crypto_tfm *tfm) __deprecated;
-static inline unsigned int crypto_tfm_alg_ivsize(struct crypto_tfm *tfm)
-{
-       BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
-       return tfm->crt_cipher.cit_ivsize;
-}
-
 static inline unsigned int crypto_tfm_alg_blocksize(struct crypto_tfm *tfm)
 {
        return tfm->__crt_alg->cra_blocksize;
 }
 
-static inline unsigned int crypto_tfm_alg_digestsize(struct crypto_tfm *tfm)
-{
-       BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST);
-       return tfm->__crt_alg->cra_digest.dia_digestsize;
-}
-
 static inline unsigned int crypto_tfm_alg_alignmask(struct crypto_tfm *tfm)
 {
        return tfm->__crt_alg->cra_alignmask;
@@ -633,7 +581,7 @@ static inline struct crypto_cipher *crypto_alloc_cipher(const char *alg_name,
 
 static inline struct crypto_tfm *crypto_cipher_tfm(struct crypto_cipher *tfm)
 {
-       return tfm;
+       return &tfm->base;
 }
 
 static inline void crypto_free_cipher(struct crypto_cipher *tfm)
@@ -809,76 +757,6 @@ static inline int crypto_hash_setkey(struct crypto_hash *hash,
        return crypto_hash_crt(hash)->setkey(hash, key, keylen);
 }
 
-static int crypto_cipher_encrypt(struct crypto_tfm *tfm,
-                                struct scatterlist *dst,
-                                struct scatterlist *src,
-                                unsigned int nbytes) __deprecated;
-static inline int crypto_cipher_encrypt(struct crypto_tfm *tfm,
-                                        struct scatterlist *dst,
-                                        struct scatterlist *src,
-                                        unsigned int nbytes)
-{
-       BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
-       return tfm->crt_cipher.cit_encrypt(tfm, dst, src, nbytes);
-}                                        
-
-static int crypto_cipher_encrypt_iv(struct crypto_tfm *tfm,
-                                   struct scatterlist *dst,
-                                   struct scatterlist *src,
-                                   unsigned int nbytes, u8 *iv) __deprecated;
-static inline int crypto_cipher_encrypt_iv(struct crypto_tfm *tfm,
-                                           struct scatterlist *dst,
-                                           struct scatterlist *src,
-                                           unsigned int nbytes, u8 *iv)
-{
-       BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
-       return tfm->crt_cipher.cit_encrypt_iv(tfm, dst, src, nbytes, iv);
-}                                        
-
-static int crypto_cipher_decrypt(struct crypto_tfm *tfm,
-                                struct scatterlist *dst,
-                                struct scatterlist *src,
-                                unsigned int nbytes) __deprecated;
-static inline int crypto_cipher_decrypt(struct crypto_tfm *tfm,
-                                        struct scatterlist *dst,
-                                        struct scatterlist *src,
-                                        unsigned int nbytes)
-{
-       BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
-       return tfm->crt_cipher.cit_decrypt(tfm, dst, src, nbytes);
-}
-
-static int crypto_cipher_decrypt_iv(struct crypto_tfm *tfm,
-                                   struct scatterlist *dst,
-                                   struct scatterlist *src,
-                                   unsigned int nbytes, u8 *iv) __deprecated;
-static inline int crypto_cipher_decrypt_iv(struct crypto_tfm *tfm,
-                                           struct scatterlist *dst,
-                                           struct scatterlist *src,
-                                           unsigned int nbytes, u8 *iv)
-{
-       BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
-       return tfm->crt_cipher.cit_decrypt_iv(tfm, dst, src, nbytes, iv);
-}
-
-static void crypto_cipher_set_iv(struct crypto_tfm *tfm,
-                                const u8 *src, unsigned int len) __deprecated;
-static inline void crypto_cipher_set_iv(struct crypto_tfm *tfm,
-                                        const u8 *src, unsigned int len)
-{
-       BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
-       memcpy(tfm->crt_cipher.cit_iv, src, len);
-}
-
-static void crypto_cipher_get_iv(struct crypto_tfm *tfm,
-                                u8 *dst, unsigned int len) __deprecated;
-static inline void crypto_cipher_get_iv(struct crypto_tfm *tfm,
-                                        u8 *dst, unsigned int len)
-{
-       BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
-       memcpy(dst, tfm->crt_cipher.cit_iv, len);
-}
-
 static inline struct crypto_comp *__crypto_comp_cast(struct crypto_tfm *tfm)
 {
        return (struct crypto_comp *)tfm;
@@ -903,7 +781,7 @@ static inline struct crypto_comp *crypto_alloc_comp(const char *alg_name,
 
 static inline struct crypto_tfm *crypto_comp_tfm(struct crypto_comp *tfm)
 {
-       return tfm;
+       return &tfm->base;
 }
 
 static inline void crypto_free_comp(struct crypto_comp *tfm)
@@ -934,14 +812,16 @@ static inline int crypto_comp_compress(struct crypto_comp *tfm,
                                        const u8 *src, unsigned int slen,
                                        u8 *dst, unsigned int *dlen)
 {
-       return crypto_comp_crt(tfm)->cot_compress(tfm, src, slen, dst, dlen);
+       return crypto_comp_crt(tfm)->cot_compress(crypto_comp_tfm(tfm),
+                                                 src, slen, dst, dlen);
 }
 
 static inline int crypto_comp_decompress(struct crypto_comp *tfm,
                                          const u8 *src, unsigned int slen,
                                          u8 *dst, unsigned int *dlen)
 {
-       return crypto_comp_crt(tfm)->cot_decompress(tfm, src, slen, dst, dlen);
+       return crypto_comp_crt(tfm)->cot_decompress(crypto_comp_tfm(tfm),
+                                                   src, slen, dst, dlen);
 }
 
 #endif /* _LINUX_CRYPTO_H */
index 5ca1cdba563a43b4bc05cbe99b313203822add6b..26e4692f2d1a185c7c3bbe986e970eb1928721d7 100644 (file)
@@ -354,6 +354,41 @@ extern int __must_check device_create_bin_file(struct device *dev,
                                               struct bin_attribute *attr);
 extern void device_remove_bin_file(struct device *dev,
                                   struct bin_attribute *attr);
+
+/* device resource management */
+typedef void (*dr_release_t)(struct device *dev, void *res);
+typedef int (*dr_match_t)(struct device *dev, void *res, void *match_data);
+
+#ifdef CONFIG_DEBUG_DEVRES
+extern void * __devres_alloc(dr_release_t release, size_t size, gfp_t gfp,
+                            const char *name);
+#define devres_alloc(release, size, gfp) \
+       __devres_alloc(release, size, gfp, #release)
+#else
+extern void * devres_alloc(dr_release_t release, size_t size, gfp_t gfp);
+#endif
+extern void devres_free(void *res);
+extern void devres_add(struct device *dev, void *res);
+extern void * devres_find(struct device *dev, dr_release_t release,
+                         dr_match_t match, void *match_data);
+extern void * devres_get(struct device *dev, void *new_res,
+                        dr_match_t match, void *match_data);
+extern void * devres_remove(struct device *dev, dr_release_t release,
+                           dr_match_t match, void *match_data);
+extern int devres_destroy(struct device *dev, dr_release_t release,
+                         dr_match_t match, void *match_data);
+
+/* devres group */
+extern void * __must_check devres_open_group(struct device *dev, void *id,
+                                            gfp_t gfp);
+extern void devres_close_group(struct device *dev, void *id);
+extern void devres_remove_group(struct device *dev, void *id);
+extern int devres_release_group(struct device *dev, void *id);
+
+/* managed kzalloc/kfree for device drivers, no kmalloc, always use kzalloc */
+extern void *devm_kzalloc(struct device *dev, size_t size, gfp_t gfp);
+extern void devm_kfree(struct device *dev, void *p);
+
 struct device {
        struct klist            klist_children;
        struct klist_node       knode_parent;           /* node in sibling list */
@@ -397,6 +432,9 @@ struct device {
        /* arch specific additions */
        struct dev_archdata     archdata;
 
+       spinlock_t              devres_lock;
+       struct list_head        devres_head;
+
        /* class_device migration path */
        struct list_head        node;
        struct class            *class;
index ff203c465fed260f75de3c0d80a71e7d90f101d2..9a663c6db16a09faf68fe0d544e1c41695a9a6ef 100644 (file)
@@ -66,6 +66,33 @@ dma_mark_declared_memory_occupied(struct device *dev,
 }
 #endif
 
-#endif
+/*
+ * Managed DMA API
+ */
+extern void *dmam_alloc_coherent(struct device *dev, size_t size,
+                                dma_addr_t *dma_handle, gfp_t gfp);
+extern void dmam_free_coherent(struct device *dev, size_t size, void *vaddr,
+                              dma_addr_t dma_handle);
+extern void *dmam_alloc_noncoherent(struct device *dev, size_t size,
+                                   dma_addr_t *dma_handle, gfp_t gfp);
+extern void dmam_free_noncoherent(struct device *dev, size_t size, void *vaddr,
+                                 dma_addr_t dma_handle);
+#ifdef ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY
+extern int dmam_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
+                                       dma_addr_t device_addr, size_t size,
+                                       int flags);
+extern void dmam_release_declared_memory(struct device *dev);
+#else /* ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY */
+static inline int dmam_declare_coherent_memory(struct device *dev,
+                               dma_addr_t bus_addr, dma_addr_t device_addr,
+                               size_t size, gfp_t gfp)
+{
+       return 0;
+}
 
+static inline void dmam_release_declared_memory(struct device *dev)
+{
+}
+#endif /* ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY */
 
+#endif
index 76f12f46db7f655f545b13a6e9c3c5c0b58acc30..022e34fcbd1bf6b56cb5f0dbb250a28885797f80 100644 (file)
@@ -24,5 +24,12 @@ void *dma_pool_alloc(struct dma_pool *pool, gfp_t mem_flags,
 
 void dma_pool_free(struct dma_pool *pool, void *vaddr, dma_addr_t addr);
 
+/*
+ * Managed DMA pool
+ */
+struct dma_pool *dmam_pool_create(const char *name, struct device *dev,
+                                 size_t size, size_t align, size_t allocation);
+void dmam_pool_destroy(struct dma_pool *pool);
+
 #endif
 
index 10b6a6fd5837c58b48746a7ecbd0391207c817d4..02bba040fcfb7e5e058b5c25d6bb138873ede572 100644 (file)
@@ -113,7 +113,7 @@ struct accessdata_dn
  * DECnet logical link information structure
  */
 struct linkinfo_dn {
-        __le16  idn_segsize;    /* Segment size for link */
+        __u16  idn_segsize;    /* Segment size for link */
         __u8   idn_linkstate;  /* Logical link state    */
 };
 
index 1ff7c1392525884b0f7ee005ae21ff822b01ae56..fe806b6f030dfb2d7583751cc33d96f36a8b7d90 100644 (file)
@@ -61,10 +61,20 @@ struct eisa_driver {
 
 #define to_eisa_driver(drv) container_of(drv,struct eisa_driver, driver)
 
+/* These external functions are only available when EISA support is enabled. */
+#ifdef CONFIG_EISA
+
 extern struct bus_type eisa_bus_type;
 int eisa_driver_register (struct eisa_driver *edrv);
 void eisa_driver_unregister (struct eisa_driver *edrv);
 
+#else /* !CONFIG_EISA */
+
+static inline int eisa_driver_register (struct eisa_driver *edrv) { return 0; }
+static inline void eisa_driver_unregister (struct eisa_driver *edrv) { }
+
+#endif /* !CONFIG_EISA */
+
 /* Mimics pci.h... */
 static inline void *eisa_get_drvdata (struct eisa_device *edev)
 {
index 1410e5330c8daafb1a9e781dca9c56c5e1c4a0e5..20fd1619ccfb0914c7e1e895c48240e0f42a45fb 100644 (file)
@@ -169,6 +169,7 @@ extern int dir_notify_enable;
 #define IS_DIRSYNC(inode)      (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
                                        ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
 #define IS_MANDLOCK(inode)     __IS_FLG(inode, MS_MANDLOCK)
+#define IS_NOATIME(inode)   __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
 
 #define IS_NOQUOTA(inode)      ((inode)->i_flags & S_NOQUOTA)
 #define IS_APPEND(inode)       ((inode)->i_flags & S_APPEND)
@@ -1572,12 +1573,18 @@ extern int invalidate_partition(struct gendisk *, int);
 extern int invalidate_inodes(struct super_block *);
 unsigned long invalidate_mapping_pages(struct address_space *mapping,
                                        pgoff_t start, pgoff_t end);
-unsigned long invalidate_inode_pages(struct address_space *mapping);
+
+static inline unsigned long __deprecated
+invalidate_inode_pages(struct address_space *mapping)
+{
+       return invalidate_mapping_pages(mapping, 0, ~0UL);
+}
+
 static inline void invalidate_remote_inode(struct inode *inode)
 {
        if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
            S_ISLNK(inode->i_mode))
-               invalidate_inode_pages(inode->i_mapping);
+               invalidate_mapping_pages(inode->i_mapping, 0, -1);
 }
 extern int invalidate_inode_pages2(struct address_space *mapping);
 extern int invalidate_inode_pages2_range(struct address_space *mapping,
index 0a022b2f63fc0fa95fa35df16784e2fcaef225b3..2c65da7cabb2a25acc1c42c067a3770872f29141 100644 (file)
@@ -20,7 +20,11 @@ enum {
        LINUX_EXTENDED_PARTITION = 0x85,
        WIN98_EXTENDED_PARTITION = 0x0f,
 
+       SUN_WHOLE_DISK = DOS_EXTENDED_PARTITION,
+
        LINUX_SWAP_PARTITION = 0x82,
+       LINUX_DATA_PARTITION = 0x83,
+       LINUX_LVM_PARTITION = 0x8e,
        LINUX_RAID_PARTITION = 0xfd,    /* autodetect RAID partition */
 
        SOLARIS_X86_PARTITION = LINUX_SWAP_PARTITION,
@@ -400,10 +404,14 @@ struct unixware_disklabel {
 
 #ifdef __KERNEL__
 
+#define ADDPART_FLAG_NONE      0
+#define ADDPART_FLAG_RAID      1
+#define ADDPART_FLAG_WHOLEDISK 2
+
 char *disk_name (struct gendisk *hd, int part, char *buf);
 
 extern int rescan_partitions(struct gendisk *disk, struct block_device *bdev);
-extern void add_partition(struct gendisk *, int, sector_t, sector_t);
+extern void add_partition(struct gendisk *, int, sector_t, sector_t, int);
 extern void delete_partition(struct gendisk *, int);
 
 extern struct gendisk *alloc_disk_node(int minors, int node_id);
index 00c314aedab7d8f9487112e9a4d16182185b6332..2a7d15bcde4684a8b40a4f7aaf65e2e0177faf39 100644 (file)
@@ -70,7 +70,7 @@ struct vm_area_struct;
 #ifdef CONFIG_NUMA
 #define GFP_THISNODE   (__GFP_THISNODE | __GFP_NOWARN | __GFP_NORETRY)
 #else
-#define GFP_THISNODE   0
+#define GFP_THISNODE   ((__force gfp_t)0)
 #endif
 
 
@@ -85,8 +85,10 @@ struct vm_area_struct;
 
 static inline enum zone_type gfp_zone(gfp_t flags)
 {
+#ifdef CONFIG_ZONE_DMA
        if (flags & __GFP_DMA)
                return ZONE_DMA;
+#endif
 #ifdef CONFIG_ZONE_DMA32
        if (flags & __GFP_DMA32)
                return ZONE_DMA32;
index d38778f2fbecec8ef06fca43f06b3ecc86fa5e89..6e7ec4c76178d9bd535de52762bc9017496c7797 100644 (file)
 #define I2C_DRIVERID_KS0127    86      /* Samsung ks0127 video decoder */
 #define I2C_DRIVERID_TLV320AIC23B 87   /* TI TLV320AIC23B audio codec  */
 #define I2C_DRIVERID_ISL1208   88      /* Intersil ISL1208 RTC         */
+#define I2C_DRIVERID_WM8731            89      /* Wolfson WM8731 audio codec */
+#define I2C_DRIVERID_WM8750            90      /* Wolfson WM8750 audio codec */
 
 #define I2C_DRIVERID_I2CDEV    900
 #define I2C_DRIVERID_ARP        902    /* SMBus ARP Client              */
index 99393ef3af394b8bfd411ec65d95b4bd7c815191..f3de05c306785c5fe8e6c50f4ac474faf8191531 100644 (file)
@@ -41,6 +41,7 @@ struct sockaddr_ll
 #define PACKET_RX_RING                 5
 #define PACKET_STATISTICS              6
 #define PACKET_COPY_THRESH             7
+#define PACKET_AUXDATA                 8
 
 struct tpacket_stats
 {
@@ -48,6 +49,15 @@ struct tpacket_stats
        unsigned int    tp_drops;
 };
 
+struct tpacket_auxdata
+{
+       __u32           tp_status;
+       __u32           tp_len;
+       __u32           tp_snaplen;
+       __u16           tp_mac;
+       __u16           tp_net;
+};
+
 struct tpacket_hdr
 {
        unsigned long   tp_status;
index 5a593a1dec1efd7f53ab6ac58349db9b996157d2..c65f5107d512c4a2df0e3373616772849c9e383b 100644 (file)
@@ -172,7 +172,7 @@ void __init parse_early_param(void);
  * module_init() - driver initialization entry point
  * @x: function to be run at kernel boot time or module insertion
  * 
- * module_init() will either be called during do_initcalls (if
+ * module_init() will either be called during do_initcalls() (if
  * builtin) or at module insertion time (if a module).  There can only
  * be one per module.
  */
index e36e86c869fb4e6576e3c67fd1febd0d16ba1ea2..5a8ba0b8ccbae860bc8d36b1f6082d94e51402fb 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/sched.h>
 #include <linux/irqflags.h>
 #include <linux/bottom_half.h>
+#include <linux/device.h>
 #include <asm/atomic.h>
 #include <asm/ptrace.h>
 #include <asm/system.h>
@@ -83,6 +84,11 @@ extern int request_irq(unsigned int, irq_handler_t handler,
                       unsigned long, const char *, void *);
 extern void free_irq(unsigned int, void *);
 
+extern int devm_request_irq(struct device *dev, unsigned int irq,
+                           irq_handler_t handler, unsigned long irqflags,
+                           const char *devname, void *dev_id);
+extern void devm_free_irq(struct device *dev, unsigned int irq, void *dev_id);
+
 /*
  * On lockdep we dont want to enable hardirqs in hardirq
  * context. Use local_irq_enable_in_hardirq() to annotate
index 81877ea39309aea73cef4a63a3212c69ab5c9131..c244a0cc9319bc37dfaee08d2c385b638dcbc990 100644 (file)
 #include <asm/io.h>
 #include <asm/page.h>
 
+struct device;
+
 void __iowrite32_copy(void __iomem *to, const void *from, size_t count);
 void __iowrite64_copy(void __iomem *to, const void *from, size_t count);
 
 int ioremap_page_range(unsigned long addr, unsigned long end,
                       unsigned long phys_addr, pgprot_t prot);
 
+/*
+ * Managed iomap interface
+ */
+void __iomem * devm_ioport_map(struct device *dev, unsigned long port,
+                              unsigned int nr);
+void devm_ioport_unmap(struct device *dev, void __iomem *addr);
+
+void __iomem * devm_ioremap(struct device *dev, unsigned long offset,
+                           unsigned long size);
+void __iomem * devm_ioremap_nocache(struct device *dev, unsigned long offset,
+                                   unsigned long size);
+void devm_iounmap(struct device *dev, void __iomem *addr);
+
 /**
  *     check_signature         -       find BIOS signatures
  *     @io_addr: mmio address to check
index 15228d79c5bc0c32f5189ceb28b6adff526f3423..6859a3b14088459fef9de4e373f36ea0009a0f3a 100644 (file)
@@ -137,4 +137,24 @@ static inline int __deprecated check_region(resource_size_t s,
 {
        return __check_region(&ioport_resource, s, n);
 }
+
+/* Wrappers for managed devices */
+struct device;
+#define devm_request_region(dev,start,n,name) \
+       __devm_request_region(dev, &ioport_resource, (start), (n), (name))
+#define devm_request_mem_region(dev,start,n,name) \
+       __devm_request_region(dev, &iomem_resource, (start), (n), (name))
+
+extern struct resource * __devm_request_region(struct device *dev,
+                               struct resource *parent, resource_size_t start,
+                               resource_size_t n, const char *name);
+
+#define devm_release_region(start,n) \
+       __devm_release_region(dev, &ioport_resource, (start), (n))
+#define devm_release_mem_region(start,n) \
+       __devm_release_region(dev, &iomem_resource, (start), (n))
+
+extern void __devm_release_region(struct device *dev, struct resource *parent,
+                                 resource_size_t start, resource_size_t n);
+
 #endif /* _LINUX_IOPORT_H */
index 63fb18dcac3075fb0e75eef911b947e49309b32d..e91dce75bbcc74ecdf905b897ccced8a090c0063 100644 (file)
@@ -176,6 +176,7 @@ static inline void console_verbose(void)
 }
 
 extern void bust_spinlocks(int yes);
+extern void wake_up_klogd(void);
 extern int oops_in_progress;           /* If set, an oops, panic(), BUG() or die() is in progress */
 extern int panic_timeout;
 extern int panic_on_oops;
@@ -200,6 +201,7 @@ extern enum system_states {
 #define TAINT_FORCED_RMMOD             (1<<3)
 #define TAINT_MACHINE_CHECK            (1<<4)
 #define TAINT_BAD_PAGE                 (1<<5)
+#define TAINT_USER                     (1<<6)
 
 extern void dump_stack(void);
 
@@ -312,6 +314,9 @@ static inline int __attribute__ ((format (printf, 1, 2))) pr_debug(const char *
        (void)__tmp; \
 })
 
+struct sysinfo;
+extern int do_sysinfo(struct sysinfo *info);
+
 #endif /* __KERNEL__ */
 
 #define SI_LOAD_SHIFT  16
index 48eccd865bd8add9d9353f13771eab89745f0000..404f4464cb1aaf255b58c818a865ae4de2e103c7 100644 (file)
@@ -74,7 +74,7 @@ static inline void kfifo_reset(struct kfifo *fifo)
  * @buffer: the data to be added.
  * @len: the length of the data to be added.
  *
- * This function copies at most 'len' bytes from the 'buffer' into
+ * This function copies at most @len bytes from the @buffer into
  * the FIFO depending on the free space, and returns the number of
  * bytes copied.
  */
@@ -99,8 +99,8 @@ static inline unsigned int kfifo_put(struct kfifo *fifo,
  * @buffer: where the data must be copied.
  * @len: the size of the destination buffer.
  *
- * This function copies at most 'len' bytes from the FIFO into the
- * 'buffer' and returns the number of copied bytes.
+ * This function copies at most @len bytes from the FIFO into the
+ * @buffer and returns the number of copied bytes.
  */
 static inline unsigned int kfifo_get(struct kfifo *fifo,
                                     unsigned char *buffer, unsigned int len)
diff --git a/include/linux/ks0108.h b/include/linux/ks0108.h
new file mode 100644 (file)
index 0000000..8047d4b
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ *    Filename: ks0108.h
+ *     Version: 0.1.0
+ * Description: ks0108 LCD Controller driver header
+ *     License: GPLv2
+ *
+ *      Author: Copyright (C) Miguel Ojeda Sandonis <maxextreme@gmail.com>
+ *        Date: 2006-10-31
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+#ifndef _KS0108_H_
+#define _KS0108_H_
+
+/* Write a byte to the data port */
+extern void ks0108_writedata(unsigned char byte);
+
+/* Write a byte to the control port */
+extern void ks0108_writecontrol(unsigned char byte);
+
+/* Set the controller's current display state (0..1) */
+extern void ks0108_displaystate(unsigned char state);
+
+/* Set the controller's current startline (0..63) */
+extern void ks0108_startline(unsigned char startline);
+
+/* Set the controller's current address (0..63) */
+extern void ks0108_address(unsigned char address);
+
+/* Set the controller's current page (0..7) */
+extern void ks0108_page(unsigned char page);
+
+#endif /* _KS0108_H_ */
index 611f17f79eefe32f78605589f175db8a77616474..7444a63262318934415604a98b96d94c5bd5964b 100644 (file)
@@ -163,7 +163,7 @@ static inline ktime_t ktime_sub(const ktime_t lhs, const ktime_t rhs)
  * @add1:      addend1
  * @add2:      addend2
  *
- * Returns the sum of addend1 and addend2
+ * Returns the sum of @add1 and @add2.
  */
 static inline ktime_t ktime_add(const ktime_t add1, const ktime_t add2)
 {
@@ -189,7 +189,7 @@ static inline ktime_t ktime_add(const ktime_t add1, const ktime_t add2)
  * @kt:                addend
  * @nsec:      the scalar nsec value to add
  *
- * Returns the sum of kt and nsec in ktime_t format
+ * Returns the sum of @kt and @nsec in ktime_t format
  */
 extern ktime_t ktime_add_ns(const ktime_t kt, u64 nsec);
 
@@ -246,7 +246,7 @@ static inline struct timeval ktime_to_timeval(const ktime_t kt)
  * ktime_to_ns - convert a ktime_t variable to scalar nanoseconds
  * @kt:                the ktime_t variable to convert
  *
- * Returns the scalar nanoseconds representation of kt
+ * Returns the scalar nanoseconds representation of @kt
  */
 static inline s64 ktime_to_ns(const ktime_t kt)
 {
index 91bb8ceef0b5ab04ce1a462e68505cc53942d1bf..596e0c18887db5ce778ef1c9defd038383d9febe 100644 (file)
@@ -31,7 +31,7 @@
 #include <linux/pci.h>
 #include <linux/dma-mapping.h>
 #include <asm/scatterlist.h>
-#include <asm/io.h>
+#include <linux/io.h>
 #include <linux/ata.h>
 #include <linux/workqueue.h>
 #include <scsi/scsi_host.h>
@@ -54,8 +54,6 @@
 #undef ATA_VERBOSE_DEBUG       /* yet more debugging output */
 #undef ATA_IRQ_TRAP            /* define to ack screaming irqs */
 #undef ATA_NDEBUG              /* define to disable quick runtime checks */
-#define ATA_ENABLE_PATA                /* define to enable PATA support in some
-                                * low-level drivers */
 
 
 /* note: prints function name for you */
@@ -109,10 +107,6 @@ static inline u32 ata_msg_init(int dval, int default_msg_enable_bits)
 #define ATA_TAG_POISON         0xfafbfcfdU
 
 /* move to PCI layer? */
-#define PCI_VDEVICE(vendor, device)            \
-       PCI_VENDOR_ID_##vendor, (device),       \
-       PCI_ANY_ID, PCI_ANY_ID, 0, 0
-
 static inline struct device *pci_dev_to_dev(struct pci_dev *pdev)
 {
        return &pdev->dev;
@@ -308,7 +302,7 @@ enum {
         * most devices.
         */
        ATA_SPINUP_WAIT         = 8000,
-       
+
        /* Horkage types. May be set by libata or controller on drives
           (some horkage may be drive/controller pair dependant */
 
@@ -352,21 +346,21 @@ typedef int (*ata_reset_fn_t)(struct ata_port *ap, unsigned int *classes);
 typedef void (*ata_postreset_fn_t)(struct ata_port *ap, unsigned int *classes);
 
 struct ata_ioports {
-       unsigned long           cmd_addr;
-       unsigned long           data_addr;
-       unsigned long           error_addr;
-       unsigned long           feature_addr;
-       unsigned long           nsect_addr;
-       unsigned long           lbal_addr;
-       unsigned long           lbam_addr;
-       unsigned long           lbah_addr;
-       unsigned long           device_addr;
-       unsigned long           status_addr;
-       unsigned long           command_addr;
-       unsigned long           altstatus_addr;
-       unsigned long           ctl_addr;
-       unsigned long           bmdma_addr;
-       unsigned long           scr_addr;
+       void __iomem            *cmd_addr;
+       void __iomem            *data_addr;
+       void __iomem            *error_addr;
+       void __iomem            *feature_addr;
+       void __iomem            *nsect_addr;
+       void __iomem            *lbal_addr;
+       void __iomem            *lbam_addr;
+       void __iomem            *lbah_addr;
+       void __iomem            *device_addr;
+       void __iomem            *status_addr;
+       void __iomem            *command_addr;
+       void __iomem            *altstatus_addr;
+       void __iomem            *ctl_addr;
+       void __iomem            *bmdma_addr;
+       void __iomem            *scr_addr;
 };
 
 struct ata_probe_ent {
@@ -385,7 +379,7 @@ struct ata_probe_ent {
        unsigned int            irq_flags;
        unsigned long           port_flags;
        unsigned long           _host_flags;
-       void __iomem            *mmio_base;
+       void __iomem * const    *iomap;
        void                    *private_data;
 
        /* port_info for the secondary port.  Together with irq2, it's
@@ -402,7 +396,7 @@ struct ata_host {
        struct device           *dev;
        unsigned long           irq;
        unsigned long           irq2;
-       void __iomem            *mmio_base;
+       void __iomem * const    *iomap;
        unsigned int            n_ports;
        void                    *private_data;
        const struct ata_port_operations *ops;
@@ -431,9 +425,6 @@ struct ata_queued_cmd {
 
        unsigned int            pad_len;
 
-       unsigned int            nsect;
-       unsigned int            cursect;
-
        unsigned int            nbytes;
        unsigned int            curbytes;
 
@@ -639,6 +630,8 @@ struct ata_port_operations {
 
        irq_handler_t irq_handler;
        void (*irq_clear) (struct ata_port *);
+       u8 (*irq_on) (struct ata_port *);
+       u8 (*irq_ack) (struct ata_port *ap, unsigned int chk_drq);
 
        u32 (*scr_read) (struct ata_port *ap, unsigned int sc_reg);
        void (*scr_write) (struct ata_port *ap, unsigned int sc_reg,
@@ -720,20 +713,18 @@ extern int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_i
                             unsigned int n_ports);
 extern void ata_pci_remove_one (struct pci_dev *pdev);
 extern void ata_pci_device_do_suspend(struct pci_dev *pdev, pm_message_t mesg);
-extern void ata_pci_device_do_resume(struct pci_dev *pdev);
+extern int __must_check ata_pci_device_do_resume(struct pci_dev *pdev);
 extern int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg);
 extern int ata_pci_device_resume(struct pci_dev *pdev);
 extern int ata_pci_clear_simplex(struct pci_dev *pdev);
 #endif /* CONFIG_PCI */
 extern int ata_device_add(const struct ata_probe_ent *ent);
-extern void ata_port_detach(struct ata_port *ap);
+extern void ata_host_detach(struct ata_host *host);
 extern void ata_host_init(struct ata_host *, struct device *,
                          unsigned long, const struct ata_port_operations *);
-extern void ata_host_remove(struct ata_host *host);
 extern int ata_scsi_detect(struct scsi_host_template *sht);
 extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg);
 extern int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *));
-extern int ata_scsi_release(struct Scsi_Host *host);
 extern void ata_sas_port_destroy(struct ata_port *);
 extern struct ata_port *ata_sas_port_alloc(struct ata_host *,
                                           struct ata_port_info *, struct Scsi_Host *);
@@ -776,15 +767,11 @@ extern u8 ata_check_status(struct ata_port *ap);
 extern u8 ata_altstatus(struct ata_port *ap);
 extern void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf);
 extern int ata_port_start (struct ata_port *ap);
-extern void ata_port_stop (struct ata_port *ap);
-extern void ata_host_stop (struct ata_host *host);
 extern irqreturn_t ata_interrupt (int irq, void *dev_instance);
-extern void ata_mmio_data_xfer(struct ata_device *adev, unsigned char *buf,
-                              unsigned int buflen, int write_data);
-extern void ata_pio_data_xfer(struct ata_device *adev, unsigned char *buf,
-                             unsigned int buflen, int write_data);
-extern void ata_pio_data_xfer_noirq(struct ata_device *adev, unsigned char *buf,
-                             unsigned int buflen, int write_data);
+extern void ata_data_xfer(struct ata_device *adev, unsigned char *buf,
+                         unsigned int buflen, int write_data);
+extern void ata_data_xfer_noirq(struct ata_device *adev, unsigned char *buf,
+                               unsigned int buflen, int write_data);
 extern void ata_qc_prep(struct ata_queued_cmd *qc);
 extern void ata_noop_qc_prep(struct ata_queued_cmd *qc);
 extern unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc);
@@ -826,6 +813,10 @@ extern void ata_scsi_slave_destroy(struct scsi_device *sdev);
 extern int ata_scsi_change_queue_depth(struct scsi_device *sdev,
                                       int queue_depth);
 extern struct ata_device *ata_dev_pair(struct ata_device *adev);
+extern u8 ata_irq_on(struct ata_port *ap);
+extern u8 ata_dummy_irq_on(struct ata_port *ap);
+extern u8 ata_irq_ack(struct ata_port *ap, unsigned int chk_drq);
+extern u8 ata_dummy_irq_ack(struct ata_port *ap, unsigned int chk_drq);
 
 /*
  * Timing helpers
@@ -864,7 +855,6 @@ struct pci_bits {
        unsigned long           val;
 };
 
-extern void ata_pci_host_stop (struct ata_host *host);
 extern struct ata_probe_ent *
 ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int portmask);
 extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits);
@@ -1096,10 +1086,9 @@ static inline u8 ata_wait_idle(struct ata_port *ap)
        u8 status = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000);
 
        if (status != 0xff && (status & (ATA_BUSY | ATA_DRQ))) {
-               unsigned long l = ap->ioaddr.status_addr;
                if (ata_msg_warn(ap))
-                       printk(KERN_WARNING "ATA: abnormal status 0x%X on port 0x%lX\n",
-                               status, l);
+                       printk(KERN_WARNING "ATA: abnormal status 0x%X on port 0x%p\n",
+                               status, ap->ioaddr.status_addr);
        }
 
        return status;
@@ -1149,8 +1138,7 @@ static inline void ata_qc_reinit(struct ata_queued_cmd *qc)
        qc->dma_dir = DMA_NONE;
        qc->__sg = NULL;
        qc->flags = 0;
-       qc->cursect = qc->cursg = qc->cursg_ofs = 0;
-       qc->nsect = 0;
+       qc->cursg = qc->cursg_ofs = 0;
        qc->nbytes = qc->curbytes = 0;
        qc->n_elem = 0;
        qc->err_mask = 0;
@@ -1163,51 +1151,6 @@ static inline void ata_qc_reinit(struct ata_queued_cmd *qc)
        qc->result_tf.feature = 0;
 }
 
-/**
- *     ata_irq_ack - Acknowledge a device interrupt.
- *     @ap: Port on which interrupts are enabled.
- *
- *     Wait up to 10 ms for legacy IDE device to become idle (BUSY
- *     or BUSY+DRQ clear).  Obtain dma status and port status from
- *     device.  Clear the interrupt.  Return port status.
- *
- *     LOCKING:
- */
-
-static inline u8 ata_irq_ack(struct ata_port *ap, unsigned int chk_drq)
-{
-       unsigned int bits = chk_drq ? ATA_BUSY | ATA_DRQ : ATA_BUSY;
-       u8 host_stat, post_stat, status;
-
-       status = ata_busy_wait(ap, bits, 1000);
-       if (status & bits)
-               if (ata_msg_err(ap))
-                       printk(KERN_ERR "abnormal status 0x%X\n", status);
-
-       /* get controller status; clear intr, err bits */
-       if (ap->flags & ATA_FLAG_MMIO) {
-               void __iomem *mmio = (void __iomem *) ap->ioaddr.bmdma_addr;
-               host_stat = readb(mmio + ATA_DMA_STATUS);
-               writeb(host_stat | ATA_DMA_INTR | ATA_DMA_ERR,
-                      mmio + ATA_DMA_STATUS);
-
-               post_stat = readb(mmio + ATA_DMA_STATUS);
-       } else {
-               host_stat = inb(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS);
-               outb(host_stat | ATA_DMA_INTR | ATA_DMA_ERR,
-                    ap->ioaddr.bmdma_addr + ATA_DMA_STATUS);
-
-               post_stat = inb(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS);
-       }
-
-       if (ata_msg_intr(ap))
-               printk(KERN_INFO "%s: irq ack: host_stat 0x%X, new host_stat 0x%X, drv_stat 0x%X\n",
-                       __FUNCTION__,
-                       host_stat, post_stat, status);
-
-       return status;
-}
-
 static inline int ata_try_flush_cache(const struct ata_device *dev)
 {
        return ata_id_wcache_enabled(dev->id) ||
@@ -1235,14 +1178,14 @@ static inline unsigned int __ac_err_mask(u8 status)
 static inline int ata_pad_alloc(struct ata_port *ap, struct device *dev)
 {
        ap->pad_dma = 0;
-       ap->pad = dma_alloc_coherent(dev, ATA_DMA_PAD_BUF_SZ,
-                                    &ap->pad_dma, GFP_KERNEL);
+       ap->pad = dmam_alloc_coherent(dev, ATA_DMA_PAD_BUF_SZ,
+                                     &ap->pad_dma, GFP_KERNEL);
        return (ap->pad == NULL) ? -ENOMEM : 0;
 }
 
 static inline void ata_pad_free(struct ata_port *ap, struct device *dev)
 {
-       dma_free_coherent(dev, ATA_DMA_PAD_BUF_SZ, ap->pad, ap->pad_dma);
+       dmam_free_coherent(dev, ATA_DMA_PAD_BUF_SZ, ap->pad, ap->pad_dma);
 }
 
 static inline struct ata_port *ata_shost_to_port(struct Scsi_Host *host)
index 611059d633f4a9fcf2ec435309564b4b4bb0b126..f9d71eab05eecc9a7d3891d346b86aa58d24233b 100644 (file)
@@ -161,7 +161,7 @@ static inline void __list_del(struct list_head * prev, struct list_head * next)
 /**
  * list_del - deletes entry from list.
  * @entry: the element to delete from the list.
- * Note: list_empty on entry does not return true after this, the entry is
+ * Note: list_empty() on entry does not return true after this, the entry is
  * in an undefined state.
  */
 #ifndef CONFIG_DEBUG_LIST
@@ -179,7 +179,7 @@ extern void list_del(struct list_head *entry);
  * list_del_rcu - deletes entry from list without re-initialization
  * @entry: the element to delete from the list.
  *
- * Note: list_empty on entry does not return true after this,
+ * Note: list_empty() on entry does not return true after this,
  * the entry is in an undefined state. It is useful for RCU based
  * lockfree traversal.
  *
@@ -209,7 +209,8 @@ static inline void list_del_rcu(struct list_head *entry)
  * list_replace - replace old entry by new one
  * @old : the element to be replaced
  * @new : the new element to insert
- * Note: if 'old' was empty, it will be overwritten.
+ *
+ * If @old was empty, it will be overwritten.
  */
 static inline void list_replace(struct list_head *old,
                                struct list_head *new)
@@ -359,6 +360,62 @@ static inline void list_splice_init(struct list_head *list,
        }
 }
 
+/**
+ * list_splice_init_rcu - splice an RCU-protected list into an existing list.
+ * @list:      the RCU-protected list to splice
+ * @head:      the place in the list to splice the first list into
+ * @sync:      function to sync: synchronize_rcu(), synchronize_sched(), ...
+ *
+ * @head can be RCU-read traversed concurrently with this function.
+ *
+ * Note that this function blocks.
+ *
+ * Important note: the caller must take whatever action is necessary to
+ *     prevent any other updates to @head.  In principle, it is possible
+ *     to modify the list as soon as sync() begins execution.
+ *     If this sort of thing becomes necessary, an alternative version
+ *     based on call_rcu() could be created.  But only if -really-
+ *     needed -- there is no shortage of RCU API members.
+ */
+static inline void list_splice_init_rcu(struct list_head *list,
+                                       struct list_head *head,
+                                       void (*sync)(void))
+{
+       struct list_head *first = list->next;
+       struct list_head *last = list->prev;
+       struct list_head *at = head->next;
+
+       if (list_empty(head))
+               return;
+
+       /* "first" and "last" tracking list, so initialize it. */
+
+       INIT_LIST_HEAD(list);
+
+       /*
+        * At this point, the list body still points to the source list.
+        * Wait for any readers to finish using the list before splicing
+        * the list body into the new list.  Any new readers will see
+        * an empty list.
+        */
+
+       sync();
+
+       /*
+        * Readers are finished with the source list, so perform splice.
+        * The order is important if the new list is global and accessible
+        * to concurrent RCU readers.  Note that RCU readers are not
+        * permitted to traverse the prev pointers without excluding
+        * this function.
+        */
+
+       last->next = at;
+       smp_wmb();
+       head->next = first;
+       first->prev = head;
+       at->prev = last;
+}
+
 /**
  * list_entry - get the struct for this entry
  * @ptr:       the &struct list_head pointer.
@@ -432,12 +489,12 @@ static inline void list_splice_init(struct list_head *list,
             pos = list_entry(pos->member.prev, typeof(*pos), member))
 
 /**
- * list_prepare_entry - prepare a pos entry for use in list_for_each_entry_continue
+ * list_prepare_entry - prepare a pos entry for use in list_for_each_entry_continue()
  * @pos:       the type * to use as a start point
  * @head:      the head of the list
  * @member:    the name of the list_struct within the struct.
  *
- * Prepares a pos entry for use as a start point in list_for_each_entry_continue.
+ * Prepares a pos entry for use as a start point in list_for_each_entry_continue().
  */
 #define list_prepare_entry(pos, head, member) \
        ((pos) ? : list_entry(head, typeof(*pos), member))
index ea097dddc44f791d34a599aa12b3a251413aa47d..7e1160dde5e7cd052fcf67ac2852f7ecc1bb7062 100644 (file)
@@ -132,6 +132,7 @@ struct lock_list {
        struct list_head                entry;
        struct lock_class               *class;
        struct stack_trace              trace;
+       int                             distance;
 };
 
 /*
index 432b2fa249290343702eabfbc8c031d84a697e39..bdc01127dced03198620b72441d3b38a49eb3a16 100644 (file)
 #ifdef __KERNEL__
 #include <linux/spinlock.h>            /* spinlock_t */
 extern spinlock_t rtc_lock;            /* serialize CMOS RAM access */
+
+/* Some RTCs extend the mc146818 register set to support alarms of more
+ * than 24 hours in the future; or dates that include a century code.
+ * This platform_data structure can pass this information to the driver.
+ */
+struct cmos_rtc_board_info {
+       u8      rtc_day_alarm;          /* zero, or register index */
+       u8      rtc_mon_alarm;          /* zero, or register index */
+       u8      rtc_century;            /* zero, or register index */
+};
 #endif
 
 /**********************************************************************
index 2d2c08d5f47392fd605902e1da5662c0d3118cb0..77a76101dcd996c26d284b10274af21b091bbb16 100644 (file)
@@ -437,15 +437,15 @@ static inline compound_page_dtor *get_compound_page_dtor(struct page *page)
 /* NODE:ZONE or SECTION:ZONE is used to ID a zone for the buddy allcator */
 #ifdef NODE_NOT_IN_PAGEFLAGS
 #define ZONEID_SHIFT           (SECTIONS_SHIFT + ZONES_SHIFT)
+#define ZONEID_PGOFF           ((SECTIONS_PGOFF < ZONES_PGOFF)? \
+                                               SECTIONS_PGOFF : ZONES_PGOFF)
 #else
 #define ZONEID_SHIFT           (NODES_SHIFT + ZONES_SHIFT)
+#define ZONEID_PGOFF           ((NODES_PGOFF < ZONES_PGOFF)? \
+                                               NODES_PGOFF : ZONES_PGOFF)
 #endif
 
-#if ZONES_WIDTH > 0
-#define ZONEID_PGSHIFT         ZONES_PGSHIFT
-#else
-#define ZONEID_PGSHIFT         NODES_PGOFF
-#endif
+#define ZONEID_PGSHIFT         (ZONEID_PGOFF * (ZONEID_SHIFT != 0))
 
 #if SECTIONS_WIDTH+NODES_WIDTH+ZONES_WIDTH > FLAGS_RESERVED
 #error SECTIONS_WIDTH+NODES_WIDTH+ZONES_WIDTH > FLAGS_RESERVED
@@ -471,7 +471,6 @@ static inline enum zone_type page_zonenum(struct page *page)
  */
 static inline int page_zone_id(struct page *page)
 {
-       BUILD_BUG_ON(ZONEID_PGSHIFT == 0 && ZONEID_MASK);
        return (page->flags >> ZONEID_PGSHIFT) & ZONEID_MASK;
 }
 
@@ -786,6 +785,7 @@ extern int try_to_release_page(struct page * page, gfp_t gfp_mask);
 extern void do_invalidatepage(struct page *page, unsigned long offset);
 
 int __set_page_dirty_nobuffers(struct page *page);
+int __set_page_dirty_no_writeback(struct page *page);
 int redirty_page_for_writepage(struct writeback_control *wbc,
                                struct page *page);
 int FASTCALL(set_page_dirty(struct page *page));
@@ -1030,6 +1030,9 @@ extern struct vm_area_struct *copy_vma(struct vm_area_struct **,
        unsigned long addr, unsigned long len, pgoff_t pgoff);
 extern void exit_mmap(struct mm_struct *);
 extern int may_expand_vm(struct mm_struct *mm, unsigned long npages);
+extern int install_special_mapping(struct mm_struct *mm,
+                                  unsigned long addr, unsigned long len,
+                                  unsigned long flags, struct page **pages);
 
 extern unsigned long get_unmapped_area(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
 
index 3b6723dfaff38f50bb8fa75e9b99072d9c2d69ba..895bc4e93039cdba7f6585b484abed3b9eb4a920 100644 (file)
@@ -1,30 +1,29 @@
-
 static inline void
 add_page_to_active_list(struct zone *zone, struct page *page)
 {
        list_add(&page->lru, &zone->active_list);
-       zone->nr_active++;
+       __inc_zone_state(zone, NR_ACTIVE);
 }
 
 static inline void
 add_page_to_inactive_list(struct zone *zone, struct page *page)
 {
        list_add(&page->lru, &zone->inactive_list);
-       zone->nr_inactive++;
+       __inc_zone_state(zone, NR_INACTIVE);
 }
 
 static inline void
 del_page_from_active_list(struct zone *zone, struct page *page)
 {
        list_del(&page->lru);
-       zone->nr_active--;
+       __dec_zone_state(zone, NR_ACTIVE);
 }
 
 static inline void
 del_page_from_inactive_list(struct zone *zone, struct page *page)
 {
        list_del(&page->lru);
-       zone->nr_inactive--;
+       __dec_zone_state(zone, NR_INACTIVE);
 }
 
 static inline void
@@ -33,9 +32,9 @@ del_page_from_lru(struct zone *zone, struct page *page)
        list_del(&page->lru);
        if (PageActive(page)) {
                __ClearPageActive(page);
-               zone->nr_active--;
+               __dec_zone_state(zone, NR_ACTIVE);
        } else {
-               zone->nr_inactive--;
+               __dec_zone_state(zone, NR_INACTIVE);
        }
 }
 
index b262f47961fbe8a439cc218cd62b20122c5ac957..ee9e3143df4fd0ab8b723a6bf14a7fd28f71e9f6 100644 (file)
@@ -47,15 +47,20 @@ struct zone_padding {
 #endif
 
 enum zone_stat_item {
+       /* First 128 byte cacheline (assuming 64 bit words) */
+       NR_FREE_PAGES,
+       NR_INACTIVE,
+       NR_ACTIVE,
        NR_ANON_PAGES,  /* Mapped anonymous pages */
        NR_FILE_MAPPED, /* pagecache pages mapped into pagetables.
                           only modified from process context */
        NR_FILE_PAGES,
-       NR_SLAB_RECLAIMABLE,
-       NR_SLAB_UNRECLAIMABLE,
-       NR_PAGETABLE,   /* used for pagetables */
        NR_FILE_DIRTY,
        NR_WRITEBACK,
+       /* Second 128 byte cacheline */
+       NR_SLAB_RECLAIMABLE,
+       NR_SLAB_UNRECLAIMABLE,
+       NR_PAGETABLE,           /* used for pagetables */
        NR_UNSTABLE_NFS,        /* NFS unstable pages */
        NR_BOUNCE,
        NR_VMSCAN_WRITE,
@@ -91,6 +96,7 @@ struct per_cpu_pageset {
 #endif
 
 enum zone_type {
+#ifdef CONFIG_ZONE_DMA
        /*
         * ZONE_DMA is used when there are devices that are not able
         * to do DMA to all of addressable memory (ZONE_NORMAL). Then we
@@ -111,6 +117,7 @@ enum zone_type {
         *                      <16M.
         */
        ZONE_DMA,
+#endif
 #ifdef CONFIG_ZONE_DMA32
        /*
         * x86_64 needs two ZONE_DMAs because it supports devices that are
@@ -147,15 +154,30 @@ enum zone_type {
  * match the requested limits. See gfp_zone() in include/linux/gfp.h
  */
 
-#if !defined(CONFIG_ZONE_DMA32) && !defined(CONFIG_HIGHMEM)
+/*
+ * Count the active zones.  Note that the use of defined(X) outside
+ * #if and family is not necessarily defined so ensure we cannot use
+ * it later.  Use __ZONE_COUNT to work out how many shift bits we need.
+ */
+#define __ZONE_COUNT (                 \
+         defined(CONFIG_ZONE_DMA)      \
+       + defined(CONFIG_ZONE_DMA32)    \
+       + 1                             \
+       + defined(CONFIG_HIGHMEM)       \
+)
+#if __ZONE_COUNT < 2
+#define ZONES_SHIFT 0
+#elif __ZONE_COUNT <= 2
 #define ZONES_SHIFT 1
-#else
+#elif __ZONE_COUNT <= 4
 #define ZONES_SHIFT 2
+#else
+#error ZONES_SHIFT -- too many zones configured adjust calculation
 #endif
+#undef __ZONE_COUNT
 
 struct zone {
        /* Fields commonly accessed by the page allocator */
-       unsigned long           free_pages;
        unsigned long           pages_min, pages_low, pages_high;
        /*
         * We don't know if the memory that we're going to allocate will be freeable
@@ -197,8 +219,6 @@ struct zone {
        struct list_head        inactive_list;
        unsigned long           nr_scan_active;
        unsigned long           nr_scan_inactive;
-       unsigned long           nr_active;
-       unsigned long           nr_inactive;
        unsigned long           pages_scanned;     /* since last reclaim */
        int                     all_unreclaimable; /* All pages pinned */
 
@@ -442,8 +462,6 @@ typedef struct pglist_data {
 
 #include <linux/memory_hotplug.h>
 
-void __get_zone_counts(unsigned long *active, unsigned long *inactive,
-                       unsigned long *free, struct pglist_data *pgdat);
 void get_zone_counts(unsigned long *active, unsigned long *inactive,
                        unsigned long *free);
 void build_all_zonelists(void);
@@ -523,7 +541,11 @@ static inline int is_dma32(struct zone *zone)
 
 static inline int is_dma(struct zone *zone)
 {
+#ifdef CONFIG_ZONE_DMA
        return zone == zone->zone_pgdat->node_zones + ZONE_DMA;
+#else
+       return 0;
+#endif
 }
 
 /* These two functions are used to setup the per zone pages min values */
index 1b7e178b0d8472549de308667343b15d4f44aa56..dab69afee2fa457b3d6feaf8bda7d3701d71c4ca 100644 (file)
@@ -43,9 +43,8 @@ struct vfsmount {
        struct super_block *mnt_sb;     /* pointer to superblock */
        struct list_head mnt_mounts;    /* list of children, anchored here */
        struct list_head mnt_child;     /* and going through their mnt_child */
-       atomic_t mnt_count;
        int mnt_flags;
-       int mnt_expiry_mark;            /* true if marked for expiry */
+       /* 4 bytes hole on 64bits arches */
        char *mnt_devname;              /* Name of device e.g. /dev/dsk/hda1 */
        struct list_head mnt_list;
        struct list_head mnt_expire;    /* link in fs-specific expiry list */
@@ -54,6 +53,13 @@ struct vfsmount {
        struct list_head mnt_slave;     /* slave list entry */
        struct vfsmount *mnt_master;    /* slave is on master->mnt_slave_list */
        struct mnt_namespace *mnt_ns;   /* containing namespace */
+       /*
+        * We put mnt_count & mnt_expiry_mark at the end of struct vfsmount
+        * to let these frequently modified fields in a separate cache line
+        * (so that reads of mnt_flags wont ping-pong on SMP machines)
+        */
+       atomic_t mnt_count;
+       int mnt_expiry_mark;            /* true if marked for expiry */
        int mnt_pinned;
 };
 
index f28d8a2e2c917ee862de2abd1144784a1c82a18a..4db21e63d8d24b0b38087a3e198d6caf735bffde 100644 (file)
@@ -24,7 +24,7 @@
 struct poll_table_struct;
 struct inode;
 
-#define NPROTO         32              /* should be enough for now..   */
+#define NPROTO         33              /* should be enough for now..   */
 
 #define SYS_SOCKET     1               /* sys_socket(2)                */
 #define SYS_BIND       2               /* sys_bind(2)                  */
index 2e37f501278825a758a38bae3b15ee678f62102f..1a528548cd1d89e5b690b2ad92e8ec6fee24532c 100644 (file)
@@ -589,7 +589,7 @@ extern int          dev_open(struct net_device *dev);
 extern int             dev_close(struct net_device *dev);
 extern int             dev_queue_xmit(struct sk_buff *skb);
 extern int             register_netdevice(struct net_device *dev);
-extern int             unregister_netdevice(struct net_device *dev);
+extern void            unregister_netdevice(struct net_device *dev);
 extern void            free_netdev(struct net_device *dev);
 extern void            synchronize_net(void);
 extern int             register_netdevice_notifier(struct notifier_block *nb);
index 6328175a1c3a9f06594031f62045bb5208b299d9..43397a414cd6a8b963b086ed89262715d201a9fb 100644 (file)
@@ -33,6 +33,7 @@ header-y += xt_tcpmss.h
 header-y += xt_tcpudp.h
 header-y += xt_SECMARK.h
 header-y += xt_CONNSECMARK.h
+header-y += xt_TCPMSS.h
 
 unifdef-y += nf_conntrack_common.h
 unifdef-y += nf_conntrack_ftp.h
diff --git a/include/linux/netfilter/nf_conntrack_sane.h b/include/linux/netfilter/nf_conntrack_sane.h
new file mode 100644 (file)
index 0000000..4767d6e
--- /dev/null
@@ -0,0 +1,21 @@
+#ifndef _NF_CONNTRACK_SANE_H
+#define _NF_CONNTRACK_SANE_H
+/* SANE tracking. */
+
+#ifdef __KERNEL__
+
+#define SANE_PORT      6566
+
+enum sane_state {
+       SANE_STATE_NORMAL,
+       SANE_STATE_START_REQUESTED,
+};
+
+/* This structure exists only once per master */
+struct nf_ct_sane_master {
+       enum sane_state state;
+};
+
+#endif /* __KERNEL__ */
+
+#endif /* _NF_CONNTRACK_SANE_H */
index 2f4e98b90cc0d0849f9bf2489cc5ddd183a3fa58..007af4c2770b70dd004ebe51403ae90fc93e9097 100644 (file)
@@ -27,6 +27,9 @@ enum tcp_conntrack {
 /* This sender sent FIN first */
 #define IP_CT_TCP_FLAG_CLOSE_INIT              0x04
 
+/* Be liberal in window checking */
+#define IP_CT_TCP_FLAG_BE_LIBERAL              0x08
+
 #ifdef __KERNEL__
 
 struct ip_ct_tcp_state {
@@ -34,7 +37,6 @@ struct ip_ct_tcp_state {
        u_int32_t       td_maxend;      /* max of ack + max(win, 1) */
        u_int32_t       td_maxwin;      /* max(win) */
        u_int8_t        td_scale;       /* window scale factor */
-       u_int8_t        loose;          /* used when connection picked up from the middle */
        u_int8_t        flags;          /* per direction options */
 };
 
diff --git a/include/linux/netfilter/xt_TCPMSS.h b/include/linux/netfilter/xt_TCPMSS.h
new file mode 100644 (file)
index 0000000..53a292c
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef _XT_TCPMSS_H
+#define _XT_TCPMSS_H
+
+struct xt_tcpmss_info {
+       u_int16_t mss;
+};
+
+#define XT_TCPMSS_CLAMP_PMTU 0xffff
+
+#endif /* _XT_TCPMSS_H */
index bdf553620ca188ddbc53695d14d0389dd386d716..bbca89aab81304a499c3ab3077b572688e255706 100644 (file)
@@ -16,6 +16,7 @@ enum ip_nat_manip_type
 
 #define IP_NAT_RANGE_MAP_IPS 1
 #define IP_NAT_RANGE_PROTO_SPECIFIED 2
+#define IP_NAT_RANGE_PROTO_RANDOM 4 /* add randomness to "port" selection */
 
 /* NAT sequence number modifications */
 struct ip_nat_seq {
index 98d566c5e32ac362fb5be6a0554d3d318332b534..9527296595cd41f9cf1b437e7d204b687ee83ea1 100644 (file)
@@ -272,25 +272,9 @@ ipt_get_target(struct ipt_entry *e)
 #include <linux/init.h>
 extern void ipt_init(void) __init;
 
-#define ipt_register_target(tgt)       \
-({     (tgt)->family = AF_INET;        \
-       xt_register_target(tgt); })
-#define ipt_unregister_target(tgt) xt_unregister_target(tgt)
-
-#define ipt_register_match(mtch)       \
-({     (mtch)->family = AF_INET;       \
-       xt_register_match(mtch); })
-#define ipt_unregister_match(mtch) xt_unregister_match(mtch)
-
-//#define ipt_register_table(tbl, repl) xt_register_table(AF_INET, tbl, repl)
-//#define ipt_unregister_table(tbl) xt_unregister_table(AF_INET, tbl)
-
-extern int ipt_register_table(struct ipt_table *table,
+extern int ipt_register_table(struct xt_table *table,
                              const struct ipt_replace *repl);
-extern void ipt_unregister_table(struct ipt_table *table);
-
-/* net/sched/ipt.c: Gimme access to your targets!  Gets target->me. */
-extern struct ipt_target *ipt_find_target(const char *name, u8 revision);
+extern void ipt_unregister_table(struct xt_table *table);
 
 /* Standard entry. */
 struct ipt_standard
@@ -315,7 +299,7 @@ extern unsigned int ipt_do_table(struct sk_buff **pskb,
                                 unsigned int hook,
                                 const struct net_device *in,
                                 const struct net_device *out,
-                                struct ipt_table *table);
+                                struct xt_table *table);
 
 #define IPT_ALIGN(s) XT_ALIGN(s)
 
index aadb39580cd3e6d2745a6888e7b99d298f6189fb..7a850f9458249c86be93b8b431dec85ba70609d8 100644 (file)
@@ -1,10 +1,9 @@
 #ifndef _IPT_TCPMSS_H
 #define _IPT_TCPMSS_H
 
-struct ipt_tcpmss_info {
-       u_int16_t mss;
-};
+#include <linux/netfilter/xt_TCPMSS.h>
 
-#define IPT_TCPMSS_CLAMP_PMTU 0xffff
+#define ipt_tcpmss_info                xt_tcpmss_info
+#define IPT_TCPMSS_CLAMP_PMTU  XT_TCPMSS_CLAMP_PMTU
 
 #endif /*_IPT_TCPMSS_H*/
index 4aed340401dbca0368049dff8fdbddf4f5a399ad..61aa10412fc8b52c81229c1ee466678bd73b4840 100644 (file)
@@ -104,6 +104,25 @@ struct ip6t_entry
        unsigned char elems[0];
 };
 
+/* Standard entry */
+struct ip6t_standard
+{
+       struct ip6t_entry entry;
+       struct ip6t_standard_target target;
+};
+
+struct ip6t_error_target
+{
+       struct ip6t_entry_target target;
+       char errorname[IP6T_FUNCTION_MAXNAMELEN];
+};
+
+struct ip6t_error
+{
+       struct ip6t_entry entry;
+       struct ip6t_error_target target;
+};
+
 /*
  * New IP firewall options for [gs]etsockopt at the RAW IP level.
  * Unlike BSD Linux inherits IP options so you don't have to use
@@ -286,24 +305,14 @@ ip6t_get_target(struct ip6t_entry *e)
 #include <linux/init.h>
 extern void ip6t_init(void) __init;
 
-#define ip6t_register_target(tgt)              \
-({     (tgt)->family = AF_INET6;               \
-       xt_register_target(tgt); })
-#define ip6t_unregister_target(tgt) xt_unregister_target(tgt)
-
-#define ip6t_register_match(match)             \
-({     (match)->family = AF_INET6;             \
-       xt_register_match(match); })
-#define ip6t_unregister_match(match) xt_unregister_match(match)
-
-extern int ip6t_register_table(struct ip6t_table *table,
+extern int ip6t_register_table(struct xt_table *table,
                               const struct ip6t_replace *repl);
-extern void ip6t_unregister_table(struct ip6t_table *table);
+extern void ip6t_unregister_table(struct xt_table *table);
 extern unsigned int ip6t_do_table(struct sk_buff **pskb,
                                  unsigned int hook,
                                  const struct net_device *in,
                                  const struct net_device *out,
-                                 struct ip6t_table *table);
+                                 struct xt_table *table);
 
 /* Check for an extension */
 extern int ip6t_ext_hdr(u8 nexthdr);
diff --git a/include/linux/netfilter_ipv6/ip6t_mh.h b/include/linux/netfilter_ipv6/ip6t_mh.h
new file mode 100644 (file)
index 0000000..b9ca9a5
--- /dev/null
@@ -0,0 +1,15 @@
+#ifndef _IP6T_MH_H
+#define _IP6T_MH_H
+
+/* MH matching stuff */
+struct ip6t_mh
+{
+       u_int8_t types[2];      /* MH type range */
+       u_int8_t invflags;      /* Inverse flags */
+};
+
+/* Values for "invflags" field in struct ip6t_mh. */
+#define IP6T_MH_INV_TYPE       0x01    /* Invert the sense of type. */
+#define IP6T_MH_INV_MASK       0x01    /* All possible flags. */
+
+#endif /*_IP6T_MH_H*/
index c3e255bf859487aee64d3de7b5b34bf9d23e002a..7a8dcb82a6999a2c8e8114c17c83be1a2f71d19e 100644 (file)
@@ -76,8 +76,6 @@ extern struct page * find_get_page(struct address_space *mapping,
                                unsigned long index);
 extern struct page * find_lock_page(struct address_space *mapping,
                                unsigned long index);
-extern __deprecated_for_modules struct page * find_trylock_page(
-                       struct address_space *mapping, unsigned long index);
 extern struct page * find_or_create_page(struct address_space *mapping,
                                unsigned long index, gfp_t gfp_mask);
 unsigned find_get_pages(struct address_space *mapping, pgoff_t start,
index 805412cc68751daadc82d5f8ced4482b7b1f586f..98c8765a488e831cad0e35adef583fcf0c93cbe2 100644 (file)
@@ -167,6 +167,7 @@ struct pci_dev {
        unsigned int    broken_parity_status:1; /* Device generates false positive parity */
        unsigned int    msi_enabled:1;
        unsigned int    msix_enabled:1;
+       unsigned int    is_managed:1;
        atomic_t        enable_cnt;     /* pci_enable_device has been called */
 
        u32             saved_config_space[16]; /* config space saved at suspend time */
@@ -528,6 +529,14 @@ static inline int pci_write_config_dword(struct pci_dev *dev, int where, u32 val
 
 int __must_check pci_enable_device(struct pci_dev *dev);
 int __must_check pci_enable_device_bars(struct pci_dev *dev, int mask);
+int __must_check pcim_enable_device(struct pci_dev *pdev);
+void pcim_pin_device(struct pci_dev *pdev);
+
+static inline int pci_is_managed(struct pci_dev *pdev)
+{
+       return pdev->is_managed;
+}
+
 void pci_disable_device(struct pci_dev *dev);
 void pci_set_master(struct pci_dev *dev);
 #define HAVE_PCI_SET_MWI
@@ -831,6 +840,11 @@ enum pci_fixup_pass {
 
 void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev);
 
+void __iomem * pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen);
+void pcim_iounmap(struct pci_dev *pdev, void __iomem *addr);
+void __iomem * const * pcim_iomap_table(struct pci_dev *pdev);
+int pcim_iomap_regions(struct pci_dev *pdev, u16 mask, const char *name);
+
 extern int pci_pci_problems;
 #define PCIPCI_FAIL            1       /* No PCI PCI DMA */
 #define PCIPCI_TRITON          2
index defdeed20641913c2c7a2d5cdf3d40a02a2914e1..8fb9c3e06eefa62e778a3d09f2f54b94c58003e2 100644 (file)
@@ -15,6 +15,8 @@
 #define PCI_CLASS_STORAGE_FLOPPY       0x0102
 #define PCI_CLASS_STORAGE_IPI          0x0103
 #define PCI_CLASS_STORAGE_RAID         0x0104
+#define PCI_CLASS_STORAGE_SATA         0x0106
+#define PCI_CLASS_STORAGE_SATA_AHCI    0x010601
 #define PCI_CLASS_STORAGE_SAS          0x0107
 #define PCI_CLASS_STORAGE_OTHER                0x0180
 
@@ -95,6 +97,7 @@
 
 #define PCI_BASE_CLASS_SERIAL          0x0c
 #define PCI_CLASS_SERIAL_FIREWIRE      0x0c00
+#define PCI_CLASS_SERIAL_FIREWIRE_OHCI 0x0c0010
 #define PCI_CLASS_SERIAL_ACCESS                0x0c01
 #define PCI_CLASS_SERIAL_SSA           0x0c02
 #define PCI_CLASS_SERIAL_USB           0x0c03
 #define PCI_DEVICE_ID_PLX_R753         0x1152
 #define PCI_DEVICE_ID_PLX_OLITEC       0x1187
 #define PCI_DEVICE_ID_PLX_PCI200SYN    0x3196
+#define PCI_DEVICE_ID_PLX_9030          0x9030
 #define PCI_DEVICE_ID_PLX_9050         0x9050
 #define PCI_DEVICE_ID_PLX_9080         0x9080
 #define PCI_DEVICE_ID_PLX_GTEK_SERIAL2 0xa001
 #define PCI_VENDOR_ID_ITE              0x1283
 #define PCI_DEVICE_ID_ITE_8211         0x8211
 #define PCI_DEVICE_ID_ITE_8212         0x8212
+#define PCI_DEVICE_ID_ITE_8213         0x8213
 #define PCI_DEVICE_ID_ITE_8872         0x8872
 #define PCI_DEVICE_ID_ITE_IT8330G_0    0xe886
 
 #define PCI_VENDOR_ID_ELECTRONICDESIGNGMBH 0x12f8
 #define PCI_DEVICE_ID_LML_33R10                0x8a02
 
+#define PCI_VENDOR_ID_ESDGMBH          0x12fe
+#define PCI_DEVICE_ID_ESDGMBH_CPCIASIO4 0x0111
 
 #define PCI_VENDOR_ID_SIIG             0x131f
 #define PCI_SUBVENDOR_ID_SIIG          0x131f
 #define PCI_DEVICE_ID_MOXA_C168                0x1680
 #define PCI_DEVICE_ID_MOXA_CP168U      0x1681
 #define PCI_DEVICE_ID_MOXA_CP168EL     0x1682
+#define PCI_DEVICE_ID_MOXA_CP204J      0x2040
+#define PCI_DEVICE_ID_MOXA_C218                0x2180
+#define PCI_DEVICE_ID_MOXA_C320                0x3200
 
 #define PCI_VENDOR_ID_CCD              0x1397
 #define PCI_DEVICE_ID_CCD_2BD0         0x2bd0
 
 #define PCI_VENDOR_ID_CHELSIO          0x1425
 
+#define PCI_SUBVENDOR_ID_PERLE          0x155f
+#define PCI_SUBDEVICE_ID_PCI_RAS4       0xf001
+#define PCI_SUBDEVICE_ID_PCI_RAS8       0xf010
+
 
 #define PCI_VENDOR_ID_SYBA             0x1592
 #define PCI_DEVICE_ID_SYBA_2P_EPP      0x0782
 
 #define PCI_VENDOR_ID_PASEMI           0x1959
 
+#define PCI_VENDOR_ID_ATTANSIC         0x1969
+
 #define PCI_VENDOR_ID_JMICRON          0x197B
 #define PCI_DEVICE_ID_JMICRON_JMB360   0x2360
 #define PCI_DEVICE_ID_JMICRON_JMB361   0x2361
index 265bafab64941225f0cad5900e349e4849bdde42..d9db5f62ee4878d1cb71f6da1587a76cbce50ff5 100644 (file)
@@ -251,7 +251,8 @@ struct sadb_x_sec_ctx {
 #define SADB_X_SPDEXPIRE       21
 #define SADB_X_SPDDELETE2      22
 #define SADB_X_NAT_T_NEW_MAPPING       23
-#define SADB_MAX               23
+#define SADB_X_MIGRATE         24
+#define SADB_MAX               24
 
 /* Security Association flags */
 #define SADB_SAFLAGS_PFS       1
@@ -297,6 +298,7 @@ struct sadb_x_sec_ctx {
 #define SADB_X_EALG_BLOWFISHCBC                7
 #define SADB_EALG_NULL                 11
 #define SADB_X_EALG_AESCBC             12
+#define SADB_X_EALG_CAMELLIACBC                22
 #define SADB_EALG_MAX                   253 /* last EALG */
 /* private allocations should use 249-255 (RFC2407) */
 #define SADB_X_EALG_SERPENTCBC  252     /* draft-ietf-ipsec-ciph-aes-cbc-00 */
index ab8a8dd8d64c5f55c88bd28c05d7439875239b72..9a5226f0f169789c5040d68b5a888de8484829ff 100644 (file)
@@ -352,6 +352,8 @@ struct pnp_protocol {
        (dev) = protocol_to_pnp_dev((dev)->protocol_list.next))
 
 
+extern struct bus_type pnp_bus_type;
+
 #if defined(CONFIG_PNP)
 
 /* device management */
index ebd42a3710b4eefc44bec8a9880bd88af6472bcb..6db9a4c153556a7236caf4dbf376b27900af3f15 100644 (file)
@@ -247,6 +247,7 @@ struct bitmap {
 
        atomic_t pending_writes; /* pending writes to the bitmap file */
        wait_queue_head_t write_wait;
+       wait_queue_head_t overflow_wait;
 
 };
 
index 966c35851b2e784a445bac96e1458554ab8784de..66a96814d614c7dd23c4371d80a54a1a829b6a84 100644 (file)
@@ -2,7 +2,10 @@
   File: linux/reiserfs_xattr.h
 */
 
-#include <linux/xattr.h>
+#ifndef _LINUX_REISERFS_XATTR_H
+#define _LINUX_REISERFS_XATTR_H
+
+#include <linux/types.h>
 
 /* Magic value in header */
 #define REISERFS_XATTR_MAGIC 0x52465841        /* "RFXA" */
@@ -13,7 +16,18 @@ struct reiserfs_xattr_header {
 };
 
 #ifdef __KERNEL__
+
 #include <linux/init.h>
+#include <linux/list.h>
+#include <linux/rwsem.h>
+#include <linux/reiserfs_fs_i.h>
+#include <linux/reiserfs_fs.h>
+
+struct inode;
+struct dentry;
+struct iattr;
+struct super_block;
+struct nameidata;
 
 struct reiserfs_xattr_handler {
        char *prefix;
@@ -49,9 +63,7 @@ int reiserfs_xattr_set(struct inode *, const char *, const void *, size_t, int);
 
 extern struct reiserfs_xattr_handler user_handler;
 extern struct reiserfs_xattr_handler trusted_handler;
-#ifdef CONFIG_REISERFS_FS_SECURITY
 extern struct reiserfs_xattr_handler security_handler;
-#endif
 
 int reiserfs_xattr_register_handlers(void) __init;
 void reiserfs_xattr_unregister_handlers(void);
@@ -137,6 +149,8 @@ static inline int reiserfs_xattr_init(struct super_block *sb, int mount_flags)
 static inline void reiserfs_init_xattr_rwsem(struct inode *inode)
 {
 }
-#endif
+#endif  /*  CONFIG_REISERFS_FS_XATTR  */
+
+#endif  /*  __KERNEL__  */
 
-#endif                         /* __KERNEL__ */
+#endif  /*  _LINUX_REISERFS_XATTR_H  */
index c6a48bfc8b14700b5dee19e9b6630744c5187129..759a0f97bec23db4e26bddcfe124e095ced54b3a 100644 (file)
@@ -24,7 +24,7 @@
 /*
  * Tracks changes to rchan/rchan_buf structs
  */
-#define RELAYFS_CHANNEL_VERSION                6
+#define RELAYFS_CHANNEL_VERSION                7
 
 /*
  * Per-cpu relay channel buffer
@@ -64,6 +64,10 @@ struct rchan
        void *private_data;             /* for user-defined data */
        size_t last_toobig;             /* tried to log event > subbuf size */
        struct rchan_buf *buf[NR_CPUS]; /* per-cpu channel buffers */
+       int is_global;                  /* One global buffer ? */
+       struct list_head list;          /* for channel list */
+       struct dentry *parent;          /* parent dentry passed to open */
+       char base_filename[NAME_MAX];   /* saved base filename */
 };
 
 /*
@@ -162,7 +166,8 @@ struct rchan *relay_open(const char *base_filename,
                         struct dentry *parent,
                         size_t subbuf_size,
                         size_t n_subbufs,
-                        struct rchan_callbacks *cb);
+                        struct rchan_callbacks *cb,
+                        void *private_data);
 extern void relay_close(struct rchan *chan);
 extern void relay_flush(struct rchan *chan);
 extern void relay_subbufs_consumed(struct rchan *chan,
index d93857056cb99b1a45de079ab9e8101231d3f003..68e3f6853fa69a1950f106e6fd60ec37233865d9 100644 (file)
@@ -25,6 +25,7 @@
 
 #define RIO_ANY_DESTID         0xff
 #define RIO_NO_HOPCOUNT                -1
+#define RIO_INVALID_DESTID     0xffff
 
 #define RIO_MAX_MPORT_RESOURCES        16
 #define RIO_MAX_DEV_RESOURCES  16
index 4463735351904f039b1c3239f6161f52ce88ad77..76c8e2dc48dd3833969d2da24b9c7dbdd6bcc306 100644 (file)
@@ -1013,8 +1013,10 @@ struct task_struct {
  * to a stack based synchronous wait) if its doing sync IO.
  */
        wait_queue_t *io_wait;
+#ifdef CONFIG_TASK_XACCT
 /* i/o counters(bytes read/written, #syscalls */
        u64 rchar, wchar, syscr, syscw;
+#endif
        struct task_io_accounting ioac;
 #if defined(CONFIG_TASK_XACCT)
        u64 acct_rss_mem1;      /* accumulated rss usage */
@@ -1649,6 +1651,44 @@ extern int sched_create_sysfs_power_savings_entries(struct sysdev_class *cls);
 
 extern void normalize_rt_tasks(void);
 
+#ifdef CONFIG_TASK_XACCT
+static inline void add_rchar(struct task_struct *tsk, ssize_t amt)
+{
+       tsk->rchar += amt;
+}
+
+static inline void add_wchar(struct task_struct *tsk, ssize_t amt)
+{
+       tsk->wchar += amt;
+}
+
+static inline void inc_syscr(struct task_struct *tsk)
+{
+       tsk->syscr++;
+}
+
+static inline void inc_syscw(struct task_struct *tsk)
+{
+       tsk->syscw++;
+}
+#else
+static inline void add_rchar(struct task_struct *tsk, ssize_t amt)
+{
+}
+
+static inline void add_wchar(struct task_struct *tsk, ssize_t amt)
+{
+}
+
+static inline void inc_syscr(struct task_struct *tsk)
+{
+}
+
+static inline void inc_syscw(struct task_struct *tsk)
+{
+}
+#endif
+
 #endif /* __KERNEL__ */
 
 #endif
index 83cdefae993165cce7e8601dc127fcb520420161..c554f60f18e4e1b3399973360bed004c8affdcab 100644 (file)
@@ -492,7 +492,7 @@ struct request_sock;
  *     Note that the fown_struct, @fown, is never outside the context of a
  *     struct file, so the file structure (and associated security information)
  *     can always be obtained:
- *             (struct file *)((long)fown - offsetof(struct file,f_owner));
+ *             container_of(fown, struct file, f_owner)
  *     @tsk contains the structure of task receiving signal.
  *     @fown contains the file owner information.
  *     @sig is the signal that will be sent.  When 0, kernel sends SIGIO.
index 4b463e66ddeab265d0c1b48cc092e2e594dd46b6..5e4364644ed13eedadbb3e11256f44b63886b618 100644 (file)
@@ -19,7 +19,9 @@
 struct cache_sizes {
        size_t                  cs_size;
        struct kmem_cache       *cs_cachep;
+#ifdef CONFIG_ZONE_DMA
        struct kmem_cache       *cs_dmacachep;
+#endif
 };
 extern struct cache_sizes malloc_sizes[];
 
@@ -39,9 +41,12 @@ static inline void *kmalloc(size_t size, gfp_t flags)
                        __you_cannot_kmalloc_that_much();
                }
 found:
-               return kmem_cache_alloc((flags & GFP_DMA) ?
-                       malloc_sizes[i].cs_dmacachep :
-                       malloc_sizes[i].cs_cachep, flags);
+#ifdef CONFIG_ZONE_DMA
+               if (flags & GFP_DMA)
+                       return kmem_cache_alloc(malloc_sizes[i].cs_dmacachep,
+                                               flags);
+#endif
+               return kmem_cache_alloc(malloc_sizes[i].cs_cachep, flags);
        }
        return __kmalloc(size, flags);
 }
@@ -62,9 +67,12 @@ static inline void *kzalloc(size_t size, gfp_t flags)
                        __you_cannot_kzalloc_that_much();
                }
 found:
-               return kmem_cache_zalloc((flags & GFP_DMA) ?
-                       malloc_sizes[i].cs_dmacachep :
-                       malloc_sizes[i].cs_cachep, flags);
+#ifdef CONFIG_ZONE_DMA
+               if (flags & GFP_DMA)
+                       return kmem_cache_zalloc(malloc_sizes[i].cs_dmacachep,
+                                               flags);
+#endif
+               return kmem_cache_zalloc(malloc_sizes[i].cs_cachep, flags);
        }
        return __kzalloc(size, flags);
 }
@@ -88,9 +96,13 @@ static inline void *kmalloc_node(size_t size, gfp_t flags, int node)
                        __you_cannot_kmalloc_that_much();
                }
 found:
-               return kmem_cache_alloc_node((flags & GFP_DMA) ?
-                       malloc_sizes[i].cs_dmacachep :
-                       malloc_sizes[i].cs_cachep, flags, node);
+#ifdef CONFIG_ZONE_DMA
+               if (flags & GFP_DMA)
+                       return kmem_cache_alloc_node(malloc_sizes[i].cs_dmacachep,
+                                               flags, node);
+#endif
+               return kmem_cache_alloc_node(malloc_sizes[i].cs_cachep,
+                                               flags, node);
        }
        return __kmalloc_node(size, flags, node);
 }
index 92cd38efad7fbca2429bbcb9453634abc4684bdd..28157a36e6ccd69ce4ae091fe835162364813e7c 100644 (file)
@@ -16,7 +16,7 @@ struct __kernel_sockaddr_storage {
                                /* _SS_MAXSIZE value minus size of ss_family */
 } __attribute__ ((aligned(_K_SS_ALIGNSIZE)));  /* force desired alignment */
 
-#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2)
+#ifdef __KERNEL__
 
 #include <asm/socket.h>                        /* arch-dependent defines       */
 #include <linux/sockios.h>             /* the SIOCxxx I/O controls     */
@@ -187,7 +187,8 @@ struct ucred {
 #define AF_LLC         26      /* Linux LLC                    */
 #define AF_TIPC                30      /* TIPC sockets                 */
 #define AF_BLUETOOTH   31      /* Bluetooth sockets            */
-#define AF_MAX         32      /* For now.. */
+#define AF_IUCV                32      /* IUCV sockets                 */
+#define AF_MAX         33      /* For now.. */
 
 /* Protocol families, same as address families. */
 #define PF_UNSPEC      AF_UNSPEC
@@ -220,6 +221,7 @@ struct ucred {
 #define PF_LLC         AF_LLC
 #define PF_TIPC                AF_TIPC
 #define PF_BLUETOOTH   AF_BLUETOOTH
+#define PF_IUCV                AF_IUCV
 #define PF_MAX         AF_MAX
 
 /* Maximum queue length specifiable by listen.  */
index 94b767d6427561297772ad556d9466333f424732..61fef376ed2e6161299719f8b3a7cfaf4f246b33 100644 (file)
@@ -228,15 +228,30 @@ do {                                                              \
 # define read_unlock_irq(lock)         _read_unlock_irq(lock)
 # define write_unlock_irq(lock)                _write_unlock_irq(lock)
 #else
-# define spin_unlock(lock)             __raw_spin_unlock(&(lock)->raw_lock)
-# define read_unlock(lock)             __raw_read_unlock(&(lock)->raw_lock)
-# define write_unlock(lock)            __raw_write_unlock(&(lock)->raw_lock)
-# define spin_unlock_irq(lock) \
-    do { __raw_spin_unlock(&(lock)->raw_lock); local_irq_enable(); } while (0)
-# define read_unlock_irq(lock) \
-    do { __raw_read_unlock(&(lock)->raw_lock); local_irq_enable(); } while (0)
-# define write_unlock_irq(lock) \
-    do { __raw_write_unlock(&(lock)->raw_lock); local_irq_enable(); } while (0)
+# define spin_unlock(lock) \
+    do {__raw_spin_unlock(&(lock)->raw_lock); __release(lock); } while (0)
+# define read_unlock(lock) \
+    do {__raw_read_unlock(&(lock)->raw_lock); __release(lock); } while (0)
+# define write_unlock(lock) \
+    do {__raw_write_unlock(&(lock)->raw_lock); __release(lock); } while (0)
+# define spin_unlock_irq(lock)                 \
+do {                                           \
+       __raw_spin_unlock(&(lock)->raw_lock);   \
+       __release(lock);                        \
+       local_irq_enable();                     \
+} while (0)
+# define read_unlock_irq(lock)                 \
+do {                                           \
+       __raw_read_unlock(&(lock)->raw_lock);   \
+       __release(lock);                        \
+       local_irq_enable();                     \
+} while (0)
+# define write_unlock_irq(lock)                        \
+do {                                           \
+       __raw_write_unlock(&(lock)->raw_lock);  \
+       __release(lock);                        \
+       local_irq_enable();                     \
+} while (0)
 #endif
 
 #define spin_unlock_irqrestore(lock, flags) \
index 679ef0d70b6b1bae44fb4d9a60af100b1ec2d8fb..4f8539ccff6cf8addcf9d3561d58d5ba8b518c26 100644 (file)
@@ -7,7 +7,7 @@
 
 #endif
 
-#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2)
+#ifdef __KERNEL__
 
 #define S_IFMT  00170000
 #define S_IFSOCK 0140000
index 98b21ad370fdd529c7a35105642276876360ff82..db312a1e2eebc70bca97465b0e28c5f6a7056bf6 100644 (file)
@@ -63,7 +63,7 @@ struct svc_sock {
  * Function prototypes.
  */
 int            svc_makesock(struct svc_serv *, int, unsigned short);
-void           svc_delete_socket(struct svc_sock *);
+void           svc_close_socket(struct svc_sock *);
 int            svc_recv(struct svc_rqst *, long);
 int            svc_send(struct svc_rqst *);
 void           svc_drop(struct svc_rqst *);
index 5423559a44a6833b336e5b29b5863abdd5ccfe6a..006868881346b771eb471c91a4cde68047f3edc6 100644 (file)
@@ -170,11 +170,13 @@ extern void swapin_readahead(swp_entry_t, unsigned long, struct vm_area_struct *
 extern unsigned long totalram_pages;
 extern unsigned long totalreserve_pages;
 extern long nr_swap_pages;
-extern unsigned int nr_free_pages(void);
-extern unsigned int nr_free_pages_pgdat(pg_data_t *pgdat);
 extern unsigned int nr_free_buffer_pages(void);
 extern unsigned int nr_free_pagecache_pages(void);
 
+/* Definition of global_page_state not available yet */
+#define nr_free_pages() global_page_state(NR_FREE_PAGES)
+
+
 /* linux/mm/swap.c */
 extern void FASTCALL(lru_cache_add(struct page *));
 extern void FASTCALL(lru_cache_add_active(struct page *));
index 81480e6134674c19030f48336ca718ab40fbb100..665412c4f4b910cdc8c60da3174a1f48ccbbd61d 100644 (file)
@@ -699,7 +699,8 @@ enum {
        NET_X25_CALL_REQUEST_TIMEOUT=2,
        NET_X25_RESET_REQUEST_TIMEOUT=3,
        NET_X25_CLEAR_REQUEST_TIMEOUT=4,
-       NET_X25_ACK_HOLD_BACK_TIMEOUT=5
+       NET_X25_ACK_HOLD_BACK_TIMEOUT=5,
+       NET_X25_FORWARD=6
 };
 
 /* /proc/sys/net/token-ring */
diff --git a/include/linux/tc.h b/include/linux/tc.h
new file mode 100644 (file)
index 0000000..f92511e
--- /dev/null
@@ -0,0 +1,141 @@
+/*
+ *     Interface to the TURBOchannel related routines.
+ *
+ *     Copyright (c) 1998  Harald Koerfgen
+ *     Copyright (c) 2005  James Simmons
+ *     Copyright (c) 2006  Maciej W. Rozycki
+ *
+ *     Based on:
+ *
+ *     "TURBOchannel Firmware Specification", EK-TCAAD-FS-004
+ *
+ *     from Digital Equipment Corporation.
+ *
+ *     This file is subject to the terms and conditions of the GNU
+ *     General Public License.  See the file "COPYING" in the main
+ *     directory of this archive for more details.
+ */
+#ifndef _LINUX_TC_H
+#define _LINUX_TC_H
+
+#include <linux/compiler.h>
+#include <linux/device.h>
+#include <linux/ioport.h>
+#include <linux/types.h>
+
+/*
+ * Offsets for the ROM header locations for TURBOchannel cards.
+ */
+#define TC_OLDCARD     0x3c0000
+#define TC_NEWCARD     0x000000
+
+#define TC_ROM_WIDTH   0x3e0
+#define TC_ROM_STRIDE  0x3e4
+#define TC_ROM_SIZE    0x3e8
+#define TC_SLOT_SIZE   0x3ec
+#define TC_PATTERN0    0x3f0
+#define TC_PATTERN1    0x3f4
+#define TC_PATTERN2    0x3f8
+#define TC_PATTERN3    0x3fc
+#define TC_FIRM_VER    0x400
+#define TC_VENDOR      0x420
+#define TC_MODULE      0x440
+#define TC_FIRM_TYPE   0x460
+#define TC_FLAGS       0x470
+#define TC_ROM_OBJECTS 0x480
+
+/*
+ * Information obtained through the get_tcinfo() PROM call.
+ */
+struct tcinfo {
+       s32             revision;       /* Hardware revision level. */
+       s32             clk_period;     /* Clock period in nanoseconds. */
+       s32             slot_size;      /* Slot size in megabytes. */
+       s32             io_timeout;     /* I/O timeout in cycles. */
+       s32             dma_range;      /* DMA address range in megabytes. */
+       s32             max_dma_burst;  /* Maximum DMA burst length. */
+       s32             parity;         /* System module supports TC parity. */
+       s32             reserved[4];
+};
+
+/*
+ * TURBOchannel bus.
+ */
+struct tc_bus {
+       struct list_head devices;       /* List of devices on this bus. */
+       struct resource resource[2];    /* Address space routed to this bus. */
+
+       struct device   dev;
+       char            name[13];
+       resource_size_t slot_base;
+       resource_size_t ext_slot_base;
+       resource_size_t ext_slot_size;
+       int             num_tcslots;
+       struct tcinfo   info;
+};
+
+/*
+ * TURBOchannel device.
+ */
+struct tc_dev {
+       struct list_head node;          /* Node in list of all TC devices. */
+       struct tc_bus   *bus;           /* Bus this device is on. */
+       struct tc_driver *driver;       /* Which driver has allocated this
+                                          device. */
+       struct device   dev;            /* Generic device interface. */
+       struct resource resource;       /* Address space of this device. */
+       char            vendor[9];
+       char            name[9];
+       char            firmware[9];
+       int             interrupt;
+       int             slot;
+};
+
+#define to_tc_dev(n) container_of(n, struct tc_dev, dev)
+
+struct tc_device_id {
+       char            vendor[9];
+       char            name[9];
+};
+
+/*
+ * TURBOchannel driver.
+ */
+struct tc_driver {
+       struct list_head node;
+       const struct tc_device_id *id_table;
+       struct device_driver driver;
+};
+
+#define to_tc_driver(drv) container_of(drv, struct tc_driver, driver)
+
+/*
+ * Return TURBOchannel clock frequency in Hz.
+ */
+static inline unsigned long tc_get_speed(struct tc_bus *tbus)
+{
+       return 100000 * (10000 / (unsigned long)tbus->info.clk_period);
+}
+
+#ifdef CONFIG_TC
+
+extern struct bus_type tc_bus_type;
+
+extern int tc_register_driver(struct tc_driver *tdrv);
+extern void tc_unregister_driver(struct tc_driver *tdrv);
+
+#else /* !CONFIG_TC */
+
+static inline int tc_register_driver(struct tc_driver *tdrv) { return 0; }
+static inline void tc_unregister_driver(struct tc_driver *tdrv) { }
+
+#endif /* CONFIG_TC */
+
+/*
+ * These have to be provided by the architecture.
+ */
+extern int tc_preadb(u8 *valp, void __iomem *addr);
+extern int tc_bus_get_info(struct tc_bus *tbus);
+extern void tc_device_get_irq(struct tc_dev *tdev);
+
+#endif /* _LINUX_TC_H */
index 3cc70d1a3504c296ed76a08d740154156fe3676f..29d3089038ab6dab1393abc5c00509d1010f366d 100644 (file)
@@ -316,7 +316,7 @@ struct tcp_sock {
        struct tcp_sack_block duplicate_sack[1]; /* D-SACK block */
        struct tcp_sack_block selective_acks[4]; /* The SACKS themselves*/
 
-       struct tcp_sack_block recv_sack_cache[4];
+       struct tcp_sack_block_wire recv_sack_cache[4];
 
        /* from STCP, retrans queue hinting */
        struct sk_buff* lost_skb_hint;
index a5b739967b74f46f745526952b1c947c236cf75a..55cee172d723914eed0770f178f95ae6bd7b122b 100644 (file)
@@ -46,7 +46,7 @@ static inline int timespec_equal(struct timespec *a, struct timespec *b)
  * lhs == rhs: return 0
  * lhs > rhs:  return >0
  */
-static inline int timespec_compare(struct timespec *lhs, struct timespec *rhs)
+static inline int timespec_compare(const struct timespec *lhs, const struct timespec *rhs)
 {
        if (lhs->tv_sec < rhs->tv_sec)
                return -1;
@@ -55,7 +55,7 @@ static inline int timespec_compare(struct timespec *lhs, struct timespec *rhs)
        return lhs->tv_nsec - rhs->tv_nsec;
 }
 
-static inline int timeval_compare(struct timeval *lhs, struct timeval *rhs)
+static inline int timeval_compare(const struct timeval *lhs, const struct timeval *rhs)
 {
        if (lhs->tv_sec < rhs->tv_sec)
                return -1;
index db501dc23c299e52af3ac357cd7af05478465d23..9a24e500c3113291b9304e218b935fdc300ab87a 100644 (file)
@@ -255,10 +255,10 @@ struct time_interpolator {
        u8 jitter;                      /* if set compensate for fluctuations */
        u32 nsec_per_cyc;               /* set by register_time_interpolator() */
        void *addr;                     /* address of counter or function */
-       u64 mask;                       /* mask the valid bits of the counter */
+       cycles_t mask;                  /* mask the valid bits of the counter */
        unsigned long offset;           /* nsec offset at last update of interpolator */
        u64 last_counter;               /* counter value in units of the counter at last update */
-       u64 last_cycle;                 /* Last timer value if TIME_SOURCE_JITTER is set */
+       cycles_t last_cycle;            /* Last timer value if TIME_SOURCE_JITTER is set */
        u64 frequency;                  /* frequency in counts/second */
        long drift;                     /* drift in parts-per-million (or -1) */
        unsigned long skips;            /* skips forward */
index 65cbcf22c31e1e8ab7aef22b3b8da180825cf7cc..8427c9e98e6b9772c26f071e94116979711b5a5b 100644 (file)
 #define NR_PTYS        CONFIG_LEGACY_PTY_COUNT   /* Number of legacy ptys */
 #define NR_UNIX98_PTY_DEFAULT  4096      /* Default maximum for Unix98 ptys */
 #define NR_UNIX98_PTY_MAX      (1 << MINORBITS) /* Absolute limit */
-#define NR_LDISCS              16
+#define NR_LDISCS              17
+
+/* line disciplines */
+#define N_TTY          0
+#define N_SLIP         1
+#define N_MOUSE                2
+#define N_PPP          3
+#define N_STRIP                4
+#define N_AX25         5
+#define N_X25          6       /* X.25 async */
+#define N_6PACK                7
+#define N_MASC         8       /* Reserved for Mobitex module <kaz@cafe.net> */
+#define N_R3964                9       /* Reserved for Simatic R3964 module */
+#define N_PROFIBUS_FDL 10      /* Reserved for Profibus <Dave@mvhi.com> */
+#define N_IRDA         11      /* Linux IrDa - http://irda.sourceforge.net/ */
+#define N_SMSBLOCK     12      /* SMS block mode - for talking to GSM data */
+                               /* cards about SMS messages */
+#define N_HDLC         13      /* synchronous HDLC */
+#define N_SYNC_PPP     14      /* synchronous PPP */
+#define N_HCI          15      /* Bluetooth HCI UART */
+#define N_GIGASET_M101 16      /* Siemens Gigaset M101 serial DECT adapter */
 
 /*
  * This character is the same as _POSIX_VDISABLE: it cannot be used as
@@ -291,6 +311,7 @@ extern void tty_vhangup(struct tty_struct * tty);
 extern void tty_unhangup(struct file *filp);
 extern int tty_hung_up_p(struct file * filp);
 extern void do_SAK(struct tty_struct *tty);
+extern void __do_SAK(struct tty_struct *tty);
 extern void disassociate_ctty(int priv);
 extern void tty_flip_buffer_push(struct tty_struct *tty);
 extern speed_t tty_get_baud_rate(struct tty_struct *tty);
index 28967eda9d7b4375d8d82e730d3ac93207ad754b..d3a4f994a5dcdc15b6e8452a799b97f3da26f72c 100644 (file)
@@ -789,6 +789,7 @@ struct ufs_sb_private_info {
 
        __u32   s_maxsymlinklen;/* upper limit on fast symlinks' size */
        __s32   fs_magic;       /* filesystem magic */
+       unsigned int s_dirblksize;
 };
 
 /*
index 5e9803ed17fc4dd9c167c13541bbe209063ec7a6..acb1f105870c9f4f2535259d46bfa9371ab1a612 100644 (file)
@@ -3,20 +3,15 @@
 
 #include <linux/types.h>
 #include <linux/percpu.h>
+#include <linux/mm.h>
 #include <linux/mmzone.h>
 #include <asm/atomic.h>
 
-#ifdef CONFIG_VM_EVENT_COUNTERS
-/*
- * Light weight per cpu counter implementation.
- *
- * Counters should only be incremented.  You need to set EMBEDDED
- * to disable VM_EVENT_COUNTERS.  Things like procps (vmstat,
- * top, etc) use /proc/vmstat and depend on these counters.
- *
- * Counters are handled completely inline. On many platforms the code
- * generated will simply be the increment of a global address.
- */
+#ifdef CONFIG_ZONE_DMA
+#define DMA_ZONE(xx) xx##_DMA,
+#else
+#define DMA_ZONE(xx)
+#endif
 
 #ifdef CONFIG_ZONE_DMA32
 #define DMA32_ZONE(xx) xx##_DMA32,
@@ -30,7 +25,7 @@
 #define HIGHMEM_ZONE(xx)
 #endif
 
-#define FOR_ALL_ZONES(xx) xx##_DMA, DMA32_ZONE(xx) xx##_NORMAL HIGHMEM_ZONE(xx)
+#define FOR_ALL_ZONES(xx) DMA_ZONE(xx) DMA32_ZONE(xx) xx##_NORMAL HIGHMEM_ZONE(xx)
 
 enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
                FOR_ALL_ZONES(PGALLOC),
@@ -45,6 +40,17 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
                NR_VM_EVENT_ITEMS
 };
 
+#ifdef CONFIG_VM_EVENT_COUNTERS
+/*
+ * Light weight per cpu counter implementation.
+ *
+ * Counters should only be incremented and no critical kernel component
+ * should rely on the counter values.
+ *
+ * Counters are handled completely inline. On many platforms the code
+ * generated will simply be the increment of a global address.
+ */
+
 struct vm_event_state {
        unsigned long event[NR_VM_EVENT_ITEMS];
 };
@@ -85,17 +91,30 @@ static inline void vm_events_fold_cpu(int cpu)
 #else
 
 /* Disable counters */
-#define get_cpu_vm_events(e)   0L
-#define count_vm_event(e)      do { } while (0)
-#define count_vm_events(e,d)   do { } while (0)
-#define __count_vm_event(e)    do { } while (0)
-#define __count_vm_events(e,d) do { } while (0)
-#define vm_events_fold_cpu(x)  do { } while (0)
+static inline void count_vm_event(enum vm_event_item item)
+{
+}
+static inline void count_vm_events(enum vm_event_item item, long delta)
+{
+}
+static inline void __count_vm_event(enum vm_event_item item)
+{
+}
+static inline void __count_vm_events(enum vm_event_item item, long delta)
+{
+}
+static inline void all_vm_events(unsigned long *ret)
+{
+}
+static inline void vm_events_fold_cpu(int cpu)
+{
+}
 
 #endif /* CONFIG_VM_EVENT_COUNTERS */
 
 #define __count_zone_vm_events(item, zone, delta) \
-                       __count_vm_events(item##_DMA + zone_idx(zone), delta)
+               __count_vm_events(item##_NORMAL - ZONE_NORMAL + \
+               zone_idx(zone), delta)
 
 /*
  * Zone based page accounting with per cpu differentials.
@@ -142,14 +161,16 @@ static inline unsigned long node_page_state(int node,
        struct zone *zones = NODE_DATA(node)->node_zones;
 
        return
+#ifdef CONFIG_ZONE_DMA
+               zone_page_state(&zones[ZONE_DMA], item) +
+#endif
 #ifdef CONFIG_ZONE_DMA32
                zone_page_state(&zones[ZONE_DMA32], item) +
 #endif
-               zone_page_state(&zones[ZONE_NORMAL], item) +
 #ifdef CONFIG_HIGHMEM
                zone_page_state(&zones[ZONE_HIGHMEM], item) +
 #endif
-               zone_page_state(&zones[ZONE_DMA], item);
+               zone_page_state(&zones[ZONE_NORMAL], item);
 }
 
 extern void zone_statistics(struct zonelist *, struct zone *);
@@ -186,6 +207,9 @@ void inc_zone_page_state(struct page *, enum zone_stat_item);
 void dec_zone_page_state(struct page *, enum zone_stat_item);
 
 extern void inc_zone_state(struct zone *, enum zone_stat_item);
+extern void __inc_zone_state(struct zone *, enum zone_stat_item);
+extern void dec_zone_state(struct zone *, enum zone_stat_item);
+extern void __dec_zone_state(struct zone *, enum zone_stat_item);
 
 void refresh_cpu_vm_stats(int);
 void refresh_vm_stats(void);
@@ -214,6 +238,12 @@ static inline void __inc_zone_page_state(struct page *page,
        __inc_zone_state(page_zone(page), item);
 }
 
+static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
+{
+       atomic_long_dec(&zone->vm_stat[item]);
+       atomic_long_dec(&vm_stat[item]);
+}
+
 static inline void __dec_zone_page_state(struct page *page,
                        enum zone_stat_item item)
 {
index 2cd05013edfc19e78ae954eb1b1e5abe783674dc..3add87465b1fc671a8ebf2280fd1868d3c7315cc 100644 (file)
@@ -516,9 +516,6 @@ struct wan_device {
 /* Public functions available for device drivers */
 extern int register_wan_device(struct wan_device *wandev);
 extern int unregister_wan_device(char *name);
-__be16 wanrouter_type_trans(struct sk_buff *skb, struct net_device *dev);
-int wanrouter_encapsulate(struct sk_buff *skb, struct net_device *dev,
-                         unsigned short type);
 
 /* Proc interface functions. These must not be called by the drivers! */
 extern int wanrouter_proc_init(void);
@@ -527,11 +524,6 @@ extern int wanrouter_proc_add(struct wan_device *wandev);
 extern int wanrouter_proc_delete(struct wan_device *wandev);
 extern int wanrouter_ioctl( struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg);
 
-extern void lock_adapter_irq(spinlock_t *lock, unsigned long *smp_flags);
-extern void unlock_adapter_irq(spinlock_t *lock, unsigned long *smp_flags);
-
-
-
 /* Public Data */
 /* list of registered devices */
 extern struct wan_device *wanrouter_router_devlist;
index 0e7f1e20ea45345d24a3d383256ddb798ec4fced..def131a5ac70085f685b527c6de0f23fccae4d0e 100644 (file)
 #define XATTR_CREATE   0x1     /* set value, fail if attr already exists */
 #define XATTR_REPLACE  0x2     /* set value, fail if attr does not exist */
 
+#ifdef  __KERNEL__
+
+#include <linux/types.h>
+
 /* Namespaces */
 #define XATTR_OS2_PREFIX "os2."
 #define XATTR_OS2_PREFIX_LEN (sizeof (XATTR_OS2_PREFIX) - 1)
@@ -29,6 +33,8 @@
 #define XATTR_USER_PREFIX "user."
 #define XATTR_USER_PREFIX_LEN (sizeof (XATTR_USER_PREFIX) - 1)
 
+struct inode;
+struct dentry;
 
 struct xattr_handler {
        char *prefix;
@@ -50,4 +56,6 @@ ssize_t generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_siz
 int generic_setxattr(struct dentry *dentry, const char *name, const void *value, size_t size, int flags);
 int generic_removexattr(struct dentry *dentry, const char *name);
 
+#endif  /*  __KERNEL__  */
+
 #endif /* _LINUX_XATTR_H */
index 9529ea1ae39253563b02c04a493b3ccc5a3b55fe..15ca89e9961b04b589d6c67c5387b807f377fd31 100644 (file)
@@ -178,6 +178,9 @@ enum {
        XFRM_MSG_REPORT,
 #define XFRM_MSG_REPORT XFRM_MSG_REPORT
 
+       XFRM_MSG_MIGRATE,
+#define XFRM_MSG_MIGRATE XFRM_MSG_MIGRATE
+
        __XFRM_MSG_MAX
 };
 #define XFRM_MSG_MAX (__XFRM_MSG_MAX - 1)
@@ -256,6 +259,7 @@ enum xfrm_attr_type_t {
        XFRMA_COADDR,           /* xfrm_address_t */
        XFRMA_LASTUSED,
        XFRMA_POLICY_TYPE,      /* struct xfrm_userpolicy_type */
+       XFRMA_MIGRATE,
        __XFRMA_MAX
 
 #define XFRMA_MAX (__XFRMA_MAX - 1)
@@ -351,6 +355,19 @@ struct xfrm_user_report {
        struct xfrm_selector            sel;
 };
 
+struct xfrm_user_migrate {
+       xfrm_address_t                  old_daddr;
+       xfrm_address_t                  old_saddr;
+       xfrm_address_t                  new_daddr;
+       xfrm_address_t                  new_saddr;
+       __u8                            proto;
+       __u8                            mode;
+       __u16                           reserved;
+       __u32                           reqid;
+       __u16                           old_family;
+       __u16                           new_family;
+};
+
 #ifndef __KERNEL__
 /* backwards compatibility for userspace */
 #define XFRMGRP_ACQUIRE                1
@@ -375,6 +392,8 @@ enum xfrm_nlgroups {
 #define XFRMNLGRP_AEVENTS      XFRMNLGRP_AEVENTS
        XFRMNLGRP_REPORT,
 #define XFRMNLGRP_REPORT       XFRMNLGRP_REPORT
+       XFRMNLGRP_MIGRATE,
+#define XFRMNLGRP_MIGRATE      XFRMNLGRP_MIGRATE
        __XFRMNLGRP_MAX
 };
 #define XFRMNLGRP_MAX  (__XFRMNLGRP_MAX - 1)
index 76f957e258b0bc85bfa7b9de282f97c3a453b1a6..a566944c4962cafd94cadb3c851767582dc4a430 100644 (file)
@@ -68,9 +68,10 @@ extern void dn_rt_cache_flush(int delay);
 struct dn_route {
        union {
                struct dst_entry dst;
-               struct dn_route *rt_next;
        } u;
 
+       struct flowi fl;
+
        __le16 rt_saddr;
        __le16 rt_daddr;
        __le16 rt_gateway;
@@ -80,8 +81,6 @@ struct dn_route {
 
        unsigned rt_flags;
        unsigned rt_type;
-
-       struct flowi fl;
 };
 
 extern void dn_route_init(void);
index 62b7e7598e9adfbb246abb5a692515fbf0e99e0e..e12a8ce0b9b30737a39edbeaea90ba9edca76557 100644 (file)
@@ -37,9 +37,7 @@ struct sk_buff;
 
 struct dst_entry
 {
-       struct dst_entry        *next;
-       atomic_t                __refcnt;       /* client references    */
-       int                     __use;
+       struct rcu_head         rcu_head;
        struct dst_entry        *child;
        struct net_device       *dev;
        short                   error;
@@ -50,7 +48,6 @@ struct dst_entry
 #define DST_NOPOLICY           4
 #define DST_NOHASH             8
 #define DST_BALANCED            0x10
-       unsigned long           lastuse;
        unsigned long           expires;
 
        unsigned short          header_len;     /* more space at head required */
@@ -75,8 +72,16 @@ struct dst_entry
 #endif
 
        struct  dst_ops         *ops;
-       struct rcu_head         rcu_head;
                
+       unsigned long           lastuse;
+       atomic_t                __refcnt;       /* client references    */
+       int                     __use;
+       union {
+               struct dst_entry *next;
+               struct rtable    *rt_next;
+               struct rt6_info   *rt6_next;
+               struct dn_route  *dn_next;
+       };
        char                    info[0];
 };
 
index 34cc76e3ddb42139bdd7d9b48971bb5d174c7130..d27ee8c0da3f2cc5ac84f29a642118734eade381 100644 (file)
 #include <asm/byteorder.h>
 
 /* This is for all connections with a full identity, no wildcards.
- * New scheme, half the table is for TIME_WAIT, the other half is
- * for the rest.  I'll experiment with dynamic table growth later.
+ * One chain is dedicated to TIME_WAIT sockets.
+ * I'll experiment with dynamic table growth later.
  */
 struct inet_ehash_bucket {
        rwlock_t          lock;
        struct hlist_head chain;
+       struct hlist_head twchain;
 };
 
 /* There are a few simple rules, which allow for local port reuse by
@@ -97,8 +98,7 @@ struct inet_hashinfo {
         *
         *          TCP_ESTABLISHED <= sk->sk_state < TCP_CLOSE
         *
-        * First half of the table is for sockets not in TIME_WAIT, second half
-        * is for TIME_WAIT sockets only.
+        * TIME_WAIT sockets use a separate chain (twchain).
         */
        struct inet_ehash_bucket        *ehash;
 
@@ -369,7 +369,7 @@ static inline struct sock *
        }
 
        /* Must check for a TIME_WAIT'er before going to listener hash. */
-       sk_for_each(sk, node, &(head + hashinfo->ehash_size)->chain) {
+       sk_for_each(sk, node, &head->twchain) {
                if (INET_TW_MATCH(sk, hash, acookie, saddr, daddr, ports, dif))
                        goto hit;
        }
index 7be4f4e3a0f2241b27ebb72aa69d0582a93a9fff..9eda572a2a6534f157b233b71f22bf9ed70abd65 100644 (file)
@@ -83,7 +83,6 @@ struct rt6_info
 {
        union {
                struct dst_entry        dst;
-               struct rt6_info         *next;
        } u;
 
        struct inet6_dev                *rt6i_idev;
diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
new file mode 100644 (file)
index 0000000..04d1abb
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2006 IBM Corporation
+ * IUCV protocol stack for Linux on zSeries
+ * Version 1.0
+ * Author(s): Jennifer Hunt <jenhunt@us.ibm.com>
+ *
+ */
+
+#ifndef __AFIUCV_H
+#define __AFIUCV_H
+
+#include <asm/types.h>
+#include <asm/byteorder.h>
+#include <linux/list.h>
+#include <linux/poll.h>
+#include <linux/socket.h>
+
+#ifndef AF_IUCV
+#define AF_IUCV                32
+#define PF_IUCV                AF_IUCV
+#endif
+
+/* Connection and socket states */
+enum {
+       IUCV_CONNECTED = 1,
+       IUCV_OPEN,
+       IUCV_BOUND,
+       IUCV_LISTEN,
+       IUCV_SEVERED,
+       IUCV_DISCONN,
+       IUCV_CLOSED
+};
+
+#define IUCV_QUEUELEN_DEFAULT  65535
+#define IUCV_CONN_TIMEOUT      (HZ * 40)
+#define IUCV_DISCONN_TIMEOUT   (HZ * 2)
+#define IUCV_CONN_IDLE_TIMEOUT (HZ * 60)
+#define IUCV_BUFSIZE_DEFAULT   32768
+
+/* IUCV socket address */
+struct sockaddr_iucv {
+       sa_family_t     siucv_family;
+       unsigned short  siucv_port;             /* Reserved */
+       unsigned int    siucv_addr;             /* Reserved */
+       char            siucv_nodeid[8];        /* Reserved */
+       char            siucv_user_id[8];       /* Guest User Id */
+       char            siucv_name[8];          /* Application Name */
+};
+
+
+/* Common socket structures and functions */
+
+#define iucv_sk(__sk) ((struct iucv_sock *) __sk)
+
+struct iucv_sock {
+       struct sock             sk;
+       char                    src_user_id[8];
+       char                    src_name[8];
+       char                    dst_user_id[8];
+       char                    dst_name[8];
+       struct list_head        accept_q;
+       struct sock             *parent;
+       struct iucv_path        *path;
+       struct sk_buff_head     send_skb_q;
+       unsigned int            send_tag;
+};
+
+struct iucv_sock_list {
+       struct hlist_head head;
+       rwlock_t          lock;
+       atomic_t          autobind_name;
+};
+
+static void iucv_sock_destruct(struct sock *sk);
+static void iucv_sock_cleanup_listen(struct sock *parent);
+static void iucv_sock_kill(struct sock *sk);
+static void iucv_sock_close(struct sock *sk);
+static int  iucv_sock_create(struct socket *sock, int proto);
+static int  iucv_sock_bind(struct socket *sock, struct sockaddr *addr,
+                       int addr_len);
+static int  iucv_sock_connect(struct socket *sock, struct sockaddr *addr,
+                             int alen, int flags);
+static int  iucv_sock_listen(struct socket *sock, int backlog);
+static int  iucv_sock_accept(struct socket *sock, struct socket *newsock,
+                            int flags);
+static int  iucv_sock_getname(struct socket *sock, struct sockaddr *addr,
+                             int *len, int peer);
+static int  iucv_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
+                             struct msghdr *msg, size_t len);
+static int  iucv_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
+                             struct msghdr *msg, size_t len, int flags);
+unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
+                           poll_table *wait);
+static int iucv_sock_release(struct socket *sock);
+static int iucv_sock_shutdown(struct socket *sock, int how);
+
+void iucv_sock_link(struct iucv_sock_list *l, struct sock *s);
+void iucv_sock_unlink(struct iucv_sock_list *l, struct sock *s);
+int  iucv_sock_wait_state(struct sock *sk, int state, int state2,
+                         unsigned long timeo);
+int  iucv_sock_wait_cnt(struct sock *sk, unsigned long timeo);
+void iucv_accept_enqueue(struct sock *parent, struct sock *sk);
+void iucv_accept_unlink(struct sock *sk);
+struct sock *iucv_accept_dequeue(struct sock *parent, struct socket *newsock);
+
+#endif /* __IUCV_H */
diff --git a/include/net/iucv/iucv.h b/include/net/iucv/iucv.h
new file mode 100644 (file)
index 0000000..746e741
--- /dev/null
@@ -0,0 +1,415 @@
+/*
+ *  drivers/s390/net/iucv.h
+ *    IUCV base support.
+ *
+ *  S390 version
+ *    Copyright 2000, 2006 IBM Corporation
+ *    Author(s):Alan Altmark (Alan_Altmark@us.ibm.com)
+ *             Xenia Tkatschow (xenia@us.ibm.com)
+ *    Rewritten for af_iucv:
+ *     Martin Schwidefsky <schwidefsky@de.ibm.com>
+ *
+ *
+ * Functionality:
+ * To explore any of the IUCV functions, one must first register their
+ * program using iucv_register(). Once your program has successfully
+ * completed a register, it can exploit the other functions.
+ * For furthur reference on all IUCV functionality, refer to the
+ * CP Programming Services book, also available on the web thru
+ * www.ibm.com/s390/vm/pubs, manual # SC24-5760
+ *
+ * Definition of Return Codes
+ * - All positive return codes including zero are reflected back
+ *   from CP. The definition of each return code can be found in
+ *   CP Programming Services book.
+ * - Return Code of:
+ *   -EINVAL: Invalid value
+ *   -ENOMEM: storage allocation failed
+ */
+
+#include <linux/types.h>
+#include <asm/debug.h>
+
+/*
+ * IUCV option flags usable by device drivers:
+ *
+ * IUCV_IPRMDATA  Indicates that your program can handle a message in the
+ *               parameter list / a message is sent in the parameter list.
+ *               Used for iucv_path_accept, iucv_path_connect,
+ *               iucv_message_reply, iucv_message_send, iucv_message_send2way.
+ * IUCV_IPQUSCE          Indicates that you do not want to receive messages on this
+ *               path until an iucv_path_resume is issued.
+ *               Used for iucv_path_accept, iucv_path_connect.
+ * IUCV_IPBUFLST  Indicates that an address list is used for the message data.
+ *               Used for iucv_message_receive, iucv_message_send,
+ *               iucv_message_send2way.
+ * IUCV_IPPRTY   Specifies that you want to send priority messages.
+ *               Used for iucv_path_accept, iucv_path_connect,
+ *               iucv_message_reply, iucv_message_send, iucv_message_send2way.
+ * IUCV_IPSYNC   Indicates a synchronous send request.
+ *               Used for iucv_message_send, iucv_message_send2way.
+ * IUCV_IPANSLST  Indicates that an address list is used for the reply data.
+ *               Used for iucv_message_reply, iucv_message_send2way.
+ * IUCV_IPLOCAL          Specifies that the communication partner has to be on the
+ *               local system. If local is specified no target class can be
+ *               specified.
+ *               Used for iucv_path_connect.
+ *
+ * All flags are defined in the input field IPFLAGS1 of each function
+ * and can be found in CP Programming Services.
+ */
+#define IUCV_IPRMDATA  0x80
+#define IUCV_IPQUSCE   0x40
+#define IUCV_IPBUFLST  0x40
+#define IUCV_IPPRTY    0x20
+#define IUCV_IPANSLST  0x08
+#define IUCV_IPSYNC    0x04
+#define IUCV_IPLOCAL   0x01
+
+/*
+ * iucv_array : Defines buffer array.
+ * Inside the array may be 31- bit addresses and 31-bit lengths.
+ * Use a pointer to an iucv_array as the buffer, reply or answer
+ * parameter on iucv_message_send, iucv_message_send2way, iucv_message_receive
+ * and iucv_message_reply if IUCV_IPBUFLST or IUCV_IPANSLST are used.
+ */
+struct iucv_array {
+       u32 address;
+       u32 length;
+} __attribute__ ((aligned (8)));
+
+extern struct bus_type iucv_bus;
+extern struct device *iucv_root;
+
+/*
+ * struct iucv_path
+ * pathid: 16 bit path identification
+ * msglim: 16 bit message limit
+ * flags: properties of the path: IPRMDATA, IPQUSCE, IPPRTY
+ * handler:  address of iucv handler structure
+ * private: private information of the handler associated with the path
+ * list: list_head for the iucv_handler path list.
+ */
+struct iucv_path {
+       u16 pathid;
+       u16 msglim;
+       u8  flags;
+       void *private;
+       struct iucv_handler *handler;
+       struct list_head list;
+};
+
+/*
+ * struct iucv_message
+ * id: 32 bit message id
+ * audit: 32 bit error information of purged or replied messages
+ * class: 32 bit target class of a message (source class for replies)
+ * tag: 32 bit tag to be associated with the message
+ * length: 32 bit length of the message / reply
+ * reply_size: 32 bit maximum allowed length of the reply
+ * rmmsg: 8 byte inline message
+ * flags: message properties (IUCV_IPPRTY)
+ */
+struct iucv_message {
+       u32 id;
+       u32 audit;
+       u32 class;
+       u32 tag;
+       u32 length;
+       u32 reply_size;
+       u8  rmmsg[8];
+       u8  flags;
+};
+
+/*
+ * struct iucv_handler
+ *
+ * A vector of functions that handle IUCV interrupts. Each functions gets
+ * a parameter area as defined by the CP Programming Services and private
+ * pointer that is provided by the user of the interface.
+ */
+struct iucv_handler {
+        /*
+         * The path_pending function is called after an iucv interrupt
+         * type 0x01 has been received. The base code allocates a path
+         * structure and "asks" the handler if this path belongs to the
+         * handler. To accept the path the path_pending function needs
+         * to call iucv_path_accept and return 0. If the callback returns
+         * a value != 0 the iucv base code will continue with the next
+         * handler. The order in which the path_pending functions are
+         * called is the order of the registration of the iucv handlers
+         * to the base code.
+         */
+       int  (*path_pending)(struct iucv_path *, u8 ipvmid[8], u8 ipuser[16]);
+       /*
+        * The path_complete function is called after an iucv interrupt
+        * type 0x02 has been received for a path that has been established
+        * for this handler with iucv_path_connect and got accepted by the
+        * peer with iucv_path_accept.
+        */
+       void (*path_complete)(struct iucv_path *, u8 ipuser[16]);
+        /*
+         * The path_severed function is called after an iucv interrupt
+         * type 0x03 has been received. The communication peer shutdown
+         * his end of the communication path. The path still exists and
+         * remaining messages can be received until a iucv_path_sever
+         * shuts down the other end of the path as well.
+         */
+       void (*path_severed)(struct iucv_path *, u8 ipuser[16]);
+       /*
+        * The path_quiesced function is called after an icuv interrupt
+        * type 0x04 has been received. The communication peer has quiesced
+        * the path. Delivery of messages is stopped until iucv_path_resume
+        * has been called.
+        */
+       void (*path_quiesced)(struct iucv_path *, u8 ipuser[16]);
+       /*
+        * The path_resumed function is called after an icuv interrupt
+        * type 0x05 has been received. The communication peer has resumed
+        * the path.
+        */
+       void (*path_resumed)(struct iucv_path *, u8 ipuser[16]);
+       /*
+        * The message_pending function is called after an icuv interrupt
+        * type 0x06 or type 0x07 has been received. A new message is
+        * availabe and can be received with iucv_message_receive.
+        */
+       void (*message_pending)(struct iucv_path *, struct iucv_message *);
+       /*
+        * The message_complete function is called after an icuv interrupt
+        * type 0x08 or type 0x09 has been received. A message send with
+        * iucv_message_send2way has been replied to. The reply can be
+        * received with iucv_message_receive.
+        */
+       void (*message_complete)(struct iucv_path *, struct iucv_message *);
+
+       struct list_head list;
+       struct list_head paths;
+};
+
+/**
+ * iucv_register:
+ * @handler: address of iucv handler structure
+ * @smp: != 0 indicates that the handler can deal with out of order messages
+ *
+ * Registers a driver with IUCV.
+ *
+ * Returns 0 on success, -ENOMEM if the memory allocation for the pathid
+ * table failed, or -EIO if IUCV_DECLARE_BUFFER failed on all cpus.
+ */
+int iucv_register(struct iucv_handler *handler, int smp);
+
+/**
+ * iucv_unregister
+ * @handler:  address of iucv handler structure
+ * @smp: != 0 indicates that the handler can deal with out of order messages
+ *
+ * Unregister driver from IUCV.
+ */
+void iucv_unregister(struct iucv_handler *handle, int smp);
+
+/**
+ * iucv_path_alloc
+ * @msglim: initial message limit
+ * @flags: initial flags
+ * @gfp: kmalloc allocation flag
+ *
+ * Allocate a new path structure for use with iucv_connect.
+ *
+ * Returns NULL if the memory allocation failed or a pointer to the
+ * path structure.
+ */
+static inline struct iucv_path *iucv_path_alloc(u16 msglim, u8 flags, gfp_t gfp)
+{
+       struct iucv_path *path;
+
+       path = kzalloc(sizeof(struct iucv_path), gfp);
+       if (path) {
+               path->msglim = msglim;
+               path->flags = flags;
+       }
+       return path;
+}
+
+/**
+ * iucv_path_free
+ * @path: address of iucv path structure
+ *
+ * Frees a path structure.
+ */
+static inline void iucv_path_free(struct iucv_path *path)
+{
+       kfree(path);
+}
+
+/**
+ * iucv_path_accept
+ * @path: address of iucv path structure
+ * @handler: address of iucv handler structure
+ * @userdata: 16 bytes of data reflected to the communication partner
+ * @private: private data passed to interrupt handlers for this path
+ *
+ * This function is issued after the user received a connection pending
+ * external interrupt and now wishes to complete the IUCV communication path.
+ *
+ * Returns the result of the CP IUCV call.
+ */
+int iucv_path_accept(struct iucv_path *path, struct iucv_handler *handler,
+                    u8 userdata[16], void *private);
+
+/**
+ * iucv_path_connect
+ * @path: address of iucv path structure
+ * @handler: address of iucv handler structure
+ * @userid: 8-byte user identification
+ * @system: 8-byte target system identification
+ * @userdata: 16 bytes of data reflected to the communication partner
+ * @private: private data passed to interrupt handlers for this path
+ *
+ * This function establishes an IUCV path. Although the connect may complete
+ * successfully, you are not able to use the path until you receive an IUCV
+ * Connection Complete external interrupt.
+ *
+ * Returns the result of the CP IUCV call.
+ */
+int iucv_path_connect(struct iucv_path *path, struct iucv_handler *handler,
+                     u8 userid[8], u8 system[8], u8 userdata[16],
+                     void *private);
+
+/**
+ * iucv_path_quiesce:
+ * @path: address of iucv path structure
+ * @userdata: 16 bytes of data reflected to the communication partner
+ *
+ * This function temporarily suspends incoming messages on an IUCV path.
+ * You can later reactivate the path by invoking the iucv_resume function.
+ *
+ * Returns the result from the CP IUCV call.
+ */
+int iucv_path_quiesce(struct iucv_path *path, u8 userdata[16]);
+
+/**
+ * iucv_path_resume:
+ * @path: address of iucv path structure
+ * @userdata: 16 bytes of data reflected to the communication partner
+ *
+ * This function resumes incoming messages on an IUCV path that has
+ * been stopped with iucv_path_quiesce.
+ *
+ * Returns the result from the CP IUCV call.
+ */
+int iucv_path_resume(struct iucv_path *path, u8 userdata[16]);
+
+/**
+ * iucv_path_sever
+ * @path: address of iucv path structure
+ * @userdata: 16 bytes of data reflected to the communication partner
+ *
+ * This function terminates an IUCV path.
+ *
+ * Returns the result from the CP IUCV call.
+ */
+int iucv_path_sever(struct iucv_path *path, u8 userdata[16]);
+
+/**
+ * iucv_message_purge
+ * @path: address of iucv path structure
+ * @msg: address of iucv msg structure
+ * @srccls: source class of message
+ *
+ * Cancels a message you have sent.
+ *
+ * Returns the result from the CP IUCV call.
+ */
+int iucv_message_purge(struct iucv_path *path, struct iucv_message *msg,
+                      u32 srccls);
+
+/**
+ * iucv_message_receive
+ * @path: address of iucv path structure
+ * @msg: address of iucv msg structure
+ * @flags: flags that affect how the message is received (IUCV_IPBUFLST)
+ * @buffer: address of data buffer or address of struct iucv_array
+ * @size: length of data buffer
+ * @residual:
+ *
+ * This function receives messages that are being sent to you over
+ * established paths. This function will deal with RMDATA messages
+ * embedded in struct iucv_message as well.
+ *
+ * Returns the result from the CP IUCV call.
+ */
+int iucv_message_receive(struct iucv_path *path, struct iucv_message *msg,
+                        u8 flags, void *buffer, size_t size, size_t *residual);
+
+/**
+ * iucv_message_reject
+ * @path: address of iucv path structure
+ * @msg: address of iucv msg structure
+ *
+ * The reject function refuses a specified message. Between the time you
+ * are notified of a message and the time that you complete the message,
+ * the message may be rejected.
+ *
+ * Returns the result from the CP IUCV call.
+ */
+int iucv_message_reject(struct iucv_path *path, struct iucv_message *msg);
+
+/**
+ * iucv_message_reply
+ * @path: address of iucv path structure
+ * @msg: address of iucv msg structure
+ * @flags: how the reply is sent (IUCV_IPRMDATA, IUCV_IPPRTY, IUCV_IPBUFLST)
+ * @reply: address of data buffer or address of struct iucv_array
+ * @size: length of reply data buffer
+ *
+ * This function responds to the two-way messages that you receive. You
+ * must identify completely the message to which you wish to reply. ie,
+ * pathid, msgid, and trgcls. Prmmsg signifies the data is moved into
+ * the parameter list.
+ *
+ * Returns the result from the CP IUCV call.
+ */
+int iucv_message_reply(struct iucv_path *path, struct iucv_message *msg,
+                      u8 flags, void *reply, size_t size);
+
+/**
+ * iucv_message_send
+ * @path: address of iucv path structure
+ * @msg: address of iucv msg structure
+ * @flags: how the message is sent (IUCV_IPRMDATA, IUCV_IPPRTY, IUCV_IPBUFLST)
+ * @srccls: source class of message
+ * @buffer: address of data buffer or address of struct iucv_array
+ * @size: length of send buffer
+ *
+ * This function transmits data to another application. Data to be
+ * transmitted is in a buffer and this is a one-way message and the
+ * receiver will not reply to the message.
+ *
+ * Returns the result from the CP IUCV call.
+ */
+int iucv_message_send(struct iucv_path *path, struct iucv_message *msg,
+                     u8 flags, u32 srccls, void *buffer, size_t size);
+
+/**
+ * iucv_message_send2way
+ * @path: address of iucv path structure
+ * @msg: address of iucv msg structure
+ * @flags: how the message is sent and the reply is received
+ *        (IUCV_IPRMDATA, IUCV_IPBUFLST, IUCV_IPPRTY, IUCV_ANSLST)
+ * @srccls: source class of message
+ * @buffer: address of data buffer or address of struct iucv_array
+ * @size: length of send buffer
+ * @ansbuf: address of answer buffer or address of struct iucv_array
+ * @asize: size of reply buffer
+ *
+ * This function transmits data to another application. Data to be
+ * transmitted is in a buffer. The receiver of the send is expected to
+ * reply to the message and a buffer is provided into which IUCV moves
+ * the reply to this message.
+ *
+ * Returns the result from the CP IUCV call.
+ */
+int iucv_message_send2way(struct iucv_path *path, struct iucv_message *msg,
+                         u8 flags, u32 srccls, void *buffer, size_t size,
+                         void *answer, size_t asize, size_t *residual);
index bd01b4633ee20138dc6681b2e15dd2e7cabc471c..68ec27490c2075d7fb342bc264b0ae6db2444bc1 100644 (file)
@@ -45,6 +45,7 @@ union nf_conntrack_expect_proto {
 #include <linux/netfilter/nf_conntrack_ftp.h>
 #include <linux/netfilter/nf_conntrack_pptp.h>
 #include <linux/netfilter/nf_conntrack_h323.h>
+#include <linux/netfilter/nf_conntrack_sane.h>
 
 /* per conntrack: application helper private data */
 union nf_conntrack_help {
@@ -52,6 +53,7 @@ union nf_conntrack_help {
        struct nf_ct_ftp_master ct_ftp_info;
        struct nf_ct_pptp_master ct_pptp_info;
        struct nf_ct_h323_master ct_h323_info;
+       struct nf_ct_sane_master ct_sane_info;
 };
 
 #include <linux/types.h>
index 61c62068ca6bdf295d573842f09cd9b3d6a6c492..bc57dd7b9b5c1c2f54efa1f3bd30cb34d5b5a952 100644 (file)
@@ -16,6 +16,7 @@ enum nf_nat_manip_type
 
 #define IP_NAT_RANGE_MAP_IPS 1
 #define IP_NAT_RANGE_PROTO_SPECIFIED 2
+#define IP_NAT_RANGE_PROTO_RANDOM 4
 
 /* NAT sequence number modifications */
 struct nf_nat_seq {
index 486e37aff06ca28751e2a4a1cbf645b52cd3ebee..749e4dfe5ff3323dcaaa3eaa94c3130e3e058628 100644 (file)
@@ -53,9 +53,11 @@ struct rtable
        union
        {
                struct dst_entry        dst;
-               struct rtable           *rt_next;
        } u;
 
+       /* Cache lookup keys */
+       struct flowi            fl;
+
        struct in_device        *idev;
        
        unsigned                rt_flags;
@@ -69,9 +71,6 @@ struct rtable
        /* Info on neighbour */
        __be32                  rt_gateway;
 
-       /* Cache lookup keys */
-       struct flowi            fl;
-
        /* Miscellaneous cached information */
        __be32                  rt_spec_dst; /* RFC1122 specific destination */
        struct inet_peer        *peer; /* long-living peer info */
@@ -146,7 +145,8 @@ static inline char rt_tos2priority(u8 tos)
 
 static inline int ip_route_connect(struct rtable **rp, __be32 dst,
                                   __be32 src, u32 tos, int oif, u8 protocol,
-                                  __be16 sport, __be16 dport, struct sock *sk)
+                                  __be16 sport, __be16 dport, struct sock *sk,
+                                  int flags)
 {
        struct flowi fl = { .oif = oif,
                            .nl_u = { .ip4_u = { .daddr = dst,
@@ -168,7 +168,7 @@ static inline int ip_route_connect(struct rtable **rp, __be32 dst,
                *rp = NULL;
        }
        security_sk_classify_flow(sk, &fl);
-       return ip_route_output_flow(rp, &fl, sk, 0);
+       return ip_route_output_flow(rp, &fl, sk, flags);
 }
 
 static inline int ip_route_newports(struct rtable **rp, u8 protocol,
index cd8fa0c858aedfd0a7295a9c9b84130fc8f339e7..5c472f255b770179c51c95aa1d4d982760c0b72c 100644 (file)
@@ -802,9 +802,8 @@ static inline void tcp_update_wl(struct tcp_sock *tp, u32 ack, u32 seq)
 /*
  * Calculate(/check) TCP checksum
  */
-static inline __sum16 tcp_v4_check(struct tcphdr *th, int len,
-                              __be32 saddr, __be32 daddr,
-                              __wsum base)
+static inline __sum16 tcp_v4_check(int len, __be32 saddr,
+                                  __be32 daddr, __wsum base)
 {
        return csum_tcpudp_magic(saddr,daddr,len,IPPROTO_TCP,base);
 }
index e47fe440d9d70c6533a16ffb98290095d3f9f77a..fc3f03d976f8782fc6e4d4d45e18b0775ab1d0e7 100644 (file)
@@ -161,6 +161,14 @@ struct x25_sock {
        unsigned long           vc_facil_mask;  /* inc_call facilities mask */
 };
 
+struct x25_forward {
+       struct list_head        node;
+       unsigned int            lci;
+       struct net_device       *dev1;
+       struct net_device       *dev2;
+       atomic_t                refcnt;
+};
+
 static inline struct x25_sock *x25_sk(const struct sock *sk)
 {
        return (struct x25_sock *)sk;
@@ -172,6 +180,7 @@ extern int  sysctl_x25_call_request_timeout;
 extern int  sysctl_x25_reset_request_timeout;
 extern int  sysctl_x25_clear_request_timeout;
 extern int  sysctl_x25_ack_holdback_timeout;
+extern int  sysctl_x25_forward;
 
 extern int  x25_addr_ntoa(unsigned char *, struct x25_address *,
                          struct x25_address *);
@@ -198,6 +207,13 @@ extern int x25_negotiate_facilities(struct sk_buff *, struct sock *,
                                struct x25_dte_facilities *);
 extern void x25_limit_facilities(struct x25_facilities *, struct x25_neigh *);
 
+/* x25_forward.c */
+extern void x25_clear_forward_by_lci(unsigned int lci);
+extern void x25_clear_forward_by_dev(struct net_device *);
+extern int x25_forward_data(int, struct x25_neigh *, struct sk_buff *);
+extern int x25_forward_call(struct x25_address *, struct x25_neigh *,
+                               struct sk_buff *, int);
+
 /* x25_in.c */
 extern int  x25_process_rx_frame(struct sock *, struct sk_buff *);
 extern int  x25_backlog_rcv(struct sock *, struct sk_buff *);
@@ -282,6 +298,8 @@ extern struct hlist_head x25_list;
 extern rwlock_t x25_list_lock;
 extern struct list_head x25_route_list;
 extern rwlock_t x25_route_list_lock;
+extern struct list_head x25_forward_list;
+extern rwlock_t x25_forward_list_lock;
 
 extern int x25_proc_init(void);
 extern void x25_proc_exit(void);
index e4765413cf80c7ee9a5f4997796f6ee7ef93a206..16924cb772c97b1d858232c352d6860cda08e525 100644 (file)
@@ -252,10 +252,13 @@ struct xfrm_state_afinfo {
                                                xfrm_address_t *daddr, xfrm_address_t *saddr);
        int                     (*tmpl_sort)(struct xfrm_tmpl **dst, struct xfrm_tmpl **src, int n);
        int                     (*state_sort)(struct xfrm_state **dst, struct xfrm_state **src, int n);
+       int                     (*output)(struct sk_buff *skb);
 };
 
 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
+extern struct xfrm_state_afinfo *xfrm_state_get_afinfo(unsigned short family);
+extern void xfrm_state_put_afinfo(struct xfrm_state_afinfo *afinfo);
 
 extern void xfrm_state_delete_tunnel(struct xfrm_state *x);
 
@@ -359,6 +362,19 @@ struct xfrm_policy
        struct xfrm_tmpl        xfrm_vec[XFRM_MAX_DEPTH];
 };
 
+struct xfrm_migrate {
+       xfrm_address_t          old_daddr;
+       xfrm_address_t          old_saddr;
+       xfrm_address_t          new_daddr;
+       xfrm_address_t          new_saddr;
+       u8                      proto;
+       u8                      mode;
+       u16                     reserved;
+       u32                     reqid;
+       u16                     old_family;
+       u16                     new_family;
+};
+
 #define XFRM_KM_TIMEOUT                30
 /* which seqno */
 #define XFRM_REPLAY_SEQ                1
@@ -385,6 +401,7 @@ struct xfrm_mgr
        int                     (*new_mapping)(struct xfrm_state *x, xfrm_address_t *ipaddr, __be16 sport);
        int                     (*notify_policy)(struct xfrm_policy *x, int dir, struct km_event *c);
        int                     (*report)(u8 proto, struct xfrm_selector *sel, xfrm_address_t *addr);
+       int                     (*migrate)(struct xfrm_selector *sel, u8 dir, u8 type, struct xfrm_migrate *m, int num_bundles);
 };
 
 extern int xfrm_register_km(struct xfrm_mgr *km);
@@ -985,6 +1002,16 @@ extern int xfrm_bundle_ok(struct xfrm_policy *pol, struct xfrm_dst *xdst,
                          struct flowi *fl, int family, int strict);
 extern void xfrm_init_pmtu(struct dst_entry *dst);
 
+#ifdef CONFIG_XFRM_MIGRATE
+extern int km_migrate(struct xfrm_selector *sel, u8 dir, u8 type,
+                     struct xfrm_migrate *m, int num_bundles);
+extern struct xfrm_state * xfrm_migrate_state_find(struct xfrm_migrate *m);
+extern struct xfrm_state * xfrm_state_migrate(struct xfrm_state *x,
+                                             struct xfrm_migrate *m);
+extern int xfrm_migrate(struct xfrm_selector *sel, u8 dir, u8 type,
+                       struct xfrm_migrate *m, int num_bundles);
+#endif
+
 extern wait_queue_head_t km_waitq;
 extern int km_new_mapping(struct xfrm_state *x, xfrm_address_t *ipaddr, __be16 sport);
 extern void km_policy_expired(struct xfrm_policy *pol, int dir, int hard, u32 pid);
@@ -1050,5 +1077,25 @@ static inline void xfrm_aevent_doreplay(struct xfrm_state *x)
                xfrm_replay_notify(x, XFRM_REPLAY_UPDATE);
 }
 
+#ifdef CONFIG_XFRM_MIGRATE
+static inline struct xfrm_algo *xfrm_algo_clone(struct xfrm_algo *orig)
+{
+       return (struct xfrm_algo *)kmemdup(orig, sizeof(*orig) + orig->alg_key_len, GFP_KERNEL);
+}
+
+static inline void xfrm_states_put(struct xfrm_state **states, int n)
+{
+       int i;
+       for (i = 0; i < n; i++)
+               xfrm_state_put(*(states + i));
+}
+
+static inline void xfrm_states_delete(struct xfrm_state **states, int n)
+{
+       int i;
+       for (i = 0; i < n; i++)
+               xfrm_state_delete(*(states + i));
+}
+#endif
 
 #endif /* _NET_XFRM_H */
index 02f6e4b9e6932c407481d7c6ae5814b3ac4187f9..4a44278ed768c7f89f23643f15f1811be932f35e 100644 (file)
 }
 #define zero_data(p) {p[0]=0;p[1]=0;p[2]=0;}
 
+/* initiator tags; opaque for target */
+typedef uint32_t __bitwise__ itt_t;
+/* below makes sense only for initiator that created this tag */
+#define build_itt(itt, id, age) ((__force itt_t)\
+       ((itt) | ((id) << ISCSI_CID_SHIFT) | ((age) << ISCSI_AGE_SHIFT)))
+#define get_itt(itt) ((__force uint32_t)(itt_t)(itt) & ISCSI_ITT_MASK)
+#define RESERVED_ITT ((__force itt_t)0xffffffff)
+
 /*
  * iSCSI Template Message Header
  */
@@ -50,7 +58,7 @@ struct iscsi_hdr {
        uint8_t         hlength;        /* AHSs total length */
        uint8_t         dlength[3];     /* Data length */
        uint8_t         lun[8];
-       __be32          itt;            /* Initiator Task Tag */
+       itt_t           itt;            /* Initiator Task Tag, opaque for target */
        __be32          ttt;            /* Target Task Tag */
        __be32          statsn;
        __be32          exp_statsn;
@@ -111,7 +119,7 @@ struct iscsi_cmd {
        uint8_t hlength;
        uint8_t dlength[3];
        uint8_t lun[8];
-       __be32 itt;     /* Initiator Task Tag */
+       itt_t    itt;   /* Initiator Task Tag */
        __be32 data_length;
        __be32 cmdsn;
        __be32 exp_statsn;
@@ -148,7 +156,7 @@ struct iscsi_cmd_rsp {
        uint8_t hlength;
        uint8_t dlength[3];
        uint8_t rsvd[8];
-       __be32  itt;    /* Initiator Task Tag */
+       itt_t    itt;   /* Initiator Task Tag */
        __be32  rsvd1;
        __be32  statsn;
        __be32  exp_cmdsn;
@@ -206,7 +214,7 @@ struct iscsi_nopout {
        uint8_t rsvd3;
        uint8_t dlength[3];
        uint8_t lun[8];
-       __be32  itt;    /* Initiator Task Tag */
+       itt_t    itt;   /* Initiator Task Tag */
        __be32  ttt;    /* Target Transfer Tag */
        __be32  cmdsn;
        __be32  exp_statsn;
@@ -221,7 +229,7 @@ struct iscsi_nopin {
        uint8_t rsvd3;
        uint8_t dlength[3];
        uint8_t lun[8];
-       __be32  itt;    /* Initiator Task Tag */
+       itt_t    itt;   /* Initiator Task Tag */
        __be32  ttt;    /* Target Transfer Tag */
        __be32  statsn;
        __be32  exp_cmdsn;
@@ -237,8 +245,8 @@ struct iscsi_tm {
        uint8_t hlength;
        uint8_t dlength[3];
        uint8_t lun[8];
-       __be32  itt;    /* Initiator Task Tag */
-       __be32  rtt;    /* Reference Task Tag */
+       itt_t    itt;   /* Initiator Task Tag */
+       itt_t    rtt;   /* Reference Task Tag */
        __be32  cmdsn;
        __be32  exp_statsn;
        __be32  refcmdsn;
@@ -267,8 +275,8 @@ struct iscsi_tm_rsp {
        uint8_t hlength;
        uint8_t dlength[3];
        uint8_t rsvd2[8];
-       __be32  itt;    /* Initiator Task Tag */
-       __be32  rtt;    /* Reference Task Tag */
+       itt_t    itt;   /* Initiator Task Tag */
+       itt_t    rtt;   /* Reference Task Tag */
        __be32  statsn;
        __be32  exp_cmdsn;
        __be32  max_cmdsn;
@@ -293,7 +301,7 @@ struct iscsi_r2t_rsp {
        uint8_t hlength;
        uint8_t dlength[3];
        uint8_t lun[8];
-       __be32  itt;    /* Initiator Task Tag */
+       itt_t    itt;   /* Initiator Task Tag */
        __be32  ttt;    /* Target Transfer Tag */
        __be32  statsn;
        __be32  exp_cmdsn;
@@ -311,7 +319,7 @@ struct iscsi_data {
        uint8_t rsvd3;
        uint8_t dlength[3];
        uint8_t lun[8];
-       __be32  itt;
+       itt_t    itt;
        __be32  ttt;
        __be32  rsvd4;
        __be32  exp_statsn;
@@ -331,7 +339,7 @@ struct iscsi_data_rsp {
        uint8_t hlength;
        uint8_t dlength[3];
        uint8_t lun[8];
-       __be32  itt;
+       itt_t    itt;
        __be32  ttt;
        __be32  statsn;
        __be32  exp_cmdsn;
@@ -355,7 +363,7 @@ struct iscsi_text {
        uint8_t hlength;
        uint8_t dlength[3];
        uint8_t rsvd4[8];
-       __be32  itt;
+       itt_t    itt;
        __be32  ttt;
        __be32  cmdsn;
        __be32  exp_statsn;
@@ -373,7 +381,7 @@ struct iscsi_text_rsp {
        uint8_t hlength;
        uint8_t dlength[3];
        uint8_t rsvd4[8];
-       __be32  itt;
+       itt_t    itt;
        __be32  ttt;
        __be32  statsn;
        __be32  exp_cmdsn;
@@ -392,7 +400,7 @@ struct iscsi_login {
        uint8_t dlength[3];
        uint8_t isid[6];        /* Initiator Session ID */
        __be16  tsih;   /* Target Session Handle */
-       __be32  itt;    /* Initiator Task Tag */
+       itt_t    itt;   /* Initiator Task Tag */
        __be16  cid;
        __be16  rsvd3;
        __be32  cmdsn;
@@ -421,7 +429,7 @@ struct iscsi_login_rsp {
        uint8_t dlength[3];
        uint8_t isid[6];        /* Initiator Session ID */
        __be16  tsih;   /* Target Session Handle */
-       __be32  itt;    /* Initiator Task Tag */
+       itt_t    itt;   /* Initiator Task Tag */
        __be32  rsvd3;
        __be32  statsn;
        __be32  exp_cmdsn;
@@ -478,7 +486,7 @@ struct iscsi_logout {
        uint8_t hlength;
        uint8_t dlength[3];
        uint8_t rsvd2[8];
-       __be32  itt;    /* Initiator Task Tag */
+       itt_t    itt;   /* Initiator Task Tag */
        __be16  cid;
        uint8_t rsvd3[2];
        __be32  cmdsn;
@@ -505,7 +513,7 @@ struct iscsi_logout_rsp {
        uint8_t hlength;
        uint8_t dlength[3];
        uint8_t rsvd3[8];
-       __be32  itt;    /* Initiator Task Tag */
+       itt_t    itt;   /* Initiator Task Tag */
        __be32  rsvd4;
        __be32  statsn;
        __be32  exp_cmdsn;
@@ -528,7 +536,7 @@ struct iscsi_snack {
        uint8_t opcode;
        uint8_t flags;
        uint8_t rsvd2[14];
-       __be32  itt;
+       itt_t    itt;
        __be32  begrun;
        __be32  runlength;
        __be32  exp_statsn;
index 0c775fceb675b052bece78b80c885aaf64f0723e..0689e004a281e3b2fdcc7f8e1d5d6770b9b63180 100644 (file)
@@ -558,10 +558,9 @@ struct sas_task {
 static inline struct sas_task *sas_alloc_task(gfp_t flags)
 {
        extern struct kmem_cache *sas_task_cache;
-       struct sas_task *task = kmem_cache_alloc(sas_task_cache, flags);
+       struct sas_task *task = kmem_cache_zalloc(sas_task_cache, flags);
 
        if (task) {
-               memset(task, 0, sizeof(*task));
                INIT_LIST_HEAD(&task->list);
                spin_lock_init(&task->task_state_lock);
                task->task_state_flags = SAS_TASK_STATE_PENDING;
index 33720397a904861434f05cace1952ae474d428b5..246ac23534bdeae9693032f5ee09ac88ffbc91fe 100644 (file)
 #define AC97_SCAP_DETECT_BY_VENDOR (1<<8) /* use vendor registers for read tests */
 #define AC97_SCAP_NO_SPDIF     (1<<9)  /* don't build SPDIF controls */
 #define AC97_SCAP_EAPD_LED     (1<<10) /* EAPD as mute LED */
+#define AC97_SCAP_POWER_SAVE   (1<<11) /* capable for aggresive power-saving */
 
 /* ac97->flags */
 #define AC97_HAS_PC_BEEP       (1<<0)  /* force PC Speaker usage */
@@ -425,6 +426,7 @@ struct snd_ac97_build_ops {
 
 struct snd_ac97_bus_ops {
        void (*reset) (struct snd_ac97 *ac97);
+       void (*warm_reset)(struct snd_ac97 *ac97);
        void (*write) (struct snd_ac97 *ac97, unsigned short reg, unsigned short val);
        unsigned short (*read) (struct snd_ac97 *ac97, unsigned short reg);
        void (*wait) (struct snd_ac97 *ac97);
@@ -501,6 +503,7 @@ struct snd_ac97 {
                        unsigned short id[3];           // codec IDs (lower 16-bit word)
                        unsigned short pcmreg[3];       // PCM registers
                        unsigned short codec_cfg[3];    // CODEC_CFG bits
+                       unsigned char swap_mic_linein;  // AD1986/AD1986A only
                } ad18xx;
                unsigned int dev_flags;         /* device specific */
        } spec;
@@ -510,7 +513,6 @@ struct snd_ac97 {
 
 #ifdef CONFIG_SND_AC97_POWER_SAVE
        unsigned int power_up;  /* power states */
-       struct workqueue_struct *power_workq;
        struct delayed_work power_work;
 #endif
        struct device dev;
index c8de6f83338f675efec508eecf7a56e3385d7a36..b2c3f00a9b3537d808ac307daa4b61ad4f7b4a42 100644 (file)
@@ -185,7 +185,7 @@ struct ad1848_mix_elem {
        int index;
        int type;
        unsigned long private_value;
-       unsigned int *tlv;
+       const unsigned int *tlv;
 };
 
 #define AD1848_SINGLE(xname, xindex, reg, shift, mask, invert) \
index 2ee061625fd0e615cb331ecca276ee4a9ddc8b35..c149d3b2558b35bfa957ed7c42992471ca8da87a 100644 (file)
@@ -181,7 +181,6 @@ struct ak4114 {
        unsigned long ccrc_errors;
        unsigned char rcs0;
        unsigned char rcs1;
-       struct workqueue_struct *workqueue;
        struct delayed_work work;
        void *change_callback_private;
        void (*change_callback)(struct ak4114 *ak4114, unsigned char c0, unsigned char c1);
@@ -189,7 +188,7 @@ struct ak4114 {
 
 int snd_ak4114_create(struct snd_card *card,
                      ak4114_read_t *read, ak4114_write_t *write,
-                     unsigned char pgm[7], unsigned char txcsb[5],
+                     const unsigned char pgm[7], const unsigned char txcsb[5],
                      void *private_data, struct ak4114 **r_ak4114);
 void snd_ak4114_reg_write(struct ak4114 *ak4114, unsigned char reg, unsigned char mask, unsigned char val);
 void snd_ak4114_reinit(struct ak4114 *ak4114);
index 2b96c32f06fd06ef2313cebd804ce5dca0424918..d650d52e3d296429d9c8ee75e5f0f7d80336aa37 100644 (file)
@@ -178,7 +178,7 @@ struct ak4117 {
 };
 
 int snd_ak4117_create(struct snd_card *card, ak4117_read_t *read, ak4117_write_t *write,
-                     unsigned char pgm[5], void *private_data, struct ak4117 **r_ak4117);
+                     const unsigned char pgm[5], void *private_data, struct ak4117 **r_ak4117);
 void snd_ak4117_reg_write(struct ak4117 *ak4117, unsigned char reg, unsigned char mask, unsigned char val);
 void snd_ak4117_reinit(struct ak4117 *ak4117);
 int snd_ak4117_build(struct ak4117 *ak4117, struct snd_pcm_substream *capture_substream);
index d0deca669b92fe7cc96e856d6f9dbbcdbcf24ce9..aa49dda4f4104b4a58032516e72f690b94191627 100644 (file)
@@ -50,6 +50,8 @@ struct snd_akm4xxx_adc_channel {
        char *name;             /* capture gain volume label */
        char *switch_name;      /* capture switch */
        unsigned int num_channels;
+       char *selector_name;    /* capture source select label */
+       const char **input_names; /* capture source names (NULL terminated) */
 };
 
 struct snd_akm4xxx {
@@ -69,8 +71,8 @@ struct snd_akm4xxx {
        } type;
 
        /* (array) information of combined codecs */
-       struct snd_akm4xxx_dac_channel *dac_info;
-       struct snd_akm4xxx_adc_channel *adc_info;
+       const struct snd_akm4xxx_dac_channel *dac_info;
+       const struct snd_akm4xxx_adc_channel *adc_info;
 
        struct snd_ak4xxx_ops ops;
 };
index 1de148b0fd9472f5fd961c7c109d9f62053d69f9..72e759f619b10633526c787287f881b158929884 100644 (file)
@@ -49,7 +49,7 @@ struct snd_kcontrol_new {
        snd_kcontrol_put_t *put;
        union {
                snd_kcontrol_tlv_rw_t *c;
-               unsigned int *p;
+               const unsigned int *p;
        } tlv;
        unsigned long private_value;
 };
@@ -69,7 +69,7 @@ struct snd_kcontrol {
        snd_kcontrol_put_t *put;
        union {
                snd_kcontrol_tlv_rw_t *c;
-               unsigned int *p;
+               const unsigned int *p;
        } tlv;
        unsigned long private_value;
        void *private_data;
@@ -108,7 +108,6 @@ typedef int (*snd_kctl_ioctl_func_t) (struct snd_card * card,
 
 void snd_ctl_notify(struct snd_card * card, unsigned int mask, struct snd_ctl_elem_id * id);
 
-struct snd_kcontrol *snd_ctl_new(struct snd_kcontrol * kcontrol, unsigned int access);
 struct snd_kcontrol *snd_ctl_new1(const struct snd_kcontrol_new * kcontrolnew, void * private_data);
 void snd_ctl_free_one(struct snd_kcontrol * kcontrol);
 int snd_ctl_add(struct snd_card * card, struct snd_kcontrol * kcontrol);
index 521f036cce994e6fb5cbbc1dc4f5161d8047a7e5..4b9e609975ab976e5dceb554ef7401e30d5b3daf 100644 (file)
@@ -211,9 +211,40 @@ extern struct class *sound_class;
 
 void snd_request_card(int card);
 
-int snd_register_device(int type, struct snd_card *card, int dev,
-                       const struct file_operations *f_ops, void *private_data,
-                       const char *name);
+int snd_register_device_for_dev(int type, struct snd_card *card,
+                               int dev,
+                               const struct file_operations *f_ops,
+                               void *private_data,
+                               const char *name,
+                               struct device *device);
+
+/**
+ * snd_register_device - Register the ALSA device file for the card
+ * @type: the device type, SNDRV_DEVICE_TYPE_XXX
+ * @card: the card instance
+ * @dev: the device index
+ * @f_ops: the file operations
+ * @private_data: user pointer for f_ops->open()
+ * @name: the device file name
+ *
+ * Registers an ALSA device file for the given card.
+ * The operators have to be set in reg parameter.
+ *
+ * This function uses the card's device pointer to link to the
+ * correct &struct device.
+ *
+ * Returns zero if successful, or a negative error code on failure.
+ */
+static inline int snd_register_device(int type, struct snd_card *card, int dev,
+                                     const struct file_operations *f_ops,
+                                     void *private_data,
+                                     const char *name)
+{
+       return snd_register_device_for_dev(type, card, dev, f_ops,
+                                          private_data, name,
+                                          snd_card_get_device_link(card));
+}
+
 int snd_unregister_device(int type, struct snd_card *card, int dev);
 void *snd_lookup_minor_data(unsigned int minor, int type);
 int snd_add_device_sysfs_file(int type, struct snd_card *card, int dev,
@@ -396,6 +427,29 @@ void snd_verbose_printd(const char *file, int line, const char *format, ...)
 #endif
 #endif
 
-#include "typedefs.h"
+/* PCI quirk list helper */
+struct snd_pci_quirk {
+       unsigned short subvendor;       /* PCI subvendor ID */
+       unsigned short subdevice;       /* PCI subdevice ID */
+       int value;                      /* value */
+#ifdef CONFIG_SND_DEBUG_DETECT
+       const char *name;               /* name of the device (optional) */
+#endif
+};
+
+#define _SND_PCI_QUIRK_ID(vend,dev) \
+       .subvendor = (vend), .subdevice = (dev)
+#define SND_PCI_QUIRK_ID(vend,dev) {_SND_PCI_QUIRK_ID(vend, dev)}
+#ifdef CONFIG_SND_DEBUG_DETECT
+#define SND_PCI_QUIRK(vend,dev,xname,val) \
+       {_SND_PCI_QUIRK_ID(vend, dev), .value = (val), .name = (xname)}
+#else
+#define SND_PCI_QUIRK(vend,dev,xname,val) \
+       {_SND_PCI_QUIRK_ID(vend, dev), .value = (val)}
+#endif
+
+const struct snd_pci_quirk *
+snd_pci_quirk_lookup(struct pci_dev *pci, const struct snd_pci_quirk *list);
+
 
 #endif /* __SOUND_CORE_H */
index 3d3c1514cf71308de5bdc36d4e5a6cdb69208342..eb7ce96ddf3ad4c103718f7501196a78b6615003 100644 (file)
 #define HCFG_LEGACYINT         0x00200000      /* 1 = legacy event captured. Write 1 to clear. */
                                                /* NOTE: The rest of the bits in this register  */
                                                /* _are_ relevant under Linux.                  */
-#define HCFG_CODECFORMAT_MASK  0x00070000      /* CODEC format                                 */
+#define HCFG_PUSH_BUTTON_ENABLE 0x00100000     /* Enables Volume Inc/Dec and Mute functions    */
+#define HCFG_BAUD_RATE         0x00080000      /* 0 = 48kHz, 1 = 44.1kHz                       */
+#define HCFG_EXPANDED_MEM      0x00040000      /* 1 = any 16M of 4G addr, 0 = 32M of 2G addr   */
+#define HCFG_CODECFORMAT_MASK  0x00030000      /* CODEC format                                 */
+
+/* Specific to Alice2, CA0102 */
+#define HCFG_CODECFORMAT_AC97_1        0x00000000      /* AC97 CODEC format -- Ver 1.03                */
+#define HCFG_CODECFORMAT_AC97_2        0x00010000      /* AC97 CODEC format -- Ver 2.1                 */
+#define HCFG_AUTOMUTE_ASYNC    0x00008000      /* When set, the async sample rate convertors   */
+                                               /* will automatically mute their output when    */
+                                               /* they are not rate-locked to the external     */
+                                               /* async audio source                           */
+#define HCFG_AUTOMUTE_SPDIF    0x00004000      /* When set, the async sample rate convertors   */
+                                               /* will automatically mute their output when    */
+                                               /* the SPDIF V-bit indicates invalid audio      */
+#define HCFG_EMU32_SLAVE       0x00002000      /* 0 = Master, 1 = Slave. Slave for EMU1010     */
+#define HCFG_SLOW_RAMP         0x00001000      /* Increases Send Smoothing time constant       */
+/* 0x00000800 not used on Alice2 */
+#define HCFG_PHASE_TRACK_MASK  0x00000700      /* When set, forces corresponding input to      */
+                                               /* phase track the previous input.              */
+                                               /* I2S0 can phase track the last S/PDIF input   */
+#define HCFG_I2S_ASRC_ENABLE   0x00000070      /* When set, enables asynchronous sample rate   */
+                                               /* conversion for the corresponding             */
+                                               /* I2S format input                             */
+/* Rest of HCFG 0x0000000f same as below. LOCKSOUNDCACHE etc.  */
+
+
+
+/* Older chips */
 #define HCFG_CODECFORMAT_AC97  0x00000000      /* AC97 CODEC format -- Primary Output          */
 #define HCFG_CODECFORMAT_I2S   0x00010000      /* I2S CODEC format -- Secondary (Rear) Output  */
 #define HCFG_GPINPUT0          0x00004000      /* External pin112                              */
 #define FXRT_CHANNELC          0x0f000000      /* Effects send bus number for channel's effects send C */
 #define FXRT_CHANNELD          0xf0000000      /* Effects send bus number for channel's effects send D */
 
+#define A_HR                   0x0b    /* High Resolution. 24bit playback from host to DSP. */
 #define MAPA                   0x0c            /* Cache map A                                          */
 
 #define MAPB                   0x0d            /* Cache map B                                          */
 #define MAP_PTE_MASK           0xffffe000      /* The 19 MSBs of the PTE indexed by the PTI            */
 #define MAP_PTI_MASK           0x00001fff      /* The 13 bit index to one of the 8192 PTE dwords       */
 
+/* 0x0e, 0x0f: Not used */
+
 #define ENVVOL                 0x10            /* Volume envelope register                             */
 #define ENVVOL_MASK            0x0000ffff      /* Current value of volume envelope state variable      */  
                                                /* 0x8000-n == 666*n usec delay                         */
                                                /* NOTE: All channels contain internal variables; do    */
                                                /* not write to these locations.                        */
 
-/* 1f something */
+/* 0x1f: not used */
 
 #define CD0                    0x20            /* Cache data 0 register                                */
 #define CD1                    0x21            /* Cache data 1 register                                */
 #define FXWC_SPDIFLEFT          (1<<22)                /* 0x00400000 */
 #define FXWC_SPDIFRIGHT         (1<<23)                /* 0x00800000 */
 
+#define A_TBLSZ        `               0x43    /* Effects Tank Internal Table Size. Only low byte or register used */
+
 #define TCBS                   0x44            /* Tank cache buffer size register                      */
 #define TCBS_MASK              0x00000007      /* Tank cache buffer size field                         */
 #define TCBS_BUFFSIZE_16K      0x00000000
 #define FXBA                   0x47            /* FX Buffer Address */
 #define FXBA_MASK              0xfffff000      /* 20 bit base address                                  */
 
-/* 0x48 something - word access, defaults to 3f */
+#define A_HWM                  0x48    /* High PCI Water Mark - word access, defaults to 3f */
 
 #define MICBS                  0x49            /* Microphone buffer size register                      */
 
 #define ADCBS_BUFSIZE_57344    0x0000001e
 #define ADCBS_BUFSIZE_65536    0x0000001f
 
+/* Current Send B, A Amounts */
+#define A_CSBA                 0x4c
+
+/* Current Send D, C Amounts */
+#define A_CSDC                 0x4d
+
+/* Current Send F, E Amounts */
+#define A_CSFE                 0x4e
+
+/* Current Send H, G Amounts */
+#define A_CSHG                 0x4f
+
 
 #define CDCS                   0x50            /* CD-ROM digital channel status register       */
 
 
 #define DBG                    0x52            /* DO NOT PROGRAM THIS REGISTER!!! MAY DESTROY CHIP */
 
+/* S/PDIF Input C Channel Status */
+#define A_SPSC                 0x52
+
 #define REG53                  0x53            /* DO NOT PROGRAM THIS REGISTER!!! MAY DESTROY CHIP */
 
 #define A_DBG                   0x53
 #define SPCS_NOTAUDIODATA      0x00000002      /* 0 = Digital audio, 1 = not audio             */
 #define SPCS_PROFESSIONAL      0x00000001      /* 0 = Consumer (IEC-958), 1 = pro (AES3-1992)  */
 
+/* 0x57: Not used */
+
 /* The 32-bit CLIx and SOLx registers all have one bit per channel control/status                      */
 #define CLIEL                  0x58            /* Channel loop interrupt enable low register   */
 
 #define AC97SLOT_CNTR          0x10            /* Center enable */
 #define AC97SLOT_LFE           0x20            /* LFE enable */
 
+/* PCB Revision */
+#define A_PCB                  0x5f
+
 // NOTE: 0x60,61,62: 64-bit
 #define CDSRCS                 0x60            /* CD-ROM Sample Rate Converter status register */
 
 
 #define HLIPH                  0x69            /* Channel half loop interrupt pending high register    */
 
-// 0x6a,6b,6c used for some recording
-// 0x6d unused
-// 0x6e,6f - tanktable base / offset
+/* S/PDIF Host Record Index (bypasses SRC) */
+#define A_SPRI                 0x6a
+/* S/PDIF Host Record Address */
+#define A_SPRA                 0x6b
+/* S/PDIF Host Record Control */
+#define A_SPRC                 0x6c
+/* Delayed Interrupt Counter & Enable */
+#define A_DICE                 0x6d
+/* Tank Table Base */
+#define A_TTB                  0x6e
+/* Tank Delay Offset */
+#define A_TDOF                 0x6f
 
 /* This is the MPU port on the card (via the game port)                                                */
 #define A_MUDATA1              0x70
 #define A_FXWC1                        0x74            /* Selects 0x7f-0x60 for FX recording           */
 #define A_FXWC2                        0x75            /* Selects 0x9f-0x80 for FX recording           */
 
+/* Extended Hardware Control */
 #define A_SPDIF_SAMPLERATE     0x76            /* Set the sample rate of SPDIF output          */
 #define A_SAMPLE_RATE          0x76            /* Various sample rate settings. */
 #define A_SAMPLE_RATE_NOT_USED  0x0ffc111e     /* Bits that are not used and cannot be set.    */
 #define A_PCM_96000            0x00004000
 #define A_PCM_44100            0x00008000
 
-/* 0x77,0x78,0x79 "something i2s-related" - default to 0x01080000 on my audigy 2 ZS --rlrevell */
-/* 0x7a, 0x7b - lookup tables */
+/* I2S0 Sample Rate Tracker Status */
+#define A_SRT3                 0x77
+
+/* I2S1 Sample Rate Tracker Status */
+#define A_SRT4                 0x78
+
+/* I2S2 Sample Rate Tracker Status */
+#define A_SRT5                 0x79
+/* - default to 0x01080000 on my audigy 2 ZS --rlrevell        */
+
+/* Tank Table DMA Address */
+#define A_TTDA                 0x7a
+/* Tank Table DMA Data */
+#define A_TTDD                 0x7b
 
 #define A_FXRT2                        0x7c
 #define A_FXRT_CHANNELE                0x0000003f      /* Effects send bus number for channel's effects send E */
 #define A_FXRT_CHANNELC                0x003f0000
 #define A_FXRT_CHANNELD                0x3f000000
 
-
+/* 0x7f: Not used */
 /* Each FX general purpose register is 32 bits in length, all bits are used                    */
 #define FXGPREGBASE            0x100           /* FX general purpose registers base            */
 #define A_FXGPREGBASE          0x400           /* Audigy GPRs, 0x400 to 0x5ff                  */
 #define A_HIWORD_RESULT_MASK   0x007ff000
 #define A_HIWORD_OPA_MASK      0x000007ff
 
+/************************************************************************************************/
+/* EMU1010m HANA FPGA registers                                                                        */
+/************************************************************************************************/
+#define EMU_HANA_DESTHI                0x00    /* 0000xxx  3 bits Link Destination */
+#define EMU_HANA_DESTLO                0x01    /* 00xxxxx  5 bits */
+#define EMU_HANA_SRCHI         0x02    /* 0000xxx  3 bits Link Source */
+#define EMU_HANA_SRCLO         0x03    /* 00xxxxx  5 bits */
+#define EMU_HANA_DOCK_PWR      0x04    /* 000000x  1 bits Audio Dock power */
+#define EMU_HANA_DOCK_PWR_ON           0x01 /* Audio Dock power on */
+#define EMU_HANA_WCLOCK                0x05    /* 0000xxx  3 bits Word Clock source select  */
+                                       /* Must be written after power on to reset DLL */
+                                       /* One is unable to detect the Audio dock without this */
+#define EMU_HANA_WCLOCK_SRC_MASK       0x07
+#define EMU_HANA_WCLOCK_INT_48K                0x00
+#define EMU_HANA_WCLOCK_INT_44_1K      0x01
+#define EMU_HANA_WCLOCK_HANA_SPDIF_IN  0x02
+#define EMU_HANA_WCLOCK_HANA_ADAT_IN   0x03
+#define EMU_HANA_WCLOCK_SYNC_BNCN      0x04
+#define EMU_HANA_WCLOCK_2ND_HANA       0x05
+#define EMU_HANA_WCLOCK_SRC_RESERVED   0x06
+#define EMU_HANA_WCLOCK_OFF            0x07 /* For testing, forces fallback to DEFCLOCK */
+#define EMU_HANA_WCLOCK_MULT_MASK      0x18
+#define EMU_HANA_WCLOCK_1X             0x00
+#define EMU_HANA_WCLOCK_2X             0x08
+#define EMU_HANA_WCLOCK_4X             0x10
+#define EMU_HANA_WCLOCK_MULT_RESERVED  0x18
+
+#define EMU_HANA_DEFCLOCK      0x06    /* 000000x  1 bits Default Word Clock  */
+#define EMU_HANA_DEFCLOCK_48K          0x00
+#define EMU_HANA_DEFCLOCK_44_1K                0x01
+
+#define EMU_HANA_UNMUTE                0x07    /* 000000x  1 bits Mute all audio outputs  */
+#define EMU_MUTE                       0x00
+#define EMU_UNMUTE                     0x01
+
+#define EMU_HANA_FPGA_CONFIG   0x08    /* 00000xx  2 bits Config control of FPGAs  */
+#define EMU_HANA_FPGA_CONFIG_AUDIODOCK 0x01 /* Set in order to program FPGA on Audio Dock */
+#define EMU_HANA_FPGA_CONFIG_HANA      0x02 /* Set in order to program FPGA on Hana */
+
+#define EMU_HANA_IRQ_ENABLE    0x09    /* 000xxxx  4 bits IRQ Enable  */
+#define EMU_HANA_IRQ_WCLK_CHANGED      0x01
+#define EMU_HANA_IRQ_ADAT              0x02
+#define EMU_HANA_IRQ_DOCK              0x04
+#define EMU_HANA_IRQ_DOCK_LOST         0x08
+
+#define EMU_HANA_SPDIF_MODE    0x0a    /* 00xxxxx  5 bits SPDIF MODE  */
+#define EMU_HANA_SPDIF_MODE_TX_COMSUMER        0x00
+#define EMU_HANA_SPDIF_MODE_TX_PRO     0x01
+#define EMU_HANA_SPDIF_MODE_TX_NOCOPY  0x02
+#define EMU_HANA_SPDIF_MODE_RX_COMSUMER        0x00
+#define EMU_HANA_SPDIF_MODE_RX_PRO     0x04
+#define EMU_HANA_SPDIF_MODE_RX_NOCOPY  0x08
+#define EMU_HANA_SPDIF_MODE_RX_INVALID 0x10
+
+#define EMU_HANA_OPTICAL_TYPE  0x0b    /* 00000xx  2 bits ADAT or SPDIF in/out  */
+#define EMU_HANA_OPTICAL_IN_SPDIF      0x00
+#define EMU_HANA_OPTICAL_IN_ADAT       0x01
+#define EMU_HANA_OPTICAL_OUT_SPDIF     0x00
+#define EMU_HANA_OPTICAL_OUT_ADAT      0x02
+
+#define EMU_HANA_MIDI_IN               0x0c    /* 000000x  1 bit  Control MIDI  */
+#define EMU_HANA_MIDI_IN_FROM_HAMOA    0x00 /* HAMOA MIDI in to Alice 2 MIDI B */
+#define EMU_HANA_MIDI_IN_FROM_DOCK     0x01 /* Audio Dock MIDI in to Alice 2 MIDI B */
+
+#define EMU_HANA_DOCK_LEDS_1   0x0d    /* 000xxxx  4 bit  Audio Dock LEDs  */
+#define EMU_HANA_DOCK_LEDS_1_MIDI1     0x01    /* MIDI 1 LED on */
+#define EMU_HANA_DOCK_LEDS_1_MIDI2     0x02    /* MIDI 2 LED on */
+#define EMU_HANA_DOCK_LEDS_1_SMPTE_IN  0x04    /* SMPTE IN LED on */
+#define EMU_HANA_DOCK_LEDS_1_SMPTE_OUT 0x08    /* SMPTE OUT LED on */
+
+#define EMU_HANA_DOCK_LEDS_2   0x0e    /* 0xxxxxx  6 bit  Audio Dock LEDs  */
+#define EMU_HANA_DOCK_LEDS_2_44K       0x01    /* 44.1 kHz LED on */
+#define EMU_HANA_DOCK_LEDS_2_48K       0x02    /* 48 kHz LED on */
+#define EMU_HANA_DOCK_LEDS_2_96K       0x04    /* 96 kHz LED on */
+#define EMU_HANA_DOCK_LEDS_2_192K      0x08    /* 192 kHz LED on */
+#define EMU_HANA_DOCK_LEDS_2_LOCK      0x10    /* LOCK LED on */
+#define EMU_HANA_DOCK_LEDS_2_EXT       0x20    /* EXT LED on */
+
+#define EMU_HANA_DOCK_LEDS_3   0x0f    /* 0xxxxxx  6 bit  Audio Dock LEDs  */
+#define EMU_HANA_DOCK_LEDS_3_CLIP_A    0x01    /* Mic A Clip LED on */
+#define EMU_HANA_DOCK_LEDS_3_CLIP_B    0x02    /* Mic B Clip LED on */
+#define EMU_HANA_DOCK_LEDS_3_SIGNAL_A  0x04    /* Signal A Clip LED on */
+#define EMU_HANA_DOCK_LEDS_3_SIGNAL_B  0x08    /* Signal B Clip LED on */
+#define EMU_HANA_DOCK_LEDS_3_MANUAL_CLIP       0x10    /* Manual Clip detection */
+#define EMU_HANA_DOCK_LEDS_3_MANUAL_SIGNAL     0x20    /* Manual Signal detection */
+
+#define EMU_HANA_ADC_PADS      0x10    /* 0000xxx  3 bit  Audio Dock ADC 14dB pads */
+#define EMU_HANA_DOCK_ADC_PAD1 0x01    /* 14dB Attenuation on Audio Dock ADC 1 */
+#define EMU_HANA_DOCK_ADC_PAD2 0x02    /* 14dB Attenuation on Audio Dock ADC 2 */
+#define EMU_HANA_DOCK_ADC_PAD3 0x04    /* 14dB Attenuation on Audio Dock ADC 3 */
+#define EMU_HANA_0202_ADC_PAD1 0x08    /* 14dB Attenuation on 0202 ADC 1 */
+
+#define EMU_HANA_DOCK_MISC     0x11    /* 0xxxxxx  6 bit  Audio Dock misc bits */
+#define EMU_HANA_DOCK_DAC1_MUTE        0x01    /* DAC 1 Mute */
+#define EMU_HANA_DOCK_DAC2_MUTE        0x02    /* DAC 2 Mute */
+#define EMU_HANA_DOCK_DAC3_MUTE        0x04    /* DAC 3 Mute */
+#define EMU_HANA_DOCK_DAC4_MUTE        0x08    /* DAC 4 Mute */
+#define EMU_HANA_DOCK_PHONES_192_DAC1  0x00    /* DAC 1 Headphones source at 192kHz */
+#define EMU_HANA_DOCK_PHONES_192_DAC2  0x10    /* DAC 2 Headphones source at 192kHz */
+#define EMU_HANA_DOCK_PHONES_192_DAC3  0x20    /* DAC 3 Headphones source at 192kHz */
+#define EMU_HANA_DOCK_PHONES_192_DAC4  0x30    /* DAC 4 Headphones source at 192kHz */
+
+#define EMU_HANA_MIDI_OUT      0x12    /* 00xxxxx  5 bit  Source for each MIDI out port */
+#define EMU_HANA_MIDI_OUT_0202 0x01 /* 0202 MIDI from Alice 2. 0 = A, 1 = B */
+#define EMU_HANA_MIDI_OUT_DOCK1        0x02 /* Audio Dock MIDI1 front, from Alice 2. 0 = A, 1 = B */
+#define EMU_HANA_MIDI_OUT_DOCK2        0x04 /* Audio Dock MIDI2 rear, from Alice 2. 0 = A, 1 = B */
+#define EMU_HANA_MIDI_OUT_SYNC2        0x08 /* Sync card. Not the actual MIDI out jack. 0 = A, 1 = B */
+#define EMU_HANA_MIDI_OUT_LOOP 0x10 /* 0 = bits (3:0) normal. 1 = MIDI loopback enabled. */
+
+#define EMU_HANA_DAC_PADS      0x13    /* 00xxxxx  5 bit  DAC 14dB attenuation pads */
+#define EMU_HANA_DOCK_DAC_PAD1 0x01    /* 14dB Attenuation on AudioDock DAC 1. Left and Right */
+#define EMU_HANA_DOCK_DAC_PAD2 0x02    /* 14dB Attenuation on AudioDock DAC 2. Left and Right */
+#define EMU_HANA_DOCK_DAC_PAD3 0x04    /* 14dB Attenuation on AudioDock DAC 3. Left and Right */
+#define EMU_HANA_DOCK_DAC_PAD4 0x08    /* 14dB Attenuation on AudioDock DAC 4. Left and Right */
+#define EMU_HANA_0202_DAC_PAD1 0x10    /* 14dB Attenuation on 0202 DAC 1. Left and Right */
+
+/* 0x14 - 0x1f Unused R/W registers */
+#define EMU_HANA_IRQ_STATUS    0x20    /* 000xxxx  4 bits IRQ Status  */
+#if 0  /* Already defined for reg 0x09 IRQ_ENABLE */
+#define EMU_HANA_IRQ_WCLK_CHANGED      0x01
+#define EMU_HANA_IRQ_ADAT              0x02
+#define EMU_HANA_IRQ_DOCK              0x04
+#define EMU_HANA_IRQ_DOCK_LOST         0x08
+#endif
+
+#define EMU_HANA_OPTION_CARDS  0x21    /* 000xxxx  4 bits Presence of option cards */
+#define EMU_HANA_OPTION_HAMOA  0x01    /* HAMOA card present */
+#define EMU_HANA_OPTION_SYNC   0x02    /* Sync card present */
+#define EMU_HANA_OPTION_DOCK_ONLINE    0x04    /* Audio Dock online and FPGA configured */
+#define EMU_HANA_OPTION_DOCK_OFFLINE   0x08    /* Audio Dock online and FPGA not configured */
+
+#define EMU_HANA_ID            0x22    /* 1010101  7 bits ID byte & 0x7f = 0x55 */
+
+#define EMU_HANA_MAJOR_REV     0x23    /* 0000xxx  3 bit  Hana FPGA Major rev */
+#define EMU_HANA_MINOR_REV     0x24    /* 0000xxx  3 bit  Hana FPGA Minor rev */
+
+#define EMU_DOCK_MAJOR_REV     0x25    /* 0000xxx  3 bit  Audio Dock FPGA Major rev */
+#define EMU_DOCK_MINOR_REV     0x26    /* 0000xxx  3 bit  Audio Dock FPGA Minor rev */
+
+#define EMU_DOCK_BOARD_ID      0x27    /* 00000xx  2 bits Audio Dock ID pins */
+#define EMU_DOCK_BOARD_ID0     0x00    /* ID bit 0 */
+#define EMU_DOCK_BOARD_ID1     0x03    /* ID bit 1 */
+
+#define EMU_HANA_WC_SPDIF_HI   0x28    /* 0xxxxxx  6 bit  SPDIF IN Word clock, upper 6 bits */
+#define EMU_HANA_WC_SPDIF_LO   0x29    /* 0xxxxxx  6 bit  SPDIF IN Word clock, lower 6 bits */
+
+#define EMU_HANA_WC_ADAT_HI    0x2a    /* 0xxxxxx  6 bit  ADAT IN Word clock, upper 6 bits */
+#define EMU_HANA_WC_ADAT_LO    0x2b    /* 0xxxxxx  6 bit  ADAT IN Word clock, lower 6 bits */
+
+#define EMU_HANA_WC_BNC_LO     0x2c    /* 0xxxxxx  6 bit  BNC IN Word clock, lower 6 bits */
+#define EMU_HANA_WC_BNC_HI     0x2d    /* 0xxxxxx  6 bit  BNC IN Word clock, upper 6 bits */
+
+#define EMU_HANA2_WC_SPDIF_HI  0x2e    /* 0xxxxxx  6 bit  HANA2 SPDIF IN Word clock, upper 6 bits */
+#define EMU_HANA2_WC_SPDIF_LO  0x2f    /* 0xxxxxx  6 bit  HANA2 SPDIF IN Word clock, lower 6 bits */
+/* 0x30 - 0x3f Unused Read only registers */
+
+/************************************************************************************************/
+/* EMU1010m HANA Destinations                                                                  */
+/************************************************************************************************/
+#define EMU_DST_ALICE2_EMU32_0 0x000f  /* 16 EMU32 channels to Alice2 +0 to +0xf */
+#define EMU_DST_ALICE2_EMU32_1 0x0000  /* 16 EMU32 channels to Alice2 +0 to +0xf */
+#define EMU_DST_ALICE2_EMU32_2 0x0001  /* 16 EMU32 channels to Alice2 +0 to +0xf */
+#define EMU_DST_ALICE2_EMU32_3 0x0002  /* 16 EMU32 channels to Alice2 +0 to +0xf */
+#define EMU_DST_ALICE2_EMU32_4 0x0003  /* 16 EMU32 channels to Alice2 +0 to +0xf */
+#define EMU_DST_ALICE2_EMU32_5 0x0004  /* 16 EMU32 channels to Alice2 +0 to +0xf */
+#define EMU_DST_ALICE2_EMU32_6 0x0005  /* 16 EMU32 channels to Alice2 +0 to +0xf */
+#define EMU_DST_ALICE2_EMU32_7 0x0006  /* 16 EMU32 channels to Alice2 +0 to +0xf */
+#define EMU_DST_ALICE2_EMU32_8 0x0007  /* 16 EMU32 channels to Alice2 +0 to +0xf */
+#define EMU_DST_ALICE2_EMU32_9 0x0008  /* 16 EMU32 channels to Alice2 +0 to +0xf */
+#define EMU_DST_ALICE2_EMU32_A 0x0009  /* 16 EMU32 channels to Alice2 +0 to +0xf */
+#define EMU_DST_ALICE2_EMU32_B 0x000a  /* 16 EMU32 channels to Alice2 +0 to +0xf */
+#define EMU_DST_ALICE2_EMU32_C 0x000b  /* 16 EMU32 channels to Alice2 +0 to +0xf */
+#define EMU_DST_ALICE2_EMU32_D 0x000c  /* 16 EMU32 channels to Alice2 +0 to +0xf */
+#define EMU_DST_ALICE2_EMU32_E 0x000d  /* 16 EMU32 channels to Alice2 +0 to +0xf */
+#define EMU_DST_ALICE2_EMU32_F 0x000e  /* 16 EMU32 channels to Alice2 +0 to +0xf */
+#define EMU_DST_DOCK_DAC1_LEFT1        0x0100  /* Audio Dock DAC1 Left, 1st or 48kHz only */
+#define EMU_DST_DOCK_DAC1_LEFT2        0x0101  /* Audio Dock DAC1 Left, 2nd or 96kHz */
+#define EMU_DST_DOCK_DAC1_LEFT3        0x0102  /* Audio Dock DAC1 Left, 3rd or 192kHz */
+#define EMU_DST_DOCK_DAC1_LEFT4        0x0103  /* Audio Dock DAC1 Left, 4th or 192kHz */
+#define EMU_DST_DOCK_DAC1_RIGHT1       0x0104  /* Audio Dock DAC1 Right, 1st or 48kHz only */
+#define EMU_DST_DOCK_DAC1_RIGHT2       0x0105  /* Audio Dock DAC1 Right, 2nd or 96kHz */
+#define EMU_DST_DOCK_DAC1_RIGHT3       0x0106  /* Audio Dock DAC1 Right, 3rd or 192kHz */
+#define EMU_DST_DOCK_DAC1_RIGHT4       0x0107  /* Audio Dock DAC1 Right, 4th or 192kHz */
+#define EMU_DST_DOCK_DAC2_LEFT1        0x0108  /* Audio Dock DAC2 Left, 1st or 48kHz only */
+#define EMU_DST_DOCK_DAC2_LEFT2        0x0109  /* Audio Dock DAC2 Left, 2nd or 96kHz */
+#define EMU_DST_DOCK_DAC2_LEFT3        0x010a  /* Audio Dock DAC2 Left, 3rd or 192kHz */
+#define EMU_DST_DOCK_DAC2_LEFT4        0x010b  /* Audio Dock DAC2 Left, 4th or 192kHz */
+#define EMU_DST_DOCK_DAC2_RIGHT1       0x010c  /* Audio Dock DAC2 Right, 1st or 48kHz only */
+#define EMU_DST_DOCK_DAC2_RIGHT2       0x010d  /* Audio Dock DAC2 Right, 2nd or 96kHz */
+#define EMU_DST_DOCK_DAC2_RIGHT3       0x010e  /* Audio Dock DAC2 Right, 3rd or 192kHz */
+#define EMU_DST_DOCK_DAC2_RIGHT4       0x010f  /* Audio Dock DAC2 Right, 4th or 192kHz */
+#define EMU_DST_DOCK_DAC3_LEFT1        0x0110  /* Audio Dock DAC1 Left, 1st or 48kHz only */
+#define EMU_DST_DOCK_DAC3_LEFT2        0x0111  /* Audio Dock DAC1 Left, 2nd or 96kHz */
+#define EMU_DST_DOCK_DAC3_LEFT3        0x0112  /* Audio Dock DAC1 Left, 3rd or 192kHz */
+#define EMU_DST_DOCK_DAC3_LEFT4        0x0113  /* Audio Dock DAC1 Left, 4th or 192kHz */
+#define EMU_DST_DOCK_PHONES_LEFT1      0x0112  /* Audio Dock PHONES Left, 1st or 48kHz only */
+#define EMU_DST_DOCK_PHONES_LEFT2      0x0113  /* Audio Dock PHONES Left, 2nd or 96kHz */
+#define EMU_DST_DOCK_DAC3_RIGHT1       0x0114  /* Audio Dock DAC1 Right, 1st or 48kHz only */
+#define EMU_DST_DOCK_DAC3_RIGHT2       0x0115  /* Audio Dock DAC1 Right, 2nd or 96kHz */
+#define EMU_DST_DOCK_DAC3_RIGHT3       0x0116  /* Audio Dock DAC1 Right, 3rd or 192kHz */
+#define EMU_DST_DOCK_DAC3_RIGHT4       0x0117  /* Audio Dock DAC1 Right, 4th or 192kHz */
+#define EMU_DST_DOCK_PHONES_RIGHT1     0x0116  /* Audio Dock PHONES Right, 1st or 48kHz only */
+#define EMU_DST_DOCK_PHONES_RIGHT2     0x0117  /* Audio Dock PHONES Right, 2nd or 96kHz */
+#define EMU_DST_DOCK_DAC4_LEFT1        0x0118  /* Audio Dock DAC2 Left, 1st or 48kHz only */
+#define EMU_DST_DOCK_DAC4_LEFT2        0x0119  /* Audio Dock DAC2 Left, 2nd or 96kHz */
+#define EMU_DST_DOCK_DAC4_LEFT3        0x011a  /* Audio Dock DAC2 Left, 3rd or 192kHz */
+#define EMU_DST_DOCK_DAC4_LEFT4        0x011b  /* Audio Dock DAC2 Left, 4th or 192kHz */
+#define EMU_DST_DOCK_SPDIF_LEFT1       0x011a  /* Audio Dock SPDIF Left, 1st or 48kHz only */
+#define EMU_DST_DOCK_SPDIF_LEFT2       0x011b  /* Audio Dock SPDIF Left, 2nd or 96kHz */
+#define EMU_DST_DOCK_DAC4_RIGHT1       0x011c  /* Audio Dock DAC2 Right, 1st or 48kHz only */
+#define EMU_DST_DOCK_DAC4_RIGHT2       0x011d  /* Audio Dock DAC2 Right, 2nd or 96kHz */
+#define EMU_DST_DOCK_DAC4_RIGHT3       0x011e  /* Audio Dock DAC2 Right, 3rd or 192kHz */
+#define EMU_DST_DOCK_DAC4_RIGHT4       0x011f  /* Audio Dock DAC2 Right, 4th or 192kHz */
+#define EMU_DST_DOCK_SPDIF_RIGHT1      0x011e  /* Audio Dock SPDIF Right, 1st or 48kHz only */
+#define EMU_DST_DOCK_SPDIF_RIGHT2      0x011f  /* Audio Dock SPDIF Right, 2nd or 96kHz */
+#define EMU_DST_HANA_SPDIF_LEFT1       0x0200  /* Hana SPDIF Left, 1st or 48kHz only */
+#define EMU_DST_HANA_SPDIF_LEFT2       0x0202  /* Hana SPDIF Left, 2nd or 96kHz */
+#define EMU_DST_HANA_SPDIF_RIGHT1      0x0201  /* Hana SPDIF Right, 1st or 48kHz only */
+#define EMU_DST_HANA_SPDIF_RIGHT2      0x0203  /* Hana SPDIF Right, 2nd or 96kHz */
+#define EMU_DST_HAMOA_DAC_LEFT1        0x0300  /* Hamoa DAC Left, 1st or 48kHz only */
+#define EMU_DST_HAMOA_DAC_LEFT2        0x0302  /* Hamoa DAC Left, 2nd or 96kHz */
+#define EMU_DST_HAMOA_DAC_LEFT3        0x0304  /* Hamoa DAC Left, 3rd or 192kHz */
+#define EMU_DST_HAMOA_DAC_LEFT4        0x0306  /* Hamoa DAC Left, 4th or 192kHz */
+#define EMU_DST_HAMOA_DAC_RIGHT1       0x0301  /* Hamoa DAC Right, 1st or 48kHz only */
+#define EMU_DST_HAMOA_DAC_RIGHT2       0x0303  /* Hamoa DAC Right, 2nd or 96kHz */
+#define EMU_DST_HAMOA_DAC_RIGHT3       0x0305  /* Hamoa DAC Right, 3rd or 192kHz */
+#define EMU_DST_HAMOA_DAC_RIGHT4       0x0307  /* Hamoa DAC Right, 4th or 192kHz */
+#define EMU_DST_HANA_ADAT      0x0400  /* Hana ADAT 8 channel out +0 to +7 */
+#define EMU_DST_ALICE_I2S0_LEFT                0x0500  /* Alice2 I2S0 Left */
+#define EMU_DST_ALICE_I2S0_RIGHT       0x0501  /* Alice2 I2S0 Right */
+#define EMU_DST_ALICE_I2S1_LEFT                0x0600  /* Alice2 I2S1 Left */
+#define EMU_DST_ALICE_I2S1_RIGHT       0x0601  /* Alice2 I2S1 Right */
+#define EMU_DST_ALICE_I2S2_LEFT                0x0700  /* Alice2 I2S2 Left */
+#define EMU_DST_ALICE_I2S2_RIGHT       0x0701  /* Alice2 I2S2 Right */
+
+/************************************************************************************************/
+/* EMU1010m HANA Sources                                                                       */
+/************************************************************************************************/
+#define EMU_SRC_SILENCE                0x0000  /* Silence */
+#define EMU_SRC_DOCK_MIC_A1    0x0100  /* Audio Dock Mic A, 1st or 48kHz only */
+#define EMU_SRC_DOCK_MIC_A2    0x0101  /* Audio Dock Mic A, 2nd or 96kHz */
+#define EMU_SRC_DOCK_MIC_A3    0x0102  /* Audio Dock Mic A, 3rd or 192kHz */
+#define EMU_SRC_DOCK_MIC_A4    0x0103  /* Audio Dock Mic A, 4th or 192kHz */
+#define EMU_SRC_DOCK_MIC_B1    0x0104  /* Audio Dock Mic B, 1st or 48kHz only */
+#define EMU_SRC_DOCK_MIC_B2    0x0105  /* Audio Dock Mic B, 2nd or 96kHz */
+#define EMU_SRC_DOCK_MIC_B3    0x0106  /* Audio Dock Mic B, 3rd or 192kHz */
+#define EMU_SRC_DOCK_MIC_B4    0x0107  /* Audio Dock Mic B, 4th or 192kHz */
+#define EMU_SRC_DOCK_ADC1_LEFT1        0x0108  /* Audio Dock ADC1 Left, 1st or 48kHz only */
+#define EMU_SRC_DOCK_ADC1_LEFT2        0x0109  /* Audio Dock ADC1 Left, 2nd or 96kHz */
+#define EMU_SRC_DOCK_ADC1_LEFT3        0x010a  /* Audio Dock ADC1 Left, 3rd or 192kHz */
+#define EMU_SRC_DOCK_ADC1_LEFT4        0x010b  /* Audio Dock ADC1 Left, 4th or 192kHz */
+#define EMU_SRC_DOCK_ADC1_RIGHT1       0x010c  /* Audio Dock ADC1 Right, 1st or 48kHz only */
+#define EMU_SRC_DOCK_ADC1_RIGHT2       0x010d  /* Audio Dock ADC1 Right, 2nd or 96kHz */
+#define EMU_SRC_DOCK_ADC1_RIGHT3       0x010e  /* Audio Dock ADC1 Right, 3rd or 192kHz */
+#define EMU_SRC_DOCK_ADC1_RIGHT4       0x010f  /* Audio Dock ADC1 Right, 4th or 192kHz */
+#define EMU_SRC_DOCK_ADC2_LEFT1        0x0110  /* Audio Dock ADC2 Left, 1st or 48kHz only */
+#define EMU_SRC_DOCK_ADC2_LEFT2        0x0111  /* Audio Dock ADC2 Left, 2nd or 96kHz */
+#define EMU_SRC_DOCK_ADC2_LEFT3        0x0112  /* Audio Dock ADC2 Left, 3rd or 192kHz */
+#define EMU_SRC_DOCK_ADC2_LEFT4        0x0113  /* Audio Dock ADC2 Left, 4th or 192kHz */
+#define EMU_SRC_DOCK_ADC2_RIGHT1       0x0114  /* Audio Dock ADC2 Right, 1st or 48kHz only */
+#define EMU_SRC_DOCK_ADC2_RIGHT2       0x0115  /* Audio Dock ADC2 Right, 2nd or 96kHz */
+#define EMU_SRC_DOCK_ADC2_RIGHT3       0x0116  /* Audio Dock ADC2 Right, 3rd or 192kHz */
+#define EMU_SRC_DOCK_ADC2_RIGHT4       0x0117  /* Audio Dock ADC2 Right, 4th or 192kHz */
+#define EMU_SRC_DOCK_ADC3_LEFT1        0x0118  /* Audio Dock ADC3 Left, 1st or 48kHz only */
+#define EMU_SRC_DOCK_ADC3_LEFT2        0x0119  /* Audio Dock ADC3 Left, 2nd or 96kHz */
+#define EMU_SRC_DOCK_ADC3_LEFT3        0x011a  /* Audio Dock ADC3 Left, 3rd or 192kHz */
+#define EMU_SRC_DOCK_ADC3_LEFT4        0x011b  /* Audio Dock ADC3 Left, 4th or 192kHz */
+#define EMU_SRC_DOCK_ADC3_RIGHT1       0x011c  /* Audio Dock ADC3 Right, 1st or 48kHz only */
+#define EMU_SRC_DOCK_ADC3_RIGHT2       0x011d  /* Audio Dock ADC3 Right, 2nd or 96kHz */
+#define EMU_SRC_DOCK_ADC3_RIGHT3       0x011e  /* Audio Dock ADC3 Right, 3rd or 192kHz */
+#define EMU_SRC_DOCK_ADC3_RIGHT4       0x011f  /* Audio Dock ADC3 Right, 4th or 192kHz */
+#define EMU_SRC_HAMOA_ADC_LEFT1        0x0200  /* Hamoa ADC Left, 1st or 48kHz only */
+#define EMU_SRC_HAMOA_ADC_LEFT2        0x0202  /* Hamoa ADC Left, 2nd or 96kHz */
+#define EMU_SRC_HAMOA_ADC_LEFT3        0x0204  /* Hamoa ADC Left, 3rd or 192kHz */
+#define EMU_SRC_HAMOA_ADC_LEFT4        0x0206  /* Hamoa ADC Left, 4th or 192kHz */
+#define EMU_SRC_HAMOA_ADC_RIGHT1       0x0201  /* Hamoa ADC Right, 1st or 48kHz only */
+#define EMU_SRC_HAMOA_ADC_RIGHT2       0x0203  /* Hamoa ADC Right, 2nd or 96kHz */
+#define EMU_SRC_HAMOA_ADC_RIGHT3       0x0205  /* Hamoa ADC Right, 3rd or 192kHz */
+#define EMU_SRC_HAMOA_ADC_RIGHT4       0x0207  /* Hamoa ADC Right, 4th or 192kHz */
+#define EMU_SRC_ALICE_EMU32A           0x0300  /* Alice2 EMU32a 16 outputs. +0 to +0xf */
+#define EMU_SRC_ALICE_EMU32B           0x0310  /* Alice2 EMU32b 16 outputs. +0 to +0xf */
+#define EMU_SRC_HANA_ADAT      0x0400  /* Hana ADAT 8 channel in +0 to +7 */
+#define EMU_SRC_HANA_SPDIF_LEFT1       0x0500  /* Hana SPDIF Left, 1st or 48kHz only */
+#define EMU_SRC_HANA_SPDIF_LEFT2       0x0502  /* Hana SPDIF Left, 2nd or 96kHz */
+#define EMU_SRC_HANA_SPDIF_RIGHT1      0x0501  /* Hana SPDIF Right, 1st or 48kHz only */
+#define EMU_SRC_HANA_SPDIF_RIGHT2      0x0503  /* Hana SPDIF Right, 2nd or 96kHz */
+/* 0x600 and 0x700 no used */
 
 /* ------------------- STRUCTURES -------------------- */
 
@@ -1063,7 +1425,7 @@ struct snd_emu_chip_details {
        unsigned char spdif_bug;    /* Has Spdif phasing bug */
        unsigned char ac97_chip;    /* Has an AC97 chip: 1 = mandatory, 2 = optional */
        unsigned char ecard;        /* APS EEPROM */
-       unsigned char emu1212m;     /* EMU 1212m card */
+       unsigned char emu1010;     /* EMU 1010m card */
        unsigned char spi_dac;      /* SPI interface for DAC */
        unsigned char i2c_adc;      /* I2C interface for ADC */
        unsigned char adc_1361t;    /* Use Philips 1361T ADC */
@@ -1072,6 +1434,14 @@ struct snd_emu_chip_details {
        const char *id;         /* for backward compatibility - can be NULL if not needed */
 };
 
+struct snd_emu1010 {
+       unsigned int output_source[64];
+       unsigned int input_source[64];
+       unsigned int adc_pads; /* bit mask */
+       unsigned int dac_pads; /* bit mask */
+       unsigned int internal_clock; /* 44100 or 48000 */
+};
+
 struct snd_emu10k1 {
        int irq;
 
@@ -1079,6 +1449,7 @@ struct snd_emu10k1 {
        unsigned int tos_link: 1,               /* tos link detected */
                rear_ac97: 1,                   /* rear channels are on AC'97 */
                enable_ir: 1;
+       unsigned int support_tlv :1;
        /* Contains profile of card capabilities */
        const struct snd_emu_chip_details *card_capabilities;
        unsigned int audigy;                    /* is Audigy? */
@@ -1104,6 +1475,8 @@ struct snd_emu10k1 {
        spinlock_t memblk_lock;
 
        unsigned int spdif_bits[3];             /* s/pdif out setup */
+       unsigned int i2c_capture_source;
+       u8 i2c_capture_volume[4][2];
 
        struct snd_emu10k1_fx8010 fx8010;               /* FX8010 info */
        int gpr_base;
@@ -1132,6 +1505,7 @@ struct snd_emu10k1 {
        int p16v_device_offset;
        u32 p16v_capture_source;
        u32 p16v_capture_channel;
+        struct snd_emu1010 emu1010;
        struct snd_emu10k1_pcm_mixer pcm_mixer[32];
        struct snd_emu10k1_pcm_mixer efx_pcm_mixer[NUM_EFX_PLAYBACK];
        struct snd_kcontrol *ctl_send_routing;
@@ -1208,6 +1582,10 @@ void snd_emu10k1_ptr_write(struct snd_emu10k1 *emu, unsigned int reg, unsigned i
 unsigned int snd_emu10k1_ptr20_read(struct snd_emu10k1 * emu, unsigned int reg, unsigned int chn);
 void snd_emu10k1_ptr20_write(struct snd_emu10k1 *emu, unsigned int reg, unsigned int chn, unsigned int data);
 int snd_emu10k1_spi_write(struct snd_emu10k1 * emu, unsigned int data);
+int snd_emu10k1_i2c_write(struct snd_emu10k1 *emu, u32 reg, u32 value);
+int snd_emu1010_fpga_write(struct snd_emu10k1 * emu, int reg, int value);
+int snd_emu1010_fpga_read(struct snd_emu10k1 * emu, int reg, int *value);
+int snd_emu1010_fpga_link_dst_src_write(struct snd_emu10k1 * emu, int dst, int src);
 unsigned int snd_emu10k1_efx_read(struct snd_emu10k1 *emu, unsigned int pc);
 void snd_emu10k1_intr_enable(struct snd_emu10k1 *emu, unsigned int intrenb);
 void snd_emu10k1_intr_disable(struct snd_emu10k1 *emu, unsigned int intrenb);
@@ -1524,11 +1902,20 @@ struct snd_emu10k1_fx8010_control_gpr {
        unsigned int value[32];         /* initial values */
        unsigned int min;               /* minimum range */
        unsigned int max;               /* maximum range */
-       union {
-               snd_kcontrol_tlv_rw_t *c;
-               unsigned int *p;
-       } tlv;
        unsigned int translation;       /* translation type (EMU10K1_GPR_TRANSLATION*) */
+       const unsigned int *tlv;
+};
+
+/* old ABI without TLV support */
+struct snd_emu10k1_fx8010_control_old_gpr {
+       struct snd_ctl_elem_id id;
+       unsigned int vcount;
+       unsigned int count;
+       unsigned short gpr[32];
+       unsigned int value[32];
+       unsigned int min;
+       unsigned int max;
+       unsigned int translation;
 };
 
 struct snd_emu10k1_fx8010_code {
@@ -1579,6 +1966,8 @@ struct snd_emu10k1_fx8010_pcm_rec {
        unsigned int res2;              /* reserved */
 };
 
+#define SNDRV_EMU10K1_VERSION          SNDRV_PROTOCOL_VERSION(1, 0, 1)
+
 #define SNDRV_EMU10K1_IOCTL_INFO       _IOR ('H', 0x10, struct snd_emu10k1_fx8010_info)
 #define SNDRV_EMU10K1_IOCTL_CODE_POKE  _IOW ('H', 0x11, struct snd_emu10k1_fx8010_code)
 #define SNDRV_EMU10K1_IOCTL_CODE_PEEK  _IOWR('H', 0x12, struct snd_emu10k1_fx8010_code)
@@ -1587,6 +1976,7 @@ struct snd_emu10k1_fx8010_pcm_rec {
 #define SNDRV_EMU10K1_IOCTL_TRAM_PEEK  _IOWR('H', 0x22, struct snd_emu10k1_fx8010_tram)
 #define SNDRV_EMU10K1_IOCTL_PCM_POKE   _IOW ('H', 0x30, struct snd_emu10k1_fx8010_pcm_rec)
 #define SNDRV_EMU10K1_IOCTL_PCM_PEEK   _IOWR('H', 0x31, struct snd_emu10k1_fx8010_pcm_rec)
+#define SNDRV_EMU10K1_IOCTL_PVERSION   _IOR ('H', 0x40, int)
 #define SNDRV_EMU10K1_IOCTL_STOP       _IO  ('H', 0x80)
 #define SNDRV_EMU10K1_IOCTL_CONTINUE   _IO  ('H', 0x81)
 #define SNDRV_EMU10K1_IOCTL_ZERO_TRAM_COUNTER _IO ('H', 0x82)
index 2f645dfd7f70c59e64f64ab2ad8ff5a2e8588358..ee6bc2d0680321f4b7d10af1d2c1c3d16c2b98e8 100644 (file)
@@ -56,6 +56,8 @@ struct snd_pcm_hardware {
        size_t fifo_size;               /* fifo size in bytes */
 };
 
+struct snd_pcm_substream;
+
 struct snd_pcm_ops {
        int (*open)(struct snd_pcm_substream *substream);
        int (*close)(struct snd_pcm_substream *substream);
@@ -384,6 +386,7 @@ struct snd_pcm_substream {
        struct snd_info_entry *proc_sw_params_entry;
        struct snd_info_entry *proc_status_entry;
        struct snd_info_entry *proc_prealloc_entry;
+       struct snd_info_entry *proc_prealloc_max_entry;
 #endif
        /* misc flags */
        unsigned int hw_opened: 1;
@@ -427,6 +430,7 @@ struct snd_pcm {
        wait_queue_head_t open_wait;
        void *private_data;
        void (*private_free) (struct snd_pcm *pcm);
+       struct device *dev; /* actual hw device this belongs to */
 #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
        struct snd_pcm_oss oss;
 #endif
diff --git a/include/sound/pt2258.h b/include/sound/pt2258.h
new file mode 100644 (file)
index 0000000..160f812
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ *   ALSA Driver for the PT2258 volume controller.
+ *
+ *     Copyright (c) 2006  Jochen Voss <voss@seehuhn.de>
+ *
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+ *
+ */      
+
+#ifndef __SOUND_PT2258_H
+#define __SOUND_PT2258_H
+
+struct snd_pt2258 {
+       struct snd_card *card;
+       struct snd_i2c_bus *i2c_bus;
+       struct snd_i2c_device *i2c_dev;
+
+       unsigned char volume[6];
+       int mute;
+};
+
+extern int snd_pt2258_reset(struct snd_pt2258 *pt);
+extern int snd_pt2258_build_controls(struct snd_pt2258 *pt);
+
+#endif /* __SOUND_PT2258_H */
index caf6fe21514dca62c1005a1ee9cc79210f545b35..736eac71d053dd165ae065ded9beb0a11ca00c56 100644 (file)
@@ -114,9 +114,21 @@ struct snd_sb_csp_info {
 #ifdef __KERNEL__
 #include "sb.h"
 #include "hwdep.h"
+#include <linux/firmware.h>
 
 struct snd_sb_csp;
 
+/* indices for the known CSP programs */
+enum {
+       CSP_PROGRAM_MULAW,
+       CSP_PROGRAM_ALAW,
+       CSP_PROGRAM_ADPCM_INIT,
+       CSP_PROGRAM_ADPCM_PLAYBACK,
+       CSP_PROGRAM_ADPCM_CAPTURE,
+
+       CSP_PROGRAM_COUNT
+};
+
 /*
  * CSP operators
  */
@@ -159,6 +171,8 @@ struct snd_sb_csp {
        struct snd_kcontrol *qsound_space;
 
        struct mutex access_mutex;      /* locking */
+
+       const struct firmware *csp_programs[CSP_PROGRAM_COUNT];
 };
 
 int snd_sb_csp_new(struct snd_sb *chip, int device, struct snd_hwdep ** rhwdep);
index 0b9e5de94ff10d8cdedf8dac10c3089271c26553..9688d4be918ecd660dc7a7d2f2fbbaa7b9c9016a 100644 (file)
@@ -85,6 +85,7 @@ struct _snd_wavefront {
        char hw_version[2];                /* major = [0], minor = [1] */
        char israw;                        /* needs Motorola microcode */
        char has_fx;                       /* has FX processor (Tropez+) */
+       char fx_initialized;               /* FX's register pages initialized */
        char prog_status[WF_MAX_PROGRAM];  /* WF_SLOT_* */
        char patch_status[WF_MAX_PATCH];   /* WF_SLOT_* */
        char sample_status[WF_MAX_SAMPLE]; /* WF_ST_* | WF_SLOT_* */
@@ -94,6 +95,7 @@ struct _snd_wavefront {
        spinlock_t irq_lock;
        wait_queue_head_t interrupt_sleeper; 
        snd_wavefront_midi_t midi;         /* ICS2115 MIDI interface */
+       struct snd_card *card;
 };
 
 struct _snd_wavefront_card {
diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h
new file mode 100644 (file)
index 0000000..2b1ae8e
--- /dev/null
@@ -0,0 +1,286 @@
+/*
+ * linux/sound/soc-dapm.h -- ALSA SoC Dynamic Audio Power Management
+ *
+ * Author:             Liam Girdwood
+ * Created:            Aug 11th 2005
+ * Copyright:  Wolfson Microelectronics. PLC.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __LINUX_SND_SOC_DAPM_H
+#define __LINUX_SND_SOC_DAPM_H
+
+#include <linux/device.h>
+#include <linux/types.h>
+#include <sound/control.h>
+#include <sound/soc.h>
+
+/* widget has no PM register bit */
+#define SND_SOC_NOPM   -1
+
+/*
+ * SoC dynamic audio power managment
+ *
+ * We can have upto 4 power domains
+ *     1. Codec domain - VREF, VMID
+ *     Usually controlled at codec probe/remove, although can be set
+ *     at stream time if power is not needed for sidetone, etc.
+ *  2. Platform/Machine domain - physically connected inputs and outputs
+ *     Is platform/machine and user action specific, is set in the machine
+ *     driver and by userspace e.g when HP are inserted
+ *  3. Path domain - Internal codec path mixers
+ *     Are automatically set when mixer and mux settings are
+ *     changed by the user.
+ *  4. Stream domain - DAC's and ADC's.
+ *     Enabled when stream playback/capture is started.
+ */
+
+/* codec domain */
+#define SND_SOC_DAPM_VMID(wname) \
+{      .id = snd_soc_dapm_vmid, .name = wname, .kcontrols = NULL, \
+       .num_kcontrols = 0}
+
+/* platform domain */
+#define SND_SOC_DAPM_INPUT(wname) \
+{      .id = snd_soc_dapm_input, .name = wname, .kcontrols = NULL, \
+       .num_kcontrols = 0}
+#define SND_SOC_DAPM_OUTPUT(wname) \
+{      .id = snd_soc_dapm_output, .name = wname, .kcontrols = NULL, \
+       .num_kcontrols = 0}
+#define SND_SOC_DAPM_MIC(wname, wevent) \
+{      .id = snd_soc_dapm_mic, .name = wname, .kcontrols = NULL, \
+       .num_kcontrols = 0, .event = wevent, \
+       .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD}
+#define SND_SOC_DAPM_HP(wname, wevent) \
+{      .id = snd_soc_dapm_hp, .name = wname, .kcontrols = NULL, \
+       .num_kcontrols = 0, .event = wevent, \
+       .event_flags = SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD}
+#define SND_SOC_DAPM_SPK(wname, wevent) \
+{      .id = snd_soc_dapm_spk, .name = wname, .kcontrols = NULL, \
+       .num_kcontrols = 0, .event = wevent, \
+       .event_flags = SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD}
+#define SND_SOC_DAPM_LINE(wname, wevent) \
+{      .id = snd_soc_dapm_line, .name = wname, .kcontrols = NULL, \
+       .num_kcontrols = 0, .event = wevent, \
+       .event_flags = SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD}
+
+/* path domain */
+#define SND_SOC_DAPM_PGA(wname, wreg, wshift, winvert,\
+        wcontrols, wncontrols) \
+{      .id = snd_soc_dapm_pga, .name = wname, .reg = wreg, .shift = wshift, \
+       .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = wncontrols}
+#define SND_SOC_DAPM_MIXER(wname, wreg, wshift, winvert, \
+        wcontrols, wncontrols)\
+{      .id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \
+       .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = wncontrols}
+#define SND_SOC_DAPM_MICBIAS(wname, wreg, wshift, winvert) \
+{      .id = snd_soc_dapm_micbias, .name = wname, .reg = wreg, .shift = wshift, \
+       .invert = winvert, .kcontrols = NULL, .num_kcontrols = 0}
+#define SND_SOC_DAPM_SWITCH(wname, wreg, wshift, winvert, wcontrols) \
+{      .id = snd_soc_dapm_switch, .name = wname, .reg = wreg, .shift = wshift, \
+       .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = 1}
+#define SND_SOC_DAPM_MUX(wname, wreg, wshift, winvert, wcontrols) \
+{      .id = snd_soc_dapm_mux, .name = wname, .reg = wreg, .shift = wshift, \
+       .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = 1}
+
+/* path domain with event - event handler must return 0 for success */
+#define SND_SOC_DAPM_PGA_E(wname, wreg, wshift, winvert, wcontrols, \
+       wncontrols, wevent, wflags) \
+{      .id = snd_soc_dapm_pga, .name = wname, .reg = wreg, .shift = wshift, \
+       .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = wncontrols, \
+       .event = wevent, .event_flags = wflags}
+#define SND_SOC_DAPM_MIXER_E(wname, wreg, wshift, winvert, wcontrols, \
+       wncontrols, wevent, wflags) \
+{      .id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \
+       .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = wncontrols, \
+       .event = wevent, .event_flags = wflags}
+#define SND_SOC_DAPM_MICBIAS_E(wname, wreg, wshift, winvert, wevent, wflags) \
+{      .id = snd_soc_dapm_micbias, .name = wname, .reg = wreg, .shift = wshift, \
+       .invert = winvert, .kcontrols = NULL, .num_kcontrols = 0, \
+       .event = wevent, .event_flags = wflags}
+#define SND_SOC_DAPM_SWITCH_E(wname, wreg, wshift, winvert, wcontrols, \
+       wevent, wflags) \
+{      .id = snd_soc_dapm_switch, .name = wname, .reg = wreg, .shift = wshift, \
+       .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = 1 \
+       .event = wevent, .event_flags = wflags}
+#define SND_SOC_DAPM_MUX_E(wname, wreg, wshift, winvert, wcontrols, \
+       wevent, wflags) \
+{      .id = snd_soc_dapm_mux, .name = wname, .reg = wreg, .shift = wshift, \
+       .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = 1, \
+       .event = wevent, .event_flags = wflags}
+
+/* events that are pre and post DAPM */
+#define SND_SOC_DAPM_PRE(wname, wevent) \
+{      .id = snd_soc_dapm_pre, .name = wname, .kcontrols = NULL, \
+       .num_kcontrols = 0, .event = wevent, \
+       .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD}
+#define SND_SOC_DAPM_POST(wname, wevent) \
+{      .id = snd_soc_dapm_post, .name = wname, .kcontrols = NULL, \
+       .num_kcontrols = 0, .event = wevent, \
+       .event_flags = SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD}
+
+/* stream domain */
+#define SND_SOC_DAPM_DAC(wname, stname, wreg, wshift, winvert) \
+{      .id = snd_soc_dapm_dac, .name = wname, .sname = stname, .reg = wreg, \
+       .shift = wshift, .invert = winvert}
+#define SND_SOC_DAPM_ADC(wname, stname, wreg, wshift, winvert) \
+{      .id = snd_soc_dapm_adc, .name = wname, .sname = stname, .reg = wreg, \
+       .shift = wshift, .invert = winvert}
+
+/* dapm kcontrol types */
+#define SOC_DAPM_SINGLE(xname, reg, shift, mask, invert) \
+{      .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
+       .info = snd_soc_info_volsw, \
+       .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \
+       .private_value =  SOC_SINGLE_VALUE(reg, shift, mask, invert) }
+#define SOC_DAPM_DOUBLE(xname, reg, shift_left, shift_right, mask, invert, \
+       power) \
+{      .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
+       .info = snd_soc_info_volsw, \
+       .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \
+       .private_value = (reg) | ((shift_left) << 8) | ((shift_right) << 12) |\
+                ((mask) << 16) | ((invert) << 24) }
+#define SOC_DAPM_ENUM(xname, xenum) \
+{      .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
+       .info = snd_soc_info_enum_double, \
+       .get = snd_soc_dapm_get_enum_double, \
+       .put = snd_soc_dapm_put_enum_double, \
+       .private_value = (unsigned long)&xenum }
+
+/* dapm stream operations */
+#define SND_SOC_DAPM_STREAM_NOP                        0x0
+#define SND_SOC_DAPM_STREAM_START              0x1
+#define SND_SOC_DAPM_STREAM_STOP               0x2
+#define SND_SOC_DAPM_STREAM_SUSPEND            0x4
+#define SND_SOC_DAPM_STREAM_RESUME             0x8
+#define SND_SOC_DAPM_STREAM_PAUSE_PUSH 0x10
+#define SND_SOC_DAPM_STREAM_PAUSE_RELEASE      0x20
+
+/* dapm event types */
+#define SND_SOC_DAPM_PRE_PMU   0x1     /* before widget power up */
+#define SND_SOC_DAPM_POST_PMU  0x2             /* after widget power up */
+#define SND_SOC_DAPM_PRE_PMD   0x4     /* before widget power down */
+#define SND_SOC_DAPM_POST_PMD  0x8             /* after widget power down */
+#define SND_SOC_DAPM_PRE_REG   0x10    /* before audio path setup */
+#define SND_SOC_DAPM_POST_REG  0x20    /* after audio path setup */
+
+/* convenience event type detection */
+#define SND_SOC_DAPM_EVENT_ON(e)       \
+       (e & (SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU))
+#define SND_SOC_DAPM_EVENT_OFF(e)      \
+       (e & (SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD))
+
+struct snd_soc_dapm_widget;
+enum snd_soc_dapm_type;
+struct snd_soc_dapm_path;
+struct snd_soc_dapm_pin;
+
+/* dapm controls */
+int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_value *ucontrol);
+int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_value *ucontrol);
+int snd_soc_dapm_get_enum_double(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_value *ucontrol);
+int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_value *ucontrol);
+int snd_soc_dapm_new_control(struct snd_soc_codec *codec,
+       const struct snd_soc_dapm_widget *widget);
+
+/* dapm path setup */
+int snd_soc_dapm_connect_input(struct snd_soc_codec *codec,
+       const char *sink_name, const char *control_name, const char *src_name);
+int snd_soc_dapm_new_widgets(struct snd_soc_codec *codec);
+void snd_soc_dapm_free(struct snd_soc_device *socdev);
+
+/* dapm events */
+int snd_soc_dapm_stream_event(struct snd_soc_codec *codec, char *stream,
+       int event);
+
+/* dapm sys fs - used by the core */
+int snd_soc_dapm_sys_add(struct device *dev);
+
+/* dapm audio endpoint control */
+int snd_soc_dapm_set_endpoint(struct snd_soc_codec *codec,
+       char *pin, int status);
+int snd_soc_dapm_sync_endpoints(struct snd_soc_codec *codec);
+
+/* dapm widget types */
+enum snd_soc_dapm_type {
+       snd_soc_dapm_input = 0,         /* input pin */
+       snd_soc_dapm_output,            /* output pin */
+       snd_soc_dapm_mux,                       /* selects 1 analog signal from many inputs */
+       snd_soc_dapm_mixer,                     /* mixes several analog signals together */
+       snd_soc_dapm_pga,                       /* programmable gain/attenuation (volume) */
+       snd_soc_dapm_adc,                       /* analog to digital converter */
+       snd_soc_dapm_dac,                       /* digital to analog converter */
+       snd_soc_dapm_micbias,           /* microphone bias (power) */
+       snd_soc_dapm_mic,                       /* microphone */
+       snd_soc_dapm_hp,                        /* headphones */
+       snd_soc_dapm_spk,                       /* speaker */
+       snd_soc_dapm_line,                      /* line input/output */
+       snd_soc_dapm_switch,            /* analog switch */
+       snd_soc_dapm_vmid,                      /* codec bias/vmid - to minimise pops */
+       snd_soc_dapm_pre,                       /* machine specific pre widget - exec first */
+       snd_soc_dapm_post,                      /* machine specific post widget - exec last */
+};
+
+/* dapm audio path between two widgets */
+struct snd_soc_dapm_path {
+       char *name;
+       char *long_name;
+
+       /* source (input) and sink (output) widgets */
+       struct snd_soc_dapm_widget *source;
+       struct snd_soc_dapm_widget *sink;
+       struct snd_kcontrol *kcontrol;
+
+       /* status */
+       u32 connect:1;  /* source and sink widgets are connected */
+       u32 walked:1;   /* path has been walked */
+
+       struct list_head list_source;
+       struct list_head list_sink;
+       struct list_head list;
+};
+
+/* dapm widget */
+struct snd_soc_dapm_widget {
+       enum snd_soc_dapm_type id;
+       char *name;             /* widget name */
+       char *sname;    /* stream name */
+       struct snd_soc_codec *codec;
+       struct list_head list;
+
+       /* dapm control */
+       short reg;                                              /* negative reg = no direct dapm */
+       unsigned char shift;                    /* bits to shift */
+       unsigned int saved_value;               /* widget saved value */
+       unsigned int value;                             /* widget current value */
+       unsigned char power:1;                  /* block power status */
+       unsigned char invert:1;                 /* invert the power bit */
+       unsigned char active:1;                 /* active stream on DAC, ADC's */
+       unsigned char connected:1;              /* connected codec pin */
+       unsigned char new:1;                    /* cnew complete */
+       unsigned char ext:1;                    /* has external widgets */
+       unsigned char muted:1;                  /* muted for pop reduction */
+       unsigned char suspend:1;                /* was active before suspend */
+       unsigned char pmdown:1;                 /* waiting for timeout */
+
+       /* external events */
+       unsigned short event_flags;             /* flags to specify event types */
+       int (*event)(struct snd_soc_dapm_widget*, int);
+
+       /* kcontrols that relate to this widget */
+       int num_kcontrols;
+       const struct snd_kcontrol_new *kcontrols;
+
+       /* widget input and outputs */
+       struct list_head sources;
+       struct list_head sinks;
+};
+
+#endif
diff --git a/include/sound/soc.h b/include/sound/soc.h
new file mode 100644 (file)
index 0000000..b1dc364
--- /dev/null
@@ -0,0 +1,461 @@
+/*
+ * linux/sound/soc.h -- ALSA SoC Layer
+ *
+ * Author:             Liam Girdwood
+ * Created:            Aug 11th 2005
+ * Copyright:  Wolfson Microelectronics. PLC.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __LINUX_SND_SOC_H
+#define __LINUX_SND_SOC_H
+
+#include <linux/platform_device.h>
+#include <linux/types.h>
+#include <linux/workqueue.h>
+#include <sound/driver.h>
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/control.h>
+#include <sound/ac97_codec.h>
+
+#define SND_SOC_VERSION "0.13.0"
+
+/*
+ * Convenience kcontrol builders
+ */
+#define SOC_SINGLE_VALUE(reg,shift,mask,invert) ((reg) | ((shift) << 8) |\
+       ((shift) << 12) | ((mask) << 16) | ((invert) << 24))
+#define SOC_SINGLE_VALUE_EXT(reg,mask,invert) ((reg) | ((mask) << 16) |\
+       ((invert) << 31))
+#define SOC_SINGLE(xname, reg, shift, mask, invert) \
+{      .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
+       .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
+       .put = snd_soc_put_volsw, \
+       .private_value =  SOC_SINGLE_VALUE(reg, shift, mask, invert) }
+#define SOC_DOUBLE(xname, reg, shift_left, shift_right, mask, invert) \
+{      .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
+       .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \
+       .put = snd_soc_put_volsw, \
+       .private_value = (reg) | ((shift_left) << 8) | \
+               ((shift_right) << 12) | ((mask) << 16) | ((invert) << 24) }
+#define SOC_DOUBLE_R(xname, reg_left, reg_right, shift, mask, invert) \
+{      .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
+       .info = snd_soc_info_volsw_2r, \
+       .get = snd_soc_get_volsw_2r, .put = snd_soc_put_volsw_2r, \
+       .private_value = (reg_left) | ((shift) << 8)  | \
+               ((mask) << 12) | ((invert) << 20) | ((reg_right) << 24) }
+#define SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, xtexts) \
+{      .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
+       .mask = xmask, .texts = xtexts }
+#define SOC_ENUM_SINGLE(xreg, xshift, xmask, xtexts) \
+       SOC_ENUM_DOUBLE(xreg, xshift, xshift, xmask, xtexts)
+#define SOC_ENUM_SINGLE_EXT(xmask, xtexts) \
+{      .mask = xmask, .texts = xtexts }
+#define SOC_ENUM(xname, xenum) \
+{      .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,\
+       .info = snd_soc_info_enum_double, \
+       .get = snd_soc_get_enum_double, .put = snd_soc_put_enum_double, \
+       .private_value = (unsigned long)&xenum }
+#define SOC_SINGLE_EXT(xname, xreg, xshift, xmask, xinvert,\
+        xhandler_get, xhandler_put) \
+{      .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
+       .info = snd_soc_info_volsw, \
+       .get = xhandler_get, .put = xhandler_put, \
+       .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmask, xinvert) }
+#define SOC_SINGLE_BOOL_EXT(xname, xdata, xhandler_get, xhandler_put) \
+{      .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
+       .info = snd_soc_info_bool_ext, \
+       .get = xhandler_get, .put = xhandler_put, \
+       .private_value = xdata }
+#define SOC_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put) \
+{      .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
+       .info = snd_soc_info_enum_ext, \
+       .get = xhandler_get, .put = xhandler_put, \
+       .private_value = (unsigned long)&xenum }
+
+/*
+ * Digital Audio Interface (DAI) types
+ */
+#define SND_SOC_DAI_AC97       0x1
+#define SND_SOC_DAI_I2S                0x2
+#define SND_SOC_DAI_PCM                0x4
+
+/*
+ * DAI hardware audio formats
+ */
+#define SND_SOC_DAIFMT_I2S             0       /* I2S mode */
+#define SND_SOC_DAIFMT_RIGHT_J 1       /* Right justified mode */
+#define SND_SOC_DAIFMT_LEFT_J  2       /* Left Justified mode */
+#define SND_SOC_DAIFMT_DSP_A   3       /* L data msb after FRM or LRC */
+#define SND_SOC_DAIFMT_DSP_B   4       /* L data msb during FRM or LRC */
+#define SND_SOC_DAIFMT_AC97            5       /* AC97 */
+
+#define SND_SOC_DAIFMT_MSB     SND_SOC_DAIFMT_LEFT_J
+#define SND_SOC_DAIFMT_LSB     SND_SOC_DAIFMT_RIGHT_J
+
+/*
+ * DAI Gating
+ */
+#define SND_SOC_DAIFMT_CONT                    (0 << 4)        /* continuous clock */
+#define SND_SOC_DAIFMT_GATED           (1 << 4)        /* clock is gated when not Tx/Rx */
+
+/*
+ * DAI hardware signal inversions
+ */
+#define SND_SOC_DAIFMT_NB_NF           (0 << 8)        /* normal bit clock + frame */
+#define SND_SOC_DAIFMT_NB_IF           (1 << 8)        /* normal bclk + inv frm */
+#define SND_SOC_DAIFMT_IB_NF           (2 << 8)        /* invert bclk + nor frm */
+#define SND_SOC_DAIFMT_IB_IF           (3 << 8)        /* invert bclk + frm */
+
+/*
+ * DAI hardware clock masters
+ * This is wrt the codec, the inverse is true for the interface
+ * i.e. if the codec is clk and frm master then the interface is
+ * clk and frame slave.
+ */
+#define SND_SOC_DAIFMT_CBM_CFM (0 << 12) /* codec clk & frm master */
+#define SND_SOC_DAIFMT_CBS_CFM (1 << 12) /* codec clk slave & frm master */
+#define SND_SOC_DAIFMT_CBM_CFS (2 << 12) /* codec clk master & frame slave */
+#define SND_SOC_DAIFMT_CBS_CFS (3 << 12) /* codec clk & frm slave */
+
+#define SND_SOC_DAIFMT_FORMAT_MASK             0x000f
+#define SND_SOC_DAIFMT_CLOCK_MASK              0x00f0
+#define SND_SOC_DAIFMT_INV_MASK                        0x0f00
+#define SND_SOC_DAIFMT_MASTER_MASK             0xf000
+
+
+/*
+ * Master Clock Directions
+ */
+#define SND_SOC_CLOCK_IN       0
+#define SND_SOC_CLOCK_OUT      1
+
+/*
+ * AC97 codec ID's bitmask
+ */
+#define SND_SOC_DAI_AC97_ID0   (1 << 0)
+#define SND_SOC_DAI_AC97_ID1   (1 << 1)
+#define SND_SOC_DAI_AC97_ID2   (1 << 2)
+#define SND_SOC_DAI_AC97_ID3   (1 << 3)
+
+struct snd_soc_device;
+struct snd_soc_pcm_stream;
+struct snd_soc_ops;
+struct snd_soc_dai_mode;
+struct snd_soc_pcm_runtime;
+struct snd_soc_codec_dai;
+struct snd_soc_cpu_dai;
+struct snd_soc_codec;
+struct snd_soc_machine_config;
+struct soc_enum;
+struct snd_soc_ac97_ops;
+struct snd_soc_clock_info;
+
+typedef int (*hw_write_t)(void *,const char* ,int);
+typedef int (*hw_read_t)(void *,char* ,int);
+
+extern struct snd_ac97_bus_ops soc_ac97_ops;
+
+/* pcm <-> DAI connect */
+void snd_soc_free_pcms(struct snd_soc_device *socdev);
+int snd_soc_new_pcms(struct snd_soc_device *socdev, int idx, const char *xid);
+int snd_soc_register_card(struct snd_soc_device *socdev);
+
+/* set runtime hw params */
+int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream,
+       const struct snd_pcm_hardware *hw);
+
+/* codec IO */
+#define snd_soc_read(codec, reg) codec->read(codec, reg)
+#define snd_soc_write(codec, reg, value) codec->write(codec, reg, value)
+
+/* codec register bit access */
+int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg,
+                               unsigned short mask, unsigned short value);
+int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned short reg,
+                               unsigned short mask, unsigned short value);
+
+int snd_soc_new_ac97_codec(struct snd_soc_codec *codec,
+       struct snd_ac97_bus_ops *ops, int num);
+void snd_soc_free_ac97_codec(struct snd_soc_codec *codec);
+
+/*
+ *Controls
+ */
+struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template,
+       void *data, char *long_name);
+int snd_soc_info_enum_double(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_info *uinfo);
+int snd_soc_info_enum_ext(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_info *uinfo);
+int snd_soc_get_enum_double(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_value *ucontrol);
+int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_value *ucontrol);
+int snd_soc_info_volsw(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_info *uinfo);
+int snd_soc_info_volsw_ext(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_info *uinfo);
+int snd_soc_info_bool_ext(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_info *uinfo);
+int snd_soc_get_volsw(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_value *ucontrol);
+int snd_soc_put_volsw(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_value *ucontrol);
+int snd_soc_info_volsw_2r(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_info *uinfo);
+int snd_soc_get_volsw_2r(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_value *ucontrol);
+int snd_soc_put_volsw_2r(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_value *ucontrol);
+
+/* SoC PCM stream information */
+struct snd_soc_pcm_stream {
+       char *stream_name;
+       u64 formats;                    /* SNDRV_PCM_FMTBIT_* */
+       unsigned int rates;             /* SNDRV_PCM_RATE_* */
+       unsigned int rate_min;          /* min rate */
+       unsigned int rate_max;          /* max rate */
+       unsigned int channels_min;      /* min channels */
+       unsigned int channels_max;      /* max channels */
+       unsigned int active:1;          /* stream is in use */
+};
+
+/* SoC audio ops */
+struct snd_soc_ops {
+       int (*startup)(struct snd_pcm_substream *);
+       void (*shutdown)(struct snd_pcm_substream *);
+       int (*hw_params)(struct snd_pcm_substream *, struct snd_pcm_hw_params *);
+       int (*hw_free)(struct snd_pcm_substream *);
+       int (*prepare)(struct snd_pcm_substream *);
+       int (*trigger)(struct snd_pcm_substream *, int);
+};
+
+/* ASoC codec DAI ops */
+struct snd_soc_codec_ops {
+       /* codec DAI clocking configuration */
+       int (*set_sysclk)(struct snd_soc_codec_dai *codec_dai,
+               int clk_id, unsigned int freq, int dir);
+       int (*set_pll)(struct snd_soc_codec_dai *codec_dai,
+               int pll_id, unsigned int freq_in, unsigned int freq_out);
+       int (*set_clkdiv)(struct snd_soc_codec_dai *codec_dai,
+               int div_id, int div);
+
+       /* CPU DAI format configuration */
+       int (*set_fmt)(struct snd_soc_codec_dai *codec_dai,
+               unsigned int fmt);
+       int (*set_tdm_slot)(struct snd_soc_codec_dai *codec_dai,
+               unsigned int mask, int slots);
+       int (*set_tristate)(struct snd_soc_codec_dai *, int tristate);
+
+       /* digital mute */
+       int (*digital_mute)(struct snd_soc_codec_dai *, int mute);
+};
+
+/* ASoC cpu DAI ops */
+struct snd_soc_cpu_ops {
+       /* CPU DAI clocking configuration */
+       int (*set_sysclk)(struct snd_soc_cpu_dai *cpu_dai,
+               int clk_id, unsigned int freq, int dir);
+       int (*set_clkdiv)(struct snd_soc_cpu_dai *cpu_dai,
+               int div_id, int div);
+       int (*set_pll)(struct snd_soc_cpu_dai *cpu_dai,
+               int pll_id, unsigned int freq_in, unsigned int freq_out);
+
+       /* CPU DAI format configuration */
+       int (*set_fmt)(struct snd_soc_cpu_dai *cpu_dai,
+               unsigned int fmt);
+       int (*set_tdm_slot)(struct snd_soc_cpu_dai *cpu_dai,
+               unsigned int mask, int slots);
+       int (*set_tristate)(struct snd_soc_cpu_dai *, int tristate);
+};
+
+/* SoC Codec DAI */
+struct snd_soc_codec_dai {
+       char *name;
+       int id;
+
+       /* DAI capabilities */
+       struct snd_soc_pcm_stream playback;
+       struct snd_soc_pcm_stream capture;
+
+       /* DAI runtime info */
+       struct snd_soc_codec *codec;
+       unsigned int active;
+       unsigned char pop_wait:1;
+
+       /* ops */
+       struct snd_soc_ops ops;
+       struct snd_soc_codec_ops dai_ops;
+
+       /* DAI private data */
+       void *private_data;
+};
+
+/* SoC CPU DAI */
+struct snd_soc_cpu_dai {
+
+       /* DAI description */
+       char *name;
+       unsigned int id;
+       unsigned char type;
+
+       /* DAI callbacks */
+       int (*probe)(struct platform_device *pdev);
+       void (*remove)(struct platform_device *pdev);
+       int (*suspend)(struct platform_device *pdev,
+               struct snd_soc_cpu_dai *cpu_dai);
+       int (*resume)(struct platform_device *pdev,
+               struct snd_soc_cpu_dai *cpu_dai);
+
+       /* ops */
+       struct snd_soc_ops ops;
+       struct snd_soc_cpu_ops dai_ops;
+
+       /* DAI capabilities */
+       struct snd_soc_pcm_stream capture;
+       struct snd_soc_pcm_stream playback;
+
+       /* DAI runtime info */
+       struct snd_pcm_runtime *runtime;
+       unsigned char active:1;
+       void *dma_data;
+
+       /* DAI private data */
+       void *private_data;
+};
+
+/* SoC Audio Codec */
+struct snd_soc_codec {
+       char *name;
+       struct module *owner;
+       struct mutex mutex;
+
+       /* callbacks */
+       int (*dapm_event)(struct snd_soc_codec *codec, int event);
+
+       /* runtime */
+       struct snd_card *card;
+       struct snd_ac97 *ac97;  /* for ad-hoc ac97 devices */
+       unsigned int active;
+       unsigned int pcm_devs;
+       void *private_data;
+
+       /* codec IO */
+       void *control_data; /* codec control (i2c/3wire) data */
+       unsigned int (*read)(struct snd_soc_codec *, unsigned int);
+       int (*write)(struct snd_soc_codec *, unsigned int, unsigned int);
+       hw_write_t hw_write;
+       hw_read_t hw_read;
+       void *reg_cache;
+       short reg_cache_size;
+       short reg_cache_step;
+
+       /* dapm */
+       struct list_head dapm_widgets;
+       struct list_head dapm_paths;
+       unsigned int dapm_state;
+       unsigned int suspend_dapm_state;
+       struct delayed_work delayed_work;
+
+       /* codec DAI's */
+       struct snd_soc_codec_dai *dai;
+       unsigned int num_dai;
+};
+
+/* codec device */
+struct snd_soc_codec_device {
+       int (*probe)(struct platform_device *pdev);
+       int (*remove)(struct platform_device *pdev);
+       int (*suspend)(struct platform_device *pdev, pm_message_t state);
+       int (*resume)(struct platform_device *pdev);
+};
+
+/* SoC platform interface */
+struct snd_soc_platform {
+       char *name;
+
+       int (*probe)(struct platform_device *pdev);
+       int (*remove)(struct platform_device *pdev);
+       int (*suspend)(struct platform_device *pdev,
+               struct snd_soc_cpu_dai *cpu_dai);
+       int (*resume)(struct platform_device *pdev,
+               struct snd_soc_cpu_dai *cpu_dai);
+
+       /* pcm creation and destruction */
+       int (*pcm_new)(struct snd_card *, struct snd_soc_codec_dai *,
+               struct snd_pcm *);
+       void (*pcm_free)(struct snd_pcm *);
+
+       /* platform stream ops */
+       struct snd_pcm_ops *pcm_ops;
+};
+
+/* SoC machine DAI configuration, glues a codec and cpu DAI together */
+struct snd_soc_dai_link  {
+       char *name;                     /* Codec name */
+       char *stream_name;              /* Stream name */
+
+       /* DAI */
+       struct snd_soc_codec_dai *codec_dai;
+       struct snd_soc_cpu_dai *cpu_dai;
+
+       /* machine stream operations */
+       struct snd_soc_ops *ops;
+
+       /* codec/machine specific init - e.g. add machine controls */
+       int (*init)(struct snd_soc_codec *codec);
+};
+
+/* SoC machine */
+struct snd_soc_machine {
+       char *name;
+
+       int (*probe)(struct platform_device *pdev);
+       int (*remove)(struct platform_device *pdev);
+
+       /* the pre and post PM functions are used to do any PM work before and
+        * after the codec and DAI's do any PM work. */
+       int (*suspend_pre)(struct platform_device *pdev, pm_message_t state);
+       int (*suspend_post)(struct platform_device *pdev, pm_message_t state);
+       int (*resume_pre)(struct platform_device *pdev);
+       int (*resume_post)(struct platform_device *pdev);
+
+       /* CPU <--> Codec DAI links  */
+       struct snd_soc_dai_link *dai_link;
+       int num_links;
+};
+
+/* SoC Device - the audio subsystem */
+struct snd_soc_device {
+       struct device *dev;
+       struct snd_soc_machine *machine;
+       struct snd_soc_platform *platform;
+       struct snd_soc_codec *codec;
+       struct snd_soc_codec_device *codec_dev;
+       struct delayed_work delayed_work;
+       void *codec_data;
+};
+
+/* runtime channel data */
+struct snd_soc_pcm_runtime {
+       struct snd_soc_dai_link *dai;
+       struct snd_soc_device *socdev;
+};
+
+/* enumerated kcontrol */
+struct soc_enum {
+       unsigned short reg;
+       unsigned short reg2;
+       unsigned char shift_l;
+       unsigned char shift_r;
+       unsigned int mask;
+       const char **texts;
+       void *dapm;
+};
+
+#endif
diff --git a/include/sound/typedefs.h b/include/sound/typedefs.h
deleted file mode 100644 (file)
index f454b02..0000000
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Typedef's for backward compatibility (for out-of-kernel drivers)
- *
- * This file will be removed soon in future
- */
-
-/* core stuff */
-typedef struct snd_card snd_card_t;
-typedef struct snd_device snd_device_t;
-typedef struct snd_device_ops snd_device_ops_t;
-typedef enum snd_card_type snd_card_type_t;
-typedef struct snd_minor snd_minor_t;
-
-/* info */
-typedef struct snd_info_entry snd_info_entry_t;
-typedef struct snd_info_buffer snd_info_buffer_t;
-
-/* control */
-typedef struct snd_ctl_file snd_ctl_file_t;
-typedef struct snd_kcontrol snd_kcontrol_t;
-typedef struct snd_kcontrol_new snd_kcontrol_new_t;
-typedef struct snd_kcontrol_volatile snd_kcontrol_volatile_t;
-typedef struct snd_kctl_event snd_kctl_event_t;
-typedef struct snd_aes_iec958 snd_aes_iec958_t;
-typedef struct snd_ctl_card_info snd_ctl_card_info_t;
-typedef struct snd_ctl_elem_id snd_ctl_elem_id_t;
-typedef struct snd_ctl_elem_list snd_ctl_elem_list_t;
-typedef struct snd_ctl_elem_info snd_ctl_elem_info_t;
-typedef struct snd_ctl_elem_value snd_ctl_elem_value_t;
-typedef struct snd_ctl_event snd_ctl_event_t;
-#if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE)
-typedef struct snd_mixer_oss snd_mixer_oss_t;
-#endif
-
-/* timer */
-typedef struct snd_timer snd_timer_t;
-typedef struct snd_timer_instance snd_timer_instance_t;
-typedef struct snd_timer_id snd_timer_id_t;
-typedef struct snd_timer_ginfo snd_timer_ginfo_t;
-typedef struct snd_timer_gparams snd_timer_gparams_t;
-typedef struct snd_timer_gstatus snd_timer_gstatus_t;
-typedef struct snd_timer_select snd_timer_select_t;
-typedef struct snd_timer_info snd_timer_info_t;
-typedef struct snd_timer_params snd_timer_params_t;
-typedef struct snd_timer_status snd_timer_status_t;
-typedef struct snd_timer_read snd_timer_read_t;
-typedef struct snd_timer_tread snd_timer_tread_t;
-
-/* PCM */
-typedef struct snd_pcm snd_pcm_t;
-typedef struct snd_pcm_str snd_pcm_str_t;
-typedef struct snd_pcm_substream snd_pcm_substream_t;
-typedef struct snd_pcm_info snd_pcm_info_t;
-typedef struct snd_pcm_hw_params snd_pcm_hw_params_t;
-typedef struct snd_pcm_sw_params snd_pcm_sw_params_t;
-typedef struct snd_pcm_channel_info snd_pcm_channel_info_t;
-typedef struct snd_pcm_status snd_pcm_status_t;
-typedef struct snd_pcm_mmap_status snd_pcm_mmap_status_t;
-typedef struct snd_pcm_mmap_control snd_pcm_mmap_control_t;
-typedef struct snd_mask snd_mask_t;
-typedef struct snd_sg_buf snd_pcm_sgbuf_t;
-
-typedef struct snd_interval snd_interval_t;
-typedef struct snd_xferi snd_xferi_t;
-typedef struct snd_xfern snd_xfern_t;
-typedef struct snd_xferv snd_xferv_t;
-
-typedef struct snd_pcm_file snd_pcm_file_t;
-typedef struct snd_pcm_runtime snd_pcm_runtime_t;
-typedef struct snd_pcm_hardware snd_pcm_hardware_t;
-typedef struct snd_pcm_ops snd_pcm_ops_t;
-typedef struct snd_pcm_hw_rule snd_pcm_hw_rule_t;
-typedef struct snd_pcm_hw_constraints snd_pcm_hw_constraints_t;
-typedef struct snd_ratnum ratnum_t;
-typedef struct snd_ratden ratden_t;
-typedef struct snd_pcm_hw_constraint_ratnums snd_pcm_hw_constraint_ratnums_t;
-typedef struct snd_pcm_hw_constraint_ratdens snd_pcm_hw_constraint_ratdens_t;
-typedef struct snd_pcm_hw_constraint_list snd_pcm_hw_constraint_list_t;
-typedef struct snd_pcm_group snd_pcm_group_t;
-typedef struct snd_pcm_notify snd_pcm_notify_t;
-
-/* rawmidi */
-typedef struct snd_rawmidi snd_rawmidi_t;
-typedef struct snd_rawmidi_info snd_rawmidi_info_t;
-typedef struct snd_rawmidi_params snd_rawmidi_params_t;
-typedef struct snd_rawmidi_status snd_rawmidi_status_t;
-typedef struct snd_rawmidi_runtime snd_rawmidi_runtime_t;
-typedef struct snd_rawmidi_substream snd_rawmidi_substream_t;
-typedef struct snd_rawmidi_str snd_rawmidi_str_t;
-typedef struct snd_rawmidi_ops snd_rawmidi_ops_t;
-typedef struct snd_rawmidi_global_ops snd_rawmidi_global_ops_t;
-typedef struct snd_rawmidi_file snd_rawmidi_file_t;
-
-/* hwdep */
-typedef struct snd_hwdep snd_hwdep_t;
-typedef struct snd_hwdep_info snd_hwdep_info_t;
-typedef struct snd_hwdep_dsp_status snd_hwdep_dsp_status_t;
-typedef struct snd_hwdep_dsp_image snd_hwdep_dsp_image_t;
-typedef struct snd_hwdep_ops snd_hwdep_ops_t;
-
-/* sequencer */
-typedef struct snd_seq_port_info snd_seq_port_info_t;
-typedef struct snd_seq_port_subscribe snd_seq_port_subscribe_t;
-typedef struct snd_seq_event snd_seq_event_t;
-typedef struct snd_seq_addr snd_seq_addr_t;
-typedef struct snd_seq_ev_volume snd_seq_ev_volume_t;
-typedef struct snd_seq_ev_loop snd_seq_ev_loop_t;
-typedef struct snd_seq_remove_events snd_seq_remove_events_t;
-typedef struct snd_seq_query_subs snd_seq_query_subs_t;
-typedef struct snd_seq_system_info snd_seq_system_info_t;
-typedef struct snd_seq_client_info snd_seq_client_info_t;
-typedef struct snd_seq_queue_info snd_seq_queue_info_t;
-typedef struct snd_seq_queue_status snd_seq_queue_status_t;
-typedef struct snd_seq_queue_tempo snd_seq_queue_tempo_t;
-typedef struct snd_seq_queue_owner snd_seq_queue_owner_t;
-typedef struct snd_seq_queue_timer snd_seq_queue_timer_t;
-typedef struct snd_seq_queue_client snd_seq_queue_client_t;
-typedef struct snd_seq_client_pool snd_seq_client_pool_t;
-typedef struct snd_seq_instr snd_seq_instr_t;
-typedef struct snd_seq_instr_data snd_seq_instr_data_t;
-typedef struct snd_seq_instr_header snd_seq_instr_header_t;
-
-typedef struct snd_seq_user_client user_client_t;
-typedef struct snd_seq_kernel_client kernel_client_t;
-typedef struct snd_seq_client client_t;
-typedef struct snd_seq_queue queue_t;
-
-/* seq_device */
-typedef struct snd_seq_device snd_seq_device_t;
-typedef struct snd_seq_dev_ops snd_seq_dev_ops_t;
-
-/* seq_midi */
-typedef struct snd_midi_event snd_midi_event_t;
-
-/* seq_midi_emul */
-typedef struct snd_midi_channel snd_midi_channel_t;
-typedef struct snd_midi_channel_set snd_midi_channel_set_t;
-typedef struct snd_midi_op snd_midi_op_t;
-
-/* seq_oss */
-typedef struct snd_seq_oss_arg snd_seq_oss_arg_t;
-typedef struct snd_seq_oss_callback snd_seq_oss_callback_t;
-typedef struct snd_seq_oss_reg snd_seq_oss_reg_t;
-
-/* virmidi */
-typedef struct snd_virmidi_dev snd_virmidi_dev_t;
-typedef struct snd_virmidi snd_virmidi_t;
-
-/* seq_instr */
-typedef struct snd_seq_kcluster snd_seq_kcluster_t;
-typedef struct snd_seq_kinstr_ops snd_seq_kinstr_ops_t;
-typedef struct snd_seq_kinstr snd_seq_kinstr_t;
-typedef struct snd_seq_kinstr_list snd_seq_kinstr_list_t;
-
-/* ac97 */
-typedef struct snd_ac97_bus ac97_bus_t;
-typedef struct snd_ac97_bus_ops ac97_bus_ops_t;
-typedef struct snd_ac97_template ac97_template_t;
-typedef struct snd_ac97 ac97_t;
-
-/* opl3/4 */
-typedef struct snd_opl3 opl3_t;
-typedef struct snd_opl4 opl4_t;
-
-/* mpu401 */
-typedef struct snd_mpu401 mpu401_t;
-
-/* i2c */
-typedef struct snd_i2c_device snd_i2c_device_t;
-typedef struct snd_i2c_bus snd_i2c_bus_t;
-
-typedef struct snd_ak4531 ak4531_t;
-
index 20f7babad514109312bf46a3aada728d80af2e27..c39b3802cf18afbb43637a516663c589b11b3b03 100644 (file)
@@ -1,3 +1,3 @@
 /* include/version.h.  Generated by alsa/ksync script.  */
-#define CONFIG_SND_VERSION "1.0.14rc1"
-#define CONFIG_SND_DATE " (Tue Jan 09 09:56:17 2007 UTC)"
+#define CONFIG_SND_VERSION "1.0.14rc2"
+#define CONFIG_SND_DATE " (Fri Feb 09 13:50:10 2007 UTC)"
index 217394652090d5853d2be332651a20673d33860c..4830651cc4cffd5dfafc1c29c5d5fd00c905ecac 100644 (file)
@@ -128,7 +128,7 @@ struct snd_vx_hardware {
        unsigned int num_ins;
        unsigned int num_outs;
        unsigned int output_level_max;
-       unsigned int *output_level_db_scale;
+       const unsigned int *output_level_db_scale;
 };
 
 /* hwdep id string */
index f3514ee96bd9753f64782d89fe978e16c8bd8261..203d2b45b7889d2b55811150a09dd39250a2ffee 100644 (file)
@@ -270,6 +270,7 @@ struct snd_ymfpci_pcm {
        struct snd_pcm_substream *substream;
        struct snd_ymfpci_voice *voices[2];     /* playback only */
        unsigned int running: 1,
+                    use_441_slot: 1,
                     output_front: 1,
                     output_rear: 1,
                     swap_rear: 1;
@@ -324,6 +325,7 @@ struct snd_ymfpci {
 
        u32 active_bank;
        struct snd_ymfpci_voice voices[64];
+       int src441_used;
 
        struct snd_ac97_bus *ac97_bus;
        struct snd_ac97 *ac97;
@@ -346,7 +348,7 @@ struct snd_ymfpci {
        int mode_dup4ch;
        int rear_opened;
        int spdif_opened;
-       struct {
+       struct snd_ymfpci_pcm_mixer {
                u16 left;
                u16 right;
                struct snd_kcontrol *ctl;
@@ -357,6 +359,8 @@ struct snd_ymfpci {
        wait_queue_head_t interrupt_sleep;
        atomic_t interrupt_sleep_count;
        struct snd_info_entry *proc_entry;
+       const struct firmware *dsp_microcode;
+       const struct firmware *controller_microcode;
 
 #ifdef CONFIG_PM
        u32 *saved_regs;
index a3f83e2c8250bf6ebf0a8429ed707a270531f769..ad33c979e0b32d3e2f2c1a21bc641003b02ad1fd 100644 (file)
@@ -192,6 +192,24 @@ config TASK_DELAY_ACCT
 
          Say N if unsure.
 
+config TASK_XACCT
+       bool "Enable extended accounting over taskstats (EXPERIMENTAL)"
+       depends on TASKSTATS
+       help
+         Collect extended task accounting data and send the data
+         to userland for processing over the taskstats interface.
+
+         Say N if unsure.
+
+config TASK_IO_ACCOUNTING
+       bool "Enable per-task storage I/O accounting (EXPERIMENTAL)"
+       depends on TASK_XACCT
+       help
+         Collect information on the number of bytes of storage I/O which this
+         task has caused.
+
+         Say N if unsure.
+
 config UTS_NS
        bool "UTS Namespaces"
        default n
@@ -280,8 +298,12 @@ config RELAY
 
          If unsure, say N.
 
+if BLK_DEV_INITRD
+
 source "usr/Kconfig"
 
+endif
+
 config CC_OPTIMIZE_FOR_SIZE
        bool "Optimize for size (Look out for broken compilers!)"
        default y
@@ -295,24 +317,6 @@ config CC_OPTIMIZE_FOR_SIZE
 
          If unsure, say N.
 
-config TASK_XACCT
-       bool "Enable extended accounting over taskstats (EXPERIMENTAL)"
-       depends on TASKSTATS
-       help
-         Collect extended task accounting data and send the data
-         to userland for processing over the taskstats interface.
-
-         Say N if unsure.
-
-config TASK_IO_ACCOUNTING
-       bool "Enable per-task storage I/O accounting (EXPERIMENTAL)"
-       depends on TASK_XACCT
-       help
-         Collect information on the number of bytes of storage I/O which this
-         task has caused.
-
-         Say N if unsure.
-
 config SYSCTL
        bool
 
index 633a268d270d3cc8bfa906c1a22476caa9645360..0154aea1e52d874814c05cb2a9c83d83bc48af71 100644 (file)
@@ -2,7 +2,12 @@
 # Makefile for the linux kernel.
 #
 
-obj-y                          := main.o version.o mounts.o initramfs.o
+obj-y                          := main.o version.o mounts.o
+ifneq ($(CONFIG_BLK_DEV_INITRD),y)
+obj-y                          += noinitramfs.o
+else
+obj-$(CONFIG_BLK_DEV_INITRD)   += initramfs.o
+endif
 obj-$(CONFIG_GENERIC_CALIBRATE_DELAY) += calibrate.o
 
 mounts-y                       := do_mounts.o
index 4fa0f7977de1a16db501d91c3c9b062cb7898c2d..00eff7a110854d5706ff51205f5ef06a7a267d27 100644 (file)
@@ -491,6 +491,17 @@ static char * __init unpack_to_rootfs(char *buf, unsigned len, int check_only)
        return message;
 }
 
+static int __initdata do_retain_initrd;
+
+static int __init retain_initrd_param(char *str)
+{
+       if (*str)
+               return 0;
+       do_retain_initrd = 1;
+       return 1;
+}
+__setup("retain_initrd", retain_initrd_param);
+
 extern char __initramfs_start[], __initramfs_end[];
 #ifdef CONFIG_BLK_DEV_INITRD
 #include <linux/initrd.h>
@@ -501,7 +512,11 @@ static void __init free_initrd(void)
 #ifdef CONFIG_KEXEC
        unsigned long crashk_start = (unsigned long)__va(crashk_res.start);
        unsigned long crashk_end   = (unsigned long)__va(crashk_res.end);
+#endif
+       if (do_retain_initrd)
+               goto skip;
 
+#ifdef CONFIG_KEXEC
        /*
         * If the initrd region is overlapped with crashkernel reserved region,
         * free only memory that is not part of crashkernel region.
@@ -519,7 +534,7 @@ static void __init free_initrd(void)
        } else
 #endif
                free_initrd_mem(initrd_start, initrd_end);
-
+skip:
        initrd_start = 0;
        initrd_end = 0;
 }
index 8b4a7d76916235df139b98bd41019a228615a2dd..4e88bddfbebfd03fe5fb6359179b8ef690c750f7 100644 (file)
@@ -395,11 +395,6 @@ static void __init smp_init(void)
        /* Any cleanup work */
        printk(KERN_INFO "Brought up %ld CPUs\n", (long)num_online_cpus());
        smp_cpus_done(max_cpus);
-#if 0
-       /* Get other processors into their bootup holding patterns. */
-
-       smp_commence();
-#endif
 }
 
 #endif
diff --git a/init/noinitramfs.c b/init/noinitramfs.c
new file mode 100644 (file)
index 0000000..f4c1a3a
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * init/noinitramfs.c
+ *
+ * Copyright (C) 2006, NXP Semiconductors, All Rights Reserved
+ * Author: Jean-Paul Saman <jean-paul.saman@nxp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#include <linux/init.h>
+#include <linux/stat.h>
+#include <linux/kdev_t.h>
+#include <linux/syscalls.h>
+
+/*
+ * Create a simple rootfs that is similar to the default initramfs
+ */
+static int __init default_rootfs(void)
+{
+       int err;
+
+       err = sys_mkdir("/dev", 0755);
+       if (err < 0)
+               goto out;
+
+       err = sys_mknod((const char __user *) "/dev/console",
+                       S_IFCHR | S_IRUSR | S_IWUSR,
+                       new_encode_dev(MKDEV(5, 1)));
+       if (err < 0)
+               goto out;
+
+       err = sys_mkdir("/root", 0700);
+       if (err < 0)
+               goto out;
+
+       return 0;
+
+out:
+       printk(KERN_WARNING "Failed to create a rootfs\n");
+       return err;
+}
+rootfs_initcall(default_rootfs);
index a9b7a227b8d4c7bde79998048206b96fef1f57ed..0c97cb746160980733569830b1944451f9d33a22 100644 (file)
@@ -150,7 +150,7 @@ void free_ipc_ns(struct kref *kref)
  *     ipc_init        -       initialise IPC subsystem
  *
  *     The various system5 IPC resources (semaphores, messages and shared
- *     memory are initialised
+ *     memory) are initialised
  */
  
 static int __init ipc_init(void)
@@ -207,8 +207,7 @@ void __ipc_init ipc_init_ids(struct ipc_ids* ids, int size)
 #ifdef CONFIG_PROC_FS
 static struct file_operations sysvipc_proc_fops;
 /**
- *     ipc_init_proc_interface -  Create a proc interface for sysipc types
- *                                using a seq_file interface.
+ *     ipc_init_proc_interface -  Create a proc interface for sysipc types using a seq_file interface.
  *     @path: Path in procfs
  *     @header: Banner to be printed at the beginning of the file.
  *     @ids: ipc id table to iterate.
@@ -417,7 +416,7 @@ void* ipc_alloc(int size)
  *     @ptr: pointer returned by ipc_alloc
  *     @size: size of block
  *
- *     Free a block created with ipc_alloc. The caller must know the size
+ *     Free a block created with ipc_alloc(). The caller must know the size
  *     used in the allocation call.
  */
 
@@ -524,7 +523,7 @@ static void ipc_do_vfree(struct work_struct *work)
  * @head: RCU callback structure for queued work
  * 
  * Since RCU callback function is called in bh,
- * we need to defer the vfree to schedule_work
+ * we need to defer the vfree to schedule_work().
  */
 static void ipc_schedule_free(struct rcu_head *head)
 {
@@ -541,7 +540,7 @@ static void ipc_schedule_free(struct rcu_head *head)
  * ipc_immediate_free - free ipc + rcu space
  * @head: RCU callback structure that contains pointer to be freed
  *
- * Free from the RCU callback context
+ * Free from the RCU callback context.
  */
 static void ipc_immediate_free(struct rcu_head *head)
 {
@@ -603,8 +602,8 @@ int ipcperms (struct kern_ipc_perm *ipcp, short flag)
  *     @in: kernel permissions
  *     @out: new style IPC permissions
  *
- *     Turn the kernel object 'in' into a set of permissions descriptions
- *     for returning to userspace (out).
+ *     Turn the kernel object @in into a set of permissions descriptions
+ *     for returning to userspace (@out).
  */
  
 
@@ -624,8 +623,8 @@ void kernel_to_ipc64_perm (struct kern_ipc_perm *in, struct ipc64_perm *out)
  *     @in: new style IPC permissions
  *     @out: old style IPC permissions
  *
- *     Turn the new style permissions object in into a compatibility
- *     object and store it into the 'out' pointer.
+ *     Turn the new style permissions object @in into a compatibility
+ *     object and store it into the @out pointer.
  */
  
 void ipc64_perm_to_ipc_perm (struct ipc64_perm *in, struct ipc_perm *out)
@@ -722,7 +721,7 @@ int ipc_checkid(struct ipc_ids* ids, struct kern_ipc_perm* ipcp, int uid)
  *     @cmd: pointer to command
  *
  *     Return IPC_64 for new style IPC and IPC_OLD for old style IPC. 
- *     The cmd value is turned from an encoding command and version into
+ *     The @cmd value is turned from an encoding command and version into
  *     just the command code.
  */
  
index 9c8c23227c7f28970f64de6e21cab6e8bfa08415..87865f8b4ce3ecdebad12707c6867a302bedee69 100644 (file)
@@ -1601,8 +1601,8 @@ static int audit_filter_user_rules(struct netlink_skb_parms *cb,
 
 int audit_filter_user(struct netlink_skb_parms *cb, int type)
 {
+       enum audit_state state = AUDIT_DISABLED;
        struct audit_entry *e;
-       enum audit_state   state;
        int ret = 1;
 
        rcu_read_lock();
index 6952dd057300f637e68a059ba1f299d8464ae9f8..cebb4c28c039b0cd9ad14592557d324b0ffac899 100644 (file)
@@ -1016,3 +1016,69 @@ asmlinkage long compat_sys_migrate_pages(compat_pid_t pid,
        return sys_migrate_pages(pid, nr_bits + 1, old, new);
 }
 #endif
+
+struct compat_sysinfo {
+       s32 uptime;
+       u32 loads[3];
+       u32 totalram;
+       u32 freeram;
+       u32 sharedram;
+       u32 bufferram;
+       u32 totalswap;
+       u32 freeswap;
+       u16 procs;
+       u16 pad;
+       u32 totalhigh;
+       u32 freehigh;
+       u32 mem_unit;
+       char _f[20-2*sizeof(u32)-sizeof(int)];
+};
+
+asmlinkage long
+compat_sys_sysinfo(struct compat_sysinfo __user *info)
+{
+       struct sysinfo s;
+
+       do_sysinfo(&s);
+
+       /* Check to see if any memory value is too large for 32-bit and scale
+        *  down if needed
+        */
+       if ((s.totalram >> 32) || (s.totalswap >> 32)) {
+               int bitcount = 0;
+
+               while (s.mem_unit < PAGE_SIZE) {
+                       s.mem_unit <<= 1;
+                       bitcount++;
+               }
+
+               s.totalram >>= bitcount;
+               s.freeram >>= bitcount;
+               s.sharedram >>= bitcount;
+               s.bufferram >>= bitcount;
+               s.totalswap >>= bitcount;
+               s.freeswap >>= bitcount;
+               s.totalhigh >>= bitcount;
+               s.freehigh >>= bitcount;
+       }
+
+       if (!access_ok(VERIFY_WRITE, info, sizeof(struct compat_sysinfo)) ||
+           __put_user (s.uptime, &info->uptime) ||
+           __put_user (s.loads[0], &info->loads[0]) ||
+           __put_user (s.loads[1], &info->loads[1]) ||
+           __put_user (s.loads[2], &info->loads[2]) ||
+           __put_user (s.totalram, &info->totalram) ||
+           __put_user (s.freeram, &info->freeram) ||
+           __put_user (s.sharedram, &info->sharedram) ||
+           __put_user (s.bufferram, &info->bufferram) ||
+           __put_user (s.totalswap, &info->totalswap) ||
+           __put_user (s.freeswap, &info->freeswap) ||
+           __put_user (s.procs, &info->procs) ||
+           __put_user (s.totalhigh, &info->totalhigh) ||
+           __put_user (s.freehigh, &info->freehigh) ||
+           __put_user (s.mem_unit, &info->mem_unit))
+               return -EFAULT;
+
+       return 0;
+}
+
index 7406fe6966f908cb547fba3de5fcf5d566f831ea..3d4206ada5c9d970c0806348a75424f30f7adbac 100644 (file)
@@ -309,6 +309,8 @@ void enable_nonboot_cpus(void)
        mutex_lock(&cpu_add_remove_lock);
        cpu_hotplug_disabled = 0;
        mutex_unlock(&cpu_add_remove_lock);
+       if (cpus_empty(frozen_cpus))
+               return;
 
        printk("Enabling non-boot CPUs ...\n");
        for_each_cpu_mask(cpu, frozen_cpus) {
index fec12eb124716f7e05e2564f241beef2049834cb..bc71fdfcd8a78d4a6b0f466b11f55cb8354bacdd 100644 (file)
@@ -257,8 +257,7 @@ static int has_stopped_jobs(int pgrp)
 }
 
 /**
- * reparent_to_init - Reparent the calling kernel thread to the init task
- * of the pid space that the thread belongs to.
+ * reparent_to_init - Reparent the calling kernel thread to the init task of the pid space that the thread belongs to.
  *
  * If a kernel thread is launched as a result of a system call, or if
  * it ever exits, it should generally reparent itself to init so that
index d57118da73ff04cfecc4b09b689c7bf74191dcc6..80284eb488ced61808dedf0b999af2f55c494d28 100644 (file)
@@ -1038,10 +1038,12 @@ static struct task_struct *copy_process(unsigned long clone_flags,
        p->utime = cputime_zero;
        p->stime = cputime_zero;
        p->sched_time = 0;
+#ifdef CONFIG_TASK_XACCT
        p->rchar = 0;           /* I/O counter: bytes read */
        p->wchar = 0;           /* I/O counter: bytes written */
        p->syscr = 0;           /* I/O counter: read syscalls */
        p->syscw = 0;           /* I/O counter: write syscalls */
+#endif
        task_io_accounting_init(p);
        acct_clear_integrals(p);
 
index d0ba190dfeb6b9ae81c98f135515b19a145f8206..f44e499e8fcab4130bfa1a77558aabaf24458fe2 100644 (file)
@@ -102,7 +102,7 @@ static DEFINE_PER_CPU(struct hrtimer_base, hrtimer_bases[MAX_HRTIMER_BASES]) =
  *
  * The function calculates the monotonic clock from the realtime
  * clock and the wall_to_monotonic offset and stores the result
- * in normalized timespec format in the variable pointed to by ts.
+ * in normalized timespec format in the variable pointed to by @ts.
  */
 void ktime_get_ts(struct timespec *ts)
 {
@@ -583,8 +583,8 @@ EXPORT_SYMBOL_GPL(hrtimer_init);
  * @which_clock: which clock to query
  * @tp:                 pointer to timespec variable to store the resolution
  *
- * Store the resolution of the clock selected by which_clock in the
- * variable pointed to by tp.
+ * Store the resolution of the clock selected by @which_clock in the
+ * variable pointed to by @tp.
  */
 int hrtimer_get_res(const clockid_t which_clock, struct timespec *tp)
 {
index 1dab0ac3f79782a129dc5736ac8d838ee9d4ba01..681c52dbfe229bbffc32db74c395f3f149738ed4 100644 (file)
@@ -1,5 +1,5 @@
 
-obj-y := handle.o manage.o spurious.o resend.o chip.o
+obj-y := handle.o manage.o spurious.o resend.o chip.o devres.o
 obj-$(CONFIG_GENERIC_IRQ_PROBE) += autoprobe.o
 obj-$(CONFIG_PROC_FS) += proc.o
 obj-$(CONFIG_GENERIC_PENDING_IRQ) += migration.o
diff --git a/kernel/irq/devres.c b/kernel/irq/devres.c
new file mode 100644 (file)
index 0000000..85a430d
--- /dev/null
@@ -0,0 +1,88 @@
+#include <linux/module.h>
+#include <linux/interrupt.h>
+
+/*
+ * Device resource management aware IRQ request/free implementation.
+ */
+struct irq_devres {
+       unsigned int irq;
+       void *dev_id;
+};
+
+static void devm_irq_release(struct device *dev, void *res)
+{
+       struct irq_devres *this = res;
+
+       free_irq(this->irq, this->dev_id);
+}
+
+static int devm_irq_match(struct device *dev, void *res, void *data)
+{
+       struct irq_devres *this = res, *match = data;
+
+       return this->irq == match->irq && this->dev_id == match->dev_id;
+}
+
+/**
+ *     devm_request_irq - allocate an interrupt line for a managed device
+ *     @dev: device to request interrupt for
+ *     @irq: Interrupt line to allocate
+ *     @handler: Function to be called when the IRQ occurs
+ *     @irqflags: Interrupt type flags
+ *     @devname: An ascii name for the claiming device
+ *     @dev_id: A cookie passed back to the handler function
+ *
+ *     Except for the extra @dev argument, this function takes the
+ *     same arguments and performs the same function as
+ *     request_irq().  IRQs requested with this function will be
+ *     automatically freed on driver detach.
+ *
+ *     If an IRQ allocated with this function needs to be freed
+ *     separately, dev_free_irq() must be used.
+ */
+int devm_request_irq(struct device *dev, unsigned int irq,
+                    irq_handler_t handler, unsigned long irqflags,
+                    const char *devname, void *dev_id)
+{
+       struct irq_devres *dr;
+       int rc;
+
+       dr = devres_alloc(devm_irq_release, sizeof(struct irq_devres),
+                         GFP_KERNEL);
+       if (!dr)
+               return -ENOMEM;
+
+       rc = request_irq(irq, handler, irqflags, devname, dev_id);
+       if (rc) {
+               kfree(dr);
+               return rc;
+       }
+
+       dr->irq = irq;
+       dr->dev_id = dev_id;
+       devres_add(dev, dr);
+
+       return 0;
+}
+EXPORT_SYMBOL(devm_request_irq);
+
+/**
+ *     devm_free_irq - free an interrupt
+ *     @dev: device to free interrupt for
+ *     @irq: Interrupt line to free
+ *     @dev_id: Device identity to free
+ *
+ *     Except for the extra @dev argument, this function takes the
+ *     same arguments and performs the same function as free_irq().
+ *     This function instead of free_irq() should be used to manually
+ *     free IRQs allocated with dev_request_irq().
+ */
+void devm_free_irq(struct device *dev, unsigned int irq, void *dev_id)
+{
+       struct irq_devres match_data = { irq, dev_id };
+
+       free_irq(irq, dev_id);
+       WARN_ON(devres_destroy(dev, devm_irq_release, devm_irq_match,
+                              &match_data));
+}
+EXPORT_SYMBOL(devm_free_irq);
index 61f5c717a8f579cbe5dd3c9b3991b7ef2fb5cead..6d3be06e8ce6362d2f2e106452c9c5383ebc6cfc 100644 (file)
@@ -136,7 +136,6 @@ void register_irq_proc(unsigned int irq)
                entry = create_proc_entry("smp_affinity", 0600, irq_desc[irq].dir);
 
                if (entry) {
-                       entry->nlink = 1;
                        entry->data = (void *)(long)irq;
                        entry->read_proc = irq_affinity_read_proc;
                        entry->write_proc = irq_affinity_write_proc;
index 5d1d907378a299ad6c6aab16b15d55d1248f296e..cee419143fd47bb410b0cf80e7762a0f02ffbfce 100644 (file)
@@ -32,8 +32,8 @@
  * @gfp_mask: get_free_pages mask, passed to kmalloc()
  * @lock: the lock to be used to protect the fifo buffer
  *
- * Do NOT pass the kfifo to kfifo_free() after use ! Simply free the
- * struct kfifo with kfree().
+ * Do NOT pass the kfifo to kfifo_free() after use! Simply free the
+ * &struct kfifo with kfree().
  */
 struct kfifo *kfifo_init(unsigned char *buffer, unsigned int size,
                         gfp_t gfp_mask, spinlock_t *lock)
@@ -108,7 +108,7 @@ EXPORT_SYMBOL(kfifo_free);
  * @buffer: the data to be added.
  * @len: the length of the data to be added.
  *
- * This function copies at most 'len' bytes from the 'buffer' into
+ * This function copies at most @len bytes from the @buffer into
  * the FIFO depending on the free space, and returns the number of
  * bytes copied.
  *
@@ -155,8 +155,8 @@ EXPORT_SYMBOL(__kfifo_put);
  * @buffer: where the data must be copied.
  * @len: the size of the destination buffer.
  *
- * This function copies at most 'len' bytes from the FIFO into the
- * 'buffer' and returns the number of copied bytes.
+ * This function copies at most @len bytes from the FIFO into the
+ * @buffer and returns the number of copied bytes.
  *
  * Note that with only one concurrent reader and one concurrent
  * writer, you don't need extra locking to use these functions.
index 1db8c72d0d380c637b18e3951df45f32291ceeda..87c50ccd1d4e93850373d23c8d96b46a93cc0688 100644 (file)
@@ -50,7 +50,7 @@ static struct kthread_stop_info kthread_stop_info;
 /**
  * kthread_should_stop - should this kthread return now?
  *
- * When someone calls kthread_stop on your kthread, it will be woken
+ * When someone calls kthread_stop() on your kthread, it will be woken
  * and this will return true.  You should then return, and your return
  * value will be passed through to kthread_stop().
  */
@@ -143,7 +143,7 @@ static void keventd_create_kthread(struct work_struct *work)
  * it.  See also kthread_run(), kthread_create_on_cpu().
  *
  * When woken, the thread will run @threadfn() with @data as its
- * argument. @threadfn can either call do_exit() directly if it is a
+ * argument. @threadfn() can either call do_exit() directly if it is a
  * standalone thread for which noone will call kthread_stop(), or
  * return when 'kthread_should_stop()' is true (which means
  * kthread_stop() has been called).  The return value should be zero
@@ -192,7 +192,7 @@ EXPORT_SYMBOL(kthread_create);
  *
  * Description: This function is equivalent to set_cpus_allowed(),
  * except that @cpu doesn't need to be online, and the thread must be
- * stopped (i.e., just returned from kthread_create().
+ * stopped (i.e., just returned from kthread_create()).
  */
 void kthread_bind(struct task_struct *k, unsigned int cpu)
 {
index 509efd49540f9beb09ddf347725690f939e09aa2..592c576d77a7c325cb4edfa4d496f244764b5ae5 100644 (file)
@@ -70,6 +70,9 @@ static int graph_lock(void)
 
 static inline int graph_unlock(void)
 {
+       if (debug_locks && !__raw_spin_is_locked(&lockdep_lock))
+               return DEBUG_LOCKS_WARN_ON(1);
+
        __raw_spin_unlock(&lockdep_lock);
        return 0;
 }
@@ -487,7 +490,7 @@ static void print_lock_dependencies(struct lock_class *class, int depth)
  * Add a new dependency to the head of the list:
  */
 static int add_lock_to_list(struct lock_class *class, struct lock_class *this,
-                           struct list_head *head, unsigned long ip)
+                           struct list_head *head, unsigned long ip, int distance)
 {
        struct lock_list *entry;
        /*
@@ -499,6 +502,7 @@ static int add_lock_to_list(struct lock_class *class, struct lock_class *this,
                return 0;
 
        entry->class = this;
+       entry->distance = distance;
        if (!save_trace(&entry->trace))
                return 0;
 
@@ -712,6 +716,9 @@ find_usage_backwards(struct lock_class *source, unsigned int depth)
        struct lock_list *entry;
        int ret;
 
+       if (!__raw_spin_is_locked(&lockdep_lock))
+               return DEBUG_LOCKS_WARN_ON(1);
+
        if (depth > max_recursion_depth)
                max_recursion_depth = depth;
        if (depth >= RECURSION_LIMIT)
@@ -900,7 +907,7 @@ check_deadlock(struct task_struct *curr, struct held_lock *next,
  */
 static int
 check_prev_add(struct task_struct *curr, struct held_lock *prev,
-              struct held_lock *next)
+              struct held_lock *next, int distance)
 {
        struct lock_list *entry;
        int ret;
@@ -978,8 +985,11 @@ check_prev_add(struct task_struct *curr, struct held_lock *prev,
         *  L2 added to its dependency list, due to the first chain.)
         */
        list_for_each_entry(entry, &prev->class->locks_after, entry) {
-               if (entry->class == next->class)
+               if (entry->class == next->class) {
+                       if (distance == 1)
+                               entry->distance = 1;
                        return 2;
+               }
        }
 
        /*
@@ -987,12 +997,13 @@ check_prev_add(struct task_struct *curr, struct held_lock *prev,
         * to the previous lock's dependency list:
         */
        ret = add_lock_to_list(prev->class, next->class,
-                              &prev->class->locks_after, next->acquire_ip);
+                              &prev->class->locks_after, next->acquire_ip, distance);
+
        if (!ret)
                return 0;
 
        ret = add_lock_to_list(next->class, prev->class,
-                              &next->class->locks_before, next->acquire_ip);
+                              &next->class->locks_before, next->acquire_ip, distance);
        if (!ret)
                return 0;
 
@@ -1040,13 +1051,14 @@ check_prevs_add(struct task_struct *curr, struct held_lock *next)
                goto out_bug;
 
        for (;;) {
+               int distance = curr->lockdep_depth - depth + 1;
                hlock = curr->held_locks + depth-1;
                /*
                 * Only non-recursive-read entries get new dependencies
                 * added:
                 */
                if (hlock->read != 2) {
-                       if (!check_prev_add(curr, hlock, next))
+                       if (!check_prev_add(curr, hlock, next, distance))
                                return 0;
                        /*
                         * Stop after the first non-trylock entry,
@@ -1293,7 +1305,8 @@ out_unlock_set:
        if (!subclass || force)
                lock->class_cache = class;
 
-       DEBUG_LOCKS_WARN_ON(class->subclass != subclass);
+       if (DEBUG_LOCKS_WARN_ON(class->subclass != subclass))
+               return NULL;
 
        return class;
 }
@@ -1308,7 +1321,8 @@ static inline int lookup_chain_cache(u64 chain_key, struct lock_class *class)
        struct list_head *hash_head = chainhashentry(chain_key);
        struct lock_chain *chain;
 
-       DEBUG_LOCKS_WARN_ON(!irqs_disabled());
+       if (DEBUG_LOCKS_WARN_ON(!irqs_disabled()))
+               return 0;
        /*
         * We can walk it lock-free, because entries only get added
         * to the hash:
@@ -1394,7 +1408,9 @@ static void check_chain_key(struct task_struct *curr)
                        return;
                }
                id = hlock->class - lock_classes;
-               DEBUG_LOCKS_WARN_ON(id >= MAX_LOCKDEP_KEYS);
+               if (DEBUG_LOCKS_WARN_ON(id >= MAX_LOCKDEP_KEYS))
+                       return;
+
                if (prev_hlock && (prev_hlock->irq_context !=
                                                        hlock->irq_context))
                        chain_key = 0;
@@ -2205,7 +2221,11 @@ out_calc_hash:
                        if (!check_prevs_add(curr, hlock))
                                return 0;
                graph_unlock();
-       }
+       } else
+               /* after lookup_chain_cache(): */
+               if (unlikely(!debug_locks))
+                       return 0;
+
        curr->lockdep_depth++;
        check_chain_key(curr);
        if (unlikely(curr->lockdep_depth >= MAX_LOCK_DEPTH)) {
@@ -2214,6 +2234,7 @@ out_calc_hash:
                printk("turning off the locking correctness validator.\n");
                return 0;
        }
+
        if (unlikely(curr->lockdep_depth > max_lockdep_depth))
                max_lockdep_depth = curr->lockdep_depth;
 
@@ -2764,4 +2785,3 @@ void debug_show_held_locks(struct task_struct *task)
 }
 
 EXPORT_SYMBOL_GPL(debug_show_held_locks);
-
index b554b40a4aa6ca1872f7225a47bc2829300e24b5..88fc611b3ae907a3677a2549b4c809f187729b8c 100644 (file)
@@ -77,12 +77,29 @@ static unsigned long count_backward_deps(struct lock_class *class)
        return ret;
 }
 
+static void print_name(struct seq_file *m, struct lock_class *class)
+{
+       char str[128];
+       const char *name = class->name;
+
+       if (!name) {
+               name = __get_key_name(class->key, str);
+               seq_printf(m, "%s", name);
+       } else{
+               seq_printf(m, "%s", name);
+               if (class->name_version > 1)
+                       seq_printf(m, "#%d", class->name_version);
+               if (class->subclass)
+                       seq_printf(m, "/%d", class->subclass);
+       }
+}
+
 static int l_show(struct seq_file *m, void *v)
 {
        unsigned long nr_forward_deps, nr_backward_deps;
        struct lock_class *class = m->private;
-       char str[128], c1, c2, c3, c4;
-       const char *name;
+       struct lock_list *entry;
+       char c1, c2, c3, c4;
 
        seq_printf(m, "%p", class->key);
 #ifdef CONFIG_DEBUG_LOCKDEP
@@ -97,16 +114,16 @@ static int l_show(struct seq_file *m, void *v)
        get_usage_chars(class, &c1, &c2, &c3, &c4);
        seq_printf(m, " %c%c%c%c", c1, c2, c3, c4);
 
-       name = class->name;
-       if (!name) {
-               name = __get_key_name(class->key, str);
-               seq_printf(m, ": %s", name);
-       } else{
-               seq_printf(m, ": %s", name);
-               if (class->name_version > 1)
-                       seq_printf(m, "#%d", class->name_version);
-               if (class->subclass)
-                       seq_printf(m, "/%d", class->subclass);
+       seq_printf(m, ": ");
+       print_name(m, class);
+       seq_puts(m, "\n");
+
+       list_for_each_entry(entry, &class->locks_after, entry) {
+               if (entry->distance == 1) {
+                       seq_printf(m, " -> [%p] ", entry->class);
+                       print_name(m, entry->class);
+                       seq_puts(m, "\n");
+               }
        }
        seq_puts(m, "\n");
 
@@ -227,7 +244,7 @@ static int lockdep_stats_show(struct seq_file *m, void *v)
 
                sum_forward_deps += count_forward_deps(class);
        }
-#ifdef CONFIG_LOCKDEP_DEBUG
+#ifdef CONFIG_DEBUG_LOCKDEP
        DEBUG_LOCKS_WARN_ON(debug_atomic_read(&nr_unused_locks) != nr_unused);
 #endif
        seq_printf(m, " lock-classes:                  %11lu [max: %lu]\n",
index 525e365f72390bb3fb4601c0be4c4bd81214eceb..623d1828259a9a4f1b9f7b6776bf0ea3b339c75d 100644 (file)
@@ -150,6 +150,7 @@ EXPORT_SYMBOL(panic);
  *  'R' - User forced a module unload.
  *  'M' - Machine had a machine check experience.
  *  'B' - System has hit bad_page.
+ *  'U' - Userspace-defined naughtiness.
  *
  *     The string is overwritten by the next call to print_taint().
  */
@@ -158,13 +159,14 @@ const char *print_tainted(void)
 {
        static char buf[20];
        if (tainted) {
-               snprintf(buf, sizeof(buf), "Tainted: %c%c%c%c%c%c",
+               snprintf(buf, sizeof(buf), "Tainted: %c%c%c%c%c%c%c",
                        tainted & TAINT_PROPRIETARY_MODULE ? 'P' : 'G',
                        tainted & TAINT_FORCED_MODULE ? 'F' : ' ',
                        tainted & TAINT_UNSAFE_SMP ? 'S' : ' ',
                        tainted & TAINT_FORCED_RMMOD ? 'R' : ' ',
                        tainted & TAINT_MACHINE_CHECK ? 'M' : ' ',
-                       tainted & TAINT_BAD_PAGE ? 'B' : ' ');
+                       tainted & TAINT_BAD_PAGE ? 'B' : ' ',
+                       tainted & TAINT_USER ? 'U' : ' ');
        }
        else
                snprintf(buf, sizeof(buf), "Not tainted");
index 5fe87de10ff07ae1afbecc8e076360c4f6005424..a1bf616178394f1906a11bb2bb063d16cb3b5902 100644 (file)
@@ -399,10 +399,9 @@ EXPORT_SYMBOL_GPL(register_posix_clock);
 static struct k_itimer * alloc_posix_timer(void)
 {
        struct k_itimer *tmr;
-       tmr = kmem_cache_alloc(posix_timers_cache, GFP_KERNEL);
+       tmr = kmem_cache_zalloc(posix_timers_cache, GFP_KERNEL);
        if (!tmr)
                return tmr;
-       memset(tmr, 0, sizeof (struct k_itimer));
        if (unlikely(!(tmr->sigq = sigqueue_alloc()))) {
                kmem_cache_free(posix_timers_cache, tmr);
                tmr = NULL;
index ed296225dcd4a66119d6785d64ddd488cc77f24c..95f6657fff73432880d14bd96e6304eea4aacff6 100644 (file)
@@ -131,3 +131,29 @@ config SUSPEND_SMP
        bool
        depends on HOTPLUG_CPU && X86 && PM
        default y
+
+config APM_EMULATION
+       tristate "Advanced Power Management Emulation"
+       depends on PM && SYS_SUPPORTS_APM_EMULATION
+       help
+         APM is a BIOS specification for saving power using several different
+         techniques. This is mostly useful for battery powered laptops with
+         APM compliant BIOSes. If you say Y here, the system time will be
+         reset after a RESUME operation, the /proc/apm device will provide
+         battery status information, and user-space programs will receive
+         notification of APM "events" (e.g. battery status change).
+
+         In order to use APM, you will need supporting software. For location
+         and more information, read <file:Documentation/pm.txt> and the
+         Battery Powered Linux mini-HOWTO, available from
+         <http://www.tldp.org/docs.html#howto>.
+
+         This driver does not spin down disk drives (see the hdparm(8)
+         manpage ("man 8 hdparm") for that), and it doesn't turn off
+         VESA-compliant "green" monitors.
+
+         Generally, if you don't have a battery in your machine, there isn't
+         much point in using this driver and you should say N. If you get
+         random kernel OOPSes or reboots that don't seem to be related to
+         anything, try disabling/enabling this option (or disabling/enabling
+         APM in your BIOS).
index 88fc5d7ac737402c18db0306049b5873effeed55..406b20adb27ad820a455b93a836ab636cbf65436 100644 (file)
@@ -87,52 +87,24 @@ static inline void platform_finish(void)
        }
 }
 
+static void unprepare_processes(void)
+{
+       thaw_processes();
+       pm_restore_console();
+}
+
 static int prepare_processes(void)
 {
        int error = 0;
 
        pm_prepare_console();
-
-       error = disable_nonboot_cpus();
-       if (error)
-               goto enable_cpus;
-
        if (freeze_processes()) {
                error = -EBUSY;
-               goto thaw;
+               unprepare_processes();
        }
-
-       if (pm_disk_mode == PM_DISK_TESTPROC) {
-               printk("swsusp debug: Waiting for 5 seconds.\n");
-               mdelay(5000);
-               goto thaw;
-       }
-
-       error = platform_prepare();
-       if (error)
-               goto thaw;
-
-       /* Free memory before shutting down devices. */
-       if (!(error = swsusp_shrink_memory()))
-               return 0;
-
-       platform_finish();
- thaw:
-       thaw_processes();
- enable_cpus:
-       enable_nonboot_cpus();
-       pm_restore_console();
        return error;
 }
 
-static void unprepare_processes(void)
-{
-       platform_finish();
-       thaw_processes();
-       enable_nonboot_cpus();
-       pm_restore_console();
-}
-
 /**
  *     pm_suspend_disk - The granpappy of hibernation power management.
  *
@@ -150,29 +122,45 @@ int pm_suspend_disk(void)
        if (error)
                return error;
 
-       if (pm_disk_mode == PM_DISK_TESTPROC)
-               return 0;
+       if (pm_disk_mode == PM_DISK_TESTPROC) {
+               printk("swsusp debug: Waiting for 5 seconds.\n");
+               mdelay(5000);
+               goto Thaw;
+       }
+       /* Free memory before shutting down devices. */
+       error = swsusp_shrink_memory();
+       if (error)
+               goto Thaw;
+
+       error = platform_prepare();
+       if (error)
+               goto Thaw;
 
        suspend_console();
        error = device_suspend(PMSG_FREEZE);
        if (error) {
-               resume_console();
-               printk("Some devices failed to suspend\n");
-               goto Thaw;
+               printk(KERN_ERR "PM: Some devices failed to suspend\n");
+               goto Resume_devices;
        }
+       error = disable_nonboot_cpus();
+       if (error)
+               goto Enable_cpus;
 
        if (pm_disk_mode == PM_DISK_TEST) {
                printk("swsusp debug: Waiting for 5 seconds.\n");
                mdelay(5000);
-               goto Done;
+               goto Enable_cpus;
        }
 
        pr_debug("PM: snapshotting memory.\n");
        in_suspend = 1;
-       if ((error = swsusp_suspend()))
-               goto Done;
+       error = swsusp_suspend();
+       if (error)
+               goto Enable_cpus;
 
        if (in_suspend) {
+               enable_nonboot_cpus();
+               platform_finish();
                device_resume();
                resume_console();
                pr_debug("PM: writing image.\n");
@@ -188,7 +176,10 @@ int pm_suspend_disk(void)
        }
 
        swsusp_free();
- Done:
+ Enable_cpus:
+       enable_nonboot_cpus();
+ Resume_devices:
+       platform_finish();
        device_resume();
        resume_console();
  Thaw:
@@ -237,19 +228,28 @@ static int software_resume(void)
 
        pr_debug("PM: Checking swsusp image.\n");
 
-       if ((error = swsusp_check()))
+       error = swsusp_check();
+       if (error)
                goto Done;
 
        pr_debug("PM: Preparing processes for restore.\n");
 
-       if ((error = prepare_processes())) {
+       error = prepare_processes();
+       if (error) {
                swsusp_close();
                goto Done;
        }
 
+       error = platform_prepare();
+       if (error) {
+               swsusp_free();
+               goto Thaw;
+       }
+
        pr_debug("PM: Reading swsusp image.\n");
 
-       if ((error = swsusp_read())) {
+       error = swsusp_read();
+       if (error) {
                swsusp_free();
                goto Thaw;
        }
@@ -257,21 +257,22 @@ static int software_resume(void)
        pr_debug("PM: Preparing devices for restore.\n");
 
        suspend_console();
-       if ((error = device_suspend(PMSG_PRETHAW))) {
-               resume_console();
-               printk("Some devices failed to suspend\n");
-               swsusp_free();
-               goto Thaw;
-       }
+       error = device_suspend(PMSG_PRETHAW);
+       if (error)
+               goto Free;
 
-       mb();
+       error = disable_nonboot_cpus();
+       if (!error)
+               swsusp_resume();
 
-       pr_debug("PM: Restoring saved image.\n");
-       swsusp_resume();
-       pr_debug("PM: Restore failed, recovering.n");
+       enable_nonboot_cpus();
+ Free:
+       swsusp_free();
+       platform_finish();
        device_resume();
        resume_console();
  Thaw:
+       printk(KERN_ERR "PM: Restore failed, recovering.\n");
        unprepare_processes();
  Done:
        /* For success case, the suspend path will release the lock */
index ff3a6182f5f0df3fb479cbd56092dd0ee8e1ff2e..e1c4131204698fd891af0b8046406ae4fd0ff76a 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/cpu.h>
 #include <linux/resume-trace.h>
 #include <linux/freezer.h>
+#include <linux/vmstat.h>
 
 #include "power.h"
 
@@ -43,6 +44,11 @@ void pm_set_ops(struct pm_ops * ops)
        mutex_unlock(&pm_mutex);
 }
 
+static inline void pm_finish(suspend_state_t state)
+{
+       if (pm_ops->finish)
+               pm_ops->finish(state);
+}
 
 /**
  *     suspend_prepare - Do prep work before entering low-power state.
@@ -63,16 +69,13 @@ static int suspend_prepare(suspend_state_t state)
 
        pm_prepare_console();
 
-       error = disable_nonboot_cpus();
-       if (error)
-               goto Enable_cpu;
-
        if (freeze_processes()) {
                error = -EAGAIN;
                goto Thaw;
        }
 
-       if ((free_pages = nr_free_pages()) < FREE_PAGE_NUMBER) {
+       if ((free_pages = global_page_state(NR_FREE_PAGES))
+                       < FREE_PAGE_NUMBER) {
                pr_debug("PM: free some memory\n");
                shrink_all_memory(FREE_PAGE_NUMBER - free_pages);
                if (nr_free_pages() < FREE_PAGE_NUMBER) {
@@ -88,18 +91,22 @@ static int suspend_prepare(suspend_state_t state)
        }
 
        suspend_console();
-       if ((error = device_suspend(PMSG_SUSPEND))) {
+       error = device_suspend(PMSG_SUSPEND);
+       if (error) {
                printk(KERN_ERR "Some devices failed to suspend\n");
-               goto Finish;
+               goto Resume_devices;
        }
-       return 0;
- Finish:
-       if (pm_ops->finish)
-               pm_ops->finish(state);
+       error = disable_nonboot_cpus();
+       if (!error)
+               return 0;
+
+       enable_nonboot_cpus();
+ Resume_devices:
+       pm_finish(state);
+       device_resume();
+       resume_console();
  Thaw:
        thaw_processes();
- Enable_cpu:
-       enable_nonboot_cpus();
        pm_restore_console();
        return error;
 }
@@ -134,12 +141,11 @@ int suspend_enter(suspend_state_t state)
 
 static void suspend_finish(suspend_state_t state)
 {
+       enable_nonboot_cpus();
+       pm_finish(state);
        device_resume();
        resume_console();
        thaw_processes();
-       enable_nonboot_cpus();
-       if (pm_ops && pm_ops->finish)
-               pm_ops->finish(state);
        pm_restore_console();
 }
 
index c024606221c4f9d6dd7ba35f3634f9f944fda23e..fc53ad06812843d346a777711b97a7f4698c76e3 100644 (file)
@@ -591,7 +591,7 @@ static unsigned int count_free_highmem_pages(void)
 
        for_each_zone(zone)
                if (populated_zone(zone) && is_highmem(zone))
-                       cnt += zone->free_pages;
+                       cnt += zone_page_state(zone, NR_FREE_PAGES);
 
        return cnt;
 }
@@ -869,7 +869,7 @@ static int enough_free_mem(unsigned int nr_pages, unsigned int nr_highmem)
        for_each_zone(zone) {
                meta += snapshot_additional_pages(zone);
                if (!is_highmem(zone))
-                       free += zone->free_pages;
+                       free += zone_page_state(zone, NR_FREE_PAGES);
        }
 
        nr_pages += count_pages_for_highmem(nr_highmem);
index 31aa0390c777d186652fe1b5dc3bfb4aafbaa338..7fb834397a0d5f97701f0e604b138cb473647011 100644 (file)
@@ -230,9 +230,10 @@ int swsusp_shrink_memory(void)
                for_each_zone (zone)
                        if (populated_zone(zone)) {
                                if (is_highmem(zone)) {
-                                       highmem_size -= zone->free_pages;
+                                       highmem_size -=
+                                       zone_page_state(zone, NR_FREE_PAGES);
                                } else {
-                                       tmp -= zone->free_pages;
+                                       tmp -= zone_page_state(zone, NR_FREE_PAGES);
                                        tmp += zone->lowmem_reserve[ZONE_NORMAL];
                                        tmp += snapshot_additional_pages(zone);
                                }
index f7b7a785a5c60a35e133daa036f7b9667ce3d718..dd09efe7df54352fac2a621c3cef33286dd4d63a 100644 (file)
@@ -37,6 +37,7 @@ static struct snapshot_data {
        int mode;
        char frozen;
        char ready;
+       char platform_suspend;
 } snapshot_state;
 
 static atomic_t device_available = ATOMIC_INIT(1);
@@ -66,6 +67,7 @@ static int snapshot_open(struct inode *inode, struct file *filp)
        data->bitmap = NULL;
        data->frozen = 0;
        data->ready = 0;
+       data->platform_suspend = 0;
 
        return 0;
 }
@@ -122,6 +124,92 @@ static ssize_t snapshot_write(struct file *filp, const char __user *buf,
        return res;
 }
 
+static inline int platform_prepare(void)
+{
+       int error = 0;
+
+       if (pm_ops && pm_ops->prepare)
+               error = pm_ops->prepare(PM_SUSPEND_DISK);
+
+       return error;
+}
+
+static inline void platform_finish(void)
+{
+       if (pm_ops && pm_ops->finish)
+               pm_ops->finish(PM_SUSPEND_DISK);
+}
+
+static inline int snapshot_suspend(int platform_suspend)
+{
+       int error;
+
+       mutex_lock(&pm_mutex);
+       /* Free memory before shutting down devices. */
+       error = swsusp_shrink_memory();
+       if (error)
+               goto Finish;
+
+       if (platform_suspend) {
+               error = platform_prepare();
+               if (error)
+                       goto Finish;
+       }
+       suspend_console();
+       error = device_suspend(PMSG_FREEZE);
+       if (error)
+               goto Resume_devices;
+
+       error = disable_nonboot_cpus();
+       if (!error) {
+               in_suspend = 1;
+               error = swsusp_suspend();
+       }
+       enable_nonboot_cpus();
+ Resume_devices:
+       if (platform_suspend)
+               platform_finish();
+
+       device_resume();
+       resume_console();
+ Finish:
+       mutex_unlock(&pm_mutex);
+       return error;
+}
+
+static inline int snapshot_restore(int platform_suspend)
+{
+       int error;
+
+       mutex_lock(&pm_mutex);
+       pm_prepare_console();
+       if (platform_suspend) {
+               error = platform_prepare();
+               if (error)
+                       goto Finish;
+       }
+       suspend_console();
+       error = device_suspend(PMSG_PRETHAW);
+       if (error)
+               goto Resume_devices;
+
+       error = disable_nonboot_cpus();
+       if (!error)
+               error = swsusp_resume();
+
+       enable_nonboot_cpus();
+ Resume_devices:
+       if (platform_suspend)
+               platform_finish();
+
+       device_resume();
+       resume_console();
+ Finish:
+       pm_restore_console();
+       mutex_unlock(&pm_mutex);
+       return error;
+}
+
 static int snapshot_ioctl(struct inode *inode, struct file *filp,
                           unsigned int cmd, unsigned long arg)
 {
@@ -145,14 +233,9 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
                if (data->frozen)
                        break;
                mutex_lock(&pm_mutex);
-               error = disable_nonboot_cpus();
-               if (!error) {
-                       error = freeze_processes();
-                       if (error) {
-                               thaw_processes();
-                               enable_nonboot_cpus();
-                               error = -EBUSY;
-                       }
+               if (freeze_processes()) {
+                       thaw_processes();
+                       error = -EBUSY;
                }
                mutex_unlock(&pm_mutex);
                if (!error)
@@ -164,7 +247,6 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
                        break;
                mutex_lock(&pm_mutex);
                thaw_processes();
-               enable_nonboot_cpus();
                mutex_unlock(&pm_mutex);
                data->frozen = 0;
                break;
@@ -174,20 +256,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
                        error = -EPERM;
                        break;
                }
-               mutex_lock(&pm_mutex);
-               /* Free memory before shutting down devices. */
-               error = swsusp_shrink_memory();
-               if (!error) {
-                       suspend_console();
-                       error = device_suspend(PMSG_FREEZE);
-                       if (!error) {
-                               in_suspend = 1;
-                               error = swsusp_suspend();
-                               device_resume();
-                       }
-                       resume_console();
-               }
-               mutex_unlock(&pm_mutex);
+               error = snapshot_suspend(data->platform_suspend);
                if (!error)
                        error = put_user(in_suspend, (unsigned int __user *)arg);
                if (!error)
@@ -201,17 +270,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
                        error = -EPERM;
                        break;
                }
-               mutex_lock(&pm_mutex);
-               pm_prepare_console();
-               suspend_console();
-               error = device_suspend(PMSG_PRETHAW);
-               if (!error) {
-                       error = swsusp_resume();
-                       device_resume();
-               }
-               resume_console();
-               pm_restore_console();
-               mutex_unlock(&pm_mutex);
+               error = snapshot_restore(data->platform_suspend);
                break;
 
        case SNAPSHOT_FREE:
@@ -282,6 +341,11 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
                break;
 
        case SNAPSHOT_S2RAM:
+               if (!pm_ops) {
+                       error = -ENOSYS;
+                       break;
+               }
+
                if (!data->frozen) {
                        error = -EPERM;
                        break;
@@ -319,28 +383,35 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
                break;
 
        case SNAPSHOT_PMOPS:
+               error = -EINVAL;
+
                switch (arg) {
 
                case PMOPS_PREPARE:
-                       if (pm_ops->prepare) {
-                               error = pm_ops->prepare(PM_SUSPEND_DISK);
+                       if (pm_ops && pm_ops->enter) {
+                               data->platform_suspend = 1;
+                               error = 0;
+                       } else {
+                               error = -ENOSYS;
                        }
                        break;
 
                case PMOPS_ENTER:
-                       kernel_shutdown_prepare(SYSTEM_SUSPEND_DISK);
-                       error = pm_ops->enter(PM_SUSPEND_DISK);
+                       if (data->platform_suspend) {
+                               kernel_shutdown_prepare(SYSTEM_SUSPEND_DISK);
+                               error = pm_ops->enter(PM_SUSPEND_DISK);
+                               error = 0;
+                       }
                        break;
 
                case PMOPS_FINISH:
-                       if (pm_ops && pm_ops->finish) {
-                               pm_ops->finish(PM_SUSPEND_DISK);
-                       }
+                       if (data->platform_suspend)
+                               error = 0;
+
                        break;
 
                default:
                        printk(KERN_ERR "SNAPSHOT_PMOPS: invalid argument %ld\n", arg);
-                       error = -EINVAL;
 
                }
                break;
index c770e1a4e882289f66ae0e54451ba186f09c03d2..0c151877ff71ad117e2d751e34ce528606d7eea2 100644 (file)
@@ -483,7 +483,7 @@ static int have_callable_console(void)
  * printk - print a kernel message
  * @fmt: format string
  *
- * This is printk.  It can be called from any context.  We want it to work.
+ * This is printk().  It can be called from any context.  We want it to work.
  *
  * We try to grab the console_sem.  If we succeed, it's easy - we log the output and
  * call the console drivers.  If we fail to get the semaphore we place the output
@@ -529,7 +529,7 @@ asmlinkage int vprintk(const char *fmt, va_list args)
                zap_locks();
 
        /* This stops the holder of console_sem just where we want him */
-       local_irq_save(flags);
+       raw_local_irq_save(flags);
        lockdep_off();
        spin_lock(&logbuf_lock);
        printk_cpu = smp_processor_id();
@@ -618,7 +618,7 @@ asmlinkage int vprintk(const char *fmt, va_list args)
                        up(&console_sem);
                }
                lockdep_on();
-               local_irq_restore(flags);
+               raw_local_irq_restore(flags);
        } else {
                /*
                 * Someone else owns the drivers.  We drop the spinlock, which
@@ -628,7 +628,7 @@ asmlinkage int vprintk(const char *fmt, va_list args)
                printk_cpu = UINT_MAX;
                spin_unlock(&logbuf_lock);
                lockdep_on();
-               local_irq_restore(flags);
+               raw_local_irq_restore(flags);
        }
 
        preempt_enable();
@@ -783,6 +783,12 @@ int is_console_locked(void)
        return console_locked;
 }
 
+void wake_up_klogd(void)
+{
+       if (!oops_in_progress && waitqueue_active(&log_wait))
+               wake_up_interruptible(&log_wait);
+}
+
 /**
  * release_console_sem - unlock the console system
  *
@@ -825,8 +831,8 @@ void release_console_sem(void)
        console_locked = 0;
        up(&console_sem);
        spin_unlock_irqrestore(&logbuf_lock, flags);
-       if (wake_klogd && !oops_in_progress && waitqueue_active(&log_wait))
-               wake_up_interruptible(&log_wait);
+       if (wake_klogd)
+               wake_up_klogd();
 }
 EXPORT_SYMBOL(release_console_sem);
 
index d6579d511069130980196be79005f2724a01b8d3..9bfadb248dd877b009e49710db79957f13188c5d 100644 (file)
@@ -449,7 +449,6 @@ void create_prof_cpu_mask(struct proc_dir_entry *root_irq_dir)
        /* create /proc/irq/prof_cpu_mask */
        if (!(entry = create_proc_entry("prof_cpu_mask", 0600, root_irq_dir)))
                return;
-       entry->nlink = 1;
        entry->data = (void *)&prof_cpu_mask;
        entry->read_proc = prof_cpu_mask_read_proc;
        entry->write_proc = prof_cpu_mask_write_proc;
index 284e2e8b4eed0e0d31ea1a5d5fb9f732f0a16d67..ef8a935710a27be3edc6c940f77878d2895d6434 100644 (file)
@@ -7,6 +7,8 @@
  * Copyright (C) 1999-2005 - Karim Yaghmour (karim@opersys.com)
  *
  * Moved to kernel/relay.c by Paul Mundt, 2006.
+ * November 2006 - CPU hotplug support by Mathieu Desnoyers
+ *     (mathieu.desnoyers@polymtl.ca)
  *
  * This file is released under the GPL.
  */
 #include <linux/relay.h>
 #include <linux/vmalloc.h>
 #include <linux/mm.h>
+#include <linux/cpu.h>
+
+/* list of open channels, for cpu hotplug */
+static DEFINE_MUTEX(relay_channels_mutex);
+static LIST_HEAD(relay_channels);
 
 /*
  * close() vm_op implementation for relay file mapping.
@@ -187,6 +194,7 @@ void relay_destroy_buf(struct rchan_buf *buf)
                        __free_page(buf->page_array[i]);
                kfree(buf->page_array);
        }
+       chan->buf[buf->cpu] = NULL;
        kfree(buf->padding);
        kfree(buf);
        kref_put(&chan->kref, relay_destroy_channel);
@@ -320,7 +328,7 @@ static void wakeup_readers(struct work_struct *work)
  *     @buf: the channel buffer
  *     @init: 1 if this is a first-time initialization
  *
- *     See relay_reset for description of effect.
+ *     See relay_reset() for description of effect.
  */
 static void __relay_reset(struct rchan_buf *buf, unsigned int init)
 {
@@ -356,57 +364,75 @@ static void __relay_reset(struct rchan_buf *buf, unsigned int init)
  *     and restarting the channel in its initial state.  The buffers
  *     are not freed, so any mappings are still in effect.
  *
- *     NOTE: Care should be taken that the channel isn't actually
+ *     NOTE. Care should be taken that the channel isn't actually
  *     being used by anything when this call is made.
  */
 void relay_reset(struct rchan *chan)
 {
        unsigned int i;
-       struct rchan_buf *prev = NULL;
 
        if (!chan)
                return;
 
-       for (i = 0; i < NR_CPUS; i++) {
-               if (!chan->buf[i] || chan->buf[i] == prev)
-                       break;
-               __relay_reset(chan->buf[i], 0);
-               prev = chan->buf[i];
+       if (chan->is_global && chan->buf[0]) {
+               __relay_reset(chan->buf[0], 0);
+               return;
        }
+
+       mutex_lock(&relay_channels_mutex);
+       for_each_online_cpu(i)
+               if (chan->buf[i])
+                       __relay_reset(chan->buf[i], 0);
+       mutex_unlock(&relay_channels_mutex);
 }
 EXPORT_SYMBOL_GPL(relay_reset);
 
 /*
  *     relay_open_buf - create a new relay channel buffer
  *
- *     Internal - used by relay_open().
+ *     used by relay_open() and CPU hotplug.
  */
-static struct rchan_buf *relay_open_buf(struct rchan *chan,
-                                       const char *filename,
-                                       struct dentry *parent,
-                                       int *is_global)
+static struct rchan_buf *relay_open_buf(struct rchan *chan, unsigned int cpu)
 {
-       struct rchan_buf *buf;
+       struct rchan_buf *buf = NULL;
        struct dentry *dentry;
+       char *tmpname;
 
-       if (*is_global)
+       if (chan->is_global)
                return chan->buf[0];
 
+       tmpname = kzalloc(NAME_MAX + 1, GFP_KERNEL);
+       if (!tmpname)
+               goto end;
+       snprintf(tmpname, NAME_MAX, "%s%d", chan->base_filename, cpu);
+
        buf = relay_create_buf(chan);
        if (!buf)
-               return NULL;
+               goto free_name;
+
+       buf->cpu = cpu;
+       __relay_reset(buf, 1);
 
        /* Create file in fs */
-       dentry = chan->cb->create_buf_file(filename, parent, S_IRUSR,
-                                          buf, is_global);
-       if (!dentry) {
-               relay_destroy_buf(buf);
-               return NULL;
-       }
+       dentry = chan->cb->create_buf_file(tmpname, chan->parent, S_IRUSR,
+                                          buf, &chan->is_global);
+       if (!dentry)
+               goto free_buf;
 
        buf->dentry = dentry;
-       __relay_reset(buf, 1);
 
+       if(chan->is_global) {
+               chan->buf[0] = buf;
+               buf->cpu = 0;
+       }
+
+       goto free_name;
+
+free_buf:
+       relay_destroy_buf(buf);
+free_name:
+       kfree(tmpname);
+end:
        return buf;
 }
 
@@ -447,6 +473,47 @@ static void setup_callbacks(struct rchan *chan,
        chan->cb = cb;
 }
 
+/**
+ *
+ *     relay_hotcpu_callback - CPU hotplug callback
+ *     @nb: notifier block
+ *     @action: hotplug action to take
+ *     @hcpu: CPU number
+ *
+ *     Returns the success/failure of the operation. (NOTIFY_OK, NOTIFY_BAD)
+ */
+static int __cpuinit relay_hotcpu_callback(struct notifier_block *nb,
+                               unsigned long action,
+                               void *hcpu)
+{
+       unsigned int hotcpu = (unsigned long)hcpu;
+       struct rchan *chan;
+
+       switch(action) {
+       case CPU_UP_PREPARE:
+               mutex_lock(&relay_channels_mutex);
+               list_for_each_entry(chan, &relay_channels, list) {
+                       if (chan->buf[hotcpu])
+                               continue;
+                       chan->buf[hotcpu] = relay_open_buf(chan, hotcpu);
+                       if(!chan->buf[hotcpu]) {
+                               printk(KERN_ERR
+                                       "relay_hotcpu_callback: cpu %d buffer "
+                                       "creation failed\n", hotcpu);
+                               mutex_unlock(&relay_channels_mutex);
+                               return NOTIFY_BAD;
+                       }
+               }
+               mutex_unlock(&relay_channels_mutex);
+               break;
+       case CPU_DEAD:
+               /* No need to flush the cpu : will be flushed upon
+                * final relay_flush() call. */
+               break;
+       }
+       return NOTIFY_OK;
+}
+
 /**
  *     relay_open - create a new relay channel
  *     @base_filename: base name of files to create
@@ -454,25 +521,24 @@ static void setup_callbacks(struct rchan *chan,
  *     @subbuf_size: size of sub-buffers
  *     @n_subbufs: number of sub-buffers
  *     @cb: client callback functions
+ *     @private_data: user-defined data
  *
  *     Returns channel pointer if successful, %NULL otherwise.
  *
  *     Creates a channel buffer for each cpu using the sizes and
  *     attributes specified.  The created channel buffer files
  *     will be named base_filename0...base_filenameN-1.  File
- *     permissions will be S_IRUSR.
+ *     permissions will be %S_IRUSR.
  */
 struct rchan *relay_open(const char *base_filename,
                         struct dentry *parent,
                         size_t subbuf_size,
                         size_t n_subbufs,
-                        struct rchan_callbacks *cb)
+                        struct rchan_callbacks *cb,
+                        void *private_data)
 {
        unsigned int i;
        struct rchan *chan;
-       char *tmpname;
-       int is_global = 0;
-
        if (!base_filename)
                return NULL;
 
@@ -487,38 +553,32 @@ struct rchan *relay_open(const char *base_filename,
        chan->n_subbufs = n_subbufs;
        chan->subbuf_size = subbuf_size;
        chan->alloc_size = FIX_SIZE(subbuf_size * n_subbufs);
+       chan->parent = parent;
+       chan->private_data = private_data;
+       strlcpy(chan->base_filename, base_filename, NAME_MAX);
        setup_callbacks(chan, cb);
        kref_init(&chan->kref);
 
-       tmpname = kmalloc(NAME_MAX + 1, GFP_KERNEL);
-       if (!tmpname)
-               goto free_chan;
-
+       mutex_lock(&relay_channels_mutex);
        for_each_online_cpu(i) {
-               sprintf(tmpname, "%s%d", base_filename, i);
-               chan->buf[i] = relay_open_buf(chan, tmpname, parent,
-                                             &is_global);
+               chan->buf[i] = relay_open_buf(chan, i);
                if (!chan->buf[i])
                        goto free_bufs;
-
-               chan->buf[i]->cpu = i;
        }
+       list_add(&chan->list, &relay_channels);
+       mutex_unlock(&relay_channels_mutex);
 
-       kfree(tmpname);
        return chan;
 
 free_bufs:
-       for (i = 0; i < NR_CPUS; i++) {
+       for_each_online_cpu(i) {
                if (!chan->buf[i])
                        break;
                relay_close_buf(chan->buf[i]);
-               if (is_global)
-                       break;
        }
-       kfree(tmpname);
 
-free_chan:
        kref_put(&chan->kref, relay_destroy_channel);
+       mutex_unlock(&relay_channels_mutex);
        return NULL;
 }
 EXPORT_SYMBOL_GPL(relay_open);
@@ -588,7 +648,7 @@ EXPORT_SYMBOL_GPL(relay_switch_subbuf);
  *     subbufs_consumed should be the number of sub-buffers newly consumed,
  *     not the total consumed.
  *
- *     NOTE: Kernel clients don't need to call this function if the channel
+ *     NOTE. Kernel clients don't need to call this function if the channel
  *     mode is 'overwrite'.
  */
 void relay_subbufs_consumed(struct rchan *chan,
@@ -619,24 +679,26 @@ EXPORT_SYMBOL_GPL(relay_subbufs_consumed);
 void relay_close(struct rchan *chan)
 {
        unsigned int i;
-       struct rchan_buf *prev = NULL;
 
        if (!chan)
                return;
 
-       for (i = 0; i < NR_CPUS; i++) {
-               if (!chan->buf[i] || chan->buf[i] == prev)
-                       break;
-               relay_close_buf(chan->buf[i]);
-               prev = chan->buf[i];
-       }
+       mutex_lock(&relay_channels_mutex);
+       if (chan->is_global && chan->buf[0])
+               relay_close_buf(chan->buf[0]);
+       else
+               for_each_possible_cpu(i)
+                       if (chan->buf[i])
+                               relay_close_buf(chan->buf[i]);
 
        if (chan->last_toobig)
                printk(KERN_WARNING "relay: one or more items not logged "
                       "[item size (%Zd) > sub-buffer size (%Zd)]\n",
                       chan->last_toobig, chan->subbuf_size);
 
+       list_del(&chan->list);
        kref_put(&chan->kref, relay_destroy_channel);
+       mutex_unlock(&relay_channels_mutex);
 }
 EXPORT_SYMBOL_GPL(relay_close);
 
@@ -649,17 +711,20 @@ EXPORT_SYMBOL_GPL(relay_close);
 void relay_flush(struct rchan *chan)
 {
        unsigned int i;
-       struct rchan_buf *prev = NULL;
 
        if (!chan)
                return;
 
-       for (i = 0; i < NR_CPUS; i++) {
-               if (!chan->buf[i] || chan->buf[i] == prev)
-                       break;
-               relay_switch_subbuf(chan->buf[i], 0);
-               prev = chan->buf[i];
+       if (chan->is_global && chan->buf[0]) {
+               relay_switch_subbuf(chan->buf[0], 0);
+               return;
        }
+
+       mutex_lock(&relay_channels_mutex);
+       for_each_possible_cpu(i)
+               if (chan->buf[i])
+                       relay_switch_subbuf(chan->buf[i], 0);
+       mutex_unlock(&relay_channels_mutex);
 }
 EXPORT_SYMBOL_GPL(relay_flush);
 
@@ -684,7 +749,7 @@ static int relay_file_open(struct inode *inode, struct file *filp)
  *     @filp: the file
  *     @vma: the vma describing what to map
  *
- *     Calls upon relay_mmap_buf to map the file into user space.
+ *     Calls upon relay_mmap_buf() to map the file into user space.
  */
 static int relay_file_mmap(struct file *filp, struct vm_area_struct *vma)
 {
@@ -826,7 +891,7 @@ static size_t relay_file_read_subbuf_avail(size_t read_pos,
  *     @read_pos: file read position
  *     @buf: relay channel buffer
  *
- *     If the read_pos is in the middle of padding, return the
+ *     If the @read_pos is in the middle of padding, return the
  *     position of the first actually available byte, otherwise
  *     return the original value.
  */
@@ -1022,3 +1087,12 @@ const struct file_operations relay_file_operations = {
        .sendfile       = relay_file_sendfile,
 };
 EXPORT_SYMBOL_GPL(relay_file_operations);
+
+static __init int relay_init(void)
+{
+
+       hotcpu_notifier(relay_hotcpu_callback, 0);
+       return 0;
+}
+
+module_init(relay_init);
index 7b9a497419d9501631e5a524582d6b812fb5e841..2a3f886365808241e329222772d28dfadf87da62 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/fs.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
+#include <linux/device.h>
 #include <asm/io.h>
 
 
@@ -617,6 +618,67 @@ void __release_region(struct resource *parent, resource_size_t start,
 }
 EXPORT_SYMBOL(__release_region);
 
+/*
+ * Managed region resource
+ */
+struct region_devres {
+       struct resource *parent;
+       resource_size_t start;
+       resource_size_t n;
+};
+
+static void devm_region_release(struct device *dev, void *res)
+{
+       struct region_devres *this = res;
+
+       __release_region(this->parent, this->start, this->n);
+}
+
+static int devm_region_match(struct device *dev, void *res, void *match_data)
+{
+       struct region_devres *this = res, *match = match_data;
+
+       return this->parent == match->parent &&
+               this->start == match->start && this->n == match->n;
+}
+
+struct resource * __devm_request_region(struct device *dev,
+                               struct resource *parent, resource_size_t start,
+                               resource_size_t n, const char *name)
+{
+       struct region_devres *dr = NULL;
+       struct resource *res;
+
+       dr = devres_alloc(devm_region_release, sizeof(struct region_devres),
+                         GFP_KERNEL);
+       if (!dr)
+               return NULL;
+
+       dr->parent = parent;
+       dr->start = start;
+       dr->n = n;
+
+       res = __request_region(parent, start, n, name);
+       if (res)
+               devres_add(dev, dr);
+       else
+               devres_free(dr);
+
+       return res;
+}
+EXPORT_SYMBOL(__devm_request_region);
+
+void __devm_release_region(struct device *dev, struct resource *parent,
+                          resource_size_t start, resource_size_t n)
+{
+       struct region_devres match_data = { parent, start, n };
+
+       __release_region(parent, start, n);
+       WARN_ON(devres_destroy(dev, devm_region_release, devm_region_match,
+                              &match_data));
+}
+EXPORT_SYMBOL(__devm_release_region);
+
 /*
  * Called from init/main.c to reserve IO ports.
  */
index cca93cc0dd7d8ba7272b1ea4782e87c97bfe1a09..1fd67e16cd315388a67ba085dad46bb266bb5d93 100644 (file)
 
 #include <asm/unistd.h>
 
+/*
+ * Scheduler clock - returns current time in nanosec units.
+ * This is default implementation.
+ * Architectures and sub-architectures can override this.
+ */
+unsigned long long __attribute__((weak)) sched_clock(void)
+{
+       return (unsigned long long)jiffies * (1000000000 / HZ);
+}
+
 /*
  * Convert user-nice values [ -20 ... 0 ... 19 ]
  * to static priority [ MAX_RT_PRIO..MAX_PRIO-1 ],
@@ -4193,13 +4203,12 @@ static void __setscheduler(struct task_struct *p, int policy, int prio)
 }
 
 /**
- * sched_setscheduler - change the scheduling policy and/or RT priority of
- * a thread.
+ * sched_setscheduler - change the scheduling policy and/or RT priority of a thread.
  * @p: the task in question.
  * @policy: new policy.
  * @param: structure containing the new RT priority.
  *
- * NOTE: the task may be already dead
+ * NOTE that the task may be already dead.
  */
 int sched_setscheduler(struct task_struct *p, int policy,
                       struct sched_param *param)
@@ -4567,7 +4576,7 @@ asmlinkage long sys_sched_getaffinity(pid_t pid, unsigned int len,
 /**
  * sys_sched_yield - yield the current processor to other threads.
  *
- * this function yields the current CPU by moving the calling thread
+ * This function yields the current CPU by moving the calling thread
  * to the expired array. If there are no other threads running on this
  * CPU then this function will return.
  */
@@ -4694,7 +4703,7 @@ EXPORT_SYMBOL(cond_resched_softirq);
 /**
  * yield - yield the current processor to other threads.
  *
- * this is a shortcut for kernel-space yielding - it marks the
+ * This is a shortcut for kernel-space yielding - it marks the
  * thread runnable and calls sys_sched_yield().
  */
 void __sched yield(void)
index 5630255d2e2a958f6e58eea4596a62b0dea3f91a..228fdb5c01d12a0b1b409b1819a95a4c8d223840 100644 (file)
@@ -1119,19 +1119,18 @@ kill_pg_info(int sig, struct siginfo *info, pid_t pgrp)
 int kill_pid_info(int sig, struct siginfo *info, struct pid *pid)
 {
        int error;
-       int acquired_tasklist_lock = 0;
        struct task_struct *p;
 
        rcu_read_lock();
-       if (unlikely(sig_needs_tasklist(sig))) {
+       if (unlikely(sig_needs_tasklist(sig)))
                read_lock(&tasklist_lock);
-               acquired_tasklist_lock = 1;
-       }
+
        p = pid_task(pid, PIDTYPE_PID);
        error = -ESRCH;
        if (p)
                error = group_send_sig_info(sig, info, p);
-       if (unlikely(acquired_tasklist_lock))
+
+       if (unlikely(sig_needs_tasklist(sig)))
                read_unlock(&tasklist_lock);
        rcu_read_unlock();
        return error;
@@ -2283,7 +2282,7 @@ static int do_tkill(int tgid, int pid, int sig)
  *  @pid: the PID of the thread
  *  @sig: signal to be sent
  *
- *  This syscall also checks the tgid and returns -ESRCH even if the PID
+ *  This syscall also checks the @tgid and returns -ESRCH even if the PID
  *  exists but it's not belonging to the target process anymore. This
  *  method solves the problem of threads exiting and PIDs getting reused.
  */
index 6e2101dec0fcfc9e95c52a1ac53bc6898b976edf..e1024383314de0428e4739e0f9c782330ecd63d5 100644 (file)
@@ -215,7 +215,7 @@ EXPORT_SYMBOL_GPL(atomic_notifier_chain_unregister);
  *     This routine uses RCU to synchronize with changes to the chain.
  *
  *     If the return value of the notifier can be and'ed
- *     with %NOTIFY_STOP_MASK then atomic_notifier_call_chain
+ *     with %NOTIFY_STOP_MASK then atomic_notifier_call_chain()
  *     will return immediately, with the return value of
  *     the notifier function which halted execution.
  *     Otherwise the return value is the return value
@@ -313,7 +313,7 @@ EXPORT_SYMBOL_GPL(blocking_notifier_chain_unregister);
  *     run in a process context, so they are allowed to block.
  *
  *     If the return value of the notifier can be and'ed
- *     with %NOTIFY_STOP_MASK then blocking_notifier_call_chain
+ *     with %NOTIFY_STOP_MASK then blocking_notifier_call_chain()
  *     will return immediately, with the return value of
  *     the notifier function which halted execution.
  *     Otherwise the return value is the return value
@@ -393,7 +393,7 @@ EXPORT_SYMBOL_GPL(raw_notifier_chain_unregister);
  *     All locking must be provided by the caller.
  *
  *     If the return value of the notifier can be and'ed
- *     with %NOTIFY_STOP_MASK then raw_notifier_call_chain
+ *     with %NOTIFY_STOP_MASK then raw_notifier_call_chain()
  *     will return immediately, with the return value of
  *     the notifier function which halted execution.
  *     Otherwise the return value is the return value
@@ -487,7 +487,7 @@ EXPORT_SYMBOL_GPL(srcu_notifier_chain_unregister);
  *     run in a process context, so they are allowed to block.
  *
  *     If the return value of the notifier can be and'ed
- *     with %NOTIFY_STOP_MASK then srcu_notifier_call_chain
+ *     with %NOTIFY_STOP_MASK then srcu_notifier_call_chain()
  *     will return immediately, with the return value of
  *     the notifier function which halted execution.
  *     Otherwise the return value is the return value
@@ -538,7 +538,7 @@ EXPORT_SYMBOL_GPL(srcu_init_notifier_head);
  *     Registers a function with the list of functions
  *     to be called at reboot time.
  *
- *     Currently always returns zero, as blocking_notifier_chain_register
+ *     Currently always returns zero, as blocking_notifier_chain_register()
  *     always returns zero.
  */
  
index 600b33358ded97ea54e90b6cc39dafef8e03fa40..e0ac6cd79fcf6955c6105815b4c8ab4d9d53e97f 100644 (file)
@@ -151,6 +151,8 @@ static int sysctl_ipc_data(ctl_table *table, int __user *name, int nlen,
 #ifdef CONFIG_PROC_SYSCTL
 static int proc_do_cad_pid(ctl_table *table, int write, struct file *filp,
                  void __user *buffer, size_t *lenp, loff_t *ppos);
+static int proc_dointvec_taint(ctl_table *table, int write, struct file *filp,
+                              void __user *buffer, size_t *lenp, loff_t *ppos);
 #endif
 
 static ctl_table root_table[];
@@ -174,6 +176,7 @@ extern ctl_table inotify_table[];
 int sysctl_legacy_va_layout;
 #endif
 
+
 static void *get_uts(ctl_table *table, int write)
 {
        char *which = table->data;
@@ -344,14 +347,16 @@ static ctl_table kern_table[] = {
                .proc_handler   = &proc_dostring,
                .strategy       = &sysctl_string,
        },
+#ifdef CONFIG_PROC_SYSCTL
        {
                .ctl_name       = KERN_TAINTED,
                .procname       = "tainted",
                .data           = &tainted,
                .maxlen         = sizeof(int),
-               .mode           = 0444,
-               .proc_handler   = &proc_dointvec,
+               .mode           = 0644,
+               .proc_handler   = &proc_dointvec_taint,
        },
+#endif
        {
                .ctl_name       = KERN_CAP_BSET,
                .procname       = "cap-bound",
@@ -1681,13 +1686,12 @@ static int _proc_do_string(void* data, int maxlen, int write,
        size_t len;
        char __user *p;
        char c;
-       
-       if (!data || !maxlen || !*lenp ||
-           (*ppos && !write)) {
+
+       if (!data || !maxlen || !*lenp) {
                *lenp = 0;
                return 0;
        }
-       
+
        if (write) {
                len = 0;
                p = buffer;
@@ -1708,6 +1712,15 @@ static int _proc_do_string(void* data, int maxlen, int write,
                len = strlen(data);
                if (len > maxlen)
                        len = maxlen;
+
+               if (*ppos > len) {
+                       *lenp = 0;
+                       return 0;
+               }
+
+               data += *ppos;
+               len  -= *ppos;
+
                if (len > *lenp)
                        len = *lenp;
                if (len)
@@ -1927,6 +1940,7 @@ int proc_dointvec(ctl_table *table, int write, struct file *filp,
 
 #define OP_SET 0
 #define OP_AND 1
+#define OP_OR  2
 
 static int do_proc_dointvec_bset_conv(int *negp, unsigned long *lvalp,
                                      int *valp,
@@ -1938,6 +1952,7 @@ static int do_proc_dointvec_bset_conv(int *negp, unsigned long *lvalp,
                switch(op) {
                case OP_SET:    *valp = val; break;
                case OP_AND:    *valp &= val; break;
+               case OP_OR:     *valp |= val; break;
                }
        } else {
                int val = *valp;
@@ -1961,7 +1976,7 @@ int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
 {
        int op;
 
-       if (!capable(CAP_SYS_MODULE)) {
+       if (write && !capable(CAP_SYS_MODULE)) {
                return -EPERM;
        }
 
@@ -1970,6 +1985,22 @@ int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
                                do_proc_dointvec_bset_conv,&op);
 }
 
+/*
+ *     Taint values can only be increased
+ */
+static int proc_dointvec_taint(ctl_table *table, int write, struct file *filp,
+                              void __user *buffer, size_t *lenp, loff_t *ppos)
+{
+       int op;
+
+       if (!capable(CAP_SYS_ADMIN))
+               return -EPERM;
+
+       op = OP_OR;
+       return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
+                               do_proc_dointvec_bset_conv,&op);
+}
+
 struct do_proc_dointvec_minmax_conv_param {
        int *min;
        int *max;
@@ -2553,17 +2584,23 @@ int sysctl_jiffies(ctl_table *table, int __user *name, int nlen,
                void __user *oldval, size_t __user *oldlenp,
                void __user *newval, size_t newlen)
 {
-       if (oldval) {
+       if (oldval && oldlenp) {
                size_t olen;
-               if (oldlenp) { 
-                       if (get_user(olen, oldlenp))
+
+               if (get_user(olen, oldlenp))
+                       return -EFAULT;
+               if (olen) {
+                       int val;
+
+                       if (olen < sizeof(int))
+                               return -EINVAL;
+
+                       val = *(int *)(table->data) / HZ;
+                       if (put_user(val, (int __user *)oldval))
+                               return -EFAULT;
+                       if (put_user(sizeof(int), oldlenp))
                                return -EFAULT;
-                       if (olen!=sizeof(int))
-                               return -EINVAL; 
                }
-               if (put_user(*(int *)(table->data)/HZ, (int __user *)oldval) ||
-                   (oldlenp && put_user(sizeof(int),oldlenp)))
-                       return -EFAULT;
        }
        if (newval && newlen) { 
                int new;
@@ -2581,17 +2618,23 @@ int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen,
                void __user *oldval, size_t __user *oldlenp,
                void __user *newval, size_t newlen)
 {
-       if (oldval) {
+       if (oldval && oldlenp) {
                size_t olen;
-               if (oldlenp) { 
-                       if (get_user(olen, oldlenp))
+
+               if (get_user(olen, oldlenp))
+                       return -EFAULT;
+               if (olen) {
+                       int val;
+
+                       if (olen < sizeof(int))
+                               return -EINVAL;
+
+                       val = jiffies_to_msecs(*(int *)(table->data));
+                       if (put_user(val, (int __user *)oldval))
+                               return -EFAULT;
+                       if (put_user(sizeof(int), oldlenp))
                                return -EFAULT;
-                       if (olen!=sizeof(int))
-                               return -EINVAL; 
                }
-               if (put_user(jiffies_to_msecs(*(int *)(table->data)), (int __user *)oldval) ||
-                   (oldlenp && put_user(sizeof(int),oldlenp)))
-                       return -EFAULT;
        }
        if (newval && newlen) { 
                int new;
@@ -2732,12 +2775,14 @@ static int sysctl_uts_string(ctl_table *table, int __user *name, int nlen,
 {
        return -ENOSYS;
 }
+#ifdef CONFIG_SYSVIPC
 static int sysctl_ipc_data(ctl_table *table, int __user *name, int nlen,
                void __user *oldval, size_t __user *oldlenp,
                void __user *newval, size_t newlen)
 {
        return -ENOSYS;
 }
+#endif
 #endif /* CONFIG_SYSCTL_SYSCALL */
 
 /*
index 22504afc0d34b48bf10e216c72b33c3be4470598..d9ef176c4e092eebf93acc31dd14dcbd362603c0 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/sysdev.h>
 #include <linux/init.h>
 #include <linux/module.h>
+#include <linux/sched.h> /* for spin_unlock_irq() using preempt_count() m68k */
 
 /* XXX - Would like a better way for initializing curr_clocksource */
 extern struct clocksource clocksource_jiffies;
index c2a8ccfc288210fb45a3ae199c94572edbbc72b4..8533c379608281070f7d74c6afcef953ccfd4327 100644 (file)
@@ -85,7 +85,7 @@ static DEFINE_PER_CPU(tvec_base_t *, tvec_bases) = &boot_tvec_bases;
  * @j: the time in (absolute) jiffies that should be rounded
  * @cpu: the processor number on which the timeout will happen
  *
- * __round_jiffies rounds an absolute time in the future (in jiffies)
+ * __round_jiffies() rounds an absolute time in the future (in jiffies)
  * up or down to (approximately) full seconds. This is useful for timers
  * for which the exact time they fire does not matter too much, as long as
  * they fire approximately every X seconds.
@@ -98,7 +98,7 @@ static DEFINE_PER_CPU(tvec_base_t *, tvec_bases) = &boot_tvec_bases;
  * processors firing at the exact same time, which could lead
  * to lock contention or spurious cache line bouncing.
  *
- * The return value is the rounded version of the "j" parameter.
+ * The return value is the rounded version of the @j parameter.
  */
 unsigned long __round_jiffies(unsigned long j, int cpu)
 {
@@ -142,7 +142,7 @@ EXPORT_SYMBOL_GPL(__round_jiffies);
  * @j: the time in (relative) jiffies that should be rounded
  * @cpu: the processor number on which the timeout will happen
  *
- * __round_jiffies_relative rounds a time delta  in the future (in jiffies)
+ * __round_jiffies_relative() rounds a time delta  in the future (in jiffies)
  * up or down to (approximately) full seconds. This is useful for timers
  * for which the exact time they fire does not matter too much, as long as
  * they fire approximately every X seconds.
@@ -155,7 +155,7 @@ EXPORT_SYMBOL_GPL(__round_jiffies);
  * processors firing at the exact same time, which could lead
  * to lock contention or spurious cache line bouncing.
  *
- * The return value is the rounded version of the "j" parameter.
+ * The return value is the rounded version of the @j parameter.
  */
 unsigned long __round_jiffies_relative(unsigned long j, int cpu)
 {
@@ -173,7 +173,7 @@ EXPORT_SYMBOL_GPL(__round_jiffies_relative);
  * round_jiffies - function to round jiffies to a full second
  * @j: the time in (absolute) jiffies that should be rounded
  *
- * round_jiffies rounds an absolute time in the future (in jiffies)
+ * round_jiffies() rounds an absolute time in the future (in jiffies)
  * up or down to (approximately) full seconds. This is useful for timers
  * for which the exact time they fire does not matter too much, as long as
  * they fire approximately every X seconds.
@@ -182,7 +182,7 @@ EXPORT_SYMBOL_GPL(__round_jiffies_relative);
  * at the same time, rather than at various times spread out. The goal
  * of this is to have the CPU wake up less, which saves power.
  *
- * The return value is the rounded version of the "j" parameter.
+ * The return value is the rounded version of the @j parameter.
  */
 unsigned long round_jiffies(unsigned long j)
 {
@@ -194,7 +194,7 @@ EXPORT_SYMBOL_GPL(round_jiffies);
  * round_jiffies_relative - function to round jiffies to a full second
  * @j: the time in (relative) jiffies that should be rounded
  *
- * round_jiffies_relative rounds a time delta  in the future (in jiffies)
+ * round_jiffies_relative() rounds a time delta  in the future (in jiffies)
  * up or down to (approximately) full seconds. This is useful for timers
  * for which the exact time they fire does not matter too much, as long as
  * they fire approximately every X seconds.
@@ -203,7 +203,7 @@ EXPORT_SYMBOL_GPL(round_jiffies);
  * at the same time, rather than at various times spread out. The goal
  * of this is to have the CPU wake up less, which saves power.
  *
- * The return value is the rounded version of the "j" parameter.
+ * The return value is the rounded version of the @j parameter.
  */
 unsigned long round_jiffies_relative(unsigned long j)
 {
@@ -387,7 +387,7 @@ void add_timer_on(struct timer_list *timer, int cpu)
  * @timer: the timer to be modified
  * @expires: new timeout in jiffies
  *
- * mod_timer is a more efficient way to update the expire field of an
+ * mod_timer() is a more efficient way to update the expire field of an
  * active timer (if the timer is inactive it will be activated)
  *
  * mod_timer(timer, expires) is equivalent to:
@@ -490,7 +490,7 @@ out:
  * the timer it also makes sure the handler has finished executing on other
  * CPUs.
  *
- * Synchronization rules: callers must prevent restarting of the timer,
+ * Synchronization rules: Callers must prevent restarting of the timer,
  * otherwise this function is meaningless. It must not be called from
  * interrupt contexts. The caller must not hold locks which would prevent
  * completion of the timer's handler. The timer's handler must not call
@@ -1392,17 +1392,16 @@ asmlinkage long sys_gettid(void)
 }
 
 /**
- * sys_sysinfo - fill in sysinfo struct
+ * do_sysinfo - fill in sysinfo struct
  * @info: pointer to buffer to fill
  */ 
-asmlinkage long sys_sysinfo(struct sysinfo __user *info)
+int do_sysinfo(struct sysinfo *info)
 {
-       struct sysinfo val;
        unsigned long mem_total, sav_total;
        unsigned int mem_unit, bitcount;
        unsigned long seq;
 
-       memset((char *)&val, 0, sizeof(struct sysinfo));
+       memset(info, 0, sizeof(struct sysinfo));
 
        do {
                struct timespec tp;
@@ -1422,17 +1421,17 @@ asmlinkage long sys_sysinfo(struct sysinfo __user *info)
                        tp.tv_nsec = tp.tv_nsec - NSEC_PER_SEC;
                        tp.tv_sec++;
                }
-               val.uptime = tp.tv_sec + (tp.tv_nsec ? 1 : 0);
+               info->uptime = tp.tv_sec + (tp.tv_nsec ? 1 : 0);
 
-               val.loads[0] = avenrun[0] << (SI_LOAD_SHIFT - FSHIFT);
-               val.loads[1] = avenrun[1] << (SI_LOAD_SHIFT - FSHIFT);
-               val.loads[2] = avenrun[2] << (SI_LOAD_SHIFT - FSHIFT);
+               info->loads[0] = avenrun[0] << (SI_LOAD_SHIFT - FSHIFT);
+               info->loads[1] = avenrun[1] << (SI_LOAD_SHIFT - FSHIFT);
+               info->loads[2] = avenrun[2] << (SI_LOAD_SHIFT - FSHIFT);
 
-               val.procs = nr_threads;
+               info->procs = nr_threads;
        } while (read_seqretry(&xtime_lock, seq));
 
-       si_meminfo(&val);
-       si_swapinfo(&val);
+       si_meminfo(info);
+       si_swapinfo(info);
 
        /*
         * If the sum of all the available memory (i.e. ram + swap)
@@ -1443,11 +1442,11 @@ asmlinkage long sys_sysinfo(struct sysinfo __user *info)
         *  -Erik Andersen <andersee@debian.org>
         */
 
-       mem_total = val.totalram + val.totalswap;
-       if (mem_total < val.totalram || mem_total < val.totalswap)
+       mem_total = info->totalram + info->totalswap;
+       if (mem_total < info->totalram || mem_total < info->totalswap)
                goto out;
        bitcount = 0;
-       mem_unit = val.mem_unit;
+       mem_unit = info->mem_unit;
        while (mem_unit > 1) {
                bitcount++;
                mem_unit >>= 1;
@@ -1459,22 +1458,31 @@ asmlinkage long sys_sysinfo(struct sysinfo __user *info)
 
        /*
         * If mem_total did not overflow, multiply all memory values by
-        * val.mem_unit and set it to 1.  This leaves things compatible
+        * info->mem_unit and set it to 1.  This leaves things compatible
         * with 2.2.x, and also retains compatibility with earlier 2.4.x
         * kernels...
         */
 
-       val.mem_unit = 1;
-       val.totalram <<= bitcount;
-       val.freeram <<= bitcount;
-       val.sharedram <<= bitcount;
-       val.bufferram <<= bitcount;
-       val.totalswap <<= bitcount;
-       val.freeswap <<= bitcount;
-       val.totalhigh <<= bitcount;
-       val.freehigh <<= bitcount;
+       info->mem_unit = 1;
+       info->totalram <<= bitcount;
+       info->freeram <<= bitcount;
+       info->sharedram <<= bitcount;
+       info->bufferram <<= bitcount;
+       info->totalswap <<= bitcount;
+       info->freeswap <<= bitcount;
+       info->totalhigh <<= bitcount;
+       info->freehigh <<= bitcount;
+
+out:
+       return 0;
+}
+
+asmlinkage long sys_sysinfo(struct sysinfo __user *info)
+{
+       struct sysinfo val;
+
+       do_sysinfo(&val);
 
- out:
        if (copy_to_user(info, &val, sizeof(struct sysinfo)))
                return -EFAULT;
 
@@ -1624,7 +1632,7 @@ struct time_interpolator *time_interpolator __read_mostly;
 static struct time_interpolator *time_interpolator_list __read_mostly;
 static DEFINE_SPINLOCK(time_interpolator_lock);
 
-static inline u64 time_interpolator_get_cycles(unsigned int src)
+static inline cycles_t time_interpolator_get_cycles(unsigned int src)
 {
        unsigned long (*x)(void);
 
@@ -1650,8 +1658,8 @@ static inline u64 time_interpolator_get_counter(int writelock)
 
        if (time_interpolator->jitter)
        {
-               u64 lcycle;
-               u64 now;
+               cycles_t lcycle;
+               cycles_t now;
 
                do {
                        lcycle = time_interpolator->last_cycle;
index a3da07c5af2835f57f094cddd20e731a8a77bdb5..020d1fff57dce7839735bf7df6362a57ff747b55 100644 (file)
@@ -656,8 +656,7 @@ void flush_scheduled_work(void)
 EXPORT_SYMBOL(flush_scheduled_work);
 
 /**
- * cancel_rearming_delayed_workqueue - reliably kill off a delayed
- *                     work whose handler rearms the delayed work.
+ * cancel_rearming_delayed_workqueue - reliably kill off a delayed work whose handler rearms the delayed work.
  * @wq:   the controlling workqueue structure
  * @dwork: the delayed work struct
  */
@@ -670,8 +669,7 @@ void cancel_rearming_delayed_workqueue(struct workqueue_struct *wq,
 EXPORT_SYMBOL(cancel_rearming_delayed_workqueue);
 
 /**
- * cancel_rearming_delayed_work - reliably kill off a delayed keventd
- *                     work whose handler rearms the delayed work.
+ * cancel_rearming_delayed_work - reliably kill off a delayed keventd work whose handler rearms the delayed work.
  * @dwork: the delayed work struct
  */
 void cancel_rearming_delayed_work(struct delayed_work *dwork)
index 9b03581cdecb3d746186e1c0fa1ab2685cdbcfcc..384249915047f0e28f8f82c10caa6b9795f4fb3b 100644 (file)
@@ -101,9 +101,14 @@ config TEXTSEARCH_FSM
 config PLIST
        boolean
 
-config IOMAP_COPY
+config HAS_IOMEM
        boolean
-       depends on !UML
+       depends on !NO_IOMEM
+       default y
+
+config HAS_IOPORT
+       boolean
+       depends on HAS_IOMEM && !NO_IOPORT
        default y
 
 endmenu
index 5c2681875b9ac31b1a363c63d909120cbc82b930..356a5ab8279c397db62fbf20951b8af94b1e9ae8 100644 (file)
@@ -181,19 +181,11 @@ config DEBUG_MUTEXES
         This feature allows mutex semantics violations to be detected and
         reported.
 
-config DEBUG_RWSEMS
-       bool "RW-sem debugging: basic checks"
-       depends on DEBUG_KERNEL
-       help
-        This feature allows read-write semaphore semantics violations to
-        be detected and reported.
-
 config DEBUG_LOCK_ALLOC
        bool "Lock debugging: detect incorrect freeing of live locks"
        depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
        select DEBUG_SPINLOCK
        select DEBUG_MUTEXES
-       select DEBUG_RWSEMS
        select LOCKDEP
        help
         This feature will check whether any held lock (spinlock, rwlock,
@@ -209,7 +201,6 @@ config PROVE_LOCKING
        select LOCKDEP
        select DEBUG_SPINLOCK
        select DEBUG_MUTEXES
-       select DEBUG_RWSEMS
        select DEBUG_LOCK_ALLOC
        default n
        help
index 77b4bad7d441be4185001773a14ebf71aae06d32..992a39ef9ffd2167ac3a7e63dabefcf1715a5edb 100644 (file)
@@ -3,7 +3,7 @@
 #
 
 lib-y := ctype.o string.o vsprintf.o cmdline.o \
-        bust_spinlocks.o rbtree.o radix-tree.o dump_stack.o \
+        rbtree.o radix-tree.o dump_stack.o \
         idr.o div64.o int_sqrt.o bitmap.o extable.o prio_tree.o \
         sha1.o irq_regs.o reciprocal_div.o
 
@@ -12,14 +12,15 @@ lib-$(CONFIG_SMP) += cpumask.o
 
 lib-y  += kobject.o kref.o kobject_uevent.o klist.o
 
-obj-y += sort.o parser.o halfmd4.o debug_locks.o random32.o
+obj-y += sort.o parser.o halfmd4.o debug_locks.o random32.o bust_spinlocks.o
 
 ifeq ($(CONFIG_DEBUG_KOBJECT),y)
 CFLAGS_kobject.o += -DDEBUG
 CFLAGS_kobject_uevent.o += -DDEBUG
 endif
 
-obj-$(CONFIG_IOMAP_COPY) += iomap_copy.o
+obj-$(CONFIG_GENERIC_IOMAP) += iomap.o
+obj-$(CONFIG_HAS_IOMEM) += iomap_copy.o devres.o
 obj-$(CONFIG_DEBUG_LOCKING_API_SELFTESTS) += locking-selftest.o
 obj-$(CONFIG_DEBUG_SPINLOCK) += spinlock_debug.o
 lib-$(CONFIG_RWSEM_GENERIC_SPINLOCK) += rwsem-spinlock.o
@@ -41,7 +42,6 @@ obj-$(CONFIG_CRC_CCITT)       += crc-ccitt.o
 obj-$(CONFIG_CRC16)    += crc16.o
 obj-$(CONFIG_CRC32)    += crc32.o
 obj-$(CONFIG_LIBCRC32C)        += libcrc32c.o
-obj-$(CONFIG_GENERIC_IOMAP) += iomap.o
 obj-$(CONFIG_GENERIC_ALLOCATOR) += genalloc.o
 
 obj-$(CONFIG_ZLIB_INFLATE) += zlib_inflate/
index 037fa9aa2ed77f554296c7f1f4b64f769fdd2a73..ee6e58fce8f75f675c2688294b07e01655a4396e 100644 (file)
@@ -95,7 +95,7 @@ void __bitmap_complement(unsigned long *dst, const unsigned long *src, int bits)
 }
 EXPORT_SYMBOL(__bitmap_complement);
 
-/*
+/**
  * __bitmap_shift_right - logical right shift of the bits in a bitmap
  *   @dst - destination bitmap
  *   @src - source bitmap
@@ -139,7 +139,7 @@ void __bitmap_shift_right(unsigned long *dst,
 EXPORT_SYMBOL(__bitmap_shift_right);
 
 
-/*
+/**
  * __bitmap_shift_left - logical left shift of the bits in a bitmap
  *   @dst - destination bitmap
  *   @src - source bitmap
@@ -529,7 +529,7 @@ int bitmap_parselist(const char *bp, unsigned long *maskp, int nmaskbits)
 }
 EXPORT_SYMBOL(bitmap_parselist);
 
-/*
+/**
  * bitmap_pos_to_ord(buf, pos, bits)
  *     @buf: pointer to a bitmap
  *     @pos: a bit position in @buf (0 <= @pos < @bits)
@@ -804,7 +804,7 @@ EXPORT_SYMBOL(bitmap_find_free_region);
  *     @pos: beginning of bit region to release
  *     @order: region size (log base 2 of number of bits) to release
  *
- * This is the complement to __bitmap_find_free_region and releases
+ * This is the complement to __bitmap_find_free_region() and releases
  * the found region (by clearing it in the bitmap).
  *
  * No return value.
index a2055bc3ef623d1b2f4659bdbd7dfe729ae47aa6..accb3565816993630ab98bc7818f3afe75307fa5 100644 (file)
 #include <linux/vt_kern.h>
 
 
-void bust_spinlocks(int yes)
+void __attribute__((weak)) bust_spinlocks(int yes)
 {
        if (yes) {
                oops_in_progress = 1;
        } else {
-               int loglevel_save = console_loglevel;
 #ifdef CONFIG_VT
                unblank_screen();
 #endif
                oops_in_progress = 0;
-               /*
-                * OK, the message is on the console.  Now we call printk()
-                * without oops_in_progress set so that printk() will give klogd
-                * and the blanked console a poke.  Hold onto your hats...
-                */
-               console_loglevel = 15;          /* NMI oopser may have shut the console up */
-               printk(" ");
-               console_loglevel = loglevel_save;
+               wake_up_klogd();
        }
 }
 
index 8a5b5303bd4f7a78187b4138eb08945c6333c10c..f596c08d213a0726c5f395209a3e20d730c3ea2c 100644 (file)
@@ -43,10 +43,10 @@ static int get_range(char **str, int *pint)
  *     comma as well.
  *
  *     Return values:
- *     0 : no int in string
- *     1 : int found, no subsequent comma
- *     2 : int found including a subsequent comma
- *     3 : hyphen found to denote a range
+ *     0 - no int in string
+ *     1 - int found, no subsequent comma
+ *     2 - int found including a subsequent comma
+ *     3 - hyphen found to denote a range
  */
 
 int get_option (char **str, int *pint)
diff --git a/lib/devres.c b/lib/devres.c
new file mode 100644 (file)
index 0000000..2a668dd
--- /dev/null
@@ -0,0 +1,300 @@
+#include <linux/pci.h>
+#include <linux/io.h>
+#include <linux/module.h>
+
+static void devm_ioremap_release(struct device *dev, void *res)
+{
+       iounmap(*(void __iomem **)res);
+}
+
+static int devm_ioremap_match(struct device *dev, void *res, void *match_data)
+{
+       return *(void **)res == match_data;
+}
+
+/**
+ * devm_ioremap - Managed ioremap()
+ * @dev: Generic device to remap IO address for
+ * @offset: BUS offset to map
+ * @size: Size of map
+ *
+ * Managed ioremap().  Map is automatically unmapped on driver detach.
+ */
+void __iomem *devm_ioremap(struct device *dev, unsigned long offset,
+                          unsigned long size)
+{
+       void __iomem **ptr, *addr;
+
+       ptr = devres_alloc(devm_ioremap_release, sizeof(*ptr), GFP_KERNEL);
+       if (!ptr)
+               return NULL;
+
+       addr = ioremap(offset, size);
+       if (addr) {
+               *ptr = addr;
+               devres_add(dev, ptr);
+       } else
+               devres_free(ptr);
+
+       return addr;
+}
+EXPORT_SYMBOL(devm_ioremap);
+
+/**
+ * devm_ioremap_nocache - Managed ioremap_nocache()
+ * @dev: Generic device to remap IO address for
+ * @offset: BUS offset to map
+ * @size: Size of map
+ *
+ * Managed ioremap_nocache().  Map is automatically unmapped on driver
+ * detach.
+ */
+void __iomem *devm_ioremap_nocache(struct device *dev, unsigned long offset,
+                                  unsigned long size)
+{
+       void __iomem **ptr, *addr;
+
+       ptr = devres_alloc(devm_ioremap_release, sizeof(*ptr), GFP_KERNEL);
+       if (!ptr)
+               return NULL;
+
+       addr = ioremap_nocache(offset, size);
+       if (addr) {
+               *ptr = addr;
+               devres_add(dev, ptr);
+       } else
+               devres_free(ptr);
+
+       return addr;
+}
+EXPORT_SYMBOL(devm_ioremap_nocache);
+
+/**
+ * devm_iounmap - Managed iounmap()
+ * @dev: Generic device to unmap for
+ * @addr: Address to unmap
+ *
+ * Managed iounmap().  @addr must have been mapped using devm_ioremap*().
+ */
+void devm_iounmap(struct device *dev, void __iomem *addr)
+{
+       iounmap(addr);
+       WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
+                              (void *)addr));
+}
+EXPORT_SYMBOL(devm_iounmap);
+
+#ifdef CONFIG_HAS_IOPORT
+/*
+ * Generic iomap devres
+ */
+static void devm_ioport_map_release(struct device *dev, void *res)
+{
+       ioport_unmap(*(void __iomem **)res);
+}
+
+static int devm_ioport_map_match(struct device *dev, void *res,
+                                void *match_data)
+{
+       return *(void **)res == match_data;
+}
+
+/**
+ * devm_ioport_map - Managed ioport_map()
+ * @dev: Generic device to map ioport for
+ * @port: Port to map
+ * @nr: Number of ports to map
+ *
+ * Managed ioport_map().  Map is automatically unmapped on driver
+ * detach.
+ */
+void __iomem * devm_ioport_map(struct device *dev, unsigned long port,
+                              unsigned int nr)
+{
+       void __iomem **ptr, *addr;
+
+       ptr = devres_alloc(devm_ioport_map_release, sizeof(*ptr), GFP_KERNEL);
+       if (!ptr)
+               return NULL;
+
+       addr = ioport_map(port, nr);
+       if (addr) {
+               *ptr = addr;
+               devres_add(dev, ptr);
+       } else
+               devres_free(ptr);
+
+       return addr;
+}
+EXPORT_SYMBOL(devm_ioport_map);
+
+/**
+ * devm_ioport_unmap - Managed ioport_unmap()
+ * @dev: Generic device to unmap for
+ * @addr: Address to unmap
+ *
+ * Managed ioport_unmap().  @addr must have been mapped using
+ * devm_ioport_map().
+ */
+void devm_ioport_unmap(struct device *dev, void __iomem *addr)
+{
+       ioport_unmap(addr);
+       WARN_ON(devres_destroy(dev, devm_ioport_map_release,
+                              devm_ioport_map_match, (void *)addr));
+}
+EXPORT_SYMBOL(devm_ioport_unmap);
+
+#ifdef CONFIG_PCI
+/*
+ * PCI iomap devres
+ */
+#define PCIM_IOMAP_MAX PCI_ROM_RESOURCE
+
+struct pcim_iomap_devres {
+       void __iomem *table[PCIM_IOMAP_MAX];
+};
+
+static void pcim_iomap_release(struct device *gendev, void *res)
+{
+       struct pci_dev *dev = container_of(gendev, struct pci_dev, dev);
+       struct pcim_iomap_devres *this = res;
+       int i;
+
+       for (i = 0; i < PCIM_IOMAP_MAX; i++)
+               if (this->table[i])
+                       pci_iounmap(dev, this->table[i]);
+}
+
+/**
+ * pcim_iomap_table - access iomap allocation table
+ * @pdev: PCI device to access iomap table for
+ *
+ * Access iomap allocation table for @dev.  If iomap table doesn't
+ * exist and @pdev is managed, it will be allocated.  All iomaps
+ * recorded in the iomap table are automatically unmapped on driver
+ * detach.
+ *
+ * This function might sleep when the table is first allocated but can
+ * be safely called without context and guaranteed to succed once
+ * allocated.
+ */
+void __iomem * const * pcim_iomap_table(struct pci_dev *pdev)
+{
+       struct pcim_iomap_devres *dr, *new_dr;
+
+       dr = devres_find(&pdev->dev, pcim_iomap_release, NULL, NULL);
+       if (dr)
+               return dr->table;
+
+       new_dr = devres_alloc(pcim_iomap_release, sizeof(*new_dr), GFP_KERNEL);
+       if (!new_dr)
+               return NULL;
+       dr = devres_get(&pdev->dev, new_dr, NULL, NULL);
+       return dr->table;
+}
+EXPORT_SYMBOL(pcim_iomap_table);
+
+/**
+ * pcim_iomap - Managed pcim_iomap()
+ * @pdev: PCI device to iomap for
+ * @bar: BAR to iomap
+ * @maxlen: Maximum length of iomap
+ *
+ * Managed pci_iomap().  Map is automatically unmapped on driver
+ * detach.
+ */
+void __iomem * pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen)
+{
+       void __iomem **tbl;
+
+       BUG_ON(bar >= PCIM_IOMAP_MAX);
+
+       tbl = (void __iomem **)pcim_iomap_table(pdev);
+       if (!tbl || tbl[bar])   /* duplicate mappings not allowed */
+               return NULL;
+
+       tbl[bar] = pci_iomap(pdev, bar, maxlen);
+       return tbl[bar];
+}
+EXPORT_SYMBOL(pcim_iomap);
+
+/**
+ * pcim_iounmap - Managed pci_iounmap()
+ * @pdev: PCI device to iounmap for
+ * @addr: Address to unmap
+ *
+ * Managed pci_iounmap().  @addr must have been mapped using pcim_iomap().
+ */
+void pcim_iounmap(struct pci_dev *pdev, void __iomem *addr)
+{
+       void __iomem **tbl;
+       int i;
+
+       pci_iounmap(pdev, addr);
+
+       tbl = (void __iomem **)pcim_iomap_table(pdev);
+       BUG_ON(!tbl);
+
+       for (i = 0; i < PCIM_IOMAP_MAX; i++)
+               if (tbl[i] == addr) {
+                       tbl[i] = NULL;
+                       return;
+               }
+       WARN_ON(1);
+}
+EXPORT_SYMBOL(pcim_iounmap);
+
+/**
+ * pcim_iomap_regions - Request and iomap PCI BARs
+ * @pdev: PCI device to map IO resources for
+ * @mask: Mask of BARs to request and iomap
+ * @name: Name used when requesting regions
+ *
+ * Request and iomap regions specified by @mask.
+ */
+int pcim_iomap_regions(struct pci_dev *pdev, u16 mask, const char *name)
+{
+       void __iomem * const *iomap;
+       int i, rc;
+
+       iomap = pcim_iomap_table(pdev);
+       if (!iomap)
+               return -ENOMEM;
+
+       for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
+               unsigned long len;
+
+               if (!(mask & (1 << i)))
+                       continue;
+
+               rc = -EINVAL;
+               len = pci_resource_len(pdev, i);
+               if (!len)
+                       goto err_inval;
+
+               rc = pci_request_region(pdev, i, name);
+               if (rc)
+                       goto err_region;
+
+               rc = -ENOMEM;
+               if (!pcim_iomap(pdev, i, 0))
+                       goto err_iomap;
+       }
+
+       return 0;
+
+ err_iomap:
+       pcim_iounmap(pdev, iomap[i]);
+ err_region:
+       pci_release_region(pdev, i);
+ err_inval:
+       while (--i >= 0) {
+               pcim_iounmap(pdev, iomap[i]);
+               pci_release_region(pdev, i);
+       }
+
+       return rc;
+}
+EXPORT_SYMBOL(pcim_iomap_regions);
+#endif
+#endif
index 71853531d3b0f6be6c0db0420ca8d646dd884469..305117ca2d415a1adf91700fe34a06d88028de67 100644 (file)
--- a/lib/idr.c
+++ b/lib/idr.c
@@ -329,8 +329,8 @@ static void sub_remove(struct idr *idp, int shift, int id)
 
 /**
  * idr_remove - remove the given id and free it's slot
- * idp: idr handle
- * id: uniqueue key
+ * @idp: idr handle
+ * @id: unique key
  */
 void idr_remove(struct idr *idp, int id)
 {
index d6ccdd85df5311a4326bf584920a1293dc11243c..4d43f37c01544de2b19e46bd259bdbe3fc5b7caf 100644 (file)
@@ -4,8 +4,9 @@
  * (C) Copyright 2004 Linus Torvalds
  */
 #include <linux/pci.h>
+#include <linux/io.h>
+
 #include <linux/module.h>
-#include <asm/io.h>
 
 /*
  * Read/write from/to an (offsettable) iomem cookie. It might be a PIO
index c2917ffe8bf11a024c34eb8729a9e87872bcfb5d..2782f49e906ec3e2315028041ca54681239e55a7 100644 (file)
@@ -97,11 +97,12 @@ static void fill_kobj_path(struct kobject *kobj, char *path, int length)
 }
 
 /**
- * kobject_get_path - generate and return the path associated with a given kobj
- * and kset pair.  The result must be freed by the caller with kfree().
+ * kobject_get_path - generate and return the path associated with a given kobj and kset pair.
  *
  * @kobj:      kobject in question, with which to build the path
  * @gfp_mask:  the allocation type used to allocate the path
+ *
+ * The result must be freed by the caller with kfree().
  */
 char *kobject_get_path(struct kobject *kobj, gfp_t gfp_mask)
 {
index 1cdabe3065f932d1edde271b2421ce6844ccb84c..4c45fd50e91367041d825a1146291a829b900eff 100644 (file)
@@ -20,8 +20,8 @@
 #define K3  0x8F1BBCDCL                        /* Rounds 40-59: sqrt(5) * 2^30 */
 #define K4  0xCA62C1D6L                        /* Rounds 60-79: sqrt(10) * 2^30 */
 
-/*
- * sha_transform: single block SHA1 transform
+/**
+ * sha_transform - single block SHA1 transform
  *
  * @digest: 160 bit digest to update
  * @data:   512 bits of data to hash
@@ -80,9 +80,8 @@ void sha_transform(__u32 *digest, const char *in, __u32 *W)
 }
 EXPORT_SYMBOL(sha_transform);
 
-/*
- * sha_init: initialize the vectors for a SHA1 digest
- *
+/**
+ * sha_init - initialize the vectors for a SHA1 digest
  * @buf: vector to initialize
  */
 void sha_init(__u32 *buf)
index 488788b341cb01960b92163b9326ec85c2a33445..961567894d16b89a208244ea957e44a3d9afd668 100644 (file)
@@ -27,7 +27,7 @@ static void generic_swap(void *a, void *b, int size)
        } while (--size > 0);
 }
 
-/*
+/**
  * sort - sort an array of elements
  * @base: pointer to data to sort
  * @num: number of elements
index a485d75962af5f7a6bbb4f819aa780c812fe25ca..bab440fb0dfcb99dfe46453350f7b6e9298c89eb 100644 (file)
@@ -160,7 +160,7 @@ EXPORT_SYMBOL(strcat);
  * @src: The string to append to it
  * @count: The maximum numbers of bytes to copy
  *
- * Note that in contrast to strncpy, strncat ensures the result is
+ * Note that in contrast to strncpy(), strncat() ensures the result is
  * terminated.
  */
 char *strncat(char *dest, const char *src, size_t count)
@@ -366,8 +366,7 @@ EXPORT_SYMBOL(strnlen);
 
 #ifndef __HAVE_ARCH_STRSPN
 /**
- * strspn - Calculate the length of the initial substring of @s which only
- *     contain letters in @accept
+ * strspn - Calculate the length of the initial substring of @s which only contain letters in @accept
  * @s: The string to be searched
  * @accept: The string to search for
  */
@@ -394,8 +393,7 @@ EXPORT_SYMBOL(strspn);
 
 #ifndef __HAVE_ARCH_STRCSPN
 /**
- * strcspn - Calculate the length of the initial substring of @s which does
- *     not contain letters in @reject
+ * strcspn - Calculate the length of the initial substring of @s which does not contain letters in @reject
  * @s: The string to be searched
  * @reject: The string to avoid
  */
index 98bcadc0118523faeaf8443d4aeb248520c9798d..9e2a002c5b543305105c69a77410177882538b1b 100644 (file)
@@ -218,7 +218,7 @@ static unsigned int get_linear_data(unsigned int consumed, const u8 **dst,
  * Call textsearch_next() to retrieve subsequent matches.
  *
  * Returns the position of first occurrence of the pattern or
- * UINT_MAX if no occurrence was found.
+ * %UINT_MAX if no occurrence was found.
  */ 
 unsigned int textsearch_find_continuous(struct ts_config *conf,
                                        struct ts_state *state,
index bed7229378f2da073be0c25eda0a30bf07146380..44f0e339a9474cd9499d13177a8ae823a172951f 100644 (file)
@@ -247,12 +247,12 @@ static char * number(char * buf, char * end, unsigned long long num, int base, i
  * be generated for the given input, excluding the trailing
  * '\0', as per ISO C99. If you want to have the exact
  * number of characters written into @buf as return value
- * (not including the trailing '\0'), use vscnprintf. If the
+ * (not including the trailing '\0'), use vscnprintf(). If the
  * return is greater than or equal to @size, the resulting
  * string is truncated.
  *
  * Call this function if you are already dealing with a va_list.
- * You probably want snprintf instead.
+ * You probably want snprintf() instead.
  */
 int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
 {
@@ -509,7 +509,7 @@ EXPORT_SYMBOL(vsnprintf);
  * returns 0.
  *
  * Call this function if you are already dealing with a va_list.
- * You probably want scnprintf instead.
+ * You probably want scnprintf() instead.
  */
 int vscnprintf(char *buf, size_t size, const char *fmt, va_list args)
 {
@@ -577,11 +577,11 @@ EXPORT_SYMBOL(scnprintf);
  * @args: Arguments for the format string
  *
  * The function returns the number of characters written
- * into @buf. Use vsnprintf or vscnprintf in order to avoid
+ * into @buf. Use vsnprintf() or vscnprintf() in order to avoid
  * buffer overflows.
  *
  * Call this function if you are already dealing with a va_list.
- * You probably want sprintf instead.
+ * You probably want sprintf() instead.
  */
 int vsprintf(char *buf, const char *fmt, va_list args)
 {
@@ -597,7 +597,7 @@ EXPORT_SYMBOL(vsprintf);
  * @...: Arguments for the format string
  *
  * The function returns the number of characters written
- * into @buf. Use snprintf or scnprintf in order to avoid
+ * into @buf. Use snprintf() or scnprintf() in order to avoid
  * buffer overflows.
  */
 int sprintf(char * buf, const char *fmt, ...)
index db7c55de92cdc2ded0583d1ccc5239bdb4828d00..7942b333e46cd46c11ac0f4a849c7b98efeee58e 100644 (file)
@@ -157,3 +157,9 @@ config RESOURCES_64BIT
        default 64BIT
        help
          This option allows memory and IO resources to be 64 bit.
+
+config ZONE_DMA_FLAG
+       int
+       default "0" if !ZONE_DMA
+       default "1"
+
index 8332c77b1bd123fdd76b2a9b2d966711a45b124b..00414849a86712c40ce174c900fe9b67cc9eb096 100644 (file)
@@ -327,7 +327,7 @@ EXPORT_SYMBOL(sync_page_range);
  * @pos:       beginning offset in pages to write
  * @count:     number of bytes to write
  *
- * Note: Holding i_mutex across sync_page_range_nolock is not a good idea
+ * Note: Holding i_mutex across sync_page_range_nolock() is not a good idea
  * as it forces O_SYNC writers to different parts of the same file
  * to be serialised right until io completion.
  */
@@ -605,26 +605,6 @@ struct page * find_get_page(struct address_space *mapping, unsigned long offset)
 }
 EXPORT_SYMBOL(find_get_page);
 
-/**
- * find_trylock_page - find and lock a page
- * @mapping: the address_space to search
- * @offset: the page index
- *
- * Same as find_get_page(), but trylock it instead of incrementing the count.
- */
-struct page *find_trylock_page(struct address_space *mapping, unsigned long offset)
-{
-       struct page *page;
-
-       read_lock_irq(&mapping->tree_lock);
-       page = radix_tree_lookup(&mapping->page_tree, offset);
-       if (page && TestSetPageLocked(page))
-               page = NULL;
-       read_unlock_irq(&mapping->tree_lock);
-       return page;
-}
-EXPORT_SYMBOL(find_trylock_page);
-
 /**
  * find_lock_page - locate, pin and lock a pagecache page
  * @mapping: the address_space to search
@@ -804,7 +784,7 @@ unsigned find_get_pages_tag(struct address_space *mapping, pgoff_t *index,
  * @mapping: target address_space
  * @index: the page index
  *
- * Same as grab_cache_page, but do not wait if the page is unavailable.
+ * Same as grab_cache_page(), but do not wait if the page is unavailable.
  * This is intended for speculative data generators, where the data can
  * be regenerated if the page couldn't be grabbed.  This routine should
  * be safe to call while holding the lock for another page.
index 0206e7e5018c8998c87349706fe1fcfb5644933c..51e1c1995fec1d87a1e8e80d4518008d4ec4f4f1 100644 (file)
@@ -47,7 +47,8 @@ unsigned int nr_free_highpages (void)
        unsigned int pages = 0;
 
        for_each_online_pgdat(pgdat)
-               pages += pgdat->node_zones[ZONE_HIGHMEM].free_pages;
+               pages += zone_page_state(&pgdat->node_zones[ZONE_HIGHMEM],
+                       NR_FREE_PAGES);
 
        return pages;
 }
index cb362f761f174b926c1c41b72ec2940c5d45763d..36db012b38dde252c827d0af4719c2e7b79e5083 100644 (file)
@@ -389,6 +389,8 @@ void __unmap_hugepage_range(struct vm_area_struct *vma, unsigned long start,
                        continue;
 
                page = pte_page(pte);
+               if (pte_dirty(pte))
+                       set_page_dirty(page);
                list_add(&page->lru, &page_list);
        }
        spin_unlock(&mm->page_table_lock);
index ef09f0acb1d8efc25fed1a524cada7cab48d40ef..072c1135ad372f4f6dd5dc8931794db01a816fa7 100644 (file)
@@ -678,7 +678,7 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb,
                                if (pte_dirty(ptent))
                                        set_page_dirty(page);
                                if (pte_young(ptent))
-                                       mark_page_accessed(page);
+                                       SetPageReferenced(page);
                                file_rss--;
                        }
                        page_remove_rmap(page, vma);
@@ -1531,8 +1531,6 @@ static int do_wp_page(struct mm_struct *mm, struct vm_area_struct *vma,
                        if (vma->vm_ops->page_mkwrite(vma, old_page) < 0)
                                goto unwritable_page;
 
-                       page_cache_release(old_page);
-
                        /*
                         * Since we dropped the lock we need to revalidate
                         * the PTE as someone else may have changed it.  If
@@ -1541,6 +1539,7 @@ static int do_wp_page(struct mm_struct *mm, struct vm_area_struct *vma,
                         */
                        page_table = pte_offset_map_lock(mm, pmd, address,
                                                         &ptl);
+                       page_cache_release(old_page);
                        if (!pte_same(*page_table, orig_pte))
                                goto unlock;
                }
@@ -1776,9 +1775,7 @@ restart:
 }
 
 /**
- * unmap_mapping_range - unmap the portion of all mmaps
- * in the specified address_space corresponding to the specified
- * page range in the underlying file.
+ * unmap_mapping_range - unmap the portion of all mmaps in the specified address_space corresponding to the specified page range in the underlying file.
  * @mapping: the address space containing mmaps to be unmapped.
  * @holebegin: byte in first page to unmap, relative to the start of
  * the underlying file.  This will be rounded down to a PAGE_SIZE
index c2aec0e1090d03d540dc43d5b35388b044679c81..259a706bd83ec5d3392b37dcf093b2c3ec953145 100644 (file)
@@ -105,7 +105,7 @@ static struct kmem_cache *sn_cache;
 
 /* Highest zone. An specific allocation for a zone below that is not
    policied. */
-enum zone_type policy_zone = ZONE_DMA;
+enum zone_type policy_zone = 0;
 
 struct mempolicy default_policy = {
        .refcnt = ATOMIC_INIT(1), /* never free it */
index ccd8cb8cd41f59fc19e2198bfb2862ad72d62ff9..cc1ca86dfc2496b6e0cae7703d4a6dc4f4f97150 100644 (file)
@@ -46,9 +46,9 @@ static void free_pool(mempool_t *pool)
  * @pool_data: optional private data available to the user-defined functions.
  *
  * this function creates and allocates a guaranteed size, preallocated
- * memory pool. The pool can be used from the mempool_alloc and mempool_free
+ * memory pool. The pool can be used from the mempool_alloc() and mempool_free()
  * functions. This function might sleep. Both the alloc_fn() and the free_fn()
- * functions might sleep - as long as the mempool_alloc function is not called
+ * functions might sleep - as long as the mempool_alloc() function is not called
  * from IRQ contexts.
  */
 mempool_t *mempool_create(int min_nr, mempool_alloc_t *alloc_fn,
@@ -195,7 +195,7 @@ EXPORT_SYMBOL(mempool_destroy);
  *             mempool_create().
  * @gfp_mask:  the usual allocation bitmask.
  *
- * this function only sleeps if the alloc_fn function sleeps or
+ * this function only sleeps if the alloc_fn() function sleeps or
  * returns NULL. Note that due to preallocation, this function
  * *never* fails when called from process contexts. (it might
  * fail if called from an IRQ context.)
index cc3a208194576482bb6f94223ba522c35daeed14..eb509ae76553260c61a4b17b3b8bc7deca663b25 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2101,3 +2101,75 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
                return 0;
        return 1;
 }
+
+
+static struct page *special_mapping_nopage(struct vm_area_struct *vma,
+                                          unsigned long address, int *type)
+{
+       struct page **pages;
+
+       BUG_ON(address < vma->vm_start || address >= vma->vm_end);
+
+       address -= vma->vm_start;
+       for (pages = vma->vm_private_data; address > 0 && *pages; ++pages)
+               address -= PAGE_SIZE;
+
+       if (*pages) {
+               struct page *page = *pages;
+               get_page(page);
+               return page;
+       }
+
+       return NOPAGE_SIGBUS;
+}
+
+/*
+ * Having a close hook prevents vma merging regardless of flags.
+ */
+static void special_mapping_close(struct vm_area_struct *vma)
+{
+}
+
+static struct vm_operations_struct special_mapping_vmops = {
+       .close = special_mapping_close,
+       .nopage = special_mapping_nopage,
+};
+
+/*
+ * Called with mm->mmap_sem held for writing.
+ * Insert a new vma covering the given region, with the given flags.
+ * Its pages are supplied by the given array of struct page *.
+ * The array can be shorter than len >> PAGE_SHIFT if it's null-terminated.
+ * The region past the last page supplied will always produce SIGBUS.
+ * The array pointer and the pages it points to are assumed to stay alive
+ * for as long as this mapping might exist.
+ */
+int install_special_mapping(struct mm_struct *mm,
+                           unsigned long addr, unsigned long len,
+                           unsigned long vm_flags, struct page **pages)
+{
+       struct vm_area_struct *vma;
+
+       vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
+       if (unlikely(vma == NULL))
+               return -ENOMEM;
+
+       vma->vm_mm = mm;
+       vma->vm_start = addr;
+       vma->vm_end = addr + len;
+
+       vma->vm_flags = vm_flags | mm->def_flags;
+       vma->vm_page_prot = protection_map[vma->vm_flags & 7];
+
+       vma->vm_ops = &special_mapping_vmops;
+       vma->vm_private_data = pages;
+
+       if (unlikely(insert_vm_struct(mm, vma))) {
+               kmem_cache_free(vm_area_cachep, vma);
+               return -ENOMEM;
+       }
+
+       mm->total_vm += len >> PAGE_SHIFT;
+
+       return 0;
+}
index be0efbde4994f5454198384ce274b62eb827adc4..f7e088f5a309eff3a03c8da5ad4ca4b37ecd5518 100644 (file)
@@ -515,7 +515,7 @@ static int __cpuinit
 ratelimit_handler(struct notifier_block *self, unsigned long u, void *v)
 {
        writeback_set_ratelimit();
-       return 0;
+       return NOTIFY_DONE;
 }
 
 static struct notifier_block __cpuinitdata ratelimit_nb = {
@@ -549,9 +549,7 @@ void __init page_writeback_init(void)
 }
 
 /**
- * generic_writepages - walk the list of dirty pages of the given
- *                      address space and writepage() all of them.
- *
+ * generic_writepages - walk the list of dirty pages of the given address space and writepage() all of them.
  * @mapping: address space structure to write
  * @wbc: subtract the number of written pages from *@wbc->nr_to_write
  *
@@ -698,7 +696,6 @@ int do_writepages(struct address_space *mapping, struct writeback_control *wbc)
 
 /**
  * write_one_page - write out a single page and optionally wait on I/O
- *
  * @page: the page to write
  * @wait: if true, wait on writeout
  *
@@ -736,6 +733,16 @@ int write_one_page(struct page *page, int wait)
 }
 EXPORT_SYMBOL(write_one_page);
 
+/*
+ * For address_spaces which do not use buffers nor write back.
+ */
+int __set_page_dirty_no_writeback(struct page *page)
+{
+       if (!PageDirty(page))
+               SetPageDirty(page);
+       return 0;
+}
+
 /*
  * For address_spaces which do not use buffers.  Just tag the page as dirty in
  * its radix tree.
index 2c606cc922a50cc212b6f4abd6e8635356ebb99e..d461b23a27a1176decc9229edf45c8ae1c388472 100644 (file)
@@ -73,7 +73,9 @@ static void __free_pages_ok(struct page *page, unsigned int order);
  * don't need any ZONE_NORMAL reservation
  */
 int sysctl_lowmem_reserve_ratio[MAX_NR_ZONES-1] = {
+#ifdef CONFIG_ZONE_DMA
         256,
+#endif
 #ifdef CONFIG_ZONE_DMA32
         256,
 #endif
@@ -85,7 +87,9 @@ int sysctl_lowmem_reserve_ratio[MAX_NR_ZONES-1] = {
 EXPORT_SYMBOL(totalram_pages);
 
 static char * const zone_names[MAX_NR_ZONES] = {
+#ifdef CONFIG_ZONE_DMA
         "DMA",
+#endif
 #ifdef CONFIG_ZONE_DMA32
         "DMA32",
 #endif
@@ -395,7 +399,7 @@ static inline void __free_one_page(struct page *page,
        VM_BUG_ON(page_idx & (order_size - 1));
        VM_BUG_ON(bad_range(zone, page));
 
-       zone->free_pages += order_size;
+       __mod_zone_page_state(zone, NR_FREE_PAGES, order_size);
        while (order < MAX_ORDER-1) {
                unsigned long combined_idx;
                struct free_area *area;
@@ -631,7 +635,7 @@ static struct page *__rmqueue(struct zone *zone, unsigned int order)
                list_del(&page->lru);
                rmv_page_order(page);
                area->nr_free--;
-               zone->free_pages -= 1UL << order;
+               __mod_zone_page_state(zone, NR_FREE_PAGES, - (1UL << order));
                expand(zone, page, order, current_order, area);
                return page;
        }
@@ -989,7 +993,8 @@ int zone_watermark_ok(struct zone *z, int order, unsigned long mark,
                      int classzone_idx, int alloc_flags)
 {
        /* free_pages my go negative - that's OK */
-       long min = mark, free_pages = z->free_pages - (1 << order) + 1;
+       long min = mark;
+       long free_pages = zone_page_state(z, NR_FREE_PAGES) - (1 << order) + 1;
        int o;
 
        if (alloc_flags & ALLOC_HIGH)
@@ -1439,35 +1444,6 @@ fastcall void free_pages(unsigned long addr, unsigned int order)
 
 EXPORT_SYMBOL(free_pages);
 
-/*
- * Total amount of free (allocatable) RAM:
- */
-unsigned int nr_free_pages(void)
-{
-       unsigned int sum = 0;
-       struct zone *zone;
-
-       for_each_zone(zone)
-               sum += zone->free_pages;
-
-       return sum;
-}
-
-EXPORT_SYMBOL(nr_free_pages);
-
-#ifdef CONFIG_NUMA
-unsigned int nr_free_pages_pgdat(pg_data_t *pgdat)
-{
-       unsigned int sum = 0;
-       enum zone_type i;
-
-       for (i = 0; i < MAX_NR_ZONES; i++)
-               sum += pgdat->node_zones[i].free_pages;
-
-       return sum;
-}
-#endif
-
 static unsigned int nr_free_zone_pages(int offset)
 {
        /* Just pick one node, since fallback list is circular */
@@ -1514,7 +1490,7 @@ void si_meminfo(struct sysinfo *val)
 {
        val->totalram = totalram_pages;
        val->sharedram = 0;
-       val->freeram = nr_free_pages();
+       val->freeram = global_page_state(NR_FREE_PAGES);
        val->bufferram = nr_blockdev_pages();
        val->totalhigh = totalhigh_pages;
        val->freehigh = nr_free_highpages();
@@ -1529,10 +1505,11 @@ void si_meminfo_node(struct sysinfo *val, int nid)
        pg_data_t *pgdat = NODE_DATA(nid);
 
        val->totalram = pgdat->node_present_pages;
-       val->freeram = nr_free_pages_pgdat(pgdat);
+       val->freeram = node_page_state(nid, NR_FREE_PAGES);
 #ifdef CONFIG_HIGHMEM
        val->totalhigh = pgdat->node_zones[ZONE_HIGHMEM].present_pages;
-       val->freehigh = pgdat->node_zones[ZONE_HIGHMEM].free_pages;
+       val->freehigh = zone_page_state(&pgdat->node_zones[ZONE_HIGHMEM],
+                       NR_FREE_PAGES);
 #else
        val->totalhigh = 0;
        val->freehigh = 0;
@@ -1551,9 +1528,6 @@ void si_meminfo_node(struct sysinfo *val, int nid)
 void show_free_areas(void)
 {
        int cpu;
-       unsigned long active;
-       unsigned long inactive;
-       unsigned long free;
        struct zone *zone;
 
        for_each_zone(zone) {
@@ -1577,20 +1551,19 @@ void show_free_areas(void)
                }
        }
 
-       get_zone_counts(&active, &inactive, &free);
-
-       printk("Active:%lu inactive:%lu dirty:%lu writeback:%lu "
-               "unstable:%lu free:%u slab:%lu mapped:%lu pagetables:%lu\n",
-               active,
-               inactive,
+       printk("Active:%lu inactive:%lu dirty:%lu writeback:%lu unstable:%lu\n"
+               " free:%lu slab:%lu mapped:%lu pagetables:%lu bounce:%lu\n",
+               global_page_state(NR_ACTIVE),
+               global_page_state(NR_INACTIVE),
                global_page_state(NR_FILE_DIRTY),
                global_page_state(NR_WRITEBACK),
                global_page_state(NR_UNSTABLE_NFS),
-               nr_free_pages(),
+               global_page_state(NR_FREE_PAGES),
                global_page_state(NR_SLAB_RECLAIMABLE) +
                        global_page_state(NR_SLAB_UNRECLAIMABLE),
                global_page_state(NR_FILE_MAPPED),
-               global_page_state(NR_PAGETABLE));
+               global_page_state(NR_PAGETABLE),
+               global_page_state(NR_BOUNCE));
 
        for_each_zone(zone) {
                int i;
@@ -1611,12 +1584,12 @@ void show_free_areas(void)
                        " all_unreclaimable? %s"
                        "\n",
                        zone->name,
-                       K(zone->free_pages),
+                       K(zone_page_state(zone, NR_FREE_PAGES)),
                        K(zone->pages_min),
                        K(zone->pages_low),
                        K(zone->pages_high),
-                       K(zone->nr_active),
-                       K(zone->nr_inactive),
+                       K(zone_page_state(zone, NR_ACTIVE)),
+                       K(zone_page_state(zone, NR_INACTIVE)),
                        K(zone->present_pages),
                        zone->pages_scanned,
                        (zone->all_unreclaimable ? "yes" : "no")
@@ -2650,11 +2623,11 @@ static void __meminit free_area_init_core(struct pglist_data *pgdat,
                                "  %s zone: %lu pages exceeds realsize %lu\n",
                                zone_names[j], memmap_pages, realsize);
 
-               /* Account for reserved DMA pages */
-               if (j == ZONE_DMA && realsize > dma_reserve) {
+               /* Account for reserved pages */
+               if (j == 0 && realsize > dma_reserve) {
                        realsize -= dma_reserve;
-                       printk(KERN_DEBUG "  DMA zone: %lu pages reserved\n",
-                                                               dma_reserve);
+                       printk(KERN_DEBUG "  %s zone: %lu pages reserved\n",
+                                       zone_names[0], dma_reserve);
                }
 
                if (!is_highmem_idx(j))
@@ -2674,7 +2647,6 @@ static void __meminit free_area_init_core(struct pglist_data *pgdat,
                spin_lock_init(&zone->lru_lock);
                zone_seqlock_init(zone);
                zone->zone_pgdat = pgdat;
-               zone->free_pages = 0;
 
                zone->prev_priority = DEF_PRIORITY;
 
@@ -2683,8 +2655,6 @@ static void __meminit free_area_init_core(struct pglist_data *pgdat,
                INIT_LIST_HEAD(&zone->inactive_list);
                zone->nr_scan_active = 0;
                zone->nr_scan_inactive = 0;
-               zone->nr_active = 0;
-               zone->nr_inactive = 0;
                zap_zone_vm_stats(zone);
                atomic_set(&zone->reclaim_in_progress, 0);
                if (!size)
@@ -2876,20 +2846,23 @@ static void __init sort_node_map(void)
                        cmp_node_active_region, NULL);
 }
 
-/* Find the lowest pfn for a node. This depends on a sorted early_node_map */
+/* Find the lowest pfn for a node */
 unsigned long __init find_min_pfn_for_node(unsigned long nid)
 {
        int i;
-
-       /* Regions in the early_node_map can be in any order */
-       sort_node_map();
+       unsigned long min_pfn = ULONG_MAX;
 
        /* Assuming a sorted map, the first range found has the starting pfn */
        for_each_active_range_index_in_nid(i, nid)
-               return early_node_map[i].start_pfn;
+               min_pfn = min(min_pfn, early_node_map[i].start_pfn);
 
-       printk(KERN_WARNING "Could not find start_pfn for node %lu\n", nid);
-       return 0;
+       if (min_pfn == ULONG_MAX) {
+               printk(KERN_WARNING
+                       "Could not find start_pfn for node %lu\n", nid);
+               return 0;
+       }
+
+       return min_pfn;
 }
 
 /**
@@ -2938,6 +2911,9 @@ void __init free_area_init_nodes(unsigned long *max_zone_pfn)
        unsigned long nid;
        enum zone_type i;
 
+       /* Sort early_node_map as initialisation assumes it is sorted */
+       sort_node_map();
+
        /* Record where the zone boundaries are */
        memset(arch_zone_lowest_possible_pfn, 0,
                                sizeof(arch_zone_lowest_possible_pfn));
index 0f539e8e827a7a1b0956c30d30ea89434b02bc26..93d9ee692fd8b193b12ba207f69f900c831e404d 100644 (file)
@@ -575,10 +575,6 @@ void handle_ra_miss(struct address_space *mapping,
  */
 unsigned long max_sane_readahead(unsigned long nr)
 {
-       unsigned long active;
-       unsigned long inactive;
-       unsigned long free;
-
-       __get_zone_counts(&active, &inactive, &free, NODE_DATA(numa_node_id()));
-       return min(nr, (inactive + free) / 2);
+       return min(nr, (node_page_state(numa_node_id(), NR_INACTIVE)
+               + node_page_state(numa_node_id(), NR_FREE_PAGES)) / 2);
 }
index 70da7a0981bfbad9683b5e9b0747277256a678ff..b38e17169271b3664dd35f7281048eb116ef37b1 100644 (file)
@@ -2316,7 +2316,7 @@ static void destroy_inodecache(void)
 
 static const struct address_space_operations shmem_aops = {
        .writepage      = shmem_writepage,
-       .set_page_dirty = __set_page_dirty_nobuffers,
+       .set_page_dirty = __set_page_dirty_no_writeback,
 #ifdef CONFIG_TMPFS
        .prepare_write  = shmem_prepare_write,
        .commit_write   = simple_commit_write,
index c6100628a6ef7be2325a55e18f69b80a5a0f2006..70784b848b69b475718f0090033770b7c17b511b 100644 (file)
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -793,8 +793,10 @@ static inline struct kmem_cache *__find_general_cachep(size_t size,
         * has cs_{dma,}cachep==NULL. Thus no special case
         * for large kmalloc calls required.
         */
+#ifdef CONFIG_ZONE_DMA
        if (unlikely(gfpflags & GFP_DMA))
                return csizep->cs_dmacachep;
+#endif
        return csizep->cs_cachep;
 }
 
@@ -1493,13 +1495,15 @@ void __init kmem_cache_init(void)
                                        ARCH_KMALLOC_FLAGS|SLAB_PANIC,
                                        NULL, NULL);
                }
-
-               sizes->cs_dmacachep = kmem_cache_create(names->name_dma,
+#ifdef CONFIG_ZONE_DMA
+               sizes->cs_dmacachep = kmem_cache_create(
+                                       names->name_dma,
                                        sizes->cs_size,
                                        ARCH_KMALLOC_MINALIGN,
                                        ARCH_KMALLOC_FLAGS|SLAB_CACHE_DMA|
                                                SLAB_PANIC,
                                        NULL, NULL);
+#endif
                sizes++;
                names++;
        }
@@ -2321,7 +2325,7 @@ kmem_cache_create (const char *name, size_t size, size_t align,
        cachep->slab_size = slab_size;
        cachep->flags = flags;
        cachep->gfpflags = 0;
-       if (flags & SLAB_CACHE_DMA)
+       if (CONFIG_ZONE_DMA_FLAG && (flags & SLAB_CACHE_DMA))
                cachep->gfpflags |= GFP_DMA;
        cachep->buffer_size = size;
        cachep->reciprocal_buffer_size = reciprocal_value(size);
@@ -2516,7 +2520,7 @@ EXPORT_SYMBOL(kmem_cache_shrink);
  * kmem_cache_destroy - delete a cache
  * @cachep: the cache to destroy
  *
- * Remove a struct kmem_cache object from the slab cache.
+ * Remove a &struct kmem_cache object from the slab cache.
  *
  * It is expected this function will be called by a module when it is
  * unloaded.  This will remove the cache completely, and avoid a duplicate
@@ -2643,10 +2647,12 @@ static void cache_init_objs(struct kmem_cache *cachep,
 
 static void kmem_flagcheck(struct kmem_cache *cachep, gfp_t flags)
 {
-       if (flags & GFP_DMA)
-               BUG_ON(!(cachep->gfpflags & GFP_DMA));
-       else
-               BUG_ON(cachep->gfpflags & GFP_DMA);
+       if (CONFIG_ZONE_DMA_FLAG) {
+               if (flags & GFP_DMA)
+                       BUG_ON(!(cachep->gfpflags & GFP_DMA));
+               else
+                       BUG_ON(cachep->gfpflags & GFP_DMA);
+       }
 }
 
 static void *slab_get_obj(struct kmem_cache *cachep, struct slab *slabp,
@@ -2814,19 +2820,11 @@ failed:
  */
 static void kfree_debugcheck(const void *objp)
 {
-       struct page *page;
-
        if (!virt_addr_valid(objp)) {
                printk(KERN_ERR "kfree_debugcheck: out of range ptr %lxh.\n",
                       (unsigned long)objp);
                BUG();
        }
-       page = virt_to_page(objp);
-       if (!PageSlab(page)) {
-               printk(KERN_ERR "kfree_debugcheck: bad ptr %lxh.\n",
-                      (unsigned long)objp);
-               BUG();
-       }
 }
 
 static inline void verify_redzone_free(struct kmem_cache *cache, void *obj)
@@ -3197,35 +3195,6 @@ static inline void *____cache_alloc(struct kmem_cache *cachep, gfp_t flags)
        return objp;
 }
 
-static __always_inline void *__cache_alloc(struct kmem_cache *cachep,
-                                               gfp_t flags, void *caller)
-{
-       unsigned long save_flags;
-       void *objp = NULL;
-
-       cache_alloc_debugcheck_before(cachep, flags);
-
-       local_irq_save(save_flags);
-
-       if (unlikely(NUMA_BUILD &&
-                       current->flags & (PF_SPREAD_SLAB | PF_MEMPOLICY)))
-               objp = alternate_node_alloc(cachep, flags);
-
-       if (!objp)
-               objp = ____cache_alloc(cachep, flags);
-       /*
-        * We may just have run out of memory on the local node.
-        * ____cache_alloc_node() knows how to locate memory on other nodes
-        */
-       if (NUMA_BUILD && !objp)
-               objp = ____cache_alloc_node(cachep, flags, numa_node_id());
-       local_irq_restore(save_flags);
-       objp = cache_alloc_debugcheck_after(cachep, flags, objp,
-                                           caller);
-       prefetchw(objp);
-       return objp;
-}
-
 #ifdef CONFIG_NUMA
 /*
  * Try allocating on another node if PF_SPREAD_SLAB|PF_MEMPOLICY.
@@ -3257,14 +3226,20 @@ static void *alternate_node_alloc(struct kmem_cache *cachep, gfp_t flags)
  * allocator to do its reclaim / fallback magic. We then insert the
  * slab into the proper nodelist and then allocate from it.
  */
-void *fallback_alloc(struct kmem_cache *cache, gfp_t flags)
+static void *fallback_alloc(struct kmem_cache *cache, gfp_t flags)
 {
-       struct zonelist *zonelist = &NODE_DATA(slab_node(current->mempolicy))
-                                       ->node_zonelists[gfp_zone(flags)];
+       struct zonelist *zonelist;
+       gfp_t local_flags;
        struct zone **z;
        void *obj = NULL;
        int nid;
-       gfp_t local_flags = (flags & GFP_LEVEL_MASK);
+
+       if (flags & __GFP_THISNODE)
+               return NULL;
+
+       zonelist = &NODE_DATA(slab_node(current->mempolicy))
+                       ->node_zonelists[gfp_zone(flags)];
+       local_flags = (flags & GFP_LEVEL_MASK);
 
 retry:
        /*
@@ -3374,16 +3349,110 @@ must_grow:
        if (x)
                goto retry;
 
-       if (!(flags & __GFP_THISNODE))
-               /* Unable to grow the cache. Fall back to other nodes. */
-               return fallback_alloc(cachep, flags);
-
-       return NULL;
+       return fallback_alloc(cachep, flags);
 
 done:
        return obj;
 }
-#endif
+
+/**
+ * kmem_cache_alloc_node - Allocate an object on the specified node
+ * @cachep: The cache to allocate from.
+ * @flags: See kmalloc().
+ * @nodeid: node number of the target node.
+ * @caller: return address of caller, used for debug information
+ *
+ * Identical to kmem_cache_alloc but it will allocate memory on the given
+ * node, which can improve the performance for cpu bound structures.
+ *
+ * Fallback to other node is possible if __GFP_THISNODE is not set.
+ */
+static __always_inline void *
+__cache_alloc_node(struct kmem_cache *cachep, gfp_t flags, int nodeid,
+                  void *caller)
+{
+       unsigned long save_flags;
+       void *ptr;
+
+       cache_alloc_debugcheck_before(cachep, flags);
+       local_irq_save(save_flags);
+
+       if (unlikely(nodeid == -1))
+               nodeid = numa_node_id();
+
+       if (unlikely(!cachep->nodelists[nodeid])) {
+               /* Node not bootstrapped yet */
+               ptr = fallback_alloc(cachep, flags);
+               goto out;
+       }
+
+       if (nodeid == numa_node_id()) {
+               /*
+                * Use the locally cached objects if possible.
+                * However ____cache_alloc does not allow fallback
+                * to other nodes. It may fail while we still have
+                * objects on other nodes available.
+                */
+               ptr = ____cache_alloc(cachep, flags);
+               if (ptr)
+                       goto out;
+       }
+       /* ___cache_alloc_node can fall back to other nodes */
+       ptr = ____cache_alloc_node(cachep, flags, nodeid);
+  out:
+       local_irq_restore(save_flags);
+       ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
+
+       return ptr;
+}
+
+static __always_inline void *
+__do_cache_alloc(struct kmem_cache *cache, gfp_t flags)
+{
+       void *objp;
+
+       if (unlikely(current->flags & (PF_SPREAD_SLAB | PF_MEMPOLICY))) {
+               objp = alternate_node_alloc(cache, flags);
+               if (objp)
+                       goto out;
+       }
+       objp = ____cache_alloc(cache, flags);
+
+       /*
+        * We may just have run out of memory on the local node.
+        * ____cache_alloc_node() knows how to locate memory on other nodes
+        */
+       if (!objp)
+               objp = ____cache_alloc_node(cache, flags, numa_node_id());
+
+  out:
+       return objp;
+}
+#else
+
+static __always_inline void *
+__do_cache_alloc(struct kmem_cache *cachep, gfp_t flags)
+{
+       return ____cache_alloc(cachep, flags);
+}
+
+#endif /* CONFIG_NUMA */
+
+static __always_inline void *
+__cache_alloc(struct kmem_cache *cachep, gfp_t flags, void *caller)
+{
+       unsigned long save_flags;
+       void *objp;
+
+       cache_alloc_debugcheck_before(cachep, flags);
+       local_irq_save(save_flags);
+       objp = __do_cache_alloc(cachep, flags);
+       local_irq_restore(save_flags);
+       objp = cache_alloc_debugcheck_after(cachep, flags, objp, caller);
+       prefetchw(objp);
+
+       return objp;
+}
 
 /*
  * Caller needs to acquire correct kmem_list's list_lock
@@ -3582,57 +3651,6 @@ out:
 }
 
 #ifdef CONFIG_NUMA
-/**
- * kmem_cache_alloc_node - Allocate an object on the specified node
- * @cachep: The cache to allocate from.
- * @flags: See kmalloc().
- * @nodeid: node number of the target node.
- * @caller: return address of caller, used for debug information
- *
- * Identical to kmem_cache_alloc but it will allocate memory on the given
- * node, which can improve the performance for cpu bound structures.
- *
- * Fallback to other node is possible if __GFP_THISNODE is not set.
- */
-static __always_inline void *
-__cache_alloc_node(struct kmem_cache *cachep, gfp_t flags,
-               int nodeid, void *caller)
-{
-       unsigned long save_flags;
-       void *ptr = NULL;
-
-       cache_alloc_debugcheck_before(cachep, flags);
-       local_irq_save(save_flags);
-
-       if (unlikely(nodeid == -1))
-               nodeid = numa_node_id();
-
-       if (likely(cachep->nodelists[nodeid])) {
-               if (nodeid == numa_node_id()) {
-                       /*
-                        * Use the locally cached objects if possible.
-                        * However ____cache_alloc does not allow fallback
-                        * to other nodes. It may fail while we still have
-                        * objects on other nodes available.
-                        */
-                       ptr = ____cache_alloc(cachep, flags);
-               }
-               if (!ptr) {
-                       /* ___cache_alloc_node can fall back to other nodes */
-                       ptr = ____cache_alloc_node(cachep, flags, nodeid);
-               }
-       } else {
-               /* Node not bootstrapped yet */
-               if (!(flags & __GFP_THISNODE))
-                       ptr = fallback_alloc(cachep, flags);
-       }
-
-       local_irq_restore(save_flags);
-       ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
-
-       return ptr;
-}
-
 void *kmem_cache_alloc_node(struct kmem_cache *cachep, gfp_t flags, int nodeid)
 {
        return __cache_alloc_node(cachep, flags, nodeid,
@@ -3733,6 +3751,7 @@ void kmem_cache_free(struct kmem_cache *cachep, void *objp)
        BUG_ON(virt_to_cache(objp) != cachep);
 
        local_irq_save(flags);
+       debug_check_no_locks_freed(objp, obj_size(cachep));
        __cache_free(cachep, objp);
        local_irq_restore(flags);
 }
@@ -4017,18 +4036,17 @@ void drain_array(struct kmem_cache *cachep, struct kmem_list3 *l3,
  * If we cannot acquire the cache chain mutex then just give up - we'll try
  * again on the next iteration.
  */
-static void cache_reap(struct work_struct *unused)
+static void cache_reap(struct work_struct *w)
 {
        struct kmem_cache *searchp;
        struct kmem_list3 *l3;
        int node = numa_node_id();
+       struct delayed_work *work =
+               container_of(w, struct delayed_work, work);
 
-       if (!mutex_trylock(&cache_chain_mutex)) {
+       if (!mutex_trylock(&cache_chain_mutex))
                /* Give up. Setup the next iteration. */
-               schedule_delayed_work(&__get_cpu_var(reap_work),
-                                     round_jiffies_relative(REAPTIMEOUT_CPUC));
-               return;
-       }
+               goto out;
 
        list_for_each_entry(searchp, &cache_chain, next) {
                check_irq_on();
@@ -4071,9 +4089,9 @@ next:
        mutex_unlock(&cache_chain_mutex);
        next_reap_node();
        refresh_cpu_vm_stats(smp_processor_id());
+out:
        /* Set up the next iteration */
-       schedule_delayed_work(&__get_cpu_var(reap_work),
-               round_jiffies_relative(REAPTIMEOUT_CPUC));
+       schedule_delayed_work(work, round_jiffies_relative(REAPTIMEOUT_CPUC));
 }
 
 #ifdef CONFIG_PROC_FS
index 5df947de7654461d43f1ba0a7ab80b46747239c8..ebf3fcb4115b8c664e54e4c47e02968ed93ab0be 100644 (file)
@@ -85,7 +85,7 @@ EXPORT_SYMBOL(cancel_dirty_page);
  *
  * We need to bale out if page->mapping is no longer equal to the original
  * mapping.  This happens a) when the VM reclaimed the page while we waited on
- * its lock, b) when a concurrent invalidate_inode_pages got there first and
+ * its lock, b) when a concurrent invalidate_mapping_pages got there first and
  * c) when tmpfs swizzles a page between a tmpfs inode and swapper_space.
  */
 static void
@@ -106,7 +106,7 @@ truncate_complete_page(struct address_space *mapping, struct page *page)
 }
 
 /*
- * This is for invalidate_inode_pages().  That function can be called at
+ * This is for invalidate_mapping_pages().  That function can be called at
  * any time, and is not supposed to throw away dirty pages.  But pages can
  * be marked dirty at any time too, so use remove_mapping which safely
  * discards clean, unused pages.
@@ -310,12 +310,7 @@ unlock:
        }
        return ret;
 }
-
-unsigned long invalidate_inode_pages(struct address_space *mapping)
-{
-       return invalidate_mapping_pages(mapping, 0, ~0UL);
-}
-EXPORT_SYMBOL(invalidate_inode_pages);
+EXPORT_SYMBOL(invalidate_mapping_pages);
 
 /*
  * This is like invalidate_complete_page(), except it ignores the page's
index 86897ee792d6b4a2f8e00a94cf4b12e2c1d6f075..9eef486da9093469fa6a101b05be786a02f0ed14 100644 (file)
@@ -699,7 +699,7 @@ finished:
  *     that it is big enough to cover the vma. Will return failure if
  *     that criteria isn't met.
  *
- *     Similar to remap_pfn_range (see mm/memory.c)
+ *     Similar to remap_pfn_range() (see mm/memory.c)
  */
 int remap_vmalloc_range(struct vm_area_struct *vma, void *addr,
                                                unsigned long pgoff)
index 7430df68cb64aaf2856c7158920442c77fe1cf27..0655d5fe73e82c164043bf99958397602d6846c7 100644 (file)
@@ -679,7 +679,7 @@ static unsigned long shrink_inactive_list(unsigned long max_scan,
                nr_taken = isolate_lru_pages(sc->swap_cluster_max,
                                             &zone->inactive_list,
                                             &page_list, &nr_scan);
-               zone->nr_inactive -= nr_taken;
+               __mod_zone_page_state(zone, NR_INACTIVE, -nr_taken);
                zone->pages_scanned += nr_scan;
                spin_unlock_irq(&zone->lru_lock);
 
@@ -740,7 +740,8 @@ static inline void note_zone_scanning_priority(struct zone *zone, int priority)
 
 static inline int zone_is_near_oom(struct zone *zone)
 {
-       return zone->pages_scanned >= (zone->nr_active + zone->nr_inactive)*3;
+       return zone->pages_scanned >= (zone_page_state(zone, NR_ACTIVE)
+                               + zone_page_state(zone, NR_INACTIVE))*3;
 }
 
 /*
@@ -825,7 +826,7 @@ force_reclaim_mapped:
        pgmoved = isolate_lru_pages(nr_pages, &zone->active_list,
                                    &l_hold, &pgscanned);
        zone->pages_scanned += pgscanned;
-       zone->nr_active -= pgmoved;
+       __mod_zone_page_state(zone, NR_ACTIVE, -pgmoved);
        spin_unlock_irq(&zone->lru_lock);
 
        while (!list_empty(&l_hold)) {
@@ -857,7 +858,7 @@ force_reclaim_mapped:
                list_move(&page->lru, &zone->inactive_list);
                pgmoved++;
                if (!pagevec_add(&pvec, page)) {
-                       zone->nr_inactive += pgmoved;
+                       __mod_zone_page_state(zone, NR_INACTIVE, pgmoved);
                        spin_unlock_irq(&zone->lru_lock);
                        pgdeactivate += pgmoved;
                        pgmoved = 0;
@@ -867,7 +868,7 @@ force_reclaim_mapped:
                        spin_lock_irq(&zone->lru_lock);
                }
        }
-       zone->nr_inactive += pgmoved;
+       __mod_zone_page_state(zone, NR_INACTIVE, pgmoved);
        pgdeactivate += pgmoved;
        if (buffer_heads_over_limit) {
                spin_unlock_irq(&zone->lru_lock);
@@ -885,14 +886,14 @@ force_reclaim_mapped:
                list_move(&page->lru, &zone->active_list);
                pgmoved++;
                if (!pagevec_add(&pvec, page)) {
-                       zone->nr_active += pgmoved;
+                       __mod_zone_page_state(zone, NR_ACTIVE, pgmoved);
                        pgmoved = 0;
                        spin_unlock_irq(&zone->lru_lock);
                        __pagevec_release(&pvec);
                        spin_lock_irq(&zone->lru_lock);
                }
        }
-       zone->nr_active += pgmoved;
+       __mod_zone_page_state(zone, NR_ACTIVE, pgmoved);
 
        __count_zone_vm_events(PGREFILL, zone, pgscanned);
        __count_vm_events(PGDEACTIVATE, pgdeactivate);
@@ -918,14 +919,16 @@ static unsigned long shrink_zone(int priority, struct zone *zone,
         * Add one to `nr_to_scan' just to make sure that the kernel will
         * slowly sift through the active list.
         */
-       zone->nr_scan_active += (zone->nr_active >> priority) + 1;
+       zone->nr_scan_active +=
+               (zone_page_state(zone, NR_ACTIVE) >> priority) + 1;
        nr_active = zone->nr_scan_active;
        if (nr_active >= sc->swap_cluster_max)
                zone->nr_scan_active = 0;
        else
                nr_active = 0;
 
-       zone->nr_scan_inactive += (zone->nr_inactive >> priority) + 1;
+       zone->nr_scan_inactive +=
+               (zone_page_state(zone, NR_INACTIVE) >> priority) + 1;
        nr_inactive = zone->nr_scan_inactive;
        if (nr_inactive >= sc->swap_cluster_max)
                zone->nr_scan_inactive = 0;
@@ -1037,7 +1040,8 @@ unsigned long try_to_free_pages(struct zone **zones, gfp_t gfp_mask)
                if (!cpuset_zone_allowed_hardwall(zone, GFP_KERNEL))
                        continue;
 
-               lru_pages += zone->nr_active + zone->nr_inactive;
+               lru_pages += zone_page_state(zone, NR_ACTIVE)
+                               + zone_page_state(zone, NR_INACTIVE);
        }
 
        for (priority = DEF_PRIORITY; priority >= 0; priority--) {
@@ -1182,7 +1186,8 @@ loop_again:
                for (i = 0; i <= end_zone; i++) {
                        struct zone *zone = pgdat->node_zones + i;
 
-                       lru_pages += zone->nr_active + zone->nr_inactive;
+                       lru_pages += zone_page_state(zone, NR_ACTIVE)
+                                       + zone_page_state(zone, NR_INACTIVE);
                }
 
                /*
@@ -1219,8 +1224,9 @@ loop_again:
                        if (zone->all_unreclaimable)
                                continue;
                        if (nr_slab == 0 && zone->pages_scanned >=
-                                   (zone->nr_active + zone->nr_inactive) * 6)
-                               zone->all_unreclaimable = 1;
+                               (zone_page_state(zone, NR_ACTIVE)
+                               + zone_page_state(zone, NR_INACTIVE)) * 6)
+                                       zone->all_unreclaimable = 1;
                        /*
                         * If we've done a decent amount of scanning and
                         * the reclaim ratio is low, start doing writepage
@@ -1385,18 +1391,22 @@ static unsigned long shrink_all_zones(unsigned long nr_pages, int prio,
 
                /* For pass = 0 we don't shrink the active list */
                if (pass > 0) {
-                       zone->nr_scan_active += (zone->nr_active >> prio) + 1;
+                       zone->nr_scan_active +=
+                               (zone_page_state(zone, NR_ACTIVE) >> prio) + 1;
                        if (zone->nr_scan_active >= nr_pages || pass > 3) {
                                zone->nr_scan_active = 0;
-                               nr_to_scan = min(nr_pages, zone->nr_active);
+                               nr_to_scan = min(nr_pages,
+                                       zone_page_state(zone, NR_ACTIVE));
                                shrink_active_list(nr_to_scan, zone, sc, prio);
                        }
                }
 
-               zone->nr_scan_inactive += (zone->nr_inactive >> prio) + 1;
+               zone->nr_scan_inactive +=
+                       (zone_page_state(zone, NR_INACTIVE) >> prio) + 1;
                if (zone->nr_scan_inactive >= nr_pages || pass > 3) {
                        zone->nr_scan_inactive = 0;
-                       nr_to_scan = min(nr_pages, zone->nr_inactive);
+                       nr_to_scan = min(nr_pages,
+                               zone_page_state(zone, NR_INACTIVE));
                        ret += shrink_inactive_list(nr_to_scan, zone, sc);
                        if (ret >= nr_pages)
                                return ret;
@@ -1408,12 +1418,7 @@ static unsigned long shrink_all_zones(unsigned long nr_pages, int prio,
 
 static unsigned long count_lru_pages(void)
 {
-       struct zone *zone;
-       unsigned long ret = 0;
-
-       for_each_zone(zone)
-               ret += zone->nr_active + zone->nr_inactive;
-       return ret;
+       return global_page_state(NR_ACTIVE) + global_page_state(NR_INACTIVE);
 }
 
 /*
index dc005a0c96ae5a0162b9da79e43d663c61c9422a..6c488d6ac425d948b7b77d78a6cac899be16af6a 100644 (file)
 #include <linux/module.h>
 #include <linux/cpu.h>
 
-void __get_zone_counts(unsigned long *active, unsigned long *inactive,
-                       unsigned long *free, struct pglist_data *pgdat)
-{
-       struct zone *zones = pgdat->node_zones;
-       int i;
-
-       *active = 0;
-       *inactive = 0;
-       *free = 0;
-       for (i = 0; i < MAX_NR_ZONES; i++) {
-               *active += zones[i].nr_active;
-               *inactive += zones[i].nr_inactive;
-               *free += zones[i].free_pages;
-       }
-}
-
-void get_zone_counts(unsigned long *active,
-               unsigned long *inactive, unsigned long *free)
-{
-       struct pglist_data *pgdat;
-
-       *active = 0;
-       *inactive = 0;
-       *free = 0;
-       for_each_online_pgdat(pgdat) {
-               unsigned long l, m, n;
-               __get_zone_counts(&l, &m, &n, pgdat);
-               *active += l;
-               *inactive += m;
-               *free += n;
-       }
-}
-
 #ifdef CONFIG_VM_EVENT_COUNTERS
 DEFINE_PER_CPU(struct vm_event_state, vm_event_states) = {{0}};
 EXPORT_PER_CPU_SYMBOL(vm_event_states);
@@ -239,7 +206,7 @@ EXPORT_SYMBOL(mod_zone_page_state);
  * in between and therefore the atomicity vs. interrupt cannot be exploited
  * in a useful way here.
  */
-static void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
+void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
 {
        struct per_cpu_pageset *pcp = zone_pcp(zone, smp_processor_id());
        s8 *p = pcp->vm_stat_diff + item;
@@ -260,9 +227,8 @@ void __inc_zone_page_state(struct page *page, enum zone_stat_item item)
 }
 EXPORT_SYMBOL(__inc_zone_page_state);
 
-void __dec_zone_page_state(struct page *page, enum zone_stat_item item)
+void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
 {
-       struct zone *zone = page_zone(page);
        struct per_cpu_pageset *pcp = zone_pcp(zone, smp_processor_id());
        s8 *p = pcp->vm_stat_diff + item;
 
@@ -275,6 +241,11 @@ void __dec_zone_page_state(struct page *page, enum zone_stat_item item)
                *p = overstep;
        }
 }
+
+void __dec_zone_page_state(struct page *page, enum zone_stat_item item)
+{
+       __dec_zone_state(page_zone(page), item);
+}
 EXPORT_SYMBOL(__dec_zone_page_state);
 
 void inc_zone_state(struct zone *zone, enum zone_stat_item item)
@@ -437,6 +408,12 @@ const struct seq_operations fragmentation_op = {
        .show   = frag_show,
 };
 
+#ifdef CONFIG_ZONE_DMA
+#define TEXT_FOR_DMA(xx) xx "_dma",
+#else
+#define TEXT_FOR_DMA(xx)
+#endif
+
 #ifdef CONFIG_ZONE_DMA32
 #define TEXT_FOR_DMA32(xx) xx "_dma32",
 #else
@@ -449,19 +426,22 @@ const struct seq_operations fragmentation_op = {
 #define TEXT_FOR_HIGHMEM(xx)
 #endif
 
-#define TEXTS_FOR_ZONES(xx) xx "_dma", TEXT_FOR_DMA32(xx) xx "_normal", \
+#define TEXTS_FOR_ZONES(xx) TEXT_FOR_DMA(xx) TEXT_FOR_DMA32(xx) xx "_normal", \
                                        TEXT_FOR_HIGHMEM(xx)
 
 static const char * const vmstat_text[] = {
        /* Zoned VM counters */
+       "nr_free_pages",
+       "nr_active",
+       "nr_inactive",
        "nr_anon_pages",
        "nr_mapped",
        "nr_file_pages",
+       "nr_dirty",
+       "nr_writeback",
        "nr_slab_reclaimable",
        "nr_slab_unreclaimable",
        "nr_page_table_pages",
-       "nr_dirty",
-       "nr_writeback",
        "nr_unstable",
        "nr_bounce",
        "nr_vmscan_write",
@@ -529,17 +509,13 @@ static int zoneinfo_show(struct seq_file *m, void *arg)
                           "\n        min      %lu"
                           "\n        low      %lu"
                           "\n        high     %lu"
-                          "\n        active   %lu"
-                          "\n        inactive %lu"
                           "\n        scanned  %lu (a: %lu i: %lu)"
                           "\n        spanned  %lu"
                           "\n        present  %lu",
-                          zone->free_pages,
+                          zone_page_state(zone, NR_FREE_PAGES),
                           zone->pages_min,
                           zone->pages_low,
                           zone->pages_high,
-                          zone->nr_active,
-                          zone->nr_inactive,
                           zone->pages_scanned,
                           zone->nr_scan_active, zone->nr_scan_inactive,
                           zone->spanned_pages,
@@ -562,12 +538,6 @@ static int zoneinfo_show(struct seq_file *m, void *arg)
                        int j;
 
                        pageset = zone_pcp(zone, i);
-                       for (j = 0; j < ARRAY_SIZE(pageset->pcp); j++) {
-                               if (pageset->pcp[j].count)
-                                       break;
-                       }
-                       if (j == ARRAY_SIZE(pageset->pcp))
-                               continue;
                        for (j = 0; j < ARRAY_SIZE(pageset->pcp); j++) {
                                seq_printf(m,
                                           "\n    cpu: %i pcp: %i"
index 2a27e37bc4cb263869b0e5a20643997064067713..d64e6a502958315d3f4400610ea5d2889478c1c8 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * NET3:       Fibre Channel device handling subroutines
- * 
+ *
  *             This program is free software; you can redistribute it and/or
  *             modify it under the terms of the GNU General Public License
  *             as published by the Free Software Foundation; either version
 #include <net/arp.h>
 
 /*
- *     Put the headers on a Fibre Channel packet. 
+ *     Put the headers on a Fibre Channel packet.
  */
+
 static int fc_header(struct sk_buff *skb, struct net_device *dev,
                     unsigned short type,
-                    void *daddr, void *saddr, unsigned len) 
+                    void *daddr, void *saddr, unsigned len)
 {
        struct fch_hdr *fch;
        int hdr_len;
 
-       /* 
-        * Add the 802.2 SNAP header if IP as the IPv4 code calls  
+       /*
+        * Add the 802.2 SNAP header if IP as the IPv4 code calls
         * dev->hard_header directly.
         */
        if (type == ETH_P_IP || type == ETH_P_ARP)
@@ -60,7 +60,7 @@ static int fc_header(struct sk_buff *skb, struct net_device *dev,
        else
        {
                hdr_len = sizeof(struct fch_hdr);
-               fch = (struct fch_hdr *)skb_push(skb, hdr_len); 
+               fch = (struct fch_hdr *)skb_push(skb, hdr_len);
        }
 
        if(saddr)
@@ -68,20 +68,20 @@ static int fc_header(struct sk_buff *skb, struct net_device *dev,
        else
                memcpy(fch->saddr,dev->dev_addr,dev->addr_len);
 
-       if(daddr) 
+       if(daddr)
        {
                memcpy(fch->daddr,daddr,dev->addr_len);
                return(hdr_len);
        }
        return -hdr_len;
 }
-       
+
 /*
  *     A neighbour discovery of some species (eg arp) has completed. We
  *     can now send the packet.
  */
-static int fc_rebuild_header(struct sk_buff *skb) 
+
+static int fc_rebuild_header(struct sk_buff *skb)
 {
        struct fch_hdr *fch=(struct fch_hdr *)skb->data;
        struct fcllc *fcllc=(struct fcllc *)(skb->data+sizeof(struct fch_hdr));
@@ -100,7 +100,7 @@ static void fc_setup(struct net_device *dev)
 {
        dev->hard_header        = fc_header;
        dev->rebuild_header     = fc_rebuild_header;
-                
+
        dev->type               = ARPHRD_IEEE802;
        dev->hard_header_len    = FC_HLEN;
        dev->mtu                = 2024;
index 797c6d961deba4468a83d7b1d19eeff23cedec56..0b98fe2fa2f65a8c53eb0991db09a4aa2ed7ff44 100644 (file)
@@ -15,7 +15,7 @@
  *                     Mark Evans, <evansmp@uhura.aston.ac.uk>
  *                     Florian La Roche, <rzsfl@rz.uni-sb.de>
  *                     Alan Cox, <gw4pts@gw4pts.ampr.org>
- * 
+ *
  *             This program is free software; you can redistribute it and/or
  *             modify it under the terms of the GNU General Public License
  *             as published by the Free Software Foundation; either version
@@ -25,7 +25,7 @@
  *             Alan Cox                :       New arp/rebuild header
  *             Maciej W. Rozycki       :       IPv6 support
  */
+
 #include <linux/module.h>
 #include <asm/system.h>
 #include <linux/types.h>
@@ -57,7 +57,7 @@ static int fddi_header(struct sk_buff *skb, struct net_device *dev,
 {
        int hl = FDDI_K_SNAP_HLEN;
        struct fddihdr *fddi;
-       
+
        if(type != ETH_P_IP && type != ETH_P_IPV6 && type != ETH_P_ARP)
                hl=FDDI_K_8022_HLEN-3;
        fddi = (struct fddihdr *)skb_push(skb, hl);
@@ -74,7 +74,7 @@ static int fddi_header(struct sk_buff *skb, struct net_device *dev,
        }
 
        /* Set the source and destination hardware addresses */
-        
+
        if (saddr != NULL)
                memcpy(fddi->saddr, saddr, dev->addr_len);
        else
@@ -95,7 +95,7 @@ static int fddi_header(struct sk_buff *skb, struct net_device *dev,
  * (or in future other address resolution) has completed on
  * this sk_buff.  We now let ARP fill in the other fields.
  */
+
 static int fddi_rebuild_header(struct sk_buff  *skb)
 {
        struct fddihdr *fddi = (struct fddihdr *)skb->data;
@@ -105,7 +105,7 @@ static int fddi_rebuild_header(struct sk_buff       *skb)
                /* Try to get ARP to resolve the header and fill destination address */
                return arp_find(fddi->daddr, skb);
        else
-#endif 
+#endif
        {
                printk("%s: Don't know how to resolve type %04X addresses.\n",
                       skb->dev->name, ntohs(fddi->hdr.llc_snap.ethertype));
@@ -120,19 +120,19 @@ static int fddi_rebuild_header(struct sk_buff     *skb)
  * up.  It's used to fill in specific skb fields and to set
  * the proper pointer to the start of packet data (skb->data).
  */
+
 __be16 fddi_type_trans(struct sk_buff *skb, struct net_device *dev)
 {
        struct fddihdr *fddi = (struct fddihdr *)skb->data;
        __be16 type;
-       
+
        /*
         * Set mac.raw field to point to FC byte, set data field to point
         * to start of packet data.  Assume 802.2 SNAP frames for now.
         */
 
        skb->mac.raw = skb->data;       /* point to frame control (FC) */
-       
+
        if(fddi->hdr.llc_8022_1.dsap==0xe0)
        {
                skb_pull(skb, FDDI_K_8022_HLEN-3);
@@ -143,9 +143,9 @@ __be16 fddi_type_trans(struct sk_buff *skb, struct net_device *dev)
                skb_pull(skb, FDDI_K_SNAP_HLEN);                /* adjust for 21 byte header */
                type=fddi->hdr.llc_snap.ethertype;
        }
-       
+
        /* Set packet type based on destination address and flag settings */
-                       
+
        if (*fddi->daddr & 0x01)
        {
                if (memcmp(fddi->daddr, dev->broadcast, FDDI_K_ALEN) == 0)
@@ -153,7 +153,7 @@ __be16 fddi_type_trans(struct sk_buff *skb, struct net_device *dev)
                else
                        skb->pkt_type = PACKET_MULTICAST;
        }
-       
+
        else if (dev->flags & IFF_PROMISC)
        {
                if (memcmp(fddi->daddr, dev->dev_addr, FDDI_K_ALEN))
@@ -187,7 +187,7 @@ static void fddi_setup(struct net_device *dev)
        dev->addr_len           = FDDI_K_ALEN;
        dev->tx_queue_len       = 100;                  /* Long queues on FDDI */
        dev->flags              = IFF_BROADCAST | IFF_MULTICAST;
-       
+
        memset(dev->broadcast, 0xFF, FDDI_K_ALEN);
 }
 
index 579e2ddf5ebe85dfc701b1ded4a1731b97393662..be0da59323b3cb2faf70404da18f7ab0a9528852 100644 (file)
@@ -39,7 +39,7 @@
 #include <asm/system.h>
 
 /*
- * Create the HIPPI MAC header for an arbitrary protocol layer 
+ * Create the HIPPI MAC header for an arbitrary protocol layer
  *
  * saddr=NULL  means use device source address
  * daddr=NULL  means leave destination address (eg unresolved arp)
@@ -104,8 +104,8 @@ static int hippi_rebuild_header(struct sk_buff *skb)
        /*
         * Only IP is currently supported
         */
-        
-       if(hip->snap.ethertype != __constant_htons(ETH_P_IP)) 
+
+       if(hip->snap.ethertype != __constant_htons(ETH_P_IP))
        {
                printk(KERN_DEBUG "%s: unable to resolve type %X addresses.\n",skb->dev->name,ntohs(hip->snap.ethertype));
                return 0;
@@ -122,11 +122,11 @@ static int hippi_rebuild_header(struct sk_buff *skb)
 /*
  *     Determine the packet's protocol ID.
  */
+
 __be16 hippi_type_trans(struct sk_buff *skb, struct net_device *dev)
 {
        struct hippi_hdr *hip;
-       
+
        hip = (struct hippi_hdr *) skb->data;
 
        /*
@@ -173,10 +173,10 @@ static int hippi_neigh_setup_dev(struct net_device *dev, struct neigh_parms *p)
 {
        /* Never send broadcast/multicast ARP messages */
        p->mcast_probes = 0;
+
        /* In IPv6 unicast probes are valid even on NBMA,
        * because they are encapsulated in normal IPv6 protocol.
-       * Should be a generic flag. 
+       * Should be a generic flag.
        */
        if (p->tbl->family != AF_INET6)
                p->ucast_probes = 0;
@@ -193,7 +193,7 @@ static void hippi_setup(struct net_device *dev)
        dev->hard_header_parse          = NULL;
        dev->hard_header_cache          = NULL;
        dev->header_cache_update        = NULL;
-       dev->neigh_setup                = hippi_neigh_setup_dev; 
+       dev->neigh_setup                = hippi_neigh_setup_dev;
 
        /*
         * We don't support HIPPI `ARP' for the time being, and probably
@@ -210,9 +210,9 @@ static void hippi_setup(struct net_device *dev)
 
        /*
         * HIPPI doesn't support broadcast+multicast and we only use
-        * static ARP tables. ARP is disabled by hippi_neigh_setup_dev. 
+        * static ARP tables. ARP is disabled by hippi_neigh_setup_dev.
         */
-       dev->flags = 0; 
+       dev->flags = 0;
 }
 
 /**
index 270b9d2cae6589b983f9925ee728370aec74cec7..6e7c2120b83ff6a678ca0e3e33f377b713a711cf 100644 (file)
@@ -117,7 +117,7 @@ module_exit(snap_exit);
  */
 struct datalink_proto *register_snap_client(unsigned char *desc,
                                            int (*rcvfunc)(struct sk_buff *,
-                                                          struct net_device *,
+                                                          struct net_device *,
                                                           struct packet_type *,
                                                           struct net_device *))
 {
index 829deb41ce81d436aad10567d03d35ca86532b58..31509f613401a3a788cdce2677ef97f0facba94a 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * NET3:       Token ring device handling subroutines
- * 
+ *
  *             This program is free software; you can redistribute it and/or
  *             modify it under the terms of the GNU General Public License
  *             as published by the Free Software Foundation; either version
@@ -12,7 +12,7 @@
  *              22 Jun 98 Paul Norton <p.norton@computer.org> Rearranged
  *              tr_header and tr_type_trans to handle passing IPX SNAP and
  *              802.2 through the correct layers. Eliminated tr_reformat.
- *        
+ *
  */
 
 #include <asm/uaccess.h>
@@ -45,7 +45,7 @@ static void rif_check_expire(unsigned long dummy);
 /*
  *     Each RIF entry we learn is kept this way
  */
+
 struct rif_cache {
        unsigned char addr[TR_ALEN];
        int iface;
@@ -62,7 +62,7 @@ struct rif_cache {
  *     We hash the RIF cache 32 ways. We do after all have to look it
  *     up a lot.
  */
+
 static struct rif_cache *rif_table[RIF_TABLE_SIZE];
 
 static DEFINE_SPINLOCK(rif_lock);
@@ -71,7 +71,7 @@ static DEFINE_SPINLOCK(rif_lock);
 /*
  *     Garbage disposal timer.
  */
+
 static struct timer_list rif_timer;
 
 int sysctl_tr_rif_timeout = 60*10*HZ;
@@ -96,16 +96,16 @@ static inline unsigned long rif_hash(const unsigned char *addr)
  *     Put the headers on a token ring packet. Token ring source routing
  *     makes this a little more exciting than on ethernet.
  */
+
 static int tr_header(struct sk_buff *skb, struct net_device *dev,
                     unsigned short type,
-                    void *daddr, void *saddr, unsigned len) 
+                    void *daddr, void *saddr, unsigned len)
 {
        struct trh_hdr *trh;
        int hdr_len;
 
-       /* 
-        * Add the 802.2 SNAP header if IP as the IPv4/IPv6 code calls  
+       /*
+        * Add the 802.2 SNAP header if IP as the IPv4/IPv6 code calls
         * dev->hard_header directly.
         */
        if (type == ETH_P_IP || type == ETH_P_IPV6 || type == ETH_P_ARP)
@@ -123,7 +123,7 @@ static int tr_header(struct sk_buff *skb, struct net_device *dev,
        else
        {
                hdr_len = sizeof(struct trh_hdr);
-               trh = (struct trh_hdr *)skb_push(skb, hdr_len); 
+               trh = (struct trh_hdr *)skb_push(skb, hdr_len);
        }
 
        trh->ac=AC;
@@ -137,8 +137,8 @@ static int tr_header(struct sk_buff *skb, struct net_device *dev,
        /*
         *      Build the destination and then source route the frame
         */
-        
-       if(daddr) 
+
+       if(daddr)
        {
                memcpy(trh->daddr,daddr,dev->addr_len);
                tr_source_route(skb,trh,dev);
@@ -147,13 +147,13 @@ static int tr_header(struct sk_buff *skb, struct net_device *dev,
 
        return -hdr_len;
 }
-       
+
 /*
  *     A neighbour discovery of some species (eg arp) has completed. We
  *     can now send the packet.
  */
-static int tr_rebuild_header(struct sk_buff *skb) 
+
+static int tr_rebuild_header(struct sk_buff *skb)
 {
        struct trh_hdr *trh=(struct trh_hdr *)skb->data;
        struct trllc *trllc=(struct trllc *)(skb->data+sizeof(struct trh_hdr));
@@ -162,7 +162,7 @@ static int tr_rebuild_header(struct sk_buff *skb)
        /*
         *      FIXME: We don't yet support IPv6 over token rings
         */
-        
+
        if(trllc->ethertype != htons(ETH_P_IP)) {
                printk("tr_rebuild_header: Don't know how to resolve type %04X addresses ?\n", ntohs(trllc->ethertype));
                return 0;
@@ -172,39 +172,39 @@ static int tr_rebuild_header(struct sk_buff *skb)
        if(arp_find(trh->daddr, skb)) {
                        return 1;
        }
-       else 
-#endif 
-       {       
-               tr_source_route(skb,trh,dev); 
+       else
+#endif
+       {
+               tr_source_route(skb,trh,dev);
                return 0;
        }
 }
-       
+
 /*
  *     Some of this is a bit hackish. We intercept RIF information
  *     used for source routing. We also grab IP directly and don't feed
  *     it via SNAP.
  */
+
 __be16 tr_type_trans(struct sk_buff *skb, struct net_device *dev)
 {
 
        struct trh_hdr *trh=(struct trh_hdr *)skb->data;
        struct trllc *trllc;
        unsigned riflen=0;
-       
+
        skb->mac.raw = skb->data;
-       
-               if(trh->saddr[0] & TR_RII)
+
+       if(trh->saddr[0] & TR_RII)
                riflen = (ntohs(trh->rcf) & TR_RCF_LEN_MASK) >> 8;
 
        trllc = (struct trllc *)(skb->data+sizeof(struct trh_hdr)-TR_MAXRIFLEN+riflen);
 
        skb_pull(skb,sizeof(struct trh_hdr)-TR_MAXRIFLEN+riflen);
 
-       if(*trh->daddr & 0x80) 
+       if(*trh->daddr & 0x80)
        {
-               if(!memcmp(trh->daddr,dev->broadcast,TR_ALEN))  
+               if(!memcmp(trh->daddr,dev->broadcast,TR_ALEN))
                        skb->pkt_type=PACKET_BROADCAST;
                else
                        skb->pkt_type=PACKET_MULTICAST;
@@ -213,7 +213,7 @@ __be16 tr_type_trans(struct sk_buff *skb, struct net_device *dev)
        {
                skb->pkt_type=PACKET_MULTICAST;
        }
-       else if(dev->flags & IFF_PROMISC) 
+       else if(dev->flags & IFF_PROMISC)
        {
                if(memcmp(trh->daddr, dev->dev_addr, TR_ALEN))
                        skb->pkt_type=PACKET_OTHERHOST;
@@ -221,10 +221,10 @@ __be16 tr_type_trans(struct sk_buff *skb, struct net_device *dev)
 
        if ((skb->pkt_type != PACKET_BROADCAST) &&
            (skb->pkt_type != PACKET_MULTICAST))
-               tr_add_rif_info(trh,dev) ; 
+               tr_add_rif_info(trh,dev) ;
 
        /*
-        * Strip the SNAP header from ARP packets since we don't 
+        * Strip the SNAP header from ARP packets since we don't
         * pass them through to the 802.2/SNAP layers.
         */
 
@@ -241,32 +241,32 @@ __be16 tr_type_trans(struct sk_buff *skb, struct net_device *dev)
 }
 
 /*
- *     We try to do source routing... 
+ *     We try to do source routing...
  */
 
-void tr_source_route(struct sk_buff *skb,struct trh_hdr *trh,struct net_device *dev) 
+void tr_source_route(struct sk_buff *skb,struct trh_hdr *trh,struct net_device *dev)
 {
        int slack;
        unsigned int hash;
        struct rif_cache *entry;
        unsigned char *olddata;
        unsigned long flags;
-       static const unsigned char mcast_func_addr[] 
+       static const unsigned char mcast_func_addr[]
                = {0xC0,0x00,0x00,0x04,0x00,0x00};
-       
+
        spin_lock_irqsave(&rif_lock, flags);
 
        /*
-        *      Broadcasts are single route as stated in RFC 1042 
+        *      Broadcasts are single route as stated in RFC 1042
         */
        if( (!memcmp(&(trh->daddr[0]),&(dev->broadcast[0]),TR_ALEN)) ||
            (!memcmp(&(trh->daddr[0]),&(mcast_func_addr[0]), TR_ALEN))  )
        {
-               trh->rcf=htons((((sizeof(trh->rcf)) << 8) & TR_RCF_LEN_MASK)  
+               trh->rcf=htons((((sizeof(trh->rcf)) << 8) & TR_RCF_LEN_MASK)
                               | TR_RCF_FRAME2K | TR_RCF_LIMITED_BROADCAST);
                trh->saddr[0]|=TR_RII;
        }
-       else 
+       else
        {
                hash = rif_hash(trh->daddr);
                /*
@@ -277,7 +277,7 @@ void tr_source_route(struct sk_buff *skb,struct trh_hdr *trh,struct net_device *
                /*
                 *      If we found an entry we can route the frame.
                 */
-               if(entry) 
+               if(entry)
                {
 #if TR_SR_DEBUG
 printk("source routing for %02X:%02X:%02X:%02X:%02X:%02X\n",trh->daddr[0],
@@ -287,7 +287,7 @@ printk("source routing for %02X:%02X:%02X:%02X:%02X:%02X\n",trh->daddr[0],
                        {
                                trh->rcf=entry->rcf;
                                memcpy(&trh->rseg[0],&entry->rseg[0],8*sizeof(unsigned short));
-                               trh->rcf^=htons(TR_RCF_DIR_BIT);        
+                               trh->rcf^=htons(TR_RCF_DIR_BIT);
                                trh->rcf&=htons(0x1fff);        /* Issam Chehab <ichehab@madge1.demon.co.uk> */
 
                                trh->saddr[0]|=TR_RII;
@@ -301,14 +301,14 @@ printk("source routing for %02X:%02X:%02X:%02X:%02X:%02X\n",trh->daddr[0],
                        }
                        entry->last_used=jiffies;
                }
-               else 
+               else
                {
                        /*
                         *      Without the information we simply have to shout
                         *      on the wire. The replies should rapidly clean this
                         *      situation up.
                         */
-                       trh->rcf=htons((((sizeof(trh->rcf)) << 8) & TR_RCF_LEN_MASK)  
+                       trh->rcf=htons((((sizeof(trh->rcf)) << 8) & TR_RCF_LEN_MASK)
                                       | TR_RCF_FRAME2K | TR_RCF_LIMITED_BROADCAST);
                        trh->saddr[0]|=TR_RII;
 #if TR_SR_DEBUG
@@ -320,7 +320,7 @@ printk("source routing for %02X:%02X:%02X:%02X:%02X:%02X\n",trh->daddr[0],
        /* Compress the RIF here so we don't have to do it in the driver(s) */
        if (!(trh->saddr[0] & 0x80))
                slack = 18;
-       else 
+       else
                slack = 18 - ((ntohs(trh->rcf) & TR_RCF_LEN_MASK)>>8);
        olddata = skb->data;
        spin_unlock_irqrestore(&rif_lock, flags);
@@ -333,7 +333,7 @@ printk("source routing for %02X:%02X:%02X:%02X:%02X:%02X\n",trh->daddr[0],
  *     We have learned some new RIF information for our source
  *     routing.
  */
+
 static void tr_add_rif_info(struct trh_hdr *trh, struct net_device *dev)
 {
        unsigned int hash, rii_p = 0;
@@ -343,29 +343,29 @@ static void tr_add_rif_info(struct trh_hdr *trh, struct net_device *dev)
 
        spin_lock_irqsave(&rif_lock, flags);
        saddr0 = trh->saddr[0];
-       
+
        /*
         *      Firstly see if the entry exists
         */
 
-               if(trh->saddr[0] & TR_RII)
+       if(trh->saddr[0] & TR_RII)
        {
                trh->saddr[0]&=0x7f;
                if (((ntohs(trh->rcf) & TR_RCF_LEN_MASK) >> 8) > 2)
                {
                        rii_p = 1;
-               }
+               }
        }
 
        hash = rif_hash(trh->saddr);
        for(entry=rif_table[hash];entry && memcmp(&(entry->addr[0]),&(trh->saddr[0]),TR_ALEN);entry=entry->next);
 
-       if(entry==NULL) 
+       if(entry==NULL)
        {
 #if TR_SR_DEBUG
 printk("adding rif_entry: addr:%02X:%02X:%02X:%02X:%02X:%02X rcf:%04X\n",
                trh->saddr[0],trh->saddr[1],trh->saddr[2],
-                       trh->saddr[3],trh->saddr[4],trh->saddr[5],
+               trh->saddr[3],trh->saddr[4],trh->saddr[5],
                ntohs(trh->rcf));
 #endif
                /*
@@ -377,7 +377,7 @@ printk("adding rif_entry: addr:%02X:%02X:%02X:%02X:%02X:%02X rcf:%04X\n",
                 */
                entry=kmalloc(sizeof(struct rif_cache),GFP_ATOMIC);
 
-               if(!entry) 
+               if(!entry)
                {
                        printk(KERN_DEBUG "tr.c: Couldn't malloc rif cache entry !\n");
                        spin_unlock_irqrestore(&rif_lock, flags);
@@ -400,13 +400,13 @@ printk("adding rif_entry: addr:%02X:%02X:%02X:%02X:%02X:%02X rcf:%04X\n",
                {
                        entry->local_ring = 1;
                }
-       }       
+       }
        else    /* Y. Tahara added */
-       { 
+       {
                /*
                 *      Update existing entries
                 */
-               if (!entry->local_ring) 
+               if (!entry->local_ring)
                    if (entry->rcf != (trh->rcf & htons((unsigned short)~TR_RCF_BROADCAST_MASK)) &&
                         !(trh->rcf & htons(TR_RCF_BROADCAST_MASK)))
                    {
@@ -417,9 +417,9 @@ printk("updating rif_entry: addr:%02X:%02X:%02X:%02X:%02X:%02X rcf:%04X\n",
                ntohs(trh->rcf));
 #endif
                            entry->rcf = trh->rcf & htons((unsigned short)~TR_RCF_BROADCAST_MASK);
-                           memcpy(&(entry->rseg[0]),&(trh->rseg[0]),8*sizeof(unsigned short));
-                   }                                         
-               entry->last_used=jiffies;               
+                           memcpy(&(entry->rseg[0]),&(trh->rseg[0]),8*sizeof(unsigned short));
+                   }
+               entry->last_used=jiffies;
        }
        trh->saddr[0]=saddr0; /* put the routing indicator back for tcpdump */
        spin_unlock_irqrestore(&rif_lock, flags);
@@ -429,16 +429,16 @@ printk("updating rif_entry: addr:%02X:%02X:%02X:%02X:%02X:%02X rcf:%04X\n",
  *     Scan the cache with a timer and see what we need to throw out.
  */
 
-static void rif_check_expire(unsigned long dummy) 
+static void rif_check_expire(unsigned long dummy)
 {
        int i;
        unsigned long flags, next_interval = jiffies + sysctl_tr_rif_timeout/2;
 
        spin_lock_irqsave(&rif_lock, flags);
-       
+
        for(i =0; i < RIF_TABLE_SIZE; i++) {
                struct rif_cache *entry, **pentry;
-               
+
                pentry = rif_table+i;
                while((entry=*pentry) != NULL) {
                        unsigned long expires
@@ -455,7 +455,7 @@ static void rif_check_expire(unsigned long dummy)
                        }
                }
        }
-       
+
        spin_unlock_irqrestore(&rif_lock, flags);
 
        mod_timer(&rif_timer, next_interval);
@@ -466,7 +466,7 @@ static void rif_check_expire(unsigned long dummy)
  *     Generate the /proc/net information for the token ring RIF
  *     routing.
  */
+
 #ifdef CONFIG_PROC_FS
 
 static struct rif_cache *rif_get_idx(loff_t pos)
@@ -475,7 +475,7 @@ static struct rif_cache *rif_get_idx(loff_t pos)
        struct rif_cache *entry;
        loff_t off = 0;
 
-       for(i = 0; i < RIF_TABLE_SIZE; i++) 
+       for(i = 0; i < RIF_TABLE_SIZE; i++)
                for(entry = rif_table[i]; entry; entry = entry->next) {
                        if (off == pos)
                                return entry;
@@ -504,7 +504,7 @@ static void *rif_seq_next(struct seq_file *seq, void *v, loff_t *pos)
                goto scan;
        }
 
-       if (ent->next) 
+       if (ent->next)
                return ent->next;
 
        i = rif_hash(ent->addr);
@@ -541,13 +541,13 @@ static int rif_seq_show(struct seq_file *seq, void *v)
                           ttl/HZ);
 
                        if (entry->local_ring)
-                               seq_puts(seq, "local\n");
+                               seq_puts(seq, "local\n");
                        else {
 
                                seq_printf(seq, "%04X", ntohs(entry->rcf));
-                               rcf_len = ((ntohs(entry->rcf) & TR_RCF_LEN_MASK)>>8)-2; 
+                               rcf_len = ((ntohs(entry->rcf) & TR_RCF_LEN_MASK)>>8)-2;
                                if (rcf_len)
-                                       rcf_len >>= 1;
+                                       rcf_len >>= 1;
                                for(j = 1; j < rcf_len; j++) {
                                        if(j==1) {
                                                segment=ntohs(entry->rseg[j-1])>>4;
@@ -559,7 +559,7 @@ static int rif_seq_show(struct seq_file *seq, void *v)
                                }
                                seq_putc(seq, '\n');
                        }
-               }
+               }
        return 0;
 }
 
@@ -591,7 +591,7 @@ static void tr_setup(struct net_device *dev)
        /*
         *      Configure and register
         */
-       
+
        dev->hard_header        = tr_header;
        dev->rebuild_header     = tr_rebuild_header;
 
@@ -600,7 +600,7 @@ static void tr_setup(struct net_device *dev)
        dev->mtu                = 2000;
        dev->addr_len           = TR_ALEN;
        dev->tx_queue_len       = 100;  /* Long queues on tr */
-       
+
        memset(dev->broadcast,0xFF, TR_ALEN);
 
        /* New-style flags. */
index 18fcb9fa518db4c4574d283ba8abdd35df9183fd..c1c205fad4fbc34cde3ba9474a269a42337959af 100644 (file)
@@ -5,7 +5,7 @@
  * Authors:    Ben Greear <greearb@candelatech.com>
  *              Please send support related email to: vlan@scry.wanfear.com
  *              VLAN Home Page: http://www.candelatech.com/~greear/vlan.html
- * 
+ *
  * Fixes:
  *              Fix for packet capture - Nick Eggleston <nick@dccinc.com>;
  *             Add HW acceleration hooks - David S. Miller <davem@redhat.com>;
@@ -72,7 +72,7 @@ static struct packet_type vlan_packet_type = {
 /*
  * Function vlan_proto_init (pro)
  *
- *    Initialize VLAN protocol layer, 
+ *    Initialize VLAN protocol layer,
  *
  */
 static int __init vlan_proto_init(void)
@@ -87,7 +87,7 @@ static int __init vlan_proto_init(void)
        /* proc file system initialization */
        err = vlan_proc_init();
        if (err < 0) {
-               printk(KERN_ERR 
+               printk(KERN_ERR
                       "%s %s: can't create entry in proc filesystem!\n",
                       __FUNCTION__, VLAN_NAME);
                return err;
@@ -108,7 +108,7 @@ static int __init vlan_proto_init(void)
        return 0;
 }
 
-/* Cleanup all vlan devices 
+/* Cleanup all vlan devices
  * Note: devices that have been registered that but not
  * brought up will exist but have no module ref count.
  */
@@ -132,7 +132,7 @@ static void __exit vlan_cleanup_devices(void)
 /*
  *     Module 'remove' entry point.
  *     o delete /proc/net/router directory and static entries.
- */ 
+ */
 static void __exit vlan_cleanup_module(void)
 {
        int i;
@@ -184,7 +184,7 @@ struct net_device *__find_vlan_dev(struct net_device *real_dev,
        struct vlan_group *grp = __vlan_find_group(real_dev->ifindex);
 
        if (grp)
-                return grp->vlan_devices[VID];
+               return grp->vlan_devices[VID];
 
        return NULL;
 }
@@ -269,7 +269,7 @@ static int unregister_vlan_dev(struct net_device *real_dev,
                }
        }
 
-        return ret;
+       return ret;
 }
 
 static int unregister_vlan_device(const char *vlan_IF_name)
@@ -295,7 +295,7 @@ static int unregister_vlan_device(const char *vlan_IF_name)
                        if (ret == 1)
                                ret = 0;
                } else {
-                       printk(VLAN_ERR 
+                       printk(VLAN_ERR
                               "%s: ERROR:      Tried to remove a non-vlan device "
                               "with VLAN code, name: %s  priv_flags: %hX\n",
                               __FUNCTION__, dev->name, dev->priv_flags);
@@ -315,7 +315,7 @@ static int unregister_vlan_device(const char *vlan_IF_name)
 static void vlan_setup(struct net_device *new_dev)
 {
        SET_MODULE_OWNER(new_dev);
-           
+
        /* new_dev->ifindex = 0;  it will be set when added to
         * the global list.
         * iflink is set as well.
@@ -324,7 +324,7 @@ static void vlan_setup(struct net_device *new_dev)
 
        /* Make this thing known as a VLAN device */
        new_dev->priv_flags |= IFF_802_1Q_VLAN;
-                               
+
        /* Set us up to have no queue, as the underlying Hardware device
         * can do all the queueing we could want.
         */
@@ -461,7 +461,7 @@ static struct net_device *register_vlan_device(const char *eth_IF_name,
        default:
                snprintf(name, IFNAMSIZ, "vlan%.4i", VLAN_ID);
        };
-                   
+
        new_dev = alloc_netdev(sizeof(struct vlan_dev_info), name,
                               vlan_setup);
 
@@ -477,7 +477,7 @@ static struct net_device *register_vlan_device(const char *eth_IF_name,
 
        new_dev->state = (real_dev->state & ((1<<__LINK_STATE_NOCARRIER) |
                                             (1<<__LINK_STATE_DORMANT))) |
-                        (1<<__LINK_STATE_PRESENT); 
+                        (1<<__LINK_STATE_PRESENT);
 
        /* need 4 bytes for extra VLAN header info,
         * hope the underlying device can handle it.
@@ -496,7 +496,7 @@ static struct net_device *register_vlan_device(const char *eth_IF_name,
        VLAN_MEM_DBG("new_dev->priv malloc, addr: %p  size: %i\n",
                     new_dev->priv,
                     sizeof(struct vlan_dev_info));
-           
+
        memcpy(new_dev->broadcast, real_dev->broadcast, real_dev->addr_len);
        memcpy(new_dev->dev_addr, real_dev->dev_addr, real_dev->addr_len);
        new_dev->addr_len = real_dev->addr_len;
@@ -521,7 +521,7 @@ static struct net_device *register_vlan_device(const char *eth_IF_name,
        printk(VLAN_DBG "About to go find the group for idx: %i\n",
               real_dev->ifindex);
 #endif
-           
+
        if (register_netdevice(new_dev))
                goto out_free_newdev;
 
@@ -543,22 +543,22 @@ static struct net_device *register_vlan_device(const char *eth_IF_name,
                grp = kzalloc(sizeof(struct vlan_group), GFP_KERNEL);
                if (!grp)
                        goto out_free_unregister;
-                                       
+
                /* printk(KERN_ALERT "VLAN REGISTER:  Allocated new group.\n"); */
                grp->real_dev_ifindex = real_dev->ifindex;
 
-               hlist_add_head_rcu(&grp->hlist, 
+               hlist_add_head_rcu(&grp->hlist,
                                   &vlan_group_hash[vlan_grp_hashfn(real_dev->ifindex)]);
 
                if (real_dev->features & NETIF_F_HW_VLAN_RX)
                        real_dev->vlan_rx_register(real_dev, grp);
        }
-           
+
        grp->vlan_devices[VLAN_ID] = new_dev;
 
        if (vlan_proc_add_dev(new_dev)<0)/* create it's proc entry */
-               printk(KERN_WARNING "VLAN: failed to add proc entry for %s\n",
-                                                        new_dev->name);
+               printk(KERN_WARNING "VLAN: failed to add proc entry for %s\n",
+                                                        new_dev->name);
 
        if (real_dev->features & NETIF_F_HW_VLAN_FILTER)
                real_dev->vlan_rx_add_vid(real_dev, VLAN_ID);
@@ -635,7 +635,7 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
                        vlandev = grp->vlan_devices[i];
                        if (!vlandev)
                                continue;
-                               
+
                        flgs = vlandev->flags;
                        if (flgs & IFF_UP)
                                continue;
@@ -643,7 +643,7 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
                        dev_change_flags(vlandev, flgs | IFF_UP);
                }
                break;
-               
+
        case NETDEV_UNREGISTER:
                /* Delete all VLANs for this dev. */
                for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
@@ -755,8 +755,8 @@ static int vlan_ioctl_handler(void __user *arg)
                /* TODO:  Implement
                   err = vlan_dev_get_ingress_priority(args);
                   if (copy_to_user((void*)arg, &args,
-                       sizeof(struct vlan_ioctl_args))) {
-                       err = -EFAULT;
+                       sizeof(struct vlan_ioctl_args))) {
+                       err = -EFAULT;
                   }
                */
                err = -EINVAL;
@@ -765,8 +765,8 @@ static int vlan_ioctl_handler(void __user *arg)
                /* TODO:  Implement
                   err = vlan_dev_get_egress_priority(args.device1, &(args.args);
                   if (copy_to_user((void*)arg, &args,
-                       sizeof(struct vlan_ioctl_args))) {
-                       err = -EFAULT;
+                       sizeof(struct vlan_ioctl_args))) {
+                       err = -EFAULT;
                   }
                */
                err = -EINVAL;
@@ -788,7 +788,7 @@ static int vlan_ioctl_handler(void __user *arg)
                args.u.VID = vid;
                if (copy_to_user(arg, &args,
                                 sizeof(struct vlan_ioctl_args))) {
-                      err = -EFAULT;
+                     err = -EFAULT;
                }
                break;
 
index 9ae3a14dd016d3ed9da0c2fb603c6a8da900e182..1976cdba8f726dc7d43edbaad4707878c18bb42f 100644 (file)
@@ -9,8 +9,8 @@
 #define VLAN_ERR KERN_ERR
 #define VLAN_INF KERN_INFO
 #define VLAN_DBG KERN_ALERT /* change these... to debug, having a hard time
-                             * changing the log level at run-time..for some reason.
-                             */
+                            * changing the log level at run-time..for some reason.
+                            */
 
 /*
 
@@ -24,7 +24,7 @@ I'll bet they might prove useful again... --Ben
 */
 
 /* This way they don't do anything! */
-#define VLAN_MEM_DBG(x, y, z) 
+#define VLAN_MEM_DBG(x, y, z)
 #define VLAN_FMEM_DBG(x, y)
 
 
@@ -51,10 +51,10 @@ struct net_device *__find_vlan_dev(struct net_device* real_dev,
 /* found in vlan_dev.c */
 int vlan_dev_rebuild_header(struct sk_buff *skb);
 int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
-                  struct packet_type *ptype, struct net_device *orig_dev);
+                 struct packet_type *ptype, struct net_device *orig_dev);
 int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
-                         unsigned short type, void *daddr, void *saddr,
-                         unsigned len);
+                        unsigned short type, void *daddr, void *saddr,
+                        unsigned len);
 int vlan_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev);
 int vlan_dev_hwaccel_hard_start_xmit(struct sk_buff *skb, struct net_device *dev);
 int vlan_dev_change_mtu(struct net_device *dev, int new_mtu);
index 60a508eb1945bd78c05b3a3424a93cb30af7b20f..2fc8fe2cb366e4887e25c998ef2881834d25dbbe 100644 (file)
@@ -5,14 +5,14 @@
  * Authors:    Ben Greear <greearb@candelatech.com>
  *              Please send support related email to: vlan@scry.wanfear.com
  *              VLAN Home Page: http://www.candelatech.com/~greear/vlan.html
- * 
+ *
  * Fixes:       Mar 22 2001: Martin Bokaemper <mbokaemper@unispherenetworks.com>
  *                - reset skb->pkt_type on incoming packets when MAC was changed
  *                - see that changed MAC is saddr for outgoing packets
  *              Oct 20, 2001:  Ard van Breeman:
  *                - Fix MC-list, finally.
  *                - Flush MC-list on VLAN destroy.
- *                
+ *
  *
  *             This program is free software; you can redistribute it and/or
  *             modify it under the terms of the GNU General Public License
@@ -58,12 +58,12 @@ int vlan_dev_rebuild_header(struct sk_buff *skb)
 
                /* TODO:  Confirm this will work with VLAN headers... */
                return arp_find(veth->h_dest, skb);
-#endif 
+#endif
        default:
                printk(VLAN_DBG
-                      "%s: unable to resolve type %X addresses.\n", 
+                      "%s: unable to resolve type %X addresses.\n",
                       dev->name, ntohs(veth->h_vlan_encapsulated_proto));
-        
+
                memcpy(veth->h_source, dev->dev_addr, ETH_ALEN);
                break;
        };
@@ -91,7 +91,7 @@ static inline struct sk_buff *vlan_check_reorder_header(struct sk_buff *skb)
 }
 
 /*
- *     Determine the packet's protocol ID. The rule here is that we 
+ *     Determine the packet's protocol ID. The rule here is that we
  *     assume 802.3 if the type field is short enough to be a length.
  *     This is normal practice and works for any 'now in use' protocol.
  *
@@ -113,7 +113,7 @@ static inline struct sk_buff *vlan_check_reorder_header(struct sk_buff *skb)
  *
  */
 int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
-                  struct packet_type* ptype, struct net_device *orig_dev)
+                 struct packet_type* ptype, struct net_device *orig_dev)
 {
        unsigned char *rawp = NULL;
        struct vlan_hdr *vhdr = (struct vlan_hdr *)(skb->data);
@@ -175,8 +175,8 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
 
 #ifdef VLAN_DEBUG
                printk(VLAN_DBG "%s: dropping skb: %p because came in on wrong device, dev: %s  real_dev: %s, skb_dev: %s\n",
-                       __FUNCTION__, skb, dev->name, 
-                       VLAN_DEV_INFO(skb->dev)->real_dev->name, 
+                       __FUNCTION__, skb, dev->name,
+                       VLAN_DEV_INFO(skb->dev)->real_dev->name,
                        skb->dev->name);
 #endif
                kfree_skb(skb);
@@ -191,7 +191,7 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
 
 #ifdef VLAN_DEBUG
        printk(VLAN_DBG "%s: priority: %lu  for TCI: %hu (hbo)\n",
-               __FUNCTION__, (unsigned long)(skb->priority), 
+               __FUNCTION__, (unsigned long)(skb->priority),
                ntohs(vhdr->h_vlan_TCI));
 #endif
 
@@ -207,7 +207,7 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
                stats->multicast++;
                break;
 
-       case PACKET_OTHERHOST: 
+       case PACKET_OTHERHOST:
                /* Our lower layer thinks this is not local, let's make sure.
                 * This allows the VLAN to have a different MAC than the underlying
                 * device, and still route correctly.
@@ -319,7 +319,7 @@ static inline unsigned short vlan_dev_get_egress_qos_mask(struct net_device* dev
 }
 
 /*
- *     Create the VLAN header for an arbitrary protocol layer 
+ *     Create the VLAN header for an arbitrary protocol layer
  *
  *     saddr=NULL      means use device source address
  *     daddr=NULL      means leave destination address (eg unresolved arp)
@@ -328,8 +328,8 @@ static inline unsigned short vlan_dev_get_egress_qos_mask(struct net_device* dev
  *  physical devices.
  */
 int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
-                         unsigned short type, void *daddr, void *saddr,
-                         unsigned len)
+                        unsigned short type, void *daddr, void *saddr,
+                        unsigned len)
 {
        struct vlan_hdr *vhdr;
        unsigned short veth_TCI = 0;
@@ -346,7 +346,7 @@ int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
         * fixes some programs that get confused when they see a VLAN device
         * sending a frame that is VLAN encoded (the consensus is that the VLAN
         * device should look completely like an Ethernet device when the
-        * REORDER_HEADER flag is set)  The drawback to this is some extra 
+        * REORDER_HEADER flag is set)  The drawback to this is some extra
         * header shuffling in the hard_start_xmit.  Users can turn off this
         * REORDER behaviour with the vconfig tool.
         */
@@ -553,7 +553,7 @@ int vlan_dev_set_egress_priority(char *dev_name, __u32 skb_prio, short vlan_prio
        struct net_device *dev = dev_get_by_name(dev_name);
        struct vlan_priority_tci_mapping *mp = NULL;
        struct vlan_priority_tci_mapping *np;
-   
+
        if (dev) {
                if (dev->priv_flags & IFF_802_1Q_VLAN) {
                        /* See if a priority mapping exists.. */
@@ -610,13 +610,13 @@ int vlan_dev_set_vlan_flag(char *dev_name, __u32 flag, short flag_val)
                                return -EINVAL;
                        }
                } else {
-                       printk(KERN_ERR 
+                       printk(KERN_ERR
                               "%s: %s is not a vlan device, priv_flags: %hX.\n",
                               __FUNCTION__, dev->name, dev->priv_flags);
                        dev_put(dev);
                }
        } else {
-               printk(KERN_ERR  "%s: Could not find device: %s\n", 
+               printk(KERN_ERR  "%s: Could not find device: %s\n",
                        __FUNCTION__, dev_name);
        }
 
@@ -700,7 +700,7 @@ int vlan_dev_set_mac_address(struct net_device *dev, void *addr_struct_p)
 }
 
 static inline int vlan_dmi_equals(struct dev_mc_list *dmi1,
-                                  struct dev_mc_list *dmi2)
+                                 struct dev_mc_list *dmi2)
 {
        return ((dmi1->dmi_addrlen == dmi2->dmi_addrlen) &&
                (memcmp(dmi1->dmi_addr, dmi2->dmi_addr, dmi1->dmi_addrlen) == 0));
@@ -810,7 +810,7 @@ int vlan_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
        case SIOCGMIIPHY:
        case SIOCGMIIREG:
        case SIOCSMIIREG:
-               if (real_dev->do_ioctl && netif_device_present(real_dev)) 
+               if (real_dev->do_ioctl && netif_device_present(real_dev))
                        err = real_dev->do_ioctl(real_dev, &ifrr, cmd);
                break;
 
@@ -818,7 +818,7 @@ int vlan_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
                err = dev_ethtool(&ifrr);
        }
 
-       if (!err) 
+       if (!err)
                ifr->ifr_ifru = ifrr.ifr_ifru;
 
        return err;
index a8fc0de1f969a89e15382c54fd675e53f3eccd72..1b72c9854d6f7fcffd601cac7696c6a9661e5a37 100644 (file)
@@ -51,7 +51,7 @@ static int vlandev_seq_show(struct seq_file *seq, void *v);
 
 
 /*
- *     Names of the proc directory entries 
+ *     Names of the proc directory entries
  */
 
 static const char name_root[]   = "vlan";
@@ -66,7 +66,7 @@ static const char name_conf[]  = "config";
  */
 
 /*
- *     Generic /proc/net/vlan/<file> file and inode operations 
+ *     Generic /proc/net/vlan/<file> file and inode operations
  */
 
 static struct seq_operations vlan_seq_ops = {
@@ -111,13 +111,13 @@ static struct file_operations vlandev_fops = {
  */
 
 /*
- *     /proc/net/vlan 
+ *     /proc/net/vlan
  */
 
 static struct proc_dir_entry *proc_vlan_dir;
 
 /*
- *     /proc/net/vlan/config 
+ *     /proc/net/vlan/config
  */
 
 static struct proc_dir_entry *proc_vlan_conf;
@@ -238,15 +238,15 @@ int vlan_proc_rem_dev(struct net_device *vlandev)
  */
 
 /* starting at dev, find a VLAN device */
-static struct net_device *vlan_skip(struct net_device *dev) 
+static struct net_device *vlan_skip(struct net_device *dev)
 {
-       while (dev && !(dev->priv_flags & IFF_802_1Q_VLAN)) 
+       while (dev && !(dev->priv_flags & IFF_802_1Q_VLAN))
                dev = dev->next;
 
        return dev;
 }
 
-/* start read of /proc/net/vlan/config */ 
+/* start read of /proc/net/vlan/config */
 static void *vlan_seq_start(struct seq_file *seq, loff_t *pos)
 {
        struct net_device *dev;
@@ -256,19 +256,19 @@ static void *vlan_seq_start(struct seq_file *seq, loff_t *pos)
 
        if (*pos == 0)
                return SEQ_START_TOKEN;
-       
-       for (dev = vlan_skip(dev_base); dev && i < *pos; 
+
+       for (dev = vlan_skip(dev_base); dev && i < *pos;
             dev = vlan_skip(dev->next), ++i);
-               
+
        return  (i == *pos) ? dev : NULL;
-} 
+}
 
 static void *vlan_seq_next(struct seq_file *seq, void *v, loff_t *pos)
 {
        ++*pos;
 
-       return vlan_skip((v == SEQ_START_TOKEN)  
-                           ? dev_base 
+       return vlan_skip((v == SEQ_START_TOKEN)
+                           ? dev_base
                            : ((struct net_device *)v)->next);
 }
 
@@ -287,13 +287,13 @@ static int vlan_seq_show(struct seq_file *seq, void *v)
                if (vlan_name_type < ARRAY_SIZE(vlan_name_type_str))
                    nmtype =  vlan_name_type_str[vlan_name_type];
 
-               seq_printf(seq, "Name-Type: %s\n", 
+               seq_printf(seq, "Name-Type: %s\n",
                           nmtype ? nmtype :  "UNKNOWN" );
        } else {
                const struct net_device *vlandev = v;
                const struct vlan_dev_info *dev_info = VLAN_DEV_INFO(vlandev);
 
-               seq_printf(seq, "%-15s| %d  | %s\n",  vlandev->name,  
+               seq_printf(seq, "%-15s| %d  | %s\n",  vlandev->name,
                           dev_info->vlan_id,    dev_info->real_dev->name);
        }
        return 0;
@@ -323,13 +323,13 @@ static int vlandev_seq_show(struct seq_file *seq, void *offset)
        seq_puts(seq, "\n");
        seq_printf(seq, fmt, "total frames transmitted", stats->tx_packets);
        seq_printf(seq, fmt, "total bytes transmitted", stats->tx_bytes);
-       seq_printf(seq, fmt, "total headroom inc", 
+       seq_printf(seq, fmt, "total headroom inc",
                   dev_info->cnt_inc_headroom_on_tx);
-       seq_printf(seq, fmt, "total encap on xmit", 
+       seq_printf(seq, fmt, "total encap on xmit",
                   dev_info->cnt_encap_on_xmit);
        seq_printf(seq, "Device: %s", dev_info->real_dev->name);
        /* now show all PRIORITY mappings relating to this VLAN */
-       seq_printf(seq, 
+       seq_printf(seq,
                       "\nINGRESS priority mappings: 0:%lu  1:%lu  2:%lu  3:%lu  4:%lu  5:%lu  6:%lu 7:%lu\n",
                       dev_info->ingress_priority_map[0],
                       dev_info->ingress_priority_map[1],
index 7dfc949206975c7df2de35f58a56237ddba5c906..915657832d944c10a537f3dbd3ce3d3d69745fb0 100644 (file)
@@ -37,6 +37,7 @@ config NETDEBUG
 source "net/packet/Kconfig"
 source "net/unix/Kconfig"
 source "net/xfrm/Kconfig"
+source "net/iucv/Kconfig"
 
 config INET
        bool "TCP/IP networking"
index ad4d14f4bb29637729552524decedc574bc1ccad..4854ac506313606ecdbb6ac2cff170e1e3ec52c6 100644 (file)
@@ -47,6 +47,7 @@ obj-$(CONFIG_IP_SCTP)         += sctp/
 obj-$(CONFIG_IEEE80211)                += ieee80211/
 obj-$(CONFIG_TIPC)             += tipc/
 obj-$(CONFIG_NETLABEL)         += netlabel/
+obj-$(CONFIG_IUCV)             += iucv/
 
 ifeq ($(CONFIG_NET),y)
 obj-$(CONFIG_SYSCTL)           += sysctl_net.o
index f3777ec5bcb988bc9d33cb332aa96dc0dbeebd7d..27e845d260a9f65b9e1a787294e735eb8c56020a 100644 (file)
@@ -895,7 +895,7 @@ struct aarp_iter_state {
 
 /*
  * Get the aarp entry that is in the chain described
- * by the iterator. 
+ * by the iterator.
  * If pos is set then skip till that index.
  * pos = 1 is the first entry
  */
@@ -905,7 +905,7 @@ static struct aarp_entry *iter_next(struct aarp_iter_state *iter, loff_t *pos)
        struct aarp_entry **table = iter->table;
        loff_t off = 0;
        struct aarp_entry *entry;
-       
+
  rescan:
        while(ct < AARP_HASH_SIZE) {
                for (entry = table[ct]; entry; entry = entry->next) {
@@ -950,9 +950,9 @@ static void *aarp_seq_next(struct seq_file *seq, void *v, loff_t *pos)
        ++*pos;
 
        /* first line after header */
-       if (v == SEQ_START_TOKEN) 
+       if (v == SEQ_START_TOKEN)
                entry = iter_next(iter, NULL);
-               
+
        /* next entry in current bucket */
        else if (entry->next)
                entry = entry->next;
@@ -986,7 +986,7 @@ static int aarp_seq_show(struct seq_file *seq, void *v)
        unsigned long now = jiffies;
 
        if (v == SEQ_START_TOKEN)
-               seq_puts(seq, 
+               seq_puts(seq,
                         "Address  Interface   Hardware Address"
                         "   Expires LastSend  Retry Status\n");
        else {
@@ -1014,7 +1014,7 @@ static int aarp_seq_show(struct seq_file *seq, void *v)
                           : (iter->table == unresolved) ? "unresolved"
                           : (iter->table == proxies) ? "proxies"
                           : "unknown");
-       }                                
+       }
        return 0;
 }
 
@@ -1030,7 +1030,7 @@ static int aarp_seq_open(struct inode *inode, struct file *file)
        struct seq_file *seq;
        int rc = -ENOMEM;
        struct aarp_iter_state *s = kmalloc(sizeof(*s), GFP_KERNEL);
-       
+
        if (!s)
                goto out;
 
index 7ae4916cd26d9a2f78ef345867a3dfc4861c6ba5..bc3015f277ba6a80284c50b159355608105c8385 100644 (file)
@@ -292,7 +292,7 @@ int __init atalk_proc_init(void)
        p->proc_fops = &atalk_seq_socket_fops;
 
        p = create_proc_entry("arp", S_IRUGO, atalk_proc_dir);
-       if (!p) 
+       if (!p)
                goto out_arp;
        p->proc_fops = &atalk_seq_arp_fops;
 
index 3a7052207708eb8f834480f7f3d56a5684cf5e28..113c175f171586242370c5e006f36c5c07bd4724 100644 (file)
  *             Bradford Johnson        :       IP-over-DDP (experimental)
  *             Jay Schulist            :       Moved IP-over-DDP to its own
  *                                             driver file. (ipddp.c & ipddp.h)
- *             Jay Schulist            :       Made work as module with 
+ *             Jay Schulist            :       Made work as module with
  *                                             AppleTalk drivers, cleaned it.
  *             Rob Newberry            :       Added proxy AARP and AARP
  *                                             procfs, moved probing to AARP
  *                                             module.
- *              Adrian Sun/ 
- *              Michael Zuelsdorff      :       fix for net.0 packets. don't 
+ *              Adrian Sun/
+ *              Michael Zuelsdorff      :       fix for net.0 packets. don't
  *                                              allow illegal ether/tokentalk
- *                                              port assignment. we lose a 
- *                                              valid localtalk port as a 
+ *                                              port assignment. we lose a
+ *                                              valid localtalk port as a
  *                                              result.
  *             Arnaldo C. de Melo      :       Cleanup, in preparation for
  *                                             shared skb support 8)
@@ -48,7 +48,7 @@
  *             modify it under the terms of the GNU General Public License
  *             as published by the Free Software Foundation; either version
  *             2 of the License, or (at your option) any later version.
- * 
+ *
  */
 
 #include <linux/capability.h>
@@ -100,17 +100,17 @@ static struct sock *atalk_search_socket(struct sockaddr_at *to,
                if (to->sat_port != at->src_port)
                        continue;
 
-               if (to->sat_addr.s_net == ATADDR_ANYNET &&
+               if (to->sat_addr.s_net == ATADDR_ANYNET &&
                    to->sat_addr.s_node == ATADDR_BCAST)
                        goto found;
 
-               if (to->sat_addr.s_net == at->src_net &&
+               if (to->sat_addr.s_net == at->src_net &&
                    (to->sat_addr.s_node == at->src_node ||
                     to->sat_addr.s_node == ATADDR_BCAST ||
                     to->sat_addr.s_node == ATADDR_ANYNODE))
                        goto found;
 
-               /* XXXX.0 -- we got a request for this router. make sure
+               /* XXXX.0 -- we got a request for this router. make sure
                 * that the node is appropriately set. */
                if (to->sat_addr.s_node == ATADDR_ANYNODE &&
                    to->sat_addr.s_net != ATADDR_ANYNET &&
@@ -314,7 +314,7 @@ static int atif_proxy_probe_device(struct atalk_iface *atif,
 
        if (probe_node == ATADDR_ANYNODE)
                probe_node = jiffies & 0xFF;
-               
+
        /* Scan the networks */
        for (netct = 0; netct <= netrange; netct++) {
                /* Sweep the available nodes from a given start */
@@ -417,7 +417,7 @@ static struct atalk_iface *atalk_find_interface(__be16 net, int node)
                if (node == ATADDR_ANYNODE && net != ATADDR_ANYNET &&
                    ntohs(iface->nets.nr_firstnet) <= ntohs(net) &&
                    ntohs(net) <= ntohs(iface->nets.nr_lastnet))
-                       break;
+                       break;
        }
        read_unlock_bh(&atalk_interfaces_lock);
        return iface;
@@ -432,13 +432,13 @@ static struct atalk_iface *atalk_find_interface(__be16 net, int node)
 static struct atalk_route *atrtr_find(struct atalk_addr *target)
 {
        /*
-        * we must search through all routes unless we find a 
+        * we must search through all routes unless we find a
         * host route, because some host routes might overlap
         * network routes
         */
        struct atalk_route *net_route = NULL;
        struct atalk_route *r;
-       
+
        read_lock_bh(&atalk_routes_lock);
        for (r = atalk_routes; r; r = r->next) {
                if (!(r->flags & RTF_UP))
@@ -460,8 +460,8 @@ static struct atalk_route *atrtr_find(struct atalk_addr *target)
                                net_route = r;
                }
        }
-       
-       /* 
+
+       /*
         * if we found a network route but not a direct host
         * route, then return it
         */
@@ -540,15 +540,15 @@ static int atrtr_create(struct rtentry *r, struct net_device *devhint)
                for (iface = atalk_interfaces; iface; iface = iface->next) {
                        if (!riface &&
                            ntohs(ga->sat_addr.s_net) >=
-                                       ntohs(iface->nets.nr_firstnet) &&
+                                       ntohs(iface->nets.nr_firstnet) &&
                            ntohs(ga->sat_addr.s_net) <=
-                                       ntohs(iface->nets.nr_lastnet))
+                                       ntohs(iface->nets.nr_lastnet))
                                riface = iface;
 
                        if (ga->sat_addr.s_net == iface->address.s_net &&
                            ga->sat_addr.s_node == iface->address.s_node)
                                riface = iface;
-               }               
+               }
                read_unlock_bh(&atalk_interfaces_lock);
 
                retval = -ENETUNREACH;
@@ -649,7 +649,7 @@ static int ddp_device_event(struct notifier_block *this, unsigned long event,
 {
        if (event == NETDEV_DOWN)
                /* Discard any use of this */
-               atalk_dev_down(ptr);
+               atalk_dev_down(ptr);
 
        return NOTIFY_DONE;
 }
@@ -701,13 +701,13 @@ static int atif_ioctl(int cmd, void __user *arg)
                         */
                        if ((dev->flags & IFF_POINTOPOINT) &&
                            atalk_find_interface(sa->sat_addr.s_net,
-                                                sa->sat_addr.s_node)) {
+                                                sa->sat_addr.s_node)) {
                                printk(KERN_DEBUG "AppleTalk: point-to-point "
                                                  "interface added with "
                                                  "existing address\n");
                                add_route = 0;
                        }
-                       
+
                        /*
                         * Phase 1 is fine on LocalTalk but we don't do
                         * EtherTalk phase 1. Anyone wanting to add it go ahead.
@@ -797,78 +797,78 @@ static int atif_ioctl(int cmd, void __user *arg)
                        sa->sat_addr.s_node = ATADDR_BCAST;
                        break;
 
-               case SIOCATALKDIFADDR:
-               case SIOCDIFADDR:
+               case SIOCATALKDIFADDR:
+               case SIOCDIFADDR:
                        if (!capable(CAP_NET_ADMIN))
                                return -EPERM;
                        if (sa->sat_family != AF_APPLETALK)
                                return -EINVAL;
                        atalk_dev_down(dev);
-                       break;                  
+                       break;
 
                case SIOCSARP:
                        if (!capable(CAP_NET_ADMIN))
-                                return -EPERM;
-                        if (sa->sat_family != AF_APPLETALK)
-                                return -EINVAL;
-                        if (!atif)
-                                return -EADDRNOTAVAIL;
-
-                        /*
-                         * for now, we only support proxy AARP on ELAP;
-                         * we should be able to do it for LocalTalk, too.
-                         */
-                        if (dev->type != ARPHRD_ETHER)
-                                return -EPROTONOSUPPORT;
-
-                        /*
-                         * atif points to the current interface on this network;
-                         * we aren't concerned about its current status (at
+                               return -EPERM;
+                       if (sa->sat_family != AF_APPLETALK)
+                               return -EINVAL;
+                       if (!atif)
+                               return -EADDRNOTAVAIL;
+
+                       /*
+                        * for now, we only support proxy AARP on ELAP;
+                        * we should be able to do it for LocalTalk, too.
+                        */
+                       if (dev->type != ARPHRD_ETHER)
+                               return -EPROTONOSUPPORT;
+
+                       /*
+                        * atif points to the current interface on this network;
+                        * we aren't concerned about its current status (at
                         * least for now), but it has all the settings about
                         * the network we're going to probe. Consequently, it
                         * must exist.
-                         */
-                        if (!atif)
-                                return -EADDRNOTAVAIL;
-
-                        nr = (struct atalk_netrange *)&(atif->nets);
-                        /*
-                         * Phase 1 is fine on Localtalk but we don't do
-                         * Ethertalk phase 1. Anyone wanting to add it go ahead.
-                         */
-                        if (dev->type == ARPHRD_ETHER && nr->nr_phase != 2)
-                                return -EPROTONOSUPPORT;
-
-                        if (sa->sat_addr.s_node == ATADDR_BCAST ||
+                        */
+                       if (!atif)
+                               return -EADDRNOTAVAIL;
+
+                       nr = (struct atalk_netrange *)&(atif->nets);
+                       /*
+                        * Phase 1 is fine on Localtalk but we don't do
+                        * Ethertalk phase 1. Anyone wanting to add it go ahead.
+                        */
+                       if (dev->type == ARPHRD_ETHER && nr->nr_phase != 2)
+                               return -EPROTONOSUPPORT;
+
+                       if (sa->sat_addr.s_node == ATADDR_BCAST ||
                            sa->sat_addr.s_node == 254)
-                                return -EINVAL;
-
-                        /*
-                         * Check if the chosen address is used. If so we
-                         * error and ATCP will try another.
-                         */
-                       if (atif_proxy_probe_device(atif, &(sa->sat_addr)) < 0)
-                               return -EADDRINUSE;
-                       
+                               return -EINVAL;
+
                        /*
-                         * We now have an address on the local network, and
+                        * Check if the chosen address is used. If so we
+                        * error and ATCP will try another.
+                        */
+                       if (atif_proxy_probe_device(atif, &(sa->sat_addr)) < 0)
+                               return -EADDRINUSE;
+
+                       /*
+                        * We now have an address on the local network, and
                         * the AARP code will defend it for us until we take it
                         * down. We don't set up any routes right now, because
                         * ATCP will install them manually via SIOCADDRT.
-                         */
-                        break;
-
-                case SIOCDARP:
-                        if (!capable(CAP_NET_ADMIN))
-                                return -EPERM;
-                        if (sa->sat_family != AF_APPLETALK)
-                                return -EINVAL;
-                        if (!atif)
-                                return -EADDRNOTAVAIL;
-
-                        /* give to aarp module to remove proxy entry */
-                        aarp_proxy_remove(atif->dev, &(sa->sat_addr));
-                        return 0;
+                        */
+                       break;
+
+               case SIOCDARP:
+                       if (!capable(CAP_NET_ADMIN))
+                               return -EPERM;
+                       if (sa->sat_family != AF_APPLETALK)
+                               return -EINVAL;
+                       if (!atif)
+                               return -EADDRNOTAVAIL;
+
+                       /* give to aarp module to remove proxy entry */
+                       aarp_proxy_remove(atif->dev, &(sa->sat_addr));
+                       return 0;
        }
 
        return copy_to_user(arg, &atreq, sizeof(atreq)) ? -EFAULT : 0;
@@ -899,7 +899,7 @@ static int atrtr_ioctl(unsigned int cmd, void __user *arg)
                                dev = __dev_get_by_name(name);
                                if (!dev)
                                        return -ENODEV;
-                       }                       
+                       }
                        return atrtr_create(&rt, dev);
                }
        }
@@ -917,7 +917,7 @@ static int atrtr_ioctl(unsigned int cmd, void __user *arg)
  * Checksum: This is 'optional'. It's quite likely also a good
  * candidate for assembler hackery 8)
  */
-static unsigned long atalk_sum_partial(const unsigned char *data, 
+static unsigned long atalk_sum_partial(const unsigned char *data,
                                       int len, unsigned long sum)
 {
        /* This ought to be unwrapped neatly. I'll trust gcc for now */
@@ -945,7 +945,7 @@ static unsigned long atalk_sum_skb(const struct sk_buff *skb, int offset,
                if (copy > len)
                        copy = len;
                sum = atalk_sum_partial(skb->data + offset, copy, sum);
-               if ( (len -= copy) == 0) 
+               if ( (len -= copy) == 0)
                        return sum;
 
                offset += copy;
@@ -1031,7 +1031,7 @@ static int atalk_create(struct socket *sock, int protocol)
 
        /*
         * We permit SOCK_DGRAM and RAW is an extension. It is trivial to do
-        * and gives you the full ELAP frame. Should be handy for CAP 8) 
+        * and gives you the full ELAP frame. Should be handy for CAP 8)
         */
        if (sock->type != SOCK_RAW && sock->type != SOCK_DGRAM)
                goto out;
@@ -1196,14 +1196,14 @@ static int atalk_connect(struct socket *sock, struct sockaddr *uaddr,
 
        if (addr->sat_addr.s_node == ATADDR_BCAST &&
            !sock_flag(sk, SOCK_BROADCAST)) {
-#if 1  
+#if 1
                printk(KERN_WARNING "%s is broken and did not set "
                                    "SO_BROADCAST. It will break when 2.2 is "
                                    "released.\n",
                        current->comm);
 #else
                return -EACCES;
-#endif                 
+#endif
        }
 
        if (sock_flag(sk, SOCK_ZAPPED))
@@ -1260,27 +1260,27 @@ static int atalk_getname(struct socket *sock, struct sockaddr *uaddr,
 #if defined(CONFIG_IPDDP) || defined(CONFIG_IPDDP_MODULE)
 static __inline__ int is_ip_over_ddp(struct sk_buff *skb)
 {
-        return skb->data[12] == 22;
+       return skb->data[12] == 22;
 }
 
 static int handle_ip_over_ddp(struct sk_buff *skb)
 {
-        struct net_device *dev = __dev_get_by_name("ipddp0");
+       struct net_device *dev = __dev_get_by_name("ipddp0");
        struct net_device_stats *stats;
 
        /* This needs to be able to handle ipddp"N" devices */
-        if (!dev)
-                return -ENODEV;
+       if (!dev)
+               return -ENODEV;
 
-        skb->protocol = htons(ETH_P_IP);
-        skb_pull(skb, 13);
-        skb->dev   = dev;
-        skb->h.raw = skb->data;
+       skb->protocol = htons(ETH_P_IP);
+       skb_pull(skb, 13);
+       skb->dev   = dev;
+       skb->h.raw = skb->data;
 
        stats = dev->priv;
-        stats->rx_packets++;
-        stats->rx_bytes += skb->len + 13;
-        netif_rx(skb);  /* Send the SKB up to a higher place. */
+       stats->rx_packets++;
+       stats->rx_bytes += skb->len + 13;
+       netif_rx(skb);  /* Send the SKB up to a higher place. */
        return 0;
 }
 #else
@@ -1298,7 +1298,7 @@ static void atalk_route_packet(struct sk_buff *skb, struct net_device *dev,
 
        /*
         * Don't route multicast, etc., packets, or packets sent to "this
-        * network" 
+        * network"
         */
        if (skb->pkt_type != PACKET_HOST || !ddp->deh_dnet) {
                /*
@@ -1335,8 +1335,8 @@ static void atalk_route_packet(struct sk_buff *skb, struct net_device *dev,
                ta.s_node = rt->gateway.s_node;
        }
 
-        /* Fix up skb->len field */
-        skb_trim(skb, min_t(unsigned int, origlen,
+       /* Fix up skb->len field */
+       skb_trim(skb, min_t(unsigned int, origlen,
                            (rt->dev->hard_header_len +
                             ddp_dl->header_length + (len_hops & 1023))));
 
@@ -1358,12 +1358,12 @@ static void atalk_route_packet(struct sk_buff *skb, struct net_device *dev,
                /* 22 bytes - 12 ether, 2 len, 3 802.2 5 snap */
                struct sk_buff *nskb = skb_realloc_headroom(skb, 32);
                kfree_skb(skb);
-               if (!nskb) 
+               if (!nskb)
                        goto out;
                skb = nskb;
        } else
                skb = skb_unshare(skb, GFP_ATOMIC);
-       
+
        /*
         * If the buffer didn't vanish into the lack of space bitbucket we can
         * send it.
@@ -1395,13 +1395,13 @@ static int atalk_rcv(struct sk_buff *skb, struct net_device *dev,
        struct sock *sock;
        struct atalk_iface *atif;
        struct sockaddr_at tosat;
-        int origlen;
+       int origlen;
        __u16 len_hops;
 
        /* Don't mangle buffer if shared */
-       if (!(skb = skb_share_check(skb, GFP_ATOMIC))) 
+       if (!(skb = skb_share_check(skb, GFP_ATOMIC)))
                goto out;
-               
+
        /* Size check and make sure header is contiguous */
        if (!pskb_may_pull(skb, sizeof(*ddp)))
                goto freeit;
@@ -1490,7 +1490,7 @@ static int ltalk_rcv(struct sk_buff *skb, struct net_device *dev,
                        goto freeit;
 
                /* Don't mangle buffer if shared */
-               if (!(skb = skb_share_check(skb, GFP_ATOMIC))) 
+               if (!(skb = skb_share_check(skb, GFP_ATOMIC)))
                        return 0;
 
                /*
@@ -1501,11 +1501,11 @@ static int ltalk_rcv(struct sk_buff *skb, struct net_device *dev,
 
                /* Now fill in the long header */
 
-               /*
-                * These two first. The mac overlays the new source/dest
-                * network information so we MUST copy these before
-                * we write the network numbers !
-                */
+               /*
+                * These two first. The mac overlays the new source/dest
+                * network information so we MUST copy these before
+                * we write the network numbers !
+                */
 
                ddp->deh_dnode = skb->mac.raw[0];     /* From physical header */
                ddp->deh_snode = skb->mac.raw[1];     /* From physical header */
@@ -1605,7 +1605,7 @@ static int atalk_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr
        skb = sock_alloc_send_skb(sk, size, (flags & MSG_DONTWAIT), &err);
        if (!skb)
                return err;
-       
+
        skb->sk = sk;
        skb_reserve(skb, ddp_dl->header_length);
        skb_reserve(skb, dev->hard_header_len);
index 1237e208e246a5ebcce6d69f524749472c4d3b06..9e4dffc1e42359b91027868f1fc73bd8062c7368 100644 (file)
@@ -15,14 +15,14 @@ static int ltalk_change_mtu(struct net_device *dev, int mtu)
 }
 
 static int ltalk_mac_addr(struct net_device *dev, void *addr)
-{      
+{
        return -EINVAL;
 }
 
 static void ltalk_setup(struct net_device *dev)
 {
        /* Fill in the fields of the device structure with localtalk-generic values. */
-       
+
        dev->change_mtu         = ltalk_change_mtu;
        dev->hard_header        = NULL;
        dev->rebuild_header     = NULL;
@@ -34,8 +34,8 @@ static void ltalk_setup(struct net_device *dev)
        dev->hard_header_len    = LTALK_HLEN;
        dev->mtu                = LTALK_MTU;
        dev->addr_len           = LTALK_ALEN;
-       dev->tx_queue_len       = 10;   
-       
+       dev->tx_queue_len       = 10;
+
        dev->broadcast[0]       = 0xFF;
 
        dev->flags              = IFF_BROADCAST|IFF_MULTICAST|IFF_NOARP;
index 62f6ed1f2f98c9c5c25d70759f87d60e3e4f699d..f094a0879c16ddedcb386c6ca749a23f6c32fe9c 100644 (file)
@@ -30,15 +30,15 @@ static ssize_t show_address(struct class_device *cdev, char *buf)
 
 static ssize_t show_atmaddress(struct class_device *cdev, char *buf)
 {
-        unsigned long flags;
+       unsigned long flags;
        char *pos = buf;
        struct atm_dev *adev = to_atm_dev(cdev);
-        struct atm_dev_addr *aaddr;
+       struct atm_dev_addr *aaddr;
        int bin[] = { 1, 2, 10, 6, 1 }, *fmt = bin;
        int i, j;
 
-        spin_lock_irqsave(&adev->lock, flags);
-        list_for_each_entry(aaddr, &adev->local, entry) {
+       spin_lock_irqsave(&adev->lock, flags);
+       list_for_each_entry(aaddr, &adev->local, entry) {
                for(i = 0, j = 0; i < ATM_ESA_LEN; ++i, ++j) {
                        if (j == *fmt) {
                                pos += sprintf(pos, ".");
@@ -49,7 +49,7 @@ static ssize_t show_atmaddress(struct class_device *cdev, char *buf)
                }
                pos += sprintf(pos, "\n");
        }
-        spin_unlock_irqrestore(&adev->lock, flags);
+       spin_unlock_irqrestore(&adev->lock, flags);
 
        return pos - buf;
 }
@@ -61,7 +61,7 @@ static ssize_t show_carrier(struct class_device *cdev, char *buf)
 
        pos += sprintf(pos, "%d\n",
                       adev->signal == ATM_PHY_SIG_LOST ? 0 : 1);
-               
+
        return pos - buf;
 }
 
@@ -86,7 +86,7 @@ static ssize_t show_link_rate(struct class_device *cdev, char *buf)
                        link_rate = adev->link_rate * 8 * 53;
        }
        pos += sprintf(pos, "%d\n", link_rate);
-               
+
        return pos - buf;
 }
 
index 83a1c1b1d6cd2901761d5bc67b96c9594df094ba..f949b5c74ec19217e548ad2c762e7655acb19f65 100644 (file)
@@ -182,7 +182,7 @@ static int br2684_xmit_vcc(struct sk_buff *skb, struct br2684_dev *brdev,
        ATM_SKB(skb)->vcc = atmvcc = brvcc->atmvcc;
        DPRINTK("atm_skb(%p)->vcc(%p)->dev(%p)\n", skb, atmvcc, atmvcc->dev);
        if (!atm_may_send(atmvcc, skb->truesize)) {
-               /* we free this here for now, because we cannot know in a higher 
+               /* we free this here for now, because we cannot know in a higher
                        layer whether the skb point it supplied wasn't freed yet.
                        now, it always is.
                */
@@ -718,7 +718,7 @@ static void *br2684_seq_next(struct seq_file *seq, void *v, loff_t *pos)
 
        ++*pos;
 
-       brd = list_entry(brd->br2684_devs.next, 
+       brd = list_entry(brd->br2684_devs.next,
                         struct br2684_dev, br2684_devs);
        return (&brd->br2684_devs != &br2684_devs) ? brd : NULL;
 }
index fbabff49446830b45053103615095a44e0486c7d..282d761454baaca115b57ac3995dcb4466949fe5 100644 (file)
@@ -109,11 +109,11 @@ static inline int vcc_writable(struct sock *sk)
        struct atm_vcc *vcc = atm_sk(sk);
 
        return (vcc->qos.txtp.max_sdu +
-               atomic_read(&sk->sk_wmem_alloc)) <= sk->sk_sndbuf;
+               atomic_read(&sk->sk_wmem_alloc)) <= sk->sk_sndbuf;
 }
 
 static void vcc_write_space(struct sock *sk)
-{       
+{
        read_lock(&sk->sk_callback_lock);
 
        if (vcc_writable(sk)) {
@@ -131,7 +131,7 @@ static struct proto vcc_proto = {
        .owner    = THIS_MODULE,
        .obj_size = sizeof(struct atm_vcc),
 };
+
 int vcc_create(struct socket *sock, int protocol, int family)
 {
        struct sock *sk;
@@ -359,7 +359,7 @@ static int __vcc_connect(struct atm_vcc *vcc, struct atm_dev *dev, short vpi,
                return error;
        vcc->dev = dev;
        write_lock_irq(&vcc_sklist_lock);
-       if (test_bit(ATM_DF_REMOVED, &dev->flags) || 
+       if (test_bit(ATM_DF_REMOVED, &dev->flags) ||
            (error = find_ci(vcc, &vpi, &vci))) {
                write_unlock_irq(&vcc_sklist_lock);
                goto fail_module_put;
@@ -494,20 +494,20 @@ int vcc_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg,
        if (!skb)
                return error;
 
-       copied = skb->len; 
+       copied = skb->len;
        if (copied > size) {
-               copied = size; 
+               copied = size;
                msg->msg_flags |= MSG_TRUNC;
        }
 
-        error = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);
-        if (error)
-                return error;
-        sock_recv_timestamp(msg, sk, skb);
-        DPRINTK("RcvM %d -= %d\n", atomic_read(&sk->rmem_alloc), skb->truesize);
-        atm_return(vcc, skb->truesize);
-        skb_free_datagram(sk, skb);
-        return copied;
+       error = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);
+       if (error)
+               return error;
+       sock_recv_timestamp(msg, sk, skb);
+       DPRINTK("RcvM %d -= %d\n", atomic_read(&sk->rmem_alloc), skb->truesize);
+       atm_return(vcc, skb->truesize);
+       skb_free_datagram(sk, skb);
+       return copied;
 }
 
 
@@ -675,7 +675,7 @@ static int check_qos(struct atm_qos *qos)
        int error;
 
        if (!qos->txtp.traffic_class && !qos->rxtp.traffic_class)
-                return -EINVAL;
+               return -EINVAL;
        if (qos->txtp.traffic_class != qos->rxtp.traffic_class &&
            qos->txtp.traffic_class && qos->rxtp.traffic_class &&
            qos->txtp.traffic_class != ATM_ANYCLASS &&
@@ -786,11 +786,11 @@ static int __init atm_init(void)
                printk(KERN_ERR "atmsvc_init() failed with %d\n", error);
                goto out_atmpvc_exit;
        }
-        if ((error = atm_proc_init()) < 0) {
+       if ((error = atm_proc_init()) < 0) {
                printk(KERN_ERR "atm_proc_init() failed with %d\n",error);
                goto out_atmsvc_exit;
        }
-        if ((error = atm_sysfs_init()) < 0) {
+       if ((error = atm_sysfs_init()) < 0) {
                printk(KERN_ERR "atm_sysfs_init() failed with %d\n",error);
                goto out_atmproc_exit;
        }
@@ -816,7 +816,8 @@ static void __exit atm_exit(void)
        proto_unregister(&vcc_proto);
 }
 
-module_init(atm_init);
+subsys_initcall(atm_init);
+
 module_exit(atm_exit);
 
 MODULE_LICENSE("GPL");
index a422da7788fbd44852fadba2261c5c5f1cdd1c0e..ad78c9e1117d2d3d8c2a9fb5fa995c1539b447cb 100644 (file)
@@ -1,5 +1,5 @@
 /* net/atm/common.h - ATM sockets (common part for PVC and SVC) */
+
 /* Written 1995-2000 by Werner Almesberger, EPFL LRC/ICA */
 
 
index 8c2022c3e81dc05d0f9550e29c8bb9208fb4a4ac..8ccee4591f65f5571f4cfd8de770a0afd3e799f9 100644 (file)
@@ -76,7 +76,7 @@ int vcc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
                                }
                                skb = skb_peek(&sk->sk_receive_queue);
                                error = put_user(skb ? skb->len : 0,
-                                                (int __user *)argp) ? -EFAULT : 0;
+                                                (int __user *)argp) ? -EFAULT : 0;
                                goto done;
                        }
                case SIOCGSTAMP: /* borrowed from IP */
index 3fc0abeeaf344fac1d514b4f84b58339b6707703..57dc2ab1b65dd6c7d1b0dcb26f4c2c763359267c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * lec.c: Lan Emulation driver 
+ * lec.c: Lan Emulation driver
  *
  * Marko Kiiskila <mkiiskila@yahoo.com>
  */
@@ -1457,7 +1457,7 @@ static void lane2_associate_ind(struct net_device *dev, u8 *mac_addr,
 static void lec_arp_check_expire(struct work_struct *work);
 static void lec_arp_expire_arp(unsigned long data);
 
-/* 
+/*
  * Arp table funcs
  */
 
@@ -1473,9 +1473,9 @@ static void lec_arp_init(struct lec_priv *priv)
        for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
                INIT_HLIST_HEAD(&priv->lec_arp_tables[i]);
        }
-        INIT_HLIST_HEAD(&priv->lec_arp_empty_ones);
-        INIT_HLIST_HEAD(&priv->lec_no_forward);
-        INIT_HLIST_HEAD(&priv->mcast_fwds);
+       INIT_HLIST_HEAD(&priv->lec_arp_empty_ones);
+       INIT_HLIST_HEAD(&priv->lec_no_forward);
+       INIT_HLIST_HEAD(&priv->mcast_fwds);
        spin_lock_init(&priv->lec_arp_lock);
        INIT_DELAYED_WORK(&priv->lec_arp_work, lec_arp_check_expire);
        schedule_delayed_work(&priv->lec_arp_work, LEC_ARP_REFRESH_INTERVAL);
@@ -1770,7 +1770,7 @@ static void lec_arp_destroy(struct lec_priv *priv)
        spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
 }
 
-/* 
+/*
  * Find entry by mac_address
  */
 static struct lec_arp_table *lec_arp_find(struct lec_priv *priv,
@@ -1949,7 +1949,7 @@ restart:
 
 /*
  * Try to find vcc where mac_address is attached.
- * 
+ *
  */
 static struct atm_vcc *lec_arp_resolve(struct lec_priv *priv,
                                       unsigned char *mac_to_find, int is_rdesc,
@@ -2075,7 +2075,7 @@ lec_addr_delete(struct lec_priv *priv, unsigned char *atm_addr,
 }
 
 /*
- * Notifies:  Response to arp_request (atm_addr != NULL) 
+ * Notifies:  Response to arp_request (atm_addr != NULL)
  */
 static void
 lec_arp_update(struct lec_priv *priv, unsigned char *mac_addr,
@@ -2176,7 +2176,7 @@ out:
 }
 
 /*
- * Notifies: Vcc setup ready 
+ * Notifies: Vcc setup ready
  */
 static void
 lec_vcc_added(struct lec_priv *priv, struct atmlec_ioc *ioc_data,
@@ -2380,7 +2380,7 @@ lec_set_flush_tran_id(struct lec_priv *priv,
                        if (!memcmp(atm_addr, entry->atm_addr, ATM_ESA_LEN)) {
                                entry->flush_tran_id = tran_id;
                                DPRINTK("Set flush transaction id to %lx for %p\n",
-                                       tran_id, entry);
+                                       tran_id, entry);
                        }
                }
        spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
index 99136babd5357a273a8c758b5d47116fc59d6dcf..b41cda7ea1e183804121ab9f89ab48b935e306fd 100644 (file)
@@ -52,12 +52,12 @@ struct lane2_ops {
 
 /*
  * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
- * frames. 
+ * frames.
  *
  * 1. Dix Ethernet EtherType frames encoded by placing EtherType
  *    field in h_type field. Data follows immediatelly after header.
  * 2. LLC Data frames whose total length, including LLC field and data,
- *    but not padding required to meet the minimum data frame length, 
+ *    but not padding required to meet the minimum data frame length,
  *    is less than 1536(0x0600) MUST be encoded by placing that length
  *    in the h_type field. The LLC field follows header immediatelly.
  * 3. LLC data frames longer than this maximum MUST be encoded by placing
index c18f73715ef9799acdc6177f3d2470eb4f10f196..cb3c004ff0224986485cc8228db6b15b9d6f573a 100644 (file)
@@ -32,7 +32,7 @@
 #include "resources.h"
 
 /*
- * mpc.c: Implementation of MPOA client kernel part 
+ * mpc.c: Implementation of MPOA client kernel part
  */
 
 #if 0
@@ -80,17 +80,17 @@ static struct llc_snap_hdr llc_snap_mpoa_ctrl = {
        0xaa, 0xaa, 0x03,
        {0x00, 0x00, 0x5e},
        {0x00, 0x03}         /* For MPOA control PDUs */
-};        
+};
 static struct llc_snap_hdr llc_snap_mpoa_data = {
        0xaa, 0xaa, 0x03,
        {0x00, 0x00, 0x00},
        {0x08, 0x00}         /* This is for IP PDUs only */
-};        
+};
 static struct llc_snap_hdr llc_snap_mpoa_data_tagged = {
        0xaa, 0xaa, 0x03,
        {0x00, 0x00, 0x00},
        {0x88, 0x4c}         /* This is for tagged data PDUs */
-};        
+};
 
 static struct notifier_block mpoa_notifier = {
        mpoa_event_listener,
@@ -106,12 +106,12 @@ static DEFINE_TIMER(mpc_timer, NULL, 0, 0);
 static struct mpoa_client *find_mpc_by_itfnum(int itf)
 {
        struct mpoa_client *mpc;
-       
+
        mpc = mpcs;  /* our global linked list */
        while (mpc != NULL) {
                if (mpc->dev_num == itf)
                        return mpc;
-               mpc = mpc->next;    
+               mpc = mpc->next;
        }
 
        return NULL;   /* not found */
@@ -120,7 +120,7 @@ static struct mpoa_client *find_mpc_by_itfnum(int itf)
 static struct mpoa_client *find_mpc_by_vcc(struct atm_vcc *vcc)
 {
        struct mpoa_client *mpc;
-       
+
        mpc = mpcs;  /* our global linked list */
        while (mpc != NULL) {
                if (mpc->mpoad_vcc == vcc)
@@ -134,7 +134,7 @@ static struct mpoa_client *find_mpc_by_vcc(struct atm_vcc *vcc)
 static struct mpoa_client *find_mpc_by_lec(struct net_device *dev)
 {
        struct mpoa_client *mpc;
-       
+
        mpc = mpcs;  /* our global linked list */
        while (mpc != NULL) {
                if (mpc->dev == dev)
@@ -190,7 +190,7 @@ struct atm_mpoa_qos *atm_mpoa_search_qos(__be32 dst_ip)
        }
 
        return qos;
-}        
+}
 
 /*
  * Returns 0 for failure
@@ -245,7 +245,7 @@ static struct net_device *find_lec_by_itfnum(int itf)
 
        sprintf(name, "lec%d", itf);
        dev = dev_get_by_name(name);
-       
+
        return dev;
 }
 
@@ -265,25 +265,25 @@ static struct mpoa_client *alloc_mpc(void)
        mpc->parameters.mpc_p2 = MPC_P2;
        memset(mpc->parameters.mpc_p3,0,sizeof(mpc->parameters.mpc_p3));
        mpc->parameters.mpc_p4 = MPC_P4;
-       mpc->parameters.mpc_p5 = MPC_P5; 
+       mpc->parameters.mpc_p5 = MPC_P5;
        mpc->parameters.mpc_p6 = MPC_P6;
-       
+
        mpcs = mpc;
-       
+
        return mpc;
 }
 
 /*
  *
  * start_mpc() puts the MPC on line. All the packets destined
- * to the lec underneath us are now being monitored and 
+ * to the lec underneath us are now being monitored and
  * shortcuts will be established.
  *
  */
 static void start_mpc(struct mpoa_client *mpc, struct net_device *dev)
 {
-       
-       dprintk("mpoa: (%s) start_mpc:\n", mpc->dev->name); 
+
+       dprintk("mpoa: (%s) start_mpc:\n", mpc->dev->name);
        if (dev->hard_start_xmit == NULL) {
                printk("mpoa: (%s) start_mpc: dev->hard_start_xmit == NULL, not starting\n",
                       dev->name);
@@ -297,8 +297,8 @@ static void start_mpc(struct mpoa_client *mpc, struct net_device *dev)
 
 static void stop_mpc(struct mpoa_client *mpc)
 {
-       
-       dprintk("mpoa: (%s) stop_mpc:", mpc->dev->name); 
+
+       dprintk("mpoa: (%s) stop_mpc:", mpc->dev->name);
 
        /* Lets not nullify lec device's dev->hard_start_xmit */
        if (mpc->dev->hard_start_xmit != mpc_send_packet) {
@@ -309,7 +309,7 @@ static void stop_mpc(struct mpoa_client *mpc)
        mpc->dev->hard_start_xmit = mpc->old_hard_start_xmit;
        mpc->old_hard_start_xmit = NULL;
        /* close_shortcuts(mpc);    ??? FIXME */
-       
+
        return;
 }
 
@@ -358,7 +358,7 @@ static void lane2_assoc_ind(struct net_device *dev, uint8_t *mac_addr,
        uint8_t length, mpoa_device_type, number_of_mps_macs;
        uint8_t *end_of_tlvs;
        struct mpoa_client *mpc;
-       
+
        mpoa_device_type = number_of_mps_macs = 0; /* silence gcc */
        dprintk("mpoa: (%s) lane2_assoc_ind: received TLV(s), ", dev->name);
        dprintk("total length of all TLVs %d\n", sizeoftlvs);
@@ -377,7 +377,7 @@ static void lane2_assoc_ind(struct net_device *dev, uint8_t *mac_addr,
                        printk("TLV value extends past its buffer, aborting parse\n");
                        return;
                }
-               
+
                if (type == 0) {
                        printk("mpoa: (%s) lane2_assoc_ind: TLV type was 0, returning\n", dev->name);
                        return;
@@ -412,10 +412,10 @@ static void lane2_assoc_ind(struct net_device *dev, uint8_t *mac_addr,
                        continue;  /* someone should read the spec */
                }
                dprintk("this MPS has %d MAC addresses\n", number_of_mps_macs);
-               
+
                /* ok, now we can go and tell our daemon the control address of MPS */
                send_set_mps_ctrl_addr(tlvs, mpc);
-               
+
                tlvs = copy_macs(mpc, mac_addr, tlvs, number_of_mps_macs, mpoa_device_type);
                if (tlvs == NULL) return;
        }
@@ -474,7 +474,7 @@ static int send_via_shortcut(struct sk_buff *skb, struct mpoa_client *mpc)
        iph = (struct iphdr *)buff;
        ipaddr = iph->daddr;
 
-       ddprintk("mpoa: (%s) send_via_shortcut: ipaddr 0x%x\n", mpc->dev->name, ipaddr);        
+       ddprintk("mpoa: (%s) send_via_shortcut: ipaddr 0x%x\n", mpc->dev->name, ipaddr);
 
        entry = mpc->in_ops->get(ipaddr, mpc);
        if (entry == NULL) {
@@ -483,15 +483,15 @@ static int send_via_shortcut(struct sk_buff *skb, struct mpoa_client *mpc)
                return 1;
        }
        if (mpc->in_ops->cache_hit(entry, mpc) != OPEN){   /* threshold not exceeded or VCC not ready */
-               ddprintk("mpoa: (%s) send_via_shortcut: cache_hit: returns != OPEN\n", mpc->dev->name);        
+               ddprintk("mpoa: (%s) send_via_shortcut: cache_hit: returns != OPEN\n", mpc->dev->name);
                mpc->in_ops->put(entry);
                return 1;
        }
 
-       ddprintk("mpoa: (%s) send_via_shortcut: using shortcut\n", mpc->dev->name);        
+       ddprintk("mpoa: (%s) send_via_shortcut: using shortcut\n", mpc->dev->name);
        /* MPOA spec A.1.4, MPOA client must decrement IP ttl at least by one */
        if (iph->ttl <= 1) {
-               ddprintk("mpoa: (%s) send_via_shortcut: IP ttl = %u, using LANE\n", mpc->dev->name, iph->ttl);        
+               ddprintk("mpoa: (%s) send_via_shortcut: IP ttl = %u, using LANE\n", mpc->dev->name, iph->ttl);
                mpc->in_ops->put(entry);
                return 1;
        }
@@ -529,7 +529,7 @@ static int mpc_send_packet(struct sk_buff *skb, struct net_device *dev)
        struct mpoa_client *mpc;
        struct ethhdr *eth;
        int i = 0;
-       
+
        mpc = find_mpc_by_lec(dev); /* this should NEVER fail */
        if(mpc == NULL) {
                printk("mpoa: (%s) mpc_send_packet: no MPC found\n", dev->name);
@@ -549,7 +549,7 @@ static int mpc_send_packet(struct sk_buff *skb, struct net_device *dev)
 
  non_ip:
        retval = mpc->old_hard_start_xmit(skb,dev);
-       
+
        return retval;
 }
 
@@ -569,11 +569,11 @@ static int atm_mpoa_vcc_attach(struct atm_vcc *vcc, void __user *arg)
        ipaddr = ioc_data.ipaddr;
        if (ioc_data.dev_num < 0 || ioc_data.dev_num >= MAX_LEC_ITF)
                return -EINVAL;
-       
+
        mpc = find_mpc_by_itfnum(ioc_data.dev_num);
        if (mpc == NULL)
                return -EINVAL;
-       
+
        if (ioc_data.type == MPC_SOCKET_INGRESS) {
                in_entry = mpc->in_ops->get(ipaddr, mpc);
                if (in_entry == NULL || in_entry->entry_state < INGRESS_RESOLVED) {
@@ -604,7 +604,7 @@ static void mpc_vcc_close(struct atm_vcc *vcc, struct net_device *dev)
        struct mpoa_client *mpc;
        in_cache_entry *in_entry;
        eg_cache_entry *eg_entry;
-       
+
        mpc = find_mpc_by_lec(dev);
        if (mpc == NULL) {
                printk("mpoa: (%s) mpc_vcc_close: close for unknown MPC\n", dev->name);
@@ -640,14 +640,14 @@ static void mpc_push(struct atm_vcc *vcc, struct sk_buff *skb)
        struct mpoa_client *mpc;
        __be32 tag;
        char *tmp;
-       
+
        ddprintk("mpoa: (%s) mpc_push:\n", dev->name);
        if (skb == NULL) {
                dprintk("mpoa: (%s) mpc_push: null skb, closing VCC\n", dev->name);
                mpc_vcc_close(vcc, dev);
                return;
        }
-       
+
        skb->dev = dev;
        if (memcmp(skb->data, &llc_snap_mpoa_ctrl, sizeof(struct llc_snap_hdr)) == 0) {
                struct sock *sk = sk_atm(vcc);
@@ -693,11 +693,11 @@ static void mpc_push(struct atm_vcc *vcc, struct sk_buff *skb)
                dev_kfree_skb_any(skb);
                return;
        }
-       
+
        /*
         * See if ingress MPC is using shortcut we opened as a return channel.
         * This means we have a bi-directional vcc opened by us.
-        */ 
+        */
        if (eg->shortcut == NULL) {
                eg->shortcut = vcc;
                printk("mpoa: (%s) mpc_push: egress SVC in use\n", dev->name);
@@ -743,7 +743,7 @@ static int atm_mpoa_mpoad_attach (struct atm_vcc *vcc, int arg)
        struct mpoa_client *mpc;
        struct lec_priv *priv;
        int err;
-       
+
        if (mpcs == NULL) {
                init_timer(&mpc_timer);
                mpc_timer_refresh();
@@ -755,7 +755,7 @@ static int atm_mpoa_mpoad_attach (struct atm_vcc *vcc, int arg)
                        return err;
                }
        }
-       
+
        mpc = find_mpc_by_itfnum(arg);
        if (mpc == NULL) {
                dprintk("mpoa: mpoad_attach: allocating new mpc for itf %d\n", arg);
@@ -776,7 +776,7 @@ static int atm_mpoa_mpoad_attach (struct atm_vcc *vcc, int arg)
                        dev_put(mpc->dev);
                        mpc->dev = NULL;
                } else
-                       priv->lane2_ops->associate_indicator = lane2_assoc_ind;  
+                       priv->lane2_ops->associate_indicator = lane2_assoc_ind;
        }
 
        mpc->mpoad_vcc = vcc;
@@ -788,7 +788,7 @@ static int atm_mpoa_mpoad_attach (struct atm_vcc *vcc, int arg)
        if (mpc->dev) {
                char empty[ATM_ESA_LEN];
                memset(empty, 0, ATM_ESA_LEN);
-               
+
                start_mpc(mpc, mpc->dev);
                /* set address if mpcd e.g. gets killed and restarted.
                 * If we do not do it now we have to wait for the next LE_ARP
@@ -806,7 +806,7 @@ static void send_set_mps_ctrl_addr(char *addr, struct mpoa_client *mpc)
        struct k_message mesg;
 
        memcpy (mpc->mps_ctrl_addr, addr, ATM_ESA_LEN);
-       
+
        mesg.type = SET_MPS_CTRL_ADDR;
        memcpy(mesg.MPS_ctrl, addr, ATM_ESA_LEN);
        msg_to_mpoad(&mesg, mpc);
@@ -828,7 +828,7 @@ static void mpoad_close(struct atm_vcc *vcc)
                printk("mpoa: mpoad_close: close for non-present mpoad\n");
                return;
        }
-       
+
        mpc->mpoad_vcc = NULL;
        if (mpc->dev) {
                struct lec_priv *priv = (struct lec_priv *)mpc->dev->priv;
@@ -844,7 +844,7 @@ static void mpoad_close(struct atm_vcc *vcc)
                atm_return(vcc, skb->truesize);
                kfree_skb(skb);
        }
-       
+
        printk("mpoa: (%s) going down\n",
                (mpc->dev) ? mpc->dev->name : "<unknown>");
        module_put(THIS_MODULE);
@@ -857,11 +857,11 @@ static void mpoad_close(struct atm_vcc *vcc)
  */
 static int msg_from_mpoad(struct atm_vcc *vcc, struct sk_buff *skb)
 {
-       
+
        struct mpoa_client *mpc = find_mpc_by_vcc(vcc);
        struct k_message *mesg = (struct k_message*)skb->data;
        atomic_sub(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
-       
+
        if (mpc == NULL) {
                printk("mpoa: msg_from_mpoad: no mpc found\n");
                return 0;
@@ -938,7 +938,7 @@ int msg_to_mpoad(struct k_message *mesg, struct mpoa_client *mpc)
        skb_put(skb, sizeof(struct k_message));
        memcpy(skb->data, mesg, sizeof(struct k_message));
        atm_force_charge(mpc->mpoad_vcc, skb->truesize);
-       
+
        sk = sk_atm(mpc->mpoad_vcc);
        skb_queue_tail(&sk->sk_receive_queue, skb);
        sk->sk_data_ready(sk, skb->len);
@@ -955,7 +955,7 @@ static int mpoa_event_listener(struct notifier_block *mpoa_notifier, unsigned lo
        dev = (struct net_device *)dev_ptr;
        if (dev->name == NULL || strncmp(dev->name, "lec", 3))
                return NOTIFY_DONE; /* we are only interested in lec:s */
-       
+
        switch (event) {
        case NETDEV_REGISTER:       /* a new lec device was allocated */
                priv = (struct lec_priv *)dev->priv;
@@ -1043,7 +1043,7 @@ static void MPOA_trigger_rcvd(struct k_message *msg, struct mpoa_client *mpc)
                mpc->in_ops->put(entry);
                return;
        }
-       
+
        if(entry->entry_state == INGRESS_INVALID){
                entry->entry_state = INGRESS_RESOLVING;
                msg->type = SND_MPOA_RES_RQST;
@@ -1053,7 +1053,7 @@ static void MPOA_trigger_rcvd(struct k_message *msg, struct mpoa_client *mpc)
                mpc->in_ops->put(entry);
                return;
        }
-       
+
        printk("mpoa: (%s) MPOA_trigger_rcvd: entry already in resolving state\n",
                (mpc->dev) ? mpc->dev->name : "<unknown>");
        mpc->in_ops->put(entry);
@@ -1062,7 +1062,7 @@ static void MPOA_trigger_rcvd(struct k_message *msg, struct mpoa_client *mpc)
 
 /*
  * Things get complicated because we have to check if there's an egress
- * shortcut with suitable traffic parameters we could use. 
+ * shortcut with suitable traffic parameters we could use.
  */
 static void check_qos_and_open_shortcut(struct k_message *msg, struct mpoa_client *client, in_cache_entry *entry)
 {
@@ -1079,7 +1079,7 @@ static void check_qos_and_open_shortcut(struct k_message *msg, struct mpoa_clien
                            else if(eg_entry->shortcut->qos.txtp.max_pcr > 0)
                                    entry->shortcut = eg_entry->shortcut;
                }
-               if(entry->shortcut){
+               if(entry->shortcut){
                        dprintk("mpoa: (%s) using egress SVC to reach %u.%u.%u.%u\n",client->dev->name, NIPQUAD(dst_ip));
                        client->eg_ops->put(eg_entry);
                        return;
@@ -1094,7 +1094,7 @@ static void check_qos_and_open_shortcut(struct k_message *msg, struct mpoa_clien
        {
                msg->qos = qos->qos;
                printk("mpoa: (%s) trying to get a CBR shortcut\n",client->dev->name);
-       }
+       }
        else memset(&msg->qos,0,sizeof(struct atm_qos));
        msg_to_mpoad(msg, client);
        return;
@@ -1111,7 +1111,7 @@ static void MPOA_res_reply_rcvd(struct k_message *msg, struct mpoa_client *mpc)
                printk("\nmpoa: (%s) ARGH, received res. reply for an entry that doesn't exist.\n", mpc->dev->name);
                return;
        }
-       ddprintk(" entry_state = %d ", entry->entry_state);     
+       ddprintk(" entry_state = %d ", entry->entry_state);
 
        if (entry->entry_state == INGRESS_RESOLVED) {
                printk("\nmpoa: (%s) MPOA_res_reply_rcvd for RESOLVED entry!\n", mpc->dev->name);
@@ -1126,7 +1126,7 @@ static void MPOA_res_reply_rcvd(struct k_message *msg, struct mpoa_client *mpc)
        ddprintk("entry->shortcut = %p\n", entry->shortcut);
 
        if(entry->entry_state == INGRESS_RESOLVING && entry->shortcut != NULL){
-               entry->entry_state = INGRESS_RESOLVED; 
+               entry->entry_state = INGRESS_RESOLVED;
                mpc->in_ops->put(entry);
                return; /* Shortcut already open... */
        }
@@ -1137,7 +1137,7 @@ static void MPOA_res_reply_rcvd(struct k_message *msg, struct mpoa_client *mpc)
                mpc->in_ops->put(entry);
                return;
        }
-       
+
        check_qos_and_open_shortcut(msg, mpc, entry);
        entry->entry_state = INGRESS_RESOLVED;
        mpc->in_ops->put(entry);
@@ -1169,13 +1169,13 @@ static void ingress_purge_rcvd(struct k_message *msg, struct mpoa_client *mpc)
        } while (entry != NULL);
 
        return;
-} 
+}
 
 static void egress_purge_rcvd(struct k_message *msg, struct mpoa_client *mpc)
 {
        __be32 cache_id = msg->content.eg_info.cache_id;
        eg_cache_entry *entry = mpc->eg_ops->get_by_cache_id(cache_id, mpc);
-       
+
        if (entry == NULL) {
                dprintk("mpoa: (%s) egress_purge_rcvd: purge for a non-existing entry\n", mpc->dev->name);
                return;
@@ -1188,7 +1188,7 @@ static void egress_purge_rcvd(struct k_message *msg, struct mpoa_client *mpc)
        mpc->eg_ops->put(entry);
 
        return;
-} 
+}
 
 static void purge_egress_shortcut(struct atm_vcc *vcc, eg_cache_entry *entry)
 {
@@ -1259,7 +1259,7 @@ static void MPOA_cache_impos_rcvd( struct k_message * msg, struct mpoa_client *
 {
        uint16_t holding_time;
        eg_cache_entry *entry = mpc->eg_ops->get_by_cache_id(msg->content.eg_info.cache_id, mpc);
-       
+
        holding_time = msg->content.eg_info.holding_time;
        dprintk("mpoa: (%s) MPOA_cache_impos_rcvd: entry = %p, holding_time = %u\n",
               mpc->dev->name, entry, holding_time);
@@ -1272,13 +1272,13 @@ static void MPOA_cache_impos_rcvd( struct k_message * msg, struct mpoa_client *
                mpc->eg_ops->update(entry, holding_time);
                return;
        }
-       
+
        write_lock_irq(&mpc->egress_lock);
        mpc->eg_ops->remove_entry(entry, mpc);
        write_unlock_irq(&mpc->egress_lock);
 
        mpc->eg_ops->put(entry);
-       
+
        return;
 }
 
@@ -1328,7 +1328,7 @@ static void set_mps_mac_addr_rcvd(struct k_message *msg, struct mpoa_client *cli
                return;
        }
        client->number_of_mps_macs = 1;
-       
+
        return;
 }
 
@@ -1364,7 +1364,7 @@ static void mpc_timer_refresh(void)
        mpc_timer.data = mpc_timer.expires;
        mpc_timer.function = mpc_cache_check;
        add_timer(&mpc_timer);
-       
+
        return;
 }
 
@@ -1373,7 +1373,7 @@ static void mpc_cache_check( unsigned long checking_time  )
        struct mpoa_client *mpc = mpcs;
        static unsigned long previous_resolving_check_time;
        static unsigned long previous_refresh_time;
-       
+
        while( mpc != NULL ){
                mpc->in_ops->clear_count(mpc);
                mpc->eg_ops->clear_expired(mpc);
@@ -1388,7 +1388,7 @@ static void mpc_cache_check( unsigned long checking_time  )
                mpc = mpc->next;
        }
        mpc_timer_refresh();
-       
+
        return;
 }
 
index 51f460d005c306a5053a887278e8480e60e0d2af..24c386c35f5700442fcbee0134c6480daf8fa2a3 100644 (file)
 int msg_to_mpoad(struct k_message *msg, struct mpoa_client *mpc);
 
 struct mpoa_client {
-        struct mpoa_client *next;
-        struct net_device *dev;      /* lec in question                     */
-        int dev_num;                 /* e.g. 2 for lec2                     */
-        int (*old_hard_start_xmit)(struct sk_buff *skb, struct net_device *dev);
-        struct atm_vcc *mpoad_vcc;   /* control channel to mpoad            */
-        uint8_t mps_ctrl_addr[ATM_ESA_LEN];  /* MPS control ATM address     */
-        uint8_t our_ctrl_addr[ATM_ESA_LEN];  /* MPC's control ATM address   */
-
-        rwlock_t ingress_lock;
-        struct in_cache_ops *in_ops; /* ingress cache operations            */
-        in_cache_entry *in_cache;    /* the ingress cache of this MPC       */
-
-        rwlock_t egress_lock;
-        struct eg_cache_ops *eg_ops; /* egress cache operations             */
-        eg_cache_entry *eg_cache;    /* the egress  cache of this MPC       */
-
-        uint8_t *mps_macs;           /* array of MPS MAC addresses, >=1     */
-        int number_of_mps_macs;      /* number of the above MAC addresses   */
-        struct mpc_parameters parameters;  /* parameters for this client    */
+       struct mpoa_client *next;
+       struct net_device *dev;      /* lec in question                     */
+       int dev_num;                 /* e.g. 2 for lec2                     */
+       int (*old_hard_start_xmit)(struct sk_buff *skb, struct net_device *dev);
+       struct atm_vcc *mpoad_vcc;   /* control channel to mpoad            */
+       uint8_t mps_ctrl_addr[ATM_ESA_LEN];  /* MPS control ATM address     */
+       uint8_t our_ctrl_addr[ATM_ESA_LEN];  /* MPC's control ATM address   */
+
+       rwlock_t ingress_lock;
+       struct in_cache_ops *in_ops; /* ingress cache operations            */
+       in_cache_entry *in_cache;    /* the ingress cache of this MPC       */
+
+       rwlock_t egress_lock;
+       struct eg_cache_ops *eg_ops; /* egress cache operations             */
+       eg_cache_entry *eg_cache;    /* the egress  cache of this MPC       */
+
+       uint8_t *mps_macs;           /* array of MPS MAC addresses, >=1     */
+       int number_of_mps_macs;      /* number of the above MAC addresses   */
+       struct mpc_parameters parameters;  /* parameters for this client    */
 };
 
 
 struct atm_mpoa_qos {
-        struct atm_mpoa_qos *next;
-        __be32 ipaddr;
-        struct atm_qos qos;
+       struct atm_mpoa_qos *next;
+       __be32 ipaddr;
+       struct atm_qos qos;
 };
 
 
index 697a081533b5acf26d49731e53d28f6f8d1e781c..24799e3e78f786398e679823c3d29feea384bef8 100644 (file)
@@ -369,7 +369,7 @@ static eg_cache_entry *eg_cache_get_by_vcc(struct atm_vcc *vcc, struct mpoa_clie
        while (entry != NULL){
                if (entry->shortcut == vcc) {
                        atomic_inc(&entry->use);
-                       read_unlock_irqrestore(&mpc->egress_lock, flags);
+                       read_unlock_irqrestore(&mpc->egress_lock, flags);
                        return entry;
                }
                entry = entry->next;
@@ -388,7 +388,7 @@ static eg_cache_entry *eg_cache_get_by_src_ip(__be32 ipaddr, struct mpoa_client
        while(entry != NULL){
                if(entry->latest_ip_addr == ipaddr) {
                        atomic_inc(&entry->use);
-                       read_unlock_irq(&mpc->egress_lock);
+                       read_unlock_irq(&mpc->egress_lock);
                        return entry;
                }
                entry = entry->next;
index 84de977def2ed595a8f00679b008e0fd90279576..8e5f78cf0be1456c348a08e0539b31bea0f79632 100644 (file)
@@ -12,66 +12,66 @@ struct mpoa_client;
 void atm_mpoa_init_cache(struct mpoa_client *mpc);
 
 typedef struct in_cache_entry {
-        struct in_cache_entry *next;
-        struct in_cache_entry *prev;
-        struct timeval  tv;
-        struct timeval  reply_wait;
-        struct timeval  hold_down;
-        uint32_t  packets_fwded;
-        uint16_t  entry_state; 
-        uint32_t retry_time;
-        uint32_t refresh_time;
-        uint32_t count;
-        struct   atm_vcc *shortcut;
-        uint8_t  MPS_ctrl_ATM_addr[ATM_ESA_LEN];
-        struct   in_ctrl_info ctrl_info;
-        atomic_t use;
+       struct in_cache_entry *next;
+       struct in_cache_entry *prev;
+       struct timeval  tv;
+       struct timeval  reply_wait;
+       struct timeval  hold_down;
+       uint32_t  packets_fwded;
+       uint16_t  entry_state;
+       uint32_t retry_time;
+       uint32_t refresh_time;
+       uint32_t count;
+       struct   atm_vcc *shortcut;
+       uint8_t  MPS_ctrl_ATM_addr[ATM_ESA_LEN];
+       struct   in_ctrl_info ctrl_info;
+       atomic_t use;
 } in_cache_entry;
 
 struct in_cache_ops{
-        in_cache_entry *(*add_entry)(__be32 dst_ip,
-                                      struct mpoa_client *client);
-        in_cache_entry *(*get)(__be32 dst_ip, struct mpoa_client *client);
-        in_cache_entry *(*get_with_mask)(__be32 dst_ip,
+       in_cache_entry *(*add_entry)(__be32 dst_ip,
+                                     struct mpoa_client *client);
+       in_cache_entry *(*get)(__be32 dst_ip, struct mpoa_client *client);
+       in_cache_entry *(*get_with_mask)(__be32 dst_ip,
                                         struct mpoa_client *client,
                                         __be32 mask);
-        in_cache_entry *(*get_by_vcc)(struct atm_vcc *vcc, 
-                                      struct mpoa_client *client);
-        void            (*put)(in_cache_entry *entry);
-        void            (*remove_entry)(in_cache_entry *delEntry,
+       in_cache_entry *(*get_by_vcc)(struct atm_vcc *vcc,
+                                     struct mpoa_client *client);
+       void            (*put)(in_cache_entry *entry);
+       void            (*remove_entry)(in_cache_entry *delEntry,
                                        struct mpoa_client *client );
-        int             (*cache_hit)(in_cache_entry *entry,
-                                     struct mpoa_client *client);
-        void            (*clear_count)(struct mpoa_client *client);
-        void            (*check_resolving)(struct mpoa_client *client);
-        void            (*refresh)(struct mpoa_client *client);
-        void            (*destroy_cache)(struct mpoa_client *mpc);
+       int             (*cache_hit)(in_cache_entry *entry,
+                                    struct mpoa_client *client);
+       void            (*clear_count)(struct mpoa_client *client);
+       void            (*check_resolving)(struct mpoa_client *client);
+       void            (*refresh)(struct mpoa_client *client);
+       void            (*destroy_cache)(struct mpoa_client *mpc);
 };
 
 typedef struct eg_cache_entry{
-        struct               eg_cache_entry *next;
-        struct               eg_cache_entry *prev;
-        struct               timeval  tv;
-        uint8_t              MPS_ctrl_ATM_addr[ATM_ESA_LEN];
-        struct atm_vcc       *shortcut;
-        uint32_t             packets_rcvd;
-        uint16_t             entry_state;
-        __be32             latest_ip_addr;    /* The src IP address of the last packet */
-        struct eg_ctrl_info  ctrl_info;
-        atomic_t             use;
+       struct               eg_cache_entry *next;
+       struct               eg_cache_entry *prev;
+       struct               timeval  tv;
+       uint8_t              MPS_ctrl_ATM_addr[ATM_ESA_LEN];
+       struct atm_vcc       *shortcut;
+       uint32_t             packets_rcvd;
+       uint16_t             entry_state;
+       __be32             latest_ip_addr;    /* The src IP address of the last packet */
+       struct eg_ctrl_info  ctrl_info;
+       atomic_t             use;
 } eg_cache_entry;
 
 struct eg_cache_ops{
-        eg_cache_entry *(*add_entry)(struct k_message *msg, struct mpoa_client *client);
-        eg_cache_entry *(*get_by_cache_id)(__be32 cache_id, struct mpoa_client *client);
-        eg_cache_entry *(*get_by_tag)(__be32 cache_id, struct mpoa_client *client);
-        eg_cache_entry *(*get_by_vcc)(struct atm_vcc *vcc, struct mpoa_client *client);
-        eg_cache_entry *(*get_by_src_ip)(__be32 ipaddr, struct mpoa_client *client);
-        void            (*put)(eg_cache_entry *entry);
-        void            (*remove_entry)(eg_cache_entry *entry, struct mpoa_client *client);
-        void            (*update)(eg_cache_entry *entry, uint16_t holding_time);
-        void            (*clear_expired)(struct mpoa_client *client);
-        void            (*destroy_cache)(struct mpoa_client *mpc);
+       eg_cache_entry *(*add_entry)(struct k_message *msg, struct mpoa_client *client);
+       eg_cache_entry *(*get_by_cache_id)(__be32 cache_id, struct mpoa_client *client);
+       eg_cache_entry *(*get_by_tag)(__be32 cache_id, struct mpoa_client *client);
+       eg_cache_entry *(*get_by_vcc)(struct atm_vcc *vcc, struct mpoa_client *client);
+       eg_cache_entry *(*get_by_src_ip)(__be32 ipaddr, struct mpoa_client *client);
+       void            (*put)(eg_cache_entry *entry);
+       void            (*remove_entry)(eg_cache_entry *entry, struct mpoa_client *client);
+       void            (*update)(eg_cache_entry *entry, uint16_t holding_time);
+       void            (*clear_expired)(struct mpoa_client *client);
+       void            (*destroy_cache)(struct mpoa_client *mpc);
 };
 
 
@@ -85,7 +85,7 @@ struct eg_cache_ops{
 /* VCC states */
 
 #define OPEN   1
-#define CLOSED 0 
+#define CLOSED 0
 
 /* Egress cache entry states */
 
index 3844c85d602f240707e73aa27c859d1b79ecaadc..43315af10309c9b25b97c1e37032d49e9629758a 100644 (file)
@@ -2,7 +2,7 @@
 #ifdef CONFIG_PROC_FS
 #include <linux/errno.h>
 #include <linux/kernel.h>
-#include <linux/string.h> 
+#include <linux/string.h>
 #include <linux/mm.h>
 #include <linux/module.h>
 #include <linux/proc_fs.h>
@@ -16,7 +16,7 @@
 
 /*
  * mpoa_proc.c: Implementation MPOA client's proc
- * file system statistics 
+ * file system statistics
  */
 
 #if 1
@@ -32,7 +32,7 @@ extern struct proc_dir_entry *atm_proc_root;  /* from proc.c. */
 
 static int proc_mpc_open(struct inode *inode, struct file *file);
 static ssize_t proc_mpc_write(struct file *file, const char __user *buff,
-                              size_t nbytes, loff_t *ppos);
+                             size_t nbytes, loff_t *ppos);
 
 static int parse_qos(const char *buff);
 
@@ -52,18 +52,18 @@ static struct file_operations mpc_file_operations = {
  * Returns the state of an ingress cache entry as a string
  */
 static const char *ingress_state_string(int state){
-        switch(state) {
+       switch(state) {
        case INGRESS_RESOLVING:
-               return "resolving  ";
+               return "resolving  ";
                break;
        case INGRESS_RESOLVED:
-                return "resolved   ";
+               return "resolved   ";
                break;
        case INGRESS_INVALID:
-               return "invalid    ";
+               return "invalid    ";
                break;
        case INGRESS_REFRESHING:
-               return "refreshing ";
+               return "refreshing ";
                break;
        default:
               return "";
@@ -74,15 +74,15 @@ static const char *ingress_state_string(int state){
  * Returns the state of an egress cache entry as a string
  */
 static const char *egress_state_string(int state){
-        switch(state) {
+       switch(state) {
        case EGRESS_RESOLVED:
-               return "resolved   ";
+               return "resolved   ";
                break;
        case EGRESS_PURGE:
-                return "purge      ";
+               return "purge      ";
                break;
        case EGRESS_INVALID:
-               return "invalid    ";
+               return "invalid    ";
                break;
        default:
               return "";
@@ -135,7 +135,7 @@ static int mpc_show(struct seq_file *m, void *v)
                return 0;
        }
 
-       seq_printf(m, "\nInterface %d:\n\n", mpc->dev_num);  
+       seq_printf(m, "\nInterface %d:\n\n", mpc->dev_num);
        seq_printf(m, "Ingress Entries:\nIP address      State      Holding time  Packets fwded  VPI  VCI\n");
        do_gettimeofday(&now);
 
@@ -163,7 +163,7 @@ static int mpc_show(struct seq_file *m, void *v)
                           egress_state_string(eg_entry->entry_state),
                           (eg_entry->ctrl_info.holding_time-(now.tv_sec-eg_entry->tv.tv_sec)),
                           eg_entry->packets_rcvd);
-               
+
                /* latest IP address */
                temp = (unsigned char *)&eg_entry->latest_ip_addr;
                sprintf(ip_string, "%d.%d.%d.%d", temp[0], temp[1], temp[2], temp[3]);
@@ -190,51 +190,51 @@ static int proc_mpc_open(struct inode *inode, struct file *file)
 }
 
 static ssize_t proc_mpc_write(struct file *file, const char __user *buff,
-                              size_t nbytes, loff_t *ppos)
+                             size_t nbytes, loff_t *ppos)
 {
-        char *page, *p;
+       char *page, *p;
        unsigned len;
 
-        if (nbytes == 0)
+       if (nbytes == 0)
                return 0;
 
-        if (nbytes >= PAGE_SIZE)
+       if (nbytes >= PAGE_SIZE)
                nbytes = PAGE_SIZE-1;
 
-        page = (char *)__get_free_page(GFP_KERNEL);
-        if (!page)
+       page = (char *)__get_free_page(GFP_KERNEL);
+       if (!page)
                return -ENOMEM;
 
-        for (p = page, len = 0; len < nbytes; p++, len++) {
-                if (get_user(*p, buff++)) {
+       for (p = page, len = 0; len < nbytes; p++, len++) {
+               if (get_user(*p, buff++)) {
                        free_page((unsigned long)page);
                        return -EFAULT;
                }
-                if (*p == '\0' || *p == '\n')
-                        break;
-        }
+               if (*p == '\0' || *p == '\n')
+                       break;
+       }
 
-        *p = '\0';
+       *p = '\0';
 
        if (!parse_qos(page))
-                printk("mpoa: proc_mpc_write: could not parse '%s'\n", page);
+               printk("mpoa: proc_mpc_write: could not parse '%s'\n", page);
+
+       free_page((unsigned long)page);
 
-        free_page((unsigned long)page);
-        
-        return len;
+       return len;
 }
 
 static int parse_qos(const char *buff)
 {
-        /* possible lines look like this
-         * add 130.230.54.142 tx=max_pcr,max_sdu rx=max_pcr,max_sdu
-         */
-        unsigned char ip[4]; 
+       /* possible lines look like this
+        * add 130.230.54.142 tx=max_pcr,max_sdu rx=max_pcr,max_sdu
+        */
+       unsigned char ip[4];
        int tx_pcr, tx_sdu, rx_pcr, rx_sdu;
-        __be32 ipaddr;
-       struct atm_qos qos; 
-        
-        memset(&qos, 0, sizeof(struct atm_qos));
+       __be32 ipaddr;
+       struct atm_qos qos;
+
+       memset(&qos, 0, sizeof(struct atm_qos));
 
        if (sscanf(buff, "del %hhu.%hhu.%hhu.%hhu",
                        ip, ip+1, ip+2, ip+3) == 4) {
@@ -250,14 +250,14 @@ static int parse_qos(const char *buff)
                ip, ip+1, ip+2, ip+3, &tx_pcr, &tx_sdu, &rx_pcr, &rx_sdu) != 8)
                return 0;
 
-        ipaddr = *(__be32 *)ip;
+       ipaddr = *(__be32 *)ip;
        qos.txtp.traffic_class = ATM_CBR;
        qos.txtp.max_pcr = tx_pcr;
        qos.txtp.max_sdu = tx_sdu;
        qos.rxtp.traffic_class = ATM_CBR;
        qos.rxtp.max_pcr = rx_pcr;
        qos.rxtp.max_sdu = rx_sdu;
-        qos.aal = ATM_AAL5;
+       qos.aal = ATM_AAL5;
        dprintk("mpoa: mpoa_proc.c: parse_qos(): setting qos paramameters to tx=%d,%d rx=%d,%d\n",
                qos.txtp.max_pcr,
                qos.txtp.max_sdu,
@@ -276,11 +276,11 @@ int mpc_proc_init(void)
 {
        struct proc_dir_entry *p;
 
-        p = create_proc_entry(STAT_FILE_NAME, 0, atm_proc_root);
+       p = create_proc_entry(STAT_FILE_NAME, 0, atm_proc_root);
        if (!p) {
-                printk(KERN_ERR "Unable to initialize /proc/atm/%s\n", STAT_FILE_NAME);
-                return -ENOMEM;
-        }
+               printk(KERN_ERR "Unable to initialize /proc/atm/%s\n", STAT_FILE_NAME);
+               return -ENOMEM;
+       }
        p->proc_fops = &mpc_file_operations;
        p->owner = THIS_MODULE;
        return 0;
index 739866bfe9e9d6992c05e64227964db56dcb3968..190f49ce2cadd84db06cbc84b5ee61ce79d35828 100644 (file)
@@ -86,7 +86,7 @@ static int __vcc_walk(struct sock **sock, int family, int *bucket, loff_t l)
                                break;
                }
                l--;
-       } 
+       }
 try_again:
        for (; sk; sk = sk_next(sk)) {
                l -= compare_family(sk, family);
@@ -205,7 +205,7 @@ static void vcc_info(struct seq_file *seq, struct atm_vcc *vcc)
        seq_printf(seq, "%p ", vcc);
        if (!vcc->dev)
                seq_printf(seq, "Unassigned    ");
-       else 
+       else
                seq_printf(seq, "%3d %3d %5d ", vcc->dev->number, vcc->vpi,
                        vcc->vci);
        switch (sk->sk_family) {
@@ -249,7 +249,7 @@ static int atm_dev_seq_show(struct seq_file *seq, void *v)
        static char atm_dev_banner[] =
                "Itf Type    ESI/\"MAC\"addr "
                "AAL(TX,err,RX,err,drop) ...               [refcnt]\n";
+
        if (v == (void *)1)
                seq_puts(seq, atm_dev_banner);
        else {
@@ -257,21 +257,21 @@ static int atm_dev_seq_show(struct seq_file *seq, void *v)
 
                atm_dev_info(seq, dev);
        }
-       return 0;
+       return 0;
 }
+
 static struct seq_operations atm_dev_seq_ops = {
        .start  = atm_dev_seq_start,
        .next   = atm_dev_seq_next,
        .stop   = atm_dev_seq_stop,
        .show   = atm_dev_seq_show,
 };
+
 static int atm_dev_seq_open(struct inode *inode, struct file *file)
 {
        return seq_open(file, &atm_dev_seq_ops);
 }
+
 static struct file_operations devices_seq_fops = {
        .open           = atm_dev_seq_open,
        .read           = seq_read,
@@ -281,7 +281,7 @@ static struct file_operations devices_seq_fops = {
 
 static int pvc_seq_show(struct seq_file *seq, void *v)
 {
-       static char atm_pvc_banner[] = 
+       static char atm_pvc_banner[] =
                "Itf VPI VCI   AAL RX(PCR,Class) TX(PCR,Class)\n";
 
        if (v == (void *)1)
@@ -316,31 +316,31 @@ static struct file_operations pvc_seq_fops = {
 
 static int vcc_seq_show(struct seq_file *seq, void *v)
 {
-       if (v == (void *)1) {
-               seq_printf(seq, sizeof(void *) == 4 ? "%-8s%s" : "%-16s%s",
-                       "Address ", "Itf VPI VCI   Fam Flags Reply "
-                       "Send buffer     Recv buffer      [refcnt]\n");
-       } else {
-               struct vcc_state *state = seq->private;
-               struct atm_vcc *vcc = atm_sk(state->sk);
-  
-               vcc_info(seq, vcc);
-       }
-       return 0;
+       if (v == (void *)1) {
+               seq_printf(seq, sizeof(void *) == 4 ? "%-8s%s" : "%-16s%s",
+                       "Address ", "Itf VPI VCI   Fam Flags Reply "
+                       "Send buffer     Recv buffer      [refcnt]\n");
+       } else {
+               struct vcc_state *state = seq->private;
+               struct atm_vcc *vcc = atm_sk(state->sk);
+
+               vcc_info(seq, vcc);
+       }
+       return 0;
 }
-  
+
 static struct seq_operations vcc_seq_ops = {
-       .start  = vcc_seq_start,
-       .next   = vcc_seq_next,
-       .stop   = vcc_seq_stop,
-       .show   = vcc_seq_show,
+       .start  = vcc_seq_start,
+       .next   = vcc_seq_next,
+       .stop   = vcc_seq_stop,
+       .show   = vcc_seq_show,
 };
+
 static int vcc_seq_open(struct inode *inode, struct file *file)
 {
-       return __vcc_seq_open(inode, file, 0, &vcc_seq_ops);
+       return __vcc_seq_open(inode, file, 0, &vcc_seq_ops);
 }
+
 static struct file_operations vcc_seq_fops = {
        .open           = vcc_seq_open,
        .read           = seq_read,
@@ -350,7 +350,7 @@ static struct file_operations vcc_seq_fops = {
 
 static int svc_seq_show(struct seq_file *seq, void *v)
 {
-       static char atm_svc_banner[] = 
+       static char atm_svc_banner[] =
                "Itf VPI VCI           State      Remote\n";
 
        if (v == (void *)1)
@@ -472,7 +472,7 @@ static void atm_proc_dirs_remove(void)
        static struct atm_proc_entry *e;
 
        for (e = atm_proc_ents; e->name; e++) {
-               if (e->dirent) 
+               if (e->dirent)
                        remove_proc_entry(e->name, atm_proc_root);
        }
        remove_proc_entry("net/atm", NULL);
index b2148b43a42611c97780ff6dc8a0a8288527cf91..848e6e191cc7179f30c3cfdcfb4007f53c5e8a85 100644 (file)
@@ -72,7 +72,7 @@ static int pvc_setsockopt(struct socket *sock, int level, int optname,
 
 
 static int pvc_getsockopt(struct socket *sock, int level, int optname,
-                         char __user *optval, int __user *optlen)
+                         char __user *optval, int __user *optlen)
 {
        struct sock *sk = sock->sk;
        int error;
@@ -91,7 +91,7 @@ static int pvc_getname(struct socket *sock,struct sockaddr *sockaddr,
        struct atm_vcc *vcc = ATM_SD(sock);
 
        if (!vcc->dev || !test_bit(ATM_VF_ADDR,&vcc->flags)) return -ENOTCONN;
-        *sockaddr_len = sizeof(struct sockaddr_atmpvc);
+       *sockaddr_len = sizeof(struct sockaddr_atmpvc);
        addr = (struct sockaddr_atmpvc *) sockaddr;
        addr->sap_family = AF_ATMPVC;
        addr->sap_addr.itf = vcc->dev->number;
index 3e57b17ca523139222e771bd49656797b2ecab4b..4df7cdd72aa18de02a3dee725c145638d0a79f3d 100644 (file)
@@ -56,12 +56,12 @@ static int atm_send_aal0(struct atm_vcc *vcc,struct sk_buff *skb)
         * still work
         */
        if (!capable(CAP_NET_ADMIN) &&
-            (((u32 *) skb->data)[0] & (ATM_HDR_VPI_MASK | ATM_HDR_VCI_MASK)) !=
-            ((vcc->vpi << ATM_HDR_VPI_SHIFT) | (vcc->vci << ATM_HDR_VCI_SHIFT)))
+           (((u32 *) skb->data)[0] & (ATM_HDR_VPI_MASK | ATM_HDR_VCI_MASK)) !=
+           ((vcc->vpi << ATM_HDR_VPI_SHIFT) | (vcc->vci << ATM_HDR_VCI_SHIFT)))
            {
                kfree_skb(skb);
                return -EADDRNOTAVAIL;
-        }
+       }
        return vcc->dev->ops->send(vcc,skb);
 }
 
index 529f7e64aa2c33ae45d162b035ccf241431c6c0d..1bcf6dc8d40988b1f4a1e5198bfed470edb3e229 100644 (file)
@@ -142,8 +142,8 @@ void atm_dev_deregister(struct atm_dev *dev)
        set_bit(ATM_DF_REMOVED, &dev->flags);
 
        /*
-        * if we remove current device from atm_devs list, new device 
-        * with same number can appear, such we need deregister proc, 
+        * if we remove current device from atm_devs list, new device
+        * with same number can appear, such we need deregister proc,
         * release async all vccs and remove them from vccs list too
         */
        mutex_lock(&atm_dev_mutex);
@@ -228,7 +228,7 @@ int atm_dev_ioctl(unsigned int cmd, void __user *arg)
                                *tmp_p++ = dev->number;
                        }
                        mutex_unlock(&atm_dev_mutex);
-                       error = ((copy_to_user(buf, tmp_buf, size)) ||
+                       error = ((copy_to_user(buf, tmp_buf, size)) ||
                                        put_user(size, &iobuf->length))
                                                ? -EFAULT : 0;
                        kfree(tmp_buf);
@@ -247,7 +247,7 @@ int atm_dev_ioctl(unsigned int cmd, void __user *arg)
        if (!(dev = try_then_request_module(atm_dev_lookup(number),
                                            "atm-device-%d", number)))
                return -ENODEV;
-       
+
        switch (cmd) {
                case ATM_GETTYPE:
                        size = strlen(dev->type) + 1;
@@ -390,7 +390,7 @@ int atm_dev_ioctl(unsigned int cmd, void __user *arg)
                                goto done;
                        }
        }
-       
+
        if (size)
                error = put_user(size, &sioc->length)
                        ? -EFAULT : 0;
@@ -414,15 +414,15 @@ static __inline__ void *dev_get_idx(loff_t left)
 
 void *atm_dev_seq_start(struct seq_file *seq, loff_t *pos)
 {
-       mutex_lock(&atm_dev_mutex);
+       mutex_lock(&atm_dev_mutex);
        return *pos ? dev_get_idx(*pos) : (void *) 1;
 }
 
 void atm_dev_seq_stop(struct seq_file *seq, void *v)
 {
-       mutex_unlock(&atm_dev_mutex);
+       mutex_unlock(&atm_dev_mutex);
 }
+
 void *atm_dev_seq_next(struct seq_file *seq, void *v, loff_t *pos)
 {
        ++*pos;
index 434ead4557143f93b13f8779fa453fe70b97f511..08b2a69cc57273acee42a17b140195875baab94b 100644 (file)
@@ -1,7 +1,7 @@
 /* net/atm/signaling.h - ATM signaling */
+
 /* Written 1995-2000 by Werner Almesberger, EPFL LRC/ICA */
+
 
 #ifndef NET_ATM_SIGNALING_H
 #define NET_ATM_SIGNALING_H
index 3a180cfd7b48ee37116f9b78a1dc98081a9528d5..876ec7b47a2f7a8eff8b3882f7e69e9b32cac9ea 100644 (file)
@@ -89,7 +89,7 @@ static int svc_release(struct socket *sock)
                clear_bit(ATM_VF_READY, &vcc->flags);
                /* VCC pointer is used as a reference, so we must not free it
                   (thereby subjecting it to re-use) before all pending connections
-                  are closed */
+                  are closed */
                svc_disconnect(vcc);
                vcc_release(sock);
        }
@@ -144,7 +144,7 @@ static int svc_bind(struct socket *sock,struct sockaddr *sockaddr,
                error = -EUNATCH;
                goto out;
        }
-        if (!sk->sk_err)
+       if (!sk->sk_err)
                set_bit(ATM_VF_BOUND,&vcc->flags);
        error = -sk->sk_err;
 out:
@@ -229,7 +229,7 @@ static int svc_connect(struct socket *sock,struct sockaddr *sockaddr,
                         * This is tricky:
                         *   Kernel ---close--> Demon
                         *   Kernel <--close--- Demon
-                        * or
+                        * or
                         *   Kernel ---close--> Demon
                         *   Kernel <--error--- Demon
                         * or
@@ -470,13 +470,13 @@ static int svc_setsockopt(struct socket *sock, int level, int optname,
                        }
                        set_bit(ATM_VF_HASSAP, &vcc->flags);
                        break;
-               case SO_MULTIPOINT:
+               case SO_MULTIPOINT:
                        if (level != SOL_ATM || optlen != sizeof(int)) {
                                error = -EINVAL;
                                goto out;
                        }
-                       if (get_user(value, (int __user *) optval)) {
-                               error = -EFAULT;
+                       if (get_user(value, (int __user *) optval)) {
+                               error = -EFAULT;
                                goto out;
                        }
                        if (value == 1) {
@@ -486,7 +486,7 @@ static int svc_setsockopt(struct socket *sock, int level, int optname,
                        } else {
                                error = -EINVAL;
                        }
-                       break;
+                       break;
                default:
                        error = vcc_setsockopt(sock, level, optname,
                                               optval, optlen);
@@ -539,7 +539,7 @@ static int svc_addparty(struct socket *sock, struct sockaddr *sockaddr,
        set_bit(ATM_VF_WAITING, &vcc->flags);
        prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE);
        sigd_enq(vcc, as_addparty, NULL, NULL,
-                (struct sockaddr_atmsvc *) sockaddr);
+                (struct sockaddr_atmsvc *) sockaddr);
        if (flags & O_NONBLOCK) {
                finish_wait(sk->sk_sleep, &wait);
                error = -EINPROGRESS;
@@ -587,26 +587,26 @@ out:
 
 static int svc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
 {
-       int error, ep_ref;
-       struct sockaddr_atmsvc sa;
+       int error, ep_ref;
+       struct sockaddr_atmsvc sa;
        struct atm_vcc *vcc = ATM_SD(sock);
-  
+
        switch (cmd) {
-               case ATM_ADDPARTY:
-                       if (!test_bit(ATM_VF_SESSION, &vcc->flags))
-                               return -EINVAL;
-                       if (copy_from_user(&sa, (void __user *) arg, sizeof(sa)))
+               case ATM_ADDPARTY:
+                       if (!test_bit(ATM_VF_SESSION, &vcc->flags))
+                               return -EINVAL;
+                       if (copy_from_user(&sa, (void __user *) arg, sizeof(sa)))
                                return -EFAULT;
-                       error = svc_addparty(sock, (struct sockaddr *) &sa, sizeof(sa), 0);
-                       break;
-               case ATM_DROPPARTY:
-                       if (!test_bit(ATM_VF_SESSION, &vcc->flags))
-                               return -EINVAL;
-                       if (copy_from_user(&ep_ref, (void __user *) arg, sizeof(int)))
+                       error = svc_addparty(sock, (struct sockaddr *) &sa, sizeof(sa), 0);
+                       break;
+               case ATM_DROPPARTY:
+                       if (!test_bit(ATM_VF_SESSION, &vcc->flags))
+                               return -EINVAL;
+                       if (copy_from_user(&ep_ref, (void __user *) arg, sizeof(int)))
                                return -EFAULT;
-                       error = svc_dropparty(sock, ep_ref);
-                       break;
-               default:
+                       error = svc_dropparty(sock, ep_ref);
+                       break;
+               default:
                        error = vcc_ioctl(sock, cmd, arg);
        }
 
index 42233df2b09939ea835016f0050e68a90c4eaf26..9a0b677d1e7fdafd94f8aecc61741b104be461f8 100644 (file)
@@ -263,9 +263,9 @@ static void ax25_destroy_timer(unsigned long data)
 {
        ax25_cb *ax25=(ax25_cb *)data;
        struct sock *sk;
-       
+
        sk=ax25->sk;
-       
+
        bh_lock_sock(sk);
        sock_hold(sk);
        ax25_destroy_socket(ax25);
@@ -369,57 +369,57 @@ static int ax25_ctl_ioctl(const unsigned int cmd, void __user *arg)
                ax25_disconnect(ax25, ENETRESET);
                break;
 
-       case AX25_WINDOW:
-               if (ax25->modulus == AX25_MODULUS) {
-                       if (ax25_ctl.arg < 1 || ax25_ctl.arg > 7)
-                               return -EINVAL;
-               } else {
-                       if (ax25_ctl.arg < 1 || ax25_ctl.arg > 63)
-                               return -EINVAL;
-               }
-               ax25->window = ax25_ctl.arg;
-               break;
-
-       case AX25_T1:
+       case AX25_WINDOW:
+               if (ax25->modulus == AX25_MODULUS) {
+                       if (ax25_ctl.arg < 1 || ax25_ctl.arg > 7)
+                               return -EINVAL;
+               } else {
+                       if (ax25_ctl.arg < 1 || ax25_ctl.arg > 63)
+                               return -EINVAL;
+               }
+               ax25->window = ax25_ctl.arg;
+               break;
+
+       case AX25_T1:
                if (ax25_ctl.arg < 1)
-                       return -EINVAL;
-               ax25->rtt = (ax25_ctl.arg * HZ) / 2;
-               ax25->t1  = ax25_ctl.arg * HZ;
-               break;
-
-       case AX25_T2:
-               if (ax25_ctl.arg < 1)
-                       return -EINVAL;
-               ax25->t2 = ax25_ctl.arg * HZ;
-               break;
-
-       case AX25_N2:
-               if (ax25_ctl.arg < 1 || ax25_ctl.arg > 31)
                        return -EINVAL;
-               ax25->n2count = 0;
-               ax25->n2 = ax25_ctl.arg;
-               break;
-
-       case AX25_T3:
-               if (ax25_ctl.arg < 0)
-                       return -EINVAL;
-               ax25->t3 = ax25_ctl.arg * HZ;
-               break;
-
-       case AX25_IDLE:
-               if (ax25_ctl.arg < 0)
-                       return -EINVAL;
-               ax25->idle = ax25_ctl.arg * 60 * HZ;
-               break;
-
-       case AX25_PACLEN:
-               if (ax25_ctl.arg < 16 || ax25_ctl.arg > 65535)
-                       return -EINVAL;
-               ax25->paclen = ax25_ctl.arg;
-               break;
-
-       default:
-               return -EINVAL;
+               ax25->rtt = (ax25_ctl.arg * HZ) / 2;
+               ax25->t1  = ax25_ctl.arg * HZ;
+               break;
+
+       case AX25_T2:
+               if (ax25_ctl.arg < 1)
+                       return -EINVAL;
+               ax25->t2 = ax25_ctl.arg * HZ;
+               break;
+
+       case AX25_N2:
+               if (ax25_ctl.arg < 1 || ax25_ctl.arg > 31)
+                       return -EINVAL;
+               ax25->n2count = 0;
+               ax25->n2 = ax25_ctl.arg;
+               break;
+
+       case AX25_T3:
+               if (ax25_ctl.arg < 0)
+                       return -EINVAL;
+               ax25->t3 = ax25_ctl.arg * HZ;
+               break;
+
+       case AX25_IDLE:
+               if (ax25_ctl.arg < 0)
+                       return -EINVAL;
+               ax25->idle = ax25_ctl.arg * 60 * HZ;
+               break;
+
+       case AX25_PACLEN:
+               if (ax25_ctl.arg < 16 || ax25_ctl.arg > 65535)
+                       return -EINVAL;
+               ax25->paclen = ax25_ctl.arg;
+               break;
+
+       default:
+               return -EINVAL;
          }
 
        return 0;
@@ -1209,7 +1209,7 @@ static int __must_check ax25_connect(struct socket *sock,
 
        if (sk->sk_type == SOCK_SEQPACKET &&
            (ax25t=ax25_find_cb(&ax25->source_addr, &fsa->fsa_ax25.sax25_call, digi,
-                        ax25->ax25_dev->dev))) {
+                        ax25->ax25_dev->dev))) {
                kfree(digi);
                err = -EADDRINUSE;              /* Already such a connection */
                ax25_cb_put(ax25t);
@@ -1456,7 +1456,7 @@ static int ax25_sendmsg(struct kiocb *iocb, struct socket *sock,
                err = -EMSGSIZE;
                goto out;
        }
-               
+
        if (usax != NULL) {
                if (usax->sax25_family != AF_AX25) {
                        err = -EINVAL;
@@ -1470,8 +1470,8 @@ static int ax25_sendmsg(struct kiocb *iocb, struct socket *sock,
                else if (addr_len != sizeof(struct full_sockaddr_ax25)) {
                        /* support for old structure may go away some time */
                        if ((addr_len < sizeof(struct sockaddr_ax25) + sizeof(ax25_address) * 6) ||
-                           (addr_len > sizeof(struct full_sockaddr_ax25))) {
-                               err = -EINVAL;
+                           (addr_len > sizeof(struct full_sockaddr_ax25))) {
+                               err = -EINVAL;
                                goto out;
                        }
 
@@ -1624,7 +1624,7 @@ static int ax25_recvmsg(struct kiocb *iocb, struct socket *sock,
 
        /* Now we can treat all alike */
        skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT,
-                               flags & MSG_DONTWAIT, &err);
+                               flags & MSG_DONTWAIT, &err);
        if (skb == NULL)
                goto out;
 
@@ -1869,7 +1869,7 @@ static void *ax25_info_next(struct seq_file *seq, void *v, loff_t *pos)
        return hlist_entry( ((struct ax25_cb *)v)->ax25_node.next,
                            struct ax25_cb, ax25_node);
 }
-       
+
 static void ax25_info_stop(struct seq_file *seq, void *v)
 {
        spin_unlock_bh(&ax25_list_lock);
index 97a49c79c6050df6caf43543caaff4d8bd07b3fc..419e7188d5a770da0f8e0b4aab4f226d01762955 100644 (file)
@@ -126,10 +126,10 @@ int ax25cmp(const ax25_address *a, const ax25_address *b)
                ct++;
        }
 
-       if ((a->ax25_call[ct] & 0x1E) == (b->ax25_call[ct] & 0x1E))     /* SSID without control bit */
-               return 0;
+       if ((a->ax25_call[ct] & 0x1E) == (b->ax25_call[ct] & 0x1E))     /* SSID without control bit */
+               return 0;
 
-       return 2;                       /* Partial match */
+       return 2;                       /* Partial match */
 }
 
 EXPORT_SYMBOL(ax25cmp);
index 136c3aefa9dec10983d1543c4cead6a876675019..8d62d86816150b9d814f1edc469f065c48a48b80 100644 (file)
@@ -55,46 +55,46 @@ int ax25_hard_header(struct sk_buff *skb, struct net_device *dev, unsigned short
        if (type == ETH_P_AX25)
                return 0;
 
-       /* header is an AX.25 UI frame from us to them */
-       buff = skb_push(skb, AX25_HEADER_LEN);
-       *buff++ = 0x00; /* KISS DATA */
+       /* header is an AX.25 UI frame from us to them */
+       buff = skb_push(skb, AX25_HEADER_LEN);
+       *buff++ = 0x00; /* KISS DATA */
 
        if (daddr != NULL)
                memcpy(buff, daddr, dev->addr_len);     /* Address specified */
 
-       buff[6] &= ~AX25_CBIT;
-       buff[6] &= ~AX25_EBIT;
-       buff[6] |= AX25_SSSID_SPARE;
-       buff    += AX25_ADDR_LEN;
-
-       if (saddr != NULL)
-               memcpy(buff, saddr, dev->addr_len);
-       else
-               memcpy(buff, dev->dev_addr, dev->addr_len);
-
-       buff[6] &= ~AX25_CBIT;
-       buff[6] |= AX25_EBIT;
-       buff[6] |= AX25_SSSID_SPARE;
-       buff    += AX25_ADDR_LEN;
-
-       *buff++  = AX25_UI;     /* UI */
-
-       /* Append a suitable AX.25 PID */
-       switch (type) {
-       case ETH_P_IP:
-               *buff++ = AX25_P_IP;
-               break;
-       case ETH_P_ARP:
-               *buff++ = AX25_P_ARP;
-               break;
-       default:
-               printk(KERN_ERR "AX.25: ax25_hard_header - wrong protocol type 0x%2.2x\n", type);
-               *buff++ = 0;
-               break;
-       }
+       buff[6] &= ~AX25_CBIT;
+       buff[6] &= ~AX25_EBIT;
+       buff[6] |= AX25_SSSID_SPARE;
+       buff    += AX25_ADDR_LEN;
+
+       if (saddr != NULL)
+               memcpy(buff, saddr, dev->addr_len);
+       else
+               memcpy(buff, dev->dev_addr, dev->addr_len);
+
+       buff[6] &= ~AX25_CBIT;
+       buff[6] |= AX25_EBIT;
+       buff[6] |= AX25_SSSID_SPARE;
+       buff    += AX25_ADDR_LEN;
+
+       *buff++  = AX25_UI;     /* UI */
+
+       /* Append a suitable AX.25 PID */
+       switch (type) {
+       case ETH_P_IP:
+               *buff++ = AX25_P_IP;
+               break;
+       case ETH_P_ARP:
+               *buff++ = AX25_P_ARP;
+               break;
+       default:
+               printk(KERN_ERR "AX.25: ax25_hard_header - wrong protocol type 0x%2.2x\n", type);
+               *buff++ = 0;
+               break;
+       }
 
        if (daddr != NULL)
-               return AX25_HEADER_LEN;
+               return AX25_HEADER_LEN;
 
        return -AX25_HEADER_LEN;        /* Unfinished header */
 }
@@ -114,8 +114,8 @@ int ax25_rebuild_header(struct sk_buff *skb)
        dst = (ax25_address *)(bp + 1);
        src = (ax25_address *)(bp + 8);
 
-       if (arp_find(bp + 1, skb))
-               return 1;
+       if (arp_find(bp + 1, skb))
+               return 1;
 
        route = ax25_get_route(dst, NULL);
        if (route) {
@@ -127,8 +127,8 @@ int ax25_rebuild_header(struct sk_buff *skb)
        if (dev == NULL)
                dev = skb->dev;
 
-        if ((ax25_dev = ax25_dev_ax25dev(dev)) == NULL) {
-                goto put;
+       if ((ax25_dev = ax25_dev_ax25dev(dev)) == NULL) {
+               goto put;
        }
 
        if (bp[16] == AX25_P_IP) {
@@ -175,8 +175,8 @@ int ax25_rebuild_header(struct sk_buff *skb)
                        ourskb->nh.raw = ourskb->data;
 
                        ax25=ax25_send_frame(
-                           ourskb, 
-                           ax25_dev->values[AX25_VALUES_PACLEN], 
+                           ourskb,
+                           ax25_dev->values[AX25_VALUES_PACLEN],
                            &src_c,
                            &dst_c, digipeat, dev);
                        if (ax25) {
@@ -186,13 +186,13 @@ int ax25_rebuild_header(struct sk_buff *skb)
                }
        }
 
-       bp[7]  &= ~AX25_CBIT;
-       bp[7]  &= ~AX25_EBIT;
-       bp[7]  |= AX25_SSSID_SPARE;
+       bp[7]  &= ~AX25_CBIT;
+       bp[7]  &= ~AX25_EBIT;
+       bp[7]  |= AX25_SSSID_SPARE;
 
-       bp[14] &= ~AX25_CBIT;
-       bp[14] |= AX25_EBIT;
-       bp[14] |= AX25_SSSID_SPARE;
+       bp[14] &= ~AX25_CBIT;
+       bp[14] |= AX25_EBIT;
+       bp[14] |= AX25_SSSID_SPARE;
 
        skb_pull(skb, AX25_KISS_HEADER_LEN);
 
@@ -211,7 +211,7 @@ put:
        if (route)
                ax25_put_route(route);
 
-       return 1;
+       return 1;
 }
 
 #else  /* INET */
index 0a0381622b1cb16ce7d630ae8c18d54938a8c3b2..7078861a738510b549d7d160c1c060886e0a32cf 100644 (file)
@@ -87,7 +87,7 @@ static int __must_check ax25_rt_add(struct ax25_routes_struct *route)
        ax25_rt = ax25_route_list;
        while (ax25_rt != NULL) {
                if (ax25cmp(&ax25_rt->callsign, &route->dest_addr) == 0 &&
-                           ax25_rt->dev == ax25_dev->dev) {
+                           ax25_rt->dev == ax25_dev->dev) {
                        kfree(ax25_rt->digipeat);
                        ax25_rt->digipeat = NULL;
                        if (route->digi_count != 0) {
@@ -252,8 +252,8 @@ static void *ax25_rt_seq_start(struct seq_file *seq, loff_t *pos)
 {
        struct ax25_route *ax25_rt;
        int i = 1;
-       read_lock(&ax25_route_lock);
+
+       read_lock(&ax25_route_lock);
        if (*pos == 0)
                return SEQ_START_TOKEN;
 
@@ -269,7 +269,7 @@ static void *ax25_rt_seq_start(struct seq_file *seq, loff_t *pos)
 static void *ax25_rt_seq_next(struct seq_file *seq, void *v, loff_t *pos)
 {
        ++*pos;
-       return (v == SEQ_START_TOKEN) ? ax25_route_list : 
+       return (v == SEQ_START_TOKEN) ? ax25_route_list :
                ((struct ax25_route *) v)->next;
 }
 
index a29c480a4dc1f992f7f339c44f4b3d0ca9184526..e3528b1a7802b61b3f0caa5da791c84235f87fc2 100644 (file)
@@ -34,7 +34,7 @@
 void ax25_std_heartbeat_expiry(ax25_cb *ax25)
 {
        struct sock *sk=ax25->sk;
-       
+
        if (sk)
                bh_lock_sock(sk);
 
index c41dbe5fadee53867d98e24967ce96f942a32c18..85c58c49b4d0bd2873abfc76167102c0dfa4e7a6 100644 (file)
@@ -56,7 +56,7 @@ void ax25_frames_acked(ax25_cb *ax25, unsigned short nr)
         */
        if (ax25->va != nr) {
                while (skb_peek(&ax25->ack_queue) != NULL && ax25->va != nr) {
-                       skb = skb_dequeue(&ax25->ack_queue);
+                       skb = skb_dequeue(&ax25->ack_queue);
                        kfree_skb(skb);
                        ax25->va = (ax25->va + 1) % ax25->modulus;
                }
@@ -65,7 +65,7 @@ void ax25_frames_acked(ax25_cb *ax25, unsigned short nr)
 
 void ax25_requeue_frames(ax25_cb *ax25)
 {
-        struct sk_buff *skb, *skb_prev = NULL;
+       struct sk_buff *skb, *skb_prev = NULL;
 
        /*
         * Requeue all the un-ack-ed frames on the output queue to be picked
index 5e9a81e8b214fe4fa96a7977be12c1fbe9378a05..7f4c294b36f111a2bb866129a0d66dcf2397deed 100644 (file)
@@ -164,7 +164,7 @@ static void *ax25_uid_seq_next(struct seq_file *seq, void *v, loff_t *pos)
        ++*pos;
 
        return hlist_entry(((ax25_uid_assoc *)v)->uid_node.next,
-                          ax25_uid_assoc, uid_node);
+                          ax25_uid_assoc, uid_node);
 }
 
 static void ax25_uid_seq_stop(struct seq_file *seq, void *v)
index 67df99e2e5c82b2a4fc72e28dc748a33209fcd55..c7228cfc6218b031e17a5f2779595ea365499ce4 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
    BlueZ - Bluetooth protocol stack for Linux
    Copyright (C) 2000-2001 Qualcomm Incorporated
 
    OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
    IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
-   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES 
-   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 
-   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 
+   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
+   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
-   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 
-   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS 
+   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
+   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
    SOFTWARE IS DISCLAIMED.
 */
 
@@ -119,7 +119,7 @@ static int bt_sock_create(struct socket *sock, int proto)
 
        read_unlock(&bt_proto_lock);
 
-       return err; 
+       return err;
 }
 
 void bt_sock_link(struct bt_sock_list *l, struct sock *sk)
@@ -265,7 +265,7 @@ unsigned int bt_sock_poll(struct file * file, struct socket *sock, poll_table *w
        if (sk->sk_shutdown == SHUTDOWN_MASK)
                mask |= POLLHUP;
 
-       if (!skb_queue_empty(&sk->sk_receive_queue) || 
+       if (!skb_queue_empty(&sk->sk_receive_queue) ||
                        (sk->sk_shutdown & RCV_SHUTDOWN))
                mask |= POLLIN | POLLRDNORM;
 
index 0b6cd0e2528d4eb64e2f35addbd5869fc619a925..a2992280c3d1ee3a5b908faf793a18b6b4f16e5c 100644 (file)
@@ -1,7 +1,7 @@
 /*
   BNEP protocol definition for Linux Bluetooth stack (BlueZ).
   Copyright (C) 2002 Maxim Krasnyansky <maxk@qualcomm.com>
-       
+
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License, version 2, as
   published by the Free Software Foundation.
@@ -60,7 +60,7 @@
 // Extension types
 #define BNEP_EXT_CONTROL           0x00
 
-// Response messages 
+// Response messages
 #define BNEP_SUCCESS               0x00
 
 #define BNEP_CONN_INVALID_DST      0x01
@@ -81,7 +81,7 @@
 #define BNEP_CONNECT_TO  15
 #define BNEP_FILTER_TO   15
 
-// Headers 
+// Headers
 #define BNEP_TYPE_MASK  0x7f
 #define BNEP_EXT_HEADER         0x80
 
@@ -132,7 +132,7 @@ struct bnep_conndel_req {
 struct bnep_conninfo {
        __u32 flags;
        __u16 role;
-       __u16 state;    
+       __u16 state;
        __u8  dst[ETH_ALEN];
        char  device[16];
 };
@@ -155,10 +155,10 @@ int bnep_get_conninfo(struct bnep_conninfo *ci);
 // BNEP sessions
 struct bnep_session {
        struct list_head list;
-       
+
        unsigned int  role;
-        unsigned long state;
-        unsigned long flags;
+       unsigned long state;
+       unsigned long flags;
        atomic_t      killed;
 
        struct ethhdr eh;
@@ -166,7 +166,7 @@ struct bnep_session {
 
        struct bnep_proto_filter proto_filter[BNEP_MAX_PROTO_FILTERS];
        u64    mc_filter;
-       
+
        struct socket    *sock;
        struct net_device *dev;
        struct net_device_stats stats;
@@ -178,7 +178,7 @@ int bnep_sock_cleanup(void);
 
 static inline int bnep_mc_hash(__u8 *addr)
 {
-        return (crc32_be(~0, addr, ETH_ALEN) >> 26);
+       return (crc32_be(~0, addr, ETH_ALEN) >> 26);
 }
 
 #endif
index 7ba6470dc507224815c72d44d09f3da14e8e6c46..b85d1492c357795344c4e960633bbc84a5fdeffe 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
    BNEP implementation for Linux Bluetooth stack (BlueZ).
    Copyright (C) 2001-2002 Inventel Systemes
    Written 2001-2002 by
    OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
    IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
-   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES 
-   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 
-   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 
+   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
+   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
-   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 
-   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS 
+   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
+   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
    SOFTWARE IS DISCLAIMED.
 */
 
 /*
  * $Id: core.c,v 1.20 2002/08/04 21:23:58 maxk Exp $
- */ 
+ */
 
 #include <linux/module.h>
 
@@ -74,7 +74,7 @@ static struct bnep_session *__bnep_get_session(u8 *dst)
        BT_DBG("");
 
        list_for_each(p, &bnep_session_list) {
-               s = list_entry(p, struct bnep_session, list);   
+               s = list_entry(p, struct bnep_session, list);
                if (!compare_ether_addr(dst, s->eh.h_source))
                        return s;
        }
@@ -87,7 +87,7 @@ static void __bnep_link_session(struct bnep_session *s)
           by the socket layer which has to hold the refference to this module.
         */
        __module_get(THIS_MODULE);
-       list_add(&s->list, &bnep_session_list); 
+       list_add(&s->list, &bnep_session_list);
 }
 
 static void __bnep_unlink_session(struct bnep_session *s)
@@ -203,7 +203,7 @@ static int bnep_ctrl_set_mcfilter(struct bnep_session *s, u8 *data, int len)
 
                        memcpy(a1, data, ETH_ALEN); data += ETH_ALEN;
                        a2 = data; data += ETH_ALEN;
-       
+
                        BT_DBG("mc filter %s -> %s",
                                batostr((void *) a1), batostr((void *) a2));
 
@@ -277,7 +277,7 @@ static int bnep_rx_extension(struct bnep_session *s, struct sk_buff *skb)
                }
 
                BT_DBG("type 0x%x len %d", h->type, h->len);
-       
+
                switch (h->type & BNEP_TYPE_MASK) {
                case BNEP_EXT_CONTROL:
                        bnep_rx_control(s, skb->data, skb->len);
@@ -293,7 +293,7 @@ static int bnep_rx_extension(struct bnep_session *s, struct sk_buff *skb)
                        break;
                }
        } while (!err && (h->type & BNEP_EXT_HEADER));
-       
+
        return err;
 }
 
@@ -319,7 +319,7 @@ static inline int bnep_rx_frame(struct bnep_session *s, struct sk_buff *skb)
 
        if ((type & BNEP_TYPE_MASK) > BNEP_RX_TYPES)
                goto badframe;
-       
+
        if ((type & BNEP_TYPE_MASK) == BNEP_CONTROL) {
                bnep_rx_control(s, skb->data, skb->len);
                kfree_skb(skb);
@@ -345,7 +345,7 @@ static inline int bnep_rx_frame(struct bnep_session *s, struct sk_buff *skb)
                        goto badframe;
                s->eh.h_proto = get_unaligned((__be16 *) (skb->data - 2));
        }
-       
+
        /* We have to alloc new skb and copy data here :(. Because original skb
         * may not be modified and because of the alignment requirements. */
        nskb = alloc_skb(2 + ETH_HLEN + skb->len, GFP_KERNEL);
@@ -361,7 +361,7 @@ static inline int bnep_rx_frame(struct bnep_session *s, struct sk_buff *skb)
        case BNEP_COMPRESSED:
                memcpy(__skb_put(nskb, ETH_HLEN), &s->eh, ETH_HLEN);
                break;
-       
+
        case BNEP_COMPRESSED_SRC_ONLY:
                memcpy(__skb_put(nskb, ETH_ALEN), s->eh.h_dest, ETH_ALEN);
                memcpy(__skb_put(nskb, ETH_ALEN), skb->mac.raw, ETH_ALEN);
@@ -381,7 +381,7 @@ static inline int bnep_rx_frame(struct bnep_session *s, struct sk_buff *skb)
 
        memcpy(__skb_put(nskb, skb->len), skb->data, skb->len);
        kfree_skb(skb);
-       
+
        s->stats.rx_packets++;
        nskb->dev       = dev;
        nskb->ip_summed = CHECKSUM_NONE;
@@ -435,7 +435,7 @@ static inline int bnep_tx_frame(struct bnep_session *s, struct sk_buff *skb)
                iv[il++] = (struct kvec) { eh->h_source, ETH_ALEN };
                len += ETH_ALEN;
                break;
-               
+
        case BNEP_COMPRESSED_DST_ONLY:
                iv[il++] = (struct kvec) { eh->h_dest, ETH_ALEN };
                len += ETH_ALEN;
@@ -445,7 +445,7 @@ static inline int bnep_tx_frame(struct bnep_session *s, struct sk_buff *skb)
 send:
        iv[il++] = (struct kvec) { skb->data, skb->len };
        len += skb->len;
-       
+
        /* FIXME: linearize skb */
        {
                len = kernel_sendmsg(sock, &s->msg, iv, il, len);
@@ -471,7 +471,7 @@ static int bnep_session(void *arg)
 
        BT_DBG("");
 
-        daemonize("kbnepd %s", dev->name);
+       daemonize("kbnepd %s", dev->name);
        set_user_nice(current, -15);
        current->flags |= PF_NOFREEZE;
 
@@ -488,13 +488,13 @@ static int bnep_session(void *arg)
 
                if (sk->sk_state != BT_CONNECTED)
                        break;
-       
+
                // TX
                while ((skb = skb_dequeue(&sk->sk_write_queue)))
                        if (bnep_tx_frame(s, skb))
                                break;
                netif_wake_queue(dev);
-       
+
                schedule();
        }
        set_current_state(TASK_RUNNING);
@@ -573,7 +573,7 @@ int bnep_add_connection(struct bnep_connadd_req *req, struct socket *sock)
        s->sock  = sock;
        s->role  = req->role;
        s->state = BT_CONNECTED;
-       
+
        s->msg.msg_flags = MSG_NOSIGNAL;
 
 #ifdef CONFIG_BT_BNEP_MC_FILTER
@@ -594,7 +594,7 @@ int bnep_add_connection(struct bnep_connadd_req *req, struct socket *sock)
        }
 
        __bnep_link_session(s);
-       
+
        err = kernel_thread(bnep_session, s, CLONE_KERNEL);
        if (err < 0) {
                /* Session thread start failed, gotta cleanup. */
@@ -627,7 +627,7 @@ int bnep_del_connection(struct bnep_conndel_req *req)
                /* Wakeup user-space which is polling for socket errors.
                 * This is temporary hack untill we have shutdown in L2CAP */
                s->sock->sk->sk_err = EUNATCH;
-               
+
                /* Kill session thread */
                atomic_inc(&s->killed);
                wake_up_interruptible(s->sock->sk->sk_sleep);
@@ -661,7 +661,7 @@ int bnep_get_connlist(struct bnep_connlist_req *req)
                s = list_entry(p, struct bnep_session, list);
 
                __bnep_copy_ci(&ci, s);
-               
+
                if (copy_to_user(req->ci, &ci, sizeof(ci))) {
                        err = -EFAULT;
                        break;
@@ -696,7 +696,7 @@ int bnep_get_conninfo(struct bnep_conninfo *ci)
 }
 
 static int __init bnep_init(void)
-{      
+{
        char flt[50] = "";
 
        l2cap_load();
index 67a002a9751aa85865364c89b8b1e35043c4dfc8..9092816f58de1e589d3afe951e2fa3b94b7404a0 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
    BNEP implementation for Linux Bluetooth stack (BlueZ).
    Copyright (C) 2001-2002 Inventel Systemes
    Written 2001-2002 by
    OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
    IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
-   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES 
-   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 
-   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 
+   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
+   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
-   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 
-   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS 
+   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
+   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
    SOFTWARE IS DISCLAIMED.
 */
 
 /*
  * $Id: netdev.c,v 1.8 2002/08/04 21:23:58 maxk Exp $
- */ 
+ */
 
 #include <linux/module.h>
 
@@ -94,7 +94,7 @@ static void bnep_net_set_mc_list(struct net_device *dev)
        r->type = BNEP_CONTROL;
        r->ctrl = BNEP_FILTER_MULTI_ADDR_SET;
 
-        if (dev->flags & (IFF_PROMISC | IFF_ALLMULTI)) {
+       if (dev->flags & (IFF_PROMISC | IFF_ALLMULTI)) {
                u8 start[ETH_ALEN] = { 0x01 };
 
                /* Request all addresses */
@@ -102,14 +102,14 @@ static void bnep_net_set_mc_list(struct net_device *dev)
                memcpy(__skb_put(skb, ETH_ALEN), dev->broadcast, ETH_ALEN);
                r->len = htons(ETH_ALEN * 2);
        } else {
-                struct dev_mc_list *dmi = dev->mc_list;
+               struct dev_mc_list *dmi = dev->mc_list;
                int i, len = skb->len;
 
                if (dev->flags & IFF_BROADCAST) {
                        memcpy(__skb_put(skb, ETH_ALEN), dev->broadcast, ETH_ALEN);
                        memcpy(__skb_put(skb, ETH_ALEN), dev->broadcast, ETH_ALEN);
-               }       
-               
+               }
+
                /* FIXME: We should group addresses here. */
 
                for (i = 0; i < dev->mc_count && i < BNEP_MAX_MULTICAST_FILTERS; i++) {
@@ -159,13 +159,13 @@ static inline u16 bnep_net_eth_proto(struct sk_buff *skb)
 {
        struct ethhdr *eh = (void *) skb->data;
        u16 proto = ntohs(eh->h_proto);
-       
+
        if (proto >= 1536)
                return proto;
-               
+
        if (get_unaligned((__be16 *) skb->data) == htons(0xFFFF))
                return ETH_P_802_3;
-               
+
        return ETH_P_802_2;
 }
 
@@ -174,7 +174,7 @@ static inline int bnep_net_proto_filter(struct sk_buff *skb, struct bnep_session
        u16 proto = bnep_net_eth_proto(skb);
        struct bnep_proto_filter *f = s->proto_filter;
        int i;
-       
+
        for (i = 0; i < BNEP_MAX_PROTO_FILTERS && f[i].end; i++) {
                if (proto >= f[i].start && proto <= f[i].end)
                        return 0;
@@ -198,14 +198,14 @@ static int bnep_net_xmit(struct sk_buff *skb, struct net_device *dev)
                return 0;
        }
 #endif
-       
+
 #ifdef CONFIG_BT_BNEP_PROTO_FILTER
        if (bnep_net_proto_filter(skb, s)) {
                kfree_skb(skb);
                return 0;
        }
 #endif
-       
+
        /*
         * We cannot send L2CAP packets from here as we are potentially in a bh.
         * So we have to queue them and wake up session thread which is sleeping
index 5563db1bf526e94d4a48c5af511315c4d3646786..6d7311cee1b4c7161caf18ed84ecdb0a2aba51d4 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
    BNEP implementation for Linux Bluetooth stack (BlueZ).
    Copyright (C) 2001-2002 Inventel Systemes
    Written 2001-2002 by
    OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
    IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
-   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES 
-   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 
-   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 
+   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
+   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
-   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 
-   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS 
+   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
+   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
    SOFTWARE IS DISCLAIMED.
 */
 
 /*
  * $Id: sock.c,v 1.4 2002/08/04 21:23:58 maxk Exp $
- */ 
+ */
 
 #include <linux/module.h>
 
@@ -89,7 +89,7 @@ static int bnep_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
 
                if (copy_from_user(&ca, argp, sizeof(ca)))
                        return -EFAULT;
-       
+
                nsock = sockfd_lookup(ca.sock, &err);
                if (!nsock)
                        return err;
@@ -101,20 +101,20 @@ static int bnep_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
 
                err = bnep_add_connection(&ca, nsock);
                if (!err) {
-                       if (copy_to_user(argp, &ca, sizeof(ca)))
+                       if (copy_to_user(argp, &ca, sizeof(ca)))
                                err = -EFAULT;
                } else
                        fput(nsock->file);
 
                return err;
-       
+
        case BNEPCONNDEL:
                if (!capable(CAP_NET_ADMIN))
                        return -EACCES;
 
                if (copy_from_user(&cd, argp, sizeof(cd)))
                        return -EFAULT;
-       
+
                return bnep_del_connection(&cd);
 
        case BNEPGETCONNLIST:
@@ -123,7 +123,7 @@ static int bnep_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
 
                if (cl.cnum <= 0)
                        return -EINVAL;
-       
+
                err = bnep_get_connlist(&cl);
                if (!err && copy_to_user(argp, &cl, sizeof(cl)))
                        return -EFAULT;
@@ -163,7 +163,7 @@ static int bnep_sock_compat_ioctl(struct socket *sock, unsigned int cmd, unsigne
 
                if (cl.cnum <= 0)
                        return -EINVAL;
-       
+
                err = bnep_get_connlist(&cl);
 
                if (!err && put_user(cl.cnum, (uint32_t __user *) arg))
index ab166b48ce8dc02c8288b44d21d4d9c5ce7b2d22..3e9d5bb3fefb6de364353c62684efd5b7629e9d4 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
    CMTP implementation for Linux Bluetooth stack (BlueZ).
    Copyright (C) 2002-2003 Marcel Holtmann <marcel@holtmann.org>
 
    OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
    IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
-   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES 
-   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 
-   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 
+   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
+   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
-   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 
-   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS 
+   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
+   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
    SOFTWARE IS DISCLAIMED.
 */
 
@@ -563,7 +563,7 @@ int cmtp_attach_device(struct cmtp_session *session)
 
        ret = wait_event_interruptible_timeout(session->wait,
                        session->ncontroller, CMTP_INTEROP_TIMEOUT);
-       
+
        BT_INFO("Found %d CAPI controller(s) on device %s", session->ncontroller, session->name);
 
        if (!ret)
index 40e3dfec0cc8677c5141ee337c8b67da9dce8d0d..e4663aa14d264830d528c8fdc109ff3381da5e59 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
    CMTP implementation for Linux Bluetooth stack (BlueZ).
    Copyright (C) 2002-2003 Marcel Holtmann <marcel@holtmann.org>
 
    OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
    IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
-   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES 
-   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 
-   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 
+   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
+   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
-   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 
-   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS 
+   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
+   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
    SOFTWARE IS DISCLAIMED.
 */
 
index b81a01c64aeae8b35e601aec9029a98f4c1ecc86..3933608a92965b3c5cf9459d9cdabad557302312 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
    CMTP implementation for Linux Bluetooth stack (BlueZ).
    Copyright (C) 2002-2003 Marcel Holtmann <marcel@holtmann.org>
 
    OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
    IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
-   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES 
-   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 
-   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 
+   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
+   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
-   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 
-   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS 
+   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
+   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
    SOFTWARE IS DISCLAIMED.
 */
 
@@ -336,7 +336,7 @@ int cmtp_add_connection(struct cmtp_connadd_req *req, struct socket *sock)
        baswap(&dst, &bt_sk(sock->sk)->dst);
 
        session = kzalloc(sizeof(struct cmtp_session), GFP_KERNEL);
-       if (!session) 
+       if (!session)
                return -ENOMEM;
 
        down_write(&cmtp_session_sem);
index 53295d33dc5c31eb610c1766e5795f3c7a123cfd..0c5ccd95517fcef43adf46a41a70171fe1d08927 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
    CMTP implementation for Linux Bluetooth stack (BlueZ).
    Copyright (C) 2002-2003 Marcel Holtmann <marcel@holtmann.org>
 
    OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
    IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
-   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES 
-   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 
-   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 
+   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
+   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
-   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 
-   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS 
+   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
+   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
    SOFTWARE IS DISCLAIMED.
 */
 
@@ -154,7 +154,7 @@ static int cmtp_sock_compat_ioctl(struct socket *sock, unsigned int cmd, unsigne
 
                if (cl.cnum <= 0)
                        return -EINVAL;
-       
+
                err = cmtp_get_connlist(&cl);
 
                if (!err && put_user(cl.cnum, (uint32_t __user *) arg))
index 6cd5711fa28a59265403a81f608e6698e7f03dfa..67ee0bd80f5f838f1904ea90aaf1aad37606f41a 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
    BlueZ - Bluetooth protocol stack for Linux
    Copyright (C) 2000-2001 Qualcomm Incorporated
 
    OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
    IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
-   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES 
-   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 
-   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 
+   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
+   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
-   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 
-   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS 
+   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
+   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
    SOFTWARE IS DISCLAIMED.
 */
 
@@ -146,7 +146,7 @@ static void hci_conn_timeout(unsigned long arg)
        case BT_CONNECT:
                hci_acl_connect_cancel(conn);
                break;
-       case BT_CONNECTED:
+       case BT_CONNECTED:
                hci_acl_disconn(conn, 0x13);
                break;
        default:
@@ -272,7 +272,7 @@ struct hci_dev *hci_get_route(bdaddr_t *dst, bdaddr_t *src)
                if (!test_bit(HCI_UP, &d->flags) || test_bit(HCI_RAW, &d->flags))
                        continue;
 
-               /* Simple routing: 
+               /* Simple routing:
                 *   No source address - find interface with bdaddr != dst
                 *   Source address    - find interface with bdaddr == src
                 */
@@ -328,7 +328,7 @@ struct hci_conn * hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst)
 
                hci_conn_hold(sco);
 
-               if (acl->state == BT_CONNECTED && 
+               if (acl->state == BT_CONNECTED &&
                                (sco->state == BT_OPEN || sco->state == BT_CLOSED))
                        hci_add_sco(sco, acl->handle);
 
@@ -370,7 +370,7 @@ int hci_conn_encrypt(struct hci_conn *conn)
        if (hci_conn_auth(conn)) {
                struct hci_cp_set_conn_encrypt cp;
                cp.handle  = __cpu_to_le16(conn->handle);
-               cp.encrypt = 1; 
+               cp.encrypt = 1;
                hci_send_cmd(conn->hdev, OGF_LINK_CTL, OCF_SET_CONN_ENCRYPT, sizeof(cp), &cp);
        }
        return 0;
index 338ae977a31b2209fb39e1a97d644db185d4597a..4917919d86a6b251ddb35027571c46c6add6fcb0 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
    BlueZ - Bluetooth protocol stack for Linux
    Copyright (C) 2000-2001 Qualcomm Incorporated
 
    OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
    IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
-   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES 
-   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 
-   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 
+   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
+   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
-   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 
-   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS 
+   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
+   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
    SOFTWARE IS DISCLAIMED.
 */
 
@@ -116,7 +116,7 @@ static void hci_req_cancel(struct hci_dev *hdev, int err)
 }
 
 /* Execute request and wait for completion. */
-static int __hci_request(struct hci_dev *hdev, void (*req)(struct hci_dev *hdev, unsigned long opt), 
+static int __hci_request(struct hci_dev *hdev, void (*req)(struct hci_dev *hdev, unsigned long opt),
                                unsigned long opt, __u32 timeout)
 {
        DECLARE_WAITQUEUE(wait, current);
@@ -278,7 +278,7 @@ static void hci_encrypt_req(struct hci_dev *hdev, unsigned long opt)
        hci_send_cmd(hdev, OGF_HOST_CTL, OCF_WRITE_ENCRYPT_MODE, 1, &encrypt);
 }
 
-/* Get HCI device by index. 
+/* Get HCI device by index.
  * Device is held on return. */
 struct hci_dev *hci_dev_get(int index)
 {
@@ -405,7 +405,7 @@ int hci_inquiry(void __user *arg)
                return -ENODEV;
 
        hci_dev_lock_bh(hdev);
-       if (inquiry_cache_age(hdev) > INQUIRY_CACHE_AGE_MAX || 
+       if (inquiry_cache_age(hdev) > INQUIRY_CACHE_AGE_MAX ||
                                        inquiry_cache_empty(hdev) ||
                                        ir.flags & IREQ_CACHE_FLUSH) {
                inquiry_cache_flush(hdev);
@@ -439,7 +439,7 @@ int hci_inquiry(void __user *arg)
                if (copy_to_user(ptr, buf, sizeof(struct inquiry_info) *
                                        ir.num_rsp))
                        err = -EFAULT;
-       } else 
+       } else
                err = -EFAULT;
 
        kfree(buf);
@@ -491,7 +491,7 @@ int hci_dev_open(__u16 dev)
                hci_dev_hold(hdev);
                set_bit(HCI_UP, &hdev->flags);
                hci_notify(hdev, HCI_DEV_UP);
-       } else {        
+       } else {
                /* Init failed, cleanup */
                tasklet_kill(&hdev->rx_task);
                tasklet_kill(&hdev->tx_task);
@@ -619,7 +619,7 @@ int hci_dev_reset(__u16 dev)
        if (hdev->flush)
                hdev->flush(hdev);
 
-       atomic_set(&hdev->cmd_cnt, 1); 
+       atomic_set(&hdev->cmd_cnt, 1);
        hdev->acl_cnt = 0; hdev->sco_cnt = 0;
 
        if (!test_bit(HCI_RAW, &hdev->flags))
@@ -841,7 +841,7 @@ int hci_register_dev(struct hci_dev *hdev)
                        break;
                head = p; id++;
        }
-       
+
        sprintf(hdev->name, "hci%d", id);
        hdev->id = id;
        list_add(&hdev->list, head);
@@ -1109,7 +1109,7 @@ int hci_send_acl(struct hci_conn *conn, struct sk_buff *skb, __u16 flags)
                __skb_queue_tail(&conn->data_q, skb);
                do {
                        skb = list; list = list->next;
-                       
+
                        skb->dev = (void *) hdev;
                        bt_cb(skb)->pkt_type = HCI_ACLDATA_PKT;
                        hci_add_acl_hdr(skb, conn->handle, flags | ACL_CONT);
@@ -1164,7 +1164,7 @@ static inline struct hci_conn *hci_low_sent(struct hci_dev *hdev, __u8 type, int
        int num = 0, min = ~0;
        struct list_head *p;
 
-       /* We don't have to lock device here. Connections are always 
+       /* We don't have to lock device here. Connections are always
         * added and removed with TX task disabled. */
        list_for_each(p, &h->list) {
                struct hci_conn *c;
@@ -1306,7 +1306,7 @@ static inline void hci_acldata_packet(struct hci_dev *hdev, struct sk_buff *skb)
        hci_dev_lock(hdev);
        conn = hci_conn_hash_lookup_handle(hdev, handle);
        hci_dev_unlock(hdev);
-       
+
        if (conn) {
                register struct hci_proto *hp;
 
@@ -1318,7 +1318,7 @@ static inline void hci_acldata_packet(struct hci_dev *hdev, struct sk_buff *skb)
                        return;
                }
        } else {
-               BT_ERR("%s ACL packet for unknown connection handle %d", 
+               BT_ERR("%s ACL packet for unknown connection handle %d",
                        hdev->name, handle);
        }
 
@@ -1353,7 +1353,7 @@ static inline void hci_scodata_packet(struct hci_dev *hdev, struct sk_buff *skb)
                        return;
                }
        } else {
-               BT_ERR("%s SCO packet for unknown connection handle %d", 
+               BT_ERR("%s SCO packet for unknown connection handle %d",
                        hdev->name, handle);
        }
 
index bb94e6da223cb6f3535f5fecd611e91d3c0c067f..00d845e3d30789e0e36baa7847e9825378f7292f 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
    BlueZ - Bluetooth protocol stack for Linux
    Copyright (C) 2000-2001 Qualcomm Incorporated
 
    OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
    IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
-   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES 
-   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 
-   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 
+   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
+   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
-   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 
-   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS 
+   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
+   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
    SOFTWARE IS DISCLAIMED.
 */
 
@@ -100,7 +100,7 @@ static void hci_cc_link_policy(struct hci_dev *hdev, __u16 ocf, struct sk_buff *
        BT_DBG("%s ocf 0x%x", hdev->name, ocf);
 
        switch (ocf) {
-       case OCF_ROLE_DISCOVERY: 
+       case OCF_ROLE_DISCOVERY:
                rd = (void *) skb->data;
 
                if (rd->status)
@@ -141,7 +141,7 @@ static void hci_cc_link_policy(struct hci_dev *hdev, __u16 ocf, struct sk_buff *
                break;
 
        default:
-               BT_DBG("%s: Command complete: ogf LINK_POLICY ocf %x", 
+               BT_DBG("%s: Command complete: ogf LINK_POLICY ocf %x",
                                hdev->name, ocf);
                break;
        }
@@ -237,10 +237,10 @@ static void hci_cc_host_ctl(struct hci_dev *hdev, __u16 ocf, struct sk_buff *skb
                if (!status) {
                        clear_bit(HCI_PSCAN, &hdev->flags);
                        clear_bit(HCI_ISCAN, &hdev->flags);
-                       if (param & SCAN_INQUIRY) 
+                       if (param & SCAN_INQUIRY)
                                set_bit(HCI_ISCAN, &hdev->flags);
 
-                       if (param & SCAN_PAGE) 
+                       if (param & SCAN_PAGE)
                                set_bit(HCI_PSCAN, &hdev->flags);
                }
                hci_req_complete(hdev, status);
@@ -343,7 +343,7 @@ static void hci_cc_info_param(struct hci_dev *hdev, __u16 ocf, struct sk_buff *s
 
                memcpy(hdev->features, lf->features, sizeof(hdev->features));
 
-               /* Adjust default settings according to features 
+               /* Adjust default settings according to features
                 * supported by device. */
                if (hdev->features[0] & LMP_3SLOT)
                        hdev->pkt_type |= (HCI_DM3 | HCI_DH3);
@@ -491,7 +491,7 @@ static void hci_cs_link_ctl(struct hci_dev *hdev, __u16 ocf, __u8 status)
                break;
 
        default:
-               BT_DBG("%s Command status: ogf LINK_CTL ocf %x status %d", 
+               BT_DBG("%s Command status: ogf LINK_CTL ocf %x status %d",
                        hdev->name, ocf, status);
                break;
        }
@@ -793,7 +793,7 @@ static inline void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *s
                if (!conn->out) {
                        struct hci_cp_change_conn_ptype cp;
                        cp.handle = ev->handle;
-                       cp.pkt_type = (conn->type == ACL_LINK) ? 
+                       cp.pkt_type = (conn->type == ACL_LINK) ?
                                __cpu_to_le16(hdev->pkt_type & ACL_PTYPE_MASK):
                                __cpu_to_le16(hdev->pkt_type & SCO_PTYPE_MASK);
 
index dbf98c49dbaaa0edeaf3b37e38b595f4ba79a237..dc3ecb19a5cd9d3dd8d1ee03d8f2fc80100cd161 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
    BlueZ - Bluetooth protocol stack for Linux
    Copyright (C) 2000-2001 Qualcomm Incorporated
 
    OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
    IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
-   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES 
-   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 
-   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 
+   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
+   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
-   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 
-   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS 
+   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
+   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
    SOFTWARE IS DISCLAIMED.
 */
 
@@ -170,7 +170,7 @@ static int hci_sock_release(struct socket *sock)
        return 0;
 }
 
-/* Ioctls that require bound socket */ 
+/* Ioctls that require bound socket */
 static inline int hci_sock_bound_ioctl(struct sock *sk, unsigned int cmd, unsigned long arg)
 {
        struct hci_dev *hdev = hci_pi(sk)->hdev;
@@ -348,8 +348,8 @@ static inline void hci_sock_cmsg(struct sock *sk, struct msghdr *msg, struct sk_
                put_cmsg(msg, SOL_HCI, HCI_CMSG_TSTAMP, sizeof(tv), &tv);
        }
 }
-static int hci_sock_recvmsg(struct kiocb *iocb, struct socket *sock, 
+
+static int hci_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
                                struct msghdr *msg, size_t len, int flags)
 {
        int noblock = flags & MSG_DONTWAIT;
@@ -386,7 +386,7 @@ static int hci_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
        return err ? : copied;
 }
 
-static int hci_sock_sendmsg(struct kiocb *iocb, struct socket *sock, 
+static int hci_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
                            struct msghdr *msg, size_t len)
 {
        struct sock *sk = sock->sk;
@@ -520,7 +520,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname, char
                        *((u32 *) f->event_mask + 0) = uf.event_mask[0];
                        *((u32 *) f->event_mask + 1) = uf.event_mask[1];
                }
-               break; 
+               break;
 
        default:
                err = -ENOPROTOOPT;
@@ -535,7 +535,7 @@ static int hci_sock_getsockopt(struct socket *sock, int level, int optname, char
 {
        struct hci_ufilter uf;
        struct sock *sk = sock->sk;
-       int len, opt; 
+       int len, opt;
 
        if (get_user(len, optlen))
                return -EFAULT;
@@ -544,7 +544,7 @@ static int hci_sock_getsockopt(struct socket *sock, int level, int optname, char
        case HCI_DATA_DIR:
                if (hci_pi(sk)->cmsg_mask & HCI_CMSG_DIR)
                        opt = 1;
-               else 
+               else
                        opt = 0;
 
                if (put_user(opt, optval))
@@ -554,7 +554,7 @@ static int hci_sock_getsockopt(struct socket *sock, int level, int optname, char
        case HCI_TIME_STAMP:
                if (hci_pi(sk)->cmsg_mask & HCI_CMSG_TSTAMP)
                        opt = 1;
-               else 
+               else
                        opt = 0;
 
                if (put_user(opt, optval))
index 66782010f82cbacf442eba7a2d6c64f17d8c0964..4b99c5e4478da77c099190daea614244ada030d3 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
    HIDP implementation for Linux Bluetooth stack (BlueZ).
    Copyright (C) 2003-2004 Marcel Holtmann <marcel@holtmann.org>
 
    OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
    IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
-   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES 
-   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 
-   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 
+   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
+   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
-   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 
-   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS 
+   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
+   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
    SOFTWARE IS DISCLAIMED.
 */
 
@@ -293,7 +293,7 @@ static inline void hidp_process_handshake(struct hidp_session *session, unsigned
 
        case HIDP_HSHK_ERR_FATAL:
                /* Device requests a reboot, as this is the only way this error
-                * can be recovered. */
+                * can be recovered. */
                __hidp_send_ctrl_message(session,
                        HIDP_TRANS_HID_CONTROL | HIDP_CTRL_SOFT_RESET, NULL, 0);
                break;
index c2775f587d2eec2f6ee5d49b8e93ebe8b7b55221..a326601c8f414473a2345404c783003355cdc9d8 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
    HIDP implementation for Linux Bluetooth stack (BlueZ).
    Copyright (C) 2003-2004 Marcel Holtmann <marcel@holtmann.org>
 
    OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
    IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
-   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES 
-   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 
-   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 
+   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
+   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
-   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 
-   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS 
+   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
+   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
    SOFTWARE IS DISCLAIMED.
 */
 
@@ -86,7 +86,7 @@ struct hidp_connadd_req {
        int   intr_sock;        // Connteted interrupt socket
        __u16 parser;
        __u16 rd_size;
-       __u8 *rd_data;
+       __u8 __user *rd_data;
        __u8  country;
        __u8  subclass;
        __u16 vendor;
index 407fba43c1b973cda01122be9cc3dce198c2b930..33bda40aceb840d662ed468c1c663ee6806f88df 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
    HIDP implementation for Linux Bluetooth stack (BlueZ).
    Copyright (C) 2003-2004 Marcel Holtmann <marcel@holtmann.org>
 
    OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
    IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
-   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES 
-   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 
-   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 
+   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
+   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
-   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 
-   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS 
+   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
+   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
    SOFTWARE IS DISCLAIMED.
 */
 
@@ -189,7 +189,7 @@ static int hidp_sock_compat_ioctl(struct socket *sock, unsigned int cmd, unsigne
 
                uca = compat_alloc_user_space(sizeof(*uca));
 
-               if (copy_from_user(&ca, (void *) arg, sizeof(ca)))
+               if (copy_from_user(&ca, (void __user *) arg, sizeof(ca)))
                        return -EFAULT;
 
                if (put_user(ca.ctrl_sock, &uca->ctrl_sock) ||
@@ -206,7 +206,7 @@ static int hidp_sock_compat_ioctl(struct socket *sock, unsigned int cmd, unsigne
                                put_user(ca.idle_to, &uca->idle_to) ||
                                copy_to_user(&uca->name[0], &ca.name[0], 128))
                        return -EFAULT;
-               
+
                arg = (unsigned long) uca;
 
                /* Fall through. We don't actually write back any _changes_
index f8c25d5001558dd777868454bd4d7681dd878039..e83ee82440d333ba8e4d9ec4f1c5b937baeff711 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
    BlueZ - Bluetooth protocol stack for Linux
    Copyright (C) 2000-2001 Qualcomm Incorporated
 
    OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
    IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
-   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES 
-   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 
-   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 
+   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
+   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
-   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 
-   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS 
+   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
+   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
    SOFTWARE IS DISCLAIMED.
 */
 
@@ -227,7 +227,7 @@ static void __l2cap_chan_add(struct l2cap_conn *conn, struct sock *sk, struct so
                bt_accept_enqueue(parent, sk);
 }
 
-/* Delete channel. 
+/* Delete channel.
  * Must be called on the locked socket. */
 static void l2cap_chan_del(struct sock *sk, int err)
 {
@@ -238,7 +238,7 @@ static void l2cap_chan_del(struct sock *sk, int err)
 
        BT_DBG("sk %p, conn %p, err %d", sk, conn, err);
 
-       if (conn) { 
+       if (conn) {
                /* Unlink from channel list */
                l2cap_chan_unlink(&conn->chan_list, sk);
                l2cap_pi(sk)->conn = NULL;
@@ -590,7 +590,7 @@ static int l2cap_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_
                err = -EACCES;
                goto done;
        }
-               
+
        write_lock_bh(&l2cap_sk_list.lock);
 
        if (la->l2_psm && __l2cap_get_sock_by_addr(la->l2_psm, &la->l2_bdaddr)) {
@@ -890,7 +890,7 @@ static inline int l2cap_do_send(struct sock *sk, struct msghdr *msg, int len)
                *frag = bt_skb_send_alloc(sk, count, msg->msg_flags & MSG_DONTWAIT, &err);
                if (!*frag)
                        goto fail;
-               
+
                if (memcpy_fromiovec(skb_put(*frag, count), msg->msg_iov, count)) {
                        err = -EFAULT;
                        goto fail;
@@ -1267,7 +1267,7 @@ static inline int l2cap_get_conf_opt(void **ptr, int *type, int *olen, unsigned
 
 static inline void l2cap_parse_conf_req(struct sock *sk, void *data, int len)
 {
-       int type, hint, olen; 
+       int type, hint, olen;
        unsigned long val;
        void *ptr = data;
 
@@ -1414,7 +1414,7 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd
 
        /* Check for backlog size */
        if (sk_acceptq_is_full(parent)) {
-               BT_DBG("backlog full %d", parent->sk_ack_backlog); 
+               BT_DBG("backlog full %d", parent->sk_ack_backlog);
                goto response;
        }
 
@@ -1607,7 +1607,7 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr
                        goto done;
                }
 
-       default: 
+       default:
                sk->sk_state = BT_DISCONN;
                sk->sk_err   = ECONNRESET;
                l2cap_sock_set_timer(sk, HZ * 5);
index e5fd0cb70ae9e42ffa851e8d62874532a1115324..ad2af5814e40163e0e21e4c82a5a760e9e404894 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
    BlueZ - Bluetooth protocol stack for Linux
    Copyright (C) 2000-2001 Qualcomm Incorporated
 
    OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
    IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
-   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES 
-   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 
-   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 
+   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
+   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
-   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 
-   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS 
+   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
+   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
    SOFTWARE IS DISCLAIMED.
 */
 
index 278c8676906a3d345c00498256973b4b91533c57..94f45736056085a901c78f7208781e67d465602c 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
    RFCOMM implementation for Linux Bluetooth stack (BlueZ).
    Copyright (C) 2002 Maxim Krasnyansky <maxk@qualcomm.com>
    Copyright (C) 2002 Marcel Holtmann <marcel@holtmann.org>
    OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
    IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
-   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES 
-   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 
-   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 
+   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
+   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
-   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 
-   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS 
+   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
+   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
    SOFTWARE IS DISCLAIMED.
 */
 
@@ -134,7 +134,7 @@ static inline void rfcomm_session_put(struct rfcomm_session *s)
 /* ---- RFCOMM FCS computation ---- */
 
 /* reversed, 8-bit, poly=0x07 */
-static unsigned char rfcomm_crc_table[256] = { 
+static unsigned char rfcomm_crc_table[256] = {
        0x00, 0x91, 0xe3, 0x72, 0x07, 0x96, 0xe4, 0x75,
        0x0e, 0x9f, 0xed, 0x7c, 0x09, 0x98, 0xea, 0x7b,
        0x1c, 0x8d, 0xff, 0x6e, 0x1b, 0x8a, 0xf8, 0x69,
@@ -179,13 +179,13 @@ static unsigned char rfcomm_crc_table[256] = {
 /* CRC on 2 bytes */
 #define __crc(data) (rfcomm_crc_table[rfcomm_crc_table[0xff ^ data[0]] ^ data[1]])
 
-/* FCS on 2 bytes */ 
+/* FCS on 2 bytes */
 static inline u8 __fcs(u8 *data)
 {
        return (0xff - __crc(data));
 }
 
-/* FCS on 3 bytes */ 
+/* FCS on 3 bytes */
 static inline u8 __fcs2(u8 *data)
 {
        return (0xff - rfcomm_crc_table[__crc(data) ^ data[2]]);
@@ -288,7 +288,7 @@ struct rfcomm_dlc *rfcomm_dlc_alloc(gfp_t prio)
        atomic_set(&d->refcnt, 1);
 
        rfcomm_dlc_clear_state(d);
-       
+
        BT_DBG("%p", d);
 
        return d;
@@ -345,7 +345,7 @@ static int __rfcomm_dlc_open(struct rfcomm_dlc *d, bdaddr_t *src, bdaddr_t *dst,
        int err = 0;
        u8 dlci;
 
-       BT_DBG("dlc %p state %ld %s %s channel %d", 
+       BT_DBG("dlc %p state %ld %s %s channel %d",
                        d, d->state, batostr(src), batostr(dst), channel);
 
        if (channel < 1 || channel > 30)
@@ -489,21 +489,21 @@ void fastcall __rfcomm_dlc_unthrottle(struct rfcomm_dlc *d)
        rfcomm_schedule(RFCOMM_SCHED_TX);
 }
 
-/* 
+/*
    Set/get modem status functions use _local_ status i.e. what we report
    to the other side.
    Remote status is provided by dlc->modem_status() callback.
  */
 int rfcomm_dlc_set_modem_status(struct rfcomm_dlc *d, u8 v24_sig)
 {
-       BT_DBG("dlc %p state %ld v24_sig 0x%x", 
+       BT_DBG("dlc %p state %ld v24_sig 0x%x",
                        d, d->state, v24_sig);
 
        if (test_bit(RFCOMM_RX_THROTTLED, &d->flags))
                v24_sig |= RFCOMM_V24_FC;
        else
                v24_sig &= ~RFCOMM_V24_FC;
-       
+
        d->v24_sig = v24_sig;
 
        if (!test_and_set_bit(RFCOMM_MSC_PENDING, &d->flags))
@@ -514,7 +514,7 @@ int rfcomm_dlc_set_modem_status(struct rfcomm_dlc *d, u8 v24_sig)
 
 int rfcomm_dlc_get_modem_status(struct rfcomm_dlc *d, u8 *v24_sig)
 {
-       BT_DBG("dlc %p state %ld v24_sig 0x%x", 
+       BT_DBG("dlc %p state %ld v24_sig 0x%x",
                        d, d->state, d->v24_sig);
 
        *v24_sig = d->v24_sig;
@@ -576,7 +576,7 @@ static struct rfcomm_session *rfcomm_session_get(bdaddr_t *src, bdaddr_t *dst)
        struct bt_sock *sk;
        list_for_each_safe(p, n, &session_list) {
                s = list_entry(p, struct rfcomm_session, list);
-               sk = bt_sk(s->sock->sk); 
+               sk = bt_sk(s->sock->sk);
 
                if ((!bacmp(src, BDADDR_ANY) || !bacmp(&sk->src, src)) &&
                                !bacmp(&sk->dst, dst))
@@ -825,7 +825,7 @@ static int rfcomm_send_pn(struct rfcomm_session *s, int cr, struct rfcomm_dlc *d
 
 int rfcomm_send_rpn(struct rfcomm_session *s, int cr, u8 dlci,
                        u8 bit_rate, u8 data_bits, u8 stop_bits,
-                       u8 parity, u8 flow_ctrl_settings, 
+                       u8 parity, u8 flow_ctrl_settings,
                        u8 xon_char, u8 xoff_char, u16 param_mask)
 {
        struct rfcomm_hdr *hdr;
@@ -834,8 +834,8 @@ int rfcomm_send_rpn(struct rfcomm_session *s, int cr, u8 dlci,
        u8 buf[16], *ptr = buf;
 
        BT_DBG("%p cr %d dlci %d bit_r 0x%x data_b 0x%x stop_b 0x%x parity 0x%x"
-                       " flwc_s 0x%x xon_c 0x%x xoff_c 0x%x p_mask 0x%x", 
-               s, cr, dlci, bit_rate, data_bits, stop_bits, parity, 
+                       " flwc_s 0x%x xon_c 0x%x xoff_c 0x%x p_mask 0x%x",
+               s, cr, dlci, bit_rate, data_bits, stop_bits, parity,
                flow_ctrl_settings, xon_char, xoff_char, param_mask);
 
        hdr = (void *) ptr; ptr += sizeof(*hdr);
@@ -1120,9 +1120,9 @@ static int rfcomm_recv_disc(struct rfcomm_session *s, u8 dlci)
 
                        d->state = BT_CLOSED;
                        __rfcomm_dlc_close(d, err);
-               } else 
+               } else
                        rfcomm_send_dm(s, dlci);
-                       
+
        } else {
                rfcomm_send_ua(s, 0);
 
@@ -1230,7 +1230,7 @@ static int rfcomm_apply_pn(struct rfcomm_dlc *d, int cr, struct rfcomm_pn *pn)
 {
        struct rfcomm_session *s = d->session;
 
-       BT_DBG("dlc %p state %ld dlci %d mtu %d fc 0x%x credits %d", 
+       BT_DBG("dlc %p state %ld dlci %d mtu %d fc 0x%x credits %d",
                        d, d->state, d->dlci, pn->mtu, pn->flow_ctrl, pn->credits);
 
        if ((pn->flow_ctrl == 0xf0 && s->cfc != RFCOMM_CFC_DISABLED) ||
@@ -1454,7 +1454,7 @@ static int rfcomm_recv_msc(struct rfcomm_session *s, int cr, struct sk_buff *skb
                if (d->modem_status)
                        d->modem_status(d, msc->v24_sig);
                rfcomm_dlc_unlock(d);
-               
+
                rfcomm_send_msc(s, 0, dlci, msc->v24_sig);
 
                d->mscex |= RFCOMM_MSCEX_RX;
@@ -1641,18 +1641,18 @@ static inline int rfcomm_process_tx(struct rfcomm_dlc *d)
        struct sk_buff *skb;
        int err;
 
-       BT_DBG("dlc %p state %ld cfc %d rx_credits %d tx_credits %d", 
+       BT_DBG("dlc %p state %ld cfc %d rx_credits %d tx_credits %d",
                        d, d->state, d->cfc, d->rx_credits, d->tx_credits);
 
        /* Send pending MSC */
        if (test_and_clear_bit(RFCOMM_MSC_PENDING, &d->flags))
-               rfcomm_send_msc(d->session, 1, d->dlci, d->v24_sig); 
+               rfcomm_send_msc(d->session, 1, d->dlci, d->v24_sig);
 
        if (d->cfc) {
-               /* CFC enabled. 
+               /* CFC enabled.
                 * Give them some credits */
                if (!test_bit(RFCOMM_RX_THROTTLED, &d->flags) &&
-                               d->rx_credits <= (d->cfc >> 2)) {
+                               d->rx_credits <= (d->cfc >> 2)) {
                        rfcomm_send_credits(d->session, d->addr, d->cfc - d->rx_credits);
                        d->rx_credits = d->cfc;
                }
@@ -1876,7 +1876,7 @@ static int rfcomm_add_listener(bdaddr_t *ba)
 
        /* Create socket */
        err = rfcomm_l2sock_create(&sock);
-       if (err < 0) { 
+       if (err < 0) {
                BT_ERR("Create socket failed %d", err);
                return err;
        }
index cb7e855f0828619fdc34095786f86d23a3d0532e..30586ab9e8783cad490916c367b1099a14103a85 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
    RFCOMM implementation for Linux Bluetooth stack (BlueZ).
    Copyright (C) 2002 Maxim Krasnyansky <maxk@qualcomm.com>
    Copyright (C) 2002 Marcel Holtmann <marcel@holtmann.org>
    OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
    IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
-   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES 
-   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 
-   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 
+   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
+   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
-   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 
-   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS 
+   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
+   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
    SOFTWARE IS DISCLAIMED.
 */
 
@@ -130,7 +130,7 @@ static struct sock *__rfcomm_get_sock_by_addr(u8 channel, bdaddr_t *src)
        struct hlist_node *node;
 
        sk_for_each(sk, node, &rfcomm_sk_list.head) {
-               if (rfcomm_pi(sk)->channel == channel && 
+               if (rfcomm_pi(sk)->channel == channel &&
                                !bacmp(&bt_sk(sk)->src, src))
                        break;
        }
@@ -572,7 +572,7 @@ static int rfcomm_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
        while (len) {
                size_t size = min_t(size_t, len, d->mtu);
                int err;
-               
+
                skb = sock_alloc_send_skb(sk, size + RFCOMM_SKB_RESERVE,
                                msg->msg_flags & MSG_DONTWAIT, &err);
                if (!skb)
@@ -843,7 +843,7 @@ static int rfcomm_sock_release(struct socket *sock)
        return err;
 }
 
-/* ---- RFCOMM core layer callbacks ---- 
+/* ---- RFCOMM core layer callbacks ----
  *
  * called under rfcomm_lock()
  */
@@ -864,7 +864,7 @@ int rfcomm_connect_ind(struct rfcomm_session *s, u8 channel, struct rfcomm_dlc *
 
        /* Check for backlog size */
        if (sk_acceptq_is_full(parent)) {
-               BT_DBG("backlog full %d", parent->sk_ack_backlog); 
+               BT_DBG("backlog full %d", parent->sk_ack_backlog);
                goto done;
        }
 
index eb2b52484c70e42e86cb329d093478cc225dab25..8cd82dce5008cf3e575229026e82281834847656 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
    RFCOMM implementation for Linux Bluetooth stack (BlueZ).
    Copyright (C) 2002 Maxim Krasnyansky <maxk@qualcomm.com>
    Copyright (C) 2002 Marcel Holtmann <marcel@holtmann.org>
    OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
    IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
-   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES 
-   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 
-   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 
+   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
+   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
-   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 
-   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS 
+   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
+   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
    SOFTWARE IS DISCLAIMED.
 */
 
@@ -110,7 +110,7 @@ static void rfcomm_dev_destruct(struct rfcomm_dev *dev)
 
        kfree(dev);
 
-       /* It's safe to call module_put() here because socket still 
+       /* It's safe to call module_put() here because socket still
           holds reference to this module. */
        module_put(THIS_MODULE);
 }
@@ -185,7 +185,7 @@ static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc)
        int err = 0;
 
        BT_DBG("id %d channel %d", req->dev_id, req->channel);
-       
+
        dev = kzalloc(sizeof(struct rfcomm_dev), GFP_KERNEL);
        if (!dev)
                return -ENOMEM;
@@ -234,7 +234,7 @@ static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc)
        bacpy(&dev->dst, &req->dst);
        dev->channel = req->channel;
 
-       dev->flags = req->flags & 
+       dev->flags = req->flags &
                ((1 << RFCOMM_RELEASE_ONHUP) | (1 << RFCOMM_REUSE_DLC));
 
        init_waitqueue_head(&dev->wait);
@@ -249,7 +249,7 @@ static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc)
        dev->dlc   = dlc;
        rfcomm_dlc_unlock(dlc);
 
-       /* It's safe to call __module_get() here because socket already 
+       /* It's safe to call __module_get() here because socket already
           holds reference to this module. */
        __module_get(THIS_MODULE);
 
@@ -487,7 +487,7 @@ static void rfcomm_dev_data_ready(struct rfcomm_dlc *dlc, struct sk_buff *skb)
 {
        struct rfcomm_dev *dev = dlc->owner;
        struct tty_struct *tty;
-       
+
        if (!dev || !(tty = dev->tty)) {
                kfree_skb(skb);
                return;
@@ -506,7 +506,7 @@ static void rfcomm_dev_state_change(struct rfcomm_dlc *dlc, int err)
        struct rfcomm_dev *dev = dlc->owner;
        if (!dev)
                return;
-       
+
        BT_DBG("dlc %p dev %p err %d", dlc, dev, err);
 
        dev->err = err;
@@ -525,7 +525,7 @@ static void rfcomm_dev_state_change(struct rfcomm_dlc *dlc, int err)
                                rfcomm_dev_put(dev);
                                rfcomm_dlc_lock(dlc);
                        }
-               } else 
+               } else
                        tty_hangup(dev->tty);
        }
 }
@@ -543,7 +543,7 @@ static void rfcomm_dev_modem_status(struct rfcomm_dlc *dlc, u8 v24_sig)
                        tty_hangup(dev->tty);
        }
 
-       dev->modem_status = 
+       dev->modem_status =
                ((v24_sig & RFCOMM_V24_RTC) ? (TIOCM_DSR | TIOCM_DTR) : 0) |
                ((v24_sig & RFCOMM_V24_RTR) ? (TIOCM_RTS | TIOCM_CTS) : 0) |
                ((v24_sig & RFCOMM_V24_IC)  ? TIOCM_RI : 0) |
@@ -561,7 +561,7 @@ static void rfcomm_tty_wakeup(unsigned long arg)
        BT_DBG("dev %p tty %p", dev, tty);
 
        if (test_bit(TTY_DO_WRITE_WAKEUP, &tty->flags) && tty->ldisc.write_wakeup)
-                (tty->ldisc.write_wakeup)(tty);
+               (tty->ldisc.write_wakeup)(tty);
 
        wake_up_interruptible(&tty->write_wait);
 #ifdef SERIAL_HAVE_POLL_WAIT
@@ -576,7 +576,7 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
        struct rfcomm_dlc *dlc;
        int err, id;
 
-        id = tty->index;
+       id = tty->index;
 
        BT_DBG("tty %p id %d", tty, id);
 
@@ -670,7 +670,7 @@ static int rfcomm_tty_write(struct tty_struct *tty, const unsigned char *buf, in
                size = min_t(uint, count, dlc->mtu);
 
                skb = rfcomm_wmalloc(dev, size + RFCOMM_SKB_RESERVE, GFP_ATOMIC);
-               
+
                if (!skb)
                        break;
 
@@ -773,7 +773,7 @@ static void rfcomm_tty_set_termios(struct tty_struct *tty, struct ktermios *old)
                return;
 
        /* Handle turning off CRTSCTS */
-       if ((old->c_cflag & CRTSCTS) && !(new->c_cflag & CRTSCTS)) 
+       if ((old->c_cflag & CRTSCTS) && !(new->c_cflag & CRTSCTS))
                BT_DBG("Turning off CRTSCTS unsupported");
 
        /* Parity on/off and when on, odd/even */
@@ -830,7 +830,7 @@ static void rfcomm_tty_set_termios(struct tty_struct *tty, struct ktermios *old)
        }
 
        /* Handle number of data bits [5-8] */
-       if ((old->c_cflag & CSIZE) != (new->c_cflag & CSIZE)) 
+       if ((old->c_cflag & CSIZE) != (new->c_cflag & CSIZE))
                changes |= RFCOMM_RPN_PM_DATA;
 
        switch (new->c_cflag & CSIZE) {
@@ -868,7 +868,7 @@ static void rfcomm_tty_set_termios(struct tty_struct *tty, struct ktermios *old)
        case 9600:
                baud = RFCOMM_RPN_BR_9600;
                break;
-       case 19200: 
+       case 19200:
                baud = RFCOMM_RPN_BR_19200;
                break;
        case 38400:
@@ -887,7 +887,7 @@ static void rfcomm_tty_set_termios(struct tty_struct *tty, struct ktermios *old)
                /* 9600 is standard accordinag to the RFCOMM specification */
                baud = RFCOMM_RPN_BR_9600;
                break;
-       
+
        }
 
        if (changes)
@@ -978,11 +978,11 @@ static int rfcomm_tty_read_proc(char *buf, char **start, off_t offset, int len,
 
 static int rfcomm_tty_tiocmget(struct tty_struct *tty, struct file *filp)
 {
-       struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data;
+       struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data;
 
        BT_DBG("tty %p dev %p", tty, dev);
 
-       return dev->modem_status;
+       return dev->modem_status;
 }
 
 static int rfcomm_tty_tiocmset(struct tty_struct *tty, struct file *filp, unsigned int set, unsigned int clear)
index 5d13d4f317538e1280118ac7f7f35994437163bf..ae4391440950cd14b1e9ef4c6b0fe7bc9259be40 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
    BlueZ - Bluetooth protocol stack for Linux
    Copyright (C) 2000-2001 Qualcomm Incorporated
 
    OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
    IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
-   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES 
-   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 
-   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 
+   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
+   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
-   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 
-   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS 
+   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
+   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
    SOFTWARE IS DISCLAIMED.
 */
 
@@ -149,7 +149,7 @@ static int sco_conn_del(struct hci_conn *hcon, int err)
        struct sco_conn *conn;
        struct sock *sk;
 
-       if (!(conn = hcon->sco_data)) 
+       if (!(conn = hcon->sco_data))
                return 0;
 
        BT_DBG("hcon %p conn %p, err %d", hcon, conn, err);
@@ -404,7 +404,7 @@ static void sco_sock_init(struct sock *sk, struct sock *parent)
 {
        BT_DBG("sk %p", sk);
 
-       if (parent) 
+       if (parent)
                sk->sk_type = parent->sk_type;
 }
 
@@ -522,7 +522,7 @@ static int sco_sock_connect(struct socket *sock, struct sockaddr *addr, int alen
        if ((err = sco_connect(sk)))
                goto done;
 
-       err = bt_sock_wait_state(sk, BT_CONNECTED, 
+       err = bt_sock_wait_state(sk, BT_CONNECTED,
                        sock_sndtimeo(sk, flags & O_NONBLOCK));
 
 done:
@@ -627,7 +627,7 @@ static int sco_sock_getname(struct socket *sock, struct sockaddr *addr, int *len
        return 0;
 }
 
-static int sco_sock_sendmsg(struct kiocb *iocb, struct socket *sock, 
+static int sco_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
                            struct msghdr *msg, size_t len)
 {
        struct sock *sk = sock->sk;
@@ -677,7 +677,7 @@ static int sco_sock_getsockopt(struct socket *sock, int level, int optname, char
        struct sock *sk = sock->sk;
        struct sco_options opts;
        struct sco_conninfo cinfo;
-       int len, err = 0; 
+       int len, err = 0;
 
        BT_DBG("sk %p", sk);
 
@@ -761,7 +761,7 @@ static void __sco_chan_add(struct sco_conn *conn, struct sock *sk, struct sock *
                bt_accept_enqueue(parent, sk);
 }
 
-/* Delete channel. 
+/* Delete channel.
  * Must be called on the locked socket. */
 static void sco_chan_del(struct sock *sk, int err)
 {
@@ -771,7 +771,7 @@ static void sco_chan_del(struct sock *sk, int err)
 
        BT_DBG("sk %p, conn %p, err %d", sk, conn, err);
 
-       if (conn) { 
+       if (conn) {
                sco_conn_lock(conn);
                conn->sk = NULL;
                sco_pi(sk)->conn = NULL;
@@ -855,7 +855,7 @@ static int sco_connect_cfm(struct hci_conn *hcon, __u8 status)
                conn = sco_conn_add(hcon, status);
                if (conn)
                        sco_conn_ready(conn);
-       } else 
+       } else
                sco_conn_del(hcon, bt_err(status));
 
        return 0;
@@ -887,7 +887,7 @@ static int sco_recv_scodata(struct hci_conn *hcon, struct sk_buff *skb)
        }
 
 drop:
-       kfree_skb(skb); 
+       kfree_skb(skb);
        return 0;
 }
 
index f8dbcee80ebad7cdffb110fd87a8796db93643ab..905a39c33a16f73ce82beaaa9fd05295550485b5 100644 (file)
@@ -40,7 +40,7 @@ int br_dev_xmit(struct sk_buff *skb, struct net_device *dev)
        skb->mac.raw = skb->data;
        skb_pull(skb, ETH_HLEN);
 
-       if (dest[0] & 1) 
+       if (dest[0] & 1)
                br_flood_deliver(br, skb, 0);
        else if ((dst = __br_fdb_get(br, dest)) != NULL)
                br_deliver(dst->dst, skb);
@@ -178,12 +178,12 @@ void br_dev_setup(struct net_device *dev)
        dev->change_mtu = br_change_mtu;
        dev->destructor = free_netdev;
        SET_MODULE_OWNER(dev);
-       SET_ETHTOOL_OPS(dev, &br_ethtool_ops);
+       SET_ETHTOOL_OPS(dev, &br_ethtool_ops);
        dev->stop = br_dev_stop;
        dev->tx_queue_len = 0;
        dev->set_mac_address = br_set_mac_address;
        dev->priv_flags = IFF_EBRIDGE;
 
-       dev->features = NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_HIGHDMA |
-                       NETIF_F_TSO | NETIF_F_NO_CSUM | NETIF_F_GSO_ROBUST;
+       dev->features = NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_HIGHDMA |
+                       NETIF_F_TSO | NETIF_F_NO_CSUM | NETIF_F_GSO_ROBUST;
 }
index 8ca448db7a0d779199fde2ed1c81f71eafbbca10..def2e403f932e25342c556040f129bba9b6830a1 100644 (file)
@@ -52,7 +52,7 @@ static __inline__ unsigned long hold_time(const struct net_bridge *br)
 static __inline__ int has_expired(const struct net_bridge *br,
                                  const struct net_bridge_fdb_entry *fdb)
 {
-       return !fdb->is_static 
+       return !fdb->is_static
                && time_before_eq(fdb->ageing_timer + hold_time(br), jiffies);
 }
 
@@ -71,7 +71,7 @@ void br_fdb_changeaddr(struct net_bridge_port *p, const unsigned char *newaddr)
 {
        struct net_bridge *br = p->br;
        int i;
-       
+
        spin_lock_bh(&br->hash_lock);
 
        /* Search all chains since old address/hash is unknown */
@@ -85,7 +85,7 @@ void br_fdb_changeaddr(struct net_bridge_port *p, const unsigned char *newaddr)
                                /* maybe another port has same hw addr? */
                                struct net_bridge_port *op;
                                list_for_each_entry(op, &br->port_list, list) {
-                                       if (op != p && 
+                                       if (op != p &&
                                            !compare_ether_addr(op->dev->dev_addr,
                                                                f->addr.addr)) {
                                                f->dst = op;
@@ -118,8 +118,8 @@ void br_fdb_cleanup(unsigned long _data)
                struct hlist_node *h, *n;
 
                hlist_for_each_entry_safe(f, h, n, &br->hash[i], hlist) {
-                       if (!f->is_static && 
-                           time_before_eq(f->ageing_timer + delay, jiffies)) 
+                       if (!f->is_static &&
+                           time_before_eq(f->ageing_timer + delay, jiffies))
                                fdb_delete(f);
                }
        }
@@ -138,11 +138,11 @@ void br_fdb_delete_by_port(struct net_bridge *br,
        spin_lock_bh(&br->hash_lock);
        for (i = 0; i < BR_HASH_SIZE; i++) {
                struct hlist_node *h, *g;
-               
+
                hlist_for_each_safe(h, g, &br->hash[i]) {
                        struct net_bridge_fdb_entry *f
                                = hlist_entry(h, struct net_bridge_fdb_entry, hlist);
-                       if (f->dst != p) 
+                       if (f->dst != p)
                                continue;
 
                        if (f->is_static && !do_all)
@@ -155,7 +155,7 @@ void br_fdb_delete_by_port(struct net_bridge *br,
                        if (f->is_local) {
                                struct net_bridge_port *op;
                                list_for_each_entry(op, &br->port_list, list) {
-                                       if (op != p && 
+                                       if (op != p &&
                                            !compare_ether_addr(op->dev->dev_addr,
                                                                f->addr.addr)) {
                                                f->dst = op;
@@ -190,14 +190,14 @@ struct net_bridge_fdb_entry *__br_fdb_get(struct net_bridge *br,
 }
 
 /* Interface used by ATM hook that keeps a ref count */
-struct net_bridge_fdb_entry *br_fdb_get(struct net_bridge *br, 
+struct net_bridge_fdb_entry *br_fdb_get(struct net_bridge *br,
                                        unsigned char *addr)
 {
        struct net_bridge_fdb_entry *fdb;
 
        rcu_read_lock();
        fdb = __br_fdb_get(br, addr);
-       if (fdb) 
+       if (fdb)
                atomic_inc(&fdb->use_count);
        rcu_read_unlock();
        return fdb;
@@ -218,7 +218,7 @@ void br_fdb_put(struct net_bridge_fdb_entry *ent)
 }
 
 /*
- * Fill buffer with forwarding table records in 
+ * Fill buffer with forwarding table records in
  * the API format.
  */
 int br_fdb_fillbuf(struct net_bridge *br, void *buf,
@@ -237,7 +237,7 @@ int br_fdb_fillbuf(struct net_bridge *br, void *buf,
                        if (num >= maxnum)
                                goto out;
 
-                       if (has_expired(br, f)) 
+                       if (has_expired(br, f))
                                continue;
 
                        if (skip) {
@@ -277,7 +277,7 @@ static inline struct net_bridge_fdb_entry *fdb_find(struct hlist_head *head,
 
 static struct net_bridge_fdb_entry *fdb_create(struct hlist_head *head,
                                               struct net_bridge_port *source,
-                                              const unsigned char *addr, 
+                                              const unsigned char *addr,
                                               int is_local)
 {
        struct net_bridge_fdb_entry *fdb;
@@ -307,17 +307,17 @@ static int fdb_insert(struct net_bridge *br, struct net_bridge_port *source,
 
        fdb = fdb_find(head, addr);
        if (fdb) {
-               /* it is okay to have multiple ports with same 
+               /* it is okay to have multiple ports with same
                 * address, just use the first one.
                 */
-               if (fdb->is_local) 
+               if (fdb->is_local)
                        return 0;
 
                printk(KERN_WARNING "%s adding interface with same address "
                       "as a received packet\n",
                       source->dev->name);
                fdb_delete(fdb);
-       }
+       }
 
        if (!fdb_create(head, source, addr, 1))
                return -ENOMEM;
@@ -350,7 +350,7 @@ void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source,
        if (likely(fdb)) {
                /* attempt to update an entry for a local interface */
                if (unlikely(fdb->is_local)) {
-                       if (net_ratelimit()) 
+                       if (net_ratelimit())
                                printk(KERN_WARNING "%s: received packet with "
                                       " own address as source address\n",
                                       source->dev->name);
index 191b861e5e53c25b176d1d36c1475cc6406ee5ae..3e45c1a1aa96124f1bf525346aecf14b704f4311 100644 (file)
@@ -21,7 +21,7 @@
 #include "br_private.h"
 
 /* Don't forward packets to originating port or forwarding diasabled */
-static inline int should_deliver(const struct net_bridge_port *p, 
+static inline int should_deliver(const struct net_bridge_port *p,
                                 const struct sk_buff *skb)
 {
        return (skb->dev != p->dev && p->state == BR_STATE_FORWARDING);
@@ -101,7 +101,7 @@ void br_forward(const struct net_bridge_port *to, struct sk_buff *skb)
 
 /* called under bridge lock */
 static void br_flood(struct net_bridge *br, struct sk_buff *skb, int clone,
-       void (*__packet_hook)(const struct net_bridge_port *p, 
+       void (*__packet_hook)(const struct net_bridge_port *p,
                              struct sk_buff *skb))
 {
        struct net_bridge_port *p;
index 2b7c2c7dad485aaa9e5399553ec27f2cd074a8e4..f35c1a378d0fb6742273bf7d6b745b6f125224c2 100644 (file)
@@ -47,7 +47,7 @@ static int port_cost(struct net_device *dev)
        set_fs(KERNEL_DS);
        err = dev_ethtool(&ifr);
        set_fs(old_fs);
-       
+
        if (!err) {
                switch(ecmd.speed) {
                case SPEED_100:
@@ -191,7 +191,7 @@ static void del_br(struct net_bridge *br)
        del_timer_sync(&br->gc_timer);
 
        br_sysfs_delbr(br->dev);
-       unregister_netdevice(br->dev);
+       unregister_netdevice(br->dev);
 }
 
 static struct net_device *new_bridge_dev(const char *name)
@@ -201,7 +201,7 @@ static struct net_device *new_bridge_dev(const char *name)
 
        dev = alloc_netdev(sizeof(struct net_bridge), name,
                           br_dev_setup);
-       
+
        if (!dev)
                return NULL;
 
@@ -258,12 +258,12 @@ static int find_portno(struct net_bridge *br)
 }
 
 /* called with RTNL but without bridge lock */
-static struct net_bridge_port *new_nbp(struct net_bridge *br, 
+static struct net_bridge_port *new_nbp(struct net_bridge *br,
                                       struct net_device *dev)
 {
        int index;
        struct net_bridge_port *p;
-       
+
        index = find_portno(br);
        if (index < 0)
                return ERR_PTR(index);
@@ -276,7 +276,7 @@ static struct net_bridge_port *new_nbp(struct net_bridge *br,
        dev_hold(dev);
        p->dev = dev;
        p->path_cost = port_cost(dev);
-       p->priority = 0x8000 >> BR_PORT_BITS;
+       p->priority = 0x8000 >> BR_PORT_BITS;
        p->port_no = index;
        br_init_port(p);
        p->state = BR_STATE_DISABLED;
@@ -298,7 +298,7 @@ int br_add_bridge(const char *name)
        int ret;
 
        dev = new_bridge_dev(name);
-       if (!dev) 
+       if (!dev)
                return -ENOMEM;
 
        rtnl_lock();
@@ -329,7 +329,7 @@ int br_del_bridge(const char *name)
 
        rtnl_lock();
        dev = __dev_get_by_name(name);
-       if (dev == NULL) 
+       if (dev == NULL)
                ret =  -ENXIO;  /* Could not find device */
 
        else if (!(dev->priv_flags & IFF_EBRIDGE)) {
@@ -340,9 +340,9 @@ int br_del_bridge(const char *name)
        else if (dev->flags & IFF_UP) {
                /* Not shutdown yet. */
                ret = -EBUSY;
-       } 
+       }
 
-       else 
+       else
                del_br(netdev_priv(dev));
 
        rtnl_unlock();
@@ -428,7 +428,7 @@ int br_add_if(struct net_bridge *br, struct net_device *dev)
        if (err)
                goto err0;
 
-       err = br_fdb_insert(br, p, dev->dev_addr);
+       err = br_fdb_insert(br, p, dev->dev_addr);
        if (err)
                goto err1;
 
@@ -464,8 +464,8 @@ err0:
 int br_del_if(struct net_bridge *br, struct net_device *dev)
 {
        struct net_bridge_port *p = dev->br_port;
-       
-       if (!p || p->br != br) 
+
+       if (!p || p->br != br)
                return -EINVAL;
 
        del_nbp(p);
index bfa4d8c333f7b727946e40c4c33e159d4fdbfe2f..35b94f9a1ac566a5a33bfec279b3fc27b1705a68 100644 (file)
@@ -119,7 +119,7 @@ static inline int is_link_local(const unsigned char *dest)
  * Called via br_handle_frame_hook.
  * Return 0 if *pskb should be processed furthur
  *       1 if *pskb is handled
- * note: already called with rcu_read_lock (preempt_disabled) 
+ * note: already called with rcu_read_lock (preempt_disabled)
  */
 int br_handle_frame(struct net_bridge_port *p, struct sk_buff **pskb)
 {
@@ -137,7 +137,7 @@ int br_handle_frame(struct net_bridge_port *p, struct sk_buff **pskb)
 
        if (p->state == BR_STATE_FORWARDING || p->state == BR_STATE_LEARNING) {
                if (br_should_route_hook) {
-                       if (br_should_route_hook(pskb)) 
+                       if (br_should_route_hook(pskb))
                                return 0;
                        skb = *pskb;
                        dest = eth_hdr(skb)->h_dest;
index 4c61a7e0a86e1ae9e16867f9f8e4b0412b8edbaf..3ab153d3c508810007da27fb9ca846a0a2ead0b0 100644 (file)
@@ -28,7 +28,7 @@ static int get_bridge_ifindices(int *indices, int num)
        int i = 0;
 
        for (dev = dev_base; dev && i < num; dev = dev->next) {
-               if (dev->priv_flags & IFF_EBRIDGE) 
+               if (dev->priv_flags & IFF_EBRIDGE)
                        indices[i++] = dev->ifindex;
        }
 
@@ -53,7 +53,7 @@ static void get_port_ifindices(struct net_bridge *br, int *ifindices, int num)
  *            (limited to a page for sanity)
  * offset  -- number of records to skip
  */
-static int get_fdb_entries(struct net_bridge *br, void __user *userbuf, 
+static int get_fdb_entries(struct net_bridge *br, void __user *userbuf,
                           unsigned long maxnum, unsigned long offset)
 {
        int num;
@@ -69,7 +69,7 @@ static int get_fdb_entries(struct net_bridge *br, void __user *userbuf,
        buf = kmalloc(size, GFP_USER);
        if (!buf)
                return -ENOMEM;
-       
+
        num = br_fdb_fillbuf(br, buf, maxnum, offset);
        if (num > 0) {
                if (copy_to_user(userbuf, buf, num*sizeof(struct __fdb_entry)))
@@ -91,7 +91,7 @@ static int add_del_if(struct net_bridge *br, int ifindex, int isadd)
        dev = dev_get_by_index(ifindex);
        if (dev == NULL)
                return -EINVAL;
-       
+
        if (isadd)
                ret = br_add_if(br, dev);
        else
@@ -110,7 +110,7 @@ static int old_dev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 {
        struct net_bridge *br = netdev_priv(dev);
        unsigned long args[4];
-       
+
        if (copy_from_user(args, rq->ifr_data, sizeof(args)))
                return -EFAULT;
 
@@ -143,7 +143,7 @@ static int old_dev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
                b.tcn_timer_value = br_timer_value(&br->tcn_timer);
                b.topology_change_timer_value = br_timer_value(&br->topology_change_timer);
                b.gc_timer_value = br_timer_value(&br->gc_timer);
-               rcu_read_unlock();
+               rcu_read_unlock();
 
                if (copy_to_user((void __user *)args[1], &b, sizeof(b)))
                        return -EFAULT;
@@ -275,7 +275,7 @@ static int old_dev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
                        return -ERANGE;
 
                spin_lock_bh(&br->lock);
-               if ((p = br_get_port(br, args[1])) == NULL) 
+               if ((p = br_get_port(br, args[1])) == NULL)
                        ret = -EINVAL;
                else
                        br_stp_set_port_priority(p, args[2]);
@@ -301,7 +301,7 @@ static int old_dev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
        }
 
        case BRCTL_GET_FDB_ENTRIES:
-               return get_fdb_entries(br, (void __user *)args[1], 
+               return get_fdb_entries(br, (void __user *)args[1],
                                       args[2], args[3]);
        }
 
@@ -368,7 +368,7 @@ int br_ioctl_deviceless_stub(unsigned int cmd, void __user *uarg)
        case SIOCGIFBR:
        case SIOCSIFBR:
                return old_deviceless(uarg);
-               
+
        case SIOCBRADDBR:
        case SIOCBRDELBR:
        {
index ea3337ad0edcf3b7b19132fc5770ce5e4c90eeb4..a0744e653f0912fce9e40ce1a55706c3dd763733 100644 (file)
@@ -68,7 +68,7 @@ static __be16 inline vlan_proto(const struct sk_buff *skb)
 
 #define IS_VLAN_IP(skb) \
        (skb->protocol == htons(ETH_P_8021Q) && \
-        vlan_proto(skb) == htons(ETH_P_IP) &&  \
+        vlan_proto(skb) == htons(ETH_P_IP) &&  \
         brnf_filter_vlan_tagged)
 
 #define IS_VLAN_IPV6(skb) \
@@ -124,7 +124,7 @@ static inline struct nf_bridge_info *nf_bridge_alloc(struct sk_buff *skb)
 
 static inline void nf_bridge_save_header(struct sk_buff *skb)
 {
-        int header_size = ETH_HLEN;
+       int header_size = ETH_HLEN;
 
        if (skb->protocol == htons(ETH_P_8021Q))
                header_size += VLAN_HLEN;
@@ -139,7 +139,7 @@ static inline void nf_bridge_save_header(struct sk_buff *skb)
 int nf_bridge_copy_header(struct sk_buff *skb)
 {
        int err;
-        int header_size = ETH_HLEN;
+       int header_size = ETH_HLEN;
 
        if (skb->protocol == htons(ETH_P_8021Q))
                header_size += VLAN_HLEN;
@@ -836,10 +836,10 @@ static unsigned int ip_sabotage_in(unsigned int hook, struct sk_buff **pskb,
  * For br_nf_post_routing, we need (prio = NF_BR_PRI_LAST), because
  * ip_refrag() can return NF_STOLEN. */
 static struct nf_hook_ops br_nf_ops[] = {
-       { .hook = br_nf_pre_routing, 
-         .owner = THIS_MODULE, 
-         .pf = PF_BRIDGE, 
-         .hooknum = NF_BR_PRE_ROUTING, 
+       { .hook = br_nf_pre_routing,
+         .owner = THIS_MODULE,
+         .pf = PF_BRIDGE,
+         .hooknum = NF_BR_PRE_ROUTING,
          .priority = NF_BR_PRI_BRNF, },
        { .hook = br_nf_local_in,
          .owner = THIS_MODULE,
@@ -949,44 +949,29 @@ static ctl_table brnf_net_table[] = {
 };
 #endif
 
-int br_netfilter_init(void)
+int __init br_netfilter_init(void)
 {
-       int i;
-
-       for (i = 0; i < ARRAY_SIZE(br_nf_ops); i++) {
-               int ret;
-
-               if ((ret = nf_register_hook(&br_nf_ops[i])) >= 0)
-                       continue;
-
-               while (i--)
-                       nf_unregister_hook(&br_nf_ops[i]);
+       int ret;
 
+       ret = nf_register_hooks(br_nf_ops, ARRAY_SIZE(br_nf_ops));
+       if (ret < 0)
                return ret;
-       }
-
 #ifdef CONFIG_SYSCTL
        brnf_sysctl_header = register_sysctl_table(brnf_net_table, 0);
        if (brnf_sysctl_header == NULL) {
                printk(KERN_WARNING
                       "br_netfilter: can't register to sysctl.\n");
-               for (i = 0; i < ARRAY_SIZE(br_nf_ops); i++)
-                       nf_unregister_hook(&br_nf_ops[i]);
-               return -EFAULT;
+               nf_unregister_hooks(br_nf_ops, ARRAY_SIZE(br_nf_ops));
+               return -ENOMEM;
        }
 #endif
-
        printk(KERN_NOTICE "Bridge firewalling registered\n");
-
        return 0;
 }
 
 void br_netfilter_fini(void)
 {
-       int i;
-
-       for (i = ARRAY_SIZE(br_nf_ops) - 1; i >= 0; i--)
-               nf_unregister_hook(&br_nf_ops[i]);
+       nf_unregister_hooks(br_nf_ops, ARRAY_SIZE(br_nf_ops));
 #ifdef CONFIG_SYSCTL
        unregister_sysctl_table(brnf_sysctl_header);
 #endif
index a9139682c49bf1aa9697fdbf1c4e5d2ebe29222a..7d68b24b5654565885922849c69bbe3758ea9515 100644 (file)
@@ -45,7 +45,7 @@ static int br_fill_ifinfo(struct sk_buff *skb, const struct net_bridge_port *por
 
        nlh = nlmsg_put(skb, pid, seq, event, sizeof(*hdr), flags);
        if (nlh == NULL)
-               return -ENOBUFS;
+               return -EMSGSIZE;
 
        hdr = nlmsg_data(nlh);
        hdr->ifi_family = AF_BRIDGE;
@@ -72,7 +72,8 @@ static int br_fill_ifinfo(struct sk_buff *skb, const struct net_bridge_port *por
        return nlmsg_end(skb, nlh);
 
 nla_put_failure:
-       return nlmsg_cancel(skb, nlh);
+       nlmsg_cancel(skb, nlh);
+       return -EMSGSIZE;
 }
 
 /*
@@ -89,9 +90,12 @@ void br_ifinfo_notify(int event, struct net_bridge_port *port)
                goto errout;
 
        err = br_fill_ifinfo(skb, port, 0, 0, event, 0);
-       /* failure implies BUG in br_nlmsg_size() */
-       BUG_ON(err < 0);
-
+       if (err < 0) {
+               /* -EMSGSIZE implies BUG in br_nlmsg_size() */
+               WARN_ON(err == -EMSGSIZE);
+               kfree_skb(skb);
+               goto errout;
+       }
        err = rtnl_notify(skb, 0, RTNLGRP_LINK, NULL, GFP_ATOMIC);
 errout:
        if (err < 0)
index 20278494e4da0d11712cfad0ed31f410abc5eb35..8cd3e422907001eec79a146c17ad22856ca5fbaf 100644 (file)
@@ -26,7 +26,7 @@ struct notifier_block br_device_notifier = {
 
 /*
  * Handle changes in state of network devices enslaved to a bridge.
- * 
+ *
  * Note: don't care about up/down if bridge itself is down, because
  *     port state is checked when bridge is brought up.
  */
@@ -60,11 +60,11 @@ static int br_device_event(struct notifier_block *unused, unsigned long event, v
                break;
 
        case NETDEV_FEAT_CHANGE:
-               if (br->dev->flags & IFF_UP) 
+               if (br->dev->flags & IFF_UP)
                        br_features_recompute(br);
 
                /* could do recursive feature change notification
-                * but who would care?? 
+                * but who would care??
                 */
                break;
 
@@ -74,7 +74,7 @@ static int br_device_event(struct notifier_block *unused, unsigned long event, v
                break;
 
        case NETDEV_UP:
-               if (netif_carrier_ok(dev) && (br->dev->flags & IFF_UP)) 
+               if (netif_carrier_ok(dev) && (br->dev->flags & IFF_UP))
                        br_stp_enable_port(p);
                break;
 
@@ -82,7 +82,7 @@ static int br_device_event(struct notifier_block *unused, unsigned long event, v
                spin_unlock_bh(&br->lock);
                br_del_if(br, dev);
                goto done;
-       } 
+       }
        spin_unlock_bh(&br->lock);
 
  done:
index 3a534e94c7f3db084e7b501dcf48dfe72038ec28..6a0540e0591e93593d547ff35cafe1e00da50799 100644 (file)
@@ -149,7 +149,7 @@ extern struct net_bridge_fdb_entry *__br_fdb_get(struct net_bridge *br,
 extern struct net_bridge_fdb_entry *br_fdb_get(struct net_bridge *br,
                                               unsigned char *addr);
 extern void br_fdb_put(struct net_bridge_fdb_entry *ent);
-extern int br_fdb_fillbuf(struct net_bridge *br, void *buf, 
+extern int br_fdb_fillbuf(struct net_bridge *br, void *buf,
                          unsigned long count, unsigned long off);
 extern int br_fdb_insert(struct net_bridge *br,
                         struct net_bridge_port *source,
@@ -203,7 +203,7 @@ extern void br_netfilter_fini(void);
 /* br_stp.c */
 extern void br_log_state(const struct net_bridge_port *p);
 extern struct net_bridge_port *br_get_port(struct net_bridge *br,
-                                          u16 port_no);
+                                          u16 port_no);
 extern void br_init_port(struct net_bridge_port *p);
 extern void br_become_designated_port(struct net_bridge_port *p);
 
index 04ca0639a95a71d52ac7b2ae3a0a48f7a34f9cf6..f9ff4d57b0d7fc60cbbd5e5718f2e67c0b247121 100644 (file)
 #define MESSAGE_AGE_INCR       ((HZ < 256) ? 1 : (HZ/256))
 
 static const char *br_port_state_names[] = {
-       [BR_STATE_DISABLED] = "disabled", 
+       [BR_STATE_DISABLED] = "disabled",
        [BR_STATE_LISTENING] = "listening",
-       [BR_STATE_LEARNING] = "learning", 
-       [BR_STATE_FORWARDING] = "forwarding", 
+       [BR_STATE_LEARNING] = "learning",
+       [BR_STATE_FORWARDING] = "forwarding",
        [BR_STATE_BLOCKING] = "blocking",
 };
 
 void br_log_state(const struct net_bridge_port *p)
 {
        pr_info("%s: port %d(%s) entering %s state\n",
-               p->br->dev->name, p->port_no, p->dev->name, 
+               p->br->dev->name, p->port_no, p->dev->name,
                br_port_state_names[p->state]);
 
 }
@@ -53,7 +53,7 @@ struct net_bridge_port *br_get_port(struct net_bridge *br, u16 port_no)
 }
 
 /* called under bridge lock */
-static int br_should_become_root_port(const struct net_bridge_port *p, 
+static int br_should_become_root_port(const struct net_bridge_port *p,
                                      u16 root_port)
 {
        struct net_bridge *br;
@@ -184,7 +184,7 @@ void br_transmit_config(struct net_bridge_port *p)
 }
 
 /* called under bridge lock */
-static inline void br_record_config_information(struct net_bridge_port *p, 
+static inline void br_record_config_information(struct net_bridge_port *p,
                                                const struct br_config_bpdu *bpdu)
 {
        p->designated_root = bpdu->root;
@@ -192,12 +192,12 @@ static inline void br_record_config_information(struct net_bridge_port *p,
        p->designated_bridge = bpdu->bridge_id;
        p->designated_port = bpdu->port_id;
 
-       mod_timer(&p->message_age_timer, jiffies 
+       mod_timer(&p->message_age_timer, jiffies
                  + (p->br->max_age - bpdu->message_age));
 }
 
 /* called under bridge lock */
-static inline void br_record_config_timeout_values(struct net_bridge *br, 
+static inline void br_record_config_timeout_values(struct net_bridge *br,
                                            const struct br_config_bpdu *bpdu)
 {
        br->max_age = bpdu->max_age;
@@ -415,7 +415,7 @@ void br_received_config_bpdu(struct net_bridge_port *p, struct br_config_bpdu *b
 {
        struct net_bridge *br;
        int was_root;
+
        br = p->br;
        was_root = br_is_root_bridge(br);
 
@@ -430,7 +430,7 @@ void br_received_config_bpdu(struct net_bridge_port *p, struct br_config_bpdu *b
                                del_timer(&br->topology_change_timer);
                                br_transmit_tcn(br);
 
-                               mod_timer(&br->tcn_timer, 
+                               mod_timer(&br->tcn_timer,
                                          jiffies + br->bridge_hello_time);
                        }
                }
@@ -441,8 +441,8 @@ void br_received_config_bpdu(struct net_bridge_port *p, struct br_config_bpdu *b
                        if (bpdu->topology_change_ack)
                                br_topology_change_acknowledged(br);
                }
-       } else if (br_is_designated_port(p)) {          
-               br_reply(p);            
+       } else if (br_is_designated_port(p)) {
+               br_reply(p);
        }
 }
 
index 068d8afbf0a79896eadadbddf4e19c15d56da288..b9fb0dc4ab1290dc4bebcb151a579bf39fb92ae2 100644 (file)
@@ -29,7 +29,7 @@
 #define LLC_RESERVE sizeof(struct llc_pdu_un)
 
 static void br_send_bpdu(struct net_bridge_port *p,
-                        const unsigned char *data, int length)
+                        const unsigned char *data, int length)
 {
        struct sk_buff *skb;
 
index d294224592db0455e0bd31d7f04ab6a290abc21e..58d13f2bd121471eb5ee8adf90e5b4ec2dcd1530 100644 (file)
@@ -28,7 +28,7 @@
  */
 static inline port_id br_make_port_id(__u8 priority, __u16 port_no)
 {
-       return ((u16)priority << BR_PORT_BITS) 
+       return ((u16)priority << BR_PORT_BITS)
                | (port_no & ((1<<BR_PORT_BITS)-1));
 }
 
@@ -50,7 +50,7 @@ void br_stp_enable_bridge(struct net_bridge *br)
        spin_lock_bh(&br->lock);
        mod_timer(&br->hello_timer, jiffies + br->hello_time);
        mod_timer(&br->gc_timer, jiffies + HZ/10);
-       
+
        br_config_bpdu_generation(br);
 
        list_for_each_entry(p, &br->port_list, list) {
index d0fcde82c6fcaa3ff81b9569b6a960e9cbc69052..030aa798fea70bd5b9ee4a6fc814529c569e460b 100644 (file)
@@ -27,7 +27,7 @@ static int br_is_designated_for_some_port(const struct net_bridge *br)
 
        list_for_each_entry(p, &br->port_list, list) {
                if (p->state != BR_STATE_DISABLED &&
-                   !memcmp(&p->designated_bridge, &br->bridge_id, 8)) 
+                   !memcmp(&p->designated_bridge, &br->bridge_id, 8))
                        return 1;
        }
 
@@ -37,7 +37,7 @@ static int br_is_designated_for_some_port(const struct net_bridge *br)
 static void br_hello_timer_expired(unsigned long arg)
 {
        struct net_bridge *br = (struct net_bridge *)arg;
-       
+
        pr_debug("%s: hello timer expired\n", br->dev->name);
        spin_lock(&br->lock);
        if (br->dev->flags & IFF_UP) {
@@ -58,11 +58,11 @@ static void br_message_age_timer_expired(unsigned long arg)
        if (p->state == BR_STATE_DISABLED)
                return;
 
-       
+
        pr_info("%s: neighbor %.2x%.2x.%.2x:%.2x:%.2x:%.2x:%.2x:%.2x lost on port %d(%s)\n",
-               br->dev->name, 
-               id->prio[0], id->prio[1], 
-               id->addr[0], id->addr[1], id->addr[2], 
+               br->dev->name,
+               id->prio[0], id->prio[1],
+               id->addr[0], id->addr[1], id->addr[2],
                id->addr[3], id->addr[4], id->addr[5],
                p->port_no, p->dev->name);
 
@@ -114,7 +114,7 @@ static void br_tcn_timer_expired(unsigned long arg)
        spin_lock(&br->lock);
        if (br->dev->flags & IFF_UP) {
                br_transmit_tcn(br);
-       
+
                mod_timer(&br->tcn_timer,jiffies + br->bridge_hello_time);
        }
        spin_unlock(&br->lock);
@@ -135,7 +135,7 @@ static void br_hold_timer_expired(unsigned long arg)
 {
        struct net_bridge_port *p = (struct net_bridge_port *) arg;
 
-       pr_debug("%s: %d(%s) hold timer expired\n", 
+       pr_debug("%s: %d(%s) hold timer expired\n",
                 p->br->dev->name,  p->port_no, p->dev->name);
 
        spin_lock(&p->br->lock);
@@ -166,10 +166,10 @@ void br_stp_port_timer_init(struct net_bridge_port *p)
 
        setup_timer(&p->forward_delay_timer, br_forward_delay_timer_expired,
                      (unsigned long) p);
-                     
+
        setup_timer(&p->hold_timer, br_hold_timer_expired,
                      (unsigned long) p);
-}      
+}
 
 /* Report ticks left (in USER_HZ) used for API */
 unsigned long br_timer_value(const struct timer_list *timer)
index ce10464716a7cc4281e005c861f7add521be8a69..01a22ad0cc7591b037c4f6108f6aab311f13618e 100644 (file)
@@ -353,19 +353,19 @@ static ssize_t brforward_read(struct kobject *kobj, char *buf,
        if (off % sizeof(struct __fdb_entry) != 0)
                return -EINVAL;
 
-       n =  br_fdb_fillbuf(br, buf, 
+       n =  br_fdb_fillbuf(br, buf,
                            count / sizeof(struct __fdb_entry),
                            off / sizeof(struct __fdb_entry));
 
        if (n > 0)
                n *= sizeof(struct __fdb_entry);
-       
+
        return n;
 }
 
 static struct bin_attribute bridge_forward = {
        .attr = { .name = SYSFS_BRIDGE_FDB,
-                 .mode = S_IRUGO, 
+                 .mode = S_IRUGO,
                  .owner = THIS_MODULE, },
        .read = brforward_read,
 };
@@ -401,7 +401,7 @@ int br_sysfs_addbr(struct net_device *dev)
                goto out2;
        }
 
-       
+
        kobject_set_name(&br->ifobj, SYSFS_BRIDGE_PORT_SUBDIR);
        br->ifobj.ktype = NULL;
        br->ifobj.kset = NULL;
index 9abbc09ccdc376348545791de814ac835bb3194d..41a78072cd0eb1f4eed32752b2708ee6369788ee 100644 (file)
@@ -5,7 +5,7 @@
  * Chris Vitale csv@bluetail.com
  *
  * May 2003
- * 
+ *
  */
 
 #include <linux/netfilter_bridge/ebtables.h>
@@ -20,7 +20,7 @@ static int ebt_filter_802_3(const struct sk_buff *skb, const struct net_device *
        __be16 type = hdr->llc.ui.ctrl & IS_UI ? hdr->llc.ui.type : hdr->llc.ni.type;
 
        if (info->bitmask & EBT_802_3_SAP) {
-               if (FWINV(info->sap != hdr->llc.ui.ssap, EBT_802_3_SAP)) 
+               if (FWINV(info->sap != hdr->llc.ui.ssap, EBT_802_3_SAP))
                                return EBT_NOMATCH;
                if (FWINV(info->sap != hdr->llc.ui.dsap, EBT_802_3_SAP))
                                return EBT_NOMATCH;
@@ -29,7 +29,7 @@ static int ebt_filter_802_3(const struct sk_buff *skb, const struct net_device *
        if (info->bitmask & EBT_802_3_TYPE) {
                if (!(hdr->llc.ui.dsap == CHECK_TYPE && hdr->llc.ui.ssap == CHECK_TYPE))
                        return EBT_NOMATCH;
-               if (FWINV(info->type != type, EBT_802_3_TYPE)) 
+               if (FWINV(info->type != type, EBT_802_3_TYPE))
                        return EBT_NOMATCH;
        }
 
index ce97c4285f9adc1ddcd9de259e05f99b9b48d292..392d877040d31897f063d97c49b49ff7c1949532 100644 (file)
@@ -18,7 +18,7 @@ static int ebt_mac_wormhash_contains(const struct ebt_mac_wormhash *wh,
                                     const char *mac, __be32 ip)
 {
        /* You may be puzzled as to how this code works.
-        * Some tricks were used, refer to 
+        * Some tricks were used, refer to
         *      include/linux/netfilter_bridge/ebt_among.h
         * as there you can find a solution of this mystery.
         */
@@ -207,8 +207,8 @@ static int ebt_among_check(const char *tablename, unsigned int hookmask,
 }
 
 static struct ebt_match filter_among = {
-       .name           = EBT_AMONG_MATCH, 
-       .match          = ebt_filter_among, 
+       .name           = EBT_AMONG_MATCH,
+       .match          = ebt_filter_among,
        .check          = ebt_among_check,
        .me             = THIS_MODULE,
 };
index 0aa7b9910a86159a66043ba819298a02f6b917f1..ffe468a632e72c490c5344c2ac9db5850c82dd74 100644 (file)
@@ -51,7 +51,7 @@ static int ebt_target_reply(struct sk_buff **pskb, unsigned int hooknr,
                return EBT_DROP;
 
        arp_send(ARPOP_REPLY, ETH_P_ARP, *siptr, (struct net_device *)in,
-                *diptr, shp, info->mac, shp);
+                *diptr, shp, info->mac, shp);
 
        return info->target;
 }
index e4c642448e1b41e403d0bab85b98c59b85b46d29..69f7f0ab9c76ae5fa5d4cdd7ef2264417a675ba3 100644 (file)
@@ -61,15 +61,15 @@ static int ebt_filter_ip(const struct sk_buff *skb, const struct net_device *in,
                if (info->bitmask & EBT_IP_DPORT) {
                        u32 dst = ntohs(pptr->dst);
                        if (FWINV(dst < info->dport[0] ||
-                                 dst > info->dport[1],
-                                 EBT_IP_DPORT))
+                                 dst > info->dport[1],
+                                 EBT_IP_DPORT))
                        return EBT_NOMATCH;
                }
                if (info->bitmask & EBT_IP_SPORT) {
                        u32 src = ntohs(pptr->src);
                        if (FWINV(src < info->sport[0] ||
-                                 src > info->sport[1],
-                                 EBT_IP_SPORT))
+                                 src > info->sport[1],
+                                 EBT_IP_SPORT))
                        return EBT_NOMATCH;
                }
        }
@@ -93,6 +93,7 @@ static int ebt_ip_check(const char *tablename, unsigned int hookmask,
                        return -EINVAL;
                if (info->protocol != IPPROTO_TCP &&
                    info->protocol != IPPROTO_UDP &&
+                   info->protocol != IPPROTO_UDPLITE &&
                    info->protocol != IPPROTO_SCTP &&
                    info->protocol != IPPROTO_DCCP)
                         return -EINVAL;
index a184f879f25396ea0b1dd079fd8a4d1de641a01d..f9a5ae9d5b6dd37ad4881cb2d05146148d87e8ef 100644 (file)
@@ -96,6 +96,7 @@ ebt_log_packet(unsigned int pf, unsigned int hooknum,
                       NIPQUAD(ih->daddr), ih->tos, ih->protocol);
                if (ih->protocol == IPPROTO_TCP ||
                    ih->protocol == IPPROTO_UDP ||
+                   ih->protocol == IPPROTO_UDPLITE ||
                    ih->protocol == IPPROTO_SCTP ||
                    ih->protocol == IPPROTO_DCCP) {
                        struct tcpudphdr _ports, *pptr;
@@ -168,10 +169,10 @@ static void ebt_log(const struct sk_buff *skb, unsigned int hooknr,
 
        if (info->bitmask & EBT_LOG_NFLOG)
                nf_log_packet(PF_BRIDGE, hooknr, skb, in, out, &li,
-                             "%s", info->prefix);
+                             "%s", info->prefix);
        else
                ebt_log_packet(PF_BRIDGE, hooknr, skb, in, out, &li,
-                              info->prefix);
+                              info->prefix);
 }
 
 static struct ebt_watcher log =
@@ -198,7 +199,7 @@ static int __init ebt_log_init(void)
        if (nf_log_register(PF_BRIDGE, &ebt_log_logger) < 0) {
                printk(KERN_WARNING "ebt_log: not logging via system console "
                       "since somebody else already registered for PF_INET\n");
-               /* we cannot make module load fail here, since otherwise 
+               /* we cannot make module load fail here, since otherwise
                 * ebtables userspace would abort */
        }
 
index 025869ee0b68945b11d1331d6886123adbdd09dd..6b0d2169af74e379b468ea47dc8b47d6e26d5add 100644 (file)
@@ -26,7 +26,7 @@ static int ebt_filter_mark(const struct sk_buff *skb,
 static int ebt_mark_check(const char *tablename, unsigned int hookmask,
    const struct ebt_entry *e, void *data, unsigned int datalen)
 {
-        struct ebt_mark_m_info *info = (struct ebt_mark_m_info *) data;
+       struct ebt_mark_m_info *info = (struct ebt_mark_m_info *) data;
 
        if (datalen != EBT_ALIGN(sizeof(struct ebt_mark_m_info)))
                return -EINVAL;
index a0bed82145eda9fcb02d88d8a7edb1a6e577f922..31b77367319cb3949e5c9f61f27ce3c184225067 100644 (file)
@@ -62,7 +62,7 @@ static int ebt_filter_config(struct ebt_stp_info *info,
                verdict = 0;
                for (i = 0; i < 6; i++)
                        verdict |= (stpc->root[2+i] ^ c->root_addr[i]) &
-                                  c->root_addrmsk[i];
+                                  c->root_addrmsk[i];
                if (FWINV(verdict != 0, EBT_STP_ROOTADDR))
                        return EBT_NOMATCH;
        }
@@ -82,7 +82,7 @@ static int ebt_filter_config(struct ebt_stp_info *info,
                verdict = 0;
                for (i = 0; i < 6; i++)
                        verdict |= (stpc->sender[2+i] ^ c->sender_addr[i]) &
-                                  c->sender_addrmsk[i];
+                                  c->sender_addrmsk[i];
                if (FWINV(verdict != 0, EBT_STP_SENDERADDR))
                        return EBT_NOMATCH;
        }
index c1af68b5a29cacdd05ade7f014852d4809e2e1c7..2e4cb24e191a38143532bbd2056a8463bd13321a 100644 (file)
@@ -10,8 +10,8 @@
  * Based on ipt_ULOG.c, which is
  * (C) 2000-2002 by Harald Welte <laforge@netfilter.org>
  *
- * This module accepts two parameters: 
- * 
+ * This module accepts two parameters:
+ *
  * nlbufsiz:
  *   The parameter specifies how big the buffer for each netlink multicast
  * group is. e.g. If you say nlbufsiz=8192, up to eight kb of packets will
 #include "../br_private.h"
 
 #define PRINTR(format, args...) do { if (net_ratelimit()) \
-                                printk(format , ## args); } while (0)
+                               printk(format , ## args); } while (0)
 
 static unsigned int nlbufsiz = NLMSG_GOODSIZE;
 module_param(nlbufsiz, uint, 0600);
 MODULE_PARM_DESC(nlbufsiz, "netlink buffer size (number of bytes) "
-                           "(defaults to 4096)");
+                          "(defaults to 4096)");
 
 static unsigned int flushtimeout = 10;
 module_param(flushtimeout, uint, 0600);
 MODULE_PARM_DESC(flushtimeout, "buffer flush timeout (hundredths ofa second) "
-                               "(defaults to 10)");
+                              "(defaults to 10)");
 
 typedef struct {
        unsigned int qlen;              /* number of nlmsgs' in the skb */
@@ -157,7 +157,7 @@ static void ebt_ulog_packet(unsigned int hooknr, const struct sk_buff *skb,
        }
 
        nlh = NLMSG_PUT(ub->skb, 0, ub->qlen, 0,
-                       size - NLMSG_ALIGN(sizeof(*nlh)));
+                       size - NLMSG_ALIGN(sizeof(*nlh)));
        ub->qlen++;
 
        pm = NLMSG_DATA(nlh);
@@ -302,7 +302,7 @@ static int __init ebt_ulog_init(void)
        }
 
        ebtulognl = netlink_kernel_create(NETLINK_NFLOG, EBT_ULOG_MAXNLGROUPS,
-                                         NULL, THIS_MODULE);
+                                         NULL, THIS_MODULE);
        if (!ebtulognl)
                ret = -ENOMEM;
        else if ((ret = ebt_register_watcher(&ulog)))
@@ -344,4 +344,4 @@ module_exit(ebt_ulog_fini);
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Bart De Schuymer <bdschuym@pandora.be>");
 MODULE_DESCRIPTION("ebtables userspace logging module for bridged Ethernet"
-                   " frames");
+                  " frames");
index 7ee377622964d46e1bb57687c6af01587fe37fa3..a43c697d3d7305dc4bc48d66254e4aa8cdacff63 100644 (file)
@@ -128,9 +128,9 @@ ebt_check_vlan(const char *tablename,
 
        /* Reserved VLAN ID (VID) values
         * -----------------------------
-        * 0 - The null VLAN ID. 
+        * 0 - The null VLAN ID.
         * 1 - The default Port VID (PVID)
-        * 0x0FFF - Reserved for implementation use. 
+        * 0x0FFF - Reserved for implementation use.
         * if_vlan.h: VLAN_GROUP_ARRAY_LEN 4096. */
        if (GET_BITMASK(EBT_VLAN_ID)) {
                if (!!info->id) { /* if id!=0 => check vid range */
@@ -141,7 +141,7 @@ ebt_check_vlan(const char *tablename,
                                return -EINVAL;
                        }
                        /* Note: This is valid VLAN-tagged frame point.
-                        * Any value of user_priority are acceptable, 
+                        * Any value of user_priority are acceptable,
                         * but should be ignored according to 802.1Q Std.
                         * So we just drop the prio flag. */
                        info->bitmask &= ~EBT_VLAN_PRIO;
index 127135ead2d5ade31f30571425fd15085e0920cf..81d84145c417ca8eda14cca79734f66a5f85bbd6 100644 (file)
@@ -51,10 +51,10 @@ static int check(const struct ebt_table_info *info, unsigned int valid_hooks)
 }
 
 static struct ebt_table frame_filter =
-{ 
+{
        .name           = "filter",
        .table          = &initial_table,
-       .valid_hooks    = FILTER_VALID_HOOKS, 
+       .valid_hooks    = FILTER_VALID_HOOKS,
        .lock           = RW_LOCK_UNLOCKED,
        .check          = check,
        .me             = THIS_MODULE,
index 6c84ccb8c9d754d045bc6351812917f6cfbd3cb3..5818d70b8e8d3bec53c5d6696beed715439d770d 100644 (file)
 #include "../br_private.h"
 
 #define BUGPRINT(format, args...) printk("kernel msg: ebtables bug: please "\
-                                         "report to author: "format, ## args)
+                                        "report to author: "format, ## args)
 /* #define BUGPRINT(format, args...) */
 #define MEMPRINT(format, args...) printk("kernel msg: ebtables "\
-                                         ": out of memory: "format, ## args)
+                                        ": out of memory: "format, ## args)
 /* #define MEMPRINT(format, args...) */
 
 
@@ -482,7 +482,7 @@ ebt_check_entry_size_and_hooks(struct ebt_entry *e,
                   as it said it has */
                if (*n != *cnt) {
                        BUGPRINT("nentries does not equal the nr of entries "
-                                "in the chain\n");
+                                "in the chain\n");
                        return -EINVAL;
                }
                if (((struct ebt_entries *)e)->policy != EBT_DROP &&
@@ -809,7 +809,7 @@ static int translate_table(char *name, struct ebt_table_info *newinfo)
        i = 0; /* holds the expected nr. of entries for the chain */
        j = 0; /* holds the up to now counted entries for the chain */
        k = 0; /* holds the total nr. of entries, should equal
-                 newinfo->nentries afterwards */
+                 newinfo->nentries afterwards */
        udc_cnt = 0; /* will hold the nr. of user defined chains (udc) */
        ret = EBT_ENTRY_ITERATE(newinfo->entries, newinfo->entries_size,
           ebt_check_entry_size_and_hooks, newinfo,
@@ -820,7 +820,7 @@ static int translate_table(char *name, struct ebt_table_info *newinfo)
 
        if (i != j) {
                BUGPRINT("nentries does not equal the nr of entries in the "
-                        "(last) chain\n");
+                        "(last) chain\n");
                return -EINVAL;
        }
        if (k != newinfo->nentries) {
@@ -835,7 +835,7 @@ static int translate_table(char *name, struct ebt_table_info *newinfo)
                   if an error occurs */
                newinfo->chainstack =
                        vmalloc((highest_possible_processor_id()+1)
-                                       * sizeof(*(newinfo->chainstack)));
+                                       * sizeof(*(newinfo->chainstack)));
                if (!newinfo->chainstack)
                        return -ENOMEM;
                for_each_possible_cpu(i) {
@@ -948,7 +948,7 @@ static int do_replace(void __user *user, unsigned int len)
        if (tmp.num_counters >= INT_MAX / sizeof(struct ebt_counter))
                return -ENOMEM;
 
-       countersize = COUNTER_OFFSET(tmp.nentries) * 
+       countersize = COUNTER_OFFSET(tmp.nentries) *
                                        (highest_possible_processor_id()+1);
        newinfo = vmalloc(sizeof(*newinfo) + countersize);
        if (!newinfo)
@@ -1350,7 +1350,7 @@ static inline int ebt_make_names(struct ebt_entry *e, char *base, char __user *u
 
        hlp = ubase + (((char *)e + e->target_offset) - base);
        t = (struct ebt_entry_target *)(((char *)e) + e->target_offset);
-       
+
        ret = EBT_MATCH_ITERATE(e, ebt_make_matchname, base, ubase);
        if (ret != 0)
                return ret;
index 52d32f1bc7281c6da3276ae78a0cad1e63aa4426..9c970749a3b0fcb56f9c1386d3edcdf6fc97b54e 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
  * 32bit Socket syscall emulation. Based on arch/sparc64/kernel/sys_sparc32.c.
  *
  * Copyright (C) 2000          VA Linux Co
@@ -8,7 +8,7 @@
  * Copyright (C) 1997          David S. Miller (davem@caip.rutgers.edu)
  * Copyright (C) 2000          Hewlett-Packard Co.
  * Copyright (C) 2000          David Mosberger-Tang <davidm@hpl.hp.com>
- * Copyright (C) 2000,2001     Andi Kleen, SuSE Labs 
+ * Copyright (C) 2000,2001     Andi Kleen, SuSE Labs
  */
 
 #include <linux/kernel.h>
@@ -225,14 +225,14 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
                return 0; /* XXX: return error? check spec. */
        }
 
-       if (level == SOL_SOCKET && type == SO_TIMESTAMP) { 
+       if (level == SOL_SOCKET && type == SO_TIMESTAMP) {
                struct timeval *tv = (struct timeval *)data;
                ctv.tv_sec = tv->tv_sec;
                ctv.tv_usec = tv->tv_usec;
                data = &ctv;
                len = sizeof(struct compat_timeval);
-       } 
-       
+       }
+
        cmlen = CMSG_COMPAT_LEN(len);
        if(kmsg->msg_controllen < cmlen) {
                kmsg->msg_flags |= MSG_CTRUNC;
@@ -419,7 +419,7 @@ static int do_set_attach_filter(struct socket *sock, int level, int optname,
                                char __user *optval, int optlen)
 {
        struct compat_sock_fprog __user *fprog32 = (struct compat_sock_fprog __user *)optval;
-       struct sock_fprog __user *kfprog = compat_alloc_user_space(sizeof(struct sock_fprog)); 
+       struct sock_fprog __user *kfprog = compat_alloc_user_space(sizeof(struct sock_fprog));
        compat_uptr_t ptr;
        u16 len;
 
@@ -610,14 +610,14 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
        int ret;
        u32 a[6];
        u32 a0, a1;
-                                
+
        if (call < SYS_SOCKET || call > SYS_RECVMSG)
                return -EINVAL;
        if (copy_from_user(a, args, nas[call]))
                return -EFAULT;
        a0 = a[0];
        a1 = a[1];
-       
+
        switch(call) {
        case SYS_SOCKET:
                ret = sys_socket(a0, a1, a[2]);
index 797fdd4352ce50e3bf1ef2de7e3e7f686d2258c4..186212b5b7da4a943690982ae7f3bd8743eed220 100644 (file)
@@ -430,7 +430,7 @@ EXPORT_SYMBOL(__skb_checksum_complete);
  *     @skb: skbuff
  *     @hlen: hardware length
  *     @iov: io vector
- * 
+ *
  *     Caller _must_ check that skb will fit to this iovec.
  *
  *     Returns: 0       - success.
index 455d589683e8a99e17edae82447b85fae7f219e6..85d58d799329716faa3af946195ac852937dd1d9 100644 (file)
@@ -255,7 +255,7 @@ static int netdev_nit;
  *     is linked into kernel lists and may not be freed until it has been
  *     removed from the kernel lists.
  *
- *     This call does not sleep therefore it can not 
+ *     This call does not sleep therefore it can not
  *     guarantee all CPU's that are in middle of receiving packets
  *     will see the new packet type (until the next received packet).
  */
@@ -282,7 +282,7 @@ void dev_add_pack(struct packet_type *pt)
  *     Remove a protocol handler that was previously added to the kernel
  *     protocol handlers by dev_add_pack(). The passed &packet_type is removed
  *     from the kernel lists and can be freed or reused once this function
- *     returns. 
+ *     returns.
  *
  *      The packet type might still be in use by receivers
  *     and must not be freed until after all the CPU's have gone
@@ -327,7 +327,7 @@ out:
 void dev_remove_pack(struct packet_type *pt)
 {
        __dev_remove_pack(pt);
-       
+
        synchronize_net();
 }
 
@@ -607,7 +607,7 @@ EXPORT_SYMBOL(dev_getfirstbyhwtype);
  *     @mask: bitmask of bits in if_flags to check
  *
  *     Search for any interface with the given flags. Returns NULL if a device
- *     is not found or a pointer to the device. The device returned has 
+ *     is not found or a pointer to the device. The device returned has
  *     had a reference added and the pointer is safe until the user calls
  *     dev_put to indicate they have finished with it.
  */
@@ -802,7 +802,7 @@ void netdev_state_change(struct net_device *dev)
 
 void dev_load(const char *name)
 {
-       struct net_device *dev;  
+       struct net_device *dev;
 
        read_lock(&dev_base_lock);
        dev = __dev_get_by_name(name);
@@ -860,7 +860,7 @@ int dev_open(struct net_device *dev)
                        clear_bit(__LINK_STATE_START, &dev->state);
        }
 
-       /*
+       /*
         *      If it went open OK then:
         */
 
@@ -964,7 +964,7 @@ int dev_close(struct net_device *dev)
  *     is returned on a failure.
  *
  *     When registered all registration and up events are replayed
- *     to the new notifier to allow device to have a race free 
+ *     to the new notifier to allow device to have a race free
  *     view of the network device list.
  */
 
@@ -979,7 +979,7 @@ int register_netdevice_notifier(struct notifier_block *nb)
                for (dev = dev_base; dev; dev = dev->next) {
                        nb->notifier_call(nb, NETDEV_REGISTER, dev);
 
-                       if (dev->flags & IFF_UP) 
+                       if (dev->flags & IFF_UP)
                                nb->notifier_call(nb, NETDEV_UP, dev);
                }
        }
@@ -1157,7 +1157,7 @@ void netif_device_attach(struct net_device *dev)
        if (!test_and_set_bit(__LINK_STATE_PRESENT, &dev->state) &&
            netif_running(dev)) {
                netif_wake_queue(dev);
-               __netdev_watchdog_up(dev);
+               __netdev_watchdog_up(dev);
        }
 }
 EXPORT_SYMBOL(netif_device_attach);
@@ -1197,7 +1197,7 @@ int skb_checksum_help(struct sk_buff *skb)
 
 out_set_summed:
        skb->ip_summed = CHECKSUM_NONE;
-out:   
+out:
        return ret;
 }
 
@@ -1258,7 +1258,7 @@ EXPORT_SYMBOL(skb_gso_segment);
 void netdev_rx_csum_fault(struct net_device *dev)
 {
        if (net_ratelimit()) {
-               printk(KERN_ERR "%s: hw csum failure.\n", 
+               printk(KERN_ERR "%s: hw csum failure.\n",
                        dev ? dev->name : "<unknown>");
                dump_stack();
        }
@@ -1372,7 +1372,7 @@ gso:
                if (unlikely(netif_queue_stopped(dev) && skb->next))
                        return NETDEV_TX_BUSY;
        } while (skb->next);
-       
+
        skb->destructor = DEV_GSO_CB(skb)->destructor;
 
 out_kfree_skb:
@@ -1449,25 +1449,25 @@ int dev_queue_xmit(struct sk_buff *skb)
            (!(dev->features & NETIF_F_GEN_CSUM) &&
             (!(dev->features & NETIF_F_IP_CSUM) ||
              skb->protocol != htons(ETH_P_IP))))
-               if (skb_checksum_help(skb))
-                       goto out_kfree_skb;
+               if (skb_checksum_help(skb))
+                       goto out_kfree_skb;
 
 gso:
        spin_lock_prefetch(&dev->queue_lock);
 
-       /* Disable soft irqs for various locks below. Also 
-        * stops preemption for RCU. 
+       /* Disable soft irqs for various locks below. Also
+        * stops preemption for RCU.
         */
-       rcu_read_lock_bh(); 
+       rcu_read_lock_bh();
 
-       /* Updates of qdisc are serialized by queue_lock. 
-        * The struct Qdisc which is pointed to by qdisc is now a 
-        * rcu structure - it may be accessed without acquiring 
+       /* Updates of qdisc are serialized by queue_lock.
+        * The struct Qdisc which is pointed to by qdisc is now a
+        * rcu structure - it may be accessed without acquiring
         * a lock (but the structure may be stale.) The freeing of the
-        * qdisc will be deferred until it's known that there are no 
+        * qdisc will be deferred until it's known that there are no
         * more references to it.
-        * 
-        * If the qdisc has an enqueue function, we still need to 
+        *
+        * If the qdisc has an enqueue function, we still need to
         * hold the queue_lock before calling it, since queue_lock
         * also serializes access to the device queue.
         */
@@ -1715,8 +1715,8 @@ static __inline__ int handle_bridge(struct sk_buff **pskb,
        if (*pt_prev) {
                *ret = deliver_skb(*pskb, *pt_prev, orig_dev);
                *pt_prev = NULL;
-       } 
-       
+       }
+
        return br_handle_frame_hook(port, pskb);
 }
 #else
@@ -1728,16 +1728,16 @@ static __inline__ int handle_bridge(struct sk_buff **pskb,
  * when CONFIG_NET_CLS_ACT is? otherwise some useless instructions
  * a compare and 2 stores extra right now if we dont have it on
  * but have CONFIG_NET_CLS_ACT
- * NOTE: This doesnt stop any functionality; if you dont have 
+ * NOTE: This doesnt stop any functionality; if you dont have
  * the ingress scheduler, you just cant add policies on ingress.
  *
  */
-static int ing_filter(struct sk_buff *skb) 
+static int ing_filter(struct sk_buff *skb)
 {
        struct Qdisc *q;
        struct net_device *dev = skb->dev;
        int result = TC_ACT_OK;
-       
+
        if (dev->qdisc_ingress) {
                __u32 ttl = (__u32) G_TC_RTTL(skb->tc_verd);
                if (MAX_RED_LOOP < ttl++) {
@@ -1801,7 +1801,7 @@ int netif_receive_skb(struct sk_buff *skb)
 
        list_for_each_entry_rcu(ptype, &ptype_all, list) {
                if (!ptype->dev || ptype->dev == skb->dev) {
-                       if (pt_prev) 
+                       if (pt_prev)
                                ret = deliver_skb(skb, pt_prev, orig_dev);
                        pt_prev = ptype;
                }
@@ -1833,7 +1833,7 @@ ncls:
        list_for_each_entry_rcu(ptype, &ptype_base[ntohs(type)&15], list) {
                if (ptype->type == type &&
                    (!ptype->dev || ptype->dev == skb->dev)) {
-                       if (pt_prev) 
+                       if (pt_prev)
                                ret = deliver_skb(skb, pt_prev, orig_dev);
                        pt_prev = ptype;
                }
@@ -2061,7 +2061,7 @@ static int dev_ifconf(char __user *arg)
                                total += done;
                        }
                }
-       }
+       }
 
        /*
         *      All done.  Write the updated control block back to the caller.
@@ -2154,7 +2154,7 @@ static struct netif_rx_stats *softnet_get_online(loff_t *pos)
        struct netif_rx_stats *rc = NULL;
 
        while (*pos < NR_CPUS)
-               if (cpu_online(*pos)) {
+               if (cpu_online(*pos)) {
                        rc = &per_cpu(netdev_rx_stat, *pos);
                        break;
                } else
@@ -2282,7 +2282,7 @@ int netdev_set_master(struct net_device *slave, struct net_device *master)
        }
 
        slave->master = master;
-       
+
        synchronize_net();
 
        if (old)
@@ -2319,13 +2319,13 @@ void dev_set_promiscuity(struct net_device *dev, int inc)
                dev_mc_upload(dev);
                printk(KERN_INFO "device %s %s promiscuous mode\n",
                       dev->name, (dev->flags & IFF_PROMISC) ? "entered" :
-                                                              "left");
+                                                              "left");
                audit_log(current->audit_context, GFP_ATOMIC,
                        AUDIT_ANOM_PROMISCUOUS,
                        "dev=%s prom=%d old_prom=%d auid=%u",
                        dev->name, (dev->flags & IFF_PROMISC),
                        (old_flags & IFF_PROMISC),
-                       audit_get_loginuid(current->audit_context)); 
+                       audit_get_loginuid(current->audit_context));
        }
 }
 
@@ -2816,7 +2816,7 @@ int dev_ioctl(unsigned int cmd, void __user *arg)
                                rtnl_unlock();
                                if (IW_IS_GET(cmd) &&
                                    copy_to_user(arg, &ifr,
-                                                sizeof(struct ifreq)))
+                                                sizeof(struct ifreq)))
                                        ret = -EFAULT;
                                return ret;
                        }
@@ -2906,7 +2906,7 @@ int register_netdevice(struct net_device *dev)
                        goto out;
                }
        }
+
        if (!dev_valid_name(dev->name)) {
                ret = -EINVAL;
                goto out;
@@ -2923,9 +2923,9 @@ int register_netdevice(struct net_device *dev)
                        = hlist_entry(p, struct net_device, name_hlist);
                if (!strncmp(d->name, dev->name, IFNAMSIZ)) {
                        ret = -EEXIST;
-                       goto out;
+                       goto out;
                }
-       }
+       }
 
        /* Fix illegal SG+CSUM combinations. */
        if ((dev->features & NETIF_F_SG) &&
@@ -3024,7 +3024,7 @@ int register_netdev(struct net_device *dev)
                if (err < 0)
                        goto out;
        }
-       
+
        err = register_netdevice(dev);
 out:
        rtnl_unlock();
@@ -3041,7 +3041,7 @@ EXPORT_SYMBOL(register_netdev);
  * for netdevice notification, and cleanup and put back the
  * reference if they receive an UNREGISTER event.
  * We can get stuck here if buggy protocols don't correctly
- * call dev_put. 
+ * call dev_put.
  */
 static void netdev_wait_allrefs(struct net_device *dev)
 {
@@ -3205,8 +3205,8 @@ EXPORT_SYMBOL(alloc_netdev);
  *     free_netdev - free network device
  *     @dev: device
  *
- *     This function does the last stage of destroying an allocated device 
- *     interface. The reference to the device object is released.  
+ *     This function does the last stage of destroying an allocated device
+ *     interface. The reference to the device object is released.
  *     If this is the last reference then it will be freed.
  */
 void free_netdev(struct net_device *dev)
@@ -3227,9 +3227,9 @@ void free_netdev(struct net_device *dev)
        kfree((char *)dev - dev->padded);
 #endif
 }
+
 /* Synchronize with packet receive processing. */
-void synchronize_net(void) 
+void synchronize_net(void)
 {
        might_sleep();
        synchronize_rcu();
@@ -3247,7 +3247,7 @@ void synchronize_net(void)
  *     unregister_netdev() instead of this.
  */
 
-int unregister_netdevice(struct net_device *dev)
+void unregister_netdevice(struct net_device *dev)
 {
        struct net_device *d, **dp;
 
@@ -3258,7 +3258,9 @@ int unregister_netdevice(struct net_device *dev)
        if (dev->reg_state == NETREG_UNINITIALIZED) {
                printk(KERN_DEBUG "unregister_netdevice: device %s/%p never "
                                  "was registered\n", dev->name, dev);
-               return -ENODEV;
+
+               WARN_ON(1);
+               return;
        }
 
        BUG_ON(dev->reg_state != NETREG_REGISTERED);
@@ -3280,11 +3282,7 @@ int unregister_netdevice(struct net_device *dev)
                        break;
                }
        }
-       if (!d) {
-               printk(KERN_ERR "unregister net_device: '%s' not found\n",
-                      dev->name);
-               return -ENODEV;
-       }
+       BUG_ON(!d);
 
        dev->reg_state = NETREG_UNREGISTERING;
 
@@ -3293,12 +3291,12 @@ int unregister_netdevice(struct net_device *dev)
        /* Shutdown queueing discipline. */
        dev_shutdown(dev);
 
-       
+
        /* Notify protocols, that we are about to destroy
           this device. They should clean all the things.
        */
        raw_notifier_call_chain(&netdev_chain, NETDEV_UNREGISTER, dev);
-       
+
        /*
         *      Flush the multicast chain
         */
@@ -3316,7 +3314,6 @@ int unregister_netdevice(struct net_device *dev)
        synchronize_net();
 
        dev_put(dev);
-       return 0;
 }
 
 /**
@@ -3486,7 +3483,7 @@ static int __init net_dev_init(void)
                goto out;
 
        INIT_LIST_HEAD(&ptype_all);
-       for (i = 0; i < 16; i++) 
+       for (i = 0; i < 16; i++)
                INIT_LIST_HEAD(&ptype_base[i]);
 
        for (i = 0; i < ARRAY_SIZE(dev_name_head); i++)
index b22648d04d365f1ce92a9eecf370effd6d32b202..bfcbdf73a2930efd98cc92e66fae46746cb47483 100644 (file)
@@ -1,12 +1,12 @@
 /*
- *     Linux NET3:     Multicast List maintenance. 
+ *     Linux NET3:     Multicast List maintenance.
  *
  *     Authors:
- *             Tim Kordas <tjk@nostromo.eeap.cwru.edu> 
+ *             Tim Kordas <tjk@nostromo.eeap.cwru.edu>
  *             Richard Underwood <richard@wuzz.demon.co.uk>
  *
  *     Stir fried together from the IP multicast and CAP patches above
- *             Alan Cox <Alan.Cox@linux.org>   
+ *             Alan Cox <Alan.Cox@linux.org>
  *
  *     Fixes:
  *             Alan Cox        :       Update the device on a real delete
 
 
 /*
- *     Device multicast list maintenance. 
+ *     Device multicast list maintenance.
  *
- *     This is used both by IP and by the user level maintenance functions. 
- *     Unlike BSD we maintain a usage count on a given multicast address so 
- *     that a casual user application can add/delete multicasts used by 
+ *     This is used both by IP and by the user level maintenance functions.
+ *     Unlike BSD we maintain a usage count on a given multicast address so
+ *     that a casual user application can add/delete multicasts used by
  *     protocols without doing damage to the protocols when it deletes the
  *     entries. It also helps IP as it tracks overlapping maps.
  *
@@ -67,7 +67,7 @@
 /*
  *     Update the multicast list into the physical NIC controller.
  */
+
 static void __dev_mc_upload(struct net_device *dev)
 {
        /* Don't do anything till we up the interface
@@ -100,7 +100,7 @@ void dev_mc_upload(struct net_device *dev)
 /*
  *     Delete a device level multicast
  */
+
 int dev_mc_delete(struct net_device *dev, void *addr, int alen, int glbl)
 {
        int err = 0;
@@ -137,7 +137,7 @@ int dev_mc_delete(struct net_device *dev, void *addr, int alen, int glbl)
                         *      loaded filter is now wrong. Fix it
                         */
                        __dev_mc_upload(dev);
-                       
+
                        netif_tx_unlock_bh(dev);
                        return 0;
                }
@@ -151,7 +151,7 @@ done:
 /*
  *     Add a device level multicast
  */
+
 int dev_mc_add(struct net_device *dev, void *addr, int alen, int glbl)
 {
        int err = 0;
@@ -187,7 +187,7 @@ int dev_mc_add(struct net_device *dev, void *addr, int alen, int glbl)
        dev->mc_count++;
 
        __dev_mc_upload(dev);
-       
+
        netif_tx_unlock_bh(dev);
        return 0;
 
@@ -204,7 +204,7 @@ done:
 void dev_mc_discard(struct net_device *dev)
 {
        netif_tx_lock_bh(dev);
-       
+
        while (dev->mc_list != NULL) {
                struct dev_mc_list *tmp = dev->mc_list;
                dev->mc_list = tmp->next;
@@ -225,7 +225,7 @@ static void *dev_mc_seq_start(struct seq_file *seq, loff_t *pos)
 
        read_lock(&dev_base_lock);
        for (dev = dev_base; dev; dev = dev->next) {
-               if (off++ == *pos) 
+               if (off++ == *pos)
                        return dev;
        }
        return NULL;
index 836ec66069254752c7ca2b9db0a597419dd758a2..61dd9d3951f1017697fe223a988e876466c5194d 100644 (file)
@@ -29,7 +29,7 @@
  * 4) All operations modify state, so a spinlock is used.
  */
 static struct dst_entry        *dst_garbage_list;
-#if RT_CACHE_DEBUG >= 2 
+#if RT_CACHE_DEBUG >= 2
 static atomic_t                         dst_total = ATOMIC_INIT(0);
 #endif
 static DEFINE_SPINLOCK(dst_lock);
@@ -99,7 +99,14 @@ static void dst_run_gc(unsigned long dummy)
        printk("dst_total: %d/%d %ld\n",
               atomic_read(&dst_total), delayed,  dst_gc_timer_expires);
 #endif
-       mod_timer(&dst_gc_timer, jiffies + dst_gc_timer_expires);
+       /* if the next desired timer is more than 4 seconds in the future
+        * then round the timer to whole seconds
+        */
+       if (dst_gc_timer_expires > 4*HZ)
+               mod_timer(&dst_gc_timer,
+                       round_jiffies(jiffies + dst_gc_timer_expires));
+       else
+               mod_timer(&dst_gc_timer, jiffies + dst_gc_timer_expires);
 
 out:
        spin_unlock(&dst_lock);
@@ -125,17 +132,16 @@ void * dst_alloc(struct dst_ops * ops)
                if (ops->gc())
                        return NULL;
        }
-       dst = kmem_cache_alloc(ops->kmem_cachep, GFP_ATOMIC);
+       dst = kmem_cache_zalloc(ops->kmem_cachep, GFP_ATOMIC);
        if (!dst)
                return NULL;
-       memset(dst, 0, ops->entry_size);
        atomic_set(&dst->__refcnt, 0);
        dst->ops = ops;
        dst->lastuse = jiffies;
        dst->path = dst;
        dst->input = dst_discard_in;
        dst->output = dst_discard_out;
-#if RT_CACHE_DEBUG >= 2 
+#if RT_CACHE_DEBUG >= 2
        atomic_inc(&dst_total);
 #endif
        atomic_inc(&ops->entries);
@@ -196,7 +202,7 @@ again:
                dst->ops->destroy(dst);
        if (dst->dev)
                dev_put(dst->dev);
-#if RT_CACHE_DEBUG >= 2 
+#if RT_CACHE_DEBUG >= 2
        atomic_dec(&dst_total);
 #endif
        kmem_cache_free(dst->ops->kmem_cachep, dst);
index 87dc556fd9d6c694f65e33c6868aebdeef8325cc..6168edd137dd39e0a986d3226115ff38091fbef1 100644 (file)
@@ -17,7 +17,7 @@
 #include <linux/netdevice.h>
 #include <asm/uaccess.h>
 
-/* 
+/*
  * Some useful ethtool_ops methods that're device independent.
  * If we find that all drivers want to do the same thing here,
  * we can turn these into dev_() function calls.
@@ -87,12 +87,12 @@ int ethtool_op_get_perm_addr(struct net_device *dev, struct ethtool_perm_addr *a
        unsigned char len = dev->addr_len;
        if ( addr->size < len )
                return -ETOOSMALL;
-       
+
        addr->size = len;
        memcpy(data, dev->perm_addr, len);
        return 0;
 }
+
 
 u32 ethtool_op_get_ufo(struct net_device *dev)
 {
@@ -550,7 +550,7 @@ static int ethtool_set_sg(struct net_device *dev, char __user *useraddr)
        if (copy_from_user(&edata, useraddr, sizeof(edata)))
                return -EFAULT;
 
-       if (edata.data && 
+       if (edata.data &&
            !(dev->features & NETIF_F_ALL_CSUM))
                return -EINVAL;
 
@@ -951,7 +951,7 @@ int dev_ethtool(struct ifreq *ifr)
        default:
                rc =  -EOPNOTSUPP;
        }
-       
+
        if(dev->ethtool_ops->complete)
                dev->ethtool_ops->complete(dev);
 
index 1df6cd4568d373e150984998691fadf9341eb629..215f1bff048feeb8991ebd3a49bc406d15053f77 100644 (file)
@@ -331,7 +331,7 @@ static int fib_nl_fill_rule(struct sk_buff *skb, struct fib_rule *rule,
 
        nlh = nlmsg_put(skb, pid, seq, type, sizeof(*frh), flags);
        if (nlh == NULL)
-               return -1;
+               return -EMSGSIZE;
 
        frh = nlmsg_data(nlh);
        frh->table = rule->table;
@@ -359,7 +359,8 @@ static int fib_nl_fill_rule(struct sk_buff *skb, struct fib_rule *rule,
        return nlmsg_end(skb, nlh);
 
 nla_put_failure:
-       return nlmsg_cancel(skb, nlh);
+       nlmsg_cancel(skb, nlh);
+       return -EMSGSIZE;
 }
 
 int fib_rules_dump(struct sk_buff *skb, struct netlink_callback *cb, int family)
@@ -405,9 +406,12 @@ static void notify_rule_change(int event, struct fib_rule *rule,
                goto errout;
 
        err = fib_nl_fill_rule(skb, rule, pid, nlh->nlmsg_seq, event, 0, ops);
-       /* failure implies BUG in fib_rule_nlmsg_size() */
-       BUG_ON(err < 0);
-
+       if (err < 0) {
+               /* -EMSGSIZE implies BUG in fib_rule_nlmsg_size() */
+               WARN_ON(err == -EMSGSIZE);
+               kfree_skb(skb);
+               goto errout;
+       }
        err = rtnl_notify(skb, pid, ops->nlgroup, nlh, GFP_KERNEL);
 errout:
        if (err < 0)
index 0df843b667f45fc44cdf6d83d60523268fb71502..8123a31d919daacfd8b782a5f3e9401e7fa08e7d 100644 (file)
@@ -53,7 +53,7 @@ static void *__load_pointer(struct sk_buff *skb, int k)
 }
 
 static inline void *load_pointer(struct sk_buff *skb, int k,
-                                 unsigned int size, void *buffer)
+                                unsigned int size, void *buffer)
 {
        if (k >= 0)
                return skb_header_pointer(skb, k, size, buffer);
@@ -91,7 +91,7 @@ unsigned int sk_run_filter(struct sk_buff *skb, struct sock_filter *filter, int
         */
        for (pc = 0; pc < flen; pc++) {
                fentry = &filter[pc];
-                       
+
                switch (fentry->code) {
                case BPF_ALU|BPF_ADD|BPF_X:
                        A += X;
@@ -399,7 +399,7 @@ int sk_chk_filter(struct sock_filter *filter, int flen)
  */
 int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk)
 {
-       struct sk_filter *fp; 
+       struct sk_filter *fp;
        unsigned int fsize = sizeof(struct sock_filter) * fprog->len;
        int err;
 
@@ -411,7 +411,7 @@ int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk)
        if (!fp)
                return -ENOMEM;
        if (copy_from_user(fp->insns, fprog->filter, fsize)) {
-               sock_kfree_s(sk, fp, fsize+sizeof(*fp)); 
+               sock_kfree_s(sk, fp, fsize+sizeof(*fp));
                return -EFAULT;
        }
 
index 3cad026764f0c9b94f9615ee22da0f9b4ed16833..17daf4c9f79384ad0005fbec5780cc8bd6f63321 100644 (file)
@@ -144,7 +144,7 @@ static void est_timer(unsigned long arg)
  * configuration TLV is created. Upon each interval, the latest statistics
  * will be read from &bstats and the estimated rate will be stored in
  * &rate_est with the statistics lock grabed during this period.
- * 
+ *
  * Returns 0 on success or a negative error code.
  */
 int gen_new_estimator(struct gnet_stats_basic *bstats,
@@ -231,7 +231,7 @@ void gen_kill_estimator(struct gnet_stats_basic *bstats,
  *
  * Replaces the configuration of a rate estimator by calling
  * gen_kill_estimator() and gen_new_estimator().
- * 
+ *
  * Returns 0 on success or a negative error code.
  */
 int
@@ -242,7 +242,7 @@ gen_replace_estimator(struct gnet_stats_basic *bstats,
     gen_kill_estimator(bstats, rate_est);
     return gen_new_estimator(bstats, rate_est, stats_lock, opt);
 }
-    
+
 
 EXPORT_SYMBOL(gen_kill_estimator);
 EXPORT_SYMBOL(gen_new_estimator);
index 8f21490355fa5b45e64363e3e786a016bbfb238f..259473d0559d1ed713887c6a21f90181a1a1c5a5 100644 (file)
@@ -57,7 +57,7 @@ gnet_stats_start_copy_compat(struct sk_buff *skb, int type, int tc_stats_type,
        int xstats_type, spinlock_t *lock, struct gnet_dump *d)
 {
        memset(d, 0, sizeof(*d));
-       
+
        spin_lock_bh(lock);
        d->lock = lock;
        if (type)
index 04b249c40b5b24a12f0e24165621cc182b1ec1c4..4fb1cb9b79b9bf98233daef4088349a904dc1822 100644 (file)
@@ -40,7 +40,7 @@
 int verify_iovec(struct msghdr *m, struct iovec *iov, char *address, int mode)
 {
        int size, err, ct;
-       
+
        if (m->msg_namelen) {
                if (mode == VERIFY_READ) {
                        err = move_addr_to_kernel(m->msg_name, m->msg_namelen,
@@ -79,7 +79,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, char *address, int mode)
  *
  *     Note: this modifies the original iovec.
  */
+
 int memcpy_toiovec(struct iovec *iov, unsigned char *kdata, int len)
 {
        while (len > 0) {
@@ -103,7 +103,7 @@ int memcpy_toiovec(struct iovec *iov, unsigned char *kdata, int len)
  *
  *     Note: this modifies the original iovec.
  */
+
 int memcpy_fromiovec(unsigned char *kdata, struct iovec *iov, int len)
 {
        while (len > 0) {
@@ -209,7 +209,7 @@ int csum_partial_copy_fromiovecend(unsigned char *kdata, struct iovec *iov,
                        if (partial_cnt) {
                                copy -= partial_cnt;
                                if (copy_from_user(kdata + copy, base + copy,
-                                               partial_cnt))
+                                               partial_cnt))
                                        goto out_fault;
                        }
                }
@@ -224,7 +224,7 @@ int csum_partial_copy_fromiovecend(unsigned char *kdata, struct iovec *iov,
                kdata += copy + partial_cnt;
                iov++;
        }
-        *csump = csum;
+       *csump = csum;
 out:
        return err;
 
index 549a2ce951b04b01ccd8a316b10a51be33da148a..8b45c9d3b2490ce22bfdffd522dd5530439e8ca3 100644 (file)
@@ -124,7 +124,7 @@ void linkwatch_run_queue(void)
 
                dev_put(dev);
        }
-}       
+}
 
 
 static void linkwatch_event(struct work_struct *dummy)
@@ -133,7 +133,7 @@ static void linkwatch_event(struct work_struct *dummy)
         * per second so that a runaway driver does not
         * cause a storm of messages on the netlink
         * socket
-        */     
+        */
        linkwatch_nextevent = jiffies + HZ;
        clear_bit(LW_RUNNING, &linkwatch_flags);
 
index e7300b6b40795e5011fa26ad87f0ed2766823fe7..c08d69650566ed613b4ff706e6fab9014ab8a7b3 100644 (file)
@@ -251,12 +251,10 @@ static struct neighbour *neigh_alloc(struct neigh_table *tbl)
                        goto out_entries;
        }
 
-       n = kmem_cache_alloc(tbl->kmem_cachep, GFP_ATOMIC);
+       n = kmem_cache_zalloc(tbl->kmem_cachep, GFP_ATOMIC);
        if (!n)
                goto out_entries;
 
-       memset(n, 0, tbl->entry_size);
-
        skb_queue_head_init(&n->arp_queue);
        rwlock_init(&n->lock);
        n->updated        = n->used = now;
@@ -345,7 +343,7 @@ struct neighbour *neigh_lookup(struct neigh_table *tbl, const void *pkey,
        struct neighbour *n;
        int key_len = tbl->key_len;
        u32 hash_val = tbl->hash(pkey, dev);
-       
+
        NEIGH_CACHE_STAT_INC(tbl, lookups);
 
        read_lock_bh(&tbl->lock);
@@ -687,16 +685,19 @@ next_elt:
                np = &n->next;
        }
 
-       /* Cycle through all hash buckets every base_reachable_time/2 ticks.
-        * ARP entry timeouts range from 1/2 base_reachable_time to 3/2
-        * base_reachable_time.
+       /* Cycle through all hash buckets every base_reachable_time/2 ticks.
+        * ARP entry timeouts range from 1/2 base_reachable_time to 3/2
+        * base_reachable_time.
         */
        expire = tbl->parms.base_reachable_time >> 1;
        expire /= (tbl->hash_mask + 1);
        if (!expire)
                expire = 1;
 
-       mod_timer(&tbl->gc_timer, now + expire);
+       if (expire>HZ)
+               mod_timer(&tbl->gc_timer, round_jiffies(now + expire));
+       else
+               mod_timer(&tbl->gc_timer, now + expire);
 
        write_unlock(&tbl->lock);
 }
@@ -741,7 +742,7 @@ static void neigh_timer_handler(unsigned long arg)
        }
 
        if (state & NUD_REACHABLE) {
-               if (time_before_eq(now, 
+               if (time_before_eq(now,
                                   neigh->confirmed + neigh->parms->reachable_time)) {
                        NEIGH_PRINTK2("neigh %p is still alive.\n", neigh);
                        next = neigh->confirmed + neigh->parms->reachable_time;
@@ -760,7 +761,7 @@ static void neigh_timer_handler(unsigned long arg)
                        notify = 1;
                }
        } else if (state & NUD_DELAY) {
-               if (time_before_eq(now, 
+               if (time_before_eq(now,
                                   neigh->confirmed + neigh->parms->delay_probe_time)) {
                        NEIGH_PRINTK2("neigh %p is now reachable.\n", neigh);
                        neigh->nud_state = NUD_REACHABLE;
@@ -846,7 +847,7 @@ int __neigh_event_send(struct neighbour *neigh, struct sk_buff *skb)
                goto out_unlock_bh;
 
        now = jiffies;
-       
+
        if (!(neigh->nud_state & (NUD_STALE | NUD_INCOMPLETE))) {
                if (neigh->parms->mcast_probes + neigh->parms->app_probes) {
                        atomic_set(&neigh->probes, neigh->parms->ucast_probes);
@@ -914,13 +915,13 @@ static void neigh_update_hhs(struct neighbour *neigh)
        NEIGH_UPDATE_F_OVERRIDE allows to override existing lladdr,
                                if it is different.
        NEIGH_UPDATE_F_WEAK_OVERRIDE will suspect existing "connected"
-                               lladdr instead of overriding it 
+                               lladdr instead of overriding it
                                if it is different.
                                It also allows to retain current state
                                if lladdr is unchanged.
        NEIGH_UPDATE_F_ADMIN    means that the change is administrative.
 
-       NEIGH_UPDATE_F_OVERRIDE_ISROUTER allows to override existing 
+       NEIGH_UPDATE_F_OVERRIDE_ISROUTER allows to override existing
                                NTF_ROUTER flag.
        NEIGH_UPDATE_F_ISROUTER indicates if the neighbour is known as
                                a router.
@@ -943,7 +944,7 @@ int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new,
        old    = neigh->nud_state;
        err    = -EPERM;
 
-       if (!(flags & NEIGH_UPDATE_F_ADMIN) && 
+       if (!(flags & NEIGH_UPDATE_F_ADMIN) &&
            (old & (NUD_NOARP | NUD_PERMANENT)))
                goto out;
 
@@ -967,7 +968,7 @@ int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new,
                   - compare new & old
                   - if they are different, check override flag
                 */
-               if ((old & NUD_VALID) && 
+               if ((old & NUD_VALID) &&
                    !memcmp(lladdr, neigh->ha, dev->addr_len))
                        lladdr = neigh->ha;
        } else {
@@ -1011,8 +1012,8 @@ int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new,
                neigh_del_timer(neigh);
                if (new & NUD_IN_TIMER) {
                        neigh_hold(neigh);
-                       neigh_add_timer(neigh, (jiffies + 
-                                               ((new & NUD_REACHABLE) ? 
+                       neigh_add_timer(neigh, (jiffies +
+                                               ((new & NUD_REACHABLE) ?
                                                 neigh->parms->reachable_time :
                                                 0)));
                }
@@ -1074,7 +1075,7 @@ struct neighbour *neigh_event_ns(struct neigh_table *tbl,
        struct neighbour *neigh = __neigh_lookup(tbl, saddr, dev,
                                                 lladdr || !dev->addr_len);
        if (neigh)
-               neigh_update(neigh, lladdr, NUD_STALE, 
+               neigh_update(neigh, lladdr, NUD_STALE,
                             NEIGH_UPDATE_F_OVERRIDE);
        return neigh;
 }
@@ -1126,7 +1127,7 @@ int neigh_compat_output(struct sk_buff *skb)
 
        if (dev->hard_header &&
            dev->hard_header(skb, dev, ntohs(skb->protocol), NULL, NULL,
-                            skb->len) < 0 &&
+                            skb->len) < 0 &&
            dev->rebuild_header(skb))
                return 0;
 
@@ -1346,10 +1347,10 @@ void neigh_table_init_no_netlink(struct neigh_table *tbl)
        tbl->stats = alloc_percpu(struct neigh_statistics);
        if (!tbl->stats)
                panic("cannot create neighbour cache statistics");
-       
+
 #ifdef CONFIG_PROC_FS
        tbl->pde = create_proc_entry(tbl->id, 0, proc_net_stat);
-       if (!tbl->pde) 
+       if (!tbl->pde)
                panic("cannot create neighbour proc dir entry");
        tbl->pde->proc_fops = &neigh_stat_seq_fops;
        tbl->pde->data = tbl;
@@ -1564,7 +1565,7 @@ int neigh_add(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
                                err = -ENOENT;
                                goto out_dev_put;
                        }
-       
+
                        neigh = __neigh_lookup_errno(tbl, dst, dev);
                        if (IS_ERR(neigh)) {
                                err = PTR_ERR(neigh);
@@ -1637,7 +1638,7 @@ static int neightbl_fill_info(struct sk_buff *skb, struct neigh_table *tbl,
 
        nlh = nlmsg_put(skb, pid, seq, type, sizeof(*ndtmsg), flags);
        if (nlh == NULL)
-               return -ENOBUFS;
+               return -EMSGSIZE;
 
        ndtmsg = nlmsg_data(nlh);
 
@@ -1706,7 +1707,8 @@ static int neightbl_fill_info(struct sk_buff *skb, struct neigh_table *tbl,
 
 nla_put_failure:
        read_unlock_bh(&tbl->lock);
-       return nlmsg_cancel(skb, nlh);
+       nlmsg_cancel(skb, nlh);
+       return -EMSGSIZE;
 }
 
 static int neightbl_fill_param_info(struct sk_buff *skb,
@@ -1720,7 +1722,7 @@ static int neightbl_fill_param_info(struct sk_buff *skb,
 
        nlh = nlmsg_put(skb, pid, seq, type, sizeof(*ndtmsg), flags);
        if (nlh == NULL)
-               return -ENOBUFS;
+               return -EMSGSIZE;
 
        ndtmsg = nlmsg_data(nlh);
 
@@ -1737,14 +1739,15 @@ static int neightbl_fill_param_info(struct sk_buff *skb,
        return nlmsg_end(skb, nlh);
 errout:
        read_unlock_bh(&tbl->lock);
-       return nlmsg_cancel(skb, nlh);
+       nlmsg_cancel(skb, nlh);
+       return -EMSGSIZE;
 }
+
 static inline struct neigh_parms *lookup_neigh_params(struct neigh_table *tbl,
                                                      int ifindex)
 {
        struct neigh_parms *p;
-       
+
        for (p = &tbl->parms; p; p = p->next)
                if ((p->dev && p->dev->ifindex == ifindex) ||
                    (!p->dev && !ifindex))
@@ -1810,7 +1813,7 @@ int neightbl_set(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
                goto errout_locked;
        }
 
-       /* 
+       /*
         * We acquire tbl->lock to be nice to the periodic timers and
         * make sure they always see a consistent set of values.
         */
@@ -1955,7 +1958,7 @@ static int neigh_fill_info(struct sk_buff *skb, struct neighbour *neigh,
 
        nlh = nlmsg_put(skb, pid, seq, type, sizeof(*ndm), flags);
        if (nlh == NULL)
-               return -ENOBUFS;
+               return -EMSGSIZE;
 
        ndm = nlmsg_data(nlh);
        ndm->ndm_family  = neigh->ops->family;
@@ -1987,7 +1990,8 @@ static int neigh_fill_info(struct sk_buff *skb, struct neighbour *neigh,
        return nlmsg_end(skb, nlh);
 
 nla_put_failure:
-       return nlmsg_cancel(skb, nlh);
+       nlmsg_cancel(skb, nlh);
+       return -EMSGSIZE;
 }
 
 
@@ -2317,7 +2321,7 @@ static void *neigh_stat_seq_start(struct seq_file *seq, loff_t *pos)
 
        if (*pos == 0)
                return SEQ_START_TOKEN;
-       
+
        for (cpu = *pos-1; cpu < NR_CPUS; ++cpu) {
                if (!cpu_possible(cpu))
                        continue;
@@ -2429,9 +2433,12 @@ static void __neigh_notify(struct neighbour *n, int type, int flags)
                goto errout;
 
        err = neigh_fill_info(skb, n, 0, 0, type, flags);
-       /* failure implies BUG in neigh_nlmsg_size() */
-       BUG_ON(err < 0);
-
+       if (err < 0) {
+               /* -EMSGSIZE implies BUG in neigh_nlmsg_size() */
+               WARN_ON(err == -EMSGSIZE);
+               kfree_skb(skb);
+               goto errout;
+       }
        err = rtnl_notify(skb, 0, RTNLGRP_NEIGH, NULL, GFP_ATOMIC);
 errout:
        if (err < 0)
@@ -2622,7 +2629,7 @@ static struct neigh_sysctl_table {
 };
 
 int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p,
-                         int p_id, int pdev_id, char *p_name, 
+                         int p_id, int pdev_id, char *p_name,
                          proc_handler *handler, ctl_handler *strategy)
 {
        struct neigh_sysctl_table *t = kmemdup(&neigh_sysctl_template,
@@ -2654,7 +2661,7 @@ int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p,
                t->neigh_vars[14].procname = NULL;
                t->neigh_vars[15].procname = NULL;
        } else {
-               dev_name_source = t->neigh_dev[0].procname;
+               dev_name_source = t->neigh_dev[0].procname;
                t->neigh_vars[12].data = (int *)(p + 1);
                t->neigh_vars[13].data = (int *)(p + 1) + 1;
                t->neigh_vars[14].data = (int *)(p + 1) + 2;
@@ -2689,7 +2696,7 @@ int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p,
                goto free;
        }
 
-       t->neigh_dev[0].procname = dev_name;
+       t->neigh_dev[0].procname = dev_name;
 
        t->neigh_neigh_dir[0].ctl_name = pdev_id;
 
index 44db095a8f7e9f4e404f616c4837edc019408060..6189dc03108d2da67aad2a155a3d53011a30daa0 100644 (file)
@@ -2,7 +2,7 @@
  * net-sysfs.c - network device class and attributes
  *
  * Copyright (c) 2003 Stephen Hemminger <shemminger@osdl.org>
- * 
+ *
  *     This program is free software; you can redistribute it and/or
  *     modify it under the terms of the GNU General Public License
  *     as published by the Free Software Foundation; either version
@@ -23,7 +23,7 @@ static const char fmt_long_hex[] = "%#lx\n";
 static const char fmt_dec[] = "%d\n";
 static const char fmt_ulong[] = "%lu\n";
 
-static inline int dev_isalive(const struct net_device *dev) 
+static inline int dev_isalive(const struct net_device *dev)
 {
        return dev->reg_state <= NETREG_REGISTERED;
 }
@@ -265,7 +265,7 @@ static ssize_t netstat_show(const struct device *d,
 
        read_lock(&dev_base_lock);
        if (dev_isalive(dev) && dev->get_stats &&
-           (stats = (*dev->get_stats)(dev))) 
+           (stats = (*dev->get_stats)(dev)))
                ret = sprintf(buf, fmt_ulong,
                              *(unsigned long *)(((u8 *) stats) + offset));
 
@@ -349,7 +349,7 @@ static ssize_t wireless_show(struct device *d, char *buf,
        struct net_device *dev = to_net_dev(d);
        const struct iw_statistics *iw = NULL;
        ssize_t ret = -EINVAL;
-       
+
        read_lock(&dev_base_lock);
        if (dev_isalive(dev)) {
                if(dev->wireless_handlers &&
@@ -430,7 +430,7 @@ static int netdev_uevent(struct device *d, char **envp,
 #endif
 
 /*
- *     netdev_release -- destroy and free a dead device. 
+ *     netdev_release -- destroy and free a dead device.
  *     Called when last reference to device kobject is gone.
  */
 static void netdev_release(struct device *d)
index 823215d8e90f6411b6e6fb94ba1ecd9bcae2f6f1..da1019451ccbe68185af1db8b7db3bb30a305c8f 100644 (file)
@@ -237,13 +237,13 @@ static void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)
 {
        int status = NETDEV_TX_BUSY;
        unsigned long tries;
-       struct net_device *dev = np->dev;
-       struct netpoll_info *npinfo = np->dev->npinfo;
+       struct net_device *dev = np->dev;
+       struct netpoll_info *npinfo = np->dev->npinfo;
 
-       if (!npinfo || !netif_running(dev) || !netif_device_present(dev)) {
-               __kfree_skb(skb);
-               return;
-       }
+       if (!npinfo || !netif_running(dev) || !netif_device_present(dev)) {
+               __kfree_skb(skb);
+               return;
+       }
 
        /* don't get messages out of order, and no recursion */
        if (skb_queue_len(&npinfo->txq) == 0 &&
@@ -676,7 +676,7 @@ int netpoll_setup(struct netpoll *np)
                }
 
                atleast = jiffies + HZ/10;
-               atmost = jiffies + 4*HZ;
+               atmost = jiffies + 4*HZ;
                while (!netif_carrier_ok(ndev)) {
                        if (time_after(jiffies, atmost)) {
                                printk(KERN_NOTICE
@@ -772,9 +772,9 @@ void netpoll_cleanup(struct netpoll *np)
                        np->dev->npinfo = NULL;
                        if (atomic_dec_and_test(&npinfo->refcnt)) {
                                skb_queue_purge(&npinfo->arp_tx);
-                               skb_queue_purge(&npinfo->txq);
+                               skb_queue_purge(&npinfo->txq);
                                cancel_rearming_delayed_work(&npinfo->tx_work);
-                               flush_scheduled_work();
+                               flush_scheduled_work();
 
                                kfree(npinfo);
                        }
index 04d4b93c68eb0b226cdd7c0a4385402d6be27aa9..c2818e07a4bd7b18c1fedfe7c194927bd780bb0a 100644 (file)
@@ -15,7 +15,7 @@
  *
  *
  * A tool for loading the network with preconfigurated packets.
- * The tool is implemented as a linux module.  Parameters are output 
+ * The tool is implemented as a linux module.  Parameters are output
  * device, delay (to hard_xmit), number of packets, and whether
  * to use multiple SKBs or just the same one.
  * pktgen uses the installed interface's output routine.
  *   *  Add IOCTL interface to easily get counters & configuration.
  *   --Ben Greear <greearb@candelatech.com>
  *
- * Renamed multiskb to clone_skb and cleaned up sending core for two distinct 
- * skb modes. A clone_skb=0 mode for Ben "ranges" work and a clone_skb != 0 
+ * Renamed multiskb to clone_skb and cleaned up sending core for two distinct
+ * skb modes. A clone_skb=0 mode for Ben "ranges" work and a clone_skb != 0
  * as a "fastpath" with a configurable number of clones after alloc's.
- * clone_skb=0 means all packets are allocated this also means ranges time 
- * stamps etc can be used. clone_skb=100 means 1 malloc is followed by 100 
+ * clone_skb=0 means all packets are allocated this also means ranges time
+ * stamps etc can be used. clone_skb=100 means 1 malloc is followed by 100
  * clones.
  *
- * Also moved to /proc/net/pktgen/ 
+ * Also moved to /proc/net/pktgen/
  * --ro
  *
  * Sept 10:  Fixed threading/locking.  Lots of bone-headed and more clever
  *
  * Integrated to 2.5.x 021029 --Lucio Maciel (luciomaciel@zipmail.com.br)
  *
- * 
+ *
  * 021124 Finished major redesign and rewrite for new functionality.
  * See Documentation/networking/pktgen.txt for how to use this.
  *
  * The new operation:
- * For each CPU one thread/process is created at start. This process checks 
- * for running devices in the if_list and sends packets until count is 0 it 
- * also the thread checks the thread->control which is used for inter-process 
- * communication. controlling process "posts" operations to the threads this 
+ * For each CPU one thread/process is created at start. This process checks
+ * for running devices in the if_list and sends packets until count is 0 it
+ * also the thread checks the thread->control which is used for inter-process
+ * communication. controlling process "posts" operations to the threads this
  * way. The if_lock should be possible to remove when add/rem_device is merged
  * into this too.
  *
- * By design there should only be *one* "controlling" process. In practice 
- * multiple write accesses gives unpredictable result. Understood by "write" 
+ * By design there should only be *one* "controlling" process. In practice
+ * multiple write accesses gives unpredictable result. Understood by "write"
  * to /proc gives result code thats should be read be the "writer".
  * For practical use this should be no problem.
  *
- * Note when adding devices to a specific CPU there good idea to also assign 
- * /proc/irq/XX/smp_affinity so TX-interrupts gets bound to the same CPU. 
+ * Note when adding devices to a specific CPU there good idea to also assign
+ * /proc/irq/XX/smp_affinity so TX-interrupts gets bound to the same CPU.
  * --ro
  *
- * Fix refcount off by one if first packet fails, potential null deref, 
+ * Fix refcount off by one if first packet fails, potential null deref,
  * memleak 030710- KJP
  *
  * First "ranges" functionality for ipv6 030726 --ro
  * Included flow support. 030802 ANK.
  *
  * Fixed unaligned access on IA-64 Grant Grundler <grundler@parisc-linux.org>
- * 
+ *
  * Remove if fix from added Harald Welte <laforge@netfilter.org> 040419
  * ia64 compilation fix from  Aron Griffis <aron@hp.com> 040604
  *
- * New xmit() return, do_div and misc clean up by Stephen Hemminger 
+ * New xmit() return, do_div and misc clean up by Stephen Hemminger
  * <shemminger@osdl.org> 040923
  *
- * Randy Dunlap fixed u64 printk compiler waring 
+ * Randy Dunlap fixed u64 printk compiler waring
  *
  * Remove FCS from BW calculation.  Lennert Buytenhek <buytenh@wantstofly.org>
  * New time handling. Lennert Buytenhek <buytenh@wantstofly.org> 041213
  *
- * Corrections from Nikolai Malykh (nmalykh@bilim.com) 
+ * Corrections from Nikolai Malykh (nmalykh@bilim.com)
  * Removed unused flags F_SET_SRCMAC & F_SET_SRCIP 041230
  *
- * interruptible_sleep_on_timeout() replaced Nishanth Aravamudan <nacc@us.ibm.com> 
+ * interruptible_sleep_on_timeout() replaced Nishanth Aravamudan <nacc@us.ibm.com>
  * 050103
  *
  * MPLS support by Steven Whitehouse <steve@chygwyn.com>
@@ -456,7 +456,7 @@ static inline __u64 pg_div64(__u64 n, __u64 base)
 /*
  * How do we know if the architecture we are running on
  * supports division with 64 bit base?
- * 
+ *
  */
 #if defined(__sparc_v9__) || defined(__powerpc64__) || defined(__alpha__) || defined(__x86_64__) || defined(__ia64__)
 
@@ -529,7 +529,7 @@ static struct notifier_block pktgen_notifier_block = {
 };
 
 /*
- * /proc handling functions 
+ * /proc handling functions
  *
  */
 
@@ -1979,7 +1979,7 @@ static void pktgen_setup_inject(struct pktgen_dev *pkt_dev)
 
        if (pkt_dev->flags & F_IPV6) {
                /*
-                * Skip this automatic address setting until locks or functions 
+                * Skip this automatic address setting until locks or functions
                 * gets exported
                 */
 
@@ -2477,10 +2477,10 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev,
 }
 
 /*
- * scan_ip6, fmt_ip taken from dietlibc-0.21 
+ * scan_ip6, fmt_ip taken from dietlibc-0.21
  * Author Felix von Leitner <felix-dietlibc@fefe.de>
  *
- * Slightly modified for kernel. 
+ * Slightly modified for kernel.
  * Should be candidate for net/ipv4/utils.c
  * --ro
  */
@@ -3256,7 +3256,7 @@ static __inline__ void pktgen_xmit(struct pktgen_dev *pkt_dev)
 out:;
 }
 
-/* 
+/*
  * Main loop of the thread goes here
  */
 
@@ -3365,8 +3365,8 @@ static struct pktgen_dev *pktgen_find_dev(struct pktgen_thread *t,
        return pkt_dev;
 }
 
-/* 
- * Adds a dev at front of if_list. 
+/*
+ * Adds a dev at front of if_list.
  */
 
 static int add_dev_to_thread(struct pktgen_thread *t,
@@ -3510,8 +3510,8 @@ static int __init pktgen_create_thread(int cpu)
        return 0;
 }
 
-/* 
- * Removes a device from the thread if_list. 
+/*
+ * Removes a device from the thread if_list.
  */
 static void _rem_dev_from_if_list(struct pktgen_thread *t,
                                  struct pktgen_dev *pkt_dev)
index e76539a5eb5e09e79939fef2e4d96bd9449c1a7b..ee5a787271f6fa0afaa18b6cc23e9fe96ff55224 100644 (file)
@@ -320,7 +320,7 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
 
        nlh = nlmsg_put(skb, pid, seq, type, sizeof(*ifm), flags);
        if (nlh == NULL)
-               return -ENOBUFS;
+               return -EMSGSIZE;
 
        ifm = nlmsg_data(nlh);
        ifm->ifi_family = AF_UNSPEC;
@@ -384,7 +384,8 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
        return nlmsg_end(skb, nlh);
 
 nla_put_failure:
-       return nlmsg_cancel(skb, nlh);
+       nlmsg_cancel(skb, nlh);
+       return -EMSGSIZE;
 }
 
 static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
@@ -633,9 +634,12 @@ static int rtnl_getlink(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
 
        err = rtnl_fill_ifinfo(nskb, dev, iw, iw_buf_len, RTM_NEWLINK,
                               NETLINK_CB(skb).pid, nlh->nlmsg_seq, 0, 0);
-       /* failure impilies BUG in if_nlmsg_size or wireless_rtnetlink_get */
-       BUG_ON(err < 0);
-
+       if (err < 0) {
+               /* -EMSGSIZE implies BUG in if_nlmsg_size */
+               WARN_ON(err == -EMSGSIZE);
+               kfree_skb(nskb);
+               goto errout;
+       }
        err = rtnl_unicast(nskb, NETLINK_CB(skb).pid);
 errout:
        kfree(iw_buf);
@@ -678,9 +682,12 @@ void rtmsg_ifinfo(int type, struct net_device *dev, unsigned change)
                goto errout;
 
        err = rtnl_fill_ifinfo(skb, dev, NULL, 0, type, 0, 0, change, 0);
-       /* failure implies BUG in if_nlmsg_size() */
-       BUG_ON(err < 0);
-
+       if (err < 0) {
+               /* -EMSGSIZE implies BUG in if_nlmsg_size() */
+               WARN_ON(err == -EMSGSIZE);
+               kfree_skb(skb);
+               goto errout;
+       }
        err = rtnl_notify(skb, 0, RTNLGRP_LINK, NULL, GFP_KERNEL);
 errout:
        if (err < 0)
@@ -867,7 +874,7 @@ void __init rtnetlink_init(void)
                panic("rtnetlink_init: cannot allocate rta_buf\n");
 
        rtnl = netlink_kernel_create(NETLINK_ROUTE, RTNLGRP_MAX, rtnetlink_rcv,
-                                    THIS_MODULE);
+                                    THIS_MODULE);
        if (rtnl == NULL)
                panic("rtnetlink_init: cannot initialize rtnetlink\n");
        netlink_set_nonroot(NETLINK_ROUTE, NL_NONROOT_RECV);
index 271cf060ef8c69fb79f37768972af65b5457d835..292ad8d5ad76262c46fc33248376cd0401658722 100644 (file)
@@ -36,7 +36,7 @@
 
 
 /*
- *     Only allow a user to send credentials, that they could set with 
+ *     Only allow a user to send credentials, that they could set with
  *     setu(g)id.
  */
 
@@ -79,11 +79,11 @@ static int scm_fp_copy(struct cmsghdr *cmsg, struct scm_fp_list **fplp)
 
        if (fpl->count + num > SCM_MAX_FD)
                return -EINVAL;
-       
+
        /*
         *      Verify the descriptors and increment the usage count.
         */
-        
+
        for (i=0; i< num; i++)
        {
                int fd = fdp[i];
@@ -123,7 +123,7 @@ int __scm_send(struct socket *sock, struct msghdr *msg, struct scm_cookie *p)
                /* The first check was omitted in <= 2.2.5. The reasoning was
                   that parser checks cmsg_len in any case, so that
                   additional check would be work duplication.
-                  But if cmsg_level is not SOL_SOCKET, we do not check 
+                  But if cmsg_level is not SOL_SOCKET, we do not check
                   for too short ancillary data object at all! Oops.
                   OK, let's add it...
                 */
@@ -159,7 +159,7 @@ int __scm_send(struct socket *sock, struct msghdr *msg, struct scm_cookie *p)
                p->fp = NULL;
        }
        return 0;
-       
+
 error:
        scm_destroy(p);
        return err;
@@ -189,7 +189,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
 
        err = -EFAULT;
        if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
-               goto out; 
+               goto out;
        if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
                goto out;
        cmlen = CMSG_SPACE(len);
index f3404ae9f190713a547211ae6cc035f374c03068..3d5646869022240ea2136843a17c2fa76e115750 100644 (file)
@@ -88,7 +88,7 @@ static struct kmem_cache *skbuff_fclone_cache __read_mostly;
 void skb_over_panic(struct sk_buff *skb, int sz, void *here)
 {
        printk(KERN_EMERG "skb_over_panic: text:%p len:%d put:%d head:%p "
-                         "data:%p tail:%p end:%p dev:%s\n",
+                         "data:%p tail:%p end:%p dev:%s\n",
               here, skb->len, sz, skb->head, skb->data, skb->tail, skb->end,
               skb->dev ? skb->dev->name : "<NULL>");
        BUG();
@@ -106,7 +106,7 @@ void skb_over_panic(struct sk_buff *skb, int sz, void *here)
 void skb_under_panic(struct sk_buff *skb, int sz, void *here)
 {
        printk(KERN_EMERG "skb_under_panic: text:%p len:%d put:%d head:%p "
-                         "data:%p tail:%p end:%p dev:%s\n",
+                         "data:%p tail:%p end:%p dev:%s\n",
               here, skb->len, sz, skb->head, skb->data, skb->tail, skb->end,
               skb->dev ? skb->dev->name : "<NULL>");
        BUG();
@@ -271,7 +271,7 @@ struct sk_buff *__netdev_alloc_skb(struct net_device *dev,
        int node = dev->dev.parent ? dev_to_node(dev->dev.parent) : -1;
        struct sk_buff *skb;
 
-       skb = __alloc_skb(length + NET_SKB_PAD, gfp_mask, 0, node);
+       skb = __alloc_skb(length + NET_SKB_PAD, gfp_mask, 0, node);
        if (likely(skb)) {
                skb_reserve(skb, NET_SKB_PAD);
                skb->dev = dev;
@@ -819,12 +819,12 @@ struct sk_buff *skb_copy_expand(const struct sk_buff *skb,
  *
  *     May return error in out of memory cases. The skb is freed on error.
  */
+
 int skb_pad(struct sk_buff *skb, int pad)
 {
        int err;
        int ntail;
-       
+
        /* If the skbuff is non linear tailroom is always zero.. */
        if (!skb_cloned(skb) && skb_tailroom(skb) >= pad) {
                memset(skb->data+skb->len, 0, pad);
@@ -851,8 +851,8 @@ int skb_pad(struct sk_buff *skb, int pad)
 free_skb:
        kfree_skb(skb);
        return err;
-}      
+}
+
 /* Trims skb to length len. It can change skb pointers.
  */
 
index 0ed5b4f0bc407aef5b376149dcc2d49aa3c49937..1e35d9973f570c1835a1ecef395b69804dcc3f2f 100644 (file)
@@ -34,7 +34,7 @@
  *             Alan Cox        :       TCP ack handling is buggy, the DESTROY timer
  *                                     was buggy. Put a remove_sock() in the handler
  *                                     for memory when we hit 0. Also altered the timer
- *                                     code. The ACK stuff can wait and needs major 
+ *                                     code. The ACK stuff can wait and needs major
  *                                     TCP layer surgery.
  *             Alan Cox        :       Fixed TCP ack bug, removed remove sock
  *                                     and fixed timer/inet_bh race.
@@ -217,8 +217,8 @@ static void sock_warn_obsolete_bsdism(const char *name)
 {
        static int warned;
        static char warncomm[TASK_COMM_LEN];
-       if (strcmp(warncomm, current->comm) && warned < 5) { 
-               strcpy(warncomm,  current->comm); 
+       if (strcmp(warncomm, current->comm) && warned < 5) {
+               strcpy(warncomm,  current->comm);
                printk(KERN_WARNING "process `%s' is using obsolete "
                       "%s SO_BSDCOMPAT\n", warncomm, name);
                warned++;
@@ -226,8 +226,8 @@ static void sock_warn_obsolete_bsdism(const char *name)
 }
 
 static void sock_disable_timestamp(struct sock *sk)
-{      
-       if (sock_flag(sk, SOCK_TIMESTAMP)) { 
+{
+       if (sock_flag(sk, SOCK_TIMESTAMP)) {
                sock_reset_flag(sk, SOCK_TIMESTAMP);
                net_disable_timestamp();
        }
@@ -347,7 +347,7 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
        int valbool;
        struct linger ling;
        int ret = 0;
-       
+
        /*
         *      Options without arguments
         */
@@ -360,20 +360,20 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
                return 0;
        }
 #endif
-       
-       if(optlen<sizeof(int))
-               return(-EINVAL);
-       
+
+       if(optlen<sizeof(int))
+               return(-EINVAL);
+
        if (get_user(val, (int __user *)optval))
                return -EFAULT;
-       
-       valbool = val?1:0;
+
+       valbool = val?1:0;
 
        lock_sock(sk);
 
-       switch(optname) 
-       {
-               case SO_DEBUG:  
+       switch(optname)
+       {
+               case SO_DEBUG:
                        if(val && !capable(CAP_NET_ADMIN))
                        {
                                ret = -EACCES;
@@ -389,7 +389,7 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
                case SO_TYPE:
                case SO_ERROR:
                        ret = -ENOPROTOOPT;
-                       break;
+                       break;
                case SO_DONTROUTE:
                        if (valbool)
                                sock_set_flag(sk, SOCK_LOCALROUTE);
@@ -404,7 +404,7 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
                           about it this is right. Otherwise apps have to
                           play 'guess the biggest size' games. RCVBUF/SNDBUF
                           are treated in BSD as hints */
-                          
+
                        if (val > sysctl_wmem_max)
                                val = sysctl_wmem_max;
 set_sndbuf:
@@ -433,7 +433,7 @@ set_sndbuf:
                           about it this is right. Otherwise apps have to
                           play 'guess the biggest size' games. RCVBUF/SNDBUF
                           are treated in BSD as hints */
-                         
+
                        if (val > sysctl_rmem_max)
                                val = sysctl_rmem_max;
 set_rcvbuf:
@@ -474,16 +474,16 @@ set_rcvbuf:
                        sock_valbool_flag(sk, SOCK_KEEPOPEN, valbool);
                        break;
 
-               case SO_OOBINLINE:
+               case SO_OOBINLINE:
                        sock_valbool_flag(sk, SOCK_URGINLINE, valbool);
                        break;
 
-               case SO_NO_CHECK:
+               case SO_NO_CHECK:
                        sk->sk_no_check = valbool;
                        break;
 
                case SO_PRIORITY:
-                       if ((val >= 0 && val <= 6) || capable(CAP_NET_ADMIN)) 
+                       if ((val >= 0 && val <= 6) || capable(CAP_NET_ADMIN))
                                sk->sk_priority = val;
                        else
                                ret = -EPERM;
@@ -547,9 +547,9 @@ set_rcvbuf:
 #ifdef CONFIG_NETDEVICES
                case SO_BINDTODEVICE:
                {
-                       char devname[IFNAMSIZ]; 
+                       char devname[IFNAMSIZ];
 
-                       /* Sorry... */ 
+                       /* Sorry... */
                        if (!capable(CAP_NET_RAW)) {
                                ret = -EPERM;
                                break;
@@ -557,9 +557,9 @@ set_rcvbuf:
 
                        /* Bind this socket to a particular device like "eth0",
                         * as specified in the passed interface name. If the
-                        * name is "" or the option length is zero the socket 
-                        * is not bound. 
-                        */ 
+                        * name is "" or the option length is zero the socket
+                        * is not bound.
+                        */
 
                        if (!valbool) {
                                sk->sk_bound_dev_if = 0;
@@ -608,7 +608,7 @@ set_rcvbuf:
                case SO_DETACH_FILTER:
                        rcu_read_lock_bh();
                        filter = rcu_dereference(sk->sk_filter);
-                        if (filter) {
+                       if (filter) {
                                rcu_assign_pointer(sk->sk_filter, NULL);
                                sk_filter_release(sk, filter);
                                rcu_read_unlock_bh();
@@ -628,9 +628,9 @@ set_rcvbuf:
                /* We implement the SO_SNDLOWAT etc to
                   not be settable (1003.1g 5.3) */
                default:
-                       ret = -ENOPROTOOPT;
+                       ret = -ENOPROTOOPT;
                        break;
-       }
+       }
        release_sock(sk);
        return ret;
 }
@@ -640,32 +640,32 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
                    char __user *optval, int __user *optlen)
 {
        struct sock *sk = sock->sk;
-       
+
        union
        {
-               int val;
-               struct linger ling;
+               int val;
+               struct linger ling;
                struct timeval tm;
        } v;
-       
+
        unsigned int lv = sizeof(int);
        int len;
-       
-       if(get_user(len,optlen))
-               return -EFAULT;
+
+       if(get_user(len,optlen))
+               return -EFAULT;
        if(len < 0)
                return -EINVAL;
-               
-       switch(optname) 
-       {
-               case SO_DEBUG:          
+
+       switch(optname)
+       {
+               case SO_DEBUG:
                        v.val = sock_flag(sk, SOCK_DBG);
                        break;
-               
+
                case SO_DONTROUTE:
                        v.val = sock_flag(sk, SOCK_LOCALROUTE);
                        break;
-               
+
                case SO_BROADCAST:
                        v.val = !!sock_flag(sk, SOCK_BROADCAST);
                        break;
@@ -673,7 +673,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
                case SO_SNDBUF:
                        v.val = sk->sk_sndbuf;
                        break;
-               
+
                case SO_RCVBUF:
                        v.val = sk->sk_rcvbuf;
                        break;
@@ -687,7 +687,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
                        break;
 
                case SO_TYPE:
-                       v.val = sk->sk_type;                            
+                       v.val = sk->sk_type;
                        break;
 
                case SO_ERROR:
@@ -699,7 +699,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
                case SO_OOBINLINE:
                        v.val = !!sock_flag(sk, SOCK_URGINLINE);
                        break;
-       
+
                case SO_NO_CHECK:
                        v.val = sk->sk_no_check;
                        break;
@@ -707,13 +707,13 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
                case SO_PRIORITY:
                        v.val = sk->sk_priority;
                        break;
-               
-               case SO_LINGER: 
+
+               case SO_LINGER:
                        lv              = sizeof(v.ling);
                        v.ling.l_onoff  = !!sock_flag(sk, SOCK_LINGER);
-                       v.ling.l_linger = sk->sk_lingertime / HZ;
+                       v.ling.l_linger = sk->sk_lingertime / HZ;
                        break;
-                                       
+
                case SO_BSDCOMPAT:
                        sock_warn_obsolete_bsdism("getsockopt");
                        break;
@@ -750,7 +750,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
 
                case SO_SNDLOWAT:
                        v.val=1;
-                       break; 
+                       break;
 
                case SO_PASSCRED:
                        v.val = test_bit(SOCK_PASSCRED, &sock->flags) ? 1 : 0;
@@ -798,9 +798,9 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
        if (copy_to_user(optval, &v, len))
                return -EFAULT;
 lenout:
-       if (put_user(len, optlen))
-               return -EFAULT;
-       return 0;
+       if (put_user(len, optlen))
+               return -EFAULT;
+       return 0;
 }
 
 /*
@@ -846,7 +846,7 @@ struct sock *sk_alloc(int family, gfp_t priority,
                        sk->sk_prot = sk->sk_prot_creator = prot;
                        sock_lock_init(sk);
                }
-               
+
                if (security_sk_alloc(sk, family, priority))
                        goto out_free;
 
@@ -988,8 +988,8 @@ void __init sk_init(void)
  */
 
 
-/* 
- * Write buffer destructor automatically called from kfree_skb. 
+/*
+ * Write buffer destructor automatically called from kfree_skb.
  */
 void sock_wfree(struct sk_buff *skb)
 {
@@ -1002,8 +1002,8 @@ void sock_wfree(struct sk_buff *skb)
        sock_put(sk);
 }
 
-/* 
- * Read buffer destructor automatically called from kfree_skb. 
+/*
+ * Read buffer destructor automatically called from kfree_skb.
  */
 void sock_rfree(struct sk_buff *skb)
 {
@@ -1051,7 +1051,7 @@ struct sk_buff *sock_wmalloc(struct sock *sk, unsigned long size, int force,
 
 /*
  * Allocate a skb from the socket's receive buffer.
- */ 
+ */
 struct sk_buff *sock_rmalloc(struct sock *sk, unsigned long size, int force,
                             gfp_t priority)
 {
@@ -1065,16 +1065,16 @@ struct sk_buff *sock_rmalloc(struct sock *sk, unsigned long size, int force,
        return NULL;
 }
 
-/* 
+/*
  * Allocate a memory block from the socket's option memory buffer.
- */ 
+ */
 void *sock_kmalloc(struct sock *sk, int size, gfp_t priority)
 {
        if ((unsigned)size <= sysctl_optmem_max &&
            atomic_read(&sk->sk_omem_alloc) + size < sysctl_optmem_max) {
                void *mem;
                /* First do the add, to avoid the race if kmalloc
-                * might sleep.
+                * might sleep.
                 */
                atomic_add(size, &sk->sk_omem_alloc);
                mem = kmalloc(size, priority);
@@ -1210,7 +1210,7 @@ failure:
        return NULL;
 }
 
-struct sk_buff *sock_alloc_send_skb(struct sock *sk, unsigned long size, 
+struct sk_buff *sock_alloc_send_skb(struct sock *sk, unsigned long size,
                                    int noblock, int *errcode)
 {
        return sock_alloc_send_pskb(sk, size, 0, noblock, errcode);
@@ -1298,7 +1298,7 @@ int sock_no_bind(struct socket *sock, struct sockaddr *saddr, int len)
        return -EOPNOTSUPP;
 }
 
-int sock_no_connect(struct socket *sock, struct sockaddr *saddr, 
+int sock_no_connect(struct socket *sock, struct sockaddr *saddr,
                    int len, int flags)
 {
        return -EOPNOTSUPP;
@@ -1314,7 +1314,7 @@ int sock_no_accept(struct socket *sock, struct socket *newsock, int flags)
        return -EOPNOTSUPP;
 }
 
-int sock_no_getname(struct socket *sock, struct sockaddr *saddr, 
+int sock_no_getname(struct socket *sock, struct sockaddr *saddr,
                    int *len, int peer)
 {
        return -EOPNOTSUPP;
@@ -1400,7 +1400,7 @@ static void sock_def_error_report(struct sock *sk)
        read_lock(&sk->sk_callback_lock);
        if (sk->sk_sleep && waitqueue_active(sk->sk_sleep))
                wake_up_interruptible(sk->sk_sleep);
-       sk_wake_async(sk,0,POLL_ERR); 
+       sk_wake_async(sk,0,POLL_ERR);
        read_unlock(&sk->sk_callback_lock);
 }
 
@@ -1473,7 +1473,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
        sk->sk_send_head        =       NULL;
 
        init_timer(&sk->sk_timer);
-       
+
        sk->sk_allocation       =       GFP_KERNEL;
        sk->sk_rcvbuf           =       sysctl_rmem_default;
        sk->sk_sndbuf           =       sysctl_wmem_default;
@@ -1553,26 +1553,26 @@ void fastcall release_sock(struct sock *sk)
 EXPORT_SYMBOL(release_sock);
 
 int sock_get_timestamp(struct sock *sk, struct timeval __user *userstamp)
-{ 
+{
        if (!sock_flag(sk, SOCK_TIMESTAMP))
                sock_enable_timestamp(sk);
-       if (sk->sk_stamp.tv_sec == -1) 
+       if (sk->sk_stamp.tv_sec == -1)
                return -ENOENT;
        if (sk->sk_stamp.tv_sec == 0)
                do_gettimeofday(&sk->sk_stamp);
        return copy_to_user(userstamp, &sk->sk_stamp, sizeof(struct timeval)) ?
-               -EFAULT : 0; 
-} 
+               -EFAULT : 0;
+}
 EXPORT_SYMBOL(sock_get_timestamp);
 
 void sock_enable_timestamp(struct sock *sk)
-{      
-       if (!sock_flag(sk, SOCK_TIMESTAMP)) { 
+{
+       if (!sock_flag(sk, SOCK_TIMESTAMP)) {
                sock_set_flag(sk, SOCK_TIMESTAMP);
                net_enable_timestamp();
        }
 }
-EXPORT_SYMBOL(sock_enable_timestamp); 
+EXPORT_SYMBOL(sock_enable_timestamp);
 
 /*
  *     Get a socket option on an socket.
index d1d7decf70b0087af2de9358049e5e43ed46d326..755bacbcb321c296a45c5d53ae872469674aa4a8 100644 (file)
@@ -69,7 +69,7 @@ int sk_stream_wait_connect(struct sock *sk, long *timeo_p)
                sk->sk_write_pending++;
                done = sk_wait_event(sk, timeo_p,
                                     !sk->sk_err &&
-                                    !((1 << sk->sk_state) & 
+                                    !((1 << sk->sk_state) &
                                       ~(TCPF_ESTABLISHED | TCPF_CLOSE_WAIT)));
                finish_wait(sk->sk_sleep, &wait);
                sk->sk_write_pending--;
@@ -139,7 +139,7 @@ int sk_stream_wait_memory(struct sock *sk, long *timeo_p)
 
                set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
                sk->sk_write_pending++;
-               sk_wait_event(sk, &current_timeo, !sk->sk_err && 
+               sk_wait_event(sk, &current_timeo, !sk->sk_err &&
                                                  !(sk->sk_shutdown & SEND_SHUTDOWN) &&
                                                  sk_stream_memory_free(sk) &&
                                                  vm_wait);
index 248a6b666aff396233020e46ea56a9d2d14d8885..0ad1cd57bc393b126e5cecbbb0f5638b34d73d97 100644 (file)
@@ -58,7 +58,7 @@ int dma_skb_copy_datagram_iovec(struct dma_chan *chan,
                if (copy > len)
                        copy = len;
                cookie = dma_memcpy_to_iovec(chan, to, pinned_list,
-                                           skb->data + offset, copy);
+                                           skb->data + offset, copy);
                if (cookie < 0)
                        goto fault;
                len -= copy;
@@ -108,8 +108,8 @@ int dma_skb_copy_datagram_iovec(struct dma_chan *chan,
                                if (copy > len)
                                        copy = len;
                                cookie = dma_skb_copy_datagram_iovec(chan, list,
-                                               offset - start, to, copy,
-                                               pinned_list);
+                                               offset - start, to, copy,
+                                               pinned_list);
                                if (cookie < 0)
                                        goto fault;
                                len -= copy;
@@ -128,5 +128,5 @@ end:
        }
 
 fault:
-       return -EFAULT;
+       return -EFAULT;
 }
index 61556065f07ec23b3d115fa05a71b156b0ae2ce1..07236c17fab934adf24a3608034b04318dd3071a 100644 (file)
@@ -33,9 +33,9 @@
 int net_msg_cost = 5*HZ;
 int net_msg_burst = 10;
 
-/* 
+/*
  * All net warning printk()s should be guarded by this function.
- */ 
+ */
 int net_ratelimit(void)
 {
        return __printk_ratelimit(net_msg_cost, net_msg_burst);
index f69ab7b4408ecca979e5e6f43aefd2a051577c06..64017d47b25b8808d8f47977bf36012b44c1d4d1 100644 (file)
@@ -369,7 +369,7 @@ static const struct iw_ioctl_description standard_event[] = {
                .header_type    = IW_HEADER_TYPE_ADDR,
        },
        [IWEVEXPIRED    - IWEVFIRST] = {
-               .header_type    = IW_HEADER_TYPE_ADDR, 
+               .header_type    = IW_HEADER_TYPE_ADDR,
        },
        [IWEVGENIE      - IWEVFIRST] = {
                .header_type    = IW_HEADER_TYPE_POINT,
@@ -377,7 +377,7 @@ static const struct iw_ioctl_description standard_event[] = {
                .max_tokens     = IW_GENERIC_IE_MAX,
        },
        [IWEVMICHAELMICFAILURE  - IWEVFIRST] = {
-               .header_type    = IW_HEADER_TYPE_POINT, 
+               .header_type    = IW_HEADER_TYPE_POINT,
                .token_size     = 1,
                .max_tokens     = sizeof(struct iw_michaelmicfailure),
        },
@@ -630,11 +630,11 @@ static __inline__ void wireless_seq_printf_stats(struct seq_file *seq,
                           dev->name, stats->status, stats->qual.qual,
                           stats->qual.updated & IW_QUAL_QUAL_UPDATED
                           ? '.' : ' ',
-                          ((__s32) stats->qual.level) - 
+                          ((__s32) stats->qual.level) -
                           ((stats->qual.updated & IW_QUAL_DBM) ? 0x100 : 0),
                           stats->qual.updated & IW_QUAL_LEVEL_UPDATED
                           ? '.' : ' ',
-                          ((__s32) stats->qual.noise) - 
+                          ((__s32) stats->qual.noise) -
                           ((stats->qual.updated & IW_QUAL_DBM) ? 0x100 : 0),
                           stats->qual.updated & IW_QUAL_NOISE_UPDATED
                           ? '.' : ' ',
@@ -862,7 +862,7 @@ static int ioctl_standard_call(struct net_device *  dev,
                                           iwr->u.data.length *
                                           descr->token_size);
                        if (err)
-                               ret =  -EFAULT;                            
+                               ret =  -EFAULT;
 #ifdef WE_IOCTL_DEBUG
                        printk(KERN_DEBUG "%s (WE) : Wrote %d bytes\n",
                               dev->name,
@@ -1040,7 +1040,7 @@ static inline int ioctl_private_call(struct net_device *  dev,
                        err = copy_to_user(iwr->u.data.pointer, extra,
                                           extra_size);
                        if (err)
-                               ret =  -EFAULT;                            
+                               ret =  -EFAULT;
 #ifdef WE_IOCTL_DEBUG
                        printk(KERN_DEBUG "%s (WE) : Wrote %d elem\n",
                               dev->name, iwr->u.data.length);
@@ -1080,7 +1080,7 @@ int wireless_process_ioctl(struct ifreq *ifr, unsigned int cmd)
        /* A bunch of special cases, then the generic case...
         * Note that 'cmd' is already filtered in dev_ioctl() with
         * (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST) */
-       switch(cmd) 
+       switch(cmd)
        {
                case SIOCGIWSTATS:
                        /* Get Wireless Stats */
@@ -2015,7 +2015,7 @@ void wireless_send_event(struct net_device *      dev,
                 * The best the driver could do is to log an error message.
                 * We will do it ourselves instead...
                 */
-               printk(KERN_ERR "%s (WE) : Invalid/Unknown Wireless Event (0x%04X)\n",
+               printk(KERN_ERR "%s (WE) : Invalid/Unknown Wireless Event (0x%04X)\n",
                       dev->name, cmd);
                return;
        }
@@ -2029,11 +2029,11 @@ void wireless_send_event(struct net_device *    dev,
        if(descr->header_type == IW_HEADER_TYPE_POINT) {
                /* Check if number of token fits within bounds */
                if(wrqu->data.length > descr->max_tokens) {
-                       printk(KERN_ERR "%s (WE) : Wireless Event too big (%d)\n", dev->name, wrqu->data.length);
+                       printk(KERN_ERR "%s (WE) : Wireless Event too big (%d)\n", dev->name, wrqu->data.length);
                        return;
                }
                if(wrqu->data.length < descr->min_tokens) {
-                       printk(KERN_ERR "%s (WE) : Wireless Event too small (%d)\n", dev->name, wrqu->data.length);
+                       printk(KERN_ERR "%s (WE) : Wireless Event too small (%d)\n", dev->name, wrqu->data.length);
                        return;
                }
                /* Calculate extra_len - extra is NULL for restricted events */
index fd38b05d6f79ec146edda973d2a307653a0c01f8..248d20f4c7c4edb45d94715b244331b760e77775 100644 (file)
@@ -139,7 +139,7 @@ static int ccid2_hc_tx_send_packet(struct sock *sk, struct sk_buff *skb)
                return 0;
        }
 
-        hctx = ccid2_hc_tx_sk(sk);
+       hctx = ccid2_hc_tx_sk(sk);
 
        ccid2_pr_debug("pipe=%d cwnd=%d\n", hctx->ccid2hctx_pipe,
                       hctx->ccid2hctx_cwnd);
@@ -368,13 +368,13 @@ static void ccid2_hc_tx_packet_sent(struct sock *sk, int more, unsigned int len)
 static int ccid2_ackvector(struct sock *sk, struct sk_buff *skb, int offset,
                           unsigned char **vec, unsigned char *veclen)
 {
-        const struct dccp_hdr *dh = dccp_hdr(skb);
-        unsigned char *options = (unsigned char *)dh + dccp_hdr_len(skb);
-        unsigned char *opt_ptr;
-        const unsigned char *opt_end = (unsigned char *)dh +
-                                        (dh->dccph_doff * 4);
-        unsigned char opt, len;
-        unsigned char *value;
+       const struct dccp_hdr *dh = dccp_hdr(skb);
+       unsigned char *options = (unsigned char *)dh + dccp_hdr_len(skb);
+       unsigned char *opt_ptr;
+       const unsigned char *opt_end = (unsigned char *)dh +
+                                       (dh->dccph_doff * 4);
+       unsigned char opt, len;
+       unsigned char *value;
 
        BUG_ON(offset < 0);
        options += offset;
@@ -383,29 +383,29 @@ static int ccid2_ackvector(struct sock *sk, struct sk_buff *skb, int offset,
                return -1;
 
        while (opt_ptr != opt_end) {
-                opt   = *opt_ptr++;
-                len   = 0;
-                value = NULL;
-
-                /* Check if this isn't a single byte option */
-                if (opt > DCCPO_MAX_RESERVED) {
-                        if (opt_ptr == opt_end)
-                                goto out_invalid_option;
-
-                        len = *opt_ptr++;
-                        if (len < 3)
-                                goto out_invalid_option;
-                        /*
-                         * Remove the type and len fields, leaving
-                         * just the value size
-                         */
-                        len     -= 2;
-                        value   = opt_ptr;
-                        opt_ptr += len;
-
-                        if (opt_ptr > opt_end)
-                                goto out_invalid_option;
-                }
+               opt   = *opt_ptr++;
+               len   = 0;
+               value = NULL;
+
+               /* Check if this isn't a single byte option */
+               if (opt > DCCPO_MAX_RESERVED) {
+                       if (opt_ptr == opt_end)
+                               goto out_invalid_option;
+
+                       len = *opt_ptr++;
+                       if (len < 3)
+                               goto out_invalid_option;
+                       /*
+                        * Remove the type and len fields, leaving
+                        * just the value size
+                        */
+                       len     -= 2;
+                       value   = opt_ptr;
+                       opt_ptr += len;
+
+                       if (opt_ptr > opt_end)
+                               goto out_invalid_option;
+               }
 
                switch (opt) {
                case DCCPO_ACK_VECTOR_0:
@@ -432,7 +432,7 @@ static void ccid2_hc_tx_kill_rto_timer(struct sock *sk)
 }
 
 static inline void ccid2_new_ack(struct sock *sk,
-                                struct ccid2_seq *seqp,
+                                struct ccid2_seq *seqp,
                                 unsigned int *maxincr)
 {
        struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
@@ -759,7 +759,7 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
 
 static int ccid2_hc_tx_init(struct ccid *ccid, struct sock *sk)
 {
-        struct ccid2_hc_tx_sock *hctx = ccid_priv(ccid);
+       struct ccid2_hc_tx_sock *hctx = ccid_priv(ccid);
 
        ccid2_change_cwnd(hctx, 1);
        /* Initialize ssthresh to infinity.  This means that we will exit the
@@ -793,7 +793,7 @@ static int ccid2_hc_tx_init(struct ccid *ccid, struct sock *sk)
 
 static void ccid2_hc_tx_exit(struct sock *sk)
 {
-        struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
+       struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
        int i;
 
        ccid2_hc_tx_kill_rto_timer(sk);
index 40402c59506a32b5b5c12d3bc7ca53730d087740..5361a4d8e13b54dc8d18ca2ea3fd959745928d06 100644 (file)
@@ -284,7 +284,7 @@ static void ccid3_hc_tx_no_feedback_timer(unsigned long data)
 
 restart_timer:
        sk_reset_timer(sk, &hctx->ccid3hctx_no_feedback_timer,
-                          jiffies + usecs_to_jiffies(t_nfb));
+                          jiffies + usecs_to_jiffies(t_nfb));
 out:
        bh_unlock_sock(sk);
        sock_put(sk);
@@ -319,7 +319,7 @@ static int ccid3_hc_tx_send_packet(struct sock *sk, struct sk_buff *skb)
        case TFRC_SSTATE_NO_SENT:
                sk_reset_timer(sk, &hctx->ccid3hctx_no_feedback_timer,
                               (jiffies +
-                               usecs_to_jiffies(TFRC_INITIAL_TIMEOUT)));
+                               usecs_to_jiffies(TFRC_INITIAL_TIMEOUT)));
                hctx->ccid3hctx_last_win_count   = 0;
                hctx->ccid3hctx_t_last_win_count = now;
                ccid3_hc_tx_set_state(sk, TFRC_SSTATE_NO_FBACK);
@@ -479,14 +479,15 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
 
                        ccid3_pr_debug("%s(%p), s=%u, w_init=%llu, "
                                       "R_sample=%dus, X=%u\n", dccp_role(sk),
-                                      sk, hctx->ccid3hctx_s, w_init,
+                                      sk, hctx->ccid3hctx_s,
+                                      (unsigned long long)w_init,
                                       (int)r_sample,
                                       (unsigned)(hctx->ccid3hctx_x >> 6));
 
                        ccid3_hc_tx_set_state(sk, TFRC_SSTATE_FBACK);
                } else {
                        hctx->ccid3hctx_rtt = (9 * hctx->ccid3hctx_rtt +
-                                                  (u32)r_sample) / 10;
+                                                  (u32)r_sample) / 10;
 
                        /* Update sending rate (step 4 of [RFC 3448, 4.3]) */
                        if (hctx->ccid3hctx_p > 0)
@@ -923,7 +924,7 @@ static void ccid3_hc_rx_update_li(struct sock *sk, u64 seq_loss, u8 win_loss)
 }
 
 static int ccid3_hc_rx_detect_loss(struct sock *sk,
-                                    struct dccp_rx_hist_entry *packet)
+                                   struct dccp_rx_hist_entry *packet)
 {
        struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk);
        struct dccp_rx_hist_entry *rx_hist =
@@ -1005,7 +1006,7 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
                DCCP_BUG_ON(r_sample < 0);
                if (unlikely(r_sample <= t_elapsed))
                        DCCP_WARN("r_sample=%ldus, t_elapsed=%ldus\n",
-                                 r_sample, t_elapsed);
+                                 (long)r_sample, (long)t_elapsed);
                else
                        r_sample -= t_elapsed;
                CCID3_RTT_SANITY_CHECK(r_sample);
@@ -1073,7 +1074,7 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
                       dccp_role(sk), sk, dccp_state_name(sk->sk_state));
 
        p_prev = hcrx->ccid3hcrx_p;
-       
+
        /* Calculate loss event rate */
        if (!list_empty(&hcrx->ccid3hcrx_li_hist)) {
                u32 i_mean = dccp_li_hist_calc_i_mean(&hcrx->ccid3hcrx_li_hist);
@@ -1155,7 +1156,7 @@ static int ccid3_hc_rx_getsockopt(struct sock *sk, const int optname, int len,
 {
        const struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk);
        const void *val;
-       
+
        /* Listen socks doesn't have a private CCID block */
        if (sk->sk_state == DCCP_LISTEN)
                return -EINVAL;
@@ -1182,7 +1183,7 @@ static int ccid3_hc_tx_getsockopt(struct sock *sk, const int optname, int len,
 {
        const struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
        const void *val;
-       
+
        /* Listen socks doesn't have a private CCID block */
        if (sk->sk_state == DCCP_LISTEN)
                return -EINVAL;
index 1f960c19ea1bf0ca948403321efd30e09fb98de8..60d00f01539021742a329d212ed0dd84d12c7c7e 100644 (file)
@@ -137,7 +137,7 @@ extern void                 dccp_rx_hist_delete(struct dccp_rx_hist *hist);
 static inline struct dccp_rx_hist_entry *
                        dccp_rx_hist_entry_new(struct dccp_rx_hist *hist,
                                               const struct sock *sk,
-                                              const u32 ndp,
+                                              const u32 ndp,
                                               const struct sk_buff *skb,
                                               const gfp_t prio)
 {
@@ -169,7 +169,7 @@ static inline struct dccp_rx_hist_entry *
 }
 
 extern int dccp_rx_hist_find_entry(const struct list_head *list, const u64 seq,
-                                  u8 *ccval);
+                                  u8 *ccval);
 extern struct dccp_rx_hist_entry *
                dccp_rx_hist_find_data_packet(const struct list_head *list);
 
index 90009fd77e158f03e3e1a4002a23be34d0bd7e01..e4e64b76c10ca8335aa71328e6f40cb462239ddf 100644 (file)
@@ -26,7 +26,7 @@
   The following two-column lookup table implements a part of the TCP throughput
   equation from [RFC 3448, sec. 3.1]:
 
-                                    s
+                                    s
   X_calc  =  --------------------------------------------------------------
             R * sqrt(2*b*p/3) + (3 * t_RTO * sqrt(3*b*p/8) * (p + 32*p^3))
 
@@ -35,7 +35,7 @@
        s      is the packet size in bytes
        R      is the round trip time in seconds
        p      is the loss event rate, between 0 and 1.0, of the number of loss
-                     events as a fraction of the number of packets transmitted
+                     events as a fraction of the number of packets transmitted
        t_RTO  is the TCP retransmission timeout value in seconds
        b      is the number of packets acknowledged by a single TCP ACK
 
@@ -47,9 +47,9 @@
 
   which we can break down into:
 
-                      s
+                     s
        X_calc  =  ---------
-                   R * f(p)
+                   R * f(p)
 
   where f(p) is given for 0 < p <= 1 by:
 
@@ -62,7 +62,7 @@
     * the return result f(p)
   The lookup table therefore actually tabulates the following function g(q):
 
-       g(q)  =  1000000 * f(q/1000000)
+       g(q)  =  1000000 * f(q/1000000)
 
   Hence, when p <= 1, q must be less than or equal to 1000000. To achieve finer
   granularity for the practically more relevant case of small values of p (up to
@@ -628,7 +628,7 @@ u32 tfrc_calc_x(u16 s, u32 R, u32 p)
        if (R == 0) {                   /* possible  divide by zero */
                DCCP_CRIT("WARNING: RTT is 0, returning maximum X_calc.");
                return ~0U;
-       }
+       }
 
        if (p <= TFRC_CALC_X_SPLIT)             {     /* 0.0000 < p <= 0.05   */
                if (p < TFRC_SMALLEST_P) {            /* 0.0000 < p <  0.0001 */
@@ -638,7 +638,7 @@ u32 tfrc_calc_x(u16 s, u32 R, u32 p)
                } else                                /* 0.0001 <= p <= 0.05  */
                        index =  p/TFRC_SMALLEST_P - 1;
 
-               f = tfrc_calc_x_lookup[index][1];
+               f = tfrc_calc_x_lookup[index][1];
 
        } else {                                      /* 0.05   <  p <= 1.00  */
                index = p/(1000000/TFRC_CALC_X_ARRSIZE) - 1;
@@ -687,8 +687,8 @@ u32 tfrc_calc_x_reverse_lookup(u32 fvalue)
        if (fvalue <= tfrc_calc_x_lookup[TFRC_CALC_X_ARRSIZE - 1][1]) {
                index = tfrc_binsearch(fvalue, 1);
                return (index + 1) * TFRC_CALC_X_SPLIT / TFRC_CALC_X_ARRSIZE;
-       }
+       }
+
        /* else ... it must be in the coarse-grained column */
        index = tfrc_binsearch(fvalue, 0);
        return (index + 1) * 1000000 / TFRC_CALC_X_ARRSIZE;
index a0900bf98e6bbaf223f6cc3a02b500772ecc1781..e33a9edb40363ef7c964de7de3eb55c0c81d7846 100644 (file)
@@ -22,7 +22,7 @@
  *     DCCP - specific warning and debugging macros.
  */
 #define DCCP_WARN(fmt, a...) LIMIT_NETDEBUG(KERN_WARNING "%s: " fmt,       \
-                                                       __FUNCTION__, ##a)
+                                                       __FUNCTION__, ##a)
 #define DCCP_CRIT(fmt, a...) printk(KERN_CRIT fmt " at %s:%d/%s()\n", ##a, \
                                         __FILE__, __LINE__, __FUNCTION__)
 #define DCCP_BUG(a...)       do { DCCP_CRIT("BUG: " a); dump_stack(); } while(0)
@@ -34,7 +34,7 @@
 #ifdef MODULE
 #define DCCP_PRINTK(enable, fmt, args...)      do { if (enable)             \
                                                        printk(fmt, ##args); \
-                                               } while(0)
+                                               } while(0)
 #else
 #define DCCP_PRINTK(enable, fmt, args...)      printk(fmt, ##args)
 #endif
@@ -128,7 +128,7 @@ enum {
        DCCP_MIB_ACTIVEOPENS,                   /* ActiveOpens */
        DCCP_MIB_ESTABRESETS,                   /* EstabResets */
        DCCP_MIB_CURRESTAB,                     /* CurrEstab */
-       DCCP_MIB_OUTSEGS,                       /* OutSegs */ 
+       DCCP_MIB_OUTSEGS,                       /* OutSegs */
        DCCP_MIB_OUTRSTS,
        DCCP_MIB_ABORTONTIMEOUT,
        DCCP_MIB_TIMEOUTS,
@@ -372,7 +372,7 @@ static inline void dccp_update_gss(struct sock *sk, u64 seq)
                       (dp->dccps_gss -
                        dccp_msk(sk)->dccpms_sequence_window + 1));
 }
-                               
+
 static inline int dccp_ack_pending(const struct sock *sk)
 {
        const struct dccp_sock *dp = dccp_sk(sk);
index 95b6927ec6530eef17fab12cc5784d101fa7ded9..cd845df5320dbe6bb74d6ee2dfcbad8244a7723e 100644 (file)
@@ -480,8 +480,8 @@ void dccp_feat_clean(struct dccp_minisock *dmsk)
 
        list_for_each_entry_safe(opt, next, &dmsk->dccpms_pending,
                                 dccpop_node) {
-                BUG_ON(opt->dccpop_val == NULL);
-                kfree(opt->dccpop_val);
+               BUG_ON(opt->dccpop_val == NULL);
+               kfree(opt->dccpop_val);
 
                if (opt->dccpop_sc != NULL) {
                        BUG_ON(opt->dccpop_sc->dccpoc_val == NULL);
@@ -489,8 +489,8 @@ void dccp_feat_clean(struct dccp_minisock *dmsk)
                        kfree(opt->dccpop_sc);
                }
 
-                kfree(opt);
-        }
+               kfree(opt);
+       }
        INIT_LIST_HEAD(&dmsk->dccpms_pending);
 
        list_for_each_entry_safe(opt, next, &dmsk->dccpms_conf, dccpop_node) {
index 2c373ad7edcf297ea2404db9bf9c81d55aaf34c3..177f7dee4d101bf3a5963b0cd61d03cc1c605552 100644 (file)
@@ -30,7 +30,7 @@ static inline int dccp_feat_is_reserved(const u8 feat)
 {
        return (feat > DCCPF_DATA_CHECKSUM &&
                feat < DCCPF_MIN_CCID_SPECIFIC) ||
-               feat == DCCPF_RESERVED;
+               feat == DCCPF_RESERVED;
 }
 
 /* feature negotiation knows only these four option types (RFC 4340, sec. 6) */
index 565bc80557ceb79139ea96c930652def3a56237d..4dee462f00db2c11fab14f709e15d8f6cd97432a 100644 (file)
@@ -91,7 +91,7 @@ static int dccp_check_seqno(struct sock *sk, struct sk_buff *skb)
                else
                        return -1;
        }
-       
+
        /*
         *   Step 6: Check sequence numbers
         *      Let LSWL = S.SWL and LAWL = S.AWL
@@ -136,7 +136,7 @@ static int dccp_check_seqno(struct sock *sk, struct sk_buff *skb)
                          (unsigned long long) DCCP_SKB_CB(skb)->dccpd_seq,
                          (unsigned long long) dp->dccps_swh,
                          (DCCP_SKB_CB(skb)->dccpd_ack_seq ==
-                               DCCP_PKT_WITHOUT_ACK_SEQ) ? "doesn't exist" : "exists",
+                               DCCP_PKT_WITHOUT_ACK_SEQ) ? "doesn't exist" : "exists",
                          (unsigned long long) lawl,
                          (unsigned long long) DCCP_SKB_CB(skb)->dccpd_ack_seq,
                          (unsigned long long) dp->dccps_awh);
@@ -308,11 +308,11 @@ static int dccp_rcv_request_sent_state_process(struct sock *sk,
                if (dccp_parse_options(sk, skb))
                        goto out_invalid_packet;
 
-                if (dccp_msk(sk)->dccpms_send_ack_vector &&
-                    dccp_ackvec_add(dp->dccps_hc_rx_ackvec, sk,
-                                    DCCP_SKB_CB(skb)->dccpd_seq,
-                                    DCCP_ACKVEC_STATE_RECEIVED))
-                        goto out_invalid_packet; /* FIXME: change error code */
+               if (dccp_msk(sk)->dccpms_send_ack_vector &&
+                   dccp_ackvec_add(dp->dccps_hc_rx_ackvec, sk,
+                                   DCCP_SKB_CB(skb)->dccpd_seq,
+                                   DCCP_ACKVEC_STATE_RECEIVED))
+                       goto out_invalid_packet; /* FIXME: change error code */
 
                dp->dccps_isr = DCCP_SKB_CB(skb)->dccpd_seq;
                dccp_update_gsr(sk, dp->dccps_isr);
index 90c74b4adb7396443a36d8124633e2d22abd5551..4a83978aa660dd9a628bb9134af6bd853de1353d 100644 (file)
@@ -72,7 +72,7 @@ int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
        tmp = ip_route_connect(&rt, nexthop, inet->saddr,
                               RT_CONN_FLAGS(sk), sk->sk_bound_dev_if,
                               IPPROTO_DCCP,
-                              inet->sport, usin->sin_port, sk);
+                              inet->sport, usin->sin_port, sk, 1);
        if (tmp < 0)
                return tmp;
 
@@ -106,7 +106,7 @@ int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
                goto failure;
 
        err = ip_route_newports(&rt, IPPROTO_DCCP, inet->sport, inet->dport,
-                               sk);
+                               sk);
        if (err != 0)
                goto failure;
 
@@ -157,7 +157,7 @@ static inline void dccp_do_pmtu_discovery(struct sock *sk,
        /* We don't check in the destentry if pmtu discovery is forbidden
         * on this route. We just assume that no packet_to_big packets
         * are send back when pmtu discovery is not active.
-        * There is a small race when the user changes this flag in the
+        * There is a small race when the user changes this flag in the
         * route, but I think that's acceptable.
         */
        if ((dst = __sk_dst_check(sk, 0)) == NULL)
@@ -486,7 +486,7 @@ static int dccp_v4_send_response(struct sock *sk, struct request_sock *req,
        struct sk_buff *skb;
 
        /* First, grab a route. */
-       
+
        if (dst == NULL && (dst = inet_csk_route_req(sk, req)) == NULL)
                goto out;
 
index 6b91a9dd04111298c96127ea49e18d864602e9f9..7f51e8db3967280e7698fb1c916a64c6c4a5b24c 100644 (file)
@@ -734,7 +734,7 @@ static int dccp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
           looks not very well thought. For now we latch
           options, received in the last packet, enqueued
           by tcp. Feel free to propose better solution.
-                                              --ANK (980728)
+                                              --ANK (980728)
         */
        if (np->rxopt.all)
        /*
@@ -1041,7 +1041,7 @@ static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
        if (final_p)
                ipv6_addr_copy(&fl.fl6_dst, final_p);
 
-       err = xfrm_lookup(&dst, &fl, sk, 0);
+       err = xfrm_lookup(&dst, &fl, sk, 1);
        if (err < 0)
                goto failure;
 
index c03ba61eb6da3c37a1bd225a24b566fdd2e89434..ca13f77319940893459e47c23794abe00f61c905 100644 (file)
@@ -242,7 +242,7 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb)
                        DCCP_CRIT("DCCP(%p): option %d(len=%d) not "
                                  "implemented, ignoring", sk, opt, len);
                        break;
-               }
+               }
 
                if (opt != DCCPO_MANDATORY)
                        mandatory = 0;
@@ -442,7 +442,7 @@ static int dccp_insert_option_timestamp_echo(struct sock *sk,
 }
 
 static int dccp_insert_feat_opt(struct sk_buff *skb, u8 type, u8 feat,
-                               u8 *val, u8 len)
+                               u8 *val, u8 len)
 {
        u8 *to;
 
index 3435542e96528f5cce06257980e7ee95cc28ccf8..f5c6aca1dfa45557a31ed6f9fe0a9b0d4f109a9f 100644 (file)
@@ -87,7 +87,7 @@ static int dccp_transmit_skb(struct sock *sk, struct sk_buff *skb)
                        kfree_skb(skb);
                        return -EPROTO;
                }
-               
+
 
                /* Build DCCP header and checksum it. */
                dh = dccp_zeroed_hdr(skb, dccp_header_size);
@@ -415,7 +415,7 @@ static inline void dccp_connect_init(struct sock *sk)
 
        sk->sk_err = 0;
        sock_reset_flag(sk, SOCK_DONE);
-       
+
        dccp_sync_mss(sk, dst_mtu(dst));
 
        /*
index 63b3fa20e14bbb718d3baa9a7a16c2bcb1a503bd..cf28c53a389a24b49c82ccc21721139bcbf110e1 100644 (file)
@@ -478,7 +478,7 @@ static int do_dccp_setsockopt(struct sock *sk, int level, int optname,
                        err = -EINVAL;
                else
                        err = dccp_setsockopt_change(sk, DCCPO_CHANGE_L,
-                                                    (struct dccp_so_feat __user *)
+                                                    (struct dccp_so_feat __user *)
                                                     optval);
                break;
        case DCCP_SOCKOPT_CHANGE_R:
@@ -1024,7 +1024,6 @@ static int __init dccp_init(void)
        do {
                dccp_hashinfo.ehash_size = (1UL << ehash_order) * PAGE_SIZE /
                                        sizeof(struct inet_ehash_bucket);
-               dccp_hashinfo.ehash_size >>= 1;
                while (dccp_hashinfo.ehash_size &
                       (dccp_hashinfo.ehash_size - 1))
                        dccp_hashinfo.ehash_size--;
@@ -1037,9 +1036,10 @@ static int __init dccp_init(void)
                goto out_free_bind_bucket_cachep;
        }
 
-       for (i = 0; i < (dccp_hashinfo.ehash_size << 1); i++) {
+       for (i = 0; i < dccp_hashinfo.ehash_size; i++) {
                rwlock_init(&dccp_hashinfo.ehash[i].lock);
                INIT_HLIST_HEAD(&dccp_hashinfo.ehash[i].chain);
+               INIT_HLIST_HEAD(&dccp_hashinfo.ehash[i].twchain);
        }
 
        bhash_order = ehash_order;
index e5348f369c60a09055e4f7b464d9e3520eb95f35..41ea0f6594c4a5b26e82247cddc3539f90f06001 100644 (file)
@@ -60,7 +60,7 @@ static int dccp_write_timeout(struct sock *sk)
    be far nicer to have all of the black holes fixed rather than fixing
    all of the TCP implementations."
 
-                           Golden words :-).
+                          Golden words :-).
                   */
 
                        dst_negative_advice(&sk->sk_dst_cache);
index 21f20f21dd3273c770d492494f71c214ea6ea41e..70061641ee5947bfa14c447ee58413b8e3171f39 100644 (file)
@@ -45,7 +45,7 @@
 
 /******************************************************************************
     (c) 1995-1998 E.M. Serrat          emserrat@geocities.com
-    
+
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
     the Free Software Foundation; either version 2 of the License, or
@@ -63,7 +63,7 @@ Version           Kernel     Date       Author/Comments
 Version 0.0.1     2.0.30    01-dic-97  Eduardo Marcelo Serrat
                                        (emserrat@geocities.com)
 
-                                        First Development of DECnet Socket La-
+                                       First Development of DECnet Socket La-
                                        yer for Linux. Only supports outgoing
                                        connections.
 
@@ -75,28 +75,28 @@ Version 0.0.2         2.1.105   20-jun-98   Patrick J. Caulfield
 Version 0.0.3     2.1.106   25-jun-98   Eduardo Marcelo Serrat
                                        (emserrat@geocities.com)
                                        _
-                                        Added support for incoming connections
-                                        so we can start developing server apps
-                                        on Linux.
+                                       Added support for incoming connections
+                                       so we can start developing server apps
+                                       on Linux.
                                        -
                                        Module Support
 Version 0.0.4     2.1.109   21-jul-98   Eduardo Marcelo Serrat
-                                       (emserrat@geocities.com)
-                                       _
-                                        Added support for X11R6.4. Now we can 
-                                        use DECnet transport for X on Linux!!!
-                                       -
+                                      (emserrat@geocities.com)
+                                      _
+                                       Added support for X11R6.4. Now we can
+                                       use DECnet transport for X on Linux!!!
+                                      -
 Version 0.0.5    2.1.110   01-aug-98   Eduardo Marcelo Serrat
-                                       (emserrat@geocities.com)
-                                       Removed bugs on flow control
-                                       Removed bugs on incoming accessdata
-                                       order
-                                       -
+                                      (emserrat@geocities.com)
+                                      Removed bugs on flow control
+                                      Removed bugs on incoming accessdata
+                                      order
+                                      -
 Version 0.0.6    2.1.110   07-aug-98   Eduardo Marcelo Serrat
-                                       dn_recvmsg fixes
+                                      dn_recvmsg fixes
 
-                                        Patrick J. Caulfield
-                                       dn_bind fixes
+                                       Patrick J. Caulfield
+                                      dn_bind fixes
 *******************************************************************************/
 
 #include <linux/module.h>
@@ -169,7 +169,7 @@ static struct hlist_head *dn_find_list(struct sock *sk)
        return &dn_sk_hash[dn_ntohs(scp->addrloc) & DN_SK_HASH_MASK];
 }
 
-/* 
+/*
  * Valid ports are those greater than zero and not already in use.
  */
 static int check_port(__le16 port)
@@ -218,7 +218,7 @@ static int dn_hash_sock(struct sock *sk)
        BUG_ON(sk_hashed(sk));
 
        write_lock_bh(&dn_hash_lock);
-       
+
        if (!scp->addrloc && !port_alloc(sk))
                goto out;
 
@@ -400,7 +400,7 @@ struct sock *dn_sklist_find_listener(struct sockaddr_dn *addr)
 
        sk = sk_head(&dn_wild_sk);
        if (sk) {
-               if (sk->sk_state == TCP_LISTEN)
+               if (sk->sk_state == TCP_LISTEN)
                        sock_hold(sk);
                else
                        sk = NULL;
@@ -500,7 +500,7 @@ static struct sock *dn_alloc_sock(struct socket *sock, gfp_t gfp)
        scp->ackxmt_oth = 0;            /* Last oth data ack'ed */
        scp->ackrcv_dat = 0;            /* Highest data ack recv*/
        scp->ackrcv_oth = 0;            /* Last oth data ack rec*/
-        scp->flowrem_sw = DN_SEND;
+       scp->flowrem_sw = DN_SEND;
        scp->flowloc_sw = DN_SEND;
        scp->flowrem_dat = 0;
        scp->flowrem_oth = 1;
@@ -690,7 +690,7 @@ static int dn_create(struct socket *sock, int protocol)
        }
 
 
-       if ((sk = dn_alloc_sock(sock, GFP_KERNEL)) == NULL) 
+       if ((sk = dn_alloc_sock(sock, GFP_KERNEL)) == NULL)
                return -ENOBUFS;
 
        sk->sk_protocol = protocol;
@@ -713,7 +713,7 @@ dn_release(struct socket *sock)
                sock_put(sk);
        }
 
-        return 0;
+       return 0;
 }
 
 static int dn_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
@@ -770,7 +770,7 @@ static int dn_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
        }
        release_sock(sk);
 
-        return rv;
+       return rv;
 }
 
 
@@ -791,7 +791,7 @@ static int dn_auto_bind(struct socket *sock)
         */
        if ((scp->accessdata.acc_accl != 0) &&
                (scp->accessdata.acc_accl <= 12)) {
-       
+
                scp->addr.sdn_objnamel = dn_htons(scp->accessdata.acc_accl);
                memcpy(scp->addr.sdn_objname, scp->accessdata.acc_acc, dn_ntohs(scp->addr.sdn_objnamel));
 
@@ -997,20 +997,20 @@ static inline int dn_check_state(struct sock *sk, struct sockaddr_dn *addr, int
 
 static void dn_access_copy(struct sk_buff *skb, struct accessdata_dn *acc)
 {
-        unsigned char *ptr = skb->data;
+       unsigned char *ptr = skb->data;
 
-        acc->acc_userl = *ptr++;
-        memcpy(&acc->acc_user, ptr, acc->acc_userl);
-        ptr += acc->acc_userl;
+       acc->acc_userl = *ptr++;
+       memcpy(&acc->acc_user, ptr, acc->acc_userl);
+       ptr += acc->acc_userl;
 
-        acc->acc_passl = *ptr++;
-        memcpy(&acc->acc_pass, ptr, acc->acc_passl);
-        ptr += acc->acc_passl;
+       acc->acc_passl = *ptr++;
+       memcpy(&acc->acc_pass, ptr, acc->acc_passl);
+       ptr += acc->acc_passl;
 
-        acc->acc_accl = *ptr++;
-        memcpy(&acc->acc_acc, ptr, acc->acc_accl);
+       acc->acc_accl = *ptr++;
+       memcpy(&acc->acc_acc, ptr, acc->acc_accl);
 
-        skb_pull(skb, acc->acc_accl + acc->acc_passl + acc->acc_userl + 3);
+       skb_pull(skb, acc->acc_accl + acc->acc_passl + acc->acc_userl + 3);
 
 }
 
@@ -1071,7 +1071,7 @@ static int dn_accept(struct socket *sock, struct socket *newsock, int flags)
 
        lock_sock(sk);
 
-        if (sk->sk_state != TCP_LISTEN || DN_SK(sk)->state != DN_O) {
+       if (sk->sk_state != TCP_LISTEN || DN_SK(sk)->state != DN_O) {
                release_sock(sk);
                return -EINVAL;
        }
@@ -1098,13 +1098,13 @@ static int dn_accept(struct socket *sock, struct socket *newsock, int flags)
        dst_release(xchg(&newsk->sk_dst_cache, skb->dst));
        skb->dst = NULL;
 
-        DN_SK(newsk)->state        = DN_CR;
+       DN_SK(newsk)->state        = DN_CR;
        DN_SK(newsk)->addrrem      = cb->src_port;
        DN_SK(newsk)->services_rem = cb->services;
        DN_SK(newsk)->info_rem     = cb->info;
        DN_SK(newsk)->segsize_rem  = cb->segsize;
        DN_SK(newsk)->accept_mode  = DN_SK(sk)->accept_mode;
-       
+
        if (DN_SK(newsk)->segsize_rem < 230)
                DN_SK(newsk)->segsize_rem = 230;
 
@@ -1154,15 +1154,15 @@ static int dn_accept(struct socket *sock, struct socket *newsock, int flags)
                dn_send_conn_ack(newsk);
 
                /*
-                * Here we use sk->sk_allocation since although the conn conf is
-                * for the newsk, the context is the old socket.
-                */
+                * Here we use sk->sk_allocation since although the conn conf is
+                * for the newsk, the context is the old socket.
+                */
                if (DN_SK(newsk)->accept_mode == ACC_IMMED)
                        err = dn_confirm_accept(newsk, &timeo,
                                                sk->sk_allocation);
        }
        release_sock(newsk);
-        return err;
+       return err;
 }
 
 
@@ -1177,10 +1177,10 @@ static int dn_getname(struct socket *sock, struct sockaddr *uaddr,int *uaddr_len
        lock_sock(sk);
 
        if (peer) {
-               if ((sock->state != SS_CONNECTED && 
-                    sock->state != SS_CONNECTING) && 
+               if ((sock->state != SS_CONNECTED &&
+                    sock->state != SS_CONNECTING) &&
                    scp->accept_mode == ACC_IMMED) {
-                       release_sock(sk);
+                       release_sock(sk);
                        return -ENOTCONN;
                }
 
@@ -1191,7 +1191,7 @@ static int dn_getname(struct socket *sock, struct sockaddr *uaddr,int *uaddr_len
 
        release_sock(sk);
 
-        return 0;
+       return 0;
 }
 
 
@@ -1285,7 +1285,7 @@ static int dn_listen(struct socket *sock, int backlog)
 out:
        release_sock(sk);
 
-        return err;
+       return err;
 }
 
 
@@ -1333,7 +1333,7 @@ static int dn_setsockopt(struct socket *sock, int level, int optname, char __use
        return err;
 }
 
-static int __dn_setsockopt(struct socket *sock, int level,int optname, char __user *optval, int optlen, int flags) 
+static int __dn_setsockopt(struct socket *sock, int level,int optname, char __user *optval, int optlen, int flags)
 {
        struct  sock *sk = sock->sk;
        struct dn_scp *scp = DN_SK(sk);
@@ -1360,7 +1360,7 @@ static int __dn_setsockopt(struct socket *sock, int level,int optname, char __us
 
        switch(optname) {
                case DSO_CONDATA:
-                       if (sock->state == SS_CONNECTED) 
+                       if (sock->state == SS_CONNECTED)
                                return -EISCONN;
                        if ((scp->state != DN_O) && (scp->state != DN_CR))
                                return -EINVAL;
@@ -1375,7 +1375,7 @@ static int __dn_setsockopt(struct socket *sock, int level,int optname, char __us
                        break;
 
                case DSO_DISDATA:
-                       if (sock->state != SS_CONNECTED && scp->accept_mode == ACC_IMMED)
+                       if (sock->state != SS_CONNECTED && scp->accept_mode == ACC_IMMED)
                                return -ENOTCONN;
 
                        if (optlen != sizeof(struct optdata_dn))
@@ -1388,7 +1388,7 @@ static int __dn_setsockopt(struct socket *sock, int level,int optname, char __us
                        break;
 
                case DSO_CONACCESS:
-                       if (sock->state == SS_CONNECTED) 
+                       if (sock->state == SS_CONNECTED)
                                return -EISCONN;
                        if (scp->state != DN_O)
                                return -EINVAL;
@@ -1521,7 +1521,7 @@ static int __dn_getsockopt(struct socket *sock, int level,int optname, char __us
 
        if(get_user(r_len , optlen))
                return -EFAULT;
-               
+
        switch(optname) {
                case DSO_CONDATA:
                        if (r_len > sizeof(struct optdata_dn))
@@ -1573,11 +1573,11 @@ static int __dn_getsockopt(struct socket *sock, int level,int optname, char __us
 #ifdef CONFIG_NETFILTER
                {
                        int val, len;
-                       
+
                        if(get_user(len, optlen))
                                return -EFAULT;
-                       
-                       val = nf_getsockopt(sk, PF_DECnet, optname, 
+
+                       val = nf_getsockopt(sk, PF_DECnet, optname,
                                                        optval, &len);
                        if (val >= 0)
                                val = put_user(len, optlen);
@@ -1588,7 +1588,7 @@ static int __dn_getsockopt(struct socket *sock, int level,int optname, char __us
                case DSO_SEQPACKET:
                case DSO_CONACCEPT:
                case DSO_CONREJECT:
-                       return -ENOPROTOOPT;
+                       return -ENOPROTOOPT;
 
                case DSO_MAXWINDOW:
                        if (r_len > sizeof(unsigned long))
@@ -1724,7 +1724,7 @@ static int dn_recvmsg(struct kiocb *iocb, struct socket *sock,
                                }
                        }
                }
-               
+
                if (scp->state != DN_RUN)
                        goto out;
 
@@ -1773,7 +1773,7 @@ static int dn_recvmsg(struct kiocb *iocb, struct socket *sock,
                if (skb->len == 0) {
                        skb_unlink(skb, queue);
                        kfree_skb(skb);
-                       /* 
+                       /*
                         * N.B. Don't refer to skb or cb after this point
                         * in loop.
                         */
@@ -1783,7 +1783,7 @@ static int dn_recvmsg(struct kiocb *iocb, struct socket *sock,
                        }
                }
 
-               if (eor) { 
+               if (eor) {
                        if (sk->sk_type == SOCK_SEQPACKET)
                                break;
                        if (!(flags & MSG_WAITALL))
@@ -1884,7 +1884,7 @@ static inline unsigned int dn_current_mss(struct sock *sk, int flags)
        return mss_now;
 }
 
-/* 
+/*
  * N.B. We get the timeout wrong here, but then we always did get it
  * wrong before and this is another step along the road to correcting
  * it. It ought to get updated each time we pass through the routine,
@@ -2044,7 +2044,7 @@ static int dn_sendmsg(struct kiocb *iocb, struct socket *sock,
                                cb->nsp_flags |= 0x20;
 
                        scp->seg_total += len;
-               
+
                        if (((sent + len) == size) && (flags & MSG_EOR)) {
                                cb->nsp_flags |= 0x40;
                                scp->seg_total = 0;
@@ -2202,7 +2202,7 @@ static void dn_socket_seq_stop(struct seq_file *seq, void *v)
 static void dn_printable_object(struct sockaddr_dn *dn, unsigned char *buf)
 {
        int i;
-    
+
        switch (dn_ntohs(dn->sdn_objnamel)) {
                case 0:
                        sprintf(buf, "%d", dn->sdn_objnum);
@@ -2214,7 +2214,7 @@ static void dn_printable_object(struct sockaddr_dn *dn, unsigned char *buf)
                                        buf[i] = '.';
                        }
                        buf[i] = 0;
-       }
+       }
 }
 
 static char *dn_state2asc(unsigned char state)
@@ -2381,7 +2381,7 @@ static int __init decnet_init(void)
 {
        int rc;
 
-        printk(banner);
+       printk(banner);
 
        rc = proto_register(&dn_proto, 1);
        if (rc != 0)
index ed083ab455b75f600ec5da51716ace4db8a04905..c5e28114beb8f69eee83aad467eefe571953421b 100644 (file)
@@ -224,27 +224,27 @@ static struct dn_dev_sysctl_table {
        {0}
        },
        {{
-               .ctl_name = 0, 
-               .procname = "", 
-               .mode = 0555, 
+               .ctl_name = 0,
+               .procname = "",
+               .mode = 0555,
                .child = dn_dev_sysctl.dn_dev_vars
        }, {0}},
        {{
                .ctl_name = NET_DECNET_CONF,
-               .procname = "conf", 
-               .mode = 0555, 
+               .procname = "conf",
+               .mode = 0555,
                .child = dn_dev_sysctl.dn_dev_dev
        }, {0}},
        {{
-               .ctl_name = NET_DECNET, 
-               .procname = "decnet", 
-               .mode = 0555, 
+               .ctl_name = NET_DECNET,
+               .procname = "decnet",
+               .mode = 0555,
                .child = dn_dev_sysctl.dn_dev_conf_dir
        }, {0}},
        {{
-               .ctl_name = CTL_NET, 
-               .procname = "net", 
-               .mode = 0555, 
+               .ctl_name = CTL_NET,
+               .procname = "net",
+               .mode = 0555,
                .child = dn_dev_sysctl.dn_dev_proto_dir
        }, {0}}
 };
@@ -299,7 +299,7 @@ static void dn_dev_sysctl_unregister(struct dn_dev_parms *parms)
        }
 }
 
-static int dn_forwarding_proc(ctl_table *table, int write, 
+static int dn_forwarding_proc(ctl_table *table, int write,
                                struct file *filep,
                                void __user *buffer,
                                size_t *lenp, loff_t *ppos)
@@ -456,7 +456,7 @@ static int dn_dev_insert_ifa(struct dn_dev *dn_db, struct dn_ifaddr *ifa)
 
        ASSERT_RTNL();
 
-       /* Check for duplicates */      
+       /* Check for duplicates */
        for(ifa1 = dn_db->ifa_list; ifa1; ifa1 = ifa1->ifa_next) {
                if (ifa1->ifa_local == ifa->ifa_local)
                        return -EEXIST;
@@ -708,7 +708,7 @@ static int dn_nl_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
                if (!dn_db)
                        return err;
        }
-       
+
        if ((ifa = dn_dev_alloc_ifa()) == NULL)
                return -ENOBUFS;
 
@@ -749,7 +749,7 @@ static int dn_nl_fill_ifaddr(struct sk_buff *skb, struct dn_ifaddr *ifa,
 
        nlh = nlmsg_put(skb, pid, seq, event, sizeof(*ifm), flags);
        if (nlh == NULL)
-               return -ENOBUFS;
+               return -EMSGSIZE;
 
        ifm = nlmsg_data(nlh);
        ifm->ifa_family = AF_DECnet;
@@ -768,7 +768,8 @@ static int dn_nl_fill_ifaddr(struct sk_buff *skb, struct dn_ifaddr *ifa,
        return nlmsg_end(skb, nlh);
 
 nla_put_failure:
-       return nlmsg_cancel(skb, nlh);
+       nlmsg_cancel(skb, nlh);
+       return -EMSGSIZE;
 }
 
 static void dn_ifaddr_notify(int event, struct dn_ifaddr *ifa)
@@ -781,9 +782,12 @@ static void dn_ifaddr_notify(int event, struct dn_ifaddr *ifa)
                goto errout;
 
        err = dn_nl_fill_ifaddr(skb, ifa, 0, 0, event, 0);
-       /* failure implies BUG in dn_ifaddr_nlmsg_size() */
-       BUG_ON(err < 0);
-
+       if (err < 0) {
+               /* -EMSGSIZE implies BUG in dn_ifaddr_nlmsg_size() */
+               WARN_ON(err == -EMSGSIZE);
+               kfree_skb(skb);
+               goto errout;
+       }
        err = rtnl_notify(skb, 0, RTNLGRP_DECnet_IFADDR, NULL, GFP_KERNEL);
 errout:
        if (err < 0)
@@ -849,7 +853,7 @@ out:
        return rv;
 }
 
-/* 
+/*
  * Find a default address to bind to.
  *
  * This is one of those areas where the initial VMS concepts don't really
@@ -880,39 +884,39 @@ last_chance:
 
 static void dn_send_endnode_hello(struct net_device *dev, struct dn_ifaddr *ifa)
 {
-        struct endnode_hello_message *msg;
-        struct sk_buff *skb = NULL;
-        __le16 *pktlen;
+       struct endnode_hello_message *msg;
+       struct sk_buff *skb = NULL;
+       __le16 *pktlen;
        struct dn_dev *dn_db = (struct dn_dev *)dev->dn_ptr;
 
-        if ((skb = dn_alloc_skb(NULL, sizeof(*msg), GFP_ATOMIC)) == NULL)
+       if ((skb = dn_alloc_skb(NULL, sizeof(*msg), GFP_ATOMIC)) == NULL)
                return;
 
-        skb->dev = dev;
+       skb->dev = dev;
 
-        msg = (struct endnode_hello_message *)skb_put(skb,sizeof(*msg));
+       msg = (struct endnode_hello_message *)skb_put(skb,sizeof(*msg));
 
-        msg->msgflg  = 0x0D;
-        memcpy(msg->tiver, dn_eco_version, 3);
+       msg->msgflg  = 0x0D;
+       memcpy(msg->tiver, dn_eco_version, 3);
        dn_dn2eth(msg->id, ifa->ifa_local);
-        msg->iinfo   = DN_RT_INFO_ENDN;
-        msg->blksize = dn_htons(mtu2blksize(dev));
-        msg->area    = 0x00;
-        memset(msg->seed, 0, 8);
-        memcpy(msg->neighbor, dn_hiord, ETH_ALEN);
+       msg->iinfo   = DN_RT_INFO_ENDN;
+       msg->blksize = dn_htons(mtu2blksize(dev));
+       msg->area    = 0x00;
+       memset(msg->seed, 0, 8);
+       memcpy(msg->neighbor, dn_hiord, ETH_ALEN);
 
        if (dn_db->router) {
                struct dn_neigh *dn = (struct dn_neigh *)dn_db->router;
                dn_dn2eth(msg->neighbor, dn->addr);
        }
 
-        msg->timer   = dn_htons((unsigned short)dn_db->parms.t3);
-        msg->mpd     = 0x00;
-        msg->datalen = 0x02;
-        memset(msg->data, 0xAA, 2);
-        
-        pktlen = (__le16 *)skb_push(skb,2);
-        *pktlen = dn_htons(skb->len - 2);
+       msg->timer   = dn_htons((unsigned short)dn_db->parms.t3);
+       msg->mpd     = 0x00;
+       msg->datalen = 0x02;
+       memset(msg->data, 0xAA, 2);
+
+       pktlen = (__le16 *)skb_push(skb,2);
+       *pktlen = dn_htons(skb->len - 2);
 
        skb->nh.raw = skb->data;
 
@@ -982,11 +986,11 @@ static void dn_send_router_hello(struct net_device *dev, struct dn_ifaddr *ifa)
        dn_dn2eth(ptr, ifa->ifa_local);
        src = ptr;
        ptr += ETH_ALEN;
-       *ptr++ = dn_db->parms.forwarding == 1 ? 
+       *ptr++ = dn_db->parms.forwarding == 1 ?
                        DN_RT_INFO_L1RT : DN_RT_INFO_L2RT;
        *((__le16 *)ptr) = dn_htons(mtu2blksize(dev));
        ptr += 2;
-       *ptr++ = dn_db->parms.priority; /* Priority */ 
+       *ptr++ = dn_db->parms.priority; /* Priority */
        *ptr++ = 0; /* Area: Reserved */
        *((__le16 *)ptr) = dn_htons((unsigned short)dn_db->parms.t3);
        ptr += 2;
@@ -1404,18 +1408,18 @@ static char *dn_type2asc(char type)
 static int dn_dev_seq_show(struct seq_file *seq, void *v)
 {
        if (v == SEQ_START_TOKEN)
-               seq_puts(seq, "Name     Flags T1   Timer1 T3   Timer3 BlkSize Pri State DevType    Router Peer\n");
+               seq_puts(seq, "Name     Flags T1   Timer1 T3   Timer3 BlkSize Pri State DevType    Router Peer\n");
        else {
                struct net_device *dev = v;
                char peer_buf[DN_ASCBUF_LEN];
                char router_buf[DN_ASCBUF_LEN];
                struct dn_dev *dn_db = dev->dn_ptr;
 
-                seq_printf(seq, "%-8s %1s     %04u %04u   %04lu %04lu"
+               seq_printf(seq, "%-8s %1s     %04u %04u   %04lu %04lu"
                                "   %04hu    %03d %02x    %-10s %-7s %-7s\n",
-                               dev->name ? dev->name : "???",
-                               dn_type2asc(dn_db->parms.mode),
-                               0, 0,
+                               dev->name ? dev->name : "???",
+                               dn_type2asc(dn_db->parms.mode),
+                               0, 0,
                                dn_db->t3, dn_db->parms.t3,
                                mtu2blksize(dev),
                                dn_db->parms.priority,
@@ -1472,17 +1476,17 @@ MODULE_PARM_DESC(addr, "The DECnet address of this machine: area,node");
 
 void __init dn_dev_init(void)
 {
-        if (addr[0] > 63 || addr[0] < 0) {
-                printk(KERN_ERR "DECnet: Area must be between 0 and 63");
-                return;
-        }
+       if (addr[0] > 63 || addr[0] < 0) {
+               printk(KERN_ERR "DECnet: Area must be between 0 and 63");
+               return;
+       }
 
-        if (addr[1] > 1023 || addr[1] < 0) {
-                printk(KERN_ERR "DECnet: Node must be between 0 and 1023");
-                return;
-        }
+       if (addr[1] > 1023 || addr[1] < 0) {
+               printk(KERN_ERR "DECnet: Node must be between 0 and 1023");
+               return;
+       }
 
-        decnet_address = dn_htons((addr[0] << 10) | addr[1]);
+       decnet_address = dn_htons((addr[0] << 10) | addr[1]);
 
        dn_dev_devices_on();
 
index 1cf010124ec5ab6a96b2cd22b65171945af2a885..3cbfddc98430a5aa53cb59f0ff60d0a0eb5e6098 100644 (file)
@@ -527,7 +527,7 @@ int dn_fib_rtm_newroute(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
                return -EINVAL;
 
        tb = dn_fib_get_table(rtm_get_table(rta, r->rtm_table), 1);
-       if (tb) 
+       if (tb)
                return tb->insert(tb, r, (struct dn_kern_rta *)rta, nlh, &NETLINK_CB(skb));
 
        return -ENOBUFS;
@@ -654,80 +654,80 @@ static int dn_fib_dnaddr_event(struct notifier_block *this, unsigned long event,
 
 static int dn_fib_sync_down(__le16 local, struct net_device *dev, int force)
 {
-        int ret = 0;
-        int scope = RT_SCOPE_NOWHERE;
-
-        if (force)
-                scope = -1;
-
-        for_fib_info() {
-                /* 
-                 * This makes no sense for DECnet.... we will almost
-                 * certainly have more than one local address the same
-                 * over all our interfaces. It needs thinking about
-                 * some more.
-                 */
-                if (local && fi->fib_prefsrc == local) {
-                        fi->fib_flags |= RTNH_F_DEAD;
-                        ret++;
-                } else if (dev && fi->fib_nhs) {
-                        int dead = 0;
-
-                        change_nexthops(fi) {
-                                if (nh->nh_flags&RTNH_F_DEAD)
-                                        dead++;
-                                else if (nh->nh_dev == dev &&
-                                                nh->nh_scope != scope) {
+       int ret = 0;
+       int scope = RT_SCOPE_NOWHERE;
+
+       if (force)
+               scope = -1;
+
+       for_fib_info() {
+               /*
+                * This makes no sense for DECnet.... we will almost
+                * certainly have more than one local address the same
+                * over all our interfaces. It needs thinking about
+                * some more.
+                */
+               if (local && fi->fib_prefsrc == local) {
+                       fi->fib_flags |= RTNH_F_DEAD;
+                       ret++;
+               } else if (dev && fi->fib_nhs) {
+                       int dead = 0;
+
+                       change_nexthops(fi) {
+                               if (nh->nh_flags&RTNH_F_DEAD)
+                                       dead++;
+                               else if (nh->nh_dev == dev &&
+                                               nh->nh_scope != scope) {
                                        spin_lock_bh(&dn_fib_multipath_lock);
-                                        nh->nh_flags |= RTNH_F_DEAD;
-                                        fi->fib_power -= nh->nh_power;
-                                        nh->nh_power = 0;
+                                       nh->nh_flags |= RTNH_F_DEAD;
+                                       fi->fib_power -= nh->nh_power;
+                                       nh->nh_power = 0;
                                        spin_unlock_bh(&dn_fib_multipath_lock);
-                                        dead++;
-                                }
-                        } endfor_nexthops(fi)
-                        if (dead == fi->fib_nhs) {
-                                fi->fib_flags |= RTNH_F_DEAD;
-                                ret++;
-                        }
-                }
-        } endfor_fib_info();
-        return ret;
+                                       dead++;
+                               }
+                       } endfor_nexthops(fi)
+                       if (dead == fi->fib_nhs) {
+                               fi->fib_flags |= RTNH_F_DEAD;
+                               ret++;
+                       }
+               }
+       } endfor_fib_info();
+       return ret;
 }
 
 
 static int dn_fib_sync_up(struct net_device *dev)
 {
-        int ret = 0;
-
-        if (!(dev->flags&IFF_UP))
-                return 0;
-
-        for_fib_info() {
-                int alive = 0;
-
-                change_nexthops(fi) {
-                        if (!(nh->nh_flags&RTNH_F_DEAD)) {
-                                alive++;
-                                continue;
-                        }
-                        if (nh->nh_dev == NULL || !(nh->nh_dev->flags&IFF_UP))
-                                continue;
-                        if (nh->nh_dev != dev || dev->dn_ptr == NULL)
-                                continue;
-                        alive++;
+       int ret = 0;
+
+       if (!(dev->flags&IFF_UP))
+               return 0;
+
+       for_fib_info() {
+               int alive = 0;
+
+               change_nexthops(fi) {
+                       if (!(nh->nh_flags&RTNH_F_DEAD)) {
+                               alive++;
+                               continue;
+                       }
+                       if (nh->nh_dev == NULL || !(nh->nh_dev->flags&IFF_UP))
+                               continue;
+                       if (nh->nh_dev != dev || dev->dn_ptr == NULL)
+                               continue;
+                       alive++;
                        spin_lock_bh(&dn_fib_multipath_lock);
-                        nh->nh_power = 0;
-                        nh->nh_flags &= ~RTNH_F_DEAD;
+                       nh->nh_power = 0;
+                       nh->nh_flags &= ~RTNH_F_DEAD;
                        spin_unlock_bh(&dn_fib_multipath_lock);
-                } endfor_nexthops(fi);
-
-                if (alive > 0) {
-                        fi->fib_flags &= ~RTNH_F_DEAD;
-                        ret++;
-                }
-        } endfor_fib_info();
-        return ret;
+               } endfor_nexthops(fi);
+
+               if (alive > 0) {
+                       fi->fib_flags &= ~RTNH_F_DEAD;
+                       ret++;
+               }
+       } endfor_fib_info();
+       return ret;
 }
 
 static struct notifier_block dn_fib_dnaddr_notifier = {
index 7322bb36e825a1625ce4e130efbe02f2309634ab..11d692dfb4f382c61651a9e13198cd360dd48ee1 100644 (file)
@@ -3,7 +3,7 @@
  *              operating system.  DECnet is implemented using the  BSD Socket
  *              interface as the means of communication with the user level.
  *
- *              DECnet Neighbour Functions (Adjacency Database and 
+ *              DECnet Neighbour Functions (Adjacency Database and
  *                                                        On-Ethernet Cache)
  *
  * Author:      Steve Whitehouse <SteveW@ACM.org>
@@ -277,19 +277,19 @@ static int dn_short_output(struct sk_buff *skb)
        struct dn_skb_cb *cb = DN_SKB_CB(skb);
 
 
-        if (skb_headroom(skb) < headroom) {
-                struct sk_buff *skb2 = skb_realloc_headroom(skb, headroom);
-                if (skb2 == NULL) {
+       if (skb_headroom(skb) < headroom) {
+               struct sk_buff *skb2 = skb_realloc_headroom(skb, headroom);
+               if (skb2 == NULL) {
                        if (net_ratelimit())
-                               printk(KERN_CRIT "dn_short_output: no memory\n");
-                        kfree_skb(skb);
-                        return -ENOBUFS;
-                }
-                kfree_skb(skb);
-                skb = skb2;
+                               printk(KERN_CRIT "dn_short_output: no memory\n");
+                       kfree_skb(skb);
+                       return -ENOBUFS;
+               }
+               kfree_skb(skb);
+               skb = skb2;
                if (net_ratelimit())
-                       printk(KERN_INFO "dn_short_output: Increasing headroom\n");
-        }
+                       printk(KERN_INFO "dn_short_output: Increasing headroom\n");
+       }
 
        data = skb_push(skb, sizeof(struct dn_short_packet) + 2);
        *((__le16 *)data) = dn_htons(skb->len - 2);
index 39a6cf7fb5660b2cf4187a341e0868450c1de369..0f244e81a377ccd80f962e8b0fb1ecf5aee3ce4a 100644 (file)
@@ -33,7 +33,7 @@
 
 /******************************************************************************
     (c) 1995-1998 E.M. Serrat          emserrat@geocities.com
-    
+
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
     the Free Software Foundation; either version 2 of the License, or
@@ -63,7 +63,7 @@
 #include <asm/system.h>
 #include <linux/fcntl.h>
 #include <linux/mm.h>
-#include <linux/termios.h>      
+#include <linux/termios.h>
 #include <linux/interrupt.h>
 #include <linux/proc_fs.h>
 #include <linux/stat.h>
@@ -139,7 +139,7 @@ static int dn_process_ack(struct sock *sk, struct sk_buff *skb, int oth)
                ptr++;
                len += 2;
                if ((ack & 0x4000) == 0) {
-                       if (oth) 
+                       if (oth)
                                ack ^= 0x2000;
                        dn_ack(sk, skb, ack);
                }
@@ -152,7 +152,7 @@ static int dn_process_ack(struct sock *sk, struct sk_buff *skb, int oth)
                skb_pull(skb, 2);
                len += 2;
                if ((ack & 0x4000) == 0) {
-                       if (oth) 
+                       if (oth)
                                ack ^= 0x2000;
                        dn_ack(sk, skb, ack);
                }
@@ -349,9 +349,9 @@ static void dn_nsp_conn_conf(struct sock *sk, struct sk_buff *skb)
 
        if ((scp->state == DN_CI) || (scp->state == DN_CD)) {
                scp->persist = 0;
-                scp->addrrem = cb->src_port;
-                sk->sk_state = TCP_ESTABLISHED;
-                scp->state = DN_RUN;
+               scp->addrrem = cb->src_port;
+               sk->sk_state = TCP_ESTABLISHED;
+               scp->state = DN_RUN;
                scp->services_rem = cb->services;
                scp->info_rem = cb->info;
                scp->segsize_rem = cb->segsize;
@@ -366,13 +366,13 @@ static void dn_nsp_conn_conf(struct sock *sk, struct sk_buff *skb)
                                memcpy(scp->conndata_in.opt_data, skb->data + 1, dlen);
                        }
                }
-                dn_nsp_send_link(sk, DN_NOCHANGE, 0);
-                if (!sock_flag(sk, SOCK_DEAD))
-                       sk->sk_state_change(sk);
-        }
+               dn_nsp_send_link(sk, DN_NOCHANGE, 0);
+               if (!sock_flag(sk, SOCK_DEAD))
+                       sk->sk_state_change(sk);
+       }
 
 out:
-        kfree_skb(skb);
+       kfree_skb(skb);
 }
 
 static void dn_nsp_conn_ack(struct sock *sk, struct sk_buff *skb)
@@ -435,7 +435,7 @@ static void dn_nsp_disc_init(struct sock *sk, struct sk_buff *skb)
                sk->sk_state_change(sk);
        }
 
-       /* 
+       /*
         * It appears that its possible for remote machines to send disc
         * init messages with no port identifier if we are in the CI and
         * possibly also the CD state. Obviously we shouldn't reply with
@@ -519,7 +519,7 @@ static void dn_nsp_linkservice(struct sock *sk, struct sk_buff *skb)
 
        /*
         * Here we ignore erronous packets which should really
-        * should cause a connection abort. It is not critical 
+        * should cause a connection abort. It is not critical
         * for now though.
         */
        if (lsflags & 0xf8)
@@ -530,7 +530,7 @@ static void dn_nsp_linkservice(struct sock *sk, struct sk_buff *skb)
                switch(lsflags & 0x04) { /* FCVAL INT */
                case 0x00: /* Normal Request */
                        switch(lsflags & 0x03) { /* FCVAL MOD */
-                               case 0x00: /* Request count */
+                       case 0x00: /* Request count */
                                if (fcval < 0) {
                                        unsigned char p_fcval = -fcval;
                                        if ((scp->flowrem_dat > p_fcval) &&
@@ -541,7 +541,7 @@ static void dn_nsp_linkservice(struct sock *sk, struct sk_buff *skb)
                                        scp->flowrem_dat += fcval;
                                        wake_up = 1;
                                }
-                                       break;
+                               break;
                        case 0x01: /* Stop outgoing data */
                                scp->flowrem_sw = DN_DONTSEND;
                                break;
@@ -557,10 +557,10 @@ static void dn_nsp_linkservice(struct sock *sk, struct sk_buff *skb)
                                wake_up = 1;
                        }
                        break;
-                }
+               }
                if (wake_up && !sock_flag(sk, SOCK_DEAD))
                        sk->sk_state_change(sk);
-        }
+       }
 
        dn_nsp_send_oth_ack(sk);
 
@@ -576,38 +576,38 @@ out:
 static __inline__ int dn_queue_skb(struct sock *sk, struct sk_buff *skb, int sig, struct sk_buff_head *queue)
 {
        int err;
-       
-        /* Cast skb->rcvbuf to unsigned... It's pointless, but reduces
-           number of warnings when compiling with -W --ANK
-         */
-        if (atomic_read(&sk->sk_rmem_alloc) + skb->truesize >=
+
+       /* Cast skb->rcvbuf to unsigned... It's pointless, but reduces
+          number of warnings when compiling with -W --ANK
+        */
+       if (atomic_read(&sk->sk_rmem_alloc) + skb->truesize >=
            (unsigned)sk->sk_rcvbuf) {
-               err = -ENOMEM;
-               goto out;
-        }
+               err = -ENOMEM;
+               goto out;
+       }
 
        err = sk_filter(sk, skb);
        if (err)
                goto out;
 
-        skb_set_owner_r(skb, sk);
-        skb_queue_tail(queue, skb);
+       skb_set_owner_r(skb, sk);
+       skb_queue_tail(queue, skb);
 
        /* This code only runs from BH or BH protected context.
         * Therefore the plain read_lock is ok here. -DaveM
         */
        read_lock(&sk->sk_callback_lock);
-        if (!sock_flag(sk, SOCK_DEAD)) {
+       if (!sock_flag(sk, SOCK_DEAD)) {
                struct socket *sock = sk->sk_socket;
                wake_up_interruptible(sk->sk_sleep);
                if (sock && sock->fasync_list &&
                    !test_bit(SOCK_ASYNC_WAITDATA, &sock->flags))
-                       __kill_fasync(sock->fasync_list, sig, 
+                       __kill_fasync(sock->fasync_list, sig,
                                    (sig == SIGURG) ? POLL_PRI : POLL_IN);
        }
        read_unlock(&sk->sk_callback_lock);
 out:
-        return err;
+       return err;
 }
 
 static void dn_nsp_otherdata(struct sock *sk, struct sk_buff *skb)
@@ -652,16 +652,16 @@ static void dn_nsp_data(struct sock *sk, struct sk_buff *skb)
        skb_pull(skb, 2);
 
        if (seq_next(scp->numdat_rcv, segnum)) {
-                if (dn_queue_skb(sk, skb, SIGIO, &sk->sk_receive_queue) == 0) {
+               if (dn_queue_skb(sk, skb, SIGIO, &sk->sk_receive_queue) == 0) {
                        seq_add(&scp->numdat_rcv, 1);
-                       queued = 1;
-                }
+                       queued = 1;
+               }
 
                if ((scp->flowloc_sw == DN_SEND) && dn_congested(sk)) {
                        scp->flowloc_sw = DN_DONTSEND;
                        dn_nsp_send_link(sk, DN_DONTSEND, 0);
                }
-        }
+       }
 
        dn_nsp_send_data_ack(sk);
 out:
@@ -732,7 +732,7 @@ static int dn_nsp_rx_packet(struct sk_buff *skb)
        if (decnet_debug_level & 2)
                printk(KERN_DEBUG "dn_nsp_rx: Message type 0x%02x\n", (int)cb->nsp_flags);
 
-       if (cb->nsp_flags & 0x83) 
+       if (cb->nsp_flags & 0x83)
                goto free_out;
 
        /*
@@ -852,7 +852,7 @@ int dn_nsp_backlog_rcv(struct sock *sk, struct sk_buff *skb)
                        case 0x30:
                                dn_nsp_disc_init(sk, skb);
                                break;
-                       case 0x40:      
+                       case 0x40:
                                dn_nsp_disc_conf(sk, skb);
                                break;
                }
index b342e4e8f5f8c936b4efe57b393740cf6f64ad35..23d5ca88dfa363ca0093fbb461d48e1d6f1c6685 100644 (file)
@@ -26,7 +26,7 @@
 
 /******************************************************************************
     (c) 1995-1998 E.M. Serrat          emserrat@geocities.com
-    
+
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
     the Free Software Foundation; either version 2 of the License, or
@@ -55,7 +55,7 @@
 #include <asm/system.h>
 #include <linux/fcntl.h>
 #include <linux/mm.h>
-#include <linux/termios.h>      
+#include <linux/termios.h>
 #include <linux/interrupt.h>
 #include <linux/proc_fs.h>
 #include <linux/stat.h>
@@ -176,14 +176,14 @@ static void dn_nsp_rtt(struct sock *sk, long rtt)
         * gathering this value might turn out negative, so we make sure
         * that is it always positive here.
         */
-       if (rtt < 0) 
+       if (rtt < 0)
                rtt = -rtt;
        /*
         * Add new rtt to smoothed average
         */
        delta = ((rtt << 3) - srtt);
        srtt += (delta >> 3);
-       if (srtt >= 1) 
+       if (srtt >= 1)
                scp->nsp_srtt = (unsigned long)srtt;
        else
                scp->nsp_srtt = 1;
@@ -193,7 +193,7 @@ static void dn_nsp_rtt(struct sock *sk, long rtt)
         */
        delta >>= 1;
        rttvar += ((((delta>0)?(delta):(-delta)) - rttvar) >> 2);
-       if (rttvar >= 1) 
+       if (rttvar >= 1)
                scp->nsp_rttvar = (unsigned long)rttvar;
        else
                scp->nsp_rttvar = 1;
@@ -434,7 +434,7 @@ int dn_nsp_check_xmit_queue(struct sock *sk, struct sk_buff *skb, struct sk_buff
                 * further.
                 */
                if (xmit_count == 1) {
-                       if (dn_equal(segnum, acknum)) 
+                       if (dn_equal(segnum, acknum))
                                dn_nsp_rtt(sk, (long)(pkttime - reftime));
 
                        if (scp->snd_window < scp->max_window)
@@ -486,16 +486,16 @@ void dn_send_conn_ack (struct sock *sk)
 {
        struct dn_scp *scp = DN_SK(sk);
        struct sk_buff *skb = NULL;
-        struct nsp_conn_ack_msg *msg;
+       struct nsp_conn_ack_msg *msg;
 
        if ((skb = dn_alloc_skb(sk, 3, sk->sk_allocation)) == NULL)
                return;
 
-        msg = (struct nsp_conn_ack_msg *)skb_put(skb, 3);
-        msg->msgflg = 0x24;                   
+       msg = (struct nsp_conn_ack_msg *)skb_put(skb, 3);
+       msg->msgflg = 0x24;
        msg->dstaddr = scp->addrrem;
 
-       dn_nsp_send(skb);       
+       dn_nsp_send(skb);
 }
 
 void dn_nsp_delayed_ack(struct sock *sk)
@@ -523,25 +523,25 @@ void dn_send_conn_conf(struct sock *sk, gfp_t gfp)
 {
        struct dn_scp *scp = DN_SK(sk);
        struct sk_buff *skb = NULL;
-        struct nsp_conn_init_msg *msg;
+       struct nsp_conn_init_msg *msg;
        __u8 len = (__u8)dn_ntohs(scp->conndata_out.opt_optl);
 
        if ((skb = dn_alloc_skb(sk, 50 + len, gfp)) == NULL)
                return;
 
-        msg = (struct nsp_conn_init_msg *)skb_put(skb, sizeof(*msg));
-        msg->msgflg = 0x28;                   
+       msg = (struct nsp_conn_init_msg *)skb_put(skb, sizeof(*msg));
+       msg->msgflg = 0x28;
        msg->dstaddr = scp->addrrem;
-        msg->srcaddr = scp->addrloc;
-        msg->services = scp->services_loc;
-        msg->info = scp->info_loc;
-        msg->segsize = dn_htons(scp->segsize_loc);
+       msg->srcaddr = scp->addrloc;
+       msg->services = scp->services_loc;
+       msg->info = scp->info_loc;
+       msg->segsize = dn_htons(scp->segsize_loc);
 
        *skb_put(skb,1) = len;
 
-       if (len > 0) 
+       if (len > 0)
                memcpy(skb_put(skb, len), scp->conndata_out.opt_data, len);
-       
+
 
        dn_nsp_send(skb);
 
@@ -550,7 +550,7 @@ void dn_send_conn_conf(struct sock *sk, gfp_t gfp)
 }
 
 
-static __inline__ void dn_nsp_do_disc(struct sock *sk, unsigned char msgflg, 
+static __inline__ void dn_nsp_do_disc(struct sock *sk, unsigned char msgflg,
                        unsigned short reason, gfp_t gfp,
                        struct dst_entry *dst,
                        int ddl, unsigned char *dd, __le16 rem, __le16 loc)
@@ -593,7 +593,7 @@ static __inline__ void dn_nsp_do_disc(struct sock *sk, unsigned char msgflg,
 }
 
 
-void dn_nsp_send_disc(struct sock *sk, unsigned char msgflg, 
+void dn_nsp_send_disc(struct sock *sk, unsigned char msgflg,
                        unsigned short reason, gfp_t gfp)
 {
        struct dn_scp *scp = DN_SK(sk);
@@ -605,19 +605,19 @@ void dn_nsp_send_disc(struct sock *sk, unsigned char msgflg,
        if (reason == 0)
                reason = dn_ntohs(scp->discdata_out.opt_status);
 
-       dn_nsp_do_disc(sk, msgflg, reason, gfp, sk->sk_dst_cache, ddl, 
+       dn_nsp_do_disc(sk, msgflg, reason, gfp, sk->sk_dst_cache, ddl,
                scp->discdata_out.opt_data, scp->addrrem, scp->addrloc);
 }
 
 
-void dn_nsp_return_disc(struct sk_buff *skb, unsigned char msgflg, 
+void dn_nsp_return_disc(struct sk_buff *skb, unsigned char msgflg,
                        unsigned short reason)
 {
        struct dn_skb_cb *cb = DN_SKB_CB(skb);
        int ddl = 0;
        gfp_t gfp = GFP_ATOMIC;
 
-       dn_nsp_do_disc(NULL, msgflg, reason, gfp, skb->dst, ddl, 
+       dn_nsp_do_disc(NULL, msgflg, reason, gfp, skb->dst, ddl,
                        NULL, cb->src_port, cb->dst_port);
 }
 
@@ -676,8 +676,8 @@ void dn_nsp_send_conninit(struct sock *sk, unsigned char msgflg)
 
        msg->srcaddr    = scp->addrloc;
        msg->services   = scp->services_loc;    /* Requested flow control    */
-       msg->info       = scp->info_loc;        /* Version Number            */ 
-       msg->segsize    = dn_htons(scp->segsize_loc);   /* Max segment size  */ 
+       msg->info       = scp->info_loc;        /* Version Number            */
+       msg->segsize    = dn_htons(scp->segsize_loc);   /* Max segment size  */
 
        if (scp->peer.sdn_objnum)
                type = 0;
@@ -692,7 +692,7 @@ void dn_nsp_send_conninit(struct sock *sk, unsigned char msgflg)
                menuver |= DN_MENUVER_UIC;
 
        *skb_put(skb, 1) = menuver;     /* Menu Version         */
-       
+
        aux = scp->accessdata.acc_userl;
        *skb_put(skb, 1) = aux;
        if (aux > 0)
@@ -718,6 +718,6 @@ void dn_nsp_send_conninit(struct sock *sk, unsigned char msgflg)
 
        cb->rt_flags = DN_RT_F_RQR;
 
-       dn_nsp_send(skb);       
+       dn_nsp_send(skb);
 }
 
index 9881933167bd8e9ae497a60b8615a2118b0674da..efccc42ff1c606288a702851a09ac0f0db8f950a 100644 (file)
@@ -43,7 +43,7 @@
 
 /******************************************************************************
     (c) 1995-1998 E.M. Serrat          emserrat@geocities.com
-    
+
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
     the Free Software Foundation; either version 2 of the License, or
@@ -167,11 +167,11 @@ static void dn_dst_check_expire(unsigned long dummy)
                while((rt=*rtp) != NULL) {
                        if (atomic_read(&rt->u.dst.__refcnt) ||
                                        (now - rt->u.dst.lastuse) < expire) {
-                               rtp = &rt->u.rt_next;
+                               rtp = &rt->u.dst.dn_next;
                                continue;
                        }
-                       *rtp = rt->u.rt_next;
-                       rt->u.rt_next = NULL;
+                       *rtp = rt->u.dst.dn_next;
+                       rt->u.dst.dn_next = NULL;
                        dnrt_free(rt);
                }
                spin_unlock(&dn_rt_hash_table[i].lock);
@@ -198,11 +198,11 @@ static int dn_dst_gc(void)
                while((rt=*rtp) != NULL) {
                        if (atomic_read(&rt->u.dst.__refcnt) ||
                                        (now - rt->u.dst.lastuse) < expire) {
-                               rtp = &rt->u.rt_next;
+                               rtp = &rt->u.dst.dn_next;
                                continue;
                        }
-                       *rtp = rt->u.rt_next;
-                       rt->u.rt_next = NULL;
+                       *rtp = rt->u.dst.dn_next;
+                       rt->u.dst.dn_next = NULL;
                        dnrt_drop(rt);
                        break;
                }
@@ -246,7 +246,7 @@ static void dn_dst_update_pmtu(struct dst_entry *dst, u32 mtu)
        }
 }
 
-/* 
+/*
  * When a route has been marked obsolete. (e.g. routing cache flush)
  */
 static struct dst_entry *dn_dst_check(struct dst_entry *dst, __u32 cookie)
@@ -286,8 +286,8 @@ static int dn_insert_route(struct dn_route *rt, unsigned hash, struct dn_route *
        while((rth = *rthp) != NULL) {
                if (compare_keys(&rth->fl, &rt->fl)) {
                        /* Put it first */
-                       *rthp = rth->u.rt_next;
-                       rcu_assign_pointer(rth->u.rt_next,
+                       *rthp = rth->u.dst.dn_next;
+                       rcu_assign_pointer(rth->u.dst.dn_next,
                                           dn_rt_hash_table[hash].chain);
                        rcu_assign_pointer(dn_rt_hash_table[hash].chain, rth);
 
@@ -300,12 +300,12 @@ static int dn_insert_route(struct dn_route *rt, unsigned hash, struct dn_route *
                        *rp = rth;
                        return 0;
                }
-               rthp = &rth->u.rt_next;
+               rthp = &rth->u.dst.dn_next;
        }
 
-       rcu_assign_pointer(rt->u.rt_next, dn_rt_hash_table[hash].chain);
+       rcu_assign_pointer(rt->u.dst.dn_next, dn_rt_hash_table[hash].chain);
        rcu_assign_pointer(dn_rt_hash_table[hash].chain, rt);
-       
+
        dst_hold(&rt->u.dst);
        rt->u.dst.__use++;
        rt->u.dst.lastuse = now;
@@ -326,8 +326,8 @@ void dn_run_flush(unsigned long dummy)
                        goto nothing_to_declare;
 
                for(; rt; rt=next) {
-                       next = rt->u.rt_next;
-                       rt->u.rt_next = NULL;
+                       next = rt->u.dst.dn_next;
+                       rt->u.dst.dn_next = NULL;
                        dst_free((struct dst_entry *)rt);
                }
 
@@ -506,23 +506,23 @@ static int dn_route_rx_long(struct sk_buff *skb)
        skb_pull(skb, 20);
        skb->h.raw = skb->data;
 
-        /* Destination info */
-        ptr += 2;
+       /* Destination info */
+       ptr += 2;
        cb->dst = dn_eth2dn(ptr);
-        if (memcmp(ptr, dn_hiord_addr, 4) != 0)
-                goto drop_it;
-        ptr += 6;
+       if (memcmp(ptr, dn_hiord_addr, 4) != 0)
+               goto drop_it;
+       ptr += 6;
 
 
-        /* Source info */
-        ptr += 2;
+       /* Source info */
+       ptr += 2;
        cb->src = dn_eth2dn(ptr);
-        if (memcmp(ptr, dn_hiord_addr, 4) != 0)
-                goto drop_it;
-        ptr += 6;
-        /* Other junk */
-        ptr++;
-        cb->hops = *ptr++; /* Visit Count */
+       if (memcmp(ptr, dn_hiord_addr, 4) != 0)
+               goto drop_it;
+       ptr += 6;
+       /* Other junk */
+       ptr++;
+       cb->hops = *ptr++; /* Visit Count */
 
        return NF_HOOK(PF_DECnet, NF_DN_PRE_ROUTING, skb, skb->dev, NULL, dn_route_rx_packet);
 
@@ -545,16 +545,16 @@ static int dn_route_rx_short(struct sk_buff *skb)
        skb->h.raw = skb->data;
 
        cb->dst = *(__le16 *)ptr;
-        ptr += 2;
-        cb->src = *(__le16 *)ptr;
-        ptr += 2;
-        cb->hops = *ptr & 0x3f;
+       ptr += 2;
+       cb->src = *(__le16 *)ptr;
+       ptr += 2;
+       cb->hops = *ptr & 0x3f;
 
        return NF_HOOK(PF_DECnet, NF_DN_PRE_ROUTING, skb, skb->dev, NULL, dn_route_rx_packet);
 
 drop_it:
-        kfree_skb(skb);
-        return NET_RX_DROP;
+       kfree_skb(skb);
+       return NET_RX_DROP;
 }
 
 static int dn_route_discard(struct sk_buff *skb)
@@ -626,20 +626,20 @@ int dn_route_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type
        cb->rt_flags = flags;
 
        if (decnet_debug_level & 1)
-               printk(KERN_DEBUG 
+               printk(KERN_DEBUG
                        "dn_route_rcv: got 0x%02x from %s [%d %d %d]\n",
-                       (int)flags, (dev) ? dev->name : "???", len, skb->len, 
+                       (int)flags, (dev) ? dev->name : "???", len, skb->len,
                        padlen);
 
-        if (flags & DN_RT_PKT_CNTL) {
+       if (flags & DN_RT_PKT_CNTL) {
                if (unlikely(skb_linearize(skb)))
                        goto dump_it;
 
-                switch(flags & DN_RT_CNTL_MSK) {
-                       case DN_RT_PKT_INIT:
+               switch(flags & DN_RT_CNTL_MSK) {
+                       case DN_RT_PKT_INIT:
                                dn_dev_init_pkt(skb);
                                break;
-                       case DN_RT_PKT_VERI:
+                       case DN_RT_PKT_VERI:
                                dn_dev_veri_pkt(skb);
                                break;
                }
@@ -648,31 +648,31 @@ int dn_route_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type
                        goto dump_it;
 
                switch(flags & DN_RT_CNTL_MSK) {
-                       case DN_RT_PKT_HELO:
+                       case DN_RT_PKT_HELO:
                                return NF_HOOK(PF_DECnet, NF_DN_HELLO, skb, skb->dev, NULL, dn_route_ptp_hello);
 
-                       case DN_RT_PKT_L1RT:
-                       case DN_RT_PKT_L2RT:
-                                return NF_HOOK(PF_DECnet, NF_DN_ROUTE, skb, skb->dev, NULL, dn_route_discard);
-                       case DN_RT_PKT_ERTH:
+                       case DN_RT_PKT_L1RT:
+                       case DN_RT_PKT_L2RT:
+                               return NF_HOOK(PF_DECnet, NF_DN_ROUTE, skb, skb->dev, NULL, dn_route_discard);
+                       case DN_RT_PKT_ERTH:
                                return NF_HOOK(PF_DECnet, NF_DN_HELLO, skb, skb->dev, NULL, dn_neigh_router_hello);
 
-                       case DN_RT_PKT_EEDH:
+                       case DN_RT_PKT_EEDH:
                                return NF_HOOK(PF_DECnet, NF_DN_HELLO, skb, skb->dev, NULL, dn_neigh_endnode_hello);
-                }
-        } else {
+               }
+       } else {
                if (dn->parms.state != DN_DEV_S_RU)
                        goto dump_it;
 
                skb_pull(skb, 1); /* Pull flags */
 
-                switch(flags & DN_RT_PKT_MSK) {
-                       case DN_RT_PKT_LONG:
-                               return dn_route_rx_long(skb);
-                       case DN_RT_PKT_SHORT:
-                               return dn_route_rx_short(skb);
+               switch(flags & DN_RT_PKT_MSK) {
+                       case DN_RT_PKT_LONG:
+                               return dn_route_rx_long(skb);
+                       case DN_RT_PKT_SHORT:
+                               return dn_route_rx_short(skb);
                }
-        }
+       }
 
 dump_it:
        kfree_skb(skb);
@@ -815,8 +815,8 @@ static int dn_rt_set_next_hop(struct dn_route *rt, struct dn_fib_res *res)
                rt->u.dst.neighbour = n;
        }
 
-       if (rt->u.dst.metrics[RTAX_MTU-1] == 0 || 
-            rt->u.dst.metrics[RTAX_MTU-1] > rt->u.dst.dev->mtu)
+       if (rt->u.dst.metrics[RTAX_MTU-1] == 0 ||
+           rt->u.dst.metrics[RTAX_MTU-1] > rt->u.dst.dev->mtu)
                rt->u.dst.metrics[RTAX_MTU-1] = rt->u.dst.dev->mtu;
        mss = dn_mss_from_pmtu(dev, dst_mtu(&rt->u.dst));
        if (rt->u.dst.metrics[RTAX_ADVMSS-1] == 0 ||
@@ -876,7 +876,7 @@ static inline __le16 dn_fib_rules_map_destination(__le16 daddr, struct dn_fib_re
 
 static int dn_route_output_slow(struct dst_entry **pprt, const struct flowi *oldflp, int try_hard)
 {
-       struct flowi fl = { .nl_u = { .dn_u = 
+       struct flowi fl = { .nl_u = { .dn_u =
                                      { .daddr = oldflp->fld_dst,
                                        .saddr = oldflp->fld_src,
                                        .scope = RT_SCOPE_UNIVERSE,
@@ -899,7 +899,7 @@ static int dn_route_output_slow(struct dst_entry **pprt, const struct flowi *old
                       "dn_route_output_slow: dst=%04x src=%04x mark=%d"
                       " iif=%d oif=%d\n", dn_ntohs(oldflp->fld_dst),
                       dn_ntohs(oldflp->fld_src),
-                       oldflp->mark, loopback_dev.ifindex, oldflp->oif);
+                      oldflp->mark, loopback_dev.ifindex, oldflp->oif);
 
        /* If we have an output interface, verify its a DECnet device */
        if (oldflp->oif) {
@@ -982,19 +982,19 @@ source_ok:
                if (err != -ESRCH)
                        goto out;
                /*
-                * Here the fallback is basically the standard algorithm for 
+                * Here the fallback is basically the standard algorithm for
                 * routing in endnodes which is described in the DECnet routing
                 * docs
                 *
                 * If we are not trying hard, look in neighbour cache.
                 * The result is tested to ensure that if a specific output
-                * device/source address was requested, then we honour that 
+                * device/source address was requested, then we honour that
                 * here
                 */
                if (!try_hard) {
                        neigh = neigh_lookup_nodev(&dn_neigh_table, &fl.fld_dst);
                        if (neigh) {
-                               if ((oldflp->oif && 
+                               if ((oldflp->oif &&
                                    (neigh->dev->ifindex != oldflp->oif)) ||
                                    (oldflp->fld_src &&
                                    (!dn_dev_islocal(neigh->dev,
@@ -1044,7 +1044,7 @@ select_source:
                if (fl.fld_src == 0) {
                        fl.fld_src = dnet_select_source(dev_out, gateway,
                                                         res.type == RTN_LOCAL ?
-                                                        RT_SCOPE_HOST : 
+                                                        RT_SCOPE_HOST :
                                                         RT_SCOPE_LINK);
                        if (fl.fld_src == 0 && res.type != RTN_LOCAL)
                                goto e_addr;
@@ -1074,14 +1074,14 @@ select_source:
        if (res.fi->fib_nhs > 1 && fl.oif == 0)
                dn_fib_select_multipath(&fl, &res);
 
-       /* 
+       /*
         * We could add some logic to deal with default routes here and
         * get rid of some of the special casing above.
         */
 
        if (!fl.fld_src)
                fl.fld_src = DN_FIB_RES_PREFSRC(res);
-       
+
        if (dev_out)
                dev_put(dev_out);
        dev_out = DN_FIB_RES_DEV(res);
@@ -1144,8 +1144,8 @@ out:
        return err;
 
 e_addr:
-        err = -EADDRNOTAVAIL;
-        goto done;
+       err = -EADDRNOTAVAIL;
+       goto done;
 e_inval:
        err = -EINVAL;
        goto done;
@@ -1169,7 +1169,7 @@ static int __dn_route_output_key(struct dst_entry **pprt, const struct flowi *fl
        if (!(flags & MSG_TRYHARD)) {
                rcu_read_lock_bh();
                for(rt = rcu_dereference(dn_rt_hash_table[hash].chain); rt;
-                       rt = rcu_dereference(rt->u.rt_next)) {
+                       rt = rcu_dereference(rt->u.dst.dn_next)) {
                        if ((flp->fld_dst == rt->fl.fld_dst) &&
                            (flp->fld_src == rt->fl.fld_src) &&
                            (flp->mark == rt->fl.mark) &&
@@ -1223,7 +1223,7 @@ static int dn_route_input_slow(struct sk_buff *skb)
        int flags = 0;
        __le16 gateway = 0;
        __le16 local_src = 0;
-       struct flowi fl = { .nl_u = { .dn_u = 
+       struct flowi fl = { .nl_u = { .dn_u =
                                     { .daddr = cb->dst,
                                       .saddr = cb->src,
                                       .scope = RT_SCOPE_UNIVERSE,
@@ -1311,7 +1311,7 @@ static int dn_route_input_slow(struct sk_buff *skb)
                if (res.fi->fib_nhs > 1 && fl.oif == 0)
                        dn_fib_select_multipath(&fl, &res);
 
-               /* 
+               /*
                 * Check for out_dev == in_dev. We use the RTCF_DOREDIRECT
                 * flag as a hint to set the intra-ethernet bit when
                 * forwarding. If we've got NAT in operation, we don't do
@@ -1443,9 +1443,9 @@ int dn_route_input(struct sk_buff *skb)
 
        rcu_read_lock();
        for(rt = rcu_dereference(dn_rt_hash_table[hash].chain); rt != NULL;
-           rt = rcu_dereference(rt->u.rt_next)) {
+           rt = rcu_dereference(rt->u.dst.dn_next)) {
                if ((rt->fl.fld_src == cb->src) &&
-                   (rt->fl.fld_dst == cb->dst) &&
+                   (rt->fl.fld_dst == cb->dst) &&
                    (rt->fl.oif == 0) &&
                    (rt->fl.mark == skb->mark) &&
                    (rt->fl.iif == cb->iif)) {
@@ -1514,8 +1514,8 @@ static int dn_rt_fill_info(struct sk_buff *skb, u32 pid, u32 seq,
 
 nlmsg_failure:
 rtattr_failure:
-        skb_trim(skb, b - skb->data);
-        return -1;
+       skb_trim(skb, b - skb->data);
+       return -1;
 }
 
 /*
@@ -1627,12 +1627,12 @@ int dn_cache_dump(struct sk_buff *skb, struct netlink_callback *cb)
                rcu_read_lock_bh();
                for(rt = rcu_dereference(dn_rt_hash_table[h].chain), idx = 0;
                        rt;
-                       rt = rcu_dereference(rt->u.rt_next), idx++) {
+                       rt = rcu_dereference(rt->u.dst.dn_next), idx++) {
                        if (idx < s_idx)
                                continue;
                        skb->dst = dst_clone(&rt->u.dst);
                        if (dn_rt_fill_info(skb, NETLINK_CB(cb->skb).pid,
-                                       cb->nlh->nlmsg_seq, RTM_NEWROUTE, 
+                                       cb->nlh->nlmsg_seq, RTM_NEWROUTE,
                                        1, NLM_F_MULTI) <= 0) {
                                dst_release(xchg(&skb->dst, NULL));
                                rcu_read_unlock_bh();
@@ -1673,7 +1673,7 @@ static struct dn_route *dn_rt_cache_get_next(struct seq_file *seq, struct dn_rou
 {
        struct dn_rt_cache_iter_state *s = rcu_dereference(seq->private);
 
-       rt = rt->u.rt_next;
+       rt = rt->u.dst.dn_next;
        while(!rt) {
                rcu_read_unlock_bh();
                if (--s->bucket < 0)
@@ -1721,7 +1721,7 @@ static int dn_rt_cache_seq_show(struct seq_file *seq, void *v)
                        rt->u.dst.__use,
                        (int) dst_metric(&rt->u.dst, RTAX_RTT));
        return 0;
-} 
+}
 
 static struct seq_operations dn_rt_cache_seq_ops = {
        .start  = dn_rt_cache_seq_start,
@@ -1778,38 +1778,38 @@ void __init dn_route_init(void)
        for(order = 0; (1UL << order) < goal; order++)
                /* NOTHING */;
 
-        /*
-         * Only want 1024 entries max, since the table is very, very unlikely
-         * to be larger than that.
-         */
-        while(order && ((((1UL << order) * PAGE_SIZE) / 
-                                sizeof(struct dn_rt_hash_bucket)) >= 2048))
-                order--;
-
-        do {
-                dn_rt_hash_mask = (1UL << order) * PAGE_SIZE /
-                        sizeof(struct dn_rt_hash_bucket);
-                while(dn_rt_hash_mask & (dn_rt_hash_mask - 1))
-                        dn_rt_hash_mask--;
-                dn_rt_hash_table = (struct dn_rt_hash_bucket *)
-                        __get_free_pages(GFP_ATOMIC, order);
-        } while (dn_rt_hash_table == NULL && --order > 0);
+       /*
+        * Only want 1024 entries max, since the table is very, very unlikely
+        * to be larger than that.
+        */
+       while(order && ((((1UL << order) * PAGE_SIZE) /
+                               sizeof(struct dn_rt_hash_bucket)) >= 2048))
+               order--;
+
+       do {
+               dn_rt_hash_mask = (1UL << order) * PAGE_SIZE /
+                       sizeof(struct dn_rt_hash_bucket);
+               while(dn_rt_hash_mask & (dn_rt_hash_mask - 1))
+                       dn_rt_hash_mask--;
+               dn_rt_hash_table = (struct dn_rt_hash_bucket *)
+                       __get_free_pages(GFP_ATOMIC, order);
+       } while (dn_rt_hash_table == NULL && --order > 0);
 
        if (!dn_rt_hash_table)
-                panic("Failed to allocate DECnet route cache hash table\n");
+               panic("Failed to allocate DECnet route cache hash table\n");
 
-       printk(KERN_INFO 
-               "DECnet: Routing cache hash table of %u buckets, %ldKbytes\n", 
-               dn_rt_hash_mask, 
+       printk(KERN_INFO
+               "DECnet: Routing cache hash table of %u buckets, %ldKbytes\n",
+               dn_rt_hash_mask,
                (long)(dn_rt_hash_mask*sizeof(struct dn_rt_hash_bucket))/1024);
 
        dn_rt_hash_mask--;
-        for(i = 0; i <= dn_rt_hash_mask; i++) {
-                spin_lock_init(&dn_rt_hash_table[i].lock);
-                dn_rt_hash_table[i].chain = NULL;
-        }
+       for(i = 0; i <= dn_rt_hash_mask; i++) {
+               spin_lock_init(&dn_rt_hash_table[i].lock);
+               dn_rt_hash_table[i].chain = NULL;
+       }
 
-        dn_dst_ops.gc_thresh = (dn_rt_hash_mask + 1);
+       dn_dst_ops.gc_thresh = (dn_rt_hash_mask + 1);
 
        proc_net_fops_create("decnet_cache", S_IRUGO, &dn_rt_cache_seq_fops);
 }
index e32d0c3d5a96a3e3ec5b040ef4b1d365e68b4125..b6c98ac93dc8737d96e54ac7f00dacacf90ae6f4 100644 (file)
@@ -151,10 +151,10 @@ static int dn_fib_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
        }
 
        if (tb[FRA_SRC])
-               r->src = nla_get_u16(tb[FRA_SRC]);
+               r->src = nla_get_le16(tb[FRA_SRC]);
 
        if (tb[FRA_DST])
-               r->dst = nla_get_u16(tb[FRA_DST]);
+               r->dst = nla_get_le16(tb[FRA_DST]);
 
        r->src_len = frh->src_len;
        r->srcmask = dnet_make_mask(r->src_len);
@@ -176,10 +176,10 @@ static int dn_fib_rule_compare(struct fib_rule *rule, struct fib_rule_hdr *frh,
        if (frh->dst_len && (r->dst_len != frh->dst_len))
                return 0;
 
-       if (tb[FRA_SRC] && (r->src != nla_get_u16(tb[FRA_SRC])))
+       if (tb[FRA_SRC] && (r->src != nla_get_le16(tb[FRA_SRC])))
                return 0;
 
-       if (tb[FRA_DST] && (r->dst != nla_get_u16(tb[FRA_DST])))
+       if (tb[FRA_DST] && (r->dst != nla_get_le16(tb[FRA_DST])))
                return 0;
 
        return 1;
@@ -214,9 +214,9 @@ static int dn_fib_rule_fill(struct fib_rule *rule, struct sk_buff *skb,
        frh->tos = 0;
 
        if (r->dst_len)
-               NLA_PUT_U16(skb, FRA_DST, r->dst);
+               NLA_PUT_LE16(skb, FRA_DST, r->dst);
        if (r->src_len)
-               NLA_PUT_U16(skb, FRA_SRC, r->src);
+               NLA_PUT_LE16(skb, FRA_SRC, r->src);
 
        return 0;
 
index 13b2421991bac8618b5fb27f139a9a2a42bdb4f3..780a141f8342c93c880b53245cbddaa2103cdc7b 100644 (file)
@@ -60,7 +60,7 @@ struct dn_hash
 #define dz_prefix(key,dz)      ((key).datum)
 
 #define for_nexthops(fi) { int nhsel; const struct dn_fib_nh *nh;\
-        for(nhsel = 0, nh = (fi)->fib_nh; nhsel < (fi)->fib_nhs; nh++, nhsel++)
+       for(nhsel = 0, nh = (fi)->fib_nh; nhsel < (fi)->fib_nhs; nh++, nhsel++)
 
 #define endfor_nexthops(fi) }
 
@@ -290,94 +290,97 @@ static inline size_t dn_fib_nlmsg_size(struct dn_fib_info *fi)
 }
 
 static int dn_fib_dump_info(struct sk_buff *skb, u32 pid, u32 seq, int event,
-                        u32 tb_id, u8 type, u8 scope, void *dst, int dst_len,
-                        struct dn_fib_info *fi, unsigned int flags)
+                       u32 tb_id, u8 type, u8 scope, void *dst, int dst_len,
+                       struct dn_fib_info *fi, unsigned int flags)
 {
-        struct rtmsg *rtm;
-        struct nlmsghdr *nlh;
-        unsigned char *b = skb->tail;
-
-        nlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*rtm), flags);
-        rtm = NLMSG_DATA(nlh);
-        rtm->rtm_family = AF_DECnet;
-        rtm->rtm_dst_len = dst_len;
-        rtm->rtm_src_len = 0;
-        rtm->rtm_tos = 0;
-        rtm->rtm_table = tb_id;
+       struct rtmsg *rtm;
+       struct nlmsghdr *nlh;
+       unsigned char *b = skb->tail;
+
+       nlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*rtm), flags);
+       rtm = NLMSG_DATA(nlh);
+       rtm->rtm_family = AF_DECnet;
+       rtm->rtm_dst_len = dst_len;
+       rtm->rtm_src_len = 0;
+       rtm->rtm_tos = 0;
+       rtm->rtm_table = tb_id;
        RTA_PUT_U32(skb, RTA_TABLE, tb_id);
-        rtm->rtm_flags = fi->fib_flags;
-        rtm->rtm_scope = scope;
+       rtm->rtm_flags = fi->fib_flags;
+       rtm->rtm_scope = scope;
        rtm->rtm_type  = type;
-        if (rtm->rtm_dst_len)
-                RTA_PUT(skb, RTA_DST, 2, dst);
-        rtm->rtm_protocol = fi->fib_protocol;
-        if (fi->fib_priority)
-                RTA_PUT(skb, RTA_PRIORITY, 4, &fi->fib_priority);
+       if (rtm->rtm_dst_len)
+               RTA_PUT(skb, RTA_DST, 2, dst);
+       rtm->rtm_protocol = fi->fib_protocol;
+       if (fi->fib_priority)
+               RTA_PUT(skb, RTA_PRIORITY, 4, &fi->fib_priority);
        if (rtnetlink_put_metrics(skb, fi->fib_metrics) < 0)
                goto rtattr_failure;
-        if (fi->fib_nhs == 1) {
-                if (fi->fib_nh->nh_gw)
-                        RTA_PUT(skb, RTA_GATEWAY, 2, &fi->fib_nh->nh_gw);
-                if (fi->fib_nh->nh_oif)
-                        RTA_PUT(skb, RTA_OIF, sizeof(int), &fi->fib_nh->nh_oif);
-        }
-        if (fi->fib_nhs > 1) {
-                struct rtnexthop *nhp;
-                struct rtattr *mp_head;
-                if (skb_tailroom(skb) <= RTA_SPACE(0))
-                        goto rtattr_failure;
-                mp_head = (struct rtattr *)skb_put(skb, RTA_SPACE(0));
-
-                for_nexthops(fi) {
-                        if (skb_tailroom(skb) < RTA_ALIGN(RTA_ALIGN(sizeof(*nhp)) + 4))
-                                goto rtattr_failure;
-                        nhp = (struct rtnexthop *)skb_put(skb, RTA_ALIGN(sizeof(*nhp)));
-                        nhp->rtnh_flags = nh->nh_flags & 0xFF;
-                        nhp->rtnh_hops = nh->nh_weight - 1;
-                        nhp->rtnh_ifindex = nh->nh_oif;
-                        if (nh->nh_gw)
-                                RTA_PUT(skb, RTA_GATEWAY, 2, &nh->nh_gw);
-                        nhp->rtnh_len = skb->tail - (unsigned char *)nhp;
-                } endfor_nexthops(fi);
-                mp_head->rta_type = RTA_MULTIPATH;
-                mp_head->rta_len = skb->tail - (u8*)mp_head;
-        }
-
-        nlh->nlmsg_len = skb->tail - b;
-        return skb->len;
+       if (fi->fib_nhs == 1) {
+               if (fi->fib_nh->nh_gw)
+                       RTA_PUT(skb, RTA_GATEWAY, 2, &fi->fib_nh->nh_gw);
+               if (fi->fib_nh->nh_oif)
+                       RTA_PUT(skb, RTA_OIF, sizeof(int), &fi->fib_nh->nh_oif);
+       }
+       if (fi->fib_nhs > 1) {
+               struct rtnexthop *nhp;
+               struct rtattr *mp_head;
+               if (skb_tailroom(skb) <= RTA_SPACE(0))
+                       goto rtattr_failure;
+               mp_head = (struct rtattr *)skb_put(skb, RTA_SPACE(0));
+
+               for_nexthops(fi) {
+                       if (skb_tailroom(skb) < RTA_ALIGN(RTA_ALIGN(sizeof(*nhp)) + 4))
+                               goto rtattr_failure;
+                       nhp = (struct rtnexthop *)skb_put(skb, RTA_ALIGN(sizeof(*nhp)));
+                       nhp->rtnh_flags = nh->nh_flags & 0xFF;
+                       nhp->rtnh_hops = nh->nh_weight - 1;
+                       nhp->rtnh_ifindex = nh->nh_oif;
+                       if (nh->nh_gw)
+                               RTA_PUT(skb, RTA_GATEWAY, 2, &nh->nh_gw);
+                       nhp->rtnh_len = skb->tail - (unsigned char *)nhp;
+               } endfor_nexthops(fi);
+               mp_head->rta_type = RTA_MULTIPATH;
+               mp_head->rta_len = skb->tail - (u8*)mp_head;
+       }
+
+       nlh->nlmsg_len = skb->tail - b;
+       return skb->len;
 
 
 nlmsg_failure:
 rtattr_failure:
-        skb_trim(skb, b - skb->data);
-        return -1;
+       skb_trim(skb, b - skb->data);
+       return -EMSGSIZE;
 }
 
 
 static void dn_rtmsg_fib(int event, struct dn_fib_node *f, int z, u32 tb_id,
-                        struct nlmsghdr *nlh, struct netlink_skb_parms *req)
+                       struct nlmsghdr *nlh, struct netlink_skb_parms *req)
 {
-        struct sk_buff *skb;
-        u32 pid = req ? req->pid : 0;
+       struct sk_buff *skb;
+       u32 pid = req ? req->pid : 0;
        int err = -ENOBUFS;
 
-        skb = nlmsg_new(dn_fib_nlmsg_size(DN_FIB_INFO(f)), GFP_KERNEL);
-        if (skb == NULL)
+       skb = nlmsg_new(dn_fib_nlmsg_size(DN_FIB_INFO(f)), GFP_KERNEL);
+       if (skb == NULL)
                goto errout;
 
-        err = dn_fib_dump_info(skb, pid, nlh->nlmsg_seq, event, tb_id,
+       err = dn_fib_dump_info(skb, pid, nlh->nlmsg_seq, event, tb_id,
                               f->fn_type, f->fn_scope, &f->fn_key, z,
                               DN_FIB_INFO(f), 0);
-       /* failure implies BUG in dn_fib_nlmsg_size() */
-       BUG_ON(err < 0);
-
+       if (err < 0) {
+               /* -EMSGSIZE implies BUG in dn_fib_nlmsg_size() */
+               WARN_ON(err == -EMSGSIZE);
+               kfree_skb(skb);
+               goto errout;
+       }
        err = rtnl_notify(skb, pid, RTNLGRP_DECnet_ROUTE, nlh, GFP_KERNEL);
 errout:
        if (err < 0)
                rtnl_set_sk_err(RTNLGRP_DECnet_ROUTE, err);
 }
 
-static __inline__ int dn_hash_dump_bucket(struct sk_buff *skb, 
+static __inline__ int dn_hash_dump_bucket(struct sk_buff *skb,
                                struct netlink_callback *cb,
                                struct dn_fib_table *tb,
                                struct dn_zone *dz,
@@ -391,12 +394,12 @@ static __inline__ int dn_hash_dump_bucket(struct sk_buff *skb,
                        continue;
                if (f->fn_state & DN_S_ZOMBIE)
                        continue;
-               if (dn_fib_dump_info(skb, NETLINK_CB(cb->skb).pid, 
+               if (dn_fib_dump_info(skb, NETLINK_CB(cb->skb).pid,
                                cb->nlh->nlmsg_seq,
                                RTM_NEWROUTE,
-                               tb->n, 
+                               tb->n,
                                (f->fn_state & DN_S_ZOMBIE) ? 0 : f->fn_type,
-                               f->fn_scope, &f->fn_key, dz->dz_order, 
+                               f->fn_scope, &f->fn_key, dz->dz_order,
                                f->fn_info, NLM_F_MULTI) < 0) {
                        cb->args[4] = i;
                        return -1;
@@ -406,7 +409,7 @@ static __inline__ int dn_hash_dump_bucket(struct sk_buff *skb,
        return skb->len;
 }
 
-static __inline__ int dn_hash_dump_zone(struct sk_buff *skb, 
+static __inline__ int dn_hash_dump_zone(struct sk_buff *skb,
                                struct netlink_callback *cb,
                                struct dn_fib_table *tb,
                                struct dn_zone *dz)
@@ -430,10 +433,10 @@ static __inline__ int dn_hash_dump_zone(struct sk_buff *skb,
        return skb->len;
 }
 
-static int dn_fib_table_dump(struct dn_fib_table *tb, struct sk_buff *skb, 
-                                struct netlink_callback *cb)
+static int dn_fib_table_dump(struct dn_fib_table *tb, struct sk_buff *skb,
+                               struct netlink_callback *cb)
 {
-        int m, s_m;
+       int m, s_m;
        struct dn_zone *dz;
        struct dn_hash *table = (struct dn_hash *)tb->data;
 
@@ -454,7 +457,7 @@ static int dn_fib_table_dump(struct dn_fib_table *tb, struct sk_buff *skb,
        read_unlock(&dn_fib_tables_lock);
        cb->args[2] = m;
 
-        return skb->len;
+       return skb->len;
 }
 
 int dn_fib_dump(struct sk_buff *skb, struct netlink_callback *cb)
@@ -479,7 +482,7 @@ int dn_fib_dump(struct sk_buff *skb, struct netlink_callback *cb)
                                goto next;
                        if (dumped)
                                memset(&cb->args[2], 0, sizeof(cb->args) -
-                                                2 * sizeof(cb->args[0]));
+                                                2 * sizeof(cb->args[0]));
                        if (tb->dump(tb, skb, cb) < 0)
                                goto out;
                        dumped = 1;
@@ -500,13 +503,13 @@ static int dn_fib_table_insert(struct dn_fib_table *tb, struct rtmsg *r, struct
        struct dn_fib_node *new_f, *f, **fp, **del_fp;
        struct dn_zone *dz;
        struct dn_fib_info *fi;
-        int z = r->rtm_dst_len;
+       int z = r->rtm_dst_len;
        int type = r->rtm_type;
        dn_fib_key_t key;
-        int err;
+       int err;
 
-        if (z > 16)
-                return -EINVAL;
+       if (z > 16)
+               return -EINVAL;
 
        dz = table->dh_zones[z];
        if (!dz && !(dz = dn_new_zone(table, z)))
@@ -521,8 +524,8 @@ static int dn_fib_table_insert(struct dn_fib_table *tb, struct rtmsg *r, struct
                key = dz_key(dst, dz);
        }
 
-        if ((fi = dn_fib_create_info(r, rta, n, &err)) == NULL)
-                return err;
+       if ((fi = dn_fib_create_info(r, rta, n, &err)) == NULL)
+               return err;
 
        if (dz->dz_nent > (dz->dz_divisor << 2) &&
                        dz->dz_divisor > DN_MAX_DIVISOR &&
@@ -590,12 +593,10 @@ create:
 
 replace:
        err = -ENOBUFS;
-       new_f = kmem_cache_alloc(dn_hash_kmem, GFP_KERNEL);
+       new_f = kmem_cache_zalloc(dn_hash_kmem, GFP_KERNEL);
        if (new_f == NULL)
                goto out;
 
-       memset(new_f, 0, sizeof(struct dn_fib_node));
-
        new_f->fn_key = key;
        new_f->fn_type = type;
        new_f->fn_scope = r->rtm_scope;
@@ -623,9 +624,9 @@ replace:
                dn_rt_cache_flush(-1);
        }
 
-        dn_rtmsg_fib(RTM_NEWROUTE, new_f, z, tb->n, n, req);
+       dn_rtmsg_fib(RTM_NEWROUTE, new_f, z, tb->n, n, req);
 
-        return 0;
+       return 0;
 out:
        dn_fib_release_info(fi);
        return err;
@@ -636,14 +637,14 @@ static int dn_fib_table_delete(struct dn_fib_table *tb, struct rtmsg *r, struct
 {
        struct dn_hash *table = (struct dn_hash*)tb->data;
        struct dn_fib_node **fp, **del_fp, *f;
-        int z = r->rtm_dst_len;
+       int z = r->rtm_dst_len;
        struct dn_zone *dz;
        dn_fib_key_t key;
        int matched;
 
 
-        if (z > 16)
-                return -EINVAL;
+       if (z > 16)
+               return -EINVAL;
 
        if ((dz = table->dh_zones[z]) == NULL)
                return -ESRCH;
@@ -679,7 +680,7 @@ static int dn_fib_table_delete(struct dn_fib_table *tb, struct rtmsg *r, struct
                if (del_fp == NULL &&
                                (!r->rtm_type || f->fn_type == r->rtm_type) &&
                                (r->rtm_scope == RT_SCOPE_NOWHERE || f->fn_scope == r->rtm_scope) &&
-                               (!r->rtm_protocol || 
+                               (!r->rtm_protocol ||
                                        fi->fib_protocol == r->rtm_protocol) &&
                                dn_fib_nh_match(r, n, rta, fi) == 0)
                        del_fp = fp;
@@ -687,7 +688,7 @@ static int dn_fib_table_delete(struct dn_fib_table *tb, struct rtmsg *r, struct
 
        if (del_fp) {
                f = *del_fp;
-               dn_rtmsg_fib(RTM_DELROUTE, f, z, tb->n, n, req);
+               dn_rtmsg_fib(RTM_DELROUTE, f, z, tb->n, n, req);
 
                if (matched != 1) {
                        write_lock_bh(&dn_fib_tables_lock);
@@ -711,7 +712,7 @@ static int dn_fib_table_delete(struct dn_fib_table *tb, struct rtmsg *r, struct
                return 0;
        }
 
-        return -ESRCH;
+       return -ESRCH;
 }
 
 static inline int dn_flush_list(struct dn_fib_node **fp, int z, struct dn_hash *table)
@@ -758,7 +759,7 @@ static int dn_fib_table_flush(struct dn_fib_table *tb)
 
 static int dn_fib_table_lookup(struct dn_fib_table *tb, const struct flowi *flp, struct dn_fib_res *res)
 {
-        int err;
+       int err;
        struct dn_zone *dz;
        struct dn_hash *t = (struct dn_hash *)tb->data;
 
@@ -787,7 +788,7 @@ static int dn_fib_table_lookup(struct dn_fib_table *tb, const struct flowi *flp,
 
                        if (err == 0) {
                                res->type = f->fn_type;
-                               res->scope = f->fn_scope; 
+                               res->scope = f->fn_scope;
                                res->prefixlen = dz->dz_order;
                                goto out;
                        }
@@ -798,21 +799,21 @@ static int dn_fib_table_lookup(struct dn_fib_table *tb, const struct flowi *flp,
        err = 1;
 out:
        read_unlock(&dn_fib_tables_lock);
-        return err;
+       return err;
 }
 
 
 struct dn_fib_table *dn_fib_get_table(u32 n, int create)
 {
-        struct dn_fib_table *t;
+       struct dn_fib_table *t;
        struct hlist_node *node;
        unsigned int h;
 
-        if (n < RT_TABLE_MIN)
-                return NULL;
+       if (n < RT_TABLE_MIN)
+               return NULL;
 
-        if (n > RT_TABLE_MAX)
-                return NULL;
+       if (n > RT_TABLE_MAX)
+               return NULL;
 
        h = n & (DN_FIB_TABLE_HASHSZ - 1);
        rcu_read_lock();
@@ -824,54 +825,54 @@ struct dn_fib_table *dn_fib_get_table(u32 n, int create)
        }
        rcu_read_unlock();
 
-        if (!create)
-                return NULL;
+       if (!create)
+               return NULL;
 
-        if (in_interrupt() && net_ratelimit()) {
-                printk(KERN_DEBUG "DECnet: BUG! Attempt to create routing table from interrupt\n"); 
-                return NULL;
-        }
+       if (in_interrupt() && net_ratelimit()) {
+               printk(KERN_DEBUG "DECnet: BUG! Attempt to create routing table from interrupt\n");
+               return NULL;
+       }
 
-        t = kzalloc(sizeof(struct dn_fib_table) + sizeof(struct dn_hash),
+       t = kzalloc(sizeof(struct dn_fib_table) + sizeof(struct dn_hash),
                    GFP_KERNEL);
-        if (t == NULL)
-                return NULL;
-
-        t->n = n;
-        t->insert = dn_fib_table_insert;
-        t->delete = dn_fib_table_delete;
-        t->lookup = dn_fib_table_lookup;
-        t->flush  = dn_fib_table_flush;
-        t->dump = dn_fib_table_dump;
+       if (t == NULL)
+               return NULL;
+
+       t->n = n;
+       t->insert = dn_fib_table_insert;
+       t->delete = dn_fib_table_delete;
+       t->lookup = dn_fib_table_lookup;
+       t->flush  = dn_fib_table_flush;
+       t->dump = dn_fib_table_dump;
        hlist_add_head_rcu(&t->hlist, &dn_fib_table_hash[h]);
 
-        return t;
+       return t;
 }
 
 struct dn_fib_table *dn_fib_empty_table(void)
 {
-        u32 id;
+       u32 id;
 
-        for(id = RT_TABLE_MIN; id <= RT_TABLE_MAX; id++)
+       for(id = RT_TABLE_MIN; id <= RT_TABLE_MAX; id++)
                if (dn_fib_get_table(id, 0) == NULL)
-                        return dn_fib_get_table(id, 1);
-        return NULL;
+                       return dn_fib_get_table(id, 1);
+       return NULL;
 }
 
 void dn_fib_flush(void)
 {
-        int flushed = 0;
-        struct dn_fib_table *tb;
+       int flushed = 0;
+       struct dn_fib_table *tb;
        struct hlist_node *node;
        unsigned int h;
 
        for (h = 0; h < DN_FIB_TABLE_HASHSZ; h++) {
                hlist_for_each_entry(tb, node, &dn_fib_table_hash[h], hlist)
-                       flushed += tb->flush(tb);
-        }
+                       flushed += tb->flush(tb);
+       }
 
-        if (flushed)
-                dn_rt_cache_flush(-1);
+       if (flushed)
+               dn_rt_cache_flush(-1);
 }
 
 void __init dn_fib_table_init(void)
@@ -891,7 +892,7 @@ void __exit dn_fib_table_cleanup(void)
        write_lock(&dn_fib_tables_lock);
        for (h = 0; h < DN_FIB_TABLE_HASHSZ; h++) {
                hlist_for_each_entry_safe(t, node, next, &dn_fib_table_hash[h],
-                                         hlist) {
+                                         hlist) {
                        hlist_del(&t->hlist);
                        kfree(t);
                }
index 8b99bd33540d53fc072278aa6ade21906a541f90..0e62def05a58b38f589b5594db24f140bdc07132 100644 (file)
@@ -138,7 +138,7 @@ static int __init dn_rtmsg_init(void)
        int rv = 0;
 
        dnrmg = netlink_kernel_create(NETLINK_DNRTMSG, DNRNG_NLGRP_MAX,
-                                     dnrmg_receive_user_sk, THIS_MODULE);
+                                     dnrmg_receive_user_sk, THIS_MODULE);
        if (dnrmg == NULL) {
                printk(KERN_ERR "dn_rtmsg: Cannot create netlink socket");
                return -ENOMEM;
index a4065eb1341eba834db319faec739d8a46e8c93f..a6c067b593ab480d4757610e1361cb447647369b 100644 (file)
@@ -164,7 +164,7 @@ static int dn_node_address_strategy(ctl_table *table, int __user *name, int nlen
        return 0;
 }
 
-static int dn_node_address_handler(ctl_table *table, int write, 
+static int dn_node_address_handler(ctl_table *table, int write,
                                struct file *filp,
                                void __user *buffer,
                                size_t *lenp, loff_t *ppos)
@@ -240,7 +240,7 @@ static int dn_def_dev_strategy(ctl_table *table, int __user *name, int nlen,
                        }
 
                        namel = strlen(devname) + 1;
-                       if (len > namel) len = namel;   
+                       if (len > namel) len = namel;
 
                        if (copy_to_user(oldval, devname, len))
                                return -EFAULT;
@@ -275,7 +275,7 @@ static int dn_def_dev_strategy(ctl_table *table, int __user *name, int nlen,
 }
 
 
-static int dn_def_dev_handler(ctl_table *table, int write, 
+static int dn_def_dev_handler(ctl_table *table, int write,
                                struct file * filp,
                                void __user *buffer,
                                size_t *lenp, loff_t *ppos)
@@ -341,17 +341,17 @@ static int dn_def_dev_handler(ctl_table *table, int write,
 
 static ctl_table dn_table[] = {
        {
-               .ctl_name = NET_DECNET_NODE_ADDRESS, 
-               .procname = "node_address", 
-               .maxlen = 7, 
-               .mode = 0644, 
+               .ctl_name = NET_DECNET_NODE_ADDRESS,
+               .procname = "node_address",
+               .maxlen = 7,
+               .mode = 0644,
                .proc_handler = dn_node_address_handler,
                .strategy = dn_node_address_strategy,
        },
        {
                .ctl_name = NET_DECNET_NODE_NAME,
                .procname = "node_name",
-               .data = node_name, 
+               .data = node_name,
                .maxlen = 7,
                .mode = 0644,
                .proc_handler = &proc_dostring,
@@ -359,8 +359,8 @@ static ctl_table dn_table[] = {
        },
        {
                .ctl_name = NET_DECNET_DEFAULT_DEVICE,
-               .procname = "default_device", 
-               .maxlen = 16, 
+               .procname = "default_device",
+               .maxlen = 16,
                .mode = 0644,
                .proc_handler = dn_def_dev_handler,
                .strategy = dn_def_dev_strategy,
@@ -432,32 +432,32 @@ static ctl_table dn_table[] = {
                .extra2 = &max_decnet_no_fc_max_cwnd
        },
        {
-                .ctl_name = NET_DECNET_MEM,
-                .procname = "decnet_mem",
-                .data = &sysctl_decnet_mem,
-                .maxlen = sizeof(sysctl_decnet_mem),
-                .mode = 0644,
-                .proc_handler = &proc_dointvec,
-                .strategy = &sysctl_intvec,
-        },
-        {
-                .ctl_name = NET_DECNET_RMEM,
-                .procname = "decnet_rmem",
-                .data = &sysctl_decnet_rmem,
-                .maxlen = sizeof(sysctl_decnet_rmem),
-                .mode = 0644,
-                .proc_handler = &proc_dointvec,
-                .strategy = &sysctl_intvec,
-        },
-        {
-                .ctl_name = NET_DECNET_WMEM,
-                .procname = "decnet_wmem",
-                .data = &sysctl_decnet_wmem,
-                .maxlen = sizeof(sysctl_decnet_wmem),
-                .mode = 0644,
-                .proc_handler = &proc_dointvec,
-                .strategy = &sysctl_intvec,
-        },
+               .ctl_name = NET_DECNET_MEM,
+               .procname = "decnet_mem",
+               .data = &sysctl_decnet_mem,
+               .maxlen = sizeof(sysctl_decnet_mem),
+               .mode = 0644,
+               .proc_handler = &proc_dointvec,
+               .strategy = &sysctl_intvec,
+       },
+       {
+               .ctl_name = NET_DECNET_RMEM,
+               .procname = "decnet_rmem",
+               .data = &sysctl_decnet_rmem,
+               .maxlen = sizeof(sysctl_decnet_rmem),
+               .mode = 0644,
+               .proc_handler = &proc_dointvec,
+               .strategy = &sysctl_intvec,
+       },
+       {
+               .ctl_name = NET_DECNET_WMEM,
+               .procname = "decnet_wmem",
+               .data = &sysctl_decnet_wmem,
+               .maxlen = sizeof(sysctl_decnet_wmem),
+               .mode = 0644,
+               .proc_handler = &proc_dointvec,
+               .strategy = &sysctl_intvec,
+       },
        {
                .ctl_name = NET_DECNET_DEBUG_LEVEL,
                .procname = "debug",
@@ -472,18 +472,18 @@ static ctl_table dn_table[] = {
 
 static ctl_table dn_dir_table[] = {
        {
-               .ctl_name = NET_DECNET, 
-               .procname = "decnet", 
-               .mode = 0555, 
+               .ctl_name = NET_DECNET,
+               .procname = "decnet",
+               .mode = 0555,
                .child = dn_table},
        {0}
 };
 
 static ctl_table dn_root_table[] = {
        {
-               .ctl_name = CTL_NET, 
-               .procname = "net", 
-               .mode = 0555, 
+               .ctl_name = CTL_NET,
+               .procname = "net",
+               .mode = 0555,
                .child = dn_dir_table
        },
        {0}
index 4d66aac134835fb082044c26041c6f6039e3ba24..f2ce4143429018b33b9da9093d2dd913439152f2 100644 (file)
@@ -139,7 +139,7 @@ static int econet_recvmsg(struct kiocb *iocb, struct socket *sock,
        skb=skb_recv_datagram(sk,flags,flags&MSG_DONTWAIT,&err);
 
        /*
-        *      An error occurred so return it. Because skb_recv_datagram() 
+        *      An error occurred so return it. Because skb_recv_datagram()
         *      handles the blocking we don't see and worry about blocking
         *      retries.
         */
@@ -190,15 +190,15 @@ static int econet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len
        struct sockaddr_ec *sec = (struct sockaddr_ec *)uaddr;
        struct sock *sk;
        struct econet_sock *eo;
-       
+
        /*
         *      Check legality
         */
-        
+
        if (addr_len < sizeof(struct sockaddr_ec) ||
            sec->sec_family != AF_ECONET)
                return -EINVAL;
-       
+
        mutex_lock(&econet_mutex);
 
        sk = sock->sk;
@@ -283,18 +283,18 @@ static int econet_sendmsg(struct kiocb *iocb, struct socket *sock,
        int i;
        mm_segment_t oldfs;
 #endif
-               
+
        /*
-        *      Check the flags. 
+        *      Check the flags.
         */
 
-       if (msg->msg_flags & ~(MSG_DONTWAIT|MSG_CMSG_COMPAT)) 
+       if (msg->msg_flags & ~(MSG_DONTWAIT|MSG_CMSG_COMPAT))
                return -EINVAL;
 
        /*
-        *      Get and verify the address. 
+        *      Get and verify the address.
         */
-        
+
        mutex_lock(&econet_mutex);
 
        if (saddr == NULL) {
@@ -339,17 +339,17 @@ static int econet_sendmsg(struct kiocb *iocb, struct socket *sock,
                unsigned short proto = 0;
 
                dev_hold(dev);
-               
-               skb = sock_alloc_send_skb(sk, len+LL_RESERVED_SPACE(dev), 
+
+               skb = sock_alloc_send_skb(sk, len+LL_RESERVED_SPACE(dev),
                                          msg->msg_flags & MSG_DONTWAIT, &err);
                if (skb==NULL)
                        goto out_unlock;
-               
+
                skb_reserve(skb, LL_RESERVED_SPACE(dev));
                skb->nh.raw = skb->data;
-               
+
                eb = (struct ec_cb *)&skb->cb;
-               
+
                /* BUG: saddr may be NULL */
                eb->cookie = saddr->cookie;
                eb->sec = *saddr;
@@ -359,7 +359,7 @@ static int econet_sendmsg(struct kiocb *iocb, struct socket *sock,
                        int res;
                        struct ec_framehdr *fh;
                        err = -EINVAL;
-                       res = dev->hard_header(skb, dev, ntohs(proto), 
+                       res = dev->hard_header(skb, dev, ntohs(proto),
                                               &addr, NULL, len);
                        /* Poke in our control byte and
                           port number.  Hack, hack.  */
@@ -372,7 +372,7 @@ static int econet_sendmsg(struct kiocb *iocb, struct socket *sock,
                        } else if (res < 0)
                                goto out_free;
                }
-               
+
                /* Copy the data. Returns -EFAULT on error */
                err = memcpy_fromiovec(skb_put(skb,len), msg->msg_iov, len);
                skb->protocol = proto;
@@ -380,15 +380,15 @@ static int econet_sendmsg(struct kiocb *iocb, struct socket *sock,
                skb->priority = sk->sk_priority;
                if (err)
                        goto out_free;
-               
+
                err = -ENETDOWN;
                if (!(dev->flags & IFF_UP))
                        goto out_free;
-               
+
                /*
                 *      Now send it
                 */
-               
+
                dev_queue_xmit(skb);
                dev_put(dev);
                mutex_unlock(&econet_mutex);
@@ -414,7 +414,7 @@ static int econet_sendmsg(struct kiocb *iocb, struct socket *sock,
                mutex_unlock(&econet_mutex);
                return -ENETDOWN;               /* No socket - can't send */
        }
-       
+
        /* Make up a UDP datagram and hand it off to some higher intellect. */
 
        memset(&udpdest, 0, sizeof(udpdest));
@@ -432,7 +432,7 @@ static int econet_sendmsg(struct kiocb *iocb, struct socket *sock,
                idev = __in_dev_get_rcu(dev);
                if (idev) {
                        if (idev->ifa_list)
-                               network = ntohl(idev->ifa_list->ifa_address) & 
+                               network = ntohl(idev->ifa_list->ifa_address) &
                                        0xffffff00;             /* !!! */
                }
                rcu_read_unlock();
@@ -470,7 +470,7 @@ static int econet_sendmsg(struct kiocb *iocb, struct socket *sock,
        }
 
        /* Get a skbuff (no data, just holds our cb information) */
-       if ((skb = sock_alloc_send_skb(sk, 0, 
+       if ((skb = sock_alloc_send_skb(sk, 0,
                                       msg->msg_flags & MSG_DONTWAIT,
                                       &err)) == NULL) {
                mutex_unlock(&econet_mutex);
@@ -660,7 +660,7 @@ static int ec_dev_ioctl(struct socket *sock, unsigned int cmd, void __user *arg)
        if (copy_from_user(&ifr, arg, sizeof(struct ifreq)))
                return -EFAULT;
 
-       if ((dev = dev_get_by_name(ifr.ifr_name)) == NULL) 
+       if ((dev = dev_get_by_name(ifr.ifr_name)) == NULL)
                return -ENODEV;
 
        sec = (struct sockaddr_ec *)&ifr.ifr_addr;
@@ -754,7 +754,7 @@ static const struct proto_ops econet_ops = {
        .connect =      sock_no_connect,
        .socketpair =   sock_no_socketpair,
        .accept =       sock_no_accept,
-       .getname =      econet_getname, 
+       .getname =      econet_getname,
        .poll =         datagram_poll,
        .ioctl =        econet_ioctl,
        .listen =       sock_no_listen,
@@ -780,7 +780,7 @@ static struct sock *ec_listening_socket(unsigned char port, unsigned char
 
        sk_for_each(sk, node, &econet_sklist) {
                struct econet_sock *opt = ec_sk(sk);
-               if ((opt->port == port || opt->port == 0) && 
+               if ((opt->port == port || opt->port == 0) &&
                    (opt->station == station || opt->station == 0) &&
                    (opt->net == net || opt->net == 0))
                        goto found;
@@ -815,7 +815,7 @@ static int ec_queue_packet(struct sock *sk, struct sk_buff *skb,
 
 #ifdef CONFIG_ECONET_AUNUDP
 /*
- *     Send an AUN protocol response. 
+ *     Send an AUN protocol response.
  */
 
 static void aun_send_response(__u32 addr, unsigned long seq, int code, int cb)
@@ -828,7 +828,7 @@ static void aun_send_response(__u32 addr, unsigned long seq, int code, int cb)
        struct aunhdr ah = {.code = code, .cb = cb, .handle = seq};
        struct kvec iov = {.iov_base = (void *)&ah, .iov_len = sizeof(ah)};
        struct msghdr udpmsg;
-       
+
        udpmsg.msg_name = (void *)&sin;
        udpmsg.msg_namelen = sizeof(sin);
        udpmsg.msg_control = NULL;
@@ -858,7 +858,7 @@ static void aun_incoming(struct sk_buff *skb, struct aunhdr *ah, size_t len)
        if ((sk = ec_listening_socket(ah->port, stn, edev->net)) == NULL)
                goto bad;               /* Nobody wants it */
 
-       newskb = alloc_skb((len - sizeof(struct aunhdr) + 15) & ~15, 
+       newskb = alloc_skb((len - sizeof(struct aunhdr) + 15) & ~15,
                           GFP_ATOMIC);
        if (newskb == NULL)
        {
@@ -867,7 +867,7 @@ static void aun_incoming(struct sk_buff *skb, struct aunhdr *ah, size_t len)
                goto bad;
        }
 
-       memcpy(skb_put(newskb, len - sizeof(struct aunhdr)), (void *)(ah+1), 
+       memcpy(skb_put(newskb, len - sizeof(struct aunhdr)), (void *)(ah+1),
               len - sizeof(struct aunhdr));
 
        if (ec_queue_packet(sk, newskb, stn, edev->net, ah->cb, ah->port))
@@ -990,7 +990,7 @@ static void ab_cleanup(unsigned long h)
                struct ec_cb *eb = (struct ec_cb *)&skb->cb;
                if ((jiffies - eb->start) > eb->timeout)
                {
-                       tx_result(skb->sk, eb->cookie, 
+                       tx_result(skb->sk, eb->cookie,
                                  ECTYPE_TRANSMIT_NOT_PRESENT);
                        skb_unlink(skb, &aun_queue);
                        kfree_skb(skb);
@@ -1024,11 +1024,11 @@ static int __init aun_udp_initialise(void)
                printk("AUN: socket error %d\n", -error);
                return error;
        }
-       
+
        udpsock->sk->sk_reuse = 1;
        udpsock->sk->sk_allocation = GFP_ATOMIC; /* we're going to call it
                                                    from interrupts */
-       
+
        error = udpsock->ops->bind(udpsock, (struct sockaddr *)&sin,
                                sizeof(sin));
        if (error < 0)
index 2d31bf3f05c551e6cf3d6e4117cd2c98df81e661..766a0b59c0d37451030bc17c5420c52c5a0d6ff3 100644 (file)
  *             Mark Evans, <evansmp@uhura.aston.ac.uk>
  *             Florian  La Roche, <rzsfl@rz.uni-sb.de>
  *             Alan Cox, <gw4pts@gw4pts.ampr.org>
- * 
+ *
  * Fixes:
  *             Mr Linux        : Arp problems
  *             Alan Cox        : Generic queue tidyup (very tiny here)
  *             Alan Cox        : eth_header ntohs should be htons
  *             Alan Cox        : eth_rebuild_header missing an htons and
  *                               minor other things.
- *             Tegge           : Arp bug fixes. 
+ *             Tegge           : Arp bug fixes.
  *             Florian         : Removed many unnecessary functions, code cleanup
  *                               and changes for new arp and skbuff.
  *             Alan Cox        : Redid header building to reflect new format.
@@ -307,9 +307,9 @@ void ether_setup(struct net_device *dev)
        dev->hard_header_len    = ETH_HLEN;
        dev->mtu                = ETH_DATA_LEN;
        dev->addr_len           = ETH_ALEN;
-       dev->tx_queue_len       = 1000; /* Ethernet wants good queues */        
+       dev->tx_queue_len       = 1000; /* Ethernet wants good queues */
        dev->flags              = IFF_BROADCAST|IFF_MULTICAST;
-       
+
        memset(dev->broadcast, 0xFF, ETH_ALEN);
 
 }
index 7a95c3d8131425bb8c42bbabcb629747f06672f0..ec6d8851a06103e96e89f1b6cc5db8305cc371fe 100644 (file)
@@ -97,7 +97,7 @@ static int prism2_wep_build_iv(struct sk_buff *skb, int hdr_len,
        struct prism2_wep_data *wep = priv;
        u32 klen, len;
        u8 *pos;
-       
+
        if (skb_headroom(skb) < 4 || skb->len < hdr_len)
                return -1;
 
@@ -146,17 +146,17 @@ static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
        /* other checks are in prism2_wep_build_iv */
        if (skb_tailroom(skb) < 4)
                return -1;
-       
+
        /* add the IV to the frame */
        if (prism2_wep_build_iv(skb, hdr_len, NULL, 0, priv))
                return -1;
-       
+
        /* Copy the IV into the first 3 bytes of the key */
        memcpy(key, skb->data + hdr_len, 3);
 
        /* Copy rest of the WEP key (the secret part) */
        memcpy(key + 3, wep->key, wep->key_len);
-       
+
        len = skb->len - hdr_len - 4;
        pos = skb->data + hdr_len + 4;
        klen = 3 + wep->key_len;
index d97e5412e31b43a670b21364580f346bc5829734..4084909f6f924220becc534f557d5ab778ad6bb9 100644 (file)
@@ -663,7 +663,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
         * any security data (IV, ICV, etc) that was left behind */
        if (!can_be_decrypted && (fc & IEEE80211_FCTL_PROTECTED) &&
            ieee->host_strip_iv_icv) {
-               int trimlen = 0;
+               int trimlen = 0;
 
                /* Top two-bits of byte 3 are the key index */
                if (skb->len >= hdrlen + 3)
@@ -852,7 +852,7 @@ void ieee80211_rx_any(struct ieee80211_device *ieee,
 
        if ((fc & IEEE80211_FCTL_VERS) != 0)
                goto drop_free;
-               
+
        switch (fc & IEEE80211_FCTL_FTYPE) {
        case IEEE80211_FTYPE_MGMT:
                if (skb->len < sizeof(struct ieee80211_hdr_3addr))
@@ -1489,7 +1489,7 @@ static void update_network(struct ieee80211_network *dst,
 
        /* We only update the statistics if they were created by receiving
         * the network information on the actual channel the network is on.
-        * 
+        *
         * This keeps beacons received on neighbor channels from bringing
         * down the signal level of an AP. */
        if (dst->channel == src->stats.received_channel)
index 854fc13cd78d0b057dbf40812293f86b1a0716cb..c55949e5c58a990b923e747977e8e536c0f7a5fd 100644 (file)
@@ -54,7 +54,7 @@ Desc. | ctrl | dura |  DA/RA  |   TA    |    SA   | Sequ |  Frame  |  fcs |
       |      | tion | (BSSID) |         |         | ence |  data   |      |
       `--------------------------------------------------|         |------'
 Total: 28 non-data bytes                                 `----.----'
-                                                              |
+                                                             |
        .- 'Frame data' expands, if WEP enabled, to <----------'
        |
        V
@@ -64,8 +64,8 @@ Bytes |  4  |   0-2296  |  4  |
 Desc. | IV  | Encrypted | ICV |
       |     | Packet    |     |
       `-----|           |-----'
-            `-----.-----'
-                  |
+           `-----.-----'
+                 |
        .- 'Encrypted Packet' expands to
        |
        V
index 5cb9cfd35397dadc60c66a0048945ec88a57d8a0..40d7a55fe03e8158d49b85e8dd18da705cf3250f 100644 (file)
@@ -754,7 +754,7 @@ int ieee80211_wx_set_auth(struct net_device *dev,
        int err = 0;
 
        spin_lock_irqsave(&ieee->lock, flags);
-       
+
        switch (wrqu->param.flags & IW_AUTH_INDEX) {
        case IW_AUTH_WPA_VERSION:
        case IW_AUTH_CIPHER_PAIRWISE:
@@ -799,7 +799,7 @@ int ieee80211_wx_get_auth(struct net_device *dev,
        int err = 0;
 
        spin_lock_irqsave(&ieee->lock, flags);
-       
+
        switch (wrqu->param.flags & IW_AUTH_INDEX) {
        case IW_AUTH_WPA_VERSION:
        case IW_AUTH_CIPHER_PAIRWISE:
index a824852909e45b6fd3ab4dc27735921ffc9f9d6a..cc8110bdd5799359e95be983db36ba1616b6dff1 100644 (file)
@@ -30,7 +30,7 @@
  * Overview
  *
  * Before you can associate, you have to authenticate.
- * 
+ *
  */
 
 /* Sends out an association request to the desired AP */
@@ -41,10 +41,10 @@ ieee80211softmac_assoc(struct ieee80211softmac_device *mac, struct ieee80211soft
 
        /* Switch to correct channel for this network */
        mac->set_channel(mac->dev, net->channel);
-       
+
        /* Send association request */
        ieee80211softmac_send_mgt_frame(mac, net, IEEE80211_STYPE_ASSOC_REQ, 0);
-       
+
        dprintk(KERN_INFO PFX "sent association request!\n");
 
        spin_lock_irqsave(&mac->lock, flags);
@@ -153,7 +153,7 @@ network_matches_request(struct ieee80211softmac_device *mac, struct ieee80211_ne
        }
 
        /* if 'ANY' network requested, take any that doesn't have privacy enabled */
-       if (mac->associnfo.req_essid.len == 0 
+       if (mac->associnfo.req_essid.len == 0
            && !(net->capability & WLAN_CAPABILITY_PRIVACY))
                return 1;
        if (net->ssid_len != mac->associnfo.req_essid.len)
@@ -212,8 +212,8 @@ ieee80211softmac_assoc_work(struct work_struct *work)
 
        /* try to find the requested network in our list, if we found one already */
        if (bssvalid || mac->associnfo.bssfixed)
-               found = ieee80211softmac_get_network_by_bssid(mac, mac->associnfo.bssid);       
-       
+               found = ieee80211softmac_get_network_by_bssid(mac, mac->associnfo.bssid);
+
        /* Search the ieee80211 networks for this network if we didn't find it by bssid,
         * but only if we've scanned at least once (to get a better list of networks to
         * select from). If we have not scanned before, the !found logic below will be
@@ -265,7 +265,7 @@ ieee80211softmac_assoc_work(struct work_struct *work)
                if (mac->associnfo.scan_retry > 0) {
                        mac->associnfo.scan_retry--;
 
-                       /* We know of no such network. Let's scan. 
+                       /* We know of no such network. Let's scan.
                         * NB: this also happens if we had no memory to copy the network info...
                         * Maybe we can hope to have more memory after scanning finishes ;)
                         */
@@ -353,7 +353,7 @@ ieee80211softmac_associated(struct ieee80211softmac_device *mac,
                mac->set_bssid_filter(mac->dev, net->bssid);
        memcpy(mac->ieee->bssid, net->bssid, ETH_ALEN);
        netif_carrier_on(mac->dev);
-       
+
        mac->association_id = le16_to_cpup(&resp->aid);
 }
 
@@ -374,7 +374,7 @@ ieee80211softmac_handle_assoc_response(struct net_device * dev,
 
        if (unlikely(!mac->running))
                return -ENODEV;
-       
+
        spin_lock_irqsave(&mac->lock, flags);
 
        if (!mac->associnfo.associating) {
@@ -426,7 +426,7 @@ ieee80211softmac_handle_assoc_response(struct net_device * dev,
                        mac->associnfo.associated = 0;
                        ieee80211softmac_call_events_locked(mac, IEEE80211SOFTMAC_EVENT_ASSOCIATE_FAILED, network);
        }
-       
+
        spin_unlock_irqrestore(&mac->lock, flags);
        return 0;
 }
index 8ed3e59b8024fd3f5dea77fd5e5df01162b3d039..826c32d24461198614b5ba3eb5eb4a0f33951ea2 100644 (file)
@@ -30,12 +30,12 @@ static void ieee80211softmac_auth_queue(struct work_struct *work);
 
 /* Queues an auth request to the desired AP */
 int
-ieee80211softmac_auth_req(struct ieee80211softmac_device *mac, 
+ieee80211softmac_auth_req(struct ieee80211softmac_device *mac,
        struct ieee80211softmac_network *net)
 {
        struct ieee80211softmac_auth_queue_item *auth;
        unsigned long flags;
-       
+
        if (net->authenticating || net->authenticated)
                return 0;
        net->authenticating = 1;
@@ -55,7 +55,7 @@ ieee80211softmac_auth_req(struct ieee80211softmac_device *mac,
        auth->retry = IEEE80211SOFTMAC_AUTH_RETRY_LIMIT;
        auth->state = IEEE80211SOFTMAC_AUTH_OPEN_REQUEST;
        INIT_DELAYED_WORK(&auth->work, ieee80211softmac_auth_queue);
-       
+
        /* Lock (for list) */
        spin_lock_irqsave(&mac->lock, flags);
 
@@ -63,7 +63,7 @@ ieee80211softmac_auth_req(struct ieee80211softmac_device *mac,
        list_add_tail(&auth->list, &mac->auth_queue);
        schedule_delayed_work(&auth->work, 0);
        spin_unlock_irqrestore(&mac->lock, flags);
-       
+
        return 0;
 }
 
@@ -85,7 +85,7 @@ ieee80211softmac_auth_queue(struct work_struct *work)
        if(auth->retry > 0) {
                /* Switch to correct channel for this network */
                mac->set_channel(mac->dev, net->channel);
-               
+
                /* Lock and set flags */
                spin_lock_irqsave(&mac->lock, flags);
                if (unlikely(!mac->running)) {
@@ -130,11 +130,11 @@ ieee80211softmac_auth_challenge_response(struct work_struct *work)
 }
 
 /* Handle the auth response from the AP
- * This should be registered with ieee80211 as handle_auth 
+ * This should be registered with ieee80211 as handle_auth
  */
-int 
+int
 ieee80211softmac_auth_resp(struct net_device *dev, struct ieee80211_auth *auth)
-{      
+{
 
        struct list_head *list_ptr;
        struct ieee80211softmac_device *mac = ieee80211_priv(dev);
@@ -142,7 +142,7 @@ ieee80211softmac_auth_resp(struct net_device *dev, struct ieee80211_auth *auth)
        struct ieee80211softmac_network *net = NULL;
        unsigned long flags;
        u8 * data;
-       
+
        if (unlikely(!mac->running))
                return -ENODEV;
 
@@ -157,15 +157,15 @@ ieee80211softmac_auth_resp(struct net_device *dev, struct ieee80211_auth *auth)
                        aq = NULL;
        }
        spin_unlock_irqrestore(&mac->lock, flags);
-       
+
        /* Make sure that we've got an auth queue item for this request */
        if(aq == NULL)
        {
                dprintkl(KERN_DEBUG PFX "Authentication response received from "MAC_FMT" but no queue item exists.\n", MAC_ARG(auth->header.addr2));
                /* Error #? */
                return -1;
-       }                       
-       
+       }
+
        /* Check for out of order authentication */
        if(!net->authenticating)
        {
@@ -182,10 +182,10 @@ ieee80211softmac_auth_resp(struct net_device *dev, struct ieee80211_auth *auth)
                case WLAN_STATUS_SUCCESS:
                        /* Update the status to Authenticated */
                        spin_lock_irqsave(&mac->lock, flags);
-                       net->authenticating = 0;
+                       net->authenticating = 0;
                        net->authenticated = 1;
                        spin_unlock_irqrestore(&mac->lock, flags);
-                       
+
                        /* Send event */
                        printkl(KERN_NOTICE PFX "Open Authentication completed with "MAC_FMT"\n", MAC_ARG(net->bssid));
                        ieee80211softmac_call_events(mac, IEEE80211SOFTMAC_EVENT_AUTHENTICATED, net);
@@ -196,8 +196,8 @@ ieee80211softmac_auth_resp(struct net_device *dev, struct ieee80211_auth *auth)
                        net->authenticated = 0;
                        net->authenticating = 0;
                        spin_unlock_irqrestore(&mac->lock, flags);
-                       
-                       printkl(KERN_NOTICE PFX "Open Authentication with "MAC_FMT" failed, error code: %i\n", 
+
+                       printkl(KERN_NOTICE PFX "Open Authentication with "MAC_FMT" failed, error code: %i\n",
                                MAC_ARG(net->bssid), le16_to_cpup(&auth->status));
                        /* Count the error? */
                        break;
@@ -212,11 +212,11 @@ ieee80211softmac_auth_resp(struct net_device *dev, struct ieee80211_auth *auth)
                        data = (u8 *)auth->info_element;
                        if (*data++ != MFIE_TYPE_CHALLENGE) {
                                printkl(KERN_NOTICE PFX "Shared Key Authentication failed due to a missing challenge.\n");
-                               break;  
+                               break;
                        }
                        /* Save the challenge */
                        spin_lock_irqsave(&mac->lock, flags);
-                       net->challenge_len = *data++;   
+                       net->challenge_len = *data++;
                        if (net->challenge_len > WLAN_AUTH_CHALLENGE_LEN)
                                net->challenge_len = WLAN_AUTH_CHALLENGE_LEN;
                        kfree(net->challenge);
@@ -229,7 +229,7 @@ ieee80211softmac_auth_resp(struct net_device *dev, struct ieee80211_auth *auth)
                                spin_unlock_irqrestore(&mac->lock, flags);
                                break;
                        }
-                       aq->state = IEEE80211SOFTMAC_AUTH_SHARED_RESPONSE; 
+                       aq->state = IEEE80211SOFTMAC_AUTH_SHARED_RESPONSE;
 
                        /* We reuse the work struct from the auth request here.
                         * It is safe to do so as each one is per-request, and
@@ -248,22 +248,22 @@ ieee80211softmac_auth_resp(struct net_device *dev, struct ieee80211_auth *auth)
                        /* Check the status code of the response */
                        switch(auth->status) {
                        case WLAN_STATUS_SUCCESS:
-                               /* Update the status to Authenticated */        
+                               /* Update the status to Authenticated */
                                spin_lock_irqsave(&mac->lock, flags);
                                net->authenticating = 0;
                                net->authenticated = 1;
                                spin_unlock_irqrestore(&mac->lock, flags);
-                               printkl(KERN_NOTICE PFX "Shared Key Authentication completed with "MAC_FMT"\n", 
+                               printkl(KERN_NOTICE PFX "Shared Key Authentication completed with "MAC_FMT"\n",
                                        MAC_ARG(net->bssid));
                                ieee80211softmac_call_events(mac, IEEE80211SOFTMAC_EVENT_AUTHENTICATED, net);
                                break;
                        default:
-                               printkl(KERN_NOTICE PFX "Shared Key Authentication with "MAC_FMT" failed, error code: %i\n", 
+                               printkl(KERN_NOTICE PFX "Shared Key Authentication with "MAC_FMT" failed, error code: %i\n",
                                        MAC_ARG(net->bssid), le16_to_cpup(&auth->status));
                                /* Lock and reset flags */
                                spin_lock_irqsave(&mac->lock, flags);
-                               net->authenticating = 0;
-                               net->authenticated = 0;
+                               net->authenticating = 0;
+                               net->authenticated = 0;
                                spin_unlock_irqrestore(&mac->lock, flags);
                                /* Count the error? */
                                break;
@@ -277,7 +277,7 @@ ieee80211softmac_auth_resp(struct net_device *dev, struct ieee80211_auth *auth)
                goto free_aq;
                break;
        default:
-               /* ERROR */     
+               /* ERROR */
                goto free_aq;
                break;
        }
@@ -313,7 +313,7 @@ ieee80211softmac_deauth_from_net(struct ieee80211softmac_device *mac,
        spin_lock_irqsave(&mac->lock, flags);
        net->authenticating = 0;
        net->authenticated = 0;
-       
+
        /* Find correct auth queue item, if it exists */
        list_for_each(list_ptr, &mac->auth_queue) {
                aq = list_entry(list_ptr, struct ieee80211softmac_auth_queue_item, list);
@@ -322,7 +322,7 @@ ieee80211softmac_deauth_from_net(struct ieee80211softmac_device *mac,
                else
                        aq = NULL;
        }
-       
+
        /* Cancel pending work */
        if(aq != NULL)
                /* Not entirely safe?  What about running work? */
@@ -333,7 +333,7 @@ ieee80211softmac_deauth_from_net(struct ieee80211softmac_device *mac,
        if(net->challenge != NULL)
                kfree(net->challenge);
        kfree(net);
-       
+
        /* can't transmit data right now... */
        netif_carrier_off(mac->dev);
        spin_unlock_irqrestore(&mac->lock, flags);
@@ -341,15 +341,15 @@ ieee80211softmac_deauth_from_net(struct ieee80211softmac_device *mac,
        ieee80211softmac_try_reassoc(mac);
 }
 
-/* 
+/*
  * Sends a deauth request to the desired AP
  */
-int 
-ieee80211softmac_deauth_req(struct ieee80211softmac_device *mac, 
+int
+ieee80211softmac_deauth_req(struct ieee80211softmac_device *mac,
        struct ieee80211softmac_network *net, int reason)
 {
        int ret;
-       
+
        /* Make sure the network is authenticated */
        if (!net->authenticated)
        {
@@ -357,25 +357,25 @@ ieee80211softmac_deauth_req(struct ieee80211softmac_device *mac,
                /* Error okay? */
                return -EPERM;
        }
-       
+
        /* Send the de-auth packet */
        if((ret = ieee80211softmac_send_mgt_frame(mac, net, IEEE80211_STYPE_DEAUTH, reason)))
                return ret;
-       
+
        ieee80211softmac_deauth_from_net(mac, net);
        return 0;
 }
+
 /*
  * This should be registered with ieee80211 as handle_deauth
  */
-int 
+int
 ieee80211softmac_deauth_resp(struct net_device *dev, struct ieee80211_deauth *deauth)
 {
-       
+
        struct ieee80211softmac_network *net = NULL;
        struct ieee80211softmac_device *mac = ieee80211_priv(dev);
-       
+
        if (unlikely(!mac->running))
                return -ENODEV;
 
@@ -385,7 +385,7 @@ ieee80211softmac_deauth_resp(struct net_device *dev, struct ieee80211_deauth *de
        }
 
        net = ieee80211softmac_get_network_by_bssid(mac, deauth->header.addr2);
-       
+
        if (net == NULL) {
                dprintkl(KERN_DEBUG PFX "Received deauthentication packet from "MAC_FMT", but that network is unknown.\n",
                        MAC_ARG(deauth->header.addr2));
index b9015656cfb3835e5e2966c457d0d9269ebb17f7..b3e33a4d48691f7ee3400ff9e22e612ebd49ffe4 100644 (file)
@@ -79,7 +79,7 @@ ieee80211softmac_notify_callback(struct work_struct *work)
                container_of(work, struct ieee80211softmac_event, work.work);
        struct ieee80211softmac_event event = *pevent;
        kfree(pevent);
-       
+
        event.fun(event.mac->dev, event.event_type, event.context);
 }
 
@@ -92,14 +92,14 @@ ieee80211softmac_notify_internal(struct ieee80211softmac_device *mac,
 
        if (event < -1 || event > IEEE80211SOFTMAC_EVENT_LAST)
                return -ENOSYS;
-       
+
        if (!fun)
                return -EINVAL;
-       
+
        eventptr = kmalloc(sizeof(struct ieee80211softmac_event), gfp_mask);
        if (!eventptr)
                return -ENOMEM;
-       
+
        eventptr->event_type = event;
        INIT_DELAYED_WORK(&eventptr->work, ieee80211softmac_notify_callback);
        eventptr->fun = fun;
@@ -122,7 +122,7 @@ ieee80211softmac_notify_gfp(struct net_device *dev,
 
        if (event < 0 || event > IEEE80211SOFTMAC_EVENT_LAST)
                return -ENOSYS;
-       
+
        return ieee80211softmac_notify_internal(mac, event, NULL, fun, context, gfp_mask);
 }
 EXPORT_SYMBOL_GPL(ieee80211softmac_notify_gfp);
@@ -133,7 +133,7 @@ ieee80211softmac_call_events_locked(struct ieee80211softmac_device *mac, int eve
 {
        struct ieee80211softmac_event *eventptr, *tmp;
        struct ieee80211softmac_network *network;
-       
+
        if (event >= 0) {
                union iwreq_data wrqu;
                int we_event;
index b96931001b43d131bc30d8d7841fda97b0897ce0..26c35253be334266680a01aa1579f794945b779f 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
  * Some parts based on code from net80211
  * Copyright (c) 2001 Atsushi Onoe
  * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- * 
+ *
  */
 
 #include "ieee80211softmac_priv.h"
 
 /* Helper functions for inserting data into the frames */
 
-/* 
+/*
  * Adds an ESSID element to the frame
  *
  */
@@ -53,7 +53,7 @@ ieee80211softmac_add_essid(u8 *dst, struct ieee80211softmac_essid *essid)
                *dst++ = 0;
                return dst;
        }
-}     
+}
 
 /* Adds Supported Rates and if required Extended Rates Information Element
  * to the frame, ASSUMES WE HAVE A SORTED LIST OF RATES */
@@ -81,18 +81,18 @@ ieee80211softmac_frame_add_rates(u8 *dst, const struct ieee80211softmac_ratesinf
                        memcpy(dst, r->rates + cck_len, ofdm_len);
                        dst += ofdm_len;
                }
-       }       
+       }
        return dst;
 }
 
 /* Allocate a management frame */
-static u8 * 
+static u8 *
 ieee80211softmac_alloc_mgt(u32 size)
 {
        u8 * data;
-       
+
        /* Add the header and FCS to the size */
-       size = size + IEEE80211_3ADDR_LEN;      
+       size = size + IEEE80211_3ADDR_LEN;
        if(size > IEEE80211_DATA_LEN)
                return NULL;
        /* Allocate the frame */
@@ -103,13 +103,13 @@ ieee80211softmac_alloc_mgt(u32 size)
 /*
  * Add a 2 Address Header
  */
-static void 
+static void
 ieee80211softmac_hdr_2addr(struct ieee80211softmac_device *mac,
        struct ieee80211_hdr_2addr *header, u32 type, u8 *dest)
 {
        /* Fill in the frame control flags */
        header->frame_ctl = cpu_to_le16(type);
-       /* Control packets always have WEP turned off */        
+       /* Control packets always have WEP turned off */
        if(type > IEEE80211_STYPE_CFENDACK && type < IEEE80211_STYPE_PSPOLL)
                header->frame_ctl |= mac->ieee->sec.level ? cpu_to_le16(IEEE80211_FCTL_PROTECTED) : 0;
 
@@ -130,13 +130,13 @@ ieee80211softmac_hdr_2addr(struct ieee80211softmac_device *mac,
 
 
 /* Add a 3 Address Header */
-static void 
+static void
 ieee80211softmac_hdr_3addr(struct ieee80211softmac_device *mac,
        struct ieee80211_hdr_3addr *header, u32 type, u8 *dest, u8 *bssid)
 {
        /* This is common with 2addr, so use that instead */
-       ieee80211softmac_hdr_2addr(mac, (struct ieee80211_hdr_2addr *)header, type, dest);      
-       
+       ieee80211softmac_hdr_2addr(mac, (struct ieee80211_hdr_2addr *)header, type, dest);
+
        /* Fill in the BSS ID */
        if(bssid == NULL)
                memset(header->addr3, 0xFF, ETH_ALEN);
@@ -201,11 +201,11 @@ ieee80211softmac_capabilities(struct ieee80211softmac_device *mac,
 
 /*****************************************************************************
  * Create Management packets
- *****************************************************************************/ 
+ *****************************************************************************/
 
 /* Creates an association request packet */
 static u32
-ieee80211softmac_assoc_req(struct ieee80211_assoc_request **pkt, 
+ieee80211softmac_assoc_req(struct ieee80211_assoc_request **pkt,
        struct ieee80211softmac_device *mac, struct ieee80211softmac_network *net)
 {
        u8 *data;
@@ -233,7 +233,7 @@ ieee80211softmac_assoc_req(struct ieee80211_assoc_request **pkt,
 
        /* Fill in Listen Interval (?) */
        (*pkt)->listen_interval = cpu_to_le16(10);
-       
+
        data = (u8 *)(*pkt)->info_element;
        /* Add SSID */
        data = ieee80211softmac_add_essid(data, &net->essid);
@@ -250,7 +250,7 @@ ieee80211softmac_assoc_req(struct ieee80211_assoc_request **pkt,
 
 /* Create a reassociation request packet */
 static u32
-ieee80211softmac_reassoc_req(struct ieee80211_reassoc_request **pkt, 
+ieee80211softmac_reassoc_req(struct ieee80211_reassoc_request **pkt,
        struct ieee80211softmac_device *mac, struct ieee80211softmac_network *net)
 {
        u8 *data;
@@ -263,9 +263,9 @@ ieee80211softmac_reassoc_req(struct ieee80211_reassoc_request **pkt,
                /* Rates IE */
                1 + 1 + IEEE80211SOFTMAC_MAX_RATES_LEN +
                /* Extended Rates IE */
-               1 + 1 + IEEE80211SOFTMAC_MAX_EX_RATES_LEN 
+               1 + 1 + IEEE80211SOFTMAC_MAX_EX_RATES_LEN
                /* Other IE's? */
-       );                              
+       );
        if (unlikely((*pkt) == NULL))
                return 0;
        ieee80211softmac_hdr_3addr(mac, &((*pkt)->header), IEEE80211_STYPE_REASSOC_REQ, net->bssid, net->bssid);
@@ -277,10 +277,10 @@ ieee80211softmac_reassoc_req(struct ieee80211_reassoc_request **pkt,
        (*pkt)->listen_interval = cpu_to_le16(10);
        /* Fill in the current AP MAC */
        memcpy((*pkt)->current_ap, mac->ieee->bssid, ETH_ALEN);
-       
+
        data = (u8 *)(*pkt)->info_element;
        /* Add SSID */
-       data = ieee80211softmac_add_essid(data, &net->essid); 
+       data = ieee80211softmac_add_essid(data, &net->essid);
        /* Add Rates */
        data = ieee80211softmac_frame_add_rates(data, &mac->ratesinfo);
        /* Return packet size */
@@ -289,7 +289,7 @@ ieee80211softmac_reassoc_req(struct ieee80211_reassoc_request **pkt,
 
 /* Create an authentication packet */
 static u32
-ieee80211softmac_auth(struct ieee80211_auth **pkt, 
+ieee80211softmac_auth(struct ieee80211_auth **pkt,
        struct ieee80211softmac_device *mac, struct ieee80211softmac_network *net,
        u16 transaction, u16 status, int *encrypt_mpdu)
 {
@@ -309,20 +309,20 @@ ieee80211softmac_auth(struct ieee80211_auth **pkt,
        if (unlikely((*pkt) == NULL))
                return 0;
        ieee80211softmac_hdr_3addr(mac, &((*pkt)->header), IEEE80211_STYPE_AUTH, net->bssid, net->bssid);
-               
+
        /* Algorithm */
        (*pkt)->algorithm = cpu_to_le16(auth_mode);
        /* Transaction */
        (*pkt)->transaction = cpu_to_le16(transaction);
        /* Status */
        (*pkt)->status = cpu_to_le16(status);
-       
+
        data = (u8 *)(*pkt)->info_element;
        /* Challenge Text */
        if (is_shared_response) {
                *data = MFIE_TYPE_CHALLENGE;
                data++;
-               
+
                /* Copy the challenge in */
                *data = net->challenge_len;
                data++;
@@ -360,7 +360,7 @@ static u32
 ieee80211softmac_probe_req(struct ieee80211_probe_request **pkt,
        struct ieee80211softmac_device *mac, struct ieee80211softmac_essid *essid)
 {
-       u8 *data;       
+       u8 *data;
        /* Allocate Packet */
        (*pkt) = (struct ieee80211_probe_request *)ieee80211softmac_alloc_mgt(
                /* SSID of requested network */
@@ -368,12 +368,12 @@ ieee80211softmac_probe_req(struct ieee80211_probe_request **pkt,
                /* Rates IE */
                1 + 1 + IEEE80211SOFTMAC_MAX_RATES_LEN +
                /* Extended Rates IE */
-               1 + 1 + IEEE80211SOFTMAC_MAX_EX_RATES_LEN 
+               1 + 1 + IEEE80211SOFTMAC_MAX_EX_RATES_LEN
        );
        if (unlikely((*pkt) == NULL))
                return 0;
        ieee80211softmac_hdr_3addr(mac, &((*pkt)->header), IEEE80211_STYPE_PROBE_REQ, NULL, NULL);
-               
+
        data = (u8 *)(*pkt)->info_element;
        /* Add ESSID (can be NULL) */
        data = ieee80211softmac_add_essid(data, essid);
@@ -401,7 +401,7 @@ ieee80211softmac_probe_resp(struct ieee80211_probe_response **pkt,
                2 +             /* DS Parameter Set */
                8 +             /* CF Parameter Set */
                4               /* IBSS Parameter Set */
-       );      
+       );
        if (unlikely((*pkt) == NULL))
                return 0;
        ieee80211softmac_hdr_3addr(mac, &((*pkt)->header), IEEE80211_STYPE_PROBE_RESP, net->bssid, net->bssid);
@@ -445,15 +445,15 @@ ieee80211softmac_send_mgt_frame(struct ieee80211softmac_device *mac,
                pkt_size = ieee80211softmac_probe_resp((struct ieee80211_probe_response **)(&pkt), mac, (struct ieee80211softmac_network *)ptrarg);
                break;
        default:
-                printkl(KERN_DEBUG PFX "Unsupported Management Frame type: %i\n", type);
-                return -EINVAL;
+               printkl(KERN_DEBUG PFX "Unsupported Management Frame type: %i\n", type);
+               return -EINVAL;
        };
 
        if(pkt_size == 0 || pkt == NULL) {
                printkl(KERN_DEBUG PFX "Error, packet is nonexistant or 0 length\n");
                return -ENOMEM;
        }
-       
+
        /* Send the packet to the ieee80211 layer for tx */
        /* we defined softmac->mgmt_xmit for this. Should we keep it
         * as it is (that means we'd need to wrap this into a txb),
index 256207b71dc94ce135aca1d3adc36f5c49875305..4f8c3ef7081950b6e20157245b100dfca7f64065 100644 (file)
@@ -32,19 +32,19 @@ struct net_device *alloc_ieee80211softmac(int sizeof_priv)
 {
        struct ieee80211softmac_device *softmac;
        struct net_device *dev;
-       
+
        dev = alloc_ieee80211(sizeof(struct ieee80211softmac_device) + sizeof_priv);
        softmac = ieee80211_priv(dev);
        softmac->dev = dev;
        softmac->ieee = netdev_priv(dev);
        spin_lock_init(&softmac->lock);
-       
+
        softmac->ieee->handle_auth = ieee80211softmac_auth_resp;
        softmac->ieee->handle_deauth = ieee80211softmac_deauth_resp;
        softmac->ieee->handle_assoc_response = ieee80211softmac_handle_assoc_response;
        softmac->ieee->handle_reassoc_request = ieee80211softmac_handle_reassoc_req;
        softmac->ieee->handle_disassoc = ieee80211softmac_handle_disassoc;
-       softmac->ieee->handle_beacon = ieee80211softmac_handle_beacon;
+       softmac->ieee->handle_beacon = ieee80211softmac_handle_beacon;
        softmac->scaninfo = NULL;
 
        softmac->associnfo.scan_retry = IEEE80211SOFTMAC_ASSOC_SCAN_RETRY_LIMIT;
@@ -66,37 +66,37 @@ struct net_device *alloc_ieee80211softmac(int sizeof_priv)
 
        /* to start with, we can't send anything ... */
        netif_carrier_off(dev);
-       
+
        return dev;
 }
 EXPORT_SYMBOL_GPL(alloc_ieee80211softmac);
 
 /* Clears the pending work queue items, stops all scans, etc. */
-void 
+void
 ieee80211softmac_clear_pending_work(struct ieee80211softmac_device *sm)
 {
        unsigned long flags;
        struct ieee80211softmac_event *eventptr, *eventtmp;
        struct ieee80211softmac_auth_queue_item *authptr, *authtmp;
        struct ieee80211softmac_network *netptr, *nettmp;
-       
+
        ieee80211softmac_stop_scan(sm);
        ieee80211softmac_wait_for_scan(sm);
-       
+
        spin_lock_irqsave(&sm->lock, flags);
        sm->running = 0;
 
        /* Free all pending assoc work items */
        cancel_delayed_work(&sm->associnfo.work);
-       
+
        /* Free all pending scan work items */
        if(sm->scaninfo != NULL)
-               cancel_delayed_work(&sm->scaninfo->softmac_scan);       
-       
+               cancel_delayed_work(&sm->scaninfo->softmac_scan);
+
        /* Free all pending auth work items */
        list_for_each_entry(authptr, &sm->auth_queue, list)
                cancel_delayed_work(&authptr->work);
-       
+
        /* delete all pending event calls and work items */
        list_for_each_entry_safe(eventptr, eventtmp, &sm->events, list)
                cancel_delayed_work(&eventptr->work);
@@ -111,13 +111,13 @@ ieee80211softmac_clear_pending_work(struct ieee80211softmac_device *sm)
                list_del(&authptr->list);
                kfree(authptr);
        }
-       
+
        /* delete all pending event calls and work items */
        list_for_each_entry_safe(eventptr, eventtmp, &sm->events, list) {
                list_del(&eventptr->list);
                kfree(eventptr);
        }
-               
+
        /* Free all networks */
        list_for_each_entry_safe(netptr, nettmp, &sm->network_list, list) {
                ieee80211softmac_del_network_locked(sm, netptr);
@@ -133,7 +133,7 @@ EXPORT_SYMBOL_GPL(ieee80211softmac_clear_pending_work);
 void free_ieee80211softmac(struct net_device *dev)
 {
        struct ieee80211softmac_device *sm = ieee80211_priv(dev);
-       ieee80211softmac_clear_pending_work(sm);        
+       ieee80211softmac_clear_pending_work(sm);
        kfree(sm->scaninfo);
        kfree(sm->wpa.IE);
        free_ieee80211(dev);
@@ -208,9 +208,9 @@ EXPORT_SYMBOL_GPL(ieee80211softmac_highest_supported_rate);
 void ieee80211softmac_process_erp(struct ieee80211softmac_device *mac,
        u8 erp_value)
 {
-       int use_protection;
+       int use_protection;
        int short_preamble;
-       u32 changes = 0;
+       u32 changes = 0;
 
        /* Barker preamble mode */
        short_preamble = ((erp_value & WLAN_ERP_BARKER_PREAMBLE) == 0
@@ -269,7 +269,7 @@ void ieee80211softmac_init_bss(struct ieee80211softmac_device *mac)
           rates, so 801.11g devices start off at 11M for now. People
           can manually change it if they really need to, but 11M is
           more reliable. Note similar logic in
-          ieee80211softmac_wx_set_rate() */     
+          ieee80211softmac_wx_set_rate() */
        if (ieee->modulation & IEEE80211_CCK_MODULATION) {
                txrates->user_rate = IEEE80211_CCK_RATE_11MB;
        } else if (ieee->modulation & IEEE80211_OFDM_MODULATION) {
@@ -332,7 +332,7 @@ void ieee80211softmac_set_rates(struct net_device *dev, u8 count, u8 *rates)
 {
        struct ieee80211softmac_device *mac = ieee80211_priv(dev);
        unsigned long flags;
-       
+
        spin_lock_irqsave(&mac->lock, flags);
        memcpy(mac->ratesinfo.rates, rates, count);
        mac->ratesinfo.count = count;
@@ -344,7 +344,7 @@ static u8 raise_rate(struct ieee80211softmac_device *mac, u8 rate)
 {
        int i;
        struct ieee80211softmac_ratesinfo *ri = &mac->ratesinfo;
-       
+
        for (i=0; i<ri->count-1; i++) {
                if (ri->rates[i] == rate)
                        return ri->rates[i+1];
@@ -357,7 +357,7 @@ u8 ieee80211softmac_lower_rate_delta(struct ieee80211softmac_device *mac, u8 rat
 {
        int i;
        struct ieee80211softmac_ratesinfo *ri = &mac->ratesinfo;
-       
+
        for (i=delta; i<ri->count; i++) {
                if (ri->rates[i] == rate)
                        return ri->rates[i-delta];
@@ -438,7 +438,7 @@ ieee80211softmac_create_network(struct ieee80211softmac_device *mac,
        softnet->channel = net->channel;
        softnet->essid.len = net->ssid_len;
        memcpy(softnet->essid.data, net->ssid, softnet->essid.len);
-       
+
        /* copy rates over */
        softnet->supported_rates.count = net->rates_len;
        memcpy(&softnet->supported_rates.rates[0], net->rates, net->rates_len);
@@ -529,7 +529,7 @@ ieee80211softmac_get_network_by_bssid(struct ieee80211softmac_device *mac,
 {
        unsigned long flags;
        struct ieee80211softmac_network *softmac_net;
-       
+
        spin_lock_irqsave(&mac->lock, flags);
        softmac_net = ieee80211softmac_get_network_by_bssid_locked(mac, bssid);
        spin_unlock_irqrestore(&mac->lock, flags);
@@ -556,13 +556,13 @@ ieee80211softmac_get_network_by_essid_locked(struct ieee80211softmac_device *mac
 /* Get a network from the list by ESSID with locking */
 struct ieee80211softmac_network *
 ieee80211softmac_get_network_by_essid(struct ieee80211softmac_device *mac,
-       struct ieee80211softmac_essid *essid)   
+       struct ieee80211softmac_essid *essid)
 {
        unsigned long flags;
        struct ieee80211softmac_network *softmac_net = NULL;
 
        spin_lock_irqsave(&mac->lock, flags);
-       softmac_net = ieee80211softmac_get_network_by_essid_locked(mac, essid); 
+       softmac_net = ieee80211softmac_get_network_by_essid_locked(mac, essid);
        spin_unlock_irqrestore(&mac->lock, flags);
        return softmac_net;
 }
index 4c2bba34d328c811ad2261c83dc39b371b00d7c5..c43b189634dfecffded989b046fbdb12834a6c31 100644 (file)
@@ -130,7 +130,7 @@ static inline u8 get_fallback_rate(struct ieee80211softmac_device *mac, u8 rate)
 {
        return ieee80211softmac_lower_rate_delta(mac, rate, 2);
 }
-                
+
 
 /*** prototypes from _io.c */
 int ieee80211softmac_send_mgt_frame(struct ieee80211softmac_device *mac,
@@ -156,7 +156,7 @@ int ieee80211softmac_handle_assoc_response(struct net_device * dev,
 int ieee80211softmac_handle_disassoc(struct net_device * dev,
                                     struct ieee80211_disassoc * disassoc);
 int ieee80211softmac_handle_reassoc_req(struct net_device * dev,
-                                       struct ieee80211_reassoc_request * reassoc);
+                                       struct ieee80211_reassoc_request * reassoc);
 void ieee80211softmac_assoc_timeout(struct work_struct *work);
 void ieee80211softmac_send_disassoc_req(struct ieee80211softmac_device *mac, u16 reason);
 void ieee80211softmac_disassoc(struct ieee80211softmac_device *mac);
@@ -164,15 +164,15 @@ void ieee80211softmac_disassoc(struct ieee80211softmac_device *mac);
 /* some helper functions */
 static inline int ieee80211softmac_scan_handlers_check_self(struct ieee80211softmac_device *sm)
 {
-       return (sm->start_scan == ieee80211softmac_start_scan_implementation) && 
-               (sm->stop_scan == ieee80211softmac_stop_scan_implementation) && 
+       return (sm->start_scan == ieee80211softmac_start_scan_implementation) &&
+               (sm->stop_scan == ieee80211softmac_stop_scan_implementation) &&
                (sm->wait_for_scan == ieee80211softmac_wait_for_scan_implementation);
 }
 
 static inline int ieee80211softmac_scan_sanity_check(struct ieee80211softmac_device *sm)
 {
-       return ((sm->start_scan != ieee80211softmac_start_scan_implementation) && 
-               (sm->stop_scan != ieee80211softmac_stop_scan_implementation) && 
+       return ((sm->start_scan != ieee80211softmac_start_scan_implementation) &&
+               (sm->stop_scan != ieee80211softmac_stop_scan_implementation) &&
                (sm->wait_for_scan != ieee80211softmac_wait_for_scan_implementation)
                ) || ieee80211softmac_scan_handlers_check_self(sm);
 }
index 0c85d6c24cdbca332a5e865fdbb2d51f0ab05621..abea3648680ebf02b978931fa5c20b3a2e0101fc 100644 (file)
@@ -62,12 +62,12 @@ ieee80211softmac_stop_scan(struct ieee80211softmac_device *sm)
        unsigned long flags;
 
        spin_lock_irqsave(&sm->lock, flags);
-       
+
        if (!sm->scanning) {
                spin_unlock_irqrestore(&sm->lock, flags);
                return;
        }
-       
+
        spin_unlock_irqrestore(&sm->lock, flags);
        sm->stop_scan(sm->dev);
 }
@@ -78,12 +78,12 @@ ieee80211softmac_wait_for_scan(struct ieee80211softmac_device *sm)
        unsigned long flags;
 
        spin_lock_irqsave(&sm->lock, flags);
-       
+
        if (!sm->scanning) {
                spin_unlock_irqrestore(&sm->lock, flags);
                return;
        }
-       
+
        spin_unlock_irqrestore(&sm->lock, flags);
        sm->wait_for_scan(sm->dev);
 }
@@ -158,14 +158,14 @@ int ieee80211softmac_start_scan_implementation(struct net_device *dev)
 {
        struct ieee80211softmac_device *sm = ieee80211_priv(dev);
        unsigned long flags;
-       
+
        if (!(dev->flags & IFF_UP))
                return -ENODEV;
 
        assert(ieee80211softmac_scan_handlers_check_self(sm));
        if (!ieee80211softmac_scan_handlers_check_self(sm))
                return -EINVAL;
-               
+
        spin_lock_irqsave(&sm->lock, flags);
        /* it looks like we need to hold the lock here
         * to make sure we don't allocate two of these... */
@@ -241,7 +241,7 @@ void ieee80211softmac_scan_finished(struct ieee80211softmac_device *sm)
        spin_lock_irqsave(&sm->lock, flags);
        sm->scanning = 0;
        spin_unlock_irqrestore(&sm->lock, flags);
-       
+
        if (sm->associnfo.bssvalid) {
                struct ieee80211softmac_network *net;
 
index fb58e03b3fbda3497245f3b484c01db14a343e4c..c306d52566e0dfda1673b37a089a85dd40ea78a7 100644 (file)
@@ -142,14 +142,14 @@ ieee80211softmac_wx_get_essid(struct net_device *net_dev,
        /* If all fails, return ANY (empty) */
        data->essid.length = 0;
        data->essid.flags = 0;  /* active */
-       
+
        /* If we have a statically configured ESSID then return it */
        if (sm->associnfo.static_essid) {
                data->essid.length = sm->associnfo.req_essid.len;
                data->essid.flags = 1;  /* active */
                memcpy(extra, sm->associnfo.req_essid.data, sm->associnfo.req_essid.len);
        }
-       
+
        /* If we're associating/associated, return that */
        if (sm->associnfo.associated || sm->associnfo.associating) {
                data->essid.length = sm->associnfo.associate_essid.len;
@@ -181,7 +181,7 @@ ieee80211softmac_wx_set_rate(struct net_device *net_dev,
                   rates, so 801.11g devices start off at 11M for now. People
                   can manually change it if they really need to, but 11M is
                   more reliable. Note similar logic in
-                  ieee80211softmac_wx_set_rate() */     
+                  ieee80211softmac_wx_set_rate() */
                if (ieee->modulation & IEEE80211_CCK_MODULATION)
                        in_rate = 11000000;
                else
@@ -247,7 +247,7 @@ ieee80211softmac_wx_set_rate(struct net_device *net_dev,
        ieee80211softmac_recalc_txrates(mac);
        err = 0;
 
-out_unlock:    
+out_unlock:
        spin_unlock_irqrestore(&mac->lock, flags);
 out:
        return err;
@@ -366,7 +366,7 @@ ieee80211softmac_wx_set_wap(struct net_device *net_dev,
        } else if (is_zero_ether_addr(data->ap_addr.sa_data)) {
                /* the bssid we have is no longer fixed */
                mac->associnfo.bssfixed = 0;
-        } else {
+       } else {
                if (!memcmp(mac->associnfo.bssid, data->ap_addr.sa_data, ETH_ALEN)) {
                        if (mac->associnfo.associating || mac->associnfo.associated) {
                        /* bssid unchanged and associated or associating - just return */
@@ -380,7 +380,7 @@ ieee80211softmac_wx_set_wap(struct net_device *net_dev,
                mac->associnfo.bssfixed = 1;
                /* queue associate if new bssid or (old one again and not associated) */
                schedule_delayed_work(&mac->associnfo.work, 0);
-        }
+       }
 
  out:
        mutex_unlock(&mac->associnfo.mutex);
@@ -437,7 +437,7 @@ ieee80211softmac_wx_set_genie(struct net_device *dev,
                mac->wpa.IEbuflen = 0;
        }
 
- out:  
+ out:
        spin_unlock_irqrestore(&mac->lock, flags);
        mutex_unlock(&mac->associnfo.mutex);
 
@@ -458,9 +458,9 @@ ieee80211softmac_wx_get_genie(struct net_device *dev,
 
        mutex_lock(&mac->associnfo.mutex);
        spin_lock_irqsave(&mac->lock, flags);
-       
+
        wrqu->data.length = 0;
-       
+
        if (mac->wpa.IE && mac->wpa.IElen) {
                wrqu->data.length = mac->wpa.IElen;
                if (mac->wpa.IElen <= space)
index 864009643675fe195be002f09e50bfeb69b0e417..cf358c84c44060353b69b5ef26129f8a9cb2a266 100644 (file)
@@ -550,7 +550,7 @@ int inet_stream_connect(struct socket *sock, struct sockaddr *uaddr,
                if (err < 0)
                        goto out;
 
-               sock->state = SS_CONNECTING;
+               sock->state = SS_CONNECTING;
 
                /* Just entered SS_CONNECTING state; the only
                 * difference is that return value in non-blocking
@@ -878,36 +878,36 @@ static struct net_proto_family inet_family_ops = {
  */
 static struct inet_protosw inetsw_array[] =
 {
-        {
-                .type =       SOCK_STREAM,
-                .protocol =   IPPROTO_TCP,
-                .prot =       &tcp_prot,
-                .ops =        &inet_stream_ops,
-                .capability = -1,
-                .no_check =   0,
-                .flags =      INET_PROTOSW_PERMANENT |
+       {
+               .type =       SOCK_STREAM,
+               .protocol =   IPPROTO_TCP,
+               .prot =       &tcp_prot,
+               .ops =        &inet_stream_ops,
+               .capability = -1,
+               .no_check =   0,
+               .flags =      INET_PROTOSW_PERMANENT |
                              INET_PROTOSW_ICSK,
-        },
-
-        {
-                .type =       SOCK_DGRAM,
-                .protocol =   IPPROTO_UDP,
-                .prot =       &udp_prot,
-                .ops =        &inet_dgram_ops,
-                .capability = -1,
-                .no_check =   UDP_CSUM_DEFAULT,
-                .flags =      INET_PROTOSW_PERMANENT,
+       },
+
+       {
+               .type =       SOCK_DGRAM,
+               .protocol =   IPPROTO_UDP,
+               .prot =       &udp_prot,
+               .ops =        &inet_dgram_ops,
+               .capability = -1,
+               .no_check =   UDP_CSUM_DEFAULT,
+               .flags =      INET_PROTOSW_PERMANENT,
        },
-        
+
 
        {
-               .type =       SOCK_RAW,
-               .protocol =   IPPROTO_IP,       /* wild card */
-               .prot =       &raw_prot,
-               .ops =        &inet_sockraw_ops,
-               .capability = CAP_NET_RAW,
-               .no_check =   UDP_CSUM_DEFAULT,
-               .flags =      INET_PROTOSW_REUSE,
+              .type =       SOCK_RAW,
+              .protocol =   IPPROTO_IP,        /* wild card */
+              .prot =       &raw_prot,
+              .ops =        &inet_sockraw_ops,
+              .capability = CAP_NET_RAW,
+              .no_check =   UDP_CSUM_DEFAULT,
+              .flags =      INET_PROTOSW_REUSE,
        }
 };
 
@@ -946,7 +946,7 @@ void inet_register_protosw(struct inet_protosw *p)
        /* Add the new entry after the last permanent entry if any, so that
         * the new entry does not override a permanent entry when matched with
         * a wild-card protocol. But it is allowed to override any existing
-        * non-permanent entry.  This means that when we remove this entry, the 
+        * non-permanent entry.  This means that when we remove this entry, the
         * system automatically returns to the old behavior.
         */
        list_add_rcu(&p->list, last_perm);
@@ -1007,7 +1007,7 @@ static int inet_sk_reselect_saddr(struct sock *sk)
                               RT_CONN_FLAGS(sk),
                               sk->sk_bound_dev_if,
                               sk->sk_protocol,
-                              inet->sport, inet->dport, sk);
+                              inet->sport, inet->dport, sk, 0);
        if (err)
                return err;
 
@@ -1073,7 +1073,7 @@ int inet_sk_rebuild_header(struct sock *sk)
                        },
                },
        };
-                                               
+
        security_sk_classify_flow(sk, &fl);
        err = ip_route_output_flow(&rt, &fl, sk, 0);
 }
@@ -1273,10 +1273,10 @@ static int __init inet_init(void)
                goto out_unregister_udp_proto;
 
        /*
-        *      Tell SOCKET that we are alive... 
+        *      Tell SOCKET that we are alive...
         */
 
-       (void)sock_register(&inet_family_ops);
+       (void)sock_register(&inet_family_ops);
 
        /*
         *      Add all the base protocols.
@@ -1306,9 +1306,9 @@ static int __init inet_init(void)
 
        arp_init();
 
-       /*
-        *      Set the IP module up
-        */
+       /*
+        *      Set the IP module up
+        */
 
        ip_init();
 
@@ -1334,11 +1334,11 @@ static int __init inet_init(void)
 #endif
        /*
         *      Initialise per-cpu ipv4 mibs
-        */ 
+        */
 
        if(init_ipv4_mibs())
                printk(KERN_CRIT "inet_init: Cannot init ipv4 mibs\n"); ;
-       
+
        ipv4_proc_init();
 
        ipfrag_init();
index 67a5509e26fc1e7b18dcfdbafd92986a97626ccb..7194eb40b6d08cbd2304fb8dd8d9eb415b9a73de 100644 (file)
@@ -91,7 +91,7 @@ static int ah_output(struct xfrm_state *x, struct sk_buff *skb)
        top_iph->check = 0;
 
        ahp = x->data;
-       ah->hdrlen  = (XFRM_ALIGN8(sizeof(struct ip_auth_hdr) + 
+       ah->hdrlen  = (XFRM_ALIGN8(sizeof(struct ip_auth_hdr) +
                                   ahp->icv_trunc_len) >> 2) - 2;
 
        ah->reserved = 0;
@@ -135,9 +135,9 @@ static int ah_input(struct xfrm_state *x, struct sk_buff *skb)
        ah = (struct ip_auth_hdr*)skb->data;
        ahp = x->data;
        ah_hlen = (ah->hdrlen + 2) << 2;
-       
+
        if (ah_hlen != XFRM_ALIGN8(sizeof(struct ip_auth_hdr) + ahp->icv_full_len) &&
-           ah_hlen != XFRM_ALIGN8(sizeof(struct ip_auth_hdr) + ahp->icv_trunc_len)) 
+           ah_hlen != XFRM_ALIGN8(sizeof(struct ip_auth_hdr) + ahp->icv_trunc_len))
                goto out;
 
        if (!pskb_may_pull(skb, ah_hlen))
@@ -166,9 +166,9 @@ static int ah_input(struct xfrm_state *x, struct sk_buff *skb)
                if (ip_clear_mutable_options(iph, &dummy))
                        goto out;
        }
-        {
+       {
                u8 auth_data[MAX_AH_AUTH_LEN];
-               
+
                memcpy(auth_data, ah->auth_data, ahp->icv_trunc_len);
                skb_push(skb, ihl);
                err = ah_mac_digest(ahp, skb, ah->auth_data);
@@ -237,7 +237,7 @@ static int ah_init_state(struct xfrm_state *x)
        ahp->tfm = tfm;
        if (crypto_hash_setkey(tfm, ahp->key, ahp->key_len))
                goto error;
-       
+
        /*
         * Lookup the algorithm description maintained by xfrm_algo,
         * verify crypto transform properties, and store information
@@ -254,16 +254,16 @@ static int ah_init_state(struct xfrm_state *x)
                       aalg_desc->uinfo.auth.icv_fullbits/8);
                goto error;
        }
-       
+
        ahp->icv_full_len = aalg_desc->uinfo.auth.icv_fullbits/8;
        ahp->icv_trunc_len = aalg_desc->uinfo.auth.icv_truncbits/8;
-       
+
        BUG_ON(ahp->icv_trunc_len > MAX_AH_AUTH_LEN);
-       
+
        ahp->work_icv = kmalloc(ahp->icv_full_len, GFP_KERNEL);
        if (!ahp->work_icv)
                goto error;
-       
+
        x->props.header_len = XFRM_ALIGN8(sizeof(struct ip_auth_hdr) + ahp->icv_trunc_len);
        if (x->props.mode == XFRM_MODE_TUNNEL)
                x->props.header_len += sizeof(struct iphdr);
index 3981e8be9ab8f34e5504815c1f4b130ec068ee14..a58afde4f72feb14890e7f8b38eb3b0cbe82ab8d 100644 (file)
@@ -15,9 +15,9 @@
  * 2 of the License, or (at your option) any later version.
  *
  * Fixes:
- *             Alan Cox        :       Removed the Ethernet assumptions in 
+ *             Alan Cox        :       Removed the Ethernet assumptions in
  *                                     Florian's code
- *             Alan Cox        :       Fixed some small errors in the ARP 
+ *             Alan Cox        :       Fixed some small errors in the ARP
  *                                     logic
  *             Alan Cox        :       Allow >4K in /proc
  *             Alan Cox        :       Make ARP add its own protocol entry
  *             Jonathan Naylor :       Only lookup the hardware address for
  *                                     the correct hardware type.
  *             Germano Caronni :       Assorted subtle races.
- *             Craig Schlenter :       Don't modify permanent entry 
+ *             Craig Schlenter :       Don't modify permanent entry
  *                                     during arp_rcv.
  *             Russ Nelson     :       Tidied up a few bits.
  *             Alexey Kuznetsov:       Major changes to caching and behaviour,
- *                                     eg intelligent arp probing and 
+ *                                     eg intelligent arp probing and
  *                                     generation
  *                                     of host down events.
  *             Alan Cox        :       Missing unlock in device events.
  *             Eckes           :       ARP ioctl control errors.
  *             Alexey Kuznetsov:       Arp free fix.
  *             Manuel Rodriguez:       Gratuitous ARP.
- *              Jonathan Layes  :       Added arpd support through kerneld 
+ *              Jonathan Layes  :       Added arpd support through kerneld
  *                                      message queue (960314)
  *             Mike Shaver     :       /proc/sys/net/ipv4/arp_* support
  *             Mike McLagan    :       Routing by source
@@ -210,7 +210,7 @@ int arp_mc_map(__be32 addr, u8 *haddr, struct net_device *dev, int dir)
        case ARPHRD_FDDI:
        case ARPHRD_IEEE802:
                ip_eth_mc_map(addr, haddr);
-               return 0; 
+               return 0;
        case ARPHRD_IEEE802_TR:
                ip_tr_mc_map(addr, haddr);
                return 0;
@@ -288,7 +288,7 @@ static int arp_constructor(struct neighbour *neigh)
                switch (dev->type) {
                default:
                        break;
-               case ARPHRD_ROSE:       
+               case ARPHRD_ROSE:
 #if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
                case ARPHRD_AX25:
 #if defined(CONFIG_NETROM) || defined(CONFIG_NETROM_MODULE)
@@ -425,18 +425,18 @@ static int arp_filter(__be32 sip, __be32 tip, struct net_device *dev)
        struct flowi fl = { .nl_u = { .ip4_u = { .daddr = sip,
                                                 .saddr = tip } } };
        struct rtable *rt;
-       int flag = 0; 
+       int flag = 0;
        /*unsigned long now; */
 
-       if (ip_route_output_key(&rt, &fl) < 0) 
+       if (ip_route_output_key(&rt, &fl) < 0)
                return 1;
-       if (rt->u.dst.dev != dev) { 
+       if (rt->u.dst.dev != dev) {
                NET_INC_STATS_BH(LINUX_MIB_ARPFILTER);
                flag = 1;
-       } 
-       ip_rt_put(rt); 
-       return flag; 
-} 
+       }
+       ip_rt_put(rt);
+       return flag;
+}
 
 /* OBSOLETE FUNCTIONS */
 
@@ -490,7 +490,7 @@ int arp_find(unsigned char *haddr, struct sk_buff *skb)
                n->used = jiffies;
                if (n->nud_state&NUD_VALID || neigh_event_send(n, skb) == 0) {
                        read_lock_bh(&n->lock);
-                       memcpy(haddr, n->ha, dev->addr_len);
+                       memcpy(haddr, n->ha, dev->addr_len);
                        read_unlock_bh(&n->lock);
                        neigh_release(n);
                        return 0;
@@ -572,7 +572,7 @@ struct sk_buff *arp_create(int type, int ptype, __be32 dest_ip,
        /*
         *      Allocate a buffer
         */
-       
+
        skb = alloc_skb(sizeof(struct arphdr)+ 2*(dev->addr_len+4)
                                + LL_RESERVED_SPACE(dev), GFP_ATOMIC);
        if (skb == NULL)
@@ -685,7 +685,7 @@ void arp_send(int type, int ptype, __be32 dest_ip,
        /*
         *      No arp on this interface.
         */
-       
+
        if (dev->flags&IFF_NOARP)
                return;
 
@@ -725,7 +725,7 @@ static int arp_process(struct sk_buff *skb)
        arp = skb->nh.arph;
 
        switch (dev_type) {
-       default:        
+       default:
                if (arp->ar_pro != htons(ETH_P_IP) ||
                    htons(dev_type) != arp->ar_hrd)
                        goto out;
@@ -792,7 +792,7 @@ static int arp_process(struct sk_buff *skb)
        tha     = arp_ptr;
        arp_ptr += dev->addr_len;
        memcpy(&tip, arp_ptr, 4);
-/* 
+/*
  *     Check for bad requests for 127.x.x.x and requests for multicast
  *     addresses.  If this is one such, delete it.
  */
@@ -809,16 +809,16 @@ static int arp_process(struct sk_buff *skb)
  *  Process entry.  The idea here is we want to send a reply if it is a
  *  request for us or if it is a request for someone else that we hold
  *  a proxy for.  We want to add an entry to our cache if it is a reply
- *  to us or if it is a request for our address.  
- *  (The assumption for this last is that if someone is requesting our 
- *  address, they are probably intending to talk to us, so it saves time 
- *  if we cache their address.  Their address is also probably not in 
+ *  to us or if it is a request for our address.
+ *  (The assumption for this last is that if someone is requesting our
+ *  address, they are probably intending to talk to us, so it saves time
+ *  if we cache their address.  Their address is also probably not in
  *  our cache, since ours is not in their cache.)
- * 
+ *
  *  Putting this another way, we only care about replies if they are to
  *  us, in which case we add them to the cache.  For requests, we care
  *  about those for us and those for our proxies.  We reply to both,
- *  and in the case of requests for us we add the requester to the arp 
+ *  and in the case of requests for us we add the requester to the arp
  *  cache.
  */
 
@@ -845,7 +845,7 @@ static int arp_process(struct sk_buff *skb)
                                if (!dont_send)
                                        dont_send |= arp_ignore(in_dev,dev,sip,tip);
                                if (!dont_send && IN_DEV_ARPFILTER(in_dev))
-                                       dont_send |= arp_filter(sip,tip,dev); 
+                                       dont_send |= arp_filter(sip,tip,dev);
                                if (!dont_send)
                                        arp_send(ARPOP_REPLY,ETH_P_ARP,sip,dev,tip,sha,dev->dev_addr,sha);
 
@@ -860,7 +860,7 @@ static int arp_process(struct sk_buff *skb)
                                if (n)
                                        neigh_release(n);
 
-                               if (NEIGH_CB(skb)->flags & LOCALLY_ENQUEUED || 
+                               if (NEIGH_CB(skb)->flags & LOCALLY_ENQUEUED ||
                                    skb->pkt_type == PACKET_HOST ||
                                    in_dev->arp_parms->proxy_delay == 0) {
                                        arp_send(ARPOP_REPLY,ETH_P_ARP,sip,dev,tip,sha,dev->dev_addr,sha);
@@ -1039,7 +1039,7 @@ static int arp_req_set(struct arpreq *r, struct net_device * dev)
                if (r->arp_flags & ATF_PERM)
                        state = NUD_PERMANENT;
                err = neigh_update(neigh, (r->arp_flags&ATF_COM) ?
-                                  r->arp_ha.sa_data : NULL, state, 
+                                  r->arp_ha.sa_data : NULL, state,
                                   NEIGH_UPDATE_F_OVERRIDE|
                                   NEIGH_UPDATE_F_ADMIN);
                neigh_release(neigh);
@@ -1121,7 +1121,7 @@ static int arp_req_delete(struct arpreq *r, struct net_device * dev)
        neigh = neigh_lookup(&arp_tbl, &ip, dev);
        if (neigh) {
                if (neigh->nud_state&~NUD_NOARP)
-                       err = neigh_update(neigh, NULL, NUD_FAILED, 
+                       err = neigh_update(neigh, NULL, NUD_FAILED,
                                           NEIGH_UPDATE_F_OVERRIDE|
                                           NEIGH_UPDATE_F_ADMIN);
                neigh_release(neigh);
@@ -1181,7 +1181,7 @@ int arp_ioctl(unsigned int cmd, void __user *arg)
 
        switch(cmd) {
        case SIOCDARP:
-               err = arp_req_delete(&r, dev);
+               err = arp_req_delete(&r, dev);
                break;
        case SIOCSARP:
                err = arp_req_set(&r, dev);
@@ -1268,14 +1268,14 @@ static char *ax2asc2(ax25_address *a, char *buf)
 
                if (c != ' ') *s++ = c;
        }
-       
+
        *s++ = '-';
 
        if ((n = ((a->ax25_call[6] >> 1) & 0x0F)) > 9) {
                *s++ = '1';
                n -= 10;
        }
-       
+
        *s++ = n + '0';
        *s++ = '\0';
 
@@ -1373,7 +1373,7 @@ static int arp_seq_open(struct inode *inode, struct file *file)
        struct seq_file *seq;
        int rc = -ENOMEM;
        struct neigh_seq_state *s = kzalloc(sizeof(*s), GFP_KERNEL);
-       
+
        if (!s)
                goto out;
 
index 7b068a891953aae4d9e377438319815c3439259b..dd02a45d0f675945c8c85799ac99b4fbea4c9c04 100644 (file)
@@ -29,12 +29,12 @@ int ip4_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
        int oif;
        int err;
 
-       
-       if (addr_len < sizeof(*usin)) 
-               return -EINVAL;
 
-       if (usin->sin_family != AF_INET) 
-               return -EAFNOSUPPORT;
+       if (addr_len < sizeof(*usin))
+               return -EINVAL;
+
+       if (usin->sin_family != AF_INET)
+               return -EAFNOSUPPORT;
 
        sk_dst_reset(sk);
 
@@ -49,15 +49,15 @@ int ip4_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
        err = ip_route_connect(&rt, usin->sin_addr.s_addr, saddr,
                               RT_CONN_FLAGS(sk), oif,
                               sk->sk_protocol,
-                              inet->sport, usin->sin_port, sk);
+                              inet->sport, usin->sin_port, sk, 1);
        if (err)
                return err;
        if ((rt->rt_flags & RTCF_BROADCAST) && !sock_flag(sk, SOCK_BROADCAST)) {
                ip_rt_put(rt);
                return -EACCES;
        }
-       if (!inet->saddr)
-               inet->saddr = rt->rt_src;       /* Update source address */
+       if (!inet->saddr)
+               inet->saddr = rt->rt_src;       /* Update source address */
        if (!inet->rcv_saddr)
                inet->rcv_saddr = rt->rt_src;
        inet->daddr = rt->rt_dst;
index 480ace9819f6d97ea0245b742445481f7fcb14e5..ba5e7f4cd127992809b6256d0ecc21c419215f13 100644 (file)
@@ -252,7 +252,7 @@ static void __inet_del_ifa(struct in_device *in_dev, struct in_ifaddr **ifap,
 
        ASSERT_RTNL();
 
-       /* 1. Deleting primary ifaddr forces deletion all secondaries 
+       /* 1. Deleting primary ifaddr forces deletion all secondaries
         * unless alias promotion is set
         **/
 
@@ -260,7 +260,7 @@ static void __inet_del_ifa(struct in_device *in_dev, struct in_ifaddr **ifap,
                struct in_ifaddr **ifap1 = &ifa1->ifa_next;
 
                while ((ifa = *ifap1) != NULL) {
-                       if (!(ifa->ifa_flags & IFA_F_SECONDARY) && 
+                       if (!(ifa->ifa_flags & IFA_F_SECONDARY) &&
                            ifa1->ifa_scope <= ifa->ifa_scope)
                                last_prim = ifa;
 
@@ -583,8 +583,8 @@ static __inline__ int inet_abc_len(__be32 addr)
 {
        int rc = -1;    /* Something else, probably a multicast. */
 
-       if (ZERONET(addr))
-               rc = 0;
+       if (ZERONET(addr))
+               rc = 0;
        else {
                __u32 haddr = ntohl(addr);
 
@@ -596,7 +596,7 @@ static __inline__ int inet_abc_len(__be32 addr)
                        rc = 24;
        }
 
-       return rc;
+       return rc;
 }
 
 
@@ -1020,29 +1020,29 @@ int unregister_inetaddr_notifier(struct notifier_block *nb)
  * alias numbering and to create unique labels if possible.
 */
 static void inetdev_changename(struct net_device *dev, struct in_device *in_dev)
-{ 
+{
        struct in_ifaddr *ifa;
        int named = 0;
 
-       for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) { 
-               char old[IFNAMSIZ], *dot; 
+       for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) {
+               char old[IFNAMSIZ], *dot;
 
                memcpy(old, ifa->ifa_label, IFNAMSIZ);
-               memcpy(ifa->ifa_label, dev->name, IFNAMSIZ); 
+               memcpy(ifa->ifa_label, dev->name, IFNAMSIZ);
                if (named++ == 0)
                        continue;
                dot = strchr(ifa->ifa_label, ':');
-               if (dot == NULL) { 
-                       sprintf(old, ":%d", named); 
+               if (dot == NULL) {
+                       sprintf(old, ":%d", named);
                        dot = old;
                }
-               if (strlen(dot) + strlen(dev->name) < IFNAMSIZ) { 
-                       strcat(ifa->ifa_label, dot); 
-               } else { 
-                       strcpy(ifa->ifa_label + (IFNAMSIZ - strlen(dot) - 1), dot); 
-               } 
-       }       
-} 
+               if (strlen(dot) + strlen(dev->name) < IFNAMSIZ) {
+                       strcat(ifa->ifa_label, dot);
+               } else {
+                       strcpy(ifa->ifa_label + (IFNAMSIZ - strlen(dot) - 1), dot);
+               }
+       }
+}
 
 /* Called only under RTNL semaphore */
 
@@ -1140,7 +1140,7 @@ static int inet_fill_ifaddr(struct sk_buff *skb, struct in_ifaddr *ifa,
 
        nlh = nlmsg_put(skb, pid, seq, event, sizeof(*ifm), flags);
        if (nlh == NULL)
-               return -ENOBUFS;
+               return -EMSGSIZE;
 
        ifm = nlmsg_data(nlh);
        ifm->ifa_family = AF_INET;
@@ -1167,7 +1167,8 @@ static int inet_fill_ifaddr(struct sk_buff *skb, struct in_ifaddr *ifa,
        return nlmsg_end(skb, nlh);
 
 nla_put_failure:
-       return nlmsg_cancel(skb, nlh);
+       nlmsg_cancel(skb, nlh);
+       return -EMSGSIZE;
 }
 
 static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
@@ -1225,9 +1226,12 @@ static void rtmsg_ifa(int event, struct in_ifaddr* ifa, struct nlmsghdr *nlh,
                goto errout;
 
        err = inet_fill_ifaddr(skb, ifa, pid, seq, event, 0);
-       /* failure implies BUG in inet_nlmsg_size() */
-       BUG_ON(err < 0);
-
+       if (err < 0) {
+               /* -EMSGSIZE implies BUG in inet_nlmsg_size() */
+               WARN_ON(err == -EMSGSIZE);
+               kfree_skb(skb);
+               goto errout;
+       }
        err = rtnl_notify(skb, pid, RTNLGRP_IPV4_IFADDR, nlh, GFP_KERNEL);
 errout:
        if (err < 0)
@@ -1535,7 +1539,7 @@ static struct devinet_sysctl_table {
                },
        },
        .devinet_conf_dir = {
-               {
+               {
                        .ctl_name       = NET_IPV4_CONF,
                        .procname       = "conf",
                        .mode           = 0555,
@@ -1577,18 +1581,18 @@ static void devinet_sysctl_register(struct in_device *in_dev,
        }
 
        if (dev) {
-               dev_name = dev->name; 
+               dev_name = dev->name;
                t->devinet_dev[0].ctl_name = dev->ifindex;
        } else {
                dev_name = "default";
                t->devinet_dev[0].ctl_name = NET_PROTO_CONF_DEFAULT;
        }
 
-       /* 
-        * Make a copy of dev_name, because '.procname' is regarded as const 
+       /*
+        * Make a copy of dev_name, because '.procname' is regarded as const
         * by sysctl and we wouldn't want anyone to change it under our feet
         * (see SIOCSIFNAME).
-        */     
+        */
        dev_name = kstrdup(dev_name, GFP_KERNEL);
        if (!dev_name)
            goto free;
index f2c6776ea0e6e0a8165ff7132f39194d4975a913..31041127eeb8006bb8729fbf769b56ffb1583e9e 100644 (file)
@@ -215,7 +215,7 @@ static int esp_input(struct xfrm_state *x, struct sk_buff *skb)
        if (padlen+2 >= elen)
                goto out;
 
-       /* ... check padding bits here. Silly. :-) */ 
+       /* ... check padding bits here. Silly. :-) */
 
        iph = skb->nh.iph;
        ihl = iph->ihl * 4;
@@ -236,7 +236,7 @@ static int esp_input(struct xfrm_state *x, struct sk_buff *skb)
 
                        ipaddr.a4 = iph->saddr;
                        km_new_mapping(x, &ipaddr, uh->source);
-                               
+
                        /* XXX: perhaps add an extra
                         * policy check here, to see
                         * if we should allow or
@@ -245,7 +245,7 @@ static int esp_input(struct xfrm_state *x, struct sk_buff *skb)
                         * address/port.
                         */
                }
-       
+
                /*
                 * 2) ignore UDP/TCP checksums in case
                 *    of NAT-T in Transport Mode, or
@@ -284,7 +284,7 @@ static u32 esp4_get_max_size(struct xfrm_state *x, int mtu)
                mtu = ALIGN(mtu + 2, 4) + blksize - 4;
                break;
        case XFRM_MODE_BEET:
-               /* The worst case. */
+               /* The worst case. */
                enclen = IPV4_BEET_PHMAXLEN;
                mtu = ALIGN(mtu + enclen + 2, blksize);
                break;
index d47b72af89edeb4a9f506d4f919117de5517d2ae..64f31e63db7f073436a3b805128e0f2df152b5de 100644 (file)
@@ -160,7 +160,7 @@ unsigned inet_addr_type(__be32 addr)
 #ifdef CONFIG_IP_MULTIPLE_TABLES
        res.r = NULL;
 #endif
-       
+
        if (ip_fib_local_table) {
                ret = RTN_UNICAST;
                if (!ip_fib_local_table->tb_lookup(ip_fib_local_table,
@@ -378,7 +378,7 @@ static int rtentry_to_fib_config(int cmd, struct rtentry *rt,
                int len = 0;
 
                mx = kzalloc(3 * nla_total_size(4), GFP_KERNEL);
-               if (mx == NULL)
+               if (mx == NULL)
                        return -ENOMEM;
 
                if (rt->rt_flags & RTF_MTU)
@@ -400,7 +400,7 @@ static int rtentry_to_fib_config(int cmd, struct rtentry *rt,
 /*
  *     Handle IP routing ioctl calls. These are used to manipulate the routing tables
  */
+
 int ip_rt_ioctl(unsigned int cmd, void __user *arg)
 {
        struct fib_config cfg;
@@ -600,7 +600,7 @@ int inet_dump_fib(struct sk_buff *skb, struct netlink_callback *cb)
                                goto next;
                        if (dumped)
                                memset(&cb->args[2], 0, sizeof(cb->args) -
-                                                2 * sizeof(cb->args[0]));
+                                                2 * sizeof(cb->args[0]));
                        if (tb->tb_dump(tb, skb, cb) < 0)
                                goto out;
                        dumped = 1;
@@ -766,7 +766,7 @@ static void fib_del_ifaddr(struct in_ifaddr *ifa)
 
 static void nl_fib_lookup(struct fib_result_nl *frn, struct fib_table *tb )
 {
-       
+
        struct fib_result       res;
        struct flowi            fl = { .mark = frn->fl_mark,
                                       .nl_u = { .ip4_u = { .daddr = frn->fl_addr,
@@ -791,11 +791,11 @@ static void nl_fib_lookup(struct fib_result_nl *frn, struct fib_table *tb )
 static void nl_fib_input(struct sock *sk, int len)
 {
        struct sk_buff *skb = NULL;
-        struct nlmsghdr *nlh = NULL;
+       struct nlmsghdr *nlh = NULL;
        struct fib_result_nl *frn;
-       u32 pid;     
+       u32 pid;
        struct fib_table *tb;
-       
+
        skb = skb_dequeue(&sk->sk_receive_queue);
        nlh = (struct nlmsghdr *)skb->data;
        if (skb->len < NLMSG_SPACE(0) || skb->len < nlh->nlmsg_len ||
@@ -803,17 +803,17 @@ static void nl_fib_input(struct sock *sk, int len)
                kfree_skb(skb);
                return;
        }
-       
+
        frn = (struct fib_result_nl *) NLMSG_DATA(nlh);
        tb = fib_get_table(frn->tb_id_in);
 
        nl_fib_lookup(frn, tb);
-       
+
        pid = nlh->nlmsg_pid;           /*pid of sending process */
        NETLINK_CB(skb).pid = 0;         /* from kernel */
        NETLINK_CB(skb).dst_group = 0;  /* unicast */
        netlink_unicast(sk, skb, pid, MSG_DONTWAIT);
-}    
+}
 
 static void nl_fib_lookup_init(void)
 {
index 648f47c1c399e262c86cfc22588ff257a5babcd5..dea04d725b04d00a9d0009ed1e3fc0cf5e8c1e1b 100644 (file)
@@ -146,7 +146,7 @@ static void fn_rehash_zone(struct fn_zone *fz)
        struct hlist_head *ht, *old_ht;
        int old_divisor, new_divisor;
        u32 new_hashmask;
-               
+
        old_divisor = fz->fz_divisor;
 
        switch (old_divisor) {
@@ -911,7 +911,7 @@ static struct fib_alias *fib_get_next(struct seq_file *seq)
 
                if (!iter->zone)
                        goto out;
-               
+
                iter->bucket = 0;
                iter->hash_head = iter->zone->fz_hash;
 
@@ -932,7 +932,7 @@ static struct fib_alias *fib_get_idx(struct seq_file *seq, loff_t pos)
 {
        struct fib_iter_state *iter = seq->private;
        struct fib_alias *fa;
-       
+
        if (iter->valid && pos >= iter->pos && iter->genid == fib_hash_genid) {
                fa   = iter->fa;
                pos -= iter->pos;
@@ -981,7 +981,7 @@ static unsigned fib_flag_trans(int type, __be32 mask, struct fib_info *fi)
        return flags;
 }
 
-/* 
+/*
  *     This outputs /proc/net/route.
  *
  *     It always works in backward compatibility mode.
@@ -1040,7 +1040,7 @@ static int fib_seq_open(struct inode *inode, struct file *file)
        struct seq_file *seq;
        int rc = -ENOMEM;
        struct fib_iter_state *s = kzalloc(sizeof(*s), GFP_KERNEL);
-       
+
        if (!s)
                goto out;
 
index e63b8a98fb4df624b91f0bb44bf06e864570d7f5..2f1fdae6efa6df82489b850fe93e227c230dcc09 100644 (file)
@@ -85,12 +85,12 @@ for (nhsel=0; nhsel < 1; nhsel++)
 #define endfor_nexthops(fi) }
 
 
-static const struct 
+static const struct
 {
        int     error;
        u8      scope;
 } fib_props[RTA_MAX + 1] = {
-        {
+       {
                .error  = 0,
                .scope  = RT_SCOPE_NOWHERE,
        },      /* RTN_UNSPEC */
@@ -314,9 +314,12 @@ void rtmsg_fib(int event, __be32 key, struct fib_alias *fa,
        err = fib_dump_info(skb, info->pid, seq, event, tb_id,
                            fa->fa_type, fa->fa_scope, key, dst_len,
                            fa->fa_tos, fa->fa_info, 0);
-       /* failure implies BUG in fib_nlmsg_size() */
-       BUG_ON(err < 0);
-
+       if (err < 0) {
+               /* -EMSGSIZE implies BUG in fib_nlmsg_size() */
+               WARN_ON(err == -EMSGSIZE);
+               kfree_skb(skb);
+               goto errout;
+       }
        err = rtnl_notify(skb, info->pid, RTNLGRP_IPV4_ROUTE,
                          info->nlh, GFP_KERNEL);
 errout:
@@ -436,7 +439,7 @@ int fib_nh_match(struct fib_config *cfg, struct fib_info *fi)
 
        rtnh = cfg->fc_mp;
        remaining = cfg->fc_mp_len;
-       
+
        for_nexthops(fi) {
                int attrlen;
 
@@ -505,9 +508,9 @@ int fib_nh_match(struct fib_config *cfg, struct fib_info *fi)
    Normally it looks as following.
 
    {universe prefix}  -> (gw, oif) [scope link]
-                          |
+                         |
                          |-> {link prefix} -> (gw, oif) [scope local]
-                                               |
+                                               |
                                                |-> {local prefix} (terminal node)
  */
 
@@ -861,7 +864,7 @@ err_inval:
        err = -EINVAL;
 
 failure:
-        if (fi) {
+       if (fi) {
                fi->fib_dead = 1;
                free_fib_info(fi);
        }
@@ -960,7 +963,7 @@ int fib_dump_info(struct sk_buff *skb, u32 pid, u32 seq, int event,
 
        nlh = nlmsg_put(skb, pid, seq, event, sizeof(*rtm), flags);
        if (nlh == NULL)
-               return -ENOBUFS;
+               return -EMSGSIZE;
 
        rtm = nlmsg_data(nlh);
        rtm->rtm_family = AF_INET;
@@ -1031,7 +1034,8 @@ int fib_dump_info(struct sk_buff *skb, u32 pid, u32 seq, int event,
        return nlmsg_end(skb, nlh);
 
 nla_put_failure:
-       return nlmsg_cancel(skb, nlh);
+       nlmsg_cancel(skb, nlh);
+       return -EMSGSIZE;
 }
 
 /*
@@ -1045,7 +1049,7 @@ int fib_sync_down(__be32 local, struct net_device *dev, int force)
 {
        int ret = 0;
        int scope = RT_SCOPE_NOWHERE;
-       
+
        if (force)
                scope = -1;
 
index 1e589b91605efa36518f0abe338a7adc674bd38e..004a437bd7b50bffbcccd2f83cecc83d82160bca 100644 (file)
@@ -7,13 +7,13 @@
  *   Robert Olsson <robert.olsson@its.uu.se> Uppsala Universitet
  *     & Swedish University of Agricultural Sciences.
  *
- *   Jens Laas <jens.laas@data.slu.se> Swedish University of 
+ *   Jens Laas <jens.laas@data.slu.se> Swedish University of
  *     Agricultural Sciences.
- * 
+ *
  *   Hans Liss <hans.liss@its.uu.se>  Uppsala Universitet
  *
  * This work is based on the LPC-trie which is originally descibed in:
- * 
+ *
  * An experimental study of compression methods for dynamic tries
  * Stefan Nilsson and Matti Tikkanen. Algorithmica, 33(1):19-33, 2002.
  * http://www.nada.kth.se/~snilsson/public/papers/dyntrie2/
@@ -224,34 +224,34 @@ static inline int tkey_mismatch(t_key a, int offset, t_key b)
 }
 
 /*
-  To understand this stuff, an understanding of keys and all their bits is 
-  necessary. Every node in the trie has a key associated with it, but not 
+  To understand this stuff, an understanding of keys and all their bits is
+  necessary. Every node in the trie has a key associated with it, but not
   all of the bits in that key are significant.
 
   Consider a node 'n' and its parent 'tp'.
 
-  If n is a leaf, every bit in its key is significant. Its presence is 
-  necessitated by path compression, since during a tree traversal (when 
-  searching for a leaf - unless we are doing an insertion) we will completely 
-  ignore all skipped bits we encounter. Thus we need to verify, at the end of 
-  a potentially successful search, that we have indeed been walking the 
+  If n is a leaf, every bit in its key is significant. Its presence is
+  necessitated by path compression, since during a tree traversal (when
+  searching for a leaf - unless we are doing an insertion) we will completely
+  ignore all skipped bits we encounter. Thus we need to verify, at the end of
+  a potentially successful search, that we have indeed been walking the
   correct key path.
 
-  Note that we can never "miss" the correct key in the tree if present by 
-  following the wrong path. Path compression ensures that segments of the key 
-  that are the same for all keys with a given prefix are skipped, but the 
-  skipped part *is* identical for each node in the subtrie below the skipped 
-  bit! trie_insert() in this implementation takes care of that - note the 
+  Note that we can never "miss" the correct key in the tree if present by
+  following the wrong path. Path compression ensures that segments of the key
+  that are the same for all keys with a given prefix are skipped, but the
+  skipped part *is* identical for each node in the subtrie below the skipped
+  bit! trie_insert() in this implementation takes care of that - note the
   call to tkey_sub_equals() in trie_insert().
 
-  if n is an internal node - a 'tnode' here, the various parts of its key 
+  if n is an internal node - a 'tnode' here, the various parts of its key
   have many different meanings.
 
-  Example:  
+  Example:
   _________________________________________________________________
   | i | i | i | i | i | i | i | N | N | N | S | S | S | S | S | C |
   -----------------------------------------------------------------
-    0   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15 
+    0   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15
 
   _________________________________________________________________
   | C | C | C | u | u | u | u | u | u | u | u | u | u | u | u | u |
@@ -263,23 +263,23 @@ static inline int tkey_mismatch(t_key a, int offset, t_key b)
   n->pos = 15
   n->bits = 4
 
-  First, let's just ignore the bits that come before the parent tp, that is 
-  the bits from 0 to (tp->pos-1). They are *known* but at this point we do 
+  First, let's just ignore the bits that come before the parent tp, that is
+  the bits from 0 to (tp->pos-1). They are *known* but at this point we do
   not use them for anything.
 
   The bits from (tp->pos) to (tp->pos + tp->bits - 1) - "N", above - are the
-  index into the parent's child array. That is, they will be used to find 
+  index into the parent's child array. That is, they will be used to find
   'n' among tp's children.
 
   The bits from (tp->pos + tp->bits) to (n->pos - 1) - "S" - are skipped bits
   for the node n.
 
-  All the bits we have seen so far are significant to the node n. The rest 
+  All the bits we have seen so far are significant to the node n. The rest
   of the bits are really not needed or indeed known in n->key.
 
-  The bits from (n->pos) to (n->pos + n->bits - 1) - "C" - are the index into 
+  The bits from (n->pos) to (n->pos + n->bits - 1) - "C" - are the index into
   n's child array, and will of course be different for each child.
-  
+
 
   The rest of the bits, from (n->pos + n->bits) onward, are completely unknown
   at this point.
@@ -294,7 +294,7 @@ static inline void check_tnode(const struct tnode *tn)
 static int halve_threshold = 25;
 static int inflate_threshold = 50;
 static int halve_threshold_root = 15;
-static int inflate_threshold_root = 25; 
+static int inflate_threshold_root = 25;
 
 
 static void __alias_free_mem(struct rcu_head *head)
@@ -355,7 +355,7 @@ static inline void tnode_free(struct tnode *tn)
                struct leaf *l = (struct leaf *) tn;
                call_rcu_bh(&l->rcu, __leaf_free_rcu);
        }
-        else
+       else
                call_rcu(&tn->rcu, __tnode_free_rcu);
 }
 
@@ -461,7 +461,7 @@ static struct node *resize(struct trie *t, struct tnode *tn)
        int inflate_threshold_use;
        int halve_threshold_use;
 
-       if (!tn)
+       if (!tn)
                return NULL;
 
        pr_debug("In tnode_resize %p inflate_threshold=%d threshold=%d\n",
@@ -556,7 +556,7 @@ static struct node *resize(struct trie *t, struct tnode *tn)
 
        if(!tn->parent)
                inflate_threshold_use = inflate_threshold_root;
-       else 
+       else
                inflate_threshold_use = inflate_threshold;
 
        err = 0;
@@ -587,7 +587,7 @@ static struct node *resize(struct trie *t, struct tnode *tn)
 
        if(!tn->parent)
                halve_threshold_use = halve_threshold_root;
-       else 
+       else
                halve_threshold_use = halve_threshold;
 
        err = 0;
@@ -665,10 +665,10 @@ static struct tnode *inflate(struct trie *t, struct tnode *tn)
                        right = tnode_new(inode->key|m, inode->pos + 1,
                                          inode->bits - 1);
 
-                        if (!right) {
+                       if (!right) {
                                tnode_free(left);
                                goto nomem;
-                        }
+                       }
 
                        put_child(t, tn, 2*i, (struct node *) left);
                        put_child(t, tn, 2*i+1, (struct node *) right);
@@ -890,23 +890,23 @@ static inline struct list_head * get_fa_head(struct leaf *l, int plen)
 
 static void insert_leaf_info(struct hlist_head *head, struct leaf_info *new)
 {
-        struct leaf_info *li = NULL, *last = NULL;
-        struct hlist_node *node;
+       struct leaf_info *li = NULL, *last = NULL;
+       struct hlist_node *node;
 
-        if (hlist_empty(head)) {
-                hlist_add_head_rcu(&new->hlist, head);
-        } else {
-                hlist_for_each_entry(li, node, head, hlist) {
-                        if (new->plen > li->plen)
-                                break;
+       if (hlist_empty(head)) {
+               hlist_add_head_rcu(&new->hlist, head);
+       } else {
+               hlist_for_each_entry(li, node, head, hlist) {
+                       if (new->plen > li->plen)
+                               break;
 
-                        last = li;
-                }
-                if (last)
-                        hlist_add_after_rcu(&last->hlist, &new->hlist);
-                else
-                        hlist_add_before_rcu(&new->hlist, &li->hlist);
-        }
+                       last = li;
+               }
+               if (last)
+                       hlist_add_after_rcu(&last->hlist, &new->hlist);
+               else
+                       hlist_add_before_rcu(&new->hlist, &li->hlist);
+       }
 }
 
 /* rcu_read_lock needs to be hold by caller from readside */
@@ -1700,7 +1700,7 @@ static struct leaf *nextleaf(struct trie *t, struct leaf *thisleaf)
                        /* Decend if tnode */
                        while (IS_TNODE(c)) {
                                p = (struct tnode *) c;
-                               idx = 0;
+                               idx = 0;
 
                                /* Rightmost non-NULL branch */
                                if (p && IS_TNODE(p))
@@ -2303,9 +2303,9 @@ static int fib_trie_seq_show(struct seq_file *seq, void *v)
 
                seq_indent(seq, iter->depth-1);
                seq_printf(seq, "  +-- %d.%d.%d.%d/%d %d %d %d\n",
-                          NIPQUAD(prf), tn->pos, tn->bits, tn->full_children, 
+                          NIPQUAD(prf), tn->pos, tn->bits, tn->full_children,
                           tn->empty_children);
-               
+
        } else {
                struct leaf *l = (struct leaf *) n;
                int i;
index 40cf0d0e1b83c21d4f2ba675aea2b764ab027550..4b7a0d946a0d2a78a17220902d5a52c84d8c7ece 100644 (file)
@@ -304,7 +304,7 @@ static inline int icmpv4_xrlim_allow(struct rtable *rt, int type, int code)
 
        /* No rate limit on loopback */
        if (dst->dev && (dst->dev->flags&IFF_LOOPBACK))
-               goto out;
+               goto out;
 
        /* Limit if icmp type is enabled in ratemask. */
        if ((1 << type) & sysctl_icmp_ratemask)
@@ -350,9 +350,9 @@ static void icmp_push_reply(struct icmp_bxm *icmp_param,
        struct sk_buff *skb;
 
        if (ip_append_data(icmp_socket->sk, icmp_glue_bits, icmp_param,
-                          icmp_param->data_len+icmp_param->head_len,
-                          icmp_param->head_len,
-                          ipc, rt, MSG_DONTWAIT) < 0)
+                          icmp_param->data_len+icmp_param->head_len,
+                          icmp_param->head_len,
+                          ipc, rt, MSG_DONTWAIT) < 0)
                ip_flush_pending_frames(icmp_socket->sk);
        else if ((skb = skb_peek(&icmp_socket->sk->sk_write_queue)) != NULL) {
                struct icmphdr *icmph = skb->h.icmph;
@@ -755,7 +755,7 @@ static void icmp_redirect(struct sk_buff *skb)
                               skb->h.icmph->un.gateway,
                               iph->saddr, skb->dev);
                break;
-       }
+       }
 out:
        return;
 out_err:
@@ -959,7 +959,7 @@ int icmp_rcv(struct sk_buff *skb)
         *      Parse the ICMP message
         */
 
-       if (rt->rt_flags & (RTCF_BROADCAST | RTCF_MULTICAST)) {
+       if (rt->rt_flags & (RTCF_BROADCAST | RTCF_MULTICAST)) {
                /*
                 *      RFC 1122: 3.2.2.6 An ICMP_ECHO to broadcast MAY be
                 *        silently ignored (we let user decide with a sysctl).
@@ -976,7 +976,7 @@ int icmp_rcv(struct sk_buff *skb)
                    icmph->type != ICMP_ADDRESS &&
                    icmph->type != ICMP_ADDRESSREPLY) {
                        goto error;
-               }
+               }
        }
 
        ICMP_INC_STATS_BH(icmp_pointers[icmph->type].input_entry);
@@ -1085,7 +1085,7 @@ static const struct icmp_control icmp_pointers[NR_ICMP_TYPES + 1] = {
                .input_entry = ICMP_MIB_DUMMY,
                .handler = icmp_discard,
        },
-       [ICMP_INFO_REPLY] = {
+       [ICMP_INFO_REPLY] = {
                .output_entry = ICMP_MIB_DUMMY,
                .input_entry = ICMP_MIB_DUMMY,
                .handler = icmp_discard,
index 0017ccb01d6d3dd0891036cc1a7837bfad7da738..b8e1625d34cfe2de876c99b095679d1956c9191f 100644 (file)
@@ -35,7 +35,7 @@
  *
  *             Chih-Jen Chang  :       Tried to revise IGMP to Version 2
  *             Tsu-Sheng Tsao          E-mail: chihjenc@scf.usc.edu and tsusheng@scf.usc.edu
- *                                     The enhancements are mainly based on Steve Deering's 
+ *                                     The enhancements are mainly based on Steve Deering's
  *                                     ipmulti-3.5 source code.
  *             Chih-Jen Chang  :       Added the igmp_get_mrouter_info and
  *             Tsu-Sheng Tsao          igmp_set_mrouter_info to keep track of
  *             Alan Cox        :       Stop IGMP from 0.0.0.0 being accepted.
  *             Alan Cox        :       Use GFP_ATOMIC in the right places.
  *             Christian Daudt :       igmp timer wasn't set for local group
- *                                     memberships but was being deleted, 
- *                                     which caused a "del_timer() called 
+ *                                     memberships but was being deleted,
+ *                                     which caused a "del_timer() called
  *                                     from %p with timer not initialized\n"
  *                                     message (960131).
- *             Christian Daudt :       removed del_timer from 
+ *             Christian Daudt :       removed del_timer from
  *                                     igmp_timer_expire function (960205).
  *             Christian Daudt :       igmp_heard_report now only calls
  *                                     igmp_timer_expire if tm->running is
@@ -455,6 +455,8 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ip_mc_list *pmc,
                        skb = add_grhead(skb, pmc, type, &pgr);
                        first = 0;
                }
+               if (!skb)
+                       return NULL;
                psrc = (__be32 *)skb_put(skb, sizeof(__be32));
                *psrc = psf->sf_inaddr;
                scount++; stotal++;
@@ -716,7 +718,7 @@ static void igmp_ifc_event(struct in_device *in_dev)
 {
        if (IGMP_V1_SEEN(in_dev) || IGMP_V2_SEEN(in_dev))
                return;
-       in_dev->mr_ifc_count = in_dev->mr_qrv ? in_dev->mr_qrv : 
+       in_dev->mr_ifc_count = in_dev->mr_qrv ? in_dev->mr_qrv :
                IGMP_Unsolicited_Report_Count;
        igmp_ifc_start_timer(in_dev, 1);
 }
@@ -836,7 +838,7 @@ static void igmp_heard_query(struct in_device *in_dev, struct sk_buff *skb,
        if (len == 8) {
                if (ih->code == 0) {
                        /* Alas, old v1 router presents here. */
-       
+
                        max_delay = IGMP_Query_Response_Interval;
                        in_dev->mr_v1_seen = jiffies +
                                IGMP_V1_Router_Present_Timeout;
@@ -858,10 +860,10 @@ static void igmp_heard_query(struct in_device *in_dev, struct sk_buff *skb,
        } else { /* v3 */
                if (!pskb_may_pull(skb, sizeof(struct igmpv3_query)))
                        return;
-               
+
                ih3 = (struct igmpv3_query *) skb->h.raw;
                if (ih3->nsrcs) {
-                       if (!pskb_may_pull(skb, sizeof(struct igmpv3_query) 
+                       if (!pskb_may_pull(skb, sizeof(struct igmpv3_query)
                                           + ntohs(ih3->nsrcs)*sizeof(__be32)))
                                return;
                        ih3 = (struct igmpv3_query *) skb->h.raw;
@@ -907,7 +909,7 @@ static void igmp_heard_query(struct in_device *in_dev, struct sk_buff *skb,
                else
                        im->gsquery = mark;
                changed = !im->gsquery ||
-                       igmp_marksources(im, ntohs(ih3->nsrcs), ih3->srcs);
+                       igmp_marksources(im, ntohs(ih3->nsrcs), ih3->srcs);
                spin_unlock_bh(&im->lock);
                if (changed)
                        igmp_mod_timer(im, max_delay);
@@ -1255,9 +1257,9 @@ out:
 void ip_mc_dec_group(struct in_device *in_dev, __be32 addr)
 {
        struct ip_mc_list *i, **ip;
-       
+
        ASSERT_RTNL();
-       
+
        for (ip=&in_dev->mc_list; (i=*ip)!=NULL; ip=&i->next) {
                if (i->multiaddr==addr) {
                        if (--i->users == 0) {
@@ -1434,7 +1436,7 @@ static int ip_mc_del1_src(struct ip_mc_list *pmc, int sfmode,
 #ifdef CONFIG_IP_MULTICAST
                if (psf->sf_oldin &&
                    !IGMP_V1_SEEN(in_dev) && !IGMP_V2_SEEN(in_dev)) {
-                       psf->sf_crcount = in_dev->mr_qrv ? in_dev->mr_qrv : 
+                       psf->sf_crcount = in_dev->mr_qrv ? in_dev->mr_qrv :
                                IGMP_Unsolicited_Report_Count;
                        psf->sf_next = pmc->tomb;
                        pmc->tomb = psf;
@@ -1498,7 +1500,7 @@ static int ip_mc_del_src(struct in_device *in_dev, __be32 *pmca, int sfmode,
                /* filter mode change */
                pmc->sfmode = MCAST_INCLUDE;
 #ifdef CONFIG_IP_MULTICAST
-               pmc->crcount = in_dev->mr_qrv ? in_dev->mr_qrv : 
+               pmc->crcount = in_dev->mr_qrv ? in_dev->mr_qrv :
                        IGMP_Unsolicited_Report_Count;
                in_dev->mr_ifc_count = pmc->crcount;
                for (psf=pmc->sources; psf; psf = psf->sf_next)
@@ -1677,7 +1679,7 @@ static int ip_mc_add_src(struct in_device *in_dev, __be32 *pmca, int sfmode,
 #ifdef CONFIG_IP_MULTICAST
                /* else no filters; keep old mode for reports */
 
-               pmc->crcount = in_dev->mr_qrv ? in_dev->mr_qrv : 
+               pmc->crcount = in_dev->mr_qrv ? in_dev->mr_qrv :
                        IGMP_Unsolicited_Report_Count;
                in_dev->mr_ifc_count = pmc->crcount;
                for (psf=pmc->sources; psf; psf = psf->sf_next)
@@ -1871,7 +1873,7 @@ int ip_mc_source(int add, int omode, struct sock *sk, struct
        } else if (pmc->sfmode != omode) {
                /* allow mode switches for empty-set filters */
                ip_mc_add_src(in_dev, &mreqs->imr_multiaddr, omode, 0, NULL, 0);
-               ip_mc_del_src(in_dev, &mreqs->imr_multiaddr, pmc->sfmode, 0, 
+               ip_mc_del_src(in_dev, &mreqs->imr_multiaddr, pmc->sfmode, 0,
                        NULL, 0);
                pmc->sfmode = omode;
        }
@@ -1897,7 +1899,7 @@ int ip_mc_source(int add, int omode, struct sock *sk, struct
                }
 
                /* update the interface filter */
-               ip_mc_del_src(in_dev, &mreqs->imr_multiaddr, omode, 1, 
+               ip_mc_del_src(in_dev, &mreqs->imr_multiaddr, omode, 1,
                        &mreqs->imr_sourceaddr, 1);
 
                for (j=i+1; j<psl->sl_count; j++)
@@ -1947,7 +1949,7 @@ int ip_mc_source(int add, int omode, struct sock *sk, struct
        psl->sl_count++;
        err = 0;
        /* update the interface list */
-       ip_mc_add_src(in_dev, &mreqs->imr_multiaddr, omode, 1, 
+       ip_mc_add_src(in_dev, &mreqs->imr_multiaddr, omode, 1,
                &mreqs->imr_sourceaddr, 1);
 done:
        rtnl_unlock();
@@ -2262,7 +2264,7 @@ static inline struct ip_mc_list *igmp_mc_get_first(struct seq_file *seq)
        struct igmp_mc_iter_state *state = igmp_mc_seq_private(seq);
 
        for (state->dev = dev_base, state->in_dev = NULL;
-            state->dev; 
+            state->dev;
             state->dev = state->dev->next) {
                struct in_device *in_dev;
                in_dev = in_dev_get(state->dev);
@@ -2344,7 +2346,7 @@ static void igmp_mc_seq_stop(struct seq_file *seq, void *v)
 static int igmp_mc_seq_show(struct seq_file *seq, void *v)
 {
        if (v == SEQ_START_TOKEN)
-               seq_puts(seq, 
+               seq_puts(seq,
                         "Idx\tDevice    : Count Querier\tGroup    Users Timer\tReporter\n");
        else {
                struct ip_mc_list *im = (struct ip_mc_list *)v;
@@ -2424,7 +2426,7 @@ static inline struct ip_sf_list *igmp_mcf_get_first(struct seq_file *seq)
        struct igmp_mcf_iter_state *state = igmp_mcf_seq_private(seq);
 
        for (state->dev = dev_base, state->idev = NULL, state->im = NULL;
-            state->dev; 
+            state->dev;
             state->dev = state->dev->next) {
                struct in_device *idev;
                idev = in_dev_get(state->dev);
@@ -2529,7 +2531,7 @@ static int igmp_mcf_seq_show(struct seq_file *seq, void *v)
        struct igmp_mcf_iter_state *state = igmp_mcf_seq_private(seq);
 
        if (v == SEQ_START_TOKEN) {
-               seq_printf(seq, 
+               seq_printf(seq,
                           "%3s %6s "
                           "%10s %10s %6s %6s\n", "Idx",
                           "Device", "MCA",
@@ -2537,8 +2539,8 @@ static int igmp_mcf_seq_show(struct seq_file *seq, void *v)
        } else {
                seq_printf(seq,
                           "%3d %6.6s 0x%08x "
-                          "0x%08x %6lu %6lu\n", 
-                          state->dev->ifindex, state->dev->name, 
+                          "0x%08x %6lu %6lu\n",
+                          state->dev->ifindex, state->dev->name,
                           ntohl(state->im->multiaddr),
                           ntohl(psf->sf_inaddr),
                           psf->sf_count[MCAST_INCLUDE],
index 9d68837888d376d186e76d4eedf839d4ebb1bc29..43fb1600f1f03904846bc3d53a98c73e0f729a61 100644 (file)
@@ -149,7 +149,7 @@ success:
        if (!inet_csk(sk)->icsk_bind_hash)
                inet_bind_hash(sk, tb, snum);
        BUG_TRAP(inet_csk(sk)->icsk_bind_hash == tb);
-       ret = 0;
+       ret = 0;
 
 fail_unlock:
        spin_unlock(&head->lock);
@@ -255,7 +255,7 @@ EXPORT_SYMBOL(inet_csk_accept);
 
 /*
  * Using different timers for retransmit, delayed acks and probes
- * We may wish use just one timer maintaining a list of expire jiffies 
+ * We may wish use just one timer maintaining a list of expire jiffies
  * to optimize.
  */
 void inet_csk_init_xmit_timers(struct sock *sk,
@@ -273,7 +273,7 @@ void inet_csk_init_xmit_timers(struct sock *sk,
        icsk->icsk_delack_timer.function     = delack_handler;
        sk->sk_timer.function                = keepalive_handler;
 
-       icsk->icsk_retransmit_timer.data = 
+       icsk->icsk_retransmit_timer.data =
                icsk->icsk_delack_timer.data =
                        sk->sk_timer.data  = (unsigned long)sk;
 
index 77761ac4f7bb0589bc22d89127e3d64abb14c65a..5df71cd08da811e65b354abb82ed9103664d0e73 100644 (file)
@@ -153,7 +153,7 @@ static int inet_csk_diag_fill(struct sock *sk,
 rtattr_failure:
 nlmsg_failure:
        skb_trim(skb, b - skb->data);
-       return -1;
+       return -EMSGSIZE;
 }
 
 static int inet_twsk_diag_fill(struct inet_timewait_sock *tw,
@@ -209,7 +209,7 @@ static int inet_twsk_diag_fill(struct inet_timewait_sock *tw,
        return skb->len;
 nlmsg_failure:
        skb_trim(skb, previous_tail - skb->data);
-       return -1;
+       return -EMSGSIZE;
 }
 
 static int sk_diag_fill(struct sock *sk, struct sk_buff *skb,
@@ -274,11 +274,14 @@ static int inet_diag_get_exact(struct sk_buff *in_skb,
        if (!rep)
                goto out;
 
-       if (sk_diag_fill(sk, rep, req->idiag_ext,
-                        NETLINK_CB(in_skb).pid,
-                        nlh->nlmsg_seq, 0, nlh) <= 0)
-               BUG();
-
+       err = sk_diag_fill(sk, rep, req->idiag_ext,
+                          NETLINK_CB(in_skb).pid,
+                          nlh->nlmsg_seq, 0, nlh);
+       if (err < 0) {
+               WARN_ON(err == -EMSGSIZE);
+               kfree_skb(rep);
+               goto out;
+       }
        err = netlink_unicast(idiagnl, rep, NETLINK_CB(in_skb).pid,
                              MSG_DONTWAIT);
        if (err > 0)
@@ -378,7 +381,7 @@ static int inet_diag_bc_run(const void *bc, int len,
                                if (addr[0] == 0 && addr[1] == 0 &&
                                    addr[2] == htonl(0xffff) &&
                                    bitstring_match(addr + 3, cond->addr,
-                                                   cond->prefix_len))
+                                                   cond->prefix_len))
                                        break;
                        }
                        yes = 0;
@@ -515,7 +518,7 @@ static int inet_twsk_diag_dump(struct inet_timewait_sock *tw,
                }
                entry.sport = tw->tw_num;
                entry.dport = ntohs(tw->tw_dport);
-               entry.userlocks = 0; 
+               entry.userlocks = 0;
 
                if (!inet_diag_bc_run(RTA_DATA(bc), RTA_PAYLOAD(bc), &entry))
                        return 0;
@@ -775,7 +778,7 @@ next_normal:
                        struct inet_timewait_sock *tw;
 
                        inet_twsk_for_each(tw, node,
-                                   &hashinfo->ehash[i + hashinfo->ehash_size].chain) {
+                                   &head->twchain) {
 
                                if (num < s_num)
                                        goto next_dying;
index 8c79c8a4ea5c2e2daee5f9184d2401ddd60b3192..fb662621c54ecf65a5812726859553b8e03a42d8 100644 (file)
@@ -212,7 +212,7 @@ static int __inet_check_established(struct inet_timewait_death_row *death_row,
        write_lock(&head->lock);
 
        /* Check TIME-WAIT sockets first. */
-       sk_for_each(sk2, node, &(head + hinfo->ehash_size)->chain) {
+       sk_for_each(sk2, node, &head->twchain) {
                tw = inet_twsk(sk2);
 
                if (INET_TW_MATCH(sk2, hash, acookie, saddr, daddr, ports, dif)) {
@@ -262,7 +262,7 @@ not_unique:
 static inline u32 inet_sk_port_offset(const struct sock *sk)
 {
        const struct inet_sock *inet = inet_sk(sk);
-       return secure_ipv4_port_ephemeral(inet->rcv_saddr, inet->daddr, 
+       return secure_ipv4_port_ephemeral(inet->rcv_saddr, inet->daddr,
                                          inet->dport);
 }
 
@@ -274,81 +274,81 @@ int inet_hash_connect(struct inet_timewait_death_row *death_row,
 {
        struct inet_hashinfo *hinfo = death_row->hashinfo;
        const unsigned short snum = inet_sk(sk)->num;
-       struct inet_bind_hashbucket *head;
-       struct inet_bind_bucket *tb;
+       struct inet_bind_hashbucket *head;
+       struct inet_bind_bucket *tb;
        int ret;
 
-       if (!snum) {
-               int low = sysctl_local_port_range[0];
-               int high = sysctl_local_port_range[1];
+       if (!snum) {
+               int low = sysctl_local_port_range[0];
+               int high = sysctl_local_port_range[1];
                int range = high - low;
-               int i;
+               int i;
                int port;
                static u32 hint;
                u32 offset = hint + inet_sk_port_offset(sk);
                struct hlist_node *node;
-               struct inet_timewait_sock *tw = NULL;
+               struct inet_timewait_sock *tw = NULL;
 
-               local_bh_disable();
+               local_bh_disable();
                for (i = 1; i <= range; i++) {
                        port = low + (i + offset) % range;
-                       head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];
-                       spin_lock(&head->lock);
+                       head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];
+                       spin_lock(&head->lock);
 
-                       /* Does not bother with rcv_saddr checks,
-                        * because the established check is already
-                        * unique enough.
-                        */
+                       /* Does not bother with rcv_saddr checks,
+                        * because the established check is already
+                        * unique enough.
+                        */
                        inet_bind_bucket_for_each(tb, node, &head->chain) {
-                               if (tb->port == port) {
-                                       BUG_TRAP(!hlist_empty(&tb->owners));
-                                       if (tb->fastreuse >= 0)
-                                               goto next_port;
-                                       if (!__inet_check_established(death_row,
+                               if (tb->port == port) {
+                                       BUG_TRAP(!hlist_empty(&tb->owners));
+                                       if (tb->fastreuse >= 0)
+                                               goto next_port;
+                                       if (!__inet_check_established(death_row,
                                                                      sk, port,
                                                                      &tw))
-                                               goto ok;
-                                       goto next_port;
-                               }
-                       }
-
-                       tb = inet_bind_bucket_create(hinfo->bind_bucket_cachep, head, port);
-                       if (!tb) {
-                               spin_unlock(&head->lock);
-                               break;
-                       }
-                       tb->fastreuse = -1;
-                       goto ok;
-
-               next_port:
-                       spin_unlock(&head->lock);
-               }
-               local_bh_enable();
-
-               return -EADDRNOTAVAIL;
+                                               goto ok;
+                                       goto next_port;
+                               }
+                       }
+
+                       tb = inet_bind_bucket_create(hinfo->bind_bucket_cachep, head, port);
+                       if (!tb) {
+                               spin_unlock(&head->lock);
+                               break;
+                       }
+                       tb->fastreuse = -1;
+                       goto ok;
+
+               next_port:
+                       spin_unlock(&head->lock);
+               }
+               local_bh_enable();
+
+               return -EADDRNOTAVAIL;
 
 ok:
                hint += i;
 
-               /* Head lock still held and bh's disabled */
-               inet_bind_hash(sk, tb, port);
+               /* Head lock still held and bh's disabled */
+               inet_bind_hash(sk, tb, port);
                if (sk_unhashed(sk)) {
-                       inet_sk(sk)->sport = htons(port);
-                       __inet_hash(hinfo, sk, 0);
-               }
-               spin_unlock(&head->lock);
+                       inet_sk(sk)->sport = htons(port);
+                       __inet_hash(hinfo, sk, 0);
+               }
+               spin_unlock(&head->lock);
 
-               if (tw) {
-                       inet_twsk_deschedule(tw, death_row);
-                       inet_twsk_put(tw);
-               }
+               if (tw) {
+                       inet_twsk_deschedule(tw, death_row);
+                       inet_twsk_put(tw);
+               }
 
                ret = 0;
                goto out;
-       }
+       }
 
-       head = &hinfo->bhash[inet_bhashfn(snum, hinfo->bhash_size)];
-       tb  = inet_csk(sk)->icsk_bind_hash;
+       head = &hinfo->bhash[inet_bhashfn(snum, hinfo->bhash_size)];
+       tb  = inet_csk(sk)->icsk_bind_hash;
        spin_lock_bh(&head->lock);
        if (sk_head(&tb->owners) == sk && !sk->sk_bind_node.next) {
                __inet_hash(hinfo, sk, 0);
index 9f414e35c488fe2c1464b1aae47363b17968fb5f..a73cf93cee36d146eb4cfd2171a76a949d8d374a 100644 (file)
@@ -78,8 +78,8 @@ void __inet_twsk_hashdance(struct inet_timewait_sock *tw, struct sock *sk,
        if (__sk_del_node_init(sk))
                sock_prot_dec_use(sk->sk_prot);
 
-       /* Step 3: Hash TW into TIMEWAIT half of established hash table. */
-       inet_twsk_add_node(tw, &(ehead + hashinfo->ehash_size)->chain);
+       /* Step 3: Hash TW into TIMEWAIT chain. */
+       inet_twsk_add_node(tw, &ehead->twchain);
        atomic_inc(&tw->tw_refcnt);
 
        write_unlock(&ehead->lock);
index a22d11d2911cd4f7772b2d6428a5d525c5cc2f59..c3ea0cd2e584eb507b8ffb893ac9a59b23d4aebf 100644 (file)
@@ -4,15 +4,15 @@
  *             interface as the means of communication with the user level.
  *
  *             The IP forwarding functionality.
- *             
+ *
  * Version:    $Id: ip_forward.c,v 1.48 2000/12/13 18:31:48 davem Exp $
  *
  * Authors:    see ip.c
  *
  * Fixes:
- *             Many            :       Split from ip.c , see ip_input.c for 
+ *             Many            :       Split from ip.c , see ip_input.c for
  *                                     history.
- *             Dave Gregorich  :       NULL ip_rt_put fix for multicast 
+ *             Dave Gregorich  :       NULL ip_rt_put fix for multicast
  *                                     routing.
  *             Jos Vos         :       Add call_out_firewall before sending,
  *                                     use output device for accounting.
@@ -69,14 +69,14 @@ int ip_forward(struct sk_buff *skb)
                goto drop;
 
        skb->ip_summed = CHECKSUM_NONE;
-       
+
        /*
         *      According to the RFC, we must first decrease the TTL field. If
         *      that reaches zero, we must reply an ICMP control message telling
         *      that the packet's lifetime expired.
         */
        if (skb->nh.iph->ttl <= 1)
-                goto too_many_hops;
+               goto too_many_hops;
 
        if (!xfrm4_route_forward(skb))
                goto drop;
@@ -107,16 +107,16 @@ int ip_forward(struct sk_buff *skb)
                       ip_forward_finish);
 
 sr_failed:
-        /*
+       /*
         *      Strict routing permits no gatewaying
         */
-         icmp_send(skb, ICMP_DEST_UNREACH, ICMP_SR_FAILED, 0);
-         goto drop;
+        icmp_send(skb, ICMP_DEST_UNREACH, ICMP_SR_FAILED, 0);
+        goto drop;
 
 too_many_hops:
-        /* Tell the sender its packet died... */
-        IP_INC_STATS_BH(IPSTATS_MIB_INHDRERRORS);
-        icmp_send(skb, ICMP_TIME_EXCEEDED, ICMP_EXC_TTL, 0);
+       /* Tell the sender its packet died... */
+       IP_INC_STATS_BH(IPSTATS_MIB_INHDRERRORS);
+       icmp_send(skb, ICMP_TIME_EXCEEDED, ICMP_EXC_TTL, 0);
 drop:
        kfree_skb(skb);
        return NET_RX_DROP;
index 8ce00d3703dacdeb46a387f27a8d5a609f100e7a..b6f05538037379719f06f5d5c176ce2394766fe2 100644 (file)
@@ -4,7 +4,7 @@
  *             interface as the means of communication with the user level.
  *
  *             The IP fragmentation functionality.
- *             
+ *
  * Version:    $Id: ip_fragment.c,v 1.59 2002/01/12 07:54:56 davem Exp $
  *
  * Authors:    Fred N. van Kempen <waltje@uWalt.NL.Mugnet.ORG>
@@ -238,7 +238,7 @@ static void ipq_kill(struct ipq *ipq)
        }
 }
 
-/* Memory limiting on fragments.  Evictor trashes the oldest 
+/* Memory limiting on fragments.  Evictor trashes the oldest
  * fragment queue until we are back under the threshold.
  */
 static void ip_evictor(void)
@@ -479,14 +479,14 @@ static void ip_frag_queue(struct ipq *qp, struct sk_buff *skb)
                goto err;
        }
 
-       offset = ntohs(skb->nh.iph->frag_off);
+       offset = ntohs(skb->nh.iph->frag_off);
        flags = offset & ~IP_OFFSET;
        offset &= IP_OFFSET;
        offset <<= 3;           /* offset is in 8-byte chunks */
-       ihl = skb->nh.iph->ihl * 4;
+       ihl = skb->nh.iph->ihl * 4;
 
        /* Determine the position of this fragment. */
-       end = offset + skb->len - ihl;
+       end = offset + skb->len - ihl;
 
        /* Is this the final fragment? */
        if ((flags & IP_MF) == 0) {
@@ -589,8 +589,8 @@ static void ip_frag_queue(struct ipq *qp, struct sk_buff *skb)
        else
                qp->fragments = skb;
 
-       if (skb->dev)
-               qp->iif = skb->dev->ifindex;
+       if (skb->dev)
+               qp->iif = skb->dev->ifindex;
        skb->dev = NULL;
        skb_get_timestamp(skb, &qp->stamp);
        qp->meat += skb->len;
@@ -684,7 +684,7 @@ static struct sk_buff *ip_frag_reasm(struct ipq *qp, struct net_device *dev)
        return head;
 
 out_nomem:
-       LIMIT_NETDEBUG(KERN_ERR "IP: queue_glue: no memory for gluing "
+       LIMIT_NETDEBUG(KERN_ERR "IP: queue_glue: no memory for gluing "
                              "queue %p\n", qp);
        goto out_fail;
 out_oversize:
@@ -703,7 +703,7 @@ struct sk_buff *ip_defrag(struct sk_buff *skb, u32 user)
        struct iphdr *iph = skb->nh.iph;
        struct ipq *qp;
        struct net_device *dev;
-       
+
        IP_INC_STATS_BH(IPSTATS_MIB_REASMREQDS);
 
        /* Start by cleaning up the memory. */
index 476cb6084c75047026980d44d7ba43b4da39a0cd..f12c0d6623a0a6c35bb36298bcba95bb7168091d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *     Linux NET3:     GRE over IP protocol decoder. 
+ *     Linux NET3:     GRE over IP protocol decoder.
  *
  *     Authors: Alexey Kuznetsov (kuznet@ms2.inr.ac.ru)
  *
@@ -63,7 +63,7 @@
    solution, but it supposes maintaing new variable in ALL
    skb, even if no tunneling is used.
 
-   Current solution: t->recursion lock breaks dead loops. It looks 
+   Current solution: t->recursion lock breaks dead loops. It looks
    like dev->tbusy flag, but I preferred new variable, because
    the semantics is different. One day, when hard_start_xmit
    will be multithreaded we will have to use skb->encapsulation.
@@ -613,7 +613,7 @@ static int ipgre_rcv(struct sk_buff *skb)
                if (flags == 0 &&
                    skb->protocol == htons(ETH_P_WCCP)) {
                        skb->protocol = htons(ETH_P_IP);
-                       if ((*(h + offset) & 0xF0) != 0x40) 
+                       if ((*(h + offset) & 0xF0) != 0x40)
                                offset += 4;
                }
 
@@ -816,7 +816,7 @@ static int ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
                struct sk_buff *new_skb = skb_realloc_headroom(skb, max_headroom);
                if (!new_skb) {
                        ip_rt_put(rt);
-                       stats->tx_dropped++;
+                       stats->tx_dropped++;
                        dev_kfree_skb(skb);
                        tunnel->recursion--;
                        return 0;
@@ -1008,7 +1008,8 @@ ipgre_tunnel_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd)
                                goto done;
                        dev = t->dev;
                }
-               err = unregister_netdevice(dev);
+               unregister_netdevice(dev);
+               err = 0;
                break;
 
        default:
@@ -1043,7 +1044,7 @@ static int ipgre_tunnel_change_mtu(struct net_device *dev, int new_mtu)
    so that I had to set ARPHRD_IPGRE to a random value.
    I have an impression, that Cisco could make something similar,
    but this feature is apparently missing in IOS<=11.2(8).
-   
+
    I set up 10.66.66/24 and fec0:6666:6666::0/96 as virtual networks
    with broadcast 224.66.66.66. If you have access to mbone, play with me :-)
 
@@ -1075,9 +1076,9 @@ static int ipgre_header(struct sk_buff *skb, struct net_device *dev, unsigned sh
        p[1]            = htons(type);
 
        /*
-        *      Set the source hardware address. 
+        *      Set the source hardware address.
         */
-        
+
        if (saddr)
                memcpy(&iph->saddr, saddr, 4);
 
@@ -1087,7 +1088,7 @@ static int ipgre_header(struct sk_buff *skb, struct net_device *dev, unsigned sh
        }
        if (iph->daddr && !MULTICAST(iph->daddr))
                return t->hlen;
-       
+
        return -t->hlen;
 }
 
index 212734ca238fa88e2bcee0eb43e13c246a5f9720..f38e97647ac043878d21f636657d0f919ca5cee3 100644 (file)
@@ -15,7 +15,7 @@
  *             Stefan Becker, <stefanb@yello.ping.de>
  *             Jorge Cwik, <jorge@laser.satlink.net>
  *             Arnt Gulbrandsen, <agulbra@nvg.unit.no>
- *             
+ *
  *
  * Fixes:
  *             Alan Cox        :       Commented a couple of minor bits of surplus code
  *             Jos Vos         :       Do accounting *before* call_in_firewall
  *     Willy Konynenberg       :       Transparent proxying support
  *
- *  
+ *
  *
  * To Fix:
  *             IP fragmentation wants rewriting cleanly. The RFC815 algorithm is much more efficient
  *             and could be made very efficient with the addition of some virtual memory hacks to permit
  *             the allocation of a buffer that can then be 'grown' by twiddling page tables.
- *             Output fragmentation wants updating along with the buffer management to use a single 
+ *             Output fragmentation wants updating along with the buffer management to use a single
  *             interleaved copy algorithm so that fragmenting has a one copy overhead. Actual packet
  *             output should probably do its own fragmentation at the UDP/RAW layer. TCP shouldn't cause
  *             fragmentation anyway.
@@ -154,7 +154,7 @@ DEFINE_SNMP_STAT(struct ipstats_mib, ip_statistics) __read_mostly;
 
 /*
  *     Process Router Attention IP option
- */ 
+ */
 int ip_call_ra_chain(struct sk_buff *skb)
 {
        struct ip_ra_chain *ra;
@@ -202,8 +202,8 @@ static inline int ip_local_deliver_finish(struct sk_buff *skb)
 
        __skb_pull(skb, ihl);
 
-        /* Point into the IP datagram, just past the header. */
-        skb->h.raw = skb->data;
+       /* Point into the IP datagram, just past the header. */
+       skb->h.raw = skb->data;
 
        rcu_read_lock();
        {
@@ -259,7 +259,7 @@ static inline int ip_local_deliver_finish(struct sk_buff *skb)
 
 /*
  *     Deliver IP Packets to the higher protocol layers.
- */ 
+ */
 int ip_local_deliver(struct sk_buff *skb)
 {
        /*
@@ -335,14 +335,14 @@ static inline int ip_rcv_finish(struct sk_buff *skb)
        /*
         *      Initialise the virtual path cache for the packet. It describes
         *      how the packet travels inside Linux networking.
-        */ 
+        */
        if (skb->dst == NULL) {
                int err = ip_route_input(skb, iph->daddr, iph->saddr, iph->tos,
                                         skb->dev);
                if (unlikely(err)) {
                        if (err == -EHOSTUNREACH)
                                IP_INC_STATS_BH(IPSTATS_MIB_INADDRERRORS);
-                       goto drop; 
+                       goto drop;
                }
        }
 
@@ -363,13 +363,13 @@ static inline int ip_rcv_finish(struct sk_buff *skb)
        return dst_input(skb);
 
 drop:
-        kfree_skb(skb);
-        return NET_RX_DROP;
+       kfree_skb(skb);
+       return NET_RX_DROP;
 }
 
 /*
  *     Main IP Receive routine.
- */ 
+ */
 int ip_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev)
 {
        struct iphdr *iph;
@@ -437,9 +437,9 @@ int ip_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt,
 inhdr_error:
        IP_INC_STATS_BH(IPSTATS_MIB_INHDRERRORS);
 drop:
-        kfree_skb(skb);
+       kfree_skb(skb);
 out:
-        return NET_RX_DROP;
+       return NET_RX_DROP;
 }
 
 EXPORT_SYMBOL(ip_statistics);
index 9f02917d6f45319de4680eade1dda3cf3440b050..f906a80d5a87952e408c1507df4b9eb26ad35352 100644 (file)
@@ -8,7 +8,7 @@
  * Version:    $Id: ip_options.c,v 1.21 2001/09/01 00:31:50 davem Exp $
  *
  * Authors:    A.N.Kuznetsov
- *             
+ *
  */
 
 #include <linux/capability.h>
@@ -26,7 +26,7 @@
 #include <net/route.h>
 #include <net/cipso_ipv4.h>
 
-/* 
+/*
  * Write options to IP header, record destination address to
  * source route option, address of outgoing interface
  * (we should already know it, so that this  function is allowed be
@@ -76,7 +76,7 @@ void ip_options_build(struct sk_buff * skb, struct ip_options * opt,
        }
 }
 
-/* 
+/*
  * Provided (sopt, skb) points to received options,
  * build in dopt compiled option set appropriate for answering.
  * i.e. invert SRR option, copy anothers,
@@ -85,7 +85,7 @@ void ip_options_build(struct sk_buff * skb, struct ip_options * opt,
  * NOTE: dopt cannot point to skb.
  */
 
-int ip_options_echo(struct ip_options * dopt, struct sk_buff * skb) 
+int ip_options_echo(struct ip_options * dopt, struct sk_buff * skb)
 {
        struct ip_options *sopt;
        unsigned char *sptr, *dptr;
@@ -215,7 +215,7 @@ int ip_options_echo(struct ip_options * dopt, struct sk_buff * skb)
  *     Simple and stupid 8), but the most efficient way.
  */
 
-void ip_options_fragment(struct sk_buff * skb) 
+void ip_options_fragment(struct sk_buff * skb)
 {
        unsigned char * optptr = skb->nh.raw + sizeof(struct iphdr);
        struct ip_options * opt = &(IPCB(skb)->opt);
@@ -370,7 +370,7 @@ int ip_options_compile(struct ip_options * opt, struct sk_buff * skb)
                                switch (optptr[3]&0xF) {
                                      case IPOPT_TS_TSONLY:
                                        opt->ts = optptr - iph;
-                                       if (skb) 
+                                       if (skb)
                                                timeptr = (__be32*)&optptr[optptr[2]-1];
                                        opt->ts_needtime = 1;
                                        optptr[2] += 4;
@@ -448,7 +448,7 @@ int ip_options_compile(struct ip_options * opt, struct sk_buff * skb)
                                goto error;
                        }
                        opt->cipso = optptr - iph;
-                       if (cipso_v4_validate(&optptr)) {
+                       if (cipso_v4_validate(&optptr)) {
                                pp_ptr = optptr;
                                goto error;
                        }
index a0f2008584bc6b24eb771b169cf33ca797f1c5b8..bb0bb8f07c54aa5172d5a62bcd38d3a73123aa56 100644 (file)
@@ -22,7 +22,7 @@
  *     Fixes:
  *             Alan Cox        :       Missing nonblock feature in ip_build_xmit.
  *             Mike Kilburn    :       htons() missing in ip_build_xmit.
- *             Bradford Johnson:       Fix faulty handling of some frames when 
+ *             Bradford Johnson:       Fix faulty handling of some frames when
  *                                     no route is found.
  *             Alexander Demenshin:    Missing sk/skb free in ip_queue_xmit
  *                                     (in case if packet not accepted by
@@ -33,9 +33,9 @@
  *                                     some redundant tests.
  *     Vitaly E. Lavrov        :       Transparent proxy revived after year coma.
  *             Andi Kleen      :       Replace ip_reply with ip_send_reply.
- *             Andi Kleen      :       Split fast and slow ip_build_xmit path 
- *                                     for decreased register pressure on x86 
- *                                     and more readibility. 
+ *             Andi Kleen      :       Split fast and slow ip_build_xmit path
+ *                                     for decreased register pressure on x86
+ *                                     and more readibility.
  *             Marc Boucher    :       When call_out_firewall returns FW_QUEUE,
  *                                     silently drop skb instead of failing with -EPERM.
  *             Detlev Wengorz  :       Copy protocol for fragments.
@@ -114,7 +114,7 @@ static inline int ip_select_ttl(struct inet_sock *inet, struct dst_entry *dst)
        return ttl;
 }
 
-/* 
+/*
  *             Add an ip header to a skbuff and send it out.
  *
  */
@@ -243,7 +243,7 @@ int ip_mc_output(struct sk_buff *skb)
                        struct sk_buff *newskb = skb_clone(skb, GFP_ATOMIC);
                        if (newskb)
                                NF_HOOK(PF_INET, NF_IP_POST_ROUTING, newskb, NULL,
-                                       newskb->dev, 
+                                       newskb->dev,
                                        ip_dev_loopback_xmit);
                }
 
@@ -277,7 +277,7 @@ int ip_output(struct sk_buff *skb)
        skb->protocol = htons(ETH_P_IP);
 
        return NF_HOOK_COND(PF_INET, NF_IP_POST_ROUTING, skb, NULL, dev,
-                           ip_finish_output,
+                           ip_finish_output,
                            !(IPCB(skb)->flags & IPSKB_REROUTED));
 }
 
@@ -660,7 +660,7 @@ slow_path:
        return err;
 
 fail:
-       kfree_skb(skb); 
+       kfree_skb(skb);
        IP_INC_STATS(IPSTATS_MIB_FRAGFAILS);
        return err;
 }
@@ -755,7 +755,7 @@ static inline int ip_ufo_append_data(struct sock *sk,
  *     from many pieces of data. Each pieces will be holded on the socket
  *     until ip_push_pending_frames() is called. Each piece can be a page
  *     or non-page data.
- *     
+ *
  *     Not only UDP, other transport protocols - e.g. raw sockets - can use
  *     this interface potentially.
  *
@@ -888,7 +888,7 @@ alloc_new_skb:
                                datalen = maxfraglen - fragheaderlen;
                        fraglen = datalen + fragheaderlen;
 
-                       if ((flags & MSG_MORE) && 
+                       if ((flags & MSG_MORE) &&
                            !(rt->u.dst.dev->features&NETIF_F_SG))
                                alloclen = mtu;
                        else
@@ -903,14 +903,14 @@ alloc_new_skb:
                                alloclen += rt->u.dst.trailer_len;
 
                        if (transhdrlen) {
-                               skb = sock_alloc_send_skb(sk, 
+                               skb = sock_alloc_send_skb(sk,
                                                alloclen + hh_len + 15,
                                                (flags & MSG_DONTWAIT), &err);
                        } else {
                                skb = NULL;
                                if (atomic_read(&sk->sk_wmem_alloc) <=
                                    2 * sk->sk_sndbuf)
-                                       skb = sock_wmalloc(sk, 
+                                       skb = sock_wmalloc(sk,
                                                           alloclen + hh_len + 15, 1,
                                                           sk->sk_allocation);
                                if (unlikely(skb == NULL))
@@ -971,7 +971,7 @@ alloc_new_skb:
                        unsigned int off;
 
                        off = skb->len;
-                       if (getfrag(from, skb_put(skb, copy), 
+                       if (getfrag(from, skb_put(skb, copy),
                                        offset, copy, off, skb) < 0) {
                                __skb_trim(skb, off);
                                err = -EFAULT;
@@ -993,7 +993,7 @@ alloc_new_skb:
                                                goto error;
                                        }
                                        get_page(page);
-                                       skb_fill_page_desc(skb, i, page, sk->sk_sndmsg_off, 0);
+                                       skb_fill_page_desc(skb, i, page, sk->sk_sndmsg_off, 0);
                                        frag = &skb_shinfo(skb)->frags[i];
                                }
                        } else if (i < MAX_SKB_FRAGS) {
@@ -1033,7 +1033,7 @@ alloc_new_skb:
 error:
        inet->cork.length -= length;
        IP_INC_STATS(IPSTATS_MIB_OUTDISCARDS);
-       return err; 
+       return err;
 }
 
 ssize_t        ip_append_page(struct sock *sk, struct page *page,
@@ -1257,7 +1257,7 @@ int ip_push_pending_frames(struct sock *sk)
        skb->dst = dst_clone(&rt->u.dst);
 
        /* Netfilter gets whole the not fragmented skb. */
-       err = NF_HOOK(PF_INET, NF_IP_LOCAL_OUT, skb, NULL, 
+       err = NF_HOOK(PF_INET, NF_IP_LOCAL_OUT, skb, NULL,
                      skb->dst->dev, dst_output);
        if (err) {
                if (err > 0)
@@ -1305,21 +1305,21 @@ void ip_flush_pending_frames(struct sock *sk)
 /*
  *     Fetch data from kernel space and fill in checksum if needed.
  */
-static int ip_reply_glue_bits(void *dptr, char *to, int offset, 
+static int ip_reply_glue_bits(void *dptr, char *to, int offset,
                              int len, int odd, struct sk_buff *skb)
 {
        __wsum csum;
 
        csum = csum_partial_copy_nocheck(dptr+offset, to, len, 0);
        skb->csum = csum_block_add(skb->csum, csum, odd);
-       return 0;  
+       return 0;
 }
 
-/* 
+/*
  *     Generic function to send a packet as reply to another packet.
  *     Used to send TCP resets so far. ICMP should use this function too.
  *
- *     Should run single threaded per socket because it uses the sock 
+ *     Should run single threaded per socket because it uses the sock
  *             structure to pass arguments.
  *
  *     LATER: switch from ip_build_xmit to ip_append_*
@@ -1357,7 +1357,7 @@ void ip_send_reply(struct sock *sk, struct sk_buff *skb, struct ip_reply_arg *ar
                                    /* Not quite clean, but right. */
                                    .uli_u = { .ports =
                                               { .sport = skb->h.th->dest,
-                                                .dport = skb->h.th->source } },
+                                                .dport = skb->h.th->source } },
                                    .proto = sk->sk_protocol };
                security_skb_classify_flow(skb, &fl);
                if (ip_route_output_key(&rt, &fl))
index 57d4bae6f080a470b277a28b505b6e11d015ebc4..e120686c3cb8901fb648029d5af260fd1b0c3750 100644 (file)
@@ -4,7 +4,7 @@
  *             interface as the means of communication with the user level.
  *
  *             The IP to API glue.
- *             
+ *
  * Version:    $Id: ip_sockglue.c,v 1.62 2002/02/01 22:01:04 davem Exp $
  *
  * Authors:    see ip.c
@@ -12,7 +12,7 @@
  * Fixes:
  *             Many            :       Split from ip.c , see ip.c for history.
  *             Martin Mares    :       TOS setting fixed.
- *             Alan Cox        :       Fixed a couple of oopses in Martin's 
+ *             Alan Cox        :       Fixed a couple of oopses in Martin's
  *                                     TOS tweaks.
  *             Mike McLagan    :       Routing by source
  */
@@ -253,7 +253,7 @@ int ip_ra_control(struct sock *sk, unsigned char on, void (*destructor)(struct s
        return 0;
 }
 
-void ip_icmp_error(struct sock *sk, struct sk_buff *skb, int err, 
+void ip_icmp_error(struct sock *sk, struct sk_buff *skb, int err,
                   __be16 port, u32 info, u8 *payload)
 {
        struct inet_sock *inet = inet_sk(sk);
@@ -266,10 +266,10 @@ void ip_icmp_error(struct sock *sk, struct sk_buff *skb, int err,
        if (!skb)
                return;
 
-       serr = SKB_EXT_ERR(skb);  
+       serr = SKB_EXT_ERR(skb);
        serr->ee.ee_errno = err;
        serr->ee.ee_origin = SO_EE_ORIGIN_ICMP;
-       serr->ee.ee_type = skb->h.icmph->type; 
+       serr->ee.ee_type = skb->h.icmph->type;
        serr->ee.ee_code = skb->h.icmph->code;
        serr->ee.ee_pad = 0;
        serr->ee.ee_info = info;
@@ -301,10 +301,10 @@ void ip_local_error(struct sock *sk, int err, __be32 daddr, __be16 port, u32 inf
        skb->nh.iph = iph;
        iph->daddr = daddr;
 
-       serr = SKB_EXT_ERR(skb);  
+       serr = SKB_EXT_ERR(skb);
        serr->ee.ee_errno = err;
        serr->ee.ee_origin = SO_EE_ORIGIN_LOCAL;
-       serr->ee.ee_type = 0; 
+       serr->ee.ee_type = 0;
        serr->ee.ee_code = 0;
        serr->ee.ee_pad = 0;
        serr->ee.ee_info = info;
@@ -319,7 +319,7 @@ void ip_local_error(struct sock *sk, int err, __be32 daddr, __be16 port, u32 inf
                kfree_skb(skb);
 }
 
-/* 
+/*
  *     Handle MSG_ERRQUEUE
  */
 int ip_recv_error(struct sock *sk, struct msghdr *msg, int len)
@@ -391,7 +391,7 @@ int ip_recv_error(struct sock *sk, struct msghdr *msg, int len)
        } else
                spin_unlock_bh(&sk->sk_error_queue.lock);
 
-out_free_skb:  
+out_free_skb:
        kfree_skb(skb);
 out:
        return err;
@@ -409,15 +409,15 @@ static int do_ip_setsockopt(struct sock *sk, int level,
        struct inet_sock *inet = inet_sk(sk);
        int val=0,err;
 
-       if (((1<<optname) & ((1<<IP_PKTINFO) | (1<<IP_RECVTTL) | 
-                           (1<<IP_RECVOPTS) | (1<<IP_RECVTOS) | 
-                           (1<<IP_RETOPTS) | (1<<IP_TOS) | 
-                           (1<<IP_TTL) | (1<<IP_HDRINCL) | 
-                           (1<<IP_MTU_DISCOVER) | (1<<IP_RECVERR) | 
+       if (((1<<optname) & ((1<<IP_PKTINFO) | (1<<IP_RECVTTL) |
+                           (1<<IP_RECVOPTS) | (1<<IP_RECVTOS) |
+                           (1<<IP_RETOPTS) | (1<<IP_TOS) |
+                           (1<<IP_TTL) | (1<<IP_HDRINCL) |
+                           (1<<IP_MTU_DISCOVER) | (1<<IP_RECVERR) |
                            (1<<IP_ROUTER_ALERT) | (1<<IP_FREEBIND) |
                            (1<<IP_PASSSEC))) ||
-                               optname == IP_MULTICAST_TTL || 
-                               optname == IP_MULTICAST_LOOP) { 
+                               optname == IP_MULTICAST_TTL ||
+                               optname == IP_MULTICAST_LOOP) {
                if (optlen >= sizeof(int)) {
                        if (get_user(val, (int __user *) optval))
                                return -EFAULT;
@@ -511,7 +511,7 @@ static int do_ip_setsockopt(struct sock *sk, int level,
                                val &= ~3;
                                val |= inet->tos & 3;
                        }
-                       if (IPTOS_PREC(val) >= IPTOS_PREC_CRITIC_ECP && 
+                       if (IPTOS_PREC(val) >= IPTOS_PREC_CRITIC_ECP &&
                            !capable(CAP_NET_ADMIN)) {
                                err = -EPERM;
                                break;
@@ -519,7 +519,7 @@ static int do_ip_setsockopt(struct sock *sk, int level,
                        if (inet->tos != val) {
                                inet->tos = val;
                                sk->sk_priority = rt_tos2priority(val);
-                               sk_dst_reset(sk); 
+                               sk_dst_reset(sk);
                        }
                        break;
                case IP_TTL:
@@ -556,13 +556,13 @@ static int do_ip_setsockopt(struct sock *sk, int level,
                        if (val < 0 || val > 255)
                                goto e_inval;
                        inet->mc_ttl = val;
-                       break;
-               case IP_MULTICAST_LOOP: 
+                       break;
+               case IP_MULTICAST_LOOP:
                        if (optlen<1)
                                goto e_inval;
                        inet->mc_loop = !!val;
-                       break;
-               case IP_MULTICAST_IF: 
+                       break;
+               case IP_MULTICAST_IF:
                {
                        struct ip_mreqn mreq;
                        struct net_device *dev = NULL;
@@ -616,7 +616,7 @@ static int do_ip_setsockopt(struct sock *sk, int level,
                }
 
                case IP_ADD_MEMBERSHIP:
-               case IP_DROP_MEMBERSHIP: 
+               case IP_DROP_MEMBERSHIP:
                {
                        struct ip_mreqn mreq;
 
@@ -629,7 +629,7 @@ static int do_ip_setsockopt(struct sock *sk, int level,
                        } else {
                                memset(&mreq, 0, sizeof(mreq));
                                if (copy_from_user(&mreq,optval,sizeof(struct ip_mreq)))
-                                       break; 
+                                       break;
                        }
 
                        if (optname == IP_ADD_MEMBERSHIP)
@@ -714,7 +714,7 @@ static int do_ip_setsockopt(struct sock *sk, int level,
                        break;
                }
                case MCAST_JOIN_GROUP:
-               case MCAST_LEAVE_GROUP: 
+               case MCAST_LEAVE_GROUP:
                {
                        struct group_req greq;
                        struct sockaddr_in *psin;
@@ -858,16 +858,16 @@ mc_msf_out:
                        kfree(gsf);
                        break;
                }
-               case IP_ROUTER_ALERT:   
+               case IP_ROUTER_ALERT:
                        err = ip_ra_control(sk, val ? 1 : 0, NULL);
                        break;
 
                case IP_FREEBIND:
                        if (optlen<1)
                                goto e_inval;
-                       inet->freebind = !!val; 
-                       break;                  
+                       inet->freebind = !!val;
+                       break;
+
                case IP_IPSEC_POLICY:
                case IP_XFRM_POLICY:
                        err = -EPERM;
@@ -954,7 +954,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
        struct inet_sock *inet = inet_sk(sk);
        int val;
        int len;
-       
+
        if(level!=SOL_IP)
                return -EOPNOTSUPP;
 
@@ -969,7 +969,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
                return -EFAULT;
        if(len < 0)
                return -EINVAL;
-               
+
        lock_sock(sk);
 
        switch(optname) {
@@ -984,7 +984,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
                                               inet->opt->optlen);
                                release_sock(sk);
 
-                               if (opt->optlen == 0) 
+                               if (opt->optlen == 0)
                                        return put_user(0, optlen);
 
                                ip_options_undo(opt);
@@ -1059,8 +1059,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
                        addr.s_addr = inet->mc_addr;
                        release_sock(sk);
 
-                       if(put_user(len, optlen))
-                               return -EFAULT;
+                       if(put_user(len, optlen))
+                               return -EFAULT;
                        if(copy_to_user(optval, &addr, len))
                                return -EFAULT;
                        return 0;
@@ -1101,7 +1101,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
                        release_sock(sk);
                        return err;
                }
-               case IP_PKTOPTIONS:             
+               case IP_PKTOPTIONS:
                {
                        struct msghdr msg;
 
@@ -1129,15 +1129,15 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
                        len -= msg.msg_controllen;
                        return put_user(len, optlen);
                }
-               case IP_FREEBIND: 
-                       val = inet->freebind; 
-                       break; 
+               case IP_FREEBIND:
+                       val = inet->freebind;
+                       break;
                default:
                        release_sock(sk);
                        return -ENOPROTOOPT;
        }
        release_sock(sk);
-       
+
        if (len < sizeof(int) && len > 0 && val>=0 && val<255) {
                unsigned char ucval = (unsigned char)val;
                len = 1;
@@ -1168,7 +1168,7 @@ int ip_getsockopt(struct sock *sk, int level,
                && (optname < MRT_BASE || optname > MRT_BASE+10)
 #endif
           ) {
-               int len;
+               int len;
 
                if(get_user(len,optlen))
                        return -EFAULT;
@@ -1197,7 +1197,7 @@ int compat_ip_getsockopt(struct sock *sk, int level, int optname,
            && (optname < MRT_BASE || optname > MRT_BASE+10)
 #endif
           ) {
-               int len;
+               int len;
 
                if (get_user(len, optlen))
                        return -EFAULT;
index 3839b706142e3816f73bbc9a6ff361a9f8467d44..aa704b88f014fa7118a8ccfc92fc067b65108c48 100644 (file)
@@ -5,7 +5,7 @@
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option) 
+ * Software Foundation; either version 2 of the License, or (at your option)
  * any later version.
  *
  * Todo:
@@ -48,7 +48,7 @@ static int ipcomp_decompress(struct xfrm_state *x, struct sk_buff *skb)
        u8 *start, *scratch;
        struct crypto_comp *tfm;
        int cpu;
-       
+
        plen = skb->len;
        dlen = IPCOMP_SCRATCH_SIZE;
        start = skb->data;
@@ -69,11 +69,11 @@ static int ipcomp_decompress(struct xfrm_state *x, struct sk_buff *skb)
        err = pskb_expand_head(skb, 0, dlen - plen, GFP_ATOMIC);
        if (err)
                goto out;
-               
+
        skb->truesize += dlen - plen;
        __skb_put(skb, dlen - plen);
        memcpy(skb->data, scratch, dlen);
-out:   
+out:
        put_cpu();
        return err;
 }
@@ -85,11 +85,11 @@ static int ipcomp_input(struct xfrm_state *x, struct sk_buff *skb)
        struct ip_comp_hdr *ipch;
 
        if (skb_linearize_cow(skb))
-               goto out;
+               goto out;
 
        skb->ip_summed = CHECKSUM_NONE;
 
-       /* Remove ipcomp header and decompress original payload */      
+       /* Remove ipcomp header and decompress original payload */
        iph = skb->nh.iph;
        ipch = (void *)skb->data;
        iph->protocol = ipch->nexthdr;
@@ -97,7 +97,7 @@ static int ipcomp_input(struct xfrm_state *x, struct sk_buff *skb)
        __skb_pull(skb, sizeof(*ipch));
        err = ipcomp_decompress(x, skb);
 
-out:   
+out:
        return err;
 }
 
@@ -109,7 +109,7 @@ static int ipcomp_compress(struct xfrm_state *x, struct sk_buff *skb)
        u8 *start, *scratch;
        struct crypto_comp *tfm;
        int cpu;
-       
+
        ihlen = iph->ihl * 4;
        plen = skb->len - ihlen;
        dlen = IPCOMP_SCRATCH_SIZE;
@@ -127,14 +127,14 @@ static int ipcomp_compress(struct xfrm_state *x, struct sk_buff *skb)
                err = -EMSGSIZE;
                goto out;
        }
-       
+
        memcpy(start + sizeof(struct ip_comp_hdr), scratch, dlen);
        put_cpu();
 
        pskb_trim(skb, ihlen + dlen + sizeof(struct ip_comp_hdr));
        return 0;
-       
-out:   
+
+out:
        put_cpu();
        return err;
 }
@@ -157,7 +157,7 @@ static int ipcomp_output(struct xfrm_state *x, struct sk_buff *skb)
 
        if (skb_linearize_cow(skb))
                goto out_ok;
-       
+
        err = ipcomp_compress(x, skb);
        iph = skb->nh.iph;
 
@@ -194,7 +194,7 @@ static void ipcomp4_err(struct sk_buff *skb, u32 info)
 
        spi = htonl(ntohs(ipch->cpi));
        x = xfrm_state_lookup((xfrm_address_t *)&iph->daddr,
-                             spi, IPPROTO_COMP, AF_INET);
+                             spi, IPPROTO_COMP, AF_INET);
        if (!x)
                return;
        NETDEBUG(KERN_DEBUG "pmtu discovery on SA IPCOMP/%08x/%u.%u.%u.%u\n",
@@ -202,12 +202,12 @@ static void ipcomp4_err(struct sk_buff *skb, u32 info)
        xfrm_state_put(x);
 }
 
-/* We always hold one tunnel user reference to indicate a tunnel */ 
+/* We always hold one tunnel user reference to indicate a tunnel */
 static struct xfrm_state *ipcomp_tunnel_create(struct xfrm_state *x)
 {
        struct xfrm_state *t;
        u8 mode = XFRM_MODE_TUNNEL;
-       
+
        t = xfrm_state_alloc();
        if (t == NULL)
                goto out;
@@ -247,7 +247,7 @@ static int ipcomp_tunnel_attach(struct xfrm_state *x)
        struct xfrm_state *t;
 
        t = xfrm_state_lookup((xfrm_address_t *)&x->id.daddr.a4,
-                             x->props.saddr.a4, IPPROTO_IPIP, AF_INET);
+                             x->props.saddr.a4, IPPROTO_IPIP, AF_INET);
        if (!t) {
                t = ipcomp_tunnel_create(x);
                if (!t) {
index afa60b9a003f0e5185073993ffbd9cc22f960c0f..ba882bec317a85d9caeaab934e4664c02851d6ad 100644 (file)
@@ -12,7 +12,7 @@
  *  BOOTP rewritten to construct and analyse packets itself instead
  *  of misusing the IP layer. num_bugs_causing_wrong_arp_replies--;
  *                                          -- MJ, December 1998
- *  
+ *
  *  Fixed ip_auto_config_setup calling at startup in the new "Linker Magic"
  *  initialization scheme.
  *     - Arnaldo Carvalho de Melo <acme@conectiva.com.br>, 08/11/1999
@@ -98,8 +98,8 @@
 #define CONF_TIMEOUT_RANDOM    (HZ)    /* Maximum amount of randomization */
 #define CONF_TIMEOUT_MULT      *7/4    /* Rate of timeout growth */
 #define CONF_TIMEOUT_MAX       (HZ*30) /* Maximum allowed timeout */
-#define CONF_NAMESERVERS_MAX   3       /* Maximum number of nameservers  
-                                           - '3' from resolv.h */
+#define CONF_NAMESERVERS_MAX   3       /* Maximum number of nameservers
+                                          - '3' from resolv.h */
 
 #define NONE __constant_htonl(INADDR_NONE)
 
@@ -365,7 +365,7 @@ static int __init ic_defaults(void)
         *      At this point we have no userspace running so need not
         *      claim locks on system_utsname
         */
-        
+
        if (!ic_host_name_set)
                sprintf(init_utsname()->nodename, "%u.%u.%u.%u", NIPQUAD(ic_myaddr));
 
@@ -650,9 +650,9 @@ static void __init ic_bootp_init_ext(u8 *e)
        *e++ = 40;
        e += 40;
 
-       *e++ = 57;              /* set extension buffer size for reply */ 
+       *e++ = 57;              /* set extension buffer size for reply */
        *e++ = 2;
-       *e++ = 1;               /* 128+236+8+20+14, see dhcpd sources */ 
+       *e++ = 1;               /* 128+236+8+20+14, see dhcpd sources */
        *e++ = 150;
 
        *e++ = 255;             /* End of the list */
@@ -913,7 +913,7 @@ static int __init ic_bootp_recv(struct sk_buff *skb, struct net_device *dev, str
        /* Parse extensions */
        if (ext_len >= 4 &&
            !memcmp(b->exten, ic_bootp_cookie, 4)) { /* Check magic cookie */
-                u8 *end = (u8 *) b + ntohs(b->iph.tot_len);
+               u8 *end = (u8 *) b + ntohs(b->iph.tot_len);
                u8 *ext;
 
 #ifdef IPCONFIG_DHCP
@@ -1020,7 +1020,7 @@ drop:
        kfree_skb(skb);
 
        return 0;
-}      
+}
 
 
 #endif
@@ -1080,7 +1080,7 @@ static int __init ic_dynamic(void)
         * seems to be a terrible waste of CPU time, but actually there is
         * only one process running at all, so we don't need to use any
         * scheduler functions.
-        * [Actually we could now, but the nothing else running note still 
+        * [Actually we could now, but the nothing else running note still
         *  applies.. - AC]
         */
        printk(KERN_NOTICE "Sending %s%s%s requests .",
@@ -1156,7 +1156,7 @@ static int __init ic_dynamic(void)
        }
 
        printk("IP-Config: Got %s answer from %u.%u.%u.%u, ",
-               ((ic_got_reply & IC_RARP) ? "RARP" 
+               ((ic_got_reply & IC_RARP) ? "RARP"
                 : (ic_proto_enabled & IC_USE_DHCP) ? "DHCP" : "BOOTP"),
                NIPQUAD(ic_servaddr));
        printk("my address is %u.%u.%u.%u\n", NIPQUAD(ic_myaddr));
@@ -1286,7 +1286,7 @@ static int __init ip_auto_config(void)
 #endif
            ic_first_dev->next) {
 #ifdef IPCONFIG_DYNAMIC
-       
+
                int retries = CONF_OPEN_RETRIES;
 
                if (ic_dynamic() < 0) {
@@ -1308,14 +1308,14 @@ static int __init ip_auto_config(void)
                         */
 #ifdef CONFIG_ROOT_NFS
                        if (ROOT_DEV ==  Root_NFS) {
-                               printk(KERN_ERR 
+                               printk(KERN_ERR
                                        "IP-Config: Retrying forever (NFS root)...\n");
                                goto try_try_again;
                        }
 #endif
 
                        if (--retries) {
-                               printk(KERN_ERR 
+                               printk(KERN_ERR
                                       "IP-Config: Reopening network devices...\n");
                                goto try_try_again;
                        }
@@ -1443,8 +1443,8 @@ static int __init ip_auto_config_setup(char *addrs)
 
        ic_set_manually = 1;
 
-       ic_enable = (*addrs && 
-               (strcmp(addrs, "off") != 0) && 
+       ic_enable = (*addrs &&
+               (strcmp(addrs, "off") != 0) &&
                (strcmp(addrs, "none") != 0));
        if (!ic_enable)
                return 1;
index 9d719d664e5b986db7c6308926decbd79dd2ee90..475bcd1e4181b34939de55853cfeaadb863e1901 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *     Linux NET3:     IP/IP protocol decoder. 
+ *     Linux NET3:     IP/IP protocol decoder.
  *
  *     Version: $Id: ipip.c,v 1.50 2001/10/02 02:22:36 davem Exp $
  *
        Thanks for the great code!
 
                -Sam Lantinga   (slouken@cs.ucdavis.edu)  02/01/95
-               
+
        Minor tweaks:
                Cleaned up the code a little and added some pre-1.3.0 tweaks.
                dev->hard_header/hard_header_len changed to use no headers.
                Comments/bracketing tweaked.
                Made the tunnels use dev->name not tunnel: when error reporting.
                Added tx_dropped stat
-               
+
                -Alan Cox       (Alan.Cox@linux.org) 21 March 95
 
        Reworked:
@@ -52,7 +52,7 @@
                Note:  There is currently no firewall or ICMP handling done.
 
                -Sam Lantinga   (slouken@cs.ucdavis.edu) 02/13/96
-               
+
 */
 
 /* Things I wish I had known when writing the tunnel driver:
@@ -75,7 +75,7 @@
        "allocated" with skb_put().  You can then write up to skb->len
        bytes to that buffer.  If you need more, you can call skb_put()
        again with the additional amount of space you need.  You can
-       find out how much more space you can allocate by calling 
+       find out how much more space you can allocate by calling
        "skb_tailroom(skb)".
        Now, to add header space, call "skb_push(skb, header_len)".
        This creates space at the beginning of the buffer and returns
@@ -92,7 +92,7 @@
    For comments look at net/ipv4/ip_gre.c --ANK
  */
 
+
 #include <linux/capability.h>
 #include <linux/module.h>
 #include <linux/types.h>
@@ -607,7 +607,7 @@ static int ipip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
                struct sk_buff *new_skb = skb_realloc_headroom(skb, max_headroom);
                if (!new_skb) {
                        ip_rt_put(rt);
-                       stats->tx_dropped++;
+                       stats->tx_dropped++;
                        dev_kfree_skb(skb);
                        tunnel->recursion--;
                        return 0;
@@ -754,7 +754,8 @@ ipip_tunnel_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd)
                                goto done;
                        dev = t->dev;
                }
-               err = unregister_netdevice(dev);
+               unregister_netdevice(dev);
+               err = 0;
                break;
 
        default:
index ecb5422ea237d0ad811a46fa924ecd01d66720d9..604f5b585104e02e9238dd2a1230a7e21be17017 100644 (file)
@@ -241,7 +241,7 @@ failure:
 /*
  *     Delete a VIF entry
  */
+
 static int vif_delete(int vifi)
 {
        struct vif_device *v;
@@ -409,7 +409,7 @@ static int vif_add(struct vifctl *vifc, int mrtsock)
                        return -ENOBUFS;
                break;
 #endif
-       case VIFF_TUNNEL:       
+       case VIFF_TUNNEL:
                dev = ipmr_new_tunnel(vifc);
                if (!dev)
                        return -ENOBUFS;
@@ -479,20 +479,18 @@ static struct mfc_cache *ipmr_cache_find(__be32 origin, __be32 mcastgrp)
  */
 static struct mfc_cache *ipmr_cache_alloc(void)
 {
-       struct mfc_cache *c=kmem_cache_alloc(mrt_cachep, GFP_KERNEL);
+       struct mfc_cache *c=kmem_cache_zalloc(mrt_cachep, GFP_KERNEL);
        if(c==NULL)
                return NULL;
-       memset(c, 0, sizeof(*c));
        c->mfc_un.res.minvif = MAXVIFS;
        return c;
 }
 
 static struct mfc_cache *ipmr_cache_alloc_unres(void)
 {
-       struct mfc_cache *c=kmem_cache_alloc(mrt_cachep, GFP_ATOMIC);
+       struct mfc_cache *c=kmem_cache_zalloc(mrt_cachep, GFP_ATOMIC);
        if(c==NULL)
                return NULL;
-       memset(c, 0, sizeof(*c));
        skb_queue_head_init(&c->mfc_un.unres.unresolved);
        c->mfc_un.unres.expires = jiffies + 10*HZ;
        return c;
@@ -501,7 +499,7 @@ static struct mfc_cache *ipmr_cache_alloc_unres(void)
 /*
  *     A cache entry has gone into a resolved state from queued
  */
+
 static void ipmr_cache_resolve(struct mfc_cache *uc, struct mfc_cache *c)
 {
        struct sk_buff *skb;
@@ -538,7 +536,7 @@ static void ipmr_cache_resolve(struct mfc_cache *uc, struct mfc_cache *c)
  *
  *     Called under mrt_lock.
  */
+
 static int ipmr_cache_report(struct sk_buff *pkt, vifi_t vifi, int assert)
 {
        struct sk_buff *skb;
@@ -569,13 +567,13 @@ static int ipmr_cache_report(struct sk_buff *pkt, vifi_t vifi, int assert)
                memcpy(msg, pkt->nh.raw, sizeof(struct iphdr));
                msg->im_msgtype = IGMPMSG_WHOLEPKT;
                msg->im_mbz = 0;
-               msg->im_vif = reg_vif_num;
+               msg->im_vif = reg_vif_num;
                skb->nh.iph->ihl = sizeof(struct iphdr) >> 2;
                skb->nh.iph->tot_len = htons(ntohs(pkt->nh.iph->tot_len) + sizeof(struct iphdr));
-       } else 
+       } else
 #endif
-       {       
-               
+       {
+
        /*
         *      Copy the IP header
         */
@@ -597,7 +595,7 @@ static int ipmr_cache_report(struct sk_buff *pkt, vifi_t vifi, int assert)
        igmp->code      =       0;
        skb->nh.iph->tot_len=htons(skb->len);                   /* Fix the length */
        skb->h.raw = skb->nh.raw;
-        }
+       }
 
        if (mroute_socket == NULL) {
                kfree_skb(skb);
@@ -619,7 +617,7 @@ static int ipmr_cache_report(struct sk_buff *pkt, vifi_t vifi, int assert)
 /*
  *     Queue a packet for resolution. It gets locked cache entry!
  */
+
 static int
 ipmr_cache_unresolved(vifi_t vifi, struct sk_buff *skb)
 {
@@ -657,7 +655,7 @@ ipmr_cache_unresolved(vifi_t vifi, struct sk_buff *skb)
                 *      Reflect first query at mrouted.
                 */
                if ((err = ipmr_cache_report(skb, vifi, IGMPMSG_NOCACHE))<0) {
-                       /* If the report failed throw the cache entry 
+                       /* If the report failed throw the cache entry
                           out - Brad Parker
                         */
                        spin_unlock_bh(&mfc_unres_lock);
@@ -783,11 +781,11 @@ static int ipmr_mfc_add(struct mfcctl *mfc, int mrtsock)
 /*
  *     Close the multicast socket, and clear the vif tables etc
  */
+
 static void mroute_clean_tables(struct sock *sk)
 {
        int i;
-               
+
        /*
         *      Shut down all active vif entries
         */
@@ -854,13 +852,13 @@ static void mrtsock_destruct(struct sock *sk)
  *     that's how BSD mrouted happens to think. Maybe one day with a proper
  *     MOSPF/PIM router set up we can clean this up.
  */
+
 int ip_mroute_setsockopt(struct sock *sk,int optname,char __user *optval,int optlen)
 {
        int ret;
        struct vifctl vif;
        struct mfcctl mfc;
-       
+
        if(optname!=MRT_INIT)
        {
                if(sk!=mroute_socket && !capable(CAP_NET_ADMIN))
@@ -901,7 +899,7 @@ int ip_mroute_setsockopt(struct sock *sk,int optname,char __user *optval,int opt
                        if(optlen!=sizeof(vif))
                                return -EINVAL;
                        if (copy_from_user(&vif,optval,sizeof(vif)))
-                               return -EFAULT; 
+                               return -EFAULT;
                        if(vif.vifc_vifi >= MAXVIFS)
                                return -ENFILE;
                        rtnl_lock();
@@ -980,13 +978,13 @@ int ip_mroute_setsockopt(struct sock *sk,int optname,char __user *optval,int opt
 /*
  *     Getsock opt support for the multicast routing system.
  */
+
 int ip_mroute_getsockopt(struct sock *sk,int optname,char __user *optval,int __user *optlen)
 {
        int olr;
        int val;
 
-       if(optname!=MRT_VERSION && 
+       if(optname!=MRT_VERSION &&
 #ifdef CONFIG_IP_PIMSM
           optname!=MRT_PIM &&
 #endif
@@ -999,7 +997,7 @@ int ip_mroute_getsockopt(struct sock *sk,int optname,char __user *optval,int __u
        olr = min_t(unsigned int, olr, sizeof(int));
        if (olr < 0)
                return -EINVAL;
-               
+
        if(put_user(olr,optlen))
                return -EFAULT;
        if(optname==MRT_VERSION)
@@ -1018,19 +1016,19 @@ int ip_mroute_getsockopt(struct sock *sk,int optname,char __user *optval,int __u
 /*
  *     The IP multicast ioctl support routines.
  */
+
 int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg)
 {
        struct sioc_sg_req sr;
        struct sioc_vif_req vr;
        struct vif_device *vif;
        struct mfc_cache *c;
-       
+
        switch(cmd)
        {
                case SIOCGETVIFCNT:
                        if (copy_from_user(&vr,arg,sizeof(vr)))
-                               return -EFAULT; 
+                               return -EFAULT;
                        if(vr.vifi>=maxvif)
                                return -EINVAL;
                        read_lock(&mrt_lock);
@@ -1096,7 +1094,7 @@ static struct notifier_block ip_mr_notifier={
  *     This avoids tunnel drivers and other mess and gives us the speed so
  *     important for multicast video.
  */
+
 static void ip_encap(struct sk_buff *skb, __be32 saddr, __be32 daddr)
 {
        struct iphdr *iph = (struct iphdr *)skb_push(skb,sizeof(struct iphdr));
@@ -1194,7 +1192,7 @@ static void ipmr_queue_xmit(struct sk_buff *skb, struct mfc_cache *c, int vifi)
        encap += LL_RESERVED_SPACE(dev) + rt->u.dst.header_len;
 
        if (skb_cow(skb, encap)) {
-               ip_rt_put(rt);
+               ip_rt_put(rt);
                goto out_free;
        }
 
@@ -1228,7 +1226,7 @@ static void ipmr_queue_xmit(struct sk_buff *skb, struct mfc_cache *c, int vifi)
         * not mrouter) cannot join to more than one interface - it will
         * result in receiving multiple packets.
         */
-       NF_HOOK(PF_INET, NF_IP_FORWARD, skb, skb->dev, dev, 
+       NF_HOOK(PF_INET, NF_IP_FORWARD, skb, skb->dev, dev,
                ipmr_forward_finish);
        return;
 
@@ -1289,7 +1287,7 @@ static int ip_mr_forward(struct sk_buff *skb, struct mfc_cache *cache, int local
                       large chunk of pimd to kernel. Ough... --ANK
                     */
                    (mroute_do_pim || cache->mfc_un.res.ttls[true_vifi] < 255) &&
-                   time_after(jiffies, 
+                   time_after(jiffies,
                               cache->mfc_un.res.last_assert + MFC_ASSERT_THRESH)) {
                        cache->mfc_un.res.last_assert = jiffies;
                        ipmr_cache_report(skb, true_vifi, IGMPMSG_WRONGVIF);
@@ -1426,14 +1424,14 @@ int pim_rcv_v1(struct sk_buff * skb)
        struct iphdr   *encap;
        struct net_device  *reg_dev = NULL;
 
-       if (!pskb_may_pull(skb, sizeof(*pim) + sizeof(*encap))) 
+       if (!pskb_may_pull(skb, sizeof(*pim) + sizeof(*encap)))
                goto drop;
 
        pim = (struct igmphdr*)skb->h.raw;
 
-        if (!mroute_do_pim ||
+       if (!mroute_do_pim ||
            skb->len < sizeof(*pim) + sizeof(*encap) ||
-           pim->group != PIM_V1_VERSION || pim->code != PIM_V1_REGISTER) 
+           pim->group != PIM_V1_VERSION || pim->code != PIM_V1_REGISTER)
                goto drop;
 
        encap = (struct iphdr*)(skb->h.raw + sizeof(struct igmphdr));
@@ -1445,7 +1443,7 @@ int pim_rcv_v1(struct sk_buff * skb)
         */
        if (!MULTICAST(encap->daddr) ||
            encap->tot_len == 0 ||
-           ntohs(encap->tot_len) + sizeof(*pim) > skb->len) 
+           ntohs(encap->tot_len) + sizeof(*pim) > skb->len)
                goto drop;
 
        read_lock(&mrt_lock);
@@ -1455,7 +1453,7 @@ int pim_rcv_v1(struct sk_buff * skb)
                dev_hold(reg_dev);
        read_unlock(&mrt_lock);
 
-       if (reg_dev == NULL) 
+       if (reg_dev == NULL)
                goto drop;
 
        skb->mac.raw = skb->nh.raw;
@@ -1486,13 +1484,13 @@ static int pim_rcv(struct sk_buff * skb)
        struct iphdr   *encap;
        struct net_device  *reg_dev = NULL;
 
-       if (!pskb_may_pull(skb, sizeof(*pim) + sizeof(*encap))) 
+       if (!pskb_may_pull(skb, sizeof(*pim) + sizeof(*encap)))
                goto drop;
 
        pim = (struct pimreghdr*)skb->h.raw;
-        if (pim->type != ((PIM_VERSION<<4)|(PIM_REGISTER)) ||
+       if (pim->type != ((PIM_VERSION<<4)|(PIM_REGISTER)) ||
            (pim->flags&PIM_NULL_REGISTER) ||
-           (ip_compute_csum((void *)pim, sizeof(*pim)) != 0 && 
+           (ip_compute_csum((void *)pim, sizeof(*pim)) != 0 &&
             csum_fold(skb_checksum(skb, 0, skb->len, 0))))
                goto drop;
 
@@ -1500,7 +1498,7 @@ static int pim_rcv(struct sk_buff * skb)
        encap = (struct iphdr*)(skb->h.raw + sizeof(struct pimreghdr));
        if (!MULTICAST(encap->daddr) ||
            encap->tot_len == 0 ||
-           ntohs(encap->tot_len) + sizeof(*pim) > skb->len) 
+           ntohs(encap->tot_len) + sizeof(*pim) > skb->len)
                goto drop;
 
        read_lock(&mrt_lock);
@@ -1510,7 +1508,7 @@ static int pim_rcv(struct sk_buff * skb)
                dev_hold(reg_dev);
        read_unlock(&mrt_lock);
 
-       if (reg_dev == NULL) 
+       if (reg_dev == NULL)
                goto drop;
 
        skb->mac.raw = skb->nh.raw;
@@ -1616,7 +1614,7 @@ int ipmr_get_route(struct sk_buff *skb, struct rtmsg *rtm, int nowait)
        return err;
 }
 
-#ifdef CONFIG_PROC_FS  
+#ifdef CONFIG_PROC_FS
 /*
  *     The /proc interfaces to multicast routing /proc/ip_mr_cache /proc/ip_mr_vif
  */
@@ -1630,7 +1628,7 @@ static struct vif_device *ipmr_vif_seq_idx(struct ipmr_vif_iter *iter,
        for (iter->ct = 0; iter->ct < maxvif; ++iter->ct) {
                if(!VIF_EXISTS(iter->ct))
                        continue;
-               if (pos-- == 0) 
+               if (pos-- == 0)
                        return &vif_table[iter->ct];
        }
        return NULL;
@@ -1639,7 +1637,7 @@ static struct vif_device *ipmr_vif_seq_idx(struct ipmr_vif_iter *iter,
 static void *ipmr_vif_seq_start(struct seq_file *seq, loff_t *pos)
 {
        read_lock(&mrt_lock);
-       return *pos ? ipmr_vif_seq_idx(seq->private, *pos - 1) 
+       return *pos ? ipmr_vif_seq_idx(seq->private, *pos - 1)
                : SEQ_START_TOKEN;
 }
 
@@ -1650,7 +1648,7 @@ static void *ipmr_vif_seq_next(struct seq_file *seq, void *v, loff_t *pos)
        ++*pos;
        if (v == SEQ_START_TOKEN)
                return ipmr_vif_seq_idx(iter, 0);
-       
+
        while (++iter->ct < maxvif) {
                if(!VIF_EXISTS(iter->ct))
                        continue;
@@ -1667,7 +1665,7 @@ static void ipmr_vif_seq_stop(struct seq_file *seq, void *v)
 static int ipmr_vif_seq_show(struct seq_file *seq, void *v)
 {
        if (v == SEQ_START_TOKEN) {
-               seq_puts(seq, 
+               seq_puts(seq,
                         "Interface      BytesIn  PktsIn  BytesOut PktsOut Flags Local    Remote\n");
        } else {
                const struct vif_device *vif = v;
@@ -1676,7 +1674,7 @@ static int ipmr_vif_seq_show(struct seq_file *seq, void *v)
                seq_printf(seq,
                           "%2Zd %-10s %8ld %7ld  %8ld %7ld %05X %08X %08X\n",
                           vif - vif_table,
-                          name, vif->bytes_in, vif->pkt_in, 
+                          name, vif->bytes_in, vif->pkt_in,
                           vif->bytes_out, vif->pkt_out,
                           vif->flags, vif->local, vif->remote);
        }
@@ -1695,7 +1693,7 @@ static int ipmr_vif_open(struct inode *inode, struct file *file)
        struct seq_file *seq;
        int rc = -ENOMEM;
        struct ipmr_vif_iter *s = kmalloc(sizeof(*s), GFP_KERNEL);
-       
+
        if (!s)
                goto out;
 
@@ -1734,15 +1732,15 @@ static struct mfc_cache *ipmr_mfc_seq_idx(struct ipmr_mfc_iter *it, loff_t pos)
 
        it->cache = mfc_cache_array;
        read_lock(&mrt_lock);
-       for (it->ct = 0; it->ct < MFC_LINES; it->ct++) 
-               for(mfc = mfc_cache_array[it->ct]; mfc; mfc = mfc->next) 
-                       if (pos-- == 0) 
+       for (it->ct = 0; it->ct < MFC_LINES; it->ct++)
+               for(mfc = mfc_cache_array[it->ct]; mfc; mfc = mfc->next)
+                       if (pos-- == 0)
                                return mfc;
        read_unlock(&mrt_lock);
 
        it->cache = &mfc_unres_queue;
        spin_lock_bh(&mfc_unres_lock);
-       for(mfc = mfc_unres_queue; mfc; mfc = mfc->next) 
+       for(mfc = mfc_unres_queue; mfc; mfc = mfc->next)
                if (pos-- == 0)
                        return mfc;
        spin_unlock_bh(&mfc_unres_lock);
@@ -1757,7 +1755,7 @@ static void *ipmr_mfc_seq_start(struct seq_file *seq, loff_t *pos)
        struct ipmr_mfc_iter *it = seq->private;
        it->cache = NULL;
        it->ct = 0;
-       return *pos ? ipmr_mfc_seq_idx(seq->private, *pos - 1) 
+       return *pos ? ipmr_mfc_seq_idx(seq->private, *pos - 1)
                : SEQ_START_TOKEN;
 }
 
@@ -1773,8 +1771,8 @@ static void *ipmr_mfc_seq_next(struct seq_file *seq, void *v, loff_t *pos)
 
        if (mfc->next)
                return mfc->next;
-       
-       if (it->cache == &mfc_unres_queue) 
+
+       if (it->cache == &mfc_unres_queue)
                goto end_of_list;
 
        BUG_ON(it->cache != mfc_cache_array);
@@ -1789,10 +1787,10 @@ static void *ipmr_mfc_seq_next(struct seq_file *seq, void *v, loff_t *pos)
        read_unlock(&mrt_lock);
        it->cache = &mfc_unres_queue;
        it->ct = 0;
-               
+
        spin_lock_bh(&mfc_unres_lock);
        mfc = mfc_unres_queue;
-       if (mfc) 
+       if (mfc)
                return mfc;
 
  end_of_list:
@@ -1817,12 +1815,12 @@ static int ipmr_mfc_seq_show(struct seq_file *seq, void *v)
        int n;
 
        if (v == SEQ_START_TOKEN) {
-               seq_puts(seq, 
+               seq_puts(seq,
                 "Group    Origin   Iif     Pkts    Bytes    Wrong Oifs\n");
        } else {
                const struct mfc_cache *mfc = v;
                const struct ipmr_mfc_iter *it = seq->private;
-               
+
                seq_printf(seq, "%08lX %08lX %-3d %8ld %8ld %8ld",
                           (unsigned long) mfc->mfc_mcastgrp,
                           (unsigned long) mfc->mfc_origin,
@@ -1832,12 +1830,12 @@ static int ipmr_mfc_seq_show(struct seq_file *seq, void *v)
                           mfc->mfc_un.res.wrong_if);
 
                if (it->cache != &mfc_unres_queue) {
-                       for(n = mfc->mfc_un.res.minvif; 
+                       for(n = mfc->mfc_un.res.minvif;
                            n < mfc->mfc_un.res.maxvif; n++ ) {
-                               if(VIF_EXISTS(n) 
+                               if(VIF_EXISTS(n)
                                   && mfc->mfc_un.res.ttls[n] < 255)
-                               seq_printf(seq, 
-                                          " %2d:%-3d", 
+                               seq_printf(seq,
+                                          " %2d:%-3d",
                                           n, mfc->mfc_un.res.ttls[n]);
                        }
                }
@@ -1858,7 +1856,7 @@ static int ipmr_mfc_open(struct inode *inode, struct file *file)
        struct seq_file *seq;
        int rc = -ENOMEM;
        struct ipmr_mfc_iter *s = kmalloc(sizeof(*s), GFP_KERNEL);
-       
+
        if (!s)
                goto out;
 
@@ -1883,7 +1881,7 @@ static struct file_operations ipmr_mfc_fops = {
        .llseek  = seq_lseek,
        .release = seq_release_private,
 };
-#endif 
+#endif
 
 #ifdef CONFIG_IP_PIMSM_V2
 static struct net_protocol pim_protocol = {
@@ -1895,7 +1893,7 @@ static struct net_protocol pim_protocol = {
 /*
  *     Setup for IP multicast routing
  */
+
 void __init ip_mr_init(void)
 {
        mrt_cachep = kmem_cache_create("ip_mrt_cache",
@@ -1905,8 +1903,8 @@ void __init ip_mr_init(void)
        init_timer(&ipmr_expire_timer);
        ipmr_expire_timer.function=ipmr_expire_process;
        register_netdevice_notifier(&ip_mr_notifier);
-#ifdef CONFIG_PROC_FS  
+#ifdef CONFIG_PROC_FS
        proc_net_fops_create("ip_mr_vif", 0, &ipmr_vif_fops);
        proc_net_fops_create("ip_mr_cache", 0, &ipmr_mfc_fops);
-#endif 
+#endif
 }
index 8086787a2c51e5c0df7f4043ac8778af0a819edf..0b5e03476ce4de91b2317de8666c0ebe02a05d36 100644 (file)
@@ -494,8 +494,8 @@ int ip_vs_check_template(struct ip_vs_conn *ct)
         * Checking the dest server status.
         */
        if ((dest == NULL) ||
-           !(dest->flags & IP_VS_DEST_F_AVAILABLE) || 
-           (sysctl_ip_vs_expire_quiescent_template && 
+           !(dest->flags & IP_VS_DEST_F_AVAILABLE) ||
+           (sysctl_ip_vs_expire_quiescent_template &&
             (atomic_read(&dest->weight) == 0))) {
                IP_VS_DBG(9, "check_template: dest not available for "
                          "protocol %s s:%u.%u.%u.%u:%d v:%u.%u.%u.%u:%d "
@@ -603,13 +603,12 @@ ip_vs_conn_new(int proto, __be32 caddr, __be16 cport, __be32 vaddr, __be16 vport
        struct ip_vs_conn *cp;
        struct ip_vs_protocol *pp = ip_vs_proto_get(proto);
 
-       cp = kmem_cache_alloc(ip_vs_conn_cachep, GFP_ATOMIC);
+       cp = kmem_cache_zalloc(ip_vs_conn_cachep, GFP_ATOMIC);
        if (cp == NULL) {
                IP_VS_ERR_RL("ip_vs_conn_new: no memory available.\n");
                return NULL;
        }
 
-       memset(cp, 0, sizeof(*cp));
        INIT_LIST_HEAD(&cp->c_list);
        init_timer(&cp->timer);
        cp->timer.data     = (unsigned long)cp;
@@ -667,7 +666,7 @@ static void *ip_vs_conn_array(struct seq_file *seq, loff_t pos)
 {
        int idx;
        struct ip_vs_conn *cp;
-       
+
        for(idx = 0; idx < IP_VS_CONN_TAB_SIZE; idx++) {
                ct_read_lock_bh(idx);
                list_for_each_entry(cp, &ip_vs_conn_tab[idx], c_list) {
@@ -695,7 +694,7 @@ static void *ip_vs_conn_seq_next(struct seq_file *seq, void *v, loff_t *pos)
        int idx;
 
        ++*pos;
-       if (v == SEQ_START_TOKEN) 
+       if (v == SEQ_START_TOKEN)
                return ip_vs_conn_array(seq, 0);
 
        /* more on same hash chain? */
@@ -710,7 +709,7 @@ static void *ip_vs_conn_seq_next(struct seq_file *seq, void *v, loff_t *pos)
                list_for_each_entry(cp, &ip_vs_conn_tab[idx], c_list) {
                        seq->private = &ip_vs_conn_tab[idx];
                        return cp;
-               }       
+               }
                ct_read_unlock_bh(idx);
        }
        seq->private = NULL;
index 34257520a3a6b8132eb87af036382aea06f753f2..24d7b66eb6d2dc2c49169af7db1a604d58420168 100644 (file)
@@ -813,14 +813,14 @@ ip_vs_out(unsigned int hooknum, struct sk_buff **pskb,
        skb->nh.iph->saddr = cp->vaddr;
        ip_send_check(skb->nh.iph);
 
-       /* For policy routing, packets originating from this
-        * machine itself may be routed differently to packets
-        * passing through.  We want this packet to be routed as
-        * if it came from this machine itself.  So re-compute
-        * the routing information.
-        */
-       if (ip_route_me_harder(pskb, RTN_LOCAL) != 0)
-               goto drop;
+       /* For policy routing, packets originating from this
+        * machine itself may be routed differently to packets
+        * passing through.  We want this packet to be routed as
+        * if it came from this machine itself.  So re-compute
+        * the routing information.
+        */
+       if (ip_route_me_harder(pskb, RTN_LOCAL) != 0)
+               goto drop;
        skb = *pskb;
 
        IP_VS_DBG_PKT(10, pp, skb, 0, "After SNAT");
@@ -847,7 +847,7 @@ ip_vs_out(unsigned int hooknum, struct sk_buff **pskb,
  *     forward to the right destination host if relevant.
  *     Currently handles error types - unreachable, quench, ttl exceeded.
  */
-static int 
+static int
 ip_vs_in_icmp(struct sk_buff **pskb, int *related, unsigned int hooknum)
 {
        struct sk_buff *skb = *pskb;
@@ -863,7 +863,7 @@ ip_vs_in_icmp(struct sk_buff **pskb, int *related, unsigned int hooknum)
        /* reassemble IP fragments */
        if (skb->nh.iph->frag_off & __constant_htons(IP_MF|IP_OFFSET)) {
                skb = ip_vs_gather_frags(skb,
-                                        hooknum == NF_IP_LOCAL_IN ?
+                                        hooknum == NF_IP_LOCAL_IN ?
                                         IP_DEFRAG_VS_IN : IP_DEFRAG_VS_FWD);
                if (!skb)
                        return NF_STOLEN;
index 687c1de1146fa7a6b510a88e563c8ab6037c48b4..847c47af040c475eef93f51156721c2da38110a0 100644 (file)
@@ -370,7 +370,7 @@ static int __init ip_vs_ftp_init(void)
                if (ret)
                        break;
                IP_VS_INFO("%s: loaded support on port[%d] = %d\n",
-                          app->name, i, ports[i]);
+                          app->name, i, ports[i]);
        }
 
        if (ret)
index a4385a2180ee6d3f890411927d3056fafbc48c34..76fd1fb91878b8a2bdd7fb4fe994963440f9eb23 100644 (file)
@@ -118,7 +118,7 @@ static ctl_table vs_vars_table[] = {
                .procname       = "lblc_expiration",
                .data           = &sysctl_ip_vs_lblc_expiration,
                .maxlen         = sizeof(int),
-               .mode           = 0644, 
+               .mode           = 0644,
                .proc_handler   = &proc_dointvec_jiffies,
        },
        { .ctl_name = 0 }
@@ -128,7 +128,7 @@ static ctl_table vs_table[] = {
        {
                .ctl_name       = NET_IPV4_VS,
                .procname       = "vs",
-               .mode           = 0555, 
+               .mode           = 0555,
                .child          = vs_vars_table
        },
        { .ctl_name = 0 }
@@ -137,7 +137,7 @@ static ctl_table vs_table[] = {
 static ctl_table ipvs_ipv4_table[] = {
        {
                .ctl_name       = NET_IPV4,
-               .procname       = "ipv4", 
+               .procname       = "ipv4",
                .mode           = 0555,
                .child          = vs_table
        },
@@ -147,8 +147,8 @@ static ctl_table ipvs_ipv4_table[] = {
 static ctl_table lblc_root_table[] = {
        {
                .ctl_name       = CTL_NET,
-               .procname       = "net", 
-               .mode           = 0555, 
+               .procname       = "net",
+               .mode           = 0555,
                .child          = ipvs_ipv4_table
        },
        { .ctl_name = 0 }
@@ -288,7 +288,7 @@ static inline void ip_vs_lblc_full_check(struct ip_vs_lblc_table *tbl)
 
                write_lock(&tbl->lock);
                list_for_each_entry_safe(en, nxt, &tbl->bucket[j], list) {
-                       if (time_before(now, 
+                       if (time_before(now,
                                        en->lastuse + sysctl_ip_vs_lblc_expiration))
                                continue;
 
index fe1af5d079afdee89edb20a6cfe78847acfa17cd..bf1e7f272b8416c5f84bd8afde6876f1882be044 100644 (file)
@@ -307,7 +307,7 @@ static ctl_table vs_vars_table[] = {
                .procname       = "lblcr_expiration",
                .data           = &sysctl_ip_vs_lblcr_expiration,
                .maxlen         = sizeof(int),
-               .mode           = 0644, 
+               .mode           = 0644,
                .proc_handler   = &proc_dointvec_jiffies,
        },
        { .ctl_name = 0 }
@@ -326,7 +326,7 @@ static ctl_table vs_table[] = {
 static ctl_table ipvs_ipv4_table[] = {
        {
                .ctl_name       = NET_IPV4,
-               .procname       = "ipv4", 
+               .procname       = "ipv4",
                .mode           = 0555,
                .child          = vs_table
        },
@@ -336,8 +336,8 @@ static ctl_table ipvs_ipv4_table[] = {
 static ctl_table lblcr_root_table[] = {
        {
                .ctl_name       = CTL_NET,
-               .procname       = "net", 
-               .mode           = 0555, 
+               .procname       = "net",
+               .mode           = 0555,
                .child          = ipvs_ipv4_table
        },
        { .ctl_name = 0 }
index b23bab231cabfe0de3ff8647907c19d51b152522..433f8a947924fa1b17091e0f9b8f292570dafcbf 100644 (file)
@@ -68,7 +68,7 @@ ip_vs_rr_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
                        q = q->next;
                        continue;
                }
-               
+
                dest = list_entry(q, struct ip_vs_dest, n_list);
                if (!(dest->flags & IP_VS_DEST_F_OVERLOAD) &&
                    atomic_read(&dest->weight) > 0)
index 252e837b17a52d54079db9c1eb5a1f62d5889a4c..cb8fce46734900428319c55be5292d6d1d8836ff 100644 (file)
@@ -134,7 +134,7 @@ static void drr_select_route(const struct flowi *flp,
                             struct rtable *first, struct rtable **rp)
 {
        struct rtable *nh, *result, *cur_min;
-       int min_usecount = -1; 
+       int min_usecount = -1;
        int devidx = -1;
        int cur_min_devidx = -1;
 
@@ -143,7 +143,7 @@ static void drr_select_route(const struct flowi *flp,
        result = NULL;
        cur_min = NULL;
        for (nh = rcu_dereference(first); nh;
-            nh = rcu_dereference(nh->u.rt_next)) {
+            nh = rcu_dereference(nh->u.dst.rt_next)) {
                if ((nh->u.dst.flags & DST_BALANCED) != 0 &&
                    multipath_comparekeys(&nh->fl, flp)) {
                        int nh_ifidx = nh->u.dst.dev->ifindex;
@@ -161,7 +161,7 @@ static void drr_select_route(const struct flowi *flp,
                         */
                        devidx = __multipath_finddev(nh_ifidx);
                        if (devidx == -1) {
-                               /* add the interface to the array 
+                               /* add the interface to the array
                                 * SMP safe
                                 */
                                spin_lock_bh(&state_lock);
index b8c289f247cbb2622bbabe2fdfc0a2e028931962..047e861f06bd42f902865bf52bf2455101dbc244 100644 (file)
@@ -74,7 +74,7 @@ static void random_select_route(const struct flowi *flp,
 
        /* count all candidate */
        for (rt = rcu_dereference(first); rt;
-            rt = rcu_dereference(rt->u.rt_next)) {
+            rt = rcu_dereference(rt->u.dst.rt_next)) {
                if ((rt->u.dst.flags & DST_BALANCED) != 0 &&
                    multipath_comparekeys(&rt->fl, flp))
                        ++candidate_count;
@@ -90,7 +90,7 @@ static void random_select_route(const struct flowi *flp,
                /* find chosen candidate and adjust GC data for all candidates
                 * to ensure they stay in cache
                 */
-               for (rt = first; rt; rt = rt->u.rt_next) {
+               for (rt = first; rt; rt = rt->u.dst.rt_next) {
                        if ((rt->u.dst.flags & DST_BALANCED) != 0 &&
                            multipath_comparekeys(&rt->fl, flp)) {
                                rt->u.dst.lastuse = jiffies;
index bba5abe5542d3a49dff281c9a222b335f0e2ee00..896246d8040e2d49a9bac1a6994bfc0a802f5dc8 100644 (file)
@@ -58,7 +58,7 @@ static void rr_select_route(const struct flowi *flp,
         */
        result = NULL;
        for (nh = rcu_dereference(first); nh;
-            nh = rcu_dereference(nh->u.rt_next)) {
+            nh = rcu_dereference(nh->u.dst.rt_next)) {
                if ((nh->u.dst.flags & DST_BALANCED) != 0 &&
                    multipath_comparekeys(&nh->fl, flp)) {
                        nh->u.dst.lastuse = jiffies;
index 92b04823e034292328be4cf92c2891ce8e05b9fd..7e22f15d13dfecb562b58adadc409282835faba3 100644 (file)
@@ -142,7 +142,7 @@ out:
        return weight;
 }
 
-static void wrandom_init_state(void) 
+static void wrandom_init_state(void)
 {
        int i;
 
@@ -167,7 +167,7 @@ static void wrandom_select_route(const struct flowi *flp,
 
        /* collect all candidates and identify their weights */
        for (rt = rcu_dereference(first); rt;
-            rt = rcu_dereference(rt->u.rt_next)) {
+            rt = rcu_dereference(rt->u.dst.rt_next)) {
                if ((rt->u.dst.flags & DST_BALANCED) != 0 &&
                    multipath_comparekeys(&rt->fl, flp)) {
                        struct multipath_candidate* mpc =
@@ -287,7 +287,7 @@ static void __multipath_free(struct rcu_head *head)
 
 static void __multipath_free_dst(struct rcu_head *head)
 {
-       struct multipath_dest *dst = container_of(head,
+       struct multipath_dest *dst = container_of(head,
                                                  struct multipath_dest,
                                                  rcu);
        kfree(dst);
index c47ce7076bd55fd66b4688d2d081daa9c2a3aca2..6069a11514f66a5322074f4783edbb32b1738b92 100644 (file)
@@ -53,7 +53,7 @@ int ip_route_me_harder(struct sk_buff **pskb, unsigned addr_type)
                dst_release(&rt->u.dst);
                dst_release(odst);
        }
-       
+
        if ((*pskb)->dst->error)
                return -1;
 
@@ -70,7 +70,7 @@ int ip_route_me_harder(struct sk_buff **pskb, unsigned addr_type)
                struct sk_buff *nskb;
 
                nskb = skb_realloc_headroom(*pskb, hh_len);
-               if (!nskb) 
+               if (!nskb)
                        return -1;
                if ((*pskb)->sk)
                        skb_set_owner_w(nskb, (*pskb)->sk);
@@ -177,7 +177,7 @@ __sum16 nf_ip_checksum(struct sk_buff *skb, unsigned int hook,
                        break;
                if ((protocol == 0 && !csum_fold(skb->csum)) ||
                    !csum_tcpudp_magic(iph->saddr, iph->daddr,
-                                      skb->len - dataoff, protocol,
+                                      skb->len - dataoff, protocol,
                                       skb->csum)) {
                        skb->ip_summed = CHECKSUM_UNNECESSARY;
                        break;
index 47bd3ad18b71eda5ca14eff95d9a67fd609eb59f..9b08e7ad71bc3cb6bd1358ae880987812260e2a8 100644 (file)
@@ -361,32 +361,6 @@ config IP_NF_TARGET_ULOG
 
          To compile it as a module, choose M here.  If unsure, say N.
 
-config IP_NF_TARGET_TCPMSS
-       tristate "TCPMSS target support"
-       depends on IP_NF_IPTABLES
-       ---help---
-         This option adds a `TCPMSS' target, which allows you to alter the
-         MSS value of TCP SYN packets, to control the maximum size for that
-         connection (usually limiting it to your outgoing interface's MTU
-         minus 40).
-
-         This is used to overcome criminally braindead ISPs or servers which
-         block ICMP Fragmentation Needed packets.  The symptoms of this
-         problem are that everything works fine from your Linux
-         firewall/router, but machines behind it can never exchange large
-         packets:
-               1) Web browsers connect, then hang with no data received.
-               2) Small mail works fine, but large emails hang.
-               3) ssh works fine, but scp hangs after initial handshaking.
-
-         Workaround: activate this option and add a rule to your firewall
-         configuration like:
-
-         iptables -A FORWARD -p tcp --tcp-flags SYN,RST SYN \
-                        -j TCPMSS --clamp-mss-to-pmtu
-
-         To compile it as a module, choose M here.  If unsure, say N.
-
 # NAT + specific targets: ip_conntrack
 config IP_NF_NAT
        tristate "Full NAT"
index 16d177b71bf82444c901b9b6cc6c5fe4480d501f..6625ec68180cd2a482da02f8c5f6eb25b19d0d82 100644 (file)
@@ -103,7 +103,6 @@ obj-$(CONFIG_IP_NF_TARGET_SAME) += ipt_SAME.o
 obj-$(CONFIG_IP_NF_NAT_SNMP_BASIC) += ip_nat_snmp_basic.o
 obj-$(CONFIG_IP_NF_TARGET_LOG) += ipt_LOG.o
 obj-$(CONFIG_IP_NF_TARGET_ULOG) += ipt_ULOG.o
-obj-$(CONFIG_IP_NF_TARGET_TCPMSS) += ipt_TCPMSS.o
 obj-$(CONFIG_IP_NF_TARGET_CLUSTERIP) += ipt_CLUSTERIP.o
 obj-$(CONFIG_IP_NF_TARGET_TTL) += ipt_TTL.o
 
index 9aa22398b3dc9dca9da657ef86c696754ce11ef0..5170f5c75f9d1742e4f47cfdc693543b744cfe10 100644 (file)
@@ -544,7 +544,7 @@ static inline int check_entry_size_and_hooks(struct arpt_entry *e,
        }
 
        /* FIXME: underflows must be unconditional, standard verdicts
-           < 0 (not ARPT_RETURN). --RR */
+          < 0 (not ARPT_RETURN). --RR */
 
        /* Clear counters and comefrom */
        e->counters = ((struct xt_counters) { 0, 0 });
@@ -869,8 +869,8 @@ static int do_replace(void __user *user, unsigned int len)
        /* Update module usage count based on number of rules */
        duprintf("do_replace: oldnum=%u, initnum=%u, newnum=%u\n",
                oldinfo->number, oldinfo->initial_entries, newinfo->number);
-       if ((oldinfo->number > oldinfo->initial_entries) || 
-           (newinfo->number <= oldinfo->initial_entries)) 
+       if ((oldinfo->number > oldinfo->initial_entries) ||
+           (newinfo->number <= oldinfo->initial_entries))
                module_put(t->me);
        if ((oldinfo->number > oldinfo->initial_entries) &&
            (newinfo->number <= oldinfo->initial_entries))
index d12b1df252a1d985376bb82b7cc1604b31c61056..709db4d3f48f7fe9d7fb3f17a844595e9a690bde 100644 (file)
@@ -67,7 +67,7 @@ target(struct sk_buff **pskb,
 
 static int
 checkentry(const char *tablename, const void *e, const struct xt_target *target,
-           void *targinfo, unsigned int hook_mask)
+          void *targinfo, unsigned int hook_mask)
 {
        const struct arpt_mangle *mangle = targinfo;
 
index ad246ba7790b0c2718fdaaf12ed7eb0d597ea357..4f561f52c83a52c42baea4019023f6d641cd4c93 100644 (file)
@@ -9,7 +9,7 @@
  *
  *     Module load syntax:
  *     insmod ip_conntrack_amanda.o [master_timeout=n]
- *     
+ *
  *     Where master_timeout is the timeout (in seconds) of the master
  *     connection (port 10080).  This defaults to 5 minutes but if
  *     your clients take longer than 5 minutes to do their work
@@ -84,7 +84,7 @@ static struct {
 };
 
 static int help(struct sk_buff **pskb,
-                struct ip_conntrack *ct, enum ip_conntrack_info ctinfo)
+               struct ip_conntrack *ct, enum ip_conntrack_info ctinfo)
 {
        struct ts_state ts;
        struct ip_conntrack_expect *exp;
index 8556a4f4f60abde4adf99135e4c28967f4d2d96b..04e466d53c0b8f399469d5936654337ecf5e2482 100644 (file)
@@ -2,7 +2,7 @@
    but required by, the NAT layer; it can also be used by an iptables
    extension. */
 
-/* (C) 1999-2001 Paul `Rusty' Russell  
+/* (C) 1999-2001 Paul `Rusty' Russell
  * (C) 2002-2004 Netfilter Core Team <coreteam@netfilter.org>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -99,7 +99,7 @@ __ip_ct_deliver_cached_events(struct ip_conntrack_ecache *ecache)
 void ip_ct_deliver_cached_events(const struct ip_conntrack *ct)
 {
        struct ip_conntrack_ecache *ecache;
-       
+
        local_bh_disable();
        ecache = &__get_cpu_var(ip_conntrack_ecache);
        if (ecache->ct == ct)
@@ -147,9 +147,9 @@ static u_int32_t __hash_conntrack(const struct ip_conntrack_tuple *tuple,
                            unsigned int size, unsigned int rnd)
 {
        return (jhash_3words((__force u32)tuple->src.ip,
-                            ((__force u32)tuple->dst.ip ^ tuple->dst.protonum),
-                            (tuple->src.u.all | (tuple->dst.u.all << 16)),
-                            rnd) % size);
+                            ((__force u32)tuple->dst.ip ^ tuple->dst.protonum),
+                            (tuple->src.u.all | (tuple->dst.u.all << 16)),
+                            rnd) % size);
 }
 
 static u_int32_t
@@ -219,7 +219,7 @@ struct ip_conntrack_expect *
 __ip_conntrack_expect_find(const struct ip_conntrack_tuple *tuple)
 {
        struct ip_conntrack_expect *i;
-       
+
        list_for_each_entry(i, &ip_conntrack_expect_list, list) {
                if (ip_ct_tuple_mask_cmp(tuple, &i->tuple, &i->mask))
                        return i;
@@ -232,7 +232,7 @@ struct ip_conntrack_expect *
 ip_conntrack_expect_find_get(const struct ip_conntrack_tuple *tuple)
 {
        struct ip_conntrack_expect *i;
-       
+
        read_lock_bh(&ip_conntrack_lock);
        i = __ip_conntrack_expect_find(tuple);
        if (i)
@@ -398,7 +398,7 @@ ip_conntrack_find_get(const struct ip_conntrack_tuple *tuple,
 
 static void __ip_conntrack_hash_insert(struct ip_conntrack *ct,
                                        unsigned int hash,
-                                       unsigned int repl_hash) 
+                                       unsigned int repl_hash)
 {
        ct->id = ++ip_conntrack_next_id;
        list_add(&ct->tuplehash[IP_CT_DIR_ORIGINAL].list,
@@ -446,15 +446,15 @@ __ip_conntrack_confirm(struct sk_buff **pskb)
        /* IP_NF_ASSERT(atomic_read(&ct->ct_general.use) == 1); */
 
        /* No external references means noone else could have
-           confirmed us. */
+          confirmed us. */
        IP_NF_ASSERT(!is_confirmed(ct));
        DEBUGP("Confirming conntrack %p\n", ct);
 
        write_lock_bh(&ip_conntrack_lock);
 
        /* See if there's one in the list already, including reverse:
-           NAT could have grabbed it without realizing, since we're
-           not in the hash.  If there is, we lost race. */
+          NAT could have grabbed it without realizing, since we're
+          not in the hash.  If there is, we lost race. */
        list_for_each_entry(h, &ip_conntrack_hash[hash], list)
                if (ip_ct_tuple_equal(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
                                      &h->tuple))
@@ -602,7 +602,7 @@ ip_conntrack_proto_find_get(u_int8_t protocol)
                        p = &ip_conntrack_generic_protocol;
        }
        preempt_enable();
-       
+
        return p;
 }
 
@@ -638,14 +638,13 @@ struct ip_conntrack *ip_conntrack_alloc(struct ip_conntrack_tuple *orig,
                }
        }
 
-       conntrack = kmem_cache_alloc(ip_conntrack_cachep, GFP_ATOMIC);
+       conntrack = kmem_cache_zalloc(ip_conntrack_cachep, GFP_ATOMIC);
        if (!conntrack) {
                DEBUGP("Can't allocate conntrack.\n");
                atomic_dec(&ip_conntrack_count);
                return ERR_PTR(-ENOMEM);
        }
 
-       memset(conntrack, 0, sizeof(*conntrack));
        atomic_set(&conntrack->ct_general.use, 1);
        conntrack->ct_general.destroy = destroy_conntrack;
        conntrack->tuplehash[IP_CT_DIR_ORIGINAL].tuple = *orig;
@@ -746,7 +745,7 @@ resolve_normal_ct(struct sk_buff *skb,
 
        IP_NF_ASSERT((skb->nh.iph->frag_off & htons(IP_OFFSET)) == 0);
 
-       if (!ip_ct_get_tuple(skb->nh.iph, skb, skb->nh.iph->ihl*4, 
+       if (!ip_ct_get_tuple(skb->nh.iph, skb, skb->nh.iph->ihl*4,
                                &tuple,proto))
                return NULL;
 
@@ -771,7 +770,7 @@ resolve_normal_ct(struct sk_buff *skb,
                if (test_bit(IPS_SEEN_REPLY_BIT, &ct->status)) {
                        DEBUGP("ip_conntrack_in: normal packet for %p\n",
                               ct);
-                       *ctinfo = IP_CT_ESTABLISHED;
+                       *ctinfo = IP_CT_ESTABLISHED;
                } else if (test_bit(IPS_EXPECTED_BIT, &ct->status)) {
                        DEBUGP("ip_conntrack_in: related packet for %p\n",
                               ct);
@@ -822,7 +821,7 @@ unsigned int ip_conntrack_in(unsigned int hooknum,
        if ((*pskb)->pkt_type == PACKET_BROADCAST) {
                printk("Broadcast packet!\n");
                return NF_ACCEPT;
-       } else if (((*pskb)->nh.iph->daddr & htonl(0x000000FF)) 
+       } else if (((*pskb)->nh.iph->daddr & htonl(0x000000FF))
                   == htonl(0x000000FF)) {
                printk("Should bcast: %u.%u.%u.%u->%u.%u.%u.%u (sk=%p, ptype=%u)\n",
                       NIPQUAD((*pskb)->nh.iph->saddr),
@@ -836,7 +835,7 @@ unsigned int ip_conntrack_in(unsigned int hooknum,
        /* It may be an special packet, error, unclean...
         * inverse of the return code tells to the netfilter
         * core what to do with the packet. */
-       if (proto->error != NULL 
+       if (proto->error != NULL
            && (ret = proto->error(*pskb, &ctinfo, hooknum)) <= 0) {
                CONNTRACK_STAT_INC(error);
                CONNTRACK_STAT_INC(invalid);
@@ -876,7 +875,7 @@ unsigned int ip_conntrack_in(unsigned int hooknum,
 int invert_tuplepr(struct ip_conntrack_tuple *inverse,
                   const struct ip_conntrack_tuple *orig)
 {
-       return ip_ct_invert_tuple(inverse, orig, 
+       return ip_ct_invert_tuple(inverse, orig,
                                  __ip_conntrack_proto_find(orig->dst.protonum));
 }
 
@@ -885,7 +884,7 @@ static inline int expect_clash(const struct ip_conntrack_expect *a,
                               const struct ip_conntrack_expect *b)
 {
        /* Part covered by intersection of masks must be unequal,
-           otherwise they clash */
+          otherwise they clash */
        struct ip_conntrack_tuple intersect_mask
                = { { a->mask.src.ip & b->mask.src.ip,
                      { a->mask.src.u.all & b->mask.src.u.all } },
@@ -923,7 +922,7 @@ void ip_conntrack_unexpect_related(struct ip_conntrack_expect *exp)
 }
 
 /* We don't increase the master conntrack refcount for non-fulfilled
- * conntracks. During the conntrack destruction, the expectations are 
+ * conntracks. During the conntrack destruction, the expectations are
  * always killed before the conntrack itself */
 struct ip_conntrack_expect *ip_conntrack_expect_alloc(struct ip_conntrack *me)
 {
@@ -1012,7 +1011,7 @@ int ip_conntrack_expect_related(struct ip_conntrack_expect *expect)
        }
 
        /* Will be over limit? */
-       if (expect->master->helper->max_expected && 
+       if (expect->master->helper->max_expected &&
            expect->master->expecting >= expect->master->helper->max_expected)
                evict_oldest_expect(expect->master);
 
@@ -1021,7 +1020,7 @@ int ip_conntrack_expect_related(struct ip_conntrack_expect *expect)
        ret = 0;
 out:
        write_unlock_bh(&ip_conntrack_lock);
-       return ret;
+       return ret;
 }
 
 /* Alter reply tuple (maybe alter helper).  This is for NAT, and is
@@ -1069,7 +1068,7 @@ static inline void unhelp(struct ip_conntrack_tuple_hash *i,
                          const struct ip_conntrack_helper *me)
 {
        if (tuplehash_to_ctrack(i)->helper == me) {
-               ip_conntrack_event(IPCT_HELPER, tuplehash_to_ctrack(i));
+               ip_conntrack_event(IPCT_HELPER, tuplehash_to_ctrack(i));
                tuplehash_to_ctrack(i)->helper = NULL;
        }
 }
@@ -1105,8 +1104,8 @@ void ip_conntrack_helper_unregister(struct ip_conntrack_helper *me)
 }
 
 /* Refresh conntrack for this many jiffies and do accounting if do_acct is 1 */
-void __ip_ct_refresh_acct(struct ip_conntrack *ct, 
-                       enum ip_conntrack_info ctinfo,
+void __ip_ct_refresh_acct(struct ip_conntrack *ct,
+                       enum ip_conntrack_info ctinfo,
                        const struct sk_buff *skb,
                        unsigned long extra_jiffies,
                        int do_acct)
@@ -1140,7 +1139,7 @@ void __ip_ct_refresh_acct(struct ip_conntrack *ct,
 #ifdef CONFIG_IP_NF_CT_ACCT
        if (do_acct) {
                ct->counters[CTINFO2DIR(ctinfo)].packets++;
-               ct->counters[CTINFO2DIR(ctinfo)].bytes += 
+               ct->counters[CTINFO2DIR(ctinfo)].bytes +=
                                                ntohs(skb->nh.iph->tot_len);
                if ((ct->counters[CTINFO2DIR(ctinfo)].packets & 0x80000000)
                    || (ct->counters[CTINFO2DIR(ctinfo)].bytes & 0x80000000))
@@ -1194,7 +1193,7 @@ ip_ct_gather_frags(struct sk_buff *skb, u_int32_t user)
 {
        skb_orphan(skb);
 
-       local_bh_disable(); 
+       local_bh_disable();
        skb = ip_defrag(skb, user);
        local_bh_enable();
 
@@ -1211,7 +1210,7 @@ static void ip_conntrack_attach(struct sk_buff *nskb, struct sk_buff *skb)
 
        /* This ICMP is in reverse direction to the packet which caused it */
        ct = ip_conntrack_get(skb, &ctinfo);
-       
+
        if (CTINFO2DIR(ctinfo) == IP_CT_DIR_ORIGINAL)
                ctinfo = IP_CT_RELATED + IP_CT_IS_REPLY;
        else
@@ -1279,7 +1278,7 @@ getorigdst(struct sock *sk, int optval, void __user *user, int *len)
        struct inet_sock *inet = inet_sk(sk);
        struct ip_conntrack_tuple_hash *h;
        struct ip_conntrack_tuple tuple;
-       
+
        IP_CT_TUPLE_U_BLANK(&tuple);
        tuple.src.ip = inet->rcv_saddr;
        tuple.src.u.tcp.port = inet->sport;
@@ -1347,7 +1346,7 @@ static void free_conntrack_hash(struct list_head *hash, int vmalloced,int size)
        if (vmalloced)
                vfree(hash);
        else
-               free_pages((unsigned long)hash, 
+               free_pages((unsigned long)hash,
                           get_order(sizeof(struct list_head) * size));
 }
 
@@ -1358,8 +1357,8 @@ void ip_conntrack_cleanup(void)
        ip_ct_attach = NULL;
 
        /* This makes sure all current packets have passed through
-           netfilter framework.  Roll on, two-stage module
-           delete... */
+          netfilter framework.  Roll on, two-stage module
+          delete... */
        synchronize_net();
 
        ip_ct_event_cache_flush();
@@ -1385,11 +1384,11 @@ static struct list_head *alloc_hashtable(int size, int *vmalloced)
        struct list_head *hash;
        unsigned int i;
 
-       *vmalloced = 0; 
-       hash = (void*)__get_free_pages(GFP_KERNEL, 
+       *vmalloced = 0;
+       hash = (void*)__get_free_pages(GFP_KERNEL,
                                       get_order(sizeof(struct list_head)
                                                 * size));
-       if (!hash) { 
+       if (!hash) {
                *vmalloced = 1;
                printk(KERN_WARNING"ip_conntrack: falling back to vmalloc.\n");
                hash = vmalloc(sizeof(struct list_head) * size);
@@ -1422,7 +1421,7 @@ static int set_hashsize(const char *val, struct kernel_param *kp)
        if (!hash)
                return -ENOMEM;
 
-       /* We have to rehash for the new table anyway, so we also can 
+       /* We have to rehash for the new table anyway, so we also can
         * use a new random seed */
        get_random_bytes(&rnd, 4);
 
@@ -1460,7 +1459,7 @@ int __init ip_conntrack_init(void)
 
        /* Idea from tcp.c: use 1/16384 of memory.  On i386: 32MB
         * machine has 256 buckets.  >= 1GB machines have 8192 buckets. */
-       if (!ip_conntrack_htable_size) {
+       if (!ip_conntrack_htable_size) {
                ip_conntrack_htable_size
                        = (((num_physpages << PAGE_SHIFT) / 16384)
                           / sizeof(struct list_head));
@@ -1490,8 +1489,8 @@ int __init ip_conntrack_init(void)
        }
 
        ip_conntrack_cachep = kmem_cache_create("ip_conntrack",
-                                               sizeof(struct ip_conntrack), 0,
-                                               0, NULL, NULL);
+                                               sizeof(struct ip_conntrack), 0,
+                                               0, NULL, NULL);
        if (!ip_conntrack_cachep) {
                printk(KERN_ERR "Unable to create ip_conntrack slab cache\n");
                goto err_free_hash;
index 0410c99cacae04d835b6f63ed789a8d54d81b4e7..1faa68ab9432e3a830f220ccde7b1348a9762f1d 100644 (file)
@@ -1,6 +1,6 @@
 /* FTP extension for IP connection tracking. */
 
-/* (C) 1999-2001 Paul `Rusty' Russell  
+/* (C) 1999-2001 Paul `Rusty' Russell
  * (C) 2002-2004 Netfilter Core Team <coreteam@netfilter.org>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -169,7 +169,7 @@ static int try_eprt(const char *data, size_t dlen, u_int32_t array[6],
        int length;
 
        /* First character is delimiter, then "1" for IPv4, then
-           delimiter again. */
+          delimiter again. */
        if (dlen <= 3) return 0;
        delim = data[0];
        if (isdigit(delim) || delim < 33 || delim > 126
@@ -344,14 +344,14 @@ static int help(struct sk_buff **pskb,
        if (!find_nl_seq(ntohl(th->seq), ct_ftp_info, dir)) {
                /* Now if this ends in \n, update ftp info. */
                DEBUGP("ip_conntrack_ftp_help: wrong seq pos %s(%u) or %s(%u)\n",
-                      ct_ftp_info->seq_aft_nl[0][dir] 
+                      ct_ftp_info->seq_aft_nl[0][dir]
                       old_seq_aft_nl_set ? "":"(UNSET) ", old_seq_aft_nl);
                ret = NF_ACCEPT;
                goto out_update_nl;
        }
 
        /* Initialize IP array to expected address (it's not mentioned
-           in EPSV responses) */
+          in EPSV responses) */
        array[0] = (ntohl(ct->tuplehash[dir].tuple.src.ip) >> 24) & 0xFF;
        array[1] = (ntohl(ct->tuplehash[dir].tuple.src.ip) >> 16) & 0xFF;
        array[2] = (ntohl(ct->tuplehash[dir].tuple.src.ip) >> 8) & 0xFF;
@@ -386,7 +386,7 @@ static int help(struct sk_buff **pskb,
 
        DEBUGP("conntrack_ftp: match `%s' (%u bytes at %u)\n",
               fb_ptr + matchoff, matchlen, ntohl(th->seq) + matchoff);
-                        
+
        /* Allocate expectation which will be inserted */
        exp = ip_conntrack_expect_alloc(ct);
        if (exp == NULL) {
@@ -504,7 +504,7 @@ static int __init ip_conntrack_ftp_init(void)
                        sprintf(tmpname, "ftp-%d", ports[i]);
                ftp[i].name = tmpname;
 
-               DEBUGP("ip_ct_ftp: registering helper for port %d\n", 
+               DEBUGP("ip_ct_ftp: registering helper for port %d\n",
                                ports[i]);
                ret = ip_conntrack_helper_register(&ftp[i]);
 
index aabfe1c06905fac1f3852ed4faafb89e5c7e7d41..53eb365ccc7e507f7ecac494265418e65b54b6f2 100644 (file)
@@ -42,7 +42,7 @@ MODULE_PARM_DESC(gkrouted_only, "only accept calls from gatekeeper");
 static int callforward_filter = 1;
 module_param(callforward_filter, bool, 0600);
 MODULE_PARM_DESC(callforward_filter, "only create call forwarding expectations "
-                                    "if both endpoints are on different sides "
+                                    "if both endpoints are on different sides "
                                     "(determined by routing information)");
 
 /* Hooks for NAT */
index 4d19373bbf0d58c85f4e0e6c9fe7151abc51954c..2b760c5cf709a32987b916f032ecd2b11b1bfcd6 100644 (file)
@@ -560,7 +560,7 @@ conntrack_pptp_help(struct sk_buff **pskb,
        tcph = skb_header_pointer(*pskb, nexthdr_off, sizeof(_tcph), &_tcph);
        BUG_ON(!tcph);
        nexthdr_off += tcph->doff * 4;
-       datalen = tcplen - tcph->doff * 4;
+       datalen = tcplen - tcph->doff * 4;
 
        pptph = skb_header_pointer(*pskb, nexthdr_off, sizeof(_pptph), &_pptph);
        if (!pptph) {
@@ -624,7 +624,7 @@ static struct ip_conntrack_helper pptp = {
        .max_expected = 2,
        .timeout = 5 * 60,
        .tuple = { .src = { .ip = 0,
-                           .u = { .tcp = { .port =
+                           .u = { .tcp = { .port =
                                    __constant_htons(PPTP_CONTROL_PORT) } }
                          },
                   .dst = { .ip = 0,
@@ -638,7 +638,7 @@ static struct ip_conntrack_helper pptp = {
                  .dst = { .ip = 0,
                           .u = { .all = 0 },
                           .protonum = 0xff
-                        }
+                        }
                },
        .help = conntrack_pptp_help,
        .destroy = pptp_destroy_siblings,
index 91832eca4106470de11dbcd2c6a4aa3a52c3bab2..053e591f407ad0c9eb45382a2562c94faeeb0748 100644 (file)
@@ -1,6 +1,6 @@
 /* IRC extension for IP connection tracking, Version 1.21
  * (C) 2000-2002 by Harald Welte <laforge@gnumonks.org>
- * based on RR's ip_conntrack_ftp.c    
+ * based on RR's ip_conntrack_ftp.c
  *
  * ip_conntrack_irc.c,v 1.21 2002/02/05 14:49:26 laforge Exp
  *
  *     Module load syntax:
  *     insmod ip_conntrack_irc.o ports=port1,port2,...port<MAX_PORTS>
  *                         max_dcc_channels=n dcc_timeout=secs
- *     
+ *
  *     please give the ports of all IRC servers You wish to connect to.
  *     If You don't specify ports, the default will be port 6667.
  *     With max_dcc_channels you can define the maximum number of not
  *     yet answered DCC channels per IRC session (default 8).
- *     With dcc_timeout you can specify how long the system waits for 
+ *     With dcc_timeout you can specify how long the system waits for
  *     an expected DCC channel (default 300 seconds).
  *
  */
@@ -63,7 +63,7 @@ static const char *dccprotos[] = { "SEND ", "CHAT ", "MOVE ", "TSEND ", "SCHAT "
 
 #if 0
 #define DEBUGP(format, args...) printk(KERN_DEBUG "%s:%s:" format, \
-                                       __FILE__, __FUNCTION__ , ## args)
+                                      __FILE__, __FUNCTION__ , ## args)
 #else
 #define DEBUGP(format, args...)
 #endif
@@ -71,7 +71,7 @@ static const char *dccprotos[] = { "SEND ", "CHAT ", "MOVE ", "TSEND ", "SCHAT "
 static int parse_dcc(char *data, char *data_end, u_int32_t *ip,
                     u_int16_t *port, char **ad_beg_p, char **ad_end_p)
 /* tries to get the ip_addr and port out of a dcc command
-   return value: -1 on failure, 0 on success 
+   return value: -1 on failure, 0 on success
        data            pointer to first byte of DCC command data
        data_end        pointer to last byte of dcc command data
        ip              returns parsed ip of dcc command
@@ -90,7 +90,7 @@ static int parse_dcc(char *data, char *data_end, u_int32_t *ip,
 
        /* skip blanks between ip and port */
        while (*data == ' ') {
-               if (data >= data_end) 
+               if (data >= data_end)
                        return -1;
                data++;
        }
@@ -171,7 +171,7 @@ static int help(struct sk_buff **pskb,
 
                        DEBUGP("DCC %s detected\n", dccprotos[i]);
                        data += strlen(dccprotos[i]);
-                       /* we have at least 
+                       /* we have at least
                         * (19+MINMATCHLEN)-5-dccprotos[i].matchlen bytes valid
                         * data left (== 14/13 bytes) */
                        if (parse_dcc((char *)data, data_limit, &dcc_ip,
@@ -260,7 +260,7 @@ static int __init ip_conntrack_irc_init(void)
        irc_buffer = kmalloc(65536, GFP_KERNEL);
        if (!irc_buffer)
                return -ENOMEM;
-       
+
        /* If no port given, default to standard irc port */
        if (ports_c == 0)
                ports[ports_c++] = IRC_PORT;
@@ -297,7 +297,7 @@ static int __init ip_conntrack_irc_init(void)
        return 0;
 }
 
-/* This function is intentionally _NOT_ defined as __exit, because 
+/* This function is intentionally _NOT_ defined as __exit, because
  * it is needed by the init function */
 static void ip_conntrack_irc_fini(void)
 {
index a1d6a89f64aa44b140eaa46473562f89508ec7c9..cc6dd49c9da0060f7fcf40d97a26925c1399440d 100644 (file)
@@ -42,7 +42,7 @@ module_param(timeout, uint, 0400);
 MODULE_PARM_DESC(timeout, "timeout for master connection/replies in seconds");
 
 static int help(struct sk_buff **pskb,
-                struct ip_conntrack *ct, enum ip_conntrack_info ctinfo)
+               struct ip_conntrack *ct, enum ip_conntrack_info ctinfo)
 {
        struct ip_conntrack_expect *exp;
        struct iphdr *iph = (*pskb)->nh.iph;
index 7f70b0886b83d4deaa97ed588f904d275d4b7be1..9228b76ccd9ac00993bb7d2c3020e884fbaef4dc 100644 (file)
@@ -6,10 +6,10 @@
  * (C) 2003 by Patrick Mchardy <kaber@trash.net>
  * (C) 2005-2006 by Pablo Neira Ayuso <pablo@eurodev.net>
  *
- * I've reworked this stuff to use attributes instead of conntrack 
+ * I've reworked this stuff to use attributes instead of conntrack
  * structures. 5.44 am. I need more tea. --pablo 05/07/11.
  *
- * Initial connection tracking via netlink development funded and 
+ * Initial connection tracking via netlink development funded and
  * generally made possible by Network Robots, Inc. (www.networkrobots.com)
  *
  * Further development of this code funded by Astaro AG (http://www.astaro.com)
@@ -45,7 +45,7 @@ MODULE_LICENSE("GPL");
 static char __initdata version[] = "0.90";
 
 static inline int
-ctnetlink_dump_tuples_proto(struct sk_buff *skb, 
+ctnetlink_dump_tuples_proto(struct sk_buff *skb,
                            const struct ip_conntrack_tuple *tuple,
                            struct ip_conntrack_protocol *proto)
 {
@@ -56,7 +56,7 @@ ctnetlink_dump_tuples_proto(struct sk_buff *skb,
 
        if (likely(proto->tuple_to_nfattr))
                ret = proto->tuple_to_nfattr(skb, tuple);
-       
+
        NFA_NEST_END(skb, nest_parms);
 
        return ret;
@@ -70,7 +70,7 @@ ctnetlink_dump_tuples_ip(struct sk_buff *skb,
                         const struct ip_conntrack_tuple *tuple)
 {
        struct nfattr *nest_parms = NFA_NEST(skb, CTA_TUPLE_IP);
-       
+
        NFA_PUT(skb, CTA_IP_V4_SRC, sizeof(__be32), &tuple->src.ip);
        NFA_PUT(skb, CTA_IP_V4_DST, sizeof(__be32), &tuple->dst.ip);
 
@@ -121,7 +121,7 @@ ctnetlink_dump_timeout(struct sk_buff *skb, const struct ip_conntrack *ct)
                timeout = 0;
        else
                timeout = htonl(timeout_l / HZ);
-       
+
        NFA_PUT(skb, CTA_TIMEOUT, sizeof(timeout), &timeout);
        return 0;
 
@@ -141,7 +141,7 @@ ctnetlink_dump_protoinfo(struct sk_buff *skb, const struct ip_conntrack *ct)
                ip_conntrack_proto_put(proto);
                return 0;
        }
-       
+
        nest_proto = NFA_NEST(skb, CTA_PROTOINFO);
 
        ret = proto->to_nfattr(skb, nest_proto, ct);
@@ -164,7 +164,7 @@ ctnetlink_dump_helpinfo(struct sk_buff *skb, const struct ip_conntrack *ct)
 
        if (!ct->helper)
                return 0;
-               
+
        nest_helper = NFA_NEST(skb, CTA_HELP);
        NFA_PUT(skb, CTA_HELP_NAME, strlen(ct->helper->name), ct->helper->name);
 
@@ -236,7 +236,7 @@ static inline int
 ctnetlink_dump_use(struct sk_buff *skb, const struct ip_conntrack *ct)
 {
        __be32 use = htonl(atomic_read(&ct->ct_general.use));
-       
+
        NFA_PUT(skb, CTA_USE, sizeof(__be32), &use);
        return 0;
 
@@ -248,7 +248,7 @@ nfattr_failure:
 
 static int
 ctnetlink_fill_info(struct sk_buff *skb, u32 pid, u32 seq,
-                   int event, int nowait, 
+                   int event, int nowait,
                    const struct ip_conntrack *ct)
 {
        struct nlmsghdr *nlh;
@@ -271,7 +271,7 @@ ctnetlink_fill_info(struct sk_buff *skb, u32 pid, u32 seq,
        if (ctnetlink_dump_tuples(skb, tuple(ct, IP_CT_DIR_ORIGINAL)) < 0)
                goto nfattr_failure;
        NFA_NEST_END(skb, nest_parms);
-       
+
        nest_parms = NFA_NEST(skb, CTA_TUPLE_REPLY);
        if (ctnetlink_dump_tuples(skb, tuple(ct, IP_CT_DIR_REPLY)) < 0)
                goto nfattr_failure;
@@ -299,7 +299,7 @@ nfattr_failure:
 
 #ifdef CONFIG_IP_NF_CONNTRACK_EVENTS
 static int ctnetlink_conntrack_event(struct notifier_block *this,
-                                     unsigned long events, void *ptr)
+                                    unsigned long events, void *ptr)
 {
        struct nlmsghdr *nlh;
        struct nfgenmsg *nfmsg;
@@ -324,7 +324,7 @@ static int ctnetlink_conntrack_event(struct notifier_block *this,
        } else if (events & (IPCT_STATUS | IPCT_PROTOINFO)) {
                type = IPCTNL_MSG_CT_NEW;
                group = NFNLGRP_CONNTRACK_UPDATE;
-       } else 
+       } else
                return NOTIFY_DONE;
 
        if (!nfnetlink_has_listeners(group))
@@ -349,7 +349,7 @@ static int ctnetlink_conntrack_event(struct notifier_block *this,
        if (ctnetlink_dump_tuples(skb, tuple(ct, IP_CT_DIR_ORIGINAL)) < 0)
                goto nfattr_failure;
        NFA_NEST_END(skb, nest_parms);
-       
+
        nest_parms = NFA_NEST(skb, CTA_TUPLE_REPLY);
        if (ctnetlink_dump_tuples(skb, tuple(ct, IP_CT_DIR_REPLY)) < 0)
                goto nfattr_failure;
@@ -368,16 +368,16 @@ static int ctnetlink_conntrack_event(struct notifier_block *this,
 
                if (events & IPCT_PROTOINFO
                    && ctnetlink_dump_protoinfo(skb, ct) < 0)
-                       goto nfattr_failure;
+                       goto nfattr_failure;
 
                if ((events & IPCT_HELPER || ct->helper)
                    && ctnetlink_dump_helpinfo(skb, ct) < 0)
-                       goto nfattr_failure;
+                       goto nfattr_failure;
 
 #ifdef CONFIG_IP_NF_CONNTRACK_MARK
                if ((events & IPCT_MARK || ct->mark)
                    && ctnetlink_dump_mark(skb, ct) < 0)
-                       goto nfattr_failure;
+                       goto nfattr_failure;
 #endif
 
                if (events & IPCT_COUNTER_FILLING &&
@@ -426,7 +426,7 @@ restart:
                                cb->args[1] = 0;
                        }
                        if (ctnetlink_fill_info(skb, NETLINK_CB(cb->skb).pid,
-                                               cb->nlh->nlmsg_seq,
+                                               cb->nlh->nlmsg_seq,
                                                IPCTNL_MSG_CT_NEW,
                                                1, ct) < 0) {
                                nf_conntrack_get(&ct->ct_general);
@@ -488,7 +488,7 @@ static const size_t cta_min_proto[CTA_PROTO_MAX] = {
 };
 
 static inline int
-ctnetlink_parse_tuple_proto(struct nfattr *attr, 
+ctnetlink_parse_tuple_proto(struct nfattr *attr,
                            struct ip_conntrack_tuple *tuple)
 {
        struct nfattr *tb[CTA_PROTO_MAX];
@@ -508,9 +508,9 @@ ctnetlink_parse_tuple_proto(struct nfattr *attr,
 
        if (likely(proto->nfattr_to_tuple))
                ret = proto->nfattr_to_tuple(tb, tuple);
-       
+
        ip_conntrack_proto_put(proto);
-       
+
        return ret;
 }
 
@@ -595,7 +595,7 @@ ctnetlink_parse_nat(struct nfattr *nat,
        int err;
 
        memset(range, 0, sizeof(*range));
-       
+
        nfattr_parse_nested(tb, CTA_NAT_MAX, nat);
 
        if (nfattr_bad_size(tb, CTA_NAT_MAX, cta_min_nat))
@@ -647,7 +647,7 @@ static const size_t cta_min[CTA_MAX] = {
 };
 
 static int
-ctnetlink_del_conntrack(struct sock *ctnl, struct sk_buff *skb, 
+ctnetlink_del_conntrack(struct sock *ctnl, struct sk_buff *skb,
                        struct nlmsghdr *nlh, struct nfattr *cda[], int *errp)
 {
        struct ip_conntrack_tuple_hash *h;
@@ -676,14 +676,14 @@ ctnetlink_del_conntrack(struct sock *ctnl, struct sk_buff *skb,
                return -ENOENT;
 
        ct = tuplehash_to_ctrack(h);
-       
+
        if (cda[CTA_ID-1]) {
                u_int32_t id = ntohl(*(__be32 *)NFA_DATA(cda[CTA_ID-1]));
                if (ct->id != id) {
                        ip_conntrack_put(ct);
                        return -ENOENT;
                }
-       }       
+       }
        if (del_timer(&ct->timeout))
                ct->timeout.function((unsigned long)ct);
 
@@ -693,7 +693,7 @@ ctnetlink_del_conntrack(struct sock *ctnl, struct sk_buff *skb,
 }
 
 static int
-ctnetlink_get_conntrack(struct sock *ctnl, struct sk_buff *skb, 
+ctnetlink_get_conntrack(struct sock *ctnl, struct sk_buff *skb,
                        struct nlmsghdr *nlh, struct nfattr *cda[], int *errp)
 {
        struct ip_conntrack_tuple_hash *h;
@@ -714,8 +714,8 @@ ctnetlink_get_conntrack(struct sock *ctnl, struct sk_buff *skb,
                        return -ENOTSUPP;
 #endif
                if ((*errp = netlink_dump_start(ctnl, skb, nlh,
-                                               ctnetlink_dump_table,
-                                               ctnetlink_done)) != 0)
+                                               ctnetlink_dump_table,
+                                               ctnetlink_done)) != 0)
                        return -EINVAL;
 
                rlen = NLMSG_ALIGN(nlh->nlmsg_len);
@@ -751,7 +751,7 @@ ctnetlink_get_conntrack(struct sock *ctnl, struct sk_buff *skb,
                return -ENOMEM;
        }
 
-       err = ctnetlink_fill_info(skb2, NETLINK_CB(skb).pid, nlh->nlmsg_seq, 
+       err = ctnetlink_fill_info(skb2, NETLINK_CB(skb).pid, nlh->nlmsg_seq,
                                  IPCTNL_MSG_CT_NEW, 1, ct);
        ip_conntrack_put(ct);
        if (err <= 0)
@@ -779,12 +779,12 @@ ctnetlink_change_status(struct ip_conntrack *ct, struct nfattr *cda[])
        if (d & (IPS_EXPECTED|IPS_CONFIRMED|IPS_DYING))
                /* unchangeable */
                return -EINVAL;
-       
+
        if (d & IPS_SEEN_REPLY && !(status & IPS_SEEN_REPLY))
                /* SEEN_REPLY bit can only be set */
                return -EINVAL;
 
-       
+
        if (d & IPS_ASSURED && !(status & IPS_ASSURED))
                /* ASSURED bit can only be set */
                return -EINVAL;
@@ -857,7 +857,7 @@ ctnetlink_change_helper(struct ip_conntrack *ct, struct nfattr *cda[])
                        memset(&ct->help, 0, sizeof(ct->help));
                }
        }
-       
+
        ct->helper = helper;
 
        return 0;
@@ -867,7 +867,7 @@ static inline int
 ctnetlink_change_timeout(struct ip_conntrack *ct, struct nfattr *cda[])
 {
        u_int32_t timeout = ntohl(*(__be32 *)NFA_DATA(cda[CTA_TIMEOUT-1]));
-       
+
        if (!del_timer(&ct->timeout))
                return -ETIME;
 
@@ -891,7 +891,7 @@ ctnetlink_change_protoinfo(struct ip_conntrack *ct, struct nfattr *cda[])
 
        if (proto->from_nfattr)
                err = proto->from_nfattr(tb, ct);
-       ip_conntrack_proto_put(proto); 
+       ip_conntrack_proto_put(proto);
 
        return err;
 }
@@ -934,7 +934,7 @@ ctnetlink_change_conntrack(struct ip_conntrack *ct, struct nfattr *cda[])
 }
 
 static int
-ctnetlink_create_conntrack(struct nfattr *cda[], 
+ctnetlink_create_conntrack(struct nfattr *cda[],
                           struct ip_conntrack_tuple *otuple,
                           struct ip_conntrack_tuple *rtuple)
 {
@@ -943,7 +943,7 @@ ctnetlink_create_conntrack(struct nfattr *cda[],
 
        ct = ip_conntrack_alloc(otuple, rtuple);
        if (ct == NULL || IS_ERR(ct))
-               return -ENOMEM; 
+               return -ENOMEM;
 
        if (!cda[CTA_TIMEOUT-1])
                goto err;
@@ -979,13 +979,13 @@ ctnetlink_create_conntrack(struct nfattr *cda[],
 
        return 0;
 
-err:   
+err:
        ip_conntrack_free(ct);
        return err;
 }
 
-static int 
-ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff *skb, 
+static int
+ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff *skb,
                        struct nlmsghdr *nlh, struct nfattr *cda[], int *errp)
 {
        struct ip_conntrack_tuple otuple, rtuple;
@@ -1039,9 +1039,9 @@ out_unlock:
        return err;
 }
 
-/*********************************************************************** 
- * EXPECT 
- ***********************************************************************/ 
+/***********************************************************************
+ * EXPECT
+ ***********************************************************************/
 
 static inline int
 ctnetlink_exp_dump_tuple(struct sk_buff *skb,
@@ -1049,7 +1049,7 @@ ctnetlink_exp_dump_tuple(struct sk_buff *skb,
                         enum ctattr_expect type)
 {
        struct nfattr *nest_parms = NFA_NEST(skb, type);
-       
+
        if (ctnetlink_dump_tuples(skb, tuple) < 0)
                goto nfattr_failure;
 
@@ -1059,7 +1059,7 @@ ctnetlink_exp_dump_tuple(struct sk_buff *skb,
 
 nfattr_failure:
        return -1;
-}                      
+}
 
 static inline int
 ctnetlink_exp_dump_mask(struct sk_buff *skb,
@@ -1090,7 +1090,7 @@ nfattr_failure:
 
 static inline int
 ctnetlink_exp_dump_expect(struct sk_buff *skb,
-                          const struct ip_conntrack_expect *exp)
+                         const struct ip_conntrack_expect *exp)
 {
        struct ip_conntrack *master = exp->master;
        __be32 timeout = htonl((exp->timeout.expires - jiffies) / HZ);
@@ -1104,20 +1104,20 @@ ctnetlink_exp_dump_expect(struct sk_buff *skb,
                                 &master->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
                                 CTA_EXPECT_MASTER) < 0)
                goto nfattr_failure;
-       
+
        NFA_PUT(skb, CTA_EXPECT_TIMEOUT, sizeof(__be32), &timeout);
        NFA_PUT(skb, CTA_EXPECT_ID, sizeof(__be32), &id);
 
        return 0;
-       
+
 nfattr_failure:
        return -1;
 }
 
 static int
 ctnetlink_exp_fill_info(struct sk_buff *skb, u32 pid, u32 seq,
-                   int event, 
-                   int nowait, 
+                   int event,
+                   int nowait,
                    const struct ip_conntrack_expect *exp)
 {
        struct nlmsghdr *nlh;
@@ -1216,7 +1216,7 @@ ctnetlink_exp_dump_table(struct sk_buff *skb, struct netlink_callback *cb)
                        goto out;
                *id = exp->id;
        }
-out:   
+out:
        read_unlock_bh(&ip_conntrack_lock);
 
        return skb->len;
@@ -1228,7 +1228,7 @@ static const size_t cta_min_exp[CTA_EXPECT_MAX] = {
 };
 
 static int
-ctnetlink_get_expect(struct sock *ctnl, struct sk_buff *skb, 
+ctnetlink_get_expect(struct sock *ctnl, struct sk_buff *skb,
                     struct nlmsghdr *nlh, struct nfattr *cda[], int *errp)
 {
        struct ip_conntrack_tuple tuple;
@@ -1247,7 +1247,7 @@ ctnetlink_get_expect(struct sock *ctnl, struct sk_buff *skb,
                        return -EAFNOSUPPORT;
 
                if ((*errp = netlink_dump_start(ctnl, skb, nlh,
-                                               ctnetlink_exp_dump_table,
+                                               ctnetlink_exp_dump_table,
                                                ctnetlink_done)) != 0)
                        return -EINVAL;
                rlen = NLMSG_ALIGN(nlh->nlmsg_len);
@@ -1275,14 +1275,14 @@ ctnetlink_get_expect(struct sock *ctnl, struct sk_buff *skb,
                        ip_conntrack_expect_put(exp);
                        return -ENOENT;
                }
-       }       
+       }
 
        err = -ENOMEM;
        skb2 = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
        if (!skb2)
                goto out;
 
-       err = ctnetlink_exp_fill_info(skb2, NETLINK_CB(skb).pid, 
+       err = ctnetlink_exp_fill_info(skb2, NETLINK_CB(skb).pid,
                                      nlh->nlmsg_seq, IPCTNL_MSG_EXP_NEW,
                                      1, exp);
        if (err <= 0)
@@ -1300,7 +1300,7 @@ out:
 }
 
 static int
-ctnetlink_del_expect(struct sock *ctnl, struct sk_buff *skb, 
+ctnetlink_del_expect(struct sock *ctnl, struct sk_buff *skb,
                     struct nlmsghdr *nlh, struct nfattr *cda[], int *errp)
 {
        struct ip_conntrack_expect *exp, *tmp;
@@ -1333,7 +1333,7 @@ ctnetlink_del_expect(struct sock *ctnl, struct sk_buff *skb,
 
                /* after list removal, usage count == 1 */
                ip_conntrack_unexpect_related(exp);
-               /* have to put what we 'get' above. 
+               /* have to put what we 'get' above.
                 * after this line usage count == 0 */
                ip_conntrack_expect_put(exp);
        } else if (cda[CTA_EXPECT_HELP_NAME-1]) {
@@ -1348,7 +1348,7 @@ ctnetlink_del_expect(struct sock *ctnl, struct sk_buff *skb,
                }
                list_for_each_entry_safe(exp, tmp, &ip_conntrack_expect_list,
                                         list) {
-                       if (exp->master->helper == h 
+                       if (exp->master->helper == h
                            && del_timer(&exp->timeout)) {
                                ip_ct_unlink_expect(exp);
                                ip_conntrack_expect_put(exp);
@@ -1413,7 +1413,7 @@ ctnetlink_create_expect(struct nfattr *cda[])
                err = -ENOMEM;
                goto out;
        }
-       
+
        exp->expectfn = NULL;
        exp->flags = 0;
        exp->master = ct;
@@ -1423,7 +1423,7 @@ ctnetlink_create_expect(struct nfattr *cda[])
        err = ip_conntrack_expect_related(exp);
        ip_conntrack_expect_put(exp);
 
-out:   
+out:
        ip_conntrack_put(tuplehash_to_ctrack(h));
        return err;
 }
index 295b6fa340dbc021e440c77cd92de51c03291164..ec71abead00c76caae6ce0ea217f6240dc506a11 100644 (file)
@@ -94,9 +94,9 @@ static int icmp_packet(struct ip_conntrack *ct,
                       enum ip_conntrack_info ctinfo)
 {
        /* Try to delete connection immediately after all replies:
-           won't actually vanish as we still have skb, and del_timer
-           means this will only run once even if count hits zero twice
-           (theoretically possible with SMP) */
+          won't actually vanish as we still have skb, and del_timer
+          means this will only run once even if count hits zero twice
+          (theoretically possible with SMP) */
        if (CTINFO2DIR(ctinfo) == IP_CT_DIR_REPLY) {
                if (atomic_dec_and_test(&ct->proto.icmp.count)
                    && del_timer(&ct->timeout))
@@ -114,11 +114,11 @@ static int icmp_packet(struct ip_conntrack *ct,
 static int icmp_new(struct ip_conntrack *conntrack,
                    const struct sk_buff *skb)
 {
-       static const u_int8_t valid_new[] = { 
+       static const u_int8_t valid_new[] = {
                [ICMP_ECHO] = 1,
                [ICMP_TIMESTAMP] = 1,
                [ICMP_INFO_REQUEST] = 1,
-               [ICMP_ADDRESS] = 1 
+               [ICMP_ADDRESS] = 1
        };
 
        if (conntrack->tuplehash[0].tuple.dst.u.icmp.type >= sizeof(valid_new)
@@ -282,7 +282,7 @@ static int icmp_nfattr_to_tuple(struct nfattr *tb[],
            || !tb[CTA_PROTO_ICMP_ID-1])
                return -EINVAL;
 
-       tuple->dst.u.icmp.type = 
+       tuple->dst.u.icmp.type =
                        *(u_int8_t *)NFA_DATA(tb[CTA_PROTO_ICMP_TYPE-1]);
        tuple->dst.u.icmp.code =
                        *(u_int8_t *)NFA_DATA(tb[CTA_PROTO_ICMP_CODE-1]);
index 2443322e4128ac3f054fabd442cc80713b71dbc5..9d5b917f49cd27e64585c64a970315ca12e73610 100644 (file)
@@ -1,9 +1,9 @@
 /*
  * Connection tracking protocol helper module for SCTP.
- * 
- * SCTP is defined in RFC 2960. References to various sections in this code 
+ *
+ * SCTP is defined in RFC 2960. References to various sections in this code
  * are to this RFC.
- * 
+ *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
@@ -38,7 +38,7 @@
 static DEFINE_RWLOCK(sctp_lock);
 
 /* FIXME: Examine ipfilter's timeouts and conntrack transitions more
-   closely.  They're more complex. --RR 
+   closely.  They're more complex. --RR
 
    And so for me for SCTP :D -Kiran */
 
@@ -87,32 +87,32 @@ static const unsigned int * sctp_timeouts[]
 #define        sSA SCTP_CONNTRACK_SHUTDOWN_ACK_SENT
 #define        sIV SCTP_CONNTRACK_MAX
 
-/* 
+/*
        These are the descriptions of the states:
 
-NOTE: These state names are tantalizingly similar to the states of an 
+NOTE: These state names are tantalizingly similar to the states of an
 SCTP endpoint. But the interpretation of the states is a little different,
-considering that these are the states of the connection and not of an end 
+considering that these are the states of the connection and not of an end
 point. Please note the subtleties. -Kiran
 
 NONE              - Nothing so far.
-COOKIE WAIT       - We have seen an INIT chunk in the original direction, or also 
-                    an INIT_ACK chunk in the reply direction.
+COOKIE WAIT       - We have seen an INIT chunk in the original direction, or also
+                   an INIT_ACK chunk in the reply direction.
 COOKIE ECHOED     - We have seen a COOKIE_ECHO chunk in the original direction.
 ESTABLISHED       - We have seen a COOKIE_ACK in the reply direction.
 SHUTDOWN_SENT     - We have seen a SHUTDOWN chunk in the original direction.
 SHUTDOWN_RECD     - We have seen a SHUTDOWN chunk in the reply directoin.
 SHUTDOWN_ACK_SENT - We have seen a SHUTDOWN_ACK chunk in the direction opposite
-                    to that of the SHUTDOWN chunk.
-CLOSED            - We have seen a SHUTDOWN_COMPLETE chunk in the direction of 
-                    the SHUTDOWN chunk. Connection is closed.
+                   to that of the SHUTDOWN chunk.
+CLOSED            - We have seen a SHUTDOWN_COMPLETE chunk in the direction of
+                   the SHUTDOWN chunk. Connection is closed.
 */
 
 /* TODO
- - I have assumed that the first INIT is in the original direction. 
+ - I have assumed that the first INIT is in the original direction.
  This messes things when an INIT comes in the reply direction in CLOSED
  state.
- - Check the error type in the reply dir before transitioning from 
+ - Check the error type in the reply dir before transitioning from
 cookie echoed to closed.
  - Sec 5.2.4 of RFC 2960
  - Multi Homing support.
@@ -229,7 +229,7 @@ static int do_basic_checks(struct ip_conntrack *conntrack,
        for_each_sctp_chunk (skb, sch, _sch, offset, count) {
                DEBUGP("Chunk Num: %d  Type: %d\n", count, sch->type);
 
-               if (sch->type == SCTP_CID_INIT 
+               if (sch->type == SCTP_CID_INIT
                        || sch->type == SCTP_CID_INIT_ACK
                        || sch->type == SCTP_CID_SHUTDOWN_COMPLETE) {
                        flag = 1;
@@ -269,42 +269,42 @@ static int new_state(enum ip_conntrack_dir dir,
        DEBUGP("Chunk type: %d\n", chunk_type);
 
        switch (chunk_type) {
-               case SCTP_CID_INIT: 
+               case SCTP_CID_INIT:
                        DEBUGP("SCTP_CID_INIT\n");
                        i = 0; break;
-               case SCTP_CID_INIT_ACK: 
+               case SCTP_CID_INIT_ACK:
                        DEBUGP("SCTP_CID_INIT_ACK\n");
                        i = 1; break;
-               case SCTP_CID_ABORT: 
+               case SCTP_CID_ABORT:
                        DEBUGP("SCTP_CID_ABORT\n");
                        i = 2; break;
-               case SCTP_CID_SHUTDOWN: 
+               case SCTP_CID_SHUTDOWN:
                        DEBUGP("SCTP_CID_SHUTDOWN\n");
                        i = 3; break;
-               case SCTP_CID_SHUTDOWN_ACK: 
+               case SCTP_CID_SHUTDOWN_ACK:
                        DEBUGP("SCTP_CID_SHUTDOWN_ACK\n");
                        i = 4; break;
-               case SCTP_CID_ERROR: 
+               case SCTP_CID_ERROR:
                        DEBUGP("SCTP_CID_ERROR\n");
                        i = 5; break;
-               case SCTP_CID_COOKIE_ECHO: 
+               case SCTP_CID_COOKIE_ECHO:
                        DEBUGP("SCTP_CID_COOKIE_ECHO\n");
                        i = 6; break;
-               case SCTP_CID_COOKIE_ACK: 
+               case SCTP_CID_COOKIE_ACK:
                        DEBUGP("SCTP_CID_COOKIE_ACK\n");
                        i = 7; break;
-               case SCTP_CID_SHUTDOWN_COMPLETE: 
+               case SCTP_CID_SHUTDOWN_COMPLETE:
                        DEBUGP("SCTP_CID_SHUTDOWN_COMPLETE\n");
                        i = 8; break;
                default:
                        /* Other chunks like DATA, SACK, HEARTBEAT and
                        its ACK do not cause a change in state */
-                       DEBUGP("Unknown chunk type, Will stay in %s\n", 
+                       DEBUGP("Unknown chunk type, Will stay in %s\n",
                                                sctp_conntrack_names[cur_state]);
                        return cur_state;
        }
 
-       DEBUGP("dir: %d   cur_state: %s  chunk_type: %d  new_state: %s\n", 
+       DEBUGP("dir: %d   cur_state: %s  chunk_type: %d  new_state: %s\n",
                        dir, sctp_conntrack_names[cur_state], chunk_type,
                        sctp_conntrack_names[sctp_conntracks[dir][i][cur_state]]);
 
@@ -367,7 +367,7 @@ static int sctp_packet(struct ip_conntrack *conntrack,
                        /* Sec 8.5.1 (C) */
                        if (!(sh->vtag == conntrack->proto.sctp.vtag[CTINFO2DIR(ctinfo)])
                                && !(sh->vtag == conntrack->proto.sctp.vtag
-                                                       [1 - CTINFO2DIR(ctinfo)] 
+                                                       [1 - CTINFO2DIR(ctinfo)]
                                        && (sch->flags & 1))) {
                                write_unlock_bh(&sctp_lock);
                                return -1;
@@ -392,17 +392,17 @@ static int sctp_packet(struct ip_conntrack *conntrack,
                }
 
                /* If it is an INIT or an INIT ACK note down the vtag */
-               if (sch->type == SCTP_CID_INIT 
+               if (sch->type == SCTP_CID_INIT
                        || sch->type == SCTP_CID_INIT_ACK) {
                        sctp_inithdr_t _inithdr, *ih;
 
                        ih = skb_header_pointer(skb, offset + sizeof(sctp_chunkhdr_t),
-                                               sizeof(_inithdr), &_inithdr);
+                                               sizeof(_inithdr), &_inithdr);
                        if (ih == NULL) {
                                        write_unlock_bh(&sctp_lock);
                                        return -1;
                        }
-                       DEBUGP("Setting vtag %x for dir %d\n", 
+                       DEBUGP("Setting vtag %x for dir %d\n",
                                        ih->init_tag, !CTINFO2DIR(ctinfo));
                        conntrack->proto.sctp.vtag[!CTINFO2DIR(ctinfo)] = ih->init_tag;
                }
@@ -427,7 +427,7 @@ static int sctp_packet(struct ip_conntrack *conntrack,
 }
 
 /* Called when a new connection for this protocol found. */
-static int sctp_new(struct ip_conntrack *conntrack, 
+static int sctp_new(struct ip_conntrack *conntrack,
                    const struct sk_buff *skb)
 {
        enum sctp_conntrack newconntrack;
@@ -457,7 +457,7 @@ static int sctp_new(struct ip_conntrack *conntrack,
        newconntrack = SCTP_CONNTRACK_MAX;
        for_each_sctp_chunk (skb, sch, _sch, offset, count) {
                /* Don't need lock here: this conntrack not in circulation yet */
-               newconntrack = new_state (IP_CT_DIR_ORIGINAL, 
+               newconntrack = new_state (IP_CT_DIR_ORIGINAL,
                                                SCTP_CONNTRACK_NONE, sch->type);
 
                /* Invalid: delete conntrack */
@@ -472,14 +472,14 @@ static int sctp_new(struct ip_conntrack *conntrack,
                                sctp_inithdr_t _inithdr, *ih;
 
                                ih = skb_header_pointer(skb, offset + sizeof(sctp_chunkhdr_t),
-                                                       sizeof(_inithdr), &_inithdr);
+                                                       sizeof(_inithdr), &_inithdr);
                                if (ih == NULL)
                                        return 0;
 
-                               DEBUGP("Setting vtag %x for new conn\n", 
+                               DEBUGP("Setting vtag %x for new conn\n",
                                        ih->init_tag);
 
-                               conntrack->proto.sctp.vtag[IP_CT_DIR_REPLY] = 
+                               conntrack->proto.sctp.vtag[IP_CT_DIR_REPLY] =
                                                                ih->init_tag;
                        } else {
                                /* Sec 8.5.1 (A) */
@@ -489,7 +489,7 @@ static int sctp_new(struct ip_conntrack *conntrack,
                /* If it is a shutdown ack OOTB packet, we expect a return
                   shutdown complete, otherwise an ABORT Sec 8.4 (5) and (8) */
                else {
-                       DEBUGP("Setting vtag %x for new conn OOTB\n", 
+                       DEBUGP("Setting vtag %x for new conn OOTB\n",
                                sh->vtag);
                        conntrack->proto.sctp.vtag[IP_CT_DIR_REPLY] = sh->vtag;
                }
@@ -500,16 +500,16 @@ static int sctp_new(struct ip_conntrack *conntrack,
        return 1;
 }
 
-static struct ip_conntrack_protocol ip_conntrack_protocol_sctp = { 
-       .proto           = IPPROTO_SCTP, 
+static struct ip_conntrack_protocol ip_conntrack_protocol_sctp = {
+       .proto           = IPPROTO_SCTP,
        .name            = "sctp",
-       .pkt_to_tuple    = sctp_pkt_to_tuple, 
-       .invert_tuple    = sctp_invert_tuple, 
-       .print_tuple     = sctp_print_tuple, 
+       .pkt_to_tuple    = sctp_pkt_to_tuple,
+       .invert_tuple    = sctp_invert_tuple,
+       .print_tuple     = sctp_print_tuple,
        .print_conntrack = sctp_print_conntrack,
-       .packet          = sctp_packet, 
-       .new             = sctp_new, 
-       .destroy         = NULL, 
+       .packet          = sctp_packet,
+       .new             = sctp_new,
+       .destroy         = NULL,
        .me              = THIS_MODULE,
 #if defined(CONFIG_IP_NF_CONNTRACK_NETLINK) || \
     defined(CONFIG_IP_NF_CONNTRACK_NETLINK_MODULE)
@@ -603,7 +603,7 @@ static ctl_table ip_ct_net_table[] = {
        {
                .ctl_name       = CTL_NET,
                .procname       = "net",
-               .mode           = 0555, 
+               .mode           = 0555,
                .child          = ip_ct_ipv4_table,
        },
        { .ctl_name = 0 }
@@ -638,7 +638,7 @@ static int __init ip_conntrack_proto_sctp_init(void)
        ip_conntrack_protocol_unregister(&ip_conntrack_protocol_sctp);
 #endif
  out:
-       DEBUGP("SCTP conntrack module loading %s\n", 
+       DEBUGP("SCTP conntrack module loading %s\n",
                                        ret ? "failed": "succeeded");
        return ret;
 }
@@ -647,7 +647,7 @@ static void __exit ip_conntrack_proto_sctp_fini(void)
 {
        ip_conntrack_protocol_unregister(&ip_conntrack_protocol_sctp);
 #ifdef CONFIG_SYSCTL
-       unregister_sysctl_table(ip_ct_sysctl_header);
+       unregister_sysctl_table(ip_ct_sysctl_header);
 #endif
        DEBUGP("SCTP conntrack module unloaded\n");
 }
index 06e4e8a6dd9f88db85452c556d51058025db3dde..fa35b49fe2fa6c69dfc91a81b83fd5e0046a2067 100644 (file)
 /* Protects conntrack->proto.tcp */
 static DEFINE_RWLOCK(tcp_lock);
 
-/* "Be conservative in what you do, 
-    be liberal in what you accept from others." 
+/* "Be conservative in what you do,
+    be liberal in what you accept from others."
     If it's non-zero, we mark only out of window RST segments as INVALID. */
 int ip_ct_tcp_be_liberal __read_mostly = 0;
 
-/* When connection is picked up from the middle, how many packets are required
-   to pass in each direction when we assume we are in sync - if any side uses
-   window scaling, we lost the game. 
-   If it is set to zero, we disable picking up already established 
+/* If it is set to zero, we disable picking up already established
    connections. */
-int ip_ct_tcp_loose __read_mostly = 3;
+int ip_ct_tcp_loose __read_mostly = 1;
 
-/* Max number of the retransmitted packets without receiving an (acceptable) 
-   ACK from the destination. If this number is reached, a shorter timer 
+/* Max number of the retransmitted packets without receiving an (acceptable)
+   ACK from the destination. If this number is reached, a shorter timer
    will be started. */
 int ip_ct_tcp_max_retrans __read_mostly = 3;
 
@@ -77,7 +74,7 @@ static const char *tcp_conntrack_names[] = {
        "CLOSE",
        "LISTEN"
 };
-  
+
 #define SECS * HZ
 #define MINS * 60 SECS
 #define HOURS * 60 MINS
@@ -93,10 +90,10 @@ unsigned int ip_ct_tcp_timeout_time_wait __read_mostly =     2 MINS;
 unsigned int ip_ct_tcp_timeout_close __read_mostly =        10 SECS;
 
 /* RFC1122 says the R2 limit should be at least 100 seconds.
-   Linux uses 15 packets as limit, which corresponds 
+   Linux uses 15 packets as limit, which corresponds
    to ~13-30min depending on RTO. */
 unsigned int ip_ct_tcp_timeout_max_retrans __read_mostly =   5 MINS;
+
 static const unsigned int * tcp_timeouts[]
 = { NULL,                              /*      TCP_CONNTRACK_NONE */
     &ip_ct_tcp_timeout_syn_sent,       /*      TCP_CONNTRACK_SYN_SENT, */
@@ -109,7 +106,7 @@ static const unsigned int * tcp_timeouts[]
     &ip_ct_tcp_timeout_close,          /*      TCP_CONNTRACK_CLOSE,    */
     NULL,                              /*      TCP_CONNTRACK_LISTEN */
  };
+
 #define sNO TCP_CONNTRACK_NONE
 #define sSS TCP_CONNTRACK_SYN_SENT
 #define sSR TCP_CONNTRACK_SYN_RECV
@@ -132,13 +129,13 @@ enum tcp_bit_set {
        TCP_RST_SET,
        TCP_NONE_SET,
 };
-  
+
 /*
  * The TCP state transition table needs a few words...
  *
  * We are the man in the middle. All the packets go through us
  * but might get lost in transit to the destination.
- * It is assumed that the destinations can't receive segments 
+ * It is assumed that the destinations can't receive segments
  * we haven't seen.
  *
  * The checked segment is in window, but our windows are *not*
@@ -148,11 +145,11 @@ enum tcp_bit_set {
  * The meaning of the states are:
  *
  * NONE:       initial state
- * SYN_SENT:   SYN-only packet seen 
+ * SYN_SENT:   SYN-only packet seen
  * SYN_RECV:   SYN-ACK packet seen
  * ESTABLISHED:        ACK packet seen
  * FIN_WAIT:   FIN packet seen
- * CLOSE_WAIT: ACK seen (after FIN) 
+ * CLOSE_WAIT: ACK seen (after FIN)
  * LAST_ACK:   FIN seen (after FIN)
  * TIME_WAIT:  last ACK seen
  * CLOSE:      closed connection
@@ -160,8 +157,8 @@ enum tcp_bit_set {
  * LISTEN state is not used.
  *
  * Packets marked as IGNORED (sIG):
- *     if they may be either invalid or valid 
- *     and the receiver may send back a connection 
+ *     if they may be either invalid or valid
+ *     and the receiver may send back a connection
  *     closing RST or a SYN/ACK.
  *
  * Packets marked as INVALID (sIV):
@@ -178,7 +175,7 @@ static const enum tcp_conntrack tcp_conntracks[2][6][TCP_CONNTRACK_MAX] = {
  *     sSS -> sSS      Retransmitted SYN
  *     sSR -> sIG      Late retransmitted SYN?
  *     sES -> sIG      Error: SYNs in window outside the SYN_SENT state
- *                     are errors. Receiver will reply with RST 
+ *                     are errors. Receiver will reply with RST
  *                     and close the connection.
  *                     Or we are not in sync and hold a dead connection.
  *     sFW -> sIG
@@ -191,10 +188,10 @@ static const enum tcp_conntrack tcp_conntracks[2][6][TCP_CONNTRACK_MAX] = {
 /*synack*/ { sIV, sIV, sIV, sIV, sIV, sIV, sIV, sIV, sIV, sIV },
 /*
  * A SYN/ACK from the client is always invalid:
- *     - either it tries to set up a simultaneous open, which is 
+ *     - either it tries to set up a simultaneous open, which is
  *       not supported;
  *     - or the firewall has just been inserted between the two hosts
- *       during the session set-up. The SYN will be retransmitted 
+ *       during the session set-up. The SYN will be retransmitted
  *       by the true client (or it'll time out).
  */
 /*          sNO, sSS, sSR, sES, sFW, sCW, sLA, sTW, sCL, sLI   */
@@ -204,9 +201,9 @@ static const enum tcp_conntrack tcp_conntracks[2][6][TCP_CONNTRACK_MAX] = {
  *     sSS -> sIV      Client migth not send FIN in this state:
  *                     we enforce waiting for a SYN/ACK reply first.
  *     sSR -> sFW      Close started.
- *     sES -> sFW      
+ *     sES -> sFW
  *     sFW -> sLA      FIN seen in both directions, waiting for
- *                     the last ACK. 
+ *                     the last ACK.
  *                     Migth be a retransmitted FIN as well...
  *     sCW -> sLA
  *     sLA -> sLA      Retransmitted FIN. Remain in the same state.
@@ -284,7 +281,7 @@ static const enum tcp_conntrack tcp_conntracks[2][6][TCP_CONNTRACK_MAX] = {
 /*          sNO, sSS, sSR, sES, sFW, sCW, sLA, sTW, sCL, sLI   */
 /*rst*/    { sIV, sCL, sCL, sCL, sCL, sCL, sCL, sCL, sCL, sIV },
 /*none*/   { sIV, sIV, sIV, sIV, sIV, sIV, sIV, sIV, sIV, sIV }
-       }
+       }
 };
 
 static int tcp_pkt_to_tuple(const struct sk_buff *skb,
@@ -340,7 +337,7 @@ static int tcp_to_nfattr(struct sk_buff *skb, struct nfattr *nfa,
                         const struct ip_conntrack *ct)
 {
        struct nfattr *nest_parms;
-       
+
        read_lock_bh(&tcp_lock);
        nest_parms = NFA_NEST(skb, CTA_PROTOINFO_TCP);
        NFA_PUT(skb, CTA_PROTOINFO_TCP_STATE, sizeof(u_int8_t),
@@ -370,7 +367,7 @@ static int nfattr_to_tcp(struct nfattr *cda[], struct ip_conntrack *ct)
        if (!attr)
                return 0;
 
-        nfattr_parse_nested(tb, CTA_PROTOINFO_TCP_MAX, attr);
+       nfattr_parse_nested(tb, CTA_PROTOINFO_TCP_MAX, attr);
 
        if (nfattr_bad_size(tb, CTA_PROTOINFO_TCP_MAX, cta_min_tcp))
                return -EINVAL;
@@ -379,7 +376,7 @@ static int nfattr_to_tcp(struct nfattr *cda[], struct ip_conntrack *ct)
                return -EINVAL;
 
        write_lock_bh(&tcp_lock);
-       ct->proto.tcp.state = 
+       ct->proto.tcp.state =
                *(u_int8_t *)NFA_DATA(tb[CTA_PROTOINFO_TCP_STATE-1]);
        write_unlock_bh(&tcp_lock);
 
@@ -398,30 +395,30 @@ static unsigned int get_conntrack_index(const struct tcphdr *tcph)
 
 /* TCP connection tracking based on 'Real Stateful TCP Packet Filtering
    in IP Filter' by Guido van Rooij.
-   
+
    http://www.nluug.nl/events/sane2000/papers.html
    http://www.iae.nl/users/guido/papers/tcp_filtering.ps.gz
-   
+
    The boundaries and the conditions are changed according to RFC793:
    the packet must intersect the window (i.e. segments may be
    after the right or before the left edge) and thus receivers may ACK
    segments after the right edge of the window.
 
-       td_maxend = max(sack + max(win,1)) seen in reply packets
+       td_maxend = max(sack + max(win,1)) seen in reply packets
        td_maxwin = max(max(win, 1)) + (sack - ack) seen in sent packets
        td_maxwin += seq + len - sender.td_maxend
                        if seq + len > sender.td_maxend
        td_end    = max(seq + len) seen in sent packets
-   
+
    I.   Upper bound for valid data:    seq <= sender.td_maxend
    II.  Lower bound for valid data:    seq + len >= sender.td_end - receiver.td_maxwin
    III.        Upper bound for valid ack:      sack <= receiver.td_end
    IV. Lower bound for valid ack:      ack >= receiver.td_end - MAXACKWINDOW
-       
+
    where sack is the highest right edge of sack block found in the packet.
-       
-   The upper bound limit for a valid ack is not ignored - 
-   we doesn't have to deal with fragments. 
+
+   The upper bound limit for a valid ack is not ignored -
+   we doesn't have to deal with fragments.
 */
 
 static inline __u32 segment_seq_plus_len(__u32 seq,
@@ -432,25 +429,25 @@ static inline __u32 segment_seq_plus_len(__u32 seq,
        return (seq + len - (iph->ihl + tcph->doff)*4
                + (tcph->syn ? 1 : 0) + (tcph->fin ? 1 : 0));
 }
-  
+
 /* Fixme: what about big packets? */
 #define MAXACKWINCONST                 66000
 #define MAXACKWINDOW(sender)                                           \
        ((sender)->td_maxwin > MAXACKWINCONST ? (sender)->td_maxwin     \
                                              : MAXACKWINCONST)
-  
+
 /*
  * Simplified tcp_parse_options routine from tcp_input.c
  */
 static void tcp_options(const struct sk_buff *skb,
                        struct iphdr *iph,
-                       struct tcphdr *tcph, 
+                       struct tcphdr *tcph,
                        struct ip_ct_tcp_state *state)
 {
        unsigned char buff[(15 * 4) - sizeof(struct tcphdr)];
        unsigned char *ptr;
        int length = (tcph->doff*4) - sizeof(struct tcphdr);
-       
+
        if (!length)
                return;
 
@@ -459,13 +456,13 @@ static void tcp_options(const struct sk_buff *skb,
                                 length, buff);
        BUG_ON(ptr == NULL);
 
-       state->td_scale = 
+       state->td_scale =
        state->flags = 0;
-       
+
        while (length > 0) {
                int opcode=*ptr++;
                int opsize;
-               
+
                switch (opcode) {
                case TCPOPT_EOL:
                        return;
@@ -479,13 +476,13 @@ static void tcp_options(const struct sk_buff *skb,
                        if (opsize > length)
                                break;  /* don't parse partial options */
 
-                       if (opcode == TCPOPT_SACK_PERM 
+                       if (opcode == TCPOPT_SACK_PERM
                            && opsize == TCPOLEN_SACK_PERM)
                                state->flags |= IP_CT_TCP_FLAG_SACK_PERM;
                        else if (opcode == TCPOPT_WINDOW
                                 && opsize == TCPOLEN_WINDOW) {
                                state->td_scale = *(u_int8_t *)ptr;
-                               
+
                                if (state->td_scale > 14) {
                                        /* See RFC1323 */
                                        state->td_scale = 14;
@@ -520,16 +517,16 @@ static void tcp_sack(const struct sk_buff *skb,
        /* Fast path for timestamp-only option */
        if (length == TCPOLEN_TSTAMP_ALIGNED*4
            && *(__be32 *)ptr ==
-               __constant_htonl((TCPOPT_NOP << 24)
-                                | (TCPOPT_NOP << 16)
-                                | (TCPOPT_TIMESTAMP << 8)
-                                | TCPOLEN_TIMESTAMP))
+               __constant_htonl((TCPOPT_NOP << 24)
+                                | (TCPOPT_NOP << 16)
+                                | (TCPOPT_TIMESTAMP << 8)
+                                | TCPOLEN_TIMESTAMP))
                return;
-               
+
        while (length > 0) {
                int opcode=*ptr++;
                int opsize, i;
-               
+
                switch (opcode) {
                case TCPOPT_EOL:
                        return;
@@ -543,16 +540,16 @@ static void tcp_sack(const struct sk_buff *skb,
                        if (opsize > length)
                                break;  /* don't parse partial options */
 
-                       if (opcode == TCPOPT_SACK 
-                           && opsize >= (TCPOLEN_SACK_BASE 
-                                         + TCPOLEN_SACK_PERBLOCK)
-                           && !((opsize - TCPOLEN_SACK_BASE) 
-                                % TCPOLEN_SACK_PERBLOCK)) {
-                               for (i = 0;
-                                    i < (opsize - TCPOLEN_SACK_BASE);
-                                    i += TCPOLEN_SACK_PERBLOCK) {
+                       if (opcode == TCPOPT_SACK
+                           && opsize >= (TCPOLEN_SACK_BASE
+                                         + TCPOLEN_SACK_PERBLOCK)
+                           && !((opsize - TCPOLEN_SACK_BASE)
+                                % TCPOLEN_SACK_PERBLOCK)) {
+                               for (i = 0;
+                                    i < (opsize - TCPOLEN_SACK_BASE);
+                                    i += TCPOLEN_SACK_PERBLOCK) {
                                        tmp = ntohl(*((__be32 *)(ptr+i)+1));
-                                       
+
                                        if (after(tmp, *sack))
                                                *sack = tmp;
                                }
@@ -564,18 +561,18 @@ static void tcp_sack(const struct sk_buff *skb,
        }
 }
 
-static int tcp_in_window(struct ip_ct_tcp *state, 
-                         enum ip_conntrack_dir dir,
-                         unsigned int index,
-                         const struct sk_buff *skb,
-                         struct iphdr *iph,
-                         struct tcphdr *tcph)
+static int tcp_in_window(struct ip_ct_tcp *state,
+                        enum ip_conntrack_dir dir,
+                        unsigned int index,
+                        const struct sk_buff *skb,
+                        struct iphdr *iph,
+                        struct tcphdr *tcph)
 {
        struct ip_ct_tcp_state *sender = &state->seen[dir];
        struct ip_ct_tcp_state *receiver = &state->seen[!dir];
        __u32 seq, ack, sack, end, win, swin;
        int res;
-       
+
        /*
         * Get the required data from the packet.
         */
@@ -583,23 +580,23 @@ static int tcp_in_window(struct ip_ct_tcp *state,
        ack = sack = ntohl(tcph->ack_seq);
        win = ntohs(tcph->window);
        end = segment_seq_plus_len(seq, skb->len, iph, tcph);
-       
+
        if (receiver->flags & IP_CT_TCP_FLAG_SACK_PERM)
                tcp_sack(skb, iph, tcph, &sack);
-               
+
        DEBUGP("tcp_in_window: START\n");
        DEBUGP("tcp_in_window: src=%u.%u.%u.%u:%hu dst=%u.%u.%u.%u:%hu "
               "seq=%u ack=%u sack=%u win=%u end=%u\n",
-               NIPQUAD(iph->saddr), ntohs(tcph->source), 
+               NIPQUAD(iph->saddr), ntohs(tcph->source),
                NIPQUAD(iph->daddr), ntohs(tcph->dest),
                seq, ack, sack, win, end);
        DEBUGP("tcp_in_window: sender end=%u maxend=%u maxwin=%u scale=%i "
               "receiver end=%u maxend=%u maxwin=%u scale=%i\n",
                sender->td_end, sender->td_maxend, sender->td_maxwin,
-               sender->td_scale, 
-               receiver->td_end, receiver->td_maxend, receiver->td_maxwin, 
+               sender->td_scale,
+               receiver->td_end, receiver->td_maxend, receiver->td_maxwin,
                receiver->td_scale);
-               
+
        if (sender->td_end == 0) {
                /*
                 * Initialize sender data.
@@ -608,26 +605,26 @@ static int tcp_in_window(struct ip_ct_tcp *state,
                        /*
                         * Outgoing SYN-ACK in reply to a SYN.
                         */
-                       sender->td_end = 
+                       sender->td_end =
                        sender->td_maxend = end;
                        sender->td_maxwin = (win == 0 ? 1 : win);
 
                        tcp_options(skb, iph, tcph, sender);
-                       /* 
+                       /*
                         * RFC 1323:
                         * Both sides must send the Window Scale option
                         * to enable window scaling in either direction.
                         */
                        if (!(sender->flags & IP_CT_TCP_FLAG_WINDOW_SCALE
                              && receiver->flags & IP_CT_TCP_FLAG_WINDOW_SCALE))
-                               sender->td_scale = 
+                               sender->td_scale =
                                receiver->td_scale = 0;
                } else {
                        /*
                         * We are in the middle of a connection,
                         * its history is lost for us.
                         * Let's try to use the data from the packet.
-                        */
+                        */
                        sender->td_end = end;
                        sender->td_maxwin = (win == 0 ? 1 : win);
                        sender->td_maxend = end + sender->td_maxwin;
@@ -635,11 +632,11 @@ static int tcp_in_window(struct ip_ct_tcp *state,
        } else if (((state->state == TCP_CONNTRACK_SYN_SENT
                     && dir == IP_CT_DIR_ORIGINAL)
                    || (state->state == TCP_CONNTRACK_SYN_RECV
-                       && dir == IP_CT_DIR_REPLY))
+                       && dir == IP_CT_DIR_REPLY))
                    && after(end, sender->td_end)) {
                /*
                 * RFC 793: "if a TCP is reinitialized ... then it need
-                * not wait at all; it must only be sure to use sequence 
+                * not wait at all; it must only be sure to use sequence
                 * numbers larger than those recently used."
                 */
                sender->td_end =
@@ -648,14 +645,14 @@ static int tcp_in_window(struct ip_ct_tcp *state,
 
                tcp_options(skb, iph, tcph, sender);
        }
-       
+
        if (!(tcph->ack)) {
                /*
                 * If there is no ACK, just pretend it was set and OK.
                 */
                ack = sack = receiver->td_end;
-       } else if (((tcp_flag_word(tcph) & (TCP_FLAG_ACK|TCP_FLAG_RST)) == 
-                   (TCP_FLAG_ACK|TCP_FLAG_RST)) 
+       } else if (((tcp_flag_word(tcph) & (TCP_FLAG_ACK|TCP_FLAG_RST)) ==
+                   (TCP_FLAG_ACK|TCP_FLAG_RST))
                   && (ack == 0)) {
                /*
                 * Broken TCP stacks, that set ACK in RST packets as well
@@ -665,8 +662,8 @@ static int tcp_in_window(struct ip_ct_tcp *state,
        }
 
        if (seq == end
-           && (!tcph->rst 
-               || (seq == 0 && state->state == TCP_CONNTRACK_SYN_SENT)))
+           && (!tcph->rst
+               || (seq == 0 && state->state == TCP_CONNTRACK_SYN_SENT)))
                /*
                 * Packets contains no data: we assume it is valid
                 * and check the ack value only.
@@ -675,7 +672,7 @@ static int tcp_in_window(struct ip_ct_tcp *state,
                 * SYN.
                 */
                seq = end = sender->td_end;
-               
+
        DEBUGP("tcp_in_window: src=%u.%u.%u.%u:%hu dst=%u.%u.%u.%u:%hu "
               "seq=%u ack=%u sack =%u win=%u end=%u\n",
                NIPQUAD(iph->saddr), ntohs(tcph->source),
@@ -684,27 +681,26 @@ static int tcp_in_window(struct ip_ct_tcp *state,
        DEBUGP("tcp_in_window: sender end=%u maxend=%u maxwin=%u scale=%i "
               "receiver end=%u maxend=%u maxwin=%u scale=%i\n",
                sender->td_end, sender->td_maxend, sender->td_maxwin,
-               sender->td_scale, 
+               sender->td_scale,
                receiver->td_end, receiver->td_maxend, receiver->td_maxwin,
                receiver->td_scale);
-       
+
        DEBUGP("tcp_in_window: I=%i II=%i III=%i IV=%i\n",
                before(seq, sender->td_maxend + 1),
-               after(end, sender->td_end - receiver->td_maxwin - 1),
-               before(sack, receiver->td_end + 1),
-               after(ack, receiver->td_end - MAXACKWINDOW(sender)));
-       
-       if (sender->loose || receiver->loose ||
-           (before(seq, sender->td_maxend + 1) &&
-            after(end, sender->td_end - receiver->td_maxwin - 1) &&
-            before(sack, receiver->td_end + 1) &&
-            after(ack, receiver->td_end - MAXACKWINDOW(sender)))) {
-               /*
+               after(end, sender->td_end - receiver->td_maxwin - 1),
+               before(sack, receiver->td_end + 1),
+               after(ack, receiver->td_end - MAXACKWINDOW(sender)));
+
+       if (before(seq, sender->td_maxend + 1) &&
+           after(end, sender->td_end - receiver->td_maxwin - 1) &&
+           before(sack, receiver->td_end + 1) &&
+           after(ack, receiver->td_end - MAXACKWINDOW(sender))) {
+               /*
                 * Take into account window scaling (RFC 1323).
                 */
                if (!tcph->syn)
                        win <<= sender->td_scale;
-               
+
                /*
                 * Update sender data.
                 */
@@ -724,7 +720,7 @@ static int tcp_in_window(struct ip_ct_tcp *state,
                                receiver->td_maxend++;
                }
 
-               /* 
+               /*
                 * Check retransmissions.
                 */
                if (index == TCP_ACK_SET) {
@@ -743,15 +739,13 @@ static int tcp_in_window(struct ip_ct_tcp *state,
                                state->retrans = 0;
                        }
                }
-               /*
-                * Close the window of disabled window tracking :-)
-                */
-               if (sender->loose)
-                       sender->loose--;
-               
                res = 1;
        } else {
-               if (LOG_INVALID(IPPROTO_TCP))
+               res = 0;
+               if (sender->flags & IP_CT_TCP_FLAG_BE_LIBERAL ||
+                   ip_ct_tcp_be_liberal)
+                       res = 1;
+               if (!res && LOG_INVALID(IPPROTO_TCP))
                        nf_log_packet(PF_INET, 0, skb, NULL, NULL, NULL,
                        "ip_ct_tcp: %s ",
                        before(seq, sender->td_maxend + 1) ?
@@ -762,13 +756,11 @@ static int tcp_in_window(struct ip_ct_tcp *state,
                        : "ACK is over the upper bound (ACKed data not seen yet)"
                        : "SEQ is under the lower bound (already ACKed data retransmitted)"
                        : "SEQ is over the upper bound (over the window of the receiver)");
+       }
 
-               res = ip_ct_tcp_be_liberal;
-       }
-  
        DEBUGP("tcp_in_window: res=%i sender end=%u maxend=%u maxwin=%u "
               "receiver end=%u maxend=%u maxwin=%u\n",
-               res, sender->td_end, sender->td_maxend, sender->td_maxwin, 
+               res, sender->td_end, sender->td_maxend, sender->td_maxwin,
                receiver->td_end, receiver->td_maxend, receiver->td_maxwin);
 
        return res;
@@ -777,7 +769,7 @@ static int tcp_in_window(struct ip_ct_tcp *state,
 #ifdef CONFIG_IP_NF_NAT_NEEDED
 /* Update sender->td_end after NAT successfully mangled the packet */
 void ip_conntrack_tcp_update(struct sk_buff *skb,
-                            struct ip_conntrack *conntrack, 
+                            struct ip_conntrack *conntrack,
                             enum ip_conntrack_dir dir)
 {
        struct iphdr *iph = skb->nh.iph;
@@ -789,7 +781,7 @@ void ip_conntrack_tcp_update(struct sk_buff *skb,
 #endif
 
        end = segment_seq_plus_len(ntohl(tcph->seq), skb->len, iph, tcph);
-       
+
        write_lock_bh(&tcp_lock);
        /*
         * We have to worry for the ack in the reply packet only...
@@ -801,11 +793,11 @@ void ip_conntrack_tcp_update(struct sk_buff *skb,
        DEBUGP("tcp_update: sender end=%u maxend=%u maxwin=%u scale=%i "
               "receiver end=%u maxend=%u maxwin=%u scale=%i\n",
                sender->td_end, sender->td_maxend, sender->td_maxwin,
-               sender->td_scale, 
+               sender->td_scale,
                receiver->td_end, receiver->td_maxend, receiver->td_maxwin,
                receiver->td_scale);
 }
+
 #endif
 
 #define        TH_FIN  0x01
@@ -855,8 +847,8 @@ static int tcp_error(struct sk_buff *skb,
                        nf_log_packet(PF_INET, 0, skb, NULL, NULL, NULL,
                                "ip_ct_tcp: short packet ");
                return -NF_ACCEPT;
-       }
-  
+       }
+
        /* Not whole TCP header or malformed packet */
        if (th->doff*4 < sizeof(struct tcphdr) || tcplen < th->doff*4) {
                if (LOG_INVALID(IPPROTO_TCP))
@@ -864,7 +856,7 @@ static int tcp_error(struct sk_buff *skb,
                                "ip_ct_tcp: truncated/malformed packet ");
                return -NF_ACCEPT;
        }
-  
+
        /* Checksum invalid? Ignore.
         * We skip checking packets on the outgoing path
         * because it is assumed to be correct.
@@ -901,11 +893,11 @@ static int tcp_packet(struct ip_conntrack *conntrack,
        struct tcphdr *th, _tcph;
        unsigned long timeout;
        unsigned int index;
-       
+
        th = skb_header_pointer(skb, iph->ihl * 4,
                                sizeof(_tcph), &_tcph);
        BUG_ON(th == NULL);
-       
+
        write_lock_bh(&tcp_lock);
        old_state = conntrack->proto.tcp.state;
        dir = CTINFO2DIR(ctinfo);
@@ -915,7 +907,7 @@ static int tcp_packet(struct ip_conntrack *conntrack,
        switch (new_state) {
        case TCP_CONNTRACK_IGNORE:
                /* Ignored packets:
-                * 
+                *
                 * a) SYN in ORIGINAL
                 * b) SYN/ACK in REPLY
                 * c) ACK in reply direction after initial SYN in original.
@@ -924,30 +916,30 @@ static int tcp_packet(struct ip_conntrack *conntrack,
                    && conntrack->proto.tcp.last_index == TCP_SYN_SET
                    && conntrack->proto.tcp.last_dir != dir
                    && ntohl(th->ack_seq) ==
-                            conntrack->proto.tcp.last_end) {
-                       /* This SYN/ACK acknowledges a SYN that we earlier 
+                            conntrack->proto.tcp.last_end) {
+                       /* This SYN/ACK acknowledges a SYN that we earlier
                         * ignored as invalid. This means that the client and
                         * the server are both in sync, while the firewall is
                         * not. We kill this session and block the SYN/ACK so
-                        * that the client cannot but retransmit its SYN and 
+                        * that the client cannot but retransmit its SYN and
                         * thus initiate a clean new session.
                         */
-                       write_unlock_bh(&tcp_lock);
+                       write_unlock_bh(&tcp_lock);
                        if (LOG_INVALID(IPPROTO_TCP))
                                nf_log_packet(PF_INET, 0, skb, NULL, NULL,
                                              NULL, "ip_ct_tcp: "
                                              "killing out of sync session ");
-                       if (del_timer(&conntrack->timeout))
-                               conntrack->timeout.function((unsigned long)
-                                                           conntrack);
-                       return -NF_DROP;
+                       if (del_timer(&conntrack->timeout))
+                               conntrack->timeout.function((unsigned long)
+                                                           conntrack);
+                       return -NF_DROP;
                }
                conntrack->proto.tcp.last_index = index;
                conntrack->proto.tcp.last_dir = dir;
                conntrack->proto.tcp.last_seq = ntohl(th->seq);
-               conntrack->proto.tcp.last_end = 
+               conntrack->proto.tcp.last_end =
                    segment_seq_plus_len(ntohl(th->seq), skb->len, iph, th);
-               
+
                write_unlock_bh(&tcp_lock);
                if (LOG_INVALID(IPPROTO_TCP))
                        nf_log_packet(PF_INET, 0, skb, NULL, NULL, NULL,
@@ -967,16 +959,16 @@ static int tcp_packet(struct ip_conntrack *conntrack,
                if (old_state < TCP_CONNTRACK_TIME_WAIT)
                        break;
                if ((conntrack->proto.tcp.seen[dir].flags &
-                        IP_CT_TCP_FLAG_CLOSE_INIT)
+                        IP_CT_TCP_FLAG_CLOSE_INIT)
                    || after(ntohl(th->seq),
-                            conntrack->proto.tcp.seen[dir].td_end)) {  
-                       /* Attempt to reopen a closed connection.
-                       * Delete this connection and look up again. */
-                       write_unlock_bh(&tcp_lock);
-                       if (del_timer(&conntrack->timeout))
-                               conntrack->timeout.function((unsigned long)
-                                                           conntrack);
-                       return -NF_REPEAT;
+                            conntrack->proto.tcp.seen[dir].td_end)) {
+                       /* Attempt to reopen a closed connection.
+                       * Delete this connection and look up again. */
+                       write_unlock_bh(&tcp_lock);
+                       if (del_timer(&conntrack->timeout))
+                               conntrack->timeout.function((unsigned long)
+                                                           conntrack);
+                       return -NF_REPEAT;
                } else {
                        write_unlock_bh(&tcp_lock);
                        if (LOG_INVALID(IPPROTO_TCP))
@@ -987,9 +979,9 @@ static int tcp_packet(struct ip_conntrack *conntrack,
        case TCP_CONNTRACK_CLOSE:
                if (index == TCP_RST_SET
                    && ((test_bit(IPS_SEEN_REPLY_BIT, &conntrack->status)
-                        && conntrack->proto.tcp.last_index == TCP_SYN_SET)
-                       || (!test_bit(IPS_ASSURED_BIT, &conntrack->status)
-                           && conntrack->proto.tcp.last_index == TCP_ACK_SET))
+                        && conntrack->proto.tcp.last_index == TCP_SYN_SET)
+                       || (!test_bit(IPS_ASSURED_BIT, &conntrack->status)
+                           && conntrack->proto.tcp.last_index == TCP_ACK_SET))
                    && ntohl(th->ack_seq) == conntrack->proto.tcp.last_end) {
                        /* RST sent to invalid SYN or ACK we had let through
                         * at a) and c) above:
@@ -1008,13 +1000,13 @@ static int tcp_packet(struct ip_conntrack *conntrack,
                break;
        }
 
-       if (!tcp_in_window(&conntrack->proto.tcp, dir, index, 
+       if (!tcp_in_window(&conntrack->proto.tcp, dir, index,
                           skb, iph, th)) {
                write_unlock_bh(&tcp_lock);
                return -NF_ACCEPT;
        }
     in_window:
-       /* From now on we have got in-window packets */ 
+       /* From now on we have got in-window packets */
        conntrack->proto.tcp.last_index = index;
 
        DEBUGP("tcp_conntracks: src=%u.%u.%u.%u:%hu dst=%u.%u.%u.%u:%hu "
@@ -1026,9 +1018,9 @@ static int tcp_packet(struct ip_conntrack *conntrack,
                old_state, new_state);
 
        conntrack->proto.tcp.state = new_state;
-       if (old_state != new_state 
+       if (old_state != new_state
            && (new_state == TCP_CONNTRACK_FIN_WAIT
-               || new_state == TCP_CONNTRACK_CLOSE))
+               || new_state == TCP_CONNTRACK_CLOSE))
                conntrack->proto.tcp.seen[dir].flags |= IP_CT_TCP_FLAG_CLOSE_INIT;
        timeout = conntrack->proto.tcp.retrans >= ip_ct_tcp_max_retrans
                  && *tcp_timeouts[new_state] > ip_ct_tcp_timeout_max_retrans
@@ -1054,8 +1046,8 @@ static int tcp_packet(struct ip_conntrack *conntrack,
                   && (old_state == TCP_CONNTRACK_SYN_RECV
                       || old_state == TCP_CONNTRACK_ESTABLISHED)
                   && new_state == TCP_CONNTRACK_ESTABLISHED) {
-               /* Set ASSURED if we see see valid ack in ESTABLISHED 
-                  after SYN_RECV or a valid answer for a picked up 
+               /* Set ASSURED if we see see valid ack in ESTABLISHED
+                  after SYN_RECV or a valid answer for a picked up
                   connection. */
                set_bit(IPS_ASSURED_BIT, &conntrack->status);
                ip_conntrack_event_cache(IPCT_STATUS, skb);
@@ -1064,7 +1056,7 @@ static int tcp_packet(struct ip_conntrack *conntrack,
 
        return NF_ACCEPT;
 }
+
 /* Called when a new connection for this protocol found. */
 static int tcp_new(struct ip_conntrack *conntrack,
                   const struct sk_buff *skb)
@@ -1080,7 +1072,7 @@ static int tcp_new(struct ip_conntrack *conntrack,
        th = skb_header_pointer(skb, iph->ihl * 4,
                                sizeof(_tcph), &_tcph);
        BUG_ON(th == NULL);
-       
+
        /* Don't need lock here: this conntrack not in circulation yet */
        new_state
                = tcp_conntracks[0][get_conntrack_index(th)]
@@ -1105,8 +1097,6 @@ static int tcp_new(struct ip_conntrack *conntrack,
 
                tcp_options(skb, iph, th, &conntrack->proto.tcp.seen[0]);
                conntrack->proto.tcp.seen[1].flags = 0;
-               conntrack->proto.tcp.seen[0].loose = 
-               conntrack->proto.tcp.seen[1].loose = 0;
        } else if (ip_ct_tcp_loose == 0) {
                /* Don't try to pick up connections. */
                return 0;
@@ -1123,35 +1113,35 @@ static int tcp_new(struct ip_conntrack *conntrack,
                if (conntrack->proto.tcp.seen[0].td_maxwin == 0)
                        conntrack->proto.tcp.seen[0].td_maxwin = 1;
                conntrack->proto.tcp.seen[0].td_maxend =
-                       conntrack->proto.tcp.seen[0].td_end + 
+                       conntrack->proto.tcp.seen[0].td_end +
                        conntrack->proto.tcp.seen[0].td_maxwin;
                conntrack->proto.tcp.seen[0].td_scale = 0;
 
-               /* We assume SACK. Should we assume window scaling too? */
+               /* We assume SACK and liberal window checking to handle
+                * window scaling */
                conntrack->proto.tcp.seen[0].flags =
-               conntrack->proto.tcp.seen[1].flags = IP_CT_TCP_FLAG_SACK_PERM;
-               conntrack->proto.tcp.seen[0].loose = 
-               conntrack->proto.tcp.seen[1].loose = ip_ct_tcp_loose;
+               conntrack->proto.tcp.seen[1].flags = IP_CT_TCP_FLAG_SACK_PERM |
+                                                    IP_CT_TCP_FLAG_BE_LIBERAL;
        }
-    
+
        conntrack->proto.tcp.seen[1].td_end = 0;
        conntrack->proto.tcp.seen[1].td_maxend = 0;
        conntrack->proto.tcp.seen[1].td_maxwin = 1;
-       conntrack->proto.tcp.seen[1].td_scale = 0;      
+       conntrack->proto.tcp.seen[1].td_scale = 0;
 
        /* tcp_packet will set them */
        conntrack->proto.tcp.state = TCP_CONNTRACK_NONE;
        conntrack->proto.tcp.last_index = TCP_NONE_SET;
-        
+
        DEBUGP("tcp_new: sender end=%u maxend=%u maxwin=%u scale=%i "
               "receiver end=%u maxend=%u maxwin=%u scale=%i\n",
                sender->td_end, sender->td_maxend, sender->td_maxwin,
-               sender->td_scale, 
+               sender->td_scale,
                receiver->td_end, receiver->td_maxend, receiver->td_maxwin,
                receiver->td_scale);
        return 1;
 }
-  
+
 struct ip_conntrack_protocol ip_conntrack_protocol_tcp =
 {
        .proto                  = IPPROTO_TCP,
index d0e8a16970ec3533088497c17e14d0fedbd3f829..a99a7c75e5b5cd58745e5a68040503ce248bbc50 100644 (file)
@@ -70,7 +70,7 @@ static int udp_packet(struct ip_conntrack *conntrack,
        /* If we've seen traffic both ways, this is some kind of UDP
           stream.  Extend timeout. */
        if (test_bit(IPS_SEEN_REPLY_BIT, &conntrack->status)) {
-               ip_ct_refresh_acct(conntrack, ctinfo, skb, 
+               ip_ct_refresh_acct(conntrack, ctinfo, skb,
                                   ip_ct_udp_timeout_stream);
                /* Also, more likely to be important, and not a probe */
                if (!test_and_set_bit(IPS_ASSURED_BIT, &conntrack->status))
@@ -102,7 +102,7 @@ static int udp_error(struct sk_buff *skb, enum ip_conntrack_info *ctinfo,
                                  "ip_ct_udp: short packet ");
                return -NF_ACCEPT;
        }
-       
+
        /* Truncated/malformed packets */
        if (ntohs(hdr->len) > udplen || ntohs(hdr->len) < sizeof(*hdr)) {
                if (LOG_INVALID(IPPROTO_UDP))
@@ -110,7 +110,7 @@ static int udp_error(struct sk_buff *skb, enum ip_conntrack_info *ctinfo,
                                  "ip_ct_udp: truncated/malformed packet ");
                return -NF_ACCEPT;
        }
-       
+
        /* Packet with no checksum */
        if (!hdr->check)
                return NF_ACCEPT;
@@ -126,7 +126,7 @@ static int udp_error(struct sk_buff *skb, enum ip_conntrack_info *ctinfo,
                                  "ip_ct_udp: bad UDP checksum ");
                return -NF_ACCEPT;
        }
-       
+
        return NF_ACCEPT;
 }
 
index 11c588a10e6b5e7adf993f59a3ae5a8a6dd2cfd3..c59a962c1f61c2c415b2e6ff7b12de755fa72864 100644 (file)
@@ -321,7 +321,7 @@ int ct_sip_get_info(const char *dptr, size_t dlen,
                        continue;
                }
                aux = ct_sip_search(hnfo->ln_str, dptr, hnfo->ln_strlen,
-                                   ct_sip_lnlen(dptr, limit),
+                                   ct_sip_lnlen(dptr, limit),
                                    hnfo->case_sensitive);
                if (!aux) {
                        DEBUGP("'%s' not found in '%s'.\n", hnfo->ln_str,
@@ -406,7 +406,7 @@ static int sip_help(struct sk_buff **pskb,
        if (dataoff >= (*pskb)->len) {
                DEBUGP("skb->len = %u\n", (*pskb)->len);
                return NF_ACCEPT;
-        }
+       }
 
        ip_ct_refresh(ct, *pskb, sip_timeout * HZ);
 
@@ -439,16 +439,16 @@ static int sip_help(struct sk_buff **pskb,
        }
        /* Get ip and port address from SDP packet. */
        if (ct_sip_get_info(dptr, datalen, &matchoff, &matchlen,
-                           POS_CONNECTION) > 0) {
+                           POS_CONNECTION) > 0) {
 
                /* We'll drop only if there are parse problems. */
                if (parse_ipaddr(dptr + matchoff, NULL, &ipaddr,
-                                dptr + datalen) < 0) {
+                                dptr + datalen) < 0) {
                        ret = NF_DROP;
                        goto out;
                }
                if (ct_sip_get_info(dptr, datalen, &matchoff, &matchlen,
-                                   POS_MEDIA) > 0) {
+                                   POS_MEDIA) > 0) {
 
                        port = simple_strtoul(dptr + matchoff, NULL, 10);
                        if (port < 1024) {
index 86efb5449676b959a97909d64ed0d8645323f81c..5903588fddceec2090954b2fc5cdbcf1f424f38d 100644 (file)
@@ -46,7 +46,7 @@ DECLARE_PER_CPU(struct ip_conntrack_stat, ip_conntrack_stat);
 
 static int kill_proto(struct ip_conntrack *i, void *data)
 {
-       return (i->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum == 
+       return (i->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum ==
                        *((u_int8_t *) data));
 }
 
@@ -124,12 +124,12 @@ static void *ct_seq_next(struct seq_file *s, void *v, loff_t *pos)
        (*pos)++;
        return ct_get_next(s, v);
 }
-  
+
 static void ct_seq_stop(struct seq_file *s, void *v)
 {
        read_unlock_bh(&ip_conntrack_lock);
 }
+
 static int ct_seq_show(struct seq_file *s, void *v)
 {
        const struct ip_conntrack_tuple_hash *hash = v;
@@ -155,12 +155,12 @@ static int ct_seq_show(struct seq_file *s, void *v)
 
        if (proto->print_conntrack(s, conntrack))
                return -ENOSPC;
-  
+
        if (print_tuple(s, &conntrack->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
                        proto))
                return -ENOSPC;
 
-       if (seq_print_counters(s, &conntrack->counters[IP_CT_DIR_ORIGINAL]))
+       if (seq_print_counters(s, &conntrack->counters[IP_CT_DIR_ORIGINAL]))
                return -ENOSPC;
 
        if (!(test_bit(IPS_SEEN_REPLY_BIT, &conntrack->status)))
@@ -171,7 +171,7 @@ static int ct_seq_show(struct seq_file *s, void *v)
                        proto))
                return -ENOSPC;
 
-       if (seq_print_counters(s, &conntrack->counters[IP_CT_DIR_REPLY]))
+       if (seq_print_counters(s, &conntrack->counters[IP_CT_DIR_REPLY]))
                return -ENOSPC;
 
        if (test_bit(IPS_ASSURED_BIT, &conntrack->status))
@@ -200,7 +200,7 @@ static struct seq_operations ct_seq_ops = {
        .stop  = ct_seq_stop,
        .show  = ct_seq_show
 };
-  
+
 static int ct_open(struct inode *inode, struct file *file)
 {
        struct seq_file *seq;
@@ -229,7 +229,7 @@ static struct file_operations ct_file_ops = {
        .llseek  = seq_lseek,
        .release = seq_release_private,
 };
-  
+
 /* expects */
 static void *exp_seq_start(struct seq_file *s, loff_t *pos)
 {
@@ -253,7 +253,7 @@ static void *exp_seq_start(struct seq_file *s, loff_t *pos)
 
 static void *exp_seq_next(struct seq_file *s, void *v, loff_t *pos)
 {
-       struct list_head *e = v;
+       struct list_head *e = v;
 
        ++*pos;
        e = e->next;
@@ -297,7 +297,7 @@ static int exp_open(struct inode *inode, struct file *file)
 {
        return seq_open(file, &exp_seq_ops);
 }
-  
+
 static struct file_operations exp_file_ops = {
        .owner   = THIS_MODULE,
        .open    = exp_open,
@@ -426,14 +426,14 @@ static unsigned int ip_conntrack_help(unsigned int hooknum,
 }
 
 static unsigned int ip_conntrack_defrag(unsigned int hooknum,
-                                       struct sk_buff **pskb,
-                                       const struct net_device *in,
-                                       const struct net_device *out,
-                                       int (*okfn)(struct sk_buff *))
+                                       struct sk_buff **pskb,
+                                       const struct net_device *in,
+                                       const struct net_device *out,
+                                       int (*okfn)(struct sk_buff *))
 {
 #if !defined(CONFIG_IP_NF_NAT) && !defined(CONFIG_IP_NF_NAT_MODULE)
        /* Previously seen (loopback)?  Ignore.  Do this before
-           fragment check. */
+          fragment check. */
        if ((*pskb)->nfct)
                return NF_ACCEPT;
 #endif
@@ -441,7 +441,7 @@ static unsigned int ip_conntrack_defrag(unsigned int hooknum,
        /* Gather fragments. */
        if ((*pskb)->nh.iph->frag_off & htons(IP_MF|IP_OFFSET)) {
                *pskb = ip_ct_gather_frags(*pskb,
-                                          hooknum == NF_IP_PRE_ROUTING ? 
+                                          hooknum == NF_IP_PRE_ROUTING ?
                                           IP_DEFRAG_CONNTRACK_IN :
                                           IP_DEFRAG_CONNTRACK_OUT);
                if (!*pskb)
@@ -776,7 +776,7 @@ static ctl_table ip_ct_net_table[] = {
        {
                .ctl_name       = CTL_NET,
                .procname       = "net",
-               .mode           = 0555, 
+               .mode           = 0555,
                .child          = ip_ct_ipv4_table,
        },
        { .ctl_name = 0 }
index ef56de2eff0c71edc8dd8f29c1d2e431dc041f32..76e175e7a9729ade19b7bef5d1dcff2de6ce4cf8 100644 (file)
@@ -33,7 +33,7 @@ MODULE_PARM_DESC(ports, "port numbers of tftp servers");
 
 #if 0
 #define DEBUGP(format, args...) printk("%s:%s:" format, \
-                                       __FILE__, __FUNCTION__ , ## args)
+                                      __FILE__, __FUNCTION__ , ## args)
 #else
 #define DEBUGP(format, args...)
 #endif
@@ -113,7 +113,7 @@ static void ip_conntrack_tftp_fini(void)
                DEBUGP("unregistering helper for port %d\n",
                        ports[i]);
                ip_conntrack_helper_unregister(&tftp[i]);
-       } 
+       }
 }
 
 static int __init ip_conntrack_tftp_init(void)
index 9d1a5175dcd40bb0bd7b6e4fcdd8d914c08fc56e..275a4d3faf0af65d0da5ed7470d71d137dba30f5 100644 (file)
@@ -120,7 +120,7 @@ static int
 in_range(const struct ip_conntrack_tuple *tuple,
         const struct ip_nat_range *range)
 {
-       struct ip_nat_protocol *proto = 
+       struct ip_nat_protocol *proto =
                                __ip_nat_proto_find(tuple->dst.protonum);
 
        /* If we are supposed to map IPs, then we must be in the
@@ -246,8 +246,9 @@ get_unique_tuple(struct ip_conntrack_tuple *tuple,
        if (maniptype == IP_NAT_MANIP_SRC) {
                if (find_appropriate_src(orig_tuple, tuple, range)) {
                        DEBUGP("get_unique_tuple: Found current src map\n");
-                       if (!ip_nat_used_tuple(tuple, conntrack))
-                               return;
+                       if (!(range->flags & IP_NAT_RANGE_PROTO_RANDOM))
+                               if (!ip_nat_used_tuple(tuple, conntrack))
+                                       return;
                }
        }
 
@@ -261,6 +262,13 @@ get_unique_tuple(struct ip_conntrack_tuple *tuple,
 
        proto = ip_nat_proto_find_get(orig_tuple->dst.protonum);
 
+       /* Change protocol info to have some randomization */
+       if (range->flags & IP_NAT_RANGE_PROTO_RANDOM) {
+               proto->unique_tuple(tuple, range, maniptype, conntrack);
+               ip_nat_proto_put(proto);
+               return;
+       }
+
        /* Only bother mapping if it's not already in range and unique */
        if ((!(range->flags & IP_NAT_RANGE_PROTO_SPECIFIED)
             || proto->in_range(tuple, maniptype, &range->min, &range->max))
@@ -435,8 +443,8 @@ int ip_nat_icmp_reply_translation(struct ip_conntrack *ct,
                     (*pskb)->nfctinfo == IP_CT_RELATED+IP_CT_IS_REPLY);
 
        /* Redirects on non-null nats must be dropped, else they'll
-           start talking to each other without our translation, and be
-           confused... --RR */
+          start talking to each other without our translation, and be
+          confused... --RR */
        if (inside->icmp.type == ICMP_REDIRECT) {
                /* If NAT isn't finished, assume it and drop. */
                if ((ct->status & IPS_NAT_DONE_MASK) != IPS_NAT_DONE_MASK)
@@ -450,8 +458,8 @@ int ip_nat_icmp_reply_translation(struct ip_conntrack *ct,
               *pskb, manip, dir == IP_CT_DIR_ORIGINAL ? "ORIG" : "REPLY");
 
        if (!ip_ct_get_tuple(&inside->ip, *pskb, (*pskb)->nh.iph->ihl*4 +
-                            sizeof(struct icmphdr) + inside->ip.ihl*4,
-                            &inner,
+                            sizeof(struct icmphdr) + inside->ip.ihl*4,
+                            &inner,
                             __ip_conntrack_proto_find(inside->ip.protocol)))
                return 0;
 
@@ -529,7 +537,7 @@ EXPORT_SYMBOL(ip_nat_protocol_unregister);
 #if defined(CONFIG_IP_NF_CONNTRACK_NETLINK) || \
     defined(CONFIG_IP_NF_CONNTRACK_NETLINK_MODULE)
 int
-ip_nat_port_range_to_nfattr(struct sk_buff *skb, 
+ip_nat_port_range_to_nfattr(struct sk_buff *skb,
                            const struct ip_nat_range *range)
 {
        NFA_PUT(skb, CTA_PROTONAT_PORT_MIN, sizeof(__be16),
@@ -547,21 +555,21 @@ int
 ip_nat_port_nfattr_to_range(struct nfattr *tb[], struct ip_nat_range *range)
 {
        int ret = 0;
-       
+
        /* we have to return whether we actually parsed something or not */
 
        if (tb[CTA_PROTONAT_PORT_MIN-1]) {
                ret = 1;
-               range->min.tcp.port = 
+               range->min.tcp.port =
                        *(__be16 *)NFA_DATA(tb[CTA_PROTONAT_PORT_MIN-1]);
        }
-       
+
        if (!tb[CTA_PROTONAT_PORT_MAX-1]) {
-               if (ret) 
+               if (ret)
                        range->max.tcp.port = range->min.tcp.port;
        } else {
                ret = 1;
-               range->max.tcp.port = 
+               range->max.tcp.port =
                        *(__be16 *)NFA_DATA(tb[CTA_PROTONAT_PORT_MAX-1]);
        }
 
index 913960e1380ffd6cf3538006e7cf933bf6260157..32e01d8dffcb08fc2a7882d74cd72e0f79cf24ab 100644 (file)
@@ -50,7 +50,7 @@ mangle_rfc959_packet(struct sk_buff **pskb,
        DEBUGP("calling ip_nat_mangle_tcp_packet\n");
 
        *seq += strlen(buffer) - matchlen;
-       return ip_nat_mangle_tcp_packet(pskb, ct, ctinfo, matchoff, 
+       return ip_nat_mangle_tcp_packet(pskb, ct, ctinfo, matchoff,
                                        matchlen, buffer, strlen(buffer));
 }
 
@@ -72,7 +72,7 @@ mangle_eprt_packet(struct sk_buff **pskb,
        DEBUGP("calling ip_nat_mangle_tcp_packet\n");
 
        *seq += strlen(buffer) - matchlen;
-       return ip_nat_mangle_tcp_packet(pskb, ct, ctinfo, matchoff, 
+       return ip_nat_mangle_tcp_packet(pskb, ct, ctinfo, matchoff,
                                        matchlen, buffer, strlen(buffer));
 }
 
@@ -94,7 +94,7 @@ mangle_epsv_packet(struct sk_buff **pskb,
        DEBUGP("calling ip_nat_mangle_tcp_packet\n");
 
        *seq += strlen(buffer) - matchlen;
-       return ip_nat_mangle_tcp_packet(pskb, ct, ctinfo, matchoff, 
+       return ip_nat_mangle_tcp_packet(pskb, ct, ctinfo, matchoff,
                                        matchlen, buffer, strlen(buffer));
 }
 
index ee80feb4b2a986a5fa5526834a50f458f5d23459..dc778cfef58b43b37ac523f0257ad593c6b09dae 100644 (file)
@@ -1,4 +1,4 @@
-/* ip_nat_helper.c - generic support functions for NAT helpers 
+/* ip_nat_helper.c - generic support functions for NAT helpers
  *
  * (C) 2000-2002 Harald Welte <laforge@netfilter.org>
  * (C) 2003-2004 Netfilter Core Team <coreteam@netfilter.org>
@@ -8,7 +8,7 @@
  * published by the Free Software Foundation.
  *
  *     14 Jan 2002 Harald Welte <laforge@gnumonks.org>:
- *             - add support for SACK adjustment 
+ *             - add support for SACK adjustment
  *     14 Mar 2002 Harald Welte <laforge@gnumonks.org>:
  *             - merge SACK support into newnat API
  *     16 Aug 2002 Brian J. Murrell <netfilter@interlinx.bc.ca>:
 static DEFINE_SPINLOCK(ip_nat_seqofs_lock);
 
 /* Setup TCP sequence correction given this change at this sequence */
-static inline void 
+static inline void
 adjust_tcp_sequence(u32 seq,
                    int sizediff,
-                   struct ip_conntrack *ct, 
+                   struct ip_conntrack *ct,
                    enum ip_conntrack_info ctinfo)
 {
        int dir;
@@ -150,7 +150,7 @@ static int enlarge_skb(struct sk_buff **pskb, unsigned int extra)
  * skb enlargement, ...
  *
  * */
-int 
+int
 ip_nat_mangle_tcp_packet(struct sk_buff **pskb,
                         struct ip_conntrack *ct,
                         enum ip_conntrack_info ctinfo,
@@ -183,10 +183,10 @@ ip_nat_mangle_tcp_packet(struct sk_buff **pskb,
        datalen = (*pskb)->len - iph->ihl*4;
        if ((*pskb)->ip_summed != CHECKSUM_PARTIAL) {
                tcph->check = 0;
-               tcph->check = tcp_v4_check(tcph, datalen,
+               tcph->check = tcp_v4_check(datalen,
                                           iph->saddr, iph->daddr,
                                           csum_partial((char *)tcph,
-                                                       datalen, 0));
+                                                       datalen, 0));
        } else
                nf_proto_csum_replace2(&tcph->check, *pskb,
                                        htons(oldlen), htons(datalen), 1);
@@ -202,7 +202,7 @@ ip_nat_mangle_tcp_packet(struct sk_buff **pskb,
        return 1;
 }
 EXPORT_SYMBOL(ip_nat_mangle_tcp_packet);
-                       
+
 /* Generic function for mangling variable-length address changes inside
  * NATed UDP connections (like the CONNECT DATA XXXXX MESG XXXXX INDEX XXXXX
  * command in the Amanda protocol)
@@ -213,7 +213,7 @@ EXPORT_SYMBOL(ip_nat_mangle_tcp_packet);
  * XXX - This function could be merged with ip_nat_mangle_tcp_packet which
  *       should be fairly easy to do.
  */
-int 
+int
 ip_nat_mangle_udp_packet(struct sk_buff **pskb,
                         struct ip_conntrack *ct,
                         enum ip_conntrack_info ctinfo,
@@ -228,8 +228,8 @@ ip_nat_mangle_udp_packet(struct sk_buff **pskb,
 
        /* UDP helpers might accidentally mangle the wrong packet */
        iph = (*pskb)->nh.iph;
-       if ((*pskb)->len < iph->ihl*4 + sizeof(*udph) + 
-                              match_offset + match_len)
+       if ((*pskb)->len < iph->ihl*4 + sizeof(*udph) +
+                              match_offset + match_len)
                return 0;
 
        if (!skb_make_writable(pskb, (*pskb)->len))
@@ -258,9 +258,9 @@ ip_nat_mangle_udp_packet(struct sk_buff **pskb,
        if ((*pskb)->ip_summed != CHECKSUM_PARTIAL) {
                udph->check = 0;
                udph->check = csum_tcpudp_magic(iph->saddr, iph->daddr,
-                                               datalen, IPPROTO_UDP,
-                                               csum_partial((char *)udph,
-                                                            datalen, 0));
+                                               datalen, IPPROTO_UDP,
+                                               csum_partial((char *)udph,
+                                                            datalen, 0));
                if (!udph->check)
                        udph->check = CSUM_MANGLED_0;
        } else
@@ -273,7 +273,7 @@ EXPORT_SYMBOL(ip_nat_mangle_udp_packet);
 /* Adjust one found SACK option including checksum correction */
 static void
 sack_adjust(struct sk_buff *skb,
-           struct tcphdr *tcph, 
+           struct tcphdr *tcph,
            unsigned int sackoff,
            unsigned int sackend,
            struct ip_nat_seq *natseq)
@@ -360,14 +360,14 @@ ip_nat_sack_adjust(struct sk_buff **pskb,
 
 /* TCP sequence number adjustment.  Returns 1 on success, 0 on failure */
 int
-ip_nat_seq_adjust(struct sk_buff **pskb, 
-                 struct ip_conntrack *ct, 
+ip_nat_seq_adjust(struct sk_buff **pskb,
+                 struct ip_conntrack *ct,
                  enum ip_conntrack_info ctinfo)
 {
        struct tcphdr *tcph;
        int dir;
        __be32 newseq, newack;
-       struct ip_nat_seq *this_way, *other_way;        
+       struct ip_nat_seq *this_way, *other_way;
 
        dir = CTINFO2DIR(ctinfo);
 
index ec957bbb53665fa5105151e23feea63e820318ce..24ce4a5023d76b0d3b9cb2abcef6e8c5740e357e 100644 (file)
@@ -202,10 +202,10 @@ pptp_outbound_pkt(struct sk_buff **pskb,
 
        /* mangle packet */
        if (ip_nat_mangle_tcp_packet(pskb, ct, ctinfo,
-                                    cid_off + sizeof(struct pptp_pkt_hdr) +
-                                    sizeof(struct PptpControlHeader),
-                                    sizeof(new_callid), (char *)&new_callid,
-                                    sizeof(new_callid)) == 0)
+                                    cid_off + sizeof(struct pptp_pkt_hdr) +
+                                    sizeof(struct PptpControlHeader),
+                                    sizeof(new_callid), (char *)&new_callid,
+                                    sizeof(new_callid)) == 0)
                return NF_DROP;
 
        return NF_ACCEPT;
@@ -293,7 +293,7 @@ pptp_inbound_pkt(struct sk_buff **pskb,
                ntohs(REQ_CID(pptpReq, pcid_off)), ntohs(new_pcid));
 
        if (ip_nat_mangle_tcp_packet(pskb, ct, ctinfo,
-                                    pcid_off + sizeof(struct pptp_pkt_hdr) +
+                                    pcid_off + sizeof(struct pptp_pkt_hdr) +
                                     sizeof(struct PptpControlHeader),
                                     sizeof(new_pcid), (char *)&new_pcid,
                                     sizeof(new_pcid)) == 0)
index feb26b48f1d5040fce65fc36c48e95df42976fab..cfaeea38314f380735fe938662f730197c3afc24 100644 (file)
@@ -88,8 +88,8 @@ static unsigned int help(struct sk_buff **pskb,
        DEBUGP("ip_nat_irc: Inserting '%s' == %u.%u.%u.%u, port %u\n",
               buffer, NIPQUAD(exp->tuple.src.ip), port);
 
-       ret = ip_nat_mangle_tcp_packet(pskb, exp->master, ctinfo, 
-                                      matchoff, matchlen, buffer, 
+       ret = ip_nat_mangle_tcp_packet(pskb, exp->master, ctinfo,
+                                      matchoff, matchlen, buffer,
                                       strlen(buffer));
        if (ret != NF_ACCEPT)
                ip_conntrack_unexpect_related(exp);
index fb716edd5bc6da555738c8eab0f6a5023d10a0bd..22a528ae0380bef73f1f6bfa10cf25c5e6b8c6a7 100644 (file)
@@ -45,7 +45,7 @@ icmp_unique_tuple(struct ip_conntrack_tuple *tuple,
 
        for (i = 0; i < range_size; i++, id++) {
                tuple->src.u.icmp.id = htons(ntohs(range->min.icmp.id) +
-                                            (id % range_size));
+                                            (id % range_size));
                if (!ip_nat_used_tuple(tuple, conntrack))
                        return 1;
        }
index b586d18b3fb39405f44ae03c12c6b2d5f50e0996..14ff24f53a7a5e5940820e202951e83e217d07fb 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <linux/types.h>
 #include <linux/init.h>
+#include <linux/random.h>
 #include <linux/netfilter.h>
 #include <linux/ip.h>
 #include <linux/tcp.h>
@@ -75,6 +76,10 @@ tcp_unique_tuple(struct ip_conntrack_tuple *tuple,
                range_size = ntohs(range->max.tcp.port) - min + 1;
        }
 
+       /* Start from random port to avoid prediction */
+       if (range->flags & IP_NAT_RANGE_PROTO_RANDOM)
+               port =  net_random();
+
        for (i = 0; i < range_size; i++, port++) {
                *portptr = htons(min + port % range_size);
                if (!ip_nat_used_tuple(tuple, conntrack)) {
index 5ced0877b32fca30b85164411768828b83be0986..dfd521672891c771b2d3ff7f43da7409c7b07b6d 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <linux/types.h>
 #include <linux/init.h>
+#include <linux/random.h>
 #include <linux/netfilter.h>
 #include <linux/ip.h>
 #include <linux/udp.h>
@@ -74,6 +75,10 @@ udp_unique_tuple(struct ip_conntrack_tuple *tuple,
                range_size = ntohs(range->max.udp.port) - min + 1;
        }
 
+       /* Start from random port to avoid prediction */
+       if (range->flags & IP_NAT_RANGE_PROTO_RANDOM)
+               port = net_random();
+
        for (i = 0; i < range_size; i++, port++) {
                *portptr = htons(min + port % range_size);
                if (!ip_nat_used_tuple(tuple, conntrack))
index a176aa3031e0f37557d100975e6e9ba92f0df4f0..080eb1d922007490cb1ccd237a313cd369c72bf8 100644 (file)
@@ -86,7 +86,7 @@ static struct
     }
 };
 
-static struct ipt_table nat_table = {
+static struct xt_table nat_table = {
        .name           = "nat",
        .valid_hooks    = NAT_VALID_HOOKS,
        .lock           = RW_LOCK_UNLOCKED,
@@ -99,7 +99,7 @@ static unsigned int ipt_snat_target(struct sk_buff **pskb,
                                    const struct net_device *in,
                                    const struct net_device *out,
                                    unsigned int hooknum,
-                                   const struct ipt_target *target,
+                                   const struct xt_target *target,
                                    const void *targinfo)
 {
        struct ip_conntrack *ct;
@@ -112,7 +112,7 @@ static unsigned int ipt_snat_target(struct sk_buff **pskb,
 
        /* Connection must be valid and new. */
        IP_NF_ASSERT(ct && (ctinfo == IP_CT_NEW || ctinfo == IP_CT_RELATED
-                           || ctinfo == IP_CT_RELATED + IP_CT_IS_REPLY));
+                           || ctinfo == IP_CT_RELATED + IP_CT_IS_REPLY));
        IP_NF_ASSERT(out);
 
        return ip_nat_setup_info(ct, &mr->range[0], hooknum);
@@ -141,7 +141,7 @@ static unsigned int ipt_dnat_target(struct sk_buff **pskb,
                                    const struct net_device *in,
                                    const struct net_device *out,
                                    unsigned int hooknum,
-                                   const struct ipt_target *target,
+                                   const struct xt_target *target,
                                    const void *targinfo)
 {
        struct ip_conntrack *ct;
@@ -166,7 +166,7 @@ static unsigned int ipt_dnat_target(struct sk_buff **pskb,
 
 static int ipt_snat_checkentry(const char *tablename,
                               const void *entry,
-                              const struct ipt_target *target,
+                              const struct xt_target *target,
                               void *targinfo,
                               unsigned int hook_mask)
 {
@@ -182,7 +182,7 @@ static int ipt_snat_checkentry(const char *tablename,
 
 static int ipt_dnat_checkentry(const char *tablename,
                               const void *entry,
-                              const struct ipt_target *target,
+                              const struct xt_target *target,
                               void *targinfo,
                               unsigned int hook_mask)
 {
@@ -193,6 +193,10 @@ static int ipt_dnat_checkentry(const char *tablename,
                printk("DNAT: multiple ranges no longer supported\n");
                return 0;
        }
+       if (mr->range[0].flags & IP_NAT_RANGE_PROTO_RANDOM) {
+               printk("DNAT: port randomization not supported\n");
+               return 0;
+       }
        return 1;
 }
 
@@ -219,8 +223,8 @@ alloc_null_binding(struct ip_conntrack *conntrack,
 
 unsigned int
 alloc_null_binding_confirmed(struct ip_conntrack *conntrack,
-                             struct ip_nat_info *info,
-                             unsigned int hooknum)
+                            struct ip_nat_info *info,
+                            unsigned int hooknum)
 {
        __be32 ip
                = (HOOK2MANIP(hooknum) == IP_NAT_MANIP_SRC
@@ -257,8 +261,9 @@ int ip_nat_rule_find(struct sk_buff **pskb,
        return ret;
 }
 
-static struct ipt_target ipt_snat_reg = {
+static struct xt_target ipt_snat_reg = {
        .name           = "SNAT",
+       .family         = AF_INET,
        .target         = ipt_snat_target,
        .targetsize     = sizeof(struct ip_nat_multi_range_compat),
        .table          = "nat",
@@ -266,8 +271,9 @@ static struct ipt_target ipt_snat_reg = {
        .checkentry     = ipt_snat_checkentry,
 };
 
-static struct ipt_target ipt_dnat_reg = {
+static struct xt_target ipt_dnat_reg = {
        .name           = "DNAT",
+       .family         = AF_INET,
        .target         = ipt_dnat_target,
        .targetsize     = sizeof(struct ip_nat_multi_range_compat),
        .table          = "nat",
@@ -282,27 +288,27 @@ int __init ip_nat_rule_init(void)
        ret = ipt_register_table(&nat_table, &nat_initial_table.repl);
        if (ret != 0)
                return ret;
-       ret = ipt_register_target(&ipt_snat_reg);
+       ret = xt_register_target(&ipt_snat_reg);
        if (ret != 0)
                goto unregister_table;
 
-       ret = ipt_register_target(&ipt_dnat_reg);
+       ret = xt_register_target(&ipt_dnat_reg);
        if (ret != 0)
                goto unregister_snat;
 
        return ret;
 
  unregister_snat:
-       ipt_unregister_target(&ipt_snat_reg);
+       xt_unregister_target(&ipt_snat_reg);
  unregister_table:
-       ipt_unregister_table(&nat_table);
+       xt_unregister_table(&nat_table);
 
        return ret;
 }
 
 void ip_nat_rule_cleanup(void)
 {
-       ipt_unregister_target(&ipt_dnat_reg);
-       ipt_unregister_target(&ipt_snat_reg);
+       xt_unregister_target(&ipt_dnat_reg);
+       xt_unregister_target(&ipt_snat_reg);
        ipt_unregister_table(&nat_table);
 }
index 6223abc924ff33f5ad884de6128d3d60b2a797be..325c5a9dc2efe22da7cb275af0cbb92b9c51e1dd 100644 (file)
@@ -88,7 +88,7 @@ static int map_sip_addr(struct sk_buff **pskb, enum ip_conntrack_info ctinfo,
                return 1;
 
        if (!ip_nat_mangle_udp_packet(pskb, ct, ctinfo,
-                                     matchoff, matchlen, addr, addrlen))
+                                     matchoff, matchlen, addr, addrlen))
                return 0;
        *dptr = (*pskb)->data + (*pskb)->nh.iph->ihl*4 + sizeof(struct udphdr);
        return 1;
@@ -149,7 +149,7 @@ static unsigned int mangle_sip_packet(struct sk_buff **pskb,
                return 0;
 
        if (!ip_nat_mangle_udp_packet(pskb, ct, ctinfo,
-                                     matchoff, matchlen, buffer, bufflen))
+                                     matchoff, matchlen, buffer, bufflen))
                return 0;
 
        /* We need to reload this. Thanks Patrick. */
@@ -170,7 +170,7 @@ static int mangle_content_len(struct sk_buff **pskb,
 
        /* Get actual SDP lenght */
        if (ct_sip_get_info(dptr, (*pskb)->len - dataoff, &matchoff,
-                           &matchlen, POS_SDP_HEADER) > 0) {
+                           &matchlen, POS_SDP_HEADER) > 0) {
 
                /* since ct_sip_get_info() give us a pointer passing 'v='
                   we need to add 2 bytes in this count. */
@@ -178,7 +178,7 @@ static int mangle_content_len(struct sk_buff **pskb,
 
                /* Now, update SDP lenght */
                if (ct_sip_get_info(dptr, (*pskb)->len - dataoff, &matchoff,
-                                   &matchlen, POS_CONTENT) > 0) {
+                                   &matchlen, POS_CONTENT) > 0) {
 
                        bufflen = sprintf(buffer, "%u", c_len);
 
@@ -204,17 +204,17 @@ static unsigned int mangle_sdp(struct sk_buff **pskb,
        /* Mangle owner and contact info. */
        bufflen = sprintf(buffer, "%u.%u.%u.%u", NIPQUAD(newip));
        if (!mangle_sip_packet(pskb, ctinfo, ct, &dptr, (*pskb)->len - dataoff,
-                              buffer, bufflen, POS_OWNER))
+                              buffer, bufflen, POS_OWNER))
                return 0;
 
        if (!mangle_sip_packet(pskb, ctinfo, ct, &dptr, (*pskb)->len - dataoff,
-                              buffer, bufflen, POS_CONNECTION))
+                              buffer, bufflen, POS_CONNECTION))
                return 0;
 
        /* Mangle media port. */
        bufflen = sprintf(buffer, "%u", port);
        if (!mangle_sip_packet(pskb, ctinfo, ct, &dptr, (*pskb)->len - dataoff,
-                              buffer, bufflen, POS_MEDIA))
+                              buffer, bufflen, POS_MEDIA))
                return 0;
 
        return mangle_content_len(pskb, ctinfo, ct, dptr);
index c3d9f3b090c44851a279eb8ee7aa5a5c9b22464a..e41d0efae5159ff405326d5c40178b6f066a7932 100644 (file)
@@ -3,11 +3,11 @@
  *
  * Basic SNMP Application Layer Gateway
  *
- * This IP NAT module is intended for use with SNMP network 
- * discovery and monitoring applications where target networks use 
+ * This IP NAT module is intended for use with SNMP network
+ * discovery and monitoring applications where target networks use
  * conflicting private address realms.
  *
- * Static NAT is used to remap the networks from the view of the network 
+ * Static NAT is used to remap the networks from the view of the network
  * management system at the IP layer, and this module remaps some application
  * layer addresses to match.
  *
@@ -20,7 +20,7 @@
  * More information on ALG and associated issues can be found in
  * RFC 2962
  *
- * The ASB.1/BER parsing code is derived from the gxsnmp package by Gregory 
+ * The ASB.1/BER parsing code is derived from the gxsnmp package by Gregory
  * McLean & Jochen Friedrich, stripped down for use in the kernel.
  *
  * Copyright (c) 2000 RP Internet (www.rpi.net.au).
@@ -69,8 +69,8 @@ MODULE_DESCRIPTION("Basic SNMP Application Layer Gateway");
 static int debug;
 static DEFINE_SPINLOCK(snmp_lock);
 
-/* 
- * Application layer address mapping mimics the NAT mapping, but 
+/*
+ * Application layer address mapping mimics the NAT mapping, but
  * only for the first octet in this case (a more flexible system
  * can be implemented if needed).
  */
@@ -80,7 +80,7 @@ struct oct1_map
        u_int8_t to;
 };
 
-                                  
+
 /*****************************************************************************
  *
  * Basic ASN.1 decoding routines (gxsnmp author Dirk Wisse)
@@ -129,7 +129,7 @@ struct oct1_map
 #define ASN1_ERR_DEC_LENGTH_MISMATCH   4
 #define ASN1_ERR_DEC_BADVALUE          5
 
-/* 
+/*
  * ASN.1 context.
  */
 struct asn1_ctx
@@ -148,10 +148,10 @@ struct asn1_octstr
        unsigned char *data;
        unsigned int len;
 };
-       
+
 static void asn1_open(struct asn1_ctx *ctx,
-                      unsigned char *buf,
-                      unsigned int len)
+                     unsigned char *buf,
+                     unsigned int len)
 {
        ctx->begin = buf;
        ctx->end = buf + len;
@@ -172,9 +172,9 @@ static unsigned char asn1_octet_decode(struct asn1_ctx *ctx, unsigned char *ch)
 static unsigned char asn1_tag_decode(struct asn1_ctx *ctx, unsigned int *tag)
 {
        unsigned char ch;
-       
+
        *tag = 0;
-       
+
        do
        {
                if (!asn1_octet_decode(ctx, &ch))
@@ -185,20 +185,20 @@ static unsigned char asn1_tag_decode(struct asn1_ctx *ctx, unsigned int *tag)
        return 1;
 }
 
-static unsigned char asn1_id_decode(struct asn1_ctx *ctx, 
-                                    unsigned int *cls,
-                                    unsigned int *con,
-                                    unsigned int *tag)
+static unsigned char asn1_id_decode(struct asn1_ctx *ctx,
+                                   unsigned int *cls,
+                                   unsigned int *con,
+                                   unsigned int *tag)
 {
        unsigned char ch;
-       
+
        if (!asn1_octet_decode(ctx, &ch))
                return 0;
-               
+
        *cls = (ch & 0xC0) >> 6;
        *con = (ch & 0x20) >> 5;
        *tag = (ch & 0x1F);
-       
+
        if (*tag == 0x1F) {
                if (!asn1_tag_decode(ctx, tag))
                        return 0;
@@ -207,25 +207,25 @@ static unsigned char asn1_id_decode(struct asn1_ctx *ctx,
 }
 
 static unsigned char asn1_length_decode(struct asn1_ctx *ctx,
-                                        unsigned int *def,
-                                        unsigned int *len)
+                                       unsigned int *def,
+                                       unsigned int *len)
 {
        unsigned char ch, cnt;
-       
+
        if (!asn1_octet_decode(ctx, &ch))
                return 0;
-               
+
        if (ch == 0x80)
                *def = 0;
        else {
                *def = 1;
-               
+
                if (ch < 0x80)
                        *len = ch;
                else {
                        cnt = (unsigned char) (ch & 0x7F);
                        *len = 0;
-                       
+
                        while (cnt > 0) {
                                if (!asn1_octet_decode(ctx, &ch))
                                        return 0;
@@ -239,20 +239,20 @@ static unsigned char asn1_length_decode(struct asn1_ctx *ctx,
 }
 
 static unsigned char asn1_header_decode(struct asn1_ctx *ctx,
-                                        unsigned char **eoc,
-                                        unsigned int *cls,
-                                        unsigned int *con,
-                                        unsigned int *tag)
+                                       unsigned char **eoc,
+                                       unsigned int *cls,
+                                       unsigned int *con,
+                                       unsigned int *tag)
 {
        unsigned int def, len;
-       
+
        if (!asn1_id_decode(ctx, cls, con, tag))
                return 0;
-               
+
        def = len = 0;
        if (!asn1_length_decode(ctx, &def, &len))
                return 0;
-               
+
        if (def)
                *eoc = ctx->pointer + len;
        else
@@ -263,19 +263,19 @@ static unsigned char asn1_header_decode(struct asn1_ctx *ctx,
 static unsigned char asn1_eoc_decode(struct asn1_ctx *ctx, unsigned char *eoc)
 {
        unsigned char ch;
-       
+
        if (eoc == 0) {
                if (!asn1_octet_decode(ctx, &ch))
                        return 0;
-                       
+
                if (ch != 0x00) {
                        ctx->error = ASN1_ERR_DEC_EOC_MISMATCH;
                        return 0;
                }
-               
+
                if (!asn1_octet_decode(ctx, &ch))
                        return 0;
-                       
+
                if (ch != 0x00) {
                        ctx->error = ASN1_ERR_DEC_EOC_MISMATCH;
                        return 0;
@@ -297,27 +297,27 @@ static unsigned char asn1_null_decode(struct asn1_ctx *ctx, unsigned char *eoc)
 }
 
 static unsigned char asn1_long_decode(struct asn1_ctx *ctx,
-                                      unsigned char *eoc,
-                                      long *integer)
+                                     unsigned char *eoc,
+                                     long *integer)
 {
        unsigned char ch;
        unsigned int  len;
-       
+
        if (!asn1_octet_decode(ctx, &ch))
                return 0;
-               
+
        *integer = (signed char) ch;
        len = 1;
-       
+
        while (ctx->pointer < eoc) {
                if (++len > sizeof (long)) {
                        ctx->error = ASN1_ERR_DEC_BADVALUE;
                        return 0;
                }
-               
+
                if (!asn1_octet_decode(ctx, &ch))
                        return 0;
-                       
+
                *integer <<= 8;
                *integer |= ch;
        }
@@ -325,28 +325,28 @@ static unsigned char asn1_long_decode(struct asn1_ctx *ctx,
 }
 
 static unsigned char asn1_uint_decode(struct asn1_ctx *ctx,
-                                      unsigned char *eoc,
-                                      unsigned int *integer)
+                                     unsigned char *eoc,
+                                     unsigned int *integer)
 {
        unsigned char ch;
        unsigned int  len;
-       
+
        if (!asn1_octet_decode(ctx, &ch))
                return 0;
-               
+
        *integer = ch;
        if (ch == 0) len = 0;
        else len = 1;
-       
+
        while (ctx->pointer < eoc) {
                if (++len > sizeof (unsigned int)) {
                        ctx->error = ASN1_ERR_DEC_BADVALUE;
                        return 0;
                }
-               
+
                if (!asn1_octet_decode(ctx, &ch))
                        return 0;
-                       
+
                *integer <<= 8;
                *integer |= ch;
        }
@@ -354,28 +354,28 @@ static unsigned char asn1_uint_decode(struct asn1_ctx *ctx,
 }
 
 static unsigned char asn1_ulong_decode(struct asn1_ctx *ctx,
-                                       unsigned char *eoc,
-                                       unsigned long *integer)
+                                      unsigned char *eoc,
+                                      unsigned long *integer)
 {
        unsigned char ch;
        unsigned int  len;
-       
+
        if (!asn1_octet_decode(ctx, &ch))
                return 0;
-               
+
        *integer = ch;
        if (ch == 0) len = 0;
        else len = 1;
-       
+
        while (ctx->pointer < eoc) {
                if (++len > sizeof (unsigned long)) {
                        ctx->error = ASN1_ERR_DEC_BADVALUE;
                        return 0;
                }
-               
+
                if (!asn1_octet_decode(ctx, &ch))
                        return 0;
-                       
+
                *integer <<= 8;
                *integer |= ch;
        }
@@ -383,21 +383,21 @@ static unsigned char asn1_ulong_decode(struct asn1_ctx *ctx,
 }
 
 static unsigned char asn1_octets_decode(struct asn1_ctx *ctx,
-                                        unsigned char *eoc,
-                                        unsigned char **octets,
-                                        unsigned int *len)
+                                       unsigned char *eoc,
+                                       unsigned char **octets,
+                                       unsigned int *len)
 {
        unsigned char *ptr;
-       
+
        *len = 0;
-       
+
        *octets = kmalloc(eoc - ctx->pointer, GFP_ATOMIC);
        if (*octets == NULL) {
                if (net_ratelimit())
                        printk("OOM in bsalg (%d)\n", __LINE__);
                return 0;
        }
-       
+
        ptr = *octets;
        while (ctx->pointer < eoc) {
                if (!asn1_octet_decode(ctx, (unsigned char *)ptr++)) {
@@ -411,16 +411,16 @@ static unsigned char asn1_octets_decode(struct asn1_ctx *ctx,
 }
 
 static unsigned char asn1_subid_decode(struct asn1_ctx *ctx,
-                                       unsigned long *subid)
+                                      unsigned long *subid)
 {
        unsigned char ch;
-       
+
        *subid = 0;
-       
+
        do {
                if (!asn1_octet_decode(ctx, &ch))
                        return 0;
-               
+
                *subid <<= 7;
                *subid |= ch & 0x7F;
        } while ((ch & 0x80) == 0x80);
@@ -428,14 +428,14 @@ static unsigned char asn1_subid_decode(struct asn1_ctx *ctx,
 }
 
 static unsigned char asn1_oid_decode(struct asn1_ctx *ctx,
-                                     unsigned char *eoc,
-                                     unsigned long **oid,
-                                     unsigned int *len)
+                                    unsigned char *eoc,
+                                    unsigned long **oid,
+                                    unsigned int *len)
 {
        unsigned long subid;
        unsigned int  size;
        unsigned long *optr;
-       
+
        size = eoc - ctx->pointer + 1;
        *oid = kmalloc(size * sizeof(unsigned long), GFP_ATOMIC);
        if (*oid == NULL) {
@@ -443,15 +443,15 @@ static unsigned char asn1_oid_decode(struct asn1_ctx *ctx,
                        printk("OOM in bsalg (%d)\n", __LINE__);
                return 0;
        }
-       
+
        optr = *oid;
-       
+
        if (!asn1_subid_decode(ctx, &subid)) {
                kfree(*oid);
                *oid = NULL;
                return 0;
        }
-       
+
        if (subid < 40) {
                optr [0] = 0;
                optr [1] = subid;
@@ -462,10 +462,10 @@ static unsigned char asn1_oid_decode(struct asn1_ctx *ctx,
                optr [0] = 2;
                optr [1] = subid - 80;
        }
-       
+
        *len = 2;
        optr += 2;
-       
+
        while (ctx->pointer < eoc) {
                if (++(*len) > size) {
                        ctx->error = ASN1_ERR_DEC_BADVALUE;
@@ -473,7 +473,7 @@ static unsigned char asn1_oid_decode(struct asn1_ctx *ctx,
                        *oid = NULL;
                        return 0;
                }
-               
+
                if (!asn1_subid_decode(ctx, optr++)) {
                        kfree(*oid);
                        *oid = NULL;
@@ -611,9 +611,9 @@ struct snmp_v1_trap
 #define SERR_EOM    2
 
 static inline void mangle_address(unsigned char *begin,
-                                  unsigned char *addr,
-                                  const struct oct1_map *map,
-                                  __sum16 *check);
+                                 unsigned char *addr,
+                                 const struct oct1_map *map,
+                                 __sum16 *check);
 struct snmp_cnv
 {
        unsigned int class;
@@ -633,7 +633,7 @@ static struct snmp_cnv snmp_conv [] =
        {ASN1_APL, SNMP_GGE, SNMP_GAUGE},       /* Gauge32 == Unsigned32  */
        {ASN1_APL, SNMP_TIT, SNMP_TIMETICKS},
        {ASN1_APL, SNMP_OPQ, SNMP_OPAQUE},
-       
+
        /* SNMPv2 data types and errors */
        {ASN1_UNI, ASN1_BTS, SNMP_BITSTR},
        {ASN1_APL, SNMP_C64, SNMP_COUNTER64},
@@ -644,13 +644,13 @@ static struct snmp_cnv snmp_conv [] =
 };
 
 static unsigned char snmp_tag_cls2syntax(unsigned int tag,
-                                         unsigned int cls,
-                                         unsigned short *syntax)
+                                        unsigned int cls,
+                                        unsigned short *syntax)
 {
        struct snmp_cnv *cnv;
-       
+
        cnv = snmp_conv;
-       
+
        while (cnv->syntax != -1) {
                if (cnv->tag == tag && cnv->class == cls) {
                        *syntax = cnv->syntax;
@@ -662,7 +662,7 @@ static unsigned char snmp_tag_cls2syntax(unsigned int tag,
 }
 
 static unsigned char snmp_object_decode(struct asn1_ctx *ctx,
-                                        struct snmp_object **obj)
+                                       struct snmp_object **obj)
 {
        unsigned int cls, con, tag, len, idlen;
        unsigned short type;
@@ -670,41 +670,41 @@ static unsigned char snmp_object_decode(struct asn1_ctx *ctx,
        unsigned long *lp, *id;
        unsigned long ul;
        long l;
-       
+
        *obj = NULL;
        id = NULL;
-       
+
        if (!asn1_header_decode(ctx, &eoc, &cls, &con, &tag))
                return 0;
-               
+
        if (cls != ASN1_UNI || con != ASN1_CON || tag != ASN1_SEQ)
                return 0;
-       
+
        if (!asn1_header_decode(ctx, &end, &cls, &con, &tag))
                return 0;
-       
+
        if (cls != ASN1_UNI || con != ASN1_PRI || tag != ASN1_OJI)
                return 0;
-       
+
        if (!asn1_oid_decode(ctx, end, &id, &idlen))
                return 0;
-               
+
        if (!asn1_header_decode(ctx, &end, &cls, &con, &tag)) {
                kfree(id);
                return 0;
        }
-       
+
        if (con != ASN1_PRI) {
                kfree(id);
                return 0;
        }
-       
+
        type = 0;
        if (!snmp_tag_cls2syntax(tag, cls, &type)) {
                kfree(id);
                return 0;
        }
-       
+
        l = 0;
        switch (type) {
                case SNMP_INTEGER:
@@ -714,7 +714,7 @@ static unsigned char snmp_object_decode(struct asn1_ctx *ctx,
                                return 0;
                        }
                        *obj = kmalloc(sizeof(struct snmp_object) + len,
-                                      GFP_ATOMIC);
+                                      GFP_ATOMIC);
                        if (*obj == NULL) {
                                kfree(id);
                                if (net_ratelimit())
@@ -730,7 +730,7 @@ static unsigned char snmp_object_decode(struct asn1_ctx *ctx,
                                return 0;
                        }
                        *obj = kmalloc(sizeof(struct snmp_object) + len,
-                                      GFP_ATOMIC);
+                                      GFP_ATOMIC);
                        if (*obj == NULL) {
                                kfree(id);
                                if (net_ratelimit())
@@ -818,12 +818,12 @@ static unsigned char snmp_object_decode(struct asn1_ctx *ctx,
                        kfree(id);
                        return 0;
        }
-       
+
        (*obj)->syntax_len = len;
        (*obj)->type = type;
        (*obj)->id = id;
        (*obj)->id_len = idlen;
-       
+
        if (!asn1_eoc_decode(ctx, eoc)) {
                kfree(id);
                kfree(*obj);
@@ -834,49 +834,49 @@ static unsigned char snmp_object_decode(struct asn1_ctx *ctx,
 }
 
 static unsigned char snmp_request_decode(struct asn1_ctx *ctx,
-                                         struct snmp_request *request)
+                                        struct snmp_request *request)
 {
        unsigned int cls, con, tag;
        unsigned char *end;
-       
+
        if (!asn1_header_decode(ctx, &end, &cls, &con, &tag))
                return 0;
-               
+
        if (cls != ASN1_UNI || con != ASN1_PRI || tag != ASN1_INT)
                return 0;
-               
+
        if (!asn1_ulong_decode(ctx, end, &request->id))
                return 0;
-               
+
        if (!asn1_header_decode(ctx, &end, &cls, &con, &tag))
                return 0;
-               
+
        if (cls != ASN1_UNI || con != ASN1_PRI || tag != ASN1_INT)
                return 0;
-               
+
        if (!asn1_uint_decode(ctx, end, &request->error_status))
                return 0;
-               
+
        if (!asn1_header_decode(ctx, &end, &cls, &con, &tag))
                return 0;
-               
+
        if (cls != ASN1_UNI || con != ASN1_PRI || tag != ASN1_INT)
                return 0;
-               
+
        if (!asn1_uint_decode(ctx, end, &request->error_index))
                return 0;
-       
+
        return 1;
 }
 
-/* 
+/*
  * Fast checksum update for possibly oddly-aligned UDP byte, from the
  * code example in the draft.
  */
 static void fast_csum(__sum16 *csum,
-                      const unsigned char *optr,
-                      const unsigned char *nptr,
-                      int offset)
+                     const unsigned char *optr,
+                     const unsigned char *nptr,
+                     int offset)
 {
        unsigned char s[4];
 
@@ -893,30 +893,30 @@ static void fast_csum(__sum16 *csum,
        *csum = csum_fold(csum_partial(s, 4, ~csum_unfold(*csum)));
 }
 
-/* 
+/*
  * Mangle IP address.
  *     - begin points to the start of the snmp messgae
  *      - addr points to the start of the address
  */
 static inline void mangle_address(unsigned char *begin,
-                                  unsigned char *addr,
-                                  const struct oct1_map *map,
-                                  __sum16 *check)
+                                 unsigned char *addr,
+                                 const struct oct1_map *map,
+                                 __sum16 *check)
 {
        if (map->from == NOCT1(addr)) {
                u_int32_t old;
-               
+
                if (debug)
                        memcpy(&old, (unsigned char *)addr, sizeof(old));
-                       
+
                *addr = map->to;
-               
+
                /* Update UDP checksum if being used */
                if (*check) {
                        fast_csum(check,
-                                 &map->from, &map->to, addr - begin);
+                                 &map->from, &map->to, addr - begin);
                }
-               
+
                if (debug)
                        printk(KERN_DEBUG "bsalg: mapped %u.%u.%u.%u to "
                               "%u.%u.%u.%u\n", NIPQUAD(old), NIPQUAD(*addr));
@@ -924,66 +924,66 @@ static inline void mangle_address(unsigned char *begin,
 }
 
 static unsigned char snmp_trap_decode(struct asn1_ctx *ctx,
-                                      struct snmp_v1_trap *trap,
-                                      const struct oct1_map *map,
-                                      __sum16 *check)
+                                     struct snmp_v1_trap *trap,
+                                     const struct oct1_map *map,
+                                     __sum16 *check)
 {
        unsigned int cls, con, tag, len;
        unsigned char *end;
 
        if (!asn1_header_decode(ctx, &end, &cls, &con, &tag))
                return 0;
-               
+
        if (cls != ASN1_UNI || con != ASN1_PRI || tag != ASN1_OJI)
                return 0;
-       
+
        if (!asn1_oid_decode(ctx, end, &trap->id, &trap->id_len))
                return 0;
-               
+
        if (!asn1_header_decode(ctx, &end, &cls, &con, &tag))
                goto err_id_free;
 
        if (!((cls == ASN1_APL && con == ASN1_PRI && tag == SNMP_IPA) ||
              (cls == ASN1_UNI && con == ASN1_PRI && tag == ASN1_OTS)))
                goto err_id_free;
-       
+
        if (!asn1_octets_decode(ctx, end, (unsigned char **)&trap->ip_address, &len))
                goto err_id_free;
-       
+
        /* IPv4 only */
        if (len != 4)
                goto err_addr_free;
-       
+
        mangle_address(ctx->begin, ctx->pointer - 4, map, check);
-       
+
        if (!asn1_header_decode(ctx, &end, &cls, &con, &tag))
                goto err_addr_free;
-               
+
        if (cls != ASN1_UNI || con != ASN1_PRI || tag != ASN1_INT)
                goto err_addr_free;
-               
+
        if (!asn1_uint_decode(ctx, end, &trap->general))
                goto err_addr_free;
-               
+
        if (!asn1_header_decode(ctx, &end, &cls, &con, &tag))
                goto err_addr_free;
-       
+
        if (cls != ASN1_UNI || con != ASN1_PRI || tag != ASN1_INT)
                goto err_addr_free;
-               
+
        if (!asn1_uint_decode(ctx, end, &trap->specific))
                goto err_addr_free;
-               
+
        if (!asn1_header_decode(ctx, &end, &cls, &con, &tag))
                goto err_addr_free;
-               
+
        if (!((cls == ASN1_APL && con == ASN1_PRI && tag == SNMP_TIT) ||
              (cls == ASN1_UNI && con == ASN1_PRI && tag == ASN1_INT)))
                goto err_addr_free;
-               
+
        if (!asn1_ulong_decode(ctx, end, &trap->time))
                goto err_addr_free;
-               
+
        return 1;
 
 err_addr_free:
@@ -1004,7 +1004,7 @@ err_id_free:
 static void hex_dump(unsigned char *buf, size_t len)
 {
        size_t i;
-       
+
        for (i = 0; i < len; i++) {
                if (i && !(i % 16))
                        printk("\n");
@@ -1018,30 +1018,30 @@ static void hex_dump(unsigned char *buf, size_t len)
  * (And this is the fucking 'basic' method).
  */
 static int snmp_parse_mangle(unsigned char *msg,
-                             u_int16_t len,
-                             const struct oct1_map *map,
-                             __sum16 *check)
+                            u_int16_t len,
+                            const struct oct1_map *map,
+                            __sum16 *check)
 {
        unsigned char *eoc, *end;
        unsigned int cls, con, tag, vers, pdutype;
        struct asn1_ctx ctx;
        struct asn1_octstr comm;
        struct snmp_object **obj;
-       
+
        if (debug > 1)
                hex_dump(msg, len);
 
        asn1_open(&ctx, msg, len);
-       
-       /* 
+
+       /*
         * Start of SNMP message.
         */
        if (!asn1_header_decode(&ctx, &eoc, &cls, &con, &tag))
                return 0;
        if (cls != ASN1_UNI || con != ASN1_CON || tag != ASN1_SEQ)
                return 0;
-       
-       /* 
+
+       /*
         * Version 1 or 2 handled.
         */
        if (!asn1_header_decode(&ctx, &end, &cls, &con, &tag))
@@ -1054,7 +1054,7 @@ static int snmp_parse_mangle(unsigned char *msg,
                printk(KERN_DEBUG "bsalg: snmp version: %u\n", vers + 1);
        if (vers > 1)
                return 1;
-       
+
        /*
         * Community.
         */
@@ -1066,14 +1066,14 @@ static int snmp_parse_mangle(unsigned char *msg,
                return 0;
        if (debug > 1) {
                unsigned int i;
-               
+
                printk(KERN_DEBUG "bsalg: community: ");
                for (i = 0; i < comm.len; i++)
                        printk("%c", comm.data[i]);
                printk("\n");
        }
        kfree(comm.data);
-       
+
        /*
         * PDU type
         */
@@ -1092,7 +1092,7 @@ static int snmp_parse_mangle(unsigned char *msg,
                        [SNMP_PDU_INFORM] = "inform",
                        [SNMP_PDU_TRAP2] = "trapv2"
                };
-               
+
                if (pdutype > SNMP_PDU_TRAP2)
                        printk(KERN_DEBUG "bsalg: bad pdu type %u\n", pdutype);
                else
@@ -1101,56 +1101,56 @@ static int snmp_parse_mangle(unsigned char *msg,
        if (pdutype != SNMP_PDU_RESPONSE &&
            pdutype != SNMP_PDU_TRAP1 && pdutype != SNMP_PDU_TRAP2)
                return 1;
-       
+
        /*
         * Request header or v1 trap
         */
        if (pdutype == SNMP_PDU_TRAP1) {
                struct snmp_v1_trap trap;
                unsigned char ret = snmp_trap_decode(&ctx, &trap, map, check);
-               
+
                if (ret) {
                        kfree(trap.id);
                        kfree((unsigned long *)trap.ip_address);
-               } else 
+               } else
                        return ret;
-               
+
        } else {
                struct snmp_request req;
-               
+
                if (!snmp_request_decode(&ctx, &req))
                        return 0;
-                       
+
                if (debug > 1)
                        printk(KERN_DEBUG "bsalg: request: id=0x%lx error_status=%u "
                        "error_index=%u\n", req.id, req.error_status,
                        req.error_index);
        }
-       
+
        /*
         * Loop through objects, look for IP addresses to mangle.
         */
        if (!asn1_header_decode(&ctx, &eoc, &cls, &con, &tag))
                return 0;
-               
+
        if (cls != ASN1_UNI || con != ASN1_CON || tag != ASN1_SEQ)
                return 0;
-       
+
        obj = kmalloc(sizeof(struct snmp_object), GFP_ATOMIC);
        if (obj == NULL) {
                if (net_ratelimit())
                        printk(KERN_WARNING "OOM in bsalg(%d)\n", __LINE__);
-               return 0;       
+               return 0;
        }
 
        while (!asn1_eoc_decode(&ctx, eoc)) {
                unsigned int i;
-               
+
                if (!snmp_object_decode(&ctx, obj)) {
                        if (*obj) {
                                kfree((*obj)->id);
                                kfree(*obj);
-                       }       
+                       }
                        kfree(obj);
                        return 0;
                }
@@ -1163,20 +1163,20 @@ static int snmp_parse_mangle(unsigned char *msg,
                                printk("%lu", (*obj)->id[i]);
                        }
                        printk(": type=%u\n", (*obj)->type);
-                       
+
                }
 
                if ((*obj)->type == SNMP_IPADDR)
                        mangle_address(ctx.begin, ctx.pointer - 4 , map, check);
-               
+
                kfree((*obj)->id);
                kfree(*obj);
        }
        kfree(obj);
-       
+
        if (!asn1_eoc_decode(&ctx, eoc))
                return 0;
-               
+
        return 1;
 }
 
@@ -1186,12 +1186,12 @@ static int snmp_parse_mangle(unsigned char *msg,
  *
  *****************************************************************************/
 
-/* 
+/*
  * SNMP translation routine.
  */
 static int snmp_translate(struct ip_conntrack *ct,
-                          enum ip_conntrack_info ctinfo,
-                          struct sk_buff **pskb)
+                         enum ip_conntrack_info ctinfo,
+                         struct sk_buff **pskb)
 {
        struct iphdr *iph = (*pskb)->nh.iph;
        struct udphdr *udph = (struct udphdr *)((__be32 *)iph + iph->ihl);
@@ -1213,12 +1213,12 @@ static int snmp_translate(struct ip_conntrack *ct,
                map.from = NOCT1(&ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.ip);
                map.to = NOCT1(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.ip);
        }
-       
+
        if (map.from == map.to)
                return NF_ACCEPT;
-       
+
        if (!snmp_parse_mangle((unsigned char *)udph + sizeof(struct udphdr),
-                              paylen, &map, &udph->check)) {
+                              paylen, &map, &udph->check)) {
                if (net_ratelimit())
                        printk(KERN_WARNING "bsalg: parser failed\n");
                return NF_DROP;
@@ -1247,7 +1247,7 @@ static int help(struct sk_buff **pskb,
        if (!(ct->status & IPS_NAT_MASK))
                return NF_ACCEPT;
 
-       /* 
+       /*
         * Make sure the packet length is ok.  So far, we were only guaranteed
         * to have a valid length IP header plus 8 bytes, which means we have
         * enough room for a UDP header.  Just verify the UDP length field so we
@@ -1305,7 +1305,7 @@ static struct ip_conntrack_helper snmp_trap_helper = {
  * Module stuff.
  *
  *****************************************************************************/
+
 static int __init ip_nat_snmp_basic_init(void)
 {
        int ret = 0;
index ad66328baa5dfee8f236b9f67c6e52c2840986ae..adf25f9f70e1316fe422e76015c1e23317c26fd2 100644 (file)
@@ -81,7 +81,7 @@ static void nat_decode_session(struct sk_buff *skb, struct flowi *fl)
        }
 }
 #endif
-               
+
 static unsigned int
 ip_nat_fn(unsigned int hooknum,
          struct sk_buff **pskb,
@@ -107,8 +107,8 @@ ip_nat_fn(unsigned int hooknum,
           protocol. 8) --RR */
        if (!ct) {
                /* Exception: ICMP redirect to new connection (not in
-                   hash table yet).  We must not let this through, in
-                   case we're doing NAT to the same network. */
+                  hash table yet).  We must not let this through, in
+                  case we're doing NAT to the same network. */
                if ((*pskb)->nh.iph->protocol == IPPROTO_ICMP) {
                        struct icmphdr _hdr, *hp;
 
@@ -148,7 +148,7 @@ ip_nat_fn(unsigned int hooknum,
                        if (unlikely(is_confirmed(ct)))
                                /* NAT module was loaded late */
                                ret = alloc_null_binding_confirmed(ct, info,
-                                                                  hooknum);
+                                                                  hooknum);
                        else if (hooknum == NF_IP_LOCAL_IN)
                                /* LOCAL_IN hook doesn't have a chain!  */
                                ret = alloc_null_binding(ct, info, hooknum);
@@ -179,10 +179,10 @@ ip_nat_fn(unsigned int hooknum,
 
 static unsigned int
 ip_nat_in(unsigned int hooknum,
-          struct sk_buff **pskb,
-          const struct net_device *in,
-          const struct net_device *out,
-          int (*okfn)(struct sk_buff *))
+         struct sk_buff **pskb,
+         const struct net_device *in,
+         const struct net_device *out,
+         int (*okfn)(struct sk_buff *))
 {
        unsigned int ret;
        __be32 daddr = (*pskb)->nh.iph->daddr;
@@ -277,9 +277,9 @@ ip_nat_adjust(unsigned int hooknum,
 
        ct = ip_conntrack_get(*pskb, &ctinfo);
        if (ct && test_bit(IPS_SEQ_ADJUST_BIT, &ct->status)) {
-               DEBUGP("ip_nat_standalone: adjusting sequence number\n");
-               if (!ip_nat_seq_adjust(pskb, ct, ctinfo))
-                       return NF_DROP;
+               DEBUGP("ip_nat_standalone: adjusting sequence number\n");
+               if (!ip_nat_seq_adjust(pskb, ct, ctinfo))
+                       return NF_DROP;
        }
        return NF_ACCEPT;
 }
index cd520df4dcf4c36552da82a3d6a37bef5131d0f3..68bf19f3b01c4232875d632ec6ba50a06c1c0e03 100644 (file)
  *
  * 2000-03-27: Simplified code (thanks to Andi Kleen for clues).
  * 2000-05-20: Fixed notifier problems (following Miguel Freitas' report).
- * 2000-06-19: Fixed so nfmark is copied to metadata (reported by Sebastian 
+ * 2000-06-19: Fixed so nfmark is copied to metadata (reported by Sebastian
  *             Zander).
  * 2000-08-01: Added Nick Williams' MAC support.
  * 2002-06-25: Code cleanup.
  * 2005-01-10: Added /proc counter for dropped packets; fixed so
- *             packets aren't delivered to user space if they're going 
- *             to be dropped. 
+ *             packets aren't delivered to user space if they're going
+ *             to be dropped.
  * 2005-05-26: local_bh_{disable,enable} around nf_reinject (Harald Welte)
  *
  */
@@ -97,7 +97,7 @@ __ipq_find_entry(ipq_cmpfn cmpfn, unsigned long data)
 
        list_for_each_prev(p, &queue_list) {
                struct ipq_queue_entry *entry = (struct ipq_queue_entry *)p;
-               
+
                if (!cmpfn || cmpfn(entry, data))
                        return entry;
        }
@@ -129,7 +129,7 @@ static inline void
 __ipq_flush(int verdict)
 {
        struct ipq_queue_entry *entry;
-       
+
        while ((entry = __ipq_find_dequeue_entry(NULL, 0)))
                ipq_issue_verdict(entry, verdict);
 }
@@ -138,21 +138,21 @@ static inline int
 __ipq_set_mode(unsigned char mode, unsigned int range)
 {
        int status = 0;
-       
+
        switch(mode) {
        case IPQ_COPY_NONE:
        case IPQ_COPY_META:
                copy_mode = mode;
                copy_range = 0;
                break;
-               
+
        case IPQ_COPY_PACKET:
                copy_mode = mode;
                copy_range = range;
                if (copy_range > 0xFFFF)
                        copy_range = 0xFFFF;
                break;
-               
+
        default:
                status = -EINVAL;
 
@@ -173,7 +173,7 @@ static struct ipq_queue_entry *
 ipq_find_dequeue_entry(ipq_cmpfn cmpfn, unsigned long data)
 {
        struct ipq_queue_entry *entry;
-       
+
        write_lock_bh(&queue_lock);
        entry = __ipq_find_dequeue_entry(cmpfn, data);
        write_unlock_bh(&queue_lock);
@@ -199,14 +199,14 @@ ipq_build_packet_message(struct ipq_queue_entry *entry, int *errp)
        struct nlmsghdr *nlh;
 
        read_lock_bh(&queue_lock);
-       
+
        switch (copy_mode) {
        case IPQ_COPY_META:
        case IPQ_COPY_NONE:
                size = NLMSG_SPACE(sizeof(*pmsg));
                data_len = 0;
                break;
-       
+
        case IPQ_COPY_PACKET:
                if ((entry->skb->ip_summed == CHECKSUM_PARTIAL ||
                     entry->skb->ip_summed == CHECKSUM_COMPLETE) &&
@@ -218,10 +218,10 @@ ipq_build_packet_message(struct ipq_queue_entry *entry, int *errp)
                        data_len = entry->skb->len;
                else
                        data_len = copy_range;
-               
+
                size = NLMSG_SPACE(sizeof(*pmsg) + data_len);
                break;
-       
+
        default:
                *errp = -EINVAL;
                read_unlock_bh(&queue_lock);
@@ -233,7 +233,7 @@ ipq_build_packet_message(struct ipq_queue_entry *entry, int *errp)
        skb = alloc_skb(size, GFP_ATOMIC);
        if (!skb)
                goto nlmsg_failure;
-               
+
        old_tail= skb->tail;
        nlh = NLMSG_PUT(skb, 0, 0, IPQM_PACKET, size - sizeof(*nlh));
        pmsg = NLMSG_DATA(nlh);
@@ -246,29 +246,29 @@ ipq_build_packet_message(struct ipq_queue_entry *entry, int *errp)
        pmsg->mark            = entry->skb->mark;
        pmsg->hook            = entry->info->hook;
        pmsg->hw_protocol     = entry->skb->protocol;
-       
+
        if (entry->info->indev)
                strcpy(pmsg->indev_name, entry->info->indev->name);
        else
                pmsg->indev_name[0] = '\0';
-       
+
        if (entry->info->outdev)
                strcpy(pmsg->outdev_name, entry->info->outdev->name);
        else
                pmsg->outdev_name[0] = '\0';
-       
+
        if (entry->info->indev && entry->skb->dev) {
                pmsg->hw_type = entry->skb->dev->type;
                if (entry->skb->dev->hard_header_parse)
                        pmsg->hw_addrlen =
                                entry->skb->dev->hard_header_parse(entry->skb,
-                                                                  pmsg->hw_addr);
+                                                                  pmsg->hw_addr);
        }
-       
+
        if (data_len)
                if (skb_copy_bits(entry->skb, 0, pmsg->payload, data_len))
                        BUG();
-               
+
        nlh->nlmsg_len = skb->tail - old_tail;
        return skb;
 
@@ -303,26 +303,26 @@ ipq_enqueue_packet(struct sk_buff *skb, struct nf_info *info,
        nskb = ipq_build_packet_message(entry, &status);
        if (nskb == NULL)
                goto err_out_free;
-               
+
        write_lock_bh(&queue_lock);
-       
+
        if (!peer_pid)
-               goto err_out_free_nskb; 
+               goto err_out_free_nskb;
 
        if (queue_total >= queue_maxlen) {
-                queue_dropped++;
+               queue_dropped++;
                status = -ENOSPC;
                if (net_ratelimit())
-                         printk (KERN_WARNING "ip_queue: full at %d entries, "
+                         printk (KERN_WARNING "ip_queue: full at %d entries, "
                                  "dropping packets(s). Dropped: %d\n", queue_total,
                                  queue_dropped);
                goto err_out_free_nskb;
        }
 
-       /* netlink_unicast will either free the nskb or attach it to a socket */ 
+       /* netlink_unicast will either free the nskb or attach it to a socket */
        status = netlink_unicast(ipqnl, nskb, peer_pid, MSG_DONTWAIT);
        if (status < 0) {
-               queue_user_dropped++;
+               queue_user_dropped++;
                goto err_out_unlock;
        }
 
@@ -332,8 +332,8 @@ ipq_enqueue_packet(struct sk_buff *skb, struct nf_info *info,
        return status;
 
 err_out_free_nskb:
-       kfree_skb(nskb); 
-       
+       kfree_skb(nskb);
+
 err_out_unlock:
        write_unlock_bh(&queue_lock);
 
@@ -359,11 +359,11 @@ ipq_mangle_ipv4(ipq_verdict_msg_t *v, struct ipq_queue_entry *e)
                        return -EINVAL;
                if (diff > skb_tailroom(e->skb)) {
                        struct sk_buff *newskb;
-                       
+
                        newskb = skb_copy_expand(e->skb,
-                                                skb_headroom(e->skb),
-                                                diff,
-                                                GFP_ATOMIC);
+                                                skb_headroom(e->skb),
+                                                diff,
+                                                GFP_ATOMIC);
                        if (newskb == NULL) {
                                printk(KERN_WARNING "ip_queue: OOM "
                                      "in mangle, dropping packet\n");
@@ -403,11 +403,11 @@ ipq_set_verdict(struct ipq_verdict_msg *vmsg, unsigned int len)
                return -ENOENT;
        else {
                int verdict = vmsg->value;
-               
+
                if (vmsg->data_len && vmsg->data_len == len)
                        if (ipq_mangle_ipv4(vmsg, entry) < 0)
                                verdict = NF_DROP;
-               
+
                ipq_issue_verdict(entry, verdict);
                return 0;
        }
@@ -426,7 +426,7 @@ ipq_set_mode(unsigned char mode, unsigned int range)
 
 static int
 ipq_receive_peer(struct ipq_peer_msg *pmsg,
-                 unsigned char type, unsigned int len)
+                unsigned char type, unsigned int len)
 {
        int status = 0;
 
@@ -436,15 +436,15 @@ ipq_receive_peer(struct ipq_peer_msg *pmsg,
        switch (type) {
        case IPQM_MODE:
                status = ipq_set_mode(pmsg->msg.mode.value,
-                                     pmsg->msg.mode.range);
+                                     pmsg->msg.mode.range);
                break;
-               
+
        case IPQM_VERDICT:
                if (pmsg->msg.verdict.value > NF_MAX_VERDICT)
                        status = -EINVAL;
                else
                        status = ipq_set_verdict(&pmsg->msg.verdict,
-                                                len - sizeof(*pmsg));
+                                                len - sizeof(*pmsg));
                        break;
        default:
                status = -EINVAL;
@@ -468,7 +468,7 @@ dev_cmp(struct ipq_queue_entry *entry, unsigned long ifindex)
                        return 1;
                if (entry->skb->nf_bridge->physoutdev &&
                    entry->skb->nf_bridge->physoutdev->ifindex == ifindex)
-                       return 1;
+                       return 1;
        }
 #endif
        return 0;
@@ -478,7 +478,7 @@ static void
 ipq_dev_drop(int ifindex)
 {
        struct ipq_queue_entry *entry;
-       
+
        while ((entry = ipq_find_dequeue_entry(dev_cmp, ifindex)) != NULL)
                ipq_issue_verdict(entry, NF_DROP);
 }
@@ -502,25 +502,25 @@ ipq_rcv_skb(struct sk_buff *skb)
 
        pid = nlh->nlmsg_pid;
        flags = nlh->nlmsg_flags;
-       
+
        if(pid <= 0 || !(flags & NLM_F_REQUEST) || flags & NLM_F_MULTI)
                RCV_SKB_FAIL(-EINVAL);
-               
+
        if (flags & MSG_TRUNC)
                RCV_SKB_FAIL(-ECOMM);
-               
+
        type = nlh->nlmsg_type;
        if (type < NLMSG_NOOP || type >= IPQM_MAX)
                RCV_SKB_FAIL(-EINVAL);
-               
+
        if (type <= IPQM_BASE)
                return;
-               
+
        if (security_netlink_recv(skb, CAP_NET_ADMIN))
                RCV_SKB_FAIL(-EPERM);
-       
+
        write_lock_bh(&queue_lock);
-       
+
        if (peer_pid) {
                if (peer_pid != pid) {
                        write_unlock_bh(&queue_lock);
@@ -530,17 +530,17 @@ ipq_rcv_skb(struct sk_buff *skb)
                net_enable_timestamp();
                peer_pid = pid;
        }
-               
+
        write_unlock_bh(&queue_lock);
-       
+
        status = ipq_receive_peer(NLMSG_DATA(nlh), type,
-                                 nlmsglen - NLMSG_LENGTH(0));
+                                 nlmsglen - NLMSG_LENGTH(0));
        if (status < 0)
                RCV_SKB_FAIL(status);
-               
+
        if (flags & NLM_F_ACK)
                netlink_ack(skb, nlh, 0);
-        return;
+       return;
 }
 
 static void
@@ -550,19 +550,19 @@ ipq_rcv_sk(struct sock *sk, int len)
        unsigned int qlen;
 
        mutex_lock(&ipqnl_mutex);
-                       
+
        for (qlen = skb_queue_len(&sk->sk_receive_queue); qlen; qlen--) {
                skb = skb_dequeue(&sk->sk_receive_queue);
                ipq_rcv_skb(skb);
                kfree_skb(skb);
        }
-               
+
        mutex_unlock(&ipqnl_mutex);
 }
 
 static int
 ipq_rcv_dev_event(struct notifier_block *this,
-                  unsigned long event, void *ptr)
+                 unsigned long event, void *ptr)
 {
        struct net_device *dev = ptr;
 
@@ -578,7 +578,7 @@ static struct notifier_block ipq_dev_notifier = {
 
 static int
 ipq_rcv_nl_event(struct notifier_block *this,
-                 unsigned long event, void *ptr)
+                unsigned long event, void *ptr)
 {
        struct netlink_notify *n = ptr;
 
@@ -607,7 +607,7 @@ static ctl_table ipq_table[] = {
                .mode           = 0644,
                .proc_handler   = proc_dointvec
        },
-       { .ctl_name = 0 }
+       { .ctl_name = 0 }
 };
 
 static ctl_table ipq_dir_table[] = {
@@ -637,25 +637,25 @@ ipq_get_info(char *buffer, char **start, off_t offset, int length)
        int len;
 
        read_lock_bh(&queue_lock);
-       
+
        len = sprintf(buffer,
-                     "Peer PID          : %d\n"
-                     "Copy mode         : %hu\n"
-                     "Copy range        : %u\n"
-                     "Queue length      : %u\n"
-                     "Queue max. length : %u\n"
+                     "Peer PID          : %d\n"
+                     "Copy mode         : %hu\n"
+                     "Copy range        : %u\n"
+                     "Queue length      : %u\n"
+                     "Queue max. length : %u\n"
                      "Queue dropped     : %u\n"
                      "Netlink dropped   : %u\n",
-                     peer_pid,
-                     copy_mode,
-                     copy_range,
-                     queue_total,
-                     queue_maxlen,
+                     peer_pid,
+                     copy_mode,
+                     copy_range,
+                     queue_total,
+                     queue_maxlen,
                      queue_dropped,
                      queue_user_dropped);
 
        read_unlock_bh(&queue_lock);
-       
+
        *start = buffer + offset;
        len -= offset;
        if (len > length)
@@ -675,7 +675,7 @@ static int __init ip_queue_init(void)
 {
        int status = -ENOMEM;
        struct proc_dir_entry *proc;
-       
+
        netlink_register_notifier(&ipq_nl_notifier);
        ipqnl = netlink_kernel_create(NETLINK_FIREWALL, 0, ipq_rcv_sk,
                                      THIS_MODULE);
@@ -691,10 +691,10 @@ static int __init ip_queue_init(void)
                printk(KERN_ERR "ip_queue: failed to create proc entry\n");
                goto cleanup_ipqnl;
        }
-       
+
        register_netdevice_notifier(&ipq_dev_notifier);
        ipq_sysctl_header = register_sysctl_table(ipq_root_table, 0);
-       
+
        status = nf_register_queue_handler(PF_INET, &nfqh);
        if (status < 0) {
                printk(KERN_ERR "ip_queue: failed to register queue handler\n");
@@ -706,12 +706,12 @@ cleanup_sysctl:
        unregister_sysctl_table(ipq_sysctl_header);
        unregister_netdevice_notifier(&ipq_dev_notifier);
        proc_net_remove(IPQ_PROC_FS_NAME);
-       
+
 cleanup_ipqnl:
        sock_release(ipqnl->sk_socket);
        mutex_lock(&ipqnl_mutex);
        mutex_unlock(&ipqnl_mutex);
-       
+
 cleanup_netlink_notifier:
        netlink_unregister_notifier(&ipq_nl_notifier);
        return status;
index fc1f153c86ba1f33a261a038fa2da3e87b38531f..50cc4b92e2845ae2699e225807582370b09621da 100644 (file)
@@ -216,7 +216,7 @@ ipt_do_table(struct sk_buff **pskb,
             unsigned int hook,
             const struct net_device *in,
             const struct net_device *out,
-            struct ipt_table *table)
+            struct xt_table *table)
 {
        static const char nulldevname[IFNAMSIZ] __attribute__((aligned(sizeof(long))));
        u_int16_t offset;
@@ -297,7 +297,7 @@ ipt_do_table(struct sk_buff **pskb,
                                e = get_entry(table_base, v);
                        } else {
                                /* Targets which reenter must return
-                                   abs. verdicts */
+                                  abs. verdicts */
 #ifdef CONFIG_NETFILTER_DEBUG
                                ((struct ipt_entry *)table_base)->comefrom
                                        = 0xeeeeeeec;
@@ -507,7 +507,7 @@ check_entry(struct ipt_entry *e, const char *name)
 static inline int check_match(struct ipt_entry_match *m, const char *name,
                                const struct ipt_ip *ip, unsigned int hookmask)
 {
-       struct ipt_match *match;
+       struct xt_match *match;
        int ret;
 
        match = m->u.kernel.match;
@@ -531,7 +531,7 @@ find_check_match(struct ipt_entry_match *m,
            unsigned int hookmask,
            unsigned int *i)
 {
-       struct ipt_match *match;
+       struct xt_match *match;
        int ret;
 
        match = try_then_request_module(xt_find_match(AF_INET, m->u.user.name,
@@ -556,9 +556,9 @@ err:
 
 static inline int check_target(struct ipt_entry *e, const char *name)
 {
-       struct ipt_entry_target *t;
-       struct ipt_target *target;
-       int ret;
+       struct ipt_entry_target *t;
+       struct xt_target *target;
+       int ret;
 
        t = ipt_get_target(e);
        target = t->u.kernel.target;
@@ -580,7 +580,7 @@ find_check_entry(struct ipt_entry *e, const char *name, unsigned int size,
            unsigned int *i)
 {
        struct ipt_entry_target *t;
-       struct ipt_target *target;
+       struct xt_target *target;
        int ret;
        unsigned int j;
 
@@ -652,7 +652,7 @@ check_entry_size_and_hooks(struct ipt_entry *e,
        }
 
        /* FIXME: underflows must be unconditional, standard verdicts
-           < 0 (not IPT_RETURN). --RR */
+          < 0 (not IPT_RETURN). --RR */
 
        /* Clear counters and comefrom */
        e->counters = ((struct xt_counters) { 0, 0 });
@@ -818,7 +818,7 @@ get_counters(const struct xt_table_info *t,
        }
 }
 
-static inline struct xt_counters * alloc_counters(struct ipt_table *table)
+static inline struct xt_counters * alloc_counters(struct xt_table *table)
 {
        unsigned int countersize;
        struct xt_counters *counters;
@@ -843,7 +843,7 @@ static inline struct xt_counters * alloc_counters(struct ipt_table *table)
 
 static int
 copy_entries_to_user(unsigned int total_size,
-                    struct ipt_table *table,
+                    struct xt_table *table,
                     void __user *userptr)
 {
        unsigned int off, num;
@@ -1046,7 +1046,7 @@ static int compat_table_info(struct xt_table_info *info,
 static int get_info(void __user *user, int *len, int compat)
 {
        char name[IPT_TABLE_MAXNAMELEN];
-       struct ipt_table *t;
+       struct xt_table *t;
        int ret;
 
        if (*len != sizeof(struct ipt_getinfo)) {
@@ -1107,7 +1107,7 @@ get_entries(struct ipt_get_entries __user *uptr, int *len)
 {
        int ret;
        struct ipt_get_entries get;
-       struct ipt_table *t;
+       struct xt_table *t;
 
        if (*len < sizeof(get)) {
                duprintf("get_entries: %u < %d\n", *len,
@@ -1151,7 +1151,7 @@ __do_replace(const char *name, unsigned int valid_hooks,
                void __user *counters_ptr)
 {
        int ret;
-       struct ipt_table *t;
+       struct xt_table *t;
        struct xt_table_info *oldinfo;
        struct xt_counters *counters;
        void *loc_cpu_old_entry;
@@ -1302,7 +1302,7 @@ do_add_counters(void __user *user, unsigned int len, int compat)
        char *name;
        int size;
        void *ptmp;
-       struct ipt_table *t;
+       struct xt_table *t;
        struct xt_table_info *private;
        int ret = 0;
        void *loc_cpu_entry;
@@ -1437,7 +1437,7 @@ compat_check_calc_match(struct ipt_entry_match *m,
            unsigned int hookmask,
            int *size, int *i)
 {
-       struct ipt_match *match;
+       struct xt_match *match;
 
        match = try_then_request_module(xt_find_match(AF_INET, m->u.user.name,
                                                   m->u.user.revision),
@@ -1466,7 +1466,7 @@ check_compat_entry_size_and_hooks(struct ipt_entry *e,
                           const char *name)
 {
        struct ipt_entry_target *t;
-       struct ipt_target *target;
+       struct xt_target *target;
        unsigned int entry_offset;
        int ret, off, h, j;
 
@@ -1550,7 +1550,7 @@ static int compat_copy_entry_from_user(struct ipt_entry *e, void **dstptr,
        struct xt_table_info *newinfo, unsigned char *base)
 {
        struct ipt_entry_target *t;
-       struct ipt_target *target;
+       struct xt_target *target;
        struct ipt_entry *de;
        unsigned int origsize;
        int ret, h;
@@ -1795,7 +1795,7 @@ struct compat_ipt_get_entries
 };
 
 static int compat_copy_entries_to_user(unsigned int total_size,
-                    struct ipt_table *table, void __user *userptr)
+                    struct xt_table *table, void __user *userptr)
 {
        unsigned int off, num;
        struct compat_ipt_entry e;
@@ -1869,7 +1869,7 @@ compat_get_entries(struct compat_ipt_get_entries __user *uptr, int *len)
 {
        int ret;
        struct compat_ipt_get_entries get;
-       struct ipt_table *t;
+       struct xt_table *t;
 
 
        if (*len < sizeof(get)) {
@@ -2052,12 +2052,12 @@ int ipt_register_table(struct xt_table *table, const struct ipt_replace *repl)
        return 0;
 }
 
-void ipt_unregister_table(struct ipt_table *table)
+void ipt_unregister_table(struct xt_table *table)
 {
        struct xt_table_info *private;
        void *loc_cpu_entry;
 
-       private = xt_unregister_table(table);
+       private = xt_unregister_table(table);
 
        /* Decrease module usage counts and free resources */
        loc_cpu_entry = private->entries[raw_smp_processor_id()];
@@ -2124,7 +2124,7 @@ icmp_checkentry(const char *tablename,
 }
 
 /* The built-in targets: standard (NULL) and error. */
-static struct ipt_target ipt_standard_target = {
+static struct xt_target ipt_standard_target = {
        .name           = IPT_STANDARD_TARGET,
        .targetsize     = sizeof(int),
        .family         = AF_INET,
@@ -2135,7 +2135,7 @@ static struct ipt_target ipt_standard_target = {
 #endif
 };
 
-static struct ipt_target ipt_error_target = {
+static struct xt_target ipt_error_target = {
        .name           = IPT_ERROR_TARGET,
        .target         = ipt_error,
        .targetsize     = IPT_FUNCTION_MAXNAMELEN,
@@ -2158,7 +2158,7 @@ static struct nf_sockopt_ops ipt_sockopts = {
 #endif
 };
 
-static struct ipt_match icmp_matchstruct = {
+static struct xt_match icmp_matchstruct = {
        .name           = "icmp",
        .match          = icmp_match,
        .matchsize      = sizeof(struct ipt_icmp),
index b1c11160b9de2a44f663bbeaa9c2c5fd0c675852..4fe28f2644759962e2dbcbd7a18c121e2a19deaf 100644 (file)
@@ -1,4 +1,4 @@
-/* Cluster IP hashmark target 
+/* Cluster IP hashmark target
  * (C) 2003-2004 by Harald Welte <laforge@netfilter.org>
  * based on ideas of Fabio Olive Leite <olive@unixforge.org>
  *
@@ -26,6 +26,7 @@
 
 #include <linux/netfilter_arp.h>
 
+#include <linux/netfilter/x_tables.h>
 #include <linux/netfilter_ipv4/ip_tables.h>
 #include <linux/netfilter_ipv4/ipt_CLUSTERIP.h>
 #include <net/netfilter/nf_conntrack_compat.h>
@@ -122,7 +123,7 @@ __clusterip_config_find(__be32 clusterip)
        struct list_head *pos;
 
        list_for_each(pos, &clusterip_configs) {
-               struct clusterip_config *c = list_entry(pos, 
+               struct clusterip_config *c = list_entry(pos,
                                        struct clusterip_config, list);
                if (c->clusterip == clusterip) {
                        return c;
@@ -228,7 +229,7 @@ clusterip_del_node(struct clusterip_config *c, u_int16_t nodenum)
        if (nodenum == 0 ||
            nodenum > c->num_total_nodes)
                return 1;
-               
+
        if (test_and_clear_bit(nodenum - 1, &c->local_nodes))
                return 0;
 
@@ -247,6 +248,7 @@ clusterip_hashfn(struct sk_buff *skb, struct clusterip_config *config)
        switch (iph->protocol) {
        case IPPROTO_TCP:
        case IPPROTO_UDP:
+       case IPPROTO_UDPLITE:
        case IPPROTO_SCTP:
        case IPPROTO_DCCP:
        case IPPROTO_ICMP:
@@ -268,7 +270,7 @@ clusterip_hashfn(struct sk_buff *skb, struct clusterip_config *config)
                                      config->hash_initval);
                break;
        case CLUSTERIP_HASHMODE_SIP_SPT:
-               hashval = jhash_2words(ntohl(iph->saddr), sport, 
+               hashval = jhash_2words(ntohl(iph->saddr), sport,
                                       config->hash_initval);
                break;
        case CLUSTERIP_HASHMODE_SIP_SPT_DPT:
@@ -295,8 +297,8 @@ clusterip_responsible(struct clusterip_config *config, u_int32_t hash)
        return test_bit(hash - 1, &config->local_nodes);
 }
 
-/*********************************************************************** 
- * IPTABLES TARGET 
+/***********************************************************************
+ * IPTABLES TARGET
  ***********************************************************************/
 
 static unsigned int
@@ -319,7 +321,7 @@ target(struct sk_buff **pskb,
        if (mark == NULL) {
                printk(KERN_ERR "CLUSTERIP: no conntrack!\n");
                        /* FIXME: need to drop invalid ones, since replies
-                        * to outgoing connections of other nodes will be 
+                        * to outgoing connections of other nodes will be
                         * marked as INVALID */
                return NF_DROP;
        }
@@ -327,11 +329,11 @@ target(struct sk_buff **pskb,
        /* special case: ICMP error handling. conntrack distinguishes between
         * error messages (RELATED) and information requests (see below) */
        if ((*pskb)->nh.iph->protocol == IPPROTO_ICMP
-           && (ctinfo == IP_CT_RELATED 
+           && (ctinfo == IP_CT_RELATED
                || ctinfo == IP_CT_RELATED+IP_CT_IS_REPLY))
-               return IPT_CONTINUE;
+               return XT_CONTINUE;
 
-       /* ip_conntrack_icmp guarantees us that we only have ICMP_ECHO, 
+       /* ip_conntrack_icmp guarantees us that we only have ICMP_ECHO,
         * TIMESTAMP, INFO_REQUEST or ADDRESS type icmp packets from here
         * on, which all have an ID field [relevant for hashing]. */
 
@@ -367,15 +369,15 @@ target(struct sk_buff **pskb,
         * actually a unicast IP packet. TCP doesn't like PACKET_MULTICAST */
        (*pskb)->pkt_type = PACKET_HOST;
 
-       return IPT_CONTINUE;
+       return XT_CONTINUE;
 }
 
 static int
 checkentry(const char *tablename,
           const void *e_void,
           const struct xt_target *target,
-           void *targinfo,
-           unsigned int hook_mask)
+          void *targinfo,
+          unsigned int hook_mask)
 {
        struct ipt_clusterip_tgt_info *cipinfo = targinfo;
        const struct ipt_entry *e = e_void;
@@ -435,7 +437,7 @@ checkentry(const char *tablename,
                                return 0;
                        }
 
-                       config = clusterip_config_init(cipinfo, 
+                       config = clusterip_config_init(cipinfo,
                                                        e->ip.dst.s_addr, dev);
                        if (!config) {
                                printk(KERN_WARNING "CLUSTERIP: cannot allocate config\n");
@@ -470,8 +472,9 @@ static void destroy(const struct xt_target *target, void *targinfo)
        nf_ct_l3proto_module_put(target->family);
 }
 
-static struct ipt_target clusterip_tgt = {
+static struct xt_target clusterip_tgt = {
        .name           = "CLUSTERIP",
+       .family         = AF_INET,
        .target         = target,
        .targetsize     = sizeof(struct ipt_clusterip_tgt_info),
        .checkentry     = checkentry,
@@ -480,8 +483,8 @@ static struct ipt_target clusterip_tgt = {
 };
 
 
-/*********************************************************************** 
- * ARP MANGLING CODE 
+/***********************************************************************
+ * ARP MANGLING CODE
  ***********************************************************************/
 
 /* hardcoded for 48bit ethernet and 32bit ipv4 addresses */
@@ -493,7 +496,7 @@ struct arp_payload {
 } __attribute__ ((packed));
 
 #ifdef CLUSTERIP_DEBUG
-static void arp_print(struct arp_payload *payload) 
+static void arp_print(struct arp_payload *payload)
 {
 #define HBUFFERLEN 30
        char hbuffer[HBUFFERLEN];
@@ -507,7 +510,7 @@ static void arp_print(struct arp_payload *payload)
        }
        hbuffer[--k]='\0';
 
-       printk("src %u.%u.%u.%u@%s, dst %u.%u.%u.%u\n", 
+       printk("src %u.%u.%u.%u@%s, dst %u.%u.%u.%u\n",
                NIPQUAD(payload->src_ip), hbuffer,
                NIPQUAD(payload->dst_ip));
 }
@@ -537,13 +540,13 @@ arp_mangle(unsigned int hook,
 
        payload = (void *)(arp+1);
 
-       /* if there is no clusterip configuration for the arp reply's 
+       /* if there is no clusterip configuration for the arp reply's
         * source ip, we don't want to mangle it */
        c = clusterip_config_find_get(payload->src_ip, 0);
        if (!c)
                return NF_ACCEPT;
 
-       /* normally the linux kernel always replies to arp queries of 
+       /* normally the linux kernel always replies to arp queries of
         * addresses on different interfacs.  However, in the CLUSTERIP case
         * this wouldn't work, since we didn't subscribe the mcast group on
         * other interfaces */
@@ -574,8 +577,8 @@ static struct nf_hook_ops cip_arp_ops = {
        .priority = -1
 };
 
-/*********************************************************************** 
- * PROC DIR HANDLING 
+/***********************************************************************
+ * PROC DIR HANDLING
  ***********************************************************************/
 
 #ifdef CONFIG_PROC_FS
@@ -637,7 +640,7 @@ static int clusterip_seq_show(struct seq_file *s, void *v)
 {
        struct clusterip_seq_position *idx = (struct clusterip_seq_position *)v;
 
-       if (idx->pos != 0) 
+       if (idx->pos != 0)
                seq_putc(s, ',');
 
        seq_printf(s, "%u", idx->bit);
@@ -727,7 +730,7 @@ static int __init ipt_clusterip_init(void)
 {
        int ret;
 
-       ret = ipt_register_target(&clusterip_tgt);
+       ret = xt_register_target(&clusterip_tgt);
        if (ret < 0)
                return ret;
 
@@ -753,7 +756,7 @@ cleanup_hook:
        nf_unregister_hook(&cip_arp_ops);
 #endif /* CONFIG_PROC_FS */
 cleanup_target:
-       ipt_unregister_target(&clusterip_tgt);
+       xt_unregister_target(&clusterip_tgt);
        return ret;
 }
 
@@ -765,7 +768,7 @@ static void __exit ipt_clusterip_fini(void)
        remove_proc_entry(clusterip_procdir->name, clusterip_procdir->parent);
 #endif
        nf_unregister_hook(&cip_arp_ops);
-       ipt_unregister_target(&clusterip_tgt);
+       xt_unregister_target(&clusterip_tgt);
 }
 
 module_init(ipt_clusterip_init);
index b55d670a24df9fb3fbf12d2f8be5a49c98d14c7b..4f565633631dfa971d39eb1bc151ebf0b292fc8d 100644 (file)
@@ -1,20 +1,22 @@
 /* iptables module for the IPv4 and TCP ECN bits, Version 1.5
  *
  * (C) 2002 by Harald Welte <laforge@netfilter.org>
- * 
+ *
  * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as 
+ * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  *
  * ipt_ECN.c,v 1.5 2002/08/18 19:36:51 laforge Exp
 */
 
+#include <linux/in.h>
 #include <linux/module.h>
 #include <linux/skbuff.h>
 #include <linux/ip.h>
 #include <linux/tcp.h>
 #include <net/checksum.h>
 
+#include <linux/netfilter/x_tables.h>
 #include <linux/netfilter_ipv4/ip_tables.h>
 #include <linux/netfilter_ipv4/ipt_ECN.h>
 
@@ -38,7 +40,7 @@ set_ect_ip(struct sk_buff **pskb, const struct ipt_ECN_info *einfo)
                iph->tos &= ~IPT_ECN_IP_MASK;
                iph->tos |= (einfo->ip_ect & IPT_ECN_IP_MASK);
                nf_csum_replace2(&iph->check, htons(oldtos), htons(iph->tos));
-       } 
+       }
        return 1;
 }
 
@@ -95,15 +97,15 @@ target(struct sk_buff **pskb,
                if (!set_ect_tcp(pskb, einfo))
                        return NF_DROP;
 
-       return IPT_CONTINUE;
+       return XT_CONTINUE;
 }
 
 static int
 checkentry(const char *tablename,
           const void *e_void,
           const struct xt_target *target,
-           void *targinfo,
-           unsigned int hook_mask)
+          void *targinfo,
+          unsigned int hook_mask)
 {
        const struct ipt_ECN_info *einfo = (struct ipt_ECN_info *)targinfo;
        const struct ipt_entry *e = e_void;
@@ -119,7 +121,7 @@ checkentry(const char *tablename,
                return 0;
        }
        if ((einfo->operation & (IPT_ECN_OP_SET_ECE|IPT_ECN_OP_SET_CWR))
-           && (e->ip.proto != IPPROTO_TCP || (e->ip.invflags & IPT_INV_PROTO))) {
+           && (e->ip.proto != IPPROTO_TCP || (e->ip.invflags & XT_INV_PROTO))) {
                printk(KERN_WARNING "ECN: cannot use TCP operations on a "
                       "non-tcp rule\n");
                return 0;
@@ -127,8 +129,9 @@ checkentry(const char *tablename,
        return 1;
 }
 
-static struct ipt_target ipt_ecn_reg = {
+static struct xt_target ipt_ecn_reg = {
        .name           = "ECN",
+       .family         = AF_INET,
        .target         = target,
        .targetsize     = sizeof(struct ipt_ECN_info),
        .table          = "mangle",
@@ -138,12 +141,12 @@ static struct ipt_target ipt_ecn_reg = {
 
 static int __init ipt_ecn_init(void)
 {
-       return ipt_register_target(&ipt_ecn_reg);
+       return xt_register_target(&ipt_ecn_reg);
 }
 
 static void __exit ipt_ecn_fini(void)
 {
-       ipt_unregister_target(&ipt_ecn_reg);
+       xt_unregister_target(&ipt_ecn_reg);
 }
 
 module_init(ipt_ecn_init);
index c96de16fefae67ed9a634fd2ad8c2f56edf65289..f4a62f2522ffc518fc7de5a4d25d5811b4a140f4 100644 (file)
@@ -20,7 +20,7 @@
 #include <net/route.h>
 
 #include <linux/netfilter.h>
-#include <linux/netfilter_ipv4/ip_tables.h>
+#include <linux/netfilter/x_tables.h>
 #include <linux/netfilter_ipv4/ipt_LOG.h>
 
 MODULE_LICENSE("GPL");
@@ -289,7 +289,7 @@ static void dump_packet(const struct nf_loginfo *info,
 
                if (ntohs(ih->frag_off) & IP_OFFSET)
                        break;
-               
+
                /* Max length: 9 "PROTO=AH " */
                printk("PROTO=AH ");
 
@@ -334,10 +334,10 @@ static void dump_packet(const struct nf_loginfo *info,
        }
 
        /* Max length: 15 "UID=4294967295 " */
-       if ((logflags & IPT_LOG_UID) && !iphoff && skb->sk) {
+       if ((logflags & IPT_LOG_UID) && !iphoff && skb->sk) {
                read_lock_bh(&skb->sk->sk_callback_lock);
                if (skb->sk->sk_socket && skb->sk->sk_socket->file)
-                       printk("UID=%u ", skb->sk->sk_socket->file->f_uid);
+                       printk("UID=%u ", skb->sk->sk_socket->file->f_uid);
                read_unlock_bh(&skb->sk->sk_callback_lock);
        }
 
@@ -431,8 +431,8 @@ ipt_log_target(struct sk_buff **pskb,
        li.u.log.logflags = loginfo->logflags;
 
        ipt_log_packet(PF_INET, hooknum, *pskb, in, out, &li,
-                      loginfo->prefix);
-       return IPT_CONTINUE;
+                      loginfo->prefix);
+       return XT_CONTINUE;
 }
 
 static int ipt_log_checkentry(const char *tablename,
@@ -455,8 +455,9 @@ static int ipt_log_checkentry(const char *tablename,
        return 1;
 }
 
-static struct ipt_target ipt_log_reg = {
+static struct xt_target ipt_log_reg = {
        .name           = "LOG",
+       .family         = AF_INET,
        .target         = ipt_log_target,
        .targetsize     = sizeof(struct ipt_log_info),
        .checkentry     = ipt_log_checkentry,
@@ -471,22 +472,25 @@ static struct nf_logger ipt_log_logger ={
 
 static int __init ipt_log_init(void)
 {
-       if (ipt_register_target(&ipt_log_reg))
-               return -EINVAL;
+       int ret;
+
+       ret = xt_register_target(&ipt_log_reg);
+       if (ret < 0)
+               return ret;
        if (nf_log_register(PF_INET, &ipt_log_logger) < 0) {
                printk(KERN_WARNING "ipt_LOG: not logging via system console "
                       "since somebody else already registered for PF_INET\n");
                /* we cannot make module load fail here, since otherwise
                 * iptables userspace would abort */
        }
-       
+
        return 0;
 }
 
 static void __exit ipt_log_fini(void)
 {
        nf_log_unregister_logger(&ipt_log_logger);
-       ipt_unregister_target(&ipt_log_reg);
+       xt_unregister_target(&ipt_log_reg);
 }
 
 module_init(ipt_log_init);
index d669685afd04dac843529c8171bd4994af8b8813..b5955f3a3f8f0866a429493264b5ecef276a0791 100644 (file)
@@ -25,7 +25,7 @@
 #else
 #include <linux/netfilter_ipv4/ip_nat_rule.h>
 #endif
-#include <linux/netfilter_ipv4/ip_tables.h>
+#include <linux/netfilter/x_tables.h>
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
@@ -86,7 +86,7 @@ masquerade_target(struct sk_buff **pskb,
        nat = nfct_nat(ct);
 #endif
        IP_NF_ASSERT(ct && (ctinfo == IP_CT_NEW || ctinfo == IP_CT_RELATED
-                           || ctinfo == IP_CT_RELATED + IP_CT_IS_REPLY));
+                           || ctinfo == IP_CT_RELATED + IP_CT_IS_REPLY));
 
        /* Source address is 0.0.0.0 - locally generated packet that is
         * probably not supposed to be masqueraded.
@@ -190,8 +190,9 @@ static struct notifier_block masq_inet_notifier = {
        .notifier_call  = masq_inet_event,
 };
 
-static struct ipt_target masquerade = {
+static struct xt_target masquerade = {
        .name           = "MASQUERADE",
+       .family         = AF_INET,
        .target         = masquerade_target,
        .targetsize     = sizeof(struct ip_nat_multi_range_compat),
        .table          = "nat",
@@ -204,7 +205,7 @@ static int __init ipt_masquerade_init(void)
 {
        int ret;
 
-       ret = ipt_register_target(&masquerade);
+       ret = xt_register_target(&masquerade);
 
        if (ret == 0) {
                /* Register for device down reports */
@@ -218,9 +219,9 @@ static int __init ipt_masquerade_init(void)
 
 static void __exit ipt_masquerade_fini(void)
 {
-       ipt_unregister_target(&masquerade);
+       xt_unregister_target(&masquerade);
        unregister_netdevice_notifier(&masq_dev_notifier);
-       unregister_inetaddr_notifier(&masq_inet_notifier);      
+       unregister_inetaddr_notifier(&masq_inet_notifier);
 }
 
 module_init(ipt_masquerade_init);
index 9390e90f2b25f0eb951ca7550de03b464f332483..fd7aaa347cd8aac4332066af2c9edd9123ca3725 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/netdevice.h>
 #include <linux/netfilter.h>
 #include <linux/netfilter_ipv4.h>
+#include <linux/netfilter/x_tables.h>
 #ifdef CONFIG_NF_NAT_NEEDED
 #include <net/netfilter/nf_nat_rule.h>
 #else
@@ -88,25 +89,26 @@ target(struct sk_buff **pskb,
        return ip_nat_setup_info(ct, &newrange, hooknum);
 }
 
-static struct ipt_target target_module = { 
+static struct xt_target target_module = {
        .name           = MODULENAME,
-       .target         = target, 
+       .family         = AF_INET,
+       .target         = target,
        .targetsize     = sizeof(struct ip_nat_multi_range_compat),
        .table          = "nat",
        .hooks          = (1 << NF_IP_PRE_ROUTING) | (1 << NF_IP_POST_ROUTING) |
                          (1 << NF_IP_LOCAL_OUT),
        .checkentry     = check,
-       .me             = THIS_MODULE 
+       .me             = THIS_MODULE
 };
 
 static int __init ipt_netmap_init(void)
 {
-       return ipt_register_target(&target_module);
+       return xt_register_target(&target_module);
 }
 
 static void __exit ipt_netmap_fini(void)
 {
-       ipt_unregister_target(&target_module);
+       xt_unregister_target(&target_module);
 }
 
 module_init(ipt_netmap_init);
index 462eceb3a1b16497bdbc5ca1831655434f932a2c..c2b6b80670f8bf89cfd68c16b396bdee1d4a99cc 100644 (file)
@@ -18,6 +18,7 @@
 #include <net/protocol.h>
 #include <net/checksum.h>
 #include <linux/netfilter_ipv4.h>
+#include <linux/netfilter/x_tables.h>
 #ifdef CONFIG_NF_NAT_NEEDED
 #include <net/netfilter/nf_nat_rule.h>
 #else
@@ -83,7 +84,7 @@ redirect_target(struct sk_buff **pskb,
                struct in_ifaddr *ifa;
 
                newdst = 0;
-               
+
                rcu_read_lock();
                indev = __in_dev_get_rcu((*pskb)->dev);
                if (indev && (ifa = indev->ifa_list))
@@ -104,8 +105,9 @@ redirect_target(struct sk_buff **pskb,
        return ip_nat_setup_info(ct, &newrange, hooknum);
 }
 
-static struct ipt_target redirect_reg = {
+static struct xt_target redirect_reg = {
        .name           = "REDIRECT",
+       .family         = AF_INET,
        .target         = redirect_target,
        .targetsize     = sizeof(struct ip_nat_multi_range_compat),
        .table          = "nat",
@@ -116,12 +118,12 @@ static struct ipt_target redirect_reg = {
 
 static int __init ipt_redirect_init(void)
 {
-       return ipt_register_target(&redirect_reg);
+       return xt_register_target(&redirect_reg);
 }
 
 static void __exit ipt_redirect_fini(void)
 {
-       ipt_unregister_target(&redirect_reg);
+       xt_unregister_target(&redirect_reg);
 }
 
 module_init(ipt_redirect_init);
index f0319e5ee437c5cdb8ed13cc3bbad8ec0f596a00..a9eb3635fff26ef86060c22b25e1165dd9082f24 100644 (file)
@@ -22,6 +22,7 @@
 #include <net/tcp.h>
 #include <net/route.h>
 #include <net/dst.h>
+#include <linux/netfilter/x_tables.h>
 #include <linux/netfilter_ipv4/ip_tables.h>
 #include <linux/netfilter_ipv4/ipt_REJECT.h>
 #ifdef CONFIG_BRIDGE_NETFILTER
@@ -56,7 +57,7 @@ static void send_reset(struct sk_buff *oldskb, int hook)
        oth = skb_header_pointer(oldskb, oldskb->nh.iph->ihl * 4,
                                 sizeof(_otcph), &_otcph);
        if (oth == NULL)
-               return;
+               return;
 
        /* No RST for RST. */
        if (oth->rst)
@@ -116,7 +117,7 @@ static void send_reset(struct sk_buff *oldskb, int hook)
 
        /* Adjust TCP checksum */
        tcph->check = 0;
-       tcph->check = tcp_v4_check(tcph, sizeof(struct tcphdr),
+       tcph->check = tcp_v4_check(sizeof(struct tcphdr),
                                   nskb->nh.iph->saddr,
                                   nskb->nh.iph->daddr,
                                   csum_partial((char *)tcph,
@@ -144,7 +145,7 @@ static void send_reset(struct sk_buff *oldskb, int hook)
 
        /* Adjust IP checksum */
        nskb->nh.iph->check = 0;
-       nskb->nh.iph->check = ip_fast_csum((unsigned char *)nskb->nh.iph, 
+       nskb->nh.iph->check = ip_fast_csum((unsigned char *)nskb->nh.iph,
                                           nskb->nh.iph->ihl);
 
        /* "Never happens" */
@@ -164,7 +165,7 @@ static void send_reset(struct sk_buff *oldskb, int hook)
 static inline void send_unreach(struct sk_buff *skb_in, int code)
 {
        icmp_send(skb_in, ICMP_DEST_UNREACH, code, 0);
-}      
+}
 
 static unsigned int reject(struct sk_buff **pskb,
                           const struct net_device *in,
@@ -176,33 +177,33 @@ static unsigned int reject(struct sk_buff **pskb,
        const struct ipt_reject_info *reject = targinfo;
 
        /* Our naive response construction doesn't deal with IP
-           options, and probably shouldn't try. */
+          options, and probably shouldn't try. */
        if ((*pskb)->nh.iph->ihl<<2 != sizeof(struct iphdr))
                return NF_DROP;
 
        /* WARNING: This code causes reentry within iptables.
           This means that the iptables jump stack is now crap.  We
           must return an absolute verdict. --RR */
-       switch (reject->with) {
-       case IPT_ICMP_NET_UNREACHABLE:
-               send_unreach(*pskb, ICMP_NET_UNREACH);
-               break;
-       case IPT_ICMP_HOST_UNREACHABLE:
-               send_unreach(*pskb, ICMP_HOST_UNREACH);
-               break;
-       case IPT_ICMP_PROT_UNREACHABLE:
-               send_unreach(*pskb, ICMP_PROT_UNREACH);
-               break;
-       case IPT_ICMP_PORT_UNREACHABLE:
-               send_unreach(*pskb, ICMP_PORT_UNREACH);
-               break;
-       case IPT_ICMP_NET_PROHIBITED:
-               send_unreach(*pskb, ICMP_NET_ANO);
-               break;
+       switch (reject->with) {
+       case IPT_ICMP_NET_UNREACHABLE:
+               send_unreach(*pskb, ICMP_NET_UNREACH);
+               break;
+       case IPT_ICMP_HOST_UNREACHABLE:
+               send_unreach(*pskb, ICMP_HOST_UNREACH);
+               break;
+       case IPT_ICMP_PROT_UNREACHABLE:
+               send_unreach(*pskb, ICMP_PROT_UNREACH);
+               break;
+       case IPT_ICMP_PORT_UNREACHABLE:
+               send_unreach(*pskb, ICMP_PORT_UNREACH);
+               break;
+       case IPT_ICMP_NET_PROHIBITED:
+               send_unreach(*pskb, ICMP_NET_ANO);
+               break;
        case IPT_ICMP_HOST_PROHIBITED:
-               send_unreach(*pskb, ICMP_HOST_ANO);
-               break;
-       case IPT_ICMP_ADMIN_PROHIBITED:
+               send_unreach(*pskb, ICMP_HOST_ANO);
+               break;
+       case IPT_ICMP_ADMIN_PROHIBITED:
                send_unreach(*pskb, ICMP_PKT_FILTERED);
                break;
        case IPT_TCP_RESET:
@@ -221,7 +222,7 @@ static int check(const char *tablename,
                 void *targinfo,
                 unsigned int hook_mask)
 {
-       const struct ipt_reject_info *rejinfo = targinfo;
+       const struct ipt_reject_info *rejinfo = targinfo;
        const struct ipt_entry *e = e_void;
 
        if (rejinfo->with == IPT_ICMP_ECHOREPLY) {
@@ -230,7 +231,7 @@ static int check(const char *tablename,
        } else if (rejinfo->with == IPT_TCP_RESET) {
                /* Must specify that it's a TCP packet */
                if (e->ip.proto != IPPROTO_TCP
-                   || (e->ip.invflags & IPT_INV_PROTO)) {
+                   || (e->ip.invflags & XT_INV_PROTO)) {
                        DEBUGP("REJECT: TCP_RESET invalid for non-tcp\n");
                        return 0;
                }
@@ -238,8 +239,9 @@ static int check(const char *tablename,
        return 1;
 }
 
-static struct ipt_target ipt_reject_reg = {
+static struct xt_target ipt_reject_reg = {
        .name           = "REJECT",
+       .family         = AF_INET,
        .target         = reject,
        .targetsize     = sizeof(struct ipt_reject_info),
        .table          = "filter",
@@ -251,12 +253,12 @@ static struct ipt_target ipt_reject_reg = {
 
 static int __init ipt_reject_init(void)
 {
-       return ipt_register_target(&ipt_reject_reg);
+       return xt_register_target(&ipt_reject_reg);
 }
 
 static void __exit ipt_reject_fini(void)
 {
-       ipt_unregister_target(&ipt_reject_reg);
+       xt_unregister_target(&ipt_reject_reg);
 }
 
 module_init(ipt_reject_init);
index 3dcf29411337ccd6052cfcc70b10827d8fff73af..bd4404e5c6889821f7d0dd1d09e876232a73649d 100644 (file)
@@ -34,6 +34,7 @@
 #include <net/protocol.h>
 #include <net/checksum.h>
 #include <linux/netfilter_ipv4.h>
+#include <linux/netfilter/x_tables.h>
 #ifdef CONFIG_NF_NAT_NEEDED
 #include <net/netfilter/nf_nat_rule.h>
 #else
@@ -86,24 +87,24 @@ same_check(const char *tablename,
                        DEBUGP("same_check: bad MAP_IPS.\n");
                        return 0;
                }
-               rangeip = (ntohl(mr->range[count].max_ip) - 
+               rangeip = (ntohl(mr->range[count].max_ip) -
                                        ntohl(mr->range[count].min_ip) + 1);
                mr->ipnum += rangeip;
-               
+
                DEBUGP("same_check: range %u, ipnum = %u\n", count, rangeip);
        }
        DEBUGP("same_check: total ipaddresses = %u\n", mr->ipnum);
-       
+
        mr->iparray = kmalloc((sizeof(u_int32_t) * mr->ipnum), GFP_KERNEL);
        if (!mr->iparray) {
                DEBUGP("same_check: Couldn't allocate %u bytes "
-                       "for %u ipaddresses!\n", 
+                       "for %u ipaddresses!\n",
                        (sizeof(u_int32_t) * mr->ipnum), mr->ipnum);
                return 0;
        }
        DEBUGP("same_check: Allocated %u bytes for %u ipaddresses.\n",
                        (sizeof(u_int32_t) * mr->ipnum), mr->ipnum);
-       
+
        for (count = 0; count < mr->rangesize; count++) {
                for (countess = ntohl(mr->range[count].min_ip);
                                countess <= ntohl(mr->range[count].max_ip);
@@ -118,13 +119,13 @@ same_check(const char *tablename,
        return 1;
 }
 
-static void 
+static void
 same_destroy(const struct xt_target *target, void *targinfo)
 {
        struct ipt_same_info *mr = targinfo;
 
        kfree(mr->iparray);
-       
+
        DEBUGP("same_destroy: Deallocated %u bytes for %u ipaddresses.\n",
                        (sizeof(u_int32_t) * mr->ipnum), mr->ipnum);
 }
@@ -155,7 +156,7 @@ same_target(struct sk_buff **pskb,
           giving some hope for consistency across reboots.
           Here we calculate the index in same->iparray which
           holds the ipaddress we should use */
-       
+
 #ifdef CONFIG_NF_NAT_NEEDED
        tmpip = ntohl(t->src.u3.ip);
 
@@ -186,8 +187,9 @@ same_target(struct sk_buff **pskb,
        return ip_nat_setup_info(ct, &newrange, hooknum);
 }
 
-static struct ipt_target same_reg = { 
+static struct xt_target same_reg = {
        .name           = "SAME",
+       .family         = AF_INET,
        .target         = same_target,
        .targetsize     = sizeof(struct ipt_same_info),
        .table          = "nat",
@@ -199,12 +201,12 @@ static struct ipt_target same_reg = {
 
 static int __init ipt_same_init(void)
 {
-       return ipt_register_target(&same_reg);
+       return xt_register_target(&same_reg);
 }
 
 static void __exit ipt_same_fini(void)
 {
-       ipt_unregister_target(&same_reg);
+       xt_unregister_target(&same_reg);
 }
 
 module_init(ipt_same_init);
diff --git a/net/ipv4/netfilter/ipt_TCPMSS.c b/net/ipv4/netfilter/ipt_TCPMSS.c
deleted file mode 100644 (file)
index 93eb5c3..0000000
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * This is a module which is used for setting the MSS option in TCP packets.
- *
- * Copyright (C) 2000 Marc Boucher <marc@mbsi.ca>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#include <linux/module.h>
-#include <linux/skbuff.h>
-
-#include <linux/ip.h>
-#include <net/tcp.h>
-
-#include <linux/netfilter_ipv4/ip_tables.h>
-#include <linux/netfilter_ipv4/ipt_TCPMSS.h>
-
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Marc Boucher <marc@mbsi.ca>");
-MODULE_DESCRIPTION("iptables TCP MSS modification module");
-
-static inline unsigned int
-optlen(const u_int8_t *opt, unsigned int offset)
-{
-       /* Beware zero-length options: make finite progress */
-       if (opt[offset] <= TCPOPT_NOP || opt[offset+1] == 0)
-               return 1;
-       else
-               return opt[offset+1];
-}
-
-static unsigned int
-ipt_tcpmss_target(struct sk_buff **pskb,
-                 const struct net_device *in,
-                 const struct net_device *out,
-                 unsigned int hooknum,
-                 const struct xt_target *target,
-                 const void *targinfo)
-{
-       const struct ipt_tcpmss_info *tcpmssinfo = targinfo;
-       struct tcphdr *tcph;
-       struct iphdr *iph;
-       u_int16_t tcplen, newmss;
-       __be16 newtotlen, oldval;
-       unsigned int i;
-       u_int8_t *opt;
-
-       if (!skb_make_writable(pskb, (*pskb)->len))
-               return NF_DROP;
-
-       iph = (*pskb)->nh.iph;
-       tcplen = (*pskb)->len - iph->ihl*4;
-       tcph = (void *)iph + iph->ihl*4;
-
-       /* Since it passed flags test in tcp match, we know it is is
-          not a fragment, and has data >= tcp header length.  SYN
-          packets should not contain data: if they did, then we risk
-          running over MTU, sending Frag Needed and breaking things
-          badly. --RR */
-       if (tcplen != tcph->doff*4) {
-               if (net_ratelimit())
-                       printk(KERN_ERR
-                              "ipt_tcpmss_target: bad length (%d bytes)\n",
-                              (*pskb)->len);
-               return NF_DROP;
-       }
-
-       if (tcpmssinfo->mss == IPT_TCPMSS_CLAMP_PMTU) {
-               if (dst_mtu((*pskb)->dst) <= sizeof(struct iphdr) +
-                                            sizeof(struct tcphdr)) {
-                       if (net_ratelimit())
-                               printk(KERN_ERR "ipt_tcpmss_target: "
-                                      "unknown or invalid path-MTU (%d)\n",
-                                      dst_mtu((*pskb)->dst));
-                       return NF_DROP; /* or IPT_CONTINUE ?? */
-               }
-
-               newmss = dst_mtu((*pskb)->dst) - sizeof(struct iphdr) -
-                                                sizeof(struct tcphdr);
-       } else
-               newmss = tcpmssinfo->mss;
-
-       opt = (u_int8_t *)tcph;
-       for (i = sizeof(struct tcphdr); i < tcph->doff*4; i += optlen(opt, i)) {
-               if (opt[i] == TCPOPT_MSS && tcph->doff*4 - i >= TCPOLEN_MSS &&
-                   opt[i+1] == TCPOLEN_MSS) {
-                       u_int16_t oldmss;
-
-                       oldmss = (opt[i+2] << 8) | opt[i+3];
-
-                       if (tcpmssinfo->mss == IPT_TCPMSS_CLAMP_PMTU &&
-                           oldmss <= newmss)
-                               return IPT_CONTINUE;
-
-                       opt[i+2] = (newmss & 0xff00) >> 8;
-                       opt[i+3] = (newmss & 0x00ff);
-
-                       nf_proto_csum_replace2(&tcph->check, *pskb,
-                                               htons(oldmss), htons(newmss), 0);
-                       return IPT_CONTINUE;
-               }
-       }
-
-       /*
-        * MSS Option not found ?! add it..
-        */
-       if (skb_tailroom((*pskb)) < TCPOLEN_MSS) {
-               struct sk_buff *newskb;
-
-               newskb = skb_copy_expand(*pskb, skb_headroom(*pskb),
-                                        TCPOLEN_MSS, GFP_ATOMIC);
-               if (!newskb)
-                       return NF_DROP;
-               kfree_skb(*pskb);
-               *pskb = newskb;
-               iph = (*pskb)->nh.iph;
-               tcph = (void *)iph + iph->ihl*4;
-       }
-
-       skb_put((*pskb), TCPOLEN_MSS);
-
-       opt = (u_int8_t *)tcph + sizeof(struct tcphdr);
-       memmove(opt + TCPOLEN_MSS, opt, tcplen - sizeof(struct tcphdr));
-
-       nf_proto_csum_replace2(&tcph->check, *pskb,
-                               htons(tcplen), htons(tcplen + TCPOLEN_MSS), 1);
-       opt[0] = TCPOPT_MSS;
-       opt[1] = TCPOLEN_MSS;
-       opt[2] = (newmss & 0xff00) >> 8;
-       opt[3] = (newmss & 0x00ff);
-
-       nf_proto_csum_replace4(&tcph->check, *pskb, 0, *((__be32 *)opt), 0);
-
-       oldval = ((__be16 *)tcph)[6];
-       tcph->doff += TCPOLEN_MSS/4;
-       nf_proto_csum_replace2(&tcph->check, *pskb,
-                               oldval, ((__be16 *)tcph)[6], 0);
-
-       newtotlen = htons(ntohs(iph->tot_len) + TCPOLEN_MSS);
-       nf_csum_replace2(&iph->check, iph->tot_len, newtotlen);
-       iph->tot_len = newtotlen;
-       return IPT_CONTINUE;
-}
-
-#define TH_SYN 0x02
-
-static inline int find_syn_match(const struct ipt_entry_match *m)
-{
-       const struct ipt_tcp *tcpinfo = (const struct ipt_tcp *)m->data;
-
-       if (strcmp(m->u.kernel.match->name, "tcp") == 0 &&
-           tcpinfo->flg_cmp & TH_SYN &&
-           !(tcpinfo->invflags & IPT_TCP_INV_FLAGS))
-               return 1;
-
-       return 0;
-}
-
-/* Must specify -p tcp --syn/--tcp-flags SYN */
-static int
-ipt_tcpmss_checkentry(const char *tablename,
-                     const void *e_void,
-                     const struct xt_target *target,
-                     void *targinfo,
-                     unsigned int hook_mask)
-{
-       const struct ipt_tcpmss_info *tcpmssinfo = targinfo;
-       const struct ipt_entry *e = e_void;
-
-       if (tcpmssinfo->mss == IPT_TCPMSS_CLAMP_PMTU &&
-           (hook_mask & ~((1 << NF_IP_FORWARD) |
-                          (1 << NF_IP_LOCAL_OUT) |
-                          (1 << NF_IP_POST_ROUTING))) != 0) {
-               printk("TCPMSS: path-MTU clamping only supported in "
-                      "FORWARD, OUTPUT and POSTROUTING hooks\n");
-               return 0;
-       }
-
-       if (IPT_MATCH_ITERATE(e, find_syn_match))
-               return 1;
-       printk("TCPMSS: Only works on TCP SYN packets\n");
-       return 0;
-}
-
-static struct ipt_target ipt_tcpmss_reg = {
-       .name           = "TCPMSS",
-       .target         = ipt_tcpmss_target,
-       .targetsize     = sizeof(struct ipt_tcpmss_info),
-       .proto          = IPPROTO_TCP,
-       .checkentry     = ipt_tcpmss_checkentry,
-       .me             = THIS_MODULE,
-};
-
-static int __init ipt_tcpmss_init(void)
-{
-       return ipt_register_target(&ipt_tcpmss_reg);
-}
-
-static void __exit ipt_tcpmss_fini(void)
-{
-       ipt_unregister_target(&ipt_tcpmss_reg);
-}
-
-module_init(ipt_tcpmss_init);
-module_exit(ipt_tcpmss_fini);
index 18e74ac4d4256f566a406017c463f234e37fadaf..cedf9f7d9d6ef650fbeef90dc2609f7d45f8836f 100644 (file)
@@ -13,7 +13,7 @@
 #include <linux/ip.h>
 #include <net/checksum.h>
 
-#include <linux/netfilter_ipv4/ip_tables.h>
+#include <linux/netfilter/x_tables.h>
 #include <linux/netfilter_ipv4/ipt_TOS.h>
 
 MODULE_LICENSE("GPL");
@@ -40,15 +40,15 @@ target(struct sk_buff **pskb,
                iph->tos = (iph->tos & IPTOS_PREC_MASK) | tosinfo->tos;
                nf_csum_replace2(&iph->check, htons(oldtos), htons(iph->tos));
        }
-       return IPT_CONTINUE;
+       return XT_CONTINUE;
 }
 
 static int
 checkentry(const char *tablename,
           const void *e_void,
           const struct xt_target *target,
-           void *targinfo,
-           unsigned int hook_mask)
+          void *targinfo,
+          unsigned int hook_mask)
 {
        const u_int8_t tos = ((struct ipt_tos_target_info *)targinfo)->tos;
 
@@ -63,8 +63,9 @@ checkentry(const char *tablename,
        return 1;
 }
 
-static struct ipt_target ipt_tos_reg = {
+static struct xt_target ipt_tos_reg = {
        .name           = "TOS",
+       .family         = AF_INET,
        .target         = target,
        .targetsize     = sizeof(struct ipt_tos_target_info),
        .table          = "mangle",
@@ -74,12 +75,12 @@ static struct ipt_target ipt_tos_reg = {
 
 static int __init ipt_tos_init(void)
 {
-       return ipt_register_target(&ipt_tos_reg);
+       return xt_register_target(&ipt_tos_reg);
 }
 
 static void __exit ipt_tos_fini(void)
 {
-       ipt_unregister_target(&ipt_tos_reg);
+       xt_unregister_target(&ipt_tos_reg);
 }
 
 module_init(ipt_tos_init);
index fffe5ca82e915d472c2a4d63c32192b1d968b546..64be31c22ba9eb4aac423865fc640e835cca86fb 100644 (file)
 #include <linux/ip.h>
 #include <net/checksum.h>
 
-#include <linux/netfilter_ipv4/ip_tables.h>
+#include <linux/netfilter/x_tables.h>
 #include <linux/netfilter_ipv4/ipt_TTL.h>
 
 MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
 MODULE_DESCRIPTION("IP tables TTL modification module");
 MODULE_LICENSE("GPL");
 
-static unsigned int 
+static unsigned int
 ipt_ttl_target(struct sk_buff **pskb,
               const struct net_device *in, const struct net_device *out,
               unsigned int hooknum, const struct xt_target *target,
@@ -59,7 +59,7 @@ ipt_ttl_target(struct sk_buff **pskb,
                iph->ttl = new_ttl;
        }
 
-       return IPT_CONTINUE;
+       return XT_CONTINUE;
 }
 
 static int ipt_ttl_checkentry(const char *tablename,
@@ -71,7 +71,7 @@ static int ipt_ttl_checkentry(const char *tablename,
        struct ipt_TTL_info *info = targinfo;
 
        if (info->mode > IPT_TTL_MAXMODE) {
-               printk(KERN_WARNING "ipt_TTL: invalid or unknown Mode %u\n", 
+               printk(KERN_WARNING "ipt_TTL: invalid or unknown Mode %u\n",
                        info->mode);
                return 0;
        }
@@ -80,23 +80,24 @@ static int ipt_ttl_checkentry(const char *tablename,
        return 1;
 }
 
-static struct ipt_target ipt_TTL = { 
+static struct xt_target ipt_TTL = {
        .name           = "TTL",
-       .target         = ipt_ttl_target, 
+       .family         = AF_INET,
+       .target         = ipt_ttl_target,
        .targetsize     = sizeof(struct ipt_TTL_info),
        .table          = "mangle",
-       .checkentry     = ipt_ttl_checkentry, 
+       .checkentry     = ipt_ttl_checkentry,
        .me             = THIS_MODULE,
 };
 
 static int __init ipt_ttl_init(void)
 {
-       return ipt_register_target(&ipt_TTL);
+       return xt_register_target(&ipt_TTL);
 }
 
 static void __exit ipt_ttl_fini(void)
 {
-       ipt_unregister_target(&ipt_TTL);
+       xt_unregister_target(&ipt_TTL);
 }
 
 module_init(ipt_ttl_init);
index dbd34783a64d0e233989a869b4e934f75255ac48..3a1eacc634b357d7de5c870bf805052eb74f6ec0 100644 (file)
@@ -4,9 +4,9 @@
  * (C) 2000-2004 by Harald Welte <laforge@netfilter.org>
  *
  * 2000/09/22 ulog-cprange feature added
- * 2001/01/04 in-kernel queue as proposed by Sebastian Zander 
+ * 2001/01/04 in-kernel queue as proposed by Sebastian Zander
  *                                             <zander@fokus.gmd.de>
- * 2001/01/30 per-rule nlgroup conflicts with global queue. 
+ * 2001/01/30 per-rule nlgroup conflicts with global queue.
  *            nlgroup now global (sysctl)
  * 2001/04/19 ulog-queue reworked, now fixed buffer size specified at
  *           module loadtime -HW
@@ -23,8 +23,8 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  *
- * This module accepts two parameters: 
- * 
+ * This module accepts two parameters:
+ *
  * nlbufsiz:
  *   The parameter specifies how big the buffer for each netlink multicast
  * group is. e.g. If you say nlbufsiz=8192, up to eight kb of packets will
@@ -57,7 +57,7 @@
 #include <linux/mm.h>
 #include <linux/moduleparam.h>
 #include <linux/netfilter.h>
-#include <linux/netfilter_ipv4/ip_tables.h>
+#include <linux/netfilter/x_tables.h>
 #include <linux/netfilter_ipv4/ipt_ULOG.h>
 #include <net/sock.h>
 #include <linux/bitops.h>
@@ -72,7 +72,7 @@ MODULE_ALIAS_NET_PF_PROTO(PF_NETLINK, NETLINK_NFLOG);
 
 #if 0
 #define DEBUGP(format, args...) printk("%s:%s:" format, \
-                                       __FILE__, __FUNCTION__ , ## args)
+                                      __FILE__, __FUNCTION__ , ## args)
 #else
 #define DEBUGP(format, args...)
 #endif
@@ -132,7 +132,6 @@ static void ulog_send(unsigned int nlgroupnum)
        ub->qlen = 0;
        ub->skb = NULL;
        ub->lastnlh = NULL;
-
 }
 
 
@@ -163,7 +162,7 @@ static struct sk_buff *ulog_alloc_skb(unsigned int size)
                PRINTR("ipt_ULOG: can't alloc whole buffer %ub!\n", n);
 
                if (n > size) {
-                       /* try to allocate only as much as we need for 
+                       /* try to allocate only as much as we need for
                         * current packet */
 
                        skb = alloc_skb(size, GFP_ATOMIC);
@@ -204,7 +203,7 @@ static void ipt_ulog_packet(unsigned int hooknum,
        size = NLMSG_SPACE(sizeof(*pm) + copy_len);
 
        ub = &ulog_buffers[groupnum];
-       
+
        spin_lock_bh(&ulog_lock);
 
        if (!ub->skb) {
@@ -212,7 +211,7 @@ static void ipt_ulog_packet(unsigned int hooknum,
                        goto alloc_failure;
        } else if (ub->qlen >= loginfo->qthreshold ||
                   size > skb_tailroom(ub->skb)) {
-               /* either the queue len is too high or we don't have 
+               /* either the queue len is too high or we don't have
                 * enough room in nlskb left. send it to userspace. */
 
                ulog_send(groupnum);
@@ -221,11 +220,11 @@ static void ipt_ulog_packet(unsigned int hooknum,
                        goto alloc_failure;
        }
 
-       DEBUGP("ipt_ULOG: qlen %d, qthreshold %d\n", ub->qlen, 
+       DEBUGP("ipt_ULOG: qlen %d, qthreshold %d\n", ub->qlen,
                loginfo->qthreshold);
 
        /* NLMSG_PUT contains a hidden goto nlmsg_failure !!! */
-       nlh = NLMSG_PUT(ub->skb, 0, ub->qlen, ULOG_NL_EVENT, 
+       nlh = NLMSG_PUT(ub->skb, 0, ub->qlen, ULOG_NL_EVENT,
                        sizeof(*pm)+copy_len);
        ub->qlen++;
 
@@ -269,7 +268,7 @@ static void ipt_ulog_packet(unsigned int hooknum,
        /* copy_len <= skb->len, so can't fail. */
        if (skb_copy_bits(skb, 0, pm->payload, copy_len) < 0)
                BUG();
-       
+
        /* check if we are building multi-part messages */
        if (ub->qlen > 1) {
                ub->lastnlh->nlmsg_flags |= NLM_F_MULTI;
@@ -313,10 +312,10 @@ static unsigned int ipt_ulog_target(struct sk_buff **pskb,
        struct ipt_ulog_info *loginfo = (struct ipt_ulog_info *) targinfo;
 
        ipt_ulog_packet(hooknum, *pskb, in, out, loginfo, NULL);
-       return IPT_CONTINUE;
+
+       return XT_CONTINUE;
 }
+
 static void ipt_logfn(unsigned int pf,
                      unsigned int hooknum,
                      const struct sk_buff *skb,
@@ -363,8 +362,9 @@ static int ipt_ulog_checkentry(const char *tablename,
        return 1;
 }
 
-static struct ipt_target ipt_ulog_reg = {
+static struct xt_target ipt_ulog_reg = {
        .name           = "ULOG",
+       .family         = AF_INET,
        .target         = ipt_ulog_target,
        .targetsize     = sizeof(struct ipt_ulog_info),
        .checkentry     = ipt_ulog_checkentry,
@@ -379,7 +379,7 @@ static struct nf_logger ipt_ulog_logger = {
 
 static int __init ipt_ulog_init(void)
 {
-       int i;
+       int ret, i;
 
        DEBUGP("ipt_ULOG: init module\n");
 
@@ -396,17 +396,18 @@ static int __init ipt_ulog_init(void)
        }
 
        nflognl = netlink_kernel_create(NETLINK_NFLOG, ULOG_MAXNLGROUPS, NULL,
-                                       THIS_MODULE);
+                                       THIS_MODULE);
        if (!nflognl)
                return -ENOMEM;
 
-       if (ipt_register_target(&ipt_ulog_reg) != 0) {
+       ret = xt_register_target(&ipt_ulog_reg);
+       if (ret < 0) {
                sock_release(nflognl->sk_socket);
-               return -EINVAL;
+               return ret;
        }
        if (nflog)
                nf_log_register(PF_INET, &ipt_ulog_logger);
-       
+
        return 0;
 }
 
@@ -419,7 +420,7 @@ static void __exit ipt_ulog_fini(void)
 
        if (nflog)
                nf_log_unregister_logger(&ipt_ulog_logger);
-       ipt_unregister_target(&ipt_ulog_reg);
+       xt_unregister_target(&ipt_ulog_reg);
        sock_release(nflognl->sk_socket);
 
        /* remove pending timers and free allocated skb's */
@@ -435,7 +436,6 @@ static void __exit ipt_ulog_fini(void)
                        ub->skb = NULL;
                }
        }
-
 }
 
 module_init(ipt_ulog_init);
index 7b60eb74788b6671617425cd2c2602ffe79fe956..cfa0472617f604c89f7e9cb87da40ae937c91632 100644 (file)
@@ -16,7 +16,7 @@
 #include <net/route.h>
 
 #include <linux/netfilter_ipv4/ipt_addrtype.h>
-#include <linux/netfilter_ipv4/ip_tables.h>
+#include <linux/netfilter/x_tables.h>
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");
@@ -40,12 +40,13 @@ static int match(const struct sk_buff *skb,
                ret &= match_type(iph->saddr, info->source)^info->invert_source;
        if (info->dest)
                ret &= match_type(iph->daddr, info->dest)^info->invert_dest;
-       
+
        return ret;
 }
 
-static struct ipt_match addrtype_match = {
+static struct xt_match addrtype_match = {
        .name           = "addrtype",
+       .family         = AF_INET,
        .match          = match,
        .matchsize      = sizeof(struct ipt_addrtype_info),
        .me             = THIS_MODULE
@@ -53,12 +54,12 @@ static struct ipt_match addrtype_match = {
 
 static int __init ipt_addrtype_init(void)
 {
-       return ipt_register_match(&addrtype_match);
+       return xt_register_match(&addrtype_match);
 }
 
 static void __exit ipt_addrtype_fini(void)
 {
-       ipt_unregister_match(&addrtype_match);
+       xt_unregister_match(&addrtype_match);
 }
 
 module_init(ipt_addrtype_init);
index 1798f86bc534ff68c5b80691262c9535c6d7b206..18a16782cf405f1cc6f49fa07a4fa541135d43c0 100644 (file)
@@ -6,12 +6,13 @@
  * published by the Free Software Foundation.
  */
 
+#include <linux/in.h>
 #include <linux/module.h>
 #include <linux/skbuff.h>
 #include <linux/ip.h>
 
 #include <linux/netfilter_ipv4/ipt_ah.h>
-#include <linux/netfilter_ipv4/ip_tables.h>
+#include <linux/netfilter/x_tables.h>
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Yon Uriarte <yon@astaro.de>");
@@ -28,8 +29,8 @@ static inline int
 spi_match(u_int32_t min, u_int32_t max, u_int32_t spi, int invert)
 {
        int r=0;
-        duprintf("ah spi_match:%c 0x%x <= 0x%x <= 0x%x",invert? '!':' ',
-               min,spi,max);
+       duprintf("ah spi_match:%c 0x%x <= 0x%x <= 0x%x",invert? '!':' ',
+               min,spi,max);
        r=(spi >= min && spi <= max) ^ invert;
        duprintf(" result %s\n",r? "PASS" : "FAILED");
        return r;
@@ -86,8 +87,9 @@ checkentry(const char *tablename,
        return 1;
 }
 
-static struct ipt_match ah_match = {
+static struct xt_match ah_match = {
        .name           = "ah",
+       .family         = AF_INET,
        .match          = match,
        .matchsize      = sizeof(struct ipt_ah),
        .proto          = IPPROTO_AH,
@@ -97,12 +99,12 @@ static struct ipt_match ah_match = {
 
 static int __init ipt_ah_init(void)
 {
-       return ipt_register_match(&ah_match);
+       return xt_register_match(&ah_match);
 }
 
 static void __exit ipt_ah_fini(void)
 {
-       ipt_unregister_match(&ah_match);
+       xt_unregister_match(&ah_match);
 }
 
 module_init(ipt_ah_init);
index dafbdec0efc07cef88a73dbd7b14be08a74fe139..37508b2cfea6d491e6ac27434b44386cae494681 100644 (file)
@@ -9,10 +9,13 @@
  * published by the Free Software Foundation.
  */
 
+#include <linux/in.h>
+#include <linux/ip.h>
 #include <linux/module.h>
 #include <linux/skbuff.h>
 #include <linux/tcp.h>
 
+#include <linux/netfilter/x_tables.h>
 #include <linux/netfilter_ipv4/ip_tables.h>
 #include <linux/netfilter_ipv4/ipt_ecn.h>
 
@@ -109,8 +112,9 @@ static int checkentry(const char *tablename, const void *ip_void,
        return 1;
 }
 
-static struct ipt_match ecn_match = {
+static struct xt_match ecn_match = {
        .name           = "ecn",
+       .family         = AF_INET,
        .match          = match,
        .matchsize      = sizeof(struct ipt_ecn_info),
        .checkentry     = checkentry,
@@ -119,12 +123,12 @@ static struct ipt_match ecn_match = {
 
 static int __init ipt_ecn_init(void)
 {
-       return ipt_register_match(&ecn_match);
+       return xt_register_match(&ecn_match);
 }
 
 static void __exit ipt_ecn_fini(void)
 {
-       ipt_unregister_match(&ecn_match);
+       xt_unregister_match(&ecn_match);
 }
 
 module_init(ipt_ecn_init);
index 5202edd8d3330e08172af8e3ed8d8da3b268960a..bc5d5e6091e476bf58fb79bfe886a1e44f876f71 100644 (file)
@@ -10,7 +10,7 @@
 #include <linux/module.h>
 #include <linux/skbuff.h>
 #include <linux/ip.h>
-#include <linux/netfilter_ipv4/ip_tables.h>
+#include <linux/netfilter/x_tables.h>
 #include <linux/netfilter_ipv4/ipt_iprange.h>
 
 MODULE_LICENSE("GPL");
@@ -41,7 +41,7 @@ match(const struct sk_buff *skb,
                        DEBUGP("src IP %u.%u.%u.%u NOT in range %s"
                               "%u.%u.%u.%u-%u.%u.%u.%u\n",
                                NIPQUAD(iph->saddr),
-                               info->flags & IPRANGE_SRC_INV ? "(INV) " : "",
+                               info->flags & IPRANGE_SRC_INV ? "(INV) " : "",
                                NIPQUAD(info->src.min_ip),
                                NIPQUAD(info->src.max_ip));
                        return 0;
@@ -54,7 +54,7 @@ match(const struct sk_buff *skb,
                        DEBUGP("dst IP %u.%u.%u.%u NOT in range %s"
                               "%u.%u.%u.%u-%u.%u.%u.%u\n",
                                NIPQUAD(iph->daddr),
-                               info->flags & IPRANGE_DST_INV ? "(INV) " : "",
+                               info->flags & IPRANGE_DST_INV ? "(INV) " : "",
                                NIPQUAD(info->dst.min_ip),
                                NIPQUAD(info->dst.max_ip));
                        return 0;
@@ -63,22 +63,22 @@ match(const struct sk_buff *skb,
        return 1;
 }
 
-static struct ipt_match iprange_match = {
+static struct xt_match iprange_match = {
        .name           = "iprange",
+       .family         = AF_INET,
        .match          = match,
        .matchsize      = sizeof(struct ipt_iprange_info),
-       .destroy        = NULL,
        .me             = THIS_MODULE
 };
 
 static int __init ipt_iprange_init(void)
 {
-       return ipt_register_match(&iprange_match);
+       return xt_register_match(&iprange_match);
 }
 
 static void __exit ipt_iprange_fini(void)
 {
-       ipt_unregister_match(&iprange_match);
+       xt_unregister_match(&iprange_match);
 }
 
 module_init(ipt_iprange_init);
index 78c336f12a9eee5ed3841b12375c92a9238c18c3..7fae9aa8944c6bb4b07797015d9fd0df315aa754 100644 (file)
@@ -15,7 +15,7 @@
 #include <net/sock.h>
 
 #include <linux/netfilter_ipv4/ipt_owner.h>
-#include <linux/netfilter_ipv4/ip_tables.h>
+#include <linux/netfilter/x_tables.h>
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Marc Boucher <marc@mbsi.ca>");
@@ -53,10 +53,10 @@ match(const struct sk_buff *skb,
 
 static int
 checkentry(const char *tablename,
-           const void *ip,
+          const void *ip,
           const struct xt_match *match,
-           void *matchinfo,
-           unsigned int hook_mask)
+          void *matchinfo,
+          unsigned int hook_mask)
 {
        const struct ipt_owner_info *info = matchinfo;
 
@@ -68,8 +68,9 @@ checkentry(const char *tablename,
        return 1;
 }
 
-static struct ipt_match owner_match = {
+static struct xt_match owner_match = {
        .name           = "owner",
+       .family         = AF_INET,
        .match          = match,
        .matchsize      = sizeof(struct ipt_owner_info),
        .hooks          = (1 << NF_IP_LOCAL_OUT) | (1 << NF_IP_POST_ROUTING),
@@ -79,12 +80,12 @@ static struct ipt_match owner_match = {
 
 static int __init ipt_owner_init(void)
 {
-       return ipt_register_match(&owner_match);
+       return xt_register_match(&owner_match);
 }
 
 static void __exit ipt_owner_fini(void)
 {
-       ipt_unregister_match(&owner_match);
+       xt_unregister_match(&owner_match);
 }
 
 module_init(ipt_owner_init);
index 4db0e73c56f1956fb8c5929301af040a188a3b64..6b97b6796173b34d6f08727099455ad567b9a7e2 100644 (file)
@@ -12,6 +12,7 @@
  * Copyright 2002-2003, Stephen Frost, 2.5.x port by laforge@netfilter.org
  */
 #include <linux/init.h>
+#include <linux/ip.h>
 #include <linux/moduleparam.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
@@ -24,7 +25,7 @@
 #include <linux/skbuff.h>
 #include <linux/inet.h>
 
-#include <linux/netfilter_ipv4/ip_tables.h>
+#include <linux/netfilter/x_tables.h>
 #include <linux/netfilter_ipv4/ipt_recent.h>
 
 MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");
@@ -462,8 +463,9 @@ static struct file_operations recent_fops = {
 };
 #endif /* CONFIG_PROC_FS */
 
-static struct ipt_match recent_match = {
+static struct xt_match recent_match = {
        .name           = "recent",
+       .family         = AF_INET,
        .match          = ipt_recent_match,
        .matchsize      = sizeof(struct ipt_recent_info),
        .checkentry     = ipt_recent_checkentry,
@@ -479,13 +481,13 @@ static int __init ipt_recent_init(void)
                return -EINVAL;
        ip_list_hash_size = 1 << fls(ip_list_tot);
 
-       err = ipt_register_match(&recent_match);
+       err = xt_register_match(&recent_match);
 #ifdef CONFIG_PROC_FS
        if (err)
                return err;
        proc_dir = proc_mkdir("ipt_recent", proc_net);
        if (proc_dir == NULL) {
-               ipt_unregister_match(&recent_match);
+               xt_unregister_match(&recent_match);
                err = -ENOMEM;
        }
 #endif
@@ -495,7 +497,7 @@ static int __init ipt_recent_init(void)
 static void __exit ipt_recent_exit(void)
 {
        BUG_ON(!list_empty(&tables));
-       ipt_unregister_match(&recent_match);
+       xt_unregister_match(&recent_match);
 #ifdef CONFIG_PROC_FS
        remove_proc_entry("ipt_recent", proc_net);
 #endif
index 5549c39c78512d63228c04c62362633337c8a5f5..5d33b51d49d8408e51f988f22864c8ec5d5a29df 100644 (file)
@@ -8,11 +8,12 @@
  * published by the Free Software Foundation.
  */
 
+#include <linux/ip.h>
 #include <linux/module.h>
 #include <linux/skbuff.h>
 
 #include <linux/netfilter_ipv4/ipt_tos.h>
-#include <linux/netfilter_ipv4/ip_tables.h>
+#include <linux/netfilter/x_tables.h>
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("iptables TOS match module");
@@ -32,8 +33,9 @@ match(const struct sk_buff *skb,
        return (skb->nh.iph->tos == info->tos) ^ info->invert;
 }
 
-static struct ipt_match tos_match = {
+static struct xt_match tos_match = {
        .name           = "tos",
+       .family         = AF_INET,
        .match          = match,
        .matchsize      = sizeof(struct ipt_tos_info),
        .me             = THIS_MODULE,
@@ -41,12 +43,12 @@ static struct ipt_match tos_match = {
 
 static int __init ipt_multiport_init(void)
 {
-       return ipt_register_match(&tos_match);
+       return xt_register_match(&tos_match);
 }
 
 static void __exit ipt_multiport_fini(void)
 {
-       ipt_unregister_match(&tos_match);
+       xt_unregister_match(&tos_match);
 }
 
 module_init(ipt_multiport_init);
index a5243bdb87d7fb9de2a9a3a4aa94846f151ba874..1eca9f40037493b69a025f16f016d070c536b91d 100644 (file)
@@ -1,4 +1,4 @@
-/* IP tables module for matching the value of the TTL 
+/* IP tables module for matching the value of the TTL
  *
  * ipt_ttl.c,v 1.5 2000/11/13 11:16:08 laforge Exp
  *
@@ -9,11 +9,12 @@
  * published by the Free Software Foundation.
  */
 
+#include <linux/ip.h>
 #include <linux/module.h>
 #include <linux/skbuff.h>
 
 #include <linux/netfilter_ipv4/ipt_ttl.h>
-#include <linux/netfilter_ipv4/ip_tables.h>
+#include <linux/netfilter/x_tables.h>
 
 MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
 MODULE_DESCRIPTION("IP tables TTL matching module");
@@ -40,7 +41,7 @@ static int match(const struct sk_buff *skb,
                        return (skb->nh.iph->ttl > info->ttl);
                        break;
                default:
-                       printk(KERN_WARNING "ipt_ttl: unknown mode %d\n", 
+                       printk(KERN_WARNING "ipt_ttl: unknown mode %d\n",
                                info->mode);
                        return 0;
        }
@@ -48,8 +49,9 @@ static int match(const struct sk_buff *skb,
        return 0;
 }
 
-static struct ipt_match ttl_match = {
+static struct xt_match ttl_match = {
        .name           = "ttl",
+       .family         = AF_INET,
        .match          = match,
        .matchsize      = sizeof(struct ipt_ttl_info),
        .me             = THIS_MODULE,
@@ -57,13 +59,12 @@ static struct ipt_match ttl_match = {
 
 static int __init ipt_ttl_init(void)
 {
-       return ipt_register_match(&ttl_match);
+       return xt_register_match(&ttl_match);
 }
 
 static void __exit ipt_ttl_fini(void)
 {
-       ipt_unregister_match(&ttl_match);
-
+       xt_unregister_match(&ttl_match);
 }
 
 module_init(ipt_ttl_init);
index e2e7dd8d7903eb60090e5fb6a9b5d3b8a06769e9..d1d61e97b97659dc4a97928affc8cc27c1cbeaa6 100644 (file)
@@ -25,7 +25,7 @@ static struct
        struct ipt_replace repl;
        struct ipt_standard entries[3];
        struct ipt_error term;
-} initial_table __initdata 
+} initial_table __initdata
 = { { "filter", FILTER_VALID_HOOKS, 4,
       sizeof(struct ipt_standard) * 3 + sizeof(struct ipt_error),
       { [NF_IP_LOCAL_IN] = 0,
@@ -74,7 +74,7 @@ static struct
     }
 };
 
-static struct ipt_table packet_filter = {
+static struct xt_table packet_filter = {
        .name           = "filter",
        .valid_hooks    = FILTER_VALID_HOOKS,
        .lock           = RW_LOCK_UNLOCKED,
index af293988944475445dcab838f41506d1e9dad9a7..98b66ef0c714b93c7235e1bfd5cca07100ba1004 100644 (file)
@@ -58,7 +58,7 @@ static struct
              { { { { IPT_ALIGN(sizeof(struct ipt_standard_target)), "" } }, { } },
                -NF_ACCEPT - 1 } },
            /* LOCAL_IN */
-           { { { { 0 }, { 0 }, { 0 }, { 0 }, "", "", { 0 }, { 0 }, 0, 0, 0 },
+           { { { { 0 }, { 0 }, { 0 }, { 0 }, "", "", { 0 }, { 0 }, 0, 0, 0 },
                0,
                sizeof(struct ipt_entry),
                sizeof(struct ipt_standard),
@@ -66,7 +66,7 @@ static struct
              { { { { IPT_ALIGN(sizeof(struct ipt_standard_target)), "" } }, { } },
                -NF_ACCEPT - 1 } },
            /* FORWARD */
-           { { { { 0 }, { 0 }, { 0 }, { 0 }, "", "", { 0 }, { 0 }, 0, 0, 0 },
+           { { { { 0 }, { 0 }, { 0 }, { 0 }, "", "", { 0 }, { 0 }, 0, 0, 0 },
                0,
                sizeof(struct ipt_entry),
                sizeof(struct ipt_standard),
@@ -103,7 +103,7 @@ static struct
     }
 };
 
-static struct ipt_table packet_mangler = {
+static struct xt_table packet_mangler = {
        .name           = "mangle",
        .valid_hooks    = MANGLE_VALID_HOOKS,
        .lock           = RW_LOCK_UNLOCKED,
@@ -166,7 +166,7 @@ static struct nf_hook_ops ipt_ops[] = {
                .hook           = ipt_route_hook,
                .owner          = THIS_MODULE,
                .pf             = PF_INET,
-               .hooknum        = NF_IP_PRE_ROUTING, 
+               .hooknum        = NF_IP_PRE_ROUTING,
                .priority       = NF_IP_PRI_MANGLE,
        },
        {
index bcbeb4aeacd912ec50f6153f5f8905935638a803..18c3d4c9ff51e23ecd8ffece105407d7fed94e91 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
  * 'raw' table, which is the very first hooked in at PRE_ROUTING and LOCAL_OUT .
  *
  * Copyright (C) 2003 Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
@@ -15,26 +15,26 @@ static struct
        struct ipt_error term;
 } initial_table __initdata = {
        .repl = {
-               .name = "raw", 
-               .valid_hooks = RAW_VALID_HOOKS, 
+               .name = "raw",
+               .valid_hooks = RAW_VALID_HOOKS,
                .num_entries = 3,
                .size = sizeof(struct ipt_standard) * 2 + sizeof(struct ipt_error),
-               .hook_entry = { 
+               .hook_entry = {
                        [NF_IP_PRE_ROUTING] = 0,
                        [NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard) },
-               .underflow = { 
+               .underflow = {
                        [NF_IP_PRE_ROUTING] = 0,
                        [NF_IP_LOCAL_OUT]  = sizeof(struct ipt_standard) },
        },
        .entries = {
             /* PRE_ROUTING */
-            { 
-                    .entry = { 
+            {
+                    .entry = {
                             .target_offset = sizeof(struct ipt_entry),
                             .next_offset = sizeof(struct ipt_standard),
                     },
-                    .target = { 
-                         .target = { 
+                    .target = {
+                         .target = {
                                  .u = {
                                          .target_size = IPT_ALIGN(sizeof(struct ipt_standard_target)),
                                  },
@@ -69,7 +69,7 @@ static struct
                        .target = {
                                .u = {
                                        .user = {
-                                               .target_size = IPT_ALIGN(sizeof(struct ipt_error_target)), 
+                                               .target_size = IPT_ALIGN(sizeof(struct ipt_error_target)),
                                                .name = IPT_ERROR_TARGET,
                                        },
                                },
@@ -79,10 +79,10 @@ static struct
        }
 };
 
-static struct ipt_table packet_raw = { 
-       .name = "raw", 
-       .valid_hooks =  RAW_VALID_HOOKS, 
-       .lock = RW_LOCK_UNLOCKED, 
+static struct xt_table packet_raw = {
+       .name = "raw",
+       .valid_hooks =  RAW_VALID_HOOKS,
+       .lock = RW_LOCK_UNLOCKED,
        .me = THIS_MODULE,
        .af = AF_INET,
 };
index 471b638cedec8c2714745a9dac00bceea8d1e830..b984db771258f989f7a9499408ea0e4319c54e62 100644 (file)
@@ -66,7 +66,7 @@ static int ipv4_print_tuple(struct seq_file *s,
                            const struct nf_conntrack_tuple *tuple)
 {
        return seq_printf(s, "src=%u.%u.%u.%u dst=%u.%u.%u.%u ",
-                         NIPQUAD(tuple->src.u3.ip),
+                         NIPQUAD(tuple->src.u3.ip),
                          NIPQUAD(tuple->dst.u3.ip));
 }
 
@@ -82,14 +82,14 @@ nf_ct_ipv4_gather_frags(struct sk_buff *skb, u_int32_t user)
 {
        skb_orphan(skb);
 
-        local_bh_disable();
-        skb = ip_defrag(skb, user);
-        local_bh_enable();
+       local_bh_disable();
+       skb = ip_defrag(skb, user);
+       local_bh_enable();
 
-        if (skb)
+       if (skb)
                ip_send_check(skb->nh.iph);
 
-        return skb;
+       return skb;
 }
 
 static int
@@ -192,10 +192,10 @@ static unsigned int ipv4_conntrack_in(unsigned int hooknum,
 }
 
 static unsigned int ipv4_conntrack_local(unsigned int hooknum,
-                                        struct sk_buff **pskb,
-                                        const struct net_device *in,
-                                        const struct net_device *out,
-                                        int (*okfn)(struct sk_buff *))
+                                        struct sk_buff **pskb,
+                                        const struct net_device *in,
+                                        const struct net_device *out,
+                                        int (*okfn)(struct sk_buff *))
 {
        /* root is playing with raw sockets. */
        if ((*pskb)->len < sizeof(struct iphdr)
@@ -332,7 +332,7 @@ getorigdst(struct sock *sk, int optval, void __user *user, int *len)
        struct inet_sock *inet = inet_sk(sk);
        struct nf_conntrack_tuple_hash *h;
        struct nf_conntrack_tuple tuple;
-       
+
        NF_CT_TUPLE_U_BLANK(&tuple);
        tuple.src.u3.ip = inet->rcv_saddr;
        tuple.src.u.tcp.port = inet->sport;
@@ -501,7 +501,7 @@ static int __init nf_conntrack_l3proto_ipv4_init(void)
        return ret;
 #if defined(CONFIG_PROC_FS) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
  cleanup_hooks:
-       nf_unregister_hooks(ipv4_conntrack_ops, ARRAY_SIZE(ipv4_conntrack_ops));
+       nf_unregister_hooks(ipv4_conntrack_ops, ARRAY_SIZE(ipv4_conntrack_ops));
 #endif
  cleanup_ipv4:
        nf_conntrack_l3proto_unregister(&nf_conntrack_l3proto_ipv4);
index 3b31bc64960809394da42ad275c84c3578379ec2..14a93a7384183f35de7a63f17e0157a5b513f658 100644 (file)
@@ -135,7 +135,7 @@ static int ct_seq_show(struct seq_file *s, void *v)
                        l3proto, l4proto))
                return -ENOSPC;
 
-       if (seq_print_counters(s, &ct->counters[IP_CT_DIR_ORIGINAL]))
+       if (seq_print_counters(s, &ct->counters[IP_CT_DIR_ORIGINAL]))
                return -ENOSPC;
 
        if (!(test_bit(IPS_SEEN_REPLY_BIT, &ct->status)))
@@ -146,7 +146,7 @@ static int ct_seq_show(struct seq_file *s, void *v)
                        l3proto, l4proto))
                return -ENOSPC;
 
-       if (seq_print_counters(s, &ct->counters[IP_CT_DIR_REPLY]))
+       if (seq_print_counters(s, &ct->counters[IP_CT_DIR_REPLY]))
                return -ENOSPC;
 
        if (test_bit(IPS_ASSURED_BIT, &ct->status))
@@ -228,7 +228,7 @@ static void *exp_seq_start(struct seq_file *s, loff_t *pos)
 
 static void *exp_seq_next(struct seq_file *s, void *v, loff_t *pos)
 {
-       struct list_head *e = v;
+       struct list_head *e = v;
 
        ++*pos;
        e = e->next;
@@ -262,7 +262,7 @@ static int exp_seq_show(struct seq_file *s, void *v)
        print_tuple(s, &exp->tuple,
                    __nf_ct_l3proto_find(exp->tuple.src.l3num),
                    __nf_ct_l4proto_find(exp->tuple.src.l3num,
-                                        exp->tuple.dst.protonum));
+                                        exp->tuple.dst.protonum));
        return seq_putc(s, '\n');
 }
 
index db9e7c45d3b42103b393d69deaa2e9b1fc71858c..677b6c80c6188fdd63ad8901e510063a8c0d37d6 100644 (file)
@@ -101,9 +101,9 @@ static int icmp_packet(struct nf_conn *ct,
                       unsigned int hooknum)
 {
        /* Try to delete connection immediately after all replies:
-           won't actually vanish as we still have skb, and del_timer
-           means this will only run once even if count hits zero twice
-           (theoretically possible with SMP) */
+          won't actually vanish as we still have skb, and del_timer
+          means this will only run once even if count hits zero twice
+          (theoretically possible with SMP) */
        if (CTINFO2DIR(ctinfo) == IP_CT_DIR_REPLY) {
                if (atomic_dec_and_test(&ct->proto.icmp.count)
                    && del_timer(&ct->timeout))
@@ -144,8 +144,8 @@ extern struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv4;
 /* Returns conntrack if it dealt with ICMP, and filled in skb fields */
 static int
 icmp_error_message(struct sk_buff *skb,
-                 enum ip_conntrack_info *ctinfo,
-                 unsigned int hooknum)
+                enum ip_conntrack_info *ctinfo,
+                unsigned int hooknum)
 {
        struct nf_conntrack_tuple innertuple, origtuple;
        struct {
@@ -181,9 +181,9 @@ icmp_error_message(struct sk_buff *skb,
                return -NF_ACCEPT;
        }
 
-        /* Ordinarily, we'd expect the inverted tupleproto, but it's
-           been preserved inside the ICMP. */
-        if (!nf_ct_invert_tuple(&innertuple, &origtuple,
+       /* Ordinarily, we'd expect the inverted tupleproto, but it's
+          been preserved inside the ICMP. */
+       if (!nf_ct_invert_tuple(&innertuple, &origtuple,
                                &nf_conntrack_l3proto_ipv4, innerproto)) {
                DEBUGP("icmp_error_message: no match\n");
                return -NF_ACCEPT;
@@ -212,10 +212,10 @@ icmp_error_message(struct sk_buff *skb,
                        *ctinfo += IP_CT_IS_REPLY;
        }
 
-        /* Update skb to refer to this connection */
-        skb->nfct = &nf_ct_tuplehash_to_ctrack(h)->ct_general;
-        skb->nfctinfo = *ctinfo;
-        return -NF_ACCEPT;
+       /* Update skb to refer to this connection */
+       skb->nfct = &nf_ct_tuplehash_to_ctrack(h)->ct_general;
+       skb->nfctinfo = *ctinfo;
+       return -NF_ACCEPT;
 }
 
 /* Small and modified version of icmp_rcv */
@@ -306,7 +306,7 @@ static int icmp_nfattr_to_tuple(struct nfattr *tb[],
        if (nfattr_bad_size(tb, CTA_PROTO_MAX, cta_min_proto))
                return -EINVAL;
 
-       tuple->dst.u.icmp.type = 
+       tuple->dst.u.icmp.type =
                        *(u_int8_t *)NFA_DATA(tb[CTA_PROTO_ICMP_TYPE-1]);
        tuple->dst.u.icmp.code =
                        *(u_int8_t *)NFA_DATA(tb[CTA_PROTO_ICMP_CODE-1]);
@@ -332,7 +332,7 @@ static struct ctl_table icmp_sysctl_table[] = {
                .mode           = 0644,
                .proc_handler   = &proc_dointvec_jiffies,
        },
-        {
+       {
                .ctl_name = 0
        }
 };
@@ -346,7 +346,7 @@ static struct ctl_table icmp_compat_sysctl_table[] = {
                .mode           = 0644,
                .proc_handler   = &proc_dointvec_jiffies,
        },
-        {
+       {
                .ctl_name = 0
        }
 };
index 86a92272b05398fa46206c3f8f6babbdc1057557..cf1010827be1f38036d4b48c693ebf0bfad9dd9e 100644 (file)
@@ -254,8 +254,9 @@ get_unique_tuple(struct nf_conntrack_tuple *tuple,
        if (maniptype == IP_NAT_MANIP_SRC) {
                if (find_appropriate_src(orig_tuple, tuple, range)) {
                        DEBUGP("get_unique_tuple: Found current src map\n");
-                       if (!nf_nat_used_tuple(tuple, ct))
-                               return;
+                       if (!(range->flags & IP_NAT_RANGE_PROTO_RANDOM))
+                               if (!nf_nat_used_tuple(tuple, ct))
+                                       return;
                }
        }
 
@@ -269,6 +270,13 @@ get_unique_tuple(struct nf_conntrack_tuple *tuple,
 
        proto = nf_nat_proto_find_get(orig_tuple->dst.protonum);
 
+       /* Change protocol info to have some randomization */
+       if (range->flags & IP_NAT_RANGE_PROTO_RANDOM) {
+               proto->unique_tuple(tuple, range, maniptype, ct);
+               nf_nat_proto_put(proto);
+               return;
+       }
+
        /* Only bother mapping if it's not already in range and unique */
        if ((!(range->flags & IP_NAT_RANGE_PROTO_SPECIFIED) ||
             proto->in_range(tuple, maniptype, &range->min, &range->max)) &&
@@ -444,8 +452,8 @@ int nf_nat_icmp_reply_translation(struct nf_conn *ct,
                     (*pskb)->nfctinfo == IP_CT_RELATED+IP_CT_IS_REPLY);
 
        /* Redirects on non-null nats must be dropped, else they'll
-           start talking to each other without our translation, and be
-           confused... --RR */
+          start talking to each other without our translation, and be
+          confused... --RR */
        if (inside->icmp.type == ICMP_REDIRECT) {
                /* If NAT isn't finished, assume it and drop. */
                if ((ct->status & IPS_NAT_DONE_MASK) != IPS_NAT_DONE_MASK)
@@ -461,13 +469,13 @@ int nf_nat_icmp_reply_translation(struct nf_conn *ct,
        if (!nf_ct_get_tuple(*pskb,
                             (*pskb)->nh.iph->ihl*4 + sizeof(struct icmphdr),
                             (*pskb)->nh.iph->ihl*4 +
-                            sizeof(struct icmphdr) + inside->ip.ihl*4,
-                            (u_int16_t)AF_INET,
-                            inside->ip.protocol,
-                            &inner,
-                            l3proto,
+                            sizeof(struct icmphdr) + inside->ip.ihl*4,
+                            (u_int16_t)AF_INET,
+                            inside->ip.protocol,
+                            &inner,
+                            l3proto,
                             __nf_ct_l4proto_find((u_int16_t)PF_INET,
-                                                 inside->ip.protocol)))
+                                                 inside->ip.protocol)))
                return 0;
 
        /* Change inner back to look like incoming packet.  We do the
index fb9ab0114c2380f32c2abee0c6a12a531657aa98..9cbf3f9be13b050ef013d1e9d60313f34630ce1b 100644 (file)
@@ -256,7 +256,7 @@ static int nat_rtp_rtcp(struct sk_buff **pskb, struct nf_conn *ct,
        if (set_h245_addr(pskb, data, dataoff, taddr,
                          &ct->tuplehash[!dir].tuple.dst.u3,
                          htons((port & htons(1)) ? nated_port + 1 :
-                                                   nated_port)) == 0) {
+                                                   nated_port)) == 0) {
                /* Save ports */
                info->rtp_port[i][dir] = rtp_port;
                info->rtp_port[i][!dir] = htons(nated_port);
index 98fbfc84d1830ecc77249dae123b2de86c7ca536..49a90c39ffce888de7c0bd664a70a9e279619b83 100644 (file)
@@ -176,10 +176,10 @@ nf_nat_mangle_tcp_packet(struct sk_buff **pskb,
        datalen = (*pskb)->len - iph->ihl*4;
        if ((*pskb)->ip_summed != CHECKSUM_PARTIAL) {
                tcph->check = 0;
-               tcph->check = tcp_v4_check(tcph, datalen,
+               tcph->check = tcp_v4_check(datalen,
                                           iph->saddr, iph->daddr,
                                           csum_partial((char *)tcph,
-                                                       datalen, 0));
+                                                       datalen, 0));
        } else
                nf_proto_csum_replace2(&tcph->check, *pskb,
                                       htons(oldlen), htons(datalen), 1);
@@ -223,7 +223,7 @@ nf_nat_mangle_udp_packet(struct sk_buff **pskb,
        /* UDP helpers might accidentally mangle the wrong packet */
        iph = (*pskb)->nh.iph;
        if ((*pskb)->len < iph->ihl*4 + sizeof(*udph) +
-                              match_offset + match_len)
+                              match_offset + match_len)
                return 0;
 
        if (!skb_make_writable(pskb, (*pskb)->len))
@@ -252,9 +252,9 @@ nf_nat_mangle_udp_packet(struct sk_buff **pskb,
        if ((*pskb)->ip_summed != CHECKSUM_PARTIAL) {
                udph->check = 0;
                udph->check = csum_tcpudp_magic(iph->saddr, iph->daddr,
-                                               datalen, IPPROTO_UDP,
-                                               csum_partial((char *)udph,
-                                                            datalen, 0));
+                                               datalen, IPPROTO_UDP,
+                                               csum_partial((char *)udph,
+                                                            datalen, 0));
                if (!udph->check)
                        udph->check = CSUM_MANGLED_0;
        } else
index 5df4fcae3ab68673c903804a906efc122fbcdb4f..7ba341c22eaabd440a72f6d6fe6056652c9237c3 100644 (file)
@@ -184,10 +184,10 @@ pptp_outbound_pkt(struct sk_buff **pskb,
 
        /* mangle packet */
        if (nf_nat_mangle_tcp_packet(pskb, ct, ctinfo,
-                                    cid_off + sizeof(struct pptp_pkt_hdr) +
-                                    sizeof(struct PptpControlHeader),
-                                    sizeof(new_callid), (char *)&new_callid,
-                                    sizeof(new_callid)) == 0)
+                                    cid_off + sizeof(struct pptp_pkt_hdr) +
+                                    sizeof(struct PptpControlHeader),
+                                    sizeof(new_callid), (char *)&new_callid,
+                                    sizeof(new_callid)) == 0)
                return NF_DROP;
        return NF_ACCEPT;
 }
@@ -276,7 +276,7 @@ pptp_inbound_pkt(struct sk_buff **pskb,
                ntohs(REQ_CID(pptpReq, pcid_off)), ntohs(new_pcid));
 
        if (nf_nat_mangle_tcp_packet(pskb, ct, ctinfo,
-                                    pcid_off + sizeof(struct pptp_pkt_hdr) +
+                                    pcid_off + sizeof(struct pptp_pkt_hdr) +
                                     sizeof(struct PptpControlHeader),
                                     sizeof(new_pcid), (char *)&new_pcid,
                                     sizeof(new_pcid)) == 0)
index dcfd772972d77cebb01729dafdd2ad4cbf58a657..6bc2f06de055952d6bad47434e860620cc0a8fd2 100644 (file)
@@ -44,7 +44,7 @@ icmp_unique_tuple(struct nf_conntrack_tuple *tuple,
 
        for (i = 0; i < range_size; i++, id++) {
                tuple->src.u.icmp.id = htons(ntohs(range->min.icmp.id) +
-                                            (id % range_size));
+                                            (id % range_size));
                if (!nf_nat_used_tuple(tuple, ct))
                        return 1;
        }
index 7e26a7e9bee15ea2e3445f27b70f4032bfceed20..439164c7a62664a0c632ebfa9d3cd0ad4bdf26d2 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <linux/types.h>
 #include <linux/init.h>
+#include <linux/random.h>
 #include <linux/ip.h>
 #include <linux/tcp.h>
 
@@ -75,6 +76,9 @@ tcp_unique_tuple(struct nf_conntrack_tuple *tuple,
                range_size = ntohs(range->max.tcp.port) - min + 1;
        }
 
+       if (range->flags & IP_NAT_RANGE_PROTO_RANDOM)
+               port =  net_random();
+
        for (i = 0; i < range_size; i++, port++) {
                *portptr = htons(min + port % range_size);
                if (!nf_nat_used_tuple(tuple, ct))
index ab0ce4c8699f5a34076e7a228041b4c77f9fae3f..8cae6e063bb6331b4ce720af5957b84439983b2d 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <linux/types.h>
 #include <linux/init.h>
+#include <linux/random.h>
 #include <linux/ip.h>
 #include <linux/udp.h>
 
@@ -73,6 +74,9 @@ udp_unique_tuple(struct nf_conntrack_tuple *tuple,
                range_size = ntohs(range->max.udp.port) - min + 1;
        }
 
+       if (range->flags & IP_NAT_RANGE_PROTO_RANDOM)
+               port = net_random();
+
        for (i = 0; i < range_size; i++, port++) {
                *portptr = htons(min + port % range_size);
                if (!nf_nat_used_tuple(tuple, ct))
index b868ee0195d4e9eb29440ef045d956c1525a1731..147a4370cf03e43f744600c5c3773454b54b5e68 100644 (file)
@@ -56,8 +56,8 @@ static struct
                /* PRE_ROUTING */
                {
                        .entry = {
-                               .target_offset = sizeof(struct ipt_entry),
-                               .next_offset = sizeof(struct ipt_standard),
+                               .target_offset = sizeof(struct ipt_entry),
+                               .next_offset = sizeof(struct ipt_standard),
                        },
                        .target = {
                                .target = {
@@ -71,8 +71,8 @@ static struct
                /* POST_ROUTING */
                {
                        .entry = {
-                               .target_offset = sizeof(struct ipt_entry),
-                               .next_offset = sizeof(struct ipt_standard),
+                               .target_offset = sizeof(struct ipt_entry),
+                               .next_offset = sizeof(struct ipt_standard),
                        },
                        .target = {
                                .target = {
@@ -86,8 +86,8 @@ static struct
                /* LOCAL_OUT */
                {
                        .entry = {
-                               .target_offset = sizeof(struct ipt_entry),
-                               .next_offset = sizeof(struct ipt_standard),
+                               .target_offset = sizeof(struct ipt_entry),
+                               .next_offset = sizeof(struct ipt_standard),
                        },
                        .target = {
                                .target = {
@@ -119,7 +119,7 @@ static struct
        }
 };
 
-static struct ipt_table nat_table = {
+static struct xt_table nat_table = {
        .name           = "nat",
        .valid_hooks    = NAT_VALID_HOOKS,
        .lock           = RW_LOCK_UNLOCKED,
@@ -145,7 +145,7 @@ static unsigned int ipt_snat_target(struct sk_buff **pskb,
 
        /* Connection must be valid and new. */
        NF_CT_ASSERT(ct && (ctinfo == IP_CT_NEW || ctinfo == IP_CT_RELATED ||
-                           ctinfo == IP_CT_RELATED + IP_CT_IS_REPLY));
+                           ctinfo == IP_CT_RELATED + IP_CT_IS_REPLY));
        NF_CT_ASSERT(out);
 
        return nf_nat_setup_info(ct, &mr->range[0], hooknum);
@@ -226,6 +226,10 @@ static int ipt_dnat_checkentry(const char *tablename,
                printk("DNAT: multiple ranges no longer supported\n");
                return 0;
        }
+       if (mr->range[0].flags & IP_NAT_RANGE_PROTO_RANDOM) {
+               printk("DNAT: port randomization not supported\n");
+               return 0;
+       }
        return 1;
 }
 
@@ -252,8 +256,8 @@ alloc_null_binding(struct nf_conn *ct,
 
 unsigned int
 alloc_null_binding_confirmed(struct nf_conn *ct,
-                             struct nf_nat_info *info,
-                             unsigned int hooknum)
+                            struct nf_nat_info *info,
+                            unsigned int hooknum)
 {
        __be32 ip
                = (HOOK2MANIP(hooknum) == IP_NAT_MANIP_SRC
@@ -290,7 +294,7 @@ int nf_nat_rule_find(struct sk_buff **pskb,
        return ret;
 }
 
-static struct ipt_target ipt_snat_reg = {
+static struct xt_target ipt_snat_reg = {
        .name           = "SNAT",
        .target         = ipt_snat_target,
        .targetsize     = sizeof(struct nf_nat_multi_range_compat),
index 3d524b957310b5e2e953d6187e8e69c8d0e78ddf..b12cd7c314caadefd43ea9e2f7842bb02fb07b28 100644 (file)
@@ -90,7 +90,7 @@ static int map_sip_addr(struct sk_buff **pskb, enum ip_conntrack_info ctinfo,
                return 1;
 
        if (!nf_nat_mangle_udp_packet(pskb, ct, ctinfo,
-                                     matchoff, matchlen, addr, addrlen))
+                                     matchoff, matchlen, addr, addrlen))
                return 0;
        *dptr = (*pskb)->data + (*pskb)->nh.iph->ihl*4 + sizeof(struct udphdr);
        return 1;
@@ -151,7 +151,7 @@ static unsigned int mangle_sip_packet(struct sk_buff **pskb,
                return 0;
 
        if (!nf_nat_mangle_udp_packet(pskb, ct, ctinfo,
-                                     matchoff, matchlen, buffer, bufflen))
+                                     matchoff, matchlen, buffer, bufflen))
                return 0;
 
        /* We need to reload this. Thanks Patrick. */
@@ -172,7 +172,7 @@ static int mangle_content_len(struct sk_buff **pskb,
 
        /* Get actual SDP lenght */
        if (ct_sip_get_info(ct, dptr, (*pskb)->len - dataoff, &matchoff,
-                           &matchlen, POS_SDP_HEADER) > 0) {
+                           &matchlen, POS_SDP_HEADER) > 0) {
 
                /* since ct_sip_get_info() give us a pointer passing 'v='
                   we need to add 2 bytes in this count. */
@@ -180,7 +180,7 @@ static int mangle_content_len(struct sk_buff **pskb,
 
                /* Now, update SDP length */
                if (ct_sip_get_info(ct, dptr, (*pskb)->len - dataoff, &matchoff,
-                                   &matchlen, POS_CONTENT) > 0) {
+                                   &matchlen, POS_CONTENT) > 0) {
 
                        bufflen = sprintf(buffer, "%u", c_len);
                        return nf_nat_mangle_udp_packet(pskb, ct, ctinfo,
@@ -205,17 +205,17 @@ static unsigned int mangle_sdp(struct sk_buff **pskb,
        /* Mangle owner and contact info. */
        bufflen = sprintf(buffer, "%u.%u.%u.%u", NIPQUAD(newip));
        if (!mangle_sip_packet(pskb, ctinfo, ct, &dptr, (*pskb)->len - dataoff,
-                              buffer, bufflen, POS_OWNER_IP4))
+                              buffer, bufflen, POS_OWNER_IP4))
                return 0;
 
        if (!mangle_sip_packet(pskb, ctinfo, ct, &dptr, (*pskb)->len - dataoff,
-                              buffer, bufflen, POS_CONNECTION_IP4))
+                              buffer, bufflen, POS_CONNECTION_IP4))
                return 0;
 
        /* Mangle media port. */
        bufflen = sprintf(buffer, "%u", port);
        if (!mangle_sip_packet(pskb, ctinfo, ct, &dptr, (*pskb)->len - dataoff,
-                              buffer, bufflen, POS_MEDIA))
+                              buffer, bufflen, POS_MEDIA))
                return 0;
 
        return mangle_content_len(pskb, ctinfo, ct, dptr);
index f12528fe1bf9f14ac552984997da16b7eeec7e3f..ce5c4939a6ee240d764e3e593429dae1523edb8a 100644 (file)
@@ -150,8 +150,8 @@ struct asn1_octstr
 };
 
 static void asn1_open(struct asn1_ctx *ctx,
-                      unsigned char *buf,
-                      unsigned int len)
+                     unsigned char *buf,
+                     unsigned int len)
 {
        ctx->begin = buf;
        ctx->end = buf + len;
@@ -186,9 +186,9 @@ static unsigned char asn1_tag_decode(struct asn1_ctx *ctx, unsigned int *tag)
 }
 
 static unsigned char asn1_id_decode(struct asn1_ctx *ctx,
-                                    unsigned int *cls,
-                                    unsigned int *con,
-                                    unsigned int *tag)
+                                   unsigned int *cls,
+                                   unsigned int *con,
+                                   unsigned int *tag)
 {
        unsigned char ch;
 
@@ -207,8 +207,8 @@ static unsigned char asn1_id_decode(struct asn1_ctx *ctx,
 }
 
 static unsigned char asn1_length_decode(struct asn1_ctx *ctx,
-                                        unsigned int *def,
-                                        unsigned int *len)
+                                       unsigned int *def,
+                                       unsigned int *len)
 {
        unsigned char ch, cnt;
 
@@ -239,10 +239,10 @@ static unsigned char asn1_length_decode(struct asn1_ctx *ctx,
 }
 
 static unsigned char asn1_header_decode(struct asn1_ctx *ctx,
-                                        unsigned char **eoc,
-                                        unsigned int *cls,
-                                        unsigned int *con,
-                                        unsigned int *tag)
+                                       unsigned char **eoc,
+                                       unsigned int *cls,
+                                       unsigned int *con,
+                                       unsigned int *tag)
 {
        unsigned int def, len;
 
@@ -297,8 +297,8 @@ static unsigned char asn1_null_decode(struct asn1_ctx *ctx, unsigned char *eoc)
 }
 
 static unsigned char asn1_long_decode(struct asn1_ctx *ctx,
-                                      unsigned char *eoc,
-                                      long *integer)
+                                     unsigned char *eoc,
+                                     long *integer)
 {
        unsigned char ch;
        unsigned int  len;
@@ -325,8 +325,8 @@ static unsigned char asn1_long_decode(struct asn1_ctx *ctx,
 }
 
 static unsigned char asn1_uint_decode(struct asn1_ctx *ctx,
-                                      unsigned char *eoc,
-                                      unsigned int *integer)
+                                     unsigned char *eoc,
+                                     unsigned int *integer)
 {
        unsigned char ch;
        unsigned int  len;
@@ -354,8 +354,8 @@ static unsigned char asn1_uint_decode(struct asn1_ctx *ctx,
 }
 
 static unsigned char asn1_ulong_decode(struct asn1_ctx *ctx,
-                                       unsigned char *eoc,
-                                       unsigned long *integer)
+                                      unsigned char *eoc,
+                                      unsigned long *integer)
 {
        unsigned char ch;
        unsigned int  len;
@@ -383,9 +383,9 @@ static unsigned char asn1_ulong_decode(struct asn1_ctx *ctx,
 }
 
 static unsigned char asn1_octets_decode(struct asn1_ctx *ctx,
-                                        unsigned char *eoc,
-                                        unsigned char **octets,
-                                        unsigned int *len)
+                                       unsigned char *eoc,
+                                       unsigned char **octets,
+                                       unsigned int *len)
 {
        unsigned char *ptr;
 
@@ -411,7 +411,7 @@ static unsigned char asn1_octets_decode(struct asn1_ctx *ctx,
 }
 
 static unsigned char asn1_subid_decode(struct asn1_ctx *ctx,
-                                       unsigned long *subid)
+                                      unsigned long *subid)
 {
        unsigned char ch;
 
@@ -428,9 +428,9 @@ static unsigned char asn1_subid_decode(struct asn1_ctx *ctx,
 }
 
 static unsigned char asn1_oid_decode(struct asn1_ctx *ctx,
-                                     unsigned char *eoc,
-                                     unsigned long **oid,
-                                     unsigned int *len)
+                                    unsigned char *eoc,
+                                    unsigned long **oid,
+                                    unsigned int *len)
 {
        unsigned long subid;
        unsigned int  size;
@@ -611,9 +611,9 @@ struct snmp_v1_trap
 #define SERR_EOM    2
 
 static inline void mangle_address(unsigned char *begin,
-                                  unsigned char *addr,
-                                  const struct oct1_map *map,
-                                  __sum16 *check);
+                                 unsigned char *addr,
+                                 const struct oct1_map *map,
+                                 __sum16 *check);
 struct snmp_cnv
 {
        unsigned int class;
@@ -644,8 +644,8 @@ static struct snmp_cnv snmp_conv [] =
 };
 
 static unsigned char snmp_tag_cls2syntax(unsigned int tag,
-                                         unsigned int cls,
-                                         unsigned short *syntax)
+                                        unsigned int cls,
+                                        unsigned short *syntax)
 {
        struct snmp_cnv *cnv;
 
@@ -662,7 +662,7 @@ static unsigned char snmp_tag_cls2syntax(unsigned int tag,
 }
 
 static unsigned char snmp_object_decode(struct asn1_ctx *ctx,
-                                        struct snmp_object **obj)
+                                       struct snmp_object **obj)
 {
        unsigned int cls, con, tag, len, idlen;
        unsigned short type;
@@ -714,7 +714,7 @@ static unsigned char snmp_object_decode(struct asn1_ctx *ctx,
                                return 0;
                        }
                        *obj = kmalloc(sizeof(struct snmp_object) + len,
-                                      GFP_ATOMIC);
+                                      GFP_ATOMIC);
                        if (*obj == NULL) {
                                kfree(id);
                                if (net_ratelimit())
@@ -730,7 +730,7 @@ static unsigned char snmp_object_decode(struct asn1_ctx *ctx,
                                return 0;
                        }
                        *obj = kmalloc(sizeof(struct snmp_object) + len,
-                                      GFP_ATOMIC);
+                                      GFP_ATOMIC);
                        if (*obj == NULL) {
                                kfree(id);
                                if (net_ratelimit())
@@ -834,7 +834,7 @@ static unsigned char snmp_object_decode(struct asn1_ctx *ctx,
 }
 
 static unsigned char snmp_request_decode(struct asn1_ctx *ctx,
-                                         struct snmp_request *request)
+                                        struct snmp_request *request)
 {
        unsigned int cls, con, tag;
        unsigned char *end;
@@ -874,9 +874,9 @@ static unsigned char snmp_request_decode(struct asn1_ctx *ctx,
  * code example in the draft.
  */
 static void fast_csum(__sum16 *csum,
-                      const unsigned char *optr,
-                      const unsigned char *nptr,
-                      int offset)
+                     const unsigned char *optr,
+                     const unsigned char *nptr,
+                     int offset)
 {
        unsigned char s[4];
 
@@ -899,9 +899,9 @@ static void fast_csum(__sum16 *csum,
  *      - addr points to the start of the address
  */
 static inline void mangle_address(unsigned char *begin,
-                                  unsigned char *addr,
-                                  const struct oct1_map *map,
-                                  __sum16 *check)
+                                 unsigned char *addr,
+                                 const struct oct1_map *map,
+                                 __sum16 *check)
 {
        if (map->from == NOCT1(addr)) {
                u_int32_t old;
@@ -914,7 +914,7 @@ static inline void mangle_address(unsigned char *begin,
                /* Update UDP checksum if being used */
                if (*check) {
                        fast_csum(check,
-                                 &map->from, &map->to, addr - begin);
+                                 &map->from, &map->to, addr - begin);
 
                }
 
@@ -925,9 +925,9 @@ static inline void mangle_address(unsigned char *begin,
 }
 
 static unsigned char snmp_trap_decode(struct asn1_ctx *ctx,
-                                      struct snmp_v1_trap *trap,
-                                      const struct oct1_map *map,
-                                      __sum16 *check)
+                                     struct snmp_v1_trap *trap,
+                                     const struct oct1_map *map,
+                                     __sum16 *check)
 {
        unsigned int cls, con, tag, len;
        unsigned char *end;
@@ -1019,9 +1019,9 @@ static void hex_dump(unsigned char *buf, size_t len)
  * (And this is the fucking 'basic' method).
  */
 static int snmp_parse_mangle(unsigned char *msg,
-                             u_int16_t len,
-                             const struct oct1_map *map,
-                             __sum16 *check)
+                            u_int16_t len,
+                            const struct oct1_map *map,
+                            __sum16 *check)
 {
        unsigned char *eoc, *end;
        unsigned int cls, con, tag, vers, pdutype;
@@ -1191,8 +1191,8 @@ static int snmp_parse_mangle(unsigned char *msg,
  * SNMP translation routine.
  */
 static int snmp_translate(struct nf_conn *ct,
-                          enum ip_conntrack_info ctinfo,
-                          struct sk_buff **pskb)
+                         enum ip_conntrack_info ctinfo,
+                         struct sk_buff **pskb)
 {
        struct iphdr *iph = (*pskb)->nh.iph;
        struct udphdr *udph = (struct udphdr *)((__be32 *)iph + iph->ihl);
@@ -1219,7 +1219,7 @@ static int snmp_translate(struct nf_conn *ct,
                return NF_ACCEPT;
 
        if (!snmp_parse_mangle((unsigned char *)udph + sizeof(struct udphdr),
-                              paylen, &map, &udph->check)) {
+                              paylen, &map, &udph->check)) {
                if (net_ratelimit())
                        printk(KERN_WARNING "bsalg: parser failed\n");
                return NF_DROP;
index 00d6dea9f7f3440aa1b6369a09f790e87e6ef72d..e4d3ef17d45b610768f37e8fa2d026ee4eac6ba7 100644 (file)
 #define DEBUGP(format, args...)
 #endif
 
-#define HOOKNAME(hooknum) ((hooknum) == NF_IP_POST_ROUTING ? "POST_ROUTING"  \
-                          : ((hooknum) == NF_IP_PRE_ROUTING ? "PRE_ROUTING" \
-                             : ((hooknum) == NF_IP_LOCAL_OUT ? "LOCAL_OUT"  \
-                                : ((hooknum) == NF_IP_LOCAL_IN ? "LOCAL_IN"  \
-                                   : "*ERROR*")))
-
 #ifdef CONFIG_XFRM
 static void nat_decode_session(struct sk_buff *skb, struct flowi *fl)
 {
@@ -102,8 +96,8 @@ nf_nat_fn(unsigned int hooknum,
           protocol. 8) --RR */
        if (!ct) {
                /* Exception: ICMP redirect to new connection (not in
-                   hash table yet).  We must not let this through, in
-                   case we're doing NAT to the same network. */
+                  hash table yet).  We must not let this through, in
+                  case we're doing NAT to the same network. */
                if ((*pskb)->nh.iph->protocol == IPPROTO_ICMP) {
                        struct icmphdr _hdr, *hp;
 
@@ -147,7 +141,7 @@ nf_nat_fn(unsigned int hooknum,
                        if (unlikely(nf_ct_is_confirmed(ct)))
                                /* NAT module was loaded late */
                                ret = alloc_null_binding_confirmed(ct, info,
-                                                                  hooknum);
+                                                                  hooknum);
                        else if (hooknum == NF_IP_LOCAL_IN)
                                /* LOCAL_IN hook doesn't have a chain!  */
                                ret = alloc_null_binding(ct, info, hooknum);
@@ -177,10 +171,10 @@ nf_nat_fn(unsigned int hooknum,
 
 static unsigned int
 nf_nat_in(unsigned int hooknum,
-          struct sk_buff **pskb,
-          const struct net_device *in,
-          const struct net_device *out,
-          int (*okfn)(struct sk_buff *))
+         struct sk_buff **pskb,
+         const struct net_device *in,
+         const struct net_device *out,
+         int (*okfn)(struct sk_buff *))
 {
        unsigned int ret;
        __be32 daddr = (*pskb)->nh.iph->daddr;
@@ -275,9 +269,9 @@ nf_nat_adjust(unsigned int hooknum,
 
        ct = nf_ct_get(*pskb, &ctinfo);
        if (ct && test_bit(IPS_SEQ_ADJUST_BIT, &ct->status)) {
-               DEBUGP("nf_nat_standalone: adjusting sequence number\n");
-               if (!nf_nat_seq_adjust(pskb, ct, ctinfo))
-                       return NF_DROP;
+               DEBUGP("nf_nat_standalone: adjusting sequence number\n");
+               if (!nf_nat_seq_adjust(pskb, ct, ctinfo))
+                       return NF_DROP;
        }
        return NF_ACCEPT;
 }
index cd873da54cbe5b5876abe933fa7287386e3d31cc..ccb199e9dd8b680dcbb8930a825aa1d43810b89e 100644 (file)
@@ -266,7 +266,7 @@ static int snmp_seq_show(struct seq_file *seq, void *v)
 
        for (i = 0; snmp4_ipstats_list[i].name != NULL; i++)
                seq_printf(seq, " %lu",
-                          fold_field((void **) ip_statistics, 
+                          fold_field((void **) ip_statistics,
                                      snmp4_ipstats_list[i].entry));
 
        seq_puts(seq, "\nIcmp:");
@@ -276,7 +276,7 @@ static int snmp_seq_show(struct seq_file *seq, void *v)
        seq_puts(seq, "\nIcmp:");
        for (i = 0; snmp4_icmp_list[i].name != NULL; i++)
                seq_printf(seq, " %lu",
-                          fold_field((void **) icmp_statistics, 
+                          fold_field((void **) icmp_statistics,
                                      snmp4_icmp_list[i].entry));
 
        seq_puts(seq, "\nTcp:");
@@ -288,7 +288,7 @@ static int snmp_seq_show(struct seq_file *seq, void *v)
                /* MaxConn field is signed, RFC 2012 */
                if (snmp4_tcp_list[i].entry == TCP_MIB_MAXCONN)
                        seq_printf(seq, " %ld",
-                                  fold_field((void **) tcp_statistics, 
+                                  fold_field((void **) tcp_statistics,
                                              snmp4_tcp_list[i].entry));
                else
                        seq_printf(seq, " %lu",
@@ -303,7 +303,7 @@ static int snmp_seq_show(struct seq_file *seq, void *v)
        seq_puts(seq, "\nUdp:");
        for (i = 0; snmp4_udp_list[i].name != NULL; i++)
                seq_printf(seq, " %lu",
-                          fold_field((void **) udp_statistics, 
+                          fold_field((void **) udp_statistics,
                                      snmp4_udp_list[i].entry));
 
        /* the UDP and UDP-Lite MIBs are the same */
@@ -348,7 +348,7 @@ static int netstat_seq_show(struct seq_file *seq, void *v)
        seq_puts(seq, "\nTcpExt:");
        for (i = 0; snmp4_net_list[i].name != NULL; i++)
                seq_printf(seq, " %lu",
-                          fold_field((void **) net_statistics, 
+                          fold_field((void **) net_statistics,
                                      snmp4_net_list[i].entry));
 
        seq_putc(seq, '\n');
index 05f5114828eaf04d0393dda48038ed1c536639b6..6cd6340de8bdb18b484551236b35063df90c4b7d 100644 (file)
@@ -74,7 +74,7 @@ int inet_add_protocol(struct net_protocol *prot, unsigned char protocol)
 /*
  *     Remove a protocol from the hash tables.
  */
+
 int inet_del_protocol(struct net_protocol *prot, unsigned char protocol)
 {
        int hash, ret;
index a6c63bbd9ddb198dd77e88f9c8ee22002382516c..931084bfb57255afe5d1676a3bcea57e29bfa86b 100644 (file)
@@ -95,7 +95,7 @@ static void raw_v4_hash(struct sock *sk)
 
 static void raw_v4_unhash(struct sock *sk)
 {
-       write_lock_bh(&raw_v4_lock);
+       write_lock_bh(&raw_v4_lock);
        if (sk_del_node_init(sk))
                sock_prot_dec_use(sk->sk_prot);
        write_unlock_bh(&raw_v4_lock);
@@ -238,7 +238,7 @@ void raw_err (struct sock *sk, struct sk_buff *skb, u32 info)
 static int raw_rcv_skb(struct sock * sk, struct sk_buff * skb)
 {
        /* Charge it to the socket. */
-       
+
        if (sock_queue_rcv_skb(sk, skb) < 0) {
                /* FIXME: increment a raw drops counter here */
                kfree_skb(skb);
@@ -263,7 +263,7 @@ int raw_rcv(struct sock *sk, struct sk_buff *skb)
 }
 
 static int raw_send_hdrinc(struct sock *sk, void *from, size_t length,
-                       struct rtable *rt, 
+                       struct rtable *rt,
                        unsigned int flags)
 {
        struct inet_sock *inet = inet_sk(sk);
@@ -285,7 +285,7 @@ static int raw_send_hdrinc(struct sock *sk, void *from, size_t length,
        skb = sock_alloc_send_skb(sk, length+hh_len+15,
                                  flags&MSG_DONTWAIT, &err);
        if (skb == NULL)
-               goto error; 
+               goto error;
        skb_reserve(skb, hh_len);
 
        skb->priority = sk->sk_priority;
@@ -326,7 +326,7 @@ error_fault:
        kfree_skb(skb);
 error:
        IP_INC_STATS(IPSTATS_MIB_OUTDISCARDS);
-       return err; 
+       return err;
 }
 
 static int raw_probe_proto_opt(struct flowi *fl, struct msghdr *msg)
@@ -399,9 +399,9 @@ static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
        err = -EOPNOTSUPP;
        if (msg->msg_flags & MSG_OOB)   /* Mirror BSD error message */
                goto out;               /* compatibility */
-                        
+
        /*
-        *      Get and verify the address. 
+        *      Get and verify the address.
         */
 
        if (msg->msg_namelen) {
@@ -426,7 +426,7 @@ static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
                 */
        } else {
                err = -EDESTADDRREQ;
-               if (sk->sk_state != TCP_ESTABLISHED) 
+               if (sk->sk_state != TCP_ESTABLISHED)
                        goto out;
                daddr = inet->daddr;
        }
@@ -480,7 +480,7 @@ static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
                                                .saddr = saddr,
                                                .tos = tos } },
                                    .proto = inet->hdrincl ? IPPROTO_RAW :
-                                                            sk->sk_protocol,
+                                                            sk->sk_protocol,
                                  };
                if (!inet->hdrincl) {
                        err = raw_probe_proto_opt(&fl, msg);
@@ -489,7 +489,7 @@ static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
                }
 
                security_sk_classify_flow(sk, &fl);
-               err = ip_route_output_flow(&rt, &fl, sk, !(msg->msg_flags&MSG_DONTWAIT));
+               err = ip_route_output_flow(&rt, &fl, sk, 1);
        }
        if (err)
                goto done;
@@ -503,9 +503,9 @@ static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
 back_from_confirm:
 
        if (inet->hdrincl)
-               err = raw_send_hdrinc(sk, msg->msg_iov, len, 
+               err = raw_send_hdrinc(sk, msg->msg_iov, len,
                                        rt, msg->msg_flags);
-       
+
         else {
                if (!ipc.addr)
                        ipc.addr = rt->rt_dst;
@@ -538,7 +538,7 @@ do_confirm:
 
 static void raw_close(struct sock *sk, long timeout)
 {
-        /*
+       /*
         * Raw sockets may have direct kernel refereneces. Kill them.
         */
        ip_ra_control(sk, 0, NULL);
@@ -861,7 +861,7 @@ static __inline__ char *get_raw_sock(struct sock *sp, char *tmpbuf, int i)
 
        sprintf(tmpbuf, "%4d: %08X:%04X %08X:%04X"
                " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p",
-               i, src, srcp, dest, destp, sp->sk_state, 
+               i, src, srcp, dest, destp, sp->sk_state,
                atomic_read(&sp->sk_wmem_alloc),
                atomic_read(&sp->sk_rmem_alloc),
                0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
index 2daa0dc19d339e5dd3659ca63a9118279d4cc039..5b3834b38a2d5839436acd84684ea6b131fb25ec 100644 (file)
@@ -20,7 +20,7 @@
  *             (rco@di.uminho.pt)      Routing table insertion and update
  *             Linus Torvalds  :       Rewrote bits to be sensible
  *             Alan Cox        :       Added BSD route gw semantics
- *             Alan Cox        :       Super /proc >4K 
+ *             Alan Cox        :       Super /proc >4K
  *             Alan Cox        :       MTU in route table
  *             Alan Cox        :       MSS actually. Also added the window
  *                                     clamper.
@@ -38,7 +38,7 @@
  *             Alan Cox        :       Faster /proc handling
  *     Alexey Kuznetsov        :       Massive rework to support tree based routing,
  *                                     routing caches and better behaviour.
- *             
+ *
  *             Olaf Erb        :       irtt wasn't being copied right.
  *             Bjorn Ekwall    :       Kerneld route support.
  *             Alan Cox        :       Multicast fixed (I hope)
@@ -289,7 +289,7 @@ static struct rtable *rt_cache_get_next(struct seq_file *seq, struct rtable *r)
 {
        struct rt_cache_iter_state *st = rcu_dereference(seq->private);
 
-       r = r->u.rt_next;
+       r = r->u.dst.rt_next;
        while (!r) {
                rcu_read_unlock_bh();
                if (--st->bucket < 0)
@@ -361,8 +361,8 @@ static int rt_cache_seq_show(struct seq_file *seq, void *v)
                                       dev_queue_xmit) : 0,
                        r->rt_spec_dst);
                seq_printf(seq, "%-127s\n", temp);
-        }
-       return 0;
+       }
+       return 0;
 }
 
 static struct seq_operations rt_cache_seq_ops = {
@@ -429,7 +429,7 @@ static void *rt_cpu_seq_next(struct seq_file *seq, void *v, loff_t *pos)
                return &per_cpu(rt_cache_stat, cpu);
        }
        return NULL;
-       
+
 }
 
 static void rt_cpu_seq_stop(struct seq_file *seq, void *v)
@@ -445,7 +445,7 @@ static int rt_cpu_seq_show(struct seq_file *seq, void *v)
                seq_printf(seq, "entries  in_hit in_slow_tot in_slow_mc in_no_route in_brd in_martian_dst in_martian_src  out_hit out_slow_tot out_slow_mc  gc_total gc_ignored gc_goal_miss gc_dst_overflow in_hlist_search out_hlist_search\n");
                return 0;
        }
-       
+
        seq_printf(seq,"%08x  %08x %08x %08x %08x %08x %08x %08x "
                   " %08x %08x %08x %08x %08x %08x %08x %08x %08x \n",
                   atomic_read(&ipv4_dst_ops.entries),
@@ -459,7 +459,7 @@ static int rt_cpu_seq_show(struct seq_file *seq, void *v)
 
                   st->out_hit,
                   st->out_slow_tot,
-                  st->out_slow_mc, 
+                  st->out_slow_mc,
 
                   st->gc_total,
                   st->gc_ignored,
@@ -493,7 +493,7 @@ static struct file_operations rt_cpu_seq_fops = {
 };
 
 #endif /* CONFIG_PROC_FS */
-  
+
 static __inline__ void rt_free(struct rtable *rt)
 {
        multipath_remove(rt);
@@ -512,7 +512,7 @@ static __inline__ int rt_fast_clean(struct rtable *rth)
        /* Kill broadcast/multicast entries very aggresively, if they
           collide in hash table with more useful entries */
        return (rth->rt_flags & (RTCF_BROADCAST | RTCF_MULTICAST)) &&
-               rth->fl.iif && rth->u.rt_next;
+               rth->fl.iif && rth->u.dst.rt_next;
 }
 
 static __inline__ int rt_valuable(struct rtable *rth)
@@ -595,10 +595,10 @@ static struct rtable **rt_remove_balanced_route(struct rtable **chain_head,
                if (((*rthp)->u.dst.flags & DST_BALANCED) != 0  &&
                    compare_keys(&(*rthp)->fl, &expentry->fl)) {
                        if (*rthp == expentry) {
-                               *rthp = rth->u.rt_next;
+                               *rthp = rth->u.dst.rt_next;
                                continue;
                        } else {
-                               *rthp = rth->u.rt_next;
+                               *rthp = rth->u.dst.rt_next;
                                rt_free(rth);
                                if (removed_count)
                                        ++(*removed_count);
@@ -606,9 +606,9 @@ static struct rtable **rt_remove_balanced_route(struct rtable **chain_head,
                } else {
                        if (!((*rthp)->u.dst.flags & DST_BALANCED) &&
                            passedexpired && !nextstep)
-                               nextstep = &rth->u.rt_next;
+                               nextstep = &rth->u.dst.rt_next;
 
-                       rthp = &rth->u.rt_next;
+                       rthp = &rth->u.dst.rt_next;
                }
        }
 
@@ -649,12 +649,12 @@ static void rt_check_expire(unsigned long dummy)
                                /* Entry is expired even if it is in use */
                                if (time_before_eq(now, rth->u.dst.expires)) {
                                        tmo >>= 1;
-                                       rthp = &rth->u.rt_next;
+                                       rthp = &rth->u.dst.rt_next;
                                        continue;
                                }
                        } else if (!rt_may_expire(rth, tmo, ip_rt_gc_timeout)) {
                                tmo >>= 1;
-                               rthp = &rth->u.rt_next;
+                               rthp = &rth->u.dst.rt_next;
                                continue;
                        }
 
@@ -668,12 +668,12 @@ static void rt_check_expire(unsigned long dummy)
                                if (!rthp)
                                        break;
                        } else {
-                               *rthp = rth->u.rt_next;
+                               *rthp = rth->u.dst.rt_next;
                                rt_free(rth);
                        }
 #else /* CONFIG_IP_ROUTE_MULTIPATH_CACHED */
-                       *rthp = rth->u.rt_next;
-                       rt_free(rth);
+                       *rthp = rth->u.dst.rt_next;
+                       rt_free(rth);
 #endif /* CONFIG_IP_ROUTE_MULTIPATH_CACHED */
                }
                spin_unlock(rt_hash_lock_addr(i));
@@ -706,7 +706,7 @@ static void rt_run_flush(unsigned long dummy)
                spin_unlock_bh(rt_hash_lock_addr(i));
 
                for (; rth; rth = next) {
-                       next = rth->u.rt_next;
+                       next = rth->u.dst.rt_next;
                        rt_free(rth);
                }
        }
@@ -739,7 +739,7 @@ void rt_cache_flush(int delay)
 
                if (user_mode && tmo < ip_rt_max_delay-ip_rt_min_delay)
                        tmo = 0;
-               
+
                if (delay > tmo)
                        delay = tmo;
        }
@@ -840,7 +840,7 @@ static int rt_garbage_collect(void)
                        while ((rth = *rthp) != NULL) {
                                if (!rt_may_expire(rth, tmo, expire)) {
                                        tmo >>= 1;
-                                       rthp = &rth->u.rt_next;
+                                       rthp = &rth->u.dst.rt_next;
                                        continue;
                                }
 #ifdef CONFIG_IP_ROUTE_MULTIPATH_CACHED
@@ -858,12 +858,12 @@ static int rt_garbage_collect(void)
                                        if (!rthp)
                                                break;
                                } else {
-                                       *rthp = rth->u.rt_next;
+                                       *rthp = rth->u.dst.rt_next;
                                        rt_free(rth);
                                        goal--;
                                }
 #else /* CONFIG_IP_ROUTE_MULTIPATH_CACHED */
-                               *rthp = rth->u.rt_next;
+                               *rthp = rth->u.dst.rt_next;
                                rt_free(rth);
                                goal--;
 #endif /* CONFIG_IP_ROUTE_MULTIPATH_CACHED */
@@ -947,13 +947,13 @@ restart:
                if (compare_keys(&rth->fl, &rt->fl)) {
 #endif
                        /* Put it first */
-                       *rthp = rth->u.rt_next;
+                       *rthp = rth->u.dst.rt_next;
                        /*
                         * Since lookup is lockfree, the deletion
                         * must be visible to another weakly ordered CPU before
                         * the insertion at the start of the hash chain.
                         */
-                       rcu_assign_pointer(rth->u.rt_next,
+                       rcu_assign_pointer(rth->u.dst.rt_next,
                                           rt_hash_table[hash].chain);
                        /*
                         * Since lookup is lockfree, the update writes
@@ -983,7 +983,7 @@ restart:
 
                chain_length++;
 
-               rthp = &rth->u.rt_next;
+               rthp = &rth->u.dst.rt_next;
        }
 
        if (cand) {
@@ -994,7 +994,7 @@ restart:
                 * only 2 entries per bucket. We will see.
                 */
                if (chain_length > ip_rt_gc_elasticity) {
-                       *candp = cand->u.rt_next;
+                       *candp = cand->u.dst.rt_next;
                        rt_free(cand);
                }
        }
@@ -1034,13 +1034,13 @@ restart:
                }
        }
 
-       rt->u.rt_next = rt_hash_table[hash].chain;
+       rt->u.dst.rt_next = rt_hash_table[hash].chain;
 #if RT_CACHE_DEBUG >= 2
-       if (rt->u.rt_next) {
+       if (rt->u.dst.rt_next) {
                struct rtable *trt;
                printk(KERN_DEBUG "rt_cache @%02x: %u.%u.%u.%u", hash,
                       NIPQUAD(rt->rt_dst));
-               for (trt = rt->u.rt_next; trt; trt = trt->u.rt_next)
+               for (trt = rt->u.dst.rt_next; trt; trt = trt->u.dst.rt_next)
                        printk(" . %u.%u.%u.%u", NIPQUAD(trt->rt_dst));
                printk("\n");
        }
@@ -1104,7 +1104,7 @@ void __ip_select_ident(struct iphdr *iph, struct dst_entry *dst, int more)
                        return;
                }
        } else
-               printk(KERN_DEBUG "rt_bind_peer(0) @%p\n", 
+               printk(KERN_DEBUG "rt_bind_peer(0) @%p\n",
                       __builtin_return_address(0));
 
        ip_select_fb_ident(iph);
@@ -1117,9 +1117,9 @@ static void rt_del(unsigned hash, struct rtable *rt)
        spin_lock_bh(rt_hash_lock_addr(hash));
        ip_rt_put(rt);
        for (rthp = &rt_hash_table[hash].chain; *rthp;
-            rthp = &(*rthp)->u.rt_next)
+            rthp = &(*rthp)->u.dst.rt_next)
                if (*rthp == rt) {
-                       *rthp = rt->u.rt_next;
+                       *rthp = rt->u.dst.rt_next;
                        rt_free(rt);
                        break;
                }
@@ -1167,7 +1167,7 @@ void ip_rt_redirect(__be32 old_gw, __be32 daddr, __be32 new_gw,
                                    rth->fl.fl4_src != skeys[i] ||
                                    rth->fl.oif != ikeys[k] ||
                                    rth->fl.iif != 0) {
-                                       rthp = &rth->u.rt_next;
+                                       rthp = &rth->u.dst.rt_next;
                                        continue;
                                }
 
@@ -1190,7 +1190,7 @@ void ip_rt_redirect(__be32 old_gw, __be32 daddr, __be32 new_gw,
 
                                /* Copy all the information. */
                                *rt = *rth;
-                               INIT_RCU_HEAD(&rt->u.dst.rcu_head);
+                               INIT_RCU_HEAD(&rt->u.dst.rcu_head);
                                rt->u.dst.__use         = 1;
                                atomic_set(&rt->u.dst.__refcnt, 1);
                                rt->u.dst.child         = NULL;
@@ -1225,11 +1225,11 @@ void ip_rt_redirect(__be32 old_gw, __be32 daddr, __be32 new_gw,
                                        rt_drop(rt);
                                        goto do_next;
                                }
-                               
+
                                netevent.old = &rth->u.dst;
                                netevent.new = &rt->u.dst;
-                               call_netevent_notifiers(NETEVENT_REDIRECT, 
-                                                       &netevent);
+                               call_netevent_notifiers(NETEVENT_REDIRECT,
+                                                       &netevent);
 
                                rt_del(hash, rth);
                                if (!rt_intern_hash(hash, rt, &rt))
@@ -1343,7 +1343,7 @@ void ip_rt_send_redirect(struct sk_buff *skb)
 #endif
        }
 out:
-        in_dev_put(in_dev);
+       in_dev_put(in_dev);
 }
 
 static int ip_error(struct sk_buff *skb)
@@ -1379,7 +1379,7 @@ static int ip_error(struct sk_buff *skb)
 
 out:   kfree_skb(skb);
        return 0;
-} 
+}
 
 /*
  *     The last two values are not from the RFC but
@@ -1392,7 +1392,7 @@ static const unsigned short mtu_plateau[] =
 static __inline__ unsigned short guess_mtu(unsigned short old_mtu)
 {
        int i;
-       
+
        for (i = 0; i < ARRAY_SIZE(mtu_plateau); i++)
                if (old_mtu > mtu_plateau[i])
                        return mtu_plateau[i];
@@ -1416,7 +1416,7 @@ unsigned short ip_rt_frag_needed(struct iphdr *iph, unsigned short new_mtu)
 
                rcu_read_lock();
                for (rth = rcu_dereference(rt_hash_table[hash].chain); rth;
-                    rth = rcu_dereference(rth->u.rt_next)) {
+                    rth = rcu_dereference(rth->u.dst.rt_next)) {
                        if (rth->fl.fl4_dst == daddr &&
                            rth->fl.fl4_src == skeys[i] &&
                            rth->rt_dst  == daddr &&
@@ -1436,7 +1436,7 @@ unsigned short ip_rt_frag_needed(struct iphdr *iph, unsigned short new_mtu)
                                        mtu = guess_mtu(old_mtu);
                                }
                                if (mtu <= rth->u.dst.metrics[RTAX_MTU-1]) {
-                                       if (mtu < rth->u.dst.metrics[RTAX_MTU-1]) { 
+                                       if (mtu < rth->u.dst.metrics[RTAX_MTU-1]) {
                                                dst_confirm(&rth->u.dst);
                                                if (mtu < ip_rt_min_pmtu) {
                                                        mtu = ip_rt_min_pmtu;
@@ -1600,7 +1600,7 @@ static void rt_set_nexthop(struct rtable *rt, struct fib_result *res, u32 itag)
 #endif
        set_class_tag(rt, itag);
 #endif
-        rt->rt_type = res->type;
+       rt->rt_type = res->type;
 }
 
 static int ip_route_input_mc(struct sk_buff *skb, __be32 daddr, __be32 saddr,
@@ -1714,11 +1714,11 @@ static void ip_handle_martian_source(struct net_device *dev,
 #endif
 }
 
-static inline int __mkroute_input(struct sk_buff *skb, 
-                                 struct fib_result* res, 
-                                 struct in_device *in_dev, 
+static inline int __mkroute_input(struct sk_buff *skb,
+                                 struct fib_result* res,
+                                 struct in_device *in_dev,
                                  __be32 daddr, __be32 saddr, u32 tos,
-                                 struct rtable **result) 
+                                 struct rtable **result)
 {
 
        struct rtable *rth;
@@ -1738,12 +1738,12 @@ static inline int __mkroute_input(struct sk_buff *skb,
        }
 
 
-       err = fib_validate_source(saddr, daddr, tos, FIB_RES_OIF(*res), 
+       err = fib_validate_source(saddr, daddr, tos, FIB_RES_OIF(*res),
                                  in_dev->dev, &spec_dst, &itag);
        if (err < 0) {
-               ip_handle_martian_source(in_dev->dev, in_dev, skb, daddr, 
+               ip_handle_martian_source(in_dev->dev, in_dev, skb, daddr,
                                         saddr);
-               
+
                err = -EINVAL;
                goto cleanup;
        }
@@ -1811,10 +1811,10 @@ static inline int __mkroute_input(struct sk_buff *skb,
        /* release the working reference to the output device */
        in_dev_put(out_dev);
        return err;
-}                                              
+}
 
-static inline int ip_mkroute_input_def(struct sk_buff *skb, 
-                                      struct fib_result* res, 
+static inline int ip_mkroute_input_def(struct sk_buff *skb,
+                                      struct fib_result* res,
                                       const struct flowi *fl,
                                       struct in_device *in_dev,
                                       __be32 daddr, __be32 saddr, u32 tos)
@@ -1835,11 +1835,11 @@ static inline int ip_mkroute_input_def(struct sk_buff *skb,
 
        /* put it into the cache */
        hash = rt_hash(daddr, saddr, fl->iif);
-       return rt_intern_hash(hash, rth, (struct rtable**)&skb->dst);   
+       return rt_intern_hash(hash, rth, (struct rtable**)&skb->dst);
 }
 
-static inline int ip_mkroute_input(struct sk_buff *skb, 
-                                  struct fib_result* res, 
+static inline int ip_mkroute_input(struct sk_buff *skb,
+                                  struct fib_result* res,
                                   const struct flowi *fl,
                                   struct in_device *in_dev,
                                   __be32 daddr, __be32 saddr, u32 tos)
@@ -1859,7 +1859,7 @@ static inline int ip_mkroute_input(struct sk_buff *skb,
        if (hopcount < 2)
                return ip_mkroute_input_def(skb, res, fl, in_dev, daddr,
                                            saddr, tos);
-       
+
        /* add all alternatives to the routing cache */
        for (hop = 0; hop < hopcount; hop++) {
                res->nh_sel = hop;
@@ -1988,7 +1988,7 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr,
                goto e_nobufs;
        if (err == -EINVAL)
                goto e_inval;
-       
+
 done:
        in_dev_put(in_dev);
        if (free_res)
@@ -2071,8 +2071,8 @@ martian_destination:
 #endif
 
 e_hostunreach:
-        err = -EHOSTUNREACH;
-        goto done;
+       err = -EHOSTUNREACH;
+       goto done;
 
 e_inval:
        err = -EINVAL;
@@ -2099,7 +2099,7 @@ int ip_route_input(struct sk_buff *skb, __be32 daddr, __be32 saddr,
 
        rcu_read_lock();
        for (rth = rcu_dereference(rt_hash_table[hash].chain); rth;
-            rth = rcu_dereference(rth->u.rt_next)) {
+            rth = rcu_dereference(rth->u.dst.rt_next)) {
                if (rth->fl.fl4_dst == daddr &&
                    rth->fl.fl4_src == saddr &&
                    rth->fl.iif == iif &&
@@ -2153,11 +2153,11 @@ int ip_route_input(struct sk_buff *skb, __be32 daddr, __be32 saddr,
 }
 
 static inline int __mkroute_output(struct rtable **result,
-                                  struct fib_result* res, 
+                                  struct fib_result* res,
                                   const struct flowi *fl,
-                                  const struct flowi *oldflp, 
-                                  struct net_device *dev_out, 
-                                  unsigned flags) 
+                                  const struct flowi *oldflp,
+                                  struct net_device *dev_out,
+                                  unsigned flags)
 {
        struct rtable *rth;
        struct in_device *in_dev;
@@ -2190,7 +2190,7 @@ static inline int __mkroute_output(struct rtable **result,
                }
        } else if (res->type == RTN_MULTICAST) {
                flags |= RTCF_MULTICAST|RTCF_LOCAL;
-               if (!ip_check_mc(in_dev, oldflp->fl4_dst, oldflp->fl4_src, 
+               if (!ip_check_mc(in_dev, oldflp->fl4_dst, oldflp->fl4_src,
                                 oldflp->proto))
                        flags &= ~RTCF_LOCAL;
                /* If multicast route do not exist use
@@ -2208,7 +2208,7 @@ static inline int __mkroute_output(struct rtable **result,
        if (!rth) {
                err = -ENOBUFS;
                goto cleanup;
-       }               
+       }
 
        atomic_set(&rth->u.dst.__refcnt, 1);
        rth->u.dst.flags= DST_HOST;
@@ -2232,7 +2232,7 @@ static inline int __mkroute_output(struct rtable **result,
        rth->rt_dst     = fl->fl4_dst;
        rth->rt_src     = fl->fl4_src;
        rth->rt_iif     = oldflp->oif ? : dev_out->ifindex;
-       /* get references to the devices that are to be hold by the routing 
+       /* get references to the devices that are to be hold by the routing
           cache entry */
        rth->u.dst.dev  = dev_out;
        dev_hold(dev_out);
@@ -2250,7 +2250,7 @@ static inline int __mkroute_output(struct rtable **result,
        }
        if (flags & (RTCF_BROADCAST | RTCF_MULTICAST)) {
                rth->rt_spec_dst = fl->fl4_src;
-               if (flags & RTCF_LOCAL && 
+               if (flags & RTCF_LOCAL &&
                    !(dev_out->flags & IFF_LOOPBACK)) {
                        rth->u.dst.output = ip_mc_output;
                        RT_CACHE_STAT_INC(out_slow_mc);
@@ -2292,7 +2292,7 @@ static inline int ip_mkroute_output_def(struct rtable **rp,
                hash = rt_hash(oldflp->fl4_dst, oldflp->fl4_src, oldflp->oif);
                err = rt_intern_hash(hash, rth, rp);
        }
-       
+
        return err;
 }
 
@@ -2563,7 +2563,7 @@ int __ip_route_output_key(struct rtable **rp, const struct flowi *flp)
 
        rcu_read_lock_bh();
        for (rth = rcu_dereference(rt_hash_table[hash].chain); rth;
-               rth = rcu_dereference(rth->u.rt_next)) {
+               rth = rcu_dereference(rth->u.dst.rt_next)) {
                if (rth->fl.fl4_dst == flp->fl4_dst &&
                    rth->fl.fl4_src == flp->fl4_src &&
                    rth->fl.iif == 0 &&
@@ -2635,7 +2635,7 @@ static int rt_fill_info(struct sk_buff *skb, u32 pid, u32 seq, int event,
 
        nlh = nlmsg_put(skb, pid, seq, event, sizeof(*r), flags);
        if (nlh == NULL)
-               return -ENOBUFS;
+               return -EMSGSIZE;
 
        r = nlmsg_data(nlh);
        r->rtm_family    = AF_INET;
@@ -2718,7 +2718,8 @@ static int rt_fill_info(struct sk_buff *skb, u32 pid, u32 seq, int event,
        return nlmsg_end(skb, nlh);
 
 nla_put_failure:
-       return nlmsg_cancel(skb, nlh);
+       nlmsg_cancel(skb, nlh);
+       return -EMSGSIZE;
 }
 
 int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void *arg)
@@ -2824,12 +2825,12 @@ int ip_rt_dump(struct sk_buff *skb,  struct netlink_callback *cb)
                        s_idx = 0;
                rcu_read_lock_bh();
                for (rt = rcu_dereference(rt_hash_table[h].chain), idx = 0; rt;
-                    rt = rcu_dereference(rt->u.rt_next), idx++) {
+                    rt = rcu_dereference(rt->u.dst.rt_next), idx++) {
                        if (idx < s_idx)
                                continue;
                        skb->dst = dst_clone(&rt->u.dst);
                        if (rt_fill_info(skb, NETLINK_CB(cb->skb).pid,
-                                        cb->nlh->nlmsg_seq, RTM_NEWROUTE, 
+                                        cb->nlh->nlmsg_seq, RTM_NEWROUTE,
                                         1, NLM_F_MULTI) <= 0) {
                                dst_release(xchg(&skb->dst, NULL));
                                rcu_read_unlock_bh();
@@ -2862,7 +2863,7 @@ static int ipv4_sysctl_rtcache_flush(ctl_table *ctl, int write,
                proc_dointvec(ctl, write, filp, buffer, lenp, ppos);
                rt_cache_flush(flush_delay);
                return 0;
-       } 
+       }
 
        return -EINVAL;
 }
@@ -2879,13 +2880,13 @@ static int ipv4_sysctl_rtcache_flush_strategy(ctl_table *table,
        if (newlen != sizeof(int))
                return -EINVAL;
        if (get_user(delay, (int __user *)newval))
-               return -EFAULT; 
-       rt_cache_flush(delay); 
+               return -EFAULT;
+       rt_cache_flush(delay);
        return 0;
 }
 
 ctl_table ipv4_route_table[] = {
-        {
+       {
                .ctl_name       = NET_IPV4_ROUTE_FLUSH,
                .procname       = "flush",
                .data           = &flush_delay,
@@ -2930,7 +2931,7 @@ ctl_table ipv4_route_table[] = {
        },
        {
                /*  Deprecated. Use gc_min_interval_ms */
+
                .ctl_name       = NET_IPV4_ROUTE_GC_MIN_INTERVAL,
                .procname       = "gc_min_interval",
                .data           = &ip_rt_gc_min_interval,
@@ -3179,8 +3180,8 @@ int __init ip_rt_init(void)
        {
        struct proc_dir_entry *rtstat_pde = NULL; /* keep gcc happy */
        if (!proc_net_fops_create("rt_cache", S_IRUGO, &rt_cache_seq_fops) ||
-           !(rtstat_pde = create_proc_entry("rt_cache", S_IRUGO, 
-                                            proc_net_stat))) {
+           !(rtstat_pde = create_proc_entry("rt_cache", S_IRUGO,
+                                            proc_net_stat))) {
                return -ENOMEM;
        }
        rtstat_pde->proc_fops = &rt_cpu_seq_fops;
index 6b19530905afdbad2e7e2c46716b8d741447f7b9..33016cc90f0b8a7add18555666a010f87bc550ab 100644 (file)
@@ -2,16 +2,16 @@
  *  Syncookies implementation for the Linux kernel
  *
  *  Copyright (C) 1997 Andi Kleen
- *  Based on ideas by D.J.Bernstein and Eric Schenk. 
+ *  Based on ideas by D.J.Bernstein and Eric Schenk.
  *
  *     This program is free software; you can redistribute it and/or
  *      modify it under the terms of the GNU General Public License
  *      as published by the Free Software Foundation; either version
  *      2 of the License, or (at your option) any later version.
- * 
+ *
  *  $Id: syncookies.c,v 1.18 2002/02/01 22:01:04 davem Exp $
  *
- *  Missing: IPv6 support. 
+ *  Missing: IPv6 support.
  */
 
 #include <linux/tcp.h>
@@ -57,7 +57,7 @@ static __u32 secure_tcp_syn_cookie(__be32 saddr, __be32 daddr, __be16 sport,
        /*
         * Compute the secure sequence number.
         * The output should be:
-        *   HASH(sec1,saddr,sport,daddr,dport,sec1) + sseq + (count * 2^24)
+        *   HASH(sec1,saddr,sport,daddr,dport,sec1) + sseq + (count * 2^24)
         *      + (HASH(sec2,saddr,sport,daddr,dport,count,sec2) % 2^24).
         * Where sseq is their sequence number and count increases every
         * minute by 1.
@@ -99,17 +99,17 @@ static __u32 check_tcp_syn_cookie(__u32 cookie, __be32 saddr, __be32 daddr,
                & COOKIEMASK;   /* Leaving the data behind */
 }
 
-/* 
+/*
  * This table has to be sorted and terminated with (__u16)-1.
  * XXX generate a better table.
  * Unresolved Issues: HIPPI with a 64k MSS is not well supported.
  */
 static __u16 const msstab[] = {
        64 - 1,
-       256 - 1,        
+       256 - 1,
        512 - 1,
        536 - 1,
-       1024 - 1,       
+       1024 - 1,
        1440 - 1,
        1460 - 1,
        4312 - 1,
@@ -128,7 +128,7 @@ __u32 cookie_v4_init_sequence(struct sock *sk, struct sk_buff *skb, __u16 *mssp)
        int mssind;
        const __u16 mss = *mssp;
 
-       
+
        tp->last_synq_overflow = jiffies;
 
        /* XXX sort msstab[] by probability?  Binary search? */
@@ -144,23 +144,23 @@ __u32 cookie_v4_init_sequence(struct sock *sk, struct sk_buff *skb, __u16 *mssp)
                                     jiffies / (HZ * 60), mssind);
 }
 
-/* 
+/*
  * This (misnamed) value is the age of syncookie which is permitted.
  * Its ideal value should be dependent on TCP_TIMEOUT_INIT and
  * sysctl_tcp_retries1. It's a rather complicated formula (exponential
  * backoff) to compute at runtime so it's currently hardcoded here.
  */
 #define COUNTER_TRIES 4
-/*  
- * Check if a ack sequence number is a valid syncookie. 
+/*
+ * Check if a ack sequence number is a valid syncookie.
  * Return the decoded mss if it is, or 0 if not.
  */
 static inline int cookie_check(struct sk_buff *skb, __u32 cookie)
 {
-       __u32 seq; 
+       __u32 seq;
        __u32 mssind;
 
-       seq = ntohl(skb->h.th->seq)-1; 
+       seq = ntohl(skb->h.th->seq)-1;
        mssind = check_tcp_syn_cookie(cookie,
                                      skb->nh.iph->saddr, skb->nh.iph->daddr,
                                      skb->h.th->source, skb->h.th->dest,
@@ -191,19 +191,19 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb,
        struct inet_request_sock *ireq;
        struct tcp_request_sock *treq;
        struct tcp_sock *tp = tcp_sk(sk);
-       __u32 cookie = ntohl(skb->h.th->ack_seq) - 1; 
+       __u32 cookie = ntohl(skb->h.th->ack_seq) - 1;
        struct sock *ret = sk;
-       struct request_sock *req; 
-       int mss; 
-       struct rtable *rt; 
+       struct request_sock *req;
+       int mss;
+       struct rtable *rt;
        __u8 rcv_wscale;
 
        if (!sysctl_tcp_syncookies || !skb->h.th->ack)
                goto out;
 
-       if (time_after(jiffies, tp->last_synq_overflow + TCP_TIMEOUT_INIT) ||
+       if (time_after(jiffies, tp->last_synq_overflow + TCP_TIMEOUT_INIT) ||
            (mss = cookie_check(skb, cookie)) == 0) {
-               NET_INC_STATS_BH(LINUX_MIB_SYNCOOKIESFAILED);
+               NET_INC_STATS_BH(LINUX_MIB_SYNCOOKIESFAILED);
                goto out;
        }
 
@@ -221,9 +221,9 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb,
        ireq = inet_rsk(req);
        treq = tcp_rsk(req);
        treq->rcv_isn           = ntohl(skb->h.th->seq) - 1;
-       treq->snt_isn           = cookie; 
+       treq->snt_isn           = cookie;
        req->mss                = mss;
-       ireq->rmt_port          = skb->h.th->source;
+       ireq->rmt_port          = skb->h.th->source;
        ireq->loc_addr          = skb->nh.iph->daddr;
        ireq->rmt_addr          = skb->nh.iph->saddr;
        ireq->opt               = NULL;
@@ -242,15 +242,15 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb,
        }
 
        ireq->snd_wscale = ireq->rcv_wscale = ireq->tstamp_ok = 0;
-       ireq->wscale_ok  = ireq->sack_ok = 0; 
-       req->expires    = 0UL; 
-       req->retrans    = 0; 
-       
+       ireq->wscale_ok  = ireq->sack_ok = 0;
+       req->expires    = 0UL;
+       req->retrans    = 0;
+
        /*
         * We need to lookup the route here to get at the correct
         * window size. We should better make sure that the window size
         * hasn't changed since we received the original syn, but I see
-        * no easy way to do this. 
+        * no easy way to do this.
         */
        {
                struct flowi fl = { .nl_u = { .ip4_u =
@@ -266,17 +266,17 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb,
                security_req_classify_flow(req, &fl);
                if (ip_route_output_key(&rt, &fl)) {
                        reqsk_free(req);
-                       goto out; 
+                       goto out;
                }
        }
 
        /* Try to redo what tcp_v4_send_synack did. */
        req->window_clamp = dst_metric(&rt->u.dst, RTAX_WINDOW);
        tcp_select_initial_window(tcp_full_space(sk), req->mss,
-                                 &req->rcv_wnd, &req->window_clamp, 
+                                 &req->rcv_wnd, &req->window_clamp,
                                  0, &rcv_wscale);
        /* BTW win scale with syncookies is 0 by definition */
-       ireq->rcv_wscale  = rcv_wscale; 
+       ireq->rcv_wscale  = rcv_wscale;
 
        ret = get_cookie_sock(sk, skb, req, &rt->u.dst);
 out:   return ret;
index fabf69a9108ca6f6d42f58c3eca46b30f1ffae6b..0aa304711a96ee09b7a99a48f4a1c676b4ee86ec 100644 (file)
@@ -24,7 +24,7 @@ extern int sysctl_ip_nonlocal_bind;
 
 #ifdef CONFIG_SYSCTL
 static int zero;
-static int tcp_retr1_max = 255; 
+static int tcp_retr1_max = 255;
 static int ip_local_port_range_min[] = { 1, 1 };
 static int ip_local_port_range_max[] = { 65535, 65535 };
 #endif
@@ -187,7 +187,7 @@ static int strategy_allowed_congestion_control(ctl_table *table, int __user *nam
 }
 
 ctl_table ipv4_table[] = {
-        {
+       {
                .ctl_name       = NET_IPV4_TCP_TIMESTAMPS,
                .procname       = "tcp_timestamps",
                .data           = &sysctl_tcp_timestamps,
@@ -195,7 +195,7 @@ ctl_table ipv4_table[] = {
                .mode           = 0644,
                .proc_handler   = &proc_dointvec
        },
-        {
+       {
                .ctl_name       = NET_IPV4_TCP_WINDOW_SCALING,
                .procname       = "tcp_window_scaling",
                .data           = &sysctl_tcp_window_scaling,
@@ -203,7 +203,7 @@ ctl_table ipv4_table[] = {
                .mode           = 0644,
                .proc_handler   = &proc_dointvec
        },
-        {
+       {
                .ctl_name       = NET_IPV4_TCP_SACK,
                .procname       = "tcp_sack",
                .data           = &sysctl_tcp_sack,
@@ -211,7 +211,7 @@ ctl_table ipv4_table[] = {
                .mode           = 0644,
                .proc_handler   = &proc_dointvec
        },
-        {
+       {
                .ctl_name       = NET_IPV4_TCP_RETRANS_COLLAPSE,
                .procname       = "tcp_retrans_collapse",
                .data           = &sysctl_tcp_retrans_collapse,
@@ -219,7 +219,7 @@ ctl_table ipv4_table[] = {
                .mode           = 0644,
                .proc_handler   = &proc_dointvec
        },
-        {
+       {
                .ctl_name       = NET_IPV4_FORWARD,
                .procname       = "ip_forward",
                .data           = &ipv4_devconf.forwarding,
@@ -228,16 +228,16 @@ ctl_table ipv4_table[] = {
                .proc_handler   = &ipv4_sysctl_forward,
                .strategy       = &ipv4_sysctl_forward_strategy
        },
-        {
+       {
                .ctl_name       = NET_IPV4_DEFAULT_TTL,
                .procname       = "ip_default_ttl",
-               .data           = &sysctl_ip_default_ttl,
+               .data           = &sysctl_ip_default_ttl,
                .maxlen         = sizeof(int),
                .mode           = 0644,
                .proc_handler   = &ipv4_doint_and_flush,
                .strategy       = &ipv4_doint_and_flush_strategy,
        },
-        {
+       {
                .ctl_name       = NET_IPV4_NO_PMTU_DISC,
                .procname       = "ip_no_pmtu_disc",
                .data           = &ipv4_config.no_pmtu_disc,
@@ -728,7 +728,7 @@ ctl_table ipv4_table[] = {
                .mode           = 0644,
                .proc_handler   = &proc_dointvec,
        },
-        {
+       {
                .ctl_name       = NET_IPV4_TCP_WORKAROUND_SIGNED_WINDOWS,
                .procname       = "tcp_workaround_signed_windows",
                .data           = &sysctl_tcp_workaround_signed_windows,
index b67e0dd743be9a159754c61fee6915241585cc01..ac6516c642a1756fae602cb79e06cb42714df302 100644 (file)
@@ -475,7 +475,7 @@ static inline void skb_entail(struct sock *sk, struct tcp_sock *tp,
        if (!sk->sk_send_head)
                sk->sk_send_head = skb;
        if (tp->nonagle & TCP_NAGLE_PUSH)
-               tp->nonagle &= ~TCP_NAGLE_PUSH; 
+               tp->nonagle &= ~TCP_NAGLE_PUSH;
 }
 
 static inline void tcp_mark_urg(struct tcp_sock *tp, int flags,
@@ -557,7 +557,7 @@ new_segment:
                }
                if (!sk_stream_wmem_schedule(sk, copy))
                        goto wait_for_memory;
-               
+
                if (can_coalesce) {
                        skb_shinfo(skb)->frags[i - 1].size += copy;
                } else {
@@ -1439,12 +1439,12 @@ skip_copy:
                dma_async_memcpy_issue_pending(tp->ucopy.dma_chan);
 
                while (dma_async_memcpy_complete(tp->ucopy.dma_chan,
-                                                tp->ucopy.dma_cookie, &done,
-                                                &used) == DMA_IN_PROGRESS) {
+                                                tp->ucopy.dma_cookie, &done,
+                                                &used) == DMA_IN_PROGRESS) {
                        /* do partial cleanup of sk_async_wait_queue */
                        while ((skb = skb_peek(&sk->sk_async_wait_queue)) &&
                               (dma_async_is_complete(skb->dma_cookie, done,
-                                                     used) == DMA_SUCCESS)) {
+                                                     used) == DMA_SUCCESS)) {
                                __skb_dequeue(&sk->sk_async_wait_queue);
                                kfree_skb(skb);
                        }
@@ -2006,7 +2006,7 @@ void tcp_get_info(struct sock *sk, struct tcp_info *info)
                info->tcpi_options |= TCPI_OPT_WSCALE;
                info->tcpi_snd_wscale = tp->rx_opt.snd_wscale;
                info->tcpi_rcv_wscale = tp->rx_opt.rcv_wscale;
-       } 
+       }
 
        if (tp->ecn_flags&TCP_ECN_OK)
                info->tcpi_options |= TCPI_OPT_ECN;
@@ -2415,10 +2415,11 @@ void __init tcp_init(void)
                                        &tcp_hashinfo.ehash_size,
                                        NULL,
                                        0);
-       tcp_hashinfo.ehash_size = (1 << tcp_hashinfo.ehash_size) >> 1;
-       for (i = 0; i < (tcp_hashinfo.ehash_size << 1); i++) {
+       tcp_hashinfo.ehash_size = 1 << tcp_hashinfo.ehash_size;
+       for (i = 0; i < tcp_hashinfo.ehash_size; i++) {
                rwlock_init(&tcp_hashinfo.ehash[i].lock);
                INIT_HLIST_HEAD(&tcp_hashinfo.ehash[i].chain);
+               INIT_HLIST_HEAD(&tcp_hashinfo.ehash[i].twchain);
        }
 
        tcp_hashinfo.bhash =
@@ -2475,7 +2476,7 @@ void __init tcp_init(void)
 
        printk(KERN_INFO "TCP: Hash tables configured "
               "(established %d bind %d)\n",
-              tcp_hashinfo.ehash_size << 1, tcp_hashinfo.bhash_size);
+              tcp_hashinfo.ehash_size, tcp_hashinfo.bhash_size);
 
        tcp_register_congestion_control(&tcp_reno);
 }
index 5ca7723d07987a604bb6382f0fdefc3f1850b2cb..c1b34f1edb32740fa38dc724f6792f5998118a54 100644 (file)
@@ -313,28 +313,28 @@ void tcp_reno_cong_avoid(struct sock *sk, u32 ack, u32 rtt, u32 in_flight,
                return;
 
        /* In "safe" area, increase. */
-        if (tp->snd_cwnd <= tp->snd_ssthresh)
+       if (tp->snd_cwnd <= tp->snd_ssthresh)
                tcp_slow_start(tp);
 
-       /* In dangerous area, increase slowly. */
+       /* In dangerous area, increase slowly. */
        else if (sysctl_tcp_abc) {
-               /* RFC3465: Appropriate Byte Count
-                * increase once for each full cwnd acked
-                */
-               if (tp->bytes_acked >= tp->snd_cwnd*tp->mss_cache) {
-                       tp->bytes_acked -= tp->snd_cwnd*tp->mss_cache;
-                       if (tp->snd_cwnd < tp->snd_cwnd_clamp)
-                               tp->snd_cwnd++;
-               }
-       } else {
-               /* In theory this is tp->snd_cwnd += 1 / tp->snd_cwnd */
-               if (tp->snd_cwnd_cnt >= tp->snd_cwnd) {
-                       if (tp->snd_cwnd < tp->snd_cwnd_clamp)
-                               tp->snd_cwnd++;
-                       tp->snd_cwnd_cnt = 0;
-               } else
-                       tp->snd_cwnd_cnt++;
-       }
+               /* RFC3465: Appropriate Byte Count
+                * increase once for each full cwnd acked
+                */
+               if (tp->bytes_acked >= tp->snd_cwnd*tp->mss_cache) {
+                       tp->bytes_acked -= tp->snd_cwnd*tp->mss_cache;
+                       if (tp->snd_cwnd < tp->snd_cwnd_clamp)
+                               tp->snd_cwnd++;
+               }
+       } else {
+               /* In theory this is tp->snd_cwnd += 1 / tp->snd_cwnd */
+               if (tp->snd_cwnd_cnt >= tp->snd_cwnd) {
+                       if (tp->snd_cwnd < tp->snd_cwnd_clamp)
+                               tp->snd_cwnd++;
+                       tp->snd_cwnd_cnt = 0;
+               } else
+                       tp->snd_cwnd_cnt++;
+       }
 }
 EXPORT_SYMBOL_GPL(tcp_reno_cong_avoid);
 
index 6ad184802266b7e06fde04235104ca9ba40a6c61..5ce6cd85680b66d52cbdcb804811d54389e6ae0f 100644 (file)
@@ -175,42 +175,42 @@ static inline void bictcp_update(struct bictcp *ca, u32 cwnd)
                }
        }
 
-        /* cubic function - calc*/
-        /* calculate c * time^3 / rtt,
-         *  while considering overflow in calculation of time^3
+       /* cubic function - calc*/
+       /* calculate c * time^3 / rtt,
+        *  while considering overflow in calculation of time^3
         * (so time^3 is done by using 64 bit)
         * and without the support of division of 64bit numbers
         * (so all divisions are done by using 32 bit)
-         *  also NOTE the unit of those veriables
-         *       time  = (t - K) / 2^bictcp_HZ
-         *       c = bic_scale >> 10
+        *  also NOTE the unit of those veriables
+               time  = (t - K) / 2^bictcp_HZ
+               c = bic_scale >> 10
         * rtt  = (srtt >> 3) / HZ
         * !!! The following code does not have overflow problems,
         * if the cwnd < 1 million packets !!!
-         */
+        */
 
        /* change the unit from HZ to bictcp_HZ */
-        t = ((tcp_time_stamp + (ca->delay_min>>3) - ca->epoch_start)
+       t = ((tcp_time_stamp + (ca->delay_min>>3) - ca->epoch_start)
             << BICTCP_HZ) / HZ;
 
-        if (t < ca->bic_K)             /* t - K */
+       if (t < ca->bic_K)              /* t - K */
                offs = ca->bic_K - t;
-        else
-                offs = t - ca->bic_K;
+       else
+               offs = t - ca->bic_K;
 
        /* c/rtt * (t-K)^3 */
        delta = (cube_rtt_scale * offs * offs * offs) >> (10+3*BICTCP_HZ);
-        if (t < ca->bic_K)                                     /* below origin*/
-                bic_target = ca->bic_origin_point - delta;
-        else                                                   /* above origin*/
-                bic_target = ca->bic_origin_point + delta;
+       if (t < ca->bic_K)                                      /* below origin*/
+               bic_target = ca->bic_origin_point - delta;
+       else                                                    /* above origin*/
+               bic_target = ca->bic_origin_point + delta;
 
-        /* cubic function - calc bictcp_cnt*/
-        if (bic_target > cwnd) {
+       /* cubic function - calc bictcp_cnt*/
+       if (bic_target > cwnd) {
                ca->cnt = cwnd / (bic_target - cwnd);
-        } else {
-                ca->cnt = 100 * cwnd;              /* very small increment*/
-        }
+       } else {
+               ca->cnt = 100 * cwnd;              /* very small increment*/
+       }
 
        if (ca->delay_min > 0) {
                /* max increment = Smax * rtt / 0.1  */
@@ -219,7 +219,7 @@ static inline void bictcp_update(struct bictcp *ca, u32 cwnd)
                        ca->cnt = min_cnt;
        }
 
-        /* slow start and low utilization  */
+       /* slow start and low utilization  */
        if (ca->loss_cwnd == 0)         /* could be aggressive in slow start */
                ca->cnt = 50;
 
@@ -227,9 +227,9 @@ static inline void bictcp_update(struct bictcp *ca, u32 cwnd)
        if (tcp_friendliness) {
                u32 scale = beta_scale;
                delta = (cwnd * scale) >> 3;
-               while (ca->ack_cnt > delta) {           /* update tcp cwnd */
-                       ca->ack_cnt -= delta;
-                       ca->tcp_cwnd++;
+               while (ca->ack_cnt > delta) {           /* update tcp cwnd */
+                       ca->ack_cnt -= delta;
+                       ca->tcp_cwnd++;
                }
 
                if (ca->tcp_cwnd > cwnd){       /* if bic is slower than tcp */
@@ -238,7 +238,7 @@ static inline void bictcp_update(struct bictcp *ca, u32 cwnd)
                        if (ca->cnt > max_cnt)
                                ca->cnt = max_cnt;
                }
-        }
+       }
 
        ca->cnt = (ca->cnt << ACK_RATIO_SHIFT) / ca->delayed_ack;
        if (ca->cnt == 0)                       /* cannot be zero */
index c4fc811bf377f6f65f86b21eb51e659555f1c2e6..a291097fcc0a9e4ba6ff813579680809fff9bf3e 100644 (file)
@@ -14,8 +14,8 @@
  * with fixed-point MD scaled <<8.
  */
 static const struct hstcp_aimd_val {
-        unsigned int cwnd;
-        unsigned int md;
+       unsigned int cwnd;
+       unsigned int md;
 } hstcp_aimd_vals[] = {
  {     38,  128, /*  0.50 */ },
  {    118,  112, /*  0.44 */ },
index 753987a1048ffdf8a890205fd425fcd69d420902..63318b6e9d512e139861eed32148488093c17a08 100644 (file)
@@ -224,7 +224,7 @@ static void htcp_cong_avoid(struct sock *sk, u32 ack, u32 rtt,
        if (!tcp_is_cwnd_limited(sk, in_flight))
                return;
 
-        if (tp->snd_cwnd <= tp->snd_ssthresh)
+       if (tp->snd_cwnd <= tp->snd_ssthresh)
                tcp_slow_start(tp);
        else {
 
index c26076fb890e5f935631dc4e45f96b90cee15521..1a14191687ac752fcbbe4fa324517554a251950f 100644 (file)
@@ -50,9 +50,9 @@
  *             Andi Kleen:             Make sure we never ack data there is not
  *                                     enough room for. Also make this condition
  *                                     a fatal error if it might still happen.
- *             Andi Kleen:             Add tcp_measure_rcv_mss to make 
+ *             Andi Kleen:             Add tcp_measure_rcv_mss to make
  *                                     connections with MSS<min(MTU,ann. MSS)
- *                                     work without delayed acks. 
+ *                                     work without delayed acks.
  *             Andi Kleen:             Process packets with PSH set in the
  *                                     fast path.
  *             J Hadi Salim:           ECN support
@@ -112,17 +112,17 @@ int sysctl_tcp_abc __read_mostly;
 
 #define TCP_REMNANT (TCP_FLAG_FIN|TCP_FLAG_URG|TCP_FLAG_SYN|TCP_FLAG_PSH)
 
-/* Adapt the MSS value used to make delayed ack decision to the 
+/* Adapt the MSS value used to make delayed ack decision to the
  * real world.
- */ 
+ */
 static void tcp_measure_rcv_mss(struct sock *sk,
                                const struct sk_buff *skb)
 {
        struct inet_connection_sock *icsk = inet_csk(sk);
-       const unsigned int lss = icsk->icsk_ack.last_seg_size; 
+       const unsigned int lss = icsk->icsk_ack.last_seg_size;
        unsigned int len;
 
-       icsk->icsk_ack.last_seg_size = 0; 
+       icsk->icsk_ack.last_seg_size = 0;
 
        /* skb->len may jitter because of SACKs, even if peer
         * sends good full-sized frames.
@@ -440,15 +440,15 @@ void tcp_rcv_space_adjust(struct sock *sk)
        struct tcp_sock *tp = tcp_sk(sk);
        int time;
        int space;
-       
+
        if (tp->rcvq_space.time == 0)
                goto new_measure;
-       
+
        time = tcp_time_stamp - tp->rcvq_space.time;
        if (time < (tp->rcv_rtt_est.rtt >> 3) ||
            tp->rcv_rtt_est.rtt == 0)
                return;
-       
+
        space = 2 * (tp->copied_seq - tp->rcvq_space.seq);
 
        space = max(tp->rcvq_space.space, space);
@@ -483,7 +483,7 @@ void tcp_rcv_space_adjust(struct sock *sk)
                        }
                }
        }
-       
+
 new_measure:
        tp->rcvq_space.seq = tp->copied_seq;
        tp->rcvq_space.time = tcp_time_stamp;
@@ -509,7 +509,7 @@ static void tcp_event_data_recv(struct sock *sk, struct tcp_sock *tp, struct sk_
        tcp_measure_rcv_mss(sk, skb);
 
        tcp_rcv_rtt_measure(tp);
-       
+
        now = tcp_time_stamp;
 
        if (!icsk->icsk_ack.ato) {
@@ -561,7 +561,7 @@ static void tcp_rtt_estimator(struct sock *sk, const __u32 mrtt)
        /*      The following amusing code comes from Jacobson's
         *      article in SIGCOMM '88.  Note that rtt and mdev
         *      are scaled versions of rtt and mean deviation.
-        *      This is designed to be as fast as possible 
+        *      This is designed to be as fast as possible
         *      m stands for "measurement".
         *
         *      On a 1990 paper the rto value is changed to:
@@ -936,28 +936,58 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_
        struct tcp_sock *tp = tcp_sk(sk);
        unsigned char *ptr = ack_skb->h.raw + TCP_SKB_CB(ack_skb)->sacked;
        struct tcp_sack_block_wire *sp = (struct tcp_sack_block_wire *)(ptr+2);
+       struct sk_buff *cached_skb;
        int num_sacks = (ptr[1] - TCPOLEN_SACK_BASE)>>3;
        int reord = tp->packets_out;
        int prior_fackets;
        u32 lost_retrans = 0;
        int flag = 0;
        int dup_sack = 0;
+       int cached_fack_count;
        int i;
+       int first_sack_index;
 
        if (!tp->sacked_out)
                tp->fackets_out = 0;
        prior_fackets = tp->fackets_out;
 
+       /* Check for D-SACK. */
+       if (before(ntohl(sp[0].start_seq), TCP_SKB_CB(ack_skb)->ack_seq)) {
+               dup_sack = 1;
+               tp->rx_opt.sack_ok |= 4;
+               NET_INC_STATS_BH(LINUX_MIB_TCPDSACKRECV);
+       } else if (num_sacks > 1 &&
+                       !after(ntohl(sp[0].end_seq), ntohl(sp[1].end_seq)) &&
+                       !before(ntohl(sp[0].start_seq), ntohl(sp[1].start_seq))) {
+               dup_sack = 1;
+               tp->rx_opt.sack_ok |= 4;
+               NET_INC_STATS_BH(LINUX_MIB_TCPDSACKOFORECV);
+       }
+
+       /* D-SACK for already forgotten data...
+        * Do dumb counting. */
+       if (dup_sack &&
+                       !after(ntohl(sp[0].end_seq), prior_snd_una) &&
+                       after(ntohl(sp[0].end_seq), tp->undo_marker))
+               tp->undo_retrans--;
+
+       /* Eliminate too old ACKs, but take into
+        * account more or less fresh ones, they can
+        * contain valid SACK info.
+        */
+       if (before(TCP_SKB_CB(ack_skb)->ack_seq, prior_snd_una - tp->max_window))
+               return 0;
+
        /* SACK fastpath:
         * if the only SACK change is the increase of the end_seq of
         * the first block then only apply that SACK block
         * and use retrans queue hinting otherwise slowpath */
        flag = 1;
-       for (i = 0; i< num_sacks; i++) {
-               __u32 start_seq = ntohl(sp[i].start_seq);
-               __u32 end_seq =  ntohl(sp[i].end_seq);
+       for (i = 0; i < num_sacks; i++) {
+               __be32 start_seq = sp[i].start_seq;
+               __be32 end_seq = sp[i].end_seq;
 
-               if (i == 0){
+               if (i == 0) {
                        if (tp->recv_sack_cache[i].start_seq != start_seq)
                                flag = 0;
                } else {
@@ -967,39 +997,14 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_
                }
                tp->recv_sack_cache[i].start_seq = start_seq;
                tp->recv_sack_cache[i].end_seq = end_seq;
-
-               /* Check for D-SACK. */
-               if (i == 0) {
-                       u32 ack = TCP_SKB_CB(ack_skb)->ack_seq;
-
-                       if (before(start_seq, ack)) {
-                               dup_sack = 1;
-                               tp->rx_opt.sack_ok |= 4;
-                               NET_INC_STATS_BH(LINUX_MIB_TCPDSACKRECV);
-                       } else if (num_sacks > 1 &&
-                                  !after(end_seq, ntohl(sp[1].end_seq)) &&
-                                  !before(start_seq, ntohl(sp[1].start_seq))) {
-                               dup_sack = 1;
-                               tp->rx_opt.sack_ok |= 4;
-                               NET_INC_STATS_BH(LINUX_MIB_TCPDSACKOFORECV);
-                       }
-
-                       /* D-SACK for already forgotten data...
-                        * Do dumb counting. */
-                       if (dup_sack &&
-                           !after(end_seq, prior_snd_una) &&
-                           after(end_seq, tp->undo_marker))
-                               tp->undo_retrans--;
-
-                       /* Eliminate too old ACKs, but take into
-                        * account more or less fresh ones, they can
-                        * contain valid SACK info.
-                        */
-                       if (before(ack, prior_snd_una - tp->max_window))
-                               return 0;
-               }
+       }
+       /* Clear the rest of the cache sack blocks so they won't match mistakenly. */
+       for (; i < ARRAY_SIZE(tp->recv_sack_cache); i++) {
+               tp->recv_sack_cache[i].start_seq = 0;
+               tp->recv_sack_cache[i].end_seq = 0;
        }
 
+       first_sack_index = 0;
        if (flag)
                num_sacks = 1;
        else {
@@ -1016,6 +1021,10 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_
                                        tmp = sp[j];
                                        sp[j] = sp[j+1];
                                        sp[j+1] = tmp;
+
+                                       /* Track where the first SACK block goes to */
+                                       if (j == first_sack_index)
+                                               first_sack_index = j+1;
                                }
 
                        }
@@ -1025,20 +1034,22 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_
        /* clear flag as used for different purpose in following code */
        flag = 0;
 
+       /* Use SACK fastpath hint if valid */
+       cached_skb = tp->fastpath_skb_hint;
+       cached_fack_count = tp->fastpath_cnt_hint;
+       if (!cached_skb) {
+               cached_skb = sk->sk_write_queue.next;
+               cached_fack_count = 0;
+       }
+
        for (i=0; i<num_sacks; i++, sp++) {
                struct sk_buff *skb;
                __u32 start_seq = ntohl(sp->start_seq);
                __u32 end_seq = ntohl(sp->end_seq);
                int fack_count;
 
-               /* Use SACK fastpath hint if valid */
-               if (tp->fastpath_skb_hint) {
-                       skb = tp->fastpath_skb_hint;
-                       fack_count = tp->fastpath_cnt_hint;
-               } else {
-                       skb = sk->sk_write_queue.next;
-                       fack_count = 0;
-               }
+               skb = cached_skb;
+               fack_count = cached_fack_count;
 
                /* Event "B" in the comment above. */
                if (after(end_seq, tp->high_seq))
@@ -1048,8 +1059,12 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_
                        int in_sack, pcount;
                        u8 sacked;
 
-                       tp->fastpath_skb_hint = skb;
-                       tp->fastpath_cnt_hint = fack_count;
+                       cached_skb = skb;
+                       cached_fack_count = fack_count;
+                       if (i == first_sack_index) {
+                               tp->fastpath_skb_hint = skb;
+                               tp->fastpath_cnt_hint = fack_count;
+                       }
 
                        /* The retransmission queue is always in order, so
                         * we can short-circuit the walk early.
@@ -1234,8 +1249,8 @@ void tcp_enter_frto(struct sock *sk)
        tp->frto_counter = 1;
 
        if (icsk->icsk_ca_state <= TCP_CA_Disorder ||
-            tp->snd_una == tp->high_seq ||
-            (icsk->icsk_ca_state == TCP_CA_Loss && !icsk->icsk_retransmits)) {
+           tp->snd_una == tp->high_seq ||
+           (icsk->icsk_ca_state == TCP_CA_Loss && !icsk->icsk_retransmits)) {
                tp->prior_ssthresh = tcp_current_ssthresh(sk);
                tp->snd_ssthresh = icsk->icsk_ca_ops->ssthresh(sk);
                tcp_ca_event(sk, CA_EVENT_FRTO);
@@ -1954,11 +1969,11 @@ tcp_fastretrans_alert(struct sock *sk, u32 prior_snd_una,
         * 1. Reno does not count dupacks (sacked_out) automatically. */
        if (!tp->packets_out)
                tp->sacked_out = 0;
-        /* 2. SACK counts snd_fack in packets inaccurately. */
+       /* 2. SACK counts snd_fack in packets inaccurately. */
        if (tp->sacked_out == 0)
                tp->fackets_out = 0;
 
-        /* Now state machine starts.
+       /* Now state machine starts.
         * A. ECE, hence prohibit cwnd undoing, the reduction is required. */
        if (flag&FLAG_ECE)
                tp->prior_ssthresh = 0;
@@ -2188,7 +2203,7 @@ static int tcp_tso_acked(struct sock *sk, struct sk_buff *skb,
                         __u32 now, __s32 *seq_rtt)
 {
        struct tcp_sock *tp = tcp_sk(sk);
-       struct tcp_skb_cb *scb = TCP_SKB_CB(skb); 
+       struct tcp_skb_cb *scb = TCP_SKB_CB(skb);
        __u32 seq = tp->snd_una;
        __u32 packets_acked;
        int acked = 0;
@@ -2264,7 +2279,7 @@ static int tcp_clean_rtx_queue(struct sock *sk, __s32 *seq_rtt_p)
 
        while ((skb = skb_peek(&sk->sk_write_queue)) &&
               skb != sk->sk_send_head) {
-               struct tcp_skb_cb *scb = TCP_SKB_CB(skb); 
+               struct tcp_skb_cb *scb = TCP_SKB_CB(skb);
                __u8 sacked = scb->sacked;
 
                /* If our packet is before the ack sequence we can
@@ -2455,9 +2470,9 @@ static int tcp_ack_update_window(struct sock *sk, struct tcp_sock *tp,
 static void tcp_process_frto(struct sock *sk, u32 prior_snd_una)
 {
        struct tcp_sock *tp = tcp_sk(sk);
-       
+
        tcp_sync_left_out(tp);
-       
+
        if (tp->snd_una == prior_snd_una ||
            !before(tp->snd_una, tp->frto_highmark)) {
                /* RTO was caused by loss, start retransmitting in
@@ -2612,7 +2627,7 @@ void tcp_parse_options(struct sk_buff *skb, struct tcp_options_received *opt_rx,
        opt_rx->saw_tstamp = 0;
 
        while(length>0) {
-               int opcode=*ptr++;
+               int opcode=*ptr++;
                int opsize;
 
                switch (opcode) {
@@ -2627,7 +2642,7 @@ void tcp_parse_options(struct sk_buff *skb, struct tcp_options_received *opt_rx,
                                        return;
                                if (opsize > length)
                                        return; /* don't parse partial options */
-                               switch(opcode) {
+                               switch(opcode) {
                                case TCPOPT_MSS:
                                        if(opsize==TCPOLEN_MSS && th->syn && !estab) {
                                                u16 in_mss = ntohs(get_unaligned((__be16 *)ptr));
@@ -2686,10 +2701,10 @@ void tcp_parse_options(struct sk_buff *skb, struct tcp_options_received *opt_rx,
                                         */
                                        break;
 #endif
-                               };
-                               ptr+=opsize-2;
-                               length-=opsize;
-               };
+                               };
+                               ptr+=opsize-2;
+                               length-=opsize;
+               };
        }
 }
 
@@ -3248,7 +3263,7 @@ drop:
                           TCP_SKB_CB(skb)->end_seq);
 
                tcp_dsack_set(tp, TCP_SKB_CB(skb)->seq, tp->rcv_nxt);
-               
+
                /* If window is closed, drop tail of packet. But after
                 * remembering D-SACK for its head made in previous line.
                 */
@@ -3327,7 +3342,7 @@ drop:
                        }
                }
                __skb_insert(skb, skb1, skb1->next, &tp->out_of_order_queue);
-               
+
                /* And clean segments covered by new one as whole. */
                while ((skb1 = skb->next) !=
                       (struct sk_buff*)&tp->out_of_order_queue &&
@@ -3492,7 +3507,7 @@ static void tcp_collapse_ofo_queue(struct sock *sk)
  */
 static int tcp_prune_queue(struct sock *sk)
 {
-       struct tcp_sock *tp = tcp_sk(sk); 
+       struct tcp_sock *tp = tcp_sk(sk);
 
        SOCK_DEBUG(sk, "prune_queue: c=%x\n", tp->copied_seq);
 
@@ -3602,7 +3617,7 @@ static void tcp_new_space(struct sock *sk)
        struct tcp_sock *tp = tcp_sk(sk);
 
        if (tcp_should_expand_sndbuf(sk, tp)) {
-               int sndmem = max_t(u32, tp->rx_opt.mss_clamp, tp->mss_cache) +
+               int sndmem = max_t(u32, tp->rx_opt.mss_clamp, tp->mss_cache) +
                        MAX_TCP_HEADER + 16 + sizeof(struct sk_buff),
                    demanded = max_t(unsigned int, tp->snd_cwnd,
                                                   tp->reordering + 1);
@@ -3675,7 +3690,7 @@ static inline void tcp_ack_snd_check(struct sock *sk)
  *     For 1003.1g we should support a new option TCP_STDURG to permit
  *     either form (or just set the sysctl tcp_stdurg).
  */
+
 static void tcp_check_urg(struct sock * sk, struct tcphdr * th)
 {
        struct tcp_sock *tp = tcp_sk(sk);
@@ -3756,7 +3771,7 @@ static void tcp_urg(struct sock *sk, struct sk_buff *skb, struct tcphdr *th)
                u32 ptr = tp->urg_seq - ntohl(th->seq) + (th->doff * 4) -
                          th->syn;
 
-               /* Is the urgent pointer pointing into this packet? */   
+               /* Is the urgent pointer pointing into this packet? */
                if (ptr < skb->len) {
                        u8 tmp;
                        if (skb_copy_bits(skb, ptr, &tmp, 1))
@@ -3820,7 +3835,7 @@ static int tcp_dma_try_early_copy(struct sock *sk, struct sk_buff *skb, int hlen
        int copied_early = 0;
 
        if (tp->ucopy.wakeup)
-               return 0;
+               return 0;
 
        if (!tp->ucopy.dma_chan && tp->ucopy.pinned_list)
                tp->ucopy.dma_chan = get_softnet_dma();
@@ -3856,26 +3871,26 @@ out:
 #endif /* CONFIG_NET_DMA */
 
 /*
- *     TCP receive function for the ESTABLISHED state. 
+ *     TCP receive function for the ESTABLISHED state.
  *
- *     It is split into a fast path and a slow path. The fast path is 
+ *     It is split into a fast path and a slow path. The fast path is
  *     disabled when:
  *     - A zero window was announced from us - zero window probing
- *        is only handled properly in the slow path. 
+ *        is only handled properly in the slow path.
  *     - Out of order segments arrived.
  *     - Urgent data is expected.
  *     - There is no buffer space left
  *     - Unexpected TCP flags/window values/header lengths are received
- *       (detected by checking the TCP header against pred_flags) 
+ *       (detected by checking the TCP header against pred_flags)
  *     - Data is sent in both directions. Fast path only supports pure senders
  *       or pure receivers (this means either the sequence number or the ack
  *       value must stay constant)
  *     - Unexpected TCP option.
  *
- *     When these conditions are not satisfied it drops into a standard 
+ *     When these conditions are not satisfied it drops into a standard
  *     receive procedure patterned after RFC793 to handle all cases.
  *     The first three cases are guaranteed by proper pred_flags setting,
- *     the rest is checked inline. Fast processing is turned on in 
+ *     the rest is checked inline. Fast processing is turned on in
  *     tcp_data_queue when everything is OK.
  */
 int tcp_rcv_established(struct sock *sk, struct sk_buff *skb,
@@ -3885,15 +3900,15 @@ int tcp_rcv_established(struct sock *sk, struct sk_buff *skb,
 
        /*
         *      Header prediction.
-        *      The code loosely follows the one in the famous 
+        *      The code loosely follows the one in the famous
         *      "30 instruction TCP receive" Van Jacobson mail.
-        *      
-        *      Van's trick is to deposit buffers into socket queue 
+        *
+        *      Van's trick is to deposit buffers into socket queue
         *      on a device interrupt, to call tcp_recv function
         *      on the receive process context and checksum and copy
         *      the buffer to user space. smart...
         *
-        *      Our current scheme is not silly either but we take the 
+        *      Our current scheme is not silly either but we take the
         *      extra cost of the net_bh soft interrupt processing...
         *      We do checksum and copy also but from device to kernel.
         */
@@ -3904,7 +3919,7 @@ int tcp_rcv_established(struct sock *sk, struct sk_buff *skb,
         *      if header_prediction is to be made
         *      'S' will always be tp->tcp_header_len >> 2
         *      '?' will be 0 for the fast path, otherwise pred_flags is 0 to
-        *  turn it off (when there are holes in the receive 
+        *  turn it off (when there are holes in the receive
         *       space for instance)
         *      PSH flag is ignored.
         */
@@ -3928,7 +3943,7 @@ int tcp_rcv_established(struct sock *sk, struct sk_buff *skb,
                                goto slow_path;
 
                        tp->rx_opt.saw_tstamp = 1;
-                       ++ptr; 
+                       ++ptr;
                        tp->rx_opt.rcv_tsval = ntohl(*ptr);
                        ++ptr;
                        tp->rx_opt.rcv_tsecr = ntohl(*ptr);
@@ -3960,7 +3975,7 @@ int tcp_rcv_established(struct sock *sk, struct sk_buff *skb,
                                 * on entry.
                                 */
                                tcp_ack(sk, skb, 0);
-                               __kfree_skb(skb); 
+                               __kfree_skb(skb);
                                tcp_data_snd_check(sk, tp);
                                return 0;
                        } else { /* Header too small */
@@ -4378,11 +4393,11 @@ reset_and_undo:
 
 /*
  *     This function implements the receiving procedure of RFC 793 for
- *     all states except ESTABLISHED and TIME_WAIT. 
+ *     all states except ESTABLISHED and TIME_WAIT.
  *     It's called from both tcp_v4_rcv and tcp_v6_rcv and should be
  *     address independent.
  */
-       
+
 int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
                          struct tcphdr *th, unsigned len)
 {
@@ -4407,19 +4422,19 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
                        if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
                                return 1;
 
-                       /* Now we have several options: In theory there is 
-                        * nothing else in the frame. KA9Q has an option to 
+                       /* Now we have several options: In theory there is
+                        * nothing else in the frame. KA9Q has an option to
                         * send data with the syn, BSD accepts data with the
-                        * syn up to the [to be] advertised window and 
-                        * Solaris 2.1 gives you a protocol error. For now 
-                        * we just ignore it, that fits the spec precisely 
+                        * syn up to the [to be] advertised window and
+                        * Solaris 2.1 gives you a protocol error. For now
+                        * we just ignore it, that fits the spec precisely
                         * and avoids incompatibilities. It would be nice in
                         * future to drop through and process the data.
                         *
-                        * Now that TTCP is starting to be used we ought to 
+                        * Now that TTCP is starting to be used we ought to
                         * queue this data.
                         * But, this leaves one open to an easy denial of
-                        * service attack, and SYN cookies can't defend
+                        * service attack, and SYN cookies can't defend
                         * against this problem. So, we drop the data
                         * in the interest of security over speed unless
                         * it's still in use.
@@ -4609,7 +4624,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
        case TCP_FIN_WAIT1:
        case TCP_FIN_WAIT2:
                /* RFC 793 says to queue data in these states,
-                * RFC 1122 says we MUST send a reset. 
+                * RFC 1122 says we MUST send a reset.
                 * BSD 4.4 also does reset.
                 */
                if (sk->sk_shutdown & RCV_SHUTDOWN) {
@@ -4621,7 +4636,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
                        }
                }
                /* Fall through */
-       case TCP_ESTABLISHED: 
+       case TCP_ESTABLISHED:
                tcp_data_queue(sk, skb);
                queued = 1;
                break;
@@ -4633,7 +4648,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
                tcp_ack_snd_check(sk);
        }
 
-       if (!queued) { 
+       if (!queued) {
 discard:
                __kfree_skb(skb);
        }
index 12de90a5047cf214cd4bd1851331ac14851c0783..0ba74bbe7d30bc9a14dbeb865ff4eb7adb9f72b8 100644 (file)
@@ -191,7 +191,7 @@ int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
        tmp = ip_route_connect(&rt, nexthop, inet->saddr,
                               RT_CONN_FLAGS(sk), sk->sk_bound_dev_if,
                               IPPROTO_TCP,
-                              inet->sport, usin->sin_port, sk);
+                              inet->sport, usin->sin_port, sk, 1);
        if (tmp < 0)
                return tmp;
 
@@ -303,7 +303,7 @@ static void do_pmtu_discovery(struct sock *sk, struct iphdr *iph, u32 mtu)
        /* We don't check in the destentry if pmtu discovery is forbidden
         * on this route. We just assume that no packet_to_big packets
         * are send back when pmtu discovery is not active.
-        * There is a small race when the user changes this flag in the
+        * There is a small race when the user changes this flag in the
         * route, but I think that's acceptable.
         */
        if ((dst = __sk_dst_check(sk, 0)) == NULL)
@@ -502,11 +502,11 @@ void tcp_v4_send_check(struct sock *sk, int len, struct sk_buff *skb)
        struct tcphdr *th = skb->h.th;
 
        if (skb->ip_summed == CHECKSUM_PARTIAL) {
-               th->check = ~tcp_v4_check(th, len,
-                                         inet->saddr, inet->daddr, 0);
+               th->check = ~tcp_v4_check(len, inet->saddr,
+                                         inet->daddr, 0);
                skb->csum_offset = offsetof(struct tcphdr, check);
        } else {
-               th->check = tcp_v4_check(th, len, inet->saddr, inet->daddr,
+               th->check = tcp_v4_check(len, inet->saddr, inet->daddr,
                                         csum_partial((char *)th,
                                                      th->doff << 2,
                                                      skb->csum));
@@ -525,7 +525,7 @@ int tcp_v4_gso_send_check(struct sk_buff *skb)
        th = skb->h.th;
 
        th->check = 0;
-       th->check = ~tcp_v4_check(th, skb->len, iph->saddr, iph->daddr, 0);
+       th->check = ~tcp_v4_check(skb->len, iph->saddr, iph->daddr, 0);
        skb->csum_offset = offsetof(struct tcphdr, check);
        skb->ip_summed = CHECKSUM_PARTIAL;
        return 0;
@@ -747,7 +747,7 @@ static int tcp_v4_send_synack(struct sock *sk, struct request_sock *req,
        if (skb) {
                struct tcphdr *th = skb->h.th;
 
-               th->check = tcp_v4_check(th, skb->len,
+               th->check = tcp_v4_check(skb->len,
                                         ireq->loc_addr,
                                         ireq->rmt_addr,
                                         csum_partial((char *)th, skb->len,
@@ -880,7 +880,7 @@ int tcp_v4_md5_do_add(struct sock *sk, __be32 addr,
 
                if (md5sig->alloced4 == md5sig->entries4) {
                        keys = kmalloc((sizeof(*keys) *
-                                       (md5sig->entries4 + 1)), GFP_ATOMIC);
+                                       (md5sig->entries4 + 1)), GFP_ATOMIC);
                        if (!keys) {
                                kfree(newkey);
                                tcp_free_md5sig_pool();
@@ -934,7 +934,7 @@ int tcp_v4_md5_do_del(struct sock *sk, __be32 addr)
                                memcpy(&tp->md5sig_info->keys4[i],
                                       &tp->md5sig_info->keys4[i+1],
                                       (tp->md5sig_info->entries4 - i) *
-                                       sizeof(struct tcp4_md5sig_key));
+                                       sizeof(struct tcp4_md5sig_key));
                        }
                        tcp_free_md5sig_pool();
                        return 0;
@@ -1388,7 +1388,7 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
                goto drop_and_free;
 
        if (want_cookie) {
-               reqsk_free(req);
+               reqsk_free(req);
        } else {
                inet_csk_reqsk_queue_hash_add(sk, req, TCP_TIMEOUT_INIT);
        }
@@ -1514,7 +1514,7 @@ static struct sock *tcp_v4_hnd_req(struct sock *sk, struct sk_buff *skb)
 static __sum16 tcp_v4_checksum_init(struct sk_buff *skb)
 {
        if (skb->ip_summed == CHECKSUM_COMPLETE) {
-               if (!tcp_v4_check(skb->h.th, skb->len, skb->nh.iph->saddr,
+               if (!tcp_v4_check(skb->len, skb->nh.iph->saddr,
                                  skb->nh.iph->daddr, skb->csum)) {
                        skb->ip_summed = CHECKSUM_UNNECESSARY;
                        return 0;
@@ -1704,7 +1704,7 @@ bad_packet:
 discard_it:
        /* Discard frame. */
        kfree_skb(skb);
-       return 0;
+       return 0;
 
 discard_and_relse:
        sock_put(sk);
@@ -1890,10 +1890,10 @@ int tcp_v4_destroy_sock(struct sock *sk)
        tcp_cleanup_congestion_control(sk);
 
        /* Cleanup up the write buffer. */
-       sk_stream_writequeue_purge(sk);
+       sk_stream_writequeue_purge(sk);
 
        /* Cleans up our, hopefully empty, out_of_order_queue. */
-       __skb_queue_purge(&tp->out_of_order_queue);
+       __skb_queue_purge(&tp->out_of_order_queue);
 
 #ifdef CONFIG_TCP_MD5SIG
        /* Clean up the MD5 key list, if any */
@@ -1906,7 +1906,7 @@ int tcp_v4_destroy_sock(struct sock *sk)
 
 #ifdef CONFIG_NET_DMA
        /* Cleans up our sk_async_wait_queue */
-       __skb_queue_purge(&sk->sk_async_wait_queue);
+       __skb_queue_purge(&sk->sk_async_wait_queue);
 #endif
 
        /* Clean prequeue, it must be empty really */
@@ -1983,7 +1983,7 @@ get_req:
                st->state = TCP_SEQ_STATE_LISTENING;
                read_unlock_bh(&icsk->icsk_accept_queue.syn_wait_lock);
        } else {
-               icsk = inet_csk(sk);
+               icsk = inet_csk(sk);
                read_lock_bh(&icsk->icsk_accept_queue.syn_wait_lock);
                if (reqsk_queue_len(&icsk->icsk_accept_queue))
                        goto start_req;
@@ -1996,7 +1996,7 @@ get_sk:
                        cur = sk;
                        goto out;
                }
-               icsk = inet_csk(sk);
+               icsk = inet_csk(sk);
                read_lock_bh(&icsk->icsk_accept_queue.syn_wait_lock);
                if (reqsk_queue_len(&icsk->icsk_accept_queue)) {
 start_req:
@@ -2051,7 +2051,7 @@ static void *established_get_first(struct seq_file *seq)
                }
                st->state = TCP_SEQ_STATE_TIME_WAIT;
                inet_twsk_for_each(tw, node,
-                                  &tcp_hashinfo.ehash[st->bucket + tcp_hashinfo.ehash_size].chain) {
+                                  &tcp_hashinfo.ehash[st->bucket].twchain) {
                        if (tw->tw_family != st->family) {
                                continue;
                        }
@@ -2107,7 +2107,7 @@ get_tw:
        }
 
        st->state = TCP_SEQ_STATE_TIME_WAIT;
-       tw = tw_head(&tcp_hashinfo.ehash[st->bucket + tcp_hashinfo.ehash_size].chain);
+       tw = tw_head(&tcp_hashinfo.ehash[st->bucket].twchain);
        goto get_tw;
 found:
        cur = sk;
index 4a3889dd194352a0e26f1f1c1b486ccad4c36a5c..30b1e520ad943442fc76f13cc5d3b6d27aa5d657 100644 (file)
@@ -64,7 +64,7 @@ static __inline__ int tcp_in_window(u32 seq, u32 end_seq, u32 s_win, u32 e_win)
        return (seq == e_win && seq == end_seq);
 }
 
-/* 
+/*
  * * Main purpose of TIME-WAIT state is to close connection gracefully,
  *   when one of ends sits in LAST-ACK or CLOSING retransmitting FIN
  *   (and, probably, tail of data) and one or more our ACKs are lost.
@@ -176,13 +176,13 @@ kill_with_rst:
         *      "When a connection is [...] on TIME-WAIT state [...]
         *      [a TCP] MAY accept a new SYN from the remote TCP to
         *      reopen the connection directly, if it:
-        *      
+        *
         *      (1)  assigns its initial sequence number for the new
         *      connection to be larger than the largest sequence
         *      number it used on the previous connection incarnation,
         *      and
         *
-        *      (2)  returns to TIME-WAIT state if the SYN turns out 
+        *      (2)  returns to TIME-WAIT state if the SYN turns out
         *      to be an old duplicate".
         */
 
@@ -266,9 +266,9 @@ kill:
        return TCP_TW_SUCCESS;
 }
 
-/* 
+/*
  * Move a socket to time-wait or dead fin-wait-2 state.
- */ 
+ */
 void tcp_time_wait(struct sock *sk, int state, int timeo)
 {
        struct inet_timewait_sock *tw = NULL;
@@ -481,7 +481,7 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct request_sock *req,
        return newsk;
 }
 
-/* 
+/*
  *     Process an incoming packet for SYN_RECV sockets represented
  *     as a request_sock.
  */
index 975f4472af29c750daec8a0ae02c0e958a578929..cebe9aa918a355c039fe2f014a8a88cc88603e4e 100644 (file)
@@ -198,7 +198,7 @@ void tcp_select_initial_window(int __space, __u32 mss,
        (*rcv_wscale) = 0;
        if (wscale_ok) {
                /* Set window scaling on max possible window
-                * See RFC1323 for an explanation of the limit to 14 
+                * See RFC1323 for an explanation of the limit to 14
                 */
                space = max_t(u32, sysctl_tcp_rmem[2], sysctl_rmem_max);
                space = min_t(u32, space, *window_clamp);
@@ -451,7 +451,7 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it,
                                    (tp->rx_opt.eff_sacks *
                                     TCPOLEN_SACK_PERBLOCK));
        }
-               
+
        if (tcp_packets_in_flight(tp) == 0)
                tcp_ca_event(sk, CA_EVENT_TX_START);
 
@@ -555,7 +555,7 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it,
 }
 
 
-/* This routine just queue's the buffer 
+/* This routine just queue's the buffer
  *
  * NOTE: probe0 timer is not checked, do not forget tcp_push_pending_frames,
  * otherwise socket can stall.
@@ -597,7 +597,7 @@ static void tcp_set_skb_tso_segs(struct sock *sk, struct sk_buff *skb, unsigned
 
 /* Function to create two new TCP segments.  Shrinks the given segment
  * to the specified size and appends a new segment with the rest of the
- * packet to the list.  This won't be called frequently, I hope. 
+ * packet to the list.  This won't be called frequently, I hope.
  * Remember, these are still headerless SKBs at this point.
  */
 int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len, unsigned int mss_now)
@@ -610,7 +610,7 @@ int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len, unsigned int mss
 
        BUG_ON(len > skb->len);
 
-       clear_all_retrans_hints(tp);
+       clear_all_retrans_hints(tp);
        nsize = skb_headlen(skb) - len;
        if (nsize < 0)
                nsize = 0;
@@ -821,7 +821,7 @@ void tcp_mtup_init(struct sock *sk)
 
        icsk->icsk_mtup.enabled = sysctl_tcp_mtu_probing > 1;
        icsk->icsk_mtup.search_high = tp->rx_opt.mss_clamp + sizeof(struct tcphdr) +
-                              icsk->icsk_af_ops->net_header_len;
+                              icsk->icsk_af_ops->net_header_len;
        icsk->icsk_mtup.search_low = tcp_mss_to_mtu(sk, sysctl_tcp_base_mss);
        icsk->icsk_mtup.probe_size = 0;
 }
@@ -965,7 +965,8 @@ static inline unsigned int tcp_cwnd_test(struct tcp_sock *tp, struct sk_buff *sk
        u32 in_flight, cwnd;
 
        /* Don't be strict about the congestion window for the final FIN.  */
-       if (TCP_SKB_CB(skb)->flags & TCPCB_FLAG_FIN)
+       if ((TCP_SKB_CB(skb)->flags & TCPCB_FLAG_FIN) &&
+           tcp_skb_pcount(skb) == 1)
                return 1;
 
        in_flight = tcp_packets_in_flight(tp);
@@ -1007,7 +1008,7 @@ static inline int tcp_minshall_check(const struct tcp_sock *tp)
  */
 
 static inline int tcp_nagle_check(const struct tcp_sock *tp,
-                                 const struct sk_buff *skb, 
+                                 const struct sk_buff *skb,
                                  unsigned mss_now, int nonagle)
 {
        return (skb->len < mss_now &&
@@ -1077,7 +1078,7 @@ static unsigned int tcp_snd_test(struct sock *sk, struct sk_buff *skb,
        return cwnd_quota;
 }
 
-static inline int tcp_skb_is_last(const struct sock *sk, 
+static inline int tcp_skb_is_last(const struct sock *sk,
                                  const struct sk_buff *skb)
 {
        return skb->next == (struct sk_buff *)&sk->sk_write_queue;
@@ -1297,7 +1298,7 @@ static int tcp_mtu_probe(struct sock *sk)
                        skb_copy_bits(skb, 0, skb_put(nskb, copy), copy);
                else
                        nskb->csum = skb_copy_and_csum_bits(skb, 0,
-                                        skb_put(nskb, copy), copy, nskb->csum);
+                                        skb_put(nskb, copy), copy, nskb->csum);
 
                if (skb->len <= copy) {
                        /* We've eaten all the data from this skb.
@@ -1307,7 +1308,7 @@ static int tcp_mtu_probe(struct sock *sk)
                        sk_stream_free_skb(sk, skb);
                } else {
                        TCP_SKB_CB(nskb)->flags |= TCP_SKB_CB(skb)->flags &
-                                                  ~(TCPCB_FLAG_FIN|TCPCB_FLAG_PSH);
+                                                  ~(TCPCB_FLAG_FIN|TCPCB_FLAG_PSH);
                        if (!skb_shinfo(skb)->nr_frags) {
                                skb_pull(skb, copy);
                                if (skb->ip_summed != CHECKSUM_PARTIAL)
@@ -1500,7 +1501,7 @@ void tcp_push_one(struct sock *sk, unsigned int mss_now)
 
 /* This function returns the amount that we can raise the
  * usable window based on the following constraints
- *  
+ *
  * 1. The window can never be shrunk once it is offered (RFC 793)
  * 2. We limit memory per socket
  *
@@ -1519,12 +1520,12 @@ void tcp_push_one(struct sock *sk, unsigned int mss_now)
  * side SWS prevention criteria. The problem is that under this rule
  * a stream of single byte packets will cause the right side of the
  * window to always advance by a single byte.
- * 
+ *
  * Of course, if the sender implements sender side SWS prevention
  * then this will not be a problem.
- * 
+ *
  * BSD seems to make the following compromise:
- * 
+ *
  *     If the free space is less than the 1/4 of the maximum
  *     space available and the free space is less than 1/2 mss,
  *     then set the window to 0.
@@ -1566,7 +1567,7 @@ u32 __tcp_select_window(struct sock *sk)
        int window;
 
        if (mss > full_space)
-               mss = full_space; 
+               mss = full_space;
 
        if (free_space < full_space/2) {
                icsk->icsk_ack.quick = 0;
@@ -1690,9 +1691,9 @@ static void tcp_retrans_try_collapse(struct sock *sk, struct sk_buff *skb, int m
 }
 
 /* Do a simple retransmit without using the backoff mechanisms in
- * tcp_timer. This is used for path mtu discovery. 
+ * tcp_timer. This is used for path mtu discovery.
  * The socket is already locked here.
- */ 
+ */
 void tcp_simple_retransmit(struct sock *sk)
 {
        const struct inet_connection_sock *icsk = inet_csk(sk);
@@ -1702,7 +1703,7 @@ void tcp_simple_retransmit(struct sock *sk)
        int lost = 0;
 
        sk_stream_for_retrans_queue(skb, sk) {
-               if (skb->len > mss && 
+               if (skb->len > mss &&
                    !(TCP_SKB_CB(skb)->sacked&TCPCB_SACKED_ACKED)) {
                        if (TCP_SKB_CB(skb)->sacked&TCPCB_SACKED_RETRANS) {
                                TCP_SKB_CB(skb)->sacked &= ~TCPCB_SACKED_RETRANS;
@@ -1723,7 +1724,7 @@ void tcp_simple_retransmit(struct sock *sk)
 
        tcp_sync_left_out(tp);
 
-       /* Don't muck with the congestion window here.
+       /* Don't muck with the congestion window here.
         * Reason is that we do not increase amount of _data_
         * in network, but units changed and effective
         * cwnd/ssthresh really reduced now.
@@ -1746,7 +1747,7 @@ int tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb)
 {
        struct tcp_sock *tp = tcp_sk(sk);
        struct inet_connection_sock *icsk = inet_csk(sk);
-       unsigned int cur_mss = tcp_current_mss(sk, 0);
+       unsigned int cur_mss = tcp_current_mss(sk, 0);
        int err;
 
        /* Inconslusive MTU probe */
@@ -1983,10 +1984,10 @@ void tcp_xmit_retransmit_queue(struct sock *sk)
  */
 void tcp_send_fin(struct sock *sk)
 {
-       struct tcp_sock *tp = tcp_sk(sk);       
+       struct tcp_sock *tp = tcp_sk(sk);
        struct sk_buff *skb = skb_peek_tail(&sk->sk_write_queue);
        int mss_now;
-       
+
        /* Optimization, tack on the FIN if we have a queue of
         * unsent frames.  But be careful about outgoing SACKS
         * and IP options.
@@ -2145,17 +2146,17 @@ struct sk_buff * tcp_make_synack(struct sock *sk, struct dst_entry *dst,
        th->seq = htonl(TCP_SKB_CB(skb)->seq);
        th->ack_seq = htonl(tcp_rsk(req)->rcv_isn + 1);
        if (req->rcv_wnd == 0) { /* ignored for retransmitted syns */
-               __u8 rcv_wscale; 
+               __u8 rcv_wscale;
                /* Set this up on the first call only */
                req->window_clamp = tp->window_clamp ? : dst_metric(dst, RTAX_WINDOW);
                /* tcp_full_space because it is guaranteed to be the first packet */
-               tcp_select_initial_window(tcp_full_space(sk), 
+               tcp_select_initial_window(tcp_full_space(sk),
                        dst_metric(dst, RTAX_ADVMSS) - (ireq->tstamp_ok ? TCPOLEN_TSTAMP_ALIGNED : 0),
                        &req->rcv_wnd,
                        &req->window_clamp,
                        ireq->wscale_ok,
                        &rcv_wscale);
-               ireq->rcv_wscale = rcv_wscale; 
+               ireq->rcv_wscale = rcv_wscale;
        }
 
        /* RFC1323: The window in SYN & SYN/ACK segments is never scaled. */
@@ -2191,9 +2192,9 @@ struct sk_buff * tcp_make_synack(struct sock *sk, struct dst_entry *dst,
        return skb;
 }
 
-/* 
+/*
  * Do all connect socket setups that can be done AF independent.
- */ 
+ */
 static void tcp_connect_init(struct sock *sk)
 {
        struct dst_entry *dst = __sk_dst_get(sk);
@@ -2250,7 +2251,7 @@ static void tcp_connect_init(struct sock *sk)
 
 /*
  * Build a SYN and send it off.
- */ 
+ */
 int tcp_connect(struct sock *sk)
 {
        struct tcp_sock *tp = tcp_sk(sk);
@@ -2408,7 +2409,7 @@ static int tcp_xmit_probe_skb(struct sock *sk, int urgent)
 
        /* We don't queue it, tcp_transmit_skb() sets ownership. */
        skb = alloc_skb(MAX_TCP_HEADER, GFP_ATOMIC);
-       if (skb == NULL) 
+       if (skb == NULL)
                return -1;
 
        /* Reserve space for headers and set control bits. */
@@ -2497,7 +2498,7 @@ void tcp_send_probe0(struct sock *sk)
                if (icsk->icsk_backoff < sysctl_tcp_retries2)
                        icsk->icsk_backoff++;
                icsk->icsk_probes_out++;
-               inet_csk_reset_xmit_timer(sk, ICSK_TIME_PROBE0, 
+               inet_csk_reset_xmit_timer(sk, ICSK_TIME_PROBE0,
                                          min(icsk->icsk_rto << icsk->icsk_backoff, TCP_RTO_MAX),
                                          TCP_RTO_MAX);
        } else {
@@ -2509,7 +2510,7 @@ void tcp_send_probe0(struct sock *sk)
                 */
                if (!icsk->icsk_probes_out)
                        icsk->icsk_probes_out = 1;
-               inet_csk_reset_xmit_timer(sk, ICSK_TIME_PROBE0, 
+               inet_csk_reset_xmit_timer(sk, ICSK_TIME_PROBE0,
                                          min(icsk->icsk_rto << icsk->icsk_backoff,
                                              TCP_RESOURCE_PROBE_INTERVAL),
                                          TCP_RTO_MAX);
index 3355c276b61146d561a073f6f4c98063cd15b3bd..a9243cfc1beadfa942184935cbe830d62e6fd0fc 100644 (file)
@@ -69,7 +69,7 @@ static int tcp_out_of_resources(struct sock *sk, int do_reset)
        struct tcp_sock *tp = tcp_sk(sk);
        int orphans = atomic_read(&tcp_orphan_count);
 
-       /* If peer does not open window for long time, or did not transmit 
+       /* If peer does not open window for long time, or did not transmit
         * anything for long time, penalize it. */
        if ((s32)(tcp_time_stamp - tp->lsndtime) > 2*TCP_RTO_MAX || !do_reset)
                orphans <<= 1;
@@ -137,7 +137,7 @@ static int tcp_write_timeout(struct sock *sk)
                                        tcp_sync_mss(sk, icsk->icsk_pmtu_cookie);
                                } else {
                                        mss = min(sysctl_tcp_base_mss,
-                                                 tcp_mtu_to_mss(sk, icsk->icsk_mtup.search_low)/2);
+                                                 tcp_mtu_to_mss(sk, icsk->icsk_mtup.search_low)/2);
                                        mss = max(mss, 68 - tp->tcp_header_len);
                                        icsk->icsk_mtup.search_low = tcp_mss_to_mtu(sk, mss);
                                        tcp_sync_mss(sk, icsk->icsk_pmtu_cookie);
@@ -150,7 +150,7 @@ static int tcp_write_timeout(struct sock *sk)
                retry_until = sysctl_tcp_retries2;
                if (sock_flag(sk, SOCK_DEAD)) {
                        const int alive = (icsk->icsk_rto < TCP_RTO_MAX);
+
                        retry_until = tcp_orphan_retries(sk, alive);
 
                        if (tcp_out_of_resources(sk, alive || icsk->icsk_retransmits < retry_until))
@@ -257,7 +257,7 @@ static void tcp_probe_timer(struct sock *sk)
 
        if (sock_flag(sk, SOCK_DEAD)) {
                const int alive = ((icsk->icsk_rto << icsk->icsk_backoff) < TCP_RTO_MAX);
+
                max_probes = tcp_orphan_retries(sk, alive);
 
                if (tcp_out_of_resources(sk, alive || icsk->icsk_probes_out <= max_probes))
@@ -453,7 +453,7 @@ static void tcp_keepalive_timer (unsigned long data)
        /* Only process if socket is not in use. */
        bh_lock_sock(sk);
        if (sock_owned_by_user(sk)) {
-               /* Try again later. */ 
+               /* Try again later. */
                inet_csk_reset_keepalive_timer (sk, HZ/20);
                goto out;
        }
@@ -515,7 +515,7 @@ resched:
        inet_csk_reset_keepalive_timer (sk, elapsed);
        goto out;
 
-death: 
+death:
        tcp_done(sk);
 
 out:
index ddc4bcc5785eed2737c2ddca93422026f86c3e0f..5c484dceb9675b7563dcf41faeb58eb38d17742c 100644 (file)
@@ -330,9 +330,9 @@ static void tcp_vegas_cong_avoid(struct sock *sk, u32 ack,
                vegas->minRTT = 0x7fffffff;
        }
        /* Use normal slow start */
-       else if (tp->snd_cwnd <= tp->snd_ssthresh) 
+       else if (tp->snd_cwnd <= tp->snd_ssthresh)
                tcp_slow_start(tp);
-       
+
 }
 
 /* Extract info for Tcp socket info provided via netlink. */
index 4f42a86c77f377deb3972838e4737e4cf1006788..4e1b61032a9cb4d7bcbae5ce4980cd1362f56353 100644 (file)
@@ -63,10 +63,10 @@ static void tcp_westwood_init(struct sock *sk)
        struct westwood *w = inet_csk_ca(sk);
 
        w->bk = 0;
-        w->bw_ns_est = 0;
-        w->bw_est = 0;
-        w->accounted = 0;
-        w->cumul_ack = 0;
+       w->bw_ns_est = 0;
+       w->bw_est = 0;
+       w->accounted = 0;
+       w->cumul_ack = 0;
        w->reset_rtt_min = 1;
        w->rtt_min = w->rtt = TCP_WESTWOOD_INIT_RTT;
        w->rtt_win_sx = tcp_time_stamp;
@@ -121,7 +121,7 @@ static void westwood_update_window(struct sock *sk)
         * to fix mismatch between tp->snd_una and w->snd_una for the first
         * bandwidth sample
         */
-        if (w->first_ack) {
+       if (w->first_ack) {
                w->snd_una = tcp_sk(sk)->snd_una;
                w->first_ack = 0;
        }
@@ -147,7 +147,7 @@ static inline void update_rtt_min(struct westwood *w)
 {
        if (w->reset_rtt_min) {
                w->rtt_min = w->rtt;
-               w->reset_rtt_min = 0;   
+               w->reset_rtt_min = 0;
        } else
                w->rtt_min = min(w->rtt, w->rtt_min);
 }
@@ -183,15 +183,15 @@ static inline u32 westwood_acked_count(struct sock *sk)
 
        w->cumul_ack = tp->snd_una - w->snd_una;
 
-        /* If cumul_ack is 0 this is a dupack since it's not moving
-         * tp->snd_una.
-         */
-        if (!w->cumul_ack) {
+       /* If cumul_ack is 0 this is a dupack since it's not moving
+        * tp->snd_una.
+        */
+       if (!w->cumul_ack) {
                w->accounted += tp->mss_cache;
                w->cumul_ack = tp->mss_cache;
        }
 
-        if (w->cumul_ack > tp->mss_cache) {
+       if (w->cumul_ack > tp->mss_cache) {
                /* Partial or delayed ack */
                if (w->accounted >= w->cumul_ack) {
                        w->accounted -= w->cumul_ack;
@@ -237,7 +237,7 @@ static void tcp_westwood_event(struct sock *sk, enum tcp_ca_event event)
 
        case CA_EVENT_FRTO:
                tp->snd_ssthresh = tcp_westwood_bw_rttmin(sk);
-               /* Update RTT_min when next ack arrives */
+               /* Update RTT_min when next ack arrives */
                w->reset_rtt_min = 1;
                break;
 
index cfff930f2bafc78039908c1ab728d2340e4dc26d..ce6c46034314b35a3d17d2d18d35b0538cfe5116 100644 (file)
@@ -20,8 +20,8 @@
  *                                     for udp at least is 'valid'.
  *             Alan Cox        :       Fixed icmp handling properly
  *             Alan Cox        :       Correct error for oversized datagrams
- *             Alan Cox        :       Tidied select() semantics. 
- *             Alan Cox        :       udp_err() fixed properly, also now 
+ *             Alan Cox        :       Tidied select() semantics.
+ *             Alan Cox        :       udp_err() fixed properly, also now
  *                                     select and read wake correctly on errors
  *             Alan Cox        :       udp_send verify_area moved to avoid mem leak
  *             Alan Cox        :       UDP can count its memory
@@ -56,7 +56,7 @@
  *                                     does have a high hit rate.
  *             Olaf Kirch      :       Don't linearise iovec on sendmsg.
  *             Andi Kleen      :       Some cleanups, cache destination entry
- *                                     for connect. 
+ *                                     for connect.
  *     Vitaly E. Lavrov        :       Transparent proxy revived after year coma.
  *             Melvin Smith    :       Check msg_name not msg_namelen in sendto(),
  *                                     return ENOTCONN for unconnected sockets (POSIX)
@@ -77,7 +77,7 @@
  *             as published by the Free Software Foundation; either version
  *             2 of the License, or (at your option) any later version.
  */
+
 #include <asm/system.h>
 #include <asm/uaccess.h>
 #include <asm/ioctls.h>
@@ -120,7 +120,7 @@ static inline int __udp_lib_lport_inuse(__u16 num, struct hlist_head udptable[])
        struct hlist_node *node;
 
        sk_for_each(sk, node, &udptable[num & (UDP_HTABLE_SIZE - 1)])
-               if (inet_sk(sk)->num == num)
+               if (sk->sk_hash == num)
                        return 1;
        return 0;
 }
@@ -191,7 +191,7 @@ gotit:
                head = &udptable[snum & (UDP_HTABLE_SIZE - 1)];
 
                sk_for_each(sk2, node, head)
-                       if (inet_sk(sk2)->num == snum                        &&
+                       if (sk2->sk_hash == snum                             &&
                            sk2 != sk                                        &&
                            (!sk2->sk_reuse        || !sk->sk_reuse)         &&
                            (!sk2->sk_bound_dev_if || !sk->sk_bound_dev_if
@@ -200,6 +200,7 @@ gotit:
                                goto fail;
        }
        inet_sk(sk)->num = snum;
+       sk->sk_hash = snum;
        if (sk_unhashed(sk)) {
                head = &udptable[snum & (UDP_HTABLE_SIZE - 1)];
                sk_add_node(sk, head);
@@ -247,7 +248,7 @@ static struct sock *__udp4_lib_lookup(__be32 saddr, __be16 sport,
        sk_for_each(sk, node, &udptable[hnum & (UDP_HTABLE_SIZE - 1)]) {
                struct inet_sock *inet = inet_sk(sk);
 
-               if (inet->num == hnum && !ipv6_only_sock(sk)) {
+               if (sk->sk_hash == hnum && !ipv6_only_sock(sk)) {
                        int score = (sk->sk_family == PF_INET ? 1 : 0);
                        if (inet->rcv_saddr) {
                                if (inet->rcv_saddr != daddr)
@@ -296,7 +297,7 @@ static inline struct sock *udp_v4_mcast_next(struct sock *sk,
        sk_for_each_from(s, node) {
                struct inet_sock *inet = inet_sk(s);
 
-               if (inet->num != hnum                                   ||
+               if (s->sk_hash != hnum                                  ||
                    (inet->daddr && inet->daddr != rmt_addr)            ||
                    (inet->dport != rmt_port && inet->dport)            ||
                    (inet->rcv_saddr && inet->rcv_saddr != loc_addr)    ||
@@ -306,17 +307,17 @@ static inline struct sock *udp_v4_mcast_next(struct sock *sk,
                if (!ip_mc_sf_allow(s, loc_addr, rmt_addr, dif))
                        continue;
                goto found;
-       }
+       }
        s = NULL;
 found:
-       return s;
+       return s;
 }
 
 /*
  * This routine is called by the ICMP module when it gets some
  * sort of error condition.  If err < 0 then the socket should
  * be closed and the error returned to the user.  If err > 0
- * it's just the icmp type << 8 | icmp code.  
+ * it's just the icmp type << 8 | icmp code.
  * Header points to the ip header of the error packet. We move
  * on past this. Then (as it used to claim before adjustment)
  * header points to the first 8 bytes of the udp header.  We need
@@ -338,7 +339,7 @@ void __udp4_lib_err(struct sk_buff *skb, u32 info, struct hlist_head udptable[])
                               skb->dev->ifindex, udptable                  );
        if (sk == NULL) {
                ICMP_INC_STATS_BH(ICMP_MIB_INERRORS);
-               return; /* No socket for error */
+               return; /* No socket for error */
        }
 
        err = 0;
@@ -374,7 +375,7 @@ void __udp4_lib_err(struct sk_buff *skb, u32 info, struct hlist_head udptable[])
        }
 
        /*
-        *      RFC1122: OK.  Passes ICMP errors back to application, as per 
+        *      RFC1122: OK.  Passes ICMP errors back to application, as per
         *      4.1.3.3.
         */
        if (!inet->recverr) {
@@ -524,7 +525,7 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
        if (len > 0xFFFF)
                return -EMSGSIZE;
 
-       /* 
+       /*
         *      Check the flags.
         */
 
@@ -536,7 +537,7 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
        if (up->pending) {
                /*
                 * There are pending frames.
-                * The socket lock must be held while it's corked.
+                * The socket lock must be held while it's corked.
                 */
                lock_sock(sk);
                if (likely(up->pending)) {
@@ -544,14 +545,14 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
                                release_sock(sk);
                                return -EINVAL;
                        }
-                       goto do_append_data;
+                       goto do_append_data;
                }
                release_sock(sk);
        }
        ulen += sizeof(struct udphdr);
 
        /*
-        *      Get and verify the address. 
+        *      Get and verify the address.
         */
        if (msg->msg_name) {
                struct sockaddr_in * usin = (struct sockaddr_in*)msg->msg_name;
@@ -575,7 +576,7 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
                   Route will not be used, if at least one option is set.
                 */
                connected = 1;
-       }
+       }
        ipc.addr = inet->saddr;
 
        ipc.oif = sk->sk_bound_dev_if;
@@ -601,7 +602,7 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
        }
        tos = RT_TOS(inet->tos);
        if (sock_flag(sk, SOCK_LOCALROUTE) ||
-           (msg->msg_flags & MSG_DONTROUTE) || 
+           (msg->msg_flags & MSG_DONTROUTE) ||
            (ipc.opt && ipc.opt->is_strictroute)) {
                tos |= RTO_ONLINK;
                connected = 0;
@@ -629,7 +630,7 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
                                               { .sport = inet->sport,
                                                 .dport = dport } } };
                security_sk_classify_flow(sk, &fl);
-               err = ip_route_output_flow(&rt, &fl, sk, !(msg->msg_flags&MSG_DONTWAIT));
+               err = ip_route_output_flow(&rt, &fl, sk, 1);
                if (err)
                        goto out;
 
@@ -761,10 +762,10 @@ out:
 /*
  *     IOCTL requests applicable to the UDP protocol
  */
+
 int udp_ioctl(struct sock *sk, int cmd, unsigned long arg)
 {
-       switch(cmd) 
+       switch(cmd)
        {
                case SIOCOUTQ:
                {
@@ -804,11 +805,11 @@ int udp_ioctl(struct sock *sk, int cmd, unsigned long arg)
  */
 
 int udp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
-               size_t len, int noblock, int flags, int *addr_len)
+               size_t len, int noblock, int flags, int *addr_len)
 {
        struct inet_sock *inet = inet_sk(sk);
-       struct sockaddr_in *sin = (struct sockaddr_in *)msg->msg_name;
-       struct sk_buff *skb;
+       struct sockaddr_in *sin = (struct sockaddr_in *)msg->msg_name;
+       struct sk_buff *skb;
        int copied, err, copy_only, is_udplite = IS_UDPLITE(sk);
 
        /*
@@ -824,8 +825,8 @@ try_again:
        skb = skb_recv_datagram(sk, flags, noblock, &err);
        if (!skb)
                goto out;
-  
-       copied = skb->len - sizeof(struct udphdr);
+
+       copied = skb->len - sizeof(struct udphdr);
        if (copied > len) {
                copied = len;
                msg->msg_flags |= MSG_TRUNC;
@@ -868,18 +869,18 @@ try_again:
                sin->sin_port = skb->h.uh->source;
                sin->sin_addr.s_addr = skb->nh.iph->saddr;
                memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
-       }
+       }
        if (inet->cmsg_flags)
                ip_cmsg_recv(msg, skb);
 
        err = copied;
        if (flags & MSG_TRUNC)
                err = skb->len - sizeof(struct udphdr);
-  
+
 out_free:
-       skb_free_datagram(sk, skb);
+       skb_free_datagram(sk, skb);
 out:
-       return err;
+       return err;
 
 csum_copy_err:
        UDP_INC_STATS_BH(UDP_MIB_INERRORS, is_udplite);
@@ -887,7 +888,7 @@ csum_copy_err:
        skb_kill_datagram(sk, skb, flags);
 
        if (noblock)
-               return -EAGAIN; 
+               return -EAGAIN;
        goto try_again;
 }
 
@@ -898,7 +899,7 @@ int udp_disconnect(struct sock *sk, int flags)
        /*
         *      1003.1g - break association.
         */
-        
+
        sk->sk_state = TCP_CLOSE;
        inet->daddr = 0;
        inet->dport = 0;
@@ -922,13 +923,13 @@ int udp_disconnect(struct sock *sk, int flags)
 static int udp_encap_rcv(struct sock * sk, struct sk_buff *skb)
 {
 #ifndef CONFIG_XFRM
-       return 1; 
+       return 1;
 #else
        struct udp_sock *up = udp_sk(sk);
-       struct udphdr *uh;
+       struct udphdr *uh;
        struct iphdr *iph;
        int iphlen, len;
-  
+
        __u8 *udpdata;
        __be32 *udpdata32;
        __u16 encap_type = up->encap_type;
@@ -971,7 +972,7 @@ static int udp_encap_rcv(struct sock * sk, struct sk_buff *skb)
                        return 0;
                } else if (len > 2 * sizeof(u32) + sizeof(struct ip_esp_hdr) &&
                           udpdata32[0] == 0 && udpdata32[1] == 0) {
-                       
+
                        /* ESP Packet with Non-IKE marker */
                        len = sizeof(struct udphdr) + 2 * sizeof(u32);
                } else
@@ -1187,14 +1188,14 @@ static inline void udp4_csum_init(struct sk_buff *skb, struct udphdr *uh)
 }
 
 /*
- *     All we need to do is get the socket, and then do a checksum. 
+ *     All we need to do is get the socket, and then do a checksum.
  */
+
 int __udp4_lib_rcv(struct sk_buff *skb, struct hlist_head udptable[],
                   int is_udplite)
 {
-       struct sock *sk;
-       struct udphdr *uh = skb->h.uh;
+       struct sock *sk;
+       struct udphdr *uh = skb->h.uh;
        unsigned short ulen;
        struct rtable *rt = (struct rtable*)skb->dst;
        __be32 saddr = skb->nh.iph->saddr;
@@ -1270,9 +1271,9 @@ short_packet:
        goto drop;
 
 csum_error:
-       /* 
-        * RFC1122: OK.  Discards the bad packet silently (as far as 
-        * the network is concerned, anyway) as per 4.1.3.4 (MUST). 
+       /*
+        * RFC1122: OK.  Discards the bad packet silently (as far as
+        * the network is concerned, anyway) as per 4.1.3.4 (MUST).
         */
        LIMIT_NETDEBUG(KERN_DEBUG "UDP%s: bad checksum. From %d.%d.%d.%d:%d to %d.%d.%d.%d:%d ulen %d\n",
                       is_udplite? "-Lite" : "",
@@ -1328,7 +1329,7 @@ int udp_lib_setsockopt(struct sock *sk, int level, int optname,
                        release_sock(sk);
                }
                break;
-               
+
        case UDP_ENCAP:
                switch (val) {
                case 0:
@@ -1356,8 +1357,8 @@ int udp_lib_setsockopt(struct sock *sk, int level, int optname,
                up->pcflag |= UDPLITE_SEND_CC;
                break;
 
-        /* The receiver specifies a minimum checksum coverage value. To make
-         * sense, this should be set to at least 8 (as done below). If zero is
+       /* The receiver specifies a minimum checksum coverage value. To make
+        * sense, this should be set to at least 8 (as done below). If zero is
         * used, this again means full checksum coverage.                     */
        case UDPLITE_RECV_CSCOV:
                if (!up->pcflag)         /* Disable the option on UDP sockets */
@@ -1406,7 +1407,7 @@ int udp_lib_getsockopt(struct sock *sk, int level, int optname,
                return -EFAULT;
 
        len = min_t(unsigned int, len, sizeof(int));
-       
+
        if(len < 0)
                return -EINVAL;
 
@@ -1433,11 +1434,11 @@ int udp_lib_getsockopt(struct sock *sk, int level, int optname,
                return -ENOPROTOOPT;
        };
 
-       if(put_user(len, optlen))
-               return -EFAULT;
+       if(put_user(len, optlen))
+               return -EFAULT;
        if(copy_to_user(optval, &val,len))
                return -EFAULT;
-       return 0;
+       return 0;
 }
 
 int udp_getsockopt(struct sock *sk, int level, int optname,
@@ -1463,7 +1464,7 @@ int compat_udp_getsockopt(struct sock *sk, int level, int optname,
  *     @sock - socket
  *     @wait - poll table
  *
- *     This is same as datagram poll, except for the special case of 
+ *     This is same as datagram poll, except for the special case of
  *     blocking sockets. If application is using a blocking fd
  *     and a packet with checksum error is in the queue;
  *     then it could get return from select indicating data available
@@ -1502,11 +1503,11 @@ unsigned int udp_poll(struct file *file, struct socket *sock, poll_table *wait)
        }
 
        return mask;
-       
+
 }
 
 struct proto udp_prot = {
-       .name              = "UDP",
+       .name              = "UDP",
        .owner             = THIS_MODULE,
        .close             = udp_lib_close,
        .connect           = ip4_datagram_connect,
@@ -1670,7 +1671,7 @@ static void udp4_format_sock(struct sock *sp, char *tmpbuf, int bucket)
 
        sprintf(tmpbuf, "%4d: %08X:%04X %08X:%04X"
                " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p",
-               bucket, src, srcp, dest, destp, sp->sk_state, 
+               bucket, src, srcp, dest, destp, sp->sk_state,
                atomic_read(&sp->sk_wmem_alloc),
                atomic_read(&sp->sk_rmem_alloc),
                0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
index f6f4277ba6dc8ce23d9cf1d878a4ca3916106d8b..820a477cfaa6e9899234b03ee8120c9ca158babd 100644 (file)
@@ -10,7 +10,7 @@ extern void   __udp4_lib_err(struct sk_buff *, u32, struct hlist_head []);
 
 extern int     __udp_lib_get_port(struct sock *sk, unsigned short snum,
                                   struct hlist_head udptable[], int *port_rover,
-                                  int (*)(const struct sock*,const struct sock*));
+                                  int (*)(const struct sock*,const struct sock*));
 extern int     ipv4_rcv_saddr_equal(const struct sock *, const struct sock *);
 
 
index 8655d038364cba364880f8cb9595e94708fe14db..289146bdb8b07ef906f11482e85844bbe34fd320 100644 (file)
@@ -6,7 +6,7 @@
  *             Split up af-specific portion
  *     Derek Atkins <derek@ihtfp.com>
  *             Add Encapsulation support
- *     
+ *
  */
 
 #include <linux/module.h>
@@ -42,7 +42,7 @@ static inline int xfrm4_rcv_encap_finish(struct sk_buff *skb)
 
        if (skb->dst == NULL) {
                if (ip_route_input(skb, iph->daddr, iph->saddr, iph->tos,
-                                  skb->dev))
+                                  skb->dev))
                        goto drop;
        }
        return dst_input(skb);
@@ -149,7 +149,7 @@ int xfrm4_rcv_encap(struct sk_buff *skb, __u16 encap_type)
                ip_send_check(skb->nh.iph);
 
                NF_HOOK(PF_INET, NF_IP_PRE_ROUTING, skb, skb->dev, NULL,
-                       xfrm4_rcv_encap_finish);
+                       xfrm4_rcv_encap_finish);
                return 0;
 #else
                return -skb->nh.iph->protocol;
index e23c21d31a531ba927956f9a61b28d63caec72d7..e54c5494c88ffbf7d8d5b9733061e13b282a4f2c 100644 (file)
@@ -23,6 +23,12 @@ static inline void ipip_ecn_decapsulate(struct sk_buff *skb)
                IP_ECN_set_ce(inner_iph);
 }
 
+static inline void ipip6_ecn_decapsulate(struct iphdr *iph, struct sk_buff *skb)
+{
+       if (INET_ECN_is_ce(iph->tos))
+               IP6_ECN_set_ce(skb->nh.ipv6h);
+}
+
 /* Add encapsulation header.
  *
  * The top IP header will be constructed per RFC 2401.  The following fields
@@ -36,6 +42,7 @@ static inline void ipip_ecn_decapsulate(struct sk_buff *skb)
 static int xfrm4_tunnel_output(struct xfrm_state *x, struct sk_buff *skb)
 {
        struct dst_entry *dst = skb->dst;
+       struct xfrm_dst *xdst = (struct xfrm_dst*)dst;
        struct iphdr *iph, *top_iph;
        int flags;
 
@@ -48,15 +55,27 @@ static int xfrm4_tunnel_output(struct xfrm_state *x, struct sk_buff *skb)
        top_iph->ihl = 5;
        top_iph->version = 4;
 
+       flags = x->props.flags;
+
        /* DS disclosed */
-       top_iph->tos = INET_ECN_encapsulate(iph->tos, iph->tos);
+       if (xdst->route->ops->family == AF_INET) {
+               top_iph->protocol = IPPROTO_IPIP;
+               top_iph->tos = INET_ECN_encapsulate(iph->tos, iph->tos);
+               top_iph->frag_off = (flags & XFRM_STATE_NOPMTUDISC) ?
+                       0 : (iph->frag_off & htons(IP_DF));
+       }
+#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
+       else {
+               struct ipv6hdr *ipv6h = (struct ipv6hdr*)iph;
+               top_iph->protocol = IPPROTO_IPV6;
+               top_iph->tos = INET_ECN_encapsulate(iph->tos, ipv6_get_dsfield(ipv6h));
+               top_iph->frag_off = 0;
+       }
+#endif
 
-       flags = x->props.flags;
        if (flags & XFRM_STATE_NOECN)
                IP_ECN_clear(top_iph);
 
-       top_iph->frag_off = (flags & XFRM_STATE_NOPMTUDISC) ?
-               0 : (iph->frag_off & htons(IP_DF));
        if (!top_iph->frag_off)
                __ip_select_ident(top_iph, dst->child, 0);
 
@@ -64,7 +83,6 @@ static int xfrm4_tunnel_output(struct xfrm_state *x, struct sk_buff *skb)
 
        top_iph->saddr = x->props.saddr.a4;
        top_iph->daddr = x->id.daddr.a4;
-       top_iph->protocol = IPPROTO_IPIP;
 
        memset(&(IPCB(skb)->opt), 0, sizeof(struct ip_options));
        return 0;
@@ -75,8 +93,16 @@ static int xfrm4_tunnel_input(struct xfrm_state *x, struct sk_buff *skb)
        struct iphdr *iph = skb->nh.iph;
        int err = -EINVAL;
 
-       if (iph->protocol != IPPROTO_IPIP)
-               goto out;
+       switch(iph->protocol){
+               case IPPROTO_IPIP:
+#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
+               case IPPROTO_IPV6:
+                       break;
+#endif
+               default:
+                       goto out;
+       }
+
        if (!pskb_may_pull(skb, sizeof(struct iphdr)))
                goto out;
 
@@ -84,10 +110,19 @@ static int xfrm4_tunnel_input(struct xfrm_state *x, struct sk_buff *skb)
            (err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC)))
                goto out;
 
-       if (x->props.flags & XFRM_STATE_DECAP_DSCP)
-               ipv4_copy_dscp(iph, skb->h.ipiph);
-       if (!(x->props.flags & XFRM_STATE_NOECN))
-               ipip_ecn_decapsulate(skb);
+       if (iph->protocol == IPPROTO_IPIP) {
+               if (x->props.flags & XFRM_STATE_DECAP_DSCP)
+                       ipv4_copy_dscp(iph, skb->h.ipiph);
+               if (!(x->props.flags & XFRM_STATE_NOECN))
+                       ipip_ecn_decapsulate(skb);
+       }
+#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
+       else {
+               if (!(x->props.flags & XFRM_STATE_NOECN))
+                       ipip6_ecn_decapsulate(iph, skb);
+               skb->protocol = htons(ETH_P_IPV6);
+       }
+#endif
        skb->mac.raw = memmove(skb->data - skb->mac_len,
                               skb->mac.raw, skb->mac_len);
        skb->nh.raw = skb->data;
index 04403fb01a5890abb1d1d8c41b8812b6d9c9b5d4..038ca160fe2c4c67e3ba17fd39f3361fd31fa795 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * xfrm4_output.c - Common IPsec encapsulation code for IPv4.
  * Copyright (c) 2004 Herbert Xu <herbert@gondor.apana.org.au>
- * 
+ *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version
@@ -28,7 +28,7 @@ static int xfrm4_tunnel_check_size(struct sk_buff *skb)
                goto out;
 
        IPCB(skb)->flags |= IPSKB_XFRM_TUNNEL_SIZE;
-       
+
        if (!(iph->frag_off & htons(IP_DF)) || skb->local_df)
                goto out;
 
@@ -47,7 +47,7 @@ static int xfrm4_output_one(struct sk_buff *skb)
        struct dst_entry *dst = skb->dst;
        struct xfrm_state *x = dst->xfrm;
        int err;
-       
+
        if (skb->ip_summed == CHECKSUM_PARTIAL) {
                err = skb_checksum_help(skb);
                if (err)
@@ -78,7 +78,7 @@ static int xfrm4_output_one(struct sk_buff *skb)
                x->curlft.packets++;
 
                spin_unlock_bh(&x->lock);
-       
+
                if (!(skb->dst = dst_pop(dst))) {
                        err = -EHOSTUNREACH;
                        goto error_nolock;
index fb9f69c616f5c3dbf43af6db14a8178aba46419b..fef19c6bcb98b89496c3e622041c77efd5ca9423 100644 (file)
@@ -1,11 +1,11 @@
-/* 
+/*
  * xfrm4_policy.c
  *
  * Changes:
  *     Kazunori MIYAZAWA @USAGI
  *     YOSHIFUJI Hideaki @USAGI
  *             Split up af-specific portion
- *     
+ *
  */
 
 #include <linux/compiler.h>
@@ -50,8 +50,8 @@ __xfrm4_find_bundle(struct flowi *fl, struct xfrm_policy *policy)
                struct xfrm_dst *xdst = (struct xfrm_dst*)dst;
                if (xdst->u.rt.fl.oif == fl->oif &&     /*XXX*/
                    xdst->u.rt.fl.fl4_dst == fl->fl4_dst &&
-                   xdst->u.rt.fl.fl4_src == fl->fl4_src &&
-                   xdst->u.rt.fl.fl4_tos == fl->fl4_tos &&
+                   xdst->u.rt.fl.fl4_src == fl->fl4_src &&
+                   xdst->u.rt.fl.fl4_tos == fl->fl4_tos &&
                    xfrm_bundle_ok(policy, xdst, fl, AF_INET, 0)) {
                        dst_clone(dst);
                        break;
@@ -72,13 +72,11 @@ __xfrm4_bundle_create(struct xfrm_policy *policy, struct xfrm_state **xfrm, int
        struct dst_entry *dst, *dst_prev;
        struct rtable *rt0 = (struct rtable*)(*dst_p);
        struct rtable *rt = rt0;
-       __be32 remote = fl->fl4_dst;
-       __be32 local  = fl->fl4_src;
        struct flowi fl_tunnel = {
                .nl_u = {
                        .ip4_u = {
-                               .saddr = local,
-                               .daddr = remote,
+                               .saddr = fl->fl4_src,
+                               .daddr = fl->fl4_dst,
                                .tos = fl->fl4_tos
                        }
                }
@@ -94,7 +92,6 @@ __xfrm4_bundle_create(struct xfrm_policy *policy, struct xfrm_state **xfrm, int
        for (i = 0; i < nx; i++) {
                struct dst_entry *dst1 = dst_alloc(&xfrm4_dst_ops);
                struct xfrm_dst *xdst;
-               int tunnel = 0;
 
                if (unlikely(dst1 == NULL)) {
                        err = -ENOBUFS;
@@ -116,19 +113,28 @@ __xfrm4_bundle_create(struct xfrm_policy *policy, struct xfrm_state **xfrm, int
 
                dst1->next = dst_prev;
                dst_prev = dst1;
-               if (xfrm[i]->props.mode != XFRM_MODE_TRANSPORT) {
-                       remote = xfrm[i]->id.daddr.a4;
-                       local  = xfrm[i]->props.saddr.a4;
-                       tunnel = 1;
-               }
+
                header_len += xfrm[i]->props.header_len;
                trailer_len += xfrm[i]->props.trailer_len;
 
-               if (tunnel) {
-                       fl_tunnel.fl4_src = local;
-                       fl_tunnel.fl4_dst = remote;
+               if (xfrm[i]->props.mode == XFRM_MODE_TUNNEL) {
+                       unsigned short encap_family = xfrm[i]->props.family;
+                       switch(encap_family) {
+                       case AF_INET:
+                               fl_tunnel.fl4_dst = xfrm[i]->id.daddr.a4;
+                               fl_tunnel.fl4_src = xfrm[i]->props.saddr.a4;
+                               break;
+#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
+                       case AF_INET6:
+                               ipv6_addr_copy(&fl_tunnel.fl6_dst, (struct in6_addr*)&xfrm[i]->id.daddr.a6);
+                               ipv6_addr_copy(&fl_tunnel.fl6_src, (struct in6_addr*)&xfrm[i]->props.saddr.a6);
+                               break;
+#endif
+                       default:
+                               BUG_ON(1);
+                       }
                        err = xfrm_dst_lookup((struct xfrm_dst **)&rt,
-                                             &fl_tunnel, AF_INET);
+                                             &fl_tunnel, encap_family);
                        if (err)
                                goto error;
                } else
@@ -145,6 +151,7 @@ __xfrm4_bundle_create(struct xfrm_policy *policy, struct xfrm_state **xfrm, int
        i = 0;
        for (; dst_prev != &rt->u.dst; dst_prev = dst_prev->child) {
                struct xfrm_dst *x = (struct xfrm_dst*)dst_prev;
+               struct xfrm_state_afinfo *afinfo;
                x->u.rt.fl = *fl;
 
                dst_prev->xfrm = xfrm[i++];
@@ -162,8 +169,18 @@ __xfrm4_bundle_create(struct xfrm_policy *policy, struct xfrm_state **xfrm, int
                /* Copy neighbout for reachability confirmation */
                dst_prev->neighbour     = neigh_clone(rt->u.dst.neighbour);
                dst_prev->input         = rt->u.dst.input;
-               dst_prev->output        = xfrm4_output;
-               if (rt->peer)
+               /* XXX: When IPv6 module can be unloaded, we should manage reference
+                * to xfrm6_output in afinfo->output. Miyazawa
+                * */
+               afinfo = xfrm_state_get_afinfo(dst_prev->xfrm->props.family);
+               if (!afinfo) {
+                       dst = *dst_p;
+                       err = -EAFNOSUPPORT;
+                       goto error;
+               }
+               dst_prev->output = afinfo->output;
+               xfrm_state_put_afinfo(afinfo);
+               if (dst_prev->xfrm->props.family == AF_INET && rt->peer)
                        atomic_inc(&rt->peer->refcnt);
                x->u.rt.peer = rt->peer;
                /* Sheit... I remember I did this right. Apparently,
@@ -274,7 +291,7 @@ static void xfrm4_dst_destroy(struct dst_entry *dst)
 
        if (likely(xdst->u.rt.idev))
                in_dev_put(xdst->u.rt.idev);
-       if (likely(xdst->u.rt.peer))
+       if (dst->xfrm->props.family == AF_INET && likely(xdst->u.rt.peer))
                inet_putpeer(xdst->u.rt.peer);
        xfrm_dst_destroy(xdst);
 }
index 3cc3df0c6ece97420f79c2a84efca31e1b8cbcd1..93e2c061cddaf3b71a7c6e3c0bae0a22f1b45d76 100644 (file)
@@ -51,6 +51,7 @@ static struct xfrm_state_afinfo xfrm4_state_afinfo = {
        .family                 = AF_INET,
        .init_flags             = xfrm4_init_flags,
        .init_tempsel           = __xfrm4_init_tempsel,
+       .output                 = xfrm4_output,
 };
 
 void __init xfrm4_state_init(void)
index f110af5b1319f0968a4278283cdaa171761d6e75..1be6762b2d474fd42d399e6accfdae30f9ff8b2e 100644 (file)
@@ -13,7 +13,7 @@
 static int ipip_output(struct xfrm_state *x, struct sk_buff *skb)
 {
        struct iphdr *iph;
-       
+
        iph = skb->nh.iph;
        iph->tot_len = htons(skb->len);
        ip_send_check(iph);
index e3854696988d76ec4bd16b2e4b6e35067de28d02..77e56f2b1af295de8d87f5dbfec9b02508c75826 100644 (file)
@@ -3,7 +3,7 @@
  *     Linux INET6 implementation
  *
  *     Authors:
- *     Pedro Roque             <roque@di.fc.ul.pt>     
+ *     Pedro Roque             <roque@di.fc.ul.pt>
  *     Alexey Kuznetsov        <kuznet@ms2.inr.ac.ru>
  *
  *     $Id: addrconf.c,v 1.69 2001/10/31 21:55:54 davem Exp $
@@ -105,7 +105,7 @@ static void addrconf_sysctl_unregister(struct ipv6_devconf *p);
 
 #ifdef CONFIG_IPV6_PRIVACY
 static int __ipv6_regen_rndid(struct inet6_dev *idev);
-static int __ipv6_try_regen_rndid(struct inet6_dev *idev, struct in6_addr *tmpaddr); 
+static int __ipv6_try_regen_rndid(struct inet6_dev *idev, struct in6_addr *tmpaddr);
 static void ipv6_regen_rndid(unsigned long data);
 
 static int desync_factor = MAX_DESYNC_FACTOR * HZ;
@@ -137,7 +137,7 @@ static void addrconf_rs_timer(unsigned long data);
 static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifa);
 static void ipv6_ifa_notify(int event, struct inet6_ifaddr *ifa);
 
-static void inet6_prefix_notify(int event, struct inet6_dev *idev, 
+static void inet6_prefix_notify(int event, struct inet6_dev *idev,
                                struct prefix_info *pinfo);
 static int ipv6_chk_same_addr(const struct in6_addr *addr, struct net_device *dev);
 
@@ -241,7 +241,7 @@ int __ipv6_addr_type(const struct in6_addr *addr)
         */
        if ((st & htonl(0xE0000000)) != htonl(0x00000000) &&
            (st & htonl(0xE0000000)) != htonl(0xE0000000))
-               return (IPV6_ADDR_UNICAST | 
+               return (IPV6_ADDR_UNICAST |
                        IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_GLOBAL));
 
        if ((st & htonl(0xFF000000)) == htonl(0xFF000000)) {
@@ -252,7 +252,7 @@ int __ipv6_addr_type(const struct in6_addr *addr)
        }
 
        if ((st & htonl(0xFFC00000)) == htonl(0xFE800000))
-               return (IPV6_ADDR_LINKLOCAL | IPV6_ADDR_UNICAST | 
+               return (IPV6_ADDR_LINKLOCAL | IPV6_ADDR_UNICAST |
                        IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_LINKLOCAL));               /* addr-select 3.1 */
        if ((st & htonl(0xFFC00000)) == htonl(0xFEC00000))
                return (IPV6_ADDR_SITELOCAL | IPV6_ADDR_UNICAST |
@@ -272,11 +272,11 @@ int __ipv6_addr_type(const struct in6_addr *addr)
                }
 
                if (addr->s6_addr32[2] == htonl(0x0000ffff))
-                       return (IPV6_ADDR_MAPPED | 
+                       return (IPV6_ADDR_MAPPED |
                                IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_GLOBAL));  /* addr-select 3.3 */
        }
 
-       return (IPV6_ADDR_RESERVED | 
+       return (IPV6_ADDR_RESERVED |
                IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_GLOBAL));  /* addr-select 3.4 */
 }
 
@@ -348,10 +348,10 @@ static struct inet6_dev * ipv6_add_dev(struct net_device *dev)
        if (dev->mtu < IPV6_MIN_MTU)
                return NULL;
 
-       ndev = kzalloc(sizeof(struct inet6_dev), GFP_KERNEL);
+       ndev = kzalloc(sizeof(struct inet6_dev), GFP_KERNEL);
 
-       if (ndev == NULL)
-               return NULL;
+       if (ndev == NULL)
+               return NULL;
 
        rwlock_init(&ndev->lock);
        ndev->dev = dev;
@@ -462,7 +462,7 @@ static void dev_forward_change(struct inet6_dev *idev)
        dev = idev->dev;
        if (dev && (dev->flags & IFF_MULTICAST)) {
                ipv6_addr_all_routers(&addr);
-       
+
                if (idev->cnf.forwarding)
                        ipv6_dev_mc_inc(dev, &addr);
                else
@@ -817,8 +817,8 @@ retry:
        tmp_valid_lft = min_t(__u32,
                              ifp->valid_lft,
                              idev->cnf.temp_valid_lft);
-       tmp_prefered_lft = min_t(__u32, 
-                                ifp->prefered_lft, 
+       tmp_prefered_lft = min_t(__u32,
+                                ifp->prefered_lft,
                                 idev->cnf.temp_prefered_lft - desync_factor / HZ);
        tmp_plen = ifp->prefix_len;
        max_addresses = idev->cnf.max_addresses;
@@ -828,7 +828,7 @@ retry:
 
        write_unlock(&idev->lock);
        ift = !max_addresses ||
-             ipv6_count_addresses(idev) < max_addresses ? 
+             ipv6_count_addresses(idev) < max_addresses ?
                ipv6_add_addr(idev, &addr, tmp_plen,
                              ipv6_addr_type(&addr)&IPV6_ADDR_SCOPE_MASK, IFA_F_TEMPORARY) : NULL;
        if (!ift || IS_ERR(ift)) {
@@ -1160,7 +1160,7 @@ record_it:
 
        if (!ifa_result)
                return -EADDRNOTAVAIL;
-       
+
        ipv6_addr_copy(saddr, &ifa_result->addr);
        in6_ifa_put(ifa_result);
        return 0;
@@ -1475,7 +1475,7 @@ regen:
         *  - value 0
         *  - XXX: already assigned to an address on the device
         */
-       if (idev->rndid[0] == 0xfd && 
+       if (idev->rndid[0] == 0xfd &&
            (idev->rndid[1]&idev->rndid[2]&idev->rndid[3]&idev->rndid[4]&idev->rndid[5]&idev->rndid[6]) == 0xff &&
            (idev->rndid[7]&0x80))
                goto regen;
@@ -1502,9 +1502,9 @@ static void ipv6_regen_rndid(unsigned long data)
 
        if (__ipv6_regen_rndid(idev) < 0)
                goto out;
-       
+
        expires = jiffies +
-               idev->cnf.temp_prefered_lft * HZ - 
+               idev->cnf.temp_prefered_lft * HZ -
                idev->cnf.regen_max_retry * idev->cnf.dad_transmits * idev->nd_parms->retrans_time - desync_factor;
        if (time_before(expires, jiffies)) {
                printk(KERN_WARNING
@@ -1630,12 +1630,12 @@ void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len)
        struct inet6_dev *in6_dev;
 
        pinfo = (struct prefix_info *) opt;
-       
+
        if (len < sizeof(struct prefix_info)) {
                ADBG(("addrconf: prefix option too short\n"));
                return;
        }
-       
+
        /*
         *      Validation checks ([ADDRCONF], page 19)
         */
@@ -1827,7 +1827,7 @@ ok:
                                 * When a new public address is created as described in [ADDRCONF],
                                 * also create a new temporary address.
                                 */
-                               read_unlock_bh(&in6_dev->lock); 
+                               read_unlock_bh(&in6_dev->lock);
                                ipv6_create_tempaddr(ifp, NULL);
                        } else {
                                read_unlock_bh(&in6_dev->lock);
@@ -1913,14 +1913,14 @@ static int inet6_addr_add(int ifindex, struct in6_addr *pfx, int plen,
        int scope;
 
        ASSERT_RTNL();
-       
+
        /* check the lifetime */
        if (!valid_lft || prefered_lft > valid_lft)
                return -EINVAL;
 
        if ((dev = __dev_get_by_index(ifindex)) == NULL)
                return -ENODEV;
-       
+
        if ((idev = addrconf_add_dev(dev)) == NULL)
                return -ENOBUFS;
 
@@ -1960,7 +1960,7 @@ static int inet6_addr_del(int ifindex, struct in6_addr *pfx, int plen)
        struct inet6_ifaddr *ifp;
        struct inet6_dev *idev;
        struct net_device *dev;
-       
+
        if ((dev = __dev_get_by_index(ifindex)) == NULL)
                return -ENODEV;
 
@@ -1973,7 +1973,7 @@ static int inet6_addr_del(int ifindex, struct in6_addr *pfx, int plen)
                    ipv6_addr_equal(pfx, &ifp->addr)) {
                        in6_ifa_hold(ifp);
                        read_unlock_bh(&idev->lock);
-                       
+
                        ipv6_del_addr(ifp);
 
                        /* If the last address is deleted administratively,
@@ -1993,10 +1993,10 @@ int addrconf_add_ifaddr(void __user *arg)
 {
        struct in6_ifreq ireq;
        int err;
-       
+
        if (!capable(CAP_NET_ADMIN))
                return -EPERM;
-       
+
        if (copy_from_user(&ireq, arg, sizeof(struct in6_ifreq)))
                return -EFAULT;
 
@@ -2011,7 +2011,7 @@ int addrconf_del_ifaddr(void __user *arg)
 {
        struct in6_ifreq ireq;
        int err;
-       
+
        if (!capable(CAP_NET_ADMIN))
                return -EPERM;
 
@@ -2056,7 +2056,7 @@ static void sit_add_v4_addrs(struct inet6_dev *idev)
                return;
        }
 
-        for (dev = dev_base; dev != NULL; dev = dev->next) {
+       for (dev = dev_base; dev != NULL; dev = dev->next) {
                struct in_device * in_dev = __in_dev_get_rtnl(dev);
                if (in_dev && (dev->flags & IFF_UP)) {
                        struct in_ifaddr * ifa;
@@ -2091,7 +2091,7 @@ static void sit_add_v4_addrs(struct inet6_dev *idev)
                                }
                        }
                }
-        }
+       }
 }
 #endif
 
@@ -2137,7 +2137,7 @@ static void addrconf_dev_config(struct net_device *dev)
 
        ASSERT_RTNL();
 
-       if ((dev->type != ARPHRD_ETHER) && 
+       if ((dev->type != ARPHRD_ETHER) &&
            (dev->type != ARPHRD_FDDI) &&
            (dev->type != ARPHRD_IEEE802_TR) &&
            (dev->type != ARPHRD_ARCNET) &&
@@ -2164,9 +2164,9 @@ static void addrconf_sit_config(struct net_device *dev)
 
        ASSERT_RTNL();
 
-       /* 
-        * Configure the tunnel with one of our IPv4 
-        * addresses... we should configure all of 
+       /*
+        * Configure the tunnel with one of our IPv4
+        * addresses... we should configure all of
         * our v4 addrs in the tunnel
         */
 
@@ -2233,7 +2233,7 @@ static void addrconf_ip6_tnl_config(struct net_device *dev)
        ip6_tnl_add_linklocal(idev);
 }
 
-static int addrconf_notify(struct notifier_block *this, unsigned long event, 
+static int addrconf_notify(struct notifier_block *this, unsigned long event,
                           void * data)
 {
        struct net_device *dev = (struct net_device *) data;
@@ -2378,7 +2378,7 @@ static int addrconf_ifdown(struct net_device *dev, int how)
                return -ENODEV;
 
        /* Step 1: remove reference to ipv6 device from parent device.
-                  Do not dev_put!
+                  Do not dev_put!
         */
        if (how == 1) {
                idev->dead = 1;
@@ -2461,7 +2461,7 @@ static int addrconf_ifdown(struct net_device *dev, int how)
        /* Step 5: netlink notification of this interface */
        idev->tstamp = jiffies;
        inet6_ifinfo_notify(RTM_DELLINK, idev);
-       
+
        /* Shot the device (if unregistered) */
 
        if (how == 1) {
@@ -2850,8 +2850,8 @@ restart:
                        age = (now - ifp->tstamp) / HZ;
 
 #ifdef CONFIG_IPV6_PRIVACY
-                       regen_advance = ifp->idev->cnf.regen_max_retry * 
-                                       ifp->idev->cnf.dad_transmits * 
+                       regen_advance = ifp->idev->cnf.regen_max_retry *
+                                       ifp->idev->cnf.dad_transmits *
                                        ifp->idev->nd_parms->retrans_time / HZ;
 #endif
 
@@ -3117,7 +3117,7 @@ static int inet6_fill_ifaddr(struct sk_buff *skb, struct inet6_ifaddr *ifa,
 
        nlh = nlmsg_put(skb, pid, seq, event, sizeof(struct ifaddrmsg), flags);
        if (nlh == NULL)
-               return -ENOBUFS;
+               return -EMSGSIZE;
 
        put_ifaddrmsg(nlh, ifa->prefix_len, ifa->flags, rt_scope(ifa->scope),
                      ifa->idev->dev->ifindex);
@@ -3137,8 +3137,10 @@ static int inet6_fill_ifaddr(struct sk_buff *skb, struct inet6_ifaddr *ifa,
        }
 
        if (nla_put(skb, IFA_ADDRESS, 16, &ifa->addr) < 0 ||
-           put_cacheinfo(skb, ifa->cstamp, ifa->tstamp, preferred, valid) < 0)
-               return nlmsg_cancel(skb, nlh);
+           put_cacheinfo(skb, ifa->cstamp, ifa->tstamp, preferred, valid) < 0) {
+               nlmsg_cancel(skb, nlh);
+               return -EMSGSIZE;
+       }
 
        return nlmsg_end(skb, nlh);
 }
@@ -3155,13 +3157,15 @@ static int inet6_fill_ifmcaddr(struct sk_buff *skb, struct ifmcaddr6 *ifmca,
 
        nlh = nlmsg_put(skb, pid, seq, event, sizeof(struct ifaddrmsg), flags);
        if (nlh == NULL)
-               return -ENOBUFS;
+               return -EMSGSIZE;
 
        put_ifaddrmsg(nlh, 128, IFA_F_PERMANENT, scope, ifindex);
        if (nla_put(skb, IFA_MULTICAST, 16, &ifmca->mca_addr) < 0 ||
            put_cacheinfo(skb, ifmca->mca_cstamp, ifmca->mca_tstamp,
-                         INFINITY_LIFE_TIME, INFINITY_LIFE_TIME) < 0)
-               return nlmsg_cancel(skb, nlh);
+                         INFINITY_LIFE_TIME, INFINITY_LIFE_TIME) < 0) {
+               nlmsg_cancel(skb, nlh);
+               return -EMSGSIZE;
+       }
 
        return nlmsg_end(skb, nlh);
 }
@@ -3178,13 +3182,15 @@ static int inet6_fill_ifacaddr(struct sk_buff *skb, struct ifacaddr6 *ifaca,
 
        nlh = nlmsg_put(skb, pid, seq, event, sizeof(struct ifaddrmsg), flags);
        if (nlh == NULL)
-               return -ENOBUFS;
+               return -EMSGSIZE;
 
        put_ifaddrmsg(nlh, 128, IFA_F_PERMANENT, scope, ifindex);
        if (nla_put(skb, IFA_ANYCAST, 16, &ifaca->aca_addr) < 0 ||
            put_cacheinfo(skb, ifaca->aca_cstamp, ifaca->aca_tstamp,
-                         INFINITY_LIFE_TIME, INFINITY_LIFE_TIME) < 0)
-               return nlmsg_cancel(skb, nlh);
+                         INFINITY_LIFE_TIME, INFINITY_LIFE_TIME) < 0) {
+               nlmsg_cancel(skb, nlh);
+               return -EMSGSIZE;
+       }
 
        return nlmsg_end(skb, nlh);
 }
@@ -3211,7 +3217,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
        s_idx = cb->args[0];
        s_ip_idx = ip_idx = cb->args[1];
        read_lock(&dev_base_lock);
-       
+
        for (dev = dev_base, idx = 0; dev; dev = dev->next, idx++) {
                if (idx < s_idx)
                        continue;
@@ -3228,8 +3234,8 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
                             ifa = ifa->if_next, ip_idx++) {
                                if (ip_idx < s_ip_idx)
                                        continue;
-                               if ((err = inet6_fill_ifaddr(skb, ifa, 
-                                   NETLINK_CB(cb->skb).pid, 
+                               if ((err = inet6_fill_ifaddr(skb, ifa,
+                                   NETLINK_CB(cb->skb).pid,
                                    cb->nlh->nlmsg_seq, RTM_NEWADDR,
                                    NLM_F_MULTI)) <= 0)
                                        goto done;
@@ -3237,12 +3243,12 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
                        break;
                case MULTICAST_ADDR:
                        /* multicast address */
-                       for (ifmca = idev->mc_list; ifmca; 
+                       for (ifmca = idev->mc_list; ifmca;
                             ifmca = ifmca->next, ip_idx++) {
                                if (ip_idx < s_ip_idx)
                                        continue;
-                               if ((err = inet6_fill_ifmcaddr(skb, ifmca, 
-                                   NETLINK_CB(cb->skb).pid, 
+                               if ((err = inet6_fill_ifmcaddr(skb, ifmca,
+                                   NETLINK_CB(cb->skb).pid,
                                    cb->nlh->nlmsg_seq, RTM_GETMULTICAST,
                                    NLM_F_MULTI)) <= 0)
                                        goto done;
@@ -3254,10 +3260,10 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
                             ifaca = ifaca->aca_next, ip_idx++) {
                                if (ip_idx < s_ip_idx)
                                        continue;
-                               if ((err = inet6_fill_ifacaddr(skb, ifaca, 
-                                   NETLINK_CB(cb->skb).pid, 
+                               if ((err = inet6_fill_ifacaddr(skb, ifaca,
+                                   NETLINK_CB(cb->skb).pid,
                                    cb->nlh->nlmsg_seq, RTM_GETANYCAST,
-                                   NLM_F_MULTI)) <= 0) 
+                                   NLM_F_MULTI)) <= 0)
                                        goto done;
                        }
                        break;
@@ -3334,9 +3340,12 @@ static int inet6_rtm_getaddr(struct sk_buff *in_skb, struct nlmsghdr* nlh,
 
        err = inet6_fill_ifaddr(skb, ifa, NETLINK_CB(in_skb).pid,
                                nlh->nlmsg_seq, RTM_NEWADDR, 0);
-       /* failure implies BUG in inet6_ifaddr_msgsize() */
-       BUG_ON(err < 0);
-
+       if (err < 0) {
+               /* -EMSGSIZE implies BUG in inet6_ifaddr_msgsize() */
+               WARN_ON(err == -EMSGSIZE);
+               kfree_skb(skb);
+               goto errout_ifa;
+       }
        err = rtnl_unicast(skb, NETLINK_CB(in_skb).pid);
 errout_ifa:
        in6_ifa_put(ifa);
@@ -3354,9 +3363,12 @@ static void inet6_ifa_notify(int event, struct inet6_ifaddr *ifa)
                goto errout;
 
        err = inet6_fill_ifaddr(skb, ifa, 0, 0, event, 0);
-       /* failure implies BUG in inet6_ifaddr_msgsize() */
-       BUG_ON(err < 0);
-
+       if (err < 0) {
+               /* -EMSGSIZE implies BUG in inet6_ifaddr_msgsize() */
+               WARN_ON(err == -EMSGSIZE);
+               kfree_skb(skb);
+               goto errout;
+       }
        err = rtnl_notify(skb, 0, RTNLGRP_IPV6_IFADDR, NULL, GFP_ATOMIC);
 errout:
        if (err < 0)
@@ -3414,7 +3426,7 @@ static inline size_t inet6_if_nlmsg_size(void)
                 );
 }
 
-static int inet6_fill_ifinfo(struct sk_buff *skb, struct inet6_dev *idev, 
+static int inet6_fill_ifinfo(struct sk_buff *skb, struct inet6_dev *idev,
                             u32 pid, u32 seq, int event, unsigned int flags)
 {
        struct net_device *dev = idev->dev;
@@ -3426,7 +3438,7 @@ static int inet6_fill_ifinfo(struct sk_buff *skb, struct inet6_dev *idev,
 
        nlh = nlmsg_put(skb, pid, seq, event, sizeof(*hdr), flags);
        if (nlh == NULL)
-               return -ENOBUFS;
+               return -EMSGSIZE;
 
        hdr = nlmsg_data(nlh);
        hdr->ifi_family = AF_INET6;
@@ -3469,7 +3481,8 @@ static int inet6_fill_ifinfo(struct sk_buff *skb, struct inet6_dev *idev,
        return nlmsg_end(skb, nlh);
 
 nla_put_failure:
-       return nlmsg_cancel(skb, nlh);
+       nlmsg_cancel(skb, nlh);
+       return -EMSGSIZE;
 }
 
 static int inet6_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
@@ -3485,7 +3498,7 @@ static int inet6_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
                        continue;
                if ((idev = in6_dev_get(dev)) == NULL)
                        continue;
-               err = inet6_fill_ifinfo(skb, idev, NETLINK_CB(cb->skb).pid, 
+               err = inet6_fill_ifinfo(skb, idev, NETLINK_CB(cb->skb).pid,
                                cb->nlh->nlmsg_seq, RTM_NEWLINK, NLM_F_MULTI);
                in6_dev_put(idev);
                if (err <= 0)
@@ -3501,15 +3514,18 @@ void inet6_ifinfo_notify(int event, struct inet6_dev *idev)
 {
        struct sk_buff *skb;
        int err = -ENOBUFS;
-       
+
        skb = nlmsg_new(inet6_if_nlmsg_size(), GFP_ATOMIC);
        if (skb == NULL)
                goto errout;
 
        err = inet6_fill_ifinfo(skb, idev, 0, 0, event, 0);
-       /* failure implies BUG in inet6_if_nlmsg_size() */
-       BUG_ON(err < 0);
-
+       if (err < 0) {
+               /* -EMSGSIZE implies BUG in inet6_if_nlmsg_size() */
+               WARN_ON(err == -EMSGSIZE);
+               kfree_skb(skb);
+               goto errout;
+       }
        err = rtnl_notify(skb, 0, RTNLGRP_IPV6_IFADDR, NULL, GFP_ATOMIC);
 errout:
        if (err < 0)
@@ -3533,7 +3549,7 @@ static int inet6_fill_prefix(struct sk_buff *skb, struct inet6_dev *idev,
 
        nlh = nlmsg_put(skb, pid, seq, event, sizeof(*pmsg), flags);
        if (nlh == NULL)
-               return -ENOBUFS;
+               return -EMSGSIZE;
 
        pmsg = nlmsg_data(nlh);
        pmsg->prefix_family = AF_INET6;
@@ -3558,10 +3574,11 @@ static int inet6_fill_prefix(struct sk_buff *skb, struct inet6_dev *idev,
        return nlmsg_end(skb, nlh);
 
 nla_put_failure:
-       return nlmsg_cancel(skb, nlh);
+       nlmsg_cancel(skb, nlh);
+       return -EMSGSIZE;
 }
 
-static void inet6_prefix_notify(int event, struct inet6_dev *idev, 
+static void inet6_prefix_notify(int event, struct inet6_dev *idev,
                         struct prefix_info *pinfo)
 {
        struct sk_buff *skb;
@@ -3572,9 +3589,12 @@ static void inet6_prefix_notify(int event, struct inet6_dev *idev,
                goto errout;
 
        err = inet6_fill_prefix(skb, idev, pinfo, 0, 0, event, 0);
-       /* failure implies BUG in inet6_prefix_nlmsg_size() */
-       BUG_ON(err < 0);
-
+       if (err < 0) {
+               /* -EMSGSIZE implies BUG in inet6_prefix_nlmsg_size() */
+               WARN_ON(err == -EMSGSIZE);
+               kfree_skb(skb);
+               goto errout;
+       }
        err = rtnl_notify(skb, 0, RTNLGRP_IPV6_PREFIX, NULL, GFP_ATOMIC);
 errout:
        if (err < 0)
@@ -3655,10 +3675,10 @@ int addrconf_sysctl_forward(ctl_table *ctl, int write, struct file * filp,
                        rt6_purge_dflt_routers();
        }
 
-        return ret;
+       return ret;
 }
 
-static int addrconf_sysctl_forward_strategy(ctl_table *table, 
+static int addrconf_sysctl_forward_strategy(ctl_table *table,
                                            int __user *name, int nlen,
                                            void __user *oldval,
                                            size_t __user *oldlenp,
@@ -3723,19 +3743,19 @@ static struct addrconf_sysctl_table
 } addrconf_sysctl __read_mostly = {
        .sysctl_header = NULL,
        .addrconf_vars = {
-               {
+               {
                        .ctl_name       =       NET_IPV6_FORWARDING,
                        .procname       =       "forwarding",
-                       .data           =       &ipv6_devconf.forwarding,
+                       .data           =       &ipv6_devconf.forwarding,
                        .maxlen         =       sizeof(int),
                        .mode           =       0644,
-                       .proc_handler   =       &addrconf_sysctl_forward,
+                       .proc_handler   =       &addrconf_sysctl_forward,
                        .strategy       =       &addrconf_sysctl_forward_strategy,
                },
                {
                        .ctl_name       =       NET_IPV6_HOP_LIMIT,
                        .procname       =       "hop_limit",
-                       .data           =       &ipv6_devconf.hop_limit,
+                       .data           =       &ipv6_devconf.hop_limit,
                        .maxlen         =       sizeof(int),
                        .mode           =       0644,
                        .proc_handler   =       proc_dointvec,
@@ -3744,116 +3764,116 @@ static struct addrconf_sysctl_table
                        .ctl_name       =       NET_IPV6_MTU,
                        .procname       =       "mtu",
                        .data           =       &ipv6_devconf.mtu6,
-                       .maxlen         =       sizeof(int),
+                       .maxlen         =       sizeof(int),
                        .mode           =       0644,
-                       .proc_handler   =       &proc_dointvec,
+                       .proc_handler   =       &proc_dointvec,
                },
                {
                        .ctl_name       =       NET_IPV6_ACCEPT_RA,
                        .procname       =       "accept_ra",
-                       .data           =       &ipv6_devconf.accept_ra,
+                       .data           =       &ipv6_devconf.accept_ra,
                        .maxlen         =       sizeof(int),
                        .mode           =       0644,
-                       .proc_handler   =       &proc_dointvec,
+                       .proc_handler   =       &proc_dointvec,
                },
                {
                        .ctl_name       =       NET_IPV6_ACCEPT_REDIRECTS,
                        .procname       =       "accept_redirects",
-                       .data           =       &ipv6_devconf.accept_redirects,
+                       .data           =       &ipv6_devconf.accept_redirects,
                        .maxlen         =       sizeof(int),
                        .mode           =       0644,
-                       .proc_handler   =       &proc_dointvec,
+                       .proc_handler   =       &proc_dointvec,
                },
                {
                        .ctl_name       =       NET_IPV6_AUTOCONF,
                        .procname       =       "autoconf",
-                       .data           =       &ipv6_devconf.autoconf,
+                       .data           =       &ipv6_devconf.autoconf,
                        .maxlen         =       sizeof(int),
                        .mode           =       0644,
-                       .proc_handler   =       &proc_dointvec,
+                       .proc_handler   =       &proc_dointvec,
                },
                {
                        .ctl_name       =       NET_IPV6_DAD_TRANSMITS,
                        .procname       =       "dad_transmits",
-                       .data           =       &ipv6_devconf.dad_transmits,
+                       .data           =       &ipv6_devconf.dad_transmits,
                        .maxlen         =       sizeof(int),
                        .mode           =       0644,
-                       .proc_handler   =       &proc_dointvec,
+                       .proc_handler   =       &proc_dointvec,
                },
                {
                        .ctl_name       =       NET_IPV6_RTR_SOLICITS,
                        .procname       =       "router_solicitations",
-                       .data           =       &ipv6_devconf.rtr_solicits,
+                       .data           =       &ipv6_devconf.rtr_solicits,
                        .maxlen         =       sizeof(int),
                        .mode           =       0644,
-                       .proc_handler   =       &proc_dointvec,
+                       .proc_handler   =       &proc_dointvec,
                },
                {
                        .ctl_name       =       NET_IPV6_RTR_SOLICIT_INTERVAL,
                        .procname       =       "router_solicitation_interval",
-                       .data           =       &ipv6_devconf.rtr_solicit_interval,
+                       .data           =       &ipv6_devconf.rtr_solicit_interval,
                        .maxlen         =       sizeof(int),
                        .mode           =       0644,
-                       .proc_handler   =       &proc_dointvec_jiffies,
+                       .proc_handler   =       &proc_dointvec_jiffies,
                        .strategy       =       &sysctl_jiffies,
                },
                {
                        .ctl_name       =       NET_IPV6_RTR_SOLICIT_DELAY,
                        .procname       =       "router_solicitation_delay",
-                       .data           =       &ipv6_devconf.rtr_solicit_delay,
+                       .data           =       &ipv6_devconf.rtr_solicit_delay,
                        .maxlen         =       sizeof(int),
                        .mode           =       0644,
-                       .proc_handler   =       &proc_dointvec_jiffies,
+                       .proc_handler   =       &proc_dointvec_jiffies,
                        .strategy       =       &sysctl_jiffies,
                },
                {
                        .ctl_name       =       NET_IPV6_FORCE_MLD_VERSION,
                        .procname       =       "force_mld_version",
-                       .data           =       &ipv6_devconf.force_mld_version,
+                       .data           =       &ipv6_devconf.force_mld_version,
                        .maxlen         =       sizeof(int),
                        .mode           =       0644,
-                       .proc_handler   =       &proc_dointvec,
+                       .proc_handler   =       &proc_dointvec,
                },
 #ifdef CONFIG_IPV6_PRIVACY
                {
                        .ctl_name       =       NET_IPV6_USE_TEMPADDR,
                        .procname       =       "use_tempaddr",
-                       .data           =       &ipv6_devconf.use_tempaddr,
+                       .data           =       &ipv6_devconf.use_tempaddr,
                        .maxlen         =       sizeof(int),
                        .mode           =       0644,
-                       .proc_handler   =       &proc_dointvec,
+                       .proc_handler   =       &proc_dointvec,
                },
                {
                        .ctl_name       =       NET_IPV6_TEMP_VALID_LFT,
                        .procname       =       "temp_valid_lft",
-                       .data           =       &ipv6_devconf.temp_valid_lft,
+                       .data           =       &ipv6_devconf.temp_valid_lft,
                        .maxlen         =       sizeof(int),
                        .mode           =       0644,
-                       .proc_handler   =       &proc_dointvec,
+                       .proc_handler   =       &proc_dointvec,
                },
                {
                        .ctl_name       =       NET_IPV6_TEMP_PREFERED_LFT,
                        .procname       =       "temp_prefered_lft",
-                       .data           =       &ipv6_devconf.temp_prefered_lft,
+                       .data           =       &ipv6_devconf.temp_prefered_lft,
                        .maxlen         =       sizeof(int),
                        .mode           =       0644,
-                       .proc_handler   =       &proc_dointvec,
+                       .proc_handler   =       &proc_dointvec,
                },
                {
                        .ctl_name       =       NET_IPV6_REGEN_MAX_RETRY,
                        .procname       =       "regen_max_retry",
-                       .data           =       &ipv6_devconf.regen_max_retry,
+                       .data           =       &ipv6_devconf.regen_max_retry,
                        .maxlen         =       sizeof(int),
                        .mode           =       0644,
-                       .proc_handler   =       &proc_dointvec,
+                       .proc_handler   =       &proc_dointvec,
                },
                {
                        .ctl_name       =       NET_IPV6_MAX_DESYNC_FACTOR,
                        .procname       =       "max_desync_factor",
-                       .data           =       &ipv6_devconf.max_desync_factor,
+                       .data           =       &ipv6_devconf.max_desync_factor,
                        .maxlen         =       sizeof(int),
                        .mode           =       0644,
-                       .proc_handler   =       &proc_dointvec,
+                       .proc_handler   =       &proc_dointvec,
                },
 #endif
                {
@@ -3867,18 +3887,18 @@ static struct addrconf_sysctl_table
                {
                        .ctl_name       =       NET_IPV6_ACCEPT_RA_DEFRTR,
                        .procname       =       "accept_ra_defrtr",
-                       .data           =       &ipv6_devconf.accept_ra_defrtr,
+                       .data           =       &ipv6_devconf.accept_ra_defrtr,
                        .maxlen         =       sizeof(int),
                        .mode           =       0644,
-                       .proc_handler   =       &proc_dointvec,
+                       .proc_handler   =       &proc_dointvec,
                },
                {
                        .ctl_name       =       NET_IPV6_ACCEPT_RA_PINFO,
                        .procname       =       "accept_ra_pinfo",
-                       .data           =       &ipv6_devconf.accept_ra_pinfo,
+                       .data           =       &ipv6_devconf.accept_ra_pinfo,
                        .maxlen         =       sizeof(int),
                        .mode           =       0644,
-                       .proc_handler   =       &proc_dointvec,
+                       .proc_handler   =       &proc_dointvec,
                },
 #ifdef CONFIG_IPV6_ROUTER_PREF
                {
@@ -3983,18 +4003,18 @@ static void addrconf_sysctl_register(struct inet6_dev *idev, struct ipv6_devconf
                t->addrconf_vars[i].extra1 = idev; /* embedded; no ref */
        }
        if (dev) {
-               dev_name = dev->name; 
+               dev_name = dev->name;
                t->addrconf_dev[0].ctl_name = dev->ifindex;
        } else {
                dev_name = "default";
                t->addrconf_dev[0].ctl_name = NET_PROTO_CONF_DEFAULT;
        }
 
-       /* 
-        * Make a copy of dev_name, because '.procname' is regarded as const 
+       /*
+        * Make a copy of dev_name, because '.procname' is regarded as const
         * by sysctl and we wouldn't want anyone to change it under our feet
         * (see SIOCSIFNAME).
-        */     
+        */
        dev_name = kstrdup(dev_name, GFP_KERNEL);
        if (!dev_name)
            goto free;
@@ -4046,12 +4066,12 @@ static void addrconf_sysctl_unregister(struct ipv6_devconf *p)
 
 int register_inet6addr_notifier(struct notifier_block *nb)
 {
-        return atomic_notifier_chain_register(&inet6addr_chain, nb);
+       return atomic_notifier_chain_register(&inet6addr_chain, nb);
 }
 
 int unregister_inet6addr_notifier(struct notifier_block *nb)
 {
-        return atomic_notifier_chain_unregister(&inet6addr_chain,nb);
+       return atomic_notifier_chain_unregister(&inet6addr_chain,nb);
 }
 
 /*
@@ -4104,9 +4124,9 @@ int __init addrconf_init(void)
 
 void __exit addrconf_cleanup(void)
 {
-       struct net_device *dev;
-       struct inet6_dev *idev;
-       struct inet6_ifaddr *ifa;
+       struct net_device *dev;
+       struct inet6_dev *idev;
+       struct inet6_ifaddr *ifa;
        int i;
 
        unregister_netdevice_notifier(&ipv6_dev_notf);
index 0e0e4262f4dc46a570c72c4a829699ef6fa6faf0..a006d242be765390f8e239b1297a528283be3d39 100644 (file)
@@ -1,9 +1,9 @@
 /*
  *     PF_INET6 socket protocol family
- *     Linux INET6 implementation 
+ *     Linux INET6 implementation
  *
  *     Authors:
- *     Pedro Roque             <roque@di.fc.ul.pt>     
+ *     Pedro Roque             <roque@di.fc.ul.pt>
  *
  *     Adapted from linux/net/ipv4/af_inet.c
  *
@@ -191,7 +191,7 @@ lookup_protocol:
        np->mc_loop     = 1;
        np->pmtudisc    = IPV6_PMTUDISC_WANT;
        np->ipv6only    = sysctl_ipv6_bindv6only;
-       
+
        /* Init the ipv4 part of the socket since we can have sockets
         * using v6 API for ipv4.
         */
@@ -206,7 +206,7 @@ lookup_protocol:
                inet->pmtudisc = IP_PMTUDISC_DONT;
        else
                inet->pmtudisc = IP_PMTUDISC_WANT;
-       /* 
+       /*
         * Increment only the relevant sk_prot->socks debug field, this changes
         * the previous behaviour of incrementing both the equivalent to
         * answer->prot->socks (inet6_sock_nr) and inet_sock_nr.
@@ -293,7 +293,7 @@ int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
                                         */
                                        sk->sk_bound_dev_if = addr->sin6_scope_id;
                                }
-                               
+
                                /* Binding to link-local address requires an interface */
                                if (!sk->sk_bound_dev_if) {
                                        err = -EINVAL;
@@ -327,7 +327,7 @@ int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
        inet->saddr = v4addr;
 
        ipv6_addr_copy(&np->rcv_saddr, &addr->sin6_addr);
-               
+
        if (!(addr_type & IPV6_ADDR_MULTICAST))
                ipv6_addr_copy(&np->saddr, &addr->sin6_addr);
 
@@ -393,7 +393,7 @@ EXPORT_SYMBOL_GPL(inet6_destroy_sock);
 /*
  *     This does both peername and sockname.
  */
+
 int inet6_getname(struct socket *sock, struct sockaddr *uaddr,
                 int *uaddr_len, int peer)
 {
@@ -401,7 +401,7 @@ int inet6_getname(struct socket *sock, struct sockaddr *uaddr,
        struct sock *sk = sock->sk;
        struct inet_sock *inet = inet_sk(sk);
        struct ipv6_pinfo *np = inet6_sk(sk);
-  
+
        sin->sin6_family = AF_INET6;
        sin->sin6_flowinfo = 0;
        sin->sin6_scope_id = 0;
@@ -433,14 +433,14 @@ int inet6_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
 {
        struct sock *sk = sock->sk;
 
-       switch(cmd) 
+       switch(cmd)
        {
        case SIOCGSTAMP:
                return sock_get_timestamp(sk, (struct timeval __user *)arg);
 
        case SIOCADDRT:
        case SIOCDELRT:
-         
+
                return(ipv6_route_ioctl(cmd,(void __user *)arg));
 
        case SIOCSIFADDR:
@@ -584,7 +584,7 @@ inet6_register_protosw(struct inet_protosw *p)
        /* Add the new entry after the last permanent entry if any, so that
         * the new entry does not override a permanent entry when matched with
         * a wild-card protocol. But it is allowed to override any existing
-        * non-permanent entry.  This means that when we remove this entry, the 
+        * non-permanent entry.  This means that when we remove this entry, the
         * system automatically returns to the old behavior.
         */
        list_add_rcu(&p->list, last_perm);
@@ -749,7 +749,7 @@ err_icmp_mib:
        snmp6_mib_free((void **)ipv6_statistics);
 err_ip_mib:
        return -ENOMEM;
-       
+
 }
 
 static void cleanup_ipv6_mibs(void)
@@ -763,7 +763,7 @@ static void cleanup_ipv6_mibs(void)
 static int __init inet6_init(void)
 {
        struct sk_buff *dummy_skb;
-        struct list_head *r;
+       struct list_head *r;
        int err;
 
        BUILD_BUG_ON(sizeof(struct inet6_skb_parm) > sizeof(dummy_skb->cb));
@@ -814,7 +814,7 @@ static int __init inet6_init(void)
        err = init_ipv6_mibs();
        if (err)
                goto out_unregister_sock;
-       
+
        /*
         *      ipngwg API draft makes clear that the correct semantics
         *      for TCP and UDP is to consider one TCP and UDP instance
@@ -933,11 +933,11 @@ static void __exit inet6_exit(void)
 #ifdef CONFIG_PROC_FS
        if6_proc_exit();
        ac6_proc_exit();
-       ipv6_misc_proc_exit();
-       udp6_proc_exit();
-       udplite6_proc_exit();
-       tcp6_proc_exit();
-       raw6_proc_exit();
+       ipv6_misc_proc_exit();
+       udp6_proc_exit();
+       udplite6_proc_exit();
+       tcp6_proc_exit();
+       raw6_proc_exit();
 #endif
 #ifdef CONFIG_IPV6_MIP6
        mip6_fini();
@@ -952,7 +952,7 @@ static void __exit inet6_exit(void)
        ndisc_cleanup();
        icmpv6_cleanup();
 #ifdef CONFIG_SYSCTL
-       ipv6_sysctl_unregister();       
+       ipv6_sysctl_unregister();
 #endif
        cleanup_ipv6_mibs();
        proto_unregister(&rawv6_prot);
index 12c5a4dec09e32dd37dc4181c6e5bb8d6c4d286b..dc68b7269c3c90de00a54aacc072ad7faaca567e 100644 (file)
@@ -1,26 +1,26 @@
 /*
  * Copyright (C)2002 USAGI/WIDE Project
- * 
+ *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  * Authors
  *
- *     Mitsuru KANDA @USAGI       : IPv6 Support 
+ *     Mitsuru KANDA @USAGI       : IPv6 Support
  *     Kazunori MIYAZAWA @USAGI   :
  *     Kunihiro Ishiguro <kunihiro@ipinfusion.com>
- *     
+ *
  *     This file is derived from net/ipv4/ah.c.
  */
 
@@ -54,7 +54,7 @@ static int zero_out_mutable_opts(struct ipv6_opt_hdr *opthdr)
                        optlen = 1;
                        break;
                default:
-                       if (len < 2) 
+                       if (len < 2)
                                goto bad;
                        optlen = opt[off+1]+2;
                        if (len < optlen)
@@ -152,7 +152,7 @@ static void ipv6_rearrange_rthdr(struct ipv6hdr *iph, struct ipv6_rt_hdr *rthdr)
        segments_left = rthdr->segments_left;
        if (segments_left == 0)
                return;
-       rthdr->segments_left = 0; 
+       rthdr->segments_left = 0;
 
        /* The value of rthdr->hdrlen has been verified either by the system
         * call if it is locally generated, or by ipv6_rthdr_rcv() for incoming
@@ -278,7 +278,7 @@ static int ah6_output(struct xfrm_state *x, struct sk_buff *skb)
        top_iph->hop_limit   = 0;
 
        ahp = x->data;
-       ah->hdrlen  = (XFRM_ALIGN8(sizeof(struct ipv6_auth_hdr) + 
+       ah->hdrlen  = (XFRM_ALIGN8(sizeof(struct ipv6_auth_hdr) +
                                   ahp->icv_trunc_len) >> 2) - 2;
 
        ah->reserved = 0;
@@ -319,7 +319,7 @@ static int ah6_input(struct xfrm_state *x, struct sk_buff *skb)
         * Moving the pointer of skb->nh.raw by using skb_pull as long as AH
         * header length. Then copy back the copy as long as hdr_len
         * If destination header following AH exists, copy it into after [Ext2].
-        * 
+        *
         * |<>|[IPv6][Ext1][Ext2][Dest][Payload]
         * There is offset of AH before IPv6 header after the process.
         */
@@ -347,9 +347,9 @@ static int ah6_input(struct xfrm_state *x, struct sk_buff *skb)
        nexthdr = ah->nexthdr;
        ah_hlen = (ah->hdrlen + 2) << 2;
 
-        if (ah_hlen != XFRM_ALIGN8(sizeof(struct ipv6_auth_hdr) + ahp->icv_full_len) &&
-            ah_hlen != XFRM_ALIGN8(sizeof(struct ipv6_auth_hdr) + ahp->icv_trunc_len))
-                goto out;
+       if (ah_hlen != XFRM_ALIGN8(sizeof(struct ipv6_auth_hdr) + ahp->icv_full_len) &&
+           ah_hlen != XFRM_ALIGN8(sizeof(struct ipv6_auth_hdr) + ahp->icv_trunc_len))
+               goto out;
 
        if (!pskb_may_pull(skb, ah_hlen))
                goto out;
@@ -365,7 +365,7 @@ static int ah6_input(struct xfrm_state *x, struct sk_buff *skb)
        skb->nh.ipv6h->flow_lbl[2] = 0;
        skb->nh.ipv6h->hop_limit   = 0;
 
-        {
+       {
                u8 auth_data[MAX_AH_AUTH_LEN];
 
                memcpy(auth_data, ah->auth_data, ahp->icv_trunc_len);
@@ -395,8 +395,8 @@ out:
        return err;
 }
 
-static void ah6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, 
-                    int type, int code, int offset, __be32 info)
+static void ah6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
+                   int type, int code, int offset, __be32 info)
 {
        struct ipv6hdr *iph = (struct ipv6hdr*)skb->data;
        struct ip_auth_hdr *ah = (struct ip_auth_hdr*)(skb->data+offset);
@@ -445,7 +445,7 @@ static int ah6_init_state(struct xfrm_state *x)
        ahp->tfm = tfm;
        if (crypto_hash_setkey(tfm, ahp->key, ahp->key_len))
                goto error;
-       
+
        /*
         * Lookup the algorithm description maintained by xfrm_algo,
         * verify crypto transform properties, and store information
@@ -462,16 +462,16 @@ static int ah6_init_state(struct xfrm_state *x)
                       aalg_desc->uinfo.auth.icv_fullbits/8);
                goto error;
        }
-       
+
        ahp->icv_full_len = aalg_desc->uinfo.auth.icv_fullbits/8;
        ahp->icv_trunc_len = aalg_desc->uinfo.auth.icv_truncbits/8;
-       
+
        BUG_ON(ahp->icv_trunc_len > MAX_AH_AUTH_LEN);
-       
+
        ahp->work_icv = kmalloc(ahp->icv_full_len, GFP_KERNEL);
        if (!ahp->work_icv)
                goto error;
-       
+
        x->props.header_len = XFRM_ALIGN8(sizeof(struct ipv6_auth_hdr) + ahp->icv_trunc_len);
        if (x->props.mode == XFRM_MODE_TUNNEL)
                x->props.header_len += sizeof(struct ipv6hdr);
index a9604764e015adc03c77cdcea9f50d63c947235b..e2dc1c41bbf5e84b1c93abfbc8a75d470697e805 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *     Anycast support for IPv6
- *     Linux INET6 implementation 
+ *     Linux INET6 implementation
  *
  *     Authors:
  *     David L Stevens (dlstevens@us.ibm.com)
@@ -397,7 +397,7 @@ static int ipv6_dev_ac_dec(struct net_device *dev, struct in6_addr *addr)
        in6_dev_put(idev);
        return ret;
 }
-       
+
 /*
  *     check if the interface has this anycast address
  */
index 5c94fea90e97467f683b5ee64d4caf7c9ca214a9..5f54dec3e2051c5fb8ecd8553d9e8d606784c637 100644 (file)
@@ -1,9 +1,9 @@
 /*
  *     common UDP/RAW code
- *     Linux INET6 implementation 
+ *     Linux INET6 implementation
  *
  *     Authors:
- *     Pedro Roque             <roque@di.fc.ul.pt>     
+ *     Pedro Roque             <roque@di.fc.ul.pt>
  *
  *     $Id: datagram.c,v 1.24 2002/02/01 22:01:04 davem Exp $
  *
@@ -55,10 +55,10 @@ int ip6_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
        }
 
        if (addr_len < SIN6_LEN_RFC2133)
-               return -EINVAL;
+               return -EINVAL;
 
-       if (usin->sin6_family != AF_INET6) 
-               return -EAFNOSUPPORT;
+       if (usin->sin6_family != AF_INET6)
+               return -EAFNOSUPPORT;
 
        memset(&fl, 0, sizeof(fl));
        if (np->sndflow) {
@@ -93,14 +93,14 @@ int ip6_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
                sin.sin_addr.s_addr = daddr->s6_addr32[3];
                sin.sin_port = usin->sin6_port;
 
-               err = ip4_datagram_connect(sk, 
-                                          (struct sockaddr*) &sin, 
+               err = ip4_datagram_connect(sk,
+                                          (struct sockaddr*) &sin,
                                           sizeof(sin));
 
 ipv4_connected:
                if (err)
                        goto out;
-               
+
                ipv6_addr_set(&np->daddr, 0, 0, htonl(0x0000ffff), inet->daddr);
 
                if (ipv6_addr_any(&np->saddr)) {
@@ -178,7 +178,7 @@ ipv4_connected:
        if (final_p)
                ipv6_addr_copy(&fl.fl6_dst, final_p);
 
-       if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0)
+       if ((err = xfrm_lookup(&dst, &fl, sk, 1)) < 0)
                goto out;
 
        /* source address lookup done in ip6_dst_lookup */
@@ -206,7 +206,7 @@ out:
        return err;
 }
 
-void ipv6_icmp_error(struct sock *sk, struct sk_buff *skb, int err, 
+void ipv6_icmp_error(struct sock *sk, struct sk_buff *skb, int err,
                     __be16 port, u32 info, u8 *payload)
 {
        struct ipv6_pinfo *np  = inet6_sk(sk);
@@ -223,7 +223,7 @@ void ipv6_icmp_error(struct sock *sk, struct sk_buff *skb, int err,
        serr = SKB_EXT_ERR(skb);
        serr->ee.ee_errno = err;
        serr->ee.ee_origin = SO_EE_ORIGIN_ICMP6;
-       serr->ee.ee_type = icmph->icmp6_type; 
+       serr->ee.ee_type = icmph->icmp6_type;
        serr->ee.ee_code = icmph->icmp6_code;
        serr->ee.ee_pad = 0;
        serr->ee.ee_info = info;
@@ -259,7 +259,7 @@ void ipv6_local_error(struct sock *sk, int err, struct flowi *fl, u32 info)
        serr = SKB_EXT_ERR(skb);
        serr->ee.ee_errno = err;
        serr->ee.ee_origin = SO_EE_ORIGIN_LOCAL;
-       serr->ee.ee_type = 0; 
+       serr->ee.ee_type = 0;
        serr->ee.ee_code = 0;
        serr->ee.ee_pad = 0;
        serr->ee.ee_info = info;
@@ -274,7 +274,7 @@ void ipv6_local_error(struct sock *sk, int err, struct flowi *fl, u32 info)
                kfree_skb(skb);
 }
 
-/* 
+/*
  *     Handle MSG_ERRQUEUE
  */
 int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len)
@@ -312,7 +312,7 @@ int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len)
        if (sin) {
                sin->sin6_family = AF_INET6;
                sin->sin6_flowinfo = 0;
-               sin->sin6_port = serr->port; 
+               sin->sin6_port = serr->port;
                sin->sin6_scope_id = 0;
                if (serr->ee.ee_origin == SO_EE_ORIGIN_ICMP6) {
                        ipv6_addr_copy(&sin->sin6_addr,
@@ -370,7 +370,7 @@ int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len)
                spin_unlock_bh(&sk->sk_error_queue.lock);
        }
 
-out_free_skb:  
+out_free_skb:
        kfree_skb(skb);
 out:
        return err;
@@ -419,7 +419,7 @@ int datagram_recv_ctl(struct sock *sk, struct msghdr *msg, struct sk_buff *skb)
                 * report extension headers (except for HbH)
                 * in order.
                 *
-                * Also note that IPV6_RECVRTHDRDSTOPTS is NOT 
+                * Also note that IPV6_RECVRTHDRDSTOPTS is NOT
                 * (and WILL NOT be) defined because
                 * IPV6_RECVDSTOPTS is more generic. --yoshfuji
                 */
@@ -512,15 +512,15 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl,
                        continue;
 
                switch (cmsg->cmsg_type) {
-               case IPV6_PKTINFO:
-               case IPV6_2292PKTINFO:
-                       if (cmsg->cmsg_len < CMSG_LEN(sizeof(struct in6_pktinfo))) {
+               case IPV6_PKTINFO:
+               case IPV6_2292PKTINFO:
+                       if (cmsg->cmsg_len < CMSG_LEN(sizeof(struct in6_pktinfo))) {
                                err = -EINVAL;
                                goto exit_f;
                        }
 
                        src_info = (struct in6_pktinfo *)CMSG_DATA(cmsg);
-                       
+
                        if (src_info->ipi6_ifindex) {
                                if (fl->oif && src_info->ipi6_ifindex != fl->oif)
                                        return -EINVAL;
@@ -531,7 +531,7 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl,
 
                        if (addr_type == IPV6_ADDR_ANY)
                                break;
-                       
+
                        if (addr_type & IPV6_ADDR_LINKLOCAL) {
                                if (!src_info->ipi6_ifindex)
                                        return -EINVAL;
@@ -554,7 +554,7 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl,
                        break;
 
                case IPV6_FLOWINFO:
-                        if (cmsg->cmsg_len < CMSG_LEN(4)) {
+                       if (cmsg->cmsg_len < CMSG_LEN(4)) {
                                err = -EINVAL;
                                goto exit_f;
                        }
@@ -570,7 +570,7 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl,
 
                case IPV6_2292HOPOPTS:
                case IPV6_HOPOPTS:
-                        if (opt->hopopt || cmsg->cmsg_len < CMSG_LEN(sizeof(struct ipv6_opt_hdr))) {
+                       if (opt->hopopt || cmsg->cmsg_len < CMSG_LEN(sizeof(struct ipv6_opt_hdr))) {
                                err = -EINVAL;
                                goto exit_f;
                        }
@@ -590,7 +590,7 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl,
                        break;
 
                case IPV6_2292DSTOPTS:
-                        if (cmsg->cmsg_len < CMSG_LEN(sizeof(struct ipv6_opt_hdr))) {
+                       if (cmsg->cmsg_len < CMSG_LEN(sizeof(struct ipv6_opt_hdr))) {
                                err = -EINVAL;
                                goto exit_f;
                        }
@@ -641,7 +641,7 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl,
 
                case IPV6_2292RTHDR:
                case IPV6_RTHDR:
-                        if (cmsg->cmsg_len < CMSG_LEN(sizeof(struct ipv6_rt_hdr))) {
+                       if (cmsg->cmsg_len < CMSG_LEN(sizeof(struct ipv6_rt_hdr))) {
                                err = -EINVAL;
                                goto exit_f;
                        }
@@ -661,7 +661,7 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl,
 
                        len = ((rthdr->hdrlen + 1) << 3);
 
-                        if (cmsg->cmsg_len < CMSG_LEN(len)) {
+                       if (cmsg->cmsg_len < CMSG_LEN(len)) {
                                err = -EINVAL;
                                goto exit_f;
                        }
@@ -716,7 +716,7 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl,
                    }
                default:
                        LIMIT_NETDEBUG(KERN_DEBUG "invalid cmsg type: %d\n",
-                                      cmsg->cmsg_type);
+                                      cmsg->cmsg_type);
                        err = -EINVAL;
                        break;
                };
index 25dcf69cd807beca9b533bd2728c6d337ea1ce86..363e63ffecca26ca7eadfcbfa07b859a0abc7df8 100644 (file)
@@ -1,26 +1,26 @@
 /*
  * Copyright (C)2002 USAGI/WIDE Project
- * 
+ *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  * Authors
  *
- *     Mitsuru KANDA @USAGI       : IPv6 Support 
+ *     Mitsuru KANDA @USAGI       : IPv6 Support
  *     Kazunori MIYAZAWA @USAGI   :
  *     Kunihiro Ishiguro <kunihiro@ipinfusion.com>
- *     
+ *
  *     This file is derived from net/ipv4/esp.c
  */
 
@@ -166,7 +166,7 @@ static int esp6_input(struct xfrm_state *x, struct sk_buff *skb)
        }
 
        /* If integrity check is required, do this. */
-        if (esp->auth.icv_full_len) {
+       if (esp->auth.icv_full_len) {
                u8 sum[alen];
 
                ret = esp_mac_digest(esp, skb, 0, skb->len - alen);
@@ -197,7 +197,7 @@ static int esp6_input(struct xfrm_state *x, struct sk_buff *skb)
        if (esp->conf.ivlen)
                crypto_blkcipher_set_iv(tfm, esph->enc_data, esp->conf.ivlen);
 
-        {
+       {
                u8 nexthdr[2];
                struct scatterlist *sg = &esp->sgbuf[0];
                u8 padlen;
@@ -225,7 +225,7 @@ static int esp6_input(struct xfrm_state *x, struct sk_buff *skb)
                        ret = -EINVAL;
                        goto out;
                }
-               /* ... check padding bits here. Silly. :-) */ 
+               /* ... check padding bits here. Silly. :-) */
 
                pskb_trim(skb, skb->len - alen - padlen - 2);
                ret = nexthdr[1];
@@ -256,20 +256,20 @@ static u32 esp6_get_max_size(struct xfrm_state *x, int mtu)
 }
 
 static void esp6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
-                     int type, int code, int offset, __be32 info)
+                    int type, int code, int offset, __be32 info)
 {
        struct ipv6hdr *iph = (struct ipv6hdr*)skb->data;
        struct ipv6_esp_hdr *esph = (struct ipv6_esp_hdr*)(skb->data+offset);
        struct xfrm_state *x;
 
-       if (type != ICMPV6_DEST_UNREACH && 
+       if (type != ICMPV6_DEST_UNREACH &&
            type != ICMPV6_PKT_TOOBIG)
                return;
 
        x = xfrm_state_lookup((xfrm_address_t *)&iph->daddr, esph->spi, IPPROTO_ESP, AF_INET6);
        if (!x)
                return;
-       printk(KERN_DEBUG "pmtu discovery on SA ESP/%08x/" NIP6_FMT "\n", 
+       printk(KERN_DEBUG "pmtu discovery on SA ESP/%08x/" NIP6_FMT "\n",
                        ntohl(esph->spi), NIP6(iph->daddr));
        xfrm_state_put(x);
 }
@@ -326,10 +326,10 @@ static int esp6_init_state(struct xfrm_state *x)
                esp->auth.tfm = hash;
                if (crypto_hash_setkey(hash, esp->auth.key, esp->auth.key_len))
                        goto error;
+
                aalg_desc = xfrm_aalg_get_byname(x->aalg->alg_name, 0);
                BUG_ON(!aalg_desc);
+
                if (aalg_desc->uinfo.auth.icv_fullbits/8 !=
                    crypto_hash_digestsize(hash)) {
                        NETDEBUG(KERN_INFO "ESP: %s digestsize %u != %hu\n",
@@ -338,10 +338,10 @@ static int esp6_init_state(struct xfrm_state *x)
                                 aalg_desc->uinfo.auth.icv_fullbits/8);
                        goto error;
                }
+
                esp->auth.icv_full_len = aalg_desc->uinfo.auth.icv_fullbits/8;
                esp->auth.icv_trunc_len = aalg_desc->uinfo.auth.icv_truncbits/8;
+
                esp->auth.work_icv = kmalloc(esp->auth.icv_full_len, GFP_KERNEL);
                if (!esp->auth.work_icv)
                        goto error;
index 0711f92d6a1238961ff0f7f4acd69e5e0268cd82..08313efc48c82660a5fd5c2ced3cc4c2b855af47 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 /* Changes:
- *     yoshfuji                : ensure not to overrun while parsing 
+ *     yoshfuji                : ensure not to overrun while parsing
  *                               tlv options.
  *     Mitsuru KANDA @USAGI and: Remove ipv6_parse_exthdrs().
  *     YOSHIFUJI Hideaki @USAGI  Register inbound extension header
@@ -167,8 +167,8 @@ static int ip6_parse_tlv(struct tlvtype_proc *procs, struct sk_buff **skbp)
                                goto bad;
                        for (curr=procs; curr->type >= 0; curr++) {
                                if (curr->type == skb->nh.raw[off]) {
-                                       /* type specific length/alignment 
-                                          checks will be performed in the 
+                                       /* type specific length/alignment
+                                          checks will be performed in the
                                           func(). */
                                        if (curr->func(skbp, off) == 0)
                                                return 0;
@@ -572,7 +572,7 @@ void __init ipv6_rthdr_init(void)
    For now we need to test the engine, so that I created
    temporary (or permanent) backdoor.
    If listening socket set IPV6_RTHDR to 2, then we invert header.
-                                                   --ANK (980729)
+                                                  --ANK (980729)
  */
 
 struct ipv6_txoptions *
@@ -635,7 +635,7 @@ static int ipv6_hop_ra(struct sk_buff **skbp, int optoff)
                return 1;
        }
        LIMIT_NETDEBUG(KERN_DEBUG "ipv6_hop_ra: wrong RA length %d\n",
-                      skb->nh.raw[optoff+1]);
+                      skb->nh.raw[optoff+1]);
        kfree_skb(skb);
        return 0;
 }
@@ -649,7 +649,7 @@ static int ipv6_hop_jumbo(struct sk_buff **skbp, int optoff)
 
        if (skb->nh.raw[optoff+1] != 4 || (optoff&3) != 2) {
                LIMIT_NETDEBUG(KERN_DEBUG "ipv6_hop_jumbo: wrong jumbo opt length/alignment %d\n",
-                              skb->nh.raw[optoff+1]);
+                              skb->nh.raw[optoff+1]);
                IP6_INC_STATS_BH(ip6_dst_idev(skb->dst),
                                 IPSTATS_MIB_INHDRERRORS);
                goto drop;
@@ -740,7 +740,7 @@ static void ipv6_push_rthdr(struct sk_buff *skb, u8 *proto,
        int hops;
 
        ihdr = (struct rt0_hdr *) opt;
-       
+
        phdr = (struct rt0_hdr *) skb_push(skb, (ihdr->rt_hdr.hdrlen + 1) << 3);
        memcpy(phdr, ihdr, sizeof(struct rt0_hdr));
 
index 21cbbbddaf4dff5e23d8a59310cb5769f28773b5..e1caa5d526c2537bf610f29e4fabaa94eccb111a 100644 (file)
@@ -4,13 +4,13 @@
  */
 #include <net/ipv6.h>
 
-/* 
+/*
  * find out if nexthdr is a well-known extension header or a protocol
  */
 
 int ipv6_ext_hdr(u8 nexthdr)
 {
-       /* 
+       /*
         * find out if nexthdr is an extension header or a protocol
         */
        return ( (nexthdr == NEXTHDR_HOP)       ||
@@ -25,18 +25,18 @@ int ipv6_ext_hdr(u8 nexthdr)
  * Skip any extension headers. This is used by the ICMP module.
  *
  * Note that strictly speaking this conflicts with RFC 2460 4.0:
- * ...The contents and semantics of each extension header determine whether 
+ * ...The contents and semantics of each extension header determine whether
  * or not to proceed to the next header.  Therefore, extension headers must
  * be processed strictly in the order they appear in the packet; a
  * receiver must not, for example, scan through a packet looking for a
  * particular kind of extension header and process that header prior to
  * processing all preceding ones.
- * 
+ *
  * We do exactly this. This is a protocol bug. We can't decide after a
- * seeing an unknown discard-with-error flavour TLV option if it's a 
+ * seeing an unknown discard-with-error flavour TLV option if it's a
  * ICMP error message or not (errors should never be send in reply to
  * ICMP error messages).
- * 
+ *
  * But I see no other way to do this. This might need to be reexamined
  * when Linux implements ESP (and maybe AUTH) headers.
  * --AK
@@ -90,9 +90,9 @@ int ipv6_skip_exthdr(const struct sk_buff *skb, int start, u8 *nexthdrp)
                                break;
                        hdrlen = 8;
                } else if (nexthdr == NEXTHDR_AUTH)
-                       hdrlen = (hp->hdrlen+2)<<2; 
+                       hdrlen = (hp->hdrlen+2)<<2;
                else
-                       hdrlen = ipv6_optlen(hp); 
+                       hdrlen = ipv6_optlen(hp);
 
                nexthdr = hp->nexthdr;
                start += hdrlen;
index 3dcc4b7f41b4cc65e5e7386842323f8d98938c8a..9377fea026824ca61ff7fe716c6957d62e86a8cf 100644 (file)
@@ -107,7 +107,7 @@ static __inline__ void icmpv6_xmit_unlock(void)
        spin_unlock_bh(&icmpv6_socket->sk->sk_lock.slock);
 }
 
-/* 
+/*
  * Slightly more convenient version of icmpv6_send.
  */
 void icmpv6_param_prob(struct sk_buff *skb, int code, int pos)
@@ -153,8 +153,8 @@ static int is_ineligible(struct sk_buff *skb)
 
 static int sysctl_icmpv6_time __read_mostly = 1*HZ;
 
-/* 
- * Check the ICMP output rate limit 
+/*
+ * Check the ICMP output rate limit
  */
 static inline int icmpv6_xrlim_allow(struct sock *sk, int type,
                                     struct flowi *fl)
@@ -170,7 +170,7 @@ static inline int icmpv6_xrlim_allow(struct sock *sk, int type,
        if (type == ICMPV6_PKT_TOOBIG)
                return 1;
 
-       /* 
+       /*
         * Look up the output route.
         * XXX: perhaps the expire for routing entries cloned by
         * this lookup should be more aggressive (not longer than timeout).
@@ -198,7 +198,7 @@ static inline int icmpv6_xrlim_allow(struct sock *sk, int type,
 /*
  *     an inline helper for the "simple" if statement below
  *     checks if parameter problem report is caused by an
- *     unrecognized IPv6 option that has the Option Type 
+ *     unrecognized IPv6 option that has the Option Type
  *     highest-order two bits set to 10
  */
 
@@ -298,7 +298,7 @@ static inline void mip6_addr_swap(struct sk_buff *skb) {}
 /*
  *     Send an ICMP message in response to a packet in error
  */
-void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info, 
+void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info,
                 struct net_device *dev)
 {
        struct inet6_dev *idev = NULL;
@@ -320,7 +320,7 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info,
                return;
 
        /*
-        *      Make sure we respect the rules 
+        *      Make sure we respect the rules
         *      i.e. RFC 1885 2.4(e)
         *      Rule (e.1) is enforced by not using icmpv6_send
         *      in any code that processes icmp errors.
@@ -336,8 +336,8 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info,
 
        if ((addr_type & IPV6_ADDR_MULTICAST || skb->pkt_type != PACKET_HOST)) {
                if (type != ICMPV6_PKT_TOOBIG &&
-                   !(type == ICMPV6_PARAMPROB && 
-                     code == ICMPV6_UNK_OPTION && 
+                   !(type == ICMPV6_PARAMPROB &&
+                     code == ICMPV6_UNK_OPTION &&
                      (opt_unrec(skb, info))))
                        return;
 
@@ -364,7 +364,7 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info,
                return;
        }
 
-       /* 
+       /*
         *      Never answer to a ICMP packet.
         */
        if (is_ineligible(skb)) {
@@ -543,14 +543,14 @@ static void icmpv6_echo_reply(struct sk_buff *skb)
        }
        err = icmpv6_push_pending_frames(sk, &fl, &tmp_hdr, skb->len + sizeof(struct icmp6hdr));
 
-        ICMP6_INC_STATS_BH(idev, ICMP6_MIB_OUTECHOREPLIES);
-        ICMP6_INC_STATS_BH(idev, ICMP6_MIB_OUTMSGS);
+       ICMP6_INC_STATS_BH(idev, ICMP6_MIB_OUTECHOREPLIES);
+       ICMP6_INC_STATS_BH(idev, ICMP6_MIB_OUTMSGS);
 
-out_put: 
+out_put:
        if (likely(idev != NULL))
                in6_dev_put(idev);
        dst_release(dst);
-out: 
+out:
        icmpv6_xmit_unlock();
 }
 
@@ -608,7 +608,7 @@ static void icmpv6_notify(struct sk_buff *skb, int type, int code, __be32 info)
        }
        read_unlock(&raw_v6_lock);
 }
-  
+
 /*
  *     Handle icmp messages
  */
@@ -722,9 +722,9 @@ static int icmpv6_rcv(struct sk_buff **pskb)
                if (type & ICMPV6_INFOMSG_MASK)
                        break;
 
-               /* 
-                * error of unknown type. 
-                * must pass to upper level 
+               /*
+                * error of unknown type.
+                * must pass to upper level
                 */
 
                icmpv6_notify(skb, type, hdr->icmp6_code, hdr->icmp6_mtu);
@@ -852,7 +852,7 @@ int icmpv6_err_convert(int type, int code, int *err)
        case ICMPV6_PKT_TOOBIG:
                *err = EMSGSIZE;
                break;
-               
+
        case ICMPV6_PARAMPROB:
                *err = EPROTO;
                fatal = 1;
index b7e5bae0e347dd59a0a9926b16911f2d3f20800a..30b16da739c23140d9cb26ac8c8da109eda07884 100644 (file)
@@ -79,7 +79,7 @@ struct sock *__inet6_lookup_established(struct inet_hashinfo *hashinfo,
                        goto hit; /* You sunk my battleship! */
        }
        /* Must check for a TIME_WAIT'er before going to listener hash. */
-       sk_for_each(sk, node, &(head + hashinfo->ehash_size)->chain) {
+       sk_for_each(sk, node, &head->twchain) {
                const struct inet_timewait_sock *tw = inet_twsk(sk);
 
                if(*((__portpair *)&(tw->tw_dport))     == ports        &&
@@ -115,7 +115,7 @@ struct sock *inet6_lookup_listener(struct inet_hashinfo *hashinfo,
        sk_for_each(sk, node, &hashinfo->listening_hash[inet_lhashfn(hnum)]) {
                if (inet_sk(sk)->num == hnum && sk->sk_family == PF_INET6) {
                        const struct ipv6_pinfo *np = inet6_sk(sk);
-                       
+
                        score = 1;
                        if (!ipv6_addr_any(&np->rcv_saddr)) {
                                if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
@@ -183,7 +183,7 @@ static int __inet6_check_established(struct inet_timewait_death_row *death_row,
        write_lock(&head->lock);
 
        /* Check TIME-WAIT sockets first. */
-       sk_for_each(sk2, node, &(head + hinfo->ehash_size)->chain) {
+       sk_for_each(sk2, node, &head->twchain) {
                const struct inet6_timewait_sock *tw6 = inet6_twsk(sk2);
 
                tw = inet_twsk(sk2);
@@ -249,81 +249,81 @@ int inet6_hash_connect(struct inet_timewait_death_row *death_row,
 {
        struct inet_hashinfo *hinfo = death_row->hashinfo;
        const unsigned short snum = inet_sk(sk)->num;
-       struct inet_bind_hashbucket *head;
-       struct inet_bind_bucket *tb;
+       struct inet_bind_hashbucket *head;
+       struct inet_bind_bucket *tb;
        int ret;
 
-       if (snum == 0) {
-               const int low = sysctl_local_port_range[0];
-               const int high = sysctl_local_port_range[1];
+       if (snum == 0) {
+               const int low = sysctl_local_port_range[0];
+               const int high = sysctl_local_port_range[1];
                const int range = high - low;
-               int i, port;
+               int i, port;
                static u32 hint;
                const u32 offset = hint + inet6_sk_port_offset(sk);
                struct hlist_node *node;
-               struct inet_timewait_sock *tw = NULL;
+               struct inet_timewait_sock *tw = NULL;
 
-               local_bh_disable();
+               local_bh_disable();
                for (i = 1; i <= range; i++) {
                        port = low + (i + offset) % range;
-                       head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];
-                       spin_lock(&head->lock);
+                       head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];
+                       spin_lock(&head->lock);
 
-                       /* Does not bother with rcv_saddr checks,
-                        * because the established check is already
-                        * unique enough.
-                        */
+                       /* Does not bother with rcv_saddr checks,
+                        * because the established check is already
+                        * unique enough.
+                        */
                        inet_bind_bucket_for_each(tb, node, &head->chain) {
-                               if (tb->port == port) {
-                                       BUG_TRAP(!hlist_empty(&tb->owners));
-                                       if (tb->fastreuse >= 0)
-                                               goto next_port;
-                                       if (!__inet6_check_established(death_row,
+                               if (tb->port == port) {
+                                       BUG_TRAP(!hlist_empty(&tb->owners));
+                                       if (tb->fastreuse >= 0)
+                                               goto next_port;
+                                       if (!__inet6_check_established(death_row,
                                                                       sk, port,
                                                                       &tw))
-                                               goto ok;
-                                       goto next_port;
-                               }
-                       }
+                                               goto ok;
+                                       goto next_port;
+                               }
+                       }
 
-                       tb = inet_bind_bucket_create(hinfo->bind_bucket_cachep,
+                       tb = inet_bind_bucket_create(hinfo->bind_bucket_cachep,
                                                     head, port);
-                       if (!tb) {
-                               spin_unlock(&head->lock);
-                               break;
-                       }
-                       tb->fastreuse = -1;
-                       goto ok;
+                       if (!tb) {
+                               spin_unlock(&head->lock);
+                               break;
+                       }
+                       tb->fastreuse = -1;
+                       goto ok;
 
-               next_port:
-                       spin_unlock(&head->lock);
-               }
-               local_bh_enable();
+               next_port:
+                       spin_unlock(&head->lock);
+               }
+               local_bh_enable();
 
-               return -EADDRNOTAVAIL;
+               return -EADDRNOTAVAIL;
 
 ok:
                hint += i;
 
-               /* Head lock still held and bh's disabled */
-               inet_bind_hash(sk, tb, port);
+               /* Head lock still held and bh's disabled */
+               inet_bind_hash(sk, tb, port);
                if (sk_unhashed(sk)) {
-                       inet_sk(sk)->sport = htons(port);
-                       __inet6_hash(hinfo, sk);
-               }
-               spin_unlock(&head->lock);
+                       inet_sk(sk)->sport = htons(port);
+                       __inet6_hash(hinfo, sk);
+               }
+               spin_unlock(&head->lock);
 
-               if (tw) {
-                       inet_twsk_deschedule(tw, death_row);
-                       inet_twsk_put(tw);
-               }
+               if (tw) {
+                       inet_twsk_deschedule(tw, death_row);
+                       inet_twsk_put(tw);
+               }
 
                ret = 0;
                goto out;
-       }
+       }
 
-       head = &hinfo->bhash[inet_bhashfn(snum, hinfo->bhash_size)];
-       tb   = inet_csk(sk)->icsk_bind_hash;
+       head = &hinfo->bhash[inet_bhashfn(snum, hinfo->bhash_size)];
+       tb   = inet_csk(sk)->icsk_bind_hash;
        spin_lock_bh(&head->lock);
 
        if (sk_head(&tb->owners) == sk && sk->sk_bind_node.next == NULL) {
index 96d8310ae9c822ed99f39899b49838e3318f56e0..f4d7be77eb0fefa93446010f9c335655c18fa654 100644 (file)
@@ -1,9 +1,9 @@
 /*
- *     Linux INET6 implementation 
+ *     Linux INET6 implementation
  *     Forwarding Information Database
  *
  *     Authors:
- *     Pedro Roque             <roque@di.fc.ul.pt>     
+ *     Pedro Roque             <roque@di.fc.ul.pt>
  *
  *     $Id: ip6_fib.c,v 1.25 2001/10/31 21:55:55 davem Exp $
  *
@@ -97,7 +97,7 @@ static DEFINE_TIMER(ip6_fib_timer, fib6_run_gc, 0, 0);
 
 static struct fib6_walker_t fib6_walker_list = {
        .prev   = &fib6_walker_list,
-       .next   = &fib6_walker_list, 
+       .next   = &fib6_walker_list,
 };
 
 #define FOR_WALKERS(w) for ((w)=fib6_walker_list.next; (w) != &fib6_walker_list; (w)=(w)->next)
@@ -131,7 +131,7 @@ static __inline__ u32 fib6_new_sernum(void)
 /*
  *     Auxiliary address test functions for the radix tree.
  *
- *     These assume a 32bit processor (although it will work on 
+ *     These assume a 32bit processor (although it will work on
  *     64bit processors)
  */
 
@@ -150,8 +150,7 @@ static __inline__ struct fib6_node * node_alloc(void)
 {
        struct fib6_node *fn;
 
-       if ((fn = kmem_cache_alloc(fib6_node_kmem, GFP_ATOMIC)) != NULL)
-               memset(fn, 0, sizeof(struct fib6_node));
+       fn = kmem_cache_zalloc(fib6_node_kmem, GFP_ATOMIC);
 
        return fn;
 }
@@ -298,7 +297,7 @@ static int fib6_dump_node(struct fib6_walker_t *w)
        int res;
        struct rt6_info *rt;
 
-       for (rt = w->leaf; rt; rt = rt->u.next) {
+       for (rt = w->leaf; rt; rt = rt->u.dst.rt6_next) {
                res = rt6_dump_route(rt, w->args);
                if (res < 0) {
                        /* Frame is full, suspend walking */
@@ -434,7 +433,7 @@ static struct fib6_node * fib6_add_1(struct fib6_node *root, void *addr,
        struct fib6_node *pn = NULL;
        struct rt6key *key;
        int     bit;
-               __be32  dir = 0;
+       __be32  dir = 0;
        __u32   sernum = fib6_new_sernum();
 
        RT6_TRACE("fib6_add_1\n");
@@ -452,27 +451,27 @@ static struct fib6_node * fib6_add_1(struct fib6_node *root, void *addr,
                if (plen < fn->fn_bit ||
                    !ipv6_prefix_equal(&key->addr, addr, fn->fn_bit))
                        goto insert_above;
-               
+
                /*
                 *      Exact match ?
                 */
-                        
+
                if (plen == fn->fn_bit) {
                        /* clean up an intermediate node */
                        if ((fn->fn_flags & RTN_RTINFO) == 0) {
                                rt6_release(fn->leaf);
                                fn->leaf = NULL;
                        }
-                       
+
                        fn->fn_sernum = sernum;
-                               
+
                        return fn;
                }
 
                /*
                 *      We have more bits to go
                 */
-                        
+
                /* Try to walk down on tree. */
                fn->fn_sernum = sernum;
                dir = addr_bit_set(addr, fn->fn_bit);
@@ -490,7 +489,7 @@ static struct fib6_node * fib6_add_1(struct fib6_node *root, void *addr,
        if (ln == NULL)
                return NULL;
        ln->fn_bit = plen;
-                       
+
        ln->parent = pn;
        ln->fn_sernum = sernum;
 
@@ -504,7 +503,7 @@ static struct fib6_node * fib6_add_1(struct fib6_node *root, void *addr,
 
 insert_above:
        /*
-        * split since we don't have a common prefix anymore or 
+        * split since we don't have a common prefix anymore or
         * we have a less significant route.
         * we've to insert an intermediate node on the list
         * this new node will point to the one we need to create
@@ -518,18 +517,18 @@ insert_above:
           See comment in __ipv6_addr_diff: bit may be an invalid value,
           but if it is >= plen, the value is ignored in any case.
         */
-       
+
        bit = __ipv6_addr_diff(addr, &key->addr, addrlen);
 
-       /* 
-        *              (intermediate)[in]      
+       /*
+        *              (intermediate)[in]
         *                /        \
         *      (new leaf node)[ln] (old node)[fn]
         */
        if (plen > bit) {
                in = node_alloc();
                ln = node_alloc();
-               
+
                if (in == NULL || ln == NULL) {
                        if (in)
                                node_free(in);
@@ -538,8 +537,8 @@ insert_above:
                        return NULL;
                }
 
-               /* 
-                * new intermediate node. 
+               /*
+                * new intermediate node.
                 * RTN_RTINFO will
                 * be off since that an address that chooses one of
                 * the branches would not match less specific routes
@@ -576,7 +575,7 @@ insert_above:
                }
        } else { /* plen <= bit */
 
-               /* 
+               /*
                 *              (new leaf node)[ln]
                 *                /        \
                 *           (old node)[fn] NULL
@@ -592,7 +591,7 @@ insert_above:
                ln->parent = pn;
 
                ln->fn_sernum = sernum;
-               
+
                if (dir)
                        pn->right = ln;
                else
@@ -624,11 +623,11 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt,
            fn->leaf == &ip6_null_entry &&
            !(rt->rt6i_flags & (RTF_DEFAULT | RTF_ADDRCONF)) ){
                fn->leaf = rt;
-               rt->u.next = NULL;
+               rt->u.dst.rt6_next = NULL;
                goto out;
        }
 
-       for (iter = fn->leaf; iter; iter=iter->u.next) {
+       for (iter = fn->leaf; iter; iter=iter->u.dst.rt6_next) {
                /*
                 *      Search for duplicates
                 */
@@ -656,7 +655,7 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt,
                if (iter->rt6i_metric > rt->rt6i_metric)
                        break;
 
-               ins = &iter->u.next;
+               ins = &iter->u.dst.rt6_next;
        }
 
        /*
@@ -664,7 +663,7 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt,
         */
 
 out:
-       rt->u.next = iter;
+       rt->u.dst.rt6_next = iter;
        *ins = rt;
        rt->rt6i_node = fn;
        atomic_inc(&rt->rt6i_ref);
@@ -1105,7 +1104,7 @@ static void fib6_del_route(struct fib6_node *fn, struct rt6_info **rtp,
        RT6_TRACE("fib6_del_route\n");
 
        /* Unlink it */
-       *rtp = rt->u.next;
+       *rtp = rt->u.dst.rt6_next;
        rt->rt6i_node = NULL;
        rt6_stats.fib_rt_entries--;
        rt6_stats.fib_discarded_routes++;
@@ -1115,14 +1114,14 @@ static void fib6_del_route(struct fib6_node *fn, struct rt6_info **rtp,
        FOR_WALKERS(w) {
                if (w->state == FWS_C && w->leaf == rt) {
                        RT6_TRACE("walker %p adjusted by delroute\n", w);
-                       w->leaf = rt->u.next;
+                       w->leaf = rt->u.dst.rt6_next;
                        if (w->leaf == NULL)
                                w->state = FWS_U;
                }
        }
        read_unlock(&fib6_walker_lock);
 
-       rt->u.next = NULL;
+       rt->u.dst.rt6_next = NULL;
 
        if (fn->leaf == NULL && fn->fn_flags&RTN_TL_ROOT)
                fn->leaf = &ip6_null_entry;
@@ -1190,7 +1189,7 @@ int fib6_del(struct rt6_info *rt, struct nl_info *info)
         *      Walk the leaf entries looking for ourself
         */
 
-       for (rtp = &fn->leaf; *rtp; rtp = &(*rtp)->u.next) {
+       for (rtp = &fn->leaf; *rtp; rtp = &(*rtp)->u.dst.rt6_next) {
                if (*rtp == rt) {
                        fib6_del_route(fn, rtp, info);
                        return 0;
@@ -1206,7 +1205,7 @@ int fib6_del(struct rt6_info *rt, struct nl_info *info)
  *     However, it is internally reenterable wrt itself and fib6_add/fib6_del.
  *     It means, that we can modify tree during walking
  *     and use this function for garbage collection, clone pruning,
- *     cleaning tree when a device goes down etc. etc. 
+ *     cleaning tree when a device goes down etc. etc.
  *
  *     It guarantees that every node will be traversed,
  *     and that it will be traversed only once.
@@ -1245,7 +1244,7 @@ static int fib6_walk_continue(struct fib6_walker_t *w)
                                continue;
                        }
                        w->state = FWS_L;
-#endif 
+#endif
                case FWS_L:
                        if (fn->left) {
                                w->node = fn->left;
@@ -1317,7 +1316,7 @@ static int fib6_clean_node(struct fib6_walker_t *w)
        struct rt6_info *rt;
        struct fib6_cleaner_t *c = (struct fib6_cleaner_t*)w;
 
-       for (rt = w->leaf; rt; rt = rt->u.next) {
+       for (rt = w->leaf; rt; rt = rt->u.dst.rt6_next) {
                res = c->func(rt, c->arg);
                if (res < 0) {
                        w->leaf = rt;
@@ -1338,7 +1337,7 @@ static int fib6_clean_node(struct fib6_walker_t *w)
 
 /*
  *     Convenient frontend to tree walker.
- *     
+ *
  *     func is called on each route.
  *             It may return -1 -> delete this route.
  *                           0  -> continue walking
index 624fae251f4e227c21dd8d8abd420f143910e70f..1551ab3890a3bba74ab9900a47e9b0b1ea471d35 100644 (file)
@@ -228,10 +228,10 @@ struct ipv6_txoptions *fl6_merge_options(struct ipv6_txoptions * opt_space,
                                         struct ipv6_txoptions * fopt)
 {
        struct ipv6_txoptions * fl_opt = fl->opt;
-       
+
        if (fopt == NULL || fopt->opt_flen == 0)
                return fl_opt;
-       
+
        if (fl_opt != NULL) {
                opt_space->hopopt = fl_opt->hopopt;
                opt_space->dst0opt = fl_opt->dst0opt;
index ad0b8abcdf4b65fbd9ebec449dcefd4acfb118e7..4fdded0e545a4a45449d6a6fdc9a5f24d78e0014 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *     IPv6 input
- *     Linux INET6 implementation 
+ *     Linux INET6 implementation
  *
  *     Authors:
  *     Pedro Roque             <roque@di.fc.ul.pt>
@@ -48,7 +48,7 @@
 
 
 
-inline int ip6_rcv_finish( struct sk_buff *skb) 
+inline int ip6_rcv_finish( struct sk_buff *skb)
 {
        if (skb->dst == NULL)
                ip6_route_input(skb);
@@ -173,9 +173,9 @@ resubmit:
        hash = nexthdr & (MAX_INET_PROTOS - 1);
        if ((ipprot = rcu_dereference(inet6_protos[hash])) != NULL) {
                int ret;
-               
+
                if (ipprot->flags & INET6_PROTO_FINAL) {
-                       struct ipv6hdr *hdr;    
+                       struct ipv6hdr *hdr;
 
                        /* Free reference early: we don't need it any more,
                           and it may hold ip_conntrack module loaded
@@ -192,9 +192,9 @@ resubmit:
                                goto discard;
                }
                if (!(ipprot->flags & INET6_PROTO_NOPOLICY) &&
-                   !xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) 
+                   !xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb))
                        goto discard;
-               
+
                ret = ipprot->handler(&skb);
                if (ret > 0)
                        goto resubmit;
@@ -205,8 +205,8 @@ resubmit:
                        if (xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) {
                                IP6_INC_STATS_BH(idev, IPSTATS_MIB_INUNKNOWNPROTOS);
                                icmpv6_send(skb, ICMPV6_PARAMPROB,
-                                           ICMPV6_UNK_NEXTHDR, nhoff,
-                                           skb->dev);
+                                           ICMPV6_UNK_NEXTHDR, nhoff,
+                                           skb->dev);
                        }
                } else
                        IP6_INC_STATS_BH(idev, IPSTATS_MIB_INDELIVERS);
@@ -253,7 +253,7 @@ int ip6_mc_input(struct sk_buff *skb)
                        struct dst_entry *dst;
 
                        dst = skb->dst;
-                       
+
                        if (deliver) {
                                skb2 = skb_clone(skb, GFP_ATOMIC);
                                dst_output(skb2);
index 7b7bd44fbf47f3a4b66af6a5bfef62ee8bff4d99..305516921aa8e96583422cdce873777d22f8ee29 100644 (file)
@@ -1,9 +1,9 @@
 /*
  *     IPv6 output functions
- *     Linux INET6 implementation 
+ *     Linux INET6 implementation
  *
  *     Authors:
- *     Pedro Roque             <roque@di.fc.ul.pt>     
+ *     Pedro Roque             <roque@di.fc.ul.pt>
  *
  *     $Id: ip6_output.c,v 1.34 2002/02/01 22:01:04 davem Exp $
  *
@@ -363,7 +363,7 @@ int ip6_forward(struct sk_buff *skb)
        struct dst_entry *dst = skb->dst;
        struct ipv6hdr *hdr = skb->nh.ipv6h;
        struct inet6_skb_parm *opt = IP6CB(skb);
-       
+
        if (ipv6_devconf.forwarding == 0)
                goto error;
 
@@ -473,7 +473,7 @@ int ip6_forward(struct sk_buff *skb)
        hdr = skb->nh.ipv6h;
 
        /* Mangling hops number delayed to point after skb COW */
+
        hdr->hop_limit--;
 
        IP6_INC_STATS_BH(ip6_dst_idev(dst), IPSTATS_MIB_OUTFORWDATAGRAMS);
@@ -659,7 +659,7 @@ static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
                                frag->nh.ipv6h->payload_len = htons(frag->len - sizeof(struct ipv6hdr));
                                ip6_copy_metadata(frag, skb);
                        }
-                       
+
                        err = output(skb);
                        if(!err)
                                IP6_INC_STATS(ip6_dst_idev(&rt->u.dst), IPSTATS_MIB_FRAGCREATES);
@@ -792,7 +792,7 @@ slow_path:
 fail:
        IP6_INC_STATS(ip6_dst_idev(skb->dst),
                      IPSTATS_MIB_FRAGFAILS);
-       kfree_skb(skb); 
+       kfree_skb(skb);
        return err;
 }
 
@@ -955,7 +955,7 @@ static inline int ip6_ufo_append_data(struct sock *sk,
                struct frag_hdr fhdr;
 
                /* specify the length of each IP datagram fragment*/
-               skb_shinfo(skb)->gso_size = mtu - fragheaderlen - 
+               skb_shinfo(skb)->gso_size = mtu - fragheaderlen -
                                            sizeof(struct frag_hdr);
                skb_shinfo(skb)->gso_type = SKB_GSO_UDP;
                ipv6_select_ident(skb, &fhdr);
@@ -1058,13 +1058,13 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to,
         * fragment alignment (= 8-15 octects, in total).
         *
         * Note that we may need to "move" the data from the tail of
-        * of the buffer to the new fragment when we split 
+        * of the buffer to the new fragment when we split
         * the message.
         *
-        * FIXME: It may be fragmented into multiple chunks 
+        * FIXME: It may be fragmented into multiple chunks
         *        at once if non-fragmentable extension headers
         *        are too large.
-        * --yoshfuji 
+        * --yoshfuji
         */
 
        inet->cork.length += length;
@@ -1129,7 +1129,7 @@ alloc_new_skb:
 
                        /*
                         * We just reserve space for fragment header.
-                        * Note: this may be overallocation if the message 
+                        * Note: this may be overallocation if the message
                         * (without MSG_MORE) fits into the MTU.
                         */
                        alloclen += sizeof(struct frag_hdr);
@@ -1310,7 +1310,7 @@ int ip6_push_pending_frames(struct sock *sk)
                ipv6_push_nfrag_opts(skb, opt, &proto, &final_dst);
 
        skb->nh.ipv6h = hdr = (struct ipv6hdr*) skb_push(skb, sizeof(struct ipv6hdr));
-       
+
        *(__be32*)hdr = fl->fl6_flowlabel |
                     htonl(0x60000000 | ((int)np->cork.tclass << 20));
 
index 8d918348f5bb62b4b61d8dbb82bc7670c1c98542..367b7483298610460e8449904200a1e5c3e0faee 100644 (file)
@@ -3,7 +3,7 @@
  *     Linux INET6 implementation
  *
  *     Authors:
- *     Ville Nuorvala          <vnuorval@tcs.hut.fi>   
+ *     Ville Nuorvala          <vnuorval@tcs.hut.fi>
  *
  *     $Id$
  *
@@ -67,8 +67,8 @@ MODULE_LICENSE("GPL");
 #define HASH_SIZE  32
 
 #define HASH(addr) ((__force u32)((addr)->s6_addr32[0] ^ (addr)->s6_addr32[1] ^ \
-                    (addr)->s6_addr32[2] ^ (addr)->s6_addr32[3]) & \
-                    (HASH_SIZE - 1))
+                    (addr)->s6_addr32[2] ^ (addr)->s6_addr32[3]) & \
+                   (HASH_SIZE - 1))
 
 static int ip6ip6_fb_tnl_dev_init(struct net_device *dev);
 static int ip6ip6_tnl_dev_init(struct net_device *dev);
@@ -90,7 +90,7 @@ static inline struct dst_entry *ip6_tnl_dst_check(struct ip6_tnl *t)
 {
        struct dst_entry *dst = t->dst_cache;
 
-       if (dst && dst->obsolete && 
+       if (dst && dst->obsolete &&
            dst->ops->check(dst, t->dst_cookie) == NULL) {
                t->dst_cache = NULL;
                dst_release(dst);
@@ -116,12 +116,12 @@ static inline void ip6_tnl_dst_store(struct ip6_tnl *t, struct dst_entry *dst)
 
 /**
  * ip6ip6_tnl_lookup - fetch tunnel matching the end-point addresses
- *   @remote: the address of the tunnel exit-point 
- *   @local: the address of the tunnel entry-point 
+ *   @remote: the address of the tunnel exit-point
+ *   @local: the address of the tunnel entry-point
  *
- * Return:  
+ * Return:
  *   tunnel matching given end-points if found,
- *   else fallback tunnel if its device is up, 
+ *   else fallback tunnel if its device is up,
  *   else %NULL
  **/
 
@@ -146,13 +146,13 @@ ip6ip6_tnl_lookup(struct in6_addr *remote, struct in6_addr *local)
 
 /**
  * ip6ip6_bucket - get head of list matching given tunnel parameters
- *   @p: parameters containing tunnel end-points 
+ *   @p: parameters containing tunnel end-points
  *
  * Description:
- *   ip6ip6_bucket() returns the head of the list matching the 
+ *   ip6ip6_bucket() returns the head of the list matching the
  *   &struct in6_addr entries laddr and raddr in @p.
  *
- * Return: head of IPv6 tunnel list 
+ * Return: head of IPv6 tunnel list
  **/
 
 static struct ip6_tnl **
@@ -213,8 +213,8 @@ ip6ip6_tnl_unlink(struct ip6_tnl *t)
  *
  * Description:
  *   Create tunnel matching given parameters.
- * 
- * Return: 
+ *
+ * Return:
  *   created tunnel or NULL
  **/
 
@@ -234,7 +234,7 @@ static struct ip6_tnl *ip6_tnl_create(struct ip6_tnl_parm *p)
                        if (__dev_get_by_name(name) == NULL)
                                break;
                }
-               if (i == IP6_TNL_MAX) 
+               if (i == IP6_TNL_MAX)
                        goto failed;
        }
        dev = alloc_netdev(sizeof (*t), name, ip6ip6_tnl_dev_setup);
@@ -258,7 +258,7 @@ failed:
 
 /**
  * ip6ip6_tnl_locate - find or create tunnel matching given parameters
- *   @p: tunnel parameters 
+ *   @p: tunnel parameters
  *   @create: != 0 if allowed to create new tunnel if no match found
  *
  * Description:
@@ -289,7 +289,7 @@ static struct ip6_tnl *ip6ip6_tnl_locate(struct ip6_tnl_parm *p, int create)
 /**
  * ip6ip6_tnl_dev_uninit - tunnel device uninitializer
  *   @dev: the device to be destroyed
- *   
+ *
  * Description:
  *   ip6ip6_tnl_dev_uninit() removes tunnel from its list
  **/
@@ -314,8 +314,8 @@ ip6ip6_tnl_dev_uninit(struct net_device *dev)
  * parse_tvl_tnl_enc_lim - handle encapsulation limit option
  *   @skb: received socket buffer
  *
- * Return: 
- *   0 if none was found, 
+ * Return:
+ *   0 if none was found,
  *   else index to encapsulation limit
  **/
 
@@ -392,8 +392,8 @@ ip6ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
        __u16 len;
        int err = -ENOENT;
 
-       /* If the packet doesn't contain the original IPv6 header we are 
-          in trouble since we might need the source address for further 
+       /* If the packet doesn't contain the original IPv6 header we are
+          in trouble since we might need the source address for further
           processing of the error. */
 
        read_lock(&ip6ip6_lock);
@@ -418,7 +418,7 @@ ip6ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
                        if (net_ratelimit())
                                printk(KERN_WARNING
                                       "%s: Too small hop limit or "
-                                      "routing loop in tunnel!\n", 
+                                      "routing loop in tunnel!\n",
                                       t->parms.name);
                        rel_msg = 1;
                }
@@ -502,7 +502,7 @@ static inline int ip6_tnl_rcv_ctl(struct ip6_tnl *t)
        int ret = 0;
 
        if (p->flags & IP6_TNL_F_CAP_RCV) {
-               struct net_device *ldev = NULL;
+               struct net_device *ldev = NULL;
 
                if (p->link)
                        ldev = dev_get_by_index(p->link);
@@ -525,7 +525,7 @@ static inline int ip6_tnl_rcv_ctl(struct ip6_tnl *t)
  * Return: 0
  **/
 
-static int 
+static int
 ip6ip6_rcv(struct sk_buff *skb)
 {
        struct ipv6hdr *ipv6h;
@@ -595,13 +595,13 @@ static void init_tel_txopt(struct ipv6_tel_txoption *opt, __u8 encap_limit)
 /**
  * ip6ip6_tnl_addr_conflict - compare packet addresses to tunnel's own
  *   @t: the outgoing tunnel device
- *   @hdr: IPv6 header from the incoming packet 
+ *   @hdr: IPv6 header from the incoming packet
  *
  * Description:
- *   Avoid trivial tunneling loop by checking that tunnel exit-point 
+ *   Avoid trivial tunneling loop by checking that tunnel exit-point
  *   doesn't match source of incoming packet.
  *
- * Return: 
+ * Return:
  *   1 if conflict,
  *   0 else
  **/
@@ -617,7 +617,7 @@ static inline int ip6_tnl_xmit_ctl(struct ip6_tnl *t)
        struct ip6_tnl_parm *p = &t->parms;
        int ret = 0;
 
-       if (p->flags & IP6_TNL_F_CAP_XMIT) {
+       if (p->flags & IP6_TNL_F_CAP_XMIT) {
                struct net_device *ldev = NULL;
 
                if (p->link)
@@ -641,19 +641,19 @@ static inline int ip6_tnl_xmit_ctl(struct ip6_tnl *t)
        return ret;
 }
 /**
- * ip6ip6_tnl_xmit - encapsulate packet and send 
+ * ip6ip6_tnl_xmit - encapsulate packet and send
  *   @skb: the outgoing socket buffer
- *   @dev: the outgoing tunnel device 
+ *   @dev: the outgoing tunnel device
  *
  * Description:
  *   Build new header and do some sanity checks on the packet before sending
  *   it.
  *
- * Return: 
+ * Return:
  *   0
  **/
 
-static int 
+static int
 ip6ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
 {
        struct ip6_tnl *t = netdev_priv(dev);
@@ -715,7 +715,7 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
        if (tdev == dev) {
                stats->collisions++;
                if (net_ratelimit())
-                       printk(KERN_WARNING 
+                       printk(KERN_WARNING
                               "%s: Local routing loop detected!\n",
                               t->parms.name);
                goto tx_err_dst_release;
@@ -741,11 +741,11 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
         * Okay, now see if we can stuff it in the buffer as-is.
         */
        max_headroom += LL_RESERVED_SPACE(tdev);
-       
-       if (skb_headroom(skb) < max_headroom || 
+
+       if (skb_headroom(skb) < max_headroom ||
            skb_cloned(skb) || skb_shared(skb)) {
                struct sk_buff *new_skb;
-               
+
                if (!(new_skb = skb_realloc_headroom(skb, max_headroom)))
                        goto tx_err_dst_release;
 
@@ -775,7 +775,7 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
        ipv6_addr_copy(&ipv6h->daddr, &fl.fl6_dst);
        nf_reset(skb);
        pkt_len = skb->len;
-       err = NF_HOOK(PF_INET6, NF_IP6_LOCAL_OUT, skb, NULL, 
+       err = NF_HOOK(PF_INET6, NF_IP6_LOCAL_OUT, skb, NULL,
                      skb->dst->dev, dst_output);
 
        if (net_xmit_eval(err) == 0) {
@@ -898,14 +898,14 @@ ip6ip6_tnl_change(struct ip6_tnl *t, struct ip6_tnl_parm *p)
 }
 
 /**
- * ip6ip6_tnl_ioctl - configure ipv6 tunnels from userspace 
+ * ip6ip6_tnl_ioctl - configure ipv6 tunnels from userspace
  *   @dev: virtual device associated with tunnel
  *   @ifr: parameters passed from userspace
  *   @cmd: command to be performed
  *
  * Description:
- *   ip6ip6_tnl_ioctl() is used for managing IPv6 tunnels 
- *   from userspace. 
+ *   ip6ip6_tnl_ioctl() is used for managing IPv6 tunnels
+ *   from userspace.
  *
  *   The possible commands are the following:
  *     %SIOCGETTUNNEL: get tunnel parameters for device
@@ -913,7 +913,7 @@ ip6ip6_tnl_change(struct ip6_tnl *t, struct ip6_tnl_parm *p)
  *     %SIOCCHGTUNNEL: change tunnel parameters to those given
  *     %SIOCDELTUNNEL: delete tunnel
  *
- *   The fallback device "ip6tnl0", created during module 
+ *   The fallback device "ip6tnl0", created during module
  *   initialization, can be used for creating other tunnel devices.
  *
  * Return:
@@ -999,7 +999,8 @@ ip6ip6_tnl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
                                break;
                        dev = t->dev;
                }
-               err = unregister_netdevice(dev);
+               err = 0;
+               unregister_netdevice(dev);
                break;
        default:
                err = -EINVAL;
@@ -1008,7 +1009,7 @@ ip6ip6_tnl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
 }
 
 /**
- * ip6ip6_tnl_get_stats - return the stats for tunnel device 
+ * ip6ip6_tnl_get_stats - return the stats for tunnel device
  *   @dev: virtual device associated with tunnel
  *
  * Return: stats for device
@@ -1101,7 +1102,7 @@ ip6ip6_tnl_dev_init(struct net_device *dev)
  * Return: 0
  **/
 
-static int 
+static int
 ip6ip6_fb_tnl_dev_init(struct net_device *dev)
 {
        struct ip6_tnl *t = netdev_priv(dev);
index 511730b67e97fb0ba1f9d167c07e120ea3b34f6a..5724ba9f75de595f13f0e6f0e8459020f425f590 100644 (file)
@@ -9,25 +9,25 @@
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
-/* 
+/*
  * [Memo]
  *
  * Outbound:
- *  The compression of IP datagram MUST be done before AH/ESP processing, 
- *  fragmentation, and the addition of Hop-by-Hop/Routing header. 
+ *  The compression of IP datagram MUST be done before AH/ESP processing,
+ *  fragmentation, and the addition of Hop-by-Hop/Routing header.
  *
  * Inbound:
- *  The decompression of IP datagram MUST be done after the reassembly, 
+ *  The decompression of IP datagram MUST be done after the reassembly,
  *  AH/ESP processing.
  */
 #include <linux/module.h>
@@ -176,7 +176,7 @@ out_ok:
 }
 
 static void ipcomp6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
-                               int type, int code, int offset, __be32 info)
+                               int type, int code, int offset, __be32 info)
 {
        __be32 spi;
        struct ipv6hdr *iph = (struct ipv6hdr*)skb->data;
@@ -422,7 +422,7 @@ static int ipcomp6_init_state(struct xfrm_state *x)
        x->props.header_len = 0;
        if (x->props.mode == XFRM_MODE_TUNNEL)
                x->props.header_len += sizeof(struct ipv6hdr);
-       
+
        mutex_lock(&ipcomp6_resource_mutex);
        if (!ipcomp6_alloc_scratches())
                goto error;
@@ -455,7 +455,7 @@ error:
        goto out;
 }
 
-static struct xfrm_type ipcomp6_type = 
+static struct xfrm_type ipcomp6_type =
 {
        .description    = "IPCOMP6",
        .owner          = THIS_MODULE,
@@ -467,7 +467,7 @@ static struct xfrm_type ipcomp6_type =
        .hdr_offset     = xfrm6_find_1stfragopt,
 };
 
-static struct inet6_protocol ipcomp6_protocol = 
+static struct inet6_protocol ipcomp6_protocol =
 {
        .handler        = xfrm6_rcv,
        .err_handler    = ipcomp6_err,
@@ -490,7 +490,7 @@ static int __init ipcomp6_init(void)
 
 static void __exit ipcomp6_fini(void)
 {
-       if (inet6_del_protocol(&ipcomp6_protocol, IPPROTO_COMP) < 0) 
+       if (inet6_del_protocol(&ipcomp6_protocol, IPPROTO_COMP) < 0)
                printk(KERN_INFO "ipv6 ipcomp close: can't remove protocol\n");
        if (xfrm_unregister_type(&ipcomp6_type, AF_INET6) < 0)
                printk(KERN_INFO "ipv6 ipcomp close: can't remove xfrm type\n");
index 352690e2ab8280ec89019697cca70d48ada6e48c..3f1e779ea5c52151e748a807dcb141ecbea0786f 100644 (file)
@@ -1,9 +1,9 @@
 /*
  *     IPv6 BSD socket options interface
- *     Linux INET6 implementation 
+ *     Linux INET6 implementation
  *
  *     Authors:
- *     Pedro Roque             <roque@di.fc.ul.pt>     
+ *     Pedro Roque             <roque@di.fc.ul.pt>
  *
  *     Based on linux/net/ipv4/ip_sockglue.c
  *
@@ -164,7 +164,7 @@ out:
 }
 
 static struct packet_type ipv6_packet_type = {
-       .type = __constant_htons(ETH_P_IPV6), 
+       .type = __constant_htons(ETH_P_IPV6),
        .func = ipv6_rcv,
        .gso_send_check = ipv6_gso_send_check,
        .gso_segment = ipv6_gso_segment,
@@ -320,7 +320,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
                np->rxopt.bits.rxinfo = valbool;
                retv = 0;
                break;
-               
+
        case IPV6_2292PKTINFO:
                np->rxopt.bits.rxoinfo = valbool;
                retv = 0;
@@ -376,7 +376,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
                np->tclass = val;
                retv = 0;
                break;
-               
+
        case IPV6_RECVTCLASS:
                np->rxopt.bits.rxtclass = valbool;
                retv = 0;
@@ -893,7 +893,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
        case IPV6_MTU:
        {
                struct dst_entry *dst;
-               val = 0;        
+               val = 0;
                lock_sock(sk);
                dst = sk_dst_get(sk);
                if (dst) {
index 882cde4b404754c97089e573981eb9ce17e74d4b..c9db5bc5b0f9dcbb66310d5325fd8cc45ac57459 100644 (file)
@@ -1,13 +1,13 @@
 /*
  *     Multicast support for IPv6
- *     Linux INET6 implementation 
+ *     Linux INET6 implementation
  *
  *     Authors:
- *     Pedro Roque             <roque@di.fc.ul.pt>     
+ *     Pedro Roque             <roque@di.fc.ul.pt>
  *
  *     $Id: mcast.c,v 1.40 2002/02/08 03:57:19 davem Exp $
  *
- *     Based on linux/ipv4/igmp.c and linux/ipv4/ip_sockglue.c 
+ *     Based on linux/ipv4/igmp.c and linux/ipv4/ip_sockglue.c
  *
  *     This program is free software; you can redistribute it and/or
  *      modify it under the terms of the GNU General Public License
@@ -644,7 +644,7 @@ int ip6_mc_msfget(struct sock *sk, struct group_filter *gsf,
                memset(&ss, 0, sizeof(ss));
                psin6->sin6_family = AF_INET6;
                psin6->sin6_addr = psl->sl_addr[i];
-               if (copy_to_user(&optval->gf_slist[i], &ss, sizeof(ss)))
+               if (copy_to_user(&optval->gf_slist[i], &ss, sizeof(ss)))
                        return -EFAULT;
        }
        return 0;
@@ -1168,7 +1168,7 @@ int igmp6_event_query(struct sk_buff *skb)
 
        /* compute payload length excluding extension headers */
        len = ntohs(skb->nh.ipv6h->payload_len) + sizeof(struct ipv6hdr);
-       len -= (char *)skb->h.raw - (char *)skb->nh.ipv6h; 
+       len -= (char *)skb->h.raw - (char *)skb->nh.ipv6h;
 
        /* Drop queries with not link local source */
        if (!(ipv6_addr_type(&skb->nh.ipv6h->saddr)&IPV6_ADDR_LINKLOCAL))
@@ -1206,7 +1206,7 @@ int igmp6_event_query(struct sk_buff *skb)
                /* clear deleted report items */
                mld_clear_delrec(idev);
        } else if (len >= 28) {
-               int srcs_offset = sizeof(struct mld2_query) - 
+               int srcs_offset = sizeof(struct mld2_query) -
                                  sizeof(struct icmp6hdr);
                if (!pskb_may_pull(skb, srcs_offset)) {
                        in6_dev_put(idev);
@@ -1230,7 +1230,7 @@ int igmp6_event_query(struct sk_buff *skb)
                }
                /* mark sources to include, if group & source-specific */
                if (mlh2->nsrcs != 0) {
-                       if (!pskb_may_pull(skb, srcs_offset + 
+                       if (!pskb_may_pull(skb, srcs_offset +
                            ntohs(mlh2->nsrcs) * sizeof(struct in6_addr))) {
                                in6_dev_put(idev);
                                return -EINVAL;
@@ -1304,7 +1304,7 @@ int igmp6_event_report(struct sk_buff *skb)
 
        /* Drop reports with not link local source */
        addr_type = ipv6_addr_type(&skb->nh.ipv6h->saddr);
-       if (addr_type != IPV6_ADDR_ANY && 
+       if (addr_type != IPV6_ADDR_ANY &&
            !(addr_type&IPV6_ADDR_LINKLOCAL))
                return -EINVAL;
 
@@ -1413,7 +1413,7 @@ static struct sk_buff *mld_newpack(struct net_device *dev, int size)
 
        if (ipv6_get_lladdr(dev, &addr_buf)) {
                /* <draft-ietf-magma-mld-source-05.txt>:
-                * use unspecified address as the source address 
+                * use unspecified address as the source address
                 * when a valid link-local address is not available.
                 */
                memset(&addr_buf, 0, sizeof(addr_buf));
@@ -1454,7 +1454,7 @@ static inline int mld_dev_queue_xmit2(struct sk_buff *skb)
 static inline int mld_dev_queue_xmit(struct sk_buff *skb)
 {
        return NF_HOOK(PF_INET6, NF_IP6_POST_ROUTING, skb, NULL, skb->dev,
-                      mld_dev_queue_xmit2);
+                      mld_dev_queue_xmit2);
 }
 
 static void mld_sendpack(struct sk_buff *skb)
@@ -1582,6 +1582,8 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ifmcaddr6 *pmc,
                        skb = add_grhead(skb, pmc, type, &pgr);
                        first = 0;
                }
+               if (!skb)
+                       return NULL;
                psrc = (struct in6_addr *)skb_put(skb, sizeof(*psrc));
                *psrc = psf->sf_addr;
                scount++; stotal++;
@@ -1752,8 +1754,8 @@ static void igmp6_send(struct in6_addr *addr, struct net_device *dev, int type)
 {
        struct sock *sk = igmp6_socket->sk;
        struct inet6_dev *idev;
-        struct sk_buff *skb;
-        struct icmp6hdr *hdr;
+       struct sk_buff *skb;
+       struct icmp6hdr *hdr;
        struct in6_addr *snd_addr;
        struct in6_addr *addrp;
        struct in6_addr addr_buf;
@@ -1791,7 +1793,7 @@ static void igmp6_send(struct in6_addr *addr, struct net_device *dev, int type)
 
        if (ipv6_get_lladdr(dev, &addr_buf)) {
                /* <draft-ietf-magma-mld-source-05.txt>:
-                * use unspecified address as the source address 
+                * use unspecified address as the source address
                 * when a valid link-local address is not available.
                 */
                memset(&addr_buf, 0, sizeof(addr_buf));
@@ -2328,7 +2330,7 @@ static inline struct ifmcaddr6 *igmp6_mc_get_first(struct seq_file *seq)
        struct igmp6_mc_iter_state *state = igmp6_mc_seq_private(seq);
 
        for (state->dev = dev_base, state->idev = NULL;
-            state->dev; 
+            state->dev;
             state->dev = state->dev->next) {
                struct inet6_dev *idev;
                idev = in6_dev_get(state->dev);
@@ -2411,7 +2413,7 @@ static int igmp6_mc_seq_show(struct seq_file *seq, void *v)
        struct igmp6_mc_iter_state *state = igmp6_mc_seq_private(seq);
 
        seq_printf(seq,
-                  "%-4d %-15s " NIP6_SEQFMT " %5d %08X %ld\n", 
+                  "%-4d %-15s " NIP6_SEQFMT " %5d %08X %ld\n",
                   state->dev->ifindex, state->dev->name,
                   NIP6(im->mca_addr),
                   im->mca_users, im->mca_flags,
@@ -2472,7 +2474,7 @@ static inline struct ip6_sf_list *igmp6_mcf_get_first(struct seq_file *seq)
        struct igmp6_mcf_iter_state *state = igmp6_mcf_seq_private(seq);
 
        for (state->dev = dev_base, state->idev = NULL, state->im = NULL;
-            state->dev; 
+            state->dev;
             state->dev = state->dev->next) {
                struct inet6_dev *idev;
                idev = in6_dev_get(state->dev);
@@ -2577,7 +2579,7 @@ static int igmp6_mcf_seq_show(struct seq_file *seq, void *v)
        struct igmp6_mcf_iter_state *state = igmp6_mcf_seq_private(seq);
 
        if (v == SEQ_START_TOKEN) {
-               seq_printf(seq, 
+               seq_printf(seq,
                           "%3s %6s "
                           "%32s %32s %6s %6s\n", "Idx",
                           "Device", "Multicast Address",
@@ -2606,7 +2608,7 @@ static int igmp6_mcf_seq_open(struct inode *inode, struct file *file)
        struct seq_file *seq;
        int rc = -ENOMEM;
        struct igmp6_mcf_iter_state *s = kzalloc(sizeof(*s), GFP_KERNEL);
-       
+
        if (!s)
                goto out;
 
index be7dd7db65d7684424083b66256703f12d3fb182..0afcabdd8ed6c9a52d434cce18ca96495dcc591c 100644 (file)
@@ -89,7 +89,6 @@ static int mip6_mh_len(int type)
 int mip6_mh_filter(struct sock *sk, struct sk_buff *skb)
 {
        struct ip6_mh *mh;
-       int mhlen;
 
        if (!pskb_may_pull(skb, (skb->h.raw - skb->data) + 8) ||
            !pskb_may_pull(skb, (skb->h.raw - skb->data) + ((skb->h.raw[1] + 1) << 3)))
@@ -103,31 +102,6 @@ int mip6_mh_filter(struct sock *sk, struct sk_buff *skb)
                mip6_param_prob(skb, 0, (&mh->ip6mh_hdrlen) - skb->nh.raw);
                return -1;
        }
-       mhlen = (mh->ip6mh_hdrlen + 1) << 3;
-
-       if (skb->ip_summed == CHECKSUM_COMPLETE) {
-               skb->ip_summed = CHECKSUM_UNNECESSARY;
-               if (csum_ipv6_magic(&skb->nh.ipv6h->saddr,
-                                   &skb->nh.ipv6h->daddr,
-                                   mhlen, IPPROTO_MH,
-                                   skb->csum)) {
-                       LIMIT_NETDEBUG(KERN_DEBUG "mip6: MH hw checksum failed\n");
-                       skb->ip_summed = CHECKSUM_NONE;
-               }
-       }
-       if (skb->ip_summed == CHECKSUM_NONE) {
-               if (csum_ipv6_magic(&skb->nh.ipv6h->saddr,
-                                   &skb->nh.ipv6h->daddr,
-                                   mhlen, IPPROTO_MH,
-                                   skb_checksum(skb, 0, mhlen, 0))) {
-                       LIMIT_NETDEBUG(KERN_DEBUG "mip6: MH checksum failed "
-                                      "[" NIP6_FMT " > " NIP6_FMT "]\n",
-                                      NIP6(skb->nh.ipv6h->saddr),
-                                      NIP6(skb->nh.ipv6h->daddr));
-                       return -1;
-               }
-               skb->ip_summed = CHECKSUM_UNNECESSARY;
-       }
 
        if (mh->ip6mh_proto != IPPROTO_NONE) {
                LIMIT_NETDEBUG(KERN_DEBUG "mip6: MH invalid payload proto = %d\n",
@@ -359,7 +333,7 @@ static struct xfrm_type mip6_destopt_type =
        .destructor     = mip6_destopt_destroy,
        .input          = mip6_destopt_input,
        .output         = mip6_destopt_output,
-       .reject         = mip6_destopt_reject,
+       .reject         = mip6_destopt_reject,
        .hdr_offset     = mip6_destopt_offset,
        .local_addr     = mip6_xfrm_addr,
 };
index 39bb658f3c447782ddd411102477cddaee9538be..121f31c283f8f823a0a26e747124839f542449ff 100644 (file)
@@ -1,9 +1,9 @@
 /*
  *     Neighbour Discovery for IPv6
- *     Linux INET6 implementation 
+ *     Linux INET6 implementation
  *
  *     Authors:
- *     Pedro Roque             <roque@di.fc.ul.pt>     
+ *     Pedro Roque             <roque@di.fc.ul.pt>
  *     Mike Shaver             <shaver@ingenia.com>
  *
  *     This program is free software; you can redistribute it and/or
@@ -427,25 +427,25 @@ static inline void ndisc_flow_init(struct flowi *fl, u8 type,
 
 static void ndisc_send_na(struct net_device *dev, struct neighbour *neigh,
                   struct in6_addr *daddr, struct in6_addr *solicited_addr,
-                  int router, int solicited, int override, int inc_opt) 
+                  int router, int solicited, int override, int inc_opt)
 {
        struct in6_addr tmpaddr;
        struct inet6_ifaddr *ifp;
        struct inet6_dev *idev;
        struct flowi fl;
        struct dst_entry* dst;
-        struct sock *sk = ndisc_socket->sk;
+       struct sock *sk = ndisc_socket->sk;
        struct in6_addr *src_addr;
-        struct nd_msg *msg;
-        int len;
-        struct sk_buff *skb;
+       struct nd_msg *msg;
+       int len;
+       struct sk_buff *skb;
        int err;
 
        len = sizeof(struct icmp6hdr) + sizeof(struct in6_addr);
 
        /* for anycast or proxy, solicited_addr != src_addr */
        ifp = ipv6_get_ifaddr(solicited_addr, dev, 1);
-       if (ifp) {
+       if (ifp) {
                src_addr = solicited_addr;
                in6_ifa_put(ifp);
        } else {
@@ -479,7 +479,7 @@ static void ndisc_send_na(struct net_device *dev, struct neighbour *neigh,
 
        if (skb == NULL) {
                ND_PRINTK0(KERN_ERR
-                          "ICMPv6 NA: %s() failed to allocate an skb.\n", 
+                          "ICMPv6 NA: %s() failed to allocate an skb.\n",
                           __FUNCTION__);
                dst_release(dst);
                return;
@@ -491,16 +491,16 @@ static void ndisc_send_na(struct net_device *dev, struct neighbour *neigh,
        msg = (struct nd_msg *)skb_put(skb, len);
        skb->h.raw = (unsigned char*)msg;
 
-        msg->icmph.icmp6_type = NDISC_NEIGHBOUR_ADVERTISEMENT;
-        msg->icmph.icmp6_code = 0;
-        msg->icmph.icmp6_cksum = 0;
+       msg->icmph.icmp6_type = NDISC_NEIGHBOUR_ADVERTISEMENT;
+       msg->icmph.icmp6_code = 0;
+       msg->icmph.icmp6_cksum = 0;
 
-        msg->icmph.icmp6_unused = 0;
-        msg->icmph.icmp6_router    = router;
-        msg->icmph.icmp6_solicited = solicited;
-        msg->icmph.icmp6_override  = override;
+       msg->icmph.icmp6_unused = 0;
+       msg->icmph.icmp6_router    = router;
+       msg->icmph.icmp6_solicited = solicited;
+       msg->icmph.icmp6_override  = override;
 
-        /* Set the target address. */
+       /* Set the target address. */
        ipv6_addr_copy(&msg->target, solicited_addr);
 
        if (inc_opt)
@@ -508,9 +508,9 @@ static void ndisc_send_na(struct net_device *dev, struct neighbour *neigh,
                                       dev->addr_len, dev->type);
 
        /* checksum */
-       msg->icmph.icmp6_cksum = csum_ipv6_magic(src_addr, daddr, len, 
+       msg->icmph.icmp6_cksum = csum_ipv6_magic(src_addr, daddr, len,
                                                 IPPROTO_ICMPV6,
-                                                csum_partial((__u8 *) msg, 
+                                                csum_partial((__u8 *) msg,
                                                              len, 0));
 
        skb->dst = dst;
@@ -524,20 +524,20 @@ static void ndisc_send_na(struct net_device *dev, struct neighbour *neigh,
 
        if (likely(idev != NULL))
                in6_dev_put(idev);
-}        
+}
 
 void ndisc_send_ns(struct net_device *dev, struct neighbour *neigh,
                   struct in6_addr *solicit,
-                  struct in6_addr *daddr, struct in6_addr *saddr) 
+                  struct in6_addr *daddr, struct in6_addr *saddr)
 {
        struct flowi fl;
        struct dst_entry* dst;
        struct inet6_dev *idev;
-        struct sock *sk = ndisc_socket->sk;
-        struct sk_buff *skb;
-        struct nd_msg *msg;
+       struct sock *sk = ndisc_socket->sk;
+       struct sk_buff *skb;
+       struct nd_msg *msg;
        struct in6_addr addr_buf;
-        int len;
+       int len;
        int err;
        int send_llinfo;
 
@@ -569,7 +569,7 @@ void ndisc_send_ns(struct net_device *dev, struct neighbour *neigh,
                                  1, &err);
        if (skb == NULL) {
                ND_PRINTK0(KERN_ERR
-                          "ICMPv6 NA: %s() failed to allocate an skb.\n", 
+                          "ICMPv6 NA: %s() failed to allocate an skb.\n",
                           __FUNCTION__);
                dst_release(dst);
                return;
@@ -594,9 +594,9 @@ void ndisc_send_ns(struct net_device *dev, struct neighbour *neigh,
 
        /* checksum */
        msg->icmph.icmp6_cksum = csum_ipv6_magic(&skb->nh.ipv6h->saddr,
-                                                daddr, len, 
+                                                daddr, len,
                                                 IPPROTO_ICMPV6,
-                                                csum_partial((__u8 *) msg, 
+                                                csum_partial((__u8 *) msg,
                                                              len, 0));
        /* send it! */
        skb->dst = dst;
@@ -619,10 +619,10 @@ void ndisc_send_rs(struct net_device *dev, struct in6_addr *saddr,
        struct dst_entry* dst;
        struct inet6_dev *idev;
        struct sock *sk = ndisc_socket->sk;
-        struct sk_buff *skb;
-        struct icmp6hdr *hdr;
+       struct sk_buff *skb;
+       struct icmp6hdr *hdr;
        __u8 * opt;
-        int len;
+       int len;
        int err;
 
        ndisc_flow_init(&fl, NDISC_ROUTER_SOLICITATION, saddr, daddr,
@@ -640,13 +640,13 @@ void ndisc_send_rs(struct net_device *dev, struct in6_addr *saddr,
        if (dev->addr_len)
                len += ndisc_opt_addr_space(dev);
 
-        skb = sock_alloc_send_skb(sk,
+       skb = sock_alloc_send_skb(sk,
                                  (MAX_HEADER + sizeof(struct ipv6hdr) +
                                   len + LL_RESERVED_SPACE(dev)),
                                  1, &err);
        if (skb == NULL) {
                ND_PRINTK0(KERN_ERR
-                          "ICMPv6 RS: %s() failed to allocate an skb.\n", 
+                          "ICMPv6 RS: %s() failed to allocate an skb.\n",
                           __FUNCTION__);
                dst_release(dst);
                return;
@@ -655,12 +655,12 @@ void ndisc_send_rs(struct net_device *dev, struct in6_addr *saddr,
        skb_reserve(skb, LL_RESERVED_SPACE(dev));
        ip6_nd_hdr(sk, skb, dev, saddr, daddr, IPPROTO_ICMPV6, len);
 
-        hdr = (struct icmp6hdr *)skb_put(skb, len);
-        skb->h.raw = (unsigned char*)hdr;
-        hdr->icmp6_type = NDISC_ROUTER_SOLICITATION;
-        hdr->icmp6_code = 0;
-        hdr->icmp6_cksum = 0;
-        hdr->icmp6_unused = 0;
+       hdr = (struct icmp6hdr *)skb_put(skb, len);
+       skb->h.raw = (unsigned char*)hdr;
+       hdr->icmp6_type = NDISC_ROUTER_SOLICITATION;
+       hdr->icmp6_code = 0;
+       hdr->icmp6_cksum = 0;
+       hdr->icmp6_unused = 0;
 
        opt = (u8*) (hdr + 1);
 
@@ -686,7 +686,7 @@ void ndisc_send_rs(struct net_device *dev, struct in6_addr *saddr,
        if (likely(idev != NULL))
                in6_dev_put(idev);
 }
-                  
+
 
 static void ndisc_error_report(struct neighbour *neigh, struct sk_buff *skb)
 {
@@ -748,7 +748,7 @@ static void ndisc_recv_ns(struct sk_buff *skb)
        int is_router;
 
        if (ipv6_addr_is_multicast(&msg->target)) {
-               ND_PRINTK2(KERN_WARNING 
+               ND_PRINTK2(KERN_WARNING
                           "ICMPv6 NS: multicast target address");
                return;
        }
@@ -768,7 +768,7 @@ static void ndisc_recv_ns(struct sk_buff *skb)
        }
 
        if (!ndisc_parse_options(msg->opt, ndoptlen, &ndopts)) {
-               ND_PRINTK2(KERN_WARNING 
+               ND_PRINTK2(KERN_WARNING
                           "ICMPv6 NS: invalid ND options\n");
                return;
        }
@@ -782,12 +782,12 @@ static void ndisc_recv_ns(struct sk_buff *skb)
                }
 
                /* RFC2461 7.1.1:
-                *      If the IP source address is the unspecified address, 
-                *      there MUST NOT be source link-layer address option 
+                *      If the IP source address is the unspecified address,
+                *      there MUST NOT be source link-layer address option
                 *      in the message.
                 */
                if (dad) {
-                       ND_PRINTK2(KERN_WARNING 
+                       ND_PRINTK2(KERN_WARNING
                                   "ICMPv6 NS: bad DAD packet (link-layer address option)\n");
                        return;
                }
@@ -816,7 +816,7 @@ static void ndisc_recv_ns(struct sk_buff *skb)
                                        goto out;
                                }
                        }
-                       addrconf_dad_failure(ifp); 
+                       addrconf_dad_failure(ifp);
                        return;
                }
 
@@ -829,7 +829,7 @@ static void ndisc_recv_ns(struct sk_buff *skb)
                }
 
                if (ipv6_chk_acast_addr(dev, &msg->target) ||
-                   (idev->cnf.forwarding && 
+                   (idev->cnf.forwarding &&
                     (ipv6_devconf.proxy_ndp || idev->cnf.proxy_ndp) &&
                     (pneigh = pneigh_lookup(&nd_tbl,
                                             &msg->target, dev, 0)) != NULL)) {
@@ -839,8 +839,8 @@ static void ndisc_recv_ns(struct sk_buff *skb)
                            idev->nd_parms->proxy_delay != 0) {
                                /*
                                 * for anycast or proxy,
-                                * sender should delay its response 
-                                * by a random time between 0 and 
+                                * sender should delay its response
+                                * by a random time between 0 and
                                 * MAX_ANYCAST_DELAY_TIME seconds.
                                 * (RFC2461) -- yoshfuji
                                 */
@@ -869,14 +869,14 @@ static void ndisc_recv_ns(struct sk_buff *skb)
        else
                NEIGH_CACHE_STAT_INC(&nd_tbl, rcv_probes_ucast);
 
-       /* 
+       /*
         *      update / create cache entry
         *      for the source address
         */
        neigh = __neigh_lookup(&nd_tbl, saddr, dev,
                               !inc || lladdr || !dev->addr_len);
        if (neigh)
-               neigh_update(neigh, lladdr, NUD_STALE, 
+               neigh_update(neigh, lladdr, NUD_STALE,
                             NEIGH_UPDATE_F_WEAK_OVERRIDE|
                             NEIGH_UPDATE_F_OVERRIDE);
        if (neigh || !dev->hard_header) {
@@ -926,7 +926,7 @@ static void ndisc_recv_na(struct sk_buff *skb)
                           "ICMPv6 NA: solicited NA is multicasted.\n");
                return;
        }
-               
+
        if (!ndisc_parse_options(msg->opt, ndoptlen, &ndopts)) {
                ND_PRINTK2(KERN_WARNING
                           "ICMPv6 NS: invalid ND option\n");
@@ -1057,7 +1057,7 @@ out:
 
 static void ndisc_router_discovery(struct sk_buff *skb)
 {
-        struct ra_msg *ra_msg = (struct ra_msg *) skb->h.raw;
+       struct ra_msg *ra_msg = (struct ra_msg *) skb->h.raw;
        struct neighbour *neigh = NULL;
        struct inet6_dev *in6_dev;
        struct rt6_info *rt = NULL;
@@ -1076,7 +1076,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
                return;
        }
        if (optlen < 0) {
-               ND_PRINTK2(KERN_WARNING 
+               ND_PRINTK2(KERN_WARNING
                           "ICMPv6 RA: packet too short\n");
                return;
        }
@@ -1286,7 +1286,7 @@ skip_defrtr:
                        rt6_mtu_change(skb->dev, mtu);
                }
        }
-                       
+
        if (ndopts.nd_opts_tgt_lladdr || ndopts.nd_opts_rh) {
                ND_PRINTK2(KERN_WARNING
                           "ICMPv6 RA: invalid RA options");
@@ -1339,7 +1339,7 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)
        if (ipv6_addr_equal(dest, target)) {
                on_link = 1;
        } else if (!(ipv6_addr_type(target) & IPV6_ADDR_LINKLOCAL)) {
-               ND_PRINTK2(KERN_WARNING 
+               ND_PRINTK2(KERN_WARNING
                           "ICMPv6 Redirect: target address is not link-local.\n");
                return;
        }
@@ -1352,11 +1352,11 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)
                return;
        }
 
-       /* RFC2461 8.1: 
+       /* RFC2461 8.1:
         *      The IP source address of the Redirect MUST be the same as the current
         *      first-hop router for the specified ICMP Destination Address.
         */
-               
+
        if (!ndisc_parse_options((u8*)(dest + 1), optlen, &ndopts)) {
                ND_PRINTK2(KERN_WARNING
                           "ICMPv6 Redirect: invalid ND options\n");
@@ -1410,8 +1410,8 @@ void ndisc_send_redirect(struct sk_buff *skb, struct neighbour *neigh,
                ND_PRINTK2(KERN_WARNING
                           "ICMPv6 Redirect: no link-local address on %s\n",
                           dev->name);
-               return;
-       }
+               return;
+       }
 
        if (!ipv6_addr_equal(&skb->nh.ipv6h->daddr, target) &&
            !(ipv6_addr_type(target) & IPV6_ADDR_LINKLOCAL)) {
@@ -1507,7 +1507,7 @@ void ndisc_send_redirect(struct sk_buff *skb, struct neighbour *neigh,
         *      build redirect option and copy skb over to the new packet.
         */
 
-       memset(opt, 0, 8);      
+       memset(opt, 0, 8);
        *(opt++) = ND_OPT_REDIRECT_HDR;
        *(opt++) = (rd_len >> 3);
        opt += 6;
@@ -1556,7 +1556,7 @@ int ndisc_rcv(struct sk_buff *skb)
        }
 
        if (msg->icmph.icmp6_code != 0) {
-               ND_PRINTK2(KERN_WARNING 
+               ND_PRINTK2(KERN_WARNING
                           "ICMPv6 NDISC: invalid ICMPv6 code: %d\n",
                           msg->icmph.icmp6_code);
                return 0;
@@ -1717,12 +1717,12 @@ int __init ndisc_init(struct net_proto_family *ops)
 {
        struct ipv6_pinfo *np;
        struct sock *sk;
-        int err;
+       int err;
 
        err = sock_create_kern(PF_INET6, SOCK_RAW, IPPROTO_ICMPV6, &ndisc_socket);
        if (err < 0) {
                ND_PRINTK0(KERN_ERR
-                          "ICMPv6 NDISC: Failed to initialize the control socket (err %d).\n", 
+                          "ICMPv6 NDISC: Failed to initialize the control socket (err %d).\n",
                           err);
                ndisc_socket = NULL; /* For safety. */
                return err;
@@ -1736,14 +1736,14 @@ int __init ndisc_init(struct net_proto_family *ops)
        np->mc_loop = 0;
        sk->sk_prot->unhash(sk);
 
-        /*
-         * Initialize the neighbour table
-         */
-       
+       /*
+        * Initialize the neighbour table
+        */
+
        neigh_table_init(&nd_tbl);
 
 #ifdef CONFIG_SYSCTL
-       neigh_sysctl_register(NULL, &nd_tbl.parms, NET_IPV6, NET_IPV6_NEIGH, 
+       neigh_sysctl_register(NULL, &nd_tbl.parms, NET_IPV6, NET_IPV6_NEIGH,
                              "ipv6",
                              &ndisc_ifinfo_sysctl_change,
                              &ndisc_ifinfo_sysctl_strategy);
index f6294e5bcb3175e84bbdbe6c28fb05017fc10413..0b2d265e7da746ef6383ba5b8fd2ee5cb008da64 100644 (file)
@@ -91,7 +91,7 @@ __sum16 nf_ip6_checksum(struct sk_buff *skb, unsigned int hook,
                if (hook != NF_IP6_PRE_ROUTING && hook != NF_IP6_LOCAL_IN)
                        break;
                if (!csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr,
-                                    skb->len - dataoff, protocol,
+                                    skb->len - dataoff, protocol,
                                     csum_sub(skb->csum,
                                              skb_checksum(skb, 0,
                                                           dataoff, 0)))) {
@@ -106,7 +106,7 @@ __sum16 nf_ip6_checksum(struct sk_buff *skb, unsigned int hook,
                                             protocol,
                                             csum_sub(0,
                                                      skb_checksum(skb, 0,
-                                                                  dataoff, 0))));
+                                                                  dataoff, 0))));
                csum = __skb_checksum_complete(skb);
        }
        return csum;
index adcd6131df2a0a05f94f8e59e9fc23c4906839c1..cd549aea84f068aebe9edfb75e5b99df6eb9da59 100644 (file)
@@ -114,6 +114,14 @@ config IP6_NF_MATCH_AH
 
          To compile it as a module, choose M here.  If unsure, say N.
 
+config IP6_NF_MATCH_MH
+       tristate "MH match support"
+       depends on IP6_NF_IPTABLES
+       help
+         This module allows one to match MH packets.
+
+         To compile it as a module, choose M here.  If unsure, say N.
+
 config IP6_NF_MATCH_EUI64
        tristate "EUI64 address check"
        depends on IP6_NF_IPTABLES
index ac1dfebde1755451e7b540168e5eb7512eff308e..4513eab773973e3db0722394b550b7a961125d24 100644 (file)
@@ -19,6 +19,7 @@ obj-$(CONFIG_IP6_NF_TARGET_LOG) += ip6t_LOG.o
 obj-$(CONFIG_IP6_NF_RAW) += ip6table_raw.o
 obj-$(CONFIG_IP6_NF_MATCH_HL) += ip6t_hl.o
 obj-$(CONFIG_IP6_NF_TARGET_REJECT) += ip6t_REJECT.o
+obj-$(CONFIG_IP6_NF_MATCH_MH) += ip6t_mh.o
 
 # objects for l3 independent conntrack
 nf_conntrack_ipv6-objs  :=  nf_conntrack_l3proto_ipv6.o nf_conntrack_proto_icmpv6.o nf_conntrack_reasm.o
index d4d9f182441a95f0b81d6abd56bdee8e57688e19..58847d3b61e503d036481309eba777081eb18c55 100644 (file)
@@ -95,7 +95,7 @@ __ipq_find_entry(ipq_cmpfn cmpfn, unsigned long data)
 
        list_for_each_prev(p, &queue_list) {
                struct ipq_queue_entry *entry = (struct ipq_queue_entry *)p;
-               
+
                if (!cmpfn || cmpfn(entry, data))
                        return entry;
        }
@@ -127,7 +127,7 @@ static inline void
 __ipq_flush(int verdict)
 {
        struct ipq_queue_entry *entry;
-       
+
        while ((entry = __ipq_find_dequeue_entry(NULL, 0)))
                ipq_issue_verdict(entry, verdict);
 }
@@ -136,21 +136,21 @@ static inline int
 __ipq_set_mode(unsigned char mode, unsigned int range)
 {
        int status = 0;
-       
+
        switch(mode) {
        case IPQ_COPY_NONE:
        case IPQ_COPY_META:
                copy_mode = mode;
                copy_range = 0;
                break;
-               
+
        case IPQ_COPY_PACKET:
                copy_mode = mode;
                copy_range = range;
                if (copy_range > 0xFFFF)
                        copy_range = 0xFFFF;
                break;
-               
+
        default:
                status = -EINVAL;
 
@@ -171,7 +171,7 @@ static struct ipq_queue_entry *
 ipq_find_dequeue_entry(ipq_cmpfn cmpfn, unsigned long data)
 {
        struct ipq_queue_entry *entry;
-       
+
        write_lock_bh(&queue_lock);
        entry = __ipq_find_dequeue_entry(cmpfn, data);
        write_unlock_bh(&queue_lock);
@@ -197,14 +197,14 @@ ipq_build_packet_message(struct ipq_queue_entry *entry, int *errp)
        struct nlmsghdr *nlh;
 
        read_lock_bh(&queue_lock);
-       
+
        switch (copy_mode) {
        case IPQ_COPY_META:
        case IPQ_COPY_NONE:
                size = NLMSG_SPACE(sizeof(*pmsg));
                data_len = 0;
                break;
-       
+
        case IPQ_COPY_PACKET:
                if ((entry->skb->ip_summed == CHECKSUM_PARTIAL ||
                     entry->skb->ip_summed == CHECKSUM_COMPLETE) &&
@@ -216,10 +216,10 @@ ipq_build_packet_message(struct ipq_queue_entry *entry, int *errp)
                        data_len = entry->skb->len;
                else
                        data_len = copy_range;
-               
+
                size = NLMSG_SPACE(sizeof(*pmsg) + data_len);
                break;
-       
+
        default:
                *errp = -EINVAL;
                read_unlock_bh(&queue_lock);
@@ -231,7 +231,7 @@ ipq_build_packet_message(struct ipq_queue_entry *entry, int *errp)
        skb = alloc_skb(size, GFP_ATOMIC);
        if (!skb)
                goto nlmsg_failure;
-               
+
        old_tail= skb->tail;
        nlh = NLMSG_PUT(skb, 0, 0, IPQM_PACKET, size - sizeof(*nlh));
        pmsg = NLMSG_DATA(nlh);
@@ -244,29 +244,29 @@ ipq_build_packet_message(struct ipq_queue_entry *entry, int *errp)
        pmsg->mark            = entry->skb->mark;
        pmsg->hook            = entry->info->hook;
        pmsg->hw_protocol     = entry->skb->protocol;
-       
+
        if (entry->info->indev)
                strcpy(pmsg->indev_name, entry->info->indev->name);
        else
                pmsg->indev_name[0] = '\0';
-       
+
        if (entry->info->outdev)
                strcpy(pmsg->outdev_name, entry->info->outdev->name);
        else
                pmsg->outdev_name[0] = '\0';
-       
+
        if (entry->info->indev && entry->skb->dev) {
                pmsg->hw_type = entry->skb->dev->type;
                if (entry->skb->dev->hard_header_parse)
                        pmsg->hw_addrlen =
                                entry->skb->dev->hard_header_parse(entry->skb,
-                                                                  pmsg->hw_addr);
+                                                                  pmsg->hw_addr);
        }
-       
+
        if (data_len)
                if (skb_copy_bits(entry->skb, 0, pmsg->payload, data_len))
                        BUG();
-               
+
        nlh->nlmsg_len = skb->tail - old_tail;
        return skb;
 
@@ -279,7 +279,7 @@ nlmsg_failure:
 }
 
 static int
-ipq_enqueue_packet(struct sk_buff *skb, struct nf_info *info, 
+ipq_enqueue_packet(struct sk_buff *skb, struct nf_info *info,
                   unsigned int queuenum, void *data)
 {
        int status = -EINVAL;
@@ -301,37 +301,37 @@ ipq_enqueue_packet(struct sk_buff *skb, struct nf_info *info,
        nskb = ipq_build_packet_message(entry, &status);
        if (nskb == NULL)
                goto err_out_free;
-               
+
        write_lock_bh(&queue_lock);
-       
+
        if (!peer_pid)
-               goto err_out_free_nskb; 
+               goto err_out_free_nskb;
 
        if (queue_total >= queue_maxlen) {
-                queue_dropped++;
+               queue_dropped++;
                status = -ENOSPC;
                if (net_ratelimit())
-                       printk (KERN_WARNING "ip6_queue: fill at %d entries, "
+                       printk (KERN_WARNING "ip6_queue: fill at %d entries, "
                                "dropping packet(s).  Dropped: %d\n", queue_total,
                                queue_dropped);
                goto err_out_free_nskb;
        }
 
-       /* netlink_unicast will either free the nskb or attach it to a socket */ 
+       /* netlink_unicast will either free the nskb or attach it to a socket */
        status = netlink_unicast(ipqnl, nskb, peer_pid, MSG_DONTWAIT);
        if (status < 0) {
-               queue_user_dropped++;
+               queue_user_dropped++;
                goto err_out_unlock;
        }
-       
+
        __ipq_enqueue_entry(entry);
 
        write_unlock_bh(&queue_lock);
        return status;
-       
+
 err_out_free_nskb:
-       kfree_skb(nskb); 
-       
+       kfree_skb(nskb);
+
 err_out_unlock:
        write_unlock_bh(&queue_lock);
 
@@ -357,11 +357,11 @@ ipq_mangle_ipv6(ipq_verdict_msg_t *v, struct ipq_queue_entry *e)
                        return -EINVAL;
                if (diff > skb_tailroom(e->skb)) {
                        struct sk_buff *newskb;
-                       
+
                        newskb = skb_copy_expand(e->skb,
-                                                skb_headroom(e->skb),
-                                                diff,
-                                                GFP_ATOMIC);
+                                                skb_headroom(e->skb),
+                                                diff,
+                                                GFP_ATOMIC);
                        if (newskb == NULL) {
                                printk(KERN_WARNING "ip6_queue: OOM "
                                      "in mangle, dropping packet\n");
@@ -401,11 +401,11 @@ ipq_set_verdict(struct ipq_verdict_msg *vmsg, unsigned int len)
                return -ENOENT;
        else {
                int verdict = vmsg->value;
-               
+
                if (vmsg->data_len && vmsg->data_len == len)
                        if (ipq_mangle_ipv6(vmsg, entry) < 0)
                                verdict = NF_DROP;
-               
+
                ipq_issue_verdict(entry, verdict);
                return 0;
        }
@@ -424,7 +424,7 @@ ipq_set_mode(unsigned char mode, unsigned int range)
 
 static int
 ipq_receive_peer(struct ipq_peer_msg *pmsg,
-                 unsigned char type, unsigned int len)
+                unsigned char type, unsigned int len)
 {
        int status = 0;
 
@@ -434,15 +434,15 @@ ipq_receive_peer(struct ipq_peer_msg *pmsg,
        switch (type) {
        case IPQM_MODE:
                status = ipq_set_mode(pmsg->msg.mode.value,
-                                     pmsg->msg.mode.range);
+                                     pmsg->msg.mode.range);
                break;
-               
+
        case IPQM_VERDICT:
                if (pmsg->msg.verdict.value > NF_MAX_VERDICT)
                        status = -EINVAL;
                else
                        status = ipq_set_verdict(&pmsg->msg.verdict,
-                                                len - sizeof(*pmsg));
+                                                len - sizeof(*pmsg));
                        break;
        default:
                status = -EINVAL;
@@ -456,7 +456,7 @@ dev_cmp(struct ipq_queue_entry *entry, unsigned long ifindex)
        if (entry->info->indev)
                if (entry->info->indev->ifindex == ifindex)
                        return 1;
-                       
+
        if (entry->info->outdev)
                if (entry->info->outdev->ifindex == ifindex)
                        return 1;
@@ -468,7 +468,7 @@ static void
 ipq_dev_drop(int ifindex)
 {
        struct ipq_queue_entry *entry;
-       
+
        while ((entry = ipq_find_dequeue_entry(dev_cmp, ifindex)) != NULL)
                ipq_issue_verdict(entry, NF_DROP);
 }
@@ -492,25 +492,25 @@ ipq_rcv_skb(struct sk_buff *skb)
 
        pid = nlh->nlmsg_pid;
        flags = nlh->nlmsg_flags;
-       
+
        if(pid <= 0 || !(flags & NLM_F_REQUEST) || flags & NLM_F_MULTI)
                RCV_SKB_FAIL(-EINVAL);
-               
+
        if (flags & MSG_TRUNC)
                RCV_SKB_FAIL(-ECOMM);
-               
+
        type = nlh->nlmsg_type;
        if (type < NLMSG_NOOP || type >= IPQM_MAX)
                RCV_SKB_FAIL(-EINVAL);
-               
+
        if (type <= IPQM_BASE)
                return;
-       
+
        if (security_netlink_recv(skb, CAP_NET_ADMIN))
-               RCV_SKB_FAIL(-EPERM);   
+               RCV_SKB_FAIL(-EPERM);
 
        write_lock_bh(&queue_lock);
-       
+
        if (peer_pid) {
                if (peer_pid != pid) {
                        write_unlock_bh(&queue_lock);
@@ -520,17 +520,17 @@ ipq_rcv_skb(struct sk_buff *skb)
                net_enable_timestamp();
                peer_pid = pid;
        }
-               
+
        write_unlock_bh(&queue_lock);
-       
+
        status = ipq_receive_peer(NLMSG_DATA(nlh), type,
-                                 nlmsglen - NLMSG_LENGTH(0));
+                                 nlmsglen - NLMSG_LENGTH(0));
        if (status < 0)
                RCV_SKB_FAIL(status);
-               
+
        if (flags & NLM_F_ACK)
                netlink_ack(skb, nlh, 0);
-        return;
+       return;
 }
 
 static void
@@ -540,19 +540,19 @@ ipq_rcv_sk(struct sock *sk, int len)
        unsigned int qlen;
 
        mutex_lock(&ipqnl_mutex);
-                       
+
        for (qlen = skb_queue_len(&sk->sk_receive_queue); qlen; qlen--) {
                skb = skb_dequeue(&sk->sk_receive_queue);
                ipq_rcv_skb(skb);
                kfree_skb(skb);
        }
-               
+
        mutex_unlock(&ipqnl_mutex);
 }
 
 static int
 ipq_rcv_dev_event(struct notifier_block *this,
-                  unsigned long event, void *ptr)
+                 unsigned long event, void *ptr)
 {
        struct net_device *dev = ptr;
 
@@ -568,7 +568,7 @@ static struct notifier_block ipq_dev_notifier = {
 
 static int
 ipq_rcv_nl_event(struct notifier_block *this,
-                 unsigned long event, void *ptr)
+                unsigned long event, void *ptr)
 {
        struct netlink_notify *n = ptr;
 
@@ -597,7 +597,7 @@ static ctl_table ipq_table[] = {
                .mode           = 0644,
                .proc_handler   = proc_dointvec
        },
-       { .ctl_name = 0 }
+       { .ctl_name = 0 }
 };
 
 static ctl_table ipq_dir_table[] = {
@@ -627,25 +627,25 @@ ipq_get_info(char *buffer, char **start, off_t offset, int length)
        int len;
 
        read_lock_bh(&queue_lock);
-       
+
        len = sprintf(buffer,
-                     "Peer PID          : %d\n"
-                     "Copy mode         : %hu\n"
-                     "Copy range        : %u\n"
-                     "Queue length      : %u\n"
-                     "Queue max. length : %u\n"
+                     "Peer PID          : %d\n"
+                     "Copy mode         : %hu\n"
+                     "Copy range        : %u\n"
+                     "Queue length      : %u\n"
+                     "Queue max. length : %u\n"
                      "Queue dropped     : %u\n"
                      "Netfilter dropped : %u\n",
-                     peer_pid,
-                     copy_mode,
-                     copy_range,
-                     queue_total,
-                     queue_maxlen,
+                     peer_pid,
+                     copy_mode,
+                     copy_range,
+                     queue_total,
+                     queue_maxlen,
                      queue_dropped,
                      queue_user_dropped);
 
        read_unlock_bh(&queue_lock);
-       
+
        *start = buffer + offset;
        len -= offset;
        if (len > length)
@@ -665,10 +665,10 @@ static int __init ip6_queue_init(void)
 {
        int status = -ENOMEM;
        struct proc_dir_entry *proc;
-       
+
        netlink_register_notifier(&ipq_nl_notifier);
        ipqnl = netlink_kernel_create(NETLINK_IP6_FW, 0, ipq_rcv_sk,
-                                     THIS_MODULE);
+                                     THIS_MODULE);
        if (ipqnl == NULL) {
                printk(KERN_ERR "ip6_queue: failed to create netlink socket\n");
                goto cleanup_netlink_notifier;
@@ -681,10 +681,10 @@ static int __init ip6_queue_init(void)
                printk(KERN_ERR "ip6_queue: failed to create proc entry\n");
                goto cleanup_ipqnl;
        }
-       
+
        register_netdevice_notifier(&ipq_dev_notifier);
        ipq_sysctl_header = register_sysctl_table(ipq_root_table, 0);
-       
+
        status = nf_register_queue_handler(PF_INET6, &nfqh);
        if (status < 0) {
                printk(KERN_ERR "ip6_queue: failed to register queue handler\n");
@@ -696,12 +696,12 @@ cleanup_sysctl:
        unregister_sysctl_table(ipq_sysctl_header);
        unregister_netdevice_notifier(&ipq_dev_notifier);
        proc_net_remove(IPQ_PROC_FS_NAME);
-       
+
 cleanup_ipqnl:
        sock_release(ipqnl->sk_socket);
        mutex_lock(&ipqnl_mutex);
        mutex_unlock(&ipqnl_mutex);
-       
+
 cleanup_netlink_notifier:
        netlink_unregister_notifier(&ipq_nl_notifier);
        return status;
index 99502c5da4c45336cf2cd1b5ed2c71b3ea685744..7c512e13f9563b31f9f47579bb671d47e12ee5b2 100644 (file)
@@ -92,16 +92,16 @@ do {                                                                \
 #endif
 
 /* Check for an extension */
-int 
+int
 ip6t_ext_hdr(u8 nexthdr)
 {
-        return ( (nexthdr == IPPROTO_HOPOPTS)   ||
-                 (nexthdr == IPPROTO_ROUTING)   ||
-                 (nexthdr == IPPROTO_FRAGMENT)  ||
-                 (nexthdr == IPPROTO_ESP)       ||
-                 (nexthdr == IPPROTO_AH)        ||
-                 (nexthdr == IPPROTO_NONE)      ||
-                 (nexthdr == IPPROTO_DSTOPTS) );
+       return ( (nexthdr == IPPROTO_HOPOPTS)   ||
+                (nexthdr == IPPROTO_ROUTING)   ||
+                (nexthdr == IPPROTO_FRAGMENT)  ||
+                (nexthdr == IPPROTO_ESP)       ||
+                (nexthdr == IPPROTO_AH)        ||
+                (nexthdr == IPPROTO_NONE)      ||
+                (nexthdr == IPPROTO_DSTOPTS) );
 }
 
 /* Returns whether matches rule or not. */
@@ -120,9 +120,9 @@ ip6_packet_match(const struct sk_buff *skb,
 #define FWINV(bool,invflg) ((bool) ^ !!(ip6info->invflags & invflg))
 
        if (FWINV(ipv6_masked_addr_cmp(&ipv6->saddr, &ip6info->smsk,
-                                      &ip6info->src), IP6T_INV_SRCIP)
+                                      &ip6info->src), IP6T_INV_SRCIP)
            || FWINV(ipv6_masked_addr_cmp(&ipv6->daddr, &ip6info->dmsk,
-                                         &ip6info->dst), IP6T_INV_DSTIP)) {
+                                         &ip6info->dst), IP6T_INV_DSTIP)) {
                dprintf("Source or dest mismatch.\n");
 /*
                dprintf("SRC: %u. Mask: %u. Target: %u.%s\n", ip->saddr,
@@ -177,7 +177,7 @@ ip6_packet_match(const struct sk_buff *skb,
                *fragoff = _frag_off;
 
                dprintf("Packet protocol %hi ?= %s%hi.\n",
-                               protohdr, 
+                               protohdr,
                                ip6info->invflags & IP6T_INV_PROTO ? "!":"",
                                ip6info->proto);
 
@@ -197,7 +197,7 @@ ip6_packet_match(const struct sk_buff *skb,
 }
 
 /* should be ip6 safe */
-static inline int 
+static inline int
 ip6_checkentry(const struct ip6t_ip6 *ipv6)
 {
        if (ipv6->flags & ~IP6T_F_MASK) {
@@ -337,7 +337,7 @@ ip6t_do_table(struct sk_buff **pskb,
                                e = get_entry(table_base, v);
                        } else {
                                /* Targets which reenter must return
-                                   abs. verdicts */
+                                  abs. verdicts */
 #ifdef CONFIG_NETFILTER_DEBUG
                                ((struct ip6t_entry *)table_base)->comefrom
                                        = 0xeeeeeeec;
@@ -530,14 +530,14 @@ check_match(struct ip6t_entry_match *m,
            unsigned int hookmask,
            unsigned int *i)
 {
-       struct ip6t_match *match;
+       struct xt_match *match;
        int ret;
 
        match = try_then_request_module(xt_find_match(AF_INET6, m->u.user.name,
-                                       m->u.user.revision),
+                                       m->u.user.revision),
                                        "ip6t_%s", m->u.user.name);
        if (IS_ERR(match) || !match) {
-               duprintf("check_match: `%s' not found\n", m->u.user.name);
+               duprintf("check_match: `%s' not found\n", m->u.user.name);
                return match ? PTR_ERR(match) : -ENOENT;
        }
        m->u.kernel.match = match;
@@ -564,14 +564,14 @@ err:
        return ret;
 }
 
-static struct ip6t_target ip6t_standard_target;
+static struct xt_target ip6t_standard_target;
 
 static inline int
 check_entry(struct ip6t_entry *e, const char *name, unsigned int size,
            unsigned int *i)
 {
        struct ip6t_entry_target *t;
-       struct ip6t_target *target;
+       struct xt_target *target;
        int ret;
        unsigned int j;
 
@@ -661,7 +661,7 @@ check_entry_size_and_hooks(struct ip6t_entry *e,
        }
 
        /* FIXME: underflows must be unconditional, standard verdicts
-           < 0 (not IP6T_RETURN). --RR */
+          < 0 (not IP6T_RETURN). --RR */
 
        /* Clear counters and comefrom */
        e->counters = ((struct xt_counters) { 0, 0 });
@@ -1003,8 +1003,8 @@ do_replace(void __user *user, unsigned int len)
        /* Update module usage count based on number of rules */
        duprintf("do_replace: oldnum=%u, initnum=%u, newnum=%u\n",
                oldinfo->number, oldinfo->initial_entries, newinfo->number);
-       if ((oldinfo->number > oldinfo->initial_entries) || 
-           (newinfo->number <= oldinfo->initial_entries)) 
+       if ((oldinfo->number > oldinfo->initial_entries) ||
+           (newinfo->number <= oldinfo->initial_entries))
                module_put(t->me);
        if ((oldinfo->number > oldinfo->initial_entries) &&
            (newinfo->number <= oldinfo->initial_entries))
@@ -1348,13 +1348,13 @@ icmp6_checkentry(const char *tablename,
 }
 
 /* The built-in targets: standard (NULL) and error. */
-static struct ip6t_target ip6t_standard_target = {
+static struct xt_target ip6t_standard_target = {
        .name           = IP6T_STANDARD_TARGET,
        .targetsize     = sizeof(int),
        .family         = AF_INET6,
 };
 
-static struct ip6t_target ip6t_error_target = {
+static struct xt_target ip6t_error_target = {
        .name           = IP6T_ERROR_TARGET,
        .target         = ip6t_error,
        .targetsize     = IP6T_FUNCTION_MAXNAMELEN,
@@ -1371,7 +1371,7 @@ static struct nf_sockopt_ops ip6t_sockopts = {
        .get            = do_ip6t_get_ctl,
 };
 
-static struct ip6t_match icmp6_matchstruct = {
+static struct xt_match icmp6_matchstruct = {
        .name           = "icmp6",
        .match          = &icmp6_match,
        .matchsize      = sizeof(struct ip6t_icmp),
@@ -1492,9 +1492,9 @@ int ipv6_find_hdr(const struct sk_buff *skb, unsigned int *offset,
                        }
                        hdrlen = 8;
                } else if (nexthdr == NEXTHDR_AUTH)
-                       hdrlen = (hp->hdrlen + 2) << 2; 
+                       hdrlen = (hp->hdrlen + 2) << 2;
                else
-                       hdrlen = ipv6_optlen(hp); 
+                       hdrlen = ipv6_optlen(hp);
 
                nexthdr = hp->nexthdr;
                len -= hdrlen;
index 435750f664dd13038ec83c678865ab865f26dff3..ccbab66277e37d25918eea826c6a35059864a8f4 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
  * Hop Limit modification target for ip6tables
  * Maciej Soltysiak <solt@dns.toxicfilms.tv>
  * Based on HW's TTL module
@@ -9,15 +9,16 @@
 #include <linux/module.h>
 #include <linux/skbuff.h>
 #include <linux/ip.h>
+#include <linux/ipv6.h>
 
-#include <linux/netfilter_ipv6/ip6_tables.h>
+#include <linux/netfilter/x_tables.h>
 #include <linux/netfilter_ipv6/ip6t_HL.h>
 
 MODULE_AUTHOR("Maciej Soltysiak <solt@dns.toxicfilms.tv>");
-MODULE_DESCRIPTION("IP tables Hop Limit modification module");
+MODULE_DESCRIPTION("IP6 tables Hop Limit modification module");
 MODULE_LICENSE("GPL");
 
-static unsigned int ip6t_hl_target(struct sk_buff **pskb, 
+static unsigned int ip6t_hl_target(struct sk_buff **pskb,
                                   const struct net_device *in,
                                   const struct net_device *out,
                                   unsigned int hooknum,
@@ -52,10 +53,9 @@ static unsigned int ip6t_hl_target(struct sk_buff **pskb,
                        break;
        }
 
-       if (new_hl != ip6h->hop_limit)
-               ip6h->hop_limit = new_hl;
+       ip6h->hop_limit = new_hl;
 
-       return IP6T_CONTINUE;
+       return XT_CONTINUE;
 }
 
 static int ip6t_hl_checkentry(const char *tablename,
@@ -67,7 +67,7 @@ static int ip6t_hl_checkentry(const char *tablename,
        struct ip6t_HL_info *info = targinfo;
 
        if (info->mode > IP6T_HL_MAXMODE) {
-               printk(KERN_WARNING "ip6t_HL: invalid or unknown Mode %u\n", 
+               printk(KERN_WARNING "ip6t_HL: invalid or unknown Mode %u\n",
                        info->mode);
                return 0;
        }
@@ -79,23 +79,24 @@ static int ip6t_hl_checkentry(const char *tablename,
        return 1;
 }
 
-static struct ip6t_target ip6t_HL = { 
-       .name           = "HL", 
-       .target         = ip6t_hl_target, 
+static struct xt_target ip6t_HL = {
+       .name           = "HL",
+       .family         = AF_INET6,
+       .target         = ip6t_hl_target,
        .targetsize     = sizeof(struct ip6t_HL_info),
        .table          = "mangle",
-       .checkentry     = ip6t_hl_checkentry, 
+       .checkentry     = ip6t_hl_checkentry,
        .me             = THIS_MODULE
 };
 
 static int __init ip6t_hl_init(void)
 {
-       return ip6t_register_target(&ip6t_HL);
+       return xt_register_target(&ip6t_HL);
 }
 
 static void __exit ip6t_hl_fini(void)
 {
-       ip6t_unregister_target(&ip6t_HL);
+       xt_unregister_target(&ip6t_HL);
 }
 
 module_init(ip6t_hl_init);
index 33b1faa90d740a85e7f027780019b74b728486ef..dc9ec93057782a0ea1900da5bf19e0819aa06047 100644 (file)
@@ -21,6 +21,7 @@
 #include <net/tcp.h>
 #include <net/ipv6.h>
 #include <linux/netfilter.h>
+#include <linux/netfilter/x_tables.h>
 #include <linux/netfilter_ipv6/ip6_tables.h>
 
 MODULE_AUTHOR("Jan Rekorajski <baggins@pld.org.pl>");
@@ -144,7 +145,7 @@ static void dump_packet(const struct nf_loginfo *info,
                                                        &_ahdr);
                                if (ah == NULL) {
                                        /*
-                                        * Max length: 26 "INCOMPLETE [65535    
+                                        * Max length: 26 "INCOMPLETE [65535
                                         *  bytes] )"
                                         */
                                        printk("INCOMPLETE [%u bytes] )",
@@ -386,7 +387,7 @@ ip6t_log_packet(unsigned int pf,
                loginfo = &default_loginfo;
 
        spin_lock_bh(&log_lock);
-       printk("<%d>%sIN=%s OUT=%s ", loginfo->u.log.level, 
+       printk("<%d>%sIN=%s OUT=%s ", loginfo->u.log.level,
                prefix,
                in ? in->name : "",
                out ? out->name : "");
@@ -441,8 +442,8 @@ ip6t_log_target(struct sk_buff **pskb,
        li.u.log.logflags = loginfo->logflags;
 
        ip6t_log_packet(PF_INET6, hooknum, *pskb, in, out, &li,
-                       loginfo->prefix);
-       return IP6T_CONTINUE;
+                       loginfo->prefix);
+       return XT_CONTINUE;
 }
 
 
@@ -466,11 +467,12 @@ static int ip6t_log_checkentry(const char *tablename,
        return 1;
 }
 
-static struct ip6t_target ip6t_log_reg = {
+static struct xt_target ip6t_log_reg = {
        .name           = "LOG",
-       .target         = ip6t_log_target, 
+       .family         = AF_INET6,
+       .target         = ip6t_log_target,
        .targetsize     = sizeof(struct ip6t_log_info),
-       .checkentry     = ip6t_log_checkentry, 
+       .checkentry     = ip6t_log_checkentry,
        .me             = THIS_MODULE,
 };
 
@@ -482,8 +484,11 @@ static struct nf_logger ip6t_logger = {
 
 static int __init ip6t_log_init(void)
 {
-       if (ip6t_register_target(&ip6t_log_reg))
-               return -EINVAL;
+       int ret;
+
+       ret = xt_register_target(&ip6t_log_reg);
+       if (ret < 0)
+               return ret;
        if (nf_log_register(PF_INET6, &ip6t_logger) < 0) {
                printk(KERN_WARNING "ip6t_LOG: not logging via system console "
                       "since somebody else already registered for PF_INET6\n");
@@ -497,7 +502,7 @@ static int __init ip6t_log_init(void)
 static void __exit ip6t_log_fini(void)
 {
        nf_log_unregister_logger(&ip6t_logger);
-       ip6t_unregister_target(&ip6t_log_reg);
+       xt_unregister_target(&ip6t_log_reg);
 }
 
 module_init(ip6t_log_init);
index 311eae82feb3a62cf7b08254c88b85aa2ec30193..6abee94c929fc70b020702ad70659b4566900969 100644 (file)
@@ -26,6 +26,7 @@
 #include <net/ip6_fib.h>
 #include <net/ip6_route.h>
 #include <net/flow.h>
+#include <linux/netfilter/x_tables.h>
 #include <linux/netfilter_ipv6/ip6_tables.h>
 #include <linux/netfilter_ipv6/ip6t_REJECT.h>
 
@@ -188,23 +189,23 @@ static unsigned int reject6_target(struct sk_buff **pskb,
        /* WARNING: This code causes reentry within ip6tables.
           This means that the ip6tables jump stack is now crap.  We
           must return an absolute verdict. --RR */
-       switch (reject->with) {
-       case IP6T_ICMP6_NO_ROUTE:
-               send_unreach(*pskb, ICMPV6_NOROUTE, hooknum);
-               break;
-       case IP6T_ICMP6_ADM_PROHIBITED:
-               send_unreach(*pskb, ICMPV6_ADM_PROHIBITED, hooknum);
-               break;
-       case IP6T_ICMP6_NOT_NEIGHBOUR:
-               send_unreach(*pskb, ICMPV6_NOT_NEIGHBOUR, hooknum);
-               break;
-       case IP6T_ICMP6_ADDR_UNREACH:
-               send_unreach(*pskb, ICMPV6_ADDR_UNREACH, hooknum);
-               break;
-       case IP6T_ICMP6_PORT_UNREACH:
-               send_unreach(*pskb, ICMPV6_PORT_UNREACH, hooknum);
-               break;
-       case IP6T_ICMP6_ECHOREPLY:
+       switch (reject->with) {
+       case IP6T_ICMP6_NO_ROUTE:
+               send_unreach(*pskb, ICMPV6_NOROUTE, hooknum);
+               break;
+       case IP6T_ICMP6_ADM_PROHIBITED:
+               send_unreach(*pskb, ICMPV6_ADM_PROHIBITED, hooknum);
+               break;
+       case IP6T_ICMP6_NOT_NEIGHBOUR:
+               send_unreach(*pskb, ICMPV6_NOT_NEIGHBOUR, hooknum);
+               break;
+       case IP6T_ICMP6_ADDR_UNREACH:
+               send_unreach(*pskb, ICMPV6_ADDR_UNREACH, hooknum);
+               break;
+       case IP6T_ICMP6_PORT_UNREACH:
+               send_unreach(*pskb, ICMPV6_PORT_UNREACH, hooknum);
+               break;
+       case IP6T_ICMP6_ECHOREPLY:
                /* Do nothing */
                break;
        case IP6T_TCP_RESET:
@@ -225,7 +226,7 @@ static int check(const char *tablename,
                 void *targinfo,
                 unsigned int hook_mask)
 {
-       const struct ip6t_reject_info *rejinfo = targinfo;
+       const struct ip6t_reject_info *rejinfo = targinfo;
        const struct ip6t_entry *e = entry;
 
        if (rejinfo->with == IP6T_ICMP6_ECHOREPLY) {
@@ -234,7 +235,7 @@ static int check(const char *tablename,
        } else if (rejinfo->with == IP6T_TCP_RESET) {
                /* Must specify that it's a TCP packet */
                if (e->ipv6.proto != IPPROTO_TCP
-                   || (e->ipv6.invflags & IP6T_INV_PROTO)) {
+                   || (e->ipv6.invflags & XT_INV_PROTO)) {
                        DEBUGP("ip6t_REJECT: TCP_RESET illegal for non-tcp\n");
                        return 0;
                }
@@ -242,8 +243,9 @@ static int check(const char *tablename,
        return 1;
 }
 
-static struct ip6t_target ip6t_reject_reg = {
+static struct xt_target ip6t_reject_reg = {
        .name           = "REJECT",
+       .family         = AF_INET6,
        .target         = reject6_target,
        .targetsize     = sizeof(struct ip6t_reject_info),
        .table          = "filter",
@@ -255,12 +257,12 @@ static struct ip6t_target ip6t_reject_reg = {
 
 static int __init ip6t_reject_init(void)
 {
-       return ip6t_register_target(&ip6t_reject_reg);
+       return xt_register_target(&ip6t_reject_reg);
 }
 
 static void __exit ip6t_reject_fini(void)
 {
-       ip6t_unregister_target(&ip6t_reject_reg);
+       xt_unregister_target(&ip6t_reject_reg);
 }
 
 module_init(ip6t_reject_init);
index 46486645eb75251da249a5170e7adc0c11023759..d3c154371b41d30bbe85c72c170c2bc0969b0891 100644 (file)
@@ -15,6 +15,7 @@
 #include <net/checksum.h>
 #include <net/ipv6.h>
 
+#include <linux/netfilter/x_tables.h>
 #include <linux/netfilter_ipv6/ip6_tables.h>
 #include <linux/netfilter_ipv6/ip6t_ah.h>
 
@@ -77,13 +78,13 @@ match(const struct sk_buff *skb,
 
        DEBUGP("IPv6 AH spi %02X ",
               (spi_match(ahinfo->spis[0], ahinfo->spis[1],
-                         ntohl(ah->spi),
-                         !!(ahinfo->invflags & IP6T_AH_INV_SPI))));
+                         ntohl(ah->spi),
+                         !!(ahinfo->invflags & IP6T_AH_INV_SPI))));
        DEBUGP("len %02X %04X %02X ",
               ahinfo->hdrlen, hdrlen,
               (!ahinfo->hdrlen ||
-               (ahinfo->hdrlen == hdrlen) ^
-               !!(ahinfo->invflags & IP6T_AH_INV_LEN)));
+               (ahinfo->hdrlen == hdrlen) ^
+               !!(ahinfo->invflags & IP6T_AH_INV_LEN)));
        DEBUGP("res %02X %04X %02X\n",
               ahinfo->hdrres, ah->reserved,
               !(ahinfo->hdrres && ah->reserved));
@@ -91,12 +92,12 @@ match(const struct sk_buff *skb,
        return (ah != NULL)
               &&
               (spi_match(ahinfo->spis[0], ahinfo->spis[1],
-                         ntohl(ah->spi),
-                         !!(ahinfo->invflags & IP6T_AH_INV_SPI)))
+                         ntohl(ah->spi),
+                         !!(ahinfo->invflags & IP6T_AH_INV_SPI)))
               &&
               (!ahinfo->hdrlen ||
-               (ahinfo->hdrlen == hdrlen) ^
-               !!(ahinfo->invflags & IP6T_AH_INV_LEN))
+               (ahinfo->hdrlen == hdrlen) ^
+               !!(ahinfo->invflags & IP6T_AH_INV_LEN))
               &&
               !(ahinfo->hdrres && ah->reserved);
 }
@@ -104,10 +105,10 @@ match(const struct sk_buff *skb,
 /* Called when user tries to insert an entry of this type. */
 static int
 checkentry(const char *tablename,
-          const void *entry,
+         const void *entry,
          const struct xt_match *match,
-          void *matchinfo,
-          unsigned int hook_mask)
+         void *matchinfo,
+         unsigned int hook_mask)
 {
        const struct ip6t_ah *ahinfo = matchinfo;
 
@@ -118,8 +119,9 @@ checkentry(const char *tablename,
        return 1;
 }
 
-static struct ip6t_match ah_match = {
+static struct xt_match ah_match = {
        .name           = "ah",
+       .family         = AF_INET6,
        .match          = match,
        .matchsize      = sizeof(struct ip6t_ah),
        .checkentry     = checkentry,
@@ -128,12 +130,12 @@ static struct ip6t_match ah_match = {
 
 static int __init ip6t_ah_init(void)
 {
-       return ip6t_register_match(&ah_match);
+       return xt_register_match(&ah_match);
 }
 
 static void __exit ip6t_ah_fini(void)
 {
-       ip6t_unregister_match(&ah_match);
+       xt_unregister_match(&ah_match);
 }
 
 module_init(ip6t_ah_init);
index 4f6b84c8f4ab6567cc70301d7bdcc2460eabb38a..967bed71d4a889c53638249640c3405656c73d52 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/ipv6.h>
 #include <linux/if_ether.h>
 
+#include <linux/netfilter/x_tables.h>
 #include <linux/netfilter_ipv6/ip6_tables.h>
 
 MODULE_DESCRIPTION("IPv6 EUI64 address checking match");
@@ -61,8 +62,9 @@ match(const struct sk_buff *skb,
        return 0;
 }
 
-static struct ip6t_match eui64_match = {
+static struct xt_match eui64_match = {
        .name           = "eui64",
+       .family         = AF_INET6,
        .match          = match,
        .matchsize      = sizeof(int),
        .hooks          = (1 << NF_IP6_PRE_ROUTING) | (1 << NF_IP6_LOCAL_IN) |
@@ -72,12 +74,12 @@ static struct ip6t_match eui64_match = {
 
 static int __init ip6t_eui64_init(void)
 {
-       return ip6t_register_match(&eui64_match);
+       return xt_register_match(&eui64_match);
 }
 
 static void __exit ip6t_eui64_fini(void)
 {
-       ip6t_unregister_match(&eui64_match);
+       xt_unregister_match(&eui64_match);
 }
 
 module_init(ip6t_eui64_init);
index cd22eaaccdca9547a90d9679dd299d971938c795..5a5da71321b6f5f6962ece60cf52997df3e3cedc 100644 (file)
@@ -14,6 +14,7 @@
 #include <net/checksum.h>
 #include <net/ipv6.h>
 
+#include <linux/netfilter/x_tables.h>
 #include <linux/netfilter_ipv6/ip6_tables.h>
 #include <linux/netfilter_ipv6/ip6t_frag.h>
 
@@ -135,8 +136,9 @@ checkentry(const char *tablename,
        return 1;
 }
 
-static struct ip6t_match frag_match = {
+static struct xt_match frag_match = {
        .name           = "frag",
+       .family         = AF_INET6,
        .match          = match,
        .matchsize      = sizeof(struct ip6t_frag),
        .checkentry     = checkentry,
@@ -145,12 +147,12 @@ static struct ip6t_match frag_match = {
 
 static int __init ip6t_frag_init(void)
 {
-       return ip6t_register_match(&frag_match);
+       return xt_register_match(&frag_match);
 }
 
 static void __exit ip6t_frag_fini(void)
 {
-       ip6t_unregister_match(&frag_match);
+       xt_unregister_match(&frag_match);
 }
 
 module_init(ip6t_frag_init);
index 3f25babe044068625a95ea3886b05b7b7365482f..d2373c7cd35458686d44dd813ab2c70c2a37bb71 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <asm/byteorder.h>
 
+#include <linux/netfilter/x_tables.h>
 #include <linux/netfilter_ipv6/ip6_tables.h>
 #include <linux/netfilter_ipv6/ip6t_opts.h>
 
index 44a729e17c4857e0d2bb7ad3209aeb07c47ec54f..37c8a4d4ed78d9417ac5eb31e6b98d739dc76983 100644 (file)
@@ -8,11 +8,12 @@
  * published by the Free Software Foundation.
  */
 
+#include <linux/ipv6.h>
 #include <linux/module.h>
 #include <linux/skbuff.h>
 
 #include <linux/netfilter_ipv6/ip6t_hl.h>
-#include <linux/netfilter_ipv6/ip6_tables.h>
+#include <linux/netfilter/x_tables.h>
 
 MODULE_AUTHOR("Maciej Soltysiak <solt@dns.toxicfilms.tv>");
 MODULE_DESCRIPTION("IP tables Hop Limit matching module");
@@ -40,7 +41,7 @@ static int match(const struct sk_buff *skb,
                        return (ip6h->hop_limit > info->hop_limit);
                        break;
                default:
-                       printk(KERN_WARNING "ip6t_hl: unknown mode %d\n", 
+                       printk(KERN_WARNING "ip6t_hl: unknown mode %d\n",
                                info->mode);
                        return 0;
        }
@@ -48,8 +49,9 @@ static int match(const struct sk_buff *skb,
        return 0;
 }
 
-static struct ip6t_match hl_match = {
+static struct xt_match hl_match = {
        .name           = "hl",
+       .family         = AF_INET6,
        .match          = match,
        .matchsize      = sizeof(struct ip6t_hl_info),
        .me             = THIS_MODULE,
@@ -57,13 +59,12 @@ static struct ip6t_match hl_match = {
 
 static int __init ip6t_hl_init(void)
 {
-       return ip6t_register_match(&hl_match);
+       return xt_register_match(&hl_match);
 }
 
 static void __exit ip6t_hl_fini(void)
 {
-       ip6t_unregister_match(&hl_match);
-
+       xt_unregister_match(&hl_match);
 }
 
 module_init(ip6t_hl_init);
index 3093c398002f0ad0235e9a925848e9efededab44..700a11d25deb02c287641b030637ab038bc9a896 100644 (file)
@@ -1,7 +1,7 @@
 /* ipv6header match - matches IPv6 packets based
    on whether they contain certain headers */
 
-/* Original idea: Brad Chapman 
+/* Original idea: Brad Chapman
  * Rewritten by: Andras Kis-Szabo <kisza@sch.bme.hu> */
 
 /* (C) 2001-2002 Andras Kis-Szabo <kisza@sch.bme.hu>
@@ -18,6 +18,7 @@
 #include <net/checksum.h>
 #include <net/ipv6.h>
 
+#include <linux/netfilter/x_tables.h>
 #include <linux/netfilter_ipv6/ip6_tables.h>
 #include <linux/netfilter_ipv6/ip6t_ipv6header.h>
 
@@ -140,8 +141,9 @@ ipv6header_checkentry(const char *tablename,
        return 1;
 }
 
-static struct ip6t_match ip6t_ipv6header_match = {
+static struct xt_match ip6t_ipv6header_match = {
        .name           = "ipv6header",
+       .family         = AF_INET6,
        .match          = &ipv6header_match,
        .matchsize      = sizeof(struct ip6t_ipv6header_info),
        .checkentry     = &ipv6header_checkentry,
@@ -151,12 +153,12 @@ static struct ip6t_match ip6t_ipv6header_match = {
 
 static int __init ipv6header_init(void)
 {
-       return ip6t_register_match(&ip6t_ipv6header_match);
+       return xt_register_match(&ip6t_ipv6header_match);
 }
 
 static void __exit ipv6header_exit(void)
 {
-       ip6t_unregister_match(&ip6t_ipv6header_match);
+       xt_unregister_match(&ip6t_ipv6header_match);
 }
 
 module_init(ipv6header_init);
diff --git a/net/ipv6/netfilter/ip6t_mh.c b/net/ipv6/netfilter/ip6t_mh.c
new file mode 100644 (file)
index 0000000..2c7efc6
--- /dev/null
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C)2006 USAGI/WIDE Project
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Author:
+ *     Masahide NAKAMURA @USAGI <masahide.nakamura.cz@hitachi.com>
+ *
+ * Based on net/netfilter/xt_tcpudp.c
+ *
+ */
+#include <linux/types.h>
+#include <linux/module.h>
+#include <net/ip.h>
+#include <linux/ipv6.h>
+#include <net/ipv6.h>
+#include <net/mip6.h>
+
+#include <linux/netfilter/x_tables.h>
+#include <linux/netfilter_ipv6/ip6t_mh.h>
+
+MODULE_DESCRIPTION("ip6t_tables match for MH");
+MODULE_LICENSE("GPL");
+
+#ifdef DEBUG_IP_FIREWALL_USER
+#define duprintf(format, args...) printk(format , ## args)
+#else
+#define duprintf(format, args...)
+#endif
+
+/* Returns 1 if the type is matched by the range, 0 otherwise */
+static inline int
+type_match(u_int8_t min, u_int8_t max, u_int8_t type, int invert)
+{
+       int ret;
+
+       ret = (type >= min && type <= max) ^ invert;
+       return ret;
+}
+
+static int
+match(const struct sk_buff *skb,
+        const struct net_device *in,
+        const struct net_device *out,
+        const struct xt_match *match,
+        const void *matchinfo,
+        int offset,
+        unsigned int protoff,
+        int *hotdrop)
+{
+       struct ip6_mh _mh, *mh;
+       const struct ip6t_mh *mhinfo = matchinfo;
+
+       /* Must not be a fragment. */
+       if (offset)
+               return 0;
+
+       mh = skb_header_pointer(skb, protoff, sizeof(_mh), &_mh);
+       if (mh == NULL) {
+               /* We've been asked to examine this packet, and we
+                  can't.  Hence, no choice but to drop. */
+               duprintf("Dropping evil MH tinygram.\n");
+               *hotdrop = 1;
+               return 0;
+       }
+
+       return type_match(mhinfo->types[0], mhinfo->types[1], mh->ip6mh_type,
+                         !!(mhinfo->invflags & IP6T_MH_INV_TYPE));
+}
+
+/* Called when user tries to insert an entry of this type. */
+static int
+mh_checkentry(const char *tablename,
+             const void *entry,
+             const struct xt_match *match,
+             void *matchinfo,
+             unsigned int hook_mask)
+{
+       const struct ip6t_mh *mhinfo = matchinfo;
+
+       /* Must specify no unknown invflags */
+       return !(mhinfo->invflags & ~IP6T_MH_INV_MASK);
+}
+
+static struct xt_match mh_match = {
+       .name           = "mh",
+       .family         = AF_INET6,
+       .checkentry     = mh_checkentry,
+       .match          = match,
+       .matchsize      = sizeof(struct ip6t_mh),
+       .proto          = IPPROTO_MH,
+       .me             = THIS_MODULE,
+};
+
+static int __init ip6t_mh_init(void)
+{
+       return xt_register_match(&mh_match);
+}
+
+static void __exit ip6t_mh_fini(void)
+{
+       xt_unregister_match(&mh_match);
+}
+
+module_init(ip6t_mh_init);
+module_exit(ip6t_mh_fini);
index 4eb9bbc4ebc3cc47a0a4ac63d10f46eced08d11d..43738bba00b548fb5b9174d41fcf7cd82a81b5fe 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <linux/netfilter_ipv6/ip6t_owner.h>
 #include <linux/netfilter_ipv6/ip6_tables.h>
+#include <linux/netfilter/x_tables.h>
 
 MODULE_AUTHOR("Marc Boucher <marc@mbsi.ca>");
 MODULE_DESCRIPTION("IP6 tables owner matching module");
@@ -69,8 +70,9 @@ checkentry(const char *tablename,
        return 1;
 }
 
-static struct ip6t_match owner_match = {
+static struct xt_match owner_match = {
        .name           = "owner",
+       .family         = AF_INET6,
        .match          = match,
        .matchsize      = sizeof(struct ip6t_owner_info),
        .hooks          = (1 << NF_IP6_LOCAL_OUT) | (1 << NF_IP6_POST_ROUTING),
@@ -80,12 +82,12 @@ static struct ip6t_match owner_match = {
 
 static int __init ip6t_owner_init(void)
 {
-       return ip6t_register_match(&owner_match);
+       return xt_register_match(&owner_match);
 }
 
 static void __exit ip6t_owner_fini(void)
 {
-       ip6t_unregister_match(&owner_match);
+       xt_unregister_match(&owner_match);
 }
 
 module_init(ip6t_owner_init);
index 54d7d14134fdae695496ed150c6c241431075789..81ab00d8c182909764449ff369480592b849f534 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <asm/byteorder.h>
 
+#include <linux/netfilter/x_tables.h>
 #include <linux/netfilter_ipv6/ip6_tables.h>
 #include <linux/netfilter_ipv6/ip6t_rt.h>
 
@@ -221,8 +222,9 @@ checkentry(const char *tablename,
        return 1;
 }
 
-static struct ip6t_match rt_match = {
+static struct xt_match rt_match = {
        .name           = "rt",
+       .family         = AF_INET6,
        .match          = match,
        .matchsize      = sizeof(struct ip6t_rt),
        .checkentry     = checkentry,
@@ -231,12 +233,12 @@ static struct ip6t_match rt_match = {
 
 static int __init ip6t_rt_init(void)
 {
-       return ip6t_register_match(&rt_match);
+       return xt_register_match(&rt_match);
 }
 
 static void __exit ip6t_rt_fini(void)
 {
-       ip6t_unregister_match(&rt_match);
+       xt_unregister_match(&rt_match);
 }
 
 module_init(ip6t_rt_init);
index 2fc07c74decf6ca468a4c643eb513d5543a3e693..112a21d0c6da2d3c4423f4649f8f9a6138a46355 100644 (file)
@@ -19,25 +19,6 @@ MODULE_DESCRIPTION("ip6tables filter table");
 
 #define FILTER_VALID_HOOKS ((1 << NF_IP6_LOCAL_IN) | (1 << NF_IP6_FORWARD) | (1 << NF_IP6_LOCAL_OUT))
 
-/* Standard entry. */
-struct ip6t_standard
-{
-       struct ip6t_entry entry;
-       struct ip6t_standard_target target;
-};
-
-struct ip6t_error_target
-{
-       struct ip6t_entry_target target;
-       char errorname[IP6T_FUNCTION_MAXNAMELEN];
-};
-
-struct ip6t_error
-{
-       struct ip6t_entry entry;
-       struct ip6t_error_target target;
-};
-
 static struct
 {
        struct ip6t_replace repl;
@@ -92,7 +73,7 @@ static struct
     }
 };
 
-static struct ip6t_table packet_filter = {
+static struct xt_table packet_filter = {
        .name           = "filter",
        .valid_hooks    = FILTER_VALID_HOOKS,
        .lock           = RW_LOCK_UNLOCKED,
index 6250e86a6ddcafbf0fcddcae7f8707eea60037c9..0c468d35a93743b34e7773966d313455dd89687f 100644 (file)
@@ -29,25 +29,6 @@ MODULE_DESCRIPTION("ip6tables mangle table");
 #define DEBUGP(x, args...)
 #endif
 
-/* Standard entry. */
-struct ip6t_standard
-{
-       struct ip6t_entry entry;
-       struct ip6t_standard_target target;
-};
-
-struct ip6t_error_target
-{
-       struct ip6t_entry_target target;
-       char errorname[IP6T_FUNCTION_MAXNAMELEN];
-};
-
-struct ip6t_error
-{
-       struct ip6t_entry entry;
-       struct ip6t_error_target target;
-};
-
 static struct
 {
        struct ip6t_replace repl;
@@ -69,7 +50,7 @@ static struct
       0, NULL, { } },
     {
            /* PRE_ROUTING */
-            { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 },
+           { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 },
                0,
                sizeof(struct ip6t_entry),
                sizeof(struct ip6t_standard),
@@ -77,7 +58,7 @@ static struct
              { { { { IP6T_ALIGN(sizeof(struct ip6t_standard_target)), "" } }, { } },
                -NF_ACCEPT - 1 } },
            /* LOCAL_IN */
-            { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 },
+           { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 },
                0,
                sizeof(struct ip6t_entry),
                sizeof(struct ip6t_standard),
@@ -85,7 +66,7 @@ static struct
              { { { { IP6T_ALIGN(sizeof(struct ip6t_standard_target)), "" } }, { } },
                -NF_ACCEPT - 1 } },
            /* FORWARD */
-            { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 },
+           { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 },
                0,
                sizeof(struct ip6t_entry),
                sizeof(struct ip6t_standard),
@@ -93,7 +74,7 @@ static struct
              { { { { IP6T_ALIGN(sizeof(struct ip6t_standard_target)), "" } }, { } },
                -NF_ACCEPT - 1 } },
            /* LOCAL_OUT */
-            { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 },
+           { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 },
                0,
                sizeof(struct ip6t_entry),
                sizeof(struct ip6t_standard),
@@ -122,7 +103,7 @@ static struct
     }
 };
 
-static struct ip6t_table packet_mangler = {
+static struct xt_table packet_mangler = {
        .name           = "mangle",
        .valid_hooks    = MANGLE_VALID_HOOKS,
        .lock           = RW_LOCK_UNLOCKED,
@@ -175,7 +156,7 @@ ip6t_local_hook(unsigned int hook,
 
        ret = ip6t_do_table(pskb, hook, in, out, &packet_mangler);
 
-       if (ret != NF_DROP && ret != NF_STOLEN 
+       if (ret != NF_DROP && ret != NF_STOLEN
                && (memcmp(&(*pskb)->nh.ipv6h->saddr, &saddr, sizeof(saddr))
                    || memcmp(&(*pskb)->nh.ipv6h->daddr, &daddr, sizeof(daddr))
                    || (*pskb)->mark != mark
index b4154da575c0693d78924a6912fe91cea69b128c..a3eb5b8ce18d0abe8a7062b0cc340e1b6bb5b160 100644 (file)
 #define DEBUGP(x, args...)
 #endif
 
-/* Standard entry. */
-struct ip6t_standard
-{
-       struct ip6t_entry entry;
-       struct ip6t_standard_target target;
-};
-
-struct ip6t_error_target
-{
-       struct ip6t_entry_target target;
-       char errorname[IP6T_FUNCTION_MAXNAMELEN];
-};
-
-struct ip6t_error
-{
-       struct ip6t_entry entry;
-       struct ip6t_error_target target;
-};
-
 static struct
 {
        struct ip6t_replace repl;
@@ -106,10 +87,10 @@ static struct
        }
 };
 
-static struct xt_table packet_raw = { 
-       .name = "raw", 
-       .valid_hooks = RAW_VALID_HOOKS, 
-       .lock = RW_LOCK_UNLOCKED, 
+static struct xt_table packet_raw = {
+       .name = "raw",
+       .valid_hooks = RAW_VALID_HOOKS,
+       .lock = RW_LOCK_UNLOCKED,
        .me = THIS_MODULE,
        .af = AF_INET6,
 };
@@ -125,17 +106,17 @@ ip6t_hook(unsigned int hook,
        return ip6t_do_table(pskb, hook, in, out, &packet_raw);
 }
 
-static struct nf_hook_ops ip6t_ops[] = { 
+static struct nf_hook_ops ip6t_ops[] = {
        {
-         .hook = ip6t_hook, 
+         .hook = ip6t_hook,
          .pf = PF_INET6,
          .hooknum = NF_IP6_PRE_ROUTING,
          .priority = NF_IP6_PRI_FIRST,
          .owner = THIS_MODULE,
        },
        {
-         .hook = ip6t_hook, 
-         .pf = PF_INET6, 
+         .hook = ip6t_hook,
+         .pf = PF_INET6,
          .hooknum = NF_IP6_LOCAL_OUT,
          .priority = NF_IP6_PRI_FIRST,
          .owner = THIS_MODULE,
index a20615ffccffe8dae47cb88a635a5603c86c1588..a2353edf4ebc09945009b4ff102e81f3a13b36d1 100644 (file)
@@ -349,7 +349,7 @@ static ctl_table nf_ct_ipv6_sysctl_table[] = {
                .mode           = 0644,
                .proc_handler   = &proc_dointvec,
        },
-        { .ctl_name = 0 }
+       { .ctl_name = 0 }
 };
 #endif
 
@@ -386,7 +386,7 @@ static int ipv6_nfattr_to_tuple(struct nfattr *tb[],
        if (nfattr_bad_size(tb, CTA_IP_MAX, cta_min_ip))
                return -EINVAL;
 
-       memcpy(&t->src.u3.ip6, NFA_DATA(tb[CTA_IP_V6_SRC-1]), 
+       memcpy(&t->src.u3.ip6, NFA_DATA(tb[CTA_IP_V6_SRC-1]),
               sizeof(u_int32_t) * 4);
        memcpy(&t->dst.u3.ip6, NFA_DATA(tb[CTA_IP_V6_DST-1]),
               sizeof(u_int32_t) * 4);
index 3905cacc69af1d916feb0dc419b47b912e198d25..b08622c992b2fbf9322d7b72717bd2449987eaf6 100644 (file)
@@ -104,9 +104,9 @@ static int icmpv6_packet(struct nf_conn *ct,
                       unsigned int hooknum)
 {
        /* Try to delete connection immediately after all replies:
-           won't actually vanish as we still have skb, and del_timer
-           means this will only run once even if count hits zero twice
-           (theoretically possible with SMP) */
+          won't actually vanish as we still have skb, and del_timer
+          means this will only run once even if count hits zero twice
+          (theoretically possible with SMP) */
        if (CTINFO2DIR(ctinfo) == IP_CT_DIR_REPLY) {
                if (atomic_dec_and_test(&ct->proto.icmp.count)
                    && del_timer(&ct->timeout))
index d9c15402ba6619023b6f28633e14666ee615b09f..15ab1e3e8b564143f3a9166f97463cacdb2a27f2 100644 (file)
@@ -311,7 +311,7 @@ static struct nf_ct_frag6_queue *nf_ct_frag6_intern(unsigned int hash,
        write_lock(&nf_ct_frag6_lock);
 #ifdef CONFIG_SMP
        hlist_for_each_entry(fq, n, &nf_ct_frag6_hash[hash], list) {
-               if (fq->id == fq_in->id && 
+               if (fq->id == fq_in->id &&
                    ipv6_addr_equal(&fq_in->saddr, &fq->saddr) &&
                    ipv6_addr_equal(&fq_in->daddr, &fq->daddr)) {
                        atomic_inc(&fq->refcnt);
@@ -374,7 +374,7 @@ fq_find(__be32 id, struct in6_addr *src, struct in6_addr *dst)
 
        read_lock(&nf_ct_frag6_lock);
        hlist_for_each_entry(fq, n, &nf_ct_frag6_hash[hash], list) {
-               if (fq->id == id && 
+               if (fq->id == id &&
                    ipv6_addr_equal(src, &fq->saddr) &&
                    ipv6_addr_equal(dst, &fq->daddr)) {
                        atomic_inc(&fq->refcnt);
@@ -388,7 +388,7 @@ fq_find(__be32 id, struct in6_addr *src, struct in6_addr *dst)
 }
 
 
-static int nf_ct_frag6_queue(struct nf_ct_frag6_queue *fq, struct sk_buff *skb, 
+static int nf_ct_frag6_queue(struct nf_ct_frag6_queue *fq, struct sk_buff *skb,
                             struct frag_hdr *fhdr, int nhoff)
 {
        struct sk_buff *prev, *next;
@@ -405,12 +405,12 @@ static int nf_ct_frag6_queue(struct nf_ct_frag6_queue *fq, struct sk_buff *skb,
 
        if ((unsigned int)end > IPV6_MAXPLEN) {
                DEBUGP("offset is too large.\n");
-               return -1;
+               return -1;
        }
 
-       if (skb->ip_summed == CHECKSUM_COMPLETE)
-               skb->csum = csum_sub(skb->csum,
-                                    csum_partial(skb->nh.raw,
+       if (skb->ip_summed == CHECKSUM_COMPLETE)
+               skb->csum = csum_sub(skb->csum,
+                                    csum_partial(skb->nh.raw,
                                                  (u8*)(fhdr + 1) - skb->nh.raw,
                                                  0));
 
@@ -625,7 +625,7 @@ nf_ct_frag6_reasm(struct nf_ct_frag6_queue *fq, struct net_device *dev)
        /* We have to remove fragment header from datagram and to relocate
         * header in order to calculate ICV correctly. */
        head->nh.raw[fq->nhoffset] = head->h.raw[0];
-       memmove(head->head + sizeof(struct frag_hdr), head->head, 
+       memmove(head->head + sizeof(struct frag_hdr), head->head,
                (head->data - head->head) - sizeof(struct frag_hdr));
        head->mac.raw += sizeof(struct frag_hdr);
        head->nh.raw += sizeof(struct frag_hdr);
@@ -701,41 +701,41 @@ out_fail:
 static int
 find_prev_fhdr(struct sk_buff *skb, u8 *prevhdrp, int *prevhoff, int *fhoff)
 {
-        u8 nexthdr = skb->nh.ipv6h->nexthdr;
+       u8 nexthdr = skb->nh.ipv6h->nexthdr;
        u8 prev_nhoff = (u8 *)&skb->nh.ipv6h->nexthdr - skb->data;
        int start = (u8 *)(skb->nh.ipv6h+1) - skb->data;
        int len = skb->len - start;
        u8 prevhdr = NEXTHDR_IPV6;
 
-        while (nexthdr != NEXTHDR_FRAGMENT) {
-                struct ipv6_opt_hdr hdr;
-                int hdrlen;
+       while (nexthdr != NEXTHDR_FRAGMENT) {
+               struct ipv6_opt_hdr hdr;
+               int hdrlen;
 
                if (!ipv6_ext_hdr(nexthdr)) {
                        return -1;
                }
-                if (len < (int)sizeof(struct ipv6_opt_hdr)) {
+               if (len < (int)sizeof(struct ipv6_opt_hdr)) {
                        DEBUGP("too short\n");
                        return -1;
                }
-                if (nexthdr == NEXTHDR_NONE) {
+               if (nexthdr == NEXTHDR_NONE) {
                        DEBUGP("next header is none\n");
                        return -1;
                }
-                if (skb_copy_bits(skb, start, &hdr, sizeof(hdr)))
-                        BUG();
-                if (nexthdr == NEXTHDR_AUTH)
-                        hdrlen = (hdr.hdrlen+2)<<2;
-                else
-                        hdrlen = ipv6_optlen(&hdr);
+               if (skb_copy_bits(skb, start, &hdr, sizeof(hdr)))
+                       BUG();
+               if (nexthdr == NEXTHDR_AUTH)
+                       hdrlen = (hdr.hdrlen+2)<<2;
+               else
+                       hdrlen = ipv6_optlen(&hdr);
 
                prevhdr = nexthdr;
                prev_nhoff = start;
 
-                nexthdr = hdr.nexthdr;
-                len -= hdrlen;
-                start += hdrlen;
-        }
+               nexthdr = hdr.nexthdr;
+               len -= hdrlen;
+               start += hdrlen;
+       }
 
        if (len < 0)
                return -1;
@@ -749,7 +749,7 @@ find_prev_fhdr(struct sk_buff *skb, u8 *prevhdrp, int *prevhoff, int *fhoff)
 
 struct sk_buff *nf_ct_frag6_gather(struct sk_buff *skb)
 {
-       struct sk_buff *clone; 
+       struct sk_buff *clone;
        struct net_device *dev = skb->dev;
        struct frag_hdr *fhdr;
        struct nf_ct_frag6_queue *fq;
index 35249d8487bbb4b61a0b0b29fd83774e26dc594c..032ef95c5b0076aa6f38c2e075dccbf897aee947 100644 (file)
@@ -50,7 +50,7 @@ static int sockstat6_seq_show(struct seq_file *seq, void *v)
        seq_printf(seq, "UDP6: inuse %d\n",
                       fold_prot_inuse(&udpv6_prot));
        seq_printf(seq, "UDPLITE6: inuse %d\n",
-                       fold_prot_inuse(&udplitev6_prot));
+                       fold_prot_inuse(&udplitev6_prot));
        seq_printf(seq, "RAW6: inuse %d\n",
                       fold_prot_inuse(&rawv6_prot));
        seq_printf(seq, "FRAG6: inuse %d memory %d\n",
@@ -89,7 +89,7 @@ static struct snmp_mib snmp6_icmp6_list[] = {
 /* icmpv6 mib according to RFC 2466
 
    Exceptions:  {In|Out}AdminProhibs are removed, because I see
-                no good reasons to account them separately
+               no good reasons to account them separately
                of another dest.unreachs.
                OutErrs is zero identically.
                OutEchos too.
@@ -146,14 +146,14 @@ static struct snmp_mib snmp6_udplite6_list[] = {
 static unsigned long
 fold_field(void *mib[], int offt)
 {
-        unsigned long res = 0;
-        int i;
-        for_each_possible_cpu(i) {
-                res += *(((unsigned long *)per_cpu_ptr(mib[0], i)) + offt);
-                res += *(((unsigned long *)per_cpu_ptr(mib[1], i)) + offt);
-        }
-        return res;
+       unsigned long res = 0;
+       int i;
+
+       for_each_possible_cpu(i) {
+               res += *(((unsigned long *)per_cpu_ptr(mib[0], i)) + offt);
+               res += *(((unsigned long *)per_cpu_ptr(mib[1], i)) + offt);
+       }
+       return res;
 }
 
 static inline void
@@ -161,7 +161,7 @@ snmp6_seq_show_item(struct seq_file *seq, void **mib, struct snmp_mib *itemlist)
 {
        int i;
        for (i=0; itemlist[i].name; i++)
-               seq_printf(seq, "%-32s\t%lu\n", itemlist[i].name, 
+               seq_printf(seq, "%-32s\t%lu\n", itemlist[i].name,
                                fold_field(mib, itemlist[i].entry));
 }
 
index 52c1d58b6ca61587c5b1e49261316d282b80efb8..ad0410c996753789ad8df6eb665be263a044c08c 100644 (file)
@@ -64,7 +64,7 @@ int inet6_add_protocol(struct inet6_protocol *prot, unsigned char protocol)
 /*
  *     Remove a protocol from the hash tables.
  */
+
 int inet6_del_protocol(struct inet6_protocol *prot, unsigned char protocol)
 {
        int ret, hash = protocol & (MAX_INET_PROTOS - 1);
index 4ae1b19ada5d3eb9e3c3c7f0b1b7a8030002eacb..16d4c63ff554cefd1dc8062ed7ec00807b486562 100644 (file)
@@ -1,9 +1,9 @@
 /*
  *     RAW sockets for IPv6
- *     Linux INET6 implementation 
+ *     Linux INET6 implementation
  *
  *     Authors:
- *     Pedro Roque             <roque@di.fc.ul.pt>     
+ *     Pedro Roque             <roque@di.fc.ul.pt>
  *
  *     Adapted from linux/net/ipv4/raw.c
  *
@@ -11,7 +11,7 @@
  *
  *     Fixes:
  *     Hideaki YOSHIFUJI       :       sin6_scope_id support
- *     YOSHIFUJI,H.@USAGI      :       raw checksum (RFC2292(bis) compliance) 
+ *     YOSHIFUJI,H.@USAGI      :       raw checksum (RFC2292(bis) compliance)
  *     Kazunori MIYAZAWA @USAGI:       change process style to use ip6_append_data
  *
  *     This program is free software; you can redistribute it and/or
@@ -71,12 +71,12 @@ static void raw_v6_hash(struct sock *sk)
        write_lock_bh(&raw_v6_lock);
        sk_add_node(sk, list);
        sock_prot_inc_use(sk->sk_prot);
-       write_unlock_bh(&raw_v6_lock);
+       write_unlock_bh(&raw_v6_lock);
 }
 
 static void raw_v6_unhash(struct sock *sk)
 {
-       write_lock_bh(&raw_v6_lock);
+       write_lock_bh(&raw_v6_lock);
        if (sk_del_node_init(sk))
                sock_prot_dec_use(sk->sk_prot);
        write_unlock_bh(&raw_v6_lock);
@@ -250,7 +250,7 @@ static int rawv6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
                                 */
                                sk->sk_bound_dev_if = addr->sin6_scope_id;
                        }
-                       
+
                        /* Binding to link-local address requires an interface */
                        if (!sk->sk_bound_dev_if)
                                goto out;
@@ -261,7 +261,7 @@ static int rawv6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
                                goto out;
                        }
                }
-               
+
                /* ipv4 addr of the socket is invalid.  Only the
                 * unspecified and mapped address have a v4 equivalent.
                 */
@@ -324,7 +324,7 @@ void rawv6_err(struct sock *sk, struct sk_buff *skb,
 
 static inline int rawv6_rcv_skb(struct sock * sk, struct sk_buff * skb)
 {
-       if ((raw6_sk(sk)->checksum || sk->sk_filter) && 
+       if ((raw6_sk(sk)->checksum || sk->sk_filter) &&
            skb_checksum_complete(skb)) {
                /* FIXME: increment a raw6 drops counter here */
                kfree_skb(skb);
@@ -342,10 +342,10 @@ static inline int rawv6_rcv_skb(struct sock * sk, struct sk_buff * skb)
 }
 
 /*
- *     This is next to useless... 
+ *     This is next to useless...
  *     if we demultiplex in network layer we don't need the extra call
- *     just to queue the skb... 
- *     maybe we could have the network decide upon a hint if it 
+ *     just to queue the skb...
+ *     maybe we could have the network decide upon a hint if it
  *     should call raw_rcv for demultiplexing
  */
 int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
@@ -353,17 +353,17 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
        struct inet_sock *inet = inet_sk(sk);
        struct raw6_sock *rp = raw6_sk(sk);
 
-        if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
-                kfree_skb(skb);
-                return NET_RX_DROP;
-        }
+       if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
+               kfree_skb(skb);
+               return NET_RX_DROP;
+       }
 
        if (!rp->checksum)
                skb->ip_summed = CHECKSUM_UNNECESSARY;
 
        if (skb->ip_summed == CHECKSUM_COMPLETE) {
                skb_postpull_rcsum(skb, skb->nh.raw,
-                                  skb->h.raw - skb->nh.raw);
+                                  skb->h.raw - skb->nh.raw);
                if (!csum_ipv6_magic(&skb->nh.ipv6h->saddr,
                                     &skb->nh.ipv6h->daddr,
                                     skb->len, inet->num, skb->csum))
@@ -404,8 +404,8 @@ static int rawv6_recvmsg(struct kiocb *iocb, struct sock *sk,
 
        if (flags & MSG_OOB)
                return -EOPNOTSUPP;
-               
-       if (addr_len) 
+
+       if (addr_len)
                *addr_len=sizeof(*sin6);
 
        if (flags & MSG_ERRQUEUE)
@@ -416,10 +416,10 @@ static int rawv6_recvmsg(struct kiocb *iocb, struct sock *sk,
                goto out;
 
        copied = skb->len;
-       if (copied > len) {
-               copied = len;
-               msg->msg_flags |= MSG_TRUNC;
-       }
+       if (copied > len) {
+               copied = len;
+               msg->msg_flags |= MSG_TRUNC;
+       }
 
        if (skb->ip_summed==CHECKSUM_UNNECESSARY) {
                err = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);
@@ -549,7 +549,7 @@ out:
 }
 
 static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
-                       struct flowi *fl, struct rt6_info *rt, 
+                       struct flowi *fl, struct rt6_info *rt,
                        unsigned int flags)
 {
        struct ipv6_pinfo *np = inet6_sk(sk);
@@ -570,7 +570,7 @@ static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
        skb = sock_alloc_send_skb(sk, length+hh_len+15,
                                  flags&MSG_DONTWAIT, &err);
        if (skb == NULL)
-               goto error; 
+               goto error;
        skb_reserve(skb, hh_len);
 
        skb->priority = sk->sk_priority;
@@ -600,7 +600,7 @@ error_fault:
        kfree_skb(skb);
 error:
        IP6_INC_STATS(rt->rt6i_idev, IPSTATS_MIB_OUTDISCARDS);
-       return err; 
+       return err;
 }
 
 static int rawv6_probe_proto_opt(struct flowi *fl, struct msghdr *msg)
@@ -694,19 +694,19 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
                return -EMSGSIZE;
 
        /* Mirror BSD error message compatibility */
-       if (msg->msg_flags & MSG_OOB)           
+       if (msg->msg_flags & MSG_OOB)
                return -EOPNOTSUPP;
 
        /*
-        *      Get and verify the address. 
+        *      Get and verify the address.
         */
        memset(&fl, 0, sizeof(fl));
 
        if (sin6) {
-               if (addr_len < SIN6_LEN_RFC2133) 
+               if (addr_len < SIN6_LEN_RFC2133)
                        return -EINVAL;
 
-               if (sin6->sin6_family && sin6->sin6_family != AF_INET6) 
+               if (sin6->sin6_family && sin6->sin6_family != AF_INET6)
                        return(-EAFNOSUPPORT);
 
                /* port is the proto value [0..255] carried in nexthdr */
@@ -744,17 +744,17 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
                    ipv6_addr_type(daddr)&IPV6_ADDR_LINKLOCAL)
                        fl.oif = sin6->sin6_scope_id;
        } else {
-               if (sk->sk_state != TCP_ESTABLISHED) 
+               if (sk->sk_state != TCP_ESTABLISHED)
                        return -EDESTADDRREQ;
-               
+
                proto = inet->num;
                daddr = &np->daddr;
                fl.fl6_flowlabel = np->flow_label;
        }
 
        if (ipv6_addr_any(daddr)) {
-               /* 
-                * unspecified destination address 
+               /*
+                * unspecified destination address
                 * treated as error... is this correct ?
                 */
                fl6_sock_release(flowlabel);
@@ -792,7 +792,7 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
        err = rawv6_probe_proto_opt(&fl, msg);
        if (err)
                goto out;
+
        ipv6_addr_copy(&fl.fl6_dst, daddr);
        if (ipv6_addr_any(&fl.fl6_src) && !ipv6_addr_any(&np->saddr))
                ipv6_addr_copy(&fl.fl6_src, &np->saddr);
@@ -815,7 +815,7 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
        if (final_p)
                ipv6_addr_copy(&fl.fl6_dst, final_p);
 
-       if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0)
+       if ((err = xfrm_lookup(&dst, &fl, sk, 1)) < 0)
                goto out;
 
        if (hlimit < 0) {
@@ -856,7 +856,7 @@ done:
        dst_release(dst);
        if (!inet->hdrincl)
                release_sock(sk);
-out:   
+out:
        fl6_sock_release(flowlabel);
        return err<0?err:len;
 do_confirm:
@@ -867,7 +867,7 @@ do_confirm:
        goto done;
 }
 
-static int rawv6_seticmpfilter(struct sock *sk, int level, int optname, 
+static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
                               char __user *optval, int optlen)
 {
        switch (optname) {
@@ -884,7 +884,7 @@ static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
        return 0;
 }
 
-static int rawv6_geticmpfilter(struct sock *sk, int level, int optname, 
+static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
                               char __user *optval, int __user *optlen)
 {
        int len;
@@ -916,7 +916,7 @@ static int do_rawv6_setsockopt(struct sock *sk, int level, int optname,
        struct raw6_sock *rp = raw6_sk(sk);
        int val;
 
-       if (get_user(val, (int __user *)optval))
+       if (get_user(val, (int __user *)optval))
                return -EFAULT;
 
        switch (optname) {
@@ -1094,10 +1094,19 @@ static void rawv6_close(struct sock *sk, long timeout)
 
 static int rawv6_init_sk(struct sock *sk)
 {
-       if (inet_sk(sk)->num == IPPROTO_ICMPV6) {
-               struct raw6_sock *rp = raw6_sk(sk);
+       struct raw6_sock *rp = raw6_sk(sk);
+
+       switch (inet_sk(sk)->num) {
+       case IPPROTO_ICMPV6:
                rp->checksum = 1;
                rp->offset   = 2;
+               break;
+       case IPPROTO_MH:
+               rp->checksum = 1;
+               rp->offset   = 4;
+               break;
+       default:
+               break;
        }
        return(0);
 }
@@ -1215,7 +1224,7 @@ static void raw6_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
                   src->s6_addr32[2], src->s6_addr32[3], srcp,
                   dest->s6_addr32[0], dest->s6_addr32[1],
                   dest->s6_addr32[2], dest->s6_addr32[3], destp,
-                  sp->sk_state, 
+                  sp->sk_state,
                   atomic_read(&sp->sk_wmem_alloc),
                   atomic_read(&sp->sk_rmem_alloc),
                   0, 0L, 0,
index 6f9a9046510f730a6f1f431010e9ffe5f6e05e16..7034c54e5010d48dc1c306335e367e7e9470dfb1 100644 (file)
@@ -1,9 +1,9 @@
 /*
  *     IPv6 fragment reassembly
- *     Linux INET6 implementation 
+ *     Linux INET6 implementation
  *
  *     Authors:
- *     Pedro Roque             <roque@di.fc.ul.pt>     
+ *     Pedro Roque             <roque@di.fc.ul.pt>
  *
  *     $Id: reassembly.c,v 1.26 2001/03/07 22:00:57 davem Exp $
  *
@@ -15,8 +15,8 @@
  *      2 of the License, or (at your option) any later version.
  */
 
-/* 
- *     Fixes:  
+/*
+ *     Fixes:
  *     Andi Kleen      Make it work with multiple hosts.
  *                     More RFC compliance.
  *
@@ -343,7 +343,7 @@ static struct frag_queue *ip6_frag_intern(struct frag_queue *fq_in)
        hash = ip6qhashfn(fq_in->id, &fq_in->saddr, &fq_in->daddr);
 #ifdef CONFIG_SMP
        hlist_for_each_entry(fq, n, &ip6_frag_hash[hash], list) {
-               if (fq->id == fq_in->id && 
+               if (fq->id == fq_in->id &&
                    ipv6_addr_equal(&fq_in->saddr, &fq->saddr) &&
                    ipv6_addr_equal(&fq_in->daddr, &fq->daddr)) {
                        atomic_inc(&fq->refcnt);
@@ -406,7 +406,7 @@ fq_find(__be32 id, struct in6_addr *src, struct in6_addr *dst,
        read_lock(&ip6_frag_lock);
        hash = ip6qhashfn(id, src, dst);
        hlist_for_each_entry(fq, n, &ip6_frag_hash[hash], list) {
-               if (fq->id == id && 
+               if (fq->id == id &&
                    ipv6_addr_equal(src, &fq->saddr) &&
                    ipv6_addr_equal(dst, &fq->daddr)) {
                        atomic_inc(&fq->refcnt);
@@ -420,7 +420,7 @@ fq_find(__be32 id, struct in6_addr *src, struct in6_addr *dst,
 }
 
 
-static void ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb, 
+static void ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb,
                           struct frag_hdr *fhdr, int nhoff)
 {
        struct sk_buff *prev, *next;
@@ -436,13 +436,13 @@ static void ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb,
        if ((unsigned int)end > IPV6_MAXPLEN) {
                IP6_INC_STATS_BH(ip6_dst_idev(skb->dst),
                                 IPSTATS_MIB_INHDRERRORS);
-               icmpv6_param_prob(skb,ICMPV6_HDR_FIELD, (u8*)&fhdr->frag_off - skb->nh.raw);
-               return;
+               icmpv6_param_prob(skb,ICMPV6_HDR_FIELD, (u8*)&fhdr->frag_off - skb->nh.raw);
+               return;
        }
 
-       if (skb->ip_summed == CHECKSUM_COMPLETE)
-               skb->csum = csum_sub(skb->csum,
-                                    csum_partial(skb->nh.raw, (u8*)(fhdr+1)-skb->nh.raw, 0));
+       if (skb->ip_summed == CHECKSUM_COMPLETE)
+               skb->csum = csum_sub(skb->csum,
+                                    csum_partial(skb->nh.raw, (u8*)(fhdr+1)-skb->nh.raw, 0));
 
        /* Is this the final fragment? */
        if (!(fhdr->frag_off & htons(IP6_MF))) {
@@ -464,7 +464,7 @@ static void ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb,
                         */
                        IP6_INC_STATS_BH(ip6_dst_idev(skb->dst),
                                         IPSTATS_MIB_INHDRERRORS);
-                       icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, 
+                       icmpv6_param_prob(skb, ICMPV6_HDR_FIELD,
                                          offsetof(struct ipv6hdr, payload_len));
                        return;
                }
@@ -482,7 +482,7 @@ static void ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb,
        /* Point into the IP datagram 'data' part. */
        if (!pskb_pull(skb, (u8 *) (fhdr + 1) - skb->data))
                goto err;
-       
+
        if (pskb_trim_rcsum(skb, end - offset))
                goto err;
 
@@ -640,7 +640,7 @@ static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff **skb_in,
         * header in order to calculate ICV correctly. */
        nhoff = fq->nhoffset;
        head->nh.raw[nhoff] = head->h.raw[0];
-       memmove(head->head + sizeof(struct frag_hdr), head->head, 
+       memmove(head->head + sizeof(struct frag_hdr), head->head,
                (head->data - head->head) - sizeof(struct frag_hdr));
        head->mac.raw += sizeof(struct frag_hdr);
        head->nh.raw += sizeof(struct frag_hdr);
@@ -695,7 +695,7 @@ out_fail:
 
 static int ipv6_frag_rcv(struct sk_buff **skbp)
 {
-       struct sk_buff *skb = *skbp; 
+       struct sk_buff *skb = *skbp;
        struct net_device *dev = skb->dev;
        struct frag_hdr *fhdr;
        struct frag_queue *fq;
index 5f0043c30b70477c423a629a591899543e084415..a415ac610e2d76ca6a06da566c4e2c6f847b2945 100644 (file)
@@ -3,7 +3,7 @@
  *     FIB front-end.
  *
  *     Authors:
- *     Pedro Roque             <roque@di.fc.ul.pt>     
+ *     Pedro Roque             <roque@di.fc.ul.pt>
  *
  *     $Id: route.c,v 1.56 2001/10/31 21:55:55 davem Exp $
  *
@@ -201,7 +201,7 @@ static void ip6_dst_destroy(struct dst_entry *dst)
        if (idev != NULL) {
                rt->rt6i_idev = NULL;
                in6_dev_put(idev);
-       }       
+       }
 }
 
 static void ip6_dst_ifdown(struct dst_entry *dst, struct net_device *dev,
@@ -243,7 +243,7 @@ static __inline__ struct rt6_info *rt6_device_match(struct rt6_info *rt,
        struct rt6_info *sprt;
 
        if (oif) {
-               for (sprt = rt; sprt; sprt = sprt->u.next) {
+               for (sprt = rt; sprt; sprt = sprt->u.dst.rt6_next) {
                        struct net_device *dev = sprt->rt6i_dev;
                        if (dev->ifindex == oif)
                                return sprt;
@@ -252,7 +252,7 @@ static __inline__ struct rt6_info *rt6_device_match(struct rt6_info *rt,
                                    sprt->rt6i_idev->dev->ifindex != oif) {
                                        if (strict && oif)
                                                continue;
-                                       if (local && (!oif || 
+                                       if (local && (!oif ||
                                                      local->rt6i_idev->dev->ifindex == oif))
                                                continue;
                                }
@@ -311,12 +311,21 @@ static inline void rt6_probe(struct rt6_info *rt)
 static int inline rt6_check_dev(struct rt6_info *rt, int oif)
 {
        struct net_device *dev = rt->rt6i_dev;
-       if (!oif || dev->ifindex == oif)
+       int ret = 0;
+
+       if (!oif)
                return 2;
-       if ((dev->flags & IFF_LOOPBACK) &&
-           rt->rt6i_idev && rt->rt6i_idev->dev->ifindex == oif)
-               return 1;
-       return 0;
+       if (dev->flags & IFF_LOOPBACK) {
+               if (!WARN_ON(rt->rt6i_idev == NULL) &&
+                   rt->rt6i_idev->dev->ifindex == oif)
+                       ret = 1;
+               else
+                       return 0;
+       }
+       if (dev->ifindex == oif)
+               return 2;
+
+       return ret;
 }
 
 static int inline rt6_check_neigh(struct rt6_info *rt)
@@ -341,7 +350,7 @@ static int rt6_score_route(struct rt6_info *rt, int oif,
                           int strict)
 {
        int m, n;
-               
+
        m = rt6_check_dev(rt, oif);
        if (!m && (strict & RT6_LOOKUP_F_IFACE))
                return -1;
@@ -367,7 +376,7 @@ static struct rt6_info *rt6_select(struct rt6_info **head, int oif,
 
        for (rt = rt0, metric = rt0->rt6i_metric;
             rt && rt->rt6i_metric == metric && (!last || rt != rt0);
-            rt = rt->u.next) {
+            rt = rt->u.dst.rt6_next) {
                int m;
 
                if (rt6_check_expired(rt))
@@ -395,9 +404,9 @@ static struct rt6_info *rt6_select(struct rt6_info **head, int oif,
                /* no entries matched; do round-robin */
                static DEFINE_SPINLOCK(lock);
                spin_lock(&lock);
-               *head = rt0->u.next;
-               rt0->u.next = last->u.next;
-               last->u.next = rt0;
+               *head = rt0->u.dst.rt6_next;
+               rt0->u.dst.rt6_next = last->u.dst.rt6_next;
+               last->u.dst.rt6_next = rt0;
                spin_unlock(&lock);
        }
 
@@ -714,7 +723,7 @@ void ip6_route_input(struct sk_buff *skb)
                                .flowlabel = (* (__be32 *) iph)&IPV6_FLOWINFO_MASK,
                        },
                },
-               .mark = skb->mark,
+               .mark = skb->mark,
                .proto = iph->nexthdr,
        };
 
@@ -879,9 +888,9 @@ static inline unsigned int ipv6_advmss(unsigned int mtu)
                mtu = ip6_rt_min_advmss;
 
        /*
-        * Maximal non-jumbo IPv6 payload is IPV6_MAXPLEN and 
-        * corresponding MSS is IPV6_MAXPLEN - tcp_header_size. 
-        * IPV6_MAXPLEN is also valid and means: "any MSS, 
+        * Maximal non-jumbo IPv6 payload is IPV6_MAXPLEN and
+        * corresponding MSS is IPV6_MAXPLEN - tcp_header_size.
+        * IPV6_MAXPLEN is also valid and means: "any MSS,
         * rely only on pmtu discovery"
         */
        if (mtu > IPV6_MAXPLEN - sizeof(struct tcphdr))
@@ -892,7 +901,7 @@ static inline unsigned int ipv6_advmss(unsigned int mtu)
 static struct dst_entry *ndisc_dst_gc_list;
 static DEFINE_SPINLOCK(ndisc_lock);
 
-struct dst_entry *ndisc_dst_alloc(struct net_device *dev, 
+struct dst_entry *ndisc_dst_alloc(struct net_device *dev,
                                  struct neighbour *neigh,
                                  struct in6_addr *addr,
                                  int (*output)(struct sk_buff *))
@@ -925,8 +934,8 @@ struct dst_entry *ndisc_dst_alloc(struct net_device *dev,
        rt->u.dst.output  = output;
 
 #if 0  /* there's no chance to use these for ndisc */
-       rt->u.dst.flags   = ipv6_addr_type(addr) & IPV6_ADDR_UNICAST 
-                               ? DST_HOST 
+       rt->u.dst.flags   = ipv6_addr_type(addr) & IPV6_ADDR_UNICAST
+                               ? DST_HOST
                                : 0;
        ipv6_addr_copy(&rt->rt6i_dst.addr, addr);
        rt->rt6i_dst.plen = 128;
@@ -949,7 +958,7 @@ int ndisc_dst_gc(int *more)
        int freed;
 
        next = NULL;
-       freed = 0;
+       freed = 0;
 
        spin_lock_bh(&ndisc_lock);
        pprev = &ndisc_dst_gc_list;
@@ -1267,9 +1276,9 @@ static int ip6_route_del(struct fib6_config *cfg)
        fn = fib6_locate(&table->tb6_root,
                         &cfg->fc_dst, cfg->fc_dst_len,
                         &cfg->fc_src, cfg->fc_src_len);
-       
+
        if (fn) {
-               for (rt = fn->leaf; rt; rt = rt->u.next) {
+               for (rt = fn->leaf; rt; rt = rt->u.dst.rt6_next) {
                        if (cfg->fc_ifindex &&
                            (rt->rt6i_dev == NULL ||
                             rt->rt6i_dev->ifindex != cfg->fc_ifindex))
@@ -1320,7 +1329,7 @@ static struct rt6_info *__ip6_route_redirect(struct fib6_table *table,
        read_lock_bh(&table->tb6_lock);
        fn = fib6_lookup(&table->tb6_root, &fl->fl6_dst, &fl->fl6_src);
 restart:
-       for (rt = fn->leaf; rt; rt = rt->u.next) {
+       for (rt = fn->leaf; rt; rt = rt->u.dst.rt6_next) {
                /*
                 * Current route is on-link; redirect is always invalid.
                 *
@@ -1396,7 +1405,7 @@ void rt6_redirect(struct in6_addr *dest, struct in6_addr *src,
         *      We have finally decided to accept it.
         */
 
-       neigh_update(neigh, lladdr, NUD_STALE, 
+       neigh_update(neigh, lladdr, NUD_STALE,
                     NEIGH_UPDATE_F_WEAK_OVERRIDE|
                     NEIGH_UPDATE_F_OVERRIDE|
                     (on_link ? 0 : (NEIGH_UPDATE_F_OVERRIDE_ISROUTER|
@@ -1445,7 +1454,7 @@ void rt6_redirect(struct in6_addr *dest, struct in6_addr *src,
        }
 
 out:
-        dst_release(&rt->u.dst);
+       dst_release(&rt->u.dst);
        return;
 }
 
@@ -1469,7 +1478,7 @@ void rt6_pmtu_discovery(struct in6_addr *daddr, struct in6_addr *saddr,
 
        if (pmtu < IPV6_MIN_MTU) {
                /*
-                * According to RFC2460, PMTU is set to the IPv6 Minimum Link 
+                * According to RFC2460, PMTU is set to the IPv6 Minimum Link
                 * MTU (1280) and a fragment header should always be included
                 * after a node receiving Too Big message reporting PMTU is
                 * less than the IPv6 Minimum Link MTU.
@@ -1581,7 +1590,7 @@ static struct rt6_info *rt6_get_route_info(struct in6_addr *prefix, int prefixle
        if (!fn)
                goto out;
 
-       for (rt = fn->leaf; rt; rt = rt->u.next) {
+       for (rt = fn->leaf; rt; rt = rt->u.dst.rt6_next) {
                if (rt->rt6i_dev->ifindex != ifindex)
                        continue;
                if ((rt->rt6i_flags & (RTF_ROUTEINFO|RTF_GATEWAY)) != (RTF_ROUTEINFO|RTF_GATEWAY))
@@ -1623,7 +1632,7 @@ static struct rt6_info *rt6_add_route_info(struct in6_addr *prefix, int prefixle
 #endif
 
 struct rt6_info *rt6_get_dflt_router(struct in6_addr *addr, struct net_device *dev)
-{      
+{
        struct rt6_info *rt;
        struct fib6_table *table;
 
@@ -1632,7 +1641,7 @@ struct rt6_info *rt6_get_dflt_router(struct in6_addr *addr, struct net_device *d
                return NULL;
 
        write_lock_bh(&table->tb6_lock);
-       for (rt = table->tb6_root.leaf; rt; rt=rt->u.next) {
+       for (rt = table->tb6_root.leaf; rt; rt=rt->u.dst.rt6_next) {
                if (dev == rt->rt6i_dev &&
                    ((rt->rt6i_flags & (RTF_ADDRCONF | RTF_DEFAULT)) == (RTF_ADDRCONF | RTF_DEFAULT)) &&
                    ipv6_addr_equal(&rt->rt6i_gateway, addr))
@@ -1675,7 +1684,7 @@ void rt6_purge_dflt_routers(void)
 
 restart:
        read_lock_bh(&table->tb6_lock);
-       for (rt = table->tb6_root.leaf; rt; rt = rt->u.next) {
+       for (rt = table->tb6_root.leaf; rt; rt = rt->u.dst.rt6_next) {
                if (rt->rt6i_flags & (RTF_DEFAULT | RTF_ADDRCONF)) {
                        dst_hold(&rt->u.dst);
                        read_unlock_bh(&table->tb6_lock);
@@ -1887,8 +1896,8 @@ static int rt6_mtu_change_route(struct rt6_info *rt, void *p_arg)
         */
        if (rt->rt6i_dev == arg->dev &&
            !dst_metric_locked(&rt->u.dst, RTAX_MTU) &&
-            (dst_mtu(&rt->u.dst) > arg->mtu ||
-             (dst_mtu(&rt->u.dst) < arg->mtu &&
+           (dst_mtu(&rt->u.dst) > arg->mtu ||
+            (dst_mtu(&rt->u.dst) < arg->mtu &&
              dst_mtu(&rt->u.dst) == idev->cnf.mtu6)))
                rt->u.dst.metrics[RTAX_MTU-1] = arg->mtu;
        rt->u.dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(arg->mtu);
@@ -2040,7 +2049,7 @@ static int rt6_fill_node(struct sk_buff *skb, struct rt6_info *rt,
 
        nlh = nlmsg_put(skb, pid, seq, type, sizeof(*rtm), flags);
        if (nlh == NULL)
-               return -ENOBUFS;
+               return -EMSGSIZE;
 
        rtm = nlmsg_data(nlh);
        rtm->rtm_family = AF_INET6;
@@ -2074,13 +2083,13 @@ static int rt6_fill_node(struct sk_buff *skb, struct rt6_info *rt,
 
        if (dst) {
                NLA_PUT(skb, RTA_DST, 16, dst);
-               rtm->rtm_dst_len = 128;
+               rtm->rtm_dst_len = 128;
        } else if (rtm->rtm_dst_len)
                NLA_PUT(skb, RTA_DST, 16, &rt->rt6i_dst.addr);
 #ifdef CONFIG_IPV6_SUBTREES
        if (src) {
                NLA_PUT(skb, RTA_SRC, 16, src);
-               rtm->rtm_src_len = 128;
+               rtm->rtm_src_len = 128;
        } else if (rtm->rtm_src_len)
                NLA_PUT(skb, RTA_SRC, 16, &rt->rt6i_src.addr);
 #endif
@@ -2111,7 +2120,8 @@ static int rt6_fill_node(struct sk_buff *skb, struct rt6_info *rt,
        return nlmsg_end(skb, nlh);
 
 nla_put_failure:
-       return nlmsg_cancel(skb, nlh);
+       nlmsg_cancel(skb, nlh);
+       return -EMSGSIZE;
 }
 
 int rt6_dump_route(struct rt6_info *rt, void *p_arg)
@@ -2222,9 +2232,12 @@ void inet6_rt_notify(int event, struct rt6_info *rt, struct nl_info *info)
                goto errout;
 
        err = rt6_fill_node(skb, rt, NULL, NULL, 0, event, pid, seq, 0, 0);
-       /* failure implies BUG in rt6_nlmsg_size() */
-       BUG_ON(err < 0);
-
+       if (err < 0) {
+               /* -EMSGSIZE implies BUG in rt6_nlmsg_size() */
+               WARN_ON(err == -EMSGSIZE);
+               kfree_skb(skb);
+               goto errout;
+       }
        err = rtnl_notify(skb, pid, RTNLGRP_IPV6_ROUTE, nlh, gfp_any());
 errout:
        if (err < 0)
@@ -2286,7 +2299,7 @@ static int rt6_info_route(struct rt6_info *rt, void *p_arg)
        arg->len += sprintf(arg->buffer + arg->len,
                            " %08x %08x %08x %08x %8s\n",
                            rt->rt6i_metric, atomic_read(&rt->u.dst.__refcnt),
-                           rt->u.dst.__use, rt->rt6i_flags, 
+                           rt->u.dst.__use, rt->rt6i_flags,
                            rt->rt6i_dev ? rt->rt6i_dev->name : "");
        return 0;
 }
@@ -2358,91 +2371,91 @@ int ipv6_sysctl_rtcache_flush(ctl_table *ctl, int write, struct file * filp,
 }
 
 ctl_table ipv6_route_table[] = {
-        {
-               .ctl_name       =       NET_IPV6_ROUTE_FLUSH, 
+       {
+               .ctl_name       =       NET_IPV6_ROUTE_FLUSH,
                .procname       =       "flush",
-               .data           =       &flush_delay,
+               .data           =       &flush_delay,
                .maxlen         =       sizeof(int),
                .mode           =       0200,
-               .proc_handler   =       &ipv6_sysctl_rtcache_flush
+               .proc_handler   =       &ipv6_sysctl_rtcache_flush
        },
        {
                .ctl_name       =       NET_IPV6_ROUTE_GC_THRESH,
                .procname       =       "gc_thresh",
-               .data           =       &ip6_dst_ops.gc_thresh,
+               .data           =       &ip6_dst_ops.gc_thresh,
                .maxlen         =       sizeof(int),
                .mode           =       0644,
-               .proc_handler   =       &proc_dointvec,
+               .proc_handler   =       &proc_dointvec,
        },
        {
                .ctl_name       =       NET_IPV6_ROUTE_MAX_SIZE,
                .procname       =       "max_size",
-               .data           =       &ip6_rt_max_size,
+               .data           =       &ip6_rt_max_size,
                .maxlen         =       sizeof(int),
                .mode           =       0644,
-               .proc_handler   =       &proc_dointvec,
+               .proc_handler   =       &proc_dointvec,
        },
        {
                .ctl_name       =       NET_IPV6_ROUTE_GC_MIN_INTERVAL,
                .procname       =       "gc_min_interval",
-               .data           =       &ip6_rt_gc_min_interval,
+               .data           =       &ip6_rt_gc_min_interval,
                .maxlen         =       sizeof(int),
                .mode           =       0644,
-               .proc_handler   =       &proc_dointvec_jiffies,
+               .proc_handler   =       &proc_dointvec_jiffies,
                .strategy       =       &sysctl_jiffies,
        },
        {
                .ctl_name       =       NET_IPV6_ROUTE_GC_TIMEOUT,
                .procname       =       "gc_timeout",
-               .data           =       &ip6_rt_gc_timeout,
+               .data           =       &ip6_rt_gc_timeout,
                .maxlen         =       sizeof(int),
                .mode           =       0644,
-               .proc_handler   =       &proc_dointvec_jiffies,
+               .proc_handler   =       &proc_dointvec_jiffies,
                .strategy       =       &sysctl_jiffies,
        },
        {
                .ctl_name       =       NET_IPV6_ROUTE_GC_INTERVAL,
                .procname       =       "gc_interval",
-               .data           =       &ip6_rt_gc_interval,
+               .data           =       &ip6_rt_gc_interval,
                .maxlen         =       sizeof(int),
                .mode           =       0644,
-               .proc_handler   =       &proc_dointvec_jiffies,
+               .proc_handler   =       &proc_dointvec_jiffies,
                .strategy       =       &sysctl_jiffies,
        },
        {
                .ctl_name       =       NET_IPV6_ROUTE_GC_ELASTICITY,
                .procname       =       "gc_elasticity",
-               .data           =       &ip6_rt_gc_elasticity,
+               .data           =       &ip6_rt_gc_elasticity,
                .maxlen         =       sizeof(int),
                .mode           =       0644,
-               .proc_handler   =       &proc_dointvec_jiffies,
+               .proc_handler   =       &proc_dointvec_jiffies,
                .strategy       =       &sysctl_jiffies,
        },
        {
                .ctl_name       =       NET_IPV6_ROUTE_MTU_EXPIRES,
                .procname       =       "mtu_expires",
-               .data           =       &ip6_rt_mtu_expires,
+               .data           =       &ip6_rt_mtu_expires,
                .maxlen         =       sizeof(int),
                .mode           =       0644,
-               .proc_handler   =       &proc_dointvec_jiffies,
+               .proc_handler   =       &proc_dointvec_jiffies,
                .strategy       =       &sysctl_jiffies,
        },
        {
                .ctl_name       =       NET_IPV6_ROUTE_MIN_ADVMSS,
                .procname       =       "min_adv_mss",
-               .data           =       &ip6_rt_min_advmss,
+               .data           =       &ip6_rt_min_advmss,
                .maxlen         =       sizeof(int),
                .mode           =       0644,
-               .proc_handler   =       &proc_dointvec_jiffies,
+               .proc_handler   =       &proc_dointvec_jiffies,
                .strategy       =       &sysctl_jiffies,
        },
        {
                .ctl_name       =       NET_IPV6_ROUTE_GC_MIN_INTERVAL_MS,
                .procname       =       "gc_min_interval_ms",
-               .data           =       &ip6_rt_gc_min_interval,
+               .data           =       &ip6_rt_gc_min_interval,
                .maxlen         =       sizeof(int),
                .mode           =       0644,
-               .proc_handler   =       &proc_dointvec_ms_jiffies,
+               .proc_handler   =       &proc_dointvec_ms_jiffies,
                .strategy       =       &sysctl_ms_jiffies,
        },
        { .ctl_name = 0 }
index 77b7b091143887b1cf5528365453e9ed696a17eb..4d3cf301e1fc92de72bec69dc34ebfd26d374196 100644 (file)
@@ -3,7 +3,7 @@
  *     Linux INET6 implementation
  *
  *     Authors:
- *     Pedro Roque             <roque@di.fc.ul.pt>     
+ *     Pedro Roque             <roque@di.fc.ul.pt>
  *     Alexey Kuznetsov        <kuznet@ms2.inr.ac.ru>
  *
  *     $Id: sit.c,v 1.53 2001/09/25 05:09:53 davem Exp $
@@ -410,7 +410,7 @@ static inline __be32 try_6to4(struct in6_addr *v6dst)
        __be32 dst = 0;
 
        if (v6dst->s6_addr16[0] == htons(0x2002)) {
-               /* 6to4 v6 addr has 16 bits prefix, 32 v4addr, 16 SLA, ... */
+               /* 6to4 v6 addr has 16 bits prefix, 32 v4addr, 16 SLA, ... */
                memcpy(&dst, &v6dst->s6_addr16[1], 4);
        }
        return dst;
@@ -434,7 +434,7 @@ static int ipip6_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
        int    max_headroom;                    /* The extra header space needed */
        __be32 dst = tiph->daddr;
        int    mtu;
-       struct in6_addr *addr6; 
+       struct in6_addr *addr6;
        int addr_type;
 
        if (tunnel->recursion++) {
@@ -537,7 +537,7 @@ static int ipip6_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
                struct sk_buff *new_skb = skb_realloc_headroom(skb, max_headroom);
                if (!new_skb) {
                        ip_rt_put(rt);
-                       stats->tx_dropped++;
+                       stats->tx_dropped++;
                        dev_kfree_skb(skb);
                        tunnel->recursion--;
                        return 0;
@@ -686,7 +686,8 @@ ipip6_tunnel_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd)
                                goto done;
                        dev = t->dev;
                }
-               err = unregister_netdevice(dev);
+               unregister_netdevice(dev);
+               err = 0;
                break;
 
        default:
@@ -830,7 +831,7 @@ static int __init sit_init(void)
                return -EAGAIN;
        }
 
-       ipip6_fb_tunnel_dev = alloc_netdev(sizeof(struct ip_tunnel), "sit0", 
+       ipip6_fb_tunnel_dev = alloc_netdev(sizeof(struct ip_tunnel), "sit0",
                                           ipip6_tunnel_setup);
        if (!ipip6_fb_tunnel_dev) {
                err = -ENOMEM;
index 7a4639db13464bf6f6c87af2312680fe736d2561..25e8e7783feefd0a3b374f7cda5d70f73de3cb92 100644 (file)
@@ -92,7 +92,7 @@ static ctl_table ipv6_net_table[] = {
                .mode           = 0555,
                .child          = ipv6_table
        },
-        { .ctl_name = 0 }
+       { .ctl_name = 0 }
 };
 
 static ctl_table ipv6_root_table[] = {
@@ -102,7 +102,7 @@ static ctl_table ipv6_root_table[] = {
                .mode           = 0555,
                .child          = ipv6_net_table
        },
-        { .ctl_name = 0 }
+       { .ctl_name = 0 }
 };
 
 void ipv6_sysctl_register(void)
index c25e930c2c6963d8e5d8aac4053e505cb83eedcf..f57a9baa6b272417af7c1f705b44ae605891f70a 100644 (file)
@@ -1,13 +1,13 @@
 /*
  *     TCP over IPv6
- *     Linux INET6 implementation 
+ *     Linux INET6 implementation
  *
  *     Authors:
- *     Pedro Roque             <roque@di.fc.ul.pt>     
+ *     Pedro Roque             <roque@di.fc.ul.pt>
  *
  *     $Id: tcp_ipv6.c,v 1.144 2002/02/01 22:01:04 davem Exp $
  *
- *     Based on: 
+ *     Based on:
  *     linux/net/ipv4/tcp.c
  *     linux/net/ipv4/tcp_input.c
  *     linux/net/ipv4/tcp_output.c
@@ -74,7 +74,7 @@ static struct socket *tcp6_socket;
 
 static void    tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb);
 static void    tcp_v6_reqsk_send_ack(struct sk_buff *skb, struct request_sock *req);
-static void    tcp_v6_send_check(struct sock *sk, int len, 
+static void    tcp_v6_send_check(struct sock *sk, int len,
                                  struct sk_buff *skb);
 
 static int     tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb);
@@ -106,8 +106,8 @@ static void tcp_v6_hash(struct sock *sk)
 }
 
 static __inline__ __sum16 tcp_v6_check(struct tcphdr *th, int len,
-                                  struct in6_addr *saddr, 
-                                  struct in6_addr *daddr, 
+                                  struct in6_addr *saddr,
+                                  struct in6_addr *daddr,
                                   __wsum base)
 {
        return csum_ipv6_magic(saddr, daddr, len, IPPROTO_TCP, base);
@@ -121,11 +121,11 @@ static __u32 tcp_v6_init_sequence(struct sk_buff *skb)
                                            skb->h.th->source);
 }
 
-static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr, 
+static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
                          int addr_len)
 {
        struct sockaddr_in6 *usin = (struct sockaddr_in6 *) uaddr;
-       struct inet_sock *inet = inet_sk(sk);
+       struct inet_sock *inet = inet_sk(sk);
        struct inet_connection_sock *icsk = inet_csk(sk);
        struct ipv6_pinfo *np = inet6_sk(sk);
        struct tcp_sock *tp = tcp_sk(sk);
@@ -135,10 +135,10 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
        int addr_type;
        int err;
 
-       if (addr_len < SIN6_LEN_RFC2133) 
+       if (addr_len < SIN6_LEN_RFC2133)
                return -EINVAL;
 
-       if (usin->sin6_family != AF_INET6) 
+       if (usin->sin6_family != AF_INET6)
                return(-EAFNOSUPPORT);
 
        memset(&fl, 0, sizeof(fl));
@@ -157,11 +157,11 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
        }
 
        /*
-        *      connect() to INADDR_ANY means loopback (BSD'ism).
-        */
-       
-       if(ipv6_addr_any(&usin->sin6_addr))
-               usin->sin6_addr.s6_addr[15] = 0x1; 
+        *      connect() to INADDR_ANY means loopback (BSD'ism).
+        */
+
+       if(ipv6_addr_any(&usin->sin6_addr))
+               usin->sin6_addr.s6_addr[15] = 0x1;
 
        addr_type = ipv6_addr_type(&usin->sin6_addr);
 
@@ -265,7 +265,7 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
        if (final_p)
                ipv6_addr_copy(&fl.fl6_dst, final_p);
 
-       if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0)
+       if ((err = xfrm_lookup(&dst, &fl, sk, 1)) < 0)
                goto failure;
 
        if (saddr == NULL) {
@@ -323,7 +323,7 @@ static void tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
        struct ipv6_pinfo *np;
        struct sock *sk;
        int err;
-       struct tcp_sock *tp; 
+       struct tcp_sock *tp;
        __u32 seq;
 
        sk = inet6_lookup(&tcp_hashinfo, &hdr->daddr, th->dest, &hdr->saddr,
@@ -347,7 +347,7 @@ static void tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
                goto out;
 
        tp = tcp_sk(sk);
-       seq = ntohl(th->seq); 
+       seq = ntohl(th->seq);
        if (sk->sk_state != TCP_LISTEN &&
            !between(seq, tp->snd_una, tp->snd_nxt)) {
                NET_INC_STATS_BH(LINUX_MIB_OUTOFWINDOWICMPS);
@@ -434,7 +434,7 @@ static void tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
 
        case TCP_SYN_SENT:
        case TCP_SYN_RECV:  /* Cannot happen.
-                              It can, it SYNs are crossed. --ANK */ 
+                              It can, it SYNs are crossed. --ANK */
                if (!sock_owned_by_user(sk)) {
                        sk->sk_err = err;
                        sk->sk_error_report(sk);                /* Wake people up to see the error (see connect in sock.c) */
@@ -519,7 +519,7 @@ static int tcp_v6_send_synack(struct sock *sk, struct request_sock *req,
        }
 
 done:
-        if (opt && opt != np->opt)
+       if (opt && opt != np->opt)
                sock_kfree_s(sk, opt, opt->tot_len);
        dst_release(dst);
        return err;
@@ -950,8 +950,8 @@ static void tcp_v6_send_check(struct sock *sk, int len, struct sk_buff *skb)
                th->check = ~csum_ipv6_magic(&np->saddr, &np->daddr, len, IPPROTO_TCP,  0);
                skb->csum_offset = offsetof(struct tcphdr, check);
        } else {
-               th->check = csum_ipv6_magic(&np->saddr, &np->daddr, len, IPPROTO_TCP, 
-                                           csum_partial((char *)th, th->doff<<2, 
+               th->check = csum_ipv6_magic(&np->saddr, &np->daddr, len, IPPROTO_TCP,
+                                           csum_partial((char *)th, th->doff<<2,
                                                         skb->csum));
        }
 }
@@ -977,7 +977,7 @@ static int tcp_v6_gso_send_check(struct sk_buff *skb)
 
 static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb)
 {
-       struct tcphdr *th = skb->h.th, *t1; 
+       struct tcphdr *th = skb->h.th, *t1;
        struct sk_buff *buff;
        struct flowi fl;
        int tot_len = sizeof(*th);
@@ -989,7 +989,7 @@ static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb)
                return;
 
        if (!ipv6_unicast_destination(skb))
-               return; 
+               return;
 
 #ifdef CONFIG_TCP_MD5SIG
        if (sk)
@@ -1008,8 +1008,8 @@ static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb)
 
        buff = alloc_skb(MAX_HEADER + sizeof(struct ipv6hdr) + tot_len,
                         GFP_ATOMIC);
-       if (buff == NULL) 
-               return;
+       if (buff == NULL)
+               return;
 
        skb_reserve(buff, MAX_HEADER + sizeof(struct ipv6hdr) + tot_len);
 
@@ -1021,9 +1021,9 @@ static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb)
        t1->source = th->dest;
        t1->doff = tot_len / 4;
        t1->rst = 1;
-  
+
        if(th->ack) {
-               t1->seq = th->ack_seq;
+               t1->seq = th->ack_seq;
        } else {
                t1->ack = 1;
                t1->ack_seq = htonl(ntohl(th->seq) + th->syn + th->fin
@@ -1128,7 +1128,7 @@ static void tcp_v6_send_ack(struct tcp_timewait_sock *tw,
        t1->window = htons(win);
 
        topt = (__be32 *)(t1 + 1);
-       
+
        if (ts) {
                *topt++ = htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) |
                                (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP);
@@ -1243,15 +1243,15 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
                return tcp_v4_conn_request(sk, skb);
 
        if (!ipv6_unicast_destination(skb))
-               goto drop; 
+               goto drop;
 
        /*
-        *      There are no SYN attacks on IPv6, yet...        
+        *      There are no SYN attacks on IPv6, yet...
         */
        if (inet_csk_reqsk_queue_is_full(sk) && !isn) {
                if (net_ratelimit())
                        printk(KERN_INFO "TCPv6: dropping request, synflood is possible\n");
-               goto drop;              
+               goto drop;
        }
 
        if (sk_acceptq_is_full(sk) && inet_csk_reqsk_queue_young(sk) > 1)
@@ -1292,7 +1292,7 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
            ipv6_addr_type(&treq->rmt_addr) & IPV6_ADDR_LINKLOCAL)
                treq->iif = inet6_iif(skb);
 
-       if (isn == 0) 
+       if (isn == 0)
                isn = tcp_v6_init_sequence(skb);
 
        tcp_rsk(req)->snt_isn = isn;
@@ -1334,7 +1334,7 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
 
                newsk = tcp_v4_syn_recv_sock(sk, skb, req, dst);
 
-               if (newsk == NULL) 
+               if (newsk == NULL)
                        return NULL;
 
                newtcp6sk = (struct tcp6_sock *)newsk;
@@ -1419,7 +1419,7 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
 
                if ((xfrm_lookup(&dst, &fl, sk, 0)) < 0)
                        goto out;
-       } 
+       }
 
        newsk = tcp_create_openreq_child(sk, req, skb);
        if (newsk == NULL)
@@ -1448,7 +1448,7 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
        ipv6_addr_copy(&newnp->rcv_saddr, &treq->loc_addr);
        newsk->sk_bound_dev_if = treq->iif;
 
-       /* Now IPv6 options... 
+       /* Now IPv6 options...
 
           First: no IPv4 options.
         */
@@ -1592,7 +1592,7 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
           looks not very well thought. For now we latch
           options, received in the last packet, enqueued
           by tcp. Feel free to propose better solution.
-                                              --ANK (980728)
+                                              --ANK (980728)
         */
        if (np->rxopt.all)
                opt_skb = skb_clone(skb, GFP_ATOMIC);
@@ -1610,7 +1610,7 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
        if (skb->len < (skb->h.th->doff<<2) || tcp_checksum_complete(skb))
                goto csum_err;
 
-       if (sk->sk_state == TCP_LISTEN) { 
+       if (sk->sk_state == TCP_LISTEN) {
                struct sock *nsk = tcp_v6_hnd_req(sk, skb);
                if (!nsk)
                        goto discard;
@@ -1620,7 +1620,7 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
                 * otherwise we just shortcircuit this and continue with
                 * the new socket..
                 */
-               if(nsk != sk) {
+               if(nsk != sk) {
                        if (tcp_child_process(sk, nsk, skb))
                                goto reset;
                        if (opt_skb)
@@ -1681,7 +1681,7 @@ ipv6_pktoptions:
 static int tcp_v6_rcv(struct sk_buff **pskb)
 {
        struct sk_buff *skb = *pskb;
-       struct tcphdr *th;      
+       struct tcphdr *th;
        struct sock *sk;
        int ret;
 
@@ -1739,10 +1739,10 @@ process:
        ret = 0;
        if (!sock_owned_by_user(sk)) {
 #ifdef CONFIG_NET_DMA
-                struct tcp_sock *tp = tcp_sk(sk);
-                if (tp->ucopy.dma_chan)
-                        ret = tcp_v6_do_rcv(sk, skb);
-                else
+               struct tcp_sock *tp = tcp_sk(sk);
+               if (tp->ucopy.dma_chan)
+                       ret = tcp_v6_do_rcv(sk, skb);
+               else
 #endif
                {
                        if (!tcp_prequeue(sk, skb))
@@ -1945,7 +1945,7 @@ static int tcp_v6_destroy_sock(struct sock *sk)
 }
 
 /* Proc filesystem TCPv6 sock list dumping. */
-static void get_openreq6(struct seq_file *seq, 
+static void get_openreq6(struct seq_file *seq,
                         struct sock *sk, struct request_sock *req, int i, int uid)
 {
        int ttd = req->expires - jiffies;
@@ -1967,11 +1967,11 @@ static void get_openreq6(struct seq_file *seq,
                   ntohs(inet_rsk(req)->rmt_port),
                   TCP_SYN_RECV,
                   0,0, /* could print option size, but that is af dependent. */
-                  1,   /* timers active (only the expire timer) */  
-                  jiffies_to_clock_t(ttd), 
+                  1,   /* timers active (only the expire timer) */
+                  jiffies_to_clock_t(ttd),
                   req->retrans,
                   uid,
-                  0,  /* non standard timer */  
+                  0,  /* non standard timer */
                   0, /* open_requests have no inode */
                   0, req);
 }
@@ -2014,7 +2014,7 @@ static void get_tcp6_sock(struct seq_file *seq, struct sock *sp, int i)
                   src->s6_addr32[2], src->s6_addr32[3], srcp,
                   dest->s6_addr32[0], dest->s6_addr32[1],
                   dest->s6_addr32[2], dest->s6_addr32[3], destp,
-                  sp->sk_state, 
+                  sp->sk_state,
                   tp->write_seq-tp->snd_una,
                   (sp->sk_state == TCP_LISTEN) ? sp->sk_ack_backlog : (tp->rcv_nxt - tp->copied_seq),
                   timer_active,
@@ -2031,7 +2031,7 @@ static void get_tcp6_sock(struct seq_file *seq, struct sock *sp, int i)
                   );
 }
 
-static void get_timewait6_sock(struct seq_file *seq, 
+static void get_timewait6_sock(struct seq_file *seq,
                               struct inet_timewait_sock *tw, int i)
 {
        struct in6_addr *dest, *src;
index f52a5c3cc0a36d5a4f64956b2d57bd4720067894..ccf2f4d196beb27489a320c926f8a85b28b52407 100644 (file)
@@ -1,9 +1,9 @@
 /*
  *     UDP over IPv6
- *     Linux INET6 implementation 
+ *     Linux INET6 implementation
  *
  *     Authors:
- *     Pedro Roque             <roque@di.fc.ul.pt>     
+ *     Pedro Roque             <roque@di.fc.ul.pt>
  *
  *     Based on linux/ipv4/udp.c
  *
@@ -67,11 +67,11 @@ static struct sock *__udp6_lib_lookup(struct in6_addr *saddr, __be16 sport,
        unsigned short hnum = ntohs(dport);
        int badness = -1;
 
-       read_lock(&udp_hash_lock);
+       read_lock(&udp_hash_lock);
        sk_for_each(sk, node, &udptable[hnum & (UDP_HTABLE_SIZE - 1)]) {
                struct inet_sock *inet = inet_sk(sk);
 
-               if (inet->num == hnum && sk->sk_family == PF_INET6) {
+               if (sk->sk_hash == hnum && sk->sk_family == PF_INET6) {
                        struct ipv6_pinfo *np = inet6_sk(sk);
                        int score = 0;
                        if (inet->dport) {
@@ -105,7 +105,7 @@ static struct sock *__udp6_lib_lookup(struct in6_addr *saddr, __be16 sport,
        }
        if (result)
                sock_hold(result);
-       read_unlock(&udp_hash_lock);
+       read_unlock(&udp_hash_lock);
        return result;
 }
 
@@ -120,13 +120,13 @@ int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk,
 {
        struct ipv6_pinfo *np = inet6_sk(sk);
        struct inet_sock *inet = inet_sk(sk);
-       struct sk_buff *skb;
+       struct sk_buff *skb;
        size_t copied;
        int err, copy_only, is_udplite = IS_UDPLITE(sk);
 
-       if (addr_len)
-               *addr_len=sizeof(struct sockaddr_in6);
-  
+       if (addr_len)
+               *addr_len=sizeof(struct sockaddr_in6);
+
        if (flags & MSG_ERRQUEUE)
                return ipv6_recv_error(sk, msg, len);
 
@@ -135,11 +135,11 @@ try_again:
        if (!skb)
                goto out;
 
-       copied = skb->len - sizeof(struct udphdr);
-       if (copied > len) {
-               copied = len;
-               msg->msg_flags |= MSG_TRUNC;
-       }
+       copied = skb->len - sizeof(struct udphdr);
+       if (copied > len) {
+               copied = len;
+               msg->msg_flags |= MSG_TRUNC;
+       }
 
        /*
         *      Decide whether to checksum and/or copy data.
@@ -168,7 +168,7 @@ try_again:
        /* Copy the address. */
        if (msg->msg_name) {
                struct sockaddr_in6 *sin6;
-         
+
                sin6 = (struct sockaddr_in6 *) msg->msg_name;
                sin6->sin6_family = AF_INET6;
                sin6->sin6_port = skb->h.uh->source;
@@ -191,7 +191,7 @@ try_again:
        } else {
                if (np->rxopt.all)
                        datagram_recv_ctl(sk, msg, skb);
-       }
+       }
 
        err = copied;
        if (flags & MSG_TRUNC)
@@ -309,7 +309,7 @@ static struct sock *udp_v6_mcast_next(struct sock *sk,
        sk_for_each_from(s, node) {
                struct inet_sock *inet = inet_sk(s);
 
-               if (inet->num == num && s->sk_family == PF_INET6) {
+               if (s->sk_hash == num && s->sk_family == PF_INET6) {
                        struct ipv6_pinfo *np = inet6_sk(s);
                        if (inet->dport) {
                                if (inet->dport != rmt_port)
@@ -339,7 +339,7 @@ static struct sock *udp_v6_mcast_next(struct sock *sk,
  * so we don't need to lock the hashes.
  */
 static int __udp6_lib_mcast_deliver(struct sk_buff *skb, struct in6_addr *saddr,
-                          struct in6_addr *daddr, struct hlist_head udptable[])
+                          struct in6_addr *daddr, struct hlist_head udptable[])
 {
        struct sock *sk, *sk2;
        const struct udphdr *uh = skb->h.uh;
@@ -379,7 +379,7 @@ static inline int udp6_csum_init(struct sk_buff *skb, struct udphdr *uh)
        }
        if (skb->ip_summed == CHECKSUM_COMPLETE &&
            !csum_ipv6_magic(&skb->nh.ipv6h->saddr, &skb->nh.ipv6h->daddr,
-                            skb->len, IPPROTO_UDP, skb->csum             ))
+                            skb->len, IPPROTO_UDP, skb->csum             ))
                skb->ip_summed = CHECKSUM_UNNECESSARY;
 
        if (skb->ip_summed != CHECKSUM_UNNECESSARY)
@@ -396,7 +396,7 @@ int __udp6_lib_rcv(struct sk_buff **pskb, struct hlist_head udptable[],
 {
        struct sk_buff *skb = *pskb;
        struct sock *sk;
-       struct udphdr *uh;
+       struct udphdr *uh;
        struct net_device *dev = skb->dev;
        struct in6_addr *saddr, *daddr;
        u32 ulen = 0;
@@ -437,15 +437,15 @@ int __udp6_lib_rcv(struct sk_buff **pskb, struct hlist_head udptable[],
                        goto discard;
        }
 
-       /* 
-        *      Multicast receive code 
+       /*
+        *      Multicast receive code
         */
        if (ipv6_addr_is_multicast(daddr))
                return __udp6_lib_mcast_deliver(skb, saddr, daddr, udptable);
 
        /* Unicast */
 
-       /* 
+       /*
         * check socket cache ... must talk to Alan about his plans
         * for sock caches... i'll skip this for now.
         */
@@ -465,21 +465,21 @@ int __udp6_lib_rcv(struct sk_buff **pskb, struct hlist_head udptable[],
                kfree_skb(skb);
                return(0);
        }
-       
+
        /* deliver */
-       
+
        udpv6_queue_rcv_skb(sk, skb);
        sock_put(sk);
        return(0);
 
-short_packet:  
+short_packet:
        LIMIT_NETDEBUG(KERN_DEBUG "UDP%sv6: short packet: %d/%u\n",
                       is_udplite? "-Lite" : "",  ulen, skb->len);
 
 discard:
        UDP6_INC_STATS_BH(UDP_MIB_INERRORS, is_udplite);
        kfree_skb(skb);
-       return(0);      
+       return(0);
 }
 
 static __inline__ int udpv6_rcv(struct sk_buff **pskb)
@@ -498,7 +498,7 @@ static void udp_v6_flush_pending_frames(struct sock *sk)
                up->len = 0;
                up->pending = 0;
                ip6_flush_pending_frames(sk);
-        }
+       }
 }
 
 /*
@@ -594,7 +594,7 @@ int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk,
                if (sk->sk_state != TCP_ESTABLISHED)
                        return -EDESTADDRREQ;
                daddr = &np->daddr;
-       } else 
+       } else
                daddr = NULL;
 
        if (daddr) {
@@ -620,7 +620,7 @@ do_udp_sendmsg:
           */
        if (len > INT_MAX - sizeof(struct udphdr))
                return -EMSGSIZE;
-       
+
        if (up->pending) {
                /*
                 * There are pending frames.
@@ -713,7 +713,7 @@ do_udp_sendmsg:
        if (ipv6_addr_any(&fl.fl6_src) && !ipv6_addr_any(&np->saddr))
                ipv6_addr_copy(&fl.fl6_src, &np->saddr);
        fl.fl_ip_sport = inet->sport;
-       
+
        /* merge ip6_build_xmit from ip6_output */
        if (opt && opt->srcrt) {
                struct rt0_hdr *rt0 = (struct rt0_hdr *) opt->srcrt;
@@ -736,7 +736,7 @@ do_udp_sendmsg:
        if (final_p)
                ipv6_addr_copy(&fl.fl6_dst, final_p);
 
-       if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0)
+       if ((err = xfrm_lookup(&dst, &fl, sk, 1)) < 0)
                goto out;
 
        if (hlimit < 0) {
@@ -911,7 +911,7 @@ static void udp6_sock_seq_show(struct seq_file *seq, struct sock *sp, int bucket
                   src->s6_addr32[2], src->s6_addr32[3], srcp,
                   dest->s6_addr32[0], dest->s6_addr32[1],
                   dest->s6_addr32[2], dest->s6_addr32[3], destp,
-                  sp->sk_state, 
+                  sp->sk_state,
                   atomic_read(&sp->sk_wmem_alloc),
                   atomic_read(&sp->sk_rmem_alloc),
                   0, 0L, 0,
index ec98788991280c586d813be9f839068f4290d598..6e252f318f7c91c81f5cdf04d2822b476f26a8ae 100644 (file)
@@ -11,9 +11,9 @@ extern void   __udp6_lib_err(struct sk_buff *, struct inet6_skb_parm *,
                               int , int , int , __be32 , struct hlist_head []);
 
 extern int     udpv6_getsockopt(struct sock *sk, int level, int optname,
-                                char __user *optval, int __user *optlen);
+                                char __user *optval, int __user *optlen);
 extern int     udpv6_setsockopt(struct sock *sk, int level, int optname,
-                                char __user *optval, int optlen);
+                                char __user *optval, int optlen);
 #ifdef CONFIG_COMPAT
 extern int     compat_udpv6_setsockopt(struct sock *sk, int level, int optname,
                                        char __user *optval, int optlen);
@@ -24,7 +24,7 @@ extern int    udpv6_sendmsg(struct kiocb *iocb, struct sock *sk,
                              struct msghdr *msg, size_t len);
 extern int     udpv6_recvmsg(struct kiocb *iocb, struct sock *sk,
                              struct msghdr *msg, size_t len,
-                             int noblock, int flags, int *addr_len);
+                             int noblock, int flags, int *addr_len);
 extern int     udpv6_queue_rcv_skb(struct sock * sk, struct sk_buff *skb);
 extern int     udpv6_destroy_sock(struct sock *sk);
 
index 5c8b7a5688003dcf7c21ca0923be689b42d7cd40..25250147bdc3514c21a92332a07e0f100383f8cd 100644 (file)
@@ -33,7 +33,7 @@ int xfrm6_rcv_spi(struct sk_buff *skb, __be32 spi)
        seq = 0;
        if (!spi && (err = xfrm_parse_spi(skb, nexthdr, &spi, &seq)) != 0)
                goto drop;
-       
+
        do {
                struct ipv6hdr *iph = skb->nh.ipv6h;
 
@@ -115,7 +115,7 @@ int xfrm6_rcv_spi(struct sk_buff *skb, __be32 spi)
                __skb_push(skb, skb->data - skb->nh.raw);
 
                NF_HOOK(PF_INET6, NF_IP6_PRE_ROUTING, skb, skb->dev, NULL,
-                       ip6_rcv_finish);
+                       ip6_rcv_finish);
                return -1;
 #else
                return 1;
@@ -142,12 +142,12 @@ int xfrm6_rcv(struct sk_buff **pskb)
 int xfrm6_input_addr(struct sk_buff *skb, xfrm_address_t *daddr,
                     xfrm_address_t *saddr, u8 proto)
 {
-       struct xfrm_state *x = NULL;
-       int wildcard = 0;
+       struct xfrm_state *x = NULL;
+       int wildcard = 0;
        struct in6_addr any;
        xfrm_address_t *xany;
        struct xfrm_state *xfrm_vec_one = NULL;
-       int nh = 0;
+       int nh = 0;
        int i = 0;
 
        ipv6_addr_set(&any, 0, 0, 0, 0);
@@ -168,12 +168,12 @@ int xfrm6_input_addr(struct sk_buff *skb, xfrm_address_t *daddr,
                        break;
                case 2:
                default:
-                       /* lookup state with wild-card addresses */
+                       /* lookup state with wild-card addresses */
                        wildcard = 1; /* XXX */
                        dst = xany;
                        src = xany;
                        break;
-               }
+               }
 
                x = xfrm_state_lookup_byaddr(dst, src, proto, AF_INET6);
                if (!x)
@@ -193,8 +193,8 @@ int xfrm6_input_addr(struct sk_buff *skb, xfrm_address_t *daddr,
                if (unlikely(x->km.state != XFRM_STATE_VALID)) {
                        spin_unlock(&x->lock);
                        xfrm_state_put(x);
-                       x = NULL;
-                       continue;
+                       x = NULL;
+                       continue;
                }
                if (xfrm_state_check_expire(x)) {
                        spin_unlock(&x->lock);
index 5e7d8a7d6414cc85a01fd463485c016af1d5a219..0bc866c0d83c4d4e352fa484ede378ca2134ed29 100644 (file)
@@ -25,6 +25,12 @@ static inline void ipip6_ecn_decapsulate(struct sk_buff *skb)
                IP6_ECN_set_ce(inner_iph);
 }
 
+static inline void ip6ip_ecn_decapsulate(struct sk_buff *skb)
+{
+       if (INET_ECN_is_ce(ipv6_get_dsfield(skb->nh.ipv6h)))
+                       IP_ECN_set_ce(skb->h.ipiph);
+}
+
 /* Add encapsulation header.
  *
  * The top IP header will be constructed per RFC 2401.  The following fields
@@ -40,6 +46,7 @@ static inline void ipip6_ecn_decapsulate(struct sk_buff *skb)
 static int xfrm6_tunnel_output(struct xfrm_state *x, struct sk_buff *skb)
 {
        struct dst_entry *dst = skb->dst;
+       struct xfrm_dst *xdst = (struct xfrm_dst*)dst;
        struct ipv6hdr *iph, *top_iph;
        int dsfield;
 
@@ -52,16 +59,24 @@ static int xfrm6_tunnel_output(struct xfrm_state *x, struct sk_buff *skb)
        skb->h.ipv6h = top_iph + 1;
 
        top_iph->version = 6;
-       top_iph->priority = iph->priority;
-       top_iph->flow_lbl[0] = iph->flow_lbl[0];
-       top_iph->flow_lbl[1] = iph->flow_lbl[1];
-       top_iph->flow_lbl[2] = iph->flow_lbl[2];
+       if (xdst->route->ops->family == AF_INET6) {
+               top_iph->priority = iph->priority;
+               top_iph->flow_lbl[0] = iph->flow_lbl[0];
+               top_iph->flow_lbl[1] = iph->flow_lbl[1];
+               top_iph->flow_lbl[2] = iph->flow_lbl[2];
+               top_iph->nexthdr = IPPROTO_IPV6;
+       } else {
+               top_iph->priority = 0;
+               top_iph->flow_lbl[0] = 0;
+               top_iph->flow_lbl[1] = 0;
+               top_iph->flow_lbl[2] = 0;
+               top_iph->nexthdr = IPPROTO_IPIP;
+       }
        dsfield = ipv6_get_dsfield(top_iph);
        dsfield = INET_ECN_encapsulate(dsfield, dsfield);
        if (x->props.flags & XFRM_STATE_NOECN)
                dsfield &= ~INET_ECN_MASK;
        ipv6_change_dsfield(top_iph, 0, dsfield);
-       top_iph->nexthdr = IPPROTO_IPV6; 
        top_iph->hop_limit = dst_metric(dst->child, RTAX_HOPLIMIT);
        ipv6_addr_copy(&top_iph->saddr, (struct in6_addr *)&x->props.saddr);
        ipv6_addr_copy(&top_iph->daddr, (struct in6_addr *)&x->id.daddr);
@@ -72,7 +87,8 @@ static int xfrm6_tunnel_input(struct xfrm_state *x, struct sk_buff *skb)
 {
        int err = -EINVAL;
 
-       if (skb->nh.raw[IP6CB(skb)->nhoff] != IPPROTO_IPV6)
+       if (skb->nh.raw[IP6CB(skb)->nhoff] != IPPROTO_IPV6
+           && skb->nh.raw[IP6CB(skb)->nhoff] != IPPROTO_IPIP)
                goto out;
        if (!pskb_may_pull(skb, sizeof(struct ipv6hdr)))
                goto out;
@@ -81,10 +97,16 @@ static int xfrm6_tunnel_input(struct xfrm_state *x, struct sk_buff *skb)
            (err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC)))
                goto out;
 
-       if (x->props.flags & XFRM_STATE_DECAP_DSCP)
-               ipv6_copy_dscp(skb->nh.ipv6h, skb->h.ipv6h);
-       if (!(x->props.flags & XFRM_STATE_NOECN))
-               ipip6_ecn_decapsulate(skb);
+       if (skb->nh.raw[IP6CB(skb)->nhoff] == IPPROTO_IPV6) {
+               if (x->props.flags & XFRM_STATE_DECAP_DSCP)
+                       ipv6_copy_dscp(skb->nh.ipv6h, skb->h.ipv6h);
+               if (!(x->props.flags & XFRM_STATE_NOECN))
+                       ipip6_ecn_decapsulate(skb);
+       } else {
+               if (!(x->props.flags & XFRM_STATE_NOECN))
+                       ip6ip_ecn_decapsulate(skb);
+               skb->protocol = htons(ETH_P_IP);
+       }
        skb->mac.raw = memmove(skb->data - skb->mac_len,
                               skb->mac.raw, skb->mac_len);
        skb->nh.raw = skb->data;
index c260ea104c524df24f2a49209b8fe57ba0409efd..d6d786b89d2bb5e9ec529fec0ac1888f5ea83e31 100644 (file)
@@ -2,7 +2,7 @@
  * xfrm6_output.c - Common IPsec encapsulation code for IPv6.
  * Copyright (C) 2002 USAGI/WIDE Project
  * Copyright (c) 2004 Herbert Xu <herbert@gondor.apana.org.au>
- * 
+ *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version
@@ -46,7 +46,7 @@ static int xfrm6_output_one(struct sk_buff *skb)
        struct dst_entry *dst = skb->dst;
        struct xfrm_state *x = dst->xfrm;
        int err;
-       
+
        if (skb->ip_summed == CHECKSUM_PARTIAL) {
                err = skb_checksum_help(skb);
                if (err)
@@ -81,7 +81,7 @@ static int xfrm6_output_one(struct sk_buff *skb)
                spin_unlock_bh(&x->lock);
 
                skb->nh.raw = skb->data;
-               
+
                if (!(skb->dst = dst_pop(dst))) {
                        err = -EHOSTUNREACH;
                        goto error_nolock;
@@ -108,7 +108,7 @@ static int xfrm6_output_finish2(struct sk_buff *skb)
 
        while (likely((err = xfrm6_output_one(skb)) == 0)) {
                nf_reset(skb);
-       
+
                err = nf_hook(PF_INET6, NF_IP6_LOCAL_OUT, &skb, NULL,
                              skb->dst->dev, dst_output);
                if (unlikely(err != 1))
index 8dffd4daae9ce4dbeb3ab8a7cc1f9887f495b669..b1133f27c8aed0ce5578d0417c0c704bc1650c9b 100644 (file)
@@ -8,7 +8,7 @@
  *             IPv6 support
  *     YOSHIFUJI Hideaki
  *             Split up af-specific portion
- * 
+ *
  */
 
 #include <linux/compiler.h>
@@ -131,13 +131,11 @@ __xfrm6_bundle_create(struct xfrm_policy *policy, struct xfrm_state **xfrm, int
        struct dst_entry *dst, *dst_prev;
        struct rt6_info *rt0 = (struct rt6_info*)(*dst_p);
        struct rt6_info *rt  = rt0;
-       struct in6_addr *remote = &fl->fl6_dst;
-       struct in6_addr *local  = &fl->fl6_src;
        struct flowi fl_tunnel = {
                .nl_u = {
                        .ip6_u = {
-                               .saddr = *local,
-                               .daddr = *remote
+                               .saddr = fl->fl6_src,
+                               .daddr = fl->fl6_dst,
                        }
                }
        };
@@ -153,7 +151,6 @@ __xfrm6_bundle_create(struct xfrm_policy *policy, struct xfrm_state **xfrm, int
        for (i = 0; i < nx; i++) {
                struct dst_entry *dst1 = dst_alloc(&xfrm6_dst_ops);
                struct xfrm_dst *xdst;
-               int tunnel = 0;
 
                if (unlikely(dst1 == NULL)) {
                        err = -ENOBUFS;
@@ -177,19 +174,29 @@ __xfrm6_bundle_create(struct xfrm_policy *policy, struct xfrm_state **xfrm, int
 
                dst1->next = dst_prev;
                dst_prev = dst1;
-               if (xfrm[i]->props.mode != XFRM_MODE_TRANSPORT) {
-                       remote = __xfrm6_bundle_addr_remote(xfrm[i], remote);
-                       local  = __xfrm6_bundle_addr_local(xfrm[i], local);
-                       tunnel = 1;
-               }
+
                __xfrm6_bundle_len_inc(&header_len, &nfheader_len, xfrm[i]);
                trailer_len += xfrm[i]->props.trailer_len;
 
-               if (tunnel) {
-                       ipv6_addr_copy(&fl_tunnel.fl6_dst, remote);
-                       ipv6_addr_copy(&fl_tunnel.fl6_src, local);
+               if (xfrm[i]->props.mode == XFRM_MODE_TUNNEL ||
+                   xfrm[i]->props.mode == XFRM_MODE_ROUTEOPTIMIZATION) {
+                       unsigned short encap_family = xfrm[i]->props.family;
+                       switch(encap_family) {
+                       case AF_INET:
+                               fl_tunnel.fl4_dst = xfrm[i]->id.daddr.a4;
+                               fl_tunnel.fl4_src = xfrm[i]->props.saddr.a4;
+                               break;
+                       case AF_INET6:
+                               ipv6_addr_copy(&fl_tunnel.fl6_dst, __xfrm6_bundle_addr_remote(xfrm[i], &fl->fl6_dst));
+
+                               ipv6_addr_copy(&fl_tunnel.fl6_src, __xfrm6_bundle_addr_remote(xfrm[i], &fl->fl6_src));
+                               break;
+                       default:
+                               BUG_ON(1);
+                       }
+
                        err = xfrm_dst_lookup((struct xfrm_dst **) &rt,
-                                             &fl_tunnel, AF_INET6);
+                                             &fl_tunnel, encap_family);
                        if (err)
                                goto error;
                } else
@@ -208,6 +215,7 @@ __xfrm6_bundle_create(struct xfrm_policy *policy, struct xfrm_state **xfrm, int
        i = 0;
        for (; dst_prev != &rt->u.dst; dst_prev = dst_prev->child) {
                struct xfrm_dst *x = (struct xfrm_dst*)dst_prev;
+               struct xfrm_state_afinfo *afinfo;
 
                dst_prev->xfrm = xfrm[i++];
                dst_prev->dev = rt->u.dst.dev;
@@ -224,16 +232,26 @@ __xfrm6_bundle_create(struct xfrm_policy *policy, struct xfrm_state **xfrm, int
                /* Copy neighbour for reachability confirmation */
                dst_prev->neighbour     = neigh_clone(rt->u.dst.neighbour);
                dst_prev->input         = rt->u.dst.input;
-               dst_prev->output        = xfrm6_output;
+               /* XXX: When IPv4 is implemented as module and can be unloaded,
+                * we should manage reference to xfrm4_output in afinfo->output.
+                * Miyazawa
+                */
+               afinfo = xfrm_state_get_afinfo(dst_prev->xfrm->props.family);
+               if (!afinfo) {
+                       dst = *dst_p;
+                       goto error;
+               };
+               dst_prev->output = afinfo->output;
+               xfrm_state_put_afinfo(afinfo);
                /* Sheit... I remember I did this right. Apparently,
                 * it was magically lost, so this code needs audit */
                x->u.rt6.rt6i_flags    = rt0->rt6i_flags&(RTCF_BROADCAST|RTCF_MULTICAST|RTCF_LOCAL);
                x->u.rt6.rt6i_metric   = rt0->rt6i_metric;
                x->u.rt6.rt6i_node     = rt0->rt6i_node;
                x->u.rt6.rt6i_gateway  = rt0->rt6i_gateway;
-               memcpy(&x->u.rt6.rt6i_gateway, &rt0->rt6i_gateway, sizeof(x->u.rt6.rt6i_gateway)); 
+               memcpy(&x->u.rt6.rt6i_gateway, &rt0->rt6i_gateway, sizeof(x->u.rt6.rt6i_gateway));
                x->u.rt6.rt6i_dst      = rt0->rt6i_dst;
-               x->u.rt6.rt6i_src      = rt0->rt6i_src; 
+               x->u.rt6.rt6i_src      = rt0->rt6i_src;
                x->u.rt6.rt6i_idev     = rt0->rt6i_idev;
                in6_dev_hold(rt0->rt6i_idev);
                __xfrm6_bundle_len_dec(&header_len, &nfheader_len, x->u.dst.xfrm);
index 9ddaa9d41539fe23ec7df3d5cc9059749348e4ec..baa461b9f74eebf97c654aa858203dcf010aa7e8 100644 (file)
@@ -8,7 +8,7 @@
  *             IPv6 support
  *     YOSHIFUJI Hideaki @USAGI
  *             Split up af-specific portion
- *     
+ *
  */
 
 #include <net/xfrm.h>
@@ -171,6 +171,7 @@ static struct xfrm_state_afinfo xfrm6_state_afinfo = {
        .init_tempsel           = __xfrm6_init_tempsel,
        .tmpl_sort              = __xfrm6_tmpl_sort,
        .state_sort             = __xfrm6_state_sort,
+       .output                 = xfrm6_output,
 };
 
 void __init xfrm6_state_init(void)
index 12e426b9aacd19d2b03e3d35bfc230dcd3c42897..fb0228772f0194b7aad847c0e38093d561821213 100644 (file)
@@ -5,12 +5,12 @@
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
@@ -32,7 +32,7 @@
 #include <linux/mutex.h>
 
 /*
- * xfrm_tunnel_spi things are for allocating unique id ("spi") 
+ * xfrm_tunnel_spi things are for allocating unique id ("spi")
  * per xfrm_address_t.
  */
 struct xfrm6_tunnel_spi {
@@ -155,8 +155,8 @@ static u32 __xfrm6_tunnel_alloc_spi(xfrm_address_t *saddr)
 
        for (spi = xfrm6_tunnel_spi; spi <= XFRM6_TUNNEL_SPI_MAX; spi++) {
                index = xfrm6_tunnel_spi_hash_byspi(spi);
-               hlist_for_each_entry(x6spi, pos, 
-                                    &xfrm6_tunnel_spi_byspi[index], 
+               hlist_for_each_entry(x6spi, pos,
+                                    &xfrm6_tunnel_spi_byspi[index],
                                     list_byspi) {
                        if (x6spi->spi == spi)
                                goto try_next_1;
@@ -167,8 +167,8 @@ try_next_1:;
        }
        for (spi = XFRM6_TUNNEL_SPI_MIN; spi < xfrm6_tunnel_spi; spi++) {
                index = xfrm6_tunnel_spi_hash_byspi(spi);
-               hlist_for_each_entry(x6spi, pos, 
-                                    &xfrm6_tunnel_spi_byspi[index], 
+               hlist_for_each_entry(x6spi, pos,
+                                    &xfrm6_tunnel_spi_byspi[index],
                                     list_byspi) {
                        if (x6spi->spi == spi)
                                goto try_next_2;
@@ -222,7 +222,7 @@ void xfrm6_tunnel_free_spi(xfrm_address_t *saddr)
 
        write_lock_bh(&xfrm6_tunnel_spi_lock);
 
-       hlist_for_each_entry_safe(x6spi, pos, n, 
+       hlist_for_each_entry_safe(x6spi, pos, n,
                                  &xfrm6_tunnel_spi_byaddr[xfrm6_tunnel_spi_hash_byaddr(saddr)],
                                  list_byaddr)
        {
@@ -269,9 +269,9 @@ static int xfrm6_tunnel_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
 {
        /* xfrm6_tunnel native err handling */
        switch (type) {
-       case ICMPV6_DEST_UNREACH: 
+       case ICMPV6_DEST_UNREACH:
                switch (code) {
-               case ICMPV6_NOROUTE: 
+               case ICMPV6_NOROUTE:
                case ICMPV6_ADM_PROHIBITED:
                case ICMPV6_NOT_NEIGHBOUR:
                case ICMPV6_ADDR_UNREACH:
@@ -287,7 +287,7 @@ static int xfrm6_tunnel_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
                case ICMPV6_EXC_HOPLIMIT:
                        break;
                case ICMPV6_EXC_FRAGTIME:
-               default: 
+               default:
                        break;
                }
                break;
index 76c661566dfdaa1e6eb0cb0f3a5d94db0d97ea2a..cac35a77f069da4594b1585b4f8fc50cd2f8f54c 100644 (file)
@@ -11,7 +11,7 @@
  *     work I am currently employed to do there.
  *
  *     All the material in this file is subject to the Gnu license version 2.
- *     Neither Alan Cox nor the Swansea University Computer Society admit 
+ *     Neither Alan Cox nor the Swansea University Computer Society admit
  *     liability nor provide warranty for any of this software. This material
  *     is provided as is and at no charge.
  *
@@ -152,8 +152,8 @@ static void ipx_destroy_socket(struct sock *sk)
        ipx_remove_socket(sk);
        skb_queue_purge(&sk->sk_receive_queue);
 #ifdef IPX_REFCNT_DEBUG
-        atomic_dec(&ipx_sock_nr);
-        printk(KERN_DEBUG "IPX socket %p released, %d are still alive\n", sk,
+       atomic_dec(&ipx_sock_nr);
+       printk(KERN_DEBUG "IPX socket %p released, %d are still alive\n", sk,
                        atomic_read(&ipx_sock_nr));
        if (atomic_read(&sk->sk_refcnt) != 1)
                printk(KERN_DEBUG "Destruction sock ipx %p delayed, cnt=%d\n",
@@ -162,7 +162,7 @@ static void ipx_destroy_socket(struct sock *sk)
        sock_put(sk);
 }
 
-/* 
+/*
  * The following code is used to support IPX Interfaces (IPXITF).  An
  * IPX interface is defined by a physical device and a frame type.
  */
@@ -369,7 +369,7 @@ static __exit void ipxitf_cleanup(void)
        struct ipx_interface *i, *tmp;
 
        spin_lock_bh(&ipx_interfaces_lock);
-       list_for_each_entry_safe(i, tmp, &ipx_interfaces, node) 
+       list_for_each_entry_safe(i, tmp, &ipx_interfaces, node)
                __ipxitf_put(i);
        spin_unlock_bh(&ipx_interfaces_lock);
 }
@@ -446,10 +446,10 @@ static struct sock *ncp_connection_hack(struct ipx_interface *intrfc,
         * You might call this a hack, but believe me, you do not want a
         * complete NCP layer in the kernel, and this is VERY fast as well. */
        struct sock *sk = NULL;
-       int connection = 0;
+       int connection = 0;
        u8 *ncphdr = (u8 *)(ipx + 1);
 
-       if (*ncphdr == 0x22 && *(ncphdr + 1) == 0x22) /* NCP request */
+       if (*ncphdr == 0x22 && *(ncphdr + 1) == 0x22) /* NCP request */
                connection = (((int) *(ncphdr + 5)) << 8) | (int) *(ncphdr + 3);
        else if (*ncphdr == 0x77 && *(ncphdr + 1) == 0x77) /* BURST packet */
                connection = (((int) *(ncphdr + 9)) << 8) | (int) *(ncphdr + 8);
@@ -482,7 +482,7 @@ static int ipxitf_demux_socket(struct ipx_interface *intrfc,
 
        if (intrfc == ipx_primary_net && ntohs(ipx->ipx_dest.sock) == 0x451)
                sock1 = ncp_connection_hack(intrfc, ipx);
-        if (!sock1)
+       if (!sock1)
                /* No special socket found, forward the packet the normal way */
                sock1 = ipxitf_find_socket(intrfc, ipx->ipx_dest.sock);
 
@@ -607,22 +607,22 @@ int ipxitf_send(struct ipx_interface *intrfc, struct sk_buff *skb, char *node)
                *last_hop = IPX_SKB_CB(skb)->last_hop.netnum;
                IPX_SKB_CB(skb)->last_hop.index = -1;
        }
-       
-       /* 
+
+       /*
         * We need to know how many skbuffs it will take to send out this
         * packet to avoid unnecessary copies.
         */
-        
-       if (!dl || !dev || dev->flags & IFF_LOOPBACK) 
+
+       if (!dl || !dev || dev->flags & IFF_LOOPBACK)
                send_to_wire = 0;       /* No non looped */
 
        /*
-        * See if this should be demuxed to sockets on this interface 
+        * See if this should be demuxed to sockets on this interface
         *
         * We want to ensure the original was eaten or that we only use
         * up clones.
         */
-        
+
        if (ipx->ipx_dest.net == intrfc->if_netnum) {
                /*
                 * To our own node, loop and free the original.
@@ -709,8 +709,8 @@ static int ipxitf_rcv(struct ipx_interface *intrfc, struct sk_buff *skb)
 
        /* See if we should update our network number */
        if (!intrfc->if_netnum) /* net number of intrfc not known yet */
-               ipxitf_discover_netnum(intrfc, skb);
-       
+               ipxitf_discover_netnum(intrfc, skb);
+
        IPX_SKB_CB(skb)->last_hop.index = -1;
        if (ipx->ipx_type == IPX_TYPE_PPROP) {
                rc = ipxitf_pprop(intrfc, skb);
@@ -756,7 +756,7 @@ out_intrfc:
 
 static void ipxitf_discover_netnum(struct ipx_interface *intrfc,
                                   struct sk_buff *skb)
-{ 
+{
        const struct ipx_cb *cb = IPX_SKB_CB(skb);
 
        /* see if this is an intra packet: source_net == dest_net */
@@ -793,7 +793,7 @@ static void ipxitf_discover_netnum(struct ipx_interface *intrfc,
  * it, not even processing it locally, if it has exact %IPX_MAX_PPROP_HOPS we
  * don't broadcast it, but process it locally. See chapter 5 of Novell's "IPX
  * RIP and SAP Router Specification", Part Number 107-000029-001.
- * 
+ *
  * If it is valid, check if we have pprop broadcasting enabled by the user,
  * if not, just return zero for local processing.
  *
@@ -820,7 +820,7 @@ static int ipxitf_pprop(struct ipx_interface *intrfc, struct sk_buff *skb)
         * tctrl <= 15, any data payload... */
        if (IPX_SKB_CB(skb)->ipx_tctrl > IPX_MAX_PPROP_HOPS ||
            ntohs(ipx->ipx_pktsize) < sizeof(struct ipxhdr) +
-                                       IPX_MAX_PPROP_HOPS * sizeof(u32))
+                                       IPX_MAX_PPROP_HOPS * sizeof(u32))
                goto out;
        /* are we broadcasting this damn thing? */
        rc = 0;
@@ -831,7 +831,7 @@ static int ipxitf_pprop(struct ipx_interface *intrfc, struct sk_buff *skb)
         * locally. */
        if (IPX_SKB_CB(skb)->ipx_tctrl == IPX_MAX_PPROP_HOPS)
                goto out;
-       
+
        c = ((u8 *) ipx) + sizeof(struct ipxhdr);
        l = (__be32 *) c;
 
@@ -851,7 +851,7 @@ static int ipxitf_pprop(struct ipx_interface *intrfc, struct sk_buff *skb)
                /* Except unconfigured interfaces */
                if (!ifcs->if_netnum)
                        continue;
-                                       
+
                /* That aren't in the list */
                if (ifcs == intrfc)
                        continue;
@@ -1003,7 +1003,7 @@ static int ipxitf_create(struct ipx_interface_definition *idef)
                        dlink_type      = htons(ETH_P_IPX);
                        datalink        = pEII_datalink;
                        break;
-               } else 
+               } else
                        printk(KERN_WARNING "IPX frame type EtherII over "
                                        "token-ring is obsolete. Use SNAP "
                                        "instead.\n");
@@ -1208,14 +1208,14 @@ static int ipxitf_ioctl(unsigned int cmd, void __user *arg)
                rc = 0;
                break;
        }
-       case SIOCAIPXITFCRT: 
+       case SIOCAIPXITFCRT:
                rc = -EFAULT;
                if (get_user(val, (unsigned char __user *) arg))
                        break;
                rc = 0;
                ipxcfg_auto_create_interfaces = val;
                break;
-       case SIOCAIPXPRISLT: 
+       case SIOCAIPXPRISLT:
                rc = -EFAULT;
                if (get_user(val, (unsigned char __user *) arg))
                        break;
@@ -1230,14 +1230,14 @@ static int ipxitf_ioctl(unsigned int cmd, void __user *arg)
 /*
  *     Checksum routine for IPX
  */
+
 /* Note: We assume ipx_tctrl==0 and htons(length)==ipx_pktsize */
 /* This functions should *not* mess with packet contents */
 
 __be16 ipx_cksum(struct ipxhdr *packet, int length)
 {
-       /* 
-        *      NOTE: sum is a net byte order quantity, which optimizes the 
+       /*
+        *      NOTE: sum is a net byte order quantity, which optimizes the
         *      loop. This only works on big and little endian machines. (I
         *      don't know of a machine that isn't.)
         */
@@ -1342,7 +1342,7 @@ static int ipx_getsockopt(struct socket *sock, int level, int optname,
        rc = -EINVAL;
        if(len < 0)
                goto out;
-               
+
        rc = -EFAULT;
        if (put_user(len, optlen) || copy_to_user(optval, &val, len))
                goto out;
@@ -1372,13 +1372,13 @@ static int ipx_create(struct socket *sock, int protocol)
        if (sock->type != SOCK_DGRAM)
                goto out;
 
-               rc = -ENOMEM;
+       rc = -ENOMEM;
        sk = sk_alloc(PF_IPX, GFP_KERNEL, &ipx_proto, 1);
        if (!sk)
                goto out;
 #ifdef IPX_REFCNT_DEBUG
-        atomic_inc(&ipx_sock_nr);
-        printk(KERN_DEBUG "IPX socket %p created, now we have %d alive\n", sk,
+       atomic_inc(&ipx_sock_nr);
+       printk(KERN_DEBUG "IPX socket %p created, now we have %d alive\n", sk,
                        atomic_read(&ipx_sock_nr));
 #endif
        sock_init_data(sock, sk);
@@ -1561,7 +1561,7 @@ static int ipx_connect(struct socket *sock, struct sockaddr *uaddr,
                        goto out;
        }
 
-        /* We can either connect to primary network or somewhere
+       /* We can either connect to primary network or somewhere
         * we can route to */
        rt = ipxrtr_lookup(addr->sipx_network);
        rc = -ENETUNREACH;
@@ -1641,10 +1641,10 @@ static int ipx_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_ty
        struct ipxhdr *ipx;
        u16 ipx_pktsize;
        int rc = 0;
-               
-       /* Not ours */  
-        if (skb->pkt_type == PACKET_OTHERHOST)
-               goto drop;
+
+       /* Not ours */
+       if (skb->pkt_type == PACKET_OTHERHOST)
+               goto drop;
 
        if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL)
                goto out;
@@ -1653,12 +1653,12 @@ static int ipx_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_ty
                goto drop;
 
        ipx_pktsize = ntohs(ipx_hdr(skb)->ipx_pktsize);
-       
+
        /* Too small or invalid header? */
        if (ipx_pktsize < sizeof(struct ipxhdr) ||
            !pskb_may_pull(skb, ipx_pktsize))
                goto drop;
-                        
+
        ipx = ipx_hdr(skb);
        if (ipx->ipx_checksum != IPX_NO_CHECKSUM &&
           ipx->ipx_checksum != ipx_cksum(ipx, ipx_pktsize))
@@ -1786,7 +1786,7 @@ static int ipx_recvmsg(struct kiocb *iocb, struct socket *sock,
                if (rc)
                        goto out;
        }
-       
+
        rc = -ENOTCONN;
        if (sock_flag(sk, SOCK_ZAPPED))
                goto out;
@@ -1875,15 +1875,15 @@ static int ipx_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
                 * This socket wants to take care of the NCP connection
                 * handed to us in arg.
                 */
-               rc = -EPERM;
-               if (!capable(CAP_NET_ADMIN))
+               rc = -EPERM;
+               if (!capable(CAP_NET_ADMIN))
                        break;
                rc = get_user(ipx_sk(sk)->ipx_ncp_conn,
                              (const unsigned short __user *)argp);
                break;
        case SIOCGSTAMP:
                rc = -EINVAL;
-               if (sk) 
+               if (sk)
                        rc = sock_get_timestamp(sk, argp);
                break;
        case SIOCGIFDSTADDR:
@@ -2035,19 +2035,27 @@ static void __exit ipx_proto_finito(void)
 
        ipxitf_cleanup();
 
-       unregister_snap_client(pSNAP_datalink);
-       pSNAP_datalink = NULL;
+       if (pSNAP_datalink) {
+               unregister_snap_client(pSNAP_datalink);
+               pSNAP_datalink = NULL;
+       }
 
-       unregister_8022_client(p8022_datalink);
-       p8022_datalink = NULL;
+       if (p8022_datalink) {
+               unregister_8022_client(p8022_datalink);
+               p8022_datalink = NULL;
+       }
 
        dev_remove_pack(&ipx_8023_packet_type);
-       destroy_8023_client(p8023_datalink);
-       p8023_datalink = NULL;
+       if (p8023_datalink) {
+               destroy_8023_client(p8023_datalink);
+               p8023_datalink = NULL;
+       }
 
        dev_remove_pack(&ipx_dix_packet_type);
-       destroy_EII_client(pEII_datalink);
-       pEII_datalink = NULL;
+       if (pEII_datalink) {
+               destroy_EII_client(pEII_datalink);
+               pEII_datalink = NULL;
+       }
 
        proto_unregister(&ipx_proto);
        sock_unregister(ipx_family_ops.family);
index b7463dfca63e154fb90fd674980d1b4adae81914..811e4badce81fd4920d5bb45854d34c1b805fe0f 100644 (file)
@@ -352,7 +352,7 @@ int __init ipx_proc_init(void)
 {
        struct proc_dir_entry *p;
        int rc = -ENOMEM;
-       
+
        ipx_proc_dir = proc_mkdir("ipx", proc_net);
 
        if (!ipx_proc_dir)
index 68560ee0d797481e8def03a906a166bb6c77d7f4..8e1cad971f11bd473da17883ff41c1cda6f68550 100644 (file)
@@ -234,7 +234,7 @@ int ipxrtr_route_packet(struct sock *sk, struct sockaddr_ipx *usipx,
        if (rc) {
                kfree_skb(skb);
                goto out_put;
-       }       
+       }
 
        /* Apply checksum. Not allowed on 802.3 links. */
        if (sk->sk_no_check || intrfc->if_dlink_type == htons(IPX_FRAME_8023))
@@ -242,7 +242,7 @@ int ipxrtr_route_packet(struct sock *sk, struct sockaddr_ipx *usipx,
        else
                ipx->ipx_checksum = ipx_cksum(ipx, len + sizeof(struct ipxhdr));
 
-       rc = ipxitf_send(intrfc, skb, (rt && rt->ir_routed) ? 
+       rc = ipxitf_send(intrfc, skb, (rt && rt->ir_routed) ?
                         rt->ir_router_node : ipx->ipx_dest.node);
 out_put:
        ipxitf_put(intrfc);
index fa574735c76fa11ce74d4e475316183e03fba1db..85ae35fa1e0e797655a8d774b24eb514e740f4b5 100644 (file)
@@ -34,7 +34,7 @@ static struct ctl_table ipx_dir_table[] = {
                .procname       = "ipx",
                .mode           = 0555,
                .child          = ipx_table,
-               },
+       },
        { 0 },
 };
 
index 7e1aea89ef05b60709fcb37e1f5ec531303f0359..eabd6838f50a2e811888d22499e31ab90ae55af8 100644 (file)
@@ -138,7 +138,7 @@ static void irda_disconnect_indication(void *instance, void *sap,
                sk->sk_shutdown |= SEND_SHUTDOWN;
 
                sk->sk_state_change(sk);
-                sock_orphan(sk);
+               sock_orphan(sk);
                release_sock(sk);
 
                /* Close our TSAP.
@@ -158,7 +158,7 @@ static void irda_disconnect_indication(void *instance, void *sap,
                        irttp_close_tsap(self->tsap);
                        self->tsap = NULL;
                }
-        }
+       }
 
        /* Note : once we are there, there is not much you want to do
         * with the socket anymore, apart from closing it.
@@ -1211,7 +1211,7 @@ static int irda_release(struct socket *sock)
 
        IRDA_DEBUG(2, "%s()\n", __FUNCTION__);
 
-        if (sk == NULL)
+       if (sk == NULL)
                return 0;
 
        lock_sock(sk);
@@ -1259,7 +1259,7 @@ static int irda_release(struct socket *sock)
         * memory leak is now gone... - Jean II
         */
 
-        return 0;
+       return 0;
 }
 
 /*
@@ -1312,7 +1312,7 @@ static int irda_sendmsg(struct kiocb *iocb, struct socket *sock,
                len = self->max_data_size;
        }
 
-       skb = sock_alloc_send_skb(sk, len + self->max_header_size + 16, 
+       skb = sock_alloc_send_skb(sk, len + self->max_header_size + 16,
                                  msg->msg_flags & MSG_DONTWAIT, &err);
        if (!skb)
                return -ENOBUFS;
@@ -1714,7 +1714,7 @@ static int irda_shutdown(struct socket *sock, int how)
        self->daddr = DEV_ADDR_ANY;     /* Until we get re-connected */
        self->saddr = 0x0;              /* so IrLMP assign us any link */
 
-        return 0;
+       return 0;
 }
 
 /*
index 89fd2a2cbca66a170c471672cfcbcd8c56745fd6..789478bc3009ad9743861420be835621473c4151 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************************
- *                
+ *
  * Filename:      discovery.c
  * Version:       0.1
  * Description:   Routines for handling discoveries at the IrLMP layer
  * Modified by:   Dag Brattli <dagb@cs.uit.no>
  * Modified at:   Fri May 28  3:11 CST 1999
  * Modified by:   Horst von Brand <vonbrand@sleipnir.valparaiso.cl>
- * 
+ *
  *     Copyright (c) 1999 Dag Brattli, All Rights Reserved.
- *     
- *     This program is free software; you can redistribute it and/or 
- *     modify it under the terms of the GNU General Public License as 
- *     published by the Free Software Foundation; either version 2 of 
+ *
+ *     This program is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU General Public License as
+ *     published by the Free Software Foundation; either version 2 of
  *     the License, or (at your option) any later version.
- * 
+ *
  *     This program is distributed in the hope that it will be useful,
  *     but WITHOUT ANY WARRANTY; without even the implied warranty of
  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  *     GNU General Public License for more details.
- * 
- *     You should have received a copy of the GNU General Public License 
- *     along with this program; if not, write to the Free Software 
- *     Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
+ *
+ *     You should have received a copy of the GNU General Public License
+ *     along with this program; if not, write to the Free Software
+ *     Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  *     MA 02111-1307 USA
- *     
+ *
  ********************************************************************/
 
 #include <linux/string.h>
@@ -65,9 +65,9 @@ void irlmp_add_discovery(hashbin_t *cachelog, discovery_t *new)
 
        spin_lock_irqsave(&cachelog->hb_spinlock, flags);
 
-       /* 
-        * Remove all discoveries of devices that has previously been 
-        * discovered on the same link with the same name (info), or the 
+       /*
+        * Remove all discoveries of devices that has previously been
+        * discovered on the same link with the same name (info), or the
         * same daddr. We do this since some devices (mostly PDAs) change
         * their device address between every discovery.
         */
@@ -79,10 +79,10 @@ void irlmp_add_discovery(hashbin_t *cachelog, discovery_t *new)
                discovery = (discovery_t *) hashbin_get_next(cachelog);
 
                if ((node->data.saddr == new->data.saddr) &&
-                   ((node->data.daddr == new->data.daddr) || 
+                   ((node->data.daddr == new->data.daddr) ||
                     (strcmp(node->data.info, new->data.info) == 0)))
                {
-                       /* This discovery is a previous discovery 
+                       /* This discovery is a previous discovery
                         * from the same device, so just remove it
                         */
                        hashbin_remove_this(cachelog, (irda_queue_t *) node);
@@ -134,7 +134,7 @@ void irlmp_add_discovery_log(hashbin_t *cachelog, hashbin_t *log)
 
                discovery = (discovery_t *) hashbin_remove_first(log);
        }
-       
+
        /* Delete the now empty log */
        hashbin_delete(log, (FREE_FUNC) kfree);
 }
@@ -232,7 +232,7 @@ void irlmp_dump_discoveries(hashbin_t *log)
        while (discovery != NULL) {
                IRDA_DEBUG(0, "Discovery:\n");
                IRDA_DEBUG(0, "  daddr=%08x\n", discovery->data.daddr);
-               IRDA_DEBUG(0, "  saddr=%08x\n", discovery->data.saddr); 
+               IRDA_DEBUG(0, "  saddr=%08x\n", discovery->data.saddr);
                IRDA_DEBUG(0, "  nickname=%s\n", discovery->data.info);
 
                discovery = (discovery_t *) hashbin_get_next(log);
@@ -321,26 +321,26 @@ static inline discovery_t *discovery_seq_idx(loff_t pos)
 {
        discovery_t *discovery;
 
-       for (discovery = (discovery_t *) hashbin_get_first(irlmp->cachelog); 
+       for (discovery = (discovery_t *) hashbin_get_first(irlmp->cachelog);
             discovery != NULL;
             discovery = (discovery_t *) hashbin_get_next(irlmp->cachelog)) {
                if (pos-- == 0)
                        break;
        }
-               
+
        return discovery;
 }
 
 static void *discovery_seq_start(struct seq_file *seq, loff_t *pos)
 {
        spin_lock_irq(&irlmp->cachelog->hb_spinlock);
-        return *pos ? discovery_seq_idx(*pos - 1) : SEQ_START_TOKEN;
+       return *pos ? discovery_seq_idx(*pos - 1) : SEQ_START_TOKEN;
 }
 
 static void *discovery_seq_next(struct seq_file *seq, void *v, loff_t *pos)
 {
        ++*pos;
-       return (v == SEQ_START_TOKEN) 
+       return (v == SEQ_START_TOKEN)
                ? (void *) hashbin_get_first(irlmp->cachelog)
                : (void *) hashbin_get_next(irlmp->cachelog);
 }
@@ -357,9 +357,9 @@ static int discovery_seq_show(struct seq_file *seq, void *v)
        else {
                const discovery_t *discovery = v;
 
-               seq_printf(seq, "nickname: %s, hint: 0x%02x%02x", 
+               seq_printf(seq, "nickname: %s, hint: 0x%02x%02x",
                           discovery->data.info,
-                          discovery->data.hints[0], 
+                          discovery->data.hints[0],
                           discovery->data.hints[1]);
 #if 0
                if ( discovery->data.hints[0] & HINT_PNP)
@@ -376,20 +376,20 @@ static int discovery_seq_show(struct seq_file *seq, void *v)
                        seq_puts(seq, "Fax ");
                if ( discovery->data.hints[0] & HINT_LAN)
                        seq_puts(seq, "LAN Access ");
-               
+
                if ( discovery->data.hints[1] & HINT_TELEPHONY)
                        seq_puts(seq, "Telephony ");
                if ( discovery->data.hints[1] & HINT_FILE_SERVER)
-                       seq_puts(seq, "File Server ");       
+                       seq_puts(seq, "File Server ");
                if ( discovery->data.hints[1] & HINT_COMM)
                        seq_puts(seq, "IrCOMM ");
                if ( discovery->data.hints[1] & HINT_OBEX)
                        seq_puts(seq, "IrOBEX ");
-#endif         
+#endif
                seq_printf(seq,", saddr: 0x%08x, daddr: 0x%08x\n\n",
                               discovery->data.saddr,
                               discovery->data.daddr);
-               
+
                seq_putc(seq, '\n');
        }
        return 0;
index ad6b6af3dd976c97bd75818f55e4361421923529..c28ee7bce26add7fe60f6bad0c295050d0a2b11e 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************************
- *                
+ *
  * Filename:      ircomm_core.c
  * Version:       1.0
  * Description:   IrCOMM service interface
@@ -8,25 +8,25 @@
  * Created at:    Sun Jun  6 20:37:34 1999
  * Modified at:   Tue Dec 21 13:26:41 1999
  * Modified by:   Dag Brattli <dagb@cs.uit.no>
- * 
+ *
  *     Copyright (c) 1999 Dag Brattli, All Rights Reserved.
  *     Copyright (c) 2000-2003 Jean Tourrilhes <jt@hpl.hp.com>
- *     
- *     This program is free software; you can redistribute it and/or 
- *     modify it under the terms of the GNU General Public License as 
- *     published by the Free Software Foundation; either version 2 of 
+ *
+ *     This program is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU General Public License as
+ *     published by the Free Software Foundation; either version 2 of
  *     the License, or (at your option) any later version.
- * 
+ *
  *     This program is distributed in the hope that it will be useful,
  *     but WITHOUT ANY WARRANTY; without even the implied warranty of
  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  *     GNU General Public License for more details.
- * 
- *     You should have received a copy of the GNU General Public License 
- *     along with this program; if not, write to the Free Software 
- *     Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
+ *
+ *     You should have received a copy of the GNU General Public License
+ *     along with this program; if not, write to the Free Software
+ *     Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  *     MA 02111-1307 USA
- *     
+ *
  ********************************************************************/
 
 #include <linux/module.h>
@@ -49,7 +49,7 @@
 #include <net/irda/ircomm_core.h>
 
 static int __ircomm_close(struct ircomm_cb *self);
-static void ircomm_control_indication(struct ircomm_cb *self, 
+static void ircomm_control_indication(struct ircomm_cb *self,
                                      struct sk_buff *skb, int clen);
 
 #ifdef CONFIG_PROC_FS
@@ -69,22 +69,22 @@ hashbin_t *ircomm = NULL;
 
 static int __init ircomm_init(void)
 {
-       ircomm = hashbin_new(HB_LOCK); 
+       ircomm = hashbin_new(HB_LOCK);
        if (ircomm == NULL) {
                IRDA_ERROR("%s(), can't allocate hashbin!\n", __FUNCTION__);
                return -ENOMEM;
        }
-       
+
 #ifdef CONFIG_PROC_FS
        { struct proc_dir_entry *ent;
        ent = create_proc_entry("ircomm", 0, proc_irda);
-       if (ent) 
+       if (ent)
                ent->proc_fops = &ircomm_proc_fops;
        }
 #endif /* CONFIG_PROC_FS */
-       
+
        IRDA_MESSAGE("IrCOMM protocol (Dag Brattli)\n");
-               
+
        return 0;
 }
 
@@ -139,7 +139,7 @@ struct ircomm_cb *ircomm_open(notify_t *notify, __u8 service_type, int line)
 
        hashbin_insert(ircomm, (irda_queue_t *) self, line, NULL);
 
-       ircomm_next_state(self, IRCOMM_IDLE);   
+       ircomm_next_state(self, IRCOMM_IDLE);
 
        return self;
 }
@@ -195,8 +195,8 @@ int ircomm_close(struct ircomm_cb *self)
        entry = hashbin_remove(ircomm, self->line, NULL);
 
        IRDA_ASSERT(entry == self, return -1;);
-       
-        return __ircomm_close(self);
+
+       return __ircomm_close(self);
 }
 
 EXPORT_SYMBOL(ircomm_close);
@@ -206,9 +206,9 @@ EXPORT_SYMBOL(ircomm_close);
  *
  *    Impl. of this function is differ from one of the reference. This
  *    function does discovery as well as sending connect request
- * 
+ *
  */
-int ircomm_connect_request(struct ircomm_cb *self, __u8 dlsap_sel, 
+int ircomm_connect_request(struct ircomm_cb *self, __u8 dlsap_sel,
                           __u32 saddr, __u32 daddr, struct sk_buff *skb,
                           __u8 service_type)
 {
@@ -243,20 +243,20 @@ void ircomm_connect_indication(struct ircomm_cb *self, struct sk_buff *skb,
                               struct ircomm_info *info)
 {
        int clen = 0;
-       
+
        IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
 
        /* Check if the packet contains data on the control channel */
        if (skb->len > 0)
                clen = skb->data[0];
-       
-       /* 
-        * If there are any data hiding in the control channel, we must 
-        * deliver it first. The side effect is that the control channel 
+
+       /*
+        * If there are any data hiding in the control channel, we must
+        * deliver it first. The side effect is that the control channel
         * will be removed from the skb
         */
        if (self->notify.connect_indication)
-               self->notify.connect_indication(self->notify.instance, self, 
+               self->notify.connect_indication(self->notify.instance, self,
                                                info->qos, info->max_data_size,
                                                info->max_header_size, skb);
        else {
@@ -282,7 +282,7 @@ int ircomm_connect_response(struct ircomm_cb *self, struct sk_buff *userdata)
        ret = ircomm_do_event(self, IRCOMM_CONNECT_RESPONSE, userdata, NULL);
 
        return ret;
-}      
+}
 
 EXPORT_SYMBOL(ircomm_connect_response);
 
@@ -299,7 +299,7 @@ void ircomm_connect_confirm(struct ircomm_cb *self, struct sk_buff *skb,
 
        if (self->notify.connect_confirm )
                self->notify.connect_confirm(self->notify.instance,
-                                            self, info->qos, 
+                                            self, info->qos,
                                             info->max_data_size,
                                             info->max_header_size, skb);
        else {
@@ -322,7 +322,7 @@ int ircomm_data_request(struct ircomm_cb *self, struct sk_buff *skb)
        IRDA_ASSERT(self != NULL, return -EFAULT;);
        IRDA_ASSERT(self->magic == IRCOMM_MAGIC, return -EFAULT;);
        IRDA_ASSERT(skb != NULL, return -EFAULT;);
-       
+
        ret = ircomm_do_event(self, IRCOMM_DATA_REQUEST, skb, NULL);
 
        return ret;
@@ -337,7 +337,7 @@ EXPORT_SYMBOL(ircomm_data_request);
  *
  */
 void ircomm_data_indication(struct ircomm_cb *self, struct sk_buff *skb)
-{      
+{
        IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
 
        IRDA_ASSERT(skb->len > 0, return;);
@@ -363,9 +363,9 @@ void ircomm_process_data(struct ircomm_cb *self, struct sk_buff *skb)
 
        clen = skb->data[0];
 
-       /* 
-        * If there are any data hiding in the control channel, we must 
-        * deliver it first. The side effect is that the control channel 
+       /*
+        * If there are any data hiding in the control channel, we must
+        * deliver it first. The side effect is that the control channel
         * will be removed from the skb
         */
        if (clen > 0)
@@ -375,7 +375,7 @@ void ircomm_process_data(struct ircomm_cb *self, struct sk_buff *skb)
        skb_pull(skb, clen+1);
 
        if (skb->len)
-               ircomm_data_indication(self, skb);              
+               ircomm_data_indication(self, skb);
        else {
                IRDA_DEBUG(4, "%s(), data was control info only!\n",
                           __FUNCTION__ );
@@ -391,13 +391,13 @@ void ircomm_process_data(struct ircomm_cb *self, struct sk_buff *skb)
 int ircomm_control_request(struct ircomm_cb *self, struct sk_buff *skb)
 {
        int ret;
-       
+
        IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
 
        IRDA_ASSERT(self != NULL, return -EFAULT;);
        IRDA_ASSERT(self->magic == IRCOMM_MAGIC, return -EFAULT;);
        IRDA_ASSERT(skb != NULL, return -EFAULT;);
-       
+
        ret = ircomm_do_event(self, IRCOMM_CONTROL_REQUEST, skb, NULL);
 
        return ret;
@@ -411,10 +411,10 @@ EXPORT_SYMBOL(ircomm_control_request);
  *    Data has arrived on the control channel
  *
  */
-static void ircomm_control_indication(struct ircomm_cb *self, 
+static void ircomm_control_indication(struct ircomm_cb *self,
                                      struct sk_buff *skb, int clen)
 {
-       IRDA_DEBUG(2, "%s()\n", __FUNCTION__ ); 
+       IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
 
        /* Use udata for delivering data on the control channel */
        if (self->notify.udata_indication) {
@@ -427,8 +427,8 @@ static void ircomm_control_indication(struct ircomm_cb *self,
 
                /* Remove data channel from control channel */
                skb_trim(ctrl_skb, clen+1);
-       
-               self->notify.udata_indication(self->notify.instance, self, 
+
+               self->notify.udata_indication(self->notify.instance, self,
                                              ctrl_skb);
 
                /* Drop reference count -
@@ -455,7 +455,7 @@ int ircomm_disconnect_request(struct ircomm_cb *self, struct sk_buff *userdata)
        IRDA_ASSERT(self != NULL, return -1;);
        IRDA_ASSERT(self->magic == IRCOMM_MAGIC, return -1;);
 
-       ret = ircomm_do_event(self, IRCOMM_DISCONNECT_REQUEST, userdata, 
+       ret = ircomm_do_event(self, IRCOMM_DISCONNECT_REQUEST, userdata,
                              &info);
        return ret;
 }
@@ -472,7 +472,7 @@ void ircomm_disconnect_indication(struct ircomm_cb *self, struct sk_buff *skb,
                                  struct ircomm_info *info)
 {
        IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
-       
+
        IRDA_ASSERT(info != NULL, return;);
 
        if (self->notify.disconnect_indication) {
@@ -486,7 +486,7 @@ void ircomm_disconnect_indication(struct ircomm_cb *self, struct sk_buff *skb,
 /*
  * Function ircomm_flow_request (self, flow)
  *
- *    
+ *
  *
  */
 void ircomm_flow_request(struct ircomm_cb *self, LOCAL_FLOW flow)
@@ -517,7 +517,7 @@ static void *ircomm_seq_start(struct seq_file *seq, loff_t *pos)
             self = (struct ircomm_cb *) hashbin_get_next(ircomm)) {
                if (off++ == *pos)
                        break;
-               
+
        }
        return self;
 }
@@ -535,7 +535,7 @@ static void ircomm_seq_stop(struct seq_file *seq, void *v)
 }
 
 static int ircomm_seq_show(struct seq_file *seq, void *v)
-{      
+{
        const struct ircomm_cb *self = v;
 
        IRDA_ASSERT(self->magic == IRCOMM_MAGIC, return -EINVAL; );
@@ -548,7 +548,7 @@ static int ircomm_seq_show(struct seq_file *seq, void *v)
        seq_printf(seq,
                   " state: %s, slsap_sel: %#02x, dlsap_sel: %#02x, mode:",
                   ircomm_state[ self->state],
-                  self->slsap_sel, self->dlsap_sel); 
+                  self->slsap_sel, self->dlsap_sel);
 
        if(self->service_type & IRCOMM_3_WIRE_RAW)
                seq_printf(seq, " 3-wire-raw");
index 01f4e801a1ba6b7ec1c485eebb2785b8571c336d..23d0468794e2dca53c42693ed543d543c44512e3 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************************
- *                
+ *
  * Filename:      ircomm_event.c
  * Version:       1.0
  * Description:   IrCOMM layer state machine
@@ -8,24 +8,24 @@
  * Created at:    Sun Jun  6 20:33:11 1999
  * Modified at:   Sun Dec 12 13:44:32 1999
  * Modified by:   Dag Brattli <dagb@cs.uit.no>
- * 
+ *
  *     Copyright (c) 1999 Dag Brattli, All Rights Reserved.
- *     
- *     This program is free software; you can redistribute it and/or 
- *     modify it under the terms of the GNU General Public License as 
- *     published by the Free Software Foundation; either version 2 of 
+ *
+ *     This program is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU General Public License as
+ *     published by the Free Software Foundation; either version 2 of
  *     the License, or (at your option) any later version.
- * 
+ *
  *     This program is distributed in the hope that it will be useful,
  *     but WITHOUT ANY WARRANTY; without even the implied warranty of
  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  *     GNU General Public License for more details.
- * 
- *     You should have received a copy of the GNU General Public License 
- *     along with this program; if not, write to the Free Software 
- *     Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
+ *
+ *     You should have received a copy of the GNU General Public License
+ *     along with this program; if not, write to the Free Software
+ *     Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  *     MA 02111-1307 USA
- *     
+ *
  ********************************************************************/
 
 #include <linux/sched.h>
 #include <net/irda/ircomm_core.h>
 #include <net/irda/ircomm_event.h>
 
-static int ircomm_state_idle(struct ircomm_cb *self, IRCOMM_EVENT event, 
+static int ircomm_state_idle(struct ircomm_cb *self, IRCOMM_EVENT event,
                             struct sk_buff *skb, struct ircomm_info *info);
-static int ircomm_state_waiti(struct ircomm_cb *self, IRCOMM_EVENT event, 
+static int ircomm_state_waiti(struct ircomm_cb *self, IRCOMM_EVENT event,
                              struct sk_buff *skb, struct ircomm_info *info);
-static int ircomm_state_waitr(struct ircomm_cb *self, IRCOMM_EVENT event, 
+static int ircomm_state_waitr(struct ircomm_cb *self, IRCOMM_EVENT event,
                              struct sk_buff *skb, struct ircomm_info *info);
-static int ircomm_state_conn(struct ircomm_cb *self, IRCOMM_EVENT event, 
+static int ircomm_state_conn(struct ircomm_cb *self, IRCOMM_EVENT event,
                             struct sk_buff *skb, struct ircomm_info *info);
 
 char *ircomm_state[] = {
@@ -60,26 +60,26 @@ char *ircomm_state[] = {
 #ifdef CONFIG_IRDA_DEBUG
 static char *ircomm_event[] = {
        "IRCOMM_CONNECT_REQUEST",
-        "IRCOMM_CONNECT_RESPONSE",
-        "IRCOMM_TTP_CONNECT_INDICATION",
+       "IRCOMM_CONNECT_RESPONSE",
+       "IRCOMM_TTP_CONNECT_INDICATION",
        "IRCOMM_LMP_CONNECT_INDICATION",
-        "IRCOMM_TTP_CONNECT_CONFIRM",
+       "IRCOMM_TTP_CONNECT_CONFIRM",
        "IRCOMM_LMP_CONNECT_CONFIRM",
 
-        "IRCOMM_LMP_DISCONNECT_INDICATION",
+       "IRCOMM_LMP_DISCONNECT_INDICATION",
        "IRCOMM_TTP_DISCONNECT_INDICATION",
-        "IRCOMM_DISCONNECT_REQUEST",
+       "IRCOMM_DISCONNECT_REQUEST",
 
-        "IRCOMM_TTP_DATA_INDICATION",
+       "IRCOMM_TTP_DATA_INDICATION",
        "IRCOMM_LMP_DATA_INDICATION",
-        "IRCOMM_DATA_REQUEST",
-        "IRCOMM_CONTROL_REQUEST",
-        "IRCOMM_CONTROL_INDICATION",
+       "IRCOMM_DATA_REQUEST",
+       "IRCOMM_CONTROL_REQUEST",
+       "IRCOMM_CONTROL_INDICATION",
 };
 #endif /* CONFIG_IRDA_DEBUG */
 
 static int (*state[])(struct ircomm_cb *self, IRCOMM_EVENT event,
-                     struct sk_buff *skb, struct ircomm_info *info) = 
+                     struct sk_buff *skb, struct ircomm_info *info) =
 {
        ircomm_state_idle,
        ircomm_state_waiti,
@@ -93,14 +93,14 @@ static int (*state[])(struct ircomm_cb *self, IRCOMM_EVENT event,
  *    IrCOMM is currently idle
  *
  */
-static int ircomm_state_idle(struct ircomm_cb *self, IRCOMM_EVENT event, 
+static int ircomm_state_idle(struct ircomm_cb *self, IRCOMM_EVENT event,
                             struct sk_buff *skb, struct ircomm_info *info)
 {
        int ret = 0;
 
        switch (event) {
        case IRCOMM_CONNECT_REQUEST:
-               ircomm_next_state(self, IRCOMM_WAITI);          
+               ircomm_next_state(self, IRCOMM_WAITI);
                ret = self->issue.connect_request(self, skb, info);
                break;
        case IRCOMM_TTP_CONNECT_INDICATION:
@@ -119,10 +119,10 @@ static int ircomm_state_idle(struct ircomm_cb *self, IRCOMM_EVENT event,
 /*
  * Function ircomm_state_waiti (self, event, skb)
  *
- *    The IrCOMM user has requested an IrCOMM connection to the remote 
+ *    The IrCOMM user has requested an IrCOMM connection to the remote
  *    device and is awaiting confirmation
  */
-static int ircomm_state_waiti(struct ircomm_cb *self, IRCOMM_EVENT event, 
+static int ircomm_state_waiti(struct ircomm_cb *self, IRCOMM_EVENT event,
                              struct sk_buff *skb, struct ircomm_info *info)
 {
        int ret = 0;
@@ -152,8 +152,8 @@ static int ircomm_state_waiti(struct ircomm_cb *self, IRCOMM_EVENT event,
  *    IrCOMM has received an incoming connection request and is awaiting
  *    response from the user
  */
-static int ircomm_state_waitr(struct ircomm_cb *self, IRCOMM_EVENT event, 
-                             struct sk_buff *skb, struct ircomm_info *info) 
+static int ircomm_state_waitr(struct ircomm_cb *self, IRCOMM_EVENT event,
+                             struct sk_buff *skb, struct ircomm_info *info)
 {
        int ret = 0;
 
@@ -185,7 +185,7 @@ static int ircomm_state_waitr(struct ircomm_cb *self, IRCOMM_EVENT event,
  *    IrCOMM is connected to the peer IrCOMM device
  *
  */
-static int ircomm_state_conn(struct ircomm_cb *self, IRCOMM_EVENT event, 
+static int ircomm_state_conn(struct ircomm_cb *self, IRCOMM_EVENT event,
                             struct sk_buff *skb, struct ircomm_info *info)
 {
        int ret = 0;
@@ -228,7 +228,7 @@ static int ircomm_state_conn(struct ircomm_cb *self, IRCOMM_EVENT event,
  *
  */
 int ircomm_do_event(struct ircomm_cb *self, IRCOMM_EVENT event,
-                   struct sk_buff *skb, struct ircomm_info *info) 
+                   struct sk_buff *skb, struct ircomm_info *info)
 {
        IRDA_DEBUG(4, "%s: state=%s, event=%s\n", __FUNCTION__ ,
                   ircomm_state[self->state], ircomm_event[event]);
@@ -245,7 +245,7 @@ int ircomm_do_event(struct ircomm_cb *self, IRCOMM_EVENT event,
 void ircomm_next_state(struct ircomm_cb *self, IRCOMM_STATE state)
 {
        self->state = state;
-       
-       IRDA_DEBUG(4, "%s: next state=%s, service type=%d\n", __FUNCTION__ , 
+
+       IRDA_DEBUG(4, "%s: next state=%s, service type=%d\n", __FUNCTION__ ,
                   ircomm_state[self->state], self->service_type);
 }
index c8e0d89ee11fd3e9443767fd875d05372453bcc5..22bd7529910470b00eefc9a94766f8047137b0d1 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************************
- *                
+ *
  * Filename:      ircomm_lmp.c
  * Version:       1.0
  * Description:   Interface between IrCOMM and IrLMP
@@ -9,25 +9,25 @@
  * Modified at:   Sun Dec 12 13:44:17 1999
  * Modified by:   Dag Brattli <dagb@cs.uit.no>
  * Sources:       Previous IrLPT work by Thomas Davis
- * 
+ *
  *     Copyright (c) 1999 Dag Brattli, All Rights Reserved.
  *     Copyright (c) 2000-2003 Jean Tourrilhes <jt@hpl.hp.com>
- *     
- *     This program is free software; you can redistribute it and/or 
- *     modify it under the terms of the GNU General Public License as 
- *     published by the Free Software Foundation; either version 2 of 
+ *
+ *     This program is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU General Public License as
+ *     published by the Free Software Foundation; either version 2 of
  *     the License, or (at your option) any later version.
- * 
+ *
  *     This program is distributed in the hope that it will be useful,
  *     but WITHOUT ANY WARRANTY; without even the implied warranty of
  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  *     GNU General Public License for more details.
- * 
- *     You should have received a copy of the GNU General Public License 
- *     along with this program; if not, write to the Free Software 
- *     Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
+ *
+ *     You should have received a copy of the GNU General Public License
+ *     along with this program; if not, write to the Free Software
+ *     Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  *     MA 02111-1307 USA
- *     
+ *
  ********************************************************************/
 
 #include <linux/sched.h>
 /*
  * Function ircomm_lmp_connect_request (self, userdata)
  *
- *    
+ *
  *
  */
-static int ircomm_lmp_connect_request(struct ircomm_cb *self, 
-                                     struct sk_buff *userdata, 
+static int ircomm_lmp_connect_request(struct ircomm_cb *self,
+                                     struct sk_buff *userdata,
                                      struct ircomm_info *info)
 {
        int ret = 0;
@@ -61,14 +61,14 @@ static int ircomm_lmp_connect_request(struct ircomm_cb *self,
                skb_get(userdata);
 
        ret = irlmp_connect_request(self->lsap, info->dlsap_sel,
-                                   info->saddr, info->daddr, NULL, userdata); 
+                                   info->saddr, info->daddr, NULL, userdata);
        return ret;
-}      
+}
 
 /*
  * Function ircomm_lmp_connect_response (self, skb)
  *
- *    
+ *
  *
  */
 static int ircomm_lmp_connect_response(struct ircomm_cb *self,
@@ -78,7 +78,7 @@ static int ircomm_lmp_connect_response(struct ircomm_cb *self,
        int ret;
 
        IRDA_DEBUG(0, "%s()\n", __FUNCTION__ );
-       
+
        /* Any userdata supplied? */
        if (userdata == NULL) {
                tx_skb = alloc_skb(LMP_MAX_HEADER, GFP_ATOMIC);
@@ -88,8 +88,8 @@ static int ircomm_lmp_connect_response(struct ircomm_cb *self,
                /* Reserve space for MUX and LAP header */
                skb_reserve(tx_skb, LMP_MAX_HEADER);
        } else {
-               /*  
-                *  Check that the client has reserved enough space for 
+               /*
+                *  Check that the client has reserved enough space for
                 *  headers
                 */
                IRDA_ASSERT(skb_headroom(userdata) >= LMP_MAX_HEADER,
@@ -105,22 +105,22 @@ static int ircomm_lmp_connect_response(struct ircomm_cb *self,
        return 0;
 }
 
-static int ircomm_lmp_disconnect_request(struct ircomm_cb *self, 
-                                        struct sk_buff *userdata, 
+static int ircomm_lmp_disconnect_request(struct ircomm_cb *self,
+                                        struct sk_buff *userdata,
                                         struct ircomm_info *info)
 {
-        struct sk_buff *tx_skb;
+       struct sk_buff *tx_skb;
        int ret;
 
        IRDA_DEBUG(0, "%s()\n", __FUNCTION__ );
 
-        if (!userdata) {
+       if (!userdata) {
                tx_skb = alloc_skb(LMP_MAX_HEADER, GFP_ATOMIC);
                if (!tx_skb)
                        return -ENOMEM;
-               
+
                /*  Reserve space for MUX and LAP header */
-               skb_reserve(tx_skb, LMP_MAX_HEADER);            
+               skb_reserve(tx_skb, LMP_MAX_HEADER);
                userdata = tx_skb;
        } else {
                /* Don't forget to refcount it - should be NULL anyway */
@@ -136,7 +136,7 @@ static int ircomm_lmp_disconnect_request(struct ircomm_cb *self,
  * Function ircomm_lmp_flow_control (skb)
  *
  *    This function is called when a data frame we have sent to IrLAP has
- *    been deallocated. We do this to make sure we don't flood IrLAP with 
+ *    been deallocated. We do this to make sure we don't flood IrLAP with
  *    frames, since we are not using the IrTTP flow control mechanism
  */
 static void ircomm_lmp_flow_control(struct sk_buff *skb)
@@ -150,29 +150,29 @@ static void ircomm_lmp_flow_control(struct sk_buff *skb)
        cb = (struct irda_skb_cb *) skb->cb;
 
        IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
-        line = cb->line;
+
+       line = cb->line;
 
        self = (struct ircomm_cb *) hashbin_lock_find(ircomm, line, NULL);
-        if (!self) {
+       if (!self) {
                IRDA_DEBUG(2, "%s(), didn't find myself\n", __FUNCTION__ );
-                return;
+               return;
        }
 
-        IRDA_ASSERT(self != NULL, return;);
+       IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == IRCOMM_MAGIC, return;);
 
        self->pkt_count--;
 
-        if ((self->pkt_count < 2) && (self->flow_status == FLOW_STOP)) {
-                IRDA_DEBUG(2, "%s(), asking TTY to start again!\n", __FUNCTION__ );
-                self->flow_status = FLOW_START;
-                if (self->notify.flow_indication)
-                        self->notify.flow_indication(self->notify.instance, 
+       if ((self->pkt_count < 2) && (self->flow_status == FLOW_STOP)) {
+               IRDA_DEBUG(2, "%s(), asking TTY to start again!\n", __FUNCTION__ );
+               self->flow_status = FLOW_START;
+               if (self->notify.flow_indication)
+                       self->notify.flow_indication(self->notify.instance,
                                                     self, FLOW_START);
-        }
+       }
 }
-    
+
 /*
  * Function ircomm_lmp_data_request (self, userdata)
  *
@@ -180,7 +180,7 @@ static void ircomm_lmp_flow_control(struct sk_buff *skb)
  *
  */
 static int ircomm_lmp_data_request(struct ircomm_cb *self,
-                                  struct sk_buff *skb, 
+                                  struct sk_buff *skb,
                                   int not_used)
 {
        struct irda_skb_cb *cb;
@@ -189,8 +189,8 @@ static int ircomm_lmp_data_request(struct ircomm_cb *self,
        IRDA_ASSERT(skb != NULL, return -1;);
 
        cb = (struct irda_skb_cb *) skb->cb;
-       
-        cb->line = self->line;
+
+       cb->line = self->line;
 
        IRDA_DEBUG(4, "%s(), sending frame\n", __FUNCTION__ );
 
@@ -199,13 +199,13 @@ static int ircomm_lmp_data_request(struct ircomm_cb *self,
 
        skb->destructor = ircomm_lmp_flow_control;
 
-        if ((self->pkt_count++ > 7) && (self->flow_status == FLOW_START)) {
+       if ((self->pkt_count++ > 7) && (self->flow_status == FLOW_START)) {
                IRDA_DEBUG(2, "%s(), asking TTY to slow down!\n", __FUNCTION__ );
-               self->flow_status = FLOW_STOP;
-                if (self->notify.flow_indication)
-                       self->notify.flow_indication(self->notify.instance, 
-                                                    self, FLOW_STOP);
-        }
+               self->flow_status = FLOW_STOP;
+               if (self->notify.flow_indication)
+                       self->notify.flow_indication(self->notify.instance,
+                                                    self, FLOW_STOP);
+       }
        ret = irlmp_data_request(self->lsap, skb);
        if (ret) {
                IRDA_ERROR("%s(), failed\n", __FUNCTION__);
@@ -227,11 +227,11 @@ static int ircomm_lmp_data_indication(void *instance, void *sap,
        struct ircomm_cb *self = (struct ircomm_cb *) instance;
 
        IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
-       
+
        IRDA_ASSERT(self != NULL, return -1;);
        IRDA_ASSERT(self->magic == IRCOMM_MAGIC, return -1;);
        IRDA_ASSERT(skb != NULL, return -1;);
-       
+
        ircomm_do_event(self, IRCOMM_LMP_DATA_INDICATION, skb, NULL);
 
        /* Drop reference count - see ircomm_tty_data_indication(). */
@@ -241,15 +241,15 @@ static int ircomm_lmp_data_indication(void *instance, void *sap,
 }
 
 /*
- * Function ircomm_lmp_connect_confirm (instance, sap, qos, max_sdu_size, 
+ * Function ircomm_lmp_connect_confirm (instance, sap, qos, max_sdu_size,
  *                                       max_header_size, skb)
  *
  *    Connection has been confirmed by peer device
  *
  */
 static void ircomm_lmp_connect_confirm(void *instance, void *sap,
-                                      struct qos_info *qos, 
-                                      __u32 max_seg_size, 
+                                      struct qos_info *qos,
+                                      __u32 max_seg_size,
                                       __u8 max_header_size,
                                       struct sk_buff *skb)
 {
@@ -312,7 +312,7 @@ static void ircomm_lmp_connect_indication(void *instance, void *sap,
  *    Peer device has closed the connection, or the link went down for some
  *    other reason
  */
-static void ircomm_lmp_disconnect_indication(void *instance, void *sap, 
+static void ircomm_lmp_disconnect_indication(void *instance, void *sap,
                                             LM_REASON reason,
                                             struct sk_buff *skb)
 {
index a39f5735a90bffeb854d843fbeb58091ba93419c..fbac13e95b28826223f7470a823c50cd8b3f7668 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************************
- *                
+ *
  * Filename:      ircomm_param.c
  * Version:       1.0
  * Description:   Parameter handling for the IrCOMM protocol
@@ -8,24 +8,24 @@
  * Created at:    Mon Jun  7 10:25:11 1999
  * Modified at:   Sun Jan 30 14:32:03 2000
  * Modified by:   Dag Brattli <dagb@cs.uit.no>
- * 
+ *
  *     Copyright (c) 1999-2000 Dag Brattli, All Rights Reserved.
- *     
- *     This program is free software; you can redistribute it and/or 
- *     modify it under the terms of the GNU General Public License as 
- *     published by the Free Software Foundation; either version 2 of 
+ *
+ *     This program is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU General Public License as
+ *     published by the Free Software Foundation; either version 2 of
  *     the License, or (at your option) any later version.
- * 
+ *
  *     This program is distributed in the hope that it will be useful,
  *     but WITHOUT ANY WARRANTY; without even the implied warranty of
  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  *     GNU General Public License for more details.
- * 
- *     You should have received a copy of the GNU General Public License 
- *     along with this program; if not, write to the Free Software 
- *     Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
+ *
+ *     You should have received a copy of the GNU General Public License
+ *     along with this program; if not, write to the Free Software
+ *     Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  *     MA 02111-1307 USA
- *     
+ *
  ********************************************************************/
 
 #include <linux/sched.h>
 
 #include <net/irda/ircomm_param.h>
 
-static int ircomm_param_service_type(void *instance, irda_param_t *param, 
+static int ircomm_param_service_type(void *instance, irda_param_t *param,
                                     int get);
-static int ircomm_param_port_type(void *instance, irda_param_t *param, 
+static int ircomm_param_port_type(void *instance, irda_param_t *param,
                                  int get);
-static int ircomm_param_port_name(void *instance, irda_param_t *param, 
+static int ircomm_param_port_name(void *instance, irda_param_t *param,
                                  int get);
-static int ircomm_param_service_type(void *instance, irda_param_t *param, 
+static int ircomm_param_service_type(void *instance, irda_param_t *param,
                                     int get);
-static int ircomm_param_data_rate(void *instance, irda_param_t *param, 
+static int ircomm_param_data_rate(void *instance, irda_param_t *param,
                                  int get);
-static int ircomm_param_data_format(void *instance, irda_param_t *param, 
+static int ircomm_param_data_format(void *instance, irda_param_t *param,
                                    int get);
-static int ircomm_param_flow_control(void *instance, irda_param_t *param, 
+static int ircomm_param_flow_control(void *instance, irda_param_t *param,
                                     int get);
 static int ircomm_param_xon_xoff(void *instance, irda_param_t *param, int get);
 static int ircomm_param_enq_ack(void *instance, irda_param_t *param, int get);
-static int ircomm_param_line_status(void *instance, irda_param_t *param, 
+static int ircomm_param_line_status(void *instance, irda_param_t *param,
                                    int get);
 static int ircomm_param_dte(void *instance, irda_param_t *param, int get);
 static int ircomm_param_dce(void *instance, irda_param_t *param, int get);
@@ -85,7 +85,7 @@ static pi_minor_info_t pi_minor_call_table_9_wire[] = {
 static pi_major_info_t pi_major_call_table[] = {
        { pi_minor_call_table_common,  3 },
        { pi_minor_call_table_non_raw, 6 },
-       { pi_minor_call_table_9_wire,  3 }
+       { pi_minor_call_table_9_wire,  3 }
 /*     { pi_minor_call_table_centronics }  */
 };
 
@@ -119,20 +119,20 @@ int ircomm_param_request(struct ircomm_tty_cb *self, __u8 pi, int flush)
 
        spin_lock_irqsave(&self->spinlock, flags);
 
-       skb = self->ctrl_skb;   
+       skb = self->ctrl_skb;
        if (!skb) {
                skb = alloc_skb(256, GFP_ATOMIC);
                if (!skb) {
                        spin_unlock_irqrestore(&self->spinlock, flags);
                        return -ENOMEM;
                }
-               
+
                skb_reserve(skb, self->max_header_size);
                self->ctrl_skb = skb;
        }
-       /* 
+       /*
         * Inserting is a little bit tricky since we don't know how much
-        * room we will need. But this should hopefully work OK 
+        * room we will need. But this should hopefully work OK
         */
        count = irda_param_insert(self, pi, skb->tail, skb_tailroom(skb),
                                  &ircomm_param_info);
@@ -162,7 +162,7 @@ int ircomm_param_request(struct ircomm_tty_cb *self, __u8 pi, int flush)
  *    query and then the remote device sends its initial parameters
  *
  */
-static int ircomm_param_service_type(void *instance, irda_param_t *param, 
+static int ircomm_param_service_type(void *instance, irda_param_t *param,
                                     int get)
 {
        struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance;
@@ -179,7 +179,7 @@ static int ircomm_param_service_type(void *instance, irda_param_t *param,
        /* Find all common service types */
        service_type &= self->service_type;
        if (!service_type) {
-               IRDA_DEBUG(2, 
+               IRDA_DEBUG(2,
                           "%s(), No common service type to use!\n", __FUNCTION__ );
                return -1;
        }
@@ -198,12 +198,12 @@ static int ircomm_param_service_type(void *instance, irda_param_t *param,
        else if (service_type & IRCOMM_3_WIRE_RAW)
                self->settings.service_type = IRCOMM_3_WIRE_RAW;
 
-       IRDA_DEBUG(0, "%s(), resulting service type=0x%02x\n", __FUNCTION__ , 
+       IRDA_DEBUG(0, "%s(), resulting service type=0x%02x\n", __FUNCTION__ ,
                   self->settings.service_type);
 
-       /* 
+       /*
         * Now the line is ready for some communication. Check if we are a
-         * server, and send over some initial parameters.
+        * server, and send over some initial parameters.
         * Client do it in ircomm_tty_state_setup().
         * Note : we may get called from ircomm_tty_getvalue_confirm(),
         * therefore before we even have open any socket. And self->client
@@ -235,13 +235,13 @@ static int ircomm_param_port_type(void *instance, irda_param_t *param, int get)
 
        IRDA_ASSERT(self != NULL, return -1;);
        IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
-       
+
        if (get)
                param->pv.i = IRCOMM_SERIAL;
        else {
                self->settings.port_type = (__u8) param->pv.i;
 
-               IRDA_DEBUG(0, "%s(), port type=%d\n", __FUNCTION__ , 
+               IRDA_DEBUG(0, "%s(), port type=%d\n", __FUNCTION__ ,
                           self->settings.port_type);
        }
        return 0;
@@ -256,7 +256,7 @@ static int ircomm_param_port_type(void *instance, irda_param_t *param, int get)
 static int ircomm_param_port_name(void *instance, irda_param_t *param, int get)
 {
        struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance;
-       
+
        IRDA_ASSERT(self != NULL, return -1;);
        IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
 
@@ -279,7 +279,7 @@ static int ircomm_param_port_name(void *instance, irda_param_t *param, int get)
 static int ircomm_param_data_rate(void *instance, irda_param_t *param, int get)
 {
        struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance;
-       
+
        IRDA_ASSERT(self != NULL, return -1;);
        IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
 
@@ -287,7 +287,7 @@ static int ircomm_param_data_rate(void *instance, irda_param_t *param, int get)
                param->pv.i = self->settings.data_rate;
        else
                self->settings.data_rate = param->pv.i;
-       
+
        IRDA_DEBUG(2, "%s(), data rate = %d\n", __FUNCTION__ , param->pv.i);
 
        return 0;
@@ -299,7 +299,7 @@ static int ircomm_param_data_rate(void *instance, irda_param_t *param, int get)
  *    Exchange data format to be used in this settings
  *
  */
-static int ircomm_param_data_format(void *instance, irda_param_t *param, 
+static int ircomm_param_data_format(void *instance, irda_param_t *param,
                                    int get)
 {
        struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance;
@@ -311,7 +311,7 @@ static int ircomm_param_data_format(void *instance, irda_param_t *param,
                param->pv.i = self->settings.data_format;
        else
                self->settings.data_format = (__u8) param->pv.i;
-       
+
        return 0;
 }
 
@@ -321,14 +321,14 @@ static int ircomm_param_data_format(void *instance, irda_param_t *param,
  *    Exchange flow control settings to be used in this settings
  *
  */
-static int ircomm_param_flow_control(void *instance, irda_param_t *param, 
+static int ircomm_param_flow_control(void *instance, irda_param_t *param,
                                     int get)
 {
        struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance;
 
        IRDA_ASSERT(self != NULL, return -1;);
        IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
-       
+
        if (get)
                param->pv.i = self->settings.flow_control;
        else
@@ -351,7 +351,7 @@ static int ircomm_param_xon_xoff(void *instance, irda_param_t *param, int get)
 
        IRDA_ASSERT(self != NULL, return -1;);
        IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
-       
+
        if (get) {
                param->pv.i = self->settings.xonxoff[0];
                param->pv.i |= self->settings.xonxoff[1] << 8;
@@ -360,7 +360,7 @@ static int ircomm_param_xon_xoff(void *instance, irda_param_t *param, int get)
                self->settings.xonxoff[1] = (__u16) param->pv.i >> 8;
        }
 
-       IRDA_DEBUG(0, "%s(), XON/XOFF = 0x%02x,0x%02x\n", __FUNCTION__ , 
+       IRDA_DEBUG(0, "%s(), XON/XOFF = 0x%02x,0x%02x\n", __FUNCTION__ ,
                   param->pv.i & 0xff, param->pv.i >> 8);
 
        return 0;
@@ -378,7 +378,7 @@ static int ircomm_param_enq_ack(void *instance, irda_param_t *param, int get)
 
        IRDA_ASSERT(self != NULL, return -1;);
        IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
-       
+
        if (get) {
                param->pv.i = self->settings.enqack[0];
                param->pv.i |= self->settings.enqack[1] << 8;
@@ -396,10 +396,10 @@ static int ircomm_param_enq_ack(void *instance, irda_param_t *param, int get)
 /*
  * Function ircomm_param_line_status (self, param)
  *
- *    
+ *
  *
  */
-static int ircomm_param_line_status(void *instance, irda_param_t *param, 
+static int ircomm_param_line_status(void *instance, irda_param_t *param,
                                    int get)
 {
        IRDA_DEBUG(2, "%s(), not impl.\n", __FUNCTION__ );
@@ -427,7 +427,7 @@ static int ircomm_param_dte(void *instance, irda_param_t *param, int get)
                dte = (__u8) param->pv.i;
 
                self->settings.dce = 0;
-                               
+
                if (dte & IRCOMM_DELTA_DTR)
                        self->settings.dce |= (IRCOMM_DELTA_DSR|
                                              IRCOMM_DELTA_RI |
@@ -436,7 +436,7 @@ static int ircomm_param_dte(void *instance, irda_param_t *param, int get)
                        self->settings.dce |= (IRCOMM_DSR|
                                              IRCOMM_RI |
                                              IRCOMM_CD);
-               
+
                if (dte & IRCOMM_DELTA_RTS)
                        self->settings.dce |= IRCOMM_DELTA_CTS;
                if (dte & IRCOMM_RTS)
@@ -455,7 +455,7 @@ static int ircomm_param_dte(void *instance, irda_param_t *param, int get)
 /*
  * Function ircomm_param_dce (instance, param)
  *
- *    
+ *
  *
  */
 static int ircomm_param_dce(void *instance, irda_param_t *param, int get)
index d98bf3570d290691ef8d9bb373da996f4725b20c..bb06ebaadd16f481741032ca39c8cd54cc55dbd7 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************************
- *                
+ *
  * Filename:      ircomm_ttp.c
  * Version:       1.0
  * Description:   Interface between IrCOMM and IrTTP
@@ -8,25 +8,25 @@
  * Created at:    Sun Jun  6 20:48:27 1999
  * Modified at:   Mon Dec 13 11:35:13 1999
  * Modified by:   Dag Brattli <dagb@cs.uit.no>
- * 
+ *
  *     Copyright (c) 1999 Dag Brattli, All Rights Reserved.
  *     Copyright (c) 2000-2003 Jean Tourrilhes <jt@hpl.hp.com>
- *     
- *     This program is free software; you can redistribute it and/or 
- *     modify it under the terms of the GNU General Public License as 
- *     published by the Free Software Foundation; either version 2 of 
+ *
+ *     This program is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU General Public License as
+ *     published by the Free Software Foundation; either version 2 of
  *     the License, or (at your option) any later version.
- * 
+ *
  *     This program is distributed in the hope that it will be useful,
  *     but WITHOUT ANY WARRANTY; without even the implied warranty of
  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  *     GNU General Public License for more details.
- * 
- *     You should have received a copy of the GNU General Public License 
- *     along with this program; if not, write to the Free Software 
- *     Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
+ *
+ *     You should have received a copy of the GNU General Public License
+ *     along with this program; if not, write to the Free Software
+ *     Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  *     MA 02111-1307 USA
- *     
+ *
  ********************************************************************/
 
 #include <linux/sched.h>
@@ -43,8 +43,8 @@
 static int ircomm_ttp_data_indication(void *instance, void *sap,
                                      struct sk_buff *skb);
 static void ircomm_ttp_connect_confirm(void *instance, void *sap,
-                                      struct qos_info *qos, 
-                                      __u32 max_sdu_size, 
+                                      struct qos_info *qos,
+                                      __u32 max_sdu_size,
                                       __u8 max_header_size,
                                       struct sk_buff *skb);
 static void ircomm_ttp_connect_indication(void *instance, void *sap,
@@ -54,25 +54,25 @@ static void ircomm_ttp_connect_indication(void *instance, void *sap,
                                          struct sk_buff *skb);
 static void ircomm_ttp_flow_indication(void *instance, void *sap,
                                       LOCAL_FLOW cmd);
-static void ircomm_ttp_disconnect_indication(void *instance, void *sap, 
+static void ircomm_ttp_disconnect_indication(void *instance, void *sap,
                                             LM_REASON reason,
                                             struct sk_buff *skb);
 static int ircomm_ttp_data_request(struct ircomm_cb *self,
-                                  struct sk_buff *skb, 
+                                  struct sk_buff *skb,
                                   int clen);
-static int ircomm_ttp_connect_request(struct ircomm_cb *self, 
-                                     struct sk_buff *userdata, 
+static int ircomm_ttp_connect_request(struct ircomm_cb *self,
+                                     struct sk_buff *userdata,
                                      struct ircomm_info *info);
 static int ircomm_ttp_connect_response(struct ircomm_cb *self,
                                       struct sk_buff *userdata);
-static int ircomm_ttp_disconnect_request(struct ircomm_cb *self, 
-                                        struct sk_buff *userdata, 
+static int ircomm_ttp_disconnect_request(struct ircomm_cb *self,
+                                        struct sk_buff *userdata,
                                         struct ircomm_info *info);
 
 /*
  * Function ircomm_open_tsap (self)
  *
- *    
+ *
  *
  */
 int ircomm_open_tsap(struct ircomm_cb *self)
@@ -113,11 +113,11 @@ int ircomm_open_tsap(struct ircomm_cb *self)
 /*
  * Function ircomm_ttp_connect_request (self, userdata)
  *
- *    
+ *
  *
  */
-static int ircomm_ttp_connect_request(struct ircomm_cb *self, 
-                                     struct sk_buff *userdata, 
+static int ircomm_ttp_connect_request(struct ircomm_cb *self,
+                                     struct sk_buff *userdata,
                                      struct ircomm_info *info)
 {
        int ret = 0;
@@ -129,16 +129,16 @@ static int ircomm_ttp_connect_request(struct ircomm_cb *self,
                skb_get(userdata);
 
        ret = irttp_connect_request(self->tsap, info->dlsap_sel,
-                                   info->saddr, info->daddr, NULL, 
-                                   TTP_SAR_DISABLE, userdata); 
+                                   info->saddr, info->daddr, NULL,
+                                   TTP_SAR_DISABLE, userdata);
 
        return ret;
-}      
+}
 
 /*
  * Function ircomm_ttp_connect_response (self, skb)
  *
- *    
+ *
  *
  */
 static int ircomm_ttp_connect_response(struct ircomm_cb *self,
@@ -147,7 +147,7 @@ static int ircomm_ttp_connect_response(struct ircomm_cb *self,
        int ret;
 
        IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
-       
+
        /* Don't forget to refcount it - should be NULL anyway */
        if(userdata)
                skb_get(userdata);
@@ -160,14 +160,14 @@ static int ircomm_ttp_connect_response(struct ircomm_cb *self,
 /*
  * Function ircomm_ttp_data_request (self, userdata)
  *
- *    Send IrCOMM data to IrTTP layer. Currently we do not try to combine 
- *    control data with pure data, so they will be sent as separate frames. 
+ *    Send IrCOMM data to IrTTP layer. Currently we do not try to combine
+ *    control data with pure data, so they will be sent as separate frames.
  *    Should not be a big problem though, since control frames are rare. But
- *    some of them are sent after connection establishment, so this can 
+ *    some of them are sent after connection establishment, so this can
  *    increase the latency a bit.
  */
 static int ircomm_ttp_data_request(struct ircomm_cb *self,
-                                  struct sk_buff *skb, 
+                                  struct sk_buff *skb,
                                   int clen)
 {
        int ret;
@@ -176,7 +176,7 @@ static int ircomm_ttp_data_request(struct ircomm_cb *self,
 
        IRDA_DEBUG(2, "%s(), clen=%d\n", __FUNCTION__ , clen);
 
-       /* 
+       /*
         * Insert clen field, currently we either send data only, or control
         * only frames, to make things easier and avoid queueing
         */
@@ -210,7 +210,7 @@ static int ircomm_ttp_data_indication(void *instance, void *sap,
        struct ircomm_cb *self = (struct ircomm_cb *) instance;
 
        IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
-       
+
        IRDA_ASSERT(self != NULL, return -1;);
        IRDA_ASSERT(self->magic == IRCOMM_MAGIC, return -1;);
        IRDA_ASSERT(skb != NULL, return -1;);
@@ -224,8 +224,8 @@ static int ircomm_ttp_data_indication(void *instance, void *sap,
 }
 
 static void ircomm_ttp_connect_confirm(void *instance, void *sap,
-                                      struct qos_info *qos, 
-                                      __u32 max_sdu_size, 
+                                      struct qos_info *qos,
+                                      __u32 max_sdu_size,
                                       __u8 max_header_size,
                                       struct sk_buff *skb)
 {
@@ -261,7 +261,7 @@ out:
  * Function ircomm_ttp_connect_indication (instance, sap, qos, max_sdu_size,
  *                                         max_header_size, skb)
  *
- *    
+ *
  *
  */
 static void ircomm_ttp_connect_indication(void *instance, void *sap,
@@ -301,11 +301,11 @@ out:
 /*
  * Function ircomm_ttp_disconnect_request (self, userdata, info)
  *
- *    
+ *
  *
  */
-static int ircomm_ttp_disconnect_request(struct ircomm_cb *self, 
-                                        struct sk_buff *userdata, 
+static int ircomm_ttp_disconnect_request(struct ircomm_cb *self,
+                                        struct sk_buff *userdata,
                                         struct ircomm_info *info)
 {
        int ret;
@@ -322,10 +322,10 @@ static int ircomm_ttp_disconnect_request(struct ircomm_cb *self,
 /*
  * Function ircomm_ttp_disconnect_indication (instance, sap, reason, skb)
  *
- *    
+ *
  *
  */
-static void ircomm_ttp_disconnect_indication(void *instance, void *sap, 
+static void ircomm_ttp_disconnect_indication(void *instance, void *sap,
                                             LM_REASON reason,
                                             struct sk_buff *skb)
 {
@@ -361,7 +361,7 @@ static void ircomm_ttp_flow_indication(void *instance, void *sap,
 
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == IRCOMM_MAGIC, return;);
-       
+
        if (self->notify.flow_indication)
                self->notify.flow_indication(self->notify.instance, self, cmd);
 }
index 262bda808d96762b2f96c9dc149f5460be4c1e0c..3d241e415a2ae67f25f9854090c1c6723b8cedf2 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************************
- *                
+ *
  * Filename:      ircomm_tty.c
  * Version:       1.0
  * Description:   IrCOMM serial TTY driver
@@ -9,25 +9,25 @@
  * Modified at:   Wed Feb 23 00:09:02 2000
  * Modified by:   Dag Brattli <dagb@cs.uit.no>
  * Sources:       serial.c and previous IrCOMM work by Takahide Higuchi
- * 
+ *
  *     Copyright (c) 1999-2000 Dag Brattli, All Rights Reserved.
  *     Copyright (c) 2000-2003 Jean Tourrilhes <jt@hpl.hp.com>
- *     
- *     This program is free software; you can redistribute it and/or 
- *     modify it under the terms of the GNU General Public License as 
- *     published by the Free Software Foundation; either version 2 of 
+ *
+ *     This program is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU General Public License as
+ *     published by the Free Software Foundation; either version 2 of
  *     the License, or (at your option) any later version.
- * 
+ *
  *     This program is distributed in the hope that it will be useful,
  *     but WITHOUT ANY WARRANTY; without even the implied warranty of
  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  *     GNU General Public License for more details.
- * 
- *     You should have received a copy of the GNU General Public License 
- *     along with this program; if not, write to the Free Software 
- *     Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
+ *
+ *     You should have received a copy of the GNU General Public License
+ *     along with this program; if not, write to the Free Software
+ *     Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  *     MA 02111-1307 USA
- *     
+ *
  ********************************************************************/
 
 #include <linux/init.h>
@@ -69,7 +69,7 @@ static int ircomm_tty_data_indication(void *instance, void *sap,
                                      struct sk_buff *skb);
 static int ircomm_tty_control_indication(void *instance, void *sap,
                                         struct sk_buff *skb);
-static void ircomm_tty_flow_indication(void *instance, void *sap, 
+static void ircomm_tty_flow_indication(void *instance, void *sap,
                                       LOCAL_FLOW cmd);
 #ifdef CONFIG_PROC_FS
 static int ircomm_tty_read_proc(char *buf, char **start, off_t offset, int len,
@@ -113,7 +113,7 @@ static int __init ircomm_tty_init(void)
        driver = alloc_tty_driver(IRCOMM_TTY_PORTS);
        if (!driver)
                return -ENOMEM;
-       ircomm_tty = hashbin_new(HB_LOCK); 
+       ircomm_tty = hashbin_new(HB_LOCK);
        if (ircomm_tty == NULL) {
                IRDA_ERROR("%s(), can't allocate hashbin!\n", __FUNCTION__);
                put_tty_driver(driver);
@@ -163,11 +163,11 @@ static void __exit ircomm_tty_cleanup(void)
 {
        int ret;
 
-       IRDA_DEBUG(4, "%s()\n", __FUNCTION__ ); 
+       IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
 
        ret = tty_unregister_driver(driver);
-        if (ret) {
-                IRDA_ERROR("%s(), failed to unregister driver\n",
+       if (ret) {
+               IRDA_ERROR("%s(), failed to unregister driver\n",
                           __FUNCTION__);
                return;
        }
@@ -179,7 +179,7 @@ static void __exit ircomm_tty_cleanup(void)
 /*
  * Function ircomm_startup (self)
  *
- *    
+ *
  *
  */
 static int ircomm_tty_startup(struct ircomm_tty_cb *self)
@@ -203,17 +203,17 @@ static int ircomm_tty_startup(struct ircomm_tty_cb *self)
        /* These callbacks we must handle ourselves */
        notify.data_indication       = ircomm_tty_data_indication;
        notify.udata_indication      = ircomm_tty_control_indication;
-       notify.flow_indication       = ircomm_tty_flow_indication;
+       notify.flow_indication       = ircomm_tty_flow_indication;
 
        /* Use the ircomm_tty interface for these ones */
-       notify.disconnect_indication = ircomm_tty_disconnect_indication;
+       notify.disconnect_indication = ircomm_tty_disconnect_indication;
        notify.connect_confirm       = ircomm_tty_connect_confirm;
-       notify.connect_indication    = ircomm_tty_connect_indication;
+       notify.connect_indication    = ircomm_tty_connect_indication;
        strlcpy(notify.name, "ircomm_tty", sizeof(notify.name));
        notify.instance = self;
 
        if (!self->ircomm) {
-               self->ircomm = ircomm_open(&notify, self->service_type, 
+               self->ircomm = ircomm_open(&notify, self->service_type,
                                           self->line);
        }
        if (!self->ircomm)
@@ -237,10 +237,10 @@ err:
 /*
  * Function ircomm_block_til_ready (self, filp)
  *
- *    
+ *
  *
  */
-static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self, 
+static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
                                      struct file *filp)
 {
        DECLARE_WAITQUEUE(wait, current);
@@ -248,7 +248,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
        int             do_clocal = 0, extra_count = 0;
        unsigned long   flags;
        struct tty_struct *tty;
-       
+
        IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
 
        tty = self->tty;
@@ -256,7 +256,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
        /*
         * If non-blocking mode is set, or the port is not enabled,
         * then make the check up front and then exit.
-        */     
+        */
        if (filp->f_flags & O_NONBLOCK || tty->flags & (1 << TTY_IO_ERROR)){
                /* nonblock mode is set or port is not enabled */
                self->flags |= ASYNC_NORMAL_ACTIVE;
@@ -268,17 +268,17 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
                IRDA_DEBUG(1, "%s(), doing CLOCAL!\n", __FUNCTION__ );
                do_clocal = 1;
        }
-       
+
        /* Wait for carrier detect and the line to become
         * free (i.e., not in use by the callout).  While we are in
         * this loop, self->open_count is dropped by one, so that
         * mgsl_close() knows when to free things.  We restore it upon
         * exit, either normal or abnormal.
         */
-        
+
        retval = 0;
        add_wait_queue(&self->open_wait, &wait);
-       
+
        IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
              __FILE__,__LINE__, tty->driver->name, self->open_count );
 
@@ -290,7 +290,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
        }
        spin_unlock_irqrestore(&self->spinlock, flags);
        self->blocked_open++;
-       
+
        while (1) {
                if (tty->termios->c_cflag & CBAUD) {
                        /* Here, we use to lock those two guys, but
@@ -298,45 +298,45 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
                         * I don't see the point (and I see the deadlock).
                         * Jean II */
                        self->settings.dte |= IRCOMM_RTS + IRCOMM_DTR;
-                       
+
                        ircomm_param_request(self, IRCOMM_DTE, TRUE);
                }
-               
+
                current->state = TASK_INTERRUPTIBLE;
-               
+
                if (tty_hung_up_p(filp) ||
                    !test_bit(ASYNC_B_INITIALIZED, &self->flags)) {
                        retval = (self->flags & ASYNC_HUP_NOTIFY) ?
                                        -EAGAIN : -ERESTARTSYS;
                        break;
                }
-               
-               /*  
+
+               /*
                 * Check if link is ready now. Even if CLOCAL is
                 * specified, we cannot return before the IrCOMM link is
-                * ready 
+                * ready
                 */
-               if (!test_bit(ASYNC_B_CLOSING, &self->flags) &&
-                   (do_clocal || (self->settings.dce & IRCOMM_CD)) &&
+               if (!test_bit(ASYNC_B_CLOSING, &self->flags) &&
+                   (do_clocal || (self->settings.dce & IRCOMM_CD)) &&
                    self->state == IRCOMM_TTY_READY)
                {
-                       break;
+                       break;
                }
-                       
+
                if (signal_pending(current)) {
                        retval = -ERESTARTSYS;
                        break;
                }
-               
+
                IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
                      __FILE__,__LINE__, tty->driver->name, self->open_count );
-               
+
                schedule();
        }
-       
+
        __set_current_state(TASK_RUNNING);
        remove_wait_queue(&self->open_wait, &wait);
-       
+
        if (extra_count) {
                /* ++ is not atomic, so this should be protected - Jean II */
                spin_lock_irqsave(&self->spinlock, flags);
@@ -344,14 +344,14 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
                spin_unlock_irqrestore(&self->spinlock, flags);
        }
        self->blocked_open--;
-       
+
        IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
              __FILE__,__LINE__, tty->driver->name, self->open_count);
-                        
+
        if (!retval)
                self->flags |= ASYNC_NORMAL_ACTIVE;
-               
-       return retval;  
+
+       return retval;
 }
 
 /*
@@ -384,7 +384,7 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
                        IRDA_ERROR("%s(), kmalloc failed!\n", __FUNCTION__);
                        return -ENOMEM;
                }
-               
+
                self->magic = IRCOMM_TTY_MAGIC;
                self->flow = FLOW_STOP;
 
@@ -398,13 +398,13 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
                /* Init some important stuff */
                init_timer(&self->watchdog_timer);
                init_waitqueue_head(&self->open_wait);
-               init_waitqueue_head(&self->close_wait);
+               init_waitqueue_head(&self->close_wait);
                spin_lock_init(&self->spinlock);
 
-               /* 
+               /*
                 * Force TTY into raw mode by default which is usually what
                 * we want for IrCOMM and IrLPT. This way applications will
-                * not have to twiddle with printcap etc.  
+                * not have to twiddle with printcap etc.
                 */
                tty->termios->c_iflag = 0;
                tty->termios->c_oflag = 0;
@@ -420,7 +420,7 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
        self->tty = tty;
        spin_unlock_irqrestore(&self->spinlock, flags);
 
-       IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __FUNCTION__ , tty->driver->name, 
+       IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __FUNCTION__ , tty->driver->name,
                   self->line, self->open_count);
 
        /* Not really used by us, but lets do it anyway */
@@ -473,7 +473,7 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
 
        ret = ircomm_tty_block_til_ready(self, filp);
        if (ret) {
-               IRDA_DEBUG(2, 
+               IRDA_DEBUG(2,
                      "%s(), returning after block_til_ready with %d\n", __FUNCTION__ ,
                      ret);
 
@@ -519,7 +519,7 @@ static void ircomm_tty_close(struct tty_struct *tty, struct file *filp)
                 * serial port won't be shutdown.
                 */
                IRDA_DEBUG(0, "%s(), bad serial port count; "
-                          "tty->count is 1, state->count is %d\n", __FUNCTION__ , 
+                          "tty->count is 1, state->count is %d\n", __FUNCTION__ ,
                           self->open_count);
                self->open_count = 1;
        }
@@ -546,7 +546,7 @@ static void ircomm_tty_close(struct tty_struct *tty, struct file *filp)
        spin_unlock_irqrestore(&self->spinlock, flags);
 
        /*
-        * Now we wait for the transmit buffer to clear; and we notify 
+        * Now we wait for the transmit buffer to clear; and we notify
         * the line discipline to only process XON/XOFF characters.
         */
        tty->closing = 1;
@@ -576,7 +576,7 @@ static void ircomm_tty_close(struct tty_struct *tty, struct file *filp)
 /*
  * Function ircomm_tty_flush_buffer (tty)
  *
- *    
+ *
  *
  */
 static void ircomm_tty_flush_buffer(struct tty_struct *tty)
@@ -586,9 +586,9 @@ static void ircomm_tty_flush_buffer(struct tty_struct *tty)
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
 
-       /* 
-        * Let do_softint() do this to avoid race condition with 
-        * do_softint() ;-) 
+       /*
+        * Let do_softint() do this to avoid race condition with
+        * do_softint() ;-)
         */
        schedule_work(&self->tqueue);
 }
@@ -597,7 +597,7 @@ static void ircomm_tty_flush_buffer(struct tty_struct *tty)
  * Function ircomm_tty_do_softint (work)
  *
  *    We use this routine to give the write wakeup to the user at at a
- *    safe time (as fast as possible after write have completed). This 
+ *    safe time (as fast as possible after write have completed). This
  *    can be compared to the Tx interrupt.
  */
 static void ircomm_tty_do_softint(struct work_struct *work)
@@ -638,7 +638,7 @@ static void ircomm_tty_do_softint(struct work_struct *work)
 
        /* Unlink transmit buffer */
        spin_lock_irqsave(&self->spinlock, flags);
-       
+
        skb = self->tx_skb;
        self->tx_skb = NULL;
 
@@ -650,9 +650,9 @@ static void ircomm_tty_do_softint(struct work_struct *work)
                /* Drop reference count - see ircomm_ttp_data_request(). */
                dev_kfree_skb(skb);
        }
-               
+
        /* Check if user (still) wants to be waken up */
-       if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && 
+       if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
            tty->ldisc.write_wakeup)
        {
                (tty->ldisc.write_wakeup)(tty);
@@ -717,12 +717,12 @@ static int ircomm_tty_write(struct tty_struct *tty,
        /* Fetch current transmit buffer */
        skb = self->tx_skb;
 
-       /*  
+       /*
         * Send out all the data we get, possibly as multiple fragmented
         * frames, but this will only happen if the data is larger than the
         * max data size. The normal case however is just the opposite, and
         * this function may be called multiple times, and will then actually
-        * defragment the data and send it out as one packet as soon as 
+        * defragment the data and send it out as one packet as soon as
         * possible, but at a safer point in time
         */
        while (count) {
@@ -731,16 +731,16 @@ static int ircomm_tty_write(struct tty_struct *tty,
                /* Adjust data size to the max data size */
                if (size > self->max_data_size)
                        size = self->max_data_size;
-               
-               /* 
+
+               /*
                 * Do we already have a buffer ready for transmit, or do
-                * we need to allocate a new frame 
+                * we need to allocate a new frame
                 */
-               if (skb) {                      
-                       /* 
-                        * Any room for more data at the end of the current 
+               if (skb) {
+                       /*
+                        * Any room for more data at the end of the current
                         * transmit buffer? Cannot use skb_tailroom, since
-                        * dev_alloc_skb gives us a larger skb than we 
+                        * dev_alloc_skb gives us a larger skb than we
                         * requested
                         * Note : use tx_data_size, because max_data_size
                         * may have changed and we don't want to overwrite
@@ -751,8 +751,8 @@ static int ircomm_tty_write(struct tty_struct *tty,
                                if (size > tailroom)
                                        size = tailroom;
                        } else {
-                               /* 
-                                * Current transmit frame is full, so break 
+                               /*
+                                * Current transmit frame is full, so break
                                 * out, so we can send it as soon as possible
                                 */
                                break;
@@ -782,15 +782,15 @@ static int ircomm_tty_write(struct tty_struct *tty,
 
        spin_unlock_irqrestore(&self->spinlock, flags);
 
-       /*     
+       /*
         * Schedule a new thread which will transmit the frame as soon
         * as possible, but at a safe point in time. We do this so the
         * "user" can give us data multiple times, as PPP does (because of
         * its 256 byte tx buffer). We will then defragment and send out
-        * all this data as one single packet.  
+        * all this data as one single packet.
         */
        schedule_work(&self->tqueue);
-       
+
        return len;
 }
 
@@ -846,7 +846,7 @@ static void ircomm_tty_wait_until_sent(struct tty_struct *tty, int timeout)
        struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data;
        unsigned long orig_jiffies, poll_time;
        unsigned long flags;
-       
+
        IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
 
        IRDA_ASSERT(self != NULL, return;);
@@ -876,7 +876,7 @@ static void ircomm_tty_wait_until_sent(struct tty_struct *tty, int timeout)
  *
  *    This routine notifies the tty driver that input buffers for the line
  *    discipline are close to full, and it should somehow signal that no
- *    more characters should be sent to the tty.  
+ *    more characters should be sent to the tty.
  */
 static void ircomm_tty_throttle(struct tty_struct *tty)
 {
@@ -890,16 +890,16 @@ static void ircomm_tty_throttle(struct tty_struct *tty)
        /* Software flow control? */
        if (I_IXOFF(tty))
                ircomm_tty_send_xchar(tty, STOP_CHAR(tty));
-       
+
        /* Hardware flow control? */
        if (tty->termios->c_cflag & CRTSCTS) {
                self->settings.dte &= ~IRCOMM_RTS;
                self->settings.dte |= IRCOMM_DELTA_RTS;
-       
+
                ircomm_param_request(self, IRCOMM_DTE, TRUE);
        }
 
-        ircomm_flow_request(self->ircomm, FLOW_STOP);
+       ircomm_flow_request(self->ircomm, FLOW_STOP);
 }
 
 /*
@@ -930,7 +930,7 @@ static void ircomm_tty_unthrottle(struct tty_struct *tty)
                ircomm_param_request(self, IRCOMM_DTE, TRUE);
                IRDA_DEBUG(1, "%s(), FLOW_START\n", __FUNCTION__ );
        }
-        ircomm_flow_request(self->ircomm, FLOW_START);
+       ircomm_flow_request(self->ircomm, FLOW_START);
 }
 
 /*
@@ -975,7 +975,7 @@ static void ircomm_tty_shutdown(struct ircomm_tty_cb *self)
        spin_lock_irqsave(&self->spinlock, flags);
 
        del_timer(&self->watchdog_timer);
-       
+
        /* Free parameter buffer */
        if (self->ctrl_skb) {
                dev_kfree_skb(self->ctrl_skb);
@@ -1001,7 +1001,7 @@ static void ircomm_tty_shutdown(struct ircomm_tty_cb *self)
  *
  *    This routine notifies the tty driver that it should hangup the tty
  *    device.
- * 
+ *
  */
 static void ircomm_tty_hangup(struct tty_struct *tty)
 {
@@ -1044,7 +1044,7 @@ static void ircomm_tty_send_xchar(struct tty_struct *tty, char ch)
  * Function ircomm_tty_start (tty)
  *
  *    This routine notifies the tty driver that it resume sending
- *    characters to the tty device.  
+ *    characters to the tty device.
  */
 void ircomm_tty_start(struct tty_struct *tty)
 {
@@ -1057,9 +1057,9 @@ void ircomm_tty_start(struct tty_struct *tty)
  * Function ircomm_tty_stop (tty)
  *
  *     This routine notifies the tty driver that it should stop outputting
- *     characters to the tty device. 
+ *     characters to the tty device.
  */
-static void ircomm_tty_stop(struct tty_struct *tty) 
+static void ircomm_tty_stop(struct tty_struct *tty)
 {
        struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data;
 
@@ -1094,14 +1094,14 @@ void ircomm_tty_check_modem_status(struct ircomm_tty_cb *self)
                /*wake_up_interruptible(&self->delta_msr_wait);*/
        }
        if ((self->flags & ASYNC_CHECK_CD) && (status & IRCOMM_DELTA_CD)) {
-               IRDA_DEBUG(2, 
+               IRDA_DEBUG(2,
                           "%s(), ircomm%d CD now %s...\n", __FUNCTION__ , self->line,
                           (status & IRCOMM_CD) ? "on" : "off");
 
                if (status & IRCOMM_CD) {
                        wake_up_interruptible(&self->open_wait);
                } else {
-                       IRDA_DEBUG(2, 
+                       IRDA_DEBUG(2,
                                   "%s(), Doing serial hangup..\n", __FUNCTION__ );
                        if (tty)
                                tty_hangup(tty);
@@ -1113,10 +1113,10 @@ void ircomm_tty_check_modem_status(struct ircomm_tty_cb *self)
        if (self->flags & ASYNC_CTS_FLOW) {
                if (tty->hw_stopped) {
                        if (status & IRCOMM_CTS) {
-                               IRDA_DEBUG(2, 
+                               IRDA_DEBUG(2,
                                           "%s(), CTS tx start...\n", __FUNCTION__ );
                                tty->hw_stopped = 0;
-                               
+
                                /* Wake up processes blocked on open */
                                wake_up_interruptible(&self->open_wait);
 
@@ -1125,7 +1125,7 @@ void ircomm_tty_check_modem_status(struct ircomm_tty_cb *self)
                        }
                } else {
                        if (!(status & IRCOMM_CTS)) {
-                               IRDA_DEBUG(2, 
+                               IRDA_DEBUG(2,
                                           "%s(), CTS tx stop...\n", __FUNCTION__ );
                                tty->hw_stopped = 1;
                        }
@@ -1145,7 +1145,7 @@ static int ircomm_tty_data_indication(void *instance, void *sap,
        struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance;
 
        IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
-       
+
        IRDA_ASSERT(self != NULL, return -1;);
        IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
        IRDA_ASSERT(skb != NULL, return -1;);
@@ -1155,10 +1155,10 @@ static int ircomm_tty_data_indication(void *instance, void *sap,
                return 0;
        }
 
-       /* 
+       /*
         * If we receive data when hardware is stopped then something is wrong.
         * We try to poll the peers line settings to check if we are up todate.
-        * Devices like WinCE can do this, and since they don't send any 
+        * Devices like WinCE can do this, and since they don't send any
         * params, we can just as well declare the hardware for running.
         */
        if (self->tty->hw_stopped && (self->flow == FLOW_START)) {
@@ -1170,9 +1170,9 @@ static int ircomm_tty_data_indication(void *instance, void *sap,
                ircomm_tty_link_established(self);
        }
 
-       /* 
+       /*
         * Just give it over to the line discipline. There is no need to
-        * involve the flip buffers, since we are not running in an interrupt 
+        * involve the flip buffers, since we are not running in an interrupt
         * handler
         */
        self->tty->ldisc.receive_buf(self->tty, skb->data, NULL, skb->len);
@@ -1195,14 +1195,14 @@ static int ircomm_tty_control_indication(void *instance, void *sap,
        int clen;
 
        IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
-       
+
        IRDA_ASSERT(self != NULL, return -1;);
        IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
        IRDA_ASSERT(skb != NULL, return -1;);
 
        clen = skb->data[0];
 
-       irda_param_extract_all(self, skb->data+1, IRDA_MIN(skb->len-1, clen), 
+       irda_param_extract_all(self, skb->data+1, IRDA_MIN(skb->len-1, clen),
                               &ircomm_param_info);
 
        /* No need to kfree_skb - see ircomm_control_indication() */
@@ -1217,7 +1217,7 @@ static int ircomm_tty_control_indication(void *instance, void *sap,
  *    transmission of data. We just mark the hardware as stopped, and wait
  *    for IrTTP to notify us that things are OK again.
  */
-static void ircomm_tty_flow_indication(void *instance, void *sap, 
+static void ircomm_tty_flow_indication(void *instance, void *sap,
                                       LOCAL_FLOW cmd)
 {
        struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance;
@@ -1247,7 +1247,7 @@ static void ircomm_tty_flow_indication(void *instance, void *sap,
 
 static int ircomm_tty_line_info(struct ircomm_tty_cb *self, char *buf)
 {
-        int  ret=0;
+       int  ret=0;
 
        ret += sprintf(buf+ret, "State: %s\n", ircomm_tty_state[self->state]);
 
@@ -1260,37 +1260,37 @@ static int ircomm_tty_line_info(struct ircomm_tty_cb *self, char *buf)
                ret += sprintf(buf+ret, "3_WIRE_RAW");
        else
                ret += sprintf(buf+ret, "No common service type!\n");
-        ret += sprintf(buf+ret, "\n");
+       ret += sprintf(buf+ret, "\n");
 
        ret += sprintf(buf+ret, "Port name: %s\n", self->settings.port_name);
 
-       ret += sprintf(buf+ret, "DTE status: ");        
-        if (self->settings.dte & IRCOMM_RTS)
-                ret += sprintf(buf+ret, "RTS|");
-        if (self->settings.dte & IRCOMM_DTR)
-                ret += sprintf(buf+ret, "DTR|");
+       ret += sprintf(buf+ret, "DTE status: ");
+       if (self->settings.dte & IRCOMM_RTS)
+               ret += sprintf(buf+ret, "RTS|");
+       if (self->settings.dte & IRCOMM_DTR)
+               ret += sprintf(buf+ret, "DTR|");
        if (self->settings.dte)
                ret--; /* remove the last | */
-        ret += sprintf(buf+ret, "\n");
+       ret += sprintf(buf+ret, "\n");
 
        ret += sprintf(buf+ret, "DCE status: ");
-        if (self->settings.dce & IRCOMM_CTS)
-                ret += sprintf(buf+ret, "CTS|");
-        if (self->settings.dce & IRCOMM_DSR)
-                ret += sprintf(buf+ret, "DSR|");
-        if (self->settings.dce & IRCOMM_CD)
-                ret += sprintf(buf+ret, "CD|");
-        if (self->settings.dce & IRCOMM_RI) 
-                ret += sprintf(buf+ret, "RI|");
+       if (self->settings.dce & IRCOMM_CTS)
+               ret += sprintf(buf+ret, "CTS|");
+       if (self->settings.dce & IRCOMM_DSR)
+               ret += sprintf(buf+ret, "DSR|");
+       if (self->settings.dce & IRCOMM_CD)
+               ret += sprintf(buf+ret, "CD|");
+       if (self->settings.dce & IRCOMM_RI)
+               ret += sprintf(buf+ret, "RI|");
        if (self->settings.dce)
                ret--; /* remove the last | */
-        ret += sprintf(buf+ret, "\n");
+       ret += sprintf(buf+ret, "\n");
 
        ret += sprintf(buf+ret, "Configuration: ");
        if (!self->settings.null_modem)
                ret += sprintf(buf+ret, "DTE <-> DCE\n");
        else
-               ret += sprintf(buf+ret, 
+               ret += sprintf(buf+ret,
                               "DTE <-> DTE (null modem emulation)\n");
 
        ret += sprintf(buf+ret, "Data rate: %d\n", self->settings.data_rate);
@@ -1314,7 +1314,7 @@ static int ircomm_tty_line_info(struct ircomm_tty_cb *self, char *buf)
                ret += sprintf(buf+ret, "ENQ_ACK_OUT|");
        if (self->settings.flow_control)
                ret--; /* remove the last | */
-        ret += sprintf(buf+ret, "\n");
+       ret += sprintf(buf+ret, "\n");
 
        ret += sprintf(buf+ret, "Flags: ");
        if (self->flags & ASYNC_CTS_FLOW)
@@ -1333,25 +1333,25 @@ static int ircomm_tty_line_info(struct ircomm_tty_cb *self, char *buf)
                ret--; /* remove the last | */
        ret += sprintf(buf+ret, "\n");
 
-       ret += sprintf(buf+ret, "Role: %s\n", self->client ? 
+       ret += sprintf(buf+ret, "Role: %s\n", self->client ?
                       "client" : "server");
        ret += sprintf(buf+ret, "Open count: %d\n", self->open_count);
        ret += sprintf(buf+ret, "Max data size: %d\n", self->max_data_size);
        ret += sprintf(buf+ret, "Max header size: %d\n", self->max_header_size);
-               
+
        if (self->tty)
-               ret += sprintf(buf+ret, "Hardware: %s\n", 
+               ret += sprintf(buf+ret, "Hardware: %s\n",
                               self->tty->hw_stopped ? "Stopped" : "Running");
 
-        ret += sprintf(buf+ret, "\n");
-        return ret;
+       ret += sprintf(buf+ret, "\n");
+       return ret;
 }
 
 
 /*
  * Function ircomm_tty_read_proc (buf, start, offset, len, eof, unused)
  *
- *    
+ *
  *
  */
 #ifdef CONFIG_PROC_FS
@@ -1359,8 +1359,8 @@ static int ircomm_tty_read_proc(char *buf, char **start, off_t offset, int len,
                                int *eof, void *unused)
 {
        struct ircomm_tty_cb *self;
-        int count = 0, l;
-        off_t begin = 0;
+       int count = 0, l;
+       off_t begin = 0;
        unsigned long flags;
 
        spin_lock_irqsave(&ircomm_tty->hb_spinlock, flags);
@@ -1370,25 +1370,25 @@ static int ircomm_tty_read_proc(char *buf, char **start, off_t offset, int len,
                if (self->magic != IRCOMM_TTY_MAGIC)
                        break;
 
-                l = ircomm_tty_line_info(self, buf + count);
-                count += l;
-                if (count+begin > offset+len)
-                        goto done;
-                if (count+begin < offset) {
-                        begin += count;
-                        count = 0;
-                }
-                               
+               l = ircomm_tty_line_info(self, buf + count);
+               count += l;
+               if (count+begin > offset+len)
+                       goto done;
+               if (count+begin < offset) {
+                       begin += count;
+                       count = 0;
+               }
+
                self = (struct ircomm_tty_cb *) hashbin_get_next(ircomm_tty);
-        }
-        *eof = 1;
+       }
+       *eof = 1;
 done:
        spin_unlock_irqrestore(&ircomm_tty->hb_spinlock, flags);
 
-        if (offset >= count+begin)
-                return 0;
-        *start = buf + (offset-begin);
-        return ((len < begin+count-offset) ? len : begin+count-offset);
+       if (offset >= count+begin)
+               return 0;
+       *start = buf + (offset-begin);
+       return ((len < begin+count-offset) ? len : begin+count-offset);
 }
 #endif /* CONFIG_PROC_FS */
 
index 99f5eddbb4b78281c39b6e0e359b1a3d88f78cca..8d7ba93e4e09e98a0a692ff17be135e1dc0e3d32 100644 (file)
@@ -1,32 +1,32 @@
 /*********************************************************************
- *                
+ *
  * Filename:      ircomm_tty_attach.c
- * Version:       
+ * Version:
  * Description:   Code for attaching the serial driver to IrCOMM
  * Status:        Experimental.
  * Author:        Dag Brattli <dagb@cs.uit.no>
  * Created at:    Sat Jun  5 17:42:00 1999
  * Modified at:   Tue Jan  4 14:20:49 2000
  * Modified by:   Dag Brattli <dagb@cs.uit.no>
- * 
+ *
  *     Copyright (c) 1999-2000 Dag Brattli, All Rights Reserved.
  *     Copyright (c) 2000-2003 Jean Tourrilhes <jt@hpl.hp.com>
- *     
- *     This program is free software; you can redistribute it and/or 
- *     modify it under the terms of the GNU General Public License as 
- *     published by the Free Software Foundation; either version 2 of 
+ *
+ *     This program is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU General Public License as
+ *     published by the Free Software Foundation; either version 2 of
  *     the License, or (at your option) any later version.
- * 
+ *
  *     This program is distributed in the hope that it will be useful,
  *     but WITHOUT ANY WARRANTY; without even the implied warranty of
  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  *     GNU General Public License for more details.
- * 
- *     You should have received a copy of the GNU General Public License 
- *     along with this program; if not, write to the Free Software 
- *     Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
+ *
+ *     You should have received a copy of the GNU General Public License
+ *     along with this program; if not, write to the Free Software
+ *     Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  *     MA 02111-1307 USA
- *     
+ *
  ********************************************************************/
 
 #include <linux/sched.h>
@@ -50,35 +50,35 @@ static void ircomm_tty_ias_register(struct ircomm_tty_cb *self);
 static void ircomm_tty_discovery_indication(discinfo_t *discovery,
                                            DISCOVERY_MODE mode,
                                            void *priv);
-static void ircomm_tty_getvalue_confirm(int result, __u16 obj_id, 
+static void ircomm_tty_getvalue_confirm(int result, __u16 obj_id,
                                        struct ias_value *value, void *priv);
 static void ircomm_tty_start_watchdog_timer(struct ircomm_tty_cb *self,
                                            int timeout);
 static void ircomm_tty_watchdog_timer_expired(void *data);
 
-static int ircomm_tty_state_idle(struct ircomm_tty_cb *self, 
-                                IRCOMM_TTY_EVENT event, 
-                                struct sk_buff *skb, 
+static int ircomm_tty_state_idle(struct ircomm_tty_cb *self,
+                                IRCOMM_TTY_EVENT event,
+                                struct sk_buff *skb,
                                 struct ircomm_tty_info *info);
-static int ircomm_tty_state_search(struct ircomm_tty_cb *self, 
-                                  IRCOMM_TTY_EVENT event, 
-                                  struct sk_buff *skb, 
+static int ircomm_tty_state_search(struct ircomm_tty_cb *self,
+                                  IRCOMM_TTY_EVENT event,
+                                  struct sk_buff *skb,
                                   struct ircomm_tty_info *info);
-static int ircomm_tty_state_query_parameters(struct ircomm_tty_cb *self, 
-                                            IRCOMM_TTY_EVENT event, 
-                                            struct sk_buff *skb, 
+static int ircomm_tty_state_query_parameters(struct ircomm_tty_cb *self,
+                                            IRCOMM_TTY_EVENT event,
+                                            struct sk_buff *skb,
                                             struct ircomm_tty_info *info);
-static int ircomm_tty_state_query_lsap_sel(struct ircomm_tty_cb *self, 
-                                          IRCOMM_TTY_EVENT event, 
-                                          struct sk_buff *skb, 
+static int ircomm_tty_state_query_lsap_sel(struct ircomm_tty_cb *self,
+                                          IRCOMM_TTY_EVENT event,
+                                          struct sk_buff *skb,
                                           struct ircomm_tty_info *info);
-static int ircomm_tty_state_setup(struct ircomm_tty_cb *self, 
-                                 IRCOMM_TTY_EVENT event, 
-                                 struct sk_buff *skb, 
+static int ircomm_tty_state_setup(struct ircomm_tty_cb *self,
+                                 IRCOMM_TTY_EVENT event,
+                                 struct sk_buff *skb,
                                  struct ircomm_tty_info *info);
-static int ircomm_tty_state_ready(struct ircomm_tty_cb *self, 
-                                 IRCOMM_TTY_EVENT event, 
-                                 struct sk_buff *skb, 
+static int ircomm_tty_state_ready(struct ircomm_tty_cb *self,
+                                 IRCOMM_TTY_EVENT event,
+                                 struct sk_buff *skb,
                                  struct ircomm_tty_info *info);
 
 char *ircomm_tty_state[] = {
@@ -111,7 +111,7 @@ static char *ircomm_tty_event[] = {
 #endif /* CONFIG_IRDA_DEBUG */
 
 static int (*state[])(struct ircomm_tty_cb *self, IRCOMM_TTY_EVENT event,
-                     struct sk_buff *skb, struct ircomm_tty_info *info) = 
+                     struct sk_buff *skb, struct ircomm_tty_info *info) =
 {
        ircomm_tty_state_idle,
        ircomm_tty_state_search,
@@ -125,7 +125,7 @@ static int (*state[])(struct ircomm_tty_cb *self, IRCOMM_TTY_EVENT event,
  * Function ircomm_tty_attach_cable (driver)
  *
  *    Try to attach cable (IrCOMM link). This function will only return
- *    when the link has been connected, or if an error condition occurs. 
+ *    when the link has been connected, or if an error condition occurs.
  *    If success, the return value is the resulting service type.
  */
 int ircomm_tty_attach_cable(struct ircomm_tty_cb *self)
@@ -135,7 +135,7 @@ int ircomm_tty_attach_cable(struct ircomm_tty_cb *self)
        IRDA_ASSERT(self != NULL, return -1;);
        IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
 
-               /* Check if somebody has already connected to us */
+       /* Check if somebody has already connected to us */
        if (ircomm_is_connected(self->ircomm)) {
                IRDA_DEBUG(0, "%s(), already connected!\n", __FUNCTION__ );
                return 0;
@@ -177,7 +177,7 @@ void ircomm_tty_detach_cable(struct ircomm_tty_cb *self)
                self->skey = NULL;
        }
 
-       if (self->iriap) { 
+       if (self->iriap) {
                iriap_close(self->iriap);
                self->iriap = NULL;
        }
@@ -212,7 +212,7 @@ static void ircomm_tty_ias_register(struct ircomm_tty_cb *self)
 
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
-       
+
        /* Compute hint bits based on service */
        hints = irlmp_service_to_hint(S_COMM);
        if (self->service_type & IRCOMM_3_WIRE_RAW)
@@ -234,19 +234,19 @@ static void ircomm_tty_ias_register(struct ircomm_tty_cb *self)
        if (self->service_type & IRCOMM_3_WIRE_RAW) {
                /* Register IrLPT with LM-IAS */
                self->obj = irias_new_object("IrLPT", IAS_IRLPT_ID);
-               irias_add_integer_attrib(self->obj, "IrDA:IrLMP:LsapSel", 
+               irias_add_integer_attrib(self->obj, "IrDA:IrLMP:LsapSel",
                                         self->slsap_sel, IAS_KERNEL_ATTR);
        } else {
                /* Register IrCOMM with LM-IAS */
                self->obj = irias_new_object("IrDA:IrCOMM", IAS_IRCOMM_ID);
-               irias_add_integer_attrib(self->obj, "IrDA:TinyTP:LsapSel", 
+               irias_add_integer_attrib(self->obj, "IrDA:TinyTP:LsapSel",
                                         self->slsap_sel, IAS_KERNEL_ATTR);
-               
+
                /* Code the parameters into the buffer */
-               irda_param_pack(oct_seq, "bbbbbb", 
+               irda_param_pack(oct_seq, "bbbbbb",
                                IRCOMM_SERVICE_TYPE, 1, self->service_type,
                                IRCOMM_PORT_TYPE,    1, IRCOMM_SERIAL);
-               
+
                /* Register parameters with LM-IAS */
                irias_add_octseq_attrib(self->obj, "Parameters", oct_seq, 6,
                                        IAS_KERNEL_ATTR);
@@ -302,23 +302,23 @@ int ircomm_tty_send_initial_parameters(struct ircomm_tty_cb *self)
        IRDA_ASSERT(self != NULL, return -1;);
        IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
 
-       if (self->service_type & IRCOMM_3_WIRE_RAW) 
+       if (self->service_type & IRCOMM_3_WIRE_RAW)
                return 0;
 
-       /* 
-        * Set default values, but only if the application for some reason 
+       /*
+        * Set default values, but only if the application for some reason
         * haven't set them already
         */
-       IRDA_DEBUG(2, "%s(), data-rate = %d\n", __FUNCTION__ , 
+       IRDA_DEBUG(2, "%s(), data-rate = %d\n", __FUNCTION__ ,
                   self->settings.data_rate);
        if (!self->settings.data_rate)
                self->settings.data_rate = 9600;
-       IRDA_DEBUG(2, "%s(), data-format = %d\n", __FUNCTION__ , 
+       IRDA_DEBUG(2, "%s(), data-format = %d\n", __FUNCTION__ ,
                   self->settings.data_format);
        if (!self->settings.data_format)
                self->settings.data_format = IRCOMM_WSIZE_8;  /* 8N1 */
 
-       IRDA_DEBUG(2, "%s(), flow-control = %d\n", __FUNCTION__ , 
+       IRDA_DEBUG(2, "%s(), flow-control = %d\n", __FUNCTION__ ,
                   self->settings.flow_control);
        /*self->settings.flow_control = IRCOMM_RTS_CTS_IN|IRCOMM_RTS_CTS_OUT;*/
 
@@ -330,7 +330,7 @@ int ircomm_tty_send_initial_parameters(struct ircomm_tty_cb *self)
                ircomm_param_request(self, IRCOMM_SERVICE_TYPE, FALSE);
        ircomm_param_request(self, IRCOMM_DATA_RATE, FALSE);
        ircomm_param_request(self, IRCOMM_DATA_FORMAT, FALSE);
-       
+
        /* For a 3 wire service, we just flush the last parameter and return */
        if (self->settings.service_type == IRCOMM_3_WIRE) {
                ircomm_param_request(self, IRCOMM_FLOW_CONTROL, TRUE);
@@ -342,10 +342,10 @@ int ircomm_tty_send_initial_parameters(struct ircomm_tty_cb *self)
 #if 0
        ircomm_param_request(self, IRCOMM_XON_XOFF, FALSE);
        ircomm_param_request(self, IRCOMM_ENQ_ACK, FALSE);
-#endif 
+#endif
        /* Notify peer that we are ready to receive data */
        ircomm_param_request(self, IRCOMM_DTE, TRUE);
-       
+
        return 0;
 }
 
@@ -388,8 +388,8 @@ static void ircomm_tty_discovery_indication(discinfo_t *discovery,
        self = (struct ircomm_tty_cb *) hashbin_get_first(ircomm_tty);
        while (self != NULL) {
                IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
-               
-               ircomm_tty_do_event(self, IRCOMM_TTY_DISCOVERY_INDICATION, 
+
+               ircomm_tty_do_event(self, IRCOMM_TTY_DISCOVERY_INDICATION,
                                    NULL, &info);
 
                self = (struct ircomm_tty_cb *) hashbin_get_next(ircomm_tty);
@@ -402,7 +402,7 @@ static void ircomm_tty_discovery_indication(discinfo_t *discovery,
  *    Link disconnected
  *
  */
-void ircomm_tty_disconnect_indication(void *instance, void *sap, 
+void ircomm_tty_disconnect_indication(void *instance, void *sap,
                                      LM_REASON reason,
                                      struct sk_buff *skb)
 {
@@ -422,7 +422,7 @@ void ircomm_tty_disconnect_indication(void *instance, void *sap,
        /* Stop data transfers */
        self->tty->hw_stopped = 1;
 
-       ircomm_tty_do_event(self, IRCOMM_TTY_DISCONNECT_INDICATION, NULL, 
+       ircomm_tty_do_event(self, IRCOMM_TTY_DISCONNECT_INDICATION, NULL,
                            NULL);
 }
 
@@ -432,8 +432,8 @@ void ircomm_tty_disconnect_indication(void *instance, void *sap,
  *    Got result from the IAS query we make
  *
  */
-static void ircomm_tty_getvalue_confirm(int result, __u16 obj_id, 
-                                       struct ias_value *value, 
+static void ircomm_tty_getvalue_confirm(int result, __u16 obj_id,
+                                       struct ias_value *value,
                                        void *priv)
 {
        struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) priv;
@@ -454,18 +454,18 @@ static void ircomm_tty_getvalue_confirm(int result, __u16 obj_id,
        }
 
        switch (value->type) {
-       case IAS_OCT_SEQ:
+       case IAS_OCT_SEQ:
                IRDA_DEBUG(2, "%s(), got octet sequence\n", __FUNCTION__ );
 
                irda_param_extract_all(self, value->t.oct_seq, value->len,
                                       &ircomm_param_info);
 
-               ircomm_tty_do_event(self, IRCOMM_TTY_GOT_PARAMETERS, NULL, 
+               ircomm_tty_do_event(self, IRCOMM_TTY_GOT_PARAMETERS, NULL,
                                    NULL);
                break;
        case IAS_INTEGER:
-               /* Got LSAP selector */ 
-               IRDA_DEBUG(2, "%s(), got lsapsel = %d\n", __FUNCTION__ , 
+               /* Got LSAP selector */
+               IRDA_DEBUG(2, "%s(), got lsapsel = %d\n", __FUNCTION__ ,
                           value->t.integer);
 
                if (value->t.integer == -1) {
@@ -491,10 +491,10 @@ static void ircomm_tty_getvalue_confirm(int result, __u16 obj_id,
  *    Connection confirmed
  *
  */
-void ircomm_tty_connect_confirm(void *instance, void *sap, 
-                               struct qos_info *qos, 
-                               __u32 max_data_size, 
-                               __u8 max_header_size, 
+void ircomm_tty_connect_confirm(void *instance, void *sap,
+                               struct qos_info *qos,
+                               __u32 max_data_size,
+                               __u8 max_header_size,
                                struct sk_buff *skb)
 {
        struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance;
@@ -515,16 +515,16 @@ void ircomm_tty_connect_confirm(void *instance, void *sap,
 }
 
 /*
- * Function ircomm_tty_connect_indication (instance, sap, qos, max_sdu_size, 
+ * Function ircomm_tty_connect_indication (instance, sap, qos, max_sdu_size,
  *                                         skb)
  *
  *    we are discovered and being requested to connect by remote device !
  *
  */
-void ircomm_tty_connect_indication(void *instance, void *sap, 
-                                  struct qos_info *qos, 
+void ircomm_tty_connect_indication(void *instance, void *sap,
+                                  struct qos_info *qos,
                                   __u32 max_data_size,
-                                  __u8 max_header_size, 
+                                  __u8 max_header_size,
                                   struct sk_buff *skb)
 {
        struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance;
@@ -542,8 +542,8 @@ void ircomm_tty_connect_indication(void *instance, void *sap,
 
        clen = skb->data[0];
        if (clen)
-               irda_param_extract_all(self, skb->data+1, 
-                                      IRDA_MIN(skb->len, clen), 
+               irda_param_extract_all(self, skb->data+1,
+                                      IRDA_MIN(skb->len, clen),
                                       &ircomm_param_info);
 
        ircomm_tty_do_event(self, IRCOMM_TTY_CONNECT_INDICATION, NULL, NULL);
@@ -566,14 +566,14 @@ void ircomm_tty_link_established(struct ircomm_tty_cb *self)
 
        if (!self->tty)
                return;
-       
+
        del_timer(&self->watchdog_timer);
 
-       /* 
+       /*
         * IrCOMM link is now up, and if we are not using hardware
         * flow-control, then declare the hardware as running. Otherwise we
         * will have to wait for the peer device (DCE) to raise the CTS
-        * line.  
+        * line.
         */
        if ((self->flags & ASYNC_CTS_FLOW) && ((self->settings.dce & IRCOMM_CTS) == 0)) {
                IRDA_DEBUG(0, "%s(), waiting for CTS ...\n", __FUNCTION__ );
@@ -582,7 +582,7 @@ void ircomm_tty_link_established(struct ircomm_tty_cb *self)
                IRDA_DEBUG(1, "%s(), starting hardware!\n", __FUNCTION__ );
 
                self->tty->hw_stopped = 0;
-       
+
                /* Wake up processes blocked on open */
                wake_up_interruptible(&self->open_wait);
        }
@@ -593,8 +593,8 @@ void ircomm_tty_link_established(struct ircomm_tty_cb *self)
 /*
  * Function ircomm_tty_start_watchdog_timer (self, timeout)
  *
- *    Start the watchdog timer. This timer is used to make sure that any 
- *    connection attempt is successful, and if not, we will retry after 
+ *    Start the watchdog timer. This timer is used to make sure that any
+ *    connection attempt is successful, and if not, we will retry after
  *    the timeout
  */
 static void ircomm_tty_start_watchdog_timer(struct ircomm_tty_cb *self,
@@ -616,7 +616,7 @@ static void ircomm_tty_start_watchdog_timer(struct ircomm_tty_cb *self,
 static void ircomm_tty_watchdog_timer_expired(void *data)
 {
        struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) data;
-       
+
        IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
 
        IRDA_ASSERT(self != NULL, return;);
@@ -633,14 +633,14 @@ static void ircomm_tty_watchdog_timer_expired(void *data)
  *
  */
 int ircomm_tty_do_event(struct ircomm_tty_cb *self, IRCOMM_TTY_EVENT event,
-                       struct sk_buff *skb, struct ircomm_tty_info *info) 
+                       struct sk_buff *skb, struct ircomm_tty_info *info)
 {
        IRDA_ASSERT(self != NULL, return -1;);
        IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
 
        IRDA_DEBUG(2, "%s: state=%s, event=%s\n", __FUNCTION__ ,
                   ircomm_tty_state[self->state], ircomm_tty_event[event]);
-       
+
        return (*state[self->state])(self, event, skb, info);
 }
 
@@ -656,7 +656,7 @@ static inline void ircomm_tty_next_state(struct ircomm_tty_cb *self, IRCOMM_TTY_
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
 
-       IRDA_DEBUG(2, "%s: next state=%s, service type=%d\n", __FUNCTION__ , 
+       IRDA_DEBUG(2, "%s: next state=%s, service type=%d\n", __FUNCTION__ ,
                   ircomm_tty_state[self->state], self->service_type);
        */
        self->state = state;
@@ -668,9 +668,9 @@ static inline void ircomm_tty_next_state(struct ircomm_tty_cb *self, IRCOMM_TTY_
  *    Just hanging around
  *
  */
-static int ircomm_tty_state_idle(struct ircomm_tty_cb *self, 
-                                IRCOMM_TTY_EVENT event, 
-                                struct sk_buff *skb, 
+static int ircomm_tty_state_idle(struct ircomm_tty_cb *self,
+                                IRCOMM_TTY_EVENT event,
+                                struct sk_buff *skb,
                                 struct ircomm_tty_info *info)
 {
        int ret = 0;
@@ -679,10 +679,10 @@ static int ircomm_tty_state_idle(struct ircomm_tty_cb *self,
                   ircomm_tty_state[self->state], ircomm_tty_event[event]);
        switch (event) {
        case IRCOMM_TTY_ATTACH_CABLE:
-               /* Try to discover any remote devices */                
+               /* Try to discover any remote devices */
                ircomm_tty_start_watchdog_timer(self, 3*HZ);
                ircomm_tty_next_state(self, IRCOMM_TTY_SEARCH);
-               
+
                irlmp_discovery_request(DISCOVERY_DEFAULT_SLOTS);
                break;
        case IRCOMM_TTY_DISCOVERY_INDICATION:
@@ -701,7 +701,7 @@ static int ircomm_tty_state_idle(struct ircomm_tty_cb *self,
                iriap_getvaluebyclass_request(self->iriap,
                                              self->saddr, self->daddr,
                                              "IrDA:IrCOMM", "Parameters");
-               
+
                ircomm_tty_start_watchdog_timer(self, 3*HZ);
                ircomm_tty_next_state(self, IRCOMM_TTY_QUERY_PARAMETERS);
                break;
@@ -732,9 +732,9 @@ static int ircomm_tty_state_idle(struct ircomm_tty_cb *self,
  *    Trying to discover an IrCOMM device
  *
  */
-static int ircomm_tty_state_search(struct ircomm_tty_cb *self, 
-                                  IRCOMM_TTY_EVENT event, 
-                                  struct sk_buff *skb, 
+static int ircomm_tty_state_search(struct ircomm_tty_cb *self,
+                                  IRCOMM_TTY_EVENT event,
+                                  struct sk_buff *skb,
                                   struct ircomm_tty_info *info)
 {
        int ret = 0;
@@ -752,19 +752,19 @@ static int ircomm_tty_state_search(struct ircomm_tty_cb *self,
                                     __FUNCTION__);
                        return -EBUSY;
                }
-               
+
                self->iriap = iriap_open(LSAP_ANY, IAS_CLIENT, self,
                                         ircomm_tty_getvalue_confirm);
-               
+
                if (self->service_type == IRCOMM_3_WIRE_RAW) {
                        iriap_getvaluebyclass_request(self->iriap, self->saddr,
-                                                     self->daddr, "IrLPT", 
+                                                     self->daddr, "IrLPT",
                                                      "IrDA:IrLMP:LsapSel");
                        ircomm_tty_next_state(self, IRCOMM_TTY_QUERY_LSAP_SEL);
                } else {
                        iriap_getvaluebyclass_request(self->iriap, self->saddr,
-                                                     self->daddr, 
-                                                     "IrDA:IrCOMM", 
+                                                     self->daddr,
+                                                     "IrDA:IrCOMM",
                                                      "Parameters");
 
                        ircomm_tty_next_state(self, IRCOMM_TTY_QUERY_PARAMETERS);
@@ -783,7 +783,7 @@ static int ircomm_tty_state_search(struct ircomm_tty_cb *self,
 #if 1
                /* Give up */
 #else
-               /* Try to discover any remote devices */                
+               /* Try to discover any remote devices */
                ircomm_tty_start_watchdog_timer(self, 3*HZ);
                irlmp_discovery_request(DISCOVERY_DEFAULT_SLOTS);
 #endif
@@ -805,9 +805,9 @@ static int ircomm_tty_state_search(struct ircomm_tty_cb *self,
  *    Querying the remote LM-IAS for IrCOMM parameters
  *
  */
-static int ircomm_tty_state_query_parameters(struct ircomm_tty_cb *self, 
-                                            IRCOMM_TTY_EVENT event, 
-                                            struct sk_buff *skb, 
+static int ircomm_tty_state_query_parameters(struct ircomm_tty_cb *self,
+                                            IRCOMM_TTY_EVENT event,
+                                            struct sk_buff *skb,
                                             struct ircomm_tty_info *info)
 {
        int ret = 0;
@@ -822,12 +822,12 @@ static int ircomm_tty_state_query_parameters(struct ircomm_tty_cb *self,
                                     __FUNCTION__);
                        return -EBUSY;
                }
-               
+
                self->iriap = iriap_open(LSAP_ANY, IAS_CLIENT, self,
                                         ircomm_tty_getvalue_confirm);
 
-               iriap_getvaluebyclass_request(self->iriap, self->saddr, 
-                                             self->daddr, "IrDA:IrCOMM", 
+               iriap_getvaluebyclass_request(self->iriap, self->saddr,
+                                             self->daddr, "IrDA:IrCOMM",
                                              "IrDA:TinyTP:LsapSel");
 
                ircomm_tty_start_watchdog_timer(self, 3*HZ);
@@ -836,7 +836,7 @@ static int ircomm_tty_state_query_parameters(struct ircomm_tty_cb *self,
        case IRCOMM_TTY_WD_TIMER_EXPIRED:
                /* Go back to search mode */
                ircomm_tty_next_state(self, IRCOMM_TTY_SEARCH);
-               ircomm_tty_start_watchdog_timer(self, 3*HZ); 
+               ircomm_tty_start_watchdog_timer(self, 3*HZ);
                break;
        case IRCOMM_TTY_CONNECT_INDICATION:
                del_timer(&self->watchdog_timer);
@@ -863,9 +863,9 @@ static int ircomm_tty_state_query_parameters(struct ircomm_tty_cb *self,
  *    Query remote LM-IAS for the LSAP selector which we can connect to
  *
  */
-static int ircomm_tty_state_query_lsap_sel(struct ircomm_tty_cb *self, 
-                                          IRCOMM_TTY_EVENT event, 
-                                          struct sk_buff *skb, 
+static int ircomm_tty_state_query_lsap_sel(struct ircomm_tty_cb *self,
+                                          IRCOMM_TTY_EVENT event,
+                                          struct sk_buff *skb,
                                           struct ircomm_tty_info *info)
 {
        int ret = 0;
@@ -877,7 +877,7 @@ static int ircomm_tty_state_query_lsap_sel(struct ircomm_tty_cb *self,
        case IRCOMM_TTY_GOT_LSAPSEL:
                /* Connect to remote device */
                ret = ircomm_connect_request(self->ircomm, self->dlsap_sel,
-                                            self->saddr, self->daddr, 
+                                            self->saddr, self->daddr,
                                             NULL, self->service_type);
                ircomm_tty_start_watchdog_timer(self, 3*HZ);
                ircomm_tty_next_state(self, IRCOMM_TTY_SETUP);
@@ -912,9 +912,9 @@ static int ircomm_tty_state_query_lsap_sel(struct ircomm_tty_cb *self,
  *    Trying to connect
  *
  */
-static int ircomm_tty_state_setup(struct ircomm_tty_cb *self, 
-                                 IRCOMM_TTY_EVENT event, 
-                                 struct sk_buff *skb, 
+static int ircomm_tty_state_setup(struct ircomm_tty_cb *self,
+                                 IRCOMM_TTY_EVENT event,
+                                 struct sk_buff *skb,
                                  struct ircomm_tty_info *info)
 {
        int ret = 0;
@@ -926,10 +926,10 @@ static int ircomm_tty_state_setup(struct ircomm_tty_cb *self,
        case IRCOMM_TTY_CONNECT_CONFIRM:
                del_timer(&self->watchdog_timer);
                ircomm_tty_ias_unregister(self);
-               
-               /* 
+
+               /*
                 * Send initial parameters. This will also send out queued
-                * parameters waiting for the connection to come up 
+                * parameters waiting for the connection to come up
                 */
                ircomm_tty_send_initial_parameters(self);
                ircomm_tty_link_established(self);
@@ -938,7 +938,7 @@ static int ircomm_tty_state_setup(struct ircomm_tty_cb *self,
        case IRCOMM_TTY_CONNECT_INDICATION:
                del_timer(&self->watchdog_timer);
                ircomm_tty_ias_unregister(self);
-               
+
                /* Accept connection */
                ircomm_connect_response(self->ircomm, NULL);
                ircomm_tty_next_state(self, IRCOMM_TTY_READY);
@@ -966,9 +966,9 @@ static int ircomm_tty_state_setup(struct ircomm_tty_cb *self,
  *    IrCOMM is now connected
  *
  */
-static int ircomm_tty_state_ready(struct ircomm_tty_cb *self, 
-                                 IRCOMM_TTY_EVENT event, 
-                                 struct sk_buff *skb, 
+static int ircomm_tty_state_ready(struct ircomm_tty_cb *self,
+                                 IRCOMM_TTY_EVENT event,
+                                 struct sk_buff *skb,
                                  struct ircomm_tty_info *info)
 {
        int ret = 0;
@@ -976,7 +976,7 @@ static int ircomm_tty_state_ready(struct ircomm_tty_cb *self,
        switch (event) {
        case IRCOMM_TTY_DATA_REQUEST:
                ret = ircomm_data_request(self->ircomm, skb);
-               break;          
+               break;
        case IRCOMM_TTY_DETACH_CABLE:
                ircomm_disconnect_request(self->ircomm, NULL);
                ircomm_tty_next_state(self, IRCOMM_TTY_IDLE);
index 75e39ea599d81147fca02e540eb03f77e3f329d0..a5174e6e7ad3264fa5cad595f4eff9aa06b4f00c 100644 (file)
@@ -1,31 +1,31 @@
 /*********************************************************************
- *                
+ *
  * Filename:      ircomm_tty_ioctl.c
- * Version:       
- * Description:   
+ * Version:
+ * Description:
  * Status:        Experimental.
  * Author:        Dag Brattli <dagb@cs.uit.no>
  * Created at:    Thu Jun 10 14:39:09 1999
  * Modified at:   Wed Jan  5 14:45:43 2000
  * Modified by:   Dag Brattli <dagb@cs.uit.no>
- * 
+ *
  *     Copyright (c) 1999-2000 Dag Brattli, All Rights Reserved.
- *     
- *     This program is free software; you can redistribute it and/or 
- *     modify it under the terms of the GNU General Public License as 
- *     published by the Free Software Foundation; either version 2 of 
+ *
+ *     This program is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU General Public License as
+ *     published by the Free Software Foundation; either version 2 of
  *     the License, or (at your option) any later version.
- * 
+ *
  *     This program is distributed in the hope that it will be useful,
  *     but WITHOUT ANY WARRANTY; without even the implied warranty of
  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  *     GNU General Public License for more details.
- * 
- *     You should have received a copy of the GNU General Public License 
- *     along with this program; if not, write to the Free Software 
- *     Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
+ *
+ *     You should have received a copy of the GNU General Public License
+ *     along with this program; if not, write to the Free Software
+ *     Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  *     MA 02111-1307 USA
- *     
+ *
  ********************************************************************/
 
 #include <linux/init.h>
@@ -75,7 +75,7 @@ static void ircomm_tty_change_speed(struct ircomm_tty_cb *self)
        }
        if (cflag & CSTOPB)
                cval |= IRCOMM_2_STOP_BIT;
-       
+
        if (cflag & PARENB)
                cval |= IRCOMM_PARITY_ENABLE;
        if (!(cflag & PARODD))
@@ -88,7 +88,7 @@ static void ircomm_tty_change_speed(struct ircomm_tty_cb *self)
 
        self->settings.data_rate = baud;
        ircomm_param_request(self, IRCOMM_DATA_RATE, FALSE);
-       
+
        /* CTS flow control flag and modem status interrupts */
        if (cflag & CRTSCTS) {
                self->flags |= ASYNC_CTS_FLOW;
@@ -104,7 +104,7 @@ static void ircomm_tty_change_speed(struct ircomm_tty_cb *self)
                self->flags &= ~ASYNC_CHECK_CD;
        else
                self->flags |= ASYNC_CHECK_CD;
-#if 0  
+#if 0
        /*
         * Set up parity check flag
         */
@@ -113,7 +113,7 @@ static void ircomm_tty_change_speed(struct ircomm_tty_cb *self)
                driver->read_status_mask |= LSR_FE | LSR_PE;
        if (I_BRKINT(driver->tty) || I_PARMRK(driver->tty))
                driver->read_status_mask |= LSR_BI;
-       
+
        /*
         * Characters to ignore
         */
@@ -124,17 +124,17 @@ static void ircomm_tty_change_speed(struct ircomm_tty_cb *self)
        if (I_IGNBRK(self->tty)) {
                self->ignore_status_mask |= LSR_BI;
                /*
-                * If we're ignore parity and break indicators, ignore 
+                * If we're ignore parity and break indicators, ignore
                 * overruns too. (For real raw support).
                 */
-               if (I_IGNPAR(self->tty)) 
+               if (I_IGNPAR(self->tty))
                        self->ignore_status_mask |= LSR_OE;
        }
 #endif
        self->settings.data_format = cval;
 
        ircomm_param_request(self, IRCOMM_DATA_FORMAT, FALSE);
-       ircomm_param_request(self, IRCOMM_FLOW_CONTROL, TRUE);
+       ircomm_param_request(self, IRCOMM_FLOW_CONTROL, TRUE);
 }
 
 /*
@@ -145,7 +145,7 @@ static void ircomm_tty_change_speed(struct ircomm_tty_cb *self)
  *    should be prepared to accept the case where old == NULL, and try to
  *    do something rational.
  */
-void ircomm_tty_set_termios(struct tty_struct *tty, 
+void ircomm_tty_set_termios(struct tty_struct *tty,
                            struct ktermios *old_termios)
 {
        struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data;
@@ -153,8 +153,8 @@ void ircomm_tty_set_termios(struct tty_struct *tty,
 
        IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
 
-       if ((cflag == old_termios->c_cflag) && 
-           (RELEVANT_IFLAG(tty->termios->c_iflag) == 
+       if ((cflag == old_termios->c_cflag) &&
+           (RELEVANT_IFLAG(tty->termios->c_iflag) ==
             RELEVANT_IFLAG(old_termios->c_iflag)))
        {
                return;
@@ -168,21 +168,21 @@ void ircomm_tty_set_termios(struct tty_struct *tty,
                self->settings.dte &= ~(IRCOMM_DTR|IRCOMM_RTS);
                ircomm_param_request(self, IRCOMM_DTE, TRUE);
        }
-       
+
        /* Handle transition away from B0 status */
        if (!(old_termios->c_cflag & CBAUD) &&
            (cflag & CBAUD)) {
                self->settings.dte |= IRCOMM_DTR;
-               if (!(tty->termios->c_cflag & CRTSCTS) || 
+               if (!(tty->termios->c_cflag & CRTSCTS) ||
                    !test_bit(TTY_THROTTLED, &tty->flags)) {
                        self->settings.dte |= IRCOMM_RTS;
                }
                ircomm_param_request(self, IRCOMM_DTE, TRUE);
        }
-       
+
        /* Handle turning off CRTSCTS */
        if ((old_termios->c_cflag & CRTSCTS) &&
-           !(tty->termios->c_cflag & CRTSCTS)) 
+           !(tty->termios->c_cflag & CRTSCTS))
        {
                tty->hw_stopped = 0;
                ircomm_tty_start(tty);
@@ -192,7 +192,7 @@ void ircomm_tty_set_termios(struct tty_struct *tty,
 /*
  * Function ircomm_tty_tiocmget (tty, file)
  *
- *    
+ *
  *
  */
 int ircomm_tty_tiocmget(struct tty_struct *tty, struct file *file)
@@ -217,12 +217,12 @@ int ircomm_tty_tiocmget(struct tty_struct *tty, struct file *file)
 /*
  * Function ircomm_tty_tiocmset (tty, file, set, clear)
  *
- *    
+ *
  *
  */
 int ircomm_tty_tiocmset(struct tty_struct *tty, struct file *file,
                        unsigned int set, unsigned int clear)
-{ 
+{
        struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data;
 
        IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
@@ -249,21 +249,21 @@ int ircomm_tty_tiocmset(struct tty_struct *tty, struct file *file,
                self->settings.dte |= IRCOMM_DELTA_DTR;
 
        ircomm_param_request(self, IRCOMM_DTE, TRUE);
-       
+
        return 0;
 }
 
 /*
  * Function get_serial_info (driver, retinfo)
  *
- *    
+ *
  *
  */
 static int ircomm_tty_get_serial_info(struct ircomm_tty_cb *self,
                                      struct serial_struct __user *retinfo)
 {
        struct serial_struct info;
-   
+
        if (!retinfo)
                return -EFAULT;
 
@@ -277,11 +277,11 @@ static int ircomm_tty_get_serial_info(struct ircomm_tty_cb *self,
        info.closing_wait = self->closing_wait;
 
        /* For compatibility  */
-       info.type = PORT_16550A;
-       info.port = 0;
-       info.irq = 0;
+       info.type = PORT_16550A;
+       info.port = 0;
+       info.irq = 0;
        info.xmit_fifo_size = 0;
-       info.hub6 = 0;   
+       info.hub6 = 0;
        info.custom_divisor = 0;
 
        if (copy_to_user(retinfo, &info, sizeof(*retinfo)))
@@ -293,7 +293,7 @@ static int ircomm_tty_get_serial_info(struct ircomm_tty_cb *self,
 /*
  * Function set_serial_info (driver, new_info)
  *
- *    
+ *
  *
  */
 static int ircomm_tty_set_serial_info(struct ircomm_tty_cb *self,
@@ -311,7 +311,7 @@ static int ircomm_tty_set_serial_info(struct ircomm_tty_cb *self,
 
        state = self
        old_state = *self;
-  
+
        if (!capable(CAP_SYS_ADMIN)) {
                if ((new_serial.baud_base != state->settings.data_rate) ||
                    (new_serial.close_delay != state->close_delay) ||
@@ -368,10 +368,10 @@ static int ircomm_tty_set_serial_info(struct ircomm_tty_cb *self,
 /*
  * Function ircomm_tty_ioctl (tty, file, cmd, arg)
  *
- *    
+ *
  *
  */
-int ircomm_tty_ioctl(struct tty_struct *tty, struct file *file, 
+int ircomm_tty_ioctl(struct tty_struct *tty, struct file *file,
                     unsigned int cmd, unsigned long arg)
 {
        struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data;
@@ -416,7 +416,7 @@ int ircomm_tty_ioctl(struct tty_struct *tty, struct file *file,
                    put_user(cnow.brk, &p_cuser->brk) ||
                    put_user(cnow.buf_overrun, &p_cuser->buf_overrun))
                        return -EFAULT;
-#endif         
+#endif
                return 0;
        default:
                ret = -ENOIOCTLCMD;  /* ioctls which we must ignore */
index 7e7a31798d8d04855fead92b2ebdb444f85ea26a..e717801b38f9c76b345df4ca5a08330e6f392f1b 100644 (file)
@@ -341,11 +341,11 @@ static void irda_task_timer_expired(void *data)
  */
 static void irda_device_setup(struct net_device *dev)
 {
-        dev->hard_header_len = 0;
-        dev->addr_len        = LAP_ALEN;
+       dev->hard_header_len = 0;
+       dev->addr_len        = LAP_ALEN;
 
-        dev->type            = ARPHRD_IRDA;
-        dev->tx_queue_len    = 8; /* Window size + 1 s-frame */
+       dev->type            = ARPHRD_IRDA;
+       dev->tx_queue_len    = 8; /* Window size + 1 s-frame */
 
        memset(dev->broadcast, 0xff, LAP_ALEN);
 
@@ -354,7 +354,7 @@ static void irda_device_setup(struct net_device *dev)
 }
 
 /*
- * Funciton  alloc_irdadev 
+ * Funciton  alloc_irdadev
  *     Allocates and sets up an IRDA device in a manner similar to
  *     alloc_etherdev.
  */
@@ -386,9 +386,9 @@ dongle_t *irda_device_dongle_init(struct net_device *dev, int type)
        /* Try to load the module needed */
        if (!reg && capable(CAP_SYS_MODULE)) {
                spin_unlock(&dongles->hb_spinlock);
-       
+
                request_module("irda-dongle-%d", type);
-               
+
                spin_lock(&dongles->hb_spinlock);
                reg = hashbin_find(dongles, type, NULL);
        }
@@ -438,15 +438,15 @@ int irda_device_register_dongle(struct dongle_reg *new)
        spin_lock(&dongles->hb_spinlock);
        /* Check if this dongle has been registered before */
        if (hashbin_find(dongles, new->type, NULL)) {
-               IRDA_MESSAGE("%s: Dongle type %x already registered\n", 
+               IRDA_MESSAGE("%s: Dongle type %x already registered\n",
                             __FUNCTION__, new->type);
-        } else {
+       } else {
                /* Insert IrDA dongle into hashbin */
                hashbin_insert(dongles, (irda_queue_t *) new, new->type, NULL);
        }
        spin_unlock(&dongles->hb_spinlock);
 
-        return 0;
+       return 0;
 }
 EXPORT_SYMBOL(irda_device_register_dongle);
 
@@ -462,7 +462,7 @@ void irda_device_unregister_dongle(struct dongle_reg *dongle)
 
        spin_lock(&dongles->hb_spinlock);
        node = hashbin_remove(dongles, dongle->type, NULL);
-       if (!node) 
+       if (!node)
                IRDA_ERROR("%s: dongle not found!\n", __FUNCTION__);
        spin_unlock(&dongles->hb_spinlock);
 }
index 8f1c6d65b24786f174bf1dbde831c97a7e7a2e99..98b0fa9657908b7600faff555b2446b887e4d0b4 100644 (file)
@@ -79,10 +79,10 @@ static int iriap_data_indication(void *instance, void *sap,
 
 static void iriap_watchdog_timer_expired(void *data);
 
-static inline void iriap_start_watchdog_timer(struct iriap_cb *self, 
-                                             int timeout) 
+static inline void iriap_start_watchdog_timer(struct iriap_cb *self,
+                                             int timeout)
 {
-       irda_start_timer(&self->watchdog_timer, timeout, self, 
+       irda_start_timer(&self->watchdog_timer, timeout, self,
                         iriap_watchdog_timer_expired);
 }
 
@@ -674,7 +674,7 @@ static void iriap_getvaluebyclass_indication(struct iriap_cb *self,
        if (attrib == NULL) {
                IRDA_DEBUG(2, "LM-IAS: Attribute %s not found\n", attr);
                iriap_getvaluebyclass_response(self, obj->id,
-                                              IAS_ATTRIB_UNKNOWN, 
+                                              IAS_ATTRIB_UNKNOWN,
                                               &irias_missing);
                return;
        }
@@ -971,7 +971,7 @@ static const char *ias_value_types[] = {
        "IAS_STRING"
 };
 
-static inline struct ias_object *irias_seq_idx(loff_t pos) 
+static inline struct ias_object *irias_seq_idx(loff_t pos)
 {
        struct ias_object *obj;
 
@@ -980,7 +980,7 @@ static inline struct ias_object *irias_seq_idx(loff_t pos)
                if (pos-- == 0)
                        break;
        }
-               
+
        return obj;
 }
 
@@ -995,7 +995,7 @@ static void *irias_seq_next(struct seq_file *seq, void *v, loff_t *pos)
 {
        ++*pos;
 
-       return (v == SEQ_START_TOKEN) 
+       return (v == SEQ_START_TOKEN)
                ? (void *) hashbin_get_first(irias_objects)
                : (void *) hashbin_get_next(irias_objects);
 }
@@ -1027,7 +1027,7 @@ static int irias_seq_show(struct seq_file *seq, void *v)
                for (attrib = (struct ias_attrib *) hashbin_get_first(obj->attribs);
                     attrib != NULL;
                     attrib = (struct ias_attrib *) hashbin_get_next(obj->attribs)) {
-                    
+
                        IRDA_ASSERT(attrib->magic == IAS_ATTRIB_MAGIC,
                                    goto outloop; );
 
@@ -1046,14 +1046,14 @@ static int irias_seq_show(struct seq_file *seq, void *v)
                                           attrib->value->t.string);
                                break;
                        case IAS_OCT_SEQ:
-                               seq_printf(seq, "octet sequence (%d bytes)\n", 
+                               seq_printf(seq, "octet sequence (%d bytes)\n",
                                           attrib->value->len);
                                break;
                        case IAS_MISSING:
                                seq_puts(seq, "missing\n");
                                break;
                        default:
-                               seq_printf(seq, "type %d?\n", 
+                               seq_printf(seq, "type %d?\n",
                                           attrib->value->type);
                        }
                        seq_putc(seq, '\n');
index b1ee99a59c0cee416137e1d4cbcb371117d6a271..4adaae242b9e44b422b46f1fe3b4fd8422db1b0d 100644 (file)
@@ -57,8 +57,8 @@ static char *strndup(char *str, size_t max)
                len = max;
 
        /* Allocate new string */
-        new_str = kmalloc(len + 1, GFP_ATOMIC);
-        if (new_str == NULL) {
+       new_str = kmalloc(len + 1, GFP_ATOMIC);
+       if (new_str == NULL) {
                IRDA_WARNING("%s: Unable to kmalloc!\n", __FUNCTION__);
                return NULL;
        }
@@ -78,7 +78,7 @@ static char *strndup(char *str, size_t max)
  */
 struct ias_object *irias_new_object( char *name, int id)
 {
-        struct ias_object *obj;
+       struct ias_object *obj;
 
        IRDA_DEBUG( 4, "%s()\n", __FUNCTION__);
 
@@ -91,6 +91,12 @@ struct ias_object *irias_new_object( char *name, int id)
 
        obj->magic = IAS_OBJECT_MAGIC;
        obj->name = strndup(name, IAS_MAX_CLASSNAME);
+       if (!obj->name) {
+               IRDA_WARNING("%s(), Unable to allocate name!\n",
+                            __FUNCTION__);
+               kfree(obj);
+               return NULL;
+       }
        obj->id = id;
 
        /* Locking notes : the attrib spinlock has lower precendence
@@ -101,6 +107,7 @@ struct ias_object *irias_new_object( char *name, int id)
        if (obj->attribs == NULL) {
                IRDA_WARNING("%s(), Unable to allocate attribs!\n",
                             __FUNCTION__);
+               kfree(obj->name);
                kfree(obj);
                return NULL;
        }
@@ -357,6 +364,15 @@ void irias_add_integer_attrib(struct ias_object *obj, char *name, int value,
 
        /* Insert value */
        attrib->value = irias_new_integer_value(value);
+       if (!attrib->name || !attrib->value) {
+               IRDA_WARNING("%s: Unable to allocate attribute!\n",
+                            __FUNCTION__);
+               if (attrib->value)
+                       irias_delete_value(attrib->value);
+               kfree(attrib->name);
+               kfree(attrib);
+               return;
+       }
 
        irias_add_attrib(obj, attrib, owner);
 }
@@ -391,6 +407,15 @@ void irias_add_octseq_attrib(struct ias_object *obj, char *name, __u8 *octets,
        attrib->name = strndup(name, IAS_MAX_ATTRIBNAME);
 
        attrib->value = irias_new_octseq_value( octets, len);
+       if (!attrib->name || !attrib->value) {
+               IRDA_WARNING("%s: Unable to allocate attribute!\n",
+                            __FUNCTION__);
+               if (attrib->value)
+                       irias_delete_value(attrib->value);
+               kfree(attrib->name);
+               kfree(attrib);
+               return;
+       }
 
        irias_add_attrib(obj, attrib, owner);
 }
@@ -424,6 +449,15 @@ void irias_add_string_attrib(struct ias_object *obj, char *name, char *value,
        attrib->name = strndup(name, IAS_MAX_ATTRIBNAME);
 
        attrib->value = irias_new_string_value(value);
+       if (!attrib->name || !attrib->value) {
+               IRDA_WARNING("%s: Unable to allocate attribute!\n",
+                            __FUNCTION__);
+               if (attrib->value)
+                       irias_delete_value(attrib->value);
+               kfree(attrib->name);
+               kfree(attrib);
+               return;
+       }
 
        irias_add_attrib(obj, attrib, owner);
 }
@@ -473,6 +507,12 @@ struct ias_value *irias_new_string_value(char *string)
        value->type = IAS_STRING;
        value->charset = CS_ASCII;
        value->t.string = strndup(string, IAS_MAX_STRING);
+       if (!value->t.string) {
+               IRDA_WARNING("%s: Unable to kmalloc!\n", __FUNCTION__);
+               kfree(value);
+               return NULL;
+       }
+
        value->len = strlen(value->t.string);
 
        return value;
index 95cf1234ea17ff2e88a088c3da5766361bbaa7e4..a4c1c954582787ced123a932d0c3f8acc5b48f18 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************************
- *                
+ *
  * Filename:      irlan_client.c
  * Version:       0.9
  * Description:   IrDA LAN Access Protocol (IrLAN) Client
  * Sources:       skeleton.c by Donald Becker <becker@CESDIS.gsfc.nasa.gov>
  *                slip.c by Laurence Culhane, <loz@holmes.demon.co.uk>
  *                          Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
- * 
- *     Copyright (c) 1998-1999 Dag Brattli <dagb@cs.uit.no>, 
+ *
+ *     Copyright (c) 1998-1999 Dag Brattli <dagb@cs.uit.no>,
  *     All Rights Reserved.
- *     
- *     This program is free software; you can redistribute it and/or 
- *     modify it under the terms of the GNU General Public License as 
- *     published by the Free Software Foundation; either version 2 of 
+ *
+ *     This program is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU General Public License as
+ *     published by the Free Software Foundation; either version 2 of
  *     the License, or (at your option) any later version.
  *
  *     Neither Dag Brattli nor University of Tromsø admit liability nor
- *     provide warranty for any of this software. This material is 
+ *     provide warranty for any of this software. This material is
  *     provided "AS-IS" and at no charge.
  *
  ********************************************************************/
 
 #undef CONFIG_IRLAN_GRATUITOUS_ARP
 
-static void irlan_client_ctrl_disconnect_indication(void *instance, void *sap, 
-                                                   LM_REASON reason, 
+static void irlan_client_ctrl_disconnect_indication(void *instance, void *sap,
+                                                   LM_REASON reason,
                                                    struct sk_buff *);
-static int irlan_client_ctrl_data_indication(void *instance, void *sap, 
+static int irlan_client_ctrl_data_indication(void *instance, void *sap,
                                             struct sk_buff *skb);
-static void irlan_client_ctrl_connect_confirm(void *instance, void *sap, 
-                                             struct qos_info *qos, 
+static void irlan_client_ctrl_connect_confirm(void *instance, void *sap,
+                                             struct qos_info *qos,
                                              __u32 max_sdu_size,
                                              __u8 max_header_size,
                                              struct sk_buff *);
-static void irlan_check_response_param(struct irlan_cb *self, char *param, 
+static void irlan_check_response_param(struct irlan_cb *self, char *param,
                                       char *value, int val_len);
 static void irlan_client_open_ctrl_tsap(struct irlan_cb *self);
 
 static void irlan_client_kick_timer_expired(void *data)
 {
        struct irlan_cb *self = (struct irlan_cb *) data;
-       
+
        IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
 
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
-       
-       /*  
+
+       /*
         * If we are in peer mode, the client may not have got the discovery
-        * indication it needs to make progress. If the client is still in 
+        * indication it needs to make progress. If the client is still in
         * IDLE state, we must kick it to, but only if the provider is not IDLE
-        */
-       if ((self->provider.access_type == ACCESS_PEER) && 
+        */
+       if ((self->provider.access_type == ACCESS_PEER) &&
            (self->client.state == IRLAN_IDLE) &&
            (self->provider.state != IRLAN_IDLE)) {
                irlan_client_wakeup(self, self->saddr, self->daddr);
@@ -92,8 +92,8 @@ static void irlan_client_kick_timer_expired(void *data)
 static void irlan_client_start_kick_timer(struct irlan_cb *self, int timeout)
 {
        IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
-       
-       irda_start_timer(&self->client.kick_timer, timeout, (void *) self, 
+
+       irda_start_timer(&self->client.kick_timer, timeout, (void *) self,
                         irlan_client_kick_timer_expired);
 }
 
@@ -110,11 +110,11 @@ void irlan_client_wakeup(struct irlan_cb *self, __u32 saddr, __u32 daddr)
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
 
-       /* 
+       /*
         * Check if we are already awake, or if we are a provider in direct
         * mode (in that case we must leave the client idle
         */
-       if ((self->client.state != IRLAN_IDLE) || 
+       if ((self->client.state != IRLAN_IDLE) ||
            (self->provider.access_type == ACCESS_DIRECT))
        {
                        IRDA_DEBUG(0, "%s(), already awake!\n", __FUNCTION__ );
@@ -135,7 +135,7 @@ void irlan_client_wakeup(struct irlan_cb *self, __u32 saddr, __u32 daddr)
        irlan_open_data_tsap(self);
 
        irlan_do_client_event(self, IRLAN_DISCOVERY_INDICATION, NULL);
-       
+
        /* Start kick timer */
        irlan_client_start_kick_timer(self, 2*HZ);
 }
@@ -148,11 +148,11 @@ void irlan_client_wakeup(struct irlan_cb *self, __u32 saddr, __u32 daddr)
  */
 void irlan_client_discovery_indication(discinfo_t *discovery,
                                       DISCOVERY_MODE mode,
-                                      void *priv) 
+                                      void *priv)
 {
        struct irlan_cb *self;
        __u32 saddr, daddr;
-       
+
        IRDA_DEBUG(1, "%s()\n", __FUNCTION__ );
 
        IRDA_ASSERT(discovery != NULL, return;);
@@ -177,35 +177,35 @@ void irlan_client_discovery_indication(discinfo_t *discovery,
 
                IRDA_DEBUG(1, "%s(), Found instance (%08x)!\n", __FUNCTION__ ,
                      daddr);
-               
+
                irlan_client_wakeup(self, saddr, daddr);
        }
 IRDA_ASSERT_LABEL(out:)
        rcu_read_unlock();
 }
-       
+
 /*
  * Function irlan_client_data_indication (handle, skb)
  *
  *    This function gets the data that is received on the control channel
  *
  */
-static int irlan_client_ctrl_data_indication(void *instance, void *sap, 
+static int irlan_client_ctrl_data_indication(void *instance, void *sap,
                                             struct sk_buff *skb)
 {
        struct irlan_cb *self;
-       
+
        IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
-       
+
        self = (struct irlan_cb *) instance;
-       
+
        IRDA_ASSERT(self != NULL, return -1;);
        IRDA_ASSERT(self->magic == IRLAN_MAGIC, return -1;);
        IRDA_ASSERT(skb != NULL, return -1;);
-       
-       irlan_do_client_event(self, IRLAN_DATA_INDICATION, skb); 
 
-       /* Ready for a new command */   
+       irlan_do_client_event(self, IRLAN_DATA_INDICATION, skb);
+
+       /* Ready for a new command */
        IRDA_DEBUG(2, "%s(), clearing tx_busy\n", __FUNCTION__ );
        self->client.tx_busy = FALSE;
 
@@ -215,27 +215,27 @@ static int irlan_client_ctrl_data_indication(void *instance, void *sap,
        return 0;
 }
 
-static void irlan_client_ctrl_disconnect_indication(void *instance, void *sap, 
-                                                   LM_REASON reason, 
-                                                   struct sk_buff *userdata) 
+static void irlan_client_ctrl_disconnect_indication(void *instance, void *sap,
+                                                   LM_REASON reason,
+                                                   struct sk_buff *userdata)
 {
        struct irlan_cb *self;
        struct tsap_cb *tsap;
        struct sk_buff *skb;
 
        IRDA_DEBUG(4, "%s(), reason=%d\n", __FUNCTION__ , reason);
-       
+
        self = (struct irlan_cb *) instance;
        tsap = (struct tsap_cb *) sap;
 
        IRDA_ASSERT(self != NULL, return;);
-       IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);       
+       IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
        IRDA_ASSERT(tsap != NULL, return;);
        IRDA_ASSERT(tsap->magic == TTP_TSAP_MAGIC, return;);
-       
+
        IRDA_ASSERT(tsap == self->client.tsap_ctrl, return;);
 
-               /* Remove frames queued on the control channel */
+       /* Remove frames queued on the control channel */
        while ((skb = skb_dequeue(&self->client.txq)) != NULL) {
                dev_kfree_skb(skb);
        }
@@ -272,7 +272,7 @@ static void irlan_client_open_ctrl_tsap(struct irlan_cb *self)
        notify.disconnect_indication = irlan_client_ctrl_disconnect_indication;
        notify.instance = self;
        strlcpy(notify.name, "IrLAN ctrl (c)", sizeof(notify.name));
-       
+
        tsap = irttp_open_tsap(LSAP_ANY, DEFAULT_INITIAL_CREDIT, &notify);
        if (!tsap) {
                IRDA_DEBUG(2, "%s(), Got no tsap!\n", __FUNCTION__ );
@@ -287,11 +287,11 @@ static void irlan_client_open_ctrl_tsap(struct irlan_cb *self)
  *    Connection to peer IrLAN laye confirmed
  *
  */
-static void irlan_client_ctrl_connect_confirm(void *instance, void *sap, 
-                                             struct qos_info *qos, 
+static void irlan_client_ctrl_connect_confirm(void *instance, void *sap,
+                                             struct qos_info *qos,
                                              __u32 max_sdu_size,
                                              __u8 max_header_size,
-                                             struct sk_buff *skb) 
+                                             struct sk_buff *skb)
 {
        struct irlan_cb *self;
 
@@ -316,7 +316,7 @@ static void irlan_client_ctrl_connect_confirm(void *instance, void *sap,
  *    Print return code of request to peer IrLAN layer.
  *
  */
-static void print_ret_code(__u8 code) 
+static void print_ret_code(__u8 code)
 {
        switch(code) {
        case 0:
@@ -358,7 +358,7 @@ static void print_ret_code(__u8 code)
 /*
  * Function irlan_client_parse_response (self, skb)
  *
- *    Extract all parameters from received buffer, then feed them to 
+ *    Extract all parameters from received buffer, then feed them to
  *    check_params for parsing
  */
 void irlan_client_parse_response(struct irlan_cb *self, struct sk_buff *skb)
@@ -369,30 +369,30 @@ void irlan_client_parse_response(struct irlan_cb *self, struct sk_buff *skb)
        int ret;
        __u16 val_len;
        int i;
-        char *name;
-        char *value;
+       char *name;
+       char *value;
+
+       IRDA_ASSERT(skb != NULL, return;);
 
-       IRDA_ASSERT(skb != NULL, return;);      
-       
        IRDA_DEBUG(4, "%s() skb->len=%d\n", __FUNCTION__ , (int) skb->len);
-       
+
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
-       
+
        if (!skb) {
                IRDA_ERROR("%s(), Got NULL skb!\n", __FUNCTION__);
                return;
        }
        frame = skb->data;
-       
-       /* 
-        *  Check return code and print it if not success 
+
+       /*
+        *  Check return code and print it if not success
         */
        if (frame[0]) {
                print_ret_code(frame[0]);
                return;
        }
-       
+
        name = kmalloc(255, GFP_ATOMIC);
        if (!name)
                return;
@@ -406,11 +406,11 @@ void irlan_client_parse_response(struct irlan_cb *self, struct sk_buff *skb)
        count = frame[1];
 
        IRDA_DEBUG(4, "%s(), got %d parameters\n", __FUNCTION__ , count);
-       
+
        ptr = frame+2;
 
        /* For all parameters */
-       for (i=0; i<count;i++) {
+       for (i=0; i<count;i++) {
                ret = irlan_extract_param(ptr, name, value, &val_len);
                if (ret < 0) {
                        IRDA_DEBUG(2, "%s(), IrLAN, Error!\n", __FUNCTION__ );
@@ -418,7 +418,7 @@ void irlan_client_parse_response(struct irlan_cb *self, struct sk_buff *skb)
                }
                ptr += ret;
                irlan_check_response_param(self, name, value, val_len);
-       }
+       }
        /* Cleanup */
        kfree(name);
        kfree(value);
@@ -430,8 +430,8 @@ void irlan_client_parse_response(struct irlan_cb *self, struct sk_buff *skb)
  *     Check which parameter is received and update local variables
  *
  */
-static void irlan_check_response_param(struct irlan_cb *self, char *param, 
-                                      char *value, int val_len) 
+static void irlan_check_response_param(struct irlan_cb *self, char *param,
+                                      char *value, int val_len)
 {
        __u16 tmp_cpu; /* Temporary value in host order */
        __u8 *bytes;
@@ -465,7 +465,7 @@ static void irlan_check_response_param(struct irlan_cb *self, char *param,
                        self->client.filter_type |= IRLAN_BROADCAST;
                else if (strcmp(value, "IPX_SOCKET") == 0)
                        self->client.filter_type |= IRLAN_IPX_SOCKET;
-               
+
        }
        if (strcmp(param, "ACCESS_TYPE") == 0) {
                if (strcmp(value, "DIRECT") == 0)
@@ -480,7 +480,7 @@ static void irlan_check_response_param(struct irlan_cb *self, char *param,
        }
        /* IRLAN version */
        if (strcmp(param, "IRLAN_VER") == 0) {
-               IRDA_DEBUG(4, "IrLAN version %d.%d\n", (__u8) value[0], 
+               IRDA_DEBUG(4, "IrLAN version %d.%d\n", (__u8) value[0],
                      (__u8) value[1]);
 
                self->version[0] = value[0];
@@ -497,17 +497,17 @@ static void irlan_check_response_param(struct irlan_cb *self, char *param,
                memcpy(&tmp_cpu, value, 2); /* Align value */
                le16_to_cpus(&tmp_cpu);     /* Convert to host order */
                self->client.recv_arb_val = tmp_cpu;
-               IRDA_DEBUG(2, "%s(), receive arb val=%d\n", __FUNCTION__ , 
+               IRDA_DEBUG(2, "%s(), receive arb val=%d\n", __FUNCTION__ ,
                           self->client.recv_arb_val);
        }
        if (strcmp(param, "MAX_FRAME") == 0) {
                memcpy(&tmp_cpu, value, 2); /* Align value */
                le16_to_cpus(&tmp_cpu);     /* Convert to host order */
                self->client.max_frame = tmp_cpu;
-               IRDA_DEBUG(4, "%s(), max frame=%d\n", __FUNCTION__ , 
+               IRDA_DEBUG(4, "%s(), max frame=%d\n", __FUNCTION__ ,
                           self->client.max_frame);
        }
-        
+
        /* RECONNECT_KEY, in case the link goes down! */
        if (strcmp(param, "RECONNECT_KEY") == 0) {
                IRDA_DEBUG(4, "Got reconnect key: ");
@@ -521,9 +521,9 @@ static void irlan_check_response_param(struct irlan_cb *self, char *param,
        if (strcmp(param, "FILTER_ENTRY") == 0) {
                bytes = value;
                IRDA_DEBUG(4, "Ethernet address = %02x:%02x:%02x:%02x:%02x:%02x\n",
-                     bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], 
+                     bytes[0], bytes[1], bytes[2], bytes[3], bytes[4],
                      bytes[5]);
-               for (i = 0; i < 6; i++) 
+               for (i = 0; i < 6; i++)
                        self->dev->dev_addr[i] = bytes[i];
        }
 }
@@ -534,11 +534,11 @@ static void irlan_check_response_param(struct irlan_cb *self, char *param,
  *    Got results from remote LM-IAS
  *
  */
-void irlan_client_get_value_confirm(int result, __u16 obj_id, 
-                                   struct ias_value *value, void *priv) 
+void irlan_client_get_value_confirm(int result, __u16 obj_id,
+                                   struct ias_value *value, void *priv)
 {
        struct irlan_cb *self;
-       
+
        IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
 
        IRDA_ASSERT(priv != NULL, return;);
@@ -553,7 +553,7 @@ void irlan_client_get_value_confirm(int result, __u16 obj_id,
        /* Check if request succeeded */
        if (result != IAS_SUCCESS) {
                IRDA_DEBUG(2, "%s(), got NULL value!\n", __FUNCTION__ );
-               irlan_do_client_event(self, IRLAN_IAS_PROVIDER_NOT_AVAIL, 
+               irlan_do_client_event(self, IRLAN_IAS_PROVIDER_NOT_AVAIL,
                                      NULL);
                return;
        }
index ce943b69e9961441b3ef9d541061b585722f1a67..843ab6fbb394b17065f35e01b74162a653e69a69 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************************
- *                
+ *
  * Filename:      irlan_client_event.c
  * Version:       0.9
  * Description:   IrLAN client state machine
@@ -8,17 +8,17 @@
  * Created at:    Sun Aug 31 20:14:37 1997
  * Modified at:   Sun Dec 26 21:52:24 1999
  * Modified by:   Dag Brattli <dagb@cs.uit.no>
- * 
- *     Copyright (c) 1998-1999 Dag Brattli <dagb@cs.uit.no>, 
+ *
+ *     Copyright (c) 1998-1999 Dag Brattli <dagb@cs.uit.no>,
  *     All Rights Reserved.
- *     
- *     This program is free software; you can redistribute it and/or 
- *     modify it under the terms of the GNU General Public License as 
- *     published by the Free Software Foundation; either version 2 of 
+ *
+ *     This program is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU General Public License as
+ *     published by the Free Software Foundation; either version 2 of
  *     the License, or (at your option) any later version.
  *
  *     Neither Dag Brattli nor University of Tromsø admit liability nor
- *     provide warranty for any of this software. This material is 
+ *     provide warranty for any of this software. This material is
  *     provided "AS-IS" and at no charge.
  *
  ********************************************************************/
 #include <net/irda/irlan_client.h>
 #include <net/irda/irlan_event.h>
 
-static int irlan_client_state_idle (struct irlan_cb *self, IRLAN_EVENT event, 
+static int irlan_client_state_idle (struct irlan_cb *self, IRLAN_EVENT event,
                                    struct sk_buff *skb);
-static int irlan_client_state_query(struct irlan_cb *self, IRLAN_EVENT event, 
+static int irlan_client_state_query(struct irlan_cb *self, IRLAN_EVENT event,
                                    struct sk_buff *skb);
-static int irlan_client_state_conn (struct irlan_cb *self, IRLAN_EVENT event, 
+static int irlan_client_state_conn (struct irlan_cb *self, IRLAN_EVENT event,
                                    struct sk_buff *skb);
-static int irlan_client_state_info (struct irlan_cb *self, IRLAN_EVENT event, 
+static int irlan_client_state_info (struct irlan_cb *self, IRLAN_EVENT event,
                                    struct sk_buff *skb);
-static int irlan_client_state_media(struct irlan_cb *self, IRLAN_EVENT event, 
+static int irlan_client_state_media(struct irlan_cb *self, IRLAN_EVENT event,
                                    struct sk_buff *skb);
-static int irlan_client_state_open (struct irlan_cb *self, IRLAN_EVENT event, 
+static int irlan_client_state_open (struct irlan_cb *self, IRLAN_EVENT event,
                                    struct sk_buff *skb);
-static int irlan_client_state_wait (struct irlan_cb *self, IRLAN_EVENT event, 
+static int irlan_client_state_wait (struct irlan_cb *self, IRLAN_EVENT event,
                                    struct sk_buff *skb);
-static int irlan_client_state_arb  (struct irlan_cb *self, IRLAN_EVENT event, 
+static int irlan_client_state_arb  (struct irlan_cb *self, IRLAN_EVENT event,
                                    struct sk_buff *skb);
-static int irlan_client_state_data (struct irlan_cb *self, IRLAN_EVENT event, 
+static int irlan_client_state_data (struct irlan_cb *self, IRLAN_EVENT event,
                                    struct sk_buff *skb);
-static int irlan_client_state_close(struct irlan_cb *self, IRLAN_EVENT event, 
+static int irlan_client_state_close(struct irlan_cb *self, IRLAN_EVENT event,
                                    struct sk_buff *skb);
-static int irlan_client_state_sync (struct irlan_cb *self, IRLAN_EVENT event, 
+static int irlan_client_state_sync (struct irlan_cb *self, IRLAN_EVENT event,
                                    struct sk_buff *skb);
 
 static int (*state[])(struct irlan_cb *, IRLAN_EVENT event, struct sk_buff *) =
-{ 
+{
        irlan_client_state_idle,
        irlan_client_state_query,
        irlan_client_state_conn,
@@ -74,8 +74,8 @@ static int (*state[])(struct irlan_cb *, IRLAN_EVENT event, struct sk_buff *) =
        irlan_client_state_sync
 };
 
-void irlan_do_client_event(struct irlan_cb *self, IRLAN_EVENT event, 
-                          struct sk_buff *skb) 
+void irlan_do_client_event(struct irlan_cb *self, IRLAN_EVENT event,
+                          struct sk_buff *skb)
 {
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
@@ -89,14 +89,14 @@ void irlan_do_client_event(struct irlan_cb *self, IRLAN_EVENT event,
  *    IDLE, We are waiting for an indication that there is a provider
  *    available.
  */
-static int irlan_client_state_idle(struct irlan_cb *self, IRLAN_EVENT event, 
-                                  struct sk_buff *skb) 
+static int irlan_client_state_idle(struct irlan_cb *self, IRLAN_EVENT event,
+                                  struct sk_buff *skb)
 {
        IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
 
        IRDA_ASSERT(self != NULL, return -1;);
        IRDA_ASSERT(self->magic == IRLAN_MAGIC, return -1;);
-       
+
        switch (event) {
        case IRLAN_DISCOVERY_INDICATION:
                if (self->client.iriap) {
@@ -104,7 +104,7 @@ static int irlan_client_state_idle(struct irlan_cb *self, IRLAN_EVENT event,
                                     __FUNCTION__);
                        return -EBUSY;
                }
-               
+
                self->client.iriap = iriap_open(LSAP_ANY, IAS_CLIENT, self,
                                                irlan_client_get_value_confirm);
                /* Get some values from peer IAS */
@@ -120,7 +120,7 @@ static int irlan_client_state_idle(struct irlan_cb *self, IRLAN_EVENT event,
                IRDA_DEBUG(4, "%s(), Unknown event %d\n", __FUNCTION__ , event);
                break;
        }
-       if (skb) 
+       if (skb)
                dev_kfree_skb(skb);
 
        return 0;
@@ -133,23 +133,23 @@ static int irlan_client_state_idle(struct irlan_cb *self, IRLAN_EVENT event,
  *    to provider, just waiting for the confirm.
  *
  */
-static int irlan_client_state_query(struct irlan_cb *self, IRLAN_EVENT event, 
-                                   struct sk_buff *skb) 
+static int irlan_client_state_query(struct irlan_cb *self, IRLAN_EVENT event,
+                                   struct sk_buff *skb)
 {
        IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
 
        IRDA_ASSERT(self != NULL, return -1;);
        IRDA_ASSERT(self->magic == IRLAN_MAGIC, return -1;);
-       
+
        switch(event) {
        case IRLAN_IAS_PROVIDER_AVAIL:
                IRDA_ASSERT(self->dtsap_sel_ctrl != 0, return -1;);
 
                self->client.open_retries = 0;
-               
-               irttp_connect_request(self->client.tsap_ctrl, 
-                                     self->dtsap_sel_ctrl, 
-                                     self->saddr, self->daddr, NULL, 
+
+               irttp_connect_request(self->client.tsap_ctrl,
+                                     self->dtsap_sel_ctrl,
+                                     self->saddr, self->daddr, NULL,
                                      IRLAN_MTU, NULL);
                irlan_next_client_state(self, IRLAN_CONN);
                break;
@@ -158,7 +158,7 @@ static int irlan_client_state_query(struct irlan_cb *self, IRLAN_EVENT event,
                irlan_next_client_state(self, IRLAN_IDLE);
 
                /* Give the client a kick! */
-               if ((self->provider.access_type == ACCESS_PEER) && 
+               if ((self->provider.access_type == ACCESS_PEER) &&
                    (self->provider.state != IRLAN_IDLE))
                        irlan_client_wakeup(self, self->saddr, self->daddr);
                break;
@@ -175,7 +175,7 @@ static int irlan_client_state_query(struct irlan_cb *self, IRLAN_EVENT event,
        }
        if (skb)
                dev_kfree_skb(skb);
-       
+
        return 0;
 }
 
@@ -186,13 +186,13 @@ static int irlan_client_state_query(struct irlan_cb *self, IRLAN_EVENT event,
  *    commands yet.
  *
  */
-static int irlan_client_state_conn(struct irlan_cb *self, IRLAN_EVENT event, 
-                                  struct sk_buff *skb) 
+static int irlan_client_state_conn(struct irlan_cb *self, IRLAN_EVENT event,
+                                  struct sk_buff *skb)
 {
        IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
-       
+
        IRDA_ASSERT(self != NULL, return -1;);
-       
+
        switch (event) {
        case IRLAN_CONNECT_COMPLETE:
                /* Send getinfo cmd */
@@ -212,7 +212,7 @@ static int irlan_client_state_conn(struct irlan_cb *self, IRLAN_EVENT event,
        }
        if (skb)
                dev_kfree_skb(skb);
-       
+
        return 0;
 }
 
@@ -221,24 +221,24 @@ static int irlan_client_state_conn(struct irlan_cb *self, IRLAN_EVENT event,
  *
  *    INFO, We have issued a GetInfo command and is awaiting a reply.
  */
-static int irlan_client_state_info(struct irlan_cb *self, IRLAN_EVENT event, 
-                                  struct sk_buff *skb) 
+static int irlan_client_state_info(struct irlan_cb *self, IRLAN_EVENT event,
+                                  struct sk_buff *skb)
 {
        IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
 
        IRDA_ASSERT(self != NULL, return -1;);
-       
+
        switch (event) {
        case IRLAN_DATA_INDICATION:
                IRDA_ASSERT(skb != NULL, return -1;);
-       
+
                irlan_client_parse_response(self, skb);
-               
+
                irlan_next_client_state(self, IRLAN_MEDIA);
-               
+
                irlan_get_media_char(self);
                break;
-               
+
        case IRLAN_LMP_DISCONNECT:
        case IRLAN_LAP_DISCONNECT:
                irlan_next_client_state(self, IRLAN_IDLE);
@@ -252,7 +252,7 @@ static int irlan_client_state_info(struct irlan_cb *self, IRLAN_EVENT event,
        }
        if (skb)
                dev_kfree_skb(skb);
-       
+
        return 0;
 }
 
@@ -263,11 +263,11 @@ static int irlan_client_state_info(struct irlan_cb *self, IRLAN_EVENT event,
  *    reply.
  *
  */
-static int irlan_client_state_media(struct irlan_cb *self, IRLAN_EVENT event, 
-                                   struct sk_buff *skb) 
+static int irlan_client_state_media(struct irlan_cb *self, IRLAN_EVENT event,
+                                   struct sk_buff *skb)
 {
        IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
-       
+
        IRDA_ASSERT(self != NULL, return -1;);
 
        switch(event) {
@@ -289,7 +289,7 @@ static int irlan_client_state_media(struct irlan_cb *self, IRLAN_EVENT event,
        }
        if (skb)
                dev_kfree_skb(skb);
-       
+
        return 0;
 }
 
@@ -300,47 +300,47 @@ static int irlan_client_state_media(struct irlan_cb *self, IRLAN_EVENT event,
  *    reply
  *
  */
-static int irlan_client_state_open(struct irlan_cb *self, IRLAN_EVENT event, 
-                                  struct sk_buff *skb) 
+static int irlan_client_state_open(struct irlan_cb *self, IRLAN_EVENT event,
+                                  struct sk_buff *skb)
 {
        struct qos_info qos;
 
        IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
-       
+
        IRDA_ASSERT(self != NULL, return -1;);
 
        switch(event) {
        case IRLAN_DATA_INDICATION:
                irlan_client_parse_response(self, skb);
-               
+
                /*
-                *  Check if we have got the remote TSAP for data 
+                *  Check if we have got the remote TSAP for data
                 *  communications
                 */
-               IRDA_ASSERT(self->dtsap_sel_data != 0, return -1;);
+               IRDA_ASSERT(self->dtsap_sel_data != 0, return -1;);
 
                /* Check which access type we are dealing with */
                switch (self->client.access_type) {
                case ACCESS_PEER:
                    if (self->provider.state == IRLAN_OPEN) {
-                           
+
                            irlan_next_client_state(self, IRLAN_ARB);
-                           irlan_do_client_event(self, IRLAN_CHECK_CON_ARB, 
+                           irlan_do_client_event(self, IRLAN_CHECK_CON_ARB,
                                                  NULL);
                    } else {
-                       
+
                            irlan_next_client_state(self, IRLAN_WAIT);
                    }
                    break;
                case ACCESS_DIRECT:
                case ACCESS_HOSTED:
                        qos.link_disc_time.bits = 0x01; /* 3 secs */
-                       
-                       irttp_connect_request(self->tsap_data, 
-                                             self->dtsap_sel_data, 
-                                             self->saddr, self->daddr, &qos, 
+
+                       irttp_connect_request(self->tsap_data,
+                                             self->dtsap_sel_data,
+                                             self->saddr, self->daddr, &qos,
                                              IRLAN_MTU, NULL);
-                       
+
                        irlan_next_client_state(self, IRLAN_DATA);
                        break;
                default:
@@ -359,7 +359,7 @@ static int irlan_client_state_open(struct irlan_cb *self, IRLAN_EVENT event,
                IRDA_DEBUG(2, "%s(), Unknown event %d\n", __FUNCTION__ , event);
                break;
        }
-       
+
        if (skb)
                dev_kfree_skb(skb);
 
@@ -373,13 +373,13 @@ static int irlan_client_state_open(struct irlan_cb *self, IRLAN_EVENT event,
  *    provider OPEN state.
  *
  */
-static int irlan_client_state_wait(struct irlan_cb *self, IRLAN_EVENT event, 
-                                  struct sk_buff *skb) 
+static int irlan_client_state_wait(struct irlan_cb *self, IRLAN_EVENT event,
+                                  struct sk_buff *skb)
 {
        IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
-       
+
        IRDA_ASSERT(self != NULL, return -1;);
-       
+
        switch(event) {
        case IRLAN_PROVIDER_SIGNAL:
                irlan_next_client_state(self, IRLAN_ARB);
@@ -398,36 +398,36 @@ static int irlan_client_state_wait(struct irlan_cb *self, IRLAN_EVENT event,
        }
        if (skb)
                dev_kfree_skb(skb);
-       
+
        return 0;
 }
 
-static int irlan_client_state_arb(struct irlan_cb *self, IRLAN_EVENT event, 
-                                 struct sk_buff *skb) 
+static int irlan_client_state_arb(struct irlan_cb *self, IRLAN_EVENT event,
+                                 struct sk_buff *skb)
 {
        struct qos_info qos;
 
        IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
 
        IRDA_ASSERT(self != NULL, return -1;);
-       
+
        switch(event) {
        case IRLAN_CHECK_CON_ARB:
                if (self->client.recv_arb_val == self->provider.send_arb_val) {
                        irlan_next_client_state(self, IRLAN_CLOSE);
                        irlan_close_data_channel(self);
-               } else if (self->client.recv_arb_val < 
-                          self->provider.send_arb_val) 
+               } else if (self->client.recv_arb_val <
+                          self->provider.send_arb_val)
                {
                        qos.link_disc_time.bits = 0x01; /* 3 secs */
 
                        irlan_next_client_state(self, IRLAN_DATA);
-                       irttp_connect_request(self->tsap_data, 
-                                             self->dtsap_sel_data, 
-                                             self->saddr, self->daddr, &qos, 
+                       irttp_connect_request(self->tsap_data,
+                                             self->dtsap_sel_data,
+                                             self->saddr, self->daddr, &qos,
                                              IRLAN_MTU, NULL);
                } else if (self->client.recv_arb_val >
-                          self->provider.send_arb_val) 
+                          self->provider.send_arb_val)
                {
                        IRDA_DEBUG(2, "%s(), lost the battle :-(\n", __FUNCTION__ );
                }
@@ -448,7 +448,7 @@ static int irlan_client_state_arb(struct irlan_cb *self, IRLAN_EVENT event,
        }
        if (skb)
                dev_kfree_skb(skb);
-       
+
        return 0;
 }
 
@@ -459,8 +459,8 @@ static int irlan_client_state_arb(struct irlan_cb *self, IRLAN_EVENT event,
  *    the local and remote machines.
  *
  */
-static int irlan_client_state_data(struct irlan_cb *self, IRLAN_EVENT event, 
-                                  struct sk_buff *skb) 
+static int irlan_client_state_data(struct irlan_cb *self, IRLAN_EVENT event,
+                                  struct sk_buff *skb)
 {
        IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
 
@@ -470,7 +470,7 @@ static int irlan_client_state_data(struct irlan_cb *self, IRLAN_EVENT event,
        switch(event) {
        case IRLAN_DATA_INDICATION:
                irlan_client_parse_response(self, skb);
-               break;          
+               break;
        case IRLAN_LMP_DISCONNECT: /* FALLTHROUGH */
        case IRLAN_LAP_DISCONNECT:
                irlan_next_client_state(self, IRLAN_IDLE);
@@ -481,18 +481,18 @@ static int irlan_client_state_data(struct irlan_cb *self, IRLAN_EVENT event,
        }
        if (skb)
                dev_kfree_skb(skb);
-       
+
        return 0;
 }
 
 /*
  * Function irlan_client_state_close (self, event, skb, info)
  *
- *    
+ *
  *
  */
-static int irlan_client_state_close(struct irlan_cb *self, IRLAN_EVENT event, 
-                                   struct sk_buff *skb) 
+static int irlan_client_state_close(struct irlan_cb *self, IRLAN_EVENT event,
+                                   struct sk_buff *skb)
 {
        IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
 
@@ -505,17 +505,17 @@ static int irlan_client_state_close(struct irlan_cb *self, IRLAN_EVENT event,
 /*
  * Function irlan_client_state_sync (self, event, skb, info)
  *
- *    
+ *
  *
  */
-static int irlan_client_state_sync(struct irlan_cb *self, IRLAN_EVENT event, 
-                                  struct sk_buff *skb) 
+static int irlan_client_state_sync(struct irlan_cb *self, IRLAN_EVENT event,
+                                  struct sk_buff *skb)
 {
        IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
-       
+
        if (skb)
                dev_kfree_skb(skb);
-       
+
        return 0;
 }
 
index 2bb04ac0932922dd8e5042787fdacea795b5ec13..9c3dc57ff7464383641f4b64ec9ec73c0eb46185 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************************
- *                
+ *
  * Filename:      irlan_common.c
  * Version:       0.9
  * Description:   IrDA LAN Access Protocol Implementation
@@ -8,17 +8,17 @@
  * Created at:    Sun Aug 31 20:14:37 1997
  * Modified at:   Sun Dec 26 21:53:10 1999
  * Modified by:   Dag Brattli <dagb@cs.uit.no>
- * 
- *     Copyright (c) 1997, 1999 Dag Brattli <dagb@cs.uit.no>, 
+ *
+ *     Copyright (c) 1997, 1999 Dag Brattli <dagb@cs.uit.no>,
  *     All Rights Reserved.
- *     
- *     This program is free software; you can redistribute it and/or 
- *     modify it under the terms of the GNU General Public License as 
- *     published by the Free Software Foundation; either version 2 of 
+ *
+ *     This program is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU General Public License as
+ *     published by the Free Software Foundation; either version 2 of
  *     the License, or (at your option) any later version.
  *
  *     Neither Dag Brattli nor University of Tromsø admit liability nor
- *     provide warranty for any of this software. This material is 
+ *     provide warranty for any of this software. This material is
  *     provided "AS-IS" and at no charge.
  *
  ********************************************************************/
 
 #include <net/irda/irlan_common.h>
 #include <net/irda/irlan_client.h>
-#include <net/irda/irlan_provider.h> 
+#include <net/irda/irlan_provider.h>
 #include <net/irda/irlan_eth.h>
 #include <net/irda/irlan_filter.h>
 
 
-/* 
+/*
  * Send gratuitous ARP when connected to a new AP or not. May be a clever
  * thing to do, but for some reason the machine crashes if you use DHCP. So
  * lets not use it by default.
@@ -106,8 +106,8 @@ extern struct proc_dir_entry *proc_irda;
 
 static struct irlan_cb *irlan_open(__u32 saddr, __u32 daddr);
 static void __irlan_close(struct irlan_cb *self);
-static int __irlan_insert_param(struct sk_buff *skb, char *param, int type, 
-                               __u8 value_byte, __u16 value_short, 
+static int __irlan_insert_param(struct sk_buff *skb, char *param, int type,
+                               __u8 value_byte, __u16 value_short,
                                __u8 *value_array, __u16 value_len);
 static void irlan_open_unicast_addr(struct irlan_cb *self);
 static void irlan_get_unicast_addr(struct irlan_cb *self);
@@ -144,12 +144,18 @@ static int __init irlan_init(void)
        /* Register with IrLMP as a client */
        ckey = irlmp_register_client(hints, &irlan_client_discovery_indication,
                                     NULL, NULL);
-       
+       if (!ckey)
+               goto err_ckey;
+
        /* Register with IrLMP as a service */
-       skey = irlmp_register_service(hints);
+       skey = irlmp_register_service(hints);
+       if (!skey)
+               goto err_skey;
 
        /* Start the master IrLAN instance (the only one for now) */
-       new = irlan_open(DEV_ADDR_ANY, DEV_ADDR_ANY);
+       new = irlan_open(DEV_ADDR_ANY, DEV_ADDR_ANY);
+       if (!new)
+               goto err_open;
 
        /* The master will only open its (listen) control TSAP */
        irlan_provider_open_ctrl_tsap(new);
@@ -158,9 +164,20 @@ static int __init irlan_init(void)
        irlmp_discovery_request(DISCOVERY_DEFAULT_SLOTS);
 
        return 0;
+
+err_open:
+       irlmp_unregister_service(skey);
+err_skey:
+       irlmp_unregister_client(ckey);
+err_ckey:
+#ifdef CONFIG_PROC_FS
+       remove_proc_entry("irlan", proc_irda);
+#endif /* CONFIG_PROC_FS */
+
+       return -ENOMEM;
 }
 
-static void __exit irlan_cleanup(void) 
+static void __exit irlan_cleanup(void)
 {
        struct irlan_cb *self, *next;
 
@@ -184,7 +201,7 @@ static void __exit irlan_cleanup(void)
 /*
  * Function irlan_open (void)
  *
- *    Open new instance of a client/provider, we should only register the 
+ *    Open new instance of a client/provider, we should only register the
  *    network device if this instance is ment for a particular client/provider
  */
 static struct irlan_cb *irlan_open(__u32 saddr, __u32 daddr)
@@ -212,9 +229,9 @@ static struct irlan_cb *irlan_open(__u32 saddr, __u32 daddr)
        /* Provider access can only be PEER, DIRECT, or HOSTED */
        self->provider.access_type = access;
        if (access == ACCESS_DIRECT) {
-               /*  
+               /*
                 * Since we are emulating an IrLAN sever we will have to
-                * give ourself an ethernet address!  
+                * give ourself an ethernet address!
                 */
                dev->dev_addr[0] = 0x40;
                dev->dev_addr[1] = 0x00;
@@ -228,15 +245,15 @@ static struct irlan_cb *irlan_open(__u32 saddr, __u32 daddr)
        self->disconnect_reason = LM_USER_REQUEST;
        init_timer(&self->watchdog_timer);
        init_timer(&self->client.kick_timer);
-       init_waitqueue_head(&self->open_wait);  
-       
+       init_waitqueue_head(&self->open_wait);
+
        skb_queue_head_init(&self->client.txq);
-       
+
        irlan_next_client_state(self, IRLAN_IDLE);
        irlan_next_provider_state(self, IRLAN_IDLE);
 
        if (register_netdev(dev)) {
-               IRDA_DEBUG(2, "%s(), register_netdev() failed!\n", 
+               IRDA_DEBUG(2, "%s(), register_netdev() failed!\n",
                           __FUNCTION__ );
                self = NULL;
                free_netdev(dev);
@@ -251,14 +268,14 @@ static struct irlan_cb *irlan_open(__u32 saddr, __u32 daddr)
 /*
  * Function __irlan_close (self)
  *
- *    This function closes and deallocates the IrLAN client instances. Be 
+ *    This function closes and deallocates the IrLAN client instances. Be
  *    aware that other functions which calls client_close() must
  *    remove self from irlans list first.
  */
 static void __irlan_close(struct irlan_cb *self)
 {
        IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
-       
+
        ASSERT_RTNL();
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
@@ -268,8 +285,8 @@ static void __irlan_close(struct irlan_cb *self)
 
        /* Close all open connections and remove TSAPs */
        irlan_close_tsaps(self);
-       
-       if (self->client.iriap) 
+
+       if (self->client.iriap)
                iriap_close(self->client.iriap);
 
        /* Remove frames queued on the control channel */
@@ -299,17 +316,17 @@ struct irlan_cb *irlan_get_any(void)
 static void irlan_connect_indication(void *instance, void *sap,
                                     struct qos_info *qos,
                                     __u32 max_sdu_size,
-                                    __u8 max_header_size, 
+                                    __u8 max_header_size,
                                     struct sk_buff *skb)
 {
        struct irlan_cb *self;
        struct tsap_cb *tsap;
 
        IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
-       
+
        self = (struct irlan_cb *) instance;
        tsap = (struct tsap_cb *) sap;
-       
+
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
        IRDA_ASSERT(tsap == self->tsap_data,return;);
@@ -332,9 +349,9 @@ static void irlan_connect_indication(void *instance, void *sap,
        irlan_do_client_event(self, IRLAN_DATA_CONNECT_INDICATION, NULL);
 
        if (self->provider.access_type == ACCESS_PEER) {
-               /* 
+               /*
                 * Data channel is open, so we are now allowed to
-                * configure the remote filter 
+                * configure the remote filter
                 */
                irlan_get_unicast_addr(self);
                irlan_open_unicast_addr(self);
@@ -344,10 +361,10 @@ static void irlan_connect_indication(void *instance, void *sap,
 }
 
 static void irlan_connect_confirm(void *instance, void *sap,
-                                 struct qos_info *qos, 
+                                 struct qos_info *qos,
                                  __u32 max_sdu_size,
-                                 __u8 max_header_size, 
-                                 struct sk_buff *skb) 
+                                 __u8 max_header_size,
+                                 struct sk_buff *skb)
 {
        struct irlan_cb *self;
 
@@ -364,16 +381,16 @@ static void irlan_connect_confirm(void *instance, void *sap,
        IRDA_DEBUG(0, "%s: We are now connected!\n", __FUNCTION__);
        del_timer(&self->watchdog_timer);
 
-       /* 
+       /*
         * Data channel is open, so we are now allowed to configure the remote
-        * filter 
+        * filter
         */
        irlan_get_unicast_addr(self);
        irlan_open_unicast_addr(self);
-       
+
        /* Open broadcast and multicast filter by default */
-       irlan_set_broadcast_filter(self, TRUE);
-       irlan_set_multicast_filter(self, TRUE);
+       irlan_set_broadcast_filter(self, TRUE);
+       irlan_set_multicast_filter(self, TRUE);
 
        /* Ready to transfer Ethernet frames */
        netif_start_queue(self->dev);
@@ -391,29 +408,29 @@ static void irlan_connect_confirm(void *instance, void *sap,
  *    the specified connection (handle)
  */
 static void irlan_disconnect_indication(void *instance,
-                                       void *sap, LM_REASON reason, 
-                                       struct sk_buff *userdata) 
+                                       void *sap, LM_REASON reason,
+                                       struct sk_buff *userdata)
 {
        struct irlan_cb *self;
        struct tsap_cb *tsap;
 
        IRDA_DEBUG(0, "%s(), reason=%d\n", __FUNCTION__ , reason);
-       
+
        self = (struct irlan_cb *) instance;
        tsap = (struct tsap_cb *) sap;
 
        IRDA_ASSERT(self != NULL, return;);
-       IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);       
+       IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
        IRDA_ASSERT(tsap != NULL, return;);
        IRDA_ASSERT(tsap->magic == TTP_TSAP_MAGIC, return;);
-       
+
        IRDA_ASSERT(tsap == self->tsap_data, return;);
 
        IRDA_DEBUG(2, "IrLAN, data channel disconnected by peer!\n");
 
        /* Save reason so we know if we should try to reconnect or not */
        self->disconnect_reason = reason;
-       
+
        switch (reason) {
        case LM_USER_REQUEST: /* User request */
                IRDA_DEBUG(2, "%s(), User requested\n", __FUNCTION__ );
@@ -434,7 +451,7 @@ static void irlan_disconnect_indication(void *instance,
                IRDA_ERROR("%s(), Unknown disconnect reason\n", __FUNCTION__);
                break;
        }
-       
+
        /* If you want to pass the skb to *both* state machines, you will
         * need to skb_clone() it, so that you don't free it twice.
         * As the state machines don't need it, git rid of it here...
@@ -444,7 +461,7 @@ static void irlan_disconnect_indication(void *instance,
 
        irlan_do_client_event(self, IRLAN_LMP_DISCONNECT, NULL);
        irlan_do_provider_event(self, IRLAN_LMP_DISCONNECT, NULL);
-       
+
        wake_up_interruptible(&self->open_wait);
 }
 
@@ -463,12 +480,12 @@ void irlan_open_data_tsap(struct irlan_cb *self)
                return;
 
        irda_notify_init(&notify);
-       
+
        notify.data_indication       = irlan_eth_receive;
        notify.udata_indication      = irlan_eth_receive;
        notify.connect_indication    = irlan_connect_indication;
        notify.connect_confirm       = irlan_connect_confirm;
-       notify.flow_indication       = irlan_eth_flow_indication;
+       notify.flow_indication       = irlan_eth_flow_indication;
        notify.disconnect_indication = irlan_disconnect_indication;
        notify.instance              = self;
        strlcpy(notify.name, "IrLAN data", sizeof(notify.name));
@@ -480,7 +497,7 @@ void irlan_open_data_tsap(struct irlan_cb *self)
        }
        self->tsap_data = tsap;
 
-       /* 
+       /*
         *  This is the data TSAP selector which we will pass to the client
         *  when the client ask for it.
         */
@@ -501,13 +518,13 @@ void irlan_close_tsaps(struct irlan_cb *self)
                self->tsap_data = NULL;
        }
        if (self->client.tsap_ctrl) {
-               irttp_disconnect_request(self->client.tsap_ctrl, NULL, 
+               irttp_disconnect_request(self->client.tsap_ctrl, NULL,
                                         P_NORMAL);
                irttp_close_tsap(self->client.tsap_ctrl);
                self->client.tsap_ctrl = NULL;
        }
        if (self->provider.tsap_ctrl) {
-               irttp_disconnect_request(self->provider.tsap_ctrl, NULL, 
+               irttp_disconnect_request(self->provider.tsap_ctrl, NULL,
                                         P_NORMAL);
                irttp_close_tsap(self->provider.tsap_ctrl);
                self->provider.tsap_ctrl = NULL;
@@ -528,8 +545,8 @@ void irlan_ias_register(struct irlan_cb *self, __u8 tsap_sel)
 
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
-       
-       /* 
+
+       /*
         * Check if object has already been registered by a previous provider.
         * If that is the case, we just change the value of the attribute
         */
@@ -543,9 +560,9 @@ void irlan_ias_register(struct irlan_cb *self, __u8 tsap_sel)
                irias_object_change_attribute("IrLAN", "IrDA:TinyTP:LsapSel",
                                              new_value);
        }
-       
-        /* Register PnP object only if not registered before */
-        if (!irias_find_object("PnP")) {
+
+       /* Register PnP object only if not registered before */
+       if (!irias_find_object("PnP")) {
                obj = irias_new_object("PnP", IAS_PNP_ID);
 #if 0
                irias_add_string_attrib(obj, "Name", sysctl_devname,
@@ -589,10 +606,10 @@ int irlan_run_ctrl_tx_queue(struct irlan_cb *self)
                self->client.tx_busy = FALSE;
                return 0;
        }
-       
+
        /* Check that it's really possible to send commands */
-       if ((self->client.tsap_ctrl == NULL) || 
-           (self->client.state == IRLAN_IDLE)) 
+       if ((self->client.tsap_ctrl == NULL) ||
+           (self->client.state == IRLAN_IDLE))
        {
                self->client.tx_busy = FALSE;
                dev_kfree_skb(skb);
@@ -632,7 +649,7 @@ void irlan_get_provider_info(struct irlan_cb *self)
        __u8 *frame;
 
        IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
-       
+
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
 
@@ -644,12 +661,12 @@ void irlan_get_provider_info(struct irlan_cb *self)
        /* Reserve space for TTP, LMP, and LAP header */
        skb_reserve(skb, self->client.max_header_size);
        skb_put(skb, 2);
-       
+
        frame = skb->data;
-       
-       frame[0] = CMD_GET_PROVIDER_INFO;
+
+       frame[0] = CMD_GET_PROVIDER_INFO;
        frame[1] = 0x00;                 /* Zero parameters */
-       
+
        irlan_ctrl_data_request(self, skb);
 }
 
@@ -659,16 +676,16 @@ void irlan_get_provider_info(struct irlan_cb *self)
  *    Send an Open Data Command to provider
  *
  */
-void irlan_open_data_channel(struct irlan_cb *self) 
+void irlan_open_data_channel(struct irlan_cb *self)
 {
        struct sk_buff *skb;
        __u8 *frame;
-       
+
        IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
 
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
-       
+
        skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER +
                        IRLAN_STRING_PARAMETER_LEN("MEDIA", "802.3") +
                        IRLAN_STRING_PARAMETER_LEN("ACCESS_TYPE", "DIRECT"),
@@ -678,11 +695,11 @@ void irlan_open_data_channel(struct irlan_cb *self)
 
        skb_reserve(skb, self->client.max_header_size);
        skb_put(skb, 2);
-       
+
        frame = skb->data;
-       
+
        /* Build frame */
-       frame[0] = CMD_OPEN_DATA_CHANNEL;
+       frame[0] = CMD_OPEN_DATA_CHANNEL;
        frame[1] = 0x02; /* Two parameters */
 
        irlan_insert_string_param(skb, "MEDIA", "802.3");
@@ -694,11 +711,11 @@ void irlan_open_data_channel(struct irlan_cb *self)
        irlan_ctrl_data_request(self, skb);
 }
 
-void irlan_close_data_channel(struct irlan_cb *self) 
+void irlan_close_data_channel(struct irlan_cb *self)
 {
        struct sk_buff *skb;
        __u8 *frame;
-       
+
        IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
 
        IRDA_ASSERT(self != NULL, return;);
@@ -716,11 +733,11 @@ void irlan_close_data_channel(struct irlan_cb *self)
 
        skb_reserve(skb, self->client.max_header_size);
        skb_put(skb, 2);
-       
+
        frame = skb->data;
-       
+
        /* Build frame */
-       frame[0] = CMD_CLOSE_DATA_CHAN;
+       frame[0] = CMD_CLOSE_DATA_CHAN;
        frame[1] = 0x01; /* One parameter */
 
        irlan_insert_byte_param(skb, "DATA_CHAN", self->dtsap_sel_data);
@@ -731,7 +748,7 @@ void irlan_close_data_channel(struct irlan_cb *self)
 /*
  * Function irlan_open_unicast_addr (self)
  *
- *    Make IrLAN provider accept ethernet frames addressed to the unicast 
+ *    Make IrLAN provider accept ethernet frames addressed to the unicast
  *    address.
  *
  */
@@ -739,12 +756,12 @@ static void irlan_open_unicast_addr(struct irlan_cb *self)
 {
        struct sk_buff *skb;
        __u8 *frame;
-       
+
        IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
 
        IRDA_ASSERT(self != NULL, return;);
-       IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);       
-       
+       IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
+
        skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER +
                        IRLAN_BYTE_PARAMETER_LEN("DATA_CHAN") +
                        IRLAN_STRING_PARAMETER_LEN("FILTER_TYPE", "DIRECTED") +
@@ -756,15 +773,15 @@ static void irlan_open_unicast_addr(struct irlan_cb *self)
        /* Reserve space for TTP, LMP, and LAP header */
        skb_reserve(skb, self->max_header_size);
        skb_put(skb, 2);
-       
+
        frame = skb->data;
-       
-       frame[0] = CMD_FILTER_OPERATION;
+
+       frame[0] = CMD_FILTER_OPERATION;
        frame[1] = 0x03;                 /* Three parameters */
-       irlan_insert_byte_param(skb, "DATA_CHAN" , self->dtsap_sel_data);
-       irlan_insert_string_param(skb, "FILTER_TYPE", "DIRECTED");
-       irlan_insert_string_param(skb, "FILTER_MODE", "FILTER"); 
-       
+       irlan_insert_byte_param(skb, "DATA_CHAN" , self->dtsap_sel_data);
+       irlan_insert_string_param(skb, "FILTER_TYPE", "DIRECTED");
+       irlan_insert_string_param(skb, "FILTER_MODE", "FILTER");
+
        irlan_ctrl_data_request(self, skb);
 }
 
@@ -777,17 +794,17 @@ static void irlan_open_unicast_addr(struct irlan_cb *self)
  *    one but then _we_ have to initiate all communication with other
  *    hosts, since ARP request for this host will not be answered.
  */
-void irlan_set_broadcast_filter(struct irlan_cb *self, int status) 
+void irlan_set_broadcast_filter(struct irlan_cb *self, int status)
 {
        struct sk_buff *skb;
        __u8 *frame;
-       
+
        IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
 
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
-       
-       skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER +
+
+       skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER +
                        IRLAN_BYTE_PARAMETER_LEN("DATA_CHAN") +
                        IRLAN_STRING_PARAMETER_LEN("FILTER_TYPE", "BROADCAST") +
                        /* We may waste one byte here...*/
@@ -799,17 +816,17 @@ void irlan_set_broadcast_filter(struct irlan_cb *self, int status)
        /* Reserve space for TTP, LMP, and LAP header */
        skb_reserve(skb, self->client.max_header_size);
        skb_put(skb, 2);
-       
+
        frame = skb->data;
-       
-       frame[0] = CMD_FILTER_OPERATION;
+
+       frame[0] = CMD_FILTER_OPERATION;
        frame[1] = 0x03;                 /* Three parameters */
-       irlan_insert_byte_param(skb, "DATA_CHAN", self->dtsap_sel_data);
-       irlan_insert_string_param(skb, "FILTER_TYPE", "BROADCAST");
+       irlan_insert_byte_param(skb, "DATA_CHAN", self->dtsap_sel_data);
+       irlan_insert_string_param(skb, "FILTER_TYPE", "BROADCAST");
        if (status)
-               irlan_insert_string_param(skb, "FILTER_MODE", "FILTER"); 
+               irlan_insert_string_param(skb, "FILTER_MODE", "FILTER");
        else
-               irlan_insert_string_param(skb, "FILTER_MODE", "NONE"); 
+               irlan_insert_string_param(skb, "FILTER_MODE", "NONE");
 
        irlan_ctrl_data_request(self, skb);
 }
@@ -818,14 +835,14 @@ void irlan_set_broadcast_filter(struct irlan_cb *self, int status)
  * Function irlan_set_multicast_filter (self, status)
  *
  *    Make IrLAN provider accept ethernet frames addressed to the multicast
- *    address. 
+ *    address.
  *
  */
-void irlan_set_multicast_filter(struct irlan_cb *self, int status) 
+void irlan_set_multicast_filter(struct irlan_cb *self, int status)
 {
        struct sk_buff *skb;
        __u8 *frame;
-       
+
        IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
 
        IRDA_ASSERT(self != NULL, return;);
@@ -839,21 +856,21 @@ void irlan_set_multicast_filter(struct irlan_cb *self, int status)
                        GFP_ATOMIC);
        if (!skb)
                return;
-       
+
        /* Reserve space for TTP, LMP, and LAP header */
        skb_reserve(skb, self->client.max_header_size);
        skb_put(skb, 2);
-       
+
        frame = skb->data;
-       
-       frame[0] = CMD_FILTER_OPERATION;
+
+       frame[0] = CMD_FILTER_OPERATION;
        frame[1] = 0x03;                 /* Three parameters */
-       irlan_insert_byte_param(skb, "DATA_CHAN", self->dtsap_sel_data);
-       irlan_insert_string_param(skb, "FILTER_TYPE", "MULTICAST");
+       irlan_insert_byte_param(skb, "DATA_CHAN", self->dtsap_sel_data);
+       irlan_insert_string_param(skb, "FILTER_TYPE", "MULTICAST");
        if (status)
-               irlan_insert_string_param(skb, "FILTER_MODE", "ALL"); 
+               irlan_insert_string_param(skb, "FILTER_MODE", "ALL");
        else
-               irlan_insert_string_param(skb, "FILTER_MODE", "NONE"); 
+               irlan_insert_string_param(skb, "FILTER_MODE", "NONE");
 
        irlan_ctrl_data_request(self, skb);
 }
@@ -870,12 +887,12 @@ static void irlan_get_unicast_addr(struct irlan_cb *self)
 {
        struct sk_buff *skb;
        __u8 *frame;
-               
+
        IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
 
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
-       
+
        skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER +
                        IRLAN_BYTE_PARAMETER_LEN("DATA_CHAN") +
                        IRLAN_STRING_PARAMETER_LEN("FILTER_TYPE", "DIRECTED") +
@@ -888,34 +905,34 @@ static void irlan_get_unicast_addr(struct irlan_cb *self)
        /* Reserve space for TTP, LMP, and LAP header */
        skb_reserve(skb, self->client.max_header_size);
        skb_put(skb, 2);
-       
+
        frame = skb->data;
-       
-       frame[0] = CMD_FILTER_OPERATION;
+
+       frame[0] = CMD_FILTER_OPERATION;
        frame[1] = 0x03;                 /* Three parameters */
-       irlan_insert_byte_param(skb, "DATA_CHAN", self->dtsap_sel_data);
-       irlan_insert_string_param(skb, "FILTER_TYPE", "DIRECTED");
-       irlan_insert_string_param(skb, "FILTER_OPERATION", "DYNAMIC"); 
-       
+       irlan_insert_byte_param(skb, "DATA_CHAN", self->dtsap_sel_data);
+       irlan_insert_string_param(skb, "FILTER_TYPE", "DIRECTED");
+       irlan_insert_string_param(skb, "FILTER_OPERATION", "DYNAMIC");
+
        irlan_ctrl_data_request(self, skb);
 }
 
 /*
  * Function irlan_get_media_char (self)
  *
- *    
+ *
  *
  */
-void irlan_get_media_char(struct irlan_cb *self) 
+void irlan_get_media_char(struct irlan_cb *self)
 {
        struct sk_buff *skb;
        __u8 *frame;
-       
+
        IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
 
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
-       
+
        skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER +
                        IRLAN_STRING_PARAMETER_LEN("MEDIA", "802.3"),
                        GFP_ATOMIC);
@@ -926,13 +943,13 @@ void irlan_get_media_char(struct irlan_cb *self)
        /* Reserve space for TTP, LMP, and LAP header */
        skb_reserve(skb, self->client.max_header_size);
        skb_put(skb, 2);
-       
+
        frame = skb->data;
-       
+
        /* Build frame */
-       frame[0] = CMD_GET_MEDIA_CHAR;
+       frame[0] = CMD_GET_MEDIA_CHAR;
        frame[1] = 0x01; /* One parameter */
-       
+
        irlan_insert_string_param(skb, "MEDIA", "802.3");
        irlan_ctrl_data_request(self, skb);
 }
@@ -963,7 +980,7 @@ int irlan_insert_string_param(struct sk_buff *skb, char *param, char *string)
 {
        int string_len = strlen(string);
 
-       return __irlan_insert_param(skb, param, IRLAN_ARRAY, 0, 0, string, 
+       return __irlan_insert_param(skb, param, IRLAN_ARRAY, 0, 0, string,
                                    string_len);
 }
 
@@ -976,7 +993,7 @@ int irlan_insert_string_param(struct sk_buff *skb, char *param, char *string)
 int irlan_insert_array_param(struct sk_buff *skb, char *name, __u8 *array,
                             __u16 array_len)
 {
-       return __irlan_insert_param(skb, name, IRLAN_ARRAY, 0, 0, array, 
+       return __irlan_insert_param(skb, name, IRLAN_ARRAY, 0, 0, array,
                                    array_len);
 }
 
@@ -989,19 +1006,19 @@ int irlan_insert_array_param(struct sk_buff *skb, char *name, __u8 *array,
  *    | Name Length[1] | Param Name[1..255] | Val Length[2] | Value[0..1016]|
  *    -----------------------------------------------------------------------
  */
-static int __irlan_insert_param(struct sk_buff *skb, char *param, int type, 
-                               __u8 value_byte, __u16 value_short, 
+static int __irlan_insert_param(struct sk_buff *skb, char *param, int type,
+                               __u8 value_byte, __u16 value_short,
                                __u8 *value_array, __u16 value_len)
 {
        __u8 *frame;
        __u8 param_len;
        __le16 tmp_le; /* Temporary value in little endian format */
        int n=0;
-       
+
        if (skb == NULL) {
                IRDA_DEBUG(2, "%s(), Got NULL skb\n", __FUNCTION__ );
                return 0;
-       }       
+       }
 
        param_len = strlen(param);
        switch (type) {
@@ -1020,7 +1037,7 @@ static int __irlan_insert_param(struct sk_buff *skb, char *param, int type,
                return 0;
                break;
        }
-       
+
        /* Insert at end of sk-buffer */
        frame = skb->tail;
 
@@ -1028,15 +1045,15 @@ static int __irlan_insert_param(struct sk_buff *skb, char *param, int type,
        if (skb_tailroom(skb) < (param_len+value_len+3)) {
                IRDA_DEBUG(2, "%s(), No more space at end of skb\n", __FUNCTION__ );
                return 0;
-       }       
+       }
        skb_put(skb, param_len+value_len+3);
-       
+
        /* Insert parameter length */
        frame[n++] = param_len;
-       
+
        /* Insert parameter */
        memcpy(frame+n, param, param_len); n += param_len;
-       
+
        /* Insert value length (2 byte little endian format, LSB first) */
        tmp_le = cpu_to_le16(value_len);
        memcpy(frame+n, &tmp_le, 2); n += 2; /* To avoid alignment problems */
@@ -1065,36 +1082,36 @@ static int __irlan_insert_param(struct sk_buff *skb, char *param, int type,
  * Function irlan_extract_param (buf, name, value, len)
  *
  *    Extracts a single parameter name/value pair from buffer and updates
- *    the buffer pointer to point to the next name/value pair. 
+ *    the buffer pointer to point to the next name/value pair.
  */
 int irlan_extract_param(__u8 *buf, char *name, char *value, __u16 *len)
 {
        __u8 name_len;
        __u16 val_len;
        int n=0;
-       
+
        IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
-       
+
        /* get length of parameter name (1 byte) */
        name_len = buf[n++];
-       
+
        if (name_len > 254) {
                IRDA_DEBUG(2, "%s(), name_len > 254\n", __FUNCTION__ );
                return -RSP_INVALID_COMMAND_FORMAT;
        }
-       
+
        /* get parameter name */
        memcpy(name, buf+n, name_len);
        name[name_len] = '\0';
        n+=name_len;
-       
-       /*  
-        *  Get length of parameter value (2 bytes in little endian 
-        *  format) 
+
+       /*
+        *  Get length of parameter value (2 bytes in little endian
+        *  format)
         */
        memcpy(&val_len, buf+n, 2); /* To avoid alignment problems */
        le16_to_cpus(&val_len); n+=2;
-       
+
        if (val_len > 1016) {
                IRDA_DEBUG(2, "%s(), parameter length to long\n", __FUNCTION__ );
                return -RSP_INVALID_COMMAND_FORMAT;
@@ -1105,9 +1122,9 @@ int irlan_extract_param(__u8 *buf, char *name, char *value, __u16 *len)
        memcpy(value, buf+n, val_len);
        value[val_len] = '\0';
        n+=val_len;
-       
-       IRDA_DEBUG(4, "Parameter: %s ", name); 
-       IRDA_DEBUG(4, "Value: %s\n", value); 
+
+       IRDA_DEBUG(4, "Parameter: %s ", name);
+       IRDA_DEBUG(4, "Value: %s\n", value);
 
        return n;
 }
@@ -1116,7 +1133,7 @@ int irlan_extract_param(__u8 *buf, char *name, char *value, __u16 *len)
 
 /*
  * Start of reading /proc entries.
- * Return entry at pos, 
+ * Return entry at pos,
  *     or start_token to indicate print header line
  *     or NULL if end of file
  */
@@ -1130,7 +1147,7 @@ static void *irlan_seq_start(struct seq_file *seq, loff_t *pos)
                return SEQ_START_TOKEN;
 
        list_for_each_entry(self, &irlans, dev_list) {
-               if (*pos == i) 
+               if (*pos == i)
                        return self;
                ++i;
        }
@@ -1143,12 +1160,12 @@ static void *irlan_seq_next(struct seq_file *seq, void *v, loff_t *pos)
        struct list_head *nxt;
 
        ++*pos;
-       if (v == SEQ_START_TOKEN) 
+       if (v == SEQ_START_TOKEN)
                nxt = irlans.next;
        else
                nxt = ((struct irlan_cb *)v)->dev_list.next;
 
-       return (nxt == &irlans) ? NULL 
+       return (nxt == &irlans) ? NULL
                : list_entry(nxt, struct irlan_cb, dev_list);
 }
 
@@ -1168,7 +1185,7 @@ static int irlan_seq_show(struct seq_file *seq, void *v)
                seq_puts(seq, "IrLAN instances:\n");
        else {
                struct irlan_cb *self = v;
-               
+
                IRDA_ASSERT(self != NULL, return -1;);
                IRDA_ASSERT(self->magic == IRLAN_MAGIC, return -1;);
 
@@ -1184,17 +1201,17 @@ static int irlan_seq_show(struct seq_file *seq, void *v)
                               self->daddr);
                seq_printf(seq,"version: %d.%d,\n",
                               self->version[1], self->version[0]);
-               seq_printf(seq,"access type: %s\n", 
+               seq_printf(seq,"access type: %s\n",
                               irlan_access[self->client.access_type]);
-               seq_printf(seq,"media: %s\n", 
+               seq_printf(seq,"media: %s\n",
                               irlan_media[self->media]);
-               
+
                seq_printf(seq,"local filter:\n");
                seq_printf(seq,"remote filter: ");
                irlan_print_filter(seq, self->client.filter_type);
-               seq_printf(seq,"tx busy: %s\n", 
+               seq_printf(seq,"tx busy: %s\n",
                               netif_queue_stopped(self->dev) ? "TRUE" : "FALSE");
-                       
+
                seq_putc(seq,'\n');
        }
        return 0;
@@ -1214,7 +1231,7 @@ static int irlan_seq_open(struct inode *inode, struct file *file)
 #endif
 
 MODULE_AUTHOR("Dag Brattli <dagb@cs.uit.no>");
-MODULE_DESCRIPTION("The Linux IrDA LAN protocol"); 
+MODULE_DESCRIPTION("The Linux IrDA LAN protocol");
 MODULE_LICENSE("GPL");
 
 module_param(eth, bool, 0);
index b0ccc455b74740a5d5f3d5db27ca9f18da5c50fd..672ab3f69033b0848562365c2cad7a68cf7745e5 100644 (file)
@@ -1,8 +1,8 @@
 /*********************************************************************
- *                
+ *
  * Filename:      irlan_eth.c
- * Version:       
- * Description:   
+ * Version:
+ * Description:
  * Status:        Experimental.
  * Author:        Dag Brattli <dagb@cs.uit.no>
  * Created at:    Thu Oct 15 08:37:58 1998
  * Sources:       skeleton.c by Donald Becker <becker@CESDIS.gsfc.nasa.gov>
  *                slip.c by Laurence Culhane,   <loz@holmes.demon.co.uk>
  *                          Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
- * 
+ *
  *     Copyright (c) 1998-2000 Dag Brattli, All Rights Reserved.
- *      
- *     This program is free software; you can redistribute it and/or 
- *     modify it under the terms of the GNU General Public License as 
- *     published by the Free Software Foundation; either version 2 of 
+ *
+ *     This program is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU General Public License as
+ *     published by the Free Software Foundation; either version 2 of
  *     the License, or (at your option) any later version.
- *  
+ *
  *     Neither Dag Brattli nor University of Tromsø admit liability nor
- *     provide warranty for any of this software. This material is 
+ *     provide warranty for any of this software. This material is
  *     provided "AS-IS" and at no charge.
- *     
+ *
  ********************************************************************/
 
 #include <linux/netdevice.h>
@@ -55,7 +55,7 @@ static void irlan_eth_setup(struct net_device *dev)
 {
        dev->open               = irlan_eth_open;
        dev->stop               = irlan_eth_close;
-       dev->hard_start_xmit    = irlan_eth_xmit; 
+       dev->hard_start_xmit    = irlan_eth_xmit;
        dev->get_stats          = irlan_eth_get_stats;
        dev->set_multicast_list = irlan_eth_set_multicast_list;
        dev->destructor         = free_netdev;
@@ -63,8 +63,8 @@ static void irlan_eth_setup(struct net_device *dev)
        SET_MODULE_OWNER(dev);
 
        ether_setup(dev);
-       
-       /* 
+
+       /*
         * Lets do all queueing in IrTTP instead of this device driver.
         * Queueing here as well can introduce some strange latency
         * problems, which we will avoid by setting the queue size to 0.
@@ -104,17 +104,17 @@ struct net_device *alloc_irlandev(const char *name)
 static int irlan_eth_open(struct net_device *dev)
 {
        struct irlan_cb *self = netdev_priv(dev);
-       
+
        IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
 
        /* Ready to play! */
-       netif_stop_queue(dev); /* Wait until data link is ready */
+       netif_stop_queue(dev); /* Wait until data link is ready */
 
        /* We are now open, so time to do some work */
        self->disconnect_reason = 0;
        irlan_client_wakeup(self, self->saddr, self->daddr);
 
-       /* Make sure we have a hardware address before we return, 
+       /* Make sure we have a hardware address before we return,
           so DHCP clients gets happy */
        return wait_event_interruptible(self->open_wait,
                                        !self->tsap_data->connected);
@@ -124,30 +124,30 @@ static int irlan_eth_open(struct net_device *dev)
  * Function irlan_eth_close (dev)
  *
  *    Stop the ether network device, his function will usually be called by
- *    ifconfig down. We should now disconnect the link, We start the 
+ *    ifconfig down. We should now disconnect the link, We start the
  *    close timer, so that the instance will be removed if we are unable
  *    to discover the remote device after the disconnect.
  */
 static int irlan_eth_close(struct net_device *dev)
 {
        struct irlan_cb *self = netdev_priv(dev);
-       
+
        IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
-       
+
        /* Stop device */
        netif_stop_queue(dev);
-       
+
        irlan_close_data_channel(self);
        irlan_close_tsaps(self);
 
        irlan_do_client_event(self, IRLAN_LMP_DISCONNECT, NULL);
-       irlan_do_provider_event(self, IRLAN_LMP_DISCONNECT, NULL);      
-       
+       irlan_do_provider_event(self, IRLAN_LMP_DISCONNECT, NULL);
+
        /* Remove frames queued on the control channel */
        skb_queue_purge(&self->client.txq);
 
        self->client.tx_busy = 0;
-       
+
        return 0;
 }
 
@@ -164,7 +164,7 @@ static int irlan_eth_xmit(struct sk_buff *skb, struct net_device *dev)
 
        /* skb headroom large enough to contain all IrDA-headers? */
        if ((skb_headroom(skb) < self->max_header_size) || (skb_shared(skb))) {
-               struct sk_buff *new_skb = 
+               struct sk_buff *new_skb =
                        skb_realloc_headroom(skb, self->max_header_size);
 
                /*  We have to free the original skb anyway */
@@ -176,7 +176,7 @@ static int irlan_eth_xmit(struct sk_buff *skb, struct net_device *dev)
 
                /* Use the new skb instead */
                skb = new_skb;
-       } 
+       }
 
        dev->trans_start = jiffies;
 
@@ -187,7 +187,7 @@ static int irlan_eth_xmit(struct sk_buff *skb, struct net_device *dev)
                ret = irttp_data_request(self->tsap_data, skb);
 
        if (ret < 0) {
-               /*   
+               /*
                 * IrTTPs tx queue is full, so we just have to
                 * drop the frame! You might think that we should
                 * just return -1 and don't deallocate the frame,
@@ -195,15 +195,15 @@ static int irlan_eth_xmit(struct sk_buff *skb, struct net_device *dev)
                 * we have replaced the original skb with a new
                 * one with larger headroom, and that would really
                 * confuse do_dev_queue_xmit() in dev.c! I have
-                * tried :-) DB 
+                * tried :-) DB
                 */
                /* irttp_data_request already free the packet */
                self->stats.tx_dropped++;
        } else {
                self->stats.tx_packets++;
-               self->stats.tx_bytes += skb->len; 
+               self->stats.tx_bytes += skb->len;
        }
-       
+
        return 0;
 }
 
@@ -218,37 +218,37 @@ int irlan_eth_receive(void *instance, void *sap, struct sk_buff *skb)
        struct irlan_cb *self = instance;
 
        if (skb == NULL) {
-               ++self->stats.rx_dropped; 
+               ++self->stats.rx_dropped;
                return 0;
        }
        if (skb->len < ETH_HLEN) {
                IRDA_DEBUG(0, "%s() : IrLAN frame too short (%d)\n",
                           __FUNCTION__, skb->len);
-               ++self->stats.rx_dropped; 
+               ++self->stats.rx_dropped;
                dev_kfree_skb(skb);
                return 0;
        }
-               
-       /* 
-        * Adopt this frame! Important to set all these fields since they 
+
+       /*
+        * Adopt this frame! Important to set all these fields since they
         * might have been previously set by the low level IrDA network
-        * device driver 
+        * device driver
         */
        skb->dev = self->dev;
        skb->protocol=eth_type_trans(skb, skb->dev); /* Remove eth header */
-       
+
        self->stats.rx_packets++;
-       self->stats.rx_bytes += skb->len; 
+       self->stats.rx_bytes += skb->len;
 
        netif_rx(skb);   /* Eat it! */
-       
+
        return 0;
 }
 
 /*
  * Function irlan_eth_flow (status)
  *
- *    Do flow control between IP/Ethernet and IrLAN/IrTTP. This is done by 
+ *    Do flow control between IP/Ethernet and IrLAN/IrTTP. This is done by
  *    controlling the queue stop/start.
  *
  * The IrDA link layer has the advantage to have flow control, and
@@ -268,11 +268,11 @@ void irlan_eth_flow_indication(void *instance, void *sap, LOCAL_FLOW flow)
 
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
-       
+
        dev = self->dev;
 
        IRDA_ASSERT(dev != NULL, return;);
-       
+
        IRDA_DEBUG(0, "%s() : flow %s ; running %d\n", __FUNCTION__,
                   flow == FLOW_STOP ? "FLOW_STOP" : "FLOW_START",
                   netif_running(dev));
@@ -301,10 +301,10 @@ void irlan_eth_send_gratuitous_arp(struct net_device *dev)
 {
        struct in_device *in_dev;
 
-       /* 
+       /*
         * When we get a new MAC address do a gratuitous ARP. This
         * is useful if we have changed access points on the same
-        * subnet.  
+        * subnet.
         */
 #ifdef CONFIG_INET
        IRDA_DEBUG(4, "IrLAN: Sending gratuitous ARP\n");
@@ -313,10 +313,10 @@ void irlan_eth_send_gratuitous_arp(struct net_device *dev)
        if (in_dev == NULL)
                goto out;
        if (in_dev->ifa_list)
-               
-       arp_send(ARPOP_REQUEST, ETH_P_ARP, 
+
+       arp_send(ARPOP_REQUEST, ETH_P_ARP,
                 in_dev->ifa_list->ifa_address,
-                dev, 
+                dev,
                 in_dev->ifa_list->ifa_address,
                 NULL, dev->dev_addr, NULL);
 out:
@@ -331,9 +331,9 @@ out:
  *
  */
 #define HW_MAX_ADDRS 4 /* Must query to get it! */
-static void irlan_eth_set_multicast_list(struct net_device *dev) 
+static void irlan_eth_set_multicast_list(struct net_device *dev)
 {
-       struct irlan_cb *self = netdev_priv(dev);
+       struct irlan_cb *self = netdev_priv(dev);
 
        IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
 
@@ -346,7 +346,7 @@ static void irlan_eth_set_multicast_list(struct net_device *dev)
        if (dev->flags & IFF_PROMISC) {
                /* Enable promiscuous mode */
                IRDA_WARNING("Promiscous mode not implemented by IrLAN!\n");
-       } 
+       }
        else if ((dev->flags & IFF_ALLMULTI) || dev->mc_count > HW_MAX_ADDRS) {
                /* Disable promiscuous mode, use normal mode. */
                IRDA_DEBUG(4, "%s(), Setting multicast filter\n", __FUNCTION__ );
@@ -378,7 +378,7 @@ static void irlan_eth_set_multicast_list(struct net_device *dev)
  *    Get the current statistics for this device
  *
  */
-static struct net_device_stats *irlan_eth_get_stats(struct net_device *dev) 
+static struct net_device_stats *irlan_eth_get_stats(struct net_device *dev)
 {
        struct irlan_cb *self = netdev_priv(dev);
 
index 2778d8c6aa3113eb16d1fb2fada8622e3f591760..623e0fd16c1900909c3830e1409a6ec7d872fe62 100644 (file)
@@ -1,25 +1,25 @@
 /*********************************************************************
- *                
+ *
  * Filename:      irlan_event.c
- * Version:       
- * Description:   
+ * Version:
+ * Description:
  * Status:        Experimental.
  * Author:        Dag Brattli <dagb@cs.uit.no>
  * Created at:    Tue Oct 20 09:10:16 1998
  * Modified at:   Sat Oct 30 12:59:01 1999
  * Modified by:   Dag Brattli <dagb@cs.uit.no>
- * 
+ *
  *     Copyright (c) 1998-1999 Dag Brattli, All Rights Reserved.
- *      
- *     This program is free software; you can redistribute it and/or 
- *     modify it under the terms of the GNU General Public License as 
- *     published by the Free Software Foundation; either version 2 of 
+ *
+ *     This program is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU General Public License as
+ *     published by the Free Software Foundation; either version 2 of
  *     the License, or (at your option) any later version.
- *  
+ *
  *     Neither Dag Brattli nor University of Tromsø admit liability nor
- *     provide warranty for any of this software. This material is 
+ *     provide warranty for any of this software. This material is
  *     provided "AS-IS" and at no charge.
- *     
+ *
  ********************************************************************/
 
 #include <net/irda/irlan_event.h>
@@ -38,7 +38,7 @@ char *irlan_state[] = {
        "IRLAN_SYNC",
 };
 
-void irlan_next_client_state(struct irlan_cb *self, IRLAN_STATE state) 
+void irlan_next_client_state(struct irlan_cb *self, IRLAN_STATE state)
 {
        IRDA_DEBUG(2, "%s(), %s\n", __FUNCTION__ , irlan_state[state]);
 
@@ -48,7 +48,7 @@ void irlan_next_client_state(struct irlan_cb *self, IRLAN_STATE state)
        self->client.state = state;
 }
 
-void irlan_next_provider_state(struct irlan_cb *self, IRLAN_STATE state) 
+void irlan_next_provider_state(struct irlan_cb *self, IRLAN_STATE state)
 {
        IRDA_DEBUG(2, "%s(), %s\n", __FUNCTION__ , irlan_state[state]);
 
index ca7d358dab523866d32f67813d6a13781adaff67..e6346b88f934fef993428aa9e0448475094d28e3 100644 (file)
@@ -1,25 +1,25 @@
 /*********************************************************************
- *                
+ *
  * Filename:      irlan_filter.c
- * Version:       
- * Description:   
+ * Version:
+ * Description:
  * Status:        Experimental.
  * Author:        Dag Brattli <dagb@cs.uit.no>
  * Created at:    Fri Jan 29 11:16:38 1999
  * Modified at:   Sat Oct 30 12:58:45 1999
  * Modified by:   Dag Brattli <dagb@cs.uit.no>
- * 
+ *
  *     Copyright (c) 1998-1999 Dag Brattli, All Rights Reserved.
- *      
- *     This program is free software; you can redistribute it and/or 
- *     modify it under the terms of the GNU General Public License as 
- *     published by the Free Software Foundation; either version 2 of 
+ *
+ *     This program is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU General Public License as
+ *     published by the Free Software Foundation; either version 2 of
  *     the License, or (at your option) any later version.
- *  
+ *
  *     Neither Dag Brattli nor University of Tromsø admit liability nor
- *     provide warranty for any of this software. This material is 
+ *     provide warranty for any of this software. This material is
  *     provided "AS-IS" and at no charge.
- *     
+ *
  ********************************************************************/
 
 #include <linux/skbuff.h>
@@ -40,7 +40,7 @@ void irlan_filter_request(struct irlan_cb *self, struct sk_buff *skb)
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
 
-       if ((self->provider.filter_type == IRLAN_DIRECTED) && 
+       if ((self->provider.filter_type == IRLAN_DIRECTED) &&
            (self->provider.filter_operation == DYNAMIC))
        {
                IRDA_DEBUG(0, "Giving peer a dynamic Ethernet address\n");
@@ -48,12 +48,12 @@ void irlan_filter_request(struct irlan_cb *self, struct sk_buff *skb)
                self->provider.mac_address[1] = 0x00;
                self->provider.mac_address[2] = 0x00;
                self->provider.mac_address[3] = 0x00;
-               
+
                /* Use arbitration value to generate MAC address */
                if (self->provider.access_type == ACCESS_PEER) {
-                       self->provider.mac_address[4] = 
+                       self->provider.mac_address[4] =
                                self->provider.send_arb_val & 0xff;
-                       self->provider.mac_address[5] = 
+                       self->provider.mac_address[5] =
                                (self->provider.send_arb_val >> 8) & 0xff;
                } else {
                        /* Just generate something for now */
@@ -65,12 +65,12 @@ void irlan_filter_request(struct irlan_cb *self, struct sk_buff *skb)
                skb->data[1] = 0x03;
                irlan_insert_string_param(skb, "FILTER_MODE", "NONE");
                irlan_insert_short_param(skb, "MAX_ENTRY", 0x0001);
-               irlan_insert_array_param(skb, "FILTER_ENTRY", 
+               irlan_insert_array_param(skb, "FILTER_ENTRY",
                                         self->provider.mac_address, 6);
                return;
        }
-       
-       if ((self->provider.filter_type == IRLAN_DIRECTED) && 
+
+       if ((self->provider.filter_type == IRLAN_DIRECTED) &&
            (self->provider.filter_mode == FILTER))
        {
                IRDA_DEBUG(0, "Directed filter on\n");
@@ -78,7 +78,7 @@ void irlan_filter_request(struct irlan_cb *self, struct sk_buff *skb)
                skb->data[1] = 0x00;
                return;
        }
-       if ((self->provider.filter_type == IRLAN_DIRECTED) && 
+       if ((self->provider.filter_type == IRLAN_DIRECTED) &&
            (self->provider.filter_mode == NONE))
        {
                IRDA_DEBUG(0, "Directed filter off\n");
@@ -87,7 +87,7 @@ void irlan_filter_request(struct irlan_cb *self, struct sk_buff *skb)
                return;
        }
 
-       if ((self->provider.filter_type == IRLAN_BROADCAST) && 
+       if ((self->provider.filter_type == IRLAN_BROADCAST) &&
            (self->provider.filter_mode == FILTER))
        {
                IRDA_DEBUG(0, "Broadcast filter on\n");
@@ -95,7 +95,7 @@ void irlan_filter_request(struct irlan_cb *self, struct sk_buff *skb)
                skb->data[1] = 0x00;
                return;
        }
-       if ((self->provider.filter_type == IRLAN_BROADCAST) && 
+       if ((self->provider.filter_type == IRLAN_BROADCAST) &&
            (self->provider.filter_mode == NONE))
        {
                IRDA_DEBUG(0, "Broadcast filter off\n");
@@ -103,7 +103,7 @@ void irlan_filter_request(struct irlan_cb *self, struct sk_buff *skb)
                skb->data[1] = 0x00;
                return;
        }
-       if ((self->provider.filter_type == IRLAN_MULTICAST) && 
+       if ((self->provider.filter_type == IRLAN_MULTICAST) &&
            (self->provider.filter_mode == FILTER))
        {
                IRDA_DEBUG(0, "Multicast filter on\n");
@@ -111,7 +111,7 @@ void irlan_filter_request(struct irlan_cb *self, struct sk_buff *skb)
                skb->data[1] = 0x00;
                return;
        }
-       if ((self->provider.filter_type == IRLAN_MULTICAST) && 
+       if ((self->provider.filter_type == IRLAN_MULTICAST) &&
            (self->provider.filter_mode == NONE))
        {
                IRDA_DEBUG(0, "Multicast filter off\n");
@@ -119,7 +119,7 @@ void irlan_filter_request(struct irlan_cb *self, struct sk_buff *skb)
                skb->data[1] = 0x00;
                return;
        }
-       if ((self->provider.filter_type == IRLAN_MULTICAST) && 
+       if ((self->provider.filter_type == IRLAN_MULTICAST) &&
            (self->provider.filter_operation == GET))
        {
                IRDA_DEBUG(0, "Multicast filter get\n");
index 58efde919667fb1a18c7ee0436aa53c6c1185f09..aac66434e4739d69610eaf80dc43f7893fa8dbd0 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************************
- *                
+ *
  * Filename:      irlan_provider.c
  * Version:       0.9
  * Description:   IrDA LAN Access Protocol Implementation
  * Sources:       skeleton.c by Donald Becker <becker@CESDIS.gsfc.nasa.gov>
  *                slip.c by Laurence Culhane,   <loz@holmes.demon.co.uk>
  *                          Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
- * 
- *     Copyright (c) 1998-1999 Dag Brattli <dagb@cs.uit.no>, 
+ *
+ *     Copyright (c) 1998-1999 Dag Brattli <dagb@cs.uit.no>,
  *     All Rights Reserved.
- *     
- *     This program is free software; you can redistribute it and/or 
- *     modify it under the terms of the GNU General Public License as 
- *     published by the Free Software Foundation; either version 2 of 
+ *
+ *     This program is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU General Public License as
+ *     published by the Free Software Foundation; either version 2 of
  *     the License, or (at your option) any later version.
  *
  *     Neither Dag Brattli nor University of Tromsø admit liability nor
- *     provide warranty for any of this software. This material is 
+ *     provide warranty for any of this software. This material is
  *     provided "AS-IS" and at no charge.
  *
  ********************************************************************/
@@ -52,8 +52,8 @@
 #include <net/irda/irlan_filter.h>
 #include <net/irda/irlan_client.h>
 
-static void irlan_provider_connect_indication(void *instance, void *sap, 
-                                             struct qos_info *qos, 
+static void irlan_provider_connect_indication(void *instance, void *sap,
+                                             struct qos_info *qos,
                                              __u32 max_sdu_size,
                                              __u8 max_header_size,
                                              struct sk_buff *skb);
@@ -64,14 +64,14 @@ static void irlan_provider_connect_indication(void *instance, void *sap,
  *    This function gets the data that is received on the control channel
  *
  */
-static int irlan_provider_data_indication(void *instance, void *sap, 
-                                         struct sk_buff *skb) 
+static int irlan_provider_data_indication(void *instance, void *sap,
+                                         struct sk_buff *skb)
 {
        struct irlan_cb *self;
        __u8 code;
-       
+
        IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
-       
+
        self = (struct irlan_cb *) instance;
 
        IRDA_ASSERT(self != NULL, return -1;);
@@ -83,16 +83,16 @@ static int irlan_provider_data_indication(void *instance, void *sap,
        switch(code) {
        case CMD_GET_PROVIDER_INFO:
                IRDA_DEBUG(4, "Got GET_PROVIDER_INFO command!\n");
-               irlan_do_provider_event(self, IRLAN_GET_INFO_CMD, skb); 
+               irlan_do_provider_event(self, IRLAN_GET_INFO_CMD, skb);
                break;
 
        case CMD_GET_MEDIA_CHAR:
                IRDA_DEBUG(4, "Got GET_MEDIA_CHAR command!\n");
-               irlan_do_provider_event(self, IRLAN_GET_MEDIA_CMD, skb); 
+               irlan_do_provider_event(self, IRLAN_GET_MEDIA_CMD, skb);
                break;
        case CMD_OPEN_DATA_CHANNEL:
                IRDA_DEBUG(4, "Got OPEN_DATA_CHANNEL command!\n");
-               irlan_do_provider_event(self, IRLAN_OPEN_DATA_CMD, skb); 
+               irlan_do_provider_event(self, IRLAN_OPEN_DATA_CMD, skb);
                break;
        case CMD_FILTER_OPERATION:
                IRDA_DEBUG(4, "Got FILTER_OPERATION command!\n");
@@ -119,9 +119,9 @@ static int irlan_provider_data_indication(void *instance, void *sap,
  *    Got connection from peer IrLAN client
  *
  */
-static void irlan_provider_connect_indication(void *instance, void *sap, 
+static void irlan_provider_connect_indication(void *instance, void *sap,
                                              struct qos_info *qos,
-                                             __u32 max_sdu_size, 
+                                             __u32 max_sdu_size,
                                              __u8 max_header_size,
                                              struct sk_buff *skb)
 {
@@ -130,13 +130,13 @@ static void irlan_provider_connect_indication(void *instance, void *sap,
        __u32 saddr, daddr;
 
        IRDA_DEBUG(0, "%s()\n", __FUNCTION__ );
-       
+
        self = (struct irlan_cb *) instance;
        tsap = (struct tsap_cb *) sap;
-       
+
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
-       
+
        IRDA_ASSERT(tsap == self->provider.tsap_ctrl,return;);
        IRDA_ASSERT(self->provider.state == IRLAN_IDLE, return;);
 
@@ -147,13 +147,13 @@ static void irlan_provider_connect_indication(void *instance, void *sap,
 
        irlan_do_provider_event(self, IRLAN_CONNECT_INDICATION, NULL);
 
-       /*  
+       /*
         * If we are in peer mode, the client may not have got the discovery
-        * indication it needs to make progress. If the client is still in 
-        * IDLE state, we must kick it. 
+        * indication it needs to make progress. If the client is still in
+        * IDLE state, we must kick it.
         */
-       if ((self->provider.access_type == ACCESS_PEER) && 
-           (self->client.state == IRLAN_IDLE)) 
+       if ((self->provider.access_type == ACCESS_PEER) &&
+           (self->client.state == IRLAN_IDLE))
        {
                irlan_client_wakeup(self, self->saddr, self->daddr);
        }
@@ -175,38 +175,38 @@ void irlan_provider_connect_response(struct irlan_cb *self,
        irttp_connect_response(tsap, IRLAN_MTU, NULL);
 }
 
-static void irlan_provider_disconnect_indication(void *instance, void *sap, 
-                                                LM_REASON reason, 
-                                                struct sk_buff *userdata) 
+static void irlan_provider_disconnect_indication(void *instance, void *sap,
+                                                LM_REASON reason,
+                                                struct sk_buff *userdata)
 {
        struct irlan_cb *self;
        struct tsap_cb *tsap;
 
        IRDA_DEBUG(4, "%s(), reason=%d\n", __FUNCTION__ , reason);
-       
+
        self = (struct irlan_cb *) instance;
        tsap = (struct tsap_cb *) sap;
 
        IRDA_ASSERT(self != NULL, return;);
-       IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);       
+       IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
        IRDA_ASSERT(tsap != NULL, return;);
        IRDA_ASSERT(tsap->magic == TTP_TSAP_MAGIC, return;);
-       
+
        IRDA_ASSERT(tsap == self->provider.tsap_ctrl, return;);
-       
+
        irlan_do_provider_event(self, IRLAN_LMP_DISCONNECT, NULL);
 }
 
 /*
  * Function irlan_parse_open_data_cmd (self, skb)
  *
- *    
+ *
  *
  */
 int irlan_parse_open_data_cmd(struct irlan_cb *self, struct sk_buff *skb)
 {
        int ret;
-       
+
        ret = irlan_provider_parse_command(self, CMD_OPEN_DATA_CHANNEL, skb);
 
        /* Open data channel */
@@ -218,12 +218,12 @@ int irlan_parse_open_data_cmd(struct irlan_cb *self, struct sk_buff *skb)
 /*
  * Function parse_command (skb)
  *
- *    Extract all parameters from received buffer, then feed them to 
+ *    Extract all parameters from received buffer, then feed them to
  *    check_params for parsing
  *
  */
 int irlan_provider_parse_command(struct irlan_cb *self, int cmd,
-                                struct sk_buff *skb) 
+                                struct sk_buff *skb)
 {
        __u8 *frame;
        __u8 *ptr;
@@ -231,16 +231,16 @@ int irlan_provider_parse_command(struct irlan_cb *self, int cmd,
        __u16 val_len;
        int i;
        char *name;
-        char *value;
+       char *value;
        int ret = RSP_SUCCESS;
-       
+
        IRDA_ASSERT(skb != NULL, return -RSP_PROTOCOL_ERROR;);
-       
+
        IRDA_DEBUG(4, "%s(), skb->len=%d\n", __FUNCTION__ , (int)skb->len);
 
        IRDA_ASSERT(self != NULL, return -RSP_PROTOCOL_ERROR;);
        IRDA_ASSERT(self->magic == IRLAN_MAGIC, return -RSP_PROTOCOL_ERROR;);
-       
+
        if (!skb)
                return -RSP_PROTOCOL_ERROR;
 
@@ -259,11 +259,11 @@ int irlan_provider_parse_command(struct irlan_cb *self, int cmd,
        count = frame[1];
 
        IRDA_DEBUG(4, "Got %d parameters\n", count);
-       
+
        ptr = frame+2;
-       
+
        /* For all parameters */
-       for (i=0; i<count;i++) {
+       for (i=0; i<count;i++) {
                ret = irlan_extract_param(ptr, name, value, &val_len);
                if (ret < 0) {
                        IRDA_DEBUG(2, "%s(), IrLAN, Error!\n", __FUNCTION__ );
@@ -286,7 +286,7 @@ int irlan_provider_parse_command(struct irlan_cb *self, int cmd,
  *    Send reply to query to peer IrLAN layer
  *
  */
-void irlan_provider_send_reply(struct irlan_cb *self, int command, 
+void irlan_provider_send_reply(struct irlan_cb *self, int command,
                               int ret_code)
 {
        struct sk_buff *skb;
@@ -310,7 +310,7 @@ void irlan_provider_send_reply(struct irlan_cb *self, int command,
        /* Reserve space for TTP, LMP, and LAP header */
        skb_reserve(skb, self->provider.max_header_size);
        skb_put(skb, 2);
-       
+
        switch (command) {
        case CMD_GET_PROVIDER_INFO:
                skb->data[0] = 0x00; /* Success */
@@ -356,7 +356,7 @@ void irlan_provider_send_reply(struct irlan_cb *self, int command,
                skb->data[0] = 0x00; /* Success */
                if (self->provider.send_arb_val) {
                        skb->data[1] = 0x03; /* 3 parameters */
-                       irlan_insert_short_param(skb, "CON_ARB", 
+                       irlan_insert_short_param(skb, "CON_ARB",
                                                 self->provider.send_arb_val);
                } else
                        skb->data[1] = 0x02; /* 2 parameters */
@@ -378,13 +378,13 @@ void irlan_provider_send_reply(struct irlan_cb *self, int command,
  * Function irlan_provider_register(void)
  *
  *    Register provider support so we can accept incoming connections.
- * 
+ *
  */
 int irlan_provider_open_ctrl_tsap(struct irlan_cb *self)
 {
        struct tsap_cb *tsap;
        notify_t notify;
-       
+
        IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
 
        IRDA_ASSERT(self != NULL, return -1;);
@@ -393,7 +393,7 @@ int irlan_provider_open_ctrl_tsap(struct irlan_cb *self)
        /* Check if already open */
        if (self->provider.tsap_ctrl)
                return -1;
-       
+
        /*
         *  First register well known control TSAP
         */
index 5a086f9827ed08a85e861db9ef8c54d3d6774477..ef401bd6ea0036765594ed3a122b8ec4341c0824 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************************
- *                
+ *
  * Filename:      irlan_provider_event.c
  * Version:       0.9
  * Description:   IrLAN provider state machine)
@@ -8,16 +8,16 @@
  * Created at:    Sun Aug 31 20:14:37 1997
  * Modified at:   Sat Oct 30 12:52:41 1999
  * Modified by:   Dag Brattli <dagb@cs.uit.no>
- * 
+ *
  *     Copyright (c) 1998-1999 Dag Brattli <dagb@cs.uit.no>, All Rights Reserved.
- *     
- *     This program is free software; you can redistribute it and/or 
- *     modify it under the terms of the GNU General Public License as 
- *     published by the Free Software Foundation; either version 2 of 
+ *
+ *     This program is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU General Public License as
+ *     published by the Free Software Foundation; either version 2 of
  *     the License, or (at your option) any later version.
  *
  *     Neither Dag Brattli nor University of Tromsø admit liability nor
- *     provide warranty for any of this software. This material is 
+ *     provide warranty for any of this software. This material is
  *     provided "AS-IS" and at no charge.
  *
  ********************************************************************/
 #include <net/irda/irlan_provider.h>
 #include <net/irda/irlan_event.h>
 
-static int irlan_provider_state_idle(struct irlan_cb *self, IRLAN_EVENT event, 
+static int irlan_provider_state_idle(struct irlan_cb *self, IRLAN_EVENT event,
                                     struct sk_buff *skb);
-static int irlan_provider_state_info(struct irlan_cb *self, IRLAN_EVENT event, 
+static int irlan_provider_state_info(struct irlan_cb *self, IRLAN_EVENT event,
                                     struct sk_buff *skb);
-static int irlan_provider_state_open(struct irlan_cb *self, IRLAN_EVENT event, 
+static int irlan_provider_state_open(struct irlan_cb *self, IRLAN_EVENT event,
                                     struct sk_buff *skb);
-static int irlan_provider_state_data(struct irlan_cb *self, IRLAN_EVENT event, 
+static int irlan_provider_state_data(struct irlan_cb *self, IRLAN_EVENT event,
                                     struct sk_buff *skb);
 
-static int (*state[])(struct irlan_cb *self, IRLAN_EVENT event, 
-                     struct sk_buff *skb) = 
-{ 
+static int (*state[])(struct irlan_cb *self, IRLAN_EVENT event,
+                     struct sk_buff *skb) =
+{
        irlan_provider_state_idle,
        NULL, /* Query */
        NULL, /* Info */
@@ -55,8 +55,8 @@ static int (*state[])(struct irlan_cb *self, IRLAN_EVENT event,
        NULL, /* Sync */
 };
 
-void irlan_do_provider_event(struct irlan_cb *self, IRLAN_EVENT event, 
-                            struct sk_buff *skb) 
+void irlan_do_provider_event(struct irlan_cb *self, IRLAN_EVENT event,
+                            struct sk_buff *skb)
 {
        IRDA_ASSERT(*state[ self->provider.state] != NULL, return;);
 
@@ -73,9 +73,9 @@ static int irlan_provider_state_idle(struct irlan_cb *self, IRLAN_EVENT event,
                                     struct sk_buff *skb)
 {
        IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
-       
+
        IRDA_ASSERT(self != NULL, return -1;);
-       
+
        switch(event) {
        case IRLAN_CONNECT_INDICATION:
             irlan_provider_connect_response( self, self->provider.tsap_ctrl);
@@ -96,13 +96,13 @@ static int irlan_provider_state_idle(struct irlan_cb *self, IRLAN_EVENT event,
  *
  *    INFO, We have issued a GetInfo command and is awaiting a reply.
  */
-static int irlan_provider_state_info(struct irlan_cb *self, IRLAN_EVENT event, 
-                                    struct sk_buff *skb) 
+static int irlan_provider_state_info(struct irlan_cb *self, IRLAN_EVENT event,
+                                    struct sk_buff *skb)
 {
        int ret;
 
        IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
-       
+
        IRDA_ASSERT(self != NULL, return -1;);
 
        switch(event) {
@@ -110,7 +110,7 @@ static int irlan_provider_state_info(struct irlan_cb *self, IRLAN_EVENT event,
                /* Be sure to use 802.3 in case of peer mode */
                if (self->provider.access_type == ACCESS_PEER) {
                        self->media = MEDIA_802_3;
-                       
+
                        /* Check if client has started yet */
                        if (self->client.state == IRLAN_IDLE) {
                                /* This should get the client going */
@@ -118,15 +118,15 @@ static int irlan_provider_state_info(struct irlan_cb *self, IRLAN_EVENT event,
                        }
                }
 
-               irlan_provider_send_reply(self, CMD_GET_PROVIDER_INFO, 
+               irlan_provider_send_reply(self, CMD_GET_PROVIDER_INFO,
                                          RSP_SUCCESS);
                /* Keep state */
                break;
-       case IRLAN_GET_MEDIA_CMD: 
-               irlan_provider_send_reply(self, CMD_GET_MEDIA_CHAR, 
+       case IRLAN_GET_MEDIA_CMD:
+               irlan_provider_send_reply(self, CMD_GET_MEDIA_CHAR,
                                          RSP_SUCCESS);
                /* Keep state */
-               break;          
+               break;
        case IRLAN_OPEN_DATA_CMD:
                ret = irlan_parse_open_data_cmd(self, skb);
                if (self->provider.access_type == ACCESS_PEER) {
@@ -152,7 +152,7 @@ static int irlan_provider_state_info(struct irlan_cb *self, IRLAN_EVENT event,
        }
        if (skb)
                dev_kfree_skb(skb);
-       
+
        return 0;
 }
 
@@ -163,7 +163,7 @@ static int irlan_provider_state_info(struct irlan_cb *self, IRLAN_EVENT event,
  *    reply
  *
  */
-static int irlan_provider_state_open(struct irlan_cb *self, IRLAN_EVENT event, 
+static int irlan_provider_state_open(struct irlan_cb *self, IRLAN_EVENT event,
                                     struct sk_buff *skb)
 {
        IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
@@ -173,11 +173,11 @@ static int irlan_provider_state_open(struct irlan_cb *self, IRLAN_EVENT event,
        switch(event) {
        case IRLAN_FILTER_CONFIG_CMD:
                irlan_provider_parse_command(self, CMD_FILTER_OPERATION, skb);
-               irlan_provider_send_reply(self, CMD_FILTER_OPERATION, 
+               irlan_provider_send_reply(self, CMD_FILTER_OPERATION,
                                          RSP_SUCCESS);
                /* Keep state */
                break;
-       case IRLAN_DATA_CONNECT_INDICATION: 
+       case IRLAN_DATA_CONNECT_INDICATION:
                irlan_next_provider_state(self, IRLAN_DATA);
                irlan_provider_connect_response(self, self->tsap_data);
                break;
@@ -202,8 +202,8 @@ static int irlan_provider_state_open(struct irlan_cb *self, IRLAN_EVENT event,
  *    the local and remote machines.
  *
  */
-static int irlan_provider_state_data(struct irlan_cb *self, IRLAN_EVENT event, 
-                                    struct sk_buff *skb) 
+static int irlan_provider_state_data(struct irlan_cb *self, IRLAN_EVENT event,
+                                    struct sk_buff *skb)
 {
        IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
 
@@ -213,7 +213,7 @@ static int irlan_provider_state_data(struct irlan_cb *self, IRLAN_EVENT event,
        switch(event) {
        case IRLAN_FILTER_CONFIG_CMD:
                irlan_provider_parse_command(self, CMD_FILTER_OPERATION, skb);
-               irlan_provider_send_reply(self, CMD_FILTER_OPERATION, 
+               irlan_provider_send_reply(self, CMD_FILTER_OPERATION,
                                          RSP_SUCCESS);
                break;
        case IRLAN_LMP_DISCONNECT: /* FALLTHROUGH */
@@ -226,7 +226,7 @@ static int irlan_provider_state_data(struct irlan_cb *self, IRLAN_EVENT event,
        }
        if (skb)
                dev_kfree_skb(skb);
-       
+
        return 0;
 }
 
index e7852a07495e44785c4b42148d22f69e12dd9fc7..fd73e4af715a3dc82fcad5fcc771b136210a7afb 100644 (file)
@@ -87,7 +87,7 @@ int __init irlap_init(void)
        /* Allocate master array */
        irlap = hashbin_new(HB_LOCK);
        if (irlap == NULL) {
-               IRDA_ERROR("%s: can't allocate irlap hashbin!\n",
+               IRDA_ERROR("%s: can't allocate irlap hashbin!\n",
                           __FUNCTION__);
                return -ENOMEM;
        }
@@ -701,8 +701,8 @@ void irlap_update_nr_received(struct irlap_cb *self, int nr)
        int count = 0;
 
        /*
-         * Remove all the ack-ed frames from the window queue.
-         */
+        * Remove all the ack-ed frames from the window queue.
+        */
 
        /*
         *  Optimize for the common case. It is most likely that the receiver
@@ -1109,13 +1109,13 @@ static void *irlap_seq_start(struct seq_file *seq, loff_t *pos)
        spin_lock_irq(&irlap->hb_spinlock);
        iter->id = 0;
 
-       for (self = (struct irlap_cb *) hashbin_get_first(irlap); 
+       for (self = (struct irlap_cb *) hashbin_get_first(irlap);
             self; self = (struct irlap_cb *) hashbin_get_next(irlap)) {
                if (iter->id == *pos)
                        break;
                ++iter->id;
        }
-               
+
        return self;
 }
 
@@ -1137,7 +1137,7 @@ static int irlap_seq_show(struct seq_file *seq, void *v)
 {
        const struct irlap_iter_state *iter = seq->private;
        const struct irlap_cb *self = v;
-       
+
        IRDA_ASSERT(self->magic == LAP_MAGIC, return -EINVAL;);
 
        seq_printf(seq, "irlap%d ", iter->id);
@@ -1222,7 +1222,7 @@ static int irlap_seq_open(struct inode *inode, struct file *file)
        struct seq_file *seq;
        int rc = -ENOMEM;
        struct irlap_iter_state *s = kzalloc(sizeof(*s), GFP_KERNEL);
-       
+
        if (!s)
                goto out;
 
index 99faff68c399aa92422453f79497889113de9094..7b6433fe1dc23d4bacbff6eed1efd7937d201583 100644 (file)
@@ -827,7 +827,7 @@ static int irlap_state_conn(struct irlap_cb *self, IRLAP_EVENT event,
                irlap_disconnect_indication(self, LAP_DISC_INDICATION);
                break;
        default:
-               IRDA_DEBUG(1, "%s(), Unknown event %d, %s\n", __FUNCTION__, 
+               IRDA_DEBUG(1, "%s(), Unknown event %d, %s\n", __FUNCTION__,
                           event, irlap_event[event]);
 
                ret = -1;
@@ -864,7 +864,7 @@ static int irlap_state_setup(struct irlap_cb *self, IRLAP_EVENT event,
  *  between 15 msecs and 45 msecs.
  */
                        irlap_start_backoff_timer(self, msecs_to_jiffies(20 +
-                                                       (jiffies % 30)));
+                                                       (jiffies % 30)));
                } else {
                        /* Always switch state before calling upper layers */
                        irlap_next_state(self, LAP_NDM);
@@ -1377,7 +1377,7 @@ static int irlap_state_nrm_p(struct irlap_cb *self, IRLAP_EVENT event,
                                /* Resend rejected frames */
                                irlap_resend_rejected_frames(self, CMD_FRAME);
 
-                               /* Give peer some time to retransmit! 
+                               /* Give peer some time to retransmit!
                                 * But account for our own Tx. */
                                irlap_start_final_timer(self, 2 * self->final_timeout);
 
index dba349c832d02454b8451bbd02aa1935e23d9e15..0b04603e9c475bb9b95ac05d1c5d6e48e3c08a6c 100644 (file)
@@ -414,7 +414,7 @@ static void irlap_recv_discovery_xid_rsp(struct irlap_cb *self,
                IRDA_ERROR("%s: frame to short!\n", __FUNCTION__);
                return;
        }
-               
+
        xid = (struct xid_frame *) skb->data;
 
        info->daddr = le32_to_cpu(xid->saddr);
@@ -485,7 +485,7 @@ static void irlap_recv_discovery_xid_cmd(struct irlap_cb *self,
                IRDA_ERROR("%s: frame to short!\n", __FUNCTION__);
                return;
        }
-       
+
        xid = (struct xid_frame *) skb->data;
 
        info->daddr = le32_to_cpu(xid->saddr);
@@ -524,7 +524,7 @@ static void irlap_recv_discovery_xid_cmd(struct irlap_cb *self,
         */
        if (info->s == 0xff) {
                /* Check if things are sane at this point... */
-               if((discovery_info == NULL) || 
+               if((discovery_info == NULL) ||
                   !pskb_may_pull(skb, 3)) {
                        IRDA_ERROR("%s: discovery frame to short!\n",
                                   __FUNCTION__);
index 7e5d12ab3b90dd1f580465089a6b150377eb07b9..b134c3cf2bdb9dd3a1fd0f42788bdf9c68f63f6a 100644 (file)
@@ -116,7 +116,7 @@ int __init irlmp_init(void)
  *    Remove IrLMP layer
  *
  */
-void __exit irlmp_cleanup(void) 
+void __exit irlmp_cleanup(void)
 {
        /* Check for main structure */
        IRDA_ASSERT(irlmp != NULL, return;);
@@ -892,7 +892,7 @@ void irlmp_discovery_request(int nslots)
 
        /*
         * Start a single discovery operation if discovery is not already
-         * running
+        * running
         */
        if (!sysctl_discovery) {
                /* Check if user wants to override the default */
@@ -1528,12 +1528,12 @@ int irlmp_unregister_service(void *handle)
 
        /* Refresh current hint bits */
        spin_lock_irqsave(&irlmp->services->hb_spinlock, flags);
-        service = (irlmp_service_t *) hashbin_get_first(irlmp->services);
-        while (service) {
+       service = (irlmp_service_t *) hashbin_get_first(irlmp->services);
+       while (service) {
                irlmp->hints.word |= service->hints.word;
 
-                service = (irlmp_service_t *)hashbin_get_next(irlmp->services);
-        }
+               service = (irlmp_service_t *)hashbin_get_next(irlmp->services);
+       }
        spin_unlock_irqrestore(&irlmp->services->hb_spinlock, flags);
        return 0;
 }
@@ -1861,7 +1861,7 @@ static void *irlmp_seq_hb_idx(struct irlmp_iter_state *iter, loff_t *off)
 
        spin_lock_irq(&iter->hashbin->hb_spinlock);
        for (element = hashbin_get_first(iter->hashbin);
-            element != NULL; 
+            element != NULL;
             element = hashbin_get_next(iter->hashbin)) {
                if (!off || *off-- == 0) {
                        /* NB: hashbin left locked */
@@ -1918,7 +1918,7 @@ static void *irlmp_seq_next(struct seq_file *seq, void *v, loff_t *pos)
        if (v == NULL) {                        /* no more in this hash bin */
                spin_unlock_irq(&iter->hashbin->hb_spinlock);
 
-               if (iter->hashbin == irlmp->unconnected_lsaps) 
+               if (iter->hashbin == irlmp->unconnected_lsaps)
                        v =  LINK_START_TOKEN;
 
                iter->hashbin = NULL;
index 4c90dd1b450317b22af7acaeb5b61ca3a19cd952..65ffa981510add944657bac1a9e766425da732cf 100644 (file)
@@ -615,7 +615,7 @@ static int irlmp_state_connect(struct lsap_cb *self, IRLMP_EVENT event,
        default:
                /* LM_LAP_DISCONNECT_INDICATION : Should never happen, we
                 * are *not* yet bound to the IrLAP link. Jean II */
-               IRDA_DEBUG(0, "%s(), Unknown event %s on LSAP %#02x\n", 
+               IRDA_DEBUG(0, "%s(), Unknown event %s on LSAP %#02x\n",
                           __FUNCTION__, irlmp_event[event], self->slsap_sel);
                break;
        }
index 39761a1d18f53058e5c45490d44e5dfa3e647855..559302d3fe66264611100da2352010ebe0580897 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************************
- *                
+ *
  * Filename:      irlmp_frame.c
  * Version:       0.9
  * Description:   IrLMP frame implementation
@@ -8,18 +8,18 @@
  * Created at:    Tue Aug 19 02:09:59 1997
  * Modified at:   Mon Dec 13 13:41:12 1999
  * Modified by:   Dag Brattli <dagb@cs.uit.no>
- * 
+ *
  *     Copyright (c) 1998-1999 Dag Brattli <dagb@cs.uit.no>
  *     All Rights Reserved.
  *     Copyright (c) 2000-2003 Jean Tourrilhes <jt@hpl.hp.com>
- *     
- *     This program is free software; you can redistribute it and/or 
- *     modify it under the terms of the GNU General Public License as 
- *     published by the Free Software Foundation; either version 2 of 
+ *
+ *     This program is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU General Public License as
+ *     published by the Free Software Foundation; either version 2 of
  *     the License, or (at your option) any later version.
  *
  *     Neither Dag Brattli nor University of Tromsø admit liability nor
- *     provide warranty for any of this software. This material is 
+ *     provide warranty for any of this software. This material is
  *     provided "AS-IS" and at no charge.
  *
  ********************************************************************/
@@ -34,7 +34,7 @@
 #include <net/irda/irlmp_frame.h>
 #include <net/irda/discovery.h>
 
-static struct lsap_cb *irlmp_find_lsap(struct lap_cb *self, __u8 dlsap, 
+static struct lsap_cb *irlmp_find_lsap(struct lap_cb *self, __u8 dlsap,
                                       __u8 slsap, int status, hashbin_t *);
 
 inline void irlmp_send_data_pdu(struct lap_cb *self, __u8 dlsap, __u8 slsap,
@@ -56,18 +56,18 @@ inline void irlmp_send_data_pdu(struct lap_cb *self, __u8 dlsap, __u8 slsap,
  *    Send Link Control Frame to IrLAP
  */
 void irlmp_send_lcf_pdu(struct lap_cb *self, __u8 dlsap, __u8 slsap,
-                       __u8 opcode, struct sk_buff *skb) 
+                       __u8 opcode, struct sk_buff *skb)
 {
        __u8 *frame;
-       
+
        IRDA_DEBUG(2, "%s()\n", __FUNCTION__);
 
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == LMP_LAP_MAGIC, return;);
        IRDA_ASSERT(skb != NULL, return;);
-       
+
        frame = skb->data;
-       
+
        frame[0] = dlsap | CONTROL_BIT;
        frame[1] = slsap;
 
@@ -87,14 +87,14 @@ void irlmp_send_lcf_pdu(struct lap_cb *self, __u8 dlsap, __u8 slsap,
  *    Used by IrLAP to pass received data frames to IrLMP layer
  *
  */
-void irlmp_link_data_indication(struct lap_cb *self, struct sk_buff *skb, 
+void irlmp_link_data_indication(struct lap_cb *self, struct sk_buff *skb,
                                int unreliable)
 {
        struct lsap_cb *lsap;
        __u8   slsap_sel;   /* Source (this) LSAP address */
        __u8   dlsap_sel;   /* Destination LSAP address */
        __u8   *fp;
-       
+
        IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
 
        IRDA_ASSERT(self != NULL, return;);
@@ -104,11 +104,11 @@ void irlmp_link_data_indication(struct lap_cb *self, struct sk_buff *skb,
        fp = skb->data;
 
        /*
-        *  The next statements may be confusing, but we do this so that 
+        *  The next statements may be confusing, but we do this so that
         *  destination LSAP of received frame is source LSAP in our view
         */
-       slsap_sel = fp[0] & LSAP_MASK; 
-       dlsap_sel = fp[1];      
+       slsap_sel = fp[0] & LSAP_MASK;
+       dlsap_sel = fp[1];
 
        /*
         *  Check if this is an incoming connection, since we must deal with
@@ -118,11 +118,11 @@ void irlmp_link_data_indication(struct lap_cb *self, struct sk_buff *skb,
                IRDA_DEBUG(3, "%s(), incoming connection, "
                           "source LSAP=%d, dest LSAP=%d\n",
                           __FUNCTION__, slsap_sel, dlsap_sel);
-               
+
                /* Try to find LSAP among the unconnected LSAPs */
                lsap = irlmp_find_lsap(self, dlsap_sel, slsap_sel, CONNECT_CMD,
                                       irlmp->unconnected_lsaps);
-               
+
                /* Maybe LSAP was already connected, so try one more time */
                if (!lsap) {
                        IRDA_DEBUG(1, "%s(), incoming connection for LSAP already connected\n", __FUNCTION__);
@@ -130,9 +130,9 @@ void irlmp_link_data_indication(struct lap_cb *self, struct sk_buff *skb,
                                               self->lsaps);
                }
        } else
-               lsap = irlmp_find_lsap(self, dlsap_sel, slsap_sel, 0, 
+               lsap = irlmp_find_lsap(self, dlsap_sel, slsap_sel, 0,
                                       self->lsaps);
-       
+
        if (lsap == NULL) {
                IRDA_DEBUG(2, "IrLMP, Sorry, no LSAP for received frame!\n");
                IRDA_DEBUG(2, "%s(), slsap_sel = %02x, dlsap_sel = %02x\n",
@@ -146,8 +146,8 @@ void irlmp_link_data_indication(struct lap_cb *self, struct sk_buff *skb,
                return;
        }
 
-       /* 
-        *  Check if we received a control frame? 
+       /*
+        *  Check if we received a control frame?
         */
        if (fp[0] & CONTROL_BIT) {
                switch (fp[2]) {
@@ -161,7 +161,7 @@ void irlmp_link_data_indication(struct lap_cb *self, struct sk_buff *skb,
                case DISCONNECT:
                        IRDA_DEBUG(4, "%s(), Disconnect indication!\n",
                                   __FUNCTION__);
-                       irlmp_do_lsap_event(lsap, LM_DISCONNECT_INDICATION, 
+                       irlmp_do_lsap_event(lsap, LM_DISCONNECT_INDICATION,
                                            skb);
                        break;
                case ACCESSMODE_CMD:
@@ -181,7 +181,7 @@ void irlmp_link_data_indication(struct lap_cb *self, struct sk_buff *skb,
                        irlmp_udata_indication(lsap, skb);
                else
                        irlmp_do_lsap_event(lsap, LM_UDATA_INDICATION, skb);
-       } else {        
+       } else {
                /* Optimize and bypass the state machine if possible */
                if (lsap->lsap_state == LSAP_DATA_TRANSFER_READY)
                        irlmp_data_indication(lsap, skb);
@@ -193,7 +193,7 @@ void irlmp_link_data_indication(struct lap_cb *self, struct sk_buff *skb,
 /*
  * Function irlmp_link_unitdata_indication (self, skb)
  *
- *    
+ *
  *
  */
 #ifdef CONFIG_IRDA_ULTRA
@@ -205,7 +205,7 @@ void irlmp_link_unitdata_indication(struct lap_cb *self, struct sk_buff *skb)
        __u8   pid;         /* Protocol identifier */
        __u8   *fp;
        unsigned long flags;
-       
+
        IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
 
        IRDA_ASSERT(self != NULL, return;);
@@ -215,13 +215,13 @@ void irlmp_link_unitdata_indication(struct lap_cb *self, struct sk_buff *skb)
        fp = skb->data;
 
        /*
-        *  The next statements may be confusing, but we do this so that 
+        *  The next statements may be confusing, but we do this so that
         *  destination LSAP of received frame is source LSAP in our view
         */
-       slsap_sel = fp[0] & LSAP_MASK; 
+       slsap_sel = fp[0] & LSAP_MASK;
        dlsap_sel = fp[1];
        pid       = fp[2];
-       
+
        if (pid & 0x80) {
                IRDA_DEBUG(0, "%s(), extension in PID not supp!\n",
                           __FUNCTION__);
@@ -233,7 +233,7 @@ void irlmp_link_unitdata_indication(struct lap_cb *self, struct sk_buff *skb)
                IRDA_DEBUG(0, "%s(), dropping frame!\n", __FUNCTION__);
                return;
        }
-       
+
        /* Search the connectionless LSAP */
        spin_lock_irqsave(&irlmp->unconnected_lsaps->hb_spinlock, flags);
        lsap = (struct lsap_cb *) hashbin_get_first(irlmp->unconnected_lsaps);
@@ -241,10 +241,10 @@ void irlmp_link_unitdata_indication(struct lap_cb *self, struct sk_buff *skb)
                /*
                 *  Check if source LSAP and dest LSAP selectors and PID match.
                 */
-               if ((lsap->slsap_sel == slsap_sel) && 
-                   (lsap->dlsap_sel == dlsap_sel) && 
-                   (lsap->pid == pid)) 
-               {                       
+               if ((lsap->slsap_sel == slsap_sel) &&
+                   (lsap->dlsap_sel == dlsap_sel) &&
+                   (lsap->pid == pid))
+               {
                        break;
                }
                lsap = (struct lsap_cb *) hashbin_get_next(irlmp->unconnected_lsaps);
@@ -262,12 +262,12 @@ void irlmp_link_unitdata_indication(struct lap_cb *self, struct sk_buff *skb)
 /*
  * Function irlmp_link_disconnect_indication (reason, userdata)
  *
- *    IrLAP has disconnected 
+ *    IrLAP has disconnected
  *
  */
-void irlmp_link_disconnect_indication(struct lap_cb *lap, 
-                                     struct irlap_cb *irlap, 
-                                     LAP_REASON reason, 
+void irlmp_link_disconnect_indication(struct lap_cb *lap,
+                                     struct irlap_cb *irlap,
+                                     LAP_REASON reason,
                                      struct sk_buff *skb)
 {
        IRDA_DEBUG(2, "%s()\n", __FUNCTION__);
@@ -278,8 +278,8 @@ void irlmp_link_disconnect_indication(struct lap_cb *lap,
        lap->reason = reason;
        lap->daddr = DEV_ADDR_ANY;
 
-        /* FIXME: must do something with the skb if any */
-       
+       /* FIXME: must do something with the skb if any */
+
        /*
         *  Inform station state machine
         */
@@ -292,9 +292,9 @@ void irlmp_link_disconnect_indication(struct lap_cb *lap,
  *    Incoming LAP connection!
  *
  */
-void irlmp_link_connect_indication(struct lap_cb *self, __u32 saddr, 
+void irlmp_link_connect_indication(struct lap_cb *self, __u32 saddr,
                                   __u32 daddr, struct qos_info *qos,
-                                  struct sk_buff *skb) 
+                                  struct sk_buff *skb)
 {
        IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
 
@@ -314,7 +314,7 @@ void irlmp_link_connect_indication(struct lap_cb *self, __u32 saddr,
  *    LAP connection confirmed!
  *
  */
-void irlmp_link_connect_confirm(struct lap_cb *self, struct qos_info *qos, 
+void irlmp_link_connect_confirm(struct lap_cb *self, struct qos_info *qos,
                                struct sk_buff *skb)
 {
        IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
@@ -359,7 +359,7 @@ void irlmp_link_connect_confirm(struct lap_cb *self, struct qos_info *qos,
  *
  * Jean II
  */
-void irlmp_link_discovery_indication(struct lap_cb *self, 
+void irlmp_link_discovery_indication(struct lap_cb *self,
                                     discovery_t *discovery)
 {
        IRDA_ASSERT(self != NULL, return;);
@@ -367,7 +367,7 @@ void irlmp_link_discovery_indication(struct lap_cb *self,
 
        /* Add to main log, cleanup */
        irlmp_add_discovery(irlmp->cachelog, discovery);
-       
+
        /* Just handle it the same way as a discovery confirm,
         * bypass the LM_LAP state machine (see below) */
        irlmp_discovery_confirm(irlmp->cachelog, DISCOVERY_PASSIVE);
@@ -387,7 +387,7 @@ void irlmp_link_discovery_confirm(struct lap_cb *self, hashbin_t *log)
 
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == LMP_LAP_MAGIC, return;);
-       
+
        /* Add to main log, cleanup */
        irlmp_add_discovery_log(irlmp->cachelog, log);
 
@@ -420,7 +420,7 @@ static inline void irlmp_update_cache(struct lap_cb *lap,
  *    Find handle associated with destination and source LSAP
  *
  * Any IrDA connection (LSAP/TSAP) is uniquely identified by
- * 3 parameters, the local lsap, the remote lsap and the remote address. 
+ * 3 parameters, the local lsap, the remote lsap and the remote address.
  * We may initiate multiple connections to the same remote service
  * (they will have different local lsap), a remote device may initiate
  * multiple connections to the same local service (they will have
@@ -433,20 +433,20 @@ static inline void irlmp_update_cache(struct lap_cb *lap,
  */
 static struct lsap_cb *irlmp_find_lsap(struct lap_cb *self, __u8 dlsap_sel,
                                       __u8 slsap_sel, int status,
-                                      hashbin_t *queue) 
+                                      hashbin_t *queue)
 {
        struct lsap_cb *lsap;
        unsigned long flags;
-       
-       /* 
+
+       /*
         *  Optimize for the common case. We assume that the last frame
         *  received is in the same connection as the last one, so check in
         *  cache first to avoid the linear search
         */
 #ifdef CONFIG_IRDA_CACHE_LAST_LSAP
-       if ((self->cache.valid) && 
-           (self->cache.slsap_sel == slsap_sel) && 
-           (self->cache.dlsap_sel == dlsap_sel)) 
+       if ((self->cache.valid) &&
+           (self->cache.slsap_sel == slsap_sel) &&
+           (self->cache.dlsap_sel == dlsap_sel))
        {
                return (self->cache.lsap);
        }
@@ -456,14 +456,14 @@ static struct lsap_cb *irlmp_find_lsap(struct lap_cb *self, __u8 dlsap_sel,
 
        lsap = (struct lsap_cb *) hashbin_get_first(queue);
        while (lsap != NULL) {
-               /* 
-                *  If this is an incoming connection, then the destination 
-                *  LSAP selector may have been specified as LM_ANY so that 
+               /*
+                *  If this is an incoming connection, then the destination
+                *  LSAP selector may have been specified as LM_ANY so that
                 *  any client can connect. In that case we only need to check
                 *  if the source LSAP (in our view!) match!
                 */
-               if ((status == CONNECT_CMD) && 
-                   (lsap->slsap_sel == slsap_sel) &&      
+               if ((status == CONNECT_CMD) &&
+                   (lsap->slsap_sel == slsap_sel) &&
                    (lsap->dlsap_sel == LSAP_ANY)) {
                        /* This is where the dest lsap sel is set on incoming
                         * lsaps */
@@ -473,8 +473,8 @@ static struct lsap_cb *irlmp_find_lsap(struct lap_cb *self, __u8 dlsap_sel,
                /*
                 *  Check if source LSAP and dest LSAP selectors match.
                 */
-               if ((lsap->slsap_sel == slsap_sel) && 
-                   (lsap->dlsap_sel == dlsap_sel)) 
+               if ((lsap->slsap_sel == slsap_sel) &&
+                   (lsap->dlsap_sel == dlsap_sel))
                        break;
 
                lsap = (struct lsap_cb *) hashbin_get_next(queue);
index 2869b16e417d273ac9bdbe4b355ee2d35bb2c295..826e6c4ca5d510ab3e54e088eeef7f4c458bf3ee 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************************
- *                
+ *
  * Filename:      irmod.c
  * Version:       0.9
  * Description:   IrDA stack main entry points
@@ -8,19 +8,19 @@
  * Created at:    Mon Dec 15 13:55:39 1997
  * Modified at:   Wed Jan  5 15:12:41 2000
  * Modified by:   Dag Brattli <dagb@cs.uit.no>
- * 
+ *
  *     Copyright (c) 1997, 1999-2000 Dag Brattli, All Rights Reserved.
  *     Copyright (c) 2000-2004 Jean Tourrilhes <jt@hpl.hp.com>
- *      
- *     This program is free software; you can redistribute it and/or 
- *     modify it under the terms of the GNU General Public License as 
- *     published by the Free Software Foundation; either version 2 of 
+ *
+ *     This program is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU General Public License as
+ *     published by the Free Software Foundation; either version 2 of
  *     the License, or (at your option) any later version.
- *  
+ *
  *     Neither Dag Brattli nor University of Tromsø admit liability nor
- *     provide warranty for any of this software. This material is 
+ *     provide warranty for any of this software. This material is
  *     provided "AS-IS" and at no charge.
- *     
+ *
  ********************************************************************/
 
 /*
@@ -52,7 +52,7 @@ extern void irda_sysctl_unregister(void);
 extern int  irsock_init(void);
 extern void irsock_cleanup(void);
 /* irlap_frame.c */
-extern int  irlap_driver_rcv(struct sk_buff *, struct net_device *, 
+extern int  irlap_driver_rcv(struct sk_buff *, struct net_device *,
                             struct packet_type *, struct net_device *);
 
 /*
@@ -104,16 +104,16 @@ static int __init irda_init(void)
        IRDA_DEBUG(0, "%s()\n", __FUNCTION__);
 
        /* Lower layer of the stack */
-       irlmp_init();
+       irlmp_init();
        irlap_init();
-       
+
        /* Higher layers of the stack */
        iriap_init();
-       irttp_init();
+       irttp_init();
        irsock_init();
-       
+
        /* Add IrDA packet type (Start receiving packets) */
-        dev_add_pack(&irda_packet_type);
+       dev_add_pack(&irda_packet_type);
 
        /* External APIs */
 #ifdef CONFIG_PROC_FS
@@ -124,7 +124,7 @@ static int __init irda_init(void)
 #endif
 
        /* Driver/dongle support */
-       irda_device_init();
+       irda_device_init();
 
        return 0;
 }
@@ -140,14 +140,14 @@ static void __exit irda_cleanup(void)
        /* Remove External APIs */
 #ifdef CONFIG_SYSCTL
        irda_sysctl_unregister();
-#endif 
+#endif
 #ifdef CONFIG_PROC_FS
        irda_proc_unregister();
 #endif
 
        /* Remove IrDA packet type (stop receiving packets) */
-        dev_remove_pack(&irda_packet_type);
-       
+       dev_remove_pack(&irda_packet_type);
+
        /* Remove higher layers */
        irsock_cleanup();
        irttp_cleanup();
@@ -177,8 +177,8 @@ static void __exit irda_cleanup(void)
  */
 subsys_initcall(irda_init);
 module_exit(irda_cleanup);
+
 MODULE_AUTHOR("Dag Brattli <dagb@cs.uit.no> & Jean Tourrilhes <jt@hpl.hp.com>");
-MODULE_DESCRIPTION("The Linux IrDA Protocol Stack"); 
+MODULE_DESCRIPTION("The Linux IrDA Protocol Stack");
 MODULE_LICENSE("GPL");
 MODULE_ALIAS_NETPROTO(PF_IRDA);
index 80887528e77efeb4c9655758371f6b73ccdac376..873ae189e37af107b22b0cf7427de8ca1fcadba6 100644 (file)
@@ -44,7 +44,7 @@
  * the generic Linux PPP driver. Because IrNET depend on recent
  * changes of the PPP driver interface, IrNET will work only with very
  * recent kernel (2.3.99-pre6 and up).
- * 
+ *
  * The present implementation offer the following features :
  *     o simple user interface using pppd
  *     o efficient implementation (interface directly to PPP and IrTTP)
 
 #define DEBUG_ASSERT           0       /* Verify all assertions */
 
-/* 
+/*
  * These are the macros we are using to actually print the debug
  * statements. Don't look at it, it's ugly...
  *
index f65c7a83bc5cf95d3f5884ec9391a888b59e590f..c378e668af0c2e1cea690245c114d296c12b3da9 100644 (file)
@@ -118,7 +118,7 @@ irnet_open_tsap(irnet_socket *      self)
 
   /* Open an IrTTP instance */
   self->tsap = irttp_open_tsap(LSAP_ANY, DEFAULT_INITIAL_CREDIT,
-                              &notify);        
+                              &notify);
   DABORT(self->tsap == NULL, -ENOMEM,
         IRDA_SR_ERROR, "Unable to allocate TSAP !\n");
 
@@ -188,7 +188,7 @@ irnet_ias_to_tsap(irnet_socket *    self,
          if(value->t.integer != -1)
            /* Get the remote TSAP selector */
            dtsap_sel = value->t.integer;
-         else 
+         else
            self->errno = -EADDRNOTAVAIL;
          break;
        default:
@@ -280,8 +280,8 @@ irnet_connect_tsap(irnet_socket *   self)
     }
 
   /* Connect to remote device */
-  err = irttp_connect_request(self->tsap, self->dtsap_sel, 
-                             self->rsaddr, self->daddr, NULL, 
+  err = irttp_connect_request(self->tsap, self->dtsap_sel,
+                             self->rsaddr, self->daddr, NULL,
                              self->max_sdu_size_rx, NULL);
   if(err != 0)
     {
@@ -438,7 +438,7 @@ irnet_dname_to_daddr(irnet_socket * self)
   if(discoveries == NULL)
     DRETURN(-ENETUNREACH, IRDA_SR_INFO, "Cachelog empty...\n");
 
-  /* 
+  /*
    * Now, check all discovered devices (if any), and connect
    * client only about the services that the client is
    * interested in...
@@ -627,7 +627,7 @@ irda_irnet_destroy(irnet_socket *   self)
 
   /* Unregister with LM-IAS */
   if(self->iriap)
-    { 
+    {
       iriap_close(self->iriap);
       self->iriap = NULL;
     }
@@ -945,7 +945,7 @@ irnet_setup_server(void)
 
   /* Register with LM-IAS (so that people can connect to us) */
   irnet_server.ias_obj = irias_new_object(IRNET_SERVICE_NAME, jiffies);
-  irias_add_integer_attrib(irnet_server.ias_obj, IRNET_IAS_VALUE, 
+  irias_add_integer_attrib(irnet_server.ias_obj, IRNET_IAS_VALUE,
                           irnet_server.s.stsap_sel, IAS_KERNEL_ATTR);
   irias_insert_object(irnet_server.ias_obj);
 
@@ -1076,7 +1076,7 @@ irnet_data_indication(void *      instance,
  */
 static void
 irnet_disconnect_indication(void *     instance,
-                           void *      sap, 
+                           void *      sap,
                            LM_REASON   reason,
                            struct sk_buff *skb)
 {
@@ -1166,10 +1166,10 @@ irnet_disconnect_indication(void *      instance,
  */
 static void
 irnet_connect_confirm(void *   instance,
-                     void *    sap, 
+                     void *    sap,
                      struct qos_info *qos,
                      __u32     max_sdu_size,
-                     __u8      max_header_size, 
+                     __u8      max_header_size,
                      struct sk_buff *skb)
 {
   irnet_socket *       self = (irnet_socket *) instance;
@@ -1235,7 +1235,7 @@ irnet_connect_confirm(void *      instance,
 static void
 irnet_flow_indication(void *   instance,
                      void *    sap,
-                     LOCAL_FLOW flow) 
+                     LOCAL_FLOW flow)
 {
   irnet_socket *       self = (irnet_socket *) instance;
   LOCAL_FLOW           oldflow = self->tx_flow;
@@ -1308,13 +1308,13 @@ irnet_status_indication(void *  instance,
  * Some other node is attempting to connect to the IrNET service, and has
  * sent a connection request on our server socket.
  * We just redirect the connection to the relevant IrNET socket.
- * 
+ *
  * Note : we also make sure that between 2 irnet nodes, there can
  * exist only one irnet connection.
  */
 static void
 irnet_connect_indication(void *                instance,
-                        void *         sap, 
+                        void *         sap,
                         struct qos_info *qos,
                         __u32          max_sdu_size,
                         __u8           max_header_size,
@@ -1463,7 +1463,7 @@ irnet_connect_indication(void *           instance,
  */
 static void
 irnet_getvalue_confirm(int     result,
-                      __u16    obj_id, 
+                      __u16    obj_id,
                       struct ias_value *value,
                       void *   priv)
 {
@@ -1526,7 +1526,7 @@ irnet_getvalue_confirm(int        result,
  */
 static void
 irnet_discovervalue_confirm(int                result,
-                           __u16       obj_id, 
+                           __u16       obj_id,
                            struct ias_value *value,
                            void *      priv)
 {
@@ -1645,7 +1645,7 @@ irnet_discovery_indication(discinfo_t *           discovery,
                           void *               priv)
 {
   irnet_socket *       self = &irnet_server.s;
-       
+
   DENTER(IRDA_OCB_TRACE, "(self=0x%p)\n", self);
   DASSERT(priv == &irnet_server, , IRDA_OCB_ERROR,
          "Invalid instance (0x%p) !!!\n", priv);
@@ -1676,7 +1676,7 @@ irnet_expiry_indication(discinfo_t *      expiry,
                        void *          priv)
 {
   irnet_socket *       self = &irnet_server.s;
-       
+
   DENTER(IRDA_OCB_TRACE, "(self=0x%p)\n", self);
   DASSERT(priv == &irnet_server, , IRDA_OCB_ERROR,
          "Invalid instance (0x%p) !!!\n", priv);
@@ -1718,7 +1718,7 @@ irnet_proc_read(char *    buf,
   int                  i = 0;
 
   len = 0;
-       
+
   /* Get the IrNET server information... */
   len += sprintf(buf+len, "IrNET server - ");
   len += sprintf(buf+len, "IrDA state: %s, ",
@@ -1811,7 +1811,7 @@ irda_irnet_init(void)
   memset(&irnet_server, 0, sizeof(struct irnet_root));
 
   /* Setup start of irnet instance list */
-  irnet_server.list = hashbin_new(HB_NOLOCK); 
+  irnet_server.list = hashbin_new(HB_NOLOCK);
   DABORT(irnet_server.list == NULL, -ENOMEM,
         MODULE_ERROR, "Can't allocate hashbin!\n");
   /* Init spinlock for instance list */
index f2fecd32d8f6469dabedf96ecbd049baee895c2d..0ba92d0d52040e6c142dd7a1184d6cb44e87dde7 100644 (file)
@@ -146,7 +146,7 @@ static void
                               void *);
 static void
        irnet_discovervalue_confirm(int,
-                                   __u16, 
+                                   __u16,
                                    struct ias_value *,
                                    void *);
 #ifdef DISCOVERY_EVENTS
index a1e502ff90709a0e98b1da34e48e88eee7bd019c..2f9f8dce5a6946b1f72772b05f30eeaf550b4691 100644 (file)
@@ -93,7 +93,7 @@ irnet_ctrl_write(irnet_socket *       ap,
 
       /* Check if we recognised one of the known command
        * We can't use "switch" with strings, so hack with "continue" */
-      
+
       /* First command : name -> Requested IrDA nickname */
       if(!strncmp(start, "name", 4))
        {
@@ -744,7 +744,7 @@ dev_irnet_ioctl(struct inode *      inode,
       break;
 
       /* Set DTR/RTS */
-    case TIOCMBIS: 
+    case TIOCMBIS:
     case TIOCMBIC:
       /* Set exclusive/non-exclusive mode */
     case TIOCEXCL:
@@ -941,7 +941,7 @@ ppp_irnet_send(struct ppp_channel * chan,
   ret = irttp_data_request(self->tsap, skb);
   if(ret < 0)
     {
-      /*   
+      /*
        * > IrTTPs tx queue is full, so we just have to
        * > drop the frame! You might think that we should
        * > just return -1 and don't deallocate the frame,
@@ -949,7 +949,7 @@ ppp_irnet_send(struct ppp_channel * chan,
        * > we have replaced the original skb with a new
        * > one with larger headroom, and that would really
        * > confuse do_dev_queue_xmit() in dev.c! I have
-       * > tried :-) DB 
+       * > tried :-) DB
        * Correction : we verify the flow control above (self->tx_flow),
        * so we come here only if IrTTP doesn't like the packet (empty,
        * too large, IrTTP not connected). In those rare cases, it's ok
@@ -1136,6 +1136,6 @@ irnet_cleanup(void)
 module_init(irnet_init);
 module_exit(irnet_cleanup);
 MODULE_AUTHOR("Jean Tourrilhes <jt@hpl.hp.com>");
-MODULE_DESCRIPTION("IrNET : Synchronous PPP over IrDA"); 
+MODULE_DESCRIPTION("IrNET : Synchronous PPP over IrDA");
 MODULE_LICENSE("GPL");
 MODULE_ALIAS_CHARDEV(10, 187);
index 88b9c43f637082fffa3f07c76d975ce34e0d7799..d6f9aba5b9dc1de454e058d4bb037ef0e56445cf 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************************
- *                
+ *
  * Filename:      irproc.c
  * Version:       1.0
  * Description:   Various entries in the /proc file system
  * Modified by:   Dag Brattli <dagb@cs.uit.no>
  *
  *     Copyright (c) 1998-1999, Dag Brattli <dagb@cs.uit.no>
- *     Copyright (c) 1998, Thomas Davis, <ratbert@radiks.net>, 
+ *     Copyright (c) 1998, Thomas Davis, <ratbert@radiks.net>,
  *     All Rights Reserved.
- *      
- *     This program is free software; you can redistribute it and/or 
- *     modify it under the terms of the GNU General Public License as 
- *     published by the Free Software Foundation; either version 2 of 
+ *
+ *     This program is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU General Public License as
+ *     published by the Free Software Foundation; either version 2 of
  *     the License, or (at your option) any later version.
- *  
- *     I, Thomas Davis, provide no warranty for any of this software. 
- *     This material is provided "AS-IS" and at no charge. 
- *     
+ *
+ *     I, Thomas Davis, provide no warranty for any of this software.
+ *     This material is provided "AS-IS" and at no charge.
+ *
  ********************************************************************/
 
 #include <linux/miscdevice.h>
@@ -46,7 +46,7 @@ struct irda_entry {
 
 struct proc_dir_entry *proc_irda;
 EXPORT_SYMBOL(proc_irda);
+
 static struct irda_entry irda_dirs[] = {
        {"discovery",   &discovery_seq_fops},
        {"irttp",       &irttp_seq_fops},
@@ -61,7 +61,7 @@ static struct irda_entry irda_dirs[] = {
  *    Register irda entry in /proc file system
  *
  */
-void __init irda_proc_register(void) 
+void __init irda_proc_register(void)
 {
        int i;
        struct proc_dir_entry *d;
@@ -73,7 +73,7 @@ void __init irda_proc_register(void)
 
        for (i=0; i<ARRAY_SIZE(irda_dirs); i++) {
                d = create_proc_entry(irda_dirs[i].name, 0, proc_irda);
-               if (d) 
+               if (d)
                        d->proc_fops = irda_dirs[i].fops;
        }
 }
@@ -84,17 +84,17 @@ void __init irda_proc_register(void)
  *    Unregister irda entry in /proc file system
  *
  */
-void __exit irda_proc_unregister(void) 
+void __exit irda_proc_unregister(void)
 {
        int i;
 
-        if (proc_irda) {
-                for (i=0; i<ARRAY_SIZE(irda_dirs); i++)
-                        remove_proc_entry(irda_dirs[i].name, proc_irda);
+       if (proc_irda) {
+               for (i=0; i<ARRAY_SIZE(irda_dirs); i++)
+                       remove_proc_entry(irda_dirs[i].name, proc_irda);
 
-                remove_proc_entry("irda", proc_net);
-                proc_irda = NULL;
-        }
+               remove_proc_entry("irda", proc_net);
+               proc_irda = NULL;
+       }
 }
 
 
index 1d26cd33ea13af07bbc22e53df6ce54c02f3e759..92662330dbcf0aee2bf1b7e0fc557ef36a64895e 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************************
- *                
+ *
  * Filename:      irqueue.c
  * Version:       0.3
  * Description:   General queue implementation
  * Modified by:   Dag Brattli <dagb@cs.uit.no>
  * Modified at:   Thu Jan  4 14:29:10 CET 2001
  * Modified by:   Marc Zyngier <mzyngier@freesurf.fr>
- * 
+ *
  *     Copyright (C) 1998-1999, Aage Kvalnes <aage@cs.uit.no>
- *     Copyright (C) 1998, Dag Brattli, 
+ *     Copyright (C) 1998, Dag Brattli,
  *     All Rights Reserved.
  *
  *     This code is taken from the Vortex Operating System written by Aage
  *     Kvalnes. Aage has agreed that this code can use the GPL licence,
  *     although he does not use that licence in his own code.
- *     
+ *
  *     This copyright does however _not_ include the ELF hash() function
  *     which I currently don't know which licence or copyright it
  *     has. Please inform me if you know.
- *      
- *     This program is free software; you can redistribute it and/or 
- *     modify it under the terms of the GNU General Public License as 
- *     published by the Free Software Foundation; either version 2 of 
+ *
+ *     This program is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU General Public License as
+ *     published by the Free Software Foundation; either version 2 of
  *     the License, or (at your option) any later version.
- *  
+ *
  *     Neither Dag Brattli nor University of Tromsø admit liability nor
- *     provide warranty for any of this software. This material is 
+ *     provide warranty for any of this software. This material is
  *     provided "AS-IS" and at no charge.
- *     
+ *
  ********************************************************************/
 
 /*
@@ -213,7 +213,7 @@ static __u32 hash( const char* name)
 {
        __u32 h = 0;
        __u32 g;
-       
+
        while(*name) {
                h = (h<<4) + *name++;
                if ((g = (h & 0xf0000000)))
@@ -231,7 +231,7 @@ static __u32 hash( const char* name)
  */
 static void enqueue_first(irda_queue_t **queue, irda_queue_t* element)
 {
-       
+
        IRDA_DEBUG( 4, "%s()\n", __FUNCTION__);
 
        /*
@@ -242,7 +242,7 @@ static void enqueue_first(irda_queue_t **queue, irda_queue_t* element)
                 * Queue is empty.  Insert one element into the queue.
                 */
                element->q_next = element->q_prev = *queue = element;
-               
+
        } else {
                /*
                 * Queue is not empty.  Insert element into front of queue.
@@ -267,20 +267,20 @@ static irda_queue_t *dequeue_first(irda_queue_t **queue)
        irda_queue_t *ret;
 
        IRDA_DEBUG( 4, "dequeue_first()\n");
-       
+
        /*
         * Set return value
         */
        ret =  *queue;
-       
+
        if ( *queue == NULL ) {
                /*
                 * Queue was empty.
                 */
        } else if ( (*queue)->q_next == *queue ) {
-               /* 
+               /*
                 *  Queue only contained a single element. It will now be
-                *  empty.  
+                *  empty.
                 */
                *queue = NULL;
        } else {
@@ -291,7 +291,7 @@ static irda_queue_t *dequeue_first(irda_queue_t **queue)
                (*queue)->q_next->q_prev = (*queue)->q_prev;
                *queue = (*queue)->q_next;
        }
-       
+
        /*
         * Return the removed entry (or NULL of queue was empty).
         */
@@ -306,25 +306,25 @@ static irda_queue_t *dequeue_first(irda_queue_t **queue)
 static irda_queue_t *dequeue_general(irda_queue_t **queue, irda_queue_t* element)
 {
        irda_queue_t *ret;
-       
+
        IRDA_DEBUG( 4, "dequeue_general()\n");
-       
+
        /*
         * Set return value
         */
        ret =  *queue;
-               
+
        if ( *queue == NULL ) {
                /*
                 * Queue was empty.
                 */
        } else if ( (*queue)->q_next == *queue ) {
-               /* 
+               /*
                 *  Queue only contained a single element. It will now be
-                *  empty.  
+                *  empty.
                 */
                *queue = NULL;
-               
+
        } else {
                /*
                 *  Remove specific element.
@@ -334,7 +334,7 @@ static irda_queue_t *dequeue_general(irda_queue_t **queue, irda_queue_t* element
                if ( (*queue) == element)
                        (*queue) = element->q_next;
        }
-       
+
        /*
         * Return the removed entry (or NULL of queue was empty).
         */
@@ -352,7 +352,7 @@ static irda_queue_t *dequeue_general(irda_queue_t **queue, irda_queue_t* element
 hashbin_t *hashbin_new(int type)
 {
        hashbin_t* hashbin;
-       
+
        /*
         * Allocate new hashbin
         */
@@ -380,8 +380,8 @@ EXPORT_SYMBOL(hashbin_new);
 /*
  * Function hashbin_delete (hashbin, free_func)
  *
- *    Destroy hashbin, the free_func can be a user supplied special routine 
- *    for deallocating this structure if it's complex. If not the user can 
+ *    Destroy hashbin, the free_func can be a user supplied special routine
+ *    for deallocating this structure if it's complex. If not the user can
  *    just supply kfree, which should take care of the job.
  */
 int hashbin_delete( hashbin_t* hashbin, FREE_FUNC free_func)
@@ -392,7 +392,7 @@ int hashbin_delete( hashbin_t* hashbin, FREE_FUNC free_func)
 
        IRDA_ASSERT(hashbin != NULL, return -1;);
        IRDA_ASSERT(hashbin->magic == HB_MAGIC, return -1;);
-       
+
        /* Synchronize */
        if ( hashbin->hb_type & HB_LOCK ) {
                spin_lock_irqsave(&hashbin->hb_spinlock, flags);
@@ -407,11 +407,11 @@ int hashbin_delete( hashbin_t* hashbin, FREE_FUNC free_func)
                while (queue ) {
                        if (free_func)
                                (*free_func)(queue);
-                       queue = dequeue_first( 
+                       queue = dequeue_first(
                                (irda_queue_t**) &hashbin->hb_queue[i]);
                }
        }
-       
+
        /* Cleanup local data */
        hashbin->hb_current = NULL;
        hashbin->magic = ~HB_MAGIC;
@@ -438,7 +438,7 @@ EXPORT_SYMBOL(hashbin_delete);
  *    Insert an entry into the hashbin
  *
  */
-void hashbin_insert(hashbin_t* hashbin, irda_queue_t* entry, long hashv, 
+void hashbin_insert(hashbin_t* hashbin, irda_queue_t* entry, long hashv,
                    const char* name)
 {
        unsigned long flags = 0;
@@ -460,14 +460,14 @@ void hashbin_insert(hashbin_t* hashbin, irda_queue_t* entry, long hashv,
        if ( hashbin->hb_type & HB_LOCK ) {
                spin_lock_irqsave(&hashbin->hb_spinlock, flags);
        } /* Default is no-lock  */
-       
+
        /*
         * Store name and key
         */
        entry->q_hash = hashv;
        if ( name )
                strlcpy( entry->q_name, name, sizeof(entry->q_name));
-       
+
        /*
         * Insert new entry first
         */
@@ -482,7 +482,7 @@ void hashbin_insert(hashbin_t* hashbin, irda_queue_t* entry, long hashv,
 }
 EXPORT_SYMBOL(hashbin_insert);
 
-/* 
+/*
  *  Function hashbin_remove_first (hashbin)
  *
  *    Remove first entry of the hashbin
@@ -537,7 +537,7 @@ void *hashbin_remove_first( hashbin_t *hashbin)
 }
 
 
-/* 
+/*
  *  Function hashbin_remove (hashbin, hashv, name)
  *
  *    Remove entry with the given name
@@ -561,7 +561,7 @@ void* hashbin_remove( hashbin_t* hashbin, long hashv, const char* name)
 
        IRDA_ASSERT( hashbin != NULL, return NULL;);
        IRDA_ASSERT( hashbin->magic == HB_MAGIC, return NULL;);
-       
+
        /*
         * Locate hashbin
         */
@@ -601,7 +601,7 @@ void* hashbin_remove( hashbin_t* hashbin, long hashv, const char* name)
                        entry = entry->q_next;
                } while ( entry != hashbin->hb_queue[ bin ] );
        }
-       
+
        /*
         * If entry was found, dequeue it
         */
@@ -622,18 +622,18 @@ void* hashbin_remove( hashbin_t* hashbin, long hashv, const char* name)
        if ( hashbin->hb_type & HB_LOCK ) {
                spin_unlock_irqrestore(&hashbin->hb_spinlock, flags);
        } /* Default is no-lock  */
-       
-       
+
+
        /* Return */
-       if ( found ) 
+       if ( found )
                return entry;
        else
                return NULL;
-       
+
 }
 EXPORT_SYMBOL(hashbin_remove);
 
-/* 
+/*
  *  Function hashbin_remove_this (hashbin, entry)
  *
  *    Remove entry with the given name
@@ -655,7 +655,7 @@ void* hashbin_remove_this( hashbin_t* hashbin, irda_queue_t* entry)
        IRDA_ASSERT( hashbin != NULL, return NULL;);
        IRDA_ASSERT( hashbin->magic == HB_MAGIC, return NULL;);
        IRDA_ASSERT( entry != NULL, return NULL;);
-       
+
        /* Synchronize */
        if ( hashbin->hb_type & HB_LOCK ) {
                spin_lock_irqsave(&hashbin->hb_spinlock, flags);
@@ -722,7 +722,7 @@ void* hashbin_find( hashbin_t* hashbin, long hashv, const char* name )
        if ( name )
                hashv = hash( name );
        bin = GET_HASHBIN( hashv );
-       
+
        /*
         * Search for entry
         */
@@ -829,7 +829,7 @@ void* hashbin_find_next( hashbin_t* hashbin, long hashv, const char* name,
  *    called before any calls to hashbin_get_next()!
  *
  */
-irda_queue_t *hashbin_get_first( hashbin_t* hashbin) 
+irda_queue_t *hashbin_get_first( hashbin_t* hashbin)
 {
        irda_queue_t *entry;
        int i;
@@ -860,7 +860,7 @@ EXPORT_SYMBOL(hashbin_get_first);
  *    Get next item in hashbin. A series of hashbin_get_next() calls must
  *    be started by a call to hashbin_get_first(). The function returns
  *    NULL when all items have been traversed
- * 
+ *
  * The context of the search is stored within the hashbin, so you must
  * protect yourself from concurrent enumerations. - Jean II
  */
@@ -876,13 +876,13 @@ irda_queue_t *hashbin_get_next( hashbin_t *hashbin)
        if ( hashbin->hb_current == NULL) {
                IRDA_ASSERT( hashbin->hb_current != NULL, return NULL;);
                return NULL;
-       }       
+       }
        entry = hashbin->hb_current->q_next;
        bin = GET_HASHBIN( entry->q_hash);
 
-       /*  
+       /*
         *  Make sure that we are not back at the beginning of the queue
-        *  again 
+        *  again
         */
        if ( entry != hashbin->hb_queue[ bin ]) {
                hashbin->hb_current = entry;
@@ -895,7 +895,7 @@ irda_queue_t *hashbin_get_next( hashbin_t *hashbin)
         */
        if ( bin >= HASHBIN_SIZE)
                return NULL;
-       
+
        /*
         *  Move to next queue in hashbin
         */
@@ -904,7 +904,7 @@ irda_queue_t *hashbin_get_next( hashbin_t *hashbin)
                entry = hashbin->hb_queue[ i];
                if ( entry) {
                        hashbin->hb_current = entry;
-                       
+
                        return entry;
                }
        }
index 86805c3d8324a0d6ae158292e55139d110ec9920..bb53ba0be585e0f75572d9d9861c6491c23d9a3c 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************************
- *                
+ *
  * Filename:      irsysctl.c
  * Version:       1.0
  * Description:   Sysctl interface for IrDA
@@ -8,19 +8,19 @@
  * Created at:    Sun May 24 22:12:06 1998
  * Modified at:   Fri Jun  4 02:50:15 1999
  * Modified by:   Dag Brattli <dagb@cs.uit.no>
- * 
+ *
  *     Copyright (c) 1997, 1999 Dag Brattli, All Rights Reserved.
  *     Copyright (c) 2000-2001 Jean Tourrilhes <jt@hpl.hp.com>
- *      
- *     This program is free software; you can redistribute it and/or 
- *     modify it under the terms of the GNU General Public License as 
- *     published by the Free Software Foundation; either version 2 of 
+ *
+ *     This program is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU General Public License as
+ *     published by the Free Software Foundation; either version 2 of
  *     the License, or (at your option) any later version.
- *  
+ *
  *     Neither Dag Brattli nor University of Tromsø admit liability nor
- *     provide warranty for any of this software. This material is 
+ *     provide warranty for any of this software. This material is
  *     provided "AS-IS" and at no charge.
- *     
+ *
  ********************************************************************/
 
 #include <linux/mm.h>
@@ -111,7 +111,7 @@ static ctl_table irda_table[] = {
                .strategy       = &sysctl_string
        },
 #ifdef CONFIG_IRDA_DEBUG
-        {
+       {
                .ctl_name       = DEBUG,
                .procname       = "debug",
                .data           = &irda_debug,
@@ -121,7 +121,7 @@ static ctl_table irda_table[] = {
        },
 #endif
 #ifdef CONFIG_IRDA_FAST_RR
-        {
+       {
                .ctl_name       = FAST_POLL,
                .procname       = "fast_poll_increase",
                .data           = &sysctl_fast_poll_increase,
@@ -287,7 +287,7 @@ int __init irda_sysctl_register(void)
  *    Unregister our sysctl interface
  *
  */
-void __exit irda_sysctl_unregister(void) 
+void __exit irda_sysctl_unregister(void)
 {
        unregister_sysctl_table(irda_table_header);
 }
index 03504f3e4990cb82bb8592845d79c7525d172b09..68836358fdf2ff2fc2db2725745d26fe3d2544cc 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************************
- *                
+ *
  * Filename:      irttp.c
  * Version:       1.2
  * Description:   Tiny Transport Protocol (TTP) implementation
@@ -8,18 +8,18 @@
  * Created at:    Sun Aug 31 20:14:31 1997
  * Modified at:   Wed Jan  5 11:31:27 2000
  * Modified by:   Dag Brattli <dagb@cs.uit.no>
- * 
- *     Copyright (c) 1998-2000 Dag Brattli <dagb@cs.uit.no>, 
+ *
+ *     Copyright (c) 1998-2000 Dag Brattli <dagb@cs.uit.no>,
  *     All Rights Reserved.
  *     Copyright (c) 2000-2003 Jean Tourrilhes <jt@hpl.hp.com>
- *     
- *     This program is free software; you can redistribute it and/or 
- *     modify it under the terms of the GNU General Public License as 
- *     published by the Free Software Foundation; either version 2 of 
+ *
+ *     This program is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU General Public License as
+ *     published by the Free Software Foundation; either version 2 of
  *     the License, or (at your option) any later version.
  *
  *     Neither Dag Brattli nor University of Tromsø admit liability nor
- *     provide warranty for any of this software. This material is 
+ *     provide warranty for any of this software. This material is
  *     provided "AS-IS" and at no charge.
  *
  ********************************************************************/
@@ -42,17 +42,17 @@ static struct irttp_cb *irttp;
 
 static void __irttp_close_tsap(struct tsap_cb *self);
 
-static int irttp_data_indication(void *instance, void *sap, 
+static int irttp_data_indication(void *instance, void *sap,
                                 struct sk_buff *skb);
-static int irttp_udata_indication(void *instance, void *sap, 
+static int irttp_udata_indication(void *instance, void *sap,
                                  struct sk_buff *skb);
-static void irttp_disconnect_indication(void *instance, void *sap,  
+static void irttp_disconnect_indication(void *instance, void *sap,
                                        LM_REASON reason, struct sk_buff *);
-static void irttp_connect_indication(void *instance, void *sap, 
+static void irttp_connect_indication(void *instance, void *sap,
                                     struct qos_info *qos, __u32 max_sdu_size,
                                     __u8 header_size, struct sk_buff *skb);
-static void irttp_connect_confirm(void *instance, void *sap, 
-                                 struct qos_info *qos, __u32 max_sdu_size, 
+static void irttp_connect_confirm(void *instance, void *sap,
+                                 struct qos_info *qos, __u32 max_sdu_size,
                                  __u8 header_size, struct sk_buff *skb);
 static void irttp_run_tx_queue(struct tsap_cb *self);
 static void irttp_run_rx_queue(struct tsap_cb *self);
@@ -61,7 +61,7 @@ static void irttp_flush_queues(struct tsap_cb *self);
 static void irttp_fragment_skb(struct tsap_cb *self, struct sk_buff *skb);
 static struct sk_buff *irttp_reassemble_skb(struct tsap_cb *self);
 static void irttp_todo_expired(unsigned long data);
-static int irttp_param_max_sdu_size(void *instance, irda_param_t *param, 
+static int irttp_param_max_sdu_size(void *instance, irda_param_t *param,
                                    int get);
 
 static void irttp_flow_indication(void *instance, void *sap, LOCAL_FLOW flow);
@@ -109,7 +109,7 @@ int __init irttp_init(void)
  *    Called by module destruction/cleanup code
  *
  */
-void __exit irttp_cleanup(void) 
+void __exit irttp_cleanup(void)
 {
        /* Check for main structure */
        IRDA_ASSERT(irttp->magic == TTP_MAGIC, return;);
@@ -865,7 +865,7 @@ static int irttp_udata_indication(void *instance, void *sap,
                err = self->notify.udata_indication(self->notify.instance,
                                                    self,skb);
                /* Same comment as in irttp_do_data_indication() */
-               if (!err) 
+               if (!err)
                        return 0;
        }
        /* Either no handler, or handler returns an error */
@@ -940,7 +940,7 @@ static int irttp_data_indication(void *instance, void *sap,
 
        /*
         * If the peer device has given us some credits and we didn't have
-         * anyone from before, then we need to shedule the tx queue.
+        * anyone from before, then we need to shedule the tx queue.
         * We need to do that because our Tx have stopped (so we may not
         * get any LAP flow indication) and the user may be stopped as
         * well. - Jean II
@@ -1798,14 +1798,14 @@ static void *irttp_seq_start(struct seq_file *seq, loff_t *pos)
        spin_lock_irq(&irttp->tsaps->hb_spinlock);
        iter->id = 0;
 
-       for (self = (struct tsap_cb *) hashbin_get_first(irttp->tsaps); 
+       for (self = (struct tsap_cb *) hashbin_get_first(irttp->tsaps);
             self != NULL;
             self = (struct tsap_cb *) hashbin_get_next(irttp->tsaps)) {
                if (iter->id == *pos)
                        break;
                ++iter->id;
        }
-               
+
        return self;
 }
 
index 1324942f976c25056d95d985b408886ba9f45d34..75a72d203b01c785cd6dd70c59363f87e25a813b 100644 (file)
@@ -563,7 +563,7 @@ static int irda_param_extract(void *self, __u8 *buf, int len,
  *    safe. Returns the number of bytes that was parsed
  *
  */
-int irda_param_extract_all(void *self, __u8 *buf, int len, 
+int irda_param_extract_all(void *self, __u8 *buf, int len,
                           pi_param_info_t *info)
 {
        int ret = -1;
index 95a69c013ee84205f105d052ed74e8840c1e8d84..349012c926b704aa6ce28a645090ccd1413f3d0f 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************************
- *                                
+ *
  * Filename:      qos.c
  * Version:       1.0
  * Description:   IrLAP QoS parameter negotiation
@@ -8,26 +8,26 @@
  * Created at:    Tue Sep  9 00:00:26 1997
  * Modified at:   Sun Jan 30 14:29:16 2000
  * Modified by:   Dag Brattli <dagb@cs.uit.no>
- * 
- *     Copyright (c) 1998-2000 Dag Brattli <dagb@cs.uit.no>, 
+ *
+ *     Copyright (c) 1998-2000 Dag Brattli <dagb@cs.uit.no>,
  *     All Rights Reserved.
  *     Copyright (c) 2000-2001 Jean Tourrilhes <jt@hpl.hp.com>
- *     
- *     This program is free software; you can redistribute it and/or 
- *     modify it under the terms of the GNU General Public License as 
- *     published by the Free Software Foundation; either version 2 of 
+ *
+ *     This program is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU General Public License as
+ *     published by the Free Software Foundation; either version 2 of
  *     the License, or (at your option) any later version.
- * 
+ *
  *     This program is distributed in the hope that it will be useful,
  *     but WITHOUT ANY WARRANTY; without even the implied warranty of
  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  *     GNU General Public License for more details.
- * 
- *     You should have received a copy of the GNU General Public License 
- *     along with this program; if not, write to the Free Software 
- *     Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
+ *
+ *     You should have received a copy of the GNU General Public License
+ *     along with this program; if not, write to the Free Software
+ *     Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  *     MA 02111-1307 USA
- *     
+ *
  ********************************************************************/
 
 #include <asm/byteorder.h>
@@ -84,16 +84,16 @@ unsigned sysctl_max_tx_data_size = 2042;
 unsigned sysctl_max_tx_window = 7;
 
 static int irlap_param_baud_rate(void *instance, irda_param_t *param, int get);
-static int irlap_param_link_disconnect(void *instance, irda_param_t *parm, 
+static int irlap_param_link_disconnect(void *instance, irda_param_t *parm,
                                       int get);
-static int irlap_param_max_turn_time(void *instance, irda_param_t *param, 
+static int irlap_param_max_turn_time(void *instance, irda_param_t *param,
                                     int get);
 static int irlap_param_data_size(void *instance, irda_param_t *param, int get);
-static int irlap_param_window_size(void *instance, irda_param_t *param, 
+static int irlap_param_window_size(void *instance, irda_param_t *param,
                                   int get);
-static int irlap_param_additional_bofs(void *instance, irda_param_t *parm, 
+static int irlap_param_additional_bofs(void *instance, irda_param_t *parm,
                                       int get);
-static int irlap_param_min_turn_time(void *instance, irda_param_t *param, 
+static int irlap_param_min_turn_time(void *instance, irda_param_t *param,
                                     int get);
 
 #ifndef CONFIG_IRDA_DYNAMIC_WINDOW
@@ -101,7 +101,7 @@ static __u32 irlap_requested_line_capacity(struct qos_info *qos);
 #endif
 
 static __u32 min_turn_times[]  = { 10000, 5000, 1000, 500, 100, 50, 10, 0 }; /* us */
-static __u32 baud_rates[]      = { 2400, 9600, 19200, 38400, 57600, 115200, 576000, 
+static __u32 baud_rates[]      = { 2400, 9600, 19200, 38400, 57600, 115200, 576000,
                                   1152000, 4000000, 16000000 };           /* bps */
 static __u32 data_sizes[]      = { 64, 128, 256, 512, 1024, 2048 };        /* bytes */
 static __u32 add_bofs[]        = { 48, 24, 12, 5, 3, 2, 1, 0 };            /* bytes */
@@ -165,7 +165,7 @@ static pi_param_info_t irlap_param_info = { pi_major_call_table, 2, 0x7f, 7 };
 static inline int value_index(__u32 value, __u32 *array, int size)
 {
        int i;
-       
+
        for (i=0; i < size; i++)
                if (array[i] == value)
                        break;
@@ -178,7 +178,7 @@ static inline int value_index(__u32 value, __u32 *array, int size)
  *    Returns value to index in array, easy!
  *
  */
-static inline __u32 index_value(int index, __u32 *array) 
+static inline __u32 index_value(int index, __u32 *array)
 {
        return array[index];
 }
@@ -189,7 +189,7 @@ static inline __u32 index_value(int index, __u32 *array)
  *    Returns index to most significant bit (MSB) in word
  *
  */
-static int msb_index (__u16 word) 
+static int msb_index (__u16 word)
 {
        __u16 msb = 0x8000;
        int index = 15;   /* Current MSB */
@@ -298,12 +298,12 @@ void irda_qos_compute_intersection(struct qos_info *qos, struct qos_info *new)
  *
  *    The purpose of this function is for layers and drivers to be able to
  *    set the maximum QoS possible and then "and in" their own limitations
- * 
+ *
  */
 void irda_init_max_qos_capabilies(struct qos_info *qos)
 {
        int i;
-       /* 
+       /*
         *  These are the maximum supported values as specified on pages
         *  39-43 in IrLAP
         */
@@ -361,25 +361,25 @@ static void irlap_adjust_qos_settings(struct qos_info *qos)
                qos->min_turn_time.value = sysctl_min_tx_turn_time;
        }
 
-       /* 
+       /*
         * Not allowed to use a max turn time less than 500 ms if the baudrate
         * is less than 115200
         */
-       if ((qos->baud_rate.value < 115200) && 
+       if ((qos->baud_rate.value < 115200) &&
            (qos->max_turn_time.value < 500))
        {
-               IRDA_DEBUG(0, 
+               IRDA_DEBUG(0,
                           "%s(), adjusting max turn time from %d to 500 ms\n",
                           __FUNCTION__, qos->max_turn_time.value);
                qos->max_turn_time.value = 500;
        }
-       
+
        /*
-        * The data size must be adjusted according to the baud rate and max 
+        * The data size must be adjusted according to the baud rate and max
         * turn time
         */
        index = value_index(qos->data_size.value, data_sizes, 6);
-       line_capacity = irlap_max_line_capacity(qos->baud_rate.value, 
+       line_capacity = irlap_max_line_capacity(qos->baud_rate.value,
                                                qos->max_turn_time.value);
 
 #ifdef CONFIG_IRDA_DYNAMIC_WINDOW
@@ -427,32 +427,32 @@ static void irlap_adjust_qos_settings(struct qos_info *qos)
  *    We just set the QoS capabilities for the peer station
  *
  */
-int irlap_qos_negotiate(struct irlap_cb *self, struct sk_buff *skb) 
+int irlap_qos_negotiate(struct irlap_cb *self, struct sk_buff *skb)
 {
        int ret;
-       
-       ret = irda_param_extract_all(self, skb->data, skb->len, 
+
+       ret = irda_param_extract_all(self, skb->data, skb->len,
                                     &irlap_param_info);
-       
+
        /* Convert the negotiated bits to values */
        irda_qos_bits_to_value(&self->qos_tx);
        irda_qos_bits_to_value(&self->qos_rx);
 
        irlap_adjust_qos_settings(&self->qos_tx);
 
-       IRDA_DEBUG(2, "Setting BAUD_RATE to %d bps.\n", 
+       IRDA_DEBUG(2, "Setting BAUD_RATE to %d bps.\n",
                   self->qos_tx.baud_rate.value);
        IRDA_DEBUG(2, "Setting DATA_SIZE to %d bytes\n",
                   self->qos_tx.data_size.value);
-       IRDA_DEBUG(2, "Setting WINDOW_SIZE to %d\n", 
+       IRDA_DEBUG(2, "Setting WINDOW_SIZE to %d\n",
                   self->qos_tx.window_size.value);
-       IRDA_DEBUG(2, "Setting XBOFS to %d\n", 
+       IRDA_DEBUG(2, "Setting XBOFS to %d\n",
                   self->qos_tx.additional_bofs.value);
        IRDA_DEBUG(2, "Setting MAX_TURN_TIME to %d ms.\n",
                   self->qos_tx.max_turn_time.value);
        IRDA_DEBUG(2, "Setting MIN_TURN_TIME to %d usecs.\n",
                   self->qos_tx.min_turn_time.value);
-       IRDA_DEBUG(2, "Setting LINK_DISC to %d secs.\n", 
+       IRDA_DEBUG(2, "Setting LINK_DISC to %d secs.\n",
                   self->qos_tx.link_disc_time.value);
        return ret;
 }
@@ -463,55 +463,55 @@ int irlap_qos_negotiate(struct irlap_cb *self, struct sk_buff *skb)
  *    Insert QoS negotiaion pararameters into frame
  *
  */
-int irlap_insert_qos_negotiation_params(struct irlap_cb *self, 
+int irlap_insert_qos_negotiation_params(struct irlap_cb *self,
                                        struct sk_buff *skb)
 {
        int ret;
 
        /* Insert data rate */
-       ret = irda_param_insert(self, PI_BAUD_RATE, skb->tail, 
+       ret = irda_param_insert(self, PI_BAUD_RATE, skb->tail,
                                skb_tailroom(skb), &irlap_param_info);
        if (ret < 0)
                return ret;
        skb_put(skb, ret);
 
        /* Insert max turnaround time */
-       ret = irda_param_insert(self, PI_MAX_TURN_TIME, skb->tail, 
+       ret = irda_param_insert(self, PI_MAX_TURN_TIME, skb->tail,
                                skb_tailroom(skb), &irlap_param_info);
        if (ret < 0)
                return ret;
        skb_put(skb, ret);
 
        /* Insert data size */
-       ret = irda_param_insert(self, PI_DATA_SIZE, skb->tail, 
+       ret = irda_param_insert(self, PI_DATA_SIZE, skb->tail,
                                skb_tailroom(skb), &irlap_param_info);
        if (ret < 0)
                return ret;
        skb_put(skb, ret);
 
        /* Insert window size */
-       ret = irda_param_insert(self, PI_WINDOW_SIZE, skb->tail, 
+       ret = irda_param_insert(self, PI_WINDOW_SIZE, skb->tail,
                                skb_tailroom(skb), &irlap_param_info);
        if (ret < 0)
                return ret;
        skb_put(skb, ret);
 
        /* Insert additional BOFs */
-       ret = irda_param_insert(self, PI_ADD_BOFS, skb->tail, 
+       ret = irda_param_insert(self, PI_ADD_BOFS, skb->tail,
                                skb_tailroom(skb), &irlap_param_info);
        if (ret < 0)
                return ret;
        skb_put(skb, ret);
 
        /* Insert minimum turnaround time */
-       ret = irda_param_insert(self, PI_MIN_TURN_TIME, skb->tail, 
+       ret = irda_param_insert(self, PI_MIN_TURN_TIME, skb->tail,
                                skb_tailroom(skb), &irlap_param_info);
        if (ret < 0)
                return ret;
        skb_put(skb, ret);
 
        /* Insert link disconnect/threshold time */
-       ret = irda_param_insert(self, PI_LINK_DISC, skb->tail, 
+       ret = irda_param_insert(self, PI_LINK_DISC, skb->tail,
                                skb_tailroom(skb), &irlap_param_info);
        if (ret < 0)
                return ret;
@@ -537,12 +537,12 @@ static int irlap_param_baud_rate(void *instance, irda_param_t *param, int get)
 
        if (get) {
                param->pv.i = self->qos_rx.baud_rate.bits;
-               IRDA_DEBUG(2, "%s(), baud rate = 0x%02x\n", 
-                          __FUNCTION__, param->pv.i);          
+               IRDA_DEBUG(2, "%s(), baud rate = 0x%02x\n",
+                          __FUNCTION__, param->pv.i);
        } else {
-               /* 
+               /*
                 *  Stations must agree on baud rate, so calculate
-                *  intersection 
+                *  intersection
                 */
                IRDA_DEBUG(2, "Requested BAUD_RATE: 0x%04x\n", (__u16) param->pv.i);
                final = (__u16) param->pv.i & self->qos_rx.baud_rate.bits;
@@ -558,24 +558,24 @@ static int irlap_param_baud_rate(void *instance, irda_param_t *param, int get)
 /*
  * Function irlap_param_link_disconnect (instance, param, get)
  *
- *    Negotiate link disconnect/threshold time. 
+ *    Negotiate link disconnect/threshold time.
  *
  */
-static int irlap_param_link_disconnect(void *instance, irda_param_t *param, 
+static int irlap_param_link_disconnect(void *instance, irda_param_t *param,
                                       int get)
 {
        __u16 final;
-       
+
        struct irlap_cb *self = (struct irlap_cb *) instance;
-       
+
        IRDA_ASSERT(self != NULL, return -1;);
        IRDA_ASSERT(self->magic == LAP_MAGIC, return -1;);
-       
+
        if (get)
                param->pv.i = self->qos_rx.link_disc_time.bits;
        else {
-               /*  
-                *  Stations must agree on link disconnect/threshold 
+               /*
+                *  Stations must agree on link disconnect/threshold
                 *  time.
                 */
                IRDA_DEBUG(2, "LINK_DISC: %02x\n", (__u8) param->pv.i);
@@ -595,14 +595,14 @@ static int irlap_param_link_disconnect(void *instance, irda_param_t *param,
  *    will be negotiated independently for each station
  *
  */
-static int irlap_param_max_turn_time(void *instance, irda_param_t *param, 
+static int irlap_param_max_turn_time(void *instance, irda_param_t *param,
                                     int get)
 {
        struct irlap_cb *self = (struct irlap_cb *) instance;
-       
+
        IRDA_ASSERT(self != NULL, return -1;);
        IRDA_ASSERT(self->magic == LAP_MAGIC, return -1;);
-       
+
        if (get)
                param->pv.i = self->qos_rx.max_turn_time.bits;
        else
@@ -621,10 +621,10 @@ static int irlap_param_max_turn_time(void *instance, irda_param_t *param,
 static int irlap_param_data_size(void *instance, irda_param_t *param, int get)
 {
        struct irlap_cb *self = (struct irlap_cb *) instance;
-       
+
        IRDA_ASSERT(self != NULL, return -1;);
        IRDA_ASSERT(self->magic == LAP_MAGIC, return -1;);
-       
+
        if (get)
                param->pv.i = self->qos_rx.data_size.bits;
        else
@@ -640,14 +640,14 @@ static int irlap_param_data_size(void *instance, irda_param_t *param, int get)
  *    will be negotiated independently for each station
  *
  */
-static int irlap_param_window_size(void *instance, irda_param_t *param, 
+static int irlap_param_window_size(void *instance, irda_param_t *param,
                                   int get)
 {
        struct irlap_cb *self = (struct irlap_cb *) instance;
-       
+
        IRDA_ASSERT(self != NULL, return -1;);
        IRDA_ASSERT(self->magic == LAP_MAGIC, return -1;);
-       
+
        if (get)
                param->pv.i = self->qos_rx.window_size.bits;
        else
@@ -665,10 +665,10 @@ static int irlap_param_window_size(void *instance, irda_param_t *param,
 static int irlap_param_additional_bofs(void *instance, irda_param_t *param, int get)
 {
        struct irlap_cb *self = (struct irlap_cb *) instance;
-       
+
        IRDA_ASSERT(self != NULL, return -1;);
        IRDA_ASSERT(self->magic == LAP_MAGIC, return -1;);
-       
+
        if (get)
                param->pv.i = self->qos_rx.additional_bofs.bits;
        else
@@ -683,14 +683,14 @@ static int irlap_param_additional_bofs(void *instance, irda_param_t *param, int
  *    Negotiate the minimum turn around time. This is a type 1 parameter and
  *    will be negotiated independently for each station
  */
-static int irlap_param_min_turn_time(void *instance, irda_param_t *param, 
+static int irlap_param_min_turn_time(void *instance, irda_param_t *param,
                                     int get)
 {
        struct irlap_cb *self = (struct irlap_cb *) instance;
-       
+
        IRDA_ASSERT(self != NULL, return -1;);
        IRDA_ASSERT(self->magic == LAP_MAGIC, return -1;);
-       
+
        if (get)
                param->pv.i = self->qos_rx.min_turn_time.bits;
        else
@@ -721,9 +721,9 @@ __u32 irlap_max_line_capacity(__u32 speed, __u32 max_turn_time)
 
        line_capacity = max_line_capacities[i][j];
 
-       IRDA_DEBUG(2, "%s(), line capacity=%d bytes\n", 
+       IRDA_DEBUG(2, "%s(), line capacity=%d bytes\n",
                   __FUNCTION__, line_capacity);
-       
+
        return line_capacity;
 }
 
@@ -749,7 +749,7 @@ void irda_qos_bits_to_value(struct qos_info *qos)
        int index;
 
        IRDA_ASSERT(qos != NULL, return;);
-       
+
        index = msb_index(qos->baud_rate.bits);
        qos->baud_rate.value = baud_rates[index];
 
@@ -761,13 +761,13 @@ void irda_qos_bits_to_value(struct qos_info *qos)
 
        index = msb_index(qos->min_turn_time.bits);
        qos->min_turn_time.value = min_turn_times[index];
-       
+
        index = msb_index(qos->max_turn_time.bits);
        qos->max_turn_time.value = max_turn_times[index];
 
        index = msb_index(qos->link_disc_time.bits);
        qos->link_disc_time.value = link_disc_times[index];
-       
+
        index = msb_index(qos->additional_bofs.bits);
        qos->additional_bofs.value = add_bofs[index];
 }
index 3871a2b911f93722e78791203eccb048d7b95a13..d3a6ee8cc4a281a60baa7522278294a3d5799e03 100644 (file)
@@ -1,25 +1,25 @@
 /*********************************************************************
- *                
+ *
  * Filename:      timer.c
- * Version:       
- * Description:   
+ * Version:
+ * Description:
  * Status:        Experimental.
  * Author:        Dag Brattli <dagb@cs.uit.no>
  * Created at:    Sat Aug 16 00:59:29 1997
  * Modified at:   Wed Dec  8 12:50:34 1999
  * Modified by:   Dag Brattli <dagb@cs.uit.no>
- * 
- *     Copyright (c) 1997, 1999 Dag Brattli <dagb@cs.uit.no>, 
+ *
+ *     Copyright (c) 1997, 1999 Dag Brattli <dagb@cs.uit.no>,
  *     All Rights Reserved.
  *     Copyright (c) 2000-2002 Jean Tourrilhes <jt@hpl.hp.com>
- *     
- *     This program is free software; you can redistribute it and/or 
- *     modify it under the terms of the GNU General Public License as 
- *     published by the Free Software Foundation; either version 2 of 
+ *
+ *     This program is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU General Public License as
+ *     published by the Free Software Foundation; either version 2 of
  *     the License, or (at your option) any later version.
  *
  *     Neither Dag Brattli nor University of Tromsø admit liability nor
- *     provide warranty for any of this software. This material is 
+ *     provide warranty for any of this software. This material is
  *     provided "AS-IS" and at no charge.
  *
  ********************************************************************/
@@ -40,11 +40,11 @@ static void irlap_query_timer_expired(void* data);
 static void irlap_final_timer_expired(void* data);
 static void irlap_wd_timer_expired(void* data);
 static void irlap_backoff_timer_expired(void* data);
-static void irlap_media_busy_expired(void* data); 
+static void irlap_media_busy_expired(void* data);
 
 void irlap_start_slot_timer(struct irlap_cb *self, int timeout)
 {
-       irda_start_timer(&self->slot_timer, timeout, (void *) self, 
+       irda_start_timer(&self->slot_timer, timeout, (void *) self,
                         irlap_slot_timer_expired);
 }
 
@@ -67,31 +67,31 @@ void irlap_start_query_timer(struct irlap_cb *self, int S, int s)
        /* Set or re-set the timer. We reset the timer for each received
         * discovery query, which allow us to automatically adjust to
         * the speed of the peer discovery (faster or slower). Jean II */
-       irda_start_timer( &self->query_timer, timeout, (void *) self, 
+       irda_start_timer( &self->query_timer, timeout, (void *) self,
                          irlap_query_timer_expired);
 }
 
 void irlap_start_final_timer(struct irlap_cb *self, int timeout)
 {
-       irda_start_timer(&self->final_timer, timeout, (void *) self, 
+       irda_start_timer(&self->final_timer, timeout, (void *) self,
                         irlap_final_timer_expired);
 }
 
 void irlap_start_wd_timer(struct irlap_cb *self, int timeout)
 {
-       irda_start_timer(&self->wd_timer, timeout, (void *) self, 
+       irda_start_timer(&self->wd_timer, timeout, (void *) self,
                         irlap_wd_timer_expired);
 }
 
 void irlap_start_backoff_timer(struct irlap_cb *self, int timeout)
 {
-       irda_start_timer(&self->backoff_timer, timeout, (void *) self, 
+       irda_start_timer(&self->backoff_timer, timeout, (void *) self,
                         irlap_backoff_timer_expired);
 }
 
 void irlap_start_mbusy_timer(struct irlap_cb *self, int timeout)
 {
-       irda_start_timer(&self->media_busy_timer, timeout, 
+       irda_start_timer(&self->media_busy_timer, timeout,
                         (void *) self, irlap_media_busy_expired);
 }
 
@@ -109,25 +109,25 @@ void irlap_stop_mbusy_timer(struct irlap_cb *self)
                irlap_do_event(self, MEDIA_BUSY_TIMER_EXPIRED, NULL, NULL);
 }
 
-void irlmp_start_watchdog_timer(struct lsap_cb *self, int timeout) 
+void irlmp_start_watchdog_timer(struct lsap_cb *self, int timeout)
 {
        irda_start_timer(&self->watchdog_timer, timeout, (void *) self,
                         irlmp_watchdog_timer_expired);
 }
 
-void irlmp_start_discovery_timer(struct irlmp_cb *self, int timeout) 
+void irlmp_start_discovery_timer(struct irlmp_cb *self, int timeout)
 {
        irda_start_timer(&self->discovery_timer, timeout, (void *) self,
                         irlmp_discovery_timer_expired);
 }
 
-void irlmp_start_idle_timer(struct lap_cb *self, int timeout) 
+void irlmp_start_idle_timer(struct lap_cb *self, int timeout)
 {
        irda_start_timer(&self->idle_timer, timeout, (void *) self,
                         irlmp_idle_timer_expired);
 }
 
-void irlmp_stop_idle_timer(struct lap_cb *self) 
+void irlmp_stop_idle_timer(struct lap_cb *self)
 {
        /* If timer is activated, kill it! */
        del_timer(&self->idle_timer);
@@ -147,7 +147,7 @@ static void irlap_slot_timer_expired(void *data)
        IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
 
        irlap_do_event(self, SLOT_TIMER_EXPIRED, NULL, NULL);
-} 
+}
 
 /*
  * Function irlap_query_timer_expired (data)
@@ -163,12 +163,12 @@ static void irlap_query_timer_expired(void *data)
        IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
 
        irlap_do_event(self, QUERY_TIMER_EXPIRED, NULL, NULL);
-} 
+}
 
 /*
  * Function irda_final_timer_expired (data)
  *
- *    
+ *
  *
  */
 static void irlap_final_timer_expired(void *data)
@@ -184,32 +184,32 @@ static void irlap_final_timer_expired(void *data)
 /*
  * Function irda_wd_timer_expired (data)
  *
- *    
+ *
  *
  */
 static void irlap_wd_timer_expired(void *data)
 {
        struct irlap_cb *self = (struct irlap_cb *) data;
-       
+
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
-       
+
        irlap_do_event(self, WD_TIMER_EXPIRED, NULL, NULL);
 }
 
 /*
  * Function irda_backoff_timer_expired (data)
  *
- *    
+ *
  *
  */
 static void irlap_backoff_timer_expired(void *data)
 {
        struct irlap_cb *self = (struct irlap_cb *) data;
-       
+
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
-       
+
        irlap_do_event(self, BACKOFF_TIMER_EXPIRED, NULL, NULL);
 }
 
@@ -217,7 +217,7 @@ static void irlap_backoff_timer_expired(void *data)
 /*
  * Function irtty_media_busy_expired (data)
  *
- *    
+ *
  */
 void irlap_media_busy_expired(void* data)
 {
index 87130c1c8693a91e678e418817b6f4bd09c10287..5abfb71aae8db6045d76236a4dd0285c4296bd31 100644 (file)
@@ -295,7 +295,7 @@ async_unwrap_bof(struct net_device *dev,
        case OUTSIDE_FRAME:
        case BEGIN_FRAME:
        default:
-               /* We may receive multiple BOF at the start of frame */ 
+               /* We may receive multiple BOF at the start of frame */
                break;
        }
 
diff --git a/net/iucv/Kconfig b/net/iucv/Kconfig
new file mode 100644 (file)
index 0000000..f8fcc3d
--- /dev/null
@@ -0,0 +1,15 @@
+config IUCV
+       tristate "IUCV support (VM only)"
+       depends on S390
+       help
+         Select this option if you want to use inter-user communication under
+         VM or VIF sockets. If you run on z/VM, say "Y" to enable a fast
+         communication link between VM guests.
+
+config AFIUCV
+       tristate "AF_IUCV support (VM only)"
+       depends on IUCV
+       help
+         Select this option if you want to use inter-user communication under
+         VM or VIF sockets. If you run on z/VM, say "Y" to enable a fast
+         communication link between VM guests.
diff --git a/net/iucv/Makefile b/net/iucv/Makefile
new file mode 100644 (file)
index 0000000..7bfdc85
--- /dev/null
@@ -0,0 +1,6 @@
+#
+# Makefile for IUCV
+#
+
+obj-$(CONFIG_IUCV)     += iucv.o
+obj-$(CONFIG_AFIUCV)   += af_iucv.o
diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
new file mode 100644 (file)
index 0000000..acc9421
--- /dev/null
@@ -0,0 +1,1077 @@
+/*
+ *  linux/net/iucv/af_iucv.c
+ *
+ *  IUCV protocol stack for Linux on zSeries
+ *
+ *  Copyright 2006 IBM Corporation
+ *
+ *  Author(s): Jennifer Hunt <jenhunt@us.ibm.com>
+ */
+
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/list.h>
+#include <linux/errno.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/skbuff.h>
+#include <linux/init.h>
+#include <linux/poll.h>
+#include <net/sock.h>
+#include <asm/ebcdic.h>
+#include <asm/cpcmd.h>
+#include <linux/kmod.h>
+
+#include <net/iucv/iucv.h>
+#include <net/iucv/af_iucv.h>
+
+#define CONFIG_IUCV_SOCK_DEBUG 1
+
+#define IPRMDATA 0x80
+#define VERSION "1.0"
+
+static char iucv_userid[80];
+
+static struct proto_ops iucv_sock_ops;
+
+static struct proto iucv_proto = {
+       .name           = "AF_IUCV",
+       .owner          = THIS_MODULE,
+       .obj_size       = sizeof(struct iucv_sock),
+};
+
+/* Call Back functions */
+static void iucv_callback_rx(struct iucv_path *, struct iucv_message *);
+static void iucv_callback_txdone(struct iucv_path *, struct iucv_message *);
+static void iucv_callback_connack(struct iucv_path *, u8 ipuser[16]);
+static int iucv_callback_connreq(struct iucv_path *, u8 ipvmid[8], u8 ipuser[16]);
+static void iucv_callback_connrej(struct iucv_path *, u8 ipuser[16]);
+
+static struct iucv_sock_list iucv_sk_list = {
+       .lock = RW_LOCK_UNLOCKED,
+       .autobind_name = ATOMIC_INIT(0)
+};
+
+static struct iucv_handler af_iucv_handler = {
+       .path_pending     = iucv_callback_connreq,
+       .path_complete    = iucv_callback_connack,
+       .path_severed     = iucv_callback_connrej,
+       .message_pending  = iucv_callback_rx,
+       .message_complete = iucv_callback_txdone
+};
+
+static inline void high_nmcpy(unsigned char *dst, char *src)
+{
+       memcpy(dst, src, 8);
+}
+
+static inline void low_nmcpy(unsigned char *dst, char *src)
+{
+       memcpy(&dst[8], src, 8);
+}
+
+/* Timers */
+static void iucv_sock_timeout(unsigned long arg)
+{
+       struct sock *sk = (struct sock *)arg;
+
+       bh_lock_sock(sk);
+       sk->sk_err = ETIMEDOUT;
+       sk->sk_state_change(sk);
+       bh_unlock_sock(sk);
+
+       iucv_sock_kill(sk);
+       sock_put(sk);
+}
+
+static void iucv_sock_clear_timer(struct sock *sk)
+{
+       sk_stop_timer(sk, &sk->sk_timer);
+}
+
+static void iucv_sock_init_timer(struct sock *sk)
+{
+       init_timer(&sk->sk_timer);
+       sk->sk_timer.function = iucv_sock_timeout;
+       sk->sk_timer.data = (unsigned long)sk;
+}
+
+static struct sock *__iucv_get_sock_by_name(char *nm)
+{
+       struct sock *sk;
+       struct hlist_node *node;
+
+       sk_for_each(sk, node, &iucv_sk_list.head)
+               if (!memcmp(&iucv_sk(sk)->src_name, nm, 8))
+                       return sk;
+
+       return NULL;
+}
+
+static void iucv_sock_destruct(struct sock *sk)
+{
+       skb_queue_purge(&sk->sk_receive_queue);
+       skb_queue_purge(&sk->sk_write_queue);
+}
+
+/* Cleanup Listen */
+static void iucv_sock_cleanup_listen(struct sock *parent)
+{
+       struct sock *sk;
+
+       /* Close non-accepted connections */
+       while ((sk = iucv_accept_dequeue(parent, NULL))) {
+               iucv_sock_close(sk);
+               iucv_sock_kill(sk);
+       }
+
+       parent->sk_state = IUCV_CLOSED;
+       sock_set_flag(parent, SOCK_ZAPPED);
+}
+
+/* Kill socket */
+static void iucv_sock_kill(struct sock *sk)
+{
+       if (!sock_flag(sk, SOCK_ZAPPED) || sk->sk_socket)
+               return;
+
+       iucv_sock_unlink(&iucv_sk_list, sk);
+       sock_set_flag(sk, SOCK_DEAD);
+       sock_put(sk);
+}
+
+/* Close an IUCV socket */
+static void iucv_sock_close(struct sock *sk)
+{
+       unsigned char user_data[16];
+       struct iucv_sock *iucv = iucv_sk(sk);
+       int err;
+
+       iucv_sock_clear_timer(sk);
+       lock_sock(sk);
+
+       switch(sk->sk_state) {
+       case IUCV_LISTEN:
+               iucv_sock_cleanup_listen(sk);
+               break;
+
+       case IUCV_CONNECTED:
+       case IUCV_DISCONN:
+               err = 0;
+               if (iucv->path) {
+                       low_nmcpy(user_data, iucv->src_name);
+                       high_nmcpy(user_data, iucv->dst_name);
+                       ASCEBC(user_data, sizeof(user_data));
+                       err = iucv_path_sever(iucv->path, user_data);
+                       iucv_path_free(iucv->path);
+                       iucv->path = NULL;
+               }
+
+               sk->sk_state = IUCV_CLOSED;
+               sk->sk_state_change(sk);
+               sk->sk_err = ECONNRESET;
+               sk->sk_state_change(sk);
+
+               skb_queue_purge(&iucv->send_skb_q);
+
+               sock_set_flag(sk, SOCK_ZAPPED);
+               break;
+
+       default:
+               sock_set_flag(sk, SOCK_ZAPPED);
+               break;
+       };
+
+       release_sock(sk);
+       iucv_sock_kill(sk);
+}
+
+static void iucv_sock_init(struct sock *sk, struct sock *parent)
+{
+       if (parent)
+               sk->sk_type = parent->sk_type;
+}
+
+static struct sock *iucv_sock_alloc(struct socket *sock, int proto, gfp_t prio)
+{
+       struct sock *sk;
+
+       sk = sk_alloc(PF_IUCV, prio, &iucv_proto, 1);
+       if (!sk)
+               return NULL;
+
+       sock_init_data(sock, sk);
+       INIT_LIST_HEAD(&iucv_sk(sk)->accept_q);
+       skb_queue_head_init(&iucv_sk(sk)->send_skb_q);
+       iucv_sk(sk)->send_tag = 0;
+
+       sk->sk_destruct = iucv_sock_destruct;
+       sk->sk_sndtimeo = IUCV_CONN_TIMEOUT;
+       sk->sk_allocation = GFP_DMA;
+
+       sock_reset_flag(sk, SOCK_ZAPPED);
+
+       sk->sk_protocol = proto;
+       sk->sk_state    = IUCV_OPEN;
+
+       iucv_sock_init_timer(sk);
+
+       iucv_sock_link(&iucv_sk_list, sk);
+       return sk;
+}
+
+/* Create an IUCV socket */
+static int iucv_sock_create(struct socket *sock, int protocol)
+{
+       struct sock *sk;
+
+       if (sock->type != SOCK_STREAM)
+               return -ESOCKTNOSUPPORT;
+
+       sock->state = SS_UNCONNECTED;
+       sock->ops = &iucv_sock_ops;
+
+       sk = iucv_sock_alloc(sock, protocol, GFP_KERNEL);
+       if (!sk)
+               return -ENOMEM;
+
+       iucv_sock_init(sk, NULL);
+
+       return 0;
+}
+
+void iucv_sock_link(struct iucv_sock_list *l, struct sock *sk)
+{
+       write_lock_bh(&l->lock);
+       sk_add_node(sk, &l->head);
+       write_unlock_bh(&l->lock);
+}
+
+void iucv_sock_unlink(struct iucv_sock_list *l, struct sock *sk)
+{
+       write_lock_bh(&l->lock);
+       sk_del_node_init(sk);
+       write_unlock_bh(&l->lock);
+}
+
+void iucv_accept_enqueue(struct sock *parent, struct sock *sk)
+{
+       sock_hold(sk);
+       list_add_tail(&iucv_sk(sk)->accept_q, &iucv_sk(parent)->accept_q);
+       iucv_sk(sk)->parent = parent;
+       parent->sk_ack_backlog++;
+}
+
+void iucv_accept_unlink(struct sock *sk)
+{
+       list_del_init(&iucv_sk(sk)->accept_q);
+       iucv_sk(sk)->parent->sk_ack_backlog--;
+       iucv_sk(sk)->parent = NULL;
+       sock_put(sk);
+}
+
+struct sock *iucv_accept_dequeue(struct sock *parent, struct socket *newsock)
+{
+       struct iucv_sock *isk, *n;
+       struct sock *sk;
+
+       list_for_each_entry_safe(isk, n, &iucv_sk(parent)->accept_q, accept_q){
+               sk = (struct sock *) isk;
+               lock_sock(sk);
+
+               if (sk->sk_state == IUCV_CLOSED) {
+                       release_sock(sk);
+                       iucv_accept_unlink(sk);
+                       continue;
+               }
+
+               if (sk->sk_state == IUCV_CONNECTED ||
+                   sk->sk_state == IUCV_SEVERED ||
+                   !newsock) {
+                       iucv_accept_unlink(sk);
+                       if (newsock)
+                               sock_graft(sk, newsock);
+
+                       if (sk->sk_state == IUCV_SEVERED)
+                               sk->sk_state = IUCV_DISCONN;
+
+                       release_sock(sk);
+                       return sk;
+               }
+
+               release_sock(sk);
+       }
+       return NULL;
+}
+
+int iucv_sock_wait_state(struct sock *sk, int state, int state2,
+                        unsigned long timeo)
+{
+       DECLARE_WAITQUEUE(wait, current);
+       int err = 0;
+
+       add_wait_queue(sk->sk_sleep, &wait);
+       while (sk->sk_state != state && sk->sk_state != state2) {
+               set_current_state(TASK_INTERRUPTIBLE);
+
+               if (!timeo) {
+                       err = -EAGAIN;
+                       break;
+               }
+
+               if (signal_pending(current)) {
+                       err = sock_intr_errno(timeo);
+                       break;
+               }
+
+               release_sock(sk);
+               timeo = schedule_timeout(timeo);
+               lock_sock(sk);
+
+               err = sock_error(sk);
+               if (err)
+                       break;
+       }
+       set_current_state(TASK_RUNNING);
+       remove_wait_queue(sk->sk_sleep, &wait);
+       return err;
+}
+
+/* Bind an unbound socket */
+static int iucv_sock_bind(struct socket *sock, struct sockaddr *addr,
+                         int addr_len)
+{
+       struct sockaddr_iucv *sa = (struct sockaddr_iucv *) addr;
+       struct sock *sk = sock->sk;
+       struct iucv_sock *iucv;
+       int err;
+
+       /* Verify the input sockaddr */
+       if (!addr || addr->sa_family != AF_IUCV)
+               return -EINVAL;
+
+       lock_sock(sk);
+       if (sk->sk_state != IUCV_OPEN) {
+               err = -EBADFD;
+               goto done;
+       }
+
+       write_lock_bh(&iucv_sk_list.lock);
+
+       iucv = iucv_sk(sk);
+       if (__iucv_get_sock_by_name(sa->siucv_name)) {
+               err = -EADDRINUSE;
+               goto done_unlock;
+       }
+       if (iucv->path) {
+               err = 0;
+               goto done_unlock;
+       }
+
+       /* Bind the socket */
+       memcpy(iucv->src_name, sa->siucv_name, 8);
+
+       /* Copy the user id */
+       memcpy(iucv->src_user_id, iucv_userid, 8);
+       sk->sk_state = IUCV_BOUND;
+       err = 0;
+
+done_unlock:
+       /* Release the socket list lock */
+       write_unlock_bh(&iucv_sk_list.lock);
+done:
+       release_sock(sk);
+       return err;
+}
+
+/* Automatically bind an unbound socket */
+static int iucv_sock_autobind(struct sock *sk)
+{
+       struct iucv_sock *iucv = iucv_sk(sk);
+       char query_buffer[80];
+       char name[12];
+       int err = 0;
+
+       /* Set the userid and name */
+       cpcmd("QUERY USERID", query_buffer, sizeof(query_buffer), &err);
+       if (unlikely(err))
+               return -EPROTO;
+
+       memcpy(iucv->src_user_id, query_buffer, 8);
+
+       write_lock_bh(&iucv_sk_list.lock);
+
+       sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
+       while (__iucv_get_sock_by_name(name)) {
+               sprintf(name, "%08x",
+                       atomic_inc_return(&iucv_sk_list.autobind_name));
+       }
+
+       write_unlock_bh(&iucv_sk_list.lock);
+
+       memcpy(&iucv->src_name, name, 8);
+
+       return err;
+}
+
+/* Connect an unconnected socket */
+static int iucv_sock_connect(struct socket *sock, struct sockaddr *addr,
+                            int alen, int flags)
+{
+       struct sockaddr_iucv *sa = (struct sockaddr_iucv *) addr;
+       struct sock *sk = sock->sk;
+       struct iucv_sock *iucv;
+       unsigned char user_data[16];
+       int err;
+
+       if (addr->sa_family != AF_IUCV || alen < sizeof(struct sockaddr_iucv))
+               return -EINVAL;
+
+       if (sk->sk_state != IUCV_OPEN && sk->sk_state != IUCV_BOUND)
+               return -EBADFD;
+
+       if (sk->sk_type != SOCK_STREAM)
+               return -EINVAL;
+
+       iucv = iucv_sk(sk);
+
+       if (sk->sk_state == IUCV_OPEN) {
+               err = iucv_sock_autobind(sk);
+               if (unlikely(err))
+                       return err;
+       }
+
+       lock_sock(sk);
+
+       /* Set the destination information */
+       memcpy(iucv_sk(sk)->dst_user_id, sa->siucv_user_id, 8);
+       memcpy(iucv_sk(sk)->dst_name, sa->siucv_name, 8);
+
+       high_nmcpy(user_data, sa->siucv_name);
+       low_nmcpy(user_data, iucv_sk(sk)->src_name);
+       ASCEBC(user_data, sizeof(user_data));
+
+       iucv = iucv_sk(sk);
+       /* Create path. */
+       iucv->path = iucv_path_alloc(IUCV_QUEUELEN_DEFAULT,
+                                    IPRMDATA, GFP_KERNEL);
+       err = iucv_path_connect(iucv->path, &af_iucv_handler,
+                               sa->siucv_user_id, NULL, user_data, sk);
+       if (err) {
+               iucv_path_free(iucv->path);
+               iucv->path = NULL;
+               err = -ECONNREFUSED;
+               goto done;
+       }
+
+       if (sk->sk_state != IUCV_CONNECTED) {
+               err = iucv_sock_wait_state(sk, IUCV_CONNECTED, IUCV_DISCONN,
+                               sock_sndtimeo(sk, flags & O_NONBLOCK));
+       }
+
+       if (sk->sk_state == IUCV_DISCONN) {
+               release_sock(sk);
+               return -ECONNREFUSED;
+       }
+done:
+       release_sock(sk);
+       return err;
+}
+
+/* Move a socket into listening state. */
+static int iucv_sock_listen(struct socket *sock, int backlog)
+{
+       struct sock *sk = sock->sk;
+       int err;
+
+       lock_sock(sk);
+
+       err = -EINVAL;
+       if (sk->sk_state != IUCV_BOUND || sock->type != SOCK_STREAM)
+               goto done;
+
+       sk->sk_max_ack_backlog = backlog;
+       sk->sk_ack_backlog = 0;
+       sk->sk_state = IUCV_LISTEN;
+       err = 0;
+
+done:
+       release_sock(sk);
+       return err;
+}
+
+/* Accept a pending connection */
+static int iucv_sock_accept(struct socket *sock, struct socket *newsock,
+                           int flags)
+{
+       DECLARE_WAITQUEUE(wait, current);
+       struct sock *sk = sock->sk, *nsk;
+       long timeo;
+       int err = 0;
+
+       lock_sock(sk);
+
+       if (sk->sk_state != IUCV_LISTEN) {
+               err = -EBADFD;
+               goto done;
+       }
+
+       timeo = sock_rcvtimeo(sk, flags & O_NONBLOCK);
+
+       /* Wait for an incoming connection */
+       add_wait_queue_exclusive(sk->sk_sleep, &wait);
+       while (!(nsk = iucv_accept_dequeue(sk, newsock))){
+               set_current_state(TASK_INTERRUPTIBLE);
+               if (!timeo) {
+                       err = -EAGAIN;
+                       break;
+               }
+
+               release_sock(sk);
+               timeo = schedule_timeout(timeo);
+               lock_sock(sk);
+
+               if (sk->sk_state != IUCV_LISTEN) {
+                       err = -EBADFD;
+                       break;
+               }
+
+               if (signal_pending(current)) {
+                       err = sock_intr_errno(timeo);
+                       break;
+               }
+       }
+
+       set_current_state(TASK_RUNNING);
+       remove_wait_queue(sk->sk_sleep, &wait);
+
+       if (err)
+               goto done;
+
+       newsock->state = SS_CONNECTED;
+
+done:
+       release_sock(sk);
+       return err;
+}
+
+static int iucv_sock_getname(struct socket *sock, struct sockaddr *addr,
+                            int *len, int peer)
+{
+       struct sockaddr_iucv *siucv = (struct sockaddr_iucv *) addr;
+       struct sock *sk = sock->sk;
+
+       addr->sa_family = AF_IUCV;
+       *len = sizeof(struct sockaddr_iucv);
+
+       if (peer) {
+               memcpy(siucv->siucv_user_id, iucv_sk(sk)->dst_user_id, 8);
+               memcpy(siucv->siucv_name, &iucv_sk(sk)->dst_name, 8);
+       } else {
+               memcpy(siucv->siucv_user_id, iucv_sk(sk)->src_user_id, 8);
+               memcpy(siucv->siucv_name, iucv_sk(sk)->src_name, 8);
+       }
+       memset(&siucv->siucv_port, 0, sizeof(siucv->siucv_port));
+       memset(&siucv->siucv_addr, 0, sizeof(siucv->siucv_addr));
+       memset(siucv->siucv_nodeid, 0, sizeof(siucv->siucv_nodeid));
+
+       return 0;
+}
+
+static int iucv_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
+                            struct msghdr *msg, size_t len)
+{
+       struct sock *sk = sock->sk;
+       struct iucv_sock *iucv = iucv_sk(sk);
+       struct sk_buff *skb;
+       struct iucv_message txmsg;
+       int err;
+
+       err = sock_error(sk);
+       if (err)
+               return err;
+
+       if (msg->msg_flags & MSG_OOB)
+               return -EOPNOTSUPP;
+
+       lock_sock(sk);
+
+       if (sk->sk_shutdown & SEND_SHUTDOWN) {
+               err = -EPIPE;
+               goto out;
+       }
+
+       if (sk->sk_state == IUCV_CONNECTED){
+               if(!(skb = sock_alloc_send_skb(sk, len,
+                                      msg->msg_flags & MSG_DONTWAIT,
+                                      &err)))
+                       return err;
+
+               if (memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len)){
+                       err = -EFAULT;
+                       goto fail;
+               }
+
+               txmsg.class = 0;
+               txmsg.tag = iucv->send_tag++;
+               memcpy(skb->cb, &txmsg.tag, 4);
+               skb_queue_tail(&iucv->send_skb_q, skb);
+               err = iucv_message_send(iucv->path, &txmsg, 0, 0,
+                                       (void *) skb->data, skb->len);
+               if (err) {
+                       if (err == 3)
+                               printk(KERN_ERR "AF_IUCV msg limit exceeded\n");
+                       skb_unlink(skb, &iucv->send_skb_q);
+                       err = -EPIPE;
+                       goto fail;
+               }
+
+       } else {
+               err = -ENOTCONN;
+               goto out;
+       }
+
+       release_sock(sk);
+       return len;
+
+fail:
+       kfree_skb(skb);
+out:
+       release_sock(sk);
+       return err;
+}
+
+static int iucv_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
+                            struct msghdr *msg, size_t len, int flags)
+{
+       int noblock = flags & MSG_DONTWAIT;
+       struct sock *sk = sock->sk;
+       int target, copied = 0;
+       struct sk_buff *skb;
+       int err = 0;
+
+       if (flags & (MSG_OOB))
+               return -EOPNOTSUPP;
+
+       target = sock_rcvlowat(sk, flags & MSG_WAITALL, len);
+
+       skb = skb_recv_datagram(sk, flags, noblock, &err);
+       if (!skb) {
+               if (sk->sk_shutdown & RCV_SHUTDOWN)
+                       return 0;
+               return err;
+       }
+
+       copied = min_t(unsigned int, skb->len, len);
+
+       if (memcpy_toiovec(msg->msg_iov, skb->data, copied)) {
+               skb_queue_head(&sk->sk_receive_queue, skb);
+               if (copied == 0)
+                       return -EFAULT;
+       }
+
+       len -= copied;
+
+       /* Mark read part of skb as used */
+       if (!(flags & MSG_PEEK)) {
+               skb_pull(skb, copied);
+
+               if (skb->len) {
+                       skb_queue_head(&sk->sk_receive_queue, skb);
+                       goto done;
+               }
+
+               kfree_skb(skb);
+       } else
+               skb_queue_head(&sk->sk_receive_queue, skb);
+
+done:
+       return err ? : copied;
+}
+
+static inline unsigned int iucv_accept_poll(struct sock *parent)
+{
+       struct iucv_sock *isk, *n;
+       struct sock *sk;
+
+       list_for_each_entry_safe(isk, n, &iucv_sk(parent)->accept_q, accept_q){
+               sk = (struct sock *) isk;
+
+               if (sk->sk_state == IUCV_CONNECTED)
+                       return POLLIN | POLLRDNORM;
+       }
+
+       return 0;
+}
+
+unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
+                           poll_table *wait)
+{
+       struct sock *sk = sock->sk;
+       unsigned int mask = 0;
+
+       poll_wait(file, sk->sk_sleep, wait);
+
+       if (sk->sk_state == IUCV_LISTEN)
+               return iucv_accept_poll(sk);
+
+       if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
+               mask |= POLLERR;
+
+       if (sk->sk_shutdown & RCV_SHUTDOWN)
+               mask |= POLLRDHUP;
+
+       if (sk->sk_shutdown == SHUTDOWN_MASK)
+               mask |= POLLHUP;
+
+       if (!skb_queue_empty(&sk->sk_receive_queue) ||
+                       (sk->sk_shutdown & RCV_SHUTDOWN))
+               mask |= POLLIN | POLLRDNORM;
+
+       if (sk->sk_state == IUCV_CLOSED)
+               mask |= POLLHUP;
+
+       if (sock_writeable(sk))
+               mask |= POLLOUT | POLLWRNORM | POLLWRBAND;
+       else
+               set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags);
+
+       return mask;
+}
+
+static int iucv_sock_shutdown(struct socket *sock, int how)
+{
+       struct sock *sk = sock->sk;
+       struct iucv_sock *iucv = iucv_sk(sk);
+       struct iucv_message txmsg;
+       int err = 0;
+       u8 prmmsg[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
+
+       how++;
+
+       if ((how & ~SHUTDOWN_MASK) || !how)
+               return -EINVAL;
+
+       lock_sock(sk);
+       switch(sk->sk_state) {
+       case IUCV_CLOSED:
+               err = -ENOTCONN;
+               goto fail;
+
+       default:
+               sk->sk_shutdown |= how;
+               break;
+       }
+
+       if (how == SEND_SHUTDOWN || how == SHUTDOWN_MASK) {
+               txmsg.class = 0;
+               txmsg.tag = 0;
+               err = iucv_message_send(iucv->path, &txmsg, IUCV_IPRMDATA, 0,
+                                       (void *) prmmsg, 8);
+               if (err) {
+                       switch(err) {
+                       case 1:
+                               err = -ENOTCONN;
+                               break;
+                       case 2:
+                               err = -ECONNRESET;
+                               break;
+                       default:
+                               err = -ENOTCONN;
+                               break;
+                       }
+               }
+       }
+
+       if (how == RCV_SHUTDOWN || how == SHUTDOWN_MASK) {
+               err = iucv_path_quiesce(iucv_sk(sk)->path, NULL);
+               if (err)
+                       err = -ENOTCONN;
+
+               skb_queue_purge(&sk->sk_receive_queue);
+       }
+
+       /* Wake up anyone sleeping in poll */
+       sk->sk_state_change(sk);
+
+fail:
+       release_sock(sk);
+       return err;
+}
+
+static int iucv_sock_release(struct socket *sock)
+{
+       struct sock *sk = sock->sk;
+       int err = 0;
+
+       if (!sk)
+               return 0;
+
+       iucv_sock_close(sk);
+
+       /* Unregister with IUCV base support */
+       if (iucv_sk(sk)->path) {
+               iucv_path_sever(iucv_sk(sk)->path, NULL);
+               iucv_path_free(iucv_sk(sk)->path);
+               iucv_sk(sk)->path = NULL;
+       }
+
+       if (sock_flag(sk, SOCK_LINGER) && sk->sk_lingertime){
+               lock_sock(sk);
+               err = iucv_sock_wait_state(sk, IUCV_CLOSED, 0,
+                                          sk->sk_lingertime);
+               release_sock(sk);
+       }
+
+       sock_orphan(sk);
+       iucv_sock_kill(sk);
+       return err;
+}
+
+/* Callback wrappers - called from iucv base support */
+static int iucv_callback_connreq(struct iucv_path *path,
+                                u8 ipvmid[8], u8 ipuser[16])
+{
+       unsigned char user_data[16];
+       unsigned char nuser_data[16];
+       unsigned char src_name[8];
+       struct hlist_node *node;
+       struct sock *sk, *nsk;
+       struct iucv_sock *iucv, *niucv;
+       int err;
+
+       memcpy(src_name, ipuser, 8);
+       EBCASC(src_name, 8);
+       /* Find out if this path belongs to af_iucv. */
+       read_lock(&iucv_sk_list.lock);
+       iucv = NULL;
+       sk_for_each(sk, node, &iucv_sk_list.head)
+               if (sk->sk_state == IUCV_LISTEN &&
+                   !memcmp(&iucv_sk(sk)->src_name, src_name, 8)) {
+                       /*
+                        * Found a listening socket with
+                        * src_name == ipuser[0-7].
+                        */
+                       iucv = iucv_sk(sk);
+                       break;
+               }
+       read_unlock(&iucv_sk_list.lock);
+       if (!iucv)
+               /* No socket found, not one of our paths. */
+               return -EINVAL;
+
+       bh_lock_sock(sk);
+
+       /* Check if parent socket is listening */
+       low_nmcpy(user_data, iucv->src_name);
+       high_nmcpy(user_data, iucv->dst_name);
+       ASCEBC(user_data, sizeof(user_data));
+       if (sk->sk_state != IUCV_LISTEN) {
+               err = iucv_path_sever(path, user_data);
+               goto fail;
+       }
+
+       /* Check for backlog size */
+       if (sk_acceptq_is_full(sk)) {
+               err = iucv_path_sever(path, user_data);
+               goto fail;
+       }
+
+       /* Create the new socket */
+       nsk = iucv_sock_alloc(NULL, SOCK_STREAM, GFP_ATOMIC);
+       if (!nsk){
+               err = iucv_path_sever(path, user_data);
+               goto fail;
+       }
+
+       niucv = iucv_sk(nsk);
+       iucv_sock_init(nsk, sk);
+
+       /* Set the new iucv_sock */
+       memcpy(niucv->dst_name, ipuser + 8, 8);
+       EBCASC(niucv->dst_name, 8);
+       memcpy(niucv->dst_user_id, ipvmid, 8);
+       memcpy(niucv->src_name, iucv->src_name, 8);
+       memcpy(niucv->src_user_id, iucv->src_user_id, 8);
+       niucv->path = path;
+
+       /* Call iucv_accept */
+       high_nmcpy(nuser_data, ipuser + 8);
+       memcpy(nuser_data + 8, niucv->src_name, 8);
+       ASCEBC(nuser_data + 8, 8);
+
+       path->msglim = IUCV_QUEUELEN_DEFAULT;
+       err = iucv_path_accept(path, &af_iucv_handler, nuser_data, nsk);
+       if (err){
+               err = iucv_path_sever(path, user_data);
+               goto fail;
+       }
+
+       iucv_accept_enqueue(sk, nsk);
+
+       /* Wake up accept */
+       nsk->sk_state = IUCV_CONNECTED;
+       sk->sk_data_ready(sk, 1);
+       err = 0;
+fail:
+       bh_unlock_sock(sk);
+       return 0;
+}
+
+static void iucv_callback_connack(struct iucv_path *path, u8 ipuser[16])
+{
+       struct sock *sk = path->private;
+
+       sk->sk_state = IUCV_CONNECTED;
+       sk->sk_state_change(sk);
+}
+
+static void iucv_callback_rx(struct iucv_path *path, struct iucv_message *msg)
+{
+       struct sock *sk = path->private;
+       struct sk_buff *skb;
+       int rc;
+
+       if (sk->sk_shutdown & RCV_SHUTDOWN)
+               return;
+
+       skb = alloc_skb(msg->length, GFP_ATOMIC | GFP_DMA);
+       if (!skb) {
+               iucv_message_reject(path, msg);
+               return;
+       }
+
+       if (msg->flags & IPRMDATA) {
+               skb->data = NULL;
+               skb->len = 0;
+       } else {
+               rc = iucv_message_receive(path, msg, 0, skb->data,
+                                         msg->length, NULL);
+               if (rc) {
+                       kfree_skb(skb);
+                       return;
+               }
+
+               skb->h.raw = skb->data;
+               skb->nh.raw = skb->data;
+               skb->len = msg->length;
+       }
+
+       if (sock_queue_rcv_skb(sk, skb))
+               kfree_skb(skb);
+}
+
+static void iucv_callback_txdone(struct iucv_path *path,
+                                struct iucv_message *msg)
+{
+       struct sock *sk = path->private;
+       struct sk_buff *this;
+       struct sk_buff_head *list = &iucv_sk(sk)->send_skb_q;
+       struct sk_buff *list_skb = list->next;
+       unsigned long flags;
+
+       spin_lock_irqsave(&list->lock, flags);
+
+       do {
+               this = list_skb;
+               list_skb = list_skb->next;
+       } while (memcmp(&msg->tag, this->cb, 4));
+
+       spin_unlock_irqrestore(&list->lock, flags);
+
+       skb_unlink(this, &iucv_sk(sk)->send_skb_q);
+       kfree_skb(this);
+}
+
+static void iucv_callback_connrej(struct iucv_path *path, u8 ipuser[16])
+{
+       struct sock *sk = path->private;
+
+       if (!list_empty(&iucv_sk(sk)->accept_q))
+               sk->sk_state = IUCV_SEVERED;
+       else
+               sk->sk_state = IUCV_DISCONN;
+
+       sk->sk_state_change(sk);
+}
+
+static struct proto_ops iucv_sock_ops = {
+       .family         = PF_IUCV,
+       .owner          = THIS_MODULE,
+       .release        = iucv_sock_release,
+       .bind           = iucv_sock_bind,
+       .connect        = iucv_sock_connect,
+       .listen         = iucv_sock_listen,
+       .accept         = iucv_sock_accept,
+       .getname        = iucv_sock_getname,
+       .sendmsg        = iucv_sock_sendmsg,
+       .recvmsg        = iucv_sock_recvmsg,
+       .poll           = iucv_sock_poll,
+       .ioctl          = sock_no_ioctl,
+       .mmap           = sock_no_mmap,
+       .socketpair     = sock_no_socketpair,
+       .shutdown       = iucv_sock_shutdown,
+       .setsockopt     = sock_no_setsockopt,
+       .getsockopt     = sock_no_getsockopt
+};
+
+static struct net_proto_family iucv_sock_family_ops = {
+       .family = AF_IUCV,
+       .owner  = THIS_MODULE,
+       .create = iucv_sock_create,
+};
+
+static int afiucv_init(void)
+{
+       int err;
+
+       if (!MACHINE_IS_VM) {
+               printk(KERN_ERR "AF_IUCV connection needs VM as base\n");
+               err = -EPROTONOSUPPORT;
+               goto out;
+       }
+       cpcmd("QUERY USERID", iucv_userid, sizeof(iucv_userid), &err);
+       if (unlikely(err)) {
+               printk(KERN_ERR "AF_IUCV needs the VM userid\n");
+               err = -EPROTONOSUPPORT;
+               goto out;
+       }
+
+       err = iucv_register(&af_iucv_handler, 0);
+       if (err)
+               goto out;
+       err = proto_register(&iucv_proto, 0);
+       if (err)
+               goto out_iucv;
+       err = sock_register(&iucv_sock_family_ops);
+       if (err)
+               goto out_proto;
+       printk(KERN_INFO "AF_IUCV lowlevel driver initialized\n");
+       return 0;
+
+out_proto:
+       proto_unregister(&iucv_proto);
+out_iucv:
+       iucv_unregister(&af_iucv_handler, 0);
+out:
+       return err;
+}
+
+static void __exit afiucv_exit(void)
+{
+       sock_unregister(PF_IUCV);
+       proto_unregister(&iucv_proto);
+       iucv_unregister(&af_iucv_handler, 0);
+
+       printk(KERN_INFO "AF_IUCV lowlevel driver unloaded\n");
+}
+
+module_init(afiucv_init);
+module_exit(afiucv_exit);
+
+MODULE_AUTHOR("Jennifer Hunt <jenhunt@us.ibm.com>");
+MODULE_DESCRIPTION("IUCV Sockets ver " VERSION);
+MODULE_VERSION(VERSION);
+MODULE_LICENSE("GPL");
+MODULE_ALIAS_NETPROTO(PF_IUCV);
diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
new file mode 100644 (file)
index 0000000..1b10d57
--- /dev/null
@@ -0,0 +1,1619 @@
+/*
+ * IUCV base infrastructure.
+ *
+ * Copyright 2001, 2006 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ * Author(s):
+ *    Original source:
+ *     Alan Altmark (Alan_Altmark@us.ibm.com)  Sept. 2000
+ *     Xenia Tkatschow (xenia@us.ibm.com)
+ *    2Gb awareness and general cleanup:
+ *     Fritz Elfert (elfert@de.ibm.com, felfert@millenux.com)
+ *    Rewritten for af_iucv:
+ *     Martin Schwidefsky <schwidefsky@de.ibm.com>
+ *
+ * Documentation used:
+ *    The original source
+ *    CP Programming Service, IBM document # SC24-5760
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+
+#include <linux/spinlock.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/list.h>
+#include <linux/errno.h>
+#include <linux/err.h>
+#include <linux/device.h>
+#include <linux/cpu.h>
+#include <net/iucv/iucv.h>
+#include <asm/atomic.h>
+#include <asm/ebcdic.h>
+#include <asm/io.h>
+#include <asm/s390_ext.h>
+#include <asm/s390_rdev.h>
+#include <asm/smp.h>
+
+/*
+ * FLAGS:
+ * All flags are defined in the field IPFLAGS1 of each function
+ * and can be found in CP Programming Services.
+ * IPSRCCLS - Indicates you have specified a source class.
+ * IPTRGCLS - Indicates you have specified a target class.
+ * IPFGPID  - Indicates you have specified a pathid.
+ * IPFGMID  - Indicates you have specified a message ID.
+ * IPNORPY  - Indicates a one-way message. No reply expected.
+ * IPALL    - Indicates that all paths are affected.
+ */
+#define IUCV_IPSRCCLS  0x01
+#define IUCV_IPTRGCLS  0x01
+#define IUCV_IPFGPID   0x02
+#define IUCV_IPFGMID   0x04
+#define IUCV_IPNORPY   0x10
+#define IUCV_IPALL     0x80
+
+static int iucv_bus_match (struct device *dev, struct device_driver *drv)
+{
+       return 0;
+}
+
+struct bus_type iucv_bus = {
+       .name = "iucv",
+       .match = iucv_bus_match,
+};
+
+struct device *iucv_root;
+static int iucv_available;
+
+/* General IUCV interrupt structure */
+struct iucv_irq_data {
+       u16 ippathid;
+       u8  ipflags1;
+       u8  iptype;
+       u32 res2[8];
+};
+
+struct iucv_work {
+       struct list_head list;
+       struct iucv_irq_data data;
+};
+
+static LIST_HEAD(iucv_work_queue);
+static DEFINE_SPINLOCK(iucv_work_lock);
+
+static struct iucv_irq_data *iucv_irq_data;
+static cpumask_t iucv_buffer_cpumask = CPU_MASK_NONE;
+static cpumask_t iucv_irq_cpumask = CPU_MASK_NONE;
+
+static void iucv_tasklet_handler(unsigned long);
+static DECLARE_TASKLET(iucv_tasklet, iucv_tasklet_handler,0);
+
+enum iucv_command_codes {
+       IUCV_QUERY = 0,
+       IUCV_RETRIEVE_BUFFER = 2,
+       IUCV_SEND = 4,
+       IUCV_RECEIVE = 5,
+       IUCV_REPLY = 6,
+       IUCV_REJECT = 8,
+       IUCV_PURGE = 9,
+       IUCV_ACCEPT = 10,
+       IUCV_CONNECT = 11,
+       IUCV_DECLARE_BUFFER = 12,
+       IUCV_QUIESCE = 13,
+       IUCV_RESUME = 14,
+       IUCV_SEVER = 15,
+       IUCV_SETMASK = 16,
+};
+
+/*
+ * Error messages that are used with the iucv_sever function. They get
+ * converted to EBCDIC.
+ */
+static char iucv_error_no_listener[16] = "NO LISTENER";
+static char iucv_error_no_memory[16] = "NO MEMORY";
+static char iucv_error_pathid[16] = "INVALID PATHID";
+
+/*
+ * iucv_handler_list: List of registered handlers.
+ */
+static LIST_HEAD(iucv_handler_list);
+
+/*
+ * iucv_path_table: an array of iucv_path structures.
+ */
+static struct iucv_path **iucv_path_table;
+static unsigned long iucv_max_pathid;
+
+/*
+ * iucv_lock: spinlock protecting iucv_handler_list and iucv_pathid_table
+ */
+static DEFINE_SPINLOCK(iucv_table_lock);
+
+/*
+ * iucv_tasklet_cpu: contains the number of the cpu executing the tasklet.
+ * Needed for iucv_path_sever called from tasklet.
+ */
+static int iucv_tasklet_cpu = -1;
+
+/*
+ * Mutex and wait queue for iucv_register/iucv_unregister.
+ */
+static DEFINE_MUTEX(iucv_register_mutex);
+
+/*
+ * Counter for number of non-smp capable handlers.
+ */
+static int iucv_nonsmp_handler;
+
+/*
+ * IUCV control data structure. Used by iucv_path_accept, iucv_path_connect,
+ * iucv_path_quiesce and iucv_path_sever.
+ */
+struct iucv_cmd_control {
+       u16 ippathid;
+       u8  ipflags1;
+       u8  iprcode;
+       u16 ipmsglim;
+       u16 res1;
+       u8  ipvmid[8];
+       u8  ipuser[16];
+       u8  iptarget[8];
+} __attribute__ ((packed,aligned(8)));
+
+/*
+ * Data in parameter list iucv structure. Used by iucv_message_send,
+ * iucv_message_send2way and iucv_message_reply.
+ */
+struct iucv_cmd_dpl {
+       u16 ippathid;
+       u8  ipflags1;
+       u8  iprcode;
+       u32 ipmsgid;
+       u32 iptrgcls;
+       u8  iprmmsg[8];
+       u32 ipsrccls;
+       u32 ipmsgtag;
+       u32 ipbfadr2;
+       u32 ipbfln2f;
+       u32 res;
+} __attribute__ ((packed,aligned(8)));
+
+/*
+ * Data in buffer iucv structure. Used by iucv_message_receive,
+ * iucv_message_reject, iucv_message_send, iucv_message_send2way
+ * and iucv_declare_cpu.
+ */
+struct iucv_cmd_db {
+       u16 ippathid;
+       u8  ipflags1;
+       u8  iprcode;
+       u32 ipmsgid;
+       u32 iptrgcls;
+       u32 ipbfadr1;
+       u32 ipbfln1f;
+       u32 ipsrccls;
+       u32 ipmsgtag;
+       u32 ipbfadr2;
+       u32 ipbfln2f;
+       u32 res;
+} __attribute__ ((packed,aligned(8)));
+
+/*
+ * Purge message iucv structure. Used by iucv_message_purge.
+ */
+struct iucv_cmd_purge {
+       u16 ippathid;
+       u8  ipflags1;
+       u8  iprcode;
+       u32 ipmsgid;
+       u8  ipaudit[3];
+       u8  res1[5];
+       u32 res2;
+       u32 ipsrccls;
+       u32 ipmsgtag;
+       u32 res3[3];
+} __attribute__ ((packed,aligned(8)));
+
+/*
+ * Set mask iucv structure. Used by iucv_enable_cpu.
+ */
+struct iucv_cmd_set_mask {
+       u8  ipmask;
+       u8  res1[2];
+       u8  iprcode;
+       u32 res2[9];
+} __attribute__ ((packed,aligned(8)));
+
+union iucv_param {
+       struct iucv_cmd_control ctrl;
+       struct iucv_cmd_dpl dpl;
+       struct iucv_cmd_db db;
+       struct iucv_cmd_purge purge;
+       struct iucv_cmd_set_mask set_mask;
+};
+
+/*
+ * Anchor for per-cpu IUCV command parameter block.
+ */
+static union iucv_param *iucv_param;
+
+/**
+ * iucv_call_b2f0
+ * @code: identifier of IUCV call to CP.
+ * @parm: pointer to a struct iucv_parm block
+ *
+ * Calls CP to execute IUCV commands.
+ *
+ * Returns the result of the CP IUCV call.
+ */
+static inline int iucv_call_b2f0(int command, union iucv_param *parm)
+{
+       register unsigned long reg0 asm ("0");
+       register unsigned long reg1 asm ("1");
+       int ccode;
+
+       reg0 = command;
+       reg1 = virt_to_phys(parm);
+       asm volatile(
+               "       .long 0xb2f01000\n"
+               "       ipm     %0\n"
+               "       srl     %0,28\n"
+               : "=d" (ccode), "=m" (*parm), "+d" (reg0), "+a" (reg1)
+               :  "m" (*parm) : "cc");
+       return (ccode == 1) ? parm->ctrl.iprcode : ccode;
+}
+
+/**
+ * iucv_query_maxconn
+ *
+ * Determines the maximum number of connections that may be established.
+ *
+ * Returns the maximum number of connections or -EPERM is IUCV is not
+ * available.
+ */
+static int iucv_query_maxconn(void)
+{
+       register unsigned long reg0 asm ("0");
+       register unsigned long reg1 asm ("1");
+       void *param;
+       int ccode;
+
+       param = kzalloc(sizeof(union iucv_param), GFP_KERNEL|GFP_DMA);
+       if (!param)
+               return -ENOMEM;
+       reg0 = IUCV_QUERY;
+       reg1 = (unsigned long) param;
+       asm volatile (
+               "       .long   0xb2f01000\n"
+               "       ipm     %0\n"
+               "       srl     %0,28\n"
+               : "=d" (ccode), "+d" (reg0), "+d" (reg1) : : "cc");
+       if (ccode == 0)
+               iucv_max_pathid = reg0;
+       kfree(param);
+       return ccode ? -EPERM : 0;
+}
+
+/**
+ * iucv_allow_cpu
+ * @data: unused
+ *
+ * Allow iucv interrupts on this cpu.
+ */
+static void iucv_allow_cpu(void *data)
+{
+       int cpu = smp_processor_id();
+       union iucv_param *parm;
+
+       /*
+        * Enable all iucv interrupts.
+        * ipmask contains bits for the different interrupts
+        *      0x80 - Flag to allow nonpriority message pending interrupts
+        *      0x40 - Flag to allow priority message pending interrupts
+        *      0x20 - Flag to allow nonpriority message completion interrupts
+        *      0x10 - Flag to allow priority message completion interrupts
+        *      0x08 - Flag to allow IUCV control interrupts
+        */
+       parm = percpu_ptr(iucv_param, smp_processor_id());
+       memset(parm, 0, sizeof(union iucv_param));
+       parm->set_mask.ipmask = 0xf8;
+       iucv_call_b2f0(IUCV_SETMASK, parm);
+
+       /* Set indication that iucv interrupts are allowed for this cpu. */
+       cpu_set(cpu, iucv_irq_cpumask);
+}
+
+/**
+ * iucv_block_cpu
+ * @data: unused
+ *
+ * Block iucv interrupts on this cpu.
+ */
+static void iucv_block_cpu(void *data)
+{
+       int cpu = smp_processor_id();
+       union iucv_param *parm;
+
+       /* Disable all iucv interrupts. */
+       parm = percpu_ptr(iucv_param, smp_processor_id());
+       memset(parm, 0, sizeof(union iucv_param));
+       iucv_call_b2f0(IUCV_SETMASK, parm);
+
+       /* Clear indication that iucv interrupts are allowed for this cpu. */
+       cpu_clear(cpu, iucv_irq_cpumask);
+}
+
+/**
+ * iucv_declare_cpu
+ * @data: unused
+ *
+ * Declare a interupt buffer on this cpu.
+ */
+static void iucv_declare_cpu(void *data)
+{
+       int cpu = smp_processor_id();
+       union iucv_param *parm;
+       int rc;
+
+       if (cpu_isset(cpu, iucv_buffer_cpumask))
+               return;
+
+       /* Declare interrupt buffer. */
+       parm = percpu_ptr(iucv_param, cpu);
+       memset(parm, 0, sizeof(union iucv_param));
+       parm->db.ipbfadr1 = virt_to_phys(percpu_ptr(iucv_irq_data, cpu));
+       rc = iucv_call_b2f0(IUCV_DECLARE_BUFFER, parm);
+       if (rc) {
+               char *err = "Unknown";
+               switch(rc) {
+               case 0x03:
+                       err = "Directory error";
+                       break;
+               case 0x0a:
+                       err = "Invalid length";
+                       break;
+               case 0x13:
+                       err = "Buffer already exists";
+                       break;
+               case 0x3e:
+                       err = "Buffer overlap";
+                       break;
+               case 0x5c:
+                       err = "Paging or storage error";
+                       break;
+               }
+               printk(KERN_WARNING "iucv_register: iucv_declare_buffer "
+                      "on cpu %i returned error 0x%02x (%s)\n", cpu, rc, err);
+               return;
+       }
+
+       /* Set indication that an iucv buffer exists for this cpu. */
+       cpu_set(cpu, iucv_buffer_cpumask);
+
+       if (iucv_nonsmp_handler == 0 || cpus_empty(iucv_irq_cpumask))
+               /* Enable iucv interrupts on this cpu. */
+               iucv_allow_cpu(NULL);
+       else
+               /* Disable iucv interrupts on this cpu. */
+               iucv_block_cpu(NULL);
+}
+
+/**
+ * iucv_retrieve_cpu
+ * @data: unused
+ *
+ * Retrieve interrupt buffer on this cpu.
+ */
+static void iucv_retrieve_cpu(void *data)
+{
+       int cpu = smp_processor_id();
+       union iucv_param *parm;
+
+       if (!cpu_isset(cpu, iucv_buffer_cpumask))
+               return;
+
+       /* Block iucv interrupts. */
+       iucv_block_cpu(NULL);
+
+       /* Retrieve interrupt buffer. */
+       parm = percpu_ptr(iucv_param, cpu);
+       iucv_call_b2f0(IUCV_RETRIEVE_BUFFER, parm);
+
+       /* Clear indication that an iucv buffer exists for this cpu. */
+       cpu_clear(cpu, iucv_buffer_cpumask);
+}
+
+/**
+ * iucv_setmask_smp
+ *
+ * Allow iucv interrupts on all cpus.
+ */
+static void iucv_setmask_mp(void)
+{
+       int cpu;
+
+       for_each_online_cpu(cpu)
+               /* Enable all cpus with a declared buffer. */
+               if (cpu_isset(cpu, iucv_buffer_cpumask) &&
+                   !cpu_isset(cpu, iucv_irq_cpumask))
+                       smp_call_function_on(iucv_allow_cpu, NULL, 0, 1, cpu);
+}
+
+/**
+ * iucv_setmask_up
+ *
+ * Allow iucv interrupts on a single cpus.
+ */
+static void iucv_setmask_up(void)
+{
+       cpumask_t cpumask;
+       int cpu;
+
+       /* Disable all cpu but the first in cpu_irq_cpumask. */
+       cpumask = iucv_irq_cpumask;
+       cpu_clear(first_cpu(iucv_irq_cpumask), cpumask);
+       for_each_cpu_mask(cpu, cpumask)
+               smp_call_function_on(iucv_block_cpu, NULL, 0, 1, cpu);
+}
+
+/**
+ * iucv_enable
+ *
+ * This function makes iucv ready for use. It allocates the pathid
+ * table, declares an iucv interrupt buffer and enables the iucv
+ * interrupts. Called when the first user has registered an iucv
+ * handler.
+ */
+static int iucv_enable(void)
+{
+       size_t alloc_size;
+       int cpu, rc;
+
+       rc = -ENOMEM;
+       alloc_size = iucv_max_pathid * sizeof(struct iucv_path);
+       iucv_path_table = kzalloc(alloc_size, GFP_KERNEL);
+       if (!iucv_path_table)
+               goto out;
+       /* Declare per cpu buffers. */
+       rc = -EIO;
+       for_each_online_cpu(cpu)
+               smp_call_function_on(iucv_declare_cpu, NULL, 0, 1, cpu);
+       if (cpus_empty(iucv_buffer_cpumask))
+               /* No cpu could declare an iucv buffer. */
+               goto out_path;
+       return 0;
+
+out_path:
+       kfree(iucv_path_table);
+out:
+       return rc;
+}
+
+/**
+ * iucv_disable
+ *
+ * This function shuts down iucv. It disables iucv interrupts, retrieves
+ * the iucv interrupt buffer and frees the pathid table. Called after the
+ * last user unregister its iucv handler.
+ */
+static void iucv_disable(void)
+{
+       on_each_cpu(iucv_retrieve_cpu, NULL, 0, 1);
+       kfree(iucv_path_table);
+}
+
+#ifdef CONFIG_HOTPLUG_CPU
+static int __cpuinit iucv_cpu_notify(struct notifier_block *self,
+                                    unsigned long action, void *hcpu)
+{
+       cpumask_t cpumask;
+       long cpu = (long) hcpu;
+
+       switch (action) {
+       case CPU_UP_PREPARE:
+               if (!percpu_populate(iucv_irq_data,
+                                    sizeof(struct iucv_irq_data),
+                                    GFP_KERNEL|GFP_DMA, cpu))
+                       return NOTIFY_BAD;
+               if (!percpu_populate(iucv_param, sizeof(union iucv_param),
+                                    GFP_KERNEL|GFP_DMA, cpu)) {
+                       percpu_depopulate(iucv_irq_data, cpu);
+                       return NOTIFY_BAD;
+               }
+               break;
+       case CPU_UP_CANCELED:
+       case CPU_DEAD:
+               percpu_depopulate(iucv_param, cpu);
+               percpu_depopulate(iucv_irq_data, cpu);
+               break;
+       case CPU_ONLINE:
+       case CPU_DOWN_FAILED:
+               smp_call_function_on(iucv_declare_cpu, NULL, 0, 1, cpu);
+               break;
+       case CPU_DOWN_PREPARE:
+               cpumask = iucv_buffer_cpumask;
+               cpu_clear(cpu, cpumask);
+               if (cpus_empty(cpumask))
+                       /* Can't offline last IUCV enabled cpu. */
+                       return NOTIFY_BAD;
+               smp_call_function_on(iucv_retrieve_cpu, NULL, 0, 1, cpu);
+               if (cpus_empty(iucv_irq_cpumask))
+                       smp_call_function_on(iucv_allow_cpu, NULL, 0, 1,
+                                            first_cpu(iucv_buffer_cpumask));
+               break;
+       }
+       return NOTIFY_OK;
+}
+
+static struct notifier_block iucv_cpu_notifier = {
+       .notifier_call = iucv_cpu_notify,
+};
+#endif
+
+/**
+ * iucv_sever_pathid
+ * @pathid: path identification number.
+ * @userdata: 16-bytes of user data.
+ *
+ * Sever an iucv path to free up the pathid. Used internally.
+ */
+static int iucv_sever_pathid(u16 pathid, u8 userdata[16])
+{
+       union iucv_param *parm;
+
+       parm = percpu_ptr(iucv_param, smp_processor_id());
+       memset(parm, 0, sizeof(union iucv_param));
+       if (userdata)
+               memcpy(parm->ctrl.ipuser, userdata, sizeof(parm->ctrl.ipuser));
+       parm->ctrl.ippathid = pathid;
+       return iucv_call_b2f0(IUCV_SEVER, parm);
+}
+
+/**
+ * __iucv_cleanup_pathid
+ * @dummy: unused dummy argument
+ *
+ * Nop function called via smp_call_function to force work items from
+ * pending external iucv interrupts to the work queue.
+ */
+static void __iucv_cleanup_pathid(void *dummy)
+{
+}
+
+/**
+ * iucv_cleanup_pathid
+ * @pathid: 16 bit pathid
+ *
+ * Function called after a path has been severed to find all remaining
+ * work items for the now stale pathid. The caller needs to hold the
+ * iucv_table_lock.
+ */
+static void iucv_cleanup_pathid(u16 pathid)
+{
+       struct iucv_work *p, *n;
+
+       /*
+        * Path is severed, the pathid can be reused immediatly on
+        * a iucv connect or a connection pending interrupt.
+        * iucv_path_connect and connection pending interrupt will
+        * wait until the iucv_table_lock is released before the
+        * recycled pathid enters the system.
+        * Force remaining interrupts to the work queue, then
+        * scan the work queue for items of this path.
+        */
+       smp_call_function(__iucv_cleanup_pathid, NULL, 0, 1);
+       spin_lock_irq(&iucv_work_lock);
+       list_for_each_entry_safe(p, n, &iucv_work_queue, list) {
+               /* Remove work items for pathid except connection pending */
+               if (p->data.ippathid == pathid && p->data.iptype != 0x01) {
+                       list_del(&p->list);
+                       kfree(p);
+               }
+       }
+       spin_unlock_irq(&iucv_work_lock);
+}
+
+/**
+ * iucv_register:
+ * @handler: address of iucv handler structure
+ * @smp: != 0 indicates that the handler can deal with out of order messages
+ *
+ * Registers a driver with IUCV.
+ *
+ * Returns 0 on success, -ENOMEM if the memory allocation for the pathid
+ * table failed, or -EIO if IUCV_DECLARE_BUFFER failed on all cpus.
+ */
+int iucv_register(struct iucv_handler *handler, int smp)
+{
+       int rc;
+
+       if (!iucv_available)
+               return -ENOSYS;
+       mutex_lock(&iucv_register_mutex);
+       if (!smp)
+               iucv_nonsmp_handler++;
+       if (list_empty(&iucv_handler_list)) {
+               rc = iucv_enable();
+               if (rc)
+                       goto out_mutex;
+       } else if (!smp && iucv_nonsmp_handler == 1)
+               iucv_setmask_up();
+       INIT_LIST_HEAD(&handler->paths);
+
+       spin_lock_irq(&iucv_table_lock);
+       list_add_tail(&handler->list, &iucv_handler_list);
+       spin_unlock_irq(&iucv_table_lock);
+       rc = 0;
+out_mutex:
+       mutex_unlock(&iucv_register_mutex);
+       return rc;
+}
+
+/**
+ * iucv_unregister
+ * @handler:  address of iucv handler structure
+ * @smp: != 0 indicates that the handler can deal with out of order messages
+ *
+ * Unregister driver from IUCV.
+ */
+void iucv_unregister(struct iucv_handler *handler, int smp)
+{
+       struct iucv_path *p, *n;
+
+       mutex_lock(&iucv_register_mutex);
+       spin_lock_bh(&iucv_table_lock);
+       /* Remove handler from the iucv_handler_list. */
+       list_del_init(&handler->list);
+       /* Sever all pathids still refering to the handler. */
+       list_for_each_entry_safe(p, n, &handler->paths, list) {
+               iucv_sever_pathid(p->pathid, NULL);
+               iucv_path_table[p->pathid] = NULL;
+               list_del(&p->list);
+               iucv_cleanup_pathid(p->pathid);
+               iucv_path_free(p);
+       }
+       spin_unlock_bh(&iucv_table_lock);
+       if (!smp)
+               iucv_nonsmp_handler--;
+       if (list_empty(&iucv_handler_list))
+               iucv_disable();
+       else if (!smp && iucv_nonsmp_handler == 0)
+               iucv_setmask_mp();
+       mutex_unlock(&iucv_register_mutex);
+}
+
+/**
+ * iucv_path_accept
+ * @path: address of iucv path structure
+ * @handler: address of iucv handler structure
+ * @userdata: 16 bytes of data reflected to the communication partner
+ * @private: private data passed to interrupt handlers for this path
+ *
+ * This function is issued after the user received a connection pending
+ * external interrupt and now wishes to complete the IUCV communication path.
+ *
+ * Returns the result of the CP IUCV call.
+ */
+int iucv_path_accept(struct iucv_path *path, struct iucv_handler *handler,
+                    u8 userdata[16], void *private)
+{
+       union iucv_param *parm;
+       int rc;
+
+       local_bh_disable();
+       /* Prepare parameter block. */
+       parm = percpu_ptr(iucv_param, smp_processor_id());
+       memset(parm, 0, sizeof(union iucv_param));
+       parm->ctrl.ippathid = path->pathid;
+       parm->ctrl.ipmsglim = path->msglim;
+       if (userdata)
+               memcpy(parm->ctrl.ipuser, userdata, sizeof(parm->ctrl.ipuser));
+       parm->ctrl.ipflags1 = path->flags;
+
+       rc = iucv_call_b2f0(IUCV_ACCEPT, parm);
+       if (!rc) {
+               path->private = private;
+               path->msglim = parm->ctrl.ipmsglim;
+               path->flags = parm->ctrl.ipflags1;
+       }
+       local_bh_enable();
+       return rc;
+}
+
+/**
+ * iucv_path_connect
+ * @path: address of iucv path structure
+ * @handler: address of iucv handler structure
+ * @userid: 8-byte user identification
+ * @system: 8-byte target system identification
+ * @userdata: 16 bytes of data reflected to the communication partner
+ * @private: private data passed to interrupt handlers for this path
+ *
+ * This function establishes an IUCV path. Although the connect may complete
+ * successfully, you are not able to use the path until you receive an IUCV
+ * Connection Complete external interrupt.
+ *
+ * Returns the result of the CP IUCV call.
+ */
+int iucv_path_connect(struct iucv_path *path, struct iucv_handler *handler,
+                     u8 userid[8], u8 system[8], u8 userdata[16],
+                     void *private)
+{
+       union iucv_param *parm;
+       int rc;
+
+       preempt_disable();
+       if (iucv_tasklet_cpu != smp_processor_id())
+               spin_lock_bh(&iucv_table_lock);
+       parm = percpu_ptr(iucv_param, smp_processor_id());
+       memset(parm, 0, sizeof(union iucv_param));
+       parm->ctrl.ipmsglim = path->msglim;
+       parm->ctrl.ipflags1 = path->flags;
+       if (userid) {
+               memcpy(parm->ctrl.ipvmid, userid, sizeof(parm->ctrl.ipvmid));
+               ASCEBC(parm->ctrl.ipvmid, sizeof(parm->ctrl.ipvmid));
+               EBC_TOUPPER(parm->ctrl.ipvmid, sizeof(parm->ctrl.ipvmid));
+       }
+       if (system) {
+               memcpy(parm->ctrl.iptarget, system,
+                      sizeof(parm->ctrl.iptarget));
+               ASCEBC(parm->ctrl.iptarget, sizeof(parm->ctrl.iptarget));
+               EBC_TOUPPER(parm->ctrl.iptarget, sizeof(parm->ctrl.iptarget));
+       }
+       if (userdata)
+               memcpy(parm->ctrl.ipuser, userdata, sizeof(parm->ctrl.ipuser));
+
+       rc = iucv_call_b2f0(IUCV_CONNECT, parm);
+       if (!rc) {
+               if (parm->ctrl.ippathid < iucv_max_pathid) {
+                       path->pathid = parm->ctrl.ippathid;
+                       path->msglim = parm->ctrl.ipmsglim;
+                       path->flags = parm->ctrl.ipflags1;
+                       path->handler = handler;
+                       path->private = private;
+                       list_add_tail(&path->list, &handler->paths);
+                       iucv_path_table[path->pathid] = path;
+               } else {
+                       iucv_sever_pathid(parm->ctrl.ippathid,
+                                         iucv_error_pathid);
+                       rc = -EIO;
+               }
+       }
+       if (iucv_tasklet_cpu != smp_processor_id())
+               spin_unlock_bh(&iucv_table_lock);
+       preempt_enable();
+       return rc;
+}
+
+/**
+ * iucv_path_quiesce:
+ * @path: address of iucv path structure
+ * @userdata: 16 bytes of data reflected to the communication partner
+ *
+ * This function temporarily suspends incoming messages on an IUCV path.
+ * You can later reactivate the path by invoking the iucv_resume function.
+ *
+ * Returns the result from the CP IUCV call.
+ */
+int iucv_path_quiesce(struct iucv_path *path, u8 userdata[16])
+{
+       union iucv_param *parm;
+       int rc;
+
+       local_bh_disable();
+       parm = percpu_ptr(iucv_param, smp_processor_id());
+       memset(parm, 0, sizeof(union iucv_param));
+       if (userdata)
+               memcpy(parm->ctrl.ipuser, userdata, sizeof(parm->ctrl.ipuser));
+       parm->ctrl.ippathid = path->pathid;
+       rc = iucv_call_b2f0(IUCV_QUIESCE, parm);
+       local_bh_enable();
+       return rc;
+}
+
+/**
+ * iucv_path_resume:
+ * @path: address of iucv path structure
+ * @userdata: 16 bytes of data reflected to the communication partner
+ *
+ * This function resumes incoming messages on an IUCV path that has
+ * been stopped with iucv_path_quiesce.
+ *
+ * Returns the result from the CP IUCV call.
+ */
+int iucv_path_resume(struct iucv_path *path, u8 userdata[16])
+{
+       union iucv_param *parm;
+       int rc;
+
+       local_bh_disable();
+       parm = percpu_ptr(iucv_param, smp_processor_id());
+       memset(parm, 0, sizeof(union iucv_param));
+       if (userdata)
+               memcpy(parm->ctrl.ipuser, userdata, sizeof(parm->ctrl.ipuser));
+       parm->ctrl.ippathid = path->pathid;
+       rc = iucv_call_b2f0(IUCV_RESUME, parm);
+       local_bh_enable();
+       return rc;
+}
+
+/**
+ * iucv_path_sever
+ * @path: address of iucv path structure
+ * @userdata: 16 bytes of data reflected to the communication partner
+ *
+ * This function terminates an IUCV path.
+ *
+ * Returns the result from the CP IUCV call.
+ */
+int iucv_path_sever(struct iucv_path *path, u8 userdata[16])
+{
+       int rc;
+
+
+       preempt_disable();
+       if (iucv_tasklet_cpu != smp_processor_id())
+               spin_lock_bh(&iucv_table_lock);
+       rc = iucv_sever_pathid(path->pathid, userdata);
+       if (!rc) {
+               iucv_path_table[path->pathid] = NULL;
+               list_del_init(&path->list);
+               iucv_cleanup_pathid(path->pathid);
+       }
+       if (iucv_tasklet_cpu != smp_processor_id())
+               spin_unlock_bh(&iucv_table_lock);
+       preempt_enable();
+       return rc;
+}
+
+/**
+ * iucv_message_purge
+ * @path: address of iucv path structure
+ * @msg: address of iucv msg structure
+ * @srccls: source class of message
+ *
+ * Cancels a message you have sent.
+ *
+ * Returns the result from the CP IUCV call.
+ */
+int iucv_message_purge(struct iucv_path *path, struct iucv_message *msg,
+                      u32 srccls)
+{
+       union iucv_param *parm;
+       int rc;
+
+       local_bh_disable();
+       parm = percpu_ptr(iucv_param, smp_processor_id());
+       memset(parm, 0, sizeof(union iucv_param));
+       parm->purge.ippathid = path->pathid;
+       parm->purge.ipmsgid = msg->id;
+       parm->purge.ipsrccls = srccls;
+       parm->purge.ipflags1 = IUCV_IPSRCCLS | IUCV_IPFGMID | IUCV_IPFGPID;
+       rc = iucv_call_b2f0(IUCV_PURGE, parm);
+       if (!rc) {
+               msg->audit = (*(u32 *) &parm->purge.ipaudit) >> 8;
+               msg->tag = parm->purge.ipmsgtag;
+       }
+       local_bh_enable();
+       return rc;
+}
+
+/**
+ * iucv_message_receive
+ * @path: address of iucv path structure
+ * @msg: address of iucv msg structure
+ * @flags: how the message is received (IUCV_IPBUFLST)
+ * @buffer: address of data buffer or address of struct iucv_array
+ * @size: length of data buffer
+ * @residual:
+ *
+ * This function receives messages that are being sent to you over
+ * established paths. This function will deal with RMDATA messages
+ * embedded in struct iucv_message as well.
+ *
+ * Returns the result from the CP IUCV call.
+ */
+int iucv_message_receive(struct iucv_path *path, struct iucv_message *msg,
+                        u8 flags, void *buffer, size_t size, size_t *residual)
+{
+       union iucv_param *parm;
+       struct iucv_array *array;
+       u8 *rmmsg;
+       size_t copy;
+       int rc;
+
+       if (msg->flags & IUCV_IPRMDATA) {
+               /*
+                * Message is 8 bytes long and has been stored to the
+                * message descriptor itself.
+                */
+               rc = (size < 8) ? 5 : 0;
+               if (residual)
+                       *residual = abs(size - 8);
+               rmmsg = msg->rmmsg;
+               if (flags & IUCV_IPBUFLST) {
+                       /* Copy to struct iucv_array. */
+                       size = (size < 8) ? size : 8;
+                       for (array = buffer; size > 0; array++) {
+                               copy = min_t(size_t, size, array->length);
+                               memcpy((u8 *)(addr_t) array->address,
+                                      rmmsg, copy);
+                               rmmsg += copy;
+                               size -= copy;
+                       }
+               } else {
+                       /* Copy to direct buffer. */
+                       memcpy(buffer, rmmsg, min_t(size_t, size, 8));
+               }
+               return 0;
+       }
+
+       local_bh_disable();
+       parm = percpu_ptr(iucv_param, smp_processor_id());
+       memset(parm, 0, sizeof(union iucv_param));
+       parm->db.ipbfadr1 = (u32)(addr_t) buffer;
+       parm->db.ipbfln1f = (u32) size;
+       parm->db.ipmsgid = msg->id;
+       parm->db.ippathid = path->pathid;
+       parm->db.iptrgcls = msg->class;
+       parm->db.ipflags1 = (flags | IUCV_IPFGPID |
+                            IUCV_IPFGMID | IUCV_IPTRGCLS);
+       rc = iucv_call_b2f0(IUCV_RECEIVE, parm);
+       if (!rc || rc == 5) {
+               msg->flags = parm->db.ipflags1;
+               if (residual)
+                       *residual = parm->db.ipbfln1f;
+       }
+       local_bh_enable();
+       return rc;
+}
+
+/**
+ * iucv_message_reject
+ * @path: address of iucv path structure
+ * @msg: address of iucv msg structure
+ *
+ * The reject function refuses a specified message. Between the time you
+ * are notified of a message and the time that you complete the message,
+ * the message may be rejected.
+ *
+ * Returns the result from the CP IUCV call.
+ */
+int iucv_message_reject(struct iucv_path *path, struct iucv_message *msg)
+{
+       union iucv_param *parm;
+       int rc;
+
+       local_bh_disable();
+       parm = percpu_ptr(iucv_param, smp_processor_id());
+       memset(parm, 0, sizeof(union iucv_param));
+       parm->db.ippathid = path->pathid;
+       parm->db.ipmsgid = msg->id;
+       parm->db.iptrgcls = msg->class;
+       parm->db.ipflags1 = (IUCV_IPTRGCLS | IUCV_IPFGMID | IUCV_IPFGPID);
+       rc = iucv_call_b2f0(IUCV_REJECT, parm);
+       local_bh_enable();
+       return rc;
+}
+
+/**
+ * iucv_message_reply
+ * @path: address of iucv path structure
+ * @msg: address of iucv msg structure
+ * @flags: how the reply is sent (IUCV_IPRMDATA, IUCV_IPPRTY, IUCV_IPBUFLST)
+ * @reply: address of reply data buffer or address of struct iucv_array
+ * @size: length of reply data buffer
+ *
+ * This function responds to the two-way messages that you receive. You
+ * must identify completely the message to which you wish to reply. ie,
+ * pathid, msgid, and trgcls. Prmmsg signifies the data is moved into
+ * the parameter list.
+ *
+ * Returns the result from the CP IUCV call.
+ */
+int iucv_message_reply(struct iucv_path *path, struct iucv_message *msg,
+                      u8 flags, void *reply, size_t size)
+{
+       union iucv_param *parm;
+       int rc;
+
+       local_bh_disable();
+       parm = percpu_ptr(iucv_param, smp_processor_id());
+       memset(parm, 0, sizeof(union iucv_param));
+       if (flags & IUCV_IPRMDATA) {
+               parm->dpl.ippathid = path->pathid;
+               parm->dpl.ipflags1 = flags;
+               parm->dpl.ipmsgid = msg->id;
+               parm->dpl.iptrgcls = msg->class;
+               memcpy(parm->dpl.iprmmsg, reply, min_t(size_t, size, 8));
+       } else {
+               parm->db.ipbfadr1 = (u32)(addr_t) reply;
+               parm->db.ipbfln1f = (u32) size;
+               parm->db.ippathid = path->pathid;
+               parm->db.ipflags1 = flags;
+               parm->db.ipmsgid = msg->id;
+               parm->db.iptrgcls = msg->class;
+       }
+       rc = iucv_call_b2f0(IUCV_REPLY, parm);
+       local_bh_enable();
+       return rc;
+}
+
+/**
+ * iucv_message_send
+ * @path: address of iucv path structure
+ * @msg: address of iucv msg structure
+ * @flags: how the message is sent (IUCV_IPRMDATA, IUCV_IPPRTY, IUCV_IPBUFLST)
+ * @srccls: source class of message
+ * @buffer: address of send buffer or address of struct iucv_array
+ * @size: length of send buffer
+ *
+ * This function transmits data to another application. Data to be
+ * transmitted is in a buffer and this is a one-way message and the
+ * receiver will not reply to the message.
+ *
+ * Returns the result from the CP IUCV call.
+ */
+int iucv_message_send(struct iucv_path *path, struct iucv_message *msg,
+                     u8 flags, u32 srccls, void *buffer, size_t size)
+{
+       union iucv_param *parm;
+       int rc;
+
+       local_bh_disable();
+       parm = percpu_ptr(iucv_param, smp_processor_id());
+       memset(parm, 0, sizeof(union iucv_param));
+       if (flags & IUCV_IPRMDATA) {
+               /* Message of 8 bytes can be placed into the parameter list. */
+               parm->dpl.ippathid = path->pathid;
+               parm->dpl.ipflags1 = flags | IUCV_IPNORPY;
+               parm->dpl.iptrgcls = msg->class;
+               parm->dpl.ipsrccls = srccls;
+               parm->dpl.ipmsgtag = msg->tag;
+               memcpy(parm->dpl.iprmmsg, buffer, 8);
+       } else {
+               parm->db.ipbfadr1 = (u32)(addr_t) buffer;
+               parm->db.ipbfln1f = (u32) size;
+               parm->db.ippathid = path->pathid;
+               parm->db.ipflags1 = flags | IUCV_IPNORPY;
+               parm->db.iptrgcls = msg->class;
+               parm->db.ipsrccls = srccls;
+               parm->db.ipmsgtag = msg->tag;
+       }
+       rc = iucv_call_b2f0(IUCV_SEND, parm);
+       if (!rc)
+               msg->id = parm->db.ipmsgid;
+       local_bh_enable();
+       return rc;
+}
+
+/**
+ * iucv_message_send2way
+ * @path: address of iucv path structure
+ * @msg: address of iucv msg structure
+ * @flags: how the message is sent and the reply is received
+ *        (IUCV_IPRMDATA, IUCV_IPBUFLST, IUCV_IPPRTY, IUCV_ANSLST)
+ * @srccls: source class of message
+ * @buffer: address of send buffer or address of struct iucv_array
+ * @size: length of send buffer
+ * @ansbuf: address of answer buffer or address of struct iucv_array
+ * @asize: size of reply buffer
+ *
+ * This function transmits data to another application. Data to be
+ * transmitted is in a buffer. The receiver of the send is expected to
+ * reply to the message and a buffer is provided into which IUCV moves
+ * the reply to this message.
+ *
+ * Returns the result from the CP IUCV call.
+ */
+int iucv_message_send2way(struct iucv_path *path, struct iucv_message *msg,
+                         u8 flags, u32 srccls, void *buffer, size_t size,
+                         void *answer, size_t asize, size_t *residual)
+{
+       union iucv_param *parm;
+       int rc;
+
+       local_bh_disable();
+       parm = percpu_ptr(iucv_param, smp_processor_id());
+       memset(parm, 0, sizeof(union iucv_param));
+       if (flags & IUCV_IPRMDATA) {
+               parm->dpl.ippathid = path->pathid;
+               parm->dpl.ipflags1 = path->flags;       /* priority message */
+               parm->dpl.iptrgcls = msg->class;
+               parm->dpl.ipsrccls = srccls;
+               parm->dpl.ipmsgtag = msg->tag;
+               parm->dpl.ipbfadr2 = (u32)(addr_t) answer;
+               parm->dpl.ipbfln2f = (u32) asize;
+               memcpy(parm->dpl.iprmmsg, buffer, 8);
+       } else {
+               parm->db.ippathid = path->pathid;
+               parm->db.ipflags1 = path->flags;        /* priority message */
+               parm->db.iptrgcls = msg->class;
+               parm->db.ipsrccls = srccls;
+               parm->db.ipmsgtag = msg->tag;
+               parm->db.ipbfadr1 = (u32)(addr_t) buffer;
+               parm->db.ipbfln1f = (u32) size;
+               parm->db.ipbfadr2 = (u32)(addr_t) answer;
+               parm->db.ipbfln2f = (u32) asize;
+       }
+       rc = iucv_call_b2f0(IUCV_SEND, parm);
+       if (!rc)
+               msg->id = parm->db.ipmsgid;
+       local_bh_enable();
+       return rc;
+}
+
+/**
+ * iucv_path_pending
+ * @data: Pointer to external interrupt buffer
+ *
+ * Process connection pending work item. Called from tasklet while holding
+ * iucv_table_lock.
+ */
+struct iucv_path_pending {
+       u16 ippathid;
+       u8  ipflags1;
+       u8  iptype;
+       u16 ipmsglim;
+       u16 res1;
+       u8  ipvmid[8];
+       u8  ipuser[16];
+       u32 res3;
+       u8  ippollfg;
+       u8  res4[3];
+} __attribute__ ((packed));
+
+static void iucv_path_pending(struct iucv_irq_data *data)
+{
+       struct iucv_path_pending *ipp = (void *) data;
+       struct iucv_handler *handler;
+       struct iucv_path *path;
+       char *error;
+
+       BUG_ON(iucv_path_table[ipp->ippathid]);
+       /* New pathid, handler found. Create a new path struct. */
+       error = iucv_error_no_memory;
+       path = iucv_path_alloc(ipp->ipmsglim, ipp->ipflags1, GFP_ATOMIC);
+       if (!path)
+               goto out_sever;
+       path->pathid = ipp->ippathid;
+       iucv_path_table[path->pathid] = path;
+       EBCASC(ipp->ipvmid, 8);
+
+       /* Call registered handler until one is found that wants the path. */
+       list_for_each_entry(handler, &iucv_handler_list, list) {
+               if (!handler->path_pending)
+                       continue;
+               /*
+                * Add path to handler to allow a call to iucv_path_sever
+                * inside the path_pending function. If the handler returns
+                * an error remove the path from the handler again.
+                */
+               list_add(&path->list, &handler->paths);
+               path->handler = handler;
+               if (!handler->path_pending(path, ipp->ipvmid, ipp->ipuser))
+                       return;
+               list_del(&path->list);
+               path->handler = NULL;
+       }
+       /* No handler wanted the path. */
+       iucv_path_table[path->pathid] = NULL;
+       iucv_path_free(path);
+       error = iucv_error_no_listener;
+out_sever:
+       iucv_sever_pathid(ipp->ippathid, error);
+}
+
+/**
+ * iucv_path_complete
+ * @data: Pointer to external interrupt buffer
+ *
+ * Process connection complete work item. Called from tasklet while holding
+ * iucv_table_lock.
+ */
+struct iucv_path_complete {
+       u16 ippathid;
+       u8  ipflags1;
+       u8  iptype;
+       u16 ipmsglim;
+       u16 res1;
+       u8  res2[8];
+       u8  ipuser[16];
+       u32 res3;
+       u8  ippollfg;
+       u8  res4[3];
+} __attribute__ ((packed));
+
+static void iucv_path_complete(struct iucv_irq_data *data)
+{
+       struct iucv_path_complete *ipc = (void *) data;
+       struct iucv_path *path = iucv_path_table[ipc->ippathid];
+
+       BUG_ON(!path || !path->handler);
+       if (path->handler->path_complete)
+               path->handler->path_complete(path, ipc->ipuser);
+}
+
+/**
+ * iucv_path_severed
+ * @data: Pointer to external interrupt buffer
+ *
+ * Process connection severed work item. Called from tasklet while holding
+ * iucv_table_lock.
+ */
+struct iucv_path_severed {
+       u16 ippathid;
+       u8  res1;
+       u8  iptype;
+       u32 res2;
+       u8  res3[8];
+       u8  ipuser[16];
+       u32 res4;
+       u8  ippollfg;
+       u8  res5[3];
+} __attribute__ ((packed));
+
+static void iucv_path_severed(struct iucv_irq_data *data)
+{
+       struct iucv_path_severed *ips = (void *) data;
+       struct iucv_path *path = iucv_path_table[ips->ippathid];
+
+       BUG_ON(!path || !path->handler);
+       if (path->handler->path_severed)
+               path->handler->path_severed(path, ips->ipuser);
+       else {
+               iucv_sever_pathid(path->pathid, NULL);
+               iucv_path_table[path->pathid] = NULL;
+               list_del_init(&path->list);
+               iucv_cleanup_pathid(path->pathid);
+               iucv_path_free(path);
+       }
+}
+
+/**
+ * iucv_path_quiesced
+ * @data: Pointer to external interrupt buffer
+ *
+ * Process connection quiesced work item. Called from tasklet while holding
+ * iucv_table_lock.
+ */
+struct iucv_path_quiesced {
+       u16 ippathid;
+       u8  res1;
+       u8  iptype;
+       u32 res2;
+       u8  res3[8];
+       u8  ipuser[16];
+       u32 res4;
+       u8  ippollfg;
+       u8  res5[3];
+} __attribute__ ((packed));
+
+static void iucv_path_quiesced(struct iucv_irq_data *data)
+{
+       struct iucv_path_quiesced *ipq = (void *) data;
+       struct iucv_path *path = iucv_path_table[ipq->ippathid];
+
+       BUG_ON(!path || !path->handler);
+       if (path->handler->path_quiesced)
+               path->handler->path_quiesced(path, ipq->ipuser);
+}
+
+/**
+ * iucv_path_resumed
+ * @data: Pointer to external interrupt buffer
+ *
+ * Process connection resumed work item. Called from tasklet while holding
+ * iucv_table_lock.
+ */
+struct iucv_path_resumed {
+       u16 ippathid;
+       u8  res1;
+       u8  iptype;
+       u32 res2;
+       u8  res3[8];
+       u8  ipuser[16];
+       u32 res4;
+       u8  ippollfg;
+       u8  res5[3];
+} __attribute__ ((packed));
+
+static void iucv_path_resumed(struct iucv_irq_data *data)
+{
+       struct iucv_path_resumed *ipr = (void *) data;
+       struct iucv_path *path = iucv_path_table[ipr->ippathid];
+
+       BUG_ON(!path || !path->handler);
+       if (path->handler->path_resumed)
+               path->handler->path_resumed(path, ipr->ipuser);
+}
+
+/**
+ * iucv_message_complete
+ * @data: Pointer to external interrupt buffer
+ *
+ * Process message complete work item. Called from tasklet while holding
+ * iucv_table_lock.
+ */
+struct iucv_message_complete {
+       u16 ippathid;
+       u8  ipflags1;
+       u8  iptype;
+       u32 ipmsgid;
+       u32 ipaudit;
+       u8  iprmmsg[8];
+       u32 ipsrccls;
+       u32 ipmsgtag;
+       u32 res;
+       u32 ipbfln2f;
+       u8  ippollfg;
+       u8  res2[3];
+} __attribute__ ((packed));
+
+static void iucv_message_complete(struct iucv_irq_data *data)
+{
+       struct iucv_message_complete *imc = (void *) data;
+       struct iucv_path *path = iucv_path_table[imc->ippathid];
+       struct iucv_message msg;
+
+       BUG_ON(!path || !path->handler);
+       if (path->handler->message_complete) {
+               msg.flags = imc->ipflags1;
+               msg.id = imc->ipmsgid;
+               msg.audit = imc->ipaudit;
+               memcpy(msg.rmmsg, imc->iprmmsg, 8);
+               msg.class = imc->ipsrccls;
+               msg.tag = imc->ipmsgtag;
+               msg.length = imc->ipbfln2f;
+               path->handler->message_complete(path, &msg);
+       }
+}
+
+/**
+ * iucv_message_pending
+ * @data: Pointer to external interrupt buffer
+ *
+ * Process message pending work item. Called from tasklet while holding
+ * iucv_table_lock.
+ */
+struct iucv_message_pending {
+       u16 ippathid;
+       u8  ipflags1;
+       u8  iptype;
+       u32 ipmsgid;
+       u32 iptrgcls;
+       union {
+               u32 iprmmsg1_u32;
+               u8  iprmmsg1[4];
+       } ln1msg1;
+       union {
+               u32 ipbfln1f;
+               u8  iprmmsg2[4];
+       } ln1msg2;
+       u32 res1[3];
+       u32 ipbfln2f;
+       u8  ippollfg;
+       u8  res2[3];
+} __attribute__ ((packed));
+
+static void iucv_message_pending(struct iucv_irq_data *data)
+{
+       struct iucv_message_pending *imp = (void *) data;
+       struct iucv_path *path = iucv_path_table[imp->ippathid];
+       struct iucv_message msg;
+
+       BUG_ON(!path || !path->handler);
+       if (path->handler->message_pending) {
+               msg.flags = imp->ipflags1;
+               msg.id = imp->ipmsgid;
+               msg.class = imp->iptrgcls;
+               if (imp->ipflags1 & IUCV_IPRMDATA) {
+                       memcpy(msg.rmmsg, imp->ln1msg1.iprmmsg1, 8);
+                       msg.length = 8;
+               } else
+                       msg.length = imp->ln1msg2.ipbfln1f;
+               msg.reply_size = imp->ipbfln2f;
+               path->handler->message_pending(path, &msg);
+       }
+}
+
+/**
+ * iucv_tasklet_handler:
+ *
+ * This tasklet loops over the queue of irq buffers created by
+ * iucv_external_interrupt, calls the appropriate action handler
+ * and then frees the buffer.
+ */
+static void iucv_tasklet_handler(unsigned long ignored)
+{
+       typedef void iucv_irq_fn(struct iucv_irq_data *);
+       static iucv_irq_fn *irq_fn[] = {
+               [0x01] = iucv_path_pending,
+               [0x02] = iucv_path_complete,
+               [0x03] = iucv_path_severed,
+               [0x04] = iucv_path_quiesced,
+               [0x05] = iucv_path_resumed,
+               [0x06] = iucv_message_complete,
+               [0x07] = iucv_message_complete,
+               [0x08] = iucv_message_pending,
+               [0x09] = iucv_message_pending,
+       };
+       struct iucv_work *p;
+
+       /* Serialize tasklet, iucv_path_sever and iucv_path_connect. */
+       spin_lock(&iucv_table_lock);
+       iucv_tasklet_cpu = smp_processor_id();
+
+       spin_lock_irq(&iucv_work_lock);
+       while (!list_empty(&iucv_work_queue)) {
+               p = list_entry(iucv_work_queue.next, struct iucv_work, list);
+               list_del_init(&p->list);
+               spin_unlock_irq(&iucv_work_lock);
+               irq_fn[p->data.iptype](&p->data);
+               kfree(p);
+               spin_lock_irq(&iucv_work_lock);
+       }
+       spin_unlock_irq(&iucv_work_lock);
+
+       iucv_tasklet_cpu = -1;
+       spin_unlock(&iucv_table_lock);
+}
+
+/**
+ * iucv_external_interrupt
+ * @code: irq code
+ *
+ * Handles external interrupts coming in from CP.
+ * Places the interrupt buffer on a queue and schedules iucv_tasklet_handler().
+ */
+static void iucv_external_interrupt(u16 code)
+{
+       struct iucv_irq_data *p;
+       struct iucv_work *work;
+
+       p = percpu_ptr(iucv_irq_data, smp_processor_id());
+       if (p->ippathid >= iucv_max_pathid) {
+               printk(KERN_WARNING "iucv_do_int: Got interrupt with "
+                      "pathid %d > max_connections (%ld)\n",
+                      p->ippathid, iucv_max_pathid - 1);
+               iucv_sever_pathid(p->ippathid, iucv_error_no_listener);
+               return;
+       }
+       if (p->iptype  < 0x01 || p->iptype > 0x09) {
+               printk(KERN_ERR "iucv_do_int: unknown iucv interrupt\n");
+               return;
+       }
+       work = kmalloc(sizeof(struct iucv_work), GFP_ATOMIC);
+       if (!work) {
+               printk(KERN_WARNING "iucv_external_interrupt: out of memory\n");
+               return;
+       }
+       memcpy(&work->data, p, sizeof(work->data));
+       spin_lock(&iucv_work_lock);
+       list_add_tail(&work->list, &iucv_work_queue);
+       spin_unlock(&iucv_work_lock);
+       tasklet_schedule(&iucv_tasklet);
+}
+
+/**
+ * iucv_init
+ *
+ * Allocates and initializes various data structures.
+ */
+static int iucv_init(void)
+{
+       int rc;
+
+       if (!MACHINE_IS_VM) {
+               rc = -EPROTONOSUPPORT;
+               goto out;
+       }
+       rc = iucv_query_maxconn();
+       if (rc)
+               goto out;
+       rc = register_external_interrupt (0x4000, iucv_external_interrupt);
+       if (rc)
+               goto out;
+       rc = bus_register(&iucv_bus);
+       if (rc)
+               goto out_int;
+       iucv_root = s390_root_dev_register("iucv");
+       if (IS_ERR(iucv_root)) {
+               rc = PTR_ERR(iucv_root);
+               goto out_bus;
+       }
+       /* Note: GFP_DMA used used to get memory below 2G */
+       iucv_irq_data = percpu_alloc(sizeof(struct iucv_irq_data),
+                                    GFP_KERNEL|GFP_DMA);
+       if (!iucv_irq_data) {
+               rc = -ENOMEM;
+               goto out_root;
+       }
+       /* Allocate parameter blocks. */
+       iucv_param = percpu_alloc(sizeof(union iucv_param),
+                                 GFP_KERNEL|GFP_DMA);
+       if (!iucv_param) {
+               rc = -ENOMEM;
+               goto out_extint;
+       }
+       register_hotcpu_notifier(&iucv_cpu_notifier);
+       ASCEBC(iucv_error_no_listener, 16);
+       ASCEBC(iucv_error_no_memory, 16);
+       ASCEBC(iucv_error_pathid, 16);
+       iucv_available = 1;
+       return 0;
+
+out_extint:
+       percpu_free(iucv_irq_data);
+out_root:
+       s390_root_dev_unregister(iucv_root);
+out_bus:
+       bus_unregister(&iucv_bus);
+out_int:
+       unregister_external_interrupt(0x4000, iucv_external_interrupt);
+out:
+       return rc;
+}
+
+/**
+ * iucv_exit
+ *
+ * Frees everything allocated from iucv_init.
+ */
+static void iucv_exit(void)
+{
+       struct iucv_work *p, *n;
+
+       spin_lock_irq(&iucv_work_lock);
+       list_for_each_entry_safe(p, n, &iucv_work_queue, list)
+               kfree(p);
+       spin_unlock_irq(&iucv_work_lock);
+       unregister_hotcpu_notifier(&iucv_cpu_notifier);
+       percpu_free(iucv_param);
+       percpu_free(iucv_irq_data);
+       s390_root_dev_unregister(iucv_root);
+       bus_unregister(&iucv_bus);
+       unregister_external_interrupt(0x4000, iucv_external_interrupt);
+}
+
+subsys_initcall(iucv_init);
+module_exit(iucv_exit);
+
+/**
+ * Export all public stuff
+ */
+EXPORT_SYMBOL (iucv_bus);
+EXPORT_SYMBOL (iucv_root);
+EXPORT_SYMBOL (iucv_register);
+EXPORT_SYMBOL (iucv_unregister);
+EXPORT_SYMBOL (iucv_path_accept);
+EXPORT_SYMBOL (iucv_path_connect);
+EXPORT_SYMBOL (iucv_path_quiesce);
+EXPORT_SYMBOL (iucv_path_sever);
+EXPORT_SYMBOL (iucv_message_purge);
+EXPORT_SYMBOL (iucv_message_receive);
+EXPORT_SYMBOL (iucv_message_reject);
+EXPORT_SYMBOL (iucv_message_reply);
+EXPORT_SYMBOL (iucv_message_send);
+EXPORT_SYMBOL (iucv_message_send2way);
+
+MODULE_AUTHOR("(C) 2001 IBM Corp. by Fritz Elfert (felfert@millenux.com)");
+MODULE_DESCRIPTION("Linux for S/390 IUCV lowlevel driver");
+MODULE_LICENSE("GPL");
index 5dd5094659a186655d88a50a44ba2849a44bc776..f3a026ff9b2cd3b1e7176fc6a1a405dd55d72f79 100644 (file)
@@ -152,7 +152,7 @@ static int pfkey_create(struct socket *sock, int protocol)
        sk = sk_alloc(PF_KEY, GFP_KERNEL, &key_proto, 1);
        if (sk == NULL)
                goto out;
-       
+
        sock->ops = &pfkey_ops;
        sock_init_data(sock, sk);
 
@@ -487,7 +487,7 @@ static int parse_exthdrs(struct sk_buff *skb, struct sadb_msg *hdr, void **ext_h
                            ext_type == SADB_X_EXT_NAT_T_OA) {
                                if (verify_address_len(p))
                                        return -EINVAL;
-                       }                               
+                       }
                        if (ext_type == SADB_X_EXT_SEC_CTX) {
                                if (verify_sec_ctx_len(p))
                                        return -EINVAL;
@@ -556,12 +556,12 @@ static int pfkey_sadb_addr2xfrm_addr(struct sadb_address *addr,
 {
        switch (((struct sockaddr*)(addr + 1))->sa_family) {
        case AF_INET:
-               xaddr->a4 = 
+               xaddr->a4 =
                        ((struct sockaddr_in *)(addr + 1))->sin_addr.s_addr;
                return AF_INET;
 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
        case AF_INET6:
-               memcpy(xaddr->a6, 
+               memcpy(xaddr->a6,
                       &((struct sockaddr_in6 *)(addr + 1))->sin6_addr,
                       sizeof(struct in6_addr));
                return AF_INET6;
@@ -659,11 +659,11 @@ static struct sk_buff * pfkey_xfrm_state2msg(struct xfrm_state *x, int add_keys,
 
        /* base, SA, (lifetime (HSC),) address(SD), (address(P),)
           key(AE), (identity(SD),) (sensitivity)> */
-       size = sizeof(struct sadb_msg) +sizeof(struct sadb_sa) + 
+       size = sizeof(struct sadb_msg) +sizeof(struct sadb_sa) +
                sizeof(struct sadb_lifetime) +
                ((hsc & 1) ? sizeof(struct sadb_lifetime) : 0) +
                ((hsc & 2) ? sizeof(struct sadb_lifetime) : 0) +
-                       sizeof(struct sadb_address)*2 + 
+                       sizeof(struct sadb_address)*2 +
                                sockaddr_size*2 +
                                        sizeof(struct sadb_x_sa2);
 
@@ -685,13 +685,13 @@ static struct sk_buff * pfkey_xfrm_state2msg(struct xfrm_state *x, int add_keys,
 
        if (add_keys) {
                if (x->aalg && x->aalg->alg_key_len) {
-                       auth_key_size = 
-                               PFKEY_ALIGN8((x->aalg->alg_key_len + 7) / 8); 
+                       auth_key_size =
+                               PFKEY_ALIGN8((x->aalg->alg_key_len + 7) / 8);
                        size += sizeof(struct sadb_key) + auth_key_size;
                }
                if (x->ealg && x->ealg->alg_key_len) {
-                       encrypt_key_size = 
-                               PFKEY_ALIGN8((x->ealg->alg_key_len+7) / 8); 
+                       encrypt_key_size =
+                               PFKEY_ALIGN8((x->ealg->alg_key_len+7) / 8);
                        size += sizeof(struct sadb_key) + encrypt_key_size;
                }
        }
@@ -758,7 +758,7 @@ static struct sk_buff * pfkey_xfrm_state2msg(struct xfrm_state *x, int add_keys,
 
        /* hard time */
        if (hsc & 2) {
-               lifetime = (struct sadb_lifetime *)  skb_put(skb, 
+               lifetime = (struct sadb_lifetime *)  skb_put(skb,
                                                             sizeof(struct sadb_lifetime));
                lifetime->sadb_lifetime_len =
                        sizeof(struct sadb_lifetime)/sizeof(uint64_t);
@@ -770,7 +770,7 @@ static struct sk_buff * pfkey_xfrm_state2msg(struct xfrm_state *x, int add_keys,
        }
        /* soft time */
        if (hsc & 1) {
-               lifetime = (struct sadb_lifetime *)  skb_put(skb, 
+               lifetime = (struct sadb_lifetime *)  skb_put(skb,
                                                             sizeof(struct sadb_lifetime));
                lifetime->sadb_lifetime_len =
                        sizeof(struct sadb_lifetime)/sizeof(uint64_t);
@@ -791,16 +791,16 @@ static struct sk_buff * pfkey_xfrm_state2msg(struct xfrm_state *x, int add_keys,
        lifetime->sadb_lifetime_addtime = x->curlft.add_time;
        lifetime->sadb_lifetime_usetime = x->curlft.use_time;
        /* src address */
-       addr = (struct sadb_address*) skb_put(skb, 
+       addr = (struct sadb_address*) skb_put(skb,
                                              sizeof(struct sadb_address)+sockaddr_size);
-       addr->sadb_address_len = 
+       addr->sadb_address_len =
                (sizeof(struct sadb_address)+sockaddr_size)/
                        sizeof(uint64_t);
        addr->sadb_address_exttype = SADB_EXT_ADDRESS_SRC;
-       /* "if the ports are non-zero, then the sadb_address_proto field, 
-          normally zero, MUST be filled in with the transport 
+       /* "if the ports are non-zero, then the sadb_address_proto field,
+          normally zero, MUST be filled in with the transport
           protocol's number." - RFC2367 */
-       addr->sadb_address_proto = 0; 
+       addr->sadb_address_proto = 0;
        addr->sadb_address_reserved = 0;
        if (x->props.family == AF_INET) {
                addr->sadb_address_prefixlen = 32;
@@ -813,29 +813,29 @@ static struct sk_buff * pfkey_xfrm_state2msg(struct xfrm_state *x, int add_keys,
        }
 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
        else if (x->props.family == AF_INET6) {
-               addr->sadb_address_prefixlen = 128;
+               addr->sadb_address_prefixlen = 128;
 
                sin6 = (struct sockaddr_in6 *) (addr + 1);
                sin6->sin6_family = AF_INET6;
                sin6->sin6_port = 0;
                sin6->sin6_flowinfo = 0;
-               memcpy(&sin6->sin6_addr, x->props.saddr.a6,
+               memcpy(&sin6->sin6_addr, x->props.saddr.a6,
                       sizeof(struct in6_addr));
                sin6->sin6_scope_id = 0;
-       }
+       }
 #endif
        else
                BUG();
 
        /* dst address */
-       addr = (struct sadb_address*) skb_put(skb, 
+       addr = (struct sadb_address*) skb_put(skb,
                                              sizeof(struct sadb_address)+sockaddr_size);
-       addr->sadb_address_len = 
+       addr->sadb_address_len =
                (sizeof(struct sadb_address)+sockaddr_size)/
                        sizeof(uint64_t);
        addr->sadb_address_exttype = SADB_EXT_ADDRESS_DST;
-       addr->sadb_address_proto = 0; 
-       addr->sadb_address_prefixlen = 32; /* XXX */ 
+       addr->sadb_address_proto = 0;
+       addr->sadb_address_prefixlen = 32; /* XXX */
        addr->sadb_address_reserved = 0;
        if (x->props.family == AF_INET) {
                sin = (struct sockaddr_in *) (addr + 1);
@@ -845,9 +845,9 @@ static struct sk_buff * pfkey_xfrm_state2msg(struct xfrm_state *x, int add_keys,
                memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
 
                if (x->sel.saddr.a4 != x->props.saddr.a4) {
-                       addr = (struct sadb_address*) skb_put(skb, 
+                       addr = (struct sadb_address*) skb_put(skb,
                                sizeof(struct sadb_address)+sockaddr_size);
-                       addr->sadb_address_len = 
+                       addr->sadb_address_len =
                                (sizeof(struct sadb_address)+sockaddr_size)/
                                sizeof(uint64_t);
                        addr->sadb_address_exttype = SADB_EXT_ADDRESS_PROXY;
@@ -876,9 +876,9 @@ static struct sk_buff * pfkey_xfrm_state2msg(struct xfrm_state *x, int add_keys,
 
                if (memcmp (x->sel.saddr.a6, x->props.saddr.a6,
                            sizeof(struct in6_addr))) {
-                       addr = (struct sadb_address *) skb_put(skb, 
+                       addr = (struct sadb_address *) skb_put(skb,
                                sizeof(struct sadb_address)+sockaddr_size);
-                       addr->sadb_address_len = 
+                       addr->sadb_address_len =
                                (sizeof(struct sadb_address)+sockaddr_size)/
                                sizeof(uint64_t);
                        addr->sadb_address_exttype = SADB_EXT_ADDRESS_PROXY;
@@ -902,7 +902,7 @@ static struct sk_buff * pfkey_xfrm_state2msg(struct xfrm_state *x, int add_keys,
 
        /* auth key */
        if (add_keys && auth_key_size) {
-               key = (struct sadb_key *) skb_put(skb, 
+               key = (struct sadb_key *) skb_put(skb,
                                                  sizeof(struct sadb_key)+auth_key_size);
                key->sadb_key_len = (sizeof(struct sadb_key) + auth_key_size) /
                        sizeof(uint64_t);
@@ -913,14 +913,14 @@ static struct sk_buff * pfkey_xfrm_state2msg(struct xfrm_state *x, int add_keys,
        }
        /* encrypt key */
        if (add_keys && encrypt_key_size) {
-               key = (struct sadb_key *) skb_put(skb, 
+               key = (struct sadb_key *) skb_put(skb,
                                                  sizeof(struct sadb_key)+encrypt_key_size);
-               key->sadb_key_len = (sizeof(struct sadb_key) + 
+               key->sadb_key_len = (sizeof(struct sadb_key) +
                                     encrypt_key_size) / sizeof(uint64_t);
                key->sadb_key_exttype = SADB_EXT_KEY_ENCRYPT;
                key->sadb_key_bits = x->ealg->alg_key_len;
                key->sadb_key_reserved = 0;
-               memcpy(key + 1, x->ealg->alg_key, 
+               memcpy(key + 1, x->ealg->alg_key,
                       (x->ealg->alg_key_len+7)/8);
        }
 
@@ -979,17 +979,17 @@ static struct sk_buff * pfkey_xfrm_state2msg(struct xfrm_state *x, int add_keys,
        return skb;
 }
 
-static struct xfrm_state * pfkey_msg2xfrm_state(struct sadb_msg *hdr, 
+static struct xfrm_state * pfkey_msg2xfrm_state(struct sadb_msg *hdr,
                                                void **ext_hdrs)
 {
-       struct xfrm_state *x; 
+       struct xfrm_state *x;
        struct sadb_lifetime *lifetime;
        struct sadb_sa *sa;
        struct sadb_key *key;
        struct sadb_x_sec_ctx *sec_ctx;
        uint16_t proto;
        int err;
-       
+
 
        sa = (struct sadb_sa *) ext_hdrs[SADB_EXT_SA-1];
        if (!sa ||
@@ -1022,7 +1022,7 @@ static struct xfrm_state * pfkey_msg2xfrm_state(struct sadb_msg *hdr,
    SADB_SASTATE_MATURE and the kernel MUST return an error if this is
    not true.
 
-           However, KAME setkey always uses SADB_SASTATE_LARVAL.
+          However, KAME setkey always uses SADB_SASTATE_LARVAL.
           Hence, we have to _ignore_ sadb_sa_state, which is also reasonable.
         */
        if (sa->sadb_sa_auth > SADB_AALG_MAX ||
@@ -1144,13 +1144,13 @@ static struct xfrm_state * pfkey_msg2xfrm_state(struct sadb_msg *hdr,
        }
        /* x->algo.flags = sa->sadb_sa_flags; */
 
-       x->props.family = pfkey_sadb_addr2xfrm_addr((struct sadb_address *) ext_hdrs[SADB_EXT_ADDRESS_SRC-1], 
+       x->props.family = pfkey_sadb_addr2xfrm_addr((struct sadb_address *) ext_hdrs[SADB_EXT_ADDRESS_SRC-1],
                                                    &x->props.saddr);
        if (!x->props.family) {
                err = -EAFNOSUPPORT;
                goto out;
        }
-       pfkey_sadb_addr2xfrm_addr((struct sadb_address *) ext_hdrs[SADB_EXT_ADDRESS_DST-1], 
+       pfkey_sadb_addr2xfrm_addr((struct sadb_address *) ext_hdrs[SADB_EXT_ADDRESS_DST-1],
                                  &x->id.daddr);
 
        if (ext_hdrs[SADB_X_EXT_SA2-1]) {
@@ -1410,7 +1410,7 @@ static int pfkey_add(struct sock *sk, struct sk_buff *skb, struct sadb_msg *hdr,
        struct km_event c;
 
        xfrm_probe_algs();
-       
+
        x = pfkey_msg2xfrm_state(hdr, ext_hdrs);
        if (IS_ERR(x))
                return PTR_ERR(x);
@@ -1530,13 +1530,13 @@ static struct sk_buff *compose_sadb_supported(struct sadb_msg *orig,
                auth_len *= sizeof(struct sadb_alg);
                auth_len += sizeof(struct sadb_supported);
        }
-       
+
        enc_len = xfrm_count_enc_supported();
        if (enc_len) {
                enc_len *= sizeof(struct sadb_alg);
                enc_len += sizeof(struct sadb_supported);
        }
-       
+
        len = enc_len + auth_len + sizeof(struct sadb_msg);
 
        skb = alloc_skb(len + 16, allocation);
@@ -1605,7 +1605,7 @@ static int pfkey_register(struct sock *sk, struct sk_buff *skb, struct sadb_msg
        }
 
        xfrm_probe_algs();
-       
+
        supp_skb = compose_sadb_supported(hdr, GFP_KERNEL);
        if (!supp_skb) {
                if (hdr->sadb_msg_satype != SADB_SATYPE_UNSPEC)
@@ -1856,7 +1856,7 @@ static int pfkey_xfrm_policy2msg_size(struct xfrm_policy *xp)
 
        return sizeof(struct sadb_msg) +
                (sizeof(struct sadb_lifetime) * 3) +
-               (sizeof(struct sadb_address) * 2) + 
+               (sizeof(struct sadb_address) * 2) +
                (sockaddr_size * 2) +
                sizeof(struct sadb_x_policy) +
                (xp->xfrm_nr * sizeof(struct sadb_x_ipsecrequest)) +
@@ -1904,9 +1904,9 @@ static void pfkey_xfrm_policy2msg(struct sk_buff *skb, struct xfrm_policy *xp, i
        memset(hdr, 0, size);   /* XXX do we need this ? */
 
        /* src address */
-       addr = (struct sadb_address*) skb_put(skb, 
+       addr = (struct sadb_address*) skb_put(skb,
                                              sizeof(struct sadb_address)+sockaddr_size);
-       addr->sadb_address_len = 
+       addr->sadb_address_len =
                (sizeof(struct sadb_address)+sockaddr_size)/
                        sizeof(uint64_t);
        addr->sadb_address_exttype = SADB_EXT_ADDRESS_SRC;
@@ -1936,14 +1936,14 @@ static void pfkey_xfrm_policy2msg(struct sk_buff *skb, struct xfrm_policy *xp, i
                BUG();
 
        /* dst address */
-       addr = (struct sadb_address*) skb_put(skb, 
+       addr = (struct sadb_address*) skb_put(skb,
                                              sizeof(struct sadb_address)+sockaddr_size);
        addr->sadb_address_len =
                (sizeof(struct sadb_address)+sockaddr_size)/
                        sizeof(uint64_t);
        addr->sadb_address_exttype = SADB_EXT_ADDRESS_DST;
        addr->sadb_address_proto = pfkey_proto_from_xfrm(xp->selector.proto);
-       addr->sadb_address_prefixlen = xp->selector.prefixlen_d; 
+       addr->sadb_address_prefixlen = xp->selector.prefixlen_d;
        addr->sadb_address_reserved = 0;
        if (xp->family == AF_INET) {
                sin = (struct sockaddr_in *) (addr + 1);
@@ -1967,7 +1967,7 @@ static void pfkey_xfrm_policy2msg(struct sk_buff *skb, struct xfrm_policy *xp, i
                BUG();
 
        /* hard time */
-       lifetime = (struct sadb_lifetime *)  skb_put(skb, 
+       lifetime = (struct sadb_lifetime *)  skb_put(skb,
                                                     sizeof(struct sadb_lifetime));
        lifetime->sadb_lifetime_len =
                sizeof(struct sadb_lifetime)/sizeof(uint64_t);
@@ -1977,7 +1977,7 @@ static void pfkey_xfrm_policy2msg(struct sk_buff *skb, struct xfrm_policy *xp, i
        lifetime->sadb_lifetime_addtime = xp->lft.hard_add_expires_seconds;
        lifetime->sadb_lifetime_usetime = xp->lft.hard_use_expires_seconds;
        /* soft time */
-       lifetime = (struct sadb_lifetime *)  skb_put(skb, 
+       lifetime = (struct sadb_lifetime *)  skb_put(skb,
                                                     sizeof(struct sadb_lifetime));
        lifetime->sadb_lifetime_len =
                sizeof(struct sadb_lifetime)/sizeof(uint64_t);
@@ -1987,7 +1987,7 @@ static void pfkey_xfrm_policy2msg(struct sk_buff *skb, struct xfrm_policy *xp, i
        lifetime->sadb_lifetime_addtime = xp->lft.soft_add_expires_seconds;
        lifetime->sadb_lifetime_usetime = xp->lft.soft_use_expires_seconds;
        /* current time */
-       lifetime = (struct sadb_lifetime *)  skb_put(skb, 
+       lifetime = (struct sadb_lifetime *)  skb_put(skb,
                                                     sizeof(struct sadb_lifetime));
        lifetime->sadb_lifetime_len =
                sizeof(struct sadb_lifetime)/sizeof(uint64_t);
@@ -2019,8 +2019,8 @@ static void pfkey_xfrm_policy2msg(struct sk_buff *skb, struct xfrm_policy *xp, i
                req_size = sizeof(struct sadb_x_ipsecrequest);
                if (t->mode == XFRM_MODE_TUNNEL)
                        req_size += ((t->encap_family == AF_INET ?
-                                    sizeof(struct sockaddr_in) :
-                                    sizeof(struct sockaddr_in6)) * 2);
+                                    sizeof(struct sockaddr_in) :
+                                    sizeof(struct sockaddr_in6)) * 2);
                else
                        size -= 2*socklen;
                rq = (void*)skb_put(skb, req_size);
@@ -2150,7 +2150,7 @@ static int pfkey_spdadd(struct sock *sk, struct sk_buff *skb, struct sadb_msg *h
                      XFRM_POLICY_BLOCK : XFRM_POLICY_ALLOW);
        xp->priority = pol->sadb_x_policy_priority;
 
-       sa = ext_hdrs[SADB_EXT_ADDRESS_SRC-1], 
+       sa = ext_hdrs[SADB_EXT_ADDRESS_SRC-1],
        xp->family = pfkey_sadb_addr2xfrm_addr(sa, &xp->selector.saddr);
        if (!xp->family) {
                err = -EINVAL;
@@ -2163,7 +2163,7 @@ static int pfkey_spdadd(struct sock *sk, struct sk_buff *skb, struct sadb_msg *h
        if (xp->selector.sport)
                xp->selector.sport_mask = htons(0xffff);
 
-       sa = ext_hdrs[SADB_EXT_ADDRESS_DST-1], 
+       sa = ext_hdrs[SADB_EXT_ADDRESS_DST-1],
        pfkey_sadb_addr2xfrm_addr(sa, &xp->selector.daddr);
        xp->selector.prefixlen_d = sa->sadb_address_prefixlen;
 
@@ -2224,7 +2224,7 @@ static int pfkey_spdadd(struct sock *sk, struct sk_buff *skb, struct sadb_msg *h
 
        if (hdr->sadb_msg_type == SADB_X_SPDUPDATE)
                c.event = XFRM_MSG_UPDPOLICY;
-       else 
+       else
                c.event = XFRM_MSG_NEWPOLICY;
 
        c.seq = hdr->sadb_msg_seq;
@@ -2261,7 +2261,7 @@ static int pfkey_spddelete(struct sock *sk, struct sk_buff *skb, struct sadb_msg
 
        memset(&sel, 0, sizeof(sel));
 
-       sa = ext_hdrs[SADB_EXT_ADDRESS_SRC-1], 
+       sa = ext_hdrs[SADB_EXT_ADDRESS_SRC-1],
        sel.family = pfkey_sadb_addr2xfrm_addr(sa, &sel.saddr);
        sel.prefixlen_s = sa->sadb_address_prefixlen;
        sel.proto = pfkey_proto_to_xfrm(sa->sadb_address_proto);
@@ -2269,7 +2269,7 @@ static int pfkey_spddelete(struct sock *sk, struct sk_buff *skb, struct sadb_msg
        if (sel.sport)
                sel.sport_mask = htons(0xffff);
 
-       sa = ext_hdrs[SADB_EXT_ADDRESS_DST-1], 
+       sa = ext_hdrs[SADB_EXT_ADDRESS_DST-1],
        pfkey_sadb_addr2xfrm_addr(sa, &sel.daddr);
        sel.prefixlen_d = sa->sadb_address_prefixlen;
        sel.proto = pfkey_proto_to_xfrm(sa->sadb_address_proto);
@@ -2345,6 +2345,196 @@ out:
        return err;
 }
 
+#ifdef CONFIG_NET_KEY_MIGRATE
+static int pfkey_sockaddr_pair_size(sa_family_t family)
+{
+       switch (family) {
+       case AF_INET:
+               return PFKEY_ALIGN8(sizeof(struct sockaddr_in) * 2);
+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
+       case AF_INET6:
+               return PFKEY_ALIGN8(sizeof(struct sockaddr_in6) * 2);
+#endif
+       default:
+               return 0;
+       }
+       /* NOTREACHED */
+}
+
+static int parse_sockaddr_pair(struct sadb_x_ipsecrequest *rq,
+                              xfrm_address_t *saddr, xfrm_address_t *daddr,
+                              u16 *family)
+{
+       struct sockaddr *sa = (struct sockaddr *)(rq + 1);
+       if (rq->sadb_x_ipsecrequest_len <
+           pfkey_sockaddr_pair_size(sa->sa_family))
+               return -EINVAL;
+
+       switch (sa->sa_family) {
+       case AF_INET:
+               {
+                       struct sockaddr_in *sin;
+                       sin = (struct sockaddr_in *)sa;
+                       if ((sin+1)->sin_family != AF_INET)
+                               return -EINVAL;
+                       memcpy(&saddr->a4, &sin->sin_addr, sizeof(saddr->a4));
+                       sin++;
+                       memcpy(&daddr->a4, &sin->sin_addr, sizeof(daddr->a4));
+                       *family = AF_INET;
+                       break;
+               }
+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
+       case AF_INET6:
+               {
+                       struct sockaddr_in6 *sin6;
+                       sin6 = (struct sockaddr_in6 *)sa;
+                       if ((sin6+1)->sin6_family != AF_INET6)
+                               return -EINVAL;
+                       memcpy(&saddr->a6, &sin6->sin6_addr,
+                              sizeof(saddr->a6));
+                       sin6++;
+                       memcpy(&daddr->a6, &sin6->sin6_addr,
+                              sizeof(daddr->a6));
+                       *family = AF_INET6;
+                       break;
+               }
+#endif
+       default:
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
+static int ipsecrequests_to_migrate(struct sadb_x_ipsecrequest *rq1, int len,
+                                   struct xfrm_migrate *m)
+{
+       int err;
+       struct sadb_x_ipsecrequest *rq2;
+
+       if (len <= sizeof(struct sadb_x_ipsecrequest) ||
+           len < rq1->sadb_x_ipsecrequest_len)
+               return -EINVAL;
+
+       /* old endoints */
+       err = parse_sockaddr_pair(rq1, &m->old_saddr, &m->old_daddr,
+                                 &m->old_family);
+       if (err)
+               return err;
+
+       rq2 = (struct sadb_x_ipsecrequest *)((u8 *)rq1 + rq1->sadb_x_ipsecrequest_len);
+       len -= rq1->sadb_x_ipsecrequest_len;
+
+       if (len <= sizeof(struct sadb_x_ipsecrequest) ||
+           len < rq2->sadb_x_ipsecrequest_len)
+               return -EINVAL;
+
+       /* new endpoints */
+       err = parse_sockaddr_pair(rq2, &m->new_saddr, &m->new_daddr,
+                                 &m->new_family);
+       if (err)
+               return err;
+
+       if (rq1->sadb_x_ipsecrequest_proto != rq2->sadb_x_ipsecrequest_proto ||
+           rq1->sadb_x_ipsecrequest_mode != rq2->sadb_x_ipsecrequest_mode ||
+           rq1->sadb_x_ipsecrequest_reqid != rq2->sadb_x_ipsecrequest_reqid)
+               return -EINVAL;
+
+       m->proto = rq1->sadb_x_ipsecrequest_proto;
+       m->mode = rq1->sadb_x_ipsecrequest_mode - 1;
+       m->reqid = rq1->sadb_x_ipsecrequest_reqid;
+
+       return ((int)(rq1->sadb_x_ipsecrequest_len +
+                     rq2->sadb_x_ipsecrequest_len));
+}
+
+static int pfkey_migrate(struct sock *sk, struct sk_buff *skb,
+                        struct sadb_msg *hdr, void **ext_hdrs)
+{
+       int i, len, ret, err = -EINVAL;
+       u8 dir;
+       struct sadb_address *sa;
+       struct sadb_x_policy *pol;
+       struct sadb_x_ipsecrequest *rq;
+       struct xfrm_selector sel;
+       struct xfrm_migrate m[XFRM_MAX_DEPTH];
+
+       if (!present_and_same_family(ext_hdrs[SADB_EXT_ADDRESS_SRC - 1],
+           ext_hdrs[SADB_EXT_ADDRESS_DST - 1]) ||
+           !ext_hdrs[SADB_X_EXT_POLICY - 1]) {
+               err = -EINVAL;
+               goto out;
+       }
+
+       pol = ext_hdrs[SADB_X_EXT_POLICY - 1];
+       if (!pol) {
+               err = -EINVAL;
+               goto out;
+       }
+
+       if (pol->sadb_x_policy_dir >= IPSEC_DIR_MAX) {
+               err = -EINVAL;
+               goto out;
+       }
+
+       dir = pol->sadb_x_policy_dir - 1;
+       memset(&sel, 0, sizeof(sel));
+
+       /* set source address info of selector */
+       sa = ext_hdrs[SADB_EXT_ADDRESS_SRC - 1];
+       sel.family = pfkey_sadb_addr2xfrm_addr(sa, &sel.saddr);
+       sel.prefixlen_s = sa->sadb_address_prefixlen;
+       sel.proto = pfkey_proto_to_xfrm(sa->sadb_address_proto);
+       sel.sport = ((struct sockaddr_in *)(sa + 1))->sin_port;
+       if (sel.sport)
+               sel.sport_mask = ~0;
+
+       /* set destination address info of selector */
+       sa = ext_hdrs[SADB_EXT_ADDRESS_DST - 1],
+       pfkey_sadb_addr2xfrm_addr(sa, &sel.daddr);
+       sel.prefixlen_d = sa->sadb_address_prefixlen;
+       sel.proto = pfkey_proto_to_xfrm(sa->sadb_address_proto);
+       sel.dport = ((struct sockaddr_in *)(sa + 1))->sin_port;
+       if (sel.dport)
+               sel.dport_mask = ~0;
+
+       rq = (struct sadb_x_ipsecrequest *)(pol + 1);
+
+       /* extract ipsecrequests */
+       i = 0;
+       len = pol->sadb_x_policy_len * 8 - sizeof(struct sadb_x_policy);
+
+       while (len > 0 && i < XFRM_MAX_DEPTH) {
+               ret = ipsecrequests_to_migrate(rq, len, &m[i]);
+               if (ret < 0) {
+                       err = ret;
+                       goto out;
+               } else {
+                       rq = (struct sadb_x_ipsecrequest *)((u8 *)rq + ret);
+                       len -= ret;
+                       i++;
+               }
+       }
+
+       if (!i || len > 0) {
+               err = -EINVAL;
+               goto out;
+       }
+
+       return xfrm_migrate(&sel, dir, XFRM_POLICY_TYPE_MAIN, m, i);
+
+ out:
+       return err;
+}
+#else
+static int pfkey_migrate(struct sock *sk, struct sk_buff *skb,
+                        struct sadb_msg *hdr, void **ext_hdrs)
+{
+       return -ENOPROTOOPT;
+}
+#endif
+
+
 static int pfkey_spdget(struct sock *sk, struct sk_buff *skb, struct sadb_msg *hdr, void **ext_hdrs)
 {
        unsigned int dir;
@@ -2473,6 +2663,7 @@ static pfkey_handler pfkey_funcs[SADB_MAX + 1] = {
        [SADB_X_SPDFLUSH]       = pfkey_spdflush,
        [SADB_X_SPDSETIDX]      = pfkey_spdadd,
        [SADB_X_SPDDELETE2]     = pfkey_spdget,
+       [SADB_X_MIGRATE]        = pfkey_migrate,
 };
 
 static int pfkey_process(struct sock *sk, struct sk_buff *skb, struct sadb_msg *hdr)
@@ -2552,15 +2743,15 @@ static int count_esp_combs(struct xfrm_tmpl *t)
                struct xfrm_algo_desc *ealg = xfrm_ealg_get_byidx(i);
                if (!ealg)
                        break;
-                       
+
                if (!(ealg_tmpl_set(t, ealg) && ealg->available))
                        continue;
-                       
+
                for (k = 1; ; k++) {
                        struct xfrm_algo_desc *aalg = xfrm_aalg_get_byidx(k);
                        if (!aalg)
                                break;
-                               
+
                        if (aalg_tmpl_set(t, aalg) && aalg->available)
                                sz += sizeof(struct sadb_comb);
                }
@@ -2615,10 +2806,10 @@ static void dump_esp_combs(struct sk_buff *skb, struct xfrm_tmpl *t)
                struct xfrm_algo_desc *ealg = xfrm_ealg_get_byidx(i);
                if (!ealg)
                        break;
-       
+
                if (!(ealg_tmpl_set(t, ealg) && ealg->available))
                        continue;
-                       
+
                for (k = 1; ; k++) {
                        struct sadb_comb *c;
                        struct xfrm_algo_desc *aalg = xfrm_aalg_get_byidx(k);
@@ -2750,7 +2941,7 @@ static int pfkey_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *t, struct
        struct sadb_x_sec_ctx *sec_ctx;
        struct xfrm_sec_ctx *xfrm_ctx;
        int ctx_size = 0;
-       
+
        sockaddr_size = pfkey_sockaddr_size(x->props.family);
        if (!sockaddr_size)
                return -EINVAL;
@@ -2759,7 +2950,7 @@ static int pfkey_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *t, struct
                (sizeof(struct sadb_address) * 2) +
                (sockaddr_size * 2) +
                sizeof(struct sadb_x_policy);
-       
+
        if (x->id.proto == IPPROTO_AH)
                size += count_ah_combs(t);
        else if (x->id.proto == IPPROTO_ESP)
@@ -2773,7 +2964,7 @@ static int pfkey_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *t, struct
        skb =  alloc_skb(size + 16, GFP_ATOMIC);
        if (skb == NULL)
                return -ENOMEM;
-       
+
        hdr = (struct sadb_msg *) skb_put(skb, sizeof(struct sadb_msg));
        hdr->sadb_msg_version = PF_KEY_V2;
        hdr->sadb_msg_type = SADB_ACQUIRE;
@@ -2785,9 +2976,9 @@ static int pfkey_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *t, struct
        hdr->sadb_msg_pid = 0;
 
        /* src address */
-       addr = (struct sadb_address*) skb_put(skb, 
+       addr = (struct sadb_address*) skb_put(skb,
                                              sizeof(struct sadb_address)+sockaddr_size);
-       addr->sadb_address_len = 
+       addr->sadb_address_len =
                (sizeof(struct sadb_address)+sockaddr_size)/
                        sizeof(uint64_t);
        addr->sadb_address_exttype = SADB_EXT_ADDRESS_SRC;
@@ -2817,9 +3008,9 @@ static int pfkey_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *t, struct
 #endif
        else
                BUG();
-       
+
        /* dst address */
-       addr = (struct sadb_address*) skb_put(skb, 
+       addr = (struct sadb_address*) skb_put(skb,
                                              sizeof(struct sadb_address)+sockaddr_size);
        addr->sadb_address_len =
                (sizeof(struct sadb_address)+sockaddr_size)/
@@ -2828,7 +3019,7 @@ static int pfkey_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *t, struct
        addr->sadb_address_proto = 0;
        addr->sadb_address_reserved = 0;
        if (x->props.family == AF_INET) {
-               addr->sadb_address_prefixlen = 32; 
+               addr->sadb_address_prefixlen = 32;
 
                sin = (struct sockaddr_in *) (addr + 1);
                sin->sin_family = AF_INET;
@@ -2838,7 +3029,7 @@ static int pfkey_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *t, struct
        }
 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
        else if (x->props.family == AF_INET6) {
-               addr->sadb_address_prefixlen = 128; 
+               addr->sadb_address_prefixlen = 128;
 
                sin6 = (struct sockaddr_in6 *) (addr + 1);
                sin6->sin6_family = AF_INET6;
@@ -2883,7 +3074,7 @@ static int pfkey_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *t, struct
 }
 
 static struct xfrm_policy *pfkey_compile_policy(struct sock *sk, int opt,
-                                                u8 *data, int len, int *dir)
+                                               u8 *data, int len, int *dir)
 {
        struct xfrm_policy *xp;
        struct sadb_x_policy *pol = (struct sadb_x_policy*)data;
@@ -3002,17 +3193,17 @@ static int pfkey_send_new_mapping(struct xfrm_state *x, xfrm_address_t *ipaddr,
         * HDR | SA | ADDRESS_SRC (old addr) | NAT_T_SPORT (old port) |
         * ADDRESS_DST (new addr) | NAT_T_DPORT (new port)
         */
-       
+
        size = sizeof(struct sadb_msg) +
                sizeof(struct sadb_sa) +
                (sizeof(struct sadb_address) * 2) +
                (sockaddr_size * 2) +
                (sizeof(struct sadb_x_nat_t_port) * 2);
-       
+
        skb =  alloc_skb(size + 16, GFP_ATOMIC);
        if (skb == NULL)
                return -ENOMEM;
-       
+
        hdr = (struct sadb_msg *) skb_put(skb, sizeof(struct sadb_msg));
        hdr->sadb_msg_version = PF_KEY_V2;
        hdr->sadb_msg_type = SADB_X_NAT_T_NEW_MAPPING;
@@ -3037,7 +3228,7 @@ static int pfkey_send_new_mapping(struct xfrm_state *x, xfrm_address_t *ipaddr,
        /* ADDRESS_SRC (old addr) */
        addr = (struct sadb_address*)
                skb_put(skb, sizeof(struct sadb_address)+sockaddr_size);
-       addr->sadb_address_len = 
+       addr->sadb_address_len =
                (sizeof(struct sadb_address)+sockaddr_size)/
                        sizeof(uint64_t);
        addr->sadb_address_exttype = SADB_EXT_ADDRESS_SRC;
@@ -3078,7 +3269,7 @@ static int pfkey_send_new_mapping(struct xfrm_state *x, xfrm_address_t *ipaddr,
        /* ADDRESS_DST (new addr) */
        addr = (struct sadb_address*)
                skb_put(skb, sizeof(struct sadb_address)+sockaddr_size);
-       addr->sadb_address_len = 
+       addr->sadb_address_len =
                (sizeof(struct sadb_address)+sockaddr_size)/
                        sizeof(uint64_t);
        addr->sadb_address_exttype = SADB_EXT_ADDRESS_DST;
@@ -3118,6 +3309,236 @@ static int pfkey_send_new_mapping(struct xfrm_state *x, xfrm_address_t *ipaddr,
        return pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_REGISTERED, NULL);
 }
 
+#ifdef CONFIG_NET_KEY_MIGRATE
+static int set_sadb_address(struct sk_buff *skb, int sasize, int type,
+                           struct xfrm_selector *sel)
+{
+       struct sadb_address *addr;
+       struct sockaddr_in *sin;
+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
+       struct sockaddr_in6 *sin6;
+#endif
+       addr = (struct sadb_address *)skb_put(skb, sizeof(struct sadb_address) + sasize);
+       addr->sadb_address_len = (sizeof(struct sadb_address) + sasize)/8;
+       addr->sadb_address_exttype = type;
+       addr->sadb_address_proto = sel->proto;
+       addr->sadb_address_reserved = 0;
+
+       switch (type) {
+       case SADB_EXT_ADDRESS_SRC:
+               if (sel->family == AF_INET) {
+                       addr->sadb_address_prefixlen = sel->prefixlen_s;
+                       sin = (struct sockaddr_in *)(addr + 1);
+                       sin->sin_family = AF_INET;
+                       memcpy(&sin->sin_addr.s_addr, &sel->saddr,
+                              sizeof(sin->sin_addr.s_addr));
+                       sin->sin_port = 0;
+                       memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
+               }
+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
+               else if (sel->family == AF_INET6) {
+                       addr->sadb_address_prefixlen = sel->prefixlen_s;
+                       sin6 = (struct sockaddr_in6 *)(addr + 1);
+                       sin6->sin6_family = AF_INET6;
+                       sin6->sin6_port = 0;
+                       sin6->sin6_flowinfo = 0;
+                       sin6->sin6_scope_id = 0;
+                       memcpy(&sin6->sin6_addr.s6_addr, &sel->saddr,
+                              sizeof(sin6->sin6_addr.s6_addr));
+               }
+#endif
+               break;
+       case SADB_EXT_ADDRESS_DST:
+               if (sel->family == AF_INET) {
+                       addr->sadb_address_prefixlen = sel->prefixlen_d;
+                       sin = (struct sockaddr_in *)(addr + 1);
+                       sin->sin_family = AF_INET;
+                       memcpy(&sin->sin_addr.s_addr, &sel->daddr,
+                              sizeof(sin->sin_addr.s_addr));
+                       sin->sin_port = 0;
+                       memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
+               }
+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
+               else if (sel->family == AF_INET6) {
+                       addr->sadb_address_prefixlen = sel->prefixlen_d;
+                       sin6 = (struct sockaddr_in6 *)(addr + 1);
+                       sin6->sin6_family = AF_INET6;
+                       sin6->sin6_port = 0;
+                       sin6->sin6_flowinfo = 0;
+                       sin6->sin6_scope_id = 0;
+                       memcpy(&sin6->sin6_addr.s6_addr, &sel->daddr,
+                              sizeof(sin6->sin6_addr.s6_addr));
+               }
+#endif
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
+static int set_ipsecrequest(struct sk_buff *skb,
+                           uint8_t proto, uint8_t mode, int level,
+                           uint32_t reqid, uint8_t family,
+                           xfrm_address_t *src, xfrm_address_t *dst)
+{
+       struct sadb_x_ipsecrequest *rq;
+       struct sockaddr_in *sin;
+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
+       struct sockaddr_in6 *sin6;
+#endif
+       int size_req;
+
+       size_req = sizeof(struct sadb_x_ipsecrequest) +
+                  pfkey_sockaddr_pair_size(family);
+
+       rq = (struct sadb_x_ipsecrequest *)skb_put(skb, size_req);
+       memset(rq, 0, size_req);
+       rq->sadb_x_ipsecrequest_len = size_req;
+       rq->sadb_x_ipsecrequest_proto = proto;
+       rq->sadb_x_ipsecrequest_mode = mode;
+       rq->sadb_x_ipsecrequest_level = level;
+       rq->sadb_x_ipsecrequest_reqid = reqid;
+
+       switch (family) {
+       case AF_INET:
+               sin = (struct sockaddr_in *)(rq + 1);
+               sin->sin_family = AF_INET;
+               memcpy(&sin->sin_addr.s_addr, src,
+                      sizeof(sin->sin_addr.s_addr));
+               sin++;
+               sin->sin_family = AF_INET;
+               memcpy(&sin->sin_addr.s_addr, dst,
+                      sizeof(sin->sin_addr.s_addr));
+               break;
+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
+       case AF_INET6:
+               sin6 = (struct sockaddr_in6 *)(rq + 1);
+               sin6->sin6_family = AF_INET6;
+               sin6->sin6_port = 0;
+               sin6->sin6_flowinfo = 0;
+               sin6->sin6_scope_id = 0;
+               memcpy(&sin6->sin6_addr.s6_addr, src,
+                      sizeof(sin6->sin6_addr.s6_addr));
+               sin6++;
+               sin6->sin6_family = AF_INET6;
+               sin6->sin6_port = 0;
+               sin6->sin6_flowinfo = 0;
+               sin6->sin6_scope_id = 0;
+               memcpy(&sin6->sin6_addr.s6_addr, dst,
+                      sizeof(sin6->sin6_addr.s6_addr));
+               break;
+#endif
+       default:
+               return -EINVAL;
+       }
+
+       return 0;
+}
+#endif
+
+#ifdef CONFIG_NET_KEY_MIGRATE
+static int pfkey_send_migrate(struct xfrm_selector *sel, u8 dir, u8 type,
+                             struct xfrm_migrate *m, int num_bundles)
+{
+       int i;
+       int sasize_sel;
+       int size = 0;
+       int size_pol = 0;
+       struct sk_buff *skb;
+       struct sadb_msg *hdr;
+       struct sadb_x_policy *pol;
+       struct xfrm_migrate *mp;
+
+       if (type != XFRM_POLICY_TYPE_MAIN)
+               return 0;
+
+       if (num_bundles <= 0 || num_bundles > XFRM_MAX_DEPTH)
+               return -EINVAL;
+
+       /* selector */
+       sasize_sel = pfkey_sockaddr_size(sel->family);
+       if (!sasize_sel)
+               return -EINVAL;
+       size += (sizeof(struct sadb_address) + sasize_sel) * 2;
+
+       /* policy info */
+       size_pol += sizeof(struct sadb_x_policy);
+
+       /* ipsecrequests */
+       for (i = 0, mp = m; i < num_bundles; i++, mp++) {
+               /* old locator pair */
+               size_pol += sizeof(struct sadb_x_ipsecrequest) +
+                           pfkey_sockaddr_pair_size(mp->old_family);
+               /* new locator pair */
+               size_pol += sizeof(struct sadb_x_ipsecrequest) +
+                           pfkey_sockaddr_pair_size(mp->new_family);
+       }
+
+       size += sizeof(struct sadb_msg) + size_pol;
+
+       /* alloc buffer */
+       skb = alloc_skb(size, GFP_ATOMIC);
+       if (skb == NULL)
+               return -ENOMEM;
+
+       hdr = (struct sadb_msg *)skb_put(skb, sizeof(struct sadb_msg));
+       hdr->sadb_msg_version = PF_KEY_V2;
+       hdr->sadb_msg_type = SADB_X_MIGRATE;
+       hdr->sadb_msg_satype = pfkey_proto2satype(m->proto);
+       hdr->sadb_msg_len = size / 8;
+       hdr->sadb_msg_errno = 0;
+       hdr->sadb_msg_reserved = 0;
+       hdr->sadb_msg_seq = 0;
+       hdr->sadb_msg_pid = 0;
+
+       /* selector src */
+       set_sadb_address(skb, sasize_sel, SADB_EXT_ADDRESS_SRC, sel);
+
+       /* selector dst */
+       set_sadb_address(skb, sasize_sel, SADB_EXT_ADDRESS_DST, sel);
+
+       /* policy information */
+       pol = (struct sadb_x_policy *)skb_put(skb, sizeof(struct sadb_x_policy));
+       pol->sadb_x_policy_len = size_pol / 8;
+       pol->sadb_x_policy_exttype = SADB_X_EXT_POLICY;
+       pol->sadb_x_policy_type = IPSEC_POLICY_IPSEC;
+       pol->sadb_x_policy_dir = dir + 1;
+       pol->sadb_x_policy_id = 0;
+       pol->sadb_x_policy_priority = 0;
+
+       for (i = 0, mp = m; i < num_bundles; i++, mp++) {
+               /* old ipsecrequest */
+               if (set_ipsecrequest(skb, mp->proto, mp->mode + 1,
+                                    (mp->reqid ?  IPSEC_LEVEL_UNIQUE : IPSEC_LEVEL_REQUIRE),
+                                    mp->reqid, mp->old_family,
+                                    &mp->old_saddr, &mp->old_daddr) < 0) {
+                       return -EINVAL;
+               }
+
+               /* new ipsecrequest */
+               if (set_ipsecrequest(skb, mp->proto, mp->mode + 1,
+                                    (mp->reqid ? IPSEC_LEVEL_UNIQUE : IPSEC_LEVEL_REQUIRE),
+                                    mp->reqid, mp->new_family,
+                                    &mp->new_saddr, &mp->new_daddr) < 0) {
+                       return -EINVAL;
+               }
+       }
+
+       /* broadcast migrate message to sockets */
+       pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_ALL, NULL);
+
+       return 0;
+}
+#else
+static int pfkey_send_migrate(struct xfrm_selector *sel, u8 dir, u8 type,
+                             struct xfrm_migrate *m, int num_bundles)
+{
+       return -ENOPROTOOPT;
+}
+#endif
+
 static int pfkey_sendmsg(struct kiocb *kiocb,
                         struct socket *sock, struct msghdr *msg, size_t len)
 {
@@ -3253,7 +3674,7 @@ static int pfkey_read_proc(char *buffer, char **start, off_t offset,
                               );
 
                buffer[len++] = '\n';
-               
+
                pos = begin + len;
                if (pos < offset) {
                        len = 0;
@@ -3287,6 +3708,7 @@ static struct xfrm_mgr pfkeyv2_mgr =
        .compile_policy = pfkey_compile_policy,
        .new_mapping    = pfkey_send_new_mapping,
        .notify_policy  = pfkey_send_policy_notify,
+       .migrate        = pfkey_send_migrate,
 };
 
 static void __exit ipsec_pfkey_exit(void)
index 7e6bc41eeb216df942fcaf4b0575a1d4e26a6d05..a2e7aa63fd8a4939af6d8cf687bd1302abfd86dd 100644 (file)
@@ -14,7 +14,7 @@
  *     LAPB 002        Jonathan Naylor New timer architecture.
  *     2000-10-29      Henner Eisen    lapb_data_indication() return status.
  */
+
 #include <linux/module.h>
 #include <linux/errno.h>
 #include <linux/types.h>
@@ -43,7 +43,7 @@ static struct list_head lapb_list = LIST_HEAD_INIT(lapb_list);
 static DEFINE_RWLOCK(lapb_list_lock);
 
 /*
- *     Free an allocated lapb control block. 
+ *     Free an allocated lapb control block.
  */
 static void lapb_free_cb(struct lapb_cb *lapb)
 {
@@ -407,7 +407,7 @@ int lapb_data_indication(struct lapb_cb *lapb, struct sk_buff *skb)
                return lapb->callbacks.data_indication(lapb->dev, skb);
 
        kfree_skb(skb);
-       return NET_RX_CN_HIGH; /* For now; must be != NET_RX_DROP */ 
+       return NET_RX_CN_HIGH; /* For now; must be != NET_RX_DROP */
 }
 
 int lapb_data_transmit(struct lapb_cb *lapb, struct sk_buff *skb)
index 49a761bd9314559205308635b1a609c949eb5e0f..981beb5e518780e24e38384af27a71fbfc104598 100644 (file)
@@ -34,7 +34,7 @@
 #include <linux/interrupt.h>
 #include <net/lapb.h>
 
-/* 
+/*
  *  This procedure is passed a buffer descriptor for an iframe. It builds
  *  the rest of the control part of the frame and then writes it out.
  */
@@ -66,7 +66,7 @@ static void lapb_send_iframe(struct lapb_cb *lapb, struct sk_buff *skb, int poll
               lapb->dev, lapb->state, poll_bit, lapb->vs, lapb->vr);
 #endif
 
-       lapb_transmit_buffer(lapb, skb, LAPB_COMMAND);  
+       lapb_transmit_buffer(lapb, skb, LAPB_COMMAND);
 }
 
 void lapb_kick(struct lapb_cb *lapb)
index 8b5eefd70f03c3f686f14fc84947ac5e7ce90ab3..b8739cf9156da832402741c7fb2693c42506f091 100644 (file)
@@ -59,7 +59,7 @@ void lapb_frames_acked(struct lapb_cb *lapb, unsigned short nr)
         */
        if (lapb->va != nr)
                while (skb_peek(&lapb->ack_queue) && lapb->va != nr) {
-                       skb = skb_dequeue(&lapb->ack_queue);
+                       skb = skb_dequeue(&lapb->ack_queue);
                        kfree_skb(skb);
                        lapb->va = (lapb->va + 1) % modulus;
                }
@@ -67,7 +67,7 @@ void lapb_frames_acked(struct lapb_cb *lapb, unsigned short nr)
 
 void lapb_requeue_frames(struct lapb_cb *lapb)
 {
-        struct sk_buff *skb, *skb_prev = NULL;
+       struct sk_buff *skb, *skb_prev = NULL;
 
        /*
         * Requeue all the un-ack-ed frames on the output queue to be picked
@@ -91,7 +91,7 @@ int lapb_validate_nr(struct lapb_cb *lapb, unsigned short nr)
 {
        unsigned short vc = lapb->va;
        int modulus;
-       
+
        modulus = (lapb->mode & LAPB_EXTENDED) ? LAPB_EMODULUS : LAPB_SMODULUS;
 
        while (vc != lapb->vs) {
@@ -99,7 +99,7 @@ int lapb_validate_nr(struct lapb_cb *lapb, unsigned short nr)
                        return 1;
                vc = (vc + 1) % modulus;
        }
-       
+
        return nr == lapb->vs;
 }
 
@@ -149,7 +149,7 @@ int lapb_decode(struct lapb_cb *lapb, struct sk_buff *skb,
                                frame->cr = LAPB_RESPONSE;
                }
        }
-               
+
        skb_pull(skb, 1);
 
        if (lapb->mode & LAPB_EXTENDED) {
@@ -220,9 +220,9 @@ int lapb_decode(struct lapb_cb *lapb, struct sk_buff *skb,
        return 0;
 }
 
-/* 
+/*
  *     This routine is called when the HDLC layer internally  generates a
- *     command or  response  for  the remote machine ( eg. RR, UA etc. ). 
+ *     command or  response  for  the remote machine ( eg. RR, UA etc. ).
  *     Only supervisory or unnumbered frames are processed, FRMRs are handled
  *     by lapb_transmit_frmr below.
  */
@@ -259,7 +259,7 @@ void lapb_send_control(struct lapb_cb *lapb, int frametype,
        lapb_transmit_buffer(lapb, skb, type);
 }
 
-/* 
+/*
  *     This routine generates FRMRs based on information previously stored in
  *     the LAPB control block.
  */
index 2c8f0f809220c37ca349bb473df0a1116d31d24b..af6d14b44e2e66abe826896c8fb4c2672f661509 100644 (file)
@@ -101,7 +101,7 @@ static void lapb_t1timer_expiry(unsigned long param)
                /*
                 *      Awaiting connection state, send SABM(E), up to N2 times.
                 */
-               case LAPB_STATE_1: 
+               case LAPB_STATE_1:
                        if (lapb->n2count == lapb->n2) {
                                lapb_clear_queues(lapb);
                                lapb->state = LAPB_STATE_0;
index 190bb3e051881fa1455f4456bff39e890ad0cc20..7d9fa38b6a7d14ca5a35d8c782d5b7e0f383a34a 100644 (file)
@@ -67,7 +67,7 @@ static inline u16 llc_ui_next_link_no(int sap)
 static inline __be16 llc_proto_type(u16 arphrd)
 {
        return arphrd == ARPHRD_IEEE802_TR ?
-                        htons(ETH_P_TR_802_2) : htons(ETH_P_802_2);
+                        htons(ETH_P_TR_802_2) : htons(ETH_P_802_2);
 }
 
 /**
@@ -114,7 +114,7 @@ static int llc_ui_send_data(struct sock* sk, struct sk_buff *skb, int noblock)
        struct llc_sock* llc = llc_sk(sk);
        int rc = 0;
 
-       if (unlikely(llc_data_accept_state(llc->state) || 
+       if (unlikely(llc_data_accept_state(llc->state) ||
                     llc->remote_busy_flag ||
                     llc->p_flag)) {
                long timeout = sock_sndtimeo(sk, noblock);
@@ -602,7 +602,7 @@ static int llc_ui_accept(struct socket *sock, struct socket *newsock, int flags)
        int rc = -EOPNOTSUPP;
 
        dprintk("%s: accepting on %02X\n", __FUNCTION__,
-               llc_sk(sk)->laddr.lsap);
+               llc_sk(sk)->laddr.lsap);
        lock_sock(sk);
        if (unlikely(sk->sk_type != SOCK_STREAM))
                goto out;
@@ -617,7 +617,7 @@ static int llc_ui_accept(struct socket *sock, struct socket *newsock, int flags)
                        goto out;
        }
        dprintk("%s: got a new connection on %02X\n", __FUNCTION__,
-               llc_sk(sk)->laddr.lsap);
+               llc_sk(sk)->laddr.lsap);
        skb = skb_dequeue(&sk->sk_receive_queue);
        rc = -EINVAL;
        if (!skb->sk)
@@ -682,7 +682,7 @@ static int llc_ui_recvmsg(struct kiocb *iocb, struct socket *sock,
        if (flags & MSG_PEEK) {
                peek_seq = llc->copied_seq;
                seq = &peek_seq;
-       }
+       }
 
        target = sock_rcvlowat(sk, flags & MSG_WAITALL, len);
        copied = 0;
@@ -860,7 +860,7 @@ static int llc_ui_sendmsg(struct kiocb *iocb, struct socket *sock,
                goto release;
        skb->dev      = llc->dev;
        skb->protocol = llc_proto_type(addr->sllc_arphrd);
-       skb_reserve(skb, hdrlen); 
+       skb_reserve(skb, hdrlen);
        rc = memcpy_fromiovec(skb_put(skb, copied), msg->msg_iov, copied);
        if (rc)
                goto out;
@@ -1116,11 +1116,11 @@ static const struct proto_ops llc_ui_ops = {
 };
 
 static char llc_proc_err_msg[] __initdata =
-        KERN_CRIT "LLC: Unable to register the proc_fs entries\n";
+       KERN_CRIT "LLC: Unable to register the proc_fs entries\n";
 static char llc_sysctl_err_msg[] __initdata =
-        KERN_CRIT "LLC: Unable to register the sysctl entries\n";
+       KERN_CRIT "LLC: Unable to register the sysctl entries\n";
 static char llc_sock_err_msg[] __initdata =
-        KERN_CRIT "LLC: Unable to register the network family\n";
+       KERN_CRIT "LLC: Unable to register the network family\n";
 
 static int __init llc2_init(void)
 {
index c761c15da4212e987be4db497d650df8758bf5b6..3b8cfbe029a74ba8d47fb24bd1d1aad8f952d351 100644 (file)
@@ -854,7 +854,7 @@ static void llc_sk_init(struct sock* sk)
        llc->n2 = 2;   /* max retransmit */
        llc->k  = 2;   /* tx win size, will adjust dynam */
        llc->rw = 128; /* rx win size (opt and equal to
-                       * tx_win of remote LLC) */
+                       * tx_win of remote LLC) */
        skb_queue_head_init(&llc->pdu_unack_q);
        sk->sk_backlog_rcv = llc_backlog_rcv;
 }
index db82aff6e40f54802fa79592a76a1d08712b923b..b3f65d1e80b12584e46c49e55f9c5dddcd47e01a 100644 (file)
@@ -164,7 +164,7 @@ int llc_rcv(struct sk_buff *skb, struct net_device *dev,
        sap = llc_sap_find(pdu->dsap);
        if (unlikely(!sap)) {/* unknown SAP */
                dprintk("%s: llc_sap_find(%02X) failed!\n", __FUNCTION__,
-                       pdu->dsap);
+                       pdu->dsap);
                goto drop;
        }
        /*
@@ -173,9 +173,9 @@ int llc_rcv(struct sk_buff *skb, struct net_device *dev,
         */
        rcv = rcu_dereference(sap->rcv_func);
        if (rcv) {
-               struct sk_buff *cskb = skb_clone(skb, GFP_ATOMIC);
-               if (cskb)
-                       rcv(cskb, dev, pt, orig_dev);
+               struct sk_buff *cskb = skb_clone(skb, GFP_ATOMIC);
+               if (cskb)
+                       rcv(cskb, dev, pt, orig_dev);
        }
        dest = llc_pdu_type(skb);
        if (unlikely(!dest || !llc_type_handlers[dest - 1]))
index b4e668e0e12c46da8b7f5cbf1a6a24a9c5da73ba..f4291f349e92c458f8181e9ac085904a9605dfd2 100644 (file)
@@ -40,7 +40,7 @@ int llc_mac_hdr_init(struct sk_buff *skb,
        case ARPHRD_IEEE802_TR: {
                struct net_device *dev = skb->dev;
                struct trh_hdr *trh;
-               
+
                skb->mac.raw = skb_push(skb, sizeof(*trh));
                trh = tr_hdr(skb);
                trh->ac = AC;
index a28ce525d201b2061ab2d91f056f156f1d6a91ad..fa8324396db39765b65bd0221a5510c838767578 100644 (file)
@@ -39,7 +39,7 @@ void llc_pdu_set_pf_bit(struct sk_buff *skb, u8 bit_value)
 
        llc_pdu_decode_pdu_type(skb, &pdu_type);
        pdu = llc_pdu_sn_hdr(skb);
-       
+
        switch (pdu_type) {
        case LLC_PDU_TYPE_I:
        case LLC_PDU_TYPE_S:
index 19308fece3ad945ae58c4e92dcef5fcfa57812f6..dcfe6c739471b5040cf9dbe34dfbd9d968927bc3 100644 (file)
@@ -142,18 +142,18 @@ out:
 }
 
 static char *llc_conn_state_names[] = {
-       [LLC_CONN_STATE_ADM] =        "adm", 
-       [LLC_CONN_STATE_SETUP] =      "setup", 
+       [LLC_CONN_STATE_ADM] =        "adm",
+       [LLC_CONN_STATE_SETUP] =      "setup",
        [LLC_CONN_STATE_NORMAL] =     "normal",
-       [LLC_CONN_STATE_BUSY] =       "busy", 
-       [LLC_CONN_STATE_REJ] =        "rej", 
-       [LLC_CONN_STATE_AWAIT] =      "await", 
+       [LLC_CONN_STATE_BUSY] =       "busy",
+       [LLC_CONN_STATE_REJ] =        "rej",
+       [LLC_CONN_STATE_AWAIT] =      "await",
        [LLC_CONN_STATE_AWAIT_BUSY] = "await_busy",
        [LLC_CONN_STATE_AWAIT_REJ] =  "await_rej",
        [LLC_CONN_STATE_D_CONN] =     "d_conn",
-       [LLC_CONN_STATE_RESET] =      "reset", 
-       [LLC_CONN_STATE_ERROR] =      "error", 
-       [LLC_CONN_STATE_TEMP] =       "temp", 
+       [LLC_CONN_STATE_RESET] =      "reset",
+       [LLC_CONN_STATE_ERROR] =      "error",
+       [LLC_CONN_STATE_TEMP] =       "temp",
 };
 
 static int llc_seq_core_show(struct seq_file *seq, void *v)
index 6a43201aa32e2d2ead2d593d2bf4c0c1d27101bb..135f7d80069e93e12145c5419bef51151a15dcae 100644 (file)
@@ -175,7 +175,7 @@ struct llc_sap_state llc_sap_state_table[LLC_NR_SAP_STATES] = {
        [LLC_SAP_STATE_INACTIVE - 1] = {
                .curr_state     = LLC_SAP_STATE_INACTIVE,
                .transitions    = llc_sap_inactive_state_transitions,
-               },
+       },
        [LLC_SAP_STATE_ACTIVE - 1] = {
                .curr_state     = LLC_SAP_STATE_ACTIVE,
                .transitions    = llc_sap_active_state_transitions,
index 61cb8cf7d1532a4d4b1abd51244e863fc7e8b887..2615dc81aa36f018e6120cbaada3b685accc4db2 100644 (file)
@@ -201,7 +201,7 @@ static void llc_sap_state_process(struct llc_sap *sap, struct sk_buff *skb)
                        if (sock_queue_rcv_skb(skb->sk, skb))
                                kfree_skb(skb);
                }
-       } 
+       }
        kfree_skb(skb);
 }
 
@@ -215,7 +215,7 @@ static void llc_sap_state_process(struct llc_sap *sap, struct sk_buff *skb)
  *     This function is called when upper layer wants to send a TEST pdu.
  *     Returns 0 for success, 1 otherwise.
  */
-void llc_build_and_send_test_pkt(struct llc_sap *sap, 
+void llc_build_and_send_test_pkt(struct llc_sap *sap,
                                 struct sk_buff *skb, u8 *dmac, u8 dsap)
 {
        struct llc_sap_state_ev *ev = llc_sap_ev(skb);
@@ -224,7 +224,7 @@ void llc_build_and_send_test_pkt(struct llc_sap *sap,
        ev->daddr.lsap = dsap;
        memcpy(ev->saddr.mac, skb->dev->dev_addr, IFHWADDRLEN);
        memcpy(ev->daddr.mac, dmac, IFHWADDRLEN);
-       
+
        ev->type      = LLC_SAP_EV_TYPE_PRIM;
        ev->prim      = LLC_TEST_PRIM;
        ev->prim_type = LLC_PRIM_TYPE_REQ;
index 8275bd33bd9d6b3d0ad2cea55a1c579e14b5f9e5..576355a192ab062c804312f9ebccccebb56f7425 100644 (file)
@@ -112,17 +112,17 @@ static struct llc_station llc_main_station;
 
 static int llc_stat_ev_enable_with_dup_addr_check(struct sk_buff *skb)
 {
-       struct llc_station_state_ev *ev = llc_station_ev(skb);  
-       
+       struct llc_station_state_ev *ev = llc_station_ev(skb);
+
        return ev->type == LLC_STATION_EV_TYPE_SIMPLE &&
               ev->prim_type ==
-                             LLC_STATION_EV_ENABLE_WITH_DUP_ADDR_CHECK ? 0 : 1;
+                             LLC_STATION_EV_ENABLE_WITH_DUP_ADDR_CHECK ? 0 : 1;
 }
 
 static int llc_stat_ev_enable_without_dup_addr_check(struct sk_buff *skb)
 {
-       struct llc_station_state_ev *ev = llc_station_ev(skb);  
-       
+       struct llc_station_state_ev *ev = llc_station_ev(skb);
+
        return ev->type == LLC_STATION_EV_TYPE_SIMPLE &&
               ev->prim_type ==
                        LLC_STATION_EV_ENABLE_WITHOUT_DUP_ADDR_CHECK ? 0 : 1;
@@ -130,8 +130,8 @@ static int llc_stat_ev_enable_without_dup_addr_check(struct sk_buff *skb)
 
 static int llc_stat_ev_ack_tmr_exp_lt_retry_cnt_max_retry(struct sk_buff *skb)
 {
-       struct llc_station_state_ev *ev = llc_station_ev(skb);  
-       
+       struct llc_station_state_ev *ev = llc_station_ev(skb);
+
        return ev->type == LLC_STATION_EV_TYPE_ACK_TMR &&
                llc_main_station.retry_count <
                llc_main_station.maximum_retry ? 0 : 1;
@@ -139,8 +139,8 @@ static int llc_stat_ev_ack_tmr_exp_lt_retry_cnt_max_retry(struct sk_buff *skb)
 
 static int llc_stat_ev_ack_tmr_exp_eq_retry_cnt_max_retry(struct sk_buff *skb)
 {
-       struct llc_station_state_ev *ev = llc_station_ev(skb);  
-       
+       struct llc_station_state_ev *ev = llc_station_ev(skb);
+
        return ev->type == LLC_STATION_EV_TYPE_ACK_TMR &&
                llc_main_station.retry_count ==
                llc_main_station.maximum_retry ? 0 : 1;
@@ -148,7 +148,7 @@ static int llc_stat_ev_ack_tmr_exp_eq_retry_cnt_max_retry(struct sk_buff *skb)
 
 static int llc_stat_ev_rx_null_dsap_xid_c(struct sk_buff *skb)
 {
-       struct llc_station_state_ev *ev = llc_station_ev(skb);  
+       struct llc_station_state_ev *ev = llc_station_ev(skb);
        struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
 
        return ev->type == LLC_STATION_EV_TYPE_PDU &&
@@ -306,7 +306,7 @@ static int llc_station_ac_send_test_r(struct sk_buff *skb)
        llc_pdu_decode_sa(skb, mac_da);
        llc_pdu_decode_ssap(skb, &dsap);
        llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, 0, dsap, LLC_PDU_RSP);
-               llc_pdu_init_as_test_rsp(nskb, skb);
+       llc_pdu_init_as_test_rsp(nskb, skb);
        rc = llc_mac_hdr_init(nskb, llc_station_mac_sa, mac_da);
        if (unlikely(rc))
                goto free;
index 45d7dd92a08804e2978a739b2db6f9d3296eb437..d047a3e15714691f27910661e29143527e5a8fd2 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * sysctl_net_llc.c: sysctl interface to LLC net subsystem.
- * 
+ *
  * Arnaldo Carvalho de Melo <acme@conectiva.com.br>
  */
 
@@ -72,7 +72,7 @@ static struct ctl_table llc2_dir_timeout_table[] = {
                .procname       = "timeout",
                .mode           = 0555,
                .child          = llc2_timeout_table,
-               },
+       },
        { 0 },
 };
 
@@ -82,7 +82,7 @@ static struct ctl_table llc_table[] = {
                .procname       = "llc2",
                .mode           = 0555,
                .child          = llc2_dir_timeout_table,
-               },
+       },
        {
                .ctl_name       = NET_LLC_STATION,
                .procname       = "station",
@@ -98,7 +98,7 @@ static struct ctl_table llc_dir_table[] = {
                .procname       = "llc",
                .mode           = 0555,
                .child          = llc_table,
-               },
+       },
        { 0 },
 };
 
index 80107d4909c5b88fb69c519ea7f4301b93bb63c0..748f7f00909a741cd745a12b9ffbae861cc51896 100644 (file)
@@ -235,6 +235,19 @@ config NF_CONNTRACK_PPTP
 
          To compile it as a module, choose M here.  If unsure, say N.
 
+config NF_CONNTRACK_SANE
+       tristate "SANE protocol support (EXPERIMENTAL)"
+       depends on EXPERIMENTAL && NF_CONNTRACK
+       help
+         SANE is a protocol for remote access to scanners as implemented
+         by the 'saned' daemon. Like FTP, it uses separate control and
+         data connections.
+
+         With this module you can support SANE on a connection tracking
+         firewall.
+
+         To compile it as a module, choose M here.  If unsure, say N.
+
 config NF_CONNTRACK_SIP
        tristate "SIP protocol support (EXPERIMENTAL)"
        depends on EXPERIMENTAL && NF_CONNTRACK
@@ -382,6 +395,32 @@ config NETFILTER_XT_TARGET_CONNSECMARK
 
          To compile it as a module, choose M here.  If unsure, say N.
 
+config NETFILTER_XT_TARGET_TCPMSS
+       tristate '"TCPMSS" target support'
+       depends on NETFILTER_XTABLES && (IPV6 || IPV6=n)
+       ---help---
+         This option adds a `TCPMSS' target, which allows you to alter the
+         MSS value of TCP SYN packets, to control the maximum size for that
+         connection (usually limiting it to your outgoing interface's MTU
+         minus 40).
+
+         This is used to overcome criminally braindead ISPs or servers which
+         block ICMP Fragmentation Needed packets.  The symptoms of this
+         problem are that everything works fine from your Linux
+         firewall/router, but machines behind it can never exchange large
+         packets:
+               1) Web browsers connect, then hang with no data received.
+               2) Small mail works fine, but large emails hang.
+               3) ssh works fine, but scp hangs after initial handshaking.
+
+         Workaround: activate this option and add a rule to your firewall
+         configuration like:
+
+         iptables -A FORWARD -p tcp --tcp-flags SYN,RST SYN \
+                        -j TCPMSS --clamp-mss-to-pmtu
+
+         To compile it as a module, choose M here.  If unsure, say N.
+
 config NETFILTER_XT_MATCH_COMMENT
        tristate  '"comment" match support'
        depends on NETFILTER_XTABLES
index 5dc5574f7e99ea79be21c416405aad456622659e..b2b5c7566b26e74644c787d9282b55c6bacb6c8a 100644 (file)
@@ -29,6 +29,7 @@ obj-$(CONFIG_NF_CONNTRACK_H323) += nf_conntrack_h323.o
 obj-$(CONFIG_NF_CONNTRACK_IRC) += nf_conntrack_irc.o
 obj-$(CONFIG_NF_CONNTRACK_NETBIOS_NS) += nf_conntrack_netbios_ns.o
 obj-$(CONFIG_NF_CONNTRACK_PPTP) += nf_conntrack_pptp.o
+obj-$(CONFIG_NF_CONNTRACK_SANE) += nf_conntrack_sane.o
 obj-$(CONFIG_NF_CONNTRACK_SIP) += nf_conntrack_sip.o
 obj-$(CONFIG_NF_CONNTRACK_TFTP) += nf_conntrack_tftp.o
 
@@ -44,6 +45,7 @@ obj-$(CONFIG_NETFILTER_XT_TARGET_NFQUEUE) += xt_NFQUEUE.o
 obj-$(CONFIG_NETFILTER_XT_TARGET_NFLOG) += xt_NFLOG.o
 obj-$(CONFIG_NETFILTER_XT_TARGET_NOTRACK) += xt_NOTRACK.o
 obj-$(CONFIG_NETFILTER_XT_TARGET_SECMARK) += xt_SECMARK.o
+obj-$(CONFIG_NETFILTER_XT_TARGET_TCPMSS) += xt_TCPMSS.o
 obj-$(CONFIG_NETFILTER_XT_TARGET_CONNSECMARK) += xt_CONNSECMARK.o
 
 # matches
index 626b0011dd8955ee950bd8bc675eb53392a3317b..6fccdcf43e08a0e2738b8060b1d98f2f89e6f2d8 100644 (file)
@@ -60,12 +60,9 @@ static DEFINE_RWLOCK(tcp_lock);
     If it's non-zero, we mark only out of window RST segments as INVALID. */
 int nf_ct_tcp_be_liberal __read_mostly = 0;
 
-/* When connection is picked up from the middle, how many packets are required
-   to pass in each direction when we assume we are in sync - if any side uses
-   window scaling, we lost the game. 
-   If it is set to zero, we disable picking up already established 
+/* If it is set to zero, we disable picking up already established
    connections. */
-int nf_ct_tcp_loose __read_mostly = 3;
+int nf_ct_tcp_loose __read_mostly = 1;
 
 /* Max number of the retransmitted packets without receiving an (acceptable) 
    ACK from the destination. If this number is reached, a shorter timer 
@@ -650,11 +647,10 @@ static int tcp_in_window(struct ip_ct_tcp *state,
                before(sack, receiver->td_end + 1),
                after(ack, receiver->td_end - MAXACKWINDOW(sender)));
 
-       if (sender->loose || receiver->loose ||
-           (before(seq, sender->td_maxend + 1) &&
-            after(end, sender->td_end - receiver->td_maxwin - 1) &&
-            before(sack, receiver->td_end + 1) &&
-            after(ack, receiver->td_end - MAXACKWINDOW(sender)))) {
+       if (before(seq, sender->td_maxend + 1) &&
+           after(end, sender->td_end - receiver->td_maxwin - 1) &&
+           before(sack, receiver->td_end + 1) &&
+           after(ack, receiver->td_end - MAXACKWINDOW(sender))) {
                /*
                 * Take into account window scaling (RFC 1323).
                 */
@@ -699,15 +695,13 @@ static int tcp_in_window(struct ip_ct_tcp *state,
                                state->retrans = 0;
                        }
                }
-               /*
-                * Close the window of disabled window tracking :-)
-                */
-               if (sender->loose)
-                       sender->loose--;
-
                res = 1;
        } else {
-               if (LOG_INVALID(IPPROTO_TCP))
+               res = 0;
+               if (sender->flags & IP_CT_TCP_FLAG_BE_LIBERAL ||
+                   nf_ct_tcp_be_liberal)
+                       res = 1;
+               if (!res && LOG_INVALID(IPPROTO_TCP))
                        nf_log_packet(pf, 0, skb, NULL, NULL, NULL,
                        "nf_ct_tcp: %s ",
                        before(seq, sender->td_maxend + 1) ?
@@ -718,8 +712,6 @@ static int tcp_in_window(struct ip_ct_tcp *state,
                        : "ACK is over the upper bound (ACKed data not seen yet)"
                        : "SEQ is under the lower bound (already ACKed data retransmitted)"
                        : "SEQ is over the upper bound (over the window of the receiver)");
-
-               res = nf_ct_tcp_be_liberal;
        }
   
        DEBUGP("tcp_in_window: res=%i sender end=%u maxend=%u maxwin=%u "
@@ -1063,8 +1055,6 @@ static int tcp_new(struct nf_conn *conntrack,
 
                tcp_options(skb, dataoff, th, &conntrack->proto.tcp.seen[0]);
                conntrack->proto.tcp.seen[1].flags = 0;
-               conntrack->proto.tcp.seen[0].loose = 
-               conntrack->proto.tcp.seen[1].loose = 0;
        } else if (nf_ct_tcp_loose == 0) {
                /* Don't try to pick up connections. */
                return 0;
@@ -1085,11 +1075,11 @@ static int tcp_new(struct nf_conn *conntrack,
                        conntrack->proto.tcp.seen[0].td_maxwin;
                conntrack->proto.tcp.seen[0].td_scale = 0;
 
-               /* We assume SACK. Should we assume window scaling too? */
+               /* We assume SACK and liberal window checking to handle
+                * window scaling */
                conntrack->proto.tcp.seen[0].flags =
-               conntrack->proto.tcp.seen[1].flags = IP_CT_TCP_FLAG_SACK_PERM;
-               conntrack->proto.tcp.seen[0].loose = 
-               conntrack->proto.tcp.seen[1].loose = nf_ct_tcp_loose;
+               conntrack->proto.tcp.seen[1].flags = IP_CT_TCP_FLAG_SACK_PERM |
+                                                    IP_CT_TCP_FLAG_BE_LIBERAL;
        }
     
        conntrack->proto.tcp.seen[1].td_end = 0;
diff --git a/net/netfilter/nf_conntrack_sane.c b/net/netfilter/nf_conntrack_sane.c
new file mode 100644 (file)
index 0000000..eb2d1dc
--- /dev/null
@@ -0,0 +1,242 @@
+/* SANE connection tracking helper
+ * (SANE = Scanner Access Now Easy)
+ * For documentation about the SANE network protocol see
+ * http://www.sane-project.org/html/doc015.html
+ */
+
+/* Copyright (C) 2007 Red Hat, Inc.
+ * Author: Michal Schmidt <mschmidt@redhat.com>
+ * Based on the FTP conntrack helper (net/netfilter/nf_conntrack_ftp.c):
+ *  (C) 1999-2001 Paul `Rusty' Russell
+ *  (C) 2002-2004 Netfilter Core Team <coreteam@netfilter.org>
+ *  (C) 2003,2004 USAGI/WIDE Project <http://www.linux-ipv6.org>
+ *  (C) 2003 Yasuyuki Kozakai @USAGI <yasuyuki.kozakai@toshiba.co.jp>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/netfilter.h>
+#include <linux/in.h>
+#include <linux/tcp.h>
+#include <net/netfilter/nf_conntrack.h>
+#include <net/netfilter/nf_conntrack_helper.h>
+#include <net/netfilter/nf_conntrack_expect.h>
+#include <linux/netfilter/nf_conntrack_sane.h>
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Michal Schmidt <mschmidt@redhat.com>");
+MODULE_DESCRIPTION("SANE connection tracking helper");
+
+static char *sane_buffer;
+
+static DEFINE_SPINLOCK(nf_sane_lock);
+
+#define MAX_PORTS 8
+static u_int16_t ports[MAX_PORTS];
+static unsigned int ports_c;
+module_param_array(ports, ushort, &ports_c, 0400);
+
+#if 0
+#define DEBUGP printk
+#else
+#define DEBUGP(format, args...)
+#endif
+
+struct sane_request {
+       __be32 RPC_code;
+#define SANE_NET_START      7   /* RPC code */
+
+       __be32 handle;
+};
+
+struct sane_reply_net_start {
+       __be32 status;
+#define SANE_STATUS_SUCCESS 0
+
+       __be16 zero;
+       __be16 port;
+       /* other fields aren't interesting for conntrack */
+};
+
+static int help(struct sk_buff **pskb,
+               unsigned int protoff,
+               struct nf_conn *ct,
+               enum ip_conntrack_info ctinfo)
+{
+       unsigned int dataoff, datalen;
+       struct tcphdr _tcph, *th;
+       char *sb_ptr;
+       int ret = NF_ACCEPT;
+       int dir = CTINFO2DIR(ctinfo);
+       struct nf_ct_sane_master *ct_sane_info;
+       struct nf_conntrack_expect *exp;
+       struct nf_conntrack_tuple *tuple;
+       struct sane_request *req;
+       struct sane_reply_net_start *reply;
+       int family = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num;
+
+       ct_sane_info = &nfct_help(ct)->help.ct_sane_info;
+       /* Until there's been traffic both ways, don't look in packets. */
+       if (ctinfo != IP_CT_ESTABLISHED &&
+           ctinfo != IP_CT_ESTABLISHED+IP_CT_IS_REPLY)
+               return NF_ACCEPT;
+
+       /* Not a full tcp header? */
+       th = skb_header_pointer(*pskb, protoff, sizeof(_tcph), &_tcph);
+       if (th == NULL)
+               return NF_ACCEPT;
+
+       /* No data? */
+       dataoff = protoff + th->doff * 4;
+       if (dataoff >= (*pskb)->len)
+               return NF_ACCEPT;
+
+       datalen = (*pskb)->len - dataoff;
+
+       spin_lock_bh(&nf_sane_lock);
+       sb_ptr = skb_header_pointer(*pskb, dataoff, datalen, sane_buffer);
+       BUG_ON(sb_ptr == NULL);
+
+       if (dir == IP_CT_DIR_ORIGINAL) {
+               if (datalen != sizeof(struct sane_request))
+                       goto out;
+
+               req = (struct sane_request *)sb_ptr;
+               if (req->RPC_code != htonl(SANE_NET_START)) {
+                       /* Not an interesting command */
+                       ct_sane_info->state = SANE_STATE_NORMAL;
+                       goto out;
+               }
+
+               /* We're interested in the next reply */
+               ct_sane_info->state = SANE_STATE_START_REQUESTED;
+               goto out;
+       }
+
+       /* Is it a reply to an uninteresting command? */
+       if (ct_sane_info->state != SANE_STATE_START_REQUESTED)
+               goto out;
+
+       /* It's a reply to SANE_NET_START. */
+       ct_sane_info->state = SANE_STATE_NORMAL;
+
+       if (datalen < sizeof(struct sane_reply_net_start)) {
+               DEBUGP("nf_ct_sane: NET_START reply too short\n");
+               goto out;
+       }
+
+       reply = (struct sane_reply_net_start *)sb_ptr;
+       if (reply->status != htonl(SANE_STATUS_SUCCESS)) {
+               /* saned refused the command */
+               DEBUGP("nf_ct_sane: unsuccessful SANE_STATUS = %u\n",
+                       ntohl(reply->status));
+               goto out;
+       }
+
+       /* Invalid saned reply? Ignore it. */
+       if (reply->zero != 0)
+               goto out;
+
+       exp = nf_conntrack_expect_alloc(ct);
+       if (exp == NULL) {
+               ret = NF_DROP;
+               goto out;
+       }
+
+       tuple = &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple;
+       nf_conntrack_expect_init(exp, family,
+                                &tuple->src.u3, &tuple->dst.u3,
+                                IPPROTO_TCP,
+                                NULL, &reply->port);
+
+       DEBUGP("nf_ct_sane: expect: ");
+       NF_CT_DUMP_TUPLE(&exp->tuple);
+       NF_CT_DUMP_TUPLE(&exp->mask);
+
+       /* Can't expect this?  Best to drop packet now. */
+       if (nf_conntrack_expect_related(exp) != 0)
+               ret = NF_DROP;
+
+       nf_conntrack_expect_put(exp);
+
+out:
+       spin_unlock_bh(&nf_sane_lock);
+       return ret;
+}
+
+static struct nf_conntrack_helper sane[MAX_PORTS][2];
+static char sane_names[MAX_PORTS][2][sizeof("sane-65535")];
+
+/* don't make this __exit, since it's called from __init ! */
+static void nf_conntrack_sane_fini(void)
+{
+       int i, j;
+
+       for (i = 0; i < ports_c; i++) {
+               for (j = 0; j < 2; j++) {
+                       DEBUGP("nf_ct_sane: unregistering helper for pf: %d "
+                              "port: %d\n",
+                               sane[i][j].tuple.src.l3num, ports[i]);
+                       nf_conntrack_helper_unregister(&sane[i][j]);
+               }
+       }
+
+       kfree(sane_buffer);
+}
+
+static int __init nf_conntrack_sane_init(void)
+{
+       int i, j = -1, ret = 0;
+       char *tmpname;
+
+       sane_buffer = kmalloc(65536, GFP_KERNEL);
+       if (!sane_buffer)
+               return -ENOMEM;
+
+       if (ports_c == 0)
+               ports[ports_c++] = SANE_PORT;
+
+       /* FIXME should be configurable whether IPv4 and IPv6 connections
+                are tracked or not - YK */
+       for (i = 0; i < ports_c; i++) {
+               sane[i][0].tuple.src.l3num = PF_INET;
+               sane[i][1].tuple.src.l3num = PF_INET6;
+               for (j = 0; j < 2; j++) {
+                       sane[i][j].tuple.src.u.tcp.port = htons(ports[i]);
+                       sane[i][j].tuple.dst.protonum = IPPROTO_TCP;
+                       sane[i][j].mask.src.u.tcp.port = 0xFFFF;
+                       sane[i][j].mask.dst.protonum = 0xFF;
+                       sane[i][j].max_expected = 1;
+                       sane[i][j].timeout = 5 * 60;    /* 5 Minutes */
+                       sane[i][j].me = THIS_MODULE;
+                       sane[i][j].help = help;
+                       tmpname = &sane_names[i][j][0];
+                       if (ports[i] == SANE_PORT)
+                               sprintf(tmpname, "sane");
+                       else
+                               sprintf(tmpname, "sane-%d", ports[i]);
+                       sane[i][j].name = tmpname;
+
+                       DEBUGP("nf_ct_sane: registering helper for pf: %d "
+                              "port: %d\n",
+                               sane[i][j].tuple.src.l3num, ports[i]);
+                       ret = nf_conntrack_helper_register(&sane[i][j]);
+                       if (ret) {
+                               printk(KERN_ERR "nf_ct_sane: failed to "
+                                      "register helper for pf: %d port: %d\n",
+                                       sane[i][j].tuple.src.l3num, ports[i]);
+                               nf_conntrack_sane_fini();
+                               return ret;
+                       }
+               }
+       }
+
+       return 0;
+}
+
+module_init(nf_conntrack_sane_init);
+module_exit(nf_conntrack_sane_fini);
index 50de965bb1043093d06ab11dcfefab81dc5f5df2..195e92990da77a159fe32f7f2450d516b1cf9497 100644 (file)
@@ -33,9 +33,7 @@ target(struct sk_buff **pskb,
 {
        const struct xt_classify_target_info *clinfo = targinfo;
 
-       if ((*pskb)->priority != clinfo->priority)
-               (*pskb)->priority = clinfo->priority;
-
+       (*pskb)->priority = clinfo->priority;
        return XT_CONTINUE;
 }
 
index 0534bfa65cce290d5aed268d68af2be33f8c5b08..795c058b16a5bbd2dbf6c5b1273256d73ab8b1fa 100644 (file)
@@ -61,7 +61,7 @@ target(struct sk_buff **pskb,
 #else
                                nf_conntrack_event_cache(IPCT_MARK, *pskb);
 #endif
-               }
+                       }
                        break;
                case XT_CONNMARK_SAVE:
                        newmark = (*ctmark & ~markinfo->mask) |
@@ -78,8 +78,7 @@ target(struct sk_buff **pskb,
                case XT_CONNMARK_RESTORE:
                        mark = (*pskb)->mark;
                        diff = (*ctmark ^ mark) & markinfo->mask;
-                       if (diff != 0)
-                               (*pskb)->mark = mark ^ diff;
+                       (*pskb)->mark = mark ^ diff;
                        break;
                }
        }
index a3fe3c334b09efa268198ab32cb6960605e33597..1ab0db641f9641b97398c806668a760b5a5bab7c 100644 (file)
@@ -41,8 +41,7 @@ static void secmark_save(struct sk_buff *skb)
 
                connsecmark = nf_ct_get_secmark(skb, &ctinfo);
                if (connsecmark && !*connsecmark)
-                       if (*connsecmark != skb->secmark)
-                               *connsecmark = skb->secmark;
+                       *connsecmark = skb->secmark;
        }
 }
 
@@ -58,8 +57,7 @@ static void secmark_restore(struct sk_buff *skb)
 
                connsecmark = nf_ct_get_secmark(skb, &ctinfo);
                if (connsecmark && *connsecmark)
-                       if (skb->secmark != *connsecmark)
-                               skb->secmark = *connsecmark;
+                       skb->secmark = *connsecmark;
        }
 }
 
index 0b48547e8d64bb0a2e41998733713a1b51730196..cfc45af357d50146034fcc052d48a7ba4eb8cf96 100644 (file)
@@ -31,9 +31,7 @@ target_v0(struct sk_buff **pskb,
 {
        const struct xt_mark_target_info *markinfo = targinfo;
 
-       if((*pskb)->mark != markinfo->mark)
-               (*pskb)->mark = markinfo->mark;
-
+       (*pskb)->mark = markinfo->mark;
        return XT_CONTINUE;
 }
 
@@ -62,9 +60,7 @@ target_v1(struct sk_buff **pskb,
                break;
        }
 
-       if((*pskb)->mark != mark)
-               (*pskb)->mark = mark;
-
+       (*pskb)->mark = mark;
        return XT_CONTINUE;
 }
 
index add752196290d8c44cce0a54f4fa9de0eccff8c1..f1131c3a9db5bcfd174911b45336d7aa3052621a 100644 (file)
@@ -47,9 +47,7 @@ static unsigned int target(struct sk_buff **pskb, const struct net_device *in,
                BUG();
        }
 
-       if ((*pskb)->secmark != secmark)
-               (*pskb)->secmark = secmark;
-
+       (*pskb)->secmark = secmark;
        return XT_CONTINUE;
 }
 
diff --git a/net/netfilter/xt_TCPMSS.c b/net/netfilter/xt_TCPMSS.c
new file mode 100644 (file)
index 0000000..db7e38c
--- /dev/null
@@ -0,0 +1,296 @@
+/*
+ * This is a module which is used for setting the MSS option in TCP packets.
+ *
+ * Copyright (C) 2000 Marc Boucher <marc@mbsi.ca>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/module.h>
+#include <linux/skbuff.h>
+#include <linux/ip.h>
+#include <linux/ipv6.h>
+#include <linux/tcp.h>
+#include <net/ipv6.h>
+#include <net/tcp.h>
+
+#include <linux/netfilter_ipv4/ip_tables.h>
+#include <linux/netfilter_ipv6/ip6_tables.h>
+#include <linux/netfilter/x_tables.h>
+#include <linux/netfilter/xt_tcpudp.h>
+#include <linux/netfilter/xt_TCPMSS.h>
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Marc Boucher <marc@mbsi.ca>");
+MODULE_DESCRIPTION("x_tables TCP MSS modification module");
+MODULE_ALIAS("ipt_TCPMSS");
+MODULE_ALIAS("ip6t_TCPMSS");
+
+static inline unsigned int
+optlen(const u_int8_t *opt, unsigned int offset)
+{
+       /* Beware zero-length options: make finite progress */
+       if (opt[offset] <= TCPOPT_NOP || opt[offset+1] == 0)
+               return 1;
+       else
+               return opt[offset+1];
+}
+
+static int
+tcpmss_mangle_packet(struct sk_buff **pskb,
+                    const struct xt_tcpmss_info *info,
+                    unsigned int tcphoff,
+                    unsigned int minlen)
+{
+       struct tcphdr *tcph;
+       unsigned int tcplen, i;
+       __be16 oldval;
+       u16 newmss;
+       u8 *opt;
+
+       if (!skb_make_writable(pskb, (*pskb)->len))
+               return -1;
+
+       tcplen = (*pskb)->len - tcphoff;
+       tcph = (struct tcphdr *)((*pskb)->nh.raw + tcphoff);
+
+       /* Since it passed flags test in tcp match, we know it is is
+          not a fragment, and has data >= tcp header length.  SYN
+          packets should not contain data: if they did, then we risk
+          running over MTU, sending Frag Needed and breaking things
+          badly. --RR */
+       if (tcplen != tcph->doff*4) {
+               if (net_ratelimit())
+                       printk(KERN_ERR "xt_TCPMSS: bad length (%u bytes)\n",
+                              (*pskb)->len);
+               return -1;
+       }
+
+       if (info->mss == XT_TCPMSS_CLAMP_PMTU) {
+               if (dst_mtu((*pskb)->dst) <= minlen) {
+                       if (net_ratelimit())
+                               printk(KERN_ERR "xt_TCPMSS: "
+                                      "unknown or invalid path-MTU (%u)\n",
+                                      dst_mtu((*pskb)->dst));
+                       return -1;
+               }
+               newmss = dst_mtu((*pskb)->dst) - minlen;
+       } else
+               newmss = info->mss;
+
+       opt = (u_int8_t *)tcph;
+       for (i = sizeof(struct tcphdr); i < tcph->doff*4; i += optlen(opt, i)) {
+               if (opt[i] == TCPOPT_MSS && tcph->doff*4 - i >= TCPOLEN_MSS &&
+                   opt[i+1] == TCPOLEN_MSS) {
+                       u_int16_t oldmss;
+
+                       oldmss = (opt[i+2] << 8) | opt[i+3];
+
+                       if (info->mss == XT_TCPMSS_CLAMP_PMTU &&
+                           oldmss <= newmss)
+                               return 0;
+
+                       opt[i+2] = (newmss & 0xff00) >> 8;
+                       opt[i+3] = (newmss & 0x00ff);
+
+                       nf_proto_csum_replace2(&tcph->check, *pskb,
+                                              htons(oldmss), htons(newmss), 0);
+                       return 0;
+               }
+       }
+
+       /*
+        * MSS Option not found ?! add it..
+        */
+       if (skb_tailroom((*pskb)) < TCPOLEN_MSS) {
+               struct sk_buff *newskb;
+
+               newskb = skb_copy_expand(*pskb, skb_headroom(*pskb),
+                                        TCPOLEN_MSS, GFP_ATOMIC);
+               if (!newskb)
+                       return -1;
+               kfree_skb(*pskb);
+               *pskb = newskb;
+               tcph = (struct tcphdr *)((*pskb)->nh.raw + tcphoff);
+       }
+
+       skb_put((*pskb), TCPOLEN_MSS);
+
+       opt = (u_int8_t *)tcph + sizeof(struct tcphdr);
+       memmove(opt + TCPOLEN_MSS, opt, tcplen - sizeof(struct tcphdr));
+
+       nf_proto_csum_replace2(&tcph->check, *pskb,
+                              htons(tcplen), htons(tcplen + TCPOLEN_MSS), 1);
+       opt[0] = TCPOPT_MSS;
+       opt[1] = TCPOLEN_MSS;
+       opt[2] = (newmss & 0xff00) >> 8;
+       opt[3] = (newmss & 0x00ff);
+
+       nf_proto_csum_replace4(&tcph->check, *pskb, 0, *((__be32 *)opt), 0);
+
+       oldval = ((__be16 *)tcph)[6];
+       tcph->doff += TCPOLEN_MSS/4;
+       nf_proto_csum_replace2(&tcph->check, *pskb,
+                               oldval, ((__be16 *)tcph)[6], 0);
+       return TCPOLEN_MSS;
+}
+
+static unsigned int
+xt_tcpmss_target4(struct sk_buff **pskb,
+                 const struct net_device *in,
+                 const struct net_device *out,
+                 unsigned int hooknum,
+                 const struct xt_target *target,
+                 const void *targinfo)
+{
+       struct iphdr *iph = (*pskb)->nh.iph;
+       __be16 newlen;
+       int ret;
+
+       ret = tcpmss_mangle_packet(pskb, targinfo, iph->ihl * 4,
+                                  sizeof(*iph) + sizeof(struct tcphdr));
+       if (ret < 0)
+               return NF_DROP;
+       if (ret > 0) {
+               iph = (*pskb)->nh.iph;
+               newlen = htons(ntohs(iph->tot_len) + ret);
+               nf_csum_replace2(&iph->check, iph->tot_len, newlen);
+               iph->tot_len = newlen;
+       }
+       return XT_CONTINUE;
+}
+
+#if defined(CONFIG_IP6_NF_IPTABLES) || defined(CONFIG_IP6_NF_IPTABLES_MODULE)
+static unsigned int
+xt_tcpmss_target6(struct sk_buff **pskb,
+                 const struct net_device *in,
+                 const struct net_device *out,
+                 unsigned int hooknum,
+                 const struct xt_target *target,
+                 const void *targinfo)
+{
+       struct ipv6hdr *ipv6h = (*pskb)->nh.ipv6h;
+       u8 nexthdr;
+       int tcphoff;
+       int ret;
+
+       nexthdr = ipv6h->nexthdr;
+       tcphoff = ipv6_skip_exthdr(*pskb, sizeof(*ipv6h), &nexthdr);
+       if (tcphoff < 0) {
+               WARN_ON(1);
+               return NF_DROP;
+       }
+       ret = tcpmss_mangle_packet(pskb, targinfo, tcphoff,
+                                  sizeof(*ipv6h) + sizeof(struct tcphdr));
+       if (ret < 0)
+               return NF_DROP;
+       if (ret > 0) {
+               ipv6h = (*pskb)->nh.ipv6h;
+               ipv6h->payload_len = htons(ntohs(ipv6h->payload_len) + ret);
+       }
+       return XT_CONTINUE;
+}
+#endif
+
+#define TH_SYN 0x02
+
+/* Must specify -p tcp --syn */
+static inline int find_syn_match(const struct xt_entry_match *m)
+{
+       const struct xt_tcp *tcpinfo = (const struct xt_tcp *)m->data;
+
+       if (strcmp(m->u.kernel.match->name, "tcp") == 0 &&
+           tcpinfo->flg_cmp & TH_SYN &&
+           !(tcpinfo->invflags & XT_TCP_INV_FLAGS))
+               return 1;
+
+       return 0;
+}
+
+static int
+xt_tcpmss_checkentry4(const char *tablename,
+                     const void *entry,
+                     const struct xt_target *target,
+                     void *targinfo,
+                     unsigned int hook_mask)
+{
+       const struct xt_tcpmss_info *info = targinfo;
+       const struct ipt_entry *e = entry;
+
+       if (info->mss == XT_TCPMSS_CLAMP_PMTU &&
+           (hook_mask & ~((1 << NF_IP_FORWARD) |
+                          (1 << NF_IP_LOCAL_OUT) |
+                          (1 << NF_IP_POST_ROUTING))) != 0) {
+               printk("xt_TCPMSS: path-MTU clamping only supported in "
+                      "FORWARD, OUTPUT and POSTROUTING hooks\n");
+               return 0;
+       }
+       if (IPT_MATCH_ITERATE(e, find_syn_match))
+               return 1;
+       printk("xt_TCPMSS: Only works on TCP SYN packets\n");
+       return 0;
+}
+
+#if defined(CONFIG_IP6_NF_IPTABLES) || defined(CONFIG_IP6_NF_IPTABLES_MODULE)
+static int
+xt_tcpmss_checkentry6(const char *tablename,
+                     const void *entry,
+                     const struct xt_target *target,
+                     void *targinfo,
+                     unsigned int hook_mask)
+{
+       const struct xt_tcpmss_info *info = targinfo;
+       const struct ip6t_entry *e = entry;
+
+       if (info->mss == XT_TCPMSS_CLAMP_PMTU &&
+           (hook_mask & ~((1 << NF_IP6_FORWARD) |
+                          (1 << NF_IP6_LOCAL_OUT) |
+                          (1 << NF_IP6_POST_ROUTING))) != 0) {
+               printk("xt_TCPMSS: path-MTU clamping only supported in "
+                      "FORWARD, OUTPUT and POSTROUTING hooks\n");
+               return 0;
+       }
+       if (IP6T_MATCH_ITERATE(e, find_syn_match))
+               return 1;
+       printk("xt_TCPMSS: Only works on TCP SYN packets\n");
+       return 0;
+}
+#endif
+
+static struct xt_target xt_tcpmss_reg[] = {
+       {
+               .family         = AF_INET,
+               .name           = "TCPMSS",
+               .checkentry     = xt_tcpmss_checkentry4,
+               .target         = xt_tcpmss_target4,
+               .targetsize     = sizeof(struct xt_tcpmss_info),
+               .proto          = IPPROTO_TCP,
+               .me             = THIS_MODULE,
+       },
+#if defined(CONFIG_IP6_NF_IPTABLES) || defined(CONFIG_IP6_NF_IPTABLES_MODULE)
+       {
+               .family         = AF_INET6,
+               .name           = "TCPMSS",
+               .checkentry     = xt_tcpmss_checkentry6,
+               .target         = xt_tcpmss_target6,
+               .targetsize     = sizeof(struct xt_tcpmss_info),
+               .proto          = IPPROTO_TCP,
+               .me             = THIS_MODULE,
+       },
+#endif
+};
+
+static int __init xt_tcpmss_init(void)
+{
+       return xt_register_targets(xt_tcpmss_reg, ARRAY_SIZE(xt_tcpmss_reg));
+}
+
+static void __exit xt_tcpmss_fini(void)
+{
+       xt_unregister_targets(xt_tcpmss_reg, ARRAY_SIZE(xt_tcpmss_reg));
+}
+
+module_init(xt_tcpmss_init);
+module_exit(xt_tcpmss_fini);
index f28bf69d3d4270d835ffa279182377e90934bd95..bd1f7a2048d6d8cca560e3cd714278530965b68f 100644 (file)
@@ -414,6 +414,7 @@ hashlimit_init_dst(struct xt_hashlimit_htable *hinfo, struct dsthash_dst *dst,
        switch (nexthdr) {
        case IPPROTO_TCP:
        case IPPROTO_UDP:
+       case IPPROTO_UDPLITE:
        case IPPROTO_SCTP:
        case IPPROTO_DCCP:
                ports = skb_header_pointer(skb, protoff, sizeof(_ports),
index 73e0ff469bff284c765bc80ebcc723af3e81f38e..07e47dbcb0a9cd1fa455ef8b7f7d60c19ac33971 100644 (file)
@@ -292,7 +292,7 @@ static int netlbl_cipsov4_add_std(struct genl_info *info)
                                        }
                        }
                doi_def->map.std->cat.local = kcalloc(
-                                             doi_def->map.std->cat.local_size,
+                                             doi_def->map.std->cat.local_size,
                                              sizeof(u32),
                                              GFP_KERNEL);
                if (doi_def->map.std->cat.local == NULL) {
@@ -300,7 +300,7 @@ static int netlbl_cipsov4_add_std(struct genl_info *info)
                        goto add_std_failure;
                }
                doi_def->map.std->cat.cipso = kcalloc(
-                                             doi_def->map.std->cat.cipso_size,
+                                             doi_def->map.std->cat.cipso_size,
                                              sizeof(u32),
                                              GFP_KERNEL);
                if (doi_def->map.std->cat.cipso == NULL) {
@@ -325,10 +325,10 @@ static int netlbl_cipsov4_add_std(struct genl_info *info)
                                if (cat_loc == NULL || cat_rem == NULL)
                                        goto add_std_failure;
                                doi_def->map.std->cat.local[
-                                                       nla_get_u32(cat_loc)] =
+                                                       nla_get_u32(cat_loc)] =
                                        nla_get_u32(cat_rem);
                                doi_def->map.std->cat.cipso[
-                                                       nla_get_u32(cat_rem)] =
+                                                       nla_get_u32(cat_rem)] =
                                        nla_get_u32(cat_loc);
                        }
        }
index 383dd4e82ee150fc33a3a8b726c0d5e02ff7f4b8..f6ee9b47428bf3b1c987fd68e8100fcd735cdca7 100644 (file)
@@ -8,7 +8,7 @@
  *             modify it under the terms of the GNU General Public License
  *             as published by the Free Software Foundation; either version
  *             2 of the License, or (at your option) any later version.
- * 
+ *
  * Tue Jun 26 14:36:48 MEST 2001 Herbert "herp" Rosmanith
  *                               added netlink_proto_exit
  * Tue Jan 22 18:32:44 BRST 2002 Arnaldo C. de Melo <acme@conectiva.com.br>
@@ -470,7 +470,7 @@ static int netlink_release(struct socket *sock)
                                          };
                atomic_notifier_call_chain(&netlink_chain,
                                NETLINK_URELEASE, &n);
-       }       
+       }
 
        module_put(nlk->module);
 
@@ -528,11 +528,11 @@ retry:
        return err;
 }
 
-static inline int netlink_capable(struct socket *sock, unsigned int flag) 
-{ 
+static inline int netlink_capable(struct socket *sock, unsigned int flag)
+{
        return (nl_table[sock->sk->sk_protocol].nl_nonroot & flag) ||
               capable(CAP_NET_ADMIN);
-} 
+}
 
 static void
 netlink_update_subscriptions(struct sock *sk, unsigned int subscriptions)
@@ -574,7 +574,7 @@ static int netlink_bind(struct socket *sock, struct sockaddr *addr, int addr_len
        struct netlink_sock *nlk = nlk_sk(sk);
        struct sockaddr_nl *nladdr = (struct sockaddr_nl *)addr;
        int err;
-       
+
        if (nladdr->nl_family != AF_NETLINK)
                return -EINVAL;
 
@@ -605,9 +605,9 @@ static int netlink_bind(struct socket *sock, struct sockaddr *addr, int addr_len
 
        netlink_table_grab();
        netlink_update_subscriptions(sk, nlk->subscriptions +
-                                        hweight32(nladdr->nl_groups) -
-                                        hweight32(nlk->groups[0]));
-       nlk->groups[0] = (nlk->groups[0] & ~0xffffffffUL) | nladdr->nl_groups; 
+                                        hweight32(nladdr->nl_groups) -
+                                        hweight32(nlk->groups[0]));
+       nlk->groups[0] = (nlk->groups[0] & ~0xffffffffUL) | nladdr->nl_groups;
        netlink_update_listeners(sk);
        netlink_table_ungrab();
 
@@ -652,7 +652,7 @@ static int netlink_getname(struct socket *sock, struct sockaddr *addr, int *addr
        struct sock *sk = sock->sk;
        struct netlink_sock *nlk = nlk_sk(sk);
        struct sockaddr_nl *nladdr=(struct sockaddr_nl *)addr;
-       
+
        nladdr->nl_family = AF_NETLINK;
        nladdr->nl_pad = 0;
        *addr_len = sizeof(*nladdr);
@@ -999,7 +999,7 @@ void netlink_set_err(struct sock *ssk, u32 pid, u32 group, int code)
 }
 
 static int netlink_setsockopt(struct socket *sock, int level, int optname,
-                              char __user *optval, int optlen)
+                             char __user *optval, int optlen)
 {
        struct sock *sk = sock->sk;
        struct netlink_sock *nlk = nlk_sk(sk);
@@ -1054,7 +1054,7 @@ static int netlink_setsockopt(struct socket *sock, int level, int optname,
 }
 
 static int netlink_getsockopt(struct socket *sock, int level, int optname,
-                              char __user *optval, int __user *optlen)
+                             char __user *optval, int __user *optlen)
 {
        struct sock *sk = sock->sk;
        struct netlink_sock *nlk = nlk_sk(sk);
@@ -1257,15 +1257,15 @@ static void netlink_data_ready(struct sock *sk, int len)
 }
 
 /*
- *     We export these functions to other modules. They provide a 
+ *     We export these functions to other modules. They provide a
  *     complete set of kernel non-blocking support for message
  *     queueing.
  */
 
 struct sock *
 netlink_kernel_create(int unit, unsigned int groups,
-                      void (*input)(struct sock *sk, int len),
-                      struct module *module)
+                     void (*input)(struct sock *sk, int len),
+                     struct module *module)
 {
        struct socket *sock;
        struct sock *sk;
@@ -1317,10 +1317,10 @@ out_sock_release:
 }
 
 void netlink_set_nonroot(int protocol, unsigned int flags)
-{ 
-       if ((unsigned int)protocol < MAX_LINKS) 
+{
+       if ((unsigned int)protocol < MAX_LINKS)
                nl_table[protocol].nl_nonroot = flags;
-} 
+}
 
 static void netlink_destroy_callback(struct netlink_callback *cb)
 {
@@ -1341,7 +1341,7 @@ static int netlink_dump(struct sock *sk)
        struct sk_buff *skb;
        struct nlmsghdr *nlh;
        int len, err = -ENOBUFS;
-       
+
        skb = sock_rmalloc(sk, NLMSG_GOODSIZE, 0, GFP_KERNEL);
        if (!skb)
                goto errout;
@@ -1626,7 +1626,7 @@ static void *netlink_seq_next(struct seq_file *seq, void *v, loff_t *pos)
 
        if (v == SEQ_START_TOKEN)
                return netlink_seq_socket_idx(seq, 0);
-               
+
        s = sk_next(v);
        if (s)
                return s;
@@ -1732,7 +1732,7 @@ int netlink_unregister_notifier(struct notifier_block *nb)
 {
        return atomic_notifier_chain_unregister(&netlink_chain, nb);
 }
-                
+
 static const struct proto_ops netlink_ops = {
        .family =       PF_NETLINK,
        .owner =        THIS_MODULE,
@@ -1808,7 +1808,7 @@ static int __init netlink_proto_init(void)
 #ifdef CONFIG_PROC_FS
        proc_net_fops_create("netlink", 0, &netlink_seq_fops);
 #endif
-       /* The netlink device handler may be needed early. */ 
+       /* The netlink device handler may be needed early. */
        rtnetlink_init();
 out:
        return err;
index 548e4e6e698f041f3802a28339b4ed69ba971b7c..c2996794eb25c0c939dcd52ae594e0727322e654 100644 (file)
@@ -310,7 +310,7 @@ static int genl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh,
        if (nlh->nlmsg_type < NLMSG_MIN_TYPE)
                goto ignore;
 
-               family = genl_family_find_byid(nlh->nlmsg_type);
+       family = genl_family_find_byid(nlh->nlmsg_type);
        if (family == NULL) {
                err = -ENOENT;
                goto errout;
index 43bbe2c9e49aa48f8b8995e857945f440dc98acd..799b76806bc30c4b70541fadd1f8b608a1f398f9 100644 (file)
@@ -110,7 +110,7 @@ static int nr_device_event(struct notifier_block *this, unsigned long event, voi
 
        nr_kill_by_device(dev);
        nr_rt_device_down(dev);
-       
+
        return NOTIFY_DONE;
 }
 
@@ -137,7 +137,7 @@ static struct sock *nr_find_listener(ax25_address *addr)
        sk_for_each(s, node, &nr_list)
                if (!ax25cmp(&nr_sk(s)->source_addr, addr) &&
                    s->sk_state == TCP_LISTEN) {
-                       bh_lock_sock(s);
+                       bh_lock_sock(s);
                        goto found;
                }
        s = NULL;
@@ -157,7 +157,7 @@ static struct sock *nr_find_socket(unsigned char index, unsigned char id)
        spin_lock_bh(&nr_list_lock);
        sk_for_each(s, node, &nr_list) {
                struct nr_sock *nr = nr_sk(s);
-               
+
                if (nr->my_index == index && nr->my_id == id) {
                        bh_lock_sock(s);
                        goto found;
@@ -181,10 +181,10 @@ static struct sock *nr_find_peer(unsigned char index, unsigned char id,
        spin_lock_bh(&nr_list_lock);
        sk_for_each(s, node, &nr_list) {
                struct nr_sock *nr = nr_sk(s);
-               
+
                if (nr->your_index == index && nr->your_id == id &&
                    !ax25cmp(&nr->dest_addr, dest)) {
-                       bh_lock_sock(s);
+                       bh_lock_sock(s);
                        goto found;
                }
        }
@@ -341,17 +341,17 @@ static int nr_getsockopt(struct socket *sock, int level, int optname,
        struct sock *sk = sock->sk;
        struct nr_sock *nr = nr_sk(sk);
        int val = 0;
-       int len; 
+       int len;
 
        if (level != SOL_NETROM)
                return -ENOPROTOOPT;
-       
+
        if (get_user(len, optlen))
                return -EFAULT;
 
        if (len < 0)
                return -EINVAL;
-               
+
        switch (optname) {
        case NETROM_T1:
                val = nr->t1 / HZ;
@@ -537,7 +537,7 @@ static int nr_release(struct socket *sock)
                break;
        }
 
-       sock->sk   = NULL;      
+       sock->sk   = NULL;
        release_sock(sk);
        sock_put(sk);
 
@@ -644,7 +644,7 @@ static int nr_connect(struct socket *sock, struct sockaddr *uaddr,
                return -EISCONN;        /* No reconnect on a seqpacket socket */
        }
 
-       sk->sk_state   = TCP_CLOSE;     
+       sk->sk_state   = TCP_CLOSE;
        sock->state = SS_UNCONNECTED;
 
        if (addr_len != sizeof(struct sockaddr_ax25) && addr_len != sizeof(struct full_sockaddr_ax25)) {
@@ -710,7 +710,7 @@ static int nr_connect(struct socket *sock, struct sockaddr *uaddr,
                release_sock(sk);
                return -EINPROGRESS;
        }
-               
+
        /*
         * A Connect Ack with Choke or timeout or failed routing will go to
         * closed.
@@ -848,7 +848,7 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
 int nr_rx_frame(struct sk_buff *skb, struct net_device *dev)
 {
        struct sock *sk;
-       struct sock *make;      
+       struct sock *make;
        struct nr_sock *nr_make;
        ax25_address *src, *dest, *user;
        unsigned short circuit_index, circuit_id;
@@ -1258,10 +1258,10 @@ static void *nr_info_next(struct seq_file *seq, void *v, loff_t *pos)
 {
        ++*pos;
 
-       return (v == SEQ_START_TOKEN) ? sk_head(&nr_list) 
+       return (v == SEQ_START_TOKEN) ? sk_head(&nr_list)
                : sk_next((struct sock *)v);
 }
-       
+
 static void nr_info_stop(struct seq_file *seq, void *v)
 {
        spin_unlock_bh(&nr_list_lock);
@@ -1291,7 +1291,7 @@ static int nr_info_show(struct seq_file *seq, void *v)
 
                seq_printf(seq, "%-9s ", ax2asc(buf, &nr->user_addr));
                seq_printf(seq, "%-9s ", ax2asc(buf, &nr->dest_addr));
-               seq_printf(seq, 
+               seq_printf(seq,
 "%-9s %-3s  %02X/%02X %02X/%02X %2d %3d %3d %3d %3lu/%03lu %2lu/%02lu %3lu/%03lu %3lu/%03lu %2d/%02d %3d %5d %5d %ld\n",
                        ax2asc(buf, &nr->source_addr),
                        devname,
@@ -1329,12 +1329,12 @@ static struct seq_operations nr_info_seqops = {
        .stop = nr_info_stop,
        .show = nr_info_show,
 };
+
 static int nr_info_open(struct inode *inode, struct file *file)
 {
        return seq_open(file, &nr_info_seqops);
 }
+
 static struct file_operations nr_info_fops = {
        .owner = THIS_MODULE,
        .open = nr_info_open,
@@ -1415,7 +1415,7 @@ static int __init nr_proto_init(void)
                        printk(KERN_ERR "NET/ROM: nr_proto_init - unable to allocate device structure\n");
                        goto fail;
                }
-               
+
                dev->base_addr = i;
                if (register_netdev(dev)) {
                        printk(KERN_ERR "NET/ROM: nr_proto_init - unable to register network device\n");
@@ -1430,7 +1430,7 @@ static int __init nr_proto_init(void)
                printk(KERN_ERR "NET/ROM: nr_proto_init - unable to register socket family\n");
                goto fail;
        }
-               
+
        register_netdevice_notifier(&nr_dev_notifier);
 
        ax25_register_pid(&nr_pid);
index 8f88964099ef05744db60430922c2e538ebffcc5..e9909aeb43e9ed12346297e1e180fd1c36dbdf03 100644 (file)
@@ -781,8 +781,8 @@ int nr_route_frame(struct sk_buff *skb, ax25_cb *ax25)
 
        if (ax25 != NULL) {
                ret = nr_add_node(nr_src, "", &ax25->dest_addr, ax25->digipeat,
-                                 ax25->ax25_dev->dev, 0,
-                                 sysctl_netrom_obsolescence_count_initialiser);
+                                 ax25->ax25_dev->dev, 0,
+                                 sysctl_netrom_obsolescence_count_initialiser);
                if (ret)
                        return ret;
        }
@@ -861,8 +861,8 @@ static void *nr_node_start(struct seq_file *seq, loff_t *pos)
        struct nr_node *nr_node;
        struct hlist_node *node;
        int i = 1;
-       spin_lock_bh(&nr_node_list_lock);
+
+       spin_lock_bh(&nr_node_list_lock);
        if (*pos == 0)
                return SEQ_START_TOKEN;
 
@@ -879,8 +879,8 @@ static void *nr_node_next(struct seq_file *seq, void *v, loff_t *pos)
 {
        struct hlist_node *node;
        ++*pos;
-       
-       node = (v == SEQ_START_TOKEN)  
+
+       node = (v == SEQ_START_TOKEN)
                ? nr_node_list.first
                : ((struct nr_node *)v)->node_node.next;
 
@@ -963,8 +963,8 @@ static void *nr_neigh_next(struct seq_file *seq, void *v, loff_t *pos)
 {
        struct hlist_node *node;
        ++*pos;
-       
-       node = (v == SEQ_START_TOKEN)  
+
+       node = (v == SEQ_START_TOKEN)
                ? nr_neigh_list.first
                : ((struct nr_neigh *)v)->neigh_node.next;
 
@@ -997,7 +997,7 @@ static int nr_neigh_show(struct seq_file *seq, void *v)
 
                if (nr_neigh->digipeat != NULL) {
                        for (i = 0; i < nr_neigh->digipeat->ndigi; i++)
-                               seq_printf(seq, " %s", 
+                               seq_printf(seq, " %s",
                                           ax2asc(buf, &nr_neigh->digipeat->calls[i]));
                }
 
index bcb9946b4f5628f59276cfed1082c33135d95119..cfab5721a6089c2c41f99b8e72ab181155c9f3e4 100644 (file)
@@ -57,7 +57,7 @@ void nr_frames_acked(struct sock *sk, unsigned short nr)
         */
        if (nrom->va != nr) {
                while (skb_peek(&nrom->ack_queue) != NULL && nrom->va != nr) {
-                       skb = skb_dequeue(&nrom->ack_queue);
+                       skb = skb_dequeue(&nrom->ack_queue);
                        kfree_skb(skb);
                        nrom->va = (nrom->va + 1) % NR_MODULUS;
                }
index ddba1c144260d4b6adfe1b288c9a68739d551b31..6cfaad952c6cdcbd36e5991355b1673f7394d211 100644 (file)
@@ -43,7 +43,7 @@ void nr_init_timers(struct sock *sk)
        init_timer(&nr->t1timer);
        nr->t1timer.data     = (unsigned long)sk;
        nr->t1timer.function = &nr_t1timer_expiry;
-       
+
        init_timer(&nr->t2timer);
        nr->t2timer.data     = (unsigned long)sk;
        nr->t2timer.function = &nr_t2timer_expiry;
index 6bb8dda849dc71d1de1bd13ca8942eb6d607316f..e4b27d7aae79b7cd288d98b9f9ddd6cca026f0c3 100644 (file)
@@ -35,7 +35,7 @@ static int min_reset[]   = {0}, max_reset[]   = {1};
 static struct ctl_table_header *nr_table_header;
 
 static ctl_table nr_table[] = {
-        {
+       {
                .ctl_name       = NET_NETROM_DEFAULT_PATH_QUALITY,
                .procname       = "default_path_quality",
                .data           = &sysctl_netrom_default_path_quality,
@@ -46,18 +46,18 @@ static ctl_table nr_table[] = {
                .extra1         = &min_quality,
                .extra2         = &max_quality
        },
-        {
+       {
                .ctl_name       = NET_NETROM_OBSOLESCENCE_COUNT_INITIALISER,
                .procname       = "obsolescence_count_initialiser",
                .data           = &sysctl_netrom_obsolescence_count_initialiser,
                .maxlen         = sizeof(int),
                .mode           = 0644,
-               .proc_handler   = &proc_dointvec_minmax,
+               .proc_handler   = &proc_dointvec_minmax,
                .strategy       = &sysctl_intvec,
                .extra1         = &min_obs,
                .extra2         = &max_obs
        },
-        {
+       {
                .ctl_name       = NET_NETROM_NETWORK_TTL_INITIALISER,
                .procname       = "network_ttl_initialiser",
                .data           = &sysctl_netrom_network_ttl_initialiser,
@@ -68,7 +68,7 @@ static ctl_table nr_table[] = {
                .extra1         = &min_ttl,
                .extra2         = &max_ttl
        },
-        {
+       {
                .ctl_name       = NET_NETROM_TRANSPORT_TIMEOUT,
                .procname       = "transport_timeout",
                .data           = &sysctl_netrom_transport_timeout,
@@ -79,7 +79,7 @@ static ctl_table nr_table[] = {
                .extra1         = &min_t1,
                .extra2         = &max_t1
        },
-        {
+       {
                .ctl_name       = NET_NETROM_TRANSPORT_MAXIMUM_TRIES,
                .procname       = "transport_maximum_tries",
                .data           = &sysctl_netrom_transport_maximum_tries,
@@ -90,7 +90,7 @@ static ctl_table nr_table[] = {
                .extra1         = &min_n2,
                .extra2         = &max_n2
        },
-        {
+       {
                .ctl_name       = NET_NETROM_TRANSPORT_ACKNOWLEDGE_DELAY,
                .procname       = "transport_acknowledge_delay",
                .data           = &sysctl_netrom_transport_acknowledge_delay,
@@ -101,7 +101,7 @@ static ctl_table nr_table[] = {
                .extra1         = &min_t2,
                .extra2         = &max_t2
        },
-        {
+       {
                .ctl_name       = NET_NETROM_TRANSPORT_BUSY_DELAY,
                .procname       = "transport_busy_delay",
                .data           = &sysctl_netrom_transport_busy_delay,
@@ -112,7 +112,7 @@ static ctl_table nr_table[] = {
                .extra1         = &min_t4,
                .extra2         = &max_t4
        },
-        {
+       {
                .ctl_name       = NET_NETROM_TRANSPORT_REQUESTED_WINDOW_SIZE,
                .procname       = "transport_requested_window_size",
                .data           = &sysctl_netrom_transport_requested_window_size,
@@ -123,7 +123,7 @@ static ctl_table nr_table[] = {
                .extra1         = &min_window,
                .extra2         = &max_window
        },
-        {
+       {
                .ctl_name       = NET_NETROM_TRANSPORT_NO_ACTIVITY_TIMEOUT,
                .procname       = "transport_no_activity_timeout",
                .data           = &sysctl_netrom_transport_no_activity_timeout,
@@ -134,7 +134,7 @@ static ctl_table nr_table[] = {
                .extra1         = &min_idle,
                .extra2         = &max_idle
        },
-        {
+       {
                .ctl_name       = NET_NETROM_ROUTING_CONTROL,
                .procname       = "routing_control",
                .data           = &sysctl_netrom_routing_control,
@@ -145,7 +145,7 @@ static ctl_table nr_table[] = {
                .extra1         = &min_route,
                .extra2         = &max_route
        },
-        {
+       {
                .ctl_name       = NET_NETROM_LINK_FAILS_COUNT,
                .procname       = "link_fails_count",
                .data           = &sysctl_netrom_link_fails_count,
@@ -156,7 +156,7 @@ static ctl_table nr_table[] = {
                .extra1         = &min_fails,
                .extra2         = &max_fails
        },
-        {
+       {
                .ctl_name       = NET_NETROM_RESET,
                .procname       = "reset",
                .data           = &sysctl_netrom_reset_circuit,
index 6dc01bdeb76bad39984322efa4d4467e3d86f6db..444550917bc1f6f89a297cf20868f4b31de4933c 100644 (file)
@@ -11,7 +11,7 @@
  *             Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
  *             Alan Cox, <gw4pts@gw4pts.ampr.org>
  *
- * Fixes:      
+ * Fixes:
  *             Alan Cox        :       verify_area() now used correctly
  *             Alan Cox        :       new skbuff lists, look ma no backlogs!
  *             Alan Cox        :       tidied skbuff lists.
  *     Alexey Kuznetsov        :       Untied from IPv4 stack.
  *     Cyrus Durgin            :       Fixed kerneld for kmod.
  *     Michal Ostrowski        :       Module initialization cleanup.
- *         Ulises Alonso        :       Frame number limit removal and 
+ *         Ulises Alonso        :       Frame number limit removal and
  *                                      packet_set_ring memory leak.
  *             Eric Biederman  :       Allow for > 8 byte hardware addresses.
  *                                     The convention is that longer addresses
  *                                     will simply extend the hardware address
- *                                     byte arrays at the end of sockaddr_ll 
+ *                                     byte arrays at the end of sockaddr_ll
  *                                     and packet_mreq.
  *
  *             This program is free software; you can redistribute it and/or
@@ -48,7 +48,7 @@
  *             2 of the License, or (at your option) any later version.
  *
  */
+
 #include <linux/types.h>
 #include <linux/sched.h>
 #include <linux/mm.h>
@@ -60,6 +60,7 @@
 #include <linux/netdevice.h>
 #include <linux/if_packet.h>
 #include <linux/wireless.h>
+#include <linux/kernel.h>
 #include <linux/kmod.h>
 #include <net/ip.h>
 #include <net/protocol.h>
@@ -123,7 +124,7 @@ Outgoing, dev->hard_header!=NULL
 
 Incoming, dev->hard_header==NULL
    mac.raw -> UNKNOWN position. It is very likely, that it points to ll header.
-              PPP makes it, that is wrong, because introduce assymetry
+             PPP makes it, that is wrong, because introduce assymetry
              between rx and tx paths.
    data    -> data
 
@@ -200,7 +201,8 @@ struct packet_sock {
 #endif
        struct packet_type      prot_hook;
        spinlock_t              bind_lock;
-       char                    running;        /* prot_hook is attached*/
+       unsigned int            running:1,      /* prot_hook is attached*/
+                               auxdata:1;
        int                     ifindex;        /* bound device         */
        __be16                  num;
 #ifdef CONFIG_PACKET_MULTICAST
@@ -214,6 +216,16 @@ struct packet_sock {
 #endif
 };
 
+struct packet_skb_cb {
+       unsigned int origlen;
+       union {
+               struct sockaddr_pkt pkt;
+               struct sockaddr_ll ll;
+       } sa;
+};
+
+#define PACKET_SKB_CB(__skb)   ((struct packet_skb_cb *)((__skb)->cb))
+
 #ifdef CONFIG_PACKET_MMAP
 
 static inline char *packet_lookup_frame(struct packet_sock *po, unsigned int position)
@@ -225,7 +237,7 @@ static inline char *packet_lookup_frame(struct packet_sock *po, unsigned int pos
        frame_offset = position % po->frames_per_block;
 
        frame = po->pg_vec[pg_vec_pos] + (frame_offset * po->frame_size);
-       
+
        return frame;
 }
 #endif
@@ -268,7 +280,7 @@ static int packet_rcv_spkt(struct sk_buff *skb, struct net_device *dev,  struct
         */
 
        sk = pt->af_packet_priv;
-       
+
        /*
         *      Yank back the headers [hope the device set this
         *      right or kerboom...]
@@ -293,7 +305,7 @@ static int packet_rcv_spkt(struct sk_buff *skb, struct net_device *dev,  struct
        /* drop conntrack reference */
        nf_reset(skb);
 
-       spkt = (struct sockaddr_pkt*)skb->cb;
+       spkt = &PACKET_SKB_CB(skb)->sa.pkt;
 
        skb_push(skb, skb->data-skb->mac.raw);
 
@@ -324,7 +336,7 @@ oom:
  *     Output a raw packet to a device layer. This bypasses all the other
  *     protocol layers and you must therefore supply it with a complete frame
  */
+
 static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock,
                               struct msghdr *msg, size_t len)
 {
@@ -334,9 +346,9 @@ static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock,
        struct net_device *dev;
        __be16 proto=0;
        int err;
-       
+
        /*
-        *      Get and verify the address. 
+        *      Get and verify the address.
         */
 
        if (saddr)
@@ -350,7 +362,7 @@ static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock,
                return(-ENOTCONN);      /* SOCK_PACKET must be sent giving an address */
 
        /*
-        *      Find the device first to size check it 
+        *      Find the device first to size check it
         */
 
        saddr->spkt_device[13] = 0;
@@ -358,7 +370,7 @@ static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock,
        err = -ENODEV;
        if (dev == NULL)
                goto out_unlock;
-       
+
        err = -ENETDOWN;
        if (!(dev->flags & IFF_UP))
                goto out_unlock;
@@ -367,7 +379,7 @@ static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock,
         *      You may not queue a frame bigger than the mtu. This is the lowest level
         *      raw protocol and you must do your own fragmentation at this level.
         */
-        
+
        err = -EMSGSIZE;
        if (len > dev->mtu + dev->hard_header_len)
                goto out_unlock;
@@ -380,14 +392,14 @@ static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock,
         *      deal with the problem - do your own algorithmic backoffs. That's far
         *      more flexible.
         */
-        
-       if (skb == NULL) 
+
+       if (skb == NULL)
                goto out_unlock;
 
        /*
-        *      Fill it in 
+        *      Fill it in
         */
-        
+
        /* FIXME: Save some space for broken drivers that write a
         * hard header at transmission time by themselves. PPP is the
         * notable one here. This should really be fixed at the driver level.
@@ -512,7 +524,10 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev, struct packet
                skb = nskb;
        }
 
-       sll = (struct sockaddr_ll*)skb->cb;
+       BUILD_BUG_ON(sizeof(*PACKET_SKB_CB(skb)) + MAX_ADDR_LEN - 8 >
+                    sizeof(skb->cb));
+
+       sll = &PACKET_SKB_CB(skb)->sa.ll;
        sll->sll_family = AF_PACKET;
        sll->sll_hatype = dev->type;
        sll->sll_protocol = skb->protocol;
@@ -523,6 +538,8 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev, struct packet
        if (dev->hard_header_parse)
                sll->sll_halen = dev->hard_header_parse(skb, sll->sll_addr);
 
+       PACKET_SKB_CB(skb)->origlen = skb->len;
+
        if (pskb_trim(skb, snaplen))
                goto drop_n_acct;
 
@@ -582,11 +599,12 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, struct packe
                else if (skb->pkt_type == PACKET_OUTGOING) {
                        /* Special case: outgoing packets have ll header at head */
                        skb_pull(skb, skb->nh.raw - skb->data);
-                       if (skb->ip_summed == CHECKSUM_PARTIAL)
-                               status |= TP_STATUS_CSUMNOTREADY;
                }
        }
 
+       if (skb->ip_summed == CHECKSUM_PARTIAL)
+               status |= TP_STATUS_CSUMNOTREADY;
+
        snaplen = skb->len;
 
        res = run_filter(skb, sk, snaplen);
@@ -623,7 +641,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, struct packe
 
        spin_lock(&sk->sk_receive_queue.lock);
        h = (struct tpacket_hdr *)packet_lookup_frame(po, po->head);
-       
+
        if (h->tp_status)
                goto ring_is_full;
        po->head = po->head != po->frame_max ? po->head+1 : 0;
@@ -642,7 +660,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, struct packe
        h->tp_snaplen = snaplen;
        h->tp_mac = macoff;
        h->tp_net = netoff;
-       if (skb->tstamp.off_sec == 0) { 
+       if (skb->tstamp.off_sec == 0) {
                __net_timestamp(skb);
                sock_enable_timestamp(sk);
        }
@@ -682,7 +700,7 @@ drop_n_restore:
                skb->len = skb_len;
        }
 drop:
-        kfree_skb(skb);
+       kfree_skb(skb);
        return 0;
 
 ring_is_full:
@@ -710,9 +728,9 @@ static int packet_sendmsg(struct kiocb *iocb, struct socket *sock,
        int ifindex, err, reserve = 0;
 
        /*
-        *      Get and verify the address. 
+        *      Get and verify the address.
         */
-        
+
        if (saddr == NULL) {
                struct packet_sock *po = pkt_sk(sk);
 
@@ -921,11 +939,11 @@ static int packet_bind_spkt(struct socket *sock, struct sockaddr *uaddr, int add
        char name[15];
        struct net_device *dev;
        int err = -ENODEV;
-       
+
        /*
         *      Check legality
         */
-        
+
        if (addr_len != sizeof(struct sockaddr))
                return -EINVAL;
        strlcpy(name,uaddr->sa_data,sizeof(name));
@@ -950,7 +968,7 @@ static int packet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len
        /*
         *      Check legality
         */
-        
+
        if (addr_len < sizeof(struct sockaddr_ll))
                return -EINVAL;
        if (sll->sll_family != AF_PACKET)
@@ -977,7 +995,7 @@ static struct proto packet_proto = {
 };
 
 /*
- *     Create a packet of type SOCK_PACKET. 
+ *     Create a packet of type SOCK_PACKET.
  */
 
 static int packet_create(struct socket *sock, int protocol)
@@ -1079,7 +1097,7 @@ static int packet_recvmsg(struct kiocb *iocb, struct socket *sock,
        skb=skb_recv_datagram(sk,flags,flags&MSG_DONTWAIT,&err);
 
        /*
-        *      An error occurred so return it. Because skb_recv_datagram() 
+        *      An error occurred so return it. Because skb_recv_datagram()
         *      handles the blocking we don't see and worry about blocking
         *      retries.
         */
@@ -1092,7 +1110,7 @@ static int packet_recvmsg(struct kiocb *iocb, struct socket *sock,
         *      it in now.
         */
 
-       sll = (struct sockaddr_ll*)skb->cb;
+       sll = &PACKET_SKB_CB(skb)->sa.ll;
        if (sock->type == SOCK_PACKET)
                msg->msg_namelen = sizeof(struct sockaddr_pkt);
        else
@@ -1117,7 +1135,22 @@ static int packet_recvmsg(struct kiocb *iocb, struct socket *sock,
        sock_recv_timestamp(msg, sk, skb);
 
        if (msg->msg_name)
-               memcpy(msg->msg_name, skb->cb, msg->msg_namelen);
+               memcpy(msg->msg_name, &PACKET_SKB_CB(skb)->sa,
+                      msg->msg_namelen);
+
+       if (pkt_sk(sk)->auxdata) {
+               struct tpacket_auxdata aux;
+
+               aux.tp_status = TP_STATUS_USER;
+               if (skb->ip_summed == CHECKSUM_PARTIAL)
+                       aux.tp_status |= TP_STATUS_CSUMNOTREADY;
+               aux.tp_len = PACKET_SKB_CB(skb)->origlen;
+               aux.tp_snaplen = skb->len;
+               aux.tp_mac = 0;
+               aux.tp_net = skb->nh.raw - skb->data;
+
+               put_cmsg(msg, SOL_PACKET, PACKET_AUXDATA, sizeof(aux), &aux);
+       }
 
        /*
         *      Free or return the buffer as appropriate. Again this
@@ -1317,6 +1350,7 @@ static int
 packet_setsockopt(struct socket *sock, int level, int optname, char __user *optval, int optlen)
 {
        struct sock *sk = sock->sk;
+       struct packet_sock *po = pkt_sk(sk);
        int ret;
 
        if (level != SOL_PACKET)
@@ -1324,7 +1358,7 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv
 
        switch(optname) {
 #ifdef CONFIG_PACKET_MULTICAST
-       case PACKET_ADD_MEMBERSHIP:     
+       case PACKET_ADD_MEMBERSHIP:
        case PACKET_DROP_MEMBERSHIP:
        {
                struct packet_mreq_max mreq;
@@ -1369,6 +1403,18 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv
                return 0;
        }
 #endif
+       case PACKET_AUXDATA:
+       {
+               int val;
+
+               if (optlen < sizeof(val))
+                       return -EINVAL;
+               if (copy_from_user(&val, optval, sizeof(val)))
+                       return -EFAULT;
+
+               po->auxdata = !!val;
+               return 0;
+       }
        default:
                return -ENOPROTOOPT;
        }
@@ -1378,8 +1424,11 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
                             char __user *optval, int __user *optlen)
 {
        int len;
+       int val;
        struct sock *sk = sock->sk;
        struct packet_sock *po = pkt_sk(sk);
+       void *data;
+       struct tpacket_stats st;
 
        if (level != SOL_PACKET)
                return -ENOPROTOOPT;
@@ -1389,12 +1438,9 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
 
        if (len < 0)
                return -EINVAL;
-               
+
        switch(optname) {
        case PACKET_STATISTICS:
-       {
-               struct tpacket_stats st;
-
                if (len > sizeof(struct tpacket_stats))
                        len = sizeof(struct tpacket_stats);
                spin_lock_bh(&sk->sk_receive_queue.lock);
@@ -1403,16 +1449,23 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
                spin_unlock_bh(&sk->sk_receive_queue.lock);
                st.tp_packets += st.tp_drops;
 
-               if (copy_to_user(optval, &st, len))
-                       return -EFAULT;
+               data = &st;
+               break;
+       case PACKET_AUXDATA:
+               if (len > sizeof(int))
+                       len = sizeof(int);
+               val = po->auxdata;
+
+               data = &val;
                break;
-       }
        default:
                return -ENOPROTOOPT;
        }
 
        if (put_user(len, optlen))
                return -EFAULT;
+       if (copy_to_user(optval, data, len))
+               return -EFAULT;
        return 0;
 }
 
@@ -1494,7 +1547,7 @@ static int packet_ioctl(struct socket *sock, unsigned int cmd,
                }
                case SIOCGSTAMP:
                        return sock_get_timestamp(sk, (struct timeval __user *)arg);
-                       
+
 #ifdef CONFIG_INET
                case SIOCADDRT:
                case SIOCDELRT:
@@ -1555,7 +1608,7 @@ static void packet_mm_open(struct vm_area_struct *vma)
        struct file *file = vma->vm_file;
        struct socket * sock = file->private_data;
        struct sock *sk = sock->sk;
-       
+
        if (sk)
                atomic_inc(&pkt_sk(sk)->mapped);
 }
@@ -1565,7 +1618,7 @@ static void packet_mm_close(struct vm_area_struct *vma)
        struct file *file = vma->vm_file;
        struct socket * sock = file->private_data;
        struct sock *sk = sock->sk;
-       
+
        if (sk)
                atomic_dec(&pkt_sk(sk)->mapped);
 }
@@ -1629,7 +1682,7 @@ static int packet_set_ring(struct sock *sk, struct tpacket_req *req, int closing
        int was_running, order = 0;
        __be16 num;
        int err = 0;
-       
+
        if (req->tp_block_nr) {
                int i, l;
 
@@ -1691,7 +1744,7 @@ static int packet_set_ring(struct sock *sk, struct tpacket_req *req, int closing
                __sock_put(sk);
        }
        spin_unlock(&po->bind_lock);
-               
+
        synchronize_net();
 
        err = -EBUSY;
@@ -1808,7 +1861,7 @@ static const struct proto_ops packet_ops = {
        .connect =      sock_no_connect,
        .socketpair =   sock_no_socketpair,
        .accept =       sock_no_accept,
-       .getname =      packet_getname, 
+       .getname =      packet_getname,
        .poll =         packet_poll,
        .ioctl =        packet_ioctl,
        .listen =       sock_no_listen,
@@ -1853,17 +1906,17 @@ static void *packet_seq_start(struct seq_file *seq, loff_t *pos)
 static void *packet_seq_next(struct seq_file *seq, void *v, loff_t *pos)
 {
        ++*pos;
-       return  (v == SEQ_START_TOKEN) 
-               ? sk_head(&packet_sklist) 
+       return  (v == SEQ_START_TOKEN)
+               ? sk_head(&packet_sklist)
                : sk_next((struct sock*)v) ;
 }
 
 static void packet_seq_stop(struct seq_file *seq, void *v)
 {
-       read_unlock(&packet_sklist_lock);               
+       read_unlock(&packet_sklist_lock);
 }
 
-static int packet_seq_show(struct seq_file *seq, void *v) 
+static int packet_seq_show(struct seq_file *seq, void *v)
 {
        if (v == SEQ_START_TOKEN)
                seq_puts(seq, "sk       RefCnt Type Proto  Iface R Rmem   User   Inode\n");
index 9e279464c9d1ed59e7b558e2fa1e0e8e6a37737a..7a81a8ee8544731a4600d00d8eb91852c06aa6fd 100644 (file)
@@ -1351,7 +1351,7 @@ static void *rose_info_start(struct seq_file *seq, loff_t *pos)
        spin_lock_bh(&rose_list_lock);
        if (*pos == 0)
                return SEQ_START_TOKEN;
-       
+
        i = 1;
        sk_for_each(s, node, &rose_list) {
                if (i == *pos)
@@ -1365,10 +1365,10 @@ static void *rose_info_next(struct seq_file *seq, void *v, loff_t *pos)
 {
        ++*pos;
 
-       return (v == SEQ_START_TOKEN) ? sk_head(&rose_list) 
+       return (v == SEQ_START_TOKEN) ? sk_head(&rose_list)
                : sk_next((struct sock *)v);
 }
-       
+
 static void rose_info_stop(struct seq_file *seq, void *v)
 {
        spin_unlock_bh(&rose_list_lock);
@@ -1379,7 +1379,7 @@ static int rose_info_show(struct seq_file *seq, void *v)
        char buf[11];
 
        if (v == SEQ_START_TOKEN)
-               seq_puts(seq, 
+               seq_puts(seq,
                         "dest_addr  dest_call src_addr   src_call  dev   lci neigh st vs vr va   t  t1  t2  t3  hb    idle Snd-Q Rcv-Q inode\n");
 
        else {
@@ -1392,7 +1392,7 @@ static int rose_info_show(struct seq_file *seq, void *v)
                        devname = "???";
                else
                        devname = dev->name;
-               
+
                seq_printf(seq, "%-10s %-9s ",
                        rose2asc(&rose->dest_addr),
                        ax2asc(buf, &rose->dest_call));
@@ -1520,7 +1520,7 @@ static int __init rose_proto_init(void)
                char name[IFNAMSIZ];
 
                sprintf(name, "rose%d", i);
-               dev = alloc_netdev(sizeof(struct net_device_stats), 
+               dev = alloc_netdev(sizeof(struct net_device_stats),
                                   name, rose_setup);
                if (!dev) {
                        printk(KERN_ERR "ROSE: rose_proto_init - unable to allocate memory\n");
index 8028c0d425dc51992ef55e7dc95d66e3397cf700..0dcca4289eeb9eed07b7fb6d39d76f72a67ff5b5 100644 (file)
@@ -66,7 +66,7 @@ static int __must_check rose_add_node(struct rose_route_struct *rose_route,
        while (rose_node != NULL) {
                if ((rose_node->mask == rose_route->mask) &&
                    (rosecmpm(&rose_route->address, &rose_node->address,
-                             rose_route->mask) == 0))
+                             rose_route->mask) == 0))
                        break;
                rose_node = rose_node->next;
        }
@@ -300,7 +300,7 @@ static int rose_del_node(struct rose_route_struct *rose_route,
        while (rose_node != NULL) {
                if ((rose_node->mask == rose_route->mask) &&
                    (rosecmpm(&rose_route->address, &rose_node->address,
-                             rose_route->mask) == 0))
+                             rose_route->mask) == 0))
                        break;
                rose_node = rose_node->next;
        }
@@ -1070,7 +1070,7 @@ static void *rose_node_start(struct seq_file *seq, loff_t *pos)
        if (*pos == 0)
                return SEQ_START_TOKEN;
 
-       for (rose_node = rose_node_list; rose_node && i < *pos; 
+       for (rose_node = rose_node_list; rose_node && i < *pos;
             rose_node = rose_node->next, ++i);
 
        return (i == *pos) ? rose_node : NULL;
@@ -1079,8 +1079,8 @@ static void *rose_node_start(struct seq_file *seq, loff_t *pos)
 static void *rose_node_next(struct seq_file *seq, void *v, loff_t *pos)
 {
        ++*pos;
-       
-       return (v == SEQ_START_TOKEN) ? rose_node_list 
+
+       return (v == SEQ_START_TOKEN) ? rose_node_list
                : ((struct rose_node *)v)->next;
 }
 
@@ -1146,7 +1146,7 @@ static void *rose_neigh_start(struct seq_file *seq, loff_t *pos)
        if (*pos == 0)
                return SEQ_START_TOKEN;
 
-       for (rose_neigh = rose_neigh_list; rose_neigh && i < *pos; 
+       for (rose_neigh = rose_neigh_list; rose_neigh && i < *pos;
             rose_neigh = rose_neigh->next, ++i);
 
        return (i == *pos) ? rose_neigh : NULL;
@@ -1155,8 +1155,8 @@ static void *rose_neigh_start(struct seq_file *seq, loff_t *pos)
 static void *rose_neigh_next(struct seq_file *seq, void *v, loff_t *pos)
 {
        ++*pos;
-       
-       return (v == SEQ_START_TOKEN) ? rose_neigh_list 
+
+       return (v == SEQ_START_TOKEN) ? rose_neigh_list
                : ((struct rose_neigh *)v)->next;
 }
 
@@ -1171,7 +1171,7 @@ static int rose_neigh_show(struct seq_file *seq, void *v)
        int i;
 
        if (v == SEQ_START_TOKEN)
-               seq_puts(seq, 
+               seq_puts(seq,
                         "addr  callsign  dev  count use mode restart  t0  tf digipeaters\n");
        else {
                struct rose_neigh *rose_neigh = v;
@@ -1229,7 +1229,7 @@ static void *rose_route_start(struct seq_file *seq, loff_t *pos)
        if (*pos == 0)
                return SEQ_START_TOKEN;
 
-       for (rose_route = rose_route_list; rose_route && i < *pos; 
+       for (rose_route = rose_route_list; rose_route && i < *pos;
             rose_route = rose_route->next, ++i);
 
        return (i == *pos) ? rose_route : NULL;
@@ -1238,8 +1238,8 @@ static void *rose_route_start(struct seq_file *seq, loff_t *pos)
 static void *rose_route_next(struct seq_file *seq, void *v, loff_t *pos)
 {
        ++*pos;
-       
-       return (v == SEQ_START_TOKEN) ? rose_route_list 
+
+       return (v == SEQ_START_TOKEN) ? rose_route_list
                : ((struct rose_route *)v)->next;
 }
 
@@ -1253,30 +1253,30 @@ static int rose_route_show(struct seq_file *seq, void *v)
        char buf[11];
 
        if (v == SEQ_START_TOKEN)
-               seq_puts(seq, 
+               seq_puts(seq,
                         "lci  address     callsign   neigh  <-> lci  address     callsign   neigh\n");
        else {
                struct rose_route *rose_route = v;
 
-               if (rose_route->neigh1) 
+               if (rose_route->neigh1)
                        seq_printf(seq,
                                   "%3.3X  %-10s  %-9s  %05d      ",
                                   rose_route->lci1,
                                   rose2asc(&rose_route->src_addr),
                                   ax2asc(buf, &rose_route->src_call),
                                   rose_route->neigh1->number);
-               else 
-                       seq_puts(seq, 
+               else
+                       seq_puts(seq,
                                 "000  *           *          00000      ");
 
-               if (rose_route->neigh2) 
+               if (rose_route->neigh2)
                        seq_printf(seq,
                                   "%3.3X  %-10s  %-9s  %05d\n",
                                rose_route->lci2,
                                rose2asc(&rose_route->dest_addr),
                                ax2asc(buf, &rose_route->dest_call),
                                rose_route->neigh2->number);
-                else 
+                else
                         seq_puts(seq,
                                  "000  *           *          00000\n");
                }
index 8548c7cf564367d7f93ba59cc59524dda5b82821..27a452bc5b8d7511d1d2b4834097ff0d9da288a8 100644 (file)
@@ -25,7 +25,7 @@ static int min_window[] = {1}, max_window[] = {7};
 static struct ctl_table_header *rose_table_header;
 
 static ctl_table rose_table[] = {
-        {
+       {
                .ctl_name       = NET_ROSE_RESTART_REQUEST_TIMEOUT,
                .procname       = "restart_request_timeout",
                .data           = &sysctl_rose_restart_request_timeout,
@@ -36,7 +36,7 @@ static ctl_table rose_table[] = {
                .extra1         = &min_timer,
                .extra2         = &max_timer
        },
-        {
+       {
                .ctl_name       = NET_ROSE_CALL_REQUEST_TIMEOUT,
                .procname       = "call_request_timeout",
                .data           = &sysctl_rose_call_request_timeout,
@@ -47,7 +47,7 @@ static ctl_table rose_table[] = {
                .extra1         = &min_timer,
                .extra2         = &max_timer
        },
-        {
+       {
                .ctl_name       = NET_ROSE_RESET_REQUEST_TIMEOUT,
                .procname       = "reset_request_timeout",
                .data           = &sysctl_rose_reset_request_timeout,
@@ -58,7 +58,7 @@ static ctl_table rose_table[] = {
                .extra1         = &min_timer,
                .extra2         = &max_timer
        },
-        {
+       {
                .ctl_name       = NET_ROSE_CLEAR_REQUEST_TIMEOUT,
                .procname       = "clear_request_timeout",
                .data           = &sysctl_rose_clear_request_timeout,
@@ -69,7 +69,7 @@ static ctl_table rose_table[] = {
                .extra1         = &min_timer,
                .extra2         = &max_timer
        },
-        {
+       {
                .ctl_name       = NET_ROSE_NO_ACTIVITY_TIMEOUT,
                .procname       = "no_activity_timeout",
                .data           = &sysctl_rose_no_activity_timeout,
@@ -80,7 +80,7 @@ static ctl_table rose_table[] = {
                .extra1         = &min_idle,
                .extra2         = &max_idle
        },
-        {
+       {
                .ctl_name       = NET_ROSE_ACK_HOLD_BACK_TIMEOUT,
                .procname       = "acknowledge_hold_back_timeout",
                .data           = &sysctl_rose_ack_hold_back_timeout,
@@ -91,7 +91,7 @@ static ctl_table rose_table[] = {
                .extra1         = &min_timer,
                .extra2         = &max_timer
        },
-        {
+       {
                .ctl_name       = NET_ROSE_ROUTING_CONTROL,
                .procname       = "routing_control",
                .data           = &sysctl_rose_routing_control,
@@ -102,7 +102,7 @@ static ctl_table rose_table[] = {
                .extra1         = &min_route,
                .extra2         = &max_route
        },
-        {
+       {
                .ctl_name       = NET_ROSE_LINK_FAIL_TIMEOUT,
                .procname       = "link_fail_timeout",
                .data           = &sysctl_rose_link_fail_timeout,
@@ -113,7 +113,7 @@ static ctl_table rose_table[] = {
                .extra1         = &min_ftimer,
                .extra2         = &max_ftimer
        },
-        {
+       {
                .ctl_name       = NET_ROSE_MAX_VCS,
                .procname       = "maximum_virtual_circuits",
                .data           = &sysctl_rose_maximum_vcs,
@@ -124,7 +124,7 @@ static ctl_table rose_table[] = {
                .extra1         = &min_maxvcs,
                .extra2         = &max_maxvcs
        },
-        {
+       {
                .ctl_name       = NET_ROSE_WINDOW_SIZE,
                .procname       = "window_size",
                .data           = &sysctl_rose_window_size,
index 93d2c55ad2d5decf115080ba0e5733caa037cd49..a7c929a9fdca89070c1fa70d4dc9a0b4a4275664 100644 (file)
@@ -163,7 +163,7 @@ int rxrpc_create_connection(struct rxrpc_transport *trans,
                conn = list_entry(_p, struct rxrpc_connection, link);
                if (conn->addr.sin_port == candidate->addr.sin_port     &&
                    conn->security_ix   == candidate->security_ix       &&
-                   conn->service_id    == candidate->service_id        && 
+                   conn->service_id    == candidate->service_id        &&
                    conn->in_clientflag == 0)
                        goto found_in_graveyard;
        }
@@ -247,13 +247,13 @@ int rxrpc_connection_lookup(struct rxrpc_peer *peer,
                    conn->in_epoch              == x_epoch      &&
                    conn->conn_id               == x_connid     &&
                    conn->security_ix           == x_secix      &&
-                   conn->service_id            == x_servid     && 
+                   conn->service_id            == x_servid     &&
                    conn->in_clientflag         == x_clflag)
                        goto found_active;
        }
        read_unlock(&peer->conn_lock);
 
-       /* [uncommon case] not active 
+       /* [uncommon case] not active
         * - create a candidate for a new record if an inbound connection
         * - only examine the graveyard for an outbound connection
         */
@@ -286,7 +286,7 @@ int rxrpc_connection_lookup(struct rxrpc_peer *peer,
                    conn->in_epoch              == x_epoch      &&
                    conn->conn_id               == x_connid     &&
                    conn->security_ix           == x_secix      &&
-                   conn->service_id            == x_servid     && 
+                   conn->service_id            == x_servid     &&
                    conn->in_clientflag         == x_clflag)
                        goto found_active_second_chance;
        }
@@ -299,7 +299,7 @@ int rxrpc_connection_lookup(struct rxrpc_peer *peer,
                    conn->in_epoch              == x_epoch      &&
                    conn->conn_id               == x_connid     &&
                    conn->security_ix           == x_secix      &&
-                   conn->service_id            == x_servid     && 
+                   conn->service_id            == x_servid     &&
                    conn->in_clientflag         == x_clflag)
                        goto found_in_graveyard;
        }
index 70e52f6b0b649444db7c60503cf2df170c03c1c7..cc0c5795a103c458554bca62d51596a137f6ebb4 100644 (file)
@@ -14,7 +14,7 @@
  */
 #if 1
 #define __RXACCT_DECL(X) X
-#define __RXACCT(X) do { X; } while(0) 
+#define __RXACCT(X) do { X; } while(0)
 #else
 #define __RXACCT_DECL(X)
 #define __RXACCT(X) do { } while(0)
index 49effd92144e2908ea95ce6ecdff1fb4be7a6940..bbbcd6c2404870cefc6c0bddc7ad18fe7a305d18 100644 (file)
@@ -141,7 +141,7 @@ static int rxrpc_krxiod(void *arg)
 
                try_to_freeze();
 
-                /* discard pending signals */
+               /* discard pending signals */
                rxrpc_discard_my_signals();
 
        } while (!rxrpc_krxiod_die);
index 3ab0f77409f49c79de6c65dc361962bf14be1c94..9a1e7f5e034c973039bb7113eaf2fa84638f3815 100644 (file)
@@ -110,7 +110,7 @@ static int rxrpc_krxsecd(void *arg)
 
                try_to_freeze();
 
-                /* discard pending signals */
+               /* discard pending signals */
                rxrpc_discard_my_signals();
 
        } while (!die);
index 48cbd065bb45ab8ba5d676f802ebbcdf2ecc0d28..baec1f7fd8b9969c8491adddeb73b173fde53ac1 100644 (file)
@@ -146,17 +146,17 @@ __attribute__((no_instrument_function));
 void __cyg_profile_func_enter (void *this_fn, void *call_site)
 {
        asm volatile("  movl    %%esp,%%edi     \n"
-                    "  andl    %0,%%edi        \n"
-                    "  addl    %1,%%edi        \n"
-                    "  movl    %%esp,%%ecx     \n"
-                    "  subl    %%edi,%%ecx     \n"
-                    "  shrl    $2,%%ecx        \n"
-                    "  movl    $0xedededed,%%eax     \n"
-                    "  rep stosl               \n"
-                    :
-                    : "i"(~(THREAD_SIZE-1)), "i"(sizeof(struct thread_info))
-                    : "eax", "ecx", "edi", "memory", "cc"
-                    );
+                   "  andl    %0,%%edi        \n"
+                   "  addl    %1,%%edi        \n"
+                   "  movl    %%esp,%%ecx     \n"
+                   "  subl    %%edi,%%ecx     \n"
+                   "  shrl    $2,%%ecx        \n"
+                   "  movl    $0xedededed,%%eax     \n"
+                   "  rep stosl               \n"
+                   :
+                   : "i"(~(THREAD_SIZE-1)), "i"(sizeof(struct thread_info))
+                   : "eax", "ecx", "edi", "memory", "cc"
+                   );
 }
 
 void __cyg_profile_func_exit(void *this_fn, void *call_site)
@@ -165,16 +165,16 @@ __attribute__((no_instrument_function));
 void __cyg_profile_func_exit(void *this_fn, void *call_site)
 {
        asm volatile("  movl    %%esp,%%edi     \n"
-                    "  andl    %0,%%edi        \n"
-                    "  addl    %1,%%edi        \n"
-                    "  movl    %%esp,%%ecx     \n"
-                    "  subl    %%edi,%%ecx     \n"
-                    "  shrl    $2,%%ecx        \n"
-                    "  movl    $0xdadadada,%%eax     \n"
-                    "  rep stosl               \n"
-                    :
-                    : "i"(~(THREAD_SIZE-1)), "i"(sizeof(struct thread_info))
-                    : "eax", "ecx", "edi", "memory", "cc"
-                    );
+                   "  andl    %0,%%edi        \n"
+                   "  addl    %1,%%edi        \n"
+                   "  movl    %%esp,%%ecx     \n"
+                   "  subl    %%edi,%%ecx     \n"
+                   "  shrl    $2,%%ecx        \n"
+                   "  movl    $0xdadadada,%%eax     \n"
+                   "  rep stosl               \n"
+                   :
+                   : "i"(~(THREAD_SIZE-1)), "i"(sizeof(struct thread_info))
+                   : "eax", "ecx", "edi", "memory", "cc"
+                   );
 }
 #endif
index 6374df7e77d1bfeb3558efd37e769e8e1b60f834..0755ae028e4330073fa58af0b794ffbdbda24e38 100644 (file)
@@ -27,7 +27,7 @@ int rxrpc_knet;
 static struct ctl_table_header *rxrpc_sysctl = NULL;
 
 static ctl_table rxrpc_sysctl_table[] = {
-        {
+       {
                .ctl_name       = 1,
                .procname       = "kdebug",
                .data           = &rxrpc_kdebug,
@@ -35,7 +35,7 @@ static ctl_table rxrpc_sysctl_table[] = {
                .mode           = 0644,
                .proc_handler   = &proc_dointvec
        },
-        {
+       {
                .ctl_name       = 2,
                .procname       = "ktrace",
                .data           = &rxrpc_ktrace,
@@ -43,7 +43,7 @@ static ctl_table rxrpc_sysctl_table[] = {
                .mode           = 0644,
                .proc_handler   = &proc_dointvec
        },
-        {
+       {
                .ctl_name       = 3,
                .procname       = "kproto",
                .data           = &rxrpc_kproto,
@@ -51,7 +51,7 @@ static ctl_table rxrpc_sysctl_table[] = {
                .mode           = 0644,
                .proc_handler   = &proc_dointvec
        },
-        {
+       {
                .ctl_name       = 4,
                .procname       = "knet",
                .data           = &rxrpc_knet,
@@ -59,7 +59,7 @@ static ctl_table rxrpc_sysctl_table[] = {
                .mode           = 0644,
                .proc_handler   = &proc_dointvec
        },
-        {
+       {
                .ctl_name       = 5,
                .procname       = "peertimo",
                .data           = &rxrpc_peer_timeout,
@@ -67,7 +67,7 @@ static ctl_table rxrpc_sysctl_table[] = {
                .mode           = 0644,
                .proc_handler   = &proc_doulongvec_minmax
        },
-        {
+       {
                .ctl_name       = 6,
                .procname       = "conntimo",
                .data           = &rxrpc_conn_timeout,
index 4268b38d92d25e4d66a972e1b498793b6004400b..ff5f4f333086974cbfa17a061c222a8bf54d6386 100644 (file)
@@ -330,10 +330,10 @@ static int rxrpc_incoming_msg(struct rxrpc_transport *trans,
        msg->state = RXRPC_MSG_RECEIVED;
        skb_get_timestamp(pkt, &msg->stamp);
        if (msg->stamp.tv_sec == 0) {
-               do_gettimeofday(&msg->stamp); 
-               if (pkt->sk) 
+               do_gettimeofday(&msg->stamp);
+               if (pkt->sk)
                        sock_enable_timestamp(pkt->sk);
-       } 
+       }
        msg->seq = ntohl(msg->hdr.seq);
 
        /* attach the packet */
index 835070e9169cc03b5975709827f752ff6d6576a0..dd0868dfbd9028d9555ae05189804e4865f81856 100644 (file)
@@ -65,7 +65,7 @@ int tcf_hash_release(struct tcf_common *p, int bind,
                        p->tcfc_bindcnt--;
 
                p->tcfc_refcnt--;
-               if (p->tcfc_bindcnt <= 0 && p->tcfc_refcnt <= 0) {
+               if (p->tcfc_bindcnt <= 0 && p->tcfc_refcnt <= 0) {
                        tcf_hash_destroy(p, hinfo);
                        ret = 1;
                }
@@ -362,7 +362,7 @@ static struct tc_action_ops *tc_lookup_action_id(u32 type)
 #endif
 
 int tcf_action_exec(struct sk_buff *skb, struct tc_action *act,
-                    struct tcf_result *res)
+                   struct tcf_result *res)
 {
        struct tc_action *a;
        int ret = -1;
@@ -473,7 +473,7 @@ errout:
 }
 
 struct tc_action *tcf_action_init_1(struct rtattr *rta, struct rtattr *est,
-                                    char *name, int ovr, int bind, int *err)
+                                   char *name, int ovr, int bind, int *err)
 {
        struct tc_action *a;
        struct tc_action_ops *a_o;
@@ -553,7 +553,7 @@ err_out:
 }
 
 struct tc_action *tcf_action_init(struct rtattr *rta, struct rtattr *est,
-                                  char *name, int ovr, int bind, int *err)
+                                 char *name, int ovr, int bind, int *err)
 {
        struct rtattr *tb[TCA_ACT_MAX_PRIO+1];
        struct tc_action *head = NULL, *act, *act_prev = NULL;
@@ -590,7 +590,7 @@ int tcf_action_copy_stats(struct sk_buff *skb, struct tc_action *a,
        int err = 0;
        struct gnet_dump d;
        struct tcf_act_hdr *h = a->priv;
-       
+
        if (h == NULL)
                goto errout;
 
@@ -632,7 +632,7 @@ errout:
 
 static int
 tca_get_fill(struct sk_buff *skb, struct tc_action *a, u32 pid, u32 seq,
-             u16 flags, int event, int bind, int ref)
+            u16 flags, int event, int bind, int ref)
 {
        struct tcamsg *t;
        struct nlmsghdr *nlh;
@@ -645,7 +645,7 @@ tca_get_fill(struct sk_buff *skb, struct tc_action *a, u32 pid, u32 seq,
        t->tca_family = AF_UNSPEC;
        t->tca__pad1 = 0;
        t->tca__pad2 = 0;
-       
+
        x = (struct rtattr*) skb->tail;
        RTA_PUT(skb, TCA_ACT_TAB, 0, NULL);
 
@@ -653,7 +653,7 @@ tca_get_fill(struct sk_buff *skb, struct tc_action *a, u32 pid, u32 seq,
                goto rtattr_failure;
 
        x->rta_len = skb->tail - (u8*)x;
-       
+
        nlh->nlmsg_len = skb->tail - b;
        return skb->len;
 
@@ -852,7 +852,7 @@ tca_action_gd(struct rtattr *rta, struct nlmsghdr *n, u32 pid, int event)
                }
 
                if (tca_get_fill(skb, head, pid, n->nlmsg_seq, 0, event,
-                                0, 1) <= 0) {
+                                0, 1) <= 0) {
                        kfree_skb(skb);
                        ret = -EINVAL;
                        goto err;
@@ -861,7 +861,7 @@ tca_action_gd(struct rtattr *rta, struct nlmsghdr *n, u32 pid, int event)
                /* now do the delete */
                tcf_action_destroy(head, 0);
                ret = rtnetlink_send(skb, pid, RTNLGRP_TC,
-                                    n->nlmsg_flags&NLM_F_ECHO);
+                                    n->nlmsg_flags&NLM_F_ECHO);
                if (ret > 0)
                        return 0;
                return ret;
@@ -872,7 +872,7 @@ err:
 }
 
 static int tcf_add_notify(struct tc_action *a, u32 pid, u32 seq, int event,
-                          u16 flags)
+                         u16 flags)
 {
        struct tcamsg *t;
        struct nlmsghdr *nlh;
@@ -900,10 +900,10 @@ static int tcf_add_notify(struct tc_action *a, u32 pid, u32 seq, int event,
                goto rtattr_failure;
 
        x->rta_len = skb->tail - (u8*)x;
-       
+
        nlh->nlmsg_len = skb->tail - b;
        NETLINK_CB(skb).dst_group = RTNLGRP_TC;
-       
+
        err = rtnetlink_send(skb, pid, RTNLGRP_TC, flags&NLM_F_ECHO);
        if (err > 0)
                err = 0;
@@ -915,7 +915,7 @@ nlmsg_failure:
        return -1;
 }
 
-       
+
 static int
 tcf_action_add(struct rtattr *rta, struct nlmsghdr *n, u32 pid, int ovr)
 {
@@ -999,13 +999,13 @@ find_dump_kind(struct nlmsghdr *n)
                return NULL;
 
        if (rtattr_parse(tb, TCA_ACT_MAX_PRIO, RTA_DATA(tb1),
-                        NLMSG_ALIGN(RTA_PAYLOAD(tb1))) < 0)
+                        NLMSG_ALIGN(RTA_PAYLOAD(tb1))) < 0)
                return NULL;
        if (tb[0] == NULL)
                return NULL;
 
        if (rtattr_parse(tb2, TCA_ACT_MAX, RTA_DATA(tb[0]),
-                        RTA_PAYLOAD(tb[0])) < 0)
+                        RTA_PAYLOAD(tb[0])) < 0)
                return NULL;
        kind = tb2[TCA_ACT_KIND-1];
 
@@ -1043,7 +1043,7 @@ tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb)
        }
 
        nlh = NLMSG_PUT(skb, NETLINK_CB(cb->skb).pid, cb->nlh->nlmsg_seq,
-                       cb->nlh->nlmsg_type, sizeof(*t));
+                       cb->nlh->nlmsg_type, sizeof(*t));
        t = NLMSG_DATA(nlh);
        t->tca_family = AF_UNSPEC;
        t->tca__pad1 = 0;
index 85de7efd5fea7b29ca7a208633c5740f1a1762e5..60095d86fd8f55bc843aa9ffbd8497ba33a512e6 100644 (file)
@@ -65,7 +65,7 @@ static g_rand gact_rand[MAX_RAND]= { NULL, gact_net_rand, gact_determ };
 #endif /* CONFIG_GACT_PROB */
 
 static int tcf_gact_init(struct rtattr *rta, struct rtattr *est,
-                         struct tc_action *a, int ovr, int bind)
+                        struct tc_action *a, int ovr, int bind)
 {
        struct rtattr *tb[TCA_GACT_MAX];
        struct tc_gact *parm;
index 01e69138578da0cc9db6151493a3312d5573011c..0fdabfa9f4bf3e77e5fc376fb95745e768e28cb0 100644 (file)
@@ -52,7 +52,7 @@ static struct tcf_hashinfo ipt_hash_info = {
 
 static int ipt_init_target(struct ipt_entry_target *t, char *table, unsigned int hook)
 {
-       struct ipt_target *target;
+       struct xt_target *target;
        int ret = 0;
 
        target = xt_request_find_target(AF_INET, t->u.user.name,
@@ -70,7 +70,7 @@ static int ipt_init_target(struct ipt_entry_target *t, char *table, unsigned int
        }
        if (t->u.kernel.target->checkentry
            && !t->u.kernel.target->checkentry(table, NULL,
-                                              t->u.kernel.target, t->data,
+                                              t->u.kernel.target, t->data,
                                               hook)) {
                module_put(t->u.kernel.target->me);
                ret = -EINVAL;
@@ -83,7 +83,7 @@ static void ipt_destroy_target(struct ipt_entry_target *t)
 {
        if (t->u.kernel.target->destroy)
                t->u.kernel.target->destroy(t->u.kernel.target, t->data);
-        module_put(t->u.kernel.target->me);
+       module_put(t->u.kernel.target->me);
 }
 
 static int tcf_ipt_release(struct tcf_ipt *ipt, int bind)
index 8ac65c219b98070885dc0ee2ff294aede855441b..53aa96cd579b8a0575166a77ad9973b1f816d059 100644 (file)
@@ -153,8 +153,8 @@ static int tcf_pedit(struct sk_buff *skb, struct tc_action *a,
                        if (tkey->offmask) {
                                if (skb->len > tkey->at) {
                                         char *j = pptr + tkey->at;
-                                        offset += ((*j & tkey->offmask) >> 
-                                                  tkey->shift);
+                                        offset += ((*j & tkey->offmask) >>
+                                                  tkey->shift);
                                } else {
                                        goto bad;
                                }
@@ -176,7 +176,7 @@ static int tcf_pedit(struct sk_buff *skb, struct tc_action *a,
                        *ptr = ((*ptr & tkey->mask) ^ tkey->val);
                        munged++;
                }
-               
+
                if (munged)
                        skb->tc_verd = SET_TC_MUNGED(skb->tc_verd);
                goto done;
@@ -200,8 +200,8 @@ static int tcf_pedit_dump(struct sk_buff *skb, struct tc_action *a,
        struct tcf_pedit *p = a->priv;
        struct tc_pedit *opt;
        struct tcf_t t;
-       int s; 
-               
+       int s;
+
        s = sizeof(*opt) + p->tcfp_nkeys * sizeof(struct tc_pedit_key);
 
        /* netlink spinlocks held above us - must use ATOMIC */
index af68e1e83251080789bccce4e8b7c950d8115b24..6ffe35da22b127e1e36bda2bdc119c7b08eb13e3 100644 (file)
@@ -62,7 +62,7 @@ struct tc_police_compat
 
 #ifdef CONFIG_NET_CLS_ACT
 static int tcf_act_police_walker(struct sk_buff *skb, struct netlink_callback *cb,
-                              int type, struct tc_action *a)
+                             int type, struct tc_action *a)
 {
        struct tcf_common *p;
        int err = 0, index = -1, i = 0, s_i = 0, n_i = 0;
@@ -112,7 +112,7 @@ void tcf_police_destroy(struct tcf_police *p)
 {
        unsigned int h = tcf_hash(p->tcf_index, POL_TAB_MASK);
        struct tcf_common **p1p;
-       
+
        for (p1p = &tcf_police_ht[h]; *p1p; p1p = &(*p1p)->tcfc_next) {
                if (*p1p == &p->common) {
                        write_lock_bh(&police_lock);
@@ -135,7 +135,7 @@ void tcf_police_destroy(struct tcf_police *p)
 
 #ifdef CONFIG_NET_CLS_ACT
 static int tcf_act_police_locate(struct rtattr *rta, struct rtattr *est,
-                                 struct tc_action *a, int ovr, int bind)
+                                struct tc_action *a, int ovr, int bind)
 {
        unsigned h;
        int ret = 0, err;
@@ -269,7 +269,7 @@ static int tcf_act_police_cleanup(struct tc_action *a, int bind)
 }
 
 static int tcf_act_police(struct sk_buff *skb, struct tc_action *a,
-                          struct tcf_result *res)
+                         struct tcf_result *res)
 {
        struct tcf_police *police = a->priv;
        psched_time_t now;
@@ -606,12 +606,12 @@ rtattr_failure:
 int tcf_police_dump_stats(struct sk_buff *skb, struct tcf_police *police)
 {
        struct gnet_dump d;
-       
+
        if (gnet_stats_start_copy_compat(skb, TCA_STATS2, TCA_STATS,
                                         TCA_XSTATS, police->tcf_stats_lock,
                                         &d) < 0)
                goto errout;
-       
+
        if (gnet_stats_copy_basic(&d, &police->tcf_bstats) < 0 ||
 #ifdef CONFIG_NET_ESTIMATOR
            gnet_stats_copy_rate_est(&d, &police->tcf_rate_est) < 0 ||
index 5fe80854ca91cdf58d766c66ce1c8fccb8d882a2..c7971182af0752d67b267a22e607f58dc0dd1613 100644 (file)
@@ -43,9 +43,9 @@ static int tcf_simp(struct sk_buff *skb, struct tc_action *a, struct tcf_result
        d->tcf_bstats.bytes += skb->len;
        d->tcf_bstats.packets++;
 
-       /* print policy string followed by _ then packet count 
-        * Example if this was the 3rd packet and the string was "hello" 
-        * then it would look like "hello_3" (without quotes) 
+       /* print policy string followed by _ then packet count
+        * Example if this was the 3rd packet and the string was "hello"
+        * then it would look like "hello_3" (without quotes)
         **/
        printk("simple: %s_%d\n",
               (char *)d->tcfd_defdata, d->tcf_bstats.packets);
index edb8fc97ae11a183734f700aa06bbf84d758f78e..f41f4ee0587af545112fe72c27620316d005af2a 100644 (file)
@@ -286,7 +286,7 @@ replay:
                        goto errout;
        } else {
                switch (n->nlmsg_type) {
-               case RTM_NEWTFILTER:    
+               case RTM_NEWTFILTER:
                        err = -EEXIST;
                        if (n->nlmsg_flags&NLM_F_EXCL)
                                goto errout;
@@ -481,11 +481,11 @@ tcf_exts_destroy(struct tcf_proto *tp, struct tcf_exts *exts)
 
 int
 tcf_exts_validate(struct tcf_proto *tp, struct rtattr **tb,
-                 struct rtattr *rate_tlv, struct tcf_exts *exts,
-                 struct tcf_ext_map *map)
+                 struct rtattr *rate_tlv, struct tcf_exts *exts,
+                 struct tcf_ext_map *map)
 {
        memset(exts, 0, sizeof(*exts));
-       
+
 #ifdef CONFIG_NET_CLS_ACT
        {
                int err;
@@ -511,7 +511,7 @@ tcf_exts_validate(struct tcf_proto *tp, struct rtattr **tb,
 #elif defined CONFIG_NET_CLS_POLICE
        if (map->police && tb[map->police-1]) {
                struct tcf_police *p;
-               
+
                p = tcf_police_locate(tb[map->police-1], rate_tlv);
                if (p == NULL)
                        return -EINVAL;
@@ -530,7 +530,7 @@ tcf_exts_validate(struct tcf_proto *tp, struct rtattr **tb,
 
 void
 tcf_exts_change(struct tcf_proto *tp, struct tcf_exts *dst,
-               struct tcf_exts *src)
+               struct tcf_exts *src)
 {
 #ifdef CONFIG_NET_CLS_ACT
        if (src->action) {
@@ -597,7 +597,7 @@ rtattr_failure: __attribute__ ((unused))
 
 int
 tcf_exts_dump_stats(struct sk_buff *skb, struct tcf_exts *exts,
-                   struct tcf_ext_map *map)
+                   struct tcf_ext_map *map)
 {
 #ifdef CONFIG_NET_CLS_ACT
        if (exts->action)
index 09fda68c8b39f494f6b5802a99efc34a39cdc030..ea13c2c5b0618a3fff9a26eeec73d3c84f6159e4 100644 (file)
@@ -98,7 +98,7 @@ static void basic_destroy(struct tcf_proto *tp)
 {
        struct basic_head *head = (struct basic_head *) xchg(&tp->root, NULL);
        struct basic_filter *f, *n;
-       
+
        list_for_each_entry_safe(f, n, &head->flist, link) {
                list_del(&f->link);
                basic_delete_filter(tp, f);
@@ -157,7 +157,7 @@ errout:
 }
 
 static int basic_change(struct tcf_proto *tp, unsigned long base, u32 handle,
-                       struct rtattr **tca, unsigned long *arg)
+                       struct rtattr **tca, unsigned long *arg)
 {
        int err = -EINVAL;
        struct basic_head *head = (struct basic_head *) tp->root;
@@ -292,7 +292,7 @@ static int __init init_basic(void)
        return register_tcf_proto_ops(&cls_basic_ops);
 }
 
-static void __exit exit_basic(void) 
+static void __exit exit_basic(void)
 {
        unregister_tcf_proto_ops(&cls_basic_ops);
 }
index c797d6ada7de06948ef1fab1e225a224ffdc057d..2ce3ce5c66eb097f4738c4a53fa2ddefe6bf91cc 100644 (file)
@@ -91,7 +91,7 @@ static __inline__ int fw_hash(u32 handle)
        else if (HTSIZE == 256) {
                u8 *t = (u8 *) &handle;
                return t[0] ^ t[1] ^ t[2] ^ t[3];
-       } else 
+       } else
                return handle & (HTSIZE - 1);
 }
 
@@ -407,7 +407,7 @@ static int __init init_fw(void)
        return register_tcf_proto_ops(&cls_fw_ops);
 }
 
-static void __exit exit_fw(void) 
+static void __exit exit_fw(void)
 {
        unregister_tcf_proto_ops(&cls_fw_ops);
 }
index 587b9adab38c07645acacef135e7242a8a729abb..7853621a04cc03d5c68fa1f6d0064c5f6586c88f 100644 (file)
@@ -130,7 +130,7 @@ static struct tcf_ext_map rsvp_ext_map = {
        else if (r > 0)                                 \
                return r;                               \
 }
-       
+
 static int rsvp_classify(struct sk_buff *skb, struct tcf_proto *tp,
                         struct tcf_result *res)
 {
@@ -347,7 +347,7 @@ static int tunnel_bts(struct rsvp_head *data)
 {
        int n = data->tgenerator>>5;
        u32 b = 1<<(data->tgenerator&0x1F);
-       
+
        if (data->tmap[n]&b)
                return 0;
        data->tmap[n] |= b;
@@ -547,7 +547,7 @@ insert:
        s->next = *sp;
        wmb();
        *sp = s;
-       
+
        goto insert;
 
 errout:
@@ -654,7 +654,7 @@ static int __init init_rsvp(void)
        return register_tcf_proto_ops(&RSVP_OPS);
 }
 
-static void __exit exit_rsvp(void) 
+static void __exit exit_rsvp(void)
 {
        unregister_tcf_proto_ops(&RSVP_OPS);
 }
index 5af8a59e1503c7d5a90cf332af72ee5921d94950..040e2d2d281a61413750a2a407624cce2c31f656 100644 (file)
@@ -222,7 +222,7 @@ tcindex_set_parms(struct tcf_proto *tp, unsigned long base, u32 handle,
        err = tcf_exts_validate(tp, tb, est, &e, &tcindex_ext_map);
        if (err < 0)
                return err;
-       
+
        memcpy(&cp, p, sizeof(cp));
        memset(&new_filter_result, 0, sizeof(new_filter_result));
 
@@ -316,12 +316,12 @@ tcindex_set_parms(struct tcf_proto *tp, unsigned long base, u32 handle,
                f = kzalloc(sizeof(*f), GFP_KERNEL);
                if (!f)
                        goto errout_alloc;
-       }
+       }
 
        if (tb[TCA_TCINDEX_CLASSID-1]) {
                cr.res.classid = *(u32 *) RTA_DATA(tb[TCA_TCINDEX_CLASSID-1]);
                tcf_bind_filter(tp, &cr.res, base);
-       }
+       }
 
        tcf_exts_change(tp, &cr.exts, &e);
 
@@ -341,7 +341,7 @@ tcindex_set_parms(struct tcf_proto *tp, unsigned long base, u32 handle,
                for (fp = p->h+(handle % p->hash); *fp; fp = &(*fp)->next)
                        /* nothing */;
                *fp = f;
-       }
+       }
        tcf_tree_unlock(tp);
 
        return 0;
@@ -491,7 +491,7 @@ static int tcindex_dump(struct tcf_proto *tp, unsigned long fh,
                if (tcf_exts_dump_stats(skb, &r->exts, &tcindex_ext_map) < 0)
                        goto rtattr_failure;
        }
-       
+
        return skb->len;
 
 rtattr_failure:
@@ -519,7 +519,7 @@ static int __init init_tcindex(void)
        return register_tcf_proto_ops(&cls_tcindex_ops);
 }
 
-static void __exit exit_tcindex(void) 
+static void __exit exit_tcindex(void)
 {
        unregister_tcf_proto_ops(&cls_tcindex_ops);
 }
index 8b51948019958b39f182a6119735cc7a50c94a22..a232671cfa4efdb44e482db65cb2b07781501d6c 100644 (file)
@@ -760,7 +760,7 @@ static int u32_dump(struct tcf_proto *tp, unsigned long fh,
                        RTA_PUT(skb, TCA_U32_INDEV, IFNAMSIZ, n->indev);
 #endif
 #ifdef CONFIG_CLS_U32_PERF
-               RTA_PUT(skb, TCA_U32_PCNT, 
+               RTA_PUT(skb, TCA_U32_PCNT,
                sizeof(struct tc_u32_pcnt) + n->sel.nkeys*sizeof(u64),
                        n->pf);
 #endif
@@ -810,7 +810,7 @@ static int __init init_u32(void)
        return register_tcf_proto_ops(&cls_u32_ops);
 }
 
-static void __exit exit_u32(void) 
+static void __exit exit_u32(void)
 {
        unregister_tcf_proto_ops(&cls_u32_ops);
 }
index 8ed93c39b4eaa5dcd76e2ebdeee3690dad3bb5eb..8d6dacd8190054a9cc401d48342232644ad3e7a9 100644 (file)
@@ -88,7 +88,7 @@ static int __init init_em_cmp(void)
        return tcf_em_register(&em_cmp_ops);
 }
 
-static void __exit exit_em_cmp(void) 
+static void __exit exit_em_cmp(void)
 {
        tcf_em_unregister(&em_cmp_ops);
 }
index 45d47d37155ead9727f5543b22e43cd0b3f87958..60acf8cdb27b34774f71dfdf79654349bf26cc5a 100644 (file)
@@ -9,7 +9,7 @@
  * Authors:    Thomas Graf <tgraf@suug.ch>
  *
  * ==========================================================================
- * 
+ *
  *     The metadata ematch compares two meta objects where each object
  *     represents either a meta value stored in the kernel or a static
  *     value provided by userspace. The objects are not provided by
@@ -290,7 +290,7 @@ META_COLLECTOR(var_sk_bound_if)
                dst->len = 3;
         } else  {
                struct net_device *dev;
-               
+
                dev = dev_get_by_index(skb->sk->sk_bound_dev_if);
                *err = var_dev(dev, dst);
                if (dev)
@@ -671,7 +671,7 @@ static inline struct meta_type_ops * meta_type_ops(struct meta_value *v)
  * Core
  **************************************************************************/
 
-static inline int meta_get(struct sk_buff *skb, struct tcf_pkt_info *info, 
+static inline int meta_get(struct sk_buff *skb, struct tcf_pkt_info *info,
                           struct meta_value *v, struct meta_obj *dst)
 {
        int err = 0;
@@ -753,7 +753,7 @@ static int em_meta_change(struct tcf_proto *tp, void *data, int len,
        struct rtattr *tb[TCA_EM_META_MAX];
        struct tcf_meta_hdr *hdr;
        struct meta_match *meta = NULL;
-       
+
        if (rtattr_parse(tb, TCA_EM_META_MAX, data, len) < 0)
                goto errout;
 
@@ -822,7 +822,7 @@ static int em_meta_dump(struct sk_buff *skb, struct tcf_ematch *em)
 
 rtattr_failure:
        return -1;
-}              
+}
 
 static struct tcf_ematch_ops em_meta_ops = {
        .kind     = TCF_EM_META,
@@ -839,7 +839,7 @@ static int __init init_em_meta(void)
        return tcf_em_register(&em_meta_ops);
 }
 
-static void __exit exit_em_meta(void) 
+static void __exit exit_em_meta(void)
 {
        tcf_em_unregister(&em_meta_ops);
 }
index 005db409be645a45abfd82f7694602874bc5b3ba..42103b2bdc519726f7c77152a61fc0d3e1d7622c 100644 (file)
@@ -23,7 +23,7 @@ struct nbyte_data
        struct tcf_em_nbyte     hdr;
        char                    pattern[0];
 };
-       
+
 static int em_nbyte_change(struct tcf_proto *tp, void *data, int data_len,
                           struct tcf_ematch *em)
 {
@@ -68,7 +68,7 @@ static int __init init_em_nbyte(void)
        return tcf_em_register(&em_nbyte_ops);
 }
 
-static void __exit exit_em_nbyte(void) 
+static void __exit exit_em_nbyte(void)
 {
        tcf_em_unregister(&em_nbyte_ops);
 }
index aa17d8f7c4c873aca24d6ae54ec5247dd8fefd8d..8ad894b58fcef7223ef9fd16368af81cb36c96d9 100644 (file)
@@ -125,7 +125,7 @@ static int em_text_dump(struct sk_buff *skb, struct tcf_ematch *m)
 
 rtattr_failure:
        return -1;
-}              
+}
 
 static struct tcf_ematch_ops em_text_ops = {
        .kind     = TCF_EM_TEXT,
@@ -142,7 +142,7 @@ static int __init init_em_text(void)
        return tcf_em_register(&em_text_ops);
 }
 
-static void __exit exit_em_text(void) 
+static void __exit exit_em_text(void)
 {
        tcf_em_unregister(&em_text_ops);
 }
index e3ddfce0ac8d9b28e7eee8d49c1f35920932363f..cd0600c6796984b955d26f4b5cc65e46aba8c4e6 100644 (file)
@@ -23,7 +23,7 @@ static int em_u32_match(struct sk_buff *skb, struct tcf_ematch *em,
 {
        struct tc_u32_key *key = (struct tc_u32_key *) em->data;
        unsigned char *ptr = skb->nh.raw;
-       
+
        if (info) {
                if (info->ptr)
                        ptr = info->ptr;
@@ -34,7 +34,7 @@ static int em_u32_match(struct sk_buff *skb, struct tcf_ematch *em,
 
        if (!tcf_valid_offset(skb, ptr, sizeof(u32)))
                return 0;
-       
+
        return !(((*(u32*) ptr)  ^ key->val) & key->mask);
 }
 
@@ -51,7 +51,7 @@ static int __init init_em_u32(void)
        return tcf_em_register(&em_u32_ops);
 }
 
-static void __exit exit_em_u32(void) 
+static void __exit exit_em_u32(void)
 {
        tcf_em_unregister(&em_u32_ops);
 }
index 8f8a16da72a8970acb1c11357ec228573b85cad4..d3ad36b361295ca371b8ec864738d5425546d79f 100644 (file)
  *                     --------<-POP---------
  *
  * where B is a virtual ematch referencing to sequence starting with B1.
- * 
+ *
  * ==========================================================================
  *
  * How to write an ematch in 60 seconds
  * ------------------------------------
- * 
+ *
  *   1) Provide a matcher function:
  *      static int my_match(struct sk_buff *skb, struct tcf_ematch *m,
  *                          struct tcf_pkt_info *info)
@@ -115,7 +115,7 @@ static inline struct tcf_ematch_ops * tcf_em_lookup(u16 kind)
 
 /**
  * tcf_em_register - register an extended match
- * 
+ *
  * @ops: ematch operations lookup table
  *
  * This function must be called by ematches to announce their presence.
@@ -211,7 +211,7 @@ static int tcf_em_validate(struct tcf_proto *tp,
                if (ref <= idx)
                        goto errout;
 
-               
+
                em->data = ref;
        } else {
                /* Note: This lookup will increase the module refcnt
@@ -327,7 +327,7 @@ int tcf_em_tree_validate(struct tcf_proto *tp, struct rtattr *rta,
        /* We do not use rtattr_parse_nested here because the maximum
         * number of attributes is unknown. This saves us the allocation
         * for a tb buffer which would serve no purpose at all.
-        * 
+        *
         * The array of rt attributes is parsed in the order as they are
         * provided, their type must be incremental from 1 to n. Even
         * if it does not serve any real purpose, a failure of sticking
@@ -399,7 +399,7 @@ void tcf_em_tree_destroy(struct tcf_proto *tp, struct tcf_ematch_tree *tree)
                        module_put(em->ops->owner);
                }
        }
-       
+
        tree->hdr.nmatches = 0;
        kfree(tree->matches);
 }
index 65825f4409d98c9872898bac77422c37b481b092..60b92fcdc8bbd5df0782769049d3671670eb3052 100644 (file)
@@ -389,7 +389,7 @@ static int qdisc_graft(struct net_device *dev, struct Qdisc *parent,
        struct Qdisc *q = *old;
 
 
-       if (parent == NULL) { 
+       if (parent == NULL) {
                if (q && q->flags&TCQ_F_INGRESS) {
                        *old = dev_graft_qdisc(dev, q);
                } else {
@@ -596,7 +596,7 @@ static int tc_get_qdisc(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
                                q = qdisc_leaf(p, clid);
                        } else { /* ingress */
                                q = dev->qdisc_ingress;
-                        }
+                       }
                } else {
                        q = dev->qdisc_sleeping;
                }
@@ -743,7 +743,7 @@ create_n_graft:
                return -ENOENT;
        if (clid == TC_H_INGRESS)
                q = qdisc_create(dev, tcm->tcm_parent, tca, &err);
-        else
+       else
                q = qdisc_create(dev, tcm->tcm_handle, tca, &err);
        if (q == NULL) {
                if (err == -EAGAIN)
@@ -808,10 +808,10 @@ static int tc_fill_qdisc(struct sk_buff *skb, struct Qdisc *q, u32 clid,
 #endif
            gnet_stats_copy_queue(&d, &q->qstats) < 0)
                goto rtattr_failure;
-       
+
        if (gnet_stats_finish_copy(&d) < 0)
                goto rtattr_failure;
-       
+
        nlh->nlmsg_len = skb->tail - b;
        return skb->len;
 
@@ -954,7 +954,7 @@ static int tc_ctl_tclass(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
        }
 
        /* OK. Locate qdisc */
-       if ((q = qdisc_lookup(dev, qid)) == NULL) 
+       if ((q = qdisc_lookup(dev, qid)) == NULL)
                return -ENOENT;
 
        /* An check that it supports classes */
@@ -978,7 +978,7 @@ static int tc_ctl_tclass(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
                        goto out;
        } else {
                switch (n->nlmsg_type) {
-               case RTM_NEWTCLASS:     
+               case RTM_NEWTCLASS:
                        err = -EEXIST;
                        if (n->nlmsg_flags&NLM_F_EXCL)
                                goto out;
@@ -1162,7 +1162,7 @@ reclassify:
                                skb->tc_verd = SET_TC_VERD(skb->tc_verd,verd);
                                goto reclassify;
                        } else {
-                               if (skb->tc_verd) 
+                               if (skb->tc_verd)
                                        skb->tc_verd = SET_TC_VERD(skb->tc_verd,0);
                                return err;
                        }
@@ -1200,7 +1200,7 @@ static struct file_operations psched_fops = {
        .read  = seq_read,
        .llseek = seq_lseek,
        .release = single_release,
-};     
+};
 #endif
 
 #ifdef CONFIG_NET_SCH_CLK_CPU
index edc7bb0b9c8b72f8589b91e5d238f6448eb0ca5d..afb3bbd571f27d981909ac3264eff661a235e28c 100644 (file)
@@ -107,7 +107,7 @@ static __inline__ struct atm_flow_data *lookup_flow(struct Qdisc *sch,
        struct atm_qdisc_data *p = PRIV(sch);
        struct atm_flow_data *flow;
 
-        for (flow = p->flows; flow; flow = flow->next)
+       for (flow = p->flows; flow; flow = flow->next)
                if (flow->classid == classid) break;
        return flow;
 }
@@ -125,7 +125,7 @@ static int atm_tc_graft(struct Qdisc *sch,unsigned long arg,
        if (!new) new = &noop_qdisc;
        *old = xchg(&flow->q,new);
        if (*old) qdisc_reset(*old);
-        return 0;
+       return 0;
 }
 
 
@@ -145,7 +145,7 @@ static unsigned long atm_tc_get(struct Qdisc *sch,u32 classid)
 
        DPRINTK("atm_tc_get(sch %p,[qdisc %p],classid %x)\n",sch,p,classid);
        flow = lookup_flow(sch,classid);
-        if (flow) flow->ref++;
+       if (flow) flow->ref++;
        DPRINTK("atm_tc_get: flow %p\n",flow);
        return (unsigned long) flow;
 }
@@ -280,9 +280,9 @@ static int atm_tc_change(struct Qdisc *sch, u32 classid, u32 parent,
            opt->rta_type,RTA_PAYLOAD(opt),hdr_len);
        if (!(sock = sockfd_lookup(fd,&error))) return error; /* f_count++ */
        DPRINTK("atm_tc_change: f_count %d\n",file_count(sock->file));
-        if (sock->ops->family != PF_ATMSVC && sock->ops->family != PF_ATMPVC) {
+       if (sock->ops->family != PF_ATMSVC && sock->ops->family != PF_ATMPVC) {
                error = -EPROTOTYPE;
-                goto err_out;
+               goto err_out;
        }
        /* @@@ should check if the socket is really operational or we'll crash
           on vcc->send */
@@ -320,9 +320,9 @@ static int atm_tc_change(struct Qdisc *sch, u32 classid, u32 parent,
                flow->q = &noop_qdisc;
        DPRINTK("atm_tc_change: qdisc %p\n",flow->q);
        flow->sock = sock;
-        flow->vcc = ATM_SD(sock); /* speedup */
+       flow->vcc = ATM_SD(sock); /* speedup */
        flow->vcc->user_back = flow;
-        DPRINTK("atm_tc_change: vcc %p\n",flow->vcc);
+       DPRINTK("atm_tc_change: vcc %p\n",flow->vcc);
        flow->old_pop = flow->vcc->pop;
        flow->parent = p;
        flow->vcc->pop = sch_atm_pop;
@@ -391,7 +391,7 @@ static struct tcf_proto **atm_tc_find_tcf(struct Qdisc *sch,unsigned long cl)
        struct atm_flow_data *flow = (struct atm_flow_data *) cl;
 
        DPRINTK("atm_tc_find_tcf(sch %p,[qdisc %p],flow %p)\n",sch,p,flow);
-        return flow ? &flow->filter_list : &p->link.filter_list;
+       return flow ? &flow->filter_list : &p->link.filter_list;
 }
 
 
@@ -546,8 +546,8 @@ static int atm_tc_requeue(struct sk_buff *skb,struct Qdisc *sch)
        D2PRINTK("atm_tc_requeue(skb %p,sch %p,[qdisc %p])\n",skb,sch,p);
        ret = p->link.q->ops->requeue(skb,p->link.q);
        if (!ret) {
-        sch->q.qlen++;
-        sch->qstats.requeues++;
+       sch->q.qlen++;
+       sch->qstats.requeues++;
     } else {
                sch->qstats.drops++;
                p->link.qstats.drops++;
@@ -726,7 +726,7 @@ static int __init atm_init(void)
        return register_qdisc(&atm_qdisc_ops);
 }
 
-static void __exit atm_exit(void) 
+static void __exit atm_exit(void)
 {
        unregister_qdisc(&atm_qdisc_ops);
 }
index f79a4f3d0a9584db88107acd901347c96a110087..48830cac1014cfe4f10972f0f4e40967ac0ab405 100644 (file)
        =======================================
 
        Sources: [1] Sally Floyd and Van Jacobson, "Link-sharing and Resource
-                Management Models for Packet Networks",
+                Management Models for Packet Networks",
                 IEEE/ACM Transactions on Networking, Vol.3, No.4, 1995
 
-                [2] Sally Floyd, "Notes on CBQ and Guaranteed Service", 1995
+                [2] Sally Floyd, "Notes on CBQ and Guaranteed Service", 1995
 
-                [3] Sally Floyd, "Notes on Class-Based Queueing: Setting
+                [3] Sally Floyd, "Notes on Class-Based Queueing: Setting
                 Parameters", 1996
 
                 [4] Sally Floyd and Michael Speer, "Experimental Results
        the implementation is different. Particularly:
 
        --- The WRR algorithm is different. Our version looks more
-        reasonable (I hope) and works when quanta are allowed to be
-        less than MTU, which is always the case when real time classes
-        have small rates. Note, that the statement of [3] is
-        incomplete, delay may actually be estimated even if class
-        per-round allotment is less than MTU. Namely, if per-round
-        allotment is W*r_i, and r_1+...+r_k = r < 1
+       reasonable (I hope) and works when quanta are allowed to be
+       less than MTU, which is always the case when real time classes
+       have small rates. Note, that the statement of [3] is
+       incomplete, delay may actually be estimated even if class
+       per-round allotment is less than MTU. Namely, if per-round
+       allotment is W*r_i, and r_1+...+r_k = r < 1
 
        delay_i <= ([MTU/(W*r_i)]*W*r + W*r + k*MTU)/B
 
@@ -280,7 +280,7 @@ cbq_classify(struct sk_buff *skb, struct Qdisc *sch, int *qerr)
 #ifdef CONFIG_NET_CLS_ACT
                switch (result) {
                case TC_ACT_QUEUED:
-               case TC_ACT_STOLEN: 
+               case TC_ACT_STOLEN:
                        *qerr = NET_XMIT_SUCCESS;
                case TC_ACT_SHOT:
                        return NULL;
@@ -479,7 +479,7 @@ static void cbq_ovl_classic(struct cbq_class *cl)
        if (!cl->delayed) {
                delay += cl->offtime;
 
-               /* 
+               /*
                   Class goes to sleep, so that it will have no
                   chance to work avgidle. Let's forgive it 8)
 
@@ -717,7 +717,7 @@ static int cbq_reshape_fail(struct sk_buff *skb, struct Qdisc *child)
 }
 #endif
 
-/* 
+/*
    It is mission critical procedure.
 
    We "regenerate" toplevel cutoff, if transmitting class
@@ -739,7 +739,7 @@ cbq_update_toplevel(struct cbq_sched_data *q, struct cbq_class *cl,
                                }
                        } while ((borrowed=borrowed->borrow) != NULL);
                }
-#if 0  
+#if 0
        /* It is not necessary now. Uncommenting it
           will save CPU cycles, but decrease fairness.
         */
@@ -768,7 +768,7 @@ cbq_update(struct cbq_sched_data *q)
                   (now - last) is total time between packet right edges.
                   (last_pktlen/rate) is "virtual" busy time, so that
 
-                        idle = (now - last) - last_pktlen/rate
+                        idle = (now - last) - last_pktlen/rate
                 */
 
                idle = PSCHED_TDIFF(q->now, cl->last);
@@ -907,7 +907,7 @@ cbq_dequeue_prio(struct Qdisc *sch, int prio)
                        skb = cl->q->dequeue(cl->q);
 
                        /* Class did not give us any skb :-(
-                          It could occur even if cl->q->q.qlen != 0 
+                          It could occur even if cl->q->q.qlen != 0
                           f.e. if cl->q == "tbf"
                         */
                        if (skb == NULL)
@@ -2131,7 +2131,7 @@ static int __init cbq_module_init(void)
 {
        return register_qdisc(&cbq_qdisc_ops);
 }
-static void __exit cbq_module_exit(void) 
+static void __exit cbq_module_exit(void)
 {
        unregister_qdisc(&cbq_qdisc_ops);
 }
index d5421816f00700ca298d6b1a1dd3a5972189fb19..96324cf4e6a9ac9a1046cfd294d66ab0ec0a82cd 100644 (file)
@@ -68,7 +68,7 @@ static inline int dsmark_valid_indices(u16 indices)
                        return 0;
                indices >>= 1;
        }
+
        return 1;
 }
 
@@ -100,7 +100,7 @@ static int dsmark_graft(struct Qdisc *sch, unsigned long arg,
        qdisc_reset(*old);
        sch_tree_unlock(sch);
 
-        return 0;
+       return 0;
 }
 
 static struct Qdisc *dsmark_leaf(struct Qdisc *sch, unsigned long arg)
@@ -151,7 +151,7 @@ static int dsmark_change(struct Qdisc *sch, u32 classid, u32 parent,
 
        if (tb[TCA_DSMARK_VALUE-1])
                p->value[*arg-1] = RTA_GET_U8(tb[TCA_DSMARK_VALUE-1]);
-               
+
        if (tb[TCA_DSMARK_MASK-1])
                p->mask[*arg-1] = mask;
 
@@ -167,7 +167,7 @@ static int dsmark_delete(struct Qdisc *sch, unsigned long arg)
 
        if (!dsmark_valid_index(p, arg))
                return -EINVAL;
-       
+
        p->mask[arg-1] = 0xff;
        p->value[arg-1] = 0;
 
@@ -193,9 +193,9 @@ static void dsmark_walk(struct Qdisc *sch,struct qdisc_walker *walker)
                                break;
                        }
                }
-ignore:                
+ignore:
                walker->count++;
-        }
+       }
 }
 
 static struct tcf_proto **dsmark_find_tcf(struct Qdisc *sch,unsigned long cl)
@@ -338,7 +338,7 @@ static unsigned int dsmark_drop(struct Qdisc *sch)
 {
        struct dsmark_qdisc_data *p = PRIV(sch);
        unsigned int len;
-       
+
        DPRINTK("dsmark_reset(sch %p,[qdisc %p])\n", sch, p);
 
        if (p->q->ops->drop == NULL)
@@ -506,7 +506,7 @@ static int __init dsmark_module_init(void)
        return register_qdisc(&dsmark_qdisc_ops);
 }
 
-static void __exit dsmark_module_exit(void) 
+static void __exit dsmark_module_exit(void)
 {
        unregister_qdisc(&dsmark_qdisc_ops);
 }
index bc116bd6937c01ffba6adcb142161f38b05b7e8c..52eb3439d7c6bf561dc88fca37fdaea0e8a1da4b 100644 (file)
@@ -36,7 +36,7 @@
 
 /* Main transmission queue. */
 
-/* Main qdisc structure lock. 
+/* Main qdisc structure lock.
 
    However, modifications
    to data, participating in scheduling must be additionally
@@ -66,7 +66,7 @@ void qdisc_unlock_tree(struct net_device *dev)
        write_unlock(&qdisc_tree_lock);
 }
 
-/* 
+/*
    dev->queue_lock serializes queue accesses for this device
    AND dev->qdisc pointer itself.
 
@@ -82,7 +82,7 @@ void qdisc_unlock_tree(struct net_device *dev)
    we do not check dev->tbusy flag here.
 
    Returns:  0  - queue is empty.
-            >0  - queue is not empty, but throttled.
+           >0  - queue is not empty, but throttled.
            <0  - queue is not empty. Device is throttled, if dev->tbusy != 0.
 
    NOTE: Called under dev->queue_lock with locally disabled BH.
@@ -112,7 +112,7 @@ static inline int qdisc_restart(struct net_device *dev)
                        if (!netif_tx_trylock(dev)) {
                        collision:
                                /* So, someone grabbed the driver. */
-                               
+
                                /* It may be transient configuration error,
                                   when hard_start_xmit() recurses. We detect
                                   it by checking xmit owner and drop the
@@ -128,7 +128,7 @@ static inline int qdisc_restart(struct net_device *dev)
                                goto requeue;
                        }
                }
-               
+
                {
                        /* And release queue */
                        spin_unlock(&dev->queue_lock);
@@ -137,7 +137,7 @@ static inline int qdisc_restart(struct net_device *dev)
                                int ret;
 
                                ret = dev_hard_start_xmit(skb, dev);
-                               if (ret == NETDEV_TX_OK) { 
+                               if (ret == NETDEV_TX_OK) {
                                        if (!nolock) {
                                                netif_tx_unlock(dev);
                                        }
@@ -146,15 +146,15 @@ static inline int qdisc_restart(struct net_device *dev)
                                }
                                if (ret == NETDEV_TX_LOCKED && nolock) {
                                        spin_lock(&dev->queue_lock);
-                                       goto collision; 
+                                       goto collision;
                                }
                        }
 
                        /* NETDEV_TX_BUSY - we need to requeue */
                        /* Release the driver */
-                       if (!nolock) { 
+                       if (!nolock) {
                                netif_tx_unlock(dev);
-                       } 
+                       }
                        spin_lock(&dev->queue_lock);
                        q = dev->qdisc;
                }
@@ -209,7 +209,7 @@ static void dev_watchdog(unsigned long arg)
                                       dev->name);
                                dev->tx_timeout(dev);
                        }
-                       if (!mod_timer(&dev->watchdog_timer, jiffies + dev->watchdog_timeo))
+                       if (!mod_timer(&dev->watchdog_timer, round_jiffies(jiffies + dev->watchdog_timeo)))
                                dev_hold(dev);
                }
        }
@@ -300,7 +300,7 @@ struct Qdisc noop_qdisc = {
        .enqueue        =       noop_enqueue,
        .dequeue        =       noop_dequeue,
        .flags          =       TCQ_F_BUILTIN,
-       .ops            =       &noop_qdisc_ops,        
+       .ops            =       &noop_qdisc_ops,
        .list           =       LIST_HEAD_INIT(noop_qdisc.list),
 };
 
@@ -454,7 +454,7 @@ struct Qdisc * qdisc_create_dflt(struct net_device *dev, struct Qdisc_ops *ops,
                                 unsigned int parentid)
 {
        struct Qdisc *sch;
-       
+
        sch = qdisc_alloc(dev, ops);
        if (IS_ERR(sch))
                goto errout;
@@ -478,7 +478,7 @@ void qdisc_reset(struct Qdisc *qdisc)
                ops->reset(qdisc);
 }
 
-/* this is the rcu callback function to clean up a qdisc when there 
+/* this is the rcu callback function to clean up a qdisc when there
  * are no further references to it */
 
 static void __qdisc_destroy(struct rcu_head *head)
@@ -600,10 +600,10 @@ void dev_shutdown(struct net_device *dev)
        dev->qdisc_sleeping = &noop_qdisc;
        qdisc_destroy(qdisc);
 #if defined(CONFIG_NET_SCH_INGRESS) || defined(CONFIG_NET_SCH_INGRESS_MODULE)
-        if ((qdisc = dev->qdisc_ingress) != NULL) {
+       if ((qdisc = dev->qdisc_ingress) != NULL) {
                dev->qdisc_ingress = NULL;
                qdisc_destroy(qdisc);
-        }
+       }
 #endif
        BUG_TRAP(!timer_pending(&dev->watchdog_timer));
        qdisc_unlock_tree(dev);
index 18e81a8ffb012e5aab0b7b6b9d9f1d3965f803d3..fa1b4fe7a5fd9772f27a8dd9b7f46e1a7df2ef08 100644 (file)
@@ -335,7 +335,7 @@ static void gred_reset(struct Qdisc* sch)
 
        qdisc_reset_queue(sch);
 
-        for (i = 0; i < t->DPs; i++) {
+       for (i = 0; i < t->DPs; i++) {
                struct gred_sched_data *q = t->tab[i];
 
                if (!q)
@@ -393,7 +393,7 @@ static inline int gred_change_table_def(struct Qdisc *sch, struct rtattr *dps)
                               "shadowed VQ 0x%x\n", i);
                        gred_destroy_vq(table->tab[i]);
                        table->tab[i] = NULL;
-               }
+               }
        }
 
        return 0;
index 6eefa69957772956628a5d74888570af99e01ee0..135087d4213a45f58eeecd2b935392bb70a933a5 100644 (file)
@@ -284,7 +284,7 @@ static inline struct hfsc_class *
 eltree_get_minel(struct hfsc_sched *q)
 {
        struct rb_node *n;
-       
+
        n = rb_first(&q->eligible);
        if (n == NULL)
                return NULL;
@@ -773,7 +773,7 @@ init_vf(struct hfsc_class *cl, unsigned int len)
                        /* update the virtual curve */
                        vt = cl->cl_vt + cl->cl_vtoff;
                        rtsc_min(&cl->cl_virtual, &cl->cl_fsc, vt,
-                                                     cl->cl_total);
+                                                     cl->cl_total);
                        if (cl->cl_virtual.x == vt) {
                                cl->cl_virtual.x -= cl->cl_vtoff;
                                cl->cl_vtoff = 0;
@@ -796,10 +796,10 @@ init_vf(struct hfsc_class *cl, unsigned int len)
 
                                /* update the ulimit curve */
                                rtsc_min(&cl->cl_ulimit, &cl->cl_usc, cur_time,
-                                        cl->cl_total);
+                                        cl->cl_total);
                                /* compute myf */
                                cl->cl_myf = rtsc_y2x(&cl->cl_ulimit,
-                                                     cl->cl_total);
+                                                     cl->cl_total);
                                cl->cl_myfadj = 0;
                        }
                }
@@ -853,7 +853,7 @@ update_vf(struct hfsc_class *cl, unsigned int len, u64 cur_time)
                 * update vt and f
                 */
                cl->cl_vt = rtsc_y2x(&cl->cl_virtual, cl->cl_total)
-                           - cl->cl_vtoff + cl->cl_vtadj;
+                           - cl->cl_vtoff + cl->cl_vtadj;
 
                /*
                 * if vt of the class is smaller than cvtmin,
@@ -870,7 +870,7 @@ update_vf(struct hfsc_class *cl, unsigned int len, u64 cur_time)
 
                if (cl->cl_flags & HFSC_USC) {
                        cl->cl_myf = cl->cl_myfadj + rtsc_y2x(&cl->cl_ulimit,
-                                                             cl->cl_total);
+                                                             cl->cl_total);
 #if 0
                        /*
                         * This code causes classes to stay way under their
@@ -1001,7 +1001,7 @@ hfsc_find_class(u32 classid, struct Qdisc *sch)
 
 static void
 hfsc_change_rsc(struct hfsc_class *cl, struct tc_service_curve *rsc,
-                u64 cur_time)
+               u64 cur_time)
 {
        sc2isc(rsc, &cl->cl_rsc);
        rtsc_init(&cl->cl_deadline, &cl->cl_rsc, cur_time, cl->cl_cumul);
@@ -1023,7 +1023,7 @@ hfsc_change_fsc(struct hfsc_class *cl, struct tc_service_curve *fsc)
 
 static void
 hfsc_change_usc(struct hfsc_class *cl, struct tc_service_curve *usc,
-                u64 cur_time)
+               u64 cur_time)
 {
        sc2isc(usc, &cl->cl_usc);
        rtsc_init(&cl->cl_ulimit, &cl->cl_usc, cur_time, cl->cl_total);
@@ -1032,7 +1032,7 @@ hfsc_change_usc(struct hfsc_class *cl, struct tc_service_curve *usc,
 
 static int
 hfsc_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
-                  struct rtattr **tca, unsigned long *arg)
+                 struct rtattr **tca, unsigned long *arg)
 {
        struct hfsc_sched *q = qdisc_priv(sch);
        struct hfsc_class *cl = (struct hfsc_class *)*arg;
@@ -1228,9 +1228,9 @@ hfsc_classify(struct sk_buff *skb, struct Qdisc *sch, int *qerr)
 #ifdef CONFIG_NET_CLS_ACT
                switch (result) {
                case TC_ACT_QUEUED:
-               case TC_ACT_STOLEN: 
+               case TC_ACT_STOLEN:
                        *qerr = NET_XMIT_SUCCESS;
-               case TC_ACT_SHOT: 
+               case TC_ACT_SHOT:
                        return NULL;
                }
 #elif defined(CONFIG_NET_CLS_POLICE)
@@ -1259,7 +1259,7 @@ hfsc_classify(struct sk_buff *skb, struct Qdisc *sch, int *qerr)
 
 static int
 hfsc_graft_class(struct Qdisc *sch, unsigned long arg, struct Qdisc *new,
-                 struct Qdisc **old)
+                struct Qdisc **old)
 {
        struct hfsc_class *cl = (struct hfsc_class *)arg;
 
@@ -1397,7 +1397,7 @@ hfsc_dump_curves(struct sk_buff *skb, struct hfsc_class *cl)
 
 static int
 hfsc_dump_class(struct Qdisc *sch, unsigned long arg, struct sk_buff *skb,
-                struct tcmsg *tcm)
+               struct tcmsg *tcm)
 {
        struct hfsc_class *cl = (struct hfsc_class *)arg;
        unsigned char *b = skb->tail;
index 15f23c5511a869d24927881868bc8a42cf581f5a..1f098d862f92b429e009c8cda471d03dee3f2afe 100644 (file)
@@ -11,7 +11,7 @@
  * Credits (in time order) for older HTB versions:
  *              Stef Coene <stef.coene@docum.org>
  *                     HTB support at LARTC mailing list
- *             Ondrej Kraus, <krauso@barr.cz> 
+ *             Ondrej Kraus, <krauso@barr.cz>
  *                     found missing INIT_QDISC(htb)
  *             Vladimir Smelhaus, Aamer Akhter, Bert Hubert
  *                     helped a lot to locate nasty class stall bug
     Author: devik@cdi.cz
     ========================================================================
     HTB is like TBF with multiple classes. It is also similar to CBQ because
-    it allows to assign priority to each class in hierarchy. 
+    it allows to assign priority to each class in hierarchy.
     In fact it is another implementation of Floyd's formal sharing.
 
     Levels:
-    Each class is assigned level. Leaf has ALWAYS level 0 and root 
+    Each class is assigned level. Leaf has ALWAYS level 0 and root
     classes have level TC_HTB_MAXDEPTH-1. Interior nodes has level
     one less than their parent.
 */
@@ -245,7 +245,7 @@ static inline struct htb_class *htb_find(u32 handle, struct Qdisc *sch)
  * We allow direct class selection by classid in priority. The we examine
  * filters in qdisc and in inner nodes (if higher filter points to the inner
  * node). If we end up with classid MAJOR:0 we enqueue the skb into special
- * internal fifo (direct). These packets then go directly thru. If we still 
+ * internal fifo (direct). These packets then go directly thru. If we still
  * have no valid leaf we try to use MAJOR:default leaf. It still unsuccessfull
  * then finish and return direct queue.
  */
@@ -433,7 +433,7 @@ static inline void htb_remove_class_from_row(struct htb_sched *q,
  * htb_activate_prios - creates active classe's feed chain
  *
  * The class is connected to ancestors and/or appropriate rows
- * for priorities it is participating on. cl->cmode must be new 
+ * for priorities it is participating on. cl->cmode must be new
  * (activated) mode. It does nothing if cl->prio_activity == 0.
  */
 static void htb_activate_prios(struct htb_sched *q, struct htb_class *cl)
@@ -466,7 +466,7 @@ static void htb_activate_prios(struct htb_sched *q, struct htb_class *cl)
 /**
  * htb_deactivate_prios - remove class from feed chain
  *
- * cl->cmode must represent old mode (before deactivation). It does 
+ * cl->cmode must represent old mode (before deactivation). It does
  * nothing if cl->prio_activity == 0. Class is removed from all feed
  * chains and rows.
  */
@@ -524,9 +524,9 @@ static inline long htb_hiwater(const struct htb_class *cl)
  *
  * It computes cl's mode at time cl->t_c+diff and returns it. If mode
  * is not HTB_CAN_SEND then cl->pq_key is updated to time difference
- * from now to time when cl will change its state. 
+ * from now to time when cl will change its state.
  * Also it is worth to note that class mode doesn't change simply
- * at cl->{c,}tokens == 0 but there can rather be hysteresis of 
+ * at cl->{c,}tokens == 0 but there can rather be hysteresis of
  * 0 .. -cl->{c,}buffer range. It is meant to limit number of
  * mode transitions per time unit. The speed gain is about 1/6.
  */
@@ -575,7 +575,7 @@ htb_change_class_mode(struct htb_sched *q, struct htb_class *cl, long *diff)
 }
 
 /**
- * htb_activate - inserts leaf cl into appropriate active feeds 
+ * htb_activate - inserts leaf cl into appropriate active feeds
  *
  * Routine learns (new) priority of leaf and activates feed chain
  * for the prio. It can be called on already active leaf safely.
@@ -594,7 +594,7 @@ static inline void htb_activate(struct htb_sched *q, struct htb_class *cl)
 }
 
 /**
- * htb_deactivate - remove leaf cl from active feeds 
+ * htb_deactivate - remove leaf cl from active feeds
  *
  * Make sure that leaf is active. In the other words it can't be called
  * with non-active leaf. It also removes class from the drop list.
@@ -854,7 +854,7 @@ static struct htb_class *htb_lookup_leaf(struct rb_root *tree, int prio,
 
        for (i = 0; i < 65535; i++) {
                if (!*sp->pptr && *sp->pid) {
-                       /* ptr was invalidated but id is valid - try to recover 
+                       /* ptr was invalidated but id is valid - try to recover
                           the original or next ptr */
                        *sp->pptr =
                            htb_id_find_next_upper(prio, sp->root, *sp->pid);
@@ -906,7 +906,7 @@ next:
 
                /* class can be empty - it is unlikely but can be true if leaf
                   qdisc drops packets in enqueue routine or if someone used
-                  graft operation on the leaf since last dequeue; 
+                  graft operation on the leaf since last dequeue;
                   simply deactivate and skip such class */
                if (unlikely(cl->un.leaf.q->q.qlen == 0)) {
                        struct htb_class *next;
@@ -1229,7 +1229,7 @@ static int htb_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new,
        if (cl && !cl->level) {
                if (new == NULL &&
                    (new = qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops,
-                                            cl->classid))
+                                            cl->classid))
                    == NULL)
                        return -ENOBUFS;
                sch_tree_lock(sch);
@@ -1347,7 +1347,7 @@ static void htb_destroy(struct Qdisc *sch)
        del_timer_sync(&q->rttim);
 #endif
        /* This line used to be after htb_destroy_class call below
-          and surprisingly it worked in 2.4. But it must precede it 
+          and surprisingly it worked in 2.4. But it must precede it
           because filter need its target class alive to be able to call
           unbind_filter on it (without Oops). */
        htb_destroy_filters(&q->filter_list);
index c3242f727d414667a26b89b4ff68d0895645a524..cfe070ee6ee33d2f62cfe0c09783d9389b3bfc63 100644 (file)
@@ -1,4 +1,4 @@
-/* net/sched/sch_ingress.c - Ingress qdisc 
+/* net/sched/sch_ingress.c - Ingress qdisc
  *              This program is free software; you can redistribute it and/or
  *              modify it under the terms of the GNU General Public License
  *              as published by the Free Software Foundation; either version
@@ -47,7 +47,7 @@
 */
 #ifndef CONFIG_NET_CLS_ACT
 #ifdef CONFIG_NETFILTER
-static int nf_registered; 
+static int nf_registered;
 #endif
 #endif
 
@@ -70,7 +70,7 @@ static int ingress_graft(struct Qdisc *sch,unsigned long arg,
        DPRINTK("ingress_graft(sch %p,[qdisc %p],new %p,old %p)\n",
                sch, p, new, old);
        DPRINTK("\n ingress_graft: You cannot add qdiscs to classes");
-        return 1;
+       return 1;
 }
 
 
@@ -162,7 +162,7 @@ static int ingress_enqueue(struct sk_buff *skb,struct Qdisc *sch)
                case TC_ACT_QUEUED:
                        result = TC_ACT_STOLEN;
                        break;
-               case TC_ACT_RECLASSIFY: 
+               case TC_ACT_RECLASSIFY:
                case TC_ACT_OK:
                case TC_ACT_UNSPEC:
                default:
@@ -172,7 +172,7 @@ static int ingress_enqueue(struct sk_buff *skb,struct Qdisc *sch)
        };
 /* backward compat */
 #else
-#ifdef CONFIG_NET_CLS_POLICE  
+#ifdef CONFIG_NET_CLS_POLICE
        switch (result) {
                case TC_POLICE_SHOT:
                result = NF_DROP;
@@ -232,14 +232,14 @@ static unsigned int ingress_drop(struct Qdisc *sch)
 #ifdef CONFIG_NETFILTER
 static unsigned int
 ing_hook(unsigned int hook, struct sk_buff **pskb,
-                             const struct net_device *indev,
-                             const struct net_device *outdev,
-                            int (*okfn)(struct sk_buff *))
+                            const struct net_device *indev,
+                            const struct net_device *outdev,
+                            int (*okfn)(struct sk_buff *))
 {
-       
+
        struct Qdisc *q;
        struct sk_buff *skb = *pskb;
-        struct net_device *dev = skb->dev;
+       struct net_device *dev = skb->dev;
        int fwres=NF_ACCEPT;
 
        DPRINTK("ing_hook: skb %s dev=%s len=%u\n",
@@ -247,7 +247,7 @@ ing_hook(unsigned int hook, struct sk_buff **pskb,
                skb->dev ? (*pskb)->dev->name : "(no dev)",
                skb->len);
 
-/* 
+/*
 revisit later: Use a private since lock dev->queue_lock is also
 used on the egress (might slow things for an iota)
 */
@@ -257,8 +257,8 @@ used on the egress (might slow things for an iota)
                if ((q = dev->qdisc_ingress) != NULL)
                        fwres = q->enqueue(skb, q);
                spin_unlock(&dev->queue_lock);
-        }
-                       
+       }
+
        return fwres;
 }
 
@@ -296,7 +296,7 @@ static int ingress_init(struct Qdisc *sch,struct rtattr *opt)
        printk("Ingress scheduler: Classifier actions prefered over netfilter\n");
 #endif
 #endif
-                                                                                
+
 #ifndef CONFIG_NET_CLS_ACT
 #ifdef CONFIG_NETFILTER
        if (!nf_registered) {
@@ -417,7 +417,7 @@ static int __init ingress_module_init(void)
 
        return ret;
 }
-static void __exit ingress_module_exit(void) 
+static void __exit ingress_module_exit(void)
 {
        unregister_qdisc(&ingress_qdisc_ops);
 #ifndef CONFIG_NET_CLS_ACT
index 79542af9dab1fb3213778011d3222e34bd202e0c..1ccbfb55b0b8cf6f5e3ab76707cb1fc88e6f4015 100644 (file)
@@ -7,7 +7,7 @@
  *             2 of the License.
  *
  *             Many of the algorithms and ideas for this came from
- *             NIST Net which is not copyrighted. 
+ *             NIST Net which is not copyrighted.
  *
  * Authors:    Stephen Hemminger <shemminger@osdl.org>
  *             Catalin(ux aka Dino) BOIE <catab at umbrella dot ro>
@@ -114,7 +114,7 @@ static unsigned long get_crandom(struct crndstate *state)
  * std deviation sigma.  Uses table lookup to approximate the desired
  * distribution, and a uniformly-distributed pseudo-random source.
  */
-static long tabledist(unsigned long mu, long sigma, 
+static long tabledist(unsigned long mu, long sigma,
                      struct crndstate *state, const struct disttable *dist)
 {
        long t, x;
@@ -126,7 +126,7 @@ static long tabledist(unsigned long mu, long sigma,
        rnd = get_crandom(state);
 
        /* default uniform distribution */
-       if (dist == NULL) 
+       if (dist == NULL)
                return (rnd % (2*sigma)) - sigma + mu;
 
        t = dist->table[rnd % dist->size];
@@ -218,7 +218,7 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)
                ++q->counter;
                ret = q->qdisc->enqueue(skb, q->qdisc);
        } else {
-               /* 
+               /*
                 * Do re-ordering by putting one out of N packets at the front
                 * of the queue.
                 */
@@ -323,7 +323,7 @@ static void netem_reset(struct Qdisc *sch)
 /* Pass size change message down to embedded FIFO */
 static int set_fifo_limit(struct Qdisc *q, int limit)
 {
-        struct rtattr *rta;
+       struct rtattr *rta;
        int ret = -ENOMEM;
 
        /* Hack to avoid sending change message to non-FIFO */
@@ -333,9 +333,9 @@ static int set_fifo_limit(struct Qdisc *q, int limit)
        rta = kmalloc(RTA_LENGTH(sizeof(struct tc_fifo_qopt)), GFP_KERNEL);
        if (rta) {
                rta->rta_type = RTM_NEWQDISC;
-               rta->rta_len = RTA_LENGTH(sizeof(struct tc_fifo_qopt)); 
+               rta->rta_len = RTA_LENGTH(sizeof(struct tc_fifo_qopt));
                ((struct tc_fifo_qopt *)RTA_DATA(rta))->limit = limit;
-               
+
                ret = q->ops->change(q, rta);
                kfree(rta);
        }
@@ -364,7 +364,7 @@ static int get_dist_table(struct Qdisc *sch, const struct rtattr *attr)
        d->size = n;
        for (i = 0; i < n; i++)
                d->table[i] = data[i];
-       
+
        spin_lock_bh(&sch->dev->queue_lock);
        d = xchg(&q->delay_dist, d);
        spin_unlock_bh(&sch->dev->queue_lock);
@@ -419,7 +419,7 @@ static int netem_change(struct Qdisc *sch, struct rtattr *opt)
        struct netem_sched_data *q = qdisc_priv(sch);
        struct tc_netem_qopt *qopt;
        int ret;
-       
+
        if (opt == NULL || RTA_PAYLOAD(opt) < sizeof(*qopt))
                return -EINVAL;
 
@@ -429,7 +429,7 @@ static int netem_change(struct Qdisc *sch, struct rtattr *opt)
                pr_debug("netem: can't set fifo limit\n");
                return ret;
        }
-       
+
        q->latency = qopt->latency;
        q->jitter = qopt->jitter;
        q->limit = qopt->limit;
@@ -445,10 +445,10 @@ static int netem_change(struct Qdisc *sch, struct rtattr *opt)
 
        /* Handle nested options after initial queue options.
         * Should have put all options in nested format but too late now.
-        */ 
+        */
        if (RTA_PAYLOAD(opt) > sizeof(*qopt)) {
                struct rtattr *tb[TCA_NETEM_MAX];
-               if (rtattr_parse(tb, TCA_NETEM_MAX, 
+               if (rtattr_parse(tb, TCA_NETEM_MAX,
                                 RTA_DATA(opt) + sizeof(*qopt),
                                 RTA_PAYLOAD(opt) - sizeof(*qopt)))
                        return -EINVAL;
@@ -681,7 +681,7 @@ static void netem_put(struct Qdisc *sch, unsigned long arg)
 {
 }
 
-static int netem_change_class(struct Qdisc *sch, u32 classid, u32 parentid, 
+static int netem_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
                            struct rtattr **tca, unsigned long *arg)
 {
        return -ENOSYS;
index 2567b4c96c1e9055c6e3ab4e4ff89a70d36aa741..9f957ca5073b09c01192390f229d5ff37b7afb73 100644 (file)
@@ -7,7 +7,7 @@
  *             2 of the License, or (at your option) any later version.
  *
  * Authors:    Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
- * Fixes:       19990609: J Hadi Salim <hadi@nortelnetworks.com>: 
+ * Fixes:       19990609: J Hadi Salim <hadi@nortelnetworks.com>:
  *              Init --  EINVAL when opt undefined
  */
 
@@ -105,7 +105,7 @@ prio_enqueue(struct sk_buff *skb, struct Qdisc *sch)
                return NET_XMIT_SUCCESS;
        }
        sch->qstats.drops++;
-       return ret; 
+       return ret;
 }
 
 
@@ -372,6 +372,20 @@ static int prio_dump_class(struct Qdisc *sch, unsigned long cl, struct sk_buff *
        return 0;
 }
 
+static int prio_dump_class_stats(struct Qdisc *sch, unsigned long cl,
+                                struct gnet_dump *d)
+{
+       struct prio_sched_data *q = qdisc_priv(sch);
+       struct Qdisc *cl_q;
+
+       cl_q = q->queues[cl - 1];
+       if (gnet_stats_copy_basic(d, &cl_q->bstats) < 0 ||
+           gnet_stats_copy_queue(d, &cl_q->qstats) < 0)
+               return -1;
+
+       return 0;
+}
+
 static void prio_walk(struct Qdisc *sch, struct qdisc_walker *arg)
 {
        struct prio_sched_data *q = qdisc_priv(sch);
@@ -414,6 +428,7 @@ static struct Qdisc_class_ops prio_class_ops = {
        .bind_tcf       =       prio_bind,
        .unbind_tcf     =       prio_put,
        .dump           =       prio_dump_class,
+       .dump_stats     =       prio_dump_class_stats,
 };
 
 static struct Qdisc_ops prio_qdisc_ops = {
@@ -438,7 +453,7 @@ static int __init prio_module_init(void)
        return register_qdisc(&prio_qdisc_ops);
 }
 
-static void __exit prio_module_exit(void) 
+static void __exit prio_module_exit(void)
 {
        unregister_qdisc(&prio_qdisc_ops);
 }
index acddad08850fa65d1082e2d5377b8fd9d3956b4b..00db53eb8159ecadc156fe1eab669cf179d4008d 100644 (file)
@@ -185,7 +185,7 @@ static struct Qdisc *red_create_dflt(struct Qdisc *sch, u32 limit)
                              TC_H_MAKE(sch->handle, 1));
        if (q) {
                rta = kmalloc(RTA_LENGTH(sizeof(struct tc_fifo_qopt)),
-                             GFP_KERNEL);
+                             GFP_KERNEL);
                if (rta) {
                        rta->rta_type = RTM_NEWQDISC;
                        rta->rta_len = RTA_LENGTH(sizeof(struct tc_fifo_qopt));
index 459cda258a5cac23fc78bef333a951def3ee1406..66f32051a99b4b182adf0db17fdb0c29ae67c3c8 100644 (file)
@@ -53,7 +53,7 @@
        Queuing using Deficit Round Robin", Proc. SIGCOMM 95.
 
 
-       This is not the thing that is usually called (W)FQ nowadays. 
+       This is not the thing that is usually called (W)FQ nowadays.
        It does not use any timestamp mechanism, but instead
        processes queues in round-robin order.
 
@@ -63,7 +63,7 @@
 
        DRAWBACKS:
 
-       - "Stochastic" -> It is not 100% fair. 
+       - "Stochastic" -> It is not 100% fair.
        When hash collisions occur, several flows are considered as one.
 
        - "Round-robin" -> It introduces larger delays than virtual clock
@@ -143,6 +143,7 @@ static unsigned sfq_hash(struct sfq_sched_data *q, struct sk_buff *skb)
                if (!(iph->frag_off&htons(IP_MF|IP_OFFSET)) &&
                    (iph->protocol == IPPROTO_TCP ||
                     iph->protocol == IPPROTO_UDP ||
+                    iph->protocol == IPPROTO_UDPLITE ||
                     iph->protocol == IPPROTO_SCTP ||
                     iph->protocol == IPPROTO_DCCP ||
                     iph->protocol == IPPROTO_ESP))
@@ -156,6 +157,7 @@ static unsigned sfq_hash(struct sfq_sched_data *q, struct sk_buff *skb)
                h2 = iph->saddr.s6_addr32[3]^iph->nexthdr;
                if (iph->nexthdr == IPPROTO_TCP ||
                    iph->nexthdr == IPPROTO_UDP ||
+                   iph->nexthdr == IPPROTO_UDPLITE ||
                    iph->nexthdr == IPPROTO_SCTP ||
                    iph->nexthdr == IPPROTO_DCCP ||
                    iph->nexthdr == IPPROTO_ESP)
@@ -499,7 +501,7 @@ static int __init sfq_module_init(void)
 {
        return register_qdisc(&sfq_qdisc_ops);
 }
-static void __exit sfq_module_exit(void) 
+static void __exit sfq_module_exit(void)
 {
        unregister_qdisc(&sfq_qdisc_ops);
 }
index ed9b6d93854086e004979a41e3b68a79135a02b5..85da8daa61d20a7c6130577c03c182d2d42ef213 100644 (file)
@@ -276,7 +276,7 @@ static void tbf_reset(struct Qdisc* sch)
 static struct Qdisc *tbf_create_dflt_qdisc(struct Qdisc *sch, u32 limit)
 {
        struct Qdisc *q;
-        struct rtattr *rta;
+       struct rtattr *rta;
        int ret;
 
        q = qdisc_create_dflt(sch->dev, &bfifo_qdisc_ops,
@@ -285,7 +285,7 @@ static struct Qdisc *tbf_create_dflt_qdisc(struct Qdisc *sch, u32 limit)
                rta = kmalloc(RTA_LENGTH(sizeof(struct tc_fifo_qopt)), GFP_KERNEL);
                if (rta) {
                        rta->rta_type = RTM_NEWQDISC;
-                       rta->rta_len = RTA_LENGTH(sizeof(struct tc_fifo_qopt)); 
+                       rta->rta_len = RTA_LENGTH(sizeof(struct tc_fifo_qopt));
                        ((struct tc_fifo_qopt *)RTA_DATA(rta))->limit = limit;
 
                        ret = q->ops->change(q, rta);
@@ -475,7 +475,7 @@ static void tbf_put(struct Qdisc *sch, unsigned long arg)
 {
 }
 
-static int tbf_change_class(struct Qdisc *sch, u32 classid, u32 parentid, 
+static int tbf_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
                            struct rtattr **tca, unsigned long *arg)
 {
        return -ENOSYS;
index 4c16ad57a3e49141335a2812b4c7bc3e976e9b46..6a66037abac9e80cb08e7bcc7c02b69681fc12b1 100644 (file)
@@ -178,7 +178,7 @@ teql_destroy(struct Qdisc* sch)
                                teql_neigh_release(xchg(&dat->ncache, NULL));
                                break;
                        }
-                               
+
                } while ((prev = q) != master->slaves);
        }
 }
@@ -292,7 +292,7 @@ restart:
 
        do {
                struct net_device *slave = q->dev;
-               
+
                if (slave->qdisc_sleeping != q)
                        continue;
                if (netif_queue_stopped(slave) || ! netif_running(slave)) {
@@ -425,7 +425,7 @@ static __init void teql_master_setup(struct net_device *dev)
 
        master->dev     = dev;
        ops->priv_size  = sizeof(struct teql_sched_data);
-       
+
        ops->enqueue    =       teql_enqueue;
        ops->dequeue    =       teql_dequeue;
        ops->requeue    =       teql_requeue;
@@ -489,7 +489,7 @@ static int __init teql_init(void)
        return i ? 0 : err;
 }
 
-static void __exit teql_exit(void) 
+static void __exit teql_exit(void)
 {
        struct teql_master *master, *nxt;
 
index 5db95caed0a321f2bc10bd11ec5061fa100c3df9..fca6f75b0a0d8b553ea4c55f2484538f304e69ce 100644 (file)
@@ -158,14 +158,14 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a
         * If the 'T5-shutdown-guard' timer is used, it SHOULD be set to the
         * recommended value of 5 times 'RTO.Max'.
         */
-        asoc->timeouts[SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD]
+       asoc->timeouts[SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD]
                = 5 * asoc->rto_max;
 
        asoc->timeouts[SCTP_EVENT_TIMEOUT_HEARTBEAT] = 0;
        asoc->timeouts[SCTP_EVENT_TIMEOUT_SACK] = asoc->sackdelay;
        asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE] =
                sp->autoclose * HZ;
-       
+
        /* Initilizes the timers */
        for (i = SCTP_EVENT_TIMEOUT_NONE; i < SCTP_NUM_TIMEOUT_TYPES; ++i) {
                init_timer(&asoc->timers[i]);
@@ -1334,8 +1334,8 @@ int sctp_assoc_set_bind_addr_from_cookie(struct sctp_association *asoc,
                                      asoc->ep->base.bind_addr.port, gfp);
 }
 
-/* Lookup laddr in the bind address list of an association. */ 
-int sctp_assoc_lookup_laddr(struct sctp_association *asoc, 
+/* Lookup laddr in the bind address list of an association. */
+int sctp_assoc_lookup_laddr(struct sctp_association *asoc,
                            const union sctp_addr *laddr)
 {
        int found;
@@ -1343,7 +1343,7 @@ int sctp_assoc_lookup_laddr(struct sctp_association *asoc,
        sctp_read_lock(&asoc->base.addr_lock);
        if ((asoc->base.bind_addr.port == ntohs(laddr->v4.sin_port)) &&
            sctp_bind_addr_match(&asoc->base.bind_addr, laddr,
-                                sctp_sk(asoc->base.sk))) {
+                                sctp_sk(asoc->base.sk))) {
                found = 1;
                goto out;
        }
index 00994158e4962997ba90a6ac9cdf7a00863bf9ea..80294cbc0de60ecab79c8ac3ca597ffbd1c60138 100644 (file)
@@ -62,7 +62,7 @@ static void sctp_bind_addr_clean(struct sctp_bind_addr *);
 /* Copy 'src' to 'dest' taking 'scope' into account.  Omit addresses
  * in 'src' which have a broader scope than 'scope'.
  */
-int sctp_bind_addr_copy(struct sctp_bind_addr *dest, 
+int sctp_bind_addr_copy(struct sctp_bind_addr *dest,
                        const struct sctp_bind_addr *src,
                        sctp_scope_t scope, gfp_t gfp,
                        int flags)
@@ -296,7 +296,7 @@ int sctp_raw_to_bind_addrs(struct sctp_bind_addr *bp, __u8 *raw_addr_list,
  ********************************************************************/
 
 /* Does this contain a specified address?  Allow wildcarding. */
-int sctp_bind_addr_match(struct sctp_bind_addr *bp, 
+int sctp_bind_addr_match(struct sctp_bind_addr *bp,
                         const union sctp_addr *addr,
                         struct sctp_sock *opt)
 {
@@ -306,7 +306,7 @@ int sctp_bind_addr_match(struct sctp_bind_addr *bp,
        list_for_each(pos, &bp->address_list) {
                laddr = list_entry(pos, struct sctp_sockaddr_entry, list);
                if (opt->pf->cmp_addr(&laddr->a, addr, opt))
-                       return 1;
+                       return 1;
        }
 
        return 0;
@@ -329,12 +329,12 @@ union sctp_addr *sctp_find_unmatch_addr(struct sctp_bind_addr     *bp,
 
        list_for_each(pos, &bp->address_list) {
                laddr = list_entry(pos, struct sctp_sockaddr_entry, list);
-               
+
                addr_buf = (union sctp_addr *)addrs;
                for (i = 0; i < addrcnt; i++) {
                        addr = (union sctp_addr *)addr_buf;
                        af = sctp_get_af_specific(addr->v4.sin_family);
-                       if (!af) 
+                       if (!af)
                                return NULL;
 
                        if (opt->pf->cmp_addr(&laddr->a, addr, opt))
@@ -350,7 +350,7 @@ union sctp_addr *sctp_find_unmatch_addr(struct sctp_bind_addr       *bp,
 }
 
 /* Copy out addresses from the global local address list. */
-static int sctp_copy_one_addr(struct sctp_bind_addr *dest, 
+static int sctp_copy_one_addr(struct sctp_bind_addr *dest,
                              union sctp_addr *addr,
                              sctp_scope_t scope, gfp_t gfp,
                              int flags)
index 31f05ec8e1d3f32d71196ba5b5799f6b103318dc..59cf7b06d216c7450cbf1bec1f3965812d63fff8 100644 (file)
@@ -1,40 +1,40 @@
 /* SCTP kernel reference Implementation
  * Copyright (c) 1999-2001 Motorola, Inc.
  * Copyright (c) 2001-2003 International Business Machines, Corp.
- * 
+ *
  * This file is part of the SCTP kernel reference Implementation
- * 
+ *
  * SCTP Checksum functions
- * 
- * The SCTP reference implementation is free software; 
- * you can redistribute it and/or modify it under the terms of 
+ *
+ * The SCTP reference implementation is free software;
+ * you can redistribute it and/or modify it under the terms of
  * the GNU General Public License as published by
  * the Free Software Foundation; either version 2, or (at your option)
  * any later version.
- * 
- * The SCTP reference implementation is distributed in the hope that it 
+ *
+ * The SCTP reference implementation is distributed in the hope that it
  * will be useful, but WITHOUT ANY WARRANTY; without even the implied
  *                 ************************
  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  * See the GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with GNU CC; see the file COPYING.  If not, write to
  * the Free Software Foundation, 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.  
- * 
+ * Boston, MA 02111-1307, USA.
+ *
  * Please send any bug reports or fixes you make to the
  * email address(es):
  *    lksctp developers <lksctp-developers@lists.sourceforge.net>
- * 
+ *
  * Or submit a bug report through the following website:
  *    http://www.sf.net/projects/lksctp
  *
- * Written or modified by: 
- *    Dinakaran Joseph 
+ * Written or modified by:
+ *    Dinakaran Joseph
  *    Jon Grimm <jgrimm@us.ibm.com>
  *    Sridhar Samudrala <sri@us.ibm.com>
- * 
+ *
  * Any bugs reported given to us we will try to fix... any fixes shared will
  * be incorporated into the next SCTP release.
  */
@@ -135,10 +135,10 @@ static const __u32 crc_c[256] = {
        0x79B737BA, 0x8BDCB4B9, 0x988C474D, 0x6AE7C44E,
        0xBE2DA0A5, 0x4C4623A6, 0x5F16D052, 0xAD7D5351,
 };
-     
+
 __u32 sctp_start_cksum(__u8 *buffer, __u16 length)
 {
-       __u32 crc32 = ~(__u32) 0;
+       __u32 crc32 = ~(__u32) 0;
        __u32 i;
 
        /* Optimize this routine to be SCTP specific, knowing how
@@ -147,7 +147,7 @@ __u32 sctp_start_cksum(__u8 *buffer, __u16 length)
 
        /* Calculate CRC up to the checksum. */
        for (i = 0; i < (sizeof(struct sctphdr) - sizeof(__u32)); i++)
-               CRC32C(crc32, buffer[i]);
+               CRC32C(crc32, buffer[i]);
 
        /* Skip checksum field of the header. */
        for (i = 0; i < sizeof(__u32); i++)
@@ -175,13 +175,13 @@ __u32 sctp_update_copy_cksum(__u8 *to, __u8 *from, __u16 length, __u32 crc32)
        __u32 i;
        __u32 *_to = (__u32 *)to;
        __u32 *_from = (__u32 *)from;
-       
+
        for (i = 0; i < (length/4); i++) {
                _to[i] = _from[i];
                CRC32C(crc32, from[i*4]);
                CRC32C(crc32, from[i*4+1]);
                CRC32C(crc32, from[i*4+2]);
-               CRC32C(crc32, from[i*4+3]);     
+               CRC32C(crc32, from[i*4+3]);
        }
 
        return crc32;
index aa8340373af7f1596e66f93ab418d87bda9052d0..5f5ab28977c9c83c54ff081c2b98d10a05872e74 100644 (file)
@@ -3,48 +3,48 @@
  * Copyright (c) 1999-2000 Cisco, Inc.
  * Copyright (c) 1999-2001 Motorola, Inc.
  * Copyright (c) 2001 Intel Corp.
- * 
+ *
  * This file is part of the SCTP kernel reference Implementation
- * 
+ *
  * This file is part of the implementation of the add-IP extension,
  * based on <draft-ietf-tsvwg-addip-sctp-02.txt> June 29, 2001,
  * for the SCTP kernel reference Implementation.
- * 
+ *
  * This file converts numerical ID value to alphabetical names for SCTP
  * terms such as chunk type, parameter time, event type, etc.
- * 
- * The SCTP reference implementation is free software; 
- * you can redistribute it and/or modify it under the terms of 
+ *
+ * The SCTP reference implementation is free software;
+ * you can redistribute it and/or modify it under the terms of
  * the GNU General Public License as published by
  * the Free Software Foundation; either version 2, or (at your option)
  * any later version.
- * 
- * The SCTP reference implementation is distributed in the hope that it 
+ *
+ * The SCTP reference implementation is distributed in the hope that it
  * will be useful, but WITHOUT ANY WARRANTY; without even the implied
  *                 ************************
  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  * See the GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with GNU CC; see the file COPYING.  If not, write to
  * the Free Software Foundation, 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.  
- * 
+ * Boston, MA 02111-1307, USA.
+ *
  * Please send any bug reports or fixes you make to the
  * email address(es):
  *    lksctp developers <lksctp-developers@lists.sourceforge.net>
- * 
+ *
  * Or submit a bug report through the following website:
  *    http://www.sf.net/projects/lksctp
  *
- * Written or modified by: 
+ * Written or modified by:
  *    La Monte H.P. Yarroll <piggy@acm.org>
  *    Karl Knutson          <karl@athena.chicago.il.us>
  *    Xingang Guo           <xingang.guo@intel.com>
  *    Jon Grimm             <jgrimm@us.ibm.com>
  *    Daisy Chang          <daisyc@us.ibm.com>
  *    Sridhar Samudrala            <sri@us.ibm.com>
- * 
+ *
  * Any bugs reported given to us we will try to fix... any fixes shared will
  * be incorporated into the next SCTP release.
  */
@@ -81,7 +81,7 @@ const char *sctp_cname(const sctp_subtype_t cid)
                return "illegal chunk id";
        if (cid.chunk <= SCTP_CID_BASE_MAX)
                return sctp_cid_tbl[cid.chunk];
-       
+
        switch (cid.chunk) {
        case SCTP_CID_ASCONF:
                return "ASCONF";
@@ -154,7 +154,7 @@ const char *sctp_pname(const sctp_subtype_t id)
 
 static const char *sctp_other_tbl[] = {
        "NO_PENDING_TSN",
-        "ICMP_PROTO_UNREACH",
+       "ICMP_PROTO_UNREACH",
 };
 
 /* Lookup "other" debug name. */
index 129756908da49992b5a42e07b84f7521a778e891..286a8dbb63b7f56924bc99961e5a469c56429013 100644 (file)
@@ -369,7 +369,7 @@ static void sctp_endpoint_bh_rcv(struct work_struct *work)
                        chunk->transport->last_time_heard = jiffies;
 
                error = sctp_do_sm(SCTP_EVENT_T_CHUNK, subtype, state,
-                                   ep, asoc, chunk, GFP_ATOMIC);
+                                  ep, asoc, chunk, GFP_ATOMIC);
 
                if (error && chunk)
                        chunk->pdiscard = 1;
index 33111873a488eaf78b63907d73da6ce6ad9cc9fd..71db66873695ffadeed4ac18cc68454dfbc7ab44 100644 (file)
@@ -226,7 +226,7 @@ int sctp_rcv(struct sk_buff *skb)
        nf_reset(skb);
 
        if (sk_filter(sk, skb))
-                goto discard_release;
+               goto discard_release;
 
        /* Create an SCTP packet structure. */
        chunk = sctp_chunkify(skb, asoc, sk);
@@ -293,11 +293,11 @@ discard_release:
 int sctp_backlog_rcv(struct sock *sk, struct sk_buff *skb)
 {
        struct sctp_chunk *chunk = SCTP_INPUT_CB(skb)->chunk;
-       struct sctp_inq *inqueue = &chunk->rcvr->inqueue;
-       struct sctp_ep_common *rcvr = NULL;
+       struct sctp_inq *inqueue = &chunk->rcvr->inqueue;
+       struct sctp_ep_common *rcvr = NULL;
        int backloged = 0;
 
-       rcvr = chunk->rcvr;
+       rcvr = chunk->rcvr;
 
        /* If the rcvr is dead then the association or endpoint
         * has been deleted and we can safely drop the chunk
@@ -347,7 +347,7 @@ done:
        else
                BUG();
 
-        return 0;
+       return 0;
 }
 
 static void sctp_add_backlog(struct sock *sk, struct sk_buff *skb)
@@ -399,7 +399,7 @@ void sctp_icmp_frag_needed(struct sock *sk, struct sctp_association *asoc,
         * Normally, if PMTU discovery is disabled, an ICMP Fragmentation
         * Needed will never be sent, but if a message was sent before
         * PMTU discovery was disabled that was larger than the PMTU, it
-        * would not be fragmented, so it must be re-transmitted fragmented.     
+        * would not be fragmented, so it must be re-transmitted fragmented.
         */
        sctp_retransmit(&asoc->outqueue, t, SCTP_RTXR_PMTUD);
 }
@@ -416,8 +416,8 @@ void sctp_icmp_frag_needed(struct sock *sk, struct sctp_association *asoc,
  *
  */
 void sctp_icmp_proto_unreachable(struct sock *sk,
-                           struct sctp_association *asoc,
-                           struct sctp_transport *t)
+                          struct sctp_association *asoc,
+                          struct sctp_transport *t)
 {
        SCTP_DEBUG_PRINTK("%s\n",  __FUNCTION__);
 
index 71b07466e880415ce812ca0b55e4f90e37f67ab9..c30629e177814cc1313f7a710999ffdfe67b873c 100644 (file)
@@ -2,43 +2,43 @@
  * Copyright (c) 1999-2000 Cisco, Inc.
  * Copyright (c) 1999-2001 Motorola, Inc.
  * Copyright (c) 2002 International Business Machines, Corp.
- * 
+ *
  * This file is part of the SCTP kernel reference Implementation
- * 
+ *
  * These functions are the methods for accessing the SCTP inqueue.
  *
  * An SCTP inqueue is a queue into which you push SCTP packets
  * (which might be bundles or fragments of chunks) and out of which you
  * pop SCTP whole chunks.
- * 
- * The SCTP reference implementation is free software; 
- * you can redistribute it and/or modify it under the terms of 
+ *
+ * The SCTP reference implementation is free software;
+ * you can redistribute it and/or modify it under the terms of
  * the GNU General Public License as published by
  * the Free Software Foundation; either version 2, or (at your option)
  * any later version.
- * 
- * The SCTP reference implementation is distributed in the hope that it 
+ *
+ * The SCTP reference implementation is distributed in the hope that it
  * will be useful, but WITHOUT ANY WARRANTY; without even the implied
  *                 ************************
  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  * See the GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with GNU CC; see the file COPYING.  If not, write to
  * the Free Software Foundation, 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.  
- * 
+ * Boston, MA 02111-1307, USA.
+ *
  * Please send any bug reports or fixes you make to the
  * email address(es):
  *    lksctp developers <lksctp-developers@lists.sourceforge.net>
- * 
+ *
  * Or submit a bug report through the following website:
  *    http://www.sf.net/projects/lksctp
  *
- * Written or modified by: 
+ * Written or modified by:
  *    La Monte H.P. Yarroll <piggy@acm.org>
  *    Karl Knutson <karl@athena.chicago.il.us>
- * 
+ *
  * Any bugs reported given to us we will try to fix... any fixes shared will
  * be incorporated into the next SCTP release.
  */
@@ -152,8 +152,8 @@ struct sctp_chunk *sctp_inq_pop(struct sctp_inq *queue)
                chunk->data_accepted = 0;
        }
 
-        chunk->chunk_hdr = ch;
-        chunk->chunk_end = ((__u8 *)ch) + WORD_ROUND(ntohs(ch->length));
+       chunk->chunk_hdr = ch;
+       chunk->chunk_end = ((__u8 *)ch) + WORD_ROUND(ntohs(ch->length));
        /* In the unlikely case of an IP reassembly, the skb could be
         * non-linear. If so, update chunk_end so that it doesn't go past
         * the skb->tail.
@@ -169,11 +169,11 @@ struct sctp_chunk *sctp_inq_pop(struct sctp_inq *queue)
                /* This is not a singleton */
                chunk->singleton = 0;
        } else if (chunk->chunk_end > chunk->skb->tail) {
-                /* RFC 2960, Section 6.10  Bundling
+               /* RFC 2960, Section 6.10  Bundling
                 *
                 * Partial chunks MUST NOT be placed in an SCTP packet.
                 * If the receiver detects a partial chunk, it MUST drop
-                * the chunk.  
+                * the chunk.
                 *
                 * Since the end of the chunk is past the end of our buffer
                 * (which contains the whole packet, we can freely discard
index ef36be073a139418ef7e50942150eaa7f4acfcaf..01b27fb5dfc50f1e33942093f3fd159b9913e756 100644 (file)
@@ -236,7 +236,7 @@ static struct dst_entry *sctp_v6_get_dst(struct sctp_association *asoc,
        ipv6_addr_copy(&fl.fl6_dst, &daddr->v6.sin6_addr);
        if (ipv6_addr_type(&daddr->v6.sin6_addr) & IPV6_ADDR_LINKLOCAL)
                fl.oif = daddr->v6.sin6_scope_id;
-       
+
 
        SCTP_DEBUG_PRINTK("%s: DST=" NIP6_FMT " ",
                          __FUNCTION__, NIP6(fl.fl6_dst));
index 8ff588f0d76af8343820d6020118c7d48570eae4..fcfb9d806de1137d3b5fb7e1e3beab4e79a94933 100644 (file)
@@ -1,39 +1,39 @@
 /* SCTP kernel reference Implementation
  * (C) Copyright IBM Corp. 2001, 2004
- * 
+ *
  * This file is part of the SCTP kernel reference Implementation
- * 
+ *
  * Support for memory object debugging.  This allows one to monitor the
- * object allocations/deallocations for types instrumented for this 
- * via the proc fs. 
- * 
- * The SCTP reference implementation is free software; 
- * you can redistribute it and/or modify it under the terms of 
+ * object allocations/deallocations for types instrumented for this
+ * via the proc fs.
+ *
+ * The SCTP reference implementation is free software;
+ * you can redistribute it and/or modify it under the terms of
  * the GNU General Public License as published by
  * the Free Software Foundation; either version 2, or (at your option)
  * any later version.
- * 
- * The SCTP reference implementation is distributed in the hope that it 
+ *
+ * The SCTP reference implementation is distributed in the hope that it
  * will be useful, but WITHOUT ANY WARRANTY; without even the implied
  *                 ************************
  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  * See the GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with GNU CC; see the file COPYING.  If not, write to
  * the Free Software Foundation, 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.  
- * 
+ * Boston, MA 02111-1307, USA.
+ *
  * Please send any bug reports or fixes you make to the
  * email address(es):
  *    lksctp developers <lksctp-developers@lists.sourceforge.net>
- * 
+ *
  * Or submit a bug report through the following website:
  *    http://www.sf.net/projects/lksctp
  *
- * Written or modified by: 
+ * Written or modified by:
  *    Jon Grimm             <jgrimm@us.ibm.com>
- * 
+ *
  * Any bugs reported given to us we will try to fix... any fixes shared will
  * be incorporated into the next SCTP release.
  */
@@ -121,7 +121,7 @@ done:
        if (len > length)
                len = length;
 
-       return len;
+       return len;
 }
 
 /* Initialize the objcount in the proc filesystem.  */
@@ -131,7 +131,7 @@ void sctp_dbg_objcnt_init(void)
        ent = create_proc_read_entry("sctp_dbg_objcnt", 0, proc_net_sctp,
                               sctp_dbg_objcnt_read, NULL);
        if (!ent)
-               printk(KERN_WARNING 
+               printk(KERN_WARNING
                        "sctp_dbg_objcnt: Unable to create /proc entry.\n");
 }
 
index 3ef4351dd956ad95649afd568b3a91381a86e730..f875fc3ced5498f012996eaf7d39d4039c149642 100644 (file)
@@ -85,8 +85,8 @@ struct sctp_packet *sctp_packet_config(struct sctp_packet *packet,
                chunk = sctp_get_ecne_prepend(packet->transport->asoc);
 
                /* If there a is a prepend chunk stick it on the list before
-                * any other chunks get appended.
-                */
+                * any other chunks get appended.
+                */
                if (chunk)
                        sctp_packet_append_chunk(packet, chunk);
        }
@@ -110,8 +110,8 @@ struct sctp_packet *sctp_packet_init(struct sctp_packet *packet,
        packet->destination_port = dport;
        INIT_LIST_HEAD(&packet->chunk_list);
        if (asoc) {
-               struct sctp_sock *sp = sctp_sk(asoc->base.sk);  
-               overhead = sp->pf->af->net_header_len; 
+               struct sctp_sock *sp = sctp_sk(asoc->base.sk);
+               overhead = sp->pf->af->net_header_len;
        } else {
                overhead = sizeof(struct ipv6hdr);
        }
@@ -442,7 +442,7 @@ int sctp_packet_transmit(struct sctp_packet *packet)
                 * acknowledged or have failed.
                 */
                if (!sctp_chunk_is_data(chunk))
-                       sctp_chunk_free(chunk);
+                       sctp_chunk_free(chunk);
        }
 
        /* Perform final transformation on checksum. */
@@ -528,7 +528,7 @@ err:
        list_for_each_entry_safe(chunk, tmp, &packet->chunk_list, list) {
                list_del_init(&chunk->list);
                if (!sctp_chunk_is_data(chunk))
-                       sctp_chunk_free(chunk);
+                       sctp_chunk_free(chunk);
        }
        goto out;
 nomem:
index fba567a7cb64343dad79285057f0ae8d9a384b98..5c2ddd10db065629139d0544cc439ffa42e10687 100644 (file)
@@ -376,7 +376,7 @@ static void sctp_insert_list(struct list_head *head, struct list_head *new)
                }
        }
        if (!done)
-               list_add_tail(new, head); 
+               list_add_tail(new, head);
 }
 
 /* Mark all the eligible packets on a transport for retransmission.  */
@@ -578,7 +578,7 @@ static int sctp_outq_flush_rtx(struct sctp_outq *q, struct sctp_packet *pkt,
                        break;
 
                case SCTP_XMIT_RWND_FULL:
-                       /* Send this packet. */
+                       /* Send this packet. */
                        if ((error = sctp_packet_transmit(pkt)) == 0)
                                *start_timer = 1;
 
@@ -590,7 +590,7 @@ static int sctp_outq_flush_rtx(struct sctp_outq *q, struct sctp_packet *pkt,
                        break;
 
                case SCTP_XMIT_NAGLE_DELAY:
-                       /* Send this packet. */
+                       /* Send this packet. */
                        if ((error = sctp_packet_transmit(pkt)) == 0)
                                *start_timer = 1;
 
@@ -605,7 +605,7 @@ static int sctp_outq_flush_rtx(struct sctp_outq *q, struct sctp_packet *pkt,
                         */
                        list_add_tail(lchunk, &transport->transmitted);
 
-                       /* Mark the chunk as ineligible for fast retransmit 
+                       /* Mark the chunk as ineligible for fast retransmit
                         * after it is retransmitted.
                         */
                        if (chunk->fast_retransmit > 0)
@@ -703,11 +703,11 @@ int sctp_outq_flush(struct sctp_outq *q, int rtx_timeout)
                         * inactive.
                         *
                         * 3.3.6 Heartbeat Acknowledgement:
-                        * ...  
+                        * ...
                         * A HEARTBEAT ACK is always sent to the source IP
                         * address of the IP datagram containing the
                         * HEARTBEAT chunk to which this ack is responding.
-                        * ...  
+                        * ...
                         */
                        if (chunk->chunk_hdr->type != SCTP_CID_HEARTBEAT &&
                            chunk->chunk_hdr->type != SCTP_CID_HEARTBEAT_ACK)
@@ -914,7 +914,7 @@ int sctp_outq_flush(struct sctp_outq *q, int rtx_timeout)
                                BUG();
                        }
 
-                       /* BUG: We assume that the sctp_packet_transmit() 
+                       /* BUG: We assume that the sctp_packet_transmit()
                         * call below will succeed all the time and add the
                         * chunk to the transmitted list and restart the
                         * timers.
@@ -1266,7 +1266,7 @@ static void sctp_check_transmitted(struct sctp_outq *q,
                                 * first instance of the packet or a later
                                 * instance).
                                 */
-                               if (!tchunk->tsn_gap_acked &&
+                               if (!tchunk->tsn_gap_acked &&
                                    !tchunk->resent &&
                                    tchunk->rtt_in_progress) {
                                        tchunk->rtt_in_progress = 0;
@@ -1275,7 +1275,7 @@ static void sctp_check_transmitted(struct sctp_outq *q,
                                                                  rtt);
                                }
                        }
-                        if (TSN_lte(tsn, sack_ctsn)) {
+                       if (TSN_lte(tsn, sack_ctsn)) {
                                /* RFC 2960  6.3.2 Retransmission Timer Rules
                                 *
                                 * R3) Whenever a SACK is received
@@ -1590,7 +1590,7 @@ static void sctp_mark_missing(struct sctp_outq *q,
                SCTP_DEBUG_PRINTK("%s: transport: %p, cwnd: %d, "
                                  "ssthresh: %d, flight_size: %d, pba: %d\n",
                                  __FUNCTION__, transport, transport->cwnd,
-                                 transport->ssthresh, transport->flight_size,
+                                 transport->ssthresh, transport->flight_size,
                                  transport->partial_bytes_acked);
        }
 }
@@ -1603,7 +1603,7 @@ static int sctp_acked(struct sctp_sackhdr *sack, __u32 tsn)
        __u16 gap;
        __u32 ctsn = ntohl(sack->cum_tsn_ack);
 
-        if (TSN_lte(tsn, ctsn))
+       if (TSN_lte(tsn, ctsn))
                goto pass;
 
        /* 3.3.4 Selective Acknowledgement (SACK) (3):
@@ -1657,7 +1657,7 @@ static void sctp_generate_fwdtsn(struct sctp_outq *q, __u32 ctsn)
 
        /* PR-SCTP C1) Let SackCumAck be the Cumulative TSN ACK carried in the
         * received SACK.
-        * 
+        *
         * If (Advanced.Peer.Ack.Point < SackCumAck), then update
         * Advanced.Peer.Ack.Point to be equal to SackCumAck.
         */
@@ -1671,7 +1671,7 @@ static void sctp_generate_fwdtsn(struct sctp_outq *q, __u32 ctsn)
         *
         * Assuming that a SACK arrived with the Cumulative TSN ACK 102
         * and the Advanced.Peer.Ack.Point is updated to this value:
-        * 
+        *
         *   out-queue at the end of  ==>   out-queue after Adv.Ack.Point
         *   normal SACK processing           local advancement
         *                ...                           ...
@@ -1692,7 +1692,7 @@ static void sctp_generate_fwdtsn(struct sctp_outq *q, __u32 ctsn)
 
                /* Remove any chunks in the abandoned queue that are acked by
                 * the ctsn.
-                */ 
+                */
                if (TSN_lte(tsn, ctsn)) {
                        list_del_init(lchunk);
                        if (!chunk->tsn_gap_acked) {
@@ -1743,7 +1743,7 @@ static void sctp_generate_fwdtsn(struct sctp_outq *q, __u32 ctsn)
         */
        if (asoc->adv_peer_ack_point > ctsn)
                ftsn_chunk = sctp_make_fwdtsn(asoc, asoc->adv_peer_ack_point,
-                                             nskips, &ftsn_skip_arr[0]); 
+                                             nskips, &ftsn_skip_arr[0]);
 
        if (ftsn_chunk) {
                list_add_tail(&ftsn_chunk->list, &q->control_chunk_list);
index 3a7ebfcc1fdbc6eb9fa8837fbf8017d373228780..1b2976d34ac759212a24d2aa1ee97cfcb1e2cd87 100644 (file)
@@ -70,7 +70,7 @@ int sctp_primitive_ ## name(struct sctp_association *asoc, \
        \
        error = sctp_do_sm(event_type, subtype, state, ep, asoc, \
                           arg, GFP_KERNEL); \
-       return error; \
+       return error; \
 }
 
 /* 10.1 ULP-to-SCTP
@@ -207,7 +207,7 @@ DECLARE_PRIMITIVE(REQUESTHEARTBEAT);
 
 /* ADDIP
 * 3.1.1 Address Configuration Change Chunk (ASCONF)
-* 
+*
 * This chunk is used to communicate to the remote endpoint one of the
 * configuration change requests that MUST be acknowledged.  The
 * information carried in the ASCONF Chunk uses the form of a
index b3493bdbcacbc884cabedc055c3cd82f5097850e..e93fc1cc430ab4f3fc58dbc1108b1d57324eaad2 100644 (file)
@@ -77,7 +77,7 @@ static struct snmp_mib sctp_snmp_list[] = {
 
 /* Return the current value of a particular entry in the mib by adding its
  * per cpu counters.
- */ 
+ */
 static unsigned long
 fold_field(void *mib[], int nr)
 {
@@ -102,7 +102,7 @@ static int sctp_snmp_seq_show(struct seq_file *seq, void *v)
 
        for (i = 0; sctp_snmp_list[i].name != NULL; i++)
                seq_printf(seq, "%-32s\t%ld\n", sctp_snmp_list[i].name,
-                          fold_field((void **)sctp_statistics, 
+                          fold_field((void **)sctp_statistics,
                                      sctp_snmp_list[i].entry));
 
        return 0;
index 0ef48126b117c76267208833f76c96c84fa814bb..e17a823ca90fcecc1d6e5da68d7ad6b9ea70eeee 100644 (file)
@@ -102,11 +102,11 @@ static __init int sctp_proc_init(void)
        }
 
        if (sctp_snmp_proc_init())
-               goto out_nomem; 
+               goto out_nomem;
        if (sctp_eps_proc_init())
-               goto out_nomem; 
+               goto out_nomem;
        if (sctp_assocs_proc_init())
-               goto out_nomem; 
+               goto out_nomem;
 
        return 0;
 
@@ -114,7 +114,7 @@ out_nomem:
        return -ENOMEM;
 }
 
-/* Clean up the proc fs entry for the SCTP protocol. 
+/* Clean up the proc fs entry for the SCTP protocol.
  * Note: Do not make this __exit as it is used in the init error
  * path.
  */
@@ -286,7 +286,7 @@ static int sctp_v4_to_addr_param(const union sctp_addr *addr,
 
        param->v4.param_hdr.type = SCTP_PARAM_IPV4_ADDRESS;
        param->v4.param_hdr.length = htons(length);
-       param->v4.addr.s_addr = addr->v4.sin_addr.s_addr;       
+       param->v4.addr.s_addr = addr->v4.sin_addr.s_addr;
 
        return length;
 }
@@ -344,9 +344,9 @@ static int sctp_v4_addr_valid(union sctp_addr *addr,
        if (IS_IPV4_UNUSABLE_ADDRESS(&addr->v4.sin_addr.s_addr))
                return 0;
 
-       /* Is this a broadcast address? */
-       if (skb && ((struct rtable *)skb->dst)->rt_flags & RTCF_BROADCAST)
-               return 0;
+       /* Is this a broadcast address? */
+       if (skb && ((struct rtable *)skb->dst)->rt_flags & RTCF_BROADCAST)
+               return 0;
 
        return 1;
 }
@@ -494,7 +494,7 @@ out_unlock:
 out:
        if (dst)
                SCTP_DEBUG_PRINTK("rt_dst:%u.%u.%u.%u, rt_src:%u.%u.%u.%u\n",
-                                 NIPQUAD(rt->rt_dst), NIPQUAD(rt->rt_src));
+                                 NIPQUAD(rt->rt_dst), NIPQUAD(rt->rt_src));
        else
                SCTP_DEBUG_PRINTK("NO ROUTE\n");
 
@@ -517,14 +517,14 @@ static void sctp_v4_get_saddr(struct sctp_association *asoc,
        if (rt) {
                saddr->v4.sin_family = AF_INET;
                saddr->v4.sin_port = htons(asoc->base.bind_addr.port);
-               saddr->v4.sin_addr.s_addr = rt->rt_src; 
+               saddr->v4.sin_addr.s_addr = rt->rt_src;
        }
 }
 
 /* What interface did this skb arrive on? */
 static int sctp_v4_skb_iif(const struct sk_buff *skb)
 {
-       return ((struct rtable *)skb->dst)->rt_iif;
+       return ((struct rtable *)skb->dst)->rt_iif;
 }
 
 /* Was this packet marked by Explicit Congestion Notification? */
@@ -569,7 +569,7 @@ static struct sock *sctp_v4_create_accept_sk(struct sock *sk,
        newinet->dport = htons(asoc->peer.port);
        newinet->daddr = asoc->peer.primary_addr.v4.sin_addr.s_addr;
        newinet->pmtudisc = inet->pmtudisc;
-       newinet->id = asoc->next_tsn ^ jiffies;
+       newinet->id = asoc->next_tsn ^ jiffies;
 
        newinet->uc_ttl = -1;
        newinet->mc_loop = 1;
index 0b1ddb1005acf3ba451faa15bf0ff8237f211a1f..f7fb29d5a0c728ea83cad16b54bfe6671b06d81d 100644 (file)
@@ -118,7 +118,7 @@ void  sctp_init_cause(struct sctp_chunk *chunk, __be16 cause_code,
        int padlen;
        __u16 len;
 
-        /* Cause code constants are now defined in network order.  */
+       /* Cause code constants are now defined in network order.  */
        err.cause = cause_code;
        len = sizeof(sctp_errhdr_t) + paylen;
        padlen = len % 4;
@@ -295,11 +295,11 @@ struct sctp_chunk *sctp_make_init_ack(const struct sctp_association *asoc,
         */
        chunksize = sizeof(initack) + addrs_len + cookie_len + unkparam_len;
 
-        /* Tell peer that we'll do ECN only if peer advertised such cap.  */
+       /* Tell peer that we'll do ECN only if peer advertised such cap.  */
        if (asoc->peer.ecn_capable)
                chunksize += sizeof(ecap_param);
 
-        /* Tell peer that we'll do PR-SCTP only if peer advertised.  */
+       /* Tell peer that we'll do PR-SCTP only if peer advertised.  */
        if (asoc->peer.prsctp_capable)
                chunksize += sizeof(prsctp_param);
 
@@ -728,7 +728,7 @@ struct sctp_chunk *sctp_make_shutdown_complete(
        if (retval && chunk)
                retval->transport = chunk->transport;
 
-        return retval;
+       return retval;
 }
 
 /* Create an ABORT.  Note that we set the T bit if we have no
@@ -844,7 +844,7 @@ err_chunk:
        return retval;
 }
 
-/* Make an ABORT chunk with a PROTOCOL VIOLATION cause code. */ 
+/* Make an ABORT chunk with a PROTOCOL VIOLATION cause code. */
 struct sctp_chunk *sctp_make_abort_violation(
        const struct sctp_association *asoc,
        const struct sctp_chunk *chunk,
@@ -979,11 +979,10 @@ struct sctp_chunk *sctp_chunkify(struct sk_buff *skb,
 {
        struct sctp_chunk *retval;
 
-       retval = kmem_cache_alloc(sctp_chunk_cachep, GFP_ATOMIC);
+       retval = kmem_cache_zalloc(sctp_chunk_cachep, GFP_ATOMIC);
 
        if (!retval)
                goto nodata;
-       memset(retval, 0, sizeof(struct sctp_chunk));
 
        if (!sk) {
                SCTP_DEBUG_PRINTK("chunkifying skb %p w/o an sk\n", skb);
@@ -1265,8 +1264,8 @@ static sctp_cookie_param_t *sctp_pack_cookie(const struct sctp_endpoint *ep,
        /* Header size is static data prior to the actual cookie, including
         * any padding.
         */
-       headersize = sizeof(sctp_paramhdr_t) + 
-                    (sizeof(struct sctp_signed_cookie) - 
+       headersize = sizeof(sctp_paramhdr_t) +
+                    (sizeof(struct sctp_signed_cookie) -
                      sizeof(struct sctp_cookie));
        bodysize = sizeof(struct sctp_cookie)
                + ntohs(init_chunk->chunk_hdr->length) + addrs_len;
@@ -1315,7 +1314,7 @@ static sctp_cookie_param_t *sctp_pack_cookie(const struct sctp_endpoint *ep,
        memcpy((__u8 *)&cookie->c.peer_init[0] +
               ntohs(init_chunk->chunk_hdr->length), raw_addrs, addrs_len);
 
-       if (sctp_sk(ep->base.sk)->hmac) {
+       if (sctp_sk(ep->base.sk)->hmac) {
                struct hash_desc desc;
 
                /* Sign the message.  */
@@ -1324,8 +1323,8 @@ static sctp_cookie_param_t *sctp_pack_cookie(const struct sctp_endpoint *ep,
                sg.length = bodysize;
                keylen = SCTP_SECRET_SIZE;
                key = (char *)ep->secret_key[ep->current_key];
-               desc.tfm = sctp_sk(ep->base.sk)->hmac;
-               desc.flags = 0;
+               desc.tfm = sctp_sk(ep->base.sk)->hmac;
+               desc.flags = 0;
 
                if (crypto_hash_setkey(desc.tfm, key, keylen) ||
                    crypto_hash_digest(&desc, &sg, bodysize, cookie->signature))
@@ -1365,7 +1364,7 @@ struct sctp_association *sctp_unpack_cookie(
         * any padding.
         */
        headersize = sizeof(sctp_chunkhdr_t) +
-                    (sizeof(struct sctp_signed_cookie) - 
+                    (sizeof(struct sctp_signed_cookie) -
                      sizeof(struct sctp_cookie));
        bodysize = ntohs(chunk->chunk_hdr->length) - headersize;
        fixed_size = headersize + sizeof(struct sctp_cookie);
@@ -1593,7 +1592,7 @@ static int sctp_process_inv_paramlength(const struct sctp_association *asoc,
                                        struct sctp_chunk **errp)
 {
        char            error[] = "The following parameter had invalid length:";
-       size_t          payload_len = WORD_ROUND(sizeof(error)) + 
+       size_t          payload_len = WORD_ROUND(sizeof(error)) +
                                                sizeof(sctp_paramhdr_t);
 
 
@@ -1752,7 +1751,7 @@ static int sctp_verify_param(const struct sctp_association *asoc,
        case SCTP_PARAM_FWD_TSN_SUPPORT:
                if (sctp_prsctp_enable)
                        break;
-               /* Fall Through */ 
+               /* Fall Through */
        default:
                SCTP_DEBUG_PRINTK("Unrecognized param: %d for chunk %d.\n",
                                ntohs(param.p->type), cid);
@@ -1861,7 +1860,7 @@ int sctp_process_init(struct sctp_association *asoc, sctp_cid_t cid,
        sctp_walk_params(param, peer_init, init_hdr.params) {
 
                if (!sctp_process_param(asoc, param, peer_addr, gfp))
-                        goto clean_up;
+                       goto clean_up;
        }
 
        /* Walk list of transports, removing transports in the UNKNOWN state. */
@@ -1937,7 +1936,7 @@ int sctp_process_init(struct sctp_association *asoc, sctp_cid_t cid,
         */
 
        /* Allocate storage for the negotiated streams if it is not a temporary
-        * association.
+        * association.
         */
        if (!asoc->temp) {
                int assoc_id;
@@ -2109,7 +2108,7 @@ static int sctp_process_param(struct sctp_association *asoc,
                        asoc->peer.prsctp_capable = 1;
                        break;
                }
-               /* Fall Through */ 
+               /* Fall Through */
        default:
                /* Any unrecognized parameters should have been caught
                 * and handled by sctp_verify_param() which should be
@@ -2168,7 +2167,7 @@ __u32 sctp_generate_tsn(const struct sctp_endpoint *ep)
  *     |                     ASCONF Parameter #N                       |
  *      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  *
- * Address Parameter and other parameter will not be wrapped in this function 
+ * Address Parameter and other parameter will not be wrapped in this function
  */
 static struct sctp_chunk *sctp_make_asconf(struct sctp_association *asoc,
                                           union sctp_addr *addr,
@@ -2290,7 +2289,7 @@ struct sctp_chunk *sctp_make_asconf_update_ip(struct sctp_association *asoc,
  *     |                       Address Parameter                       |
  *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  *
- * Create an ASCONF chunk with Set Primary IP address parameter. 
+ * Create an ASCONF chunk with Set Primary IP address parameter.
  */
 struct sctp_chunk *sctp_make_asconf_set_prim(struct sctp_association *asoc,
                                             union sctp_addr *addr)
@@ -2339,7 +2338,7 @@ struct sctp_chunk *sctp_make_asconf_set_prim(struct sctp_association *asoc,
  *     |                 ASCONF Parameter Response#N                   |
  *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  *
- * Create an ASCONF_ACK chunk with enough space for the parameter responses. 
+ * Create an ASCONF_ACK chunk with enough space for the parameter responses.
  */
 static struct sctp_chunk *sctp_make_asconf_ack(const struct sctp_association *asoc,
                                               __u32 serial, int vparam_len)
@@ -2381,7 +2380,7 @@ static void sctp_add_asconf_response(struct sctp_chunk *chunk, __be32 crr_id,
                                 ntohs(asconf_param->param_hdr.length);
        }
 
-       /* Add Success Indication or Error Cause Indication parameter. */ 
+       /* Add Success Indication or Error Cause Indication parameter. */
        ack_param.param_hdr.type = response_type;
        ack_param.param_hdr.length = htons(sizeof(ack_param) +
                                           err_param_len +
@@ -2424,11 +2423,11 @@ static __be16 sctp_process_asconf_param(struct sctp_association *asoc,
        switch (asconf_param->param_hdr.type) {
        case SCTP_PARAM_ADD_IP:
                /* ADDIP 4.3 D9) If an endpoint receives an ADD IP address
-                * request and does not have the local resources to add this
-                * new address to the association, it MUST return an Error
-                * Cause TLV set to the new error code 'Operation Refused
-                * Due to Resource Shortage'.
-                */
+                * request and does not have the local resources to add this
+                * new address to the association, it MUST return an Error
+                * Cause TLV set to the new error code 'Operation Refused
+                * Due to Resource Shortage'.
+                */
 
                peer = sctp_assoc_add_peer(asoc, &addr, GFP_ATOMIC, SCTP_UNCONFIRMED);
                if (!peer)
@@ -2440,10 +2439,10 @@ static __be16 sctp_process_asconf_param(struct sctp_association *asoc,
                break;
        case SCTP_PARAM_DEL_IP:
                /* ADDIP 4.3 D7) If a request is received to delete the
-                * last remaining IP address of a peer endpoint, the receiver
-                * MUST send an Error Cause TLV with the error cause set to the
-                * new error code 'Request to Delete Last Remaining IP Address'.
-                */
+                * last remaining IP address of a peer endpoint, the receiver
+                * MUST send an Error Cause TLV with the error cause set to the
+                * new error code 'Request to Delete Last Remaining IP Address'.
+                */
                pos = asoc->peer.transport_addr_list.next;
                if (pos->next == &asoc->peer.transport_addr_list)
                        return SCTP_ERROR_DEL_LAST_IP;
@@ -2475,7 +2474,7 @@ static __be16 sctp_process_asconf_param(struct sctp_association *asoc,
        return SCTP_ERROR_NO_ERROR;
 }
 
-/* Process an incoming ASCONF chunk with the next expected serial no. and 
+/* Process an incoming ASCONF chunk with the next expected serial no. and
  * return an ASCONF_ACK chunk to be sent in response.
  */
 struct sctp_chunk *sctp_process_asconf(struct sctp_association *asoc,
@@ -2495,19 +2494,19 @@ struct sctp_chunk *sctp_process_asconf(struct sctp_association *asoc,
        hdr = (sctp_addiphdr_t *)asconf->skb->data;
        serial = ntohl(hdr->serial);
 
-       /* Skip the addiphdr and store a pointer to address parameter.  */ 
+       /* Skip the addiphdr and store a pointer to address parameter.  */
        length = sizeof(sctp_addiphdr_t);
        addr_param = (union sctp_addr_param *)(asconf->skb->data + length);
        chunk_len -= length;
 
        /* Skip the address parameter and store a pointer to the first
         * asconf paramter.
-        */ 
+        */
        length = ntohs(addr_param->v4.param_hdr.length);
        asconf_param = (sctp_addip_param_t *)((void *)addr_param + length);
        chunk_len -= length;
 
-       /* create an ASCONF_ACK chunk. 
+       /* create an ASCONF_ACK chunk.
         * Based on the definitions of parameters, we know that the size of
         * ASCONF_ACK parameters are less than or equal to the twice of ASCONF
         * paramters.
@@ -2538,7 +2537,7 @@ struct sctp_chunk *sctp_process_asconf(struct sctp_association *asoc,
                /* ADDIP 4.3 D11) When an endpoint receiving an ASCONF to add
                 * an IP address sends an 'Out of Resource' in its response, it
                 * MUST also fail any subsequent add or delete requests bundled
-                * in the ASCONF. 
+                * in the ASCONF.
                 */
                if (SCTP_ERROR_RSRC_LOW == err_code)
                        goto done;
@@ -2549,12 +2548,12 @@ struct sctp_chunk *sctp_process_asconf(struct sctp_association *asoc,
                                                      length);
                chunk_len -= length;
        }
-       
+
 done:
        asoc->peer.addip_serial++;
 
        /* If we are sending a new ASCONF_ACK hold a reference to it in assoc
-        * after freeing the reference to old asconf ack if any. 
+        * after freeing the reference to old asconf ack if any.
         */
        if (asconf_ack) {
                if (asoc->addip_last_asconf_ack)
@@ -2622,7 +2621,7 @@ static int sctp_asconf_param_success(struct sctp_association *asoc,
 
 /* Get the corresponding ASCONF response error code from the ASCONF_ACK chunk
  * for the given asconf parameter.  If there is no response for this parameter,
- * return the error code based on the third argument 'no_err'. 
+ * return the error code based on the third argument 'no_err'.
  * ADDIP 4.1
  * A7) If an error response is received for a TLV parameter, all TLVs with no
  * response before the failed TLV are considered successful if not reported.
@@ -2646,7 +2645,7 @@ static __be16 sctp_get_asconf_response(struct sctp_chunk *asconf_ack,
 
        /* Skip the addiphdr from the asconf_ack chunk and store a pointer to
         * the first asconf_ack parameter.
-        */ 
+        */
        length = sizeof(sctp_addiphdr_t);
        asconf_ack_param = (sctp_addip_param_t *)(asconf_ack->skb->data +
                                                  length);
@@ -2697,14 +2696,14 @@ int sctp_process_asconf_ack(struct sctp_association *asoc,
 
        /* Skip the chunkhdr and addiphdr from the last asconf sent and store
         * a pointer to address parameter.
-        */ 
+        */
        length = sizeof(sctp_addip_chunk_t);
        addr_param = (union sctp_addr_param *)(asconf->skb->data + length);
        asconf_len -= length;
 
        /* Skip the address parameter in the last asconf sent and store a
         * pointer to the first asconf paramter.
-        */ 
+        */
        length = ntohs(addr_param->v4.param_hdr.length);
        asconf_param = (sctp_addip_param_t *)((void *)addr_param + length);
        asconf_len -= length;
@@ -2741,7 +2740,7 @@ int sctp_process_asconf_ack(struct sctp_association *asoc,
                case SCTP_ERROR_INV_PARAM:
                        /* Disable sending this type of asconf parameter in
                         * future.
-                        */     
+                        */
                        asoc->peer.addip_disabled_mask |=
                                asconf_param->param_hdr.type;
                        break;
@@ -2755,7 +2754,7 @@ int sctp_process_asconf_ack(struct sctp_association *asoc,
 
                /* Skip the processed asconf parameter and move to the next
                 * one.
-                */ 
+                */
                length = ntohs(asconf_param->param_hdr.length);
                asconf_param = (sctp_addip_param_t *)((void *)asconf_param +
                                                      length);
@@ -2784,14 +2783,14 @@ int sctp_process_asconf_ack(struct sctp_association *asoc,
        return retval;
 }
 
-/* Make a FWD TSN chunk. */ 
+/* Make a FWD TSN chunk. */
 struct sctp_chunk *sctp_make_fwdtsn(const struct sctp_association *asoc,
                                    __u32 new_cum_tsn, size_t nstreams,
                                    struct sctp_fwdtsn_skip *skiplist)
 {
        struct sctp_chunk *retval = NULL;
        struct sctp_fwdtsn_chunk *ftsn_chunk;
-       struct sctp_fwdtsn_hdr ftsn_hdr; 
+       struct sctp_fwdtsn_hdr ftsn_hdr;
        struct sctp_fwdtsn_skip skip;
        size_t hint;
        int i;
index 6db77d1329f7fe6fd63a099a583b9d7dc8dad7dd..135567493119e24cee2e359ac8b8e2640f19f120 100644 (file)
@@ -61,7 +61,7 @@ static int sctp_cmd_interpreter(sctp_event_t event_type,
                                struct sctp_endpoint *ep,
                                struct sctp_association *asoc,
                                void *event_arg,
-                               sctp_disposition_t status,
+                               sctp_disposition_t status,
                                sctp_cmd_seq_t *commands,
                                gfp_t gfp);
 static int sctp_side_effects(sctp_event_t event_type, sctp_subtype_t subtype,
@@ -78,7 +78,7 @@ static int sctp_side_effects(sctp_event_t event_type, sctp_subtype_t subtype,
  ********************************************************************/
 
 /* A helper function for delayed processing of INET ECN CE bit. */
-static void sctp_do_ecn_ce_work(struct sctp_association *asoc, 
+static void sctp_do_ecn_ce_work(struct sctp_association *asoc,
                                __u32 lowest_tsn)
 {
        /* Save the TSN away for comparison when we receive CWR */
@@ -160,7 +160,7 @@ static int sctp_gen_sack(struct sctp_association *asoc, int force,
        struct sctp_transport *trans = asoc->peer.last_data_from;
        int error = 0;
 
-       if (force || 
+       if (force ||
            (!trans && (asoc->param_flags & SPP_SACKDELAY_DISABLE)) ||
            (trans && (trans->param_flags & SPP_SACKDELAY_DISABLE)))
                asoc->peer.sack_needed = 1;
@@ -178,7 +178,7 @@ static int sctp_gen_sack(struct sctp_association *asoc, int force,
         * [This is actually not mentioned in Section 6, but we
         * implement it here anyway. --piggy]
         */
-        if (max_tsn_seen != ctsn)
+       if (max_tsn_seen != ctsn)
                asoc->peer.sack_needed = 1;
 
        /* From 6.2  Acknowledgement on Reception of DATA Chunks:
@@ -199,10 +199,10 @@ static int sctp_gen_sack(struct sctp_association *asoc, int force,
                 * for the association.
                 */
                if (trans)
-                       asoc->timeouts[SCTP_EVENT_TIMEOUT_SACK] = 
+                       asoc->timeouts[SCTP_EVENT_TIMEOUT_SACK] =
                                trans->sackdelay;
                else
-                       asoc->timeouts[SCTP_EVENT_TIMEOUT_SACK] = 
+                       asoc->timeouts[SCTP_EVENT_TIMEOUT_SACK] =
                                asoc->sackdelay;
 
                /* Restart the SACK timer. */
@@ -338,8 +338,8 @@ static void sctp_generate_t4_rto_event(unsigned long data)
 
 static void sctp_generate_t5_shutdown_guard_event(unsigned long data)
 {
-        struct sctp_association *asoc = (struct sctp_association *)data;
-        sctp_generate_timeout_event(asoc,
+       struct sctp_association *asoc = (struct sctp_association *)data;
+       sctp_generate_timeout_event(asoc,
                                    SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD);
 
 } /* sctp_generate_t5_shutdown_guard_event() */
@@ -380,7 +380,7 @@ void sctp_generate_heartbeat_event(unsigned long data)
                           asoc->state, asoc->ep, asoc,
                           transport, GFP_ATOMIC);
 
-         if (error)
+        if (error)
                 asoc->base.sk->sk_err = -error;
 
 out_unlock:
@@ -570,7 +570,7 @@ static void sctp_cmd_hb_timers_stop(sctp_cmd_seq_t *cmds,
 
 /* Helper function to stop any pending T3-RTX timers */
 static void sctp_cmd_t3_rtx_timers_stop(sctp_cmd_seq_t *cmds,
-                                       struct sctp_association *asoc)
+                                       struct sctp_association *asoc)
 {
        struct sctp_transport *t;
        struct list_head *pos;
@@ -675,7 +675,7 @@ static int sctp_cmd_process_sack(sctp_cmd_seq_t *cmds,
 /* Helper function to set the timeout value for T2-SHUTDOWN timer and to set
  * the transport for a shutdown chunk.
  */
-static void sctp_cmd_setup_t2(sctp_cmd_seq_t *cmds, 
+static void sctp_cmd_setup_t2(sctp_cmd_seq_t *cmds,
                              struct sctp_association *asoc,
                              struct sctp_chunk *chunk)
 {
@@ -688,7 +688,7 @@ static void sctp_cmd_setup_t2(sctp_cmd_seq_t *cmds,
 }
 
 /* Helper function to change the state of an association. */
-static void sctp_cmd_new_state(sctp_cmd_seq_t *cmds, 
+static void sctp_cmd_new_state(sctp_cmd_seq_t *cmds,
                               struct sctp_association *asoc,
                               sctp_state_t state)
 {
@@ -727,7 +727,7 @@ static void sctp_cmd_new_state(sctp_cmd_seq_t *cmds,
            sctp_state(asoc, SHUTDOWN_RECEIVED)) {
                /* Wake up any processes waiting in the asoc's wait queue in
                 * sctp_wait_for_connect() or sctp_wait_for_sndbuf().
-                */
+                */
                if (waitqueue_active(&asoc->wait))
                        wake_up_interruptible(&asoc->wait);
 
@@ -749,9 +749,9 @@ static void sctp_cmd_delete_tcb(sctp_cmd_seq_t *cmds,
        struct sock *sk = asoc->base.sk;
 
        /* If it is a non-temporary association belonging to a TCP-style
-        * listening socket that is not closed, do not free it so that accept() 
+        * listening socket that is not closed, do not free it so that accept()
         * can pick it up later.
-        */ 
+        */
        if (sctp_style(sk, TCP) && sctp_sstate(sk, LISTENING) &&
            (!asoc->temp) && (sk->sk_shutdown != SHUTDOWN_MASK))
                return;
@@ -764,7 +764,7 @@ static void sctp_cmd_delete_tcb(sctp_cmd_seq_t *cmds,
  * ADDIP Section 4.1 ASCONF Chunk Procedures
  * A4) Start a T-4 RTO timer, using the RTO value of the selected
  * destination address (we use active path instead of primary path just
- * because primary path may be inactive. 
+ * because primary path may be inactive.
  */
 static void sctp_cmd_setup_t4(sctp_cmd_seq_t *cmds,
                                struct sctp_association *asoc,
@@ -777,7 +777,7 @@ static void sctp_cmd_setup_t4(sctp_cmd_seq_t *cmds,
        chunk->transport = t;
 }
 
-/* Process an incoming Operation Error Chunk. */ 
+/* Process an incoming Operation Error Chunk. */
 static void sctp_cmd_process_operr(sctp_cmd_seq_t *cmds,
                                   struct sctp_association *asoc,
                                   struct sctp_chunk *chunk)
@@ -816,7 +816,7 @@ static void sctp_cmd_process_operr(sctp_cmd_seq_t *cmds,
 }
 
 /* Process variable FWDTSN chunk information. */
-static void sctp_cmd_process_fwdtsn(struct sctp_ulpq *ulpq, 
+static void sctp_cmd_process_fwdtsn(struct sctp_ulpq *ulpq,
                                    struct sctp_chunk *chunk)
 {
        struct sctp_fwdtsn_skip *skip;
@@ -828,9 +828,9 @@ static void sctp_cmd_process_fwdtsn(struct sctp_ulpq *ulpq,
        return;
 }
 
-/* Helper function to remove the association non-primary peer 
+/* Helper function to remove the association non-primary peer
  * transports.
- */ 
+ */
 static void sctp_cmd_del_non_primary(struct sctp_association *asoc)
 {
        struct sctp_transport *t;
@@ -840,7 +840,7 @@ static void sctp_cmd_del_non_primary(struct sctp_association *asoc)
        list_for_each_safe(pos, temp, &asoc->peer.transport_addr_list) {
                t = list_entry(pos, struct sctp_transport, transports);
                if (!sctp_cmp_addr_exact(&t->ipaddr,
-                                        &asoc->peer.primary_addr)) {
+                                        &asoc->peer.primary_addr)) {
                        sctp_assoc_del_peer(asoc, &t->ipaddr);
                }
        }
@@ -915,7 +915,7 @@ int sctp_do_sm(sctp_event_t event_type, sctp_subtype_t subtype,
        DEBUG_POST;
 
        error = sctp_side_effects(event_type, subtype, state,
-                                 ep, asoc, event_arg, status, 
+                                 ep, asoc, event_arg, status,
                                  &commands, gfp);
        DEBUG_POST_SFX;
 
@@ -968,7 +968,7 @@ static int sctp_side_effects(sctp_event_t event_type, sctp_subtype_t subtype,
                error = -ENOMEM;
                break;
 
-        case SCTP_DISPOSITION_DELETE_TCB:
+       case SCTP_DISPOSITION_DELETE_TCB:
                /* This should now be a command. */
                break;
 
@@ -1021,7 +1021,7 @@ static int sctp_cmd_interpreter(sctp_event_t event_type,
                                struct sctp_endpoint *ep,
                                struct sctp_association *asoc,
                                void *event_arg,
-                               sctp_disposition_t status,
+                               sctp_disposition_t status,
                                sctp_cmd_seq_t *commands,
                                gfp_t gfp)
 {
@@ -1057,7 +1057,7 @@ static int sctp_cmd_interpreter(sctp_event_t event_type,
                case SCTP_CMD_NEW_ASOC:
                        /* Register a new association.  */
                        if (local_cork) {
-                               sctp_outq_uncork(&asoc->outqueue); 
+                               sctp_outq_uncork(&asoc->outqueue);
                                local_cork = 0;
                        }
                        asoc = cmd->obj.ptr;
@@ -1074,7 +1074,7 @@ static int sctp_cmd_interpreter(sctp_event_t event_type,
                       sctp_outq_teardown(&asoc->outqueue);
                       break;
 
-               case SCTP_CMD_DELETE_TCB:                       
+               case SCTP_CMD_DELETE_TCB:
                        if (local_cork) {
                                sctp_outq_uncork(&asoc->outqueue);
                                local_cork = 0;
@@ -1104,7 +1104,7 @@ static int sctp_cmd_interpreter(sctp_event_t event_type,
 
                case SCTP_CMD_PROCESS_FWDTSN:
                        sctp_cmd_process_fwdtsn(&asoc->ulpq, cmd->obj.ptr);
-                        break;
+                       break;
 
                case SCTP_CMD_GEN_SACK:
                        /* Generate a Selective ACK.
@@ -1162,12 +1162,12 @@ static int sctp_cmd_interpreter(sctp_event_t event_type,
                                                SCTP_CHUNK(cmd->obj.ptr));
 
                        /* FIXME - Eventually come up with a cleaner way to
-                        * enabling COOKIE-ECHO + DATA bundling during 
-                        * multihoming stale cookie scenarios, the following 
-                        * command plays with asoc->peer.retran_path to 
-                        * avoid the problem of sending the COOKIE-ECHO and 
-                        * DATA in different paths, which could result 
-                        * in the association being ABORTed if the DATA chunk 
+                        * enabling COOKIE-ECHO + DATA bundling during
+                        * multihoming stale cookie scenarios, the following
+                        * command plays with asoc->peer.retran_path to
+                        * avoid the problem of sending the COOKIE-ECHO and
+                        * DATA in different paths, which could result
+                        * in the association being ABORTed if the DATA chunk
                         * is processed first by the server.  Checking the
                         * init error counter simply causes this command
                         * to be executed only during failed attempts of
@@ -1177,7 +1177,7 @@ static int sctp_cmd_interpreter(sctp_event_t event_type,
                             asoc->peer.primary_path) &&
                            (asoc->init_err_counter > 0)) {
                                sctp_add_cmd_sf(commands,
-                                               SCTP_CMD_FORCE_PRIM_RETRAN,
+                                               SCTP_CMD_FORCE_PRIM_RETRAN,
                                                SCTP_NULL());
                        }
 
index fbbc9e6a3b787bc8209a3c036bb3be7995813068..b3cad8a03736c1a05b34fe6c9264a3b192eb6e19 100644 (file)
@@ -189,7 +189,7 @@ sctp_disposition_t sctp_sf_do_4_C(const struct sctp_endpoint *ep,
                                             0, 0, 0, GFP_ATOMIC);
        if (ev)
                sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP,
-                               SCTP_ULPEVENT(ev));
+                               SCTP_ULPEVENT(ev));
 
        /* Upon reception of the SHUTDOWN COMPLETE chunk the endpoint
         * will verify that it is in SHUTDOWN-ACK-SENT state, if it is
@@ -228,7 +228,7 @@ sctp_disposition_t sctp_sf_do_4_C(const struct sctp_endpoint *ep,
  *    Verification Tag field to Tag_A, and also provide its own
  *    Verification Tag (Tag_Z) in the Initiate Tag field.
  *
- * Verification Tag: Must be 0. 
+ * Verification Tag: Must be 0.
  *
  * Inputs
  * (endpoint, asoc, chunk)
@@ -256,7 +256,7 @@ sctp_disposition_t sctp_sf_do_5_1B_init(const struct sctp_endpoint *ep,
        /* 6.10 Bundling
         * An endpoint MUST NOT bundle INIT, INIT ACK or
         * SHUTDOWN COMPLETE with any other chunks.
-        * 
+        *
         * IG Section 2.11.2
         * Furthermore, we require that the receiver of an INIT chunk MUST
         * enforce these rules by silently discarding an arriving packet
@@ -282,7 +282,7 @@ sctp_disposition_t sctp_sf_do_5_1B_init(const struct sctp_endpoint *ep,
                return sctp_sf_tabort_8_4_8(ep, asoc, type, arg, commands);
 
        /* 3.1 A packet containing an INIT chunk MUST have a zero Verification
-        * Tag. 
+        * Tag.
         */
        if (chunk->sctp_hdr->vtag != 0)
                return sctp_sf_tabort_8_4_8(ep, asoc, type, arg, commands);
@@ -326,7 +326,7 @@ sctp_disposition_t sctp_sf_do_5_1B_init(const struct sctp_endpoint *ep,
                }
        }
 
-        /* Grab the INIT header.  */
+       /* Grab the INIT header.  */
        chunk->subh.init_hdr = (sctp_inithdr_t *)chunk->skb->data;
 
        /* Tag the variable length parameters.  */
@@ -594,7 +594,7 @@ sctp_disposition_t sctp_sf_do_5_1D_ce(const struct sctp_endpoint *ep,
        /* "Decode" the chunk.  We have no optional parameters so we
         * are in good shape.
         */
-        chunk->subh.cookie_hdr =
+       chunk->subh.cookie_hdr =
                (struct sctp_signed_cookie *)chunk->skb->data;
        if (!pskb_pull(chunk->skb, ntohs(chunk->chunk_hdr->length) -
                                         sizeof(sctp_chunkhdr_t)))
@@ -665,7 +665,7 @@ sctp_disposition_t sctp_sf_do_5_1D_ce(const struct sctp_endpoint *ep,
        if (!ev)
                goto nomem_ev;
 
-       /* Sockets API Draft Section 5.3.1.6    
+       /* Sockets API Draft Section 5.3.1.6
         * When a peer sends a Adaptation Layer Indication parameter , SCTP
         * delivers this notification to inform the application that of the
         * peers requested adaptation layer.
@@ -891,7 +891,7 @@ sctp_disposition_t sctp_sf_sendbeat_8_3(const struct sctp_endpoint *ep,
        sctp_add_cmd_sf(commands, SCTP_CMD_HB_TIMER_UPDATE,
                        SCTP_TRANSPORT(transport));
 
-        return SCTP_DISPOSITION_CONSUME;
+       return SCTP_DISPOSITION_CONSUME;
 }
 
 /*
@@ -1280,7 +1280,7 @@ static sctp_disposition_t sctp_sf_do_unexpected_init(
                return sctp_sf_pdiscard(ep, asoc, type, arg, commands);
 
        /* 3.1 A packet containing an INIT chunk MUST have a zero Verification
-        * Tag. 
+        * Tag.
         */
        if (chunk->sctp_hdr->vtag != 0)
                return sctp_sf_tabort_8_4_8(ep, asoc, type, arg, commands);
@@ -1548,7 +1548,7 @@ sctp_disposition_t sctp_sf_do_5_2_3_initack(const struct sctp_endpoint *ep,
        /* Per the above section, we'll discard the chunk if we have an
         * endpoint.  If this is an OOTB INIT-ACK, treat it as such.
         */
-        if (ep == sctp_sk((sctp_get_ctl_sock()))->ep)
+       if (ep == sctp_sk((sctp_get_ctl_sock()))->ep)
                return sctp_sf_ootb(ep, asoc, type, arg, commands);
        else
                return sctp_sf_discard_chunk(ep, asoc, type, arg, commands);
@@ -1760,9 +1760,9 @@ static sctp_disposition_t sctp_sf_do_dupcook_d(const struct sctp_endpoint *ep,
 
        /* Clarification from Implementor's Guide:
         * D) When both local and remote tags match the endpoint should
-         * enter the ESTABLISHED state, if it is in the COOKIE-ECHOED state.
-         * It should stop any cookie timer that may be running and send
-         * a COOKIE ACK.
+        * enter the ESTABLISHED state, if it is in the COOKIE-ECHOED state.
+        * It should stop any cookie timer that may be running and send
+        * a COOKIE ACK.
         */
 
        /* Don't accidentally move back into established state. */
@@ -1786,7 +1786,7 @@ static sctp_disposition_t sctp_sf_do_dupcook_d(const struct sctp_endpoint *ep,
                                             SCTP_COMM_UP, 0,
                                             asoc->c.sinit_num_ostreams,
                                             asoc->c.sinit_max_instreams,
-                                             GFP_ATOMIC);
+                                            GFP_ATOMIC);
                if (!ev)
                        goto nomem;
 
@@ -1870,7 +1870,7 @@ sctp_disposition_t sctp_sf_do_5_2_4_dupcook(const struct sctp_endpoint *ep,
        /* "Decode" the chunk.  We have no optional parameters so we
         * are in good shape.
         */
-        chunk->subh.cookie_hdr = (struct sctp_signed_cookie *)chunk->skb->data;
+       chunk->subh.cookie_hdr = (struct sctp_signed_cookie *)chunk->skb->data;
        if (!pskb_pull(chunk->skb, ntohs(chunk->chunk_hdr->length) -
                                        sizeof(sctp_chunkhdr_t)))
                goto nomem;
@@ -1936,7 +1936,7 @@ sctp_disposition_t sctp_sf_do_5_2_4_dupcook(const struct sctp_endpoint *ep,
        default: /* Discard packet for all others. */
                retval = sctp_sf_pdiscard(ep, asoc, type, arg, commands);
                break;
-        };
+       };
 
        /* Delete the tempory new association. */
        sctp_add_cmd_sf(commands, SCTP_CMD_NEW_ASOC, SCTP_ASOC(new_asoc));
@@ -2083,7 +2083,7 @@ sctp_disposition_t sctp_sf_cookie_echoed_err(const struct sctp_endpoint *ep,
         */
        sctp_walk_errors(err, chunk->chunk_hdr) {
                if (SCTP_ERROR_STALE_COOKIE == err->cause)
-                       return sctp_sf_do_5_2_6_stale(ep, asoc, type, 
+                       return sctp_sf_do_5_2_6_stale(ep, asoc, type,
                                                        arg, commands);
        }
 
@@ -2185,10 +2185,10 @@ static sctp_disposition_t sctp_sf_do_5_2_6_stale(const struct sctp_endpoint *ep,
         */
        sctp_add_cmd_sf(commands, SCTP_CMD_DEL_NON_PRIMARY, SCTP_NULL());
 
-       /* If we've sent any data bundled with COOKIE-ECHO we will need to 
-        * resend 
+       /* If we've sent any data bundled with COOKIE-ECHO we will need to
+        * resend
         */
-       sctp_add_cmd_sf(commands, SCTP_CMD_RETRAN, 
+       sctp_add_cmd_sf(commands, SCTP_CMD_RETRAN,
                        SCTP_TRANSPORT(asoc->peer.primary_path));
 
        /* Cast away the const modifier, as we want to just
@@ -2274,7 +2274,7 @@ sctp_disposition_t sctp_sf_do_9_1_abort(const struct sctp_endpoint *ep,
                error = ((sctp_errhdr_t *)chunk->skb->data)->cause;
 
        sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR, SCTP_ERROR(ECONNRESET));
-       /* ASSOC_FAILED will DELETE_TCB. */
+       /* ASSOC_FAILED will DELETE_TCB. */
        sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, SCTP_PERR(error));
        SCTP_INC_STATS(SCTP_MIB_ABORTEDS);
        SCTP_DEC_STATS(SCTP_MIB_CURRESTAB);
@@ -2439,7 +2439,7 @@ sctp_disposition_t sctp_sf_do_9_2_shutdown(const struct sctp_endpoint *ep,
        ev = sctp_ulpevent_make_shutdown_event(asoc, 0, GFP_ATOMIC);
        if (!ev) {
                disposition = SCTP_DISPOSITION_NOMEM;
-               goto out;       
+               goto out;
        }
        sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP, SCTP_ULPEVENT(ev));
 
@@ -2553,7 +2553,7 @@ sctp_disposition_t sctp_sf_do_ecn_cwr(const struct sctp_endpoint *ep,
        if (!sctp_chunk_length_valid(chunk, sizeof(sctp_ecne_chunk_t)))
                return sctp_sf_violation_chunklen(ep, asoc, type, arg,
                                                  commands);
-               
+
        cwr = (sctp_cwrhdr_t *) chunk->skb->data;
        skb_pull(chunk->skb, sizeof(sctp_cwrhdr_t));
 
@@ -2661,7 +2661,7 @@ sctp_disposition_t sctp_sf_eat_data_6_2(const struct sctp_endpoint *ep,
                sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_BAD_TAG,
                                SCTP_NULL());
                return sctp_sf_pdiscard(ep, asoc, type, arg, commands);
-        }
+       }
 
        if (!sctp_chunk_length_valid(chunk, sizeof(sctp_data_chunk_t)))
                return sctp_sf_violation_chunklen(ep, asoc, type, arg,
@@ -2743,7 +2743,7 @@ discard_noforce:
        return SCTP_DISPOSITION_DISCARD;
 consume:
        return SCTP_DISPOSITION_CONSUME;
-       
+
 }
 
 /*
@@ -2930,7 +2930,7 @@ sctp_disposition_t sctp_sf_tabort_8_4_8(const struct sctp_endpoint *ep,
                /* Make an ABORT. The T bit will be set if the asoc
                 * is NULL.
                 */
-               abort = sctp_make_abort(asoc, chunk, 0);
+               abort = sctp_make_abort(asoc, chunk, 0);
                if (!abort) {
                        sctp_ootb_pkt_free(packet);
                        return SCTP_DISPOSITION_NOMEM;
@@ -2994,7 +2994,7 @@ sctp_disposition_t sctp_sf_operr_notify(const struct sctp_endpoint *ep,
                }
 
                sctp_add_cmd_sf(commands, SCTP_CMD_PROCESS_OPERR,
-                               SCTP_CHUNK(chunk));     
+                               SCTP_CHUNK(chunk));
        }
        return SCTP_DISPOSITION_CONSUME;
 
@@ -3128,7 +3128,7 @@ sctp_disposition_t sctp_sf_ootb(const struct sctp_endpoint *ep,
                 */
                if (SCTP_CID_ABORT == ch->type)
                        return sctp_sf_pdiscard(ep, asoc, type, arg, commands);
-                       
+
                ch = (sctp_chunkhdr_t *) ch_end;
        } while (ch_end < skb->tail);
 
@@ -3175,8 +3175,8 @@ static sctp_disposition_t sctp_sf_shut_8_4_5(const struct sctp_endpoint *ep,
 
        if (packet) {
                /* Make an SHUTDOWN_COMPLETE.
-                * The T bit will be set if the asoc is NULL.
-                */
+                * The T bit will be set if the asoc is NULL.
+                */
                shut = sctp_make_shutdown_complete(asoc, chunk);
                if (!shut) {
                        sctp_ootb_pkt_free(packet);
@@ -3261,10 +3261,10 @@ sctp_disposition_t sctp_sf_do_asconf(const struct sctp_endpoint *ep,
 
        /* ADDIP 4.2 C1) Compare the value of the serial number to the value
         * the endpoint stored in a new association variable
-        * 'Peer-Serial-Number'. 
+        * 'Peer-Serial-Number'.
         */
        if (serial == asoc->peer.addip_serial + 1) {
-               /* ADDIP 4.2 C2) If the value found in the serial number is
+               /* ADDIP 4.2 C2) If the value found in the serial number is
                 * equal to the ('Peer-Serial-Number' + 1), the endpoint MUST
                 * do V1-V5.
                 */
@@ -3285,9 +3285,9 @@ sctp_disposition_t sctp_sf_do_asconf(const struct sctp_endpoint *ep,
                else
                        return SCTP_DISPOSITION_DISCARD;
        } else {
-               /* ADDIP 4.2 C4) Otherwise, the ASCONF Chunk is discarded since 
+               /* ADDIP 4.2 C4) Otherwise, the ASCONF Chunk is discarded since
                 * it must be either a stale packet or from an attacker.
-                */     
+                */
                return SCTP_DISPOSITION_DISCARD;
        }
 
@@ -3296,7 +3296,7 @@ sctp_disposition_t sctp_sf_do_asconf(const struct sctp_endpoint *ep,
         * being responded to.
         */
        sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(asconf_ack));
-       
+
        return SCTP_DISPOSITION_CONSUME;
 }
 
@@ -3307,7 +3307,7 @@ sctp_disposition_t sctp_sf_do_asconf(const struct sctp_endpoint *ep,
  */
 sctp_disposition_t sctp_sf_do_asconf_ack(const struct sctp_endpoint *ep,
                                         const struct sctp_association *asoc,
-                                        const sctp_subtype_t type, void *arg,
+                                        const sctp_subtype_t type, void *arg,
                                         sctp_cmd_seq_t *commands)
 {
        struct sctp_chunk       *asconf_ack = arg;
@@ -3359,7 +3359,7 @@ sctp_disposition_t sctp_sf_do_asconf_ack(const struct sctp_endpoint *ep,
                                SCTP_TO(SCTP_EVENT_TIMEOUT_T4_RTO));
                sctp_add_cmd_sf(commands, SCTP_CMD_DISCARD_PACKET,SCTP_NULL());
                sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR,
-                               SCTP_ERROR(ECONNABORTED));
+                               SCTP_ERROR(ECONNABORTED));
                sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED,
                                SCTP_PERR(SCTP_ERROR_ASCONF_ACK));
                SCTP_INC_STATS(SCTP_MIB_ABORTEDS);
@@ -3387,7 +3387,7 @@ sctp_disposition_t sctp_sf_do_asconf_ack(const struct sctp_endpoint *ep,
                 */
                sctp_add_cmd_sf(commands, SCTP_CMD_DISCARD_PACKET,SCTP_NULL());
                sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR,
-                               SCTP_ERROR(ECONNABORTED));
+                               SCTP_ERROR(ECONNABORTED));
                sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED,
                                SCTP_PERR(SCTP_ERROR_ASCONF_ACK));
                SCTP_INC_STATS(SCTP_MIB_ABORTEDS);
@@ -3451,17 +3451,17 @@ sctp_disposition_t sctp_sf_eat_fwd_tsn(const struct sctp_endpoint *ep,
 
        sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_FWDTSN, SCTP_U32(tsn));
        if (len > sizeof(struct sctp_fwdtsn_hdr))
-               sctp_add_cmd_sf(commands, SCTP_CMD_PROCESS_FWDTSN, 
+               sctp_add_cmd_sf(commands, SCTP_CMD_PROCESS_FWDTSN,
                                SCTP_CHUNK(chunk));
-       
+
        /* Count this as receiving DATA. */
        if (asoc->autoclose) {
                sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_RESTART,
                                SCTP_TO(SCTP_EVENT_TIMEOUT_AUTOCLOSE));
        }
-       
+
        /* FIXME: For now send a SACK, but DATA processing may
-        * send another. 
+        * send another.
         */
        sctp_add_cmd_sf(commands, SCTP_CMD_GEN_SACK, SCTP_NOFORCE());
 
@@ -3511,9 +3511,9 @@ sctp_disposition_t sctp_sf_eat_fwd_tsn_fast(
 
        sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_FWDTSN, SCTP_U32(tsn));
        if (len > sizeof(struct sctp_fwdtsn_hdr))
-               sctp_add_cmd_sf(commands, SCTP_CMD_PROCESS_FWDTSN, 
+               sctp_add_cmd_sf(commands, SCTP_CMD_PROCESS_FWDTSN,
                                SCTP_CHUNK(chunk));
-       
+
        /* Go a head and force a SACK, since we are shutting down. */
 gen_shutdown:
        /* Implementor's Guide.
@@ -3527,7 +3527,7 @@ gen_shutdown:
        sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_RESTART,
                        SCTP_TO(SCTP_EVENT_TIMEOUT_T2_SHUTDOWN));
 
-        return SCTP_DISPOSITION_CONSUME;
+       return SCTP_DISPOSITION_CONSUME;
 }
 
 /*
@@ -3706,7 +3706,7 @@ sctp_disposition_t sctp_sf_violation(const struct sctp_endpoint *ep,
  * if it's length is set to be smaller then the size of sctp_sack_chunk_t.
  *
  * We inform the other end by sending an ABORT with a Protocol Violation
- * error code. 
+ * error code.
  *
  * Section: Not specified
  * Verification Tag:  Nothing to do
@@ -3747,7 +3747,7 @@ static sctp_disposition_t sctp_sf_violation_chunklen(
                                SCTP_PERR(SCTP_ERROR_PROTO_VIOLATION));
        } else {
                sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR,
-                               SCTP_ERROR(ECONNABORTED));
+                               SCTP_ERROR(ECONNABORTED));
                sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED,
                                SCTP_PERR(SCTP_ERROR_PROTO_VIOLATION));
                SCTP_DEC_STATS(SCTP_MIB_CURRESTAB);
@@ -3756,7 +3756,7 @@ static sctp_disposition_t sctp_sf_violation_chunklen(
        sctp_add_cmd_sf(commands, SCTP_CMD_DISCARD_PACKET, SCTP_NULL());
 
        SCTP_INC_STATS(SCTP_MIB_ABORTEDS);
-       
+
        return SCTP_DISPOSITION_ABORT;
 
 nomem:
@@ -4437,7 +4437,7 @@ sctp_disposition_t sctp_sf_do_9_2_start_shutdown(
        /* sctp-implguide 2.10 Issues with Heartbeating and failover
         *
         * HEARTBEAT ... is discontinued after sending either SHUTDOWN
-         * or SHUTDOWN-ACK.
+        * or SHUTDOWN-ACK.
         */
        sctp_add_cmd_sf(commands, SCTP_CMD_HB_TIMERS_STOP, SCTP_NULL());
 
@@ -4515,7 +4515,7 @@ sctp_disposition_t sctp_sf_do_9_2_shutdown_ack(
        /* sctp-implguide 2.10 Issues with Heartbeating and failover
         *
         * HEARTBEAT ... is discontinued after sending either SHUTDOWN
-         * or SHUTDOWN-ACK.
+        * or SHUTDOWN-ACK.
         */
        sctp_add_cmd_sf(commands, SCTP_CMD_HB_TIMERS_STOP, SCTP_NULL());
 
@@ -4874,7 +4874,7 @@ sctp_disposition_t sctp_sf_t4_timer_expire(
        /* ADDIP 4.1 B4) Re-transmit the ASCONF Chunk last sent and if possible
         * choose an alternate destination address (please refer to RFC2960
         * [5] section 6.4.1). An endpoint MUST NOT add new parameters to this
-        * chunk, it MUST be the same (including its serial number) as the last 
+        * chunk, it MUST be the same (including its serial number) as the last
         * ASCONF sent.
         */
        sctp_chunk_hold(asoc->addip_last_asconf);
@@ -4953,7 +4953,7 @@ sctp_disposition_t sctp_sf_autoclose_timer_expire(
        /* sctpimpguide-05 Section 2.12.2
         * The sender of the SHUTDOWN MAY also start an overall guard timer
         * 'T5-shutdown-guard' to bound the overall time for shutdown sequence.
-        */
+        */
        sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_START,
                        SCTP_TO(SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD));
        disposition = SCTP_DISPOSITION_CONSUME;
@@ -5127,7 +5127,7 @@ static struct sctp_packet *sctp_ootb_pkt_new(const struct sctp_association *asoc
                        vtag = ntohl(init->init_hdr.init_tag);
                        break;
                }
-               default:        
+               default:
                        vtag = ntohl(chunk->sctp_hdr->vtag);
                        break;
                }
@@ -5176,7 +5176,7 @@ static void sctp_send_stale_cookie_err(const struct sctp_endpoint *ep,
                        /* Override the OOTB vtag from the cookie. */
                        cookie = chunk->subh.cookie_hdr;
                        packet->vtag = cookie->c.peer_vtag;
-                       
+
                        /* Set the skb to the belonging sock for accounting. */
                        err_chunk->skb->sk = ep->base.sk;
                        sctp_packet_append_chunk(packet, err_chunk);
@@ -5310,7 +5310,7 @@ static int sctp_eat_data(const struct sctp_association *asoc,
                sctp_add_cmd_sf(commands, SCTP_CMD_PART_DELIVER, SCTP_NULL());
        }
 
-        /* Spill over rwnd a little bit.  Note: While allowed, this spill over
+       /* Spill over rwnd a little bit.  Note: While allowed, this spill over
         * seems a bit troublesome in that frag_point varies based on
         * PMTU.  In cases, such as loopback, this might be a rather
         * large spill over.
index 5f6cc7aa661bd0371d1394d23610c6be780a6644..5e54b17377f40a0b3eb5a711031ae07d32bc16bd 100644 (file)
@@ -954,7 +954,7 @@ static const sctp_sm_table_entry_t timeout_event_table[SCTP_NUM_TIMEOUT_TYPES][S
        TYPE_SCTP_EVENT_TIMEOUT_AUTOCLOSE,
 };
 
-static const sctp_sm_table_entry_t *sctp_chunk_event_lookup(sctp_cid_t cid, 
+static const sctp_sm_table_entry_t *sctp_chunk_event_lookup(sctp_cid_t cid,
                                                            sctp_state_t state)
 {
        if (state > SCTP_STATE_MAX)
index 388d0fb1a3776a7e8a487ab3656df4b17166f2fa..536298c2eda26034d3f0afab142ad95cbcee2e7d 100644 (file)
@@ -381,12 +381,12 @@ SCTP_STATIC int sctp_do_bind(struct sock *sk, union sctp_addr *addr, int len)
 
  /* ADDIP Section 4.1.1 Congestion Control of ASCONF Chunks
  *
- * R1) One and only one ASCONF Chunk MAY be in transit and unacknowledged 
+ * R1) One and only one ASCONF Chunk MAY be in transit and unacknowledged
  * at any one time.  If a sender, after sending an ASCONF chunk, decides
- * it needs to transfer another ASCONF Chunk, it MUST wait until the 
+ * it needs to transfer another ASCONF Chunk, it MUST wait until the
  * ASCONF-ACK Chunk returns from the previous ASCONF Chunk before sending a
- * subsequent ASCONF. Note this restriction binds each side, so at any 
- * time two ASCONF may be in-transit on any given association (one sent 
+ * subsequent ASCONF. Note this restriction binds each side, so at any
+ * time two ASCONF may be in-transit on any given association (one sent
  * from each endpoint).
  */
 static int sctp_send_asconf(struct sctp_association *asoc,
@@ -396,10 +396,10 @@ static int sctp_send_asconf(struct sctp_association *asoc,
 
        /* If there is an outstanding ASCONF chunk, queue it for later
         * transmission.
-        */     
+        */
        if (asoc->addip_last_asconf) {
                list_add_tail(&chunk->list, &asoc->addip_chunk_list);
-               goto out;       
+               goto out;
        }
 
        /* Hold the chunk until an ASCONF_ACK is received. */
@@ -449,7 +449,7 @@ int sctp_bindx_add(struct sock *sk, struct sockaddr *addrs, int addrcnt)
                        goto err_bindx_add;
                }
 
-               retval = sctp_do_bind(sk, (union sctp_addr *)sa_addr, 
+               retval = sctp_do_bind(sk, (union sctp_addr *)sa_addr,
                                      af->sockaddr_len);
 
                addr_buf += af->sockaddr_len;
@@ -470,13 +470,13 @@ err_bindx_add:
  * associations that are part of the endpoint indicating that a list of local
  * addresses are added to the endpoint.
  *
- * If any of the addresses is already in the bind address list of the 
+ * If any of the addresses is already in the bind address list of the
  * association, we do not send the chunk for that association.  But it will not
  * affect other associations.
  *
  * Only sctp_setsockopt_bindx() is supposed to call this function.
  */
-static int sctp_send_asconf_add_ip(struct sock         *sk, 
+static int sctp_send_asconf_add_ip(struct sock         *sk,
                                   struct sockaddr      *addrs,
                                   int                  addrcnt)
 {
@@ -517,8 +517,8 @@ static int sctp_send_asconf_add_ip(struct sock              *sk,
                        continue;
 
                /* Check if any address in the packed array of addresses is
-                * in the bind address list of the association. If so, 
-                * do not send the asconf chunk to its peer, but continue with 
+                * in the bind address list of the association. If so,
+                * do not send the asconf chunk to its peer, but continue with
                 * other associations.
                 */
                addr_buf = addrs;
@@ -664,7 +664,7 @@ err_bindx_rem:
  * the associations that are part of the endpoint indicating that a list of
  * local addresses are removed from the endpoint.
  *
- * If any of the addresses is already in the bind address list of the 
+ * If any of the addresses is already in the bind address list of the
  * association, we do not send the chunk for that association.  But it will not
  * affect other associations.
  *
@@ -710,7 +710,7 @@ static int sctp_send_asconf_del_ip(struct sock              *sk,
                        continue;
 
                /* Check if any address in the packed array of addresses is
-                * not present in the bind address list of the association.
+                * not present in the bind address list of the association.
                 * If so, do not send the asconf chunk to its peer, but
                 * continue with other associations.
                 */
@@ -898,7 +898,7 @@ SCTP_STATIC int sctp_setsockopt_bindx(struct sock* sk,
                return -EFAULT;
        }
 
-       /* Walk through the addrs buffer and count the number of addresses. */ 
+       /* Walk through the addrs buffer and count the number of addresses. */
        addr_buf = kaddrs;
        while (walk_size < addrs_size) {
                sa_addr = (struct sockaddr *)addr_buf;
@@ -906,7 +906,7 @@ SCTP_STATIC int sctp_setsockopt_bindx(struct sock* sk,
 
                /* If the address family is not supported or if this address
                 * causes the address buffer to overflow return EINVAL.
-                */ 
+                */
                if (!af || (walk_size + af->sockaddr_len) > addrs_size) {
                        kfree(kaddrs);
                        return -EINVAL;
@@ -935,7 +935,7 @@ SCTP_STATIC int sctp_setsockopt_bindx(struct sock* sk,
        default:
                err = -EINVAL;
                break;
-        };
+       };
 
 out:
        kfree(kaddrs);
@@ -1035,10 +1035,10 @@ static int __sctp_connect(struct sock* sk,
                                }
                        } else {
                                /*
-                                * If an unprivileged user inherits a 1-many 
-                                * style socket with open associations on a 
-                                * privileged port, it MAY be permitted to 
-                                * accept new associations, but it SHOULD NOT 
+                                * If an unprivileged user inherits a 1-many
+                                * style socket with open associations on a
+                                * privileged port, it MAY be permitted to
+                                * accept new associations, but it SHOULD NOT
                                 * be permitted to open new associations.
                                 */
                                if (ep->base.bind_addr.port < PROT_SOCK &&
@@ -1094,8 +1094,8 @@ static int __sctp_connect(struct sock* sk,
 out_free:
 
        SCTP_DEBUG_PRINTK("About to exit __sctp_connect() free asoc: %p"
-                         " kaddrs: %p err: %d\n",
-                         asoc, kaddrs, err);
+                         " kaddrs: %p err: %d\n",
+                         asoc, kaddrs, err);
        if (asoc)
                sctp_association_free(asoc);
        return err;
@@ -1435,7 +1435,7 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk,
         * length messages when SCTP_EOF|SCTP_ABORT is not set.
         * If SCTP_ABORT is set, the message length could be non zero with
         * the msg_iov set to the user abort reason.
-        */
+        */
        if (((sinfo_flags & SCTP_EOF) && (msg_len > 0)) ||
            (!(sinfo_flags & (SCTP_EOF|SCTP_ABORT)) && (msg_len == 0))) {
                err = -EINVAL;
@@ -1599,7 +1599,7 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk,
                                        = sinit->sinit_max_attempts;
                        }
                        if (sinit->sinit_max_init_timeo) {
-                               asoc->max_init_timeo = 
+                               asoc->max_init_timeo =
                                 msecs_to_jiffies(sinit->sinit_max_init_timeo);
                        }
                }
@@ -2298,7 +2298,7 @@ static int sctp_setsockopt_delayed_ack_time(struct sock *sk,
        /* Get association, if assoc_id != 0 and the socket is a one
         * to many style socket, and an association was not found, then
         * the id was invalid.
-        */
+        */
        asoc = sctp_id2assoc(sk, params.assoc_id);
        if (!asoc && params.assoc_id && sctp_style(sk, UDP))
                return -EINVAL;
@@ -2307,22 +2307,22 @@ static int sctp_setsockopt_delayed_ack_time(struct sock *sk,
                if (asoc) {
                        asoc->sackdelay =
                                msecs_to_jiffies(params.assoc_value);
-                       asoc->param_flags = 
+                       asoc->param_flags =
                                (asoc->param_flags & ~SPP_SACKDELAY) |
                                SPP_SACKDELAY_ENABLE;
                } else {
                        sp->sackdelay = params.assoc_value;
-                       sp->param_flags = 
+                       sp->param_flags =
                                (sp->param_flags & ~SPP_SACKDELAY) |
                                SPP_SACKDELAY_ENABLE;
                }
        } else {
                if (asoc) {
-                       asoc->param_flags = 
+                       asoc->param_flags =
                                (asoc->param_flags & ~SPP_SACKDELAY) |
                                SPP_SACKDELAY_DISABLE;
                } else {
-                       sp->param_flags = 
+                       sp->param_flags =
                                (sp->param_flags & ~SPP_SACKDELAY) |
                                SPP_SACKDELAY_DISABLE;
                }
@@ -2338,17 +2338,17 @@ static int sctp_setsockopt_delayed_ack_time(struct sock *sk,
                        if (params.assoc_value) {
                                trans->sackdelay =
                                        msecs_to_jiffies(params.assoc_value);
-                               trans->param_flags = 
+                               trans->param_flags =
                                        (trans->param_flags & ~SPP_SACKDELAY) |
                                        SPP_SACKDELAY_ENABLE;
                        } else {
-                               trans->param_flags = 
+                               trans->param_flags =
                                        (trans->param_flags & ~SPP_SACKDELAY) |
                                        SPP_SACKDELAY_DISABLE;
                        }
                }
        }
+
        return 0;
 }
 
@@ -2374,13 +2374,13 @@ static int sctp_setsockopt_initmsg(struct sock *sk, char __user *optval, int opt
                return -EFAULT;
 
        if (sinit.sinit_num_ostreams)
-               sp->initmsg.sinit_num_ostreams = sinit.sinit_num_ostreams;      
+               sp->initmsg.sinit_num_ostreams = sinit.sinit_num_ostreams;
        if (sinit.sinit_max_instreams)
-               sp->initmsg.sinit_max_instreams = sinit.sinit_max_instreams;    
+               sp->initmsg.sinit_max_instreams = sinit.sinit_max_instreams;
        if (sinit.sinit_max_attempts)
-               sp->initmsg.sinit_max_attempts = sinit.sinit_max_attempts;      
+               sp->initmsg.sinit_max_attempts = sinit.sinit_max_attempts;
        if (sinit.sinit_max_init_timeo)
-               sp->initmsg.sinit_max_init_timeo = sinit.sinit_max_init_timeo;  
+               sp->initmsg.sinit_max_init_timeo = sinit.sinit_max_init_timeo;
 
        return 0;
 }
@@ -2511,7 +2511,7 @@ static int sctp_setsockopt_rtoinfo(struct sock *sk, char __user *optval, int opt
 
        if (asoc) {
                if (rtoinfo.srto_initial != 0)
-                       asoc->rto_initial = 
+                       asoc->rto_initial =
                                msecs_to_jiffies(rtoinfo.srto_initial);
                if (rtoinfo.srto_max != 0)
                        asoc->rto_max = msecs_to_jiffies(rtoinfo.srto_max);
@@ -2665,7 +2665,7 @@ static int sctp_setsockopt_maxseg(struct sock *sk, char __user *optval, int optl
        /* Update the frag_point of the existing associations. */
        list_for_each(pos, &(sp->ep->asocs)) {
                asoc = list_entry(pos, struct sctp_association, asocs);
-               asoc->frag_point = sctp_frag_point(sp, asoc->pathmtu); 
+               asoc->frag_point = sctp_frag_point(sp, asoc->pathmtu);
        }
 
        return 0;
@@ -2703,7 +2703,7 @@ static int sctp_setsockopt_peer_primary_addr(struct sock *sk, char __user *optva
                return -EFAULT;
 
        asoc = sctp_id2assoc(sk, prim.sspp_assoc_id);
-       if (!asoc) 
+       if (!asoc)
                return -EINVAL;
 
        if (!asoc->peer.asconf_capable)
@@ -3015,7 +3015,7 @@ SCTP_STATIC struct sock *sctp_accept(struct sock *sk, int flags, int *err)
 
 out:
        sctp_release_sock(sk);
-       *err = error;
+       *err = error;
        return newsk;
 }
 
@@ -3087,7 +3087,7 @@ SCTP_STATIC int sctp_init_sock(struct sock *sk)
        sp->assocparams.sasoc_cookie_life = sctp_valid_cookie_life;
 
        /* Initialize default event subscriptions. By default, all the
-        * options are off. 
+        * options are off.
         */
        memset(&sp->subscribe, 0, sizeof(struct sctp_event_subscribe));
 
@@ -3099,8 +3099,8 @@ SCTP_STATIC int sctp_init_sock(struct sock *sk)
        sp->pathmtu     = 0; // allow default discovery
        sp->sackdelay   = sctp_sack_timeout;
        sp->param_flags = SPP_HB_ENABLE |
-                         SPP_PMTUD_ENABLE |
-                         SPP_SACKDELAY_ENABLE;
+                         SPP_PMTUD_ENABLE |
+                         SPP_SACKDELAY_ENABLE;
 
        /* If enabled no SCTP message fragmentation will be performed.
         * Configure through SCTP_DISABLE_FRAGMENTS socket option.
@@ -3680,7 +3680,7 @@ static int sctp_getsockopt_delayed_ack_time(struct sock *sk, int len,
        /* Get association, if assoc_id != 0 and the socket is a one
         * to many style socket, and an association was not found, then
         * the id was invalid.
-        */
+        */
        asoc = sctp_id2assoc(sk, params.assoc_id);
        if (!asoc && params.assoc_id && sctp_style(sk, UDP))
                return -EINVAL;
@@ -3756,7 +3756,7 @@ static int sctp_getsockopt_peer_addrs_num_old(struct sock *sk, int len,
        return cnt;
 }
 
-/* 
+/*
  * Old API for getting list of peer addresses. Does not work for 32-bit
  * programs running on a 64-bit kernel
  */
@@ -3833,7 +3833,7 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
                return -EINVAL;
 
        to = optval + offsetof(struct sctp_getaddrs,addrs);
-       space_left = len - sizeof(struct sctp_getaddrs) - 
+       space_left = len - sizeof(struct sctp_getaddrs) -
                        offsetof(struct sctp_getaddrs,addrs);
 
        list_for_each(pos, &asoc->peer.transport_addr_list) {
@@ -3907,7 +3907,7 @@ static int sctp_getsockopt_local_addrs_num_old(struct sock *sk, int len,
                                addr = list_entry(pos,
                                                  struct sctp_sockaddr_entry,
                                                  list);
-                               if ((PF_INET == sk->sk_family) && 
+                               if ((PF_INET == sk->sk_family) &&
                                    (AF_INET6 == addr->a.sa.sa_family))
                                        continue;
                                cnt++;
@@ -3941,7 +3941,7 @@ static int sctp_copy_laddrs_to_user_old(struct sock *sk, __u16 port, int max_add
 
        list_for_each_safe(pos, next, &sctp_local_addr_list) {
                addr = list_entry(pos, struct sctp_sockaddr_entry, list);
-               if ((PF_INET == sk->sk_family) && 
+               if ((PF_INET == sk->sk_family) &&
                    (AF_INET6 == addr->a.sa.sa_family))
                        continue;
                memcpy(&temp, &addr->a, sizeof(temp));
@@ -3970,7 +3970,7 @@ static int sctp_copy_laddrs_to_user(struct sock *sk, __u16 port,
 
        list_for_each_safe(pos, next, &sctp_local_addr_list) {
                addr = list_entry(pos, struct sctp_sockaddr_entry, list);
-               if ((PF_INET == sk->sk_family) && 
+               if ((PF_INET == sk->sk_family) &&
                    (AF_INET6 == addr->a.sa.sa_family))
                        continue;
                memcpy(&temp, &addr->a, sizeof(temp));
@@ -4051,7 +4051,7 @@ static int sctp_getsockopt_local_addrs_old(struct sock *sk, int len,
                                err = cnt;
                                goto unlock;
                        }
-                       goto copy_getaddrs;             
+                       goto copy_getaddrs;
                }
        }
 
@@ -4139,7 +4139,7 @@ static int sctp_getsockopt_local_addrs(struct sock *sk, int len,
                                err = cnt;
                                goto unlock;
                        }
-                       goto copy_getaddrs;             
+                       goto copy_getaddrs;
                }
        }
 
@@ -4196,7 +4196,7 @@ static int sctp_getsockopt_primary_addr(struct sock *sk, int len,
 
        if (!asoc->peer.primary_path)
                return -ENOTCONN;
-       
+
        memcpy(&prim.ssp_addr, &asoc->peer.primary_path->ipaddr,
                asoc->peer.primary_path->af_specific->sockaddr_len);
 
@@ -4864,7 +4864,7 @@ SCTP_STATIC int sctp_seqpacket_listen(struct sock *sk, int backlog)
        if (!backlog) {
                if (sctp_sstate(sk, CLOSED))
                        return 0;
-               
+
                sctp_unhash_endpoint(ep);
                sk->sk_state = SCTP_SS_CLOSED;
        }
@@ -4872,7 +4872,7 @@ SCTP_STATIC int sctp_seqpacket_listen(struct sock *sk, int backlog)
        /* Return if we are already listening. */
        if (sctp_sstate(sk, LISTENING))
                return 0;
-               
+
        /*
         * If a bind() or sctp_bindx() is not called prior to a listen()
         * call that allows new associations to be accepted, the system
@@ -4907,7 +4907,7 @@ SCTP_STATIC int sctp_stream_listen(struct sock *sk, int backlog)
        if (!backlog) {
                if (sctp_sstate(sk, CLOSED))
                        return 0;
-               
+
                sctp_unhash_endpoint(ep);
                sk->sk_state = SCTP_SS_CLOSED;
        }
@@ -5010,7 +5010,7 @@ unsigned int sctp_poll(struct file *file, struct socket *sock, poll_table *wait)
         */
        if (sctp_style(sk, TCP) && sctp_sstate(sk, LISTENING))
                return (!list_empty(&sp->ep->asocs)) ?
-                       (POLLIN | POLLRDNORM) : 0;
+                       (POLLIN | POLLRDNORM) : 0;
 
        mask = 0;
 
@@ -5430,7 +5430,7 @@ static int sctp_wait_for_sndbuf(struct sctp_association *asoc, long *timeo_p,
        DEFINE_WAIT(wait);
 
        SCTP_DEBUG_PRINTK("wait_for_sndbuf: asoc=%p, timeo=%ld, msg_len=%zu\n",
-                         asoc, (long)(*timeo_p), msg_len);
+                         asoc, (long)(*timeo_p), msg_len);
 
        /* Increment the association's refcnt.  */
        sctp_association_hold(asoc);
index 3e5936a5f671db698f560e65b4f5761ad3edd579..a596f5308cb18c89cd63836f95d65aef1f630b58 100644 (file)
@@ -130,9 +130,9 @@ static struct sctp_transport *sctp_transport_init(struct sctp_transport *peer,
 struct sctp_transport *sctp_transport_new(const union sctp_addr *addr,
                                          gfp_t gfp)
 {
-        struct sctp_transport *transport;
+       struct sctp_transport *transport;
 
-        transport = t_new(struct sctp_transport, gfp);
+       transport = t_new(struct sctp_transport, gfp);
        if (!transport)
                goto fail;
 
@@ -185,7 +185,7 @@ static void sctp_transport_destroy(struct sctp_transport *transport)
        if (transport->asoc)
                sctp_association_put(transport->asoc);
 
-        sctp_packet_free(&transport->packet);
+       sctp_packet_free(&transport->packet);
 
        dst_release(transport->dst);
        kfree(transport);
@@ -268,7 +268,7 @@ void sctp_transport_route(struct sctp_transport *transport,
 
                /* Initialize sk->sk_rcv_saddr, if the transport is the
                 * association's active path for getsockname().
-                */ 
+                */
                if (asoc && (transport == asoc->peer.active_path))
                        opt->pf->af->to_sk_saddr(&transport->saddr,
                                                 asoc->base.sk);
@@ -459,8 +459,8 @@ void sctp_transport_lower_cwnd(struct sctp_transport *transport,
                 * destination address(es) to which the missing DATA chunks
                 * were last sent, according to the formula described in
                 * Section 7.2.3.
-                *
-                * RFC 2960 7.2.3, sctpimpguide Upon detection of packet
+                *
+                * RFC 2960 7.2.3, sctpimpguide Upon detection of packet
                 * losses from SACK (see Section 7.2.4), An endpoint
                 * should do the following:
                 *      ssthresh = max(cwnd/2, 4*MTU)
@@ -488,7 +488,7 @@ void sctp_transport_lower_cwnd(struct sctp_transport *transport,
                if ((jiffies - transport->last_time_ecne_reduced) >
                    transport->rtt) {
                        transport->ssthresh = max(transport->cwnd/2,
-                                                 4*transport->asoc->pathmtu);
+                                                 4*transport->asoc->pathmtu);
                        transport->cwnd = transport->ssthresh;
                        transport->last_time_ecne_reduced = jiffies;
                }
index 42d9498c64fadde9e6279cc8527734237fecc38b..d3192a1babccb96645c8f3d54db2621a62073fc1 100644 (file)
@@ -277,7 +277,7 @@ static void sctp_tsnmap_update(struct sctp_tsnmap *map)
                        /* Now tsn_map must have been all '1's,
                         * so we swap the map and check the overflow table
                         */
-                       __u8 *tmp = map->tsn_map;
+                       __u8 *tmp = map->tsn_map;
                        memset(tmp, 0, map->len);
                        map->tsn_map = map->overflow_map;
                        map->overflow_map = tmp;
index 445e07a7ac4b873cd1f7138e806fd97c1d1a0193..2e11bc8d5d35cf79bf8908536c7cdb76bd3f12bc 100644 (file)
@@ -749,7 +749,7 @@ struct sctp_ulpevent *sctp_ulpevent_make_pdapi(
         */
        pd->pdapi_length = sizeof(struct sctp_pdapi_event);
 
-        /*  pdapi_indication: 32 bits (unsigned integer)
+       /*  pdapi_indication: 32 bits (unsigned integer)
         *
         * This field holds the indication being sent to the application.
         */
@@ -790,13 +790,13 @@ void sctp_ulpevent_read_sndrcvinfo(const struct sctp_ulpevent *event,
                return;
 
        /* Sockets API Extensions for SCTP
-        * Section 5.2.2 SCTP Header Information Structure (SCTP_SNDRCV)
-        *
-        * sinfo_stream: 16 bits (unsigned integer)
-        *
-        * For recvmsg() the SCTP stack places the message's stream number in
-        * this value.
-       */
+        * Section 5.2.2 SCTP Header Information Structure (SCTP_SNDRCV)
+        *
+        * sinfo_stream: 16 bits (unsigned integer)
+        *
+        * For recvmsg() the SCTP stack places the message's stream number in
+        * this value.
+       */
        sinfo.sinfo_stream = event->stream;
        /* sinfo_ssn: 16 bits (unsigned integer)
         *
@@ -828,7 +828,7 @@ void sctp_ulpevent_read_sndrcvinfo(const struct sctp_ulpevent *event,
        sinfo.sinfo_flags = event->flags;
        /* sinfo_tsn: 32 bit (unsigned integer)
         *
-        * For the receiving side, this field holds a TSN that was 
+        * For the receiving side, this field holds a TSN that was
         * assigned to one of the SCTP Data Chunks.
         */
        sinfo.sinfo_tsn = event->tsn;
@@ -879,7 +879,7 @@ static void sctp_ulpevent_receive_data(struct sctp_ulpevent *event,
         * fragment of the real event.  However, we still need to do rwnd
         * accounting.
         * In general, the skb passed from IP can have only 1 level of
-        * fragments. But we allow multiple levels of fragments. 
+        * fragments. But we allow multiple levels of fragments.
         */
        for (frag = skb_shinfo(skb)->frag_list; frag; frag = frag->next) {
                sctp_ulpevent_receive_data(sctp_skb2event(frag), asoc);
@@ -888,7 +888,7 @@ static void sctp_ulpevent_receive_data(struct sctp_ulpevent *event,
 
 /* Do accounting for bytes just read by user and release the references to
  * the association.
- */ 
+ */
 static void sctp_ulpevent_release_data(struct sctp_ulpevent *event)
 {
        struct sk_buff *skb, *frag;
index e1d144275f97aab998d4edc5155e608a316945e9..f4759a9bdaee5d52c21850928c132e4dc7ecf523 100644 (file)
@@ -191,7 +191,7 @@ int sctp_ulpq_tail_event(struct sctp_ulpq *ulpq, struct sctp_ulpevent *event)
                queue = &sk->sk_receive_queue;
        } else if (ulpq->pd_mode) {
                if (event->msg_flags & MSG_NOTIFICATION)
-                       queue = &sctp_sk(sk)->pd_lobby;
+                       queue = &sctp_sk(sk)->pd_lobby;
                else {
                        clear_pd = event->msg_flags & MSG_EOR;
                        queue = &sk->sk_receive_queue;
@@ -298,32 +298,32 @@ static struct sctp_ulpevent *sctp_make_reassembled_event(struct sk_buff_head *qu
         */
        if (last)
                last->next = pos;
-       else {
-               if (skb_cloned(f_frag)) {
-                       /* This is a cloned skb, we can't just modify
-                        * the frag_list.  We need a new skb to do that.
-                        * Instead of calling skb_unshare(), we'll do it
-                        * ourselves since we need to delay the free.
-                        */
-                       new = skb_copy(f_frag, GFP_ATOMIC);
-                       if (!new)
-                               return NULL;    /* try again later */
-
-                       sctp_skb_set_owner_r(new, f_frag->sk);
-
-                       skb_shinfo(new)->frag_list = pos;
-               } else
-                       skb_shinfo(f_frag)->frag_list = pos;
-       }
+       else {
+               if (skb_cloned(f_frag)) {
+                       /* This is a cloned skb, we can't just modify
+                        * the frag_list.  We need a new skb to do that.
+                        * Instead of calling skb_unshare(), we'll do it
+                        * ourselves since we need to delay the free.
+                        */
+                       new = skb_copy(f_frag, GFP_ATOMIC);
+                       if (!new)
+                               return NULL;    /* try again later */
+
+                       sctp_skb_set_owner_r(new, f_frag->sk);
+
+                       skb_shinfo(new)->frag_list = pos;
+               } else
+                       skb_shinfo(f_frag)->frag_list = pos;
+       }
 
        /* Remove the first fragment from the reassembly queue.  */
        __skb_unlink(f_frag, queue);
 
-       /* if we did unshare, then free the old skb and re-assign */
-       if (new) {
-               kfree_skb(f_frag);
-               f_frag = new;
-       }
+       /* if we did unshare, then free the old skb and re-assign */
+       if (new) {
+               kfree_skb(f_frag);
+               f_frag = new;
+       }
 
        while (pos) {
 
@@ -335,7 +335,7 @@ static struct sctp_ulpevent *sctp_make_reassembled_event(struct sk_buff_head *qu
 
                /* Remove the fragment from the reassembly queue.  */
                __skb_unlink(pos, queue);
-       
+
                /* Break if we have reached the last fragment.  */
                if (pos == l_frag)
                        break;
@@ -624,7 +624,7 @@ static inline void sctp_ulpq_store_ordered(struct sctp_ulpq *ulpq,
 
        sid = event->stream;
        ssn = event->ssn;
-       
+
        cevent = (struct sctp_ulpevent *) pos->cb;
        csid = cevent->stream;
        cssn = cevent->ssn;
@@ -718,11 +718,11 @@ static inline void sctp_ulpq_reap_ordered(struct sctp_ulpq *ulpq)
                if (cssn != sctp_ssn_peek(in, csid))
                        break;
 
-               /* Found it, so mark in the ssnmap. */         
+               /* Found it, so mark in the ssnmap. */
                sctp_ssn_next(in, csid);
 
                __skb_unlink(pos, &ulpq->lobby);
-               if (!event) {                                           
+               if (!event) {
                        /* Create a temporary list to collect chunks on.  */
                        event = sctp_skb2event(pos);
                        __skb_queue_tail(&temp, sctp_event2skb(event));
@@ -755,7 +755,7 @@ void sctp_ulpq_skip(struct sctp_ulpq *ulpq, __u16 sid, __u16 ssn)
        sctp_ssn_skip(in, sid, ssn);
 
        /* Go find any other chunks that were waiting for
-        * ordering and deliver them if needed. 
+        * ordering and deliver them if needed.
         */
        sctp_ulpq_reap_ordered(ulpq);
        return;
@@ -849,7 +849,7 @@ void sctp_ulpq_renege(struct sctp_ulpq *ulpq, struct sctp_chunk *chunk,
        if (chunk) {
                needed = ntohs(chunk->chunk_hdr->length);
                needed -= sizeof(sctp_data_chunk_t);
-       } else 
+       } else
                needed = SCTP_DEFAULT_MAXWINDOW;
 
        freed = 0;
@@ -866,7 +866,7 @@ void sctp_ulpq_renege(struct sctp_ulpq *ulpq, struct sctp_chunk *chunk,
                tsn = ntohl(chunk->subh.data_hdr->tsn);
                sctp_tsnmap_mark(&asoc->peer.tsn_map, tsn);
                sctp_ulpq_tail_data(ulpq, chunk, gfp);
-               
+
                sctp_ulpq_partial_delivery(ulpq, chunk, gfp);
        }
 
index 4e396312f8d58751d0c23914a056126e79ff72ac..a92f595802345c64e627ac3b04d5e8dc4afeac19 100644 (file)
@@ -407,24 +407,11 @@ int sock_map_fd(struct socket *sock)
 
 static struct socket *sock_from_file(struct file *file, int *err)
 {
-       struct inode *inode;
-       struct socket *sock;
-
        if (file->f_op == &socket_file_ops)
                return file->private_data;      /* set in sock_map_fd */
 
-       inode = file->f_path.dentry->d_inode;
-       if (!S_ISSOCK(inode->i_mode)) {
-               *err = -ENOTSOCK;
-               return NULL;
-       }
-
-       sock = SOCKET_I(inode);
-       if (sock->file != file) {
-               printk(KERN_ERR "socki_lookup: socket file changed!\n");
-               sock->file = file;
-       }
-       return sock;
+       *err = -ENOTSOCK;
+       return NULL;
 }
 
 /**
@@ -1527,8 +1514,9 @@ asmlinkage long sys_sendto(int fd, void __user *buff, size_t len,
        struct file *sock_file;
 
        sock_file = fget_light(fd, &fput_needed);
+       err = -EBADF;
        if (!sock_file)
-               return -EBADF;
+               goto out;
 
        sock = sock_from_file(sock_file, &err);
        if (!sock)
@@ -1555,6 +1543,7 @@ asmlinkage long sys_sendto(int fd, void __user *buff, size_t len,
 
 out_put:
        fput_light(sock_file, fput_needed);
+out:
        return err;
 }
 
@@ -1586,12 +1575,13 @@ asmlinkage long sys_recvfrom(int fd, void __user *ubuf, size_t size,
        int fput_needed;
 
        sock_file = fget_light(fd, &fput_needed);
+       err = -EBADF;
        if (!sock_file)
-               return -EBADF;
+               goto out;
 
        sock = sock_from_file(sock_file, &err);
        if (!sock)
-               goto out;
+               goto out_put;
 
        msg.msg_control = NULL;
        msg.msg_controllen = 0;
@@ -1610,8 +1600,9 @@ asmlinkage long sys_recvfrom(int fd, void __user *ubuf, size_t size,
                if (err2 < 0)
                        err = err2;
        }
-out:
+out_put:
        fput_light(sock_file, fput_needed);
+out:
        return err;
 }
 
@@ -2189,7 +2180,7 @@ done:
 }
 
 int kernel_connect(struct socket *sock, struct sockaddr *addr, int addrlen,
-                   int flags)
+                  int flags)
 {
        return sock->ops->connect(sock, addr, addrlen, flags);
 }
index 993ff1a5d945687883c51ffc4a8662c87aa7704a..76f7eac4082d4fe17a5b0f3f452fedc1feef85ce 100644 (file)
@@ -213,7 +213,7 @@ retry:
                rpcauth_gc_credcache(auth, &free);
        hlist_for_each_safe(pos, next, &cache->hashtable[nr]) {
                struct rpc_cred *entry;
-               entry = hlist_entry(pos, struct rpc_cred, cr_hash);
+               entry = hlist_entry(pos, struct rpc_cred, cr_hash);
                if (entry->cr_ops->crmatch(acred, entry, flags)) {
                        hlist_del(&entry->cr_hash);
                        cred = entry;
index e1a104abb782d81635937f90aa202742f3836f84..718fb94ad0f7025af40e6612771970f65e11da6b 100644 (file)
@@ -2,7 +2,7 @@
  * linux/net/sunrpc/auth_gss/auth_gss.c
  *
  * RPCSEC_GSS client authentication.
- * 
+ *
  *  Copyright (c) 2000 The Regents of the University of Michigan.
  *  All rights reserved.
  *
@@ -74,7 +74,7 @@ static struct rpc_credops gss_credops;
 * as it is passed to gssd to signal the use of
 * machine creds should be part of the shared rpc interface */
 
-#define CA_RUN_AS_MACHINE  0x00000200 
+#define CA_RUN_AS_MACHINE  0x00000200
 
 /* dump the buffer in `emacs-hexl' style */
 #define isprint(c)      ((c > 0x1f) && (c < 0x7f))
@@ -607,8 +607,8 @@ gss_pipe_destroy_msg(struct rpc_pipe_msg *msg)
        }
 }
 
-/* 
- * NOTE: we have the opportunity to use different 
+/*
+ * NOTE: we have the opportunity to use different
  * parameters based on the input flavor (which must be a pseudoflavor)
  */
 static struct rpc_auth *
@@ -869,7 +869,7 @@ gss_validate(struct rpc_task *task, __be32 *p)
 
        flav = ntohl(*p++);
        if ((len = ntohl(*p++)) > RPC_MAX_AUTH_SIZE)
-                goto out_bad;
+               goto out_bad;
        if (flav != RPC_AUTH_GSS)
                goto out_bad;
        seq = htonl(task->tk_rqstp->rq_seqno);
@@ -925,7 +925,7 @@ gss_wrap_req_integ(struct rpc_cred *cred, struct gss_cl_ctx *ctx,
        *integ_len = htonl(integ_buf.len);
 
        /* guess whether we're in the head or the tail: */
-       if (snd_buf->page_len || snd_buf->tail[0].iov_len) 
+       if (snd_buf->page_len || snd_buf->tail[0].iov_len)
                iov = snd_buf->tail;
        else
                iov = snd_buf->head;
@@ -1030,7 +1030,7 @@ gss_wrap_req_priv(struct rpc_cred *cred, struct gss_cl_ctx *ctx,
        maj_stat = gss_wrap(ctx->gc_gss_ctx, offset, snd_buf, inpages);
        /* RPC_SLACK_SPACE should prevent this ever happening: */
        BUG_ON(snd_buf->len > snd_buf->buflen);
-        status = -EIO;
+       status = -EIO;
        /* We're assuming that when GSS_S_CONTEXT_EXPIRED, the encryption was
         * done anyway, so it's safe to put the request on the wire: */
        if (maj_stat == GSS_S_CONTEXT_EXPIRED)
@@ -1079,7 +1079,7 @@ gss_wrap_req(struct rpc_task *task,
                        status = gss_wrap_req_integ(cred, ctx, encode,
                                                                rqstp, p, obj);
                        break;
-                       case RPC_GSS_SVC_PRIVACY:
+               case RPC_GSS_SVC_PRIVACY:
                        status = gss_wrap_req_priv(cred, ctx, encode,
                                        rqstp, p, obj);
                        break;
@@ -1179,7 +1179,7 @@ gss_unwrap_resp(struct rpc_task *task,
                        if (status)
                                goto out;
                        break;
-                       case RPC_GSS_SVC_PRIVACY:
+               case RPC_GSS_SVC_PRIVACY:
                        status = gss_unwrap_resp_priv(cred, ctx, rqstp, &p);
                        if (status)
                                goto out;
@@ -1196,7 +1196,7 @@ out:
                        status);
        return status;
 }
-  
+
 static struct rpc_authops authgss_ops = {
        .owner          = THIS_MODULE,
        .au_flavor      = RPC_AUTH_GSS,
index 826df44e7fca15dfdb2f640e5dfc84f872ddb2ce..ea8c92ecdae5294834253f552fb8f1523501bc5d 100644 (file)
@@ -11,7 +11,7 @@
 
 /*
  * Copyright 1993 by OpenVision Technologies, Inc.
- * 
+ *
  * Permission to use, copy, modify, distribute, and sell this software
  * and its documentation for any purpose is hereby granted without fee,
  * provided that the above copyright notice appears in all copies and
@@ -21,7 +21,7 @@
  * without specific, written prior permission. OpenVision makes no
  * representations about the suitability of this software for any
  * purpose.  It is provided "as is" without express or implied warranty.
- * 
+ *
  * OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  * EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR
@@ -201,7 +201,7 @@ g_verify_token_header(struct xdr_netobj *mech, int *body_size,
                return(G_BAD_TOK_HEADER);
        if (*buf++ != 0x06)
                return(G_BAD_TOK_HEADER);
+
        if ((toksize-=1) < 0)
                return(G_BAD_TOK_HEADER);
        toid.len = *buf++;
@@ -211,9 +211,9 @@ g_verify_token_header(struct xdr_netobj *mech, int *body_size,
        toid.data = buf;
        buf+=toid.len;
 
-       if (! g_OID_equal(&toid, mech)) 
+       if (! g_OID_equal(&toid, mech))
                ret = G_WRONG_MECH;
+
    /* G_WRONG_MECH is not returned immediately because it's more important
       to return G_BAD_TOK_HEADER if the token header is in fact bad */
 
index d926cda8862399de9d73d94c30063004a7c6b3f5..0a9948de0992f584d5e4c2a7f9ee8341a4cc9d08 100644 (file)
@@ -58,7 +58,7 @@ krb5_encrypt(
        int length)
 {
        u32 ret = -EINVAL;
-        struct scatterlist sg[1];
+       struct scatterlist sg[1];
        u8 local_iv[16] = {0};
        struct blkcipher_desc desc = { .tfm = tfm, .info = local_iv };
 
@@ -67,7 +67,7 @@ krb5_encrypt(
 
        if (crypto_blkcipher_ivsize(tfm) > 16) {
                dprintk("RPC:      gss_k5encrypt: tfm iv size to large %d\n",
-                        crypto_blkcipher_ivsize(tfm));
+                        crypto_blkcipher_ivsize(tfm));
                goto out;
        }
 
index c604baf3a5f694de79525cedf66a120d59953dd9..3e315a68efaa4f9c137836ece35e5f6c500016f7 100644 (file)
@@ -11,7 +11,7 @@
 
 /*
  * Copyright 1993 by OpenVision Technologies, Inc.
- * 
+ *
  * Permission to use, copy, modify, distribute, and sell this software
  * and its documentation for any purpose is hereby granted without fee,
  * provided that the above copyright notice appears in all copies and
@@ -21,7 +21,7 @@
  * without specific, written prior permission. OpenVision makes no
  * representations about the suitability of this software for any
  * purpose.  It is provided "as is" without express or implied warranty.
- * 
+ *
  * OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  * EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR
index 3db745379d060a0d3e0a653636223e3d7d460ab4..3423890e4a30718eed9f00780f5752188d0186f1 100644 (file)
@@ -6,14 +6,14 @@
  *
  *  J. Bruce Fields   <bfields@umich.edu>
  *
- *  Redistribution and use in source and binary forms, with or without 
+ *  Redistribution and use in source and binary forms, with or without
  *  modification, are permitted provided that the following conditions
  *  are met:
  *
  *  1. Redistributions of source code must retain the above copyright
  *     notice, this list of conditions and the following disclaimer.
  *  2. Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the 
+ *     notice, this list of conditions and the following disclaimer in the
  *     documentation and/or other materials provided with the distribution.
  *  3. Neither the name of the University nor the names of its
  *     contributors may be used to endorse or promote products derived
index 35188b6ea8f75a950709498fa5dc187e73b0c02f..8400b621971e2466a14e8339b9559a8241912226 100644 (file)
@@ -59,7 +59,7 @@ asn1_bitstring_len(struct xdr_netobj *in, int *enclen, int *zerobits)
 
        /* count trailing 0's */
        for(i = in->len; i > 0; i--) {
-               if (*ptr == 0) { 
+               if (*ptr == 0) {
                        ptr--;
                        elen--;
                } else
@@ -82,7 +82,7 @@ asn1_bitstring_len(struct xdr_netobj *in, int *enclen, int *zerobits)
 
 /*
  * decode_asn1_bitstring()
- * 
+ *
  * decode a bitstring into a buffer of the expected length.
  * enclen = bit string length
  * explen = expected length (define in rfc)
@@ -97,9 +97,9 @@ decode_asn1_bitstring(struct xdr_netobj *out, char *in, int enclen, int explen)
        return 1;
 }
 
-/* 
+/*
  * SPKMInnerContextToken choice SPKM_MIC asn1 token layout
- * 
+ *
  * contextid is always 16 bytes plain data. max asn1 bitstring len = 17.
  *
  * tokenlen = pos[0] to end of token (max pos[45] with MD5 cksum)
@@ -107,21 +107,21 @@ decode_asn1_bitstring(struct xdr_netobj *out, char *in, int enclen, int explen)
  * pos  value
  * ----------
  * [0] a4  SPKM-MIC tag
- * [1] ??  innertoken length  (max 44) 
- * 
- * 
- * tok_hdr piece of checksum data starts here 
+ * [1] ??  innertoken length  (max 44)
+ *
+ *
+ * tok_hdr piece of checksum data starts here
  *
- * the maximum mic-header len = 9 + 17 = 26 
+ * the maximum mic-header len = 9 + 17 = 26
  *     mic-header
  *     ----------
- * [2] 30      SEQUENCE tag  
- * [3] ??      mic-header length: (max 23) = TokenID + ContextID 
+ * [2] 30      SEQUENCE tag
+ * [3] ??      mic-header length: (max 23) = TokenID + ContextID
  *
  *             TokenID  - all fields constant and can be hardcoded
  *             -------
  * [4]   02    Type 2
- * [5]   02    Length 2 
+ * [5]   02    Length 2
  * [6][7] 01 01        TokenID (SPKM_MIC_TOK)
  *
  *             ContextID  - encoded length not constant, calculated
@@ -131,17 +131,17 @@ decode_asn1_bitstring(struct xdr_netobj *out, char *in, int enclen, int explen)
  * [10]        ??      ctxzbit
  * [11]                contextid
  *
- * mic_header piece of checksum data ends here. 
+ * mic_header piece of checksum data ends here.
  *
  *     int-cksum - encoded length not constant, calculated
  *     ---------
  * [??]        03      Type 3
- * [??]        ??      encoded length 
- * [??]        ??      md5zbit         
+ * [??]        ??      encoded length
+ * [??]        ??      md5zbit
  * [??]                int-cksum (NID_md5 = 16)
  *
- * maximum SPKM-MIC innercontext token length = 
- *      10 + encoded contextid_size(17 max) + 2 + encoded  
+ * maximum SPKM-MIC innercontext token length =
+ *      10 + encoded contextid_size(17 max) + 2 + encoded
  *       cksum_size (17 maxfor NID_md5) = 46
  */
 
@@ -178,8 +178,8 @@ spkm3_mic_header(unsigned char **hdrbuf, unsigned int *hdrlen, unsigned char *ct
 /*
  * spkm3_mic_innercontext_token()
  *
- * *tokp points to the beginning of the SPKM_MIC token  described 
- * in rfc 2025, section 3.2.1: 
+ * *tokp points to the beginning of the SPKM_MIC token  described
+ * in rfc 2025, section 3.2.1:
  *
  * toklen is the inner token length
  */
@@ -209,7 +209,7 @@ spkm3_verify_mic_token(unsigned char **tokp, int *mic_hdrlen, unsigned char **ck
 
        /* spkm3 innercontext token preamble */
        if ((ptr[0] != 0xa4) || (ptr[2] != 0x30)) {
-               dprintk("RPC: BAD SPKM ictoken preamble\n"); 
+               dprintk("RPC: BAD SPKM ictoken preamble\n");
                goto out;
        }
 
@@ -245,9 +245,9 @@ spkm3_verify_mic_token(unsigned char **tokp, int *mic_hdrlen, unsigned char **ck
                goto out;
 
        /*
-       * in the current implementation: the optional int-alg is not present 
-       * so the default int-alg (md5) is used the optional snd-seq field is 
-       * also not present 
+       * in the current implementation: the optional int-alg is not present
+       * so the default int-alg (md5) is used the optional snd-seq field is
+       * also not present
        */
 
        if (*mic_hdrlen != 6 + ctxelen) {
@@ -255,7 +255,7 @@ spkm3_verify_mic_token(unsigned char **tokp, int *mic_hdrlen, unsigned char **ck
                goto out;
        }
        /* checksum */
-        *cksum = (&ptr[10] + ctxelen); /* ctxelen includes ptr[10] */
+       *cksum = (&ptr[10] + ctxelen); /* ctxelen includes ptr[10] */
 
        ret = GSS_S_COMPLETE;
 out:
index e54581ca75702b43321aae63bced573ceffc73b8..35a1b34c4a1dd9662dbdb71af26e7ebf66099007 100644 (file)
@@ -45,7 +45,7 @@
 
 /*
  * spkm3_read_token()
- * 
+ *
  * only SPKM_MIC_TOK with md5 intg-alg is supported
  */
 u32
index 066c64a97fd87fafd5e48411b82bae5abb574393..8fde38ecaf211e9e4217007609aa34901eaed25d 100644 (file)
@@ -172,8 +172,8 @@ static struct cache_head *rsi_alloc(void)
 }
 
 static void rsi_request(struct cache_detail *cd,
-                       struct cache_head *h,
-                       char **bpp, int *blen)
+                      struct cache_head *h,
+                      char **bpp, int *blen)
 {
        struct rsi *rsii = container_of(h, struct rsi, h);
 
@@ -184,7 +184,7 @@ static void rsi_request(struct cache_detail *cd,
 
 
 static int rsi_parse(struct cache_detail *cd,
-                    char *mesg, int mlen)
+                   char *mesg, int mlen)
 {
        /* context token expiry major minor context token */
        char *buf = mesg;
index 14274490f92e8d9b521b5396320c5e76178adb5e..c80df455802d55dfe15b119189106e34865d0ac8 100644 (file)
@@ -274,7 +274,7 @@ int cache_check(struct cache_detail *detail,
  *
  * A table is then only scanned if the current time is at least
  * the nextcheck time.
- * 
+ *
  */
 
 static LIST_HEAD(cache_list);
@@ -296,16 +296,16 @@ void cache_register(struct cache_detail *cd)
                struct proc_dir_entry *p;
                cd->proc_ent->owner = cd->owner;
                cd->channel_ent = cd->content_ent = NULL;
-               
-               p = create_proc_entry("flush", S_IFREG|S_IRUSR|S_IWUSR,
-                                     cd->proc_ent);
+
+               p = create_proc_entry("flush", S_IFREG|S_IRUSR|S_IWUSR,
+                                     cd->proc_ent);
                cd->flush_ent =  p;
-               if (p) {
-                       p->proc_fops = &cache_flush_operations;
-                       p->owner = cd->owner;
-                       p->data = cd;
-               }
+               if (p) {
+                       p->proc_fops = &cache_flush_operations;
+                       p->owner = cd->owner;
+                       p->data = cd;
+               }
+
                if (cd->cache_request || cd->cache_parse) {
                        p = create_proc_entry("channel", S_IFREG|S_IRUSR|S_IWUSR,
                                              cd->proc_ent);
@@ -316,16 +316,16 @@ void cache_register(struct cache_detail *cd)
                                p->data = cd;
                        }
                }
-               if (cd->cache_show) {
-                       p = create_proc_entry("content", S_IFREG|S_IRUSR|S_IWUSR,
-                                             cd->proc_ent);
+               if (cd->cache_show) {
+                       p = create_proc_entry("content", S_IFREG|S_IRUSR|S_IWUSR,
+                                             cd->proc_ent);
                        cd->content_ent = p;
-                       if (p) {
-                               p->proc_fops = &content_file_operations;
-                               p->owner = cd->owner;
-                               p->data = cd;
-                       }
-               }
+                       if (p) {
+                               p->proc_fops = &content_file_operations;
+                               p->owner = cd->owner;
+                               p->data = cd;
+                       }
+               }
        }
        rwlock_init(&cd->hash_lock);
        INIT_LIST_HEAD(&cd->queue);
@@ -417,15 +417,15 @@ static int cache_clean(void)
                current_index++;
 
        /* find a cleanable entry in the bucket and clean it, or set to next bucket */
-       
+
        if (current_detail && current_index < current_detail->hash_size) {
                struct cache_head *ch, **cp;
                struct cache_detail *d;
-               
+
                write_lock(&current_detail->hash_lock);
 
                /* Ok, now to clean this strand */
-                       
+
                cp = & current_detail->hash_table[current_index];
                ch = *cp;
                for (; ch; cp= & ch->next, ch= *cp) {
@@ -477,9 +477,9 @@ static void do_cache_clean(struct work_struct *work)
 }
 
 
-/* 
+/*
  * Clean all caches promptly.  This just calls cache_clean
- * repeatedly until we are sure that every cache has had a chance to 
+ * repeatedly until we are sure that every cache has had a chance to
  * be fully cleaned
  */
 void cache_flush(void)
@@ -508,7 +508,7 @@ void cache_purge(struct cache_detail *detail)
  * All deferred requests are stored in a hash table,
  * indexed by "struct cache_head *".
  * As it may be wasteful to store a whole request
- * structure, we allow the request to provide a 
+ * structure, we allow the request to provide a
  * deferred form, which must contain a
  * 'struct cache_deferred_req'
  * This cache_deferred_req contains a method to allow
@@ -584,7 +584,7 @@ static void cache_revisit_request(struct cache_head *item)
 
        INIT_LIST_HEAD(&pending);
        spin_lock(&cache_defer_lock);
-       
+
        lp = cache_defer_hash[hash].next;
        if (lp) {
                while (lp != &cache_defer_hash[hash]) {
@@ -614,7 +614,7 @@ void cache_clean_deferred(void *owner)
 
        INIT_LIST_HEAD(&pending);
        spin_lock(&cache_defer_lock);
-       
+
        list_for_each_entry_safe(dreq, tmp, &cache_defer_list, recent) {
                if (dreq->owner == owner) {
                        list_del(&dreq->hash);
@@ -639,7 +639,7 @@ void cache_clean_deferred(void *owner)
  * On write, an update request is processed
  * Poll works if anything to read, and always allows write
  *
- * Implemented by linked list of requests.  Each open file has 
+ * Implemented by linked list of requests.  Each open file has
  * a ->private that also exists in this list.  New request are added
  * to the end and may wakeup and preceding readers.
  * New readers are added to the head.  If, on read, an item is found with
@@ -1059,10 +1059,10 @@ static int cache_make_upcall(struct cache_detail *detail, struct cache_head *h)
  * Messages are, like requests, separated into fields by
  * spaces and dequotes as \xHEXSTRING or embedded \nnn octal
  *
- * Message is 
+ * Message is
  *   reply cachename expiry key ... content....
  *
- * key and content are both parsed by cache 
+ * key and content are both parsed by cache
  */
 
 #define isodigit(c) (isdigit(c) && c <= '7')
@@ -1132,7 +1132,7 @@ static void *c_start(struct seq_file *m, loff_t *pos)
        unsigned hash, entry;
        struct cache_head *ch;
        struct cache_detail *cd = ((struct handle*)m->private)->cd;
-       
+
 
        read_lock(&cd->hash_lock);
        if (!n--)
@@ -1147,7 +1147,7 @@ static void *c_start(struct seq_file *m, loff_t *pos)
        do {
                hash++;
                n += 1LL<<32;
-       } while(hash < cd->hash_size && 
+       } while(hash < cd->hash_size &&
                cd->hash_table[hash]==NULL);
        if (hash >= cd->hash_size)
                return NULL;
index 16c9fbc1db6995e059ec263aa02449f912bd3942..c95a61736d1c58da98186f69ce740061e56d75af 100644 (file)
@@ -410,7 +410,7 @@ struct rpc_clnt *rpc_bind_new_program(struct rpc_clnt *old,
                rpc_shutdown_client(clnt);
                clnt = ERR_PTR(err);
        }
-out:   
+out:
        return clnt;
 }
 
@@ -431,7 +431,7 @@ static const struct rpc_call_ops rpc_default_ops = {
  *     sleeps on RPC calls
  */
 #define RPC_INTR_SIGNALS (sigmask(SIGHUP) | sigmask(SIGINT) | sigmask(SIGQUIT) | sigmask(SIGTERM))
+
 static void rpc_save_sigmask(sigset_t *oldset, int intr)
 {
        unsigned long   sigallow = sigmask(SIGKILL);
@@ -474,7 +474,7 @@ int rpc_call_sync(struct rpc_clnt *clnt, struct rpc_message *msg, int flags)
        int             status;
 
        /* If this client is slain all further I/O fails */
-       if (clnt->cl_dead) 
+       if (clnt->cl_dead)
                return -EIO;
 
        BUG_ON(flags & RPC_TASK_ASYNC);
@@ -515,7 +515,7 @@ rpc_call_async(struct rpc_clnt *clnt, struct rpc_message *msg, int flags,
 
        /* If this client is slain all further I/O fails */
        status = -EIO;
-       if (clnt->cl_dead) 
+       if (clnt->cl_dead)
                goto out_release;
 
        flags |= RPC_TASK_ASYNC;
@@ -526,7 +526,7 @@ rpc_call_async(struct rpc_clnt *clnt, struct rpc_message *msg, int flags,
                goto out_release;
 
        /* Mask signals on GSS_AUTH upcalls */
-       rpc_task_sigmask(task, &oldset);                
+       rpc_task_sigmask(task, &oldset);
 
        rpc_call_setup(task, msg, 0);
 
@@ -537,7 +537,7 @@ rpc_call_async(struct rpc_clnt *clnt, struct rpc_message *msg, int flags,
        else
                rpc_put_task(task);
 
-       rpc_restore_sigmask(&oldset);           
+       rpc_restore_sigmask(&oldset);
        return status;
 out_release:
        rpc_release_calldata(tk_ops, data);
@@ -749,7 +749,7 @@ call_allocate(struct rpc_task *task)
        struct rpc_xprt *xprt = task->tk_xprt;
        unsigned int    bufsiz;
 
-       dprintk("RPC: %4d call_allocate (status %d)\n", 
+       dprintk("RPC: %4d call_allocate (status %d)\n",
                                task->tk_pid, task->tk_status);
        task->tk_action = call_bind;
        if (req->rq_buffer)
@@ -761,7 +761,7 @@ call_allocate(struct rpc_task *task)
 
        if (xprt->ops->buf_alloc(task, bufsiz << 1) != NULL)
                return;
-       printk(KERN_INFO "RPC: buffer allocation failed for task %p\n", task); 
+       printk(KERN_INFO "RPC: buffer allocation failed for task %p\n", task);
 
        if (RPC_IS_ASYNC(task) || !signalled()) {
                xprt_release(task);
@@ -798,7 +798,7 @@ call_encode(struct rpc_task *task)
        kxdrproc_t      encode;
        __be32          *p;
 
-       dprintk("RPC: %4d call_encode (status %d)\n", 
+       dprintk("RPC: %4d call_encode (status %d)\n",
                                task->tk_pid, task->tk_status);
 
        /* Default buffer setup */
@@ -933,7 +933,7 @@ call_connect_status(struct rpc_task *task)
        struct rpc_clnt *clnt = task->tk_client;
        int status = task->tk_status;
 
-       dprintk("RPC: %5u call_connect_status (status %d)\n", 
+       dprintk("RPC: %5u call_connect_status (status %d)\n",
                                task->tk_pid, task->tk_status);
 
        task->tk_status = 0;
@@ -966,7 +966,7 @@ call_connect_status(struct rpc_task *task)
 static void
 call_transmit(struct rpc_task *task)
 {
-       dprintk("RPC: %4d call_transmit (status %d)\n", 
+       dprintk("RPC: %4d call_transmit (status %d)\n",
                                task->tk_pid, task->tk_status);
 
        task->tk_action = call_status;
@@ -1028,7 +1028,7 @@ call_status(struct rpc_task *task)
        if (req->rq_received > 0 && !req->rq_bytes_sent)
                task->tk_status = req->rq_received;
 
-       dprintk("RPC: %4d call_status (status %d)\n", 
+       dprintk("RPC: %4d call_status (status %d)\n",
                                task->tk_pid, task->tk_status);
 
        status = task->tk_status;
@@ -1118,7 +1118,7 @@ call_decode(struct rpc_task *task)
        kxdrproc_t      decode = task->tk_msg.rpc_proc->p_decode;
        __be32          *p;
 
-       dprintk("RPC: %4d call_decode (status %d)\n", 
+       dprintk("RPC: %4d call_decode (status %d)\n",
                                task->tk_pid, task->tk_status);
 
        if (task->tk_flags & RPC_CALL_MAJORSEEN) {
@@ -1196,7 +1196,7 @@ static void
 call_refreshresult(struct rpc_task *task)
 {
        int status = task->tk_status;
-       dprintk("RPC: %4d call_refreshresult (status %d)\n", 
+       dprintk("RPC: %4d call_refreshresult (status %d)\n",
                                task->tk_pid, task->tk_status);
 
        task->tk_status = 0;
index 3946ec3eb517a674881fc3b8d35277f2a5f3de44..f4e1357bc186e63796592244e497b80a80b25ef3 100644 (file)
@@ -329,7 +329,7 @@ static int xdr_decode_bool(struct rpc_rqst *req, __be32 *p, unsigned int *boolp)
 static struct rpc_procinfo     pmap_procedures[] = {
 [PMAP_SET] = {
          .p_proc               = PMAP_SET,
-         .p_encode             = (kxdrproc_t) xdr_encode_mapping,      
+         .p_encode             = (kxdrproc_t) xdr_encode_mapping,
          .p_decode             = (kxdrproc_t) xdr_decode_bool,
          .p_bufsiz             = 4,
          .p_count              = 1,
@@ -338,7 +338,7 @@ static struct rpc_procinfo  pmap_procedures[] = {
        },
 [PMAP_UNSET] = {
          .p_proc               = PMAP_UNSET,
-         .p_encode             = (kxdrproc_t) xdr_encode_mapping,      
+         .p_encode             = (kxdrproc_t) xdr_encode_mapping,
          .p_decode             = (kxdrproc_t) xdr_decode_bool,
          .p_bufsiz             = 4,
          .p_count              = 1,
index fc083f0b354434940b98aa27e882f9d4bef8bfe6..54a6b92525ea803d3dbd9d81a9f2ccb5cd28b3b9 100644 (file)
@@ -4,7 +4,7 @@
  * Scheduling for synchronous and asynchronous RPC requests.
  *
  * Copyright (C) 1996 Olaf Kirch, <okir@monad.swb.de>
- * 
+ *
  * TCP NFS related read + write fixes
  * (C) 1999 Dave Airlie, University of Limerick, Ireland <airlied@linux.ie>
  */
@@ -307,7 +307,7 @@ EXPORT_SYMBOL(__rpc_wait_for_completion_task);
 /*
  * Make an RPC task runnable.
  *
- * Note: If the task is ASYNC, this must be called with 
+ * Note: If the task is ASYNC, this must be called with
  * the spinlock held to protect the wait queue operation.
  */
 static void rpc_make_runnable(struct rpc_task *task)
@@ -646,8 +646,8 @@ static int __rpc_execute(struct rpc_task *task)
                if (RPC_DO_CALLBACK(task)) {
                        /* Define a callback save pointer */
                        void (*save_callback)(struct rpc_task *);
-       
-                       /* 
+
+                       /*
                         * If a callback exists, save it, reset it,
                         * call it.
                         * The save is needed to stop from resetting
index 4c1611211119352d752fbe968f07ff448fc31de7..b00511d39b6526b2026220644c5b6c9eb2a6bdef 100644 (file)
@@ -386,7 +386,7 @@ svc_destroy(struct svc_serv *serv)
                svsk = list_entry(serv->sv_tempsocks.next,
                                  struct svc_sock,
                                  sk_list);
-               svc_delete_socket(svsk);
+               svc_close_socket(svsk);
        }
        if (serv->sv_shutdown)
                serv->sv_shutdown(serv);
@@ -395,9 +395,9 @@ svc_destroy(struct svc_serv *serv)
                svsk = list_entry(serv->sv_permsocks.next,
                                  struct svc_sock,
                                  sk_list);
-               svc_delete_socket(svsk);
+               svc_close_socket(svsk);
        }
-       
+
        cache_clean_deferred(serv);
 
        /* Unregister service with the portmapper */
@@ -415,7 +415,7 @@ svc_init_buffer(struct svc_rqst *rqstp, unsigned int size)
 {
        int pages;
        int arghi;
-       
+
        pages = size / PAGE_SIZE + 1; /* extra page as we hold both request and reply.
                                       * We assume one is at most one page
                                       */
@@ -514,7 +514,7 @@ choose_pool(struct svc_serv *serv, struct svc_pool *pool, unsigned int *state)
        if (pool != NULL)
                return pool;
 
-       return &serv->sv_pools[(*state)++ % serv->sv_nrpools];
+       return &serv->sv_pools[(*state)++ % serv->sv_nrpools];
 }
 
 /*
@@ -530,13 +530,13 @@ choose_victim(struct svc_serv *serv, struct svc_pool *pool, unsigned int *state)
                spin_lock_bh(&pool->sp_lock);
        } else {
                /* choose a pool in round-robin fashion */
-               for (i = 0; i < serv->sv_nrpools; i++) {
-                       pool = &serv->sv_pools[--(*state) % serv->sv_nrpools];
+               for (i = 0; i < serv->sv_nrpools; i++) {
+                       pool = &serv->sv_pools[--(*state) % serv->sv_nrpools];
                        spin_lock_bh(&pool->sp_lock);
-                       if (!list_empty(&pool->sp_all_threads))
-                               goto found_pool;
+                       if (!list_empty(&pool->sp_all_threads))
+                               goto found_pool;
                        spin_unlock_bh(&pool->sp_lock);
-               }
+               }
                return NULL;
        }
 
@@ -551,7 +551,7 @@ found_pool:
                rqstp = list_entry(pool->sp_all_threads.next, struct svc_rqst, rq_all);
                list_del_init(&rqstp->rq_all);
                task = rqstp->rq_task;
-       }
+       }
        spin_unlock_bh(&pool->sp_lock);
 
        return task;
@@ -636,7 +636,7 @@ svc_exit_thread(struct svc_rqst *rqstp)
 
 /*
  * Register an RPC service with the local portmapper.
- * To unregister a service, call this routine with 
+ * To unregister a service, call this routine with
  * proto and port == 0.
  */
 int
@@ -709,7 +709,7 @@ svc_process(struct svc_rqst *rqstp)
                goto err_short_len;
 
        /* setup response xdr_buf.
-        * Initially it has just one page 
+        * Initially it has just one page
         */
        rqstp->rq_resused = 1;
        resv->iov_base = page_address(rqstp->rq_respages[0]);
@@ -811,7 +811,7 @@ svc_process(struct svc_rqst *rqstp)
        memset(rqstp->rq_argp, 0, procp->pc_argsize);
        memset(rqstp->rq_resp, 0, procp->pc_ressize);
 
-       /* un-reserve some of the out-queue now that we have a 
+       /* un-reserve some of the out-queue now that we have a
         * better idea of reply size
         */
        if (procp->pc_xdrressize)
index c7bb5f7f21a587213a4003ec1f5218492a579d3d..811a24c83262fc011d90643c9ff1e47b329ac47e 100644 (file)
@@ -2,7 +2,7 @@
  * linux/net/sunrpc/svcauth.c
  *
  * The generic interface for RPC authentication on the server side.
- * 
+ *
  * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
  *
  * CHANGES
@@ -74,7 +74,7 @@ int svc_authorise(struct svc_rqst *rqstp)
        int rv = 0;
 
        rqstp->rq_authop = NULL;
-       
+
        if (aops) {
                rv = aops->release(rqstp);
                module_put(aops->owner);
index 0d1e8fb83b930ee4e9e472d07e2f265875389b02..987244f95909e9d89477d49b080a9b01d4a7f649 100644 (file)
@@ -151,7 +151,7 @@ static void ip_map_request(struct cache_detail *cd,
        char text_addr[20];
        struct ip_map *im = container_of(h, struct ip_map, h);
        __be32 addr = im->m_addr.s_addr;
-       
+
        snprintf(text_addr, 20, "%u.%u.%u.%u",
                 ntohl(addr) >> 24 & 0xff,
                 ntohl(addr) >> 16 & 0xff,
@@ -198,7 +198,7 @@ static int ip_map_parse(struct cache_detail *cd,
 
        if (sscanf(buf, "%u.%u.%u.%u%c", &b1, &b2, &b3, &b4, &c) != 4)
                return -EINVAL;
-       
+
        expiry = get_expiry(&mesg);
        if (expiry ==0)
                return -EINVAL;
@@ -248,7 +248,7 @@ static int ip_map_show(struct seq_file *m,
        /* class addr domain */
        addr = im->m_addr;
 
-       if (test_bit(CACHE_VALID, &h->flags) && 
+       if (test_bit(CACHE_VALID, &h->flags) &&
            !test_bit(CACHE_NEGATIVE, &h->flags))
                dom = im->m_client->h.name;
 
@@ -262,7 +262,7 @@ static int ip_map_show(struct seq_file *m,
                   );
        return 0;
 }
-       
+
 
 struct cache_detail ip_map_cache = {
        .owner          = THIS_MODULE,
@@ -343,7 +343,7 @@ int auth_unix_add_addr(struct in_addr addr, struct auth_domain *dom)
 int auth_unix_forget_old(struct auth_domain *dom)
 {
        struct unix_domain *udom;
-       
+
        if (dom->flavour != &svcauth_unix)
                return -EINVAL;
        udom = container_of(dom, struct unix_domain, h);
@@ -465,7 +465,7 @@ svcauth_null_accept(struct svc_rqst *rqstp, __be32 *authp)
        if (argv->iov_len < 3*4)
                return SVC_GARBAGE;
 
-       if (svc_getu32(argv) != 0) { 
+       if (svc_getu32(argv) != 0) {
                dprintk("svc: bad null cred\n");
                *authp = rpc_autherr_badcred;
                return SVC_DENIED;
index ff1f8bf680aab43e741249912409b09013ba6fad..2fd0ba2b20dfd5e149d680e0e0abda687fc6229e 100644 (file)
  *     providing that certain rules are followed:
  *
  *     SK_CONN, SK_DATA, can be set or cleared at any time.
- *             after a set, svc_sock_enqueue must be called.   
+ *             after a set, svc_sock_enqueue must be called.
  *             after a clear, the socket must be read/accepted
  *              if this succeeds, it must be set again.
  *     SK_CLOSE can set at any time. It is never cleared.
+ *      sk_inuse contains a bias of '1' until SK_DEAD is set.
+ *             so when sk_inuse hits zero, we know the socket is dead
+ *             and no-one is using it.
+ *      SK_DEAD can only be set while SK_BUSY is held which ensures
+ *             no other thread will be using the socket or will try to
+ *            set SK_DEAD.
  *
  */
 
@@ -70,6 +76,7 @@
 
 static struct svc_sock *svc_setup_socket(struct svc_serv *, struct socket *,
                                         int *errp, int pmap_reg);
+static void            svc_delete_socket(struct svc_sock *svsk);
 static void            svc_udp_data_ready(struct sock *, int);
 static int             svc_udp_recvfrom(struct svc_rqst *);
 static int             svc_udp_sendto(struct svc_rqst *);
@@ -245,7 +252,7 @@ svc_sock_enqueue(struct svc_sock *svsk)
                        svsk->sk_sk, rqstp);
                svc_thread_dequeue(pool, rqstp);
                if (rqstp->rq_sock)
-                       printk(KERN_ERR 
+                       printk(KERN_ERR
                                "svc_sock_enqueue: server %p, rq_sock=%p!\n",
                                rqstp, rqstp->rq_sock);
                rqstp->rq_sock = svsk;
@@ -329,8 +336,9 @@ void svc_reserve(struct svc_rqst *rqstp, int space)
 static inline void
 svc_sock_put(struct svc_sock *svsk)
 {
-       if (atomic_dec_and_test(&svsk->sk_inuse) &&
-                       test_bit(SK_DEAD, &svsk->sk_flags)) {
+       if (atomic_dec_and_test(&svsk->sk_inuse)) {
+               BUG_ON(! test_bit(SK_DEAD, &svsk->sk_flags));
+
                dprintk("svc: releasing dead socket\n");
                if (svsk->sk_sock->file)
                        sockfd_put(svsk->sk_sock);
@@ -476,7 +484,7 @@ svc_sendto(struct svc_rqst *rqstp, struct xdr_buf *xdr)
        if (xdr->tail[0].iov_len) {
                result = kernel_sendpage(sock, rqstp->rq_respages[0],
                                             ((unsigned long)xdr->tail[0].iov_base)
-                                               & (PAGE_SIZE-1),
+                                               & (PAGE_SIZE-1),
                                             xdr->tail[0].iov_len, 0);
 
                if (result > 0)
@@ -520,7 +528,7 @@ svc_sock_names(char *buf, struct svc_serv *serv, char *toclose)
 
        if (!serv)
                return 0;
-       spin_lock(&serv->sv_lock);
+       spin_lock_bh(&serv->sv_lock);
        list_for_each_entry(svsk, &serv->sv_permsocks, sk_list) {
                int onelen = one_sock_name(buf+len, svsk);
                if (toclose && strcmp(toclose, buf+len) == 0)
@@ -528,12 +536,12 @@ svc_sock_names(char *buf, struct svc_serv *serv, char *toclose)
                else
                        len += onelen;
        }
-       spin_unlock(&serv->sv_lock);
+       spin_unlock_bh(&serv->sv_lock);
        if (closesk)
                /* Should unregister with portmap, but you cannot
                 * unregister just one protocol...
                 */
-               svc_delete_socket(closesk);
+               svc_close_socket(closesk);
        else if (toclose)
                return -ENOENT;
        return len;
@@ -683,6 +691,11 @@ svc_udp_recvfrom(struct svc_rqst *rqstp)
                return svc_deferred_recv(rqstp);
        }
 
+       if (test_bit(SK_CLOSE, &svsk->sk_flags)) {
+               svc_delete_socket(svsk);
+               return 0;
+       }
+
        clear_bit(SK_DATA, &svsk->sk_flags);
        while ((skb = skb_recv_datagram(svsk->sk_sk, 0, 1, &err)) == NULL) {
                if (err == -EAGAIN) {
@@ -698,7 +711,7 @@ svc_udp_recvfrom(struct svc_rqst *rqstp)
                tv.tv_sec = xtime.tv_sec;
                tv.tv_usec = xtime.tv_nsec / NSEC_PER_USEC;
                skb_set_timestamp(skb, &tv);
-               /* Don't enable netstamp, sunrpc doesn't 
+               /* Don't enable netstamp, sunrpc doesn't
                   need that much accuracy */
        }
        skb_get_timestamp(skb, &svsk->sk_sk->sk_stamp);
@@ -730,7 +743,7 @@ svc_udp_recvfrom(struct svc_rqst *rqstp)
                        return 0;
                }
                local_bh_enable();
-               skb_free_datagram(svsk->sk_sk, skb); 
+               skb_free_datagram(svsk->sk_sk, skb);
        } else {
                /* we can use it in-place */
                rqstp->rq_arg.head[0].iov_base = skb->data + sizeof(struct udphdr);
@@ -781,7 +794,7 @@ svc_udp_init(struct svc_sock *svsk)
        svsk->sk_sendto = svc_udp_sendto;
 
        /* initialise setting must have enough space to
-        * receive and respond to one request.  
+        * receive and respond to one request.
         * svc_udp_recvfrom will re-adjust if necessary
         */
        svc_sock_setbufsize(svsk->sk_sock,
@@ -910,7 +923,7 @@ svc_tcp_accept(struct svc_sock *svsk)
        if (ntohs(sin.sin_port) >= 1024) {
                dprintk(KERN_WARNING
                        "%s: connect from unprivileged port: %u.%u.%u.%u:%d\n",
-                       serv->sv_name, 
+                       serv->sv_name,
                        NIPQUAD(sin.sin_addr.s_addr), ntohs(sin.sin_port));
        }
 
@@ -1025,7 +1038,7 @@ svc_tcp_recvfrom(struct svc_rqst *rqstp)
                 * on the number of threads which will access the socket.
                 *
                 * rcvbuf just needs to be able to hold a few requests.
-                * Normally they will be removed from the queue 
+                * Normally they will be removed from the queue
                 * as soon a a complete request arrives.
                 */
                svc_sock_setbufsize(svsk->sk_sock,
@@ -1050,7 +1063,7 @@ svc_tcp_recvfrom(struct svc_rqst *rqstp)
 
                if (len < want) {
                        dprintk("svc: short recvfrom while reading record length (%d of %lu)\n",
-                               len, want);
+                               len, want);
                        svc_sock_received(svsk);
                        return -EAGAIN; /* record header not complete */
                }
@@ -1176,7 +1189,8 @@ svc_tcp_sendto(struct svc_rqst *rqstp)
                       rqstp->rq_sock->sk_server->sv_name,
                       (sent<0)?"got error":"sent only",
                       sent, xbufp->len);
-               svc_delete_socket(rqstp->rq_sock);
+               set_bit(SK_CLOSE, &rqstp->rq_sock->sk_flags);
+               svc_sock_enqueue(rqstp->rq_sock);
                sent = -EAGAIN;
        }
        return sent;
@@ -1207,7 +1221,7 @@ svc_tcp_init(struct svc_sock *svsk)
                tp->nonagle = 1;        /* disable Nagle's algorithm */
 
                /* initialise setting must have enough space to
-                * receive and respond to one request.  
+                * receive and respond to one request.
                 * svc_tcp_recvfrom will re-adjust if necessary
                 */
                svc_sock_setbufsize(svsk->sk_sock,
@@ -1216,7 +1230,7 @@ svc_tcp_init(struct svc_sock *svsk)
 
                set_bit(SK_CHNGBUF, &svsk->sk_flags);
                set_bit(SK_DATA, &svsk->sk_flags);
-               if (sk->sk_state != TCP_ESTABLISHED) 
+               if (sk->sk_state != TCP_ESTABLISHED)
                        set_bit(SK_CLOSE, &svsk->sk_flags);
        }
 }
@@ -1232,7 +1246,7 @@ svc_sock_update_bufs(struct svc_serv *serv)
 
        spin_lock_bh(&serv->sv_lock);
        list_for_each(le, &serv->sv_permsocks) {
-               struct svc_sock *svsk = 
+               struct svc_sock *svsk =
                        list_entry(le, struct svc_sock, sk_list);
                set_bit(SK_CHNGBUF, &svsk->sk_flags);
        }
@@ -1264,11 +1278,11 @@ svc_recv(struct svc_rqst *rqstp, long timeout)
                rqstp, timeout);
 
        if (rqstp->rq_sock)
-               printk(KERN_ERR 
+               printk(KERN_ERR
                        "svc_recv: service %p, socket not NULL!\n",
                         rqstp);
        if (waitqueue_active(&rqstp->rq_wait))
-               printk(KERN_ERR 
+               printk(KERN_ERR
                        "svc_recv: service %p, wait queue active!\n",
                         rqstp);
 
@@ -1357,7 +1371,7 @@ svc_recv(struct svc_rqst *rqstp, long timeout)
        return len;
 }
 
-/* 
+/*
  * Drop request
  */
 void
@@ -1495,7 +1509,7 @@ svc_setup_socket(struct svc_serv *serv, struct socket *sock,
        svsk->sk_odata = inet->sk_data_ready;
        svsk->sk_owspace = inet->sk_write_space;
        svsk->sk_server = serv;
-       atomic_set(&svsk->sk_inuse, 0);
+       atomic_set(&svsk->sk_inuse, 1);
        svsk->sk_lastrecv = get_seconds();
        spin_lock_init(&svsk->sk_defer_lock);
        INIT_LIST_HEAD(&svsk->sk_deferred);
@@ -1618,7 +1632,7 @@ bummer:
 /*
  * Remove a dead socket
  */
-void
+static void
 svc_delete_socket(struct svc_sock *svsk)
 {
        struct svc_serv *serv;
@@ -1637,23 +1651,33 @@ svc_delete_socket(struct svc_sock *svsk)
 
        if (!test_and_set_bit(SK_DETACHED, &svsk->sk_flags))
                list_del_init(&svsk->sk_list);
-       /*
+       /*
         * We used to delete the svc_sock from whichever list
         * it's sk_ready node was on, but we don't actually
         * need to.  This is because the only time we're called
         * while still attached to a queue, the queue itself
         * is about to be destroyed (in svc_destroy).
         */
-       if (!test_and_set_bit(SK_DEAD, &svsk->sk_flags))
+       if (!test_and_set_bit(SK_DEAD, &svsk->sk_flags)) {
+               BUG_ON(atomic_read(&svsk->sk_inuse)<2);
+               atomic_dec(&svsk->sk_inuse);
                if (test_bit(SK_TEMP, &svsk->sk_flags))
                        serv->sv_tmpcnt--;
+       }
 
-       /* This atomic_inc should be needed - svc_delete_socket
-        * should have the semantic of dropping a reference.
-        * But it doesn't yet....
-        */
-       atomic_inc(&svsk->sk_inuse);
        spin_unlock_bh(&serv->sv_lock);
+}
+
+void svc_close_socket(struct svc_sock *svsk)
+{
+       set_bit(SK_CLOSE, &svsk->sk_flags);
+       if (test_and_set_bit(SK_BUSY, &svsk->sk_flags))
+               /* someone else will have to effect the close */
+               return;
+
+       atomic_inc(&svsk->sk_inuse);
+       svc_delete_socket(svsk);
+       clear_bit(SK_BUSY, &svsk->sk_flags);
        svc_sock_put(svsk);
 }
 
@@ -1673,7 +1697,7 @@ svc_makesock(struct svc_serv *serv, int protocol, unsigned short port)
 }
 
 /*
- * Handle defer and revisit of requests 
+ * Handle defer and revisit of requests
  */
 
 static void svc_revisit(struct cache_deferred_req *dreq, int too_many)
@@ -1752,7 +1776,7 @@ static int svc_deferred_recv(struct svc_rqst *rqstp)
 static struct svc_deferred_req *svc_deferred_dequeue(struct svc_sock *svsk)
 {
        struct svc_deferred_req *dr = NULL;
-       
+
        if (!test_bit(SK_DEFERRED, &svsk->sk_flags))
                return NULL;
        spin_lock_bh(&svsk->sk_defer_lock);
index 82b27528d0c45b50b2b25416b84b9f03b1d6ac74..47d8df2b5eb2a94bf378704a748555efdcc86221 100644 (file)
@@ -42,7 +42,7 @@ rpc_register_sysctl(void)
                        sunrpc_table[0].de->owner = THIS_MODULE;
 #endif
        }
-                       
+
 }
 
 void
@@ -126,7 +126,7 @@ static ctl_table debug_table[] = {
                .maxlen         = sizeof(int),
                .mode           = 0644,
                .proc_handler   = &proc_dodebug
-       }, 
+       },
        {
                .ctl_name       = CTL_NFSDEBUG,
                .procname       = "nfs_debug",
@@ -134,7 +134,7 @@ static ctl_table debug_table[] = {
                .maxlen         = sizeof(int),
                .mode           = 0644,
                .proc_handler   = &proc_dodebug
-       }, 
+       },
        {
                .ctl_name       = CTL_NFSDDEBUG,
                .procname       = "nfsd_debug",
@@ -142,7 +142,7 @@ static ctl_table debug_table[] = {
                .maxlen         = sizeof(int),
                .mode           = 0644,
                .proc_handler   = &proc_dodebug
-       }, 
+       },
        {
                .ctl_name       = CTL_NLMDEBUG,
                .procname       = "nlm_debug",
@@ -150,7 +150,7 @@ static ctl_table debug_table[] = {
                .maxlen         = sizeof(int),
                .mode           = 0644,
                .proc_handler   = &proc_dodebug
-       }, 
+       },
        { .ctl_name = 0 }
 };
 
index a0af250ca319752a6c940ff6be4ef7beebc937f2..6a59180e166718d309f7a2f98df0bb7fc31852d7 100644 (file)
@@ -302,7 +302,7 @@ _copy_from_pages(char *p, struct page **pages, size_t pgbase, size_t len)
  * @buf: xdr_buf
  * @len: bytes to remove from buf->head[0]
  *
- * Shrinks XDR buffer's header kvec buf->head[0] by 
+ * Shrinks XDR buffer's header kvec buf->head[0] by
  * 'len' bytes. The extra data is not lost, but is instead
  * moved into the inlined pages and/or the tail.
  */
@@ -375,7 +375,7 @@ xdr_shrink_bufhead(struct xdr_buf *buf, size_t len)
  * @buf: xdr_buf
  * @len: bytes to remove from buf->pages
  *
- * Shrinks XDR buffer's page array buf->pages by 
+ * Shrinks XDR buffer's page array buf->pages by
  * 'len' bytes. The extra data is not lost, but is instead
  * moved into the tail.
  */
@@ -1024,7 +1024,7 @@ xdr_encode_array2(struct xdr_buf *buf, unsigned int base,
 
 int
 xdr_process_buf(struct xdr_buf *buf, unsigned int offset, unsigned int len,
-                int (*actor)(struct scatterlist *, void *), void *data)
+               int (*actor)(struct scatterlist *, void *), void *data)
 {
        int i, ret = 0;
        unsigned page_len, thislen, page_offset;
index 7a3999f0a4a2aabc7e156bdb459a68a5cab7d6a7..e7c71a1ea3d46dbcee26f25a49bfeb93bda6bb57 100644 (file)
@@ -410,7 +410,7 @@ void xprt_set_retrans_timeout_def(struct rpc_task *task)
 /*
  * xprt_set_retrans_timeout_rtt - set a request's retransmit timeout
  * @task: task whose timeout is to be set
- * 
+ *
  * Set a request's retransmit timeout using the RTT estimator.
  */
 void xprt_set_retrans_timeout_rtt(struct rpc_task *task)
@@ -873,7 +873,7 @@ void xprt_release(struct rpc_task *task)
  */
 void xprt_set_timeout(struct rpc_timeout *to, unsigned int retr, unsigned long incr)
 {
-       to->to_initval   = 
+       to->to_initval   =
        to->to_increment = incr;
        to->to_maxval    = to->to_initval + (incr * retr);
        to->to_retries   = retr;
index 0be25e175b935641cf889695c40f7d1d545e0eef..e5207a11edf64d36fd4a44bc8e9212425b1bf57f 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * net/tipc/addr.c: TIPC address utility routines
- *     
+ *
  * Copyright (c) 2000-2006, Ericsson AB
  * Copyright (c) 2004-2005, Wind River Systems
  * All rights reserved.
@@ -48,10 +48,10 @@ u32 tipc_get_addr(void)
 
 /**
  * tipc_addr_domain_valid - validates a network domain address
- * 
- * Accepts <Z.C.N>, <Z.C.0>, <Z.0.0>, and <0.0.0>, 
+ *
+ * Accepts <Z.C.N>, <Z.C.0>, <Z.0.0>, and <0.0.0>,
  * where Z, C, and N are non-zero and do not exceed the configured limits.
- * 
+ *
  * Returns 1 if domain address is valid, otherwise 0
  */
 
@@ -80,10 +80,10 @@ int tipc_addr_domain_valid(u32 addr)
 
 /**
  * tipc_addr_node_valid - validates a proposed network address for this node
- * 
- * Accepts <Z.C.N>, where Z, C, and N are non-zero and do not exceed 
+ *
+ * Accepts <Z.C.N>, where Z, C, and N are non-zero and do not exceed
  * the configured limits.
- * 
+ *
  * Returns 1 if address can be used, otherwise 0
  */
 
index bcfebb3cbbf319f31e8c6bd4af45e7688c1c13bf..e4bd5335e48d9eb64bdd9d5b1bf899ce7a8ec8d9 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * net/tipc/addr.h: Include file for TIPC address utility routines
- * 
+ *
  * Copyright (c) 2000-2006, Ericsson AB
  * Copyright (c) 2004-2005, Wind River Systems
  * All rights reserved.
@@ -100,8 +100,8 @@ static inline int addr_scope(u32 domain)
 
 /**
  * addr_domain - convert 2-bit scope value to equivalent message lookup domain
- *  
- * Needed when address of a named message must be looked up a second time 
+ *
+ * Needed when address of a named message must be looked up a second time
  * after a network hop.
  */
 
index 730c5c47ed8d4b67b465caba2dc9768d514e3f87..e7880172ef19275db1e9f0e9c7d94fdc1e1a51e9 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * net/tipc/bcast.c: TIPC broadcast code
- *     
+ *
  * Copyright (c) 2004-2006, Ericsson AB
  * Copyright (c) 2004, Intel Corporation.
  * Copyright (c) 2005, Wind River Systems
  * Loss rate for incoming broadcast frames; used to test retransmission code.
  * Set to N to cause every N'th frame to be discarded; 0 => don't discard any.
  */
+
 #define TIPC_BCAST_LOSS_RATE 0
 
 /**
  * struct bcbearer_pair - a pair of bearers used by broadcast link
  * @primary: pointer to primary bearer
  * @secondary: pointer to secondary bearer
- * 
- * Bearers must have same priority and same set of reachable destinations 
+ *
+ * Bearers must have same priority and same set of reachable destinations
  * to be paired.
  */
 
@@ -84,7 +84,7 @@ struct bcbearer_pair {
  * @bpairs_temp: temporary array of bearer pairs used by tipc_bcbearer_sort()
  * @remains: temporary node map used by tipc_bcbearer_send()
  * @remains_new: temporary node map used tipc_bcbearer_send()
- * 
+ *
  * Note: The fields labelled "temporary" are incorporated into the bearer
  * to avoid consuming potentially limited stack space through the use of
  * large local variables within multicast routines.  Concurrent access is
@@ -104,7 +104,7 @@ struct bcbearer {
  * struct bclink - link used for broadcast messages
  * @link: (non-standard) broadcast link structure
  * @node: (non-standard) node structure representing b'cast link's peer node
- * 
+ *
  * Handles sequence numbering, fragmentation, bundling, etc.
  */
 
@@ -125,7 +125,7 @@ char tipc_bclink_name[] = "multicast-link";
 static u32 buf_seqno(struct sk_buff *buf)
 {
        return msg_seqno(buf_msg(buf));
-} 
+}
 
 static u32 bcbuf_acks(struct sk_buff *buf)
 {
@@ -143,9 +143,9 @@ static void bcbuf_decr_acks(struct sk_buff *buf)
 }
 
 
-/** 
+/**
  * bclink_set_gap - set gap according to contents of current deferred pkt queue
- * 
+ *
  * Called with 'node' locked, bc_lock unlocked
  */
 
@@ -159,14 +159,14 @@ static void bclink_set_gap(struct node *n_ptr)
                n_ptr->bclink.gap_to = mod(buf_seqno(buf) - 1);
 }
 
-/** 
+/**
  * bclink_ack_allowed - test if ACK or NACK message can be sent at this moment
- * 
+ *
  * This mechanism endeavours to prevent all nodes in network from trying
  * to ACK or NACK at the same time.
- * 
+ *
  * Note: TIPC uses a different trigger to distribute ACKs than it does to
- *       distribute NACKs, but tries to use the same spacing (divide by 16). 
+ *       distribute NACKs, but tries to use the same spacing (divide by 16).
  */
 
 static int bclink_ack_allowed(u32 n)
@@ -175,11 +175,11 @@ static int bclink_ack_allowed(u32 n)
 }
 
 
-/** 
+/**
  * bclink_retransmit_pkt - retransmit broadcast packets
  * @after: sequence number of last packet to *not* retransmit
  * @to: sequence number of last packet to retransmit
- * 
+ *
  * Called with bc_lock locked
  */
 
@@ -189,16 +189,16 @@ static void bclink_retransmit_pkt(u32 after, u32 to)
 
        buf = bcl->first_out;
        while (buf && less_eq(buf_seqno(buf), after)) {
-               buf = buf->next;                
+               buf = buf->next;
        }
        tipc_link_retransmit(bcl, buf, mod(to - after));
 }
 
-/** 
+/**
  * tipc_bclink_acknowledge - handle acknowledgement of broadcast packets
  * @n_ptr: node that sent acknowledgement info
  * @acked: broadcast sequence # that has been acknowledged
- * 
+ *
  * Node is locked, bc_lock unlocked.
  */
 
@@ -244,9 +244,9 @@ void tipc_bclink_acknowledge(struct node *n_ptr, u32 acked)
        spin_unlock_bh(&bc_lock);
 }
 
-/** 
+/**
  * bclink_send_ack - unicast an ACK msg
- * 
+ *
  * tipc_net_lock and node lock set
  */
 
@@ -258,9 +258,9 @@ static void bclink_send_ack(struct node *n_ptr)
                tipc_link_send_proto_msg(l_ptr, STATE_MSG, 0, 0, 0, 0, 0);
 }
 
-/** 
+/**
  * bclink_send_nack- broadcast a NACK msg
- * 
+ *
  * tipc_net_lock and node lock set
  */
 
@@ -278,7 +278,7 @@ static void bclink_send_nack(struct node *n_ptr)
                msg_init(msg, BCAST_PROTOCOL, STATE_MSG,
                         TIPC_OK, INT_H_SIZE, n_ptr->addr);
                msg_set_mc_netid(msg, tipc_net_id);
-               msg_set_bcast_ack(msg, mod(n_ptr->bclink.last_in)); 
+               msg_set_bcast_ack(msg, mod(n_ptr->bclink.last_in));
                msg_set_bcgap_after(msg, n_ptr->bclink.gap_after);
                msg_set_bcgap_to(msg, n_ptr->bclink.gap_to);
                msg_set_bcast_tag(msg, tipc_own_tag);
@@ -292,17 +292,17 @@ static void bclink_send_nack(struct node *n_ptr)
                        bcl->stats.bearer_congs++;
                }
 
-               /* 
+               /*
                 * Ensure we doesn't send another NACK msg to the node
                 * until 16 more deferred messages arrive from it
                 * (i.e. helps prevent all nodes from NACK'ing at same time)
                 */
-               
+
                n_ptr->bclink.nack_sync = tipc_own_tag;
        }
 }
 
-/** 
+/**
  * tipc_bclink_check_gap - send a NACK if a sequence gap exists
  *
  * tipc_net_lock and node lock set
@@ -320,9 +320,9 @@ void tipc_bclink_check_gap(struct node *n_ptr, u32 last_sent)
        bclink_send_nack(n_ptr);
 }
 
-/** 
+/**
  * tipc_bclink_peek_nack - process a NACK msg meant for another node
- * 
+ *
  * Only tipc_net_lock set.
  */
 
@@ -349,7 +349,7 @@ static void tipc_bclink_peek_nack(u32 dest, u32 sender_tag, u32 gap_after, u32 g
                if (less_eq(my_to, gap_to))
                        n_ptr->bclink.gap_to = gap_after;
        } else {
-               /* 
+               /*
                 * Expand gap if missing bufs not in deferred queue:
                 */
                struct sk_buff *buf = n_ptr->bclink.deferred_head;
@@ -371,7 +371,7 @@ static void tipc_bclink_peek_nack(u32 dest, u32 sender_tag, u32 gap_after, u32 g
        }
        /*
         * Some nodes may send a complementary NACK now:
-        */ 
+        */
        if (bclink_ack_allowed(sender_tag + 1)) {
                if (n_ptr->bclink.gap_to != n_ptr->bclink.gap_after) {
                        bclink_send_nack(n_ptr);
@@ -408,7 +408,7 @@ int tipc_bclink_send_msg(struct sk_buff *buf)
 
 /**
  * tipc_bclink_recv_pkt - receive a broadcast packet, and deliver upwards
- * 
+ *
  * tipc_net_lock is read_locked, no other locks set
  */
 
@@ -425,7 +425,7 @@ void tipc_bclink_recv_pkt(struct sk_buff *buf)
 
        msg_dbg(msg, "<BC<<<");
 
-       if (unlikely(!node || !tipc_node_is_up(node) || !node->bclink.supported || 
+       if (unlikely(!node || !tipc_node_is_up(node) || !node->bclink.supported ||
                     (msg_mc_netid(msg) != tipc_net_id))) {
                buf_discard(buf);
                return;
@@ -443,7 +443,7 @@ void tipc_bclink_recv_pkt(struct sk_buff *buf)
                        bclink_retransmit_pkt(msg_bcgap_after(msg),
                                              msg_bcgap_to(msg));
                        bcl->owner->next = NULL;
-                       spin_unlock_bh(&bc_lock);              
+                       spin_unlock_bh(&bc_lock);
                } else {
                        tipc_bclink_peek_nack(msg_destnode(msg),
                                              msg_bcast_tag(msg),
@@ -547,10 +547,10 @@ u32 tipc_bclink_acks_missing(struct node *n_ptr)
 
 /**
  * tipc_bcbearer_send - send a packet through the broadcast pseudo-bearer
- * 
+ *
  * Send through as many bearers as necessary to reach all nodes
  * that support TIPC multicasting.
- * 
+ *
  * Returns 0 if packet sent successfully, non-zero if not
  */
 
@@ -581,7 +581,7 @@ static int tipc_bcbearer_send(struct sk_buff *buf,
                send_count = 0;
 
        /* Send buffer over bearers until all targets reached */
-       
+
        bcbearer->remains = tipc_cltr_bcast_nodes;
 
        for (bp_index = 0; bp_index < MAX_BEARERS; bp_index++) {
@@ -615,7 +615,7 @@ update:
 
                bcbearer->remains = bcbearer->remains_new;
        }
-       
+
        /* Unable to reach all targets */
 
        bcbearer->bearer.publ.blocked = 1;
@@ -682,7 +682,7 @@ void tipc_bcbearer_sort(void)
 
 /**
  * tipc_bcbearer_push - resolve bearer congestion
- * 
+ *
  * Forces bclink to push out any unsent packets, until all packets are gone
  * or congestion reoccurs.
  * No locks set when function called
@@ -714,27 +714,27 @@ int tipc_bclink_stats(char *buf, const u32 buf_size)
        spin_lock_bh(&bc_lock);
 
        tipc_printf(&pb, "Link <%s>\n"
-                        "  Window:%u packets\n", 
+                        "  Window:%u packets\n",
                    bcl->name, bcl->queue_limit[0]);
-       tipc_printf(&pb, "  RX packets:%u fragments:%u/%u bundles:%u/%u\n", 
+       tipc_printf(&pb, "  RX packets:%u fragments:%u/%u bundles:%u/%u\n",
                    bcl->stats.recv_info,
                    bcl->stats.recv_fragments,
                    bcl->stats.recv_fragmented,
                    bcl->stats.recv_bundles,
                    bcl->stats.recv_bundled);
-       tipc_printf(&pb, "  TX packets:%u fragments:%u/%u bundles:%u/%u\n", 
+       tipc_printf(&pb, "  TX packets:%u fragments:%u/%u bundles:%u/%u\n",
                    bcl->stats.sent_info,
                    bcl->stats.sent_fragments,
-                   bcl->stats.sent_fragmented, 
+                   bcl->stats.sent_fragmented,
                    bcl->stats.sent_bundles,
                    bcl->stats.sent_bundled);
-       tipc_printf(&pb, "  RX naks:%u defs:%u dups:%u\n", 
+       tipc_printf(&pb, "  RX naks:%u defs:%u dups:%u\n",
                    bcl->stats.recv_nacks,
-                   bcl->stats.deferred_recv, 
+                   bcl->stats.deferred_recv,
                    bcl->stats.duplicates);
-       tipc_printf(&pb, "  TX naks:%u acks:%u dups:%u\n", 
-                   bcl->stats.sent_nacks, 
-                   bcl->stats.sent_acks, 
+       tipc_printf(&pb, "  TX naks:%u acks:%u dups:%u\n",
+                   bcl->stats.sent_nacks,
+                   bcl->stats.sent_acks,
                    bcl->stats.retransmitted);
        tipc_printf(&pb, "  Congestion bearer:%u link:%u  Send queue max:%u avg:%u\n",
                    bcl->stats.bearer_congs,
@@ -778,7 +778,7 @@ int tipc_bclink_init(void)
        bclink = kzalloc(sizeof(*bclink), GFP_ATOMIC);
        if (!bcbearer || !bclink) {
  nomem:
-               warn("Multicast link creation failed, no memory\n");
+               warn("Multicast link creation failed, no memory\n");
                kfree(bcbearer);
                bcbearer = NULL;
                kfree(bclink);
@@ -796,7 +796,7 @@ int tipc_bclink_init(void)
        bcl->next_out_no = 1;
        spin_lock_init(&bclink->node.lock);
        bcl->owner = &bclink->node;
-        bcl->max_pkt = MAX_PKT_DEFAULT_MCAST;
+       bcl->max_pkt = MAX_PKT_DEFAULT_MCAST;
        tipc_link_set_queue_limits(bcl, BCLINK_WIN_DEFAULT);
        bcl->b_ptr = &bcbearer->bearer;
        bcl->state = WORKING_WORKING;
index b243d9d495f0588382f13272f30c3cb45c8067c2..f910ed29d05570172223da5070a0aefa1e772df5 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * net/tipc/bcast.h: Include file for TIPC broadcast code
- * 
+ *
  * Copyright (c) 2003-2006, Ericsson AB
  * Copyright (c) 2005, Wind River Systems
  * All rights reserved.
@@ -102,7 +102,7 @@ static inline void tipc_nmap_add(struct node_map *nm_ptr, u32 node)
        }
 }
 
-/** 
+/**
  * nmap_remove - remove a node from a node map
  */
 
@@ -190,7 +190,7 @@ static inline void tipc_port_list_add(struct port_list *pl_ptr, u32 port)
 
 /**
  * port_list_free - free dynamically created entries in port_list chain
- * 
+ *
  * Note: First item is on stack, so it doesn't need to be released
  */
 
index 39744a33bd3693864997d6ec2d1d2339f2f2eb48..271a375b49b74ab10395ca08555801f5cf0b0f46 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * net/tipc/bearer.c: TIPC bearer code
- * 
+ *
  * Copyright (c) 1996-2006, Ericsson AB
  * Copyright (c) 2004-2006, Wind River Systems
  * All rights reserved.
@@ -52,7 +52,7 @@ struct bearer *tipc_bearers = NULL;
 
 /**
  * media_name_valid - validate media name
- * 
+ *
  * Returns 1 if media name is valid, otherwise 0.
  */
 
@@ -84,17 +84,17 @@ static struct media *media_find(const char *name)
 
 /**
  * tipc_register_media - register a media type
- * 
+ *
  * Bearers for this media type must be activated separately at a later stage.
  */
 
 int  tipc_register_media(u32 media_type,
-                        char *name, 
-                        int (*enable)(struct tipc_bearer *), 
-                        void (*disable)(struct tipc_bearer *), 
-                        int (*send_msg)(struct sk_buff *, 
+                        char *name,
+                        int (*enable)(struct tipc_bearer *),
+                        void (*disable)(struct tipc_bearer *),
+                        int (*send_msg)(struct sk_buff *,
                                         struct tipc_bearer *,
-                                        struct tipc_media_addr *), 
+                                        struct tipc_media_addr *),
                         char *(*addr2str)(struct tipc_media_addr *a,
                                           char *str_buf, int str_size),
                         struct tipc_media_addr *bcast_addr,
@@ -121,11 +121,11 @@ int  tipc_register_media(u32 media_type,
        }
        if ((bearer_priority < TIPC_MIN_LINK_PRI) &&
            (bearer_priority > TIPC_MAX_LINK_PRI)) {
-               warn("Media <%s> rejected, illegal priority (%u)\n", name, 
+               warn("Media <%s> rejected, illegal priority (%u)\n", name,
                     bearer_priority);
                goto exit;
        }
-       if ((link_tolerance < TIPC_MIN_LINK_TOL) || 
+       if ((link_tolerance < TIPC_MIN_LINK_TOL) ||
            (link_tolerance > TIPC_MAX_LINK_TOL)) {
                warn("Media <%s> rejected, illegal tolerance (%u)\n", name,
                     link_tolerance);
@@ -219,7 +219,7 @@ struct sk_buff *tipc_media_get_names(void)
 
        read_lock_bh(&tipc_net_lock);
        for (i = 0, m_ptr = media_list; i < media_count; i++, m_ptr++) {
-               tipc_cfg_append_tlv(buf, TIPC_TLV_MEDIA_NAME, m_ptr->name, 
+               tipc_cfg_append_tlv(buf, TIPC_TLV_MEDIA_NAME, m_ptr->name,
                                    strlen(m_ptr->name) + 1);
        }
        read_unlock_bh(&tipc_net_lock);
@@ -230,11 +230,11 @@ struct sk_buff *tipc_media_get_names(void)
  * bearer_name_validate - validate & (optionally) deconstruct bearer name
  * @name - ptr to bearer name string
  * @name_parts - ptr to area for bearer name components (or NULL if not needed)
- * 
+ *
  * Returns 1 if bearer name is valid, otherwise 0.
  */
 
-static int bearer_name_validate(const char *name, 
+static int bearer_name_validate(const char *name,
                                struct bearer_name *name_parts)
 {
        char name_copy[TIPC_MAX_BEARER_NAME];
@@ -262,8 +262,8 @@ static int bearer_name_validate(const char *name,
 
        /* validate component parts of bearer name */
 
-       if ((media_len <= 1) || (media_len > TIPC_MAX_MEDIA_NAME) || 
-           (if_len <= 1) || (if_len > TIPC_MAX_IF_NAME) || 
+       if ((media_len <= 1) || (media_len > TIPC_MAX_MEDIA_NAME) ||
+           (if_len <= 1) || (if_len > TIPC_MAX_IF_NAME) ||
            (strspn(media_name, tipc_alphabet) != (media_len - 1)) ||
            (strspn(if_name, tipc_alphabet) != (if_len - 1)))
                return 0;
@@ -336,8 +336,8 @@ struct sk_buff *tipc_bearer_get_names(void)
                for (j = 0; j < MAX_BEARERS; j++) {
                        b_ptr = &tipc_bearers[j];
                        if (b_ptr->active && (b_ptr->media == m_ptr)) {
-                               tipc_cfg_append_tlv(buf, TIPC_TLV_BEARER_NAME, 
-                                                   b_ptr->publ.name, 
+                               tipc_cfg_append_tlv(buf, TIPC_TLV_BEARER_NAME,
+                                                   b_ptr->publ.name,
                                                    strlen(b_ptr->publ.name) + 1);
                        }
                }
@@ -401,8 +401,8 @@ void tipc_bearer_lock_push(struct bearer *b_ptr)
 
 
 /*
- * Interrupt enabling new requests after bearer congestion or blocking:    
- * See bearer_send().   
+ * Interrupt enabling new requests after bearer congestion or blocking:
+ * See bearer_send().
  */
 void tipc_continue(struct tipc_bearer *tb_ptr)
 {
@@ -417,9 +417,9 @@ void tipc_continue(struct tipc_bearer *tb_ptr)
 }
 
 /*
- * Schedule link for sending of messages after the bearer 
- * has been deblocked by 'continue()'. This method is called 
- * when somebody tries to send a message via this link while 
+ * Schedule link for sending of messages after the bearer
+ * has been deblocked by 'continue()'. This method is called
+ * when somebody tries to send a message via this link while
  * the bearer is congested. 'tipc_net_lock' is in read_lock here
  * bearer.lock is busy
  */
@@ -430,9 +430,9 @@ static void tipc_bearer_schedule_unlocked(struct bearer *b_ptr, struct link *l_p
 }
 
 /*
- * Schedule link for sending of messages after the bearer 
- * has been deblocked by 'continue()'. This method is called 
- * when somebody tries to send a message via this link while 
+ * Schedule link for sending of messages after the bearer
+ * has been deblocked by 'continue()'. This method is called
+ * when somebody tries to send a message via this link while
  * the bearer is congested. 'tipc_net_lock' is in read_lock here,
  * bearer.lock is free
  */
@@ -468,7 +468,7 @@ int tipc_bearer_resolve_congestion(struct bearer *b_ptr, struct link *l_ptr)
 
 /**
  * tipc_enable_bearer - enable bearer with the given name
- */              
+ */
 
 int tipc_enable_bearer(const char *name, u32 bcast_scope, u32 priority)
 {
@@ -490,7 +490,7 @@ int tipc_enable_bearer(const char *name, u32 bcast_scope, u32 priority)
                warn("Bearer <%s> rejected, illegal name\n", name);
                return -EINVAL;
        }
-       if (!tipc_addr_domain_valid(bcast_scope) || 
+       if (!tipc_addr_domain_valid(bcast_scope) ||
            !in_scope(bcast_scope, tipc_own_addr)) {
                warn("Bearer <%s> rejected, illegal broadcast scope\n", name);
                return -EINVAL;
@@ -539,7 +539,7 @@ restart:
                }
        }
        if (bearer_id >= MAX_BEARERS) {
-               warn("Bearer <%s> rejected, bearer limit reached (%u)\n", 
+               warn("Bearer <%s> rejected, bearer limit reached (%u)\n",
                     name, MAX_BEARERS);
                goto failed;
        }
@@ -612,7 +612,7 @@ int tipc_block_bearer(const char *name)
 
 /**
  * bearer_disable -
- * 
+ *
  * Note: This routine assumes caller holds tipc_net_lock.
  */
 
index c4e7c1c3655b84dba596da999a71ea69fb7bf775..6a36b6600e6c79c7c827eca58061de84e1f7f754 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * net/tipc/bearer.h: Include file for TIPC bearer code
- * 
+ *
  * Copyright (c) 1996-2006, Ericsson AB
  * Copyright (c) 2005, Wind River Systems
  * All rights reserved.
  * @type_id: TIPC media identifier [defined in tipc_bearer.h]
  * @name: media name
  */
+
 struct media {
-       int (*send_msg)(struct sk_buff *buf, 
+       int (*send_msg)(struct sk_buff *buf,
                        struct tipc_bearer *b_ptr,
                        struct tipc_media_addr *dest);
        int (*enable_bearer)(struct tipc_bearer *b_ptr);
        void (*disable_bearer)(struct tipc_bearer *b_ptr);
-       char *(*addr2str)(struct tipc_media_addr *a, 
+       char *(*addr2str)(struct tipc_media_addr *a,
                          char *str_buf, int str_size);
        struct tipc_media_addr bcast_addr;
        int bcast;
@@ -91,7 +91,7 @@ struct media {
  * @net_plane: network plane ('A' through 'H') currently associated with bearer
  * @nodes: indicates which nodes in cluster can be reached through bearer
  */
+
 struct bearer {
        struct tipc_bearer publ;
        struct media *media;
@@ -131,21 +131,21 @@ void tipc_bearer_lock_push(struct bearer *b_ptr);
 
 
 /**
- * tipc_bearer_send- sends buffer to destination over bearer 
- * 
+ * tipc_bearer_send- sends buffer to destination over bearer
+ *
  * Returns true (1) if successful, or false (0) if unable to send
- * 
+ *
  * IMPORTANT:
  * The media send routine must not alter the buffer being passed in
  * as it may be needed for later retransmission!
- * 
- * If the media send routine returns a non-zero value (indicating that 
+ *
+ * If the media send routine returns a non-zero value (indicating that
  * it was unable to send the buffer), it must:
  *   1) mark the bearer as blocked,
  *   2) call tipc_continue() once the bearer is able to send again.
  * Media types that are unable to meet these two critera must ensure their
  * send routine always returns success -- even if the buffer was not sent --
- * and let TIPC's link code deal with the undelivered message. 
+ * and let TIPC's link code deal with the undelivered message.
  */
 
 static inline int tipc_bearer_send(struct bearer *b_ptr, struct sk_buff *buf,
index b46b5188a9fd77d01bebd8ed5c481b5b5e1fcfc9..95b373913aa0dd21ae33a73dc730b92fd2e5c2fa 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * net/tipc/cluster.c: TIPC cluster management routines
- * 
+ *
  * Copyright (c) 2000-2006, Ericsson AB
  * Copyright (c) 2005, Wind River Systems
  * All rights reserved.
@@ -56,7 +56,7 @@ struct cluster *tipc_cltr_create(u32 addr)
 {
        struct _zone *z_ptr;
        struct cluster *c_ptr;
-       int max_nodes; 
+       int max_nodes;
 
        c_ptr = kzalloc(sizeof(*c_ptr), GFP_ATOMIC);
        if (c_ptr == NULL) {
@@ -81,7 +81,7 @@ struct cluster *tipc_cltr_create(u32 addr)
                tipc_local_nodes = c_ptr->nodes;
        c_ptr->highest_slave = LOWEST_SLAVE - 1;
        c_ptr->highest_node = 0;
-       
+
        z_ptr = tipc_zone_find(tipc_zone(addr));
        if (!z_ptr) {
                z_ptr = tipc_zone_create(addr);
@@ -150,7 +150,7 @@ void tipc_cltr_attach_node(struct cluster *c_ptr, struct node *n_ptr)
 
 /**
  * tipc_cltr_select_router - select router to a cluster
- * 
+ *
  * Uses deterministic and fair algorithm.
  */
 
@@ -192,7 +192,7 @@ u32 tipc_cltr_select_router(struct cluster *c_ptr, u32 ref)
 
 /**
  * tipc_cltr_select_node - select destination node within a remote cluster
- * 
+ *
  * Uses deterministic and fair algorithm.
  */
 
@@ -295,7 +295,7 @@ void tipc_cltr_send_slave_routes(struct cluster *c_ptr, u32 dest)
                msg_set_remote_node(msg, c_ptr->addr);
                msg_set_type(msg, SLAVE_ROUTING_TABLE);
                for (n_num = LOWEST_SLAVE; n_num <= highest; n_num++) {
-                       if (c_ptr->nodes[n_num] && 
+                       if (c_ptr->nodes[n_num] &&
                            tipc_node_has_active_links(c_ptr->nodes[n_num])) {
                                send = 1;
                                msg_set_dataoctet(msg, n_num);
@@ -329,7 +329,7 @@ void tipc_cltr_send_ext_routes(struct cluster *c_ptr, u32 dest)
                msg_set_remote_node(msg, c_ptr->addr);
                msg_set_type(msg, EXT_ROUTING_TABLE);
                for (n_num = 1; n_num <= highest; n_num++) {
-                       if (c_ptr->nodes[n_num] && 
+                       if (c_ptr->nodes[n_num] &&
                            tipc_node_has_active_links(c_ptr->nodes[n_num])) {
                                send = 1;
                                msg_set_dataoctet(msg, n_num);
@@ -360,7 +360,7 @@ void tipc_cltr_send_local_routes(struct cluster *c_ptr, u32 dest)
                msg_set_remote_node(msg, c_ptr->addr);
                msg_set_type(msg, LOCAL_ROUTING_TABLE);
                for (n_num = 1; n_num <= highest; n_num++) {
-                       if (c_ptr->nodes[n_num] && 
+                       if (c_ptr->nodes[n_num] &&
                            tipc_node_has_active_links(c_ptr->nodes[n_num])) {
                                send = 1;
                                msg_set_dataoctet(msg, n_num);
@@ -492,7 +492,7 @@ void tipc_cltr_remove_as_router(struct cluster *c_ptr, u32 router)
 }
 
 /**
- * tipc_cltr_multicast - multicast message to local nodes 
+ * tipc_cltr_multicast - multicast message to local nodes
  */
 
 static void tipc_cltr_multicast(struct cluster *c_ptr, struct sk_buff *buf,
@@ -554,9 +554,9 @@ void tipc_cltr_broadcast(struct sk_buff *buf)
                                        buf_copy = skb_copy(buf, GFP_ATOMIC);
                                        if (buf_copy == NULL)
                                                goto exit;
-                                       msg_set_destnode(buf_msg(buf_copy), 
+                                       msg_set_destnode(buf_msg(buf_copy),
                                                         n_ptr->addr);
-                                       tipc_link_send(buf_copy, n_ptr->addr, 
+                                       tipc_link_send(buf_copy, n_ptr->addr,
                                                       n_ptr->addr);
                                }
                        }
index 1b4cd309495ae9eac69f995269735c9ab7d69c8d..62df074afaecf8a5912b5b9a25a0779a391b8da8 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * net/tipc/cluster.h: Include file for TIPC cluster management routines
- * 
+ *
  * Copyright (c) 2000-2006, Ericsson AB
  * Copyright (c) 2005, Wind River Systems
  * All rights reserved.
@@ -50,7 +50,7 @@
  * @highest_node: id of highest numbered node within cluster
  * @highest_slave: (used for secondary node support)
  */
+
 struct cluster {
        u32 addr;
        struct _zone *owner;
index baf55c459c8bc15b2e2b514642656889a1e123a2..14789a82de537b6629383ec37af4ec6d6b5c81dc 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * net/tipc/config.c: TIPC configuration management code
- * 
+ *
  * Copyright (c) 2002-2006, Ericsson AB
  * Copyright (c) 2004-2006, Wind River Systems
  * All rights reserved.
@@ -86,7 +86,7 @@ struct sk_buff *tipc_cfg_reply_alloc(int payload_size)
        return buf;
 }
 
-int tipc_cfg_append_tlv(struct sk_buff *buf, int tlv_type, 
+int tipc_cfg_append_tlv(struct sk_buff *buf, int tlv_type,
                        void *tlv_data, int tlv_data_size)
 {
        struct tlv_desc *tlv = (struct tlv_desc *)buf->tail;
@@ -112,7 +112,7 @@ struct sk_buff *tipc_cfg_reply_unsigned_type(u16 tlv_type, u32 value)
        buf = tipc_cfg_reply_alloc(TLV_SPACE(sizeof(value)));
        if (buf) {
                value_net = htonl(value);
-               tipc_cfg_append_tlv(buf, tlv_type, &value_net, 
+               tipc_cfg_append_tlv(buf, tlv_type, &value_net,
                                    sizeof(value_net));
        }
        return buf;
@@ -182,7 +182,7 @@ int tipc_cfg_cmd(const struct tipc_cmd_msg * msg,
 
 static void cfg_cmd_event(struct tipc_cmd_msg *msg,
                          char *data,
-                         u32 sz,        
+                         u32 sz,
                          struct tipc_portid const *orig)
 {
        int rv = -EINVAL;
@@ -192,7 +192,7 @@ static void cfg_cmd_event(struct tipc_cmd_msg *msg,
 
        msg->cmd = ntohl(msg->cmd);
 
-       cfg_prepare_res_msg(msg->cmd, msg->usr_handle, rv, &rmsg, msg_sect, 
+       cfg_prepare_res_msg(msg->cmd, msg->usr_handle, rv, &rmsg, msg_sect,
                            data, 0);
        if (ntohl(msg->magic) != TIPC_MAGIC)
                goto exit;
@@ -295,7 +295,7 @@ static struct sk_buff *cfg_set_own_addr(void)
                                                   " (cannot change node address once assigned)");
        tipc_own_addr = addr;
 
-       /* 
+       /*
         * Must release all spinlocks before calling start_net() because
         * Linux version of TIPC calls eth_media_start() which calls
         * register_netdevice_notifier() which may block!
@@ -619,7 +619,7 @@ static void cfg_named_msg_event(void *userdata,
                                struct sk_buff **buf,
                                const unchar *msg,
                                u32 size,
-                               u32 importance, 
+                               u32 importance,
                                struct tipc_portid const *orig,
                                struct tipc_name_seq const *dest)
 {
@@ -640,7 +640,7 @@ static void cfg_named_msg_event(void *userdata,
        /* Generate reply for request (if can't, return request) */
 
        rep_buf = tipc_cfg_do_cmd(orig->node,
-                                 ntohs(req_hdr->tcm_type), 
+                                 ntohs(req_hdr->tcm_type),
                                  msg + sizeof(*req_hdr),
                                  size - sizeof(*req_hdr),
                                  BUF_HEADROOM + MAX_H_SIZE + sizeof(*rep_hdr));
index 7a728f954d84b3b4ab53f78972b120b40c3036b6..5cd7cc56c54d13ee43a1a5155ff3d0a99dfa5a88 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * net/tipc/config.h: Include file for TIPC configuration service code
- * 
+ *
  * Copyright (c) 2003-2006, Ericsson AB
  * Copyright (c) 2005, Wind River Systems
  * All rights reserved.
@@ -43,7 +43,7 @@
 #include "link.h"
 
 struct sk_buff *tipc_cfg_reply_alloc(int payload_size);
-int tipc_cfg_append_tlv(struct sk_buff *buf, int tlv_type, 
+int tipc_cfg_append_tlv(struct sk_buff *buf, int tlv_type,
                        void *tlv_data, int tlv_data_size);
 struct sk_buff *tipc_cfg_reply_unsigned_type(u16 tlv_type, u32 value);
 struct sk_buff *tipc_cfg_reply_string_type(u16 tlv_type, char *string);
@@ -68,8 +68,8 @@ static inline struct sk_buff *tipc_cfg_reply_ultra_string(char *string)
        return tipc_cfg_reply_string_type(TIPC_TLV_ULTRA_STRING, string);
 }
 
-struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd, 
-                               const void *req_tlv_area, int req_tlv_space, 
+struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd,
+                               const void *req_tlv_area, int req_tlv_space,
                                int headroom);
 
 void tipc_cfg_link_event(u32 addr, char *name, int up);
index 6f5b7ee311802388b80ad5d72e2a8a15ae48b89e..d2d7d32c02c7bc4044065b695a43f138c591fab3 100644 (file)
@@ -89,7 +89,7 @@ int tipc_mode = TIPC_NOT_RUNNING;
 int tipc_random;
 atomic_t tipc_user_count = ATOMIC_INIT(0);
 
-const char tipc_alphabet[] = 
+const char tipc_alphabet[] =
        "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.";
 
 /* configurable TIPC parameters */
@@ -171,13 +171,13 @@ int tipc_core_start(void)
        get_random_bytes(&tipc_random, sizeof(tipc_random));
        tipc_mode = TIPC_NODE_MODE;
 
-       if ((res = tipc_handler_start()) || 
+       if ((res = tipc_handler_start()) ||
            (res = tipc_ref_table_init(tipc_max_ports + tipc_max_subscriptions,
                                       tipc_random)) ||
            (res = tipc_reg_start()) ||
            (res = tipc_nametbl_init()) ||
-            (res = tipc_k_signal((Handler)tipc_subscr_start, 0)) ||
-           (res = tipc_k_signal((Handler)tipc_cfg_init, 0)) || 
+           (res = tipc_k_signal((Handler)tipc_subscr_start, 0)) ||
+           (res = tipc_k_signal((Handler)tipc_cfg_init, 0)) ||
            (res = tipc_netlink_start()) ||
            (res = tipc_socket_init())) {
                tipc_core_stop();
@@ -191,7 +191,7 @@ static int __init tipc_init(void)
        int res;
 
        tipc_log_reinit(CONFIG_TIPC_LOG);
-       info("Activated (version " TIPC_MOD_VER 
+       info("Activated (version " TIPC_MOD_VER
             " compiled " __DATE__ " " __TIME__ ")\n");
 
        tipc_own_addr = 0;
@@ -207,9 +207,9 @@ static int __init tipc_init(void)
 
        if ((res = tipc_core_start()))
                err("Unable to start in single node mode\n");
-       else    
+       else
                info("Started in single node mode\n");
-        return res;
+       return res;
 }
 
 static void __exit tipc_exit(void)
@@ -268,11 +268,11 @@ EXPORT_SYMBOL(tipc_available_nodes);
 /* TIPC API for external bearers (see tipc_bearer.h) */
 
 EXPORT_SYMBOL(tipc_block_bearer);
-EXPORT_SYMBOL(tipc_continue); 
+EXPORT_SYMBOL(tipc_continue);
 EXPORT_SYMBOL(tipc_disable_bearer);
 EXPORT_SYMBOL(tipc_enable_bearer);
 EXPORT_SYMBOL(tipc_recv_msg);
-EXPORT_SYMBOL(tipc_register_media); 
+EXPORT_SYMBOL(tipc_register_media);
 
 /* TIPC API for external APIs (see tipc_port.h) */
 
index 4638947c2326e0ea534f490b02abc767270d2c1a..e40ada964d6e9ce4794b30c98ab6f2516ac70427 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * net/tipc/core.h: Include file for TIPC global declarations
- * 
+ *
  * Copyright (c) 2005-2006, Ericsson AB
  * Copyright (c) 2005-2006, Wind River Systems
  * All rights reserved.
@@ -54,7 +54,7 @@
 #include <asm/atomic.h>
 #include <asm/hardirq.h>
 #include <linux/netdevice.h>
-#include <linux/in.h>  
+#include <linux/in.h>
 #include <linux/list.h>
 #include <linux/vmalloc.h>
 
@@ -88,7 +88,7 @@ void tipc_dump(struct print_buf*,const char *fmt, ...);
 #define dump(fmt, arg...) do {if (DBG_OUTPUT != TIPC_NULL) tipc_dump(DBG_OUTPUT, fmt, ##arg);} while(0)
 
 
-/*     
+/*
  * By default, TIPC_OUTPUT is defined to be system console and TIPC log buffer,
  * while DBG_OUTPUT is the null print buffer.  These defaults can be changed
  * here, or on a per .c file basis, by redefining these symbols.  The following
@@ -126,9 +126,9 @@ void tipc_dump(struct print_buf*,const char *fmt, ...);
 #define dump(fmt,arg...) do {} while (0)
 
 
-/*     
+/*
  * TIPC_OUTPUT is defined to be the system console, while DBG_OUTPUT is
- * the null print buffer.  Thes ensures that any system or debug messages 
+ * the null print buffer.  Thes ensures that any system or debug messages
  * that are generated without using the above macros are handled correctly.
  */
 
@@ -138,10 +138,10 @@ void tipc_dump(struct print_buf*,const char *fmt, ...);
 #undef  DBG_OUTPUT
 #define DBG_OUTPUT TIPC_NULL
 
-#endif                   
+#endif
 
 
-/* 
+/*
  * TIPC-specific error codes
  */
 
@@ -204,11 +204,11 @@ u32 tipc_k_signal(Handler routine, unsigned long argument);
  * @timer: pointer to timer structure
  * @routine: pointer to routine to invoke when timer expires
  * @argument: value to pass to routine when timer expires
- * 
+ *
  * Timer must be initialized before use (and terminated when no longer needed).
  */
 
-static inline void k_init_timer(struct timer_list *timer, Handler routine, 
+static inline void k_init_timer(struct timer_list *timer, Handler routine,
                                unsigned long argument)
 {
        dbg("initializing timer %p\n", timer);
@@ -221,13 +221,13 @@ static inline void k_init_timer(struct timer_list *timer, Handler routine,
  * k_start_timer - start a timer
  * @timer: pointer to timer structure
  * @msec: time to delay (in ms)
- * 
+ *
  * Schedules a previously initialized timer for later execution.
  * If timer is already running, the new timeout overrides the previous request.
- * 
+ *
  * To ensure the timer doesn't expire before the specified delay elapses,
  * the amount of delay is rounded up when converting to the jiffies
- * then an additional jiffy is added to account for the fact that 
+ * then an additional jiffy is added to account for the fact that
  * the starting time may be in the middle of the current jiffy.
  */
 
@@ -240,10 +240,10 @@ static inline void k_start_timer(struct timer_list *timer, unsigned long msec)
 /**
  * k_cancel_timer - cancel a timer
  * @timer: pointer to timer structure
- * 
- * Cancels a previously initialized timer.  
+ *
+ * Cancels a previously initialized timer.
  * Can be called safely even if the timer is already inactive.
- * 
+ *
  * WARNING: Must not be called when holding locks required by the timer's
  *          timeout routine, otherwise deadlock can occur on SMP systems!
  */
@@ -257,11 +257,11 @@ static inline void k_cancel_timer(struct timer_list *timer)
 /**
  * k_term_timer - terminate a timer
  * @timer: pointer to timer structure
- * 
+ *
  * Prevents further use of a previously initialized timer.
- * 
+ *
  * WARNING: Caller must ensure timer isn't currently running.
- * 
+ *
  * (Do not "enhance" this routine to automatically cancel an active timer,
  * otherwise deadlock can arise when a timeout routine calls k_term_timer.)
  */
@@ -302,7 +302,7 @@ static inline struct tipc_msg *buf_msg(struct sk_buff *skb)
  * @size: message size (including TIPC header)
  *
  * Returns a new buffer with data pointers set to the specified size.
- * 
+ *
  * NOTE: Headroom is reserved to allow prepending of a data link header.
  *       There may also be unrequested tailroom present at the buffer's end.
  */
@@ -334,4 +334,4 @@ static inline void buf_discard(struct sk_buff *skb)
                kfree_skb(skb);
 }
 
-#endif                 
+#endif
index 627f99b7afdfbcc637bc0eca6f4cf1bc8badfcd6..e809d2a2ce062486f408a923dbdfa2b590ad537f 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * net/tipc/dbg.c: TIPC print buffer routines for debugging
- * 
+ *
  * Copyright (c) 1996-2006, Ericsson AB
  * Copyright (c) 2005-2006, Wind River Systems
  * All rights reserved.
@@ -123,34 +123,34 @@ int tipc_printbuf_empty(struct print_buf *pb)
 /**
  * tipc_printbuf_validate - check for print buffer overflow
  * @pb: pointer to print buffer structure
- * 
- * Verifies that a print buffer has captured all data written to it. 
+ *
+ * Verifies that a print buffer has captured all data written to it.
  * If data has been lost, linearize buffer and prepend an error message
- * 
+ *
  * Returns length of print buffer data string (including trailing NUL)
  */
 
 int tipc_printbuf_validate(struct print_buf *pb)
 {
-        char *err = "\n\n*** PRINT BUFFER OVERFLOW ***\n\n";
-        char *cp_buf;
-        struct print_buf cb;
+       char *err = "\n\n*** PRINT BUFFER OVERFLOW ***\n\n";
+       char *cp_buf;
+       struct print_buf cb;
 
        if (!pb->buf)
                return 0;
 
        if (pb->buf[pb->size - 1] == 0) {
-                cp_buf = kmalloc(pb->size, GFP_ATOMIC);
-                if (cp_buf != NULL){
-                        tipc_printbuf_init(&cb, cp_buf, pb->size);
-                        tipc_printbuf_move(&cb, pb);
-                        tipc_printbuf_move(pb, &cb);
-                        kfree(cp_buf);
-                        memcpy(pb->buf, err, strlen(err));
-                } else {
-                        tipc_printbuf_reset(pb);
-                        tipc_printf(pb, err);
-                }
+               cp_buf = kmalloc(pb->size, GFP_ATOMIC);
+               if (cp_buf != NULL){
+                       tipc_printbuf_init(&cb, cp_buf, pb->size);
+                       tipc_printbuf_move(&cb, pb);
+                       tipc_printbuf_move(pb, &cb);
+                       kfree(cp_buf);
+                       memcpy(pb->buf, err, strlen(err));
+               } else {
+                       tipc_printbuf_reset(pb);
+                       tipc_printf(pb, err);
+               }
        }
        return (pb->crs - pb->buf + 1);
 }
@@ -159,7 +159,7 @@ int tipc_printbuf_validate(struct print_buf *pb)
  * tipc_printbuf_move - move print buffer contents to another print buffer
  * @pb_to: pointer to destination print buffer structure
  * @pb_from: pointer to source print buffer structure
- * 
+ *
  * Current contents of destination print buffer (if any) are discarded.
  * Source print buffer becomes empty if a successful move occurs.
  */
@@ -234,13 +234,13 @@ void tipc_printf(struct print_buf *pb, const char *fmt, ...)
                                pb->crs = pb->buf + pb->size - 1;
                        } else {
                                strcpy(pb->buf, print_string + chars_left);
-                                save_char = print_string[chars_left];
-                                print_string[chars_left] = 0;
-                                strcpy(pb->crs, print_string);
-                                print_string[chars_left] = save_char;
-                                pb->crs = pb->buf + chars_to_add - chars_left;
-                        }
-                }
+                               save_char = print_string[chars_left];
+                               print_string[chars_left] = 0;
+                               strcpy(pb->crs, print_string);
+                               print_string[chars_left] = save_char;
+                               pb->crs = pb->buf + chars_to_add - chars_left;
+                       }
+               }
                pb_next = pb->next;
                pb->next = NULL;
                pb = pb_next;
@@ -249,7 +249,7 @@ void tipc_printf(struct print_buf *pb, const char *fmt, ...)
 }
 
 /**
- * TIPC_TEE - perform next output operation on both print buffers  
+ * TIPC_TEE - perform next output operation on both print buffers
  * @b0: pointer to chain of print buffers (may be NULL)
  * @b1: pointer to print buffer to add to chain
  *
@@ -350,7 +350,7 @@ void tipc_dump(struct print_buf *pb, const char *fmt, ...)
 }
 
 /**
- * tipc_log_stop - free up TIPC log print buffer 
+ * tipc_log_stop - free up TIPC log print buffer
  */
 
 void tipc_log_stop(void)
index 467c0bc78a79feb7e8938a9100ae4e42cb3541df..c01b085000e08622838ce5b46f1ea1023d7069c2 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * net/tipc/dbg.h: Include file for TIPC print buffer routines
- * 
+ *
  * Copyright (c) 1997-2006, Ericsson AB
  * Copyright (c) 2005-2006, Wind River Systems
  * All rights reserved.
index 3b0cd12f37dafeb788ddbe2334a57cd5ffacae4c..5d643e5721eb45ec36d3fb43d2f205e90f1ec5b5 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * net/tipc/discover.c
- * 
+ *
  * Copyright (c) 2003-2006, Ericsson AB
  * Copyright (c) 2005-2006, Wind River Systems
  * All rights reserved.
 #define  CHECK_LINK_COUNT      306
 #endif
 
-/* 
+/*
  * TODO: Most of the inter-cluster setup stuff should be
  * rewritten, and be made conformant with specification.
- */ 
+ */
 
 
 /**
@@ -80,10 +80,10 @@ struct link_req {
 
 
 #if 0
-int disc_create_link(const struct tipc_link_create *argv) 
+int disc_create_link(const struct tipc_link_create *argv)
 {
-       /* 
-        * Code for inter cluster link setup here 
+       /*
+        * Code for inter cluster link setup here
         */
        return TIPC_OK;
 }
@@ -93,16 +93,16 @@ int disc_create_link(const struct tipc_link_create *argv)
  * disc_lost_link(): A link has lost contact
  */
 
-void tipc_disc_link_event(u32 addr, char *name, int up) 
+void tipc_disc_link_event(u32 addr, char *name, int up)
 {
        if (in_own_cluster(addr))
                return;
-       /* 
-        * Code for inter cluster link setup here 
+       /*
+        * Code for inter cluster link setup here
         */
 }
 
-/** 
+/**
  * tipc_disc_init_msg - initialize a link setup message
  * @type: message type (request or response)
  * @req_links: number of links associated with message
@@ -210,7 +210,7 @@ void tipc_disc_recv_msg(struct sk_buff *buf)
                        dbg("creating link\n");
                        link = tipc_link_create(b_ptr, orig, &media_addr);
                        if (!link) {
-                               spin_unlock_bh(&n_ptr->lock);                
+                               spin_unlock_bh(&n_ptr->lock);
                                return;
                        }
                }
@@ -224,10 +224,10 @@ void tipc_disc_recv_msg(struct sk_buff *buf)
                        warn("Resetting link <%s>, peer interface address changed\n",
                             link->name);
                        memcpy(addr, &media_addr, sizeof(*addr));
-                       tipc_link_reset(link);     
+                       tipc_link_reset(link);
                }
                link_fully_up = (link->state == WORKING_WORKING);
-               spin_unlock_bh(&n_ptr->lock);                
+               spin_unlock_bh(&n_ptr->lock);
                if ((type == DSC_RESP_MSG) || link_fully_up)
                        return;
                rbuf = tipc_disc_init_msg(DSC_RESP_MSG, 1, orig, b_ptr);
@@ -244,23 +244,23 @@ void tipc_disc_recv_msg(struct sk_buff *buf)
  * @req: ptr to link request structure
  */
 
-void tipc_disc_stop_link_req(struct link_req *req) 
+void tipc_disc_stop_link_req(struct link_req *req)
 {
        if (!req)
                return;
-               
+
        k_cancel_timer(&req->timer);
        k_term_timer(&req->timer);
        buf_discard(req->buf);
        kfree(req);
-} 
+}
 
 /**
  * tipc_disc_update_link_req - update frequency of periodic link setup requests
  * @req: ptr to link request structure
  */
 
-void tipc_disc_update_link_req(struct link_req *req) 
+void tipc_disc_update_link_req(struct link_req *req)
 {
        if (!req)
                return;
@@ -278,16 +278,16 @@ void tipc_disc_update_link_req(struct link_req *req)
        } else {
                /* leave timer "as is" if haven't yet reached a "normal" rate */
        }
-} 
+}
 
 /**
  * disc_timeout - send a periodic link setup request
  * @req: ptr to link request structure
- * 
+ *
  * Called whenever a link setup request timer associated with a bearer expires.
  */
 
-static void disc_timeout(struct link_req *req) 
+static void disc_timeout(struct link_req *req)
 {
        spin_lock_bh(&req->bearer->publ.lock);
 
@@ -300,7 +300,7 @@ static void disc_timeout(struct link_req *req)
                req->timer_intv *= 2;
                if (req->timer_intv > TIPC_LINK_REQ_FAST)
                        req->timer_intv = TIPC_LINK_REQ_FAST;
-               if ((req->timer_intv == TIPC_LINK_REQ_FAST) && 
+               if ((req->timer_intv == TIPC_LINK_REQ_FAST) &&
                    (req->bearer->nodes.count))
                        req->timer_intv = TIPC_LINK_REQ_SLOW;
        }
@@ -315,14 +315,14 @@ static void disc_timeout(struct link_req *req)
  * @dest: destination address for request messages
  * @dest_domain: network domain of node(s) which should respond to message
  * @req_links: max number of desired links
- * 
+ *
  * Returns pointer to link request structure, or NULL if unable to create.
  */
 
-struct link_req *tipc_disc_init_link_req(struct bearer *b_ptr, 
+struct link_req *tipc_disc_init_link_req(struct bearer *b_ptr,
                                         const struct tipc_media_addr *dest,
                                         u32 dest_domain,
-                                        u32 req_links) 
+                                        u32 req_links)
 {
        struct link_req *req;
 
@@ -342,5 +342,5 @@ struct link_req *tipc_disc_init_link_req(struct bearer *b_ptr,
        k_init_timer(&req->timer, (Handler)disc_timeout, (unsigned long)req);
        k_start_timer(&req->timer, req->timer_intv);
        return req;
-} 
+}
 
index 0454fd1ae7f357cd0f5596981a04da632b7a7a53..9fd7587b143a5e74dd03ec6b8a7299ae5f410f58 100644 (file)
@@ -41,7 +41,7 @@
 
 struct link_req;
 
-struct link_req *tipc_disc_init_link_req(struct bearer *b_ptr, 
+struct link_req *tipc_disc_init_link_req(struct bearer *b_ptr,
                                         const struct tipc_media_addr *dest,
                                         u32 dest_domain,
                                         u32 req_links);
index 682da4a280416311ead3d8b9c45a4c42c67cda47..9be4839e32c5efe1a3ad87e24b1e6f42ecb3f9f9 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * net/tipc/eth_media.c: Ethernet bearer support for TIPC
- * 
+ *
  * Copyright (c) 2001-2006, Ericsson AB
  * Copyright (c) 2005-2006, Wind River Systems
  * All rights reserved.
@@ -50,7 +50,7 @@
  * @dev: ptr to associated Ethernet network device
  * @tipc_packet_type: used in binding TIPC to Ethernet driver
  */
+
 struct eth_bearer {
        struct tipc_bearer *bearer;
        struct net_device *dev;
@@ -62,10 +62,10 @@ static int eth_started = 0;
 static struct notifier_block notifier;
 
 /**
- * send_msg - send a TIPC message out over an Ethernet interface 
+ * send_msg - send a TIPC message out over an Ethernet interface
  */
 
-static int send_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr, 
+static int send_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr,
                    struct tipc_media_addr *dest)
 {
        struct sk_buff *clone;
@@ -76,7 +76,7 @@ static int send_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr,
                clone->nh.raw = clone->data;
                dev = ((struct eth_bearer *)(tb_ptr->usr_handle))->dev;
                clone->dev = dev;
-               dev->hard_header(clone, dev, ETH_P_TIPC, 
+               dev->hard_header(clone, dev, ETH_P_TIPC,
                                 &dest->dev_addr.eth_addr,
                                 dev->dev_addr, clone->len);
                dev_queue_xmit(clone);
@@ -86,12 +86,12 @@ static int send_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr,
 
 /**
  * recv_msg - handle incoming TIPC message from an Ethernet interface
- * 
+ *
  * Routine truncates any Ethernet padding/CRC appended to the message,
  * and ensures message size matches actual length
  */
 
-static int recv_msg(struct sk_buff *buf, struct net_device *dev, 
+static int recv_msg(struct sk_buff *buf, struct net_device *dev,
                    struct packet_type *pt, struct net_device *orig_dev)
 {
        struct eth_bearer *eb_ptr = (struct eth_bearer *)pt->af_packet_priv;
@@ -99,14 +99,14 @@ static int recv_msg(struct sk_buff *buf, struct net_device *dev,
 
        if (likely(eb_ptr->bearer)) {
               if (likely(!dev->promiscuity) ||
-                  !memcmp(buf->mac.raw,dev->dev_addr,ETH_ALEN) ||
-                  !memcmp(buf->mac.raw,dev->broadcast,ETH_ALEN)) {
-                       size = msg_size((struct tipc_msg *)buf->data);
-                       skb_trim(buf, size);
-                       if (likely(buf->len == size)) {
-                               buf->next = NULL;
-                               tipc_recv_msg(buf, eb_ptr->bearer);
-                               return TIPC_OK;
+                  !memcmp(buf->mac.raw,dev->dev_addr,ETH_ALEN) ||
+                  !memcmp(buf->mac.raw,dev->broadcast,ETH_ALEN)) {
+                       size = msg_size((struct tipc_msg *)buf->data);
+                       skb_trim(buf, size);
+                       if (likely(buf->len == size)) {
+                               buf->next = NULL;
+                               tipc_recv_msg(buf, eb_ptr->bearer);
+                               return TIPC_OK;
                        }
                }
        }
@@ -115,7 +115,7 @@ static int recv_msg(struct sk_buff *buf, struct net_device *dev,
 }
 
 /**
- * enable_bearer - attach TIPC bearer to an Ethernet interface 
+ * enable_bearer - attach TIPC bearer to an Ethernet interface
  */
 
 static int enable_bearer(struct tipc_bearer *tb_ptr)
@@ -127,7 +127,7 @@ static int enable_bearer(struct tipc_bearer *tb_ptr)
 
        /* Find device with specified name */
 
-       while (dev && dev->name && strncmp(dev->name, driver_name, IFNAMSIZ)) { 
+       while (dev && dev->name && strncmp(dev->name, driver_name, IFNAMSIZ)) {
                dev = dev->next;
        }
        if (!dev)
@@ -154,14 +154,14 @@ static int enable_bearer(struct tipc_bearer *tb_ptr)
        eb_ptr->bearer = tb_ptr;
        tb_ptr->usr_handle = (void *)eb_ptr;
        tb_ptr->mtu = dev->mtu;
-       tb_ptr->blocked = 0; 
+       tb_ptr->blocked = 0;
        tb_ptr->addr.type = htonl(TIPC_MEDIA_TYPE_ETH);
        memcpy(&tb_ptr->addr.dev_addr, &dev->dev_addr, ETH_ALEN);
        return 0;
 }
 
 /**
- * disable_bearer - detach TIPC bearer from an Ethernet interface 
+ * disable_bearer - detach TIPC bearer from an Ethernet interface
  *
  * We really should do dev_remove_pack() here, but this function can not be
  * called at tasklet level. => Use eth_bearer->bearer as a flag to throw away
@@ -176,11 +176,11 @@ static void disable_bearer(struct tipc_bearer *tb_ptr)
 /**
  * recv_notification - handle device updates from OS
  *
- * Change the state of the Ethernet bearer (if any) associated with the 
+ * Change the state of the Ethernet bearer (if any) associated with the
  * specified device.
  */
 
-static int recv_notification(struct notifier_block *nb, unsigned long evt, 
+static int recv_notification(struct notifier_block *nb, unsigned long evt,
                             void *dv)
 {
        struct net_device *dev = (struct net_device *)dv;
@@ -194,7 +194,7 @@ static int recv_notification(struct notifier_block *nb, unsigned long evt,
        if (!eb_ptr->bearer)
                return NOTIFY_DONE;             /* bearer had been disabled */
 
-        eb_ptr->bearer->mtu = dev->mtu;
+       eb_ptr->bearer->mtu = dev->mtu;
 
        switch (evt) {
        case NETDEV_CHANGE:
@@ -210,12 +210,12 @@ static int recv_notification(struct notifier_block *nb, unsigned long evt,
                tipc_block_bearer(eb_ptr->bearer->name);
                break;
        case NETDEV_CHANGEMTU:
-        case NETDEV_CHANGEADDR:
+       case NETDEV_CHANGEADDR:
                tipc_block_bearer(eb_ptr->bearer->name);
-                tipc_continue(eb_ptr->bearer);
+               tipc_continue(eb_ptr->bearer);
                break;
        case NETDEV_UNREGISTER:
-        case NETDEV_CHANGENAME:
+       case NETDEV_CHANGENAME:
                tipc_disable_bearer(eb_ptr->bearer->name);
                break;
        }
@@ -227,7 +227,7 @@ static int recv_notification(struct notifier_block *nb, unsigned long evt,
  */
 
 static char *eth_addr2str(struct tipc_media_addr *a, char *str_buf, int str_size)
-{                       
+{
        unchar *addr = (unchar *)&a->dev_addr;
 
        if (str_size < 18)
@@ -246,7 +246,7 @@ static char *eth_addr2str(struct tipc_media_addr *a, char *str_buf, int str_size
  */
 
 int tipc_eth_media_start(void)
-{                       
+{
        struct tipc_media_addr bcast_addr;
        int res;
 
@@ -259,8 +259,8 @@ int tipc_eth_media_start(void)
        memset(eth_bearers, 0, sizeof(eth_bearers));
 
        res = tipc_register_media(TIPC_MEDIA_TYPE_ETH, "eth",
-                                 enable_bearer, disable_bearer, send_msg, 
-                                 eth_addr2str, &bcast_addr, ETH_LINK_PRIORITY, 
+                                 enable_bearer, disable_bearer, send_msg,
+                                 eth_addr2str, &bcast_addr, ETH_LINK_PRIORITY,
                                  ETH_LINK_TOLERANCE, ETH_LINK_WINDOW);
        if (res)
                return res;
index eb80778d6d9c6d22781b205a21b139bd4c87f052..e1dcf663f8a64960fdfdc824df07f071dca6818e 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * net/tipc/handler.c: TIPC signal handling
- * 
+ *
  * Copyright (c) 2000-2006, Ericsson AB
  * Copyright (c) 2005, Wind River Systems
  * All rights reserved.
@@ -95,7 +95,7 @@ static void process_signal_queue(unsigned long dummy)
 
 int tipc_handler_start(void)
 {
-       tipc_queue_item_cache = 
+       tipc_queue_item_cache =
                kmem_cache_create("tipc_queue_items", sizeof(struct queue_item),
                                  0, SLAB_HWCACHE_ALIGN, NULL, NULL);
        if (!tipc_queue_item_cache)
@@ -110,7 +110,7 @@ int tipc_handler_start(void)
 void tipc_handler_stop(void)
 {
        struct list_head *l, *n;
-       struct queue_item *item; 
+       struct queue_item *item;
 
        if (!handler_enabled)
                return;
index 1bb983c8130b32be1b70e776b04ee573f6530c42..71c2f2fd405c251dccf23be6b77374f42ef17685 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * net/tipc/link.c: TIPC link code
- * 
+ *
  * Copyright (c) 1996-2006, Ericsson AB
  * Copyright (c) 2004-2006, Wind River Systems
  * All rights reserved.
 #include "bcast.h"
 
 
-/* 
- * Limit for deferred reception queue: 
+/*
+ * Limit for deferred reception queue:
  */
 
 #define DEF_QUEUE_LIMIT 256u
 
-/* 
- * Link state events: 
+/*
+ * Link state events:
  */
 
 #define  STARTING_EVT    856384768     /* link processing trigger */
 #define  TRAFFIC_MSG_EVT 560815u       /* rx'd ??? */
 #define  TIMEOUT_EVT     560817u       /* link timer expired */
 
-/*   
- * The following two 'message types' is really just implementation 
- * data conveniently stored in the message header. 
+/*
+ * The following two 'message types' is really just implementation
+ * data conveniently stored in the message header.
  * They must not be considered part of the protocol
  */
 #define OPEN_MSG   0
 #define CLOSED_MSG 1
 
-/* 
+/*
  * State value stored in 'exp_msg_count'
  */
 
@@ -97,7 +97,7 @@ struct link_name {
 
 /* LINK EVENT CODE IS NOT SUPPORTED AT PRESENT */
 
-/** 
+/**
  * struct link_event - link up/down event notification
  */
 
@@ -121,7 +121,7 @@ static int  link_send_sections_long(struct port *sender,
 static void link_check_defragm_bufs(struct link *l_ptr);
 static void link_state_event(struct link *l_ptr, u32 event);
 static void link_reset_statistics(struct link *l_ptr);
-static void link_print(struct link *l_ptr, struct print_buf *buf, 
+static void link_print(struct link *l_ptr, struct print_buf *buf,
                       const char *str);
 
 /*
@@ -136,13 +136,13 @@ static void link_print(struct link *l_ptr, struct print_buf *buf,
  *
  * To enable per-link debugging, use LINK_LOG_BUF_SIZE to specify the size
  * of the print buffer used by each link.  If LINK_LOG_BUF_SIZE is set to 0,
- * the dbg_link_XXX() routines simply send their output to the standard 
+ * the dbg_link_XXX() routines simply send their output to the standard
  * debug print buffer (DBG_OUTPUT), if it has been defined; this can be useful
  * when there is only a single link in the system being debugged.
  *
  * Notes:
  * - When enabled, LINK_LOG_BUF_SIZE should be set to at least TIPC_PB_MIN_SIZE
- * - "l_ptr" must be valid when using dbg_link_XXX() macros  
+ * - "l_ptr" must be valid when using dbg_link_XXX() macros
  */
 
 #define LINK_LOG_BUF_SIZE 0
@@ -222,18 +222,18 @@ static u32 link_max_pkt(struct link *l_ptr)
 static void link_init_max_pkt(struct link *l_ptr)
 {
        u32 max_pkt;
-       
+
        max_pkt = (l_ptr->b_ptr->publ.mtu & ~3);
        if (max_pkt > MAX_MSG_SIZE)
                max_pkt = MAX_MSG_SIZE;
 
-        l_ptr->max_pkt_target = max_pkt;
+       l_ptr->max_pkt_target = max_pkt;
        if (l_ptr->max_pkt_target < MAX_PKT_DEFAULT)
                l_ptr->max_pkt = l_ptr->max_pkt_target;
-       else 
+       else
                l_ptr->max_pkt = MAX_PKT_DEFAULT;
 
-        l_ptr->max_pkt_probes = 0;
+       l_ptr->max_pkt_probes = 0;
 }
 
 static u32 link_next_sent(struct link *l_ptr)
@@ -269,7 +269,7 @@ int tipc_link_is_active(struct link *l_ptr)
  * link_name_validate - validate & (optionally) deconstruct link name
  * @name - ptr to link name string
  * @name_parts - ptr to area for link name components (or NULL if not needed)
- * 
+ *
  * Returns 1 if link name is valid, otherwise 0.
  */
 
@@ -317,8 +317,8 @@ static int link_name_validate(const char *name, struct link_name *name_parts)
                    &z_peer, &c_peer, &n_peer, &dummy) != 3) ||
            (z_local > 255) || (c_local > 4095) || (n_local > 4095) ||
            (z_peer  > 255) || (c_peer  > 4095) || (n_peer  > 4095) ||
-           (if_local_len <= 1) || (if_local_len > TIPC_MAX_IF_NAME) || 
-           (if_peer_len  <= 1) || (if_peer_len  > TIPC_MAX_IF_NAME) || 
+           (if_local_len <= 1) || (if_local_len > TIPC_MAX_IF_NAME) ||
+           (if_peer_len  <= 1) || (if_peer_len  > TIPC_MAX_IF_NAME) ||
            (strspn(if_local, tipc_alphabet) != (if_local_len - 1)) ||
            (strspn(if_peer, tipc_alphabet) != (if_peer_len - 1)))
                return 0;
@@ -337,7 +337,7 @@ static int link_name_validate(const char *name, struct link_name *name_parts)
 /**
  * link_timeout - handle expiration of link timer
  * @l_ptr: pointer to link
- * 
+ *
  * This routine must not grab "tipc_net_lock" to avoid a potential deadlock conflict
  * with tipc_link_delete().  (There is no risk that the node will be deleted by
  * another thread because tipc_link_delete() always cancels the link timer before
@@ -406,7 +406,7 @@ static void link_set_timer(struct link *l_ptr, u32 time)
  * @b_ptr: pointer to associated bearer
  * @peer: network address of node at other end of link
  * @media_addr: media address to use when sending messages over link
- * 
+ *
  * Returns pointer to link.
  */
 
@@ -427,7 +427,7 @@ struct link *tipc_link_create(struct bearer *b_ptr, const u32 peer,
        if_name = strchr(b_ptr->publ.name, ':') + 1;
        sprintf(l_ptr->name, "%u.%u.%u:%s-%u.%u.%u:",
                tipc_zone(tipc_own_addr), tipc_cluster(tipc_own_addr),
-               tipc_node(tipc_own_addr), 
+               tipc_node(tipc_own_addr),
                if_name,
                tipc_zone(peer), tipc_cluster(peer), tipc_node(peer));
                /* note: peer i/f is appended to link name by reset/activate */
@@ -478,17 +478,17 @@ struct link *tipc_link_create(struct bearer *b_ptr, const u32 peer,
 
        dbg("tipc_link_create(): tolerance = %u,cont intv = %u, abort_limit = %u\n",
            l_ptr->tolerance, l_ptr->continuity_interval, l_ptr->abort_limit);
-       
+
        return l_ptr;
 }
 
-/** 
+/**
  * tipc_link_delete - delete a link
  * @l_ptr: pointer to link
- * 
+ *
  * Note: 'tipc_net_lock' is write_locked, bearer is locked.
  * This routine must not grab the node lock until after link timer cancellation
- * to avoid a potential deadlock situation.  
+ * to avoid a potential deadlock situation.
  */
 
 void tipc_link_delete(struct link *l_ptr)
@@ -501,7 +501,7 @@ void tipc_link_delete(struct link *l_ptr)
        dbg("tipc_link_delete()\n");
 
        k_cancel_timer(&l_ptr->timer);
-       
+
        tipc_node_lock(l_ptr->owner);
        tipc_link_reset(l_ptr);
        tipc_node_detach_link(l_ptr->owner, l_ptr);
@@ -521,12 +521,12 @@ void tipc_link_start(struct link *l_ptr)
 }
 
 /**
- * link_schedule_port - schedule port for deferred sending 
+ * link_schedule_port - schedule port for deferred sending
  * @l_ptr: pointer to link
  * @origport: reference to sending port
  * @sz: amount of data to be sent
- * 
- * Schedules port for renewed sending of messages after link congestion 
+ *
+ * Schedules port for renewed sending of messages after link congestion
  * has abated.
  */
 
@@ -567,7 +567,7 @@ void tipc_link_wakeup_ports(struct link *l_ptr, int all)
                return;
        if (link_congested(l_ptr))
                goto exit;
-       list_for_each_entry_safe(p_ptr, temp_p_ptr, &l_ptr->waiting_ports, 
+       list_for_each_entry_safe(p_ptr, temp_p_ptr, &l_ptr->waiting_ports,
                                 wait_list) {
                if (win <= 0)
                        break;
@@ -584,7 +584,7 @@ exit:
        spin_unlock_bh(&tipc_port_list_lock);
 }
 
-/** 
+/**
  * link_release_outqueue - purge link's outbound message queue
  * @l_ptr: pointer to link
  */
@@ -621,7 +621,7 @@ void tipc_link_reset_fragments(struct link *l_ptr)
        l_ptr->defragm_buf = NULL;
 }
 
-/** 
+/**
  * tipc_link_stop - purge all inbound and outbound messages associated with link
  * @l_ptr: pointer to link
  */
@@ -665,7 +665,7 @@ static void link_send_event(void (*fcn)(u32 a, char *n, int up),
                            struct link *l_ptr, int up)
 {
        struct link_event *ev;
-       
+
        ev = kmalloc(sizeof(*ev), GFP_ATOMIC);
        if (!ev) {
                warn("Link event allocation failure\n");
@@ -690,15 +690,15 @@ void tipc_link_reset(struct link *l_ptr)
        u32 prev_state = l_ptr->state;
        u32 checkpoint = l_ptr->next_in_no;
        int was_active_link = tipc_link_is_active(l_ptr);
-       
+
        msg_set_session(l_ptr->pmsg, msg_session(l_ptr->pmsg) + 1);
 
-        /* Link is down, accept any session: */
+       /* Link is down, accept any session: */
        l_ptr->peer_session = 0;
 
-        /* Prepare for max packet size negotiation */
+       /* Prepare for max packet size negotiation */
        link_init_max_pkt(l_ptr);
-       
+
        l_ptr->state = RESET_UNKNOWN;
        dbg_link_state("Resetting Link\n");
 
@@ -770,7 +770,7 @@ static void link_activate(struct link *l_ptr)
 
 static void link_state_event(struct link *l_ptr, unsigned event)
 {
-       struct link *other; 
+       struct link *other;
        u32 cont_intv = l_ptr->continuity_interval;
 
        if (!l_ptr->started && (event != STARTING_EVT))
@@ -799,11 +799,11 @@ static void link_state_event(struct link *l_ptr, unsigned event)
                        if (l_ptr->next_in_no != l_ptr->checkpoint) {
                                l_ptr->checkpoint = l_ptr->next_in_no;
                                if (tipc_bclink_acks_missing(l_ptr->owner)) {
-                                       tipc_link_send_proto_msg(l_ptr, STATE_MSG, 
+                                       tipc_link_send_proto_msg(l_ptr, STATE_MSG,
                                                                 0, 0, 0, 0, 0);
                                        l_ptr->fsm_msg_cnt++;
                                } else if (l_ptr->max_pkt < l_ptr->max_pkt_target) {
-                                       tipc_link_send_proto_msg(l_ptr, STATE_MSG, 
+                                       tipc_link_send_proto_msg(l_ptr, STATE_MSG,
                                                                 1, 0, 0, 0, 0);
                                        l_ptr->fsm_msg_cnt++;
                                }
@@ -819,7 +819,7 @@ static void link_state_event(struct link *l_ptr, unsigned event)
                        break;
                case RESET_MSG:
                        dbg_link("RES -> RR\n");
-                       info("Resetting link <%s>, requested by peer\n", 
+                       info("Resetting link <%s>, requested by peer\n",
                             l_ptr->name);
                        tipc_link_reset(l_ptr);
                        l_ptr->state = RESET_RESET;
@@ -871,7 +871,7 @@ static void link_state_event(struct link *l_ptr, unsigned event)
                                dbg_link("Probing %u/%u,timer = %u ms)\n",
                                         l_ptr->fsm_msg_cnt, l_ptr->abort_limit,
                                         cont_intv / 4);
-                               tipc_link_send_proto_msg(l_ptr, STATE_MSG, 
+                               tipc_link_send_proto_msg(l_ptr, STATE_MSG,
                                                         1, 0, 0, 0, 0);
                                l_ptr->fsm_msg_cnt++;
                                link_set_timer(l_ptr, cont_intv / 4);
@@ -977,11 +977,11 @@ static void link_state_event(struct link *l_ptr, unsigned event)
 
 /*
  * link_bundle_buf(): Append contents of a buffer to
- * the tail of an existing one. 
+ * the tail of an existing one.
  */
 
 static int link_bundle_buf(struct link *l_ptr,
-                          struct sk_buff *bundler, 
+                          struct sk_buff *bundler,
                           struct sk_buff *buf)
 {
        struct tipc_msg *bundler_msg = buf_msg(bundler);
@@ -1030,8 +1030,8 @@ static void link_add_to_outqueue(struct link *l_ptr,
        l_ptr->out_queue_size++;
 }
 
-/* 
- * tipc_link_send_buf() is the 'full path' for messages, called from 
+/*
+ * tipc_link_send_buf() is the 'full path' for messages, called from
  * inside TIPC when the 'fast path' in tipc_send_buf
  * has failed, and from link_send()
  */
@@ -1074,7 +1074,7 @@ int tipc_link_send_buf(struct link *l_ptr, struct sk_buff *buf)
        if (queue_size > l_ptr->stats.max_queue_sz)
                l_ptr->stats.max_queue_sz = queue_size;
 
-       if (likely(!tipc_bearer_congested(l_ptr->b_ptr, l_ptr) && 
+       if (likely(!tipc_bearer_congested(l_ptr->b_ptr, l_ptr) &&
                   !link_congested(l_ptr))) {
                link_add_to_outqueue(l_ptr, buf, msg);
 
@@ -1094,7 +1094,7 @@ int tipc_link_send_buf(struct link *l_ptr, struct sk_buff *buf)
 
                /* Try adding message to an existing bundle */
 
-               if (l_ptr->next_out && 
+               if (l_ptr->next_out &&
                    link_bundle_buf(l_ptr, l_ptr->last_out, buf)) {
                        tipc_bearer_resolve_congestion(l_ptr->b_ptr, l_ptr);
                        return dsz;
@@ -1109,7 +1109,7 @@ int tipc_link_send_buf(struct link *l_ptr, struct sk_buff *buf)
                        if (bundler) {
                                msg_init(&bundler_hdr, MSG_BUNDLER, OPEN_MSG,
                                         TIPC_OK, INT_H_SIZE, l_ptr->addr);
-                               memcpy(bundler->data, (unchar *)&bundler_hdr, 
+                               memcpy(bundler->data, (unchar *)&bundler_hdr,
                                       INT_H_SIZE);
                                skb_trim(bundler, INT_H_SIZE);
                                link_bundle_buf(l_ptr, bundler, buf);
@@ -1126,8 +1126,8 @@ int tipc_link_send_buf(struct link *l_ptr, struct sk_buff *buf)
        return dsz;
 }
 
-/* 
- * tipc_link_send(): same as tipc_link_send_buf(), but the link to use has 
+/*
+ * tipc_link_send(): same as tipc_link_send_buf(), but the link to use has
  * not been selected yet, and the the owner node is not locked
  * Called by TIPC internal users, e.g. the name distributor
  */
@@ -1161,8 +1161,8 @@ int tipc_link_send(struct sk_buff *buf, u32 dest, u32 selector)
        return res;
 }
 
-/* 
- * link_send_buf_fast: Entry for data messages where the 
+/*
+ * link_send_buf_fast: Entry for data messages where the
  * destination link is known and the header is complete,
  * inclusive total message length. Very time critical.
  * Link is locked. Returns user data length.
@@ -1197,8 +1197,8 @@ static int link_send_buf_fast(struct link *l_ptr, struct sk_buff *buf,
        return tipc_link_send_buf(l_ptr, buf);  /* All other cases */
 }
 
-/* 
- * tipc_send_buf_fast: Entry for data messages where the 
+/*
+ * tipc_send_buf_fast: Entry for data messages where the
  * destination node is known and the header is complete,
  * inclusive total message length.
  * Returns user data length.
@@ -1236,15 +1236,15 @@ int tipc_send_buf_fast(struct sk_buff *buf, u32 destnode)
 }
 
 
-/* 
- * tipc_link_send_sections_fast: Entry for messages where the 
+/*
+ * tipc_link_send_sections_fast: Entry for messages where the
  * destination processor is known and the header is complete,
- * except for total message length. 
+ * except for total message length.
  * Returns user data length or errno.
  */
-int tipc_link_send_sections_fast(struct port *sender, 
+int tipc_link_send_sections_fast(struct port *sender,
                                 struct iovec const *msg_sect,
-                                const u32 num_sect, 
+                                const u32 num_sect,
                                 u32 destaddr)
 {
        struct tipc_msg *hdr = &sender->publ.phdr;
@@ -1287,14 +1287,14 @@ exit:
 
                        /* Exit if link (or bearer) is congested */
 
-                       if (link_congested(l_ptr) || 
+                       if (link_congested(l_ptr) ||
                            !list_empty(&l_ptr->b_ptr->cong_links)) {
                                res = link_schedule_port(l_ptr,
                                                         sender->publ.ref, res);
                                goto exit;
                        }
 
-                       /* 
+                       /*
                         * Message size exceeds max_pkt hint; update hint,
                         * then re-try fast path or fragment the message
                         */
@@ -1324,10 +1324,10 @@ exit:
        return res;
 }
 
-/* 
- * link_send_sections_long(): Entry for long messages where the 
+/*
+ * link_send_sections_long(): Entry for long messages where the
  * destination node is known and the header is complete,
- * inclusive total message length. 
+ * inclusive total message length.
  * Link and bearer congestion status have been checked to be ok,
  * and are ignored if they change.
  *
@@ -1357,9 +1357,9 @@ static int link_send_sections_long(struct port *sender,
 
 again:
        fragm_no = 1;
-       max_pkt = sender->max_pkt - INT_H_SIZE;  
+       max_pkt = sender->max_pkt - INT_H_SIZE;
                /* leave room for tunnel header in case of link changeover */
-       fragm_sz = max_pkt - INT_H_SIZE; 
+       fragm_sz = max_pkt - INT_H_SIZE;
                /* leave room for fragmentation header in each fragment */
        rest = dsz;
        fragm_crs = 0;
@@ -1440,7 +1440,7 @@ error:
                        if (!buf)
                                goto error;
 
-                       buf->next = NULL;                                
+                       buf->next = NULL;
                        prev->next = buf;
                        memcpy(buf->data, (unchar *)&fragm_hdr, INT_H_SIZE);
                        fragm_crs = INT_H_SIZE;
@@ -1450,7 +1450,7 @@ error:
        }
        while (rest > 0);
 
-       /* 
+       /*
         * Now we have a buffer chain. Select a link and check
         * that packet size is still OK
         */
@@ -1506,7 +1506,7 @@ reject:
        return dsz;
 }
 
-/* 
+/*
  * tipc_link_push_packet: Push one unsent packet to the media
  */
 u32 tipc_link_push_packet(struct link *l_ptr)
@@ -1519,7 +1519,7 @@ u32 tipc_link_push_packet(struct link *l_ptr)
        /* consider that buffers may have been released in meantime */
 
        if (r_q_size && buf) {
-               u32 last = lesser(mod(r_q_head + r_q_size), 
+               u32 last = lesser(mod(r_q_head + r_q_size),
                                  link_last_sent(l_ptr));
                u32 first = msg_seqno(buf_msg(buf));
 
@@ -1535,7 +1535,7 @@ u32 tipc_link_push_packet(struct link *l_ptr)
 
        if (r_q_size && buf && !skb_cloned(buf)) {
                msg_set_ack(buf_msg(buf), mod(l_ptr->next_in_no - 1));
-               msg_set_bcast_ack(buf_msg(buf), l_ptr->owner->bclink.last_in); 
+               msg_set_bcast_ack(buf_msg(buf), l_ptr->owner->bclink.last_in);
                if (tipc_bearer_send(l_ptr->b_ptr, buf, &l_ptr->media_addr)) {
                        msg_dbg(buf_msg(buf), ">DEF-RETR>");
                        l_ptr->retransm_queue_head = mod(++r_q_head);
@@ -1554,7 +1554,7 @@ u32 tipc_link_push_packet(struct link *l_ptr)
        buf = l_ptr->proto_msg_queue;
        if (buf) {
                msg_set_ack(buf_msg(buf), mod(l_ptr->next_in_no - 1));
-               msg_set_bcast_ack(buf_msg(buf),l_ptr->owner->bclink.last_in); 
+               msg_set_bcast_ack(buf_msg(buf),l_ptr->owner->bclink.last_in);
                if (tipc_bearer_send(l_ptr->b_ptr, buf, &l_ptr->media_addr)) {
                        msg_dbg(buf_msg(buf), ">DEF-PROT>");
                        l_ptr->unacked_window = 0;
@@ -1578,7 +1578,7 @@ u32 tipc_link_push_packet(struct link *l_ptr)
 
                if (mod(next - first) < l_ptr->queue_limit[0]) {
                        msg_set_ack(msg, mod(l_ptr->next_in_no - 1));
-                       msg_set_bcast_ack(msg, l_ptr->owner->bclink.last_in); 
+                       msg_set_bcast_ack(msg, l_ptr->owner->bclink.last_in);
                        if (tipc_bearer_send(l_ptr->b_ptr, buf, &l_ptr->media_addr)) {
                                if (msg_user(msg) == MSG_BUNDLER)
                                        msg_set_type(msg, CLOSED_MSG);
@@ -1629,12 +1629,12 @@ static void link_reset_all(unsigned long addr)
 
        tipc_node_lock(n_ptr);
 
-       warn("Resetting all links to %s\n", 
+       warn("Resetting all links to %s\n",
             addr_string_fill(addr_string, n_ptr->addr));
 
        for (i = 0; i < MAX_BEARERS; i++) {
                if (n_ptr->links[i]) {
-                       link_print(n_ptr->links[i], TIPC_OUTPUT, 
+                       link_print(n_ptr->links[i], TIPC_OUTPUT,
                                   "Resetting link\n");
                        tipc_link_reset(n_ptr->links[i]);
                }
@@ -1689,7 +1689,7 @@ static void link_retransmit_failure(struct link *l_ptr, struct sk_buff *buf)
        }
 }
 
-void tipc_link_retransmit(struct link *l_ptr, struct sk_buff *buf, 
+void tipc_link_retransmit(struct link *l_ptr, struct sk_buff *buf,
                          u32 retransmits)
 {
        struct tipc_msg *msg;
@@ -1698,7 +1698,7 @@ void tipc_link_retransmit(struct link *l_ptr, struct sk_buff *buf,
                return;
 
        msg = buf_msg(buf);
-       
+
        dbg("Retransmitting %u in link %x\n", retransmits, l_ptr);
 
        if (tipc_bearer_congested(l_ptr->b_ptr, l_ptr)) {
@@ -1728,7 +1728,7 @@ void tipc_link_retransmit(struct link *l_ptr, struct sk_buff *buf,
        while (retransmits && (buf != l_ptr->next_out) && buf && !skb_cloned(buf)) {
                msg = buf_msg(buf);
                msg_set_ack(msg, mod(l_ptr->next_in_no - 1));
-               msg_set_bcast_ack(msg, l_ptr->owner->bclink.last_in); 
+               msg_set_bcast_ack(msg, l_ptr->owner->bclink.last_in);
                if (tipc_bearer_send(l_ptr->b_ptr, buf, &l_ptr->media_addr)) {
                        msg_dbg(buf_msg(buf), ">RETR>");
                        buf = buf->next;
@@ -1746,7 +1746,7 @@ void tipc_link_retransmit(struct link *l_ptr, struct sk_buff *buf,
        l_ptr->retransm_queue_head = l_ptr->retransm_queue_size = 0;
 }
 
-/* 
+/*
  * link_recv_non_seq: Receive packets which are outside
  *                    the link sequence flow
  */
@@ -1761,11 +1761,11 @@ static void link_recv_non_seq(struct sk_buff *buf)
                tipc_bclink_recv_pkt(buf);
 }
 
-/** 
+/**
  * link_insert_deferred_queue - insert deferred messages back into receive chain
  */
 
-static struct sk_buff *link_insert_deferred_queue(struct link *l_ptr, 
+static struct sk_buff *link_insert_deferred_queue(struct link *l_ptr,
                                                  struct sk_buff *buf)
 {
        u32 seq_no;
@@ -1813,11 +1813,11 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *tb_ptr)
                        link_recv_non_seq(buf);
                        continue;
                }
-               
+
                if (unlikely(!msg_short(msg) &&
                             (msg_destnode(msg) != tipc_own_addr)))
                        goto cont;
-               
+
                n_ptr = tipc_node_find(msg_prevnode(msg));
                if (unlikely(!n_ptr))
                        goto cont;
@@ -1828,8 +1828,8 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *tb_ptr)
                        tipc_node_unlock(n_ptr);
                        goto cont;
                }
-               /* 
-                * Release acked messages 
+               /*
+                * Release acked messages
                 */
                if (less(n_ptr->bclink.acked, msg_bcast_ack(msg))) {
                        if (tipc_node_is_up(n_ptr) && n_ptr->bclink.supported)
@@ -1837,7 +1837,7 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *tb_ptr)
                }
 
                crs = l_ptr->first_out;
-               while ((crs != l_ptr->next_out) && 
+               while ((crs != l_ptr->next_out) &&
                       less_eq(msg_seqno(buf_msg(crs)), ackd)) {
                        struct sk_buff *next = crs->next;
 
@@ -1875,7 +1875,7 @@ deliver:
                                        switch (msg_user(msg)) {
                                        case MSG_BUNDLER:
                                                l_ptr->stats.recv_bundles++;
-                                               l_ptr->stats.recv_bundled += 
+                                               l_ptr->stats.recv_bundled +=
                                                        msg_msgcnt(msg);
                                                tipc_node_unlock(n_ptr);
                                                tipc_link_recv_bundle(buf);
@@ -1894,7 +1894,7 @@ deliver:
                                                continue;
                                        case MSG_FRAGMENTER:
                                                l_ptr->stats.recv_fragments++;
-                                               if (tipc_link_recv_fragment(&l_ptr->defragm_buf, 
+                                               if (tipc_link_recv_fragment(&l_ptr->defragm_buf,
                                                                            &buf, &msg)) {
                                                        l_ptr->stats.recv_fragmented++;
                                                        goto deliver;
@@ -1905,7 +1905,7 @@ deliver:
                                                if (link_recv_changeover_msg(&l_ptr, &buf)) {
                                                        msg = buf_msg(buf);
                                                        seq_no = msg_seqno(msg);
-                                                       TIPC_SKB_CB(buf)->handle 
+                                                       TIPC_SKB_CB(buf)->handle
                                                                = b_ptr;
                                                        if (type == ORIGINAL_MSG)
                                                                goto deliver;
@@ -1948,8 +1948,8 @@ cont:
        read_unlock_bh(&tipc_net_lock);
 }
 
-/* 
- * link_defer_buf(): Sort a received out-of-sequence packet 
+/*
+ * link_defer_buf(): Sort a received out-of-sequence packet
  *                   into the deferred reception queue.
  * Returns the increase of the queue length,i.e. 0 or 1
  */
@@ -1986,7 +1986,7 @@ u32 tipc_link_defer_pkt(struct sk_buff **head,
                        if (prev)
                                prev->next = buf;
                        else
-                               *head = buf;   
+                               *head = buf;
                        return 1;
                }
                if (seq_no == msg_seqno(msg)) {
@@ -2003,11 +2003,11 @@ u32 tipc_link_defer_pkt(struct sk_buff **head,
        return 0;
 }
 
-/** 
+/**
  * link_handle_out_of_seq_msg - handle arrival of out-of-sequence packet
  */
 
-static void link_handle_out_of_seq_msg(struct link *l_ptr, 
+static void link_handle_out_of_seq_msg(struct link *l_ptr,
                                       struct sk_buff *buf)
 {
        u32 seq_no = msg_seqno(buf_msg(buf));
@@ -2017,14 +2017,14 @@ static void link_handle_out_of_seq_msg(struct link *l_ptr,
                return;
        }
 
-       dbg("rx OOS msg: seq_no %u, expecting %u (%u)\n", 
+       dbg("rx OOS msg: seq_no %u, expecting %u (%u)\n",
            seq_no, mod(l_ptr->next_in_no), l_ptr->next_in_no);
 
        /* Record OOS packet arrival (force mismatch on next timeout) */
 
        l_ptr->checkpoint--;
 
-       /* 
+       /*
         * Discard packet if a duplicate; otherwise add it to deferred queue
         * and notify peer of gap as per protocol specification
         */
@@ -2053,13 +2053,13 @@ void tipc_link_send_proto_msg(struct link *l_ptr, u32 msg_typ, int probe_msg,
 {
        struct sk_buff *buf = NULL;
        struct tipc_msg *msg = l_ptr->pmsg;
-        u32 msg_size = sizeof(l_ptr->proto_msg);
+       u32 msg_size = sizeof(l_ptr->proto_msg);
 
        if (link_blocked(l_ptr))
                return;
        msg_set_type(msg, msg_typ);
        msg_set_net_plane(msg, l_ptr->b_ptr->net_plane);
-       msg_set_bcast_ack(msg, mod(l_ptr->owner->bclink.last_in)); 
+       msg_set_bcast_ack(msg, mod(l_ptr->owner->bclink.last_in));
        msg_set_last_bcast(msg, tipc_bclink_get_last_sent());
 
        if (msg_typ == STATE_MSG) {
@@ -2082,23 +2082,23 @@ void tipc_link_send_proto_msg(struct link *l_ptr, u32 msg_typ, int probe_msg,
                msg_set_max_pkt(msg, ack_mtu);
                msg_set_ack(msg, mod(l_ptr->next_in_no - 1));
                msg_set_probe(msg, probe_msg != 0);
-               if (probe_msg) { 
+               if (probe_msg) {
                        u32 mtu = l_ptr->max_pkt;
 
-                        if ((mtu < l_ptr->max_pkt_target) &&
+                       if ((mtu < l_ptr->max_pkt_target) &&
                            link_working_working(l_ptr) &&
                            l_ptr->fsm_msg_cnt) {
                                msg_size = (mtu + (l_ptr->max_pkt_target - mtu)/2 + 2) & ~3;
-                                if (l_ptr->max_pkt_probes == 10) {
-                                        l_ptr->max_pkt_target = (msg_size - 4);
-                                        l_ptr->max_pkt_probes = 0;
+                               if (l_ptr->max_pkt_probes == 10) {
+                                       l_ptr->max_pkt_target = (msg_size - 4);
+                                       l_ptr->max_pkt_probes = 0;
                                        msg_size = (mtu + (l_ptr->max_pkt_target - mtu)/2 + 2) & ~3;
-                                }
+                               }
                                l_ptr->max_pkt_probes++;
-                        }
+                       }
 
                        l_ptr->stats.sent_probes++;
-                }
+               }
                l_ptr->stats.sent_states++;
        } else {                /* RESET_MSG or ACTIVATE_MSG */
                msg_set_ack(msg, mod(l_ptr->reset_checkpoint - 1));
@@ -2144,7 +2144,7 @@ void tipc_link_send_proto_msg(struct link *l_ptr, u32 msg_typ, int probe_msg,
                return;
 
        memcpy(buf->data, (unchar *)msg, sizeof(l_ptr->proto_msg));
-        msg_set_size(buf_msg(buf), msg_size);
+       msg_set_size(buf_msg(buf), msg_size);
 
        if (tipc_bearer_send(l_ptr->b_ptr, buf, &l_ptr->media_addr)) {
                l_ptr->unacked_window = 0;
@@ -2160,15 +2160,15 @@ void tipc_link_send_proto_msg(struct link *l_ptr, u32 msg_typ, int probe_msg,
 
 /*
  * Receive protocol message :
- * Note that network plane id propagates through the network, and may 
- * change at any time. The node with lowest address rules    
+ * Note that network plane id propagates through the network, and may
+ * change at any time. The node with lowest address rules
  */
 
 static void link_recv_proto_msg(struct link *l_ptr, struct sk_buff *buf)
 {
        u32 rec_gap = 0;
        u32 max_pkt_info;
-        u32 max_pkt_ack;
+       u32 max_pkt_ack;
        u32 msg_tol;
        struct tipc_msg *msg = buf_msg(buf);
 
@@ -2188,12 +2188,12 @@ static void link_recv_proto_msg(struct link *l_ptr, struct sk_buff *buf)
        l_ptr->owner->permit_changeover = msg_redundant_link(msg);
 
        switch (msg_type(msg)) {
-       
+
        case RESET_MSG:
                if (!link_working_unknown(l_ptr) && l_ptr->peer_session) {
                        if (msg_session(msg) == l_ptr->peer_session) {
                                dbg("Duplicate RESET: %u<->%u\n",
-                                   msg_session(msg), l_ptr->peer_session);                                     
+                                   msg_session(msg), l_ptr->peer_session);
                                break; /* duplicate: ignore */
                        }
                }
@@ -2211,13 +2211,13 @@ static void link_recv_proto_msg(struct link *l_ptr, struct sk_buff *buf)
                        l_ptr->priority = msg_linkprio(msg);
 
                max_pkt_info = msg_max_pkt(msg);
-                if (max_pkt_info) {
+               if (max_pkt_info) {
                        if (max_pkt_info < l_ptr->max_pkt_target)
                                l_ptr->max_pkt_target = max_pkt_info;
                        if (l_ptr->max_pkt > l_ptr->max_pkt_target)
                                l_ptr->max_pkt = l_ptr->max_pkt_target;
                } else {
-                        l_ptr->max_pkt = l_ptr->max_pkt_target;
+                       l_ptr->max_pkt = l_ptr->max_pkt_target;
                }
                l_ptr->owner->bclink.supported = (max_pkt_info != 0);
 
@@ -2235,8 +2235,8 @@ static void link_recv_proto_msg(struct link *l_ptr, struct sk_buff *buf)
 
                if ((msg_tol = msg_link_tolerance(msg)))
                        link_set_supervision_props(l_ptr, msg_tol);
-               
-               if (msg_linkprio(msg) && 
+
+               if (msg_linkprio(msg) &&
                    (msg_linkprio(msg) != l_ptr->priority)) {
                        warn("Resetting link <%s>, priority change %u->%u\n",
                             l_ptr->name, l_ptr->priority, msg_linkprio(msg));
@@ -2250,25 +2250,25 @@ static void link_recv_proto_msg(struct link *l_ptr, struct sk_buff *buf)
                        break;
 
                if (less_eq(mod(l_ptr->next_in_no), msg_next_sent(msg))) {
-                       rec_gap = mod(msg_next_sent(msg) - 
+                       rec_gap = mod(msg_next_sent(msg) -
                                      mod(l_ptr->next_in_no));
                }
 
                max_pkt_ack = msg_max_pkt(msg);
-                if (max_pkt_ack > l_ptr->max_pkt) {
-                        dbg("Link <%s> updated MTU %u -> %u\n",
-                            l_ptr->name, l_ptr->max_pkt, max_pkt_ack);
-                        l_ptr->max_pkt = max_pkt_ack;
-                        l_ptr->max_pkt_probes = 0;
-                }
+               if (max_pkt_ack > l_ptr->max_pkt) {
+                       dbg("Link <%s> updated MTU %u -> %u\n",
+                           l_ptr->name, l_ptr->max_pkt, max_pkt_ack);
+                       l_ptr->max_pkt = max_pkt_ack;
+                       l_ptr->max_pkt_probes = 0;
+               }
 
                max_pkt_ack = 0;
-                if (msg_probe(msg)) {
+               if (msg_probe(msg)) {
                        l_ptr->stats.recv_probes++;
-                        if (msg_size(msg) > sizeof(l_ptr->proto_msg)) {
-                                max_pkt_ack = msg_size(msg);
-                        }
-                }
+                       if (msg_size(msg) > sizeof(l_ptr->proto_msg)) {
+                               max_pkt_ack = msg_size(msg);
+                       }
+               }
 
                /* Protocol message before retransmits, reduce loss risk */
 
@@ -2294,11 +2294,11 @@ exit:
 
 
 /*
- * tipc_link_tunnel(): Send one message via a link belonging to 
+ * tipc_link_tunnel(): Send one message via a link belonging to
  * another bearer. Owner node is locked.
  */
-void tipc_link_tunnel(struct link *l_ptr, 
-                     struct tipc_msg *tunnel_hdr, 
+void tipc_link_tunnel(struct link *l_ptr,
+                     struct tipc_msg *tunnel_hdr,
                      struct tipc_msg  *msg,
                      u32 selector)
 {
@@ -2374,7 +2374,7 @@ void tipc_link_changeover(struct link *l_ptr)
                return;
        }
 
-       split_bundles = (l_ptr->owner->active_links[0] != 
+       split_bundles = (l_ptr->owner->active_links[0] !=
                         l_ptr->owner->active_links[1]);
 
        while (crs) {
@@ -2418,7 +2418,7 @@ void tipc_link_send_duplicate(struct link *l_ptr, struct link *tunnel)
                if (msg_user(msg) == MSG_BUNDLER)
                        msg_set_type(msg, CLOSED_MSG);
                msg_set_ack(msg, mod(l_ptr->next_in_no - 1));   /* Update */
-               msg_set_bcast_ack(msg, l_ptr->owner->bclink.last_in); 
+               msg_set_bcast_ack(msg, l_ptr->owner->bclink.last_in);
                msg_set_size(&tunnel_hdr, length + INT_H_SIZE);
                outbuf = buf_acquire(length + INT_H_SIZE);
                if (outbuf == NULL) {
@@ -2445,7 +2445,7 @@ void tipc_link_send_duplicate(struct link *l_ptr, struct link *tunnel)
  * @skb: encapsulating message buffer
  * @from_pos: offset to extract from
  *
- * Returns a new message buffer containing an embedded message.  The 
+ * Returns a new message buffer containing an embedded message.  The
  * encapsulating message itself is left unchanged.
  */
 
@@ -2461,7 +2461,7 @@ static struct sk_buff *buf_extract(struct sk_buff *skb, u32 from_pos)
        return eb;
 }
 
-/* 
+/*
  *  link_recv_changeover_msg(): Receive tunneled packet sent
  *  via other link. Node is locked. Return extracted buffer.
  */
@@ -2482,7 +2482,7 @@ static int link_recv_changeover_msg(struct link **l_ptr,
                goto exit;
        }
        if (dest_link == *l_ptr) {
-               err("Unexpected changeover message on link <%s>\n", 
+               err("Unexpected changeover message on link <%s>\n",
                    (*l_ptr)->name);
                goto exit;
        }
@@ -2582,9 +2582,9 @@ void tipc_link_recv_bundle(struct sk_buff *buf)
  */
 
 
-/* 
+/*
  * tipc_link_send_long_buf: Entry for buffers needing fragmentation.
- * The buffer is complete, inclusive total message length. 
+ * The buffer is complete, inclusive total message length.
  * Returns user data length.
  */
 int tipc_link_send_long_buf(struct link *l_ptr, struct sk_buff *buf)
@@ -2650,9 +2650,9 @@ exit:
        return dsz;
 }
 
-/* 
- * A pending message being re-assembled must store certain values 
- * to handle subsequent fragments correctly. The following functions 
+/*
+ * A pending message being re-assembled must store certain values
+ * to handle subsequent fragments correctly. The following functions
  * help storing these values in unused, available fields in the
  * pending message. This makes dynamic memory allocation unecessary.
  */
@@ -2692,11 +2692,11 @@ static void incr_timer_cnt(struct sk_buff *buf)
        msg_incr_reroute_cnt(buf_msg(buf));
 }
 
-/* 
- * tipc_link_recv_fragment(): Called with node lock on. Returns 
+/*
+ * tipc_link_recv_fragment(): Called with node lock on. Returns
  * the reassembled buffer if message is complete.
  */
-int tipc_link_recv_fragment(struct sk_buff **pending, struct sk_buff **fb, 
+int tipc_link_recv_fragment(struct sk_buff **pending, struct sk_buff **fb,
                            struct tipc_msg **m)
 {
        struct sk_buff *prev = NULL;
@@ -2737,9 +2737,9 @@ int tipc_link_recv_fragment(struct sk_buff **pending, struct sk_buff **fb,
 
                        /*  Prepare buffer for subsequent fragments. */
 
-                       set_long_msg_seqno(pbuf, long_msg_seq_no); 
-                       set_fragm_size(pbuf,fragm_sz); 
-                       set_expected_frags(pbuf,exp_fragm_cnt - 1); 
+                       set_long_msg_seqno(pbuf, long_msg_seq_no);
+                       set_fragm_size(pbuf,fragm_sz);
+                       set_expected_frags(pbuf,exp_fragm_cnt - 1);
                } else {
                        warn("Link unable to reassemble fragmented message\n");
                }
@@ -2765,7 +2765,7 @@ int tipc_link_recv_fragment(struct sk_buff **pending, struct sk_buff **fb,
                        *m = buf_msg(pbuf);
                        return 1;
                }
-               set_expected_frags(pbuf,exp_frags);     
+               set_expected_frags(pbuf,exp_frags);
                return 0;
        }
        dbg(" Discarding orphan fragment %x\n",fbuf);
@@ -2849,10 +2849,10 @@ void tipc_link_set_queue_limits(struct link *l_ptr, u32 window)
  * link_find_link - locate link by name
  * @name - ptr to link name string
  * @node - ptr to area to be filled with ptr to associated node
- * 
+ *
  * Caller must hold 'tipc_net_lock' to ensure node and bearer are not deleted;
  * this also prevents link deletion.
- * 
+ *
  * Returns pointer to link (or 0 if invalid link name).
  */
 
@@ -2860,7 +2860,7 @@ static struct link *link_find_link(const char *name, struct node **node)
 {
        struct link_name link_name_parts;
        struct bearer *b_ptr;
-       struct link *l_ptr; 
+       struct link *l_ptr;
 
        if (!link_name_validate(name, &link_name_parts))
                return NULL;
@@ -2869,7 +2869,7 @@ static struct link *link_find_link(const char *name, struct node **node)
        if (!b_ptr)
                return NULL;
 
-       *node = tipc_node_find(link_name_parts.addr_peer); 
+       *node = tipc_node_find(link_name_parts.addr_peer);
        if (!*node)
                return NULL;
 
@@ -2880,14 +2880,14 @@ static struct link *link_find_link(const char *name, struct node **node)
        return l_ptr;
 }
 
-struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, int req_tlv_space, 
+struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, int req_tlv_space,
                                     u16 cmd)
 {
        struct tipc_link_config *args;
-        u32 new_value;
+       u32 new_value;
        struct link *l_ptr;
        struct node *node;
-        int res;
+       int res;
 
        if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_LINK_CONFIG))
                return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
@@ -2899,40 +2899,40 @@ struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, int req_tlv_space
                if ((cmd == TIPC_CMD_SET_LINK_WINDOW) &&
                    (tipc_bclink_set_queue_limits(new_value) == 0))
                        return tipc_cfg_reply_none();
-               return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
+               return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
                                                   " (cannot change setting on broadcast link)");
        }
 
        read_lock_bh(&tipc_net_lock);
-       l_ptr = link_find_link(args->name, &node); 
+       l_ptr = link_find_link(args->name, &node);
        if (!l_ptr) {
                read_unlock_bh(&tipc_net_lock);
-               return tipc_cfg_reply_error_string("link not found");
+               return tipc_cfg_reply_error_string("link not found");
        }
 
        tipc_node_lock(node);
        res = -EINVAL;
        switch (cmd) {
-       case TIPC_CMD_SET_LINK_TOL: 
-               if ((new_value >= TIPC_MIN_LINK_TOL) && 
+       case TIPC_CMD_SET_LINK_TOL:
+               if ((new_value >= TIPC_MIN_LINK_TOL) &&
                    (new_value <= TIPC_MAX_LINK_TOL)) {
                        link_set_supervision_props(l_ptr, new_value);
-                       tipc_link_send_proto_msg(l_ptr, STATE_MSG, 
+                       tipc_link_send_proto_msg(l_ptr, STATE_MSG,
                                                 0, 0, new_value, 0, 0);
                        res = TIPC_OK;
                }
                break;
-       case TIPC_CMD_SET_LINK_PRI: 
+       case TIPC_CMD_SET_LINK_PRI:
                if ((new_value >= TIPC_MIN_LINK_PRI) &&
                    (new_value <= TIPC_MAX_LINK_PRI)) {
                        l_ptr->priority = new_value;
-                       tipc_link_send_proto_msg(l_ptr, STATE_MSG, 
+                       tipc_link_send_proto_msg(l_ptr, STATE_MSG,
                                                 0, 0, 0, new_value, 0);
                        res = TIPC_OK;
                }
                break;
-       case TIPC_CMD_SET_LINK_WINDOW: 
-               if ((new_value >= TIPC_MIN_LINK_WIN) && 
+       case TIPC_CMD_SET_LINK_WINDOW:
+               if ((new_value >= TIPC_MIN_LINK_WIN) &&
                    (new_value <= TIPC_MAX_LINK_WIN)) {
                        tipc_link_set_queue_limits(l_ptr, new_value);
                        res = TIPC_OK;
@@ -2943,7 +2943,7 @@ struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, int req_tlv_space
 
        read_unlock_bh(&tipc_net_lock);
        if (res)
-               return tipc_cfg_reply_error_string("cannot change link setting");
+               return tipc_cfg_reply_error_string("cannot change link setting");
 
        return tipc_cfg_reply_none();
 }
@@ -2963,7 +2963,7 @@ static void link_reset_statistics(struct link *l_ptr)
 struct sk_buff *tipc_link_cmd_reset_stats(const void *req_tlv_area, int req_tlv_space)
 {
        char *link_name;
-       struct link *l_ptr; 
+       struct link *l_ptr;
        struct node *node;
 
        if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_LINK_NAME))
@@ -2977,7 +2977,7 @@ struct sk_buff *tipc_link_cmd_reset_stats(const void *req_tlv_area, int req_tlv_
        }
 
        read_lock_bh(&tipc_net_lock);
-       l_ptr = link_find_link(link_name, &node); 
+       l_ptr = link_find_link(link_name, &node);
        if (!l_ptr) {
                read_unlock_bh(&tipc_net_lock);
                return tipc_cfg_reply_error_string("link not found");
@@ -3004,14 +3004,14 @@ static u32 percent(u32 count, u32 total)
  * @name: link name
  * @buf: print buffer area
  * @buf_size: size of print buffer area
- * 
+ *
  * Returns length of print buffer data string (or 0 if error)
  */
 
 static int tipc_link_stats(const char *name, char *buf, const u32 buf_size)
 {
        struct print_buf pb;
-       struct link *l_ptr; 
+       struct link *l_ptr;
        struct node *node;
        char *status;
        u32 profile_total = 0;
@@ -3022,7 +3022,7 @@ static int tipc_link_stats(const char *name, char *buf, const u32 buf_size)
        tipc_printbuf_init(&pb, buf, buf_size);
 
        read_lock_bh(&tipc_net_lock);
-       l_ptr = link_find_link(name, &node); 
+       l_ptr = link_find_link(name, &node);
        if (!l_ptr) {
                read_unlock_bh(&tipc_net_lock);
                return 0;
@@ -3036,28 +3036,28 @@ static int tipc_link_stats(const char *name, char *buf, const u32 buf_size)
        else
                status = "DEFUNCT";
        tipc_printf(&pb, "Link <%s>\n"
-                        "  %s  MTU:%u  Priority:%u  Tolerance:%u ms"
-                        "  Window:%u packets\n", 
-                   l_ptr->name, status, link_max_pkt(l_ptr), 
+                        "  %s  MTU:%u  Priority:%u  Tolerance:%u ms"
+                        "  Window:%u packets\n",
+                   l_ptr->name, status, link_max_pkt(l_ptr),
                    l_ptr->priority, l_ptr->tolerance, l_ptr->queue_limit[0]);
-       tipc_printf(&pb, "  RX packets:%u fragments:%u/%u bundles:%u/%u\n", 
+       tipc_printf(&pb, "  RX packets:%u fragments:%u/%u bundles:%u/%u\n",
                    l_ptr->next_in_no - l_ptr->stats.recv_info,
                    l_ptr->stats.recv_fragments,
                    l_ptr->stats.recv_fragmented,
                    l_ptr->stats.recv_bundles,
                    l_ptr->stats.recv_bundled);
-       tipc_printf(&pb, "  TX packets:%u fragments:%u/%u bundles:%u/%u\n", 
+       tipc_printf(&pb, "  TX packets:%u fragments:%u/%u bundles:%u/%u\n",
                    l_ptr->next_out_no - l_ptr->stats.sent_info,
                    l_ptr->stats.sent_fragments,
-                   l_ptr->stats.sent_fragmented, 
+                   l_ptr->stats.sent_fragmented,
                    l_ptr->stats.sent_bundles,
                    l_ptr->stats.sent_bundled);
        profile_total = l_ptr->stats.msg_length_counts;
        if (!profile_total)
                profile_total = 1;
        tipc_printf(&pb, "  TX profile sample:%u packets  average:%u octets\n"
-                        "  0-64:%u%% -256:%u%% -1024:%u%% -4096:%u%% "
-                        "-16354:%u%% -32768:%u%% -66000:%u%%\n",
+                        "  0-64:%u%% -256:%u%% -1024:%u%% -4096:%u%% "
+                        "-16354:%u%% -32768:%u%% -66000:%u%%\n",
                    l_ptr->stats.msg_length_counts,
                    l_ptr->stats.msg_lengths_total / profile_total,
                    percent(l_ptr->stats.msg_length_profile[0], profile_total),
@@ -3067,21 +3067,21 @@ static int tipc_link_stats(const char *name, char *buf, const u32 buf_size)
                    percent(l_ptr->stats.msg_length_profile[4], profile_total),
                    percent(l_ptr->stats.msg_length_profile[5], profile_total),
                    percent(l_ptr->stats.msg_length_profile[6], profile_total));
-       tipc_printf(&pb, "  RX states:%u probes:%u naks:%u defs:%u dups:%u\n", 
+       tipc_printf(&pb, "  RX states:%u probes:%u naks:%u defs:%u dups:%u\n",
                    l_ptr->stats.recv_states,
                    l_ptr->stats.recv_probes,
                    l_ptr->stats.recv_nacks,
-                   l_ptr->stats.deferred_recv, 
+                   l_ptr->stats.deferred_recv,
                    l_ptr->stats.duplicates);
-       tipc_printf(&pb, "  TX states:%u probes:%u naks:%u acks:%u dups:%u\n", 
-                   l_ptr->stats.sent_states, 
-                   l_ptr->stats.sent_probes, 
-                   l_ptr->stats.sent_nacks, 
-                   l_ptr->stats.sent_acks, 
+       tipc_printf(&pb, "  TX states:%u probes:%u naks:%u acks:%u dups:%u\n",
+                   l_ptr->stats.sent_states,
+                   l_ptr->stats.sent_probes,
+                   l_ptr->stats.sent_nacks,
+                   l_ptr->stats.sent_acks,
                    l_ptr->stats.retransmitted);
        tipc_printf(&pb, "  Congestion bearer:%u link:%u  Send queue max:%u avg:%u\n",
                    l_ptr->stats.bearer_congs,
-                   l_ptr->stats.link_congs, 
+                   l_ptr->stats.link_congs,
                    l_ptr->stats.max_queue_sz,
                    l_ptr->stats.queue_sz_counts
                    ? (l_ptr->stats.accu_queue_sz / l_ptr->stats.queue_sz_counts)
@@ -3113,7 +3113,7 @@ struct sk_buff *tipc_link_cmd_show_stats(const void *req_tlv_area, int req_tlv_s
                                  (char *)TLV_DATA(rep_tlv), MAX_LINK_STATS_INFO);
        if (!str_len) {
                buf_discard(buf);
-               return tipc_cfg_reply_error_string("link not found");
+               return tipc_cfg_reply_error_string("link not found");
        }
 
        skb_put(buf, TLV_SPACE(str_len));
@@ -3164,7 +3164,7 @@ int link_control(const char *name, u32 op, u32 val)
  * tipc_link_get_max_pkt - get maximum packet size to use when sending to destination
  * @dest: network address of destination node
  * @selector: used to select from set of active links
- * 
+ *
  * If no active link can be found, uses default maximum packet size.
  */
 
@@ -3173,11 +3173,11 @@ u32 tipc_link_get_max_pkt(u32 dest, u32 selector)
        struct node *n_ptr;
        struct link *l_ptr;
        u32 res = MAX_PKT_DEFAULT;
-       
+
        if (dest == tipc_own_addr)
                return MAX_MSG_SIZE;
 
-       read_lock_bh(&tipc_net_lock);        
+       read_lock_bh(&tipc_net_lock);
        n_ptr = tipc_node_select(dest, selector);
        if (n_ptr) {
                tipc_node_lock(n_ptr);
@@ -3186,7 +3186,7 @@ u32 tipc_link_get_max_pkt(u32 dest, u32 selector)
                        res = link_max_pkt(l_ptr);
                tipc_node_unlock(n_ptr);
        }
-       read_unlock_bh(&tipc_net_lock);       
+       read_unlock_bh(&tipc_net_lock);
        return res;
 }
 
@@ -3244,8 +3244,8 @@ static void link_print(struct link *l_ptr, struct print_buf *buf,
                tipc_printf(buf, "%u]",
                            msg_seqno(buf_msg
                                      (l_ptr->last_out)), l_ptr->out_queue_size);
-               if ((mod(msg_seqno(buf_msg(l_ptr->last_out)) - 
-                        msg_seqno(buf_msg(l_ptr->first_out))) 
+               if ((mod(msg_seqno(buf_msg(l_ptr->last_out)) -
+                        msg_seqno(buf_msg(l_ptr->first_out)))
                     != (l_ptr->out_queue_size - 1))
                    || (l_ptr->last_out->next != 0)) {
                        tipc_printf(buf, "\nSend queue inconsistency\n");
index 2d3c157f707d179e8961dceb6b36fa104e38d4f4..52f3e7c1871fbee83a5d84a78387fbca00cc60e7 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * net/tipc/link.h: Include file for TIPC link code
- * 
+ *
  * Copyright (c) 1995-2006, Ericsson AB
  * Copyright (c) 2004-2005, Wind River Systems
  * All rights reserved.
@@ -45,8 +45,8 @@
 #define PUSH_FAILED   1
 #define PUSH_FINISHED 2
 
-/* 
- * Link states 
+/*
+ * Link states
  */
 
 #define WORKING_WORKING 560810u
@@ -54,7 +54,7 @@
 #define RESET_UNKNOWN   560812u
 #define RESET_RESET     560813u
 
-/* 
+/*
  * Starting value for maximum packet size negotiation on unicast links
  * (unless bearer MTU is less)
  */
@@ -74,7 +74,7 @@
  * @peer_session: link session # being used by peer end of link
  * @peer_bearer_id: bearer id used by link's peer endpoint
  * @b_ptr: pointer to bearer used by link
- * @tolerance: minimum link continuity loss needed to reset link [in ms] 
+ * @tolerance: minimum link continuity loss needed to reset link [in ms]
  * @continuity_interval: link continuity testing interval [in ms]
  * @abort_limit: # of unacknowledged continuity probes needed to reset link
  * @state: current state of link FSM
  * @stats: collects statistics regarding link activity
  * @print_buf: print buffer used to log link activity
  */
+
 struct link {
        u32 addr;
        char name[TIPC_MAX_LINK_NAME];
@@ -143,18 +143,18 @@ struct link {
        u32 exp_msg_count;
        u32 reset_checkpoint;
 
-        /* Max packet negotiation */
-        u32 max_pkt;
-        u32 max_pkt_target;
-        u32 max_pkt_probes;
+       /* Max packet negotiation */
+       u32 max_pkt;
+       u32 max_pkt_target;
+       u32 max_pkt_probes;
 
        /* Sending */
        u32 out_queue_size;
        struct sk_buff *first_out;
        struct sk_buff *last_out;
        u32 next_out_no;
-        u32 last_retransmitted;
-        u32 stale_count;
+       u32 last_retransmitted;
+       u32 stale_count;
 
        /* Reception */
        u32 next_in_no;
@@ -174,7 +174,7 @@ struct link {
        u32 long_msg_seq_no;
        struct sk_buff *defragm_buf;
 
-        /* Statistics */
+       /* Statistics */
        struct {
                u32 sent_info;          /* used in counting # sent packets */
                u32 recv_info;          /* used in counting # recv'd packets */
@@ -239,9 +239,9 @@ void tipc_link_reset(struct link *l_ptr);
 int tipc_link_send(struct sk_buff *buf, u32 dest, u32 selector);
 int tipc_link_send_buf(struct link *l_ptr, struct sk_buff *buf);
 u32 tipc_link_get_max_pkt(u32 dest,u32 selector);
-int tipc_link_send_sections_fast(struct port* sender, 
+int tipc_link_send_sections_fast(struct port* sender,
                                 struct iovec const *msg_sect,
-                                const u32 num_sect, 
+                                const u32 num_sect,
                                 u32 destnode);
 int tipc_link_send_long_buf(struct link *l_ptr, struct sk_buff *buf);
 void tipc_link_tunnel(struct link *l_ptr, struct tipc_msg *tnl_hdr,
@@ -250,7 +250,7 @@ void tipc_link_recv_bundle(struct sk_buff *buf);
 int  tipc_link_recv_fragment(struct sk_buff **pending,
                             struct sk_buff **fb,
                             struct tipc_msg **msg);
-void tipc_link_send_proto_msg(struct link *l_ptr, u32 msg_typ, int prob, u32 gap, 
+void tipc_link_send_proto_msg(struct link *l_ptr, u32 msg_typ, int prob, u32 gap,
                              u32 tolerance, u32 priority, u32 acked_mtu);
 void tipc_link_push_queue(struct link *l_ptr);
 u32 tipc_link_defer_pkt(struct sk_buff **head, struct sk_buff **tail,
index 3bd345a344e52eae9a5bb783f60219eefc4f440d..782485468fb2a1445a29317643ee66b617fe5099 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * net/tipc/msg.c: TIPC message header routines
- *     
+ *
  * Copyright (c) 2000-2006, Ericsson AB
  * Copyright (c) 2005, Wind River Systems
  * All rights reserved.
index 6699aaf7bd4cdefa305ef8eb95d19fc5ed987241..62d5490636044e41bddb4834aec81dd563bc61de 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * net/tipc/msg.h: Include file for TIPC message header routines
- * 
+ *
  * Copyright (c) 2000-2006, Ericsson AB
  * Copyright (c) 2005, Wind River Systems
  * All rights reserved.
 
 /*
                TIPC user data message header format, version 2
-               
+
        - Fundamental definitions available to privileged TIPC users
          are located in tipc_msg.h.
-       - Remaining definitions available to TIPC internal users appear below. 
+       - Remaining definitions available to TIPC internal users appear below.
 */
 
 
@@ -75,7 +75,7 @@ static inline void msg_set_bits(struct tipc_msg *m, u32 w,
        msg_set_word(m, w, (word |= (val << pos)));
 }
 
-/* 
+/*
  * Word 0
  */
 
@@ -84,7 +84,7 @@ static inline u32 msg_version(struct tipc_msg *m)
        return msg_bits(m, 0, 29, 7);
 }
 
-static inline void msg_set_version(struct tipc_msg *m) 
+static inline void msg_set_version(struct tipc_msg *m)
 {
        msg_set_bits(m, 0, 29, 0xf, TIPC_VERSION);
 }
@@ -99,47 +99,47 @@ static inline u32 msg_isdata(struct tipc_msg *m)
        return (msg_user(m) <= DATA_CRITICAL);
 }
 
-static inline void msg_set_user(struct tipc_msg *m, u32 n) 
+static inline void msg_set_user(struct tipc_msg *m, u32 n)
 {
        msg_set_bits(m, 0, 25, 0xf, n);
 }
 
-static inline void msg_set_importance(struct tipc_msg *m, u32 i) 
+static inline void msg_set_importance(struct tipc_msg *m, u32 i)
 {
        msg_set_user(m, i);
 }
 
-static inline void msg_set_hdr_sz(struct tipc_msg *m,u32 n) 
+static inline void msg_set_hdr_sz(struct tipc_msg *m,u32 n)
 {
        msg_set_bits(m, 0, 21, 0xf, n>>2);
 }
 
-static inline int msg_non_seq(struct tipc_msg *m) 
+static inline int msg_non_seq(struct tipc_msg *m)
 {
        return msg_bits(m, 0, 20, 1);
 }
 
-static inline void msg_set_non_seq(struct tipc_msg *m) 
+static inline void msg_set_non_seq(struct tipc_msg *m)
 {
        msg_set_bits(m, 0, 20, 1, 1);
 }
 
-static inline int msg_dest_droppable(struct tipc_msg *m) 
+static inline int msg_dest_droppable(struct tipc_msg *m)
 {
        return msg_bits(m, 0, 19, 1);
 }
 
-static inline void msg_set_dest_droppable(struct tipc_msg *m, u32 d) 
+static inline void msg_set_dest_droppable(struct tipc_msg *m, u32 d)
 {
        msg_set_bits(m, 0, 19, 1, d);
 }
 
-static inline int msg_src_droppable(struct tipc_msg *m) 
+static inline int msg_src_droppable(struct tipc_msg *m)
 {
        return msg_bits(m, 0, 18, 1);
 }
 
-static inline void msg_set_src_droppable(struct tipc_msg *m, u32 d) 
+static inline void msg_set_src_droppable(struct tipc_msg *m, u32 d)
 {
        msg_set_bits(m, 0, 18, 1, d);
 }
@@ -150,31 +150,31 @@ static inline void msg_set_size(struct tipc_msg *m, u32 sz)
 }
 
 
-/* 
+/*
  * Word 1
  */
 
-static inline void msg_set_type(struct tipc_msg *m, u32 n) 
+static inline void msg_set_type(struct tipc_msg *m, u32 n)
 {
        msg_set_bits(m, 1, 29, 0x7, n);
 }
 
-static inline void msg_set_errcode(struct tipc_msg *m, u32 err) 
+static inline void msg_set_errcode(struct tipc_msg *m, u32 err)
 {
        msg_set_bits(m, 1, 25, 0xf, err);
 }
 
-static inline u32 msg_reroute_cnt(struct tipc_msg *m) 
+static inline u32 msg_reroute_cnt(struct tipc_msg *m)
 {
        return msg_bits(m, 1, 21, 0xf);
 }
 
-static inline void msg_incr_reroute_cnt(struct tipc_msg *m) 
+static inline void msg_incr_reroute_cnt(struct tipc_msg *m)
 {
        msg_set_bits(m, 1, 21, 0xf, msg_reroute_cnt(m) + 1);
 }
 
-static inline void msg_reset_reroute_cnt(struct tipc_msg *m) 
+static inline void msg_reset_reroute_cnt(struct tipc_msg *m)
 {
        msg_set_bits(m, 1, 21, 0xf, 0);
 }
@@ -184,12 +184,12 @@ static inline u32 msg_lookup_scope(struct tipc_msg *m)
        return msg_bits(m, 1, 19, 0x3);
 }
 
-static inline void msg_set_lookup_scope(struct tipc_msg *m, u32 n) 
+static inline void msg_set_lookup_scope(struct tipc_msg *m, u32 n)
 {
        msg_set_bits(m, 1, 19, 0x3, n);
 }
 
-static inline void msg_set_options(struct tipc_msg *m, const char *opt, u32 sz) 
+static inline void msg_set_options(struct tipc_msg *m, const char *opt, u32 sz)
 {
        u32 hsz = msg_hdr_sz(m);
        char *to = (char *)&m->hdr[hsz/4];
@@ -206,13 +206,13 @@ static inline u32 msg_bcast_ack(struct tipc_msg *m)
        return msg_bits(m, 1, 0, 0xffff);
 }
 
-static inline void msg_set_bcast_ack(struct tipc_msg *m, u32 n) 
+static inline void msg_set_bcast_ack(struct tipc_msg *m, u32 n)
 {
        msg_set_bits(m, 1, 0, 0xffff, n);
 }
 
 
-/* 
+/*
  * Word 2
  */
 
@@ -221,7 +221,7 @@ static inline u32 msg_ack(struct tipc_msg *m)
        return msg_bits(m, 2, 16, 0xffff);
 }
 
-static inline void msg_set_ack(struct tipc_msg *m, u32 n) 
+static inline void msg_set_ack(struct tipc_msg *m, u32 n)
 {
        msg_set_bits(m, 2, 16, 0xffff, n);
 }
@@ -231,48 +231,48 @@ static inline u32 msg_seqno(struct tipc_msg *m)
        return msg_bits(m, 2, 0, 0xffff);
 }
 
-static inline void msg_set_seqno(struct tipc_msg *m, u32 n) 
+static inline void msg_set_seqno(struct tipc_msg *m, u32 n)
 {
        msg_set_bits(m, 2, 0, 0xffff, n);
 }
 
 
-/* 
+/*
  * Words 3-10
  */
 
 
-static inline void msg_set_prevnode(struct tipc_msg *m, u32 a) 
+static inline void msg_set_prevnode(struct tipc_msg *m, u32 a)
 {
        msg_set_word(m, 3, a);
 }
 
-static inline void msg_set_origport(struct tipc_msg *m, u32 p) 
+static inline void msg_set_origport(struct tipc_msg *m, u32 p)
 {
        msg_set_word(m, 4, p);
 }
 
-static inline void msg_set_destport(struct tipc_msg *m, u32 p) 
+static inline void msg_set_destport(struct tipc_msg *m, u32 p)
 {
        msg_set_word(m, 5, p);
 }
 
-static inline void msg_set_mc_netid(struct tipc_msg *m, u32 p) 
+static inline void msg_set_mc_netid(struct tipc_msg *m, u32 p)
 {
        msg_set_word(m, 5, p);
 }
 
-static inline void msg_set_orignode(struct tipc_msg *m, u32 a) 
+static inline void msg_set_orignode(struct tipc_msg *m, u32 a)
 {
        msg_set_word(m, 6, a);
 }
 
-static inline void msg_set_destnode(struct tipc_msg *m, u32 a) 
+static inline void msg_set_destnode(struct tipc_msg *m, u32 a)
 {
        msg_set_word(m, 7, a);
 }
 
-static inline int msg_is_dest(struct tipc_msg *m, u32 d) 
+static inline int msg_is_dest(struct tipc_msg *m, u32 d)
 {
        return(msg_short(m) || (msg_destnode(m) == d));
 }
@@ -284,7 +284,7 @@ static inline u32 msg_routed(struct tipc_msg *m)
        return(msg_destnode(m) ^ msg_orignode(m)) >> 11;
 }
 
-static inline void msg_set_nametype(struct tipc_msg *m, u32 n) 
+static inline void msg_set_nametype(struct tipc_msg *m, u32 n)
 {
        msg_set_word(m, 8, n);
 }
@@ -309,17 +309,17 @@ static inline void msg_set_transp_seqno(struct tipc_msg *m, u32 n)
        msg_set_word(m, 8, n);
 }
 
-static inline void msg_set_namelower(struct tipc_msg *m, u32 n) 
+static inline void msg_set_namelower(struct tipc_msg *m, u32 n)
 {
        msg_set_word(m, 9, n);
 }
 
-static inline void msg_set_nameinst(struct tipc_msg *m, u32 n) 
+static inline void msg_set_nameinst(struct tipc_msg *m, u32 n)
 {
        msg_set_namelower(m, n);
 }
 
-static inline void msg_set_nameupper(struct tipc_msg *m, u32 n) 
+static inline void msg_set_nameupper(struct tipc_msg *m, u32 n)
 {
        msg_set_word(m, 10, n);
 }
@@ -329,7 +329,7 @@ static inline struct tipc_msg *msg_get_wrapped(struct tipc_msg *m)
        return (struct tipc_msg *)msg_data(m);
 }
 
-static inline void msg_expand(struct tipc_msg *m, u32 destnode) 
+static inline void msg_expand(struct tipc_msg *m, u32 destnode)
 {
        if (!msg_short(m))
                return;
@@ -344,7 +344,7 @@ static inline void msg_expand(struct tipc_msg *m, u32 destnode)
 /*
                TIPC internal message header format, version 2
 
-       1 0 9 8 7 6 5 4|3 2 1 0 9 8 7 6|5 4 3 2 1 0 9 8|7 6 5 4 3 2 1 0 
+       1 0 9 8 7 6 5 4|3 2 1 0 9 8 7 6|5 4 3 2 1 0 9 8|7 6 5 4 3 2 1 0
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    w0:|vers |msg usr|hdr sz |n|resrv|            packet size          |
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -372,9 +372,9 @@ static inline void msg_expand(struct tipc_msg *m, u32 destnode)
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 
       NB: CONN_MANAGER use data message format. LINK_CONFIG has own format.
-*/   
+*/
 
-/* 
+/*
  * Internal users
  */
 
@@ -390,7 +390,7 @@ static inline void msg_expand(struct tipc_msg *m, u32 destnode)
 #define  INT_H_SIZE           40
 #define  DSC_H_SIZE           40
 
-/* 
+/*
  *  Connection management protocol messages
  */
 
@@ -398,7 +398,7 @@ static inline void msg_expand(struct tipc_msg *m, u32 destnode)
 #define CONN_PROBE_REPLY  1
 #define CONN_ACK          2
 
-/* 
+/*
  * Name distributor messages
  */
 
@@ -406,7 +406,7 @@ static inline void msg_expand(struct tipc_msg *m, u32 destnode)
 #define WITHDRAWAL        1
 
 
-/* 
+/*
  * Word 1
  */
 
@@ -425,13 +425,13 @@ static inline u32 msg_req_links(struct tipc_msg *m)
        return msg_bits(m, 1, 16, 0xfff);
 }
 
-static inline void msg_set_req_links(struct tipc_msg *m, u32 n) 
+static inline void msg_set_req_links(struct tipc_msg *m, u32 n)
 {
        msg_set_bits(m, 1, 16, 0xfff, n);
 }
 
 
-/* 
+/*
  * Word 2
  */
 
@@ -440,7 +440,7 @@ static inline u32 msg_dest_domain(struct tipc_msg *m)
        return msg_word(m, 2);
 }
 
-static inline void msg_set_dest_domain(struct tipc_msg *m, u32 n) 
+static inline void msg_set_dest_domain(struct tipc_msg *m, u32 n)
 {
        msg_set_word(m, 2, n);
 }
@@ -460,13 +460,13 @@ static inline u32 msg_bcgap_to(struct tipc_msg *m)
        return msg_bits(m, 2, 0, 0xffff);
 }
 
-static inline void msg_set_bcgap_to(struct tipc_msg *m, u32 n) 
+static inline void msg_set_bcgap_to(struct tipc_msg *m, u32 n)
 {
        msg_set_bits(m, 2, 0, 0xffff, n);
 }
 
 
-/* 
+/*
  * Word 4
  */
 
@@ -533,7 +533,7 @@ static inline void msg_set_link_selector(struct tipc_msg *m, u32 n)
        msg_set_bits(m, 4, 0, 1, (n & 1));
 }
 
-/* 
+/*
  * Word 5
  */
 
@@ -603,7 +603,7 @@ static inline void msg_clear_redundant_link(struct tipc_msg *m)
 }
 
 
-/* 
+/*
  * Word 9
  */
 
@@ -627,12 +627,12 @@ static inline void msg_set_bcast_tag(struct tipc_msg *m, u32 n)
        msg_set_bits(m, 9, 16, 0xffff, n);
 }
 
-static inline u32 msg_max_pkt(struct tipc_msg *m) 
+static inline u32 msg_max_pkt(struct tipc_msg *m)
 {
        return (msg_bits(m, 9, 16, 0xffff) * 4);
 }
 
-static inline void msg_set_max_pkt(struct tipc_msg *m, u32 n) 
+static inline void msg_set_max_pkt(struct tipc_msg *m, u32 n)
 {
        msg_set_bits(m, 9, 16, 0xffff, (n / 4));
 }
@@ -647,7 +647,7 @@ static inline void msg_set_link_tolerance(struct tipc_msg *m, u32 n)
        msg_set_bits(m, 9, 0, 0xffff, n);
 }
 
-/* 
+/*
  * Routing table message data
  */
 
@@ -672,7 +672,7 @@ static inline void msg_set_dataoctet(struct tipc_msg *m, u32 pos)
        msg_data(m)[pos + 4] = 1;
 }
 
-/* 
+/*
  * Segmentation message types
  */
 
@@ -680,7 +680,7 @@ static inline void msg_set_dataoctet(struct tipc_msg *m, u32 pos)
 #define FRAGMENT           1
 #define LAST_FRAGMENT      2
 
-/* 
+/*
  * Link management protocol message types
  */
 
@@ -688,13 +688,13 @@ static inline void msg_set_dataoctet(struct tipc_msg *m, u32 pos)
 #define RESET_MSG       1
 #define ACTIVATE_MSG    2
 
-/* 
+/*
  * Changeover tunnel message types
  */
 #define DUPLICATE_MSG    0
 #define ORIGINAL_MSG     1
 
-/* 
+/*
  * Routing table message types
  */
 #define EXT_ROUTING_TABLE    0
@@ -703,7 +703,7 @@ static inline void msg_set_dataoctet(struct tipc_msg *m, u32 pos)
 #define ROUTE_ADDITION       3
 #define ROUTE_REMOVAL        4
 
-/* 
+/*
  * Config protocol message types
  */
 
@@ -724,7 +724,7 @@ static inline u32 msg_tot_importance(struct tipc_msg *m)
 }
 
 
-static inline void msg_init(struct tipc_msg *m, u32 user, u32 type, 
+static inline void msg_init(struct tipc_msg *m, u32 user, u32 type,
                            u32 err, u32 hsize, u32 destnode)
 {
        memset(m, 0, hsize);
@@ -741,7 +741,7 @@ static inline void msg_init(struct tipc_msg *m, u32 user, u32 type,
        }
 }
 
-/** 
+/**
  * msg_calc_data_size - determine total data size for message
  */
 
@@ -755,15 +755,15 @@ static inline int msg_calc_data_size(struct iovec const *msg_sect, u32 num_sect)
        return dsz;
 }
 
-/** 
+/**
  * msg_build - create message using specified header and data
- * 
+ *
  * Note: Caller must not hold any locks in case copy_from_user() is interrupted!
- * 
+ *
  * Returns message data size or errno
  */
 
-static inline int msg_build(struct tipc_msg *hdr, 
+static inline int msg_build(struct tipc_msg *hdr,
                            struct iovec const *msg_sect, u32 num_sect,
                            int max_size, int usrmem, struct sk_buff** buf)
 {
@@ -789,11 +789,11 @@ static inline int msg_build(struct tipc_msg *hdr,
        memcpy((*buf)->data, (unchar *)hdr, hsz);
        for (res = 1, cnt = 0; res && (cnt < num_sect); cnt++) {
                if (likely(usrmem))
-                       res = !copy_from_user((*buf)->data + pos, 
-                                             msg_sect[cnt].iov_base, 
+                       res = !copy_from_user((*buf)->data + pos,
+                                             msg_sect[cnt].iov_base,
                                              msg_sect[cnt].iov_len);
                else
-                       memcpy((*buf)->data + pos, msg_sect[cnt].iov_base, 
+                       memcpy((*buf)->data + pos, msg_sect[cnt].iov_base,
                               msg_sect[cnt].iov_len);
                pos += msg_sect[cnt].iov_len;
        }
index 7bf87cb26ef3e0dbf072f760d112052646e9f357..39fd1619febf4c1e9e4c49152fe0fb9964d02522 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * net/tipc/name_distr.c: TIPC name distribution code
- * 
+ *
  * Copyright (c) 2000-2006, Ericsson AB
  * Copyright (c) 2005, Wind River Systems
  * All rights reserved.
  * @upper: name sequence upper bound
  * @ref: publishing port reference
  * @key: publication key
- * 
+ *
  * ===> All fields are stored in network byte order. <===
- * 
+ *
  * First 3 fields identify (name or) name sequence being published.
  * Reference field uniquely identifies port that published name sequence.
  * Key field uniquely identifies publication, in the event a port has
  * multiple publications of the same name sequence.
- * 
- * Note: There is no field that identifies the publishing node because it is 
+ *
+ * Note: There is no field that identifies the publishing node because it is
  * the same for all items contained within a publication message.
  */
 
@@ -74,12 +74,12 @@ struct distr_item {
 };
 
 /**
- * List of externally visible publications by this node -- 
+ * List of externally visible publications by this node --
  * that is, all publications having scope > TIPC_NODE_SCOPE.
  */
 
 static LIST_HEAD(publ_root);
-static u32 publ_cnt = 0;               
+static u32 publ_cnt = 0;
 
 /**
  * publ_to_item - add publication info to a publication message
@@ -101,12 +101,12 @@ static void publ_to_item(struct distr_item *i, struct publication *p)
 
 static struct sk_buff *named_prepare_buf(u32 type, u32 size, u32 dest)
 {
-       struct sk_buff *buf = buf_acquire(LONG_H_SIZE + size);  
+       struct sk_buff *buf = buf_acquire(LONG_H_SIZE + size);
        struct tipc_msg *msg;
 
        if (buf != NULL) {
                msg = buf_msg(buf);
-               msg_init(msg, NAME_DISTRIBUTOR, type, TIPC_OK, 
+               msg_init(msg, NAME_DISTRIBUTOR, type, TIPC_OK,
                         LONG_H_SIZE, dest);
                msg_set_size(msg, LONG_H_SIZE + size);
        }
@@ -174,7 +174,7 @@ void tipc_named_node_up(unsigned long node)
        u32 rest;
        u32 max_item_buf;
 
-       read_lock_bh(&tipc_nametbl_lock); 
+       read_lock_bh(&tipc_nametbl_lock);
        max_item_buf = TIPC_MAX_USER_MSG_SIZE / ITEM_SIZE;
        max_item_buf *= ITEM_SIZE;
        rest = publ_cnt * ITEM_SIZE;
@@ -183,7 +183,7 @@ void tipc_named_node_up(unsigned long node)
                if (!buf) {
                        left = (rest <= max_item_buf) ? rest : max_item_buf;
                        rest -= left;
-                       buf = named_prepare_buf(PUBLICATION, left, node);       
+                       buf = named_prepare_buf(PUBLICATION, left, node);
                        if (!buf) {
                                warn("Bulk publication distribution failure\n");
                                goto exit;
@@ -196,20 +196,20 @@ void tipc_named_node_up(unsigned long node)
                if (!left) {
                        msg_set_link_selector(buf_msg(buf), node);
                        dbg("tipc_named_node_up: sending publish msg to "
-                           "<%u.%u.%u>\n", tipc_zone(node), 
+                           "<%u.%u.%u>\n", tipc_zone(node),
                            tipc_cluster(node), tipc_node(node));
                        tipc_link_send(buf, node, node);
                        buf = NULL;
                }
        }
 exit:
-       read_unlock_bh(&tipc_nametbl_lock); 
+       read_unlock_bh(&tipc_nametbl_lock);
 }
 
 /**
  * node_is_down - remove publication associated with a failed node
- * 
- * Invoked for each publication issued by a newly failed node.  
+ *
+ * Invoked for each publication issued by a newly failed node.
  * Removes publication structure from name table & deletes it.
  * In rare cases the link may have come back up again when this
  * function is called, and we have two items representing the same
@@ -221,15 +221,15 @@ static void node_is_down(struct publication *publ)
 {
        struct publication *p;
 
-        write_lock_bh(&tipc_nametbl_lock);
-       dbg("node_is_down: withdrawing %u, %u, %u\n", 
+       write_lock_bh(&tipc_nametbl_lock);
+       dbg("node_is_down: withdrawing %u, %u, %u\n",
            publ->type, publ->lower, publ->upper);
-        publ->key += 1222345;
-       p = tipc_nametbl_remove_publ(publ->type, publ->lower, 
+       publ->key += 1222345;
+       p = tipc_nametbl_remove_publ(publ->type, publ->lower,
                                     publ->node, publ->ref, publ->key);
        write_unlock_bh(&tipc_nametbl_lock);
 
-        if (p != publ) {
+       if (p != publ) {
                err("Unable to remove publication from failed node\n"
                    "(type=%u, lower=%u, node=0x%x, ref=%u, key=%u)\n",
                    publ->type, publ->lower, publ->node, publ->ref, publ->key);
@@ -251,27 +251,27 @@ void tipc_named_recv(struct sk_buff *buf)
        struct distr_item *item = (struct distr_item *)msg_data(msg);
        u32 count = msg_data_sz(msg) / ITEM_SIZE;
 
-       write_lock_bh(&tipc_nametbl_lock); 
+       write_lock_bh(&tipc_nametbl_lock);
        while (count--) {
                if (msg_type(msg) == PUBLICATION) {
-                       dbg("tipc_named_recv: got publication for %u, %u, %u\n", 
+                       dbg("tipc_named_recv: got publication for %u, %u, %u\n",
                            ntohl(item->type), ntohl(item->lower),
                            ntohl(item->upper));
-                       publ = tipc_nametbl_insert_publ(ntohl(item->type), 
+                       publ = tipc_nametbl_insert_publ(ntohl(item->type),
                                                        ntohl(item->lower),
                                                        ntohl(item->upper),
                                                        TIPC_CLUSTER_SCOPE,
-                                                       msg_orignode(msg), 
+                                                       msg_orignode(msg),
                                                        ntohl(item->ref),
                                                        ntohl(item->key));
                        if (publ) {
-                               tipc_nodesub_subscribe(&publ->subscr, 
-                                                      msg_orignode(msg), 
+                               tipc_nodesub_subscribe(&publ->subscr,
+                                                      msg_orignode(msg),
                                                       publ,
                                                       (net_ev_handler)node_is_down);
                        }
                } else if (msg_type(msg) == WITHDRAWAL) {
-                       dbg("tipc_named_recv: got withdrawl for %u, %u, %u\n", 
+                       dbg("tipc_named_recv: got withdrawl for %u, %u, %u\n",
                            ntohl(item->type), ntohl(item->lower),
                            ntohl(item->upper));
                        publ = tipc_nametbl_remove_publ(ntohl(item->type),
@@ -282,7 +282,7 @@ void tipc_named_recv(struct sk_buff *buf)
 
                        if (publ) {
                                tipc_nodesub_unsubscribe(&publ->subscr);
-                               kfree(publ);
+                               kfree(publ);
                        } else {
                                err("Unable to remove publication by node 0x%x\n"
                                    "(type=%u, lower=%u, ref=%u, key=%u)\n",
@@ -295,13 +295,13 @@ void tipc_named_recv(struct sk_buff *buf)
                }
                item++;
        }
-       write_unlock_bh(&tipc_nametbl_lock); 
+       write_unlock_bh(&tipc_nametbl_lock);
        buf_discard(buf);
 }
 
 /**
  * tipc_named_reinit - re-initialize local publication list
- * 
+ *
  * This routine is called whenever TIPC networking is (re)enabled.
  * All existing publications by this node that have "cluster" or "zone" scope
  * are updated to reflect the node's current network address.
@@ -312,11 +312,11 @@ void tipc_named_reinit(void)
 {
        struct publication *publ;
 
-       write_lock_bh(&tipc_nametbl_lock); 
+       write_lock_bh(&tipc_nametbl_lock);
        list_for_each_entry(publ, &publ_root, local_list) {
                if (publ->node == tipc_own_addr)
                        break;
                publ->node = tipc_own_addr;
        }
-       write_unlock_bh(&tipc_nametbl_lock); 
+       write_unlock_bh(&tipc_nametbl_lock);
 }
index 843da0172f4e9ec974cfb5ea48d5240ad0fe9131..1e41bdd4f2553a13a8a8f6ebeb75604ab9997fdb 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * net/tipc/name_distr.h: Include file for TIPC name distribution code
- * 
+ *
  * Copyright (c) 2000-2006, Ericsson AB
  * Copyright (c) 2005, Wind River Systems
  * All rights reserved.
index 049242ea5c38e88ce4394d100ba300194a5dde55..9dfc9127acdd4f6ef6fdcad29082f1a477d639e2 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * net/tipc/name_table.c: TIPC name table code
- * 
+ *
  * Copyright (c) 2000-2006, Ericsson AB
  * Copyright (c) 2004-2005, Wind River Systems
  * All rights reserved.
@@ -65,7 +65,7 @@ struct sub_seq {
        struct publication *zone_list;
 };
 
-/** 
+/**
  * struct name_seq - container for all published instances of a name type
  * @type: 32 bit 'type' value for name sequence
  * @sseq: pointer to dynamically-sized array of sub-sequences of this 'type';
@@ -89,7 +89,7 @@ struct name_seq {
 
 /**
  * struct name_table - table containing all existing port name publications
- * @types: pointer to fixed-sized array of name sequence lists, 
+ * @types: pointer to fixed-sized array of name sequence lists,
  *         accessed via hashing on 'type'; name sequence lists are *not* sorted
  * @local_publ_count: number of publications issued by this node
  */
@@ -113,8 +113,8 @@ static int hash(int x)
  * publ_create - create a publication structure
  */
 
-static struct publication *publ_create(u32 type, u32 lower, u32 upper, 
-                                      u32 scope, u32 node, u32 port_ref,   
+static struct publication *publ_create(u32 type, u32 lower, u32 upper,
+                                      u32 scope, u32 node, u32 port_ref,
                                       u32 key)
 {
        struct publication *publ = kzalloc(sizeof(*publ), GFP_ATOMIC);
@@ -148,7 +148,7 @@ static struct sub_seq *tipc_subseq_alloc(u32 cnt)
 
 /**
  * tipc_nameseq_create - create a name sequence structure for the specified 'type'
- * 
+ *
  * Allocates a single sub-sequence structure and sets it to all 0's.
  */
 
@@ -178,7 +178,7 @@ static struct name_seq *tipc_nameseq_create(u32 type, struct hlist_head *seq_hea
 
 /**
  * nameseq_find_subseq - find sub-sequence (if any) matching a name instance
- *  
+ *
  * Very time-critical, so binary searches through sub-sequence array.
  */
 
@@ -204,7 +204,7 @@ static struct sub_seq *nameseq_find_subseq(struct name_seq *nseq,
 
 /**
  * nameseq_locate_subseq - determine position of name instance in sub-sequence
- * 
+ *
  * Returns index in sub-sequence array of the entry that contains the specified
  * instance value; if no entry contains that value, returns the position
  * where a new entry for it would be inserted in the array.
@@ -232,7 +232,7 @@ static u32 nameseq_locate_subseq(struct name_seq *nseq, u32 instance)
 }
 
 /**
- * tipc_nameseq_insert_publ - 
+ * tipc_nameseq_insert_publ -
  */
 
 static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq,
@@ -343,8 +343,8 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq,
                }
        }
 
-       /* 
-        * Any subscriptions waiting for notification? 
+       /*
+        * Any subscriptions waiting for notification?
         */
        list_for_each_entry_safe(s, st, &nseq->subscriptions, nameseq_list) {
                dbg("calling report_overlap()\n");
@@ -352,7 +352,7 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq,
                                           publ->lower,
                                           publ->upper,
                                           TIPC_PUBLISHED,
-                                          publ->ref, 
+                                          publ->ref,
                                           publ->node,
                                           created_subseq);
        }
@@ -361,7 +361,7 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq,
 
 /**
  * tipc_nameseq_remove_publ -
- * 
+ *
  * NOTE: There may be cases where TIPC is asked to remove a publication
  * that is not in the name table.  For example, if another node issues a
  * publication for a name sequence that overlaps an existing name sequence
@@ -392,12 +392,12 @@ static struct publication *tipc_nameseq_remove_publ(struct name_seq *nseq, u32 i
 
        prev = sseq->zone_list;
        publ = sseq->zone_list->zone_list_next;
-       while ((publ->key != key) || (publ->ref != ref) || 
+       while ((publ->key != key) || (publ->ref != ref) ||
               (publ->node && (publ->node != node))) {
                prev = publ;
                publ = publ->zone_list_next;
                if (prev == sseq->zone_list) {
-                       
+
                        /* Prevent endless loop if publication not found */
 
                        return NULL;
@@ -426,7 +426,7 @@ static struct publication *tipc_nameseq_remove_publ(struct name_seq *nseq, u32 i
 
                                err("Unable to de-list cluster publication\n"
                                    "{%u%u}, node=0x%x, ref=%u, key=%u)\n",
-                                   publ->type, publ->lower, publ->node, 
+                                   publ->type, publ->lower, publ->node,
                                    publ->ref, publ->key);
                                goto end_cluster;
                        }
@@ -456,7 +456,7 @@ end_cluster:
 
                                err("Unable to de-list node publication\n"
                                    "{%u%u}, node=0x%x, ref=%u, key=%u)\n",
-                                   publ->type, publ->lower, publ->node, 
+                                   publ->type, publ->lower, publ->node,
                                    publ->ref, publ->key);
                                goto end_node;
                        }
@@ -486,8 +486,8 @@ end_node:
                tipc_subscr_report_overlap(s,
                                           publ->lower,
                                           publ->upper,
-                                          TIPC_WITHDRAWN, 
-                                          publ->ref, 
+                                          TIPC_WITHDRAWN,
+                                          publ->ref,
                                           publ->node,
                                           removed_subseq);
        }
@@ -517,8 +517,8 @@ void tipc_nameseq_subscribe(struct name_seq *nseq, struct subscription *s)
                        int must_report = 1;
 
                        do {
-                               tipc_subscr_report_overlap(s, 
-                                                          sseq->lower, 
+                               tipc_subscr_report_overlap(s,
+                                                          sseq->lower,
                                                           sseq->upper,
                                                           TIPC_PUBLISHED,
                                                           crs->ref,
@@ -576,7 +576,7 @@ struct publication *tipc_nametbl_insert_publ(u32 type, u32 lower, u32 upper,
                                        scope, node, port, key);
 }
 
-struct publication *tipc_nametbl_remove_publ(u32 type, u32 lower, 
+struct publication *tipc_nametbl_remove_publ(u32 type, u32 lower,
                                             u32 node, u32 ref, u32 key)
 {
        struct publication *publ;
@@ -676,14 +676,14 @@ not_found:
 
 /**
  * tipc_nametbl_mc_translate - find multicast destinations
- * 
+ *
  * Creates list of all local ports that overlap the given multicast address;
  * also determines if any off-node ports overlap.
  *
  * Note: Publications with a scope narrower than 'limit' are ignored.
  * (i.e. local node-scope publications mustn't receive messages arriving
  * from another node, even if the multcast link brought it here)
- * 
+ *
  * Returns non-zero if any off-node ports overlap
  */
 
@@ -730,7 +730,7 @@ exit:
  * tipc_nametbl_publish_rsv - publish port name using a reserved name type
  */
 
-int tipc_nametbl_publish_rsv(u32 ref, unsigned int scope, 
+int tipc_nametbl_publish_rsv(u32 ref, unsigned int scope,
                        struct tipc_name_seq const *seq)
 {
        int res;
@@ -745,13 +745,13 @@ int tipc_nametbl_publish_rsv(u32 ref, unsigned int scope,
  * tipc_nametbl_publish - add name publication to network name tables
  */
 
-struct publication *tipc_nametbl_publish(u32 type, u32 lower, u32 upper, 
+struct publication *tipc_nametbl_publish(u32 type, u32 lower, u32 upper,
                                    u32 scope, u32 port_ref, u32 key)
 {
        struct publication *publ;
 
        if (table.local_publ_count >= tipc_max_publications) {
-               warn("Publication failed, local publication limit reached (%u)\n", 
+               warn("Publication failed, local publication limit reached (%u)\n",
                     tipc_max_publications);
                return NULL;
        }
@@ -808,22 +808,22 @@ void tipc_nametbl_subscribe(struct subscription *s)
        u32 type = s->seq.type;
        struct name_seq *seq;
 
-        write_lock_bh(&tipc_nametbl_lock);
+       write_lock_bh(&tipc_nametbl_lock);
        seq = nametbl_find_seq(type);
        if (!seq) {
                seq = tipc_nameseq_create(type, &table.types[hash(type)]);
        }
-        if (seq){
-                spin_lock_bh(&seq->lock);
-                dbg("tipc_nametbl_subscribe:found %p for {%u,%u,%u}\n",
-                    seq, type, s->seq.lower, s->seq.upper);
-                tipc_nameseq_subscribe(seq, s);
-                spin_unlock_bh(&seq->lock);
-        } else {
+       if (seq){
+               spin_lock_bh(&seq->lock);
+               dbg("tipc_nametbl_subscribe:found %p for {%u,%u,%u}\n",
+                   seq, type, s->seq.lower, s->seq.upper);
+               tipc_nameseq_subscribe(seq, s);
+               spin_unlock_bh(&seq->lock);
+       } else {
                warn("Failed to create subscription for {%u,%u,%u}\n",
                     s->seq.type, s->seq.lower, s->seq.upper);
-        }
-        write_unlock_bh(&tipc_nametbl_lock);
+       }
+       write_unlock_bh(&tipc_nametbl_lock);
 }
 
 /**
@@ -834,19 +834,19 @@ void tipc_nametbl_unsubscribe(struct subscription *s)
 {
        struct name_seq *seq;
 
-        write_lock_bh(&tipc_nametbl_lock);
-        seq = nametbl_find_seq(s->seq.type);
+       write_lock_bh(&tipc_nametbl_lock);
+       seq = nametbl_find_seq(s->seq.type);
        if (seq != NULL){
-                spin_lock_bh(&seq->lock);
-                list_del_init(&s->nameseq_list);
-                spin_unlock_bh(&seq->lock);
-                if ((seq->first_free == 0) && list_empty(&seq->subscriptions)) {
-                        hlist_del_init(&seq->ns_list);
-                        kfree(seq->sseqs);
-                        kfree(seq);
-                }
-        }
-        write_unlock_bh(&tipc_nametbl_lock);
+               spin_lock_bh(&seq->lock);
+               list_del_init(&s->nameseq_list);
+               spin_unlock_bh(&seq->lock);
+               if ((seq->first_free == 0) && list_empty(&seq->subscriptions)) {
+                       hlist_del_init(&seq->ns_list);
+                       kfree(seq->sseqs);
+                       kfree(seq);
+               }
+       }
+       write_unlock_bh(&tipc_nametbl_lock);
 }
 
 
@@ -952,7 +952,7 @@ static void nametbl_header(struct print_buf *buf, u32 depth)
  * nametbl_list - print specified name table contents into the given buffer
  */
 
-static void nametbl_list(struct print_buf *buf, u32 depth_info, 
+static void nametbl_list(struct print_buf *buf, u32 depth_info,
                         u32 type, u32 lowbound, u32 upbound)
 {
        struct hlist_head *seq_head;
@@ -976,7 +976,7 @@ static void nametbl_list(struct print_buf *buf, u32 depth_info,
                for (i = 0; i < tipc_nametbl_size; i++) {
                        seq_head = &table.types[i];
                        hlist_for_each_entry(seq, seq_node, seq_head, ns_list) {
-                               nameseq_list(seq, buf, depth, seq->type, 
+                               nameseq_list(seq, buf, depth, seq->type,
                                             lowbound, upbound, i);
                        }
                }
@@ -991,7 +991,7 @@ static void nametbl_list(struct print_buf *buf, u32 depth_info,
                seq_head = &table.types[i];
                hlist_for_each_entry(seq, seq_node, seq_head, ns_list) {
                        if (seq->type == type) {
-                               nameseq_list(seq, buf, depth, type, 
+                               nameseq_list(seq, buf, depth, type,
                                             lowbound, upbound, i);
                                break;
                        }
@@ -1030,7 +1030,7 @@ struct sk_buff *tipc_nametbl_get(const void *req_tlv_area, int req_tlv_space)
        tipc_printbuf_init(&b, TLV_DATA(rep_tlv), MAX_NAME_TBL_QUERY);
        argv = (struct tipc_name_table_query *)TLV_DATA(req_tlv_area);
        read_lock_bh(&tipc_nametbl_lock);
-       nametbl_list(&b, ntohl(argv->depth), ntohl(argv->type), 
+       nametbl_list(&b, ntohl(argv->depth), ntohl(argv->type),
                     ntohl(argv->lowbound), ntohl(argv->upbound));
        read_unlock_bh(&tipc_nametbl_lock);
        str_len = tipc_printbuf_validate(&b);
index e8a3d71763ce637e5bdfabe753be917c2792ae92..b9e7cd336d76d54488dc2ded2f0a91914cb7dea1 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * net/tipc/name_table.h: Include file for TIPC name table code
- * 
+ *
  * Copyright (c) 2000-2006, Ericsson AB
  * Copyright (c) 2004-2005, Wind River Systems
  * All rights reserved.
@@ -64,7 +64,7 @@ struct port_list;
  * @node_list: next matching name seq publication with >= node scope
  * @cluster_list: next matching name seq publication with >= cluster scope
  * @zone_list: next matching name seq publication with >= zone scope
- * 
+ *
  * Note that the node list, cluster list, and zone list are circular lists.
  */
 
@@ -89,16 +89,16 @@ extern rwlock_t tipc_nametbl_lock;
 
 struct sk_buff *tipc_nametbl_get(const void *req_tlv_area, int req_tlv_space);
 u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *node);
-int tipc_nametbl_mc_translate(u32 type, u32 lower, u32 upper, u32 limit, 
+int tipc_nametbl_mc_translate(u32 type, u32 lower, u32 upper, u32 limit,
                         struct port_list *dports);
-int tipc_nametbl_publish_rsv(u32 ref, unsigned int scope, 
+int tipc_nametbl_publish_rsv(u32 ref, unsigned int scope,
                        struct tipc_name_seq const *seq);
 struct publication *tipc_nametbl_publish(u32 type, u32 lower, u32 upper,
                                    u32 scope, u32 port_ref, u32 key);
 int tipc_nametbl_withdraw(u32 type, u32 lower, u32 ref, u32 key);
 struct publication *tipc_nametbl_insert_publ(u32 type, u32 lower, u32 upper,
                                        u32 scope, u32 node, u32 ref, u32 key);
-struct publication *tipc_nametbl_remove_publ(u32 type, u32 lower, 
+struct publication *tipc_nametbl_remove_publ(u32 type, u32 lower,
                                        u32 node, u32 ref, u32 key);
 void tipc_nametbl_subscribe(struct subscription *s);
 void tipc_nametbl_unsubscribe(struct subscription *s);
index a991bf8a7f7493db1ee39b1dc6d1e6fff7e862a1..c39c76201e8edb2bd343c68f4b5e6ce4de202c49 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * net/tipc/net.c: TIPC network routing code
- * 
+ *
  * Copyright (c) 1995-2006, Ericsson AB
  * Copyright (c) 2005, Wind River Systems
  * All rights reserved.
 #include "discover.h"
 #include "config.h"
 
-/* 
+/*
  * The TIPC locking policy is designed to ensure a very fine locking
  * granularity, permitting complete parallel access to individual
- * port and node/link instances. The code consists of three major 
+ * port and node/link instances. The code consists of three major
  * locking domains, each protected with their own disjunct set of locks.
  *
  * 1: The routing hierarchy.
- *    Comprises the structures 'zone', 'cluster', 'node', 'link' 
- *    and 'bearer'. The whole hierarchy is protected by a big 
- *    read/write lock, tipc_net_lock, to enssure that nothing is added 
- *    or removed while code is accessing any of these structures. 
- *    This layer must not be called from the two others while they 
+ *    Comprises the structures 'zone', 'cluster', 'node', 'link'
+ *    and 'bearer'. The whole hierarchy is protected by a big
+ *    read/write lock, tipc_net_lock, to enssure that nothing is added
+ *    or removed while code is accessing any of these structures.
+ *    This layer must not be called from the two others while they
  *    hold any of their own locks.
  *    Neither must it itself do any upcalls to the other two before
  *    it has released tipc_net_lock and other protective locks.
  *
- *   Within the tipc_net_lock domain there are two sub-domains;'node' and 
+ *   Within the tipc_net_lock domain there are two sub-domains;'node' and
  *   'bearer', where local write operations are permitted,
  *   provided that those are protected by individual spin_locks
- *   per instance. Code holding tipc_net_lock(read) and a node spin_lock 
+ *   per instance. Code holding tipc_net_lock(read) and a node spin_lock
  *   is permitted to poke around in both the node itself and its
- *   subordinate links. I.e, it can update link counters and queues, 
- *   change link state, send protocol messages, and alter the 
- *   "active_links" array in the node; but it can _not_ remove a link 
+ *   subordinate links. I.e, it can update link counters and queues,
+ *   change link state, send protocol messages, and alter the
+ *   "active_links" array in the node; but it can _not_ remove a link
  *   or a node from the overall structure.
- *   Correspondingly, individual bearers may change status within a 
- *   tipc_net_lock(read), protected by an individual spin_lock ber bearer 
+ *   Correspondingly, individual bearers may change status within a
+ *   tipc_net_lock(read), protected by an individual spin_lock ber bearer
  *   instance, but it needs tipc_net_lock(write) to remove/add any bearers.
- *     
  *
- *  2: The transport level of the protocol. 
- *     This consists of the structures port, (and its user level 
- *     representations, such as user_port and tipc_sock), reference and 
- *     tipc_user (port.c, reg.c, socket.c). 
+ *
+ *  2: The transport level of the protocol.
+ *     This consists of the structures port, (and its user level
+ *     representations, such as user_port and tipc_sock), reference and
+ *     tipc_user (port.c, reg.c, socket.c).
  *
  *     This layer has four different locks:
  *     - The tipc_port spin_lock. This is protecting each port instance
- *       from parallel data access and removal. Since we can not place 
- *       this lock in the port itself, it has been placed in the 
+ *       from parallel data access and removal. Since we can not place
+ *       this lock in the port itself, it has been placed in the
  *       corresponding reference table entry, which has the same life
- *       cycle as the module. This entry is difficult to access from 
- *       outside the TIPC core, however, so a pointer to the lock has 
- *       been added in the port instance, -to be used for unlocking 
+ *       cycle as the module. This entry is difficult to access from
+ *       outside the TIPC core, however, so a pointer to the lock has
+ *       been added in the port instance, -to be used for unlocking
  *       only.
- *     - A read/write lock to protect the reference table itself (teg.c). 
- *       (Nobody is using read-only access to this, so it can just as 
+ *     - A read/write lock to protect the reference table itself (teg.c).
+ *       (Nobody is using read-only access to this, so it can just as
  *       well be changed to a spin_lock)
  *     - A spin lock to protect the registry of kernel/driver users (reg.c)
- *     - A global spin_lock (tipc_port_lock), which only task is to ensure 
+ *     - A global spin_lock (tipc_port_lock), which only task is to ensure
  *       consistency where more than one port is involved in an operation,
  *       i.e., whe a port is part of a linked list of ports.
  *       There are two such lists; 'port_list', which is used for management,
  *       and 'wait_list', which is used to queue ports during congestion.
- *     
+ *
  *  3: The name table (name_table.c, name_distr.c, subscription.c)
- *     - There is one big read/write-lock (tipc_nametbl_lock) protecting the 
- *       overall name table structure. Nothing must be added/removed to 
+ *     - There is one big read/write-lock (tipc_nametbl_lock) protecting the
+ *       overall name table structure. Nothing must be added/removed to
  *       this structure without holding write access to it.
  *     - There is one local spin_lock per sub_sequence, which can be seen
  *       as a sub-domain to the tipc_nametbl_lock domain. It is used only
 DEFINE_RWLOCK(tipc_net_lock);
 struct network tipc_net = { NULL };
 
-struct node *tipc_net_select_remote_node(u32 addr, u32 ref) 
+struct node *tipc_net_select_remote_node(u32 addr, u32 ref)
 {
        return tipc_zone_select_remote_node(tipc_net.zones[tipc_zone(addr)], addr, ref);
 }
@@ -224,7 +224,7 @@ void tipc_net_route_msg(struct sk_buff *buf)
                        buf_discard(buf);
                } else {
                        msg_dbg(msg, "NET>REJ>:");
-                       tipc_reject_msg(buf, msg_destport(msg) ? 
+                       tipc_reject_msg(buf, msg_destport(msg) ?
                                        TIPC_ERR_NO_PORT : TIPC_ERR_NO_NAME);
                }
                return;
@@ -236,7 +236,7 @@ void tipc_net_route_msg(struct sk_buff *buf)
        dnode = msg_short(msg) ? tipc_own_addr : msg_destnode(msg);
        if (in_scope(dnode, tipc_own_addr)) {
                if (msg_isdata(msg)) {
-                       if (msg_mcast(msg)) 
+                       if (msg_mcast(msg))
                                tipc_port_recv_mcast(buf, NULL);
                        else if (msg_destport(msg))
                                tipc_port_recv_msg(buf);
@@ -284,7 +284,7 @@ int tipc_net_start(void)
            (res = tipc_bclink_init())) {
                return res;
        }
-        tipc_subscr_stop();
+       tipc_subscr_stop();
        tipc_cfg_stop();
        tipc_k_signal((Handler)tipc_subscr_start, 0);
        tipc_k_signal((Handler)tipc_cfg_init, 0);
@@ -298,12 +298,12 @@ void tipc_net_stop(void)
 {
        if (tipc_mode != TIPC_NET_MODE)
                return;
-        write_lock_bh(&tipc_net_lock);
+       write_lock_bh(&tipc_net_lock);
        tipc_bearer_stop();
        tipc_mode = TIPC_NODE_MODE;
        tipc_bclink_stop();
        net_stop();
-        write_unlock_bh(&tipc_net_lock);
+       write_unlock_bh(&tipc_net_lock);
        info("Left network mode \n");
 }
 
index f3e0b85e64753d1e7bedc728d45dd93aa5d2c26e..a6a0e9976ac9e1de14395165e53ca9750f430219 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * net/tipc/net.h: Include file for TIPC network routing code
- * 
+ *
  * Copyright (c) 1995-2006, Ericsson AB
  * Copyright (c) 2005, Wind River Systems
  * All rights reserved.
@@ -43,7 +43,7 @@ struct _zone;
  * struct network - TIPC network structure
  * @zones: array of pointers to all zones within network
  */
+
 struct network {
        struct _zone **zones;
 };
index eb1bb4dce7af950f43bbf6c5899f649ea170e986..b8e1edc2badcbff690cecc06adaed983ec874039 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * net/tipc/netlink.c: TIPC configuration handling
- * 
+ *
  * Copyright (c) 2005-2006, Ericsson AB
  * Copyright (c) 2005, Wind River Systems
  * All rights reserved.
@@ -63,15 +63,15 @@ static int handle_cmd(struct sk_buff *skb, struct genl_info *info)
                genlmsg_unicast(rep_buf, req_nlh->nlmsg_pid);
        }
 
-        return 0;
+       return 0;
 }
 
 static struct genl_family family = {
-        .id            = GENL_ID_GENERATE,
-        .name          = TIPC_GENL_NAME,
-        .version       = TIPC_GENL_VERSION,
-        .hdrsize       = TIPC_GENL_HDRLEN,
-        .maxattr       = 0,
+       .id             = GENL_ID_GENERATE,
+       .name           = TIPC_GENL_NAME,
+       .version        = TIPC_GENL_VERSION,
+       .hdrsize        = TIPC_GENL_HDRLEN,
+       .maxattr        = 0,
 };
 
 static struct genl_ops ops = {
@@ -93,7 +93,7 @@ int tipc_netlink_start(void)
        if (genl_register_ops(&family, &ops))
                goto err_unregister;
 
-        return 0;
+       return 0;
 
  err_unregister:
        genl_unregister_family(&family);
index 4111a31def7997548dd0e49024d6f92612123eb6..e2e452a62ba181238399c7fc3ddc730cd07e8100 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * net/tipc/node.c: TIPC node management routines
- * 
+ *
  * Copyright (c) 2000-2006, Ericsson AB
  * Copyright (c) 2005-2006, Wind River Systems
  * All rights reserved.
@@ -58,7 +58,7 @@ struct node *tipc_node_create(u32 addr)
 {
        struct cluster *c_ptr;
        struct node *n_ptr;
-        struct node **curr_node;
+       struct node **curr_node;
 
        n_ptr = kzalloc(sizeof(*n_ptr),GFP_ATOMIC);
        if (!n_ptr) {
@@ -74,16 +74,16 @@ struct node *tipc_node_create(u32 addr)
                kfree(n_ptr);
                return NULL;
        }
-               
+
        n_ptr->addr = addr;
-                spin_lock_init(&n_ptr->lock);
+               spin_lock_init(&n_ptr->lock);
        INIT_LIST_HEAD(&n_ptr->nsub);
        n_ptr->owner = c_ptr;
        tipc_cltr_attach_node(c_ptr, n_ptr);
        n_ptr->last_router = -1;
 
        /* Insert node into ordered list */
-       for (curr_node = &tipc_nodes; *curr_node; 
+       for (curr_node = &tipc_nodes; *curr_node;
             curr_node = &(*curr_node)->next) {
                if (addr < (*curr_node)->addr) {
                        n_ptr->next = *curr_node;
@@ -116,7 +116,7 @@ void tipc_node_delete(struct node *n_ptr)
 
 /**
  * tipc_node_link_up - handle addition of link
- * 
+ *
  * Link becomes active (alone or shared) or standby, depending on its priority.
  */
 
@@ -128,19 +128,19 @@ void tipc_node_link_up(struct node *n_ptr, struct link *l_ptr)
 
        info("Established link <%s> on network plane %c\n",
             l_ptr->name, l_ptr->b_ptr->net_plane);
-       
+
        if (!active[0]) {
                dbg(" link %x into %x/%x\n", l_ptr, &active[0], &active[1]);
                active[0] = active[1] = l_ptr;
                node_established_contact(n_ptr);
                return;
        }
-       if (l_ptr->priority < active[0]->priority) { 
+       if (l_ptr->priority < active[0]->priority) {
                info("New link <%s> becomes standby\n", l_ptr->name);
                return;
        }
        tipc_link_send_duplicate(active[0], l_ptr);
-       if (l_ptr->priority == active[0]->priority) { 
+       if (l_ptr->priority == active[0]->priority) {
                active[0] = l_ptr;
                return;
        }
@@ -160,17 +160,17 @@ static void node_select_active_links(struct node *n_ptr)
        u32 i;
        u32 highest_prio = 0;
 
-        active[0] = active[1] = NULL;
+       active[0] = active[1] = NULL;
 
        for (i = 0; i < MAX_BEARERS; i++) {
-                struct link *l_ptr = n_ptr->links[i];
+               struct link *l_ptr = n_ptr->links[i];
 
                if (!l_ptr || !tipc_link_is_up(l_ptr) ||
                    (l_ptr->priority < highest_prio))
                        continue;
 
                if (l_ptr->priority > highest_prio) {
-                        highest_prio = l_ptr->priority;
+                       highest_prio = l_ptr->priority;
                        active[0] = active[1] = l_ptr;
                } else {
                        active[1] = l_ptr;
@@ -203,15 +203,15 @@ void tipc_node_link_down(struct node *n_ptr, struct link *l_ptr)
                active[1] = active[0];
        if (active[0] == l_ptr)
                node_select_active_links(n_ptr);
-       if (tipc_node_is_up(n_ptr)) 
+       if (tipc_node_is_up(n_ptr))
                tipc_link_changeover(l_ptr);
-       else 
+       else
                node_lost_contact(n_ptr);
 }
 
 int tipc_node_has_active_links(struct node *n_ptr)
 {
-       return (n_ptr && 
+       return (n_ptr &&
                ((n_ptr->active_links[0]) || (n_ptr->active_links[1])));
 }
 
@@ -236,28 +236,28 @@ struct node *tipc_node_attach_link(struct link *l_ptr)
 
        if (!n_ptr)
                n_ptr = tipc_node_create(l_ptr->addr);
-        if (n_ptr) {
+       if (n_ptr) {
                u32 bearer_id = l_ptr->b_ptr->identity;
                char addr_string[16];
 
-                if (n_ptr->link_cnt >= 2) {
+               if (n_ptr->link_cnt >= 2) {
                        char addr_string[16];
 
-                        err("Attempt to create third link to %s\n",
+                       err("Attempt to create third link to %s\n",
                            addr_string_fill(addr_string, n_ptr->addr));
-                        return NULL;
-                }
-
-                if (!n_ptr->links[bearer_id]) {
-                        n_ptr->links[bearer_id] = l_ptr;
-                        tipc_net.zones[tipc_zone(l_ptr->addr)]->links++;
-                        n_ptr->link_cnt++;
-                        return n_ptr;
-                }
-                err("Attempt to establish second link on <%s> to %s \n",
-                    l_ptr->b_ptr->publ.name, 
+                       return NULL;
+               }
+
+               if (!n_ptr->links[bearer_id]) {
+                       n_ptr->links[bearer_id] = l_ptr;
+                       tipc_net.zones[tipc_zone(l_ptr->addr)]->links++;
+                       n_ptr->link_cnt++;
+                       return n_ptr;
+               }
+               err("Attempt to establish second link on <%s> to %s \n",
+                   l_ptr->b_ptr->publ.name,
                    addr_string_fill(addr_string, l_ptr->addr));
-        }
+       }
        return NULL;
 }
 
@@ -272,17 +272,17 @@ void tipc_node_detach_link(struct node *n_ptr, struct link *l_ptr)
  * Routing table management - five cases to handle:
  *
  * 1: A link towards a zone/cluster external node comes up.
- *    => Send a multicast message updating routing tables of all 
- *    system nodes within own cluster that the new destination 
- *    can be reached via this node. 
+ *    => Send a multicast message updating routing tables of all
+ *    system nodes within own cluster that the new destination
+ *    can be reached via this node.
  *    (node.establishedContact()=>cluster.multicastNewRoute())
  *
  * 2: A link towards a slave node comes up.
- *    => Send a multicast message updating routing tables of all 
- *    system nodes within own cluster that the new destination 
- *    can be reached via this node. 
+ *    => Send a multicast message updating routing tables of all
+ *    system nodes within own cluster that the new destination
+ *    can be reached via this node.
  *    (node.establishedContact()=>cluster.multicastNewRoute())
- *    => Send a  message to the slave node about existence 
+ *    => Send a  message to the slave node about existence
  *    of all system nodes within cluster:
  *    (node.establishedContact()=>cluster.sendLocalRoutes())
  *
@@ -292,13 +292,13 @@ void tipc_node_detach_link(struct node *n_ptr, struct link *l_ptr)
  *     nodes which can be reached via this node.
  *    (node.establishedContact()==>network.sendExternalRoutes())
  *    (node.establishedContact()==>network.sendSlaveRoutes())
- *    => Send messages to all directly connected slave nodes 
+ *    => Send messages to all directly connected slave nodes
  *    containing information about the existence of the new node
  *    (node.establishedContact()=>cluster.multicastNewRoute())
- *    
+ *
  * 4: The link towards a zone/cluster external node or slave
  *    node goes down.
- *    => Send a multcast message updating routing tables of all 
+ *    => Send a multcast message updating routing tables of all
  *    nodes within cluster that the new destination can not any
  *    longer be reached via this node.
  *    (node.lostAllLinks()=>cluster.bcastLostRoute())
@@ -308,7 +308,7 @@ void tipc_node_detach_link(struct node *n_ptr, struct link *l_ptr)
  *    routing tables. Note: This is a completely node
  *    local operation.
  *    (node.lostAllLinks()=>network.removeAsRouter())
- *    => Send messages to all directly connected slave nodes 
+ *    => Send messages to all directly connected slave nodes
  *    containing information about loss of the node
  *    (node.establishedContact()=>cluster.multicastLostRoute())
  *
@@ -319,12 +319,12 @@ static void node_established_contact(struct node *n_ptr)
        struct cluster *c_ptr;
 
        dbg("node_established_contact:-> %x\n", n_ptr->addr);
-       if (!tipc_node_has_active_routes(n_ptr) && in_own_cluster(n_ptr->addr)) { 
+       if (!tipc_node_has_active_routes(n_ptr) && in_own_cluster(n_ptr->addr)) {
                tipc_k_signal((Handler)tipc_named_node_up, n_ptr->addr);
        }
 
-        /* Syncronize broadcast acks */
-        n_ptr->bclink.acked = tipc_bclink_get_last_sent();
+       /* Syncronize broadcast acks */
+       n_ptr->bclink.acked = tipc_bclink_get_last_sent();
 
        if (is_slave(tipc_own_addr))
                return;
@@ -333,11 +333,11 @@ static void node_established_contact(struct node *n_ptr)
                c_ptr = tipc_cltr_find(tipc_own_addr);
                if (!c_ptr)
                        c_ptr = tipc_cltr_create(tipc_own_addr);
-                if (c_ptr)
-                        tipc_cltr_bcast_new_route(c_ptr, n_ptr->addr, 1, 
+               if (c_ptr)
+                       tipc_cltr_bcast_new_route(c_ptr, n_ptr->addr, 1,
                                                  tipc_max_nodes);
                return;
-       } 
+       }
 
        c_ptr = n_ptr->owner;
        if (is_slave(n_ptr->addr)) {
@@ -367,26 +367,26 @@ static void node_lost_contact(struct node *n_ptr)
        char addr_string[16];
        u32 i;
 
-        /* Clean up broadcast reception remains */
-        n_ptr->bclink.gap_after = n_ptr->bclink.gap_to = 0;
-        while (n_ptr->bclink.deferred_head) {
-                struct sk_buff* buf = n_ptr->bclink.deferred_head;
-                n_ptr->bclink.deferred_head = buf->next;
-                buf_discard(buf);
-        }
-        if (n_ptr->bclink.defragm) {
-                buf_discard(n_ptr->bclink.defragm);  
-                n_ptr->bclink.defragm = NULL;
-        }            
-        if (in_own_cluster(n_ptr->addr) && n_ptr->bclink.supported) { 
-                tipc_bclink_acknowledge(n_ptr, mod(n_ptr->bclink.acked + 10000));
-        }
-
-        /* Update routing tables */
+       /* Clean up broadcast reception remains */
+       n_ptr->bclink.gap_after = n_ptr->bclink.gap_to = 0;
+       while (n_ptr->bclink.deferred_head) {
+               struct sk_buff* buf = n_ptr->bclink.deferred_head;
+               n_ptr->bclink.deferred_head = buf->next;
+               buf_discard(buf);
+       }
+       if (n_ptr->bclink.defragm) {
+               buf_discard(n_ptr->bclink.defragm);
+               n_ptr->bclink.defragm = NULL;
+       }
+       if (in_own_cluster(n_ptr->addr) && n_ptr->bclink.supported) {
+               tipc_bclink_acknowledge(n_ptr, mod(n_ptr->bclink.acked + 10000));
+       }
+
+       /* Update routing tables */
        if (is_slave(tipc_own_addr)) {
                tipc_net_remove_as_router(n_ptr->addr);
        } else {
-               if (!in_own_cluster(n_ptr->addr)) { 
+               if (!in_own_cluster(n_ptr->addr)) {
                        /* Case 4 (see above) */
                        c_ptr = tipc_cltr_find(tipc_own_addr);
                        tipc_cltr_bcast_lost_route(c_ptr, n_ptr->addr, 1,
@@ -399,7 +399,7 @@ static void node_lost_contact(struct node *n_ptr)
                                                           tipc_max_nodes);
                        } else {
                                if (n_ptr->bclink.supported) {
-                                       tipc_nmap_remove(&tipc_cltr_bcast_nodes, 
+                                       tipc_nmap_remove(&tipc_cltr_bcast_nodes,
                                                         n_ptr->addr);
                                        if (n_ptr->addr < tipc_own_addr)
                                                tipc_own_tag--;
@@ -414,13 +414,13 @@ static void node_lost_contact(struct node *n_ptr)
        if (tipc_node_has_active_routes(n_ptr))
                return;
 
-       info("Lost contact with %s\n", 
+       info("Lost contact with %s\n",
             addr_string_fill(addr_string, n_ptr->addr));
 
        /* Abort link changeover */
        for (i = 0; i < MAX_BEARERS; i++) {
                struct link *l_ptr = n_ptr->links[i];
-               if (!l_ptr) 
+               if (!l_ptr)
                        continue;
                l_ptr->reset_checkpoint = l_ptr->next_in_no;
                l_ptr->exp_msg_count = 0;
@@ -429,7 +429,7 @@ static void node_lost_contact(struct node *n_ptr)
 
        /* Notify subscribers */
        list_for_each_entry_safe(ns, tns, &n_ptr->nsub, nodesub_list) {
-                ns->node = NULL;
+               ns->node = NULL;
                list_del_init(&ns->nodesub_list);
                tipc_k_signal((Handler)ns->handle_node_down,
                              (unsigned long)ns->usr_handle);
@@ -438,7 +438,7 @@ static void node_lost_contact(struct node *n_ptr)
 
 /**
  * tipc_node_select_next_hop - find the next-hop node for a message
- * 
+ *
  * Called by when cluster local lookup has failed.
  */
 
@@ -447,13 +447,13 @@ struct node *tipc_node_select_next_hop(u32 addr, u32 selector)
        struct node *n_ptr;
        u32 router_addr;
 
-        if (!tipc_addr_domain_valid(addr))
-                return NULL;
+       if (!tipc_addr_domain_valid(addr))
+               return NULL;
 
        /* Look for direct link to destination processsor */
        n_ptr = tipc_node_find(addr);
        if (n_ptr && tipc_node_has_active_links(n_ptr))
-                return n_ptr;
+               return n_ptr;
 
        /* Cluster local system nodes *must* have direct links */
        if (!is_slave(addr) && in_own_cluster(addr))
@@ -461,10 +461,10 @@ struct node *tipc_node_select_next_hop(u32 addr, u32 selector)
 
        /* Look for cluster local router with direct link to node */
        router_addr = tipc_node_select_router(n_ptr, selector);
-       if (router_addr) 
-                return tipc_node_select(router_addr, selector);
+       if (router_addr)
+               return tipc_node_select(router_addr, selector);
 
-       /* Slave nodes can only be accessed within own cluster via a 
+       /* Slave nodes can only be accessed within own cluster via a
           known router with direct link -- if no router was found,give up */
        if (is_slave(addr))
                return NULL;
@@ -473,20 +473,20 @@ struct node *tipc_node_select_next_hop(u32 addr, u32 selector)
        addr = tipc_addr(tipc_zone(addr), tipc_cluster(addr), 0);
        n_ptr = tipc_net_select_remote_node(addr, selector);
        if (n_ptr && tipc_node_has_active_links(n_ptr))
-                return n_ptr;
+               return n_ptr;
 
        /* Last resort -- look for any router to anywhere in remote zone */
        router_addr =  tipc_net_select_router(addr, selector);
-       if (router_addr) 
-                return tipc_node_select(router_addr, selector);
+       if (router_addr)
+               return tipc_node_select(router_addr, selector);
 
-        return NULL;
+       return NULL;
 }
 
 /**
  * tipc_node_select_router - select router to reach specified node
- * 
- * Uses a deterministic and fair algorithm for selecting router node. 
+ *
+ * Uses a deterministic and fair algorithm for selecting router node.
  */
 
 u32 tipc_node_select_router(struct node *n_ptr, u32 ref)
@@ -496,8 +496,8 @@ u32 tipc_node_select_router(struct node *n_ptr, u32 ref)
        u32 start;
        u32 r;
 
-        if (!n_ptr)
-                return 0;
+       if (!n_ptr)
+               return 0;
 
        if (n_ptr->last_router < 0)
                return 0;
@@ -531,10 +531,10 @@ void tipc_node_add_router(struct node *n_ptr, u32 router)
 {
        u32 r_num = tipc_node(router);
 
-       n_ptr->routers[r_num / 32] = 
+       n_ptr->routers[r_num / 32] =
                ((1 << (r_num % 32)) | n_ptr->routers[r_num / 32]);
        n_ptr->last_router = tipc_max_nodes / 32;
-       while ((--n_ptr->last_router >= 0) && 
+       while ((--n_ptr->last_router >= 0) &&
               !n_ptr->routers[n_ptr->last_router]);
 }
 
@@ -548,7 +548,7 @@ void tipc_node_remove_router(struct node *n_ptr, u32 router)
        n_ptr->routers[r_num / 32] =
                ((~(1 << (r_num % 32))) & (n_ptr->routers[r_num / 32]));
        n_ptr->last_router = tipc_max_nodes / 32;
-       while ((--n_ptr->last_router >= 0) && 
+       while ((--n_ptr->last_router >= 0) &&
               !n_ptr->routers[n_ptr->last_router]);
 
        if (!tipc_node_is_up(n_ptr))
@@ -562,7 +562,7 @@ void node_print(struct print_buf *buf, struct node *n_ptr, char *str)
 
        tipc_printf(buf, "\n\n%s", str);
        for (i = 0; i < MAX_BEARERS; i++) {
-               if (!n_ptr->links[i]) 
+               if (!n_ptr->links[i])
                        continue;
                tipc_printf(buf, "Links[%u]: %x, ", i, n_ptr->links[i]);
        }
@@ -590,7 +590,7 @@ struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space)
        u32 domain;
        struct sk_buff *buf;
        struct node *n_ptr;
-        struct tipc_node_info node_info;
+       struct tipc_node_info node_info;
        u32 payload_size;
 
        if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NET_ADDR))
@@ -601,10 +601,10 @@ struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space)
                return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
                                                   " (network address)");
 
-        if (!tipc_nodes)
-                return tipc_cfg_reply_none();
+       if (!tipc_nodes)
+               return tipc_cfg_reply_none();
 
-       /* For now, get space for all other nodes 
+       /* For now, get space for all other nodes
           (will need to modify this when slave nodes are supported */
 
        payload_size = TLV_SPACE(sizeof(node_info)) * (tipc_max_nodes - 1);
@@ -620,9 +620,9 @@ struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space)
        for (n_ptr = tipc_nodes; n_ptr; n_ptr = n_ptr->next) {
                if (!in_scope(domain, n_ptr->addr))
                        continue;
-                node_info.addr = htonl(n_ptr->addr);
-                node_info.up = htonl(tipc_node_is_up(n_ptr));
-               tipc_cfg_append_tlv(buf, TIPC_TLV_NODE_INFO, 
+               node_info.addr = htonl(n_ptr->addr);
+               node_info.up = htonl(tipc_node_is_up(n_ptr));
+               tipc_cfg_append_tlv(buf, TIPC_TLV_NODE_INFO,
                                    &node_info, sizeof(node_info));
        }
 
@@ -634,7 +634,7 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space)
        u32 domain;
        struct sk_buff *buf;
        struct node *n_ptr;
-        struct tipc_link_info link_info;
+       struct tipc_link_info link_info;
        u32 payload_size;
 
        if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NET_ADDR))
@@ -645,9 +645,9 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space)
                return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
                                                   " (network address)");
 
-        if (tipc_mode != TIPC_NET_MODE)
-                return tipc_cfg_reply_none();
-       
+       if (tipc_mode != TIPC_NET_MODE)
+               return tipc_cfg_reply_none();
+
        /* Get space for all unicast links + multicast link */
 
        payload_size = TLV_SPACE(sizeof(link_info)) *
@@ -661,27 +661,27 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space)
 
        /* Add TLV for broadcast link */
 
-        link_info.dest = htonl(tipc_own_addr & 0xfffff00);
-        link_info.up = htonl(1);
-        sprintf(link_info.str, tipc_bclink_name);
+       link_info.dest = htonl(tipc_own_addr & 0xfffff00);
+       link_info.up = htonl(1);
+       sprintf(link_info.str, tipc_bclink_name);
        tipc_cfg_append_tlv(buf, TIPC_TLV_LINK_INFO, &link_info, sizeof(link_info));
 
        /* Add TLVs for any other links in scope */
 
        for (n_ptr = tipc_nodes; n_ptr; n_ptr = n_ptr->next) {
-                u32 i;
+               u32 i;
 
                if (!in_scope(domain, n_ptr->addr))
                        continue;
-                for (i = 0; i < MAX_BEARERS; i++) {
-                        if (!n_ptr->links[i]) 
-                                continue;
-                        link_info.dest = htonl(n_ptr->addr);
-                        link_info.up = htonl(tipc_link_is_up(n_ptr->links[i]));
-                        strcpy(link_info.str, n_ptr->links[i]->name);
-                       tipc_cfg_append_tlv(buf, TIPC_TLV_LINK_INFO, 
+               for (i = 0; i < MAX_BEARERS; i++) {
+                       if (!n_ptr->links[i])
+                               continue;
+                       link_info.dest = htonl(n_ptr->addr);
+                       link_info.up = htonl(tipc_link_is_up(n_ptr->links[i]));
+                       strcpy(link_info.str, n_ptr->links[i]->name);
+                       tipc_cfg_append_tlv(buf, TIPC_TLV_LINK_INFO,
                                            &link_info, sizeof(link_info));
-                }
+               }
        }
 
        return buf;
index a07cc79ea63719f2aaec8737aee2b59153789cc9..cd1882654bbb27205307e0f61302c72ff8697f16 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * net/tipc/node.h: Include file for TIPC node management routines
- * 
+ *
  * Copyright (c) 2000-2006, Ericsson AB
  * Copyright (c) 2005, Wind River Systems
  * All rights reserved.
@@ -67,7 +67,7 @@
  *    @deferred_tail: newest OOS b'cast message received from node
  *    @defragm: list of partially reassembled b'cast message fragments from node
  */
+
 struct node {
        u32 addr;
        spinlock_t lock;
@@ -85,8 +85,8 @@ struct node {
                int supported;
                u32 acked;
                u32 last_in;
-               u32 gap_after; 
-               u32 gap_to; 
+               u32 gap_after;
+               u32 gap_to;
                u32 nack_sync;
                struct sk_buff *deferred_head;
                struct sk_buff *deferred_tail;
index cc3fff3dec4f825cefda388a04b3d97b397be013..8ecbd0fb6103442712626899ee59edc6470ee0e2 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * net/tipc/node_subscr.c: TIPC "node down" subscription handling
- * 
+ *
  * Copyright (c) 1995-2006, Ericsson AB
  * Copyright (c) 2005, Wind River Systems
  * All rights reserved.
  * tipc_nodesub_subscribe - create "node down" subscription for specified node
  */
 
-void tipc_nodesub_subscribe(struct node_subscr *node_sub, u32 addr, 
+void tipc_nodesub_subscribe(struct node_subscr *node_sub, u32 addr,
                       void *usr_handle, net_ev_handler handle_down)
 {
        if (addr == tipc_own_addr) {
                node_sub->node = NULL;
                return;
        }
-       
+
        node_sub->node = tipc_node_find(addr);
        if (!node_sub->node) {
                warn("Node subscription rejected, unknown node 0x%x\n", addr);
index 01751c4fbb43ec10d40f8be516d18e2380d17df9..5f3f5859b84c3538252a7d21ccf36b0cca8c7af3 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * net/tipc/node_subscr.h: Include file for TIPC "node down" subscription handling
- * 
+ *
  * Copyright (c) 1995-2006, Ericsson AB
  * Copyright (c) 2005, Wind River Systems
  * All rights reserved.
index b7f3199523caaf846d0aa1479c69888426374040..5f8217d4b45206d2f3339a0bdfa0752607cec96e 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * net/tipc/port.c: TIPC port code
- * 
+ *
  * Copyright (c) 1992-2006, Ericsson AB
  * Copyright (c) 2004-2005, Wind River Systems
  * All rights reserved.
@@ -126,8 +126,8 @@ int tipc_multicast(u32 ref, struct tipc_name_seq const *seq, u32 domain,
 
        ext_targets = tipc_nametbl_mc_translate(seq->type, seq->lower, seq->upper,
                                                TIPC_NODE_SCOPE, &dports);
-       
-       /* Send message to destinations (duplicate it only if necessary) */ 
+
+       /* Send message to destinations (duplicate it only if necessary) */
 
        if (ext_targets) {
                if (dports.count != 0) {
@@ -157,7 +157,7 @@ int tipc_multicast(u32 ref, struct tipc_name_seq const *seq, u32 domain,
 
 /**
  * tipc_port_recv_mcast - deliver multicast message to all destination ports
- * 
+ *
  * If there is no port list, perform a lookup to create one
  */
 
@@ -213,7 +213,7 @@ exit:
 
 /**
  * tipc_createport_raw - create a native TIPC port
- * 
+ *
  * Returns local port reference
  */
 
@@ -273,7 +273,7 @@ int tipc_deleteport(u32 ref)
 
        tipc_withdraw(ref, 0, NULL);
        p_ptr = tipc_port_lock(ref);
-       if (!p_ptr) 
+       if (!p_ptr)
                return -EINVAL;
 
        tipc_ref_discard(ref);
@@ -302,7 +302,7 @@ int tipc_deleteport(u32 ref)
 
 /**
  * tipc_get_port() - return port associated with 'ref'
- * 
+ *
  * Note: Port is not locked.
  */
 
@@ -336,7 +336,7 @@ static int port_unreliable(struct port *p_ptr)
 int tipc_portunreliable(u32 ref, unsigned int *isunreliable)
 {
        struct port *p_ptr;
-       
+
        p_ptr = tipc_port_lock(ref);
        if (!p_ptr)
                return -EINVAL;
@@ -348,7 +348,7 @@ int tipc_portunreliable(u32 ref, unsigned int *isunreliable)
 int tipc_set_portunreliable(u32 ref, unsigned int isunreliable)
 {
        struct port *p_ptr;
-       
+
        p_ptr = tipc_port_lock(ref);
        if (!p_ptr)
                return -EINVAL;
@@ -365,7 +365,7 @@ static int port_unreturnable(struct port *p_ptr)
 int tipc_portunreturnable(u32 ref, unsigned int *isunrejectable)
 {
        struct port *p_ptr;
-       
+
        p_ptr = tipc_port_lock(ref);
        if (!p_ptr)
                return -EINVAL;
@@ -377,7 +377,7 @@ int tipc_portunreturnable(u32 ref, unsigned int *isunrejectable)
 int tipc_set_portunreturnable(u32 ref, unsigned int isunrejectable)
 {
        struct port *p_ptr;
-       
+
        p_ptr = tipc_port_lock(ref);
        if (!p_ptr)
                return -EINVAL;
@@ -386,19 +386,19 @@ int tipc_set_portunreturnable(u32 ref, unsigned int isunrejectable)
        return TIPC_OK;
 }
 
-/* 
- * port_build_proto_msg(): build a port level protocol 
- * or a connection abortion message. Called with 
+/*
+ * port_build_proto_msg(): build a port level protocol
+ * or a connection abortion message. Called with
  * tipc_port lock on.
  */
 static struct sk_buff *port_build_proto_msg(u32 destport, u32 destnode,
                                            u32 origport, u32 orignode,
-                                           u32 usr, u32 type, u32 err, 
+                                           u32 usr, u32 type, u32 err,
                                            u32 seqno, u32 ack)
 {
        struct sk_buff *buf;
        struct tipc_msg *msg;
-       
+
        buf = buf_acquire(LONG_H_SIZE);
        if (buf) {
                msg = buf_msg(buf);
@@ -461,7 +461,7 @@ int tipc_reject_msg(struct sk_buff *buf, u32 err)
                msg_set_orignode(rmsg, tipc_own_addr);
        else
                msg_set_orignode(rmsg, msg_destnode(msg));
-       msg_set_size(rmsg, data_sz + hdr_sz); 
+       msg_set_size(rmsg, data_sz + hdr_sz);
        msg_set_nametype(rmsg, msg_nametype(msg));
        msg_set_nameinst(rmsg, msg_nameinst(msg));
        memcpy(rbuf->data + hdr_sz, msg_data(msg), data_sz);
@@ -492,7 +492,7 @@ int tipc_port_reject_sections(struct port *p_ptr, struct tipc_msg *hdr,
        struct sk_buff *buf;
        int res;
 
-       res = msg_build(hdr, msg_sect, num_sect, MAX_MSG_SIZE, 
+       res = msg_build(hdr, msg_sect, num_sect, MAX_MSG_SIZE,
                        !p_ptr->user_port, &buf);
        if (!buf)
                return res;
@@ -523,7 +523,7 @@ static void port_timeout(unsigned long ref)
                                           tipc_own_addr,
                                           CONN_MANAGER,
                                           CONN_PROBE,
-                                          TIPC_OK, 
+                                          TIPC_OK,
                                           port_out_seqno(p_ptr),
                                           0);
                port_incr_out_seqno(p_ptr);
@@ -562,7 +562,7 @@ static struct sk_buff *port_build_self_abort_msg(struct port *p_ptr, u32 err)
                                    port_peernode(p_ptr),
                                    imp,
                                    TIPC_CONN_MSG,
-                                   err, 
+                                   err,
                                    p_ptr->last_in_seqno + 1,
                                    0);
 }
@@ -582,7 +582,7 @@ static struct sk_buff *port_build_peer_abort_msg(struct port *p_ptr, u32 err)
                                    tipc_own_addr,
                                    imp,
                                    TIPC_CONN_MSG,
-                                   err, 
+                                   err,
                                    port_out_seqno(p_ptr),
                                    0);
 }
@@ -613,7 +613,7 @@ void tipc_port_recv_proto_msg(struct sk_buff *buf)
                        }
                }
                if (msg_type(msg) == CONN_ACK) {
-                       int wakeup = tipc_port_congested(p_ptr) && 
+                       int wakeup = tipc_port_congested(p_ptr) &&
                                     p_ptr->publ.congested &&
                                     p_ptr->wakeup;
                        p_ptr->acked += msg_msgcnt(msg);
@@ -630,8 +630,8 @@ void tipc_port_recv_proto_msg(struct sk_buff *buf)
        }
        if (err) {
                r_buf = port_build_proto_msg(msg_origport(msg),
-                                            msg_orignode(msg), 
-                                            msg_destport(msg), 
+                                            msg_orignode(msg),
+                                            msg_destport(msg),
                                             tipc_own_addr,
                                             DATA_HIGH,
                                             TIPC_CONN_MSG,
@@ -643,10 +643,10 @@ void tipc_port_recv_proto_msg(struct sk_buff *buf)
 
        /* All is fine */
        if (msg_type(msg) == CONN_PROBE) {
-               r_buf = port_build_proto_msg(msg_origport(msg), 
-                                            msg_orignode(msg), 
-                                            msg_destport(msg), 
-                                            tipc_own_addr, 
+               r_buf = port_build_proto_msg(msg_origport(msg),
+                                            msg_orignode(msg),
+                                            msg_destport(msg),
+                                            tipc_own_addr,
                                             CONN_MANAGER,
                                             CONN_PROBE_REPLY,
                                             TIPC_OK,
@@ -665,39 +665,39 @@ exit:
 
 static void port_print(struct port *p_ptr, struct print_buf *buf, int full_id)
 {
-        struct publication *publ;
+       struct publication *publ;
 
        if (full_id)
-               tipc_printf(buf, "<%u.%u.%u:%u>:", 
+               tipc_printf(buf, "<%u.%u.%u:%u>:",
                            tipc_zone(tipc_own_addr), tipc_cluster(tipc_own_addr),
-                            tipc_node(tipc_own_addr), p_ptr->publ.ref);
+                           tipc_node(tipc_own_addr), p_ptr->publ.ref);
        else
                tipc_printf(buf, "%-10u:", p_ptr->publ.ref);
 
-        if (p_ptr->publ.connected) {
-                u32 dport = port_peerport(p_ptr);
-                u32 destnode = port_peernode(p_ptr);
-
-                tipc_printf(buf, " connected to <%u.%u.%u:%u>",
-                            tipc_zone(destnode), tipc_cluster(destnode),
-                            tipc_node(destnode), dport);
-                if (p_ptr->publ.conn_type != 0)
-                        tipc_printf(buf, " via {%u,%u}",
-                                    p_ptr->publ.conn_type,
-                                    p_ptr->publ.conn_instance);
-        }
-        else if (p_ptr->publ.published) {
-                tipc_printf(buf, " bound to");
-                list_for_each_entry(publ, &p_ptr->publications, pport_list) {
+       if (p_ptr->publ.connected) {
+               u32 dport = port_peerport(p_ptr);
+               u32 destnode = port_peernode(p_ptr);
+
+               tipc_printf(buf, " connected to <%u.%u.%u:%u>",
+                           tipc_zone(destnode), tipc_cluster(destnode),
+                           tipc_node(destnode), dport);
+               if (p_ptr->publ.conn_type != 0)
+                       tipc_printf(buf, " via {%u,%u}",
+                                   p_ptr->publ.conn_type,
+                                   p_ptr->publ.conn_instance);
+       }
+       else if (p_ptr->publ.published) {
+               tipc_printf(buf, " bound to");
+               list_for_each_entry(publ, &p_ptr->publications, pport_list) {
                        if (publ->lower == publ->upper)
                                tipc_printf(buf, " {%u,%u}", publ->type,
                                            publ->lower);
                        else
-                               tipc_printf(buf, " {%u,%u,%u}", publ->type, 
+                               tipc_printf(buf, " {%u,%u,%u}", publ->type,
                                            publ->lower, publ->upper);
-                }
-        }
-        tipc_printf(buf, "\n");
+               }
+       }
+       tipc_printf(buf, "\n");
 }
 
 #define MAX_PORT_QUERY 32768
@@ -818,7 +818,7 @@ static void port_dispatcher_sigh(void *dummy)
                struct sk_buff *next = buf->next;
                struct tipc_msg *msg = buf_msg(buf);
                u32 dref = msg_destport(msg);
-               
+
                message_type = msg_type(msg);
                if (message_type > TIPC_DIRECT_MSG)
                        goto reject;    /* Unsupported message type */
@@ -838,7 +838,7 @@ static void port_dispatcher_sigh(void *dummy)
                        goto err;
 
                switch (message_type) {
-               
+
                case TIPC_CONN_MSG:{
                                tipc_conn_msg_event cb = up_ptr->conn_msg_cb;
                                u32 peer_port = port_peerport(p_ptr);
@@ -856,9 +856,9 @@ static void port_dispatcher_sigh(void *dummy)
                                        goto reject;
                                if (unlikely(!cb))
                                        goto reject;
-                               if (unlikely(++p_ptr->publ.conn_unacked >= 
+                               if (unlikely(++p_ptr->publ.conn_unacked >=
                                             TIPC_FLOW_CONTROL_WIN))
-                                       tipc_acknowledge(dref, 
+                                       tipc_acknowledge(dref,
                                                         p_ptr->publ.conn_unacked);
                                skb_pull(buf, msg_hdr_sz(msg));
                                cb(usr_handle, dref, &buf, msg_data(msg),
@@ -874,7 +874,7 @@ static void port_dispatcher_sigh(void *dummy)
                                if (unlikely(!cb))
                                        goto reject;
                                skb_pull(buf, msg_hdr_sz(msg));
-                               cb(usr_handle, dref, &buf, msg_data(msg), 
+                               cb(usr_handle, dref, &buf, msg_data(msg),
                                   msg_data_sz(msg), msg_importance(msg),
                                   &orig);
                                break;
@@ -895,7 +895,7 @@ static void port_dispatcher_sigh(void *dummy)
                                dseq.upper = (message_type == TIPC_NAMED_MSG)
                                        ? dseq.lower : msg_nameupper(msg);
                                skb_pull(buf, msg_hdr_sz(msg));
-                               cb(usr_handle, dref, &buf, msg_data(msg), 
+                               cb(usr_handle, dref, &buf, msg_data(msg),
                                   msg_data_sz(msg), msg_importance(msg),
                                   &orig, &dseq);
                                break;
@@ -907,9 +907,9 @@ static void port_dispatcher_sigh(void *dummy)
                continue;
 err:
                switch (message_type) {
-               
+
                case TIPC_CONN_MSG:{
-                               tipc_conn_shutdown_event cb = 
+                               tipc_conn_shutdown_event cb =
                                        up_ptr->conn_err_cb;
                                u32 peer_port = port_peerport(p_ptr);
                                u32 peer_node = port_peernode(p_ptr);
@@ -940,7 +940,7 @@ err:
                        }
                case TIPC_MCAST_MSG:
                case TIPC_NAMED_MSG:{
-                               tipc_named_msg_err_event cb = 
+                               tipc_named_msg_err_event cb =
                                        up_ptr->named_err_cb;
 
                                spin_unlock_bh(p_ptr->publ.lock);
@@ -951,7 +951,7 @@ err:
                                dseq.upper = (message_type == TIPC_NAMED_MSG)
                                        ? dseq.lower : msg_nameupper(msg);
                                skb_pull(buf, msg_hdr_sz(msg));
-                               cb(usr_handle, dref, &buf, msg_data(msg), 
+                               cb(usr_handle, dref, &buf, msg_data(msg),
                                   msg_data_sz(msg), msg_errcode(msg), &dseq);
                                break;
                        }
@@ -986,9 +986,9 @@ static u32 port_dispatcher(struct tipc_port *dummy, struct sk_buff *buf)
        return TIPC_OK;
 }
 
-/* 
+/*
  * Wake up port after congestion: Called with port locked,
- *                                
+ *
  */
 
 static void port_wakeup_sh(unsigned long ref)
@@ -1033,7 +1033,7 @@ void tipc_acknowledge(u32 ref, u32 ack)
                                           tipc_own_addr,
                                           CONN_MANAGER,
                                           CONN_ACK,
-                                          TIPC_OK, 
+                                          TIPC_OK,
                                           port_out_seqno(p_ptr),
                                           ack);
        }
@@ -1046,20 +1046,20 @@ void tipc_acknowledge(u32 ref, u32 ack)
  *                    registry if non-zero user_ref.
  */
 
-int tipc_createport(u32 user_ref, 
-                   void *usr_handle, 
-                   unsigned int importance, 
-                   tipc_msg_err_event error_cb, 
-                   tipc_named_msg_err_event named_error_cb, 
-                   tipc_conn_shutdown_event conn_error_cb, 
-                   tipc_msg_event msg_cb, 
-                   tipc_named_msg_event named_msg_cb, 
-                   tipc_conn_msg_event conn_msg_cb, 
+int tipc_createport(u32 user_ref,
+                   void *usr_handle,
+                   unsigned int importance,
+                   tipc_msg_err_event error_cb,
+                   tipc_named_msg_err_event named_error_cb,
+                   tipc_conn_shutdown_event conn_error_cb,
+                   tipc_msg_event msg_cb,
+                   tipc_named_msg_event named_msg_cb,
+                   tipc_conn_msg_event conn_msg_cb,
                    tipc_continue_event continue_event_cb,/* May be zero */
                    u32 *portref)
 {
        struct user_port *up_ptr;
-       struct port *p_ptr; 
+       struct port *p_ptr;
        u32 ref;
 
        up_ptr = kmalloc(sizeof(*up_ptr), GFP_ATOMIC);
@@ -1088,7 +1088,7 @@ int tipc_createport(u32 user_ref,
        INIT_LIST_HEAD(&up_ptr->uport_list);
        tipc_reg_add_port(up_ptr);
        *portref = p_ptr->publ.ref;
-       dbg(" tipc_createport: %x with ref %u\n", p_ptr, p_ptr->publ.ref);        
+       dbg(" tipc_createport: %x with ref %u\n", p_ptr, p_ptr->publ.ref);
        tipc_port_unlock(p_ptr);
        return TIPC_OK;
 }
@@ -1103,7 +1103,7 @@ int tipc_ownidentity(u32 ref, struct tipc_portid *id)
 int tipc_portimportance(u32 ref, unsigned int *importance)
 {
        struct port *p_ptr;
-       
+
        p_ptr = tipc_port_lock(ref);
        if (!p_ptr)
                return -EINVAL;
@@ -1172,19 +1172,19 @@ int tipc_withdraw(u32 ref, unsigned int scope, struct tipc_name_seq const *seq)
        struct publication *publ;
        struct publication *tpubl;
        int res = -EINVAL;
-       
+
        p_ptr = tipc_port_lock(ref);
        if (!p_ptr)
                return -EINVAL;
        if (!seq) {
-               list_for_each_entry_safe(publ, tpubl, 
+               list_for_each_entry_safe(publ, tpubl,
                                         &p_ptr->publications, pport_list) {
-                       tipc_nametbl_withdraw(publ->type, publ->lower, 
+                       tipc_nametbl_withdraw(publ->type, publ->lower,
                                              publ->ref, publ->key);
                }
                res = TIPC_OK;
        } else {
-               list_for_each_entry_safe(publ, tpubl, 
+               list_for_each_entry_safe(publ, tpubl,
                                         &p_ptr->publications, pport_list) {
                        if (publ->scope != scope)
                                continue;
@@ -1194,7 +1194,7 @@ int tipc_withdraw(u32 ref, unsigned int scope, struct tipc_name_seq const *seq)
                                continue;
                        if (publ->upper != seq->upper)
                                break;
-                       tipc_nametbl_withdraw(publ->type, publ->lower, 
+                       tipc_nametbl_withdraw(publ->type, publ->lower,
                                              publ->ref, publ->key);
                        res = TIPC_OK;
                        break;
@@ -1292,7 +1292,7 @@ int tipc_shutdown(u32 ref)
                                           tipc_own_addr,
                                           imp,
                                           TIPC_CONN_MSG,
-                                          TIPC_CONN_SHUTDOWN, 
+                                          TIPC_CONN_SHUTDOWN,
                                           port_out_seqno(p_ptr),
                                           0);
        }
@@ -1304,7 +1304,7 @@ int tipc_shutdown(u32 ref)
 int tipc_isconnected(u32 ref, int *isconnected)
 {
        struct port *p_ptr;
-       
+
        p_ptr = tipc_port_lock(ref);
        if (!p_ptr)
                return -EINVAL;
@@ -1317,7 +1317,7 @@ int tipc_peer(u32 ref, struct tipc_portid *peer)
 {
        struct port *p_ptr;
        int res;
-        
+
        p_ptr = tipc_port_lock(ref);
        if (!p_ptr)
                return -EINVAL;
@@ -1348,7 +1348,7 @@ int tipc_port_recv_sections(struct port *sender, unsigned int num_sect,
 {
        struct sk_buff *buf;
        int res;
-        
+
        res = msg_build(&sender->publ.phdr, msg_sect, num_sect,
                        MAX_MSG_SIZE, !sender->user_port, &buf);
        if (likely(buf))
@@ -1394,7 +1394,7 @@ int tipc_send(u32 ref, unsigned int num_sect, struct iovec const *msg_sect)
        return -ELINKCONG;
 }
 
-/** 
+/**
  * tipc_send_buf - send message buffer on connection
  */
 
@@ -1406,7 +1406,7 @@ int tipc_send_buf(u32 ref, struct sk_buff *buf, unsigned int dsz)
        u32 hsz;
        u32 sz;
        u32 res;
-        
+
        p_ptr = tipc_port_deref(ref);
        if (!p_ptr || !p_ptr->publ.connected)
                return -EINVAL;
@@ -1447,12 +1447,12 @@ int tipc_send_buf(u32 ref, struct sk_buff *buf, unsigned int dsz)
  * tipc_forward2name - forward message sections to port name
  */
 
-int tipc_forward2name(u32 ref, 
-                     struct tipc_name const *name, 
+int tipc_forward2name(u32 ref,
+                     struct tipc_name const *name,
                      u32 domain,
-                     u32 num_sect, 
+                     u32 num_sect,
                      struct iovec const *msg_sect,
-                     struct tipc_portid const *orig, 
+                     struct tipc_portid const *orig,
                      unsigned int importance)
 {
        struct port *p_ptr;
@@ -1483,7 +1483,7 @@ int tipc_forward2name(u32 ref,
                p_ptr->sent++;
                if (likely(destnode == tipc_own_addr))
                        return tipc_port_recv_sections(p_ptr, num_sect, msg_sect);
-               res = tipc_link_send_sections_fast(p_ptr, msg_sect, num_sect, 
+               res = tipc_link_send_sections_fast(p_ptr, msg_sect, num_sect,
                                                   destnode);
                if (likely(res != -ELINKCONG))
                        return res;
@@ -1493,7 +1493,7 @@ int tipc_forward2name(u32 ref,
                }
                return -ELINKCONG;
        }
-       return tipc_port_reject_sections(p_ptr, msg, msg_sect, num_sect, 
+       return tipc_port_reject_sections(p_ptr, msg, msg_sect, num_sect,
                                         TIPC_ERR_NO_NAME);
 }
 
@@ -1501,10 +1501,10 @@ int tipc_forward2name(u32 ref,
  * tipc_send2name - send message sections to port name
  */
 
-int tipc_send2name(u32 ref, 
+int tipc_send2name(u32 ref,
                   struct tipc_name const *name,
-                  unsigned int domain, 
-                  unsigned int num_sect, 
+                  unsigned int domain,
+                  unsigned int num_sect,
                   struct iovec const *msg_sect)
 {
        struct tipc_portid orig;
@@ -1515,7 +1515,7 @@ int tipc_send2name(u32 ref,
                                 TIPC_PORT_IMPORTANCE);
 }
 
-/** 
+/**
  * tipc_forward_buf2name - forward message buffer to port name
  */
 
@@ -1571,14 +1571,14 @@ int tipc_forward_buf2name(u32 ref,
        return tipc_reject_msg(buf, TIPC_ERR_NO_NAME);
 }
 
-/** 
+/**
  * tipc_send_buf2name - send message buffer to port name
  */
 
-int tipc_send_buf2name(u32 ref, 
-                      struct tipc_name const *dest, 
+int tipc_send_buf2name(u32 ref,
+                      struct tipc_name const *dest,
                       u32 domain,
-                      struct sk_buff *buf, 
+                      struct sk_buff *buf,
                       unsigned int dsz)
 {
        struct tipc_portid orig;
@@ -1589,15 +1589,15 @@ int tipc_send_buf2name(u32 ref,
                                     TIPC_PORT_IMPORTANCE);
 }
 
-/** 
+/**
  * tipc_forward2port - forward message sections to port identity
  */
 
 int tipc_forward2port(u32 ref,
                      struct tipc_portid const *dest,
-                     unsigned int num_sect, 
+                     unsigned int num_sect,
                      struct iovec const *msg_sect,
-                     struct tipc_portid const *orig, 
+                     struct tipc_portid const *orig,
                      unsigned int importance)
 {
        struct port *p_ptr;
@@ -1630,24 +1630,24 @@ int tipc_forward2port(u32 ref,
        return -ELINKCONG;
 }
 
-/** 
- * tipc_send2port - send message sections to port identity 
+/**
+ * tipc_send2port - send message sections to port identity
  */
 
-int tipc_send2port(u32 ref, 
+int tipc_send2port(u32 ref,
                   struct tipc_portid const *dest,
-                  unsigned int num_sect, 
+                  unsigned int num_sect,
                   struct iovec const *msg_sect)
 {
        struct tipc_portid orig;
 
        orig.ref = ref;
        orig.node = tipc_own_addr;
-       return tipc_forward2port(ref, dest, num_sect, msg_sect, &orig, 
+       return tipc_forward2port(ref, dest, num_sect, msg_sect, &orig,
                                 TIPC_PORT_IMPORTANCE);
 }
 
-/** 
+/**
  * tipc_forward_buf2port - forward message buffer to port identity
  */
 int tipc_forward_buf2port(u32 ref,
@@ -1692,20 +1692,20 @@ int tipc_forward_buf2port(u32 ref,
        return -ELINKCONG;
 }
 
-/** 
+/**
  * tipc_send_buf2port - send message buffer to port identity
  */
 
-int tipc_send_buf2port(u32 ref, 
+int tipc_send_buf2port(u32 ref,
                       struct tipc_portid const *dest,
-                      struct sk_buff *buf, 
+                      struct sk_buff *buf,
                       unsigned int dsz)
 {
        struct tipc_portid orig;
 
        orig.ref = ref;
        orig.node = tipc_own_addr;
-       return tipc_forward_buf2port(ref, dest, buf, dsz, &orig, 
+       return tipc_forward_buf2port(ref, dest, buf, dsz, &orig,
                                     TIPC_PORT_IMPORTANCE);
 }
 
index 839f100da646e8d8fc7c4a3bc6b35635bdd78963..7ef4d64b32f79a95e89bd412c1dae6e1ef47248b 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * net/tipc/port.h: Include file for TIPC port code
- * 
+ *
  * Copyright (c) 1994-2006, Ericsson AB
  * Copyright (c) 2004-2005, Wind River Systems
  * All rights reserved.
  * <various callback routines>
  * @uport_list: adjacent user ports in list of ports held by user
  */
+
 struct user_port {
        u32 user_ref;
-       void *usr_handle; 
+       void *usr_handle;
        u32 ref;
-       tipc_msg_err_event err_cb; 
-       tipc_named_msg_err_event named_err_cb; 
-       tipc_conn_shutdown_event conn_err_cb; 
-       tipc_msg_event msg_cb; 
-       tipc_named_msg_event named_msg_cb; 
-       tipc_conn_msg_event conn_msg_cb; 
+       tipc_msg_err_event err_cb;
+       tipc_named_msg_err_event named_err_cb;
+       tipc_conn_shutdown_event conn_err_cb;
+       tipc_msg_event msg_cb;
+       tipc_named_msg_event named_msg_cb;
+       tipc_conn_msg_event conn_msg_cb;
        tipc_continue_event continue_event_cb;
        struct list_head uport_list;
 };
@@ -113,7 +113,7 @@ struct port {
 extern spinlock_t tipc_port_list_lock;
 struct port_list;
 
-int tipc_port_recv_sections(struct port *p_ptr, u32 num_sect, 
+int tipc_port_recv_sections(struct port *p_ptr, u32 num_sect,
                            struct iovec const *msg_sect);
 int tipc_port_reject_sections(struct port *p_ptr, struct tipc_msg *hdr,
                              struct iovec const *msg_sect, u32 num_sect,
@@ -133,9 +133,9 @@ static inline struct port *tipc_port_lock(u32 ref)
        return (struct port *)tipc_ref_lock(ref);
 }
 
-/** 
+/**
  * tipc_port_unlock - unlock a port instance
- * 
+ *
  * Can use pointer instead of tipc_ref_unlock() since port is already locked.
  */
 
@@ -164,7 +164,7 @@ static inline int tipc_port_congested(struct port *p_ptr)
        return((p_ptr->sent - p_ptr->acked) >= (TIPC_FLOW_CONTROL_WIN * 2));
 }
 
-/** 
+/**
  * tipc_port_recv_msg - receive message from lower layer and deliver to port user
  */
 
@@ -175,7 +175,7 @@ static inline int tipc_port_recv_msg(struct sk_buff *buf)
        u32 destport = msg_destport(msg);
        u32 dsz = msg_data_sz(msg);
        u32 err;
-       
+
        /* forward unresolved named message */
        if (unlikely(!destport)) {
                tipc_net_route_msg(buf);
index e6d6ae22ea495065db2e5862c8ec41b95fda8661..6704a58c785162e40989711bd061c44e6b8f25e8 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * net/tipc/ref.c: TIPC object registry code
- * 
+ *
  * Copyright (c) 1991-2006, Ericsson AB
  * Copyright (c) 2004-2005, Wind River Systems
  * All rights reserved.
  * Object reference table consists of 2**N entries.
  *
  * A used entry has object ptr != 0, reference == XXXX|own index
- *                                  (XXXX changes each time entry is acquired) 
+ *                                  (XXXX changes each time entry is acquired)
  * A free entry has object ptr == 0, reference == YYYY|next free index
  *                                  (YYYY is one more than last used XXXX)
  *
- * Free list is initially chained from entry (2**N)-1 to entry 1. 
+ * Free list is initially chained from entry (2**N)-1 to entry 1.
  * Entry 0 is not used to allow index 0 to indicate the end of the free list.
  *
  * Note: Any accidental reference of the form XXXX|0--0 won't match entry 0
@@ -113,9 +113,9 @@ void tipc_ref_table_stop(void)
 
 /**
  * tipc_ref_acquire - create reference to an object
- * 
+ *
  * Return a unique reference value which can be translated back to the pointer
- * 'object' at a later time.  Also, pass back a pointer to the lock protecting 
+ * 'object' at a later time.  Also, pass back a pointer to the lock protecting
  * the object, but without locking it.
  */
 
@@ -141,15 +141,15 @@ u32 tipc_ref_acquire(void *object, spinlock_t **lock)
                index = tipc_ref_table.first_free;
                entry = &(tipc_ref_table.entries[index]);
                index_mask = tipc_ref_table.index_mask;
-               /* take lock in case a previous user of entry still holds it */ 
-               spin_lock_bh(&entry->lock);  
+               /* take lock in case a previous user of entry still holds it */
+               spin_lock_bh(&entry->lock);
                next_plus_upper = entry->data.next_plus_upper;
                tipc_ref_table.first_free = next_plus_upper & index_mask;
                reference = (next_plus_upper & ~index_mask) + index;
                entry->data.reference = reference;
                entry->object = object;
-                if (lock != 0)
-                        *lock = &entry->lock;
+               if (lock != 0)
+                       *lock = &entry->lock;
                spin_unlock_bh(&entry->lock);
        }
        write_unlock_bh(&ref_table_lock);
@@ -158,7 +158,7 @@ u32 tipc_ref_acquire(void *object, spinlock_t **lock)
 
 /**
  * tipc_ref_discard - invalidate references to an object
- * 
+ *
  * Disallow future references to an object and free up the entry for re-use.
  * Note: The entry's spin_lock may still be busy after discard
  */
@@ -166,7 +166,7 @@ u32 tipc_ref_acquire(void *object, spinlock_t **lock)
 void tipc_ref_discard(u32 ref)
 {
        struct reference *entry;
-       u32 index; 
+       u32 index;
        u32 index_mask;
 
        if (!ref) {
@@ -198,7 +198,7 @@ void tipc_ref_discard(u32 ref)
                tipc_ref_table.first_free = index;
        else
                /* next_plus_upper is always XXXX|0--0 for last free entry */
-               tipc_ref_table.entries[tipc_ref_table.last_free].data.next_plus_upper 
+               tipc_ref_table.entries[tipc_ref_table.last_free].data.next_plus_upper
                        |= index;
        tipc_ref_table.last_free = index;
 
index 6d20006be45b66d4f034aabf6ebd1eb538041ecc..38f3a7f4a78d8dcb8308db0b2ffc9aa2a921ca29 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * net/tipc/ref.h: Include file for TIPC object registry code
- * 
+ *
  * Copyright (c) 1991-2006, Ericsson AB
  * Copyright (c) 2005, Wind River Systems
  * All rights reserved.
@@ -43,7 +43,7 @@
  * @lock: spinlock controlling access to object
  * @data: reference value associated with object (or link to next unused entry)
  */
+
 struct reference {
        void *object;
        spinlock_t lock;
@@ -96,7 +96,7 @@ static inline void *tipc_ref_lock(u32 ref)
 }
 
 /**
- * tipc_ref_unlock - unlock referenced object 
+ * tipc_ref_unlock - unlock referenced object
  */
 
 static inline void tipc_ref_unlock(u32 ref)
@@ -119,7 +119,7 @@ static inline void tipc_ref_unlock(u32 ref)
 static inline void *tipc_ref_deref(u32 ref)
 {
        if (likely(tipc_ref_table.entries)) {
-               struct reference *r = 
+               struct reference *r =
                        &tipc_ref_table.entries[ref & tipc_ref_table.index_mask];
 
                if (likely(r->data.reference == ref))
index 2a6a5a6b4c125bac4f9e2e59241091b71a6d1c99..b71739fbe2c66cf588805bf99f6761695045f1b4 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * net/tipc/socket.c: TIPC socket API
- * 
+ *
  * Copyright (c) 2001-2006, Ericsson AB
  * Copyright (c) 2004-2006, Wind River Systems
  * All rights reserved.
@@ -82,29 +82,29 @@ static int sockets_enabled = 0;
 static atomic_t tipc_queue_size = ATOMIC_INIT(0);
 
 
-/* 
- * sock_lock(): Lock a port/socket pair. lock_sock() can 
- * not be used here, since the same lock must protect ports 
+/*
+ * sock_lock(): Lock a port/socket pair. lock_sock() can
+ * not be used here, since the same lock must protect ports
  * with non-socket interfaces.
  * See net.c for description of locking policy.
  */
 static void sock_lock(struct tipc_sock* tsock)
 {
-        spin_lock_bh(tsock->p->lock);       
+       spin_lock_bh(tsock->p->lock);
 }
 
-/* 
+/*
  * sock_unlock(): Unlock a port/socket pair
  */
 static void sock_unlock(struct tipc_sock* tsock)
 {
-        spin_unlock_bh(tsock->p->lock);
+       spin_unlock_bh(tsock->p->lock);
 }
 
 /**
  * pollmask - determine the current set of poll() events for a socket
  * @sock: socket structure
- * 
+ *
  * TIPC sets the returned events as follows:
  * a) POLLRDNORM and POLLIN are set if the socket's receive queue is non-empty
  *    or if a connection-oriented socket is does not have an active connection
@@ -115,7 +115,7 @@ static void sock_unlock(struct tipc_sock* tsock)
  *
  * IMPORTANT: The fact that a read or write operation will not block does NOT
  * imply that the operation will succeed!
- * 
+ *
  * Returns pollmask value
  */
 
@@ -130,7 +130,7 @@ static u32 pollmask(struct socket *sock)
        else
                mask = 0;
 
-       if (sock->state == SS_DISCONNECTING) 
+       if (sock->state == SS_DISCONNECTING)
                mask |= POLLHUP;
        else
                mask |= POLLOUT;
@@ -146,9 +146,9 @@ static u32 pollmask(struct socket *sock)
 
 static void advance_queue(struct tipc_sock *tsock)
 {
-        sock_lock(tsock);
+       sock_lock(tsock);
        buf_discard(skb_dequeue(&tsock->sk.sk_receive_queue));
-        sock_unlock(tsock);
+       sock_unlock(tsock);
        atomic_dec(&tipc_queue_size);
 }
 
@@ -156,7 +156,7 @@ static void advance_queue(struct tipc_sock *tsock)
  * tipc_create - create a TIPC socket
  * @sock: pre-allocated socket structure
  * @protocol: protocol indicator (must be 0)
- * 
+ *
  * This routine creates and attaches a 'struct sock' to the 'struct socket',
  * then create and attaches a TIPC port to the 'struct sock' part.
  *
@@ -167,7 +167,7 @@ static int tipc_create(struct socket *sock, int protocol)
        struct tipc_sock *tsock;
        struct tipc_port *port;
        struct sock *sk;
-        u32 ref;
+       u32 ref;
 
        if (unlikely(protocol != 0))
                return -EPROTONOSUPPORT;
@@ -232,7 +232,7 @@ static int tipc_create(struct socket *sock, int protocol)
  * For SEQPACKET and STREAM socket types, the first message is rejected
  * and any others are discarded.  (If the first message on a STREAM socket
  * is partially-read, it is discarded and the next one is rejected instead.)
- * 
+ *
  * NOTE: Rejected messages are not necessarily returned to the sender!  They
  * are returned or discarded according to the "destination droppable" setting
  * specified for the message by the sender.
@@ -247,7 +247,7 @@ static int release(struct socket *sock)
        int res = TIPC_OK;
        struct sk_buff *buf;
 
-        dbg("sock_delete: %x\n",tsock);
+       dbg("sock_delete: %x\n",tsock);
        if (!tsock)
                return 0;
        down_interruptible(&tsock->sem);
@@ -255,7 +255,7 @@ static int release(struct socket *sock)
                up(&tsock->sem);
                return 0;
        }
-       
+
        /* Reject unreceived messages, unless no longer connected */
 
        while (sock->state != SS_DISCONNECTING) {
@@ -289,7 +289,7 @@ static int release(struct socket *sock)
 
        sock_put(sk);
 
-        atomic_dec(&tipc_user_count);
+       atomic_dec(&tipc_user_count);
        return res;
 }
 
@@ -298,11 +298,11 @@ static int release(struct socket *sock)
  * @sock: socket structure
  * @uaddr: socket address describing name(s) and desired operation
  * @uaddr_len: size of socket address data structure
- * 
+ *
  * Name and name sequence binding is indicated using a positive scope value;
  * a negative scope value unbinds the specified name.  Specifying no name
  * (i.e. a socket address length of 0) unbinds all names from the socket.
- * 
+ *
  * Returns 0 on success, errno otherwise
  */
 
@@ -314,7 +314,7 @@ static int bind(struct socket *sock, struct sockaddr *uaddr, int uaddr_len)
 
        if (down_interruptible(&tsock->sem))
                return -ERESTARTSYS;
-       
+
        if (unlikely(!uaddr_len)) {
                res = tipc_withdraw(tsock->p->ref, 0, NULL);
                goto exit;
@@ -335,8 +335,8 @@ static int bind(struct socket *sock, struct sockaddr *uaddr, int uaddr_len)
                res = -EAFNOSUPPORT;
                goto exit;
        }
-        
-               if (addr->scope > 0)
+
+       if (addr->scope > 0)
                res = tipc_publish(tsock->p->ref, addr->scope,
                                   &addr->addr.nameseq);
        else
@@ -347,17 +347,17 @@ exit:
        return res;
 }
 
-/** 
+/**
  * get_name - get port ID of socket or peer socket
  * @sock: socket structure
  * @uaddr: area for returned socket address
  * @uaddr_len: area for returned length of socket address
  * @peer: 0 to obtain socket name, 1 to obtain peer socket name
- * 
+ *
  * Returns 0 on success, errno otherwise
  */
 
-static int get_name(struct socket *sock, struct sockaddr *uaddr, 
+static int get_name(struct socket *sock, struct sockaddr *uaddr,
                    int *uaddr_len, int peer)
 {
        struct tipc_sock *tsock = tipc_sk(sock->sk);
@@ -390,7 +390,7 @@ static int get_name(struct socket *sock, struct sockaddr *uaddr,
  * Returns the pollmask
  */
 
-static unsigned int poll(struct file *file, struct socket *sock, 
+static unsigned int poll(struct file *file, struct socket *sock,
                         poll_table *wait)
 {
        poll_wait(file, sock->sk->sk_sleep, wait);
@@ -398,14 +398,14 @@ static unsigned int poll(struct file *file, struct socket *sock,
        return pollmask(sock);
 }
 
-/** 
+/**
  * dest_name_check - verify user is permitted to send to specified port name
  * @dest: destination address
  * @m: descriptor for message to be sent
- * 
+ *
  * Prevents restricted configuration commands from being issued by
  * unauthorized users.
- * 
+ *
  * Returns 0 if permission is granted, otherwise errno
  */
 
@@ -413,19 +413,19 @@ static int dest_name_check(struct sockaddr_tipc *dest, struct msghdr *m)
 {
        struct tipc_cfg_msg_hdr hdr;
 
-        if (likely(dest->addr.name.name.type >= TIPC_RESERVED_TYPES))
-                return 0;
-        if (likely(dest->addr.name.name.type == TIPC_TOP_SRV))
-                return 0;
+       if (likely(dest->addr.name.name.type >= TIPC_RESERVED_TYPES))
+               return 0;
+       if (likely(dest->addr.name.name.type == TIPC_TOP_SRV))
+               return 0;
 
-        if (likely(dest->addr.name.name.type != TIPC_CFG_SRV))
-                return -EACCES;
+       if (likely(dest->addr.name.name.type != TIPC_CFG_SRV))
+               return -EACCES;
 
-        if (copy_from_user(&hdr, m->msg_iov[0].iov_base, sizeof(hdr)))
+       if (copy_from_user(&hdr, m->msg_iov[0].iov_base, sizeof(hdr)))
                return -EFAULT;
        if ((ntohs(hdr.tcm_type) & 0xC000) && (!capable(CAP_NET_ADMIN)))
                return -EACCES;
-        
+
        return 0;
 }
 
@@ -435,12 +435,12 @@ static int dest_name_check(struct sockaddr_tipc *dest, struct msghdr *m)
  * @sock: socket structure
  * @m: message to send
  * @total_len: length of message
- * 
+ *
  * Message must have an destination specified explicitly.
- * Used for SOCK_RDM and SOCK_DGRAM messages, 
+ * Used for SOCK_RDM and SOCK_DGRAM messages,
  * and for 'SYN' messages on SOCK_SEQPACKET and SOCK_STREAM connections.
  * (Note: 'SYN+' is prohibited on SOCK_STREAM.)
- * 
+ *
  * Returns the number of bytes sent on success, or errno otherwise
  */
 
@@ -448,7 +448,7 @@ static int send_msg(struct kiocb *iocb, struct socket *sock,
                    struct msghdr *m, size_t total_len)
 {
        struct tipc_sock *tsock = tipc_sk(sock->sk);
-        struct sockaddr_tipc *dest = (struct sockaddr_tipc *)m->msg_name;
+       struct sockaddr_tipc *dest = (struct sockaddr_tipc *)m->msg_name;
        struct sk_buff *buf;
        int needs_conn;
        int res = -EINVAL;
@@ -489,61 +489,61 @@ static int send_msg(struct kiocb *iocb, struct socket *sock,
                sock->state = SS_CONNECTING;
        }
 
-        do {
-                if (dest->addrtype == TIPC_ADDR_NAME) {
-                        if ((res = dest_name_check(dest, m)))
-                                goto exit;
-                        res = tipc_send2name(tsock->p->ref,
-                                             &dest->addr.name.name,
-                                             dest->addr.name.domain, 
-                                             m->msg_iovlen,
-                                             m->msg_iov);
-                }
-                else if (dest->addrtype == TIPC_ADDR_ID) {
-                        res = tipc_send2port(tsock->p->ref,
-                                             &dest->addr.id,
-                                             m->msg_iovlen,
-                                             m->msg_iov);
-                }
-                else if (dest->addrtype == TIPC_ADDR_MCAST) {
+       do {
+               if (dest->addrtype == TIPC_ADDR_NAME) {
+                       if ((res = dest_name_check(dest, m)))
+                               goto exit;
+                       res = tipc_send2name(tsock->p->ref,
+                                            &dest->addr.name.name,
+                                            dest->addr.name.domain,
+                                            m->msg_iovlen,
+                                            m->msg_iov);
+               }
+               else if (dest->addrtype == TIPC_ADDR_ID) {
+                       res = tipc_send2port(tsock->p->ref,
+                                            &dest->addr.id,
+                                            m->msg_iovlen,
+                                            m->msg_iov);
+               }
+               else if (dest->addrtype == TIPC_ADDR_MCAST) {
                        if (needs_conn) {
                                res = -EOPNOTSUPP;
                                goto exit;
                        }
-                        if ((res = dest_name_check(dest, m)))
-                                goto exit;
-                        res = tipc_multicast(tsock->p->ref,
-                                             &dest->addr.nameseq,
-                                             0,
-                                             m->msg_iovlen,
-                                             m->msg_iov);
-                }
-                if (likely(res != -ELINKCONG)) {
-exit:                                
-                        up(&tsock->sem);
-                        return res;
-                }
+                       if ((res = dest_name_check(dest, m)))
+                               goto exit;
+                       res = tipc_multicast(tsock->p->ref,
+                                            &dest->addr.nameseq,
+                                            0,
+                                            m->msg_iovlen,
+                                            m->msg_iov);
+               }
+               if (likely(res != -ELINKCONG)) {
+exit:
+                       up(&tsock->sem);
+                       return res;
+               }
                if (m->msg_flags & MSG_DONTWAIT) {
                        res = -EWOULDBLOCK;
                        goto exit;
                }
-                if (wait_event_interruptible(*sock->sk->sk_sleep,
-                                             !tsock->p->congested)) {
-                    res = -ERESTARTSYS;
-                    goto exit;
-                }
-        } while (1);
+               if (wait_event_interruptible(*sock->sk->sk_sleep,
+                                            !tsock->p->congested)) {
+                   res = -ERESTARTSYS;
+                   goto exit;
+               }
+       } while (1);
 }
 
-/** 
+/**
  * send_packet - send a connection-oriented message
  * @iocb: (unused)
  * @sock: socket structure
  * @m: message to send
  * @total_len: length of message
- * 
+ *
  * Used for SOCK_SEQPACKET messages and SOCK_STREAM data.
- * 
+ *
  * Returns the number of bytes sent on success, or errno otherwise
  */
 
@@ -551,7 +551,7 @@ static int send_packet(struct kiocb *iocb, struct socket *sock,
                       struct msghdr *m, size_t total_len)
 {
        struct tipc_sock *tsock = tipc_sk(sock->sk);
-        struct sockaddr_tipc *dest = (struct sockaddr_tipc *)m->msg_name;
+       struct sockaddr_tipc *dest = (struct sockaddr_tipc *)m->msg_name;
        int res;
 
        /* Handle implied connection establishment */
@@ -561,45 +561,45 @@ static int send_packet(struct kiocb *iocb, struct socket *sock,
 
        if (down_interruptible(&tsock->sem)) {
                return -ERESTARTSYS;
-        }
+       }
 
-        do {
+       do {
                if (unlikely(sock->state != SS_CONNECTED)) {
                        if (sock->state == SS_DISCONNECTING)
-                               res = -EPIPE;   
+                               res = -EPIPE;
                        else
                                res = -ENOTCONN;
                        goto exit;
                }
 
-                res = tipc_send(tsock->p->ref, m->msg_iovlen, m->msg_iov);
-                if (likely(res != -ELINKCONG)) {
+               res = tipc_send(tsock->p->ref, m->msg_iovlen, m->msg_iov);
+               if (likely(res != -ELINKCONG)) {
 exit:
-                        up(&tsock->sem);
-                        return res;
-                }
+                       up(&tsock->sem);
+                       return res;
+               }
                if (m->msg_flags & MSG_DONTWAIT) {
                        res = -EWOULDBLOCK;
                        goto exit;
                }
-                if (wait_event_interruptible(*sock->sk->sk_sleep,
-                                             !tsock->p->congested)) {
-                    res = -ERESTARTSYS;
-                    goto exit;
-                }
-        } while (1);
+               if (wait_event_interruptible(*sock->sk->sk_sleep,
+                                            !tsock->p->congested)) {
+                   res = -ERESTARTSYS;
+                   goto exit;
+               }
+       } while (1);
 }
 
-/** 
+/**
  * send_stream - send stream-oriented data
  * @iocb: (unused)
  * @sock: socket structure
  * @m: data to send
  * @total_len: total length of data to be sent
- * 
+ *
  * Used for SOCK_STREAM data.
- * 
- * Returns the number of bytes sent on success (or partial success), 
+ *
+ * Returns the number of bytes sent on success (or partial success),
  * or errno if no data sent
  */
 
@@ -616,26 +616,26 @@ static int send_stream(struct kiocb *iocb, struct socket *sock,
        int bytes_to_send;
        int bytes_sent;
        int res;
-       
+
        if (likely(total_len <= TIPC_MAX_USER_MSG_SIZE))
                return send_packet(iocb, sock, m, total_len);
 
        /* Can only send large data streams if already connected */
 
-        if (unlikely(sock->state != SS_CONNECTED)) {
-                if (sock->state == SS_DISCONNECTING)
-                        return -EPIPE;   
-                else
-                        return -ENOTCONN;
-        }
+       if (unlikely(sock->state != SS_CONNECTED)) {
+               if (sock->state == SS_DISCONNECTING)
+                       return -EPIPE;
+               else
+                       return -ENOTCONN;
+       }
 
        if (unlikely(m->msg_name))
                return -EISCONN;
 
-       /* 
+       /*
         * Send each iovec entry using one or more messages
         *
-        * Note: This algorithm is good for the most likely case 
+        * Note: This algorithm is good for the most likely case
         * (i.e. one large iovec entry), but could be improved to pass sets
         * of small iovec entries into send_packet().
         */
@@ -657,7 +657,7 @@ static int send_stream(struct kiocb *iocb, struct socket *sock,
                                ? curr_left : TIPC_MAX_USER_MSG_SIZE;
                        my_iov.iov_base = curr_start;
                        my_iov.iov_len = bytes_to_send;
-                        if ((res = send_packet(iocb, sock, &my_msg, 0)) < 0) {
+                       if ((res = send_packet(iocb, sock, &my_msg, 0)) < 0) {
                                return bytes_sent ? bytes_sent : res;
                        }
                        curr_left -= bytes_to_send;
@@ -676,11 +676,11 @@ static int send_stream(struct kiocb *iocb, struct socket *sock,
  * @sock: socket structure
  * @tsock: TIPC-specific socket structure
  * @msg: peer's response message
- * 
+ *
  * Returns 0 on success, errno otherwise
  */
 
-static int auto_connect(struct socket *sock, struct tipc_sock *tsock, 
+static int auto_connect(struct socket *sock, struct tipc_sock *tsock,
                        struct tipc_msg *msg)
 {
        struct tipc_portid peer;
@@ -702,15 +702,15 @@ static int auto_connect(struct socket *sock, struct tipc_sock *tsock,
  * set_orig_addr - capture sender's address for received message
  * @m: descriptor for message info
  * @msg: received message header
- * 
+ *
  * Note: Address is not captured if not requested by receiver.
  */
 
 static void set_orig_addr(struct msghdr *m, struct tipc_msg *msg)
 {
-        struct sockaddr_tipc *addr = (struct sockaddr_tipc *)m->msg_name;
+       struct sockaddr_tipc *addr = (struct sockaddr_tipc *)m->msg_name;
 
-        if (addr) {
+       if (addr) {
                addr->family = AF_TIPC;
                addr->addrtype = TIPC_ADDR_ID;
                addr->addr.id.ref = msg_origport(msg);
@@ -722,13 +722,13 @@ static void set_orig_addr(struct msghdr *m, struct tipc_msg *msg)
 }
 
 /**
- * anc_data_recv - optionally capture ancillary data for received message 
+ * anc_data_recv - optionally capture ancillary data for received message
  * @m: descriptor for message info
  * @msg: received message header
  * @tport: TIPC port associated with message
- * 
+ *
  * Note: Ancillary data is not captured if not requested by receiver.
- * 
+ *
  * Returns 0 if successful, otherwise errno
  */
 
@@ -753,7 +753,7 @@ static int anc_data_recv(struct msghdr *m, struct tipc_msg *msg,
                if ((res = put_cmsg(m, SOL_TIPC, TIPC_ERRINFO, 8, anc_data)))
                        return res;
                if (anc_data[1] &&
-                   (res = put_cmsg(m, SOL_TIPC, TIPC_RETDATA, anc_data[1], 
+                   (res = put_cmsg(m, SOL_TIPC, TIPC_RETDATA, anc_data[1],
                                    msg_data(msg))))
                        return res;
        }
@@ -790,13 +790,13 @@ static int anc_data_recv(struct msghdr *m, struct tipc_msg *msg,
        return 0;
 }
 
-/** 
+/**
  * recv_msg - receive packet-oriented message
  * @iocb: (unused)
  * @m: descriptor for message info
  * @buf_len: total size of user buffer area
  * @flags: receive flags
- * 
+ *
  * Used for SOCK_DGRAM, SOCK_RDM, and SOCK_SEQPACKET messages.
  * If the complete message doesn't fit in user area, truncate it.
  *
@@ -827,9 +827,9 @@ static int recv_msg(struct kiocb *iocb, struct socket *sock,
        if (sock->type == SOCK_SEQPACKET) {
                if (unlikely(sock->state == SS_UNCONNECTED))
                        return -ENOTCONN;
-               if (unlikely((sock->state == SS_DISCONNECTING) && 
+               if (unlikely((sock->state == SS_DISCONNECTING) &&
                             (skb_queue_len(&sock->sk->sk_receive_queue) == 0)))
-                       return -ENOTCONN;
+                       return -ENOTCONN;
        }
 
        /* Look for a message in receive queue; wait if necessary */
@@ -845,7 +845,7 @@ restart:
        }
 
        if ((res = wait_event_interruptible(
-               *sock->sk->sk_sleep, 
+               *sock->sk->sk_sleep,
                ((q_len = skb_queue_len(&sock->sk->sk_receive_queue)) ||
                 (sock->state == SS_DISCONNECTING))) )) {
                goto exit;
@@ -890,7 +890,7 @@ restart:
                goto exit;
 
        /* Capture message data (if valid) & compute return value (always) */
-       
+
        if (!err) {
                if (unlikely(buf_len < sz)) {
                        sz = buf_len;
@@ -913,23 +913,23 @@ restart:
        /* Consume received message (optional) */
 
        if (likely(!(flags & MSG_PEEK))) {
-                if (unlikely(++tsock->p->conn_unacked >= TIPC_FLOW_CONTROL_WIN))
-                        tipc_acknowledge(tsock->p->ref, tsock->p->conn_unacked);
+               if (unlikely(++tsock->p->conn_unacked >= TIPC_FLOW_CONTROL_WIN))
+                       tipc_acknowledge(tsock->p->ref, tsock->p->conn_unacked);
                advance_queue(tsock);
-        }
+       }
 exit:
        up(&tsock->sem);
        return res;
 }
 
-/** 
+/**
  * recv_stream - receive stream-oriented data
  * @iocb: (unused)
  * @m: descriptor for message info
  * @buf_len: total size of user buffer area
  * @flags: receive flags
- * 
- * Used for SOCK_STREAM messages only.  If not enough data is available 
+ *
+ * Used for SOCK_STREAM messages only.  If not enough data is available
  * will optionally wait for more; never truncates data.
  *
  * Returns size of returned message data, errno otherwise
@@ -980,7 +980,7 @@ restart:
        }
 
        if ((res = wait_event_interruptible(
-               *sock->sk->sk_sleep, 
+               *sock->sk->sk_sleep,
                ((q_len = skb_queue_len(&sock->sk->sk_receive_queue)) ||
                 (sock->state == SS_DISCONNECTING))) )) {
                goto exit;
@@ -1017,7 +1017,7 @@ restart:
        }
 
        /* Capture message data (if valid) & compute return value (always) */
-       
+
        if (!err) {
                buf_crs = (unsigned char *)(TIPC_SKB_CB(buf)->handle);
                sz = buf->tail - buf_crs;
@@ -1050,14 +1050,14 @@ restart:
        /* Consume received message (optional) */
 
        if (likely(!(flags & MSG_PEEK))) {
-                if (unlikely(++tsock->p->conn_unacked >= TIPC_FLOW_CONTROL_WIN))
-                        tipc_acknowledge(tsock->p->ref, tsock->p->conn_unacked);
+               if (unlikely(++tsock->p->conn_unacked >= TIPC_FLOW_CONTROL_WIN))
+                       tipc_acknowledge(tsock->p->ref, tsock->p->conn_unacked);
                advance_queue(tsock);
-        }
+       }
 
        /* Loop around if more data is required */
 
-       if ((sz_copied < buf_len)    /* didn't get all requested data */ 
+       if ((sz_copied < buf_len)    /* didn't get all requested data */
            && (flags & MSG_WAITALL) /* ... and need to wait for more */
            && (!(flags & MSG_PEEK)) /* ... and aren't just peeking at data */
            && (!err)                /* ... and haven't reached a FIN */
@@ -1074,7 +1074,7 @@ exit:
  * @queue_size: current size of queue
  * @base: nominal maximum size of queue
  * @msg: message to be added to queue
- * 
+ *
  * Returns 1 if queue is currently overloaded, 0 otherwise
  */
 
@@ -1098,7 +1098,7 @@ static int queue_overloaded(u32 queue_size, u32 base, struct tipc_msg *msg)
        return (queue_size > threshold);
 }
 
-/** 
+/**
  * async_disconnect - wrapper function used to disconnect port
  * @portref: TIPC port reference (passed as pointer-sized value)
  */
@@ -1108,13 +1108,13 @@ static void async_disconnect(unsigned long portref)
        tipc_disconnect((u32)portref);
 }
 
-/** 
+/**
  * dispatch - handle arriving message
  * @tport: TIPC port that received message
  * @buf: message
- * 
+ *
  * Called with port locked.  Must not take socket lock to avoid deadlock risk.
- * 
+ *
  * Returns TIPC error status code (TIPC_OK if message is not to be rejected)
  */
 
@@ -1159,13 +1159,13 @@ static u32 dispatch(struct tipc_port *tport, struct sk_buff *buf)
                                msg_dbg(msg, "dispatch filter 4\n");
                                return TIPC_ERR_NO_PORT;
                        }
-               } 
+               }
                else if (sock->state == SS_LISTENING) {
                        if (msg_connected(msg) || msg_errcode(msg)) {
                                msg_dbg(msg, "dispatch filter 5\n");
                                return TIPC_ERR_NO_PORT;
                        }
-               } 
+               }
                else if (sock->state == SS_DISCONNECTING) {
                        msg_dbg(msg, "dispatch filter 6\n");
                        return TIPC_ERR_NO_PORT;
@@ -1180,18 +1180,18 @@ static u32 dispatch(struct tipc_port *tport, struct sk_buff *buf)
 
        /* Reject message if there isn't room to queue it */
 
-       if (unlikely((u32)atomic_read(&tipc_queue_size) > 
+       if (unlikely((u32)atomic_read(&tipc_queue_size) >
                     OVERLOAD_LIMIT_BASE)) {
-               if (queue_overloaded(atomic_read(&tipc_queue_size), 
+               if (queue_overloaded(atomic_read(&tipc_queue_size),
                                     OVERLOAD_LIMIT_BASE, msg))
                        return TIPC_ERR_OVERLOAD;
-        }
+       }
        recv_q_len = skb_queue_len(&tsock->sk.sk_receive_queue);
        if (unlikely(recv_q_len > (OVERLOAD_LIMIT_BASE / 2))) {
-               if (queue_overloaded(recv_q_len, 
-                                    OVERLOAD_LIMIT_BASE / 2, msg)) 
+               if (queue_overloaded(recv_q_len,
+                                    OVERLOAD_LIMIT_BASE / 2, msg))
                        return TIPC_ERR_OVERLOAD;
-        }
+       }
 
        /* Initiate connection termination for an incoming 'FIN' */
 
@@ -1213,10 +1213,10 @@ static u32 dispatch(struct tipc_port *tport, struct sk_buff *buf)
        return TIPC_OK;
 }
 
-/** 
+/**
  * wakeupdispatch - wake up port after congestion
  * @tport: port to wakeup
- * 
+ *
  * Called with port lock on.
  */
 
@@ -1238,7 +1238,7 @@ static void wakeupdispatch(struct tipc_port *tport)
  * Returns 0 on success, errno otherwise
  */
 
-static int connect(struct socket *sock, struct sockaddr *dest, int destlen, 
+static int connect(struct socket *sock, struct sockaddr *dest, int destlen,
                   int flags)
 {
    struct tipc_sock *tsock = tipc_sk(sock->sk);
@@ -1260,7 +1260,7 @@ static int connect(struct socket *sock, struct sockaddr *dest, int destlen,
    if (sock->state == SS_CONNECTING)
           return -EALREADY;
    if (sock->state != SS_UNCONNECTED)
-           return -EISCONN;
+          return -EISCONN;
 
    /*
     * Reject connection attempt using multicast address
@@ -1270,7 +1270,7 @@ static int connect(struct socket *sock, struct sockaddr *dest, int destlen,
     */
 
    if (dst->addrtype == TIPC_ADDR_MCAST)
-           return -EINVAL;
+          return -EINVAL;
 
    /* Send a 'SYN-' to destination */
 
@@ -1281,19 +1281,19 @@ static int connect(struct socket *sock, struct sockaddr *dest, int destlen,
           return res;
    }
 
-   if (down_interruptible(&tsock->sem)) 
-           return -ERESTARTSYS;
-       
+   if (down_interruptible(&tsock->sem))
+          return -ERESTARTSYS;
+
    /* Wait for destination's 'ACK' response */
 
    res = wait_event_interruptible_timeout(*sock->sk->sk_sleep,
-                                          skb_queue_len(&sock->sk->sk_receive_queue),
+                                         skb_queue_len(&sock->sk->sk_receive_queue),
                                          sock->sk->sk_rcvtimeo);
    buf = skb_peek(&sock->sk->sk_receive_queue);
    if (res > 0) {
           msg = buf_msg(buf);
-           res = auto_connect(sock, tsock, msg);
-           if (!res) {
+          res = auto_connect(sock, tsock, msg);
+          if (!res) {
                   if (!msg_data_sz(msg))
                           advance_queue(tsock);
           }
@@ -1301,7 +1301,7 @@ static int connect(struct socket *sock, struct sockaddr *dest, int destlen,
           if (res == 0) {
                   res = -ETIMEDOUT;
           } else
-                  { /* leave "res" unchanged */ }
+                  { /* leave "res" unchanged */ }
           sock->state = SS_DISCONNECTING;
    }
 
@@ -1309,11 +1309,11 @@ static int connect(struct socket *sock, struct sockaddr *dest, int destlen,
    return res;
 }
 
-/** 
+/**
  * listen - allow socket to listen for incoming connections
  * @sock: socket structure
  * @len: (unused)
- * 
+ *
  * Returns 0 on success, errno otherwise
  */
 
@@ -1326,15 +1326,15 @@ static int listen(struct socket *sock, int len)
        if (sock->state != SS_UNCONNECTED)
                return -EINVAL;
        sock->state = SS_LISTENING;
-        return 0;
+       return 0;
 }
 
-/** 
+/**
  * accept - wait for connection request
  * @sock: listening socket
  * @newsock: new socket that is to be connected
  * @flags: file-related flags associated with socket
- * 
+ *
  * Returns 0 on success, errno otherwise
  */
 
@@ -1348,15 +1348,15 @@ static int accept(struct socket *sock, struct socket *newsock, int flags)
                return -EOPNOTSUPP;
        if (sock->state != SS_LISTENING)
                return -EINVAL;
-       
-       if (unlikely((skb_queue_len(&sock->sk->sk_receive_queue) == 0) && 
+
+       if (unlikely((skb_queue_len(&sock->sk->sk_receive_queue) == 0) &&
                     (flags & O_NONBLOCK)))
                return -EWOULDBLOCK;
 
        if (down_interruptible(&tsock->sem))
                return -ERESTARTSYS;
 
-       if (wait_event_interruptible(*sock->sk->sk_sleep, 
+       if (wait_event_interruptible(*sock->sk->sk_sleep,
                                     skb_queue_len(&sock->sk->sk_receive_queue))) {
                res = -ERESTARTSYS;
                goto exit;
@@ -1381,18 +1381,18 @@ static int accept(struct socket *sock, struct socket *newsock, int flags)
                        new_tsock->p->conn_instance = msg_nameinst(msg);
                }
 
-               /* 
+              /*
                 * Respond to 'SYN-' by discarding it & returning 'ACK'-.
                 * Respond to 'SYN+' by queuing it on new socket.
                 */
 
                msg_dbg(msg,"<ACC<: ");
-                if (!msg_data_sz(msg)) {
-                        struct msghdr m = {NULL,};
+               if (!msg_data_sz(msg)) {
+                       struct msghdr m = {NULL,};
 
-                        send_packet(NULL, newsock, &m, 0);
-                        advance_queue(tsock);
-                } else {
+                       send_packet(NULL, newsock, &m, 0);
+                       advance_queue(tsock);
+               } else {
                        sock_lock(tsock);
                        skb_dequeue(&sock->sk->sk_receive_queue);
                        sock_unlock(tsock);
@@ -1410,7 +1410,7 @@ exit:
  * @how: direction to close (unused; always treated as read + write)
  *
  * Terminates connection (if necessary), then purges socket's receive queue.
- * 
+ *
  * Returns 0 on success, errno otherwise
  */
 
@@ -1483,32 +1483,32 @@ restart:
  * @opt: option identifier
  * @ov: pointer to new option value
  * @ol: length of option value
- * 
- * For stream sockets only, accepts and ignores all IPPROTO_TCP options 
+ *
+ * For stream sockets only, accepts and ignores all IPPROTO_TCP options
  * (to ease compatibility).
- * 
+ *
  * Returns 0 on success, errno otherwise
  */
 
-static int setsockopt(struct socket *sock, 
+static int setsockopt(struct socket *sock,
                      int lvl, int opt, char __user *ov, int ol)
 {
        struct tipc_sock *tsock = tipc_sk(sock->sk);
        u32 value;
        int res;
 
-        if ((lvl == IPPROTO_TCP) && (sock->type == SOCK_STREAM))
-                return 0;
+       if ((lvl == IPPROTO_TCP) && (sock->type == SOCK_STREAM))
+               return 0;
        if (lvl != SOL_TIPC)
                return -ENOPROTOOPT;
        if (ol < sizeof(value))
                return -EINVAL;
-        if ((res = get_user(value, (u32 __user *)ov)))
+       if ((res = get_user(value, (u32 __user *)ov)))
                return res;
 
-       if (down_interruptible(&tsock->sem)) 
+       if (down_interruptible(&tsock->sem))
                return -ERESTARTSYS;
-       
+
        switch (opt) {
        case TIPC_IMPORTANCE:
                res = tipc_set_portimportance(tsock->p->ref, value);
@@ -1516,7 +1516,7 @@ static int setsockopt(struct socket *sock,
        case TIPC_SRC_DROPPABLE:
                if (sock->type != SOCK_STREAM)
                        res = tipc_set_portunreliable(tsock->p->ref, value);
-               else 
+               else
                        res = -ENOPROTOOPT;
                break;
        case TIPC_DEST_DROPPABLE:
@@ -1540,29 +1540,29 @@ static int setsockopt(struct socket *sock,
  * @opt: option identifier
  * @ov: receptacle for option value
  * @ol: receptacle for length of option value
- * 
- * For stream sockets only, returns 0 length result for all IPPROTO_TCP options 
+ *
+ * For stream sockets only, returns 0 length result for all IPPROTO_TCP options
  * (to ease compatibility).
- * 
+ *
  * Returns 0 on success, errno otherwise
  */
 
-static int getsockopt(struct socket *sock, 
+static int getsockopt(struct socket *sock,
                      int lvl, int opt, char __user *ov, int __user *ol)
 {
        struct tipc_sock *tsock = tipc_sk(sock->sk);
-        int len;
+       int len;
        u32 value;
-        int res;
+       int res;
 
-        if ((lvl == IPPROTO_TCP) && (sock->type == SOCK_STREAM))
-                return put_user(0, ol);
+       if ((lvl == IPPROTO_TCP) && (sock->type == SOCK_STREAM))
+               return put_user(0, ol);
        if (lvl != SOL_TIPC)
                return -ENOPROTOOPT;
-        if ((res = get_user(len, ol)))
-                return res;
+       if ((res = get_user(len, ol)))
+               return res;
 
-       if (down_interruptible(&tsock->sem)) 
+       if (down_interruptible(&tsock->sem))
                return -ERESTARTSYS;
 
        switch (opt) {
@@ -1595,30 +1595,30 @@ static int getsockopt(struct socket *sock,
                res = put_user(sizeof(value), ol);
        }
 
-        up(&tsock->sem);
+       up(&tsock->sem);
        return res;
 }
 
 /**
  * Placeholders for non-implemented functionality
- * 
+ *
  * Returns error code (POSIX-compliant where defined)
  */
 
 static int ioctl(struct socket *s, u32 cmd, unsigned long arg)
 {
-        return -EINVAL;
+       return -EINVAL;
 }
 
 static int no_mmap(struct file *file, struct socket *sock,
-                   struct vm_area_struct *vma)
+                  struct vm_area_struct *vma)
 {
-        return -EINVAL;
+       return -EINVAL;
 }
 static ssize_t no_sendpage(struct socket *sock, struct page *page,
-                           int offset, size_t size, int flags)
+                          int offset, size_t size, int flags)
 {
-        return -EINVAL;
+       return -EINVAL;
 }
 
 static int no_skpair(struct socket *s1, struct socket *s2)
@@ -1647,8 +1647,8 @@ static struct proto_ops msg_ops = {
        .getsockopt     = getsockopt,
        .sendmsg        = send_msg,
        .recvmsg        = recv_msg,
-        .mmap          = no_mmap,
-        .sendpage      = no_sendpage
+       .mmap           = no_mmap,
+       .sendpage       = no_sendpage
 };
 
 static struct proto_ops packet_ops = {
@@ -1668,8 +1668,8 @@ static struct proto_ops packet_ops = {
        .getsockopt     = getsockopt,
        .sendmsg        = send_packet,
        .recvmsg        = recv_msg,
-        .mmap          = no_mmap,
-        .sendpage      = no_sendpage
+       .mmap           = no_mmap,
+       .sendpage       = no_sendpage
 };
 
 static struct proto_ops stream_ops = {
@@ -1689,8 +1689,8 @@ static struct proto_ops stream_ops = {
        .getsockopt     = getsockopt,
        .sendmsg        = send_stream,
        .recvmsg        = recv_stream,
-        .mmap          = no_mmap,
-        .sendpage      = no_sendpage
+       .mmap           = no_mmap,
+       .sendpage       = no_sendpage
 };
 
 static struct net_proto_family tipc_family_ops = {
@@ -1707,14 +1707,14 @@ static struct proto tipc_proto = {
 
 /**
  * tipc_socket_init - initialize TIPC socket interface
- * 
+ *
  * Returns 0 on success, errno otherwise
  */
 int tipc_socket_init(void)
 {
        int res;
 
-        res = proto_register(&tipc_proto, 1);
+       res = proto_register(&tipc_proto, 1);
        if (res) {
                err("Failed to register TIPC protocol type\n");
                goto out;
index ddade7388aa065b1b3a7be8f3c70dc76d31d7283..8c01ccd3626ce6cc26a7da35d748c789e29a0053 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * net/tipc/subscr.c: TIPC subscription service
- * 
+ *
  * Copyright (c) 2000-2006, Ericsson AB
  * Copyright (c) 2005, Wind River Systems
  * All rights reserved.
  * @port_ref: object reference to port used to communicate with subscriber
  * @swap: indicates if subscriber uses opposite endianness in its messages
  */
+
 struct subscriber {
        u32 ref;
-        spinlock_t *lock;
+       spinlock_t *lock;
        struct list_head subscriber_list;
        struct list_head subscription_list;
        u32 port_ref;
@@ -82,7 +82,7 @@ static struct top_srv topsrv = { 0 };
  * htohl - convert value to endianness used by destination
  * @in: value to convert
  * @swap: non-zero if endianness must be reversed
- * 
+ *
  * Returns converted value
  */
 
@@ -97,11 +97,11 @@ static u32 htohl(u32 in, int swap)
  * subscr_send_event - send a message containing a tipc_event to the subscriber
  */
 
-static void subscr_send_event(struct subscription *sub, 
-                             u32 found_lower, 
+static void subscr_send_event(struct subscription *sub,
+                             u32 found_lower,
                              u32 found_upper,
-                             u32 event, 
-                             u32 port_ref, 
+                             u32 event,
+                             u32 port_ref,
                              u32 node)
 {
        struct iovec msg_sect;
@@ -123,8 +123,8 @@ static void subscr_send_event(struct subscription *sub,
  * Returns 1 if there is overlap, otherwise 0.
  */
 
-int tipc_subscr_overlap(struct subscription *sub, 
-                       u32 found_lower, 
+int tipc_subscr_overlap(struct subscription *sub,
+                       u32 found_lower,
                        u32 found_upper)
 
 {
@@ -139,15 +139,15 @@ int tipc_subscr_overlap(struct subscription *sub,
 
 /**
  * tipc_subscr_report_overlap - issue event if there is subscription overlap
- * 
+ *
  * Protected by nameseq.lock in name_table.c
  */
 
-void tipc_subscr_report_overlap(struct subscription *sub, 
-                               u32 found_lower, 
+void tipc_subscr_report_overlap(struct subscription *sub,
+                               u32 found_lower,
                                u32 found_upper,
-                               u32 event, 
-                               u32 port_ref, 
+                               u32 event,
+                               u32 port_ref,
                                u32 node,
                                int must)
 {
@@ -189,11 +189,11 @@ static void subscr_timeout(struct subscription *sub)
 
        /* Notify subscriber of timeout, then unlink subscription */
 
-       subscr_send_event(sub, 
-                         sub->evt.s.seq.lower, 
+       subscr_send_event(sub,
+                         sub->evt.s.seq.lower,
                          sub->evt.s.seq.upper,
-                         TIPC_SUBSCR_TIMEOUT, 
-                         0, 
+                         TIPC_SUBSCR_TIMEOUT,
+                         0,
                          0);
        list_del(&sub->subscription_list);
 
@@ -221,11 +221,11 @@ static void subscr_del(struct subscription *sub)
 
 /**
  * subscr_terminate - terminate communication with a subscriber
- * 
+ *
  * Called with subscriber locked.  Routine must temporarily release this lock
- * to enable subscription timeout routine(s) to finish without deadlocking; 
+ * to enable subscription timeout routine(s) to finish without deadlocking;
  * the lock is then reclaimed to allow caller to release it upon return.
- * (This should work even in the unlikely event some other thread creates 
+ * (This should work even in the unlikely event some other thread creates
  * a new object reference in the interim that uses this lock; this routine will
  * simply wait for it to be released, then claim it.)
  */
@@ -241,7 +241,7 @@ static void subscr_terminate(struct subscriber *subscriber)
        spin_unlock_bh(subscriber->lock);
 
        /* Destroy any existing subscriptions for subscriber */
-       
+
        list_for_each_entry_safe(sub, sub_temp, &subscriber->subscription_list,
                                 subscription_list) {
                if (sub->timeout != TIPC_WAIT_FOREVER) {
@@ -315,7 +315,7 @@ static void subscr_cancel(struct tipc_subscr *s,
 
 /**
  * subscr_subscribe - create subscription for subscriber
- * 
+ *
  * Called with subscriber locked
  */
 
@@ -431,7 +431,7 @@ static void subscr_conn_msg_event(void *usr_handle,
                subscr_terminate(subscriber);
        else
                subscr_subscribe((struct tipc_subscr *)data, subscriber);
-       
+
        spin_unlock_bh(subscriber_lock);
 }
 
@@ -444,7 +444,7 @@ static void subscr_named_msg_event(void *usr_handle,
                                   struct sk_buff **buf,
                                   const unchar *data,
                                   u32 size,
-                                  u32 importance, 
+                                  u32 importance,
                                   struct tipc_portid const *orig,
                                   struct tipc_name_seq const *dest)
 {
@@ -534,22 +534,22 @@ int tipc_subscr_start(void)
                return res;
        }
 
-       res = tipc_createport(topsrv.user_ref,
-                             NULL,
-                             TIPC_CRITICAL_IMPORTANCE,
-                             NULL,
-                             NULL,
-                             NULL,
-                             NULL,
-                             subscr_named_msg_event,
-                             NULL,
-                             NULL,
-                             &topsrv.setup_port);
-       if (res)
+       res = tipc_createport(topsrv.user_ref,
+                             NULL,
+                             TIPC_CRITICAL_IMPORTANCE,
+                             NULL,
+                             NULL,
+                             NULL,
+                             NULL,
+                             subscr_named_msg_event,
+                             NULL,
+                             NULL,
+                             &topsrv.setup_port);
+       if (res)
                goto failed;
 
-       res = tipc_nametbl_publish_rsv(topsrv.setup_port, TIPC_NODE_SCOPE, &seq);
-       if (res)
+       res = tipc_nametbl_publish_rsv(topsrv.setup_port, TIPC_NODE_SCOPE, &seq);
+       if (res)
                goto failed;
 
        spin_unlock_bh(&topsrv.lock);
@@ -571,7 +571,7 @@ void tipc_subscr_stop(void)
 
        if (topsrv.user_ref) {
                tipc_deleteport(topsrv.setup_port);
-               list_for_each_entry_safe(subscriber, subscriber_temp, 
+               list_for_each_entry_safe(subscriber, subscriber_temp,
                                         &topsrv.subscriber_list,
                                         subscriber_list) {
                        tipc_ref_lock(subscriber->ref);
index 1e5090465d2e3ba00756e37027967f916c0ee46e..93a8e674fac1dd4ccd370466156fab217f9d2f27 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * net/tipc/subscr.h: Include file for TIPC subscription service
- * 
+ *
  * Copyright (c) 2003-2006, Ericsson AB
  * Copyright (c) 2005, Wind River Systems
  * All rights reserved.
@@ -48,7 +48,7 @@
  * @timer_ref: reference to timer governing subscription duration (may be NULL)
  * @owner: pointer to subscriber object associated with this subscription
  */
+
 struct subscription {
        struct tipc_name_seq seq;
        u32 timeout;
@@ -60,15 +60,15 @@ struct subscription {
        struct subscriber *owner;
 };
 
-int tipc_subscr_overlap(struct subscription * sub, 
-                       u32 found_lower, 
+int tipc_subscr_overlap(struct subscription * sub,
+                       u32 found_lower,
                        u32 found_upper);
 
-void tipc_subscr_report_overlap(struct subscription * sub, 
-                               u32 found_lower, 
+void tipc_subscr_report_overlap(struct subscription * sub,
+                               u32 found_lower,
                                u32 found_upper,
-                               u32 event, 
-                               u32 port_ref, 
+                               u32 event,
+                               u32 port_ref,
                                u32 node,
                                int must_report);
 
index 04d1b9be9c5197ccf4ec6c9c9a401985959d50a0..4146c40cd20b444ecd71b3f2b60d2433a3689c75 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * net/tipc/user_reg.c: TIPC user registry code
- * 
+ *
  * Copyright (c) 2000-2006, Ericsson AB
  * Copyright (c) 2004-2005, Wind River Systems
  * All rights reserved.
@@ -40,7 +40,7 @@
 /*
  * TIPC user registry keeps track of users of the tipc_port interface.
  *
- * The registry utilizes an array of "TIPC user" entries; 
+ * The registry utilizes an array of "TIPC user" entries;
  * a user's ID is the index of their associated array entry.
  * Array entry 0 is not used, so userid 0 is not valid;
  * TIPC sometimes uses this value to denote an anonymous user.
@@ -51,7 +51,7 @@
  * struct tipc_user - registered TIPC user info
  * @next: index of next free registry entry (or -1 for an allocated entry)
  * @callback: ptr to routine to call when TIPC mode changes (NULL if none)
- * @usr_handle: user-defined value passed to callback routine 
+ * @usr_handle: user-defined value passed to callback routine
  * @ports: list of user ports owned by the user
  */
 
@@ -71,7 +71,7 @@ static DEFINE_SPINLOCK(reg_lock);
 
 /**
  * reg_init - create TIPC user registry (but don't activate it)
- * 
+ *
  * If registry has been pre-initialized it is left "as is".
  * NOTE: This routine may be called when TIPC is inactive.
  */
@@ -79,7 +79,7 @@ static DEFINE_SPINLOCK(reg_lock);
 static int reg_init(void)
 {
        u32 i;
-       
+
        spin_lock_bh(&reg_lock);
        if (!users) {
                users = kzalloc(USER_LIST_SIZE, GFP_ATOMIC);
@@ -137,7 +137,7 @@ int tipc_reg_start(void)
  */
 
 void tipc_reg_stop(void)
-{               
+{
        int id;
 
        if (!users)
@@ -174,14 +174,14 @@ int tipc_attach(u32 *userid, tipc_mode_event cb, void *usr_handle)
        user_ptr = &users[next_free_user];
        *userid = next_free_user;
        next_free_user = user_ptr->next;
-       user_ptr->next = -1; 
+       user_ptr->next = -1;
        spin_unlock_bh(&reg_lock);
 
        user_ptr->callback = cb;
        user_ptr->usr_handle = usr_handle;
        INIT_LIST_HEAD(&user_ptr->ports);
        atomic_inc(&tipc_user_count);
-       
+
        if (cb && (tipc_mode != TIPC_NOT_RUNNING))
                tipc_k_signal((Handler)reg_callback, (unsigned long)user_ptr);
        return TIPC_OK;
@@ -207,16 +207,16 @@ void tipc_detach(u32 userid)
        }
 
        user_ptr = &users[userid];
-        user_ptr->callback = NULL;              
+       user_ptr->callback = NULL;
        INIT_LIST_HEAD(&ports_temp);
-        list_splice(&user_ptr->ports, &ports_temp);
+       list_splice(&user_ptr->ports, &ports_temp);
        user_ptr->next = next_free_user;
        next_free_user = userid;
        spin_unlock_bh(&reg_lock);
 
        atomic_dec(&tipc_user_count);
 
-        list_for_each_entry_safe(up_ptr, temp_up_ptr, &ports_temp, uport_list) {
+       list_for_each_entry_safe(up_ptr, temp_up_ptr, &ports_temp, uport_list) {
                tipc_deleteport(up_ptr->ref);
        }
 }
index d0e88794ed1b48b938d5390027ba3fea923f3e13..81dc12e2882f02abc575fa1248fabcf3ad2c76a7 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * net/tipc/user_reg.h: Include file for TIPC user registry code
- * 
+ *
  * Copyright (c) 2000-2006, Ericsson AB
  * Copyright (c) 2005, Wind River Systems
  * All rights reserved.
index f5b00ea2d5acb2cb77d46d7ec3c2265fe3c16700..114e173f11a5fbbb6b459219984778fe44ebd2d8 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * net/tipc/zone.c: TIPC zone management routines
- * 
+ *
  * Copyright (c) 2000-2006, Ericsson AB
  * Copyright (c) 2005, Wind River Systems
  * All rights reserved.
@@ -92,7 +92,7 @@ void tipc_zone_remove_as_router(struct _zone *z_ptr, u32 router)
 
        for (c_num = 1; c_num <= tipc_max_clusters; c_num++) {
                if (z_ptr->clusters[c_num]) {
-                       tipc_cltr_remove_as_router(z_ptr->clusters[c_num], 
+                       tipc_cltr_remove_as_router(z_ptr->clusters[c_num],
                                                   router);
                }
        }
index 5ab3d08602e2528d31dc45f9cea84c656b9dbfb3..6e7a08df8af5bc1ca14b7263d7ed9a033edc3a42 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * net/tipc/zone.h: Include file for TIPC zone management routines
- * 
+ *
  * Copyright (c) 2000-2006, Ericsson AB
  * Copyright (c) 2005-2006, Wind River Systems
  * All rights reserved.
@@ -47,7 +47,7 @@
  * @clusters: array of pointers to all clusters within zone
  * @links: number of (unicast) links to zone
  */
+
 struct _zone {
        u32 addr;
        struct cluster *clusters[2]; /* currently limited to just 1 cluster */
index 2f208c7f4d435aaef980a37795052609940f608d..ac9478d0ca8b45a69c295bb2b6ffa1fdafc34847 100644 (file)
@@ -195,7 +195,7 @@ static inline void unix_release_addr(struct unix_address *addr)
  *             - if started by not zero, should be NULL terminated (FS object)
  *             - if started by zero, it is abstract name.
  */
+
 static int unix_mkname(struct sockaddr_un * sunaddr, int len, unsigned *hashp)
 {
        if (len <= sizeof(short) || len > sizeof(*sunaddr))
@@ -432,7 +432,7 @@ static int unix_release_sock (struct sock *sk, int embrion)
         */
 
        if (atomic_read(&unix_tot_inflight))
-               unix_gc();              /* Garbage collect fds */       
+               unix_gc();              /* Garbage collect fds */
 
        return 0;
 }
@@ -698,7 +698,7 @@ static struct sock *unix_find_other(struct sockaddr_un *sunname, int len,
        struct sock *u;
        struct nameidata nd;
        int err = 0;
-       
+
        if (sunname->sun_path[0]) {
                err = path_lookup(sunname->sun_path, LOOKUP_FOLLOW, &nd);
                if (err)
@@ -915,7 +915,7 @@ static int unix_dgram_connect(struct socket *sock, struct sockaddr *addr,
                unix_peer(sk)=other;
                unix_state_wunlock(sk);
        }
-       return 0;
+       return 0;
 
 out_unlock:
        unix_state_wunlock(sk);
@@ -1021,7 +1021,7 @@ restart:
                        goto out;
                sock_put(other);
                goto restart;
-        }
+       }
 
        /* Latch our state.
 
@@ -1415,7 +1415,7 @@ out:
        return err;
 }
 
-               
+
 static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock,
                               struct msghdr *msg, size_t len)
 {
@@ -1467,11 +1467,11 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock,
 
                if (size > SKB_MAX_ALLOC)
                        size = SKB_MAX_ALLOC;
-                       
+
                /*
                 *      Grab a buffer
                 */
-                
+
                skb=sock_alloc_send_skb(sk,size,msg->msg_flags&MSG_DONTWAIT, &err);
 
                if (skb==NULL)
@@ -1530,7 +1530,7 @@ static int unix_seqpacket_sendmsg(struct kiocb *kiocb, struct socket *sock,
 {
        int err;
        struct sock *sk = sock->sk;
-       
+
        err = sock_error(sk);
        if (err)
                return err;
@@ -1543,7 +1543,7 @@ static int unix_seqpacket_sendmsg(struct kiocb *kiocb, struct socket *sock,
 
        return unix_dgram_sendmsg(kiocb, sock, msg, len);
 }
-                                                                                            
+
 static void unix_copy_addr(struct msghdr *msg, struct sock *sk)
 {
        struct unix_sock *u = unix_sk(sk);
@@ -1605,7 +1605,7 @@ static int unix_dgram_recvmsg(struct kiocb *iocb, struct socket *sock,
                if (UNIXCB(skb).fp)
                        unix_detach_fds(siocb->scm, skb);
        }
-       else 
+       else
        {
                /* It is questionable: on PEEK we could:
                   - do not return fds - good, but too simple 8)
@@ -1613,11 +1613,11 @@ static int unix_dgram_recvmsg(struct kiocb *iocb, struct socket *sock,
                     apparently wrong)
                   - clone fds (I chose it for now, it is the most universal
                     solution)
-               
-                  POSIX 1003.1g does not actually define this clearly
-                  at all. POSIX 1003.1g doesn't define a lot of things
-                  clearly however!                  
-                  
+
+                  POSIX 1003.1g does not actually define this clearly
+                  at all. POSIX 1003.1g doesn't define a lot of things
+                  clearly however!
+
                */
                if (UNIXCB(skb).fp)
                        siocb->scm->fp = scm_fp_dup(UNIXCB(skb).fp);
@@ -1637,7 +1637,7 @@ out:
 /*
  *     Sleep until data has arrive. But check for races..
  */
+
 static long unix_stream_data_wait(struct sock * sk, long timeo)
 {
        DEFINE_WAIT(wait);
@@ -1721,7 +1721,7 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
                        /*
                         *      POSIX 1003.1g mandates this order.
                         */
-                        
+
                        if ((err = sock_error(sk)) != 0)
                                break;
                        if (sk->sk_shutdown & RCV_SHUTDOWN)
@@ -1937,7 +1937,7 @@ static struct sock *unix_seq_idx(int *iter, loff_t pos)
        struct sock *s;
 
        for (s = first_unix_socket(iter); s; s = next_unix_socket(iter, s)) {
-               if (off == pos) 
+               if (off == pos)
                        return s;
                ++off;
        }
@@ -1955,7 +1955,7 @@ static void *unix_seq_next(struct seq_file *seq, void *v, loff_t *pos)
 {
        ++*pos;
 
-       if (v == (void *)1) 
+       if (v == (void *)1)
                return first_unix_socket(seq->private);
        return next_unix_socket(seq->private, v);
 }
@@ -1967,7 +1967,7 @@ static void unix_seq_stop(struct seq_file *seq, void *v)
 
 static int unix_seq_show(struct seq_file *seq, void *v)
 {
-       
+
        if (v == (void *)1)
                seq_puts(seq, "Num       RefCount Protocol Flags    Type St "
                         "Inode Path\n");
@@ -2064,8 +2064,8 @@ static int __init af_unix_init(void)
        BUILD_BUG_ON(sizeof(struct unix_skb_parms) > sizeof(dummy_skb->cb));
 
        rc = proto_register(&unix_proto, 1);
-        if (rc != 0) {
-                printk(KERN_CRIT "%s: Cannot create unix_sock SLAB cache!\n",
+       if (rc != 0) {
+               printk(KERN_CRIT "%s: Cannot create unix_sock SLAB cache!\n",
                       __FUNCTION__);
                goto out;
        }
index f14ad6635fccf15a324831a1d094ed6d529cd8cb..f8bcf5d114d9738ba86e84d58fde8d84ffba708e 100644 (file)
@@ -63,7 +63,7 @@
  *             Damn. Added missing check for ->dead in listen queues scanning.
  *
  */
+
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/string.h>
@@ -118,7 +118,7 @@ static struct sock *unix_get_socket(struct file *filp)
  *     Keep the number of times in flight count for the file
  *     descriptor if it is for an AF_UNIX socket.
  */
+
 void unix_inflight(struct file *fp)
 {
        struct sock *s = unix_get_socket(fp);
@@ -190,7 +190,7 @@ void unix_gc(void)
                unix_sk(s)->gc_tree = GC_ORPHAN;
        }
        /*
-        *      Everything is now marked 
+        *      Everything is now marked
         */
 
        /* Invariant to be maintained:
@@ -227,7 +227,7 @@ void unix_gc(void)
        }
 
        /*
-        *      Mark phase 
+        *      Mark phase
         */
 
        while (!empty_stack())
@@ -237,11 +237,11 @@ void unix_gc(void)
 
                spin_lock(&x->sk_receive_queue.lock);
                skb = skb_peek(&x->sk_receive_queue);
-               
+
                /*
-                *      Loop through all but first born 
+                *      Loop through all but first born
                 */
-               
+
                while (skb && skb != (struct sk_buff *)&x->sk_receive_queue) {
                        /*
                         *      Do we have file descriptors ?
index c2059733e15a10700d7d90dd12308da986027a9c..41d7e32be70dcf847b07879c9b3e65906864fe95 100644 (file)
 *              2 of the License, or (at your option) any later version.
 * ============================================================================
 * Due Credit:
-*               Wanpipe socket layer is based on Packet and 
-*               the X25 socket layers. The above sockets were 
-*               used for the specific use of Sangoma Technologies 
-*               API programs. 
-*               Packet socket Authors: Ross Biro, Fred N. van Kempen and 
+*               Wanpipe socket layer is based on Packet and
+*               the X25 socket layers. The above sockets were
+*               used for the specific use of Sangoma Technologies
+*               API programs.
+*               Packet socket Authors: Ross Biro, Fred N. van Kempen and
 *                                      Alan Cox.
 *               X25 socket Author: Jonathan Naylor.
 * ============================================================================
@@ -28,7 +28,7 @@
 * Feb 29, 2000  Nenad Corbic     o Added support for PVC protocols, such as
 *                                  CHDLC, Frame Relay and HDLC API.
 * Jan 17, 2000         Nenad Corbic     o Initial version, based on AF_PACKET socket.
-*                                 X25API support only. 
+*                                 X25API support only.
 *
 ******************************************************************************/
 
        #define DBG_PRINTK(format, a...) printk(format, ## a)
 #else
        #define DBG_PRINTK(format, a...)
-#endif      
+#endif
 
 
-/* SECURE SOCKET IMPLEMENTATION 
- * 
+/* SECURE SOCKET IMPLEMENTATION
+ *
  *   TRANSMIT:
  *
  *      When the user sends a packet via send() system call
- *      the wanpipe_sendmsg() function is executed.  
- *      
+ *      the wanpipe_sendmsg() function is executed.
+ *
  *      Each packet is enqueud into sk->sk_write_queue transmit
  *      queue. When the packet is enqueued, a delayed transmit
- *      timer is triggerd which acts as a Bottom Half hander. 
+ *      timer is triggerd which acts as a Bottom Half hander.
  *
  *      wanpipe_delay_transmit() function (BH), dequeues packets
- *      from the sk->sk_write_queue transmit queue and sends it 
- *      to the deriver via dev->hard_start_xmit(skb, dev) function.  
+ *      from the sk->sk_write_queue transmit queue and sends it
+ *      to the deriver via dev->hard_start_xmit(skb, dev) function.
  *      Note, this function is actual a function pointer of if_send()
  *      routine in the wanpipe driver.
  *
  *      X25API GUARANTEED DELIVERY:
  *
- *         In order to provide 100% guaranteed packet delivery, 
- *         an atomic 'packet_sent' counter is implemented.  Counter 
- *         is incremented for each packet enqueued 
+ *         In order to provide 100% guaranteed packet delivery,
+ *         an atomic 'packet_sent' counter is implemented.  Counter
+ *         is incremented for each packet enqueued
  *         into sk->sk_write_queue.  Counter is decremented each
- *         time wanpipe_delayed_transmit() function successfuly 
+ *         time wanpipe_delayed_transmit() function successfuly
  *         passes the packet to the driver. Before each send(), a poll
  *         routine checks the sock resources The maximum value of
  *         packet sent counter is 1, thus if one packet is queued, the
  *      function, wanpipe_rcv() to queue the incoming packets
  *      into an AF_WANPIPE socket queue.  Based on wanpipe_rcv()
  *      return code, the driver knows whether the packet was
- *      successfully queued.  If the socket queue is full, 
- *      protocol flow control is used by the driver, if any, 
+ *      successfully queued.  If the socket queue is full,
+ *      protocol flow control is used by the driver, if any,
  *      to slow down the traffic until the sock queue is free.
  *
- *      Every time a packet arrives into a socket queue the 
+ *      Every time a packet arrives into a socket queue the
  *      socket wakes up processes which are waiting to receive
  *      data.
  *
  *      bit which signals the socket to kick the wanpipe driver
  *      bottom half hander when the socket queue is partialy
  *      empty. wanpipe_recvmsg() function performs this action.
- * 
+ *
  *      In case of x25api, packets will never be dropped, since
- *      flow control is available. 
- *      
- *      In case of streaming protocols like CHDLC, packets will 
- *      be dropped but the statistics will be generated. 
+ *      flow control is available.
+ *
+ *      In case of streaming protocols like CHDLC, packets will
+ *      be dropped but the statistics will be generated.
  */
 
 
@@ -170,11 +170,11 @@ struct wanpipe_opt
        struct net_device *dev; /* Bounded device */
        unsigned short lcn;     /* Binded LCN */
        unsigned char  svc;     /* 0=pvc, 1=svc */
-       unsigned char  timer;   /* flag for delayed transmit*/  
+       unsigned char  timer;   /* flag for delayed transmit*/
        struct timer_list tx_timer;
        unsigned poll_cnt;
        unsigned char force;    /* Used to force sock release */
-       atomic_t packet_sent;   
+       atomic_t packet_sent;
 };
 #endif
 
@@ -215,8 +215,8 @@ static int check_driver_busy (struct sock *);
  *
  *     Wanpipe socket bottom half handler.  This function
  *      is called by the WANPIPE device drivers to queue a
- *      incoming packet into the socket receive queue. 
- *      Once the packet is queued, all processes waiting to 
+ *      incoming packet into the socket receive queue.
+ *      Once the packet is queued, all processes waiting to
  *      read are woken up.
  *
  *      During socket bind, this function is bounded into
@@ -245,13 +245,13 @@ static int wanpipe_rcv(struct sk_buff *skb, struct net_device *dev,
        if (dev->hard_header_parse)
                sll->sll_halen = dev->hard_header_parse(skb, sll->sll_addr);
 
-       /* 
+       /*
         * WAN_PACKET_DATA : Data which should be passed up the receive queue.
-         * WAN_PACKET_ASYC : Asynchronous data like place call, which should
-         *                   be passed up the listening sock.
-         * WAN_PACKET_ERR  : Asynchronous data like clear call or restart 
-         *                   which should go into an error queue.
-         */
+        * WAN_PACKET_ASYC : Asynchronous data like place call, which should
+        *                   be passed up the listening sock.
+        * WAN_PACKET_ERR  : Asynchronous data like clear call or restart
+        *                   which should go into an error queue.
+        */
        switch (skb->pkt_type){
 
                case WAN_PACKET_DATA:
@@ -261,10 +261,10 @@ static int wanpipe_rcv(struct sk_buff *skb, struct net_device *dev,
                        break;
                case WAN_PACKET_CMD:
                        sk->sk_state = chan->state;
-                       /* Bug fix: update Mar6. 
-                         * Do not set the sock lcn number here, since
-                        * cmd is not guaranteed to be executed on the
-                         * board, thus Lcn could be wrong */
+                       /* Bug fix: update Mar6.
+                        * Do not set the sock lcn number here, since
+                        * cmd is not guaranteed to be executed on the
+                        * board, thus Lcn could be wrong */
                        sk->sk_data_ready(sk, skb->len);
                        kfree_skb(skb);
                        break;
@@ -276,7 +276,7 @@ static int wanpipe_rcv(struct sk_buff *skb, struct net_device *dev,
                        break;
                default:
                        printk(KERN_INFO "wansock: BH Illegal Packet Type Dropping\n");
-                       kfree_skb(skb); 
+                       kfree_skb(skb);
                        break;
        }
 
@@ -297,20 +297,20 @@ static int wanpipe_rcv(struct sk_buff *skb, struct net_device *dev,
  *
  *     Wanpipe LISTEN socket bottom half handler.  This function
  *      is called by the WANPIPE device drivers to queue an
- *      incoming call into the socket listening queue. 
- *      Once the packet is queued, the waiting accept() process 
+ *      incoming call into the socket listening queue.
+ *      Once the packet is queued, the waiting accept() process
  *      is woken up.
  *
  *      During socket bind, this function is bounded into
- *      WANPIPE driver private. 
- * 
+ *      WANPIPE driver private.
+ *
  *      IMPORTANT NOTE:
  *          The accept call() is waiting for an skb packet
  *          which contains a pointer to a device structure.
  *
- *          When we do a bind to a device structre, we 
- *          bind a newly created socket into "chan->sk".  Thus, 
- *          when accept receives the skb packet, it will know 
+ *          When we do a bind to a device structre, we
+ *          bind a newly created socket into "chan->sk".  Thus,
+ *          when accept receives the skb packet, it will know
  *          from which dev it came form, and in turn it will know
  *          the address of the new sock.
  *
@@ -322,31 +322,31 @@ static int wanpipe_listen_rcv (struct sk_buff *skb,  struct sock *sk)
        wanpipe_opt *wp = wp_sk(sk), *newwp;
        struct wan_sockaddr_ll *sll = (struct wan_sockaddr_ll*)skb->cb;
        struct sock *newsk;
-       struct net_device *dev; 
+       struct net_device *dev;
        sdla_t *card;
        mbox_cmd_t *mbox_ptr;
        wanpipe_common_t *chan;
 
-       /* Find a free device, if none found, all svc's are busy 
-         */
+       /* Find a free device, if none found, all svc's are busy
+        */
 
        card = (sdla_t*)wp->card;
        if (!card){
                printk(KERN_INFO "wansock: LISTEN ERROR, No Card\n");
                return -ENODEV;
        }
-       
+
        dev = wanpipe_find_free_dev(card);
        if (!dev){
                printk(KERN_INFO "wansock: LISTEN ERROR, No Free Device\n");
                return -ENODEV;
        }
 
-       chan=dev->priv; 
+       chan=dev->priv;
        chan->state = WANSOCK_CONNECTING;
 
        /* Allocate a new sock, which accept will bind
-         * and pass up to the user 
+        * and pass up to the user
         */
        if ((newsk = wanpipe_make_new(sk)) == NULL){
                release_device(dev);
@@ -354,33 +354,33 @@ static int wanpipe_listen_rcv (struct sk_buff *skb,  struct sock *sk)
        }
 
 
-       /* Initialize the new sock structure 
+       /* Initialize the new sock structure
         */
        newsk->sk_bound_dev_if = dev->ifindex;
        newwp = wp_sk(newsk);
        newwp->card = wp->card;
 
        /* Insert the sock into the main wanpipe
-         * sock list.
-         */
+        * sock list.
+        */
        atomic_inc(&wanpipe_socks_nr);
 
        /* Allocate and fill in the new Mail Box. Then
-         * bind the mail box to the sock. It will be 
-         * used by the ioctl call to read call information
-         * and to execute commands. 
-         */    
+        * bind the mail box to the sock. It will be
+        * used by the ioctl call to read call information
+        * and to execute commands.
+        */
        if ((mbox_ptr = kzalloc(sizeof(mbox_cmd_t), GFP_ATOMIC)) == NULL) {
                wanpipe_kill_sock_irq (newsk);
-               release_device(dev);            
+               release_device(dev);
                return -ENOMEM;
        }
        memcpy(mbox_ptr,skb->data,skb->len);
 
        /* Register the lcn on which incoming call came
-         * from. Thus, if we have to clear it, we know
-         * which lcn to clear
-        */ 
+        * from. Thus, if we have to clear it, we know
+        * which lcn to clear
+        */
 
        newwp->lcn = mbox_ptr->cmd.lcn;
        newwp->mbox = (void *)mbox_ptr;
@@ -416,20 +416,20 @@ static int wanpipe_listen_rcv (struct sk_buff *skb,  struct sock *sk)
 
        /* We must do this manually, since the sock_queue_rcv_skb()
         * function sets the skb->dev to NULL.  However, we use
-        * the dev field in the accept function.*/ 
-       if (atomic_read(&sk->sk_rmem_alloc) + skb->truesize >= 
+        * the dev field in the accept function.*/
+       if (atomic_read(&sk->sk_rmem_alloc) + skb->truesize >=
            (unsigned)sk->sk_rcvbuf) {
 
-               wanpipe_unlink_driver(newsk);
+               wanpipe_unlink_driver(newsk);
                wanpipe_kill_sock_irq (newsk);
                --sk->sk_ack_backlog;
                return -ENOMEM;
-       }       
+       }
 
        skb_set_owner_r(skb, sk);
        skb_queue_tail(&sk->sk_receive_queue, skb);
        sk->sk_data_ready(sk, skb->len);
-       
+
        return 0;
 }
 
@@ -474,7 +474,7 @@ static struct sock *wanpipe_make_new(struct sock *osk)
        return sk;
 }
 
-/* 
+/*
  * FIXME: wanpipe_opt has to include a sock in its definition and stop using
  * sk_protinfo, but this code is not even compilable now, so lets leave it for
  * later.
@@ -489,12 +489,12 @@ static struct proto wanpipe_proto = {
  * wanpipe_make_new
  *
  *     Allocate memory for the a new sock, and sock
- *      private data.  
- *     
+ *      private data.
+ *
  *     Increment the module use count.
- *             
- *      This function is used by wanpipe_create() and 
- *      wanpipe_make_new() functions. 
+ *
+ *      This function is used by wanpipe_create() and
+ *      wanpipe_make_new() functions.
  *
  *===========================================================*/
 
@@ -514,7 +514,7 @@ static struct sock *wanpipe_alloc_socket(void)
        wp_sk(sk) = wan_opt;
 
        /* Use timer to send data to the driver. This will act
-         * as a BH handler for sendmsg functions */
+        * as a BH handler for sendmsg functions */
        init_timer(&wan_opt->tx_timer);
        wan_opt->tx_timer.data     = (unsigned long)sk;
        wan_opt->tx_timer.function = wanpipe_delayed_transmit;
@@ -528,14 +528,14 @@ static struct sock *wanpipe_alloc_socket(void)
  * wanpipe_sendmsg
  *
  *     This function implements a sendto() system call,
- *      for AF_WANPIPE socket family. 
+ *      for AF_WANPIPE socket family.
  *      During socket bind() sk->sk_bound_dev_if is initialized
  *      to a correct network device. This number is used
  *      to find a network device to which the packet should
  *      be passed to.
  *
- *      Each packet is queued into sk->sk_write_queue and 
- *      delayed transmit bottom half handler is marked for 
+ *      Each packet is queued into sk->sk_write_queue and
+ *      delayed transmit bottom half handler is marked for
  *      execution.
  *
  *      A socket must be in WANSOCK_CONNECTED state before
@@ -554,18 +554,18 @@ static int wanpipe_sendmsg(struct kiocb *iocb, struct socket *sock,
        unsigned char *addr;
        int ifindex, err, reserve = 0;
 
-       
+
        if (!sock_flag(sk, SOCK_ZAPPED))
                return -ENETDOWN;
 
        if (sk->sk_state != WANSOCK_CONNECTED)
-               return -ENOTCONN;       
+               return -ENOTCONN;
 
-       if (msg->msg_flags & ~(MSG_DONTWAIT|MSG_CMSG_COMPAT)) 
+       if (msg->msg_flags & ~(MSG_DONTWAIT|MSG_CMSG_COMPAT))
                return(-EINVAL);
 
        /* it was <=, now one can send
-         * zero length packets */
+        * zero length packets */
        if (len < sizeof(x25api_hdr_t))
                return -EINVAL;
 
@@ -577,7 +577,7 @@ static int wanpipe_sendmsg(struct kiocb *iocb, struct socket *sock,
                addr    = NULL;
 
        }else{
-               if (msg->msg_namelen < sizeof(struct wan_sockaddr_ll)){ 
+               if (msg->msg_namelen < sizeof(struct wan_sockaddr_ll)){
                        return -EINVAL;
                }
 
@@ -592,12 +592,12 @@ static int wanpipe_sendmsg(struct kiocb *iocb, struct socket *sock,
                return -ENXIO;
        }
        dev_put(dev);
-       
+
        if (sock->type == SOCK_RAW)
                reserve = dev->hard_header_len;
 
        if (len > dev->mtu+reserve){
-               return -EMSGSIZE;
+               return -EMSGSIZE;
        }
 
        skb = sock_alloc_send_skb(sk, len + LL_RESERVED_SPACE(dev),
@@ -606,7 +606,7 @@ static int wanpipe_sendmsg(struct kiocb *iocb, struct socket *sock,
        if (skb==NULL){
                goto out_unlock;
        }
-               
+
        skb_reserve(skb, LL_RESERVED_SPACE(dev));
        skb->nh.raw = skb->data;
 
@@ -645,7 +645,7 @@ static int wanpipe_sendmsg(struct kiocb *iocb, struct socket *sock,
 
        if (!(test_and_set_bit(0, &wp->timer)))
                mod_timer(&wp->tx_timer, jiffies + 1);
-       
+
        return(len);
 
 out_free:
@@ -658,12 +658,12 @@ out_unlock:
  * wanpipe_delayed_tarnsmit
  *
  *     Transmit bottom half handler. It dequeues packets
- *      from sk->sk_write_queue and passes them to the 
- *      driver.  If the driver is busy, the packet is 
- *      re-enqueued.  
+ *      from sk->sk_write_queue and passes them to the
+ *      driver.  If the driver is busy, the packet is
+ *      re-enqueued.
  *
  *      Packet Sent counter is decremented on successful
- *      transmission. 
+ *      transmission.
  *===========================================================*/
 
 
@@ -680,17 +680,17 @@ static void wanpipe_delayed_transmit (unsigned long data)
                DBG_PRINTK(KERN_INFO "wansock: Transmit delay, no dev or card\n");
                return;
        }
-       
+
        if (sk->sk_state != WANSOCK_CONNECTED || !sock_flag(sk, SOCK_ZAPPED)) {
                clear_bit(0, &wp->timer);
                DBG_PRINTK(KERN_INFO "wansock: Tx Timer, State not CONNECTED\n");
                return;
        }
-       
+
        /* If driver is executing command, we must offload
-         * the board by not sending data. Otherwise a 
-         * pending command will never get a free buffer
-         * to execute */       
+        * the board by not sending data. Otherwise a
+        * pending command will never get a free buffer
+        * to execute */
        if (atomic_read(&card->u.x.command_busy)){
                wp->tx_timer.expires = jiffies + SLOW_BACKOFF;
                add_timer(&wp->tx_timer);
@@ -698,30 +698,30 @@ static void wanpipe_delayed_transmit (unsigned long data)
                return;
        }
 
-       
+
        if (test_and_set_bit(0,&wanpipe_tx_critical)){
                printk(KERN_INFO "WanSock: Tx timer critical %s\n",dev->name);
                wp->tx_timer.expires = jiffies + SLOW_BACKOFF;
                add_timer(&wp->tx_timer);
                return;
-       }       
-       
+       }
+
        /* Check for a packet in the fifo and send */
        if ((skb = skb_dequeue(&sk->sk_write_queue)) != NULL){
 
-               if (dev->hard_start_xmit(skb, dev) != 0){                       
+               if (dev->hard_start_xmit(skb, dev) != 0){
 
                        /* Driver failed to transmit, re-enqueue
-                         * the packet and retry again later */
+                        * the packet and retry again later */
                        skb_queue_head(&sk->sk_write_queue,skb);
                        clear_bit(0,&wanpipe_tx_critical);
                        return;
                }else{
 
                        /* Packet Sent successful. Check for more packets
-                         * if more packets, re-trigger the transmit routine 
-                         * other wise exit
-                         */
+                        * if more packets, re-trigger the transmit routine
+                        * other wise exit
+                        */
                        atomic_dec(&wp->packet_sent);
 
                        if (skb_peek(&sk->sk_write_queue) == NULL) {
@@ -741,18 +741,18 @@ static void wanpipe_delayed_transmit (unsigned long data)
 }
 
 /*============================================================
- * execute_command 
+ * execute_command
  *
  *     Execute x25api commands.  The atomic variable
  *      chan->command is used to indicate to the driver that
  *      command is pending for execution.  The acutal command
- *      structure is placed into a sock mbox structure 
+ *      structure is placed into a sock mbox structure
  *      (wp_sk(sk)->mbox).
  *
  *      The sock private structure, mbox is
  *      used as shared memory between sock and the driver.
  *      Driver uses the sock mbox to execute the command
- *      and return the result.  
+ *      and return the result.
  *
  *      For all command except PLACE CALL, the function
  *      waits for the result.  PLACE CALL can be ether
@@ -768,7 +768,7 @@ static int execute_command(struct sock *sk,  unsigned char cmd, unsigned int fla
        wanpipe_common_t *chan=NULL;
        int err=0;
        DECLARE_WAITQUEUE(wait, current);
-       
+
        dev = dev_get_by_index(sk->sk_bound_dev_if);
        if (dev == NULL){
                printk(KERN_INFO "wansock: Exec failed no dev %i\n",
@@ -793,7 +793,7 @@ static int execute_command(struct sock *sk,  unsigned char cmd, unsigned int fla
                return -EINVAL;
        }
 
-       ((mbox_cmd_t*)wp->mbox)->cmd.command = cmd;     
+       ((mbox_cmd_t*)wp->mbox)->cmd.command = cmd;
        ((mbox_cmd_t*)wp->mbox)->cmd.lcn     = wp->lcn;
        ((mbox_cmd_t*)wp->mbox)->cmd.result  = 0x7F;
 
@@ -820,12 +820,12 @@ static int execute_command(struct sock *sk,  unsigned char cmd, unsigned int fla
        }
        current->state = TASK_RUNNING;
        remove_wait_queue(sk->sk_sleep,&wait);
-       
+
        return err;
 }
 
 /*============================================================
- * wanpipe_destroy_timer 
+ * wanpipe_destroy_timer
  *
  *     Used by wanpipe_release, to delay release of
  *      the socket.
@@ -846,7 +846,7 @@ static void wanpipe_destroy_timer(unsigned long data)
 
                kfree(wp);
                wp_sk(sk) = NULL;
-               
+
                if (atomic_read(&sk->sk_refcnt) != 1) {
                        atomic_set(&sk->sk_refcnt, 1);
                        DBG_PRINTK(KERN_INFO "wansock: Error, wrong reference count: %i ! :delay.\n",
@@ -865,9 +865,9 @@ static void wanpipe_destroy_timer(unsigned long data)
 /*============================================================
  * wanpipe_unlink_driver
  *
- *     When the socket is released, this function is 
+ *     When the socket is released, this function is
  *      used to remove links that bind the sock and the
- *      driver together.  
+ *      driver together.
  *===========================================================*/
 static void wanpipe_unlink_driver (struct sock *sk)
 {
@@ -882,7 +882,7 @@ static void wanpipe_unlink_driver (struct sock *sk)
        if (!dev){
                printk(KERN_INFO "wansock: No dev on release\n");
                return;
-       }                       
+       }
        dev_put(dev);
 
        if ((chan = dev->priv) == NULL){
@@ -897,7 +897,7 @@ static void wanpipe_unlink_driver (struct sock *sk)
        chan->tx_timer=NULL;
        clear_bit(0,&chan->common_critical);
        release_device(dev);
-       
+
        return;
 }
 
@@ -931,7 +931,7 @@ static void wanpipe_link_driver(struct net_device *dev, struct sock *sk)
 /*============================================================
  * release_device
  *
- *     During sock release, clear a critical bit, which 
+ *     During sock release, clear a critical bit, which
  *      marks the device a being taken.
  *===========================================================*/
 
@@ -945,8 +945,8 @@ static void release_device(struct net_device *dev)
 /*============================================================
  * wanpipe_release
  *
- *     Close a PACKET socket. This is fairly simple. We 
- *      immediately go to 'closed' state and remove our 
+ *     Close a PACKET socket. This is fairly simple. We
+ *      immediately go to 'closed' state and remove our
  *      protocol entry in the device list.
  *===========================================================*/
 
@@ -954,7 +954,7 @@ static int wanpipe_release(struct socket *sock)
 {
        wanpipe_opt *wp;
        struct sock *sk = sock->sk;
-       
+
        if (!sk)
                return 0;
 
@@ -962,9 +962,9 @@ static int wanpipe_release(struct socket *sock)
        check_write_queue(sk);
 
        /* Kill the tx timer, if we don't kill it now, the timer
-         * will run after we kill the sock.  Timer code will 
-         * try to access the sock which has been killed and cause
-         * kernel panic */
+        * will run after we kill the sock.  Timer code will
+        * try to access the sock which has been killed and cause
+        * kernel panic */
 
        del_timer(&wp->tx_timer);
 
@@ -982,7 +982,7 @@ static int wanpipe_release(struct socket *sock)
                        DBG_PRINTK(KERN_INFO "wansock: Sending Clear Indication %i\n",
                                        sk->sk_state);
                        dev_put(dev);
-               }       
+               }
        }
 
        set_bit(1,&wanpipe_tx_critical);
@@ -992,10 +992,10 @@ static int wanpipe_release(struct socket *sock)
        clear_bit(1,&wanpipe_tx_critical);
 
 
-       
+
        release_driver(sk);
 
-       
+
        /*
         *      Now the socket is dead. No more input will appear.
         */
@@ -1040,9 +1040,9 @@ static int wanpipe_release(struct socket *sock)
 /*============================================================
  * check_write_queue
  *
- *     During sock shutdown, if the sock state is 
- *      WANSOCK_CONNECTED and there is transmit data 
- *      pending. Wait until data is released 
+ *     During sock shutdown, if the sock state is
+ *      WANSOCK_CONNECTED and there is transmit data
+ *      pending. Wait until data is released
  *      before proceeding.
  *===========================================================*/
 
@@ -1062,7 +1062,7 @@ static void check_write_queue(struct sock *sk)
 /*============================================================
  * release_driver
  *
- *     This function is called during sock shutdown, to 
+ *     This function is called during sock shutdown, to
  *      release any resources and links that bind the sock
  *      to the driver.  It also changes the state of the
  *      sock to WANSOCK_DISCONNECTED
@@ -1105,7 +1105,7 @@ static void release_driver(struct sock *sk)
  *  start_cleanup_timer
  *
  *     If new incoming call's are pending but the socket
- *      is being released, start the timer which will 
+ *      is being released, start the timer which will
  *      envoke the kill routines for pending socks.
  *===========================================================*/
 
@@ -1125,7 +1125,7 @@ static void start_cleanup_timer (struct sock *sk)
  *
  *     This is a function which performs actual killing
  *      of the sock.  It releases socket resources,
- *      and unlinks the sock from the driver. 
+ *      and unlinks the sock from the driver.
  *===========================================================*/
 
 static void wanpipe_kill_sock_timer (unsigned long data)
@@ -1139,13 +1139,13 @@ static void wanpipe_kill_sock_timer (unsigned long data)
 
        /* This function can be called from interrupt. We must use
         * appropriate locks */
-       
+
        if (test_bit(1,&wanpipe_tx_critical)){
                sk->sk_timer.expires = jiffies + 10;
                add_timer(&sk->sk_timer);
                return;
        }
-       
+
        write_lock(&wanpipe_sklist_lock);
        sk_del_node_init(sk);
        write_unlock(&wanpipe_sklist_lock);
@@ -1159,7 +1159,7 @@ static void wanpipe_kill_sock_timer (unsigned long data)
                        chan=dev->priv;
                        atomic_set(&chan->disconnect,1);
                        dev_put(dev);
-               }       
+               }
        }
 
        release_driver(sk);
@@ -1170,7 +1170,7 @@ static void wanpipe_kill_sock_timer (unsigned long data)
        skb_queue_purge(&sk->sk_receive_queue);
        skb_queue_purge(&sk->sk_write_queue);
        skb_queue_purge(&sk->sk_error_queue);
-       
+
        if (atomic_read(&sk->sk_rmem_alloc) ||
            atomic_read(&sk->sk_wmem_alloc)) {
                del_timer(&sk->sk_timer);
@@ -1205,7 +1205,7 @@ static void wanpipe_kill_sock_accept (struct sock *sk)
 
        /* This function can be called from interrupt. We must use
         * appropriate locks */
-       
+
        write_lock(&wanpipe_sklist_lock);
        sk_del_node_init(sk);
        write_unlock(&wanpipe_sklist_lock);
@@ -1282,10 +1282,10 @@ static int wanpipe_do_bind(struct sock *sk, struct net_device *dev,
                        chan=dev->priv;
                        sk->sk_state = chan->state;
 
-                       if (wp->num == htons(X25_PROT) && 
-                           sk->sk_state != WANSOCK_DISCONNECTED && 
+                       if (wp->num == htons(X25_PROT) &&
+                           sk->sk_state != WANSOCK_DISCONNECTED &&
                            sk->sk_state != WANSOCK_CONNECTING) {
-                               DBG_PRINTK(KERN_INFO 
+                               DBG_PRINTK(KERN_INFO
                                        "wansock: Binding to Device not DISCONNECTED %i\n",
                                                sk->sk_state);
                                release_device(dev);
@@ -1338,7 +1338,7 @@ static int wanpipe_bind(struct socket *sock, struct sockaddr *uaddr, int addr_le
        /*
         *      Check legality
         */
-        
+
        if (addr_len < sizeof(struct wan_sockaddr_ll)){
                printk(KERN_INFO "wansock: Address length error\n");
                return -EINVAL;
@@ -1358,12 +1358,12 @@ static int wanpipe_bind(struct socket *sock, struct sockaddr *uaddr, int addr_le
 
        if (!strcmp(sll->sll_device,"svc_listen")){
 
-               /* Bind a sock to a card structure for listening 
-                */             
-               int err=0; 
+               /* Bind a sock to a card structure for listening
+                */
+               int err=0;
 
                /* This is x25 specific area if protocol doesn't
-                 * match, return error */
+                * match, return error */
                if (sll->sll_protocol != htons(X25_PROT))
                        return -EINVAL;
 
@@ -1376,14 +1376,14 @@ static int wanpipe_bind(struct socket *sock, struct sockaddr *uaddr, int addr_le
                sk->sk_state = WANSOCK_BIND_LISTEN;
                return 0;
 
-       }else if (!strcmp(sll->sll_device,"svc_connect")){ 
+       }else if (!strcmp(sll->sll_device,"svc_connect")){
 
                /* This is x25 specific area if protocol doesn't
-                 * match, return error */
+                * match, return error */
                if (sll->sll_protocol != htons(X25_PROT))
                        return -EINVAL;
 
-               /* Find a free device 
+               /* Find a free device
                 */
                dev = wanpipe_find_free_dev(card);
                if (dev == NULL){
@@ -1392,9 +1392,9 @@ static int wanpipe_bind(struct socket *sock, struct sockaddr *uaddr, int addr_le
                        return -EINVAL;
                }
        }else{
-               /* Bind a socket to a interface name 
-                 * This is used by PVC mostly
-                 */
+               /* Bind a socket to a interface name
+                * This is used by PVC mostly
+                */
                strlcpy(name,sll->sll_device,sizeof(name));
                dev = dev_get_by_name(name);
                if (dev == NULL){
@@ -1419,8 +1419,8 @@ static int wanpipe_bind(struct socket *sock, struct sockaddr *uaddr, int addr_le
 
 /*============================================================
  * get_atomic_device
- *     
- *     Sets a bit atomically which indicates that 
+ *
+ *     Sets a bit atomically which indicates that
  *      the interface is taken. This avoids race conditions.
  *===========================================================*/
 
@@ -1436,7 +1436,7 @@ static inline int get_atomic_device(struct net_device *dev)
 
 /*============================================================
  * check_dev
- *     
+ *
  *     Check that device name belongs to a particular card.
  *===========================================================*/
 
@@ -1446,8 +1446,8 @@ static int check_dev(struct net_device *dev, sdla_t *card)
 
        for (tmp_dev = card->wandev.dev; tmp_dev;
             tmp_dev = *((struct net_device **)tmp_dev->priv)) {
-               if (tmp_dev->ifindex == dev->ifindex){ 
-                       return 0;       
+               if (tmp_dev->ifindex == dev->ifindex){
+                       return 0;
                }
        }
        return 1;
@@ -1455,7 +1455,7 @@ static int check_dev(struct net_device *dev, sdla_t *card)
 
 /*============================================================
  *  wanpipe_find_free_dev
- *     
+ *
  *     Find a free network interface. If found set atomic
  *      bit indicating that the interface is taken.
  *      X25API Specific.
@@ -1468,12 +1468,12 @@ struct net_device *wanpipe_find_free_dev(sdla_t *card)
 
        if (test_and_set_bit(0,&find_free_critical)){
                printk(KERN_INFO "CRITICAL in Find Free\n");
-       }       
+       }
 
        for (dev = card->wandev.dev; dev;
             dev = *((struct net_device **)dev->priv)) {
                chan = dev->priv;
-               if (!chan) 
+               if (!chan)
                        continue;
                if (chan->usedby == API && chan->svc){
                        if (!get_atomic_device (dev)){
@@ -1492,16 +1492,16 @@ struct net_device *wanpipe_find_free_dev(sdla_t *card)
 
 /*============================================================
  *  wanpipe_create
- *     
+ *
  *     SOCKET() System call.  It allocates a sock structure
- *      and adds the socket to the wanpipe_sk_list. 
+ *      and adds the socket to the wanpipe_sk_list.
  *      Crates AF_WANPIPE socket.
  *===========================================================*/
 
 static int wanpipe_create(struct socket *sock, int protocol)
 {
        struct sock *sk;
-       
+
        //FIXME: This checks for root user, SECURITY ?
        //if (!capable(CAP_NET_RAW))
        //      return -EPERM;
@@ -1526,7 +1526,7 @@ static int wanpipe_create(struct socket *sock, int protocol)
        sk->sk_bound_dev_if = 0;
 
        atomic_inc(&wanpipe_socks_nr);
-       
+
        /* We must disable interrupts because the ISR
         * can also change the list */
        set_bit(1,&wanpipe_tx_critical);
@@ -1541,8 +1541,8 @@ static int wanpipe_create(struct socket *sock, int protocol)
 
 /*============================================================
  *  wanpipe_recvmsg
- *     
- *     Pull a packet from our receive queue and hand it 
+ *
+ *     Pull a packet from our receive queue and hand it
  *      to the user. If necessary we block.
  *===========================================================*/
 
@@ -1570,13 +1570,13 @@ static int wanpipe_recvmsg(struct kiocb *iocb, struct socket *sock,
         *      but then it will block.
         */
 
-       if (flags & MSG_OOB){   
+       if (flags & MSG_OOB){
                skb = skb_dequeue(&sk->sk_error_queue);
        }else{
                skb=skb_recv_datagram(sk,flags,1,&err);
        }
        /*
-        *      An error occurred so return it. Because skb_recv_datagram() 
+        *      An error occurred so return it. Because skb_recv_datagram()
         *      handles the blocking we don't see and worry about blocking
         *      retries.
         */
@@ -1602,9 +1602,9 @@ static int wanpipe_recvmsg(struct kiocb *iocb, struct socket *sock,
        err = memcpy_toiovec(msg->msg_iov, skb->data, copied);
        if (err)
                goto out_free;
-       
+
        sock_recv_timestamp(msg, sk, skb);
-       
+
        if (msg->msg_name)
                memcpy(msg->msg_name, skb->cb, msg->msg_namelen);
 
@@ -1623,13 +1623,13 @@ out:
 
 /*============================================================
  *  wanpipe_wakeup_driver
- *     
+ *
  *     If socket receive buffer is full and driver cannot
  *      pass data up the sock, it sets a packet_block flag.
- *      This function check that flag and if sock receive 
- *      queue has room it kicks the driver BH handler. 
+ *      This function check that flag and if sock receive
+ *      queue has room it kicks the driver BH handler.
  *
- *     This way, driver doesn't have to poll the sock 
+ *     This way, driver doesn't have to poll the sock
  *      receive queue.
  *===========================================================*/
 
@@ -1646,8 +1646,8 @@ static void wanpipe_wakeup_driver(struct sock *sk)
 
        if ((chan = dev->priv) == NULL)
                return;
-       
-       if (atomic_read(&chan->receive_block)){  
+
+       if (atomic_read(&chan->receive_block)){
                if (atomic_read(&sk->sk_rmem_alloc) <
                    ((unsigned)sk->sk_rcvbuf * 0.9)) {
                        printk(KERN_INFO "wansock: Queuing task for wanpipe\n");
@@ -1655,13 +1655,13 @@ static void wanpipe_wakeup_driver(struct sock *sk)
                        wanpipe_queue_tq(&chan->wanpipe_task);
                        wanpipe_mark_bh();
                }
-       }       
-}      
+       }
+}
 
 /*============================================================
  *  wanpipe_getname
- *     
- *     I don't know what to do with this yet. 
+ *
+ *     I don't know what to do with this yet.
  *      User can use this function to get sock address
  *      information. Not very useful for Sangoma's purposes.
  *===========================================================*/
@@ -1687,17 +1687,17 @@ static int wanpipe_getname(struct socket *sock, struct sockaddr *uaddr,
                sll->sll_halen = 0;
        }
        *uaddr_len = sizeof(*sll);
-       
+
        dev_put(dev);
-       
+
        return 0;
 }
 
 /*============================================================
  *  wanpipe_notifier
- *     
+ *
  *     If driver turns off network interface, this function
- *      will be envoked. Currently I treate it as a 
+ *      will be envoked. Currently I treate it as a
  *      call disconnect. More thought should go into this
  *      function.
  *
@@ -1718,7 +1718,7 @@ static int wanpipe_notifier(struct notifier_block *this, unsigned long msg, void
                        continue;
                if (dev == NULL)
                        continue;
-               
+
                switch (msg) {
                case NETDEV_DOWN:
                case NETDEV_UNREGISTER:
@@ -1732,7 +1732,7 @@ static int wanpipe_notifier(struct notifier_block *this, unsigned long msg, void
 
                                if (msg == NETDEV_UNREGISTER) {
                                        printk(KERN_INFO "wansock: Unregistering Device: %s\n",
-                                                         dev->name);
+                                                         dev->name);
                                        wanpipe_unlink_driver(sk);
                                        sk->sk_bound_dev_if = 0;
                                }
@@ -1753,7 +1753,7 @@ static int wanpipe_notifier(struct notifier_block *this, unsigned long msg, void
 
 /*============================================================
  *  wanpipe_ioctl
- *     
+ *
  *     Execute a user commands, and set socket options.
  *
  * FIXME: More thought should go into this function.
@@ -1765,7 +1765,7 @@ static int wanpipe_ioctl(struct socket *sock, unsigned int cmd, unsigned long ar
        struct sock *sk = sock->sk;
        int err;
 
-       switch(cmd) 
+       switch(cmd)
        {
                case SIOCGSTAMP:
                        return sock_get_timestamp(sk, (struct timeval __user *)arg);
@@ -1778,7 +1778,7 @@ static int wanpipe_ioctl(struct socket *sock, unsigned int cmd, unsigned long ar
 
                        if (sk->sk_state == WANSOCK_CONNECTED)
                                return 0;
-                       
+
                        return 1;
 
 
@@ -1804,7 +1804,7 @@ static int wanpipe_ioctl(struct socket *sock, unsigned int cmd, unsigned long ar
                case SIOC_WANPIPE_DEBUG:
 
                        return wanpipe_debug(sk,(void*)arg);
-       
+
                case SIOC_WANPIPE_SET_NONBLOCK:
 
                        if (sk->sk_state != WANSOCK_DISCONNECTED)
@@ -1812,7 +1812,7 @@ static int wanpipe_ioctl(struct socket *sock, unsigned int cmd, unsigned long ar
 
                        sock->file->f_flags |= O_NONBLOCK;
                        return 0;
-       
+
 #ifdef CONFIG_INET
                case SIOCADDRT:
                case SIOCDELRT:
@@ -1842,7 +1842,7 @@ static int wanpipe_ioctl(struct socket *sock, unsigned int cmd, unsigned long ar
 
 /*============================================================
  *  wanpipe_debug
- *     
+ *
  *     This function will pass up information about all
  *      active sockets.
  *
@@ -1893,49 +1893,49 @@ static int wanpipe_debug (struct sock *origsk, void *arg)
 
                if (sk->sk_bound_dev_if) {
                        dev = dev_get_by_index(sk->sk_bound_dev_if);
-                       if (!dev)       
+                       if (!dev)
                                continue;
 
                        chan=dev->priv;
                        dev_put(dev);
-       
+
                        if ((err=put_user(chan->state, &dbg_data->debug[cnt].d_state)))
                                return err;
                        if ((err=put_user(chan->svc, &dbg_data->debug[cnt].svc)))
                                return err;
 
-                       if ((err=put_user(atomic_read(&chan->command), 
+                       if ((err=put_user(atomic_read(&chan->command),
                                                &dbg_data->debug[cnt].command)))
                                return err;
 
 
                        if (wp){
-                               sdla_t *card = (sdla_t*)wp->card;                       
-       
+                               sdla_t *card = (sdla_t*)wp->card;
+
                                if (card){
-                                       if ((err=put_user(atomic_read(&card->u.x.command_busy), 
+                                       if ((err=put_user(atomic_read(&card->u.x.command_busy),
                                                                &dbg_data->debug[cnt].cmd_busy)))
                                                return err;
                                }
 
-                               if ((err=put_user(wp->lcn, 
+                               if ((err=put_user(wp->lcn,
                                                  &dbg_data->debug[cnt].lcn)))
                                        return err;
-                               
+
                                if (wp->mbox) {
                                        if ((err=put_user(1, &dbg_data->debug[cnt].mbox)))
                                                return err;
                                }
                        }
 
-                       if ((err=put_user(atomic_read(&chan->receive_block), 
+                       if ((err=put_user(atomic_read(&chan->receive_block),
                                                                &dbg_data->debug[cnt].rblock)))
                                return err;
 
                        if (copy_to_user(dbg_data->debug[cnt].name, dev->name, strlen(dev->name)))
                                return -EFAULT;
                }
-       
+
                if (++cnt == MAX_NUM_DEBUG)
                        break;
        }
@@ -1944,7 +1944,7 @@ static int wanpipe_debug (struct sock *origsk, void *arg)
 
 /*============================================================
  *  get_ioctl_cmd
- *     
+ *
  *     Pass up the contents of socket MBOX to the user.
  *===========================================================*/
 
@@ -1974,7 +1974,7 @@ static int get_ioctl_cmd (struct sock *sk, void *arg)
        if ((err=put_user(mbox_ptr->cmd.result, &usr_data->hdr.result)))
                return err;
        if ((err=put_user(mbox_ptr->cmd.lcn, &usr_data->hdr.lcn)))
-               return err;     
+               return err;
 
        if (mbox_ptr->cmd.length > 0){
                if (mbox_ptr->cmd.length > X25_MAX_DATA)
@@ -1986,13 +1986,13 @@ static int get_ioctl_cmd (struct sock *sk, void *arg)
                }
        }
        return 0;
-} 
+}
 
 /*============================================================
  *  set_ioctl_cmd
- *     
+ *
  *     Before command can be execute, socket MBOX must
- *      be created, and initialized with user data.    
+ *      be created, and initialized with user data.
  *===========================================================*/
 
 static int set_ioctl_cmd (struct sock *sk, void *arg)
@@ -2008,7 +2008,7 @@ static int set_ioctl_cmd (struct sock *sk, void *arg)
                        return -ENODEV;
 
                dev_put(dev);
-               
+
                if ((mbox_ptr = kzalloc(sizeof(mbox_cmd_t), GFP_ATOMIC)) == NULL)
                        return -ENOMEM;
 
@@ -2092,12 +2092,12 @@ unsigned int wanpipe_poll(struct file * file, struct socket *sock, poll_table *w
                return mask;
        }
 
-       /* This check blocks the user process if there is   
+       /* This check blocks the user process if there is
         * a packet already queued in the socket write queue.
-         * This option is only for X25API protocol, for other
-         * protocol like chdlc enable streaming mode, 
-         * where multiple packets can be pending in the socket 
-         * transmit queue */
+        * This option is only for X25API protocol, for other
+        * protocol like chdlc enable streaming mode,
+        * where multiple packets can be pending in the socket
+        * transmit queue */
 
        if (wp_sk(sk)->num == htons(X25_PROT)) {
                if (atomic_read(&wp_sk(sk)->packet_sent))
@@ -2110,7 +2110,7 @@ unsigned int wanpipe_poll(struct file * file, struct socket *sock, poll_table *w
        }else{
                set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags);
        }
-               
+
        return mask;
 }
 
@@ -2125,8 +2125,8 @@ static int wanpipe_listen(struct socket *sock, int backlog)
 {
        struct sock *sk = sock->sk;
 
-       /* This is x25 specific area if protocol doesn't
-         * match, return error */
+       /* This is x25 specific area if protocol doesn't
+        * match, return error */
        if (wp_sk(sk)->num != htons(X25_PROT))
                return -EINVAL;
 
@@ -2163,7 +2163,7 @@ static int wanpipe_link_card (struct sock *sk)
        card->sk=sk;
        card->func=wanpipe_listen_rcv;
        sock_set_flag(sk, SOCK_ZAPPED);
+
        return 0;
 }
 
@@ -2176,7 +2176,7 @@ static int wanpipe_link_card (struct sock *sk)
 
 static void wanpipe_unlink_card (struct sock *sk)
 {
-       sdla_t *card = (sdla_t*)wp_sk(sk)->card; 
+       sdla_t *card = (sdla_t*)wp_sk(sk)->card;
 
        if (card){
                card->sk=NULL;
@@ -2202,9 +2202,9 @@ static int wanpipe_exec_cmd(struct sock *sk, int cmd, unsigned int flags)
                printk(KERN_INFO "NO MBOX PTR !!!!!\n");
                return -EINVAL;
        }
-       
+
        /* This is x25 specific area if protocol doesn't
-         * match, return error */
+        * match, return error */
        if (wp->num != htons(X25_PROT))
                return -EINVAL;
 
@@ -2217,17 +2217,17 @@ static int wanpipe_exec_cmd(struct sock *sk, int cmd, unsigned int flags)
                                err = -EHOSTDOWN;
                                break;
                        }
-                       
+
                        err = execute_command(sk,X25_ACCEPT_CALL,0);
                        if (err < 0)
                                break;
 
-                       /* Update. Mar6 2000. 
-                         * Do not set the sock lcn number here, since
-                         * it is done in wanpipe_listen_rcv(). 
-                         */ 
-                       if (sk->sk_state == WANSOCK_CONNECTED) {
-                               wp->lcn = ((mbox_cmd_t*)wp->mbox)->cmd.lcn;     
+                       /* Update. Mar6 2000.
+                        * Do not set the sock lcn number here, since
+                        * it is done in wanpipe_listen_rcv().
+                        */
+                       if (sk->sk_state == WANSOCK_CONNECTED) {
+                               wp->lcn = ((mbox_cmd_t*)wp->mbox)->cmd.lcn;
                                DBG_PRINTK(KERN_INFO "\nwansock: Accept OK %i\n",
                                        wp->lcn);
                                err = 0;
@@ -2249,15 +2249,15 @@ static int wanpipe_exec_cmd(struct sock *sk, int cmd, unsigned int flags)
 
 
                        /* Check if data buffers are pending for transmission,
-                         * if so, check whether user wants to wait until data
-                         * is transmitted, or clear a call and drop packets */
-                          
+                        * if so, check whether user wants to wait until data
+                        * is transmitted, or clear a call and drop packets */
+
                        if (atomic_read(&sk->sk_wmem_alloc) ||
                            check_driver_busy(sk)) {
-                               mbox_cmd_t *mbox = wp->mbox;
+                               mbox_cmd_t *mbox = wp->mbox;
                                if (mbox->cmd.qdm & 0x80){
                                        mbox->cmd.result = 0x35;
-                                       err = -EAGAIN;  
+                                       err = -EAGAIN;
                                        break;
                                }
                        }
@@ -2286,15 +2286,15 @@ static int wanpipe_exec_cmd(struct sock *sk, int cmd, unsigned int flags)
 
 
                        /* Check if data buffers are pending for transmission,
-                         * if so, check whether user wants to wait until data
-                         * is transmitted, or reset a call and drop packets */
-                          
+                        * if so, check whether user wants to wait until data
+                        * is transmitted, or reset a call and drop packets */
+
                        if (atomic_read(&sk->sk_wmem_alloc) ||
                            check_driver_busy(sk)) {
-                               mbox_cmd_t *mbox = wp->mbox;
+                               mbox_cmd_t *mbox = wp->mbox;
                                if (mbox->cmd.qdm & 0x80){
                                        mbox->cmd.result = 0x35;
-                                       err = -EAGAIN;  
+                                       err = -EAGAIN;
                                        break;
                                }
                        }
@@ -2316,7 +2316,7 @@ static int wanpipe_exec_cmd(struct sock *sk, int cmd, unsigned int flags)
 
                        if (sk->sk_state == WANSOCK_CONNECTED) {
 
-                               wp->lcn = ((mbox_cmd_t*)wp->mbox)->cmd.lcn;     
+                               wp->lcn = ((mbox_cmd_t*)wp->mbox)->cmd.lcn;
 
                                DBG_PRINTK(KERN_INFO "\nwansock: PLACE CALL OK %i\n",
                                        wp->lcn);
@@ -2337,7 +2337,7 @@ static int wanpipe_exec_cmd(struct sock *sk, int cmd, unsigned int flags)
 
                        break;
 
-               default: 
+               default:
                        return -EINVAL;
        }
 
@@ -2364,9 +2364,9 @@ static int check_driver_busy (struct sock *sk)
 /*======================================================================
  * wanpipe_accept
  *
- *     ACCEPT() System call.   X25API Specific function. 
- *     For each incoming call, create a new socket and 
- *      return it to the user. 
+ *     ACCEPT() System call.   X25API Specific function.
+ *     For each incoming call, create a new socket and
+ *      return it to the user.
  *=====================================================================*/
 
 static int wanpipe_accept(struct socket *sock, struct socket *newsock, int flags)
@@ -2378,10 +2378,10 @@ static int wanpipe_accept(struct socket *sock, struct socket *newsock, int flags
        int err=0;
 
        if (newsock->sk != NULL){
-               wanpipe_kill_sock_accept(newsock->sk);  
+               wanpipe_kill_sock_accept(newsock->sk);
                newsock->sk=NULL;
        }
-       
+
        if ((sk = sock->sk) == NULL)
                return -EINVAL;
 
@@ -2410,10 +2410,10 @@ static int wanpipe_accept(struct socket *sock, struct socket *newsock, int flags
        }
        current->state = TASK_RUNNING;
        remove_wait_queue(sk->sk_sleep,&wait);
-       
+
        if (err != 0)
                return err;
-       
+
        newsk = get_newsk_from_skb(skb);
        if (!newsk){
                return -EINVAL;
@@ -2431,7 +2431,7 @@ static int wanpipe_accept(struct socket *sock, struct socket *newsock, int flags
        /* Now attach up the new socket */
        sk->sk_ack_backlog--;
        newsock->sk = newsk;
-       
+
        kfree_skb(skb);
 
        DBG_PRINTK(KERN_INFO "\nwansock: ACCEPT Got LCN %i\n",
@@ -2449,16 +2449,16 @@ static int wanpipe_accept(struct socket *sock, struct socket *newsock, int flags
 struct sock * get_newsk_from_skb (struct sk_buff *skb)
 {
        struct net_device *dev = skb->dev;
-       wanpipe_common_t *chan; 
+       wanpipe_common_t *chan;
 
        if (!dev){
                return NULL;
        }
-               
+
        if ((chan = dev->priv) == NULL){
                return NULL;
        }
-               
+
        if (!chan->sk){
                return NULL;
        }
@@ -2470,7 +2470,7 @@ struct sock * get_newsk_from_skb (struct sk_buff *skb)
  *
  *     CONNECT() System Call. X25API specific function
  *     Check the state of the sock, and execute PLACE_CALL command.
- *      Connect can ether block or return without waiting for connection, 
+ *      Connect can ether block or return without waiting for connection,
  *      if specified by user.
  *=====================================================================*/
 
@@ -2492,7 +2492,7 @@ static int wanpipe_connect(struct socket *sock, struct sockaddr *uaddr, int addr
                return -ECONNREFUSED;
        }
 
-       sk->sk_state = WANSOCK_DISCONNECTED;    
+       sk->sk_state = WANSOCK_DISCONNECTED;
        sock->state  = SS_UNCONNECTED;
 
        if (addr_len != sizeof(struct wan_sockaddr_ll))
@@ -2505,7 +2505,7 @@ static int wanpipe_connect(struct socket *sock, struct sockaddr *uaddr, int addr
                return -ENETUNREACH;
 
        dev_put(dev);
-       
+
        if (!sock_flag(sk, SOCK_ZAPPED)) /* Must bind first - autobinding does not work */
                return -EINVAL;
 
@@ -2534,7 +2534,7 @@ static int wanpipe_connect(struct socket *sock, struct sockaddr *uaddr, int addr
 
        if (sk->sk_state != WANSOCK_CONNECTED) {
                sock->state = SS_UNCONNECTED;
-               return -ECONNREFUSED; 
+               return -ECONNREFUSED;
        }
 
        sock->state = SS_CONNECTED;
@@ -2549,10 +2549,10 @@ const struct proto_ops wanpipe_ops = {
        .connect =      wanpipe_connect,
        .socketpair =   sock_no_socketpair,
        .accept =       wanpipe_accept,
-       .getname =      wanpipe_getname, 
+       .getname =      wanpipe_getname,
        .poll =         wanpipe_poll,
        .ioctl =        wanpipe_ioctl,
-       .listen =       wanpipe_listen, 
+       .listen =       wanpipe_listen,
        .shutdown =     sock_no_shutdown,
        .setsockopt =   sock_no_setsockopt,
        .getsockopt =   sock_no_getsockopt,
index 769cdd62c1bbab511af3c675433e2af191174840..5d2d93dc083727348c26f26746bf8fc15c2e7e9c 100644 (file)
@@ -86,8 +86,8 @@ static int wanrouter_device_del_if(struct wan_device *wandev,
 
 static struct wan_device *wanrouter_find_device(char *name);
 static int wanrouter_delete_interface(struct wan_device *wandev, char *name);
-void lock_adapter_irq(spinlock_t *lock, unsigned long *smp_flags);
-void unlock_adapter_irq(spinlock_t *lock, unsigned long *smp_flags);
+static void lock_adapter_irq(spinlock_t *lock, unsigned long *smp_flags);
+static void unlock_adapter_irq(spinlock_t *lock, unsigned long *smp_flags);
 
 
 
@@ -104,8 +104,8 @@ struct wan_device* wanrouter_router_devlist; /* list of registered devices */
  *     Organize Unique Identifiers for encapsulation/decapsulation
  */
 
-static unsigned char wanrouter_oui_ether[] = { 0x00, 0x00, 0x00 };
 #if 0
+static unsigned char wanrouter_oui_ether[] = { 0x00, 0x00, 0x00 };
 static unsigned char wanrouter_oui_802_2[] = { 0x00, 0x80, 0xC2 };
 #endif
 
@@ -246,6 +246,8 @@ int unregister_wan_device(char *name)
        return 0;
 }
 
+#if 0
+
 /*
  *     Encapsulate packet.
  *
@@ -312,10 +314,10 @@ __be16 wanrouter_type_trans(struct sk_buff *skb, struct net_device *dev)
                cnt += 1;
                break;
 
-        case NLPID_SNAP:       /* SNAP encapsulation */
+       case NLPID_SNAP:        /* SNAP encapsulation */
                if (memcmp(&skb->data[cnt + 1], wanrouter_oui_ether,
                           sizeof(wanrouter_oui_ether))){
-                       printk(KERN_INFO
+                       printk(KERN_INFO
                                "%s: unsupported SNAP OUI %02X-%02X-%02X "
                                "on interface %s!\n", wanrouter_modname,
                                skb->data[cnt+1], skb->data[cnt+2],
@@ -341,6 +343,7 @@ __be16 wanrouter_type_trans(struct sk_buff *skb, struct net_device *dev)
        return ethertype;
 }
 
+#endif  /*  0  */
 
 /*
  *     WAN device IOCTL.
@@ -447,7 +450,7 @@ static int wanrouter_device_setup(struct wan_device *wandev,
                kfree(conf);
                printk(KERN_INFO "%s: ERROR, Invalid MAGIC Number\n",
                                wandev->name);
-               return -EINVAL;
+               return -EINVAL;
        }
 
        if (conf->data_size && conf->data) {
@@ -456,13 +459,13 @@ static int wanrouter_device_setup(struct wan_device *wandev,
                            "%s: ERROR, Invalid firmware data size %i !\n",
                                        wandev->name, conf->data_size);
                        kfree(conf);
-                       return -EINVAL;
+                       return -EINVAL;
                }
 
                data = vmalloc(conf->data_size);
                if (!data) {
                        printk(KERN_INFO
-                               "%s: ERROR, Faild allocate kernel memory !\n",
+                               "%s: ERROR, Faild allocate kernel memory !\n",
                                wandev->name);
                        kfree(conf);
                        return -ENOBUFS;
@@ -683,7 +686,7 @@ out:
 static int wanrouter_device_del_if(struct wan_device *wandev, char __user *u_name)
 {
        char name[WAN_IFNAME_SZ + 1];
-        int err = 0;
+       int err = 0;
 
        if (wandev->state == WAN_UNCONFIGURED)
                return -ENODEV;
@@ -706,8 +709,8 @@ static int wanrouter_device_del_if(struct wan_device *wandev, char __user *u_nam
         * interfaces are deleted and the link irrecoverably disconnected.
         */
 
-        if (!wandev->ndev && wandev->shutdown)
-                err = wandev->shutdown(wandev);
+       if (!wandev->ndev && wandev->shutdown)
+               err = wandev->shutdown(wandev);
 
        return err;
 }
@@ -799,23 +802,19 @@ static int wanrouter_delete_interface(struct wan_device *wandev, char *name)
        return 0;
 }
 
-void lock_adapter_irq(spinlock_t *lock, unsigned long *smp_flags)
+static void lock_adapter_irq(spinlock_t *lock, unsigned long *smp_flags)
 {
-               spin_lock_irqsave(lock, *smp_flags);
+       spin_lock_irqsave(lock, *smp_flags);
 }
 
 
-void unlock_adapter_irq(spinlock_t *lock, unsigned long *smp_flags)
+static void unlock_adapter_irq(spinlock_t *lock, unsigned long *smp_flags)
 {
        spin_unlock_irqrestore(lock, *smp_flags);
 }
 
 EXPORT_SYMBOL(register_wan_device);
 EXPORT_SYMBOL(unregister_wan_device);
-EXPORT_SYMBOL(wanrouter_encapsulate);
-EXPORT_SYMBOL(wanrouter_type_trans);
-EXPORT_SYMBOL(lock_adapter_irq);
-EXPORT_SYMBOL(unlock_adapter_irq);
 
 MODULE_LICENSE("GPL");
 
index 930ea59463ad2888890a5c45b6f8aea9e6d24d67..abce828736049252e2c454f81b9f30ec21b0e1cf 100644 (file)
 
 #define PROT_DECODE(prot) ((prot == WANCONFIG_FR) ? " FR" :\
                              (prot == WANCONFIG_X25) ? " X25" : \
-                                (prot == WANCONFIG_PPP) ? " PPP" : \
+                                (prot == WANCONFIG_PPP) ? " PPP" : \
                                    (prot == WANCONFIG_CHDLC) ? " CHDLC": \
                                       (prot == WANCONFIG_MPPP) ? " MPPP" : \
-                                          " Unknown" )
+                                          " Unknown" )
 
 /****** Function Prototypes *************************************************/
 
index 587a71aa411d30075549c5dde1ff52819d95eadc..a2c34ab6f194f44ce5ca2bf51c077579adda1caa 100644 (file)
@@ -6,5 +6,5 @@ obj-$(CONFIG_X25) += x25.o
 
 x25-y                  := af_x25.o x25_dev.o x25_facilities.o x25_in.o \
                           x25_link.o x25_out.o x25_route.o x25_subr.o \
-                          x25_timer.o x25_proc.o
+                          x25_timer.o x25_proc.o x25_forward.o
 x25-$(CONFIG_SYSCTL)   += sysctl_net_x25.o
index b5c80b18990224439e512fb819a96e75fb909b97..e62ba41b05c59b06e8889440f079ccbd9f19344b 100644 (file)
@@ -3,7 +3,7 @@
  *
  *     This is ALPHA test software. This code may break your machine,
  *     randomly fail to work with new releases, misbehave and/or generally
- *     screw up. It might even work. 
+ *     screw up. It might even work.
  *
  *     This code REQUIRES 2.1.15 or higher
  *
  *     X.25 002        Jonathan Naylor Centralised disconnect handling.
  *                                     New timer architecture.
  *     2000-03-11      Henner Eisen    MSG_EOR handling more POSIX compliant.
- *     2000-03-22      Daniela Squassoni Allowed disabling/enabling of 
- *                                       facilities negotiation and increased 
+ *     2000-03-22      Daniela Squassoni Allowed disabling/enabling of
+ *                                       facilities negotiation and increased
  *                                       the throughput upper limit.
  *     2000-08-27      Arnaldo C. Melo s/suser/capable/ + micro cleanups
- *     2000-09-04      Henner Eisen    Set sock->state in x25_accept(). 
+ *     2000-09-04      Henner Eisen    Set sock->state in x25_accept().
  *                                     Fixed x25_output() related skb leakage.
  *     2000-10-02      Henner Eisen    Made x25_kick() single threaded per socket.
  *     2000-10-27      Henner Eisen    MSG_DONTWAIT for fragment allocation.
@@ -63,6 +63,7 @@ int sysctl_x25_call_request_timeout    = X25_DEFAULT_T21;
 int sysctl_x25_reset_request_timeout   = X25_DEFAULT_T22;
 int sysctl_x25_clear_request_timeout   = X25_DEFAULT_T23;
 int sysctl_x25_ack_holdback_timeout    = X25_DEFAULT_T2;
+int sysctl_x25_forward                 = 0;
 
 HLIST_HEAD(x25_list);
 DEFINE_RWLOCK(x25_list_lock);
@@ -255,8 +256,8 @@ static struct sock *x25_find_listener(struct x25_address *addr,
                         * call user data vs this sockets call user data
                         */
                        if(skb->len > 0 && x25_sk(s)->cudmatchlength > 0) {
-                               if((memcmp(x25_sk(s)->calluserdata.cuddata,
-                                       skb->data,
+                               if((memcmp(x25_sk(s)->calluserdata.cuddata,
+                                       skb->data,
                                        x25_sk(s)->cudmatchlength)) == 0) {
                                        sock_hold(s);
                                        goto found;
@@ -420,7 +421,7 @@ static int x25_getsockopt(struct socket *sock, int level, int optname,
 {
        struct sock *sk = sock->sk;
        int val, len, rc = -ENOPROTOOPT;
-       
+
        if (level != SOL_X25 || optname != X25_QBITINCL)
                goto out;
 
@@ -433,7 +434,7 @@ static int x25_getsockopt(struct socket *sock, int level, int optname,
        rc = -EINVAL;
        if (len < 0)
                goto out;
-               
+
        rc = -EFAULT;
        if (put_user(len, optlen))
                goto out;
@@ -522,12 +523,12 @@ static int x25_create(struct socket *sock, int protocol)
        x25->facilities.pacsize_out = X25_DEFAULT_PACKET_SIZE;
        x25->facilities.throughput  = X25_DEFAULT_THROUGHPUT;
        x25->facilities.reverse     = X25_DEFAULT_REVERSE;
-       x25->dte_facilities.calling_len = 0;
-       x25->dte_facilities.called_len = 0;
-       memset(x25->dte_facilities.called_ae, '\0',
-                       sizeof(x25->dte_facilities.called_ae));
-       memset(x25->dte_facilities.calling_ae, '\0',
-                       sizeof(x25->dte_facilities.calling_ae));
+       x25->dte_facilities.calling_len = 0;
+       x25->dte_facilities.called_len = 0;
+       memset(x25->dte_facilities.called_ae, '\0',
+                       sizeof(x25->dte_facilities.called_ae));
+       memset(x25->dte_facilities.calling_ae, '\0',
+                       sizeof(x25->dte_facilities.calling_ae));
 
        rc = 0;
 out:
@@ -607,7 +608,7 @@ static int x25_release(struct socket *sock)
                        break;
        }
 
-       sock->sk        = NULL; 
+       sock->sk        = NULL;
        sk->sk_socket   = NULL; /* Not used, but we should do this */
 out:
        return 0;
@@ -634,7 +635,7 @@ static int x25_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
 static int x25_wait_for_connection_establishment(struct sock *sk)
 {
        DECLARE_WAITQUEUE(wait, current);
-        int rc;
+       int rc;
 
        add_wait_queue_exclusive(sk->sk_sleep, &wait);
        for (;;) {
@@ -685,7 +686,7 @@ static int x25_connect(struct socket *sock, struct sockaddr *uaddr,
        if (sk->sk_state == TCP_ESTABLISHED)
                goto out;
 
-       sk->sk_state   = TCP_CLOSE;     
+       sk->sk_state   = TCP_CLOSE;
        sock->state = SS_UNCONNECTED;
 
        rc = -EINVAL;
@@ -777,7 +778,7 @@ static int x25_wait_for_data(struct sock *sk, long timeout)
        remove_wait_queue(sk->sk_sleep, &wait);
        return rc;
 }
-       
+
 static int x25_accept(struct socket *sock, struct socket *newsock, int flags)
 {
        struct sock *sk = sock->sk;
@@ -836,7 +837,7 @@ static int x25_getname(struct socket *sock, struct sockaddr *uaddr,
 
        return 0;
 }
+
 int x25_rx_call_request(struct sk_buff *skb, struct x25_neigh *nb,
                        unsigned int lci)
 {
@@ -846,7 +847,7 @@ int x25_rx_call_request(struct sk_buff *skb, struct x25_neigh *nb,
        struct x25_address source_addr, dest_addr;
        struct x25_facilities facilities;
        struct x25_dte_facilities dte_facilities;
-       int len, rc;
+       int len, addr_len, rc;
 
        /*
         *      Remove the LCI and frame type.
@@ -857,7 +858,8 @@ int x25_rx_call_request(struct sk_buff *skb, struct x25_neigh *nb,
         *      Extract the X.25 addresses and convert them to ASCII strings,
         *      and remove them.
         */
-       skb_pull(skb, x25_addr_ntoa(skb->data, &source_addr, &dest_addr));
+       addr_len = x25_addr_ntoa(skb->data, &source_addr, &dest_addr);
+       skb_pull(skb, addr_len);
 
        /*
         *      Get the length of the facilities, skip past them for the moment
@@ -873,11 +875,28 @@ int x25_rx_call_request(struct sk_buff *skb, struct x25_neigh *nb,
        sk = x25_find_listener(&source_addr,skb);
        skb_push(skb,len);
 
+       if (sk != NULL && sk_acceptq_is_full(sk)) {
+               goto out_sock_put;
+       }
+
        /*
-        *      We can't accept the Call Request.
+        *      We dont have any listeners for this incoming call.
+        *      Try forwarding it.
         */
-       if (sk == NULL || sk_acceptq_is_full(sk))
-               goto out_clear_request;
+       if (sk == NULL) {
+               skb_push(skb, addr_len + X25_STD_MIN_LEN);
+               if (sysctl_x25_forward &&
+                               x25_forward_call(&dest_addr, nb, skb, lci) > 0)
+               {
+                       /* Call was forwarded, dont process it any more */
+                       kfree_skb(skb);
+                       rc = 1;
+                       goto out;
+               } else {
+                       /* No listeners, can't forward, clear the call */
+                       goto out_clear_request;
+               }
+       }
 
        /*
         *      Try to reach a compromise on the requested facilities.
@@ -1101,7 +1120,7 @@ static int x25_sendmsg(struct kiocb *iocb, struct socket *sock,
        if (msg->msg_flags & MSG_OOB)
                skb_queue_tail(&x25->interrupt_out_queue, skb);
        else {
-               len = x25_output(sk, skb);
+               len = x25_output(sk, skb);
                if (len < 0)
                        kfree_skb(skb);
                else if (x25->qbitincl)
@@ -1200,7 +1219,7 @@ static int x25_recvmsg(struct kiocb *iocb, struct socket *sock,
                msg->msg_flags |= MSG_TRUNC;
        }
 
-       /* Currently, each datagram always contains a complete record */ 
+       /* Currently, each datagram always contains a complete record */
        msg->msg_flags |= MSG_EOR;
 
        rc = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);
@@ -1258,8 +1277,8 @@ static int x25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
                case SIOCGSTAMP:
                        rc = -EINVAL;
                        if (sk)
-                               rc = sock_get_timestamp(sk, 
-                                               (struct timeval __user *)argp); 
+                               rc = sock_get_timestamp(sk,
+                                               (struct timeval __user *)argp);
                        break;
                case SIOCGIFADDR:
                case SIOCSIFADDR:
@@ -1327,17 +1346,17 @@ static int x25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
                }
 
                case SIOCX25GDTEFACILITIES: {
-                       rc = copy_to_user(argp, &x25->dte_facilities,
+                       rc = copy_to_user(argp, &x25->dte_facilities,
                                                sizeof(x25->dte_facilities));
                        if (rc)
                                rc = -EFAULT;
-                       break;
-               }
+                       break;
+               }
 
-               case SIOCX25SDTEFACILITIES: {
-                       struct x25_dte_facilities dtefacs;
-                       rc = -EFAULT;
-                       if (copy_from_user(&dtefacs, argp, sizeof(dtefacs)))
+               case SIOCX25SDTEFACILITIES: {
+                       struct x25_dte_facilities dtefacs;
+                       rc = -EFAULT;
+                       if (copy_from_user(&dtefacs, argp, sizeof(dtefacs)))
                                break;
                        rc = -EINVAL;
                        if (sk->sk_state != TCP_LISTEN &&
@@ -1395,7 +1414,7 @@ static int x25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
                        if (copy_from_user(&sub_addr, argp,
                                        sizeof(sub_addr)))
                                break;
-                       rc = -EINVAL;
+                       rc = -EINVAL;
                        if(sub_addr.cudmatchlength > X25_MAX_CUD_LEN)
                                break;
                        x25->cudmatchlength = sub_addr.cudmatchlength;
@@ -1424,7 +1443,7 @@ static int x25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
                        break;
                }
 
-               default:
+               default:
                        rc = -ENOIOCTLCMD;
                        break;
        }
@@ -1598,6 +1617,9 @@ void x25_kill_by_neigh(struct x25_neigh *nb)
                        x25_disconnect(s, ENETUNREACH, 0, 0);
 
        write_unlock_bh(&x25_list_lock);
+
+       /* Remove any related forwards */
+       x25_clear_forward_by_dev(nb->dev);
 }
 
 static int __init x25_init(void)
index aabda59c824e795409f5dec97f5fe9ff78b8ea87..5f631061c229457e93981ded6809683c474af17e 100644 (file)
@@ -18,7 +18,7 @@ static int max_timer[] = { 300 * HZ };
 static struct ctl_table_header *x25_table_header;
 
 static struct ctl_table x25_table[] = {
-        {
+       {
                .ctl_name =     NET_X25_RESTART_REQUEST_TIMEOUT,
                .procname =     "restart_request_timeout",
                .data =         &sysctl_x25_restart_request_timeout,
@@ -29,7 +29,7 @@ static struct ctl_table x25_table[] = {
                .extra1 =       &min_timer,
                .extra2 =       &max_timer,
        },
-        {
+       {
                .ctl_name =     NET_X25_CALL_REQUEST_TIMEOUT,
                .procname =     "call_request_timeout",
                .data =         &sysctl_x25_call_request_timeout,
@@ -40,7 +40,7 @@ static struct ctl_table x25_table[] = {
                .extra1 =       &min_timer,
                .extra2 =       &max_timer,
        },
-        {
+       {
                .ctl_name =     NET_X25_RESET_REQUEST_TIMEOUT,
                .procname =     "reset_request_timeout",
                .data =         &sysctl_x25_reset_request_timeout,
@@ -51,7 +51,7 @@ static struct ctl_table x25_table[] = {
                .extra1 =       &min_timer,
                .extra2 =       &max_timer,
        },
-        {
+       {
                .ctl_name =     NET_X25_CLEAR_REQUEST_TIMEOUT,
                .procname =     "clear_request_timeout",
                .data =         &sysctl_x25_clear_request_timeout,
@@ -62,7 +62,7 @@ static struct ctl_table x25_table[] = {
                .extra1 =       &min_timer,
                .extra2 =       &max_timer,
        },
-        {
+       {
                .ctl_name =     NET_X25_ACK_HOLD_BACK_TIMEOUT,
                .procname =     "acknowledgement_hold_back_timeout",
                .data =         &sysctl_x25_ack_holdback_timeout,
@@ -73,6 +73,14 @@ static struct ctl_table x25_table[] = {
                .extra1 =       &min_timer,
                .extra2 =       &max_timer,
        },
+       {
+               .ctl_name =     NET_X25_FORWARD,
+               .procname =     "x25_forward",
+               .data =         &sysctl_x25_forward,
+               .maxlen =       sizeof(int),
+               .mode =         0644,
+               .proc_handler = &proc_dointvec,
+       },
        { 0, },
 };
 
index 328d80f000ad67dbc6162b6fb97c542621e1f2d6..c7221de98a9529cff4d11ac141ccc00eb7da9bcc 100644 (file)
@@ -1,8 +1,8 @@
 /*
  *     X.25 Packet Layer release 002
  *
- *     This is ALPHA test software. This code may break your machine, randomly fail to work with new 
- *     releases, misbehave and/or generally screw up. It might even work. 
+ *     This is ALPHA test software. This code may break your machine, randomly fail to work with new
+ *     releases, misbehave and/or generally screw up. It might even work.
  *
  *     This code REQUIRES 2.1.15 or higher
  *
@@ -31,7 +31,7 @@ static int x25_receive_data(struct sk_buff *skb, struct x25_neigh *nb)
        unsigned int lci;
 
        frametype = skb->data[2];
-        lci = ((skb->data[0] << 8) & 0xF00) + ((skb->data[1] << 0) & 0x0FF);
+       lci = ((skb->data[0] << 8) & 0xF00) + ((skb->data[1] << 0) & 0x0FF);
 
        /*
         *      LCI of zero is always for us, and its always a link control
@@ -67,9 +67,18 @@ static int x25_receive_data(struct sk_buff *skb, struct x25_neigh *nb)
                return x25_rx_call_request(skb, nb, lci);
 
        /*
-        *      Its not a Call Request, nor is it a control frame.
-        *      Let caller throw it away.
+        *      Its not a Call Request, nor is it a control frame.
+        *      Can we forward it?
         */
+
+       if (x25_forward_data(lci, nb, skb)) {
+               if (frametype == X25_CLEAR_CONFIRMATION) {
+                       x25_clear_forward_by_lci(lci);
+               }
+               kfree_skb(skb);
+               return 1;
+       }
+
 /*
        x25_transmit_clear_request(nb, lci, 0x0D);
 */
index 27f5cc7966f691414b26bdce5c228e6e940f512b..dec404afa11333830ac69330ce2d6ef4a7fa357a 100644 (file)
@@ -3,7 +3,7 @@
  *
  *     This is ALPHA test software. This code may break your machine,
  *     randomly fail to work with new releases, misbehave and/or generally
- *     screw up. It might even work. 
+ *     screw up. It might even work.
  *
  *     This code REQUIRES 2.1.15 or higher
  *
@@ -15,7 +15,7 @@
  *
  *     History
  *     X.25 001        Split from x25_subr.c
- *     mar/20/00       Daniela Squassoni Disabling/enabling of facilities 
+ *     mar/20/00       Daniela Squassoni Disabling/enabling of facilities
  *                                       negotiation.
  *     apr/14/05       Shaun Pereira - Allow fast select with no restriction
  *                                     on response.
@@ -125,8 +125,8 @@ int x25_parse_facilities(struct sk_buff *skb, struct x25_facilities *facilities,
                        break;
                case X25_FAC_CLASS_D:
                        switch (*p) {
-                       case X25_FAC_CALLING_AE:
-                               if (p[1] > X25_MAX_DTE_FACIL_LEN)
+                       case X25_FAC_CALLING_AE:
+                               if (p[1] > X25_MAX_DTE_FACIL_LEN)
                                        break;
                                dte_facs->calling_len = p[2];
                                memcpy(dte_facs->calling_ae, &p[3], p[1] - 1);
@@ -293,7 +293,7 @@ int x25_negotiate_facilities(struct sk_buff *skb, struct sock *sk,
 }
 
 /*
- *     Limit values of certain facilities according to the capability of the 
+ *     Limit values of certain facilities according to the capability of the
  *      currently attached x25 link.
  */
 void x25_limit_facilities(struct x25_facilities *facilities,
diff --git a/net/x25/x25_forward.c b/net/x25/x25_forward.c
new file mode 100644 (file)
index 0000000..d339e0c
--- /dev/null
@@ -0,0 +1,163 @@
+/*
+ *     This module:
+ *             This module is free software; you can redistribute it and/or
+ *             modify it under the terms of the GNU General Public License
+ *             as published by the Free Software Foundation; either version
+ *             2 of the License, or (at your option) any later version.
+ *
+ *     History
+ *     03-01-2007      Added forwarding for x.25       Andrew Hendry
+ */
+#include <linux/if_arp.h>
+#include <linux/init.h>
+#include <net/x25.h>
+
+struct list_head x25_forward_list = LIST_HEAD_INIT(x25_forward_list);
+DEFINE_RWLOCK(x25_forward_list_lock);
+
+int x25_forward_call(struct x25_address *dest_addr, struct x25_neigh *from,
+                       struct sk_buff *skb, int lci)
+{
+       struct x25_route *rt;
+       struct x25_neigh *neigh_new = NULL;
+       struct list_head *entry;
+       struct x25_forward *x25_frwd, *new_frwd;
+       struct sk_buff *skbn;
+       short same_lci = 0;
+       int rc = 0;
+
+       if ((rt = x25_get_route(dest_addr)) != NULL) {
+
+               if ((neigh_new = x25_get_neigh(rt->dev)) == NULL) {
+                       /* This shouldnt happen, if it occurs somehow
+                        * do something sensible
+                        */
+                       goto out_put_route;
+               }
+
+               /* Avoid a loop. This is the normal exit path for a
+                * system with only one x.25 iface and default route
+                */
+               if (rt->dev == from->dev) {
+                       goto out_put_nb;
+               }
+
+               /* Remote end sending a call request on an already
+                * established LCI? It shouldnt happen, just in case..
+                */
+               read_lock_bh(&x25_forward_list_lock);
+               list_for_each(entry, &x25_forward_list) {
+                       x25_frwd = list_entry(entry, struct x25_forward, node);
+                       if (x25_frwd->lci == lci) {
+                               printk(KERN_WARNING "X.25: call request for lci which is already registered!, transmitting but not registering new pair\n");
+                               same_lci = 1;
+                       }
+               }
+               read_unlock_bh(&x25_forward_list_lock);
+
+               /* Save the forwarding details for future traffic */
+               if (!same_lci){
+                       if ((new_frwd = kmalloc(sizeof(struct x25_forward),
+                                                       GFP_ATOMIC)) == NULL){
+                               rc = -ENOMEM;
+                               goto out_put_nb;
+                       }
+                       new_frwd->lci = lci;
+                       new_frwd->dev1 = rt->dev;
+                       new_frwd->dev2 = from->dev;
+                       write_lock_bh(&x25_forward_list_lock);
+                       list_add(&new_frwd->node, &x25_forward_list);
+                       write_unlock_bh(&x25_forward_list_lock);
+               }
+
+               /* Forward the call request */
+               if ( (skbn = skb_clone(skb, GFP_ATOMIC)) == NULL){
+                       goto out_put_nb;
+               }
+               x25_transmit_link(skbn, neigh_new);
+               rc = 1;
+       }
+
+
+out_put_nb:
+       x25_neigh_put(neigh_new);
+
+out_put_route:
+       x25_route_put(rt);
+       return rc;
+}
+
+
+int x25_forward_data(int lci, struct x25_neigh *from, struct sk_buff *skb) {
+
+       struct x25_forward *frwd;
+       struct list_head *entry;
+       struct net_device *peer = NULL;
+       struct x25_neigh *nb;
+       struct sk_buff *skbn;
+       int rc = 0;
+
+       read_lock_bh(&x25_forward_list_lock);
+       list_for_each(entry, &x25_forward_list) {
+               frwd = list_entry(entry, struct x25_forward, node);
+               if (frwd->lci == lci) {
+                       /* The call is established, either side can send */
+                       if (from->dev == frwd->dev1) {
+                               peer = frwd->dev2;
+                       } else {
+                               peer = frwd->dev1;
+                       }
+                       break;
+               }
+       }
+       read_unlock_bh(&x25_forward_list_lock);
+
+       if ( (nb = x25_get_neigh(peer)) == NULL)
+               goto out;
+
+       if ( (skbn = pskb_copy(skb, GFP_ATOMIC)) == NULL){
+               goto out;
+
+       }
+       x25_transmit_link(skbn, nb);
+
+       x25_neigh_put(nb);
+       rc = 1;
+out:
+       return rc;
+}
+
+void x25_clear_forward_by_lci(unsigned int lci)
+{
+       struct x25_forward *fwd;
+       struct list_head *entry, *tmp;
+
+       write_lock_bh(&x25_forward_list_lock);
+
+       list_for_each_safe(entry, tmp, &x25_forward_list) {
+               fwd = list_entry(entry, struct x25_forward, node);
+               if (fwd->lci == lci) {
+                       list_del(&fwd->node);
+                       kfree(fwd);
+               }
+       }
+       write_unlock_bh(&x25_forward_list_lock);
+}
+
+
+void x25_clear_forward_by_dev(struct net_device *dev)
+{
+       struct x25_forward *fwd;
+       struct list_head *entry, *tmp;
+
+       write_lock_bh(&x25_forward_list_lock);
+
+       list_for_each_safe(entry, tmp, &x25_forward_list) {
+               fwd = list_entry(entry, struct x25_forward, node);
+               if ((fwd->dev1 == dev) || (fwd->dev2 == dev)){
+                       list_del(&fwd->node);
+                       kfree(fwd);
+               }
+       }
+       write_unlock_bh(&x25_forward_list_lock);
+}
index eed50e10f09be6f93d1f3cce4febfba0400714c0..c5239fcdefa0c6b155364ad70e7a11c3423982ec 100644 (file)
@@ -3,7 +3,7 @@
  *
  *     This is ALPHA test software. This code may break your machine,
  *     randomly fail to work with new releases, misbehave and/or generally
- *     screw up. It might even work. 
+ *     screw up. It might even work.
  *
  *     This code REQUIRES 2.1.15 or higher
  *
@@ -17,7 +17,7 @@
  *     X.25 001        Jonathan Naylor   Started coding.
  *     X.25 002        Jonathan Naylor   Centralised disconnection code.
  *                                       New timer architecture.
- *     2000-03-20      Daniela Squassoni Disabling/enabling of facilities 
+ *     2000-03-20      Daniela Squassoni Disabling/enabling of facilities
  *                                       negotiation.
  *     2000-11-10      Henner Eisen      Check and reset for out-of-sequence
  *                                       i-frames.
@@ -67,7 +67,7 @@ static int x25_queue_rx_frame(struct sock *sk, struct sk_buff *skb, int more)
                        kfree_skb(skbo);
                }
 
-               x25->fraglen = 0;               
+               x25->fraglen = 0;
        }
 
        skb_set_owner_r(skbn, sk);
@@ -167,7 +167,7 @@ static int x25_state3_machine(struct sock *sk, struct sk_buff *skb, int frametyp
        int queued = 0;
        int modulus;
        struct x25_sock *x25 = x25_sk(sk);
-       
+
        modulus = (x25->neighbour->extended) ? X25_EMODULUS : X25_SMODULUS;
 
        switch (frametype) {
index 0a760fe66843fa128858aa67c1959b4b39bb0f46..741ce95d4ad156b65f12a5693776a20a60d91d03 100644 (file)
@@ -3,7 +3,7 @@
  *
  *     This is ALPHA test software. This code may break your machine,
  *     randomly fail to work with new releases, misbehave and/or generally
- *     screw up. It might even work. 
+ *     screw up. It might even work.
  *
  *     This code REQUIRES 2.1.15 or higher
  *
@@ -16,7 +16,7 @@
  *     History
  *     X.25 001        Jonathan Naylor   Started coding.
  *     X.25 002        Jonathan Naylor   New timer architecture.
- *     mar/20/00       Daniela Squassoni Disabling/enabling of facilities 
+ *     mar/20/00       Daniela Squassoni Disabling/enabling of facilities
  *                                       negotiation.
  *     2000-09-04      Henner Eisen      dev_hold() / dev_put() for x25_neigh.
  */
@@ -94,7 +94,7 @@ void x25_link_control(struct sk_buff *skb, struct x25_neigh *nb,
                               skb->data[3], skb->data[4],
                               skb->data[5], skb->data[6]);
                        break;
-                       
+
                default:
                        printk(KERN_WARNING "x25: received unknown %02X "
                               "with LCI 000\n", frametype);
index a2e62cea819a05547816e113bb8b3d2de6a0ac4f..6f5737853912a9d66185979195d725629e53a873 100644 (file)
@@ -3,7 +3,7 @@
  *
  *     This is ALPHA test software. This code may break your machine,
  *     randomly fail to work with new releases, misbehave and/or generally
- *     screw up. It might even work. 
+ *     screw up. It might even work.
  *
  *     This code REQUIRES 2.1.15 or higher
  *
@@ -78,7 +78,7 @@ int x25_output(struct sock *sk, struct sk_buff *skb)
                                               "sent\n", err, sent);
                                return err;
                        }
-                               
+
                        skb_reserve(skbn, frontlen);
 
                        len = max_len > skb->len ? skb->len : max_len;
@@ -101,7 +101,7 @@ int x25_output(struct sock *sk, struct sk_buff *skb)
                        skb_queue_tail(&sk->sk_write_queue, skbn);
                        sent += len;
                }
-               
+
                kfree_skb(skb);
        } else {
                skb_queue_tail(&sk->sk_write_queue, skb);
@@ -110,7 +110,7 @@ int x25_output(struct sock *sk, struct sk_buff *skb)
        return sent;
 }
 
-/* 
+/*
  *     This procedure is passed a buffer descriptor for an iframe. It builds
  *     the rest of the control part of the frame and then writes it out.
  */
@@ -131,7 +131,7 @@ static void x25_send_iframe(struct sock *sk, struct sk_buff *skb)
                skb->data[2] |= (x25->vr << 5) & 0xE0;
        }
 
-       x25_transmit_link(skb, x25->neighbour); 
+       x25_transmit_link(skb, x25->neighbour);
 }
 
 void x25_kick(struct sock *sk)
index a11837d361d2dd7582794be5c56ef4ce744b031e..3c9f1ba56221c3e0067ea8d4105ca257a2af4ed3 100644 (file)
@@ -3,7 +3,7 @@
  *
  *     This is ALPHA test software. This code may break your machine,
  *     randomly fail to work with new releases, misbehave and/or generally
- *     screw up. It might even work. 
+ *     screw up. It might even work.
  *
  *     This code REQUIRES 2.4 with seq_file support
  *
@@ -62,7 +62,7 @@ static void *x25_seq_route_next(struct seq_file *seq, void *v, loff_t *pos)
        rt = v;
        if (rt->node.next != &x25_route_list)
                rt = list_entry(rt->node.next, struct x25_route, node);
-       else 
+       else
                rt = NULL;
 out:
        return rt;
@@ -88,7 +88,7 @@ static int x25_seq_route_show(struct seq_file *seq, void *v)
                   rt->dev ? rt->dev->name : "???");
 out:
        return 0;
-} 
+}
 
 static __inline__ struct sock *x25_get_socket_idx(loff_t pos)
 {
@@ -163,7 +163,76 @@ static int x25_seq_socket_show(struct seq_file *seq, void *v)
                   s->sk_socket ? SOCK_INODE(s->sk_socket)->i_ino : 0L);
 out:
        return 0;
-} 
+}
+
+static __inline__ struct x25_forward *x25_get_forward_idx(loff_t pos)
+{
+       struct x25_forward *f;
+       struct list_head *entry;
+
+       list_for_each(entry, &x25_forward_list) {
+               f = list_entry(entry, struct x25_forward, node);
+               if (!pos--)
+                       goto found;
+       }
+
+       f = NULL;
+found:
+       return f;
+}
+
+static void *x25_seq_forward_start(struct seq_file *seq, loff_t *pos)
+{
+       loff_t l = *pos;
+
+       read_lock_bh(&x25_forward_list_lock);
+       return l ? x25_get_forward_idx(--l) : SEQ_START_TOKEN;
+}
+
+static void *x25_seq_forward_next(struct seq_file *seq, void *v, loff_t *pos)
+{
+       struct x25_forward *f;
+
+       ++*pos;
+       if (v == SEQ_START_TOKEN) {
+               f = NULL;
+               if (!list_empty(&x25_forward_list))
+                       f = list_entry(x25_forward_list.next,
+                                       struct x25_forward, node);
+               goto out;
+       }
+       f = v;
+       if (f->node.next != &x25_forward_list)
+               f = list_entry(f->node.next, struct x25_forward, node);
+       else
+               f = NULL;
+out:
+       return f;
+
+}
+
+static void x25_seq_forward_stop(struct seq_file *seq, void *v)
+{
+       read_unlock_bh(&x25_forward_list_lock);
+}
+
+static int x25_seq_forward_show(struct seq_file *seq, void *v)
+{
+       struct x25_forward *f;
+
+       if (v == SEQ_START_TOKEN) {
+               seq_printf(seq, "lci dev1       dev2\n");
+               goto out;
+       }
+
+       f = v;
+
+       seq_printf(seq, "%d %-10s %-10s\n",
+                       f->lci, f->dev1->name, f->dev2->name);
+
+out:
+       return 0;
+}
 
 static struct seq_operations x25_seq_route_ops = {
        .start  = x25_seq_route_start,
@@ -179,6 +248,13 @@ static struct seq_operations x25_seq_socket_ops = {
        .show   = x25_seq_socket_show,
 };
 
+static struct seq_operations x25_seq_forward_ops = {
+       .start  = x25_seq_forward_start,
+       .next   = x25_seq_forward_next,
+       .stop   = x25_seq_forward_stop,
+       .show   = x25_seq_forward_show,
+};
+
 static int x25_seq_socket_open(struct inode *inode, struct file *file)
 {
        return seq_open(file, &x25_seq_socket_ops);
@@ -189,6 +265,11 @@ static int x25_seq_route_open(struct inode *inode, struct file *file)
        return seq_open(file, &x25_seq_route_ops);
 }
 
+static int x25_seq_forward_open(struct inode *inode, struct file *file)
+{
+       return seq_open(file, &x25_seq_forward_ops);
+}
+
 static struct file_operations x25_seq_socket_fops = {
        .owner          = THIS_MODULE,
        .open           = x25_seq_socket_open,
@@ -205,6 +286,14 @@ static struct file_operations x25_seq_route_fops = {
        .release        = seq_release,
 };
 
+static struct file_operations x25_seq_forward_fops = {
+       .owner          = THIS_MODULE,
+       .open           = x25_seq_forward_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = seq_release,
+};
+
 static struct proc_dir_entry *x25_proc_dir;
 
 int __init x25_proc_init(void)
@@ -225,9 +314,17 @@ int __init x25_proc_init(void)
        if (!p)
                goto out_socket;
        p->proc_fops = &x25_seq_socket_fops;
+
+       p = create_proc_entry("forward", S_IRUGO, x25_proc_dir);
+       if (!p)
+               goto out_forward;
+       p->proc_fops = &x25_seq_forward_fops;
        rc = 0;
+
 out:
        return rc;
+out_forward:
+       remove_proc_entry("socket", x25_proc_dir);
 out_socket:
        remove_proc_entry("route", x25_proc_dir);
 out_route:
@@ -237,6 +334,7 @@ out_route:
 
 void __exit x25_proc_exit(void)
 {
+       remove_proc_entry("forward", x25_proc_dir);
        remove_proc_entry("route", x25_proc_dir);
        remove_proc_entry("socket", x25_proc_dir);
        remove_proc_entry("x25", proc_net);
index 2a3fe986b245f648f59a83bca138a72b22419482..060fcfaa2f47c3ec8465348336dd4a095546b22e 100644 (file)
@@ -3,7 +3,7 @@
  *
  *     This is ALPHA test software. This code may break your machine,
  *     randomly fail to work with new releases, misbehave and/or generally
- *     screw up. It might even work. 
+ *     screw up. It might even work.
  *
  *     This code REQUIRES 2.1.15 or higher
  *
@@ -119,6 +119,9 @@ void x25_route_device_down(struct net_device *dev)
                        __x25_remove_route(rt);
        }
        write_unlock_bh(&x25_route_list_lock);
+
+       /* Remove any related forwarding */
+       x25_clear_forward_by_dev(dev);
 }
 
 /*
index 71ff3088f6fe325cb7321df423566ce59e420b5e..2af190dc5b014ef8f544772d188c668e367f3a90 100644 (file)
@@ -3,7 +3,7 @@
  *
  *     This is ALPHA test software. This code may break your machine,
  *     randomly fail to work with new releases, misbehave and/or generally
- *     screw up. It might even work. 
+ *     screw up. It might even work.
  *
  *     This code REQUIRES 2.1.15 or higher
  *
@@ -99,8 +99,8 @@ static void x25_heartbeat_expiry(unsigned long param)
 {
        struct sock *sk = (struct sock *)param;
 
-        bh_lock_sock(sk);
-        if (sock_owned_by_user(sk)) /* can currently only occur in state 3 */ 
+       bh_lock_sock(sk);
+       if (sock_owned_by_user(sk)) /* can currently only occur in state 3 */
                goto restart_heartbeat;
 
        switch (x25_sk(sk)->state) {
index 0faab6332586a3dd7af013196e9cf998f690a3ec..577a4f821b9879d580a965092b5372b4f6cd213a 100644 (file)
@@ -24,6 +24,17 @@ config XFRM_SUB_POLICY
 
          If unsure, say N.
 
+config XFRM_MIGRATE
+       bool "Transformation migrate database (EXPERIMENTAL)"
+       depends on XFRM && EXPERIMENTAL
+       ---help---
+         A feature to update locator(s) of a given IPsec security
+         association dynamically.  This feature is required, for
+         instance, in a Mobile IPv6 environment with IPsec configuration
+         where mobile nodes change their attachment point to the Internet.
+
+         If unsure, say N.
+
 config NET_KEY
        tristate "PF_KEY sockets"
        select XFRM
@@ -34,4 +45,19 @@ config NET_KEY
 
          Say Y unless you know what you are doing.
 
+config NET_KEY_MIGRATE
+       bool "PF_KEY MIGRATE (EXPERIMENTAL)"
+       depends on NET_KEY && EXPERIMENTAL
+       select XFRM_MIGRATE
+       ---help---
+         Add a PF_KEY MIGRATE message to PF_KEYv2 socket family.
+         The PF_KEY MIGRATE message is used to dynamically update
+         locator(s) of a given IPsec security association.
+         This feature is required, for instance, in a Mobile IPv6
+         environment with IPsec configuration where mobile nodes
+         change their attachment point to the Internet.  Detail
+         information can be found in the internet-draft
+         <draft-sugimoto-mip6-pfkey-migrate>.
+
+         If unsure, say N.
 
index f1cf3402e75c9aa6c8b242674133b546d0190fad..f373a8a7d9c84830c8c95664a122370e936b97df 100644 (file)
@@ -1,11 +1,11 @@
-/* 
+/*
  * xfrm algorithm interface
  *
  * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option) 
+ * Software Foundation; either version 2 of the License, or (at your option)
  * any later version.
  */
 
@@ -32,14 +32,14 @@ static struct xfrm_algo_desc aalg_list[] = {
 {
        .name = "hmac(digest_null)",
        .compat = "digest_null",
-       
+
        .uinfo = {
                .auth = {
                        .icv_truncbits = 0,
                        .icv_fullbits = 0,
                }
        },
-       
+
        .desc = {
                .sadb_alg_id = SADB_X_AALG_NULL,
                .sadb_alg_ivlen = 0,
@@ -57,7 +57,7 @@ static struct xfrm_algo_desc aalg_list[] = {
                        .icv_fullbits = 128,
                }
        },
-       
+
        .desc = {
                .sadb_alg_id = SADB_AALG_MD5HMAC,
                .sadb_alg_ivlen = 0,
@@ -142,14 +142,14 @@ static struct xfrm_algo_desc ealg_list[] = {
 {
        .name = "ecb(cipher_null)",
        .compat = "cipher_null",
-       
+
        .uinfo = {
                .encr = {
                        .blockbits = 8,
                        .defkeybits = 0,
                }
        },
-       
+
        .desc = {
                .sadb_alg_id =  SADB_EALG_NULL,
                .sadb_alg_ivlen = 0,
@@ -248,40 +248,57 @@ static struct xfrm_algo_desc ealg_list[] = {
        }
 },
 {
-        .name = "cbc(serpent)",
-        .compat = "serpent",
-
-        .uinfo = {
-                .encr = {
-                        .blockbits = 128,
-                        .defkeybits = 128,
-                }
-        },
-
-        .desc = {
-                .sadb_alg_id = SADB_X_EALG_SERPENTCBC,
-                .sadb_alg_ivlen = 8,
-                .sadb_alg_minbits = 128,
-                .sadb_alg_maxbits = 256,
-        }
+       .name = "cbc(serpent)",
+       .compat = "serpent",
+
+       .uinfo = {
+               .encr = {
+                       .blockbits = 128,
+                       .defkeybits = 128,
+               }
+       },
+
+       .desc = {
+               .sadb_alg_id = SADB_X_EALG_SERPENTCBC,
+               .sadb_alg_ivlen = 8,
+               .sadb_alg_minbits = 128,
+               .sadb_alg_maxbits = 256,
+       }
+},
+{
+       .name = "cbc(camellia)",
+
+       .uinfo = {
+               .encr = {
+                       .blockbits = 128,
+                       .defkeybits = 128,
+               }
+       },
+
+       .desc = {
+               .sadb_alg_id = SADB_X_EALG_CAMELLIACBC,
+               .sadb_alg_ivlen = 8,
+               .sadb_alg_minbits = 128,
+               .sadb_alg_maxbits = 256
+       }
 },
 {
-        .name = "cbc(twofish)",
-        .compat = "twofish",
-                 
-        .uinfo = {
-                .encr = {
-                        .blockbits = 128,
-                        .defkeybits = 128,
-                }
-        },
-
-        .desc = {
-                .sadb_alg_id = SADB_X_EALG_TWOFISHCBC,
-                .sadb_alg_ivlen = 8,
-                .sadb_alg_minbits = 128,
-                .sadb_alg_maxbits = 256
-        }
+       .name = "cbc(twofish)",
+       .compat = "twofish",
+
+       .uinfo = {
+               .encr = {
+                       .blockbits = 128,
+                       .defkeybits = 128,
+               }
+       },
+
+       .desc = {
+               .sadb_alg_id = SADB_X_EALG_TWOFISHCBC,
+               .sadb_alg_ivlen = 8,
+               .sadb_alg_minbits = 128,
+               .sadb_alg_maxbits = 256
+       }
 },
 };
 
@@ -461,7 +478,7 @@ void xfrm_probe_algs(void)
 {
 #ifdef CONFIG_CRYPTO
        int i, status;
-       
+
        BUG_ON(in_softirq());
 
        for (i = 0; i < aalg_entries(); i++) {
@@ -470,14 +487,14 @@ void xfrm_probe_algs(void)
                if (aalg_list[i].available != status)
                        aalg_list[i].available = status;
        }
-       
+
        for (i = 0; i < ealg_entries(); i++) {
                status = crypto_has_blkcipher(ealg_list[i].name, 0,
                                              CRYPTO_ALG_ASYNC);
                if (ealg_list[i].available != status)
                        ealg_list[i].available = status;
        }
-       
+
        for (i = 0; i < calg_entries(); i++) {
                status = crypto_has_comp(calg_list[i].name, 0,
                                         CRYPTO_ALG_ASYNC);
@@ -524,15 +541,15 @@ int skb_icv_walk(const struct sk_buff *skb, struct hash_desc *desc,
        if (copy > 0) {
                if (copy > len)
                        copy = len;
-               
+
                sg.page = virt_to_page(skb->data + offset);
                sg.offset = (unsigned long)(skb->data + offset) % PAGE_SIZE;
                sg.length = copy;
-               
+
                err = icv_update(desc, &sg, copy);
                if (unlikely(err))
                        return err;
-               
+
                if ((len -= copy) == 0)
                        return 0;
                offset += copy;
@@ -549,11 +566,11 @@ int skb_icv_walk(const struct sk_buff *skb, struct hash_desc *desc,
 
                        if (copy > len)
                                copy = len;
-                       
+
                        sg.page = frag->page;
                        sg.offset = frag->page_offset + offset-start;
                        sg.length = copy;
-                       
+
                        err = icv_update(desc, &sg, copy);
                        if (unlikely(err))
                                return err;
index 414f890703802a0e2ef761df2573561f54f1b79e..ee15bdae14196d092b85ce9aa5123e5d128d0a25 100644 (file)
@@ -4,7 +4,7 @@
  * Changes:
  *     YOSHIFUJI Hideaki @USAGI
  *             Split up af-specific portion
- *     
+ *
  */
 
 #include <linux/slab.h>
index b7e537fe2d7542d95335e7a2a1fde2172a5ba0b8..a24f385107197809e954d6dc1ea9eb41f53f2161 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
  * xfrm_policy.c
  *
  * Changes:
@@ -151,7 +151,7 @@ retry:
        return type;
 }
 
-int xfrm_dst_lookup(struct xfrm_dst **dst, struct flowi *fl, 
+int xfrm_dst_lookup(struct xfrm_dst **dst, struct flowi *fl,
                    unsigned short family)
 {
        struct xfrm_policy_afinfo *afinfo = xfrm_policy_get_afinfo(family);
@@ -262,7 +262,7 @@ static inline unsigned long make_jiffies(long secs)
        if (secs >= (MAX_SCHEDULE_TIMEOUT-1)/HZ)
                return MAX_SCHEDULE_TIMEOUT-1;
        else
-               return secs*HZ;
+               return secs*HZ;
 }
 
 static void xfrm_policy_timer(unsigned long data)
@@ -1024,17 +1024,17 @@ end:
 static inline int policy_to_flow_dir(int dir)
 {
        if (XFRM_POLICY_IN == FLOW_DIR_IN &&
-           XFRM_POLICY_OUT == FLOW_DIR_OUT &&
-           XFRM_POLICY_FWD == FLOW_DIR_FWD)
-               return dir;
-       switch (dir) {
-       default:
-       case XFRM_POLICY_IN:
-               return FLOW_DIR_IN;
-       case XFRM_POLICY_OUT:
-               return FLOW_DIR_OUT;
-       case XFRM_POLICY_FWD:
-               return FLOW_DIR_FWD;
+           XFRM_POLICY_OUT == FLOW_DIR_OUT &&
+           XFRM_POLICY_FWD == FLOW_DIR_FWD)
+               return dir;
+       switch (dir) {
+       default:
+       case XFRM_POLICY_IN:
+               return FLOW_DIR_IN;
+       case XFRM_POLICY_OUT:
+               return FLOW_DIR_OUT;
+       case XFRM_POLICY_FWD:
+               return FLOW_DIR_FWD;
        };
 }
 
@@ -1044,9 +1044,9 @@ static struct xfrm_policy *xfrm_sk_policy_lookup(struct sock *sk, int dir, struc
 
        read_lock_bh(&xfrm_policy_lock);
        if ((pol = sk->sk_policy[dir]) != NULL) {
-               int match = xfrm_selector_match(&pol->selector, fl,
+               int match = xfrm_selector_match(&pol->selector, fl,
                                                sk->sk_family);
-               int err = 0;
+               int err = 0;
 
                if (match) {
                        err = security_xfrm_policy_lookup(pol, fl->secid,
@@ -1511,7 +1511,7 @@ restart:
        }
        *dst_p = dst;
        dst_release(dst_orig);
-       xfrm_pols_put(pols, npols);
+       xfrm_pols_put(pols, npols);
        return 0;
 
 error:
@@ -1546,7 +1546,7 @@ xfrm_secpath_reject(int idx, struct sk_buff *skb, struct flowi *fl)
  */
 
 static inline int
-xfrm_state_ok(struct xfrm_tmpl *tmpl, struct xfrm_state *x, 
+xfrm_state_ok(struct xfrm_tmpl *tmpl, struct xfrm_state *x,
              unsigned short family)
 {
        if (xfrm_state_kern(x))
@@ -1619,7 +1619,7 @@ static inline int secpath_has_nontransport(struct sec_path *sp, int k, int *idxp
        return 0;
 }
 
-int __xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb, 
+int __xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb,
                        unsigned short family)
 {
        struct xfrm_policy *pol;
@@ -2236,3 +2236,234 @@ void __init xfrm_init(void)
        xfrm_input_init();
 }
 
+#ifdef CONFIG_XFRM_MIGRATE
+static int xfrm_migrate_selector_match(struct xfrm_selector *sel_cmp,
+                                      struct xfrm_selector *sel_tgt)
+{
+       if (sel_cmp->proto == IPSEC_ULPROTO_ANY) {
+               if (sel_tgt->family == sel_cmp->family &&
+                   xfrm_addr_cmp(&sel_tgt->daddr, &sel_cmp->daddr,
+                                 sel_cmp->family) == 0 &&
+                   xfrm_addr_cmp(&sel_tgt->saddr, &sel_cmp->saddr,
+                                 sel_cmp->family) == 0 &&
+                   sel_tgt->prefixlen_d == sel_cmp->prefixlen_d &&
+                   sel_tgt->prefixlen_s == sel_cmp->prefixlen_s) {
+                       return 1;
+               }
+       } else {
+               if (memcmp(sel_tgt, sel_cmp, sizeof(*sel_tgt)) == 0) {
+                       return 1;
+               }
+       }
+       return 0;
+}
+
+static struct xfrm_policy * xfrm_migrate_policy_find(struct xfrm_selector *sel,
+                                                    u8 dir, u8 type)
+{
+       struct xfrm_policy *pol, *ret = NULL;
+       struct hlist_node *entry;
+       struct hlist_head *chain;
+       u32 priority = ~0U;
+
+       read_lock_bh(&xfrm_policy_lock);
+       chain = policy_hash_direct(&sel->daddr, &sel->saddr, sel->family, dir);
+       hlist_for_each_entry(pol, entry, chain, bydst) {
+               if (xfrm_migrate_selector_match(sel, &pol->selector) &&
+                   pol->type == type) {
+                       ret = pol;
+                       priority = ret->priority;
+                       break;
+               }
+       }
+       chain = &xfrm_policy_inexact[dir];
+       hlist_for_each_entry(pol, entry, chain, bydst) {
+               if (xfrm_migrate_selector_match(sel, &pol->selector) &&
+                   pol->type == type &&
+                   pol->priority < priority) {
+                       ret = pol;
+                       break;
+               }
+       }
+
+       if (ret)
+               xfrm_pol_hold(ret);
+
+       read_unlock_bh(&xfrm_policy_lock);
+
+       return ret;
+}
+
+static int migrate_tmpl_match(struct xfrm_migrate *m, struct xfrm_tmpl *t)
+{
+       int match = 0;
+
+       if (t->mode == m->mode && t->id.proto == m->proto &&
+           (m->reqid == 0 || t->reqid == m->reqid)) {
+               switch (t->mode) {
+               case XFRM_MODE_TUNNEL:
+               case XFRM_MODE_BEET:
+                       if (xfrm_addr_cmp(&t->id.daddr, &m->old_daddr,
+                                         m->old_family) == 0 &&
+                           xfrm_addr_cmp(&t->saddr, &m->old_saddr,
+                                         m->old_family) == 0) {
+                               match = 1;
+                       }
+                       break;
+               case XFRM_MODE_TRANSPORT:
+                       /* in case of transport mode, template does not store
+                          any IP addresses, hence we just compare mode and
+                          protocol */
+                       match = 1;
+                       break;
+               default:
+                       break;
+               }
+       }
+       return match;
+}
+
+/* update endpoint address(es) of template(s) */
+static int xfrm_policy_migrate(struct xfrm_policy *pol,
+                              struct xfrm_migrate *m, int num_migrate)
+{
+       struct xfrm_migrate *mp;
+       struct dst_entry *dst;
+       int i, j, n = 0;
+
+       write_lock_bh(&pol->lock);
+       if (unlikely(pol->dead)) {
+               /* target policy has been deleted */
+               write_unlock_bh(&pol->lock);
+               return -ENOENT;
+       }
+
+       for (i = 0; i < pol->xfrm_nr; i++) {
+               for (j = 0, mp = m; j < num_migrate; j++, mp++) {
+                       if (!migrate_tmpl_match(mp, &pol->xfrm_vec[i]))
+                               continue;
+                       n++;
+                       if (pol->xfrm_vec[i].mode != XFRM_MODE_TUNNEL)
+                               continue;
+                       /* update endpoints */
+                       memcpy(&pol->xfrm_vec[i].id.daddr, &mp->new_daddr,
+                              sizeof(pol->xfrm_vec[i].id.daddr));
+                       memcpy(&pol->xfrm_vec[i].saddr, &mp->new_saddr,
+                              sizeof(pol->xfrm_vec[i].saddr));
+                       pol->xfrm_vec[i].encap_family = mp->new_family;
+                       /* flush bundles */
+                       while ((dst = pol->bundles) != NULL) {
+                               pol->bundles = dst->next;
+                               dst_free(dst);
+                       }
+               }
+       }
+
+       write_unlock_bh(&pol->lock);
+
+       if (!n)
+               return -ENODATA;
+
+       return 0;
+}
+
+static int xfrm_migrate_check(struct xfrm_migrate *m, int num_migrate)
+{
+       int i, j;
+
+       if (num_migrate < 1 || num_migrate > XFRM_MAX_DEPTH)
+               return -EINVAL;
+
+       for (i = 0; i < num_migrate; i++) {
+               if ((xfrm_addr_cmp(&m[i].old_daddr, &m[i].new_daddr,
+                                  m[i].old_family) == 0) &&
+                   (xfrm_addr_cmp(&m[i].old_saddr, &m[i].new_saddr,
+                                  m[i].old_family) == 0))
+                       return -EINVAL;
+               if (xfrm_addr_any(&m[i].new_daddr, m[i].new_family) ||
+                   xfrm_addr_any(&m[i].new_saddr, m[i].new_family))
+                       return -EINVAL;
+
+               /* check if there is any duplicated entry */
+               for (j = i + 1; j < num_migrate; j++) {
+                       if (!memcmp(&m[i].old_daddr, &m[j].old_daddr,
+                                   sizeof(m[i].old_daddr)) &&
+                           !memcmp(&m[i].old_saddr, &m[j].old_saddr,
+                                   sizeof(m[i].old_saddr)) &&
+                           m[i].proto == m[j].proto &&
+                           m[i].mode == m[j].mode &&
+                           m[i].reqid == m[j].reqid &&
+                           m[i].old_family == m[j].old_family)
+                               return -EINVAL;
+               }
+       }
+
+       return 0;
+}
+
+int xfrm_migrate(struct xfrm_selector *sel, u8 dir, u8 type,
+                struct xfrm_migrate *m, int num_migrate)
+{
+       int i, err, nx_cur = 0, nx_new = 0;
+       struct xfrm_policy *pol = NULL;
+       struct xfrm_state *x, *xc;
+       struct xfrm_state *x_cur[XFRM_MAX_DEPTH];
+       struct xfrm_state *x_new[XFRM_MAX_DEPTH];
+       struct xfrm_migrate *mp;
+
+       if ((err = xfrm_migrate_check(m, num_migrate)) < 0)
+               goto out;
+
+       /* Stage 1 - find policy */
+       if ((pol = xfrm_migrate_policy_find(sel, dir, type)) == NULL) {
+               err = -ENOENT;
+               goto out;
+       }
+
+       /* Stage 2 - find and update state(s) */
+       for (i = 0, mp = m; i < num_migrate; i++, mp++) {
+               if ((x = xfrm_migrate_state_find(mp))) {
+                       x_cur[nx_cur] = x;
+                       nx_cur++;
+                       if ((xc = xfrm_state_migrate(x, mp))) {
+                               x_new[nx_new] = xc;
+                               nx_new++;
+                       } else {
+                               err = -ENODATA;
+                               goto restore_state;
+                       }
+               }
+       }
+
+       /* Stage 3 - update policy */
+       if ((err = xfrm_policy_migrate(pol, m, num_migrate)) < 0)
+               goto restore_state;
+
+       /* Stage 4 - delete old state(s) */
+       if (nx_cur) {
+               xfrm_states_put(x_cur, nx_cur);
+               xfrm_states_delete(x_cur, nx_cur);
+       }
+
+       /* Stage 5 - announce */
+       km_migrate(sel, dir, type, m, num_migrate);
+
+       xfrm_pol_put(pol);
+
+       return 0;
+out:
+       return err;
+
+restore_state:
+       if (pol)
+               xfrm_pol_put(pol);
+       if (nx_cur)
+               xfrm_states_put(x_cur, nx_cur);
+       if (nx_new)
+               xfrm_states_delete(x_new, nx_new);
+
+       return err;
+}
+EXPORT_SYMBOL(xfrm_migrate);
+#endif
+
index fdb08d9f34aa684b1180985e031e77f1de116f55..a35f9e4ede2674625b13191a9fd58736e81cbe91 100644 (file)
@@ -183,9 +183,6 @@ static DEFINE_SPINLOCK(xfrm_state_gc_lock);
 
 int __xfrm_state_delete(struct xfrm_state *x);
 
-static struct xfrm_state_afinfo *xfrm_state_get_afinfo(unsigned short family);
-static void xfrm_state_put_afinfo(struct xfrm_state_afinfo *afinfo);
-
 int km_query(struct xfrm_state *x, struct xfrm_tmpl *t, struct xfrm_policy *pol);
 void km_state_expired(struct xfrm_state *x, int hard, u32 pid);
 
@@ -230,7 +227,7 @@ static inline unsigned long make_jiffies(long secs)
        if (secs >= (MAX_SCHEDULE_TIMEOUT-1)/HZ)
                return MAX_SCHEDULE_TIMEOUT-1;
        else
-               return secs*HZ;
+               return secs*HZ;
 }
 
 static void xfrm_timer_handler(unsigned long data)
@@ -526,7 +523,7 @@ static void xfrm_hash_grow_check(int have_hash_collision)
 }
 
 struct xfrm_state *
-xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr, 
+xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr,
                struct flowi *fl, struct xfrm_tmpl *tmpl,
                struct xfrm_policy *pol, int *err,
                unsigned short family)
@@ -537,7 +534,7 @@ xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr,
        int acquire_in_progress = 0;
        int error = 0;
        struct xfrm_state *best = NULL;
-       
+
        spin_lock_bh(&xfrm_state_lock);
        hlist_for_each_entry(x, entry, xfrm_state_bydst+h, bydst) {
                if (x->props.family == family &&
@@ -573,7 +570,7 @@ xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr,
                                acquire_in_progress = 1;
                        } else if (x->km.state == XFRM_STATE_ERROR ||
                                   x->km.state == XFRM_STATE_EXPIRED) {
-                               if (xfrm_selector_match(&x->sel, fl, family) &&
+                               if (xfrm_selector_match(&x->sel, fl, family) &&
                                    security_xfrm_state_pol_flow_match(x, pol, fl))
                                        error = -ESRCH;
                        }
@@ -831,6 +828,160 @@ out:
 }
 EXPORT_SYMBOL(xfrm_state_add);
 
+#ifdef CONFIG_XFRM_MIGRATE
+struct xfrm_state *xfrm_state_clone(struct xfrm_state *orig, int *errp)
+{
+       int err = -ENOMEM;
+       struct xfrm_state *x = xfrm_state_alloc();
+       if (!x)
+               goto error;
+
+       memcpy(&x->id, &orig->id, sizeof(x->id));
+       memcpy(&x->sel, &orig->sel, sizeof(x->sel));
+       memcpy(&x->lft, &orig->lft, sizeof(x->lft));
+       x->props.mode = orig->props.mode;
+       x->props.replay_window = orig->props.replay_window;
+       x->props.reqid = orig->props.reqid;
+       x->props.family = orig->props.family;
+       x->props.saddr = orig->props.saddr;
+
+       if (orig->aalg) {
+               x->aalg = xfrm_algo_clone(orig->aalg);
+               if (!x->aalg)
+                       goto error;
+       }
+       x->props.aalgo = orig->props.aalgo;
+
+       if (orig->ealg) {
+               x->ealg = xfrm_algo_clone(orig->ealg);
+               if (!x->ealg)
+                       goto error;
+       }
+       x->props.ealgo = orig->props.ealgo;
+
+       if (orig->calg) {
+               x->calg = xfrm_algo_clone(orig->calg);
+               if (!x->calg)
+                       goto error;
+       }
+       x->props.calgo = orig->props.calgo;
+
+       if (orig->encap) {
+               x->encap = kmemdup(orig->encap, sizeof(*x->encap), GFP_KERNEL);
+               if (!x->encap)
+                       goto error;
+       }
+
+       if (orig->coaddr) {
+               x->coaddr = kmemdup(orig->coaddr, sizeof(*x->coaddr),
+                                   GFP_KERNEL);
+               if (!x->coaddr)
+                       goto error;
+       }
+
+       err = xfrm_init_state(x);
+       if (err)
+               goto error;
+
+       x->props.flags = orig->props.flags;
+
+       x->curlft.add_time = orig->curlft.add_time;
+       x->km.state = orig->km.state;
+       x->km.seq = orig->km.seq;
+
+       return x;
+
+ error:
+       if (errp)
+               *errp = err;
+       if (x) {
+               kfree(x->aalg);
+               kfree(x->ealg);
+               kfree(x->calg);
+               kfree(x->encap);
+               kfree(x->coaddr);
+       }
+       kfree(x);
+       return NULL;
+}
+EXPORT_SYMBOL(xfrm_state_clone);
+
+/* xfrm_state_lock is held */
+struct xfrm_state * xfrm_migrate_state_find(struct xfrm_migrate *m)
+{
+       unsigned int h;
+       struct xfrm_state *x;
+       struct hlist_node *entry;
+
+       if (m->reqid) {
+               h = xfrm_dst_hash(&m->old_daddr, &m->old_saddr,
+                                 m->reqid, m->old_family);
+               hlist_for_each_entry(x, entry, xfrm_state_bydst+h, bydst) {
+                       if (x->props.mode != m->mode ||
+                           x->id.proto != m->proto)
+                               continue;
+                       if (m->reqid && x->props.reqid != m->reqid)
+                               continue;
+                       if (xfrm_addr_cmp(&x->id.daddr, &m->old_daddr,
+                                         m->old_family) ||
+                           xfrm_addr_cmp(&x->props.saddr, &m->old_saddr,
+                                         m->old_family))
+                               continue;
+                       xfrm_state_hold(x);
+                       return x;
+               }
+       } else {
+               h = xfrm_src_hash(&m->old_daddr, &m->old_saddr,
+                                 m->old_family);
+               hlist_for_each_entry(x, entry, xfrm_state_bysrc+h, bysrc) {
+                       if (x->props.mode != m->mode ||
+                           x->id.proto != m->proto)
+                               continue;
+                       if (xfrm_addr_cmp(&x->id.daddr, &m->old_daddr,
+                                         m->old_family) ||
+                           xfrm_addr_cmp(&x->props.saddr, &m->old_saddr,
+                                         m->old_family))
+                               continue;
+                       xfrm_state_hold(x);
+                       return x;
+               }
+       }
+
+       return NULL;
+}
+EXPORT_SYMBOL(xfrm_migrate_state_find);
+
+struct xfrm_state * xfrm_state_migrate(struct xfrm_state *x,
+                                      struct xfrm_migrate *m)
+{
+       struct xfrm_state *xc;
+       int err;
+
+       xc = xfrm_state_clone(x, &err);
+       if (!xc)
+               return NULL;
+
+       memcpy(&xc->id.daddr, &m->new_daddr, sizeof(xc->id.daddr));
+       memcpy(&xc->props.saddr, &m->new_saddr, sizeof(xc->props.saddr));
+
+       /* add state */
+       if (!xfrm_addr_cmp(&x->id.daddr, &m->new_daddr, m->new_family)) {
+               /* a care is needed when the destination address of the
+                  state is to be updated as it is a part of triplet */
+               xfrm_state_insert(xc);
+       } else {
+               if ((err = xfrm_state_add(xc)) < 0)
+                       goto error;
+       }
+
+       return xc;
+error:
+       kfree(xc);
+       return NULL;
+}
+EXPORT_SYMBOL(xfrm_state_migrate);
+#endif
+
 int xfrm_state_update(struct xfrm_state *x)
 {
        struct xfrm_state *x1;
@@ -970,8 +1121,8 @@ xfrm_state_lookup_byaddr(xfrm_address_t *daddr, xfrm_address_t *saddr,
 EXPORT_SYMBOL(xfrm_state_lookup_byaddr);
 
 struct xfrm_state *
-xfrm_find_acq(u8 mode, u32 reqid, u8 proto, 
-             xfrm_address_t *daddr, xfrm_address_t *saddr, 
+xfrm_find_acq(u8 mode, u32 reqid, u8 proto,
+             xfrm_address_t *daddr, xfrm_address_t *saddr,
              int create, unsigned short family)
 {
        struct xfrm_state *x;
@@ -1345,6 +1496,26 @@ void km_policy_expired(struct xfrm_policy *pol, int dir, int hard, u32 pid)
 }
 EXPORT_SYMBOL(km_policy_expired);
 
+int km_migrate(struct xfrm_selector *sel, u8 dir, u8 type,
+              struct xfrm_migrate *m, int num_migrate)
+{
+       int err = -EINVAL;
+       int ret;
+       struct xfrm_mgr *km;
+
+       read_lock(&xfrm_km_lock);
+       list_for_each_entry(km, &xfrm_km_list, list) {
+               if (km->migrate) {
+                       ret = km->migrate(sel, dir, type, m, num_migrate);
+                       if (!ret)
+                               err = ret;
+               }
+       }
+       read_unlock(&xfrm_km_lock);
+       return err;
+}
+EXPORT_SYMBOL(km_migrate);
+
 int km_report(u8 proto, struct xfrm_selector *sel, xfrm_address_t *addr)
 {
        int err = -EINVAL;
@@ -1458,7 +1629,7 @@ int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo)
 }
 EXPORT_SYMBOL(xfrm_state_unregister_afinfo);
 
-static struct xfrm_state_afinfo *xfrm_state_get_afinfo(unsigned short family)
+struct xfrm_state_afinfo *xfrm_state_get_afinfo(unsigned short family)
 {
        struct xfrm_state_afinfo *afinfo;
        if (unlikely(family >= NPROTO))
@@ -1470,11 +1641,14 @@ static struct xfrm_state_afinfo *xfrm_state_get_afinfo(unsigned short family)
        return afinfo;
 }
 
-static void xfrm_state_put_afinfo(struct xfrm_state_afinfo *afinfo)
+void xfrm_state_put_afinfo(struct xfrm_state_afinfo *afinfo)
 {
        read_unlock(&xfrm_state_afinfo_lock);
 }
 
+EXPORT_SYMBOL(xfrm_state_get_afinfo);
+EXPORT_SYMBOL(xfrm_state_put_afinfo);
+
 /* Temporarily located here until net/xfrm/xfrm_tunnel.c is created */
 void xfrm_state_delete_tunnel(struct xfrm_state *x)
 {
@@ -1564,7 +1738,7 @@ error:
 }
 
 EXPORT_SYMBOL(xfrm_init_state);
+
 void __init xfrm_state_init(void)
 {
        unsigned int sz;
index 82f36d396fca5fa56f0bb44f8dbb4d7ad2db7bf0..d55436d00e86b5d9c1e95537c154efaecac36ae2 100644 (file)
@@ -48,7 +48,7 @@ static int verify_one_alg(struct rtattr **xfrma, enum xfrm_attr_type_t type)
 
        algp = RTA_DATA(rt);
 
-       len -= (algp->alg_key_len + 7U) / 8; 
+       len -= (algp->alg_key_len + 7U) / 8;
        if (len < 0)
                return -EINVAL;
 
@@ -1107,7 +1107,7 @@ static int copy_sec_ctx(struct xfrm_sec_ctx *s, struct sk_buff *skb)
        uctx->ctx_alg = s->ctx_alg;
        uctx->ctx_len = s->ctx_len;
        memcpy(uctx + 1, s->ctx_str, s->ctx_len);
-       return 0;
+       return 0;
 
  rtattr_failure:
        return -1;
@@ -1632,6 +1632,176 @@ static int xfrm_add_acquire(struct sk_buff *skb, struct nlmsghdr *nlh,
        return 0;
 }
 
+#ifdef CONFIG_XFRM_MIGRATE
+static int verify_user_migrate(struct rtattr **xfrma)
+{
+       struct rtattr *rt = xfrma[XFRMA_MIGRATE-1];
+       struct xfrm_user_migrate *um;
+
+       if (!rt)
+               return -EINVAL;
+
+       if ((rt->rta_len - sizeof(*rt)) < sizeof(*um))
+               return -EINVAL;
+
+       return 0;
+}
+
+static int copy_from_user_migrate(struct xfrm_migrate *ma,
+                                 struct rtattr **xfrma, int *num)
+{
+       struct rtattr *rt = xfrma[XFRMA_MIGRATE-1];
+       struct xfrm_user_migrate *um;
+       int i, num_migrate;
+
+       um = RTA_DATA(rt);
+       num_migrate = (rt->rta_len - sizeof(*rt)) / sizeof(*um);
+
+       if (num_migrate <= 0 || num_migrate > XFRM_MAX_DEPTH)
+               return -EINVAL;
+
+       for (i = 0; i < num_migrate; i++, um++, ma++) {
+               memcpy(&ma->old_daddr, &um->old_daddr, sizeof(ma->old_daddr));
+               memcpy(&ma->old_saddr, &um->old_saddr, sizeof(ma->old_saddr));
+               memcpy(&ma->new_daddr, &um->new_daddr, sizeof(ma->new_daddr));
+               memcpy(&ma->new_saddr, &um->new_saddr, sizeof(ma->new_saddr));
+
+               ma->proto = um->proto;
+               ma->mode = um->mode;
+               ma->reqid = um->reqid;
+
+               ma->old_family = um->old_family;
+               ma->new_family = um->new_family;
+       }
+
+       *num = i;
+       return 0;
+}
+
+static int xfrm_do_migrate(struct sk_buff *skb, struct nlmsghdr *nlh,
+                          struct rtattr **xfrma)
+{
+       struct xfrm_userpolicy_id *pi = NLMSG_DATA(nlh);
+       struct xfrm_migrate m[XFRM_MAX_DEPTH];
+       u8 type;
+       int err;
+       int n = 0;
+
+       err = verify_user_migrate((struct rtattr **)xfrma);
+       if (err)
+               return err;
+
+       err = copy_from_user_policy_type(&type, (struct rtattr **)xfrma);
+       if (err)
+               return err;
+
+       err = copy_from_user_migrate((struct xfrm_migrate *)m,
+                                    (struct rtattr **)xfrma, &n);
+       if (err)
+               return err;
+
+       if (!n)
+               return 0;
+
+       xfrm_migrate(&pi->sel, pi->dir, type, m, n);
+
+       return 0;
+}
+#else
+static int xfrm_do_migrate(struct sk_buff *skb, struct nlmsghdr *nlh,
+                          struct rtattr **xfrma)
+{
+       return -ENOPROTOOPT;
+}
+#endif
+
+#ifdef CONFIG_XFRM_MIGRATE
+static int copy_to_user_migrate(struct xfrm_migrate *m, struct sk_buff *skb)
+{
+       struct xfrm_user_migrate um;
+
+       memset(&um, 0, sizeof(um));
+       um.proto = m->proto;
+       um.mode = m->mode;
+       um.reqid = m->reqid;
+       um.old_family = m->old_family;
+       memcpy(&um.old_daddr, &m->old_daddr, sizeof(um.old_daddr));
+       memcpy(&um.old_saddr, &m->old_saddr, sizeof(um.old_saddr));
+       um.new_family = m->new_family;
+       memcpy(&um.new_daddr, &m->new_daddr, sizeof(um.new_daddr));
+       memcpy(&um.new_saddr, &m->new_saddr, sizeof(um.new_saddr));
+
+       RTA_PUT(skb, XFRMA_MIGRATE, sizeof(um), &um);
+       return 0;
+
+rtattr_failure:
+       return -1;
+}
+
+static int build_migrate(struct sk_buff *skb, struct xfrm_migrate *m,
+                        int num_migrate, struct xfrm_selector *sel,
+                        u8 dir, u8 type)
+{
+       struct xfrm_migrate *mp;
+       struct xfrm_userpolicy_id *pol_id;
+       struct nlmsghdr *nlh;
+       unsigned char *b = skb->tail;
+       int i;
+
+       nlh = NLMSG_PUT(skb, 0, 0, XFRM_MSG_MIGRATE, sizeof(*pol_id));
+       pol_id = NLMSG_DATA(nlh);
+       nlh->nlmsg_flags = 0;
+
+       /* copy data from selector, dir, and type to the pol_id */
+       memset(pol_id, 0, sizeof(*pol_id));
+       memcpy(&pol_id->sel, sel, sizeof(pol_id->sel));
+       pol_id->dir = dir;
+
+       if (copy_to_user_policy_type(type, skb) < 0)
+               goto nlmsg_failure;
+
+       for (i = 0, mp = m ; i < num_migrate; i++, mp++) {
+               if (copy_to_user_migrate(mp, skb) < 0)
+                       goto nlmsg_failure;
+       }
+
+       nlh->nlmsg_len = skb->tail - b;
+       return skb->len;
+nlmsg_failure:
+       skb_trim(skb, b - skb->data);
+       return -1;
+}
+
+static int xfrm_send_migrate(struct xfrm_selector *sel, u8 dir, u8 type,
+                            struct xfrm_migrate *m, int num_migrate)
+{
+       struct sk_buff *skb;
+       size_t len;
+
+       len = RTA_SPACE(sizeof(struct xfrm_user_migrate) * num_migrate);
+       len += NLMSG_SPACE(sizeof(struct xfrm_userpolicy_id));
+#ifdef CONFIG_XFRM_SUB_POLICY
+       len += RTA_SPACE(sizeof(struct xfrm_userpolicy_type));
+#endif
+       skb = alloc_skb(len, GFP_ATOMIC);
+       if (skb == NULL)
+               return -ENOMEM;
+
+       /* build migrate */
+       if (build_migrate(skb, m, num_migrate, sel, dir, type) < 0)
+               BUG();
+
+       NETLINK_CB(skb).dst_group = XFRMNLGRP_MIGRATE;
+       return netlink_broadcast(xfrm_nl, skb, 0, XFRMNLGRP_MIGRATE,
+                                GFP_ATOMIC);
+}
+#else
+static int xfrm_send_migrate(struct xfrm_selector *sel, u8 dir, u8 type,
+                            struct xfrm_migrate *m, int num_migrate)
+{
+       return -ENOPROTOOPT;
+}
+#endif
 
 #define XMSGSIZE(type) NLMSG_LENGTH(sizeof(struct type))
 
@@ -1653,6 +1823,7 @@ static const int xfrm_msg_min[XFRM_NR_MSGTYPES] = {
        [XFRM_MSG_NEWAE       - XFRM_MSG_BASE] = XMSGSIZE(xfrm_aevent_id),
        [XFRM_MSG_GETAE       - XFRM_MSG_BASE] = XMSGSIZE(xfrm_aevent_id),
        [XFRM_MSG_REPORT      - XFRM_MSG_BASE] = XMSGSIZE(xfrm_user_report),
+       [XFRM_MSG_MIGRATE     - XFRM_MSG_BASE] = XMSGSIZE(xfrm_userpolicy_id),
 };
 
 #undef XMSGSIZE
@@ -1679,6 +1850,7 @@ static struct xfrm_link {
        [XFRM_MSG_FLUSHPOLICY - XFRM_MSG_BASE] = { .doit = xfrm_flush_policy  },
        [XFRM_MSG_NEWAE       - XFRM_MSG_BASE] = { .doit = xfrm_new_ae  },
        [XFRM_MSG_GETAE       - XFRM_MSG_BASE] = { .doit = xfrm_get_ae  },
+       [XFRM_MSG_MIGRATE     - XFRM_MSG_BASE] = { .doit = xfrm_do_migrate    },
 };
 
 static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, int *errp)
@@ -2285,6 +2457,7 @@ static struct xfrm_mgr netlink_mgr = {
        .compile_policy = xfrm_compile_policy,
        .notify_policy  = xfrm_send_policy_notify,
        .report         = xfrm_send_report,
+       .migrate        = xfrm_send_migrate,
 };
 
 static int __init xfrm_user_init(void)
@@ -2294,7 +2467,7 @@ static int __init xfrm_user_init(void)
        printk(KERN_INFO "Initializing XFRM netlink socket\n");
 
        nlsk = netlink_kernel_create(NETLINK_XFRM, XFRMNLGRP_MAX,
-                                    xfrm_netlink_rcv, THIS_MODULE);
+                                    xfrm_netlink_rcv, THIS_MODULE);
        if (nlsk == NULL)
                return -ENOMEM;
        rcu_assign_pointer(xfrm_nl, nlsk);
index a1880e854dcee12417383fe0926885e826457d56..06c1a377c4c515e10b0e31c14ab868a80f7aeaa5 100644 (file)
@@ -1,7 +1,7 @@
 ####
 # kbuild: Generic definitions
 
-# Convenient constants
+# Convenient variables
 comma   := ,
 squote  := '
 empty   :=
@@ -56,44 +56,48 @@ endef
 # gcc support functions
 # See documentation in Documentation/kbuild/makefiles.txt
 
-# checker-shell
-# Usage: option = $(call checker-shell,$(CC)...-o $$OUT,option-ok,otherwise)
-# Exit code chooses option. $$OUT is safe location for needless output.
-define checker-shell
-$(shell set -e; \
-  DIR=$(KBUILD_EXTMOD); \
-  cd $${DIR:-$(objtree)}; \
-  OUT=$$PWD/.$$$$.null; \
-  if $(1) >/dev/null 2>&1; \
-    then echo "$(2)"; \
-    else echo "$(3)"; \
-  fi; \
-  rm -f $$OUT)
-endef
+# output directory for tests below
+TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/)
+
+# try-run
+# Usage: option = $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise)
+# Exit code chooses option. "$$TMP" is can be used as temporary file and
+# is automatically cleaned up.
+try-run = $(shell set -e;              \
+       TMP="$(TMPOUT).$$$$.tmp";       \
+       if ($(1)) >/dev/null 2>&1;      \
+       then echo "$(2)";               \
+       else echo "$(3)";               \
+       fi;                             \
+       rm -f "$$TMP")
 
 # as-option
 # Usage: cflags-y += $(call as-option,-Wa$(comma)-isa=foo,)
-as-option = $(call checker-shell,\
-   $(CC) $(CFLAGS) $(1) -c -xassembler /dev/null -o $$OUT,$(1),$(2))
+
+as-option = $(call try-run,\
+       $(CC) $(CFLAGS) $(1) -c -xassembler /dev/null -o "$$TMP",$(1),$(2))
 
 # as-instr
 # Usage: cflags-y += $(call as-instr,instr,option1,option2)
-as-instr = $(call checker-shell,\
-   printf "$(1)" | $(CC) $(AFLAGS) -c -xassembler -o $$OUT -,$(2),$(3))
+
+as-instr = $(call try-run,\
+       echo -e "$(1)" | $(CC) $(AFLAGS) -c -xassembler -o "$$TMP" -,$(2),$(3))
 
 # cc-option
 # Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586)
-cc-option = $(call checker-shell,\
-   $(CC) $(CFLAGS) $(if $(3),$(3),$(1)) -S -xc /dev/null -o $$OUT,$(1),$(2))
+
+cc-option = $(call try-run,\
+       $(CC) $(CFLAGS) $(1) -S -xc /dev/null -o "$$TMP",$(1),$(2))
 
 # cc-option-yn
 # Usage: flag := $(call cc-option-yn,-march=winchip-c6)
-cc-option-yn = $(call cc-option,"y","n",$(1))
+cc-option-yn = $(call try-run,\
+       $(CC) $(CFLAGS) $(1) -S -xc /dev/null -o "$$TMP",y,n)
 
 # cc-option-align
 # Prefix align with either -falign or -malign
 cc-option-align = $(subst -functions=0,,\
-   $(call cc-option,-falign-functions=0,-malign-functions=0))
+       $(call cc-option,-falign-functions=0,-malign-functions=0))
 
 # cc-version
 # Usage gcc-ver := $(call cc-version,$(CC))
@@ -105,24 +109,22 @@ cc-ifversion = $(shell [ $(call cc-version, $(CC)) $(1) $(2) ] && echo $(3))
 
 # ld-option
 # Usage: ldflags += $(call ld-option, -Wl$(comma)--hash-style=both)
-ld-option = $(call checker-shell,\
-   $(CC) $(1) -nostdlib -xc /dev/null -o $$OUT,$(1),$(2))
+ld-option = $(call try-run,\
+       $(CC) $(1) -nostdlib -xc /dev/null -o "$$TMP",$(1),$(2))
 
 ######
 
+###
 # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj=
 # Usage:
 # $(Q)$(MAKE) $(build)=dir
 build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj
 
-# Prefix -I with $(srctree) if it is not an absolute path,
-# add original to the end
-addtree = $(if \
-       $(filter-out -I/%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1))) $(1)
+# Prefix -I with $(srctree) if it is not an absolute path.
+addtree = $(if $(filter-out -I/%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1))) $(1)
 
 # Find all -I options and call addtree
-flags = $(foreach o,$($(1)),\
-       $(if $(filter -I%,$(o)),$(call addtree,$(o)),$(o)))
+flags = $(foreach o,$($(1)),$(if $(filter -I%,$(o)),$(call addtree,$(o)),$(o)))
 
 # echo command.
 # Short version is used, if $(quiet) equals `quiet_', otherwise full one.
@@ -144,7 +146,7 @@ objectify = $(foreach o,$(1),$(if $(filter /%,$(o)),$(o),$(obj)/$(o)))
 # See Documentation/kbuild/makefiles.txt for more info
 
 ifneq ($(KBUILD_NOCMDDEP),1)
-# Check if both arguments has same arguments. Result is empty string, if equal.
+# Check if both arguments has same arguments. Result is empty string if equal.
 # User may override this check using make KBUILD_NOCMDDEP=1
 arg-check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \
                     $(filter-out $(cmd_$@),   $(cmd_$(1))) )
@@ -168,7 +170,6 @@ if_changed = $(if $(strip $(any-prereq) $(arg-check)),                       \
        echo 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd)
 
 # Execute the command and also postprocess generated .d dependencies file.
-#
 if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ),                  \
        @set -e;                                                             \
        $(echo-cmd) $(cmd_$(1));                                             \
@@ -176,10 +177,9 @@ if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ),                  \
        rm -f $(depfile);                                                    \
        mv -f $(dot-target).tmp $(dot-target).cmd)
 
-# Will check if $(cmd_foo) changed, or any of the prerequisites changed,
-# and if so will execute $(rule_foo).
 # Usage: $(call if_changed_rule,foo)
-#
+# Will check if $(cmd_foo) or any of the prerequisites changed,
+# and if so will execute $(rule_foo).
 if_changed_rule = $(if $(strip $(any-prereq) $(arg-check) ),                 \
        @set -e;                                                             \
        $(rule_$(1)))
index f50a70f550b39b37566269d466eaebd33de50ea6..c9b4d3631101b34785b3ab8eabb7add39ee9c079 100755 (executable)
@@ -83,7 +83,7 @@ use strict;
 #  * my_function
 #  **/
 #
-# If the Description: header tag is ommitted, then there must be a blank line
+# If the Description: header tag is omitted, then there must be a blank line
 # after the last parameter specification.
 # e.g.
 # /**
@@ -265,7 +265,7 @@ my $doc_start = '^/\*\*\s*$'; # Allow whitespace at end of comment start.
 my $doc_end = '\*/';
 my $doc_com = '\s*\*\s*';
 my $doc_decl = $doc_com.'(\w+)';
-my $doc_sect = $doc_com.'(['.$doc_special.']?[\w ]+):(.*)';
+my $doc_sect = $doc_com.'(['.$doc_special.']?[\w\s]+):(.*)';
 my $doc_content = $doc_com.'(.*)';
 my $doc_block = $doc_com.'DOC:\s*(.*)?';
 
@@ -365,7 +365,7 @@ sub dump_section {
 #  parameterlist => @list of parameters
 #  parameterdescs => %parameter descriptions
 #  sectionlist => @list of sections
-#  sections => %descriont descriptions
+#  sections => %section descriptions
 #
 
 sub output_highlight {
@@ -583,14 +583,14 @@ sub output_function_xml(%) {
     $id = "API-".$args{'function'};
     $id =~ s/[^A-Za-z0-9]/-/g;
 
-    print "<refentry>\n";
+    print "<refentry id=\"$id\">\n";
     print "<refentryinfo>\n";
     print " <title>LINUX</title>\n";
     print " <productname>Kernel Hackers Manual</productname>\n";
     print " <date>$man_date</date>\n";
     print "</refentryinfo>\n";
     print "<refmeta>\n";
-    print " <refentrytitle><phrase id=\"$id\">".$args{'function'}."</phrase></refentrytitle>\n";
+    print " <refentrytitle><phrase>".$args{'function'}."</phrase></refentrytitle>\n";
     print " <manvolnum>9</manvolnum>\n";
     print "</refmeta>\n";
     print "<refnamediv>\n";
@@ -659,14 +659,14 @@ sub output_struct_xml(%) {
     $id = "API-struct-".$args{'struct'};
     $id =~ s/[^A-Za-z0-9]/-/g;
 
-    print "<refentry>\n";
+    print "<refentry id=\"$id\">\n";
     print "<refentryinfo>\n";
     print " <title>LINUX</title>\n";
     print " <productname>Kernel Hackers Manual</productname>\n";
     print " <date>$man_date</date>\n";
     print "</refentryinfo>\n";
     print "<refmeta>\n";
-    print " <refentrytitle><phrase id=\"$id\">".$args{'type'}." ".$args{'struct'}."</phrase></refentrytitle>\n";
+    print " <refentrytitle><phrase>".$args{'type'}." ".$args{'struct'}."</phrase></refentrytitle>\n";
     print " <manvolnum>9</manvolnum>\n";
     print "</refmeta>\n";
     print "<refnamediv>\n";
@@ -743,14 +743,14 @@ sub output_enum_xml(%) {
     $id = "API-enum-".$args{'enum'};
     $id =~ s/[^A-Za-z0-9]/-/g;
 
-    print "<refentry>\n";
+    print "<refentry id=\"$id\">\n";
     print "<refentryinfo>\n";
     print " <title>LINUX</title>\n";
     print " <productname>Kernel Hackers Manual</productname>\n";
     print " <date>$man_date</date>\n";
     print "</refentryinfo>\n";
     print "<refmeta>\n";
-    print " <refentrytitle><phrase id=\"$id\">enum ".$args{'enum'}."</phrase></refentrytitle>\n";
+    print " <refentrytitle><phrase>enum ".$args{'enum'}."</phrase></refentrytitle>\n";
     print " <manvolnum>9</manvolnum>\n";
     print "</refmeta>\n";
     print "<refnamediv>\n";
@@ -809,14 +809,14 @@ sub output_typedef_xml(%) {
     $id = "API-typedef-".$args{'typedef'};
     $id =~ s/[^A-Za-z0-9]/-/g;
 
-    print "<refentry>\n";
+    print "<refentry id=\"$id\">\n";
     print "<refentryinfo>\n";
     print " <title>LINUX</title>\n";
     print " <productname>Kernel Hackers Manual</productname>\n";
     print " <date>$man_date</date>\n";
     print "</refentryinfo>\n";
     print "<refmeta>\n";
-    print " <refentrytitle><phrase id=\"$id\">typedef ".$args{'typedef'}."</phrase></refentrytitle>\n";
+    print " <refentrytitle><phrase>typedef ".$args{'typedef'}."</phrase></refentrytitle>\n";
     print " <manvolnum>9</manvolnum>\n";
     print "</refmeta>\n";
     print "<refnamediv>\n";
@@ -953,7 +953,11 @@ sub output_function_man(%) {
     print $args{'function'}." \\- ".$args{'purpose'}."\n";
 
     print ".SH SYNOPSIS\n";
-    print ".B \"".$args{'functiontype'}."\" ".$args{'function'}."\n";
+    if ($args{'functiontype'} ne "") {
+       print ".B \"".$args{'functiontype'}."\" ".$args{'function'}."\n";
+    } else {
+       print ".B \"".$args{'function'}."\n";
+    }
     $count = 0;
     my $parenth = "(";
     my $post = ",";
@@ -1118,13 +1122,19 @@ sub output_intro_man(%) {
 sub output_function_text(%) {
     my %args = %{$_[0]};
     my ($parameter, $section);
+    my $start;
 
     print "Name:\n\n";
     print $args{'function'}." - ".$args{'purpose'}."\n";
 
     print "\nSynopsis:\n\n";
-    my $start=$args{'functiontype'}." ".$args{'function'}." (";
+    if ($args{'functiontype'} ne "") {
+       $start = $args{'functiontype'}." ".$args{'function'}." (";
+    } else {
+       $start = $args{'function'}." (";
+    }
     print $start;
+
     my $count = 0;
     foreach my $parameter (@{$args{'parameterlist'}}) {
        $type = $args{'parametertypes'}{$parameter};
@@ -1433,7 +1443,7 @@ sub create_parameterlist($$$) {
        } elsif ($arg =~ m/\(.*\*/) {
            # pointer-to-function
            $arg =~ tr/#/,/;
-           $arg =~ m/[^\(]+\(\*([^\)]+)\)/;
+           $arg =~ m/[^\(]+\(\*\s*([^\)]+)\)/;
            $param = $1;
            $type = $arg;
            $type =~ s/([^\(]+\(\*)$param/$1/;
@@ -1536,7 +1546,7 @@ sub dump_function($$) {
     $prototype =~ s/^__always_inline +//;
     $prototype =~ s/^noinline +//;
     $prototype =~ s/__devinit +//;
-    $prototype =~ s/^#define +//; #ak added
+    $prototype =~ s/^#define\s+//; #ak added
     $prototype =~ s/__attribute__ \(\([a-z,]*\)\)//;
 
     # Yes, this truly is vile.  We are looking for:
@@ -1710,6 +1720,7 @@ sub process_file($) {
     my $file;
     my $identifier;
     my $func;
+    my $descr;
     my $initial_section_counter = $section_counter;
 
     if (defined($ENV{'SRCTREE'})) {
@@ -1753,7 +1764,12 @@ sub process_file($) {
 
                $state = 2;
                if (/-(.*)/) {
-                   $declaration_purpose = xml_escape($1);
+                   # strip leading/trailing/multiple spaces #RDD:T:
+                   $descr= $1;
+                   $descr =~ s/^\s*//;
+                   $descr =~ s/\s*$//;
+                   $descr =~ s/\s+/ /;
+                   $declaration_purpose = xml_escape($descr);
                } else {
                    $declaration_purpose = "";
                }
index e7c0b5e2066bbb532995ba0758516c236b60c1d1..da8caf10ef9745b5f222117e9e236960c2f4e643 100644 (file)
@@ -332,11 +332,10 @@ static struct avc_node *avc_alloc_node(void)
 {
        struct avc_node *node;
 
-       node = kmem_cache_alloc(avc_node_cachep, GFP_ATOMIC);
+       node = kmem_cache_zalloc(avc_node_cachep, GFP_ATOMIC);
        if (!node)
                goto out;
 
-       memset(node, 0, sizeof(*node));
        INIT_RCU_HEAD(&node->rhead);
        INIT_LIST_HEAD(&node->list);
        atomic_set(&node->ae.used, 1);
index 65fb5e8ea9419ba1dc984c728d2614721f7bbf9b..35eb8de892fc513bd187ad3c5acbce9cd271ebd1 100644 (file)
@@ -181,11 +181,10 @@ static int inode_alloc_security(struct inode *inode)
        struct task_security_struct *tsec = current->security;
        struct inode_security_struct *isec;
 
-       isec = kmem_cache_alloc(sel_inode_cache, GFP_KERNEL);
+       isec = kmem_cache_zalloc(sel_inode_cache, GFP_KERNEL);
        if (!isec)
                return -ENOMEM;
 
-       memset(isec, 0, sizeof(*isec));
        mutex_init(&isec->lock);
        INIT_LIST_HEAD(&isec->list);
        isec->inode = inode;
@@ -2655,7 +2654,7 @@ static int selinux_file_send_sigiotask(struct task_struct *tsk,
        struct file_security_struct *fsec;
 
        /* struct fown_struct is never outside the context of a struct file */
-        file = (struct file *)((long)fown - offsetof(struct file,f_owner));
+        file = container_of(fown, struct file, f_owner);
 
        tsec = tsk->security;
        fsec = file->f_security;
index ebb993c5c244d3e5fb72468eee758fe40550e23a..9142073319c0085fcd07f87291510f3033f20bf2 100644 (file)
@@ -36,10 +36,9 @@ avtab_insert_node(struct avtab *h, int hvalue,
                  struct avtab_key *key, struct avtab_datum *datum)
 {
        struct avtab_node * newnode;
-       newnode = kmem_cache_alloc(avtab_node_cachep, GFP_KERNEL);
+       newnode = kmem_cache_zalloc(avtab_node_cachep, GFP_KERNEL);
        if (newnode == NULL)
                return NULL;
-       memset(newnode, 0, sizeof(struct avtab_node));
        newnode->key = *key;
        newnode->datum = *datum;
        if (prev) {
index 9d77300746c648cdc6f9700605bc6666257fa5ca..97532bbc2ccba8fb301a6dfdd9991a3694012381 100644 (file)
@@ -76,6 +76,8 @@ source "sound/sparc/Kconfig"
 
 source "sound/parisc/Kconfig"
 
+source "sound/soc/Kconfig"
+
 endmenu
 
 menu "Open Sound System"
index 9aee54c4882d95549f9e2f046164ce43e86944d6..b7c7fb7c24c8f33e6071be8405ed821495afdc48 100644 (file)
@@ -5,7 +5,7 @@ obj-$(CONFIG_SOUND) += soundcore.o
 obj-$(CONFIG_SOUND_PRIME) += sound_firmware.o
 obj-$(CONFIG_SOUND_PRIME) += oss/
 obj-$(CONFIG_DMASOUND) += oss/
-obj-$(CONFIG_SND) += core/ i2c/ drivers/ isa/ pci/ ppc/ arm/ synth/ usb/ sparc/ parisc/ pcmcia/ mips/
+obj-$(CONFIG_SND) += core/ i2c/ drivers/ isa/ pci/ ppc/ arm/ synth/ usb/ sparc/ parisc/ pcmcia/ mips/ soc/
 obj-$(CONFIG_SND_AOA) += aoa/
 
 # This one must be compilable even if sound is configured out
index 66de2c2f155470cc1977fe98e923f15eafa20379..7fa37e15f1961b8c6b48834bc4886c403bcb568c 100644 (file)
@@ -26,6 +26,7 @@ static int ac97_bus_match(struct device *dev, struct device_driver *drv)
        return 1;
 }
 
+#ifdef CONFIG_PM
 static int ac97_bus_suspend(struct device *dev, pm_message_t state)
 {
        int ret = 0;
@@ -45,12 +46,15 @@ static int ac97_bus_resume(struct device *dev)
 
        return ret;
 }
+#endif /* CONFIG_PM */
 
 struct bus_type ac97_bus_type = {
        .name           = "ac97",
        .match          = ac97_bus_match,
+#ifdef CONFIG_PM
        .suspend        = ac97_bus_suspend,
        .resume         = ac97_bus_resume,
+#endif /* CONFIG_PM */
 };
 
 static int __init ac97_bus_init(void)
index 378ef1e9879b09753c2b7d8ef5bd7ce4de8fd26a..541b908f3cdf0075feebeb1b00672817adb2dc20 100644 (file)
@@ -99,7 +99,7 @@ struct aoa_fabric {
  * that are not assigned yet are passed to the fabric
  * again for reconsideration. */
 extern int
-aoa_fabric_register(struct aoa_fabric *fabric);
+aoa_fabric_register(struct aoa_fabric *fabric, struct device *dev);
 
 /* it is vital to call this when the fabric exits!
  * When calling, the remove_codec will be called
index 0b7650788f1f846b5b0415682fcef6ca9d10fd21..b00fc4842c9327ecf0bf9a82bf5e24596b8b1937 100644 (file)
@@ -825,7 +825,16 @@ static int onyx_resume(struct codec_info_item *cii)
        int err = -ENXIO;
 
        mutex_lock(&onyx->mutex);
-       /* take codec out of suspend */
+
+       /* reset codec */
+       onyx->codec.gpio->methods->set_hw_reset(onyx->codec.gpio, 0);
+       msleep(1);
+       onyx->codec.gpio->methods->set_hw_reset(onyx->codec.gpio, 1);
+       msleep(1);
+       onyx->codec.gpio->methods->set_hw_reset(onyx->codec.gpio, 0);
+       msleep(1);
+
+       /* take codec out of suspend (if it still is after reset) */
        if (onyx_read_register(onyx, ONYX_REG_CONTROL, &v))
                goto out_unlock;
        onyx_write_register(onyx, ONYX_REG_CONTROL, v & ~(ONYX_ADPSV | ONYX_DAPSV));
index b42fdea77ed04a4f36f37d3e0f64ad02f6c20b9d..17fe689ed2878d9a3f70dfc10777f19ec4612d9c 100644 (file)
@@ -14,7 +14,7 @@ MODULE_PARM_DESC(index, "index for AOA sound card.");
 
 static struct aoa_card *aoa_card;
 
-int aoa_alsa_init(char *name, struct module *mod)
+int aoa_alsa_init(char *name, struct module *mod, struct device *dev)
 {
        struct snd_card *alsa_card;
        int err;
@@ -28,6 +28,7 @@ int aoa_alsa_init(char *name, struct module *mod)
                return -ENOMEM;
        aoa_card = alsa_card->private_data;
        aoa_card->alsa_card = alsa_card;
+       alsa_card->dev = dev;
        strlcpy(alsa_card->driver, "AppleOnbdAudio", sizeof(alsa_card->driver));
        strlcpy(alsa_card->shortname, name, sizeof(alsa_card->shortname));
        strlcpy(alsa_card->longname, name, sizeof(alsa_card->longname));
@@ -59,7 +60,7 @@ void aoa_alsa_cleanup(void)
 }
 
 int aoa_snd_device_new(snd_device_type_t type,
-        void * device_data, struct snd_device_ops * ops)
+                      void * device_data, struct snd_device_ops * ops)
 {
        struct snd_card *card = aoa_get_card();
        int err;
index 660d2f1793bb6123d6a35378ad6b0ea03fc430f9..9669e4489cab9f5d3d8c906ad79b7ee6d84af6bd 100644 (file)
@@ -10,7 +10,7 @@
 #define __SND_AOA_ALSA_H
 #include "../aoa.h"
 
-extern int aoa_alsa_init(char *name, struct module *mod);
+extern int aoa_alsa_init(char *name, struct module *mod, struct device *dev);
 extern void aoa_alsa_cleanup(void);
 
 #endif /* __SND_AOA_ALSA_H */
index ecd2d8263f2d5b974e5a8ddbb326cd016a8b7107..19fdae400687eef99eae88b1e1dd9730d91d7ec9 100644 (file)
@@ -82,7 +82,7 @@ void aoa_codec_unregister(struct aoa_codec *codec)
 }
 EXPORT_SYMBOL_GPL(aoa_codec_unregister);
 
-int aoa_fabric_register(struct aoa_fabric *new_fabric)
+int aoa_fabric_register(struct aoa_fabric *new_fabric, struct device *dev)
 {
        struct aoa_codec *c;
        int err;
@@ -98,7 +98,7 @@ int aoa_fabric_register(struct aoa_fabric *new_fabric)
        if (!new_fabric)
                return -EINVAL;
 
-       err = aoa_alsa_init(new_fabric->name, new_fabric->owner);
+       err = aoa_alsa_init(new_fabric->name, new_fabric->owner, dev);
        if (err)
                return err;
 
index 172eb95476c032edbbad972fac59bb68fa2dee9d..1b94ba6dd2798a6f207534462ee1c8fcad1217a8 100644 (file)
@@ -1014,7 +1014,7 @@ static int aoa_fabric_layout_probe(struct soundbus_dev *sdev)
 
        ldev->gpio.methods->init(&ldev->gpio);
 
-       err = aoa_fabric_register(&layout_fabric);
+       err = aoa_fabric_register(&layout_fabric, &sdev->ofdev.dev);
        if (err && err != -EALREADY) {
                printk(KERN_INFO "snd-aoa-fabric-layout: can't use,"
                                 " another fabric is active!\n");
@@ -1034,9 +1034,9 @@ static int aoa_fabric_layout_probe(struct soundbus_dev *sdev)
        list_del(&ldev->list);
        layouts_list_items--;
  outnodev:
-       if (sound) of_node_put(sound);
+       of_node_put(sound);
        layout_device = NULL;
-       if (ldev) kfree(ldev);
+       kfree(ldev);
        return -ENODEV;
 }
 
@@ -1077,8 +1077,6 @@ static int aoa_fabric_layout_suspend(struct soundbus_dev *sdev, pm_message_t sta
 {
        struct layout_dev *ldev = sdev->ofdev.dev.driver_data;
 
-       printk("aoa_fabric_layout_suspend()\n");
-
        if (ldev->gpio.methods && ldev->gpio.methods->all_amps_off)
                ldev->gpio.methods->all_amps_off(&ldev->gpio);
 
@@ -1089,8 +1087,6 @@ static int aoa_fabric_layout_resume(struct soundbus_dev *sdev)
 {
        struct layout_dev *ldev = sdev->ofdev.dev.driver_data;
 
-       printk("aoa_fabric_layout_resume()\n");
-
        if (ldev->gpio.methods && ldev->gpio.methods->all_amps_off)
                ldev->gpio.methods->all_amps_restore(&ldev->gpio);
 
@@ -1107,6 +1103,9 @@ static struct soundbus_driver aoa_soundbus_driver = {
        .suspend = aoa_fabric_layout_suspend,
        .resume = aoa_fabric_layout_resume,
 #endif
+       .driver = {
+               .owner = THIS_MODULE,
+       }
 };
 
 static int __init aoa_fabric_layout_init(void)
index e593a1333fe3e30667244764f2f7057f1f55b8f3..e36f6aa448d46594694c6383a80af504135b3cab 100644 (file)
@@ -41,8 +41,8 @@ static int alloc_dbdma_descriptor_ring(struct i2sbus_dev *i2sdev,
                                       struct dbdma_command_mem *r,
                                       int numcmds)
 {
-       /* one more for rounding */
-       r->size = (numcmds+1) * sizeof(struct dbdma_cmd);
+       /* one more for rounding, one for branch back, one for stop command */
+       r->size = (numcmds + 3) * sizeof(struct dbdma_cmd);
        /* We use the PCI APIs for now until the generic one gets fixed
         * enough or until we get some macio-specific versions
         */
@@ -377,11 +377,8 @@ static int i2sbus_suspend(struct macio_dev* dev, pm_message_t state)
                if (i2sdev->sound.pcm) {
                        /* Suspend PCM streams */
                        snd_pcm_suspend_all(i2sdev->sound.pcm);
-                       /* Probably useless as we handle
-                        * power transitions ourselves */
-                       snd_power_change_state(i2sdev->sound.pcm->card,
-                                              SNDRV_CTL_POWER_D3hot);
                }
+
                /* Notify codecs */
                list_for_each_entry(cii, &i2sdev->sound.codec_list, list) {
                        err = 0;
@@ -390,7 +387,11 @@ static int i2sbus_suspend(struct macio_dev* dev, pm_message_t state)
                        if (err)
                                ret = err;
                }
+
+               /* wait until streams are stopped */
+               i2sbus_wait_for_stop_both(i2sdev);
        }
+
        return ret;
 }
 
@@ -402,6 +403,9 @@ static int i2sbus_resume(struct macio_dev* dev)
        int err, ret = 0;
 
        list_for_each_entry(i2sdev, &control->list, item) {
+               /* reset i2s bus format etc. */
+               i2sbus_pcm_prepare_both(i2sdev);
+
                /* Notify codecs so they can re-initialize */
                list_for_each_entry(cii, &i2sdev->sound.codec_list, list) {
                        err = 0;
@@ -410,12 +414,6 @@ static int i2sbus_resume(struct macio_dev* dev)
                        if (err)
                                ret = err;
                }
-               /* Notify Alsa */
-               if (i2sdev->sound.pcm) {
-                       /* Same comment as above, probably useless */
-                       snd_power_change_state(i2sdev->sound.pcm->card,
-                                              SNDRV_CTL_POWER_D0);
-               }
        }
 
        return ret;
index 5eff30b10201c849b89b83a7e7d01a1ba2377ec6..c6b42f9bdbc9e92eefb3bc3426bb970f297ebd2d 100644 (file)
@@ -125,7 +125,8 @@ static int i2sbus_pcm_open(struct i2sbus_dev *i2sdev, int in)
        }
        /* bus dependent stuff */
        hw->info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID |
-                  SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_RESUME;
+                  SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_RESUME |
+                  SNDRV_PCM_INFO_JOINT_DUPLEX;
 
        CHECK_RATE(5512);
        CHECK_RATE(8000);
@@ -245,18 +246,78 @@ static int i2sbus_pcm_close(struct i2sbus_dev *i2sdev, int in)
        return err;
 }
 
+static void i2sbus_wait_for_stop(struct i2sbus_dev *i2sdev,
+                                struct pcm_info *pi)
+{
+       unsigned long flags;
+       struct completion done;
+       long timeout;
+
+       spin_lock_irqsave(&i2sdev->low_lock, flags);
+       if (pi->dbdma_ring.stopping) {
+               init_completion(&done);
+               pi->stop_completion = &done;
+               spin_unlock_irqrestore(&i2sdev->low_lock, flags);
+               timeout = wait_for_completion_timeout(&done, HZ);
+               spin_lock_irqsave(&i2sdev->low_lock, flags);
+               pi->stop_completion = NULL;
+               if (timeout == 0) {
+                       /* timeout expired, stop dbdma forcefully */
+                       printk(KERN_ERR "i2sbus_wait_for_stop: timed out\n");
+                       /* make sure RUN, PAUSE and S0 bits are cleared */
+                       out_le32(&pi->dbdma->control, (RUN | PAUSE | 1) << 16);
+                       pi->dbdma_ring.stopping = 0;
+                       timeout = 10;
+                       while (in_le32(&pi->dbdma->status) & ACTIVE) {
+                               if (--timeout <= 0)
+                                       break;
+                               udelay(1);
+                       }
+               }
+       }
+       spin_unlock_irqrestore(&i2sdev->low_lock, flags);
+}
+
+#ifdef CONFIG_PM
+void i2sbus_wait_for_stop_both(struct i2sbus_dev *i2sdev)
+{
+       struct pcm_info *pi;
+
+       get_pcm_info(i2sdev, 0, &pi, NULL);
+       i2sbus_wait_for_stop(i2sdev, pi);
+       get_pcm_info(i2sdev, 1, &pi, NULL);
+       i2sbus_wait_for_stop(i2sdev, pi);
+}
+#endif
+
 static int i2sbus_hw_params(struct snd_pcm_substream *substream,
                            struct snd_pcm_hw_params *params)
 {
        return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params));
 }
 
-static int i2sbus_hw_free(struct snd_pcm_substream *substream)
+static inline int i2sbus_hw_free(struct snd_pcm_substream *substream, int in)
 {
+       struct i2sbus_dev *i2sdev = snd_pcm_substream_chip(substream);
+       struct pcm_info *pi;
+
+       get_pcm_info(i2sdev, in, &pi, NULL);
+       if (pi->dbdma_ring.stopping)
+               i2sbus_wait_for_stop(i2sdev, pi);
        snd_pcm_lib_free_pages(substream);
        return 0;
 }
 
+static int i2sbus_playback_hw_free(struct snd_pcm_substream *substream)
+{
+       return i2sbus_hw_free(substream, 0);
+}
+
+static int i2sbus_record_hw_free(struct snd_pcm_substream *substream)
+{
+       return i2sbus_hw_free(substream, 1);
+}
+
 static int i2sbus_pcm_prepare(struct i2sbus_dev *i2sdev, int in)
 {
        /* whee. Hard work now. The user has selected a bitrate
@@ -264,7 +325,7 @@ static int i2sbus_pcm_prepare(struct i2sbus_dev *i2sdev, int in)
         * I2S controller appropriately. */
        struct snd_pcm_runtime *runtime;
        struct dbdma_cmd *command;
-       int i, periodsize;
+       int i, periodsize, nperiods;
        dma_addr_t offset;
        struct bus_info bi;
        struct codec_info_item *cii;
@@ -274,6 +335,7 @@ static int i2sbus_pcm_prepare(struct i2sbus_dev *i2sdev, int in)
        struct pcm_info *pi, *other;
        int cnt;
        int result = 0;
+       unsigned int cmd, stopaddr;
 
        mutex_lock(&i2sdev->lock);
 
@@ -283,6 +345,13 @@ static int i2sbus_pcm_prepare(struct i2sbus_dev *i2sdev, int in)
                result = -EBUSY;
                goto out_unlock;
        }
+       if (pi->dbdma_ring.stopping)
+               i2sbus_wait_for_stop(i2sdev, pi);
+
+       if (!pi->substream || !pi->substream->runtime) {
+               result = -EINVAL;
+               goto out_unlock;
+       }
 
        runtime = pi->substream->runtime;
        pi->active = 1;
@@ -297,24 +366,43 @@ static int i2sbus_pcm_prepare(struct i2sbus_dev *i2sdev, int in)
        i2sdev->rate = runtime->rate;
 
        periodsize = snd_pcm_lib_period_bytes(pi->substream);
+       nperiods = pi->substream->runtime->periods;
        pi->current_period = 0;
 
        /* generate dbdma command ring first */
        command = pi->dbdma_ring.cmds;
+       memset(command, 0, (nperiods + 2) * sizeof(struct dbdma_cmd));
+
+       /* commands to DMA to/from the ring */
+       /*
+        * For input, we need to do a graceful stop; if we abort
+        * the DMA, we end up with leftover bytes that corrupt
+        * the next recording.  To do this we set the S0 status
+        * bit and wait for the DMA controller to stop.  Each
+        * command has a branch condition to
+        * make it branch to a stop command if S0 is set.
+        * On input we also need to wait for the S7 bit to be
+        * set before turning off the DMA controller.
+        * In fact we do the graceful stop for output as well.
+        */
        offset = runtime->dma_addr;
-       for (i = 0; i < pi->substream->runtime->periods;
-            i++, command++, offset += periodsize) {
-               memset(command, 0, sizeof(struct dbdma_cmd));
-               command->command =
-                   cpu_to_le16((in ? INPUT_MORE : OUTPUT_MORE) | INTR_ALWAYS);
+       cmd = (in? INPUT_MORE: OUTPUT_MORE) | BR_IFSET | INTR_ALWAYS;
+       stopaddr = pi->dbdma_ring.bus_cmd_start +
+               (nperiods + 1) * sizeof(struct dbdma_cmd);
+       for (i = 0; i < nperiods; i++, command++, offset += periodsize) {
+               command->command = cpu_to_le16(cmd);
+               command->cmd_dep = cpu_to_le32(stopaddr);
                command->phy_addr = cpu_to_le32(offset);
                command->req_count = cpu_to_le16(periodsize);
-               command->xfer_status = cpu_to_le16(0);
        }
-       /* last one branches back to first */
-       command--;
-       command->command |= cpu_to_le16(BR_ALWAYS);
+
+       /* branch back to beginning of ring */
+       command->command = cpu_to_le16(DBDMA_NOP | BR_ALWAYS);
        command->cmd_dep = cpu_to_le32(pi->dbdma_ring.bus_cmd_start);
+       command++;
+
+       /* set stop command */
+       command->command = cpu_to_le16(DBDMA_STOP);
 
        /* ok, let's set the serial format and stuff */
        switch (runtime->format) {
@@ -435,16 +523,18 @@ static int i2sbus_pcm_prepare(struct i2sbus_dev *i2sdev, int in)
        return result;
 }
 
-static struct dbdma_cmd STOP_CMD = {
-       .command = __constant_cpu_to_le16(DBDMA_STOP),
-};
+#ifdef CONFIG_PM
+void i2sbus_pcm_prepare_both(struct i2sbus_dev *i2sdev)
+{
+       i2sbus_pcm_prepare(i2sdev, 0);
+       i2sbus_pcm_prepare(i2sdev, 1);
+}
+#endif
 
 static int i2sbus_pcm_trigger(struct i2sbus_dev *i2sdev, int in, int cmd)
 {
        struct codec_info_item *cii;
        struct pcm_info *pi;
-       int timeout;
-       struct dbdma_cmd tmp;
        int result = 0;
        unsigned long flags;
 
@@ -464,92 +554,50 @@ static int i2sbus_pcm_trigger(struct i2sbus_dev *i2sdev, int in, int cmd)
                                cii->codec->start(cii, pi->substream);
                pi->dbdma_ring.running = 1;
 
-               /* reset dma engine */
-               out_le32(&pi->dbdma->control,
-                        0 | (RUN | PAUSE | FLUSH | WAKE) << 16);
-               timeout = 100;
-               while (in_le32(&pi->dbdma->status) & RUN && timeout--)
-                       udelay(1);
-               if (timeout <= 0) {
-                       printk(KERN_ERR
-                              "i2sbus: error waiting for dma reset\n");
-                       result = -ENXIO;
-                       goto out_unlock;
+               if (pi->dbdma_ring.stopping) {
+                       /* Clear the S0 bit, then see if we stopped yet */
+                       out_le32(&pi->dbdma->control, 1 << 16);
+                       if (in_le32(&pi->dbdma->status) & ACTIVE) {
+                               /* possible race here? */
+                               udelay(10);
+                               if (in_le32(&pi->dbdma->status) & ACTIVE) {
+                                       pi->dbdma_ring.stopping = 0;
+                                       goto out_unlock; /* keep running */
+                               }
+                       }
                }
 
+               /* make sure RUN, PAUSE and S0 bits are cleared */
+               out_le32(&pi->dbdma->control, (RUN | PAUSE | 1) << 16);
+
+               /* set branch condition select register */
+               out_le32(&pi->dbdma->br_sel, (1 << 16) | 1);
+
                /* write dma command buffer address to the dbdma chip */
                out_le32(&pi->dbdma->cmdptr, pi->dbdma_ring.bus_cmd_start);
-               /* post PCI write */
-               mb();
-               (void)in_le32(&pi->dbdma->status);
-
-               /* change first command to STOP */
-               tmp = *pi->dbdma_ring.cmds;
-               *pi->dbdma_ring.cmds = STOP_CMD;
-
-               /* set running state, remember that the first command is STOP */
-               out_le32(&pi->dbdma->control, RUN | (RUN << 16));
-               timeout = 100;
-               /* wait for STOP to be executed */
-               while (in_le32(&pi->dbdma->status) & ACTIVE && timeout--)
-                       udelay(1);
-               if (timeout <= 0) {
-                       printk(KERN_ERR "i2sbus: error waiting for dma stop\n");
-                       result = -ENXIO;
-                       goto out_unlock;
-               }
-               /* again, write dma command buffer address to the dbdma chip,
-                * this time of the first real command */
-               *pi->dbdma_ring.cmds = tmp;
-               out_le32(&pi->dbdma->cmdptr, pi->dbdma_ring.bus_cmd_start);
-               /* post write */
-               mb();
-               (void)in_le32(&pi->dbdma->status);
-
-               /* reset dma engine again */
-               out_le32(&pi->dbdma->control,
-                        0 | (RUN | PAUSE | FLUSH | WAKE) << 16);
-               timeout = 100;
-               while (in_le32(&pi->dbdma->status) & RUN && timeout--)
-                       udelay(1);
-               if (timeout <= 0) {
-                       printk(KERN_ERR
-                              "i2sbus: error waiting for dma reset\n");
-                       result = -ENXIO;
-                       goto out_unlock;
-               }
 
-               /* wake up the chip with the next descriptor */
-               out_le32(&pi->dbdma->control,
-                        (RUN | WAKE) | ((RUN | WAKE) << 16));
-               /* get the frame count  */
+               /* initialize the frame count and current period */
+               pi->current_period = 0;
                pi->frame_count = in_le32(&i2sdev->intfregs->frame_count);
 
+               /* set the DMA controller running */
+               out_le32(&pi->dbdma->control, (RUN << 16) | RUN);
+
                /* off you go! */
                break;
+
        case SNDRV_PCM_TRIGGER_STOP:
        case SNDRV_PCM_TRIGGER_SUSPEND:
                if (!pi->dbdma_ring.running) {
                        result = -EALREADY;
                        goto out_unlock;
                }
+               pi->dbdma_ring.running = 0;
 
-               /* turn off all relevant bits */
-               out_le32(&pi->dbdma->control,
-                        (RUN | WAKE | FLUSH | PAUSE) << 16);
-               {
-                       /* FIXME: move to own function */
-                       int timeout = 5000;
-                       while ((in_le32(&pi->dbdma->status) & RUN)
-                              && --timeout > 0)
-                               udelay(1);
-                       if (!timeout)
-                               printk(KERN_ERR
-                                      "i2sbus: timed out turning "
-                                      "off dbdma engine!\n");
-               }
+               /* Set the S0 bit to make the DMA branch to the stop cmd */
+               out_le32(&pi->dbdma->control, (1 << 16) | 1);
+               pi->dbdma_ring.stopping = 1;
 
-               pi->dbdma_ring.running = 0;
                list_for_each_entry(cii, &i2sdev->sound.codec_list, list)
                        if (cii->codec->stop)
                                cii->codec->stop(cii, pi->substream);
@@ -574,70 +622,82 @@ static snd_pcm_uframes_t i2sbus_pcm_pointer(struct i2sbus_dev *i2sdev, int in)
        fc = in_le32(&i2sdev->intfregs->frame_count);
        fc = fc - pi->frame_count;
 
-       return (bytes_to_frames(pi->substream->runtime,
-                       pi->current_period *
-                       snd_pcm_lib_period_bytes(pi->substream))
-               + fc) % pi->substream->runtime->buffer_size;
+       if (fc >= pi->substream->runtime->buffer_size)
+               fc %= pi->substream->runtime->buffer_size;
+       return fc;
 }
 
 static inline void handle_interrupt(struct i2sbus_dev *i2sdev, int in)
 {
        struct pcm_info *pi;
-       u32 fc;
-       u32 delta;
+       u32 fc, nframes;
+       u32 status;
+       int timeout, i;
+       int dma_stopped = 0;
+       struct snd_pcm_runtime *runtime;
 
        spin_lock(&i2sdev->low_lock);
        get_pcm_info(i2sdev, in, &pi, NULL);
-
-       if (!pi->dbdma_ring.running) {
-               /* there was still an interrupt pending
-                * while we stopped. or maybe another
-                * processor (not the one that was stopping
-                * the DMA engine) was spinning above
-                * waiting for the lock. */
+       if (!pi->dbdma_ring.running && !pi->dbdma_ring.stopping)
                goto out_unlock;
-       }
 
-       fc = in_le32(&i2sdev->intfregs->frame_count);
-       /* a counter overflow does not change the calculation. */
-       delta = fc - pi->frame_count;
-
-       /* update current_period */
-       while (delta >= pi->substream->runtime->period_size) {
-               pi->current_period++;
-               delta = delta - pi->substream->runtime->period_size;
-       }
-
-       if (unlikely(delta)) {
-               /* Some interrupt came late, so check the dbdma.
-                * This special case exists to syncronize the frame_count with
-                * the dbdma transfer, but is hit every once in a while. */
-               int period;
-
-               period = (in_le32(&pi->dbdma->cmdptr)
-                       - pi->dbdma_ring.bus_cmd_start)
-                               / sizeof(struct dbdma_cmd);
-               pi->current_period = pi->current_period
-                                       % pi->substream->runtime->periods;
-
-               while (pi->current_period != period) {
-                       pi->current_period++;
-                       pi->current_period %= pi->substream->runtime->periods;
-                       /* Set delta to zero, as the frame_count value is too
-                        * high (otherwise the code path will not be executed).
-                        * This corrects the fact that the frame_count is too
-                        * low at the beginning due to buffering. */
-                       delta = 0;
+       i = pi->current_period;
+       runtime = pi->substream->runtime;
+       while (pi->dbdma_ring.cmds[i].xfer_status) {
+               if (le16_to_cpu(pi->dbdma_ring.cmds[i].xfer_status) & BT)
+                       /*
+                        * BT is the branch taken bit.  If it took a branch
+                        * it is because we set the S0 bit to make it
+                        * branch to the stop command.
+                        */
+                       dma_stopped = 1;
+               pi->dbdma_ring.cmds[i].xfer_status = 0;
+
+               if (++i >= runtime->periods) {
+                       i = 0;
+                       pi->frame_count += runtime->buffer_size;
                }
+               pi->current_period = i;
+
+               /*
+                * Check the frame count.  The DMA tends to get a bit
+                * ahead of the frame counter, which confuses the core.
+                */
+               fc = in_le32(&i2sdev->intfregs->frame_count);
+               nframes = i * runtime->period_size;
+               if (fc < pi->frame_count + nframes)
+                       pi->frame_count = fc - nframes;
        }
 
-       pi->frame_count = fc - delta;
-       pi->current_period %= pi->substream->runtime->periods;
+       if (dma_stopped) {
+               timeout = 1000;
+               for (;;) {
+                       status = in_le32(&pi->dbdma->status);
+                       if (!(status & ACTIVE) && (!in || (status & 0x80)))
+                               break;
+                       if (--timeout <= 0) {
+                               printk(KERN_ERR "i2sbus: timed out "
+                                      "waiting for DMA to stop!\n");
+                               break;
+                       }
+                       udelay(1);
+               }
+
+               /* Turn off DMA controller, clear S0 bit */
+               out_le32(&pi->dbdma->control, (RUN | PAUSE | 1) << 16);
+
+               pi->dbdma_ring.stopping = 0;
+               if (pi->stop_completion)
+                       complete(pi->stop_completion);
+       }
 
+       if (!pi->dbdma_ring.running)
+               goto out_unlock;
        spin_unlock(&i2sdev->low_lock);
        /* may call _trigger again, hence needs to be unlocked */
        snd_pcm_period_elapsed(pi->substream);
        return;
+
  out_unlock:
        spin_unlock(&i2sdev->low_lock);
 }
@@ -718,7 +778,7 @@ static struct snd_pcm_ops i2sbus_playback_ops = {
        .close =        i2sbus_playback_close,
        .ioctl =        snd_pcm_lib_ioctl,
        .hw_params =    i2sbus_hw_params,
-       .hw_free =      i2sbus_hw_free,
+       .hw_free =      i2sbus_playback_hw_free,
        .prepare =      i2sbus_playback_prepare,
        .trigger =      i2sbus_playback_trigger,
        .pointer =      i2sbus_playback_pointer,
@@ -788,7 +848,7 @@ static struct snd_pcm_ops i2sbus_record_ops = {
        .close =        i2sbus_record_close,
        .ioctl =        snd_pcm_lib_ioctl,
        .hw_params =    i2sbus_hw_params,
-       .hw_free =      i2sbus_hw_free,
+       .hw_free =      i2sbus_record_hw_free,
        .prepare =      i2sbus_record_prepare,
        .trigger =      i2sbus_record_trigger,
        .pointer =      i2sbus_record_pointer,
@@ -812,7 +872,6 @@ static void i2sbus_private_free(struct snd_pcm *pcm)
        module_put(THIS_MODULE);
 }
 
-/* FIXME: this function needs an error handling strategy with labels */
 int
 i2sbus_attach_codec(struct soundbus_dev *dev, struct snd_card *card,
                    struct codec_info *ci, void *data)
@@ -880,41 +939,31 @@ i2sbus_attach_codec(struct soundbus_dev *dev, struct snd_card *card,
        if (!cii->sdev) {
                printk(KERN_DEBUG
                       "i2sbus: failed to get soundbus dev reference\n");
-               kfree(cii);
-               return -ENODEV;
+               err = -ENODEV;
+               goto out_free_cii;
        }
 
        if (!try_module_get(THIS_MODULE)) {
                printk(KERN_DEBUG "i2sbus: failed to get module reference!\n");
-               soundbus_dev_put(dev);
-               kfree(cii);
-               return -EBUSY;
+               err = -EBUSY;
+               goto out_put_sdev;
        }
 
        if (!try_module_get(ci->owner)) {
                printk(KERN_DEBUG
                       "i2sbus: failed to get module reference to codec owner!\n");
-               module_put(THIS_MODULE);
-               soundbus_dev_put(dev);
-               kfree(cii);
-               return -EBUSY;
+               err = -EBUSY;
+               goto out_put_this_module;
        }
 
        if (!dev->pcm) {
-               err = snd_pcm_new(card,
-                                 dev->pcmname,
-                                 dev->pcmid,
-                                 0,
-                                 0,
+               err = snd_pcm_new(card, dev->pcmname, dev->pcmid, 0, 0,
                                  &dev->pcm);
                if (err) {
                        printk(KERN_DEBUG "i2sbus: failed to create pcm\n");
-                       kfree(cii);
-                       module_put(ci->owner);
-                       soundbus_dev_put(dev);
-                       module_put(THIS_MODULE);
-                       return err;
+                       goto out_put_ci_module;
                }
+               dev->pcm->dev = &dev->ofdev.dev;
        }
 
        /* ALSA yet again sucks.
@@ -926,20 +975,12 @@ i2sbus_attach_codec(struct soundbus_dev *dev, struct snd_card *card,
                        /* eh? */
                        printk(KERN_ERR
                               "Can't attach same bus to different cards!\n");
-                       module_put(ci->owner);
-                       kfree(cii);
-                       soundbus_dev_put(dev);
-                       module_put(THIS_MODULE);
-                       return -EINVAL;
-               }
-               if ((err =
-                    snd_pcm_new_stream(dev->pcm, SNDRV_PCM_STREAM_PLAYBACK, 1))) {
-                       module_put(ci->owner);
-                       kfree(cii);
-                       soundbus_dev_put(dev);
-                       module_put(THIS_MODULE);
-                       return err;
+                       err = -EINVAL;
+                       goto out_put_ci_module;
                }
+               err = snd_pcm_new_stream(dev->pcm, SNDRV_PCM_STREAM_PLAYBACK, 1);
+               if (err)
+                       goto out_put_ci_module;
                snd_pcm_set_ops(dev->pcm, SNDRV_PCM_STREAM_PLAYBACK,
                                &i2sbus_playback_ops);
                i2sdev->out.created = 1;
@@ -949,20 +990,11 @@ i2sbus_attach_codec(struct soundbus_dev *dev, struct snd_card *card,
                if (dev->pcm->card != card) {
                        printk(KERN_ERR
                               "Can't attach same bus to different cards!\n");
-                       module_put(ci->owner);
-                       kfree(cii);
-                       soundbus_dev_put(dev);
-                       module_put(THIS_MODULE);
-                       return -EINVAL;
-               }
-               if ((err =
-                    snd_pcm_new_stream(dev->pcm, SNDRV_PCM_STREAM_CAPTURE, 1))) {
-                       module_put(ci->owner);
-                       kfree(cii);
-                       soundbus_dev_put(dev);
-                       module_put(THIS_MODULE);
-                       return err;
+                       goto out_put_ci_module;
                }
+               err = snd_pcm_new_stream(dev->pcm, SNDRV_PCM_STREAM_CAPTURE, 1);
+               if (err)
+                       goto out_put_ci_module;
                snd_pcm_set_ops(dev->pcm, SNDRV_PCM_STREAM_CAPTURE,
                                &i2sbus_record_ops);
                i2sdev->in.created = 1;
@@ -977,11 +1009,7 @@ i2sbus_attach_codec(struct soundbus_dev *dev, struct snd_card *card,
        err = snd_device_register(card, dev->pcm);
        if (err) {
                printk(KERN_ERR "i2sbus: error registering new pcm\n");
-               module_put(ci->owner);
-               kfree(cii);
-               soundbus_dev_put(dev);
-               module_put(THIS_MODULE);
-               return err;
+               goto out_put_ci_module;
        }
        /* no errors any more, so let's add this to our list */
        list_add(&cii->list, &dev->codec_list);
@@ -996,6 +1024,15 @@ i2sbus_attach_codec(struct soundbus_dev *dev, struct snd_card *card,
                64 * 1024, 64 * 1024);
 
        return 0;
+ out_put_ci_module:
+       module_put(ci->owner);
+ out_put_this_module:
+       module_put(THIS_MODULE);
+ out_put_sdev:
+       soundbus_dev_put(dev);
+ out_free_cii:
+       kfree(cii);
+       return err;
 }
 
 void i2sbus_detach_codec(struct soundbus_dev *dev, void *data)
index ec20ee615d7fa282ec96a6120a6ee231fc68ab74..ff29654782c96efdee2c3f9ba21064ea49bba393 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/interrupt.h>
 #include <linux/spinlock.h>
 #include <linux/mutex.h>
+#include <linux/completion.h>
 
 #include <sound/pcm.h>
 
@@ -34,6 +35,7 @@ struct dbdma_command_mem {
        void *space;
        int size;
        u32 running:1;
+       u32 stopping:1;
 };
 
 struct pcm_info {
@@ -45,6 +47,7 @@ struct pcm_info {
        u32 frame_count;
        struct dbdma_command_mem dbdma_ring;
        volatile struct dbdma_regs __iomem *dbdma;
+       struct completion *stop_completion;
 };
 
 enum {
@@ -101,6 +104,9 @@ i2sbus_tx_intr(int irq, void *devid);
 extern irqreturn_t
 i2sbus_rx_intr(int irq, void *devid);
 
+extern void i2sbus_wait_for_stop_both(struct i2sbus_dev *i2sdev);
+extern void i2sbus_pcm_prepare_both(struct i2sbus_dev *i2sdev);
+
 /* control specific functions */
 extern int i2sbus_control_init(struct macio_dev* dev,
                               struct i2sbus_control **c);
index 06295190606ce0767e069e246457d73032793c32..9175ff9ded0165500514d630edd4e1603ad34d16 100644 (file)
@@ -228,7 +228,7 @@ struct aaci {
 
        /* AC'97 */
        struct mutex            ac97_sem;
-       ac97_bus_t              *ac97_bus;
+       struct snd_ac97_bus     *ac97_bus;
 
        u32                     maincr;
        spinlock_t              lock;
index 0c7bcd62e5b223f6c31f4328cd9baf376d700328..42bcf2794b285dd14bc89d8b9cb8cc11686d2037 100644 (file)
@@ -108,7 +108,6 @@ static void snd_ctl_empty_read_queue(struct snd_ctl_file * ctl)
 static int snd_ctl_release(struct inode *inode, struct file *file)
 {
        unsigned long flags;
-       struct list_head *list;
        struct snd_card *card;
        struct snd_ctl_file *ctl;
        struct snd_kcontrol *control;
@@ -122,12 +121,10 @@ static int snd_ctl_release(struct inode *inode, struct file *file)
        list_del(&ctl->list);
        write_unlock_irqrestore(&card->ctl_files_rwlock, flags);
        down_write(&card->controls_rwsem);
-       list_for_each(list, &card->controls) {
-               control = snd_kcontrol(list);
+       list_for_each_entry(control, &card->controls, list)
                for (idx = 0; idx < control->count; idx++)
                        if (control->vd[idx].owner == ctl)
                                control->vd[idx].owner = NULL;
-       }
        up_write(&card->controls_rwsem);
        snd_ctl_empty_read_queue(ctl);
        kfree(ctl);
@@ -140,7 +137,6 @@ void snd_ctl_notify(struct snd_card *card, unsigned int mask,
                    struct snd_ctl_elem_id *id)
 {
        unsigned long flags;
-       struct list_head *flist;
        struct snd_ctl_file *ctl;
        struct snd_kctl_event *ev;
        
@@ -149,14 +145,11 @@ void snd_ctl_notify(struct snd_card *card, unsigned int mask,
 #if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE)
        card->mixer_oss_change_count++;
 #endif
-       list_for_each(flist, &card->ctl_files) {
-               struct list_head *elist;
-               ctl = snd_ctl_file(flist);
+       list_for_each_entry(ctl, &card->ctl_files, list) {
                if (!ctl->subscribed)
                        continue;
                spin_lock_irqsave(&ctl->read_lock, flags);
-               list_for_each(elist, &ctl->events) {
-                       ev = snd_kctl_event(elist);
+               list_for_each_entry(ev, &ctl->events, list) {
                        if (ev->id.numid == id->numid) {
                                ev->mask |= mask;
                                goto _found;
@@ -190,7 +183,8 @@ EXPORT_SYMBOL(snd_ctl_notify);
  *
  * Returns the pointer of the new instance, or NULL on failure.
  */
-struct snd_kcontrol *snd_ctl_new(struct snd_kcontrol *control, unsigned int access)
+static struct snd_kcontrol *snd_ctl_new(struct snd_kcontrol *control,
+                                       unsigned int access)
 {
        struct snd_kcontrol *kctl;
        unsigned int idx;
@@ -208,8 +202,6 @@ struct snd_kcontrol *snd_ctl_new(struct snd_kcontrol *control, unsigned int acce
        return kctl;
 }
 
-EXPORT_SYMBOL(snd_ctl_new);
-
 /**
  * snd_ctl_new1 - create a control instance from the template
  * @ncontrol: the initialization record
@@ -277,11 +269,9 @@ EXPORT_SYMBOL(snd_ctl_free_one);
 static unsigned int snd_ctl_hole_check(struct snd_card *card,
                                       unsigned int count)
 {
-       struct list_head *list;
        struct snd_kcontrol *kctl;
 
-       list_for_each(list, &card->controls) {
-               kctl = snd_kcontrol(list);
+       list_for_each_entry(kctl, &card->controls, list) {
                if ((kctl->id.numid <= card->last_numid &&
                     kctl->id.numid + kctl->count > card->last_numid) ||
                    (kctl->id.numid <= card->last_numid + count - 1 &&
@@ -498,12 +488,10 @@ EXPORT_SYMBOL(snd_ctl_rename_id);
  */
 struct snd_kcontrol *snd_ctl_find_numid(struct snd_card *card, unsigned int numid)
 {
-       struct list_head *list;
        struct snd_kcontrol *kctl;
 
        snd_assert(card != NULL && numid != 0, return NULL);
-       list_for_each(list, &card->controls) {
-               kctl = snd_kcontrol(list);
+       list_for_each_entry(kctl, &card->controls, list) {
                if (kctl->id.numid <= numid && kctl->id.numid + kctl->count > numid)
                        return kctl;
        }
@@ -527,14 +515,12 @@ EXPORT_SYMBOL(snd_ctl_find_numid);
 struct snd_kcontrol *snd_ctl_find_id(struct snd_card *card,
                                     struct snd_ctl_elem_id *id)
 {
-       struct list_head *list;
        struct snd_kcontrol *kctl;
 
        snd_assert(card != NULL && id != NULL, return NULL);
        if (id->numid != 0)
                return snd_ctl_find_numid(card, id->numid);
-       list_for_each(list, &card->controls) {
-               kctl = snd_kcontrol(list);
+       list_for_each_entry(kctl, &card->controls, list) {
                if (kctl->id.iface != id->iface)
                        continue;
                if (kctl->id.device != id->device)
@@ -1182,7 +1168,6 @@ static long snd_ctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg
 {
        struct snd_ctl_file *ctl;
        struct snd_card *card;
-       struct list_head *list;
        struct snd_kctl_ioctl *p;
        void __user *argp = (void __user *)arg;
        int __user *ip = argp;
@@ -1232,8 +1217,7 @@ static long snd_ctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg
 #endif
        }
        down_read(&snd_ioctl_rwsem);
-       list_for_each(list, &snd_control_ioctls) {
-               p = list_entry(list, struct snd_kctl_ioctl, list);
+       list_for_each_entry(p, &snd_control_ioctls, list) {
                err = p->fioctl(card, ctl, cmd, arg);
                if (err != -ENOIOCTLCMD) {
                        up_read(&snd_ioctl_rwsem);
@@ -1357,13 +1341,11 @@ EXPORT_SYMBOL(snd_ctl_register_ioctl_compat);
 static int _snd_ctl_unregister_ioctl(snd_kctl_ioctl_func_t fcn,
                                     struct list_head *lists)
 {
-       struct list_head *list;
        struct snd_kctl_ioctl *p;
 
        snd_assert(fcn != NULL, return -EINVAL);
        down_write(&snd_ioctl_rwsem);
-       list_for_each(list, lists) {
-               p = list_entry(list, struct snd_kctl_ioctl, list);
+       list_for_each_entry(p, lists, list) {
                if (p->fioctl == fcn) {
                        list_del(&p->list);
                        up_write(&snd_ioctl_rwsem);
@@ -1453,7 +1435,6 @@ static int snd_ctl_dev_register(struct snd_device *device)
 static int snd_ctl_dev_disconnect(struct snd_device *device)
 {
        struct snd_card *card = device->device_data;
-       struct list_head *flist;
        struct snd_ctl_file *ctl;
        int err, cardnum;
 
@@ -1462,8 +1443,7 @@ static int snd_ctl_dev_disconnect(struct snd_device *device)
        snd_assert(cardnum >= 0 && cardnum < SNDRV_CARDS, return -ENXIO);
 
        down_read(&card->controls_rwsem);
-       list_for_each(flist, &card->ctl_files) {
-               ctl = snd_ctl_file(flist);
+       list_for_each_entry(ctl, &card->ctl_files, list) {
                wake_up(&ctl->change_sleep);
                kill_fasync(&ctl->fasync, SIGIO, POLL_ERR);
        }
index ab48962c48ce9716973392f2a426ab540e424b24..9311ca397bbc20ed62d3c5e092dd6df5ed3b1d8f 100644 (file)
@@ -392,7 +392,7 @@ enum {
 static inline long snd_ctl_ioctl_compat(struct file *file, unsigned int cmd, unsigned long arg)
 {
        struct snd_ctl_file *ctl;
-       struct list_head *list;
+       struct snd_kctl_ioctl *p;
        void __user *argp = compat_ptr(arg);
        int err;
 
@@ -427,8 +427,7 @@ static inline long snd_ctl_ioctl_compat(struct file *file, unsigned int cmd, uns
        }
 
        down_read(&snd_ioctl_rwsem);
-       list_for_each(list, &snd_control_compat_ioctls) {
-               struct snd_kctl_ioctl *p = list_entry(list, struct snd_kctl_ioctl, list);
+       list_for_each_entry(p, &snd_control_compat_ioctls, list) {
                if (p->fioctl) {
                        err = p->fioctl(ctl->card, ctl, cmd, arg);
                        if (err != -ENOIOCTLCMD) {
index ccb25816ac9ececd151dad12fe042fe65ad97374..5858b02b0b1d4e753e4a1d9ee2bceedfaec02019 100644 (file)
@@ -79,13 +79,11 @@ EXPORT_SYMBOL(snd_device_new);
  */
 int snd_device_free(struct snd_card *card, void *device_data)
 {
-       struct list_head *list;
        struct snd_device *dev;
        
        snd_assert(card != NULL, return -ENXIO);
        snd_assert(device_data != NULL, return -ENXIO);
-       list_for_each(list, &card->devices) {
-               dev = snd_device(list);
+       list_for_each_entry(dev, &card->devices, list) {
                if (dev->device_data != device_data)
                        continue;
                /* unlink */
@@ -124,13 +122,11 @@ EXPORT_SYMBOL(snd_device_free);
  */
 int snd_device_disconnect(struct snd_card *card, void *device_data)
 {
-       struct list_head *list;
        struct snd_device *dev;
 
        snd_assert(card != NULL, return -ENXIO);
        snd_assert(device_data != NULL, return -ENXIO);
-       list_for_each(list, &card->devices) {
-               dev = snd_device(list);
+       list_for_each_entry(dev, &card->devices, list) {
                if (dev->device_data != device_data)
                        continue;
                if (dev->state == SNDRV_DEV_REGISTERED &&
@@ -161,14 +157,12 @@ int snd_device_disconnect(struct snd_card *card, void *device_data)
  */
 int snd_device_register(struct snd_card *card, void *device_data)
 {
-       struct list_head *list;
        struct snd_device *dev;
        int err;
 
        snd_assert(card != NULL, return -ENXIO);
        snd_assert(device_data != NULL, return -ENXIO);
-       list_for_each(list, &card->devices) {
-               dev = snd_device(list);
+       list_for_each_entry(dev, &card->devices, list) {
                if (dev->device_data != device_data)
                        continue;
                if (dev->state == SNDRV_DEV_BUILD && dev->ops->dev_register) {
@@ -192,13 +186,11 @@ EXPORT_SYMBOL(snd_device_register);
  */
 int snd_device_register_all(struct snd_card *card)
 {
-       struct list_head *list;
        struct snd_device *dev;
        int err;
        
        snd_assert(card != NULL, return -ENXIO);
-       list_for_each(list, &card->devices) {
-               dev = snd_device(list);
+       list_for_each_entry(dev, &card->devices, list) {
                if (dev->state == SNDRV_DEV_BUILD && dev->ops->dev_register) {
                        if ((err = dev->ops->dev_register(dev)) < 0)
                                return err;
@@ -215,12 +207,10 @@ int snd_device_register_all(struct snd_card *card)
 int snd_device_disconnect_all(struct snd_card *card)
 {
        struct snd_device *dev;
-       struct list_head *list;
        int err = 0;
 
        snd_assert(card != NULL, return -ENXIO);
-       list_for_each(list, &card->devices) {
-               dev = snd_device(list);
+       list_for_each_entry(dev, &card->devices, list) {
                if (snd_device_disconnect(card, dev->device_data) < 0)
                        err = -ENXIO;
        }
@@ -234,7 +224,6 @@ int snd_device_disconnect_all(struct snd_card *card)
 int snd_device_free_all(struct snd_card *card, snd_device_cmd_t cmd)
 {
        struct snd_device *dev;
-       struct list_head *list;
        int err;
        unsigned int range_low, range_high;
 
@@ -242,8 +231,7 @@ int snd_device_free_all(struct snd_card *card, snd_device_cmd_t cmd)
        range_low = cmd * SNDRV_DEV_TYPE_RANGE_SIZE;
        range_high = range_low + SNDRV_DEV_TYPE_RANGE_SIZE - 1;
       __again:
-       list_for_each(list, &card->devices) {
-               dev = snd_device(list);         
+       list_for_each_entry(dev, &card->devices, list) {
                if (dev->type >= range_low && dev->type <= range_high) {
                        if ((err = snd_device_free(card, dev->device_data)) < 0)
                                return err;
index 46b47689362c293259fe828802788b32f06de560..39c03f3dfbfa07d2a0dfed12ac5bf12480cfb8ac 100644 (file)
@@ -47,14 +47,11 @@ static int snd_hwdep_dev_disconnect(struct snd_device *device);
 
 static struct snd_hwdep *snd_hwdep_search(struct snd_card *card, int device)
 {
-       struct list_head *p;
        struct snd_hwdep *hwdep;
 
-       list_for_each(p, &snd_hwdep_devices) {
-               hwdep = list_entry(p, struct snd_hwdep, list);
+       list_for_each_entry(hwdep, &snd_hwdep_devices, list)
                if (hwdep->card == card && hwdep->device == device)
                        return hwdep;
-       }
        return NULL;
 }
 
@@ -159,15 +156,16 @@ static int snd_hwdep_release(struct inode *inode, struct file * file)
        int err = -ENXIO;
        struct snd_hwdep *hw = file->private_data;
        struct module *mod = hw->card->module;
+
        mutex_lock(&hw->open_mutex);
-       if (hw->ops.release) {
+       if (hw->ops.release)
                err = hw->ops.release(hw, file);
-               wake_up(&hw->open_wait);
-       }
        if (hw->used > 0)
                hw->used--;
-       snd_card_file_remove(hw->card, file);
        mutex_unlock(&hw->open_mutex);
+       wake_up(&hw->open_wait);
+
+       snd_card_file_remove(hw->card, file);
        module_put(mod);
        return err;
 }
@@ -468,15 +466,12 @@ static int snd_hwdep_dev_disconnect(struct snd_device *device)
 static void snd_hwdep_proc_read(struct snd_info_entry *entry,
                                struct snd_info_buffer *buffer)
 {
-       struct list_head *p;
        struct snd_hwdep *hwdep;
 
        mutex_lock(&register_mutex);
-       list_for_each(p, &snd_hwdep_devices) {
-               hwdep = list_entry(p, struct snd_hwdep, list);
+       list_for_each_entry(hwdep, &snd_hwdep_devices, list)
                snd_iprintf(buffer, "%02i-%02i: %s\n",
                            hwdep->card->number, hwdep->device, hwdep->name);
-       }
        mutex_unlock(&register_mutex);
 }
 
index a4cc6b155ae9add936d14e1e7aab1822c14b86d6..db61037337427b9adc881868fa104c9ec015bc06 100644 (file)
@@ -114,22 +114,28 @@ struct snd_card *snd_card_new(int idx, const char *xid,
        if (idx < 0) {
                int idx2;
                for (idx2 = 0; idx2 < SNDRV_CARDS; idx2++)
+                       /* idx == -1 == 0xffff means: take any free slot */
                        if (~snd_cards_lock & idx & 1<<idx2) {
                                idx = idx2;
                                if (idx >= snd_ecards_limit)
                                        snd_ecards_limit = idx + 1;
                                break;
                        }
-       } else if (idx < snd_ecards_limit) {
-               if (snd_cards_lock & (1 << idx))
-                       err = -ENODEV;  /* invalid */
-       } else if (idx < SNDRV_CARDS)
-               snd_ecards_limit = idx + 1; /* increase the limit */
-       else
-               err = -ENODEV;
+       } else {
+                if (idx < snd_ecards_limit) {
+                       if (snd_cards_lock & (1 << idx))
+                               err = -EBUSY;   /* invalid */
+               } else {
+                       if (idx < SNDRV_CARDS)
+                               snd_ecards_limit = idx + 1; /* increase the limit */
+                       else
+                               err = -ENODEV;
+               }
+       }
        if (idx < 0 || err < 0) {
                mutex_unlock(&snd_card_mutex);
-               snd_printk(KERN_ERR "cannot find the slot for index %d (range 0-%i)\n", idx, snd_ecards_limit - 1);
+               snd_printk(KERN_ERR "cannot find the slot for index %d (range 0-%i), error: %d\n",
+                        idx, snd_ecards_limit - 1, err);
                goto __error;
        }
        snd_cards_lock |= 1 << idx;             /* lock it */
index bc0bd0910a6264a2fae71b74f50f672d98b7b9c7..f057430db0d01021d6b2c27df157b64a4958fd7a 100644 (file)
@@ -406,19 +406,17 @@ void snd_dma_free_pages(struct snd_dma_buffer *dmab)
  */
 size_t snd_dma_get_reserved_buf(struct snd_dma_buffer *dmab, unsigned int id)
 {
-       struct list_head *p;
        struct snd_mem_list *mem;
 
        snd_assert(dmab, return 0);
 
        mutex_lock(&list_mutex);
-       list_for_each(p, &mem_list_head) {
-               mem = list_entry(p, struct snd_mem_list, list);
+       list_for_each_entry(mem, &mem_list_head, list) {
                if (mem->id == id &&
                    (mem->buffer.dev.dev == NULL || dmab->dev.dev == NULL ||
                     ! memcmp(&mem->buffer.dev, &dmab->dev, sizeof(dmab->dev)))) {
                        struct device *dev = dmab->dev.dev;
-                       list_del(p);
+                       list_del(&mem->list);
                        *dmab = mem->buffer;
                        if (dmab->dev.dev == NULL)
                                dmab->dev.dev = dev;
@@ -488,7 +486,6 @@ static int snd_mem_proc_read(char *page, char **start, off_t off,
 {
        int len = 0;
        long pages = snd_allocated_pages >> (PAGE_SHIFT-12);
-       struct list_head *p;
        struct snd_mem_list *mem;
        int devno;
        static char *types[] = { "UNKNOWN", "CONT", "DEV", "DEV-SG", "SBUS" };
@@ -498,8 +495,7 @@ static int snd_mem_proc_read(char *page, char **start, off_t off,
                        "pages  : %li bytes (%li pages per %likB)\n",
                        pages * PAGE_SIZE, pages, PAGE_SIZE / 1024);
        devno = 0;
-       list_for_each(p, &mem_list_head) {
-               mem = list_entry(p, struct snd_mem_list, list);
+       list_for_each_entry(mem, &mem_list_head, list) {
                devno++;
                len += snprintf(page + len, count - len,
                                "buffer %d : ID %08x : type %s\n",
index 03fc711f4127a5d361cc9b349ef7258c224136d9..6db86a7c9704047fbc352a4efb5e2f1ee3352489 100644 (file)
@@ -78,3 +78,31 @@ void snd_verbose_printd(const char *file, int line, const char *format, ...)
 
 EXPORT_SYMBOL(snd_verbose_printd);
 #endif
+
+#ifdef CONFIG_PCI
+#include <linux/pci.h>
+/**
+ * snd_pci_quirk_lookup - look up a PCI SSID quirk list
+ * @pci: pci_dev handle
+ * @list: quirk list, terminated by a null entry
+ *
+ * Look through the given quirk list and finds a matching entry
+ * with the same PCI SSID.  When subdevice is 0, all subdevice
+ * values may match.
+ *
+ * Returns the matched entry pointer, or NULL if nothing matched.
+ */
+const struct snd_pci_quirk *
+snd_pci_quirk_lookup(struct pci_dev *pci, const struct snd_pci_quirk *list)
+{
+       const struct snd_pci_quirk *q;
+
+       for (q = list; q->subvendor; q++)
+               if (q->subvendor == pci->subsystem_vendor &&
+                   (!q->subdevice || q->subdevice == pci->subsystem_device))
+                       return q;
+       return NULL;
+}
+
+EXPORT_SYMBOL(snd_pci_quirk_lookup);
+#endif
index 8e018988551610574daece3988e78d53d1ca9c5d..2743414fc8fa8ac7fbf14d9b49dc38be622eea0a 100644 (file)
@@ -45,11 +45,9 @@ static int snd_pcm_dev_disconnect(struct snd_device *device);
 
 static struct snd_pcm *snd_pcm_search(struct snd_card *card, int device)
 {
-       struct list_head *p;
        struct snd_pcm *pcm;
 
-       list_for_each(p, &snd_pcm_devices) {
-               pcm = list_entry(p, struct snd_pcm, list);
+       list_for_each_entry(pcm, &snd_pcm_devices, list) {
                if (pcm->card == card && pcm->device == device)
                        return pcm;
        }
@@ -782,7 +780,6 @@ int snd_pcm_attach_substream(struct snd_pcm *pcm, int stream,
        struct snd_pcm_runtime *runtime;
        struct snd_ctl_file *kctl;
        struct snd_card *card;
-       struct list_head *list;
        int prefer_subdevice = -1;
        size_t size;
 
@@ -795,8 +792,7 @@ int snd_pcm_attach_substream(struct snd_pcm *pcm, int stream,
 
        card = pcm->card;
        down_read(&card->controls_rwsem);
-       list_for_each(list, &card->ctl_files) {
-               kctl = snd_ctl_file(list);
+       list_for_each_entry(kctl, &card->ctl_files, list) {
                if (kctl->pid == current->pid) {
                        prefer_subdevice = kctl->prefer_pcm_subdevice;
                        if (prefer_subdevice != -1)
@@ -941,9 +937,10 @@ static int snd_pcm_dev_register(struct snd_device *device)
 {
        int cidx, err;
        struct snd_pcm_substream *substream;
-       struct list_head *list;
+       struct snd_pcm_notify *notify;
        char str[16];
        struct snd_pcm *pcm = device->device_data;
+       struct device *dev;
 
        snd_assert(pcm != NULL && device != NULL, return -ENXIO);
        mutex_lock(&register_mutex);
@@ -966,11 +963,18 @@ static int snd_pcm_dev_register(struct snd_device *device)
                        devtype = SNDRV_DEVICE_TYPE_PCM_CAPTURE;
                        break;
                }
-               if ((err = snd_register_device(devtype, pcm->card,
-                                              pcm->device,
-                                              &snd_pcm_f_ops[cidx],
-                                              pcm, str)) < 0)
-               {
+               /* device pointer to use, pcm->dev takes precedence if
+                * it is assigned, otherwise fall back to card's device
+                * if possible */
+               dev = pcm->dev;
+               if (!dev)
+                       dev = snd_card_get_device_link(pcm->card);
+               /* register pcm */
+               err = snd_register_device_for_dev(devtype, pcm->card,
+                                                 pcm->device,
+                                                 &snd_pcm_f_ops[cidx],
+                                                 pcm, str, dev);
+               if (err < 0) {
                        list_del(&pcm->list);
                        mutex_unlock(&register_mutex);
                        return err;
@@ -980,11 +984,10 @@ static int snd_pcm_dev_register(struct snd_device *device)
                for (substream = pcm->streams[cidx].substream; substream; substream = substream->next)
                        snd_pcm_timer_init(substream);
        }
-       list_for_each(list, &snd_pcm_notify_list) {
-               struct snd_pcm_notify *notify;
-               notify = list_entry(list, struct snd_pcm_notify, list);
+
+       list_for_each_entry(notify, &snd_pcm_notify_list, list)
                notify->n_register(pcm);
-       }
+
        mutex_unlock(&register_mutex);
        return 0;
 }
@@ -1027,7 +1030,7 @@ static int snd_pcm_dev_disconnect(struct snd_device *device)
 
 int snd_pcm_notify(struct snd_pcm_notify *notify, int nfree)
 {
-       struct list_head *p;
+       struct snd_pcm *pcm;
 
        snd_assert(notify != NULL &&
                   notify->n_register != NULL &&
@@ -1036,13 +1039,12 @@ int snd_pcm_notify(struct snd_pcm_notify *notify, int nfree)
        mutex_lock(&register_mutex);
        if (nfree) {
                list_del(&notify->list);
-               list_for_each(p, &snd_pcm_devices)
-                       notify->n_unregister(list_entry(p,
-                                                       struct snd_pcm, list));
+               list_for_each_entry(pcm, &snd_pcm_devices, list)
+                       notify->n_unregister(pcm);
        } else {
                list_add_tail(&notify->list, &snd_pcm_notify_list);
-               list_for_each(p, &snd_pcm_devices)
-                       notify->n_register(list_entry(p, struct snd_pcm, list));
+               list_for_each_entry(pcm, &snd_pcm_devices, list)
+                       notify->n_register(pcm);
        }
        mutex_unlock(&register_mutex);
        return 0;
@@ -1058,12 +1060,10 @@ EXPORT_SYMBOL(snd_pcm_notify);
 static void snd_pcm_proc_read(struct snd_info_entry *entry,
                              struct snd_info_buffer *buffer)
 {
-       struct list_head *p;
        struct snd_pcm *pcm;
 
        mutex_lock(&register_mutex);
-       list_for_each(p, &snd_pcm_devices) {
-               pcm = list_entry(p, struct snd_pcm, list);
+       list_for_each_entry(pcm, &snd_pcm_devices, list) {
                snd_iprintf(buffer, "%02i-%02i: %s : %s",
                            pcm->card->number, pcm->device, pcm->id, pcm->name);
                if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream)
index b336797be4fc877f4cd2ff0e8fa1e9e184ff2774..9fefcaa2c324e5a4c740a9653945185a212e5374 100644 (file)
@@ -781,6 +781,11 @@ int snd_interval_list(struct snd_interval *i, unsigned int count, unsigned int *
 {
         unsigned int k;
        int changed = 0;
+
+       if (!count) {
+               i->empty = 1;
+               return -EINVAL;
+       }
         for (k = 0; k < count; k++) {
                if (mask && !(mask & (1 << k)))
                        continue;
index be030cb4d373207751fa516ea1b13534b8d143c4..95b1b2f0b1e23a81d1498ca62023defda6ad63c4 100644 (file)
@@ -101,6 +101,8 @@ int snd_pcm_lib_preallocate_free(struct snd_pcm_substream *substream)
 {
        snd_pcm_lib_preallocate_dma_free(substream);
 #ifdef CONFIG_SND_VERBOSE_PROCFS
+       snd_info_free_entry(substream->proc_prealloc_max_entry);
+       substream->proc_prealloc_max_entry = NULL;
        snd_info_free_entry(substream->proc_prealloc_entry);
        substream->proc_prealloc_entry = NULL;
 #endif
@@ -141,6 +143,18 @@ static void snd_pcm_lib_preallocate_proc_read(struct snd_info_entry *entry,
        snd_iprintf(buffer, "%lu\n", (unsigned long) substream->dma_buffer.bytes / 1024);
 }
 
+/*
+ * read callback for prealloc_max proc file
+ *
+ * prints the maximum allowed size in kB.
+ */
+static void snd_pcm_lib_preallocate_max_proc_read(struct snd_info_entry *entry,
+                                                 struct snd_info_buffer *buffer)
+{
+       struct snd_pcm_substream *substream = entry->private_data;
+       snd_iprintf(buffer, "%lu\n", (unsigned long) substream->dma_max / 1024);
+}
+
 /*
  * write callback for prealloc proc file
  *
@@ -203,6 +217,15 @@ static inline void preallocate_info_init(struct snd_pcm_substream *substream)
                }
        }
        substream->proc_prealloc_entry = entry;
+       if ((entry = snd_info_create_card_entry(substream->pcm->card, "prealloc_max", substream->proc_root)) != NULL) {
+               entry->c.text.read = snd_pcm_lib_preallocate_max_proc_read;
+               entry->private_data = substream;
+               if (snd_info_register(entry) < 0) {
+                       snd_info_free_entry(entry);
+                       entry = NULL;
+               }
+       }
+       substream->proc_prealloc_max_entry = entry;
 }
 
 #else /* !CONFIG_SND_VERBOSE_PROCFS */
index 0f055bfcbdac3b305e78c80fc6f0f01e0d21f56c..7e6ceec738d53cafc868865d5470a70d13f91b43 100644 (file)
@@ -61,14 +61,11 @@ static DEFINE_MUTEX(register_mutex);
 
 static struct snd_rawmidi *snd_rawmidi_search(struct snd_card *card, int device)
 {
-       struct list_head *p;
        struct snd_rawmidi *rawmidi;
 
-       list_for_each(p, &snd_rawmidi_devices) {
-               rawmidi = list_entry(p, struct snd_rawmidi, list);
+       list_for_each_entry(rawmidi, &snd_rawmidi_devices, list)
                if (rawmidi->card == card && rawmidi->device == device)
                        return rawmidi;
-       }
        return NULL;
 }
 
@@ -389,7 +386,6 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file)
        struct snd_rawmidi *rmidi;
        struct snd_rawmidi_file *rawmidi_file;
        wait_queue_t wait;
-       struct list_head *list;
        struct snd_ctl_file *kctl;
 
        if (maj == snd_major) {
@@ -426,8 +422,7 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file)
        while (1) {
                subdevice = -1;
                down_read(&card->controls_rwsem);
-               list_for_each(list, &card->ctl_files) {
-                       kctl = snd_ctl_file(list);
+               list_for_each_entry(kctl, &card->ctl_files, list) {
                        if (kctl->pid == current->pid) {
                                subdevice = kctl->prefer_rawmidi_subdevice;
                                if (subdevice != -1)
@@ -575,7 +570,6 @@ int snd_rawmidi_info_select(struct snd_card *card, struct snd_rawmidi_info *info
        struct snd_rawmidi *rmidi;
        struct snd_rawmidi_str *pstr;
        struct snd_rawmidi_substream *substream;
-       struct list_head *list;
 
        mutex_lock(&register_mutex);
        rmidi = snd_rawmidi_search(card, info->device);
@@ -589,8 +583,7 @@ int snd_rawmidi_info_select(struct snd_card *card, struct snd_rawmidi_info *info
                return -ENOENT;
        if (info->subdevice >= pstr->substream_count)
                return -ENXIO;
-       list_for_each(list, &pstr->substreams) {
-               substream = list_entry(list, struct snd_rawmidi_substream, list);
+       list_for_each_entry(substream, &pstr->substreams, list) {
                if ((unsigned int)substream->number == info->subdevice)
                        return snd_rawmidi_info(substream, info);
        }
@@ -1313,14 +1306,14 @@ static void snd_rawmidi_proc_info_read(struct snd_info_entry *entry,
        struct snd_rawmidi *rmidi;
        struct snd_rawmidi_substream *substream;
        struct snd_rawmidi_runtime *runtime;
-       struct list_head *list;
 
        rmidi = entry->private_data;
        snd_iprintf(buffer, "%s\n\n", rmidi->name);
        mutex_lock(&rmidi->open_mutex);
        if (rmidi->info_flags & SNDRV_RAWMIDI_INFO_OUTPUT) {
-               list_for_each(list, &rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substreams) {
-                       substream = list_entry(list, struct snd_rawmidi_substream, list);
+               list_for_each_entry(substream,
+                                   &rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substreams,
+                                   list) {
                        snd_iprintf(buffer,
                                    "Output %d\n"
                                    "  Tx bytes     : %lu\n",
@@ -1339,8 +1332,9 @@ static void snd_rawmidi_proc_info_read(struct snd_info_entry *entry,
                }
        }
        if (rmidi->info_flags & SNDRV_RAWMIDI_INFO_INPUT) {
-               list_for_each(list, &rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT].substreams) {
-                       substream = list_entry(list, struct snd_rawmidi_substream, list);
+               list_for_each_entry(substream,
+                                   &rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT].substreams,
+                                   list) {
                        snd_iprintf(buffer,
                                    "Input %d\n"
                                    "  Rx bytes     : %lu\n",
@@ -1625,13 +1619,10 @@ static int snd_rawmidi_dev_disconnect(struct snd_device *device)
 void snd_rawmidi_set_ops(struct snd_rawmidi *rmidi, int stream,
                         struct snd_rawmidi_ops *ops)
 {
-       struct list_head *list;
        struct snd_rawmidi_substream *substream;
        
-       list_for_each(list, &rmidi->streams[stream].substreams) {
-               substream = list_entry(list, struct snd_rawmidi_substream, list);
+       list_for_each_entry(substream, &rmidi->streams[stream].substreams, list)
                substream->ops = ops;
-       }
 }
 
 /*
index 532a660df51dae965ca486b537118d8fe9b93272..bb9dd9fa8e51a0b122f2e3ef1010937c4d986112 100644 (file)
@@ -659,7 +659,6 @@ static int deliver_to_subscribers(struct snd_seq_client *client,
        int err = 0, num_ev = 0;
        struct snd_seq_event event_saved;
        struct snd_seq_client_port *src_port;
-       struct list_head *p;
        struct snd_seq_port_subs_info *grp;
 
        src_port = snd_seq_port_use_ptr(client, event->source.port);
@@ -674,8 +673,7 @@ static int deliver_to_subscribers(struct snd_seq_client *client,
                read_lock(&grp->list_lock);
        else
                down_read(&grp->list_mutex);
-       list_for_each(p, &grp->list_head) {
-               subs = list_entry(p, struct snd_seq_subscribers, src_list);
+       list_for_each_entry(subs, &grp->list_head, src_list) {
                event->dest = subs->info.dest;
                if (subs->info.flags & SNDRV_SEQ_PORT_SUBS_TIMESTAMP)
                        /* convert time according to flag with subscription */
@@ -709,15 +707,14 @@ static int port_broadcast_event(struct snd_seq_client *client,
 {
        int num_ev = 0, err = 0;
        struct snd_seq_client *dest_client;
-       struct list_head *p;
+       struct snd_seq_client_port *port;
 
        dest_client = get_event_dest_client(event, SNDRV_SEQ_FILTER_BROADCAST);
        if (dest_client == NULL)
                return 0; /* no matching destination */
 
        read_lock(&dest_client->ports_lock);
-       list_for_each(p, &dest_client->ports_list_head) {
-               struct snd_seq_client_port *port = list_entry(p, struct snd_seq_client_port, list);
+       list_for_each_entry(port, &dest_client->ports_list_head, list) {
                event->dest.port = port->addr.port;
                /* pass NULL as source client to avoid error bounce */
                err = snd_seq_deliver_single_event(NULL, event,
@@ -2473,11 +2470,10 @@ static void snd_seq_info_dump_subscribers(struct snd_info_buffer *buffer,
 static void snd_seq_info_dump_ports(struct snd_info_buffer *buffer,
                                    struct snd_seq_client *client)
 {
-       struct list_head *l;
+       struct snd_seq_client_port *p;
 
        mutex_lock(&client->ports_mutex);
-       list_for_each(l, &client->ports_list_head) {
-               struct snd_seq_client_port *p = list_entry(l, struct snd_seq_client_port, list);
+       list_for_each_entry(p, &client->ports_list_head, list) {
                snd_iprintf(buffer, "  Port %3d : \"%s\" (%c%c%c%c)\n",
                            p->addr.port, p->name,
                            FLAG_PERM_RD(p->capability),
index b79d011813c026436b9b8c311daec32962d48ac6..37852cdace76091c83a4c33b063c1a60f5a0959c 100644 (file)
@@ -106,11 +106,10 @@ static void remove_drivers(void);
 static void snd_seq_device_info(struct snd_info_entry *entry,
                                struct snd_info_buffer *buffer)
 {
-       struct list_head *head;
+       struct ops_list *ops;
 
        mutex_lock(&ops_mutex);
-       list_for_each(head, &opslist) {
-               struct ops_list *ops = list_entry(head, struct ops_list, list);
+       list_for_each_entry(ops, &opslist, list) {
                snd_iprintf(buffer, "snd-%s%s%s%s,%d\n",
                                ops->id,
                                ops->driver & DRIVER_LOADED ? ",loaded" : (ops->driver == DRIVER_EMPTY ? ",empty" : ""),
@@ -143,7 +142,7 @@ void snd_seq_autoload_unlock(void)
 void snd_seq_device_load_drivers(void)
 {
 #ifdef CONFIG_KMOD
-       struct list_head *head;
+       struct ops_list *ops;
 
        /* Calling request_module during module_init()
         * may cause blocking.
@@ -155,8 +154,7 @@ void snd_seq_device_load_drivers(void)
                return;
 
        mutex_lock(&ops_mutex);
-       list_for_each(head, &opslist) {
-               struct ops_list *ops = list_entry(head, struct ops_list, list);
+       list_for_each_entry(ops, &opslist, list) {
                if (! (ops->driver & DRIVER_LOADED) &&
                    ! (ops->driver & DRIVER_REQUESTED)) {
                        ops->used++;
@@ -314,8 +312,8 @@ static int snd_seq_device_dev_disconnect(struct snd_device *device)
 int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
                                   int argsize)
 {
-       struct list_head *head;
        struct ops_list *ops;
+       struct snd_seq_device *dev;
 
        if (id == NULL || entry == NULL ||
            entry->init_device == NULL || entry->free_device == NULL)
@@ -341,8 +339,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
        ops->argsize = argsize;
 
        /* initialize existing devices if necessary */
-       list_for_each(head, &ops->dev_list) {
-               struct snd_seq_device *dev = list_entry(head, struct snd_seq_device, list);
+       list_for_each_entry(dev, &ops->dev_list, list) {
                init_device(dev, ops);
        }
        mutex_unlock(&ops->reg_mutex);
@@ -394,8 +391,8 @@ static struct ops_list * create_driver(char *id)
  */
 int snd_seq_device_unregister_driver(char *id)
 {
-       struct list_head *head;
        struct ops_list *ops;
+       struct snd_seq_device *dev;
 
        ops = find_driver(id, 0);
        if (ops == NULL)
@@ -411,8 +408,7 @@ int snd_seq_device_unregister_driver(char *id)
        /* close and release all devices associated with this driver */
        mutex_lock(&ops->reg_mutex);
        ops->driver |= DRIVER_LOCKED; /* do not remove this driver recursively */
-       list_for_each(head, &ops->dev_list) {
-               struct snd_seq_device *dev = list_entry(head, struct snd_seq_device, list);
+       list_for_each_entry(dev, &ops->dev_list, list) {
                free_device(dev, ops);
        }
 
@@ -512,11 +508,10 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
  */
 static struct ops_list * find_driver(char *id, int create_if_empty)
 {
-       struct list_head *head;
+       struct ops_list *ops;
 
        mutex_lock(&ops_mutex);
-       list_for_each(head, &opslist) {
-               struct ops_list *ops = list_entry(head, struct ops_list, list);
+       list_for_each_entry(ops, &opslist, list) {
                if (strcmp(ops->id, id) == 0) {
                        ops->used++;
                        mutex_unlock(&ops_mutex);
index 8c64b58ff77bf3afb9e7f82e30209a15c68f0dc9..eefd1cf872b49efac2f67d35831cc54b061d0163 100644 (file)
@@ -59,14 +59,12 @@ much elements are in array.
 struct snd_seq_client_port *snd_seq_port_use_ptr(struct snd_seq_client *client,
                                                 int num)
 {
-       struct list_head *p;
        struct snd_seq_client_port *port;
 
        if (client == NULL)
                return NULL;
        read_lock(&client->ports_lock);
-       list_for_each(p, &client->ports_list_head) {
-               port = list_entry(p, struct snd_seq_client_port, list);
+       list_for_each_entry(port, &client->ports_list_head, list) {
                if (port->addr.port == num) {
                        if (port->closing)
                                break; /* deleting now */
@@ -85,14 +83,12 @@ struct snd_seq_client_port *snd_seq_port_query_nearest(struct snd_seq_client *cl
                                                       struct snd_seq_port_info *pinfo)
 {
        int num;
-       struct list_head *p;
        struct snd_seq_client_port *port, *found;
 
        num = pinfo->addr.port;
        found = NULL;
        read_lock(&client->ports_lock);
-       list_for_each(p, &client->ports_list_head) {
-               port = list_entry(p, struct snd_seq_client_port, list);
+       list_for_each_entry(port, &client->ports_list_head, list) {
                if (port->addr.port < num)
                        continue;
                if (port->addr.port == num) {
@@ -131,8 +127,7 @@ struct snd_seq_client_port *snd_seq_create_port(struct snd_seq_client *client,
                                                int port)
 {
        unsigned long flags;
-       struct snd_seq_client_port *new_port;
-       struct list_head *l;
+       struct snd_seq_client_port *new_port, *p;
        int num = -1;
        
        /* sanity check */
@@ -161,15 +156,14 @@ struct snd_seq_client_port *snd_seq_create_port(struct snd_seq_client *client,
        num = port >= 0 ? port : 0;
        mutex_lock(&client->ports_mutex);
        write_lock_irqsave(&client->ports_lock, flags);
-       list_for_each(l, &client->ports_list_head) {
-               struct snd_seq_client_port *p = list_entry(l, struct snd_seq_client_port, list);
+       list_for_each_entry(p, &client->ports_list_head, list) {
                if (p->addr.port > num)
                        break;
                if (port < 0) /* auto-probe mode */
                        num = p->addr.port + 1;
        }
        /* insert the new port */
-       list_add_tail(&new_port->list, l);
+       list_add_tail(&new_port->list, &p->list);
        client->num_ports++;
        new_port->addr.port = num;      /* store the port number in the port */
        write_unlock_irqrestore(&client->ports_lock, flags);
@@ -251,9 +245,9 @@ static void clear_subscriber_list(struct snd_seq_client *client,
                                list_del(&subs->dest_list);
                        else
                                list_del(&subs->src_list);
+                       up_write(&agrp->list_mutex);
                        unsubscribe_port(c, aport, agrp, &subs->info, 1);
                        kfree(subs);
-                       up_write(&agrp->list_mutex);
                        snd_seq_port_unlock(aport);
                        snd_seq_client_unlock(c);
                }
@@ -287,16 +281,14 @@ static int port_delete(struct snd_seq_client *client,
 int snd_seq_delete_port(struct snd_seq_client *client, int port)
 {
        unsigned long flags;
-       struct list_head *l;
-       struct snd_seq_client_port *found = NULL;
+       struct snd_seq_client_port *found = NULL, *p;
 
        mutex_lock(&client->ports_mutex);
        write_lock_irqsave(&client->ports_lock, flags);
-       list_for_each(l, &client->ports_list_head) {
-               struct snd_seq_client_port *p = list_entry(l, struct snd_seq_client_port, list);
+       list_for_each_entry(p, &client->ports_list_head, list) {
                if (p->addr.port == port) {
                        /* ok found.  delete from the list at first */
-                       list_del(l);
+                       list_del(&p->list);
                        client->num_ports--;
                        found = p;
                        break;
@@ -314,7 +306,8 @@ int snd_seq_delete_port(struct snd_seq_client *client, int port)
 int snd_seq_delete_all_ports(struct snd_seq_client *client)
 {
        unsigned long flags;
-       struct list_head deleted_list, *p, *n;
+       struct list_head deleted_list;
+       struct snd_seq_client_port *port, *tmp;
        
        /* move the port list to deleted_list, and
         * clear the port list in the client data.
@@ -331,9 +324,8 @@ int snd_seq_delete_all_ports(struct snd_seq_client *client)
        write_unlock_irqrestore(&client->ports_lock, flags);
 
        /* remove each port in deleted_list */
-       list_for_each_safe(p, n, &deleted_list) {
-               struct snd_seq_client_port *port = list_entry(p, struct snd_seq_client_port, list);
-               list_del(p);
+       list_for_each_entry_safe(port, tmp, &deleted_list, list) {
+               list_del(&port->list);
                snd_seq_system_client_ev_port_exit(port->addr.client, port->addr.port);
                port_delete(client, port);
        }
@@ -500,8 +492,7 @@ int snd_seq_port_connect(struct snd_seq_client *connector,
 {
        struct snd_seq_port_subs_info *src = &src_port->c_src;
        struct snd_seq_port_subs_info *dest = &dest_port->c_dest;
-       struct snd_seq_subscribers *subs;
-       struct list_head *p;
+       struct snd_seq_subscribers *subs, *s;
        int err, src_called = 0;
        unsigned long flags;
        int exclusive;
@@ -525,13 +516,11 @@ int snd_seq_port_connect(struct snd_seq_client *connector,
                if (src->exclusive || dest->exclusive)
                        goto __error;
                /* check whether already exists */
-               list_for_each(p, &src->list_head) {
-                       struct snd_seq_subscribers *s = list_entry(p, struct snd_seq_subscribers, src_list);
+               list_for_each_entry(s, &src->list_head, src_list) {
                        if (match_subs_info(info, &s->info))
                                goto __error;
                }
-               list_for_each(p, &dest->list_head) {
-                       struct snd_seq_subscribers *s = list_entry(p, struct snd_seq_subscribers, dest_list);
+               list_for_each_entry(s, &dest->list_head, dest_list) {
                        if (match_subs_info(info, &s->info))
                                goto __error;
                }
@@ -582,7 +571,6 @@ int snd_seq_port_disconnect(struct snd_seq_client *connector,
        struct snd_seq_port_subs_info *src = &src_port->c_src;
        struct snd_seq_port_subs_info *dest = &dest_port->c_dest;
        struct snd_seq_subscribers *subs;
-       struct list_head *p;
        int err = -ENOENT;
        unsigned long flags;
 
@@ -590,8 +578,7 @@ int snd_seq_port_disconnect(struct snd_seq_client *connector,
        down_write_nested(&dest->list_mutex, SINGLE_DEPTH_NESTING);
 
        /* look for the connection */
-       list_for_each(p, &src->list_head) {
-               subs = list_entry(p, struct snd_seq_subscribers, src_list);
+       list_for_each_entry(subs, &src->list_head, src_list) {
                if (match_subs_info(info, &subs->info)) {
                        write_lock_irqsave(&src->list_lock, flags);
                        // write_lock(&dest->list_lock);  // no lock yet
@@ -620,12 +607,10 @@ int snd_seq_port_disconnect(struct snd_seq_client *connector,
 struct snd_seq_subscribers *snd_seq_port_get_subscription(struct snd_seq_port_subs_info *src_grp,
                                                          struct snd_seq_addr *dest_addr)
 {
-       struct list_head *p;
        struct snd_seq_subscribers *s, *found = NULL;
 
        down_read(&src_grp->list_mutex);
-       list_for_each(p, &src_grp->list_head) {
-               s = list_entry(p, struct snd_seq_subscribers, src_list);
+       list_for_each_entry(s, &src_grp->list_head, src_list) {
                if (addr_match(dest_addr, &s->info.dest)) {
                        found = s;
                        break;
index 0cfa06c6b81f3418c56c5d56ae6740e4a3a04d67..972f93405364ec59efc62a35f97fda81d250d74d 100644 (file)
@@ -81,13 +81,11 @@ static int snd_virmidi_dev_receive_event(struct snd_virmidi_dev *rdev,
                                         struct snd_seq_event *ev)
 {
        struct snd_virmidi *vmidi;
-       struct list_head *list;
        unsigned char msg[4];
        int len;
 
        read_lock(&rdev->filelist_lock);
-       list_for_each(list, &rdev->filelist) {
-               vmidi = list_entry(list, struct snd_virmidi, list);
+       list_for_each_entry(vmidi, &rdev->filelist, list) {
                if (!vmidi->trigger)
                        continue;
                if (ev->type == SNDRV_SEQ_EVENT_SYSEX) {
index 82a61c67cf3ae6a027bdd082ca11f56f87960b05..4084de06412707e28011788d56c02aa60514fe10 100644 (file)
@@ -219,26 +219,27 @@ static int snd_kernel_minor(int type, struct snd_card *card, int dev)
 #endif
 
 /**
- * snd_register_device - Register the ALSA device file for the card
+ * snd_register_device_for_dev - Register the ALSA device file for the card
  * @type: the device type, SNDRV_DEVICE_TYPE_XXX
  * @card: the card instance
  * @dev: the device index
  * @f_ops: the file operations
  * @private_data: user pointer for f_ops->open()
  * @name: the device file name
+ * @device: the &struct device to link this new device to
  *
  * Registers an ALSA device file for the given card.
  * The operators have to be set in reg parameter.
  *
- * Retrurns zero if successful, or a negative error code on failure.
+ * Returns zero if successful, or a negative error code on failure.
  */
-int snd_register_device(int type, struct snd_card *card, int dev,
-                       const struct file_operations *f_ops, void *private_data,
-                       const char *name)
+int snd_register_device_for_dev(int type, struct snd_card *card, int dev,
+                               const struct file_operations *f_ops,
+                               void *private_data,
+                               const char *name, struct device *device)
 {
        int minor;
        struct snd_minor *preg;
-       struct device *device = snd_card_get_device_link(card);
 
        snd_assert(name, return -EINVAL);
        preg = kmalloc(sizeof *preg, GFP_KERNEL);
@@ -272,7 +273,7 @@ int snd_register_device(int type, struct snd_card *card, int dev,
        return 0;
 }
 
-EXPORT_SYMBOL(snd_register_device);
+EXPORT_SYMBOL(snd_register_device_for_dev);
 
 /* find the matching minor record
  * return the index of snd_minor, or -1 if not found
index 10a79aed33f86bcdc492509519cfcc41b11114bc..3e06383510692ba3ef5416eb367b0a7c9f5c2b4c 100644 (file)
@@ -35,9 +35,6 @@
 #include <sound/minors.h>
 #include <sound/initval.h>
 #include <linux/kmod.h>
-#ifdef CONFIG_KERNELD
-#include <linux/kerneld.h>
-#endif
 
 #if defined(CONFIG_SND_HPET) || defined(CONFIG_SND_HPET_MODULE)
 #define DEFAULT_TIMER_LIMIT 3
@@ -130,11 +127,8 @@ static struct snd_timer_instance *snd_timer_instance_new(char *owner,
 static struct snd_timer *snd_timer_find(struct snd_timer_id *tid)
 {
        struct snd_timer *timer = NULL;
-       struct list_head *p;
-
-       list_for_each(p, &snd_timer_list) {
-               timer = list_entry(p, struct snd_timer, device_list);
 
+       list_for_each_entry(timer, &snd_timer_list, device_list) {
                if (timer->tmr_class != tid->dev_class)
                        continue;
                if ((timer->tmr_class == SNDRV_TIMER_CLASS_CARD ||
@@ -184,13 +178,10 @@ static void snd_timer_check_slave(struct snd_timer_instance *slave)
 {
        struct snd_timer *timer;
        struct snd_timer_instance *master;
-       struct list_head *p, *q;
 
        /* FIXME: it's really dumb to look up all entries.. */
-       list_for_each(p, &snd_timer_list) {
-               timer = list_entry(p, struct snd_timer, device_list);
-               list_for_each(q, &timer->open_list_head) {
-                       master = list_entry(q, struct snd_timer_instance, open_list);
+       list_for_each_entry(timer, &snd_timer_list, device_list) {
+               list_for_each_entry(master, &timer->open_list_head, open_list) {
                        if (slave->slave_class == master->slave_class &&
                            slave->slave_id == master->slave_id) {
                                list_del(&slave->open_list);
@@ -214,16 +205,13 @@ static void snd_timer_check_slave(struct snd_timer_instance *slave)
  */
 static void snd_timer_check_master(struct snd_timer_instance *master)
 {
-       struct snd_timer_instance *slave;
-       struct list_head *p, *n;
+       struct snd_timer_instance *slave, *tmp;
 
        /* check all pending slaves */
-       list_for_each_safe(p, n, &snd_timer_slave_list) {
-               slave = list_entry(p, struct snd_timer_instance, open_list);
+       list_for_each_entry_safe(slave, tmp, &snd_timer_slave_list, open_list) {
                if (slave->slave_class == master->slave_class &&
                    slave->slave_id == master->slave_id) {
-                       list_del(p);
-                       list_add_tail(p, &master->slave_list_head);
+                       list_move_tail(&slave->open_list, &master->slave_list_head);
                        spin_lock_irq(&slave_active_lock);
                        slave->master = master;
                        slave->timer = master->timer;
@@ -317,8 +305,7 @@ static int _snd_timer_stop(struct snd_timer_instance *timeri,
 int snd_timer_close(struct snd_timer_instance *timeri)
 {
        struct snd_timer *timer = NULL;
-       struct list_head *p, *n;
-       struct snd_timer_instance *slave;
+       struct snd_timer_instance *slave, *tmp;
 
        snd_assert(timeri != NULL, return -ENXIO);
 
@@ -353,12 +340,11 @@ int snd_timer_close(struct snd_timer_instance *timeri)
                    timer->hw.close)
                        timer->hw.close(timer);
                /* remove slave links */
-               list_for_each_safe(p, n, &timeri->slave_list_head) {
-                       slave = list_entry(p, struct snd_timer_instance, open_list);
+               list_for_each_entry_safe(slave, tmp, &timeri->slave_list_head,
+                                        open_list) {
                        spin_lock_irq(&slave_active_lock);
                        _snd_timer_stop(slave, 1, SNDRV_TIMER_EVENT_RESOLUTION);
-                       list_del(p);
-                       list_add_tail(p, &snd_timer_slave_list);
+                       list_move_tail(&slave->open_list, &snd_timer_slave_list);
                        slave->master = NULL;
                        slave->timer = NULL;
                        spin_unlock_irq(&slave_active_lock);
@@ -394,7 +380,6 @@ static void snd_timer_notify1(struct snd_timer_instance *ti, int event)
        unsigned long flags;
        unsigned long resolution = 0;
        struct snd_timer_instance *ts;
-       struct list_head *n;
        struct timespec tstamp;
 
        getnstimeofday(&tstamp);
@@ -413,11 +398,9 @@ static void snd_timer_notify1(struct snd_timer_instance *ti, int event)
        if (timer->hw.flags & SNDRV_TIMER_HW_SLAVE)
                return;
        spin_lock_irqsave(&timer->lock, flags);
-       list_for_each(n, &ti->slave_active_head) {
-               ts = list_entry(n, struct snd_timer_instance, active_list);
+       list_for_each_entry(ts, &ti->slave_active_head, active_list)
                if (ts->ccallback)
                        ts->ccallback(ti, event + 100, &tstamp, resolution);
-       }
        spin_unlock_irqrestore(&timer->lock, flags);
 }
 
@@ -593,10 +576,8 @@ static void snd_timer_reschedule(struct snd_timer * timer, unsigned long ticks_l
 {
        struct snd_timer_instance *ti;
        unsigned long ticks = ~0UL;
-       struct list_head *p;
 
-       list_for_each(p, &timer->active_list_head) {
-               ti = list_entry(p, struct snd_timer_instance, active_list);
+       list_for_each_entry(ti, &timer->active_list_head, active_list) {
                if (ti->flags & SNDRV_TIMER_IFLG_START) {
                        ti->flags &= ~SNDRV_TIMER_IFLG_START;
                        ti->flags |= SNDRV_TIMER_IFLG_RUNNING;
@@ -661,9 +642,9 @@ static void snd_timer_tasklet(unsigned long arg)
  */
 void snd_timer_interrupt(struct snd_timer * timer, unsigned long ticks_left)
 {
-       struct snd_timer_instance *ti, *ts;
+       struct snd_timer_instance *ti, *ts, *tmp;
        unsigned long resolution, ticks;
-       struct list_head *p, *q, *n, *ack_list_head;
+       struct list_head *p, *ack_list_head;
        unsigned long flags;
        int use_tasklet = 0;
 
@@ -679,12 +660,12 @@ void snd_timer_interrupt(struct snd_timer * timer, unsigned long ticks_left)
                resolution = timer->hw.resolution;
 
        /* loop for all active instances
-        * Here we cannot use list_for_each because the active_list of a
+        * Here we cannot use list_for_each_entry because the active_list of a
         * processed instance is relinked to done_list_head before the callback
         * is called.
         */
-       list_for_each_safe(p, n, &timer->active_list_head) {
-               ti = list_entry(p, struct snd_timer_instance, active_list);
+       list_for_each_entry_safe(ti, tmp, &timer->active_list_head,
+                                active_list) {
                if (!(ti->flags & SNDRV_TIMER_IFLG_RUNNING))
                        continue;
                ti->pticks += ticks_left;
@@ -700,7 +681,7 @@ void snd_timer_interrupt(struct snd_timer * timer, unsigned long ticks_left)
                } else {
                        ti->flags &= ~SNDRV_TIMER_IFLG_RUNNING;
                        if (--timer->running)
-                               list_del(p);
+                               list_del(&ti->active_list);
                }
                if ((timer->hw.flags & SNDRV_TIMER_HW_TASKLET) ||
                    (ti->flags & SNDRV_TIMER_IFLG_FAST))
@@ -709,8 +690,7 @@ void snd_timer_interrupt(struct snd_timer * timer, unsigned long ticks_left)
                        ack_list_head = &timer->sack_list_head;
                if (list_empty(&ti->ack_list))
                        list_add_tail(&ti->ack_list, ack_list_head);
-               list_for_each(q, &ti->slave_active_head) {
-                       ts = list_entry(q, struct snd_timer_instance, active_list);
+               list_for_each_entry(ts, &ti->slave_active_head, active_list) {
                        ts->pticks = ti->pticks;
                        ts->resolution = resolution;
                        if (list_empty(&ts->ack_list))
@@ -844,7 +824,6 @@ static int snd_timer_dev_register(struct snd_device *dev)
 {
        struct snd_timer *timer = dev->device_data;
        struct snd_timer *timer1;
-       struct list_head *p;
 
        snd_assert(timer != NULL && timer->hw.start != NULL &&
                   timer->hw.stop != NULL, return -ENXIO);
@@ -853,8 +832,7 @@ static int snd_timer_dev_register(struct snd_device *dev)
                return -EINVAL;
 
        mutex_lock(&register_mutex);
-       list_for_each(p, &snd_timer_list) {
-               timer1 = list_entry(p, struct snd_timer, device_list);
+       list_for_each_entry(timer1, &snd_timer_list, device_list) {
                if (timer1->tmr_class > timer->tmr_class)
                        break;
                if (timer1->tmr_class < timer->tmr_class)
@@ -877,7 +855,7 @@ static int snd_timer_dev_register(struct snd_device *dev)
                mutex_unlock(&register_mutex);
                return -EBUSY;
        }
-       list_add_tail(&timer->device_list, p);
+       list_add_tail(&timer->device_list, &timer1->device_list);
        mutex_unlock(&register_mutex);
        return 0;
 }
@@ -896,7 +874,6 @@ void snd_timer_notify(struct snd_timer *timer, int event, struct timespec *tstam
        unsigned long flags;
        unsigned long resolution = 0;
        struct snd_timer_instance *ti, *ts;
-       struct list_head *p, *n;
 
        if (! (timer->hw.flags & SNDRV_TIMER_HW_SLAVE))
                return;
@@ -911,15 +888,12 @@ void snd_timer_notify(struct snd_timer *timer, int event, struct timespec *tstam
                else
                        resolution = timer->hw.resolution;
        }
-       list_for_each(p, &timer->active_list_head) {
-               ti = list_entry(p, struct snd_timer_instance, active_list);
+       list_for_each_entry(ti, &timer->active_list_head, active_list) {
                if (ti->ccallback)
                        ti->ccallback(ti, event, tstamp, resolution);
-               list_for_each(n, &ti->slave_active_head) {
-                       ts = list_entry(n, struct snd_timer_instance, active_list);
+               list_for_each_entry(ts, &ti->slave_active_head, active_list)
                        if (ts->ccallback)
                                ts->ccallback(ts, event, tstamp, resolution);
-               }
        }
        spin_unlock_irqrestore(&timer->lock, flags);
 }
@@ -1057,11 +1031,9 @@ static void snd_timer_proc_read(struct snd_info_entry *entry,
 {
        struct snd_timer *timer;
        struct snd_timer_instance *ti;
-       struct list_head *p, *q;
 
        mutex_lock(&register_mutex);
-       list_for_each(p, &snd_timer_list) {
-               timer = list_entry(p, struct snd_timer, device_list);
+       list_for_each_entry(timer, &snd_timer_list, device_list) {
                switch (timer->tmr_class) {
                case SNDRV_TIMER_CLASS_GLOBAL:
                        snd_iprintf(buffer, "G%i: ", timer->tmr_device);
@@ -1088,14 +1060,12 @@ static void snd_timer_proc_read(struct snd_info_entry *entry,
                if (timer->hw.flags & SNDRV_TIMER_HW_SLAVE)
                        snd_iprintf(buffer, " SLAVE");
                snd_iprintf(buffer, "\n");
-               list_for_each(q, &timer->open_list_head) {
-                       ti = list_entry(q, struct snd_timer_instance, open_list);
+               list_for_each_entry(ti, &timer->open_list_head, open_list)
                        snd_iprintf(buffer, "  Client %s : %s\n",
                                    ti->owner ? ti->owner : "unknown",
                                    ti->flags & (SNDRV_TIMER_IFLG_START |
                                                 SNDRV_TIMER_IFLG_RUNNING)
                                    ? "running" : "stopped");
-               }
        }
        mutex_unlock(&register_mutex);
 }
index 40ebd2f440562145989e02f3d55fce723f74d4d3..83529b08d019804945972dd4e474fe9a33a78f5d 100644 (file)
@@ -109,4 +109,15 @@ config SND_MPU401
          To compile this driver as a module, choose M here: the module
          will be called snd-mpu401.
 
+config SND_PORTMAN2X4
+       tristate "Portman 2x4 driver"
+       depends on SND && PARPORT
+       select SND_RAWMIDI
+       help
+         Say Y here to include support for Midiman Portman 2x4 parallel
+         port MIDI device.
+
+         To compile this driver as a module, choose M here: the module
+         will be called snd-portman2x4.
+
 endmenu
index c9bad6d67e73a94c0b499c2abc94ae316cd5fc13..04112642611a86fd522d30768473499e68ddc064 100644 (file)
@@ -6,6 +6,7 @@
 snd-dummy-objs := dummy.o
 snd-mtpav-objs := mtpav.o
 snd-mts64-objs := mts64.o
+snd-portman2x4-objs := portman2x4.o
 snd-serial-u16550-objs := serial-u16550.o
 snd-virmidi-objs := virmidi.o
 
@@ -15,5 +16,6 @@ obj-$(CONFIG_SND_VIRMIDI) += snd-virmidi.o
 obj-$(CONFIG_SND_SERIAL_U16550) += snd-serial-u16550.o
 obj-$(CONFIG_SND_MTPAV) += snd-mtpav.o
 obj-$(CONFIG_SND_MTS64) += snd-mts64.o
+obj-$(CONFIG_SND_PORTMAN2X4) += snd-portman2x4.o
 
 obj-$(CONFIG_SND) += opl3/ opl4/ mpu401/ vx/
index 42001efa9f3ec04db9127c71c685624c9b75f48b..8339bad969bab9fc4decf1a14a0b37d337952296 100644 (file)
@@ -501,7 +501,7 @@ static int snd_dummy_volume_put(struct snd_kcontrol *kcontrol,
        return change;
 }
 
-static DECLARE_TLV_DB_SCALE(db_scale_dummy, -4500, 30, 0);
+static const DECLARE_TLV_DB_SCALE(db_scale_dummy, -4500, 30, 0);
 
 #define DUMMY_CAPSRC(xname, xindex, addr) \
 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
new file mode 100644 (file)
index 0000000..6c48772
--- /dev/null
@@ -0,0 +1,876 @@
+/*
+ *   Driver for Midiman Portman2x4 parallel port midi interface
+ *
+ *   Copyright (c) by Levent Guendogdu <levon@feature-it.com>
+ *
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * ChangeLog
+ * Jan 24 2007 Matthias Koenig <mkoenig@suse.de>
+ *      - cleanup and rewrite
+ * Sep 30 2004 Tobias Gehrig <tobias@gehrig.tk>
+ *      - source code cleanup
+ * Sep 03 2004 Tobias Gehrig <tobias@gehrig.tk>
+ *      - fixed compilation problem with alsa 1.0.6a (removed MODULE_CLASSES,
+ *        MODULE_PARM_SYNTAX and changed MODULE_DEVICES to
+ *        MODULE_SUPPORTED_DEVICE)
+ * Mar 24 2004 Tobias Gehrig <tobias@gehrig.tk>
+ *      - added 2.6 kernel support
+ * Mar 18 2004 Tobias Gehrig <tobias@gehrig.tk>
+ *      - added parport_unregister_driver to the startup routine if the driver fails to detect a portman
+ *      - added support for all 4 output ports in portman_putmidi
+ * Mar 17 2004 Tobias Gehrig <tobias@gehrig.tk>
+ *      - added checks for opened input device in interrupt handler
+ * Feb 20 2004 Tobias Gehrig <tobias@gehrig.tk>
+ *      - ported from alsa 0.5 to 1.0
+ */
+
+#include <sound/driver.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/parport.h>
+#include <linux/spinlock.h>
+#include <linux/delay.h>
+#include <sound/core.h>
+#include <sound/initval.h>
+#include <sound/rawmidi.h>
+#include <sound/control.h>
+
+#define CARD_NAME "Portman 2x4"
+#define DRIVER_NAME "portman"
+#define PLATFORM_DRIVER "snd_portman2x4"
+
+static int index[SNDRV_CARDS]  = SNDRV_DEFAULT_IDX;
+static char *id[SNDRV_CARDS]   = SNDRV_DEFAULT_STR;
+static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
+
+static struct platform_device *platform_devices[SNDRV_CARDS]; 
+static int device_count;
+
+module_param_array(index, int, NULL, S_IRUGO);
+MODULE_PARM_DESC(index, "Index value for " CARD_NAME " soundcard.");
+module_param_array(id, charp, NULL, S_IRUGO);
+MODULE_PARM_DESC(id, "ID string for " CARD_NAME " soundcard.");
+module_param_array(enable, bool, NULL, S_IRUGO);
+MODULE_PARM_DESC(enable, "Enable " CARD_NAME " soundcard.");
+
+MODULE_AUTHOR("Levent Guendogdu, Tobias Gehrig, Matthias Koenig");
+MODULE_DESCRIPTION("Midiman Portman2x4");
+MODULE_LICENSE("GPL");
+MODULE_SUPPORTED_DEVICE("{{Midiman,Portman2x4}}");
+
+/*********************************************************************
+ * Chip specific
+ *********************************************************************/
+#define PORTMAN_NUM_INPUT_PORTS 2
+#define PORTMAN_NUM_OUTPUT_PORTS 4
+
+struct portman {
+       spinlock_t reg_lock;
+       struct snd_card *card;
+       struct snd_rawmidi *rmidi;
+       struct pardevice *pardev;
+       int pardev_claimed;
+
+       int open_count;
+       int mode[PORTMAN_NUM_INPUT_PORTS];
+       struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
+};
+
+static int portman_free(struct portman *pm)
+{
+       kfree(pm);
+       return 0;
+}
+
+static int __devinit portman_create(struct snd_card *card, 
+                                   struct pardevice *pardev, 
+                                   struct portman **rchip)
+{
+       struct portman *pm;
+
+       *rchip = NULL;
+
+       pm = kzalloc(sizeof(struct portman), GFP_KERNEL);
+       if (pm == NULL) 
+               return -ENOMEM;
+
+       /* Init chip specific data */
+       spin_lock_init(&pm->reg_lock);
+       pm->card = card;
+       pm->pardev = pardev;
+
+       *rchip = pm;
+
+       return 0;
+}
+
+/*********************************************************************
+ * HW related constants
+ *********************************************************************/
+
+/* Standard PC parallel port status register equates. */
+#define        PP_STAT_BSY     0x80    /* Busy status.  Inverted. */
+#define        PP_STAT_ACK     0x40    /* Acknowledge.  Non-Inverted. */
+#define        PP_STAT_POUT    0x20    /* Paper Out.    Non-Inverted. */
+#define        PP_STAT_SEL     0x10    /* Select.       Non-Inverted. */
+#define        PP_STAT_ERR     0x08    /* Error.        Non-Inverted. */
+
+/* Standard PC parallel port command register equates. */
+#define        PP_CMD_IEN      0x10    /* IRQ Enable.   Non-Inverted. */
+#define        PP_CMD_SELI     0x08    /* Select Input. Inverted. */
+#define        PP_CMD_INIT     0x04    /* Init Printer. Non-Inverted. */
+#define        PP_CMD_FEED     0x02    /* Auto Feed.    Inverted. */
+#define        PP_CMD_STB      0x01    /* Strobe.       Inverted. */
+
+/* Parallel Port Command Register as implemented by PCP2x4. */
+#define        INT_EN          PP_CMD_IEN      /* Interrupt enable. */
+#define        STROBE          PP_CMD_STB      /* Command strobe. */
+
+/* The parallel port command register field (b1..b3) selects the 
+ * various "registers" within the PC/P 2x4.  These are the internal
+ * address of these "registers" that must be written to the parallel
+ * port command register.
+ */
+#define        RXDATA0         (0 << 1)        /* PCP RxData channel 0. */
+#define        RXDATA1         (1 << 1)        /* PCP RxData channel 1. */
+#define        GEN_CTL         (2 << 1)        /* PCP General Control Register. */
+#define        SYNC_CTL        (3 << 1)        /* PCP Sync Control Register. */
+#define        TXDATA0         (4 << 1)        /* PCP TxData channel 0. */
+#define        TXDATA1         (5 << 1)        /* PCP TxData channel 1. */
+#define        TXDATA2         (6 << 1)        /* PCP TxData channel 2. */
+#define        TXDATA3         (7 << 1)        /* PCP TxData channel 3. */
+
+/* Parallel Port Status Register as implemented by PCP2x4. */
+#define        ESTB            PP_STAT_POUT    /* Echoed strobe. */
+#define        INT_REQ         PP_STAT_ACK     /* Input data int request. */
+#define        BUSY            PP_STAT_ERR     /* Interface Busy. */
+
+/* Parallel Port Status Register BUSY and SELECT lines are multiplexed
+ * between several functions.  Depending on which 2x4 "register" is
+ * currently selected (b1..b3), the BUSY and SELECT lines are
+ * assigned as follows:
+ *
+ *   SELECT LINE:                                                    A3 A2 A1
+ *                                                                   --------
+ */
+#define        RXAVAIL         PP_STAT_SEL     /* Rx Available, channel 0.   0 0 0 */
+//  RXAVAIL1    PP_STAT_SEL             /* Rx Available, channel 1.   0 0 1 */
+#define        SYNC_STAT       PP_STAT_SEL     /* Reserved - Sync Status.    0 1 0 */
+//                                      /* Reserved.                  0 1 1 */
+#define        TXEMPTY         PP_STAT_SEL     /* Tx Empty, channel 0.       1 0 0 */
+//      TXEMPTY1        PP_STAT_SEL     /* Tx Empty, channel 1.       1 0 1 */
+//  TXEMPTY2    PP_STAT_SEL             /* Tx Empty, channel 2.       1 1 0 */
+//  TXEMPTY3    PP_STAT_SEL             /* Tx Empty, channel 3.       1 1 1 */
+
+/*   BUSY LINE:                                                      A3 A2 A1
+ *                                                                   --------
+ */
+#define        RXDATA          PP_STAT_BSY     /* Rx Input Data, channel 0.  0 0 0 */
+//      RXDATA1         PP_STAT_BSY     /* Rx Input Data, channel 1.  0 0 1 */
+#define        SYNC_DATA       PP_STAT_BSY     /* Reserved - Sync Data.      0 1 0 */
+                                       /* Reserved.                  0 1 1 */
+#define        DATA_ECHO       PP_STAT_BSY     /* Parallel Port Data Echo.   1 0 0 */
+#define        A0_ECHO         PP_STAT_BSY     /* Address 0 Echo.            1 0 1 */
+#define        A1_ECHO         PP_STAT_BSY     /* Address 1 Echo.            1 1 0 */
+#define        A2_ECHO         PP_STAT_BSY     /* Address 2 Echo.            1 1 1 */
+
+#define PORTMAN2X4_MODE_INPUT_TRIGGERED         0x01
+
+/*********************************************************************
+ * Hardware specific functions
+ *********************************************************************/
+static inline void portman_write_command(struct portman *pm, u8 value)
+{
+       parport_write_control(pm->pardev->port, value);
+}
+
+static inline u8 portman_read_command(struct portman *pm)
+{
+       return parport_read_control(pm->pardev->port);
+}
+
+static inline u8 portman_read_status(struct portman *pm)
+{
+       return parport_read_status(pm->pardev->port);
+}
+
+static inline u8 portman_read_data(struct portman *pm)
+{
+       return parport_read_data(pm->pardev->port);
+}
+
+static inline void portman_write_data(struct portman *pm, u8 value)
+{
+       parport_write_data(pm->pardev->port, value);
+}
+
+static void portman_write_midi(struct portman *pm, 
+                              int port, u8 mididata)
+{
+       int command = ((port + 4) << 1);
+
+       /* Get entering data byte and port number in BL and BH respectively.
+        * Set up Tx Channel address field for use with PP Cmd Register.
+        * Store address field in BH register.
+        * Inputs:      AH = Output port number (0..3).
+        *              AL = Data byte.
+        *    command = TXDATA0 | INT_EN;
+        * Align port num with address field (b1...b3),
+        * set address for TXDatax, Strobe=0
+        */
+       command |= INT_EN;
+
+       /* Disable interrupts so that the process is not interrupted, then 
+        * write the address associated with the current Tx channel to the 
+        * PP Command Reg.  Do not set the Strobe signal yet.
+        */
+
+       do {
+               portman_write_command(pm, command);
+
+               /* While the address lines settle, write parallel output data to 
+                * PP Data Reg.  This has no effect until Strobe signal is asserted.
+                */
+
+               portman_write_data(pm, mididata);
+               
+               /* If PCP channel's TxEmpty is set (TxEmpty is read through the PP
+                * Status Register), then go write data.  Else go back and wait.
+                */
+       } while ((portman_read_status(pm) & TXEMPTY) != TXEMPTY);
+
+       /* TxEmpty is set.  Maintain PC/P destination address and assert
+        * Strobe through the PP Command Reg.  This will Strobe data into
+        * the PC/P transmitter and set the PC/P BUSY signal.
+        */
+
+       portman_write_command(pm, command | STROBE);
+
+       /* Wait for strobe line to settle and echo back through hardware.
+        * Once it has echoed back, assume that the address and data lines
+        * have settled!
+        */
+
+       while ((portman_read_status(pm) & ESTB) == 0)
+               cpu_relax();
+
+       /* Release strobe and immediately re-allow interrupts. */
+       portman_write_command(pm, command);
+
+       while ((portman_read_status(pm) & ESTB) == ESTB)
+               cpu_relax();
+
+       /* PC/P BUSY is now set.  We must wait until BUSY resets itself.
+        * We'll reenable ints while we're waiting.
+        */
+
+       while ((portman_read_status(pm) & BUSY) == BUSY)
+               cpu_relax();
+
+       /* Data sent. */
+}
+
+
+/*
+ *  Read MIDI byte from port
+ *  Attempt to read input byte from specified hardware input port (0..).
+ *  Return -1 if no data
+ */
+static int portman_read_midi(struct portman *pm, int port)
+{
+       unsigned char midi_data = 0;
+       unsigned char cmdout;   /* Saved address+IE bit. */
+
+       /* Make sure clocking edge is down before starting... */
+       portman_write_data(pm, 0);      /* Make sure edge is down. */
+
+       /* Set destination address to PCP. */
+       cmdout = (port << 1) | INT_EN;  /* Address + IE + No Strobe. */
+       portman_write_command(pm, cmdout);
+
+       while ((portman_read_status(pm) & ESTB) == ESTB)
+               cpu_relax();    /* Wait for strobe echo. */
+
+       /* After the address lines settle, check multiplexed RxAvail signal.
+        * If data is available, read it.
+        */
+       if ((portman_read_status(pm) & RXAVAIL) == 0)
+               return -1;      /* No data. */
+
+       /* Set the Strobe signal to enable the Rx clocking circuitry. */
+       portman_write_command(pm, cmdout | STROBE);     /* Write address+IE+Strobe. */
+
+       while ((portman_read_status(pm) & ESTB) == 0)
+               cpu_relax(); /* Wait for strobe echo. */
+
+       /* The first data bit (msb) is already sitting on the input line. */
+       midi_data = (portman_read_status(pm) & 128);
+       portman_write_data(pm, 1);      /* Cause rising edge, which shifts data. */
+
+       /* Data bit 6. */
+       portman_write_data(pm, 0);      /* Cause falling edge while data settles. */
+       midi_data |= (portman_read_status(pm) >> 1) & 64;
+       portman_write_data(pm, 1);      /* Cause rising edge, which shifts data. */
+
+       /* Data bit 5. */
+       portman_write_data(pm, 0);      /* Cause falling edge while data settles. */
+       midi_data |= (portman_read_status(pm) >> 2) & 32;
+       portman_write_data(pm, 1);      /* Cause rising edge, which shifts data. */
+
+       /* Data bit 4. */
+       portman_write_data(pm, 0);      /* Cause falling edge while data settles. */
+       midi_data |= (portman_read_status(pm) >> 3) & 16;
+       portman_write_data(pm, 1);      /* Cause rising edge, which shifts data. */
+
+       /* Data bit 3. */
+       portman_write_data(pm, 0);      /* Cause falling edge while data settles. */
+       midi_data |= (portman_read_status(pm) >> 4) & 8;
+       portman_write_data(pm, 1);      /* Cause rising edge, which shifts data. */
+
+       /* Data bit 2. */
+       portman_write_data(pm, 0);      /* Cause falling edge while data settles. */
+       midi_data |= (portman_read_status(pm) >> 5) & 4;
+       portman_write_data(pm, 1);      /* Cause rising edge, which shifts data. */
+
+       /* Data bit 1. */
+       portman_write_data(pm, 0);      /* Cause falling edge while data settles. */
+       midi_data |= (portman_read_status(pm) >> 6) & 2;
+       portman_write_data(pm, 1);      /* Cause rising edge, which shifts data. */
+
+       /* Data bit 0. */
+       portman_write_data(pm, 0);      /* Cause falling edge while data settles. */
+       midi_data |= (portman_read_status(pm) >> 7) & 1;
+       portman_write_data(pm, 1);      /* Cause rising edge, which shifts data. */
+       portman_write_data(pm, 0);      /* Return data clock low. */
+
+
+       /* De-assert Strobe and return data. */
+       portman_write_command(pm, cmdout);      /* Output saved address+IE. */
+
+       /* Wait for strobe echo. */
+       while ((portman_read_status(pm) & ESTB) == ESTB)
+               cpu_relax();
+
+       return (midi_data & 255);       /* Shift back and return value. */
+}
+
+/*
+ *  Checks if any input data on the given channel is available
+ *  Checks RxAvail 
+ */
+static int portman_data_avail(struct portman *pm, int channel)
+{
+       int command = INT_EN;
+       switch (channel) {
+       case 0:
+               command |= RXDATA0;
+               break;
+       case 1:
+               command |= RXDATA1;
+               break;
+       }
+       /* Write hardware (assumme STROBE=0) */
+       portman_write_command(pm, command);
+       /* Check multiplexed RxAvail signal */
+       if ((portman_read_status(pm) & RXAVAIL) == RXAVAIL)
+               return 1;       /* Data available */
+
+       /* No Data available */
+       return 0;
+}
+
+
+/*
+ *  Flushes any input
+ */
+static void portman_flush_input(struct portman *pm, unsigned char port)
+{
+       /* Local variable for counting things */
+       unsigned int i = 0;
+       unsigned char command = 0;
+
+       switch (port) {
+       case 0:
+               command = RXDATA0;
+               break;
+       case 1:
+               command = RXDATA1;
+               break;
+       default:
+               snd_printk(KERN_WARNING
+                          "portman_flush_input() Won't flush port %i\n",
+                          port);
+               return;
+       }
+
+       /* Set address for specified channel in port and allow to settle. */
+       portman_write_command(pm, command);
+
+       /* Assert the Strobe and wait for echo back. */
+       portman_write_command(pm, command | STROBE);
+
+       /* Wait for ESTB */
+       while ((portman_read_status(pm) & ESTB) == 0)
+               cpu_relax();
+
+       /* Output clock cycles to the Rx circuitry. */
+       portman_write_data(pm, 0);
+
+       /* Flush 250 bits... */
+       for (i = 0; i < 250; i++) {
+               portman_write_data(pm, 1);
+               portman_write_data(pm, 0);
+       }
+
+       /* Deassert the Strobe signal of the port and wait for it to settle. */
+       portman_write_command(pm, command | INT_EN);
+
+       /* Wait for settling */
+       while ((portman_read_status(pm) & ESTB) == ESTB)
+               cpu_relax();
+}
+
+static int portman_probe(struct parport *p)
+{
+       /* Initialize the parallel port data register.  Will set Rx clocks
+        * low in case we happen to be addressing the Rx ports at this time.
+        */
+       /* 1 */
+       parport_write_data(p, 0);
+
+       /* Initialize the parallel port command register, thus initializing
+        * hardware handshake lines to midi box:
+        *
+        *                                  Strobe = 0
+        *                                  Interrupt Enable = 0            
+        */
+       /* 2 */
+       parport_write_control(p, 0);
+
+       /* Check if Portman PC/P 2x4 is out there. */
+       /* 3 */
+       parport_write_control(p, RXDATA0);      /* Write Strobe=0 to command reg. */
+
+       /* Check for ESTB to be clear */
+       /* 4 */
+       if ((parport_read_status(p) & ESTB) == ESTB)
+               return 1;       /* CODE 1 - Strobe Failure. */
+
+       /* Set for RXDATA0 where no damage will be done. */
+       /* 5 */
+       parport_write_control(p, RXDATA0 + STROBE);     /* Write Strobe=1 to command reg. */
+
+       /* 6 */
+       if ((parport_read_status(p) & ESTB) != ESTB)
+               return 1;       /* CODE 1 - Strobe Failure. */
+
+       /* 7 */
+       parport_write_control(p, 0);    /* Reset Strobe=0. */
+
+       /* Check if Tx circuitry is functioning properly.  If initialized 
+        * unit TxEmpty is false, send out char and see if if goes true.
+        */
+       /* 8 */
+       parport_write_control(p, TXDATA0);      /* Tx channel 0, strobe off. */
+
+       /* If PCP channel's TxEmpty is set (TxEmpty is read through the PP
+        * Status Register), then go write data.  Else go back and wait.
+        */
+       /* 9 */
+       if ((parport_read_status(p) & TXEMPTY) == 0)
+               return 2;
+
+       /* Return OK status. */
+       return 0;
+}
+
+static int portman_device_init(struct portman *pm)
+{
+       portman_flush_input(pm, 0);
+       portman_flush_input(pm, 1);
+
+       return 0;
+}
+
+/*********************************************************************
+ * Rawmidi
+ *********************************************************************/
+static int snd_portman_midi_open(struct snd_rawmidi_substream *substream)
+{
+       return 0;
+}
+
+static int snd_portman_midi_close(struct snd_rawmidi_substream *substream)
+{
+       return 0;
+}
+
+static void snd_portman_midi_input_trigger(struct snd_rawmidi_substream *substream,
+                                          int up)
+{
+       struct portman *pm = substream->rmidi->private_data;
+       unsigned long flags;
+
+       spin_lock_irqsave(&pm->reg_lock, flags);
+       if (up)
+               pm->mode[substream->number] |= PORTMAN2X4_MODE_INPUT_TRIGGERED;
+       else
+               pm->mode[substream->number] &= ~PORTMAN2X4_MODE_INPUT_TRIGGERED;
+       spin_unlock_irqrestore(&pm->reg_lock, flags);
+}
+
+static void snd_portman_midi_output_trigger(struct snd_rawmidi_substream *substream,
+                                           int up)
+{
+       struct portman *pm = substream->rmidi->private_data;
+       unsigned long flags;
+       unsigned char byte;
+
+       spin_lock_irqsave(&pm->reg_lock, flags);
+       if (up) {
+               while ((snd_rawmidi_transmit(substream, &byte, 1) == 1))
+                       portman_write_midi(pm, substream->number, byte);
+       }
+       spin_unlock_irqrestore(&pm->reg_lock, flags);
+}
+
+static struct snd_rawmidi_ops snd_portman_midi_output = {
+       .open =         snd_portman_midi_open,
+       .close =        snd_portman_midi_close,
+       .trigger =      snd_portman_midi_output_trigger,
+};
+
+static struct snd_rawmidi_ops snd_portman_midi_input = {
+       .open =         snd_portman_midi_open,
+       .close =        snd_portman_midi_close,
+       .trigger =      snd_portman_midi_input_trigger,
+};
+
+/* Create and initialize the rawmidi component */
+static int __devinit snd_portman_rawmidi_create(struct snd_card *card)
+{
+       struct portman *pm = card->private_data;
+       struct snd_rawmidi *rmidi;
+       struct snd_rawmidi_substream *substream;
+       int err;
+       
+       err = snd_rawmidi_new(card, CARD_NAME, 0, 
+                             PORTMAN_NUM_OUTPUT_PORTS, 
+                             PORTMAN_NUM_INPUT_PORTS, 
+                             &rmidi);
+       if (err < 0) 
+               return err;
+
+       rmidi->private_data = pm;
+       strcpy(rmidi->name, CARD_NAME);
+       rmidi->info_flags = SNDRV_RAWMIDI_INFO_OUTPUT |
+                           SNDRV_RAWMIDI_INFO_INPUT |
+                            SNDRV_RAWMIDI_INFO_DUPLEX;
+
+       pm->rmidi = rmidi;
+
+       /* register rawmidi ops */
+       snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, 
+                           &snd_portman_midi_output);
+       snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_INPUT, 
+                           &snd_portman_midi_input);
+
+       /* name substreams */
+       /* output */
+       list_for_each_entry(substream,
+                           &rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substreams,
+                           list) {
+               sprintf(substream->name,
+                       "Portman2x4 %d", substream->number+1);
+       }
+       /* input */
+       list_for_each_entry(substream,
+                           &rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT].substreams,
+                           list) {
+               pm->midi_input[substream->number] = substream;
+               sprintf(substream->name,
+                       "Portman2x4 %d", substream->number+1);
+       }
+
+       return err;
+}
+
+/*********************************************************************
+ * parport stuff
+ *********************************************************************/
+static void snd_portman_interrupt(int irq, void *userdata)
+{
+       unsigned char midivalue = 0;
+       struct portman *pm = ((struct snd_card*)userdata)->private_data;
+
+       spin_lock(&pm->reg_lock);
+
+       /* While any input data is waiting */
+       while ((portman_read_status(pm) & INT_REQ) == INT_REQ) {
+               /* If data available on channel 0, 
+                  read it and stuff it into the queue. */
+               if (portman_data_avail(pm, 0)) {
+                       /* Read Midi */
+                       midivalue = portman_read_midi(pm, 0);
+                       /* put midi into queue... */
+                       if (pm->mode[0] & PORTMAN2X4_MODE_INPUT_TRIGGERED)
+                               snd_rawmidi_receive(pm->midi_input[0],
+                                                   &midivalue, 1);
+
+               }
+               /* If data available on channel 1, 
+                  read it and stuff it into the queue. */
+               if (portman_data_avail(pm, 1)) {
+                       /* Read Midi */
+                       midivalue = portman_read_midi(pm, 1);
+                       /* put midi into queue... */
+                       if (pm->mode[1] & PORTMAN2X4_MODE_INPUT_TRIGGERED)
+                               snd_rawmidi_receive(pm->midi_input[1],
+                                                   &midivalue, 1);
+               }
+
+       }
+
+       spin_unlock(&pm->reg_lock);
+}
+
+static int __devinit snd_portman_probe_port(struct parport *p)
+{
+       struct pardevice *pardev;
+       int res;
+
+       pardev = parport_register_device(p, DRIVER_NAME,
+                                        NULL, NULL, NULL,
+                                        0, NULL);
+       if (!pardev)
+               return -EIO;
+       
+       if (parport_claim(pardev)) {
+               parport_unregister_device(pardev);
+               return -EIO;
+       }
+
+       res = portman_probe(p);
+
+       parport_release(pardev);
+       parport_unregister_device(pardev);
+
+       return res;
+}
+
+static void __devinit snd_portman_attach(struct parport *p)
+{
+       struct platform_device *device;
+
+       device = platform_device_alloc(PLATFORM_DRIVER, device_count);
+       if (!device) 
+               return;
+
+       /* Temporary assignment to forward the parport */
+       platform_set_drvdata(device, p);
+
+       if (platform_device_register(device) < 0) {
+               platform_device_put(device);
+               return;
+       }
+
+       /* Since we dont get the return value of probe
+        * We need to check if device probing succeeded or not */
+       if (!platform_get_drvdata(device)) {
+               platform_device_unregister(device);
+               return;
+       }
+
+       /* register device in global table */
+       platform_devices[device_count] = device;
+       device_count++;
+}
+
+static void snd_portman_detach(struct parport *p)
+{
+       /* nothing to do here */
+}
+
+static struct parport_driver portman_parport_driver = {
+       .name   = "portman2x4",
+       .attach = snd_portman_attach,
+       .detach = snd_portman_detach
+};
+
+/*********************************************************************
+ * platform stuff
+ *********************************************************************/
+static void snd_portman_card_private_free(struct snd_card *card)
+{
+       struct portman *pm = card->private_data;
+       struct pardevice *pardev = pm->pardev;
+
+       if (pardev) {
+               if (pm->pardev_claimed)
+                       parport_release(pardev);
+               parport_unregister_device(pardev);
+       }
+
+       portman_free(pm);
+}
+
+static int __devinit snd_portman_probe(struct platform_device *pdev)
+{
+       struct pardevice *pardev;
+       struct parport *p;
+       int dev = pdev->id;
+       struct snd_card *card = NULL;
+       struct portman *pm = NULL;
+       int err;
+
+       p = platform_get_drvdata(pdev);
+       platform_set_drvdata(pdev, NULL);
+
+       if (dev >= SNDRV_CARDS)
+               return -ENODEV;
+       if (!enable[dev]) 
+               return -ENOENT;
+
+       if ((err = snd_portman_probe_port(p)) < 0)
+               return err;
+
+       card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
+       if (card == NULL) {
+               snd_printd("Cannot create card\n");
+               return -ENOMEM;
+       }
+       strcpy(card->driver, DRIVER_NAME);
+       strcpy(card->shortname, CARD_NAME);
+       sprintf(card->longname,  "%s at 0x%lx, irq %i", 
+               card->shortname, p->base, p->irq);
+
+       pardev = parport_register_device(p,                     /* port */
+                                        DRIVER_NAME,           /* name */
+                                        NULL,                  /* preempt */
+                                        NULL,                  /* wakeup */
+                                        snd_portman_interrupt, /* ISR */
+                                        PARPORT_DEV_EXCL,      /* flags */
+                                        (void *)card);         /* private */
+       if (pardev == NULL) {
+               snd_printd("Cannot register pardevice\n");
+               err = -EIO;
+               goto __err;
+       }
+
+       if ((err = portman_create(card, pardev, &pm)) < 0) {
+               snd_printd("Cannot create main component\n");
+               parport_unregister_device(pardev);
+               goto __err;
+       }
+       card->private_data = pm;
+       card->private_free = snd_portman_card_private_free;
+       
+       if ((err = snd_portman_rawmidi_create(card)) < 0) {
+               snd_printd("Creating Rawmidi component failed\n");
+               goto __err;
+       }
+
+       /* claim parport */
+       if (parport_claim(pardev)) {
+               snd_printd("Cannot claim parport 0x%lx\n", pardev->port->base);
+               err = -EIO;
+               goto __err;
+       }
+       pm->pardev_claimed = 1;
+
+       /* init device */
+       if ((err = portman_device_init(pm)) < 0)
+               goto __err;
+
+       platform_set_drvdata(pdev, card);
+
+       /* At this point card will be usable */
+       if ((err = snd_card_register(card)) < 0) {
+               snd_printd("Cannot register card\n");
+               goto __err;
+       }
+
+       snd_printk(KERN_INFO "Portman 2x4 on 0x%lx\n", p->base);
+       return 0;
+
+__err:
+       snd_card_free(card);
+       return err;
+}
+
+static int snd_portman_remove(struct platform_device *pdev)
+{
+       struct snd_card *card = platform_get_drvdata(pdev);
+
+       if (card)
+               snd_card_free(card);
+
+       return 0;
+}
+
+
+static struct platform_driver snd_portman_driver = {
+       .probe  = snd_portman_probe,
+       .remove = snd_portman_remove,
+       .driver = {
+               .name = PLATFORM_DRIVER
+       }
+};
+
+/*********************************************************************
+ * module init stuff
+ *********************************************************************/
+static void snd_portman_unregister_all(void)
+{
+       int i;
+
+       for (i = 0; i < SNDRV_CARDS; ++i) {
+               if (platform_devices[i]) {
+                       platform_device_unregister(platform_devices[i]);
+                       platform_devices[i] = NULL;
+               }
+       }               
+       platform_driver_unregister(&snd_portman_driver);
+       parport_unregister_driver(&portman_parport_driver);
+}
+
+static int __init snd_portman_module_init(void)
+{
+       int err;
+
+       if ((err = platform_driver_register(&snd_portman_driver)) < 0)
+               return err;
+
+       if (parport_register_driver(&portman_parport_driver) != 0) {
+               platform_driver_unregister(&snd_portman_driver);
+               return -EIO;
+       }
+
+       if (device_count == 0) {
+               snd_portman_unregister_all();
+               return -ENODEV;
+       }
+
+       return 0;
+}
+
+static void __exit snd_portman_module_exit(void)
+{
+       snd_portman_unregister_all();
+}
+
+module_init(snd_portman_module_init);
+module_exit(snd_portman_module_exit);
index 74028b2219c2358b8ad4a67b9f99d024a7540cee..3a86a58207269c3169c6e6457a0700d2138b0728 100644 (file)
@@ -117,13 +117,13 @@ MODULE_PARM_DESC(adaptor, "Type of adaptor.");
 #define SERIAL_MODE_INPUT_TRIGGERED    (1 << 2)
 #define SERIAL_MODE_OUTPUT_TRIGGERED   (1 << 3)
 
-typedef struct _snd_uart16550 {
+struct snd_uart16550 {
        struct snd_card *card;
        struct snd_rawmidi *rmidi;
        struct snd_rawmidi_substream *midi_output[SNDRV_SERIAL_MAX_OUTS];
        struct snd_rawmidi_substream *midi_input[SNDRV_SERIAL_MAX_INS];
 
-       int filemode;           //open status of file
+       int filemode;           /* open status of file */
 
        spinlock_t open_lock;
 
@@ -140,39 +140,39 @@ typedef struct _snd_uart16550 {
        unsigned char old_divisor_msb;
        unsigned char old_line_ctrl_reg;
 
-       // parameter for using of write loop
-       short int fifo_limit;   //used in uart16550
-        short int fifo_count;  //used in uart16550
+       /* parameter for using of write loop */
+       short int fifo_limit;   /* used in uart16550 */
+        short int fifo_count;  /* used in uart16550 */
 
-       // type of adaptor
+       /* type of adaptor */
        int adaptor;
 
-       // inputs
+       /* inputs */
        int prev_in;
        unsigned char rstatus;
 
-       // outputs
+       /* outputs */
        int prev_out;
        unsigned char prev_status[SNDRV_SERIAL_MAX_OUTS];
 
-       // write buffer and its writing/reading position
+       /* write buffer and its writing/reading position */
        unsigned char tx_buff[TX_BUFF_SIZE];
        int buff_in_count;
         int buff_in;
         int buff_out;
         int drop_on_full;
 
-       // wait timer
+       /* wait timer */
        unsigned int timer_running:1;
        struct timer_list buffer_timer;
 
-} snd_uart16550_t;
+};
 
 static struct platform_device *devices[SNDRV_CARDS];
 
-static inline void snd_uart16550_add_timer(snd_uart16550_t *uart)
+static inline void snd_uart16550_add_timer(struct snd_uart16550 *uart)
 {
-       if (! uart->timer_running) {
+       if (!uart->timer_running) {
                /* timer 38600bps * 10bit * 16byte */
                uart->buffer_timer.expires = jiffies + (HZ+255)/256;
                uart->timer_running = 1;
@@ -180,7 +180,7 @@ static inline void snd_uart16550_add_timer(snd_uart16550_t *uart)
        }
 }
 
-static inline void snd_uart16550_del_timer(snd_uart16550_t *uart)
+static inline void snd_uart16550_del_timer(struct snd_uart16550 *uart)
 {
        if (uart->timer_running) {
                del_timer(&uart->buffer_timer);
@@ -189,10 +189,10 @@ static inline void snd_uart16550_del_timer(snd_uart16550_t *uart)
 }
 
 /* This macro is only used in snd_uart16550_io_loop */
-static inline void snd_uart16550_buffer_output(snd_uart16550_t *uart)
+static inline void snd_uart16550_buffer_output(struct snd_uart16550 *uart)
 {
        unsigned short buff_out = uart->buff_out;
-       if( uart->buff_in_count > 0 ) {
+       if (uart->buff_in_count > 0) {
                outb(uart->tx_buff[buff_out], uart->base + UART_TX);
                uart->fifo_count++;
                buff_out++;
@@ -206,7 +206,7 @@ static inline void snd_uart16550_buffer_output(snd_uart16550_t *uart)
  * We don't want to interrupt this, 
  * as we're already handling an interrupt 
  */
-static void snd_uart16550_io_loop(snd_uart16550_t * uart)
+static void snd_uart16550_io_loop(struct snd_uart16550 * uart)
 {
        unsigned char c, status;
        int substream;
@@ -220,9 +220,8 @@ static void snd_uart16550_io_loop(snd_uart16550_t * uart)
                c = inb(uart->base + UART_RX);
 
                /* keep track of last status byte */
-               if (c & 0x80) {
+               if (c & 0x80)
                        uart->rstatus = c;
-               }
 
                /* handle stream switch */
                if (uart->adaptor == SNDRV_SERIAL_GENERIC) {
@@ -230,14 +229,16 @@ static void snd_uart16550_io_loop(snd_uart16550_t * uart)
                                if (c <= SNDRV_SERIAL_MAX_INS && c > 0)
                                        substream = c - 1;
                                if (c != 0xf5)
-                                       uart->rstatus = 0; /* prevent future bytes from being interpreted as streams */
-                       }
-                       else if ((uart->filemode & SERIAL_MODE_INPUT_OPEN) && (uart->midi_input[substream] != NULL)) {
-                               snd_rawmidi_receive(uart->midi_input[substream], &c, 1);
-                       }
-               } else if ((uart->filemode & SERIAL_MODE_INPUT_OPEN) && (uart->midi_input[substream] != NULL)) {
+                                       /* prevent future bytes from being
+                                          interpreted as streams */
+                                       uart->rstatus = 0;
+                       } else if ((uart->filemode & SERIAL_MODE_INPUT_OPEN)
+                                  && uart->midi_input[substream])
+                               snd_rawmidi_receive(uart->midi_input[substream],
+                                                   &c, 1);
+               } else if ((uart->filemode & SERIAL_MODE_INPUT_OPEN) &&
+                          uart->midi_input[substream])
                        snd_rawmidi_receive(uart->midi_input[substream], &c, 1);
-               }
 
                if (status & UART_LSR_OE)
                        snd_printk("%s: Overrun on device at 0x%lx\n",
@@ -250,21 +251,20 @@ static void snd_uart16550_io_loop(snd_uart16550_t * uart)
        /* no need of check SERIAL_MODE_OUTPUT_OPEN because if not,
           buffer is never filled. */
        /* Check write status */
-       if (status & UART_LSR_THRE) {
+       if (status & UART_LSR_THRE)
                uart->fifo_count = 0;
-       }
        if (uart->adaptor == SNDRV_SERIAL_MS124W_SA
           || uart->adaptor == SNDRV_SERIAL_GENERIC) {
                /* Can't use FIFO, must send only when CTS is true */
                status = inb(uart->base + UART_MSR);
-               while( (uart->fifo_count == 0) && (status & UART_MSR_CTS) &&
-                     (uart->buff_in_count > 0) ) {
+               while (uart->fifo_count == 0 && (status & UART_MSR_CTS) &&
+                      uart->buff_in_count > 0) {
                       snd_uart16550_buffer_output(uart);
-                      status = inb( uart->base + UART_MSR );
+                      status = inb(uart->base + UART_MSR);
                }
        } else {
                /* Write loop */
-               while (uart->fifo_count < uart->fifo_limit      /* Can we write ? */
+               while (uart->fifo_count < uart->fifo_limit /* Can we write ? */
                       && uart->buff_in_count > 0)      /* Do we want to? */
                        snd_uart16550_buffer_output(uart);
        }
@@ -294,15 +294,16 @@ static void snd_uart16550_io_loop(snd_uart16550_t * uart)
  */
 static irqreturn_t snd_uart16550_interrupt(int irq, void *dev_id)
 {
-       snd_uart16550_t *uart;
+       struct snd_uart16550 *uart;
 
-       uart = (snd_uart16550_t *) dev_id;
+       uart = dev_id;
        spin_lock(&uart->open_lock);
        if (uart->filemode == SERIAL_MODE_NOT_OPENED) {
                spin_unlock(&uart->open_lock);
                return IRQ_NONE;
        }
-       inb(uart->base + UART_IIR);             /* indicate to the UART that the interrupt has been serviced */
+       /* indicate to the UART that the interrupt has been serviced */
+       inb(uart->base + UART_IIR);
        snd_uart16550_io_loop(uart);
        spin_unlock(&uart->open_lock);
        return IRQ_HANDLED;
@@ -312,9 +313,9 @@ static irqreturn_t snd_uart16550_interrupt(int irq, void *dev_id)
 static void snd_uart16550_buffer_timer(unsigned long data)
 {
        unsigned long flags;
-       snd_uart16550_t *uart;
+       struct snd_uart16550 *uart;
 
-       uart = (snd_uart16550_t *)data;
+       uart = (struct snd_uart16550 *)data;
        spin_lock_irqsave(&uart->open_lock, flags);
        snd_uart16550_del_timer(uart);
        snd_uart16550_io_loop(uart);
@@ -326,7 +327,7 @@ static void snd_uart16550_buffer_timer(unsigned long data)
  *  return 0 if found
  *  return negative error if not found
  */
-static int __init snd_uart16550_detect(snd_uart16550_t *uart)
+static int __init snd_uart16550_detect(struct snd_uart16550 *uart)
 {
        unsigned long io_base = uart->base;
        int ok;
@@ -343,7 +344,8 @@ static int __init snd_uart16550_detect(snd_uart16550_t *uart)
                return -EBUSY;
        }
 
-       ok = 1;                 /* uart detected unless one of the following tests should fail */
+       /* uart detected unless one of the following tests should fail */
+       ok = 1;
        /* 8 data-bits, 1 stop-bit, parity off, DLAB = 0 */
        outb(UART_LCR_WLEN8, io_base + UART_LCR); /* Line Control Register */
        c = inb(io_base + UART_IER);
@@ -368,7 +370,7 @@ static int __init snd_uart16550_detect(snd_uart16550_t *uart)
        return ok;
 }
 
-static void snd_uart16550_do_open(snd_uart16550_t * uart)
+static void snd_uart16550_do_open(struct snd_uart16550 * uart)
 {
        char byte;
 
@@ -460,7 +462,7 @@ static void snd_uart16550_do_open(snd_uart16550_t * uart)
        inb(uart->base + UART_RX);      /* Clear any pre-existing receive interrupt */
 }
 
-static void snd_uart16550_do_close(snd_uart16550_t * uart)
+static void snd_uart16550_do_close(struct snd_uart16550 * uart)
 {
        if (uart->irq < 0)
                snd_uart16550_del_timer(uart);
@@ -514,7 +516,7 @@ static void snd_uart16550_do_close(snd_uart16550_t * uart)
 static int snd_uart16550_input_open(struct snd_rawmidi_substream *substream)
 {
        unsigned long flags;
-       snd_uart16550_t *uart = substream->rmidi->private_data;
+       struct snd_uart16550 *uart = substream->rmidi->private_data;
 
        spin_lock_irqsave(&uart->open_lock, flags);
        if (uart->filemode == SERIAL_MODE_NOT_OPENED)
@@ -528,7 +530,7 @@ static int snd_uart16550_input_open(struct snd_rawmidi_substream *substream)
 static int snd_uart16550_input_close(struct snd_rawmidi_substream *substream)
 {
        unsigned long flags;
-       snd_uart16550_t *uart = substream->rmidi->private_data;
+       struct snd_uart16550 *uart = substream->rmidi->private_data;
 
        spin_lock_irqsave(&uart->open_lock, flags);
        uart->filemode &= ~SERIAL_MODE_INPUT_OPEN;
@@ -539,24 +541,24 @@ static int snd_uart16550_input_close(struct snd_rawmidi_substream *substream)
        return 0;
 }
 
-static void snd_uart16550_input_trigger(struct snd_rawmidi_substream *substream, int up)
+static void snd_uart16550_input_trigger(struct snd_rawmidi_substream *substream,
+                                       int up)
 {
        unsigned long flags;
-       snd_uart16550_t *uart = substream->rmidi->private_data;
+       struct snd_uart16550 *uart = substream->rmidi->private_data;
 
        spin_lock_irqsave(&uart->open_lock, flags);
-       if (up) {
+       if (up)
                uart->filemode |= SERIAL_MODE_INPUT_TRIGGERED;
-       } else {
+       else
                uart->filemode &= ~SERIAL_MODE_INPUT_TRIGGERED;
-       }
        spin_unlock_irqrestore(&uart->open_lock, flags);
 }
 
 static int snd_uart16550_output_open(struct snd_rawmidi_substream *substream)
 {
        unsigned long flags;
-       snd_uart16550_t *uart = substream->rmidi->private_data;
+       struct snd_uart16550 *uart = substream->rmidi->private_data;
 
        spin_lock_irqsave(&uart->open_lock, flags);
        if (uart->filemode == SERIAL_MODE_NOT_OPENED)
@@ -570,7 +572,7 @@ static int snd_uart16550_output_open(struct snd_rawmidi_substream *substream)
 static int snd_uart16550_output_close(struct snd_rawmidi_substream *substream)
 {
        unsigned long flags;
-       snd_uart16550_t *uart = substream->rmidi->private_data;
+       struct snd_uart16550 *uart = substream->rmidi->private_data;
 
        spin_lock_irqsave(&uart->open_lock, flags);
        uart->filemode &= ~SERIAL_MODE_OUTPUT_OPEN;
@@ -581,18 +583,20 @@ static int snd_uart16550_output_close(struct snd_rawmidi_substream *substream)
        return 0;
 };
 
-static inline int snd_uart16550_buffer_can_write( snd_uart16550_t *uart, int Num )
+static inline int snd_uart16550_buffer_can_write(struct snd_uart16550 *uart,
+                                                int Num)
 {
-       if( uart->buff_in_count + Num < TX_BUFF_SIZE )
+       if (uart->buff_in_count + Num < TX_BUFF_SIZE)
                return 1;
        else
                return 0;
 }
 
-static inline int snd_uart16550_write_buffer(snd_uart16550_t *uart, unsigned char byte)
+static inline int snd_uart16550_write_buffer(struct snd_uart16550 *uart,
+                                            unsigned char byte)
 {
        unsigned short buff_in = uart->buff_in;
-       if( uart->buff_in_count < TX_BUFF_SIZE ) {
+       if (uart->buff_in_count < TX_BUFF_SIZE) {
                uart->tx_buff[buff_in] = byte;
                buff_in++;
                buff_in &= TX_BUFF_MASK;
@@ -605,12 +609,14 @@ static inline int snd_uart16550_write_buffer(snd_uart16550_t *uart, unsigned cha
                return 0;
 }
 
-static int snd_uart16550_output_byte(snd_uart16550_t *uart, struct snd_rawmidi_substream *substream, unsigned char midi_byte)
+static int snd_uart16550_output_byte(struct snd_uart16550 *uart,
+                                    struct snd_rawmidi_substream *substream,
+                                    unsigned char midi_byte)
 {
-       if (uart->buff_in_count == 0                            /* Buffer empty? */
+       if (uart->buff_in_count == 0                    /* Buffer empty? */
            && ((uart->adaptor != SNDRV_SERIAL_MS124W_SA &&
            uart->adaptor != SNDRV_SERIAL_GENERIC) ||
-               (uart->fifo_count == 0                               /* FIFO empty? */
+               (uart->fifo_count == 0                  /* FIFO empty? */
                 && (inb(uart->base + UART_MSR) & UART_MSR_CTS)))) { /* CTS? */
 
                /* Tx Buffer Empty - try to write immediately */
@@ -623,12 +629,13 @@ static int snd_uart16550_output_byte(snd_uart16550_t *uart, struct snd_rawmidi_s
                                uart->fifo_count++;
                                outb(midi_byte, uart->base + UART_TX);
                        } else {
-                               /* Cannot write (buffer empty) - put char in buffer */
+                               /* Cannot write (buffer empty) -
+                                * put char in buffer */
                                snd_uart16550_write_buffer(uart, midi_byte);
                        }
                }
        } else {
-               if( !snd_uart16550_write_buffer(uart, midi_byte) ) {
+               if (!snd_uart16550_write_buffer(uart, midi_byte)) {
                        snd_printk("%s: Buffer overrun on device at 0x%lx\n",
                                   uart->rmidi->name, uart->base);
                        return 0;
@@ -642,9 +649,9 @@ static void snd_uart16550_output_write(struct snd_rawmidi_substream *substream)
 {
        unsigned long flags;
        unsigned char midi_byte, addr_byte;
-       snd_uart16550_t *uart = substream->rmidi->private_data;
+       struct snd_uart16550 *uart = substream->rmidi->private_data;
        char first;
-       static unsigned long lasttime=0;
+       static unsigned long lasttime = 0;
        
        /* Interupts are disabled during the updating of the tx_buff,
         * since it is 'bad' to have two processes updating the same
@@ -653,7 +660,7 @@ static void snd_uart16550_output_write(struct snd_rawmidi_substream *substream)
 
        spin_lock_irqsave(&uart->open_lock, flags);
 
-       if (uart->irq < 0)      //polling
+       if (uart->irq < 0)      /* polling */
                snd_uart16550_io_loop(uart);
 
        if (uart->adaptor == SNDRV_SERIAL_MS124W_MB) {
@@ -671,7 +678,8 @@ static void snd_uart16550_output_write(struct snd_rawmidi_substream *substream)
                        /* select any combination of the four ports */
                        addr_byte = (substream->number << 4) | 0x08;
                        /* ...except none */
-                       if (addr_byte == 0x08) addr_byte = 0xf8;
+                       if (addr_byte == 0x08)
+                               addr_byte = 0xf8;
 #endif
                        snd_uart16550_output_byte(uart, substream, addr_byte);
                        /* send midi byte */
@@ -679,31 +687,42 @@ static void snd_uart16550_output_write(struct snd_rawmidi_substream *substream)
                }
        } else {
                first = 0;
-               while( 1 == snd_rawmidi_transmit_peek(substream, &midi_byte, 1) ) {
-                       /* Also send F5 after 3 seconds with no data to handle device disconnect */
-                       if (first == 0 && (uart->adaptor == SNDRV_SERIAL_SOUNDCANVAS ||
-                               uart->adaptor == SNDRV_SERIAL_GENERIC) &&
-                          (uart->prev_out != substream->number || jiffies-lasttime > 3*HZ)) {
-
-                               if( snd_uart16550_buffer_can_write( uart, 3 ) ) {
+               while (snd_rawmidi_transmit_peek(substream, &midi_byte, 1) == 1) {
+                       /* Also send F5 after 3 seconds with no data
+                        * to handle device disconnect */
+                       if (first == 0 &&
+                           (uart->adaptor == SNDRV_SERIAL_SOUNDCANVAS ||
+                            uart->adaptor == SNDRV_SERIAL_GENERIC) &&
+                           (uart->prev_out != substream->number ||
+                            jiffies-lasttime > 3*HZ)) {
+
+                               if (snd_uart16550_buffer_can_write(uart, 3)) {
                                        /* Roland Soundcanvas part selection */
-                                       /* If this substream of the data is different previous
-                                          substream in this uart, send the change part event */
+                                       /* If this substream of the data is
+                                        * different previous substream
+                                        * in this uart, send the change part
+                                        * event
+                                        */
                                        uart->prev_out = substream->number;
                                        /* change part */
-                                       snd_uart16550_output_byte(uart, substream, 0xf5);
+                                       snd_uart16550_output_byte(uart, substream,
+                                                                 0xf5);
                                        /* data */
-                                       snd_uart16550_output_byte(uart, substream, uart->prev_out + 1);
-                                       /* If midi_byte is a data byte, send the previous status byte */
-                                       if ((midi_byte < 0x80) && (uart->adaptor == SNDRV_SERIAL_SOUNDCANVAS))
+                                       snd_uart16550_output_byte(uart, substream,
+                                                                 uart->prev_out + 1);
+                                       /* If midi_byte is a data byte,
+                                        * send the previous status byte */
+                                       if (midi_byte < 0x80 &&
+                                           uart->adaptor == SNDRV_SERIAL_SOUNDCANVAS)
                                                snd_uart16550_output_byte(uart, substream, uart->prev_status[uart->prev_out]);
-                               } else if( !uart->drop_on_full )
+                               } else if (!uart->drop_on_full)
                                        break;
 
                        }
 
                        /* send midi byte */
-                       if( !snd_uart16550_output_byte(uart, substream, midi_byte) && !uart->drop_on_full )
+                       if (!snd_uart16550_output_byte(uart, substream, midi_byte) &&
+                           !uart->drop_on_full )
                                break;
 
                        if (midi_byte >= 0x80 && midi_byte < 0xf0)
@@ -717,17 +736,17 @@ static void snd_uart16550_output_write(struct snd_rawmidi_substream *substream)
        spin_unlock_irqrestore(&uart->open_lock, flags);
 }
 
-static void snd_uart16550_output_trigger(struct snd_rawmidi_substream *substream, int up)
+static void snd_uart16550_output_trigger(struct snd_rawmidi_substream *substream,
+                                        int up)
 {
        unsigned long flags;
-       snd_uart16550_t *uart = substream->rmidi->private_data;
+       struct snd_uart16550 *uart = substream->rmidi->private_data;
 
        spin_lock_irqsave(&uart->open_lock, flags);
-       if (up) {
+       if (up)
                uart->filemode |= SERIAL_MODE_OUTPUT_TRIGGERED;
-       } else {
+       else
                uart->filemode &= ~SERIAL_MODE_OUTPUT_TRIGGERED;
-       }
        spin_unlock_irqrestore(&uart->open_lock, flags);
        if (up)
                snd_uart16550_output_write(substream);
@@ -747,10 +766,10 @@ static struct snd_rawmidi_ops snd_uart16550_input =
        .trigger =      snd_uart16550_input_trigger,
 };
 
-static int snd_uart16550_free(snd_uart16550_t *uart)
+static int snd_uart16550_free(struct snd_uart16550 *uart)
 {
        if (uart->irq >= 0)
-               free_irq(uart->irq, (void *)uart);
+               free_irq(uart->irq, uart);
        release_and_free_resource(uart->res_base);
        kfree(uart);
        return 0;
@@ -758,7 +777,7 @@ static int snd_uart16550_free(snd_uart16550_t *uart)
 
 static int snd_uart16550_dev_free(struct snd_device *device)
 {
-       snd_uart16550_t *uart = device->device_data;
+       struct snd_uart16550 *uart = device->device_data;
        return snd_uart16550_free(uart);
 }
 
@@ -769,12 +788,12 @@ static int __init snd_uart16550_create(struct snd_card *card,
                                       unsigned int base,
                                       int adaptor,
                                       int droponfull,
-                                      snd_uart16550_t **ruart)
+                                      struct snd_uart16550 **ruart)
 {
        static struct snd_device_ops ops = {
                .dev_free =     snd_uart16550_dev_free,
        };
-       snd_uart16550_t *uart;
+       struct snd_uart16550 *uart;
        int err;
 
 
@@ -795,7 +814,7 @@ static int __init snd_uart16550_create(struct snd_card *card,
 
        if (irq >= 0 && irq != SNDRV_AUTO_IRQ) {
                if (request_irq(irq, snd_uart16550_interrupt,
-                               IRQF_DISABLED, "Serial MIDI", (void *) uart)) {
+                               IRQF_DISABLED, "Serial MIDI", uart)) {
                        snd_printk("irq %d busy. Using Polling.\n", irq);
                } else {
                        uart->irq = irq;
@@ -843,23 +862,28 @@ static int __init snd_uart16550_create(struct snd_card *card,
 
 static void __init snd_uart16550_substreams(struct snd_rawmidi_str *stream)
 {
-       struct list_head *list;
+       struct snd_rawmidi_substream *substream;
 
-       list_for_each(list, &stream->substreams) {
-               struct snd_rawmidi_substream *substream = list_entry(list, struct snd_rawmidi_substream, list);
+       list_for_each_entry(substream, &stream->substreams, list) {
                sprintf(substream->name, "Serial MIDI %d", substream->number + 1);
        }
 }
 
-static int __init snd_uart16550_rmidi(snd_uart16550_t *uart, int device, int outs, int ins, struct snd_rawmidi **rmidi)
+static int __init snd_uart16550_rmidi(struct snd_uart16550 *uart, int device,
+                                     int outs, int ins,
+                                     struct snd_rawmidi **rmidi)
 {
        struct snd_rawmidi *rrawmidi;
        int err;
 
-       if ((err = snd_rawmidi_new(uart->card, "UART Serial MIDI", device, outs, ins, &rrawmidi)) < 0)
+       err = snd_rawmidi_new(uart->card, "UART Serial MIDI", device,
+                             outs, ins, &rrawmidi);
+       if (err < 0)
                return err;
-       snd_rawmidi_set_ops(rrawmidi, SNDRV_RAWMIDI_STREAM_INPUT, &snd_uart16550_input);
-       snd_rawmidi_set_ops(rrawmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, &snd_uart16550_output);
+       snd_rawmidi_set_ops(rrawmidi, SNDRV_RAWMIDI_STREAM_INPUT,
+                           &snd_uart16550_input);
+       snd_rawmidi_set_ops(rrawmidi, SNDRV_RAWMIDI_STREAM_OUTPUT,
+                           &snd_uart16550_output);
        strcpy(rrawmidi->name, "Serial MIDI");
        snd_uart16550_substreams(&rrawmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT]);
        snd_uart16550_substreams(&rrawmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT]);
@@ -875,7 +899,7 @@ static int __init snd_uart16550_rmidi(snd_uart16550_t *uart, int device, int out
 static int __init snd_serial_probe(struct platform_device *devptr)
 {
        struct snd_card *card;
-       snd_uart16550_t *uart;
+       struct snd_uart16550 *uart;
        int err;
        int dev = devptr->id;
 
@@ -929,7 +953,8 @@ static int __init snd_serial_probe(struct platform_device *devptr)
                                        &uart)) < 0)
                goto _err;
 
-       if ((err = snd_uart16550_rmidi(uart, 0, outs[dev], ins[dev], &uart->rmidi)) < 0)
+       err = snd_uart16550_rmidi(uart, 0, outs[dev], ins[dev], &uart->rmidi);
+       if (err < 0)
                goto _err;
 
        sprintf(card->longname, "%s at 0x%lx, irq %d speed %d div %d outs %d ins %d adaptor %s droponfull %d",
index 1613ed844ac6228e40574301511f72054a530a87..f63152a6a2234939b22d3f6308b881435dce81da 100644 (file)
@@ -716,7 +716,7 @@ static int vx_monitor_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_
        return 0;
 }
 
-static DECLARE_TLV_DB_SCALE(db_scale_audio_gain, -10975, 25, 0);
+static const DECLARE_TLV_DB_SCALE(db_scale_audio_gain, -10975, 25, 0);
 
 static struct snd_kcontrol_new vx_control_audio_gain = {
        .iface =        SNDRV_CTL_ELEM_IFACE_MIXER,
index 816a2e7c88ca88a62940d67fe288b17c678949e3..45902d48c89c78aaee72bb16b6e1b63691617ff3 100644 (file)
@@ -16,3 +16,4 @@ obj-$(CONFIG_SND) += other/
 # Toplevel Module Dependency
 obj-$(CONFIG_SND_INTERWAVE_STB) += snd-tea6330t.o snd-i2c.o
 obj-$(CONFIG_SND_ICE1712) += snd-cs8427.o snd-i2c.o
+obj-$(CONFIG_SND_ICE1724) += snd-i2c.o
index 2fe023ef00a7d643248bd47c97d473fabf0960c9..77a8a7c75dd9b0f21c9b5756a1d3715d7b8bda9b 100644 (file)
@@ -6,11 +6,11 @@
 snd-ak4114-objs := ak4114.o
 snd-ak4117-objs := ak4117.o
 snd-ak4xxx-adda-objs := ak4xxx-adda.o
+snd-pt2258-objs := pt2258.o
 snd-tea575x-tuner-objs := tea575x-tuner.o
 
 # Module Dependency
 obj-$(CONFIG_SND_PDAUDIOCF) += snd-ak4117.o
 obj-$(CONFIG_SND_ICE1712) += snd-ak4xxx-adda.o
-obj-$(CONFIG_SND_ICE1724) += snd-ak4xxx-adda.o
-obj-$(CONFIG_SND_ICE1724) += snd-ak4114.o
+obj-$(CONFIG_SND_ICE1724) += snd-ak4114.o snd-ak4xxx-adda.o snd-pt2258.o
 obj-$(CONFIG_SND_FM801_TEA575X) += snd-tea575x-tuner.o
index d2f2c5078e65d2b1885dac4380c7e732f23ef7fd..adbfd5884d0606cfce7547fc2757681ab2df746b 100644 (file)
@@ -42,8 +42,8 @@ static void reg_write(struct ak4114 *ak4114, unsigned char reg, unsigned char va
        ak4114->write(ak4114->private_data, reg, val);
        if (reg <= AK4114_REG_INT1_MASK)
                ak4114->regmap[reg] = val;
-       else if (reg >= AK4114_REG_RXCSB0 && reg <= AK4114_REG_TXCSB4)
-               ak4114->txcsb[reg-AK4114_REG_RXCSB0] = val;
+       else if (reg >= AK4114_REG_TXCSB0 && reg <= AK4114_REG_TXCSB4)
+               ak4114->txcsb[reg-AK4114_REG_TXCSB0] = val;
 }
 
 static inline unsigned char reg_read(struct ak4114 *ak4114, unsigned char reg)
@@ -66,10 +66,8 @@ static void snd_ak4114_free(struct ak4114 *chip)
 {
        chip->init = 1; /* don't schedule new work */
        mb();
-       if (chip->workqueue != NULL) {
-               flush_workqueue(chip->workqueue);
-               destroy_workqueue(chip->workqueue);
-       }
+       cancel_delayed_work(&chip->work);
+       flush_scheduled_work();
        kfree(chip);
 }
 
@@ -82,7 +80,7 @@ static int snd_ak4114_dev_free(struct snd_device *device)
 
 int snd_ak4114_create(struct snd_card *card,
                      ak4114_read_t *read, ak4114_write_t *write,
-                     unsigned char pgm[7], unsigned char txcsb[5],
+                     const unsigned char pgm[7], const unsigned char txcsb[5],
                      void *private_data, struct ak4114 **r_ak4114)
 {
        struct ak4114 *chip;
@@ -100,18 +98,13 @@ int snd_ak4114_create(struct snd_card *card,
        chip->read = read;
        chip->write = write;
        chip->private_data = private_data;
+       INIT_DELAYED_WORK(&chip->work, ak4114_stats);
 
        for (reg = 0; reg < 7; reg++)
                chip->regmap[reg] = pgm[reg];
        for (reg = 0; reg < 5; reg++)
                chip->txcsb[reg] = txcsb[reg];
 
-       chip->workqueue = create_workqueue("snd-ak4114");
-       if (chip->workqueue == NULL) {
-               kfree(chip);
-               return -ENOMEM;
-       }
-
        snd_ak4114_reinit(chip);
 
        chip->rcs0 = reg_read(chip, AK4114_REG_RCS0) & ~(AK4114_QINT | AK4114_CINT);
@@ -134,7 +127,8 @@ void snd_ak4114_reg_write(struct ak4114 *chip, unsigned char reg, unsigned char
        if (reg <= AK4114_REG_INT1_MASK)
                reg_write(chip, reg, (chip->regmap[reg] & ~mask) | val);
        else if (reg >= AK4114_REG_TXCSB0 && reg <= AK4114_REG_TXCSB4)
-               reg_write(chip, reg, (chip->txcsb[reg] & ~mask) | val);
+               reg_write(chip, reg,
+                         (chip->txcsb[reg-AK4114_REG_TXCSB0] & ~mask) | val);
 }
 
 void snd_ak4114_reinit(struct ak4114 *chip)
@@ -143,7 +137,7 @@ void snd_ak4114_reinit(struct ak4114 *chip)
 
        chip->init = 1;
        mb();
-       flush_workqueue(chip->workqueue);
+       flush_scheduled_work();
        /* bring the chip to reset state and powerdown state */
        reg_write(chip, AK4114_REG_PWRDN, old & ~(AK4114_RST|AK4114_PWN));
        udelay(200);
@@ -158,8 +152,7 @@ void snd_ak4114_reinit(struct ak4114 *chip)
        reg_write(chip, AK4114_REG_PWRDN, old | AK4114_RST | AK4114_PWN);
        /* bring up statistics / event queing */
        chip->init = 0;
-       INIT_DELAYED_WORK(&chip->work, ak4114_stats);
-       queue_delayed_work(chip->workqueue, &chip->work, HZ / 10);
+       schedule_delayed_work(&chip->work, HZ / 10);
 }
 
 static unsigned int external_rate(unsigned char rcs1)
@@ -568,7 +561,7 @@ static void ak4114_stats(struct work_struct *work)
        if (chip->init)
                return;
        snd_ak4114_check_rate_and_errors(chip, 0);
-       queue_delayed_work(chip->workqueue, &chip->work, HZ / 10);
+       schedule_delayed_work(&chip->work, HZ / 10);
 }
 
 EXPORT_SYMBOL(snd_ak4114_create);
index 4e45952dd95a78d292d62cca26381f3e496274d2..c022f29da2f744f192e903774f9ea87d03f78edc 100644 (file)
@@ -74,7 +74,7 @@ static int snd_ak4117_dev_free(struct snd_device *device)
 }
 
 int snd_ak4117_create(struct snd_card *card, ak4117_read_t *read, ak4117_write_t *write,
-                     unsigned char pgm[5], void *private_data, struct ak4117 **r_ak4117)
+                     const unsigned char pgm[5], void *private_data, struct ak4117 **r_ak4117)
 {
        struct ak4117 *chip;
        int err = 0;
index 5da49e2eb35047248abea410872d1a90921b5acc..8805110017a7ece661d519a2e19d737089245849 100644 (file)
@@ -140,7 +140,7 @@ EXPORT_SYMBOL(snd_akm4xxx_reset);
  * Used for AK4524 input/ouput attenuation, AK4528, and
  * AK5365 input attenuation
  */
-static unsigned char vol_cvt_datt[128] = {
+static const unsigned char vol_cvt_datt[128] = {
        0x00, 0x01, 0x01, 0x02, 0x02, 0x03, 0x03, 0x04,
        0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x06, 0x06,
        0x06, 0x07, 0x07, 0x08, 0x08, 0x08, 0x09, 0x0a,
@@ -162,17 +162,17 @@ static unsigned char vol_cvt_datt[128] = {
 /*
  * dB tables
  */
-static DECLARE_TLV_DB_SCALE(db_scale_vol_datt, -6350, 50, 1);
-static DECLARE_TLV_DB_SCALE(db_scale_8bit, -12750, 50, 1);
-static DECLARE_TLV_DB_SCALE(db_scale_7bit, -6350, 50, 1);
-static DECLARE_TLV_DB_LINEAR(db_scale_linear, TLV_DB_GAIN_MUTE, 0);
+static const DECLARE_TLV_DB_SCALE(db_scale_vol_datt, -6350, 50, 1);
+static const DECLARE_TLV_DB_SCALE(db_scale_8bit, -12750, 50, 1);
+static const DECLARE_TLV_DB_SCALE(db_scale_7bit, -6350, 50, 1);
+static const DECLARE_TLV_DB_LINEAR(db_scale_linear, TLV_DB_GAIN_MUTE, 0);
 
 /*
  * initialize all the ak4xxx chips
  */
 void snd_akm4xxx_init(struct snd_akm4xxx *ak)
 {
-       static unsigned char inits_ak4524[] = {
+       static const unsigned char inits_ak4524[] = {
                0x00, 0x07, /* 0: all power up */
                0x01, 0x00, /* 1: ADC/DAC reset */
                0x02, 0x60, /* 2: 24bit I2S */
@@ -184,7 +184,7 @@ void snd_akm4xxx_init(struct snd_akm4xxx *ak)
                0x07, 0x00, /* 7: DAC right muted */
                0xff, 0xff
        };
-       static unsigned char inits_ak4528[] = {
+       static const unsigned char inits_ak4528[] = {
                0x00, 0x07, /* 0: all power up */
                0x01, 0x00, /* 1: ADC/DAC reset */
                0x02, 0x60, /* 2: 24bit I2S */
@@ -194,7 +194,7 @@ void snd_akm4xxx_init(struct snd_akm4xxx *ak)
                0x05, 0x00, /* 5: ADC right muted */
                0xff, 0xff
        };
-       static unsigned char inits_ak4529[] = {
+       static const unsigned char inits_ak4529[] = {
                0x09, 0x01, /* 9: ATS=0, RSTN=1 */
                0x0a, 0x3f, /* A: all power up, no zero/overflow detection */
                0x00, 0x0c, /* 0: TDM=0, 24bit I2S, SMUTE=0 */
@@ -210,7 +210,7 @@ void snd_akm4xxx_init(struct snd_akm4xxx *ak)
                0x08, 0x55, /* 8: deemphasis all off */
                0xff, 0xff
        };
-       static unsigned char inits_ak4355[] = {
+       static const unsigned char inits_ak4355[] = {
                0x01, 0x02, /* 1: reset and soft-mute */
                0x00, 0x06, /* 0: mode3(i2s), disable auto-clock detect,
                             * disable DZF, sharp roll-off, RSTN#=0 */
@@ -227,7 +227,7 @@ void snd_akm4xxx_init(struct snd_akm4xxx *ak)
                0x01, 0x01, /* 1: un-reset, unmute */
                0xff, 0xff
        };
-       static unsigned char inits_ak4358[] = {
+       static const unsigned char inits_ak4358[] = {
                0x01, 0x02, /* 1: reset and soft-mute */
                0x00, 0x06, /* 0: mode3(i2s), disable auto-clock detect,
                             * disable DZF, sharp roll-off, RSTN#=0 */
@@ -246,7 +246,7 @@ void snd_akm4xxx_init(struct snd_akm4xxx *ak)
                0x01, 0x01, /* 1: un-reset, unmute */
                0xff, 0xff
        };
-       static unsigned char inits_ak4381[] = {
+       static const unsigned char inits_ak4381[] = {
                0x00, 0x0c, /* 0: mode3(i2s), disable auto-clock detect */
                0x01, 0x02, /* 1: de-emphasis off, normal speed,
                             * sharp roll-off, DZF off */
@@ -259,7 +259,8 @@ void snd_akm4xxx_init(struct snd_akm4xxx *ak)
        };
 
        int chip, num_chips;
-       unsigned char *ptr, reg, data, *inits;
+       const unsigned char *ptr, *inits;
+       unsigned char reg, data;
 
        memset(ak->images, 0, sizeof(ak->images));
        memset(ak->volumes, 0, sizeof(ak->volumes));
@@ -513,6 +514,66 @@ static int ak4xxx_switch_put(struct snd_kcontrol *kcontrol,
        return change;
 }
 
+#define AK5365_NUM_INPUTS 5
+
+static int ak4xxx_capture_source_info(struct snd_kcontrol *kcontrol,
+                                     struct snd_ctl_elem_info *uinfo)
+{
+       struct snd_akm4xxx *ak = snd_kcontrol_chip(kcontrol);
+       int mixer_ch = AK_GET_SHIFT(kcontrol->private_value);
+       const char **input_names;
+       int  num_names, idx;
+
+       input_names = ak->adc_info[mixer_ch].input_names;
+
+       num_names = 0;
+       while (num_names < AK5365_NUM_INPUTS && input_names[num_names])
+               ++num_names;
+       
+       uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
+       uinfo->count = 1;
+       uinfo->value.enumerated.items = num_names;
+       idx = uinfo->value.enumerated.item;
+       if (idx >= num_names)
+               return -EINVAL;
+       strncpy(uinfo->value.enumerated.name, input_names[idx],
+               sizeof(uinfo->value.enumerated.name));
+       return 0;
+}
+
+static int ak4xxx_capture_source_get(struct snd_kcontrol *kcontrol,
+                                    struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_akm4xxx *ak = snd_kcontrol_chip(kcontrol);
+       int chip = AK_GET_CHIP(kcontrol->private_value);
+       int addr = AK_GET_ADDR(kcontrol->private_value);
+       int mask = AK_GET_MASK(kcontrol->private_value);
+       unsigned char val;
+
+       val = snd_akm4xxx_get(ak, chip, addr) & mask;
+       ucontrol->value.enumerated.item[0] = val;
+       return 0;
+}
+
+static int ak4xxx_capture_source_put(struct snd_kcontrol *kcontrol,
+                                    struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_akm4xxx *ak = snd_kcontrol_chip(kcontrol);
+       int chip = AK_GET_CHIP(kcontrol->private_value);
+       int addr = AK_GET_ADDR(kcontrol->private_value);
+       int mask = AK_GET_MASK(kcontrol->private_value);
+       unsigned char oval, val;
+
+       oval = snd_akm4xxx_get(ak, chip, addr);
+       val = oval & ~mask;
+       val |= ucontrol->value.enumerated.item[0] & mask;
+       if (val != oval) {
+               snd_akm4xxx_write(ak, chip, addr, val);
+               return 1;
+       }
+       return 0;
+}
+
 /*
  * build AK4xxx controls
  */
@@ -647,9 +708,10 @@ static int build_adc_controls(struct snd_akm4xxx *ak)
 
                if (ak->type == SND_AK5365 && (idx % 2) == 0) {
                        if (! ak->adc_info || 
-                           ! ak->adc_info[mixer_ch].switch_name)
+                           ! ak->adc_info[mixer_ch].switch_name) {
                                knew.name = "Capture Switch";
-                       else
+                               knew.index = mixer_ch + ak->idx_offset * 2;
+                       } else
                                knew.name = ak->adc_info[mixer_ch].switch_name;
                        knew.info = ak4xxx_switch_info;
                        knew.get = ak4xxx_switch_get;
@@ -662,6 +724,26 @@ static int build_adc_controls(struct snd_akm4xxx *ak)
                        err = snd_ctl_add(ak->card, snd_ctl_new1(&knew, ak));
                        if (err < 0)
                                return err;
+
+                       memset(&knew, 0, sizeof(knew));
+                       knew.name = ak->adc_info[mixer_ch].selector_name;
+                       if (!knew.name) {
+                               knew.name = "Capture Channel";
+                               knew.index = mixer_ch + ak->idx_offset * 2;
+                       }
+
+                       knew.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
+                       knew.info = ak4xxx_capture_source_info;
+                       knew.get = ak4xxx_capture_source_get;
+                       knew.put = ak4xxx_capture_source_put;
+                       knew.access = 0;
+                       /* input selector control: reg. 1, bits 0-2.
+                        * mis-use 'shift' to pass mixer_ch */
+                       knew.private_value
+                               = AK_COMPOSE(idx/2, 1, mixer_ch, 0x07);
+                       err = snd_ctl_add(ak->card, snd_ctl_new1(&knew, ak));
+                       if (err < 0)
+                               return err;
                }
 
                idx += num_stereo;
diff --git a/sound/i2c/other/pt2258.c b/sound/i2c/other/pt2258.c
new file mode 100644 (file)
index 0000000..e91cc3b
--- /dev/null
@@ -0,0 +1,233 @@
+/*
+ *   ALSA Driver for the PT2258 volume controller.
+ *
+ *     Copyright (c) 2006  Jochen Voss <voss@seehuhn.de>
+ *
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+ *
+ */      
+
+#include <sound/driver.h>
+#include <sound/core.h>
+#include <sound/control.h>
+#include <sound/tlv.h>
+#include <sound/i2c.h>
+#include <sound/pt2258.h>
+
+MODULE_AUTHOR("Jochen Voss <voss@seehuhn.de>");
+MODULE_DESCRIPTION("PT2258 volume controller (Princeton Technology Corp.)");
+MODULE_LICENSE("GPL");
+
+#define PT2258_CMD_RESET 0xc0
+#define PT2258_CMD_UNMUTE 0xf8
+#define PT2258_CMD_MUTE 0xf9
+
+static const unsigned char pt2258_channel_code[12] = {
+       0x80, 0x90,             /* channel 1: -10dB, -1dB */
+       0x40, 0x50,             /* channel 2: -10dB, -1dB */
+       0x00, 0x10,             /* channel 3: -10dB, -1dB */
+       0x20, 0x30,             /* channel 4: -10dB, -1dB */
+       0x60, 0x70,             /* channel 5: -10dB, -1dB */
+       0xa0, 0xb0              /* channel 6: -10dB, -1dB */
+};
+
+int snd_pt2258_reset(struct snd_pt2258 *pt)
+{
+       unsigned char bytes[2];
+       int i;
+
+       /* reset chip */
+       bytes[0] = PT2258_CMD_RESET;
+       snd_i2c_lock(pt->i2c_bus);
+       if (snd_i2c_sendbytes(pt->i2c_dev, bytes, 1) != 1)
+               goto __error;
+       snd_i2c_unlock(pt->i2c_bus);
+
+       /* mute all channels */
+       pt->mute = 1;
+       bytes[0] = PT2258_CMD_MUTE;
+       snd_i2c_lock(pt->i2c_bus);
+       if (snd_i2c_sendbytes(pt->i2c_dev, bytes, 1) != 1)
+               goto __error;
+       snd_i2c_unlock(pt->i2c_bus);
+
+       /* set all channels to 0dB */
+       for (i = 0; i < 6; ++i)
+               pt->volume[i] = 0;
+       bytes[0] = 0xd0;
+       bytes[1] = 0xe0;
+       snd_i2c_lock(pt->i2c_bus);
+       if (snd_i2c_sendbytes(pt->i2c_dev, bytes, 2) != 2)
+               goto __error;
+       snd_i2c_unlock(pt->i2c_bus);
+
+       return 0;
+
+      __error:
+       snd_i2c_unlock(pt->i2c_bus);
+       snd_printk(KERN_ERR "PT2258 reset failed\n");
+       return -EIO;
+}
+
+static int pt2258_stereo_volume_info(struct snd_kcontrol *kcontrol,
+                                    struct snd_ctl_elem_info *uinfo)
+{
+       uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
+       uinfo->count = 2;
+       uinfo->value.integer.min = 0;
+       uinfo->value.integer.max = 79;
+       return 0;
+}
+
+static int pt2258_stereo_volume_get(struct snd_kcontrol *kcontrol,
+                                   struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_pt2258 *pt = kcontrol->private_data;
+       int base = kcontrol->private_value;
+
+       /* chip does not support register reads */
+       ucontrol->value.integer.value[0] = 79 - pt->volume[base];
+       ucontrol->value.integer.value[1] = 79 - pt->volume[base + 1];
+       return 0;
+}
+
+static int pt2258_stereo_volume_put(struct snd_kcontrol *kcontrol,
+                                   struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_pt2258 *pt = kcontrol->private_data;
+       int base = kcontrol->private_value;
+       unsigned char bytes[2];
+       int val0, val1;
+
+       val0 = 79 - ucontrol->value.integer.value[0];
+       val1 = 79 - ucontrol->value.integer.value[1];
+       if (val0 == pt->volume[base] && val1 == pt->volume[base + 1])
+               return 0;
+
+       pt->volume[base] = val0;
+       bytes[0] = pt2258_channel_code[2 * base] | (val0 / 10);
+       bytes[1] = pt2258_channel_code[2 * base + 1] | (val0 % 10);
+       snd_i2c_lock(pt->i2c_bus);
+       if (snd_i2c_sendbytes(pt->i2c_dev, bytes, 2) != 2)
+               goto __error;
+       snd_i2c_unlock(pt->i2c_bus);
+
+       pt->volume[base + 1] = val1;
+       bytes[0] = pt2258_channel_code[2 * base + 2] | (val1 / 10);
+       bytes[1] = pt2258_channel_code[2 * base + 3] | (val1 % 10);
+       snd_i2c_lock(pt->i2c_bus);
+       if (snd_i2c_sendbytes(pt->i2c_dev, bytes, 2) != 2)
+               goto __error;
+       snd_i2c_unlock(pt->i2c_bus);
+
+       return 1;
+
+      __error:
+       snd_i2c_unlock(pt->i2c_bus);
+       snd_printk(KERN_ERR "PT2258 access failed\n");
+       return -EIO;
+}
+
+static int pt2258_switch_info(struct snd_kcontrol *kcontrol,
+                             struct snd_ctl_elem_info *uinfo)
+{
+       uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
+       uinfo->count = 1;
+       uinfo->value.integer.min = 0;
+       uinfo->value.integer.max = 1;
+       return 0;
+}
+
+static int pt2258_switch_get(struct snd_kcontrol *kcontrol,
+                            struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_pt2258 *pt = kcontrol->private_data;
+
+       ucontrol->value.integer.value[0] = !pt->mute;
+       return 0;
+}
+
+static int pt2258_switch_put(struct snd_kcontrol *kcontrol,
+                            struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_pt2258 *pt = kcontrol->private_data;
+       unsigned char bytes[2];
+       int val;
+
+       val = !ucontrol->value.integer.value[0];
+       if (pt->mute == val)
+               return 0;
+
+       pt->mute = val;
+       bytes[0] = val ? PT2258_CMD_MUTE : PT2258_CMD_UNMUTE;
+       snd_i2c_lock(pt->i2c_bus);
+       if (snd_i2c_sendbytes(pt->i2c_dev, bytes, 1) != 1)
+               goto __error;
+       snd_i2c_unlock(pt->i2c_bus);
+
+       return 1;
+
+      __error:
+       snd_i2c_unlock(pt->i2c_bus);
+       snd_printk(KERN_ERR "PT2258 access failed 2\n");
+       return -EIO;
+}
+
+static const DECLARE_TLV_DB_SCALE(pt2258_db_scale, -7900, 100, 0);
+
+int snd_pt2258_build_controls(struct snd_pt2258 *pt)
+{
+       struct snd_kcontrol_new knew;
+       char *names[3] = {
+               "Mic Loopback Playback Volume",
+               "Line Loopback Playback Volume",
+               "CD Loopback Playback Volume"
+       };
+       int i, err;
+
+       for (i = 0; i < 3; ++i) {
+               memset(&knew, 0, sizeof(knew));
+               knew.name = names[i];
+               knew.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
+               knew.count = 1;
+               knew.access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
+                   SNDRV_CTL_ELEM_ACCESS_TLV_READ;
+               knew.private_value = 2 * i;
+               knew.info = pt2258_stereo_volume_info;
+               knew.get = pt2258_stereo_volume_get;
+               knew.put = pt2258_stereo_volume_put;
+               knew.tlv.p = pt2258_db_scale;
+
+               err = snd_ctl_add(pt->card, snd_ctl_new1(&knew, pt));
+               if (err < 0)
+                       return err;
+       }
+
+       memset(&knew, 0, sizeof(knew));
+       knew.name = "Loopback Switch";
+       knew.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
+       knew.info = pt2258_switch_info;
+       knew.get = pt2258_switch_get;
+       knew.put = pt2258_switch_put;
+       knew.access = 0;
+       err = snd_ctl_add(pt->card, snd_ctl_new1(&knew, pt));
+       if (err < 0)
+               return err;
+
+       return 0;
+}
+
+EXPORT_SYMBOL(snd_pt2258_reset);
+EXPORT_SYMBOL(snd_pt2258_build_controls);
index 57371f1a441f4ed0da9a4a81791e0415886e75ae..4e3a9729f56968d7f3077c27228068521af89536 100644 (file)
@@ -358,6 +358,7 @@ config SND_SBAWE
 config SND_SB16_CSP
        bool "Sound Blaster 16/AWE CSP support"
        depends on (SND_SB16 || SND_SBAWE) && (BROKEN || !PPC)
+       select FW_LOADER
        help
          Say Y here to include support for the CSP core.  This special
          coprocessor can do variable tasks like various compression and
@@ -390,6 +391,7 @@ config SND_SSCAPE
 config SND_WAVEFRONT
        tristate "Turtle Beach Maui,Tropez,Tropez+ (Wavefront)"
        depends on SND
+       select FW_LOADER
        select SND_OPL3_LIB
        select SND_MPU401_UART
        select SND_CS4231_LIB
index b524e0d9ee44262ac87a30904a05cc125fee8a9f..ec9209cd517784f201316c21a2adcb49e048fe95 100644 (file)
@@ -906,11 +906,11 @@ static int snd_ad1816a_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_
        return change;
 }
 
-static DECLARE_TLV_DB_SCALE(db_scale_4bit, -4500, 300, 0);
-static DECLARE_TLV_DB_SCALE(db_scale_5bit, -4650, 150, 0);
-static DECLARE_TLV_DB_SCALE(db_scale_6bit, -9450, 150, 0);
-static DECLARE_TLV_DB_SCALE(db_scale_5bit_12db_max, -3450, 150, 0);
-static DECLARE_TLV_DB_SCALE(db_scale_rec_gain, 0, 150, 0);
+static const DECLARE_TLV_DB_SCALE(db_scale_4bit, -4500, 300, 0);
+static const DECLARE_TLV_DB_SCALE(db_scale_5bit, -4650, 150, 0);
+static const DECLARE_TLV_DB_SCALE(db_scale_6bit, -9450, 150, 0);
+static const DECLARE_TLV_DB_SCALE(db_scale_5bit_12db_max, -3450, 150, 0);
+static const DECLARE_TLV_DB_SCALE(db_scale_rec_gain, 0, 150, 0);
 
 static struct snd_kcontrol_new snd_ad1816a_controls[] __devinitdata = {
 AD1816A_DOUBLE("Master Playback Switch", AD1816A_MASTER_ATT, 15, 7, 1, 1),
index 666b3bcc19f0d64216874418024ebd1260d4edbb..8094282c2ae1992d76f588018b28ad2390d44e3e 100644 (file)
@@ -1223,9 +1223,9 @@ int snd_ad1848_add_ctl_elem(struct snd_ad1848 *chip,
 
 EXPORT_SYMBOL(snd_ad1848_add_ctl_elem);
 
-static DECLARE_TLV_DB_SCALE(db_scale_6bit, -9450, 150, 0);
-static DECLARE_TLV_DB_SCALE(db_scale_5bit_12db_max, -3450, 150, 0);
-static DECLARE_TLV_DB_SCALE(db_scale_rec_gain, 0, 150, 0);
+static const DECLARE_TLV_DB_SCALE(db_scale_6bit, -9450, 150, 0);
+static const DECLARE_TLV_DB_SCALE(db_scale_5bit_12db_max, -3450, 150, 0);
+static const DECLARE_TLV_DB_SCALE(db_scale_rec_gain, 0, 150, 0);
 
 static struct ad1848_mix_elem snd_ad1848_controls[] = {
 AD1848_DOUBLE("PCM Playback Switch", 0, AD1848_LEFT_OUTPUT, AD1848_RIGHT_OUTPUT, 7, 7, 1, 1),
index b680fddf0d740f86aebd7998c10ad632055b22fa..8ced5e81b9a7049371aa968901c696a5d8e840f1 100644 (file)
@@ -294,10 +294,10 @@ static int snd_gus_init_dma_irq(struct snd_gus_card * gus, int latches)
                gus->mix_cntrl_reg |= 4;        /* enable MIC */
        }
        dma1 = gus->gf1.dma1;
-       dma1 = dma1 < 0 ? -dma1 : dma1;
+       dma1 = abs(dma1);
        dma1 = dmas[dma1 & 7];
        dma2 = gus->gf1.dma2;
-       dma2 = dma2 < 0 ? -dma2 : dma2;
+       dma2 = abs(dma2);
        dma2 = dmas[dma2 & 7];
        dma1 |= gus->equal_dma ? 0x40 : (dma2 << 3);
 
@@ -306,7 +306,7 @@ static int snd_gus_init_dma_irq(struct snd_gus_card * gus, int latches)
                return -EINVAL;
        }
        irq = gus->gf1.irq;
-       irq = irq < 0 ? -irq : irq;
+       irq = abs(irq);
        irq = irqs[irq & 0x0f];
        if (irq == 0) {
                snd_printk(KERN_ERR "Error! IRQ isn't defined.\n");
index 419b4ebbf00eaf7fe874d41d857adc3f8a224fb5..1e30713d2cada591a3a3228adf600356715227e8 100644 (file)
@@ -486,8 +486,8 @@ static int snd_opl3sa2_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_
        return change;
 }
 
-static DECLARE_TLV_DB_SCALE(db_scale_master, -3000, 200, 0);
-static DECLARE_TLV_DB_SCALE(db_scale_5bit_12db_max, -3450, 150, 0);
+static const DECLARE_TLV_DB_SCALE(db_scale_master, -3000, 200, 0);
+static const DECLARE_TLV_DB_SCALE(db_scale_5bit_12db_max, -3450, 150, 0);
 
 static struct snd_kcontrol_new snd_opl3sa2_controls[] = {
 OPL3SA2_DOUBLE("Master Playback Switch", 0, 0x07, 0x08, 7, 7, 1, 1),
index fcd638090a9e036195dc11d1f18057d38e09595a..3d9d7e0107cad3828aa74b0fa4935bea38a5b26a 100644 (file)
@@ -161,10 +161,13 @@ int snd_sb_csp_new(struct snd_sb *chip, int device, struct snd_hwdep ** rhwdep)
  */
 static void snd_sb_csp_free(struct snd_hwdep *hwdep)
 {
+       int i;
        struct snd_sb_csp *p = hwdep->private_data;
        if (p) {
                if (p->running & SNDRV_SB_CSP_ST_RUNNING)
                        snd_sb_csp_stop(p);
+               for (i = 0; i < ARRAY_SIZE(p->csp_programs); ++i)
+                       release_firmware(p->csp_programs[i]);
                kfree(p);
        }
 }
@@ -687,8 +690,50 @@ static int snd_sb_csp_load_user(struct snd_sb_csp * p, const unsigned char __use
        return err;
 }
 
+#define FIRMWARE_IN_THE_KERNEL
+
+#ifdef FIRMWARE_IN_THE_KERNEL
 #include "sb16_csp_codecs.h"
 
+static const struct firmware snd_sb_csp_static_programs[] = {
+       { .data = mulaw_main, .size = sizeof mulaw_main },
+       { .data = alaw_main, .size = sizeof alaw_main },
+       { .data = ima_adpcm_init, .size = sizeof ima_adpcm_init },
+       { .data = ima_adpcm_playback, .size = sizeof ima_adpcm_playback },
+       { .data = ima_adpcm_capture, .size = sizeof ima_adpcm_capture },
+};
+#endif
+
+static int snd_sb_csp_firmware_load(struct snd_sb_csp *p, int index, int flags)
+{
+       static const char *const names[] = {
+               "sb16/mulaw_main.csp",
+               "sb16/alaw_main.csp",
+               "sb16/ima_adpcm_init.csp",
+               "sb16/ima_adpcm_playback.csp",
+               "sb16/ima_adpcm_capture.csp",
+       };
+       const struct firmware *program;
+       int err;
+
+       BUILD_BUG_ON(ARRAY_SIZE(names) != CSP_PROGRAM_COUNT);
+       program = p->csp_programs[index];
+       if (!program) {
+               err = request_firmware(&program, names[index],
+                                      p->chip->card->dev);
+               if (err >= 0)
+                       p->csp_programs[index] = program;
+               else {
+#ifdef FIRMWARE_IN_THE_KERNEL
+                       program = &snd_sb_csp_static_programs[index];
+#else
+                       return err;
+#endif
+               }
+       }
+       return snd_sb_csp_load(p, program->data, program->size, flags);
+}
+
 /*
  * autoload hardware codec if necessary
  * return 0 if CSP is loaded and ready to run (p->running != 0)
@@ -708,27 +753,27 @@ static int snd_sb_csp_autoload(struct snd_sb_csp * p, int pcm_sfmt, int play_rec
        } else {
                switch (pcm_sfmt) {
                case SNDRV_PCM_FORMAT_MU_LAW:
-                       err = snd_sb_csp_load(p, &mulaw_main[0], sizeof(mulaw_main), 0);
+                       err = snd_sb_csp_firmware_load(p, CSP_PROGRAM_MULAW, 0);
                        p->acc_format = SNDRV_PCM_FMTBIT_MU_LAW;
                        p->mode = SNDRV_SB_CSP_MODE_DSP_READ | SNDRV_SB_CSP_MODE_DSP_WRITE;
                        break;
                case SNDRV_PCM_FORMAT_A_LAW:
-                       err = snd_sb_csp_load(p, &alaw_main[0], sizeof(alaw_main), 0);
+                       err = snd_sb_csp_firmware_load(p, CSP_PROGRAM_ALAW, 0);
                        p->acc_format = SNDRV_PCM_FMTBIT_A_LAW;
                        p->mode = SNDRV_SB_CSP_MODE_DSP_READ | SNDRV_SB_CSP_MODE_DSP_WRITE;
                        break;
                case SNDRV_PCM_FORMAT_IMA_ADPCM:
-                       err = snd_sb_csp_load(p, &ima_adpcm_init[0], sizeof(ima_adpcm_init),
-                                             SNDRV_SB_CSP_LOAD_INITBLOCK);
+                       err = snd_sb_csp_firmware_load(p, CSP_PROGRAM_ADPCM_INIT,
+                                                      SNDRV_SB_CSP_LOAD_INITBLOCK);
                        if (err)
                                break;
                        if (play_rec_mode == SNDRV_SB_CSP_MODE_DSP_WRITE) {
-                               err = snd_sb_csp_load(p, &ima_adpcm_playback[0],
-                                                     sizeof(ima_adpcm_playback), 0);
+                               err = snd_sb_csp_firmware_load
+                                       (p, CSP_PROGRAM_ADPCM_PLAYBACK, 0);
                                p->mode = SNDRV_SB_CSP_MODE_DSP_WRITE;
                        } else {
-                               err = snd_sb_csp_load(p, &ima_adpcm_capture[0],
-                                                     sizeof(ima_adpcm_capture), 0);
+                               err = snd_sb_csp_firmware_load
+                                       (p, CSP_PROGRAM_ADPCM_CAPTURE, 0);
                                p->mode = SNDRV_SB_CSP_MODE_DSP_READ;
                        }
                        p->acc_format = SNDRV_PCM_FMTBIT_IMA_ADPCM;
index 85db535aea9b595271b9ccecd43ec548dcd30b6e..e2fdd5fd39d023c9b855808c6a16e73140ba2842 100644 (file)
@@ -402,6 +402,7 @@ static struct snd_card *snd_wavefront_card_new(int dev)
        init_waitqueue_head(&acard->wavefront.interrupt_sleeper);
        spin_lock_init(&acard->wavefront.midi.open);
        spin_lock_init(&acard->wavefront.midi.virtual);
+       acard->wavefront.card = card;
        card->private_free = snd_wavefront_free;
 
        return card;
index 4f0846feb73f1eb8218e014b399b176596ffd2da..15331ed8819449b03864dcdebd062048f4f4954f 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/init.h>
 #include <linux/time.h>
 #include <linux/wait.h>
+#include <linux/firmware.h>
 #include <sound/core.h>
 #include <sound/snd_wavefront.h>
 #include <sound/initval.h>
 #define FX_MSB_TRANSFER 0x02    /* transfer after DSP MSB byte written */
 #define FX_AUTO_INCR    0x04    /* auto-increment DSP address after transfer */
 
-/* weird stuff, derived from port I/O tracing with dosemu */
-
-static unsigned char page_zero[] __devinitdata = {
-0x01, 0x7c, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf5, 0x00,
-0x11, 0x00, 0x20, 0x00, 0x32, 0x00, 0x40, 0x00, 0x13, 0x00, 0x00,
-0x00, 0x14, 0x02, 0x76, 0x00, 0x60, 0x00, 0x80, 0x02, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x19,
-0x01, 0x1a, 0x01, 0x20, 0x01, 0x40, 0x01, 0x17, 0x00, 0x00, 0x01,
-0x80, 0x01, 0x20, 0x00, 0x10, 0x01, 0xa0, 0x03, 0xd1, 0x00, 0x00,
-0x01, 0xf2, 0x02, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0xf4, 0x02,
-0xe0, 0x00, 0x15, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x17,
-0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x00, 0x50, 0x00, 0x00, 0x00,
-0x40, 0x00, 0x00, 0x00, 0x71, 0x02, 0x00, 0x00, 0x60, 0x00, 0x00,
-0x00, 0x92, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xb3, 0x02,
-0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0xd4, 0x00, 0x00, 0x00, 0x40,
-0x00, 0x80, 0x00, 0xf5, 0x00, 0x20, 0x00, 0x70, 0x00, 0xa0, 0x02,
-0x11, 0x00, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
-0x02, 0x00, 0x00, 0x20, 0x00, 0x10, 0x00, 0x17, 0x00, 0x1b, 0x00,
-0x1d, 0x02, 0xdf
-};
-
-static unsigned char page_one[] __devinitdata = {
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x19, 0x00,
-0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xd8, 0x00, 0x00,
-0x02, 0x20, 0x00, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x01,
-0xc0, 0x01, 0xfa, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x02, 0x60,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xc0, 0x02, 0x80, 0x00,
-0x00, 0x02, 0xfb, 0x02, 0xa0, 0x00, 0x00, 0x00, 0x1b, 0x02, 0xd7,
-0x00, 0x00, 0x02, 0xf7, 0x03, 0x20, 0x03, 0x00, 0x00, 0x00, 0x00,
-0x1c, 0x03, 0x3c, 0x00, 0x00, 0x03, 0x3f, 0x00, 0x00, 0x03, 0xc0,
-0x00, 0x00, 0x03, 0xdf, 0x00, 0x00, 0x00, 0x00, 0x03, 0x5d, 0x00,
-0x00, 0x03, 0xc0, 0x00, 0x00, 0x03, 0x7d, 0x00, 0x00, 0x03, 0xc0,
-0x00, 0x00, 0x03, 0x9e, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x03,
-0xbe, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
-0xdb, 0x00, 0x00, 0x02, 0xdb, 0x00, 0x00, 0x02, 0xe0, 0x00, 0x00,
-0x02, 0xfb, 0x00, 0x00, 0x02, 0xc0, 0x02, 0x40, 0x02, 0xfb, 0x02,
-0x60, 0x00, 0x1b
-};
-
-static unsigned char page_two[] __devinitdata = {
-0xc4, 0x00, 0x44, 0x07, 0x44, 0x00, 0x40, 0x25, 0x01, 0x06, 0xc4,
-0x07, 0x40, 0x25, 0x01, 0x00, 0x46, 0x46, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x07,
-0x05, 0x05, 0x05, 0x04, 0x07, 0x05, 0x04, 0x07, 0x05, 0x44, 0x46,
-0x44, 0x46, 0x46, 0x07, 0x05, 0x44, 0x46, 0x05, 0x46, 0x05, 0x46,
-0x05, 0x46, 0x05, 0x44, 0x46, 0x05, 0x07, 0x44, 0x46, 0x05, 0x07,
-0x44, 0x46, 0x05, 0x07, 0x44, 0x46, 0x05, 0x07, 0x44, 0x05, 0x05,
-0x05, 0x44, 0x05, 0x05, 0x05, 0x46, 0x05, 0x46, 0x05, 0x46, 0x05,
-0x46, 0x05, 0x46, 0x07, 0x46, 0x07, 0x44
-};
-
-static unsigned char page_three[] __devinitdata = {
-0x07, 0x40, 0x00, 0x00, 0x00, 0x47, 0x00, 0x40, 0x00, 0x40, 0x06,
-0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80,
-0xc0, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x40, 0x00,
-0x60, 0x00, 0x70, 0x00, 0x40, 0x00, 0x40, 0x00, 0x42, 0x00, 0x40,
-0x00, 0x02, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
-0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00,
-0x00, 0x42, 0x00, 0x40, 0x00, 0x42, 0x00, 0x02, 0x00, 0x02, 0x00,
-0x02, 0x00, 0x42, 0x00, 0xc0, 0x00, 0x40
-};
-
-static unsigned char page_four[] __devinitdata = {
-0x63, 0x03, 0x26, 0x02, 0x2c, 0x00, 0x24, 0x00, 0x2e, 0x02, 0x02,
-0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
-0x20, 0x00, 0x60, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20,
-0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x60, 0x00,
-0x20, 0x00, 0x60, 0x00, 0x20, 0x00, 0x60, 0x00, 0x20, 0x00, 0x60,
-0x00, 0x20, 0x00, 0x60, 0x00, 0x20, 0x00, 0x60, 0x00, 0x20, 0x00,
-0x20, 0x00, 0x22, 0x02, 0x22, 0x02, 0x20, 0x00, 0x60, 0x00, 0x22,
-0x02, 0x62, 0x02, 0x20, 0x01, 0x21, 0x01
-};
-
-static unsigned char page_six[] __devinitdata = {
-0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x04, 0x00, 0x00, 0x06, 0x00,
-0x00, 0x08, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x0e,
-0x00, 0x00, 0x10, 0x00, 0x00, 0x12, 0x00, 0x00, 0x14, 0x00, 0x00,
-0x16, 0x00, 0x00, 0x18, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x1c, 0x00,
-0x00, 0x1e, 0x00, 0x00, 0x20, 0x00, 0x00, 0x22, 0x00, 0x00, 0x24,
-0x00, 0x00, 0x26, 0x00, 0x00, 0x28, 0x00, 0x00, 0x2a, 0x00, 0x00,
-0x2c, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x30, 0x00, 0x00, 0x32, 0x00,
-0x00, 0x34, 0x00, 0x00, 0x36, 0x00, 0x00, 0x38, 0x00, 0x00, 0x3a,
-0x00, 0x00, 0x3c, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x40, 0x00, 0x00,
-0x42, 0x03, 0x00, 0x44, 0x01, 0x00, 0x46, 0x0a, 0x21, 0x48, 0x0d,
-0x23, 0x4a, 0x23, 0x1b, 0x4c, 0x37, 0x8f, 0x4e, 0x45, 0x77, 0x50,
-0x52, 0xe2, 0x52, 0x1c, 0x92, 0x54, 0x1c, 0x52, 0x56, 0x07, 0x00,
-0x58, 0x2f, 0xc6, 0x5a, 0x0b, 0x00, 0x5c, 0x30, 0x06, 0x5e, 0x17,
-0x00, 0x60, 0x3d, 0xda, 0x62, 0x29, 0x00, 0x64, 0x3e, 0x41, 0x66,
-0x39, 0x00, 0x68, 0x4c, 0x48, 0x6a, 0x49, 0x00, 0x6c, 0x4c, 0x6c,
-0x6e, 0x11, 0xd2, 0x70, 0x16, 0x0c, 0x72, 0x00, 0x00, 0x74, 0x00,
-0x80, 0x76, 0x0f, 0x00, 0x78, 0x00, 0x80, 0x7a, 0x13, 0x00, 0x7c,
-0x80, 0x00, 0x7e, 0x80, 0x80
-};
-
-static unsigned char page_seven[] __devinitdata = {
-0x0f, 0xff, 0x00, 0x00, 0x08, 0x00, 0x08, 0x00, 0x02, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x0f, 0xff, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00,
-0x08, 0x00, 0x00, 0x00, 0x0f, 0xff, 0x00, 0x00, 0x00, 0x00, 0x0f,
-0xff, 0x0f, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0x0f, 0xff,
-0x0f, 0xff, 0x0f, 0xff, 0x02, 0xe9, 0x06, 0x8c, 0x06, 0x8c, 0x0f,
-0xff, 0x1a, 0x75, 0x0d, 0x8b, 0x04, 0xe9, 0x0b, 0x16, 0x1a, 0x38,
-0x0d, 0xc8, 0x04, 0x6f, 0x0b, 0x91, 0x0f, 0xff, 0x06, 0x40, 0x06,
-0x40, 0x02, 0x8f, 0x0f, 0xff, 0x06, 0x62, 0x06, 0x62, 0x02, 0x7b,
-0x0f, 0xff, 0x06, 0x97, 0x06, 0x97, 0x02, 0x52, 0x0f, 0xff, 0x06,
-0xf6, 0x06, 0xf6, 0x02, 0x19, 0x05, 0x55, 0x05, 0x55, 0x05, 0x55,
-0x05, 0x55, 0x05, 0x55, 0x05, 0x55, 0x05, 0x55, 0x05, 0x55, 0x14,
-0xda, 0x0d, 0x93, 0x04, 0xda, 0x05, 0x93, 0x14, 0xda, 0x0d, 0x93,
-0x04, 0xda, 0x05, 0x93, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x02, 0x00
-};
-
-static unsigned char page_zero_v2[] __devinitdata = {
-0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-};
-
-static unsigned char page_one_v2[] __devinitdata = {
-0x01, 0xc0, 0x01, 0xfa, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-};
-
-static unsigned char page_two_v2[] __devinitdata = {
-0x46, 0x46, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00
-};
-static unsigned char page_three_v2[] __devinitdata = {
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00
-};
-static unsigned char page_four_v2[] __devinitdata = {
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00
-};
+#define WAIT_IDLE      0xff
 
-static unsigned char page_seven_v2[] __devinitdata = {
-0x0f, 0xff, 0x0f, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-};
+#define FIRMWARE_IN_THE_KERNEL
 
-static unsigned char mod_v2[] __devinitdata = {
-0x01, 0x00, 0x02, 0x00, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x02,
-0x00, 0x01, 0x03, 0x02, 0x00, 0x01, 0x04, 0x02, 0x00, 0x01, 0x05,
-0x02, 0x00, 0x01, 0x06, 0x02, 0x00, 0x01, 0x07, 0x02, 0x00, 0xb0,
-0x20, 0xb1, 0x20, 0xb2, 0x20, 0xb3, 0x20, 0xb4, 0x20, 0xb5, 0x20,
-0xb6, 0x20, 0xb7, 0x20, 0xf0, 0x20, 0xf1, 0x20, 0xf2, 0x20, 0xf3,
-0x20, 0xf4, 0x20, 0xf5, 0x20, 0xf6, 0x20, 0xf7, 0x20, 0x10, 0xff,
-0x11, 0xff, 0x12, 0xff, 0x13, 0xff, 0x14, 0xff, 0x15, 0xff, 0x16,
-0xff, 0x17, 0xff, 0x20, 0xff, 0x21, 0xff, 0x22, 0xff, 0x23, 0xff,
-0x24, 0xff, 0x25, 0xff, 0x26, 0xff, 0x27, 0xff, 0x30, 0x00, 0x31,
-0x00, 0x32, 0x00, 0x33, 0x00, 0x34, 0x00, 0x35, 0x00, 0x36, 0x00,
-0x37, 0x00, 0x40, 0x00, 0x41, 0x00, 0x42, 0x00, 0x43, 0x00, 0x44,
-0x00, 0x45, 0x00, 0x46, 0x00, 0x47, 0x00, 0x50, 0x00, 0x51, 0x00,
-0x52, 0x00, 0x53, 0x00, 0x54, 0x00, 0x55, 0x00, 0x56, 0x00, 0x57,
-0x00, 0x60, 0x00, 0x61, 0x00, 0x62, 0x00, 0x63, 0x00, 0x64, 0x00,
-0x65, 0x00, 0x66, 0x00, 0x67, 0x00, 0x70, 0xc0, 0x71, 0xc0, 0x72,
-0xc0, 0x73, 0xc0, 0x74, 0xc0, 0x75, 0xc0, 0x76, 0xc0, 0x77, 0xc0,
-0x80, 0x00, 0x81, 0x00, 0x82, 0x00, 0x83, 0x00, 0x84, 0x00, 0x85,
-0x00, 0x86, 0x00, 0x87, 0x00, 0x90, 0x00, 0x91, 0x00, 0x92, 0x00,
-0x93, 0x00, 0x94, 0x00, 0x95, 0x00, 0x96, 0x00, 0x97, 0x00, 0xa0,
-0x00, 0xa1, 0x00, 0xa2, 0x00, 0xa3, 0x00, 0xa4, 0x00, 0xa5, 0x00,
-0xa6, 0x00, 0xa7, 0x00, 0xc0, 0x00, 0xc1, 0x00, 0xc2, 0x00, 0xc3,
-0x00, 0xc4, 0x00, 0xc5, 0x00, 0xc6, 0x00, 0xc7, 0x00, 0xd0, 0x00,
-0xd1, 0x00, 0xd2, 0x00, 0xd3, 0x00, 0xd4, 0x00, 0xd5, 0x00, 0xd6,
-0x00, 0xd7, 0x00, 0xe0, 0x00, 0xe1, 0x00, 0xe2, 0x00, 0xe3, 0x00,
-0xe4, 0x00, 0xe5, 0x00, 0xe6, 0x00, 0xe7, 0x00, 0x01, 0x00, 0x02,
-0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x03,
-0x02, 0x01, 0x01, 0x04, 0x02, 0x01, 0x01, 0x05, 0x02, 0x01, 0x01,
-0x06, 0x02, 0x01, 0x01, 0x07, 0x02, 0x01
-};
-static unsigned char coefficients[] __devinitdata = {
-0x07, 0x46, 0x00, 0x00, 0x07, 0x49, 0x00, 0x00, 0x00, 0x4b, 0x03,
-0x11, 0x00, 0x4d, 0x01, 0x32, 0x07, 0x46, 0x00, 0x00, 0x07, 0x49,
-0x00, 0x00, 0x07, 0x40, 0x00, 0x00, 0x07, 0x41, 0x00, 0x00, 0x01,
-0x40, 0x02, 0x40, 0x01, 0x41, 0x02, 0x60, 0x07, 0x40, 0x00, 0x00,
-0x07, 0x41, 0x00, 0x00, 0x07, 0x47, 0x00, 0x00, 0x07, 0x4a, 0x00,
-0x00, 0x00, 0x47, 0x01, 0x00, 0x00, 0x4a, 0x01, 0x20, 0x07, 0x47,
-0x00, 0x00, 0x07, 0x4a, 0x00, 0x00, 0x07, 0x7c, 0x00, 0x00, 0x07,
-0x7e, 0x00, 0x00, 0x00, 0x00, 0x01, 0x1c, 0x07, 0x7c, 0x00, 0x00,
-0x07, 0x7e, 0x00, 0x00, 0x07, 0x44, 0x00, 0x00, 0x00, 0x44, 0x01,
-0x00, 0x07, 0x44, 0x00, 0x00, 0x07, 0x42, 0x00, 0x00, 0x07, 0x43,
-0x00, 0x00, 0x00, 0x42, 0x01, 0x1a, 0x00, 0x43, 0x01, 0x20, 0x07,
-0x42, 0x00, 0x00, 0x07, 0x43, 0x00, 0x00, 0x07, 0x40, 0x00, 0x00,
-0x07, 0x41, 0x00, 0x00, 0x01, 0x40, 0x02, 0x40, 0x01, 0x41, 0x02,
-0x60, 0x07, 0x40, 0x00, 0x00, 0x07, 0x41, 0x00, 0x00, 0x07, 0x44,
-0x0f, 0xff, 0x07, 0x42, 0x00, 0x00, 0x07, 0x43, 0x00, 0x00, 0x07,
-0x40, 0x00, 0x00, 0x07, 0x41, 0x00, 0x00, 0x07, 0x51, 0x06, 0x40,
-0x07, 0x50, 0x06, 0x40, 0x07, 0x4f, 0x03, 0x81, 0x07, 0x53, 0x1a,
-0x76, 0x07, 0x54, 0x0d, 0x8b, 0x07, 0x55, 0x04, 0xe9, 0x07, 0x56,
-0x0b, 0x17, 0x07, 0x57, 0x1a, 0x38, 0x07, 0x58, 0x0d, 0xc9, 0x07,
-0x59, 0x04, 0x6f, 0x07, 0x5a, 0x0b, 0x91, 0x07, 0x73, 0x14, 0xda,
-0x07, 0x74, 0x0d, 0x93, 0x07, 0x75, 0x04, 0xd9, 0x07, 0x76, 0x05,
-0x93, 0x07, 0x77, 0x14, 0xda, 0x07, 0x78, 0x0d, 0x93, 0x07, 0x79,
-0x04, 0xd9, 0x07, 0x7a, 0x05, 0x93, 0x07, 0x5e, 0x03, 0x68, 0x07,
-0x5c, 0x04, 0x31, 0x07, 0x5d, 0x04, 0x31, 0x07, 0x62, 0x03, 0x52,
-0x07, 0x60, 0x04, 0x76, 0x07, 0x61, 0x04, 0x76, 0x07, 0x66, 0x03,
-0x2e, 0x07, 0x64, 0x04, 0xda, 0x07, 0x65, 0x04, 0xda, 0x07, 0x6a,
-0x02, 0xf6, 0x07, 0x68, 0x05, 0x62, 0x07, 0x69, 0x05, 0x62, 0x06,
-0x46, 0x0a, 0x22, 0x06, 0x48, 0x0d, 0x24, 0x06, 0x6e, 0x11, 0xd3,
-0x06, 0x70, 0x15, 0xcb, 0x06, 0x52, 0x20, 0x93, 0x06, 0x54, 0x20,
-0x54, 0x06, 0x4a, 0x27, 0x1d, 0x06, 0x58, 0x2f, 0xc8, 0x06, 0x5c,
-0x30, 0x07, 0x06, 0x4c, 0x37, 0x90, 0x06, 0x60, 0x3d, 0xdb, 0x06,
-0x64, 0x3e, 0x42, 0x06, 0x4e, 0x45, 0x78, 0x06, 0x68, 0x4c, 0x48,
-0x06, 0x6c, 0x4c, 0x6c, 0x06, 0x50, 0x52, 0xe2, 0x06, 0x42, 0x02,
-0xba
-};
-static unsigned char coefficients2[] __devinitdata = {
-0x07, 0x46, 0x00, 0x00, 0x07, 0x49, 0x00, 0x00, 0x07, 0x45, 0x0f,
-0xff, 0x07, 0x48, 0x0f, 0xff, 0x07, 0x7b, 0x04, 0xcc, 0x07, 0x7d,
-0x04, 0xcc, 0x07, 0x7c, 0x00, 0x00, 0x07, 0x7e, 0x00, 0x00, 0x07,
-0x46, 0x00, 0x00, 0x07, 0x49, 0x00, 0x00, 0x07, 0x47, 0x00, 0x00,
-0x07, 0x4a, 0x00, 0x00, 0x07, 0x4c, 0x00, 0x00, 0x07, 0x4e, 0x00, 0x00
-};
-static unsigned char coefficients3[] __devinitdata = {
-0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x28, 0x00, 0x51, 0x00,
-0x51, 0x00, 0x7a, 0x00, 0x7a, 0x00, 0xa3, 0x00, 0xa3, 0x00, 0xcc,
-0x00, 0xcc, 0x00, 0xf5, 0x00, 0xf5, 0x01, 0x1e, 0x01, 0x1e, 0x01,
-0x47, 0x01, 0x47, 0x01, 0x70, 0x01, 0x70, 0x01, 0x99, 0x01, 0x99,
-0x01, 0xc2, 0x01, 0xc2, 0x01, 0xeb, 0x01, 0xeb, 0x02, 0x14, 0x02,
-0x14, 0x02, 0x3d, 0x02, 0x3d, 0x02, 0x66, 0x02, 0x66, 0x02, 0x8f,
-0x02, 0x8f, 0x02, 0xb8, 0x02, 0xb8, 0x02, 0xe1, 0x02, 0xe1, 0x03,
-0x0a, 0x03, 0x0a, 0x03, 0x33, 0x03, 0x33, 0x03, 0x5c, 0x03, 0x5c,
-0x03, 0x85, 0x03, 0x85, 0x03, 0xae, 0x03, 0xae, 0x03, 0xd7, 0x03,
-0xd7, 0x04, 0x00, 0x04, 0x00, 0x04, 0x28, 0x04, 0x28, 0x04, 0x51,
-0x04, 0x51, 0x04, 0x7a, 0x04, 0x7a, 0x04, 0xa3, 0x04, 0xa3, 0x04,
-0xcc, 0x04, 0xcc, 0x04, 0xf5, 0x04, 0xf5, 0x05, 0x1e, 0x05, 0x1e,
-0x05, 0x47, 0x05, 0x47, 0x05, 0x70, 0x05, 0x70, 0x05, 0x99, 0x05,
-0x99, 0x05, 0xc2, 0x05, 0xc2, 0x05, 0xeb, 0x05, 0xeb, 0x06, 0x14,
-0x06, 0x14, 0x06, 0x3d, 0x06, 0x3d, 0x06, 0x66, 0x06, 0x66, 0x06,
-0x8f, 0x06, 0x8f, 0x06, 0xb8, 0x06, 0xb8, 0x06, 0xe1, 0x06, 0xe1,
-0x07, 0x0a, 0x07, 0x0a, 0x07, 0x33, 0x07, 0x33, 0x07, 0x5c, 0x07,
-0x5c, 0x07, 0x85, 0x07, 0x85, 0x07, 0xae, 0x07, 0xae, 0x07, 0xd7,
-0x07, 0xd7, 0x08, 0x00, 0x08, 0x00, 0x08, 0x28, 0x08, 0x28, 0x08,
-0x51, 0x08, 0x51, 0x08, 0x7a, 0x08, 0x7a, 0x08, 0xa3, 0x08, 0xa3,
-0x08, 0xcc, 0x08, 0xcc, 0x08, 0xf5, 0x08, 0xf5, 0x09, 0x1e, 0x09,
-0x1e, 0x09, 0x47, 0x09, 0x47, 0x09, 0x70, 0x09, 0x70, 0x09, 0x99,
-0x09, 0x99, 0x09, 0xc2, 0x09, 0xc2, 0x09, 0xeb, 0x09, 0xeb, 0x0a,
-0x14, 0x0a, 0x14, 0x0a, 0x3d, 0x0a, 0x3d, 0x0a, 0x66, 0x0a, 0x66,
-0x0a, 0x8f, 0x0a, 0x8f, 0x0a, 0xb8, 0x0a, 0xb8, 0x0a, 0xe1, 0x0a,
-0xe1, 0x0b, 0x0a, 0x0b, 0x0a, 0x0b, 0x33, 0x0b, 0x33, 0x0b, 0x5c,
-0x0b, 0x5c, 0x0b, 0x85, 0x0b, 0x85, 0x0b, 0xae, 0x0b, 0xae, 0x0b,
-0xd7, 0x0b, 0xd7, 0x0c, 0x00, 0x0c, 0x00, 0x0c, 0x28, 0x0c, 0x28,
-0x0c, 0x51, 0x0c, 0x51, 0x0c, 0x7a, 0x0c, 0x7a, 0x0c, 0xa3, 0x0c,
-0xa3, 0x0c, 0xcc, 0x0c, 0xcc, 0x0c, 0xf5, 0x0c, 0xf5, 0x0d, 0x1e,
-0x0d, 0x1e, 0x0d, 0x47, 0x0d, 0x47, 0x0d, 0x70, 0x0d, 0x70, 0x0d,
-0x99, 0x0d, 0x99, 0x0d, 0xc2, 0x0d, 0xc2, 0x0d, 0xeb, 0x0d, 0xeb,
-0x0e, 0x14, 0x0e, 0x14, 0x0e, 0x3d, 0x0e, 0x3d, 0x0e, 0x66, 0x0e,
-0x66, 0x0e, 0x8f, 0x0e, 0x8f, 0x0e, 0xb8, 0x0e, 0xb8, 0x0e, 0xe1,
-0x0e, 0xe1, 0x0f, 0x0a, 0x0f, 0x0a, 0x0f, 0x33, 0x0f, 0x33, 0x0f,
-0x5c, 0x0f, 0x5c, 0x0f, 0x85, 0x0f, 0x85, 0x0f, 0xae, 0x0f, 0xae,
-0x0f, 0xd7, 0x0f, 0xd7, 0x0f, 0xff, 0x0f, 0xff
+#ifdef FIRMWARE_IN_THE_KERNEL
+#include "yss225.c"
+static const struct firmware yss225_registers_firmware = {
+       .data = (u8 *)yss225_registers,
+       .size = sizeof yss225_registers
 };
+#endif
 
 static int
 wavefront_fx_idle (snd_wavefront_t *dev)
@@ -555,465 +248,56 @@ snd_wavefront_fx_ioctl (struct snd_hwdep *sdev, struct file *file,
    of the port I/O done, using the Yamaha faxback document as a guide
    to add more logic to the code. Its really pretty weird.
 
-   There was an alternative approach of just dumping the whole I/O
+   This is the approach of just dumping the whole I/O
    sequence as a series of port/value pairs and a simple loop
-   that output it. However, I hope that eventually I'll get more
-   control over what this code does, and so I tried to stick with
-   a somewhat "algorithmic" approach.
+   that outputs it.
 */
 
-
 int __devinit
 snd_wavefront_fx_start (snd_wavefront_t *dev)
-
 {
-       unsigned int i, j;
+       unsigned int i;
+       int err;
+       const struct firmware *firmware;
 
-       /* Set all bits for all channels on the MOD unit to zero */
-       /* XXX But why do this twice ? */
+       if (dev->fx_initialized)
+               return 0;
 
-       for (j = 0; j < 2; j++) {
-               for (i = 0x10; i <= 0xff; i++) {
-           
-                       if (!wavefront_fx_idle (dev)) {
-                               return (-1);
+       err = request_firmware(&firmware, "yamaha/yss225_registers.bin",
+                              dev->card->dev);
+       if (err < 0) {
+#ifdef FIRMWARE_IN_THE_KERNEL
+               firmware = &yss225_registers_firmware;
+#else
+               err = -1;
+               goto out;
+#endif
+       }
+
+       for (i = 0; i + 1 < firmware->size; i += 2) {
+               if (firmware->data[i] >= 8 && firmware->data[i] < 16) {
+                       outb(firmware->data[i + 1],
+                            dev->base + firmware->data[i]);
+               } else if (firmware->data[i] == WAIT_IDLE) {
+                       if (!wavefront_fx_idle(dev)) {
+                               err = -1;
+                               goto out;
                        }
-           
-                       outb (i, dev->fx_mod_addr);
-                       outb (0x0, dev->fx_mod_data);
-               }
-       }
-
-       if (!wavefront_fx_idle (dev)) return (-1);
-       outb (0x02, dev->fx_op);                        /* mute on */
-
-       if (!wavefront_fx_idle (dev)) return (-1);
-       outb (0x07, dev->fx_dsp_page);
-       outb (0x44, dev->fx_dsp_addr);
-       outb (0x00, dev->fx_dsp_msb);
-       outb (0x00, dev->fx_dsp_lsb);
-       if (!wavefront_fx_idle (dev)) return (-1);
-       outb (0x07, dev->fx_dsp_page);
-       outb (0x42, dev->fx_dsp_addr);
-       outb (0x00, dev->fx_dsp_msb);
-       outb (0x00, dev->fx_dsp_lsb);
-       if (!wavefront_fx_idle (dev)) return (-1);
-       outb (0x07, dev->fx_dsp_page);
-       outb (0x43, dev->fx_dsp_addr);
-       outb (0x00, dev->fx_dsp_msb);
-       outb (0x00, dev->fx_dsp_lsb);
-       if (!wavefront_fx_idle (dev)) return (-1);
-       outb (0x07, dev->fx_dsp_page);
-       outb (0x7c, dev->fx_dsp_addr);
-       outb (0x00, dev->fx_dsp_msb);
-       outb (0x00, dev->fx_dsp_lsb);
-       if (!wavefront_fx_idle (dev)) return (-1);
-       outb (0x07, dev->fx_dsp_page);
-       outb (0x7e, dev->fx_dsp_addr);
-       outb (0x00, dev->fx_dsp_msb);
-       outb (0x00, dev->fx_dsp_lsb);
-       if (!wavefront_fx_idle (dev)) return (-1);
-       outb (0x07, dev->fx_dsp_page);
-       outb (0x46, dev->fx_dsp_addr);
-       outb (0x00, dev->fx_dsp_msb);
-       outb (0x00, dev->fx_dsp_lsb);
-       if (!wavefront_fx_idle (dev)) return (-1);
-       outb (0x07, dev->fx_dsp_page);
-       outb (0x49, dev->fx_dsp_addr);
-       outb (0x00, dev->fx_dsp_msb);
-       outb (0x00, dev->fx_dsp_lsb);
-       if (!wavefront_fx_idle (dev)) return (-1);
-       outb (0x07, dev->fx_dsp_page);
-       outb (0x47, dev->fx_dsp_addr);
-       outb (0x00, dev->fx_dsp_msb);
-       outb (0x00, dev->fx_dsp_lsb);
-       if (!wavefront_fx_idle (dev)) return (-1);
-       outb (0x07, dev->fx_dsp_page);
-       outb (0x4a, dev->fx_dsp_addr);
-       outb (0x00, dev->fx_dsp_msb);
-       outb (0x00, dev->fx_dsp_lsb);
-
-       /* either because of stupidity by TB's programmers, or because it
-          actually does something, rezero the MOD page.
-       */
-       for (i = 0x10; i <= 0xff; i++) {
-       
-               if (!wavefront_fx_idle (dev)) {
-                       return (-1);
+               } else {
+                       snd_printk(KERN_ERR "invalid address"
+                                  " in register data\n");
+                       err = -1;
+                       goto out;
                }
-       
-               outb (i, dev->fx_mod_addr);
-               outb (0x0, dev->fx_mod_data);
-       }
-       /* load page zero */
-
-       outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr);
-       outb (0x00, dev->fx_dsp_page);
-       outb (0x00, dev->fx_dsp_addr);
-
-       for (i = 0; i < sizeof (page_zero); i += 2) {
-               outb (page_zero[i], dev->fx_dsp_msb);
-               outb (page_zero[i+1], dev->fx_dsp_lsb);
-               if (!wavefront_fx_idle (dev)) return (-1);
-       }
-
-       /* Now load page one */
-
-       outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr);
-       outb (0x01, dev->fx_dsp_page);
-       outb (0x00, dev->fx_dsp_addr);
-
-       for (i = 0; i < sizeof (page_one); i += 2) {
-               outb (page_one[i], dev->fx_dsp_msb);
-               outb (page_one[i+1], dev->fx_dsp_lsb);
-               if (!wavefront_fx_idle (dev)) return (-1);
-       }
-    
-       outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr);
-       outb (0x02, dev->fx_dsp_page);
-       outb (0x00, dev->fx_dsp_addr);
-
-       for (i = 0; i < sizeof (page_two); i++) {
-               outb (page_two[i], dev->fx_dsp_lsb);
-               if (!wavefront_fx_idle (dev)) return (-1);
-       }
-    
-       outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr);
-       outb (0x03, dev->fx_dsp_page);
-       outb (0x00, dev->fx_dsp_addr);
-
-       for (i = 0; i < sizeof (page_three); i++) {
-               outb (page_three[i], dev->fx_dsp_lsb);
-               if (!wavefront_fx_idle (dev)) return (-1);
-       }
-    
-       outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr);
-       outb (0x04, dev->fx_dsp_page);
-       outb (0x00, dev->fx_dsp_addr);
-
-       for (i = 0; i < sizeof (page_four); i++) {
-               outb (page_four[i], dev->fx_dsp_lsb);
-               if (!wavefront_fx_idle (dev)) return (-1);
-       }
-
-       /* Load memory area (page six) */
-    
-       outb (FX_LSB_TRANSFER, dev->fx_lcr); 
-       outb (0x06, dev->fx_dsp_page); 
-
-       for (i = 0; i < sizeof (page_six); i += 3) {
-               outb (page_six[i], dev->fx_dsp_addr);
-               outb (page_six[i+1], dev->fx_dsp_msb);
-               outb (page_six[i+2], dev->fx_dsp_lsb);
-               if (!wavefront_fx_idle (dev)) return (-1);
-       }
-    
-       outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr);
-       outb (0x07, dev->fx_dsp_page);
-       outb (0x00, dev->fx_dsp_addr);
-
-       for (i = 0; i < sizeof (page_seven); i += 2) {
-               outb (page_seven[i], dev->fx_dsp_msb);
-               outb (page_seven[i+1], dev->fx_dsp_lsb);
-               if (!wavefront_fx_idle (dev)) return (-1);
-       }
-
-       /* Now setup the MOD area. We do this algorithmically in order to
-          save a little data space. It could be done in the same fashion
-          as the "pages".
-       */
-
-       for (i = 0x00; i <= 0x0f; i++) {
-               outb (0x01, dev->fx_mod_addr);
-               outb (i, dev->fx_mod_data);
-               if (!wavefront_fx_idle (dev)) return (-1);
-               outb (0x02, dev->fx_mod_addr);
-               outb (0x00, dev->fx_mod_data);
-               if (!wavefront_fx_idle (dev)) return (-1);
-       }
-
-       for (i = 0xb0; i <= 0xbf; i++) {
-               outb (i, dev->fx_mod_addr);
-               outb (0x20, dev->fx_mod_data);
-               if (!wavefront_fx_idle (dev)) return (-1);
        }
 
-       for (i = 0xf0; i <= 0xff; i++) {
-               outb (i, dev->fx_mod_addr);
-               outb (0x20, dev->fx_mod_data);
-               if (!wavefront_fx_idle (dev)) return (-1);
-       }
-
-       for (i = 0x10; i <= 0x1d; i++) {
-               outb (i, dev->fx_mod_addr);
-               outb (0xff, dev->fx_mod_data);
-               if (!wavefront_fx_idle (dev)) return (-1);
-       }
-
-       outb (0x1e, dev->fx_mod_addr);
-       outb (0x40, dev->fx_mod_data);
-       if (!wavefront_fx_idle (dev)) return (-1);
-
-       for (i = 0x1f; i <= 0x2d; i++) {
-               outb (i, dev->fx_mod_addr);
-               outb (0xff, dev->fx_mod_data);
-               if (!wavefront_fx_idle (dev)) return (-1);
-       }
-
-       outb (0x2e, dev->fx_mod_addr);
-       outb (0x00, dev->fx_mod_data);
-       if (!wavefront_fx_idle (dev)) return (-1);
-
-       for (i = 0x2f; i <= 0x3e; i++) {
-               outb (i, dev->fx_mod_addr);
-               outb (0x00, dev->fx_mod_data);
-               if (!wavefront_fx_idle (dev)) return (-1);
-       }
-
-       outb (0x3f, dev->fx_mod_addr);
-       outb (0x20, dev->fx_mod_data);
-       if (!wavefront_fx_idle (dev)) return (-1);
-
-       for (i = 0x40; i <= 0x4d; i++) {
-               outb (i, dev->fx_mod_addr);
-               outb (0x00, dev->fx_mod_data);
-               if (!wavefront_fx_idle (dev)) return (-1);
-       }
-
-       outb (0x4e, dev->fx_mod_addr);
-       outb (0x0e, dev->fx_mod_data);
-       if (!wavefront_fx_idle (dev)) return (-1);
-       outb (0x4f, dev->fx_mod_addr);
-       outb (0x0e, dev->fx_mod_data);
-       if (!wavefront_fx_idle (dev)) return (-1);
-
-
-       for (i = 0x50; i <= 0x6b; i++) {
-               outb (i, dev->fx_mod_addr);
-               outb (0x00, dev->fx_mod_data);
-               if (!wavefront_fx_idle (dev)) return (-1);
-       }
-
-       outb (0x6c, dev->fx_mod_addr);
-       outb (0x40, dev->fx_mod_data);
-       if (!wavefront_fx_idle (dev)) return (-1);
-
-       outb (0x6d, dev->fx_mod_addr);
-       outb (0x00, dev->fx_mod_data);
-       if (!wavefront_fx_idle (dev)) return (-1);
-
-       outb (0x6e, dev->fx_mod_addr);
-       outb (0x40, dev->fx_mod_data);
-       if (!wavefront_fx_idle (dev)) return (-1);
-
-       outb (0x6f, dev->fx_mod_addr);
-       outb (0x40, dev->fx_mod_data);
-       if (!wavefront_fx_idle (dev)) return (-1);
-
-       for (i = 0x70; i <= 0x7f; i++) {
-               outb (i, dev->fx_mod_addr);
-               outb (0xc0, dev->fx_mod_data);
-               if (!wavefront_fx_idle (dev)) return (-1);
-       }
-    
-       for (i = 0x80; i <= 0xaf; i++) {
-               outb (i, dev->fx_mod_addr);
-               outb (0x00, dev->fx_mod_data);
-               if (!wavefront_fx_idle (dev)) return (-1);
-       }
-
-       for (i = 0xc0; i <= 0xdd; i++) {
-               outb (i, dev->fx_mod_addr);
-               outb (0x00, dev->fx_mod_data);
-               if (!wavefront_fx_idle (dev)) return (-1);
-       }
-
-       outb (0xde, dev->fx_mod_addr);
-       outb (0x10, dev->fx_mod_data);
-       if (!wavefront_fx_idle (dev)) return (-1);
-       outb (0xdf, dev->fx_mod_addr);
-       outb (0x10, dev->fx_mod_data);
-       if (!wavefront_fx_idle (dev)) return (-1);
-
-       for (i = 0xe0; i <= 0xef; i++) {
-               outb (i, dev->fx_mod_addr);
-               outb (0x00, dev->fx_mod_data);
-               if (!wavefront_fx_idle (dev)) return (-1);
-       }
-
-       for (i = 0x00; i <= 0x0f; i++) {
-               outb (0x01, dev->fx_mod_addr);
-               outb (i, dev->fx_mod_data);
-               outb (0x02, dev->fx_mod_addr);
-               outb (0x01, dev->fx_mod_data);
-               if (!wavefront_fx_idle (dev)) return (-1);
-       }
-
-       outb (0x02, dev->fx_op); /* mute on */
-
-       /* Now set the coefficients and so forth for the programs above */
-
-       for (i = 0; i < sizeof (coefficients); i += 4) {
-               outb (coefficients[i], dev->fx_dsp_page);
-               outb (coefficients[i+1], dev->fx_dsp_addr);
-               outb (coefficients[i+2], dev->fx_dsp_msb);
-               outb (coefficients[i+3], dev->fx_dsp_lsb);
-               if (!wavefront_fx_idle (dev)) return (-1);
-       }
-
-       /* Some settings (?) that are too small to bundle into loops */
-
-       if (!wavefront_fx_idle (dev)) return (-1);
-       outb (0x1e, dev->fx_mod_addr);
-       outb (0x14, dev->fx_mod_data);
-       if (!wavefront_fx_idle (dev)) return (-1);
-       outb (0xde, dev->fx_mod_addr);
-       outb (0x20, dev->fx_mod_data);
-       if (!wavefront_fx_idle (dev)) return (-1);
-       outb (0xdf, dev->fx_mod_addr);
-       outb (0x20, dev->fx_mod_data);
-    
-       /* some more coefficients */
-
-       if (!wavefront_fx_idle (dev)) return (-1);
-       outb (0x06, dev->fx_dsp_page);
-       outb (0x78, dev->fx_dsp_addr);
-       outb (0x00, dev->fx_dsp_msb);
-       outb (0x40, dev->fx_dsp_lsb);
-       if (!wavefront_fx_idle (dev)) return (-1);
-       outb (0x07, dev->fx_dsp_page);
-       outb (0x03, dev->fx_dsp_addr);
-       outb (0x0f, dev->fx_dsp_msb);
-       outb (0xff, dev->fx_dsp_lsb);
-       if (!wavefront_fx_idle (dev)) return (-1);
-       outb (0x07, dev->fx_dsp_page);
-       outb (0x0b, dev->fx_dsp_addr);
-       outb (0x0f, dev->fx_dsp_msb);
-       outb (0xff, dev->fx_dsp_lsb);
-       if (!wavefront_fx_idle (dev)) return (-1);
-       outb (0x07, dev->fx_dsp_page);
-       outb (0x02, dev->fx_dsp_addr);
-       outb (0x00, dev->fx_dsp_msb);
-       outb (0x00, dev->fx_dsp_lsb);
-       if (!wavefront_fx_idle (dev)) return (-1);
-       outb (0x07, dev->fx_dsp_page);
-       outb (0x0a, dev->fx_dsp_addr);
-       outb (0x00, dev->fx_dsp_msb);
-       outb (0x00, dev->fx_dsp_lsb);
-       if (!wavefront_fx_idle (dev)) return (-1);
-       outb (0x07, dev->fx_dsp_page);
-       outb (0x46, dev->fx_dsp_addr);
-       outb (0x00, dev->fx_dsp_msb);
-       outb (0x00, dev->fx_dsp_lsb);
-       if (!wavefront_fx_idle (dev)) return (-1);
-       outb (0x07, dev->fx_dsp_page);
-       outb (0x49, dev->fx_dsp_addr);
-       outb (0x00, dev->fx_dsp_msb);
-       outb (0x00, dev->fx_dsp_lsb);
-    
-       /* Now, for some strange reason, lets reload every page
-          and all the coefficients over again. I have *NO* idea
-          why this is done. I do know that no sound is produced
-          is this phase is omitted.
-       */
-
-       outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr);
-       outb (0x00, dev->fx_dsp_page);  
-       outb (0x10, dev->fx_dsp_addr);
-
-       for (i = 0; i < sizeof (page_zero_v2); i += 2) {
-               outb (page_zero_v2[i], dev->fx_dsp_msb);
-               outb (page_zero_v2[i+1], dev->fx_dsp_lsb);
-               if (!wavefront_fx_idle (dev)) return (-1);
-       }
-    
-       outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr);
-       outb (0x01, dev->fx_dsp_page);
-       outb (0x10, dev->fx_dsp_addr);
-
-       for (i = 0; i < sizeof (page_one_v2); i += 2) {
-               outb (page_one_v2[i], dev->fx_dsp_msb);
-               outb (page_one_v2[i+1], dev->fx_dsp_lsb);
-               if (!wavefront_fx_idle (dev)) return (-1);
-       }
-    
-       if (!wavefront_fx_idle (dev)) return (-1);
-       if (!wavefront_fx_idle (dev)) return (-1);
-    
-       outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr);
-       outb (0x02, dev->fx_dsp_page);
-       outb (0x10, dev->fx_dsp_addr);
-
-       for (i = 0; i < sizeof (page_two_v2); i++) {
-               outb (page_two_v2[i], dev->fx_dsp_lsb);
-               if (!wavefront_fx_idle (dev)) return (-1);
-       }
-       outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr);
-       outb (0x03, dev->fx_dsp_page);
-       outb (0x10, dev->fx_dsp_addr);
-
-       for (i = 0; i < sizeof (page_three_v2); i++) {
-               outb (page_three_v2[i], dev->fx_dsp_lsb);
-               if (!wavefront_fx_idle (dev)) return (-1);
-       }
-    
-       outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr);
-       outb (0x04, dev->fx_dsp_page);
-       outb (0x10, dev->fx_dsp_addr);
-
-       for (i = 0; i < sizeof (page_four_v2); i++) {
-               outb (page_four_v2[i], dev->fx_dsp_lsb);
-               if (!wavefront_fx_idle (dev)) return (-1);
-       }
-    
-       outb (FX_LSB_TRANSFER, dev->fx_lcr);
-       outb (0x06, dev->fx_dsp_page);
-
-       /* Page six v.2 is algorithmic */
-    
-       for (i = 0x10; i <= 0x3e; i += 2) {
-               outb (i, dev->fx_dsp_addr);
-               outb (0x00, dev->fx_dsp_msb);
-               outb (0x00, dev->fx_dsp_lsb);
-               if (!wavefront_fx_idle (dev)) return (-1);
-       }
-
-       outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr);
-       outb (0x07, dev->fx_dsp_page);
-       outb (0x10, dev->fx_dsp_addr);
-
-       for (i = 0; i < sizeof (page_seven_v2); i += 2) {
-               outb (page_seven_v2[i], dev->fx_dsp_msb);
-               outb (page_seven_v2[i+1], dev->fx_dsp_lsb);
-               if (!wavefront_fx_idle (dev)) return (-1);
-       }
-
-       for (i = 0x00; i < sizeof(mod_v2); i += 2) {
-               outb (mod_v2[i], dev->fx_mod_addr);
-               outb (mod_v2[i+1], dev->fx_mod_data);
-               if (!wavefront_fx_idle (dev)) return (-1);
-       }
+       dev->fx_initialized = 1;
+       err = 0;
 
-       for (i = 0; i < sizeof (coefficients2); i += 4) {
-               outb (coefficients2[i], dev->fx_dsp_page);
-               outb (coefficients2[i+1], dev->fx_dsp_addr);
-               outb (coefficients2[i+2], dev->fx_dsp_msb);
-               outb (coefficients2[i+3], dev->fx_dsp_lsb);
-               if (!wavefront_fx_idle (dev)) return (-1);
-       }
-
-       for (i = 0; i < sizeof (coefficients3); i += 2) {
-               int x;
-
-               outb (0x07, dev->fx_dsp_page);
-               x = (i % 4) ? 0x4e : 0x4c;
-               outb (x, dev->fx_dsp_addr);
-               outb (coefficients3[i], dev->fx_dsp_msb);
-               outb (coefficients3[i+1], dev->fx_dsp_lsb);
-       }
-
-       outb (0x00, dev->fx_op); /* mute off */
-       if (!wavefront_fx_idle (dev)) return (-1);
-
-       return (0);
+out:
+#ifdef FIRMWARE_IN_THE_KERNEL
+       if (firmware != &yss225_registers_firmware)
+#endif
+               release_firmware(firmware);
+       return err;
 }
diff --git a/sound/isa/wavefront/yss225.c b/sound/isa/wavefront/yss225.c
new file mode 100644 (file)
index 0000000..9f6be3f
--- /dev/null
@@ -0,0 +1,2739 @@
+/*
+ *  Copyright (c) 1998-2002 by Paul Davis <pbd@op.net>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+ */
+
+/* weird stuff, derived from port I/O tracing with dosemu */
+
+static const struct {
+       unsigned char addr;
+       unsigned char data;
+} yss225_registers[] __devinitdata = {
+/* Set all bits for all channels on the MOD unit to zero */
+{ WAIT_IDLE }, { 0xe, 0x10 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x11 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x12 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x13 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x14 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x15 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x16 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x17 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x18 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x19 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x1a }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x1b }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x1c }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x1d }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x1e }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x1f }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x20 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x21 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x22 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x23 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x24 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x25 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x26 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x27 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x28 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x29 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x2a }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x2b }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x2c }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x2d }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x2e }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x2f }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x30 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x31 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x32 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x33 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x34 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x35 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x36 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x37 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x38 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x39 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x3a }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x3b }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x3c }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x3d }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x3e }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x3f }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x40 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x41 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x42 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x43 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x44 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x45 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x46 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x47 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x48 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x49 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x4a }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x4b }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x4c }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x4d }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x4e }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x4f }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x50 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x51 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x52 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x53 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x54 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x55 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x56 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x57 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x58 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x59 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x5a }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x5b }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x5c }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x5d }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x5e }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x5f }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x60 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x61 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x62 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x63 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x64 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x65 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x66 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x67 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x68 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x69 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x6a }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x6b }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x6c }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x6d }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x6e }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x6f }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x70 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x71 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x72 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x73 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x74 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x75 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x76 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x77 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x78 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x79 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x7a }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x7b }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x7c }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x7d }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x7e }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x7f }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x80 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x81 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x82 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x83 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x84 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x85 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x86 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x87 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x88 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x89 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x8a }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x8b }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x8c }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x8d }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x8e }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x8f }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x90 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x91 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x92 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x93 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x94 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x95 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x96 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x97 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x98 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x99 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x9a }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x9b }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x9c }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x9d }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x9e }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x9f }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xa0 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xa1 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xa2 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xa3 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xa4 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xa5 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xa6 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xa7 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xa8 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xa9 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xaa }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xab }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xac }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xad }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xae }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xaf }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xb0 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xb1 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xb2 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xb3 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xb4 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xb5 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xb6 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xb7 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xb8 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xb9 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xba }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xbb }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xbc }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xbd }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xbe }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xbf }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xc0 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xc1 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xc2 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xc3 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xc4 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xc5 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xc6 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xc7 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xc8 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xc9 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xca }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xcb }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xcc }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xcd }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xce }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xcf }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xd0 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xd1 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xd2 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xd3 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xd4 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xd5 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xd6 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xd7 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xd8 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xd9 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xda }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xdb }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xdc }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xdd }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xde }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xdf }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xe0 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xe1 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xe2 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xe3 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xe4 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xe5 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xe6 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xe7 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xe8 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xe9 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xea }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xeb }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xec }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xed }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xee }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xef }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xf0 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xf1 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xf2 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xf3 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xf4 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xf5 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xf6 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xf7 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xf8 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xf9 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xfa }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xfb }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xfc }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xfd }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xfe }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xff }, { 0xf, 0x00 },
+
+/* XXX But why do this twice? */
+{ WAIT_IDLE }, { 0xe, 0x10 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x11 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x12 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x13 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x14 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x15 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x16 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x17 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x18 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x19 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x1a }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x1b }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x1c }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x1d }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x1e }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x1f }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x20 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x21 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x22 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x23 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x24 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x25 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x26 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x27 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x28 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x29 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x2a }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x2b }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x2c }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x2d }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x2e }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x2f }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x30 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x31 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x32 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x33 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x34 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x35 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x36 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x37 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x38 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x39 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x3a }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x3b }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x3c }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x3d }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x3e }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x3f }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x40 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x41 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x42 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x43 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x44 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x45 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x46 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x47 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x48 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x49 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x4a }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x4b }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x4c }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x4d }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x4e }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x4f }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x50 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x51 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x52 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x53 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x54 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x55 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x56 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x57 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x58 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x59 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x5a }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x5b }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x5c }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x5d }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x5e }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x5f }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x60 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x61 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x62 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x63 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x64 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x65 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x66 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x67 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x68 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x69 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x6a }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x6b }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x6c }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x6d }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x6e }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x6f }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x70 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x71 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x72 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x73 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x74 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x75 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x76 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x77 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x78 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x79 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x7a }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x7b }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x7c }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x7d }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x7e }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x7f }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x80 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x81 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x82 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x83 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x84 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x85 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x86 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x87 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x88 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x89 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x8a }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x8b }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x8c }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x8d }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x8e }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x8f }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x90 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x91 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x92 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x93 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x94 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x95 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x96 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x97 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x98 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x99 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x9a }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x9b }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x9c }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x9d }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x9e }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x9f }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xa0 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xa1 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xa2 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xa3 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xa4 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xa5 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xa6 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xa7 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xa8 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xa9 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xaa }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xab }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xac }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xad }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xae }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xaf }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xb0 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xb1 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xb2 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xb3 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xb4 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xb5 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xb6 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xb7 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xb8 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xb9 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xba }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xbb }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xbc }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xbd }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xbe }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xbf }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xc0 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xc1 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xc2 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xc3 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xc4 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xc5 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xc6 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xc7 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xc8 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xc9 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xca }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xcb }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xcc }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xcd }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xce }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xcf }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xd0 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xd1 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xd2 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xd3 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xd4 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xd5 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xd6 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xd7 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xd8 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xd9 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xda }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xdb }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xdc }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xdd }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xde }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xdf }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xe0 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xe1 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xe2 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xe3 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xe4 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xe5 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xe6 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xe7 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xe8 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xe9 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xea }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xeb }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xec }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xed }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xee }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xef }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xf0 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xf1 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xf2 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xf3 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xf4 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xf5 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xf6 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xf7 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xf8 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xf9 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xfa }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xfb }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xfc }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xfd }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xfe }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xff }, { 0xf, 0x00 },
+
+/* mute on */
+{ WAIT_IDLE }, { 0x8, 0x02 },
+
+{ WAIT_IDLE }, { 0xb, 0x07 }, { 0xa, 0x44 }, { 0xd, 0x00 }, { 0xc, 0x00 },
+{ WAIT_IDLE }, { 0xb, 0x07 }, { 0xa, 0x42 }, { 0xd, 0x00 }, { 0xc, 0x00 },
+{ WAIT_IDLE }, { 0xb, 0x07 }, { 0xa, 0x43 }, { 0xd, 0x00 }, { 0xc, 0x00 },
+{ WAIT_IDLE }, { 0xb, 0x07 }, { 0xa, 0x7c }, { 0xd, 0x00 }, { 0xc, 0x00 },
+{ WAIT_IDLE }, { 0xb, 0x07 }, { 0xa, 0x7e }, { 0xd, 0x00 }, { 0xc, 0x00 },
+{ WAIT_IDLE }, { 0xb, 0x07 }, { 0xa, 0x46 }, { 0xd, 0x00 }, { 0xc, 0x00 },
+{ WAIT_IDLE }, { 0xb, 0x07 }, { 0xa, 0x49 }, { 0xd, 0x00 }, { 0xc, 0x00 },
+{ WAIT_IDLE }, { 0xb, 0x07 }, { 0xa, 0x47 }, { 0xd, 0x00 }, { 0xc, 0x00 },
+{ WAIT_IDLE }, { 0xb, 0x07 }, { 0xa, 0x4a }, { 0xd, 0x00 }, { 0xc, 0x00 },
+
+/* either because of stupidity by TB's programmers, or because it
+   actually does something, rezero the MOD page. */
+{ WAIT_IDLE }, { 0xe, 0x10 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x11 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x12 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x13 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x14 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x15 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x16 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x17 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x18 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x19 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x1a }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x1b }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x1c }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x1d }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x1e }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x1f }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x20 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x21 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x22 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x23 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x24 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x25 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x26 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x27 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x28 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x29 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x2a }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x2b }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x2c }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x2d }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x2e }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x2f }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x30 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x31 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x32 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x33 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x34 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x35 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x36 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x37 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x38 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x39 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x3a }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x3b }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x3c }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x3d }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x3e }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x3f }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x40 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x41 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x42 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x43 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x44 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x45 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x46 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x47 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x48 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x49 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x4a }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x4b }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x4c }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x4d }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x4e }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x4f }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x50 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x51 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x52 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x53 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x54 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x55 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x56 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x57 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x58 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x59 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x5a }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x5b }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x5c }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x5d }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x5e }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x5f }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x60 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x61 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x62 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x63 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x64 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x65 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x66 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x67 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x68 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x69 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x6a }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x6b }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x6c }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x6d }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x6e }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x6f }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x70 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x71 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x72 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x73 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x74 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x75 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x76 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x77 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x78 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x79 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x7a }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x7b }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x7c }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x7d }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x7e }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x7f }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x80 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x81 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x82 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x83 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x84 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x85 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x86 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x87 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x88 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x89 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x8a }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x8b }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x8c }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x8d }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x8e }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x8f }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x90 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x91 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x92 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x93 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x94 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x95 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x96 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x97 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x98 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x99 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x9a }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x9b }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x9c }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x9d }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x9e }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0x9f }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xa0 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xa1 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xa2 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xa3 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xa4 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xa5 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xa6 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xa7 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xa8 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xa9 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xaa }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xab }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xac }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xad }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xae }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xaf }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xb0 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xb1 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xb2 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xb3 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xb4 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xb5 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xb6 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xb7 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xb8 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xb9 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xba }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xbb }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xbc }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xbd }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xbe }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xbf }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xc0 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xc1 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xc2 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xc3 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xc4 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xc5 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xc6 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xc7 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xc8 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xc9 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xca }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xcb }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xcc }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xcd }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xce }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xcf }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xd0 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xd1 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xd2 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xd3 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xd4 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xd5 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xd6 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xd7 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xd8 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xd9 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xda }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xdb }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xdc }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xdd }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xde }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xdf }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xe0 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xe1 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xe2 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xe3 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xe4 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xe5 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xe6 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xe7 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xe8 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xe9 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xea }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xeb }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xec }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xed }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xee }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xef }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xf0 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xf1 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xf2 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xf3 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xf4 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xf5 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xf6 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xf7 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xf8 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xf9 }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xfa }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xfb }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xfc }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xfd }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xfe }, { 0xf, 0x00 },
+{ WAIT_IDLE }, { 0xe, 0xff }, { 0xf, 0x00 },
+
+/* load page zero */
+{ 0x9, 0x05 }, { 0xb, 0x00 }, { 0xa, 0x00 },
+
+{ 0xd, 0x01 }, { 0xc, 0x7c }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x1e }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0xf5 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x11 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x20 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x32 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x40 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x13 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x14 }, { WAIT_IDLE },
+{ 0xd, 0x02 }, { 0xc, 0x76 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x60 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x80 }, { WAIT_IDLE },
+{ 0xd, 0x02 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x02 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x18 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x19 }, { WAIT_IDLE },
+{ 0xd, 0x01 }, { 0xc, 0x1a }, { WAIT_IDLE },
+{ 0xd, 0x01 }, { 0xc, 0x20 }, { WAIT_IDLE },
+{ 0xd, 0x01 }, { 0xc, 0x40 }, { WAIT_IDLE },
+{ 0xd, 0x01 }, { 0xc, 0x17 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x01 }, { 0xc, 0x80 }, { WAIT_IDLE },
+{ 0xd, 0x01 }, { 0xc, 0x20 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x10 }, { WAIT_IDLE },
+{ 0xd, 0x01 }, { 0xc, 0xa0 }, { WAIT_IDLE },
+{ 0xd, 0x03 }, { 0xc, 0xd1 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x01 }, { 0xc, 0xf2 }, { WAIT_IDLE },
+{ 0xd, 0x02 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x13 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0xf4 }, { WAIT_IDLE },
+{ 0xd, 0x02 }, { 0xc, 0xe0 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x15 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x16 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x17 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x20 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x20 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x50 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x40 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x71 }, { WAIT_IDLE },
+{ 0xd, 0x02 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x60 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x92 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x80 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0xb3 }, { WAIT_IDLE },
+{ 0xd, 0x02 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0xa0 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0xd4 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x40 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x80 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0xf5 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x20 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x70 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0xa0 }, { WAIT_IDLE },
+{ 0xd, 0x02 }, { 0xc, 0x11 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x16 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x20 }, { WAIT_IDLE },
+{ 0xd, 0x02 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x20 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x10 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x17 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x1b }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x1d }, { WAIT_IDLE },
+{ 0xd, 0x02 }, { 0xc, 0xdf }, { WAIT_IDLE },
+
+/* Now load page one */
+{ 0x9, 0x05 }, { 0xb, 0x01 }, { 0xa, 0x00 },
+
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x02 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x19 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x1f }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x03 }, { 0xc, 0xd8 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x02 }, { 0xc, 0x20 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x19 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x18 }, { WAIT_IDLE },
+{ 0xd, 0x01 }, { 0xc, 0xc0 }, { WAIT_IDLE },
+{ 0xd, 0x01 }, { 0xc, 0xfa }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x1a }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x02 }, { 0xc, 0x40 }, { WAIT_IDLE },
+{ 0xd, 0x02 }, { 0xc, 0x60 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x02 }, { 0xc, 0xc0 }, { WAIT_IDLE },
+{ 0xd, 0x02 }, { 0xc, 0x80 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x02 }, { 0xc, 0xfb }, { WAIT_IDLE },
+{ 0xd, 0x02 }, { 0xc, 0xa0 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x1b }, { WAIT_IDLE },
+{ 0xd, 0x02 }, { 0xc, 0xd7 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x02 }, { 0xc, 0xf7 }, { WAIT_IDLE },
+{ 0xd, 0x03 }, { 0xc, 0x20 }, { WAIT_IDLE },
+{ 0xd, 0x03 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x1c }, { WAIT_IDLE },
+{ 0xd, 0x03 }, { 0xc, 0x3c }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x03 }, { 0xc, 0x3f }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x03 }, { 0xc, 0xc0 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x03 }, { 0xc, 0xdf }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x03 }, { 0xc, 0x5d }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x03 }, { 0xc, 0xc0 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x03 }, { 0xc, 0x7d }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x03 }, { 0xc, 0xc0 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x03 }, { 0xc, 0x9e }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x03 }, { 0xc, 0xc0 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x03 }, { 0xc, 0xbe }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x03 }, { 0xc, 0xc0 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x1b }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x02 }, { 0xc, 0xdb }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x02 }, { 0xc, 0xdb }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x02 }, { 0xc, 0xe0 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x02 }, { 0xc, 0xfb }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x02 }, { 0xc, 0xc0 }, { WAIT_IDLE },
+{ 0xd, 0x02 }, { 0xc, 0x40 }, { WAIT_IDLE },
+{ 0xd, 0x02 }, { 0xc, 0xfb }, { WAIT_IDLE },
+{ 0xd, 0x02 }, { 0xc, 0x60 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x1b }, { WAIT_IDLE },
+
+{ 0x9, 0x05 }, { 0xb, 0x02 }, { 0xa, 0x00 },
+
+{ 0xc, 0xc4 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x44 }, { WAIT_IDLE },
+{ 0xc, 0x07 }, { WAIT_IDLE },
+{ 0xc, 0x44 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x40 }, { WAIT_IDLE },
+{ 0xc, 0x25 }, { WAIT_IDLE },
+{ 0xc, 0x01 }, { WAIT_IDLE },
+{ 0xc, 0x06 }, { WAIT_IDLE },
+{ 0xc, 0xc4 }, { WAIT_IDLE },
+{ 0xc, 0x07 }, { WAIT_IDLE },
+{ 0xc, 0x40 }, { WAIT_IDLE },
+{ 0xc, 0x25 }, { WAIT_IDLE },
+{ 0xc, 0x01 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x46 }, { WAIT_IDLE },
+{ 0xc, 0x46 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x46 }, { WAIT_IDLE },
+{ 0xc, 0x07 }, { WAIT_IDLE },
+{ 0xc, 0x05 }, { WAIT_IDLE },
+{ 0xc, 0x05 }, { WAIT_IDLE },
+{ 0xc, 0x05 }, { WAIT_IDLE },
+{ 0xc, 0x04 }, { WAIT_IDLE },
+{ 0xc, 0x07 }, { WAIT_IDLE },
+{ 0xc, 0x05 }, { WAIT_IDLE },
+{ 0xc, 0x04 }, { WAIT_IDLE },
+{ 0xc, 0x07 }, { WAIT_IDLE },
+{ 0xc, 0x05 }, { WAIT_IDLE },
+{ 0xc, 0x44 }, { WAIT_IDLE },
+{ 0xc, 0x46 }, { WAIT_IDLE },
+{ 0xc, 0x44 }, { WAIT_IDLE },
+{ 0xc, 0x46 }, { WAIT_IDLE },
+{ 0xc, 0x46 }, { WAIT_IDLE },
+{ 0xc, 0x07 }, { WAIT_IDLE },
+{ 0xc, 0x05 }, { WAIT_IDLE },
+{ 0xc, 0x44 }, { WAIT_IDLE },
+{ 0xc, 0x46 }, { WAIT_IDLE },
+{ 0xc, 0x05 }, { WAIT_IDLE },
+{ 0xc, 0x46 }, { WAIT_IDLE },
+{ 0xc, 0x05 }, { WAIT_IDLE },
+{ 0xc, 0x46 }, { WAIT_IDLE },
+{ 0xc, 0x05 }, { WAIT_IDLE },
+{ 0xc, 0x46 }, { WAIT_IDLE },
+{ 0xc, 0x05 }, { WAIT_IDLE },
+{ 0xc, 0x44 }, { WAIT_IDLE },
+{ 0xc, 0x46 }, { WAIT_IDLE },
+{ 0xc, 0x05 }, { WAIT_IDLE },
+{ 0xc, 0x07 }, { WAIT_IDLE },
+{ 0xc, 0x44 }, { WAIT_IDLE },
+{ 0xc, 0x46 }, { WAIT_IDLE },
+{ 0xc, 0x05 }, { WAIT_IDLE },
+{ 0xc, 0x07 }, { WAIT_IDLE },
+{ 0xc, 0x44 }, { WAIT_IDLE },
+{ 0xc, 0x46 }, { WAIT_IDLE },
+{ 0xc, 0x05 }, { WAIT_IDLE },
+{ 0xc, 0x07 }, { WAIT_IDLE },
+{ 0xc, 0x44 }, { WAIT_IDLE },
+{ 0xc, 0x46 }, { WAIT_IDLE },
+{ 0xc, 0x05 }, { WAIT_IDLE },
+{ 0xc, 0x07 }, { WAIT_IDLE },
+{ 0xc, 0x44 }, { WAIT_IDLE },
+{ 0xc, 0x05 }, { WAIT_IDLE },
+{ 0xc, 0x05 }, { WAIT_IDLE },
+{ 0xc, 0x05 }, { WAIT_IDLE },
+{ 0xc, 0x44 }, { WAIT_IDLE },
+{ 0xc, 0x05 }, { WAIT_IDLE },
+{ 0xc, 0x05 }, { WAIT_IDLE },
+{ 0xc, 0x05 }, { WAIT_IDLE },
+{ 0xc, 0x46 }, { WAIT_IDLE },
+{ 0xc, 0x05 }, { WAIT_IDLE },
+{ 0xc, 0x46 }, { WAIT_IDLE },
+{ 0xc, 0x05 }, { WAIT_IDLE },
+{ 0xc, 0x46 }, { WAIT_IDLE },
+{ 0xc, 0x05 }, { WAIT_IDLE },
+{ 0xc, 0x46 }, { WAIT_IDLE },
+{ 0xc, 0x05 }, { WAIT_IDLE },
+{ 0xc, 0x46 }, { WAIT_IDLE },
+{ 0xc, 0x07 }, { WAIT_IDLE },
+{ 0xc, 0x46 }, { WAIT_IDLE },
+{ 0xc, 0x07 }, { WAIT_IDLE },
+{ 0xc, 0x44 }, { WAIT_IDLE },
+
+{ 0x9, 0x05 }, { 0xb, 0x03 }, { 0xa, 0x00 },
+
+{ 0xc, 0x07 }, { WAIT_IDLE },
+{ 0xc, 0x40 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x47 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x40 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x40 }, { WAIT_IDLE },
+{ 0xc, 0x06 }, { WAIT_IDLE },
+{ 0xc, 0x40 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x80 }, { WAIT_IDLE },
+{ 0xc, 0x80 }, { WAIT_IDLE },
+{ 0xc, 0xc0 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x40 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x40 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x40 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x60 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x70 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x40 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x40 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x42 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x40 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x02 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x40 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x40 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x40 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x40 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x40 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x42 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x40 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x42 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x02 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x02 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x02 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x42 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0xc0 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x40 }, { WAIT_IDLE },
+
+{ 0x9, 0x05 }, { 0xb, 0x04 }, { 0xa, 0x00 },
+
+{ 0xc, 0x63 }, { WAIT_IDLE },
+{ 0xc, 0x03 }, { WAIT_IDLE },
+{ 0xc, 0x26 }, { WAIT_IDLE },
+{ 0xc, 0x02 }, { WAIT_IDLE },
+{ 0xc, 0x2c }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x24 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x2e }, { WAIT_IDLE },
+{ 0xc, 0x02 }, { WAIT_IDLE },
+{ 0xc, 0x02 }, { WAIT_IDLE },
+{ 0xc, 0x02 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x01 }, { WAIT_IDLE },
+{ 0xc, 0x20 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x60 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x20 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x20 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x20 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x20 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x20 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x20 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x20 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x20 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x60 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x20 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x60 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x20 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x60 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x20 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x60 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x20 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x60 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x20 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x60 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x20 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x20 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x22 }, { WAIT_IDLE },
+{ 0xc, 0x02 }, { WAIT_IDLE },
+{ 0xc, 0x22 }, { WAIT_IDLE },
+{ 0xc, 0x02 }, { WAIT_IDLE },
+{ 0xc, 0x20 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x60 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x22 }, { WAIT_IDLE },
+{ 0xc, 0x02 }, { WAIT_IDLE },
+{ 0xc, 0x62 }, { WAIT_IDLE },
+{ 0xc, 0x02 }, { WAIT_IDLE },
+{ 0xc, 0x20 }, { WAIT_IDLE },
+{ 0xc, 0x01 }, { WAIT_IDLE },
+{ 0xc, 0x21 }, { WAIT_IDLE },
+{ 0xc, 0x01 }, { WAIT_IDLE },
+
+/* Load memory area (page six) */
+{ 0x9, 0x01 }, { 0xb, 0x06 },
+
+{ 0xa, 0x00 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x02 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x04 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x06 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x08 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x0a }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x0c }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x0e }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x10 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x12 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x14 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x16 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x18 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x1a }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x1c }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x1e }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x20 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x22 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x24 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x26 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x28 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x2a }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x2c }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x2e }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x30 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x32 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x34 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x36 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x38 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x3a }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x3c }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x3e }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x40 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x42 }, { 0xd, 0x03 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x44 }, { 0xd, 0x01 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x46 }, { 0xd, 0x0a }, { 0xc, 0x21 }, { WAIT_IDLE },
+{ 0xa, 0x48 }, { 0xd, 0x0d }, { 0xc, 0x23 }, { WAIT_IDLE },
+{ 0xa, 0x4a }, { 0xd, 0x23 }, { 0xc, 0x1b }, { WAIT_IDLE },
+{ 0xa, 0x4c }, { 0xd, 0x37 }, { 0xc, 0x8f }, { WAIT_IDLE },
+{ 0xa, 0x4e }, { 0xd, 0x45 }, { 0xc, 0x77 }, { WAIT_IDLE },
+{ 0xa, 0x50 }, { 0xd, 0x52 }, { 0xc, 0xe2 }, { WAIT_IDLE },
+{ 0xa, 0x52 }, { 0xd, 0x1c }, { 0xc, 0x92 }, { WAIT_IDLE },
+{ 0xa, 0x54 }, { 0xd, 0x1c }, { 0xc, 0x52 }, { WAIT_IDLE },
+{ 0xa, 0x56 }, { 0xd, 0x07 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x58 }, { 0xd, 0x2f }, { 0xc, 0xc6 }, { WAIT_IDLE },
+{ 0xa, 0x5a }, { 0xd, 0x0b }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x5c }, { 0xd, 0x30 }, { 0xc, 0x06 }, { WAIT_IDLE },
+{ 0xa, 0x5e }, { 0xd, 0x17 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x60 }, { 0xd, 0x3d }, { 0xc, 0xda }, { WAIT_IDLE },
+{ 0xa, 0x62 }, { 0xd, 0x29 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x64 }, { 0xd, 0x3e }, { 0xc, 0x41 }, { WAIT_IDLE },
+{ 0xa, 0x66 }, { 0xd, 0x39 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x68 }, { 0xd, 0x4c }, { 0xc, 0x48 }, { WAIT_IDLE },
+{ 0xa, 0x6a }, { 0xd, 0x49 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x6c }, { 0xd, 0x4c }, { 0xc, 0x6c }, { WAIT_IDLE },
+{ 0xa, 0x6e }, { 0xd, 0x11 }, { 0xc, 0xd2 }, { WAIT_IDLE },
+{ 0xa, 0x70 }, { 0xd, 0x16 }, { 0xc, 0x0c }, { WAIT_IDLE },
+{ 0xa, 0x72 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x74 }, { 0xd, 0x00 }, { 0xc, 0x80 }, { WAIT_IDLE },
+{ 0xa, 0x76 }, { 0xd, 0x0f }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x78 }, { 0xd, 0x00 }, { 0xc, 0x80 }, { WAIT_IDLE },
+{ 0xa, 0x7a }, { 0xd, 0x13 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x7c }, { 0xd, 0x80 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x7e }, { 0xd, 0x80 }, { 0xc, 0x80 }, { WAIT_IDLE },
+
+{ 0x9, 0x05 }, { 0xb, 0x07 }, { 0xa, 0x00 },
+
+{ 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x08 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x08 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x02 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x08 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x08 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE },
+{ 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE },
+{ 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE },
+{ 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE },
+{ 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE },
+{ 0xd, 0x02 }, { 0xc, 0xe9 }, { WAIT_IDLE },
+{ 0xd, 0x06 }, { 0xc, 0x8c }, { WAIT_IDLE },
+{ 0xd, 0x06 }, { 0xc, 0x8c }, { WAIT_IDLE },
+{ 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE },
+{ 0xd, 0x1a }, { 0xc, 0x75 }, { WAIT_IDLE },
+{ 0xd, 0x0d }, { 0xc, 0x8b }, { WAIT_IDLE },
+{ 0xd, 0x04 }, { 0xc, 0xe9 }, { WAIT_IDLE },
+{ 0xd, 0x0b }, { 0xc, 0x16 }, { WAIT_IDLE },
+{ 0xd, 0x1a }, { 0xc, 0x38 }, { WAIT_IDLE },
+{ 0xd, 0x0d }, { 0xc, 0xc8 }, { WAIT_IDLE },
+{ 0xd, 0x04 }, { 0xc, 0x6f }, { WAIT_IDLE },
+{ 0xd, 0x0b }, { 0xc, 0x91 }, { WAIT_IDLE },
+{ 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE },
+{ 0xd, 0x06 }, { 0xc, 0x40 }, { WAIT_IDLE },
+{ 0xd, 0x06 }, { 0xc, 0x40 }, { WAIT_IDLE },
+{ 0xd, 0x02 }, { 0xc, 0x8f }, { WAIT_IDLE },
+{ 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE },
+{ 0xd, 0x06 }, { 0xc, 0x62 }, { WAIT_IDLE },
+{ 0xd, 0x06 }, { 0xc, 0x62 }, { WAIT_IDLE },
+{ 0xd, 0x02 }, { 0xc, 0x7b }, { WAIT_IDLE },
+{ 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE },
+{ 0xd, 0x06 }, { 0xc, 0x97 }, { WAIT_IDLE },
+{ 0xd, 0x06 }, { 0xc, 0x97 }, { WAIT_IDLE },
+{ 0xd, 0x02 }, { 0xc, 0x52 }, { WAIT_IDLE },
+{ 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE },
+{ 0xd, 0x06 }, { 0xc, 0xf6 }, { WAIT_IDLE },
+{ 0xd, 0x06 }, { 0xc, 0xf6 }, { WAIT_IDLE },
+{ 0xd, 0x02 }, { 0xc, 0x19 }, { WAIT_IDLE },
+{ 0xd, 0x05 }, { 0xc, 0x55 }, { WAIT_IDLE },
+{ 0xd, 0x05 }, { 0xc, 0x55 }, { WAIT_IDLE },
+{ 0xd, 0x05 }, { 0xc, 0x55 }, { WAIT_IDLE },
+{ 0xd, 0x05 }, { 0xc, 0x55 }, { WAIT_IDLE },
+{ 0xd, 0x05 }, { 0xc, 0x55 }, { WAIT_IDLE },
+{ 0xd, 0x05 }, { 0xc, 0x55 }, { WAIT_IDLE },
+{ 0xd, 0x05 }, { 0xc, 0x55 }, { WAIT_IDLE },
+{ 0xd, 0x05 }, { 0xc, 0x55 }, { WAIT_IDLE },
+{ 0xd, 0x14 }, { 0xc, 0xda }, { WAIT_IDLE },
+{ 0xd, 0x0d }, { 0xc, 0x93 }, { WAIT_IDLE },
+{ 0xd, 0x04 }, { 0xc, 0xda }, { WAIT_IDLE },
+{ 0xd, 0x05 }, { 0xc, 0x93 }, { WAIT_IDLE },
+{ 0xd, 0x14 }, { 0xc, 0xda }, { WAIT_IDLE },
+{ 0xd, 0x0d }, { 0xc, 0x93 }, { WAIT_IDLE },
+{ 0xd, 0x04 }, { 0xc, 0xda }, { WAIT_IDLE },
+{ 0xd, 0x05 }, { 0xc, 0x93 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x02 }, { 0xc, 0x00 }, { WAIT_IDLE },
+
+/* Now setup the MOD area. */
+{ 0xe, 0x01 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x01 }, { 0xf, 0x01 }, { WAIT_IDLE },
+{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x01 }, { 0xf, 0x02 }, { WAIT_IDLE },
+{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x01 }, { 0xf, 0x03 }, { WAIT_IDLE },
+{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x01 }, { 0xf, 0x04 }, { WAIT_IDLE },
+{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x01 }, { 0xf, 0x05 }, { WAIT_IDLE },
+{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x01 }, { 0xf, 0x06 }, { WAIT_IDLE },
+{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x01 }, { 0xf, 0x07 }, { WAIT_IDLE },
+{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x01 }, { 0xf, 0x08 }, { WAIT_IDLE },
+{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x01 }, { 0xf, 0x09 }, { WAIT_IDLE },
+{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x01 }, { 0xf, 0x0a }, { WAIT_IDLE },
+{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x01 }, { 0xf, 0x0b }, { WAIT_IDLE },
+{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x01 }, { 0xf, 0x0c }, { WAIT_IDLE },
+{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x01 }, { 0xf, 0x0d }, { WAIT_IDLE },
+{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x01 }, { 0xf, 0x0e }, { WAIT_IDLE },
+{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x01 }, { 0xf, 0x0f }, { WAIT_IDLE },
+{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE },
+
+{ 0xe, 0xb0 }, { 0xf, 0x20 }, { WAIT_IDLE },
+{ 0xe, 0xb1 }, { 0xf, 0x20 }, { WAIT_IDLE },
+{ 0xe, 0xb2 }, { 0xf, 0x20 }, { WAIT_IDLE },
+{ 0xe, 0xb3 }, { 0xf, 0x20 }, { WAIT_IDLE },
+{ 0xe, 0xb4 }, { 0xf, 0x20 }, { WAIT_IDLE },
+{ 0xe, 0xb5 }, { 0xf, 0x20 }, { WAIT_IDLE },
+{ 0xe, 0xb6 }, { 0xf, 0x20 }, { WAIT_IDLE },
+{ 0xe, 0xb7 }, { 0xf, 0x20 }, { WAIT_IDLE },
+{ 0xe, 0xb8 }, { 0xf, 0x20 }, { WAIT_IDLE },
+{ 0xe, 0xb9 }, { 0xf, 0x20 }, { WAIT_IDLE },
+{ 0xe, 0xba }, { 0xf, 0x20 }, { WAIT_IDLE },
+{ 0xe, 0xbb }, { 0xf, 0x20 }, { WAIT_IDLE },
+{ 0xe, 0xbc }, { 0xf, 0x20 }, { WAIT_IDLE },
+{ 0xe, 0xbd }, { 0xf, 0x20 }, { WAIT_IDLE },
+{ 0xe, 0xbe }, { 0xf, 0x20 }, { WAIT_IDLE },
+{ 0xe, 0xbf }, { 0xf, 0x20 }, { WAIT_IDLE },
+
+{ 0xe, 0xf0 }, { 0xf, 0x20 }, { WAIT_IDLE },
+{ 0xe, 0xf1 }, { 0xf, 0x20 }, { WAIT_IDLE },
+{ 0xe, 0xf2 }, { 0xf, 0x20 }, { WAIT_IDLE },
+{ 0xe, 0xf3 }, { 0xf, 0x20 }, { WAIT_IDLE },
+{ 0xe, 0xf4 }, { 0xf, 0x20 }, { WAIT_IDLE },
+{ 0xe, 0xf5 }, { 0xf, 0x20 }, { WAIT_IDLE },
+{ 0xe, 0xf6 }, { 0xf, 0x20 }, { WAIT_IDLE },
+{ 0xe, 0xf7 }, { 0xf, 0x20 }, { WAIT_IDLE },
+{ 0xe, 0xf8 }, { 0xf, 0x20 }, { WAIT_IDLE },
+{ 0xe, 0xf9 }, { 0xf, 0x20 }, { WAIT_IDLE },
+{ 0xe, 0xfa }, { 0xf, 0x20 }, { WAIT_IDLE },
+{ 0xe, 0xfb }, { 0xf, 0x20 }, { WAIT_IDLE },
+{ 0xe, 0xfc }, { 0xf, 0x20 }, { WAIT_IDLE },
+{ 0xe, 0xfd }, { 0xf, 0x20 }, { WAIT_IDLE },
+{ 0xe, 0xfe }, { 0xf, 0x20 }, { WAIT_IDLE },
+{ 0xe, 0xff }, { 0xf, 0x20 }, { WAIT_IDLE },
+
+{ 0xe, 0x10 }, { 0xf, 0xff }, { WAIT_IDLE },
+{ 0xe, 0x11 }, { 0xf, 0xff }, { WAIT_IDLE },
+{ 0xe, 0x12 }, { 0xf, 0xff }, { WAIT_IDLE },
+{ 0xe, 0x13 }, { 0xf, 0xff }, { WAIT_IDLE },
+{ 0xe, 0x14 }, { 0xf, 0xff }, { WAIT_IDLE },
+{ 0xe, 0x15 }, { 0xf, 0xff }, { WAIT_IDLE },
+{ 0xe, 0x16 }, { 0xf, 0xff }, { WAIT_IDLE },
+{ 0xe, 0x17 }, { 0xf, 0xff }, { WAIT_IDLE },
+{ 0xe, 0x18 }, { 0xf, 0xff }, { WAIT_IDLE },
+{ 0xe, 0x19 }, { 0xf, 0xff }, { WAIT_IDLE },
+{ 0xe, 0x1a }, { 0xf, 0xff }, { WAIT_IDLE },
+{ 0xe, 0x1b }, { 0xf, 0xff }, { WAIT_IDLE },
+{ 0xe, 0x1c }, { 0xf, 0xff }, { WAIT_IDLE },
+{ 0xe, 0x1d }, { 0xf, 0xff }, { WAIT_IDLE },
+{ 0xe, 0x1e }, { 0xf, 0x40 }, { WAIT_IDLE },
+{ 0xe, 0x1f }, { 0xf, 0xff }, { WAIT_IDLE },
+{ 0xe, 0x20 }, { 0xf, 0xff }, { WAIT_IDLE },
+{ 0xe, 0x21 }, { 0xf, 0xff }, { WAIT_IDLE },
+{ 0xe, 0x22 }, { 0xf, 0xff }, { WAIT_IDLE },
+{ 0xe, 0x23 }, { 0xf, 0xff }, { WAIT_IDLE },
+{ 0xe, 0x24 }, { 0xf, 0xff }, { WAIT_IDLE },
+{ 0xe, 0x25 }, { 0xf, 0xff }, { WAIT_IDLE },
+{ 0xe, 0x26 }, { 0xf, 0xff }, { WAIT_IDLE },
+{ 0xe, 0x27 }, { 0xf, 0xff }, { WAIT_IDLE },
+{ 0xe, 0x28 }, { 0xf, 0xff }, { WAIT_IDLE },
+{ 0xe, 0x29 }, { 0xf, 0xff }, { WAIT_IDLE },
+{ 0xe, 0x2a }, { 0xf, 0xff }, { WAIT_IDLE },
+{ 0xe, 0x2b }, { 0xf, 0xff }, { WAIT_IDLE },
+{ 0xe, 0x2c }, { 0xf, 0xff }, { WAIT_IDLE },
+{ 0xe, 0x2d }, { 0xf, 0xff }, { WAIT_IDLE },
+{ 0xe, 0x2e }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x2f }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x30 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x31 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x32 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x33 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x34 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x35 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x36 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x37 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x38 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x39 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x3a }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x3b }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x3c }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x3d }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x3e }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x3f }, { 0xf, 0x20 }, { WAIT_IDLE },
+{ 0xe, 0x40 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x41 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x42 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x43 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x44 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x45 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x46 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x47 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x48 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x49 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x4a }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x4b }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x4c }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x4d }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x4e }, { 0xf, 0x0e }, { WAIT_IDLE },
+{ 0xe, 0x4f }, { 0xf, 0x0e }, { WAIT_IDLE },
+{ 0xe, 0x50 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x51 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x52 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x53 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x54 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x55 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x56 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x57 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x58 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x59 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x5a }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x5b }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x5c }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x5d }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x5e }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x5f }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x60 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x61 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x62 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x63 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x64 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x65 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x66 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x67 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x68 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x69 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x6a }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x6b }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x6c }, { 0xf, 0x40 }, { WAIT_IDLE },
+{ 0xe, 0x6d }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x6e }, { 0xf, 0x40 }, { WAIT_IDLE },
+{ 0xe, 0x6f }, { 0xf, 0x40 }, { WAIT_IDLE },
+{ 0xe, 0x70 }, { 0xf, 0xc0 }, { WAIT_IDLE },
+{ 0xe, 0x71 }, { 0xf, 0xc0 }, { WAIT_IDLE },
+{ 0xe, 0x72 }, { 0xf, 0xc0 }, { WAIT_IDLE },
+{ 0xe, 0x73 }, { 0xf, 0xc0 }, { WAIT_IDLE },
+{ 0xe, 0x74 }, { 0xf, 0xc0 }, { WAIT_IDLE },
+{ 0xe, 0x75 }, { 0xf, 0xc0 }, { WAIT_IDLE },
+{ 0xe, 0x76 }, { 0xf, 0xc0 }, { WAIT_IDLE },
+{ 0xe, 0x77 }, { 0xf, 0xc0 }, { WAIT_IDLE },
+{ 0xe, 0x78 }, { 0xf, 0xc0 }, { WAIT_IDLE },
+{ 0xe, 0x79 }, { 0xf, 0xc0 }, { WAIT_IDLE },
+{ 0xe, 0x7a }, { 0xf, 0xc0 }, { WAIT_IDLE },
+{ 0xe, 0x7b }, { 0xf, 0xc0 }, { WAIT_IDLE },
+{ 0xe, 0x7c }, { 0xf, 0xc0 }, { WAIT_IDLE },
+{ 0xe, 0x7d }, { 0xf, 0xc0 }, { WAIT_IDLE },
+{ 0xe, 0x7e }, { 0xf, 0xc0 }, { WAIT_IDLE },
+{ 0xe, 0x7f }, { 0xf, 0xc0 }, { WAIT_IDLE },
+{ 0xe, 0x80 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x81 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x82 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x83 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x84 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x85 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x86 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x87 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x88 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x89 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x8a }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x8b }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x8c }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x8d }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x8e }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x8f }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x90 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x91 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x92 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x93 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x94 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x95 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x96 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x97 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x98 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x99 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x9a }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x9b }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x9c }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x9d }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x9e }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x9f }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xa0 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xa1 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xa2 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xa3 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xa4 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xa5 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xa6 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xa7 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xa8 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xa9 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xaa }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xab }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xac }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xad }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xae }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xaf }, { 0xf, 0x00 }, { WAIT_IDLE },
+
+{ 0xe, 0xc0 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xc1 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xc2 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xc3 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xc4 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xc5 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xc6 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xc7 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xc8 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xc9 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xca }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xcb }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xcc }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xcd }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xce }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xcf }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xd0 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xd1 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xd2 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xd3 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xd4 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xd5 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xd6 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xd7 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xd8 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xd9 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xda }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xdb }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xdc }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xdd }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xde }, { 0xf, 0x10 }, { WAIT_IDLE },
+{ 0xe, 0xdf }, { 0xf, 0x10 }, { WAIT_IDLE },
+{ 0xe, 0xe0 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xe1 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xe2 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xe3 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xe4 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xe5 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xe6 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xe7 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xe8 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xe9 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xea }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xeb }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xec }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xed }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xee }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xef }, { 0xf, 0x00 }, { WAIT_IDLE },
+
+{ 0xe, 0x01 }, { 0xf, 0x00 }, { 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE },
+{ 0xe, 0x01 }, { 0xf, 0x01 }, { 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE },
+{ 0xe, 0x01 }, { 0xf, 0x02 }, { 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE },
+{ 0xe, 0x01 }, { 0xf, 0x03 }, { 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE },
+{ 0xe, 0x01 }, { 0xf, 0x04 }, { 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE },
+{ 0xe, 0x01 }, { 0xf, 0x05 }, { 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE },
+{ 0xe, 0x01 }, { 0xf, 0x06 }, { 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE },
+{ 0xe, 0x01 }, { 0xf, 0x07 }, { 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE },
+{ 0xe, 0x01 }, { 0xf, 0x08 }, { 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE },
+{ 0xe, 0x01 }, { 0xf, 0x09 }, { 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE },
+{ 0xe, 0x01 }, { 0xf, 0x0a }, { 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE },
+{ 0xe, 0x01 }, { 0xf, 0x0b }, { 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE },
+{ 0xe, 0x01 }, { 0xf, 0x0c }, { 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE },
+{ 0xe, 0x01 }, { 0xf, 0x0d }, { 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE },
+{ 0xe, 0x01 }, { 0xf, 0x0e }, { 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE },
+{ 0xe, 0x01 }, { 0xf, 0x0f }, { 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE },
+
+/* mute on */
+{ 0x8, 0x02 },
+
+/* Now set the coefficients and so forth for the programs above */
+{ 0xb, 0x07 }, { 0xa, 0x46 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x49 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xb, 0x00 }, { 0xa, 0x4b }, { 0xd, 0x03 }, { 0xc, 0x11 }, { WAIT_IDLE },
+{ 0xb, 0x00 }, { 0xa, 0x4d }, { 0xd, 0x01 }, { 0xc, 0x32 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x46 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x49 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x40 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x41 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xb, 0x01 }, { 0xa, 0x40 }, { 0xd, 0x02 }, { 0xc, 0x40 }, { WAIT_IDLE },
+{ 0xb, 0x01 }, { 0xa, 0x41 }, { 0xd, 0x02 }, { 0xc, 0x60 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x40 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x41 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x47 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x4a }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xb, 0x00 }, { 0xa, 0x47 }, { 0xd, 0x01 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xb, 0x00 }, { 0xa, 0x4a }, { 0xd, 0x01 }, { 0xc, 0x20 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x47 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x4a }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x7c }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x7e }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xb, 0x00 }, { 0xa, 0x00 }, { 0xd, 0x01 }, { 0xc, 0x1c }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x7c }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x7e }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x44 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xb, 0x00 }, { 0xa, 0x44 }, { 0xd, 0x01 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x44 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x42 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x43 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xb, 0x00 }, { 0xa, 0x42 }, { 0xd, 0x01 }, { 0xc, 0x1a }, { WAIT_IDLE },
+{ 0xb, 0x00 }, { 0xa, 0x43 }, { 0xd, 0x01 }, { 0xc, 0x20 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x42 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x43 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x40 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x41 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xb, 0x01 }, { 0xa, 0x40 }, { 0xd, 0x02 }, { 0xc, 0x40 }, { WAIT_IDLE },
+{ 0xb, 0x01 }, { 0xa, 0x41 }, { 0xd, 0x02 }, { 0xc, 0x60 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x40 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x41 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x44 }, { 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x42 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x43 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x40 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x41 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x51 }, { 0xd, 0x06 }, { 0xc, 0x40 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x50 }, { 0xd, 0x06 }, { 0xc, 0x40 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x4f }, { 0xd, 0x03 }, { 0xc, 0x81 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x53 }, { 0xd, 0x1a }, { 0xc, 0x76 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x54 }, { 0xd, 0x0d }, { 0xc, 0x8b }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x55 }, { 0xd, 0x04 }, { 0xc, 0xe9 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x56 }, { 0xd, 0x0b }, { 0xc, 0x17 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x57 }, { 0xd, 0x1a }, { 0xc, 0x38 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x58 }, { 0xd, 0x0d }, { 0xc, 0xc9 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x59 }, { 0xd, 0x04 }, { 0xc, 0x6f }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x5a }, { 0xd, 0x0b }, { 0xc, 0x91 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x73 }, { 0xd, 0x14 }, { 0xc, 0xda }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x74 }, { 0xd, 0x0d }, { 0xc, 0x93 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x75 }, { 0xd, 0x04 }, { 0xc, 0xd9 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x76 }, { 0xd, 0x05 }, { 0xc, 0x93 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x77 }, { 0xd, 0x14 }, { 0xc, 0xda }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x78 }, { 0xd, 0x0d }, { 0xc, 0x93 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x79 }, { 0xd, 0x04 }, { 0xc, 0xd9 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x7a }, { 0xd, 0x05 }, { 0xc, 0x93 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x5e }, { 0xd, 0x03 }, { 0xc, 0x68 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x5c }, { 0xd, 0x04 }, { 0xc, 0x31 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x5d }, { 0xd, 0x04 }, { 0xc, 0x31 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x62 }, { 0xd, 0x03 }, { 0xc, 0x52 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x60 }, { 0xd, 0x04 }, { 0xc, 0x76 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x61 }, { 0xd, 0x04 }, { 0xc, 0x76 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x66 }, { 0xd, 0x03 }, { 0xc, 0x2e }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x64 }, { 0xd, 0x04 }, { 0xc, 0xda }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x65 }, { 0xd, 0x04 }, { 0xc, 0xda }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x6a }, { 0xd, 0x02 }, { 0xc, 0xf6 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x68 }, { 0xd, 0x05 }, { 0xc, 0x62 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x69 }, { 0xd, 0x05 }, { 0xc, 0x62 }, { WAIT_IDLE },
+{ 0xb, 0x06 }, { 0xa, 0x46 }, { 0xd, 0x0a }, { 0xc, 0x22 }, { WAIT_IDLE },
+{ 0xb, 0x06 }, { 0xa, 0x48 }, { 0xd, 0x0d }, { 0xc, 0x24 }, { WAIT_IDLE },
+{ 0xb, 0x06 }, { 0xa, 0x6e }, { 0xd, 0x11 }, { 0xc, 0xd3 }, { WAIT_IDLE },
+{ 0xb, 0x06 }, { 0xa, 0x70 }, { 0xd, 0x15 }, { 0xc, 0xcb }, { WAIT_IDLE },
+{ 0xb, 0x06 }, { 0xa, 0x52 }, { 0xd, 0x20 }, { 0xc, 0x93 }, { WAIT_IDLE },
+{ 0xb, 0x06 }, { 0xa, 0x54 }, { 0xd, 0x20 }, { 0xc, 0x54 }, { WAIT_IDLE },
+{ 0xb, 0x06 }, { 0xa, 0x4a }, { 0xd, 0x27 }, { 0xc, 0x1d }, { WAIT_IDLE },
+{ 0xb, 0x06 }, { 0xa, 0x58 }, { 0xd, 0x2f }, { 0xc, 0xc8 }, { WAIT_IDLE },
+{ 0xb, 0x06 }, { 0xa, 0x5c }, { 0xd, 0x30 }, { 0xc, 0x07 }, { WAIT_IDLE },
+{ 0xb, 0x06 }, { 0xa, 0x4c }, { 0xd, 0x37 }, { 0xc, 0x90 }, { WAIT_IDLE },
+{ 0xb, 0x06 }, { 0xa, 0x60 }, { 0xd, 0x3d }, { 0xc, 0xdb }, { WAIT_IDLE },
+{ 0xb, 0x06 }, { 0xa, 0x64 }, { 0xd, 0x3e }, { 0xc, 0x42 }, { WAIT_IDLE },
+{ 0xb, 0x06 }, { 0xa, 0x4e }, { 0xd, 0x45 }, { 0xc, 0x78 }, { WAIT_IDLE },
+{ 0xb, 0x06 }, { 0xa, 0x68 }, { 0xd, 0x4c }, { 0xc, 0x48 }, { WAIT_IDLE },
+{ 0xb, 0x06 }, { 0xa, 0x6c }, { 0xd, 0x4c }, { 0xc, 0x6c }, { WAIT_IDLE },
+{ 0xb, 0x06 }, { 0xa, 0x50 }, { 0xd, 0x52 }, { 0xc, 0xe2 }, { WAIT_IDLE },
+{ 0xb, 0x06 }, { 0xa, 0x42 }, { 0xd, 0x02 }, { 0xc, 0xba }, { WAIT_IDLE },
+
+/* Some settings (?) */
+{ WAIT_IDLE }, { 0xe, 0x1e }, { 0xf, 0x14 },
+{ WAIT_IDLE }, { 0xe, 0xde }, { 0xf, 0x20 },
+{ WAIT_IDLE }, { 0xe, 0xdf }, { 0xf, 0x20 },
+
+/* some more coefficients */
+{ WAIT_IDLE }, { 0xb, 0x06 }, { 0xa, 0x78 }, { 0xd, 0x00 }, { 0xc, 0x40 },
+{ WAIT_IDLE }, { 0xb, 0x07 }, { 0xa, 0x03 }, { 0xd, 0x0f }, { 0xc, 0xff },
+{ WAIT_IDLE }, { 0xb, 0x07 }, { 0xa, 0x0b }, { 0xd, 0x0f }, { 0xc, 0xff },
+{ WAIT_IDLE }, { 0xb, 0x07 }, { 0xa, 0x02 }, { 0xd, 0x00 }, { 0xc, 0x00 },
+{ WAIT_IDLE }, { 0xb, 0x07 }, { 0xa, 0x0a }, { 0xd, 0x00 }, { 0xc, 0x00 },
+{ WAIT_IDLE }, { 0xb, 0x07 }, { 0xa, 0x46 }, { 0xd, 0x00 }, { 0xc, 0x00 },
+{ WAIT_IDLE }, { 0xb, 0x07 }, { 0xa, 0x49 }, { 0xd, 0x00 }, { 0xc, 0x00 },
+
+/* Now, for some strange reason, lets reload every page
+   and all the coefficients over again. I have *NO* idea
+   why this is done. I do know that no sound is produced
+   is this phase is omitted. */
+{ 0x9, 0x05 }, { 0xb, 0x00 }, { 0xa, 0x10 },
+
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x02 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+
+{ 0x9, 0x05 }, { 0xb, 0x01 }, { 0xa, 0x10 },
+
+{ 0xd, 0x01 }, { 0xc, 0xc0 }, { WAIT_IDLE },
+{ 0xd, 0x01 }, { 0xc, 0xfa }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x1a }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+
+{ WAIT_IDLE }, { WAIT_IDLE },
+
+{ 0x9, 0x05 }, { 0xb, 0x02 }, { 0xa, 0x10 },
+
+{ 0xc, 0x46 }, { WAIT_IDLE },
+{ 0xc, 0x46 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+
+{ 0x9, 0x05 }, { 0xb, 0x03 }, { 0xa, 0x10 },
+
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+
+{ 0x9, 0x05 }, { 0xb, 0x04 }, { 0xa, 0x10 },
+
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xc, 0x00 }, { WAIT_IDLE },
+
+/* Page six v.2 */
+{ 0x9, 0x01 }, { 0xb, 0x06 },
+
+{ 0xa, 0x10 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x12 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x14 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x16 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x18 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x1a }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x1c }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x1e }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x20 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x22 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x24 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x26 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x28 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x2a }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x2c }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x2e }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x30 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x32 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x34 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x36 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x38 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x3a }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x3c }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xa, 0x3e }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+
+{ 0x9, 0x05 }, { 0xb, 0x07 }, { 0xa, 0x10 },
+
+{ 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE },
+{ 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+
+{ 0xe, 0x01 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x01 }, { 0xf, 0x01 }, { WAIT_IDLE },
+{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x01 }, { 0xf, 0x02 }, { WAIT_IDLE },
+{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x01 }, { 0xf, 0x03 }, { WAIT_IDLE },
+{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x01 }, { 0xf, 0x04 }, { WAIT_IDLE },
+{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x01 }, { 0xf, 0x05 }, { WAIT_IDLE },
+{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x01 }, { 0xf, 0x06 }, { WAIT_IDLE },
+{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x01 }, { 0xf, 0x07 }, { WAIT_IDLE },
+{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xb0 }, { 0xf, 0x20 }, { WAIT_IDLE },
+{ 0xe, 0xb1 }, { 0xf, 0x20 }, { WAIT_IDLE },
+{ 0xe, 0xb2 }, { 0xf, 0x20 }, { WAIT_IDLE },
+{ 0xe, 0xb3 }, { 0xf, 0x20 }, { WAIT_IDLE },
+{ 0xe, 0xb4 }, { 0xf, 0x20 }, { WAIT_IDLE },
+{ 0xe, 0xb5 }, { 0xf, 0x20 }, { WAIT_IDLE },
+{ 0xe, 0xb6 }, { 0xf, 0x20 }, { WAIT_IDLE },
+{ 0xe, 0xb7 }, { 0xf, 0x20 }, { WAIT_IDLE },
+{ 0xe, 0xf0 }, { 0xf, 0x20 }, { WAIT_IDLE },
+{ 0xe, 0xf1 }, { 0xf, 0x20 }, { WAIT_IDLE },
+{ 0xe, 0xf2 }, { 0xf, 0x20 }, { WAIT_IDLE },
+{ 0xe, 0xf3 }, { 0xf, 0x20 }, { WAIT_IDLE },
+{ 0xe, 0xf4 }, { 0xf, 0x20 }, { WAIT_IDLE },
+{ 0xe, 0xf5 }, { 0xf, 0x20 }, { WAIT_IDLE },
+{ 0xe, 0xf6 }, { 0xf, 0x20 }, { WAIT_IDLE },
+{ 0xe, 0xf7 }, { 0xf, 0x20 }, { WAIT_IDLE },
+{ 0xe, 0x10 }, { 0xf, 0xff }, { WAIT_IDLE },
+{ 0xe, 0x11 }, { 0xf, 0xff }, { WAIT_IDLE },
+{ 0xe, 0x12 }, { 0xf, 0xff }, { WAIT_IDLE },
+{ 0xe, 0x13 }, { 0xf, 0xff }, { WAIT_IDLE },
+{ 0xe, 0x14 }, { 0xf, 0xff }, { WAIT_IDLE },
+{ 0xe, 0x15 }, { 0xf, 0xff }, { WAIT_IDLE },
+{ 0xe, 0x16 }, { 0xf, 0xff }, { WAIT_IDLE },
+{ 0xe, 0x17 }, { 0xf, 0xff }, { WAIT_IDLE },
+{ 0xe, 0x20 }, { 0xf, 0xff }, { WAIT_IDLE },
+{ 0xe, 0x21 }, { 0xf, 0xff }, { WAIT_IDLE },
+{ 0xe, 0x22 }, { 0xf, 0xff }, { WAIT_IDLE },
+{ 0xe, 0x23 }, { 0xf, 0xff }, { WAIT_IDLE },
+{ 0xe, 0x24 }, { 0xf, 0xff }, { WAIT_IDLE },
+{ 0xe, 0x25 }, { 0xf, 0xff }, { WAIT_IDLE },
+{ 0xe, 0x26 }, { 0xf, 0xff }, { WAIT_IDLE },
+{ 0xe, 0x27 }, { 0xf, 0xff }, { WAIT_IDLE },
+{ 0xe, 0x30 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x31 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x32 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x33 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x34 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x35 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x36 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x37 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x40 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x41 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x42 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x43 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x44 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x45 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x46 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x47 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x50 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x51 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x52 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x53 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x54 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x55 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x56 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x57 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x60 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x61 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x62 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x63 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x64 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x65 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x66 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x67 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x70 }, { 0xf, 0xc0 }, { WAIT_IDLE },
+{ 0xe, 0x71 }, { 0xf, 0xc0 }, { WAIT_IDLE },
+{ 0xe, 0x72 }, { 0xf, 0xc0 }, { WAIT_IDLE },
+{ 0xe, 0x73 }, { 0xf, 0xc0 }, { WAIT_IDLE },
+{ 0xe, 0x74 }, { 0xf, 0xc0 }, { WAIT_IDLE },
+{ 0xe, 0x75 }, { 0xf, 0xc0 }, { WAIT_IDLE },
+{ 0xe, 0x76 }, { 0xf, 0xc0 }, { WAIT_IDLE },
+{ 0xe, 0x77 }, { 0xf, 0xc0 }, { WAIT_IDLE },
+{ 0xe, 0x80 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x81 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x82 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x83 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x84 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x85 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x86 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x87 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x90 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x91 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x92 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x93 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x94 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x95 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x96 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x97 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xa0 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xa1 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xa2 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xa3 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xa4 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xa5 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xa6 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xa7 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xc0 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xc1 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xc2 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xc3 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xc4 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xc5 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xc6 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xc7 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xd0 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xd1 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xd2 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xd3 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xd4 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xd5 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xd6 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xd7 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xe0 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xe1 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xe2 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xe3 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xe4 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xe5 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xe6 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0xe7 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x01 }, { 0xf, 0x00 }, { WAIT_IDLE },
+{ 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE },
+{ 0xe, 0x01 }, { 0xf, 0x01 }, { WAIT_IDLE },
+{ 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE },
+{ 0xe, 0x01 }, { 0xf, 0x02 }, { WAIT_IDLE },
+{ 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE },
+{ 0xe, 0x01 }, { 0xf, 0x03 }, { WAIT_IDLE },
+{ 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE },
+{ 0xe, 0x01 }, { 0xf, 0x04 }, { WAIT_IDLE },
+{ 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE },
+{ 0xe, 0x01 }, { 0xf, 0x05 }, { WAIT_IDLE },
+{ 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE },
+{ 0xe, 0x01 }, { 0xf, 0x06 }, { WAIT_IDLE },
+{ 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE },
+{ 0xe, 0x01 }, { 0xf, 0x07 }, { WAIT_IDLE },
+{ 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE },
+
+{ 0xb, 0x07 }, { 0xa, 0x46 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x49 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x45 }, { 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x48 }, { 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x7b }, { 0xd, 0x04 }, { 0xc, 0xcc }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x7d }, { 0xd, 0x04 }, { 0xc, 0xcc }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x7c }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x7e }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x46 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x49 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x47 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x4a }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
+
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x00 }, { 0xc, 0x00 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x00 }, { 0xc, 0x00 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x00 }, { 0xc, 0x28 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x00 }, { 0xc, 0x28 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x00 }, { 0xc, 0x51 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x00 }, { 0xc, 0x51 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x00 }, { 0xc, 0x7a },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x00 }, { 0xc, 0x7a },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x00 }, { 0xc, 0xa3 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x00 }, { 0xc, 0xa3 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x00 }, { 0xc, 0xcc },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x00 }, { 0xc, 0xcc },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x00 }, { 0xc, 0xf5 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x00 }, { 0xc, 0xf5 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x01 }, { 0xc, 0x1e },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x01 }, { 0xc, 0x1e },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x01 }, { 0xc, 0x47 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x01 }, { 0xc, 0x47 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x01 }, { 0xc, 0x70 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x01 }, { 0xc, 0x70 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x01 }, { 0xc, 0x99 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x01 }, { 0xc, 0x99 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x01 }, { 0xc, 0xc2 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x01 }, { 0xc, 0xc2 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x01 }, { 0xc, 0xeb },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x01 }, { 0xc, 0xeb },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x02 }, { 0xc, 0x14 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x02 }, { 0xc, 0x14 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x02 }, { 0xc, 0x3d },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x02 }, { 0xc, 0x3d },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x02 }, { 0xc, 0x66 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x02 }, { 0xc, 0x66 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x02 }, { 0xc, 0x8f },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x02 }, { 0xc, 0x8f },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x02 }, { 0xc, 0xb8 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x02 }, { 0xc, 0xb8 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x02 }, { 0xc, 0xe1 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x02 }, { 0xc, 0xe1 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x03 }, { 0xc, 0x0a },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x03 }, { 0xc, 0x0a },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x03 }, { 0xc, 0x33 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x03 }, { 0xc, 0x33 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x03 }, { 0xc, 0x5c },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x03 }, { 0xc, 0x5c },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x03 }, { 0xc, 0x85 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x03 }, { 0xc, 0x85 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x03 }, { 0xc, 0xae },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x03 }, { 0xc, 0xae },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x03 }, { 0xc, 0xd7 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x03 }, { 0xc, 0xd7 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x04 }, { 0xc, 0x00 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x04 }, { 0xc, 0x00 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x04 }, { 0xc, 0x28 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x04 }, { 0xc, 0x28 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x04 }, { 0xc, 0x51 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x04 }, { 0xc, 0x51 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x04 }, { 0xc, 0x7a },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x04 }, { 0xc, 0x7a },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x04 }, { 0xc, 0xa3 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x04 }, { 0xc, 0xa3 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x04 }, { 0xc, 0xcc },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x04 }, { 0xc, 0xcc },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x04 }, { 0xc, 0xf5 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x04 }, { 0xc, 0xf5 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x05 }, { 0xc, 0x1e },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x05 }, { 0xc, 0x1e },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x05 }, { 0xc, 0x47 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x05 }, { 0xc, 0x47 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x05 }, { 0xc, 0x70 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x05 }, { 0xc, 0x70 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x05 }, { 0xc, 0x99 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x05 }, { 0xc, 0x99 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x05 }, { 0xc, 0xc2 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x05 }, { 0xc, 0xc2 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x05 }, { 0xc, 0xeb },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x05 }, { 0xc, 0xeb },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x06 }, { 0xc, 0x14 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x06 }, { 0xc, 0x14 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x06 }, { 0xc, 0x3d },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x06 }, { 0xc, 0x3d },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x06 }, { 0xc, 0x66 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x06 }, { 0xc, 0x66 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x06 }, { 0xc, 0x8f },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x06 }, { 0xc, 0x8f },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x06 }, { 0xc, 0xb8 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x06 }, { 0xc, 0xb8 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x06 }, { 0xc, 0xe1 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x06 }, { 0xc, 0xe1 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x07 }, { 0xc, 0x0a },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x07 }, { 0xc, 0x0a },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x07 }, { 0xc, 0x33 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x07 }, { 0xc, 0x33 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x07 }, { 0xc, 0x5c },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x07 }, { 0xc, 0x5c },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x07 }, { 0xc, 0x85 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x07 }, { 0xc, 0x85 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x07 }, { 0xc, 0xae },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x07 }, { 0xc, 0xae },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x07 }, { 0xc, 0xd7 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x07 }, { 0xc, 0xd7 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x08 }, { 0xc, 0x00 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x08 }, { 0xc, 0x00 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x08 }, { 0xc, 0x28 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x08 }, { 0xc, 0x28 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x08 }, { 0xc, 0x51 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x08 }, { 0xc, 0x51 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x08 }, { 0xc, 0x7a },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x08 }, { 0xc, 0x7a },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x08 }, { 0xc, 0xa3 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x08 }, { 0xc, 0xa3 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x08 }, { 0xc, 0xcc },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x08 }, { 0xc, 0xcc },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x08 }, { 0xc, 0xf5 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x08 }, { 0xc, 0xf5 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x09 }, { 0xc, 0x1e },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x09 }, { 0xc, 0x1e },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x09 }, { 0xc, 0x47 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x09 }, { 0xc, 0x47 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x09 }, { 0xc, 0x70 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x09 }, { 0xc, 0x70 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x09 }, { 0xc, 0x99 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x09 }, { 0xc, 0x99 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x09 }, { 0xc, 0xc2 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x09 }, { 0xc, 0xc2 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x09 }, { 0xc, 0xeb },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x09 }, { 0xc, 0xeb },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0a }, { 0xc, 0x14 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0a }, { 0xc, 0x14 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0a }, { 0xc, 0x3d },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0a }, { 0xc, 0x3d },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0a }, { 0xc, 0x66 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0a }, { 0xc, 0x66 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0a }, { 0xc, 0x8f },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0a }, { 0xc, 0x8f },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0a }, { 0xc, 0xb8 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0a }, { 0xc, 0xb8 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0a }, { 0xc, 0xe1 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0a }, { 0xc, 0xe1 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0b }, { 0xc, 0x0a },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0b }, { 0xc, 0x0a },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0b }, { 0xc, 0x33 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0b }, { 0xc, 0x33 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0b }, { 0xc, 0x5c },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0b }, { 0xc, 0x5c },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0b }, { 0xc, 0x85 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0b }, { 0xc, 0x85 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0b }, { 0xc, 0xae },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0b }, { 0xc, 0xae },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0b }, { 0xc, 0xd7 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0b }, { 0xc, 0xd7 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0c }, { 0xc, 0x00 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0c }, { 0xc, 0x00 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0c }, { 0xc, 0x28 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0c }, { 0xc, 0x28 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0c }, { 0xc, 0x51 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0c }, { 0xc, 0x51 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0c }, { 0xc, 0x7a },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0c }, { 0xc, 0x7a },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0c }, { 0xc, 0xa3 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0c }, { 0xc, 0xa3 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0c }, { 0xc, 0xcc },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0c }, { 0xc, 0xcc },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0c }, { 0xc, 0xf5 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0c }, { 0xc, 0xf5 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0d }, { 0xc, 0x1e },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0d }, { 0xc, 0x1e },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0d }, { 0xc, 0x47 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0d }, { 0xc, 0x47 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0d }, { 0xc, 0x70 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0d }, { 0xc, 0x70 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0d }, { 0xc, 0x99 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0d }, { 0xc, 0x99 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0d }, { 0xc, 0xc2 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0d }, { 0xc, 0xc2 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0d }, { 0xc, 0xeb },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0d }, { 0xc, 0xeb },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0e }, { 0xc, 0x14 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0e }, { 0xc, 0x14 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0e }, { 0xc, 0x3d },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0e }, { 0xc, 0x3d },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0e }, { 0xc, 0x66 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0e }, { 0xc, 0x66 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0e }, { 0xc, 0x8f },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0e }, { 0xc, 0x8f },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0e }, { 0xc, 0xb8 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0e }, { 0xc, 0xb8 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0e }, { 0xc, 0xe1 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0e }, { 0xc, 0xe1 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0f }, { 0xc, 0x0a },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0f }, { 0xc, 0x0a },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0f }, { 0xc, 0x33 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0f }, { 0xc, 0x33 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0f }, { 0xc, 0x5c },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0f }, { 0xc, 0x5c },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0f }, { 0xc, 0x85 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0f }, { 0xc, 0x85 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0f }, { 0xc, 0xae },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0f }, { 0xc, 0xae },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0f }, { 0xc, 0xd7 },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0f }, { 0xc, 0xd7 },
+{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0f }, { 0xc, 0xff },
+{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0f }, { 0xc, 0xff },
+
+/* mute off */
+{ 0x8, 0x00 }, { WAIT_IDLE }
+};
index a0588c21324ac6ae98fbfccbf286139c1a97d582..4c419300305d34de140cd9c5c87399906883a3a4 100644 (file)
@@ -5,6 +5,20 @@
 #
 # Prompt user for primary drivers.
 
+config OBSOLETE_OSS
+       bool "Obsolete OSS drivers"
+       depends on SOUND_PRIME
+       help
+         This option enables support for obsolete OSS drivers that
+         are scheduled for removal in the near future since there
+         are ALSA drivers for the same hardware.
+
+         Please contact Adrian Bunk <bunk@stusta.de> if you had to
+         say Y here because your soundcard is not properly supported
+         by ALSA.
+
+         If unsure, say N.
+
 config SOUND_BT878
        tristate "BT878 audio dma"
        depends on SOUND_PRIME && PCI
@@ -33,7 +47,7 @@ config SOUND_BCM_CS4297A
 
 config SOUND_ES1371
        tristate "Creative Ensoniq AudioPCI 97 (ES1371)"
-       depends on SOUND_PRIME && PCI
+       depends on SOUND_PRIME && PCI && OBSOLETE_OSS
        help
          Say Y or M if you have a PCI sound card utilizing the Ensoniq
          ES1371 chipset, such as Ensoniq's AudioPCI97. To find out if
@@ -705,18 +719,6 @@ config AEDSP16_SBPRO
 
 endchoice
 
-config AEDSP16_MPU401
-       bool "Audio Excel DSP 16 (MPU401 emulation)"
-       depends on SOUND_AEDSP16 && SOUND_MPU401
-       help
-         Answer Y if you want your audio card to emulate the MPU-401 midi
-         interface. You should then also say Y to "MPU-401 support".
-
-         Note that the I/O base for MPU-401 support of aedsp16 is the same
-         you have selected for "MPU-401 support". If you are using this
-         driver as a module you have to specify the MPU I/O base address with
-         the parameter 'mpu_base=0xNNN'.
-
 config SOUND_VIDC
        tristate "VIDC 16-bit sound"
        depends on ARM && (ARCH_ACORN || ARCH_CLPS7500) && SOUND_OSS
index cb845580fe031ee54efcf5f19acac2a8fa025173..18e149f52a8869b6b2b22600afe17ddb194e89e7 100644 (file)
@@ -14,7 +14,7 @@ config DMASOUND_ATARI
 
 config DMASOUND_PMAC
        tristate "PowerMac DMA sound support"
-       depends on PPC32 && PPC_PMAC && SOUND && I2C
+       depends on PPC32 && PPC_PMAC && SOUND && I2C && OBSOLETE_OSS
        select DMASOUND
        help
          If you want to use the internal audio of your PowerMac in Linux,
index 8a6b1803c763e1f71bc30fc69d010a9f42839042..1bcfb3aac18dce993208d423c523b564772d4887 100644 (file)
@@ -236,7 +236,7 @@ config SND_CS5535AUDIO
 config SND_DARLA20
        tristate "(Echoaudio) Darla20"
        depends on SND
-       depends on FW_LOADER
+       select FW_LOADER
        select SND_PCM
        help
          Say 'Y' or 'M' to include support for Echoaudio Darla.
@@ -247,7 +247,7 @@ config SND_DARLA20
 config SND_GINA20
        tristate "(Echoaudio) Gina20"
        depends on SND
-       depends on FW_LOADER
+       select FW_LOADER
        select SND_PCM
        help
          Say 'Y' or 'M' to include support for Echoaudio Gina.
@@ -258,7 +258,7 @@ config SND_GINA20
 config SND_LAYLA20
        tristate "(Echoaudio) Layla20"
        depends on SND
-       depends on FW_LOADER
+       select FW_LOADER
        select SND_RAWMIDI
        select SND_PCM
        help
@@ -270,7 +270,7 @@ config SND_LAYLA20
 config SND_DARLA24
        tristate "(Echoaudio) Darla24"
        depends on SND
-       depends on FW_LOADER
+       select FW_LOADER
        select SND_PCM
        help
          Say 'Y' or 'M' to include support for Echoaudio Darla24.
@@ -281,7 +281,7 @@ config SND_DARLA24
 config SND_GINA24
        tristate "(Echoaudio) Gina24"
        depends on SND
-       depends on FW_LOADER
+       select FW_LOADER
        select SND_PCM
        help
          Say 'Y' or 'M' to include support for Echoaudio Gina24.
@@ -292,7 +292,7 @@ config SND_GINA24
 config SND_LAYLA24
        tristate "(Echoaudio) Layla24"
        depends on SND
-       depends on FW_LOADER
+       select FW_LOADER
        select SND_RAWMIDI
        select SND_PCM
        help
@@ -304,7 +304,7 @@ config SND_LAYLA24
 config SND_MONA
        tristate "(Echoaudio) Mona"
        depends on SND
-       depends on FW_LOADER
+       select FW_LOADER
        select SND_RAWMIDI
        select SND_PCM
        help
@@ -316,7 +316,7 @@ config SND_MONA
 config SND_MIA
        tristate "(Echoaudio) Mia"
        depends on SND
-       depends on FW_LOADER
+       select FW_LOADER
        select SND_RAWMIDI
        select SND_PCM
        help
@@ -328,7 +328,7 @@ config SND_MIA
 config SND_ECHO3G
        tristate "(Echoaudio) 3G cards"
        depends on SND
-       depends on FW_LOADER
+       select FW_LOADER
        select SND_RAWMIDI
        select SND_PCM
        help
@@ -340,7 +340,7 @@ config SND_ECHO3G
 config SND_INDIGO
        tristate "(Echoaudio) Indigo"
        depends on SND
-       depends on FW_LOADER
+       select FW_LOADER
        select SND_PCM
        help
          Say 'Y' or 'M' to include support for Echoaudio Indigo.
@@ -351,7 +351,7 @@ config SND_INDIGO
 config SND_INDIGOIO
        tristate "(Echoaudio) Indigo IO"
        depends on SND
-       depends on FW_LOADER
+       select FW_LOADER
        select SND_PCM
        help
          Say 'Y' or 'M' to include support for Echoaudio Indigo IO.
@@ -362,7 +362,7 @@ config SND_INDIGOIO
 config SND_INDIGODJ
        tristate "(Echoaudio) Indigo DJ"
        depends on SND
-       depends on FW_LOADER
+       select FW_LOADER
        select SND_PCM
        help
          Say 'Y' or 'M' to include support for Echoaudio Indigo DJ.
@@ -373,6 +373,7 @@ config SND_INDIGODJ
 config SND_EMU10K1
        tristate "Emu10k1 (SB Live!, Audigy, E-mu APS)"
        depends on SND
+       select FW_LOADER
        select SND_HWDEP
        select SND_RAWMIDI
        select SND_AC97_CODEC
@@ -575,6 +576,7 @@ config SND_INTEL8X0M
 config SND_KORG1212
        tristate "Korg 1212 IO"
        depends on SND
+       select FW_LOADER
        select SND_PCM
        help
          Say Y here to include support for Korg 1212IO soundcards.
@@ -585,6 +587,7 @@ config SND_KORG1212
 config SND_MAESTRO3
        tristate "ESS Allegro/Maestro3"
        depends on SND
+       select FW_LOADER
        select SND_AC97_CODEC
        help
          Say Y here to include support for soundcards based on ESS Maestro 3
@@ -629,7 +632,7 @@ config SND_PCXHR
 config SND_RIPTIDE
        tristate "Conexant Riptide"
        depends on SND
-       depends on FW_LOADER
+       select FW_LOADER
        select SND_OPL3_LIB
        select SND_MPU401_UART
        select SND_AC97_CODEC
@@ -734,6 +737,7 @@ config SND_VX222
 config SND_YMFPCI
        tristate "Yamaha YMF724/740/744/754"
        depends on SND
+       select FW_LOADER
        select SND_OPL3_LIB
        select SND_MPU401_UART
        select SND_AC97_CODEC
index d2994cb4c8c96aad65b05ef787629bfbe46983e4..74ed81081478c1266a8851f6c8709fcdcc90c486 100644 (file)
@@ -111,7 +111,7 @@ static const struct ac97_codec_id snd_ac97_codec_ids[] = {
 { 0x41445372, 0xffffffff, "AD1981A",           patch_ad1981a,  NULL },
 { 0x41445374, 0xffffffff, "AD1981B",           patch_ad1981b,  NULL },
 { 0x41445375, 0xffffffff, "AD1985",            patch_ad1985,   NULL },
-{ 0x41445378, 0xffffffff, "AD1986",            patch_ad1985,   NULL },
+{ 0x41445378, 0xffffffff, "AD1986",            patch_ad1986,   NULL },
 { 0x414c4300, 0xffffff00, "ALC100,100P",       NULL,           NULL },
 { 0x414c4710, 0xfffffff0, "ALC200,200P",       NULL,           NULL },
 { 0x414c4721, 0xffffffff, "ALC650D",           NULL,   NULL }, /* already patched */
@@ -194,6 +194,13 @@ static const struct ac97_codec_id snd_ac97_codec_ids[] = {
 
 
 static void update_power_regs(struct snd_ac97 *ac97);
+#ifdef CONFIG_SND_AC97_POWER_SAVE
+#define ac97_is_power_save_mode(ac97) \
+       ((ac97->scaps & AC97_SCAP_POWER_SAVE) && power_save)
+#else
+#define ac97_is_power_save_mode(ac97) 0
+#endif
+
 
 /*
  *  I/O routines
@@ -982,8 +989,8 @@ static int snd_ac97_free(struct snd_ac97 *ac97)
 {
        if (ac97) {
 #ifdef CONFIG_SND_AC97_POWER_SAVE
-               if (ac97->power_workq)
-                       destroy_workqueue(ac97->power_workq);
+               cancel_delayed_work(&ac97->power_work);
+               flush_scheduled_work();
 #endif
                snd_ac97_proc_done(ac97);
                if (ac97->bus)
@@ -1184,13 +1191,13 @@ static int snd_ac97_cmute_new_stereo(struct snd_card *card, char *name, int reg,
 /*
  * set dB information
  */
-static DECLARE_TLV_DB_SCALE(db_scale_4bit, -4500, 300, 0);
-static DECLARE_TLV_DB_SCALE(db_scale_5bit, -4650, 150, 0);
-static DECLARE_TLV_DB_SCALE(db_scale_6bit, -9450, 150, 0);
-static DECLARE_TLV_DB_SCALE(db_scale_5bit_12db_max, -3450, 150, 0);
-static DECLARE_TLV_DB_SCALE(db_scale_rec_gain, 0, 150, 0);
+static const DECLARE_TLV_DB_SCALE(db_scale_4bit, -4500, 300, 0);
+static const DECLARE_TLV_DB_SCALE(db_scale_5bit, -4650, 150, 0);
+static const DECLARE_TLV_DB_SCALE(db_scale_6bit, -9450, 150, 0);
+static const DECLARE_TLV_DB_SCALE(db_scale_5bit_12db_max, -3450, 150, 0);
+static const DECLARE_TLV_DB_SCALE(db_scale_rec_gain, 0, 150, 0);
 
-static unsigned int *find_db_scale(unsigned int maxval)
+static const unsigned int *find_db_scale(unsigned int maxval)
 {
        switch (maxval) {
        case 0x0f: return db_scale_4bit;
@@ -1200,8 +1207,8 @@ static unsigned int *find_db_scale(unsigned int maxval)
        return NULL;
 }
 
-static void set_tlv_db_scale(struct snd_kcontrol *kctl, unsigned int *tlv)
-{      
+static void set_tlv_db_scale(struct snd_kcontrol *kctl, const unsigned int *tlv)
+{
        kctl->tlv.p = tlv;
        if (tlv)
                kctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ;
@@ -1989,7 +1996,6 @@ int snd_ac97_mixer(struct snd_ac97_bus *bus, struct snd_ac97_template *template,
        mutex_init(&ac97->reg_mutex);
        mutex_init(&ac97->page_mutex);
 #ifdef CONFIG_SND_AC97_POWER_SAVE
-       ac97->power_workq = create_workqueue("ac97");
        INIT_DELAYED_WORK(&ac97->power_work, do_update_power);
 #endif
 
@@ -2275,15 +2281,13 @@ static void snd_ac97_powerdown(struct snd_ac97 *ac97)
        udelay(100);
        power |= AC97_PD_PR2 | AC97_PD_PR3;     /* Analog Mixer powerdown */
        snd_ac97_write(ac97, AC97_POWERDOWN, power);
-#ifdef CONFIG_SND_AC97_POWER_SAVE
-       if (power_save) {
+       if (ac97_is_power_save_mode(ac97)) {
                udelay(100);
                /* AC-link powerdown, internal Clk disable */
                /* FIXME: this may cause click noises on some boards */
                power |= AC97_PD_PR4 | AC97_PD_PR5;
                snd_ac97_write(ac97, AC97_POWERDOWN, power);
        }
-#endif
 }
 
 
@@ -2337,14 +2341,16 @@ int snd_ac97_update_power(struct snd_ac97 *ac97, int reg, int powerup)
                }
        }
 
-       if (power_save && !powerup && ac97->power_workq)
+       if (ac97_is_power_save_mode(ac97) && !powerup)
                /* adjust power-down bits after two seconds delay
                 * (for avoiding loud click noises for many (OSS) apps
                 *  that open/close frequently)
                 */
-               queue_delayed_work(ac97->power_workq, &ac97->power_work, HZ*2);
-       else
+               schedule_delayed_work(&ac97->power_work, HZ*2);
+       else {
+               cancel_delayed_work(&ac97->power_work);
                update_power_regs(ac97);
+       }
 
        return 0;
 }
@@ -2357,19 +2363,15 @@ static void update_power_regs(struct snd_ac97 *ac97)
        unsigned int power_up, bits;
        int i;
 
+       power_up = (1 << PWIDX_FRONT) | (1 << PWIDX_ADC);
+       power_up |= (1 << PWIDX_MIC);
+       if (ac97->scaps & AC97_SCAP_SURROUND_DAC)
+               power_up |= (1 << PWIDX_SURR);
+       if (ac97->scaps & AC97_SCAP_CENTER_LFE_DAC)
+               power_up |= (1 << PWIDX_CLFE);
 #ifdef CONFIG_SND_AC97_POWER_SAVE
-       if (power_save)
+       if (ac97_is_power_save_mode(ac97))
                power_up = ac97->power_up;
-       else {
-#endif
-               power_up = (1 << PWIDX_FRONT) | (1 << PWIDX_ADC);
-               power_up |= (1 << PWIDX_MIC);
-               if (ac97->scaps & AC97_SCAP_SURROUND_DAC)
-                       power_up |= (1 << PWIDX_SURR);
-               if (ac97->scaps & AC97_SCAP_CENTER_LFE_DAC)
-                       power_up |= (1 << PWIDX_CLFE);
-#ifdef CONFIG_SND_AC97_POWER_SAVE
-       }
 #endif
        if (power_up) {
                if (ac97->regs[AC97_POWERDOWN] & AC97_PD_PR2) {
@@ -2414,6 +2416,10 @@ void snd_ac97_suspend(struct snd_ac97 *ac97)
                return;
        if (ac97->build_ops->suspend)
                ac97->build_ops->suspend(ac97);
+#ifdef CONFIG_SND_AC97_POWER_SAVE
+       cancel_delayed_work(&ac97->power_work);
+       flush_scheduled_work();
+#endif
        snd_ac97_powerdown(ac97);
 }
 
index e813968e0cf8a91324e1822e2453396836cf9991..641d0c8d659ed222f7540e8483f7881c1c232ab3 100644 (file)
@@ -54,7 +54,7 @@ static int patch_build_controls(struct snd_ac97 * ac97, const struct snd_kcontro
 
 /* replace with a new TLV */
 static void reset_tlv(struct snd_ac97 *ac97, const char *name,
-                     unsigned int *tlv)
+                     const unsigned int *tlv)
 {
        struct snd_ctl_elem_id sid;
        struct snd_kcontrol *kctl;
@@ -190,14 +190,28 @@ static inline int is_clfe_on(struct snd_ac97 *ac97)
        return ac97->channel_mode >= 2;
 }
 
+/* system has shared jacks with surround out enabled */
+static inline int is_shared_surrout(struct snd_ac97 *ac97)
+{
+       return !ac97->indep_surround && is_surround_on(ac97);
+}
+
+/* system has shared jacks with center/lfe out enabled */
+static inline int is_shared_clfeout(struct snd_ac97 *ac97)
+{
+       return !ac97->indep_surround && is_clfe_on(ac97);
+}
+
+/* system has shared jacks with line in enabled */
 static inline int is_shared_linein(struct snd_ac97 *ac97)
 {
-       return ! ac97->indep_surround && is_surround_on(ac97);
+       return !ac97->indep_surround && !is_surround_on(ac97);
 }
 
+/* system has shared jacks with mic in enabled */
 static inline int is_shared_micin(struct snd_ac97 *ac97)
 {
-       return ! ac97->indep_surround && is_clfe_on(ac97);
+       return !ac97->indep_surround && !is_clfe_on(ac97);
 }
 
 
@@ -941,6 +955,9 @@ static int patch_sigmatel_stac9708_specific(struct snd_ac97 *ac97)
 {
        int err;
 
+       /* the register bit is writable, but the function is not implemented: */
+       snd_ac97_remove_ctl(ac97, "PCM Out Path & Mute", NULL);
+
        snd_ac97_rename_vol_ctl(ac97, "Headphone Playback", "Sigmatel Surround Playback");
        if ((err = patch_build_controls(ac97, &snd_ac97_stac9708_bias_control, 1)) < 0)
                return err;
@@ -1552,7 +1569,7 @@ static const struct snd_kcontrol_new snd_ac97_controls_ad1885[] = {
        AC97_SINGLE("Line Jack Sense", AC97_AD_JACK_SPDIF, 8, 1, 1), /* inverted */
 };
 
-static DECLARE_TLV_DB_SCALE(db_scale_6bit_6db_max, -8850, 150, 0);
+static const DECLARE_TLV_DB_SCALE(db_scale_6bit_6db_max, -8850, 150, 0);
 
 static int patch_ad1885_specific(struct snd_ac97 * ac97)
 {
@@ -1609,19 +1626,22 @@ int patch_ad1886(struct snd_ac97 * ac97)
        return 0;
 }
 
-/* MISC bits */
+/* MISC bits (AD1888/AD1980/AD1985 register 0x76) */
 #define AC97_AD198X_MBC                0x0003  /* mic boost */
 #define AC97_AD198X_MBC_20     0x0000  /* +20dB */
 #define AC97_AD198X_MBC_10     0x0001  /* +10dB */
 #define AC97_AD198X_MBC_30     0x0002  /* +30dB */
 #define AC97_AD198X_VREFD      0x0004  /* VREF high-Z */
-#define AC97_AD198X_VREFH      0x0008  /* 2.25V, 3.7V */
-#define AC97_AD198X_VREF_0     0x000c  /* 0V */
+#define AC97_AD198X_VREFH      0x0008  /* 0=2.25V, 1=3.7V */
+#define AC97_AD198X_VREF_0     0x000c  /* 0V (AD1985 only) */
+#define AC97_AD198X_VREF_MASK  (AC97_AD198X_VREFH | AC97_AD198X_VREFD)
+#define AC97_AD198X_VREF_SHIFT 2
 #define AC97_AD198X_SRU                0x0010  /* sample rate unlock */
 #define AC97_AD198X_LOSEL      0x0020  /* LINE_OUT amplifiers input select */
 #define AC97_AD198X_2MIC       0x0040  /* 2-channel mic select */
 #define AC97_AD198X_SPRD       0x0080  /* SPREAD enable */
-#define AC97_AD198X_DMIX0      0x0100  /* downmix mode: 0 = 6-to-4, 1 = 6-to-2 downmix */
+#define AC97_AD198X_DMIX0      0x0100  /* downmix mode: */
+                                       /*  0 = 6-to-4, 1 = 6-to-2 downmix */
 #define AC97_AD198X_DMIX1      0x0200  /* downmix mode: 1 = enabled */
 #define AC97_AD198X_HPSEL      0x0400  /* headphone amplifier input select */
 #define AC97_AD198X_CLDIS      0x0800  /* center/lfe disable */
@@ -1630,6 +1650,83 @@ int patch_ad1886(struct snd_ac97 * ac97)
 #define AC97_AD198X_AC97NC     0x4000  /* AC97 no compatible mode */
 #define AC97_AD198X_DACZ       0x8000  /* DAC zero-fill mode */
 
+/* MISC 1 bits (AD1986 register 0x76) */
+#define AC97_AD1986_MBC                0x0003  /* mic boost */
+#define AC97_AD1986_MBC_20     0x0000  /* +20dB */
+#define AC97_AD1986_MBC_10     0x0001  /* +10dB */
+#define AC97_AD1986_MBC_30     0x0002  /* +30dB */
+#define AC97_AD1986_LISEL0     0x0004  /* LINE_IN select bit 0 */
+#define AC97_AD1986_LISEL1     0x0008  /* LINE_IN select bit 1 */
+#define AC97_AD1986_LISEL_MASK (AC97_AD1986_LISEL1 | AC97_AD1986_LISEL0)
+#define AC97_AD1986_LISEL_LI   0x0000  /* LINE_IN pins as LINE_IN source */
+#define AC97_AD1986_LISEL_SURR 0x0004  /* SURROUND pins as LINE_IN source */
+#define AC97_AD1986_LISEL_MIC  0x0008  /* MIC_1/2 pins as LINE_IN source */
+#define AC97_AD1986_SRU                0x0010  /* sample rate unlock */
+#define AC97_AD1986_SOSEL      0x0020  /* SURROUND_OUT amplifiers input sel */
+#define AC97_AD1986_2MIC       0x0040  /* 2-channel mic select */
+#define AC97_AD1986_SPRD       0x0080  /* SPREAD enable */
+#define AC97_AD1986_DMIX0      0x0100  /* downmix mode: */
+                                       /*  0 = 6-to-4, 1 = 6-to-2 downmix */
+#define AC97_AD1986_DMIX1      0x0200  /* downmix mode: 1 = enabled */
+#define AC97_AD1986_CLDIS      0x0800  /* center/lfe disable */
+#define AC97_AD1986_SODIS      0x1000  /* SURROUND_OUT disable */
+#define AC97_AD1986_MSPLT      0x2000  /* mute split (read only 1) */
+#define AC97_AD1986_AC97NC     0x4000  /* AC97 no compatible mode (r/o 1) */
+#define AC97_AD1986_DACZ       0x8000  /* DAC zero-fill mode */
+
+/* MISC 2 bits (AD1986 register 0x70) */
+#define AC97_AD_MISC2          0x70    /* Misc Control Bits 2 (AD1986) */
+
+#define AC97_AD1986_CVREF0     0x0004  /* C/LFE VREF_OUT 2.25V */
+#define AC97_AD1986_CVREF1     0x0008  /* C/LFE VREF_OUT 0V */
+#define AC97_AD1986_CVREF2     0x0010  /* C/LFE VREF_OUT 3.7V */
+#define AC97_AD1986_CVREF_MASK \
+       (AC97_AD1986_CVREF2 | AC97_AD1986_CVREF1 | AC97_AD1986_CVREF0)
+#define AC97_AD1986_JSMAP      0x0020  /* Jack Sense Mapping 1 = alternate */
+#define AC97_AD1986_MMDIS      0x0080  /* Mono Mute Disable */
+#define AC97_AD1986_MVREF0     0x0400  /* MIC VREF_OUT 2.25V */
+#define AC97_AD1986_MVREF1     0x0800  /* MIC VREF_OUT 0V */
+#define AC97_AD1986_MVREF2     0x1000  /* MIC VREF_OUT 3.7V */
+#define AC97_AD1986_MVREF_MASK \
+       (AC97_AD1986_MVREF2 | AC97_AD1986_MVREF1 | AC97_AD1986_MVREF0)
+
+/* MISC 3 bits (AD1986 register 0x7a) */
+#define AC97_AD_MISC3          0x7a    /* Misc Control Bits 3 (AD1986) */
+
+#define AC97_AD1986_MMIX       0x0004  /* Mic Mix, left/right */
+#define AC97_AD1986_GPO                0x0008  /* General Purpose Out */
+#define AC97_AD1986_LOHPEN     0x0010  /* LINE_OUT headphone drive */
+#define AC97_AD1986_LVREF0     0x0100  /* LINE_OUT VREF_OUT 2.25V */
+#define AC97_AD1986_LVREF1     0x0200  /* LINE_OUT VREF_OUT 0V */
+#define AC97_AD1986_LVREF2     0x0400  /* LINE_OUT VREF_OUT 3.7V */
+#define AC97_AD1986_LVREF_MASK \
+       (AC97_AD1986_LVREF2 | AC97_AD1986_LVREF1 | AC97_AD1986_LVREF0)
+#define AC97_AD1986_JSINVA     0x0800  /* Jack Sense Invert SENSE_A */
+#define AC97_AD1986_LOSEL      0x1000  /* LINE_OUT amplifiers input select */
+#define AC97_AD1986_HPSEL0     0x2000  /* Headphone amplifiers */
+                                       /*   input select Surround DACs */
+#define AC97_AD1986_HPSEL1     0x4000  /* Headphone amplifiers input */
+                                       /*   select C/LFE DACs */
+#define AC97_AD1986_JSINVB     0x8000  /* Jack Sense Invert SENSE_B */
+
+/* Serial Config bits (AD1986 register 0x74) (incomplete) */
+#define AC97_AD1986_OMS0       0x0100  /* Optional Mic Selector bit 0 */
+#define AC97_AD1986_OMS1       0x0200  /* Optional Mic Selector bit 1 */
+#define AC97_AD1986_OMS2       0x0400  /* Optional Mic Selector bit 2 */
+#define AC97_AD1986_OMS_MASK \
+       (AC97_AD1986_OMS2 | AC97_AD1986_OMS1 | AC97_AD1986_OMS0)
+#define AC97_AD1986_OMS_M      0x0000  /* MIC_1/2 pins are MIC sources */
+#define AC97_AD1986_OMS_L      0x0100  /* LINE_IN pins are MIC sources */
+#define AC97_AD1986_OMS_C      0x0200  /* Center/LFE pins are MCI sources */
+#define AC97_AD1986_OMS_MC     0x0400  /* Mix of MIC and C/LFE pins */
+                                       /*   are MIC sources */
+#define AC97_AD1986_OMS_ML     0x0500  /* MIX of MIC and LINE_IN pins */
+                                       /*   are MIC sources */
+#define AC97_AD1986_OMS_LC     0x0600  /* MIX of LINE_IN and C/LFE pins */
+                                       /*   are MIC sources */
+#define AC97_AD1986_OMS_MLC    0x0700  /* MIX of MIC, LINE_IN, C/LFE pins */
+                                       /*   are MIC sources */
+
 
 static int snd_ac97_ad198x_spdif_source_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
 {
@@ -1952,8 +2049,80 @@ int patch_ad1980(struct snd_ac97 * ac97)
        return 0;
 }
 
+static int snd_ac97_ad1985_vrefout_info(struct snd_kcontrol *kcontrol,
+                                       struct snd_ctl_elem_info *uinfo)
+{
+       static char *texts[4] = {"High-Z", "3.7 V", "2.25 V", "0 V"};
+
+       uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
+       uinfo->count = 1;
+       uinfo->value.enumerated.items = 4;
+       if (uinfo->value.enumerated.item > 3)
+               uinfo->value.enumerated.item = 3;
+       strcpy(uinfo->value.enumerated.name,
+              texts[uinfo->value.enumerated.item]);
+       return 0;
+}
+
+static int snd_ac97_ad1985_vrefout_get(struct snd_kcontrol *kcontrol,
+                                      struct snd_ctl_elem_value *ucontrol)
+{
+       static const int reg2ctrl[4] = {2, 0, 1, 3};
+       struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
+       unsigned short val;
+       val = (ac97->regs[AC97_AD_MISC] & AC97_AD198X_VREF_MASK)
+             >> AC97_AD198X_VREF_SHIFT;
+       ucontrol->value.enumerated.item[0] = reg2ctrl[val];
+       return 0;
+}
+
+static int snd_ac97_ad1985_vrefout_put(struct snd_kcontrol *kcontrol, 
+                                      struct snd_ctl_elem_value *ucontrol)
+{
+       static const int ctrl2reg[4] = {1, 2, 0, 3};
+       struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
+       unsigned short val;
+
+       if (ucontrol->value.enumerated.item[0] > 3
+           || ucontrol->value.enumerated.item[0] < 0)
+               return -EINVAL;
+       val = ctrl2reg[ucontrol->value.enumerated.item[0]]
+             << AC97_AD198X_VREF_SHIFT;
+       return snd_ac97_update_bits(ac97, AC97_AD_MISC,
+                                   AC97_AD198X_VREF_MASK, val);
+}
+
 static const struct snd_kcontrol_new snd_ac97_ad1985_controls[] = {
-       AC97_SINGLE("Exchange Center/LFE", AC97_AD_SERIAL_CFG, 3, 1, 0)
+       AC97_SINGLE("Exchange Center/LFE", AC97_AD_SERIAL_CFG, 3, 1, 0),
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               .name = "Exchange Front/Surround",
+               .info = snd_ac97_ad1888_lohpsel_info,
+               .get = snd_ac97_ad1888_lohpsel_get,
+               .put = snd_ac97_ad1888_lohpsel_put
+       },
+       AC97_SINGLE("High Pass Filter Enable", AC97_AD_TEST2, 12, 1, 1),
+       AC97_SINGLE("Spread Front to Surround and Center/LFE",
+                   AC97_AD_MISC, 7, 1, 0),
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               .name = "Downmix",
+               .info = snd_ac97_ad1888_downmix_info,
+               .get = snd_ac97_ad1888_downmix_get,
+               .put = snd_ac97_ad1888_downmix_put
+       },
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               .name = "V_REFOUT",
+               .info = snd_ac97_ad1985_vrefout_info,
+               .get = snd_ac97_ad1985_vrefout_get,
+               .put = snd_ac97_ad1985_vrefout_put
+       },
+       AC97_SURROUND_JACK_MODE_CTL,
+       AC97_CHANNEL_MODE_CTL,
+
+       AC97_SINGLE("Headphone Jack Sense", AC97_AD_JACK_SPDIF, 10, 1, 0),
+       AC97_SINGLE("Line Jack Sense", AC97_AD_JACK_SPDIF, 12, 1, 0),
 };
 
 static void ad1985_update_jacks(struct snd_ac97 *ac97)
@@ -1967,9 +2136,16 @@ static int patch_ad1985_specific(struct snd_ac97 *ac97)
 {
        int err;
 
-       if ((err = patch_ad1980_specific(ac97)) < 0)
+       /* rename 0x04 as "Master" and 0x02 as "Master Surround" */
+       snd_ac97_rename_vol_ctl(ac97, "Master Playback",
+                               "Master Surround Playback");
+       snd_ac97_rename_vol_ctl(ac97, "Headphone Playback", "Master Playback");
+
+       if ((err = patch_build_controls(ac97, &snd_ac97_ad198x_2cmic, 1)) < 0)
                return err;
-       return patch_build_controls(ac97, snd_ac97_ad1985_controls, ARRAY_SIZE(snd_ac97_ad1985_controls));
+
+       return patch_build_controls(ac97, snd_ac97_ad1985_controls,
+                                   ARRAY_SIZE(snd_ac97_ad1985_controls));
 }
 
 static struct snd_ac97_build_ops patch_ad1985_build_ops = {
@@ -1989,24 +2165,311 @@ int patch_ad1985(struct snd_ac97 * ac97)
        ac97->build_ops = &patch_ad1985_build_ops;
        misc = snd_ac97_read(ac97, AC97_AD_MISC);
        /* switch front/surround line-out/hp-out */
-       /* center/LFE, mic in 3.75V mode */
        /* AD-compatible mode */
        /* Stereo mutes enabled */
-       /* in accordance with ADI driver: misc | 0x5c28 */
        snd_ac97_write_cache(ac97, AC97_AD_MISC, misc |
-                            AC97_AD198X_VREFH |
                             AC97_AD198X_LOSEL |
                             AC97_AD198X_HPSEL |
-                            AC97_AD198X_CLDIS |
-                            AC97_AD198X_LODIS |
                             AC97_AD198X_MSPLT |
                             AC97_AD198X_AC97NC);
        ac97->flags |= AC97_STEREO_MUTES;
+
+       /* update current jack configuration */
+       ad1985_update_jacks(ac97);
+
        /* on AD1985 rev. 3, AC'97 revision bits are zero */
        ac97->ext_id = (ac97->ext_id & ~AC97_EI_REV_MASK) | AC97_EI_REV_23;
        return 0;
 }
 
+static int snd_ac97_ad1986_bool_info(struct snd_kcontrol *kcontrol,
+                                    struct snd_ctl_elem_info *uinfo)
+{
+       uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
+       uinfo->count = 1;
+       uinfo->value.integer.min = 0;
+       uinfo->value.integer.max = 1;
+       return 0;
+}
+
+static int snd_ac97_ad1986_lososel_get(struct snd_kcontrol *kcontrol,
+                                      struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
+       unsigned short val;
+
+       val = ac97->regs[AC97_AD_MISC3];
+       ucontrol->value.integer.value[0] = (val & AC97_AD1986_LOSEL) != 0;
+       return 0;
+}
+
+static int snd_ac97_ad1986_lososel_put(struct snd_kcontrol *kcontrol,
+                                      struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
+       int ret0;
+       int ret1;
+       int sprd = (ac97->regs[AC97_AD_MISC] & AC97_AD1986_SPRD) != 0;
+
+       ret0 = snd_ac97_update_bits(ac97, AC97_AD_MISC3, AC97_AD1986_LOSEL,
+                                       ucontrol->value.integer.value[0] != 0
+                                   ? AC97_AD1986_LOSEL : 0);
+       if (ret0 < 0)
+               return ret0;
+
+       /* SOSEL is set to values of "Spread" or "Exchange F/S" controls */
+       ret1 = snd_ac97_update_bits(ac97, AC97_AD_MISC, AC97_AD1986_SOSEL,
+                                   (ucontrol->value.integer.value[0] != 0
+                                    || sprd)
+                                   ? AC97_AD1986_SOSEL : 0);
+       if (ret1 < 0)
+               return ret1;
+
+       return (ret0 > 0 || ret1 > 0) ? 1 : 0;
+}
+
+static int snd_ac97_ad1986_spread_get(struct snd_kcontrol *kcontrol,
+                                     struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
+       unsigned short val;
+
+       val = ac97->regs[AC97_AD_MISC];
+       ucontrol->value.integer.value[0] = (val & AC97_AD1986_SPRD) != 0;
+       return 0;
+}
+
+static int snd_ac97_ad1986_spread_put(struct snd_kcontrol *kcontrol,
+                                     struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
+       int ret0;
+       int ret1;
+       int sprd = (ac97->regs[AC97_AD_MISC3] & AC97_AD1986_LOSEL) != 0;
+
+       ret0 = snd_ac97_update_bits(ac97, AC97_AD_MISC, AC97_AD1986_SPRD,
+                                       ucontrol->value.integer.value[0] != 0
+                                   ? AC97_AD1986_SPRD : 0);
+       if (ret0 < 0)
+               return ret0;
+
+       /* SOSEL is set to values of "Spread" or "Exchange F/S" controls */
+       ret1 = snd_ac97_update_bits(ac97, AC97_AD_MISC, AC97_AD1986_SOSEL,
+                                   (ucontrol->value.integer.value[0] != 0
+                                    || sprd)
+                                   ? AC97_AD1986_SOSEL : 0);
+       if (ret1 < 0)
+               return ret1;
+
+       return (ret0 > 0 || ret1 > 0) ? 1 : 0;
+}
+
+static int snd_ac97_ad1986_miclisel_get(struct snd_kcontrol *kcontrol,
+                                       struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
+
+       ucontrol->value.integer.value[0] = ac97->spec.ad18xx.swap_mic_linein;
+       return 0;
+}
+
+static int snd_ac97_ad1986_miclisel_put(struct snd_kcontrol *kcontrol,
+                                       struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
+       unsigned char swap = ucontrol->value.integer.value[0] != 0;
+
+       if (swap != ac97->spec.ad18xx.swap_mic_linein) {
+               ac97->spec.ad18xx.swap_mic_linein = swap;
+               if (ac97->build_ops->update_jacks)
+                       ac97->build_ops->update_jacks(ac97);
+               return 1;
+       }
+       return 0;
+}
+
+static int snd_ac97_ad1986_vrefout_get(struct snd_kcontrol *kcontrol,
+                                      struct snd_ctl_elem_value *ucontrol)
+{
+       /* Use MIC_1/2 V_REFOUT as the "get" value */
+       struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
+       unsigned short val;
+       unsigned short reg = ac97->regs[AC97_AD_MISC2];
+       if ((reg & AC97_AD1986_MVREF0) != 0)
+               val = 2;
+       else if ((reg & AC97_AD1986_MVREF1) != 0)
+               val = 3;
+       else if ((reg & AC97_AD1986_MVREF2) != 0)
+               val = 1;
+       else
+               val = 0;
+       ucontrol->value.enumerated.item[0] = val;
+       return 0;
+}
+
+static int snd_ac97_ad1986_vrefout_put(struct snd_kcontrol *kcontrol,
+                                      struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
+       unsigned short cval;
+       unsigned short lval;
+       unsigned short mval;
+       int cret;
+       int lret;
+       int mret;
+
+       switch (ucontrol->value.enumerated.item[0])
+       {
+       case 0: /* High-Z */
+               cval = 0;
+               lval = 0;
+               mval = 0;
+               break;
+       case 1: /* 3.7 V */
+               cval = AC97_AD1986_CVREF2;
+               lval = AC97_AD1986_LVREF2;
+               mval = AC97_AD1986_MVREF2;
+               break;
+       case 2: /* 2.25 V */
+               cval = AC97_AD1986_CVREF0;
+               lval = AC97_AD1986_LVREF0;
+               mval = AC97_AD1986_MVREF0;
+               break;
+       case 3: /* 0 V */
+               cval = AC97_AD1986_CVREF1;
+               lval = AC97_AD1986_LVREF1;
+               mval = AC97_AD1986_MVREF1;
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       cret = snd_ac97_update_bits(ac97, AC97_AD_MISC2,
+                                   AC97_AD1986_CVREF_MASK, cval);
+       if (cret < 0)
+               return cret;
+       lret = snd_ac97_update_bits(ac97, AC97_AD_MISC3,
+                                   AC97_AD1986_LVREF_MASK, lval);
+       if (lret < 0)
+               return lret;
+       mret = snd_ac97_update_bits(ac97, AC97_AD_MISC2,
+                                   AC97_AD1986_MVREF_MASK, mval);
+       if (mret < 0)
+               return mret;
+
+       return (cret > 0 || lret > 0 || mret > 0) ? 1 : 0;
+}
+
+static const struct snd_kcontrol_new snd_ac97_ad1986_controls[] = {
+       AC97_SINGLE("Exchange Center/LFE", AC97_AD_SERIAL_CFG, 3, 1, 0),
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               .name = "Exchange Front/Surround",
+               .info = snd_ac97_ad1986_bool_info,
+               .get = snd_ac97_ad1986_lososel_get,
+               .put = snd_ac97_ad1986_lososel_put
+       },
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               .name = "Exchange Mic/Line In",
+               .info = snd_ac97_ad1986_bool_info,
+               .get = snd_ac97_ad1986_miclisel_get,
+               .put = snd_ac97_ad1986_miclisel_put
+       },
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               .name = "Spread Front to Surround and Center/LFE",
+               .info = snd_ac97_ad1986_bool_info,
+               .get = snd_ac97_ad1986_spread_get,
+               .put = snd_ac97_ad1986_spread_put
+       },
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               .name = "Downmix",
+               .info = snd_ac97_ad1888_downmix_info,
+               .get = snd_ac97_ad1888_downmix_get,
+               .put = snd_ac97_ad1888_downmix_put
+       },
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               .name = "V_REFOUT",
+               .info = snd_ac97_ad1985_vrefout_info,
+               .get = snd_ac97_ad1986_vrefout_get,
+               .put = snd_ac97_ad1986_vrefout_put
+       },
+       AC97_SURROUND_JACK_MODE_CTL,
+       AC97_CHANNEL_MODE_CTL,
+
+       AC97_SINGLE("Headphone Jack Sense", AC97_AD_JACK_SPDIF, 10, 1, 0),
+       AC97_SINGLE("Line Jack Sense", AC97_AD_JACK_SPDIF, 12, 1, 0)
+};
+
+static void ad1986_update_jacks(struct snd_ac97 *ac97)
+{
+       unsigned short misc_val = 0;
+       unsigned short ser_val;
+
+       /* disable SURROUND and CENTER/LFE if not surround mode */
+       if (! is_surround_on(ac97))
+               misc_val |= AC97_AD1986_SODIS;
+       if (! is_clfe_on(ac97))
+               misc_val |= AC97_AD1986_CLDIS;
+
+       /* select line input (default=LINE_IN, SURROUND or MIC_1/2) */
+       if (is_shared_linein(ac97))
+               misc_val |= AC97_AD1986_LISEL_SURR;
+       else if (ac97->spec.ad18xx.swap_mic_linein != 0)
+               misc_val |= AC97_AD1986_LISEL_MIC;
+       snd_ac97_update_bits(ac97, AC97_AD_MISC,
+                            AC97_AD1986_SODIS | AC97_AD1986_CLDIS |
+                            AC97_AD1986_LISEL_MASK,
+                            misc_val);
+
+       /* select microphone input (MIC_1/2, Center/LFE or LINE_IN) */
+       if (is_shared_micin(ac97))
+               ser_val = AC97_AD1986_OMS_C;
+       else if (ac97->spec.ad18xx.swap_mic_linein != 0)
+               ser_val = AC97_AD1986_OMS_L;
+       else
+               ser_val = AC97_AD1986_OMS_M;
+       snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG,
+                            AC97_AD1986_OMS_MASK,
+                            ser_val);
+}
+
+static int patch_ad1986_specific(struct snd_ac97 *ac97)
+{
+       int err;
+
+       if ((err = patch_build_controls(ac97, &snd_ac97_ad198x_2cmic, 1)) < 0)
+               return err;
+
+       return patch_build_controls(ac97, snd_ac97_ad1986_controls,
+                                   ARRAY_SIZE(snd_ac97_ad1985_controls));
+}
+
+static struct snd_ac97_build_ops patch_ad1986_build_ops = {
+       .build_post_spdif = patch_ad198x_post_spdif,
+       .build_specific = patch_ad1986_specific,
+#ifdef CONFIG_PM
+       .resume = ad18xx_resume,
+#endif
+       .update_jacks = ad1986_update_jacks,
+};
+
+int patch_ad1986(struct snd_ac97 * ac97)
+{
+       patch_ad1881(ac97);
+       ac97->build_ops = &patch_ad1986_build_ops;
+       ac97->flags |= AC97_STEREO_MUTES;
+
+       /* update current jack configuration */
+       ad1986_update_jacks(ac97);
+
+       return 0;
+}
+
+
 /*
  * realtek ALC65x/850 codecs
  */
@@ -2014,12 +2477,12 @@ static void alc650_update_jacks(struct snd_ac97 *ac97)
 {
        int shared;
        
-       /* shared Line-In */
-       shared = is_shared_linein(ac97);
+       /* shared Line-In / Surround Out */
+       shared = is_shared_surrout(ac97);
        snd_ac97_update_bits(ac97, AC97_ALC650_MULTICH, 1 << 9,
                             shared ? (1 << 9) : 0);
-       /* update shared Mic */
-       shared = is_shared_micin(ac97);
+       /* update shared Mic In / Center/LFE Out */
+       shared = is_shared_clfeout(ac97);
        /* disable/enable vref */
        snd_ac97_update_bits(ac97, AC97_ALC650_CLOCK, 1 << 12,
                             shared ? (1 << 12) : 0);
@@ -2064,7 +2527,7 @@ static const struct snd_kcontrol_new snd_ac97_spdif_controls_alc650[] = {
        /* AC97_SINGLE("IEC958 Input Monitor", AC97_ALC650_MULTICH, 13, 1, 0), */
 };
 
-static DECLARE_TLV_DB_SCALE(db_scale_5bit_3db_max, -4350, 150, 0);
+static const DECLARE_TLV_DB_SCALE(db_scale_5bit_3db_max, -4350, 150, 0);
 
 static int patch_alc650_specific(struct snd_ac97 * ac97)
 {
@@ -2149,12 +2612,12 @@ static void alc655_update_jacks(struct snd_ac97 *ac97)
 {
        int shared;
        
-       /* shared Line-In */
-       shared = is_shared_linein(ac97);
+       /* shared Line-In / Surround Out */
+       shared = is_shared_surrout(ac97);
        ac97_update_bits_page(ac97, AC97_ALC650_MULTICH, 1 << 9,
                              shared ? (1 << 9) : 0, 0);
-       /* update shared mic */
-       shared = is_shared_micin(ac97);
+       /* update shared Mic In / Center/LFE Out */
+       shared = is_shared_clfeout(ac97);
        /* misc control; vrefout disable */
        snd_ac97_update_bits(ac97, AC97_ALC650_CLOCK, 1 << 12,
                             shared ? (1 << 12) : 0);
@@ -2264,7 +2727,8 @@ int patch_alc655(struct snd_ac97 * ac97)
                if (ac97->subsystem_vendor == 0x1462 &&
                    (ac97->subsystem_device == 0x0131 || /* MSI S270 laptop */
                     ac97->subsystem_device == 0x0161 || /* LG K1 Express */
-                    ac97->subsystem_device == 0x0351))  /* MSI L725 laptop */
+                    ac97->subsystem_device == 0x0351 || /* MSI L725 laptop */
+                    ac97->subsystem_device == 0x0061))  /* MSI S250 laptop */
                        val &= ~(1 << 1); /* Pin 47 is EAPD (for internal speaker) */
                else
                        val |= (1 << 1); /* Pin 47 is spdif input pin */
@@ -2297,16 +2761,16 @@ static void alc850_update_jacks(struct snd_ac97 *ac97)
 {
        int shared;
        
-       /* shared Line-In */
-       shared = is_shared_linein(ac97);
+       /* shared Line-In / Surround Out */
+       shared = is_shared_surrout(ac97);
        /* SURR 1kOhm (bit4), Amp (bit5) */
        snd_ac97_update_bits(ac97, AC97_ALC850_MISC1, (1<<4)|(1<<5),
                             shared ? (1<<5) : (1<<4));
        /* LINE-IN = 0, SURROUND = 2 */
        snd_ac97_update_bits(ac97, AC97_ALC850_JACK_SELECT, 7 << 12,
                             shared ? (2<<12) : (0<<12));
-       /* update shared mic */
-       shared = is_shared_micin(ac97);
+       /* update shared Mic In / Center/LFE Out */
+       shared = is_shared_clfeout(ac97);
        /* Vref disable (bit12), 1kOhm (bit13) */
        snd_ac97_update_bits(ac97, AC97_ALC850_MISC1, (1<<12)|(1<<13),
                             shared ? (1<<12) : (1<<13));
@@ -2379,9 +2843,9 @@ int patch_alc850(struct snd_ac97 *ac97)
  */
 static void cm9738_update_jacks(struct snd_ac97 *ac97)
 {
-       /* shared Line-In */
+       /* shared Line-In / Surround Out */
        snd_ac97_update_bits(ac97, AC97_CM9738_VENDOR_CTRL, 1 << 10,
-                            is_shared_linein(ac97) ? (1 << 10) : 0);
+                            is_shared_surrout(ac97) ? (1 << 10) : 0);
 }
 
 static const struct snd_kcontrol_new snd_ac97_cm9738_controls[] = {
@@ -2463,12 +2927,12 @@ static const struct snd_kcontrol_new snd_ac97_cm9739_controls_spdif[] = {
 
 static void cm9739_update_jacks(struct snd_ac97 *ac97)
 {
-       /* shared Line-In */
+       /* shared Line-In / Surround Out */
        snd_ac97_update_bits(ac97, AC97_CM9739_MULTI_CHAN, 1 << 10,
-                            is_shared_linein(ac97) ? (1 << 10) : 0);
-       /* shared Mic */
+                            is_shared_surrout(ac97) ? (1 << 10) : 0);
+       /* shared Mic In / Center/LFE Out **/
        snd_ac97_update_bits(ac97, AC97_CM9739_MULTI_CHAN, 0x3000,
-                            is_shared_micin(ac97) ? 0x1000 : 0x2000);
+                            is_shared_clfeout(ac97) ? 0x1000 : 0x2000);
 }
 
 static const struct snd_kcontrol_new snd_ac97_cm9739_controls[] = {
@@ -2580,8 +3044,8 @@ static void cm9761_update_jacks(struct snd_ac97 *ac97)
 
        val |= surr_on[ac97->spec.dev_flags][is_surround_on(ac97)];
        val |= clfe_on[ac97->spec.dev_flags][is_clfe_on(ac97)];
-       val |= surr_shared[ac97->spec.dev_flags][is_shared_linein(ac97)];
-       val |= clfe_shared[ac97->spec.dev_flags][is_shared_micin(ac97)];
+       val |= surr_shared[ac97->spec.dev_flags][is_shared_surrout(ac97)];
+       val |= clfe_shared[ac97->spec.dev_flags][is_shared_clfeout(ac97)];
 
        snd_ac97_update_bits(ac97, AC97_CM9761_MULTI_CHAN, 0x3c88, val);
 }
@@ -2821,6 +3285,7 @@ int patch_vt1617a(struct snd_ac97 * ac97)
        snd_ac97_write_cache(ac97, 0x5c, 0x20);
        ac97->ext_id |= AC97_EI_SPDIF;  /* force the detection of spdif */
        ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000;
+       ac97->build_ops = &patch_vt1616_ops;
        return 0;
 }
 
@@ -2828,12 +3293,12 @@ int patch_vt1617a(struct snd_ac97 * ac97)
  */
 static void it2646_update_jacks(struct snd_ac97 *ac97)
 {
-       /* shared Line-In */
+       /* shared Line-In / Surround Out */
        snd_ac97_update_bits(ac97, 0x76, 1 << 9,
-                            is_shared_linein(ac97) ? (1<<9) : 0);
-       /* shared Mic */
+                            is_shared_surrout(ac97) ? (1<<9) : 0);
+       /* shared Mic / Center/LFE Out */
        snd_ac97_update_bits(ac97, 0x76, 1 << 10,
-                            is_shared_micin(ac97) ? (1<<10) : 0);
+                            is_shared_clfeout(ac97) ? (1<<10) : 0);
 }
 
 static const struct snd_kcontrol_new snd_ac97_controls_it2646[] = {
index 741979217207501992d8e9493923ff0bfb498f0f..94340daaaf1f7a64835c2923b0780230fd01a260 100644 (file)
@@ -48,6 +48,7 @@ int patch_ad1980(struct snd_ac97 * ac97);
 int patch_ad1981a(struct snd_ac97 * ac97);
 int patch_ad1981b(struct snd_ac97 * ac97);
 int patch_ad1985(struct snd_ac97 * ac97);
+int patch_ad1986(struct snd_ac97 * ac97);
 int patch_alc650(struct snd_ac97 * ac97);
 int patch_alc655(struct snd_ac97 * ac97);
 int patch_alc850(struct snd_ac97 * ac97);
index c153cb79c518a4fc3ca3e8a3827ab75e92ccc0a5..dc26820a03a5b4acac2b001d77b11aadb98709b5 100644 (file)
@@ -267,9 +267,9 @@ static int snd_ak4531_put_input_sw(struct snd_kcontrol *kcontrol, struct snd_ctl
        return change;
 }
 
-static DECLARE_TLV_DB_SCALE(db_scale_master, -6200, 200, 0);
-static DECLARE_TLV_DB_SCALE(db_scale_mono, -2800, 400, 0);
-static DECLARE_TLV_DB_SCALE(db_scale_input, -5000, 200, 0);
+static const DECLARE_TLV_DB_SCALE(db_scale_master, -6200, 200, 0);
+static const DECLARE_TLV_DB_SCALE(db_scale_mono, -2800, 400, 0);
+static const DECLARE_TLV_DB_SCALE(db_scale_input, -5000, 200, 0);
 
 static struct snd_kcontrol_new snd_ak4531_controls[] = {
 
index 9f406fbe0d9568e80cf691a8583f597419501fef..8afcb98ca7bb8cd377670b13b9f761553cd2bdbc 100644 (file)
@@ -444,7 +444,7 @@ static int snd_als300_capture_close(struct snd_pcm_substream *substream)
 }
 
 static int snd_als300_pcm_hw_params(struct snd_pcm_substream *substream,
-                                       snd_pcm_hw_params_t * hw_params)
+                                   struct snd_pcm_hw_params *hw_params)
 {
        return snd_pcm_lib_malloc_pages(substream,
                                        params_buffer_bytes(hw_params));
@@ -673,7 +673,7 @@ static void snd_als300_init(struct snd_als300 *chip)
        snd_als300_dbgcallleave();
 }
 
-static int __devinit snd_als300_create(snd_card_t *card,
+static int __devinit snd_als300_create(struct snd_card *card,
                                       struct pci_dev *pci, int chip_type,
                                       struct snd_als300 **rchip)
 {
@@ -681,7 +681,7 @@ static int __devinit snd_als300_create(snd_card_t *card,
        void *irq_handler;
        int err;
 
-       static snd_device_ops_t ops = {
+       static struct snd_device_ops ops = {
                .dev_free = snd_als300_dev_free,
        };
        *rchip = NULL;
index 476c3433073e9c1d78dfbeb8a737adb3c06f941c..7d8053b5e8d574fa23715d91de0b7fc580a48c7b 100644 (file)
@@ -45,6 +45,7 @@ static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */
 static int ac97_clock = 48000;
 static char *ac97_quirk;
 static int spdif_aclink = 1;
+static int ac97_codec = -1;
 
 module_param(index, int, 0444);
 MODULE_PARM_DESC(index, "Index value for ATI IXP controller.");
@@ -54,6 +55,8 @@ module_param(ac97_clock, int, 0444);
 MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (default 48000Hz).");
 module_param(ac97_quirk, charp, 0444);
 MODULE_PARM_DESC(ac97_quirk, "AC'97 workaround for strange hardware.");
+module_param(ac97_codec, int, 0444);
+MODULE_PARM_DESC(ac97_codec, "Specify codec instead of probing.");
 module_param(spdif_aclink, bool, 0444);
 MODULE_PARM_DESC(spdif_aclink, "S/PDIF over AC-link.");
 
@@ -293,6 +296,10 @@ static struct pci_device_id snd_atiixp_ids[] = {
 
 MODULE_DEVICE_TABLE(pci, snd_atiixp_ids);
 
+static struct snd_pci_quirk atiixp_quirks[] __devinitdata = {
+       SND_PCI_QUIRK(0x15bd, 0x3100, "DFI RS482", 0),
+       { } /* terminator */
+};
 
 /*
  * lowlevel functions
@@ -553,11 +560,33 @@ static int snd_atiixp_aclink_down(struct atiixp *chip)
             ATI_REG_ISR_CODEC2_NOT_READY)
 #define CODEC_CHECK_BITS (ALL_CODEC_NOT_READY|ATI_REG_ISR_NEW_FRAME)
 
+static int ac97_probing_bugs(struct pci_dev *pci)
+{
+       const struct snd_pci_quirk *q;
+
+       q = snd_pci_quirk_lookup(pci, atiixp_quirks);
+       if (q) {
+               snd_printdd(KERN_INFO "Atiixp quirk for %s.  "
+                           "Forcing codec %d\n", q->name, q->value);
+               return q->value;
+       }
+       /* this hardware doesn't need workarounds.  Probe for codec */
+       return -1;
+}
+
 static int snd_atiixp_codec_detect(struct atiixp *chip)
 {
        int timeout;
 
        chip->codec_not_ready_bits = 0;
+       if (ac97_codec == -1)
+               ac97_codec = ac97_probing_bugs(chip->pci);
+       if (ac97_codec >= 0) {
+               chip->codec_not_ready_bits |= 
+                       CODEC_CHECK_BITS ^ (1 << (ac97_codec + 10));
+               return 0;
+       }
+
        atiixp_write(chip, IER, CODEC_CHECK_BITS);
        /* wait for the interrupts */
        timeout = 50;
@@ -1396,7 +1425,7 @@ static int __devinit snd_atiixp_mixer_new(struct atiixp *chip, int clock,
                ac97.private_data = chip;
                ac97.pci = chip->pci;
                ac97.num = i;
-               ac97.scaps = AC97_SCAP_SKIP_MODEM;
+               ac97.scaps = AC97_SCAP_SKIP_MODEM | AC97_SCAP_POWER_SAVE;
                if (! chip->spdif_over_aclink)
                        ac97.scaps |= AC97_SCAP_NO_SPDIF;
                if ((err = snd_ac97_mixer(pbus, &ac97, &chip->ac97[i])) < 0) {
index cc2e6b9d407e41e8456e6837083668494f5d8f96..904023fe4f26b902e49b11e347003e8e44741028 100644 (file)
@@ -1090,7 +1090,7 @@ static int __devinit snd_atiixp_mixer_new(struct atiixp_modem *chip, int clock)
                ac97.private_data = chip;
                ac97.pci = chip->pci;
                ac97.num = i;
-               ac97.scaps = AC97_SCAP_SKIP_AUDIO;
+               ac97.scaps = AC97_SCAP_SKIP_AUDIO | AC97_SCAP_POWER_SAVE;
                if ((err = snd_ac97_mixer(pbus, &ac97, &chip->ac97[i])) < 0) {
                        chip->ac97[i] = NULL; /* to be sure */
                        snd_printdd("atiixp-modem: codec %d not available for modem\n", i);
index f61f052f6d14d01cb88933c014cc9a945acbaba8..ea6712b63c9f7a268eba7b72ef989d58fbda1056 100644 (file)
@@ -1382,7 +1382,6 @@ static int __devinit snd_ca0106_create(int dev, struct snd_card *card,
        snd_ca0106_ptr_write(chip, SPDIF_SELECT1, 0, 0xf);
        snd_ca0106_ptr_write(chip, SPDIF_SELECT2, 0, 0x000f0000); /* 0x0b000000 for digital, 0x000b0000 for analog, from win2000 drivers. Use 0x000f0000 for surround71 */
        chip->spdif_enable = 0; /* Set digital SPDIF output off */
-       chip->capture_source = 3; /* Set CAPTURE_SOURCE */
        //snd_ca0106_ptr_write(chip, 0x45, 0, 0); /* Analogue out */
        //snd_ca0106_ptr_write(chip, 0x45, 0, 0xf00); /* Digital out */
 
@@ -1402,8 +1401,22 @@ static int __devinit snd_ca0106_create(int dev, struct snd_card *card,
                snd_ca0106_ptr_write(chip, PLAYBACK_VOLUME1, ch, 0xffffffff); /* Mute */
                snd_ca0106_ptr_write(chip, PLAYBACK_VOLUME2, ch, 0xffffffff); /* Mute */
        }
-        snd_ca0106_ptr_write(chip, CAPTURE_SOURCE, 0x0, 0x333300e4); /* Select MIC, Line in, TAD in, AUX in */
-       chip->capture_source = 3; /* Set CAPTURE_SOURCE */
+       if (chip->details->i2c_adc == 1) {
+               /* Select MIC, Line in, TAD in, AUX in */
+               snd_ca0106_ptr_write(chip, CAPTURE_SOURCE, 0x0, 0x333300e4);
+               /* Default to CAPTURE_SOURCE to i2s in */
+               chip->capture_source = 3;
+       } else if (chip->details->ac97 == 1) {
+               /* Default to AC97 in */
+               snd_ca0106_ptr_write(chip, CAPTURE_SOURCE, 0x0, 0x444400e4);
+               /* Default to CAPTURE_SOURCE to AC97 in */
+               chip->capture_source = 4;
+       } else {
+               /* Select MIC, Line in, TAD in, AUX in */
+               snd_ca0106_ptr_write(chip, CAPTURE_SOURCE, 0x0, 0x333300e4);
+               /* Default to Set CAPTURE_SOURCE to i2s in */
+               chip->capture_source = 3;
+       }
 
         if (chip->details->gpio_type == 2) { /* The SB0438 use GPIO differently. */
                /* FIXME: Still need to find out what the other GPIO bits do. E.g. For digital spdif out. */
@@ -1605,6 +1618,8 @@ static int __devinit snd_ca0106_probe(struct pci_dev *pci,
        snd_ca0106_proc_init(chip);
 #endif
 
+       snd_card_set_dev(card, &pci->dev);
+
        if ((err = snd_card_register(card)) < 0) {
                snd_card_free(card);
                return err;
index 9855f528ea78173aeec031472bd7876aa5590b0a..b913a1fb8c212676047b9827d44a9dc6ae80441b 100644 (file)
@@ -74,8 +74,8 @@
 
 #include "ca0106.h"
 
-static DECLARE_TLV_DB_SCALE(snd_ca0106_db_scale1, -5175, 25, 1);
-static DECLARE_TLV_DB_SCALE(snd_ca0106_db_scale2, -10350, 50, 1);
+static const DECLARE_TLV_DB_SCALE(snd_ca0106_db_scale1, -5175, 25, 1);
+static const DECLARE_TLV_DB_SCALE(snd_ca0106_db_scale2, -10350, 50, 1);
 
 static int snd_ca0106_shared_spdif_info(struct snd_kcontrol *kcontrol,
                                        struct snd_ctl_elem_info *uinfo)
@@ -482,19 +482,6 @@ static int snd_ca0106_i2c_volume_put(struct snd_kcontrol *kcontrol,
        .private_value = ((chid) << 8) | (reg)                  \
 }
 
-#define I2C_VOLUME(xname,chid) \
-{                                                              \
-       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,     \
-       .access = SNDRV_CTL_ELEM_ACCESS_READWRITE |             \
-                 SNDRV_CTL_ELEM_ACCESS_TLV_READ,               \
-       .info =  snd_ca0106_i2c_volume_info,                    \
-       .get =   snd_ca0106_i2c_volume_get,                     \
-       .put =   snd_ca0106_i2c_volume_put,                     \
-       .tlv = { .p = snd_ca0106_db_scale2 },                   \
-       .private_value = chid                                   \
-}
-
-
 static struct snd_kcontrol_new snd_ca0106_volume_ctls[] __devinitdata = {
        CA_VOLUME("Analog Front Playback Volume",
                  CONTROL_FRONT_CHANNEL, PLAYBACK_VOLUME2),
@@ -517,11 +504,6 @@ static struct snd_kcontrol_new snd_ca0106_volume_ctls[] __devinitdata = {
         CA_VOLUME("CAPTURE feedback Playback Volume",
                  1, CAPTURE_CONTROL),
 
-        I2C_VOLUME("Phone Capture Volume", 0),
-        I2C_VOLUME("Mic Capture Volume", 1),
-        I2C_VOLUME("Line in Capture Volume", 2),
-        I2C_VOLUME("Aux Capture Volume", 3),
-
        {
                .access =       SNDRV_CTL_ELEM_ACCESS_READ,
                .iface =        SNDRV_CTL_ELEM_IFACE_PCM,
@@ -539,14 +521,14 @@ static struct snd_kcontrol_new snd_ca0106_volume_ctls[] __devinitdata = {
        },
        {
                .iface =        SNDRV_CTL_ELEM_IFACE_MIXER,
-               .name =         "Digital Capture Source",
+               .name =         "Digital Source Capture Enum",
                .info =         snd_ca0106_capture_source_info,
                .get =          snd_ca0106_capture_source_get,
                .put =          snd_ca0106_capture_source_put
        },
        {
                .iface =        SNDRV_CTL_ELEM_IFACE_MIXER,
-               .name =         "Capture Source",
+               .name =         "Analog Source Capture Enum",
                .info =         snd_ca0106_i2c_capture_source_info,
                .get =          snd_ca0106_i2c_capture_source_get,
                .put =          snd_ca0106_i2c_capture_source_put
@@ -561,6 +543,25 @@ static struct snd_kcontrol_new snd_ca0106_volume_ctls[] __devinitdata = {
        },
 };
 
+#define I2C_VOLUME(xname,chid) \
+{                                                              \
+       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,     \
+       .access = SNDRV_CTL_ELEM_ACCESS_READWRITE |             \
+                 SNDRV_CTL_ELEM_ACCESS_TLV_READ,               \
+       .info =  snd_ca0106_i2c_volume_info,                    \
+       .get =   snd_ca0106_i2c_volume_get,                     \
+       .put =   snd_ca0106_i2c_volume_put,                     \
+       .tlv = { .p = snd_ca0106_db_scale2 },                   \
+       .private_value = chid                                   \
+}
+
+static struct snd_kcontrol_new snd_ca0106_volume_i2c_adc_ctls[] __devinitdata = {
+        I2C_VOLUME("Phone Capture Volume", 0),
+        I2C_VOLUME("Mic Capture Volume", 1),
+        I2C_VOLUME("Line in Capture Volume", 2),
+        I2C_VOLUME("Aux Capture Volume", 3),
+};
+
 static int __devinit remove_ctl(struct snd_card *card, const char *name)
 {
        struct snd_ctl_elem_id id;
@@ -645,6 +646,11 @@ int __devinit snd_ca0106_mixer(struct snd_ca0106 *emu)
                        return err;
        }
        if (emu->details->i2c_adc == 1) {
+               for (i = 0; i < ARRAY_SIZE(snd_ca0106_volume_i2c_adc_ctls); i++) {
+                       err = snd_ctl_add(card, snd_ctl_new1(&snd_ca0106_volume_i2c_adc_ctls[i], emu));
+                       if (err < 0)
+                               return err;
+               }
                if (emu->details->gpio_type == 1)
                        err = snd_ctl_add(card, snd_ctl_new1(&snd_ca0106_capture_mic_line_in, emu));
                else  /* gpio_type == 2 */
index 8e5519de7115f2897f0d31072fa12194e9d9ef38..44cf546076474c8f5e4ed61c181551262302f733 100644 (file)
@@ -1055,7 +1055,7 @@ static int snd_cs4281_put_volume(struct snd_kcontrol *kcontrol,
        return change;
 }
 
-static DECLARE_TLV_DB_SCALE(db_scale_dsp, -4650, 150, 0);
+static const DECLARE_TLV_DB_SCALE(db_scale_dsp, -4650, 150, 0);
 
 static struct snd_kcontrol_new snd_cs4281_fm_vol = 
 {
index b7108e29a668e98b38be86e2489cd0553ccd5f0e..8e7fe033270fcbc8857482f621e0cf7aa0f43fa3 100644 (file)
@@ -47,6 +47,7 @@
 #include <sound/core.h>
 #include <sound/info.h>
 #include <sound/control.h>
+#include <sound/tlv.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
 #include <sound/asoundef.h>
index e59a982ee361b0b843054e04d4fb1704557d673f..a13c623eb999f2988b7f26f994640730dda56092 100644 (file)
@@ -51,6 +51,7 @@
 #include <sound/core.h>
 #include <sound/info.h>
 #include <sound/control.h>
+#include <sound/tlv.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
 #include <sound/asoundef.h>
index 12099fe1547dcb9c1b864ec1312fa17e230efe4f..8fb15823aca569ae6249e36bba4e0a2da6a8236d 100644 (file)
@@ -58,6 +58,7 @@
 #include <sound/core.h>
 #include <sound/info.h>
 #include <sound/control.h>
+#include <sound/tlv.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
 #include <sound/asoundef.h>
index d26a1d1f3ed192effd33c6b18a415f1001ad2da7..48eb7c599111b62e5a2af76b3962c1831db14808 100644 (file)
@@ -39,7 +39,7 @@ static int set_phantom_power(struct echoaudio *chip, char on);
 static int write_control_reg(struct echoaudio *chip, u32 ctl, u32 frq,
                             char force);
 
-#include <linux/irq.h>
+#include <linux/interrupt.h>
 
 static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
 {
index 047e0b5bf15d3af1ac3b44a622c0a0a4a2cfce38..6a428b81dba65e4719980a5dee6f3922b83a431b 100644 (file)
@@ -34,6 +34,7 @@ module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable " ECHOCARD_NAME " soundcard.");
 
 static unsigned int channels_list[10] = {1, 2, 4, 6, 8, 10, 12, 14, 16, 999999};
+static const DECLARE_TLV_DB_SCALE(db_scale_output_gain, -12800, 100, 1);
 
 static int get_firmware(const struct firmware **fw_entry,
                        const struct firmware *frm, struct echoaudio *chip)
@@ -1011,17 +1012,21 @@ static int snd_echo_output_gain_put(struct snd_kcontrol *kcontrol,
 static struct snd_kcontrol_new snd_echo_line_output_gain __devinitdata = {
        .name = "Line Playback Volume",
        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+       .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ,
        .info = snd_echo_output_gain_info,
        .get = snd_echo_output_gain_get,
        .put = snd_echo_output_gain_put,
+       .tlv = {.p = db_scale_output_gain},
 };
 #else
 static struct snd_kcontrol_new snd_echo_pcm_output_gain __devinitdata = {
        .name = "PCM Playback Volume",
        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+       .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ,
        .info = snd_echo_output_gain_info,
        .get = snd_echo_output_gain_get,
        .put = snd_echo_output_gain_put,
+       .tlv = {.p = db_scale_output_gain},
 };
 #endif
 
@@ -1080,12 +1085,16 @@ static int snd_echo_input_gain_put(struct snd_kcontrol *kcontrol,
        return changed;
 }
 
+static const DECLARE_TLV_DB_SCALE(db_scale_input_gain, -2500, 50, 0);
+
 static struct snd_kcontrol_new snd_echo_line_input_gain __devinitdata = {
        .name = "Line Capture Volume",
        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+       .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ,
        .info = snd_echo_input_gain_info,
        .get = snd_echo_input_gain_get,
        .put = snd_echo_input_gain_put,
+       .tlv = {.p = db_scale_input_gain},
 };
 
 #endif /* ECHOCARD_HAS_INPUT_GAIN */
@@ -1277,9 +1286,11 @@ static int snd_echo_mixer_put(struct snd_kcontrol *kcontrol,
 static struct snd_kcontrol_new snd_echo_monitor_mixer __devinitdata = {
        .name = "Monitor Mixer Volume",
        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+       .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ,
        .info = snd_echo_mixer_info,
        .get = snd_echo_mixer_get,
        .put = snd_echo_mixer_put,
+       .tlv = {.p = db_scale_output_gain},
 };
 
 #endif /* ECHOCARD_HAS_MONITOR */
@@ -1343,9 +1354,11 @@ static int snd_echo_vmixer_put(struct snd_kcontrol *kcontrol,
 static struct snd_kcontrol_new snd_echo_vmixer __devinitdata = {
        .name = "VMixer Volume",
        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+       .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ,
        .info = snd_echo_vmixer_info,
        .get = snd_echo_vmixer_get,
        .put = snd_echo_vmixer_put,
+       .tlv = {.p = db_scale_output_gain},
 };
 
 #endif /* ECHOCARD_HAS_VMIXER */
@@ -1753,9 +1766,12 @@ static int snd_echo_vumeters_get(struct snd_kcontrol *kcontrol,
 static struct snd_kcontrol_new snd_echo_vumeters __devinitdata = {
        .name = "VU-meters",
        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-       .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE,
+       .access = SNDRV_CTL_ELEM_ACCESS_READ |
+                 SNDRV_CTL_ELEM_ACCESS_VOLATILE |
+                 SNDRV_CTL_ELEM_ACCESS_TLV_READ,
        .info = snd_echo_vumeters_info,
        .get = snd_echo_vumeters_get,
+       .tlv = {.p = db_scale_output_gain},
 };
 
 
index 29d6d12f80cab91230e9b0264d087f07707abc90..af4d32026e4ad8302b64d10b7416a4d4f3fb9edb 100644 (file)
@@ -51,6 +51,7 @@
 #include <sound/core.h>
 #include <sound/info.h>
 #include <sound/control.h>
+#include <sound/tlv.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
 #include <sound/asoundef.h>
index e464d720d0bdda5dd1ea67af66865b1b98a0ef18..9ff454a947ed1d697d062c6b6f53344da753e86c 100644 (file)
@@ -57,6 +57,7 @@
 #include <sound/core.h>
 #include <sound/info.h>
 #include <sound/control.h>
+#include <sound/tlv.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
 #include <sound/asoundef.h>
index bfd2467099ac1da151608dd800d9d868d7cf952e..37eb726fd03dddca1e00d0b361937e4af4d99c6b 100644 (file)
@@ -49,6 +49,7 @@
 #include <sound/core.h>
 #include <sound/info.h>
 #include <sound/control.h>
+#include <sound/tlv.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
 #include <sound/asoundef.h>
index 8ed7ff1fd8752c4492a9150c9cf85a9d56ca4e94..dc8b91824181f8d275efd74d89eb0b409061ba30 100644 (file)
@@ -49,6 +49,7 @@
 #include <sound/core.h>
 #include <sound/info.h>
 #include <sound/control.h>
+#include <sound/tlv.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
 #include <sound/asoundef.h>
index a8788e9591713ab0889d4ebdfdc094d7b126c8bc..eadf3263453a9e968ed98fad4c9951e2b5188b7f 100644 (file)
@@ -50,6 +50,7 @@
 #include <sound/core.h>
 #include <sound/info.h>
 #include <sound/control.h>
+#include <sound/tlv.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
 #include <sound/asoundef.h>
index e503d74b3ba9357310064355ad61e709b3e04f07..6cede497579e9ea8c7855a368905438727b2c24c 100644 (file)
@@ -56,6 +56,7 @@
 #include <sound/core.h>
 #include <sound/info.h>
 #include <sound/control.h>
+#include <sound/tlv.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
 #include <sound/asoundef.h>
index d4581fdc841ca04ba47a7175b8fe9e8362c134b0..44f735426aa02cffea629c51dd11ea2350932901 100644 (file)
@@ -58,6 +58,7 @@
 #include <sound/core.h>
 #include <sound/info.h>
 #include <sound/control.h>
+#include <sound/tlv.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
 #include <sound/asoundef.h>
index be40c64263d251ab5db26a4ef1981fe1a1050aab..dc172d03ac3ffa08a6eb88888dc6983b4571e873 100644 (file)
@@ -56,6 +56,7 @@
 #include <sound/core.h>
 #include <sound/info.h>
 #include <sound/control.h>
+#include <sound/tlv.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
 #include <sound/asoundef.h>
index 5dc512add3721c7f53fa7adf5efa64b3f4221dee..c856ed50dd9a2fc2cfcf76126577de44c0f3c639 100644 (file)
@@ -55,6 +55,7 @@
 #include <sound/core.h>
 #include <sound/info.h>
 #include <sound/control.h>
+#include <sound/tlv.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
 #include <sound/asoundef.h>
index 972ec40d8166ce3d90001a790ac34cabaa7c6048..80aa585eade4560231c44a320c5649eba3fb2018 100644 (file)
@@ -3,8 +3,10 @@
  *                   Creative Labs, Inc.
  *  Routines for control of EMU10K1 chips
  *
- *  Copyright (c) by James Courtier-Dutton <James@superbug.demon.co.uk>
+ *  Copyright (c) by James Courtier-Dutton <James@superbug.co.uk>
  *      Added support for Audigy 2 Value.
+ *     Added EMU 1010 support.
+ *     General bug fixes and enhancements.
  *
  *
  *  BUGS:
 
 #include <sound/core.h>
 #include <sound/emu10k1.h>
+#include <linux/firmware.h>
 #include "p16v.h"
 #include "tina2.h"
+#include "p17v.h"
 
 
 /*************************************************************************
@@ -117,11 +121,28 @@ static unsigned int spi_dac_init[] = {
                0x0622,
                0x1400,
 };
+
+static unsigned int i2c_adc_init[][2] = {
+       { 0x17, 0x00 }, /* Reset */
+       { 0x07, 0x00 }, /* Timeout */
+       { 0x0b, 0x22 },  /* Interface control */
+       { 0x0c, 0x22 },  /* Master mode control */
+       { 0x0d, 0x08 },  /* Powerdown control */
+       { 0x0e, 0xcf },  /* Attenuation Left  0x01 = -103dB, 0xff = 24dB */
+       { 0x0f, 0xcf },  /* Attenuation Right 0.5dB steps */
+       { 0x10, 0x7b },  /* ALC Control 1 */
+       { 0x11, 0x00 },  /* ALC Control 2 */
+       { 0x12, 0x32 },  /* ALC Control 3 */
+       { 0x13, 0x00 },  /* Noise gate control */
+       { 0x14, 0xa6 },  /* Limiter control */
+       { 0x15, ADC_MUX_2 },  /* ADC Mixer control. Mic for Audigy 2 ZS Notebook */
+};
        
 static int snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir, int resume)
 {
        unsigned int silent_page;
        int ch;
+       u32 tmp;
 
        /* disable audio and lock cache */
        outl(HCFG_LOCKSOUNDCACHE | HCFG_LOCKTANKCACHE_MASK | HCFG_MUTEBUTTONENABLE,
@@ -160,8 +181,6 @@ static int snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir, int resume)
 
        if (emu->card_capabilities->ca0151_chip) { /* audigy2 */
                /* Hacks for Alice3 to work independent of haP16V driver */
-               u32 tmp;
-
                //Setup SRCMulti_I2S SamplingRate
                tmp = snd_emu10k1_ptr_read(emu, A_SPDIF_SAMPLERATE, 0);
                tmp &= 0xfffff1ff;
@@ -181,8 +200,6 @@ static int snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir, int resume)
        }
        if (emu->card_capabilities->ca0108_chip) { /* audigy2 Value */
                /* Hacks for Alice3 to work independent of haP16V driver */
-               u32 tmp;
-
                snd_printk(KERN_INFO "Audigy2 value: Special config.\n");
                //Setup SRCMulti_I2S SamplingRate
                tmp = snd_emu10k1_ptr_read(emu, A_SPDIF_SAMPLERATE, 0);
@@ -211,7 +228,7 @@ static int snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir, int resume)
                int size, n;
 
                size = ARRAY_SIZE(spi_dac_init);
-               for (n=0; n < size; n++)
+               for (n = 0; n < size; n++)
                        snd_emu10k1_spi_write(emu, spi_dac_init[n]);
 
                snd_emu10k1_ptr20_write(emu, 0x60, 0, 0x10);
@@ -228,6 +245,23 @@ static int snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir, int resume)
                outl(0x76, emu->port + A_IOCFG); /* Windows uses 0x3f76 */
 
        }
+       if (emu->card_capabilities->i2c_adc) { /* Audigy 2 ZS Notebook with ADC Wolfson WM8775 */
+               int size, n;
+
+               snd_emu10k1_ptr20_write(emu, P17V_I2S_SRC_SEL, 0, 0x2020205f);
+               tmp = inl(emu->port + A_IOCFG);
+               outl(tmp | 0x4, emu->port + A_IOCFG);  /* Set bit 2 for mic input */
+               tmp = inl(emu->port + A_IOCFG);
+               size = ARRAY_SIZE(i2c_adc_init);
+               for (n = 0; n < size; n++)
+                       snd_emu10k1_i2c_write(emu, i2c_adc_init[n][0], i2c_adc_init[n][1]);
+               for (n=0; n < 4; n++) {
+                       emu->i2c_capture_volume[n][0]= 0xcf;
+                       emu->i2c_capture_volume[n][1]= 0xcf;
+               }
+
+       }
+
        
        snd_emu10k1_ptr_write(emu, PTB, 0, emu->ptb_pages.addr);
        snd_emu10k1_ptr_write(emu, TCB, 0, 0);  /* taken from original driver */
@@ -239,6 +273,10 @@ static int snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir, int resume)
                snd_emu10k1_ptr_write(emu, MAPB, ch, silent_page);
        }
 
+       if (emu->card_capabilities->emu1010) {
+               outl(HCFG_AUTOMUTE_ASYNC |
+                       HCFG_EMU32_SLAVE |
+                       HCFG_AUDIOENABLE, emu->port + HCFG);
        /*
         *  Hokay, setup HCFG
         *   Mute Disable Audio = 0
@@ -246,7 +284,7 @@ static int snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir, int resume)
         *   Lock Sound Memory = 0
         *   Auto Mute = 1
         */
-       if (emu->audigy) {
+       } else if (emu->audigy) {
                if (emu->revision == 4) /* audigy2 */
                        outl(HCFG_AUDIOENABLE |
                             HCFG_AC3ENABLE_CDSPDIF |
@@ -265,8 +303,10 @@ static int snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir, int resume)
                outl(HCFG_LOCKTANKCACHE_MASK | HCFG_AUTOMUTE | HCFG_JOYENABLE, emu->port + HCFG);
 
        if (enable_ir) {        /* enable IR for SB Live */
-               if ( emu->card_capabilities->emu1212m) {
-                       ;  /* Disable all access to A_IOCFG for the emu1212m */
+               if (emu->card_capabilities->emu1010) {
+                       ;  /* Disable all access to A_IOCFG for the emu1010 */
+               } else if (emu->card_capabilities->i2c_adc) {
+                       ;  /* Disable A_IOCFG for Audigy 2 ZS Notebook */
                } else if (emu->audigy) {
                        unsigned int reg = inl(emu->port + A_IOCFG);
                        outl(reg | A_IOCFG_GPOUT2, emu->port + A_IOCFG);
@@ -284,8 +324,10 @@ static int snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir, int resume)
                }
        }
        
-       if ( emu->card_capabilities->emu1212m) {
-               ;  /* Disable all access to A_IOCFG for the emu1212m */
+       if (emu->card_capabilities->emu1010) {
+               ;  /* Disable all access to A_IOCFG for the emu1010 */
+       } else if (emu->card_capabilities->i2c_adc) {
+               ;  /* Disable A_IOCFG for Audigy 2 ZS Notebook */
        } else if (emu->audigy) {       /* enable analog output */
                unsigned int reg = inl(emu->port + A_IOCFG);
                outl(reg | A_IOCFG_GPOUT0, emu->port + A_IOCFG);
@@ -302,8 +344,10 @@ static void snd_emu10k1_audio_enable(struct snd_emu10k1 *emu)
        outl(inl(emu->port + HCFG) | HCFG_AUDIOENABLE, emu->port + HCFG);
 
        /* Enable analog/digital outs on audigy */
-       if ( emu->card_capabilities->emu1212m) {
-               ;  /* Disable all access to A_IOCFG for the emu1212m */
+       if (emu->card_capabilities->emu1010) {
+               ;  /* Disable all access to A_IOCFG for the emu1010 */
+       } else if (emu->card_capabilities->i2c_adc) {
+               ;  /* Disable A_IOCFG for Audigy 2 ZS Notebook */
        } else if (emu->audigy) {
                outl(inl(emu->port + A_IOCFG) & ~0x44, emu->port + A_IOCFG);
  
@@ -596,133 +640,423 @@ static int snd_emu10k1_cardbus_init(struct snd_emu10k1 * emu)
        return 0;
 }
 
-static int snd_emu1212m_fpga_write(struct snd_emu10k1 * emu, int reg, int value)
+static int snd_emu1010_load_firmware(struct snd_emu10k1 * emu, const char * filename)
 {
-       if (reg<0 || reg>0x3f)
-               return 1;
-       reg+=0x40; /* 0x40 upwards are registers. */
-       if (value<0 || value>0x3f) /* 0 to 0x3f are values */
-               return 1;
-       outl(reg, emu->port + A_IOCFG);
-       outl(reg | 0x80, emu->port + A_IOCFG);  /* High bit clocks the value into the fpga. */
-       outl(value, emu->port + A_IOCFG);
-       outl(value | 0x80 , emu->port + A_IOCFG);  /* High bit clocks the value into the fpga. */
-
-       return 0;
-}
-
-static int snd_emu1212m_fpga_read(struct snd_emu10k1 * emu, int reg, int *value)
-{
-       if (reg<0 || reg>0x3f)
-               return 1;
-       reg+=0x40; /* 0x40 upwards are registers. */
-       outl(reg, emu->port + A_IOCFG);
-       outl(reg | 0x80, emu->port + A_IOCFG);  /* High bit clocks the value into the fpga. */
-       *value = inl(emu->port + A_IOCFG);
-
-       return 0;
-}
+       int err;
+       int n, i;
+       int reg;
+       int value;
+       const struct firmware *fw_entry;
+
+       if ((err = request_firmware(&fw_entry, filename, &emu->pci->dev)) != 0) {
+               snd_printk(KERN_ERR "firmware: %s not found. Err=%d\n",filename, err);
+               return err;
+       }
+       snd_printk(KERN_INFO "firmware size=0x%zx\n", fw_entry->size);
+       if (fw_entry->size != 0x133a4) {
+               snd_printk(KERN_ERR "firmware: %s wrong size.\n",filename);
+               return -EINVAL;
+       }
 
-static int snd_emu1212m_fpga_netlist_write(struct snd_emu10k1 * emu, int reg, int value)
-{
-       snd_emu1212m_fpga_write(emu, 0x00, ((reg >> 8) & 0x3f) );
-       snd_emu1212m_fpga_write(emu, 0x01, (reg & 0x3f) );
-       snd_emu1212m_fpga_write(emu, 0x02, ((value >> 8) & 0x3f) );
-       snd_emu1212m_fpga_write(emu, 0x03, (value & 0x3f) );
+       /* The FPGA is a Xilinx Spartan IIE XC2S50E */
+       /* GPIO7 -> FPGA PGMN
+        * GPIO6 -> FPGA CCLK
+        * GPIO5 -> FPGA DIN
+        * FPGA CONFIG OFF -> FPGA PGMN
+        */
+       outl(0x00, emu->port + A_IOCFG); /* Set PGMN low for 1uS. */
+       udelay(1);
+       outl(0x80, emu->port + A_IOCFG); /* Leave bit 7 set during netlist setup. */
+       udelay(100); /* Allow FPGA memory to clean */
+       for(n = 0; n < fw_entry->size; n++) {
+               value=fw_entry->data[n];        
+               for(i = 0; i < 8; i++) {
+                       reg = 0x80;
+                       if (value & 0x1)
+                               reg = reg | 0x20;
+                       value = value >> 1;   
+                       outl(reg, emu->port + A_IOCFG);
+                       outl(reg | 0x40, emu->port + A_IOCFG);
+               }
+       }
+       /* After programming, set GPIO bit 4 high again. */
+       outl(0x10, emu->port + A_IOCFG);
+       
 
+        release_firmware(fw_entry);
        return 0;
 }
 
-static int snd_emu10k1_emu1212m_init(struct snd_emu10k1 * emu)
+static int snd_emu10k1_emu1010_init(struct snd_emu10k1 * emu)
 {
        unsigned int i;
-       int tmp;
-
-       snd_printk(KERN_ERR "emu1212m: Special config.\n");
+       int tmp,tmp2;
+       int reg;
+       int err;
+       const char *hana_filename = "emu/hana.fw";
+       const char *dock_filename = "emu/audio_dock.fw";
+
+       snd_printk(KERN_INFO "emu1010: Special config.\n");
+       /* AC97 2.1, Any 16Meg of 4Gig address, Auto-Mute, EMU32 Slave,
+        * Lock Sound Memory Cache, Lock Tank Memory Cache,
+        * Mute all codecs.
+        */
        outl(0x0005a00c, emu->port + HCFG);
-       outl(0x0005a004, emu->port + HCFG);
+       /* AC97 2.1, Any 16Meg of 4Gig address, Auto-Mute, EMU32 Slave,
+        * Lock Tank Memory Cache,
+        * Mute all codecs.
+        */
+       outl(0x0005a004, emu->port + HCFG); 
+       /* AC97 2.1, Any 16Meg of 4Gig address, Auto-Mute, EMU32 Slave,
+        * Mute all codecs.
+        */
        outl(0x0005a000, emu->port + HCFG);
+       /* AC97 2.1, Any 16Meg of 4Gig address, Auto-Mute, EMU32 Slave,
+        * Mute all codecs.
+        */
        outl(0x0005a000, emu->port + HCFG);
 
-       snd_emu1212m_fpga_read(emu, 0x22, &tmp );
-       snd_emu1212m_fpga_read(emu, 0x23, &tmp );
-       snd_emu1212m_fpga_read(emu, 0x24, &tmp );
-       snd_emu1212m_fpga_write(emu, 0x04, 0x01 );
-       snd_emu1212m_fpga_read(emu, 0x0b, &tmp );
-       snd_emu1212m_fpga_write(emu, 0x0b, 0x01 );
-       snd_emu1212m_fpga_read(emu, 0x10, &tmp );
-       snd_emu1212m_fpga_write(emu, 0x10, 0x00 );
-       snd_emu1212m_fpga_read(emu, 0x11, &tmp );
-       snd_emu1212m_fpga_write(emu, 0x11, 0x30 );
-       snd_emu1212m_fpga_read(emu, 0x13, &tmp );
-       snd_emu1212m_fpga_write(emu, 0x13, 0x0f );
-       snd_emu1212m_fpga_read(emu, 0x11, &tmp );
-       snd_emu1212m_fpga_write(emu, 0x11, 0x30 );
-       snd_emu1212m_fpga_read(emu, 0x0a, &tmp );
-       snd_emu1212m_fpga_write(emu, 0x0a, 0x10 );
-       snd_emu1212m_fpga_write(emu, 0x0c, 0x19 );
-       snd_emu1212m_fpga_write(emu, 0x12, 0x0c );
-       snd_emu1212m_fpga_write(emu, 0x09, 0x0f );
-       snd_emu1212m_fpga_write(emu, 0x06, 0x00 );
-       snd_emu1212m_fpga_write(emu, 0x05, 0x00 );
-       snd_emu1212m_fpga_write(emu, 0x0e, 0x12 );
-       snd_emu1212m_fpga_netlist_write(emu, 0x0000, 0x0200);
-       snd_emu1212m_fpga_netlist_write(emu, 0x0001, 0x0201);
-       snd_emu1212m_fpga_netlist_write(emu, 0x0002, 0x0500);
-       snd_emu1212m_fpga_netlist_write(emu, 0x0003, 0x0501);
-       snd_emu1212m_fpga_netlist_write(emu, 0x0004, 0x0400);
-       snd_emu1212m_fpga_netlist_write(emu, 0x0005, 0x0401);
-       snd_emu1212m_fpga_netlist_write(emu, 0x0006, 0x0402);
-       snd_emu1212m_fpga_netlist_write(emu, 0x0007, 0x0403);
-       snd_emu1212m_fpga_netlist_write(emu, 0x0008, 0x0404);
-       snd_emu1212m_fpga_netlist_write(emu, 0x0009, 0x0405);
-       snd_emu1212m_fpga_netlist_write(emu, 0x000a, 0x0406);
-       snd_emu1212m_fpga_netlist_write(emu, 0x000b, 0x0407);
-       snd_emu1212m_fpga_netlist_write(emu, 0x000c, 0x0100);
-       snd_emu1212m_fpga_netlist_write(emu, 0x000d, 0x0104);
-       snd_emu1212m_fpga_netlist_write(emu, 0x000e, 0x0200);
-       snd_emu1212m_fpga_netlist_write(emu, 0x000f, 0x0201);
-       for (i=0;i < 0x20;i++) {
-               snd_emu1212m_fpga_netlist_write(emu, 0x0100+i, 0x0000);
+       /* Disable 48Volt power to Audio Dock */
+       snd_emu1010_fpga_write(emu,  EMU_HANA_DOCK_PWR,  0 );
+
+       /* ID, should read & 0x7f = 0x55. (Bit 7 is the IRQ bit) */
+       snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg );
+       snd_printdd("reg1=0x%x\n",reg);
+       if (reg == 0x55) {
+               /* FPGA netlist already present so clear it */
+               /* Return to programming mode */
+
+               snd_emu1010_fpga_write(emu,  EMU_HANA_FPGA_CONFIG, 0x02 );
        }
-       for (i=0;i < 4;i++) {
-               snd_emu1212m_fpga_netlist_write(emu, 0x0200+i, 0x0000);
+       snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg );
+       snd_printdd("reg2=0x%x\n",reg);
+       if (reg == 0x55) {
+               /* FPGA failed to return to programming mode */
+               return -ENODEV;
        }
-       for (i=0;i < 7;i++) {
-               snd_emu1212m_fpga_netlist_write(emu, 0x0300+i, 0x0000);
+       snd_printk(KERN_INFO "emu1010: EMU_HANA_ID=0x%x\n",reg);
+       if ((err = snd_emu1010_load_firmware(emu, hana_filename)) != 0) {
+               snd_printk(KERN_INFO "emu1010: Loading Hana Firmware file %s failed\n", hana_filename);
+               return err;
        }
-       for (i=0;i < 7;i++) {
-               snd_emu1212m_fpga_netlist_write(emu, 0x0400+i, 0x0000);
+
+       /* ID, should read & 0x7f = 0x55 when FPGA programmed. */
+       snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg );
+       if (reg != 0x55) {
+               /* FPGA failed to be programmed */
+               snd_printk(KERN_INFO "emu1010: Loading Hana Firmware file failed, reg=0x%x\n", reg);
+               return -ENODEV;
        }
-       snd_emu1212m_fpga_netlist_write(emu, 0x0500, 0x0108);
-       snd_emu1212m_fpga_netlist_write(emu, 0x0501, 0x010c);
-       snd_emu1212m_fpga_netlist_write(emu, 0x0600, 0x0110);
-       snd_emu1212m_fpga_netlist_write(emu, 0x0601, 0x0114);
-       snd_emu1212m_fpga_netlist_write(emu, 0x0700, 0x0118);
-       snd_emu1212m_fpga_netlist_write(emu, 0x0701, 0x011c);
-       snd_emu1212m_fpga_write(emu, 0x07, 0x01 );
 
-       snd_emu1212m_fpga_read(emu, 0x21, &tmp );
+       snd_printk(KERN_INFO "emu1010: Hana Firmware loaded\n");
+       snd_emu1010_fpga_read(emu, EMU_HANA_MAJOR_REV, &tmp );
+       snd_emu1010_fpga_read(emu, EMU_HANA_MINOR_REV, &tmp2 );
+       snd_printk("Hana ver:%d.%d\n",tmp ,tmp2);
+       /* Enable 48Volt power to Audio Dock */
+       snd_emu1010_fpga_write(emu,  EMU_HANA_DOCK_PWR,  EMU_HANA_DOCK_PWR_ON );
+
+       snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &reg );
+       snd_printk(KERN_INFO "emu1010: Card options=0x%x\n",reg);
+       snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &reg );
+       snd_printk(KERN_INFO "emu1010: Card options=0x%x\n",reg);
+       snd_emu1010_fpga_read(emu, EMU_HANA_OPTICAL_TYPE, &tmp ); 
+       /* ADAT input. */
+       snd_emu1010_fpga_write(emu, EMU_HANA_OPTICAL_TYPE, 0x01 );
+       snd_emu1010_fpga_read(emu, EMU_HANA_ADC_PADS, &tmp );
+       /* Set no attenuation on Audio Dock pads. */
+       snd_emu1010_fpga_write(emu, EMU_HANA_ADC_PADS, 0x00 );
+       emu->emu1010.adc_pads = 0x00;
+       snd_emu1010_fpga_read(emu, EMU_HANA_DOCK_MISC, &tmp );
+       /* Unmute Audio dock DACs, Headphone source DAC-4. */
+       snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_MISC, 0x30 );
+       snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_LEDS_2, 0x12 );
+       snd_emu1010_fpga_read(emu, EMU_HANA_DAC_PADS, &tmp );
+       /* DAC PADs. */
+       snd_emu1010_fpga_write(emu, EMU_HANA_DAC_PADS, 0x0f );
+       emu->emu1010.dac_pads = 0x0f;
+       snd_emu1010_fpga_read(emu, EMU_HANA_DOCK_MISC, &tmp );
+       snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_MISC, 0x30 );
+       snd_emu1010_fpga_read(emu, EMU_HANA_SPDIF_MODE, &tmp );
+       /* SPDIF Format. Set Consumer mode, 24bit, copy enable */
+       snd_emu1010_fpga_write(emu, EMU_HANA_SPDIF_MODE, 0x10 );
+       /* MIDI routing */
+       snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_IN, 0x19 );
+       /* Unknown. */
+       snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_OUT, 0x0c );
+       /* snd_emu1010_fpga_write(emu, 0x09, 0x0f ); // IRQ Enable: All on */
+       /* IRQ Enable: All off */
+       snd_emu1010_fpga_write(emu, EMU_HANA_IRQ_ENABLE, 0x00 );
+
+       snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &reg );
+       snd_printk(KERN_INFO "emu1010: Card options3=0x%x\n",reg);
+       /* Default WCLK set to 48kHz. */
+       snd_emu1010_fpga_write(emu, EMU_HANA_DEFCLOCK, 0x00 );
+       /* Word Clock source, Internal 48kHz x1 */
+       snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK, EMU_HANA_WCLOCK_INT_48K );
+       //snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK, EMU_HANA_WCLOCK_INT_48K | EMU_HANA_WCLOCK_4X );
+       /* Audio Dock LEDs. */
+       snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_LEDS_2, 0x12 );
 
-       outl(0x0000a000, emu->port + HCFG);
+#if 0
+       /* For 96kHz */
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_ALICE2_EMU32_0, EMU_SRC_HAMOA_ADC_LEFT1);
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_ALICE2_EMU32_1, EMU_SRC_HAMOA_ADC_RIGHT1);
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_ALICE2_EMU32_4, EMU_SRC_HAMOA_ADC_LEFT2);
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_ALICE2_EMU32_5, EMU_SRC_HAMOA_ADC_RIGHT2);
+#endif
+#if 0
+       /* For 192kHz */
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_ALICE2_EMU32_0, EMU_SRC_HAMOA_ADC_LEFT1);
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_ALICE2_EMU32_1, EMU_SRC_HAMOA_ADC_RIGHT1);
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_ALICE2_EMU32_2, EMU_SRC_HAMOA_ADC_LEFT2);
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_ALICE2_EMU32_3, EMU_SRC_HAMOA_ADC_RIGHT2);
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_ALICE2_EMU32_4, EMU_SRC_HAMOA_ADC_LEFT3);
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_ALICE2_EMU32_5, EMU_SRC_HAMOA_ADC_RIGHT3);
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_ALICE2_EMU32_6, EMU_SRC_HAMOA_ADC_LEFT4);
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_ALICE2_EMU32_7, EMU_SRC_HAMOA_ADC_RIGHT4);
+#endif
+#if 1
+       /* For 48kHz */
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_ALICE2_EMU32_0, EMU_SRC_DOCK_MIC_A1);
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_ALICE2_EMU32_1, EMU_SRC_DOCK_MIC_B1);
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_ALICE2_EMU32_2, EMU_SRC_HAMOA_ADC_LEFT2);
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_ALICE2_EMU32_3, EMU_SRC_HAMOA_ADC_LEFT2);
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_ALICE2_EMU32_4, EMU_SRC_DOCK_ADC1_LEFT1);
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_ALICE2_EMU32_5, EMU_SRC_DOCK_ADC1_RIGHT1);
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_ALICE2_EMU32_6, EMU_SRC_DOCK_ADC2_LEFT1);
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_ALICE2_EMU32_7, EMU_SRC_DOCK_ADC2_RIGHT1);
+#endif
+#if 0
+       /* Original */
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_ALICE2_EMU32_4, EMU_SRC_HANA_ADAT);
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_ALICE2_EMU32_5, EMU_SRC_HANA_ADAT + 1);
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_ALICE2_EMU32_6, EMU_SRC_HANA_ADAT + 2);
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_ALICE2_EMU32_7, EMU_SRC_HANA_ADAT + 3);
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_ALICE2_EMU32_8, EMU_SRC_HANA_ADAT + 4);
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_ALICE2_EMU32_9, EMU_SRC_HANA_ADAT + 5);
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_ALICE2_EMU32_A, EMU_SRC_HANA_ADAT + 6);
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_ALICE2_EMU32_B, EMU_SRC_HANA_ADAT + 7);
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_ALICE2_EMU32_C, EMU_SRC_DOCK_MIC_A1);
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_ALICE2_EMU32_D, EMU_SRC_DOCK_MIC_B1);
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_ALICE2_EMU32_E, EMU_SRC_HAMOA_ADC_LEFT2);
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_ALICE2_EMU32_F, EMU_SRC_HAMOA_ADC_LEFT2);
+#endif
+       for (i = 0;i < 0x20; i++ ) {
+               /* AudioDock Elink <-  Silence */
+               snd_emu1010_fpga_link_dst_src_write(emu, 0x0100+i, EMU_SRC_SILENCE);
+       }
+       for (i = 0;i < 4; i++) {
+               /* Hana SPDIF Out <- Silence */
+               snd_emu1010_fpga_link_dst_src_write(emu, 0x0200+i, EMU_SRC_SILENCE);
+       }
+       for (i = 0;i < 7; i++) {
+               /* Hamoa DAC <- Silence */
+               snd_emu1010_fpga_link_dst_src_write(emu, 0x0300+i, EMU_SRC_SILENCE);
+       }
+       for (i = 0;i < 7; i++) {
+               /* Hana ADAT Out <- Silence */
+               snd_emu1010_fpga_link_dst_src_write(emu, EMU_DST_HANA_ADAT + i, EMU_SRC_SILENCE);
+       }
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_ALICE_I2S0_LEFT, EMU_SRC_DOCK_ADC1_LEFT1);
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_ALICE_I2S0_RIGHT, EMU_SRC_DOCK_ADC1_RIGHT1);
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_ALICE_I2S1_LEFT, EMU_SRC_DOCK_ADC2_LEFT1);
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_ALICE_I2S1_RIGHT, EMU_SRC_DOCK_ADC2_RIGHT1);
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_ALICE_I2S2_LEFT, EMU_SRC_DOCK_ADC3_LEFT1);
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_ALICE_I2S2_RIGHT, EMU_SRC_DOCK_ADC3_RIGHT1);
+       snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, 0x01 ); // Unmute all
+
+       snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &tmp );
+       
+       /* AC97 1.03, Any 32Meg of 2Gig address, Auto-Mute, EMU32 Slave,
+        * Lock Sound Memory Cache, Lock Tank Memory Cache,
+        * Mute all codecs.
+        */
+       outl(0x0000a000, emu->port + HCFG); 
+       /* AC97 1.03, Any 32Meg of 2Gig address, Auto-Mute, EMU32 Slave,
+        * Lock Sound Memory Cache, Lock Tank Memory Cache,
+        * Un-Mute all codecs.
+        */
        outl(0x0000a001, emu->port + HCFG);
        /* Initial boot complete. Now patches */
 
-       snd_emu1212m_fpga_read(emu, 0x21, &tmp );
-       snd_emu1212m_fpga_write(emu, 0x0c, 0x19 );
-       snd_emu1212m_fpga_write(emu, 0x12, 0x0c );
-       snd_emu1212m_fpga_write(emu, 0x0c, 0x19 );
-       snd_emu1212m_fpga_write(emu, 0x12, 0x0c );
-       snd_emu1212m_fpga_read(emu, 0x0a, &tmp );
-       snd_emu1212m_fpga_write(emu, 0x0a, 0x10 );
-
-       snd_emu1212m_fpga_read(emu, 0x20, &tmp );
-       snd_emu1212m_fpga_read(emu, 0x21, &tmp );
-
-       snd_emu1212m_fpga_netlist_write(emu, 0x0300, 0x0312);
-       snd_emu1212m_fpga_netlist_write(emu, 0x0301, 0x0313);
-       snd_emu1212m_fpga_netlist_write(emu, 0x0200, 0x0302);
-       snd_emu1212m_fpga_netlist_write(emu, 0x0201, 0x0303);
+       snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &tmp );
+       snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_IN, 0x19 ); /* MIDI Route */
+       snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_OUT, 0x0c ); /* Unknown */
+       snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_IN, 0x19 ); /* MIDI Route */
+       snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_OUT, 0x0c ); /* Unknown */
+       snd_emu1010_fpga_read(emu, EMU_HANA_SPDIF_MODE, &tmp ); 
+       snd_emu1010_fpga_write(emu, EMU_HANA_SPDIF_MODE, 0x10 ); /* SPDIF Format spdif  (or 0x11 for aes/ebu) */
+
+       /* Delay to allow Audio Dock to settle */
+       msleep(100);
+       snd_emu1010_fpga_read(emu, EMU_HANA_IRQ_STATUS, &tmp ); /* IRQ Status */
+       snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &reg ); /* OPTIONS: Which cards are attached to the EMU */
+       /* FIXME: The loading of this should be able to happen any time,
+        * as the user can plug/unplug it at any time
+        */
+       if (reg & (EMU_HANA_OPTION_DOCK_ONLINE | EMU_HANA_OPTION_DOCK_OFFLINE) ) {
+               /* Audio Dock attached */
+               /* Return to Audio Dock programming mode */
+               snd_printk(KERN_INFO "emu1010: Loading Audio Dock Firmware\n");
+               snd_emu1010_fpga_write(emu,  EMU_HANA_FPGA_CONFIG, EMU_HANA_FPGA_CONFIG_AUDIODOCK );
+               if ((err = snd_emu1010_load_firmware(emu, dock_filename)) != 0) {
+                       return err;
+               }
+               snd_emu1010_fpga_write(emu,  EMU_HANA_FPGA_CONFIG, 0 );
+               snd_emu1010_fpga_read(emu, EMU_HANA_IRQ_STATUS, &reg );
+               snd_printk(KERN_INFO "emu1010: EMU_HANA+DOCK_IRQ_STATUS=0x%x\n",reg);
+               /* ID, should read & 0x7f = 0x55 when FPGA programmed. */
+               snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg );
+               snd_printk(KERN_INFO "emu1010: EMU_HANA+DOCK_ID=0x%x\n",reg);
+               if (reg != 0x55) {
+                       /* FPGA failed to be programmed */
+                       snd_printk(KERN_INFO "emu1010: Loading Audio Dock Firmware file failed, reg=0x%x\n", reg);
+                       return 0;
+                       return -ENODEV;
+               }
+               snd_printk(KERN_INFO "emu1010: Audio Dock Firmware loaded\n");
+               snd_emu1010_fpga_read(emu, EMU_DOCK_MAJOR_REV, &tmp );
+               snd_emu1010_fpga_read(emu, EMU_DOCK_MINOR_REV, &tmp2 );
+               snd_printk("Audio Dock ver:%d.%d\n",tmp ,tmp2);
+       }
+#if 0
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_HAMOA_DAC_LEFT1, EMU_SRC_ALICE_EMU32B + 2); /* ALICE2 bus 0xa2 */
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_HAMOA_DAC_RIGHT1, EMU_SRC_ALICE_EMU32B + 3); /* ALICE2 bus 0xa3 */
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_HANA_SPDIF_LEFT1, EMU_SRC_ALICE_EMU32A + 2); /* ALICE2 bus 0xb2 */
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_HANA_SPDIF_RIGHT1, EMU_SRC_ALICE_EMU32A + 3); /* ALICE2 bus 0xb3 */
+#endif
+       /* Default outputs */
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_DOCK_DAC1_LEFT1, EMU_SRC_ALICE_EMU32A + 0); /* ALICE2 bus 0xa0 */
+       emu->emu1010.output_source[0] = 21;
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_DOCK_DAC1_RIGHT1, EMU_SRC_ALICE_EMU32A + 1);
+       emu->emu1010.output_source[1] = 22;
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_DOCK_DAC2_LEFT1, EMU_SRC_ALICE_EMU32A + 2);
+       emu->emu1010.output_source[2] = 23;
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_DOCK_DAC2_RIGHT1, EMU_SRC_ALICE_EMU32A + 3);
+       emu->emu1010.output_source[3] = 24;
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_DOCK_DAC3_LEFT1, EMU_SRC_ALICE_EMU32A + 4);
+       emu->emu1010.output_source[4] = 25;
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_DOCK_DAC3_RIGHT1, EMU_SRC_ALICE_EMU32A + 5);
+       emu->emu1010.output_source[5] = 26;
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_DOCK_DAC4_LEFT1, EMU_SRC_ALICE_EMU32A + 6);
+       emu->emu1010.output_source[6] = 27;
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_DOCK_DAC4_RIGHT1, EMU_SRC_ALICE_EMU32A + 7);
+       emu->emu1010.output_source[7] = 28;
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_DOCK_PHONES_LEFT1, EMU_SRC_ALICE_EMU32A + 0); /* ALICE2 bus 0xa0 */
+       emu->emu1010.output_source[8] = 21;
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_DOCK_PHONES_RIGHT1, EMU_SRC_ALICE_EMU32A + 1);
+       emu->emu1010.output_source[9] = 22;
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_DOCK_SPDIF_LEFT1, EMU_SRC_ALICE_EMU32A + 0); /* ALICE2 bus 0xa0 */
+       emu->emu1010.output_source[10] = 21;
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_DOCK_SPDIF_RIGHT1, EMU_SRC_ALICE_EMU32A + 1);
+       emu->emu1010.output_source[11] = 22;
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_HANA_SPDIF_LEFT1, EMU_SRC_ALICE_EMU32A + 0); /* ALICE2 bus 0xa0 */
+       emu->emu1010.output_source[12] = 21;
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_HANA_SPDIF_RIGHT1, EMU_SRC_ALICE_EMU32A + 1);
+       emu->emu1010.output_source[13] = 22;
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_HAMOA_DAC_LEFT1, EMU_SRC_ALICE_EMU32A + 0); /* ALICE2 bus 0xa0 */
+       emu->emu1010.output_source[14] = 21;
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_HAMOA_DAC_RIGHT1, EMU_SRC_ALICE_EMU32A + 1);
+       emu->emu1010.output_source[15] = 22;
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_HANA_ADAT, EMU_SRC_ALICE_EMU32A + 0); /* ALICE2 bus 0xa0 */
+       emu->emu1010.output_source[16] = 21;
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_HANA_ADAT + 1, EMU_SRC_ALICE_EMU32A + 1);
+       emu->emu1010.output_source[17] = 22;
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_HANA_ADAT + 2, EMU_SRC_ALICE_EMU32A + 2);
+       emu->emu1010.output_source[18] = 23;
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_HANA_ADAT + 3, EMU_SRC_ALICE_EMU32A + 3);
+       emu->emu1010.output_source[19] = 24;
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_HANA_ADAT + 4, EMU_SRC_ALICE_EMU32A + 4);
+       emu->emu1010.output_source[20] = 25;
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_HANA_ADAT + 5, EMU_SRC_ALICE_EMU32A + 5);
+       emu->emu1010.output_source[21] = 26;
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_HANA_ADAT + 6, EMU_SRC_ALICE_EMU32A + 6);
+       emu->emu1010.output_source[22] = 27;
+       snd_emu1010_fpga_link_dst_src_write(emu,
+               EMU_DST_HANA_ADAT + 7, EMU_SRC_ALICE_EMU32A + 7);
+       emu->emu1010.output_source[23] = 28;
+
+       /* TEMP: Select SPDIF in/out */
+       snd_emu1010_fpga_write(emu, EMU_HANA_OPTICAL_TYPE, 0x0); /* Output spdif */
+
+       /* TEMP: Select 48kHz SPDIF out */
+       snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, 0x0); /* Mute all */
+       snd_emu1010_fpga_write(emu, EMU_HANA_DEFCLOCK, 0x0); /* Default fallback clock 48kHz */
+       /* Word Clock source, Internal 48kHz x1 */
+       snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK, EMU_HANA_WCLOCK_INT_48K );
+       //snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK, EMU_HANA_WCLOCK_INT_48K | EMU_HANA_WCLOCK_4X );
+       emu->emu1010.internal_clock = 1; /* 48000 */
+       snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_LEDS_2, 0x12);/* Set LEDs on Audio Dock */
+       snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, 0x1); /* Unmute all */
+       //snd_emu1010_fpga_write(emu, 0x7, 0x0); /* Mute all */
+       //snd_emu1010_fpga_write(emu, 0x7, 0x1); /* Unmute all */
+       //snd_emu1010_fpga_write(emu, 0xe, 0x12); /* Set LEDs on Audio Dock */
 
        return 0;
 }
@@ -747,6 +1081,10 @@ static int snd_emu10k1_free(struct snd_emu10k1 *emu)
                }
                snd_emu10k1_free_efx(emu);
                }
+       if (emu->card_capabilities->emu1010) {
+               /* Disable 48Volt power to Audio Dock */
+               snd_emu1010_fpga_write(emu,  EMU_HANA_DOCK_PWR,  0 );
+       }
        if (emu->memhdr)
                snd_util_memhdr_free(emu->memhdr);
        if (emu->silent_page.area)
@@ -838,10 +1176,11 @@ static struct snd_emu_chip_details emu_chip_details[] = {
         .adc_1361t = 1,  /* 24 bit capture instead of 16bit */
         .ac97_chip = 1} ,
        /* Audigy 2 ZS Notebook Cardbus card.*/
-       /* Tested by James@superbug.co.uk 22th December 2005 */
+       /* Tested by James@superbug.co.uk 6th November 2006 */
        /* Audio output 7.1/Headphones working.
         * Digital output working. (AC3 not checked, only PCM)
-        * Audio inputs not tested.
+        * Audio Mic/Line inputs working.
+        * Digital input not tested.
         */ 
        /* DSP: Tina2
         * DAC: Wolfson WM8768/WM8568
@@ -849,6 +1188,25 @@ static struct snd_emu_chip_details emu_chip_details[] = {
         * AC97: None
         * CA0151: None
         */
+       /* Tested by James@superbug.co.uk 4th April 2006 */
+       /* A_IOCFG bits
+        * Output
+        * 0: Not Used
+        * 1: 0 = Mute all the 7.1 channel out. 1 = unmute.
+        * 2: Analog input 0 = line in, 1 = mic in
+        * 3: Not Used
+        * 4: Digital output 0 = off, 1 = on.
+        * 5: Not Used
+        * 6: Not Used
+        * 7: Not Used
+        * Input
+        *      All bits 1 (0x3fxx) means nothing plugged in.
+        * 8-9: 0 = Line in/Mic, 2 = Optical in, 3 = Nothing.
+        * A-B: 0 = Headphones, 2 = Optical out, 3 = Nothing.
+        * C-D: 2 = Front/Rear/etc, 3 = nothing.
+        * E-F: Always 0
+        *
+        */
        {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x20011102,
         .driver = "Audigy2", .name = "Audigy 2 ZS Notebook [SB0530]", 
         .id = "Audigy2",
@@ -856,6 +1214,7 @@ static struct snd_emu_chip_details emu_chip_details[] = {
         .ca0108_chip = 1,
         .ca_cardbus_chip = 1,
         .spi_dac = 1,
+        .i2c_adc = 1,
         .spk71 = 1} ,
        {.vendor = 0x1102, .device = 0x0008, 
         .driver = "Audigy2", .name = "Audigy 2 Value [Unknown]", 
@@ -865,11 +1224,12 @@ static struct snd_emu_chip_details emu_chip_details[] = {
         .ac97_chip = 1} ,
        /* Tested by James@superbug.co.uk 8th July 2005. No sound available yet. */
        {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x40011102,
-        .driver = "Audigy2", .name = "E-mu 1212m [4001]", 
-        .id = "EMU1212m",
+        .driver = "Audigy2", .name = "E-mu 1010 [4001]", 
+        .id = "EMU1010",
         .emu10k2_chip = 1,
         .ca0102_chip = 1,
-        .emu1212m = 1} ,
+        .spk71 = 1,
+        .emu1010 = 1} ,
        /* Tested by James@superbug.co.uk 3rd July 2005 */
        {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20071102,
         .driver = "Audigy2", .name = "Audigy 4 PRO [SB0380]", 
@@ -1297,8 +1657,8 @@ int __devinit snd_emu10k1_create(struct snd_card *card,
        } else if (emu->card_capabilities->ca_cardbus_chip) {
                if ((err = snd_emu10k1_cardbus_init(emu)) < 0)
                        goto error;
-       } else if (emu->card_capabilities->emu1212m) {
-               if ((err = snd_emu10k1_emu1212m_init(emu)) < 0) {
+       } else if (emu->card_capabilities->emu1010) {
+               if ((err = snd_emu10k1_emu1010_init(emu)) < 0) {
                        snd_emu10k1_free(emu);
                        return err;
                }
@@ -1446,8 +1806,8 @@ void snd_emu10k1_resume_init(struct snd_emu10k1 *emu)
                snd_emu10k1_ecard_init(emu);
        else if (emu->card_capabilities->ca_cardbus_chip)
                snd_emu10k1_cardbus_init(emu);
-       else if (emu->card_capabilities->emu1212m)
-               snd_emu10k1_emu1212m_init(emu);
+       else if (emu->card_capabilities->emu1010)
+               snd_emu10k1_emu1010_init(emu);
        else
                snd_emu10k1_ptr_write(emu, AC97SLOT, 0, AC97SLOT_CNTR|AC97SLOT_LFE);
        snd_emu10k1_init(emu, emu->enable_ir, 1);
index 2199b42a601994539c076c81d8e361e415316d32..bb0fec7f7e1be06b08fe83c1c386aa93f43b2d1a 100644 (file)
@@ -460,7 +460,7 @@ static int snd_emu10k1x_pcm_prepare(struct snd_pcm_substream *substream)
        u32 period_size_bytes = frames_to_bytes(runtime, runtime->period_size);
        int i;
        
-       for(i=0; i < runtime->periods; i++) {
+       for(i = 0; i < runtime->periods; i++) {
                *table_base++=runtime->dma_addr+(i*period_size_bytes);
                *table_base++=period_size_bytes<<16;
        }
@@ -1042,8 +1042,8 @@ static void snd_emu10k1x_proc_reg_write(struct snd_info_entry *entry,
                if (sscanf(line, "%x %x %x", &reg, &channel_id, &val) != 3)
                        continue;
 
-               if ((reg < 0x49) && (reg >=0) && (val <= 0xffffffff) 
-                   && (channel_id >=0) && (channel_id <= 2) )
+               if ((reg < 0x49) && (reg >= 0) && (val <= 0xffffffff) 
+                   && (channel_id >= 0) && (channel_id <= 2) )
                        snd_emu10k1x_ptr_write(emu, reg, channel_id, val);
        }
 }
index 13cd6ce898115171b903283674c90425357b984d..c02012cccd8ee767e0823539a6f287d2626c5362 100644 (file)
@@ -3,6 +3,9 @@
  *                   Creative Labs, Inc.
  *  Routines for effect processor FX8010
  *
+ *  Copyright (c) by James Courtier-Dutton <James@superbug.co.uk>
+ *     Added EMU 1010 support.
+ *
  *  BUGS:
  *    --
  *
@@ -293,7 +296,7 @@ static const u32 db_table[101] = {
 };
 
 /* EMU10k1/EMU10k2 DSP control db gain */
-static DECLARE_TLV_DB_SCALE(snd_emu10k1_db_scale1, -4000, 40, 1);
+static const DECLARE_TLV_DB_SCALE(snd_emu10k1_db_scale1, -4000, 40, 1);
 
 static const u32 onoff_table[2] = {
        0x00000000, 0x00000001
@@ -652,13 +655,66 @@ snd_emu10k1_look_for_ctl(struct snd_emu10k1 *emu, struct snd_ctl_elem_id *id)
        return NULL;
 }
 
+#define MAX_TLV_SIZE   256
+
+static unsigned int *copy_tlv(const unsigned int __user *_tlv)
+{
+       unsigned int data[2];
+       unsigned int *tlv;
+
+       if (!_tlv)
+               return NULL;
+       if (copy_from_user(data, _tlv, sizeof(data)))
+               return NULL;
+       if (data[1] >= MAX_TLV_SIZE)
+               return NULL;
+       tlv = kmalloc(data[1] * 4 + sizeof(data), GFP_KERNEL);
+       if (!tlv)
+               return NULL;
+       memcpy(tlv, data, sizeof(data));
+       if (copy_from_user(tlv + 2, _tlv + 2, data[1])) {
+               kfree(tlv);
+               return NULL;
+       }
+       return tlv;
+}
+
+static int copy_gctl(struct snd_emu10k1 *emu,
+                    struct snd_emu10k1_fx8010_control_gpr *gctl,
+                    struct snd_emu10k1_fx8010_control_gpr __user *_gctl,
+                    int idx)
+{
+       struct snd_emu10k1_fx8010_control_old_gpr __user *octl;
+
+       if (emu->support_tlv)
+               return copy_from_user(gctl, &_gctl[idx], sizeof(*gctl));
+       octl = (struct snd_emu10k1_fx8010_control_old_gpr __user *)_gctl;
+       if (copy_from_user(gctl, &octl[idx], sizeof(*octl)))
+               return -EFAULT;
+       gctl->tlv = NULL;
+       return 0;
+}
+
+static int copy_gctl_to_user(struct snd_emu10k1 *emu,
+                    struct snd_emu10k1_fx8010_control_gpr __user *_gctl,
+                    struct snd_emu10k1_fx8010_control_gpr *gctl,
+                    int idx)
+{
+       struct snd_emu10k1_fx8010_control_old_gpr __user *octl;
+
+       if (emu->support_tlv)
+               return copy_to_user(&_gctl[idx], gctl, sizeof(*gctl));
+       
+       octl = (struct snd_emu10k1_fx8010_control_old_gpr __user *)_gctl;
+       return copy_to_user(&octl[idx], gctl, sizeof(*octl));
+}
+
 static int snd_emu10k1_verify_controls(struct snd_emu10k1 *emu,
                                       struct snd_emu10k1_fx8010_code *icode)
 {
        unsigned int i;
        struct snd_ctl_elem_id __user *_id;
        struct snd_ctl_elem_id id;
-       struct snd_emu10k1_fx8010_control_gpr __user *_gctl;
        struct snd_emu10k1_fx8010_control_gpr *gctl;
        int err;
        
@@ -673,9 +729,8 @@ static int snd_emu10k1_verify_controls(struct snd_emu10k1 *emu,
        if (! gctl)
                return -ENOMEM;
        err = 0;
-       for (i = 0, _gctl = icode->gpr_add_controls;
-            i < icode->gpr_add_control_count; i++, _gctl++) {
-               if (copy_from_user(gctl, _gctl, sizeof(*gctl))) {
+       for (i = 0; i < icode->gpr_add_control_count; i++) {
+               if (copy_gctl(emu, gctl, icode->gpr_add_controls, i)) {
                        err = -EFAULT;
                        goto __error;
                }
@@ -694,10 +749,9 @@ static int snd_emu10k1_verify_controls(struct snd_emu10k1 *emu,
                        goto __error;
                }
        }
-       for (i = 0, _gctl = icode->gpr_list_controls;
-            i < icode->gpr_list_control_count; i++, _gctl++) {
+       for (i = 0; i < icode->gpr_list_control_count; i++) {
                /* FIXME: we need to check the WRITE access */
-               if (copy_from_user(gctl, _gctl, sizeof(*gctl))) {
+               if (copy_gctl(emu, gctl, icode->gpr_list_controls, i)) {
                        err = -EFAULT;
                        goto __error;
                }
@@ -715,13 +769,14 @@ static void snd_emu10k1_ctl_private_free(struct snd_kcontrol *kctl)
        kctl->private_value = 0;
        list_del(&ctl->list);
        kfree(ctl);
+       if (kctl->tlv.p)
+               kfree(kctl->tlv.p);
 }
 
 static int snd_emu10k1_add_controls(struct snd_emu10k1 *emu,
                                    struct snd_emu10k1_fx8010_code *icode)
 {
        unsigned int i, j;
-       struct snd_emu10k1_fx8010_control_gpr __user *_gctl;
        struct snd_emu10k1_fx8010_control_gpr *gctl;
        struct snd_emu10k1_fx8010_ctl *ctl, *nctl;
        struct snd_kcontrol_new knew;
@@ -737,9 +792,8 @@ static int snd_emu10k1_add_controls(struct snd_emu10k1 *emu,
                goto __error;
        }
 
-       for (i = 0, _gctl = icode->gpr_add_controls;
-            i < icode->gpr_add_control_count; i++, _gctl++) {
-               if (copy_from_user(gctl, _gctl, sizeof(*gctl))) {
+       for (i = 0; i < icode->gpr_add_control_count; i++) {
+               if (copy_gctl(emu, gctl, icode->gpr_add_controls, i)) {
                        err = -EFAULT;
                        goto __error;
                }
@@ -760,11 +814,10 @@ static int snd_emu10k1_add_controls(struct snd_emu10k1 *emu,
                knew.device = gctl->id.device;
                knew.subdevice = gctl->id.subdevice;
                knew.info = snd_emu10k1_gpr_ctl_info;
-               if (gctl->tlv.p) {
-                       knew.tlv.p = gctl->tlv.p;
+               knew.tlv.p = copy_tlv(gctl->tlv);
+               if (knew.tlv.p)
                        knew.access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
                                SNDRV_CTL_ELEM_ACCESS_TLV_READ;
-               } 
                knew.get = snd_emu10k1_gpr_ctl_get;
                knew.put = snd_emu10k1_gpr_ctl_put;
                memset(nctl, 0, sizeof(*nctl));
@@ -782,12 +835,14 @@ static int snd_emu10k1_add_controls(struct snd_emu10k1 *emu,
                        ctl = kmalloc(sizeof(*ctl), GFP_KERNEL);
                        if (ctl == NULL) {
                                err = -ENOMEM;
+                               kfree(knew.tlv.p);
                                goto __error;
                        }
                        knew.private_value = (unsigned long)ctl;
                        *ctl = *nctl;
                        if ((err = snd_ctl_add(emu->card, kctl = snd_ctl_new1(&knew, emu))) < 0) {
                                kfree(ctl);
+                               kfree(knew.tlv.p);
                                goto __error;
                        }
                        kctl->private_free = snd_emu10k1_ctl_private_free;
@@ -838,7 +893,6 @@ static int snd_emu10k1_list_controls(struct snd_emu10k1 *emu,
        unsigned int i = 0, j;
        unsigned int total = 0;
        struct snd_emu10k1_fx8010_control_gpr *gctl;
-       struct snd_emu10k1_fx8010_control_gpr __user *_gctl;
        struct snd_emu10k1_fx8010_ctl *ctl;
        struct snd_ctl_elem_id *id;
        struct list_head *list;
@@ -847,11 +901,11 @@ static int snd_emu10k1_list_controls(struct snd_emu10k1 *emu,
        if (! gctl)
                return -ENOMEM;
 
-       _gctl = icode->gpr_list_controls;       
        list_for_each(list, &emu->fx8010.gpr_ctl) {
                ctl = emu10k1_gpr_ctl(list);
                total++;
-               if (_gctl && i < icode->gpr_list_control_count) {
+               if (icode->gpr_list_controls &&
+                   i < icode->gpr_list_control_count) {
                        memset(gctl, 0, sizeof(*gctl));
                        id = &ctl->kcontrol->id;
                        gctl->id.iface = id->iface;
@@ -868,11 +922,11 @@ static int snd_emu10k1_list_controls(struct snd_emu10k1 *emu,
                        gctl->min = ctl->min;
                        gctl->max = ctl->max;
                        gctl->translation = ctl->translation;
-                       if (copy_to_user(_gctl, gctl, sizeof(*gctl))) {
+                       if (copy_gctl_to_user(emu, icode->gpr_list_controls,
+                                             gctl, i)) {
                                kfree(gctl);
                                return -EFAULT;
                        }
-                       _gctl++;
                        i++;
                }
        }
@@ -1023,7 +1077,7 @@ snd_emu10k1_init_mono_control(struct snd_emu10k1_fx8010_control_gpr *ctl,
        ctl->gpr[0] = gpr + 0; ctl->value[0] = defval;
        ctl->min = 0;
        ctl->max = 100;
-       ctl->tlv.p = snd_emu10k1_db_scale1;
+       ctl->tlv = snd_emu10k1_db_scale1;
        ctl->translation = EMU10K1_GPR_TRANSLATION_TABLE100;    
 }
 
@@ -1038,7 +1092,7 @@ snd_emu10k1_init_stereo_control(struct snd_emu10k1_fx8010_control_gpr *ctl,
        ctl->gpr[1] = gpr + 1; ctl->value[1] = defval;
        ctl->min = 0;
        ctl->max = 100;
-       ctl->tlv.p = snd_emu10k1_db_scale1;
+       ctl->tlv = snd_emu10k1_db_scale1;
        ctl->translation = EMU10K1_GPR_TRANSLATION_TABLE100;
 }
 
@@ -1069,6 +1123,21 @@ snd_emu10k1_init_stereo_onoff_control(struct snd_emu10k1_fx8010_control_gpr *ctl
        ctl->translation = EMU10K1_GPR_TRANSLATION_ONOFF;
 }
 
+static int snd_emu10k1_audigy_dsp_convert_32_to_2x16(
+                               struct snd_emu10k1_fx8010_code *icode,
+                               u32 *ptr, int tmp, int bit_shifter16,
+                               int reg_in, int reg_out)
+{
+       A_OP(icode, ptr, iACC3, A_GPR(tmp + 1), reg_in, A_C_00000000, A_C_00000000);
+       A_OP(icode, ptr, iANDXOR, A_GPR(tmp), A_GPR(tmp + 1), A_GPR(bit_shifter16 - 1), A_C_00000000);
+       A_OP(icode, ptr, iTSTNEG, A_GPR(tmp + 2), A_GPR(tmp), A_C_80000000, A_GPR(bit_shifter16 - 2));
+       A_OP(icode, ptr, iANDXOR, A_GPR(tmp + 2), A_GPR(tmp + 2), A_C_80000000, A_C_00000000);
+       A_OP(icode, ptr, iANDXOR, A_GPR(tmp), A_GPR(tmp), A_GPR(bit_shifter16 - 3), A_C_00000000);
+       A_OP(icode, ptr, iMACINT0, A_GPR(tmp), A_C_00000000, A_GPR(tmp), A_C_00010000);
+       A_OP(icode, ptr, iANDXOR, reg_out, A_GPR(tmp), A_C_ffffffff, A_GPR(tmp + 2));
+       A_OP(icode, ptr, iACC3, reg_out + 1, A_GPR(tmp + 1), A_C_00000000, A_C_00000000);
+       return 1;
+}
 
 /*
  * initial DSP configuration for Audigy
@@ -1077,6 +1146,7 @@ snd_emu10k1_init_stereo_onoff_control(struct snd_emu10k1_fx8010_control_gpr *ctl
 static int __devinit _snd_emu10k1_audigy_init_efx(struct snd_emu10k1 *emu)
 {
        int err, i, z, gpr, nctl;
+       int bit_shifter16;
        const int playback = 10;
        const int capture = playback + (SND_EMU10K1_PLAYBACK_CHANNELS * 2); /* we reserve 10 voices */
        const int stereo_mix = capture + 2;
@@ -1114,17 +1184,14 @@ static int __devinit _snd_emu10k1_audigy_init_efx(struct snd_emu10k1 *emu)
        ptr = 0;
        nctl = 0;
        gpr = stereo_mix + 10;
+       gpr_map[gpr++] = 0x00007fff;
+       gpr_map[gpr++] = 0x00008000;
+       gpr_map[gpr++] = 0x0000ffff;
+       bit_shifter16 = gpr;
 
        /* stop FX processor */
        snd_emu10k1_ptr_write(emu, A_DBG, 0, (emu->fx8010.dbg = 0) | A_DBG_SINGLE_STEP);
 
-#if 0
-       /* FIX: jcd test */
-       for (z = 0; z < 80; z=z+2) {
-               A_OP(icode, &ptr, iACC3, A_EXTOUT(z), A_FXBUS(FXBUS_PCM_LEFT_FRONT), A_C_00000000, A_C_00000000); /* left */
-               A_OP(icode, &ptr, iACC3, A_EXTOUT(z+1), A_FXBUS(FXBUS_PCM_RIGHT_FRONT), A_C_00000000, A_C_00000000); /* right */
-       }
-#endif /* jcd test */
 #if 1
        /* PCM front Playback Volume (independent from stereo mix) */
        A_OP(icode, &ptr, iMAC0, A_GPR(playback), A_C_00000000, A_GPR(gpr), A_FXBUS(FXBUS_PCM_LEFT_FRONT));
@@ -1182,13 +1249,20 @@ static int __devinit _snd_emu10k1_audigy_init_efx(struct snd_emu10k1 *emu)
        A_OP(icode, &ptr, iMAC0, A_GPR(capture+1), A_GPR(capture+1), A_GPR(gpr+1), A_FXBUS(FXBUS_MIDI_RIGHT));
        snd_emu10k1_init_stereo_control(&controls[nctl++], "Synth Capture Volume", gpr, 0);
        gpr += 2;
-
+      
        /*
         * inputs
         */
 #define A_ADD_VOLUME_IN(var,vol,input) \
 A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input))
 
+       /* emu1212 DSP 0 and DSP 1 Capture */
+       if (emu->card_capabilities->emu1010) {
+               A_OP(icode, &ptr, iMAC0, A_GPR(capture+0), A_GPR(capture+0), A_GPR(gpr), A_P16VIN(0x0));
+               A_OP(icode, &ptr, iMAC0, A_GPR(capture+1), A_GPR(capture+1), A_GPR(gpr+1), A_P16VIN(0x1));
+               snd_emu10k1_init_stereo_control(&controls[nctl++], "EMU Capture Volume", gpr, 0);
+               gpr += 2;
+       }
        /* AC'97 Playback Volume - used only for mic (renamed later) */
        A_ADD_VOLUME_IN(stereo_mix, gpr, A_EXTIN_AC97_L);
        A_ADD_VOLUME_IN(stereo_mix+1, gpr+1, A_EXTIN_AC97_R);
@@ -1429,6 +1503,13 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input))
 
        /* digital outputs */
        /* A_PUT_STEREO_OUTPUT(A_EXTOUT_FRONT_L, A_EXTOUT_FRONT_R, playback + SND_EMU10K1_PLAYBACK_CHANNELS); */
+       if (emu->card_capabilities->emu1010) {
+               /* EMU1010 Outputs from PCM Front, Rear, Center, LFE, Side */
+               snd_printk("EMU outputs on\n");
+               for (z = 0; z < 8; z++) {
+                       A_OP(icode, &ptr, iACC3, A_EMU32OUTL(z), A_GPR(playback + SND_EMU10K1_PLAYBACK_CHANNELS + z), A_C_00000000, A_C_00000000);
+               }
+       }
 
        /* IEC958 Optical Raw Playback Switch */ 
        gpr_map[gpr++] = 0;
@@ -1466,9 +1547,57 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input))
        A_PUT_OUTPUT(A_EXTOUT_ADC_CAP_R, capture+1);
 #endif
 
-       /* EFX capture - capture the 16 EXTINs */
-       for (z = 0; z < 16; z++) {
-               A_OP(icode, &ptr, iACC3, A_FXBUS2(z), A_C_00000000, A_C_00000000, A_EXTIN(z));
+       if (emu->card_capabilities->emu1010) {
+               snd_printk("EMU inputs on\n");
+               /* Capture 8 channels of S32_LE sound */
+               
+               /* printk("emufx.c: gpr=0x%x, tmp=0x%x\n",gpr, tmp); */
+               /* For the EMU1010: How to get 32bit values from the DSP. High 16bits into L, low 16bits into R. */
+               /* A_P16VIN(0) is delayed by one sample,
+                * so all other A_P16VIN channels will need to also be delayed
+                */
+               /* Left ADC in. 1 of 2 */
+               snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_P16VIN(0x0), A_FXBUS2(0) );
+               /* Right ADC in 1 of 2 */
+               gpr_map[gpr++] = 0x00000000;
+               snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBUS2(2) );
+               A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x1), A_C_00000000, A_C_00000000);
+               gpr_map[gpr++] = 0x00000000;
+               snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBUS2(4) );
+               A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x2), A_C_00000000, A_C_00000000);
+               gpr_map[gpr++] = 0x00000000;
+               snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBUS2(6) );
+               A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x3), A_C_00000000, A_C_00000000);
+               /* For 96kHz mode */
+               /* Left ADC in. 2 of 2 */
+               gpr_map[gpr++] = 0x00000000;
+               snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBUS2(0x8) );
+               A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x4), A_C_00000000, A_C_00000000);
+               /* Right ADC in 2 of 2 */
+               gpr_map[gpr++] = 0x00000000;
+               snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBUS2(0xa) );
+               A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x5), A_C_00000000, A_C_00000000);
+               gpr_map[gpr++] = 0x00000000;
+               snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBUS2(0xc) );
+               A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x6), A_C_00000000, A_C_00000000);
+               gpr_map[gpr++] = 0x00000000;
+               snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBUS2(0xe) );
+               A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x7), A_C_00000000, A_C_00000000);
+
+#if 0
+               for (z = 4; z < 8; z++) {
+                       A_OP(icode, &ptr, iACC3, A_FXBUS2(z), A_C_00000000, A_C_00000000, A_C_00000000);
+               }
+               for (z = 0xc; z < 0x10; z++) {
+                       A_OP(icode, &ptr, iACC3, A_FXBUS2(z), A_C_00000000, A_C_00000000, A_C_00000000);
+               }
+#endif
+       } else {
+               /* EFX capture - capture the 16 EXTINs */
+               /* Capture 16 channels of S16_LE sound */
+               for (z = 0; z < 16; z++) {
+                       A_OP(icode, &ptr, iACC3, A_FXBUS2(z), A_C_00000000, A_C_00000000, A_EXTIN(z));
+               }
        }
        
 #endif /* JCD test */
@@ -1488,7 +1617,9 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input))
        seg = snd_enter_user();
        icode->gpr_add_control_count = nctl;
        icode->gpr_add_controls = (struct snd_emu10k1_fx8010_control_gpr __user *)controls;
+       emu->support_tlv = 1; /* support TLV */
        err = snd_emu10k1_icode_poke(emu, icode);
+       emu->support_tlv = 0; /* clear again */
        snd_leave_user(seg);
 
  __err:
@@ -2105,7 +2236,9 @@ static int __devinit _snd_emu10k1_init_efx(struct snd_emu10k1 *emu)
        seg = snd_enter_user();
        icode->gpr_add_control_count = i;
        icode->gpr_add_controls = (struct snd_emu10k1_fx8010_control_gpr __user *)controls;
+       emu->support_tlv = 1; /* support TLV */
        err = snd_emu10k1_icode_poke(emu, icode);
+       emu->support_tlv = 0; /* clear again */
        snd_leave_user(seg);
        if (err >= 0)
                err = snd_emu10k1_ipcm_poke(emu, ipcm);
@@ -2138,7 +2271,7 @@ void snd_emu10k1_free_efx(struct snd_emu10k1 *emu)
                snd_emu10k1_ptr_write(emu, DBG, 0, emu->fx8010.dbg = EMU10K1_DBG_SINGLE_STEP);
 }
 
-#if 0 // FIXME: who use them?
+#if 0 /* FIXME: who use them? */
 int snd_emu10k1_fx8010_tone_control_activate(struct snd_emu10k1 *emu, int output)
 {
        if (output < 0 || output >= 6)
@@ -2249,6 +2382,9 @@ static int snd_emu10k1_fx8010_ioctl(struct snd_hwdep * hw, struct file *file, un
        int res;
        
        switch (cmd) {
+       case SNDRV_EMU10K1_IOCTL_PVERSION:
+               emu->support_tlv = 1;
+               return put_user(SNDRV_EMU10K1_VERSION, (int __user *)argp);
        case SNDRV_EMU10K1_IOCTL_INFO:
                info = kmalloc(sizeof(*info), GFP_KERNEL);
                if (!info)
index c31f3d0877fa42f5d041a73243d6b6a4b1a669fd..4db6e1ca16653193f9dc3170d394ddefeff981b1 100644 (file)
@@ -5,6 +5,9 @@
  *  Routines for control of EMU10K1 chips / mixer routines
  *  Multichannel PCM support Copyright (c) Lee Revell <rlrevell@joe-job.com>
  *
+ *  Copyright (c) by James Courtier-Dutton <James@superbug.co.uk>
+ *     Added EMU 1010 support.
+ *
  *  BUGS:
  *    --
  *
 #include <linux/init.h>
 #include <sound/core.h>
 #include <sound/emu10k1.h>
+#include <linux/delay.h>
+#include <sound/tlv.h>
+
+#include "p17v.h"
 
 #define AC97_ID_STAC9758       0x83847658
 
+static const DECLARE_TLV_DB_SCALE(snd_audigy_db_scale2, -10350, 50, 1); /* WM8775 gain scale */
+
 static int snd_emu10k1_spdif_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
 {
        uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958;
@@ -68,6 +77,669 @@ static int snd_emu10k1_spdif_get_mask(struct snd_kcontrol *kcontrol,
        return 0;
 }
 
+static char *emu1010_src_texts[] = { 
+       "Silence",
+       "Dock Mic A",
+       "Dock Mic B",
+       "Dock ADC1 Left",
+       "Dock ADC1 Right",
+       "Dock ADC2 Left",
+       "Dock ADC2 Right",
+       "Dock ADC3 Left",
+       "Dock ADC3 Right",
+       "0202 ADC Left",
+       "0202 ADC Right",
+       "0202 SPDIF Left",
+       "0202 SPDIF Right",
+       "ADAT 0",
+       "ADAT 1",
+       "ADAT 2",
+       "ADAT 3",
+       "ADAT 4",
+       "ADAT 5",
+       "ADAT 6",
+       "ADAT 7",
+       "DSP 0",
+       "DSP 1",
+       "DSP 2",
+       "DSP 3",
+       "DSP 4",
+       "DSP 5",
+       "DSP 6",
+       "DSP 7",
+       "DSP 8",
+       "DSP 9",
+       "DSP 10",
+       "DSP 11",
+       "DSP 12",
+       "DSP 13",
+       "DSP 14",
+       "DSP 15",
+       "DSP 16",
+       "DSP 17",
+       "DSP 18",
+       "DSP 19",
+       "DSP 20",
+       "DSP 21",
+       "DSP 22",
+       "DSP 23",
+       "DSP 24",
+       "DSP 25",
+       "DSP 26",
+       "DSP 27",
+       "DSP 28",
+       "DSP 29",
+       "DSP 30",
+       "DSP 31",
+};
+
+static unsigned int emu1010_src_regs[] = {
+       EMU_SRC_SILENCE,/* 0 */
+       EMU_SRC_DOCK_MIC_A1, /* 1 */
+       EMU_SRC_DOCK_MIC_B1, /* 2 */
+       EMU_SRC_DOCK_ADC1_LEFT1, /* 3 */
+       EMU_SRC_DOCK_ADC1_RIGHT1, /* 4 */
+       EMU_SRC_DOCK_ADC2_LEFT1, /* 5 */
+       EMU_SRC_DOCK_ADC2_RIGHT1, /* 6 */
+       EMU_SRC_DOCK_ADC3_LEFT1, /* 7 */
+       EMU_SRC_DOCK_ADC3_RIGHT1, /* 8 */
+       EMU_SRC_HAMOA_ADC_LEFT1, /* 9 */
+       EMU_SRC_HAMOA_ADC_RIGHT1, /* 10 */
+       EMU_SRC_HANA_SPDIF_LEFT1, /* 11 */
+       EMU_SRC_HANA_SPDIF_RIGHT1, /* 12 */
+       EMU_SRC_HANA_ADAT, /* 13 */
+       EMU_SRC_HANA_ADAT+1, /* 14 */
+       EMU_SRC_HANA_ADAT+2, /* 15 */
+       EMU_SRC_HANA_ADAT+3, /* 16 */
+       EMU_SRC_HANA_ADAT+4, /* 17 */
+       EMU_SRC_HANA_ADAT+5, /* 18 */
+       EMU_SRC_HANA_ADAT+6, /* 19 */
+       EMU_SRC_HANA_ADAT+7, /* 20 */
+       EMU_SRC_ALICE_EMU32A, /* 21 */
+       EMU_SRC_ALICE_EMU32A+1, /* 22 */
+       EMU_SRC_ALICE_EMU32A+2, /* 23 */
+       EMU_SRC_ALICE_EMU32A+3, /* 24 */
+       EMU_SRC_ALICE_EMU32A+4, /* 25 */
+       EMU_SRC_ALICE_EMU32A+5, /* 26 */
+       EMU_SRC_ALICE_EMU32A+6, /* 27 */
+       EMU_SRC_ALICE_EMU32A+7, /* 28 */
+       EMU_SRC_ALICE_EMU32A+8, /* 29 */
+       EMU_SRC_ALICE_EMU32A+9, /* 30 */
+       EMU_SRC_ALICE_EMU32A+0xa, /* 31 */
+       EMU_SRC_ALICE_EMU32A+0xb, /* 32 */
+       EMU_SRC_ALICE_EMU32A+0xc, /* 33 */
+       EMU_SRC_ALICE_EMU32A+0xd, /* 34 */
+       EMU_SRC_ALICE_EMU32A+0xe, /* 35 */
+       EMU_SRC_ALICE_EMU32A+0xf, /* 36 */
+       EMU_SRC_ALICE_EMU32B, /* 37 */
+       EMU_SRC_ALICE_EMU32B+1, /* 38 */
+       EMU_SRC_ALICE_EMU32B+2, /* 39 */
+       EMU_SRC_ALICE_EMU32B+3, /* 40 */
+       EMU_SRC_ALICE_EMU32B+4, /* 41 */
+       EMU_SRC_ALICE_EMU32B+5, /* 42 */
+       EMU_SRC_ALICE_EMU32B+6, /* 43 */
+       EMU_SRC_ALICE_EMU32B+7, /* 44 */
+       EMU_SRC_ALICE_EMU32B+8, /* 45 */
+       EMU_SRC_ALICE_EMU32B+9, /* 46 */
+       EMU_SRC_ALICE_EMU32B+0xa, /* 47 */
+       EMU_SRC_ALICE_EMU32B+0xb, /* 48 */
+       EMU_SRC_ALICE_EMU32B+0xc, /* 49 */
+       EMU_SRC_ALICE_EMU32B+0xd, /* 50 */
+       EMU_SRC_ALICE_EMU32B+0xe, /* 51 */
+       EMU_SRC_ALICE_EMU32B+0xf, /* 52 */
+};
+
+static unsigned int emu1010_output_dst[] = {
+       EMU_DST_DOCK_DAC1_LEFT1, /* 0 */
+       EMU_DST_DOCK_DAC1_RIGHT1, /* 1 */
+       EMU_DST_DOCK_DAC2_LEFT1, /* 2 */
+       EMU_DST_DOCK_DAC2_RIGHT1, /* 3 */
+       EMU_DST_DOCK_DAC3_LEFT1, /* 4 */
+       EMU_DST_DOCK_DAC3_RIGHT1, /* 5 */
+       EMU_DST_DOCK_DAC4_LEFT1, /* 6 */
+       EMU_DST_DOCK_DAC4_RIGHT1, /* 7 */
+       EMU_DST_DOCK_PHONES_LEFT1, /* 8 */
+       EMU_DST_DOCK_PHONES_RIGHT1, /* 9 */
+       EMU_DST_DOCK_SPDIF_LEFT1, /* 10 */
+       EMU_DST_DOCK_SPDIF_RIGHT1, /* 11 */
+       EMU_DST_HANA_SPDIF_LEFT1, /* 12 */
+       EMU_DST_HANA_SPDIF_RIGHT1, /* 13 */
+       EMU_DST_HAMOA_DAC_LEFT1, /* 14 */
+       EMU_DST_HAMOA_DAC_RIGHT1, /* 15 */
+       EMU_DST_HANA_ADAT, /* 16 */
+       EMU_DST_HANA_ADAT+1, /* 17 */
+       EMU_DST_HANA_ADAT+2, /* 18 */
+       EMU_DST_HANA_ADAT+3, /* 19 */
+       EMU_DST_HANA_ADAT+4, /* 20 */
+       EMU_DST_HANA_ADAT+5, /* 21 */
+       EMU_DST_HANA_ADAT+6, /* 22 */
+       EMU_DST_HANA_ADAT+7, /* 23 */
+};
+
+static unsigned int emu1010_input_dst[] = {
+       EMU_DST_ALICE2_EMU32_0,
+       EMU_DST_ALICE2_EMU32_1,
+       EMU_DST_ALICE2_EMU32_2,
+       EMU_DST_ALICE2_EMU32_3,
+       EMU_DST_ALICE2_EMU32_4,
+       EMU_DST_ALICE2_EMU32_5,
+       EMU_DST_ALICE2_EMU32_6,
+       EMU_DST_ALICE2_EMU32_7,
+       EMU_DST_ALICE2_EMU32_8,
+       EMU_DST_ALICE2_EMU32_9,
+       EMU_DST_ALICE2_EMU32_A,
+       EMU_DST_ALICE2_EMU32_B,
+       EMU_DST_ALICE2_EMU32_C,
+       EMU_DST_ALICE2_EMU32_D,
+       EMU_DST_ALICE2_EMU32_E,
+       EMU_DST_ALICE2_EMU32_F,
+       EMU_DST_ALICE_I2S0_LEFT,
+       EMU_DST_ALICE_I2S0_RIGHT,
+       EMU_DST_ALICE_I2S1_LEFT,
+       EMU_DST_ALICE_I2S1_RIGHT,
+       EMU_DST_ALICE_I2S2_LEFT,
+       EMU_DST_ALICE_I2S2_RIGHT,
+};
+
+static int snd_emu1010_input_output_source_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
+{
+       uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
+       uinfo->count = 1;
+       uinfo->value.enumerated.items = 53;
+       if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
+               uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
+       strcpy(uinfo->value.enumerated.name, emu1010_src_texts[uinfo->value.enumerated.item]);
+       return 0;
+}
+
+static int snd_emu1010_output_source_get(struct snd_kcontrol *kcontrol,
+                                 struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
+       int channel;
+
+       channel = (kcontrol->private_value) & 0xff;
+       ucontrol->value.enumerated.item[0] = emu->emu1010.output_source[channel];
+       return 0;
+}
+
+static int snd_emu1010_output_source_put(struct snd_kcontrol *kcontrol,
+                                 struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
+       int change = 0;
+       unsigned int val;
+       int channel;
+
+       channel = (kcontrol->private_value) & 0xff;
+       if (emu->emu1010.output_source[channel] != ucontrol->value.enumerated.item[0]) {
+               val = emu->emu1010.output_source[channel] = ucontrol->value.enumerated.item[0];
+               change = 1;
+               snd_emu1010_fpga_link_dst_src_write(emu,
+                       emu1010_output_dst[channel], emu1010_src_regs[val]);
+       }
+       return change;
+}
+
+static int snd_emu1010_input_source_get(struct snd_kcontrol *kcontrol,
+                                 struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
+       int channel;
+
+       channel = (kcontrol->private_value) & 0xff;
+       ucontrol->value.enumerated.item[0] = emu->emu1010.input_source[channel];
+       return 0;
+}
+
+static int snd_emu1010_input_source_put(struct snd_kcontrol *kcontrol,
+                                 struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
+       int change = 0;
+       unsigned int val;
+       int channel;
+
+       channel = (kcontrol->private_value) & 0xff;
+       if (emu->emu1010.input_source[channel] != ucontrol->value.enumerated.item[0]) {
+               val = emu->emu1010.input_source[channel] = ucontrol->value.enumerated.item[0];
+               change = 1;
+               snd_emu1010_fpga_link_dst_src_write(emu,
+                       emu1010_input_dst[channel], emu1010_src_regs[val]);
+       }
+       return change;
+}
+
+#define EMU1010_SOURCE_OUTPUT(xname,chid) \
+{                                                              \
+       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,     \
+       .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,              \
+       .info =  snd_emu1010_input_output_source_info,          \
+       .get =   snd_emu1010_output_source_get,                 \
+       .put =   snd_emu1010_output_source_put,                 \
+       .private_value = chid                                   \
+}
+
+static struct snd_kcontrol_new snd_emu1010_output_enum_ctls[] __devinitdata = {
+       EMU1010_SOURCE_OUTPUT("Dock DAC1 Left Playback Enum", 0),
+       EMU1010_SOURCE_OUTPUT("Dock DAC1 Right Playback Enum", 1),
+       EMU1010_SOURCE_OUTPUT("Dock DAC2 Left Playback Enum", 2),
+       EMU1010_SOURCE_OUTPUT("Dock DAC2 Right Playback Enum", 3),
+       EMU1010_SOURCE_OUTPUT("Dock DAC3 Left Playback Enum", 4),
+       EMU1010_SOURCE_OUTPUT("Dock DAC3 Right Playback Enum", 5),
+       EMU1010_SOURCE_OUTPUT("Dock DAC4 Left Playback Enum", 6),
+       EMU1010_SOURCE_OUTPUT("Dock DAC4 Right Playback Enum", 7),
+       EMU1010_SOURCE_OUTPUT("Dock Phones Left Playback Enum", 8),
+       EMU1010_SOURCE_OUTPUT("Dock Phones Right Playback Enum", 9),
+       EMU1010_SOURCE_OUTPUT("Dock SPDIF Left Playback Enum", 0xa),
+       EMU1010_SOURCE_OUTPUT("Dock SPDIF Right Playback Enum", 0xb),
+       EMU1010_SOURCE_OUTPUT("1010 SPDIF Left Playback Enum", 0xc),
+       EMU1010_SOURCE_OUTPUT("1010 SPDIF Right Playback Enum", 0xd),
+       EMU1010_SOURCE_OUTPUT("0202 DAC Left Playback Enum", 0xe),
+       EMU1010_SOURCE_OUTPUT("0202 DAC Right Playback Enum", 0xf),
+       EMU1010_SOURCE_OUTPUT("1010 ADAT 0 Playback Enum", 0x10),
+       EMU1010_SOURCE_OUTPUT("1010 ADAT 1 Playback Enum", 0x11),
+       EMU1010_SOURCE_OUTPUT("1010 ADAT 2 Playback Enum", 0x12),
+       EMU1010_SOURCE_OUTPUT("1010 ADAT 3 Playback Enum", 0x13),
+       EMU1010_SOURCE_OUTPUT("1010 ADAT 4 Playback Enum", 0x14),
+       EMU1010_SOURCE_OUTPUT("1010 ADAT 5 Playback Enum", 0x15),
+       EMU1010_SOURCE_OUTPUT("1010 ADAT 6 Playback Enum", 0x16),
+       EMU1010_SOURCE_OUTPUT("1010 ADAT 7 Playback Enum", 0x17),
+};
+
+#define EMU1010_SOURCE_INPUT(xname,chid) \
+{                                                              \
+       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,     \
+       .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,              \
+       .info =  snd_emu1010_input_output_source_info,          \
+       .get =   snd_emu1010_input_source_get,                  \
+       .put =   snd_emu1010_input_source_put,                  \
+       .private_value = chid                                   \
+}
+
+static struct snd_kcontrol_new snd_emu1010_input_enum_ctls[] __devinitdata = {
+       EMU1010_SOURCE_INPUT("DSP 0 Capture Enum", 0),
+       EMU1010_SOURCE_INPUT("DSP 1 Capture Enum", 1),
+       EMU1010_SOURCE_INPUT("DSP 2 Capture Enum", 2),
+       EMU1010_SOURCE_INPUT("DSP 3 Capture Enum", 3),
+       EMU1010_SOURCE_INPUT("DSP 4 Capture Enum", 4),
+       EMU1010_SOURCE_INPUT("DSP 5 Capture Enum", 5),
+       EMU1010_SOURCE_INPUT("DSP 6 Capture Enum", 6),
+       EMU1010_SOURCE_INPUT("DSP 7 Capture Enum", 7),
+       EMU1010_SOURCE_INPUT("DSP 8 Capture Enum", 8),
+       EMU1010_SOURCE_INPUT("DSP 9 Capture Enum", 9),
+       EMU1010_SOURCE_INPUT("DSP A Capture Enum", 0xa),
+       EMU1010_SOURCE_INPUT("DSP B Capture Enum", 0xb),
+       EMU1010_SOURCE_INPUT("DSP C Capture Enum", 0xc),
+       EMU1010_SOURCE_INPUT("DSP D Capture Enum", 0xd),
+       EMU1010_SOURCE_INPUT("DSP E Capture Enum", 0xe),
+       EMU1010_SOURCE_INPUT("DSP F Capture Enum", 0xf),
+       EMU1010_SOURCE_INPUT("DSP 10 Capture Enum", 0x10),
+       EMU1010_SOURCE_INPUT("DSP 11 Capture Enum", 0x11),
+       EMU1010_SOURCE_INPUT("DSP 12 Capture Enum", 0x12),
+       EMU1010_SOURCE_INPUT("DSP 13 Capture Enum", 0x13),
+       EMU1010_SOURCE_INPUT("DSP 14 Capture Enum", 0x14),
+       EMU1010_SOURCE_INPUT("DSP 15 Capture Enum", 0x15),
+};
+
+
+
+
+static int snd_emu1010_adc_pads_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
+{
+       uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
+       uinfo->count = 1;
+       uinfo->value.integer.min = 0;
+       uinfo->value.integer.max = 1;
+       return 0;
+}
+
+static int snd_emu1010_adc_pads_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
+       unsigned int mask = kcontrol->private_value & 0xff;
+       ucontrol->value.integer.value[0] = (emu->emu1010.adc_pads & mask) ? 1 : 0;
+       return 0;
+}
+
+static int snd_emu1010_adc_pads_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
+       unsigned int mask = kcontrol->private_value & 0xff;
+       unsigned int val, cache;
+       val = ucontrol->value.integer.value[0];
+       cache = emu->emu1010.adc_pads;
+       if (val == 1) 
+               cache = cache | mask;
+       else
+               cache = cache & ~mask;
+       if (cache != emu->emu1010.adc_pads) {
+               snd_emu1010_fpga_write(emu, EMU_HANA_ADC_PADS, cache );
+               emu->emu1010.adc_pads = cache;
+       }
+
+       return 0;
+}
+
+
+
+#define EMU1010_ADC_PADS(xname,chid) \
+{                                                              \
+       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,     \
+       .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,              \
+       .info =  snd_emu1010_adc_pads_info,                     \
+       .get =   snd_emu1010_adc_pads_get,                      \
+       .put =   snd_emu1010_adc_pads_put,                      \
+       .private_value = chid                                   \
+}
+
+static struct snd_kcontrol_new snd_emu1010_adc_pads[] __devinitdata = {
+       EMU1010_ADC_PADS("ADC1 14dB PAD Audio Dock Capture Switch", EMU_HANA_DOCK_ADC_PAD1),
+       EMU1010_ADC_PADS("ADC2 14dB PAD Audio Dock Capture Switch", EMU_HANA_DOCK_ADC_PAD2),
+       EMU1010_ADC_PADS("ADC3 14dB PAD Audio Dock Capture Switch", EMU_HANA_DOCK_ADC_PAD3),
+       EMU1010_ADC_PADS("ADC1 14dB PAD 0202 Capture Switch", EMU_HANA_0202_ADC_PAD1),
+};
+
+static int snd_emu1010_dac_pads_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
+{
+       uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
+       uinfo->count = 1;
+       uinfo->value.integer.min = 0;
+       uinfo->value.integer.max = 1;
+       return 0;
+}
+
+static int snd_emu1010_dac_pads_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
+       unsigned int mask = kcontrol->private_value & 0xff;
+       ucontrol->value.integer.value[0] = (emu->emu1010.dac_pads & mask) ? 1 : 0;
+       return 0;
+}
+
+static int snd_emu1010_dac_pads_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
+       unsigned int mask = kcontrol->private_value & 0xff;
+       unsigned int val, cache;
+       val = ucontrol->value.integer.value[0];
+       cache = emu->emu1010.dac_pads;
+       if (val == 1) 
+               cache = cache | mask;
+       else
+               cache = cache & ~mask;
+       if (cache != emu->emu1010.dac_pads) {
+               snd_emu1010_fpga_write(emu, EMU_HANA_DAC_PADS, cache );
+               emu->emu1010.dac_pads = cache;
+       }
+
+       return 0;
+}
+
+
+
+#define EMU1010_DAC_PADS(xname,chid) \
+{                                                              \
+       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,     \
+       .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,              \
+       .info =  snd_emu1010_dac_pads_info,                     \
+       .get =   snd_emu1010_dac_pads_get,                      \
+       .put =   snd_emu1010_dac_pads_put,                      \
+       .private_value = chid                                   \
+}
+
+static struct snd_kcontrol_new snd_emu1010_dac_pads[] __devinitdata = {
+       EMU1010_DAC_PADS("DAC1 Audio Dock 14dB PAD Playback Switch", EMU_HANA_DOCK_DAC_PAD1),
+       EMU1010_DAC_PADS("DAC2 Audio Dock 14dB PAD Playback Switch", EMU_HANA_DOCK_DAC_PAD2),
+       EMU1010_DAC_PADS("DAC3 Audio Dock 14dB PAD Playback Switch", EMU_HANA_DOCK_DAC_PAD3),
+       EMU1010_DAC_PADS("DAC4 Audio Dock 14dB PAD Playback Switch", EMU_HANA_DOCK_DAC_PAD4),
+       EMU1010_DAC_PADS("DAC1 0202 14dB PAD Playback Switch", EMU_HANA_0202_DAC_PAD1),
+};
+
+
+static int snd_emu1010_internal_clock_info(struct snd_kcontrol *kcontrol,
+                                         struct snd_ctl_elem_info *uinfo)
+{
+       static char *texts[2] = {
+               "44100", "48000"
+       };
+
+       uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
+       uinfo->count = 1;
+       uinfo->value.enumerated.items = 2;
+       if (uinfo->value.enumerated.item > 1)
+                uinfo->value.enumerated.item = 1;
+       strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
+       return 0;
+}
+
+static int snd_emu1010_internal_clock_get(struct snd_kcontrol *kcontrol,
+                                       struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
+
+       ucontrol->value.enumerated.item[0] = emu->emu1010.internal_clock;
+       return 0;
+}
+
+static int snd_emu1010_internal_clock_put(struct snd_kcontrol *kcontrol,
+                                       struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
+       unsigned int val;
+       int change = 0;
+
+       val = ucontrol->value.enumerated.item[0] ;
+       change = (emu->emu1010.internal_clock != val);
+       if (change) {
+               emu->emu1010.internal_clock = val;
+               switch (val) {
+               case 0:
+                       /* 44100 */
+                       /* Mute all */
+                       snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, EMU_MUTE );
+                       /* Default fallback clock 48kHz */
+                       snd_emu1010_fpga_write(emu, EMU_HANA_DEFCLOCK, EMU_HANA_DEFCLOCK_44_1K );
+                       /* Word Clock source, Internal 44.1kHz x1 */
+                       snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK,
+                       EMU_HANA_WCLOCK_INT_44_1K | EMU_HANA_WCLOCK_1X );
+                       /* Set LEDs on Audio Dock */
+                       snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_LEDS_2,
+                               EMU_HANA_DOCK_LEDS_2_44K | EMU_HANA_DOCK_LEDS_2_LOCK );
+                       /* Allow DLL to settle */
+                       msleep(10);
+                       /* Unmute all */
+                       snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, EMU_UNMUTE );
+                       break;
+               case 1:
+                       /* 48000 */
+                       /* Mute all */
+                       snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, EMU_MUTE );
+                       /* Default fallback clock 48kHz */
+                       snd_emu1010_fpga_write(emu, EMU_HANA_DEFCLOCK, EMU_HANA_DEFCLOCK_48K );
+                       /* Word Clock source, Internal 48kHz x1 */
+                       snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK,
+                               EMU_HANA_WCLOCK_INT_48K | EMU_HANA_WCLOCK_1X );
+                       /* Set LEDs on Audio Dock */
+                       snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_LEDS_2,
+                               EMU_HANA_DOCK_LEDS_2_48K | EMU_HANA_DOCK_LEDS_2_LOCK );
+                       /* Allow DLL to settle */
+                       msleep(10);
+                       /* Unmute all */
+                       snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, EMU_UNMUTE );
+                       break;
+               }
+       }
+        return change;
+}
+
+static struct snd_kcontrol_new snd_emu1010_internal_clock =
+{
+       .access =       SNDRV_CTL_ELEM_ACCESS_READWRITE,
+       .iface =        SNDRV_CTL_ELEM_IFACE_MIXER,
+       .name =         "Clock Internal Rate",
+       .count =        1,
+       .info =         snd_emu1010_internal_clock_info,
+       .get =          snd_emu1010_internal_clock_get,
+       .put =          snd_emu1010_internal_clock_put
+};
+
+static int snd_audigy_i2c_capture_source_info(struct snd_kcontrol *kcontrol,
+                                         struct snd_ctl_elem_info *uinfo)
+{
+#if 0
+       static char *texts[4] = {
+               "Unknown1", "Unknown2", "Mic", "Line"
+       };
+#endif
+       static char *texts[2] = {
+               "Mic", "Line"
+       };
+
+       uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
+       uinfo->count = 1;
+       uinfo->value.enumerated.items = 2;
+       if (uinfo->value.enumerated.item > 1)
+                uinfo->value.enumerated.item = 1;
+       strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
+       return 0;
+}
+
+static int snd_audigy_i2c_capture_source_get(struct snd_kcontrol *kcontrol,
+                                       struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
+
+       ucontrol->value.enumerated.item[0] = emu->i2c_capture_source;
+       return 0;
+}
+
+static int snd_audigy_i2c_capture_source_put(struct snd_kcontrol *kcontrol,
+                                       struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
+       unsigned int source_id;
+       unsigned int ngain, ogain;
+       u32 gpio;
+       int change = 0;
+       unsigned long flags;
+       u32 source;
+       /* If the capture source has changed,
+        * update the capture volume from the cached value
+        * for the particular source.
+        */
+       source_id = ucontrol->value.enumerated.item[0]; /* Use 2 and 3 */
+       change = (emu->i2c_capture_source != source_id);
+       if (change) {
+               snd_emu10k1_i2c_write(emu, ADC_MUX, 0); /* Mute input */
+               spin_lock_irqsave(&emu->emu_lock, flags);
+               gpio = inl(emu->port + A_IOCFG);
+               if (source_id==0)
+                       outl(gpio | 0x4, emu->port + A_IOCFG);
+               else
+                       outl(gpio & ~0x4, emu->port + A_IOCFG);
+               spin_unlock_irqrestore(&emu->emu_lock, flags);
+
+               ngain = emu->i2c_capture_volume[source_id][0]; /* Left */
+               ogain = emu->i2c_capture_volume[emu->i2c_capture_source][0]; /* Left */
+               if (ngain != ogain)
+                       snd_emu10k1_i2c_write(emu, ADC_ATTEN_ADCL, ((ngain) & 0xff));
+               ngain = emu->i2c_capture_volume[source_id][1]; /* Right */
+               ogain = emu->i2c_capture_volume[emu->i2c_capture_source][1]; /* Right */
+               if (ngain != ogain)
+                       snd_emu10k1_i2c_write(emu, ADC_ATTEN_ADCR, ((ngain) & 0xff));
+
+               source = 1 << (source_id + 2);
+               snd_emu10k1_i2c_write(emu, ADC_MUX, source); /* Set source */
+               emu->i2c_capture_source = source_id;
+       }
+        return change;
+}
+
+static struct snd_kcontrol_new snd_audigy_i2c_capture_source =
+{
+               .iface =        SNDRV_CTL_ELEM_IFACE_MIXER,
+               .name =         "Capture Source",
+               .info =         snd_audigy_i2c_capture_source_info,
+               .get =          snd_audigy_i2c_capture_source_get,
+               .put =          snd_audigy_i2c_capture_source_put
+};
+
+static int snd_audigy_i2c_volume_info(struct snd_kcontrol *kcontrol,
+                                 struct snd_ctl_elem_info *uinfo)
+{
+       uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
+       uinfo->count = 2;
+       uinfo->value.integer.min = 0;
+       uinfo->value.integer.max = 255;
+       return 0;
+}
+
+static int snd_audigy_i2c_volume_get(struct snd_kcontrol *kcontrol,
+                                struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
+       int source_id;
+
+       source_id = kcontrol->private_value;
+
+       ucontrol->value.integer.value[0] = emu->i2c_capture_volume[source_id][0];
+       ucontrol->value.integer.value[1] = emu->i2c_capture_volume[source_id][1];
+       return 0;
+}
+
+static int snd_audigy_i2c_volume_put(struct snd_kcontrol *kcontrol,
+                                struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
+       unsigned int ogain;
+       unsigned int ngain;
+       int source_id;
+       int change = 0;
+
+       source_id = kcontrol->private_value;
+       ogain = emu->i2c_capture_volume[source_id][0]; /* Left */
+       ngain = ucontrol->value.integer.value[0];
+       if (ngain > 0xff)
+               return 0;
+       if (ogain != ngain) {
+               if (emu->i2c_capture_source == source_id)
+                       snd_emu10k1_i2c_write(emu, ADC_ATTEN_ADCL, ((ngain) & 0xff) );
+               emu->i2c_capture_volume[source_id][0] = ucontrol->value.integer.value[0];
+               change = 1;
+       }
+       ogain = emu->i2c_capture_volume[source_id][1]; /* Right */
+       ngain = ucontrol->value.integer.value[1];
+       if (ngain > 0xff)
+               return 0;
+       if (ogain != ngain) {
+               if (emu->i2c_capture_source == source_id)
+                       snd_emu10k1_i2c_write(emu, ADC_ATTEN_ADCR, ((ngain) & 0xff));
+               emu->i2c_capture_volume[source_id][1] = ucontrol->value.integer.value[1];
+               change = 1;
+       }
+
+       return change;
+}
+
+#define I2C_VOLUME(xname,chid) \
+{                                                              \
+       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,     \
+       .access = SNDRV_CTL_ELEM_ACCESS_READWRITE |             \
+                 SNDRV_CTL_ELEM_ACCESS_TLV_READ,               \
+       .info =  snd_audigy_i2c_volume_info,                    \
+       .get =   snd_audigy_i2c_volume_get,                     \
+       .put =   snd_audigy_i2c_volume_put,                     \
+       .tlv = { .p = snd_audigy_db_scale2 },                   \
+       .private_value = chid                                   \
+}
+
+
+static struct snd_kcontrol_new snd_audigy_i2c_volume_ctls[] __devinitdata = {
+       I2C_VOLUME("Mic Capture Volume", 0),
+       I2C_VOLUME("Line Capture Volume", 0)
+};
+
 #if 0
 static int snd_audigy_spdif_output_rate_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
 {
@@ -668,7 +1340,9 @@ static int snd_emu10k1_shared_spdif_put(struct snd_kcontrol *kcontrol,
        int change = 0;
 
        spin_lock_irqsave(&emu->reg_lock, flags);
-       if (emu->audigy) {
+       if ( emu->card_capabilities->i2c_adc) {
+               /* Do nothing for Audigy 2 ZS Notebook */
+       } else if (emu->audigy) {
                reg = inl(emu->port + A_IOCFG);
                val = ucontrol->value.integer.value[0] ? A_IOCFG_GPOUT0 : 0;
                change = (reg & A_IOCFG_GPOUT0) != val;
@@ -806,6 +1480,24 @@ int __devinit snd_emu10k1_mixer(struct snd_emu10k1 *emu,
                "AMic Playback Volume", "Mic Playback Volume",
                NULL
        };
+       static char *audigy_rename_ctls_i2c_adc[] = {
+               //"Analog Mix Capture Volume","OLD Analog Mix Capture Volume",
+               "Line Capture Volume", "Analog Mix Capture Volume",
+               "Wave Playback Volume", "OLD PCM Playback Volume",
+               "Wave Master Playback Volume", "Master Playback Volume",
+               "AMic Playback Volume", "Old Mic Playback Volume",
+               "CD Capture Volume", "IEC958 Optical Capture Volume",
+               NULL
+       };
+       static char *audigy_remove_ctls_i2c_adc[] = {
+               /* On the Audigy2 ZS Notebook
+                * Capture via WM8775  */
+               "Mic Capture Volume",
+               "Analog Mix Capture Volume",
+               "Aux Capture Volume",
+               "IEC958 Optical Capture Volume",
+               NULL
+       };
        static char *audigy_remove_ctls_1361t_adc[] = {
                /* On the Audigy2 the AC97 playback is piped into
                 * the Philips ADC for 24bit capture */
@@ -890,6 +1582,7 @@ int __devinit snd_emu10k1_mixer(struct snd_emu10k1 *emu,
                        if (emu->ac97->id == AC97_ID_STAC9758) {
                                emu->rear_ac97 = 1;
                                snd_emu10k1_ptr_write(emu, AC97SLOT, 0, AC97SLOT_CNTR|AC97SLOT_LFE|AC97SLOT_REAR_LEFT|AC97SLOT_REAR_RIGHT);
+                               snd_ac97_write_cache(emu->ac97, AC97_HEADPHONE, 0x0202);
                        }
                        /* remove unused AC97 controls */
                        snd_ac97_write_cache(emu->ac97, AC97_SURROUND_MASTER, 0x0202);
@@ -898,6 +1591,10 @@ int __devinit snd_emu10k1_mixer(struct snd_emu10k1 *emu,
                }
                for (; *c; c++)
                        remove_ctl(card, *c);
+       } else if (emu->card_capabilities->i2c_adc) {
+               c = audigy_remove_ctls_i2c_adc;
+               for (; *c; c++)
+                       remove_ctl(card, *c);
        } else {
        no_ac97:
                if (emu->card_capabilities->ecard)
@@ -911,6 +1608,8 @@ int __devinit snd_emu10k1_mixer(struct snd_emu10k1 *emu,
        if (emu->audigy)
                if (emu->card_capabilities->adc_1361t)
                        c = audigy_rename_ctls_1361t_adc;
+               else if (emu->card_capabilities->i2c_adc)
+                       c = audigy_rename_ctls_i2c_adc;
                else
                        c = audigy_rename_ctls;
        else
@@ -1021,7 +1720,7 @@ int __devinit snd_emu10k1_mixer(struct snd_emu10k1 *emu,
                        return err;
        }
 
-       if ( emu->card_capabilities->emu1212m) {
+       if ( emu->card_capabilities->emu1010) {
                ;  /* Disable the snd_audigy_spdif_shared_spdif */
        } else if (emu->audigy) {
                if ((kctl = snd_ctl_new1(&snd_audigy_shared_spdif, emu)) == NULL)
@@ -1045,6 +1744,48 @@ int __devinit snd_emu10k1_mixer(struct snd_emu10k1 *emu,
                if ((err = snd_p16v_mixer(emu)))
                        return err;
        }
+
+       if ( emu->card_capabilities->emu1010) {
+               int i;
+
+               for (i = 0; i < ARRAY_SIZE(snd_emu1010_output_enum_ctls); i++) {
+                       err = snd_ctl_add(card, snd_ctl_new1(&snd_emu1010_output_enum_ctls[i], emu));
+                       if (err < 0)
+                               return err;
+               }
+               for (i = 0; i < ARRAY_SIZE(snd_emu1010_input_enum_ctls); i++) {
+                       err = snd_ctl_add(card, snd_ctl_new1(&snd_emu1010_input_enum_ctls[i], emu));
+                       if (err < 0)
+                               return err;
+               }
+               for (i = 0; i < ARRAY_SIZE(snd_emu1010_adc_pads); i++) {
+                       err = snd_ctl_add(card, snd_ctl_new1(&snd_emu1010_adc_pads[i], emu));
+                       if (err < 0)
+                               return err;
+               }
+               for (i = 0; i < ARRAY_SIZE(snd_emu1010_dac_pads); i++) {
+                       err = snd_ctl_add(card, snd_ctl_new1(&snd_emu1010_dac_pads[i], emu));
+                       if (err < 0)
+                               return err;
+               }
+               err = snd_ctl_add(card, snd_ctl_new1(&snd_emu1010_internal_clock, emu));
+               if (err < 0)
+                       return err;
+       }
+
+       if ( emu->card_capabilities->i2c_adc) {
+               int i;
+
+               err = snd_ctl_add(card, snd_ctl_new1(&snd_audigy_i2c_capture_source, emu));
+               if (err < 0)
+                       return err;
+
+               for (i = 0; i < ARRAY_SIZE(snd_audigy_i2c_volume_ctls); i++) {
+                       err = snd_ctl_add(card, snd_ctl_new1(&snd_audigy_i2c_volume_ctls[i], emu));
+                       if (err < 0)
+                               return err;
+               }
+       }
                
        return 0;
 }
index 717e92ec9e0ae25d1f4978f9bd651e2da4069a70..ab4f5df5241b6f0471abbb23bda5be408cb9e9d8 100644 (file)
@@ -147,7 +147,7 @@ static int snd_emu10k1_pcm_channel_alloc(struct snd_emu10k1_pcm * epcm, int voic
                                              1,
                                              &epcm->extra);
                if (err < 0) {
-                       // printk("pcm_channel_alloc: failed extra: voices=%d, frame=%d\n", voices, frame);
+                       /* printk("pcm_channel_alloc: failed extra: voices=%d, frame=%d\n", voices, frame); */
                        for (i = 0; i < voices; i++) {
                                snd_emu10k1_voice_free(epcm->emu, epcm->voices[i]);
                                epcm->voices[i] = NULL;
@@ -339,7 +339,7 @@ static void snd_emu10k1_pcm_init_voice(struct snd_emu10k1 *emu,
                }
        }
 
-       // setup routing
+       /* setup routing */
        if (emu->audigy) {
                snd_emu10k1_ptr_write(emu, A_FXRT1, voice,
                                      snd_emu10k1_compose_audigy_fxrt1(send_routing));
@@ -353,12 +353,15 @@ static void snd_emu10k1_pcm_init_voice(struct snd_emu10k1 *emu,
        } else
                snd_emu10k1_ptr_write(emu, FXRT, voice,
                                      snd_emu10k1_compose_send_routing(send_routing));
-       // Stop CA
-       // Assumption that PT is already 0 so no harm overwriting
+       /* Stop CA */
+       /* Assumption that PT is already 0 so no harm overwriting */
        snd_emu10k1_ptr_write(emu, PTRX, voice, (send_amount[0] << 8) | send_amount[1]);
        snd_emu10k1_ptr_write(emu, DSL, voice, end_addr | (send_amount[3] << 24));
        snd_emu10k1_ptr_write(emu, PSST, voice, start_addr | (send_amount[2] << 24));
-       pitch_target = emu10k1_calc_pitch_target(runtime->rate);
+       if (emu->card_capabilities->emu1010)
+               pitch_target = PITCH_48000; /* Disable interpolators on emu1010 card */
+       else 
+               pitch_target = emu10k1_calc_pitch_target(runtime->rate);
        if (extra)
                snd_emu10k1_ptr_write(emu, CCCA, voice, start_addr |
                              emu10k1_select_interprom(pitch_target) |
@@ -367,14 +370,14 @@ static void snd_emu10k1_pcm_init_voice(struct snd_emu10k1 *emu,
                snd_emu10k1_ptr_write(emu, CCCA, voice, (start_addr + ccis) |
                              emu10k1_select_interprom(pitch_target) |
                              (w_16 ? 0 : CCCA_8BITSELECT));
-       // Clear filter delay memory
+       /* Clear filter delay memory */
        snd_emu10k1_ptr_write(emu, Z1, voice, 0);
        snd_emu10k1_ptr_write(emu, Z2, voice, 0);
-       // invalidate maps
+       /* invalidate maps */
        silent_page = ((unsigned int)emu->silent_page.addr << 1) | MAP_PTI_MASK;
        snd_emu10k1_ptr_write(emu, MAPA, voice, silent_page);
        snd_emu10k1_ptr_write(emu, MAPB, voice, silent_page);
-       // modulation envelope
+       /* modulation envelope */
        snd_emu10k1_ptr_write(emu, CVCF, voice, 0xffff);
        snd_emu10k1_ptr_write(emu, VTFT, voice, 0xffff);
        snd_emu10k1_ptr_write(emu, ATKHLDM, voice, 0);
@@ -385,12 +388,12 @@ static void snd_emu10k1_pcm_init_voice(struct snd_emu10k1 *emu,
        snd_emu10k1_ptr_write(emu, TREMFRQ, voice, 0);
        snd_emu10k1_ptr_write(emu, FM2FRQ2, voice, 0);
        snd_emu10k1_ptr_write(emu, ENVVAL, voice, 0x8000);
-       // volume envelope
+       /* volume envelope */
        snd_emu10k1_ptr_write(emu, ATKHLDV, voice, 0x7f7f);
        snd_emu10k1_ptr_write(emu, ENVVOL, voice, 0x0000);
-       // filter envelope
+       /* filter envelope */
        snd_emu10k1_ptr_write(emu, PEFE_FILTERAMOUNT, voice, 0x7f);
-       // pitch envelope
+       /* pitch envelope */
        snd_emu10k1_ptr_write(emu, PEFE_PITCHAMOUNT, voice, 0);
 
        spin_unlock_irqrestore(&emu->reg_lock, flags);
@@ -468,7 +471,7 @@ static int snd_emu10k1_efx_playback_hw_free(struct snd_pcm_substream *substream)
                snd_emu10k1_voice_free(epcm->emu, epcm->extra);
                epcm->extra = NULL;
        }
-       for (i=0; i < NUM_EFX_PLAYBACK; i++) {
+       for (i = 0; i < NUM_EFX_PLAYBACK; i++) {
                if (epcm->voices[i]) {
                        snd_emu10k1_voice_free(epcm->emu, epcm->voices[i]);
                        epcm->voices[i] = NULL;
@@ -637,7 +640,7 @@ static void snd_emu10k1_playback_invalidate_cache(struct snd_emu10k1 *emu, int e
        stereo = (!extra && runtime->channels == 2);
        sample = snd_pcm_format_width(runtime->format) == 16 ? 0 : 0x80808080;
        ccis = emu10k1_ccis(stereo, sample == 0);
-       // set cs to 2 * number of cache registers beside the invalidated
+       /* set cs to 2 * number of cache registers beside the invalidated */
        cs = (sample == 0) ? (32-ccis) : (64-ccis+1) >> 1;
        if (cs > 16) cs = 16;
        for (i = 0; i < cs; i++) {
@@ -646,14 +649,14 @@ static void snd_emu10k1_playback_invalidate_cache(struct snd_emu10k1 *emu, int e
                        snd_emu10k1_ptr_write(emu, CD0 + i, voice + 1, sample);
                }
        }
-       // reset cache
+       /* reset cache */
        snd_emu10k1_ptr_write(emu, CCR_CACHEINVALIDSIZE, voice, 0);
        snd_emu10k1_ptr_write(emu, CCR_READADDRESS, voice, cra);
        if (stereo) {
                snd_emu10k1_ptr_write(emu, CCR_CACHEINVALIDSIZE, voice + 1, 0);
                snd_emu10k1_ptr_write(emu, CCR_READADDRESS, voice + 1, cra);
        }
-       // fill cache
+       /* fill cache */
        snd_emu10k1_ptr_write(emu, CCR_CACHEINVALIDSIZE, voice, ccis);
        if (stereo) {
                snd_emu10k1_ptr_write(emu, CCR_CACHEINVALIDSIZE, voice+1, ccis);
@@ -698,7 +701,10 @@ static void snd_emu10k1_playback_trigger_voice(struct snd_emu10k1 *emu, struct s
        voice = evoice->number;
 
        pitch = snd_emu10k1_rate_to_pitch(runtime->rate) >> 8;
-       pitch_target = emu10k1_calc_pitch_target(runtime->rate);
+       if (emu->card_capabilities->emu1010)
+               pitch_target = PITCH_48000; /* Disable interpolators on emu1010 card */
+       else 
+               pitch_target = emu10k1_calc_pitch_target(runtime->rate);
        snd_emu10k1_ptr_write(emu, PTRX_PITCHTARGET, voice, pitch_target);
        if (master || evoice->epcm->type == PLAYBACK_EFX)
                snd_emu10k1_ptr_write(emu, CPF_CURRENTPITCH, voice, pitch_target);
@@ -732,7 +738,7 @@ static int snd_emu10k1_playback_trigger(struct snd_pcm_substream *substream,
        struct snd_emu10k1_pcm_mixer *mix;
        int result = 0;
 
-       // printk("trigger - emu10k1 = 0x%x, cmd = %i, pointer = %i\n", (int)emu, cmd, substream->ops->pointer(substream));
+       /* printk("trigger - emu10k1 = 0x%x, cmd = %i, pointer = %i\n", (int)emu, cmd, substream->ops->pointer(substream)); */
        spin_lock(&emu->reg_lock);
        switch (cmd) {
        case SNDRV_PCM_TRIGGER_START:
@@ -778,10 +784,10 @@ static int snd_emu10k1_capture_trigger(struct snd_pcm_substream *substream,
        switch (cmd) {
        case SNDRV_PCM_TRIGGER_START:
        case SNDRV_PCM_TRIGGER_RESUME:
-               // hmm this should cause full and half full interrupt to be raised?  
+               /* hmm this should cause full and half full interrupt to be raised? */
                outl(epcm->capture_ipr, emu->port + IPR);
                snd_emu10k1_intr_enable(emu, epcm->capture_inte);
-               // printk("adccr = 0x%x, adcbs = 0x%x\n", epcm->adccr, epcm->adcbs);
+               /* printk("adccr = 0x%x, adcbs = 0x%x\n", epcm->adccr, epcm->adcbs); */
                switch (epcm->type) {
                case CAPTURE_AC97ADC:
                        snd_emu10k1_ptr_write(emu, ADCCR, 0, epcm->capture_cr_val);
@@ -790,6 +796,7 @@ static int snd_emu10k1_capture_trigger(struct snd_pcm_substream *substream,
                        if (emu->audigy) {
                                snd_emu10k1_ptr_write(emu, A_FXWC1, 0, epcm->capture_cr_val);
                                snd_emu10k1_ptr_write(emu, A_FXWC2, 0, epcm->capture_cr_val2);
+                               snd_printdd("cr_val=0x%x, cr_val2=0x%x\n", epcm->capture_cr_val, epcm->capture_cr_val2);
                        } else
                                snd_emu10k1_ptr_write(emu, FXWC, 0, epcm->capture_cr_val);
                        break;
@@ -851,7 +858,7 @@ static snd_pcm_uframes_t snd_emu10k1_playback_pointer(struct snd_pcm_substream *
                        ptr -= runtime->buffer_size;
        }
 #endif
-       // printk("ptr = 0x%x, buffer_size = 0x%x, period_size = 0x%x\n", ptr, runtime->buffer_size, runtime->period_size);
+       /* printk("ptr = 0x%x, buffer_size = 0x%x, period_size = 0x%x\n", ptr, runtime->buffer_size, runtime->period_size); */
        return ptr;
 }
 
@@ -868,7 +875,7 @@ static int snd_emu10k1_efx_playback_trigger(struct snd_pcm_substream *substream,
        spin_lock(&emu->reg_lock);
        switch (cmd) {
        case SNDRV_PCM_TRIGGER_START:
-               // prepare voices
+               /* prepare voices */
                for (i = 0; i < NUM_EFX_PLAYBACK; i++) {        
                        snd_emu10k1_playback_invalidate_cache(emu, 0, epcm->voices[i]);
                }
@@ -917,7 +924,7 @@ static snd_pcm_uframes_t snd_emu10k1_capture_pointer(struct snd_pcm_substream *s
        if (!epcm->running)
                return 0;
        if (epcm->first_ptr) {
-               udelay(50);     // hack, it takes awhile until capture is started
+               udelay(50);     /* hack, it takes awhile until capture is started */
                epcm->first_ptr = 0;
        }
        ptr = snd_emu10k1_ptr_read(emu, epcm->capture_idx_reg, 0) & 0x0000ffff;
@@ -972,6 +979,28 @@ static struct snd_pcm_hardware snd_emu10k1_capture =
        .fifo_size =            0,
 };
 
+static struct snd_pcm_hardware snd_emu10k1_capture_efx =
+{
+       .info =                 (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
+                                SNDRV_PCM_INFO_BLOCK_TRANSFER |
+                                SNDRV_PCM_INFO_RESUME |
+                                SNDRV_PCM_INFO_MMAP_VALID),
+       .formats =              SNDRV_PCM_FMTBIT_S16_LE,
+       .rates =                SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 | 
+                                SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 | 
+                                SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_192000,
+       .rate_min =             44100,
+       .rate_max =             192000,
+       .channels_min =         8,
+       .channels_max =         8,
+       .buffer_bytes_max =     (64*1024),
+       .period_bytes_min =     384,
+       .period_bytes_max =     (64*1024),
+       .periods_min =          2,
+       .periods_max =          2,
+       .fifo_size =            0,
+};
+
 /*
  *
  */
@@ -1016,7 +1045,7 @@ static int snd_emu10k1_efx_playback_close(struct snd_pcm_substream *substream)
        struct snd_emu10k1_pcm_mixer *mix;
        int i;
 
-       for (i=0; i < NUM_EFX_PLAYBACK; i++) {
+       for (i = 0; i < NUM_EFX_PLAYBACK; i++) {
                mix = &emu->efx_pcm_mixer[i];
                mix->epcm = NULL;
                snd_emu10k1_pcm_efx_mixer_notify(emu, i, 0);
@@ -1045,7 +1074,7 @@ static int snd_emu10k1_efx_playback_open(struct snd_pcm_substream *substream)
        runtime->private_free = snd_emu10k1_pcm_free_substream;
        runtime->hw = snd_emu10k1_efx_playback;
        
-       for (i=0; i < NUM_EFX_PLAYBACK; i++) {
+       for (i = 0; i < NUM_EFX_PLAYBACK; i++) {
                mix = &emu->efx_pcm_mixer[i];
                mix->send_routing[0][0] = i;
                memset(&mix->send_volume, 0, sizeof(mix->send_volume));
@@ -1199,15 +1228,69 @@ static int snd_emu10k1_capture_efx_open(struct snd_pcm_substream *substream)
        epcm->capture_idx_reg = FXIDX;
        substream->runtime->private_data = epcm;
        substream->runtime->private_free = snd_emu10k1_pcm_free_substream;
-       runtime->hw = snd_emu10k1_capture;
+       runtime->hw = snd_emu10k1_capture_efx;
        runtime->hw.rates = SNDRV_PCM_RATE_48000;
        runtime->hw.rate_min = runtime->hw.rate_max = 48000;
        spin_lock_irq(&emu->reg_lock);
-       runtime->hw.channels_min = runtime->hw.channels_max = 0;
-       for (idx = 0; idx < nefx; idx++) {
-               if (emu->efx_voices_mask[idx/32] & (1 << (idx%32))) {
-                       runtime->hw.channels_min++;
-                       runtime->hw.channels_max++;
+       if (emu->card_capabilities->emu1010) {
+               /* TODO 
+                * SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE
+                * SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |
+                * SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 |
+                * SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_192000
+                * rate_min = 44100,
+                * rate_max = 192000,
+                * channels_min = 8,
+                * channels_max = 8,
+                * Need to add mixer control to fix sample rate
+                *                 
+                * There are 16 mono channels of 16bits each.
+                * 24bit Audio uses 2x channels over 16bit
+                * 96kHz uses 2x channels over 48kHz
+                * 192kHz uses 4x channels over 48kHz
+                * So, for 48kHz 24bit, one has 8 channels
+                * for 96kHz 24bit, one has 4 channels
+                * for 192kHz 24bit, one has 2 channels
+                */
+#if 1
+               switch (emu->emu1010.internal_clock) {
+               case 0:
+                       /* For 44.1kHz */
+                       runtime->hw.rates = SNDRV_PCM_RATE_44100;
+                       runtime->hw.rate_min = runtime->hw.rate_max = 44100;
+                       runtime->hw.channels_min = runtime->hw.channels_max = 8;
+                       break;
+               case 1:
+                       /* For 48kHz */
+                       runtime->hw.rates = SNDRV_PCM_RATE_48000;
+                       runtime->hw.rate_min = runtime->hw.rate_max = 48000;
+                       runtime->hw.channels_min = runtime->hw.channels_max = 8;
+                       break;
+               };
+#endif
+#if 0
+               /* For 96kHz */
+               runtime->hw.rates = SNDRV_PCM_RATE_96000;
+               runtime->hw.rate_min = runtime->hw.rate_max = 96000;
+               runtime->hw.channels_min = runtime->hw.channels_max = 4;
+#endif
+#if 0
+               /* For 192kHz */
+               runtime->hw.rates = SNDRV_PCM_RATE_192000;
+               runtime->hw.rate_min = runtime->hw.rate_max = 192000;
+               runtime->hw.channels_min = runtime->hw.channels_max = 2;
+#endif
+               runtime->hw.formats = SNDRV_PCM_FMTBIT_S32_LE;
+               /* efx_voices_mask[0] is expected to be zero
+                * efx_voices_mask[1] is expected to have 16bits set
+                */
+       } else {
+               runtime->hw.channels_min = runtime->hw.channels_max = 0;
+               for (idx = 0; idx < nefx; idx++) {
+                       if (emu->efx_voices_mask[idx/32] & (1 << (idx%32))) {
+                               runtime->hw.channels_min++;
+                               runtime->hw.channels_max++;
+                       }
                }
        }
        epcm->capture_cr_val = emu->efx_voices_mask[0];
@@ -1460,7 +1543,7 @@ static void snd_emu10k1_fx8010_playback_tram_poke1(unsigned short *dst_left,
                                                   unsigned int count,
                                                   unsigned int tram_shift)
 {
-       // printk("tram_poke1: dst_left = 0x%p, dst_right = 0x%p, src = 0x%p, count = 0x%x\n", dst_left, dst_right, src, count);
+       /* printk("tram_poke1: dst_left = 0x%p, dst_right = 0x%p, src = 0x%p, count = 0x%x\n", dst_left, dst_right, src, count); */
        if ((tram_shift & 1) == 0) {
                while (count--) {
                        *dst_left-- = *src++;
@@ -1537,7 +1620,7 @@ static int snd_emu10k1_fx8010_playback_prepare(struct snd_pcm_substream *substre
        struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number];
        unsigned int i;
        
-       // printk("prepare: etram_pages = 0x%p, dma_area = 0x%x, buffer_size = 0x%x (0x%x)\n", emu->fx8010.etram_pages, runtime->dma_area, runtime->buffer_size, runtime->buffer_size << 2);
+       /* printk("prepare: etram_pages = 0x%p, dma_area = 0x%x, buffer_size = 0x%x (0x%x)\n", emu->fx8010.etram_pages, runtime->dma_area, runtime->buffer_size, runtime->buffer_size << 2); */
        memset(&pcm->pcm_rec, 0, sizeof(pcm->pcm_rec));
        pcm->pcm_rec.hw_buffer_size = pcm->buffer_size * 2; /* byte size */
        pcm->pcm_rec.sw_buffer_size = snd_pcm_lib_buffer_bytes(substream);
index b939e03aaedf8bc2a5902e3f21d262f7de13be44..2c1585991bc810186054fbf2cbe47045091daf92 100644 (file)
@@ -3,6 +3,9 @@
  *                   Creative Labs, Inc.
  *  Routines for control of EMU10K1 chips / proc interface routines
  *
+ *  Copyright (c) by James Courtier-Dutton <James@superbug.co.uk>
+ *     Added EMU 1010 support.
+ *
  *  BUGS:
  *    --
  *
@@ -255,7 +258,7 @@ static void snd_emu10k1_proc_rates_read(struct snd_info_entry *entry,
        unsigned int val, tmp, n;
        val = snd_emu10k1_ptr20_read(emu, CAPTURE_RATE_STATUS, 0);
        tmp = (val >> 16) & 0x8;
-       for (n=0;n<4;n++) {
+       for (n = 0; n < 4; n++) {
                tmp = val >> (16 + (n*4));
                if (tmp & 0x8) snd_iprintf(buffer, "Channel %d: Rate=%d\n", n, samplerate[tmp & 0x7]);
                else snd_iprintf(buffer, "Channel %d: No input\n", n);
@@ -372,6 +375,27 @@ static void snd_emu10k1_proc_voices_read(struct snd_info_entry *entry,
 }
 
 #ifdef CONFIG_SND_DEBUG
+static void snd_emu_proc_emu1010_reg_read(struct snd_info_entry *entry,
+                                    struct snd_info_buffer *buffer)
+{
+       struct snd_emu10k1 *emu = entry->private_data;
+       unsigned long value;
+       unsigned long flags;
+       unsigned long regs;
+       int i;
+       snd_iprintf(buffer, "EMU1010 Registers:\n\n");
+
+       for(i = 0; i < 0x30; i+=1) {
+               spin_lock_irqsave(&emu->emu_lock, flags);
+               regs=i+0x40; /* 0x40 upwards are registers. */
+               outl(regs, emu->port + A_IOCFG);
+               outl(regs | 0x80, emu->port + A_IOCFG);  /* High bit clocks the value into the fpga. */
+               value = inl(emu->port + A_IOCFG);
+               spin_unlock_irqrestore(&emu->emu_lock, flags);
+               snd_iprintf(buffer, "%02X: %08lX, %02lX\n", i, value, (value >> 8) & 0x7f);
+       }
+}
+
 static void snd_emu_proc_io_reg_read(struct snd_info_entry *entry,
                                     struct snd_info_buffer *buffer)
 {
@@ -398,7 +422,7 @@ static void snd_emu_proc_io_reg_write(struct snd_info_entry *entry,
        while (!snd_info_get_line(buffer, line, sizeof(line))) {
                if (sscanf(line, "%x %x", &reg, &val) != 2)
                        continue;
-               if ((reg < 0x40) && (reg >=0) && (val <= 0xffffffff) ) {
+               if ((reg < 0x40) && (reg >= 0) && (val <= 0xffffffff) ) {
                        spin_lock_irqsave(&emu->emu_lock, flags);
                        outl(val, emu->port + (reg & 0xfffffffc));
                        spin_unlock_irqrestore(&emu->emu_lock, flags);
@@ -474,7 +498,7 @@ static void snd_emu_proc_ptr_reg_write(struct snd_info_entry *entry,
        while (!snd_info_get_line(buffer, line, sizeof(line))) {
                if (sscanf(line, "%x %x %x", &reg, &channel_id, &val) != 3)
                        continue;
-               if ((reg < 0xa0) && (reg >=0) && (val <= 0xffffffff) && (channel_id >=0) && (channel_id <= 3) )
+               if ((reg < 0xa0) && (reg >= 0) && (val <= 0xffffffff) && (channel_id >= 0) && (channel_id <= 3) )
                        snd_ptr_write(emu, iobase, reg, channel_id, val);
        }
 }
@@ -531,6 +555,10 @@ int __devinit snd_emu10k1_proc_init(struct snd_emu10k1 * emu)
 {
        struct snd_info_entry *entry;
 #ifdef CONFIG_SND_DEBUG
+       if ((emu->card_capabilities->emu1010) &&
+            snd_card_proc_new(emu->card, "emu1010_regs", &entry)) {
+               snd_info_set_text_ops(entry, emu, snd_emu_proc_emu1010_reg_read);
+       }
        if (! snd_card_proc_new(emu->card, "io_regs", &entry)) {
                snd_info_set_text_ops(entry, emu, snd_emu_proc_io_reg_read);
                entry->c.text.write = snd_emu_proc_io_reg_write;
index 029e7856c43beaa7d171a22696d95410119b7b43..116e1c8d93616bd9df9c6b19452a9e4781f59400 100644 (file)
@@ -30,6 +30,7 @@
 #include <sound/core.h>
 #include <sound/emu10k1.h>
 #include <linux/delay.h>
+#include "p17v.h"
 
 unsigned int snd_emu10k1_ptr_read(struct snd_emu10k1 * emu, unsigned int reg, unsigned int chn)
 {
@@ -167,6 +168,109 @@ int snd_emu10k1_spi_write(struct snd_emu10k1 * emu,
        return 0;
 }
 
+/* The ADC does not support i2c read, so only write is implemented */
+int snd_emu10k1_i2c_write(struct snd_emu10k1 *emu,
+                               u32 reg,
+                               u32 value)
+{
+       u32 tmp;
+       int timeout = 0;
+       int status;
+       int retry;
+       if ((reg > 0x7f) || (value > 0x1ff)) {
+               snd_printk(KERN_ERR "i2c_write: invalid values.\n");
+               return -EINVAL;
+       }
+
+       tmp = reg << 25 | value << 16;
+       // snd_printk("I2C-write:reg=0x%x, value=0x%x\n", reg, value);
+       /* Not sure what this I2C channel controls. */
+       /* snd_emu10k1_ptr_write(emu, P17V_I2C_0, 0, tmp); */
+
+       /* This controls the I2C connected to the WM8775 ADC Codec */
+       snd_emu10k1_ptr20_write(emu, P17V_I2C_1, 0, tmp);
+       tmp = snd_emu10k1_ptr20_read(emu, P17V_I2C_1, 0); /* write post */
+
+       for (retry = 0; retry < 10; retry++) {
+               /* Send the data to i2c */
+               //tmp = snd_emu10k1_ptr_read(emu, P17V_I2C_ADDR, 0);
+               //tmp = tmp & ~(I2C_A_ADC_READ|I2C_A_ADC_LAST|I2C_A_ADC_START|I2C_A_ADC_ADD_MASK);
+               tmp = 0;
+               tmp = tmp | (I2C_A_ADC_LAST|I2C_A_ADC_START|I2C_A_ADC_ADD);
+               snd_emu10k1_ptr20_write(emu, P17V_I2C_ADDR, 0, tmp);
+
+               /* Wait till the transaction ends */
+               while (1) {
+                       udelay(10);
+                       status = snd_emu10k1_ptr20_read(emu, P17V_I2C_ADDR, 0);
+                       // snd_printk("I2C:status=0x%x\n", status);
+                       timeout++;
+                       if ((status & I2C_A_ADC_START) == 0)
+                               break;
+
+                       if (timeout > 1000) {
+                               snd_printk("emu10k1:I2C:timeout status=0x%x\n", status);
+                               break;
+                       }
+               }
+               //Read back and see if the transaction is successful
+               if ((status & I2C_A_ADC_ABORT) == 0)
+                       break;
+       }
+
+       if (retry == 10) {
+               snd_printk(KERN_ERR "Writing to ADC failed!\n");
+               return -EINVAL;
+       }
+    
+       return 0;
+}
+
+int snd_emu1010_fpga_write(struct snd_emu10k1 * emu, int reg, int value)
+{
+       if (reg < 0 || reg > 0x3f)
+               return 1;
+       reg += 0x40; /* 0x40 upwards are registers. */
+       if (value < 0 || value > 0x3f) /* 0 to 0x3f are values */
+               return 1;
+       outl(reg, emu->port + A_IOCFG);
+       udelay(10);
+       outl(reg | 0x80, emu->port + A_IOCFG);  /* High bit clocks the value into the fpga. */
+       udelay(10);
+       outl(value, emu->port + A_IOCFG);
+       udelay(10);
+       outl(value | 0x80 , emu->port + A_IOCFG);  /* High bit clocks the value into the fpga. */
+
+       return 0;
+}
+
+int snd_emu1010_fpga_read(struct snd_emu10k1 * emu, int reg, int *value)
+{
+       if (reg < 0 || reg > 0x3f)
+               return 1;
+       reg += 0x40; /* 0x40 upwards are registers. */
+       outl(reg, emu->port + A_IOCFG);
+       udelay(10);
+       outl(reg | 0x80, emu->port + A_IOCFG);  /* High bit clocks the value into the fpga. */
+       udelay(10);
+       *value = ((inl(emu->port + A_IOCFG) >> 8) & 0x7f);
+
+       return 0;
+}
+
+/* Each Destination has one and only one Source,
+ * but one Source can feed any number of Destinations simultaneously.
+ */
+int snd_emu1010_fpga_link_dst_src_write(struct snd_emu10k1 * emu, int dst, int src)
+{
+       snd_emu1010_fpga_write(emu, 0x00, ((dst >> 8) & 0x3f) );
+       snd_emu1010_fpga_write(emu, 0x01, (dst & 0x3f) );
+       snd_emu1010_fpga_write(emu, 0x02, ((src >> 8) & 0x3f) );
+       snd_emu1010_fpga_write(emu, 0x03, (src & 0x3f) );
+
+       return 0;
+}
+
 void snd_emu10k1_intr_enable(struct snd_emu10k1 *emu, unsigned int intrenb)
 {
        unsigned long flags;
index 4e0f95438f47e3045c2b8e84949fa5b2a3ba01ba..465f8d505329b40f48d0d0c219e189df810532c2 100644 (file)
@@ -253,7 +253,7 @@ static int snd_p16v_pcm_close_playback(struct snd_pcm_substream *substream)
        struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream);
        //struct snd_pcm_runtime *runtime = substream->runtime;
        //struct snd_emu10k1_pcm *epcm = runtime->private_data;
-       emu->p16v_voices[substream->pcm->device - emu->p16v_device_offset].use=0;
+       emu->p16v_voices[substream->pcm->device - emu->p16v_device_offset].use = 0;
        /* FIXME: maybe zero others */
        return 0;
 }
@@ -264,7 +264,7 @@ static int snd_p16v_pcm_close_capture(struct snd_pcm_substream *substream)
        struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream);
        //struct snd_pcm_runtime *runtime = substream->runtime;
        //struct snd_emu10k1_pcm *epcm = runtime->private_data;
-       emu->p16v_capture_voice.use=0;
+       emu->p16v_capture_voice.use = 0;
        /* FIXME: maybe zero others */
        return 0;
 }
@@ -349,7 +349,7 @@ static int snd_p16v_pcm_prepare_playback(struct snd_pcm_substream *substream)
          break;
        }
        /* FIXME: Check emu->buffer.size before actually writing to it. */
-       for(i=0; i < runtime->periods; i++) {
+       for(i = 0; i < runtime->periods; i++) {
                table_base[i*2]=runtime->dma_addr+(i*period_size_bytes);
                table_base[(i*2)+1]=period_size_bytes<<16;
        }
@@ -394,7 +394,7 @@ static int snd_p16v_pcm_prepare_capture(struct snd_pcm_substream *substream)
        /* FIXME: Check emu->buffer.size before actually writing to it. */
        snd_emu10k1_ptr20_write(emu, 0x13, channel, 0);
        snd_emu10k1_ptr20_write(emu, CAPTURE_DMA_ADDR, channel, runtime->dma_addr);
-       snd_emu10k1_ptr20_write(emu, CAPTURE_BUFFER_SIZE, channel, frames_to_bytes(runtime, runtime->buffer_size)<<16); // buffer size in bytes
+       snd_emu10k1_ptr20_write(emu, CAPTURE_BUFFER_SIZE, channel, frames_to_bytes(runtime, runtime->buffer_size) << 16); // buffer size in bytes
        snd_emu10k1_ptr20_write(emu, CAPTURE_POINTER, channel, 0);
        //snd_emu10k1_ptr20_write(emu, CAPTURE_SOURCE, 0x0, 0x333300e4); /* Select MIC or Line in */
        //snd_emu10k1_ptr20_write(emu, EXTENDED_INT_MASK, 0, snd_emu10k1_ptr20_read(emu, EXTENDED_INT_MASK, 0) | (0x110000<<channel));
@@ -437,7 +437,7 @@ static int snd_p16v_pcm_trigger_playback(struct snd_pcm_substream *substream,
         struct snd_pcm_substream *s;
        u32 basic = 0;
        u32 inte = 0;
-       int running=0;
+       int running = 0;
 
        switch (cmd) {
        case SNDRV_PCM_TRIGGER_START:
@@ -445,7 +445,7 @@ static int snd_p16v_pcm_trigger_playback(struct snd_pcm_substream *substream,
                break;
        case SNDRV_PCM_TRIGGER_STOP:
        default:
-               running=0;
+               running = 0;
                break;
        }
         snd_pcm_group_for_each(pos, substream) {
@@ -785,7 +785,7 @@ static int snd_p16v_capture_channel_put(struct snd_kcontrol *kcontrol,
        }
         return change;
 }
-static DECLARE_TLV_DB_SCALE(snd_p16v_db_scale1, -5175, 25, 1);
+static const DECLARE_TLV_DB_SCALE(snd_p16v_db_scale1, -5175, 25, 1);
 
 #define P16V_VOL(xname,xreg,xhl) { \
        .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
index 7ddb5be632cf8ad83a75564c1599470f8e27cfa6..4ef5f68a9cd0654c6a512d297dc3a0c2cc5cd0d0 100644 (file)
 #define P17V_I2C_ADDR          0x3d    /* I2C Address */
 #define P17V_I2C_0             0x3e    /* I2C Data */
 #define P17V_I2C_1             0x3f    /* I2C Data */
+/* I2C values */
+#define I2C_A_ADC_ADD_MASK     0x000000fe      /*The address is a 7 bit address */
+#define I2C_A_ADC_RW_MASK      0x00000001      /*bit mask for R/W */
+#define I2C_A_ADC_TRANS_MASK   0x00000010      /*Bit mask for I2c address DAC value  */
+#define I2C_A_ADC_ABORT_MASK   0x00000020      /*Bit mask for I2C transaction abort flag */
+#define I2C_A_ADC_LAST_MASK    0x00000040      /*Bit mask for Last word transaction */
+#define I2C_A_ADC_BYTE_MASK    0x00000080      /*Bit mask for Byte Mode */
+
+#define I2C_A_ADC_ADD          0x00000034      /*This is the Device address for ADC  */
+#define I2C_A_ADC_READ         0x00000001      /*To perform a read operation */
+#define I2C_A_ADC_START                0x00000100      /*Start I2C transaction */
+#define I2C_A_ADC_ABORT                0x00000200      /*I2C transaction abort */
+#define I2C_A_ADC_LAST         0x00000400      /*I2C last transaction */
+#define I2C_A_ADC_BYTE         0x00000800      /*I2C one byte mode */
+
+#define I2C_D_ADC_REG_MASK     0xfe000000      /*ADC address register */ 
+#define I2C_D_ADC_DAT_MASK     0x01ff0000      /*ADC data register */
+
+#define ADC_TIMEOUT            0x00000007      /*ADC Timeout Clock Disable */
+#define ADC_IFC_CTRL           0x0000000b      /*ADC Interface Control */
+#define ADC_MASTER             0x0000000c      /*ADC Master Mode Control */
+#define ADC_POWER              0x0000000d      /*ADC PowerDown Control */
+#define ADC_ATTEN_ADCL         0x0000000e      /*ADC Attenuation ADCL */
+#define ADC_ATTEN_ADCR         0x0000000f      /*ADC Attenuation ADCR */
+#define ADC_ALC_CTRL1          0x00000010      /*ADC ALC Control 1 */
+#define ADC_ALC_CTRL2          0x00000011      /*ADC ALC Control 2 */
+#define ADC_ALC_CTRL3          0x00000012      /*ADC ALC Control 3 */
+#define ADC_NOISE_CTRL         0x00000013      /*ADC Noise Gate Control */
+#define ADC_LIMIT_CTRL         0x00000014      /*ADC Limiter Control */
+#define ADC_MUX                        0x00000015      /*ADC Mux offset */
+#if 0
+/* FIXME: Not tested yet. */
+#define ADC_GAIN_MASK          0x000000ff      //Mask for ADC Gain
+#define ADC_ZERODB             0x000000cf      //Value to set ADC to 0dB
+#define ADC_MUTE_MASK          0x000000c0      //Mask for ADC mute
+#define ADC_MUTE               0x000000c0      //Value to mute ADC
+#define ADC_OSR                        0x00000008      //Mask for ADC oversample rate select
+#define ADC_TIMEOUT_DISABLE    0x00000008      //Value and mask to disable Timeout clock
+#define ADC_HPF_DISABLE                0x00000100      //Value and mask to disable High pass filter
+#define ADC_TRANWIN_MASK       0x00000070      //Mask for Length of Transient Window
+#endif
+
+#define ADC_MUX_MASK           0x0000000f      //Mask for ADC Mux
+#define ADC_MUX_0              0x00000001      //Value to select Unknown at ADC Mux (Not used)
+#define ADC_MUX_1              0x00000002      //Value to select Unknown at ADC Mux (Not used)
+#define ADC_MUX_2              0x00000004      //Value to select Mic at ADC Mux
+#define ADC_MUX_3              0x00000008      //Value to select Line-In at ADC Mux
 
 #define P17V_START_AUDIO       0x40    /* Start Audio bit */
 /* 41 - 47: Reserved */
index 94eca82dd4fc06914b1b698cfcdbc527b99e2d52..1db50fe61475e8b6596aa69a65451dc9c3c958e2 100644 (file)
@@ -83,7 +83,7 @@ static int voice_alloc(struct snd_emu10k1 *emu, int type, int number,
        if (first_voice == last_voice)
                return -ENOMEM;
        
-       for (i=0; i < number; i++) {
+       for (i = 0; i < number; i++) {
                voice = &emu->voices[(first_voice + i) % NUM_G];
                // printk("voice alloc - %i, %i of %i\n", voice->number, idx-first_voice+1, number);
                voice->use = 1;
index a84f6b21024fb368e18eee643be6b47b81886873..425b167522d56a087279c18797b5be87df2a5061 100644 (file)
@@ -413,8 +413,6 @@ struct ensoniq {
        } u;
 
        struct pci_dev *pci;
-       unsigned short subsystem_vendor_id;
-       unsigned short subsystem_device_id;
        struct snd_card *card;
        struct snd_pcm *pcm1;   /* DAC1/ADC PCM */
        struct snd_pcm *pcm2;   /* DAC2 PCM */
@@ -1607,11 +1605,26 @@ static void snd_ensoniq_mixer_free_ac97(struct snd_ac97 *ac97)
        ensoniq->u.es1371.ac97 = NULL;
 }
 
-static struct {
+struct es1371_quirk {
        unsigned short vid;             /* vendor ID */
        unsigned short did;             /* device ID */
        unsigned char rev;              /* revision */
-} es1371_spdif_present[] __devinitdata = {
+};
+
+static int __devinit es1371_quirk_lookup(struct ensoniq *ensoniq,
+                                        struct es1371_quirk *list)
+{
+       while (list->vid != (unsigned short)PCI_ANY_ID) {
+               if (ensoniq->pci->vendor == list->vid &&
+                   ensoniq->pci->device == list->did &&
+                   ensoniq->rev == list->rev)
+                       return 1;
+               list++;
+       }
+       return 0;
+}
+
+static struct es1371_quirk es1371_spdif_present[] __devinitdata = {
        { .vid = PCI_VENDOR_ID_ENSONIQ, .did = PCI_DEVICE_ID_ENSONIQ_CT5880, .rev = CT5880REV_CT5880_C },
        { .vid = PCI_VENDOR_ID_ENSONIQ, .did = PCI_DEVICE_ID_ENSONIQ_CT5880, .rev = CT5880REV_CT5880_D },
        { .vid = PCI_VENDOR_ID_ENSONIQ, .did = PCI_DEVICE_ID_ENSONIQ_CT5880, .rev = CT5880REV_CT5880_E },
@@ -1620,12 +1633,19 @@ static struct {
        { .vid = PCI_ANY_ID, .did = PCI_ANY_ID }
 };
 
-static int snd_ensoniq_1371_mixer(struct ensoniq * ensoniq, int has_spdif, int has_line)
+static struct snd_pci_quirk ens1373_line_quirk[] __devinitdata = {
+       SND_PCI_QUIRK_ID(0x1274, 0x2000), /* GA-7DXR */
+       SND_PCI_QUIRK_ID(0x1458, 0xa000), /* GA-8IEXP */
+       { } /* end */
+};
+
+static int __devinit snd_ensoniq_1371_mixer(struct ensoniq *ensoniq,
+                                           int has_spdif, int has_line)
 {
        struct snd_card *card = ensoniq->card;
        struct snd_ac97_bus *pbus;
        struct snd_ac97_template ac97;
-       int err, idx;
+       int err;
        static struct snd_ac97_bus_ops ops = {
                .write = snd_es1371_codec_write,
                .read = snd_es1371_codec_read,
@@ -1641,33 +1661,28 @@ static int snd_ensoniq_1371_mixer(struct ensoniq * ensoniq, int has_spdif, int h
        ac97.scaps = AC97_SCAP_AUDIO;
        if ((err = snd_ac97_mixer(pbus, &ac97, &ensoniq->u.es1371.ac97)) < 0)
                return err;
-       for (idx = 0; es1371_spdif_present[idx].vid != (unsigned short)PCI_ANY_ID; idx++)
-               if ((ensoniq->pci->vendor == es1371_spdif_present[idx].vid &&
-                    ensoniq->pci->device == es1371_spdif_present[idx].did &&
-                    ensoniq->rev == es1371_spdif_present[idx].rev) || has_spdif > 0) {
-                       struct snd_kcontrol *kctl;
-                       int i, index = 0; 
-
-                        if (has_spdif < 0)
-                                break;
-
-                       ensoniq->spdif_default = ensoniq->spdif_stream =
-                               SNDRV_PCM_DEFAULT_CON_SPDIF;
-                       outl(ensoniq->spdif_default, ES_REG(ensoniq, CHANNEL_STATUS));
-
-                       if (ensoniq->u.es1371.ac97->ext_id & AC97_EI_SPDIF)
-                               index++;
-
-                       for (i = 0; i < (int)ARRAY_SIZE(snd_es1371_mixer_spdif); i++) {
-                               kctl = snd_ctl_new1(&snd_es1371_mixer_spdif[i], ensoniq);
-                               if (! kctl)
-                                       return -ENOMEM;
-                               kctl->id.index = index;
-                               if ((err = snd_ctl_add(card, kctl)) < 0)
-                                       return err;
-                       }
-                       break;
+       if (has_spdif > 0 ||
+           (!has_spdif && es1371_quirk_lookup(ensoniq, es1371_spdif_present))) {
+               struct snd_kcontrol *kctl;
+               int i, index = 0;
+
+               ensoniq->spdif_default = ensoniq->spdif_stream =
+                       SNDRV_PCM_DEFAULT_CON_SPDIF;
+               outl(ensoniq->spdif_default, ES_REG(ensoniq, CHANNEL_STATUS));
+
+               if (ensoniq->u.es1371.ac97->ext_id & AC97_EI_SPDIF)
+                       index++;
+
+               for (i = 0; i < ARRAY_SIZE(snd_es1371_mixer_spdif); i++) {
+                       kctl = snd_ctl_new1(&snd_es1371_mixer_spdif[i], ensoniq);
+                       if (!kctl)
+                               return -ENOMEM;
+                       kctl->id.index = index;
+                       err = snd_ctl_add(card, kctl);
+                       if (err < 0)
+                               return err;
                }
+       }
        if (ensoniq->u.es1371.ac97->ext_id & AC97_EI_SDAC) {
                /* mirror rear to front speakers */
                ensoniq->cssr &= ~(ES_1373_REAR_BIT27|ES_1373_REAR_BIT24);
@@ -1676,12 +1691,10 @@ static int snd_ensoniq_1371_mixer(struct ensoniq * ensoniq, int has_spdif, int h
                if (err < 0)
                        return err;
        }
-       if (((ensoniq->subsystem_vendor_id == 0x1274) &&
-           (ensoniq->subsystem_device_id == 0x2000)) || /* GA-7DXR */
-           ((ensoniq->subsystem_vendor_id == 0x1458) &&
-           (ensoniq->subsystem_device_id == 0xa000)) || /* GA-8IEXP */
-           has_line > 0) {
-                err = snd_ctl_add(card, snd_ctl_new1(&snd_ens1373_line, ensoniq));
+       if (has_line > 0 ||
+           snd_pci_quirk_lookup(ensoniq->pci, ens1373_line_quirk)) {
+                err = snd_ctl_add(card, snd_ctl_new1(&snd_ens1373_line,
+                                                     ensoniq));
                 if (err < 0)
                         return err;
        }
@@ -1956,21 +1969,15 @@ static int snd_ensoniq_dev_free(struct snd_device *device)
 }
 
 #ifdef CHIP1371
-static struct {
-       unsigned short svid;            /* subsystem vendor ID */
-       unsigned short sdid;            /* subsystem device ID */
-} es1371_amplifier_hack[] = {
-       { .svid = 0x107b, .sdid = 0x2150 },     /* Gateway Solo 2150 */
-       { .svid = 0x13bd, .sdid = 0x100c },     /* EV1938 on Mebius PC-MJ100V */
-       { .svid = 0x1102, .sdid = 0x5938 },     /* Targa Xtender300 */
-       { .svid = 0x1102, .sdid = 0x8938 },     /* IPC Topnote G notebook */
-       { .svid = PCI_ANY_ID, .sdid = PCI_ANY_ID }
+static struct snd_pci_quirk es1371_amplifier_hack[] __devinitdata = {
+       SND_PCI_QUIRK_ID(0x107b, 0x2150),       /* Gateway Solo 2150 */
+       SND_PCI_QUIRK_ID(0x13bd, 0x100c),       /* EV1938 on Mebius PC-MJ100V */
+       SND_PCI_QUIRK_ID(0x1102, 0x5938),       /* Targa Xtender300 */
+       SND_PCI_QUIRK_ID(0x1102, 0x8938),       /* IPC Topnote G notebook */
+       { } /* end */
 };
-static struct {
-       unsigned short vid;             /* vendor ID */
-       unsigned short did;             /* device ID */
-       unsigned char rev;              /* revision */
-} es1371_ac97_reset_hack[] = {
+
+static struct es1371_quirk es1371_ac97_reset_hack[] = {
        { .vid = PCI_VENDOR_ID_ENSONIQ, .did = PCI_DEVICE_ID_ENSONIQ_CT5880, .rev = CT5880REV_CT5880_C },
        { .vid = PCI_VENDOR_ID_ENSONIQ, .did = PCI_DEVICE_ID_ENSONIQ_CT5880, .rev = CT5880REV_CT5880_D },
        { .vid = PCI_VENDOR_ID_ENSONIQ, .did = PCI_DEVICE_ID_ENSONIQ_CT5880, .rev = CT5880REV_CT5880_E },
@@ -1984,7 +1991,6 @@ static void snd_ensoniq_chip_init(struct ensoniq *ensoniq)
 {
 #ifdef CHIP1371
        int idx;
-       struct pci_dev *pci = ensoniq->pci;
 #endif
        /* this code was part of snd_ensoniq_create before intruduction
          * of suspend/resume
@@ -1999,16 +2005,12 @@ static void snd_ensoniq_chip_init(struct ensoniq *ensoniq)
        outl(ensoniq->ctrl, ES_REG(ensoniq, CONTROL));
        outl(ensoniq->sctrl, ES_REG(ensoniq, SERIAL));
        outl(0, ES_REG(ensoniq, 1371_LEGACY));
-       for (idx = 0; es1371_ac97_reset_hack[idx].vid != (unsigned short)PCI_ANY_ID; idx++)
-               if (pci->vendor == es1371_ac97_reset_hack[idx].vid &&
-                   pci->device == es1371_ac97_reset_hack[idx].did &&
-                   ensoniq->rev == es1371_ac97_reset_hack[idx].rev) {
-                       outl(ensoniq->cssr, ES_REG(ensoniq, STATUS));
-                       /* need to delay around 20ms(bleech) to give
-                       some CODECs enough time to wakeup */
-                       msleep(20);
-                       break;
-               }
+       if (es1371_quirk_lookup(ensoniq, es1371_ac97_reset_hack)) {
+           outl(ensoniq->cssr, ES_REG(ensoniq, STATUS));
+           /* need to delay around 20ms(bleech) to give
+              some CODECs enough time to wakeup */
+           msleep(20);
+       }
        /* AC'97 warm reset to start the bitclk */
        outl(ensoniq->ctrl | ES_1371_SYNC_RES, ES_REG(ensoniq, CONTROL));
        inl(ES_REG(ensoniq, CONTROL));
@@ -2112,11 +2114,7 @@ static int __devinit snd_ensoniq_create(struct snd_card *card,
                                     struct ensoniq ** rensoniq)
 {
        struct ensoniq *ensoniq;
-       unsigned short cmdw;
        unsigned char cmdb;
-#ifdef CHIP1371
-       int idx;
-#endif
        int err;
        static struct snd_device_ops ops = {
                .dev_free =     snd_ensoniq_dev_free,
@@ -2159,10 +2157,6 @@ static int __devinit snd_ensoniq_create(struct snd_card *card,
        pci_set_master(pci);
        pci_read_config_byte(pci, PCI_REVISION_ID, &cmdb);
        ensoniq->rev = cmdb;
-       pci_read_config_word(pci, PCI_SUBSYSTEM_VENDOR_ID, &cmdw);
-       ensoniq->subsystem_vendor_id = cmdw;
-       pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &cmdw);
-       ensoniq->subsystem_device_id = cmdw;
 #ifdef CHIP1370
 #if 0
        ensoniq->ctrl = ES_1370_CDC_EN | ES_1370_SERR_DISABLE |
@@ -2175,19 +2169,11 @@ static int __devinit snd_ensoniq_create(struct snd_card *card,
        ensoniq->ctrl = 0;
        ensoniq->sctrl = 0;
        ensoniq->cssr = 0;
-       for (idx = 0; es1371_amplifier_hack[idx].svid != (unsigned short)PCI_ANY_ID; idx++)
-               if (ensoniq->subsystem_vendor_id == es1371_amplifier_hack[idx].svid &&
-                   ensoniq->subsystem_device_id == es1371_amplifier_hack[idx].sdid) {
-                       ensoniq->ctrl |= ES_1371_GPIO_OUT(1);   /* turn amplifier on */
-                       break;
-               }
-       for (idx = 0; es1371_ac97_reset_hack[idx].vid != (unsigned short)PCI_ANY_ID; idx++)
-               if (pci->vendor == es1371_ac97_reset_hack[idx].vid &&
-                   pci->device == es1371_ac97_reset_hack[idx].did &&
-                   ensoniq->rev == es1371_ac97_reset_hack[idx].rev) {
-                       ensoniq->cssr |= ES_1371_ST_AC97_RST;
-                       break;
-               }
+       if (snd_pci_quirk_lookup(pci, es1371_amplifier_hack))
+               ensoniq->ctrl |= ES_1371_GPIO_OUT(1);   /* turn amplifier on */
+
+       if (es1371_quirk_lookup(ensoniq, es1371_ac97_reset_hack))
+               ensoniq->cssr |= ES_1371_ST_AC97_RST;
 #endif
 
        snd_ensoniq_chip_init(ensoniq);
index 66ac26c5a2403027bf724dc2e095a83f41768343..fec29a1089451266133fd1547efa1542aba7071f 100644 (file)
@@ -1344,7 +1344,7 @@ static unsigned int db_scale_line[] = {
        8, 15, TLV_DB_SCALE_ITEM(-750, 150, 0),
 };
 
-static DECLARE_TLV_DB_SCALE(db_scale_capture, 0, 150, 0);
+static const DECLARE_TLV_DB_SCALE(db_scale_capture, 0, 150, 0);
 
 static struct snd_kcontrol_new snd_es1938_controls[] = {
 ES1938_DOUBLE_TLV("Master Playback Volume", 0, 0x60, 0x62, 0, 0, 63, 0,
index b7b361ce3a93bb6270807fc75b0ea31db10aa09a..6dc578bbeec962245b2b844253eee21ca01a7f2a 100644 (file)
@@ -1157,7 +1157,7 @@ static int snd_fm801_put_mux(struct snd_kcontrol *kcontrol,
        return snd_fm801_update_bits(chip, FM801_REC_SRC, 7, val);
 }
 
-static DECLARE_TLV_DB_SCALE(db_scale_dsp, -3450, 150, 0);
+static const DECLARE_TLV_DB_SCALE(db_scale_dsp, -3450, 150, 0);
 
 #define FM801_CONTROLS ARRAY_SIZE(snd_fm801_controls)
 
index dbacba6177db8efef14012d2b265ee96baa709d4..60d7b05a204a28a26c8cf2dab727454e9b276533 100644 (file)
@@ -1,5 +1,14 @@
 snd-hda-intel-objs := hda_intel.o
-snd-hda-codec-objs := hda_codec.o hda_generic.o patch_realtek.o patch_cmedia.o patch_analog.o patch_sigmatel.o patch_si3054.o patch_atihdmi.o
+snd-hda-codec-objs := hda_codec.o \
+       hda_generic.o \
+       patch_realtek.o \
+       patch_cmedia.o \
+       patch_analog.o \
+       patch_sigmatel.o \
+       patch_si3054.o \
+       patch_atihdmi.o \
+       patch_conexant.o \
+       patch_via.o
 ifdef CONFIG_PROC_FS
 snd-hda-codec-objs += hda_proc.o
 endif
index 18bbc87e376f167c5beb9c823ab2ffb3cb0d4f0a..8f34fb4479837087b177c6f0c15d6eeb29caf300 100644 (file)
@@ -52,6 +52,7 @@ struct hda_vendor_id {
 static struct hda_vendor_id hda_vendor_ids[] = {
        { 0x10ec, "Realtek" },
        { 0x1057, "Motorola" },
+       { 0x1106, "VIA" },
        { 0x11d4, "Analog Devices" },
        { 0x13f6, "C-Media" },
        { 0x14f1, "Conexant" },
@@ -262,7 +263,7 @@ int snd_hda_queue_unsol_event(struct hda_bus *bus, u32 res, u32 res_ex)
        unsol->queue[wp] = res;
        unsol->queue[wp + 1] = res_ex;
 
-       queue_work(unsol->workq, &unsol->work);
+       schedule_work(&unsol->work);
 
        return 0;
 }
@@ -309,12 +310,6 @@ static int init_unsol_queue(struct hda_bus *bus)
                snd_printk(KERN_ERR "hda_codec: can't allocate unsolicited queue\n");
                return -ENOMEM;
        }
-       unsol->workq = create_singlethread_workqueue("hda_codec");
-       if (! unsol->workq) {
-               snd_printk(KERN_ERR "hda_codec: can't create workqueue\n");
-               kfree(unsol);
-               return -ENOMEM;
-       }
        INIT_WORK(&unsol->work, process_unsol_events);
        unsol->bus = bus;
        bus->unsol = unsol;
@@ -333,7 +328,7 @@ static int snd_hda_bus_free(struct hda_bus *bus)
        if (! bus)
                return 0;
        if (bus->unsol) {
-               destroy_workqueue(bus->unsol->workq);
+               flush_scheduled_work();
                kfree(bus->unsol);
        }
        list_for_each_safe(p, n, &bus->codec_list) {
@@ -1714,6 +1709,8 @@ EXPORT_SYMBOL(snd_hda_build_pcms);
 /**
  * snd_hda_check_board_config - compare the current codec with the config table
  * @codec: the HDA codec
+ * @num_configs: number of config enums
+ * @models: array of model name strings
  * @tbl: configuration table, terminated by null entries
  *
  * Compares the modelname or PCI subsystem id of the current codec with the
@@ -1722,33 +1719,44 @@ EXPORT_SYMBOL(snd_hda_build_pcms);
  *
  * If no entries are matching, the function returns a negative value.
  */
-int snd_hda_check_board_config(struct hda_codec *codec, const struct hda_board_config *tbl)
-{
-       const struct hda_board_config *c;
-
-       if (codec->bus->modelname) {
-               for (c = tbl; c->modelname || c->pci_subvendor; c++) {
-                       if (c->modelname &&
-                           ! strcmp(codec->bus->modelname, c->modelname)) {
-                               snd_printd(KERN_INFO "hda_codec: model '%s' is selected\n", c->modelname);
-                               return c->config;
+int snd_hda_check_board_config(struct hda_codec *codec,
+                              int num_configs, const char **models,
+                              const struct snd_pci_quirk *tbl)
+{
+       if (codec->bus->modelname && models) {
+               int i;
+               for (i = 0; i < num_configs; i++) {
+                       if (models[i] &&
+                           !strcmp(codec->bus->modelname, models[i])) {
+                               snd_printd(KERN_INFO "hda_codec: model '%s' is "
+                                          "selected\n", models[i]);
+                               return i;
                        }
                }
        }
 
-       if (codec->bus->pci) {
-               u16 subsystem_vendor, subsystem_device;
-               pci_read_config_word(codec->bus->pci, PCI_SUBSYSTEM_VENDOR_ID, &subsystem_vendor);
-               pci_read_config_word(codec->bus->pci, PCI_SUBSYSTEM_ID, &subsystem_device);
-               for (c = tbl; c->modelname || c->pci_subvendor; c++) {
-                       if (c->pci_subvendor == subsystem_vendor &&
-                           (! c->pci_subdevice /* all match */||
-                            (c->pci_subdevice == subsystem_device))) {
-                               snd_printdd(KERN_INFO "hda_codec: PCI %x:%x, codec config %d is selected\n",
-                                           subsystem_vendor, subsystem_device, c->config);
-                               return c->config;
-                       }
+       if (!codec->bus->pci || !tbl)
+               return -1;
+
+       tbl = snd_pci_quirk_lookup(codec->bus->pci, tbl);
+       if (!tbl)
+               return -1;
+       if (tbl->value >= 0 && tbl->value < num_configs) {
+#ifdef CONFIG_SND_DEBUG_DETECT
+               char tmp[10];
+               const char *model = NULL;
+               if (models)
+                       model = models[tbl->value];
+               if (!model) {
+                       sprintf(tmp, "#%d", tbl->value);
+                       model = tmp;
                }
+               snd_printdd(KERN_INFO "hda_codec: model '%s' is selected "
+                           "for config %x:%x (%s)\n",
+                           model, tbl->subvendor, tbl->subdevice,
+                           (tbl->name ? tbl->name : "Unknown device"));
+#endif
+               return tbl->value;
        }
        return -1;
 }
index 1a7e82104bb91f34a93bcfed92247a1b5ecd5bee..b9a8e238b0a882bdc58071f43652294f939b73e8 100644 (file)
@@ -199,7 +199,7 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };
 
 /* STATESTS int mask: SD2,SD1,SD0 */
 #define STATESTS_INT_MASK      0x07
-#define AZX_MAX_CODECS         4
+#define AZX_MAX_CODECS         3
 
 /* SD_CTL bits */
 #define SD_CTL_STREAM_RESET    0x01    /* stream reset bit */
@@ -1285,7 +1285,7 @@ static int __devinit create_codec_pcm(struct azx *chip, struct hda_codec *codec,
                snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &azx_pcm_ops);
        snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
                                              snd_dma_pci_data(chip->pci),
-                                             1024 * 64, 1024 * 128);
+                                             1024 * 64, 1024 * 1024);
        chip->pcm[pcm_dev] = pcm;
        if (chip->pcm_devs < pcm_dev + 1)
                chip->pcm_devs = pcm_dev + 1;
@@ -1391,6 +1391,7 @@ static int azx_acquire_irq(struct azx *chip, int do_disconnect)
                return -1;
        }
        chip->irq = chip->pci->irq;
+       pci_intx(chip->pci, !chip->msi);
        return 0;
 }
 
@@ -1501,6 +1502,31 @@ static int azx_dev_free(struct snd_device *device)
        return azx_free(device->device_data);
 }
 
+/*
+ * white/black-listing for position_fix
+ */
+static const struct snd_pci_quirk position_fix_list[] __devinitdata = {
+       SND_PCI_QUIRK(0x1028, 0x01cc, "Dell D820", POS_FIX_NONE),
+       {}
+};
+
+static int __devinit check_position_fix(struct azx *chip, int fix)
+{
+       const struct snd_pci_quirk *q;
+
+       if (fix == POS_FIX_AUTO) {
+               q = snd_pci_quirk_lookup(chip->pci, position_fix_list);
+               if (q) {
+                       snd_printdd(KERN_INFO
+                                   "hda_intel: position_fix set to %d "
+                                   "for device %04x:%04x\n",
+                                   q->value, q->subvendor, q->subdevice);
+                       return q->value;
+               }
+       }
+       return fix;
+}
+
 /*
  * constructor
  */
@@ -1535,7 +1561,8 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci,
        chip->driver_type = driver_type;
        chip->msi = enable_msi;
 
-       chip->position_fix = position_fix;
+       chip->position_fix = check_position_fix(chip, position_fix);
+
        chip->single_cmd = single_cmd;
 
 #if BITS_PER_LONG != 64
index 9ca1baf860bd579ffd64321d2efe5d7ecce8e599..39718d6cdadd381435a149ecc6eb0ff62e28c8fc 100644 (file)
@@ -173,14 +173,9 @@ static inline int snd_hda_codec_proc_new(struct hda_codec *codec) { return 0; }
 /*
  * Misc
  */
-struct hda_board_config {
-       const char *modelname;
-       int config;
-       unsigned short pci_subvendor;
-       unsigned short pci_subdevice;
-};
-
-int snd_hda_check_board_config(struct hda_codec *codec, const struct hda_board_config *tbl);
+int snd_hda_check_board_config(struct hda_codec *codec, int num_configs,
+                              const char **modelnames,
+                              const struct snd_pci_quirk *pci_list);
 int snd_hda_add_new_ctls(struct hda_codec *codec, struct snd_kcontrol_new *knew);
 
 /*
@@ -204,7 +199,6 @@ struct hda_bus_unsolicited {
        unsigned int rp, wp;
 
        /* workqueue */
-       struct workqueue_struct *workq;
        struct work_struct work;
        struct hda_bus *bus;
 };
index 0b668793face2af3a04e48e26b0d3f95b1f2b143..9f9e9ae44a9d89bb62b76410781972fcff53d11c 100644 (file)
@@ -14,6 +14,10 @@ extern struct hda_codec_preset snd_hda_preset_sigmatel[];
 extern struct hda_codec_preset snd_hda_preset_si3054[];
 /* ATI HDMI codecs */
 extern struct hda_codec_preset snd_hda_preset_atihdmi[];
+/* Conexant audio codec */
+extern struct hda_codec_preset snd_hda_preset_conexant[];
+/* VIA codecs */
+extern struct hda_codec_preset snd_hda_preset_via[];
 
 static const struct hda_codec_preset *hda_preset_tables[] = {
        snd_hda_preset_realtek,
@@ -22,5 +26,7 @@ static const struct hda_codec_preset *hda_preset_tables[] = {
        snd_hda_preset_sigmatel,
        snd_hda_preset_si3054,
        snd_hda_preset_atihdmi,
+       snd_hda_preset_conexant,
+       snd_hda_preset_via,
        NULL
 };
index 076365bc10e970706db63bbf99f52303347664fe..38977bce70e2f6f0d33aab76923087068d6de66e 100644 (file)
@@ -782,54 +782,63 @@ static struct hda_channel_mode ad1986a_modes[3] = {
 
 /* eapd initialization */
 static struct hda_verb ad1986a_eapd_init_verbs[] = {
-       {0x1b, AC_VERB_SET_EAPD_BTLENABLE, 0x00},
+       {0x1b, AC_VERB_SET_EAPD_BTLENABLE, 0x00 },
        {}
 };
 
+/* Ultra initialization */
+static struct hda_verb ad1986a_ultra_init[] = {
+       /* eapd initialization */
+       { 0x1b, AC_VERB_SET_EAPD_BTLENABLE, 0x00 },
+       /* CLFE -> Mic in */
+       { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2 },
+       { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
+       { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
+       { } /* end */
+};
+
 /* models */
-enum { AD1986A_6STACK, AD1986A_3STACK, AD1986A_LAPTOP, AD1986A_LAPTOP_EAPD };
-
-static struct hda_board_config ad1986a_cfg_tbl[] = {
-       { .modelname = "6stack",        .config = AD1986A_6STACK },
-       { .modelname = "3stack",        .config = AD1986A_3STACK },
-       { .pci_subvendor = 0x10de, .pci_subdevice = 0xcb84,
-         .config = AD1986A_3STACK }, /* ASUS A8N-VM CSM */
-       { .pci_subvendor = 0x1043, .pci_subdevice = 0x817f,
-         .config = AD1986A_3STACK }, /* ASUS P5P-L2 */
-       { .pci_subvendor = 0x1043, .pci_subdevice = 0x81b3,
-         .config = AD1986A_3STACK }, /* ASUS P5RD2-VM / P5GPL-X SE */
-       { .pci_subvendor = 0x1043, .pci_subdevice = 0x81cb,
-         .config = AD1986A_3STACK }, /* ASUS M2NPV-VM */
-       { .modelname = "laptop",        .config = AD1986A_LAPTOP },
-       { .pci_subvendor = 0x144d, .pci_subdevice = 0xc01e,
-         .config = AD1986A_LAPTOP }, /* FSC V2060 */
-       { .pci_subvendor = 0x17c0, .pci_subdevice = 0x2017,
-         .config = AD1986A_LAPTOP }, /* Samsung M50 */
-       { .pci_subvendor = 0x1043, .pci_subdevice = 0x818f,
-         .config = AD1986A_LAPTOP }, /* ASUS P5GV-MX */
-       { .modelname = "laptop-eapd",   .config = AD1986A_LAPTOP_EAPD },
-       { .pci_subvendor = 0x144d, .pci_subdevice = 0xc023,
-         .config = AD1986A_LAPTOP_EAPD }, /* Samsung X60 Chane */
-       { .pci_subvendor = 0x144d, .pci_subdevice = 0xc024,
-         .config = AD1986A_LAPTOP_EAPD }, /* Samsung R65-T2300 Charis */
-       { .pci_subvendor = 0x144d, .pci_subdevice = 0xc026,
-         .config = AD1986A_LAPTOP_EAPD }, /* Samsung X11-T2300 Culesa */
-       { .pci_subvendor = 0x1043, .pci_subdevice = 0x1153,
-         .config = AD1986A_LAPTOP_EAPD }, /* ASUS M9 */
-       { .pci_subvendor = 0x1043, .pci_subdevice = 0x1213,
-         .config = AD1986A_LAPTOP_EAPD }, /* ASUS A6J */
-       { .pci_subvendor = 0x1043, .pci_subdevice = 0x11f7,
-         .config = AD1986A_LAPTOP_EAPD }, /* ASUS U5A */
-       { .pci_subvendor = 0x1043, .pci_subdevice = 0x1263,
-         .config = AD1986A_LAPTOP_EAPD }, /* ASUS U5F */
-       { .pci_subvendor = 0x1043, .pci_subdevice = 0x1297,
-         .config = AD1986A_LAPTOP_EAPD }, /* ASUS Z62F */
-       { .pci_subvendor = 0x1043, .pci_subdevice = 0x12b3,
-         .config = AD1986A_LAPTOP_EAPD }, /* ASUS V1j */
-       { .pci_subvendor = 0x103c, .pci_subdevice = 0x30af,
-         .config = AD1986A_LAPTOP_EAPD }, /* HP Compaq Presario B2800 */
-       { .pci_subvendor = 0x17aa, .pci_subdevice = 0x2066,
-         .config = AD1986A_LAPTOP_EAPD }, /* Lenovo 3000 N100-07684JU */
+enum {
+       AD1986A_6STACK,
+       AD1986A_3STACK,
+       AD1986A_LAPTOP,
+       AD1986A_LAPTOP_EAPD,
+       AD1986A_ULTRA,
+       AD1986A_MODELS
+};
+
+static const char *ad1986a_models[AD1986A_MODELS] = {
+       [AD1986A_6STACK]        = "6stack",
+       [AD1986A_3STACK]        = "3stack",
+       [AD1986A_LAPTOP]        = "laptop",
+       [AD1986A_LAPTOP_EAPD]   = "laptop-eapd",
+       [AD1986A_ULTRA]         = "ultra",
+};
+
+static struct snd_pci_quirk ad1986a_cfg_tbl[] = {
+       SND_PCI_QUIRK(0x103c, 0x30af, "HP B2800", AD1986A_LAPTOP_EAPD),
+       SND_PCI_QUIRK(0x10de, 0xcb84, "ASUS A8N-VM", AD1986A_3STACK),
+       SND_PCI_QUIRK(0x1043, 0x1153, "ASUS M9", AD1986A_LAPTOP_EAPD),
+       SND_PCI_QUIRK(0x1043, 0x1213, "ASUS A6J", AD1986A_LAPTOP_EAPD),
+       SND_PCI_QUIRK(0x1043, 0x11f7, "ASUS U5A", AD1986A_LAPTOP_EAPD),
+       SND_PCI_QUIRK(0x1043, 0x1263, "ASUS U5F", AD1986A_LAPTOP_EAPD),
+       SND_PCI_QUIRK(0x1043, 0x1297, "ASUS Z62F", AD1986A_LAPTOP_EAPD),
+       SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS V1j", AD1986A_LAPTOP_EAPD),
+       SND_PCI_QUIRK(0x1043, 0x1302, "ASUS W3j", AD1986A_LAPTOP_EAPD),
+       SND_PCI_QUIRK(0x1043, 0x817f, "ASUS P5", AD1986A_3STACK),
+       SND_PCI_QUIRK(0x1043, 0x818f, "ASUS P5", AD1986A_LAPTOP),
+       SND_PCI_QUIRK(0x1043, 0x81b3, "ASUS P5", AD1986A_3STACK),
+       SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS M2N", AD1986A_3STACK),
+       SND_PCI_QUIRK(0x1043, 0x8234, "ASUS M2N", AD1986A_3STACK),
+       SND_PCI_QUIRK(0x144d, 0xc01e, "FSC V2060", AD1986A_LAPTOP),
+       SND_PCI_QUIRK(0x144d, 0xc023, "Samsung X60", AD1986A_LAPTOP_EAPD),
+       SND_PCI_QUIRK(0x144d, 0xc024, "Samsung R65", AD1986A_LAPTOP_EAPD),
+       SND_PCI_QUIRK(0x144d, 0xc026, "Samsung X11", AD1986A_LAPTOP_EAPD),
+       SND_PCI_QUIRK(0x144d, 0xc504, "Samsung Q35", AD1986A_3STACK),
+       SND_PCI_QUIRK(0x144d, 0xc027, "Samsung Q1", AD1986A_ULTRA),
+       SND_PCI_QUIRK(0x17aa, 0x1017, "Lenovo A60", AD1986A_3STACK),
+       SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo N100", AD1986A_LAPTOP_EAPD),
+       SND_PCI_QUIRK(0x17c0, 0x2017, "Samsung M50", AD1986A_LAPTOP),
        {}
 };
 
@@ -861,7 +870,9 @@ static int patch_ad1986a(struct hda_codec *codec)
        codec->patch_ops = ad198x_patch_ops;
 
        /* override some parameters */
-       board_config = snd_hda_check_board_config(codec, ad1986a_cfg_tbl);
+       board_config = snd_hda_check_board_config(codec, AD1986A_MODELS,
+                                                 ad1986a_models,
+                                                 ad1986a_cfg_tbl);
        switch (board_config) {
        case AD1986A_3STACK:
                spec->num_mixers = 2;
@@ -891,6 +902,15 @@ static int patch_ad1986a(struct hda_codec *codec)
                spec->multiout.dig_out_nid = 0;
                spec->input_mux = &ad1986a_laptop_eapd_capture_source;
                break;
+       case AD1986A_ULTRA:
+               spec->mixers[0] = ad1986a_laptop_eapd_mixers;
+               spec->num_init_verbs = 2;
+               spec->init_verbs[1] = ad1986a_ultra_init;
+               spec->multiout.max_channels = 2;
+               spec->multiout.num_dacs = 1;
+               spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
+               spec->multiout.dig_out_nid = 0;
+               break;
        }
 
        return 0;
@@ -1391,20 +1411,27 @@ static struct hda_input_mux ad1981_thinkpad_capture_source = {
 };
 
 /* models */
-enum { AD1981_BASIC, AD1981_HP, AD1981_THINKPAD };
+enum {
+       AD1981_BASIC,
+       AD1981_HP,
+       AD1981_THINKPAD,
+       AD1981_MODELS
+};
+
+static const char *ad1981_models[AD1981_MODELS] = {
+       [AD1981_HP]             = "hp",
+       [AD1981_THINKPAD]       = "thinkpad",
+       [AD1981_BASIC]          = "basic",
+};
 
-static struct hda_board_config ad1981_cfg_tbl[] = {
-       { .modelname = "hp", .config = AD1981_HP },
+static struct snd_pci_quirk ad1981_cfg_tbl[] = {
        /* All HP models */
-       { .pci_subvendor = 0x103c, .config = AD1981_HP },
-       { .pci_subvendor = 0x30b0, .pci_subdevice = 0x103c,
-         .config = AD1981_HP }, /* HP nx6320 (reversed SSID, H/W bug) */
-       { .modelname = "thinkpad", .config = AD1981_THINKPAD },
+       SND_PCI_QUIRK(0x103c, 0, "HP nx", AD1981_HP),
+       /* HP nx6320 (reversed SSID, H/W bug) */
+       SND_PCI_QUIRK(0x30b0, 0x103c, "HP nx6320", AD1981_HP),
        /* Lenovo Thinkpad T60/X60/Z6xx */
-       { .pci_subvendor = 0x17aa, .config = AD1981_THINKPAD },
-       { .pci_subvendor = 0x1014, .pci_subdevice = 0x0597,
-         .config = AD1981_THINKPAD }, /* Z60m/t */
-       { .modelname = "basic", .config = AD1981_BASIC },
+       SND_PCI_QUIRK(0x17aa, 0, "Lenovo Thinkpad", AD1981_THINKPAD),
+       SND_PCI_QUIRK(0x1014, 0x0597, "Lenovo Z60", AD1981_THINKPAD),
        {}
 };
 
@@ -1437,7 +1464,9 @@ static int patch_ad1981(struct hda_codec *codec)
        codec->patch_ops = ad198x_patch_ops;
 
        /* override some parameters */
-       board_config = snd_hda_check_board_config(codec, ad1981_cfg_tbl);
+       board_config = snd_hda_check_board_config(codec, AD1981_MODELS,
+                                                 ad1981_models,
+                                                 ad1981_cfg_tbl);
        switch (board_config) {
        case AD1981_HP:
                spec->mixers[0] = ad1981_hp_mixers;
@@ -2565,15 +2594,14 @@ static int ad1988_auto_init(struct hda_codec *codec)
 /*
  */
 
-static struct hda_board_config ad1988_cfg_tbl[] = {
-       { .modelname = "6stack",        .config = AD1988_6STACK },
-       { .modelname = "6stack-dig",    .config = AD1988_6STACK_DIG },
-       { .modelname = "3stack",        .config = AD1988_3STACK },
-       { .modelname = "3stack-dig",    .config = AD1988_3STACK_DIG },
-       { .modelname = "laptop",        .config = AD1988_LAPTOP },
-       { .modelname = "laptop-dig",    .config = AD1988_LAPTOP_DIG },
-       { .modelname = "auto",          .config = AD1988_AUTO },
-       {}
+static const char *ad1988_models[AD1988_MODEL_LAST] = {
+       [AD1988_6STACK]         = "6stack",
+       [AD1988_6STACK_DIG]     = "6stack-dig",
+       [AD1988_3STACK]         = "3stack",
+       [AD1988_3STACK_DIG]     = "3stack-dig",
+       [AD1988_LAPTOP]         = "laptop",
+       [AD1988_LAPTOP_DIG]     = "laptop-dig",
+       [AD1988_AUTO]           = "auto",
 };
 
 static int patch_ad1988(struct hda_codec *codec)
@@ -2591,8 +2619,9 @@ static int patch_ad1988(struct hda_codec *codec)
        if (is_rev2(codec))
                snd_printk(KERN_INFO "patch_analog: AD1988A rev.2 is detected, enable workarounds\n");
 
-       board_config = snd_hda_check_board_config(codec, ad1988_cfg_tbl);
-       if (board_config < 0 || board_config >= AD1988_MODEL_LAST) {
+       board_config = snd_hda_check_board_config(codec, AD1988_MODEL_LAST,
+                                                 ad1988_models, NULL);
+       if (board_config < 0) {
                printk(KERN_INFO "hda_codec: Unknown model for AD1988, trying auto-probe from BIOS...\n");
                board_config = AD1988_AUTO;
        }
index d38ce22507ae128a5a9a81331c0fd47860857bbb..5b9d3a31a1ae8f261c527985abe363f57b86f4d4 100644 (file)
@@ -40,6 +40,7 @@ enum {
        CMI_FULL_DIG,   /* back 6-jack + front-panel 2-jack + digital I/O */
        CMI_ALLOUT,     /* back 5-jack + front-panel 2-jack + digital out */
        CMI_AUTO,       /* let driver guess it */
+       CMI_MODELS
 };
 
 struct cmi_spec {
@@ -603,14 +604,17 @@ static void cmi9880_free(struct hda_codec *codec)
 /*
  */
 
-static struct hda_board_config cmi9880_cfg_tbl[] = {
-       { .modelname = "minimal", .config = CMI_MINIMAL },
-       { .modelname = "min_fp", .config = CMI_MIN_FP },
-       { .modelname = "full", .config = CMI_FULL },
-       { .modelname = "full_dig", .config = CMI_FULL_DIG },
-       { .pci_subvendor = 0x1043, .pci_subdevice = 0x813d, .config = CMI_FULL_DIG }, /* ASUS P5AD2 */
-       { .modelname = "allout", .config = CMI_ALLOUT },
-       { .modelname = "auto", .config = CMI_AUTO },
+static const char *cmi9880_models[CMI_MODELS] = {
+       [CMI_MINIMAL]   = "minimal",
+       [CMI_MIN_FP]    = "min_fp",
+       [CMI_FULL]      = "full",
+       [CMI_FULL_DIG]  = "full_dig",
+       [CMI_ALLOUT]    = "allout",
+       [CMI_AUTO]      = "auto",
+};
+
+static struct snd_pci_quirk cmi9880_cfg_tbl[] = {
+       SND_PCI_QUIRK(0x1043, 0x813d, "ASUS P5AD2", CMI_FULL_DIG),
        {} /* terminator */
 };
 
@@ -633,7 +637,9 @@ static int patch_cmi9880(struct hda_codec *codec)
                return -ENOMEM;
 
        codec->spec = spec;
-       spec->board_config = snd_hda_check_board_config(codec, cmi9880_cfg_tbl);
+       spec->board_config = snd_hda_check_board_config(codec, CMI_MODELS,
+                                                       cmi9880_models,
+                                                       cmi9880_cfg_tbl);
        if (spec->board_config < 0) {
                snd_printdd(KERN_INFO "hda_codec: Unknown model for CMI9880\n");
                spec->board_config = CMI_AUTO; /* try everything */
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
new file mode 100644 (file)
index 0000000..73f4668
--- /dev/null
@@ -0,0 +1,1311 @@
+/*
+ * HD audio interface patch for Conexant HDA audio codec
+ *
+ * Copyright (c) 2006 Pototskiy Akex <alex.pototskiy@gmail.com>
+ *                   Takashi Iwai <tiwai@suse.de>
+ *                   Tobin Davis  <tdavis@dsl-only.net>
+ *
+ *  This driver is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This driver is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+ */
+
+#include <sound/driver.h>
+#include <linux/init.h>
+#include <linux/delay.h>
+#include <linux/slab.h>
+#include <linux/pci.h>
+#include <sound/core.h>
+#include "hda_codec.h"
+#include "hda_local.h"
+
+#define CXT_PIN_DIR_IN              0x00
+#define CXT_PIN_DIR_OUT             0x01
+#define CXT_PIN_DIR_INOUT           0x02
+#define CXT_PIN_DIR_IN_NOMICBIAS    0x03
+#define CXT_PIN_DIR_INOUT_NOMICBIAS 0x04
+
+#define CONEXANT_HP_EVENT      0x37
+#define CONEXANT_MIC_EVENT     0x38
+
+
+
+struct conexant_spec {
+
+       struct snd_kcontrol_new *mixers[5];
+       int num_mixers;
+
+       const struct hda_verb *init_verbs[5];   /* initialization verbs
+                                                * don't forget NULL
+                                                * termination!
+                                                */
+       unsigned int num_init_verbs;
+
+       /* playback */
+       struct hda_multi_out multiout;  /* playback set-up
+                                        * max_channels, dacs must be set
+                                        * dig_out_nid and hp_nid are optional
+                                        */
+       unsigned int cur_eapd;
+       unsigned int need_dac_fix;
+
+       /* capture */
+       unsigned int num_adc_nids;
+       hda_nid_t *adc_nids;
+       hda_nid_t dig_in_nid;           /* digital-in NID; optional */
+
+       /* capture source */
+       const struct hda_input_mux *input_mux;
+       hda_nid_t *capsrc_nids;
+       unsigned int cur_mux[3];
+
+       /* channel model */
+       const struct hda_channel_mode *channel_mode;
+       int num_channel_mode;
+
+       /* PCM information */
+       struct hda_pcm pcm_rec[2];      /* used in build_pcms() */
+
+       struct mutex amp_mutex; /* PCM volume/mute control mutex */
+       unsigned int spdif_route;
+
+       /* dynamic controls, init_verbs and input_mux */
+       struct auto_pin_cfg autocfg;
+       unsigned int num_kctl_alloc, num_kctl_used;
+       struct snd_kcontrol_new *kctl_alloc;
+       struct hda_input_mux private_imux;
+       hda_nid_t private_dac_nids[4];
+
+};
+
+static int conexant_playback_pcm_open(struct hda_pcm_stream *hinfo,
+                                     struct hda_codec *codec,
+                                     struct snd_pcm_substream *substream)
+{
+       struct conexant_spec *spec = codec->spec;
+       return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
+}
+
+static int conexant_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
+                                        struct hda_codec *codec,
+                                        unsigned int stream_tag,
+                                        unsigned int format,
+                                        struct snd_pcm_substream *substream)
+{
+       struct conexant_spec *spec = codec->spec;
+       return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
+                                               stream_tag,
+                                               format, substream);
+}
+
+static int conexant_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
+                                        struct hda_codec *codec,
+                                        struct snd_pcm_substream *substream)
+{
+       struct conexant_spec *spec = codec->spec;
+       return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
+}
+
+/*
+ * Digital out
+ */
+static int conexant_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
+                                         struct hda_codec *codec,
+                                         struct snd_pcm_substream *substream)
+{
+       struct conexant_spec *spec = codec->spec;
+       return snd_hda_multi_out_dig_open(codec, &spec->multiout);
+}
+
+static int conexant_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
+                                        struct hda_codec *codec,
+                                        struct snd_pcm_substream *substream)
+{
+       struct conexant_spec *spec = codec->spec;
+       return snd_hda_multi_out_dig_close(codec, &spec->multiout);
+}
+
+/*
+ * Analog capture
+ */
+static int conexant_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
+                                     struct hda_codec *codec,
+                                     unsigned int stream_tag,
+                                     unsigned int format,
+                                     struct snd_pcm_substream *substream)
+{
+       struct conexant_spec *spec = codec->spec;
+       snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
+                                  stream_tag, 0, format);
+       return 0;
+}
+
+static int conexant_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
+                                     struct hda_codec *codec,
+                                     struct snd_pcm_substream *substream)
+{
+       struct conexant_spec *spec = codec->spec;
+       snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
+                                  0, 0, 0);
+       return 0;
+}
+
+
+
+static struct hda_pcm_stream conexant_pcm_analog_playback = {
+       .substreams = 1,
+       .channels_min = 2,
+       .channels_max = 2,
+       .nid = 0, /* fill later */
+       .ops = {
+               .open = conexant_playback_pcm_open,
+               .prepare = conexant_playback_pcm_prepare,
+               .cleanup = conexant_playback_pcm_cleanup
+       },
+};
+
+static struct hda_pcm_stream conexant_pcm_analog_capture = {
+       .substreams = 1,
+       .channels_min = 2,
+       .channels_max = 2,
+       .nid = 0, /* fill later */
+       .ops = {
+               .prepare = conexant_capture_pcm_prepare,
+               .cleanup = conexant_capture_pcm_cleanup
+       },
+};
+
+
+static struct hda_pcm_stream conexant_pcm_digital_playback = {
+       .substreams = 1,
+       .channels_min = 2,
+       .channels_max = 2,
+       .nid = 0, /* fill later */
+       .ops = {
+               .open = conexant_dig_playback_pcm_open,
+               .close = conexant_dig_playback_pcm_close
+       },
+};
+
+static struct hda_pcm_stream conexant_pcm_digital_capture = {
+       .substreams = 1,
+       .channels_min = 2,
+       .channels_max = 2,
+       /* NID is set in alc_build_pcms */
+};
+
+static int conexant_build_pcms(struct hda_codec *codec)
+{
+       struct conexant_spec *spec = codec->spec;
+       struct hda_pcm *info = spec->pcm_rec;
+
+       codec->num_pcms = 1;
+       codec->pcm_info = info;
+
+       info->name = "CONEXANT Analog";
+       info->stream[SNDRV_PCM_STREAM_PLAYBACK] = conexant_pcm_analog_playback;
+       info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max =
+               spec->multiout.max_channels;
+       info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
+               spec->multiout.dac_nids[0];
+       info->stream[SNDRV_PCM_STREAM_CAPTURE] = conexant_pcm_analog_capture;
+       info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adc_nids;
+       info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
+
+       if (spec->multiout.dig_out_nid) {
+               info++;
+               codec->num_pcms++;
+               info->name = "Conexant Digital";
+               info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
+                       conexant_pcm_digital_playback;
+               info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
+                       spec->multiout.dig_out_nid;
+               if (spec->dig_in_nid) {
+                       info->stream[SNDRV_PCM_STREAM_CAPTURE] =
+                               conexant_pcm_digital_capture;
+                       info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
+                               spec->dig_in_nid;
+               }
+       }
+
+       return 0;
+}
+
+static int conexant_mux_enum_info(struct snd_kcontrol *kcontrol,
+                                 struct snd_ctl_elem_info *uinfo)
+{
+       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct conexant_spec *spec = codec->spec;
+
+       return snd_hda_input_mux_info(spec->input_mux, uinfo);
+}
+
+static int conexant_mux_enum_get(struct snd_kcontrol *kcontrol,
+                                struct snd_ctl_elem_value *ucontrol)
+{
+       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct conexant_spec *spec = codec->spec;
+       unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
+
+       ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
+       return 0;
+}
+
+static int conexant_mux_enum_put(struct snd_kcontrol *kcontrol,
+                                struct snd_ctl_elem_value *ucontrol)
+{
+       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct conexant_spec *spec = codec->spec;
+       unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
+
+       return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
+                                    spec->capsrc_nids[adc_idx],
+                                    &spec->cur_mux[adc_idx]);
+}
+
+static int conexant_init(struct hda_codec *codec)
+{
+       struct conexant_spec *spec = codec->spec;
+       int i;
+
+       for (i = 0; i < spec->num_init_verbs; i++)
+               snd_hda_sequence_write(codec, spec->init_verbs[i]);
+       return 0;
+}
+
+static void conexant_free(struct hda_codec *codec)
+{
+        struct conexant_spec *spec = codec->spec;
+        unsigned int i;
+
+        if (spec->kctl_alloc) {
+                for (i = 0; i < spec->num_kctl_used; i++)
+                        kfree(spec->kctl_alloc[i].name);
+                kfree(spec->kctl_alloc);
+        }
+
+       kfree(codec->spec);
+}
+
+#ifdef CONFIG_PM
+static int conexant_resume(struct hda_codec *codec)
+{
+       struct conexant_spec *spec = codec->spec;
+       int i;
+
+       codec->patch_ops.init(codec);
+       for (i = 0; i < spec->num_mixers; i++)
+               snd_hda_resume_ctls(codec, spec->mixers[i]);
+       if (spec->multiout.dig_out_nid)
+               snd_hda_resume_spdif_out(codec);
+       if (spec->dig_in_nid)
+               snd_hda_resume_spdif_in(codec);
+       return 0;
+}
+#endif
+
+static int conexant_build_controls(struct hda_codec *codec)
+{
+       struct conexant_spec *spec = codec->spec;
+       unsigned int i;
+       int err;
+
+       for (i = 0; i < spec->num_mixers; i++) {
+               err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
+               if (err < 0)
+                       return err;
+       }
+       if (spec->multiout.dig_out_nid) {
+               err = snd_hda_create_spdif_out_ctls(codec,
+                                                   spec->multiout.dig_out_nid);
+               if (err < 0)
+                       return err;
+       } 
+       if (spec->dig_in_nid) {
+               err = snd_hda_create_spdif_in_ctls(codec,spec->dig_in_nid);
+               if (err < 0)
+                       return err;
+       }
+       return 0;
+}
+
+static struct hda_codec_ops conexant_patch_ops = {
+       .build_controls = conexant_build_controls,
+       .build_pcms = conexant_build_pcms,
+       .init = conexant_init,
+       .free = conexant_free,
+#ifdef CONFIG_PM
+       .resume = conexant_resume,
+#endif
+};
+
+/*
+ * EAPD control
+ * the private value = nid | (invert << 8)
+ */
+
+static int conexant_eapd_info(struct snd_kcontrol *kcontrol,
+                             struct snd_ctl_elem_info *uinfo)
+{
+       uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
+       uinfo->count = 1;
+       uinfo->value.integer.min = 0;
+       uinfo->value.integer.max = 1;
+       return 0;
+}
+
+static int conexant_eapd_get(struct snd_kcontrol *kcontrol,
+                            struct snd_ctl_elem_value *ucontrol)
+{
+       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct conexant_spec *spec = codec->spec;
+       int invert = (kcontrol->private_value >> 8) & 1;
+       if (invert)
+               ucontrol->value.integer.value[0] = !spec->cur_eapd;
+       else
+               ucontrol->value.integer.value[0] = spec->cur_eapd;
+       return 0;
+}
+
+static int conexant_eapd_put(struct snd_kcontrol *kcontrol,
+                            struct snd_ctl_elem_value *ucontrol)
+{
+       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct conexant_spec *spec = codec->spec;
+       int invert = (kcontrol->private_value >> 8) & 1;
+       hda_nid_t nid = kcontrol->private_value & 0xff;
+       unsigned int eapd;
+       eapd = ucontrol->value.integer.value[0];
+       if (invert)
+               eapd = !eapd;
+       if (eapd == spec->cur_eapd && !codec->in_resume)
+               return 0;
+       spec->cur_eapd = eapd;
+       snd_hda_codec_write(codec, nid,
+                           0, AC_VERB_SET_EAPD_BTLENABLE,
+                           eapd ? 0x02 : 0x00);
+       return 1;
+}
+
+/* controls for test mode */
+#ifdef CONFIG_SND_DEBUG
+
+static int conexant_ch_mode_info(struct snd_kcontrol *kcontrol,
+                                struct snd_ctl_elem_info *uinfo)
+{
+       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct conexant_spec *spec = codec->spec;
+       return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
+                                   spec->num_channel_mode);
+}
+
+static int conexant_ch_mode_get(struct snd_kcontrol *kcontrol,
+                               struct snd_ctl_elem_value *ucontrol)
+{
+       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct conexant_spec *spec = codec->spec;
+       return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
+                                  spec->num_channel_mode,
+                                  spec->multiout.max_channels);
+}
+
+static int conexant_ch_mode_put(struct snd_kcontrol *kcontrol,
+                               struct snd_ctl_elem_value *ucontrol)
+{
+       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct conexant_spec *spec = codec->spec;
+       int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
+                                     spec->num_channel_mode,
+                                     &spec->multiout.max_channels);
+       if (err >= 0 && spec->need_dac_fix)
+               spec->multiout.num_dacs = spec->multiout.max_channels / 2;
+       return err;
+}
+
+#define CXT_PIN_MODE(xname, nid, dir) \
+       { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0,  \
+         .info = conexant_ch_mode_info, \
+         .get = conexant_ch_mode_get, \
+         .put = conexant_ch_mode_put, \
+         .private_value = nid | (dir<<16) }
+
+static int cxt_gpio_data_info(struct snd_kcontrol *kcontrol,
+                             struct snd_ctl_elem_info *uinfo)
+{
+       uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
+       uinfo->count = 1;
+       uinfo->value.integer.min = 0;
+       uinfo->value.integer.max = 1;
+       return 0;
+}                                
+
+static int cxt_gpio_data_get(struct snd_kcontrol *kcontrol,
+                            struct snd_ctl_elem_value *ucontrol)
+{
+       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+       hda_nid_t nid = kcontrol->private_value & 0xffff;
+       unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
+       long *valp = ucontrol->value.integer.value;
+       unsigned int val = snd_hda_codec_read(codec, nid, 0,
+                                             AC_VERB_GET_GPIO_DATA, 0x00);
+
+       *valp = (val & mask) != 0;
+       return 0;
+}
+
+static int cxt_gpio_data_put(struct snd_kcontrol *kcontrol,
+                            struct snd_ctl_elem_value *ucontrol)
+{
+       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+       hda_nid_t nid = kcontrol->private_value & 0xffff;
+       unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
+       long val = *ucontrol->value.integer.value;
+       unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
+                                                   AC_VERB_GET_GPIO_DATA,
+                                                   0x00);
+       unsigned int old_data = gpio_data;
+
+       /* Set/unset the masked GPIO bit(s) as needed */
+       if (val == 0)
+               gpio_data &= ~mask;
+       else
+               gpio_data |= mask;
+       if (gpio_data == old_data && !codec->in_resume)
+               return 0;
+       snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
+       return 1;
+}
+
+#define CXT_GPIO_DATA_SWITCH(xname, nid, mask) \
+       { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0,  \
+         .info = cxt_gpio_data_info, \
+         .get = cxt_gpio_data_get, \
+         .put = cxt_gpio_data_put, \
+         .private_value = nid | (mask<<16) }
+
+static int cxt_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
+                              struct snd_ctl_elem_info *uinfo)
+{
+       uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
+       uinfo->count = 1;
+       uinfo->value.integer.min = 0;
+       uinfo->value.integer.max = 1;
+       return 0;
+}                                
+
+static int cxt_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
+                             struct snd_ctl_elem_value *ucontrol)
+{
+       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+       hda_nid_t nid = kcontrol->private_value & 0xffff;
+       unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
+       long *valp = ucontrol->value.integer.value;
+       unsigned int val = snd_hda_codec_read(codec, nid, 0,
+                                             AC_VERB_GET_DIGI_CONVERT, 0x00);
+
+       *valp = (val & mask) != 0;
+       return 0;
+}
+
+static int cxt_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
+                             struct snd_ctl_elem_value *ucontrol)
+{
+       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+       hda_nid_t nid = kcontrol->private_value & 0xffff;
+       unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
+       long val = *ucontrol->value.integer.value;
+       unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
+                                                   AC_VERB_GET_DIGI_CONVERT,
+                                                   0x00);
+       unsigned int old_data = ctrl_data;
+
+       /* Set/unset the masked control bit(s) as needed */
+       if (val == 0)
+               ctrl_data &= ~mask;
+       else
+               ctrl_data |= mask;
+       if (ctrl_data == old_data && !codec->in_resume)
+               return 0;
+       snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
+                           ctrl_data);
+       return 1;
+}
+
+#define CXT_SPDIF_CTRL_SWITCH(xname, nid, mask) \
+       { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0,  \
+         .info = cxt_spdif_ctrl_info, \
+         .get = cxt_spdif_ctrl_get, \
+         .put = cxt_spdif_ctrl_put, \
+         .private_value = nid | (mask<<16) }
+
+#endif /* CONFIG_SND_DEBUG */
+
+/* Conexant 5045 specific */
+
+static hda_nid_t cxt5045_dac_nids[1] = { 0x19 };
+static hda_nid_t cxt5045_adc_nids[1] = { 0x1a };
+static hda_nid_t cxt5045_capsrc_nids[1] = { 0x1a };
+#define CXT5045_SPDIF_OUT      0x13
+
+static struct hda_channel_mode cxt5045_modes[1] = {
+       { 2, NULL },
+};
+
+static struct hda_input_mux cxt5045_capture_source = {
+       .num_items = 2,
+       .items = {
+               { "ExtMic", 0x1 },
+               { "LineIn", 0x2 },
+       }
+};
+
+/* turn on/off EAPD (+ mute HP) as a master switch */
+static int cxt5045_hp_master_sw_put(struct snd_kcontrol *kcontrol,
+                                   struct snd_ctl_elem_value *ucontrol)
+{
+       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct conexant_spec *spec = codec->spec;
+
+       if (!conexant_eapd_put(kcontrol, ucontrol))
+               return 0;
+
+       /* toggle HP mute appropriately */
+       snd_hda_codec_amp_update(codec, 0x11, 0, HDA_OUTPUT, 0,
+                                0x80, spec->cur_eapd ? 0 : 0x80);
+       snd_hda_codec_amp_update(codec, 0x11, 1, HDA_OUTPUT, 0,
+                                0x80, spec->cur_eapd ? 0 : 0x80);
+       return 1;
+}
+
+/* bind volumes of both NID 0x10 and 0x11 */
+static int cxt5045_hp_master_vol_put(struct snd_kcontrol *kcontrol,
+                                    struct snd_ctl_elem_value *ucontrol)
+{
+       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+       long *valp = ucontrol->value.integer.value;
+       int change;
+
+       change = snd_hda_codec_amp_update(codec, 0x10, 0, HDA_OUTPUT, 0,
+                                         0x7f, valp[0] & 0x7f);
+       change |= snd_hda_codec_amp_update(codec, 0x10, 1, HDA_OUTPUT, 0,
+                                          0x7f, valp[1] & 0x7f);
+       snd_hda_codec_amp_update(codec, 0x11, 0, HDA_OUTPUT, 0,
+                                0x7f, valp[0] & 0x7f);
+       snd_hda_codec_amp_update(codec, 0x11, 1, HDA_OUTPUT, 0,
+                                0x7f, valp[1] & 0x7f);
+       return change;
+}
+
+
+/* mute internal speaker if HP is plugged */
+static void cxt5045_hp_automute(struct hda_codec *codec)
+{
+       unsigned int present;
+
+       present = snd_hda_codec_read(codec, 0x11, 0,
+                                    AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
+       snd_hda_codec_amp_update(codec, 0x10, 0, HDA_OUTPUT, 0,
+                                0x80, present ? 0x80 : 0);
+       snd_hda_codec_amp_update(codec, 0x10, 1, HDA_OUTPUT, 0,
+                                0x80, present ? 0x80 : 0);
+}
+
+/* unsolicited event for HP jack sensing */
+static void cxt5045_hp_unsol_event(struct hda_codec *codec,
+                                  unsigned int res)
+{
+       res >>= 26;
+       switch (res) {
+       case CONEXANT_HP_EVENT:
+               cxt5045_hp_automute(codec);
+               break;
+       }
+}
+
+static struct snd_kcontrol_new cxt5045_mixers[] = {
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               .name = "Capture Source",
+               .info = conexant_mux_enum_info,
+               .get = conexant_mux_enum_get,
+               .put = conexant_mux_enum_put
+       },
+       HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x17, 0x02, HDA_INPUT),
+       HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x17, 0x02, HDA_INPUT),
+       HDA_CODEC_VOLUME("Capture Volume", 0x1a, 0x02, HDA_INPUT),
+       HDA_CODEC_MUTE("Capture Switch", 0x1a, 0x02, HDA_INPUT),
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               .name = "Master Playback Volume",
+               .info = snd_hda_mixer_amp_volume_info,
+               .get = snd_hda_mixer_amp_volume_get,
+               .put = cxt5045_hp_master_vol_put,
+               .private_value = HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
+       },
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               .name = "Master Playback Switch",
+               .info = conexant_eapd_info,
+               .get = conexant_eapd_get,
+               .put = cxt5045_hp_master_sw_put,
+               .private_value = 0x11,
+       },
+
+       {}
+};
+
+static struct hda_verb cxt5045_init_verbs[] = {
+       /* Line in, Mic */
+       {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
+       {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 },
+       /* HP, Amp  */
+       {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
+       {0x1A, AC_VERB_SET_CONNECT_SEL,0x01},
+       {0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
+        AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x00},
+       {0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
+        AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x03},
+       /* Record selector: Front mic */
+       {0x14, AC_VERB_SET_CONNECT_SEL,0x03},
+       {0x17, AC_VERB_SET_AMP_GAIN_MUTE,
+        AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
+       /* SPDIF route: PCM */
+       { 0x13, AC_VERB_SET_CONNECT_SEL, 0x0 },
+       /* pin sensing on HP and Mic jacks */
+       {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
+       /* EAPD */
+       {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x0 }, /* default on */
+       { } /* end */
+};
+
+#ifdef CONFIG_SND_DEBUG
+/* Test configuration for debugging, modelled after the ALC260 test
+ * configuration.
+ */
+static struct hda_input_mux cxt5045_test_capture_source = {
+       .num_items = 5,
+       .items = {
+               { "MIXER", 0x0 },
+               { "MIC1 pin", 0x1 },
+               { "LINE1 pin", 0x2 },
+               { "HP-OUT pin", 0x3 },
+               { "CD pin", 0x4 },
+        },
+};
+
+static struct snd_kcontrol_new cxt5045_test_mixer[] = {
+
+       /* Output controls */
+       HDA_CODEC_VOLUME("OutAmp-1 Volume", 0x19, 0x00, HDA_OUTPUT),
+       HDA_CODEC_MUTE("OutAmp-1 Switch", 0x19,0x00, HDA_OUTPUT),
+       HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT),
+       
+       /* Modes for retasking pin widgets */
+       CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT),
+       CXT_PIN_MODE("LINE1 pin mode", 0x12, CXT_PIN_DIR_INOUT),
+
+       /* Loopback mixer controls */
+       HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x17, 0x01, HDA_INPUT),
+       HDA_CODEC_MUTE("MIC1 Playback Switch", 0x17, 0x01, HDA_INPUT),
+       HDA_CODEC_VOLUME("LINE loopback Playback Volume", 0x17, 0x02, HDA_INPUT),
+       HDA_CODEC_MUTE("LINE loopback Playback Switch", 0x17, 0x02, HDA_INPUT),
+       HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x17, 0x03, HDA_INPUT),
+       HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x17, 0x03, HDA_INPUT),
+       HDA_CODEC_VOLUME("CD Playback Volume", 0x17, 0x04, HDA_INPUT),
+       HDA_CODEC_MUTE("CD Playback Switch", 0x17, 0x04, HDA_INPUT),
+
+       /* Controls for GPIO pins, assuming they exist and are configured as outputs */
+       CXT_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
+#if 0   /* limit this to one GPIO pin for now */       
+       CXT_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
+       CXT_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
+       CXT_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
+#endif
+       CXT_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x13, 0x01),
+
+       HDA_CODEC_VOLUME("Capture Volume", 0x17, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE("Capture Switch", 0x17, 0x0, HDA_OUTPUT),
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               .name = "Input Source",
+               .info = conexant_mux_enum_info,
+               .get = conexant_mux_enum_get,
+               .put = conexant_mux_enum_put,
+       },
+
+       { } /* end */
+};
+
+static struct hda_verb cxt5045_test_init_verbs[] = {
+       /* Enable all GPIOs as outputs with an initial value of 0 */
+       {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
+       {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
+       {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
+
+       /* Enable retasking pins as output, initially without power amp */
+       {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
+       {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
+
+       /* Disable digital (SPDIF) pins initially, but users can enable
+        * them via a mixer switch.  In the case of SPDIF-out, this initverb
+        * payload also sets the generation to 0, output to be in "consumer"
+        * PCM format, copyright asserted, no pre-emphasis and no validity
+        * control.
+        */
+       {0x13, AC_VERB_SET_DIGI_CONVERT_1, 0},
+
+       /* Start with output sum widgets muted and their output gains at min */
+       {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
+       {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
+
+       /* Unmute retasking pin widget output buffers since the default
+        * state appears to be output.  As the pin mode is changed by the
+        * user the pin mode control will take care of enabling the pin's
+        * input/output buffers as needed.
+        */
+       {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+
+       /* Mute capture amp left and right */
+       {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
+
+       /* Set ADC connection select to match default mixer setting (mic1
+        * pin)
+        */
+       {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
+
+       /* Mute all inputs to mixer widget (even unconnected ones) */
+       {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* Mixer pin */
+       {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* Mic1 pin */
+       {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* Line pin */
+       {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* HP pin */
+       {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
+
+       { }
+};
+#endif
+
+
+/* initialize jack-sensing, too */
+static int cxt5045_init(struct hda_codec *codec)
+{
+       conexant_init(codec);
+       cxt5045_hp_automute(codec);
+       return 0;
+}
+
+
+enum {
+       CXT5045_LAPTOP, /* Laptops w/ EAPD support */
+#ifdef CONFIG_SND_DEBUG
+       CXT5045_TEST,
+#endif
+       CXT5045_MODELS
+};
+
+static const char *cxt5045_models[CXT5045_MODELS] = {
+       [CXT5045_LAPTOP]        = "laptop",
+#ifdef CONFIG_SND_DEBUG
+       [CXT5045_TEST]          = "test",
+#endif
+};
+
+static struct snd_pci_quirk cxt5045_cfg_tbl[] = {
+       SND_PCI_QUIRK(0x103c, 0x30b7, "HP DV6000Z", CXT5045_LAPTOP),
+       {}
+};
+
+static int patch_cxt5045(struct hda_codec *codec)
+{
+       struct conexant_spec *spec;
+       int board_config;
+
+       spec = kzalloc(sizeof(*spec), GFP_KERNEL);
+       if (!spec)
+               return -ENOMEM;
+       mutex_init(&spec->amp_mutex);
+       codec->spec = spec;
+
+       spec->multiout.max_channels = 2;
+       spec->multiout.num_dacs = ARRAY_SIZE(cxt5045_dac_nids);
+       spec->multiout.dac_nids = cxt5045_dac_nids;
+       spec->multiout.dig_out_nid = CXT5045_SPDIF_OUT;
+       spec->num_adc_nids = 1;
+       spec->adc_nids = cxt5045_adc_nids;
+       spec->capsrc_nids = cxt5045_capsrc_nids;
+       spec->input_mux = &cxt5045_capture_source;
+       spec->num_mixers = 1;
+       spec->mixers[0] = cxt5045_mixers;
+       spec->num_init_verbs = 1;
+       spec->init_verbs[0] = cxt5045_init_verbs;
+       spec->spdif_route = 0;
+       spec->num_channel_mode = ARRAY_SIZE(cxt5045_modes),
+       spec->channel_mode = cxt5045_modes,
+
+
+       codec->patch_ops = conexant_patch_ops;
+       codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
+
+       board_config = snd_hda_check_board_config(codec, CXT5045_MODELS,
+                                                 cxt5045_models,
+                                                 cxt5045_cfg_tbl);
+       switch (board_config) {
+       case CXT5045_LAPTOP:
+               spec->input_mux = &cxt5045_capture_source;
+               spec->num_init_verbs = 2;
+               spec->init_verbs[1] = cxt5045_init_verbs;
+               spec->mixers[0] = cxt5045_mixers;
+               codec->patch_ops.init = cxt5045_init;
+               break;
+#ifdef CONFIG_SND_DEBUG
+       case CXT5045_TEST:
+               spec->input_mux = &cxt5045_test_capture_source;
+               spec->mixers[0] = cxt5045_test_mixer;
+               spec->init_verbs[0] = cxt5045_test_init_verbs;
+#endif 
+       }
+       return 0;
+}
+
+
+/* Conexant 5047 specific */
+
+static hda_nid_t cxt5047_dac_nids[1] = { 0x10 };
+static hda_nid_t cxt5047_adc_nids[1] = { 0x12 };
+static hda_nid_t cxt5047_capsrc_nids[1] = { 0x1a };
+#define CXT5047_SPDIF_OUT      0x11
+
+static struct hda_channel_mode cxt5047_modes[1] = {
+       { 2, NULL },
+};
+
+static struct hda_input_mux cxt5047_capture_source = {
+       .num_items = 2,
+       .items = {
+               { "ExtMic", 0x1 },
+               { "IntMic", 0x2 },
+       }
+};
+
+static struct hda_input_mux cxt5047_hp_capture_source = {
+       .num_items = 1,
+       .items = {
+               { "ExtMic", 0x1 },
+       }
+};
+
+/* turn on/off EAPD (+ mute HP) as a master switch */
+static int cxt5047_hp_master_sw_put(struct snd_kcontrol *kcontrol,
+                                   struct snd_ctl_elem_value *ucontrol)
+{
+       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct conexant_spec *spec = codec->spec;
+
+       if (!conexant_eapd_put(kcontrol, ucontrol))
+               return 0;
+
+       /* toggle HP mute appropriately */
+       snd_hda_codec_amp_update(codec, 0x13, 0, HDA_OUTPUT, 0,
+                                0x80, spec->cur_eapd ? 0 : 0x80);
+       snd_hda_codec_amp_update(codec, 0x13, 1, HDA_OUTPUT, 0,
+                                0x80, spec->cur_eapd ? 0 : 0x80);
+       return 1;
+}
+
+#if 0
+/* bind volumes of both NID 0x13 and 0x1d */
+static int cxt5047_hp_master_vol_put(struct snd_kcontrol *kcontrol,
+                                    struct snd_ctl_elem_value *ucontrol)
+{
+       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+       long *valp = ucontrol->value.integer.value;
+       int change;
+
+       change = snd_hda_codec_amp_update(codec, 0x1c, 0, HDA_OUTPUT, 0,
+                                         0x7f, valp[0] & 0x7f);
+       change |= snd_hda_codec_amp_update(codec, 0x1c, 1, HDA_OUTPUT, 0,
+                                          0x7f, valp[1] & 0x7f);
+       snd_hda_codec_amp_update(codec, 0x13, 0, HDA_OUTPUT, 0,
+                                0x7f, valp[0] & 0x7f);
+       snd_hda_codec_amp_update(codec, 0x13, 1, HDA_OUTPUT, 0,
+                                0x7f, valp[1] & 0x7f);
+       return change;
+}
+#endif
+
+/* mute internal speaker if HP is plugged */
+static void cxt5047_hp_automute(struct hda_codec *codec)
+{
+       unsigned int present;
+
+       present = snd_hda_codec_read(codec, 0x13, 0,
+                                    AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
+       snd_hda_codec_amp_update(codec, 0x1c, 0, HDA_OUTPUT, 0,
+                                0x80, present ? 0x80 : 0);
+       snd_hda_codec_amp_update(codec, 0x1c, 1, HDA_OUTPUT, 0,
+                                0x80, present ? 0x80 : 0);
+}
+
+/* toggle input of built-in and mic jack appropriately */
+static void cxt5047_hp_automic(struct hda_codec *codec)
+{
+       static struct hda_verb mic_jack_on[] = {
+               {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
+               {0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
+               {}
+       };
+       static struct hda_verb mic_jack_off[] = {
+               {0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
+               {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
+               {}
+       };
+       unsigned int present;
+
+       present = snd_hda_codec_read(codec, 0x08, 0,
+                                    AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
+       if (present)
+               snd_hda_sequence_write(codec, mic_jack_on);
+       else
+               snd_hda_sequence_write(codec, mic_jack_off);
+}
+
+/* unsolicited event for HP jack sensing */
+static void cxt5047_hp_unsol_event(struct hda_codec *codec,
+                                 unsigned int res)
+{
+       res >>= 26;
+       switch (res) {
+       case CONEXANT_HP_EVENT:
+               cxt5047_hp_automute(codec);
+               break;
+       case CONEXANT_MIC_EVENT:
+               cxt5047_hp_automic(codec);
+               break;
+       }
+}
+
+static struct snd_kcontrol_new cxt5047_mixers[] = {
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               .name = "Capture Source",
+               .info = conexant_mux_enum_info,
+               .get = conexant_mux_enum_get,
+               .put = conexant_mux_enum_put
+       },
+       HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT),
+       HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19, 0x02, HDA_INPUT),
+       HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
+       HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
+       HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
+       HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
+       HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT),
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               .name = "Master Playback Switch",
+               .info = conexant_eapd_info,
+               .get = conexant_eapd_get,
+               .put = cxt5047_hp_master_sw_put,
+               .private_value = 0x13,
+       },
+
+       {}
+};
+
+static struct snd_kcontrol_new cxt5047_hp_mixers[] = {
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               .name = "Capture Source",
+               .info = conexant_mux_enum_info,
+               .get = conexant_mux_enum_get,
+               .put = conexant_mux_enum_put
+       },
+       HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT),
+       HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19,0x02,HDA_INPUT),
+       HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
+       HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
+       HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
+       HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
+       HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT),
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               .name = "Master Playback Switch",
+               .info = conexant_eapd_info,
+               .get = conexant_eapd_get,
+               .put = cxt5047_hp_master_sw_put,
+               .private_value = 0x13,
+       },
+       { } /* end */
+};
+
+static struct hda_verb cxt5047_init_verbs[] = {
+       /* Line in, Mic, Built-in Mic */
+       {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
+       {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 },
+       {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 },
+       /* HP, Amp  */
+       {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
+       {0x1A, AC_VERB_SET_CONNECT_SEL,0x03},
+       {0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
+        AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x00},
+       {0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
+        AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x03},
+       /* Record selector: Front mic */
+       {0x12, AC_VERB_SET_CONNECT_SEL,0x03},
+       {0x19, AC_VERB_SET_AMP_GAIN_MUTE,
+        AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
+       /* SPDIF route: PCM */
+       { 0x18, AC_VERB_SET_CONNECT_SEL, 0x0 },
+       { } /* end */
+};
+
+/* configuration for Toshiba Laptops */
+static struct hda_verb cxt5047_toshiba_init_verbs[] = {
+       {0x13, AC_VERB_SET_EAPD_BTLENABLE, 0x0 }, /* default on */
+       /* pin sensing on HP and Mic jacks */
+       {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
+       {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
+       {}
+};
+
+/* configuration for HP Laptops */
+static struct hda_verb cxt5047_hp_init_verbs[] = {
+       /* pin sensing on HP and Mic jacks */
+       {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
+       {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
+       {}
+};
+
+/* Test configuration for debugging, modelled after the ALC260 test
+ * configuration.
+ */
+#ifdef CONFIG_SND_DEBUG
+static struct hda_input_mux cxt5047_test_capture_source = {
+       .num_items = 5,
+       .items = {
+               { "MIXER", 0x0 },
+               { "LINE1 pin", 0x1 },
+               { "MIC1 pin", 0x2 },
+               { "MIC2 pin", 0x3 },
+               { "CD pin", 0x4 },
+        },
+};
+
+static struct snd_kcontrol_new cxt5047_test_mixer[] = {
+
+       /* Output only controls */
+       HDA_CODEC_VOLUME("OutAmp-1 Volume", 0x10, 0x00, HDA_OUTPUT),
+       HDA_CODEC_MUTE("OutAmp-1 Switch", 0x10,0x00, HDA_OUTPUT),
+       HDA_CODEC_VOLUME("OutAmp-2 Volume", 0x1c, 0x00, HDA_OUTPUT),
+       HDA_CODEC_MUTE("OutAmp-2 Switch", 0x1c, 0x00, HDA_OUTPUT),
+       HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
+       HDA_CODEC_VOLUME("HeadPhone Playback Volume", 0x13, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE("HeadPhone Playback Switch", 0x13, 0x0, HDA_OUTPUT),
+
+       /* Modes for retasking pin widgets */
+       CXT_PIN_MODE("LINE1 pin mode", 0x14, CXT_PIN_DIR_INOUT),
+       CXT_PIN_MODE("MIC1 pin mode", 0x15, CXT_PIN_DIR_INOUT),
+
+       /* Loopback mixer controls */
+       HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x19, 0x02, HDA_INPUT),
+       HDA_CODEC_MUTE("MIC1 Playback Switch", 0x19, 0x02, HDA_INPUT),
+       HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x19, 0x03, HDA_INPUT),
+       HDA_CODEC_MUTE("MIC2 Playback Switch", 0x19, 0x03, HDA_INPUT),
+       HDA_CODEC_VOLUME("LINE Playback Volume", 0x19, 0x01, HDA_INPUT),
+       HDA_CODEC_MUTE("LINE Playback Switch", 0x19, 0x01, HDA_INPUT),
+       HDA_CODEC_VOLUME("CD Playback Volume", 0x19, 0x04, HDA_INPUT),
+       HDA_CODEC_MUTE("CD Playback Switch", 0x19, 0x04, HDA_INPUT),
+
+#if 0   
+       /* Controls for GPIO pins, assuming they exist and are configured as outputs */
+       CXT_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
+       CXT_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
+       CXT_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
+       CXT_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
+#endif
+       CXT_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x18, 0x01),
+
+       HDA_CODEC_VOLUME("Capture Volume", 0x19, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE("Capture Switch", 0x19, 0x0, HDA_OUTPUT),
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               .name = "Input Source",
+               .info = conexant_mux_enum_info,
+               .get = conexant_mux_enum_get,
+               .put = conexant_mux_enum_put,
+       },
+
+       { } /* end */
+};
+
+static struct hda_verb cxt5047_test_init_verbs[] = {
+       /* Enable all GPIOs as outputs with an initial value of 0 */
+       {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
+       {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
+       {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
+
+       /* Enable retasking pins as output, initially without power amp */
+       {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
+       {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
+       {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
+
+       /* Disable digital (SPDIF) pins initially, but users can enable
+        * them via a mixer switch.  In the case of SPDIF-out, this initverb
+        * payload also sets the generation to 0, output to be in "consumer"
+        * PCM format, copyright asserted, no pre-emphasis and no validity
+        * control.
+        */
+       {0x18, AC_VERB_SET_DIGI_CONVERT_1, 0},
+
+       /* Ensure mic1, mic2, line1 pin widgets take input from the 
+        * OUT1 sum bus when acting as an output.
+        */
+       {0x1a, AC_VERB_SET_CONNECT_SEL, 0},
+       {0x1b, AC_VERB_SET_CONNECT_SEL, 0},
+
+       /* Start with output sum widgets muted and their output gains at min */
+       {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
+       {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
+
+       /* Unmute retasking pin widget output buffers since the default
+        * state appears to be output.  As the pin mode is changed by the
+        * user the pin mode control will take care of enabling the pin's
+        * input/output buffers as needed.
+        */
+       {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+
+       /* Mute capture amp left and right */
+       {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
+
+       /* Set ADC connection select to match default mixer setting (mic1
+        * pin)
+        */
+       {0x12, AC_VERB_SET_CONNECT_SEL, 0x00},
+
+       /* Mute all inputs to mixer widget (even unconnected ones) */
+       {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
+       {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
+       {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
+       {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
+       {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
+       {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
+       {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
+       {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
+
+       { }
+};
+#endif
+
+
+/* initialize jack-sensing, too */
+static int cxt5047_hp_init(struct hda_codec *codec)
+{
+       conexant_init(codec);
+       cxt5047_hp_automute(codec);
+       cxt5047_hp_automic(codec);
+       return 0;
+}
+
+
+enum {
+       CXT5047_LAPTOP,         /* Laptops w/o EAPD support */
+       CXT5047_LAPTOP_HP,      /* Some HP laptops */
+       CXT5047_LAPTOP_EAPD,    /* Laptops with EAPD support */
+#ifdef CONFIG_SND_DEBUG
+       CXT5047_TEST,
+#endif
+       CXT5047_MODELS
+};
+
+static const char *cxt5047_models[CXT5047_MODELS] = {
+       [CXT5047_LAPTOP]        = "laptop",
+       [CXT5047_LAPTOP_HP]     = "laptop-hp",
+       [CXT5047_LAPTOP_EAPD]   = "laptop-eapd",
+#ifdef CONFIG_SND_DEBUG
+       [CXT5047_TEST]          = "test",
+#endif
+};
+
+static struct snd_pci_quirk cxt5047_cfg_tbl[] = {
+       SND_PCI_QUIRK(0x103c, 0x30a0, "HP DV1000", CXT5047_LAPTOP),
+       SND_PCI_QUIRK(0x103c, 0x30b2, "HP DV2000T/DV3000T", CXT5047_LAPTOP),
+       SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP),
+       SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD),
+       {}
+};
+
+static int patch_cxt5047(struct hda_codec *codec)
+{
+       struct conexant_spec *spec;
+       int board_config;
+
+       spec = kzalloc(sizeof(*spec), GFP_KERNEL);
+       if (!spec)
+               return -ENOMEM;
+       mutex_init(&spec->amp_mutex);
+       codec->spec = spec;
+
+       spec->multiout.max_channels = 2;
+       spec->multiout.num_dacs = ARRAY_SIZE(cxt5047_dac_nids);
+       spec->multiout.dac_nids = cxt5047_dac_nids;
+       spec->multiout.dig_out_nid = CXT5047_SPDIF_OUT;
+       spec->num_adc_nids = 1;
+       spec->adc_nids = cxt5047_adc_nids;
+       spec->capsrc_nids = cxt5047_capsrc_nids;
+       spec->input_mux = &cxt5047_capture_source;
+       spec->num_mixers = 1;
+       spec->mixers[0] = cxt5047_mixers;
+       spec->num_init_verbs = 1;
+       spec->init_verbs[0] = cxt5047_init_verbs;
+       spec->spdif_route = 0;
+       spec->num_channel_mode = ARRAY_SIZE(cxt5047_modes),
+       spec->channel_mode = cxt5047_modes,
+
+       codec->patch_ops = conexant_patch_ops;
+       codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
+
+       board_config = snd_hda_check_board_config(codec, CXT5047_MODELS,
+                                                 cxt5047_models,
+                                                 cxt5047_cfg_tbl);
+       switch (board_config) {
+       case CXT5047_LAPTOP:
+               break;
+       case CXT5047_LAPTOP_HP:
+               spec->input_mux = &cxt5047_hp_capture_source;
+               spec->num_init_verbs = 2;
+               spec->init_verbs[1] = cxt5047_hp_init_verbs;
+               spec->mixers[0] = cxt5047_hp_mixers;
+               codec->patch_ops.init = cxt5047_hp_init;
+               break;
+       case CXT5047_LAPTOP_EAPD:
+               spec->num_init_verbs = 2;
+               spec->init_verbs[1] = cxt5047_toshiba_init_verbs;
+               break;
+#ifdef CONFIG_SND_DEBUG
+       case CXT5047_TEST:
+               spec->input_mux = &cxt5047_test_capture_source;
+               spec->mixers[0] = cxt5047_test_mixer;
+               spec->init_verbs[0] = cxt5047_test_init_verbs;
+#endif 
+       }
+       return 0;
+}
+
+struct hda_codec_preset snd_hda_preset_conexant[] = {
+       { .id = 0x14f15045, .name = "CXT5045", .patch = patch_cxt5045 },
+       { .id = 0x14f15047, .name = "CXT5047", .patch = patch_cxt5047 },
+       {} /* terminator */
+};
index 4e0c3c1b908b927bfc1836cb9843fb827bccf0cd..145682b7807124430dbcec680668a2f01b64b7a2 100644 (file)
 #include "hda_codec.h"
 #include "hda_local.h"
 
+#define ALC880_FRONT_EVENT             0x01
+#define ALC880_DCVOL_EVENT             0x02
+#define ALC880_HP_EVENT                        0x04
+#define ALC880_MIC_EVENT               0x08
 
 /* ALC880 board config type */
 enum {
@@ -48,7 +52,10 @@ enum {
        ALC880_ASUS_DIG,
        ALC880_ASUS_W1V,
        ALC880_ASUS_DIG2,
+       ALC880_FUJITSU,
        ALC880_UNIWILL_DIG,
+       ALC880_UNIWILL,
+       ALC880_UNIWILL_P53,
        ALC880_CLEVO,
        ALC880_TCL_S700,
        ALC880_LG,
@@ -77,8 +84,12 @@ enum {
 /* ALC262 models */
 enum {
        ALC262_BASIC,
+       ALC262_HIPPO,
+       ALC262_HIPPO_1,
        ALC262_FUJITSU,
        ALC262_HP_BPC,
+       ALC262_HP_BPC_D7000_WL,
+       ALC262_HP_BPC_D7000_WF,
        ALC262_BENQ_ED8,
        ALC262_AUTO,
        ALC262_MODEL_LAST /* last tag */
@@ -91,16 +102,30 @@ enum {
        ALC861_3ST_DIG,
        ALC861_6ST_DIG,
        ALC861_UNIWILL_M31,
+       ALC861_TOSHIBA,
+       ALC861_ASUS,
+       ALC861_ASUS_LAPTOP,
        ALC861_AUTO,
        ALC861_MODEL_LAST,
 };
 
+/* ALC861-VD models */
+enum {
+       ALC660VD_3ST,
+       ALC861VD_3ST,
+       ALC861VD_3ST_DIG,
+       ALC861VD_6ST_DIG,
+       ALC861VD_AUTO,
+       ALC861VD_MODEL_LAST,
+};
+
 /* ALC882 models */
 enum {
        ALC882_3ST_DIG,
        ALC882_6ST_DIG,
        ALC882_ARIMA,
        ALC882_AUTO,
+       ALC885_MACPRO,
        ALC882_MODEL_LAST,
 };
 
@@ -110,8 +135,12 @@ enum {
        ALC883_3ST_6ch_DIG,
        ALC883_3ST_6ch,
        ALC883_6ST_DIG,
+       ALC883_TARGA_DIG,
+       ALC883_TARGA_2ch_DIG,
        ALC888_DEMO_BOARD,
        ALC883_ACER,
+       ALC883_MEDION,
+       ALC883_LAPTOP_EAPD,
        ALC883_AUTO,
        ALC883_MODEL_LAST,
 };
@@ -1015,6 +1044,60 @@ static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
        { } /* end */
 };
 
+/* Uniwill */
+static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
+       HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
+       HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
+       HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
+       HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
+       HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
+       HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
+       HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
+       HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
+       HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
+       HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
+       HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
+       HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
+       HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
+       HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
+       HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
+       HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
+       HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
+       HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               .name = "Channel Mode",
+               .info = alc_ch_mode_info,
+               .get = alc_ch_mode_get,
+               .put = alc_ch_mode_put,
+       },
+       { } /* end */
+};
+
+static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
+       HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
+       HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
+       HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
+       HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
+       HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
+       HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
+       HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
+       HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
+       HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
+       HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
+       { } /* end */
+};
+
+static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
+       HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
+       HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
+       HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
+       HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
+       HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
+       HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
+       { } /* end */
+};
+
 /*
  * build control elements
  */
@@ -1248,6 +1331,159 @@ static struct hda_verb alc880_pin_6stack_init_verbs[] = {
        { }
 };
 
+/*
+ * Uniwill pin configuration:
+ * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
+ * line = 0x1a
+ */
+static struct hda_verb alc880_uniwill_init_verbs[] = {
+       {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
+
+       {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
+       {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
+       {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
+       {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
+       {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
+       {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
+       {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
+       {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
+       {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
+       {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
+
+       {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
+       {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
+       {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
+       {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
+       {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
+       {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
+       /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
+       /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
+       {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
+
+       {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
+       {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
+
+       { }
+};
+
+/*
+* Uniwill P53
+* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19, 
+ */
+static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
+       {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
+
+       {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
+       {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
+       {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
+       {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
+       {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
+       {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
+       {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
+       {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
+       {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
+
+       {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
+       {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
+       {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
+       {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
+       {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
+       {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
+
+       {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
+       {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
+
+       { }
+};
+
+static struct hda_verb alc880_beep_init_verbs[] = {
+       { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
+       { }
+};
+
+/* toggle speaker-output according to the hp-jack state */
+static void alc880_uniwill_automute(struct hda_codec *codec)
+{
+       unsigned int present;
+
+       present = snd_hda_codec_read(codec, 0x14, 0,
+                                    AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
+       snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
+                                0x80, present ? 0x80 : 0);
+       snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
+                                0x80, present ? 0x80 : 0);
+       snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
+                                0x80, present ? 0x80 : 0);
+       snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
+                                0x80, present ? 0x80 : 0);
+
+       present = snd_hda_codec_read(codec, 0x18, 0,
+                                    AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
+       snd_hda_codec_write(codec, 0x0b, 0, AC_VERB_SET_AMP_GAIN_MUTE,
+                           0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
+}
+
+static void alc880_uniwill_unsol_event(struct hda_codec *codec,
+                                      unsigned int res)
+{
+       /* Looks like the unsol event is incompatible with the standard
+        * definition.  4bit tag is placed at 28 bit!
+        */
+       if ((res >> 28) == ALC880_HP_EVENT ||
+           (res >> 28) == ALC880_MIC_EVENT)
+               alc880_uniwill_automute(codec);
+}
+
+static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
+{
+       unsigned int present;
+
+       present = snd_hda_codec_read(codec, 0x14, 0,
+                                    AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
+
+       snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0,
+                                0x80, present ? 0x80 : 0);
+       snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
+                                0x80, present ? 0x80 : 0);
+}
+
+static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
+{
+       unsigned int present;
+       
+       present = snd_hda_codec_read(codec, 0x21, 0,
+                                    AC_VERB_GET_VOLUME_KNOB_CONTROL, 0) & 0x7f;
+
+       snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
+                                0x7f, present);
+       snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
+                                0x7f,  present);
+
+       snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
+                                0x7f,  present);
+       snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
+                                0x7f, present);
+
+}
+static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
+                                          unsigned int res)
+{
+       /* Looks like the unsol event is incompatible with the standard
+        * definition.  4bit tag is placed at 28 bit!
+        */
+       if ((res >> 28) == ALC880_HP_EVENT)
+               alc880_uniwill_p53_hp_automute(codec);
+       if ((res >> 28) == ALC880_DCVOL_EVENT) 
+               alc880_uniwill_p53_dcvol_automute(codec);
+}
+
 /* FIXME! */
 /*
  * F1734 pin configuration:
@@ -2125,159 +2361,112 @@ static struct hda_verb alc880_test_init_verbs[] = {
 /*
  */
 
-static struct hda_board_config alc880_cfg_tbl[] = {
-       /* Back 3 jack, front 2 jack */
-       { .modelname = "3stack", .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe200, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe201, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe202, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe203, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe204, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe205, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe206, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe207, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe208, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe209, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20a, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20b, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20c, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20d, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20e, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20f, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe210, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe211, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe212, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe213, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe214, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe234, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe302, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe303, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe304, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe306, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe307, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe404, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xa101, .config = ALC880_3ST },
-       { .pci_subvendor = 0x107b, .pci_subdevice = 0x3031, .config = ALC880_3ST },
-       { .pci_subvendor = 0x107b, .pci_subdevice = 0x4036, .config = ALC880_3ST },
-       { .pci_subvendor = 0x107b, .pci_subdevice = 0x4037, .config = ALC880_3ST },
-       { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST },
-       { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST },
-       { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST },
-       /* TCL S700 */
-       { .modelname = "tcl", .config = ALC880_TCL_S700 },
-       { .pci_subvendor = 0x19db, .pci_subdevice = 0x4188, .config = ALC880_TCL_S700 },
-
-       /* Back 3 jack, front 2 jack (Internal add Aux-In) */
-       { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST },
-       { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST }, 
-       { .pci_subvendor = 0x104d, .pci_subdevice = 0x81a0, .config = ALC880_3ST },
-
-       /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */
-       { .modelname = "3stack-digout", .config = ALC880_3ST_DIG },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG },
-       { .pci_subvendor = 0x1025, .pci_subdevice = 0x0070, .config = ALC880_3ST_DIG },
-
-       /* Clevo laptops */
-       { .modelname = "clevo", .config = ALC880_CLEVO },
-       { .pci_subvendor = 0x1558, .pci_subdevice = 0x0520,
-         .config = ALC880_CLEVO }, /* Clevo m520G NB */
-       { .pci_subvendor = 0x1558, .pci_subdevice = 0x0660,
-         .config = ALC880_CLEVO }, /* Clevo m665n */
-
-       /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xd402, .config = ALC880_3ST_DIG },
-       { .pci_subvendor = 0x1025, .pci_subdevice = 0xe309, .config = ALC880_3ST_DIG },
-
-       /* Back 5 jack, front 2 jack */
-       { .modelname = "5stack", .config = ALC880_5ST },
-       { .pci_subvendor = 0x107b, .pci_subdevice = 0x3033, .config = ALC880_5ST },
-       { .pci_subvendor = 0x107b, .pci_subdevice = 0x4039, .config = ALC880_5ST },
-       { .pci_subvendor = 0x107b, .pci_subdevice = 0x3032, .config = ALC880_5ST },
-       { .pci_subvendor = 0x103c, .pci_subdevice = 0x2a09, .config = ALC880_5ST },
-       { .pci_subvendor = 0x1043, .pci_subdevice = 0x814e, .config = ALC880_5ST },
-
-       /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */
-       { .modelname = "5stack-digout", .config = ALC880_5ST_DIG },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe224, .config = ALC880_5ST_DIG },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe400, .config = ALC880_5ST_DIG },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe401, .config = ALC880_5ST_DIG },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe402, .config = ALC880_5ST_DIG },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xd400, .config = ALC880_5ST_DIG },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xd401, .config = ALC880_5ST_DIG },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG },
-       { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG },
-       { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG },
-       { .pci_subvendor = 0xa0a0, .pci_subdevice = 0x0560,
-         .config = ALC880_5ST_DIG }, /* Aopen i915GMm-HFS */
-       /* { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG }, */ /* conflict with 6stack */
-       { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG },
-       /* note subvendor = 0 below */
-       /* { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG }, */
-
-       { .modelname = "w810", .config = ALC880_W810 },
-       { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 },
-
-       { .modelname = "z71v", .config = ALC880_Z71V },
-       { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V },
-
-       { .modelname = "6stack", .config = ALC880_6ST },
-       { .pci_subvendor = 0x1043, .pci_subdevice = 0x8196, .config = ALC880_6ST }, /* ASUS P5GD1-HVM */
-       { .pci_subvendor = 0x1043, .pci_subdevice = 0x81b4, .config = ALC880_6ST },
-       { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */
-       { .pci_subvendor = 0x1458, .pci_subdevice = 0xa102, .config = ALC880_6ST }, /* Gigabyte K8N51 */
-
-       { .modelname = "6stack-digout", .config = ALC880_6ST_DIG },
-       { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG },
-       { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG },
-       { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG },
-       { .pci_subvendor = 0x1039, .pci_subdevice = 0x1234, .config = ALC880_6ST_DIG },
-       { .pci_subvendor = 0x1025, .pci_subdevice = 0x0077, .config = ALC880_6ST_DIG },
-       { .pci_subvendor = 0x1025, .pci_subdevice = 0x0078, .config = ALC880_6ST_DIG },
-       { .pci_subvendor = 0x1025, .pci_subdevice = 0x0087, .config = ALC880_6ST_DIG },
-       { .pci_subvendor = 0x1297, .pci_subdevice = 0xc790, .config = ALC880_6ST_DIG }, /* Shuttle ST20G5 */
-       { .pci_subvendor = 0x1509, .pci_subdevice = 0x925d, .config = ALC880_6ST_DIG }, /* FIC P4M-915GD1 */
-       { .pci_subvendor = 0x1695, .pci_subdevice = 0x4012, .config = ALC880_5ST_DIG }, /* Epox EP-5LDA+ GLi */
-
-       { .modelname = "asus", .config = ALC880_ASUS },
-       { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG },
-       { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG },
-       { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG },
-       { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG },
-       { .pci_subvendor = 0x1043, .pci_subdevice = 0x1173, .config = ALC880_ASUS_DIG },
-       { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS },
-       { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c2, .config = ALC880_ASUS_DIG }, /* Asus W6A */
-       { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG },
-       { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS },
-       { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG },
-       { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS },
-       { .modelname = "asus-w1v", .config = ALC880_ASUS_W1V },
-       { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V },
-       { .modelname = "asus-dig", .config = ALC880_ASUS_DIG },
-       { .pci_subvendor = 0x1043, .pci_subdevice = 0x8181, .config = ALC880_ASUS_DIG }, /* ASUS P4GPL-X */
-       { .modelname = "asus-dig2", .config = ALC880_ASUS_DIG2 },
-       { .pci_subvendor = 0x1558, .pci_subdevice = 0x5401, .config = ALC880_ASUS_DIG2 },
-
-       { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG },
-       { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG },     
-
-       { .modelname = "F1734", .config = ALC880_F1734 },
-       { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 },
-       { .pci_subvendor = 0x1584, .pci_subdevice = 0x9054, .config = ALC880_F1734 },
-
-       { .modelname = "lg", .config = ALC880_LG },
-       { .pci_subvendor = 0x1854, .pci_subdevice = 0x003b, .config = ALC880_LG },
-       { .pci_subvendor = 0x1854, .pci_subdevice = 0x0068, .config = ALC880_LG },
-
-       { .modelname = "lg-lw", .config = ALC880_LG_LW },
-       { .pci_subvendor = 0x1854, .pci_subdevice = 0x0018, .config = ALC880_LG_LW },
-       { .pci_subvendor = 0x1854, .pci_subdevice = 0x0077, .config = ALC880_LG_LW },
-
+static const char *alc880_models[ALC880_MODEL_LAST] = {
+       [ALC880_3ST]            = "3stack",
+       [ALC880_TCL_S700]       = "tcl",
+       [ALC880_3ST_DIG]        = "3stack-digout",
+       [ALC880_CLEVO]          = "clevo",
+       [ALC880_5ST]            = "5stack",
+       [ALC880_5ST_DIG]        = "5stack-digout",
+       [ALC880_W810]           = "w810",
+       [ALC880_Z71V]           = "z71v",
+       [ALC880_6ST]            = "6stack",
+       [ALC880_6ST_DIG]        = "6stack-digout",
+       [ALC880_ASUS]           = "asus",
+       [ALC880_ASUS_W1V]       = "asus-w1v",
+       [ALC880_ASUS_DIG]       = "asus-dig",
+       [ALC880_ASUS_DIG2]      = "asus-dig2",
+       [ALC880_UNIWILL_DIG]    = "uniwill",
+       [ALC880_UNIWILL_P53]    = "uniwill-p53",
+       [ALC880_FUJITSU]        = "fujitsu",
+       [ALC880_F1734]          = "F1734",
+       [ALC880_LG]             = "lg",
+       [ALC880_LG_LW]          = "lg-lw",
 #ifdef CONFIG_SND_DEBUG
-       { .modelname = "test", .config = ALC880_TEST },
+       [ALC880_TEST]           = "test",
 #endif
-       { .modelname = "auto", .config = ALC880_AUTO },
+       [ALC880_AUTO]           = "auto",
+};
+
+static struct snd_pci_quirk alc880_cfg_tbl[] = {
+       /* Broken BIOS configuration */
+       SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
+       SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
+
+       SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
+       SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
+       SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
+       SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
+       SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
+       SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
+       SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
+       SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
+       SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
+
+       SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
+       SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
+
+       SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
+       SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
+       SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
+       SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
+       SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
+       SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
+       SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
+       /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
+       SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
+       SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
+       SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
+       SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
+       SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
+       SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
+       SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
+
+       SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
+       SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
+       SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
+       SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
+       SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
+       SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
+       SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
+       SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
+       SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
+       SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
+       SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
+       SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
+       SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
+       SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
+       SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
+       SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
+       SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
+       SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
+
+       SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
+       SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
+       SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
+       SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
+
+       SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
+       SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
+       SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
+       SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
+
+       SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
+       SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
+       SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
+       SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
+
+       SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
+       SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
+       SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
+       SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
+       SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
+       SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
+       SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
+       SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
+       SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
+       SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
+       SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
 
        {}
 };
@@ -2438,7 +2627,8 @@ static struct alc_config_preset alc880_presets[] = {
        },
        [ALC880_UNIWILL_DIG] = {
                .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
-               .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs },
+               .init_verbs = { alc880_volume_init_verbs,
+                               alc880_pin_asus_init_verbs },
                .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
                .dac_nids = alc880_asus_dac_nids,
                .dig_out_nid = ALC880_DIGOUT_NID,
@@ -2447,6 +2637,46 @@ static struct alc_config_preset alc880_presets[] = {
                .need_dac_fix = 1,
                .input_mux = &alc880_capture_source,
        },
+       [ALC880_UNIWILL] = {
+               .mixers = { alc880_uniwill_mixer },
+               .init_verbs = { alc880_volume_init_verbs,
+                               alc880_uniwill_init_verbs },
+               .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
+               .dac_nids = alc880_asus_dac_nids,
+               .dig_out_nid = ALC880_DIGOUT_NID,
+               .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
+               .channel_mode = alc880_threestack_modes,
+               .need_dac_fix = 1,
+               .input_mux = &alc880_capture_source,
+               .unsol_event = alc880_uniwill_unsol_event,
+               .init_hook = alc880_uniwill_automute,
+       },
+       [ALC880_UNIWILL_P53] = {
+               .mixers = { alc880_uniwill_p53_mixer },
+               .init_verbs = { alc880_volume_init_verbs,
+                               alc880_uniwill_p53_init_verbs },
+               .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
+               .dac_nids = alc880_asus_dac_nids,
+               .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
+               .channel_mode = alc880_threestack_modes,
+               .input_mux = &alc880_capture_source,
+               .unsol_event = alc880_uniwill_p53_unsol_event,
+               .init_hook = alc880_uniwill_p53_hp_automute,
+       },
+       [ALC880_FUJITSU] = {
+               .mixers = { alc880_fujitsu_mixer, 
+                           alc880_pcbeep_mixer, },
+               .init_verbs = { alc880_volume_init_verbs,
+                               alc880_uniwill_p53_init_verbs,
+                               alc880_beep_init_verbs },
+               .num_dacs = ARRAY_SIZE(alc880_dac_nids),
+               .dac_nids = alc880_dac_nids,
+               .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
+               .channel_mode = alc880_2_jack_modes,
+               .input_mux = &alc880_capture_source,
+               .unsol_event = alc880_uniwill_p53_unsol_event,
+               .init_hook = alc880_uniwill_p53_hp_automute,
+       },
        [ALC880_CLEVO] = {
                .mixers = { alc880_three_stack_mixer },
                .init_verbs = { alc880_volume_init_verbs,
@@ -2841,8 +3071,10 @@ static int patch_alc880(struct hda_codec *codec)
 
        codec->spec = spec;
 
-       board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl);
-       if (board_config < 0 || board_config >= ALC880_MODEL_LAST) {
+       board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
+                                                 alc880_models,
+                                                 alc880_cfg_tbl);
+       if (board_config < 0) {
                printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
                       "trying auto-probe from BIOS...\n");
                board_config = ALC880_AUTO;
@@ -3090,11 +3322,20 @@ static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
  * and the output jack.  If this turns out to be the case for all such
  * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
  * to ALC_PIN_DIR_INOUT_NOMICBIAS.
+ *
+ * The C20x Tablet series have a mono internal speaker which is controlled
+ * via the chip's Mono sum widget and pin complex, so include the necessary
+ * controls for such models.  On models without a "mono speaker" the control
+ * won't do anything.
  */
 static struct snd_kcontrol_new alc260_acer_mixer[] = {
        HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
        HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
        ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
+       HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
+                             HDA_OUTPUT),
+       HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
+                          HDA_INPUT),
        HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
        HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
        HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
@@ -3409,11 +3650,11 @@ static struct hda_verb alc260_acer_init_verbs[] = {
        {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
        /* Line In jack is connected to Line1 pin */
        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
+       /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
+       {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
        /* Ensure all other unused pins are disabled and muted. */
        {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
        {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
-       {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
-       {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
        {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
        {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
@@ -3441,6 +3682,8 @@ static struct hda_verb alc260_acer_init_verbs[] = {
 
        /* Unmute Line-out pin widget amp left and right (no equiv mixer ctrl) */
        {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
+       {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
        /* Unmute Mic1 and Line1 pin widget input buffers since they start as
         * inputs. If the pin mode is changed by the user the pin mode control
         * will take care of enabling the pin's input/output buffers as needed.
@@ -3928,33 +4171,33 @@ static void alc260_auto_init(struct hda_codec *codec)
 /*
  * ALC260 configurations
  */
-static struct hda_board_config alc260_cfg_tbl[] = {
-       { .modelname = "basic", .config = ALC260_BASIC },
-       { .pci_subvendor = 0x104d, .pci_subdevice = 0x81bb,
-         .config = ALC260_BASIC }, /* Sony VAIO */
-       { .pci_subvendor = 0x104d, .pci_subdevice = 0x81cc,
-         .config = ALC260_BASIC }, /* Sony VAIO VGN-S3HP */
-       { .pci_subvendor = 0x104d, .pci_subdevice = 0x81cd,
-         .config = ALC260_BASIC }, /* Sony VAIO */
-       { .pci_subvendor = 0x152d, .pci_subdevice = 0x0729,
-         .config = ALC260_BASIC }, /* CTL Travel Master U553W */
-       { .modelname = "hp", .config = ALC260_HP },
-       { .modelname = "hp-3013", .config = ALC260_HP_3013 },
-       { .pci_subvendor = 0x103c, .pci_subdevice = 0x3010, .config = ALC260_HP_3013 },
-       { .pci_subvendor = 0x103c, .pci_subdevice = 0x3011, .config = ALC260_HP },
-       { .pci_subvendor = 0x103c, .pci_subdevice = 0x3012, .config = ALC260_HP_3013 },
-       { .pci_subvendor = 0x103c, .pci_subdevice = 0x3013, .config = ALC260_HP_3013 },
-       { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014, .config = ALC260_HP },
-       { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015, .config = ALC260_HP },
-       { .pci_subvendor = 0x103c, .pci_subdevice = 0x3016, .config = ALC260_HP },
-       { .modelname = "fujitsu", .config = ALC260_FUJITSU_S702X },
-       { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1326, .config = ALC260_FUJITSU_S702X },
-       { .modelname = "acer", .config = ALC260_ACER },
-       { .pci_subvendor = 0x1025, .pci_subdevice = 0x008f, .config = ALC260_ACER },
+static const char *alc260_models[ALC260_MODEL_LAST] = {
+       [ALC260_BASIC]          = "basic",
+       [ALC260_HP]             = "hp",
+       [ALC260_HP_3013]        = "hp-3013",
+       [ALC260_FUJITSU_S702X]  = "fujitsu",
+       [ALC260_ACER]           = "acer",
 #ifdef CONFIG_SND_DEBUG
-       { .modelname = "test", .config = ALC260_TEST },
+       [ALC260_TEST]           = "test",
 #endif
-       { .modelname = "auto", .config = ALC260_AUTO },
+       [ALC260_AUTO]           = "auto",
+};
+
+static struct snd_pci_quirk alc260_cfg_tbl[] = {
+       SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
+       SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
+       SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
+       SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
+       SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
+       SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
+       SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
+       SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
+       SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
+       SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
+       SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
+       SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
+       SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
+       SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
        {}
 };
 
@@ -4053,8 +4296,10 @@ static int patch_alc260(struct hda_codec *codec)
 
        codec->spec = spec;
 
-       board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl);
-       if (board_config < 0 || board_config >= ALC260_MODEL_LAST) {
+       board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
+                                                 alc260_models,
+                                                 alc260_cfg_tbl);
+       if (board_config < 0) {
                snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
                           "trying auto-probe from BIOS...\n");
                board_config = ALC260_AUTO;
@@ -4207,8 +4452,10 @@ static struct snd_kcontrol_new alc882_base_mixer[] = {
        HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
        HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
+       HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
        HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
        HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
+       HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
        HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
        HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
        HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
@@ -4313,6 +4560,100 @@ static struct hda_verb alc882_eapd_verbs[] = {
        { } 
 };
 
+/* Mac Pro test */
+static struct snd_kcontrol_new alc882_macpro_mixer[] = {
+       HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
+       HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
+       HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
+       HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
+       HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
+       HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
+       HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
+       { } /* end */
+};
+
+static struct hda_verb alc882_macpro_init_verbs[] = {
+       /* Front mixer: unmute input/output amp left and right (volume = 0) */
+       {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
+       {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
+       {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
+       /* Front Pin: output 0 (0x0c) */
+       {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
+       {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
+       /* Front Mic pin: input vref at 80% */
+       {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
+       {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
+       /* Speaker:  output */
+       {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
+       {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
+       /* Headphone output (output 0 - 0x0c) */
+       {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
+       {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
+
+       /* FIXME: use matrix-type input source selection */
+       /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
+       /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
+       {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+       {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
+       {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
+       {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
+       /* Input mixer2 */
+       {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+       {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
+       {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
+       {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
+       /* Input mixer3 */
+       {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+       {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
+       {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
+       {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
+       /* ADC1: mute amp left and right */
+       {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
+       {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
+       /* ADC2: mute amp left and right */
+       {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
+       {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
+       /* ADC3: mute amp left and right */
+       {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
+       {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
+
+       { }
+};
+static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
+{
+       unsigned int gpiostate, gpiomask, gpiodir;
+
+       gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
+                                      AC_VERB_GET_GPIO_DATA, 0);
+
+       if (!muted)
+               gpiostate |= (1 << pin);
+       else
+               gpiostate &= ~(1 << pin);
+
+       gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
+                                     AC_VERB_GET_GPIO_MASK, 0);
+       gpiomask |= (1 << pin);
+
+       gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
+                                    AC_VERB_GET_GPIO_DIRECTION, 0);
+       gpiodir |= (1 << pin);
+
+
+       snd_hda_codec_write(codec, codec->afg, 0,
+                           AC_VERB_SET_GPIO_MASK, gpiomask);
+       snd_hda_codec_write(codec, codec->afg, 0,
+                           AC_VERB_SET_GPIO_DIRECTION, gpiodir);
+
+       msleep(1);
+
+       snd_hda_codec_write(codec, codec->afg, 0,
+                           AC_VERB_SET_GPIO_DATA, gpiostate);
+}
+
 /*
  * generic initialization of ADC, input mixers and output mixers
  */
@@ -4435,19 +4776,20 @@ static struct snd_kcontrol_new alc882_capture_mixer[] = {
 /*
  * configuration and preset
  */
-static struct hda_board_config alc882_cfg_tbl[] = {
-       { .modelname = "3stack-dig", .config = ALC882_3ST_DIG },
-       { .modelname = "6stack-dig", .config = ALC882_6ST_DIG },
-       { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668,
-         .config = ALC882_6ST_DIG }, /* MSI  */
-       { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668,
-         .config = ALC882_6ST_DIG }, /* Foxconn */
-       { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668,
-         .config = ALC882_6ST_DIG }, /* ECS to Intel*/
-       { .modelname = "arima", .config = ALC882_ARIMA },
-       { .pci_subvendor = 0x161f, .pci_subdevice = 0x2054,
-         .config = ALC882_ARIMA }, /* Arima W820Di1 */
-       { .modelname = "auto", .config = ALC882_AUTO },
+static const char *alc882_models[ALC882_MODEL_LAST] = {
+       [ALC882_3ST_DIG]        = "3stack-dig",
+       [ALC882_6ST_DIG]        = "6stack-dig",
+       [ALC882_ARIMA]          = "arima",
+       [ALC885_MACPRO]         = "macpro",
+       [ALC882_AUTO]           = "auto",
+};
+
+static struct snd_pci_quirk alc882_cfg_tbl[] = {
+       SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
+       SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
+       SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
+       SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
+       SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
        {}
 };
 
@@ -4484,6 +4826,17 @@ static struct alc_config_preset alc882_presets[] = {
                .channel_mode = alc882_sixstack_modes,
                .input_mux = &alc882_capture_source,
        },
+       [ALC885_MACPRO] = {
+               .mixers = { alc882_macpro_mixer },
+               .init_verbs = { alc882_macpro_init_verbs },
+               .num_dacs = ARRAY_SIZE(alc882_dac_nids),
+               .dac_nids = alc882_dac_nids,
+               .dig_out_nid = ALC882_DIGOUT_NID,
+               .dig_in_nid = ALC882_DIGIN_NID,
+               .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
+               .channel_mode = alc882_ch_modes,
+               .input_mux = &alc882_capture_source,
+       },
 };
 
 
@@ -4584,7 +4937,9 @@ static int patch_alc882(struct hda_codec *codec)
 
        codec->spec = spec;
 
-       board_config = snd_hda_check_board_config(codec, alc882_cfg_tbl);
+       board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
+                                                 alc882_models,
+                                                 alc882_cfg_tbl);
 
        if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
                printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
@@ -4609,6 +4964,11 @@ static int patch_alc882(struct hda_codec *codec)
        if (board_config != ALC882_AUTO)
                setup_preset(spec, &alc882_presets[board_config]);
 
+       if (board_config == ALC885_MACPRO) {
+               alc882_gpio_mute(codec, 0, 0);
+               alc882_gpio_mute(codec, 1, 0);
+       }
+
        spec->stream_name_analog = "ALC882 Analog";
        spec->stream_analog_playback = &alc882_pcm_analog_playback;
        spec->stream_analog_capture = &alc882_pcm_analog_capture;
@@ -4767,6 +5127,13 @@ static struct hda_channel_mode alc883_sixstack_modes[2] = {
        { 8, alc883_sixstack_ch8_init },
 };
 
+static struct hda_verb alc883_medion_eapd_verbs[] = {
+        /* eanable EAPD on medion laptop */
+       {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
+       {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
+       { }
+};
+
 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  *                 Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  */
@@ -4788,8 +5155,10 @@ static struct snd_kcontrol_new alc883_base_mixer[] = {
        HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
        HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
+       HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
        HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
        HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
+       HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
        HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
        HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
        HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
@@ -4818,8 +5187,10 @@ static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
        HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
        HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
+       HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
        HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
        HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
+       HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
        HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
        HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
        HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
@@ -4854,8 +5225,10 @@ static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
        HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
        HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
+       HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
        HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
        HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
+       HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
        HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
        HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
        HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
@@ -4875,25 +5248,120 @@ static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
        { } /* end */
 };
 
-static struct snd_kcontrol_new alc883_chmode_mixer[] = {
-       {
-               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-               .name = "Channel Mode",
-               .info = alc_ch_mode_info,
-               .get = alc_ch_mode_get,
-               .put = alc_ch_mode_put,
-       },
-       { } /* end */
-};
-
-static struct hda_verb alc883_init_verbs[] = {
-       /* ADC1: mute amp left and right */
-       {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
-       {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
-       /* ADC2: mute amp left and right */
-       {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
-       {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
-       /* Front mixer: unmute input/output amp left and right (volume = 0) */
+static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
+       HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
+       HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
+       HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
+       HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
+       HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
+       HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
+       HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
+       HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
+       HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
+       HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
+       HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
+       HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
+       HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
+       HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
+       HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
+       HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
+       HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
+       HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
+
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               /* .name = "Capture Source", */
+               .name = "Input Source",
+               .count = 1,
+               .info = alc883_mux_enum_info,
+               .get = alc883_mux_enum_get,
+               .put = alc883_mux_enum_put,
+       },
+       { } /* end */
+};
+
+static struct snd_kcontrol_new alc883_tagra_mixer[] = {
+       HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
+       HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
+       HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
+       HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
+       HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
+       HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
+       HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
+       HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
+       HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
+       HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
+       HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
+       HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
+       HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
+       HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
+       HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
+       HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
+       HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
+       HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               /* .name = "Capture Source", */
+               .name = "Input Source",
+               .count = 2,
+               .info = alc883_mux_enum_info,
+               .get = alc883_mux_enum_get,
+               .put = alc883_mux_enum_put,
+       },
+       { } /* end */
+};     
+
+static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
+       HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
+       HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
+       HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
+       HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
+       HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
+       HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
+       HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
+       HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
+       HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
+       HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               /* .name = "Capture Source", */
+               .name = "Input Source",
+               .count = 2,
+               .info = alc883_mux_enum_info,
+               .get = alc883_mux_enum_get,
+               .put = alc883_mux_enum_put,
+       },
+       { } /* end */
+};     
+
+static struct snd_kcontrol_new alc883_chmode_mixer[] = {
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               .name = "Channel Mode",
+               .info = alc_ch_mode_info,
+               .get = alc_ch_mode_get,
+               .put = alc_ch_mode_put,
+       },
+       { } /* end */
+};
+
+static struct hda_verb alc883_init_verbs[] = {
+       /* ADC1: mute amp left and right */
+       {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
+       {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
+       /* ADC2: mute amp left and right */
+       {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
+       {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
+       /* Front mixer: unmute input/output amp left and right (volume = 0) */
        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
@@ -4963,6 +5431,45 @@ static struct hda_verb alc883_init_verbs[] = {
        { }
 };
 
+static struct hda_verb alc883_tagra_verbs[] = {
+       {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+       {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
+
+       {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
+       {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
+       
+       {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
+       {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
+       {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
+
+       {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
+       {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, 
+       {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, 
+       {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, 
+
+       { } /* end */
+};
+
+/* toggle speaker-output according to the hp-jack state */
+static void alc883_tagra_automute(struct hda_codec *codec)
+{
+       unsigned int present;
+
+       present = snd_hda_codec_read(codec, 0x14, 0,
+                                    AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
+       snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
+                                0x80, present ? 0x80 : 0);
+       snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
+                                0x80, present ? 0x80 : 0);
+       snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3);
+}
+
+static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
+{
+       if ((res >> 26) == ALC880_HP_EVENT)
+               alc883_tagra_automute(codec);
+}
+
 /*
  * generic initialization of ADC, input mixers and output mixers
  */
@@ -5057,32 +5564,42 @@ static struct snd_kcontrol_new alc883_capture_mixer[] = {
 /*
  * configuration and preset
  */
-static struct hda_board_config alc883_cfg_tbl[] = {
-       { .modelname = "3stack-dig", .config = ALC883_3ST_2ch_DIG },
-       { .modelname = "3stack-6ch-dig", .config = ALC883_3ST_6ch_DIG },
-       { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668,
-         .config = ALC883_3ST_6ch_DIG }, /* ECS to Intel*/
-       { .modelname = "3stack-6ch", .config = ALC883_3ST_6ch },
-       { .pci_subvendor = 0x108e, .pci_subdevice = 0x534d,
-         .config = ALC883_3ST_6ch },
-        { .pci_subvendor = 0x8086, .pci_subdevice = 0xd601,
-          .config = ALC883_3ST_6ch }, /* D102GGC */
-       { .modelname = "6stack-dig", .config = ALC883_6ST_DIG },
-       { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668,
-         .config = ALC883_6ST_DIG }, /* MSI  */
-       { .pci_subvendor = 0x1462, .pci_subdevice = 0x7280,
-         .config = ALC883_6ST_DIG }, /* MSI K9A Platinum (MS-7280) */
-       { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668,
-         .config = ALC883_6ST_DIG }, /* Foxconn */
-       { .modelname = "6stack-dig-demo", .config = ALC888_DEMO_BOARD },
-       { .modelname = "acer", .config = ALC883_ACER },
-       { .pci_subvendor = 0x1025, .pci_subdevice = 0/*0x0102*/,
-         .config = ALC883_ACER },
-       { .pci_subvendor = 0x1025, .pci_subdevice = 0x0102,
-         .config = ALC883_ACER },
-       { .pci_subvendor = 0x1025, .pci_subdevice = 0x009f,
-         .config = ALC883_ACER },
-       { .modelname = "auto", .config = ALC883_AUTO },
+static const char *alc883_models[ALC883_MODEL_LAST] = {
+       [ALC883_3ST_2ch_DIG]    = "3stack-dig",
+       [ALC883_3ST_6ch_DIG]    = "3stack-6ch-dig",
+       [ALC883_3ST_6ch]        = "3stack-6ch",
+       [ALC883_6ST_DIG]        = "6stack-dig",
+       [ALC883_TARGA_DIG]      = "targa-dig",
+       [ALC883_TARGA_2ch_DIG]  = "targa-2ch-dig",
+       [ALC888_DEMO_BOARD]     = "6stack-dig-demo",
+       [ALC883_ACER]           = "acer",
+       [ALC883_MEDION]         = "medion",
+       [ALC883_LAPTOP_EAPD]    = "laptop-eapd",
+       [ALC883_AUTO]           = "auto",
+};
+
+static struct snd_pci_quirk alc883_cfg_tbl[] = {
+       SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
+       SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
+       SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
+       SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
+       SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
+       SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
+       SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
+       SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
+       SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
+       SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
+       SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
+       SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
+       SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
+       SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
+       SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
+       SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
+       SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
+       SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
+       SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
+       SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
+       SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
        {}
 };
 
@@ -5139,6 +5656,35 @@ static struct alc_config_preset alc883_presets[] = {
                .channel_mode = alc883_sixstack_modes,
                .input_mux = &alc883_capture_source,
        },
+       [ALC883_TARGA_DIG] = {
+               .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
+               .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
+               .num_dacs = ARRAY_SIZE(alc883_dac_nids),
+               .dac_nids = alc883_dac_nids,
+               .dig_out_nid = ALC883_DIGOUT_NID,
+               .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
+               .adc_nids = alc883_adc_nids,
+               .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
+               .channel_mode = alc883_3ST_6ch_modes,
+               .need_dac_fix = 1,
+               .input_mux = &alc883_capture_source,
+               .unsol_event = alc883_tagra_unsol_event,
+               .init_hook = alc883_tagra_automute,
+       },
+       [ALC883_TARGA_2ch_DIG] = {
+               .mixers = { alc883_tagra_2ch_mixer},
+               .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
+               .num_dacs = ARRAY_SIZE(alc883_dac_nids),
+               .dac_nids = alc883_dac_nids,
+               .dig_out_nid = ALC883_DIGOUT_NID,
+               .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
+               .adc_nids = alc883_adc_nids,
+               .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
+               .channel_mode = alc883_3ST_2ch_modes,
+               .input_mux = &alc883_capture_source,
+               .unsol_event = alc883_tagra_unsol_event,
+               .init_hook = alc883_tagra_automute,
+       },
        [ALC888_DEMO_BOARD] = {
                .mixers = { alc883_base_mixer, alc883_chmode_mixer },
                .init_verbs = { alc883_init_verbs },
@@ -5169,6 +5715,31 @@ static struct alc_config_preset alc883_presets[] = {
                .channel_mode = alc883_3ST_2ch_modes,
                .input_mux = &alc883_capture_source,
        },
+       [ALC883_MEDION] = {
+               .mixers = { alc883_fivestack_mixer,
+                           alc883_chmode_mixer },
+               .init_verbs = { alc883_init_verbs,
+                               alc883_medion_eapd_verbs },
+               .num_dacs = ARRAY_SIZE(alc883_dac_nids),
+               .dac_nids = alc883_dac_nids,
+               .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
+               .adc_nids = alc883_adc_nids,
+               .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
+               .channel_mode = alc883_sixstack_modes,
+               .input_mux = &alc883_capture_source,
+       },
+       [ALC883_LAPTOP_EAPD] = {
+               .mixers = { alc883_base_mixer,
+                           alc883_chmode_mixer },
+               .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
+               .num_dacs = ARRAY_SIZE(alc883_dac_nids),
+               .dac_nids = alc883_dac_nids,
+               .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
+               .adc_nids = alc883_adc_nids,
+               .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
+               .channel_mode = alc883_3ST_2ch_modes,
+               .input_mux = &alc883_capture_source,
+       },
 };
 
 
@@ -5277,8 +5848,10 @@ static int patch_alc883(struct hda_codec *codec)
 
        codec->spec = spec;
 
-       board_config = snd_hda_check_board_config(codec, alc883_cfg_tbl);
-       if (board_config < 0 || board_config >= ALC883_MODEL_LAST) {
+       board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
+                                                 alc883_models,
+                                                 alc883_cfg_tbl);
+       if (board_config < 0) {
                printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
                       "trying auto-probe from BIOS...\n");
                board_config = ALC883_AUTO;
@@ -5355,6 +5928,24 @@ static struct snd_kcontrol_new alc262_base_mixer[] = {
        { } /* end */
 };
 
+static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
+       HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
+       HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
+       HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
+       HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
+       HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
+       HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
+       HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
+       HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
+       HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
+       /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
+          HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
+       /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
+       HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
+       { } /* end */
+};
+
 static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
        HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
@@ -5377,6 +5968,30 @@ static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
        { } /* end */
 };
 
+static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
+       HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
+       HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
+       HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
+       HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
+       HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
+       HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
+       HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
+       HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
+       HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
+       HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
+       HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
+       { } /* end */
+};
+
+static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
+       HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
+       HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
+       { } /* end */
+};
+
 #define alc262_capture_mixer           alc882_capture_mixer
 #define alc262_capture_alt_mixer       alc882_capture_alt_mixer
 
@@ -5459,40 +6074,24 @@ static struct hda_verb alc262_init_verbs[] = {
        { }
 };
 
-/*
- * fujitsu model
- *  0x14 = headphone/spdif-out, 0x15 = internal speaker
- */
-
-#define ALC_HP_EVENT   0x37
-
-static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
-       {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
-       {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
+static struct hda_verb alc262_hippo_unsol_verbs[] = {
+       {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
+       {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
        {}
 };
 
-static struct hda_input_mux alc262_fujitsu_capture_source = {
-       .num_items = 2,
-       .items = {
-               { "Mic", 0x0 },
-               { "CD", 0x4 },
-       },
-};
+static struct hda_verb alc262_hippo1_unsol_verbs[] = {
+       {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
+       {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
+       {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
 
-static struct hda_input_mux alc262_HP_capture_source = {
-       .num_items = 5,
-       .items = {
-               { "Mic", 0x0 },
-               { "Front Mic", 0x3 },
-               { "Line", 0x2 },
-               { "CD", 0x4 },
-               { "AUX IN", 0x6 },
-       },
+       {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
+       {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
+       {}
 };
 
 /* mute/unmute internal speaker according to the hp jack and mute state */
-static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
+static void alc262_hippo_automute(struct hda_codec *codec, int force)
 {
        struct alc_spec *spec = codec->spec;
        unsigned int mute;
@@ -5500,52 +6099,165 @@ static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
        if (force || ! spec->sense_updated) {
                unsigned int present;
                /* need to execute and sync at first */
-               snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
-               present = snd_hda_codec_read(codec, 0x14, 0,
+               snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
+               present = snd_hda_codec_read(codec, 0x15, 0,
                                         AC_VERB_GET_PIN_SENSE, 0);
                spec->jack_present = (present & 0x80000000) != 0;
                spec->sense_updated = 1;
        }
        if (spec->jack_present) {
                /* mute internal speaker */
-               snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
+               snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
                                         0x80, 0x80);
-               snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
+               snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
                                         0x80, 0x80);
        } else {
                /* unmute internal speaker if necessary */
-               mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
-               snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
+               mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
+               snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
                                         0x80, mute & 0x80);
-               mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
-               snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
+               mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0);
+               snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
                                         0x80, mute & 0x80);
        }
 }
 
 /* unsolicited event for HP jack sensing */
-static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
+static void alc262_hippo_unsol_event(struct hda_codec *codec,
                                       unsigned int res)
 {
-       if ((res >> 26) != ALC_HP_EVENT)
+       if ((res >> 26) != ALC880_HP_EVENT)
                return;
-       alc262_fujitsu_automute(codec, 1);
+       alc262_hippo_automute(codec, 1);
 }
 
-/* bind volumes of both NID 0x0c and 0x0d */
-static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
-                                        struct snd_ctl_elem_value *ucontrol)
+static void alc262_hippo1_automute(struct hda_codec *codec, int force)
 {
-       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
-       long *valp = ucontrol->value.integer.value;
-       int change;
+       struct alc_spec *spec = codec->spec;
+       unsigned int mute;
 
-       change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
-                                         0x7f, valp[0] & 0x7f);
-       change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
-                                          0x7f, valp[1] & 0x7f);
-       snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
-                                0x7f, valp[0] & 0x7f);
+       if (force || ! spec->sense_updated) {
+               unsigned int present;
+               /* need to execute and sync at first */
+               snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
+               present = snd_hda_codec_read(codec, 0x1b, 0,
+                                        AC_VERB_GET_PIN_SENSE, 0);
+               spec->jack_present = (present & 0x80000000) != 0;
+               spec->sense_updated = 1;
+       }
+       if (spec->jack_present) {
+               /* mute internal speaker */
+               snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
+                                        0x80, 0x80);
+               snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
+                                        0x80, 0x80);
+       } else {
+               /* unmute internal speaker if necessary */
+               mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
+               snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
+                                        0x80, mute & 0x80);
+               mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0);
+               snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
+                                        0x80, mute & 0x80);
+       }
+}
+
+/* unsolicited event for HP jack sensing */
+static void alc262_hippo1_unsol_event(struct hda_codec *codec,
+                                      unsigned int res)
+{
+       if ((res >> 26) != ALC880_HP_EVENT)
+               return;
+       alc262_hippo1_automute(codec, 1);
+}
+
+/*
+ * fujitsu model
+ *  0x14 = headphone/spdif-out, 0x15 = internal speaker
+ */
+
+#define ALC_HP_EVENT   0x37
+
+static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
+       {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
+       {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
+       {}
+};
+
+static struct hda_input_mux alc262_fujitsu_capture_source = {
+       .num_items = 2,
+       .items = {
+               { "Mic", 0x0 },
+               { "CD", 0x4 },
+       },
+};
+
+static struct hda_input_mux alc262_HP_capture_source = {
+       .num_items = 5,
+       .items = {
+               { "Mic", 0x0 },
+               { "Front Mic", 0x3 },
+               { "Line", 0x2 },
+               { "CD", 0x4 },
+               { "AUX IN", 0x6 },
+       },
+};
+
+/* mute/unmute internal speaker according to the hp jack and mute state */
+static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
+{
+       struct alc_spec *spec = codec->spec;
+       unsigned int mute;
+
+       if (force || ! spec->sense_updated) {
+               unsigned int present;
+               /* need to execute and sync at first */
+               snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
+               present = snd_hda_codec_read(codec, 0x14, 0,
+                                        AC_VERB_GET_PIN_SENSE, 0);
+               spec->jack_present = (present & 0x80000000) != 0;
+               spec->sense_updated = 1;
+       }
+       if (spec->jack_present) {
+               /* mute internal speaker */
+               snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
+                                        0x80, 0x80);
+               snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
+                                        0x80, 0x80);
+       } else {
+               /* unmute internal speaker if necessary */
+               mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
+               snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
+                                        0x80, mute & 0x80);
+               mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
+               snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
+                                        0x80, mute & 0x80);
+       }
+}
+
+/* unsolicited event for HP jack sensing */
+static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
+                                      unsigned int res)
+{
+       if ((res >> 26) != ALC_HP_EVENT)
+               return;
+       alc262_fujitsu_automute(codec, 1);
+}
+
+/* bind volumes of both NID 0x0c and 0x0d */
+static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
+                                        struct snd_ctl_elem_value *ucontrol)
+{
+       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+       long *valp = ucontrol->value.integer.value;
+       int change;
+
+       change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
+                                         0x7f, valp[0] & 0x7f);
+       change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
+                                          0x7f, valp[1] & 0x7f);
+       snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
+                                0x7f, valp[0] & 0x7f);
        snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
                                 0x7f, valp[1] & 0x7f);
        return change;
@@ -5809,6 +6521,100 @@ static struct hda_verb alc262_HP_BPC_init_verbs[] = {
        { }
 };
 
+static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
+       /*
+        * Unmute ADC0-2 and set the default input to mic-in
+        */
+       {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
+       {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+       {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
+       {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+       {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
+       {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+
+       /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
+        * mixer widget
+        * Note: PASD motherboards uses the Line In 2 as the input for front
+        * panel mic (mic 2)
+        */
+       /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
+       {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+       {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
+       {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
+       {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
+       {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
+       {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
+       {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
+       {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
+       /*
+        * Set up output mixers (0x0c - 0x0e)
+        */
+       /* set vol=0 to output mixers */
+       {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
+       {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
+       {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
+
+       /* set up input amps for analog loopback */
+       /* Amp Indices: DAC = 0, mixer = 1 */
+       {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+       {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
+       {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+       {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
+       {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+       {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
+
+
+       {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },        /* HP */
+       {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },       /* Mono */
+       {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },    /* rear MIC */
+       {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },        /* Line in */
+       {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },    /* Front MIC */
+       {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },       /* Line out */
+       {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },        /* CD in */
+
+       {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
+       {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
+
+       {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
+       {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
+
+       /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
+       {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
+       {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
+       {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
+       {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
+       {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
+
+       /* FIXME: use matrix-type input source selection */
+       /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
+       /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
+       {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
+       {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
+       {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
+       {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
+       {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
+        /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))},  */
+       {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
+       /* Input mixer2 */
+       {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
+       {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
+       {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
+       {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
+       {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
+        /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
+       {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
+       /* Input mixer3 */
+       {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
+       {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
+       {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
+       {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
+       {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
+        /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
+       {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
+
+       { }
+};
+
 /* pcm configuration: identiacal with ALC880 */
 #define alc262_pcm_analog_playback     alc880_pcm_analog_playback
 #define alc262_pcm_analog_capture      alc880_pcm_analog_capture
@@ -5866,26 +6672,35 @@ static void alc262_auto_init(struct hda_codec *codec)
 /*
  * configuration and preset
  */
-static struct hda_board_config alc262_cfg_tbl[] = {
-       { .modelname = "basic", .config = ALC262_BASIC },
-       { .modelname = "fujitsu", .config = ALC262_FUJITSU },
-       { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1397,
-         .config = ALC262_FUJITSU },
-       { .modelname = "hp-bpc", .config = ALC262_HP_BPC },
-       { .pci_subvendor = 0x103c, .pci_subdevice = 0x280c,
-         .config = ALC262_HP_BPC }, /* xw4400 */
-       { .pci_subvendor = 0x103c, .pci_subdevice = 0x2801,
-         .config = ALC262_HP_BPC }, /* q965 */
-       { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014,
-         .config = ALC262_HP_BPC }, /* xw6400 */
-       { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015,
-         .config = ALC262_HP_BPC }, /* xw8400 */
-       { .pci_subvendor = 0x103c, .pci_subdevice = 0x12fe,
-         .config = ALC262_HP_BPC }, /* xw9400 */
-       { .modelname = "benq", .config = ALC262_BENQ_ED8 },
-       { .pci_subvendor = 0x17ff, .pci_subdevice = 0x0560,
-         .config = ALC262_BENQ_ED8 },
-       { .modelname = "auto", .config = ALC262_AUTO },
+static const char *alc262_models[ALC262_MODEL_LAST] = {
+       [ALC262_BASIC]          = "basic",
+       [ALC262_HIPPO]          = "hippo",
+       [ALC262_HIPPO_1]        = "hippo_1",
+       [ALC262_FUJITSU]        = "fujitsu",
+       [ALC262_HP_BPC]         = "hp-bpc",
+       [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
+       [ALC262_BENQ_ED8]       = "benq",
+       [ALC262_AUTO]           = "auto",
+};
+
+static struct snd_pci_quirk alc262_cfg_tbl[] = {
+       SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
+       SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
+       SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
+       SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
+       SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
+       SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
+       SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
+       SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
+       SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
+       SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
+       SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
+       SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
+       SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
+       SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
+       SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
+       SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
+       SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
        {}
 };
 
@@ -5900,6 +6715,30 @@ static struct alc_config_preset alc262_presets[] = {
                .channel_mode = alc262_modes,
                .input_mux = &alc262_capture_source,
        },
+       [ALC262_HIPPO] = {
+               .mixers = { alc262_base_mixer },
+               .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
+               .num_dacs = ARRAY_SIZE(alc262_dac_nids),
+               .dac_nids = alc262_dac_nids,
+               .hp_nid = 0x03,
+               .dig_out_nid = ALC262_DIGOUT_NID,
+               .num_channel_mode = ARRAY_SIZE(alc262_modes),
+               .channel_mode = alc262_modes,
+               .input_mux = &alc262_capture_source,
+               .unsol_event = alc262_hippo_unsol_event,
+       },
+       [ALC262_HIPPO_1] = {
+               .mixers = { alc262_hippo1_mixer },
+               .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
+               .num_dacs = ARRAY_SIZE(alc262_dac_nids),
+               .dac_nids = alc262_dac_nids,
+               .hp_nid = 0x02,
+               .dig_out_nid = ALC262_DIGOUT_NID,
+               .num_channel_mode = ARRAY_SIZE(alc262_modes),
+               .channel_mode = alc262_modes,
+               .input_mux = &alc262_capture_source,
+               .unsol_event = alc262_hippo1_unsol_event,
+       },
        [ALC262_FUJITSU] = {
                .mixers = { alc262_fujitsu_mixer },
                .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
@@ -5922,6 +6761,27 @@ static struct alc_config_preset alc262_presets[] = {
                .channel_mode = alc262_modes,
                .input_mux = &alc262_HP_capture_source,
        },      
+       [ALC262_HP_BPC_D7000_WF] = {
+               .mixers = { alc262_HP_BPC_WildWest_mixer },
+               .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
+               .num_dacs = ARRAY_SIZE(alc262_dac_nids),
+               .dac_nids = alc262_dac_nids,
+               .hp_nid = 0x03,
+               .num_channel_mode = ARRAY_SIZE(alc262_modes),
+               .channel_mode = alc262_modes,
+               .input_mux = &alc262_HP_capture_source,
+       },      
+       [ALC262_HP_BPC_D7000_WL] = {
+               .mixers = { alc262_HP_BPC_WildWest_mixer,
+                           alc262_HP_BPC_WildWest_option_mixer },
+               .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
+               .num_dacs = ARRAY_SIZE(alc262_dac_nids),
+               .dac_nids = alc262_dac_nids,
+               .hp_nid = 0x03,
+               .num_channel_mode = ARRAY_SIZE(alc262_modes),
+               .channel_mode = alc262_modes,
+               .input_mux = &alc262_HP_capture_source,
+       },      
        [ALC262_BENQ_ED8] = {
                .mixers = { alc262_base_mixer },
                .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
@@ -5940,7 +6800,7 @@ static int patch_alc262(struct hda_codec *codec)
        int board_config;
        int err;
 
-       spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
+       spec = kzalloc(sizeof(*spec), GFP_KERNEL);
        if (spec == NULL)
                return -ENOMEM;
 
@@ -5956,9 +6816,11 @@ static int patch_alc262(struct hda_codec *codec)
        }
 #endif
 
-       board_config = snd_hda_check_board_config(codec, alc262_cfg_tbl);
-       
-       if (board_config < 0 || board_config >= ALC262_MODEL_LAST) {
+       board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
+                                                 alc262_models,
+                                                 alc262_cfg_tbl);
+
+       if (board_config < 0) {
                printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
                       "trying auto-probe from BIOS...\n");
                board_config = ALC262_AUTO;
@@ -6078,6 +6940,44 @@ static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
        { 4, alc861_uniwill_m31_ch4_init },
 };
 
+/* Set mic1 and line-in as input and unmute the mixer */
+static struct hda_verb alc861_asus_ch2_init[] = {
+       /* set pin widget 1Ah (line in) for input */
+       { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
+       /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
+       { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
+
+       { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
+#if 0
+       { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
+       { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
+#endif
+       { } /* end */
+};
+/* Set mic1 nad line-in as output and mute mixer */
+static struct hda_verb alc861_asus_ch6_init[] = {
+       /* set pin widget 1Ah (line in) for output (Back Surround)*/
+       { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
+       /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
+       /* set pin widget 18h (mic1) for output (CLFE)*/
+       { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
+       /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
+       { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
+       { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
+
+       { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
+#if 0
+       { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
+       { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
+#endif
+       { } /* end */
+};
+
+static struct hda_channel_mode alc861_asus_modes[2] = {
+       { 2, alc861_asus_ch2_init },
+       { 6, alc861_asus_ch6_init },
+};
+
 /* patch-ALC861 */
 
 static struct snd_kcontrol_new alc861_base_mixer[] = {
@@ -6154,17 +7054,39 @@ static struct snd_kcontrol_new alc861_3ST_mixer[] = {
                 .private_value = ARRAY_SIZE(alc861_threestack_modes),
        },
        { } /* end */
-};                     
-static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
-        /* output mixer control */
-       HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
-       HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
-       HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
-       HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
-       /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
+};
 
-       /* Input mixer control */
-       /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
+static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
+        /* output mixer control */
+       HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
+       HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
+       HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
+       
+        /*Capture mixer control */
+       HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
+       HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               .name = "Capture Source",
+               .count = 1,
+               .info = alc_mux_enum_info,
+               .get = alc_mux_enum_get,
+               .put = alc_mux_enum_put,
+       },
+
+       { } /* end */
+};     
+
+static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
+        /* output mixer control */
+       HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
+       /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
+
+       /* Input mixer control */
+       /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
           HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
        HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
        HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
@@ -6196,7 +7118,58 @@ static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
        },
        { } /* end */
 };                     
-       
+
+static struct snd_kcontrol_new alc861_asus_mixer[] = {
+        /* output mixer control */
+       HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
+
+       /* Input mixer control */
+       HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
+       HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
+       HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
+       HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
+       HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
+       HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
+       HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
+       HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
+       HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT), /* was HDA_INPUT (why?) */
+       /* Capture mixer control */
+       HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
+       HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               .name = "Capture Source",
+               .count = 1,
+               .info = alc_mux_enum_info,
+               .get = alc_mux_enum_get,
+               .put = alc_mux_enum_put,
+       },
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               .name = "Channel Mode",
+               .info = alc_ch_mode_info,
+               .get = alc_ch_mode_get,
+               .put = alc_ch_mode_put,
+                .private_value = ARRAY_SIZE(alc861_asus_modes),
+       },
+       { }
+};
+
+/* additional mixer */
+static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
+       HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
+       HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
+       HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
+       { }
+};
+
 /*
  * generic initialization of ADC, input mixers and output mixers
  */
@@ -6217,7 +7190,7 @@ static struct hda_verb alc861_base_init_verbs[] = {
        /* port-E for HP out (front panel) */
        { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
        /* route front PCM to HP */
-       { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
+       { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
        /* port-F for mic-in (front panel) with vref */
        { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
        /* port-G for CLFE (rear panel) */
@@ -6281,7 +7254,7 @@ static struct hda_verb alc861_threestack_init_verbs[] = {
        /* port-E for HP out (front panel) */
        { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
        /* route front PCM to HP */
-       { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
+       { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
        /* port-F for mic-in (front panel) with vref */
        { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
        /* port-G for CLFE (rear panel) */
@@ -6341,7 +7314,7 @@ static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
        /* port-E for HP out (front panel) */
        { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, // this has to be set to VREF80
        /* route front PCM to HP */
-       { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
+       { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
        /* port-F for mic-in (front panel) with vref */
        { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
        /* port-G for CLFE (rear panel) */
@@ -6385,6 +7358,74 @@ static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
        { }
 };
 
+static struct hda_verb alc861_asus_init_verbs[] = {
+       /*
+        * Unmute ADC0 and set the default input to mic-in
+        */
+       /* port-A for surround (rear panel) | according to codec#0 this is the HP jack*/
+       { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
+       /* route front PCM to HP */
+       { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
+       /* port-B for mic-in (rear panel) with vref */
+       { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
+       /* port-C for line-in (rear panel) */
+       { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
+       /* port-D for Front */
+       { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
+       { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
+       /* port-E for HP out (front panel) */
+       { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, /* this has to be set to VREF80 */
+       /* route front PCM to HP */
+       { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
+       /* port-F for mic-in (front panel) with vref */
+       { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
+       /* port-G for CLFE (rear panel) */
+       { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
+       /* port-H for side (rear panel) */
+       { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
+       /* CD-in */
+       { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
+       /* route front mic to ADC1*/
+       {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
+       {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+       /* Unmute DAC0~3 & spdif out*/
+       {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       /* Unmute Mixer 14 (mic) 1c (Line in)*/
+       {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+        {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
+       {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+        {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
+       
+       /* Unmute Stereo Mixer 15 */
+       {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+       {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
+       {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
+       {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c          }, /* Output 0~12 step */
+
+       {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+       {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
+       {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+       {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
+       {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+       {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
+       {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+       {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
+       {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, /* hp used DAC 3 (Front) */
+       {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
+       { }
+};
+
+/* additional init verbs for ASUS laptops */
+static struct hda_verb alc861_asus_laptop_init_verbs[] = {
+       { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
+       { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
+       { }
+};
+
 /*
  * generic initialization of ADC, input mixers and output mixers
  */
@@ -6437,6 +7478,39 @@ static struct hda_verb alc861_auto_init_verbs[] = {
        { }
 };
 
+static struct hda_verb alc861_toshiba_init_verbs[] = {
+       {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
+        
+       { }
+};
+
+/* toggle speaker-output according to the hp-jack state */
+static void alc861_toshiba_automute(struct hda_codec *codec)
+{
+       unsigned int present;
+
+       present = snd_hda_codec_read(codec, 0x0f, 0,
+                                    AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
+       snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0,
+                                0x80, present ? 0x80 : 0);
+       snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0,
+                                0x80, present ? 0x80 : 0);
+       snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3,
+                                0x80, present ? 0 : 0x80);
+       snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3,
+                                0x80, present ? 0 : 0x80);
+}
+
+static void alc861_toshiba_unsol_event(struct hda_codec *codec,
+                                      unsigned int res)
+{
+       /* Looks like the unsol event is incompatible with the standard
+        * definition.  6bit tag is placed at 26 bit!
+        */
+       if ((res >> 26) == ALC880_HP_EVENT)
+               alc861_toshiba_automute(codec);
+}
+
 /* pcm configuration: identiacal with ALC880 */
 #define alc861_pcm_analog_playback     alc880_pcm_analog_playback
 #define alc861_pcm_analog_capture      alc880_pcm_analog_capture
@@ -6710,19 +7784,29 @@ static void alc861_auto_init(struct hda_codec *codec)
 /*
  * configuration and preset
  */
-static struct hda_board_config alc861_cfg_tbl[] = {
-       { .modelname = "3stack", .config = ALC861_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xd600,
-         .config = ALC861_3ST },
-       { .modelname = "3stack-660", .config = ALC660_3ST },
-       { .pci_subvendor = 0x1043, .pci_subdevice = 0x81e7,
-         .config = ALC660_3ST },
-       { .modelname = "3stack-dig", .config = ALC861_3ST_DIG },
-       { .modelname = "6stack-dig", .config = ALC861_6ST_DIG },
-       { .modelname = "uniwill-m31", .config = ALC861_UNIWILL_M31},
-       { .pci_subvendor = 0x1584, .pci_subdevice = 0x9072,
-         .config = ALC861_UNIWILL_M31 },
-       { .modelname = "auto", .config = ALC861_AUTO },
+static const char *alc861_models[ALC861_MODEL_LAST] = {
+       [ALC861_3ST]            = "3stack",
+       [ALC660_3ST]            = "3stack-660",
+       [ALC861_3ST_DIG]        = "3stack-dig",
+       [ALC861_6ST_DIG]        = "6stack-dig",
+       [ALC861_UNIWILL_M31]    = "uniwill-m31",
+       [ALC861_TOSHIBA]        = "toshiba",
+       [ALC861_ASUS]           = "asus",
+       [ALC861_ASUS_LAPTOP]    = "asus-laptop",
+       [ALC861_AUTO]           = "auto",
+};
+
+static struct snd_pci_quirk alc861_cfg_tbl[] = {
+       SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
+       SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
+       SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
+       SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
+       SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660_3ST),
+       SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
+       SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA),
+       SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
+       SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
+       SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
        {}
 };
 
@@ -6789,8 +7873,48 @@ static struct alc_config_preset alc861_presets[] = {
                .adc_nids = alc861_adc_nids,
                .input_mux = &alc861_capture_source,
        },
-
-};     
+       [ALC861_TOSHIBA] = {
+               .mixers = { alc861_toshiba_mixer },
+               .init_verbs = { alc861_base_init_verbs, alc861_toshiba_init_verbs },
+               .num_dacs = ARRAY_SIZE(alc861_dac_nids),
+               .dac_nids = alc861_dac_nids,
+               .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
+               .channel_mode = alc883_3ST_2ch_modes,
+               .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
+               .adc_nids = alc861_adc_nids,
+               .input_mux = &alc861_capture_source,
+               .unsol_event = alc861_toshiba_unsol_event,
+               .init_hook = alc861_toshiba_automute,
+       },
+       [ALC861_ASUS] = {
+               .mixers = { alc861_asus_mixer },
+               .init_verbs = { alc861_asus_init_verbs },
+               .num_dacs = ARRAY_SIZE(alc861_dac_nids),
+               .dac_nids = alc861_dac_nids,
+               .dig_out_nid = ALC861_DIGOUT_NID,
+               .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
+               .channel_mode = alc861_asus_modes,
+               .need_dac_fix = 1,
+               .hp_nid = 0x06,
+               .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
+               .adc_nids = alc861_adc_nids,
+               .input_mux = &alc861_capture_source,
+       },
+       [ALC861_ASUS_LAPTOP] = {
+               .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
+               .init_verbs = { alc861_asus_init_verbs,
+                               alc861_asus_laptop_init_verbs },
+               .num_dacs = ARRAY_SIZE(alc861_dac_nids),
+               .dac_nids = alc861_dac_nids,
+               .dig_out_nid = ALC861_DIGOUT_NID,
+               .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
+               .channel_mode = alc883_3ST_2ch_modes,
+               .need_dac_fix = 1,
+               .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
+               .adc_nids = alc861_adc_nids,
+               .input_mux = &alc861_capture_source,
+       },
+};
 
 
 static int patch_alc861(struct hda_codec *codec)
@@ -6799,15 +7923,17 @@ static int patch_alc861(struct hda_codec *codec)
        int board_config;
        int err;
 
-       spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
+       spec = kzalloc(sizeof(*spec), GFP_KERNEL);
        if (spec == NULL)
                return -ENOMEM;
 
        codec->spec = spec;     
 
-        board_config = snd_hda_check_board_config(codec, alc861_cfg_tbl);
+        board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
+                                                 alc861_models,
+                                                 alc861_cfg_tbl);
 
-       if (board_config < 0 || board_config >= ALC861_MODEL_LAST) {
+       if (board_config < 0) {
                printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
                       "trying auto-probe from BIOS...\n");
                board_config = ALC861_AUTO;
@@ -6845,20 +7971,707 @@ static int patch_alc861(struct hda_codec *codec)
        return 0;
 }
 
+/*
+ * ALC861-VD support
+ *
+ * Based on ALC882
+ *
+ * In addition, an independent DAC
+ */
+#define ALC861VD_DIGOUT_NID    0x06
+
+static hda_nid_t alc861vd_dac_nids[4] = {
+       /* front, surr, clfe, side surr */
+       0x02, 0x03, 0x04, 0x05
+};
+
+/* dac_nids for ALC660vd are in a different order - according to
+ * Realtek's driver.
+ * This should probably tesult in a different mixer for 6stack models
+ * of ALC660vd codecs, but for now there is only 3stack mixer
+ * - and it is the same as in 861vd.
+ * adc_nids in ALC660vd are (is) the same as in 861vd
+ */
+static hda_nid_t alc660vd_dac_nids[3] = {
+       /* front, rear, clfe, rear_surr */
+       0x02, 0x04, 0x03
+};
+
+static hda_nid_t alc861vd_adc_nids[1] = {
+       /* ADC0 */
+       0x09,
+};
+
+/* input MUX */
+/* FIXME: should be a matrix-type input source selection */
+static struct hda_input_mux alc861vd_capture_source = {
+       .num_items = 4,
+       .items = {
+               { "Mic", 0x0 },
+               { "Front Mic", 0x1 },
+               { "Line", 0x2 },
+               { "CD", 0x4 },
+       },
+};
+
+#define alc861vd_mux_enum_info alc_mux_enum_info
+#define alc861vd_mux_enum_get alc_mux_enum_get
+
+static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
+                               struct snd_ctl_elem_value *ucontrol)
+{
+       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct alc_spec *spec = codec->spec;
+       const struct hda_input_mux *imux = spec->input_mux;
+       unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
+       static hda_nid_t capture_mixers[1] = { 0x22 };
+       hda_nid_t nid = capture_mixers[adc_idx];
+       unsigned int *cur_val = &spec->cur_mux[adc_idx];
+       unsigned int i, idx;
+
+       idx = ucontrol->value.enumerated.item[0];
+       if (idx >= imux->num_items)
+               idx = imux->num_items - 1;
+       if (*cur_val == idx && ! codec->in_resume)
+               return 0;
+       for (i = 0; i < imux->num_items; i++) {
+               unsigned int v = (i == idx) ? 0x7000 : 0x7080;
+               snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
+                                   v | (imux->items[i].index << 8));
+       }
+       *cur_val = idx;
+       return 1;
+}
+
+/*
+ * 2ch mode
+ */
+static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
+       { 2, NULL }
+};
+
+/*
+ * 6ch mode
+ */
+static struct hda_verb alc861vd_6stack_ch6_init[] = {
+       { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
+       { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
+       { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
+       { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
+       { } /* end */
+};
+
+/*
+ * 8ch mode
+ */
+static struct hda_verb alc861vd_6stack_ch8_init[] = {
+       { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
+       { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
+       { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
+       { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
+       { } /* end */
+};
+
+static struct hda_channel_mode alc861vd_6stack_modes[2] = {
+       { 6, alc861vd_6stack_ch6_init },
+       { 8, alc861vd_6stack_ch8_init },
+};
+
+static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               .name = "Channel Mode",
+               .info = alc_ch_mode_info,
+               .get = alc_ch_mode_get,
+               .put = alc_ch_mode_put,
+       },
+       { } /* end */
+};
+
+static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
+       HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
+       HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
+
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               /* The multiple "Capture Source" controls confuse alsamixer
+                * So call somewhat different..
+                *FIXME: the controls appear in the "playback" view!
+                */
+               /* .name = "Capture Source", */
+               .name = "Input Source",
+               .count = 1,
+               .info = alc861vd_mux_enum_info,
+               .get = alc861vd_mux_enum_get,
+               .put = alc861vd_mux_enum_put,
+       },
+       { } /* end */
+};
+
+/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
+ *                 Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
+ */
+static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
+       HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
+       HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
+
+       HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
+       HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
+
+       HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
+                               HDA_OUTPUT),
+       HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
+                               HDA_OUTPUT),
+       HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
+       HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
+
+       HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
+       HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
+
+       HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
+
+       HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
+       HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
+       HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
+
+       HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
+       HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
+       HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
+
+       HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
+       HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
+
+       HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
+       HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
+
+       HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
+       HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
+
+       { } /* end */
+};
+
+static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
+       HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
+       HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
+
+       HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
+
+       HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
+       HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
+       HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
+
+       HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
+       HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
+       HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
+
+       HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
+       HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
+
+       HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
+       HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
+
+       HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
+       HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
+
+       { } /* end */
+};
+
+/*
+ * generic initialization of ADC, input mixers and output mixers
+ */
+static struct hda_verb alc861vd_volume_init_verbs[] = {
+       /*
+        * Unmute ADC0 and set the default input to mic-in
+        */
+       {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
+       {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+
+       /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
+        * the analog-loopback mixer widget
+        */
+       /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
+       {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+       {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
+       {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
+       {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
+       {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
+
+       /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
+       {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
+       {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
+       {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
+       {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(8)},
+
+       /*
+        * Set up output mixers (0x02 - 0x05)
+        */
+       /* set vol=0 to output mixers */
+       {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
+       {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
+       {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
+       {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
+
+       /* set up input amps for analog loopback */
+       /* Amp Indices: DAC = 0, mixer = 1 */
+       {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
+       {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
+       {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
+       {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
+       {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
+       {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
+       {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
+       {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
+
+       { }
+};
+
+/*
+ * 3-stack pin configuration:
+ * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
+ */
+static struct hda_verb alc861vd_3stack_init_verbs[] = {
+       /*
+        * Set pin mode and muting
+        */
+       /* set front pin widgets 0x14 for output */
+       {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
+       {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
+
+       /* Mic (rear) pin: input vref at 80% */
+       {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
+       {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
+       /* Front Mic pin: input vref at 80% */
+       {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
+       {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
+       /* Line In pin: input */
+       {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
+       {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
+       /* Line-2 In: Headphone output (output 0 - 0x0c) */
+       {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
+       {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
+       /* CD pin widget for input */
+       {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
+
+       { }
+};
+
+/*
+ * 6-stack pin configuration:
+ */
+static struct hda_verb alc861vd_6stack_init_verbs[] = {
+       /*
+        * Set pin mode and muting
+        */
+       /* set front pin widgets 0x14 for output */
+       {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
+       {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
+
+       /* Rear Pin: output 1 (0x0d) */
+       {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
+       {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
+       /* CLFE Pin: output 2 (0x0e) */
+       {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
+       {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
+       /* Side Pin: output 3 (0x0f) */
+       {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
+       {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
+
+       /* Mic (rear) pin: input vref at 80% */
+       {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
+       {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
+       /* Front Mic pin: input vref at 80% */
+       {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
+       {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
+       /* Line In pin: input */
+       {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
+       {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
+       /* Line-2 In: Headphone output (output 0 - 0x0c) */
+       {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
+       {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
+       /* CD pin widget for input */
+       {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
+
+       { }
+};
+
+/* pcm configuration: identiacal with ALC880 */
+#define alc861vd_pcm_analog_playback   alc880_pcm_analog_playback
+#define alc861vd_pcm_analog_capture    alc880_pcm_analog_capture
+#define alc861vd_pcm_digital_playback  alc880_pcm_digital_playback
+#define alc861vd_pcm_digital_capture   alc880_pcm_digital_capture
+
+/*
+ * configuration and preset
+ */
+static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
+       [ALC660VD_3ST]          = "3stack-660",
+       [ALC861VD_3ST]          = "3stack",
+       [ALC861VD_3ST_DIG]      = "3stack-digout",
+       [ALC861VD_6ST_DIG]      = "6stack-digout",
+       [ALC861VD_AUTO]         = "auto",
+};
+
+static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
+       SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
+       SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
+       SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
+
+       SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_3ST),
+       {}
+};
+
+static struct alc_config_preset alc861vd_presets[] = {
+       [ALC660VD_3ST] = {
+               .mixers = { alc861vd_3st_mixer },
+               .init_verbs = { alc861vd_volume_init_verbs,
+                                alc861vd_3stack_init_verbs },
+               .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
+               .dac_nids = alc660vd_dac_nids,
+               .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
+               .adc_nids = alc861vd_adc_nids,
+               .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
+               .channel_mode = alc861vd_3stack_2ch_modes,
+               .input_mux = &alc861vd_capture_source,
+       },
+       [ALC861VD_3ST] = {
+               .mixers = { alc861vd_3st_mixer },
+               .init_verbs = { alc861vd_volume_init_verbs,
+                                alc861vd_3stack_init_verbs },
+               .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
+               .dac_nids = alc861vd_dac_nids,
+               .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
+               .channel_mode = alc861vd_3stack_2ch_modes,
+               .input_mux = &alc861vd_capture_source,
+       },
+       [ALC861VD_3ST_DIG] = {
+               .mixers = { alc861vd_3st_mixer },
+               .init_verbs = { alc861vd_volume_init_verbs,
+                                alc861vd_3stack_init_verbs },
+               .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
+               .dac_nids = alc861vd_dac_nids,
+               .dig_out_nid = ALC861VD_DIGOUT_NID,
+               .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
+               .channel_mode = alc861vd_3stack_2ch_modes,
+               .input_mux = &alc861vd_capture_source,
+       },
+       [ALC861VD_6ST_DIG] = {
+               .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
+               .init_verbs = { alc861vd_volume_init_verbs,
+                               alc861vd_6stack_init_verbs },
+               .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
+               .dac_nids = alc861vd_dac_nids,
+               .dig_out_nid = ALC861VD_DIGOUT_NID,
+               .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
+               .channel_mode = alc861vd_6stack_modes,
+               .input_mux = &alc861vd_capture_source,
+       },
+};
+
+/*
+ * BIOS auto configuration
+ */
+static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
+                               hda_nid_t nid, int pin_type, int dac_idx)
+{
+       /* set as output */
+       snd_hda_codec_write(codec, nid, 0,
+                               AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
+       snd_hda_codec_write(codec, nid, 0,
+                               AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
+}
+
+static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
+{
+       struct alc_spec *spec = codec->spec;
+       int i;
+
+       for (i = 0; i <= HDA_SIDE; i++) {
+               hda_nid_t nid = spec->autocfg.line_out_pins[i];
+               if (nid)
+                       alc861vd_auto_set_output_and_unmute(codec, nid,
+                                                               PIN_OUT, i);
+       }
+}
+
+
+static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
+{
+       struct alc_spec *spec = codec->spec;
+       hda_nid_t pin;
+
+       pin = spec->autocfg.hp_pins[0];
+       if (pin) /* connect to front and  use dac 0 */
+               alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
+}
+
+#define alc861vd_is_input_pin(nid)     alc880_is_input_pin(nid)
+#define ALC861VD_PIN_CD_NID            ALC880_PIN_CD_NID
+
+static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
+{
+       struct alc_spec *spec = codec->spec;
+       int i;
+
+       for (i = 0; i < AUTO_PIN_LAST; i++) {
+               hda_nid_t nid = spec->autocfg.input_pins[i];
+               if (alc861vd_is_input_pin(nid)) {
+                       snd_hda_codec_write(codec, nid, 0,
+                                       AC_VERB_SET_PIN_WIDGET_CONTROL,
+                                       i <= AUTO_PIN_FRONT_MIC ?
+                                                       PIN_VREF80 : PIN_IN);
+                       if (nid != ALC861VD_PIN_CD_NID)
+                               snd_hda_codec_write(codec, nid, 0,
+                                               AC_VERB_SET_AMP_GAIN_MUTE,
+                                               AMP_OUT_MUTE);
+               }
+       }
+}
+
+#define alc861vd_idx_to_mixer_vol(nid)         ((nid) + 0x02)
+#define alc861vd_idx_to_mixer_switch(nid)      ((nid) + 0x0c)
+
+/* add playback controls from the parsed DAC table */
+/* Based on ALC880 version. But ALC861VD has separate,
+ * different NIDs for mute/unmute switch and volume control */
+static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
+                                            const struct auto_pin_cfg *cfg)
+{
+       char name[32];
+       static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
+       hda_nid_t nid_v, nid_s;
+       int i, err;
+
+       for (i = 0; i < cfg->line_outs; i++) {
+               if (! spec->multiout.dac_nids[i])
+                       continue;
+               nid_v = alc861vd_idx_to_mixer_vol(
+                               alc880_dac_to_idx(
+                                       spec->multiout.dac_nids[i]));
+               nid_s = alc861vd_idx_to_mixer_switch(
+                               alc880_dac_to_idx(
+                                       spec->multiout.dac_nids[i]));
+
+               if (i == 2) {
+                       /* Center/LFE */
+                       if ((err = add_control(spec, ALC_CTL_WIDGET_VOL,
+                                               "Center Playback Volume",
+                                               HDA_COMPOSE_AMP_VAL(nid_v, 1,
+                                                       0, HDA_OUTPUT))) < 0)
+                               return err;
+                       if ((err = add_control(spec, ALC_CTL_WIDGET_VOL,
+                                               "LFE Playback Volume",
+                                               HDA_COMPOSE_AMP_VAL(nid_v, 2,
+                                                       0, HDA_OUTPUT))) < 0)
+                               return err;
+                       if ((err = add_control(spec, ALC_CTL_BIND_MUTE,
+                                               "Center Playback Switch",
+                                               HDA_COMPOSE_AMP_VAL(nid_s, 1,
+                                               2, HDA_INPUT))) < 0)
+                               return err;
+                       if ((err = add_control(spec, ALC_CTL_BIND_MUTE,
+                                               "LFE Playback Switch",
+                                               HDA_COMPOSE_AMP_VAL(nid_s, 2,
+                                               2, HDA_INPUT))) < 0)
+                               return err;
+               } else {
+                       sprintf(name, "%s Playback Volume", chname[i]);
+                       if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
+                                               HDA_COMPOSE_AMP_VAL(nid_v, 3,
+                                                       0, HDA_OUTPUT))) < 0)
+                               return err;
+                       sprintf(name, "%s Playback Switch", chname[i]);
+                       if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
+                                               HDA_COMPOSE_AMP_VAL(nid_v, 3,
+                                                       2, HDA_INPUT))) < 0)
+                               return err;
+               }
+       }
+       return 0;
+}
+
+/* add playback controls for speaker and HP outputs */
+/* Based on ALC880 version. But ALC861VD has separate,
+ * different NIDs for mute/unmute switch and volume control */
+static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
+                                       hda_nid_t pin, const char *pfx)
+{
+       hda_nid_t nid_v, nid_s;
+       int err;
+       char name[32];
+
+       if (! pin)
+               return 0;
+
+       if (alc880_is_fixed_pin(pin)) {
+               nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
+               /* specify the DAC as the extra output */
+               if (! spec->multiout.hp_nid)
+                       spec->multiout.hp_nid = nid_v;
+               else
+                       spec->multiout.extra_out_nid[0] = nid_v;
+               /* control HP volume/switch on the output mixer amp */
+               nid_v = alc861vd_idx_to_mixer_vol(
+                               alc880_fixed_pin_idx(pin));
+               nid_s = alc861vd_idx_to_mixer_switch(
+                               alc880_fixed_pin_idx(pin));
+
+               sprintf(name, "%s Playback Volume", pfx);
+               if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
+                               HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
+                                                       HDA_OUTPUT))) < 0)
+                       return err;
+               sprintf(name, "%s Playback Switch", pfx);
+               if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
+                               HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
+                                                       HDA_INPUT))) < 0)
+                       return err;
+       } else if (alc880_is_multi_pin(pin)) {
+               /* set manual connection */
+               /* we have only a switch on HP-out PIN */
+               sprintf(name, "%s Playback Switch", pfx);
+               if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
+                               HDA_COMPOSE_AMP_VAL(pin, 3, 0,
+                                                       HDA_OUTPUT))) < 0)
+                       return err;
+       }
+       return 0;
+}
+
+/* parse the BIOS configuration and set up the alc_spec
+ * return 1 if successful, 0 if the proper config is not found,
+ * or a negative error code
+ * Based on ALC880 version - had to change it to override
+ * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
+static int alc861vd_parse_auto_config(struct hda_codec *codec)
+{
+       struct alc_spec *spec = codec->spec;
+       int err;
+       static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
+
+       if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
+                                               alc861vd_ignore)) < 0)
+               return err;
+       if (! spec->autocfg.line_outs)
+               return 0; /* can't find valid BIOS pin config */
+
+       if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
+               (err = alc861vd_auto_create_multi_out_ctls(spec,
+                       &spec->autocfg)) < 0 ||
+               (err = alc861vd_auto_create_extra_out(spec,
+                       spec->autocfg.speaker_pins[0], "Speaker")) < 0 ||
+               (err = alc861vd_auto_create_extra_out(spec,
+                       spec->autocfg.hp_pins[0], "Headphone")) < 0 ||
+               (err = alc880_auto_create_analog_input_ctls(spec,
+                       &spec->autocfg)) < 0)
+               return err;
+
+       spec->multiout.max_channels = spec->multiout.num_dacs * 2;
+
+       if (spec->autocfg.dig_out_pin)
+               spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
+
+       if (spec->kctl_alloc)
+               spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
+
+       spec->init_verbs[spec->num_init_verbs++]
+               = alc861vd_volume_init_verbs;
+
+       spec->num_mux_defs = 1;
+       spec->input_mux = &spec->private_imux;
+
+       return 1;
+}
+
+/* additional initialization for auto-configuration model */
+static void alc861vd_auto_init(struct hda_codec *codec)
+{
+       alc861vd_auto_init_multi_out(codec);
+       alc861vd_auto_init_hp_out(codec);
+       alc861vd_auto_init_analog_input(codec);
+}
+
+static int patch_alc861vd(struct hda_codec *codec)
+{
+       struct alc_spec *spec;
+       int err, board_config;
+
+       spec = kzalloc(sizeof(*spec), GFP_KERNEL);
+       if (spec == NULL)
+               return -ENOMEM;
+
+       codec->spec = spec;
+
+       board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
+                                                 alc861vd_models,
+                                                 alc861vd_cfg_tbl);
+
+       if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
+               printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
+                       "ALC861VD, trying auto-probe from BIOS...\n");
+               board_config = ALC861VD_AUTO;
+       }
+
+       if (board_config == ALC861VD_AUTO) {
+               /* automatic parse from the BIOS config */
+               err = alc861vd_parse_auto_config(codec);
+               if (err < 0) {
+                       alc_free(codec);
+                       return err;
+               } else if (! err) {
+                       printk(KERN_INFO
+                              "hda_codec: Cannot set up configuration "
+                              "from BIOS.  Using base mode...\n");
+                       board_config = ALC861VD_3ST;
+               }
+       }
+
+       if (board_config != ALC861VD_AUTO)
+               setup_preset(spec, &alc861vd_presets[board_config]);
+
+       spec->stream_name_analog = "ALC861VD Analog";
+       spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
+       spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
+
+       spec->stream_name_digital = "ALC861VD Digital";
+       spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
+       spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
+
+       spec->adc_nids = alc861vd_adc_nids;
+       spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
+
+       spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
+       spec->num_mixers++;
+
+       codec->patch_ops = alc_patch_ops;
+
+       if (board_config == ALC861VD_AUTO)
+               spec->init_hook = alc861vd_auto_init;
+
+       return 0;
+}
+
 /*
  * patch entries
  */
 struct hda_codec_preset snd_hda_preset_realtek[] = {
        { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
        { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
-       { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
+       { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
+               .patch = patch_alc861 },
+       { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
+       { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
+       { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
+       { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
        { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
        { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
        { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
        { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
-       { .id = 0x10ec0861, .rev = 0x100300, .name = "ALC861",
-         .patch = patch_alc861 },
-        { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
-         .patch = patch_alc861 },
        {} /* terminator */
 };
index fe51ef3e49d297a08622109d902f15c4b436ab0f..6f4a39273b988f8a99f8ac83283684a925cfc1ec 100644 (file)
 #define NUM_CONTROL_ALLOC      32
 #define STAC_HP_EVENT          0x37
 
-#define STAC_REF               0
-#define STAC_D945GTP3          1
-#define STAC_D945GTP5          2
-#define STAC_MACMINI           3
-#define STAC_922X_MODELS       4       /* number of 922x models */
-#define STAC_D965_3ST          4
-#define STAC_D965_5ST          5
-#define STAC_927X_MODELS       6       /* number of 922x models */
+enum {
+       STAC_REF,
+       STAC_9200_MODELS
+};
+
+enum {
+       STAC_9205_REF,
+       STAC_9205_MODELS
+};
+
+enum {
+       STAC_925x_REF,
+       STAC_M2_2,
+       STAC_MA6,
+       STAC_925x_MODELS
+};
+
+enum {
+       STAC_D945_REF,
+       STAC_D945GTP3,
+       STAC_D945GTP5,
+       STAC_MACMINI,
+       STAC_922X_MODELS
+};
+
+enum {
+       STAC_D965_REF,
+       STAC_D965_3ST,
+       STAC_D965_5ST,
+       STAC_927X_MODELS
+};
 
 struct sigmatel_spec {
        struct snd_kcontrol_new *mixers[4];
@@ -67,6 +90,9 @@ struct sigmatel_spec {
        unsigned int num_adcs;
        hda_nid_t *mux_nids;
        unsigned int num_muxes;
+       hda_nid_t *dmic_nids;
+       unsigned int num_dmics;
+       hda_nid_t dmux_nid;
        hda_nid_t dig_in_nid;
 
        /* pin widgets */
@@ -80,6 +106,8 @@ struct sigmatel_spec {
        struct snd_kcontrol_new *mixer;
 
        /* capture source */
+       struct hda_input_mux *dinput_mux;
+       unsigned int cur_dmux;
        struct hda_input_mux *input_mux;
        unsigned int cur_mux[3];
 
@@ -92,6 +120,7 @@ struct sigmatel_spec {
        struct auto_pin_cfg autocfg;
        unsigned int num_kctl_alloc, num_kctl_used;
        struct snd_kcontrol_new *kctl_alloc;
+       struct hda_input_mux private_dimux;
        struct hda_input_mux private_imux;
 };
 
@@ -107,6 +136,18 @@ static hda_nid_t stac9200_dac_nids[1] = {
         0x02,
 };
 
+static hda_nid_t stac925x_adc_nids[1] = {
+        0x03,
+};
+
+static hda_nid_t stac925x_mux_nids[1] = {
+        0x0f,
+};
+
+static hda_nid_t stac925x_dac_nids[1] = {
+        0x02,
+};
+
 static hda_nid_t stac922x_adc_nids[2] = {
         0x06, 0x07,
 };
@@ -131,11 +172,20 @@ static hda_nid_t stac9205_mux_nids[2] = {
         0x19, 0x1a
 };
 
+static hda_nid_t stac9205_dmic_nids[3] = {
+        0x17, 0x18, 0
+};
+
 static hda_nid_t stac9200_pin_nids[8] = {
        0x08, 0x09, 0x0d, 0x0e, 
        0x0f, 0x10, 0x11, 0x12,
 };
 
+static hda_nid_t stac925x_pin_nids[8] = {
+       0x07, 0x08, 0x0a, 0x0b, 
+       0x0c, 0x0d, 0x10, 0x11,
+};
+
 static hda_nid_t stac922x_pin_nids[10] = {
        0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
        0x0f, 0x10, 0x11, 0x15, 0x1b,
@@ -154,6 +204,34 @@ static hda_nid_t stac9205_pin_nids[12] = {
        
 };
 
+static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
+                                  struct snd_ctl_elem_info *uinfo)
+{
+       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct sigmatel_spec *spec = codec->spec;
+       return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
+}
+
+static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
+                                 struct snd_ctl_elem_value *ucontrol)
+{
+       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct sigmatel_spec *spec = codec->spec;
+
+       ucontrol->value.enumerated.item[0] = spec->cur_dmux;
+       return 0;
+}
+
+static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
+                                 struct snd_ctl_elem_value *ucontrol)
+{
+       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct sigmatel_spec *spec = codec->spec;
+
+       return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
+                                    spec->dmux_nid, &spec->cur_dmux);
+}
+
 static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
 {
        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
@@ -187,6 +265,12 @@ static struct hda_verb stac9200_core_init[] = {
        {}
 };
 
+static struct hda_verb stac925x_core_init[] = {
+       /* set dac0mux for dac converter */
+       { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
+       {}
+};
+
 static struct hda_verb stac922x_core_init[] = {
        /* set master volume and direct control */      
        { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
@@ -232,6 +316,23 @@ static struct snd_kcontrol_new stac9200_mixer[] = {
        { } /* end */
 };
 
+static struct snd_kcontrol_new stac925x_mixer[] = {
+       HDA_CODEC_VOLUME("Master Playback Volume", 0xe, 0, HDA_OUTPUT),
+       HDA_CODEC_MUTE("Master Playback Switch", 0xe, 0, HDA_OUTPUT),
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               .name = "Input Source",
+               .count = 1,
+               .info = stac92xx_mux_enum_info,
+               .get = stac92xx_mux_enum_get,
+               .put = stac92xx_mux_enum_put,
+       },
+       HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
+       HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_OUTPUT),
+       HDA_CODEC_VOLUME("Capture Mux Volume", 0x0f, 0, HDA_OUTPUT),
+       { } /* end */
+};
+
 /* This needs to be generated dynamically based on sequence */
 static struct snd_kcontrol_new stac922x_mixer[] = {
        {
@@ -263,7 +364,7 @@ static struct snd_kcontrol_new stac9227_mixer[] = {
        { } /* end */
 };
 
-static snd_kcontrol_new_t stac927x_mixer[] = {
+static struct snd_kcontrol_new stac927x_mixer[] = {
        {
                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
                .name = "Input Source",
@@ -278,7 +379,15 @@ static snd_kcontrol_new_t stac927x_mixer[] = {
        { } /* end */
 };
 
-static snd_kcontrol_new_t stac9205_mixer[] = {
+static struct snd_kcontrol_new stac9205_mixer[] = {
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               .name = "Digital Input Source",
+               .count = 1,
+               .info = stac92xx_dmux_enum_info,
+               .get = stac92xx_dmux_enum_get,
+               .put = stac92xx_dmux_enum_put,
+       },
        {
                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
                .name = "Input Source",
@@ -327,22 +436,64 @@ static unsigned int ref9200_pin_configs[8] = {
        0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
 };
 
-static unsigned int *stac9200_brd_tbl[] = {
-       ref9200_pin_configs,
+static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
+       [STAC_REF] = ref9200_pin_configs,
+};
+
+static const char *stac9200_models[STAC_9200_MODELS] = {
+       [STAC_REF] = "ref",
 };
 
-static struct hda_board_config stac9200_cfg_tbl[] = {
-       { .modelname = "ref",
-         .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x2668,      /* DFI LanParty */
-         .config = STAC_REF },
+static struct snd_pci_quirk stac9200_cfg_tbl[] = {
+       /* SigmaTel reference board */
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
+                     "DFI LanParty", STAC_REF),
        /* Dell laptops have BIOS problem */
-       { .pci_subvendor = PCI_VENDOR_ID_DELL, .pci_subdevice = 0x01b5,
-         .config = STAC_REF }, /* Dell Inspiron 630m */
-       { .pci_subvendor = PCI_VENDOR_ID_DELL, .pci_subdevice = 0x01c2,
-         .config = STAC_REF }, /* Dell Latitude D620 */
-       { .pci_subvendor = PCI_VENDOR_ID_DELL, .pci_subdevice = 0x01cb,
-         .config = STAC_REF }, /* Dell Latitude 120L */
+       SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
+                     "Dell Inspiron 630m", STAC_REF),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
+                     "Dell Latitude D620", STAC_REF),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
+                     "Dell Latitude 120L", STAC_REF),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
+                     "Dell Latitude D820", STAC_REF),
+       {} /* terminator */
+};
+
+static unsigned int ref925x_pin_configs[8] = {
+       0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
+       0x90a70320, 0x02214210, 0x400003f1, 0x9033032e,
+};
+
+static unsigned int stac925x_MA6_pin_configs[8] = {
+       0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
+       0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
+};
+
+static unsigned int stac925xM2_2_pin_configs[8] = {
+       0x40c003f3, 0x424503f2, 0x041800f4, 0x02a19020,
+       0x50a103F0, 0x90100210, 0x400003f1, 0x9033032e,
+};
+
+static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
+       [STAC_REF] = ref925x_pin_configs,
+       [STAC_M2_2] = stac925xM2_2_pin_configs,
+       [STAC_MA6] = stac925x_MA6_pin_configs,
+};
+
+static const char *stac925x_models[STAC_925x_MODELS] = {
+       [STAC_REF] = "ref",
+       [STAC_M2_2] = "m2-2",
+       [STAC_MA6] = "m6",
+};
+
+static struct snd_pci_quirk stac925x_cfg_tbl[] = {
+       /* SigmaTel reference board */
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
+       SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
+       SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
+       SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
+       SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
        {} /* terminator */
 };
 
@@ -365,100 +516,80 @@ static unsigned int d945gtp5_pin_configs[10] = {
 };
 
 static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
-       [STAC_REF] =    ref922x_pin_configs,
+       [STAC_D945_REF] = ref922x_pin_configs,
        [STAC_D945GTP3] = d945gtp3_pin_configs,
        [STAC_D945GTP5] = d945gtp5_pin_configs,
        [STAC_MACMINI] = d945gtp5_pin_configs,
 };
 
-static struct hda_board_config stac922x_cfg_tbl[] = {
-       { .modelname = "5stack", .config = STAC_D945GTP5 },
-       { .modelname = "3stack", .config = STAC_D945GTP3 },
-       { .modelname = "ref",
-         .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x2668,      /* DFI LanParty */
-         .config = STAC_REF },         /* SigmaTel reference board */
-         /* Intel 945G based systems */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x0101,
-         .config = STAC_D945GTP3 },    /* Intel D945GTP - 3 Stack */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x0202,
-         .config = STAC_D945GTP3 },    /* Intel D945GNT - 3 Stack */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x0606,
-         .config = STAC_D945GTP3 },    /* Intel D945GTP - 3 Stack */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x0601,
-         .config = STAC_D945GTP3 },    /* Intel D945GTP - 3 Stack */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x0111,
-         .config = STAC_D945GTP3 },    /* Intel D945GZP - 3 Stack */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x1115,
-         .config = STAC_D945GTP3 },    /* Intel D945GPM - 3 Stack */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x1116,
-         .config = STAC_D945GTP3 },    /* Intel D945GBO - 3 Stack */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x1117,
-         .config = STAC_D945GTP3 },    /* Intel D945GPM - 3 Stack */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x1118,
-         .config = STAC_D945GTP3 },    /* Intel D945GPM - 3 Stack */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x1119,
-         .config = STAC_D945GTP3 },    /* Intel D945GPM - 3 Stack */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x8826,
-         .config = STAC_D945GTP3 },    /* Intel D945GPM - 3 Stack */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x5049,
-         .config = STAC_D945GTP3 },    /* Intel D945GCZ - 3 Stack */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x5055,
-         .config = STAC_D945GTP3 },    /* Intel D945GCZ - 3 Stack */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x5048,
-         .config = STAC_D945GTP3 },    /* Intel D945GPB - 3 Stack */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x0110,
-         .config = STAC_D945GTP3 },    /* Intel D945GLR - 3 Stack */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x0404,
-         .config = STAC_D945GTP5 },    /* Intel D945GTP - 5 Stack */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x0303,
-         .config = STAC_D945GTP5 },    /* Intel D945GNT - 5 Stack */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x0013,
-         .config = STAC_D945GTP5 },    /* Intel D955XBK - 5 Stack */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x0417,
-         .config = STAC_D945GTP5 },    /* Intel D975XBK - 5 Stack */
-         /* Intel 945P based systems */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x0b0b,
-         .config = STAC_D945GTP3 },    /* Intel D945PSN - 3 Stack */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x0112,
-         .config = STAC_D945GTP3 },    /* Intel D945PLN - 3 Stack */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x0d0d,
-         .config = STAC_D945GTP3 },    /* Intel D945PLM - 3 Stack */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x0909,
-         .config = STAC_D945GTP3 },    /* Intel D945PAW - 3 Stack */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x0505,
-         .config = STAC_D945GTP3 },    /* Intel D945PLM - 3 Stack */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x0707,
-         .config = STAC_D945GTP5 },    /* Intel D945PSV - 5 Stack */
-         /* other systems  */
-       { .pci_subvendor = 0x8384,
-         .pci_subdevice = 0x7680,
-         .config = STAC_MACMINI },     /* Apple Mac Mini (early 2006) */
+static const char *stac922x_models[STAC_922X_MODELS] = {
+       [STAC_D945_REF] = "ref",
+       [STAC_D945GTP5] = "5stack",
+       [STAC_D945GTP3] = "3stack",
+       [STAC_MACMINI]  = "macmini",
+};
+
+static struct snd_pci_quirk stac922x_cfg_tbl[] = {
+       /* SigmaTel reference board */
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
+                     "DFI LanParty", STAC_D945_REF),
+       /* Intel 945G based systems */
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
+                     "Intel D945G", STAC_D945GTP3),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
+                     "Intel D945G", STAC_D945GTP3),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
+                     "Intel D945G", STAC_D945GTP3),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
+                     "Intel D945G", STAC_D945GTP3),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
+                     "Intel D945G", STAC_D945GTP3),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
+                     "Intel D945G", STAC_D945GTP3),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
+                     "Intel D945G", STAC_D945GTP3),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
+                     "Intel D945G", STAC_D945GTP3),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
+                     "Intel D945G", STAC_D945GTP3),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
+                     "Intel D945G", STAC_D945GTP3),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
+                     "Intel D945G", STAC_D945GTP3),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
+                     "Intel D945G", STAC_D945GTP3),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
+                     "Intel D945G", STAC_D945GTP3),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
+                     "Intel D945G", STAC_D945GTP3),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
+                     "Intel D945G", STAC_D945GTP3),
+       /* Intel D945G 5-stack systems */
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
+                     "Intel D945G", STAC_D945GTP5),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
+                     "Intel D945G", STAC_D945GTP5),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
+                     "Intel D945G", STAC_D945GTP5),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
+                     "Intel D945G", STAC_D945GTP5),
+       /* Intel 945P based systems */
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
+                     "Intel D945P", STAC_D945GTP3),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
+                     "Intel D945P", STAC_D945GTP3),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
+                     "Intel D945P", STAC_D945GTP3),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
+                     "Intel D945P", STAC_D945GTP3),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
+                     "Intel D945P", STAC_D945GTP3),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
+                     "Intel D945P", STAC_D945GTP5),
+       /* other systems  */
+       /* Apple Mac Mini (early 2006) */
+       SND_PCI_QUIRK(0x8384, 0x7680,
+                     "Mac Mini", STAC_MACMINI),
        {} /* terminator */
 };
 
@@ -484,120 +615,72 @@ static unsigned int d965_5st_pin_configs[14] = {
 };
 
 static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
-       [STAC_REF] =    ref927x_pin_configs,
+       [STAC_D965_REF] = ref927x_pin_configs,
        [STAC_D965_3ST] = d965_3st_pin_configs,
        [STAC_D965_5ST] = d965_5st_pin_configs,
 };
 
-static struct hda_board_config stac927x_cfg_tbl[] = {
-       { .modelname = "5stack", .config = STAC_D965_5ST },
-       { .modelname = "3stack", .config = STAC_D965_3ST },
-       { .modelname = "ref",
-         .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x2668,      /* DFI LanParty */
-         .config = STAC_REF },         /* SigmaTel reference board */
+static const char *stac927x_models[STAC_927X_MODELS] = {
+       [STAC_D965_REF] = "ref",
+       [STAC_D965_3ST] = "3stack",
+       [STAC_D965_5ST] = "5stack",
+};
+
+static struct snd_pci_quirk stac927x_cfg_tbl[] = {
+       /* SigmaTel reference board */
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
+                     "DFI LanParty", STAC_D965_REF),
         /* Intel 946 based systems */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x3d01,
-         .config = STAC_D965_3ST }, /* D946  configuration */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0xa301,
-         .config = STAC_D965_3ST }, /* Intel D946GZT - 3 stack  */
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
        /* 965 based 3 stack systems */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x2116,
-         .config = STAC_D965_3ST }, /* Intel D965 3Stack config */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x2115,
-         .config = STAC_D965_3ST }, /* Intel DQ965WC - 3 Stack  */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x2114,
-         .config = STAC_D965_3ST }, /* Intel D965 3Stack config */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x2113,
-         .config = STAC_D965_3ST }, /* Intel D965 3Stack config */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x2112,
-         .config = STAC_D965_3ST }, /* Intel DG965MS - 3 Stack  */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x2111,
-         .config = STAC_D965_3ST }, /* Intel D965 3Stack config */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x2110,
-         .config = STAC_D965_3ST }, /* Intel D965 3Stack config */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x2009,
-         .config = STAC_D965_3ST }, /* Intel D965 3Stack config */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x2008,
-         .config = STAC_D965_3ST }, /* Intel DQ965GF - 3 Stack  */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x2007,
-         .config = STAC_D965_3ST }, /* Intel D965 3Stack config */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x2006,
-         .config = STAC_D965_3ST }, /* Intel D965 3Stack config */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x2005,
-         .config = STAC_D965_3ST }, /* Intel D965 3Stack config */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x2004,
-         .config = STAC_D965_3ST }, /* Intel D965 3Stack config */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x2003,
-         .config = STAC_D965_3ST }, /* Intel D965 3Stack config */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x2002,
-         .config = STAC_D965_3ST }, /* Intel D965 3Stack config */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x2001,
-         .config = STAC_D965_3ST }, /* Intel DQ965GF - 3 Stack */
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
        /* 965 based 5 stack systems */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x2301,
-         .config = STAC_D965_5ST }, /* Intel DG965 - 5 Stack */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x2302,
-         .config = STAC_D965_5ST }, /* Intel DG965 - 5 Stack */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x2303,
-         .config = STAC_D965_5ST }, /* Intel DG965 - 5 Stack */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x2304,
-         .config = STAC_D965_5ST }, /* Intel DG965 - 5 Stack */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x2305,
-         .config = STAC_D965_5ST }, /* Intel DG965 - 5 Stack */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x2501,
-         .config = STAC_D965_5ST }, /* Intel DG965MQ - 5 Stack */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x2502,
-         .config = STAC_D965_5ST }, /* Intel DG965 - 5 Stack */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x2503,
-         .config = STAC_D965_5ST }, /* Intel DG965 - 5 Stack */
-       { .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x2504,
-         .config = STAC_D965_5ST }, /* Intel DQ965GF - 5 Stack */
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
        {} /* terminator */
 };
 
 static unsigned int ref9205_pin_configs[12] = {
        0x40000100, 0x40000100, 0x01016011, 0x01014010,
-       0x01813122, 0x01a19021, 0x40000100, 0x40000100, 
-       0x40000100, 0x40000100, 0x01441030, 0x01c41030
+       0x01813122, 0x01a19021, 0x40000100, 0x40000100,
+       0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
 };
 
-static unsigned int *stac9205_brd_tbl[] = {
+static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
        ref9205_pin_configs,
 };
 
-static struct hda_board_config stac9205_cfg_tbl[] = {
-       { .modelname = "ref",
-         .pci_subvendor = PCI_VENDOR_ID_INTEL,
-         .pci_subdevice = 0x2668,      /* DFI LanParty */
-         .config = STAC_REF },         /* SigmaTel reference board */
+static const char *stac9205_models[STAC_9205_MODELS] = {
+       [STAC_9205_REF] = "ref",
+};
+
+static struct snd_pci_quirk stac9205_cfg_tbl[] = {
+       /* SigmaTel reference board */
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
+                     "DFI LanParty", STAC_9205_REF),
        {} /* terminator */
 };
 
@@ -1154,6 +1237,58 @@ static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
        return 0;
 }
 
+/* labels for dmic mux inputs */
+static const char *stac92xx_dmic_labels[5] = {
+       "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
+       "Digital Mic 3", "Digital Mic 4"
+};
+
+/* create playback/capture controls for input pins on dmic capable codecs */
+static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
+                                               const struct auto_pin_cfg *cfg)
+{
+       struct sigmatel_spec *spec = codec->spec;
+       struct hda_input_mux *dimux = &spec->private_dimux;
+       hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
+       int i, j;
+
+       dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
+       dimux->items[dimux->num_items].index = 0;
+       dimux->num_items++;
+
+       for (i = 0; i < spec->num_dmics; i++) {
+               int index;
+               int num_cons;
+               unsigned int def_conf;
+
+               def_conf = snd_hda_codec_read(codec,
+                                             spec->dmic_nids[i],
+                                             0,
+                                             AC_VERB_GET_CONFIG_DEFAULT,
+                                             0);
+               if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
+                       continue;
+
+               num_cons = snd_hda_get_connections(codec,
+                               spec->dmux_nid,
+                               con_lst,
+                               HDA_MAX_NUM_INPUTS);
+               for (j = 0; j < num_cons; j++)
+                       if (con_lst[j] == spec->dmic_nids[i]) {
+                               index = j;
+                               goto found;
+                       }
+               continue;
+found:
+               dimux->items[dimux->num_items].label =
+                       stac92xx_dmic_labels[dimux->num_items];
+               dimux->items[dimux->num_items].index = index;
+               dimux->num_items++;
+       }
+
+       return 0;
+}
+
 /* create playback/capture controls for input pins */
 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
 {
@@ -1238,7 +1373,9 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
        struct sigmatel_spec *spec = codec->spec;
        int err;
 
-       if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
+       if ((err = snd_hda_parse_pin_def_config(codec,
+                                               &spec->autocfg,
+                                               spec->dmic_nids)) < 0)
                return err;
        if (! spec->autocfg.line_outs)
                return 0; /* can't find valid pin config */
@@ -1254,6 +1391,11 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
            (err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
                return err;
 
+       if (spec->num_dmics > 0)
+               if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
+                                               &spec->autocfg)) < 0)
+                       return err;
+
        spec->multiout.max_channels = spec->multiout.num_dacs * 2;
        if (spec->multiout.max_channels > 2)
                spec->surr_switch = 1;
@@ -1267,6 +1409,7 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
                spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
 
        spec->input_mux = &spec->private_imux;
+       spec->dinput_mux = &spec->private_dimux;
 
        return 1;
 }
@@ -1366,6 +1509,7 @@ static int stac9200_parse_auto_config(struct hda_codec *codec)
                spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
 
        spec->input_mux = &spec->private_imux;
+       spec->dinput_mux = &spec->private_dimux;
 
        return 1;
 }
@@ -1448,6 +1592,11 @@ static int stac92xx_init(struct hda_codec *codec)
                        stac92xx_auto_set_pinctl(codec, nid, pinctl);
                }
        }
+       if (spec->num_dmics > 0)
+               for (i = 0; i < spec->num_dmics; i++)
+                       stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
+                                                AC_PINCTL_IN_EN);
+
        if (cfg->dig_out_pin)
                stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
                                         AC_PINCTL_OUT_EN);
@@ -1598,7 +1747,9 @@ static int patch_stac9200(struct hda_codec *codec)
        codec->spec = spec;
        spec->num_pins = 8;
        spec->pin_nids = stac9200_pin_nids;
-       spec->board_config = snd_hda_check_board_config(codec, stac9200_cfg_tbl);
+       spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
+                                                       stac9200_models,
+                                                       stac9200_cfg_tbl);
        if (spec->board_config < 0) {
                snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
                err = stac92xx_save_bios_config_regs(codec);
@@ -1618,6 +1769,7 @@ static int patch_stac9200(struct hda_codec *codec)
        spec->adc_nids = stac9200_adc_nids;
        spec->mux_nids = stac9200_mux_nids;
        spec->num_muxes = 1;
+       spec->num_dmics = 0;
 
        spec->init = stac9200_core_init;
        spec->mixer = stac9200_mixer;
@@ -1633,6 +1785,56 @@ static int patch_stac9200(struct hda_codec *codec)
        return 0;
 }
 
+static int patch_stac925x(struct hda_codec *codec)
+{
+       struct sigmatel_spec *spec;
+       int err;
+
+       spec  = kzalloc(sizeof(*spec), GFP_KERNEL);
+       if (spec == NULL)
+               return -ENOMEM;
+
+       codec->spec = spec;
+       spec->num_pins = 8;
+       spec->pin_nids = stac925x_pin_nids;
+       spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
+                                                       stac925x_models,
+                                                       stac925x_cfg_tbl);
+       if (spec->board_config < 0) {
+               snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x, using BIOS defaults\n");
+               err = stac92xx_save_bios_config_regs(codec);
+               if (err < 0) {
+                       stac92xx_free(codec);
+                       return err;
+               }
+               spec->pin_configs = spec->bios_pin_configs;
+       } else if (stac925x_brd_tbl[spec->board_config] != NULL){
+               spec->pin_configs = stac925x_brd_tbl[spec->board_config];
+               stac92xx_set_config_regs(codec);
+       }
+
+       spec->multiout.max_channels = 2;
+       spec->multiout.num_dacs = 1;
+       spec->multiout.dac_nids = stac925x_dac_nids;
+       spec->adc_nids = stac925x_adc_nids;
+       spec->mux_nids = stac925x_mux_nids;
+       spec->num_muxes = 1;
+       spec->num_dmics = 0;
+
+       spec->init = stac925x_core_init;
+       spec->mixer = stac925x_mixer;
+
+       err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
+       if (err < 0) {
+               stac92xx_free(codec);
+               return err;
+       }
+
+       codec->patch_ops = stac92xx_patch_ops;
+
+       return 0;
+}
+
 static int patch_stac922x(struct hda_codec *codec)
 {
        struct sigmatel_spec *spec;
@@ -1645,7 +1847,9 @@ static int patch_stac922x(struct hda_codec *codec)
        codec->spec = spec;
        spec->num_pins = 10;
        spec->pin_nids = stac922x_pin_nids;
-       spec->board_config = snd_hda_check_board_config(codec, stac922x_cfg_tbl);
+       spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
+                                                       stac922x_models,
+                                                       stac922x_cfg_tbl);
        if (spec->board_config < 0) {
                snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
                        "using BIOS defaults\n");
@@ -1663,6 +1867,7 @@ static int patch_stac922x(struct hda_codec *codec)
        spec->adc_nids = stac922x_adc_nids;
        spec->mux_nids = stac922x_mux_nids;
        spec->num_muxes = 2;
+       spec->num_dmics = 0;
 
        spec->init = stac922x_core_init;
        spec->mixer = stac922x_mixer;
@@ -1695,7 +1900,9 @@ static int patch_stac927x(struct hda_codec *codec)
        codec->spec = spec;
        spec->num_pins = 14;
        spec->pin_nids = stac927x_pin_nids;
-       spec->board_config = snd_hda_check_board_config(codec, stac927x_cfg_tbl);
+       spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
+                                                       stac927x_models,
+                                                       stac927x_cfg_tbl);
        if (spec->board_config < 0) {
                 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC927x, using BIOS defaults\n");
                err = stac92xx_save_bios_config_regs(codec);
@@ -1714,6 +1921,7 @@ static int patch_stac927x(struct hda_codec *codec)
                spec->adc_nids = stac927x_adc_nids;
                spec->mux_nids = stac927x_mux_nids;
                spec->num_muxes = 3;
+               spec->num_dmics = 0;
                spec->init = d965_core_init;
                spec->mixer = stac9227_mixer;
                break;
@@ -1721,6 +1929,7 @@ static int patch_stac927x(struct hda_codec *codec)
                spec->adc_nids = stac927x_adc_nids;
                spec->mux_nids = stac927x_mux_nids;
                spec->num_muxes = 3;
+               spec->num_dmics = 0;
                spec->init = d965_core_init;
                spec->mixer = stac9227_mixer;
                break;
@@ -1728,6 +1937,7 @@ static int patch_stac927x(struct hda_codec *codec)
                spec->adc_nids = stac927x_adc_nids;
                spec->mux_nids = stac927x_mux_nids;
                spec->num_muxes = 3;
+               spec->num_dmics = 0;
                spec->init = stac927x_core_init;
                spec->mixer = stac927x_mixer;
        }
@@ -1757,7 +1967,9 @@ static int patch_stac9205(struct hda_codec *codec)
        codec->spec = spec;
        spec->num_pins = 14;
        spec->pin_nids = stac9205_pin_nids;
-       spec->board_config = snd_hda_check_board_config(codec, stac9205_cfg_tbl);
+       spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
+                                                       stac9205_models,
+                                                       stac9205_cfg_tbl);
        if (spec->board_config < 0) {
                snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
                err = stac92xx_save_bios_config_regs(codec);
@@ -1773,13 +1985,28 @@ static int patch_stac9205(struct hda_codec *codec)
 
        spec->adc_nids = stac9205_adc_nids;
        spec->mux_nids = stac9205_mux_nids;
-       spec->num_muxes = 3;
+       spec->num_muxes = 2;
+       spec->dmic_nids = stac9205_dmic_nids;
+       spec->num_dmics = 2;
+       spec->dmux_nid = 0x1d;
 
        spec->init = stac9205_core_init;
        spec->mixer = stac9205_mixer;
 
        spec->multiout.dac_nids = spec->dac_nids;
 
+       /* Configure GPIO0 as EAPD output */
+       snd_hda_codec_write(codec, codec->afg, 0,
+                           AC_VERB_SET_GPIO_DIRECTION, 0x00000001);
+       /* Configure GPIO0 as CMOS */
+       snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0x00000000);
+       /* Assert GPIO0 high */
+       snd_hda_codec_write(codec, codec->afg, 0,
+                           AC_VERB_SET_GPIO_DATA, 0x00000001);
+       /* Enable GPIO0 */
+       snd_hda_codec_write(codec, codec->afg, 0,
+                           AC_VERB_SET_GPIO_MASK, 0x00000001);
+
        err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
        if (err < 0) {
                stac92xx_free(codec);
@@ -1963,18 +2190,19 @@ enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
        /* Unknown. id=0x83847661 and subsys=0x104D1200. */
        STAC9872K_VAIO,
        /* AR Series. id=0x83847664 and subsys=104D1300 */
-       CXD9872AKD_VAIO 
-     };
-
-static struct hda_board_config stac9872_cfg_tbl[] = {
-       { .modelname = "vaio", .config = CXD9872RD_VAIO },
-       { .modelname = "vaio-ar", .config = CXD9872AKD_VAIO },
-       { .pci_subvendor = 0x104d, .pci_subdevice = 0x81e6,
-         .config = CXD9872RD_VAIO },
-       { .pci_subvendor = 0x104d, .pci_subdevice = 0x81ef,
-         .config = CXD9872RD_VAIO },
-       { .pci_subvendor = 0x104d, .pci_subdevice = 0x81fd,
-         .config = CXD9872AKD_VAIO },
+       CXD9872AKD_VAIO,
+       STAC_9872_MODELS,
+};
+
+static const char *stac9872_models[STAC_9872_MODELS] = {
+       [CXD9872RD_VAIO]        = "vaio",
+       [CXD9872AKD_VAIO]       = "vaio-ar",
+};
+
+static struct snd_pci_quirk stac9872_cfg_tbl[] = {
+       SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
+       SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
+       SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
        {}
 };
 
@@ -1983,7 +2211,9 @@ static int patch_stac9872(struct hda_codec *codec)
        struct sigmatel_spec *spec;
        int board_config;
 
-       board_config = snd_hda_check_board_config(codec, stac9872_cfg_tbl);
+       board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
+                                                 stac9872_models,
+                                                 stac9872_cfg_tbl);
        if (board_config < 0)
                /* unknown config, let generic-parser do its job... */
                return snd_hda_parse_generic_codec(codec);
@@ -2055,6 +2285,12 @@ struct hda_codec_preset snd_hda_preset_sigmatel[] = {
        { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
        { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
        { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
+       { .id = 0x83847632, .name = "STAC9202",  .patch = patch_stac925x },
+       { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
+       { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
+       { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
+       { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
+       { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
        /* The following does not take into account .id=0x83847661 when subsys =
         * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
         * currently not fully supported.
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c
new file mode 100644 (file)
index 0000000..4c839b0
--- /dev/null
@@ -0,0 +1,1396 @@
+/*
+ * Universal Interface for Intel High Definition Audio Codec
+ *
+ * HD audio interface patch for VIA VT1708 codec
+ *
+ * Copyright (c) 2006 Lydia Wang <lydiawang@viatech.com>
+ *                    Takashi Iwai <tiwai@suse.de>
+ *
+ *  This driver is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This driver is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+ */
+
+/* * * * * * * * * * * * * * Release History * * * * * * * * * * * * * * * * */
+/*                                                                           */
+/* 2006-03-03  Lydia Wang  Create the basic patch to support VT1708 codec    */
+/* 2006-03-14  Lydia Wang  Modify hard code for some pin widget nid          */
+/* 2006-08-02  Lydia Wang  Add support to VT1709 codec                       */
+/* 2006-09-08  Lydia Wang  Fix internal loopback recording source select bug */
+/*                                                                           */
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+
+#include <sound/driver.h>
+#include <linux/init.h>
+#include <linux/delay.h>
+#include <linux/slab.h>
+#include <linux/pci.h>
+#include <sound/core.h>
+#include "hda_codec.h"
+#include "hda_local.h"
+
+
+/* amp values */
+#define AMP_VAL_IDX_SHIFT      19
+#define AMP_VAL_IDX_MASK       (0x0f<<19)
+
+#define NUM_CONTROL_ALLOC      32
+#define NUM_VERB_ALLOC         32
+
+/* Pin Widget NID */
+#define VT1708_HP_NID          0x13
+#define VT1708_DIGOUT_NID      0x14
+#define VT1708_DIGIN_NID       0x16
+
+#define VT1709_HP_DAC_NID      0x28
+#define VT1709_DIGOUT_NID      0x13
+#define VT1709_DIGIN_NID       0x17
+
+#define IS_VT1708_VENDORID(x)          ((x) >= 0x11061708 && (x) <= 0x1106170b)
+#define IS_VT1709_10CH_VENDORID(x)     ((x) >= 0x1106e710 && (x) <= 0x1106e713)
+#define IS_VT1709_6CH_VENDORID(x)      ((x) >= 0x1106e714 && (x) <= 0x1106e717)
+
+
+enum {
+       VIA_CTL_WIDGET_VOL,
+       VIA_CTL_WIDGET_MUTE,
+};
+
+enum {
+       AUTO_SEQ_FRONT,
+       AUTO_SEQ_SURROUND,
+       AUTO_SEQ_CENLFE,
+       AUTO_SEQ_SIDE
+};
+
+static struct snd_kcontrol_new vt1708_control_templates[] = {
+       HDA_CODEC_VOLUME(NULL, 0, 0, 0),
+       HDA_CODEC_MUTE(NULL, 0, 0, 0),
+};
+
+
+struct via_spec {
+       /* codec parameterization */
+       struct snd_kcontrol_new *mixers[3];
+       unsigned int num_mixers;
+
+       struct hda_verb *init_verbs;
+
+       char *stream_name_analog;
+       struct hda_pcm_stream *stream_analog_playback;
+       struct hda_pcm_stream *stream_analog_capture;
+
+       char *stream_name_digital;
+       struct hda_pcm_stream *stream_digital_playback;
+       struct hda_pcm_stream *stream_digital_capture;
+
+       /* playback */
+       struct hda_multi_out multiout;
+
+       /* capture */
+       unsigned int num_adc_nids;
+       hda_nid_t *adc_nids;
+       hda_nid_t dig_in_nid;
+
+       /* capture source */
+       const struct hda_input_mux *input_mux;
+       unsigned int cur_mux[3];
+
+       /* PCM information */
+       struct hda_pcm pcm_rec[2];
+
+       /* dynamic controls, init_verbs and input_mux */
+       struct auto_pin_cfg autocfg;
+       unsigned int num_kctl_alloc, num_kctl_used;
+       struct snd_kcontrol_new *kctl_alloc;
+       struct hda_input_mux private_imux;
+       hda_nid_t private_dac_nids[4];  
+};
+
+static hda_nid_t vt1708_adc_nids[2] = {
+       /* ADC1-2 */
+       0x15, 0x27
+};
+
+static hda_nid_t vt1709_adc_nids[3] = {
+       /* ADC1-2 */
+       0x14, 0x15, 0x16
+};
+
+/* add dynamic controls */
+static int via_add_control(struct via_spec *spec, int type, const char *name,
+                          unsigned long val)
+{
+       struct snd_kcontrol_new *knew;
+
+       if (spec->num_kctl_used >= spec->num_kctl_alloc) {
+               int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
+
+               /* array + terminator */
+               knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
+               if (!knew)
+                       return -ENOMEM;
+               if (spec->kctl_alloc) {
+                       memcpy(knew, spec->kctl_alloc,
+                              sizeof(*knew) * spec->num_kctl_alloc);
+                       kfree(spec->kctl_alloc);
+               }
+               spec->kctl_alloc = knew;
+               spec->num_kctl_alloc = num;
+       }
+
+       knew = &spec->kctl_alloc[spec->num_kctl_used];
+       *knew = vt1708_control_templates[type];
+       knew->name = kstrdup(name, GFP_KERNEL);
+
+       if (!knew->name)
+               return -ENOMEM;
+       knew->private_value = val;
+       spec->num_kctl_used++;
+       return 0;
+}
+
+/* create input playback/capture controls for the given pin */
+static int via_new_analog_input(struct via_spec *spec, hda_nid_t pin,
+                               const char *ctlname, int idx, int mix_nid)
+{
+       char name[32];
+       int err;
+
+       sprintf(name, "%s Playback Volume", ctlname);
+       err = via_add_control(spec, VIA_CTL_WIDGET_VOL, name,
+                             HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
+       if (err < 0)
+               return err;
+       sprintf(name, "%s Playback Switch", ctlname);
+       err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, name,
+                             HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
+       if (err < 0)
+               return err;
+       return 0;
+}
+
+static void via_auto_set_output_and_unmute(struct hda_codec *codec,
+                                          hda_nid_t nid, int pin_type,
+                                          int dac_idx)
+{
+       /* set as output */
+       snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
+                           pin_type);
+       snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
+                           AMP_OUT_UNMUTE);
+}
+
+
+static void via_auto_init_multi_out(struct hda_codec *codec)
+{
+       struct via_spec *spec = codec->spec;
+       int i;
+
+       for (i = 0; i <= AUTO_SEQ_SIDE; i++) {
+               hda_nid_t nid = spec->autocfg.line_out_pins[i];
+               if (nid)
+                       via_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
+       }
+}
+
+static void via_auto_init_hp_out(struct hda_codec *codec)
+{
+       struct via_spec *spec = codec->spec;
+       hda_nid_t pin;
+
+       pin = spec->autocfg.hp_pins[0];
+       if (pin) /* connect to front */
+               via_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
+}
+
+static void via_auto_init_analog_input(struct hda_codec *codec)
+{
+       struct via_spec *spec = codec->spec;
+       int i;
+
+       for (i = 0; i < AUTO_PIN_LAST; i++) {
+               hda_nid_t nid = spec->autocfg.input_pins[i];
+
+               snd_hda_codec_write(codec, nid, 0,
+                                   AC_VERB_SET_PIN_WIDGET_CONTROL,
+                                   (i <= AUTO_PIN_FRONT_MIC ?
+                                    PIN_VREF50 : PIN_IN));
+
+       }
+}
+/*
+ * input MUX handling
+ */
+static int via_mux_enum_info(struct snd_kcontrol *kcontrol,
+                            struct snd_ctl_elem_info *uinfo)
+{
+       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct via_spec *spec = codec->spec;
+       return snd_hda_input_mux_info(spec->input_mux, uinfo);
+}
+
+static int via_mux_enum_get(struct snd_kcontrol *kcontrol,
+                           struct snd_ctl_elem_value *ucontrol)
+{
+       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct via_spec *spec = codec->spec;
+       unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
+
+       ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
+       return 0;
+}
+
+static int via_mux_enum_put(struct snd_kcontrol *kcontrol,
+                           struct snd_ctl_elem_value *ucontrol)
+{
+       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct via_spec *spec = codec->spec;
+       unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
+       unsigned int vendor_id = codec->vendor_id;
+
+       /* AIW0  lydia 060801 add for correct sw0 input select */
+       if (IS_VT1708_VENDORID(vendor_id) && (adc_idx == 0))
+               return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
+                                            0x18, &spec->cur_mux[adc_idx]);
+       else if ((IS_VT1709_10CH_VENDORID(vendor_id) ||
+                 IS_VT1709_6CH_VENDORID(vendor_id)) && (adc_idx == 0) )
+               return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
+                                            0x19, &spec->cur_mux[adc_idx]);
+       else
+               return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
+                                            spec->adc_nids[adc_idx],
+                                            &spec->cur_mux[adc_idx]);
+}
+
+/* capture mixer elements */
+static struct snd_kcontrol_new vt1708_capture_mixer[] = {
+       HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_INPUT),
+       HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_INPUT),
+       HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x27, 0x0, HDA_INPUT),
+       HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x27, 0x0, HDA_INPUT),
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               /* The multiple "Capture Source" controls confuse alsamixer
+                * So call somewhat different..
+                * FIXME: the controls appear in the "playback" view!
+                */
+               /* .name = "Capture Source", */
+               .name = "Input Source",
+               .count = 1,
+               .info = via_mux_enum_info,
+               .get = via_mux_enum_get,
+               .put = via_mux_enum_put,
+       },
+       { } /* end */
+};
+/*
+ * generic initialization of ADC, input mixers and output mixers
+ */
+static struct hda_verb vt1708_volume_init_verbs[] = {
+       /*
+        * Unmute ADC0-1 and set the default input to mic-in
+        */
+       {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+       {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+
+
+       /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
+        * mixer widget
+        */
+       /* Amp Indices: CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */
+       {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+       {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
+       {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
+       {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
+       {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
+
+       /*
+        * Set up output mixers (0x19 - 0x1b)
+        */
+       /* set vol=0 to output mixers */
+       {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
+       {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
+       {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
+       
+       /* Setup default input to PW4 */
+       {0x20, AC_VERB_SET_CONNECT_SEL, 0x1},
+       /* Set mic as default input of sw0 */
+       {0x18, AC_VERB_SET_CONNECT_SEL, 0x2},
+       /* PW9 Output enable */
+       {0x25, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
+};
+
+static int via_playback_pcm_open(struct hda_pcm_stream *hinfo,
+                                struct hda_codec *codec,
+                                struct snd_pcm_substream *substream)
+{
+       struct via_spec *spec = codec->spec;
+       return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
+}
+
+static int via_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
+                                   struct hda_codec *codec,
+                                   unsigned int stream_tag,
+                                   unsigned int format,
+                                   struct snd_pcm_substream *substream)
+{
+       struct via_spec *spec = codec->spec;
+       return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
+                                               stream_tag, format, substream);
+}
+
+static int via_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
+                                   struct hda_codec *codec,
+                                   struct snd_pcm_substream *substream)
+{
+       struct via_spec *spec = codec->spec;
+       return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
+}
+
+/*
+ * Digital out
+ */
+static int via_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
+                                    struct hda_codec *codec,
+                                    struct snd_pcm_substream *substream)
+{
+       struct via_spec *spec = codec->spec;
+       return snd_hda_multi_out_dig_open(codec, &spec->multiout);
+}
+
+static int via_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
+                                     struct hda_codec *codec,
+                                     struct snd_pcm_substream *substream)
+{
+       struct via_spec *spec = codec->spec;
+       return snd_hda_multi_out_dig_close(codec, &spec->multiout);
+}
+
+/*
+ * Analog capture
+ */
+static int via_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
+                                  struct hda_codec *codec,
+                                  unsigned int stream_tag,
+                                  unsigned int format,
+                                  struct snd_pcm_substream *substream)
+{
+       struct via_spec *spec = codec->spec;
+
+       snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
+                                  stream_tag, 0, format);
+       return 0;
+}
+
+static int via_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
+                                  struct hda_codec *codec,
+                                  struct snd_pcm_substream *substream)
+{
+       struct via_spec *spec = codec->spec;
+       snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
+                                  0, 0, 0);
+       return 0;
+}
+
+static struct hda_pcm_stream vt1708_pcm_analog_playback = {
+       .substreams = 1,
+       .channels_min = 2,
+       .channels_max = 8,
+       .nid = 0x10, /* NID to query formats and rates */
+       .ops = {
+               .open = via_playback_pcm_open,
+               .prepare = via_playback_pcm_prepare,
+               .cleanup = via_playback_pcm_cleanup
+       },
+};
+
+static struct hda_pcm_stream vt1708_pcm_analog_capture = {
+       .substreams = 2,
+       .channels_min = 2,
+       .channels_max = 2,
+       .nid = 0x15, /* NID to query formats and rates */
+       .ops = {
+               .prepare = via_capture_pcm_prepare,
+               .cleanup = via_capture_pcm_cleanup
+       },
+};
+
+static struct hda_pcm_stream vt1708_pcm_digital_playback = {
+       .substreams = 1,
+       .channels_min = 2,
+       .channels_max = 2,
+       /* NID is set in via_build_pcms */
+       .ops = {
+               .open = via_dig_playback_pcm_open,
+               .close = via_dig_playback_pcm_close
+       },
+};
+
+static struct hda_pcm_stream vt1708_pcm_digital_capture = {
+       .substreams = 1,
+       .channels_min = 2,
+       .channels_max = 2,
+};
+
+static int via_build_controls(struct hda_codec *codec)
+{
+       struct via_spec *spec = codec->spec;
+       int err;
+       int i;
+
+       for (i = 0; i < spec->num_mixers; i++) {
+               err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
+               if (err < 0)
+                       return err;
+       }
+
+       if (spec->multiout.dig_out_nid) {
+               err = snd_hda_create_spdif_out_ctls(codec,
+                                                   spec->multiout.dig_out_nid);
+               if (err < 0)
+                       return err;
+       }
+       if (spec->dig_in_nid) {
+               err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
+               if (err < 0)
+                       return err;
+       }
+       return 0;
+}
+
+static int via_build_pcms(struct hda_codec *codec)
+{
+       struct via_spec *spec = codec->spec;
+       struct hda_pcm *info = spec->pcm_rec;
+
+       codec->num_pcms = 1;
+       codec->pcm_info = info;
+
+       info->name = spec->stream_name_analog;
+       info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
+       info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
+       info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
+       info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
+
+       info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max =
+               spec->multiout.max_channels;
+
+       if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
+               codec->num_pcms++;
+               info++;
+               info->name = spec->stream_name_digital;
+               if (spec->multiout.dig_out_nid) {
+                       info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
+                               *(spec->stream_digital_playback);
+                       info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
+                               spec->multiout.dig_out_nid;
+               }
+               if (spec->dig_in_nid) {
+                       info->stream[SNDRV_PCM_STREAM_CAPTURE] =
+                               *(spec->stream_digital_capture);
+                       info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
+                               spec->dig_in_nid;
+               }
+       }
+
+       return 0;
+}
+
+static void via_free(struct hda_codec *codec)
+{
+       struct via_spec *spec = codec->spec;
+       unsigned int i;
+
+       if (!spec)
+               return;
+
+       if (spec->kctl_alloc) {
+               for (i = 0; i < spec->num_kctl_used; i++)
+                       kfree(spec->kctl_alloc[i].name);
+               kfree(spec->kctl_alloc);
+       }
+
+       kfree(codec->spec);
+}
+
+static int via_init(struct hda_codec *codec)
+{
+       struct via_spec *spec = codec->spec;
+       snd_hda_sequence_write(codec, spec->init_verbs);
+       return 0;
+}
+
+#ifdef CONFIG_PM
+/*
+ * resume
+ */
+static int via_resume(struct hda_codec *codec)
+{
+       struct via_spec *spec = codec->spec;
+       int i;
+
+       via_init(codec);
+       for (i = 0; i < spec->num_mixers; i++)
+               snd_hda_resume_ctls(codec, spec->mixers[i]);
+       if (spec->multiout.dig_out_nid)
+               snd_hda_resume_spdif_out(codec);
+       if (spec->dig_in_nid)
+               snd_hda_resume_spdif_in(codec);
+
+       return 0;
+}
+#endif
+
+/*
+ */
+static struct hda_codec_ops via_patch_ops = {
+       .build_controls = via_build_controls,
+       .build_pcms = via_build_pcms,
+       .init = via_init,
+       .free = via_free,
+#ifdef CONFIG_PM
+       .resume = via_resume,
+#endif
+};
+
+/* fill in the dac_nids table from the parsed pin configuration */
+static int vt1708_auto_fill_dac_nids(struct via_spec *spec,
+                                    const struct auto_pin_cfg *cfg)
+{
+       int i;
+       hda_nid_t nid;
+
+       spec->multiout.num_dacs = cfg->line_outs;
+
+       spec->multiout.dac_nids = spec->private_dac_nids;
+       
+       for(i = 0; i < 4; i++) {
+               nid = cfg->line_out_pins[i];
+               if (nid) {
+                       /* config dac list */
+                       switch (i) {
+                       case AUTO_SEQ_FRONT:
+                               spec->multiout.dac_nids[i] = 0x10;
+                               break;
+                       case AUTO_SEQ_CENLFE:
+                               spec->multiout.dac_nids[i] = 0x12;
+                               break;
+                       case AUTO_SEQ_SURROUND:
+                               spec->multiout.dac_nids[i] = 0x13;
+                               break;
+                       case AUTO_SEQ_SIDE:
+                               spec->multiout.dac_nids[i] = 0x11;
+                               break;
+                       }
+               }
+       }
+
+       return 0;
+}
+
+/* add playback controls from the parsed DAC table */
+static int vt1708_auto_create_multi_out_ctls(struct via_spec *spec,
+                                            const struct auto_pin_cfg *cfg)
+{
+       char name[32];
+       static const char *chname[4] = { "Front", "Surround", "C/LFE", "Side" };
+       hda_nid_t nid, nid_vol = 0;
+       int i, err;
+
+       for (i = 0; i <= AUTO_SEQ_SIDE; i++) {
+               nid = cfg->line_out_pins[i];
+
+               if (!nid)
+                       continue;
+               
+               if (i != AUTO_SEQ_FRONT)
+                       nid_vol = 0x1b - i + 1;
+
+               if (i == AUTO_SEQ_CENLFE) {
+                       /* Center/LFE */
+                       err = via_add_control(spec, VIA_CTL_WIDGET_VOL,
+                                             "Center Playback Volume",
+                                             HDA_COMPOSE_AMP_VAL(nid_vol, 1, 0, HDA_OUTPUT));
+                       if (err < 0)
+                               return err;
+                       err = via_add_control(spec, VIA_CTL_WIDGET_VOL,
+                                             "LFE Playback Volume",
+                                             HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT));
+                       if (err < 0)
+                               return err;
+                       err = via_add_control(spec, VIA_CTL_WIDGET_MUTE,
+                                             "Center Playback Switch",
+                                             HDA_COMPOSE_AMP_VAL(nid_vol, 1, 0, HDA_OUTPUT));
+                       if (err < 0)
+                               return err;
+                       err = via_add_control(spec, VIA_CTL_WIDGET_MUTE,
+                                             "LFE Playback Switch",
+                                             HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT));
+                       if (err < 0)
+                               return err;
+               } else if (i == AUTO_SEQ_FRONT){
+                       /* add control to mixer index 0 */
+                       err = via_add_control(spec, VIA_CTL_WIDGET_VOL,
+                                             "Master Front Playback Volume",
+                                             HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT));
+                       if (err < 0)
+                               return err;
+                       err = via_add_control(spec, VIA_CTL_WIDGET_MUTE,
+                                             "Master Front Playback Switch",
+                                             HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT));
+                       if (err < 0)
+                               return err;
+                       
+                       /* add control to PW3 */
+                       sprintf(name, "%s Playback Volume", chname[i]);
+                       err = via_add_control(spec, VIA_CTL_WIDGET_VOL, name,
+                                             HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
+                       if (err < 0)
+                               return err;
+                       sprintf(name, "%s Playback Switch", chname[i]);
+                       err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, name,
+                                             HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
+                       if (err < 0)
+                               return err;
+               } else {
+                       sprintf(name, "%s Playback Volume", chname[i]);
+                       err = via_add_control(spec, VIA_CTL_WIDGET_VOL, name,
+                                             HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT));
+                       if (err < 0)
+                               return err;
+                       sprintf(name, "%s Playback Switch", chname[i]);
+                       err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, name,
+                                             HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT));
+                       if (err < 0)
+                               return err;
+               }
+       }
+
+       return 0;
+}
+
+static int vt1708_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin)
+{
+       int err;
+
+       if (!pin)
+               return 0;
+
+       spec->multiout.hp_nid = VT1708_HP_NID; /* AOW3 */
+
+       err = via_add_control(spec, VIA_CTL_WIDGET_VOL,
+                             "Headphone Playback Volume",
+                             HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
+       if (err < 0)
+               return err;
+       err = via_add_control(spec, VIA_CTL_WIDGET_MUTE,
+                             "Headphone Playback Switch",
+                             HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
+       if (err < 0)
+               return err;
+
+       return 0;
+}
+
+/* create playback/capture controls for input pins */
+static int vt1708_auto_create_analog_input_ctls(struct via_spec *spec,
+                                               const struct auto_pin_cfg *cfg)
+{
+       static char *labels[] = {
+               "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux", NULL
+       };
+       struct hda_input_mux *imux = &spec->private_imux;
+       int i, err, idx = 0;
+
+       /* for internal loopback recording select */
+       imux->items[imux->num_items].label = "Stereo Mixer";
+       imux->items[imux->num_items].index = idx;
+       imux->num_items++;
+
+       for (i = 0; i < AUTO_PIN_LAST; i++) {
+               if (!cfg->input_pins[i])
+                       continue;
+
+               switch (cfg->input_pins[i]) {
+               case 0x1d: /* Mic */
+                       idx = 2;
+                       break;
+                               
+               case 0x1e: /* Line In */
+                       idx = 3;
+                       break;
+
+               case 0x21: /* Front Mic */
+                       idx = 4;
+                       break;
+
+               case 0x24: /* CD */
+                       idx = 1;
+                       break;
+               }
+               err = via_new_analog_input(spec, cfg->input_pins[i], labels[i],
+                                          idx, 0x17);
+               if (err < 0)
+                       return err;
+               imux->items[imux->num_items].label = labels[i];
+               imux->items[imux->num_items].index = idx;
+               imux->num_items++;
+       }
+       return 0;
+}
+
+static int vt1708_parse_auto_config(struct hda_codec *codec)
+{
+       struct via_spec *spec = codec->spec;
+       int err;
+
+       err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL);
+       if (err < 0)
+               return err;
+       err = vt1708_auto_fill_dac_nids(spec, &spec->autocfg);
+       if (err < 0)
+               return err;
+       if (!spec->autocfg.line_outs && !spec->autocfg.hp_pins[0])
+               return 0; /* can't find valid BIOS pin config */
+
+       err = vt1708_auto_create_multi_out_ctls(spec, &spec->autocfg);
+       if (err < 0)
+               return err;
+       err = vt1708_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
+       if (err < 0)
+               return err;
+       err = vt1708_auto_create_analog_input_ctls(spec, &spec->autocfg);
+       if (err < 0)
+               return err;
+
+       spec->multiout.max_channels = spec->multiout.num_dacs * 2;
+
+       if (spec->autocfg.dig_out_pin)
+               spec->multiout.dig_out_nid = VT1708_DIGOUT_NID;
+       if (spec->autocfg.dig_in_pin)
+               spec->dig_in_nid = VT1708_DIGIN_NID;
+
+       if (spec->kctl_alloc)
+               spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
+
+       spec->init_verbs = vt1708_volume_init_verbs;    
+
+       spec->input_mux = &spec->private_imux;
+
+       return 1;
+}
+
+/* init callback for auto-configuration model -- overriding the default init */
+static int via_auto_init(struct hda_codec *codec)
+{
+       via_init(codec);
+       via_auto_init_multi_out(codec);
+       via_auto_init_hp_out(codec);
+       via_auto_init_analog_input(codec);
+       return 0;
+}
+
+static int patch_vt1708(struct hda_codec *codec)
+{
+       struct via_spec *spec;
+       int err;
+
+       /* create a codec specific record */
+       spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
+       if (spec == NULL)
+               return -ENOMEM;
+
+       codec->spec = spec;
+
+       /* automatic parse from the BIOS config */
+       err = vt1708_parse_auto_config(codec);
+       if (err < 0) {
+               via_free(codec);
+               return err;
+       } else if (!err) {
+               printk(KERN_INFO "hda_codec: Cannot set up configuration "
+                      "from BIOS.  Using genenic mode...\n");
+       }
+
+       
+       spec->stream_name_analog = "VT1708 Analog";
+       spec->stream_analog_playback = &vt1708_pcm_analog_playback;
+       spec->stream_analog_capture = &vt1708_pcm_analog_capture;
+
+       spec->stream_name_digital = "VT1708 Digital";
+       spec->stream_digital_playback = &vt1708_pcm_digital_playback;
+       spec->stream_digital_capture = &vt1708_pcm_digital_capture;
+
+       
+       if (!spec->adc_nids && spec->input_mux) {
+               spec->adc_nids = vt1708_adc_nids;
+               spec->num_adc_nids = ARRAY_SIZE(vt1708_adc_nids);
+               spec->mixers[spec->num_mixers] = vt1708_capture_mixer;
+               spec->num_mixers++;
+       }
+
+       codec->patch_ops = via_patch_ops;
+
+       codec->patch_ops.init = via_auto_init;
+
+       return 0;
+}
+
+/* capture mixer elements */
+static struct snd_kcontrol_new vt1709_capture_mixer[] = {
+       HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x0, HDA_INPUT),
+       HDA_CODEC_MUTE("Capture Switch", 0x14, 0x0, HDA_INPUT),
+       HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x15, 0x0, HDA_INPUT),
+       HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x15, 0x0, HDA_INPUT),
+       HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x16, 0x0, HDA_INPUT),
+       HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x16, 0x0, HDA_INPUT),
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               /* The multiple "Capture Source" controls confuse alsamixer
+                * So call somewhat different..
+                * FIXME: the controls appear in the "playback" view!
+                */
+               /* .name = "Capture Source", */
+               .name = "Input Source",
+               .count = 1,
+               .info = via_mux_enum_info,
+               .get = via_mux_enum_get,
+               .put = via_mux_enum_put,
+       },
+       { } /* end */
+};
+
+/*
+ * generic initialization of ADC, input mixers and output mixers
+ */
+static struct hda_verb vt1709_10ch_volume_init_verbs[] = {
+       /*
+        * Unmute ADC0-2 and set the default input to mic-in
+        */
+       {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+       {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+       {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+
+
+       /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
+        * mixer widget
+        */
+       /* Amp Indices: AOW0=0, CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */
+       {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+       {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
+       {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
+       {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
+       {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
+
+       /*
+        * Set up output selector (0x1a, 0x1b, 0x29)
+        */
+       /* set vol=0 to output mixers */
+       {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
+       {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
+       {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
+
+       /*
+        *  Unmute PW3 and PW4
+        */
+       {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
+       {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
+
+       /* Set input of PW4 as AOW4 */
+       {0x20, AC_VERB_SET_CONNECT_SEL, 0x1},
+       /* Set mic as default input of sw0 */
+       {0x19, AC_VERB_SET_CONNECT_SEL, 0x2},
+       /* PW9 Output enable */
+       {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
+       { }
+};
+
+static struct hda_pcm_stream vt1709_10ch_pcm_analog_playback = {
+       .substreams = 1,
+       .channels_min = 2,
+       .channels_max = 10,
+       .nid = 0x10, /* NID to query formats and rates */
+       .ops = {
+               .open = via_playback_pcm_open,
+               .prepare = via_playback_pcm_prepare,
+               .cleanup = via_playback_pcm_cleanup
+       },
+};
+
+static struct hda_pcm_stream vt1709_6ch_pcm_analog_playback = {
+       .substreams = 1,
+       .channels_min = 2,
+       .channels_max = 6,
+       .nid = 0x10, /* NID to query formats and rates */
+       .ops = {
+               .open = via_playback_pcm_open,
+               .prepare = via_playback_pcm_prepare,
+               .cleanup = via_playback_pcm_cleanup
+       },
+};
+
+static struct hda_pcm_stream vt1709_pcm_analog_capture = {
+       .substreams = 2,
+       .channels_min = 2,
+       .channels_max = 2,
+       .nid = 0x14, /* NID to query formats and rates */
+       .ops = {
+               .prepare = via_capture_pcm_prepare,
+               .cleanup = via_capture_pcm_cleanup
+       },
+};
+
+static struct hda_pcm_stream vt1709_pcm_digital_playback = {
+       .substreams = 1,
+       .channels_min = 2,
+       .channels_max = 2,
+       /* NID is set in via_build_pcms */
+       .ops = {
+               .open = via_dig_playback_pcm_open,
+               .close = via_dig_playback_pcm_close
+       },
+};
+
+static struct hda_pcm_stream vt1709_pcm_digital_capture = {
+       .substreams = 1,
+       .channels_min = 2,
+       .channels_max = 2,
+};
+
+static int vt1709_auto_fill_dac_nids(struct via_spec *spec,
+                                    const struct auto_pin_cfg *cfg)
+{
+       int i;
+       hda_nid_t nid;
+
+       if (cfg->line_outs == 4)  /* 10 channels */
+               spec->multiout.num_dacs = cfg->line_outs+1; /* AOW0~AOW4 */
+       else if (cfg->line_outs == 3) /* 6 channels */
+               spec->multiout.num_dacs = cfg->line_outs; /* AOW0~AOW2 */
+
+       spec->multiout.dac_nids = spec->private_dac_nids;
+
+       if (cfg->line_outs == 4) { /* 10 channels */
+               for (i = 0; i < cfg->line_outs; i++) {
+                       nid = cfg->line_out_pins[i];
+                       if (nid) {
+                               /* config dac list */
+                               switch (i) {
+                               case AUTO_SEQ_FRONT:
+                                       /* AOW0 */
+                                       spec->multiout.dac_nids[i] = 0x10;
+                                       break;
+                               case AUTO_SEQ_CENLFE:
+                                       /* AOW2 */
+                                       spec->multiout.dac_nids[i] = 0x12;
+                                       break;
+                               case AUTO_SEQ_SURROUND:
+                                       /* AOW3 */
+                                       spec->multiout.dac_nids[i] = 0x27;
+                                       break;
+                               case AUTO_SEQ_SIDE:
+                                       /* AOW1 */
+                                       spec->multiout.dac_nids[i] = 0x11;
+                                       break;
+                               default:
+                                       break;
+                               }
+                       }
+               }
+               spec->multiout.dac_nids[cfg->line_outs] = 0x28; /* AOW4 */
+
+       } else if (cfg->line_outs == 3) { /* 6 channels */
+               for(i = 0; i < cfg->line_outs; i++) {
+                       nid = cfg->line_out_pins[i];
+                       if (nid) {
+                               /* config dac list */
+                               switch(i) {
+                               case AUTO_SEQ_FRONT:
+                                       /* AOW0 */
+                                       spec->multiout.dac_nids[i] = 0x10;
+                                       break;
+                               case AUTO_SEQ_CENLFE:
+                                       /* AOW2 */
+                                       spec->multiout.dac_nids[i] = 0x12;
+                                       break;
+                               case AUTO_SEQ_SURROUND:
+                                       /* AOW1 */
+                                       spec->multiout.dac_nids[i] = 0x11;
+                                       break;
+                               default:
+                                       break;
+                               }
+                       }
+               }
+       }
+
+       return 0;
+}
+
+/* add playback controls from the parsed DAC table */
+static int vt1709_auto_create_multi_out_ctls(struct via_spec *spec,
+                                            const struct auto_pin_cfg *cfg)
+{
+       char name[32];
+       static const char *chname[4] = { "Front", "Surround", "C/LFE", "Side" };
+       hda_nid_t nid = 0;
+       int i, err;
+
+       for (i = 0; i <= AUTO_SEQ_SIDE; i++) {
+               nid = cfg->line_out_pins[i];
+
+               if (!nid)       
+                       continue;
+
+               if (i == AUTO_SEQ_CENLFE) {
+                       /* Center/LFE */
+                       err = via_add_control(spec, VIA_CTL_WIDGET_VOL,
+                                             "Center Playback Volume",
+                                             HDA_COMPOSE_AMP_VAL(0x1b, 1, 0, HDA_OUTPUT));
+                       if (err < 0)
+                               return err;
+                       err = via_add_control(spec, VIA_CTL_WIDGET_VOL,
+                                             "LFE Playback Volume",
+                                             HDA_COMPOSE_AMP_VAL(0x1b, 2, 0, HDA_OUTPUT));
+                       if (err < 0)
+                               return err;
+                       err = via_add_control(spec, VIA_CTL_WIDGET_MUTE,
+                                             "Center Playback Switch",
+                                             HDA_COMPOSE_AMP_VAL(0x1b, 1, 0, HDA_OUTPUT));
+                       if (err < 0)
+                               return err;
+                       err = via_add_control(spec, VIA_CTL_WIDGET_MUTE,
+                                             "LFE Playback Switch",
+                                             HDA_COMPOSE_AMP_VAL(0x1b, 2, 0, HDA_OUTPUT));
+                       if (err < 0)
+                               return err;
+               } else if (i == AUTO_SEQ_FRONT){
+                       /* add control to mixer index 0 */
+                       err = via_add_control(spec, VIA_CTL_WIDGET_VOL,
+                                             "Master Front Playback Volume",
+                                             HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT));
+                       if (err < 0)
+                               return err;
+                       err = via_add_control(spec, VIA_CTL_WIDGET_MUTE,
+                                             "Master Front Playback Switch",
+                                             HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT));
+                       if (err < 0)
+                               return err;
+                       
+                       /* add control to PW3 */
+                       sprintf(name, "%s Playback Volume", chname[i]);
+                       err = via_add_control(spec, VIA_CTL_WIDGET_VOL, name,
+                                             HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
+                       if (err < 0)
+                               return err;
+                       sprintf(name, "%s Playback Switch", chname[i]);
+                       err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, name,
+                                             HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
+                       if (err < 0)
+                               return err;
+               } else if (i == AUTO_SEQ_SURROUND) {
+                       sprintf(name, "%s Playback Volume", chname[i]);
+                       err = via_add_control(spec, VIA_CTL_WIDGET_VOL, name,
+                                             HDA_COMPOSE_AMP_VAL(0x29, 3, 0, HDA_OUTPUT));
+                       if (err < 0)
+                               return err;
+                       sprintf(name, "%s Playback Switch", chname[i]);
+                       err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, name,
+                                             HDA_COMPOSE_AMP_VAL(0x29, 3, 0, HDA_OUTPUT));
+                       if (err < 0)
+                               return err;
+               } else if (i == AUTO_SEQ_SIDE) {
+                       sprintf(name, "%s Playback Volume", chname[i]);
+                       err = via_add_control(spec, VIA_CTL_WIDGET_VOL, name,
+                                             HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT));
+                       if (err < 0)
+                               return err;
+                       sprintf(name, "%s Playback Switch", chname[i]);
+                       err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, name,
+                                             HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT));
+                       if (err < 0)
+                               return err;
+               }
+       }
+
+       return 0;
+}
+
+static int vt1709_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin)
+{
+       int err;
+
+       if (!pin)
+               return 0;
+
+       if (spec->multiout.num_dacs == 5) /* 10 channels */
+               spec->multiout.hp_nid = VT1709_HP_DAC_NID;
+       else if (spec->multiout.num_dacs == 3) /* 6 channels */
+               spec->multiout.hp_nid = 0;
+
+       err = via_add_control(spec, VIA_CTL_WIDGET_VOL,
+                             "Headphone Playback Volume",
+                             HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
+       if (err < 0)
+               return err;
+       err = via_add_control(spec, VIA_CTL_WIDGET_MUTE,
+                             "Headphone Playback Switch",
+                             HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
+       if (err < 0)
+               return err;
+
+       return 0;
+}
+
+/* create playback/capture controls for input pins */
+static int vt1709_auto_create_analog_input_ctls(struct via_spec *spec,
+                                               const struct auto_pin_cfg *cfg)
+{
+       static char *labels[] = {
+               "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux", NULL
+       };
+       struct hda_input_mux *imux = &spec->private_imux;
+       int i, err, idx = 0;
+
+       /* for internal loopback recording select */
+       imux->items[imux->num_items].label = "Stereo Mixer";
+       imux->items[imux->num_items].index = idx;
+       imux->num_items++;
+
+       for (i = 0; i < AUTO_PIN_LAST; i++) {
+               if (!cfg->input_pins[i])
+                       continue;
+
+               switch (cfg->input_pins[i]) {
+               case 0x1d: /* Mic */
+                       idx = 2;
+                       break;
+                               
+               case 0x1e: /* Line In */
+                       idx = 3;
+                       break;
+
+               case 0x21: /* Front Mic */
+                       idx = 4;
+                       break;
+
+               case 0x23: /* CD */
+                       idx = 1;
+                       break;
+               }
+               err = via_new_analog_input(spec, cfg->input_pins[i], labels[i],
+                                          idx, 0x18);
+               if (err < 0)
+                       return err;
+               imux->items[imux->num_items].label = labels[i];
+               imux->items[imux->num_items].index = idx;
+               imux->num_items++;
+       }
+       return 0;
+}
+
+static int vt1709_parse_auto_config(struct hda_codec *codec)
+{
+       struct via_spec *spec = codec->spec;
+       int err;
+
+       err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL);
+       if (err < 0)
+               return err;
+       err = vt1709_auto_fill_dac_nids(spec, &spec->autocfg);
+       if (err < 0)
+               return err;
+       if (!spec->autocfg.line_outs && !spec->autocfg.hp_pins[0])
+               return 0; /* can't find valid BIOS pin config */
+
+       err = vt1709_auto_create_multi_out_ctls(spec, &spec->autocfg);
+       if (err < 0)
+               return err;
+       err = vt1709_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
+       if (err < 0)
+               return err;
+       err = vt1709_auto_create_analog_input_ctls(spec, &spec->autocfg);
+       if (err < 0)
+               return err;
+
+       spec->multiout.max_channels = spec->multiout.num_dacs * 2;
+
+       if (spec->autocfg.dig_out_pin)
+               spec->multiout.dig_out_nid = VT1709_DIGOUT_NID;
+       if (spec->autocfg.dig_in_pin)
+               spec->dig_in_nid = VT1709_DIGIN_NID;
+
+       if (spec->kctl_alloc)
+               spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
+
+       spec->input_mux = &spec->private_imux;
+
+       return 1;
+}
+
+static int patch_vt1709_10ch(struct hda_codec *codec)
+{
+       struct via_spec *spec;
+       int err;
+
+       /* create a codec specific record */
+       spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
+       if (spec == NULL)
+               return -ENOMEM;
+
+       codec->spec = spec;
+
+       err = vt1709_parse_auto_config(codec);
+       if (err < 0) {
+               via_free(codec);
+               return err;
+       } else if (!err) {
+               printk(KERN_INFO "hda_codec: Cannot set up configuration.  "
+                      "Using genenic mode...\n");
+       }
+
+       spec->init_verbs = vt1709_10ch_volume_init_verbs;       
+
+       spec->stream_name_analog = "VT1709 Analog";
+       spec->stream_analog_playback = &vt1709_10ch_pcm_analog_playback;
+       spec->stream_analog_capture = &vt1709_pcm_analog_capture;
+
+       spec->stream_name_digital = "VT1709 Digital";
+       spec->stream_digital_playback = &vt1709_pcm_digital_playback;
+       spec->stream_digital_capture = &vt1709_pcm_digital_capture;
+
+       
+       if (!spec->adc_nids && spec->input_mux) {
+               spec->adc_nids = vt1709_adc_nids;
+               spec->num_adc_nids = ARRAY_SIZE(vt1709_adc_nids);
+               spec->mixers[spec->num_mixers] = vt1709_capture_mixer;
+               spec->num_mixers++;
+       }
+
+       codec->patch_ops = via_patch_ops;
+
+       codec->patch_ops.init = via_auto_init;
+
+       return 0;
+}
+/*
+ * generic initialization of ADC, input mixers and output mixers
+ */
+static struct hda_verb vt1709_6ch_volume_init_verbs[] = {
+       /*
+        * Unmute ADC0-2 and set the default input to mic-in
+        */
+       {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+       {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+       {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+
+
+       /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
+        * mixer widget
+        */
+       /* Amp Indices: AOW0=0, CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */
+       {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+       {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
+       {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
+       {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
+       {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
+
+       /*
+        * Set up output selector (0x1a, 0x1b, 0x29)
+        */
+       /* set vol=0 to output mixers */
+       {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
+       {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
+       {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
+
+       /*
+        *  Unmute PW3 and PW4
+        */
+       {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
+       {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
+
+       /* Set input of PW4 as MW0 */
+       {0x20, AC_VERB_SET_CONNECT_SEL, 0},
+       /* Set mic as default input of sw0 */
+       {0x19, AC_VERB_SET_CONNECT_SEL, 0x2},
+       /* PW9 Output enable */
+       {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
+       { }
+};
+
+static int patch_vt1709_6ch(struct hda_codec *codec)
+{
+       struct via_spec *spec;
+       int err;
+
+       /* create a codec specific record */
+       spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
+       if (spec == NULL)
+               return -ENOMEM;
+
+       codec->spec = spec;
+
+       err = vt1709_parse_auto_config(codec);
+       if (err < 0) {
+               via_free(codec);
+               return err;
+       } else if (!err) {
+               printk(KERN_INFO "hda_codec: Cannot set up configuration.  "
+                      "Using genenic mode...\n");
+       }
+
+       spec->init_verbs = vt1709_6ch_volume_init_verbs;        
+
+       spec->stream_name_analog = "VT1709 Analog";
+       spec->stream_analog_playback = &vt1709_6ch_pcm_analog_playback;
+       spec->stream_analog_capture = &vt1709_pcm_analog_capture;
+
+       spec->stream_name_digital = "VT1709 Digital";
+       spec->stream_digital_playback = &vt1709_pcm_digital_playback;
+       spec->stream_digital_capture = &vt1709_pcm_digital_capture;
+
+       
+       if (!spec->adc_nids && spec->input_mux) {
+               spec->adc_nids = vt1709_adc_nids;
+               spec->num_adc_nids = ARRAY_SIZE(vt1709_adc_nids);
+               spec->mixers[spec->num_mixers] = vt1709_capture_mixer;
+               spec->num_mixers++;
+       }
+
+       codec->patch_ops = via_patch_ops;
+
+       codec->patch_ops.init = via_auto_init;
+
+       return 0;
+}
+
+/*
+ * patch entries
+ */
+struct hda_codec_preset snd_hda_preset_via[] = {
+       { .id = 0x11061708, .name = "VIA VT1708", .patch = patch_vt1708},
+       { .id = 0x11061709, .name = "VIA VT1708", .patch = patch_vt1708},
+       { .id = 0x1106170A, .name = "VIA VT1708", .patch = patch_vt1708},
+       { .id = 0x1106170B, .name = "VIA VT1708", .patch = patch_vt1708},
+       { .id = 0x1106E710, .name = "VIA VT1709 10-Ch", .patch = patch_vt1709_10ch},
+       { .id = 0x1106E711, .name = "VIA VT1709 10-Ch", .patch = patch_vt1709_10ch},
+       { .id = 0x1106E712, .name = "VIA VT1709 10-Ch", .patch = patch_vt1709_10ch},
+       { .id = 0x1106E713, .name = "VIA VT1709 10-Ch", .patch = patch_vt1709_10ch},
+       { .id = 0x1106E714, .name = "VIA VT1709 6-Ch", .patch = patch_vt1709_6ch},
+       { .id = 0x1106E715, .name = "VIA VT1709 6-Ch", .patch = patch_vt1709_6ch},
+       { .id = 0x1106E716, .name = "VIA VT1709 6-Ch", .patch = patch_vt1709_6ch},
+       { .id = 0x1106E717, .name = "VIA VT1709 6-Ch", .patch = patch_vt1709_6ch},
+       {} /* terminator */
+};
index 7837cef8855c23d43e9dabf7d2b4565b5bc69384..6efdd62f68375001f96be4449a6d1817542ac414 100644 (file)
@@ -5,7 +5,7 @@
 
 snd-ice17xx-ak4xxx-objs := ak4xxx.o
 snd-ice1712-objs := ice1712.o delta.o hoontech.o ews.o
-snd-ice1724-objs := ice1724.o amp.o revo.o aureon.o vt1720_mobo.o pontis.o prodigy192.o juli.o phase.o
+snd-ice1724-objs := ice1724.o amp.o revo.o aureon.o vt1720_mobo.o pontis.o prodigy192.o juli.o phase.o wtm.o
 
 # Toplevel Module Dependency
 obj-$(CONFIG_SND_ICE1712) += snd-ice1712.o snd-ice17xx-ak4xxx.o
index 59c4078ad33133f82937ca98a4e5062632f8e7f8..6e22d326df328ad04bfa00a1c2c31f80406a212b 100644 (file)
@@ -42,7 +42,7 @@ static void wm_put(struct snd_ice1712 *ice, int reg, unsigned short val)
 
 static int __devinit snd_vt1724_amp_init(struct snd_ice1712 *ice)
 {
-       static unsigned short wm_inits[] = {
+       static const unsigned short wm_inits[] = {
                WM_ATTEN_L,     0x0000, /* 0 db */
                WM_ATTEN_R,     0x0000, /* 0 db */
                WM_DAC_CTRL,    0x0008, /* 24bit I2S */
@@ -75,7 +75,7 @@ static int __devinit snd_vt1724_amp_add_controls(struct snd_ice1712 *ice)
 
 
 /* entry point */
-struct snd_ice1712_card_info snd_vt1724_amp_cards[] __devinitdata = {
+const struct snd_ice1712_card_info snd_vt1724_amp_cards[] __devinitdata = {
        {
                .subvendor = VT1724_SUBDEVICE_AV710,
                .name = "Chaintech AV-710",
index a0fc89b48122d4a65779acec06542eb90d90a293..7b667bad0c6ba17c98a2405cae81983d1b1b45f9 100644 (file)
@@ -42,7 +42,7 @@
 #define WM_DAC_CTRL    0x02
 #define WM_INT_CTRL    0x03
 
-extern struct snd_ice1712_card_info  snd_vt1724_amp_cards[];
+extern const struct snd_ice1712_card_info  snd_vt1724_amp_cards[];
 
 
 #endif /* __SOUND_AMP_H */
index 9e76cebd2d228c1680465e40757ad2cca4063153..6941d85dfec9d669c6da90db6fd6de45821f0d55 100644 (file)
@@ -294,7 +294,7 @@ static unsigned short aureon_ac97_read(struct snd_ice1712 *ice, unsigned short r
 static int aureon_ac97_init (struct snd_ice1712 *ice)
 {
        int i;
-       static unsigned short ac97_defaults[] = {
+       static const unsigned short ac97_defaults[] = {
                0x00, 0x9640,
                0x02, 0x8000,
                0x04, 0x8000,
@@ -474,7 +474,8 @@ static void aureon_spi_write(struct snd_ice1712 *ice, unsigned int cs, unsigned
 
        tmp = snd_ice1712_gpio_read(ice);
 
-       if (ice->eeprom.subvendor == VT1724_SUBDEVICE_PRODIGY71LT) {
+       if (ice->eeprom.subvendor == VT1724_SUBDEVICE_PRODIGY71LT ||
+           ice->eeprom.subvendor == VT1724_SUBDEVICE_PRODIGY71XT) {
                snd_ice1712_gpio_set_mask(ice, ~(PRODIGY_SPI_MOSI|PRODIGY_SPI_CLK|PRODIGY_WM_CS));
                mosi = PRODIGY_SPI_MOSI;
                clk = PRODIGY_SPI_CLK;
@@ -601,7 +602,9 @@ static unsigned short wm_get(struct snd_ice1712 *ice, int reg)
 static void wm_put_nocache(struct snd_ice1712 *ice, int reg, unsigned short val)
 {
        aureon_spi_write(ice,
-                       (ice->eeprom.subvendor == VT1724_SUBDEVICE_PRODIGY71LT ? PRODIGY_WM_CS : AUREON_WM_CS),
+                        ((ice->eeprom.subvendor == VT1724_SUBDEVICE_PRODIGY71LT ||
+                          ice->eeprom.subvendor == VT1724_SUBDEVICE_PRODIGY71XT) ?
+                        PRODIGY_WM_CS : AUREON_WM_CS),
                        (reg << 9) | (val & 0x1ff), 16);
 }
 
@@ -661,17 +664,17 @@ static int aureon_ac97_mmute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_e
        return change;
 }
 
-static DECLARE_TLV_DB_SCALE(db_scale_wm_dac, -12700, 100, 1);
-static DECLARE_TLV_DB_SCALE(db_scale_wm_pcm, -6400, 50, 1);
-static DECLARE_TLV_DB_SCALE(db_scale_wm_adc, -1200, 100, 0);
-static DECLARE_TLV_DB_SCALE(db_scale_ac97_master, -4650, 150, 0);
-static DECLARE_TLV_DB_SCALE(db_scale_ac97_gain, -3450, 150, 0);
+static const DECLARE_TLV_DB_SCALE(db_scale_wm_dac, -12700, 100, 1);
+static const DECLARE_TLV_DB_SCALE(db_scale_wm_pcm, -6400, 50, 1);
+static const DECLARE_TLV_DB_SCALE(db_scale_wm_adc, -1200, 100, 0);
+static const DECLARE_TLV_DB_SCALE(db_scale_ac97_master, -4650, 150, 0);
+static const DECLARE_TLV_DB_SCALE(db_scale_ac97_gain, -3450, 150, 0);
 
 /*
  * Logarithmic volume values for WM8770
  * Computed as 20 * Log10(255 / x)
  */
-static unsigned char wm_vol[256] = {
+static const unsigned char wm_vol[256] = {
        127, 48, 42, 39, 36, 34, 33, 31, 30, 29, 28, 27, 27, 26, 25, 25, 24, 24, 23,
        23, 22, 22, 21, 21, 21, 20, 20, 20, 19, 19, 19, 18, 18, 18, 18, 17, 17, 17,
        17, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15, 14, 14, 14, 14, 14, 13, 13, 13,
@@ -1064,14 +1067,14 @@ static int wm_adc_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_val
  */
 static int wm_adc_mux_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
 {
-       static char *texts[] = {
+       static const char * const texts[] = {
                "CD",           //AIN1
                "Aux",          //AIN2
                "Line",         //AIN3
                "Mic",          //AIN4
                "AC97"          //AIN5
        };
-       static char *universe_texts[] = {
+       static const char * const universe_texts[] = {
                "Aux1",         //AIN1
                "CD",           //AIN2
                "Phono",        //AIN3
@@ -1137,11 +1140,11 @@ static int wm_adc_mux_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_val
 static int aureon_cs8415_mux_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
 {
        struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
-       static char *aureon_texts[] = {
+       static const char * const aureon_texts[] = {
                "CD",           //RXP0
                "Optical"       //RXP1
        };
-       static char *prodigy_texts[] = {
+       static const char * const prodigy_texts[] = {
                "CD",
                "Coax"
        };
@@ -1288,12 +1291,14 @@ static int aureon_set_headphone_amp(struct snd_ice1712 *ice, int enable)
 
        tmp2 = tmp = snd_ice1712_gpio_read(ice);
        if (enable)
-               if (ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71LT)
+               if (ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71LT &&
+                   ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71XT)
                        tmp |= AUREON_HP_SEL;
                else
                        tmp |= PRODIGY_HP_SEL;
        else
-               if (ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71LT)
+               if (ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71LT &&
+                   ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71XT)
                        tmp &= ~ AUREON_HP_SEL;
                else
                        tmp &= ~ PRODIGY_HP_SEL;
@@ -1363,7 +1368,7 @@ static int aureon_deemp_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_v
  */
 static int aureon_oversampling_info(struct snd_kcontrol *k, struct snd_ctl_elem_info *uinfo)
 {
-       static char *texts[2] = { "128x", "64x" };
+       static const char * const texts[2] = { "128x", "64x"    };
 
        uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
        uinfo->count = 1;
@@ -1406,7 +1411,7 @@ static int aureon_oversampling_put(struct snd_kcontrol *kcontrol, struct snd_ctl
  * mixers
  */
 
-static struct snd_kcontrol_new aureon_dac_controls[] __devinitdata = {
+static const struct snd_kcontrol_new aureon_dac_controls[] __devinitdata = {
        {
                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
                .name = "Master Playback Switch",
@@ -1521,7 +1526,7 @@ static struct snd_kcontrol_new aureon_dac_controls[] __devinitdata = {
        }
 };
 
-static struct snd_kcontrol_new wm_controls[] __devinitdata = {
+static const struct snd_kcontrol_new wm_controls[] __devinitdata = {
        {
                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
                .name = "PCM Playback Switch",
@@ -1587,7 +1592,7 @@ static struct snd_kcontrol_new wm_controls[] __devinitdata = {
        }
 };
 
-static struct snd_kcontrol_new ac97_controls[] __devinitdata = {
+static const struct snd_kcontrol_new ac97_controls[] __devinitdata = {
        {
                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
                .name = "AC97 Playback Switch",
@@ -1692,7 +1697,7 @@ static struct snd_kcontrol_new ac97_controls[] __devinitdata = {
        }
 };
 
-static struct snd_kcontrol_new universe_ac97_controls[] __devinitdata = {
+static const struct snd_kcontrol_new universe_ac97_controls[] __devinitdata = {
        {
                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
                .name = "AC97 Playback Switch",
@@ -1824,8 +1829,7 @@ static struct snd_kcontrol_new universe_ac97_controls[] __devinitdata = {
 
 };
 
-       
-static struct snd_kcontrol_new cs8415_controls[] __devinitdata = {
+static const struct snd_kcontrol_new cs8415_controls[] __devinitdata = {
        {
                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
                .name = SNDRV_CTL_NAME_IEC958("",CAPTURE,SWITCH),
@@ -1870,7 +1874,6 @@ static struct snd_kcontrol_new cs8415_controls[] __devinitdata = {
        }
 };
 
 static int __devinit aureon_add_controls(struct snd_ice1712 *ice)
 {
        unsigned int i, counts;
@@ -1898,7 +1901,8 @@ static int __devinit aureon_add_controls(struct snd_ice1712 *ice)
                                return err;
                }
        }
-       else if (ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71LT) {
+       else if (ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71LT &&
+                ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71XT) {
                for (i = 0; i < ARRAY_SIZE(ac97_controls); i++) {
                        err = snd_ctl_add(ice->card, snd_ctl_new1(&ac97_controls[i], ice));
                        if (err < 0)
@@ -1906,7 +1910,8 @@ static int __devinit aureon_add_controls(struct snd_ice1712 *ice)
                }
        }
 
-       if (ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71LT) {
+       if (ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71LT &&
+           ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71XT) {
                unsigned char id;
                snd_ice1712_save_gpio_status(ice);
                id = aureon_cs8415_get(ice, CS8415_ID);
@@ -1936,7 +1941,7 @@ static int __devinit aureon_add_controls(struct snd_ice1712 *ice)
  */
 static int __devinit aureon_init(struct snd_ice1712 *ice)
 {
-       static unsigned short wm_inits_aureon[] = {
+       static const unsigned short wm_inits_aureon[] = {
                /* These come first to reduce init pop noise */
                0x1b, 0x044,            /* ADC Mux (AC'97 source) */
                0x1c, 0x00B,            /* Out Mux1 (VOUT1 = DAC+AUX, VOUT2 = DAC) */
@@ -1972,7 +1977,7 @@ static int __devinit aureon_init(struct snd_ice1712 *ice)
                0x1a, 0x000,            /* -12dB ADC/R */
                (unsigned short)-1
        };
-       static unsigned short wm_inits_prodigy[] = {
+       static const unsigned short wm_inits_prodigy[] = {
 
                /* These come first to reduce init pop noise */
                0x1b, 0x000,            /* ADC Mux */
@@ -2014,7 +2019,7 @@ static int __devinit aureon_init(struct snd_ice1712 *ice)
                (unsigned short)-1
 
        };
-       static unsigned short cs_inits[] = {
+       static const unsigned short cs_inits[] = {
                0x0441, /* RUN */
                0x0180, /* no mute, OMCK output on RMCK pin */
                0x0201, /* S/PDIF source on RXP1 */
@@ -2022,7 +2027,7 @@ static int __devinit aureon_init(struct snd_ice1712 *ice)
                (unsigned short)-1
        };
        unsigned int tmp;
-       unsigned short *p;
+       const unsigned short *p;
        int err, i;
 
        if (ice->eeprom.subvendor == VT1724_SUBDEVICE_AUREON51_SKY) {
@@ -2062,7 +2067,8 @@ static int __devinit aureon_init(struct snd_ice1712 *ice)
 
        /* initialize WM8770 codec */
        if (ice->eeprom.subvendor == VT1724_SUBDEVICE_PRODIGY71 ||
-               ice->eeprom.subvendor == VT1724_SUBDEVICE_PRODIGY71LT)
+               ice->eeprom.subvendor == VT1724_SUBDEVICE_PRODIGY71LT ||
+               ice->eeprom.subvendor == VT1724_SUBDEVICE_PRODIGY71XT)
                p = wm_inits_prodigy;
        else
                p = wm_inits_aureon;
@@ -2070,7 +2076,8 @@ static int __devinit aureon_init(struct snd_ice1712 *ice)
                wm_put(ice, p[0], p[1]);
 
        /* initialize CS8415A codec */
-       if (ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71LT) {
+       if (ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71LT &&
+           ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71XT) {
                for (p = cs_inits; *p != (unsigned short)-1; p++)
                        aureon_spi_write(ice, AUREON_CS8415_CS, *p | 0x200000, 24);
                ice->spec.aureon.cs8415_mux = 1;
@@ -2100,73 +2107,58 @@ static int __devinit aureon_init(struct snd_ice1712 *ice)
  * hence the driver needs to sets up it properly.
  */
 
-static unsigned char aureon51_eeprom[] __devinitdata = {
-       0x0a,   /* SYSCONF: clock 512, spdif-in/ADC, 3DACs */
-       0x80,   /* ACLINK: I2S */
-       0xfc,   /* I2S: vol, 96k, 24bit, 192k */
-       0xc3,   /* SPDIF: out-en, out-int, spdif-in */
-       0xff,   /* GPIO_DIR */
-       0xff,   /* GPIO_DIR1 */
-       0x5f,   /* GPIO_DIR2 */
-       0x00,   /* GPIO_MASK */
-       0x00,   /* GPIO_MASK1 */
-       0x00,   /* GPIO_MASK2 */
-       0x00,   /* GPIO_STATE */
-       0x00,   /* GPIO_STATE1 */
-       0x00,   /* GPIO_STATE2 */
+static const unsigned char aureon51_eeprom[] __devinitdata = {
+       [ICE_EEP2_SYSCONF]     = 0x0a,  /* clock 512, spdif-in/ADC, 3DACs */
+       [ICE_EEP2_ACLINK]      = 0x80,  /* I2S */
+       [ICE_EEP2_I2S]         = 0xfc,  /* vol, 96k, 24bit, 192k */
+       [ICE_EEP2_SPDIF]       = 0xc3,  /* out-en, out-int, spdif-in */
+       [ICE_EEP2_GPIO_DIR]    = 0xff,
+       [ICE_EEP2_GPIO_DIR1]   = 0xff,
+       [ICE_EEP2_GPIO_DIR2]   = 0x5f,
+       [ICE_EEP2_GPIO_MASK]   = 0x00,
+       [ICE_EEP2_GPIO_MASK1]  = 0x00,
+       [ICE_EEP2_GPIO_MASK2]  = 0x00,
+       [ICE_EEP2_GPIO_STATE]  = 0x00,
+       [ICE_EEP2_GPIO_STATE1] = 0x00,
+       [ICE_EEP2_GPIO_STATE2] = 0x00,
 };
 
-static unsigned char aureon71_eeprom[] __devinitdata = {
-       0x0b,   /* SYSCONF: clock 512, spdif-in/ADC, 4DACs */
-       0x80,   /* ACLINK: I2S */
-       0xfc,   /* I2S: vol, 96k, 24bit, 192k */
-       0xc3,   /* SPDIF: out-en, out-int, spdif-in */
-       0xff,   /* GPIO_DIR */
-       0xff,   /* GPIO_DIR1 */
-       0x5f,   /* GPIO_DIR2 */
-       0x00,   /* GPIO_MASK */
-       0x00,   /* GPIO_MASK1 */
-       0x00,   /* GPIO_MASK2 */
-       0x00,   /* GPIO_STATE */
-       0x00,   /* GPIO_STATE1 */
-       0x00,   /* GPIO_STATE2 */
+static const unsigned char aureon71_eeprom[] __devinitdata = {
+       [ICE_EEP2_SYSCONF]     = 0x0b,  /* clock 512, spdif-in/ADC, 4DACs */
+       [ICE_EEP2_ACLINK]      = 0x80,  /* I2S */
+       [ICE_EEP2_I2S]         = 0xfc,  /* vol, 96k, 24bit, 192k */
+       [ICE_EEP2_SPDIF]       = 0xc3,  /* out-en, out-int, spdif-in */
+       [ICE_EEP2_GPIO_DIR]    = 0xff,
+       [ICE_EEP2_GPIO_DIR1]   = 0xff,
+       [ICE_EEP2_GPIO_DIR2]   = 0x5f,
+       [ICE_EEP2_GPIO_MASK]   = 0x00,
+       [ICE_EEP2_GPIO_MASK1]  = 0x00,
+       [ICE_EEP2_GPIO_MASK2]  = 0x00,
+       [ICE_EEP2_GPIO_STATE]  = 0x00,
+       [ICE_EEP2_GPIO_STATE1] = 0x00,
+       [ICE_EEP2_GPIO_STATE2] = 0x00,
 };
-
-static unsigned char prodigy71_eeprom[] __devinitdata = {
-       0x0b,   /* SYSCONF: clock 512, spdif-in/ADC, 4DACs */
-       0x80,   /* ACLINK: I2S */
-       0xfc,   /* I2S: vol, 96k, 24bit, 192k */
-       0xc3,   /* SPDIF: out-en, out-int, spdif-in */
-       0xff,   /* GPIO_DIR */
-       0xff,   /* GPIO_DIR1 */
-       0x5f,   /* GPIO_DIR2 */
-       0x00,   /* GPIO_MASK */
-       0x00,   /* GPIO_MASK1 */
-       0x00,   /* GPIO_MASK2 */
-       0x00,   /* GPIO_STATE */
-       0x00,   /* GPIO_STATE1 */
-       0x00,   /* GPIO_STATE2 */
+#define prodigy71_eeprom aureon71_eeprom
+
+static const unsigned char prodigy71lt_eeprom[] __devinitdata = {
+       [ICE_EEP2_SYSCONF]     = 0x4b,  /* clock 384, spdif-in/ADC, 4DACs */
+       [ICE_EEP2_ACLINK]      = 0x80,  /* I2S */
+       [ICE_EEP2_I2S]         = 0xfc,  /* vol, 96k, 24bit, 192k */
+       [ICE_EEP2_SPDIF]       = 0xc3,  /* out-en, out-int, spdif-in */
+       [ICE_EEP2_GPIO_DIR]    = 0xff,
+       [ICE_EEP2_GPIO_DIR1]   = 0xff,
+       [ICE_EEP2_GPIO_DIR2]   = 0x5f,
+       [ICE_EEP2_GPIO_MASK]   = 0x00,
+       [ICE_EEP2_GPIO_MASK1]  = 0x00,
+       [ICE_EEP2_GPIO_MASK2]  = 0x00,
+       [ICE_EEP2_GPIO_STATE]  = 0x00,
+       [ICE_EEP2_GPIO_STATE1] = 0x00,
+       [ICE_EEP2_GPIO_STATE2] = 0x00,
 };
-
-static unsigned char prodigy71lt_eeprom[] __devinitdata = {
-       0x4b,   /* SYSCINF: clock 512, spdif-in/ADC, 4DACs */
-       0x80,   /* ACLINK: I2S */
-       0xfc,   /* I2S: vol, 96k, 24bit, 192k */
-       0xc3,   /* SPDIF: out-en, out-int, spdif-in */
-       0xff,   /* GPIO_DIR */
-       0xff,   /* GPIO_DIR1 */
-       0x5f,   /* GPIO_DIR2 */
-       0x00,   /* GPIO_MASK */
-       0x00,   /* GPIO_MASK1 */
-       0x00,   /* GPIO_MASK2 */
-       0x00,   /* GPIO_STATE */
-       0x00,   /* GPIO_STATE1 */
-       0x00,   /* GPIO_STATE2 */
-};
-       
+#define prodigy71xt_eeprom prodigy71lt_eeprom
 
 /* entry point */
-struct snd_ice1712_card_info snd_vt1724_aureon_cards[] __devinitdata = {
+const struct snd_ice1712_card_info snd_vt1724_aureon_cards[] __devinitdata = {
        {
                .subvendor = VT1724_SUBDEVICE_AUREON51_SKY,
                .name = "Terratec Aureon 5.1-Sky",
@@ -2217,5 +2209,15 @@ struct snd_ice1712_card_info snd_vt1724_aureon_cards[] __devinitdata = {
                .eeprom_data = prodigy71lt_eeprom,
                .driver = "Prodigy71LT",
        },
+       {
+               .subvendor = VT1724_SUBDEVICE_PRODIGY71XT,
+               .name = "Audiotrak Prodigy 7.1 XT",
+               .model = "prodigy71xt",
+               .chip_init = aureon_init,
+               .build_controls = aureon_add_controls,
+               .eeprom_size = sizeof(prodigy71xt_eeprom),
+               .eeprom_data = prodigy71xt_eeprom,
+               .driver = "Prodigy71LT",
+       },
        { } /* terminator */
 };
index 3b7bea656c57eec0a056dd02ec407b3f603c9a20..79e58e88ed473228bd2106713247eee06c1795e8 100644 (file)
                                       "{Terratec,Aureon 7.1 Space},"\
                                       "{Terratec,Aureon 7.1 Universe}," \
                                        "{AudioTrak,Prodigy 7.1}," \
-                                       "{AudioTrak,Prodigy 7.1 LT},"
+                                       "{AudioTrak,Prodigy 7.1 LT},"\
+                                       "{AudioTrak,Prodigy 7.1 XT},"
 
 #define VT1724_SUBDEVICE_AUREON51_SKY  0x3b154711      /* Aureon 5.1 Sky */
 #define VT1724_SUBDEVICE_AUREON71_SPACE        0x3b154511      /* Aureon 7.1 Space */
 #define VT1724_SUBDEVICE_AUREON71_UNIVERSE     0x3b155311      /* Aureon 7.1 Universe */
 #define VT1724_SUBDEVICE_PRODIGY71     0x33495345      /* PRODIGY 7.1 */
 #define VT1724_SUBDEVICE_PRODIGY71LT   0x32315441      /* PRODIGY 7.1 LT */
+#define VT1724_SUBDEVICE_PRODIGY71XT   0x36315441      /* PRODIGY 7.1 XT*/
 
-extern struct snd_ice1712_card_info  snd_vt1724_aureon_cards[];
+extern const struct snd_ice1712_card_info  snd_vt1724_aureon_cards[];
 
 /* GPIO bits */
 #define AUREON_CS8415_CS       (1 << 22)
index af659800c9b040579d03a04bc44b6400af56f588..3eeb36c6e98551be3a735e38747a1239b27222b5 100644 (file)
@@ -416,7 +416,7 @@ static int snd_ice1712_delta1010lt_wordclock_status_get(struct snd_kcontrol *kco
        return 0;
 }
 
-static struct snd_kcontrol_new snd_ice1712_delta1010lt_wordclock_status __devinitdata =
+static const struct snd_kcontrol_new snd_ice1712_delta1010lt_wordclock_status __devinitdata =
 {
        .access =       (SNDRV_CTL_ELEM_ACCESS_READ),
        .iface =        SNDRV_CTL_ELEM_IFACE_MIXER,
@@ -429,7 +429,7 @@ static struct snd_kcontrol_new snd_ice1712_delta1010lt_wordclock_status __devini
  * initialize the chips on M-Audio cards
  */
 
-static struct snd_akm4xxx akm_audiophile __devinitdata = {
+static const struct snd_akm4xxx akm_audiophile __devinitdata = {
        .type = SND_AK4528,
        .num_adcs = 2,
        .num_dacs = 2,
@@ -438,7 +438,7 @@ static struct snd_akm4xxx akm_audiophile __devinitdata = {
        }
 };
 
-static struct snd_ak4xxx_private akm_audiophile_priv __devinitdata = {
+static const struct snd_ak4xxx_private akm_audiophile_priv __devinitdata = {
        .caddr = 2,
        .cif = 0,
        .data_mask = ICE1712_DELTA_AP_DOUT,
@@ -450,7 +450,7 @@ static struct snd_ak4xxx_private akm_audiophile_priv __devinitdata = {
        .mask_flags = 0,
 };
 
-static struct snd_akm4xxx akm_delta410 __devinitdata = {
+static const struct snd_akm4xxx akm_delta410 __devinitdata = {
        .type = SND_AK4529,
        .num_adcs = 2,
        .num_dacs = 8,
@@ -459,7 +459,7 @@ static struct snd_akm4xxx akm_delta410 __devinitdata = {
        }
 };
 
-static struct snd_ak4xxx_private akm_delta410_priv __devinitdata = {
+static const struct snd_ak4xxx_private akm_delta410_priv __devinitdata = {
        .caddr = 0,
        .cif = 0,
        .data_mask = ICE1712_DELTA_AP_DOUT,
@@ -471,7 +471,7 @@ static struct snd_ak4xxx_private akm_delta410_priv __devinitdata = {
        .mask_flags = 0,
 };
 
-static struct snd_akm4xxx akm_delta1010lt __devinitdata = {
+static const struct snd_akm4xxx akm_delta1010lt __devinitdata = {
        .type = SND_AK4524,
        .num_adcs = 8,
        .num_dacs = 8,
@@ -481,7 +481,7 @@ static struct snd_akm4xxx akm_delta1010lt __devinitdata = {
        }
 };
 
-static struct snd_ak4xxx_private akm_delta1010lt_priv __devinitdata = {
+static const struct snd_ak4xxx_private akm_delta1010lt_priv __devinitdata = {
        .caddr = 2,
        .cif = 0, /* the default level of the CIF pin from AK4524 */
        .data_mask = ICE1712_DELTA_1010LT_DOUT,
@@ -493,7 +493,7 @@ static struct snd_ak4xxx_private akm_delta1010lt_priv __devinitdata = {
        .mask_flags = 0,
 };
 
-static struct snd_akm4xxx akm_delta44 __devinitdata = {
+static const struct snd_akm4xxx akm_delta44 __devinitdata = {
        .type = SND_AK4524,
        .num_adcs = 4,
        .num_dacs = 4,
@@ -503,7 +503,7 @@ static struct snd_akm4xxx akm_delta44 __devinitdata = {
        }
 };
 
-static struct snd_ak4xxx_private akm_delta44_priv __devinitdata = {
+static const struct snd_ak4xxx_private akm_delta44_priv __devinitdata = {
        .caddr = 2,
        .cif = 0, /* the default level of the CIF pin from AK4524 */
        .data_mask = ICE1712_DELTA_CODEC_SERIAL_DATA,
@@ -515,7 +515,7 @@ static struct snd_ak4xxx_private akm_delta44_priv __devinitdata = {
        .mask_flags = 0,
 };
 
-static struct snd_akm4xxx akm_vx442 __devinitdata = {
+static const struct snd_akm4xxx akm_vx442 __devinitdata = {
        .type = SND_AK4524,
        .num_adcs = 4,
        .num_dacs = 4,
@@ -525,7 +525,7 @@ static struct snd_akm4xxx akm_vx442 __devinitdata = {
        }
 };
 
-static struct snd_ak4xxx_private akm_vx442_priv __devinitdata = {
+static const struct snd_ak4xxx_private akm_vx442_priv __devinitdata = {
        .caddr = 2,
        .cif = 0,
        .data_mask = ICE1712_VX442_DOUT,
@@ -650,15 +650,15 @@ static int __devinit snd_ice1712_delta_init(struct snd_ice1712 *ice)
  * additional controls for M-Audio cards
  */
 
-static struct snd_kcontrol_new snd_ice1712_delta1010_wordclock_select __devinitdata =
+static const struct snd_kcontrol_new snd_ice1712_delta1010_wordclock_select __devinitdata =
 ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_MIXER, "Word Clock Sync", 0, ICE1712_DELTA_WORD_CLOCK_SELECT, 1, 0);
-static struct snd_kcontrol_new snd_ice1712_delta1010lt_wordclock_select __devinitdata =
+static const struct snd_kcontrol_new snd_ice1712_delta1010lt_wordclock_select __devinitdata =
 ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_MIXER, "Word Clock Sync", 0, ICE1712_DELTA_1010LT_WORDCLOCK, 0, 0);
-static struct snd_kcontrol_new snd_ice1712_delta1010_wordclock_status __devinitdata =
+static const struct snd_kcontrol_new snd_ice1712_delta1010_wordclock_status __devinitdata =
 ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_MIXER, "Word Clock Status", 0, ICE1712_DELTA_WORD_CLOCK_STATUS, 1, SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE);
-static struct snd_kcontrol_new snd_ice1712_deltadio2496_spdif_in_select __devinitdata =
+static const struct snd_kcontrol_new snd_ice1712_deltadio2496_spdif_in_select __devinitdata =
 ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_MIXER, "IEC958 Input Optical", 0, ICE1712_DELTA_SPDIF_INPUT_SELECT, 0, 0);
-static struct snd_kcontrol_new snd_ice1712_delta_spdif_in_status __devinitdata =
+static const struct snd_kcontrol_new snd_ice1712_delta_spdif_in_status __devinitdata =
 ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_MIXER, "Delta IEC958 Input Status", 0, ICE1712_DELTA_SPDIF_IN_STAT, 1, SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE);
 
 
@@ -735,7 +735,7 @@ static int __devinit snd_ice1712_delta_add_controls(struct snd_ice1712 *ice)
 
 
 /* entry point */
-struct snd_ice1712_card_info snd_ice1712_delta_cards[] __devinitdata = {
+const struct snd_ice1712_card_info snd_ice1712_delta_cards[] __devinitdata = {
        {
                .subvendor = ICE1712_SUBDEVICE_DELTA1010,
                .name = "M Audio Delta 1010",
index 746ebde94522e406b8d1a548b8873ac2a97e7ee7..e65d669af6391fb15ff4eff5e31a25d8e660687c 100644 (file)
@@ -46,7 +46,7 @@
 #define ICE1712_SUBDEVICE_MEDIASTATION 0x694c0100
 
 /* entry point */
-extern struct snd_ice1712_card_info snd_ice1712_delta_cards[];
+extern const struct snd_ice1712_card_info snd_ice1712_delta_cards[];
 
 
 /*
index b135389fec6c7cbc83e69a73f9f05f5cdf1272ef..9b7ff302c0725dd9aea8226500d36b11f0773d8a 100644 (file)
@@ -332,7 +332,7 @@ static void ews88_setup_spdif(struct snd_ice1712 *ice, int rate)
 
 /*
  */
-static struct snd_akm4xxx akm_ews88mt __devinitdata = {
+static const struct snd_akm4xxx akm_ews88mt __devinitdata = {
        .num_adcs = 8,
        .num_dacs = 8,
        .type = SND_AK4524,
@@ -342,7 +342,7 @@ static struct snd_akm4xxx akm_ews88mt __devinitdata = {
        }
 };
 
-static struct snd_ak4xxx_private akm_ews88mt_priv __devinitdata = {
+static const struct snd_ak4xxx_private akm_ews88mt_priv __devinitdata = {
        .caddr = 2,
        .cif = 1, /* CIF high */
        .data_mask = ICE1712_EWS88_SERIAL_DATA,
@@ -354,7 +354,7 @@ static struct snd_ak4xxx_private akm_ews88mt_priv __devinitdata = {
        .mask_flags = 0,
 };
 
-static struct snd_akm4xxx akm_ewx2496 __devinitdata = {
+static const struct snd_akm4xxx akm_ewx2496 __devinitdata = {
        .num_adcs = 2,
        .num_dacs = 2,
        .type = SND_AK4524,
@@ -363,7 +363,7 @@ static struct snd_akm4xxx akm_ewx2496 __devinitdata = {
        }
 };
 
-static struct snd_ak4xxx_private akm_ewx2496_priv __devinitdata = {
+static const struct snd_ak4xxx_private akm_ewx2496_priv __devinitdata = {
        .caddr = 2,
        .cif = 1, /* CIF high */
        .data_mask = ICE1712_EWS88_SERIAL_DATA,
@@ -375,7 +375,7 @@ static struct snd_ak4xxx_private akm_ewx2496_priv __devinitdata = {
        .mask_flags = 0,
 };
 
-static struct snd_akm4xxx akm_6fire __devinitdata = {
+static const struct snd_akm4xxx akm_6fire __devinitdata = {
        .num_adcs = 6,
        .num_dacs = 6,
        .type = SND_AK4524,
@@ -384,7 +384,7 @@ static struct snd_akm4xxx akm_6fire __devinitdata = {
        }
 };
 
-static struct snd_ak4xxx_private akm_6fire_priv __devinitdata = {
+static const struct snd_ak4xxx_private akm_6fire_priv __devinitdata = {
        .caddr = 2,
        .cif = 1, /* CIF high */
        .data_mask = ICE1712_6FIRE_SERIAL_DATA,
@@ -578,7 +578,7 @@ static int snd_ice1712_ewx_io_sense_put(struct snd_kcontrol *kcontrol, struct sn
        return val != nval;
 }
 
-static struct snd_kcontrol_new snd_ice1712_ewx2496_controls[] __devinitdata = {
+static const struct snd_kcontrol_new snd_ice1712_ewx2496_controls[] __devinitdata = {
        {
                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
                .name = "Input Sensitivity Switch",
@@ -678,7 +678,7 @@ static int snd_ice1712_ews88mt_input_sense_put(struct snd_kcontrol *kcontrol, st
        return ndata != data;
 }
 
-static struct snd_kcontrol_new snd_ice1712_ews88mt_input_sense __devinitdata = {
+static const struct snd_kcontrol_new snd_ice1712_ews88mt_input_sense __devinitdata = {
        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
        .name = "Input Sensitivity Switch",
        .info = snd_ice1712_ewx_io_sense_info,
@@ -687,7 +687,7 @@ static struct snd_kcontrol_new snd_ice1712_ews88mt_input_sense __devinitdata = {
        .count = 8,
 };
 
-static struct snd_kcontrol_new snd_ice1712_ews88mt_output_sense __devinitdata = {
+static const struct snd_kcontrol_new snd_ice1712_ews88mt_output_sense __devinitdata = {
        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
        .name = "Output Sensitivity Switch",
        .info = snd_ice1712_ewx_io_sense_info,
@@ -769,7 +769,7 @@ static int snd_ice1712_ews88d_control_put(struct snd_kcontrol *kcontrol, struct
   .private_value = xshift | (xinvert << 8),\
 }
 
-static struct snd_kcontrol_new snd_ice1712_ews88d_controls[] __devinitdata = {
+static const struct snd_kcontrol_new snd_ice1712_ews88d_controls[] __devinitdata = {
        EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "IEC958 Input Optical", 0, 1, 0), /* inverted */
        EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "ADAT Output Optical", 1, 0, 0),
        EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "ADAT External Master Clock", 2, 0, 0),
@@ -909,7 +909,7 @@ static int snd_ice1712_6fire_select_input_put(struct snd_kcontrol *kcontrol, str
   .private_value = xshift | (xinvert << 8),\
 }
 
-static struct snd_kcontrol_new snd_ice1712_6fire_controls[] __devinitdata = {
+static const struct snd_kcontrol_new snd_ice1712_6fire_controls[] __devinitdata = {
        {
                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
                .name = "Analog Input Select",
@@ -989,7 +989,7 @@ static int __devinit snd_ice1712_ews_add_controls(struct snd_ice1712 *ice)
 
 
 /* entry point */
-struct snd_ice1712_card_info snd_ice1712_ews_cards[] __devinitdata = {
+const struct snd_ice1712_card_info snd_ice1712_ews_cards[] __devinitdata = {
        {
                .subvendor = ICE1712_SUBDEVICE_EWX2496,
                .name = "TerraTec EWX24/96",
index a12a0b053558b3db17d7ace7a97078cebdaa1d9b..df449b4741f6303ce3f6d84a488afeee4827ff02 100644 (file)
@@ -40,7 +40,7 @@
 #define ICE1712_SUBDEVICE_PHASE88      0x3b155111
 
 /* entry point */
-extern struct snd_ice1712_card_info snd_ice1712_ews_cards[];
+extern const struct snd_ice1712_card_info snd_ice1712_ews_cards[];
 
 
 /* TerraTec EWX 24/96 configuration definitions */
index 3f27d04e7d3c07edb48052b4bf9d3d5789a3b21f..df97313aaf83cdd368e706707de198e3fad82aa2 100644 (file)
@@ -239,7 +239,7 @@ static void stdsp24_ak4524_lock(struct snd_akm4xxx *ak, int chip)
 static int __devinit snd_ice1712_value_init(struct snd_ice1712 *ice)
 {
        /* Hoontech STDSP24 with modified hardware */
-       static struct snd_akm4xxx akm_stdsp24_mv __devinitdata = {
+       static const struct snd_akm4xxx akm_stdsp24_mv __devinitdata = {
                .num_adcs = 2,
                .num_dacs = 2,
                .type = SND_AK4524,
@@ -248,7 +248,7 @@ static int __devinit snd_ice1712_value_init(struct snd_ice1712 *ice)
                }
        };
 
-       static struct snd_ak4xxx_private akm_stdsp24_mv_priv __devinitdata = {
+       static const struct snd_ak4xxx_private akm_stdsp24_mv_priv __devinitdata = {
                .caddr = 2,
                .cif = 1, /* CIF high */
                .data_mask = ICE1712_STDSP24_SERIAL_DATA,
@@ -298,7 +298,7 @@ static int __devinit snd_ice1712_ez8_init(struct snd_ice1712 *ice)
 
 
 /* entry point */
-struct snd_ice1712_card_info snd_ice1712_hoontech_cards[] __devinitdata = {
+const struct snd_ice1712_card_info snd_ice1712_hoontech_cards[] __devinitdata = {
        {
                .subvendor = ICE1712_SUBDEVICE_STDSP24,
                .name = "Hoontech SoundTrack Audio DSP24",
@@ -325,4 +325,3 @@ struct snd_ice1712_card_info snd_ice1712_hoontech_cards[] __devinitdata = {
        },
        { } /* terminator */
 };
-
index 1ee538b20fbfafe5767b4adb64b85225c2ba6cfa..b62d6e4f6c7107bba95ddb373837b2075f8be959 100644 (file)
@@ -35,7 +35,7 @@
 #define ICE1712_SUBDEVICE_STDSP24_MEDIA7_1     0x16141217      /* Hoontech ST Audio DSP24 Media 7.1 */
 #define ICE1712_SUBDEVICE_EVENT_EZ8            0x00010001      /* A dummy id for EZ8 */
 
-extern struct snd_ice1712_card_info snd_ice1712_hoontech_cards[];
+extern const struct snd_ice1712_card_info snd_ice1712_hoontech_cards[];
 
 
 /* Hoontech SoundTrack Audio DSP 24 GPIO definitions */
index 8ba31cfb90450146d47dd663f060714245a89f14..830a1bbd7110a058ba2765a913eda0c34849f27d 100644 (file)
@@ -107,7 +107,7 @@ module_param_array(dxr_enable, int, NULL, 0444);
 MODULE_PARM_DESC(dxr_enable, "Enable DXR support for Terratec DMX6FIRE.");
 
 
-static struct pci_device_id snd_ice1712_ids[] = {
+static const struct pci_device_id snd_ice1712_ids[] = {
        { PCI_VENDOR_ID_ICE, PCI_DEVICE_ID_ICE_1712, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },   /* ICE1712 */
        { 0, }
 };
@@ -287,7 +287,7 @@ static int snd_ice1712_digmix_route_ac97_put(struct snd_kcontrol *kcontrol, stru
        return val != nval;
 }
 
-static struct snd_kcontrol_new snd_ice1712_mixer_digmix_route_ac97 __devinitdata = {
+static const struct snd_kcontrol_new snd_ice1712_mixer_digmix_route_ac97 __devinitdata = {
        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
        .name = "Digital Mixer To AC97",
        .info = snd_ice1712_digmix_route_ac97_info,
@@ -719,7 +719,7 @@ static snd_pcm_uframes_t snd_ice1712_capture_pointer(struct snd_pcm_substream *s
        return bytes_to_frames(substream->runtime, ptr);
 }
 
-static struct snd_pcm_hardware snd_ice1712_playback =
+static const struct snd_pcm_hardware snd_ice1712_playback =
 {
        .info =                 (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
                                 SNDRV_PCM_INFO_BLOCK_TRANSFER |
@@ -739,7 +739,7 @@ static struct snd_pcm_hardware snd_ice1712_playback =
        .fifo_size =            0,
 };
 
-static struct snd_pcm_hardware snd_ice1712_playback_ds =
+static const struct snd_pcm_hardware snd_ice1712_playback_ds =
 {
        .info =                 (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
                                 SNDRV_PCM_INFO_BLOCK_TRANSFER |
@@ -759,7 +759,7 @@ static struct snd_pcm_hardware snd_ice1712_playback_ds =
        .fifo_size =            0,
 };
 
-static struct snd_pcm_hardware snd_ice1712_capture =
+static const struct snd_pcm_hardware snd_ice1712_capture =
 {
        .info =                 (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
                                 SNDRV_PCM_INFO_BLOCK_TRANSFER |
@@ -1133,7 +1133,7 @@ static snd_pcm_uframes_t snd_ice1712_capture_pro_pointer(struct snd_pcm_substrea
        return bytes_to_frames(substream->runtime, ptr);
 }
 
-static struct snd_pcm_hardware snd_ice1712_playback_pro =
+static const struct snd_pcm_hardware snd_ice1712_playback_pro =
 {
        .info =                 (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
                                 SNDRV_PCM_INFO_BLOCK_TRANSFER |
@@ -1153,7 +1153,7 @@ static struct snd_pcm_hardware snd_ice1712_playback_pro =
        .fifo_size =            0,
 };
 
-static struct snd_pcm_hardware snd_ice1712_capture_pro =
+static const struct snd_pcm_hardware snd_ice1712_capture_pro =
 {
        .info =                 (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
                                 SNDRV_PCM_INFO_BLOCK_TRANSFER |
@@ -1378,9 +1378,9 @@ static int snd_ice1712_pro_mixer_volume_put(struct snd_kcontrol *kcontrol, struc
        return change;
 }
 
-static DECLARE_TLV_DB_SCALE(db_scale_playback, -14400, 150, 0);
+static const DECLARE_TLV_DB_SCALE(db_scale_playback, -14400, 150, 0);
 
-static struct snd_kcontrol_new snd_ice1712_multi_playback_ctrls[] __devinitdata = {
+static const struct snd_kcontrol_new snd_ice1712_multi_playback_ctrls[] __devinitdata = {
        {
                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
                .name = "Multi Playback Switch",
@@ -1404,7 +1404,7 @@ static struct snd_kcontrol_new snd_ice1712_multi_playback_ctrls[] __devinitdata
        },
 };
 
-static struct snd_kcontrol_new snd_ice1712_multi_capture_analog_switch __devinitdata = {
+static const struct snd_kcontrol_new snd_ice1712_multi_capture_analog_switch __devinitdata = {
        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
        .name = "H/W Multi Capture Switch",
        .info = snd_ice1712_pro_mixer_switch_info,
@@ -1413,7 +1413,7 @@ static struct snd_kcontrol_new snd_ice1712_multi_capture_analog_switch __devinit
        .private_value = 10,
 };
 
-static struct snd_kcontrol_new snd_ice1712_multi_capture_spdif_switch __devinitdata = {
+static const struct snd_kcontrol_new snd_ice1712_multi_capture_spdif_switch __devinitdata = {
        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
        .name = SNDRV_CTL_NAME_IEC958("Multi ",CAPTURE,SWITCH),
        .info = snd_ice1712_pro_mixer_switch_info,
@@ -1423,7 +1423,7 @@ static struct snd_kcontrol_new snd_ice1712_multi_capture_spdif_switch __devinitd
        .count = 2,
 };
 
-static struct snd_kcontrol_new snd_ice1712_multi_capture_analog_volume __devinitdata = {
+static const struct snd_kcontrol_new snd_ice1712_multi_capture_analog_volume __devinitdata = {
        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
        .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
                   SNDRV_CTL_ELEM_ACCESS_TLV_READ),
@@ -1435,7 +1435,7 @@ static struct snd_kcontrol_new snd_ice1712_multi_capture_analog_volume __devinit
        .tlv = { .p = db_scale_playback }
 };
 
-static struct snd_kcontrol_new snd_ice1712_multi_capture_spdif_volume __devinitdata = {
+static const struct snd_kcontrol_new snd_ice1712_multi_capture_spdif_volume __devinitdata = {
        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
        .name = SNDRV_CTL_NAME_IEC958("Multi ",CAPTURE,VOLUME),
        .info = snd_ice1712_pro_mixer_volume_info,
@@ -1627,7 +1627,7 @@ static int snd_ice1712_eeprom_get(struct snd_kcontrol *kcontrol,
        return 0;
 }
 
-static struct snd_kcontrol_new snd_ice1712_eeprom __devinitdata = {
+static const struct snd_kcontrol_new snd_ice1712_eeprom __devinitdata = {
        .iface = SNDRV_CTL_ELEM_IFACE_CARD,
        .name = "ICE1712 EEPROM",
        .access = SNDRV_CTL_ELEM_ACCESS_READ,
@@ -1663,7 +1663,7 @@ static int snd_ice1712_spdif_default_put(struct snd_kcontrol *kcontrol,
        return 0;
 }
 
-static struct snd_kcontrol_new snd_ice1712_spdif_default __devinitdata =
+static const struct snd_kcontrol_new snd_ice1712_spdif_default __devinitdata =
 {
        .iface =        SNDRV_CTL_ELEM_IFACE_PCM,
        .name =         SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT),
@@ -1714,7 +1714,7 @@ static int snd_ice1712_spdif_maskp_get(struct snd_kcontrol *kcontrol,
        return 0;
 }
 
-static struct snd_kcontrol_new snd_ice1712_spdif_maskc __devinitdata =
+static const struct snd_kcontrol_new snd_ice1712_spdif_maskc __devinitdata =
 {
        .access =       SNDRV_CTL_ELEM_ACCESS_READ,
        .iface =        SNDRV_CTL_ELEM_IFACE_PCM,
@@ -1723,7 +1723,7 @@ static struct snd_kcontrol_new snd_ice1712_spdif_maskc __devinitdata =
        .get =          snd_ice1712_spdif_maskc_get,
 };
 
-static struct snd_kcontrol_new snd_ice1712_spdif_maskp __devinitdata =
+static const struct snd_kcontrol_new snd_ice1712_spdif_maskp __devinitdata =
 {
        .access =       SNDRV_CTL_ELEM_ACCESS_READ,
        .iface =        SNDRV_CTL_ELEM_IFACE_PCM,
@@ -1750,7 +1750,7 @@ static int snd_ice1712_spdif_stream_put(struct snd_kcontrol *kcontrol,
        return 0;
 }
 
-static struct snd_kcontrol_new snd_ice1712_spdif_stream __devinitdata =
+static const struct snd_kcontrol_new snd_ice1712_spdif_stream __devinitdata =
 {
        .access =       (SNDRV_CTL_ELEM_ACCESS_READWRITE |
                         SNDRV_CTL_ELEM_ACCESS_INACTIVE),
@@ -1811,7 +1811,7 @@ int snd_ice1712_gpio_put(struct snd_kcontrol *kcontrol,
 static int snd_ice1712_pro_internal_clock_info(struct snd_kcontrol *kcontrol,
                                               struct snd_ctl_elem_info *uinfo)
 {
-       static char *texts[] = {
+       static const char * const texts[] = {
                "8000",         /* 0: 6 */
                "9600",         /* 1: 3 */
                "11025",        /* 2: 10 */
@@ -1840,7 +1840,7 @@ static int snd_ice1712_pro_internal_clock_get(struct snd_kcontrol *kcontrol,
                                              struct snd_ctl_elem_value *ucontrol)
 {
        struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
-       static unsigned char xlate[16] = {
+       static const unsigned char xlate[16] = {
                9, 6, 3, 1, 7, 4, 0, 12, 8, 5, 2, 11, 255, 255, 255, 10
        };
        unsigned char val;
@@ -1864,7 +1864,7 @@ static int snd_ice1712_pro_internal_clock_put(struct snd_kcontrol *kcontrol,
                                              struct snd_ctl_elem_value *ucontrol)
 {
        struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
-       static unsigned int xrate[13] = {
+       static const unsigned int xrate[13] = {
                8000, 9600, 11025, 12000, 16000, 22050, 24000,
                32000, 44100, 48000, 64000, 88200, 96000
        };
@@ -1891,7 +1891,7 @@ static int snd_ice1712_pro_internal_clock_put(struct snd_kcontrol *kcontrol,
        return change;
 }
 
-static struct snd_kcontrol_new snd_ice1712_pro_internal_clock __devinitdata = {
+static const struct snd_kcontrol_new snd_ice1712_pro_internal_clock __devinitdata = {
        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
        .name = "Multi Track Internal Clock",
        .info = snd_ice1712_pro_internal_clock_info,
@@ -1902,7 +1902,7 @@ static struct snd_kcontrol_new snd_ice1712_pro_internal_clock __devinitdata = {
 static int snd_ice1712_pro_internal_clock_default_info(struct snd_kcontrol *kcontrol,
                                                       struct snd_ctl_elem_info *uinfo)
 {
-       static char *texts[] = {
+       static const char * const texts[] = {
                "8000",         /* 0: 6 */
                "9600",         /* 1: 3 */
                "11025",        /* 2: 10 */
@@ -1931,7 +1931,7 @@ static int snd_ice1712_pro_internal_clock_default_get(struct snd_kcontrol *kcont
                                                      struct snd_ctl_elem_value *ucontrol)
 {
        int val;
-       static unsigned int xrate[13] = {
+       static const unsigned int xrate[13] = {
                8000, 9600, 11025, 12000, 16000, 22050, 24000,
                32000, 44100, 48000, 64000, 88200, 96000
        };
@@ -1948,7 +1948,7 @@ static int snd_ice1712_pro_internal_clock_default_get(struct snd_kcontrol *kcont
 static int snd_ice1712_pro_internal_clock_default_put(struct snd_kcontrol *kcontrol,
                                                      struct snd_ctl_elem_value *ucontrol)
 {
-       static unsigned int xrate[13] = {
+       static const unsigned int xrate[13] = {
                8000, 9600, 11025, 12000, 16000, 22050, 24000,
                32000, 44100, 48000, 64000, 88200, 96000
        };
@@ -1962,7 +1962,7 @@ static int snd_ice1712_pro_internal_clock_default_put(struct snd_kcontrol *kcont
        return change;
 }
 
-static struct snd_kcontrol_new snd_ice1712_pro_internal_clock_default __devinitdata = {
+static const struct snd_kcontrol_new snd_ice1712_pro_internal_clock_default __devinitdata = {
        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
        .name = "Multi Track Internal Clock Default",
        .info = snd_ice1712_pro_internal_clock_default_info,
@@ -2001,7 +2001,7 @@ static int snd_ice1712_pro_rate_locking_put(struct snd_kcontrol *kcontrol,
        return change;
 }
 
-static struct snd_kcontrol_new snd_ice1712_pro_rate_locking __devinitdata = {
+static const struct snd_kcontrol_new snd_ice1712_pro_rate_locking __devinitdata = {
        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
        .name = "Multi Track Rate Locking",
        .info = snd_ice1712_pro_rate_locking_info,
@@ -2040,7 +2040,7 @@ static int snd_ice1712_pro_rate_reset_put(struct snd_kcontrol *kcontrol,
        return change;
 }
 
-static struct snd_kcontrol_new snd_ice1712_pro_rate_reset __devinitdata = {
+static const struct snd_kcontrol_new snd_ice1712_pro_rate_reset __devinitdata = {
        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
        .name = "Multi Track Rate Reset",
        .info = snd_ice1712_pro_rate_reset_info,
@@ -2054,7 +2054,7 @@ static struct snd_kcontrol_new snd_ice1712_pro_rate_reset __devinitdata = {
 static int snd_ice1712_pro_route_info(struct snd_kcontrol *kcontrol,
                                      struct snd_ctl_elem_info *uinfo)
 {
-       static char *texts[] = {
+       static const char * const texts[] = {
                "PCM Out", /* 0 */
                "H/W In 0", "H/W In 1", "H/W In 2", "H/W In 3", /* 1-4 */
                "H/W In 4", "H/W In 5", "H/W In 6", "H/W In 7", /* 5-8 */
@@ -2207,7 +2207,7 @@ static int snd_ice1712_pro_route_spdif_put(struct snd_kcontrol *kcontrol,
        return change;
 }
 
-static struct snd_kcontrol_new snd_ice1712_mixer_pro_analog_route __devinitdata = {
+static const struct snd_kcontrol_new snd_ice1712_mixer_pro_analog_route __devinitdata = {
        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
        .name = "H/W Playback Route",
        .info = snd_ice1712_pro_route_info,
@@ -2215,7 +2215,7 @@ static struct snd_kcontrol_new snd_ice1712_mixer_pro_analog_route __devinitdata
        .put = snd_ice1712_pro_route_analog_put,
 };
 
-static struct snd_kcontrol_new snd_ice1712_mixer_pro_spdif_route __devinitdata = {
+static const struct snd_kcontrol_new snd_ice1712_mixer_pro_spdif_route __devinitdata = {
        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
        .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Route",
        .info = snd_ice1712_pro_route_info,
@@ -2257,7 +2257,7 @@ static int snd_ice1712_pro_volume_rate_put(struct snd_kcontrol *kcontrol,
        return change;
 }
 
-static struct snd_kcontrol_new snd_ice1712_mixer_pro_volume_rate __devinitdata = {
+static const struct snd_kcontrol_new snd_ice1712_mixer_pro_volume_rate __devinitdata = {
        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
        .name = "Multi Track Volume Rate",
        .info = snd_ice1712_pro_volume_rate_info,
@@ -2290,7 +2290,7 @@ static int snd_ice1712_pro_peak_get(struct snd_kcontrol *kcontrol,
        return 0;
 }
 
-static struct snd_kcontrol_new snd_ice1712_mixer_pro_peak __devinitdata = {
+static const struct snd_kcontrol_new snd_ice1712_mixer_pro_peak __devinitdata = {
        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
        .name = "Multi Track Peak",
        .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE,
@@ -2305,7 +2305,7 @@ static struct snd_kcontrol_new snd_ice1712_mixer_pro_peak __devinitdata = {
 /*
  * list of available boards
  */
-static struct snd_ice1712_card_info *card_tables[] __devinitdata = {
+static const struct snd_ice1712_card_info *card_tables[] __devinitdata = {
        snd_ice1712_hoontech_cards,
        snd_ice1712_delta_cards,
        snd_ice1712_ews_cards,
@@ -2329,7 +2329,7 @@ static int __devinit snd_ice1712_read_eeprom(struct snd_ice1712 *ice,
 {
        int dev = 0xa0;         /* EEPROM device address */
        unsigned int i, size;
-       struct snd_ice1712_card_info **tbl, *c;
+       const struct snd_ice1712_card_info **tbl, *c;
 
        if (! modelname || ! *modelname) {
                ice->eeprom.subvendor = 0;
@@ -2658,7 +2658,7 @@ static int __devinit snd_ice1712_create(struct snd_card *card,
  *
  */
 
-static struct snd_ice1712_card_info no_matched __devinitdata;
+static const struct snd_ice1712_card_info no_matched __devinitdata;
 
 static int __devinit snd_ice1712_probe(struct pci_dev *pci,
                                       const struct pci_device_id *pci_id)
@@ -2667,7 +2667,7 @@ static int __devinit snd_ice1712_probe(struct pci_dev *pci,
        struct snd_card *card;
        struct snd_ice1712 *ice;
        int pcm_dev = 0, err;
-       struct snd_ice1712_card_info **tbl, *c;
+       const struct snd_ice1712_card_info **tbl, *c;
 
        if (dev >= SNDRV_CARDS)
                return -ENODEV;
index ce27eac40d4e15d5e8e10a5f3e94b65cda98d90b..c3d9feaaf57df8363790e722107631fae6e0453f 100644 (file)
@@ -28,6 +28,7 @@
 #include <sound/i2c.h>
 #include <sound/ak4xxx-adda.h>
 #include <sound/ak4114.h>
+#include <sound/pt2258.h>
 #include <sound/pcm.h>
 #include <sound/mpu401.h>
 
@@ -381,6 +382,11 @@ struct snd_ice1712 {
                        unsigned short master[2];
                        unsigned short vol[8];
                } phase28;
+               /* a non-standard I2C device for revo51 */
+               struct revo51_spec {
+                       struct snd_i2c_device *dev;
+                       struct snd_pt2258 *pt2258;
+               } revo51;
                /* Hoontech-specific setting */
                struct hoontech_spec {
                        unsigned char boxbits[4];
@@ -462,6 +468,14 @@ static inline void snd_ice1712_gpio_write_bits(struct snd_ice1712 *ice,
        snd_ice1712_gpio_write(ice, mask & bits);
 }
 
+static inline int snd_ice1712_gpio_read_bits(struct snd_ice1712 *ice,
+                                             unsigned int mask)
+{
+       ice->gpio.direction &= ~mask;
+       snd_ice1712_gpio_set_dir(ice, ice->gpio.direction);
+       return  (snd_ice1712_gpio_read(ice) & mask);
+}
+
 int snd_ice1712_spdif_build_controls(struct snd_ice1712 *ice);
 
 int snd_ice1712_akm4xxx_init(struct snd_akm4xxx *ak, const struct snd_akm4xxx *template,
@@ -500,8 +514,8 @@ struct snd_ice1712_card_info {
        unsigned int mpu401_2_info_flags;
        const char *mpu401_1_name;
        const char *mpu401_2_name;
-       unsigned int eeprom_size;
-       unsigned char *eeprom_data;
+       const unsigned int eeprom_size;
+       const unsigned char *eeprom_data;
 };
 
 
index 3e3a102e6c34286884476f394a6cb3324586a7fb..1127ebdf5fec45971a41869d797229300fc2ba90 100644 (file)
@@ -50,7 +50,7 @@
 #include "prodigy192.h"
 #include "juli.h"
 #include "phase.h"
-
+#include "wtm.h"
 
 MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
 MODULE_DESCRIPTION("VIA ICEnsemble ICE1724/1720 (Envy24HT/PT)");
@@ -64,6 +64,7 @@ MODULE_SUPPORTED_DEVICE("{"
               PRODIGY192_DEVICE_DESC
               JULI_DEVICE_DESC
               PHASE_DEVICE_DESC
+              WTM_DEVICE_DESC
                "{VIA,VT1720},"
                "{VIA,VT1724},"
                "{ICEnsemble,Generic ICE1724},"
@@ -86,7 +87,7 @@ MODULE_PARM_DESC(model, "Use the given board model.");
 
 
 /* Both VT1720 and VT1724 have the same PCI IDs */
-static struct pci_device_id snd_vt1724_ids[] = {
+static const struct pci_device_id snd_vt1724_ids[] = {
        { PCI_VENDOR_ID_ICE, PCI_DEVICE_ID_VT1724, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
        { 0, }
 };
@@ -341,7 +342,7 @@ static int snd_vt1724_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
 
        what = 0;
        snd_pcm_group_for_each(pos, substream) {
-               struct vt1724_pcm_reg *reg;
+               const struct vt1724_pcm_reg *reg;
                s = snd_pcm_group_substream_entry(pos);
                reg = s->runtime->private_data;
                what |= reg->start;
@@ -605,7 +606,7 @@ static snd_pcm_uframes_t snd_vt1724_playback_pro_pointer(struct snd_pcm_substrea
 static int snd_vt1724_pcm_prepare(struct snd_pcm_substream *substream)
 {
        struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
-       struct vt1724_pcm_reg *reg = substream->runtime->private_data;
+       const struct vt1724_pcm_reg *reg = substream->runtime->private_data;
 
        spin_lock_irq(&ice->reg_lock);
        outl(substream->runtime->dma_addr, ice->profi_port + reg->addr);
@@ -620,7 +621,7 @@ static int snd_vt1724_pcm_prepare(struct snd_pcm_substream *substream)
 static snd_pcm_uframes_t snd_vt1724_pcm_pointer(struct snd_pcm_substream *substream)
 {
        struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
-       struct vt1724_pcm_reg *reg = substream->runtime->private_data;
+       const struct vt1724_pcm_reg *reg = substream->runtime->private_data;
        size_t ptr;
 
        if (!(inl(ICEMT1724(ice, DMA_CONTROL)) & reg->start))
@@ -646,21 +647,21 @@ static snd_pcm_uframes_t snd_vt1724_pcm_pointer(struct snd_pcm_substream *substr
 #endif
 }
 
-static struct vt1724_pcm_reg vt1724_playback_pro_reg = {
+static const struct vt1724_pcm_reg vt1724_playback_pro_reg = {
        .addr = VT1724_MT_PLAYBACK_ADDR,
        .size = VT1724_MT_PLAYBACK_SIZE,
        .count = VT1724_MT_PLAYBACK_COUNT,
        .start = VT1724_PDMA0_START,
 };
 
-static struct vt1724_pcm_reg vt1724_capture_pro_reg = {
+static const struct vt1724_pcm_reg vt1724_capture_pro_reg = {
        .addr = VT1724_MT_CAPTURE_ADDR,
        .size = VT1724_MT_CAPTURE_SIZE,
        .count = VT1724_MT_CAPTURE_COUNT,
        .start = VT1724_RDMA0_START,
 };
 
-static struct snd_pcm_hardware snd_vt1724_playback_pro =
+static const struct snd_pcm_hardware snd_vt1724_playback_pro =
 {
        .info =                 (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
                                 SNDRV_PCM_INFO_BLOCK_TRANSFER |
@@ -679,7 +680,7 @@ static struct snd_pcm_hardware snd_vt1724_playback_pro =
        .periods_max =          1024,
 };
 
-static struct snd_pcm_hardware snd_vt1724_spdif =
+static const struct snd_pcm_hardware snd_vt1724_spdif =
 {
        .info =                 (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
                                 SNDRV_PCM_INFO_BLOCK_TRANSFER |
@@ -701,7 +702,7 @@ static struct snd_pcm_hardware snd_vt1724_spdif =
        .periods_max =          1024,
 };
 
-static struct snd_pcm_hardware snd_vt1724_2ch_stereo =
+static const struct snd_pcm_hardware snd_vt1724_2ch_stereo =
 {
        .info =                 (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
                                 SNDRV_PCM_INFO_BLOCK_TRANSFER |
@@ -773,7 +774,7 @@ static int snd_vt1724_playback_pro_open(struct snd_pcm_substream *substream)
        struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
        int chs;
 
-       runtime->private_data = &vt1724_playback_pro_reg;
+       runtime->private_data = (void *)&vt1724_playback_pro_reg;
        ice->playback_pro_substream = substream;
        runtime->hw = snd_vt1724_playback_pro;
        snd_pcm_set_sync(substream);
@@ -802,7 +803,7 @@ static int snd_vt1724_capture_pro_open(struct snd_pcm_substream *substream)
        struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
        struct snd_pcm_runtime *runtime = substream->runtime;
 
-       runtime->private_data = &vt1724_capture_pro_reg;
+       runtime->private_data = (void *)&vt1724_capture_pro_reg;
        ice->capture_pro_substream = substream;
        runtime->hw = snd_vt1724_2ch_stereo;
        snd_pcm_set_sync(substream);
@@ -888,14 +889,14 @@ static int __devinit snd_vt1724_pcm_profi(struct snd_ice1712 * ice, int device)
  * SPDIF PCM
  */
 
-static struct vt1724_pcm_reg vt1724_playback_spdif_reg = {
+static const struct vt1724_pcm_reg vt1724_playback_spdif_reg = {
        .addr = VT1724_MT_PDMA4_ADDR,
        .size = VT1724_MT_PDMA4_SIZE,
        .count = VT1724_MT_PDMA4_COUNT,
        .start = VT1724_PDMA4_START,
 };
 
-static struct vt1724_pcm_reg vt1724_capture_spdif_reg = {
+static const struct vt1724_pcm_reg vt1724_capture_spdif_reg = {
        .addr = VT1724_MT_RDMA1_ADDR,
        .size = VT1724_MT_RDMA1_SIZE,
        .count = VT1724_MT_RDMA1_COUNT,
@@ -953,7 +954,7 @@ static int snd_vt1724_playback_spdif_open(struct snd_pcm_substream *substream)
        struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
        struct snd_pcm_runtime *runtime = substream->runtime;
 
-       runtime->private_data = &vt1724_playback_spdif_reg;
+       runtime->private_data = (void *)&vt1724_playback_spdif_reg;
        ice->playback_con_substream = substream;
        if (ice->force_pdma4) {
                runtime->hw = snd_vt1724_2ch_stereo;
@@ -985,7 +986,7 @@ static int snd_vt1724_capture_spdif_open(struct snd_pcm_substream *substream)
        struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
        struct snd_pcm_runtime *runtime = substream->runtime;
 
-       runtime->private_data = &vt1724_capture_spdif_reg;
+       runtime->private_data = (void *)&vt1724_capture_spdif_reg;
        ice->capture_con_substream = substream;
        if (ice->force_rdma1) {
                runtime->hw = snd_vt1724_2ch_stereo;
@@ -1090,7 +1091,7 @@ static int __devinit snd_vt1724_pcm_spdif(struct snd_ice1712 * ice, int device)
  * independent surround PCMs
  */
 
-static struct vt1724_pcm_reg vt1724_playback_dma_regs[3] = {
+static const struct vt1724_pcm_reg vt1724_playback_dma_regs[3] = {
        {
                .addr = VT1724_MT_PDMA1_ADDR,
                .size = VT1724_MT_PDMA1_SIZE,
@@ -1136,7 +1137,7 @@ static int snd_vt1724_playback_indep_open(struct snd_pcm_substream *substream)
                return -EBUSY; /* FIXME: should handle blocking mode properly */
        }
        mutex_unlock(&ice->open_mutex);
-       runtime->private_data = &vt1724_playback_dma_regs[substream->number];
+       runtime->private_data = (void *)&vt1724_playback_dma_regs[substream->number];
        ice->playback_con_substream_ds[substream->number] = substream;
        runtime->hw = snd_vt1724_2ch_stereo;
        snd_pcm_set_sync(substream);
@@ -1317,7 +1318,7 @@ static int snd_vt1724_eeprom_get(struct snd_kcontrol *kcontrol,
        return 0;
 }
 
-static struct snd_kcontrol_new snd_vt1724_eeprom __devinitdata = {
+static const struct snd_kcontrol_new snd_vt1724_eeprom __devinitdata = {
        .iface = SNDRV_CTL_ELEM_IFACE_CARD,
        .name = "ICE1724 EEPROM",
        .access = SNDRV_CTL_ELEM_ACCESS_READ,
@@ -1430,7 +1431,7 @@ static int snd_vt1724_spdif_default_put(struct snd_kcontrol *kcontrol,
        return (val != old);
 }
 
-static struct snd_kcontrol_new snd_vt1724_spdif_default __devinitdata =
+static const struct snd_kcontrol_new snd_vt1724_spdif_default __devinitdata =
 {
        .iface =        SNDRV_CTL_ELEM_IFACE_PCM,
        .name =         SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT),
@@ -1462,7 +1463,7 @@ static int snd_vt1724_spdif_maskp_get(struct snd_kcontrol *kcontrol,
        return 0;
 }
 
-static struct snd_kcontrol_new snd_vt1724_spdif_maskc __devinitdata =
+static const struct snd_kcontrol_new snd_vt1724_spdif_maskc __devinitdata =
 {
        .access =       SNDRV_CTL_ELEM_ACCESS_READ,
        .iface =        SNDRV_CTL_ELEM_IFACE_PCM,
@@ -1471,7 +1472,7 @@ static struct snd_kcontrol_new snd_vt1724_spdif_maskc __devinitdata =
        .get =          snd_vt1724_spdif_maskc_get,
 };
 
-static struct snd_kcontrol_new snd_vt1724_spdif_maskp __devinitdata =
+static const struct snd_kcontrol_new snd_vt1724_spdif_maskp __devinitdata =
 {
        .access =       SNDRV_CTL_ELEM_ACCESS_READ,
        .iface =        SNDRV_CTL_ELEM_IFACE_PCM,
@@ -1516,7 +1517,7 @@ static int snd_vt1724_spdif_sw_put(struct snd_kcontrol *kcontrol,
        return old != val;
 }
 
-static struct snd_kcontrol_new snd_vt1724_spdif_switch __devinitdata =
+static const struct snd_kcontrol_new snd_vt1724_spdif_switch __devinitdata =
 {
        .iface =        SNDRV_CTL_ELEM_IFACE_MIXER,
        /* FIXME: the following conflict with IEC958 Playback Route */
@@ -1584,7 +1585,7 @@ int snd_ice1712_gpio_put(struct snd_kcontrol *kcontrol,
 static int snd_vt1724_pro_internal_clock_info(struct snd_kcontrol *kcontrol,
                                              struct snd_ctl_elem_info *uinfo)
 {
-       static char *texts_1724[] = {
+       static const char * const texts_1724[] = {
                "8000",         /* 0: 6 */
                "9600",         /* 1: 3 */
                "11025",        /* 2: 10 */
@@ -1602,7 +1603,7 @@ static int snd_vt1724_pro_internal_clock_info(struct snd_kcontrol *kcontrol,
                "192000",       /* 14: 14 */
                "IEC958 Input", /* 15: -- */
        };
-       static char *texts_1720[] = {
+       static const char * const texts_1720[] = {
                "8000",         /* 0: 6 */
                "9600",         /* 1: 3 */
                "11025",        /* 2: 10 */
@@ -1635,7 +1636,7 @@ static int snd_vt1724_pro_internal_clock_get(struct snd_kcontrol *kcontrol,
                                             struct snd_ctl_elem_value *ucontrol)
 {
        struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
-       static unsigned char xlate[16] = {
+       static const unsigned char xlate[16] = {
                9, 6, 3, 1, 7, 4, 0, 12, 8, 5, 2, 11, 13, 255, 14, 10
        };
        unsigned char val;
@@ -1694,7 +1695,7 @@ static int snd_vt1724_pro_internal_clock_put(struct snd_kcontrol *kcontrol,
        return change;
 }
 
-static struct snd_kcontrol_new snd_vt1724_pro_internal_clock __devinitdata = {
+static const struct snd_kcontrol_new snd_vt1724_pro_internal_clock __devinitdata = {
        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
        .name = "Multi Track Internal Clock",
        .info = snd_vt1724_pro_internal_clock_info,
@@ -1733,7 +1734,7 @@ static int snd_vt1724_pro_rate_locking_put(struct snd_kcontrol *kcontrol,
        return change;
 }
 
-static struct snd_kcontrol_new snd_vt1724_pro_rate_locking __devinitdata = {
+static const struct snd_kcontrol_new snd_vt1724_pro_rate_locking __devinitdata = {
        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
        .name = "Multi Track Rate Locking",
        .info = snd_vt1724_pro_rate_locking_info,
@@ -1772,7 +1773,7 @@ static int snd_vt1724_pro_rate_reset_put(struct snd_kcontrol *kcontrol,
        return change;
 }
 
-static struct snd_kcontrol_new snd_vt1724_pro_rate_reset __devinitdata = {
+static const struct snd_kcontrol_new snd_vt1724_pro_rate_reset __devinitdata = {
        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
        .name = "Multi Track Rate Reset",
        .info = snd_vt1724_pro_rate_reset_info,
@@ -1816,7 +1817,7 @@ static int get_route_val(struct snd_ice1712 *ice, int shift)
 {
        unsigned long val;
        unsigned char eitem;
-       static unsigned char xlate[8] = {
+       static const unsigned char xlate[8] = {
                0, 255, 1, 2, 255, 255, 3, 4,
        };
 
@@ -1835,7 +1836,7 @@ static int put_route_val(struct snd_ice1712 *ice, unsigned int val, int shift)
 {
        unsigned int old_val, nval;
        int change;
-       static unsigned char xroute[8] = {
+       static const unsigned char xroute[8] = {
                0, /* PCM */
                2, /* PSDIN0 Left */
                3, /* PSDIN0 Right */
@@ -1891,7 +1892,7 @@ static int snd_vt1724_pro_route_spdif_put(struct snd_kcontrol *kcontrol,
                             digital_route_shift(idx));
 }
 
-static struct snd_kcontrol_new snd_vt1724_mixer_pro_analog_route __devinitdata = {
+static const struct snd_kcontrol_new snd_vt1724_mixer_pro_analog_route __devinitdata = {
        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
        .name = "H/W Playback Route",
        .info = snd_vt1724_pro_route_info,
@@ -1899,7 +1900,7 @@ static struct snd_kcontrol_new snd_vt1724_mixer_pro_analog_route __devinitdata =
        .put = snd_vt1724_pro_route_analog_put,
 };
 
-static struct snd_kcontrol_new snd_vt1724_mixer_pro_spdif_route __devinitdata = {
+static const struct snd_kcontrol_new snd_vt1724_mixer_pro_spdif_route __devinitdata = {
        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
        .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Route",
        .info = snd_vt1724_pro_route_info,
@@ -1935,7 +1936,7 @@ static int snd_vt1724_pro_peak_get(struct snd_kcontrol *kcontrol,
        return 0;
 }
 
-static struct snd_kcontrol_new snd_vt1724_mixer_pro_peak __devinitdata = {
+static const struct snd_kcontrol_new snd_vt1724_mixer_pro_peak __devinitdata = {
        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
        .name = "Multi Track Peak",
        .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE,
@@ -1947,9 +1948,9 @@ static struct snd_kcontrol_new snd_vt1724_mixer_pro_peak __devinitdata = {
  *
  */
 
-static struct snd_ice1712_card_info no_matched __devinitdata;
+static const struct snd_ice1712_card_info no_matched __devinitdata;
 
-static struct snd_ice1712_card_info *card_tables[] __devinitdata = {
+static const struct snd_ice1712_card_info *card_tables[] __devinitdata = {
        snd_vt1724_revo_cards,
        snd_vt1724_amp_cards, 
        snd_vt1724_aureon_cards,
@@ -1958,6 +1959,7 @@ static struct snd_ice1712_card_info *card_tables[] __devinitdata = {
        snd_vt1724_prodigy192_cards,
        snd_vt1724_juli_cards,
        snd_vt1724_phase_cards,
+       snd_vt1724_wtm_cards,
        NULL,
 };
 
@@ -2007,7 +2009,7 @@ static int __devinit snd_vt1724_read_eeprom(struct snd_ice1712 *ice,
 {
        const int dev = 0xa0;           /* EEPROM device address */
        unsigned int i, size;
-       struct snd_ice1712_card_info **tbl, *c;
+       const struct snd_ice1712_card_info **tbl, *c;
 
        if (! modelname || ! *modelname) {
                ice->eeprom.subvendor = 0;
@@ -2306,7 +2308,7 @@ static int __devinit snd_vt1724_probe(struct pci_dev *pci,
        struct snd_card *card;
        struct snd_ice1712 *ice;
        int pcm_dev = 0, err;
-       struct snd_ice1712_card_info **tbl, *c;
+       const struct snd_ice1712_card_info **tbl, *c;
 
        if (dev >= SNDRV_CARDS)
                return -ENODEV;
index 5176b41ea9d37b8e86a1426d2d9b3d70bdb37083..d88172fa95da5f9f539871e509afba47e72a2797 100644 (file)
@@ -125,7 +125,7 @@ static void juli_akm_set_rate_val(struct snd_akm4xxx *ak, unsigned int rate)
        snd_akm4xxx_reset(ak, 0);
 }
 
-static struct snd_akm4xxx akm_juli_dac __devinitdata = {
+static const struct snd_akm4xxx akm_juli_dac __devinitdata = {
        .type = SND_AK4358,
        .num_dacs = 2,
        .ops = {
@@ -146,7 +146,7 @@ static int __devinit juli_add_controls(struct snd_ice1712 *ice)
  */
 static int __devinit juli_init(struct snd_ice1712 *ice)
 {
-       static unsigned char ak4114_init_vals[] = {
+       static const unsigned char ak4114_init_vals[] = {
                /* AK4117_REG_PWRDN */  AK4114_RST | AK4114_PWN | AK4114_OCKS0 | AK4114_OCKS1,
                /* AK4114_REQ_FORMAT */ AK4114_DIF_I24I2S,
                /* AK4114_REG_IO0 */    AK4114_TX1E,
@@ -154,7 +154,7 @@ static int __devinit juli_init(struct snd_ice1712 *ice)
                /* AK4114_REG_INT0_MASK */ 0,
                /* AK4114_REG_INT1_MASK */ 0
        };
-       static unsigned char ak4114_init_txcsb[] = {
+       static const unsigned char ak4114_init_txcsb[] = {
                0x41, 0x02, 0x2c, 0x00, 0x00
        };
        int err;
@@ -206,24 +206,24 @@ static int __devinit juli_init(struct snd_ice1712 *ice)
  * hence the driver needs to sets up it properly.
  */
 
-static unsigned char juli_eeprom[] __devinitdata = {
-       0x20,   /* SYSCONF: clock 512, mpu401, 1xADC, 1xDACs */
-       0x80,   /* ACLINK: I2S */
-       0xf8,   /* I2S: vol, 96k, 24bit, 192k */
-       0xc3,   /* SPDIF: out-en, out-int, spdif-in */
-       0x9f,   /* GPIO_DIR */
-       0xff,   /* GPIO_DIR1 */
-       0x7f,   /* GPIO_DIR2 */
-       0x9f,   /* GPIO_MASK */
-       0xff,   /* GPIO_MASK1 */
-       0x7f,   /* GPIO_MASK2 */
-       0x16,   /* GPIO_STATE: internal clock, multiple 1x, 48kHz */
-       0x80,   /* GPIO_STATE1: mute */
-       0x00,   /* GPIO_STATE2 */
+static const unsigned char juli_eeprom[] __devinitdata = {
+       [ICE_EEP2_SYSCONF]     = 0x20,  /* clock 512, mpu401, 1xADC, 1xDACs */
+       [ICE_EEP2_ACLINK]      = 0x80,  /* I2S */
+       [ICE_EEP2_I2S]         = 0xf8,  /* vol, 96k, 24bit, 192k */
+       [ICE_EEP2_SPDIF]       = 0xc3,  /* out-en, out-int, spdif-in */
+       [ICE_EEP2_GPIO_DIR]    = 0x9f,
+       [ICE_EEP2_GPIO_DIR1]   = 0xff,
+       [ICE_EEP2_GPIO_DIR2]   = 0x7f,
+       [ICE_EEP2_GPIO_MASK]   = 0x9f,
+       [ICE_EEP2_GPIO_MASK1]  = 0xff,
+       [ICE_EEP2_GPIO_MASK2]  = 0x7f,
+       [ICE_EEP2_GPIO_STATE]  = 0x16,  /* internal clock, multiple 1x, 48kHz */
+       [ICE_EEP2_GPIO_STATE1] = 0x80,  /* mute */
+       [ICE_EEP2_GPIO_STATE2] = 0x00,
 };
 
 /* entry point */
-struct snd_ice1712_card_info snd_vt1724_juli_cards[] __devinitdata = {
+const struct snd_ice1712_card_info snd_vt1724_juli_cards[] __devinitdata = {
        {
                .subvendor = VT1724_SUBDEVICE_JULI,
                .name = "ESI Juli@",
index d9f8534fd92ee527f12e337fd0cca53ed7a77004..1b9294f8bce3543423bc84d338c7f70c2725ac88 100644 (file)
@@ -5,6 +5,6 @@
 
 #define VT1724_SUBDEVICE_JULI          0x31305345      /* Juli@ */
 
-extern struct snd_ice1712_card_info  snd_vt1724_juli_cards[];
+extern const struct snd_ice1712_card_info  snd_vt1724_juli_cards[];
 
 #endif /* __SOUND_JULI_H */
index e08d73f4ff85d6d012a40f6b47ca79d548d3c820..0751718f4d7b18a5420f79484ae558aa9bc56677 100644 (file)
@@ -71,7 +71,7 @@
  * Logarithmic volume values for WM8770
  * Computed as 20 * Log10(255 / x)
  */
-static unsigned char wm_vol[256] = {
+static const unsigned char wm_vol[256] = {
        127, 48, 42, 39, 36, 34, 33, 31, 30, 29, 28, 27, 27, 26, 25, 25, 24, 24, 23,
        23, 22, 22, 21, 21, 21, 20, 20, 20, 19, 19, 19, 18, 18, 18, 18, 17, 17, 17,
        17, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15, 14, 14, 14, 14, 14, 13, 13, 13,
@@ -89,13 +89,13 @@ static unsigned char wm_vol[256] = {
 #define WM_VOL_MAX     (sizeof(wm_vol) - 1)
 #define WM_VOL_MUTE    0x8000
 
-static struct snd_akm4xxx akm_phase22 __devinitdata = {
+static const struct snd_akm4xxx akm_phase22 __devinitdata = {
        .type = SND_AK4524,
        .num_dacs = 2,
        .num_adcs = 2,
 };
 
-static struct snd_ak4xxx_private akm_phase22_priv __devinitdata = {
+static const struct snd_ak4xxx_private akm_phase22_priv __devinitdata = {
        .caddr =        2,
        .cif =          1,
        .data_mask =    1 << 4,
@@ -152,36 +152,36 @@ static int __devinit phase22_add_controls(struct snd_ice1712 *ice)
        return 0;
 }
 
-static unsigned char phase22_eeprom[] __devinitdata = {
-       0x00,   /* SYSCONF: 1xADC, 1xDACs */
-       0x80,   /* ACLINK: I2S */
-       0xf8,   /* I2S: vol, 96k, 24bit*/
-       0xc3,   /* SPDIF: out-en, out-int, spdif-in */
-       0xFF,   /* GPIO_DIR */
-       0xFF,   /* GPIO_DIR1 */
-       0xFF,   /* GPIO_DIR2 */
-       0x00,   /* GPIO_MASK */
-       0x00,   /* GPIO_MASK1 */
-       0x00,   /* GPIO_MASK2 */
-       0x00,   /* GPIO_STATE: */
-       0x00,   /* GPIO_STATE1: */
-       0x00,   /* GPIO_STATE2 */
+static const unsigned char phase22_eeprom[] __devinitdata = {
+       [ICE_EEP2_SYSCONF]     = 0x00,  /* 1xADC, 1xDACs */
+       [ICE_EEP2_ACLINK]      = 0x80,  /* I2S */
+       [ICE_EEP2_I2S]         = 0xf8,  /* vol, 96k, 24bit */
+       [ICE_EEP2_SPDIF]       = 0xc3,  /* out-en, out-int, spdif-in */
+       [ICE_EEP2_GPIO_DIR]    = 0xff,
+       [ICE_EEP2_GPIO_DIR1]   = 0xff,
+       [ICE_EEP2_GPIO_DIR2]   = 0xff,
+       [ICE_EEP2_GPIO_MASK]   = 0x00,
+       [ICE_EEP2_GPIO_MASK1]  = 0x00,
+       [ICE_EEP2_GPIO_MASK2]  = 0x00,
+       [ICE_EEP2_GPIO_STATE]  = 0x00,
+       [ICE_EEP2_GPIO_STATE1] = 0x00,
+       [ICE_EEP2_GPIO_STATE2] = 0x00,
 };
 
-static unsigned char phase28_eeprom[] __devinitdata = {
-       0x0b,   /* SYSCONF: clock 512, spdif-in/ADC, 4DACs */
-       0x80,   /* ACLINK: I2S */
-       0xfc,   /* I2S: vol, 96k, 24bit, 192k */
-       0xc3,   /* SPDIF: out-en, out-int, spdif-in */
-       0xff,   /* GPIO_DIR */
-       0xff,   /* GPIO_DIR1 */
-       0x5f,   /* GPIO_DIR2 */
-       0x00,   /* GPIO_MASK */
-       0x00,   /* GPIO_MASK1 */
-       0x00,   /* GPIO_MASK2 */
-       0x00,   /* GPIO_STATE */
-       0x00,   /* GPIO_STATE1 */
-       0x00,   /* GPIO_STATE2 */
+static const unsigned char phase28_eeprom[] __devinitdata = {
+       [ICE_EEP2_SYSCONF]     = 0x0b,  /* clock 512, spdif-in/ADC, 4DACs */
+       [ICE_EEP2_ACLINK]      = 0x80,  /* I2S */
+       [ICE_EEP2_I2S]         = 0xfc,  /* vol, 96k, 24bit, 192k */
+       [ICE_EEP2_SPDIF]       = 0xc3,  /* out-en, out-int, spdif-in */
+       [ICE_EEP2_GPIO_DIR]    = 0xff,
+       [ICE_EEP2_GPIO_DIR1]   = 0xff,
+       [ICE_EEP2_GPIO_DIR2]   = 0x5f,
+       [ICE_EEP2_GPIO_MASK]   = 0x00,
+       [ICE_EEP2_GPIO_MASK1]  = 0x00,
+       [ICE_EEP2_GPIO_MASK2]  = 0x00,
+       [ICE_EEP2_GPIO_STATE]  = 0x00,
+       [ICE_EEP2_GPIO_STATE1] = 0x00,
+       [ICE_EEP2_GPIO_STATE2] = 0x00,
 };
 
 /*
@@ -343,7 +343,7 @@ static int wm_master_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_
 
 static int __devinit phase28_init(struct snd_ice1712 *ice)
 {
-       static unsigned short wm_inits_phase28[] = {
+       static const unsigned short wm_inits_phase28[] = {
                /* These come first to reduce init pop noise */
                0x1b, 0x044,            /* ADC Mux (AC'97 source) */
                0x1c, 0x00B,            /* Out Mux1 (VOUT1 = DAC+AUX, VOUT2 = DAC) */
@@ -382,7 +382,7 @@ static int __devinit phase28_init(struct snd_ice1712 *ice)
 
        unsigned int tmp;
        struct snd_akm4xxx *ak;
-       unsigned short *p;
+       const unsigned short *p;
        int i;
 
        ice->num_total_dacs = 8;
@@ -697,10 +697,10 @@ static int phase28_oversampling_put(struct snd_kcontrol *kcontrol, struct snd_ct
        return 0;
 }
 
-static DECLARE_TLV_DB_SCALE(db_scale_wm_dac, -12700, 100, 1);
-static DECLARE_TLV_DB_SCALE(db_scale_wm_pcm, -6400, 50, 1);
+static const DECLARE_TLV_DB_SCALE(db_scale_wm_dac, -12700, 100, 1);
+static const DECLARE_TLV_DB_SCALE(db_scale_wm_pcm, -6400, 50, 1);
 
-static struct snd_kcontrol_new phase28_dac_controls[] __devinitdata = {
+static const struct snd_kcontrol_new phase28_dac_controls[] __devinitdata = {
        {
                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
                .name = "Master Playback Switch",
@@ -815,7 +815,7 @@ static struct snd_kcontrol_new phase28_dac_controls[] __devinitdata = {
        }
 };
 
-static struct snd_kcontrol_new wm_controls[] __devinitdata = {
+static const struct snd_kcontrol_new wm_controls[] __devinitdata = {
        {
                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
                .name = "PCM Playback Switch",
@@ -870,7 +870,7 @@ static int __devinit phase28_add_controls(struct snd_ice1712 *ice)
        return 0;
 }
 
-struct snd_ice1712_card_info snd_vt1724_phase_cards[] __devinitdata = {
+const struct snd_ice1712_card_info snd_vt1724_phase_cards[] __devinitdata = {
        {
                .subvendor = VT1724_SUBDEVICE_PHASE22,
                .name = "Terratec PHASE 22",
index 13e841b554887a8c6b8ae9eac8ff3d17c762087c..ad379a99bf92bd67c0a86d278421140801d37382 100644 (file)
@@ -31,7 +31,7 @@
 #define VT1724_SUBDEVICE_PHASE28       0x3b154911
 
 /* entry point */
-extern struct snd_ice1712_card_info snd_vt1724_phase_cards[];
+extern const struct snd_ice1712_card_info snd_vt1724_phase_cards[];
 
 /* PHASE28 GPIO bits */
 #define PHASE28_SPI_MISO       (1 << 21)
index 6c74c2d2e7f3919e39be1c3b3089676fdf8826e0..9552497f0765a6f13a8ebd952f6330feb7af3956 100644 (file)
@@ -434,7 +434,7 @@ static unsigned int spi_read(struct snd_ice1712 *ice, unsigned int dev, unsigned
  */
 static int cs_source_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
 {
-       static char *texts[] = {
+       static const char * const texts[] = {
                "Coax",         /* RXP0 */
                "Optical",      /* RXP1 */
                "CD",           /* RXP2 */
@@ -565,13 +565,13 @@ static int pontis_gpio_data_put(struct snd_kcontrol *kcontrol, struct snd_ctl_el
        return changed;
 }
 
-static DECLARE_TLV_DB_SCALE(db_scale_volume, -6400, 50, 1);
+static const DECLARE_TLV_DB_SCALE(db_scale_volume, -6400, 50, 1);
 
 /*
  * mixers
  */
 
-static struct snd_kcontrol_new pontis_controls[] __devinitdata = {
+static const struct snd_kcontrol_new pontis_controls[] __devinitdata = {
        {
                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
                .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
@@ -741,7 +741,7 @@ static int __devinit pontis_add_controls(struct snd_ice1712 *ice)
  */
 static int __devinit pontis_init(struct snd_ice1712 *ice)
 {
-       static unsigned short wm_inits[] = {
+       static const unsigned short wm_inits[] = {
                /* These come first to reduce init pop noise */
                WM_ADC_MUX,     0x00c0, /* ADC mute */
                WM_DAC_MUTE,    0x0001, /* DAC softmute */
@@ -750,7 +750,7 @@ static int __devinit pontis_init(struct snd_ice1712 *ice)
                WM_POWERDOWN,   0x0008, /* All power-up except HP */
                WM_RESET,       0x0000, /* reset */
        };
-       static unsigned short wm_inits2[] = {
+       static const unsigned short wm_inits2[] = {
                WM_MASTER_CTRL, 0x0022, /* 256fs, slave mode */
                WM_DAC_INT,     0x0022, /* I2S, normal polarity, 24bit */
                WM_ADC_INT,     0x0022, /* I2S, normal polarity, 24bit */
@@ -776,7 +776,7 @@ static int __devinit pontis_init(struct snd_ice1712 *ice)
                WM_DAC_MUTE,    0x0000, /* DAC unmute */
                WM_ADC_MUX,     0x0003, /* ADC unmute, both CD/Line On */
        };
-       static unsigned char cs_inits[] = {
+       static const unsigned char cs_inits[] = {
                0x04,   0x80,   /* RUN, RXP0 */
                0x05,   0x05,   /* slave, 24bit */
                0x01,   0x00,
@@ -826,24 +826,24 @@ static int __devinit pontis_init(struct snd_ice1712 *ice)
  * hence the driver needs to sets up it properly.
  */
 
-static unsigned char pontis_eeprom[] __devinitdata = {
-       0x08,   /* SYSCONF: clock 256, mpu401, spdif-in/ADC, 1DAC */
-       0x80,   /* ACLINK: I2S */
-       0xf8,   /* I2S: vol, 96k, 24bit, 192k */
-       0xc3,   /* SPDIF: out-en, out-int, spdif-in */
-       0x07,   /* GPIO_DIR */
-       0x00,   /* GPIO_DIR1 */
-       0x00,   /* GPIO_DIR2 (ignored) */
-       0x0f,   /* GPIO_MASK (4-7 reserved for CS8416) */
-       0xff,   /* GPIO_MASK1 */
-       0x00,   /* GPIO_MASK2 (ignored) */
-       0x06,   /* GPIO_STATE (0-low, 1-high, 2-high) */
-       0x00,   /* GPIO_STATE1 */
-       0x00,   /* GPIO_STATE2 (ignored) */
+static const unsigned char pontis_eeprom[] __devinitdata = {
+       [ICE_EEP2_SYSCONF]     = 0x08,  /* clock 256, mpu401, spdif-in/ADC, 1DAC */
+       [ICE_EEP2_ACLINK]      = 0x80,  /* I2S */
+       [ICE_EEP2_I2S]         = 0xf8,  /* vol, 96k, 24bit, 192k */
+       [ICE_EEP2_SPDIF]       = 0xc3,  /* out-en, out-int, spdif-in */
+       [ICE_EEP2_GPIO_DIR]    = 0x07,
+       [ICE_EEP2_GPIO_DIR1]   = 0x00,
+       [ICE_EEP2_GPIO_DIR2]   = 0x00,  /* ignored */
+       [ICE_EEP2_GPIO_MASK]   = 0x0f,  /* 4-7 reserved for CS8416 */
+       [ICE_EEP2_GPIO_MASK1]  = 0xff,
+       [ICE_EEP2_GPIO_MASK2]  = 0x00,  /* ignored */
+       [ICE_EEP2_GPIO_STATE]  = 0x06,  /* 0-low, 1-high, 2-high */
+       [ICE_EEP2_GPIO_STATE1] = 0x00,
+       [ICE_EEP2_GPIO_STATE2] = 0x00,  /* ignored */
 };
 
 /* entry point */
-struct snd_ice1712_card_info snd_vt1720_pontis_cards[] __devinitdata = {
+const struct snd_ice1712_card_info snd_vt1720_pontis_cards[] __devinitdata = {
        {
                .subvendor = VT1720_SUBDEVICE_PONTIS_MS300,
                .name = "Pontis MS300",
index d0d1378b935c5d2691ad8700a22f29f8145e84c5..1a418255c19ea82eeadd7f7d4cb09af274d452f5 100644 (file)
@@ -28,6 +28,6 @@
 
 #define VT1720_SUBDEVICE_PONTIS_MS300  0x00020002      /* a dummy id for MS300 */
 
-extern struct snd_ice1712_card_info  snd_vt1720_pontis_cards[];
+extern const struct snd_ice1712_card_info  snd_vt1720_pontis_cards[];
 
 #endif /* __SOUND_PONTIS_H */
index 41b2605daa3ae128ed15bec566849dac13e77852..31cc66eb9f8fa9ccd6bc9bad39794ac329dd1686 100644 (file)
@@ -357,14 +357,14 @@ static int aureon_oversampling_put(struct snd_kcontrol *kcontrol, struct snd_ctl
 }
 #endif
 
-static DECLARE_TLV_DB_SCALE(db_scale_dac, -19125, 75, 0);
-static DECLARE_TLV_DB_SCALE(db_scale_adc, 0, 150, 0);
+static const DECLARE_TLV_DB_SCALE(db_scale_dac, -19125, 75, 0);
+static const DECLARE_TLV_DB_SCALE(db_scale_adc, 0, 150, 0);
 
 /*
  * mixers
  */
 
-static struct snd_kcontrol_new stac_controls[] __devinitdata = {
+static const struct snd_kcontrol_new stac_controls[] __devinitdata = {
        {
                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
                .name = "Master Playback Switch",
@@ -475,7 +475,7 @@ static int __devinit prodigy192_add_controls(struct snd_ice1712 *ice)
  */
 static int __devinit prodigy192_init(struct snd_ice1712 *ice)
 {
-       static unsigned short stac_inits_prodigy[] = {
+       static const unsigned short stac_inits_prodigy[] = {
                STAC946X_RESET, 0,
 /*             STAC946X_MASTER_VOLUME, 0,
                STAC946X_LF_VOLUME, 0,
@@ -486,7 +486,7 @@ static int __devinit prodigy192_init(struct snd_ice1712 *ice)
                STAC946X_LFE_VOLUME, 0,*/
                (unsigned short)-1
        };
-       unsigned short *p;
+       const unsigned short *p;
 
        /* prodigy 192 */
        ice->num_total_dacs = 6;
@@ -506,25 +506,25 @@ static int __devinit prodigy192_init(struct snd_ice1712 *ice)
  * hence the driver needs to sets up it properly.
  */
 
-static unsigned char prodigy71_eeprom[] __devinitdata = {
-       0x2b,   /* SYSCONF: clock 512, mpu401, spdif-in/ADC, 4DACs */
-       0x80,   /* ACLINK: I2S */
-       0xf8,   /* I2S: vol, 96k, 24bit, 192k */
-       0xc3,   /* SPDIF: out-en, out-int, spdif-in */
-       0xff,   /* GPIO_DIR */
-       0xff,   /* GPIO_DIR1 */
-       0xbf,   /* GPIO_DIR2 */
-       0x00,   /* GPIO_MASK */
-       0x00,   /* GPIO_MASK1 */
-       0x00,   /* GPIO_MASK2 */
-       0x00,   /* GPIO_STATE */
-       0x00,   /* GPIO_STATE1 */
-       0x00,   /* GPIO_STATE2 */
+static const unsigned char prodigy71_eeprom[] __devinitdata = {
+       [ICE_EEP2_SYSCONF]     = 0x2b,  /* clock 512, mpu401, spdif-in/ADC, 4DACs */
+       [ICE_EEP2_ACLINK]      = 0x80,  /* I2S */
+       [ICE_EEP2_I2S]         = 0xf8,  /* vol, 96k, 24bit, 192k */
+       [ICE_EEP2_SPDIF]       = 0xc3,  /* out-en, out-int, spdif-in */
+       [ICE_EEP2_GPIO_DIR]    = 0xff,
+       [ICE_EEP2_GPIO_DIR1]   = 0xff,
+       [ICE_EEP2_GPIO_DIR2]   = 0xbf,
+       [ICE_EEP2_GPIO_MASK]   = 0x00,
+       [ICE_EEP2_GPIO_MASK1]  = 0x00,
+       [ICE_EEP2_GPIO_MASK2]  = 0x00,
+       [ICE_EEP2_GPIO_STATE]  = 0x00,
+       [ICE_EEP2_GPIO_STATE1] = 0x00,
+       [ICE_EEP2_GPIO_STATE2] = 0x00,
 };
 
 
 /* entry point */
-struct snd_ice1712_card_info snd_vt1724_prodigy192_cards[] __devinitdata = {
+const struct snd_ice1712_card_info snd_vt1724_prodigy192_cards[] __devinitdata = {
        {
                .subvendor = VT1724_SUBDEVICE_PRODIGY192VE,
                .name = "Audiotrak Prodigy 192",
index 94c824e24e0650887b78dad4d503aa463aee1dfe..2fa2e62b9e047cea85254f97519aee75c4f5c105 100644 (file)
@@ -6,6 +6,6 @@
 
 #define VT1724_SUBDEVICE_PRODIGY192VE   0x34495345     /* PRODIGY 192 VE */
 
-extern struct snd_ice1712_card_info  snd_vt1724_prodigy192_cards[];
+extern const struct snd_ice1712_card_info  snd_vt1724_prodigy192_cards[];
 
 #endif /* __SOUND_PRODIGY192_H */
index bf98ea34feb04b1a65992db370fadd79dc25105f..025a7e8497c30cbb44a847a722a04bd264a33213 100644 (file)
@@ -83,39 +83,143 @@ static void revo_set_rate_val(struct snd_akm4xxx *ak, unsigned int rate)
        snd_akm4xxx_reset(ak, 0);
 }
 
+/*
+ * I2C access to the PT2258 volume controller on GPIO 6/7 (Revolution 5.1)
+ */
+
+static void revo_i2c_start(struct snd_i2c_bus *bus)
+{
+       struct snd_ice1712 *ice = bus->private_data;
+       snd_ice1712_save_gpio_status(ice);
+}
+
+static void revo_i2c_stop(struct snd_i2c_bus *bus)
+{
+       struct snd_ice1712 *ice = bus->private_data;
+       snd_ice1712_restore_gpio_status(ice);
+}
+
+static void revo_i2c_direction(struct snd_i2c_bus *bus, int clock, int data)
+{
+       struct snd_ice1712 *ice = bus->private_data;
+       unsigned int mask, val;
+
+       val = 0;
+       if (clock)
+               val |= VT1724_REVO_I2C_CLOCK;   /* write SCL */
+       if (data)
+               val |= VT1724_REVO_I2C_DATA;    /* write SDA */
+       mask = VT1724_REVO_I2C_CLOCK | VT1724_REVO_I2C_DATA;
+       ice->gpio.direction &= ~mask;
+       ice->gpio.direction |= val;
+       snd_ice1712_gpio_set_dir(ice, ice->gpio.direction);
+       snd_ice1712_gpio_set_mask(ice, ~mask);
+}
+
+static void revo_i2c_setlines(struct snd_i2c_bus *bus, int clk, int data)
+{
+       struct snd_ice1712 *ice = bus->private_data;
+       unsigned int val = 0;
+
+       if (clk)
+               val |= VT1724_REVO_I2C_CLOCK;
+       if (data)
+               val |= VT1724_REVO_I2C_DATA;
+       snd_ice1712_gpio_write_bits(ice,
+                                   VT1724_REVO_I2C_DATA |
+                                   VT1724_REVO_I2C_CLOCK, val);
+       udelay(5);
+}
+
+static int revo_i2c_getdata(struct snd_i2c_bus *bus, int ack)
+{
+       struct snd_ice1712 *ice = bus->private_data;
+       int bit;
+
+       if (ack)
+               udelay(5);
+       bit = snd_ice1712_gpio_read_bits(ice, VT1724_REVO_I2C_DATA) ? 1 : 0;
+       return bit;
+}
+
+static struct snd_i2c_bit_ops revo51_bit_ops = {
+       .start = revo_i2c_start,
+       .stop = revo_i2c_stop,
+       .direction = revo_i2c_direction,
+       .setlines = revo_i2c_setlines,
+       .getdata = revo_i2c_getdata,
+};
+
+static int revo51_i2c_init(struct snd_ice1712 *ice,
+                          struct snd_pt2258 *pt)
+{
+       int err;
+
+       /* create the I2C bus */
+       err = snd_i2c_bus_create(ice->card, "ICE1724 GPIO6", NULL, &ice->i2c);
+       if (err < 0)
+               return err;
+
+       ice->i2c->private_data = ice;
+       ice->i2c->hw_ops.bit = &revo51_bit_ops;
+
+       /* create the I2C device */
+       err = snd_i2c_device_create(ice->i2c, "PT2258", 0x40,
+                                   &ice->spec.revo51.dev);
+       if (err < 0)
+               return err;
+
+       pt->card = ice->card;
+       pt->i2c_bus = ice->i2c;
+       pt->i2c_dev = ice->spec.revo51.dev;
+       ice->spec.revo51.pt2258 = pt;
+
+       snd_pt2258_reset(pt);
+
+       return 0;
+}
+
 /*
  * initialize the chips on M-Audio Revolution cards
  */
 
 #define AK_DAC(xname,xch) { .name = xname, .num_channels = xch }
 
-static struct snd_akm4xxx_dac_channel revo71_front[] = {
+static const struct snd_akm4xxx_dac_channel revo71_front[] = {
        AK_DAC("PCM Playback Volume", 2)
 };
 
-static struct snd_akm4xxx_dac_channel revo71_surround[] = {
+static const struct snd_akm4xxx_dac_channel revo71_surround[] = {
        AK_DAC("PCM Center Playback Volume", 1),
        AK_DAC("PCM LFE Playback Volume", 1),
        AK_DAC("PCM Side Playback Volume", 2),
        AK_DAC("PCM Rear Playback Volume", 2),
 };
 
-static struct snd_akm4xxx_dac_channel revo51_dac[] = {
+static const struct snd_akm4xxx_dac_channel revo51_dac[] = {
        AK_DAC("PCM Playback Volume", 2),
        AK_DAC("PCM Center Playback Volume", 1),
        AK_DAC("PCM LFE Playback Volume", 1),
        AK_DAC("PCM Rear Playback Volume", 2),
 };
 
-static struct snd_akm4xxx_adc_channel revo51_adc[] = {
+static const char *revo51_adc_input_names[] = {
+       "Mic",
+       "Line",
+       "CD",
+       NULL
+};
+
+static const struct snd_akm4xxx_adc_channel revo51_adc[] = {
        {
                .name = "PCM Capture Volume",
                .switch_name = "PCM Capture Switch",
-               .num_channels = 2
+               .num_channels = 2,
+               .input_names = revo51_adc_input_names
        },
 };
 
-static struct snd_akm4xxx akm_revo_front __devinitdata = {
+static const struct snd_akm4xxx akm_revo_front __devinitdata = {
        .type = SND_AK4381,
        .num_dacs = 2,
        .ops = {
@@ -124,7 +228,7 @@ static struct snd_akm4xxx akm_revo_front __devinitdata = {
        .dac_info = revo71_front,
 };
 
-static struct snd_ak4xxx_private akm_revo_front_priv __devinitdata = {
+static const struct snd_ak4xxx_private akm_revo_front_priv __devinitdata = {
        .caddr = 1,
        .cif = 0,
        .data_mask = VT1724_REVO_CDOUT,
@@ -136,7 +240,7 @@ static struct snd_ak4xxx_private akm_revo_front_priv __devinitdata = {
        .mask_flags = 0,
 };
 
-static struct snd_akm4xxx akm_revo_surround __devinitdata = {
+static const struct snd_akm4xxx akm_revo_surround __devinitdata = {
        .type = SND_AK4355,
        .idx_offset = 1,
        .num_dacs = 6,
@@ -146,7 +250,7 @@ static struct snd_akm4xxx akm_revo_surround __devinitdata = {
        .dac_info = revo71_surround,
 };
 
-static struct snd_ak4xxx_private akm_revo_surround_priv __devinitdata = {
+static const struct snd_ak4xxx_private akm_revo_surround_priv __devinitdata = {
        .caddr = 3,
        .cif = 0,
        .data_mask = VT1724_REVO_CDOUT,
@@ -158,7 +262,7 @@ static struct snd_ak4xxx_private akm_revo_surround_priv __devinitdata = {
        .mask_flags = 0,
 };
 
-static struct snd_akm4xxx akm_revo51 __devinitdata = {
+static const struct snd_akm4xxx akm_revo51 __devinitdata = {
        .type = SND_AK4358,
        .num_dacs = 6,
        .ops = {
@@ -167,36 +271,213 @@ static struct snd_akm4xxx akm_revo51 __devinitdata = {
        .dac_info = revo51_dac,
 };
 
-static struct snd_ak4xxx_private akm_revo51_priv __devinitdata = {
+static const struct snd_ak4xxx_private akm_revo51_priv __devinitdata = {
        .caddr = 2,
        .cif = 0,
        .data_mask = VT1724_REVO_CDOUT,
        .clk_mask = VT1724_REVO_CCLK,
-       .cs_mask = VT1724_REVO_CS0 | VT1724_REVO_CS1 | VT1724_REVO_CS2,
-       .cs_addr = VT1724_REVO_CS1 | VT1724_REVO_CS2,
-       .cs_none = VT1724_REVO_CS0 | VT1724_REVO_CS1 | VT1724_REVO_CS2,
+       .cs_mask = VT1724_REVO_CS0 | VT1724_REVO_CS1,
+       .cs_addr = VT1724_REVO_CS1,
+       .cs_none = VT1724_REVO_CS0 | VT1724_REVO_CS1,
        .add_flags = VT1724_REVO_CCLK, /* high at init */
        .mask_flags = 0,
 };
 
-static struct snd_akm4xxx akm_revo51_adc __devinitdata = {
+static const struct snd_akm4xxx akm_revo51_adc __devinitdata = {
        .type = SND_AK5365,
        .num_adcs = 2,
        .adc_info = revo51_adc,
 };
 
-static struct snd_ak4xxx_private akm_revo51_adc_priv __devinitdata = {
+static const struct snd_ak4xxx_private akm_revo51_adc_priv __devinitdata = {
        .caddr = 2,
        .cif = 0,
        .data_mask = VT1724_REVO_CDOUT,
        .clk_mask = VT1724_REVO_CCLK,
-       .cs_mask = VT1724_REVO_CS0 | VT1724_REVO_CS1 | VT1724_REVO_CS2,
-       .cs_addr = VT1724_REVO_CS0 | VT1724_REVO_CS2,
-       .cs_none = VT1724_REVO_CS0 | VT1724_REVO_CS1 | VT1724_REVO_CS2,
+       .cs_mask = VT1724_REVO_CS0 | VT1724_REVO_CS1,
+       .cs_addr = VT1724_REVO_CS0,
+       .cs_none = VT1724_REVO_CS0 | VT1724_REVO_CS1,
+       .add_flags = VT1724_REVO_CCLK, /* high at init */
+       .mask_flags = 0,
+};
+
+static struct snd_pt2258 ptc_revo51_volume;
+
+/* AK4358 for AP192 DAC, AK5385A for ADC */
+static void ap192_set_rate_val(struct snd_akm4xxx *ak, unsigned int rate)
+{
+       struct snd_ice1712 *ice = ak->private_data[0];
+
+       revo_set_rate_val(ak, rate);
+
+#if 1 /* FIXME: do we need this procedure? */
+       /* reset DFS pin of AK5385A for ADC, too */
+       /* DFS0 (pin 18) -- GPIO10 pin 77 */
+       snd_ice1712_save_gpio_status(ice);
+       snd_ice1712_gpio_write_bits(ice, 1 << 10,
+                                   rate > 48000 ? (1 << 10) : 0);
+       snd_ice1712_restore_gpio_status(ice);
+#endif
+}
+
+static const struct snd_akm4xxx_dac_channel ap192_dac[] = {
+       AK_DAC("PCM Playback Volume", 2)
+};
+
+static const struct snd_akm4xxx akm_ap192 __devinitdata = {
+       .type = SND_AK4358,
+       .num_dacs = 2,
+       .ops = {
+               .set_rate_val = ap192_set_rate_val
+       },
+       .dac_info = ap192_dac,
+};
+
+static const struct snd_ak4xxx_private akm_ap192_priv __devinitdata = {
+       .caddr = 2,
+       .cif = 0,
+       .data_mask = VT1724_REVO_CDOUT,
+       .clk_mask = VT1724_REVO_CCLK,
+       .cs_mask = VT1724_REVO_CS0 | VT1724_REVO_CS3,
+       .cs_addr = VT1724_REVO_CS3,
+       .cs_none = VT1724_REVO_CS0 | VT1724_REVO_CS3,
        .add_flags = VT1724_REVO_CCLK, /* high at init */
        .mask_flags = 0,
 };
 
+#if 0
+/* FIXME: ak4114 makes the sound much lower due to some confliction,
+ *        so let's disable it right now...
+ */
+#define BUILD_AK4114_AP192
+#endif
+
+#ifdef BUILD_AK4114_AP192
+/* AK4114 support on Audiophile 192 */
+/* CDTO (pin 32) -- GPIO2 pin 52
+ * CDTI (pin 33) -- GPIO3 pin 53 (shared with AK4358)
+ * CCLK (pin 34) -- GPIO1 pin 51 (shared with AK4358)
+ * CSN  (pin 35) -- GPIO7 pin 59
+ */
+#define AK4114_ADDR    0x00
+
+static void write_data(struct snd_ice1712 *ice, unsigned int gpio,
+                      unsigned int data, int idx)
+{
+       for (; idx >= 0; idx--) {
+               /* drop clock */
+               gpio &= ~VT1724_REVO_CCLK;
+               snd_ice1712_gpio_write(ice, gpio);
+               udelay(1);
+               /* set data */
+               if (data & (1 << idx))
+                       gpio |= VT1724_REVO_CDOUT;
+               else
+                       gpio &= ~VT1724_REVO_CDOUT;
+               snd_ice1712_gpio_write(ice, gpio);
+               udelay(1);
+               /* raise clock */
+               gpio |= VT1724_REVO_CCLK;
+               snd_ice1712_gpio_write(ice, gpio);
+               udelay(1);
+       }
+}
+
+static unsigned char read_data(struct snd_ice1712 *ice, unsigned int gpio,
+                              int idx)
+{
+       unsigned char data = 0;
+
+       for (; idx >= 0; idx--) {
+               /* drop clock */
+               gpio &= ~VT1724_REVO_CCLK;
+               snd_ice1712_gpio_write(ice, gpio);
+               udelay(1);
+               /* read data */
+               if (snd_ice1712_gpio_read(ice) & VT1724_REVO_CDIN)
+                       data |= (1 << idx);
+               udelay(1);
+               /* raise clock */
+               gpio |= VT1724_REVO_CCLK;
+               snd_ice1712_gpio_write(ice, gpio);
+               udelay(1);
+       }
+       return data;
+}
+
+static unsigned char ap192_4wire_start(struct snd_ice1712 *ice)
+{
+       unsigned int tmp;
+
+       snd_ice1712_save_gpio_status(ice);
+       tmp = snd_ice1712_gpio_read(ice);
+       tmp |= VT1724_REVO_CCLK; /* high at init */
+       tmp |= VT1724_REVO_CS0;
+       tmp &= ~VT1724_REVO_CS3;
+       snd_ice1712_gpio_write(ice, tmp);
+       udelay(1);
+       return tmp;
+}
+
+static void ap192_4wire_finish(struct snd_ice1712 *ice, unsigned int tmp)
+{
+       tmp |= VT1724_REVO_CS3;
+       tmp |= VT1724_REVO_CS0;
+       snd_ice1712_gpio_write(ice, tmp);
+       udelay(1);
+       snd_ice1712_restore_gpio_status(ice);
+}
+
+static void ap192_ak4114_write(void *private_data, unsigned char addr,
+                              unsigned char data)
+{
+       struct snd_ice1712 *ice = private_data;
+       unsigned int tmp, addrdata;
+
+       tmp = ap192_4wire_start(ice);
+       addrdata = (AK4114_ADDR << 6) | 0x20 | (addr & 0x1f);
+       addrdata = (addrdata << 8) | data;
+       write_data(ice, tmp, addrdata, 15);
+       ap192_4wire_finish(ice, tmp);
+}
+
+static unsigned char ap192_ak4114_read(void *private_data, unsigned char addr)
+{
+       struct snd_ice1712 *ice = private_data;
+       unsigned int tmp;
+       unsigned char data;
+
+       tmp = ap192_4wire_start(ice);
+       write_data(ice, tmp, (AK4114_ADDR << 6) | (addr & 0x1f), 7);
+       data = read_data(ice, tmp, 7);
+       ap192_4wire_finish(ice, tmp);
+       return data;
+}
+
+static int ap192_ak4114_init(struct snd_ice1712 *ice)
+{
+       static const unsigned char ak4114_init_vals[] = {
+               AK4114_RST | AK4114_PWN | AK4114_OCKS0 | AK4114_OCKS1,
+               AK4114_DIF_I24I2S,
+               AK4114_TX1E,
+               AK4114_EFH_1024 | AK4114_DIT | AK4114_IPS(1),
+               0,
+               0
+       };
+       static const unsigned char ak4114_init_txcsb[] = {
+               0x41, 0x02, 0x2c, 0x00, 0x00
+       };
+       struct ak4114 *ak;
+       int err;
+
+       return snd_ak4114_create(ice->card,
+                                ap192_ak4114_read,
+                                ap192_ak4114_write,
+                                ak4114_init_vals, ak4114_init_txcsb,
+                                ice, &ak);
+}
+#endif /* BUILD_AK4114_AP192 */
+
 static int __devinit revo_init(struct snd_ice1712 *ice)
 {
        struct snd_akm4xxx *ak;
@@ -213,6 +494,10 @@ static int __devinit revo_init(struct snd_ice1712 *ice)
                ice->num_total_dacs = 6;
                ice->num_total_adcs = 2;
                break;
+       case VT1724_SUBDEVICE_AUDIOPHILE192:
+               ice->num_total_dacs = 2;
+               ice->num_total_adcs = 2;
+               break;
        default:
                snd_BUG();
                return -EINVAL;
@@ -235,14 +520,28 @@ static int __devinit revo_init(struct snd_ice1712 *ice)
                break;
        case VT1724_SUBDEVICE_REVOLUTION51:
                ice->akm_codecs = 2;
-               if ((err = snd_ice1712_akm4xxx_init(ak, &akm_revo51, &akm_revo51_priv, ice)) < 0)
+               err = snd_ice1712_akm4xxx_init(ak, &akm_revo51,
+                                              &akm_revo51_priv, ice);
+               if (err < 0)
                        return err;
-               err = snd_ice1712_akm4xxx_init(ak + 1, &akm_revo51_adc,
+               err = snd_ice1712_akm4xxx_init(ak+1, &akm_revo51_adc,
                                               &akm_revo51_adc_priv, ice);
                if (err < 0)
                        return err;
-               /* unmute all codecs - needed! */
-               snd_ice1712_gpio_write_bits(ice, VT1724_REVO_MUTE, VT1724_REVO_MUTE);
+               err = revo51_i2c_init(ice, &ptc_revo51_volume);
+               if (err < 0)
+                       return err;
+               /* unmute all codecs */
+               snd_ice1712_gpio_write_bits(ice, VT1724_REVO_MUTE,
+                                           VT1724_REVO_MUTE);
+               break;
+       case VT1724_SUBDEVICE_AUDIOPHILE192:
+               ice->akm_codecs = 1;
+               err = snd_ice1712_akm4xxx_init(ak, &akm_ap192, &akm_ap192_priv,
+                                              ice);
+               if (err < 0)
+                       return err;
+               
                break;
        }
 
@@ -256,16 +555,34 @@ static int __devinit revo_add_controls(struct snd_ice1712 *ice)
 
        switch (ice->eeprom.subvendor) {
        case VT1724_SUBDEVICE_REVOLUTION71:
+               err = snd_ice1712_akm4xxx_build_controls(ice);
+               if (err < 0)
+                       return err;
+               break;
        case VT1724_SUBDEVICE_REVOLUTION51:
                err = snd_ice1712_akm4xxx_build_controls(ice);
                if (err < 0)
                        return err;
+               err = snd_pt2258_build_controls(ice->spec.revo51.pt2258);
+               if (err < 0)
+                       return err;
+               break;
+       case VT1724_SUBDEVICE_AUDIOPHILE192:
+               err = snd_ice1712_akm4xxx_build_controls(ice);
+               if (err < 0)
+                       return err;
+#ifdef BUILD_AK4114_AP192
+               err = ap192_ak4114_init(ice);
+               if (err < 0)
+                       return err;
+#endif
+               break;
        }
        return 0;
 }
 
 /* entry point */
-struct snd_ice1712_card_info snd_vt1724_revo_cards[] __devinitdata = {
+const struct snd_ice1712_card_info snd_vt1724_revo_cards[] __devinitdata = {
        {
                .subvendor = VT1724_SUBDEVICE_REVOLUTION71,
                .name = "M Audio Revolution-7.1",
@@ -280,5 +597,12 @@ struct snd_ice1712_card_info snd_vt1724_revo_cards[] __devinitdata = {
                .chip_init = revo_init,
                .build_controls = revo_add_controls,
        },
+       {
+               .subvendor = VT1724_SUBDEVICE_AUDIOPHILE192,
+               .name = "M Audio Audiophile192",
+               .model = "ap192",
+               .chip_init = revo_init,
+               .build_controls = revo_add_controls,
+       },
        { } /* terminator */
 };
index efbb86ec3289ed0286549316635ecd9cc79b225b..2a24488fad805653d99195d352d3b48442d03dd8 100644 (file)
 
 #define REVO_DEVICE_DESC \
                "{MidiMan M Audio,Revolution 7.1},"\
-               "{MidiMan M Audio,Revolution 5.1},"
+               "{MidiMan M Audio,Revolution 5.1},"\
+               "{MidiMan M Audio,Audiophile 192},"
 
 #define VT1724_SUBDEVICE_REVOLUTION71  0x12143036
 #define VT1724_SUBDEVICE_REVOLUTION51  0x12143136
+#define VT1724_SUBDEVICE_AUDIOPHILE192 0x12143236
 
 /* entry point */
-extern struct snd_ice1712_card_info snd_vt1724_revo_cards[];
+extern const struct snd_ice1712_card_info snd_vt1724_revo_cards[];
 
 
 /*
@@ -42,9 +44,12 @@ extern struct snd_ice1712_card_info snd_vt1724_revo_cards[];
 #define VT1724_REVO_CCLK       0x02
 #define VT1724_REVO_CDIN       0x04    /* not used */
 #define VT1724_REVO_CDOUT      0x08
-#define VT1724_REVO_CS0                0x10    /* AK5365 chipselect for Rev. 5.1 */
+#define VT1724_REVO_CS0                0x10    /* AK5365 chipselect for (revo51) */
 #define VT1724_REVO_CS1                0x20    /* front AKM4381 chipselect */
-#define VT1724_REVO_CS2                0x40    /* surround AKM4355 chipselect */
+#define VT1724_REVO_CS2                0x40    /* surround AKM4355 CS (revo71) */
+#define VT1724_REVO_I2C_DATA    0x40    /* I2C: PT 2258 SDA (on revo51) */
+#define VT1724_REVO_I2C_CLOCK   0x80    /* I2C: PT 2258 SCL (on revo51) */
+#define VT1724_REVO_CS3                0x80    /* AK4114 for AP192 */
 #define VT1724_REVO_MUTE       (1<<22) /* 0 = all mute, 1 = normal operation */
 
 #endif /* __SOUND_REVO_H */
index 7ca263c1309156aaaed3fe4d827b2484b270ee83..72b060d63c29cc83307f468bd85335d128f809d5 100644 (file)
@@ -30,6 +30,7 @@
 #include <sound/core.h>
 
 #include "ice1712.h"
+#include "envy24ht.h"
 #include "vt1720_mobo.h"
 
 
@@ -55,41 +56,41 @@ static int __devinit k8x800_add_controls(struct snd_ice1712 *ice)
 
 /* EEPROM image */
 
-static unsigned char k8x800_eeprom[] __devinitdata = {
-       0x01,   /* SYSCONF: clock 256, 1ADC, 2DACs */
-       0x02,   /* ACLINK: ACLINK, packed */
-       0x00,   /* I2S: - */
-       0x00,   /* SPDIF: - */
-       0xff,   /* GPIO_DIR */
-       0xff,   /* GPIO_DIR1 */
-       0x00,   /* - */
-       0xff,   /* GPIO_MASK */
-       0xff,   /* GPIO_MASK1 */
-       0x00,   /* - */
-       0x00,   /* GPIO_STATE */
-       0x00,   /* GPIO_STATE1 */
-       0x00,   /* - */
+static const unsigned char k8x800_eeprom[] __devinitdata = {
+       [ICE_EEP2_SYSCONF]     = 0x01,  /* clock 256, 1ADC, 2DACs */
+       [ICE_EEP2_ACLINK]      = 0x02,  /* ACLINK, packed */
+       [ICE_EEP2_I2S]         = 0x00,  /* - */
+       [ICE_EEP2_SPDIF]       = 0x00,  /* - */
+       [ICE_EEP2_GPIO_DIR]    = 0xff,
+       [ICE_EEP2_GPIO_DIR1]   = 0xff,
+       [ICE_EEP2_GPIO_DIR2]   = 0x00,  /* - */
+       [ICE_EEP2_GPIO_MASK]   = 0xff,
+       [ICE_EEP2_GPIO_MASK1]  = 0xff,
+       [ICE_EEP2_GPIO_MASK2]  = 0x00,  /* - */
+       [ICE_EEP2_GPIO_STATE]  = 0x00,
+       [ICE_EEP2_GPIO_STATE1] = 0x00,
+       [ICE_EEP2_GPIO_STATE2] = 0x00,  /* - */
 };
 
-static unsigned char sn25p_eeprom[] __devinitdata = {
-       0x01,   /* SYSCONF: clock 256, 1ADC, 2DACs */
-       0x02,   /* ACLINK: ACLINK, packed */
-       0x00,   /* I2S: - */
-       0x41,   /* SPDIF: - */
-       0xff,   /* GPIO_DIR */
-       0xff,   /* GPIO_DIR1 */
-       0x00,   /* - */
-       0xff,   /* GPIO_MASK */
-       0xff,   /* GPIO_MASK1 */
-       0x00,   /* - */
-       0x00,   /* GPIO_STATE */
-       0x00,   /* GPIO_STATE1 */
-       0x00,   /* - */
+static const unsigned char sn25p_eeprom[] __devinitdata = {
+       [ICE_EEP2_SYSCONF]     = 0x01,  /* clock 256, 1ADC, 2DACs */
+       [ICE_EEP2_ACLINK]      = 0x02,  /* ACLINK, packed */
+       [ICE_EEP2_I2S]         = 0x00,  /* - */
+       [ICE_EEP2_SPDIF]       = 0x41,  /* - */
+       [ICE_EEP2_GPIO_DIR]    = 0xff,
+       [ICE_EEP2_GPIO_DIR1]   = 0xff,
+       [ICE_EEP2_GPIO_DIR2]   = 0x00,  /* - */
+       [ICE_EEP2_GPIO_MASK]   = 0xff,
+       [ICE_EEP2_GPIO_MASK1]  = 0xff,
+       [ICE_EEP2_GPIO_MASK2]  = 0x00,  /* - */
+       [ICE_EEP2_GPIO_STATE]  = 0x00,
+       [ICE_EEP2_GPIO_STATE1] = 0x00,
+       [ICE_EEP2_GPIO_STATE2] = 0x00,  /* - */
 };
 
 
 /* entry point */
-struct snd_ice1712_card_info snd_vt1720_mobo_cards[] __devinitdata = {
+const struct snd_ice1712_card_info snd_vt1720_mobo_cards[] __devinitdata = {
        {
                .subvendor = VT1720_SUBDEVICE_K8X800,
                .name = "Albatron K8X800 Pro II",
index 0b1b0ee1bea7aba566eec6206793009a44dd718c..70af3ad64a5d3d36b5577cc2fd0ca4a2240ff6e8 100644 (file)
@@ -36,6 +36,6 @@
 #define VT1720_SUBDEVICE_9CJS          0x0f272327
 #define VT1720_SUBDEVICE_SN25P         0x97123650
 
-extern struct snd_ice1712_card_info  snd_vt1720_mobo_cards[];
+extern const struct snd_ice1712_card_info  snd_vt1720_mobo_cards[];
 
 #endif /* __SOUND_VT1720_MOBO_H */
diff --git a/sound/pci/ice1712/wtm.c b/sound/pci/ice1712/wtm.c
new file mode 100644 (file)
index 0000000..4a706b1
--- /dev/null
@@ -0,0 +1,542 @@
+/*
+ *     ALSA driver for ICEnsemble VT1724 (Envy24HT)
+ *     
+ *     Lowlevel functions for Ego Sys Waveterminal 192M
+ *
+ *             Copyright (c) 2006 Guedez Clement <klem.dev@gmail.com>
+ *             Some functions are taken from the Prodigy192 driver
+ *             source
+ *             
+ *     This program is free software; you can redistribute it and/or modify
+ *     it under the terms of the GNU General Public License as published by
+ *     the Free Software Foundation; either version 2 of the License, or
+ *     (at your option) any later version.
+ *
+ *     This program is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *     GNU General Public License for more details.
+ *
+ *     You should have received a copy of the GNU General Public License
+ *     along with this program; if not, write to the Free Software
+ *     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *     
+ */    
+
+
+
+#include <sound/driver.h>
+#include <asm/io.h>
+#include <linux/delay.h>
+#include <linux/interrupt.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <sound/core.h>
+
+#include "ice1712.h"
+#include "envy24ht.h"
+#include "wtm.h"
+#include "stac946x.h"
+
+
+/*
+ *     2*ADC 6*DAC no1 ringbuffer r/w on i2c bus 
+ */
+static inline void stac9460_put(struct snd_ice1712 *ice, int reg, 
+                                               unsigned char val)
+{
+       snd_vt1724_write_i2c(ice, STAC9460_I2C_ADDR, reg, val);
+}
+
+static inline unsigned char stac9460_get(struct snd_ice1712 *ice, int reg)
+{
+       return snd_vt1724_read_i2c(ice, STAC9460_I2C_ADDR, reg);
+}
+
+/*
+ *     2*ADC 2*DAC no2 ringbuffer r/w on i2c bus
+ */
+static inline void stac9460_2_put(struct snd_ice1712 *ice, int reg,
+                                               unsigned char val)
+{
+       snd_vt1724_write_i2c(ice, STAC9460_2_I2C_ADDR, reg, val);
+}
+
+static inline unsigned char stac9460_2_get(struct snd_ice1712 *ice, int reg)
+{
+       return snd_vt1724_read_i2c(ice, STAC9460_2_I2C_ADDR, reg);
+}
+
+
+/*
+ *     DAC mute control
+ */
+static int stac9460_dac_mute_info(struct snd_kcontrol *kcontrol,
+                               struct snd_ctl_elem_info *uinfo)
+{
+       uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
+       uinfo->count = 1;
+       uinfo->value.integer.min = 0;
+       return 0;
+}
+
+static int stac9460_dac_mute_get(struct snd_kcontrol *kcontrol,
+                               struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
+       unsigned char val;
+       int idx, id;
+
+       if (kcontrol->private_value) {
+               idx = STAC946X_MASTER_VOLUME;
+               id = 0;
+       } else {
+               id = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
+               idx = id + STAC946X_LF_VOLUME;
+       }
+       if (id < 6)
+               val = stac9460_get(ice, idx);
+       else 
+               val = stac9460_2_get(ice,idx - 6);
+       ucontrol->value.integer.value[0] = (~val >> 7) & 0x1;
+       return 0;
+}
+
+static int stac9460_dac_mute_put(struct snd_kcontrol *kcontrol,
+                               struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
+       unsigned char new, old;
+       int id, idx;
+       int change;
+
+       if (kcontrol->private_value) {
+               idx = STAC946X_MASTER_VOLUME;
+               old = stac9460_get(ice, idx);
+               new = (~ucontrol->value.integer.value[0]<< 7 & 0x80) |
+                                                       (old & ~0x80);
+               change = (new != old);
+               if (change) {
+                       stac9460_put(ice, idx, new);
+                       stac9460_2_put(ice, idx, new);
+               }
+       } else {
+               id = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
+               idx = id + STAC946X_LF_VOLUME;
+               if (id < 6)
+                       old = stac9460_get(ice, idx);
+               else 
+                       old = stac9460_2_get(ice, idx - 6);
+               new = (~ucontrol->value.integer.value[0]<< 7 & 0x80) |
+                                                       (old & ~0x80);
+               change = (new != old);
+               if (change) {
+                       if (id < 6)
+                               stac9460_put(ice, idx, new);
+                       else
+                               stac9460_2_put(ice, idx - 6, new);
+               }
+       }
+       return change;
+}
+
+/*
+ *     DAC volume attenuation mixer control
+ */
+static int stac9460_dac_vol_info(struct snd_kcontrol *kcontrol,
+                               struct snd_ctl_elem_info *uinfo)
+{
+       uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
+       uinfo->count = 1;
+       uinfo->value.integer.min = 0;                   /* mute */
+       uinfo->value.integer.max = 0x7f;                /* 0dB */
+       return 0;
+}
+
+static int stac9460_dac_vol_get(struct snd_kcontrol *kcontrol,
+                               struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
+       int idx, id;
+       unsigned char vol;
+
+       if (kcontrol->private_value) {
+               idx = STAC946X_MASTER_VOLUME;
+               id = 0;
+       } else {
+               id = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
+               idx = id + STAC946X_LF_VOLUME;
+       }
+       if (id < 6)
+               vol = stac9460_get(ice, idx) & 0x7f;
+       else 
+               vol = stac9460_2_get(ice, idx - 6) & 0x7f;
+       ucontrol->value.integer.value[0] = 0x7f - vol;
+       return 0;
+}
+
+static int stac9460_dac_vol_put(struct snd_kcontrol *kcontrol,
+                               struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
+       int idx, id;
+       unsigned char tmp, ovol, nvol;
+       int change;
+
+       if (kcontrol->private_value) {
+               idx = STAC946X_MASTER_VOLUME;
+               nvol = ucontrol->value.integer.value[0];
+               tmp = stac9460_get(ice, idx);
+               ovol = 0x7f - (tmp & 0x7f);
+               change = (ovol != nvol);
+               if (change) {
+                        stac9460_put(ice, idx, (0x7f - nvol) | (tmp & 0x80));
+                        stac9460_2_put(ice, idx, (0x7f - nvol) | (tmp & 0x80));
+               }
+       } else {
+               id = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
+               idx = id + STAC946X_LF_VOLUME;
+               nvol = ucontrol->value.integer.value[0];
+               if (id < 6)
+                       tmp = stac9460_get(ice, idx);
+               else 
+                       tmp = stac9460_2_get(ice, idx - 6);
+               ovol = 0x7f - (tmp & 0x7f);
+               change = (ovol != nvol);
+               if (change) {
+                       if (id < 6)
+                               stac9460_put(ice, idx, (0x7f - nvol) |
+                                                       (tmp & 0x80));
+                       else 
+                               stac9460_2_put(ice, idx-6, (0x7f - nvol) |
+                                                               (tmp & 0x80));
+               }
+       }
+       return change;
+}
+
+/*
+ * ADC mute control
+ */
+static int stac9460_adc_mute_info(struct snd_kcontrol *kcontrol,
+                               struct snd_ctl_elem_info *uinfo)
+{
+       uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
+       uinfo->count = 2;
+       uinfo->value.integer.min = 0;
+       uinfo->value.integer.max = 1;
+       return 0;
+}
+
+static int stac9460_adc_mute_get(struct snd_kcontrol *kcontrol,
+                               struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
+       unsigned char val;
+       int i, id;
+       
+       id = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
+       if (id == 0) {
+               for (i = 0; i < 2; ++i) {
+                       val = stac9460_get(ice, STAC946X_MIC_L_VOLUME + i);
+                       ucontrol->value.integer.value[i] = ~val>>7 & 0x1;
+               }
+       } else {
+               for (i = 0; i < 2; ++i) {
+                       val = stac9460_2_get(ice, STAC946X_MIC_L_VOLUME + i);
+                       ucontrol->value.integer.value[i] = ~val>>7 & 0x1;
+               }
+       }
+       return 0;
+}
+
+static int stac9460_adc_mute_put(struct snd_kcontrol *kcontrol,
+                               struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
+       unsigned char new, old;
+       int i, reg, id;
+       int change;
+       
+       id = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
+       if (id == 0) {
+               for (i = 0; i < 2; ++i) {
+                       reg = STAC946X_MIC_L_VOLUME + i;
+                       old = stac9460_get(ice, reg);
+                       new = (~ucontrol->value.integer.value[i]<<7&0x80) |
+                                                               (old&~0x80);
+                       change = (new != old);
+                       if (change)
+                               stac9460_put(ice, reg, new);
+               }
+       } else {
+               for (i = 0; i < 2; ++i) {
+                       reg = STAC946X_MIC_L_VOLUME + i;
+                       old = stac9460_2_get(ice, reg);
+                       new = (~ucontrol->value.integer.value[i]<<7&0x80) |
+                                                               (old&~0x80);
+                       change = (new != old);
+                       if (change)
+                               stac9460_2_put(ice, reg, new);
+               }
+       }
+       return change;
+}
+
+/*
+ *ADC gain mixer control
+ */
+static int stac9460_adc_vol_info(struct snd_kcontrol *kcontrol,
+                               struct snd_ctl_elem_info *uinfo)
+{
+       uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
+       uinfo->count = 2;
+       uinfo->value.integer.min = 0;           /* 0dB */
+       uinfo->value.integer.max = 0x0f;        /* 22.5dB */
+       return 0;
+}
+
+static int stac9460_adc_vol_get(struct snd_kcontrol *kcontrol,
+                               struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
+       int i, reg, id;
+       unsigned char vol;
+       
+       id = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
+       if (id == 0) {
+               for (i = 0; i < 2; ++i) {
+                       reg = STAC946X_MIC_L_VOLUME + i;
+                       vol = stac9460_get(ice, reg) & 0x0f;
+                       ucontrol->value.integer.value[i] = 0x0f - vol;
+               }
+       } else {
+               for (i = 0; i < 2; ++i) {
+                       reg = STAC946X_MIC_L_VOLUME + i;
+                       vol = stac9460_2_get(ice, reg) & 0x0f;
+                       ucontrol->value.integer.value[i] = 0x0f - vol;
+               }
+       }
+       return 0;
+}
+
+static int stac9460_adc_vol_put(struct snd_kcontrol *kcontrol,
+                       struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
+       int i, reg, id;
+       unsigned char ovol, nvol;
+       int change;
+       
+       id = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
+       if (id == 0) {
+               for (i = 0; i < 2; ++i) {
+                       reg = STAC946X_MIC_L_VOLUME + i;
+                       nvol = ucontrol->value.integer.value[i];
+                       ovol = 0x0f - stac9460_get(ice, reg);
+                       change = ((ovol & 0x0f) != nvol);
+                       if (change)
+                               stac9460_put(ice, reg, (0x0f - nvol) |
+                                                       (ovol & ~0x0f));
+               }
+       } else {
+               for (i = 0; i < 2; ++i) {
+                       reg = STAC946X_MIC_L_VOLUME + i;
+                       nvol = ucontrol->value.integer.value[i];
+                       ovol = 0x0f - stac9460_2_get(ice, reg);
+                       change = ((ovol & 0x0f) != nvol);
+                       if (change)
+                               stac9460_2_put(ice, reg, (0x0f - nvol) |
+                                                       (ovol & ~0x0f));
+               }
+       }
+       return change;
+}
+
+/*
+ * MIC / LINE switch fonction
+ */
+
+static int stac9460_mic_sw_info(struct snd_kcontrol *kcontrol,
+                               struct snd_ctl_elem_info *uinfo)
+{
+       uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
+       uinfo->count = 1;
+       uinfo->value.integer.min = 0;
+       uinfo->value.integer.max = 1;
+       return 0;
+}
+
+static int stac9460_mic_sw_get(struct snd_kcontrol *kcontrol,
+                       struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
+       unsigned char val;
+       int id;
+               
+       id = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
+       if (id == 0)
+               val = stac9460_get(ice, STAC946X_GENERAL_PURPOSE);
+       else
+               val = stac9460_2_get(ice, STAC946X_GENERAL_PURPOSE);
+       ucontrol->value.integer.value[0] = ~val>>7 & 0x1;
+       return 0;
+}
+
+static int stac9460_mic_sw_put(struct snd_kcontrol *kcontrol,
+                       struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
+       unsigned char new, old;
+       int change, id;
+
+       id = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
+       if (id == 0)
+               old = stac9460_get(ice, STAC946X_GENERAL_PURPOSE);
+       else
+               old = stac9460_2_get(ice, STAC946X_GENERAL_PURPOSE);
+       new = (~ucontrol->value.integer.value[0]<< 7 & 0x80) | (old & ~0x80);
+       change = (new != old);
+       if (change) {
+               if (id == 0)
+                       stac9460_put(ice, STAC946X_GENERAL_PURPOSE, new);
+               else
+                       stac9460_2_put(ice, STAC946X_GENERAL_PURPOSE, new);
+       }
+       return change;
+}
+
+/*
+ * Control tabs
+ */
+static const struct snd_kcontrol_new stac9640_controls[] __devinitdata = {
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               .name = "Master Playback Switch",
+               .info = stac9460_dac_mute_info,
+               .get = stac9460_dac_mute_get,
+               .put = stac9460_dac_mute_put,
+               .private_value = 1
+       },
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               .name = "Master Playback Volume",
+               .info = stac9460_dac_vol_info,
+               .get = stac9460_dac_vol_get,
+               .put = stac9460_dac_vol_put,
+               .private_value = 1,
+       },
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               .name = "MIC/Line switch",
+               .count = 2,
+               .info = stac9460_mic_sw_info,
+               .get = stac9460_mic_sw_get,
+               .put = stac9460_mic_sw_put,
+
+       },
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               .name = "DAC Switch",
+               .count = 8,
+               .info = stac9460_dac_mute_info,
+               .get = stac9460_dac_mute_get,
+               .put = stac9460_dac_mute_put,
+       },
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               .name = "DAC Volume",
+               .count = 8,
+               .info = stac9460_dac_vol_info,
+               .get = stac9460_dac_vol_get,
+               .put = stac9460_dac_vol_put,
+       },
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               .name = "ADC Switch",
+               .count = 2,
+               .info = stac9460_adc_mute_info,
+               .get = stac9460_adc_mute_get,
+               .put = stac9460_adc_mute_put,
+       },
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               .name = "ADC Volume",
+               .count = 2,
+               .info = stac9460_adc_vol_info,
+               .get = stac9460_adc_vol_get,
+               .put = stac9460_adc_vol_put,
+
+       }       
+};
+
+
+
+/*INIT*/
+static int __devinit wtm_add_controls(struct snd_ice1712 *ice)
+{
+       unsigned int i;
+       int err;
+
+       for (i = 0; i < ARRAY_SIZE(stac9640_controls); i++) {
+               err = snd_ctl_add(ice->card,
+                               snd_ctl_new1(&stac9640_controls[i], ice));
+               if (err < 0)
+                       return err;
+       }
+       return 0;
+}
+
+static int __devinit wtm_init(struct snd_ice1712 *ice)
+{
+       static unsigned short stac_inits_prodigy[] = {
+               STAC946X_RESET, 0,
+               (unsigned short)-1
+       };
+       unsigned short *p;
+               
+       /*WTM 192M*/
+       ice->num_total_dacs = 8;
+       ice->num_total_adcs = 4;
+       ice->force_rdma1 = 1;
+
+       /*initialize codec*/
+       p = stac_inits_prodigy;
+       for (; *p != (unsigned short)-1; p += 2) {
+               stac9460_put(ice, p[0], p[1]);
+               stac9460_2_put(ice, p[0], p[1]);
+       }
+       return 0;
+}
+
+
+static unsigned char wtm_eeprom[] __devinitdata = {
+       0x47,   /*SYSCONF: clock 192KHz, 4ADC, 8DAC */
+       0x80,   /* ACLINK : I2S */
+       0xf8,   /* I2S: vol; 96k, 24bit, 192k */
+       0xc1    /*SPDIF: out-en, spidf ext out*/,
+       0x9f,   /* GPIO_DIR */
+       0xff,   /* GPIO_DIR1 */
+       0x7f,   /* GPIO_DIR2 */
+       0x9f,   /* GPIO_MASK */
+       0xff,   /* GPIO_MASK1 */
+       0x7f,   /* GPIO_MASK2 */
+       0x16,   /* GPIO_STATE */
+       0x80,   /* GPIO_STATE1 */
+       0x00,   /* GPIO_STATE2 */
+};
+
+
+/*entry point*/
+struct snd_ice1712_card_info snd_vt1724_wtm_cards[] __devinitdata = {
+       {
+               .subvendor = VT1724_SUBDEVICE_WTM,
+               .name = "ESI Waveterminal 192M",
+               .model = "WT192M",
+               .chip_init = wtm_init,
+               .build_controls = wtm_add_controls,
+               .eeprom_size = sizeof(wtm_eeprom),
+               .eeprom_data = wtm_eeprom,
+       },
+       {} /*terminator*/
+};
diff --git a/sound/pci/ice1712/wtm.h b/sound/pci/ice1712/wtm.h
new file mode 100644 (file)
index 0000000..03a394e
--- /dev/null
@@ -0,0 +1,20 @@
+#ifndef __SOUND_WTM_H
+#define __SOUND_WTM_H
+
+/* ID */
+#define WTM_DEVICE_DESC                "{EGO SYS INC,WaveTerminal 192M},"
+#define VT1724_SUBDEVICE_WTM   0x36495345      /* WT192M ver1.0 */
+
+/*
+ *chip addresses on I2C bus
+ */
+
+#define        AK4114_ADDR             0x20    /*S/PDIF receiver*/
+#define STAC9460_I2C_ADDR      0x54    /* ADC*2 | DAC*6 */     
+#define STAC9460_2_I2C_ADDR    0x56    /* ADC|DAC *2 */        
+
+
+extern struct snd_ice1712_card_info snd_vt1724_wtm_cards[];
+
+#endif /* __SOUND_WTM_H */
+
index 30aaa6092a84433d3c8315617d2bfbbe9bd8898b..a289abfc7172f5daeab4a255463570cb06ff7805 100644 (file)
@@ -71,6 +71,7 @@ static char *ac97_quirk;
 static int buggy_semaphore;
 static int buggy_irq = -1; /* auto-check */
 static int xbox;
+static int spdif_aclink = -1;
 
 module_param(index, int, 0444);
 MODULE_PARM_DESC(index, "Index value for Intel i8x0 soundcard.");
@@ -86,6 +87,8 @@ module_param(buggy_irq, bool, 0444);
 MODULE_PARM_DESC(buggy_irq, "Enable workaround for buggy interrupts on some motherboards.");
 module_param(xbox, bool, 0444);
 MODULE_PARM_DESC(xbox, "Set to 1 for Xbox, if you have problems with the AC'97 codec detection.");
+module_param(spdif_aclink, int, 0444);
+MODULE_PARM_DESC(spdif_aclink, "S/PDIF over AC-link.");
 
 /* just for backward compatibility */
 static int enable;
@@ -368,12 +371,8 @@ struct intel8x0 {
 
        int irq;
 
-       unsigned int mmio;
-       unsigned long addr;
-       void __iomem *remap_addr;
-       unsigned int bm_mmio;
-       unsigned long bmaddr;
-       void __iomem *remap_bmaddr;
+       void __iomem *addr;
+       void __iomem *bmaddr;
 
        struct pci_dev *pci;
        struct snd_card *card;
@@ -446,72 +445,48 @@ MODULE_DEVICE_TABLE(pci, snd_intel8x0_ids);
  *  Lowlevel I/O - busmaster
  */
 
-static u8 igetbyte(struct intel8x0 *chip, u32 offset)
+static inline u8 igetbyte(struct intel8x0 *chip, u32 offset)
 {
-       if (chip->bm_mmio)
-               return readb(chip->remap_bmaddr + offset);
-       else
-               return inb(chip->bmaddr + offset);
+       return ioread8(chip->bmaddr + offset);
 }
 
-static u16 igetword(struct intel8x0 *chip, u32 offset)
+static inline u16 igetword(struct intel8x0 *chip, u32 offset)
 {
-       if (chip->bm_mmio)
-               return readw(chip->remap_bmaddr + offset);
-       else
-               return inw(chip->bmaddr + offset);
+       return ioread16(chip->bmaddr + offset);
 }
 
-static u32 igetdword(struct intel8x0 *chip, u32 offset)
+static inline u32 igetdword(struct intel8x0 *chip, u32 offset)
 {
-       if (chip->bm_mmio)
-               return readl(chip->remap_bmaddr + offset);
-       else
-               return inl(chip->bmaddr + offset);
+       return ioread32(chip->bmaddr + offset);
 }
 
-static void iputbyte(struct intel8x0 *chip, u32 offset, u8 val)
+static inline void iputbyte(struct intel8x0 *chip, u32 offset, u8 val)
 {
-       if (chip->bm_mmio)
-               writeb(val, chip->remap_bmaddr + offset);
-       else
-               outb(val, chip->bmaddr + offset);
+       iowrite8(val, chip->bmaddr + offset);
 }
 
-static void iputword(struct intel8x0 *chip, u32 offset, u16 val)
+static inline void iputword(struct intel8x0 *chip, u32 offset, u16 val)
 {
-       if (chip->bm_mmio)
-               writew(val, chip->remap_bmaddr + offset);
-       else
-               outw(val, chip->bmaddr + offset);
+       iowrite16(val, chip->bmaddr + offset);
 }
 
-static void iputdword(struct intel8x0 *chip, u32 offset, u32 val)
+static inline void iputdword(struct intel8x0 *chip, u32 offset, u32 val)
 {
-       if (chip->bm_mmio)
-               writel(val, chip->remap_bmaddr + offset);
-       else
-               outl(val, chip->bmaddr + offset);
+       iowrite32(val, chip->bmaddr + offset);
 }
 
 /*
  *  Lowlevel I/O - AC'97 registers
  */
 
-static u16 iagetword(struct intel8x0 *chip, u32 offset)
+static inline u16 iagetword(struct intel8x0 *chip, u32 offset)
 {
-       if (chip->mmio)
-               return readw(chip->remap_addr + offset);
-       else
-               return inw(chip->addr + offset);
+       return ioread16(chip->addr + offset);
 }
 
-static void iaputword(struct intel8x0 *chip, u32 offset, u16 val)
+static inline void iaputword(struct intel8x0 *chip, u32 offset, u16 val)
 {
-       if (chip->mmio)
-               writew(val, chip->remap_addr + offset);
-       else
-               outw(val, chip->addr + offset);
+       iowrite16(val, chip->addr + offset);
 }
 
 /*
@@ -1606,10 +1581,14 @@ static int __devinit snd_intel8x0_pcm(struct intel8x0 *chip)
        case DEVICE_INTEL_ICH4:
                tbl = intel_pcms;
                tblsize = ARRAY_SIZE(intel_pcms);
+               if (spdif_aclink)
+                       tblsize--;
                break;
        case DEVICE_NFORCE:
                tbl = nforce_pcms;
                tblsize = ARRAY_SIZE(nforce_pcms);
+               if (spdif_aclink)
+                       tblsize--;
                break;
        case DEVICE_ALI:
                tbl = ali_pcms;
@@ -2068,24 +2047,26 @@ static int __devinit snd_intel8x0_mixer(struct intel8x0 *chip, int ac97_clock,
        };
 
        chip->spdif_idx = -1; /* use PCMOUT (or disabled) */
-       switch (chip->device_type) {
-       case DEVICE_NFORCE:
-               chip->spdif_idx = NVD_SPBAR;
-               break;
-       case DEVICE_ALI:
-               chip->spdif_idx = ALID_AC97SPDIFOUT;
-               break;
-       case DEVICE_INTEL_ICH4:
-               chip->spdif_idx = ICHD_SPBAR;
-               break;
-       };
+       if (!spdif_aclink) {
+               switch (chip->device_type) {
+               case DEVICE_NFORCE:
+                       chip->spdif_idx = NVD_SPBAR;
+                       break;
+               case DEVICE_ALI:
+                       chip->spdif_idx = ALID_AC97SPDIFOUT;
+                       break;
+               case DEVICE_INTEL_ICH4:
+                       chip->spdif_idx = ICHD_SPBAR;
+                       break;
+               };
+       }
 
        chip->in_ac97_init = 1;
        
        memset(&ac97, 0, sizeof(ac97));
        ac97.private_data = chip;
        ac97.private_free = snd_intel8x0_mixer_free_ac97;
-       ac97.scaps = AC97_SCAP_SKIP_MODEM;
+       ac97.scaps = AC97_SCAP_SKIP_MODEM | AC97_SCAP_POWER_SAVE;
        if (chip->xbox)
                ac97.scaps |= AC97_SCAP_DETECT_BY_VENDOR;
        if (chip->device_type != DEVICE_ALI) {
@@ -2201,11 +2182,11 @@ static int __devinit snd_intel8x0_mixer(struct intel8x0 *chip, int ac97_clock,
                if ((igetdword(chip, ICHREG(GLOB_STA)) & ICH_SAMPLE_CAP) == ICH_SAMPLE_16_20)
                        chip->smp20bit = 1;
        }
-       if (chip->device_type == DEVICE_NFORCE) {
+       if (chip->device_type == DEVICE_NFORCE && !spdif_aclink) {
                /* 48kHz only */
                chip->ichd[chip->spdif_idx].pcm->rates = SNDRV_PCM_RATE_48000;
        }
-       if (chip->device_type == DEVICE_INTEL_ICH4) {
+       if (chip->device_type == DEVICE_INTEL_ICH4 && !spdif_aclink) {
                /* use slot 10/11 for SPDIF */
                u32 val;
                val = igetdword(chip, ICHREG(GLOB_CNT)) & ~ICH_PCM_SPDIF_MASK;
@@ -2333,7 +2314,7 @@ static int snd_intel8x0_ich_chip_init(struct intel8x0 *chip, int probing)
                /* unmute the output on SIS7012 */
                iputword(chip, 0x4c, igetword(chip, 0x4c) | 1);
        }
-       if (chip->device_type == DEVICE_NFORCE) {
+       if (chip->device_type == DEVICE_NFORCE && !spdif_aclink) {
                /* enable SPDIF interrupt */
                unsigned int val;
                pci_read_config_dword(chip->pci, 0x4c, &val);
@@ -2426,7 +2407,7 @@ static int snd_intel8x0_free(struct intel8x0 *chip)
        /* reset channels */
        for (i = 0; i < chip->bdbars_count; i++)
                iputbyte(chip, ICH_REG_OFF_CR + chip->ichd[i].reg_offset, ICH_RESETREGS);
-       if (chip->device_type == DEVICE_NFORCE) {
+       if (chip->device_type == DEVICE_NFORCE && !spdif_aclink) {
                /* stop the spdif interrupt */
                unsigned int val;
                pci_read_config_dword(chip->pci, 0x4c, &val);
@@ -2443,10 +2424,10 @@ static int snd_intel8x0_free(struct intel8x0 *chip)
                        fill_nocache(chip->bdbars.area, chip->bdbars.bytes, 0);
                snd_dma_free_pages(&chip->bdbars);
        }
-       if (chip->remap_addr)
-               iounmap(chip->remap_addr);
-       if (chip->remap_bmaddr)
-               iounmap(chip->remap_bmaddr);
+       if (chip->addr)
+               pci_iounmap(chip->pci, chip->addr);
+       if (chip->bmaddr)
+               pci_iounmap(chip->pci, chip->bmaddr);
        pci_release_regions(chip->pci);
        pci_disable_device(chip->pci);
        kfree(chip);
@@ -2520,7 +2501,7 @@ static int intel8x0_resume(struct pci_dev *pci)
        snd_intel8x0_chip_init(chip, 0);
 
        /* re-initialize mixer stuff */
-       if (chip->device_type == DEVICE_INTEL_ICH4) {
+       if (chip->device_type == DEVICE_INTEL_ICH4 && !spdif_aclink) {
                /* enable separate SDINs for ICH4 */
                iputbyte(chip, ICHREG(SDM), chip->sdm_saved);
                /* use slot 10/11 for SPDIF */
@@ -2793,35 +2774,27 @@ static int __devinit snd_intel8x0_create(struct snd_card *card,
 
        if (device_type == DEVICE_ALI) {
                /* ALI5455 has no ac97 region */
-               chip->bmaddr = pci_resource_start(pci, 0);
+               chip->bmaddr = pci_iomap(pci, 0, 0);
                goto port_inited;
        }
 
-       if (pci_resource_flags(pci, 2) & IORESOURCE_MEM) {      /* ICH4 and Nforce */
-               chip->mmio = 1;
-               chip->addr = pci_resource_start(pci, 2);
-               chip->remap_addr = ioremap_nocache(chip->addr,
-                                                  pci_resource_len(pci, 2));
-               if (chip->remap_addr == NULL) {
-                       snd_printk(KERN_ERR "AC'97 space ioremap problem\n");
-                       snd_intel8x0_free(chip);
-                       return -EIO;
-               }
-       } else {
-               chip->addr = pci_resource_start(pci, 0);
-       }
-       if (pci_resource_flags(pci, 3) & IORESOURCE_MEM) {      /* ICH4 */
-               chip->bm_mmio = 1;
-               chip->bmaddr = pci_resource_start(pci, 3);
-               chip->remap_bmaddr = ioremap_nocache(chip->bmaddr,
-                                                    pci_resource_len(pci, 3));
-               if (chip->remap_bmaddr == NULL) {
-                       snd_printk(KERN_ERR "Controller space ioremap problem\n");
-                       snd_intel8x0_free(chip);
-                       return -EIO;
-               }
-       } else {
-               chip->bmaddr = pci_resource_start(pci, 1);
+       if (pci_resource_flags(pci, 2) & IORESOURCE_MEM) /* ICH4 and Nforce */
+               chip->addr = pci_iomap(pci, 2, 0);
+       else
+               chip->addr = pci_iomap(pci, 0, 0);
+       if (!chip->addr) {
+               snd_printk(KERN_ERR "AC'97 space ioremap problem\n");
+               snd_intel8x0_free(chip);
+               return -EIO;
+       }
+       if (pci_resource_flags(pci, 3) & IORESOURCE_MEM) /* ICH4 */
+               chip->bmaddr = pci_iomap(pci, 3, 0);
+       else
+               chip->bmaddr = pci_iomap(pci, 1, 0);
+       if (!chip->bmaddr) {
+               snd_printk(KERN_ERR "Controller space ioremap problem\n");
+               snd_intel8x0_free(chip);
+               return -EIO;
        }
 
  port_inited:
@@ -2964,6 +2937,29 @@ static struct shortname_table {
        { 0, NULL },
 };
 
+static struct snd_pci_quirk spdif_aclink_defaults[] __devinitdata = {
+       SND_PCI_QUIRK(0x147b, 0x1c1a, "ASUS KN8", 1),
+       { } /* end */
+};
+
+/* look up white/black list for SPDIF over ac-link */
+static int __devinit check_default_spdif_aclink(struct pci_dev *pci)
+{
+       const struct snd_pci_quirk *w;
+
+       w = snd_pci_quirk_lookup(pci, spdif_aclink_defaults);
+       if (w) {
+               if (w->value)
+                       snd_printdd(KERN_INFO "intel8x0: Using SPDIF over "
+                                   "AC-Link for %s\n", w->name);
+               else
+                       snd_printdd(KERN_INFO "intel8x0: Using integrated "
+                                   "SPDIF DMA for %s\n", w->name);
+               return w->value;
+       }
+       return 0;
+}
+
 static int __devinit snd_intel8x0_probe(struct pci_dev *pci,
                                        const struct pci_device_id *pci_id)
 {
@@ -2976,16 +2972,18 @@ static int __devinit snd_intel8x0_probe(struct pci_dev *pci,
        if (card == NULL)
                return -ENOMEM;
 
-       switch (pci_id->driver_data) {
-       case DEVICE_NFORCE:
-               strcpy(card->driver, "NFORCE");
-               break;
-       case DEVICE_INTEL_ICH4:
-               strcpy(card->driver, "ICH4");
-               break;
-       default:
-               strcpy(card->driver, "ICH");
-               break;
+       if (spdif_aclink < 0)
+               spdif_aclink = check_default_spdif_aclink(pci);
+
+       strcpy(card->driver, "ICH");
+       if (!spdif_aclink) {
+               switch (pci_id->driver_data) {
+               case DEVICE_NFORCE:
+                       strcpy(card->driver, "NFORCE");
+                       break;
+               case DEVICE_INTEL_ICH4:
+                       strcpy(card->driver, "ICH4");
+               }
        }
 
        strcpy(card->shortname, "Intel ICH");
@@ -3025,8 +3023,8 @@ static int __devinit snd_intel8x0_probe(struct pci_dev *pci,
        snd_intel8x0_proc_init(chip);
 
        snprintf(card->longname, sizeof(card->longname),
-                "%s with %s at %#lx, irq %i", card->shortname,
-                snd_ac97_get_short_name(chip->ac97[0]), chip->addr, chip->irq);
+                "%s with %s at irq %i", card->shortname,
+                snd_ac97_get_short_name(chip->ac97[0]), chip->irq);
 
        if (! ac97_clock)
                intel8x0_measure_ac97_clock(chip);
index 09dcf923b5471fdda5015daf25f8b6a4f7a239a2..c155e1f3a0e51e58baad24375bdaf36f1b382296 100644 (file)
@@ -196,12 +196,8 @@ struct intel8x0m {
 
        int irq;
 
-       unsigned int mmio;
-       unsigned long addr;
-       void __iomem *remap_addr;
-       unsigned int bm_mmio;
-       unsigned long bmaddr;
-       void __iomem *remap_bmaddr;
+       void __iomem *addr;
+       void __iomem *bmaddr;
 
        struct pci_dev *pci;
        struct snd_card *card;
@@ -253,72 +249,48 @@ MODULE_DEVICE_TABLE(pci, snd_intel8x0m_ids);
  *  Lowlevel I/O - busmaster
  */
 
-static u8 igetbyte(struct intel8x0m *chip, u32 offset)
+static inline u8 igetbyte(struct intel8x0m *chip, u32 offset)
 {
-       if (chip->bm_mmio)
-               return readb(chip->remap_bmaddr + offset);
-       else
-               return inb(chip->bmaddr + offset);
+       return ioread8(chip->bmaddr + offset);
 }
 
-static u16 igetword(struct intel8x0m *chip, u32 offset)
+static inline u16 igetword(struct intel8x0m *chip, u32 offset)
 {
-       if (chip->bm_mmio)
-               return readw(chip->remap_bmaddr + offset);
-       else
-               return inw(chip->bmaddr + offset);
+       return ioread16(chip->bmaddr + offset);
 }
 
-static u32 igetdword(struct intel8x0m *chip, u32 offset)
+static inline u32 igetdword(struct intel8x0m *chip, u32 offset)
 {
-       if (chip->bm_mmio)
-               return readl(chip->remap_bmaddr + offset);
-       else
-               return inl(chip->bmaddr + offset);
+       return ioread32(chip->bmaddr + offset);
 }
 
-static void iputbyte(struct intel8x0m *chip, u32 offset, u8 val)
+static inline void iputbyte(struct intel8x0m *chip, u32 offset, u8 val)
 {
-       if (chip->bm_mmio)
-               writeb(val, chip->remap_bmaddr + offset);
-       else
-               outb(val, chip->bmaddr + offset);
+       iowrite8(val, chip->bmaddr + offset);
 }
 
-static void iputword(struct intel8x0m *chip, u32 offset, u16 val)
+static inline void iputword(struct intel8x0m *chip, u32 offset, u16 val)
 {
-       if (chip->bm_mmio)
-               writew(val, chip->remap_bmaddr + offset);
-       else
-               outw(val, chip->bmaddr + offset);
+       iowrite16(val, chip->bmaddr + offset);
 }
 
-static void iputdword(struct intel8x0m *chip, u32 offset, u32 val)
+static inline void iputdword(struct intel8x0m *chip, u32 offset, u32 val)
 {
-       if (chip->bm_mmio)
-               writel(val, chip->remap_bmaddr + offset);
-       else
-               outl(val, chip->bmaddr + offset);
+       iowrite32(val, chip->bmaddr + offset);
 }
 
 /*
  *  Lowlevel I/O - AC'97 registers
  */
 
-static u16 iagetword(struct intel8x0m *chip, u32 offset)
+static inline u16 iagetword(struct intel8x0m *chip, u32 offset)
 {
-       if (chip->mmio)
-               return readw(chip->remap_addr + offset);
-       else
-               return inw(chip->addr + offset);
+       return ioread16(chip->addr + offset);
 }
 
-static void iaputword(struct intel8x0m *chip, u32 offset, u16 val)
+static inline void iaputword(struct intel8x0m *chip, u32 offset, u16 val)
 {
-       if (chip->mmio)
-               writew(val, chip->remap_addr + offset);
-       else
-               outw(val, chip->addr + offset);
+       iowrite16(val, chip->addr + offset);
 }
 
 /*
@@ -858,7 +830,7 @@ static int __devinit snd_intel8x0_mixer(struct intel8x0m *chip, int ac97_clock)
        memset(&ac97, 0, sizeof(ac97));
        ac97.private_data = chip;
        ac97.private_free = snd_intel8x0_mixer_free_ac97;
-       ac97.scaps = AC97_SCAP_SKIP_AUDIO;
+       ac97.scaps = AC97_SCAP_SKIP_AUDIO | AC97_SCAP_POWER_SAVE;
 
        glob_sta = igetdword(chip, ICHREG(GLOB_STA));
 
@@ -1019,10 +991,10 @@ static int snd_intel8x0_free(struct intel8x0m *chip)
       __hw_end:
        if (chip->bdbars.area)
                snd_dma_free_pages(&chip->bdbars);
-       if (chip->remap_addr)
-               iounmap(chip->remap_addr);
-       if (chip->remap_bmaddr)
-               iounmap(chip->remap_bmaddr);
+       if (chip->addr)
+               pci_iounmap(chip->pci, chip->addr);
+       if (chip->bmaddr)
+               pci_iounmap(chip->pci, chip->bmaddr);
        if (chip->irq >= 0)
                free_irq(chip->irq, chip);
        pci_release_regions(chip->pci);
@@ -1173,35 +1145,27 @@ static int __devinit snd_intel8x0m_create(struct snd_card *card,
 
        if (device_type == DEVICE_ALI) {
                /* ALI5455 has no ac97 region */
-               chip->bmaddr = pci_resource_start(pci, 0);
+               chip->bmaddr = pci_iomap(pci, 0, 0);
                goto port_inited;
        }
 
-       if (pci_resource_flags(pci, 2) & IORESOURCE_MEM) {      /* ICH4 and Nforce */
-               chip->mmio = 1;
-               chip->addr = pci_resource_start(pci, 2);
-               chip->remap_addr = ioremap_nocache(chip->addr,
-                                                  pci_resource_len(pci, 2));
-               if (chip->remap_addr == NULL) {
-                       snd_printk(KERN_ERR "AC'97 space ioremap problem\n");
-                       snd_intel8x0_free(chip);
-                       return -EIO;
-               }
-       } else {
-               chip->addr = pci_resource_start(pci, 0);
+       if (pci_resource_flags(pci, 2) & IORESOURCE_MEM) /* ICH4 and Nforce */
+               chip->addr = pci_iomap(pci, 2, 0);
+       else
+               chip->addr = pci_iomap(pci, 0, 0);
+       if (!chip->addr) {
+               snd_printk(KERN_ERR "AC'97 space ioremap problem\n");
+               snd_intel8x0_free(chip);
+               return -EIO;
        }
-       if (pci_resource_flags(pci, 3) & IORESOURCE_MEM) {      /* ICH4 */
-               chip->bm_mmio = 1;
-               chip->bmaddr = pci_resource_start(pci, 3);
-               chip->remap_bmaddr = ioremap_nocache(chip->bmaddr,
-                                                    pci_resource_len(pci, 3));
-               if (chip->remap_bmaddr == NULL) {
-                       snd_printk(KERN_ERR "Controller space ioremap problem\n");
-                       snd_intel8x0_free(chip);
-                       return -EIO;
-               }
-       } else {
-               chip->bmaddr = pci_resource_start(pci, 1);
+       if (pci_resource_flags(pci, 3) & IORESOURCE_MEM) /* ICH4 */
+               chip->bmaddr = pci_iomap(pci, 3, 0);
+       else
+               chip->bmaddr = pci_iomap(pci, 1, 0);
+       if (!chip->bmaddr) {
+               snd_printk(KERN_ERR "Controller space ioremap problem\n");
+               snd_intel8x0_free(chip);
+               return -EIO;
        }
 
  port_inited:
@@ -1339,8 +1303,8 @@ static int __devinit snd_intel8x0m_probe(struct pci_dev *pci,
        
        snd_intel8x0m_proc_init(chip);
 
-       sprintf(card->longname, "%s at 0x%lx, irq %i",
-               card->shortname, chip->addr, chip->irq);
+       sprintf(card->longname, "%s at irq %i",
+               card->shortname, chip->irq);
 
        if ((err = snd_card_register(card)) < 0) {
                snd_card_free(card);
index 345eefeedb394628c9f8ffb224fc54ce278ebb76..21d0899ac382cedf13cfd3919be969656bec0806 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/wait.h>
 #include <linux/moduleparam.h>
 #include <linux/mutex.h>
+#include <linux/firmware.h>
 
 #include <sound/core.h>
 #include <sound/info.h>
@@ -263,7 +264,15 @@ enum MonitorModeSelector {
 #define COMMAND_ACK_DELAY   13         // number of RTC ticks to wait for an acknowledgement
                                        //    from the card after sending a command.
 
+#define FIRMWARE_IN_THE_KERNEL
+
+#ifdef FIRMWARE_IN_THE_KERNEL
 #include "korg1212-firmware.h"
+static const struct firmware static_dsp_code = {
+       .data = (u8 *)dspCode,
+       .size = sizeof dspCode
+};
+#endif
 
 enum ClockSourceIndex {
    K1212_CLKIDX_AdatAt44_1K = 0,    // selects source as ADAT at 44.1 kHz
@@ -345,8 +354,6 @@ struct snd_korg1212 {
         struct snd_dma_buffer dma_rec;
        struct snd_dma_buffer dma_shared;
 
-        u32 dspCodeSize;
-
        u32 DataBufsSize;
 
         struct KorgAudioBuffer  * playDataBufsPtr;
@@ -1223,8 +1230,6 @@ static int snd_korg1212_downloadDSPCode(struct snd_korg1212 *korg1212)
 
         snd_korg1212_setCardState(korg1212, K1212_STATE_DSP_IN_PROCESS);
 
-        memcpy(korg1212->dma_dsp.area, dspCode, korg1212->dspCodeSize);
-
         rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_StartDSPDownload,
                                      UpperWordSwap(korg1212->dma_dsp.addr),
                                      0, 0, 0);
@@ -2156,6 +2161,7 @@ static int __devinit snd_korg1212_create(struct snd_card *card, struct pci_dev *
         unsigned int i;
        unsigned ioport_size, iomem_size, iomem2_size;
         struct snd_korg1212 * korg1212;
+       const struct firmware *dsp_code;
 
         static struct snd_device_ops ops = {
                 .dev_free = snd_korg1212_dev_free,
@@ -2329,8 +2335,6 @@ static int __devinit snd_korg1212_create(struct snd_card *card, struct pci_dev *
 
 #endif // K1212_LARGEALLOC
 
-        korg1212->dspCodeSize = sizeof (dspCode);
-
         korg1212->VolumeTablePhy = korg1212->sharedBufferPhy +
                offsetof(struct KorgSharedBuffer, volumeData);
         korg1212->RoutingTablePhy = korg1212->sharedBufferPhy +
@@ -2338,17 +2342,40 @@ static int __devinit snd_korg1212_create(struct snd_card *card, struct pci_dev *
         korg1212->AdatTimeCodePhy = korg1212->sharedBufferPhy +
                offsetof(struct KorgSharedBuffer, AdatTimeCode);
 
+       err = request_firmware(&dsp_code, "korg/k1212.dsp", &pci->dev);
+       if (err < 0) {
+               release_firmware(dsp_code);
+#ifdef FIRMWARE_IN_THE_KERNEL
+               dsp_code = &static_dsp_code;
+#else
+               snd_printk(KERN_ERR "firmware not available\n");
+               snd_korg1212_free(korg1212);
+               return err;
+#endif
+       }
+
        if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
-                               korg1212->dspCodeSize, &korg1212->dma_dsp) < 0) {
-               snd_printk(KERN_ERR "korg1212: can not allocate dsp code memory (%d bytes)\n", korg1212->dspCodeSize);
+                               dsp_code->size, &korg1212->dma_dsp) < 0) {
+               snd_printk(KERN_ERR "korg1212: cannot allocate dsp code memory (%zd bytes)\n", dsp_code->size);
                 snd_korg1212_free(korg1212);
+#ifdef FIRMWARE_IN_THE_KERNEL
+               if (dsp_code != &static_dsp_code)
+#endif
+                       release_firmware(dsp_code);
                 return -ENOMEM;
         }
 
         K1212_DEBUG_PRINTK("K1212_DEBUG: DSP Code area = 0x%p (0x%08x) %d bytes [%s]\n",
-                  korg1212->dma_dsp.area, korg1212->dma_dsp.addr, korg1212->dspCodeSize,
+                  korg1212->dma_dsp.area, korg1212->dma_dsp.addr, dsp_code->size,
                   stateName[korg1212->cardState]);
 
+       memcpy(korg1212->dma_dsp.area, dsp_code->data, dsp_code->size);
+
+#ifdef FIRMWARE_IN_THE_KERNEL
+       if (dsp_code != &static_dsp_code)
+#endif
+               release_firmware(dsp_code);
+
        rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_RebootCard, 0, 0, 0, 0);
 
        if (rc)
index 6efe6d5ade1e9518673735f7fdfe3f02c79ccb1a..4526904e3f86df587fe37eb1ad9783c64c3bef25 100644 (file)
@@ -41,6 +41,7 @@
 #include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/moduleparam.h>
+#include <linux/firmware.h>
 #include <sound/core.h>
 #include <sound/info.h>
 #include <sound/control.h>
@@ -48,6 +49,7 @@
 #include <sound/mpu401.h>
 #include <sound/ac97_codec.h>
 #include <sound/initval.h>
+#include <asm/byteorder.h>
 
 MODULE_AUTHOR("Zach Brown <zab@zabbo.net>, Takashi Iwai <tiwai@suse.de>");
 MODULE_DESCRIPTION("ESS Maestro3 PCI");
@@ -768,21 +770,6 @@ MODULE_PARM_DESC(amp_gpio, "GPIO pin number for external amp. (default = -1)");
 /*
  */
 
-/* quirk lists */
-struct m3_quirk {
-       const char *name;       /* device name */
-       u16 vendor, device;     /* subsystem ids */
-       int amp_gpio;           /* gpio pin #  for external amp, -1 = default */
-       int irda_workaround;    /* non-zero if avoid to touch 0x10 on GPIO_DIRECTION
-                                  (e.g. for IrDA on Dell Inspirons) */
-};
-
-struct m3_hv_quirk {
-       u16 vendor, device, subsystem_vendor, subsystem_device;
-       u32 config;             /* ALLEGRO_CONFIG hardware volume bits */
-       int is_omnibook;        /* Do HP OmniBook GPIO magic? */
-};
-
 struct m3_list {
        int curlen;
        int mem_addr;
@@ -830,8 +817,6 @@ struct snd_m3 {
        struct snd_pcm *pcm;
 
        struct pci_dev *pci;
-       const struct m3_quirk *quirk;
-       const struct m3_hv_quirk *hv_quirk;
 
        int dacs_active;
        int timer_users;
@@ -845,7 +830,11 @@ struct snd_m3 {
        u8 reset_state;
 
        int external_amp;
-       int amp_gpio;
+       int amp_gpio;   /* gpio pin #  for external amp, -1 = default */
+       unsigned int hv_config;         /* hardware-volume config bits */
+       unsigned irda_workaround :1;    /* avoid to touch 0x10 on GPIO_DIRECTION
+                                          (e.g. for IrDA on Dell Inspirons) */
+       unsigned is_omnibook :1;        /* Do HP OmniBook GPIO magic? */
 
        /* midi */
        struct snd_rawmidi *rmidi;
@@ -864,6 +853,9 @@ struct snd_m3 {
 #ifdef CONFIG_PM
        u16 *suspend_mem;
 #endif
+
+       const struct firmware *assp_kernel_image;
+       const struct firmware *assp_minisrc_image;
 };
 
 /*
@@ -891,127 +883,104 @@ static struct pci_device_id snd_m3_ids[] = {
 
 MODULE_DEVICE_TABLE(pci, snd_m3_ids);
 
-static const struct m3_quirk m3_quirk_list[] = {
-       /* panasonic CF-28 "toughbook" */
-       {
-               .name = "Panasonic CF-28",
-               .vendor = 0x10f7,
-               .device = 0x833e,
-               .amp_gpio = 0x0d,
-       },
-       /* panasonic CF-72 "toughbook" */
-       {
-               .name = "Panasonic CF-72",
-               .vendor = 0x10f7,
-               .device = 0x833d,
-               .amp_gpio = 0x0d,
-       },
-       /* Dell Inspiron 4000 */
-       {
-               .name = "Dell Inspiron 4000",
-               .vendor = 0x1028,
-               .device = 0x00b0,
-               .amp_gpio = -1,
-               .irda_workaround = 1,
-       },
-       /* Dell Inspiron 8000 */
-       {
-               .name = "Dell Inspiron 8000",
-               .vendor = 0x1028,
-               .device = 0x00a4,
-               .amp_gpio = -1,
-               .irda_workaround = 1,
-       },
-       /* Dell Inspiron 8100 */
-       {
-               .name = "Dell Inspiron 8100",
-               .vendor = 0x1028,
-               .device = 0x00e6,
-               .amp_gpio = -1,
-               .irda_workaround = 1,
-       },
-       /* NEC LM800J/7 */
-       {
-               .name = "NEC LM800J/7",
-               .vendor = 0x1033,
-               .device = 0x80f1,
-               .amp_gpio = 0x03,
-       },
-       /* LEGEND ZhaoYang 3100CF */
-       {
-               .name = "LEGEND ZhaoYang 3100CF",
-               .vendor = 0x1509,
-               .device = 0x1740,
-               .amp_gpio = 0x03,
-       },
-       /* END */
-       { NULL }
+static struct snd_pci_quirk m3_amp_quirk_list[] __devinitdata = {
+       SND_PCI_QUIRK(0x10f7, 0x833e, "Panasonic CF-28", 0x0d),
+       SND_PCI_QUIRK(0x10f7, 0x833d, "Panasonic CF-72", 0x0d),
+       SND_PCI_QUIRK(0x1033, 0x80f1, "NEC LM800J/7", 0x03),
+       SND_PCI_QUIRK(0x1509, 0x1740, "LEGEND ZhaoYang 3100CF", 0x03),
+       { } /* END */
 };
 
-/* These values came from the Windows driver. */
-static const struct m3_hv_quirk m3_hv_quirk_list[] = {
+static struct snd_pci_quirk m3_irda_quirk_list[] __devinitdata = {
+       SND_PCI_QUIRK(0x1028, 0x00b0, "Dell Inspiron 4000", 1),
+       SND_PCI_QUIRK(0x1028, 0x00a4, "Dell Inspiron 8000", 1),
+       SND_PCI_QUIRK(0x1028, 0x00e6, "Dell Inspiron 8100", 1),
+       { } /* END */
+};
+
+/* hardware volume quirks */
+static struct snd_pci_quirk m3_hv_quirk_list[] __devinitdata = {
        /* Allegro chips */
-       { 0x125D, 0x1988, 0x0E11, 0x002E, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
-       { 0x125D, 0x1988, 0x0E11, 0x0094, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
-       { 0x125D, 0x1988, 0x0E11, 0xB112, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
-       { 0x125D, 0x1988, 0x0E11, 0xB114, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
-       { 0x125D, 0x1988, 0x103C, 0x0012, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
-       { 0x125D, 0x1988, 0x103C, 0x0018, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
-       { 0x125D, 0x1988, 0x103C, 0x001C, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
-       { 0x125D, 0x1988, 0x103C, 0x001D, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
-       { 0x125D, 0x1988, 0x103C, 0x001E, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
-       { 0x125D, 0x1988, 0x107B, 0x3350, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
-       { 0x125D, 0x1988, 0x10F7, 0x8338, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
-       { 0x125D, 0x1988, 0x10F7, 0x833C, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
-       { 0x125D, 0x1988, 0x10F7, 0x833D, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
-       { 0x125D, 0x1988, 0x10F7, 0x833E, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
-       { 0x125D, 0x1988, 0x10F7, 0x833F, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
-       { 0x125D, 0x1988, 0x13BD, 0x1018, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
-       { 0x125D, 0x1988, 0x13BD, 0x1019, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
-       { 0x125D, 0x1988, 0x13BD, 0x101A, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
-       { 0x125D, 0x1988, 0x14FF, 0x0F03, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
-       { 0x125D, 0x1988, 0x14FF, 0x0F04, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
-       { 0x125D, 0x1988, 0x14FF, 0x0F05, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
-       { 0x125D, 0x1988, 0x156D, 0xB400, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
-       { 0x125D, 0x1988, 0x156D, 0xB795, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
-       { 0x125D, 0x1988, 0x156D, 0xB797, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
-       { 0x125D, 0x1988, 0x156D, 0xC700, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
-       { 0x125D, 0x1988, 0x1033, 0x80F1, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE, 0 },
-       { 0x125D, 0x1988, 0x103C, 0x001A, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE, 0 }, /* HP OmniBook 6100 */
-       { 0x125D, 0x1988, 0x107B, 0x340A, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE, 0 },
-       { 0x125D, 0x1988, 0x107B, 0x3450, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE, 0 },
-       { 0x125D, 0x1988, 0x109F, 0x3134, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE, 0 },
-       { 0x125D, 0x1988, 0x109F, 0x3161, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE, 0 },
-       { 0x125D, 0x1988, 0x144D, 0x3280, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE, 0 },
-       { 0x125D, 0x1988, 0x144D, 0x3281, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE, 0 },
-       { 0x125D, 0x1988, 0x144D, 0xC002, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE, 0 },
-       { 0x125D, 0x1988, 0x144D, 0xC003, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE, 0 },
-       { 0x125D, 0x1988, 0x1509, 0x1740, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE, 0 },
-       { 0x125D, 0x1988, 0x1610, 0x0010, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE, 0 },
-       { 0x125D, 0x1988, 0x1042, 0x1042, HV_CTRL_ENABLE, 0 },
-       { 0x125D, 0x1988, 0x107B, 0x9500, HV_CTRL_ENABLE, 0 },
-       { 0x125D, 0x1988, 0x14FF, 0x0F06, HV_CTRL_ENABLE, 0 },
-       { 0x125D, 0x1988, 0x1558, 0x8586, HV_CTRL_ENABLE, 0 },
-       { 0x125D, 0x1988, 0x161F, 0x2011, HV_CTRL_ENABLE, 0 },
+       SND_PCI_QUIRK(0x0E11, 0x002E, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD),
+       SND_PCI_QUIRK(0x0E11, 0x0094, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD),
+       SND_PCI_QUIRK(0x0E11, 0xB112, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD),
+       SND_PCI_QUIRK(0x0E11, 0xB114, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD),
+       SND_PCI_QUIRK(0x103C, 0x0012, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD),
+       SND_PCI_QUIRK(0x103C, 0x0018, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD),
+       SND_PCI_QUIRK(0x103C, 0x001C, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD),
+       SND_PCI_QUIRK(0x103C, 0x001D, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD),
+       SND_PCI_QUIRK(0x103C, 0x001E, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD),
+       SND_PCI_QUIRK(0x107B, 0x3350, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD),
+       SND_PCI_QUIRK(0x10F7, 0x8338, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD),
+       SND_PCI_QUIRK(0x10F7, 0x833C, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD),
+       SND_PCI_QUIRK(0x10F7, 0x833D, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD),
+       SND_PCI_QUIRK(0x10F7, 0x833E, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD),
+       SND_PCI_QUIRK(0x10F7, 0x833F, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD),
+       SND_PCI_QUIRK(0x13BD, 0x1018, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD),
+       SND_PCI_QUIRK(0x13BD, 0x1019, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD),
+       SND_PCI_QUIRK(0x13BD, 0x101A, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD),
+       SND_PCI_QUIRK(0x14FF, 0x0F03, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD),
+       SND_PCI_QUIRK(0x14FF, 0x0F04, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD),
+       SND_PCI_QUIRK(0x14FF, 0x0F05, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD),
+       SND_PCI_QUIRK(0x156D, 0xB400, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD),
+       SND_PCI_QUIRK(0x156D, 0xB795, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD),
+       SND_PCI_QUIRK(0x156D, 0xB797, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD),
+       SND_PCI_QUIRK(0x156D, 0xC700, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD),
+       SND_PCI_QUIRK(0x1033, 0x80F1, NULL,
+                     HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE),
+       SND_PCI_QUIRK(0x103C, 0x001A, NULL, /* HP OmniBook 6100 */
+                     HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE),
+       SND_PCI_QUIRK(0x107B, 0x340A, NULL,
+                     HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE),
+       SND_PCI_QUIRK(0x107B, 0x3450, NULL,
+                     HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE),
+       SND_PCI_QUIRK(0x109F, 0x3134, NULL,
+                     HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE),
+       SND_PCI_QUIRK(0x109F, 0x3161, NULL,
+                     HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE),
+       SND_PCI_QUIRK(0x144D, 0x3280, NULL,
+                     HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE),
+       SND_PCI_QUIRK(0x144D, 0x3281, NULL,
+                     HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE),
+       SND_PCI_QUIRK(0x144D, 0xC002, NULL,
+                     HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE),
+       SND_PCI_QUIRK(0x144D, 0xC003, NULL,
+                     HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE),
+       SND_PCI_QUIRK(0x1509, 0x1740, NULL,
+                     HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE),
+       SND_PCI_QUIRK(0x1610, 0x0010, NULL,
+                     HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE),
+       SND_PCI_QUIRK(0x1042, 0x1042, NULL, HV_CTRL_ENABLE),
+       SND_PCI_QUIRK(0x107B, 0x9500, NULL, HV_CTRL_ENABLE),
+       SND_PCI_QUIRK(0x14FF, 0x0F06, NULL, HV_CTRL_ENABLE),
+       SND_PCI_QUIRK(0x1558, 0x8586, NULL, HV_CTRL_ENABLE),
+       SND_PCI_QUIRK(0x161F, 0x2011, NULL, HV_CTRL_ENABLE),
        /* Maestro3 chips */
-       { 0x125D, 0x1998, 0x103C, 0x000E, HV_CTRL_ENABLE, 0 },
-       { 0x125D, 0x1998, 0x103C, 0x0010, HV_CTRL_ENABLE, 1 }, /* HP OmniBook 6000 */
-       { 0x125D, 0x1998, 0x103C, 0x0011, HV_CTRL_ENABLE, 1 }, /* HP OmniBook 500 */
-       { 0x125D, 0x1998, 0x103C, 0x001B, HV_CTRL_ENABLE, 0 },
-       { 0x125D, 0x1998, 0x104D, 0x80A6, HV_CTRL_ENABLE, 0 },
-       { 0x125D, 0x1998, 0x104D, 0x80AA, HV_CTRL_ENABLE, 0 },
-       { 0x125D, 0x1998, 0x107B, 0x5300, HV_CTRL_ENABLE, 0 },
-       { 0x125D, 0x1998, 0x110A, 0x1998, HV_CTRL_ENABLE, 0 },
-       { 0x125D, 0x1998, 0x13BD, 0x1015, HV_CTRL_ENABLE, 0 },
-       { 0x125D, 0x1998, 0x13BD, 0x101C, HV_CTRL_ENABLE, 0 },
-       { 0x125D, 0x1998, 0x13BD, 0x1802, HV_CTRL_ENABLE, 0 },
-       { 0x125D, 0x1998, 0x1599, 0x0715, HV_CTRL_ENABLE, 0 },
-       { 0x125D, 0x1998, 0x5643, 0x5643, HV_CTRL_ENABLE, 0 },
-       { 0x125D, 0x199A, 0x144D, 0x3260, HV_CTRL_ENABLE | REDUCED_DEBOUNCE, 0 },
-       { 0x125D, 0x199A, 0x144D, 0x3261, HV_CTRL_ENABLE | REDUCED_DEBOUNCE, 0 },
-       { 0x125D, 0x199A, 0x144D, 0xC000, HV_CTRL_ENABLE | REDUCED_DEBOUNCE, 0 },
-       { 0x125D, 0x199A, 0x144D, 0xC001, HV_CTRL_ENABLE | REDUCED_DEBOUNCE, 0 },
-       { 0 }
+       SND_PCI_QUIRK(0x103C, 0x000E, NULL, HV_CTRL_ENABLE),
+       SND_PCI_QUIRK(0x103C, 0x0010, NULL, HV_CTRL_ENABLE),
+       SND_PCI_QUIRK(0x103C, 0x0011, NULL, HV_CTRL_ENABLE),
+       SND_PCI_QUIRK(0x103C, 0x001B, NULL, HV_CTRL_ENABLE),
+       SND_PCI_QUIRK(0x104D, 0x80A6, NULL, HV_CTRL_ENABLE),
+       SND_PCI_QUIRK(0x104D, 0x80AA, NULL, HV_CTRL_ENABLE),
+       SND_PCI_QUIRK(0x107B, 0x5300, NULL, HV_CTRL_ENABLE),
+       SND_PCI_QUIRK(0x110A, 0x1998, NULL, HV_CTRL_ENABLE),
+       SND_PCI_QUIRK(0x13BD, 0x1015, NULL, HV_CTRL_ENABLE),
+       SND_PCI_QUIRK(0x13BD, 0x101C, NULL, HV_CTRL_ENABLE),
+       SND_PCI_QUIRK(0x13BD, 0x1802, NULL, HV_CTRL_ENABLE),
+       SND_PCI_QUIRK(0x1599, 0x0715, NULL, HV_CTRL_ENABLE),
+       SND_PCI_QUIRK(0x5643, 0x5643, NULL, HV_CTRL_ENABLE),
+       SND_PCI_QUIRK(0x144D, 0x3260, NULL, HV_CTRL_ENABLE | REDUCED_DEBOUNCE),
+       SND_PCI_QUIRK(0x144D, 0x3261, NULL, HV_CTRL_ENABLE | REDUCED_DEBOUNCE),
+       SND_PCI_QUIRK(0x144D, 0xC000, NULL, HV_CTRL_ENABLE | REDUCED_DEBOUNCE),
+       SND_PCI_QUIRK(0x144D, 0xC001, NULL, HV_CTRL_ENABLE | REDUCED_DEBOUNCE),
+       { } /* END */
+};
+
+/* HP Omnibook quirks */
+static struct snd_pci_quirk m3_omnibook_quirk_list[] __devinitdata = {
+       SND_PCI_QUIRK_ID(0x103c, 0x0010), /* HP OmniBook 6000 */
+       SND_PCI_QUIRK_ID(0x103c, 0x0011), /* HP OmniBook 500 */
+       { } /* END */
 };
 
 /*
@@ -2050,7 +2019,7 @@ static void snd_m3_ac97_reset(struct snd_m3 *chip)
 
        for (i = 0; i < 5; i++) {
                dir = inw(io + GPIO_DIRECTION);
-               if (! chip->quirk || ! chip->quirk->irda_workaround)
+               if (!chip->irda_workaround)
                        dir |= 0x10; /* assuming pci bus master? */
 
                snd_m3_remote_codec_config(io, 0);
@@ -2132,6 +2101,10 @@ static int __devinit snd_m3_mixer(struct snd_m3 *chip)
 }
 
 
+#define FIRMWARE_IN_THE_KERNEL
+
+#ifdef FIRMWARE_IN_THE_KERNEL
+
 /*
  * DSP Code images
  */
@@ -2260,6 +2233,30 @@ static const u16 assp_minisrc_image[] = {
     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 
 };
 
+static const struct firmware assp_kernel = {
+       .data = (u8 *)assp_kernel_image,
+       .size = sizeof assp_kernel_image
+};
+static const struct firmware assp_minisrc = {
+       .data = (u8 *)assp_minisrc_image,
+       .size = sizeof assp_minisrc_image
+};
+
+#endif /* FIRMWARE_IN_THE_KERNEL */
+
+#ifdef __LITTLE_ENDIAN
+static inline void snd_m3_convert_from_le(const struct firmware *fw) { }
+#else
+static void snd_m3_convert_from_le(const struct firmware *fw)
+{
+       int i;
+       u16 *data = (u16 *)fw->data;
+
+       for (i = 0; i < fw->size / 2; ++i)
+               le16_to_cpus(&data[i]);
+}
+#endif
+
 
 /*
  * initialize ASSP
@@ -2274,6 +2271,7 @@ static const u16 minisrc_lpf[MINISRC_LPF_LEN] = {
 static void snd_m3_assp_init(struct snd_m3 *chip)
 {
        unsigned int i;
+       u16 *data;
 
        /* zero kernel data */
        for (i = 0; i < (REV_B_DATA_MEMORY_UNIT_LENGTH * NUM_UNITS_KERNEL_DATA) / 2; i++)
@@ -2291,10 +2289,10 @@ static void snd_m3_assp_init(struct snd_m3 *chip)
                          KDATA_DMA_XFER0);
 
        /* write kernel into code memory.. */
-       for (i = 0 ; i < ARRAY_SIZE(assp_kernel_image); i++) {
+       data = (u16 *)chip->assp_kernel_image->data;
+       for (i = 0 ; i * 2 < chip->assp_kernel_image->size; i++) {
                snd_m3_assp_write(chip, MEMTYPE_INTERNAL_CODE, 
-                                 REV_B_CODE_MEMORY_BEGIN + i, 
-                                 assp_kernel_image[i]);
+                                 REV_B_CODE_MEMORY_BEGIN + i, data[i]);
        }
 
        /*
@@ -2303,10 +2301,10 @@ static void snd_m3_assp_init(struct snd_m3 *chip)
         * drop it there.  It seems that the minisrc doesn't
         * need vectors, so we won't bother with them..
         */
-       for (i = 0; i < ARRAY_SIZE(assp_minisrc_image); i++) {
+       data = (u16 *)chip->assp_minisrc_image->data;
+       for (i = 0; i * 2 < chip->assp_minisrc_image->size; i++) {
                snd_m3_assp_write(chip, MEMTYPE_INTERNAL_CODE, 
-                                 0x400 + i, 
-                                 assp_minisrc_image[i]);
+                                 0x400 + i, data[i]);
        }
 
        /*
@@ -2444,7 +2442,7 @@ snd_m3_chip_init(struct snd_m3 *chip)
               DISABLE_LEGACY);
        pci_write_config_word(pcidev, PCI_LEGACY_AUDIO_CTRL, w);
 
-       if (chip->hv_quirk && chip->hv_quirk->is_omnibook) {
+       if (chip->is_omnibook) {
                /*
                 * Volume buttons on some HP OmniBook laptops don't work
                 * correctly. This makes them work for the most part.
@@ -2461,8 +2459,7 @@ snd_m3_chip_init(struct snd_m3 *chip)
        }
        pci_read_config_dword(pcidev, PCI_ALLEGRO_CONFIG, &n);
        n &= ~(HV_CTRL_ENABLE | REDUCED_DEBOUNCE | HV_BUTTON_FROM_GD);
-       if (chip->hv_quirk)
-               n |= chip->hv_quirk->config;
+       n |= chip->hv_config;
        /* For some reason we must always use reduced debounce. */
        n |= REDUCED_DEBOUNCE;
        n |= PM_CTRL_ENABLE | CLK_DIV_BY_49 | USE_PCI_TIMING;
@@ -2510,7 +2507,7 @@ snd_m3_enable_ints(struct snd_m3 *chip)
 
        /* TODO: MPU401 not supported yet */
        val = ASSP_INT_ENABLE /*| MPU401_INT_ENABLE*/;
-       if (chip->hv_quirk && (chip->hv_quirk->config & HV_CTRL_ENABLE))
+       if (chip->hv_config & HV_CTRL_ENABLE)
                val |= HV_INT_ENABLE;
        outw(val, io + HOST_INT_CTRL);
        outb(inb(io + ASSP_CONTROL_C) | ASSP_HOST_INT_ENABLE,
@@ -2553,6 +2550,15 @@ static int snd_m3_free(struct snd_m3 *chip)
        if (chip->iobase)
                pci_release_regions(chip->pci);
 
+#ifdef FIRMWARE_IN_THE_KERNEL
+       if (chip->assp_kernel_image != &assp_kernel)
+#endif
+               release_firmware(chip->assp_kernel_image);
+#ifdef FIRMWARE_IN_THE_KERNEL
+       if (chip->assp_minisrc_image != &assp_minisrc)
+#endif
+               release_firmware(chip->assp_minisrc_image);
+
        pci_disable_device(chip->pci);
        kfree(chip);
        return 0;
@@ -2665,8 +2671,7 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci,
 {
        struct snd_m3 *chip;
        int i, err;
-       const struct m3_quirk *quirk;
-       const struct m3_hv_quirk *hv_quirk;
+       const struct snd_pci_quirk *quirk;
        static struct snd_device_ops ops = {
                .dev_free =     snd_m3_dev_free,
        };
@@ -2706,34 +2711,32 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci,
        chip->pci = pci;
        chip->irq = -1;
 
-       for (quirk = m3_quirk_list; quirk->vendor; quirk++) {
-               if (pci->subsystem_vendor == quirk->vendor &&
-                   pci->subsystem_device == quirk->device) {
-                       printk(KERN_INFO "maestro3: enabled hack for '%s'\n", quirk->name);
-                       chip->quirk = quirk;
-                       break;
-               }
-       }
-
-       for (hv_quirk = m3_hv_quirk_list; hv_quirk->vendor; hv_quirk++) {
-               if (pci->vendor == hv_quirk->vendor &&
-                   pci->device == hv_quirk->device &&
-                   pci->subsystem_vendor == hv_quirk->subsystem_vendor &&
-                   pci->subsystem_device == hv_quirk->subsystem_device) {
-                       chip->hv_quirk = hv_quirk;
-                       break;
-               }
-       }
-
        chip->external_amp = enable_amp;
        if (amp_gpio >= 0 && amp_gpio <= 0x0f)
                chip->amp_gpio = amp_gpio;
-       else if (chip->quirk && chip->quirk->amp_gpio >= 0)
-               chip->amp_gpio = chip->quirk->amp_gpio;
-       else if (chip->allegro_flag)
-               chip->amp_gpio = GPO_EXT_AMP_ALLEGRO;
-       else /* presumably this is for all 'maestro3's.. */
-               chip->amp_gpio = GPO_EXT_AMP_M3;
+       else {
+               quirk = snd_pci_quirk_lookup(pci, m3_amp_quirk_list);
+               if (quirk) {
+                       snd_printdd(KERN_INFO "maestro3: set amp-gpio "
+                                   "for '%s'\n", quirk->name);
+                       chip->amp_gpio = quirk->value;
+               } else if (chip->allegro_flag)
+                       chip->amp_gpio = GPO_EXT_AMP_ALLEGRO;
+               else /* presumably this is for all 'maestro3's.. */
+                       chip->amp_gpio = GPO_EXT_AMP_M3;
+       }
+
+       quirk = snd_pci_quirk_lookup(pci, m3_irda_quirk_list);
+       if (quirk) {
+               snd_printdd(KERN_INFO "maestro3: enabled irda workaround "
+                           "for '%s'\n", quirk->name);
+               chip->irda_workaround = 1;
+       }
+       quirk = snd_pci_quirk_lookup(pci, m3_hv_quirk_list);
+       if (quirk)
+               chip->hv_config = quirk->value;
+       if (snd_pci_quirk_lookup(pci, m3_omnibook_quirk_list))
+               chip->is_omnibook = 1;
 
        chip->num_substreams = NR_DSPS;
        chip->substreams = kcalloc(chip->num_substreams, sizeof(struct m3_dma),
@@ -2744,6 +2747,30 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci,
                return -ENOMEM;
        }
 
+       err = request_firmware(&chip->assp_kernel_image,
+                              "ess/maestro3_assp_kernel.fw", &pci->dev);
+       if (err < 0) {
+#ifdef FIRMWARE_IN_THE_KERNEL
+               chip->assp_kernel_image = &assp_kernel;
+#else
+               snd_m3_free(chip);
+               return err;
+#endif
+       } else
+               snd_m3_convert_from_le(chip->assp_kernel_image);
+
+       err = request_firmware(&chip->assp_minisrc_image,
+                              "ess/maestro3_assp_minisrc.fw", &pci->dev);
+       if (err < 0) {
+#ifdef FIRMWARE_IN_THE_KERNEL
+               chip->assp_minisrc_image = &assp_minisrc;
+#else
+               snd_m3_free(chip);
+               return err;
+#endif
+       } else
+               snd_m3_convert_from_le(chip->assp_minisrc_image);
+
        if ((err = pci_request_regions(pci, card->driver)) < 0) {
                snd_m3_free(chip);
                return err;
index 13de0f71d4b74650f4bad2a85ba5032ba551c389..d7d15c036e02f3c9c29f74269cb2daac3b5e73f8 100644 (file)
@@ -389,7 +389,7 @@ static int mixart_analog_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_e
        return changed;
 }
 
-static DECLARE_TLV_DB_SCALE(db_scale_analog, -9600, 50, 0);
+static const DECLARE_TLV_DB_SCALE(db_scale_analog, -9600, 50, 0);
 
 static struct snd_kcontrol_new mixart_control_analog_level = {
        .iface =        SNDRV_CTL_ELEM_IFACE_MIXER,
@@ -872,7 +872,7 @@ static int mixart_pcm_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem
        return changed;
 }
 
-static DECLARE_TLV_DB_SCALE(db_scale_digital, -10950, 50, 0);
+static const DECLARE_TLV_DB_SCALE(db_scale_digital, -10950, 50, 0);
 
 static struct snd_kcontrol_new snd_mixart_pcm_vol =
 {
index 879e31a9f9c63937cc998cec1c2c7f646a8501ee..03b3a4792f7345923cf0812d289b64ff14b4a89f 100644 (file)
@@ -1628,23 +1628,15 @@ __error:
 }
 
 
-struct nm256_quirk {
-       unsigned short vendor;
-       unsigned short device;
-       int type;
-};
-
 enum { NM_BLACKLISTED, NM_RESET_WORKAROUND, NM_RESET_WORKAROUND_2 };
 
-static struct nm256_quirk nm256_quirks[] __devinitdata = {
+static struct snd_pci_quirk nm256_quirks[] __devinitdata = {
        /* HP omnibook 4150 has cs4232 codec internally */
-       { .vendor = 0x103c, .device = 0x0007, .type = NM_BLACKLISTED },
-       /* Sony PCG-F305 */
-       { .vendor = 0x104d, .device = 0x8041, .type = NM_RESET_WORKAROUND },
-       /* Dell Latitude LS */
-       { .vendor = 0x1028, .device = 0x0080, .type = NM_RESET_WORKAROUND },
-       /* Dell Latitude CSx */
-       { .vendor = 0x1028, .device = 0x0091, .type = NM_RESET_WORKAROUND_2 },
+       SND_PCI_QUIRK(0x103c, 0x0007, "HP omnibook 4150", NM_BLACKLISTED),
+       /* Reset workarounds to avoid lock-ups */
+       SND_PCI_QUIRK(0x104d, 0x8041, "Sony PCG-F305", NM_RESET_WORKAROUND),
+       SND_PCI_QUIRK(0x1028, 0x0080, "Dell Latitude LS", NM_RESET_WORKAROUND),
+       SND_PCI_QUIRK(0x1028, 0x0091, "Dell Latitude CSx", NM_RESET_WORKAROUND_2),
        { } /* terminator */
 };
 
@@ -1655,26 +1647,22 @@ static int __devinit snd_nm256_probe(struct pci_dev *pci,
        struct snd_card *card;
        struct nm256 *chip;
        int err;
-       struct nm256_quirk *q;
-       u16 subsystem_vendor, subsystem_device;
-
-       pci_read_config_word(pci, PCI_SUBSYSTEM_VENDOR_ID, &subsystem_vendor);
-       pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &subsystem_device);
-
-       for (q = nm256_quirks; q->vendor; q++) {
-               if (q->vendor == subsystem_vendor && q->device == subsystem_device) {
-                       switch (q->type) {
-                       case NM_BLACKLISTED:
-                               printk(KERN_INFO "nm256: The device is blacklisted. "
-                                      "Loading stopped\n");
-                               return -ENODEV;
-                       case NM_RESET_WORKAROUND_2:
-                               reset_workaround_2 = 1;
-                               /* Fall-through */
-                       case NM_RESET_WORKAROUND:
-                               reset_workaround = 1;
-                               break;
-                       }
+       const struct snd_pci_quirk *q;
+
+       q = snd_pci_quirk_lookup(pci, nm256_quirks);
+       if (q) {
+               snd_printdd(KERN_INFO "nm256: Enabled quirk for %s.\n", q->name);
+               switch (q->value) {
+               case NM_BLACKLISTED:
+                       printk(KERN_INFO "nm256: The device is blacklisted. "
+                              "Loading stopped\n");
+                       return -ENODEV;
+               case NM_RESET_WORKAROUND_2:
+                       reset_workaround_2 = 1;
+                       /* Fall-through */
+               case NM_RESET_WORKAROUND:
+                       reset_workaround = 1;
+                       break;
                }
        }
 
index b133ad9e095e20de0c36f764cf33e70e0e71b76f..d9cc8d2beb6d315f779b8fbabed1f476fca83cf7 100644 (file)
@@ -44,8 +44,8 @@
 #define PCXHR_ANALOG_PLAYBACK_LEVEL_MAX  128   /*    0.0 dB */
 #define PCXHR_ANALOG_PLAYBACK_ZERO_LEVEL 104   /*  -24.0 dB ( 0.0 dB - fix level +24.0 dB ) */
 
-static DECLARE_TLV_DB_SCALE(db_scale_analog_capture, -9600, 50, 0);
-static DECLARE_TLV_DB_SCALE(db_scale_analog_playback, -12800, 100, 0);
+static const DECLARE_TLV_DB_SCALE(db_scale_analog_capture, -9600, 50, 0);
+static const DECLARE_TLV_DB_SCALE(db_scale_analog_playback, -12800, 100, 0);
 
 static int pcxhr_update_analog_audio_level(struct snd_pcxhr *chip, int is_capture, int channel)
 {
@@ -195,7 +195,7 @@ static struct snd_kcontrol_new pcxhr_control_output_switch = {
 #define PCXHR_DIGITAL_LEVEL_MAX                0x1ff   /* +18 dB */
 #define PCXHR_DIGITAL_ZERO_LEVEL       0x1b7   /*  0 dB */
 
-static DECLARE_TLV_DB_SCALE(db_scale_digital, -10950, 50, 0);
+static const DECLARE_TLV_DB_SCALE(db_scale_digital, -10950, 50, 0);
 
 #define MORE_THAN_ONE_STREAM_LEVEL     0x000001
 #define VALID_STREAM_PAN_LEVEL_MASK    0x800000
index 6383987b460e388c6711a4962d8ff04b63f25d70..89b3c7ff5037ad85586d6a48db973a7532b158fe 100644 (file)
@@ -80,6 +80,7 @@ MODULE_SUPPORTED_DEVICE("{{RME Hammerfall-DSP},"
 /* Write registers. These are defined as byte-offsets from the iobase value.
  */
 #define HDSP_resetPointer               0
+#define HDSP_freqReg                   0
 #define HDSP_outputBufferAddress       32
 #define HDSP_inputBufferAddress                36
 #define HDSP_controlRegister           64
@@ -469,6 +470,7 @@ struct hdsp {
        struct pci_dev       *pci;
        struct snd_kcontrol *spdif_ctl;
         unsigned short        mixer_matrix[HDSP_MATRIX_MIXER_SIZE];
+       unsigned int          dds_value; /* last value written to freq register */
 };
 
 /* These tables map the ALSA channels 1..N to the channels that we
@@ -598,6 +600,7 @@ static int hdsp_playback_to_output_key (struct hdsp *hdsp, int in, int out)
                return (64 * out) + (32 + (in));
        case 0x96:
        case 0x97:
+       case 0x98:
                return (32 * out) + (16 + (in));
        default:
                return (52 * out) + (26 + (in));
@@ -611,6 +614,7 @@ static int hdsp_input_to_output_key (struct hdsp *hdsp, int in, int out)
                return (64 * out) + in;
        case 0x96:
        case 0x97:
+       case 0x98:
                return (32 * out) + in;
        default:
                return (52 * out) + in;
@@ -938,6 +942,11 @@ static snd_pcm_uframes_t hdsp_hw_pointer(struct hdsp *hdsp)
 static void hdsp_reset_hw_pointer(struct hdsp *hdsp)
 {
        hdsp_write (hdsp, HDSP_resetPointer, 0);
+       if (hdsp->io_type == H9632 && hdsp->firmware_rev >= 152)
+               /* HDSP_resetPointer = HDSP_freqReg, which is strange and
+                * requires (?) to write again DDS value after a reset pointer
+                * (at least, it works like this) */
+               hdsp_write (hdsp, HDSP_freqReg, hdsp->dds_value);
 }
 
 static void hdsp_start_audio(struct hdsp *s)
@@ -982,6 +991,30 @@ static int hdsp_set_interrupt_interval(struct hdsp *s, unsigned int frames)
        return 0;
 }
 
+static void hdsp_set_dds_value(struct hdsp *hdsp, int rate)
+{
+       u64 n;
+       u32 r;
+       
+       if (rate >= 112000)
+               rate /= 4;
+       else if (rate >= 56000)
+               rate /= 2;
+
+       /* RME says n = 104857600000000, but in the windows MADI driver, I see:
+//     return 104857600000000 / rate; // 100 MHz
+       return 110100480000000 / rate; // 105 MHz
+        */        
+       n = 104857600000000ULL;  /*  =  2^20 * 10^8 */
+       div64_32(&n, rate, &r);
+       /* n should be less than 2^32 for being written to FREQ register */
+       snd_assert((n >> 32) == 0);
+       /* HDSP_freqReg and HDSP_resetPointer are the same, so keep the DDS
+          value to write it after a reset */
+       hdsp->dds_value = n;
+       hdsp_write(hdsp, HDSP_freqReg, hdsp->dds_value);
+}
+
 static int hdsp_set_rate(struct hdsp *hdsp, int rate, int called_internally)
 {
        int reject_if_open = 0;
@@ -1090,6 +1123,10 @@ static int hdsp_set_rate(struct hdsp *hdsp, int rate, int called_internally)
        hdsp->control_register |= rate_bits;
        hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register);
 
+       /* For HDSP9632 rev 152, need to set DDS value in FREQ register */
+       if (hdsp->io_type == H9632 && hdsp->firmware_rev >= 152)
+               hdsp_set_dds_value(hdsp, rate);
+
        if (rate >= 128000) {
                hdsp->channel_map = channel_map_H9632_qs;
        } else if (rate > 48000) {
@@ -4943,6 +4980,7 @@ static int __devinit snd_hdsp_create(struct snd_card *card,
        hdsp->irq = pci->irq;
        hdsp->precise_ptr = 0;
        hdsp->use_midi_tasklet = 1;
+       hdsp->dds_value = 0;
 
        if ((err = snd_hdsp_initialize_memory(hdsp)) < 0)
                return err;
index 0547f6f04bdceb480eece1fb07351459e2a26761..e0215aca119364eff28261ab238a01e84a840963 100644 (file)
@@ -6,6 +6,8 @@
  *      code based on hdsp.c   Paul Davis
  *                             Marcus Andersson
  *                             Thomas Charbonnel
+ *      Modified 2006-06-01 for AES32 support by Remy Bruno
+ *                                               <remy.bruno@trinnov.com>
  *
  *   This program is free software; you can redistribute it and/or modify
  *   it under the terms of the GNU General Public License as published by
@@ -77,7 +79,8 @@ MODULE_PARM_DESC(enable_monitor,
 
 MODULE_AUTHOR
       ("Winfried Ritsch <ritsch_AT_iem.at>, Paul Davis <paul@linuxaudiosystems.com>, "
-       "Marcus Andersson, Thomas Charbonnel <thomas@undata.org>");
+       "Marcus Andersson, Thomas Charbonnel <thomas@undata.org>, "
+       "Remy Bruno <remy.bruno@trinnov.com>");
 MODULE_DESCRIPTION("RME HDSPM");
 MODULE_LICENSE("GPL");
 MODULE_SUPPORTED_DEVICE("{{RME HDSPM-MADI}}");
@@ -107,7 +110,12 @@ MODULE_SUPPORTED_DEVICE("{{RME HDSPM-MADI}}");
 /* --- Read registers. ---
    These are defined as byte-offsets from the iobase value */
 #define HDSPM_statusRegister    0
-#define HDSPM_statusRegister2  96
+/*#define HDSPM_statusRegister2  96 */
+/* after RME Windows driver sources, status2 is 4-byte word # 48 = word at
+ * offset 192, for AES32 *and* MADI
+ * => need to check that offset 192 is working on MADI */
+#define HDSPM_statusRegister2  192
+#define HDSPM_timecodeRegister 128
 
 #define HDSPM_midiDataIn0     360
 #define HDSPM_midiDataIn1     364
@@ -140,37 +148,50 @@ MODULE_SUPPORTED_DEVICE("{{RME HDSPM-MADI}}");
 #define HDSPM_Frequency0  (1<<6)  /* 0=44.1kHz/88.2kHz 1=48kHz/96kHz */
 #define HDSPM_Frequency1  (1<<7)  /* 0=32kHz/64kHz */
 #define HDSPM_DoubleSpeed (1<<8)  /* 0=normal speed, 1=double speed */
-#define HDSPM_QuadSpeed   (1<<31) /* quad speed bit, not implemented now */
+#define HDSPM_QuadSpeed   (1<<31) /* quad speed bit */
 
+#define HDSPM_Professional (1<<9) /* Professional */ /* AES32 ONLY */
 #define HDSPM_TX_64ch     (1<<10) /* Output 64channel MODE=1,
-                                    56channelMODE=0 */
+                                    56channelMODE=0 */ /* MADI ONLY*/
+#define HDSPM_Emphasis    (1<<10) /* Emphasis */ /* AES32 ONLY */
 
 #define HDSPM_AutoInp     (1<<11) /* Auto Input (takeover) == Safe Mode, 
-                                     0=off, 1=on  */
+                                     0=off, 1=on  */ /* MADI ONLY */
+#define HDSPM_Dolby       (1<<11) /* Dolby = "NonAudio" ?? */ /* AES32 ONLY */
 
-#define HDSPM_InputSelect0 (1<<14) /* Input select 0= optical, 1=coax */
+#define HDSPM_InputSelect0 (1<<14) /* Input select 0= optical, 1=coax */ /* MADI ONLY*/
 #define HDSPM_InputSelect1 (1<<15) /* should be 0 */
 
 #define HDSPM_SyncRef0     (1<<16) /* 0=WOrd, 1=MADI */
-#define HDSPM_SyncRef1     (1<<17) /* should be 0 */
+#define HDSPM_SyncRef1     (1<<17) /* for AES32: SyncRefN codes the AES # */
+#define HDSPM_SyncRef2     (1<<13)
+#define HDSPM_SyncRef3     (1<<25)
 
+#define HDSPM_SMUX         (1<<18) /* Frame ??? */ /* MADI ONY */
 #define HDSPM_clr_tms      (1<<19) /* clear track marker, do not use 
                                       AES additional bits in
                                      lower 5 Audiodatabits ??? */
+#define HDSPM_taxi_reset   (1<<20) /* ??? */ /* MADI ONLY ? */
+#define HDSPM_WCK48        (1<<20) /* Frame ??? = HDSPM_SMUX */ /* AES32 ONLY */
 
 #define HDSPM_Midi0InterruptEnable (1<<22)
 #define HDSPM_Midi1InterruptEnable (1<<23)
 
 #define HDSPM_LineOut (1<<24) /* Analog Out on channel 63/64 on=1, mute=0 */
 
+#define HDSPM_DS_DoubleWire (1<<26) /* AES32 ONLY */
+#define HDSPM_QS_DoubleWire (1<<27) /* AES32 ONLY */
+#define HDSPM_QS_QuadWire   (1<<28) /* AES32 ONLY */
+
+#define HDSPM_wclk_sel (1<<30)
 
 /* --- bit helper defines */
 #define HDSPM_LatencyMask    (HDSPM_Latency0|HDSPM_Latency1|HDSPM_Latency2)
-#define HDSPM_FrequencyMask  (HDSPM_Frequency0|HDSPM_Frequency1)
+#define HDSPM_FrequencyMask  (HDSPM_Frequency0|HDSPM_Frequency1|HDSPM_DoubleSpeed|HDSPM_QuadSpeed)
 #define HDSPM_InputMask      (HDSPM_InputSelect0|HDSPM_InputSelect1)
 #define HDSPM_InputOptical   0
 #define HDSPM_InputCoaxial   (HDSPM_InputSelect0)
-#define HDSPM_SyncRefMask    (HDSPM_SyncRef0|HDSPM_SyncRef1)
+#define HDSPM_SyncRefMask    (HDSPM_SyncRef0|HDSPM_SyncRef1|HDSPM_SyncRef2|HDSPM_SyncRef3)
 #define HDSPM_SyncRef_Word   0
 #define HDSPM_SyncRef_MADI   (HDSPM_SyncRef0)
 
@@ -183,6 +204,9 @@ MODULE_SUPPORTED_DEVICE("{{RME HDSPM-MADI}}");
 #define HDSPM_Frequency64KHz   (HDSPM_DoubleSpeed|HDSPM_Frequency0)
 #define HDSPM_Frequency88_2KHz (HDSPM_DoubleSpeed|HDSPM_Frequency1)
 #define HDSPM_Frequency96KHz   (HDSPM_DoubleSpeed|HDSPM_Frequency1|HDSPM_Frequency0)
+#define HDSPM_Frequency128KHz   (HDSPM_QuadSpeed|HDSPM_Frequency0)
+#define HDSPM_Frequency176_4KHz   (HDSPM_QuadSpeed|HDSPM_Frequency1)
+#define HDSPM_Frequency192KHz   (HDSPM_QuadSpeed|HDSPM_Frequency1|HDSPM_Frequency0)
 
 /* --- for internal discrimination */
 #define HDSPM_CLOCK_SOURCE_AUTOSYNC          0 /* Sample Clock Sources */
@@ -229,7 +253,8 @@ MODULE_SUPPORTED_DEVICE("{{RME HDSPM-MADI}}");
 #define HDSPM_BIGENDIAN_MODE  (1<<9)
 #define HDSPM_RD_MULTIPLE     (1<<10)
 
-/* --- Status Register bits --- */
+/* --- Status Register bits --- */ /* MADI ONLY */ /* Bits defined here and
+     that do not conflict with specific bits for AES32 seem to be valid also for the AES32 */
 #define HDSPM_audioIRQPending    (1<<0)        /* IRQ is high and pending */
 #define HDSPM_RX_64ch            (1<<1)        /* Input 64chan. MODE=1, 56chn. MODE=0 */
 #define HDSPM_AB_int             (1<<2)        /* InputChannel Opt=0, Coax=1 (like inp0) */
@@ -263,7 +288,7 @@ MODULE_SUPPORTED_DEVICE("{{RME HDSPM-MADI}}");
 #define HDSPM_madiFreq176_4 (HDSPM_madiFreq3)
 #define HDSPM_madiFreq192   (HDSPM_madiFreq3|HDSPM_madiFreq0)
 
-/* Status2 Register bits */
+/* Status2 Register bits */ /* MADI ONLY */
 
 #define HDSPM_version0 (1<<0)  /* not realy defined but I guess */
 #define HDSPM_version1 (1<<1)  /* in former cards it was ??? */
@@ -297,6 +322,56 @@ MODULE_SUPPORTED_DEVICE("{{RME HDSPM-MADI}}");
 #define HDSPM_SelSyncRef_MADI      (HDSPM_SelSyncRef0)
 #define HDSPM_SelSyncRef_NVALID    (HDSPM_SelSyncRef0|HDSPM_SelSyncRef1|HDSPM_SelSyncRef2)
 
+/*
+   For AES32, bits for status, status2 and timecode are different
+*/
+/* status */
+#define HDSPM_AES32_wcLock     0x0200000
+#define HDSPM_AES32_wcFreq_bit  22
+/* (status >> HDSPM_AES32_wcFreq_bit) & 0xF gives WC frequency (cf function 
+  HDSPM_bit2freq */
+#define HDSPM_AES32_syncref_bit  16
+/* (status >> HDSPM_AES32_syncref_bit) & 0xF gives sync source */
+
+#define HDSPM_AES32_AUTOSYNC_FROM_WORD 0
+#define HDSPM_AES32_AUTOSYNC_FROM_AES1 1
+#define HDSPM_AES32_AUTOSYNC_FROM_AES2 2
+#define HDSPM_AES32_AUTOSYNC_FROM_AES3 3
+#define HDSPM_AES32_AUTOSYNC_FROM_AES4 4
+#define HDSPM_AES32_AUTOSYNC_FROM_AES5 5
+#define HDSPM_AES32_AUTOSYNC_FROM_AES6 6
+#define HDSPM_AES32_AUTOSYNC_FROM_AES7 7
+#define HDSPM_AES32_AUTOSYNC_FROM_AES8 8
+#define HDSPM_AES32_AUTOSYNC_FROM_NONE -1
+
+/*  status2 */
+/* HDSPM_LockAES_bit is given by HDSPM_LockAES >> (AES# - 1) */
+#define HDSPM_LockAES   0x80
+#define HDSPM_LockAES1  0x80
+#define HDSPM_LockAES2  0x40
+#define HDSPM_LockAES3  0x20
+#define HDSPM_LockAES4  0x10
+#define HDSPM_LockAES5  0x8
+#define HDSPM_LockAES6  0x4
+#define HDSPM_LockAES7  0x2
+#define HDSPM_LockAES8  0x1
+/*
+   Timecode
+   After windows driver sources, bits 4*i to 4*i+3 give the input frequency on
+   AES i+1
+ bits 3210
+      0001  32kHz
+      0010  44.1kHz
+      0011  48kHz
+      0100  64kHz
+      0101  88.2kHz
+      0110  96kHz
+      0111  128kHz
+      1000  176.4kHz
+      1001  192kHz
+  NB: Timecode register doesn't seem to work on AES32 card revision 230
+*/
+
 /* Mixer Values */
 #define UNITY_GAIN          32768      /* = 65536/2 */
 #define MINUS_INFINITY_GAIN 0
@@ -314,10 +389,14 @@ MODULE_SUPPORTED_DEVICE("{{RME HDSPM-MADI}}");
    size is the same regardless of the number of channels, and
    also the latency to use. 
    for one direction !!!
+   => need to mupltiply by 2!!
 */
-#define HDSPM_DMA_AREA_BYTES (HDSPM_MAX_CHANNELS * HDSPM_CHANNEL_BUFFER_BYTES)
+#define HDSPM_DMA_AREA_BYTES (2 * HDSPM_MAX_CHANNELS * HDSPM_CHANNEL_BUFFER_BYTES)
 #define HDSPM_DMA_AREA_KILOBYTES (HDSPM_DMA_AREA_BYTES/1024)
 
+/* revisions >= 230 indicate AES32 card */
+#define HDSPM_AESREVISION 230
+
 struct hdspm_midi {
        struct hdspm *hdspm;
        int id;
@@ -336,7 +415,9 @@ struct hdspm {
         struct snd_pcm_substream *playback_substream; /* and/or capture stream */
 
        char *card_name;             /* for procinfo */
-       unsigned short firmware_rev; /* dont know if relevant */
+       unsigned short firmware_rev; /* dont know if relevant (yes if AES32)*/
+
+       unsigned char is_aes32;    /* indicates if card is AES32 */
 
        int precise_ptr;        /* use precise pointers, to be tested */
        int monitor_outs;       /* set up monitoring outs init flag */
@@ -453,6 +534,15 @@ static int snd_hdspm_set_defaults(struct hdspm * hdspm);
 static void hdspm_set_sgbuf(struct hdspm * hdspm, struct snd_sg_buf *sgbuf,
                             unsigned int reg, int channels);
 
+static inline int HDSPM_bit2freq(int n)
+{
+       static int bit2freq_tab[] = { 0, 32000, 44100, 48000, 64000, 88200,
+               96000, 128000, 176400, 192000 };
+       if (n < 1 || n > 9)
+               return 0;
+       return bit2freq_tab[n];
+}
+
 /* Write/read to/from HDSPM with Adresses in Bytes
    not words but only 32Bit writes are allowed */
 
@@ -544,86 +634,105 @@ static inline int snd_hdspm_use_is_exclusive(struct hdspm * hdspm)
 /* check for external sample rate */
 static inline int hdspm_external_sample_rate(struct hdspm * hdspm)
 {
-       unsigned int status2 = hdspm_read(hdspm, HDSPM_statusRegister2);
-       unsigned int status = hdspm_read(hdspm, HDSPM_statusRegister);
-       unsigned int rate_bits;
-       int rate = 0;
+       if (hdspm->is_aes32) {
+               unsigned int status2 = hdspm_read(hdspm, HDSPM_statusRegister2);
+               unsigned int status = hdspm_read(hdspm, HDSPM_statusRegister);
+               unsigned int timecode = hdspm_read(hdspm, HDSPM_timecodeRegister);
+
+               int syncref = hdspm_autosync_ref(hdspm);
+
+               if (syncref == HDSPM_AES32_AUTOSYNC_FROM_WORD &&
+                               status & HDSPM_AES32_wcLock)
+                       return HDSPM_bit2freq((status >> HDSPM_AES32_wcFreq_bit) & 0xF);
+               if (syncref >= HDSPM_AES32_AUTOSYNC_FROM_AES1 &&
+                       syncref <= HDSPM_AES32_AUTOSYNC_FROM_AES8 &&
+                       status2 & (HDSPM_LockAES >>
+                                 (syncref - HDSPM_AES32_AUTOSYNC_FROM_AES1)))
+                       return HDSPM_bit2freq((timecode >>
+                         (4*(syncref-HDSPM_AES32_AUTOSYNC_FROM_AES1))) & 0xF);
+               return 0;
+       } else {
+               unsigned int status2 = hdspm_read(hdspm, HDSPM_statusRegister2);
+               unsigned int status = hdspm_read(hdspm, HDSPM_statusRegister);
+               unsigned int rate_bits;
+               int rate = 0;
 
-       /* if wordclock has synced freq and wordclock is valid */
-       if ((status2 & HDSPM_wcLock) != 0 &&
-           (status & HDSPM_SelSyncRef0) == 0) {
+               /* if wordclock has synced freq and wordclock is valid */
+               if ((status2 & HDSPM_wcLock) != 0 &&
+                               (status & HDSPM_SelSyncRef0) == 0) {
 
-               rate_bits = status2 & HDSPM_wcFreqMask;
+                       rate_bits = status2 & HDSPM_wcFreqMask;
 
-               switch (rate_bits) {
-               case HDSPM_wcFreq32:
-                       rate = 32000;
-                       break;
-               case HDSPM_wcFreq44_1:
-                       rate = 44100;
-                       break;
-               case HDSPM_wcFreq48:
-                       rate = 48000;
-                       break;
-               case HDSPM_wcFreq64:
-                       rate = 64000;
-                       break;
-               case HDSPM_wcFreq88_2:
-                       rate = 88200;
-                       break;
-               case HDSPM_wcFreq96:
-                       rate = 96000;
-                       break;
-                       /* Quadspeed Bit missing ???? */
-               default:
-                       rate = 0;
-                       break;
+                       switch (rate_bits) {
+                       case HDSPM_wcFreq32:
+                               rate = 32000;
+                               break;
+                       case HDSPM_wcFreq44_1:
+                               rate = 44100;
+                               break;
+                       case HDSPM_wcFreq48:
+                               rate = 48000;
+                               break;
+                       case HDSPM_wcFreq64:
+                               rate = 64000;
+                               break;
+                       case HDSPM_wcFreq88_2:
+                               rate = 88200;
+                               break;
+                       case HDSPM_wcFreq96:
+                               rate = 96000;
+                               break;
+                               /* Quadspeed Bit missing ???? */
+                       default:
+                               rate = 0;
+                               break;
+                       }
                }
-       }
 
-       /* if rate detected and Syncref is Word than have it, word has priority to MADI */
-       if (rate != 0
-           && (status2 & HDSPM_SelSyncRefMask) == HDSPM_SelSyncRef_WORD)
-               return rate;
+               /* if rate detected and Syncref is Word than have it, word has priority to MADI */
+               if (rate != 0 &&
+                   (status2 & HDSPM_SelSyncRefMask) == HDSPM_SelSyncRef_WORD)
+                       return rate;
 
-       /* maby a madi input (which is taken if sel sync is madi) */
-       if (status & HDSPM_madiLock) {
-               rate_bits = status & HDSPM_madiFreqMask;
+               /* maby a madi input (which is taken if sel sync is madi) */
+               if (status & HDSPM_madiLock) {
+                       rate_bits = status & HDSPM_madiFreqMask;
 
-               switch (rate_bits) {
-               case HDSPM_madiFreq32:
-                       rate = 32000;
-                       break;
-               case HDSPM_madiFreq44_1:
-                       rate = 44100;
-                       break;
-               case HDSPM_madiFreq48:
-                       rate = 48000;
-                       break;
-               case HDSPM_madiFreq64:
-                       rate = 64000;
-                       break;
-               case HDSPM_madiFreq88_2:
-                       rate = 88200;
-                       break;
-               case HDSPM_madiFreq96:
-                       rate = 96000;
-                       break;
-               case HDSPM_madiFreq128:
-                       rate = 128000;
-                       break;
-               case HDSPM_madiFreq176_4:
-                       rate = 176400;
-                       break;
-               case HDSPM_madiFreq192:
-                       rate = 192000;
-                       break;
-               default:
-                       rate = 0;
-                       break;
+                       switch (rate_bits) {
+                       case HDSPM_madiFreq32:
+                               rate = 32000;
+                               break;
+                       case HDSPM_madiFreq44_1:
+                               rate = 44100;
+                               break;
+                       case HDSPM_madiFreq48:
+                               rate = 48000;
+                               break;
+                       case HDSPM_madiFreq64:
+                               rate = 64000;
+                               break;
+                       case HDSPM_madiFreq88_2:
+                               rate = 88200;
+                               break;
+                       case HDSPM_madiFreq96:
+                               rate = 96000;
+                               break;
+                       case HDSPM_madiFreq128:
+                               rate = 128000;
+                               break;
+                       case HDSPM_madiFreq176_4:
+                               rate = 176400;
+                               break;
+                       case HDSPM_madiFreq192:
+                               rate = 192000;
+                               break;
+                       default:
+                               rate = 0;
+                               break;
+                       }
                }
+               return rate;
        }
-       return rate;
 }
 
 /* Latency function */
@@ -676,7 +785,8 @@ static inline void hdspm_silence_playback(struct hdspm * hdspm)
        int n = hdspm->period_bytes;
        void *buf = hdspm->playback_buffer;
 
-       snd_assert(buf != NULL, return);
+       if (buf == NULL)
+               return;
 
        for (i = 0; i < HDSPM_MAX_CHANNELS; i++) {
                memset(buf, 0, n);
@@ -716,6 +826,7 @@ static int hdspm_set_rate(struct hdspm * hdspm, int rate, int called_internally)
        int current_rate;
        int rate_bits;
        int not_set = 0;
+       int is_single, is_double, is_quad;
 
        /* ASSUMPTION: hdspm->lock is either set, or there is no need for
           it (e.g. during module initialization).
@@ -766,43 +877,56 @@ static int hdspm_set_rate(struct hdspm * hdspm, int rate, int called_internally)
           changes in the read/write routines.  
         */
 
+       is_single = (current_rate <= 48000);
+       is_double = (current_rate > 48000 && current_rate <= 96000);
+       is_quad = (current_rate > 96000);
+
        switch (rate) {
        case 32000:
-               if (current_rate > 48000) {
+               if (!is_single)
                        reject_if_open = 1;
-               }
                rate_bits = HDSPM_Frequency32KHz;
                break;
        case 44100:
-               if (current_rate > 48000) {
+               if (!is_single)
                        reject_if_open = 1;
-               }
                rate_bits = HDSPM_Frequency44_1KHz;
                break;
        case 48000:
-               if (current_rate > 48000) {
+               if (!is_single)
                        reject_if_open = 1;
-               }
                rate_bits = HDSPM_Frequency48KHz;
                break;
        case 64000:
-               if (current_rate <= 48000) {
+               if (!is_double)
                        reject_if_open = 1;
-               }
                rate_bits = HDSPM_Frequency64KHz;
                break;
        case 88200:
-               if (current_rate <= 48000) {
+               if (!is_double)
                        reject_if_open = 1;
-               }
                rate_bits = HDSPM_Frequency88_2KHz;
                break;
        case 96000:
-               if (current_rate <= 48000) {
+               if (!is_double)
                        reject_if_open = 1;
-               }
                rate_bits = HDSPM_Frequency96KHz;
                break;
+       case 128000:
+               if (!is_quad)
+                       reject_if_open = 1;
+               rate_bits = HDSPM_Frequency128KHz;
+               break;
+       case 176400:
+               if (!is_quad)
+                       reject_if_open = 1;
+               rate_bits = HDSPM_Frequency176_4KHz;
+               break;
+       case 192000:
+               if (!is_quad)
+                       reject_if_open = 1;
+               rate_bits = HDSPM_Frequency192KHz;
+               break;
        default:
                return -EINVAL;
        }
@@ -819,7 +943,7 @@ static int hdspm_set_rate(struct hdspm * hdspm, int rate, int called_internally)
        hdspm->control_register |= rate_bits;
        hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register);
 
-       if (rate > 64000)
+       if (rate > 96000 /* 64000*/)
                hdspm->channel_map = channel_map_madi_qs;
        else if (rate > 48000)
                hdspm->channel_map = channel_map_madi_ds;
@@ -1455,11 +1579,27 @@ static int hdspm_pref_sync_ref(struct hdspm * hdspm)
        /* Notice that this looks at the requested sync source,
           not the one actually in use.
         */
-       switch (hdspm->control_register & HDSPM_SyncRefMask) {
-       case HDSPM_SyncRef_Word:
-               return HDSPM_SYNC_FROM_WORD;
-       case HDSPM_SyncRef_MADI:
-               return HDSPM_SYNC_FROM_MADI;
+       if (hdspm->is_aes32) {
+               switch (hdspm->control_register & HDSPM_SyncRefMask) {
+               /* number gives AES index, except for 0 which
+                  corresponds to WordClock */
+               case 0: return 0;
+               case HDSPM_SyncRef0: return 1;
+               case HDSPM_SyncRef1: return 2;
+               case HDSPM_SyncRef1+HDSPM_SyncRef0: return 3;
+               case HDSPM_SyncRef2: return 4;
+               case HDSPM_SyncRef2+HDSPM_SyncRef0: return 5;
+               case HDSPM_SyncRef2+HDSPM_SyncRef1: return 6;
+               case HDSPM_SyncRef2+HDSPM_SyncRef1+HDSPM_SyncRef0: return 7;
+               case HDSPM_SyncRef3: return 8;
+               }
+       } else {
+               switch (hdspm->control_register & HDSPM_SyncRefMask) {
+               case HDSPM_SyncRef_Word:
+                       return HDSPM_SYNC_FROM_WORD;
+               case HDSPM_SyncRef_MADI:
+                       return HDSPM_SYNC_FROM_MADI;
+               }
        }
 
        return HDSPM_SYNC_FROM_WORD;
@@ -1469,15 +1609,49 @@ static int hdspm_set_pref_sync_ref(struct hdspm * hdspm, int pref)
 {
        hdspm->control_register &= ~HDSPM_SyncRefMask;
 
-       switch (pref) {
-       case HDSPM_SYNC_FROM_MADI:
-               hdspm->control_register |= HDSPM_SyncRef_MADI;
-               break;
-       case HDSPM_SYNC_FROM_WORD:
-               hdspm->control_register |= HDSPM_SyncRef_Word;
-               break;
-       default:
-               return -1;
+       if (hdspm->is_aes32) {
+               switch (pref) {
+               case 0:
+                      hdspm->control_register |= 0;
+                      break;
+               case 1:
+                      hdspm->control_register |= HDSPM_SyncRef0;
+                      break;
+               case 2:
+                      hdspm->control_register |= HDSPM_SyncRef1;
+                      break;
+               case 3:
+                      hdspm->control_register |= HDSPM_SyncRef1+HDSPM_SyncRef0;
+                      break;
+               case 4:
+                      hdspm->control_register |= HDSPM_SyncRef2;
+                      break;
+               case 5:
+                      hdspm->control_register |= HDSPM_SyncRef2+HDSPM_SyncRef0;
+                      break;
+               case 6:
+                      hdspm->control_register |= HDSPM_SyncRef2+HDSPM_SyncRef1;
+                      break;
+               case 7:
+                      hdspm->control_register |= HDSPM_SyncRef2+HDSPM_SyncRef1+HDSPM_SyncRef0;
+                      break;
+               case 8:
+                      hdspm->control_register |= HDSPM_SyncRef3;
+                      break;
+               default:
+                      return -1;
+               }
+       } else {
+               switch (pref) {
+               case HDSPM_SYNC_FROM_MADI:
+                       hdspm->control_register |= HDSPM_SyncRef_MADI;
+                       break;
+               case HDSPM_SYNC_FROM_WORD:
+                       hdspm->control_register |= HDSPM_SyncRef_Word;
+                       break;
+               default:
+                       return -1;
+               }
        }
        hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register);
        return 0;
@@ -1486,18 +1660,36 @@ static int hdspm_set_pref_sync_ref(struct hdspm * hdspm, int pref)
 static int snd_hdspm_info_pref_sync_ref(struct snd_kcontrol *kcontrol,
                                        struct snd_ctl_elem_info *uinfo)
 {
-       static char *texts[] = { "Word", "MADI" };
+       struct hdspm *hdspm = snd_kcontrol_chip(kcontrol);
 
-       uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
-       uinfo->count = 1;
+       if (hdspm->is_aes32) {
+               static char *texts[] = { "Word", "AES1", "AES2", "AES3",
+                       "AES4", "AES5", "AES6", "AES7", "AES8" };
 
-       uinfo->value.enumerated.items = 2;
+               uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
+               uinfo->count = 1;
 
-       if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
-               uinfo->value.enumerated.item =
-                   uinfo->value.enumerated.items - 1;
-       strcpy(uinfo->value.enumerated.name,
-              texts[uinfo->value.enumerated.item]);
+               uinfo->value.enumerated.items = 9;
+
+               if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
+                       uinfo->value.enumerated.item =
+                               uinfo->value.enumerated.items - 1;
+               strcpy(uinfo->value.enumerated.name,
+                               texts[uinfo->value.enumerated.item]);
+       } else {
+               static char *texts[] = { "Word", "MADI" };
+
+               uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
+               uinfo->count = 1;
+
+               uinfo->value.enumerated.items = 2;
+
+               if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
+                       uinfo->value.enumerated.item =
+                               uinfo->value.enumerated.items - 1;
+               strcpy(uinfo->value.enumerated.name,
+                               texts[uinfo->value.enumerated.item]);
+       }
        return 0;
 }
 
@@ -1517,7 +1709,7 @@ static int snd_hdspm_put_pref_sync_ref(struct snd_kcontrol *kcontrol,
        int change, max;
        unsigned int val;
 
-       max = 2;
+       max = hdspm->is_aes32 ? 9 : 2;
 
        if (!snd_hdspm_use_is_exclusive(hdspm))
                return -EBUSY;
@@ -1542,40 +1734,64 @@ static int snd_hdspm_put_pref_sync_ref(struct snd_kcontrol *kcontrol,
 
 static int hdspm_autosync_ref(struct hdspm * hdspm)
 {
-       /* This looks at the autosync selected sync reference */
-       unsigned int status2 = hdspm_read(hdspm, HDSPM_statusRegister2);
-
-       switch (status2 & HDSPM_SelSyncRefMask) {
-
-       case HDSPM_SelSyncRef_WORD:
-               return HDSPM_AUTOSYNC_FROM_WORD;
-
-       case HDSPM_SelSyncRef_MADI:
-               return HDSPM_AUTOSYNC_FROM_MADI;
-
-       case HDSPM_SelSyncRef_NVALID:
-               return HDSPM_AUTOSYNC_FROM_NONE;
+       if (hdspm->is_aes32) {
+               unsigned int status = hdspm_read(hdspm, HDSPM_statusRegister);
+               unsigned int syncref = (status >> HDSPM_AES32_syncref_bit) & 0xF;
+               if (syncref == 0)
+                       return HDSPM_AES32_AUTOSYNC_FROM_WORD;
+               if (syncref <= 8)
+                       return syncref;
+               return HDSPM_AES32_AUTOSYNC_FROM_NONE;
+       } else {
+               /* This looks at the autosync selected sync reference */
+               unsigned int status2 = hdspm_read(hdspm, HDSPM_statusRegister2);
+
+               switch (status2 & HDSPM_SelSyncRefMask) {
+               case HDSPM_SelSyncRef_WORD:
+                       return HDSPM_AUTOSYNC_FROM_WORD;
+               case HDSPM_SelSyncRef_MADI:
+                       return HDSPM_AUTOSYNC_FROM_MADI;
+               case HDSPM_SelSyncRef_NVALID:
+                       return HDSPM_AUTOSYNC_FROM_NONE;
+               default:
+                       return 0;
+               }
 
-       default:
                return 0;
        }
-
-       return 0;
 }
 
 static int snd_hdspm_info_autosync_ref(struct snd_kcontrol *kcontrol,
                                       struct snd_ctl_elem_info *uinfo)
 {
-       static char *texts[] = { "WordClock", "MADI", "None" };
+       struct hdspm *hdspm = snd_kcontrol_chip(kcontrol);
 
-       uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
-       uinfo->count = 1;
-       uinfo->value.enumerated.items = 3;
-       if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
-               uinfo->value.enumerated.item =
-                   uinfo->value.enumerated.items - 1;
-       strcpy(uinfo->value.enumerated.name,
-              texts[uinfo->value.enumerated.item]);
+       if (hdspm->is_aes32) {
+               static char *texts[] = { "WordClock", "AES1", "AES2", "AES3",
+                       "AES4", "AES5", "AES6", "AES7", "AES8", "None"};
+
+               uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
+               uinfo->count = 1;
+               uinfo->value.enumerated.items = 10;
+               if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
+                       uinfo->value.enumerated.item =
+                               uinfo->value.enumerated.items - 1;
+               strcpy(uinfo->value.enumerated.name,
+                               texts[uinfo->value.enumerated.item]);
+       }
+       else
+       {
+               static char *texts[] = { "WordClock", "MADI", "None" };
+
+               uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
+               uinfo->count = 1;
+               uinfo->value.enumerated.items = 3;
+               if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
+                       uinfo->value.enumerated.item =
+                               uinfo->value.enumerated.items - 1;
+               strcpy(uinfo->value.enumerated.name,
+                               texts[uinfo->value.enumerated.item]);
+       }
        return 0;
 }
 
@@ -1787,45 +2003,376 @@ static int snd_hdspm_put_c_tms(struct snd_kcontrol *kcontrol,
   .put = snd_hdspm_put_safe_mode \
 }
 
-static int hdspm_safe_mode(struct hdspm * hdspm)
+static int hdspm_safe_mode(struct hdspm * hdspm)
+{
+       return (hdspm->control_register & HDSPM_AutoInp) ? 1 : 0;
+}
+
+static int hdspm_set_safe_mode(struct hdspm * hdspm, int out)
+{
+       if (out)
+               hdspm->control_register |= HDSPM_AutoInp;
+       else
+               hdspm->control_register &= ~HDSPM_AutoInp;
+       hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register);
+
+       return 0;
+}
+
+static int snd_hdspm_info_safe_mode(struct snd_kcontrol *kcontrol,
+                                   struct snd_ctl_elem_info *uinfo)
+{
+       uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
+       uinfo->count = 1;
+       uinfo->value.integer.min = 0;
+       uinfo->value.integer.max = 1;
+       return 0;
+}
+
+static int snd_hdspm_get_safe_mode(struct snd_kcontrol *kcontrol,
+                                  struct snd_ctl_elem_value *ucontrol)
+{
+       struct hdspm *hdspm = snd_kcontrol_chip(kcontrol);
+
+       spin_lock_irq(&hdspm->lock);
+       ucontrol->value.integer.value[0] = hdspm_safe_mode(hdspm);
+       spin_unlock_irq(&hdspm->lock);
+       return 0;
+}
+
+static int snd_hdspm_put_safe_mode(struct snd_kcontrol *kcontrol,
+                                  struct snd_ctl_elem_value *ucontrol)
+{
+       struct hdspm *hdspm = snd_kcontrol_chip(kcontrol);
+       int change;
+       unsigned int val;
+
+       if (!snd_hdspm_use_is_exclusive(hdspm))
+               return -EBUSY;
+       val = ucontrol->value.integer.value[0] & 1;
+       spin_lock_irq(&hdspm->lock);
+       change = (int) val != hdspm_safe_mode(hdspm);
+       hdspm_set_safe_mode(hdspm, val);
+       spin_unlock_irq(&hdspm->lock);
+       return change;
+}
+
+#define HDSPM_EMPHASIS(xname, xindex) \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
+  .name = xname, \
+  .index = xindex, \
+  .info = snd_hdspm_info_emphasis, \
+  .get = snd_hdspm_get_emphasis, \
+  .put = snd_hdspm_put_emphasis \
+}
+
+static int hdspm_emphasis(struct hdspm * hdspm)
+{
+       return (hdspm->control_register & HDSPM_Emphasis) ? 1 : 0;
+}
+
+static int hdspm_set_emphasis(struct hdspm * hdspm, int emp)
+{
+       if (emp)
+               hdspm->control_register |= HDSPM_Emphasis;
+       else
+               hdspm->control_register &= ~HDSPM_Emphasis;
+       hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register);
+
+       return 0;
+}
+
+static int snd_hdspm_info_emphasis(struct snd_kcontrol *kcontrol,
+                                  struct snd_ctl_elem_info *uinfo)
+{
+       uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
+       uinfo->count = 1;
+       uinfo->value.integer.min = 0;
+       uinfo->value.integer.max = 1;
+       return 0;
+}
+
+static int snd_hdspm_get_emphasis(struct snd_kcontrol *kcontrol,
+                                 struct snd_ctl_elem_value *ucontrol)
+{
+       struct hdspm *hdspm = snd_kcontrol_chip(kcontrol);
+
+       spin_lock_irq(&hdspm->lock);
+       ucontrol->value.enumerated.item[0] = hdspm_emphasis(hdspm);
+       spin_unlock_irq(&hdspm->lock);
+       return 0;
+}
+
+static int snd_hdspm_put_emphasis(struct snd_kcontrol *kcontrol,
+                                 struct snd_ctl_elem_value *ucontrol)
+{
+       struct hdspm *hdspm = snd_kcontrol_chip(kcontrol);
+       int change;
+       unsigned int val;
+
+       if (!snd_hdspm_use_is_exclusive(hdspm))
+               return -EBUSY;
+       val = ucontrol->value.integer.value[0] & 1;
+       spin_lock_irq(&hdspm->lock);
+       change = (int) val != hdspm_emphasis(hdspm);
+       hdspm_set_emphasis(hdspm, val);
+       spin_unlock_irq(&hdspm->lock);
+       return change;
+}
+
+#define HDSPM_DOLBY(xname, xindex) \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
+  .name = xname, \
+  .index = xindex, \
+  .info = snd_hdspm_info_dolby, \
+  .get = snd_hdspm_get_dolby, \
+  .put = snd_hdspm_put_dolby \
+}
+
+static int hdspm_dolby(struct hdspm * hdspm)
+{
+       return (hdspm->control_register & HDSPM_Dolby) ? 1 : 0;
+}
+
+static int hdspm_set_dolby(struct hdspm * hdspm, int dol)
+{
+       if (dol)
+               hdspm->control_register |= HDSPM_Dolby;
+       else
+               hdspm->control_register &= ~HDSPM_Dolby;
+       hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register);
+
+       return 0;
+}
+
+static int snd_hdspm_info_dolby(struct snd_kcontrol *kcontrol,
+                               struct snd_ctl_elem_info *uinfo)
+{
+       uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
+       uinfo->count = 1;
+       uinfo->value.integer.min = 0;
+       uinfo->value.integer.max = 1;
+       return 0;
+}
+
+static int snd_hdspm_get_dolby(struct snd_kcontrol *kcontrol,
+                              struct snd_ctl_elem_value *ucontrol)
+{
+       struct hdspm *hdspm = snd_kcontrol_chip(kcontrol);
+
+       spin_lock_irq(&hdspm->lock);
+       ucontrol->value.enumerated.item[0] = hdspm_dolby(hdspm);
+       spin_unlock_irq(&hdspm->lock);
+       return 0;
+}
+
+static int snd_hdspm_put_dolby(struct snd_kcontrol *kcontrol,
+                              struct snd_ctl_elem_value *ucontrol)
+{
+       struct hdspm *hdspm = snd_kcontrol_chip(kcontrol);
+       int change;
+       unsigned int val;
+
+       if (!snd_hdspm_use_is_exclusive(hdspm))
+               return -EBUSY;
+       val = ucontrol->value.integer.value[0] & 1;
+       spin_lock_irq(&hdspm->lock);
+       change = (int) val != hdspm_dolby(hdspm);
+       hdspm_set_dolby(hdspm, val);
+       spin_unlock_irq(&hdspm->lock);
+       return change;
+}
+
+#define HDSPM_PROFESSIONAL(xname, xindex) \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
+  .name = xname, \
+  .index = xindex, \
+  .info = snd_hdspm_info_professional, \
+  .get = snd_hdspm_get_professional, \
+  .put = snd_hdspm_put_professional \
+}
+
+static int hdspm_professional(struct hdspm * hdspm)
+{
+       return (hdspm->control_register & HDSPM_Professional) ? 1 : 0;
+}
+
+static int hdspm_set_professional(struct hdspm * hdspm, int dol)
+{
+       if (dol)
+               hdspm->control_register |= HDSPM_Professional;
+       else
+               hdspm->control_register &= ~HDSPM_Professional;
+       hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register);
+
+       return 0;
+}
+
+static int snd_hdspm_info_professional(struct snd_kcontrol *kcontrol,
+                                      struct snd_ctl_elem_info *uinfo)
+{
+       uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
+       uinfo->count = 1;
+       uinfo->value.integer.min = 0;
+       uinfo->value.integer.max = 1;
+       return 0;
+}
+
+static int snd_hdspm_get_professional(struct snd_kcontrol *kcontrol,
+                                     struct snd_ctl_elem_value *ucontrol)
+{
+       struct hdspm *hdspm = snd_kcontrol_chip(kcontrol);
+
+       spin_lock_irq(&hdspm->lock);
+       ucontrol->value.enumerated.item[0] = hdspm_professional(hdspm);
+       spin_unlock_irq(&hdspm->lock);
+       return 0;
+}
+
+static int snd_hdspm_put_professional(struct snd_kcontrol *kcontrol,
+                                     struct snd_ctl_elem_value *ucontrol)
+{
+       struct hdspm *hdspm = snd_kcontrol_chip(kcontrol);
+       int change;
+       unsigned int val;
+
+       if (!snd_hdspm_use_is_exclusive(hdspm))
+               return -EBUSY;
+       val = ucontrol->value.integer.value[0] & 1;
+       spin_lock_irq(&hdspm->lock);
+       change = (int) val != hdspm_professional(hdspm);
+       hdspm_set_professional(hdspm, val);
+       spin_unlock_irq(&hdspm->lock);
+       return change;
+}
+
+#define HDSPM_INPUT_SELECT(xname, xindex) \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
+  .name = xname, \
+  .index = xindex, \
+  .info = snd_hdspm_info_input_select, \
+  .get = snd_hdspm_get_input_select, \
+  .put = snd_hdspm_put_input_select \
+}
+
+static int hdspm_input_select(struct hdspm * hdspm)
+{
+       return (hdspm->control_register & HDSPM_InputSelect0) ? 1 : 0;
+}
+
+static int hdspm_set_input_select(struct hdspm * hdspm, int out)
+{
+       if (out)
+               hdspm->control_register |= HDSPM_InputSelect0;
+       else
+               hdspm->control_register &= ~HDSPM_InputSelect0;
+       hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register);
+
+       return 0;
+}
+
+static int snd_hdspm_info_input_select(struct snd_kcontrol *kcontrol,
+                                      struct snd_ctl_elem_info *uinfo)
+{
+       static char *texts[] = { "optical", "coaxial" };
+
+       uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
+       uinfo->count = 1;
+       uinfo->value.enumerated.items = 2;
+
+       if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
+               uinfo->value.enumerated.item =
+                   uinfo->value.enumerated.items - 1;
+       strcpy(uinfo->value.enumerated.name,
+              texts[uinfo->value.enumerated.item]);
+
+       return 0;
+}
+
+static int snd_hdspm_get_input_select(struct snd_kcontrol *kcontrol,
+                                     struct snd_ctl_elem_value *ucontrol)
+{
+       struct hdspm *hdspm = snd_kcontrol_chip(kcontrol);
+
+       spin_lock_irq(&hdspm->lock);
+       ucontrol->value.enumerated.item[0] = hdspm_input_select(hdspm);
+       spin_unlock_irq(&hdspm->lock);
+       return 0;
+}
+
+static int snd_hdspm_put_input_select(struct snd_kcontrol *kcontrol,
+                                     struct snd_ctl_elem_value *ucontrol)
+{
+       struct hdspm *hdspm = snd_kcontrol_chip(kcontrol);
+       int change;
+       unsigned int val;
+
+       if (!snd_hdspm_use_is_exclusive(hdspm))
+               return -EBUSY;
+       val = ucontrol->value.integer.value[0] & 1;
+       spin_lock_irq(&hdspm->lock);
+       change = (int) val != hdspm_input_select(hdspm);
+       hdspm_set_input_select(hdspm, val);
+       spin_unlock_irq(&hdspm->lock);
+       return change;
+}
+
+#define HDSPM_DS_WIRE(xname, xindex) \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
+  .name = xname, \
+  .index = xindex, \
+  .info = snd_hdspm_info_ds_wire, \
+  .get = snd_hdspm_get_ds_wire, \
+  .put = snd_hdspm_put_ds_wire \
+}
+
+static int hdspm_ds_wire(struct hdspm * hdspm)
 {
-       return (hdspm->control_register & HDSPM_AutoInp) ? 1 : 0;
+       return (hdspm->control_register & HDSPM_DS_DoubleWire) ? 1 : 0;
 }
 
-static int hdspm_set_safe_mode(struct hdspm * hdspm, int out)
+static int hdspm_set_ds_wire(struct hdspm * hdspm, int ds)
 {
-       if (out)
-               hdspm->control_register |= HDSPM_AutoInp;
+       if (ds)
+               hdspm->control_register |= HDSPM_DS_DoubleWire;
        else
-               hdspm->control_register &= ~HDSPM_AutoInp;
+               hdspm->control_register &= ~HDSPM_DS_DoubleWire;
        hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register);
 
        return 0;
 }
 
-static int snd_hdspm_info_safe_mode(struct snd_kcontrol *kcontrol,
-                                   struct snd_ctl_elem_info *uinfo)
+static int snd_hdspm_info_ds_wire(struct snd_kcontrol *kcontrol,
+                                 struct snd_ctl_elem_info *uinfo)
 {
-       uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
+       static char *texts[] = { "Single", "Double" };
+
+       uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
        uinfo->count = 1;
-       uinfo->value.integer.min = 0;
-       uinfo->value.integer.max = 1;
+       uinfo->value.enumerated.items = 2;
+
+       if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
+               uinfo->value.enumerated.item =
+                   uinfo->value.enumerated.items - 1;
+       strcpy(uinfo->value.enumerated.name,
+              texts[uinfo->value.enumerated.item]);
+
        return 0;
 }
 
-static int snd_hdspm_get_safe_mode(struct snd_kcontrol *kcontrol,
-                                  struct snd_ctl_elem_value *ucontrol)
+static int snd_hdspm_get_ds_wire(struct snd_kcontrol *kcontrol,
+                                struct snd_ctl_elem_value *ucontrol)
 {
        struct hdspm *hdspm = snd_kcontrol_chip(kcontrol);
 
        spin_lock_irq(&hdspm->lock);
-       ucontrol->value.integer.value[0] = hdspm_safe_mode(hdspm);
+       ucontrol->value.enumerated.item[0] = hdspm_ds_wire(hdspm);
        spin_unlock_irq(&hdspm->lock);
        return 0;
 }
 
-static int snd_hdspm_put_safe_mode(struct snd_kcontrol *kcontrol,
-                                  struct snd_ctl_elem_value *ucontrol)
+static int snd_hdspm_put_ds_wire(struct snd_kcontrol *kcontrol,
+                                struct snd_ctl_elem_value *ucontrol)
 {
        struct hdspm *hdspm = snd_kcontrol_chip(kcontrol);
        int change;
@@ -1835,45 +2382,56 @@ static int snd_hdspm_put_safe_mode(struct snd_kcontrol *kcontrol,
                return -EBUSY;
        val = ucontrol->value.integer.value[0] & 1;
        spin_lock_irq(&hdspm->lock);
-       change = (int) val != hdspm_safe_mode(hdspm);
-       hdspm_set_safe_mode(hdspm, val);
+       change = (int) val != hdspm_ds_wire(hdspm);
+       hdspm_set_ds_wire(hdspm, val);
        spin_unlock_irq(&hdspm->lock);
        return change;
 }
 
-#define HDSPM_INPUT_SELECT(xname, xindex) \
+#define HDSPM_QS_WIRE(xname, xindex) \
 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
   .name = xname, \
   .index = xindex, \
-  .info = snd_hdspm_info_input_select, \
-  .get = snd_hdspm_get_input_select, \
-  .put = snd_hdspm_put_input_select \
+  .info = snd_hdspm_info_qs_wire, \
+  .get = snd_hdspm_get_qs_wire, \
+  .put = snd_hdspm_put_qs_wire \
 }
 
-static int hdspm_input_select(struct hdspm * hdspm)
+static int hdspm_qs_wire(struct hdspm * hdspm)
 {
-       return (hdspm->control_register & HDSPM_InputSelect0) ? 1 : 0;
+       if (hdspm->control_register & HDSPM_QS_DoubleWire)
+               return 1;
+       if (hdspm->control_register & HDSPM_QS_QuadWire)
+               return 2;
+       return 0;
 }
 
-static int hdspm_set_input_select(struct hdspm * hdspm, int out)
+static int hdspm_set_qs_wire(struct hdspm * hdspm, int mode)
 {
-       if (out)
-               hdspm->control_register |= HDSPM_InputSelect0;
-       else
-               hdspm->control_register &= ~HDSPM_InputSelect0;
+       hdspm->control_register &= ~(HDSPM_QS_DoubleWire | HDSPM_QS_QuadWire);
+       switch (mode) {
+       case 0:
+               break;
+       case 1:
+               hdspm->control_register |= HDSPM_QS_DoubleWire;
+               break;
+       case 2:
+               hdspm->control_register |= HDSPM_QS_QuadWire;
+               break;
+       }
        hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register);
 
        return 0;
 }
 
-static int snd_hdspm_info_input_select(struct snd_kcontrol *kcontrol,
+static int snd_hdspm_info_qs_wire(struct snd_kcontrol *kcontrol,
                                       struct snd_ctl_elem_info *uinfo)
 {
-       static char *texts[] = { "optical", "coaxial" };
+       static char *texts[] = { "Single", "Double", "Quad" };
 
        uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
        uinfo->count = 1;
-       uinfo->value.enumerated.items = 2;
+       uinfo->value.enumerated.items = 3;
 
        if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
                uinfo->value.enumerated.item =
@@ -1884,30 +2442,34 @@ static int snd_hdspm_info_input_select(struct snd_kcontrol *kcontrol,
        return 0;
 }
 
-static int snd_hdspm_get_input_select(struct snd_kcontrol *kcontrol,
+static int snd_hdspm_get_qs_wire(struct snd_kcontrol *kcontrol,
                                      struct snd_ctl_elem_value *ucontrol)
 {
        struct hdspm *hdspm = snd_kcontrol_chip(kcontrol);
 
        spin_lock_irq(&hdspm->lock);
-       ucontrol->value.enumerated.item[0] = hdspm_input_select(hdspm);
+       ucontrol->value.enumerated.item[0] = hdspm_qs_wire(hdspm);
        spin_unlock_irq(&hdspm->lock);
        return 0;
 }
 
-static int snd_hdspm_put_input_select(struct snd_kcontrol *kcontrol,
+static int snd_hdspm_put_qs_wire(struct snd_kcontrol *kcontrol,
                                      struct snd_ctl_elem_value *ucontrol)
 {
        struct hdspm *hdspm = snd_kcontrol_chip(kcontrol);
        int change;
-       unsigned int val;
+       int val;
 
        if (!snd_hdspm_use_is_exclusive(hdspm))
                return -EBUSY;
-       val = ucontrol->value.integer.value[0] & 1;
+       val = ucontrol->value.integer.value[0];
+       if (val < 0)
+               val = 0;
+       if (val > 2)
+               val = 2;
        spin_lock_irq(&hdspm->lock);
-       change = (int) val != hdspm_input_select(hdspm);
-       hdspm_set_input_select(hdspm, val);
+       change = (int) val != hdspm_qs_wire(hdspm);
+       hdspm_set_qs_wire(hdspm, val);
        spin_unlock_irq(&hdspm->lock);
        return change;
 }
@@ -2135,14 +2697,24 @@ static int snd_hdspm_info_sync_check(struct snd_kcontrol *kcontrol,
 
 static int hdspm_wc_sync_check(struct hdspm * hdspm)
 {
-       int status2 = hdspm_read(hdspm, HDSPM_statusRegister2);
-       if (status2 & HDSPM_wcLock) {
-               if (status2 & HDSPM_wcSync)
+       if (hdspm->is_aes32) {
+               int status = hdspm_read(hdspm, HDSPM_statusRegister);
+               if (status & HDSPM_AES32_wcLock) {
+                       /* I don't know how to differenciate sync from lock.
+                          Doing as if sync for now */
                        return 2;
-               else
-                       return 1;
+               }
+               return 0;
+       } else {
+               int status2 = hdspm_read(hdspm, HDSPM_statusRegister2);
+               if (status2 & HDSPM_wcLock) {
+                       if (status2 & HDSPM_wcSync)
+                               return 2;
+                       else
+                               return 1;
+               }
+               return 0;
        }
-       return 0;
 }
 
 static int snd_hdspm_get_wc_sync_check(struct snd_kcontrol *kcontrol,
@@ -2188,9 +2760,43 @@ static int snd_hdspm_get_madisync_sync_check(struct snd_kcontrol *kcontrol,
 }
 
 
+#define HDSPM_AES_SYNC_CHECK(xname, xindex) \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
+  .name = xname, \
+  .index = xindex, \
+  .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, \
+  .info = snd_hdspm_info_sync_check, \
+  .get = snd_hdspm_get_aes_sync_check \
+}
+
+static int hdspm_aes_sync_check(struct hdspm * hdspm, int idx)
+{
+       int status2 = hdspm_read(hdspm, HDSPM_statusRegister2);
+       if (status2 & (HDSPM_LockAES >> idx)) {
+               /* I don't know how to differenciate sync from lock.
+                  Doing as if sync for now */
+               return 2;
+       }
+       return 0;
+}
+
+static int snd_hdspm_get_aes_sync_check(struct snd_kcontrol *kcontrol,
+                                       struct snd_ctl_elem_value *ucontrol)
+{
+       int offset;
+       struct hdspm *hdspm = snd_kcontrol_chip(kcontrol);
+
+       offset = ucontrol->id.index - 1;
+       if (offset < 0 || offset >= 8)
+               return -EINVAL;
+
+       ucontrol->value.enumerated.item[0] =
+               hdspm_aes_sync_check(hdspm, offset);
+       return 0;
+}
 
 
-static struct snd_kcontrol_new snd_hdspm_controls[] = {
+static struct snd_kcontrol_new snd_hdspm_controls_madi[] = {
 
        HDSPM_MIXER("Mixer", 0),
 /* 'Sample Clock Source' complies with the alsa control naming scheme */
@@ -2211,6 +2817,29 @@ static struct snd_kcontrol_new snd_hdspm_controls[] = {
        HDSPM_INPUT_SELECT("Input Select", 0),
 };
 
+static struct snd_kcontrol_new snd_hdspm_controls_aes32[] = {
+
+       HDSPM_MIXER("Mixer", 0),
+/* 'Sample Clock Source' complies with the alsa control naming scheme */
+       HDSPM_CLOCK_SOURCE("Sample Clock Source", 0),
+
+       HDSPM_SYSTEM_CLOCK_MODE("System Clock Mode", 0),
+       HDSPM_PREF_SYNC_REF("Preferred Sync Reference", 0),
+       HDSPM_AUTOSYNC_REF("AutoSync Reference", 0),
+       HDSPM_SYSTEM_SAMPLE_RATE("System Sample Rate", 0),
+/* 'External Rate' complies with the alsa control naming scheme */
+       HDSPM_AUTOSYNC_SAMPLE_RATE("External Rate", 0),
+       HDSPM_WC_SYNC_CHECK("Word Clock Lock Status", 0),
+/*     HDSPM_AES_SYNC_CHECK("AES Lock Status", 0),*/ /* created in snd_hdspm_create_controls() */
+       HDSPM_LINE_OUT("Line Out", 0),
+       HDSPM_EMPHASIS("Emphasis", 0),
+       HDSPM_DOLBY("Non Audio", 0),
+       HDSPM_PROFESSIONAL("Professional", 0),
+       HDSPM_C_TMS("Clear Track Marker", 0),
+       HDSPM_DS_WIRE("Double Speed Wire Mode", 0),
+       HDSPM_QS_WIRE("Quad Speed Wire Mode", 0),
+};
+
 static struct snd_kcontrol_new snd_hdspm_playback_mixer = HDSPM_PLAYBACK_MIXER;
 
 
@@ -2245,20 +2874,40 @@ static int snd_hdspm_create_controls(struct snd_card *card, struct hdspm * hdspm
        struct snd_kcontrol *kctl;
 
        /* add control list first */
-
-       for (idx = 0; idx < ARRAY_SIZE(snd_hdspm_controls); idx++) {
-               if ((err =
-                    snd_ctl_add(card, kctl =
-                                snd_ctl_new1(&snd_hdspm_controls[idx],
-                                             hdspm))) < 0) {
-                       return err;
+       if (hdspm->is_aes32) {
+               struct snd_kcontrol_new aes_sync_ctl =
+                       HDSPM_AES_SYNC_CHECK("AES Lock Status", 0);
+
+               for (idx = 0; idx < ARRAY_SIZE(snd_hdspm_controls_aes32);
+                    idx++) {
+                       err = snd_ctl_add(card,
+                                         snd_ctl_new1(&snd_hdspm_controls_aes32[idx],
+                                                      hdspm));
+                       if (err < 0)
+                               return err;
+               }
+               for (idx = 1; idx <= 8; idx++) {
+                       aes_sync_ctl.index = idx;
+                       err = snd_ctl_add(card,
+                                         snd_ctl_new1(&aes_sync_ctl, hdspm));
+                       if (err < 0)
+                               return err;
+               }
+       } else {
+               for (idx = 0; idx < ARRAY_SIZE(snd_hdspm_controls_madi);
+                    idx++) {
+                       err = snd_ctl_add(card,
+                                         snd_ctl_new1(&snd_hdspm_controls_madi[idx],
+                                                      hdspm));
+                       if (err < 0)
+                               return err;
                }
        }
 
        /* Channel playback mixer as default control 
-          Note: the whole matrix would be 128*HDSPM_MIXER_CHANNELS Faders, thats too big for any alsamixer
-          they are accesible via special IOCTL on hwdep
-          and the mixer 2dimensional mixer control */
+Note: the whole matrix would be 128*HDSPM_MIXER_CHANNELS Faders, thats too big for any alsamixer
+they are accesible via special IOCTL on hwdep
+and the mixer 2dimensional mixer control */
 
        snd_hdspm_playback_mixer.name = "Chn";
        limit = HDSPM_MAX_CHANNELS;
@@ -2289,7 +2938,8 @@ static int snd_hdspm_create_controls(struct snd_card *card, struct hdspm * hdspm
  ------------------------------------------------------------*/
 
 static void
-snd_hdspm_proc_read(struct snd_info_entry * entry, struct snd_info_buffer *buffer)
+snd_hdspm_proc_read_madi(struct snd_info_entry * entry,
+                        struct snd_info_buffer *buffer)
 {
        struct hdspm *hdspm = (struct hdspm *) entry->private_data;
        unsigned int status;
@@ -2420,11 +3070,10 @@ snd_hdspm_proc_read(struct snd_info_entry * entry, struct snd_info_buffer *buffe
                clock_source = "Error";
        }
        snd_iprintf(buffer, "Sample Clock Source: %s\n", clock_source);
-       if (!(hdspm->control_register & HDSPM_ClockModeMaster)) {
+       if (!(hdspm->control_register & HDSPM_ClockModeMaster))
                system_clock_mode = "Slave";
-       } else {
+       else
                system_clock_mode = "Master";
-       }
        snd_iprintf(buffer, "System Clock Mode: %s\n", system_clock_mode);
 
        switch (hdspm_pref_sync_ref(hdspm)) {
@@ -2484,13 +3133,213 @@ snd_hdspm_proc_read(struct snd_info_entry * entry, struct snd_info_buffer *buffe
        snd_iprintf(buffer, "\n");
 }
 
+static void
+snd_hdspm_proc_read_aes32(struct snd_info_entry * entry,
+                         struct snd_info_buffer *buffer)
+{
+       struct hdspm *hdspm = (struct hdspm *) entry->private_data;
+       unsigned int status;
+       unsigned int status2;
+       unsigned int timecode;
+       int pref_syncref;
+       char *autosync_ref;
+       char *system_clock_mode;
+       char *clock_source;
+       int x;
+
+       status = hdspm_read(hdspm, HDSPM_statusRegister);
+       status2 = hdspm_read(hdspm, HDSPM_statusRegister2);
+       timecode = hdspm_read(hdspm, HDSPM_timecodeRegister);
+
+       snd_iprintf(buffer, "%s (Card #%d) Rev.%x\n",
+                   hdspm->card_name, hdspm->card->number + 1,
+                   hdspm->firmware_rev);
+
+       snd_iprintf(buffer, "IRQ: %d Registers bus: 0x%lx VM: 0x%lx\n",
+                   hdspm->irq, hdspm->port, (unsigned long)hdspm->iobase);
+
+       snd_iprintf(buffer, "--- System ---\n");
+
+       snd_iprintf(buffer,
+                   "IRQ Pending: Audio=%d, MIDI0=%d, MIDI1=%d, IRQcount=%d\n",
+                   status & HDSPM_audioIRQPending,
+                   (status & HDSPM_midi0IRQPending) ? 1 : 0,
+                   (status & HDSPM_midi1IRQPending) ? 1 : 0,
+                   hdspm->irq_count);
+       snd_iprintf(buffer,
+                   "HW pointer: id = %d, rawptr = %d (%d->%d) estimated= %ld (bytes)\n",
+                   ((status & HDSPM_BufferID) ? 1 : 0),
+                   (status & HDSPM_BufferPositionMask),
+                   (status & HDSPM_BufferPositionMask) % (2 *
+                                                          (int)hdspm->
+                                                          period_bytes),
+                   ((status & HDSPM_BufferPositionMask) -
+                    64) % (2 * (int)hdspm->period_bytes),
+                   (long) hdspm_hw_pointer(hdspm) * 4);
+
+       snd_iprintf(buffer,
+                   "MIDI FIFO: Out1=0x%x, Out2=0x%x, In1=0x%x, In2=0x%x \n",
+                   hdspm_read(hdspm, HDSPM_midiStatusOut0) & 0xFF,
+                   hdspm_read(hdspm, HDSPM_midiStatusOut1) & 0xFF,
+                   hdspm_read(hdspm, HDSPM_midiStatusIn0) & 0xFF,
+                   hdspm_read(hdspm, HDSPM_midiStatusIn1) & 0xFF);
+       snd_iprintf(buffer,
+                   "Register: ctrl1=0x%x, ctrl2=0x%x, status1=0x%x, status2=0x%x, timecode=0x%x\n",
+                   hdspm->control_register, hdspm->control2_register,
+                   status, status2, timecode);
+
+       snd_iprintf(buffer, "--- Settings ---\n");
+
+       x = 1 << (6 +
+                 hdspm_decode_latency(hdspm->
+                                      control_register &
+                                      HDSPM_LatencyMask));
+
+       snd_iprintf(buffer,
+                   "Size (Latency): %d samples (2 periods of %lu bytes)\n",
+                   x, (unsigned long) hdspm->period_bytes);
+
+       snd_iprintf(buffer, "Line out: %s,   Precise Pointer: %s\n",
+                   (hdspm->
+                    control_register & HDSPM_LineOut) ? "on " : "off",
+                   (hdspm->precise_ptr) ? "on" : "off");
+
+       snd_iprintf(buffer,
+                   "ClearTrackMarker %s, Emphasis %s, Dolby %s\n",
+                   (hdspm->
+                    control_register & HDSPM_clr_tms) ? "on" : "off",
+                   (hdspm->
+                    control_register & HDSPM_Emphasis) ? "on" : "off",
+                   (hdspm->
+                    control_register & HDSPM_Dolby) ? "on" : "off");
+
+       switch (hdspm_clock_source(hdspm)) {
+       case HDSPM_CLOCK_SOURCE_AUTOSYNC:
+               clock_source = "AutoSync";
+               break;
+       case HDSPM_CLOCK_SOURCE_INTERNAL_32KHZ:
+               clock_source = "Internal 32 kHz";
+               break;
+       case HDSPM_CLOCK_SOURCE_INTERNAL_44_1KHZ:
+               clock_source = "Internal 44.1 kHz";
+               break;
+       case HDSPM_CLOCK_SOURCE_INTERNAL_48KHZ:
+               clock_source = "Internal 48 kHz";
+               break;
+       case HDSPM_CLOCK_SOURCE_INTERNAL_64KHZ:
+               clock_source = "Internal 64 kHz";
+               break;
+       case HDSPM_CLOCK_SOURCE_INTERNAL_88_2KHZ:
+               clock_source = "Internal 88.2 kHz";
+               break;
+       case HDSPM_CLOCK_SOURCE_INTERNAL_96KHZ:
+               clock_source = "Internal 96 kHz";
+               break;
+       case HDSPM_CLOCK_SOURCE_INTERNAL_128KHZ:
+               clock_source = "Internal 128 kHz";
+               break;
+       case HDSPM_CLOCK_SOURCE_INTERNAL_176_4KHZ:
+               clock_source = "Internal 176.4 kHz";
+               break;
+       case HDSPM_CLOCK_SOURCE_INTERNAL_192KHZ:
+               clock_source = "Internal 192 kHz";
+               break;
+       default:
+               clock_source = "Error";
+       }
+       snd_iprintf(buffer, "Sample Clock Source: %s\n", clock_source);
+       if (!(hdspm->control_register & HDSPM_ClockModeMaster))
+               system_clock_mode = "Slave";
+       else
+               system_clock_mode = "Master";
+       snd_iprintf(buffer, "System Clock Mode: %s\n", system_clock_mode);
+
+       pref_syncref = hdspm_pref_sync_ref(hdspm);
+       if (pref_syncref == 0)
+               snd_iprintf(buffer, "Preferred Sync Reference: Word Clock\n");
+       else
+               snd_iprintf(buffer, "Preferred Sync Reference: AES%d\n",
+                               pref_syncref);
+
+       snd_iprintf(buffer, "System Clock Frequency: %d\n",
+                   hdspm->system_sample_rate);
+
+       snd_iprintf(buffer, "Double speed: %s\n",
+                       hdspm->control_register & HDSPM_DS_DoubleWire?
+                       "Double wire" : "Single wire");
+       snd_iprintf(buffer, "Quad speed: %s\n",
+                       hdspm->control_register & HDSPM_QS_DoubleWire?
+                       "Double wire" :
+                       hdspm->control_register & HDSPM_QS_QuadWire?
+                       "Quad wire" : "Single wire");
+
+       snd_iprintf(buffer, "--- Status:\n");
+
+       snd_iprintf(buffer, "Word: %s  Frequency: %d\n",
+                       (status & HDSPM_AES32_wcLock)? "Sync   " : "No Lock",
+                       HDSPM_bit2freq((status >> HDSPM_AES32_wcFreq_bit) & 0xF));
+
+       for (x = 0; x < 8; x++) {
+               snd_iprintf(buffer, "AES%d: %s  Frequency: %d\n",
+                               x+1,
+                               (status2 & (HDSPM_LockAES >> x))? "Sync   ": "No Lock",
+                               HDSPM_bit2freq((timecode >> (4*x)) & 0xF));
+       }
+
+       switch (hdspm_autosync_ref(hdspm)) {
+       case HDSPM_AES32_AUTOSYNC_FROM_NONE: autosync_ref="None"; break;
+       case HDSPM_AES32_AUTOSYNC_FROM_WORD: autosync_ref="Word Clock"; break;
+       case HDSPM_AES32_AUTOSYNC_FROM_AES1: autosync_ref="AES1"; break;
+       case HDSPM_AES32_AUTOSYNC_FROM_AES2: autosync_ref="AES2"; break;
+       case HDSPM_AES32_AUTOSYNC_FROM_AES3: autosync_ref="AES3"; break;
+       case HDSPM_AES32_AUTOSYNC_FROM_AES4: autosync_ref="AES4"; break;
+       case HDSPM_AES32_AUTOSYNC_FROM_AES5: autosync_ref="AES5"; break;
+       case HDSPM_AES32_AUTOSYNC_FROM_AES6: autosync_ref="AES6"; break;
+       case HDSPM_AES32_AUTOSYNC_FROM_AES7: autosync_ref="AES7"; break;
+       case HDSPM_AES32_AUTOSYNC_FROM_AES8: autosync_ref="AES8"; break;
+       default: autosync_ref = "---"; break;
+       }
+       snd_iprintf(buffer, "AutoSync ref = %s\n", autosync_ref);
+
+       snd_iprintf(buffer, "\n");
+}
+
+#ifdef CONFIG_SND_DEBUG
+static void
+snd_hdspm_proc_read_debug(struct snd_info_entry * entry,
+                         struct snd_info_buffer *buffer)
+{
+       struct hdspm *hdspm = (struct hdspm *)entry->private_data;
+
+       int j,i;
+
+       for (i = 0; i < 256 /* 1024*64 */; i += j)
+       {
+               snd_iprintf(buffer, "0x%08X: ", i);
+               for (j = 0; j < 16; j += 4)
+                       snd_iprintf(buffer, "%08X ", hdspm_read(hdspm, i + j));
+               snd_iprintf(buffer, "\n");
+       }
+}
+#endif
+
+
+
 static void __devinit snd_hdspm_proc_init(struct hdspm * hdspm)
 {
        struct snd_info_entry *entry;
 
        if (!snd_card_proc_new(hdspm->card, "hdspm", &entry))
                snd_info_set_text_ops(entry, hdspm,
-                                     snd_hdspm_proc_read);
+                                     hdspm->is_aes32 ?
+                                     snd_hdspm_proc_read_aes32 :
+                                     snd_hdspm_proc_read_madi);
+#ifdef CONFIG_SND_DEBUG
+       /* debug file to read all hdspm registers */
+       if (!snd_card_proc_new(hdspm->card, "debug", &entry))
+               snd_info_set_text_ops(entry, hdspm,
+                               snd_hdspm_proc_read_debug);
+#endif
 }
 
 /*------------------------------------------------------------
@@ -2507,13 +3356,20 @@ static int snd_hdspm_set_defaults(struct hdspm * hdspm)
 
        /* set defaults:       */
 
-       hdspm->control_register = HDSPM_ClockModeMaster |       /* Master Cloack Mode on */
-           hdspm_encode_latency(7) |   /* latency maximum = 8192 samples */
-           HDSPM_InputCoaxial |        /* Input Coax not Optical */
-           HDSPM_SyncRef_MADI |        /* Madi is syncclock */
-           HDSPM_LineOut |     /* Analog output in */
-           HDSPM_TX_64ch |     /* transmit in 64ch mode */
-           HDSPM_AutoInp;      /* AutoInput chossing (takeover) */
+       if (hdspm->is_aes32)
+               hdspm->control_register = HDSPM_ClockModeMaster |       /* Master Cloack Mode on */
+                       hdspm_encode_latency(7) |       /* latency maximum = 8192 samples */
+                       HDSPM_SyncRef0 |        /* AES1 is syncclock */
+                       HDSPM_LineOut | /* Analog output in */
+                       HDSPM_Professional;  /* Professional mode */
+       else
+               hdspm->control_register = HDSPM_ClockModeMaster |       /* Master Cloack Mode on */
+                       hdspm_encode_latency(7) |       /* latency maximum = 8192 samples */
+                       HDSPM_InputCoaxial |    /* Input Coax not Optical */
+                       HDSPM_SyncRef_MADI |    /* Madi is syncclock */
+                       HDSPM_LineOut | /* Analog output in */
+                       HDSPM_TX_64ch | /* transmit in 64ch mode */
+                       HDSPM_AutoInp;  /* AutoInput chossing (takeover) */
 
        /* ! HDSPM_Frequency0|HDSPM_Frequency1 = 44.1khz */
        /* !  HDSPM_DoubleSpeed HDSPM_QuadSpeed = normal speed */
@@ -2822,6 +3678,8 @@ static int snd_hdspm_hw_params(struct snd_pcm_substream *substream,
 
                hdspm->playback_buffer =
                    (unsigned char *) substream->runtime->dma_area;
+               snd_printdd("Allocated sample buffer for playback at %p\n",
+                               hdspm->playback_buffer);
        } else {
                hdspm_set_sgbuf(hdspm, sgbuf, HDSPM_pageAddressBufferIn,
                                params_channels(params));
@@ -2831,7 +3689,15 @@ static int snd_hdspm_hw_params(struct snd_pcm_substream *substream,
 
                hdspm->capture_buffer =
                    (unsigned char *) substream->runtime->dma_area;
+               snd_printdd("Allocated sample buffer for capture at %p\n",
+                               hdspm->capture_buffer);
        }
+       /*
+          snd_printdd("Allocated sample buffer for %s at 0x%08X\n",
+          substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
+          "playback" : "capture",
+          snd_pcm_sgbuf_get_addr(sgbuf, 0));
+        */
        return 0;
 }
 
@@ -2982,9 +3848,10 @@ static struct snd_pcm_hardware snd_hdspm_playback_subinfo = {
                  SNDRV_PCM_RATE_44100 |
                  SNDRV_PCM_RATE_48000 |
                  SNDRV_PCM_RATE_64000 |
-                 SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000),
+                 SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 |
+                 SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_192000 ),
        .rate_min = 32000,
-       .rate_max = 96000,
+       .rate_max = 192000,
        .channels_min = 1,
        .channels_max = HDSPM_MAX_CHANNELS,
        .buffer_bytes_max =
@@ -3006,9 +3873,10 @@ static struct snd_pcm_hardware snd_hdspm_capture_subinfo = {
                  SNDRV_PCM_RATE_44100 |
                  SNDRV_PCM_RATE_48000 |
                  SNDRV_PCM_RATE_64000 |
-                 SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000),
+                 SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 |
+                 SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_192000),
        .rate_min = 32000,
-       .rate_max = 96000,
+       .rate_max = 192000,
        .channels_min = 1,
        .channels_max = HDSPM_MAX_CHANNELS,
        .buffer_bytes_max =
@@ -3315,7 +4183,8 @@ static int __devinit snd_hdspm_preallocate_memory(struct hdspm * hdspm)
 
        pcm = hdspm->pcm;
 
-       wanted = HDSPM_DMA_AREA_BYTES + 4096;   /* dont know why, but it works */
+/*     wanted = HDSPM_DMA_AREA_BYTES + 4096;*/ /* dont know why, but it works */
+       wanted = HDSPM_DMA_AREA_BYTES;
 
        if ((err =
             snd_pcm_lib_preallocate_pages_for_all(pcm,
@@ -3467,9 +4336,16 @@ static int __devinit snd_hdspm_create(struct snd_card *card, struct hdspm * hdsp
        pci_read_config_word(hdspm->pci,
                             PCI_CLASS_REVISION, &hdspm->firmware_rev);
 
-       strcpy(card->driver, "HDSPM");
+       hdspm->is_aes32 = (hdspm->firmware_rev >= HDSPM_AESREVISION);
+
        strcpy(card->mixername, "Xilinx FPGA");
-       hdspm->card_name = "RME HDSPM MADI";
+       if (hdspm->is_aes32) {
+               strcpy(card->driver, "HDSPAES32");
+               hdspm->card_name = "RME HDSPM AES32";
+       } else {
+               strcpy(card->driver, "HDSPM");
+               hdspm->card_name = "RME HDSPM MADI";
+       }
 
        if ((err = pci_enable_device(pci)) < 0)
                return err;
index 474f2d451ae800dca606c003fc7e3ed1b2fd22b5..3bff32167f6617a13be87b4d215e43f8bf4e1c99 100644 (file)
@@ -2627,7 +2627,7 @@ static int snd_trident_vol_control_get(struct snd_kcontrol *kcontrol,
        return 0;
 }
 
-static DECLARE_TLV_DB_SCALE(db_scale_gvol, -6375, 25, 0);
+static const DECLARE_TLV_DB_SCALE(db_scale_gvol, -6375, 25, 0);
 
 static int snd_trident_vol_control_put(struct snd_kcontrol *kcontrol,
                                       struct snd_ctl_elem_value *ucontrol)
@@ -2844,7 +2844,7 @@ static int snd_trident_pcm_rvol_control_put(struct snd_kcontrol *kcontrol,
        return change;
 }
 
-static DECLARE_TLV_DB_SCALE(db_scale_crvol, -3175, 25, 1);
+static const DECLARE_TLV_DB_SCALE(db_scale_crvol, -3175, 25, 1);
 
 static struct snd_kcontrol_new snd_trident_pcm_rvol_control __devinitdata =
 {
index a572b018807fff08d52efd5686349a8fc7bd8aa7..a28992269f5e04bc993b7cbb25353dee7b0fc660 100644 (file)
@@ -1699,7 +1699,7 @@ static int snd_via8233_pcmdxs_volume_put(struct snd_kcontrol *kcontrol,
        return change;
 }
 
-static DECLARE_TLV_DB_SCALE(db_scale_dxs, -9450, 150, 1);
+static const DECLARE_TLV_DB_SCALE(db_scale_dxs, -9450, 150, 1);
 
 static struct snd_kcontrol_new snd_via8233_pcmdxs_volume_control __devinitdata = {
        .name = "PCM Playback Volume",
@@ -1823,7 +1823,7 @@ static int __devinit snd_via82xx_mixer_new(struct via82xx *chip, const char *qui
        ac97.private_data = chip;
        ac97.private_free = snd_via82xx_mixer_free_ac97;
        ac97.pci = chip->pci;
-       ac97.scaps = AC97_SCAP_SKIP_MODEM;
+       ac97.scaps = AC97_SCAP_SKIP_MODEM | AC97_SCAP_POWER_SAVE;
        if ((err = snd_ac97_mixer(chip->ac97_bus, &ac97, &chip->ac97)) < 0)
                return err;
 
@@ -2357,93 +2357,59 @@ static struct via823x_info via823x_cards[] __devinitdata = {
 /*
  * auto detection of DXS channel supports.
  */
-struct dxs_whitelist {
-       unsigned short subvendor;
-       unsigned short subdevice; 
-       unsigned short mask; 
-       short action;   /* new dxs_support value */
+
+static struct snd_pci_quirk dxs_whitelist[] __devinitdata = {
+       SND_PCI_QUIRK(0x1005, 0x4710, "Avance Logic Mobo", VIA_DXS_ENABLE),
+       SND_PCI_QUIRK(0x1019, 0x0996, "ESC Mobo", VIA_DXS_48K),
+       SND_PCI_QUIRK(0x1019, 0x0a81, "ECS K7VTA3 v8.0", VIA_DXS_NO_VRA),
+       SND_PCI_QUIRK(0x1019, 0x0a85, "ECS L7VMM2", VIA_DXS_NO_VRA),
+       SND_PCI_QUIRK(0x1019, 0, "ESC K8", VIA_DXS_SRC),
+       SND_PCI_QUIRK(0x1019, 0xaa01, "ESC K8T890-A", VIA_DXS_SRC),
+       SND_PCI_QUIRK(0x1025, 0x0033, "Acer Inspire 1353LM", VIA_DXS_NO_VRA),
+       SND_PCI_QUIRK(0x1025, 0x0046, "Acer Aspire 1524 WLMi", VIA_DXS_SRC),
+       SND_PCI_QUIRK(0x1043, 0, "ASUS A7/A8", VIA_DXS_NO_VRA),
+       SND_PCI_QUIRK(0x1071, 0, "Diverse Notebook", VIA_DXS_NO_VRA),
+       SND_PCI_QUIRK(0x10cf, 0x118e, "FSC Laptop", VIA_DXS_ENABLE),
+       SND_PCI_QUIRK(0x1106, 0, "ASRock", VIA_DXS_SRC),
+       SND_PCI_QUIRK(0x1297, 0xa232, "Shuttle", VIA_DXS_ENABLE),
+       SND_PCI_QUIRK(0x1297, 0xc160, "Shuttle Sk41G", VIA_DXS_ENABLE),
+       SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte GA-7VAXP", VIA_DXS_ENABLE),
+       SND_PCI_QUIRK(0x1462, 0x3800, "MSI KT266", VIA_DXS_ENABLE),
+       SND_PCI_QUIRK(0x1462, 0x7120, "MSI KT4V", VIA_DXS_ENABLE),
+       SND_PCI_QUIRK(0x1462, 0x7142, "MSI K8MM-V", VIA_DXS_ENABLE),
+       SND_PCI_QUIRK(0x1462, 0, "MSI Mobo", VIA_DXS_SRC),
+       SND_PCI_QUIRK(0x147b, 0x1401, "ABIT KD7(-RAID)", VIA_DXS_ENABLE),
+       SND_PCI_QUIRK(0x147b, 0x1411, "ABIT VA-20", VIA_DXS_ENABLE),
+       SND_PCI_QUIRK(0x147b, 0x1413, "ABIT KV8 Pro", VIA_DXS_ENABLE),
+       SND_PCI_QUIRK(0x147b, 0x1415, "ABIT AV8", VIA_DXS_NO_VRA),
+       SND_PCI_QUIRK(0x14ff, 0x0403, "Twinhead mobo", VIA_DXS_ENABLE),
+       SND_PCI_QUIRK(0x14ff, 0x0408, "Twinhead laptop", VIA_DXS_SRC),
+       SND_PCI_QUIRK(0x1558, 0x4701, "Clevo D470", VIA_DXS_SRC),
+       SND_PCI_QUIRK(0x1584, 0x8120, "Diverse Laptop", VIA_DXS_ENABLE),
+       SND_PCI_QUIRK(0x1584, 0x8123, "Targa/Uniwill", VIA_DXS_NO_VRA),
+       SND_PCI_QUIRK(0x161f, 0x202b, "Amira Notebook", VIA_DXS_NO_VRA),
+       SND_PCI_QUIRK(0x161f, 0x2032, "m680x machines", VIA_DXS_48K),
+       SND_PCI_QUIRK(0x1631, 0xe004, "PB EasyNote 3174", VIA_DXS_ENABLE),
+       SND_PCI_QUIRK(0x1695, 0x3005, "EPoX EP-8K9A", VIA_DXS_ENABLE),
+       SND_PCI_QUIRK(0x1695, 0, "EPoX mobo", VIA_DXS_SRC),
+       SND_PCI_QUIRK(0x16f3, 0, "Jetway K8", VIA_DXS_SRC),
+       SND_PCI_QUIRK(0x1734, 0, "FSC Laptop", VIA_DXS_SRC),
+       SND_PCI_QUIRK(0x1849, 0x3059, "ASRock K7VM2", VIA_DXS_NO_VRA),
+       SND_PCI_QUIRK(0x1849, 0, "ASRock mobo", VIA_DXS_SRC),
+       SND_PCI_QUIRK(0x1919, 0x200a, "Soltek SL-K8",  VIA_DXS_NO_VRA),
+       SND_PCI_QUIRK(0x4005, 0x4710, "MSI K7T266", VIA_DXS_SRC),
+       { } /* terminator */
 };
 
 static int __devinit check_dxs_list(struct pci_dev *pci, int revision)
 {
-       static struct dxs_whitelist whitelist[] __devinitdata = {
-               { .subvendor = 0x1005, .subdevice = 0x4710, .action = VIA_DXS_ENABLE }, /* Avance Logic Mobo */
-               { .subvendor = 0x1019, .subdevice = 0x0996, .action = VIA_DXS_48K },
-               { .subvendor = 0x1019, .subdevice = 0x0a81, .action = VIA_DXS_NO_VRA }, /* ECS K7VTA3 v8.0 */
-               { .subvendor = 0x1019, .subdevice = 0x0a85, .action = VIA_DXS_NO_VRA }, /* ECS L7VMM2 */
-               { .subvendor = 0x1019, .subdevice = 0xa101, .action = VIA_DXS_SRC },
-               { .subvendor = 0x1019, .subdevice = 0xaa01, .action = VIA_DXS_SRC }, /* ECS K8T890-A */
-               { .subvendor = 0x1025, .subdevice = 0x0033, .action = VIA_DXS_NO_VRA }, /* Acer Inspire 1353LM */
-               { .subvendor = 0x1025, .subdevice = 0x0046, .action = VIA_DXS_SRC }, /* Acer Aspire 1524 WLMi */
-               { .subvendor = 0x1043, .subdevice = 0x8095, .action = VIA_DXS_NO_VRA }, /* ASUS A7V8X (FIXME: possibly VIA_DXS_ENABLE?)*/
-               { .subvendor = 0x1043, .subdevice = 0x80a1, .action = VIA_DXS_NO_VRA }, /* ASUS A7V8-X */
-               { .subvendor = 0x1043, .subdevice = 0x80b0, .action = VIA_DXS_NO_VRA }, /* ASUS A7V600 & K8V*/ 
-               { .subvendor = 0x1043, .subdevice = 0x810d, .action = VIA_DXS_SRC }, /* ASUS */
-               { .subvendor = 0x1043, .subdevice = 0x812a, .action = VIA_DXS_SRC    }, /* ASUS A8V Deluxe */ 
-               { .subvendor = 0x1043, .subdevice = 0x8174, .action = VIA_DXS_SRC    }, /* ASUS */
-               { .subvendor = 0x1043, .subdevice = 0x81b9, .action = VIA_DXS_SRC    }, /* ASUS A8V-MX */
-               { .subvendor = 0x1071, .subdevice = 0x8375, .action = VIA_DXS_NO_VRA }, /* Vobis/Yakumo/Mitac notebook */
-               { .subvendor = 0x1071, .subdevice = 0x8399, .action = VIA_DXS_NO_VRA }, /* Umax AB 595T (VIA K8N800A - VT8237) */
-               { .subvendor = 0x10cf, .subdevice = 0x118e, .action = VIA_DXS_ENABLE }, /* FSC laptop */
-               { .subvendor = 0x1106, .subdevice = 0x4161, .action = VIA_DXS_NO_VRA }, /* ASRock K7VT2 */
-               { .subvendor = 0x1106, .subdevice = 0x4552, .action = VIA_DXS_NO_VRA }, /* QDI Kudoz 7X/600-6AL */
-               { .subvendor = 0x1106, .subdevice = 0xaa01, .action = VIA_DXS_NO_VRA }, /* EPIA MII */
-               { .subvendor = 0x1106, .subdevice = 0xc001, .action = VIA_DXS_SRC }, /* Insight P4-ITX */
-               { .subvendor = 0x1297, .subdevice = 0xa232, .action = VIA_DXS_ENABLE }, /* Shuttle ?? */
-               { .subvendor = 0x1297, .subdevice = 0xc160, .action = VIA_DXS_ENABLE }, /* Shuttle SK41G */
-               { .subvendor = 0x1458, .subdevice = 0xa002, .action = VIA_DXS_ENABLE }, /* Gigabyte GA-7VAXP */
-               { .subvendor = 0x1462, .subdevice = 0x0080, .action = VIA_DXS_SRC }, /* MSI K8T Neo-FIS2R */
-               { .subvendor = 0x1462, .subdevice = 0x0430, .action = VIA_DXS_SRC }, /* MSI 7142 (K8MM-V) */
-               { .subvendor = 0x1462, .subdevice = 0x0470, .action = VIA_DXS_SRC }, /* MSI KT880 Delta-FSR */
-               { .subvendor = 0x1462, .subdevice = 0x3800, .action = VIA_DXS_ENABLE }, /* MSI KT266 */
-               { .subvendor = 0x1462, .subdevice = 0x5901, .action = VIA_DXS_NO_VRA }, /* MSI KT6 Delta-SR */
-               { .subvendor = 0x1462, .subdevice = 0x7023, .action = VIA_DXS_SRC }, /* MSI K8T Neo2-FI */
-               { .subvendor = 0x1462, .subdevice = 0x7120, .action = VIA_DXS_ENABLE }, /* MSI KT4V */
-               { .subvendor = 0x1462, .subdevice = 0x7142, .action = VIA_DXS_ENABLE }, /* MSI K8MM-V */
-               { .subvendor = 0x1462, .subdevice = 0xb012, .action = VIA_DXS_SRC }, /* P4M800/VIA8237R */
-               { .subvendor = 0x147b, .subdevice = 0x1401, .action = VIA_DXS_ENABLE }, /* ABIT KD7(-RAID) */
-               { .subvendor = 0x147b, .subdevice = 0x1411, .action = VIA_DXS_ENABLE }, /* ABIT VA-20 */
-               { .subvendor = 0x147b, .subdevice = 0x1413, .action = VIA_DXS_ENABLE }, /* ABIT KV8 Pro */
-               { .subvendor = 0x147b, .subdevice = 0x1415, .action = VIA_DXS_NO_VRA }, /* Abit AV8 */
-               { .subvendor = 0x14ff, .subdevice = 0x0403, .action = VIA_DXS_ENABLE }, /* Twinhead mobo */
-               { .subvendor = 0x14ff, .subdevice = 0x0408, .action = VIA_DXS_SRC }, /* Twinhead laptop */
-               { .subvendor = 0x1558, .subdevice = 0x4701, .action = VIA_DXS_SRC }, /* Clevo D470 */
-               { .subvendor = 0x1584, .subdevice = 0x8120, .action = VIA_DXS_ENABLE }, /* Gericom/Targa/Vobis/Uniwill laptop */
-               { .subvendor = 0x1584, .subdevice = 0x8123, .action = VIA_DXS_NO_VRA }, /* Uniwill (Targa Visionary XP-210) */
-               { .subvendor = 0x161f, .subdevice = 0x202b, .action = VIA_DXS_NO_VRA }, /* Amira Note book */
-               { .subvendor = 0x161f, .subdevice = 0x2032, .action = VIA_DXS_48K }, /* m680x machines */
-               { .subvendor = 0x1631, .subdevice = 0xe004, .action = VIA_DXS_ENABLE }, /* Easy Note 3174, Packard Bell */
-               { .subvendor = 0x1695, .subdevice = 0x3005, .action = VIA_DXS_ENABLE }, /* EPoX EP-8K9A */
-               { .subvendor = 0x1695, .subdevice = 0x300c, .action = VIA_DXS_SRC }, /* EPoX EP-8KRAI */
-               { .subvendor = 0x1695, .subdevice = 0x300e, .action = VIA_DXS_SRC }, /* EPoX 9HEAI */
-               { .subvendor = 0x16f3, .subdevice = 0x6405, .action = VIA_DXS_SRC }, /* Jetway K8M8MS */
-               { .subvendor = 0x1734, .subdevice = 0x1078, .action = VIA_DXS_SRC }, /* FSC Amilo L7300 */
-               { .subvendor = 0x1734, .subdevice = 0x1093, .action = VIA_DXS_SRC }, /* FSC */
-               { .subvendor = 0x1734, .subdevice = 0x10ab, .action = VIA_DXS_SRC }, /* FSC */
-               { .subvendor = 0x1849, .subdevice = 0x3059, .action = VIA_DXS_NO_VRA }, /* ASRock K7VM2 */
-               { .subvendor = 0x1849, .subdevice = 0x9739, .action = VIA_DXS_SRC }, /* ASRock mobo(?) */
-               { .subvendor = 0x1849, .subdevice = 0x9761, .action = VIA_DXS_SRC }, /* ASRock mobo(?) */
-               { .subvendor = 0x1919, .subdevice = 0x200a, .action = VIA_DXS_NO_VRA }, /* Soltek SL-K8Tpro-939 */
-               { .subvendor = 0x4005, .subdevice = 0x4710, .action = VIA_DXS_SRC },    /* MSI K7T266 Pro2 (MS-6380 V2.0) BIOS 3.7 */
-               { } /* terminator */
-       };
-       const struct dxs_whitelist *w;
-       unsigned short subsystem_vendor;
-       unsigned short subsystem_device;
-
-       pci_read_config_word(pci, PCI_SUBSYSTEM_VENDOR_ID, &subsystem_vendor);
-       pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &subsystem_device);
+       const struct snd_pci_quirk *w;
 
-       for (w = whitelist; w->subvendor; w++) {
-               if (w->subvendor != subsystem_vendor)
-                       continue;
-               if (w->mask) {
-                       if ((w->mask & subsystem_device) == w->subdevice)
-                               return w->action;
-               } else {
-                       if (subsystem_device == w->subdevice)
-                               return w->action;
-               }
+       w = snd_pci_quirk_lookup(pci, dxs_whitelist);
+       if (w) {
+               snd_printdd(KERN_INFO "via82xx: DXS white list for %s found\n",
+                           w->name);
+               return w->value;
        }
 
        /* for newer revision, default to DXS_SRC */
index 17d6b847585f5663114a52bd318cc4456553aa5e..b338e15db0d98d26b272a013fbd5c30f3a1abe40 100644 (file)
@@ -900,7 +900,7 @@ static int __devinit snd_via82xx_mixer_new(struct via82xx_modem *chip)
        ac97.private_data = chip;
        ac97.private_free = snd_via82xx_mixer_free_ac97;
        ac97.pci = chip->pci;
-       ac97.scaps = AC97_SCAP_SKIP_AUDIO;
+       ac97.scaps = AC97_SCAP_SKIP_AUDIO | AC97_SCAP_POWER_SAVE;
        ac97.num = chip->ac97_secondary;
 
        if ((err = snd_ac97_mixer(chip->ac97_bus, &ac97, &chip->ac97)) < 0)
index 89f58ea180b3a79dedea5700f409c52cf8d203ee..474eac9490aeb3ae79ce7fb10c1d253d4b39b50a 100644 (file)
@@ -73,8 +73,8 @@ MODULE_DEVICE_TABLE(pci, snd_vx222_ids);
 /*
  */
 
-static DECLARE_TLV_DB_SCALE(db_scale_old_vol, -11350, 50, 0);
-static DECLARE_TLV_DB_SCALE(db_scale_akm, -7350, 50, 0);
+static const DECLARE_TLV_DB_SCALE(db_scale_old_vol, -11350, 50, 0);
+static const DECLARE_TLV_DB_SCALE(db_scale_akm, -7350, 50, 0);
 
 static struct snd_vx_hardware vx222_old_hw = {
 
index 5e51950e05f94b801dec0bea7af712c04b1fc44d..55558bef7166ff80c7d5d51e21e891160d3dd848 100644 (file)
@@ -846,7 +846,7 @@ static void vx2_set_input_level(struct snd_vx222 *chip)
 
 #define MIC_LEVEL_MAX  0xff
 
-static DECLARE_TLV_DB_SCALE(db_scale_mic, -6450, 50, 0);
+static const DECLARE_TLV_DB_SCALE(db_scale_mic, -6450, 50, 0);
 
 /*
  * controls API for input levels
index 1b07469916696f0a80df594a98d20e2ca1799f9e..112f2fff6c8e279d3045e33d034a956ed09db94a 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef _HWMCODE_
 #define _HWMCODE_
 
-static unsigned long DspInst[YDSXG_DSPLENGTH / 4] = {
+static u32 DspInst[YDSXG_DSPLENGTH / 4] = {
        0x00000081, 0x000001a4, 0x0000000a, 0x0000002f,
        0x00080253, 0x01800317, 0x0000407b, 0x0000843f,
        0x0001483c, 0x0001943c, 0x0005d83c, 0x00001c3c,
@@ -12,7 +12,7 @@ static unsigned long DspInst[YDSXG_DSPLENGTH / 4] = {
        0x00000000, 0x00000000, 0x00000000, 0x00000000
 };
 
-static unsigned long CntrlInst[YDSXG_CTRLLENGTH / 4] = {
+static u32 CntrlInst[YDSXG_CTRLLENGTH / 4] = {
        0x000007, 0x240007, 0x0C0007, 0x1C0007,
        0x060007, 0x700002, 0x000020, 0x030040,
        0x007104, 0x004286, 0x030040, 0x000F0D,
@@ -791,7 +791,7 @@ static unsigned long CntrlInst[YDSXG_CTRLLENGTH / 4] = {
 // 04/09  creat
 // 04/12  stop nise fix
 // 06/21  WorkingOff timming
-static unsigned long CntrlInst1E[YDSXG_CTRLLENGTH / 4] = {
+static u32 CntrlInst1E[YDSXG_CTRLLENGTH / 4] = {
        0x000007, 0x240007, 0x0C0007, 0x1C0007,
        0x060007, 0x700002, 0x000020, 0x030040,
        0x007104, 0x004286, 0x030040, 0x000F0D,
index 7881944a19576d56345d3440fb40ff26863bd3e3..fd12674d03943329e1bb224bce4805b655663d06 100644 (file)
@@ -2,12 +2,6 @@
  *  Copyright (c) by Jaroslav Kysela <perex@suse.cz>
  *  Routines for control of YMF724/740/744/754 chips
  *
- *  BUGS:
- *    --
- *
- *  TODO:
- *    --
- *
  *   This program is free software; you can redistribute it and/or modify
  *   it under the terms of the GNU General Public License as published by
  *   the Free Software Foundation; either version 2 of the License, or
@@ -26,6 +20,7 @@
 
 #include <sound/driver.h>
 #include <linux/delay.h>
+#include <linux/firmware.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
 #include <sound/mpu401.h>
 
 #include <asm/io.h>
-
-/*
- *  constants
- */
+#include <asm/byteorder.h>
 
 /*
  *  common I/O routines
@@ -179,6 +171,17 @@ static u32 snd_ymfpci_calc_lpfQ(u32 rate)
        return val[0];
 }
 
+static void snd_ymfpci_pcm_441_volume_set(struct snd_ymfpci_pcm *ypcm)
+{
+       unsigned int value;
+       struct snd_ymfpci_pcm_mixer *mixer;
+       
+       mixer = &ypcm->chip->pcm_mixer[ypcm->substream->number];
+       value = min_t(unsigned int, mixer->left, 0x7fff) >> 1;
+       value |= (min_t(unsigned int, mixer->right, 0x7fff) >> 1) << 16;
+       snd_ymfpci_writel(ypcm->chip, YDSXGR_BUF441OUTVOL, value);
+}
+
 /*
  *  Hardware start management
  */
@@ -290,6 +293,10 @@ static int snd_ymfpci_voice_free(struct snd_ymfpci *chip, struct snd_ymfpci_voic
        snd_assert(pvoice != NULL, return -EINVAL);
        snd_ymfpci_hw_stop(chip);
        spin_lock_irqsave(&chip->voice_lock, flags);
+       if (pvoice->number == chip->src441_used) {
+               chip->src441_used = -1;
+               pvoice->ypcm->use_441_slot = 0;
+       }
        pvoice->use = pvoice->pcm = pvoice->synth = pvoice->midi = 0;
        pvoice->ypcm = NULL;
        pvoice->interrupt = NULL;
@@ -394,7 +401,7 @@ static int snd_ymfpci_playback_trigger(struct snd_pcm_substream *substream,
        case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
        case SNDRV_PCM_TRIGGER_RESUME:
                chip->ctrl_playback[ypcm->voices[0]->number + 1] = cpu_to_le32(ypcm->voices[0]->bank_addr);
-               if (ypcm->voices[1] != NULL)
+               if (ypcm->voices[1] != NULL && !ypcm->use_441_slot)
                        chip->ctrl_playback[ypcm->voices[1]->number + 1] = cpu_to_le32(ypcm->voices[1]->bank_addr);
                ypcm->running = 1;
                break;
@@ -402,7 +409,7 @@ static int snd_ymfpci_playback_trigger(struct snd_pcm_substream *substream,
        case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
        case SNDRV_PCM_TRIGGER_SUSPEND:
                chip->ctrl_playback[ypcm->voices[0]->number + 1] = 0;
-               if (ypcm->voices[1] != NULL)
+               if (ypcm->voices[1] != NULL && !ypcm->use_441_slot)
                        chip->ctrl_playback[ypcm->voices[1]->number + 1] = 0;
                ypcm->running = 0;
                break;
@@ -489,6 +496,7 @@ static void snd_ymfpci_pcm_init_voice(struct snd_ymfpci_pcm *ypcm, unsigned int
        unsigned int nbank;
        u32 vol_left, vol_right;
        u8 use_left, use_right;
+       unsigned long flags;
 
        snd_assert(voice != NULL, return);
        if (runtime->channels == 1) {
@@ -507,11 +515,27 @@ static void snd_ymfpci_pcm_init_voice(struct snd_ymfpci_pcm *ypcm, unsigned int
                vol_left = cpu_to_le32(0x40000000);
                vol_right = cpu_to_le32(0x40000000);
        }
+       spin_lock_irqsave(&ypcm->chip->voice_lock, flags);
        format = runtime->channels == 2 ? 0x00010000 : 0;
        if (snd_pcm_format_width(runtime->format) == 8)
                format |= 0x80000000;
+       else if (ypcm->chip->device_id == PCI_DEVICE_ID_YAMAHA_754 &&
+                runtime->rate == 44100 && runtime->channels == 2 &&
+                voiceidx == 0 && (ypcm->chip->src441_used == -1 ||
+                                  ypcm->chip->src441_used == voice->number)) {
+               ypcm->chip->src441_used = voice->number;
+               ypcm->use_441_slot = 1;
+               format |= 0x10000000;
+               snd_ymfpci_pcm_441_volume_set(ypcm);
+       }
+       if (ypcm->chip->src441_used == voice->number &&
+           (format & 0x10000000) == 0) {
+               ypcm->chip->src441_used = -1;
+               ypcm->use_441_slot = 0;
+       }
        if (runtime->channels == 2 && (voiceidx & 1) != 0)
                format |= 1;
+       spin_unlock_irqrestore(&ypcm->chip->voice_lock, flags);
        for (nbank = 0; nbank < 2; nbank++) {
                bank = &voice->bank[nbank];
                memset(bank, 0, sizeof(*bank));
@@ -1480,7 +1504,7 @@ static int snd_ymfpci_put_single(struct snd_kcontrol *kcontrol,
        return change;
 }
 
-static DECLARE_TLV_DB_LINEAR(db_scale_native, TLV_DB_GAIN_MUTE, 0);
+static const DECLARE_TLV_DB_LINEAR(db_scale_native, TLV_DB_GAIN_MUTE, 0);
 
 #define YMFPCI_DOUBLE(xname, xindex, reg) \
 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
@@ -1722,7 +1746,10 @@ static int snd_ymfpci_pcm_vol_put(struct snd_kcontrol *kcontrol,
                spin_lock_irqsave(&chip->voice_lock, flags);
                if (substream->runtime && substream->runtime->private_data) {
                        struct snd_ymfpci_pcm *ypcm = substream->runtime->private_data;
-                       ypcm->update_pcm_vol = 2;
+                       if (!ypcm->use_441_slot)
+                               ypcm->update_pcm_vol = 2;
+                       else
+                               snd_ymfpci_pcm_441_volume_set(ypcm);
                }
                spin_unlock_irqrestore(&chip->voice_lock, flags);
                return 1;
@@ -1971,13 +1998,94 @@ static void snd_ymfpci_disable_dsp(struct snd_ymfpci *chip)
        }
 }
 
+#define FIRMWARE_IN_THE_KERNEL
+
+#ifdef FIRMWARE_IN_THE_KERNEL
+
 #include "ymfpci_image.h"
 
+static struct firmware snd_ymfpci_dsp_microcode = {
+       .size = YDSXG_DSPLENGTH,
+       .data = (u8 *)DspInst,
+};
+static struct firmware snd_ymfpci_controller_microcode = {
+       .size = YDSXG_CTRLLENGTH,
+       .data = (u8 *)CntrlInst,
+};
+static struct firmware snd_ymfpci_controller_1e_microcode = {
+       .size = YDSXG_CTRLLENGTH,
+       .data = (u8 *)CntrlInst1E,
+};
+#endif
+
+#ifdef __LITTLE_ENDIAN
+static inline void snd_ymfpci_convert_from_le(const struct firmware *fw) { }
+#else
+static void snd_ymfpci_convert_from_le(const struct firmware *fw)
+{
+       int i;
+       u32 *data = (u32 *)fw->data;
+
+       for (i = 0; i < fw->size / 4; ++i)
+               le32_to_cpus(&data[i]);
+}
+#endif
+
+static int snd_ymfpci_request_firmware(struct snd_ymfpci *chip)
+{
+       int err, is_1e;
+       const char *name;
+
+       err = request_firmware(&chip->dsp_microcode, "yamaha/ds1_dsp.fw",
+                              &chip->pci->dev);
+       if (err >= 0) {
+               if (chip->dsp_microcode->size == YDSXG_DSPLENGTH)
+                       snd_ymfpci_convert_from_le(chip->dsp_microcode);
+               else {
+                       snd_printk(KERN_ERR "DSP microcode has wrong size\n");
+                       err = -EINVAL;
+               }
+       }
+       if (err < 0) {
+#ifdef FIRMWARE_IN_THE_KERNEL
+               chip->dsp_microcode = &snd_ymfpci_dsp_microcode;
+#else
+               return err;
+#endif
+       }
+       is_1e = chip->device_id == PCI_DEVICE_ID_YAMAHA_724F ||
+               chip->device_id == PCI_DEVICE_ID_YAMAHA_740C ||
+               chip->device_id == PCI_DEVICE_ID_YAMAHA_744 ||
+               chip->device_id == PCI_DEVICE_ID_YAMAHA_754;
+       name = is_1e ? "yamaha/ds1e_ctrl.fw" : "yamaha/ds1_ctrl.fw";
+       err = request_firmware(&chip->controller_microcode, name,
+                              &chip->pci->dev);
+       if (err >= 0) {
+               if (chip->controller_microcode->size == YDSXG_CTRLLENGTH)
+                       snd_ymfpci_convert_from_le(chip->controller_microcode);
+               else {
+                       snd_printk(KERN_ERR "controller microcode"
+                                  " has wrong size\n");
+                       err = -EINVAL;
+               }
+       }
+       if (err < 0) {
+#ifdef FIRMWARE_IN_THE_KERNEL
+               chip->controller_microcode =
+                       is_1e ? &snd_ymfpci_controller_1e_microcode
+                             : &snd_ymfpci_controller_microcode;
+#else
+               return err;
+#endif
+       }
+       return 0;
+}
+
 static void snd_ymfpci_download_image(struct snd_ymfpci *chip)
 {
        int i;
        u16 ctrl;
-       unsigned long *inst;
+       u32 *inst;
 
        snd_ymfpci_writel(chip, YDSXGR_NATIVEDACOUTVOL, 0x00000000);
        snd_ymfpci_disable_dsp(chip);
@@ -1992,21 +2100,12 @@ static void snd_ymfpci_download_image(struct snd_ymfpci *chip)
        snd_ymfpci_writew(chip, YDSXGR_GLOBALCTRL, ctrl & ~0x0007);
 
        /* setup DSP instruction code */
+       inst = (u32 *)chip->dsp_microcode->data;
        for (i = 0; i < YDSXG_DSPLENGTH / 4; i++)
-               snd_ymfpci_writel(chip, YDSXGR_DSPINSTRAM + (i << 2), DspInst[i]);
+               snd_ymfpci_writel(chip, YDSXGR_DSPINSTRAM + (i << 2), inst[i]);
 
        /* setup control instruction code */
-       switch (chip->device_id) {
-       case PCI_DEVICE_ID_YAMAHA_724F:
-       case PCI_DEVICE_ID_YAMAHA_740C:
-       case PCI_DEVICE_ID_YAMAHA_744:
-       case PCI_DEVICE_ID_YAMAHA_754:
-               inst = CntrlInst1E;
-               break;
-       default:
-               inst = CntrlInst;
-               break;
-       }
+       inst = (u32 *)chip->controller_microcode->data;
        for (i = 0; i < YDSXG_CTRLLENGTH / 4; i++)
                snd_ymfpci_writel(chip, YDSXGR_CTRLINSTRAM + (i << 2), inst[i]);
 
@@ -2160,6 +2259,15 @@ static int snd_ymfpci_free(struct snd_ymfpci *chip)
        pci_write_config_word(chip->pci, 0x40, chip->old_legacy_ctrl);
        
        pci_disable_device(chip->pci);
+#ifdef FIRMWARE_IN_THE_KERNEL
+       if (chip->dsp_microcode != &snd_ymfpci_dsp_microcode)
+#endif
+               release_firmware(chip->dsp_microcode);
+#ifdef FIRMWARE_IN_THE_KERNEL
+       if (chip->controller_microcode != &snd_ymfpci_controller_microcode &&
+           chip->controller_microcode != &snd_ymfpci_controller_1e_microcode)
+#endif
+               release_firmware(chip->controller_microcode);
        kfree(chip);
        return 0;
 }
@@ -2180,7 +2288,7 @@ static int saved_regs_index[] = {
        YDSXGR_PRIADCLOOPVOL,
        YDSXGR_NATIVEDACINVOL,
        YDSXGR_NATIVEDACOUTVOL,
-       // YDSXGR_BUF441OUTVOL,
+       YDSXGR_BUF441OUTVOL,
        YDSXGR_NATIVEADCINVOL,
        YDSXGR_SPDIFLOOPVOL,
        YDSXGR_SPDIFOUTVOL,
@@ -2295,6 +2403,7 @@ int __devinit snd_ymfpci_create(struct snd_card *card,
        chip->reg_area_phys = pci_resource_start(pci, 0);
        chip->reg_area_virt = ioremap_nocache(chip->reg_area_phys, 0x8000);
        pci_set_master(pci);
+       chip->src441_used = -1;
 
        if ((chip->res_reg_area = request_mem_region(chip->reg_area_phys, 0x8000, "YMFPCI")) == NULL) {
                snd_printk(KERN_ERR "unable to grab memory region 0x%lx-0x%lx\n", chip->reg_area_phys, chip->reg_area_phys + 0x8000 - 1);
@@ -2315,6 +2424,12 @@ int __devinit snd_ymfpci_create(struct snd_card *card,
                return -EIO;
        }
 
+       err = snd_ymfpci_request_firmware(chip);
+       if (err < 0) {
+               snd_printk(KERN_ERR "firmware request failed: %d\n", err);
+               snd_ymfpci_free(chip);
+               return err;
+       }
        snd_ymfpci_download_image(chip);
 
        udelay(100); /* seems we need a delay after downloading image.. */
index bced7b623b12ed15ab1a9d7cf0e336be2deef358..2b1f996c898d3f4a230196c6253de5cc22e95633 100644 (file)
@@ -64,7 +64,7 @@ static int vx_mic_level_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_v
        return 0;
 }
 
-static DECLARE_TLV_DB_SCALE(db_scale_mic, -21, 3, 0);
+static const DECLARE_TLV_DB_SCALE(db_scale_mic, -21, 3, 0);
 
 static struct snd_kcontrol_new vx_control_mic_level = {
        .iface =        SNDRV_CTL_ELEM_IFACE_MIXER,
index d7df59e9c647e43b142f8215e4fac3386a0de196..363bcb5f08e671c6d085e42e717afba5057d6035 100644 (file)
@@ -91,7 +91,7 @@ static int snd_vxpocket_dev_free(struct snd_device *device)
  * Only output levels can be modified
  */
 
-static DECLARE_TLV_DB_SCALE(db_scale_old_vol, -11350, 50, 0);
+static const DECLARE_TLV_DB_SCALE(db_scale_old_vol, -11350, 50, 0);
 
 static struct snd_vx_hardware vxpocket_hw = {
        .name = "VXPocket",
diff --git a/sound/soc/Kconfig b/sound/soc/Kconfig
new file mode 100644 (file)
index 0000000..ec821a5
--- /dev/null
@@ -0,0 +1,32 @@
+#
+# SoC audio configuration
+#
+
+menu "SoC audio support"
+       depends on SND!=n
+
+config SND_SOC_AC97_BUS
+       bool
+
+config SND_SOC
+       tristate "SoC audio support"
+       ---help---
+
+         If you want SoC support, you should say Y here and also to the
+         specific driver for your SoC below. You will also need to select the
+         specific codec(s) attached to the SoC
+
+         This SoC audio support can also be built as a module.  If so, the module
+         will be called snd-soc-core.
+
+# All the supported Soc's
+menu "SoC Platforms"
+depends on SND_SOC
+source "sound/soc/at91/Kconfig"
+source "sound/soc/pxa/Kconfig"
+endmenu
+
+# Supported codecs
+source "sound/soc/codecs/Kconfig"
+
+endmenu
diff --git a/sound/soc/Makefile b/sound/soc/Makefile
new file mode 100644 (file)
index 0000000..98e6f49
--- /dev/null
@@ -0,0 +1,4 @@
+snd-soc-core-objs := soc-core.o soc-dapm.o
+
+obj-$(CONFIG_SND_SOC)  += snd-soc-core.o
+obj-$(CONFIG_SND_SOC)  += codecs/ at91/ pxa/
diff --git a/sound/soc/at91/Kconfig b/sound/soc/at91/Kconfig
new file mode 100644 (file)
index 0000000..5bcf08b
--- /dev/null
@@ -0,0 +1,32 @@
+menu "SoC Audio for the Atmel AT91"
+
+config SND_AT91_SOC
+       tristate "SoC Audio for the Atmel AT91 System-on-Chip"
+       depends on ARCH_AT91 && SND
+       select SND_PCM
+       help
+         Say Y or M if you want to add support for codecs attached to
+         the AT91 SSC interface. You will also need
+         to select the audio interfaces to support below.
+
+config SND_AT91_SOC_I2S
+       tristate
+
+config SND_AT91_SOC_ETI_B1_WM8731
+       tristate "SoC I2S Audio support for WM8731-based Endrelia ETI-B1 boards"
+       depends on SND_AT91_SOC && (MACH_ETI_B1 || MACH_ETI_C1)
+       select SND_AT91_SOC_I2S
+       select SND_SOC_WM8731
+       help
+         Say Y if you want to add support for SoC audio on WM8731-based
+         Endrelia Technologies Inc ETI-B1 or ETI-C1 boards.
+
+config SND_AT91_SOC_ETI_SLAVE
+       bool "Run codec in slave Mode on Endrelia boards"
+       depends on SND_AT91_SOC_ETI_B1_WM8731
+       default n
+       help
+         Say Y if you want to run with the AT91 SSC generating the BCLK
+         and LRC signals on Endrelia boards.
+
+endmenu
diff --git a/sound/soc/at91/Makefile b/sound/soc/at91/Makefile
new file mode 100644 (file)
index 0000000..b77b01a
--- /dev/null
@@ -0,0 +1,11 @@
+# AT91 Platform Support
+snd-soc-at91-objs := at91-pcm.o
+snd-soc-at91-i2s-objs := at91-i2s.o
+
+obj-$(CONFIG_SND_AT91_SOC) += snd-soc-at91.o
+obj-$(CONFIG_SND_AT91_SOC_I2S) += snd-soc-at91-i2s.o
+
+# AT91 Machine Support
+snd-soc-eti-b1-wm8731-objs := eti_b1_wm8731.o
+
+obj-$(CONFIG_SND_AT91_SOC_ETI_B1_WM8731) += snd-soc-eti-b1-wm8731.o
diff --git a/sound/soc/at91/at91-i2s.c b/sound/soc/at91/at91-i2s.c
new file mode 100644 (file)
index 0000000..fcc544a
--- /dev/null
@@ -0,0 +1,720 @@
+/*
+ * at91-i2s.c  --  ALSA SoC I2S Audio Layer Platform driver
+ *
+ * Author: Frank Mandarino <fmandarino@endrelia.com>
+ *         Endrelia Technologies Inc.
+ *
+ * Based on pxa2xx Platform drivers by
+ * Liam Girdwood <liam.girdwood@wolfsonmicro.com>
+ *
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ *
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/interrupt.h>
+#include <linux/device.h>
+#include <linux/delay.h>
+#include <linux/clk.h>
+#include <sound/driver.h>
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/initval.h>
+#include <sound/soc.h>
+
+#include <asm/arch/hardware.h>
+#include <asm/arch/at91_pmc.h>
+#include <asm/arch/at91_ssc.h>
+#include <asm/arch/at91_pdc.h>
+
+#include "at91-pcm.h"
+#include "at91-i2s.h"
+
+#if 0
+#define        DBG(x...)       printk(KERN_DEBUG "at91-i2s:" x)
+#else
+#define        DBG(x...)
+#endif
+
+#if defined(CONFIG_ARCH_AT91SAM9260)
+#define NUM_SSC_DEVICES                1
+#else
+#define NUM_SSC_DEVICES                3
+#endif
+
+
+/*
+ * SSC PDC registers required by the PCM DMA engine.
+ */
+static struct at91_pdc_regs pdc_tx_reg = {
+       .xpr            = AT91_PDC_TPR,
+       .xcr            = AT91_PDC_TCR,
+       .xnpr           = AT91_PDC_TNPR,
+       .xncr           = AT91_PDC_TNCR,
+};
+
+static struct at91_pdc_regs pdc_rx_reg = {
+       .xpr            = AT91_PDC_RPR,
+       .xcr            = AT91_PDC_RCR,
+       .xnpr           = AT91_PDC_RNPR,
+       .xncr           = AT91_PDC_RNCR,
+};
+
+/*
+ * SSC & PDC status bits for transmit and receive.
+ */
+static struct at91_ssc_mask ssc_tx_mask = {
+       .ssc_enable     = AT91_SSC_TXEN,
+       .ssc_disable    = AT91_SSC_TXDIS,
+       .ssc_endx       = AT91_SSC_ENDTX,
+       .ssc_endbuf     = AT91_SSC_TXBUFE,
+       .pdc_enable     = AT91_PDC_TXTEN,
+       .pdc_disable    = AT91_PDC_TXTDIS,
+};
+
+static struct at91_ssc_mask ssc_rx_mask = {
+       .ssc_enable     = AT91_SSC_RXEN,
+       .ssc_disable    = AT91_SSC_RXDIS,
+       .ssc_endx       = AT91_SSC_ENDRX,
+       .ssc_endbuf     = AT91_SSC_RXBUFF,
+       .pdc_enable     = AT91_PDC_RXTEN,
+       .pdc_disable    = AT91_PDC_RXTDIS,
+};
+
+
+/*
+ * DMA parameters.
+ */
+static struct at91_pcm_dma_params ssc_dma_params[NUM_SSC_DEVICES][2] = {
+       {{
+       .name           = "SSC0/I2S PCM Stereo out",
+       .pdc            = &pdc_tx_reg,
+       .mask           = &ssc_tx_mask,
+       },
+       {
+       .name           = "SSC0/I2S PCM Stereo in",
+       .pdc            = &pdc_rx_reg,
+       .mask           = &ssc_rx_mask,
+       }},
+#if NUM_SSC_DEVICES == 3
+       {{
+       .name           = "SSC1/I2S PCM Stereo out",
+       .pdc            = &pdc_tx_reg,
+       .mask           = &ssc_tx_mask,
+       },
+       {
+       .name           = "SSC1/I2S PCM Stereo in",
+       .pdc            = &pdc_rx_reg,
+       .mask           = &ssc_rx_mask,
+       }},
+       {{
+       .name           = "SSC2/I2S PCM Stereo out",
+       .pdc            = &pdc_tx_reg,
+       .mask           = &ssc_tx_mask,
+       },
+       {
+       .name           = "SSC1/I2S PCM Stereo in",
+       .pdc            = &pdc_rx_reg,
+       .mask           = &ssc_rx_mask,
+       }},
+#endif
+};
+
+struct at91_ssc_state {
+       u32     ssc_cmr;
+       u32     ssc_rcmr;
+       u32     ssc_rfmr;
+       u32     ssc_tcmr;
+       u32     ssc_tfmr;
+       u32     ssc_sr;
+       u32     ssc_imr;
+};
+
+static struct at91_ssc_info {
+       char            *name;
+       struct at91_ssc_periph ssc;
+       spinlock_t      lock;           /* lock for dir_mask */
+       unsigned short  dir_mask;       /* 0=unused, 1=playback, 2=capture */
+       unsigned short  initialized;    /* 1=SSC has been initialized */
+       unsigned short  daifmt;
+       unsigned short  cmr_div;
+       unsigned short  tcmr_period;
+       unsigned short  rcmr_period;
+       struct at91_pcm_dma_params *dma_params[2];
+       struct at91_ssc_state ssc_state;
+
+} ssc_info[NUM_SSC_DEVICES] = {
+       {
+       .name           = "ssc0",
+       .lock           = SPIN_LOCK_UNLOCKED,
+       .dir_mask       = 0,
+       .initialized    = 0,
+       },
+#if NUM_SSC_DEVICES == 3
+       {
+       .name           = "ssc1",
+       .lock           = SPIN_LOCK_UNLOCKED,
+       .dir_mask       = 0,
+       .initialized    = 0,
+       },
+       {
+       .name           = "ssc2",
+       .lock           = SPIN_LOCK_UNLOCKED,
+       .dir_mask       = 0,
+       .initialized    = 0,
+       },
+#endif
+};
+
+static unsigned int at91_i2s_sysclk;
+
+/*
+ * SSC interrupt handler.  Passes PDC interrupts to the DMA
+ * interrupt handler in the PCM driver.
+ */
+static irqreturn_t at91_i2s_interrupt(int irq, void *dev_id)
+{
+       struct at91_ssc_info *ssc_p = dev_id;
+       struct at91_pcm_dma_params *dma_params;
+       u32 ssc_sr;
+       int i;
+
+       ssc_sr = at91_ssc_read(ssc_p->ssc.base + AT91_SSC_SR)
+                       & at91_ssc_read(ssc_p->ssc.base + AT91_SSC_IMR);
+
+       /*
+        * Loop through the substreams attached to this SSC.  If
+        * a DMA-related interrupt occurred on that substream, call
+        * the DMA interrupt handler function, if one has been
+        * registered in the dma_params structure by the PCM driver.
+        */
+       for (i = 0; i < ARRAY_SIZE(ssc_p->dma_params); i++) {
+               dma_params = ssc_p->dma_params[i];
+
+               if (dma_params != NULL && dma_params->dma_intr_handler != NULL &&
+                       (ssc_sr &
+                       (dma_params->mask->ssc_endx | dma_params->mask->ssc_endbuf)))
+
+                       dma_params->dma_intr_handler(ssc_sr, dma_params->substream);
+       }
+
+       return IRQ_HANDLED;
+}
+
+/*
+ * Startup.  Only that one substream allowed in each direction.
+ */
+static int at91_i2s_startup(struct snd_pcm_substream *substream)
+{
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct at91_ssc_info *ssc_p = &ssc_info[rtd->dai->cpu_dai->id];
+       int dir_mask;
+
+       DBG("i2s_startup: SSC_SR=0x%08lx\n",
+                       at91_ssc_read(ssc_p->ssc.base + AT91_SSC_SR));
+       dir_mask = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 0x1 : 0x2;
+
+       spin_lock_irq(&ssc_p->lock);
+       if (ssc_p->dir_mask & dir_mask) {
+               spin_unlock_irq(&ssc_p->lock);
+               return -EBUSY;
+       }
+       ssc_p->dir_mask |= dir_mask;
+       spin_unlock_irq(&ssc_p->lock);
+
+       return 0;
+}
+
+/*
+ * Shutdown.  Clear DMA parameters and shutdown the SSC if there
+ * are no other substreams open.
+ */
+static void at91_i2s_shutdown(struct snd_pcm_substream *substream)
+{
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct at91_ssc_info *ssc_p = &ssc_info[rtd->dai->cpu_dai->id];
+       struct at91_pcm_dma_params *dma_params;
+       int dir, dir_mask;
+
+       dir = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 0 : 1;
+       dma_params = ssc_p->dma_params[dir];
+
+       if (dma_params != NULL) {
+               at91_ssc_write(dma_params->ssc_base + AT91_SSC_CR,
+                               dma_params->mask->ssc_disable);
+               DBG("%s disabled SSC_SR=0x%08lx\n", (dir ? "receive" : "transmit"),
+                       at91_ssc_read(ssc_p->ssc.base + AT91_SSC_SR));
+
+               dma_params->ssc_base = NULL;
+               dma_params->substream = NULL;
+               ssc_p->dma_params[dir] = NULL;
+       }
+
+       dir_mask = 1 << dir;
+
+       spin_lock_irq(&ssc_p->lock);
+       ssc_p->dir_mask &= ~dir_mask;
+       if (!ssc_p->dir_mask) {
+               /* Shutdown the SSC clock. */
+               DBG("Stopping pid %d clock\n", ssc_p->ssc.pid);
+               at91_sys_write(AT91_PMC_PCDR, 1<<ssc_p->ssc.pid);
+
+               if (ssc_p->initialized) {
+                       free_irq(ssc_p->ssc.pid, ssc_p);
+                       ssc_p->initialized = 0;
+               }
+
+               /* Reset the SSC */
+               at91_ssc_write(ssc_p->ssc.base + AT91_SSC_CR, AT91_SSC_SWRST);
+
+               /* Clear the SSC dividers */
+               ssc_p->cmr_div = ssc_p->tcmr_period = ssc_p->rcmr_period = 0;
+       }
+       spin_unlock_irq(&ssc_p->lock);
+}
+
+/*
+ * Record the SSC system clock rate.
+ */
+static int at91_i2s_set_dai_sysclk(struct snd_soc_cpu_dai *cpu_dai,
+               int clk_id, unsigned int freq, int dir)
+{
+       /*
+        * The only clock supplied to the SSC is the AT91 master clock,
+        * which is only used if the SSC is generating BCLK and/or
+        * LRC clocks.
+        */
+       switch (clk_id) {
+       case AT91_SYSCLK_MCK:
+               at91_i2s_sysclk = freq;
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
+/*
+ * Record the DAI format for use in hw_params().
+ */
+static int at91_i2s_set_dai_fmt(struct snd_soc_cpu_dai *cpu_dai,
+               unsigned int fmt)
+{
+       struct at91_ssc_info *ssc_p = &ssc_info[cpu_dai->id];
+
+       if ((fmt & SND_SOC_DAIFMT_FORMAT_MASK) != SND_SOC_DAIFMT_I2S)
+               return -EINVAL;
+
+       ssc_p->daifmt = fmt;
+       return 0;
+}
+
+/*
+ * Record SSC clock dividers for use in hw_params().
+ */
+static int at91_i2s_set_dai_clkdiv(struct snd_soc_cpu_dai *cpu_dai,
+       int div_id, int div)
+{
+       struct at91_ssc_info *ssc_p = &ssc_info[cpu_dai->id];
+
+       switch (div_id) {
+       case AT91SSC_CMR_DIV:
+               /*
+                * The same master clock divider is used for both
+                * transmit and receive, so if a value has already
+                * been set, it must match this value.
+                */
+               if (ssc_p->cmr_div == 0)
+                       ssc_p->cmr_div = div;
+               else
+                       if (div != ssc_p->cmr_div)
+                               return -EBUSY;
+               break;
+
+       case AT91SSC_TCMR_PERIOD:
+               ssc_p->tcmr_period = div;
+               break;
+
+       case AT91SSC_RCMR_PERIOD:
+               ssc_p->rcmr_period = div;
+               break;
+
+       default:
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
+/*
+ * Configure the SSC.
+ */
+static int at91_i2s_hw_params(struct snd_pcm_substream *substream,
+       struct snd_pcm_hw_params *params)
+{
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       int id = rtd->dai->cpu_dai->id;
+       struct at91_ssc_info *ssc_p = &ssc_info[id];
+       struct at91_pcm_dma_params *dma_params;
+       int dir, channels, bits;
+       u32 tfmr, rfmr, tcmr, rcmr;
+       int start_event;
+       int ret;
+
+       /*
+        * Currently, there is only one set of dma params for
+        * each direction.  If more are added, this code will
+        * have to be changed to select the proper set.
+        */
+       dir = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 0 : 1;
+
+       dma_params = &ssc_dma_params[id][dir];
+       dma_params->ssc_base = ssc_p->ssc.base;
+       dma_params->substream = substream;
+
+       ssc_p->dma_params[dir] = dma_params;
+
+       /*
+        * The cpu_dai->dma_data field is only used to communicate the
+        * appropriate DMA parameters to the pcm driver hw_params()
+        * function.  It should not be used for other purposes
+        * as it is common to all substreams.
+        */
+       rtd->dai->cpu_dai->dma_data = dma_params;
+
+       channels = params_channels(params);
+
+       /*
+        * The SSC only supports up to 16-bit samples in I2S format, due
+        * to the size of the Frame Mode Register FSLEN field.  Also, I2S
+        * implies signed data.
+        */
+       bits = 16;
+       dma_params->pdc_xfer_size = 2;
+
+       /*
+        * Compute SSC register settings.
+        */
+       switch (ssc_p->daifmt) {
+       case SND_SOC_DAIFMT_CBS_CFS:
+               /*
+                * SSC provides BCLK and LRC clocks.
+                *
+                * The SSC transmit and receive clocks are generated from the
+                * MCK divider, and the BCLK signal is output on the SSC TK line.
+                */
+               rcmr =    (( ssc_p->rcmr_period         << 24) & AT91_SSC_PERIOD)
+                       | (( 1                          << 16) & AT91_SSC_STTDLY)
+                       | (( AT91_SSC_START_FALLING_RF       ) & AT91_SSC_START)
+                       | (( AT91_SSC_CK_RISING              ) & AT91_SSC_CKI)
+                       | (( AT91_SSC_CKO_NONE               ) & AT91_SSC_CKO)
+                       | (( AT91_SSC_CKS_DIV                ) & AT91_SSC_CKS);
+
+               rfmr =    (( AT91_SSC_FSEDGE_POSITIVE        ) & AT91_SSC_FSEDGE)
+                       | (( AT91_SSC_FSOS_NEGATIVE          ) & AT91_SSC_FSOS)
+                       | (((bits - 1)                  << 16) & AT91_SSC_FSLEN)
+                       | (((channels - 1)              <<  8) & AT91_SSC_DATNB)
+                       | (( 1                          <<  7) & AT91_SSC_MSBF)
+                       | (( 0                          <<  5) & AT91_SSC_LOOP)
+                       | (((bits - 1)                  <<  0) & AT91_SSC_DATALEN);
+
+               tcmr =    (( ssc_p->tcmr_period         << 24) & AT91_SSC_PERIOD)
+                       | (( 1                          << 16) & AT91_SSC_STTDLY)
+                       | (( AT91_SSC_START_FALLING_RF       ) & AT91_SSC_START)
+                       | (( AT91_SSC_CKI_FALLING            ) & AT91_SSC_CKI)
+                       | (( AT91_SSC_CKO_CONTINUOUS         ) & AT91_SSC_CKO)
+                       | (( AT91_SSC_CKS_DIV                ) & AT91_SSC_CKS);
+
+               tfmr =    (( AT91_SSC_FSEDGE_POSITIVE        ) & AT91_SSC_FSEDGE)
+                       | (( 0                          << 23) & AT91_SSC_FSDEN)
+                       | (( AT91_SSC_FSOS_NEGATIVE          ) & AT91_SSC_FSOS)
+                       | (((bits - 1)                  << 16) & AT91_SSC_FSLEN)
+                       | (((channels - 1)              <<  8) & AT91_SSC_DATNB)
+                       | (( 1                          <<  7) & AT91_SSC_MSBF)
+                       | (( 0                          <<  5) & AT91_SSC_DATDEF)
+                       | (((bits - 1)                  <<  0) & AT91_SSC_DATALEN);
+               break;
+
+       case SND_SOC_DAIFMT_CBM_CFM:
+
+               /*
+                * CODEC supplies BCLK and LRC clocks.
+                *
+                * The SSC transmit clock is obtained from the BCLK signal on
+                * on the TK line, and the SSC receive clock is generated from the
+                * transmit clock.
+                *
+                * For single channel data, one sample is transferred on the falling
+                * edge of the LRC clock.  For two channel data, one sample is
+                * transferred on both edges of the LRC clock.
+                */
+               start_event = channels == 1
+                               ? AT91_SSC_START_FALLING_RF
+                               : AT91_SSC_START_EDGE_RF;
+
+               rcmr =    (( 0                          << 24) & AT91_SSC_PERIOD)
+                       | (( 1                          << 16) & AT91_SSC_STTDLY)
+                       | (( start_event                     ) & AT91_SSC_START)
+                       | (( AT91_SSC_CK_RISING              ) & AT91_SSC_CKI)
+                       | (( AT91_SSC_CKO_NONE               ) & AT91_SSC_CKO)
+                       | (( AT91_SSC_CKS_CLOCK              ) & AT91_SSC_CKS);
+
+               rfmr =    (( AT91_SSC_FSEDGE_POSITIVE        ) & AT91_SSC_FSEDGE)
+                       | (( AT91_SSC_FSOS_NONE              ) & AT91_SSC_FSOS)
+                       | (( 0                          << 16) & AT91_SSC_FSLEN)
+                       | (( 0                          <<  8) & AT91_SSC_DATNB)
+                       | (( 1                          <<  7) & AT91_SSC_MSBF)
+                       | (( 0                          <<  5) & AT91_SSC_LOOP)
+                       | (((bits - 1)                  <<  0) & AT91_SSC_DATALEN);
+
+               tcmr =    (( 0                          << 24) & AT91_SSC_PERIOD)
+                       | (( 1                          << 16) & AT91_SSC_STTDLY)
+                       | (( start_event                     ) & AT91_SSC_START)
+                       | (( AT91_SSC_CKI_FALLING            ) & AT91_SSC_CKI)
+                       | (( AT91_SSC_CKO_NONE               ) & AT91_SSC_CKO)
+                       | (( AT91_SSC_CKS_PIN                ) & AT91_SSC_CKS);
+
+               tfmr =    (( AT91_SSC_FSEDGE_POSITIVE        ) & AT91_SSC_FSEDGE)
+                       | (( 0                          << 23) & AT91_SSC_FSDEN)
+                       | (( AT91_SSC_FSOS_NONE              ) & AT91_SSC_FSOS)
+                       | (( 0                          << 16) & AT91_SSC_FSLEN)
+                       | (( 0                          <<  8) & AT91_SSC_DATNB)
+                       | (( 1                          <<  7) & AT91_SSC_MSBF)
+                       | (( 0                          <<  5) & AT91_SSC_DATDEF)
+                       | (((bits - 1)                  <<  0) & AT91_SSC_DATALEN);
+               break;
+
+       case SND_SOC_DAIFMT_CBS_CFM:
+       case SND_SOC_DAIFMT_CBM_CFS:
+       default:
+               printk(KERN_WARNING "at91-i2s: unsupported DAI format 0x%x.\n",
+                       ssc_p->daifmt);
+               return -EINVAL;
+               break;
+       }
+       DBG("RCMR=%08x RFMR=%08x TCMR=%08x TFMR=%08x\n", rcmr, rfmr, tcmr, tfmr);
+
+       if (!ssc_p->initialized) {
+
+               /* Enable PMC peripheral clock for this SSC */
+               DBG("Starting pid %d clock\n", ssc_p->ssc.pid);
+               at91_sys_write(AT91_PMC_PCER, 1<<ssc_p->ssc.pid);
+
+               /* Reset the SSC and its PDC registers */
+               at91_ssc_write(ssc_p->ssc.base + AT91_SSC_CR, AT91_SSC_SWRST);
+
+               at91_ssc_write(ssc_p->ssc.base + AT91_PDC_RPR, 0);
+               at91_ssc_write(ssc_p->ssc.base + AT91_PDC_RCR, 0);
+               at91_ssc_write(ssc_p->ssc.base + AT91_PDC_RNPR, 0);
+               at91_ssc_write(ssc_p->ssc.base + AT91_PDC_RNCR, 0);
+               at91_ssc_write(ssc_p->ssc.base + AT91_PDC_TPR, 0);
+               at91_ssc_write(ssc_p->ssc.base + AT91_PDC_TCR, 0);
+               at91_ssc_write(ssc_p->ssc.base + AT91_PDC_TNPR, 0);
+               at91_ssc_write(ssc_p->ssc.base + AT91_PDC_TNCR, 0);
+
+               if ((ret = request_irq(ssc_p->ssc.pid, at91_i2s_interrupt,
+                                       0, ssc_p->name, ssc_p)) < 0) {
+                       printk(KERN_WARNING "at91-i2s: request_irq failure\n");
+
+                       DBG("Stopping pid %d clock\n", ssc_p->ssc.pid);
+                       at91_sys_write(AT91_PMC_PCER, 1<<ssc_p->ssc.pid);
+                       return ret;
+               }
+
+               ssc_p->initialized = 1;
+       }
+
+       /* set SSC clock mode register */
+       at91_ssc_write(ssc_p->ssc.base + AT91_SSC_CMR, ssc_p->cmr_div);
+
+       /* set receive clock mode and format */
+       at91_ssc_write(ssc_p->ssc.base + AT91_SSC_RCMR, rcmr);
+       at91_ssc_write(ssc_p->ssc.base + AT91_SSC_RFMR, rfmr);
+
+       /* set transmit clock mode and format */
+       at91_ssc_write(ssc_p->ssc.base + AT91_SSC_TCMR, tcmr);
+       at91_ssc_write(ssc_p->ssc.base + AT91_SSC_TFMR, tfmr);
+
+       DBG("hw_params: SSC initialized\n");
+       return 0;
+}
+
+
+static int at91_i2s_prepare(struct snd_pcm_substream *substream)
+{
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct at91_ssc_info *ssc_p = &ssc_info[rtd->dai->cpu_dai->id];
+       struct at91_pcm_dma_params *dma_params;
+       int dir;
+
+       dir = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 0 : 1;
+       dma_params = ssc_p->dma_params[dir];
+
+       at91_ssc_write(dma_params->ssc_base + AT91_SSC_CR,
+                       dma_params->mask->ssc_enable);
+
+       DBG("%s enabled SSC_SR=0x%08lx\n", dir ? "receive" : "transmit",
+               at91_ssc_read(dma_params->ssc_base + AT91_SSC_SR));
+       return 0;
+}
+
+
+#ifdef CONFIG_PM
+static int at91_i2s_suspend(struct platform_device *pdev,
+       struct snd_soc_cpu_dai *cpu_dai)
+{
+       struct at91_ssc_info *ssc_p;
+
+       if(!cpu_dai->active)
+               return 0;
+
+       ssc_p = &ssc_info[cpu_dai->id];
+
+       /* Save the status register before disabling transmit and receive. */
+       ssc_p->ssc_state.ssc_sr = at91_ssc_read(ssc_p->ssc.base + AT91_SSC_SR);
+       at91_ssc_write(ssc_p->ssc.base + AT91_SSC_CR,
+                       AT91_SSC_TXDIS | AT91_SSC_RXDIS);
+
+       /* Save the current interrupt mask, then disable unmasked interrupts. */
+       ssc_p->ssc_state.ssc_imr = at91_ssc_read(ssc_p->ssc.base + AT91_SSC_IMR);
+       at91_ssc_write(ssc_p->ssc.base + AT91_SSC_IDR, ssc_p->ssc_state.ssc_imr);
+
+       ssc_p->ssc_state.ssc_cmr  = at91_ssc_read(ssc_p->ssc.base + AT91_SSC_CMR);
+       ssc_p->ssc_state.ssc_rcmr = at91_ssc_read(ssc_p->ssc.base + AT91_SSC_RCMR);
+       ssc_p->ssc_state.ssc_rfmr = at91_ssc_read(ssc_p->ssc.base + AT91_SSC_RFMR);
+       ssc_p->ssc_state.ssc_tcmr = at91_ssc_read(ssc_p->ssc.base + AT91_SSC_TCMR);
+       ssc_p->ssc_state.ssc_tfmr = at91_ssc_read(ssc_p->ssc.base + AT91_SSC_TFMR);
+
+       return 0;
+}
+
+static int at91_i2s_resume(struct platform_device *pdev,
+       struct snd_soc_cpu_dai *cpu_dai)
+{
+       struct at91_ssc_info *ssc_p;
+
+       if(!cpu_dai->active)
+               return 0;
+
+       ssc_p = &ssc_info[cpu_dai->id];
+
+       at91_ssc_write(ssc_p->ssc.base + AT91_SSC_TFMR, ssc_p->ssc_state.ssc_tfmr);
+       at91_ssc_write(ssc_p->ssc.base + AT91_SSC_TCMR, ssc_p->ssc_state.ssc_tcmr);
+       at91_ssc_write(ssc_p->ssc.base + AT91_SSC_RFMR, ssc_p->ssc_state.ssc_rfmr);
+       at91_ssc_write(ssc_p->ssc.base + AT91_SSC_RCMR, ssc_p->ssc_state.ssc_rcmr);
+       at91_ssc_write(ssc_p->ssc.base + AT91_SSC_CMR,  ssc_p->ssc_state.ssc_cmr);
+
+       at91_ssc_write(ssc_p->ssc.base + AT91_SSC_IER,  ssc_p->ssc_state.ssc_imr);
+
+       at91_ssc_write(ssc_p->ssc.base + AT91_SSC_CR,
+               ((ssc_p->ssc_state.ssc_sr & AT91_SSC_RXENA) ? AT91_SSC_RXEN : 0) |
+               ((ssc_p->ssc_state.ssc_sr & AT91_SSC_TXENA) ? AT91_SSC_TXEN : 0));
+
+       return 0;
+}
+
+#else
+#define at91_i2s_suspend       NULL
+#define at91_i2s_resume                NULL
+#endif
+
+#define AT91_I2S_RATES (SNDRV_PCM_RATE_8000  | SNDRV_PCM_RATE_11025 |\
+                       SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |\
+                       SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |\
+                       SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |\
+                       SNDRV_PCM_RATE_96000)
+
+struct snd_soc_cpu_dai at91_i2s_dai[NUM_SSC_DEVICES] = {
+       {       .name = "at91_ssc0/i2s",
+               .id = 0,
+               .type = SND_SOC_DAI_I2S,
+               .suspend = at91_i2s_suspend,
+               .resume = at91_i2s_resume,
+               .playback = {
+                       .channels_min = 1,
+                       .channels_max = 2,
+                       .rates = AT91_I2S_RATES,
+                       .formats = SNDRV_PCM_FMTBIT_S16_LE,},
+               .capture = {
+                       .channels_min = 1,
+                       .channels_max = 2,
+                       .rates = AT91_I2S_RATES,
+                       .formats = SNDRV_PCM_FMTBIT_S16_LE,},
+               .ops = {
+                       .startup = at91_i2s_startup,
+                       .shutdown = at91_i2s_shutdown,
+                       .prepare = at91_i2s_prepare,
+                       .hw_params = at91_i2s_hw_params,},
+               .dai_ops = {
+                       .set_sysclk = at91_i2s_set_dai_sysclk,
+                       .set_fmt = at91_i2s_set_dai_fmt,
+                       .set_clkdiv = at91_i2s_set_dai_clkdiv,},
+               .private_data = &ssc_info[0].ssc,
+       },
+#if NUM_SSC_DEVICES == 3
+       {       .name = "at91_ssc1/i2s",
+               .id = 1,
+               .type = SND_SOC_DAI_I2S,
+               .suspend = at91_i2s_suspend,
+               .resume = at91_i2s_resume,
+               .playback = {
+                       .channels_min = 1,
+                       .channels_max = 2,
+                       .rates = AT91_I2S_RATES,
+                       .formats = SNDRV_PCM_FMTBIT_S16_LE,},
+               .capture = {
+                       .channels_min = 1,
+                       .channels_max = 2,
+                       .rates = AT91_I2S_RATES,
+                       .formats = SNDRV_PCM_FMTBIT_S16_LE,},
+               .ops = {
+                       .startup = at91_i2s_startup,
+                       .shutdown = at91_i2s_shutdown,
+                       .prepare = at91_i2s_prepare,
+                       .hw_params = at91_i2s_hw_params,},
+               .dai_ops = {
+                       .set_sysclk = at91_i2s_set_dai_sysclk,
+                       .set_fmt = at91_i2s_set_dai_fmt,
+                       .set_clkdiv = at91_i2s_set_dai_clkdiv,},
+               .private_data = &ssc_info[1].ssc,
+       },
+       {       .name = "at91_ssc2/i2s",
+               .id = 2,
+               .type = SND_SOC_DAI_I2S,
+               .suspend = at91_i2s_suspend,
+               .resume = at91_i2s_resume,
+               .playback = {
+                       .channels_min = 1,
+                       .channels_max = 2,
+                       .rates = AT91_I2S_RATES,
+                       .formats = SNDRV_PCM_FMTBIT_S16_LE,},
+               .capture = {
+                       .channels_min = 1,
+                       .channels_max = 2,
+                       .rates = AT91_I2S_RATES,
+                       .formats = SNDRV_PCM_FMTBIT_S16_LE,},
+               .ops = {
+                       .startup = at91_i2s_startup,
+                       .shutdown = at91_i2s_shutdown,
+                       .prepare = at91_i2s_prepare,
+                       .hw_params = at91_i2s_hw_params,},
+               .dai_ops = {
+                       .set_sysclk = at91_i2s_set_dai_sysclk,
+                       .set_fmt = at91_i2s_set_dai_fmt,
+                       .set_clkdiv = at91_i2s_set_dai_clkdiv,},
+               .private_data = &ssc_info[2].ssc,
+       },
+#endif
+};
+
+EXPORT_SYMBOL_GPL(at91_i2s_dai);
+
+/* Module information */
+MODULE_AUTHOR("Frank Mandarino, fmandarino@endrelia.com, www.endrelia.com");
+MODULE_DESCRIPTION("AT91 I2S ASoC Interface");
+MODULE_LICENSE("GPL");
diff --git a/sound/soc/at91/at91-i2s.h b/sound/soc/at91/at91-i2s.h
new file mode 100644 (file)
index 0000000..f8a875b
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * at91-i2s.h - ALSA I2S interface for the Atmel AT91 SoC
+ *
+ * Author:     Frank Mandarino <fmandarino@endrelia.com>
+ *             Endrelia Technologies Inc.
+ * Created:    Jan 9, 2007
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef _AT91_I2S_H
+#define _AT91_I2S_H
+
+/* I2S system clock ids */
+#define AT91_SYSCLK_MCK                0 /* SSC uses AT91 MCK as system clock */
+
+/* I2S divider ids */
+#define AT91SSC_CMR_DIV                0 /* MCK divider for BCLK */
+#define AT91SSC_TCMR_PERIOD    1 /* BCLK divider for transmit FS */
+#define AT91SSC_RCMR_PERIOD    2 /* BCLK divider for receive FS */
+
+extern struct snd_soc_cpu_dai at91_i2s_dai[];
+
+#endif /* _AT91_I2S_H */
+
diff --git a/sound/soc/at91/at91-pcm.c b/sound/soc/at91/at91-pcm.c
new file mode 100644 (file)
index 0000000..e88b12e
--- /dev/null
@@ -0,0 +1,432 @@
+/*
+ * at91-pcm.c -- ALSA PCM interface for the Atmel AT91 SoC
+ *
+ * Author:     Frank Mandarino <fmandarino@endrelia.com>
+ *             Endrelia Technologies Inc.
+ * Created:    Mar 3, 2006
+ *
+ * Based on pxa2xx-pcm.c by:
+ *
+ * Author:     Nicolas Pitre
+ * Created:    Nov 30, 2004
+ * Copyright:  (C) 2004 MontaVista Software, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+#include <linux/dma-mapping.h>
+
+#include <sound/driver.h>
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/pcm_params.h>
+#include <sound/soc.h>
+
+#include <asm/arch/hardware.h>
+#include <asm/arch/at91_ssc.h>
+#include <asm/arch/at91_pdc.h>
+
+#include "at91-pcm.h"
+
+#if 0
+#define        DBG(x...)       printk(KERN_INFO "at91-pcm: " x)
+#else
+#define        DBG(x...)
+#endif
+
+static const struct snd_pcm_hardware at91_pcm_hardware = {
+       .info                   = SNDRV_PCM_INFO_MMAP |
+                                 SNDRV_PCM_INFO_MMAP_VALID |
+                                 SNDRV_PCM_INFO_INTERLEAVED |
+                                 SNDRV_PCM_INFO_PAUSE,
+       .formats                = SNDRV_PCM_FMTBIT_S16_LE,
+       .period_bytes_min       = 32,
+       .period_bytes_max       = 8192,
+       .periods_min            = 2,
+       .periods_max            = 1024,
+       .buffer_bytes_max       = 32 * 1024,
+};
+
+struct at91_runtime_data {
+       struct at91_pcm_dma_params *params;
+       dma_addr_t dma_buffer;                  /* physical address of dma buffer */
+       dma_addr_t dma_buffer_end;              /* first address beyond DMA buffer */
+       size_t period_size;
+       dma_addr_t period_ptr;                  /* physical address of next period */
+       u32 pdc_xpr_save;                       /* PDC register save */
+       u32 pdc_xcr_save;
+       u32 pdc_xnpr_save;
+       u32 pdc_xncr_save;
+};
+
+static void at91_pcm_dma_irq(u32 ssc_sr,
+       struct snd_pcm_substream *substream)
+{
+       struct at91_runtime_data *prtd = substream->runtime->private_data;
+       struct at91_pcm_dma_params *params = prtd->params;
+       static int count = 0;
+
+       count++;
+
+       if (ssc_sr & params->mask->ssc_endbuf) {
+
+               printk(KERN_WARNING
+                       "at91-pcm: buffer %s on %s (SSC_SR=%#x, count=%d)\n",
+                       substream->stream == SNDRV_PCM_STREAM_PLAYBACK
+                               ? "underrun" : "overrun",
+                       params->name, ssc_sr, count);
+
+               /* re-start the PDC */
+               at91_ssc_write(params->ssc_base + AT91_PDC_PTCR, params->mask->pdc_disable);
+
+               prtd->period_ptr += prtd->period_size;
+               if (prtd->period_ptr >= prtd->dma_buffer_end) {
+                       prtd->period_ptr = prtd->dma_buffer;
+               }
+
+               at91_ssc_write(params->ssc_base + params->pdc->xpr, prtd->period_ptr);
+               at91_ssc_write(params->ssc_base + params->pdc->xcr,
+                               prtd->period_size / params->pdc_xfer_size);
+
+               at91_ssc_write(params->ssc_base + AT91_PDC_PTCR, params->mask->pdc_enable);
+       }
+
+       if (ssc_sr & params->mask->ssc_endx) {
+
+               /* Load the PDC next pointer and counter registers */
+               prtd->period_ptr += prtd->period_size;
+               if (prtd->period_ptr >= prtd->dma_buffer_end) {
+                       prtd->period_ptr = prtd->dma_buffer;
+               }
+               at91_ssc_write(params->ssc_base + params->pdc->xnpr, prtd->period_ptr);
+               at91_ssc_write(params->ssc_base + params->pdc->xncr,
+                               prtd->period_size / params->pdc_xfer_size);
+       }
+
+       snd_pcm_period_elapsed(substream);
+}
+
+static int at91_pcm_hw_params(struct snd_pcm_substream *substream,
+       struct snd_pcm_hw_params *params)
+{
+       struct snd_pcm_runtime *runtime = substream->runtime;
+       struct at91_runtime_data *prtd = runtime->private_data;
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+
+       /* this may get called several times by oss emulation
+        * with different params */
+
+       snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);
+       runtime->dma_bytes = params_buffer_bytes(params);
+
+       prtd->params = rtd->dai->cpu_dai->dma_data;
+       prtd->params->dma_intr_handler = at91_pcm_dma_irq;
+
+       prtd->dma_buffer = runtime->dma_addr;
+       prtd->dma_buffer_end = runtime->dma_addr + runtime->dma_bytes;
+       prtd->period_size = params_period_bytes(params);
+
+       DBG("hw_params: DMA for %s initialized (dma_bytes=%d, period_size=%d)\n",
+               prtd->params->name, runtime->dma_bytes, prtd->period_size);
+       return 0;
+}
+
+static int at91_pcm_hw_free(struct snd_pcm_substream *substream)
+{
+       struct at91_runtime_data *prtd = substream->runtime->private_data;
+       struct at91_pcm_dma_params *params = prtd->params;
+
+       if (params != NULL) {
+               at91_ssc_write(params->ssc_base + AT91_PDC_PTCR, params->mask->pdc_disable);
+               prtd->params->dma_intr_handler = NULL;
+       }
+
+       return 0;
+}
+
+static int at91_pcm_prepare(struct snd_pcm_substream *substream)
+{
+       struct at91_runtime_data *prtd = substream->runtime->private_data;
+       struct at91_pcm_dma_params *params = prtd->params;
+
+       at91_ssc_write(params->ssc_base + AT91_SSC_IDR,
+                       params->mask->ssc_endx | params->mask->ssc_endbuf);
+
+       at91_ssc_write(params->ssc_base + AT91_PDC_PTCR, params->mask->pdc_disable);
+       return 0;
+}
+
+static int at91_pcm_trigger(struct snd_pcm_substream *substream,
+       int cmd)
+{
+       struct at91_runtime_data *prtd = substream->runtime->private_data;
+       struct at91_pcm_dma_params *params = prtd->params;
+       int ret = 0;
+
+       switch (cmd) {
+       case SNDRV_PCM_TRIGGER_START:
+               prtd->period_ptr = prtd->dma_buffer;
+
+               at91_ssc_write(params->ssc_base + params->pdc->xpr, prtd->period_ptr);
+               at91_ssc_write(params->ssc_base + params->pdc->xcr,
+                               prtd->period_size / params->pdc_xfer_size);
+
+               prtd->period_ptr += prtd->period_size;
+               at91_ssc_write(params->ssc_base + params->pdc->xnpr, prtd->period_ptr);
+               at91_ssc_write(params->ssc_base + params->pdc->xncr,
+                               prtd->period_size / params->pdc_xfer_size);
+
+               DBG("trigger: period_ptr=%lx, xpr=%lx, xcr=%ld, xnpr=%lx, xncr=%ld\n",
+                       (unsigned long) prtd->period_ptr,
+                       at91_ssc_read(params->ssc_base + params->pdc->xpr),
+                       at91_ssc_read(params->ssc_base + params->pdc->xcr),
+                       at91_ssc_read(params->ssc_base + params->pdc->xnpr),
+                       at91_ssc_read(params->ssc_base + params->pdc->xncr));
+
+               at91_ssc_write(params->ssc_base + AT91_SSC_IER,
+                       params->mask->ssc_endx | params->mask->ssc_endbuf);
+
+               at91_ssc_write(params->ssc_base + AT91_PDC_PTCR, params->mask->pdc_enable);
+
+               DBG("sr=%lx imr=%lx\n", at91_ssc_read(params->ssc_base + AT91_SSC_SR),
+                                       at91_ssc_read(params->ssc_base + AT91_SSC_IER));
+               break;
+
+       case SNDRV_PCM_TRIGGER_STOP:
+       case SNDRV_PCM_TRIGGER_SUSPEND:
+       case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
+               at91_ssc_write(params->ssc_base + AT91_PDC_PTCR, params->mask->pdc_disable);
+               break;
+
+       case SNDRV_PCM_TRIGGER_RESUME:
+       case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
+               at91_ssc_write(params->ssc_base + AT91_PDC_PTCR, params->mask->pdc_enable);
+               break;
+
+       default:
+               ret = -EINVAL;
+       }
+
+       return ret;
+}
+
+static snd_pcm_uframes_t at91_pcm_pointer(
+       struct snd_pcm_substream *substream)
+{
+       struct snd_pcm_runtime *runtime = substream->runtime;
+       struct at91_runtime_data *prtd = runtime->private_data;
+       struct at91_pcm_dma_params *params = prtd->params;
+       dma_addr_t ptr;
+       snd_pcm_uframes_t x;
+
+       ptr = (dma_addr_t) at91_ssc_read(params->ssc_base + params->pdc->xpr);
+       x = bytes_to_frames(runtime, ptr - prtd->dma_buffer);
+
+       if (x == runtime->buffer_size)
+               x = 0;
+       return x;
+}
+
+static int at91_pcm_open(struct snd_pcm_substream *substream)
+{
+       struct snd_pcm_runtime *runtime = substream->runtime;
+       struct at91_runtime_data *prtd;
+       int ret = 0;
+
+       snd_soc_set_runtime_hwparams(substream, &at91_pcm_hardware);
+
+       /* ensure that buffer size is a multiple of period size */
+       ret = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS);
+       if (ret < 0)
+               goto out;
+
+       prtd = kzalloc(sizeof(struct at91_runtime_data), GFP_KERNEL);
+       if (prtd == NULL) {
+               ret = -ENOMEM;
+               goto out;
+       }
+       runtime->private_data = prtd;
+
+ out:
+       return ret;
+}
+
+static int at91_pcm_close(struct snd_pcm_substream *substream)
+{
+       struct at91_runtime_data *prtd = substream->runtime->private_data;
+
+       kfree(prtd);
+       return 0;
+}
+
+static int at91_pcm_mmap(struct snd_pcm_substream *substream,
+       struct vm_area_struct *vma)
+{
+       struct snd_pcm_runtime *runtime = substream->runtime;
+
+       return dma_mmap_writecombine(substream->pcm->card->dev, vma,
+                                    runtime->dma_area,
+                                    runtime->dma_addr,
+                                    runtime->dma_bytes);
+}
+
+struct snd_pcm_ops at91_pcm_ops = {
+       .open           = at91_pcm_open,
+       .close          = at91_pcm_close,
+       .ioctl          = snd_pcm_lib_ioctl,
+       .hw_params      = at91_pcm_hw_params,
+       .hw_free        = at91_pcm_hw_free,
+       .prepare        = at91_pcm_prepare,
+       .trigger        = at91_pcm_trigger,
+       .pointer        = at91_pcm_pointer,
+       .mmap           = at91_pcm_mmap,
+};
+
+static int at91_pcm_preallocate_dma_buffer(struct snd_pcm *pcm,
+       int stream)
+{
+       struct snd_pcm_substream *substream = pcm->streams[stream].substream;
+       struct snd_dma_buffer *buf = &substream->dma_buffer;
+       size_t size = at91_pcm_hardware.buffer_bytes_max;
+
+       buf->dev.type = SNDRV_DMA_TYPE_DEV;
+       buf->dev.dev = pcm->card->dev;
+       buf->private_data = NULL;
+       buf->area = dma_alloc_writecombine(pcm->card->dev, size,
+                                          &buf->addr, GFP_KERNEL);
+
+       DBG("preallocate_dma_buffer: area=%p, addr=%p, size=%d\n",
+               (void *) buf->area,
+               (void *) buf->addr,
+               size);
+
+       if (!buf->area)
+               return -ENOMEM;
+
+       buf->bytes = size;
+       return 0;
+}
+
+static u64 at91_pcm_dmamask = 0xffffffff;
+
+static int at91_pcm_new(struct snd_card *card,
+       struct snd_soc_codec_dai *dai, struct snd_pcm *pcm)
+{
+       int ret = 0;
+
+       if (!card->dev->dma_mask)
+               card->dev->dma_mask = &at91_pcm_dmamask;
+       if (!card->dev->coherent_dma_mask)
+               card->dev->coherent_dma_mask = 0xffffffff;
+
+       if (dai->playback.channels_min) {
+               ret = at91_pcm_preallocate_dma_buffer(pcm,
+                       SNDRV_PCM_STREAM_PLAYBACK);
+               if (ret)
+                       goto out;
+       }
+
+       if (dai->capture.channels_min) {
+               ret = at91_pcm_preallocate_dma_buffer(pcm,
+                       SNDRV_PCM_STREAM_CAPTURE);
+               if (ret)
+                       goto out;
+       }
+ out:
+       return ret;
+}
+
+static void at91_pcm_free_dma_buffers(struct snd_pcm *pcm)
+{
+       struct snd_pcm_substream *substream;
+       struct snd_dma_buffer *buf;
+       int stream;
+
+       for (stream = 0; stream < 2; stream++) {
+               substream = pcm->streams[stream].substream;
+               if (!substream)
+                       continue;
+
+               buf = &substream->dma_buffer;
+               if (!buf->area)
+                       continue;
+
+               dma_free_writecombine(pcm->card->dev, buf->bytes,
+                                     buf->area, buf->addr);
+               buf->area = NULL;
+       }
+}
+
+#ifdef CONFIG_PM
+static int at91_pcm_suspend(struct platform_device *pdev,
+       struct snd_soc_cpu_dai *dai)
+{
+       struct snd_pcm_runtime *runtime = dai->runtime;
+       struct at91_runtime_data *prtd;
+       struct at91_pcm_dma_params *params;
+
+       if (!runtime)
+               return 0;
+
+       prtd = runtime->private_data;
+       params = prtd->params;
+
+       /* disable the PDC and save the PDC registers */
+
+       at91_ssc_write(params->ssc_base + AT91_PDC_PTCR, params->mask->pdc_disable);
+
+       prtd->pdc_xpr_save  = at91_ssc_read(params->ssc_base + params->pdc->xpr);
+       prtd->pdc_xcr_save  = at91_ssc_read(params->ssc_base + params->pdc->xcr);
+       prtd->pdc_xnpr_save = at91_ssc_read(params->ssc_base + params->pdc->xnpr);
+       prtd->pdc_xncr_save = at91_ssc_read(params->ssc_base + params->pdc->xncr);
+
+       return 0;
+}
+
+static int at91_pcm_resume(struct platform_device *pdev,
+       struct snd_soc_cpu_dai *dai)
+{
+       struct snd_pcm_runtime *runtime = dai->runtime;
+       struct at91_runtime_data *prtd;
+       struct at91_pcm_dma_params *params;
+
+       if (!runtime)
+               return 0;
+
+       prtd = runtime->private_data;
+       params = prtd->params;
+
+       /* restore the PDC registers and enable the PDC */
+       at91_ssc_write(params->ssc_base + params->pdc->xpr,  prtd->pdc_xpr_save);
+       at91_ssc_write(params->ssc_base + params->pdc->xcr,  prtd->pdc_xcr_save);
+       at91_ssc_write(params->ssc_base + params->pdc->xnpr, prtd->pdc_xnpr_save);
+       at91_ssc_write(params->ssc_base + params->pdc->xncr, prtd->pdc_xncr_save);
+
+       at91_ssc_write(params->ssc_base + AT91_PDC_PTCR, params->mask->pdc_enable);
+       return 0;
+}
+#else
+#define at91_pcm_suspend       NULL
+#define at91_pcm_resume                NULL
+#endif
+
+struct snd_soc_platform at91_soc_platform = {
+       .name           = "at91-audio",
+       .pcm_ops        = &at91_pcm_ops,
+       .pcm_new        = at91_pcm_new,
+       .pcm_free       = at91_pcm_free_dma_buffers,
+       .suspend        = at91_pcm_suspend,
+       .resume         = at91_pcm_resume,
+};
+
+EXPORT_SYMBOL_GPL(at91_soc_platform);
+
+MODULE_AUTHOR("Frank Mandarino <fmandarino@endrelia.com>");
+MODULE_DESCRIPTION("Atmel AT91 PCM module");
+MODULE_LICENSE("GPL");
diff --git a/sound/soc/at91/at91-pcm.h b/sound/soc/at91/at91-pcm.h
new file mode 100644 (file)
index 0000000..58d0f00
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * at91-pcm.h - ALSA PCM interface for the Atmel AT91 SoC
+ *
+ * Author:     Frank Mandarino <fmandarino@endrelia.com>
+ *             Endrelia Technologies Inc.
+ * Created:    Mar 3, 2006
+ *
+ * Based on pxa2xx-pcm.h by:
+ *
+ * Author:     Nicolas Pitre
+ * Created:    Nov 30, 2004
+ * Copyright:  MontaVista Software, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef _AT91_PCM_H
+#define _AT91_PCM_H
+
+#include <asm/arch/hardware.h>
+
+struct at91_ssc_periph {
+       void __iomem    *base;
+       u32             pid;
+};
+
+/*
+ * Registers and status bits that are required by the PCM driver.
+ */
+struct at91_pdc_regs {
+       unsigned int    xpr;            /* PDC recv/trans pointer */
+       unsigned int    xcr;            /* PDC recv/trans counter */
+       unsigned int    xnpr;           /* PDC next recv/trans pointer */
+       unsigned int    xncr;           /* PDC next recv/trans counter */
+       unsigned int    ptcr;           /* PDC transfer control */
+};
+
+struct at91_ssc_mask {
+       u32     ssc_enable;             /* SSC recv/trans enable */
+       u32     ssc_disable;            /* SSC recv/trans disable */
+       u32     ssc_endx;               /* SSC ENDTX or ENDRX */
+       u32     ssc_endbuf;             /* SSC TXBUFE or RXBUFF */
+       u32     pdc_enable;             /* PDC recv/trans enable */
+       u32     pdc_disable;            /* PDC recv/trans disable */
+};
+
+/*
+ * This structure, shared between the PCM driver and the interface,
+ * contains all information required by the PCM driver to perform the
+ * PDC DMA operation.  All fields except dma_intr_handler() are initialized
+ * by the interface.  The dms_intr_handler() pointer is set by the PCM
+ * driver and called by the interface SSC interrupt handler if it is
+ * non-NULL.
+ */
+struct at91_pcm_dma_params {
+       char *name;                     /* stream identifier */
+       int pdc_xfer_size;              /* PDC counter increment in bytes */
+       void __iomem *ssc_base;         /* SSC base address */
+       struct at91_pdc_regs *pdc; /* PDC receive or transmit registers */
+       struct at91_ssc_mask *mask;/* SSC & PDC status bits */
+       struct snd_pcm_substream *substream;
+       void (*dma_intr_handler)(u32, struct snd_pcm_substream *);
+};
+
+extern struct snd_soc_platform at91_soc_platform;
+
+#define at91_ssc_read(a)       ((unsigned long) __raw_readl(a))
+#define at91_ssc_write(a,v)    __raw_writel((v),(a))
+
+#endif /* _AT91_PCM_H */
diff --git a/sound/soc/at91/eti_b1_wm8731.c b/sound/soc/at91/eti_b1_wm8731.c
new file mode 100644 (file)
index 0000000..8179df3
--- /dev/null
@@ -0,0 +1,375 @@
+/*
+ * eti_b1_wm8731  --  SoC audio for AT91RM9200-based Endrelia ETI_B1 board.
+ *
+ * Author:     Frank Mandarino <fmandarino@endrelia.com>
+ *             Endrelia Technologies Inc.
+ * Created:    Mar 29, 2006
+ *
+ * Based on corgi.c by:
+ *
+ * Copyright 2005 Wolfson Microelectronics PLC.
+ * Copyright 2005 Openedhand Ltd.
+ *
+ * Authors: Liam Girdwood <liam.girdwood@wolfsonmicro.com>
+ *          Richard Purdie <richard@openedhand.com>
+ *
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/version.h>
+#include <linux/kernel.h>
+#include <linux/clk.h>
+#include <linux/timer.h>
+#include <linux/interrupt.h>
+#include <linux/platform_device.h>
+#include <sound/driver.h>
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/soc.h>
+#include <sound/soc-dapm.h>
+
+#include <asm/arch/hardware.h>
+#include <asm/arch/at91_pio.h>
+#include <asm/arch/gpio.h>
+
+#include "../codecs/wm8731.h"
+#include "at91-pcm.h"
+#include "at91-i2s.h"
+
+#if 0
+#define        DBG(x...)       printk(KERN_INFO "eti_b1_wm8731: " x)
+#else
+#define        DBG(x...)
+#endif
+
+#define AT91_PIO_TF1   (1 << (AT91_PIN_PB6 - PIN_BASE) % 32)
+#define AT91_PIO_TK1   (1 << (AT91_PIN_PB7 - PIN_BASE) % 32)
+#define AT91_PIO_TD1   (1 << (AT91_PIN_PB8 - PIN_BASE) % 32)
+#define AT91_PIO_RD1   (1 << (AT91_PIN_PB9 - PIN_BASE) % 32)
+#define AT91_PIO_RK1   (1 << (AT91_PIN_PB10 - PIN_BASE) % 32)
+#define AT91_PIO_RF1   (1 << (AT91_PIN_PB11 - PIN_BASE) % 32)
+
+static struct clk *pck1_clk;
+static struct clk *pllb_clk;
+
+
+static int eti_b1_startup(struct snd_pcm_substream *substream)
+{
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_codec_dai *codec_dai = rtd->dai->codec_dai;
+       struct snd_soc_cpu_dai *cpu_dai = rtd->dai->cpu_dai;
+       int ret;
+
+       /* cpu clock is the AT91 master clock sent to the SSC */
+       ret = cpu_dai->dai_ops.set_sysclk(cpu_dai, AT91_SYSCLK_MCK,
+               60000000, SND_SOC_CLOCK_IN);
+       if (ret < 0)
+               return ret;
+
+       /* codec system clock is supplied by PCK1, set to 12MHz */
+       ret = codec_dai->dai_ops.set_sysclk(codec_dai, WM8731_SYSCLK,
+               12000000, SND_SOC_CLOCK_IN);
+       if (ret < 0)
+               return ret;
+
+       /* Start PCK1 clock. */
+       clk_enable(pck1_clk);
+       DBG("pck1 started\n");
+
+       return 0;
+}
+
+static void eti_b1_shutdown(struct snd_pcm_substream *substream)
+{
+       /* Stop PCK1 clock. */
+       clk_disable(pck1_clk);
+       DBG("pck1 stopped\n");
+}
+
+static int eti_b1_hw_params(struct snd_pcm_substream *substream,
+       struct snd_pcm_hw_params *params)
+{
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_codec_dai *codec_dai = rtd->dai->codec_dai;
+       struct snd_soc_cpu_dai *cpu_dai = rtd->dai->cpu_dai;
+       int ret;
+
+#ifdef CONFIG_SND_AT91_SOC_ETI_SLAVE
+       unsigned int rate;
+       int cmr_div, period;
+
+       /* set codec DAI configuration */
+       ret = codec_dai->dai_ops.set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
+               SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
+       if (ret < 0)
+               return ret;
+
+       /* set cpu DAI configuration */
+       ret = cpu_dai->dai_ops.set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
+               SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
+       if (ret < 0)
+               return ret;
+
+       /*
+        * The SSC clock dividers depend on the sample rate.  The CMR.DIV
+        * field divides the system master clock MCK to drive the SSC TK
+        * signal which provides the codec BCLK.  The TCMR.PERIOD and
+        * RCMR.PERIOD fields further divide the BCLK signal to drive
+        * the SSC TF and RF signals which provide the codec DACLRC and
+        * ADCLRC clocks.
+        *
+        * The dividers were determined through trial and error, where a
+        * CMR.DIV value is chosen such that the resulting BCLK value is
+        * divisible, or almost divisible, by (2 * sample rate), and then
+        * the TCMR.PERIOD or RCMR.PERIOD is BCLK / (2 * sample rate) - 1.
+        */
+       rate = params_rate(params);
+
+       switch (rate) {
+       case 8000:
+               cmr_div = 25;   /* BCLK = 60MHz/(2*25) = 1.2MHz */
+               period = 74;    /* LRC = BCLK/(2*(74+1)) = 8000Hz */
+               break;
+       case 32000:
+               cmr_div = 7;    /* BCLK = 60MHz/(2*7) ~= 4.28571428MHz */
+               period = 66;    /* LRC = BCLK/(2*(66+1)) = 31982.942Hz */
+               break;
+       case 48000:
+               cmr_div = 13;   /* BCLK = 60MHz/(2*13) ~= 2.3076923MHz */
+               period = 23;    /* LRC = BCLK/(2*(23+1)) = 48076.923Hz */
+               break;
+       default:
+               printk(KERN_WARNING "unsupported rate %d on ETI-B1 board\n", rate);
+               return -EINVAL;
+       }
+
+       /* set the MCK divider for BCLK */
+       ret = cpu_dai->dai_ops.set_clkdiv(cpu_dai, AT91SSC_CMR_DIV, cmr_div);
+       if (ret < 0)
+               return ret;
+
+       if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+               /* set the BCLK divider for DACLRC */
+               ret = cpu_dai->dai_ops.set_clkdiv(cpu_dai,
+                                               AT91SSC_TCMR_PERIOD, period);
+       } else {
+               /* set the BCLK divider for ADCLRC */
+               ret = cpu_dai->dai_ops.set_clkdiv(cpu_dai,
+                                               AT91SSC_RCMR_PERIOD, period);
+       }
+       if (ret < 0)
+               return ret;
+
+#else /* CONFIG_SND_AT91_SOC_ETI_SLAVE */
+       /*
+        * Codec in Master Mode.
+        */
+
+       /* set codec DAI configuration */
+       ret = codec_dai->dai_ops.set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
+               SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
+       if (ret < 0)
+               return ret;
+
+       /* set cpu DAI configuration */
+       ret = cpu_dai->dai_ops.set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
+               SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
+       if (ret < 0)
+               return ret;
+
+#endif /* CONFIG_SND_AT91_SOC_ETI_SLAVE */
+
+       return 0;
+}
+
+static struct snd_soc_ops eti_b1_ops = {
+       .startup = eti_b1_startup,
+       .hw_params = eti_b1_hw_params,
+       .shutdown = eti_b1_shutdown,
+};
+
+
+static const struct snd_soc_dapm_widget eti_b1_dapm_widgets[] = {
+       SND_SOC_DAPM_MIC("Int Mic", NULL),
+       SND_SOC_DAPM_SPK("Ext Spk", NULL),
+};
+
+static const char *intercon[][3] = {
+
+       /* speaker connected to LHPOUT */
+       {"Ext Spk", NULL, "LHPOUT"},
+
+       /* mic is connected to Mic Jack, with WM8731 Mic Bias */
+       {"MICIN", NULL, "Mic Bias"},
+       {"Mic Bias", NULL, "Int Mic"},
+
+       /* terminator */
+       {NULL, NULL, NULL},
+};
+
+/*
+ * Logic for a wm8731 as connected on a Endrelia ETI-B1 board.
+ */
+static int eti_b1_wm8731_init(struct snd_soc_codec *codec)
+{
+       int i;
+
+       DBG("eti_b1_wm8731_init() called\n");
+
+       /* Add specific widgets */
+       for(i = 0; i < ARRAY_SIZE(eti_b1_dapm_widgets); i++) {
+               snd_soc_dapm_new_control(codec, &eti_b1_dapm_widgets[i]);
+       }
+
+       /* Set up specific audio path interconnects */
+       for(i = 0; intercon[i][0] != NULL; i++) {
+               snd_soc_dapm_connect_input(codec, intercon[i][0],
+                       intercon[i][1], intercon[i][2]);
+       }
+
+       /* not connected */
+       snd_soc_dapm_set_endpoint(codec, "RLINEIN", 0);
+       snd_soc_dapm_set_endpoint(codec, "LLINEIN", 0);
+
+       /* always connected */
+       snd_soc_dapm_set_endpoint(codec, "Int Mic", 1);
+       snd_soc_dapm_set_endpoint(codec, "Ext Spk", 1);
+
+       snd_soc_dapm_sync_endpoints(codec);
+
+       return 0;
+}
+
+static struct snd_soc_dai_link eti_b1_dai = {
+       .name = "WM8731",
+       .stream_name = "WM8731",
+       .cpu_dai = &at91_i2s_dai[1],
+       .codec_dai = &wm8731_dai,
+       .init = eti_b1_wm8731_init,
+       .ops = &eti_b1_ops,
+};
+
+static struct snd_soc_machine snd_soc_machine_eti_b1 = {
+       .name = "ETI_B1",
+       .dai_link = &eti_b1_dai,
+       .num_links = 1,
+};
+
+static struct wm8731_setup_data eti_b1_wm8731_setup = {
+       .i2c_address = 0x1a,
+};
+
+static struct snd_soc_device eti_b1_snd_devdata = {
+       .machine = &snd_soc_machine_eti_b1,
+       .platform = &at91_soc_platform,
+       .codec_dev = &soc_codec_dev_wm8731,
+       .codec_data = &eti_b1_wm8731_setup,
+};
+
+static struct platform_device *eti_b1_snd_device;
+
+static int __init eti_b1_init(void)
+{
+       int ret;
+       u32 ssc_pio_lines;
+       struct at91_ssc_periph *ssc = eti_b1_dai.cpu_dai->private_data;
+
+       if (!request_mem_region(AT91RM9200_BASE_SSC1, SZ_16K, "soc-audio")) {
+               DBG("SSC1 memory region is busy\n");
+               return -EBUSY;
+       }
+
+       ssc->base = ioremap(AT91RM9200_BASE_SSC1, SZ_16K);
+       if (!ssc->base) {
+               DBG("SSC1 memory ioremap failed\n");
+               ret = -ENOMEM;
+               goto fail_release_mem;
+       }
+
+       ssc->pid = AT91RM9200_ID_SSC1;
+
+       eti_b1_snd_device = platform_device_alloc("soc-audio", -1);
+       if (!eti_b1_snd_device) {
+               DBG("platform device allocation failed\n");
+               ret = -ENOMEM;
+               goto fail_io_unmap;
+       }
+
+       platform_set_drvdata(eti_b1_snd_device, &eti_b1_snd_devdata);
+       eti_b1_snd_devdata.dev = &eti_b1_snd_device->dev;
+
+       ret = platform_device_add(eti_b1_snd_device);
+       if (ret) {
+               DBG("platform device add failed\n");
+               platform_device_put(eti_b1_snd_device);
+               goto fail_io_unmap;
+       }
+
+       ssc_pio_lines = AT91_PIO_TF1 | AT91_PIO_TK1 | AT91_PIO_TD1
+                       | AT91_PIO_RD1 /* | AT91_PIO_RK1 */ | AT91_PIO_RF1;
+
+       /* Reset all PIO registers and assign lines to peripheral A */
+       at91_sys_write(AT91_PIOB + PIO_PDR,  ssc_pio_lines);
+       at91_sys_write(AT91_PIOB + PIO_ODR,  ssc_pio_lines);
+       at91_sys_write(AT91_PIOB + PIO_IFDR, ssc_pio_lines);
+       at91_sys_write(AT91_PIOB + PIO_CODR, ssc_pio_lines);
+       at91_sys_write(AT91_PIOB + PIO_IDR,  ssc_pio_lines);
+       at91_sys_write(AT91_PIOB + PIO_MDDR, ssc_pio_lines);
+       at91_sys_write(AT91_PIOB + PIO_PUDR, ssc_pio_lines);
+       at91_sys_write(AT91_PIOB + PIO_ASR,  ssc_pio_lines);
+       at91_sys_write(AT91_PIOB + PIO_OWDR, ssc_pio_lines);
+
+       /*
+        * Set PCK1 parent to PLLB and its rate to 12 Mhz.
+        */
+       pllb_clk = clk_get(NULL, "pllb");
+       pck1_clk = clk_get(NULL, "pck1");
+
+       clk_set_parent(pck1_clk, pllb_clk);
+       clk_set_rate(pck1_clk, 12000000);
+
+       DBG("MCLK rate %luHz\n", clk_get_rate(pck1_clk));
+
+       /* assign the GPIO pin to PCK1 */
+       at91_set_B_periph(AT91_PIN_PA24, 0);
+
+#ifdef CONFIG_SND_AT91_SOC_ETI_SLAVE
+       printk(KERN_INFO "eti_b1_wm8731: Codec in Slave Mode\n");
+#else
+       printk(KERN_INFO "eti_b1_wm8731: Codec in Master Mode\n");
+#endif
+       return ret;
+
+fail_io_unmap:
+       iounmap(ssc->base);
+fail_release_mem:
+       release_mem_region(AT91RM9200_BASE_SSC1, SZ_16K);
+       return ret;
+}
+
+static void __exit eti_b1_exit(void)
+{
+       struct at91_ssc_periph *ssc = eti_b1_dai.cpu_dai->private_data;
+
+       clk_put(pck1_clk);
+       clk_put(pllb_clk);
+
+       platform_device_unregister(eti_b1_snd_device);
+
+       iounmap(ssc->base);
+       release_mem_region(AT91RM9200_BASE_SSC1, SZ_16K);
+}
+
+module_init(eti_b1_init);
+module_exit(eti_b1_exit);
+
+/* Module information */
+MODULE_AUTHOR("Frank Mandarino <fmandarino@endrelia.com>");
+MODULE_DESCRIPTION("ALSA SoC ETI-B1-WM8731");
+MODULE_LICENSE("GPL");
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
new file mode 100644 (file)
index 0000000..78ac268
--- /dev/null
@@ -0,0 +1,15 @@
+config SND_SOC_AC97_CODEC
+       tristate
+       depends SND_SOC
+
+config SND_SOC_WM8731
+       tristate
+       depends SND_SOC
+
+config SND_SOC_WM8750
+       tristate
+       depends SND_SOC
+
+config SND_SOC_WM9712
+       tristate
+       depends SND_SOC
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
new file mode 100644 (file)
index 0000000..3249a6e
--- /dev/null
@@ -0,0 +1,9 @@
+snd-soc-ac97-objs := ac97.o
+snd-soc-wm8731-objs := wm8731.o
+snd-soc-wm8750-objs := wm8750.o
+snd-soc-wm9712-objs := wm9712.o
+
+obj-$(CONFIG_SND_SOC_AC97_CODEC)       += snd-soc-ac97.o
+obj-$(CONFIG_SND_SOC_WM8731)   += snd-soc-wm8731.o
+obj-$(CONFIG_SND_SOC_WM8750)   += snd-soc-wm8750.o
+obj-$(CONFIG_SND_SOC_WM9712)   += snd-soc-wm9712.o
diff --git a/sound/soc/codecs/ac97.c b/sound/soc/codecs/ac97.c
new file mode 100644 (file)
index 0000000..55bc55e
--- /dev/null
@@ -0,0 +1,156 @@
+/*
+ * ac97.c  --  ALSA Soc AC97 codec support
+ *
+ * Copyright 2005 Wolfson Microelectronics PLC.
+ * Author: Liam Girdwood
+ *         liam.girdwood@wolfsonmicro.com or linux@wolfsonmicro.com
+ *
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ *
+ *  Revision history
+ *    17th Oct 2005   Initial version.
+ *
+ * Generic AC97 support.
+ */
+
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/device.h>
+#include <sound/driver.h>
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/ac97_codec.h>
+#include <sound/initval.h>
+#include <sound/soc.h>
+
+#define AC97_VERSION "0.6"
+
+static int ac97_prepare(struct snd_pcm_substream *substream)
+{
+       struct snd_pcm_runtime *runtime = substream->runtime;
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_device *socdev = rtd->socdev;
+       struct snd_soc_codec *codec = socdev->codec;
+
+       int reg = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ?
+                 AC97_PCM_FRONT_DAC_RATE : AC97_PCM_LR_ADC_RATE;
+       return snd_ac97_set_rate(codec->ac97, reg, runtime->rate);
+}
+
+#define STD_AC97_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\
+               SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000)
+
+static struct snd_soc_codec_dai ac97_dai = {
+       .name = "AC97 HiFi",
+       .playback = {
+               .stream_name = "AC97 Playback",
+               .channels_min = 1,
+               .channels_max = 2,
+               .rates = STD_AC97_RATES,
+               .formats = SNDRV_PCM_FMTBIT_S16_LE,},
+       .capture = {
+               .stream_name = "AC97 Capture",
+               .channels_min = 1,
+               .channels_max = 2,
+               .rates = STD_AC97_RATES,
+               .formats = SNDRV_PCM_FMTBIT_S16_LE,},
+       .ops = {
+               .prepare = ac97_prepare,},
+};
+
+static unsigned int ac97_read(struct snd_soc_codec *codec,
+       unsigned int reg)
+{
+       return soc_ac97_ops.read(codec->ac97, reg);
+}
+
+static int ac97_write(struct snd_soc_codec *codec, unsigned int reg,
+       unsigned int val)
+{
+       soc_ac97_ops.write(codec->ac97, reg, val);
+       return 0;
+}
+
+static int ac97_soc_probe(struct platform_device *pdev)
+{
+       struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+       struct snd_soc_codec *codec;
+       struct snd_ac97_bus *ac97_bus;
+       struct snd_ac97_template ac97_template;
+       int ret = 0;
+
+       printk(KERN_INFO "AC97 SoC Audio Codec %s\n", AC97_VERSION);
+
+       socdev->codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL);
+       if (socdev->codec == NULL)
+               return -ENOMEM;
+       codec = socdev->codec;
+       mutex_init(&codec->mutex);
+
+       codec->name = "AC97";
+       codec->owner = THIS_MODULE;
+       codec->dai = &ac97_dai;
+       codec->num_dai = 1;
+       codec->write = ac97_write;
+       codec->read = ac97_read;
+       INIT_LIST_HEAD(&codec->dapm_widgets);
+       INIT_LIST_HEAD(&codec->dapm_paths);
+
+       /* register pcms */
+       ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
+       if(ret < 0)
+               goto err;
+
+       /* add codec as bus device for standard ac97 */
+       ret = snd_ac97_bus(codec->card, 0, &soc_ac97_ops, NULL, &ac97_bus);
+       if(ret < 0)
+               goto bus_err;
+
+       memset(&ac97_template, 0, sizeof(struct snd_ac97_template));
+       ret = snd_ac97_mixer(ac97_bus, &ac97_template, &codec->ac97);
+       if(ret < 0)
+               goto bus_err;
+
+       ret = snd_soc_register_card(socdev);
+       if (ret < 0)
+               goto bus_err;
+       return 0;
+
+bus_err:
+       snd_soc_free_pcms(socdev);
+
+err:
+       kfree(socdev->codec->reg_cache);
+       kfree(socdev->codec);
+       socdev->codec = NULL;
+       return ret;
+}
+
+static int ac97_soc_remove(struct platform_device *pdev)
+{
+       struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+       struct snd_soc_codec *codec = socdev->codec;
+
+       if(codec == NULL)
+               return 0;
+
+       snd_soc_free_pcms(socdev);
+       kfree(socdev->codec->reg_cache);
+       kfree(socdev->codec);
+
+       return 0;
+}
+
+struct snd_soc_codec_device soc_codec_dev_ac97= {
+       .probe =        ac97_soc_probe,
+       .remove =       ac97_soc_remove,
+};
+
+EXPORT_SYMBOL_GPL(soc_codec_dev_ac97);
+
+MODULE_DESCRIPTION("Soc Generic AC97 driver");
+MODULE_AUTHOR("Liam Girdwood");
+MODULE_LICENSE("GPL");
diff --git a/sound/soc/codecs/ac97.h b/sound/soc/codecs/ac97.h
new file mode 100644 (file)
index 0000000..930ddfc
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * linux/sound/codecs/ac97.h -- ALSA SoC Layer
+ *
+ * Author:             Liam Girdwood
+ * Created:            Dec 1st 2005
+ * Copyright:  Wolfson Microelectronics. PLC.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __LINUX_SND_SOC_AC97_H
+#define __LINUX_SND_SOC_AC97_H
+
+extern struct snd_soc_codec_device soc_codec_dev_ac97;
+
+#endif
diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c
new file mode 100644 (file)
index 0000000..7ca0b52
--- /dev/null
@@ -0,0 +1,758 @@
+/*
+ * wm8731.c  --  WM8731 ALSA SoC Audio driver
+ *
+ * Copyright 2005 Openedhand Ltd.
+ *
+ * Author: Richard Purdie <richard@openedhand.com>
+ *
+ * Based on wm8753.c by Liam Girdwood
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/init.h>
+#include <linux/delay.h>
+#include <linux/pm.h>
+#include <linux/i2c.h>
+#include <linux/platform_device.h>
+#include <sound/driver.h>
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/pcm_params.h>
+#include <sound/soc.h>
+#include <sound/soc-dapm.h>
+#include <sound/initval.h>
+
+#include "wm8731.h"
+
+#define AUDIO_NAME "wm8731"
+#define WM8731_VERSION "0.13"
+
+/*
+ * Debug
+ */
+
+#define WM8731_DEBUG 0
+
+#ifdef WM8731_DEBUG
+#define dbg(format, arg...) \
+       printk(KERN_DEBUG AUDIO_NAME ": " format "\n" , ## arg)
+#else
+#define dbg(format, arg...) do {} while (0)
+#endif
+#define err(format, arg...) \
+       printk(KERN_ERR AUDIO_NAME ": " format "\n" , ## arg)
+#define info(format, arg...) \
+       printk(KERN_INFO AUDIO_NAME ": " format "\n" , ## arg)
+#define warn(format, arg...) \
+       printk(KERN_WARNING AUDIO_NAME ": " format "\n" , ## arg)
+
+struct snd_soc_codec_device soc_codec_dev_wm8731;
+
+/* codec private data */
+struct wm8731_priv {
+       unsigned int sysclk;
+};
+
+/*
+ * wm8731 register cache
+ * We can't read the WM8731 register space when we are
+ * using 2 wire for device control, so we cache them instead.
+ * There is no point in caching the reset register
+ */
+static const u16 wm8731_reg[WM8731_CACHEREGNUM] = {
+    0x0097, 0x0097, 0x0079, 0x0079,
+    0x000a, 0x0008, 0x009f, 0x000a,
+    0x0000, 0x0000
+};
+
+/*
+ * read wm8731 register cache
+ */
+static inline unsigned int wm8731_read_reg_cache(struct snd_soc_codec *codec,
+       unsigned int reg)
+{
+       u16 *cache = codec->reg_cache;
+       if (reg == WM8731_RESET)
+               return 0;
+       if (reg >= WM8731_CACHEREGNUM)
+               return -1;
+       return cache[reg];
+}
+
+/*
+ * write wm8731 register cache
+ */
+static inline void wm8731_write_reg_cache(struct snd_soc_codec *codec,
+       u16 reg, unsigned int value)
+{
+       u16 *cache = codec->reg_cache;
+       if (reg >= WM8731_CACHEREGNUM)
+               return;
+       cache[reg] = value;
+}
+
+/*
+ * write to the WM8731 register space
+ */
+static int wm8731_write(struct snd_soc_codec *codec, unsigned int reg,
+       unsigned int value)
+{
+       u8 data[2];
+
+       /* data is
+        *   D15..D9 WM8731 register offset
+        *   D8...D0 register data
+        */
+       data[0] = (reg << 1) | ((value >> 8) & 0x0001);
+       data[1] = value & 0x00ff;
+
+       wm8731_write_reg_cache (codec, reg, value);
+       if (codec->hw_write(codec->control_data, data, 2) == 2)
+               return 0;
+       else
+               return -EIO;
+}
+
+#define wm8731_reset(c)        wm8731_write(c, WM8731_RESET, 0)
+
+static const char *wm8731_input_select[] = {"Line In", "Mic"};
+static const char *wm8731_deemph[] = {"None", "32Khz", "44.1Khz", "48Khz"};
+
+static const struct soc_enum wm8731_enum[] = {
+       SOC_ENUM_SINGLE(WM8731_APANA, 2, 2, wm8731_input_select),
+       SOC_ENUM_SINGLE(WM8731_APDIGI, 1, 4, wm8731_deemph),
+};
+
+static const struct snd_kcontrol_new wm8731_snd_controls[] = {
+
+SOC_DOUBLE_R("Master Playback Volume", WM8731_LOUT1V, WM8731_ROUT1V,
+       0, 127, 0),
+SOC_DOUBLE_R("Master Playback ZC Switch", WM8731_LOUT1V, WM8731_ROUT1V,
+       7, 1, 0),
+
+SOC_DOUBLE_R("Capture Volume", WM8731_LINVOL, WM8731_RINVOL, 0, 31, 0),
+SOC_DOUBLE_R("Line Capture Switch", WM8731_LINVOL, WM8731_RINVOL, 7, 1, 1),
+
+SOC_SINGLE("Mic Boost (+20dB)", WM8731_APANA, 0, 1, 0),
+SOC_SINGLE("Capture Mic Switch", WM8731_APANA, 1, 1, 1),
+
+SOC_SINGLE("Sidetone Playback Volume", WM8731_APANA, 6, 3, 1),
+
+SOC_SINGLE("ADC High Pass Filter Switch", WM8731_APDIGI, 0, 1, 1),
+SOC_SINGLE("Store DC Offset Switch", WM8731_APDIGI, 4, 1, 0),
+
+SOC_ENUM("Playback De-emphasis", wm8731_enum[1]),
+};
+
+/* add non dapm controls */
+static int wm8731_add_controls(struct snd_soc_codec *codec)
+{
+       int err, i;
+
+       for (i = 0; i < ARRAY_SIZE(wm8731_snd_controls); i++) {
+               if ((err = snd_ctl_add(codec->card,
+                               snd_soc_cnew(&wm8731_snd_controls[i],codec, NULL))) < 0)
+                       return err;
+       }
+
+       return 0;
+}
+
+/* Output Mixer */
+static const struct snd_kcontrol_new wm8731_output_mixer_controls[] = {
+SOC_DAPM_SINGLE("Line Bypass Switch", WM8731_APANA, 3, 1, 0),
+SOC_DAPM_SINGLE("Mic Sidetone Switch", WM8731_APANA, 5, 1, 0),
+SOC_DAPM_SINGLE("HiFi Playback Switch", WM8731_APANA, 4, 1, 0),
+};
+
+/* Input mux */
+static const struct snd_kcontrol_new wm8731_input_mux_controls =
+SOC_DAPM_ENUM("Input Select", wm8731_enum[0]);
+
+static const struct snd_soc_dapm_widget wm8731_dapm_widgets[] = {
+SND_SOC_DAPM_MIXER("Output Mixer", WM8731_PWR, 4, 1,
+       &wm8731_output_mixer_controls[0],
+       ARRAY_SIZE(wm8731_output_mixer_controls)),
+SND_SOC_DAPM_DAC("DAC", "HiFi Playback", WM8731_PWR, 3, 1),
+SND_SOC_DAPM_OUTPUT("LOUT"),
+SND_SOC_DAPM_OUTPUT("LHPOUT"),
+SND_SOC_DAPM_OUTPUT("ROUT"),
+SND_SOC_DAPM_OUTPUT("RHPOUT"),
+SND_SOC_DAPM_ADC("ADC", "HiFi Capture", WM8731_PWR, 2, 1),
+SND_SOC_DAPM_MUX("Input Mux", SND_SOC_NOPM, 0, 0, &wm8731_input_mux_controls),
+SND_SOC_DAPM_PGA("Line Input", WM8731_PWR, 0, 1, NULL, 0),
+SND_SOC_DAPM_MICBIAS("Mic Bias", WM8731_PWR, 1, 1),
+SND_SOC_DAPM_INPUT("MICIN"),
+SND_SOC_DAPM_INPUT("RLINEIN"),
+SND_SOC_DAPM_INPUT("LLINEIN"),
+};
+
+static const char *intercon[][3] = {
+       /* output mixer */
+       {"Output Mixer", "Line Bypass Switch", "Line Input"},
+       {"Output Mixer", "HiFi Playback Switch", "DAC"},
+       {"Output Mixer", "Mic Sidetone Switch", "Mic Bias"},
+
+       /* outputs */
+       {"RHPOUT", NULL, "Output Mixer"},
+       {"ROUT", NULL, "Output Mixer"},
+       {"LHPOUT", NULL, "Output Mixer"},
+       {"LOUT", NULL, "Output Mixer"},
+
+       /* input mux */
+       {"Input Mux", "Line In", "Line Input"},
+       {"Input Mux", "Mic", "Mic Bias"},
+       {"ADC", NULL, "Input Mux"},
+
+       /* inputs */
+       {"Line Input", NULL, "LLINEIN"},
+       {"Line Input", NULL, "RLINEIN"},
+       {"Mic Bias", NULL, "MICIN"},
+
+       /* terminator */
+       {NULL, NULL, NULL},
+};
+
+static int wm8731_add_widgets(struct snd_soc_codec *codec)
+{
+       int i;
+
+       for(i = 0; i < ARRAY_SIZE(wm8731_dapm_widgets); i++) {
+               snd_soc_dapm_new_control(codec, &wm8731_dapm_widgets[i]);
+       }
+
+       /* set up audio path interconnects */
+       for(i = 0; intercon[i][0] != NULL; i++) {
+               snd_soc_dapm_connect_input(codec, intercon[i][0],
+                       intercon[i][1], intercon[i][2]);
+       }
+
+       snd_soc_dapm_new_widgets(codec);
+       return 0;
+}
+
+struct _coeff_div {
+       u32 mclk;
+       u32 rate;
+       u16 fs;
+       u8 sr:4;
+       u8 bosr:1;
+       u8 usb:1;
+};
+
+/* codec mclk clock divider coefficients */
+static const struct _coeff_div coeff_div[] = {
+       /* 48k */
+       {12288000, 48000, 256, 0x0, 0x0, 0x0},
+       {18432000, 48000, 384, 0x0, 0x1, 0x0},
+       {12000000, 48000, 250, 0x0, 0x0, 0x1},
+
+       /* 32k */
+       {12288000, 32000, 384, 0x6, 0x0, 0x0},
+       {18432000, 32000, 576, 0x6, 0x1, 0x0},
+       {12000000, 32000, 375, 0x6, 0x0, 0x1},
+
+       /* 8k */
+       {12288000, 8000, 1536, 0x3, 0x0, 0x0},
+       {18432000, 8000, 2304, 0x3, 0x1, 0x0},
+       {11289600, 8000, 1408, 0xb, 0x0, 0x0},
+       {16934400, 8000, 2112, 0xb, 0x1, 0x0},
+       {12000000, 8000, 1500, 0x3, 0x0, 0x1},
+
+       /* 96k */
+       {12288000, 96000, 128, 0x7, 0x0, 0x0},
+       {18432000, 96000, 192, 0x7, 0x1, 0x0},
+       {12000000, 96000, 125, 0x7, 0x0, 0x1},
+
+       /* 44.1k */
+       {11289600, 44100, 256, 0x8, 0x0, 0x0},
+       {16934400, 44100, 384, 0x8, 0x1, 0x0},
+       {12000000, 44100, 272, 0x8, 0x1, 0x1},
+
+       /* 88.2k */
+       {11289600, 88200, 128, 0xf, 0x0, 0x0},
+       {16934400, 88200, 192, 0xf, 0x1, 0x0},
+       {12000000, 88200, 136, 0xf, 0x1, 0x1},
+};
+
+static inline int get_coeff(int mclk, int rate)
+{
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(coeff_div); i++) {
+               if (coeff_div[i].rate == rate && coeff_div[i].mclk == mclk)
+                       return i;
+       }
+       return 0;
+}
+
+static int wm8731_hw_params(struct snd_pcm_substream *substream,
+       struct snd_pcm_hw_params *params)
+{
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_device *socdev = rtd->socdev;
+       struct snd_soc_codec *codec = socdev->codec;
+       struct wm8731_priv *wm8731 = codec->private_data;
+       u16 iface = wm8731_read_reg_cache(codec, WM8731_IFACE) & 0xfff3;
+       int i = get_coeff(wm8731->sysclk, params_rate(params));
+       u16 srate = (coeff_div[i].sr << 2) |
+               (coeff_div[i].bosr << 1) | coeff_div[i].usb;
+
+       wm8731_write(codec, WM8731_SRATE, srate);
+
+       /* bit size */
+       switch (params_format(params)) {
+       case SNDRV_PCM_FORMAT_S16_LE:
+               break;
+       case SNDRV_PCM_FORMAT_S20_3LE:
+               iface |= 0x0004;
+               break;
+       case SNDRV_PCM_FORMAT_S24_LE:
+               iface |= 0x0008;
+               break;
+       }
+
+       wm8731_write(codec, WM8731_IFACE, iface);
+       return 0;
+}
+
+static int wm8731_pcm_prepare(struct snd_pcm_substream *substream)
+{
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_device *socdev = rtd->socdev;
+       struct snd_soc_codec *codec = socdev->codec;
+
+       /* set active */
+       wm8731_write(codec, WM8731_ACTIVE, 0x0001);
+
+       return 0;
+}
+
+static void wm8731_shutdown(struct snd_pcm_substream *substream)
+{
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_device *socdev = rtd->socdev;
+       struct snd_soc_codec *codec = socdev->codec;
+
+       /* deactivate */
+       if (!codec->active) {
+               udelay(50);
+               wm8731_write(codec, WM8731_ACTIVE, 0x0);
+       }
+}
+
+static int wm8731_mute(struct snd_soc_codec_dai *dai, int mute)
+{
+       struct snd_soc_codec *codec = dai->codec;
+       u16 mute_reg = wm8731_read_reg_cache(codec, WM8731_APDIGI) & 0xfff7;
+
+       if (mute)
+               wm8731_write(codec, WM8731_APDIGI, mute_reg | 0x8);
+       else
+               wm8731_write(codec, WM8731_APDIGI, mute_reg);
+       return 0;
+}
+
+static int wm8731_set_dai_sysclk(struct snd_soc_codec_dai *codec_dai,
+               int clk_id, unsigned int freq, int dir)
+{
+       struct snd_soc_codec *codec = codec_dai->codec;
+       struct wm8731_priv *wm8731 = codec->private_data;
+
+       switch (freq) {
+       case 11289600:
+       case 12000000:
+       case 12288000:
+       case 16934400:
+       case 18432000:
+               wm8731->sysclk = freq;
+               return 0;
+       }
+       return -EINVAL;
+}
+
+
+static int wm8731_set_dai_fmt(struct snd_soc_codec_dai *codec_dai,
+               unsigned int fmt)
+{
+       struct snd_soc_codec *codec = codec_dai->codec;
+       u16 iface = 0;
+
+       /* set master/slave audio interface */
+       switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
+       case SND_SOC_DAIFMT_CBM_CFM:
+               iface |= 0x0040;
+               break;
+       case SND_SOC_DAIFMT_CBS_CFS:
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       /* interface format */
+       switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
+       case SND_SOC_DAIFMT_I2S:
+               iface |= 0x0002;
+               break;
+       case SND_SOC_DAIFMT_RIGHT_J:
+               break;
+       case SND_SOC_DAIFMT_LEFT_J:
+               iface |= 0x0001;
+               break;
+       case SND_SOC_DAIFMT_DSP_A:
+               iface |= 0x0003;
+               break;
+       case SND_SOC_DAIFMT_DSP_B:
+               iface |= 0x0013;
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       /* clock inversion */
+       switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
+       case SND_SOC_DAIFMT_NB_NF:
+               break;
+       case SND_SOC_DAIFMT_IB_IF:
+               iface |= 0x0090;
+               break;
+       case SND_SOC_DAIFMT_IB_NF:
+               iface |= 0x0080;
+               break;
+       case SND_SOC_DAIFMT_NB_IF:
+               iface |= 0x0010;
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       /* set iface */
+       wm8731_write(codec, WM8731_IFACE, iface);
+       return 0;
+}
+
+static int wm8731_dapm_event(struct snd_soc_codec *codec, int event)
+{
+       u16 reg = wm8731_read_reg_cache(codec, WM8731_PWR) & 0xff7f;
+
+       switch (event) {
+       case SNDRV_CTL_POWER_D0: /* full On */
+               /* vref/mid, osc on, dac unmute */
+               wm8731_write(codec, WM8731_PWR, reg);
+               break;
+       case SNDRV_CTL_POWER_D1: /* partial On */
+       case SNDRV_CTL_POWER_D2: /* partial On */
+               break;
+       case SNDRV_CTL_POWER_D3hot: /* Off, with power */
+               /* everything off except vref/vmid, */
+               wm8731_write(codec, WM8731_PWR, reg | 0x0040);
+               break;
+       case SNDRV_CTL_POWER_D3cold: /* Off, without power */
+               /* everything off, dac mute, inactive */
+               wm8731_write(codec, WM8731_ACTIVE, 0x0);
+               wm8731_write(codec, WM8731_PWR, 0xffff);
+               break;
+       }
+       codec->dapm_state = event;
+       return 0;
+}
+
+#define WM8731_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\
+               SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |\
+               SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |\
+               SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |\
+               SNDRV_PCM_RATE_96000)
+
+#define WM8731_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
+       SNDRV_PCM_FMTBIT_S24_LE)
+
+struct snd_soc_codec_dai wm8731_dai = {
+       .name = "WM8731",
+       .playback = {
+               .stream_name = "Playback",
+               .channels_min = 1,
+               .channels_max = 2,
+               .rates = WM8731_RATES,
+               .formats = WM8731_FORMATS,},
+       .capture = {
+               .stream_name = "Capture",
+               .channels_min = 1,
+               .channels_max = 2,
+               .rates = WM8731_RATES,
+               .formats = WM8731_FORMATS,},
+       .ops = {
+               .prepare = wm8731_pcm_prepare,
+               .hw_params = wm8731_hw_params,
+               .shutdown = wm8731_shutdown,
+       },
+       .dai_ops = {
+               .digital_mute = wm8731_mute,
+               .set_sysclk = wm8731_set_dai_sysclk,
+               .set_fmt = wm8731_set_dai_fmt,
+       }
+};
+EXPORT_SYMBOL_GPL(wm8731_dai);
+
+static int wm8731_suspend(struct platform_device *pdev, pm_message_t state)
+{
+       struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+       struct snd_soc_codec *codec = socdev->codec;
+
+       wm8731_write(codec, WM8731_ACTIVE, 0x0);
+       wm8731_dapm_event(codec, SNDRV_CTL_POWER_D3cold);
+       return 0;
+}
+
+static int wm8731_resume(struct platform_device *pdev)
+{
+       struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+       struct snd_soc_codec *codec = socdev->codec;
+       int i;
+       u8 data[2];
+       u16 *cache = codec->reg_cache;
+
+       /* Sync reg_cache with the hardware */
+       for (i = 0; i < ARRAY_SIZE(wm8731_reg); i++) {
+               data[0] = (i << 1) | ((cache[i] >> 8) & 0x0001);
+               data[1] = cache[i] & 0x00ff;
+               codec->hw_write(codec->control_data, data, 2);
+       }
+       wm8731_dapm_event(codec, SNDRV_CTL_POWER_D3hot);
+       wm8731_dapm_event(codec, codec->suspend_dapm_state);
+       return 0;
+}
+
+/*
+ * initialise the WM8731 driver
+ * register the mixer and dsp interfaces with the kernel
+ */
+static int wm8731_init(struct snd_soc_device *socdev)
+{
+       struct snd_soc_codec *codec = socdev->codec;
+       int reg, ret = 0;
+
+       codec->name = "WM8731";
+       codec->owner = THIS_MODULE;
+       codec->read = wm8731_read_reg_cache;
+       codec->write = wm8731_write;
+       codec->dapm_event = wm8731_dapm_event;
+       codec->dai = &wm8731_dai;
+       codec->num_dai = 1;
+       codec->reg_cache_size = sizeof(wm8731_reg);
+       codec->reg_cache = kmemdup(wm8731_reg, sizeof(wm8731_reg), GFP_KERNEL);
+       if (codec->reg_cache == NULL)
+               return -ENOMEM;
+
+       wm8731_reset(codec);
+
+       /* register pcms */
+       ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
+       if (ret < 0) {
+               printk(KERN_ERR "wm8731: failed to create pcms\n");
+               goto pcm_err;
+       }
+
+       /* power on device */
+       wm8731_dapm_event(codec, SNDRV_CTL_POWER_D3hot);
+
+       /* set the update bits */
+       reg = wm8731_read_reg_cache(codec, WM8731_LOUT1V);
+       wm8731_write(codec, WM8731_LOUT1V, reg | 0x0100);
+       reg = wm8731_read_reg_cache(codec, WM8731_ROUT1V);
+       wm8731_write(codec, WM8731_ROUT1V, reg | 0x0100);
+       reg = wm8731_read_reg_cache(codec, WM8731_LINVOL);
+       wm8731_write(codec, WM8731_LINVOL, reg | 0x0100);
+       reg = wm8731_read_reg_cache(codec, WM8731_RINVOL);
+       wm8731_write(codec, WM8731_RINVOL, reg | 0x0100);
+
+       wm8731_add_controls(codec);
+       wm8731_add_widgets(codec);
+       ret = snd_soc_register_card(socdev);
+       if (ret < 0) {
+               printk(KERN_ERR "wm8731: failed to register card\n");
+               goto card_err;
+       }
+
+       return ret;
+
+card_err:
+       snd_soc_free_pcms(socdev);
+       snd_soc_dapm_free(socdev);
+pcm_err:
+       kfree(codec->reg_cache);
+       return ret;
+}
+
+static struct snd_soc_device *wm8731_socdev;
+
+#if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE)
+
+/*
+ * WM8731 2 wire address is determined by GPIO5
+ * state during powerup.
+ *    low  = 0x1a
+ *    high = 0x1b
+ */
+static unsigned short normal_i2c[] = { 0, I2C_CLIENT_END };
+
+/* Magic definition of all other variables and things */
+I2C_CLIENT_INSMOD;
+
+static struct i2c_driver wm8731_i2c_driver;
+static struct i2c_client client_template;
+
+/* If the i2c layer weren't so broken, we could pass this kind of data
+   around */
+
+static int wm8731_codec_probe(struct i2c_adapter *adap, int addr, int kind)
+{
+       struct snd_soc_device *socdev = wm8731_socdev;
+       struct wm8731_setup_data *setup = socdev->codec_data;
+       struct snd_soc_codec *codec = socdev->codec;
+       struct i2c_client *i2c;
+       int ret;
+
+       if (addr != setup->i2c_address)
+               return -ENODEV;
+
+       client_template.adapter = adap;
+       client_template.addr = addr;
+
+       i2c = kmemdup(&client_template, sizeof(client_template), GFP_KERNEL);
+       if (i2c == NULL) {
+               kfree(codec);
+               return -ENOMEM;
+       }
+       i2c_set_clientdata(i2c, codec);
+       codec->control_data = i2c;
+
+       ret = i2c_attach_client(i2c);
+       if (ret < 0) {
+               err("failed to attach codec at addr %x\n", addr);
+               goto err;
+       }
+
+       ret = wm8731_init(socdev);
+       if (ret < 0) {
+               err("failed to initialise WM8731\n");
+               goto err;
+       }
+       return ret;
+
+err:
+       kfree(codec);
+       kfree(i2c);
+       return ret;
+}
+
+static int wm8731_i2c_detach(struct i2c_client *client)
+{
+       struct snd_soc_codec* codec = i2c_get_clientdata(client);
+       i2c_detach_client(client);
+       kfree(codec->reg_cache);
+       kfree(client);
+       return 0;
+}
+
+static int wm8731_i2c_attach(struct i2c_adapter *adap)
+{
+       return i2c_probe(adap, &addr_data, wm8731_codec_probe);
+}
+
+/* corgi i2c codec control layer */
+static struct i2c_driver wm8731_i2c_driver = {
+       .driver = {
+               .name = "WM8731 I2C Codec",
+               .owner = THIS_MODULE,
+       },
+       .id =             I2C_DRIVERID_WM8731,
+       .attach_adapter = wm8731_i2c_attach,
+       .detach_client =  wm8731_i2c_detach,
+       .command =        NULL,
+};
+
+static struct i2c_client client_template = {
+       .name =   "WM8731",
+       .driver = &wm8731_i2c_driver,
+};
+#endif
+
+static int wm8731_probe(struct platform_device *pdev)
+{
+       struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+       struct wm8731_setup_data *setup;
+       struct snd_soc_codec *codec;
+       struct wm8731_priv *wm8731;
+       int ret = 0;
+
+       info("WM8731 Audio Codec %s", WM8731_VERSION);
+
+       setup = socdev->codec_data;
+       codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL);
+       if (codec == NULL)
+               return -ENOMEM;
+
+       wm8731 = kzalloc(sizeof(struct wm8731_priv), GFP_KERNEL);
+       if (wm8731 == NULL) {
+               kfree(codec);
+               return -ENOMEM;
+       }
+
+       codec->private_data = wm8731;
+       socdev->codec = codec;
+       mutex_init(&codec->mutex);
+       INIT_LIST_HEAD(&codec->dapm_widgets);
+       INIT_LIST_HEAD(&codec->dapm_paths);
+
+       wm8731_socdev = socdev;
+#if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE)
+       if (setup->i2c_address) {
+               normal_i2c[0] = setup->i2c_address;
+               codec->hw_write = (hw_write_t)i2c_master_send;
+               ret = i2c_add_driver(&wm8731_i2c_driver);
+               if (ret != 0)
+                       printk(KERN_ERR "can't add i2c driver");
+       }
+#else
+       /* Add other interfaces here */
+#endif
+       return ret;
+}
+
+/* power down chip */
+static int wm8731_remove(struct platform_device *pdev)
+{
+       struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+       struct snd_soc_codec *codec = socdev->codec;
+
+       if (codec->control_data)
+               wm8731_dapm_event(codec, SNDRV_CTL_POWER_D3cold);
+
+       snd_soc_free_pcms(socdev);
+       snd_soc_dapm_free(socdev);
+#if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE)
+       i2c_del_driver(&wm8731_i2c_driver);
+#endif
+       kfree(codec->private_data);
+       kfree(codec);
+
+       return 0;
+}
+
+struct snd_soc_codec_device soc_codec_dev_wm8731 = {
+       .probe =        wm8731_probe,
+       .remove =       wm8731_remove,
+       .suspend =      wm8731_suspend,
+       .resume =       wm8731_resume,
+};
+
+EXPORT_SYMBOL_GPL(soc_codec_dev_wm8731);
+
+MODULE_DESCRIPTION("ASoC WM8731 driver");
+MODULE_AUTHOR("Richard Purdie");
+MODULE_LICENSE("GPL");
diff --git a/sound/soc/codecs/wm8731.h b/sound/soc/codecs/wm8731.h
new file mode 100644 (file)
index 0000000..5bcab6a
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * wm8731.h  --  WM8731 Soc Audio driver
+ *
+ * Copyright 2005 Openedhand Ltd.
+ *
+ * Author: Richard Purdie <richard@openedhand.com>
+ *
+ * Based on wm8753.h
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef _WM8731_H
+#define _WM8731_H
+
+/* WM8731 register space */
+
+#define WM8731_LINVOL   0x00
+#define WM8731_RINVOL   0x01
+#define WM8731_LOUT1V   0x02
+#define WM8731_ROUT1V   0x03
+#define WM8731_APANA    0x04
+#define WM8731_APDIGI   0x05
+#define WM8731_PWR      0x06
+#define WM8731_IFACE    0x07
+#define WM8731_SRATE    0x08
+#define WM8731_ACTIVE   0x09
+#define WM8731_RESET   0x0f
+
+#define WM8731_CACHEREGNUM     10
+
+#define WM8731_SYSCLK  0
+#define WM8731_DAI             0
+
+struct wm8731_setup_data {
+       unsigned short i2c_address;
+};
+
+extern struct snd_soc_codec_dai wm8731_dai;
+extern struct snd_soc_codec_device soc_codec_dev_wm8731;
+
+#endif
diff --git a/sound/soc/codecs/wm8750.c b/sound/soc/codecs/wm8750.c
new file mode 100644 (file)
index 0000000..7073e8e
--- /dev/null
@@ -0,0 +1,1049 @@
+/*
+ * wm8750.c -- WM8750 ALSA SoC audio driver
+ *
+ * Copyright 2005 Openedhand Ltd.
+ *
+ * Author: Richard Purdie <richard@openedhand.com>
+ *
+ * Based on WM8753.c
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/init.h>
+#include <linux/delay.h>
+#include <linux/pm.h>
+#include <linux/i2c.h>
+#include <linux/platform_device.h>
+#include <sound/driver.h>
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/pcm_params.h>
+#include <sound/soc.h>
+#include <sound/soc-dapm.h>
+#include <sound/initval.h>
+
+#include "wm8750.h"
+
+#define AUDIO_NAME "WM8750"
+#define WM8750_VERSION "0.12"
+
+/*
+ * Debug
+ */
+
+#define WM8750_DEBUG 0
+
+#ifdef WM8750_DEBUG
+#define dbg(format, arg...) \
+       printk(KERN_DEBUG AUDIO_NAME ": " format "\n" , ## arg)
+#else
+#define dbg(format, arg...) do {} while (0)
+#endif
+#define err(format, arg...) \
+       printk(KERN_ERR AUDIO_NAME ": " format "\n" , ## arg)
+#define info(format, arg...) \
+       printk(KERN_INFO AUDIO_NAME ": " format "\n" , ## arg)
+#define warn(format, arg...) \
+       printk(KERN_WARNING AUDIO_NAME ": " format "\n" , ## arg)
+
+/* codec private data */
+struct wm8750_priv {
+       unsigned int sysclk;
+};
+
+/*
+ * wm8750 register cache
+ * We can't read the WM8750 register space when we
+ * are using 2 wire for device control, so we cache them instead.
+ */
+static const u16 wm8750_reg[] = {
+       0x0097, 0x0097, 0x0079, 0x0079,  /*  0 */
+       0x0000, 0x0008, 0x0000, 0x000a,  /*  4 */
+       0x0000, 0x0000, 0x00ff, 0x00ff,  /*  8 */
+       0x000f, 0x000f, 0x0000, 0x0000,  /* 12 */
+       0x0000, 0x007b, 0x0000, 0x0032,  /* 16 */
+       0x0000, 0x00c3, 0x00c3, 0x00c0,  /* 20 */
+       0x0000, 0x0000, 0x0000, 0x0000,  /* 24 */
+       0x0000, 0x0000, 0x0000, 0x0000,  /* 28 */
+       0x0000, 0x0000, 0x0050, 0x0050,  /* 32 */
+       0x0050, 0x0050, 0x0050, 0x0050,  /* 36 */
+       0x0079, 0x0079, 0x0079,          /* 40 */
+};
+
+/*
+ * read wm8750 register cache
+ */
+static inline unsigned int wm8750_read_reg_cache(struct snd_soc_codec *codec,
+       unsigned int reg)
+{
+       u16 *cache = codec->reg_cache;
+       if (reg > WM8750_CACHE_REGNUM)
+               return -1;
+       return cache[reg];
+}
+
+/*
+ * write wm8750 register cache
+ */
+static inline void wm8750_write_reg_cache(struct snd_soc_codec *codec,
+       unsigned int reg, unsigned int value)
+{
+       u16 *cache = codec->reg_cache;
+       if (reg > WM8750_CACHE_REGNUM)
+               return;
+       cache[reg] = value;
+}
+
+static int wm8750_write(struct snd_soc_codec *codec, unsigned int reg,
+       unsigned int value)
+{
+       u8 data[2];
+
+       /* data is
+        *   D15..D9 WM8753 register offset
+        *   D8...D0 register data
+        */
+       data[0] = (reg << 1) | ((value >> 8) & 0x0001);
+       data[1] = value & 0x00ff;
+
+       wm8750_write_reg_cache (codec, reg, value);
+       if (codec->hw_write(codec->control_data, data, 2) == 2)
+               return 0;
+       else
+               return -EIO;
+}
+
+#define wm8750_reset(c)        wm8750_write(c, WM8750_RESET, 0)
+
+/*
+ * WM8750 Controls
+ */
+static const char *wm8750_bass[] = {"Linear Control", "Adaptive Boost"};
+static const char *wm8750_bass_filter[] = { "130Hz @ 48kHz", "200Hz @ 48kHz" };
+static const char *wm8750_treble[] = {"8kHz", "4kHz"};
+static const char *wm8750_3d_lc[] = {"200Hz", "500Hz"};
+static const char *wm8750_3d_uc[] = {"2.2kHz", "1.5kHz"};
+static const char *wm8750_3d_func[] = {"Capture", "Playback"};
+static const char *wm8750_alc_func[] = {"Off", "Right", "Left", "Stereo"};
+static const char *wm8750_ng_type[] = {"Constant PGA Gain",
+       "Mute ADC Output"};
+static const char *wm8750_line_mux[] = {"Line 1", "Line 2", "Line 3", "PGA",
+       "Differential"};
+static const char *wm8750_pga_sel[] = {"Line 1", "Line 2", "Line 3",
+       "Differential"};
+static const char *wm8750_out3[] = {"VREF", "ROUT1 + Vol", "MonoOut",
+       "ROUT1"};
+static const char *wm8750_diff_sel[] = {"Line 1", "Line 2"};
+static const char *wm8750_adcpol[] = {"Normal", "L Invert", "R Invert",
+       "L + R Invert"};
+static const char *wm8750_deemph[] = {"None", "32Khz", "44.1Khz", "48Khz"};
+static const char *wm8750_mono_mux[] = {"Stereo", "Mono (Left)",
+       "Mono (Right)", "Digital Mono"};
+
+static const struct soc_enum wm8750_enum[] = {
+SOC_ENUM_SINGLE(WM8750_BASS, 7, 2, wm8750_bass),
+SOC_ENUM_SINGLE(WM8750_BASS, 6, 2, wm8750_bass_filter),
+SOC_ENUM_SINGLE(WM8750_TREBLE, 6, 2, wm8750_treble),
+SOC_ENUM_SINGLE(WM8750_3D, 5, 2, wm8750_3d_lc),
+SOC_ENUM_SINGLE(WM8750_3D, 6, 2, wm8750_3d_uc),
+SOC_ENUM_SINGLE(WM8750_3D, 7, 2, wm8750_3d_func),
+SOC_ENUM_SINGLE(WM8750_ALC1, 7, 4, wm8750_alc_func),
+SOC_ENUM_SINGLE(WM8750_NGATE, 1, 2, wm8750_ng_type),
+SOC_ENUM_SINGLE(WM8750_LOUTM1, 0, 5, wm8750_line_mux),
+SOC_ENUM_SINGLE(WM8750_ROUTM1, 0, 5, wm8750_line_mux),
+SOC_ENUM_SINGLE(WM8750_LADCIN, 6, 4, wm8750_pga_sel), /* 10 */
+SOC_ENUM_SINGLE(WM8750_RADCIN, 6, 4, wm8750_pga_sel),
+SOC_ENUM_SINGLE(WM8750_ADCTL2, 7, 4, wm8750_out3),
+SOC_ENUM_SINGLE(WM8750_ADCIN, 8, 2, wm8750_diff_sel),
+SOC_ENUM_SINGLE(WM8750_ADCDAC, 5, 4, wm8750_adcpol),
+SOC_ENUM_SINGLE(WM8750_ADCDAC, 1, 4, wm8750_deemph),
+SOC_ENUM_SINGLE(WM8750_ADCIN, 6, 4, wm8750_mono_mux), /* 16 */
+
+};
+
+static const struct snd_kcontrol_new wm8750_snd_controls[] = {
+
+SOC_DOUBLE_R("Capture Volume", WM8750_LINVOL, WM8750_RINVOL, 0, 63, 0),
+SOC_DOUBLE_R("Capture ZC Switch", WM8750_LINVOL, WM8750_RINVOL, 6, 1, 0),
+SOC_DOUBLE_R("Capture Switch", WM8750_LINVOL, WM8750_RINVOL, 7, 1, 1),
+
+SOC_DOUBLE_R("Headphone Playback ZC Switch", WM8750_LOUT1V,
+       WM8750_ROUT1V, 7, 1, 0),
+SOC_DOUBLE_R("Speaker Playback ZC Switch", WM8750_LOUT2V,
+       WM8750_ROUT2V, 7, 1, 0),
+
+SOC_ENUM("Playback De-emphasis", wm8750_enum[15]),
+
+SOC_ENUM("Capture Polarity", wm8750_enum[14]),
+SOC_SINGLE("Playback 6dB Attenuate", WM8750_ADCDAC, 7, 1, 0),
+SOC_SINGLE("Capture 6dB Attenuate", WM8750_ADCDAC, 8, 1, 0),
+
+SOC_DOUBLE_R("PCM Volume", WM8750_LDAC, WM8750_RDAC, 0, 255, 0),
+
+SOC_ENUM("Bass Boost", wm8750_enum[0]),
+SOC_ENUM("Bass Filter", wm8750_enum[1]),
+SOC_SINGLE("Bass Volume", WM8750_BASS, 0, 15, 1),
+
+SOC_SINGLE("Treble Volume", WM8750_TREBLE, 0, 15, 0),
+SOC_ENUM("Treble Cut-off", wm8750_enum[2]),
+
+SOC_SINGLE("3D Switch", WM8750_3D, 0, 1, 0),
+SOC_SINGLE("3D Volume", WM8750_3D, 1, 15, 0),
+SOC_ENUM("3D Lower Cut-off", wm8750_enum[3]),
+SOC_ENUM("3D Upper Cut-off", wm8750_enum[4]),
+SOC_ENUM("3D Mode", wm8750_enum[5]),
+
+SOC_SINGLE("ALC Capture Target Volume", WM8750_ALC1, 0, 7, 0),
+SOC_SINGLE("ALC Capture Max Volume", WM8750_ALC1, 4, 7, 0),
+SOC_ENUM("ALC Capture Function", wm8750_enum[6]),
+SOC_SINGLE("ALC Capture ZC Switch", WM8750_ALC2, 7, 1, 0),
+SOC_SINGLE("ALC Capture Hold Time", WM8750_ALC2, 0, 15, 0),
+SOC_SINGLE("ALC Capture Decay Time", WM8750_ALC3, 4, 15, 0),
+SOC_SINGLE("ALC Capture Attack Time", WM8750_ALC3, 0, 15, 0),
+SOC_SINGLE("ALC Capture NG Threshold", WM8750_NGATE, 3, 31, 0),
+SOC_ENUM("ALC Capture NG Type", wm8750_enum[4]),
+SOC_SINGLE("ALC Capture NG Switch", WM8750_NGATE, 0, 1, 0),
+
+SOC_SINGLE("Left ADC Capture Volume", WM8750_LADC, 0, 255, 0),
+SOC_SINGLE("Right ADC Capture Volume", WM8750_RADC, 0, 255, 0),
+
+SOC_SINGLE("ZC Timeout Switch", WM8750_ADCTL1, 0, 1, 0),
+SOC_SINGLE("Playback Invert Switch", WM8750_ADCTL1, 1, 1, 0),
+
+SOC_SINGLE("Right Speaker Playback Invert Switch", WM8750_ADCTL2, 4, 1, 0),
+
+/* Unimplemented */
+/* ADCDAC Bit 0 - ADCHPD */
+/* ADCDAC Bit 4 - HPOR */
+/* ADCTL1 Bit 2,3 - DATSEL */
+/* ADCTL1 Bit 4,5 - DMONOMIX */
+/* ADCTL1 Bit 6,7 - VSEL */
+/* ADCTL2 Bit 2 - LRCM */
+/* ADCTL2 Bit 3 - TRI */
+/* ADCTL3 Bit 5 - HPFLREN */
+/* ADCTL3 Bit 6 - VROI */
+/* ADCTL3 Bit 7,8 - ADCLRM */
+/* ADCIN Bit 4 - LDCM */
+/* ADCIN Bit 5 - RDCM */
+
+SOC_DOUBLE_R("Mic Boost", WM8750_LADCIN, WM8750_RADCIN, 4, 3, 0),
+
+SOC_DOUBLE_R("Bypass Left Playback Volume", WM8750_LOUTM1,
+       WM8750_LOUTM2, 4, 7, 1),
+SOC_DOUBLE_R("Bypass Right Playback Volume", WM8750_ROUTM1,
+       WM8750_ROUTM2, 4, 7, 1),
+SOC_DOUBLE_R("Bypass Mono Playback Volume", WM8750_MOUTM1,
+       WM8750_MOUTM2, 4, 7, 1),
+
+SOC_SINGLE("Mono Playback ZC Switch", WM8750_MOUTV, 7, 1, 0),
+
+SOC_DOUBLE_R("Headphone Playback Volume", WM8750_LOUT1V, WM8750_ROUT1V,
+       0, 127, 0),
+SOC_DOUBLE_R("Speaker Playback Volume", WM8750_LOUT2V, WM8750_ROUT2V,
+       0, 127, 0),
+
+SOC_SINGLE("Mono Playback Volume", WM8750_MOUTV, 0, 127, 0),
+
+};
+
+/* add non dapm controls */
+static int wm8750_add_controls(struct snd_soc_codec *codec)
+{
+       int err, i;
+
+       for (i = 0; i < ARRAY_SIZE(wm8750_snd_controls); i++) {
+               err = snd_ctl_add(codec->card,
+                               snd_soc_cnew(&wm8750_snd_controls[i],codec, NULL));
+               if (err < 0)
+                       return err;
+       }
+       return 0;
+}
+
+/*
+ * DAPM Controls
+ */
+
+/* Left Mixer */
+static const struct snd_kcontrol_new wm8750_left_mixer_controls[] = {
+SOC_DAPM_SINGLE("Playback Switch", WM8750_LOUTM1, 8, 1, 0),
+SOC_DAPM_SINGLE("Left Bypass Switch", WM8750_LOUTM1, 7, 1, 0),
+SOC_DAPM_SINGLE("Right Playback Switch", WM8750_LOUTM2, 8, 1, 0),
+SOC_DAPM_SINGLE("Right Bypass Switch", WM8750_LOUTM2, 7, 1, 0),
+};
+
+/* Right Mixer */
+static const struct snd_kcontrol_new wm8750_right_mixer_controls[] = {
+SOC_DAPM_SINGLE("Left Playback Switch", WM8750_ROUTM1, 8, 1, 0),
+SOC_DAPM_SINGLE("Left Bypass Switch", WM8750_ROUTM1, 7, 1, 0),
+SOC_DAPM_SINGLE("Playback Switch", WM8750_ROUTM2, 8, 1, 0),
+SOC_DAPM_SINGLE("Right Bypass Switch", WM8750_ROUTM2, 7, 1, 0),
+};
+
+/* Mono Mixer */
+static const struct snd_kcontrol_new wm8750_mono_mixer_controls[] = {
+SOC_DAPM_SINGLE("Left Playback Switch", WM8750_MOUTM1, 8, 1, 0),
+SOC_DAPM_SINGLE("Left Bypass Switch", WM8750_MOUTM1, 7, 1, 0),
+SOC_DAPM_SINGLE("Right Playback Switch", WM8750_MOUTM2, 8, 1, 0),
+SOC_DAPM_SINGLE("Right Bypass Switch", WM8750_MOUTM2, 7, 1, 0),
+};
+
+/* Left Line Mux */
+static const struct snd_kcontrol_new wm8750_left_line_controls =
+SOC_DAPM_ENUM("Route", wm8750_enum[8]);
+
+/* Right Line Mux */
+static const struct snd_kcontrol_new wm8750_right_line_controls =
+SOC_DAPM_ENUM("Route", wm8750_enum[9]);
+
+/* Left PGA Mux */
+static const struct snd_kcontrol_new wm8750_left_pga_controls =
+SOC_DAPM_ENUM("Route", wm8750_enum[10]);
+
+/* Right PGA Mux */
+static const struct snd_kcontrol_new wm8750_right_pga_controls =
+SOC_DAPM_ENUM("Route", wm8750_enum[11]);
+
+/* Out 3 Mux */
+static const struct snd_kcontrol_new wm8750_out3_controls =
+SOC_DAPM_ENUM("Route", wm8750_enum[12]);
+
+/* Differential Mux */
+static const struct snd_kcontrol_new wm8750_diffmux_controls =
+SOC_DAPM_ENUM("Route", wm8750_enum[13]);
+
+/* Mono ADC Mux */
+static const struct snd_kcontrol_new wm8750_monomux_controls =
+SOC_DAPM_ENUM("Route", wm8750_enum[16]);
+
+static const struct snd_soc_dapm_widget wm8750_dapm_widgets[] = {
+       SND_SOC_DAPM_MIXER("Left Mixer", SND_SOC_NOPM, 0, 0,
+               &wm8750_left_mixer_controls[0],
+               ARRAY_SIZE(wm8750_left_mixer_controls)),
+       SND_SOC_DAPM_MIXER("Right Mixer", SND_SOC_NOPM, 0, 0,
+               &wm8750_right_mixer_controls[0],
+               ARRAY_SIZE(wm8750_right_mixer_controls)),
+       SND_SOC_DAPM_MIXER("Mono Mixer", WM8750_PWR2, 2, 0,
+               &wm8750_mono_mixer_controls[0],
+               ARRAY_SIZE(wm8750_mono_mixer_controls)),
+
+       SND_SOC_DAPM_PGA("Right Out 2", WM8750_PWR2, 3, 0, NULL, 0),
+       SND_SOC_DAPM_PGA("Left Out 2", WM8750_PWR2, 4, 0, NULL, 0),
+       SND_SOC_DAPM_PGA("Right Out 1", WM8750_PWR2, 5, 0, NULL, 0),
+       SND_SOC_DAPM_PGA("Left Out 1", WM8750_PWR2, 6, 0, NULL, 0),
+       SND_SOC_DAPM_DAC("Right DAC", "Right Playback", WM8750_PWR2, 7, 0),
+       SND_SOC_DAPM_DAC("Left DAC", "Left Playback", WM8750_PWR2, 8, 0),
+
+       SND_SOC_DAPM_MICBIAS("Mic Bias", WM8750_PWR1, 1, 0),
+       SND_SOC_DAPM_ADC("Right ADC", "Right Capture", WM8750_PWR1, 2, 0),
+       SND_SOC_DAPM_ADC("Left ADC", "Left Capture", WM8750_PWR1, 3, 0),
+
+       SND_SOC_DAPM_MUX("Left PGA Mux", WM8750_PWR1, 5, 0,
+               &wm8750_left_pga_controls),
+       SND_SOC_DAPM_MUX("Right PGA Mux", WM8750_PWR1, 4, 0,
+               &wm8750_right_pga_controls),
+       SND_SOC_DAPM_MUX("Left Line Mux", SND_SOC_NOPM, 0, 0,
+               &wm8750_left_line_controls),
+       SND_SOC_DAPM_MUX("Right Line Mux", SND_SOC_NOPM, 0, 0,
+               &wm8750_right_line_controls),
+
+       SND_SOC_DAPM_MUX("Out3 Mux", SND_SOC_NOPM, 0, 0, &wm8750_out3_controls),
+       SND_SOC_DAPM_PGA("Out 3", WM8750_PWR2, 1, 0, NULL, 0),
+       SND_SOC_DAPM_PGA("Mono Out 1", WM8750_PWR2, 2, 0, NULL, 0),
+
+       SND_SOC_DAPM_MUX("Differential Mux", SND_SOC_NOPM, 0, 0,
+               &wm8750_diffmux_controls),
+       SND_SOC_DAPM_MUX("Left ADC Mux", SND_SOC_NOPM, 0, 0,
+               &wm8750_monomux_controls),
+       SND_SOC_DAPM_MUX("Right ADC Mux", SND_SOC_NOPM, 0, 0,
+               &wm8750_monomux_controls),
+
+       SND_SOC_DAPM_OUTPUT("LOUT1"),
+       SND_SOC_DAPM_OUTPUT("ROUT1"),
+       SND_SOC_DAPM_OUTPUT("LOUT2"),
+       SND_SOC_DAPM_OUTPUT("ROUT2"),
+       SND_SOC_DAPM_OUTPUT("MONO"),
+       SND_SOC_DAPM_OUTPUT("OUT3"),
+
+       SND_SOC_DAPM_INPUT("LINPUT1"),
+       SND_SOC_DAPM_INPUT("LINPUT2"),
+       SND_SOC_DAPM_INPUT("LINPUT3"),
+       SND_SOC_DAPM_INPUT("RINPUT1"),
+       SND_SOC_DAPM_INPUT("RINPUT2"),
+       SND_SOC_DAPM_INPUT("RINPUT3"),
+};
+
+static const char *audio_map[][3] = {
+       /* left mixer */
+       {"Left Mixer", "Playback Switch", "Left DAC"},
+       {"Left Mixer", "Left Bypass Switch", "Left Line Mux"},
+       {"Left Mixer", "Right Playback Switch", "Right DAC"},
+       {"Left Mixer", "Right Bypass Switch", "Right Line Mux"},
+
+       /* right mixer */
+       {"Right Mixer", "Left Playback Switch", "Left DAC"},
+       {"Right Mixer", "Left Bypass Switch", "Left Line Mux"},
+       {"Right Mixer", "Playback Switch", "Right DAC"},
+       {"Right Mixer", "Right Bypass Switch", "Right Line Mux"},
+
+       /* left out 1 */
+       {"Left Out 1", NULL, "Left Mixer"},
+       {"LOUT1", NULL, "Left Out 1"},
+
+       /* left out 2 */
+       {"Left Out 2", NULL, "Left Mixer"},
+       {"LOUT2", NULL, "Left Out 2"},
+
+       /* right out 1 */
+       {"Right Out 1", NULL, "Right Mixer"},
+       {"ROUT1", NULL, "Right Out 1"},
+
+       /* right out 2 */
+       {"Right Out 2", NULL, "Right Mixer"},
+       {"ROUT2", NULL, "Right Out 2"},
+
+       /* mono mixer */
+       {"Mono Mixer", "Left Playback Switch", "Left DAC"},
+       {"Mono Mixer", "Left Bypass Switch", "Left Line Mux"},
+       {"Mono Mixer", "Right Playback Switch", "Right DAC"},
+       {"Mono Mixer", "Right Bypass Switch", "Right Line Mux"},
+
+       /* mono out */
+       {"Mono Out 1", NULL, "Mono Mixer"},
+       {"MONO1", NULL, "Mono Out 1"},
+
+       /* out 3 */
+       {"Out3 Mux", "VREF", "VREF"},
+       {"Out3 Mux", "ROUT1 + Vol", "ROUT1"},
+       {"Out3 Mux", "ROUT1", "Right Mixer"},
+       {"Out3 Mux", "MonoOut", "MONO1"},
+       {"Out 3", NULL, "Out3 Mux"},
+       {"OUT3", NULL, "Out 3"},
+
+       /* Left Line Mux */
+       {"Left Line Mux", "Line 1", "LINPUT1"},
+       {"Left Line Mux", "Line 2", "LINPUT2"},
+       {"Left Line Mux", "Line 3", "LINPUT3"},
+       {"Left Line Mux", "PGA", "Left PGA Mux"},
+       {"Left Line Mux", "Differential", "Differential Mux"},
+
+       /* Right Line Mux */
+       {"Right Line Mux", "Line 1", "RINPUT1"},
+       {"Right Line Mux", "Line 2", "RINPUT2"},
+       {"Right Line Mux", "Line 3", "RINPUT3"},
+       {"Right Line Mux", "PGA", "Right PGA Mux"},
+       {"Right Line Mux", "Differential", "Differential Mux"},
+
+       /* Left PGA Mux */
+       {"Left PGA Mux", "Line 1", "LINPUT1"},
+       {"Left PGA Mux", "Line 2", "LINPUT2"},
+       {"Left PGA Mux", "Line 3", "LINPUT3"},
+       {"Left PGA Mux", "Differential", "Differential Mux"},
+
+       /* Right PGA Mux */
+       {"Right PGA Mux", "Line 1", "RINPUT1"},
+       {"Right PGA Mux", "Line 2", "RINPUT2"},
+       {"Right PGA Mux", "Line 3", "RINPUT3"},
+       {"Right PGA Mux", "Differential", "Differential Mux"},
+
+       /* Differential Mux */
+       {"Differential Mux", "Line 1", "LINPUT1"},
+       {"Differential Mux", "Line 1", "RINPUT1"},
+       {"Differential Mux", "Line 2", "LINPUT2"},
+       {"Differential Mux", "Line 2", "RINPUT2"},
+
+       /* Left ADC Mux */
+       {"Left ADC Mux", "Stereo", "Left PGA Mux"},
+       {"Left ADC Mux", "Mono (Left)", "Left PGA Mux"},
+       {"Left ADC Mux", "Digital Mono", "Left PGA Mux"},
+
+       /* Right ADC Mux */
+       {"Right ADC Mux", "Stereo", "Right PGA Mux"},
+       {"Right ADC Mux", "Mono (Right)", "Right PGA Mux"},
+       {"Right ADC Mux", "Digital Mono", "Right PGA Mux"},
+
+       /* ADC */
+       {"Left ADC", NULL, "Left ADC Mux"},
+       {"Right ADC", NULL, "Right ADC Mux"},
+
+       /* terminator */
+       {NULL, NULL, NULL},
+};
+
+static int wm8750_add_widgets(struct snd_soc_codec *codec)
+{
+       int i;
+
+       for(i = 0; i < ARRAY_SIZE(wm8750_dapm_widgets); i++) {
+               snd_soc_dapm_new_control(codec, &wm8750_dapm_widgets[i]);
+       }
+
+       /* set up audio path audio_mapnects */
+       for(i = 0; audio_map[i][0] != NULL; i++) {
+               snd_soc_dapm_connect_input(codec, audio_map[i][0],
+                       audio_map[i][1], audio_map[i][2]);
+       }
+
+       snd_soc_dapm_new_widgets(codec);
+       return 0;
+}
+
+struct _coeff_div {
+       u32 mclk;
+       u32 rate;
+       u16 fs;
+       u8 sr:5;
+       u8 usb:1;
+};
+
+/* codec hifi mclk clock divider coefficients */
+static const struct _coeff_div coeff_div[] = {
+       /* 8k */
+       {12288000, 8000, 1536, 0x6, 0x0},
+       {11289600, 8000, 1408, 0x16, 0x0},
+       {18432000, 8000, 2304, 0x7, 0x0},
+       {16934400, 8000, 2112, 0x17, 0x0},
+       {12000000, 8000, 1500, 0x6, 0x1},
+
+       /* 11.025k */
+       {11289600, 11025, 1024, 0x18, 0x0},
+       {16934400, 11025, 1536, 0x19, 0x0},
+       {12000000, 11025, 1088, 0x19, 0x1},
+
+       /* 16k */
+       {12288000, 16000, 768, 0xa, 0x0},
+       {18432000, 16000, 1152, 0xb, 0x0},
+       {12000000, 16000, 750, 0xa, 0x1},
+
+       /* 22.05k */
+       {11289600, 22050, 512, 0x1a, 0x0},
+       {16934400, 22050, 768, 0x1b, 0x0},
+       {12000000, 22050, 544, 0x1b, 0x1},
+
+       /* 32k */
+       {12288000, 32000, 384, 0xc, 0x0},
+       {18432000, 32000, 576, 0xd, 0x0},
+       {12000000, 32000, 375, 0xa, 0x1},
+
+       /* 44.1k */
+       {11289600, 44100, 256, 0x10, 0x0},
+       {16934400, 44100, 384, 0x11, 0x0},
+       {12000000, 44100, 272, 0x11, 0x1},
+
+       /* 48k */
+       {12288000, 48000, 256, 0x0, 0x0},
+       {18432000, 48000, 384, 0x1, 0x0},
+       {12000000, 48000, 250, 0x0, 0x1},
+
+       /* 88.2k */
+       {11289600, 88200, 128, 0x1e, 0x0},
+       {16934400, 88200, 192, 0x1f, 0x0},
+       {12000000, 88200, 136, 0x1f, 0x1},
+
+       /* 96k */
+       {12288000, 96000, 128, 0xe, 0x0},
+       {18432000, 96000, 192, 0xf, 0x0},
+       {12000000, 96000, 125, 0xe, 0x1},
+};
+
+static inline int get_coeff(int mclk, int rate)
+{
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(coeff_div); i++) {
+               if (coeff_div[i].rate == rate && coeff_div[i].mclk == mclk)
+                       return i;
+       }
+
+       printk(KERN_ERR "wm8750: could not get coeff for mclk %d @ rate %d\n",
+               mclk, rate);
+       return -EINVAL;
+}
+
+static int wm8750_set_dai_sysclk(struct snd_soc_codec_dai *codec_dai,
+               int clk_id, unsigned int freq, int dir)
+{
+       struct snd_soc_codec *codec = codec_dai->codec;
+       struct wm8750_priv *wm8750 = codec->private_data;
+
+       switch (freq) {
+       case 11289600:
+       case 12000000:
+       case 12288000:
+       case 16934400:
+       case 18432000:
+               wm8750->sysclk = freq;
+               return 0;
+       }
+       return -EINVAL;
+}
+
+static int wm8750_set_dai_fmt(struct snd_soc_codec_dai *codec_dai,
+               unsigned int fmt)
+{
+       struct snd_soc_codec *codec = codec_dai->codec;
+       u16 iface = 0;
+
+       /* set master/slave audio interface */
+       switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
+       case SND_SOC_DAIFMT_CBM_CFM:
+               iface = 0x0040;
+               break;
+       case SND_SOC_DAIFMT_CBS_CFS:
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       /* interface format */
+       switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
+       case SND_SOC_DAIFMT_I2S:
+               iface |= 0x0002;
+               break;
+       case SND_SOC_DAIFMT_RIGHT_J:
+               break;
+       case SND_SOC_DAIFMT_LEFT_J:
+               iface |= 0x0001;
+               break;
+       case SND_SOC_DAIFMT_DSP_A:
+               iface |= 0x0003;
+               break;
+       case SND_SOC_DAIFMT_DSP_B:
+               iface |= 0x0013;
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       /* clock inversion */
+       switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
+       case SND_SOC_DAIFMT_NB_NF:
+               break;
+       case SND_SOC_DAIFMT_IB_IF:
+               iface |= 0x0090;
+               break;
+       case SND_SOC_DAIFMT_IB_NF:
+               iface |= 0x0080;
+               break;
+       case SND_SOC_DAIFMT_NB_IF:
+               iface |= 0x0010;
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       wm8750_write(codec, WM8750_IFACE, iface);
+       return 0;
+}
+
+static int wm8750_pcm_hw_params(struct snd_pcm_substream *substream,
+       struct snd_pcm_hw_params *params)
+{
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_device *socdev = rtd->socdev;
+       struct snd_soc_codec *codec = socdev->codec;
+       struct wm8750_priv *wm8750 = codec->private_data;
+       u16 iface = wm8750_read_reg_cache(codec, WM8750_IFACE) & 0x1f3;
+       u16 srate = wm8750_read_reg_cache(codec, WM8750_SRATE) & 0x1c0;
+       int coeff = get_coeff(wm8750->sysclk, params_rate(params));
+
+       /* bit size */
+       switch (params_format(params)) {
+       case SNDRV_PCM_FORMAT_S16_LE:
+               break;
+       case SNDRV_PCM_FORMAT_S20_3LE:
+               iface |= 0x0004;
+               break;
+       case SNDRV_PCM_FORMAT_S24_LE:
+               iface |= 0x0008;
+               break;
+       case SNDRV_PCM_FORMAT_S32_LE:
+               iface |= 0x000c;
+               break;
+       }
+
+       /* set iface & srate */
+       wm8750_write(codec, WM8750_IFACE, iface);
+       if (coeff >= 0)
+               wm8750_write(codec, WM8750_SRATE, srate |
+                       (coeff_div[coeff].sr << 1) | coeff_div[coeff].usb);
+
+       return 0;
+}
+
+static int wm8750_mute(struct snd_soc_codec_dai *dai, int mute)
+{
+       struct snd_soc_codec *codec = dai->codec;
+       u16 mute_reg = wm8750_read_reg_cache(codec, WM8750_ADCDAC) & 0xfff7;
+
+       if (mute)
+               wm8750_write(codec, WM8750_ADCDAC, mute_reg | 0x8);
+       else
+               wm8750_write(codec, WM8750_ADCDAC, mute_reg);
+       return 0;
+}
+
+static int wm8750_dapm_event(struct snd_soc_codec *codec, int event)
+{
+       u16 pwr_reg = wm8750_read_reg_cache(codec, WM8750_PWR1) & 0xfe3e;
+
+       switch (event) {
+       case SNDRV_CTL_POWER_D0: /* full On */
+               /* set vmid to 50k and unmute dac */
+               wm8750_write(codec, WM8750_PWR1, pwr_reg | 0x00c0);
+               break;
+       case SNDRV_CTL_POWER_D1: /* partial On */
+       case SNDRV_CTL_POWER_D2: /* partial On */
+               /* set vmid to 5k for quick power up */
+               wm8750_write(codec, WM8750_PWR1, pwr_reg | 0x01c1);
+               break;
+       case SNDRV_CTL_POWER_D3hot: /* Off, with power */
+               /* mute dac and set vmid to 500k, enable VREF */
+               wm8750_write(codec, WM8750_PWR1, pwr_reg | 0x0141);
+               break;
+       case SNDRV_CTL_POWER_D3cold: /* Off, without power */
+               wm8750_write(codec, WM8750_PWR1, 0x0001);
+               break;
+       }
+       codec->dapm_state = event;
+       return 0;
+}
+
+#define WM8750_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\
+               SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_44100 | \
+               SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000)
+
+#define WM8750_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
+       SNDRV_PCM_FMTBIT_S24_LE)
+
+struct snd_soc_codec_dai wm8750_dai = {
+       .name = "WM8750",
+       .playback = {
+               .stream_name = "Playback",
+               .channels_min = 1,
+               .channels_max = 2,
+               .rates = WM8750_RATES,
+               .formats = WM8750_FORMATS,},
+       .capture = {
+               .stream_name = "Capture",
+               .channels_min = 1,
+               .channels_max = 2,
+               .rates = WM8750_RATES,
+               .formats = WM8750_FORMATS,},
+       .ops = {
+               .hw_params = wm8750_pcm_hw_params,
+       },
+       .dai_ops = {
+               .digital_mute = wm8750_mute,
+               .set_fmt = wm8750_set_dai_fmt,
+               .set_sysclk = wm8750_set_dai_sysclk,
+       },
+};
+EXPORT_SYMBOL_GPL(wm8750_dai);
+
+static void wm8750_work(struct work_struct *work)
+{
+       struct snd_soc_codec *codec =
+               container_of(work, struct snd_soc_codec, delayed_work.work);
+       wm8750_dapm_event(codec, codec->dapm_state);
+}
+
+static int wm8750_suspend(struct platform_device *pdev, pm_message_t state)
+{
+       struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+       struct snd_soc_codec *codec = socdev->codec;
+
+       wm8750_dapm_event(codec, SNDRV_CTL_POWER_D3cold);
+       return 0;
+}
+
+static int wm8750_resume(struct platform_device *pdev)
+{
+       struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+       struct snd_soc_codec *codec = socdev->codec;
+       int i;
+       u8 data[2];
+       u16 *cache = codec->reg_cache;
+
+       /* Sync reg_cache with the hardware */
+       for (i = 0; i < ARRAY_SIZE(wm8750_reg); i++) {
+               if (i == WM8750_RESET)
+                       continue;
+               data[0] = (i << 1) | ((cache[i] >> 8) & 0x0001);
+               data[1] = cache[i] & 0x00ff;
+               codec->hw_write(codec->control_data, data, 2);
+       }
+
+       wm8750_dapm_event(codec, SNDRV_CTL_POWER_D3hot);
+
+       /* charge wm8750 caps */
+       if (codec->suspend_dapm_state == SNDRV_CTL_POWER_D0) {
+               wm8750_dapm_event(codec, SNDRV_CTL_POWER_D2);
+               codec->dapm_state = SNDRV_CTL_POWER_D0;
+               schedule_delayed_work(&codec->delayed_work, msecs_to_jiffies(1000));
+       }
+
+       return 0;
+}
+
+/*
+ * initialise the WM8750 driver
+ * register the mixer and dsp interfaces with the kernel
+ */
+static int wm8750_init(struct snd_soc_device *socdev)
+{
+       struct snd_soc_codec *codec = socdev->codec;
+       int reg, ret = 0;
+
+       codec->name = "WM8750";
+       codec->owner = THIS_MODULE;
+       codec->read = wm8750_read_reg_cache;
+       codec->write = wm8750_write;
+       codec->dapm_event = wm8750_dapm_event;
+       codec->dai = &wm8750_dai;
+       codec->num_dai = 1;
+       codec->reg_cache_size = sizeof(wm8750_reg);
+       codec->reg_cache = kmemdup(wm8750_reg, sizeof(wm8750_reg), GFP_KRENEL);
+       if (codec->reg_cache == NULL)
+               return -ENOMEM;
+
+       wm8750_reset(codec);
+
+       /* register pcms */
+       ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
+       if (ret < 0) {
+               printk(KERN_ERR "wm8750: failed to create pcms\n");
+               goto pcm_err;
+       }
+
+       /* charge output caps */
+       wm8750_dapm_event(codec, SNDRV_CTL_POWER_D2);
+       codec->dapm_state = SNDRV_CTL_POWER_D3hot;
+       schedule_delayed_work(&codec->delayed_work, msecs_to_jiffies(1000));
+
+       /* set the update bits */
+       reg = wm8750_read_reg_cache(codec, WM8750_LDAC);
+       wm8750_write(codec, WM8750_LDAC, reg | 0x0100);
+       reg = wm8750_read_reg_cache(codec, WM8750_RDAC);
+       wm8750_write(codec, WM8750_RDAC, reg | 0x0100);
+       reg = wm8750_read_reg_cache(codec, WM8750_LOUT1V);
+       wm8750_write(codec, WM8750_LOUT1V, reg | 0x0100);
+       reg = wm8750_read_reg_cache(codec, WM8750_ROUT1V);
+       wm8750_write(codec, WM8750_ROUT1V, reg | 0x0100);
+       reg = wm8750_read_reg_cache(codec, WM8750_LOUT2V);
+       wm8750_write(codec, WM8750_LOUT2V, reg | 0x0100);
+       reg = wm8750_read_reg_cache(codec, WM8750_ROUT2V);
+       wm8750_write(codec, WM8750_ROUT2V, reg | 0x0100);
+       reg = wm8750_read_reg_cache(codec, WM8750_LINVOL);
+       wm8750_write(codec, WM8750_LINVOL, reg | 0x0100);
+       reg = wm8750_read_reg_cache(codec, WM8750_RINVOL);
+       wm8750_write(codec, WM8750_RINVOL, reg | 0x0100);
+
+       wm8750_add_controls(codec);
+       wm8750_add_widgets(codec);
+       ret = snd_soc_register_card(socdev);
+       if (ret < 0) {
+               printk(KERN_ERR "wm8750: failed to register card\n");
+               goto card_err;
+       }
+       return ret;
+
+card_err:
+       snd_soc_free_pcms(socdev);
+       snd_soc_dapm_free(socdev);
+pcm_err:
+       kfree(codec->reg_cache);
+       return ret;
+}
+
+/* If the i2c layer weren't so broken, we could pass this kind of data
+   around */
+static struct snd_soc_device *wm8750_socdev;
+
+#if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE)
+
+/*
+ * WM8731 2 wire address is determined by GPIO5
+ * state during powerup.
+ *    low  = 0x1a
+ *    high = 0x1b
+ */
+static unsigned short normal_i2c[] = { 0, I2C_CLIENT_END };
+
+/* Magic definition of all other variables and things */
+I2C_CLIENT_INSMOD;
+
+static struct i2c_driver wm8750_i2c_driver;
+static struct i2c_client client_template;
+
+static int wm8750_codec_probe(struct i2c_adapter *adap, int addr, int kind)
+{
+       struct snd_soc_device *socdev = wm8750_socdev;
+       struct wm8750_setup_data *setup = socdev->codec_data;
+       struct snd_soc_codec *codec = socdev->codec;
+       struct i2c_client *i2c;
+       int ret;
+
+       if (addr != setup->i2c_address)
+               return -ENODEV;
+
+       client_template.adapter = adap;
+       client_template.addr = addr;
+
+       i2c = kmemdup(&client_template, sizeof(client_template), GFP_KERNEL);
+       if (i2c == NULL) {
+               kfree(codec);
+               return -ENOMEM;
+       }
+       i2c_set_clientdata(i2c, codec);
+       codec->control_data = i2c;
+
+       ret = i2c_attach_client(i2c);
+       if (ret < 0) {
+               err("failed to attach codec at addr %x\n", addr);
+               goto err;
+       }
+
+       ret = wm8750_init(socdev);
+       if (ret < 0) {
+       err("failed to initialise WM8750\n");
+               goto err;
+       }
+       return ret;
+
+err:
+       kfree(codec);
+       kfree(i2c);
+       return ret;
+}
+
+static int wm8750_i2c_detach(struct i2c_client *client)
+{
+       struct snd_soc_codec *codec = i2c_get_clientdata(client);
+       i2c_detach_client(client);
+       kfree(codec->reg_cache);
+       kfree(client);
+       return 0;
+}
+
+static int wm8750_i2c_attach(struct i2c_adapter *adap)
+{
+       return i2c_probe(adap, &addr_data, wm8750_codec_probe);
+}
+
+/* corgi i2c codec control layer */
+static struct i2c_driver wm8750_i2c_driver = {
+       .driver = {
+               .name = "WM8750 I2C Codec",
+               .owner = THIS_MODULE,
+       },
+       .id =             I2C_DRIVERID_WM8750,
+       .attach_adapter = wm8750_i2c_attach,
+       .detach_client =  wm8750_i2c_detach,
+       .command =        NULL,
+};
+
+static struct i2c_client client_template = {
+       .name =   "WM8750",
+       .driver = &wm8750_i2c_driver,
+};
+#endif
+
+static int wm8750_probe(struct platform_device *pdev)
+{
+       struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+       struct wm8750_setup_data *setup = socdev->codec_data;
+       struct snd_soc_codec *codec;
+       struct wm8750_priv *wm8750;
+       int ret = 0;
+
+       info("WM8750 Audio Codec %s", WM8750_VERSION);
+       codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL);
+       if (codec == NULL)
+               return -ENOMEM;
+
+       wm8750 = kzalloc(sizeof(struct wm8750_priv), GFP_KERNEL);
+       if (wm8750 == NULL) {
+               kfree(codec);
+               return -ENOMEM;
+       }
+
+       codec->private_data = wm8750;
+       socdev->codec = codec;
+       mutex_init(&codec->mutex);
+       INIT_LIST_HEAD(&codec->dapm_widgets);
+       INIT_LIST_HEAD(&codec->dapm_paths);
+       wm8750_socdev = socdev;
+       INIT_DELAYED_WORK(&codec->delayed_work, wm8750_work);
+       
+#if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE)
+       if (setup->i2c_address) {
+               normal_i2c[0] = setup->i2c_address;
+               codec->hw_write = (hw_write_t)i2c_master_send;
+               ret = i2c_add_driver(&wm8750_i2c_driver);
+               if (ret != 0)
+                       printk(KERN_ERR "can't add i2c driver");
+       }
+#else
+               /* Add other interfaces here */
+#endif
+
+       return ret;
+}
+
+/*
+ * This function forces any delayed work to be queued and run.
+ */
+static int run_delayed_work(struct delayed_work *dwork)
+{
+       int ret;
+
+       /* cancel any work waiting to be queued. */
+       ret = cancel_delayed_work(dwork);
+
+       /* if there was any work waiting then we run it now and
+        * wait for it's completion */
+       if (ret) {
+               schedule_delayed_work(dwork, 0);
+               flush_scheduled_work();
+       }
+       return ret;
+}
+
+/* power down chip */
+static int wm8750_remove(struct platform_device *pdev)
+{
+       struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+       struct snd_soc_codec *codec = socdev->codec;
+
+       if (codec->control_data)
+               wm8750_dapm_event(codec, SNDRV_CTL_POWER_D3cold);
+       run_delayed_work(&codec->delayed_work);
+       snd_soc_free_pcms(socdev);
+       snd_soc_dapm_free(socdev);
+#if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE)
+       i2c_del_driver(&wm8750_i2c_driver);
+#endif
+       kfree(codec->private_data);
+       kfree(codec);
+
+       return 0;
+}
+
+struct snd_soc_codec_device soc_codec_dev_wm8750 = {
+       .probe =        wm8750_probe,
+       .remove =       wm8750_remove,
+       .suspend =      wm8750_suspend,
+       .resume =       wm8750_resume,
+};
+
+EXPORT_SYMBOL_GPL(soc_codec_dev_wm8750);
+
+MODULE_DESCRIPTION("ASoC WM8750 driver");
+MODULE_AUTHOR("Liam Girdwood");
+MODULE_LICENSE("GPL");
diff --git a/sound/soc/codecs/wm8750.h b/sound/soc/codecs/wm8750.h
new file mode 100644 (file)
index 0000000..a97a54a
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2005 Openedhand Ltd.
+ *
+ * Author: Richard Purdie <richard@openedhand.com>
+ *
+ * Based on WM8753.h
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#ifndef _WM8750_H
+#define _WM8750_H
+
+/* WM8750 register space */
+
+#define WM8750_LINVOL    0x00
+#define WM8750_RINVOL    0x01
+#define WM8750_LOUT1V    0x02
+#define WM8750_ROUT1V    0x03
+#define WM8750_ADCDAC    0x05
+#define WM8750_IFACE     0x07
+#define WM8750_SRATE     0x08
+#define WM8750_LDAC      0x0a
+#define WM8750_RDAC      0x0b
+#define WM8750_BASS      0x0c
+#define WM8750_TREBLE    0x0d
+#define WM8750_RESET     0x0f
+#define WM8750_3D        0x10
+#define WM8750_ALC1      0x11
+#define WM8750_ALC2      0x12
+#define WM8750_ALC3      0x13
+#define WM8750_NGATE     0x14
+#define WM8750_LADC      0x15
+#define WM8750_RADC      0x16
+#define WM8750_ADCTL1    0x17
+#define WM8750_ADCTL2    0x18
+#define WM8750_PWR1      0x19
+#define WM8750_PWR2      0x1a
+#define WM8750_ADCTL3    0x1b
+#define WM8750_ADCIN     0x1f
+#define WM8750_LADCIN    0x20
+#define WM8750_RADCIN    0x21
+#define WM8750_LOUTM1    0x22
+#define WM8750_LOUTM2    0x23
+#define WM8750_ROUTM1    0x24
+#define WM8750_ROUTM2    0x25
+#define WM8750_MOUTM1    0x26
+#define WM8750_MOUTM2    0x27
+#define WM8750_LOUT2V    0x28
+#define WM8750_ROUT2V    0x29
+#define WM8750_MOUTV     0x2a
+
+#define WM8750_CACHE_REGNUM 0x2a
+
+#define WM8750_SYSCLK  0
+
+struct wm8750_setup_data {
+       unsigned short i2c_address;
+};
+
+extern struct snd_soc_codec_dai wm8750_dai;
+extern struct snd_soc_codec_device soc_codec_dev_wm8750;
+
+#endif
diff --git a/sound/soc/codecs/wm9712.c b/sound/soc/codecs/wm9712.c
new file mode 100644 (file)
index 0000000..92a6487
--- /dev/null
@@ -0,0 +1,771 @@
+/*
+ * wm9712.c  --  ALSA Soc WM9712 codec support
+ *
+ * Copyright 2006 Wolfson Microelectronics PLC.
+ * Author: Liam Girdwood
+ *         liam.girdwood@wolfsonmicro.com or linux@wolfsonmicro.com
+ *
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ *
+ *  Revision history
+ *    4th Feb 2006   Initial version.
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/version.h>
+#include <linux/kernel.h>
+#include <linux/device.h>
+#include <sound/driver.h>
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/ac97_codec.h>
+#include <sound/initval.h>
+#include <sound/soc.h>
+#include <sound/soc-dapm.h>
+
+#define WM9712_VERSION "0.4"
+
+static unsigned int ac97_read(struct snd_soc_codec *codec,
+       unsigned int reg);
+static int ac97_write(struct snd_soc_codec *codec,
+       unsigned int reg, unsigned int val);
+
+/*
+ * WM9712 register cache
+ */
+static const u16 wm9712_reg[] = {
+       0x6174, 0x8000, 0x8000, 0x8000, // 6
+       0xf0f0, 0xaaa0, 0xc008, 0x6808, // e
+       0xe808, 0xaaa0, 0xad00, 0x8000, // 16
+       0xe808, 0x3000, 0x8000, 0x0000, // 1e
+       0x0000, 0x0000, 0x0000, 0x000f, // 26
+       0x0405, 0x0410, 0xbb80, 0xbb80, // 2e
+       0x0000, 0xbb80, 0x0000, 0x0000, // 36
+       0x0000, 0x2000, 0x0000, 0x0000, // 3e
+       0x0000, 0x0000, 0x0000, 0x0000, // 46
+       0x0000, 0x0000, 0xf83e, 0xffff, // 4e
+       0x0000, 0x0000, 0x0000, 0xf83e, // 56
+       0x0008, 0x0000, 0x0000, 0x0000, // 5e
+       0xb032, 0x3e00, 0x0000, 0x0000, // 66
+       0x0000, 0x0000, 0x0000, 0x0000, // 6e
+       0x0000, 0x0000, 0x0000, 0x0006, // 76
+       0x0001, 0x0000, 0x574d, 0x4c12, // 7e
+       0x0000, 0x0000 // virtual hp mixers
+};
+
+/* virtual HP mixers regs */
+#define HPL_MIXER      0x80
+#define HPR_MIXER      0x82
+
+static const char *wm9712_alc_select[] = {"None", "Left", "Right", "Stereo"};
+static const char *wm9712_alc_mux[] = {"Stereo", "Left", "Right", "None"};
+static const char *wm9712_out3_src[] = {"Left", "VREF", "Left + Right",
+       "Mono"};
+static const char *wm9712_spk_src[] = {"Speaker Mix", "Headphone Mix"};
+static const char *wm9712_rec_adc[] = {"Stereo", "Left", "Right", "Mute"};
+static const char *wm9712_base[] = {"Linear Control", "Adaptive Boost"};
+static const char *wm9712_rec_gain[] = {"+1.5dB Steps", "+0.75dB Steps"};
+static const char *wm9712_mic[] = {"Mic 1", "Differential", "Mic 2",
+       "Stereo"};
+static const char *wm9712_rec_sel[] = {"Mic", "NC", "NC", "Speaker Mixer",
+       "Line", "Headphone Mixer", "Phone Mixer", "Phone"};
+static const char *wm9712_ng_type[] = {"Constant Gain", "Mute"};
+static const char *wm9712_diff_sel[] = {"Mic", "Line"};
+
+static const struct soc_enum wm9712_enum[] = {
+SOC_ENUM_SINGLE(AC97_PCI_SVID, 14, 4, wm9712_alc_select),
+SOC_ENUM_SINGLE(AC97_VIDEO, 12, 4, wm9712_alc_mux),
+SOC_ENUM_SINGLE(AC97_AUX, 9, 4, wm9712_out3_src),
+SOC_ENUM_SINGLE(AC97_AUX, 8, 2, wm9712_spk_src),
+SOC_ENUM_SINGLE(AC97_REC_SEL, 12, 4, wm9712_rec_adc),
+SOC_ENUM_SINGLE(AC97_MASTER_TONE, 15, 2, wm9712_base),
+SOC_ENUM_DOUBLE(AC97_REC_GAIN, 14, 6, 2, wm9712_rec_gain),
+SOC_ENUM_SINGLE(AC97_MIC, 5, 4, wm9712_mic),
+SOC_ENUM_SINGLE(AC97_REC_SEL, 8, 8, wm9712_rec_sel),
+SOC_ENUM_SINGLE(AC97_REC_SEL, 0, 8, wm9712_rec_sel),
+SOC_ENUM_SINGLE(AC97_PCI_SVID, 5, 2, wm9712_ng_type),
+SOC_ENUM_SINGLE(0x5c, 8, 2, wm9712_diff_sel),
+};
+
+static const struct snd_kcontrol_new wm9712_snd_ac97_controls[] = {
+SOC_DOUBLE("Speaker Playback Volume", AC97_MASTER, 8, 0, 31, 1),
+SOC_SINGLE("Speaker Playback Switch", AC97_MASTER, 15, 1, 1),
+SOC_DOUBLE("Headphone Playback Volume", AC97_HEADPHONE, 8, 0, 31, 1),
+SOC_SINGLE("Headphone Playback Switch", AC97_HEADPHONE,15, 1, 1),
+
+SOC_SINGLE("Speaker Playback ZC Switch", AC97_MASTER, 7, 1, 0),
+SOC_SINGLE("Speaker Playback Invert Switch", AC97_MASTER, 6, 1, 0),
+SOC_SINGLE("Headphone Playback ZC Switch", AC97_HEADPHONE, 7, 1, 0),
+SOC_SINGLE("Mono Playback ZC Switch", AC97_MASTER_MONO, 7, 1, 0),
+SOC_SINGLE("Mono Playback Volume", AC97_MASTER_MONO, 0, 31, 0),
+
+SOC_SINGLE("ALC Target Volume", AC97_CODEC_CLASS_REV, 12, 15, 0),
+SOC_SINGLE("ALC Hold Time", AC97_CODEC_CLASS_REV, 8, 15, 0),
+SOC_SINGLE("ALC Decay Time", AC97_CODEC_CLASS_REV, 4, 15, 0),
+SOC_SINGLE("ALC Attack Time", AC97_CODEC_CLASS_REV, 0, 15, 0),
+SOC_ENUM("ALC Function", wm9712_enum[0]),
+SOC_SINGLE("ALC Max Volume", AC97_PCI_SVID, 11, 7, 0),
+SOC_SINGLE("ALC ZC Timeout", AC97_PCI_SVID, 9, 3, 1),
+SOC_SINGLE("ALC ZC Switch", AC97_PCI_SVID, 8, 1, 0),
+SOC_SINGLE("ALC NG Switch", AC97_PCI_SVID, 7, 1, 0),
+SOC_ENUM("ALC NG Type", wm9712_enum[10]),
+SOC_SINGLE("ALC NG Threshold", AC97_PCI_SVID, 0, 31, 1),
+
+SOC_SINGLE("Mic Headphone  Volume", AC97_VIDEO, 12, 7, 1),
+SOC_SINGLE("ALC Headphone Volume", AC97_VIDEO, 7, 7, 1),
+
+SOC_SINGLE("Out3 Switch", AC97_AUX, 15, 1, 1),
+SOC_SINGLE("Out3 ZC Switch", AC97_AUX, 7, 1, 1),
+SOC_SINGLE("Out3 Volume", AC97_AUX, 0, 31, 1),
+
+SOC_SINGLE("PCBeep Bypass Headphone Volume", AC97_PC_BEEP, 12, 7, 1),
+SOC_SINGLE("PCBeep Bypass Speaker Volume", AC97_PC_BEEP, 8, 7, 1),
+SOC_SINGLE("PCBeep Bypass Phone Volume", AC97_PC_BEEP, 4, 7, 1),
+
+SOC_SINGLE("Aux Playback Headphone Volume", AC97_CD, 12, 7, 1),
+SOC_SINGLE("Aux Playback Speaker Volume", AC97_CD, 8, 7, 1),
+SOC_SINGLE("Aux Playback Phone Volume", AC97_CD, 4, 7, 1),
+
+SOC_SINGLE("Phone Volume", AC97_PHONE, 0, 15, 0),
+SOC_DOUBLE("Line Capture Volume", AC97_LINE, 8, 0, 31, 1),
+
+SOC_SINGLE("Capture 20dB Boost Switch", AC97_REC_SEL, 14, 1, 0),
+SOC_SINGLE("Capture to Phone 20dB Boost Switch", AC97_REC_SEL, 11, 1, 1),
+
+SOC_SINGLE("3D Upper Cut-off Switch", AC97_3D_CONTROL, 5, 1, 1),
+SOC_SINGLE("3D Lower Cut-off Switch", AC97_3D_CONTROL, 4, 1, 1),
+SOC_SINGLE("3D Playback Volume", AC97_3D_CONTROL, 0, 15, 0),
+
+SOC_ENUM("Bass Control", wm9712_enum[5]),
+SOC_SINGLE("Bass Cut-off Switch", AC97_MASTER_TONE, 12, 1, 1),
+SOC_SINGLE("Tone Cut-off Switch", AC97_MASTER_TONE, 4, 1, 1),
+SOC_SINGLE("Playback Attenuate (-6dB) Switch", AC97_MASTER_TONE, 6, 1, 0),
+SOC_SINGLE("Bass Volume", AC97_MASTER_TONE, 8, 15, 0),
+SOC_SINGLE("Treble Volume", AC97_MASTER_TONE, 0, 15, 0),
+
+SOC_SINGLE("Capture ADC Switch", AC97_REC_GAIN, 15, 1, 1),
+SOC_ENUM("Capture Volume Steps", wm9712_enum[6]),
+SOC_DOUBLE("Capture Volume", AC97_REC_GAIN, 8, 0, 63, 1),
+SOC_SINGLE("Capture ZC Switch", AC97_REC_GAIN, 7, 1, 0),
+
+SOC_SINGLE("Mic 1 Volume", AC97_MIC, 8, 31, 1),
+SOC_SINGLE("Mic 2 Volume", AC97_MIC, 0, 31, 1),
+SOC_SINGLE("Mic 20dB Boost Switch", AC97_MIC, 7, 1, 0),
+};
+
+/* add non dapm controls */
+static int wm9712_add_controls(struct snd_soc_codec *codec)
+{
+       int err, i;
+
+       for (i = 0; i < ARRAY_SIZE(wm9712_snd_ac97_controls); i++) {
+               err = snd_ctl_add(codec->card,
+                               snd_soc_cnew(&wm9712_snd_ac97_controls[i],codec, NULL));
+               if (err < 0)
+                       return err;
+       }
+       return 0;
+}
+
+/* We have to create a fake left and right HP mixers because
+ * the codec only has a single control that is shared by both channels.
+ * This makes it impossible to determine the audio path.
+ */
+static int mixer_event (struct snd_soc_dapm_widget *w, int event)
+{
+       u16 l, r, beep, line, phone, mic, pcm, aux;
+
+       l = ac97_read(w->codec, HPL_MIXER);
+       r = ac97_read(w->codec, HPR_MIXER);
+       beep = ac97_read(w->codec, AC97_PC_BEEP);
+       mic = ac97_read(w->codec, AC97_VIDEO);
+       phone = ac97_read(w->codec, AC97_PHONE);
+       line = ac97_read(w->codec, AC97_LINE);
+       pcm = ac97_read(w->codec, AC97_PCM);
+       aux = ac97_read(w->codec, AC97_CD);
+
+       if (l & 0x1 || r & 0x1)
+               ac97_write(w->codec, AC97_VIDEO, mic & 0x7fff);
+       else
+               ac97_write(w->codec, AC97_VIDEO, mic | 0x8000);
+
+       if (l & 0x2 || r & 0x2)
+               ac97_write(w->codec, AC97_PCM, pcm & 0x7fff);
+       else
+               ac97_write(w->codec, AC97_PCM, pcm | 0x8000);
+
+       if (l & 0x4 || r & 0x4)
+               ac97_write(w->codec, AC97_LINE, line & 0x7fff);
+       else
+               ac97_write(w->codec, AC97_LINE, line | 0x8000);
+
+       if (l & 0x8 || r & 0x8)
+               ac97_write(w->codec, AC97_PHONE, phone & 0x7fff);
+       else
+               ac97_write(w->codec, AC97_PHONE, phone | 0x8000);
+
+       if (l & 0x10 || r & 0x10)
+               ac97_write(w->codec, AC97_CD, aux & 0x7fff);
+       else
+               ac97_write(w->codec, AC97_CD, aux | 0x8000);
+
+       if (l & 0x20 || r & 0x20)
+               ac97_write(w->codec, AC97_PC_BEEP, beep & 0x7fff);
+       else
+               ac97_write(w->codec, AC97_PC_BEEP, beep | 0x8000);
+
+       return 0;
+}
+
+/* Left Headphone Mixers */
+static const struct snd_kcontrol_new wm9712_hpl_mixer_controls[] = {
+       SOC_DAPM_SINGLE("PCBeep Bypass Switch", HPL_MIXER, 5, 1, 0),
+       SOC_DAPM_SINGLE("Aux Playback Switch", HPL_MIXER, 4, 1, 0),
+       SOC_DAPM_SINGLE("Phone Bypass Switch", HPL_MIXER, 3, 1, 0),
+       SOC_DAPM_SINGLE("Line Bypass Switch", HPL_MIXER, 2, 1, 0),
+       SOC_DAPM_SINGLE("PCM Playback Switch", HPL_MIXER, 1, 1, 0),
+       SOC_DAPM_SINGLE("Mic Sidetone Switch", HPL_MIXER, 0, 1, 0),
+};
+
+/* Right Headphone Mixers */
+static const struct snd_kcontrol_new wm9712_hpr_mixer_controls[] = {
+       SOC_DAPM_SINGLE("PCBeep Bypass Switch", HPR_MIXER, 5, 1, 0),
+       SOC_DAPM_SINGLE("Aux Playback Switch", HPR_MIXER, 4, 1, 0),
+       SOC_DAPM_SINGLE("Phone Bypass Switch", HPR_MIXER, 3, 1, 0),
+       SOC_DAPM_SINGLE("Line Bypass Switch", HPR_MIXER, 2, 1, 0),
+       SOC_DAPM_SINGLE("PCM Playback Switch", HPR_MIXER, 1, 1, 0),
+       SOC_DAPM_SINGLE("Mic Sidetone Switch", HPR_MIXER, 0, 1, 0),
+};
+
+/* Speaker Mixer */
+static const struct snd_kcontrol_new wm9712_speaker_mixer_controls[] = {
+       SOC_DAPM_SINGLE("PCBeep Bypass Switch", AC97_PC_BEEP, 11, 1, 1),
+       SOC_DAPM_SINGLE("Aux Playback Switch", AC97_CD, 11, 1, 1),
+       SOC_DAPM_SINGLE("Phone Bypass Switch", AC97_PHONE, 14, 1, 1),
+       SOC_DAPM_SINGLE("Line Bypass Switch", AC97_LINE, 14, 1, 1),
+       SOC_DAPM_SINGLE("PCM Playback Switch", AC97_PCM, 14, 1, 1),
+};
+
+/* Phone Mixer */
+static const struct snd_kcontrol_new wm9712_phone_mixer_controls[] = {
+       SOC_DAPM_SINGLE("PCBeep Bypass Switch", AC97_PC_BEEP, 7, 1, 1),
+       SOC_DAPM_SINGLE("Aux Playback Switch", AC97_CD, 7, 1, 1),
+       SOC_DAPM_SINGLE("Line Bypass Switch", AC97_LINE, 13, 1, 1),
+       SOC_DAPM_SINGLE("PCM Playback Switch", AC97_PCM, 13, 1, 1),
+       SOC_DAPM_SINGLE("Mic 1 Sidetone Switch", AC97_MIC, 14, 1, 1),
+       SOC_DAPM_SINGLE("Mic 2 Sidetone Switch", AC97_MIC, 13, 1, 1),
+};
+
+/* ALC headphone mux */
+static const struct snd_kcontrol_new wm9712_alc_mux_controls =
+SOC_DAPM_ENUM("Route", wm9712_enum[1]);
+
+/* out 3 mux */
+static const struct snd_kcontrol_new wm9712_out3_mux_controls =
+SOC_DAPM_ENUM("Route", wm9712_enum[2]);
+
+/* spk mux */
+static const struct snd_kcontrol_new wm9712_spk_mux_controls =
+SOC_DAPM_ENUM("Route", wm9712_enum[3]);
+
+/* Capture to Phone mux */
+static const struct snd_kcontrol_new wm9712_capture_phone_mux_controls =
+SOC_DAPM_ENUM("Route", wm9712_enum[4]);
+
+/* Capture left select */
+static const struct snd_kcontrol_new wm9712_capture_selectl_controls =
+SOC_DAPM_ENUM("Route", wm9712_enum[8]);
+
+/* Capture right select */
+static const struct snd_kcontrol_new wm9712_capture_selectr_controls =
+SOC_DAPM_ENUM("Route", wm9712_enum[9]);
+
+/* Mic select */
+static const struct snd_kcontrol_new wm9712_mic_src_controls =
+SOC_DAPM_ENUM("Route", wm9712_enum[7]);
+
+/* diff select */
+static const struct snd_kcontrol_new wm9712_diff_sel_controls =
+SOC_DAPM_ENUM("Route", wm9712_enum[11]);
+
+static const struct snd_soc_dapm_widget wm9712_dapm_widgets[] = {
+SND_SOC_DAPM_MUX("ALC Sidetone Mux", SND_SOC_NOPM, 0, 0,
+       &wm9712_alc_mux_controls),
+SND_SOC_DAPM_MUX("Out3 Mux", SND_SOC_NOPM, 0, 0,
+       &wm9712_out3_mux_controls),
+SND_SOC_DAPM_MUX("Speaker Mux", SND_SOC_NOPM, 0, 0,
+       &wm9712_spk_mux_controls),
+SND_SOC_DAPM_MUX("Capture Phone Mux", SND_SOC_NOPM, 0, 0,
+       &wm9712_capture_phone_mux_controls),
+SND_SOC_DAPM_MUX("Left Capture Select", SND_SOC_NOPM, 0, 0,
+       &wm9712_capture_selectl_controls),
+SND_SOC_DAPM_MUX("Right Capture Select", SND_SOC_NOPM, 0, 0,
+       &wm9712_capture_selectr_controls),
+SND_SOC_DAPM_MUX("Mic Select Source", SND_SOC_NOPM, 0, 0,
+       &wm9712_mic_src_controls),
+SND_SOC_DAPM_MUX("Differential Source", SND_SOC_NOPM, 0, 0,
+       &wm9712_diff_sel_controls),
+SND_SOC_DAPM_MIXER("AC97 Mixer", SND_SOC_NOPM, 0, 0, NULL, 0),
+SND_SOC_DAPM_MIXER_E("Left HP Mixer", AC97_INT_PAGING, 9, 1,
+       &wm9712_hpl_mixer_controls[0], ARRAY_SIZE(wm9712_hpl_mixer_controls),
+       mixer_event, SND_SOC_DAPM_POST_REG),
+SND_SOC_DAPM_MIXER_E("Right HP Mixer", AC97_INT_PAGING, 8, 1,
+       &wm9712_hpr_mixer_controls[0], ARRAY_SIZE(wm9712_hpr_mixer_controls),
+        mixer_event, SND_SOC_DAPM_POST_REG),
+SND_SOC_DAPM_MIXER("Phone Mixer", AC97_INT_PAGING, 6, 1,
+       &wm9712_phone_mixer_controls[0], ARRAY_SIZE(wm9712_phone_mixer_controls)),
+SND_SOC_DAPM_MIXER("Speaker Mixer", AC97_INT_PAGING, 7, 1,
+       &wm9712_speaker_mixer_controls[0],
+       ARRAY_SIZE(wm9712_speaker_mixer_controls)),
+SND_SOC_DAPM_MIXER("Mono Mixer", SND_SOC_NOPM, 0, 0, NULL, 0),
+SND_SOC_DAPM_DAC("Left DAC", "Left HiFi Playback", AC97_INT_PAGING, 14, 1),
+SND_SOC_DAPM_DAC("Right DAC", "Right HiFi Playback", AC97_INT_PAGING, 13, 1),
+SND_SOC_DAPM_DAC("Aux DAC", "Aux Playback", SND_SOC_NOPM, 0, 0),
+SND_SOC_DAPM_ADC("Left ADC", "Left HiFi Capture", AC97_INT_PAGING, 12, 1),
+SND_SOC_DAPM_ADC("Right ADC", "Right HiFi Capture", AC97_INT_PAGING, 11, 1),
+SND_SOC_DAPM_PGA("Headphone PGA", AC97_INT_PAGING, 4, 1, NULL, 0),
+SND_SOC_DAPM_PGA("Speaker PGA", AC97_INT_PAGING, 3, 1, NULL, 0),
+SND_SOC_DAPM_PGA("Out 3 PGA", AC97_INT_PAGING, 5, 1, NULL, 0),
+SND_SOC_DAPM_PGA("Line PGA", AC97_INT_PAGING, 2, 1, NULL, 0),
+SND_SOC_DAPM_PGA("Phone PGA", AC97_INT_PAGING, 1, 1, NULL, 0),
+SND_SOC_DAPM_PGA("Mic PGA", AC97_INT_PAGING, 0, 1, NULL, 0),
+SND_SOC_DAPM_MICBIAS("Mic Bias", AC97_INT_PAGING, 10, 1),
+SND_SOC_DAPM_OUTPUT("MONOOUT"),
+SND_SOC_DAPM_OUTPUT("HPOUTL"),
+SND_SOC_DAPM_OUTPUT("HPOUTR"),
+SND_SOC_DAPM_OUTPUT("LOUT2"),
+SND_SOC_DAPM_OUTPUT("ROUT2"),
+SND_SOC_DAPM_OUTPUT("OUT3"),
+SND_SOC_DAPM_INPUT("LINEINL"),
+SND_SOC_DAPM_INPUT("LINEINR"),
+SND_SOC_DAPM_INPUT("PHONE"),
+SND_SOC_DAPM_INPUT("PCBEEP"),
+SND_SOC_DAPM_INPUT("MIC1"),
+SND_SOC_DAPM_INPUT("MIC2"),
+};
+
+static const char *audio_map[][3] = {
+       /* virtual mixer - mixes left & right channels for spk and mono */
+       {"AC97 Mixer", NULL, "Left DAC"},
+       {"AC97 Mixer", NULL, "Right DAC"},
+
+       /* Left HP mixer */
+       {"Left HP Mixer", "PCBeep Bypass Switch", "PCBEEP"},
+       {"Left HP Mixer", "Aux Playback Switch",  "Aux DAC"},
+       {"Left HP Mixer", "Phone Bypass Switch",  "Phone PGA"},
+       {"Left HP Mixer", "Line Bypass Switch",   "Line PGA"},
+       {"Left HP Mixer", "PCM Playback Switch",  "Left DAC"},
+       {"Left HP Mixer", "Mic Sidetone Switch",  "Mic PGA"},
+       {"Left HP Mixer", NULL,  "ALC Sidetone Mux"},
+       //{"Right HP Mixer", NULL, "HP Mixer"},
+
+       /* Right HP mixer */
+       {"Right HP Mixer", "PCBeep Bypass Switch", "PCBEEP"},
+       {"Right HP Mixer", "Aux Playback Switch",  "Aux DAC"},
+       {"Right HP Mixer", "Phone Bypass Switch",  "Phone PGA"},
+       {"Right HP Mixer", "Line Bypass Switch",   "Line PGA"},
+       {"Right HP Mixer", "PCM Playback Switch",  "Right DAC"},
+       {"Right HP Mixer", "Mic Sidetone Switch",  "Mic PGA"},
+       {"Right HP Mixer", NULL,  "ALC Sidetone Mux"},
+
+       /* speaker mixer */
+       {"Speaker Mixer", "PCBeep Bypass Switch", "PCBEEP"},
+       {"Speaker Mixer", "Line Bypass Switch",   "Line PGA"},
+       {"Speaker Mixer", "PCM Playback Switch",  "AC97 Mixer"},
+       {"Speaker Mixer", "Phone Bypass Switch",  "Phone PGA"},
+       {"Speaker Mixer", "Aux Playback Switch",  "Aux DAC"},
+
+       /* Phone mixer */
+       {"Phone Mixer", "PCBeep Bypass Switch",  "PCBEEP"},
+       {"Phone Mixer", "Line Bypass Switch",    "Line PGA"},
+       {"Phone Mixer", "Aux Playback Switch",   "Aux DAC"},
+       {"Phone Mixer", "PCM Playback Switch",   "AC97 Mixer"},
+       {"Phone Mixer", "Mic 1 Sidetone Switch", "Mic PGA"},
+       {"Phone Mixer", "Mic 2 Sidetone Switch", "Mic PGA"},
+
+       /* inputs */
+       {"Line PGA", NULL, "LINEINL"},
+       {"Line PGA", NULL, "LINEINR"},
+       {"Phone PGA", NULL, "PHONE"},
+       {"Mic PGA", NULL, "MIC1"},
+       {"Mic PGA", NULL, "MIC2"},
+
+       /* left capture selector */
+       {"Left Capture Select", "Mic", "MIC1"},
+       {"Left Capture Select", "Speaker Mixer", "Speaker Mixer"},
+       {"Left Capture Select", "Line", "LINEINL"},
+       {"Left Capture Select", "Headphone Mixer", "Left HP Mixer"},
+       {"Left Capture Select", "Phone Mixer", "Phone Mixer"},
+       {"Left Capture Select", "Phone", "PHONE"},
+
+       /* right capture selector */
+       {"Right Capture Select", "Mic", "MIC2"},
+       {"Right Capture Select", "Speaker Mixer", "Speaker Mixer"},
+       {"Right Capture Select", "Line", "LINEINR"},
+       {"Right Capture Select", "Headphone Mixer", "Right HP Mixer"},
+       {"Right Capture Select", "Phone Mixer", "Phone Mixer"},
+       {"Right Capture Select", "Phone", "PHONE"},
+
+       /* ALC Sidetone */
+       {"ALC Sidetone Mux", "Stereo", "Left Capture Select"},
+       {"ALC Sidetone Mux", "Stereo", "Right Capture Select"},
+       {"ALC Sidetone Mux", "Left", "Left Capture Select"},
+       {"ALC Sidetone Mux", "Right", "Right Capture Select"},
+
+       /* ADC's */
+       {"Left ADC", NULL, "Left Capture Select"},
+       {"Right ADC", NULL, "Right Capture Select"},
+
+       /* outputs */
+       {"MONOOUT", NULL, "Phone Mixer"},
+       {"HPOUTL", NULL, "Headphone PGA"},
+       {"Headphone PGA", NULL, "Left HP Mixer"},
+       {"HPOUTR", NULL, "Headphone PGA"},
+       {"Headphone PGA", NULL, "Right HP Mixer"},
+
+       /* mono hp mixer */
+       {"Mono HP Mixer", NULL, "Left HP Mixer"},
+       {"Mono HP Mixer", NULL, "Right HP Mixer"},
+
+       /* Out3 Mux */
+       {"Out3 Mux", "Left", "Left HP Mixer"},
+       {"Out3 Mux", "Mono", "Phone Mixer"},
+       {"Out3 Mux", "Left + Right", "Mono HP Mixer"},
+       {"Out 3 PGA", NULL, "Out3 Mux"},
+       {"OUT3", NULL, "Out 3 PGA"},
+
+       /* speaker Mux */
+       {"Speaker Mux", "Speaker Mix", "Speaker Mixer"},
+       {"Speaker Mux", "Headphone Mix", "Mono HP Mixer"},
+       {"Speaker PGA", NULL, "Speaker Mux"},
+       {"LOUT2", NULL, "Speaker PGA"},
+       {"ROUT2", NULL, "Speaker PGA"},
+
+       {NULL, NULL, NULL},
+};
+
+static int wm9712_add_widgets(struct snd_soc_codec *codec)
+{
+       int i;
+
+       for(i = 0; i < ARRAY_SIZE(wm9712_dapm_widgets); i++) {
+               snd_soc_dapm_new_control(codec, &wm9712_dapm_widgets[i]);
+       }
+
+       /* set up audio path audio_mapnects */
+       for(i = 0; audio_map[i][0] != NULL; i++) {
+               snd_soc_dapm_connect_input(codec, audio_map[i][0],
+                       audio_map[i][1], audio_map[i][2]);
+       }
+
+       snd_soc_dapm_new_widgets(codec);
+       return 0;
+}
+
+static unsigned int ac97_read(struct snd_soc_codec *codec,
+       unsigned int reg)
+{
+       u16 *cache = codec->reg_cache;
+
+       if (reg == AC97_RESET || reg == AC97_GPIO_STATUS ||
+               reg == AC97_VENDOR_ID1 || reg == AC97_VENDOR_ID2 ||
+               reg == AC97_REC_GAIN)
+               return soc_ac97_ops.read(codec->ac97, reg);
+       else {
+               reg = reg >> 1;
+
+               if (reg > (ARRAY_SIZE(wm9712_reg)))
+                       return -EIO;
+
+               return cache[reg];
+       }
+}
+
+static int ac97_write(struct snd_soc_codec *codec, unsigned int reg,
+       unsigned int val)
+{
+       u16 *cache = codec->reg_cache;
+
+       soc_ac97_ops.write(codec->ac97, reg, val);
+       reg = reg >> 1;
+       if (reg <= (ARRAY_SIZE(wm9712_reg)))
+               cache[reg] = val;
+
+       return 0;
+}
+
+static int ac97_prepare(struct snd_pcm_substream *substream)
+{
+       struct snd_pcm_runtime *runtime = substream->runtime;
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_device *socdev = rtd->socdev;
+       struct snd_soc_codec *codec = socdev->codec;
+       int reg;
+       u16 vra;
+
+       vra = ac97_read(codec, AC97_EXTENDED_STATUS);
+       ac97_write(codec, AC97_EXTENDED_STATUS, vra | 0x1);
+
+       if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+               reg = AC97_PCM_FRONT_DAC_RATE;
+       else
+               reg = AC97_PCM_LR_ADC_RATE;
+
+       return ac97_write(codec, reg, runtime->rate);
+}
+
+static int ac97_aux_prepare(struct snd_pcm_substream *substream)
+{
+       struct snd_pcm_runtime *runtime = substream->runtime;
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_device *socdev = rtd->socdev;
+       struct snd_soc_codec *codec = socdev->codec;
+       u16 vra, xsle;
+
+       vra = ac97_read(codec, AC97_EXTENDED_STATUS);
+       ac97_write(codec, AC97_EXTENDED_STATUS, vra | 0x1);
+       xsle = ac97_read(codec, AC97_PCI_SID);
+       ac97_write(codec, AC97_PCI_SID, xsle | 0x8000);
+
+       if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK)
+               return -ENODEV;
+
+       return ac97_write(codec, AC97_PCM_SURR_DAC_RATE, runtime->rate);
+}
+
+#define WM9712_AC97_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\
+               SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000)
+
+struct snd_soc_codec_dai wm9712_dai[] = {
+{
+       .name = "AC97 HiFi",
+       .playback = {
+               .stream_name = "HiFi Playback",
+               .channels_min = 1,
+               .channels_max = 2,
+               .rates = WM9712_AC97_RATES,
+               .formats = SNDRV_PCM_FMTBIT_S16_LE,},
+       .capture = {
+               .stream_name = "HiFi Capture",
+               .channels_min = 1,
+               .channels_max = 2,
+               .rates = WM9712_AC97_RATES,
+               .formats = SNDRV_PCM_FMTBIT_S16_LE,},
+       .ops = {
+               .prepare = ac97_prepare,},
+},
+{
+       .name = "AC97 Aux",
+       .playback = {
+               .stream_name = "Aux Playback",
+               .channels_min = 1,
+               .channels_max = 1,
+               .rates = WM9712_AC97_RATES,
+               .formats = SNDRV_PCM_FMTBIT_S16_LE,},
+       .ops = {
+               .prepare = ac97_aux_prepare,},
+}
+};
+EXPORT_SYMBOL_GPL(wm9712_dai);
+
+static int wm9712_dapm_event(struct snd_soc_codec *codec, int event)
+{
+       u16 reg;
+
+       switch (event) {
+       case SNDRV_CTL_POWER_D0: /* full On */
+               /* liam - maybe enable thermal shutdown */
+               reg = ac97_read(codec, AC97_EXTENDED_MID) & 0xdfff;
+               ac97_write(codec, AC97_EXTENDED_MID, reg);
+               break;
+       case SNDRV_CTL_POWER_D1: /* partial On */
+       case SNDRV_CTL_POWER_D2: /* partial On */
+               break;
+       case SNDRV_CTL_POWER_D3hot: /* Off, with power */
+               /* enable master bias and vmid */
+               reg = ac97_read(codec, AC97_EXTENDED_MID) & 0xbbff;
+               ac97_write(codec, AC97_EXTENDED_MID, reg);
+               ac97_write(codec, AC97_POWERDOWN, 0x0000);
+               break;
+       case SNDRV_CTL_POWER_D3cold: /* Off, without power */
+               /* disable everything including AC link */
+               ac97_write(codec, AC97_EXTENDED_MID, 0xffff);
+               ac97_write(codec, AC97_EXTENDED_MSTATUS, 0xffff);
+               ac97_write(codec, AC97_POWERDOWN, 0xffff);
+               break;
+       }
+       codec->dapm_state = event;
+       return 0;
+}
+
+static int wm9712_reset(struct snd_soc_codec *codec, int try_warm)
+{
+       if (try_warm && soc_ac97_ops.warm_reset) {
+               soc_ac97_ops.warm_reset(codec->ac97);
+               if (!(ac97_read(codec, 0) & 0x8000))
+                       return 1;
+       }
+
+       soc_ac97_ops.reset(codec->ac97);
+       if (ac97_read(codec, 0) & 0x8000)
+               goto err;
+       return 0;
+
+err:
+       printk(KERN_ERR "WM9712 AC97 reset failed\n");
+       return -EIO;
+}
+
+static int wm9712_soc_suspend(struct platform_device *pdev,
+       pm_message_t state)
+{
+       struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+       struct snd_soc_codec *codec = socdev->codec;
+
+       wm9712_dapm_event(codec, SNDRV_CTL_POWER_D3cold);
+       return 0;
+}
+
+static int wm9712_soc_resume(struct platform_device *pdev)
+{
+       struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+       struct snd_soc_codec *codec = socdev->codec;
+       int i, ret;
+       u16 *cache = codec->reg_cache;
+
+       ret = wm9712_reset(codec, 1);
+       if (ret < 0){
+               printk(KERN_ERR "could not reset AC97 codec\n");
+               return ret;
+       }
+
+       wm9712_dapm_event(codec, SNDRV_CTL_POWER_D3hot);
+
+       if (ret == 0) {
+               /* Sync reg_cache with the hardware after cold reset */
+               for (i = 2; i < ARRAY_SIZE(wm9712_reg) << 1; i+=2) {
+                       if (i == AC97_INT_PAGING || i == AC97_POWERDOWN ||
+                               (i > 0x58 && i != 0x5c))
+                               continue;
+                       soc_ac97_ops.write(codec->ac97, i, cache[i>>1]);
+               }
+       }
+
+       if (codec->suspend_dapm_state == SNDRV_CTL_POWER_D0)
+               wm9712_dapm_event(codec, SNDRV_CTL_POWER_D0);
+
+       return ret;
+}
+
+static int wm9712_soc_probe(struct platform_device *pdev)
+{
+       struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+       struct snd_soc_codec *codec;
+       int ret = 0;
+
+       printk(KERN_INFO "WM9711/WM9712 SoC Audio Codec %s\n", WM9712_VERSION);
+
+       socdev->codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL);
+       if (socdev->codec == NULL)
+               return -ENOMEM;
+       codec = socdev->codec;
+       mutex_init(&codec->mutex);
+
+       codec->reg_cache =
+               kzalloc(sizeof(u16) * ARRAY_SIZE(wm9712_reg), GFP_KERNEL);
+       if (codec->reg_cache == NULL) {
+               ret = -ENOMEM;
+               goto cache_err;
+       }
+       memcpy(codec->reg_cache, wm9712_reg, sizeof(u16) * ARRAY_SIZE(wm9712_reg));
+       codec->reg_cache_size = sizeof(u16) * ARRAY_SIZE(wm9712_reg);
+       codec->reg_cache_step = 2;
+
+       codec->name = "WM9712";
+       codec->owner = THIS_MODULE;
+       codec->dai = wm9712_dai;
+       codec->num_dai = ARRAY_SIZE(wm9712_dai);
+       codec->write = ac97_write;
+       codec->read = ac97_read;
+       codec->dapm_event = wm9712_dapm_event;
+       INIT_LIST_HEAD(&codec->dapm_widgets);
+       INIT_LIST_HEAD(&codec->dapm_paths);
+
+       ret = snd_soc_new_ac97_codec(codec, &soc_ac97_ops, 0);
+       if (ret < 0) {
+               printk(KERN_ERR "wm9712: failed to register AC97 codec\n");
+               goto codec_err;
+       }
+
+       /* register pcms */
+       ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
+       if (ret < 0)
+               goto pcm_err;
+
+       ret = wm9712_reset(codec, 0);
+       if (ret < 0) {
+               printk(KERN_ERR "AC97 link error\n");
+               goto reset_err;
+       }
+
+       /* set alc mux to none */
+       ac97_write(codec, AC97_VIDEO, ac97_read(codec, AC97_VIDEO) | 0x3000);
+
+       wm9712_dapm_event(codec, SNDRV_CTL_POWER_D3hot);
+       wm9712_add_controls(codec);
+       wm9712_add_widgets(codec);
+       ret = snd_soc_register_card(socdev);
+       if (ret < 0) {
+               printk(KERN_ERR "wm9712: failed to register card\n");
+               goto reset_err;
+       }
+
+       return 0;
+
+reset_err:
+       snd_soc_free_pcms(socdev);
+
+pcm_err:
+       snd_soc_free_ac97_codec(codec);
+
+codec_err:
+       kfree(codec->reg_cache);
+
+cache_err:
+       kfree(socdev->codec);
+       socdev->codec = NULL;
+       return ret;
+}
+
+static int wm9712_soc_remove(struct platform_device *pdev)
+{
+       struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+       struct snd_soc_codec *codec = socdev->codec;
+
+       if (codec == NULL)
+               return 0;
+
+       snd_soc_dapm_free(socdev);
+       snd_soc_free_pcms(socdev);
+       snd_soc_free_ac97_codec(codec);
+       kfree(codec->reg_cache);
+       kfree(codec);
+       return 0;
+}
+
+struct snd_soc_codec_device soc_codec_dev_wm9712 = {
+       .probe =        wm9712_soc_probe,
+       .remove =       wm9712_soc_remove,
+       .suspend =      wm9712_soc_suspend,
+       .resume =       wm9712_soc_resume,
+};
+
+EXPORT_SYMBOL_GPL(soc_codec_dev_wm9712);
+
+MODULE_DESCRIPTION("ASoC WM9711/WM9712 driver");
+MODULE_AUTHOR("Liam Girdwood");
+MODULE_LICENSE("GPL");
diff --git a/sound/soc/codecs/wm9712.h b/sound/soc/codecs/wm9712.h
new file mode 100644 (file)
index 0000000..719105d
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * wm9712.h  --  WM9712 Soc Audio driver
+ */
+
+#ifndef _WM9712_H
+#define _WM9712_H
+
+#define WM9712_DAI_AC97_HIFI   0
+#define WM9712_DAI_AC97_AUX            1
+
+extern struct snd_soc_codec_dai wm9712_dai[2];
+extern struct snd_soc_codec_device soc_codec_dev_wm9712;
+
+#endif
diff --git a/sound/soc/pxa/Kconfig b/sound/soc/pxa/Kconfig
new file mode 100644 (file)
index 0000000..579e1c8
--- /dev/null
@@ -0,0 +1,60 @@
+menu "SoC Audio for the Intel PXA2xx"
+
+config SND_PXA2XX_SOC
+       tristate "SoC Audio for the Intel PXA2xx chip"
+       depends on ARCH_PXA && SND
+       select SND_PCM
+       help
+         Say Y or M if you want to add support for codecs attached to
+         the PXA2xx AC97, I2S or SSP interface. You will also need
+         to select the audio interfaces to support below.
+
+config SND_PXA2XX_AC97
+       tristate
+       select SND_AC97_CODEC
+
+config SND_PXA2XX_SOC_AC97
+       tristate
+       select AC97_BUS
+       select SND_SOC_AC97_BUS
+
+config SND_PXA2XX_SOC_I2S
+       tristate
+
+config SND_PXA2XX_SOC_CORGI
+       tristate "SoC Audio support for Sharp Zaurus SL-C7x0"
+       depends on SND_PXA2XX_SOC && PXA_SHARP_C7xx
+       select SND_PXA2XX_SOC_I2S
+       select SND_SOC_WM8731
+       help
+         Say Y if you want to add support for SoC audio on Sharp
+         Zaurus SL-C7x0 models (Corgi, Shepherd, Husky).
+
+config SND_PXA2XX_SOC_SPITZ
+       tristate "SoC Audio support for Sharp Zaurus SL-Cxx00"
+       depends on SND_PXA2XX_SOC && PXA_SHARP_Cxx00
+       select SND_PXA2XX_SOC_I2S
+       select SND_SOC_WM8750
+       help
+         Say Y if you want to add support for SoC audio on Sharp
+         Zaurus SL-Cxx00 models (Spitz, Borzoi and Akita).
+
+config SND_PXA2XX_SOC_POODLE
+       tristate "SoC Audio support for Poodle"
+       depends on SND_PXA2XX_SOC && MACH_POODLE
+       select SND_PXA2XX_SOC_I2S
+       select SND_SOC_WM8731
+       help
+         Say Y if you want to add support for SoC audio on Sharp
+         Zaurus SL-5600 model (Poodle).
+
+config SND_PXA2XX_SOC_TOSA
+       tristate "SoC AC97 Audio support for Tosa"
+       depends on SND_PXA2XX_SOC && MACH_TOSA
+       select SND_PXA2XX_SOC_AC97
+       select SND_SOC_WM9712
+       help
+         Say Y if you want to add support for SoC audio on Sharp
+         Zaurus SL-C6000x models (Tosa).
+
+endmenu
diff --git a/sound/soc/pxa/Makefile b/sound/soc/pxa/Makefile
new file mode 100644 (file)
index 0000000..78e0d6b
--- /dev/null
@@ -0,0 +1,20 @@
+# PXA Platform Support
+snd-soc-pxa2xx-objs := pxa2xx-pcm.o
+snd-soc-pxa2xx-ac97-objs := pxa2xx-ac97.o
+snd-soc-pxa2xx-i2s-objs := pxa2xx-i2s.o
+
+obj-$(CONFIG_SND_PXA2XX_SOC) += snd-soc-pxa2xx.o
+obj-$(CONFIG_SND_PXA2XX_SOC_AC97) += snd-soc-pxa2xx-ac97.o
+obj-$(CONFIG_SND_PXA2XX_SOC_I2S) += snd-soc-pxa2xx-i2s.o
+
+# PXA Machine Support
+snd-soc-corgi-objs := corgi.o
+snd-soc-poodle-objs := poodle.o
+snd-soc-tosa-objs := tosa.o
+snd-soc-spitz-objs := spitz.o
+
+obj-$(CONFIG_SND_PXA2XX_SOC_CORGI) += snd-soc-corgi.o
+obj-$(CONFIG_SND_PXA2XX_SOC_POODLE) += snd-soc-poodle.o
+obj-$(CONFIG_SND_PXA2XX_SOC_TOSA) += snd-soc-tosa.o
+obj-$(CONFIG_SND_PXA2XX_SOC_SPITZ) += snd-soc-spitz.o
+
diff --git a/sound/soc/pxa/corgi.c b/sound/soc/pxa/corgi.c
new file mode 100644 (file)
index 0000000..5ee51a9
--- /dev/null
@@ -0,0 +1,383 @@
+/*
+ * corgi.c  --  SoC audio for Corgi
+ *
+ * Copyright 2005 Wolfson Microelectronics PLC.
+ * Copyright 2005 Openedhand Ltd.
+ *
+ * Authors: Liam Girdwood <liam.girdwood@wolfsonmicro.com>
+ *          Richard Purdie <richard@openedhand.com>
+ *
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ *
+ *  Revision history
+ *    30th Nov 2005   Initial version.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/timer.h>
+#include <linux/interrupt.h>
+#include <linux/platform_device.h>
+#include <sound/driver.h>
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/soc.h>
+#include <sound/soc-dapm.h>
+
+#include <asm/mach-types.h>
+#include <asm/hardware/scoop.h>
+#include <asm/arch/pxa-regs.h>
+#include <asm/arch/hardware.h>
+#include <asm/arch/corgi.h>
+#include <asm/arch/audio.h>
+
+#include "../codecs/wm8731.h"
+#include "pxa2xx-pcm.h"
+#include "pxa2xx-i2s.h"
+
+#define CORGI_HP        0
+#define CORGI_MIC       1
+#define CORGI_LINE      2
+#define CORGI_HEADSET   3
+#define CORGI_HP_OFF    4
+#define CORGI_SPK_ON    0
+#define CORGI_SPK_OFF   1
+
+ /* audio clock in Hz - rounded from 12.235MHz */
+#define CORGI_AUDIO_CLOCK 12288000
+
+static int corgi_jack_func;
+static int corgi_spk_func;
+
+static void corgi_ext_control(struct snd_soc_codec *codec)
+{
+       int spk = 0, mic = 0, line = 0, hp = 0, hs = 0;
+
+       /* set up jack connection */
+       switch (corgi_jack_func) {
+       case CORGI_HP:
+               hp = 1;
+               /* set = unmute headphone */
+               set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_L);
+               set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_R);
+               break;
+       case CORGI_MIC:
+               mic = 1;
+               /* reset = mute headphone */
+               reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_L);
+               reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_R);
+               break;
+       case CORGI_LINE:
+               line = 1;
+               reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_L);
+               reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_R);
+               break;
+       case CORGI_HEADSET:
+               hs = 1;
+               mic = 1;
+               reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_L);
+               set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_R);
+               break;
+       }
+
+       if (corgi_spk_func == CORGI_SPK_ON)
+               spk = 1;
+
+       /* set the enpoints to their new connetion states */
+       snd_soc_dapm_set_endpoint(codec, "Ext Spk", spk);
+       snd_soc_dapm_set_endpoint(codec, "Mic Jack", mic);
+       snd_soc_dapm_set_endpoint(codec, "Line Jack", line);
+       snd_soc_dapm_set_endpoint(codec, "Headphone Jack", hp);
+       snd_soc_dapm_set_endpoint(codec, "Headset Jack", hs);
+
+       /* signal a DAPM event */
+       snd_soc_dapm_sync_endpoints(codec);
+}
+
+static int corgi_startup(struct snd_pcm_substream *substream)
+{
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_codec *codec = rtd->socdev->codec;
+
+       /* check the jack status at stream startup */
+       corgi_ext_control(codec);
+       return 0;
+}
+
+/* we need to unmute the HP at shutdown as the mute burns power on corgi */
+static int corgi_shutdown(struct snd_pcm_substream *substream)
+{
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_codec *codec = rtd->socdev->codec;
+
+       /* set = unmute headphone */
+       set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_L);
+       set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_R);
+       return 0;
+}
+
+static int corgi_hw_params(struct snd_pcm_substream *substream,
+       struct snd_pcm_hw_params *params)
+{
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_codec_dai *codec_dai = rtd->dai->codec_dai;
+       struct snd_soc_cpu_dai *cpu_dai = rtd->dai->cpu_dai;
+       unsigned int clk = 0;
+       int ret = 0;
+
+       switch (params_rate(params)) {
+       case 8000:
+       case 16000:
+       case 48000:
+       case 96000:
+               clk = 12288000;
+               break;
+       case 11025:
+       case 22050:
+       case 44100:
+               clk = 11289600;
+               break;
+       }
+
+       /* set codec DAI configuration */
+       ret = codec_dai->dai_ops.set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
+               SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
+       if (ret < 0)
+               return ret;
+
+       /* set cpu DAI configuration */
+       ret = cpu_dai->dai_ops.set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
+               SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
+       if (ret < 0)
+               return ret;
+
+       /* set the codec system clock for DAC and ADC */
+       ret = codec_dai->dai_ops.set_sysclk(codec_dai, WM8731_SYSCLK, clk,
+               SND_SOC_CLOCK_IN);
+       if (ret < 0)
+               return ret;
+
+       /* set the I2S system clock as input (unused) */
+       ret = cpu_dai->dai_ops.set_sysclk(cpu_dai, PXA2XX_I2S_SYSCLK, 0,
+               SND_SOC_CLOCK_IN);
+       if (ret < 0)
+               return ret;
+
+       return 0;
+}
+
+static struct snd_soc_ops corgi_ops = {
+       .startup = corgi_startup,
+       .hw_params = corgi_hw_params,
+       .shutdown = corgi_shutdown,
+};
+
+static int corgi_get_jack(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_value *ucontrol)
+{
+       ucontrol->value.integer.value[0] = corgi_jack_func;
+       return 0;
+}
+
+static int corgi_set_jack(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+
+       if (corgi_jack_func == ucontrol->value.integer.value[0])
+               return 0;
+
+       corgi_jack_func = ucontrol->value.integer.value[0];
+       corgi_ext_control(codec);
+       return 1;
+}
+
+static int corgi_get_spk(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_value *ucontrol)
+{
+       ucontrol->value.integer.value[0] = corgi_spk_func;
+       return 0;
+}
+
+static int corgi_set_spk(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_soc_codec *codec =  snd_kcontrol_chip(kcontrol);
+
+       if (corgi_spk_func == ucontrol->value.integer.value[0])
+               return 0;
+
+       corgi_spk_func = ucontrol->value.integer.value[0];
+       corgi_ext_control(codec);
+       return 1;
+}
+
+static int corgi_amp_event(struct snd_soc_dapm_widget *w, int event)
+{
+       if (SND_SOC_DAPM_EVENT_ON(event))
+               set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_APM_ON);
+       else
+               reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_APM_ON);
+
+       return 0;
+}
+
+static int corgi_mic_event(struct snd_soc_dapm_widget *w, int event)
+{
+       if (SND_SOC_DAPM_EVENT_ON(event))
+               set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MIC_BIAS);
+       else
+               reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MIC_BIAS);
+
+       return 0;
+}
+
+/* corgi machine dapm widgets */
+static const struct snd_soc_dapm_widget wm8731_dapm_widgets[] = {
+SND_SOC_DAPM_HP("Headphone Jack", NULL),
+SND_SOC_DAPM_MIC("Mic Jack", corgi_mic_event),
+SND_SOC_DAPM_SPK("Ext Spk", corgi_amp_event),
+SND_SOC_DAPM_LINE("Line Jack", NULL),
+SND_SOC_DAPM_HP("Headset Jack", NULL),
+};
+
+/* Corgi machine audio map (connections to the codec pins) */
+static const char *audio_map[][3] = {
+
+       /* headset Jack  - in = micin, out = LHPOUT*/
+       {"Headset Jack", NULL, "LHPOUT"},
+
+       /* headphone connected to LHPOUT1, RHPOUT1 */
+       {"Headphone Jack", NULL, "LHPOUT"},
+       {"Headphone Jack", NULL, "RHPOUT"},
+
+       /* speaker connected to LOUT, ROUT */
+       {"Ext Spk", NULL, "ROUT"},
+       {"Ext Spk", NULL, "LOUT"},
+
+       /* mic is connected to MICIN (via right channel of headphone jack) */
+       {"MICIN", NULL, "Mic Jack"},
+
+       /* Same as the above but no mic bias for line signals */
+       {"MICIN", NULL, "Line Jack"},
+
+       {NULL, NULL, NULL},
+};
+
+static const char *jack_function[] = {"Headphone", "Mic", "Line", "Headset",
+       "Off"};
+static const char *spk_function[] = {"On", "Off"};
+static const struct soc_enum corgi_enum[] = {
+       SOC_ENUM_SINGLE_EXT(5, jack_function),
+       SOC_ENUM_SINGLE_EXT(2, spk_function),
+};
+
+static const struct snd_kcontrol_new wm8731_corgi_controls[] = {
+       SOC_ENUM_EXT("Jack Function", corgi_enum[0], corgi_get_jack,
+               corgi_set_jack),
+       SOC_ENUM_EXT("Speaker Function", corgi_enum[1], corgi_get_spk,
+               corgi_set_spk),
+};
+
+/*
+ * Logic for a wm8731 as connected on a Sharp SL-C7x0 Device
+ */
+static int corgi_wm8731_init(struct snd_soc_codec *codec)
+{
+       int i, err;
+
+       snd_soc_dapm_set_endpoint(codec, "LLINEIN", 0);
+       snd_soc_dapm_set_endpoint(codec, "RLINEIN", 0);
+
+       /* Add corgi specific controls */
+       for (i = 0; i < ARRAY_SIZE(wm8731_corgi_controls); i++) {
+               err = snd_ctl_add(codec->card,
+                       snd_soc_cnew(&wm8731_corgi_controls[i],codec, NULL));
+               if (err < 0)
+                       return err;
+       }
+
+       /* Add corgi specific widgets */
+       for(i = 0; i < ARRAY_SIZE(wm8731_dapm_widgets); i++) {
+               snd_soc_dapm_new_control(codec, &wm8731_dapm_widgets[i]);
+       }
+
+       /* Set up corgi specific audio path audio_map */
+       for(i = 0; audio_map[i][0] != NULL; i++) {
+               snd_soc_dapm_connect_input(codec, audio_map[i][0],
+                       audio_map[i][1], audio_map[i][2]);
+       }
+
+       snd_soc_dapm_sync_endpoints(codec);
+       return 0;
+}
+
+/* corgi digital audio interface glue - connects codec <--> CPU */
+static struct snd_soc_dai_link corgi_dai = {
+       .name = "WM8731",
+       .stream_name = "WM8731",
+       .cpu_dai = &pxa_i2s_dai,
+       .codec_dai = &wm8731_dai,
+       .init = corgi_wm8731_init,
+       .ops = &corgi_ops,
+};
+
+/* corgi audio machine driver */
+static struct snd_soc_machine snd_soc_machine_corgi = {
+       .name = "Corgi",
+       .dai_link = &corgi_dai,
+       .num_links = 1,
+};
+
+/* corgi audio private data */
+static struct wm8731_setup_data corgi_wm8731_setup = {
+       .i2c_address = 0x1b,
+};
+
+/* corgi audio subsystem */
+static struct snd_soc_device corgi_snd_devdata = {
+       .machine = &snd_soc_machine_corgi,
+       .platform = &pxa2xx_soc_platform,
+       .codec_dev = &soc_codec_dev_wm8731,
+       .codec_data = &corgi_wm8731_setup,
+};
+
+static struct platform_device *corgi_snd_device;
+
+static int __init corgi_init(void)
+{
+       int ret;
+
+       if (!(machine_is_corgi() || machine_is_shepherd() || machine_is_husky()))
+               return -ENODEV;
+
+       corgi_snd_device = platform_device_alloc("soc-audio", -1);
+       if (!corgi_snd_device)
+               return -ENOMEM;
+
+       platform_set_drvdata(corgi_snd_device, &corgi_snd_devdata);
+       corgi_snd_devdata.dev = &corgi_snd_device->dev;
+       ret = platform_device_add(corgi_snd_device);
+
+       if (ret)
+               platform_device_put(corgi_snd_device);
+
+       return ret;
+}
+
+static void __exit corgi_exit(void)
+{
+       platform_device_unregister(corgi_snd_device);
+}
+
+module_init(corgi_init);
+module_exit(corgi_exit);
+
+/* Module information */
+MODULE_AUTHOR("Richard Purdie");
+MODULE_DESCRIPTION("ALSA SoC Corgi");
+MODULE_LICENSE("GPL");
diff --git a/sound/soc/pxa/poodle.c b/sound/soc/pxa/poodle.c
new file mode 100644 (file)
index 0000000..0915cf7
--- /dev/null
@@ -0,0 +1,352 @@
+/*
+ * poodle.c  --  SoC audio for Poodle
+ *
+ * Copyright 2005 Wolfson Microelectronics PLC.
+ * Copyright 2005 Openedhand Ltd.
+ *
+ * Authors: Liam Girdwood <liam.girdwood@wolfsonmicro.com>
+ *          Richard Purdie <richard@openedhand.com>
+ *
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/timer.h>
+#include <linux/interrupt.h>
+#include <linux/platform_device.h>
+#include <sound/driver.h>
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/soc.h>
+#include <sound/soc-dapm.h>
+
+#include <asm/mach-types.h>
+#include <asm/hardware/locomo.h>
+#include <asm/arch/pxa-regs.h>
+#include <asm/arch/hardware.h>
+#include <asm/arch/poodle.h>
+#include <asm/arch/audio.h>
+
+#include "../codecs/wm8731.h"
+#include "pxa2xx-pcm.h"
+#include "pxa2xx-i2s.h"
+
+#define POODLE_HP        1
+#define POODLE_HP_OFF    0
+#define POODLE_SPK_ON    1
+#define POODLE_SPK_OFF   0
+
+ /* audio clock in Hz - rounded from 12.235MHz */
+#define POODLE_AUDIO_CLOCK 12288000
+
+static int poodle_jack_func;
+static int poodle_spk_func;
+
+static void poodle_ext_control(struct snd_soc_codec *codec)
+{
+       int spk = 0;
+
+       /* set up jack connection */
+       if (poodle_jack_func == POODLE_HP) {
+               /* set = unmute headphone */
+               locomo_gpio_write(&poodle_locomo_device.dev,
+                       POODLE_LOCOMO_GPIO_MUTE_L, 1);
+               locomo_gpio_write(&poodle_locomo_device.dev,
+                       POODLE_LOCOMO_GPIO_MUTE_R, 1);
+               snd_soc_dapm_set_endpoint(codec, "Headphone Jack", 1);
+       } else {
+               locomo_gpio_write(&poodle_locomo_device.dev,
+                       POODLE_LOCOMO_GPIO_MUTE_L, 0);
+               locomo_gpio_write(&poodle_locomo_device.dev,
+                       POODLE_LOCOMO_GPIO_MUTE_R, 0);
+               snd_soc_dapm_set_endpoint(codec, "Headphone Jack", 0);
+       }
+
+       if (poodle_spk_func == POODLE_SPK_ON)
+               spk = 1;
+
+       /* set the enpoints to their new connetion states */
+       snd_soc_dapm_set_endpoint(codec, "Ext Spk", spk);
+
+       /* signal a DAPM event */
+       snd_soc_dapm_sync_endpoints(codec);
+}
+
+static int poodle_startup(struct snd_pcm_substream *substream)
+{
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_codec *codec = rtd->socdev->codec;
+
+       /* check the jack status at stream startup */
+       poodle_ext_control(codec);
+       return 0;
+}
+
+/* we need to unmute the HP at shutdown as the mute burns power on poodle */
+static int poodle_shutdown(struct snd_pcm_substream *substream)
+{
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_codec *codec = rtd->socdev->codec;
+
+       /* set = unmute headphone */
+       locomo_gpio_write(&poodle_locomo_device.dev,
+               POODLE_LOCOMO_GPIO_MUTE_L, 1);
+       locomo_gpio_write(&poodle_locomo_device.dev,
+               POODLE_LOCOMO_GPIO_MUTE_R, 1);
+       return 0;
+}
+
+static int poodle_hw_params(struct snd_pcm_substream *substream,
+       struct snd_pcm_hw_params *params)
+{
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_codec_dai *codec_dai = rtd->dai->codec_dai;
+       struct snd_soc_cpu_dai *cpu_dai = rtd->dai->cpu_dai;
+       unsigned int clk = 0;
+       int ret = 0;
+
+       switch (params_rate(params)) {
+       case 8000:
+       case 16000:
+       case 48000:
+       case 96000:
+               clk = 12288000;
+               break;
+       case 11025:
+       case 22050:
+       case 44100:
+               clk = 11289600;
+               break;
+       }
+
+       /* set codec DAI configuration */
+       ret = codec_dai->dai_ops.set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
+               SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
+       if (ret < 0)
+               return ret;
+
+       /* set cpu DAI configuration */
+       ret = cpu_dai->dai_ops.set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
+               SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
+       if (ret < 0)
+               return ret;
+
+       /* set the codec system clock for DAC and ADC */
+       ret = codec_dai->dai_ops.set_sysclk(codec_dai, WM8731_SYSCLK, clk,
+               SND_SOC_CLOCK_IN);
+       if (ret < 0)
+               return ret;
+
+       /* set the I2S system clock as input (unused) */
+       ret = cpu_dai->dai_ops.set_sysclk(cpu_dai, PXA2XX_I2S_SYSCLK, 0,
+               SND_SOC_CLOCK_IN);
+       if (ret < 0)
+               return ret;
+
+       return 0;
+}
+
+static struct snd_soc_ops poodle_ops = {
+       .startup = poodle_startup,
+       .hw_params = poodle_hw_params,
+       .shutdown = poodle_shutdown,
+};
+
+static int poodle_get_jack(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_value *ucontrol)
+{
+       ucontrol->value.integer.value[0] = poodle_jack_func;
+       return 0;
+}
+
+static int poodle_set_jack(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_soc_codec *codec =  snd_kcontrol_chip(kcontrol);
+
+       if (poodle_jack_func == ucontrol->value.integer.value[0])
+               return 0;
+
+       poodle_jack_func = ucontrol->value.integer.value[0];
+       poodle_ext_control(codec);
+       return 1;
+}
+
+static int poodle_get_spk(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_value *ucontrol)
+{
+       ucontrol->value.integer.value[0] = poodle_spk_func;
+       return 0;
+}
+
+static int poodle_set_spk(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_soc_codec *codec =  snd_kcontrol_chip(kcontrol);
+
+       if (poodle_spk_func == ucontrol->value.integer.value[0])
+               return 0;
+
+       poodle_spk_func = ucontrol->value.integer.value[0];
+       poodle_ext_control(codec);
+       return 1;
+}
+
+static int poodle_amp_event(struct snd_soc_dapm_widget *w, int event)
+{
+       if (SND_SOC_DAPM_EVENT_ON(event))
+               locomo_gpio_write(&poodle_locomo_device.dev,
+                       POODLE_LOCOMO_GPIO_AMP_ON, 0);
+       else
+               locomo_gpio_write(&poodle_locomo_device.dev,
+                       POODLE_LOCOMO_GPIO_AMP_ON, 1);
+
+       return 0;
+}
+
+/* poodle machine dapm widgets */
+static const struct snd_soc_dapm_widget wm8731_dapm_widgets[] = {
+SND_SOC_DAPM_HP("Headphone Jack", NULL),
+SND_SOC_DAPM_SPK("Ext Spk", poodle_amp_event),
+};
+
+/* Corgi machine audio_mapnections to the codec pins */
+static const char *audio_map[][3] = {
+
+       /* headphone connected to LHPOUT1, RHPOUT1 */
+       {"Headphone Jack", NULL, "LHPOUT"},
+       {"Headphone Jack", NULL, "RHPOUT"},
+
+       /* speaker connected to LOUT, ROUT */
+       {"Ext Spk", NULL, "ROUT"},
+       {"Ext Spk", NULL, "LOUT"},
+
+       {NULL, NULL, NULL},
+};
+
+static const char *jack_function[] = {"Off", "Headphone"};
+static const char *spk_function[] = {"Off", "On"};
+static const struct soc_enum poodle_enum[] = {
+       SOC_ENUM_SINGLE_EXT(2, jack_function),
+       SOC_ENUM_SINGLE_EXT(2, spk_function),
+};
+
+static const snd_kcontrol_new_t wm8731_poodle_controls[] = {
+       SOC_ENUM_EXT("Jack Function", poodle_enum[0], poodle_get_jack,
+               poodle_set_jack),
+       SOC_ENUM_EXT("Speaker Function", poodle_enum[1], poodle_get_spk,
+               poodle_set_spk),
+};
+
+/*
+ * Logic for a wm8731 as connected on a Sharp SL-C7x0 Device
+ */
+static int poodle_wm8731_init(struct snd_soc_codec *codec)
+{
+       int i, err;
+
+       snd_soc_dapm_set_endpoint(codec, "LLINEIN", 0);
+       snd_soc_dapm_set_endpoint(codec, "RLINEIN", 0);
+       snd_soc_dapm_set_endpoint(codec, "MICIN", 1);
+
+       /* Add poodle specific controls */
+       for (i = 0; i < ARRAY_SIZE(wm8731_poodle_controls); i++) {
+               err = snd_ctl_add(codec->card,
+                       snd_soc_cnew(&wm8731_poodle_controls[i],codec, NULL));
+               if (err < 0)
+                       return err;
+       }
+
+       /* Add poodle specific widgets */
+       for (i = 0; i < ARRAY_SIZE(wm8731_dapm_widgets); i++) {
+               snd_soc_dapm_new_control(codec, &wm8731_dapm_widgets[i]);
+       }
+
+       /* Set up poodle specific audio path audio_map */
+       for (i = 0; audio_map[i][0] != NULL; i++) {
+               snd_soc_dapm_connect_input(codec, audio_map[i][0],
+                       audio_map[i][1], audio_map[i][2]);
+       }
+
+       snd_soc_dapm_sync_endpoints(codec);
+       return 0;
+}
+
+/* poodle digital audio interface glue - connects codec <--> CPU */
+static struct snd_soc_dai_link poodle_dai = {
+       .name = "WM8731",
+       .stream_name = "WM8731",
+       .cpu_dai = &pxa_i2s_dai,
+       .codec_dai = &wm8731_dai,
+       .init = poodle_wm8731_init,
+       .ops = &poodle_ops,
+};
+
+/* poodle audio machine driver */
+static struct snd_soc_machine snd_soc_machine_poodle = {
+       .name = "Poodle",
+       .dai_link = &poodle_dai,
+       .num_links = 1,
+};
+
+/* poodle audio private data */
+static struct wm8731_setup_data poodle_wm8731_setup = {
+       .i2c_address = 0x1b,
+};
+
+/* poodle audio subsystem */
+static struct snd_soc_device poodle_snd_devdata = {
+       .machine = &snd_soc_machine_poodle,
+       .platform = &pxa2xx_soc_platform,
+       .codec_dev = &soc_codec_dev_wm8731,
+       .codec_data = &poodle_wm8731_setup,
+};
+
+static struct platform_device *poodle_snd_device;
+
+static int __init poodle_init(void)
+{
+       int ret;
+
+       if (!machine_is_poodle())
+               return -ENODEV;
+
+       locomo_gpio_set_dir(&poodle_locomo_device.dev,
+               POODLE_LOCOMO_GPIO_AMP_ON, 0);
+       /* should we mute HP at startup - burning power ?*/
+       locomo_gpio_set_dir(&poodle_locomo_device.dev,
+               POODLE_LOCOMO_GPIO_MUTE_L, 0);
+       locomo_gpio_set_dir(&poodle_locomo_device.dev,
+               POODLE_LOCOMO_GPIO_MUTE_R, 0);
+
+       poodle_snd_device = platform_device_alloc("soc-audio", -1);
+       if (!poodle_snd_device)
+               return -ENOMEM;
+
+       platform_set_drvdata(poodle_snd_device, &poodle_snd_devdata);
+       poodle_snd_devdata.dev = &poodle_snd_device->dev;
+       ret = platform_device_add(poodle_snd_device);
+
+       if (ret)
+               platform_device_put(poodle_snd_device);
+
+       return ret;
+}
+
+static void __exit poodle_exit(void)
+{
+       platform_device_unregister(poodle_snd_device);
+}
+
+module_init(poodle_init);
+module_exit(poodle_exit);
+
+/* Module information */
+MODULE_AUTHOR("Richard Purdie");
+MODULE_DESCRIPTION("ALSA SoC Poodle");
+MODULE_LICENSE("GPL");
diff --git a/sound/soc/pxa/pxa2xx-ac97.c b/sound/soc/pxa/pxa2xx-ac97.c
new file mode 100644 (file)
index 0000000..1bbbeff
--- /dev/null
@@ -0,0 +1,431 @@
+/*
+ * linux/sound/pxa2xx-ac97.c -- AC97 support for the Intel PXA2xx chip.
+ *
+ * Author:     Nicolas Pitre
+ * Created:    Dec 02, 2004
+ * Copyright:  MontaVista Software Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/interrupt.h>
+#include <linux/wait.h>
+#include <linux/delay.h>
+
+#include <sound/driver.h>
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/ac97_codec.h>
+#include <sound/initval.h>
+#include <sound/soc.h>
+
+#include <asm/irq.h>
+#include <linux/mutex.h>
+#include <asm/hardware.h>
+#include <asm/arch/pxa-regs.h>
+#include <asm/arch/audio.h>
+
+#include "pxa2xx-pcm.h"
+#include "pxa2xx-ac97.h"
+
+static DEFINE_MUTEX(car_mutex);
+static DECLARE_WAIT_QUEUE_HEAD(gsr_wq);
+static volatile long gsr_bits;
+
+/*
+ * Beware PXA27x bugs:
+ *
+ *   o Slot 12 read from modem space will hang controller.
+ *   o CDONE, SDONE interrupt fails after any slot 12 IO.
+ *
+ * We therefore have an hybrid approach for waiting on SDONE (interrupt or
+ * 1 jiffy timeout if interrupt never comes).
+ */
+
+static unsigned short pxa2xx_ac97_read(struct snd_ac97 *ac97,
+       unsigned short reg)
+{
+       unsigned short val = -1;
+       volatile u32 *reg_addr;
+
+       mutex_lock(&car_mutex);
+
+       /* set up primary or secondary codec/modem space */
+#ifdef CONFIG_PXA27x
+       reg_addr = ac97->num ? &SAC_REG_BASE : &PAC_REG_BASE;
+#else
+       if (reg == AC97_GPIO_STATUS)
+               reg_addr = ac97->num ? &SMC_REG_BASE : &PMC_REG_BASE;
+       else
+               reg_addr = ac97->num ? &SAC_REG_BASE : &PAC_REG_BASE;
+#endif
+       reg_addr += (reg >> 1);
+
+#ifndef CONFIG_PXA27x
+       if (reg == AC97_GPIO_STATUS) {
+               /* read from controller cache */
+               val = *reg_addr;
+               goto out;
+       }
+#endif
+
+       /* start read access across the ac97 link */
+       GSR = GSR_CDONE | GSR_SDONE;
+       gsr_bits = 0;
+       val = *reg_addr;
+
+       wait_event_timeout(gsr_wq, (GSR | gsr_bits) & GSR_SDONE, 1);
+       if (!((GSR | gsr_bits) & GSR_SDONE)) {
+               printk(KERN_ERR "%s: read error (ac97_reg=%x GSR=%#lx)\n",
+                               __FUNCTION__, reg, GSR | gsr_bits);
+               val = -1;
+               goto out;
+       }
+
+       /* valid data now */
+       GSR = GSR_CDONE | GSR_SDONE;
+       gsr_bits = 0;
+       val = *reg_addr;
+       /* but we've just started another cycle... */
+       wait_event_timeout(gsr_wq, (GSR | gsr_bits) & GSR_SDONE, 1);
+
+out:   mutex_unlock(&car_mutex);
+       return val;
+}
+
+static void pxa2xx_ac97_write(struct snd_ac97 *ac97, unsigned short reg,
+       unsigned short val)
+{
+       volatile u32 *reg_addr;
+
+       mutex_lock(&car_mutex);
+
+       /* set up primary or secondary codec/modem space */
+#ifdef CONFIG_PXA27x
+       reg_addr = ac97->num ? &SAC_REG_BASE : &PAC_REG_BASE;
+#else
+       if (reg == AC97_GPIO_STATUS)
+               reg_addr = ac97->num ? &SMC_REG_BASE : &PMC_REG_BASE;
+       else
+               reg_addr = ac97->num ? &SAC_REG_BASE : &PAC_REG_BASE;
+#endif
+       reg_addr += (reg >> 1);
+
+       GSR = GSR_CDONE | GSR_SDONE;
+       gsr_bits = 0;
+       *reg_addr = val;
+       wait_event_timeout(gsr_wq, (GSR | gsr_bits) & GSR_CDONE, 1);
+       if (!((GSR | gsr_bits) & GSR_CDONE))
+               printk(KERN_ERR "%s: write error (ac97_reg=%x GSR=%#lx)\n",
+                               __FUNCTION__, reg, GSR | gsr_bits);
+
+       mutex_unlock(&car_mutex);
+}
+
+static void pxa2xx_ac97_warm_reset(struct snd_ac97 *ac97)
+{
+       gsr_bits = 0;
+
+#ifdef CONFIG_PXA27x
+       /* warm reset broken on Bulverde,
+          so manually keep AC97 reset high */
+       pxa_gpio_mode(113 | GPIO_OUT | GPIO_DFLT_HIGH);
+       udelay(10);
+       GCR |= GCR_WARM_RST;
+       pxa_gpio_mode(113 | GPIO_ALT_FN_2_OUT);
+       udelay(500);
+#else
+       GCR |= GCR_WARM_RST | GCR_PRIRDY_IEN | GCR_SECRDY_IEN;
+       wait_event_timeout(gsr_wq, gsr_bits & (GSR_PCR | GSR_SCR), 1);
+#endif
+
+       if (!((GSR | gsr_bits) & (GSR_PCR | GSR_SCR)))
+               printk(KERN_INFO "%s: warm reset timeout (GSR=%#lx)\n",
+                                __FUNCTION__, gsr_bits);
+
+       GCR &= ~(GCR_PRIRDY_IEN|GCR_SECRDY_IEN);
+       GCR |= GCR_SDONE_IE|GCR_CDONE_IE;
+}
+
+static void pxa2xx_ac97_cold_reset(struct snd_ac97 *ac97)
+{
+       GCR &=  GCR_COLD_RST;  /* clear everything but nCRST */
+       GCR &= ~GCR_COLD_RST;  /* then assert nCRST */
+
+       gsr_bits = 0;
+#ifdef CONFIG_PXA27x
+       /* PXA27x Developers Manual section 13.5.2.2.1 */
+       pxa_set_cken(1 << 31, 1);
+       udelay(5);
+       pxa_set_cken(1 << 31, 0);
+       GCR = GCR_COLD_RST;
+       udelay(50);
+#else
+       GCR = GCR_COLD_RST;
+       GCR |= GCR_CDONE_IE|GCR_SDONE_IE;
+       wait_event_timeout(gsr_wq, gsr_bits & (GSR_PCR | GSR_SCR), 1);
+#endif
+
+       if (!((GSR | gsr_bits) & (GSR_PCR | GSR_SCR)))
+               printk(KERN_INFO "%s: cold reset timeout (GSR=%#lx)\n",
+                                __FUNCTION__, gsr_bits);
+
+       GCR &= ~(GCR_PRIRDY_IEN|GCR_SECRDY_IEN);
+       GCR |= GCR_SDONE_IE|GCR_CDONE_IE;
+}
+
+static irqreturn_t pxa2xx_ac97_irq(int irq, void *dev_id)
+{
+       long status;
+
+       status = GSR;
+       if (status) {
+               GSR = status;
+               gsr_bits |= status;
+               wake_up(&gsr_wq);
+
+#ifdef CONFIG_PXA27x
+               /* Although we don't use those we still need to clear them
+                  since they tend to spuriously trigger when MMC is used
+                  (hardware bug? go figure)... */
+               MISR = MISR_EOC;
+               PISR = PISR_EOC;
+               MCSR = MCSR_EOC;
+#endif
+
+               return IRQ_HANDLED;
+       }
+
+       return IRQ_NONE;
+}
+
+struct snd_ac97_bus_ops soc_ac97_ops = {
+       .read   = pxa2xx_ac97_read,
+       .write  = pxa2xx_ac97_write,
+       .warm_reset     = pxa2xx_ac97_warm_reset,
+       .reset  = pxa2xx_ac97_cold_reset,
+};
+
+static struct pxa2xx_pcm_dma_params pxa2xx_ac97_pcm_stereo_out = {
+       .name                   = "AC97 PCM Stereo out",
+       .dev_addr               = __PREG(PCDR),
+       .drcmr                  = &DRCMRTXPCDR,
+       .dcmd                   = DCMD_INCSRCADDR | DCMD_FLOWTRG |
+                                 DCMD_BURST32 | DCMD_WIDTH4,
+};
+
+static struct pxa2xx_pcm_dma_params pxa2xx_ac97_pcm_stereo_in = {
+       .name                   = "AC97 PCM Stereo in",
+       .dev_addr               = __PREG(PCDR),
+       .drcmr                  = &DRCMRRXPCDR,
+       .dcmd                   = DCMD_INCTRGADDR | DCMD_FLOWSRC |
+                                 DCMD_BURST32 | DCMD_WIDTH4,
+};
+
+static struct pxa2xx_pcm_dma_params pxa2xx_ac97_pcm_aux_mono_out = {
+       .name                   = "AC97 Aux PCM (Slot 5) Mono out",
+       .dev_addr               = __PREG(MODR),
+       .drcmr                  = &DRCMRTXMODR,
+       .dcmd                   = DCMD_INCSRCADDR | DCMD_FLOWTRG |
+                                 DCMD_BURST16 | DCMD_WIDTH2,
+};
+
+static struct pxa2xx_pcm_dma_params pxa2xx_ac97_pcm_aux_mono_in = {
+       .name                   = "AC97 Aux PCM (Slot 5) Mono in",
+       .dev_addr               = __PREG(MODR),
+       .drcmr                  = &DRCMRRXMODR,
+       .dcmd                   = DCMD_INCTRGADDR | DCMD_FLOWSRC |
+                                 DCMD_BURST16 | DCMD_WIDTH2,
+};
+
+static struct pxa2xx_pcm_dma_params pxa2xx_ac97_pcm_mic_mono_in = {
+       .name                   = "AC97 Mic PCM (Slot 6) Mono in",
+       .dev_addr               = __PREG(MCDR),
+       .drcmr                  = &DRCMRRXMCDR,
+       .dcmd                   = DCMD_INCTRGADDR | DCMD_FLOWSRC |
+                                 DCMD_BURST16 | DCMD_WIDTH2,
+};
+
+#ifdef CONFIG_PM
+static int pxa2xx_ac97_suspend(struct platform_device *pdev,
+       struct snd_soc_cpu_dai *dai)
+{
+       GCR |= GCR_ACLINK_OFF;
+       pxa_set_cken(CKEN2_AC97, 0);
+       return 0;
+}
+
+static int pxa2xx_ac97_resume(struct platform_device *pdev,
+       struct snd_soc_cpu_dai *dai)
+{
+       pxa_gpio_mode(GPIO31_SYNC_AC97_MD);
+       pxa_gpio_mode(GPIO30_SDATA_OUT_AC97_MD);
+       pxa_gpio_mode(GPIO28_BITCLK_AC97_MD);
+       pxa_gpio_mode(GPIO29_SDATA_IN_AC97_MD);
+#ifdef CONFIG_PXA27x
+       /* Use GPIO 113 as AC97 Reset on Bulverde */
+       pxa_gpio_mode(113 | GPIO_ALT_FN_2_OUT);
+#endif
+       pxa_set_cken(CKEN2_AC97, 1);
+       return 0;
+}
+
+#else
+#define pxa2xx_ac97_suspend    NULL
+#define pxa2xx_ac97_resume     NULL
+#endif
+
+static int pxa2xx_ac97_probe(struct platform_device *pdev)
+{
+       int ret;
+
+       ret = request_irq(IRQ_AC97, pxa2xx_ac97_irq, IRQF_DISABLED, "AC97", NULL);
+       if (ret < 0)
+               goto err;
+
+       pxa_gpio_mode(GPIO31_SYNC_AC97_MD);
+       pxa_gpio_mode(GPIO30_SDATA_OUT_AC97_MD);
+       pxa_gpio_mode(GPIO28_BITCLK_AC97_MD);
+       pxa_gpio_mode(GPIO29_SDATA_IN_AC97_MD);
+#ifdef CONFIG_PXA27x
+       /* Use GPIO 113 as AC97 Reset on Bulverde */
+       pxa_gpio_mode(113 | GPIO_ALT_FN_2_OUT);
+#endif
+       pxa_set_cken(CKEN2_AC97, 1);
+       return 0;
+
+ err:
+       if (CKEN & CKEN2_AC97) {
+               GCR |= GCR_ACLINK_OFF;
+               free_irq(IRQ_AC97, NULL);
+               pxa_set_cken(CKEN2_AC97, 0);
+       }
+       return ret;
+}
+
+static void pxa2xx_ac97_remove(struct platform_device *pdev)
+{
+       GCR |= GCR_ACLINK_OFF;
+       free_irq(IRQ_AC97, NULL);
+       pxa_set_cken(CKEN2_AC97, 0);
+}
+
+static int pxa2xx_ac97_hw_params(struct snd_pcm_substream *substream,
+                               struct snd_pcm_hw_params *params)
+{
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_cpu_dai *cpu_dai = rtd->dai->cpu_dai;
+
+       if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+               cpu_dai->dma_data = &pxa2xx_ac97_pcm_stereo_out;
+       else
+               cpu_dai->dma_data = &pxa2xx_ac97_pcm_stereo_in;
+
+       return 0;
+}
+
+static int pxa2xx_ac97_hw_aux_params(struct snd_pcm_substream *substream,
+       struct snd_pcm_hw_params *params)
+{
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_cpu_dai *cpu_dai = rtd->dai->cpu_dai;
+
+       if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+               cpu_dai->dma_data = &pxa2xx_ac97_pcm_aux_mono_out;
+       else
+               cpu_dai->dma_data = &pxa2xx_ac97_pcm_aux_mono_in;
+
+       return 0;
+}
+
+static int pxa2xx_ac97_hw_mic_params(struct snd_pcm_substream *substream,
+       struct snd_pcm_hw_params *params)
+{
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_cpu_dai *cpu_dai = rtd->dai->cpu_dai;
+
+       if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+               return -ENODEV;
+       else
+               cpu_dai->dma_data = &pxa2xx_ac97_pcm_mic_mono_in;
+
+       return 0;
+}
+
+#define PXA2XX_AC97_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\
+               SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_44100 | \
+               SNDRV_PCM_RATE_48000)
+
+/*
+ * There is only 1 physical AC97 interface for pxa2xx, but it
+ * has extra fifo's that can be used for aux DACs and ADCs.
+ */
+struct snd_soc_cpu_dai pxa_ac97_dai[] = {
+{
+       .name = "pxa2xx-ac97",
+       .id = 0,
+       .type = SND_SOC_DAI_AC97,
+       .probe = pxa2xx_ac97_probe,
+       .remove = pxa2xx_ac97_remove,
+       .suspend = pxa2xx_ac97_suspend,
+       .resume = pxa2xx_ac97_resume,
+       .playback = {
+               .stream_name = "AC97 Playback",
+               .channels_min = 2,
+               .channels_max = 2,
+               .rates = PXA2XX_AC97_RATES,
+               .formats = SNDRV_PCM_FMTBIT_S16_LE,},
+       .capture = {
+               .stream_name = "AC97 Capture",
+               .channels_min = 2,
+               .channels_max = 2,
+               .rates = PXA2XX_AC97_RATES,
+               .formats = SNDRV_PCM_FMTBIT_S16_LE,},
+       .ops = {
+               .hw_params = pxa2xx_ac97_hw_params,},
+},
+{
+       .name = "pxa2xx-ac97-aux",
+       .id = 1,
+       .type = SND_SOC_DAI_AC97,
+       .playback = {
+               .stream_name = "AC97 Aux Playback",
+               .channels_min = 1,
+               .channels_max = 1,
+               .rates = PXA2XX_AC97_RATES,
+               .formats = SNDRV_PCM_FMTBIT_S16_LE,},
+       .capture = {
+               .stream_name = "AC97 Aux Capture",
+               .channels_min = 1,
+               .channels_max = 1,
+               .rates = PXA2XX_AC97_RATES,
+               .formats = SNDRV_PCM_FMTBIT_S16_LE,},
+       .ops = {
+               .hw_params = pxa2xx_ac97_hw_aux_params,},
+},
+{
+       .name = "pxa2xx-ac97-mic",
+       .id = 2,
+       .type = SND_SOC_DAI_AC97,
+       .capture = {
+               .stream_name = "AC97 Mic Capture",
+               .channels_min = 1,
+               .channels_max = 1,
+               .rates = PXA2XX_AC97_RATES,
+               .formats = SNDRV_PCM_FMTBIT_S16_LE,},
+       .ops = {
+               .hw_params = pxa2xx_ac97_hw_mic_params,},
+},
+};
+
+EXPORT_SYMBOL_GPL(pxa_ac97_dai);
+EXPORT_SYMBOL_GPL(soc_ac97_ops);
+
+MODULE_AUTHOR("Nicolas Pitre");
+MODULE_DESCRIPTION("AC97 driver for the Intel PXA2xx chip");
+MODULE_LICENSE("GPL");
diff --git a/sound/soc/pxa/pxa2xx-ac97.h b/sound/soc/pxa/pxa2xx-ac97.h
new file mode 100644 (file)
index 0000000..4c4b882
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * linux/sound/arm/pxa2xx-ac97.h
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef _PXA2XX_AC97_H
+#define _PXA2XX_AC97_H
+
+/* pxa2xx DAI ID's */
+#define PXA2XX_DAI_AC97_HIFI   0
+#define PXA2XX_DAI_AC97_AUX            1
+#define PXA2XX_DAI_AC97_MIC            2
+
+extern struct snd_soc_cpu_dai pxa_ac97_dai[3];
+
+/* platform data */
+extern struct snd_ac97_bus_ops pxa2xx_ac97_ops;
+
+#endif
diff --git a/sound/soc/pxa/pxa2xx-i2s.c b/sound/soc/pxa/pxa2xx-i2s.c
new file mode 100644 (file)
index 0000000..575a613
--- /dev/null
@@ -0,0 +1,318 @@
+/*
+ * pxa2xx-i2s.c  --  ALSA Soc Audio Layer
+ *
+ * Copyright 2005 Wolfson Microelectronics PLC.
+ * Author: Liam Girdwood
+ *         liam.girdwood@wolfsonmicro.com or linux@wolfsonmicro.com
+ *
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ *
+ *  Revision history
+ *    12th Aug 2005   Initial version.
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/device.h>
+#include <linux/delay.h>
+#include <sound/driver.h>
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/initval.h>
+#include <sound/soc.h>
+
+#include <asm/hardware.h>
+#include <asm/arch/pxa-regs.h>
+#include <asm/arch/audio.h>
+
+#include "pxa2xx-pcm.h"
+#include "pxa2xx-i2s.h"
+
+struct pxa_i2s_port {
+       u32 sadiv;
+       u32 sacr0;
+       u32 sacr1;
+       u32 saimr;
+       int master;
+       u32 fmt;
+};
+static struct pxa_i2s_port pxa_i2s;
+
+static struct pxa2xx_pcm_dma_params pxa2xx_i2s_pcm_stereo_out = {
+       .name                   = "I2S PCM Stereo out",
+       .dev_addr               = __PREG(SADR),
+       .drcmr                  = &DRCMRTXSADR,
+       .dcmd                   = DCMD_INCSRCADDR | DCMD_FLOWTRG |
+                                 DCMD_BURST32 | DCMD_WIDTH4,
+};
+
+static struct pxa2xx_pcm_dma_params pxa2xx_i2s_pcm_stereo_in = {
+       .name                   = "I2S PCM Stereo in",
+       .dev_addr               = __PREG(SADR),
+       .drcmr                  = &DRCMRRXSADR,
+       .dcmd                   = DCMD_INCTRGADDR | DCMD_FLOWSRC |
+                                 DCMD_BURST32 | DCMD_WIDTH4,
+};
+
+static struct pxa2xx_gpio gpio_bus[] = {
+       { /* I2S SoC Slave */
+               .rx = GPIO29_SDATA_IN_I2S_MD,
+               .tx = GPIO30_SDATA_OUT_I2S_MD,
+               .clk = GPIO28_BITCLK_IN_I2S_MD,
+               .frm = GPIO31_SYNC_I2S_MD,
+       },
+       { /* I2S SoC Master */
+#ifdef CONFIG_PXA27x
+               .sys = GPIO113_I2S_SYSCLK_MD,
+#else
+               .sys = GPIO32_SYSCLK_I2S_MD,
+#endif
+               .rx = GPIO29_SDATA_IN_I2S_MD,
+               .tx = GPIO30_SDATA_OUT_I2S_MD,
+               .clk = GPIO28_BITCLK_OUT_I2S_MD,
+               .frm = GPIO31_SYNC_I2S_MD,
+       },
+};
+
+static int pxa2xx_i2s_startup(struct snd_pcm_substream *substream)
+{
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_cpu_dai *cpu_dai = rtd->dai->cpu_dai;
+
+       if (!cpu_dai->active) {
+               SACR0 |= SACR0_RST;
+               SACR0 = 0;
+       }
+
+       return 0;
+}
+
+/* wait for I2S controller to be ready */
+static int pxa_i2s_wait(void)
+{
+       int i;
+
+       /* flush the Rx FIFO */
+       for(i = 0; i < 16; i++)
+               SADR;
+       return 0;
+}
+
+static int pxa2xx_i2s_set_dai_fmt(struct snd_soc_cpu_dai *cpu_dai,
+               unsigned int fmt)
+{
+       /* interface format */
+       switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
+       case SND_SOC_DAIFMT_I2S:
+               pxa_i2s.fmt = 0;
+               break;
+       case SND_SOC_DAIFMT_LEFT_J:
+               pxa_i2s.fmt = SACR1_AMSL;
+               break;
+       }
+
+       switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
+       case SND_SOC_DAIFMT_CBS_CFS:
+               pxa_i2s.master = 1;
+               break;
+       case SND_SOC_DAIFMT_CBM_CFS:
+               pxa_i2s.master = 0;
+               break;
+       default:
+               break;
+       }
+       return 0;
+}
+
+static int pxa2xx_i2s_set_dai_sysclk(struct snd_soc_cpu_dai *cpu_dai,
+               int clk_id, unsigned int freq, int dir)
+{
+       if (clk_id != PXA2XX_I2S_SYSCLK)
+               return -ENODEV;
+
+       if (pxa_i2s.master && dir == SND_SOC_CLOCK_OUT)
+               pxa_gpio_mode(gpio_bus[pxa_i2s.master].sys);
+
+       return 0;
+}
+
+static int pxa2xx_i2s_hw_params(struct snd_pcm_substream *substream,
+                               struct snd_pcm_hw_params *params)
+{
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_cpu_dai *cpu_dai = rtd->dai->cpu_dai;
+
+       pxa_gpio_mode(gpio_bus[pxa_i2s.master].rx);
+       pxa_gpio_mode(gpio_bus[pxa_i2s.master].tx);
+       pxa_gpio_mode(gpio_bus[pxa_i2s.master].frm);
+       pxa_gpio_mode(gpio_bus[pxa_i2s.master].clk);
+       pxa_set_cken(CKEN8_I2S, 1);
+       pxa_i2s_wait();
+
+       if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+               cpu_dai->dma_data = &pxa2xx_i2s_pcm_stereo_out;
+       else
+               cpu_dai->dma_data = &pxa2xx_i2s_pcm_stereo_in;
+
+       /* is port used by another stream */
+       if (!(SACR0 & SACR0_ENB)) {
+
+               SACR0 = 0;
+               SACR1 = 0;
+               if (pxa_i2s.master)
+                       SACR0 |= SACR0_BCKD;
+
+               SACR0 |= SACR0_RFTH(14) | SACR0_TFTH(1);
+               SACR1 |= pxa_i2s.fmt;
+       }
+       if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+               SAIMR |= SAIMR_TFS;
+       else
+               SAIMR |= SAIMR_RFS;
+
+       switch (params_rate(params)) {
+       case 8000:
+               SADIV = 0x48;
+               break;
+       case 11025:
+               SADIV = 0x34;
+               break;
+       case 16000:
+               SADIV = 0x24;
+               break;
+       case 22050:
+               SADIV = 0x1a;
+               break;
+       case 44100:
+               SADIV = 0xd;
+               break;
+       case 48000:
+               SADIV = 0xc;
+               break;
+       case 96000: /* not in manual and possibly slightly inaccurate */
+               SADIV = 0x6;
+               break;
+       }
+
+       return 0;
+}
+
+static int pxa2xx_i2s_trigger(struct snd_pcm_substream *substream, int cmd)
+{
+       int ret = 0;
+
+       switch (cmd) {
+       case SNDRV_PCM_TRIGGER_START:
+               SACR0 |= SACR0_ENB;
+               break;
+       case SNDRV_PCM_TRIGGER_RESUME:
+       case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
+       case SNDRV_PCM_TRIGGER_STOP:
+       case SNDRV_PCM_TRIGGER_SUSPEND:
+       case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
+               break;
+       default:
+               ret = -EINVAL;
+       }
+
+       return ret;
+}
+
+static void pxa2xx_i2s_shutdown(struct snd_pcm_substream *substream)
+{
+       if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+               SACR1 |= SACR1_DRPL;
+               SAIMR &= ~SAIMR_TFS;
+       } else {
+               SACR1 |= SACR1_DREC;
+               SAIMR &= ~SAIMR_RFS;
+       }
+
+       if (SACR1 & (SACR1_DREC | SACR1_DRPL)) {
+               SACR0 &= ~SACR0_ENB;
+               pxa_i2s_wait();
+               pxa_set_cken(CKEN8_I2S, 0);
+       }
+}
+
+#ifdef CONFIG_PM
+static int pxa2xx_i2s_suspend(struct platform_device *dev,
+       struct snd_soc_cpu_dai *dai)
+{
+       if (!dai->active)
+               return 0;
+
+       /* store registers */
+       pxa_i2s.sacr0 = SACR0;
+       pxa_i2s.sacr1 = SACR1;
+       pxa_i2s.saimr = SAIMR;
+       pxa_i2s.sadiv = SADIV;
+
+       /* deactivate link */
+       SACR0 &= ~SACR0_ENB;
+       pxa_i2s_wait();
+       return 0;
+}
+
+static int pxa2xx_i2s_resume(struct platform_device *pdev,
+       struct snd_soc_cpu_dai *dai)
+{
+       if (!dai->active)
+               return 0;
+
+       pxa_i2s_wait();
+
+       SACR0 = pxa_i2s.sacr0 &= ~SACR0_ENB;
+       SACR1 = pxa_i2s.sacr1;
+       SAIMR = pxa_i2s.saimr;
+       SADIV = pxa_i2s.sadiv;
+       SACR0 |= SACR0_ENB;
+
+       return 0;
+}
+
+#else
+#define pxa2xx_i2s_suspend     NULL
+#define pxa2xx_i2s_resume      NULL
+#endif
+
+#define PXA2XX_I2S_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\
+               SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_44100 | \
+               SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000)
+
+struct snd_soc_cpu_dai pxa_i2s_dai = {
+       .name = "pxa2xx-i2s",
+       .id = 0,
+       .type = SND_SOC_DAI_I2S,
+       .suspend = pxa2xx_i2s_suspend,
+       .resume = pxa2xx_i2s_resume,
+       .playback = {
+               .channels_min = 2,
+               .channels_max = 2,
+               .rates = PXA2XX_I2S_RATES,
+               .formats = SNDRV_PCM_FMTBIT_S16_LE,},
+       .capture = {
+               .channels_min = 2,
+               .channels_max = 2,
+               .rates = PXA2XX_I2S_RATES,
+               .formats = SNDRV_PCM_FMTBIT_S16_LE,},
+       .ops = {
+               .startup = pxa2xx_i2s_startup,
+               .shutdown = pxa2xx_i2s_shutdown,
+               .trigger = pxa2xx_i2s_trigger,
+               .hw_params = pxa2xx_i2s_hw_params,},
+       .dai_ops = {
+               .set_fmt = pxa2xx_i2s_set_dai_fmt,
+               .set_sysclk = pxa2xx_i2s_set_dai_sysclk,
+       },
+};
+
+EXPORT_SYMBOL_GPL(pxa_i2s_dai);
+
+/* Module information */
+MODULE_AUTHOR("Liam Girdwood, liam.girdwood@wolfsonmicro.com, www.wolfsonmicro.com");
+MODULE_DESCRIPTION("pxa2xx I2S SoC Interface");
+MODULE_LICENSE("GPL");
diff --git a/sound/soc/pxa/pxa2xx-i2s.h b/sound/soc/pxa/pxa2xx-i2s.h
new file mode 100644 (file)
index 0000000..a2484f0
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * linux/sound/arm/pxa2xx-i2s.h
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef _PXA2XX_I2S_H
+#define _PXA2XX_I2S_H
+
+/* pxa2xx DAI ID's */
+#define PXA2XX_DAI_I2S                 0
+
+/* I2S clock */
+#define PXA2XX_I2S_SYSCLK              0
+
+extern struct snd_soc_cpu_dai pxa_i2s_dai;
+
+#endif
diff --git a/sound/soc/pxa/pxa2xx-pcm.c b/sound/soc/pxa/pxa2xx-pcm.c
new file mode 100644 (file)
index 0000000..35e8fa3
--- /dev/null
@@ -0,0 +1,372 @@
+/*
+ * linux/sound/arm/pxa2xx-pcm.c -- ALSA PCM interface for the Intel PXA2xx chip
+ *
+ * Author:     Nicolas Pitre
+ * Created:    Nov 30, 2004
+ * Copyright:  (C) 2004 MontaVista Software, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+#include <linux/dma-mapping.h>
+
+#include <sound/driver.h>
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/pcm_params.h>
+#include <sound/soc.h>
+
+#include <asm/dma.h>
+#include <asm/hardware.h>
+#include <asm/arch/pxa-regs.h>
+#include <asm/arch/audio.h>
+
+#include "pxa2xx-pcm.h"
+
+static const struct snd_pcm_hardware pxa2xx_pcm_hardware = {
+       .info                   = SNDRV_PCM_INFO_MMAP |
+                                 SNDRV_PCM_INFO_MMAP_VALID |
+                                 SNDRV_PCM_INFO_INTERLEAVED |
+                                 SNDRV_PCM_INFO_PAUSE |
+                                 SNDRV_PCM_INFO_RESUME,
+       .formats                = SNDRV_PCM_FMTBIT_S16_LE |
+                                       SNDRV_PCM_FMTBIT_S24_LE |
+                                       SNDRV_PCM_FMTBIT_S32_LE,
+       .period_bytes_min       = 32,
+       .period_bytes_max       = 8192 - 32,
+       .periods_min            = 1,
+       .periods_max            = PAGE_SIZE/sizeof(pxa_dma_desc),
+       .buffer_bytes_max       = 128 * 1024,
+       .fifo_size              = 32,
+};
+
+struct pxa2xx_runtime_data {
+       int dma_ch;
+       struct pxa2xx_pcm_dma_params *params;
+       pxa_dma_desc *dma_desc_array;
+       dma_addr_t dma_desc_array_phys;
+};
+
+static void pxa2xx_pcm_dma_irq(int dma_ch, void *dev_id)
+{
+       struct snd_pcm_substream *substream = dev_id;
+       struct pxa2xx_runtime_data *prtd = substream->runtime->private_data;
+       int dcsr;
+
+       dcsr = DCSR(dma_ch);
+       DCSR(dma_ch) = dcsr & ~DCSR_STOPIRQEN;
+
+       if (dcsr & DCSR_ENDINTR) {
+               snd_pcm_period_elapsed(substream);
+       } else {
+               printk( KERN_ERR "%s: DMA error on channel %d (DCSR=%#x)\n",
+                       prtd->params->name, dma_ch, dcsr );
+       }
+}
+
+static int pxa2xx_pcm_hw_params(struct snd_pcm_substream *substream,
+       struct snd_pcm_hw_params *params)
+{
+       struct snd_pcm_runtime *runtime = substream->runtime;
+       struct pxa2xx_runtime_data *prtd = runtime->private_data;
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct pxa2xx_pcm_dma_params *dma = rtd->dai->cpu_dai->dma_data;
+       size_t totsize = params_buffer_bytes(params);
+       size_t period = params_period_bytes(params);
+       pxa_dma_desc *dma_desc;
+       dma_addr_t dma_buff_phys, next_desc_phys;
+       int ret;
+
+       /* return if this is a bufferless transfer e.g.
+        * codec <--> BT codec or GSM modem -- lg FIXME */
+        if (!dma)
+               return 0;
+
+       /* this may get called several times by oss emulation
+        * with different params */
+       if (prtd->params == NULL) {
+               prtd->params = dma;
+               ret = pxa_request_dma(prtd->params->name, DMA_PRIO_LOW,
+                             pxa2xx_pcm_dma_irq, substream);
+               if (ret < 0)
+                       return ret;
+               prtd->dma_ch = ret;
+       } else if (prtd->params != dma) {
+               pxa_free_dma(prtd->dma_ch);
+               prtd->params = dma;
+               ret = pxa_request_dma(prtd->params->name, DMA_PRIO_LOW,
+                             pxa2xx_pcm_dma_irq, substream);
+               if (ret < 0)
+                       return ret;
+               prtd->dma_ch = ret;
+       }
+
+       snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);
+       runtime->dma_bytes = totsize;
+
+       dma_desc = prtd->dma_desc_array;
+       next_desc_phys = prtd->dma_desc_array_phys;
+       dma_buff_phys = runtime->dma_addr;
+       do {
+               next_desc_phys += sizeof(pxa_dma_desc);
+               dma_desc->ddadr = next_desc_phys;
+               if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+                       dma_desc->dsadr = dma_buff_phys;
+                       dma_desc->dtadr = prtd->params->dev_addr;
+               } else {
+                       dma_desc->dsadr = prtd->params->dev_addr;
+                       dma_desc->dtadr = dma_buff_phys;
+               }
+               if (period > totsize)
+                       period = totsize;
+               dma_desc->dcmd = prtd->params->dcmd | period | DCMD_ENDIRQEN;
+               dma_desc++;
+               dma_buff_phys += period;
+       } while (totsize -= period);
+       dma_desc[-1].ddadr = prtd->dma_desc_array_phys;
+
+       return 0;
+}
+
+static int pxa2xx_pcm_hw_free(struct snd_pcm_substream *substream)
+{
+       struct pxa2xx_runtime_data *prtd = substream->runtime->private_data;
+
+       if (prtd && prtd->params)
+               *prtd->params->drcmr = 0;
+
+       if (prtd->dma_ch) {
+               snd_pcm_set_runtime_buffer(substream, NULL);
+               pxa_free_dma(prtd->dma_ch);
+               prtd->dma_ch = 0;
+       }
+
+       return 0;
+}
+
+static int pxa2xx_pcm_prepare(struct snd_pcm_substream *substream)
+{
+       struct pxa2xx_runtime_data *prtd = substream->runtime->private_data;
+
+       DCSR(prtd->dma_ch) &= ~DCSR_RUN;
+       DCSR(prtd->dma_ch) = 0;
+       DCMD(prtd->dma_ch) = 0;
+       *prtd->params->drcmr = prtd->dma_ch | DRCMR_MAPVLD;
+
+       return 0;
+}
+
+static int pxa2xx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
+{
+       struct pxa2xx_runtime_data *prtd = substream->runtime->private_data;
+       int ret = 0;
+
+       switch (cmd) {
+       case SNDRV_PCM_TRIGGER_START:
+               DDADR(prtd->dma_ch) = prtd->dma_desc_array_phys;
+               DCSR(prtd->dma_ch) = DCSR_RUN;
+               break;
+
+       case SNDRV_PCM_TRIGGER_STOP:
+       case SNDRV_PCM_TRIGGER_SUSPEND:
+       case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
+               DCSR(prtd->dma_ch) &= ~DCSR_RUN;
+               break;
+
+       case SNDRV_PCM_TRIGGER_RESUME:
+               DCSR(prtd->dma_ch) |= DCSR_RUN;
+               break;
+       case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
+               DDADR(prtd->dma_ch) = prtd->dma_desc_array_phys;
+               DCSR(prtd->dma_ch) |= DCSR_RUN;
+               break;
+
+       default:
+               ret = -EINVAL;
+       }
+
+       return ret;
+}
+
+static snd_pcm_uframes_t
+pxa2xx_pcm_pointer(struct snd_pcm_substream *substream)
+{
+       struct snd_pcm_runtime *runtime = substream->runtime;
+       struct pxa2xx_runtime_data *prtd = runtime->private_data;
+
+       dma_addr_t ptr = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ?
+                        DSADR(prtd->dma_ch) : DTADR(prtd->dma_ch);
+       snd_pcm_uframes_t x = bytes_to_frames(runtime, ptr - runtime->dma_addr);
+
+       if (x == runtime->buffer_size)
+               x = 0;
+       return x;
+}
+
+static int pxa2xx_pcm_open(struct snd_pcm_substream *substream)
+{
+       struct snd_pcm_runtime *runtime = substream->runtime;
+       struct pxa2xx_runtime_data *prtd;
+       int ret;
+
+       snd_soc_set_runtime_hwparams(substream, &pxa2xx_pcm_hardware);
+
+       /*
+        * For mysterious reasons (and despite what the manual says)
+        * playback samples are lost if the DMA count is not a multiple
+        * of the DMA burst size.  Let's add a rule to enforce that.
+        */
+       ret = snd_pcm_hw_constraint_step(runtime, 0,
+               SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 32);
+       if (ret)
+               goto out;
+
+       ret = snd_pcm_hw_constraint_step(runtime, 0,
+               SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 32);
+       if (ret)
+               goto out;
+
+       ret = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS);
+       if (ret < 0)
+               goto out;
+
+       prtd = kzalloc(sizeof(struct pxa2xx_runtime_data), GFP_KERNEL);
+       if (prtd == NULL) {
+               ret = -ENOMEM;
+               goto out;
+       }
+
+       prtd->dma_desc_array =
+               dma_alloc_writecombine(substream->pcm->card->dev, PAGE_SIZE,
+                                      &prtd->dma_desc_array_phys, GFP_KERNEL);
+       if (!prtd->dma_desc_array) {
+               ret = -ENOMEM;
+               goto err1;
+       }
+
+       runtime->private_data = prtd;
+       return 0;
+
+ err1:
+       kfree(prtd);
+ out:
+       return ret;
+}
+
+static int pxa2xx_pcm_close(struct snd_pcm_substream *substream)
+{
+       struct snd_pcm_runtime *runtime = substream->runtime;
+       struct pxa2xx_runtime_data *prtd = runtime->private_data;
+
+       dma_free_writecombine(substream->pcm->card->dev, PAGE_SIZE,
+                             prtd->dma_desc_array, prtd->dma_desc_array_phys);
+       kfree(prtd);
+       return 0;
+}
+
+static int pxa2xx_pcm_mmap(struct snd_pcm_substream *substream,
+       struct vm_area_struct *vma)
+{
+       struct snd_pcm_runtime *runtime = substream->runtime;
+       return dma_mmap_writecombine(substream->pcm->card->dev, vma,
+                                    runtime->dma_area,
+                                    runtime->dma_addr,
+                                    runtime->dma_bytes);
+}
+
+struct snd_pcm_ops pxa2xx_pcm_ops = {
+       .open           = pxa2xx_pcm_open,
+       .close          = pxa2xx_pcm_close,
+       .ioctl          = snd_pcm_lib_ioctl,
+       .hw_params      = pxa2xx_pcm_hw_params,
+       .hw_free        = pxa2xx_pcm_hw_free,
+       .prepare        = pxa2xx_pcm_prepare,
+       .trigger        = pxa2xx_pcm_trigger,
+       .pointer        = pxa2xx_pcm_pointer,
+       .mmap           = pxa2xx_pcm_mmap,
+};
+
+static int pxa2xx_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream)
+{
+       struct snd_pcm_substream *substream = pcm->streams[stream].substream;
+       struct snd_dma_buffer *buf = &substream->dma_buffer;
+       size_t size = pxa2xx_pcm_hardware.buffer_bytes_max;
+       buf->dev.type = SNDRV_DMA_TYPE_DEV;
+       buf->dev.dev = pcm->card->dev;
+       buf->private_data = NULL;
+       buf->area = dma_alloc_writecombine(pcm->card->dev, size,
+                                          &buf->addr, GFP_KERNEL);
+       if (!buf->area)
+               return -ENOMEM;
+       buf->bytes = size;
+       return 0;
+}
+
+static void pxa2xx_pcm_free_dma_buffers(struct snd_pcm *pcm)
+{
+       struct snd_pcm_substream *substream;
+       struct snd_dma_buffer *buf;
+       int stream;
+
+       for (stream = 0; stream < 2; stream++) {
+               substream = pcm->streams[stream].substream;
+               if (!substream)
+                       continue;
+
+               buf = &substream->dma_buffer;
+               if (!buf->area)
+                       continue;
+
+               dma_free_writecombine(pcm->card->dev, buf->bytes,
+                                     buf->area, buf->addr);
+               buf->area = NULL;
+       }
+}
+
+static u64 pxa2xx_pcm_dmamask = DMA_32BIT_MASK;
+
+int pxa2xx_pcm_new(struct snd_card *card, struct snd_soc_codec_dai *dai,
+       struct snd_pcm *pcm)
+{
+       int ret = 0;
+
+       if (!card->dev->dma_mask)
+               card->dev->dma_mask = &pxa2xx_pcm_dmamask;
+       if (!card->dev->coherent_dma_mask)
+               card->dev->coherent_dma_mask = DMA_32BIT_MASK;
+
+       if (dai->playback.channels_min) {
+               ret = pxa2xx_pcm_preallocate_dma_buffer(pcm,
+                       SNDRV_PCM_STREAM_PLAYBACK);
+               if (ret)
+                       goto out;
+       }
+
+       if (dai->capture.channels_min) {
+               ret = pxa2xx_pcm_preallocate_dma_buffer(pcm,
+                       SNDRV_PCM_STREAM_CAPTURE);
+               if (ret)
+                       goto out;
+       }
+ out:
+       return ret;
+}
+
+struct snd_soc_platform pxa2xx_soc_platform = {
+       .name           = "pxa2xx-audio",
+       .pcm_ops        = &pxa2xx_pcm_ops,
+       .pcm_new        = pxa2xx_pcm_new,
+       .pcm_free       = pxa2xx_pcm_free_dma_buffers,
+};
+
+EXPORT_SYMBOL_GPL(pxa2xx_soc_platform);
+
+MODULE_AUTHOR("Nicolas Pitre");
+MODULE_DESCRIPTION("Intel PXA2xx PCM DMA module");
+MODULE_LICENSE("GPL");
diff --git a/sound/soc/pxa/pxa2xx-pcm.h b/sound/soc/pxa/pxa2xx-pcm.h
new file mode 100644 (file)
index 0000000..54c9c75
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * linux/sound/arm/pxa2xx-pcm.h -- ALSA PCM interface for the Intel PXA2xx chip
+ *
+ * Author:     Nicolas Pitre
+ * Created:    Nov 30, 2004
+ * Copyright:  MontaVista Software, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef _PXA2XX_PCM_H
+#define _PXA2XX_PCM_H
+
+struct pxa2xx_pcm_dma_params {
+       char *name;                     /* stream identifier */
+       u32 dcmd;                       /* DMA descriptor dcmd field */
+       volatile u32 *drcmr;            /* the DMA request channel to use */
+       u32 dev_addr;                   /* device physical address for DMA */
+};
+
+struct pxa2xx_gpio {
+       u32 sys;
+       u32     rx;
+       u32 tx;
+       u32 clk;
+       u32 frm;
+};
+
+/* platform data */
+extern struct snd_soc_platform pxa2xx_soc_platform;
+
+#endif
diff --git a/sound/soc/pxa/spitz.c b/sound/soc/pxa/spitz.c
new file mode 100644 (file)
index 0000000..80e8210
--- /dev/null
@@ -0,0 +1,394 @@
+/*
+ * spitz.c  --  SoC audio for Sharp SL-Cxx00 models Spitz, Borzoi and Akita
+ *
+ * Copyright 2005 Wolfson Microelectronics PLC.
+ * Copyright 2005 Openedhand Ltd.
+ *
+ * Authors: Liam Girdwood <liam.girdwood@wolfsonmicro.com>
+ *          Richard Purdie <richard@openedhand.com>
+ *
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ *
+ *  Revision history
+ *    30th Nov 2005   Initial version.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/timer.h>
+#include <linux/interrupt.h>
+#include <linux/platform_device.h>
+#include <sound/driver.h>
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/soc.h>
+#include <sound/soc-dapm.h>
+
+#include <asm/mach-types.h>
+#include <asm/hardware/scoop.h>
+#include <asm/arch/pxa-regs.h>
+#include <asm/arch/hardware.h>
+#include <asm/arch/akita.h>
+#include <asm/arch/spitz.h>
+#include <asm/mach-types.h>
+#include "../codecs/wm8750.h"
+#include "pxa2xx-pcm.h"
+#include "pxa2xx-i2s.h"
+
+#define SPITZ_HP        0
+#define SPITZ_MIC       1
+#define SPITZ_LINE      2
+#define SPITZ_HEADSET   3
+#define SPITZ_HP_OFF    4
+#define SPITZ_SPK_ON    0
+#define SPITZ_SPK_OFF   1
+
+ /* audio clock in Hz - rounded from 12.235MHz */
+#define SPITZ_AUDIO_CLOCK 12288000
+
+static int spitz_jack_func;
+static int spitz_spk_func;
+
+static void spitz_ext_control(struct snd_soc_codec *codec)
+{
+       if (spitz_spk_func == SPITZ_SPK_ON)
+               snd_soc_dapm_set_endpoint(codec, "Ext Spk", 1);
+       else
+               snd_soc_dapm_set_endpoint(codec, "Ext Spk", 0);
+
+       /* set up jack connection */
+       switch (spitz_jack_func) {
+       case SPITZ_HP:
+               /* enable and unmute hp jack, disable mic bias */
+               snd_soc_dapm_set_endpoint(codec, "Headset Jack", 0);
+               snd_soc_dapm_set_endpoint(codec, "Mic Jack", 0);
+               snd_soc_dapm_set_endpoint(codec, "Line Jack", 0);
+               snd_soc_dapm_set_endpoint(codec, "Headphone Jack", 1);
+               set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_MUTE_L);
+               set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_MUTE_R);
+               break;
+       case SPITZ_MIC:
+               /* enable mic jack and bias, mute hp */
+               snd_soc_dapm_set_endpoint(codec, "Headphone Jack", 0);
+               snd_soc_dapm_set_endpoint(codec, "Headset Jack", 0);
+               snd_soc_dapm_set_endpoint(codec, "Line Jack", 0);
+               snd_soc_dapm_set_endpoint(codec, "Mic Jack", 1);
+               reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_MUTE_L);
+               reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_MUTE_R);
+               break;
+       case SPITZ_LINE:
+               /* enable line jack, disable mic bias and mute hp */
+               snd_soc_dapm_set_endpoint(codec, "Headphone Jack", 0);
+               snd_soc_dapm_set_endpoint(codec, "Headset Jack", 0);
+               snd_soc_dapm_set_endpoint(codec, "Mic Jack", 0);
+               snd_soc_dapm_set_endpoint(codec, "Line Jack", 1);
+               reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_MUTE_L);
+               reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_MUTE_R);
+               break;
+       case SPITZ_HEADSET:
+               /* enable and unmute headset jack enable mic bias, mute L hp */
+               snd_soc_dapm_set_endpoint(codec, "Headphone Jack", 0);
+               snd_soc_dapm_set_endpoint(codec, "Mic Jack", 1);
+               snd_soc_dapm_set_endpoint(codec, "Line Jack", 0);
+               snd_soc_dapm_set_endpoint(codec, "Headset Jack", 1);
+               reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_MUTE_L);
+               set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_MUTE_R);
+               break;
+       case SPITZ_HP_OFF:
+
+               /* jack removed, everything off */
+               snd_soc_dapm_set_endpoint(codec, "Headphone Jack", 0);
+               snd_soc_dapm_set_endpoint(codec, "Headset Jack", 0);
+               snd_soc_dapm_set_endpoint(codec, "Mic Jack", 0);
+               snd_soc_dapm_set_endpoint(codec, "Line Jack", 0);
+               reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_MUTE_L);
+               reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_MUTE_R);
+               break;
+       }
+       snd_soc_dapm_sync_endpoints(codec);
+}
+
+static int spitz_startup(struct snd_pcm_substream *substream)
+{
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_codec *codec = rtd->socdev->codec;
+
+       /* check the jack status at stream startup */
+       spitz_ext_control(codec);
+       return 0;
+}
+
+static int spitz_hw_params(struct snd_pcm_substream *substream,
+       struct snd_pcm_hw_params *params)
+{
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_codec_dai *codec_dai = rtd->dai->codec_dai;
+       struct snd_soc_cpu_dai *cpu_dai = rtd->dai->cpu_dai;
+       unsigned int clk = 0;
+       int ret = 0;
+
+       switch (params_rate(params)) {
+       case 8000:
+       case 16000:
+       case 48000:
+       case 96000:
+               clk = 12288000;
+               break;
+       case 11025:
+       case 22050:
+       case 44100:
+               clk = 11289600;
+               break;
+       }
+
+       /* set codec DAI configuration */
+       ret = codec_dai->dai_ops.set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
+               SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
+       if (ret < 0)
+               return ret;
+
+       /* set cpu DAI configuration */
+       ret = cpu_dai->dai_ops.set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
+               SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
+       if (ret < 0)
+               return ret;
+
+       /* set the codec system clock for DAC and ADC */
+       ret = codec_dai->dai_ops.set_sysclk(codec_dai, WM8750_SYSCLK, clk,
+               SND_SOC_CLOCK_IN);
+       if (ret < 0)
+               return ret;
+
+       /* set the I2S system clock as input (unused) */
+       ret = cpu_dai->dai_ops.set_sysclk(cpu_dai, PXA2XX_I2S_SYSCLK, 0,
+               SND_SOC_CLOCK_IN);
+       if (ret < 0)
+               return ret;
+
+       return 0;
+}
+
+static struct snd_soc_ops spitz_ops = {
+       .startup = spitz_startup,
+       .hw_params = spitz_hw_params,
+};
+
+static int spitz_get_jack(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_value *ucontrol)
+{
+       ucontrol->value.integer.value[0] = spitz_jack_func;
+       return 0;
+}
+
+static int spitz_set_jack(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+
+       if (spitz_jack_func == ucontrol->value.integer.value[0])
+               return 0;
+
+       spitz_jack_func = ucontrol->value.integer.value[0];
+       spitz_ext_control(codec);
+       return 1;
+}
+
+static int spitz_get_spk(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_value *ucontrol)
+{
+       ucontrol->value.integer.value[0] = spitz_spk_func;
+       return 0;
+}
+
+static int spitz_set_spk(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_soc_codec *codec =  snd_kcontrol_chip(kcontrol);
+
+       if (spitz_spk_func == ucontrol->value.integer.value[0])
+               return 0;
+
+       spitz_spk_func = ucontrol->value.integer.value[0];
+       spitz_ext_control(codec);
+       return 1;
+}
+
+static int spitz_mic_bias(struct snd_soc_dapm_widget *w, int event)
+{
+       if (machine_is_borzoi() || machine_is_spitz()) {
+               if (SND_SOC_DAPM_EVENT_ON(event))
+                       set_scoop_gpio(&spitzscoop2_device.dev,
+                               SPITZ_SCP2_MIC_BIAS);
+               else
+                       reset_scoop_gpio(&spitzscoop2_device.dev,
+                               SPITZ_SCP2_MIC_BIAS);
+       }
+
+       if (machine_is_akita()) {
+               if (SND_SOC_DAPM_EVENT_ON(event))
+                       akita_set_ioexp(&akitaioexp_device.dev,
+                               AKITA_IOEXP_MIC_BIAS);
+               else
+                       akita_reset_ioexp(&akitaioexp_device.dev,
+                               AKITA_IOEXP_MIC_BIAS);
+       }
+       return 0;
+}
+
+/* spitz machine dapm widgets */
+static const struct snd_soc_dapm_widget wm8750_dapm_widgets[] = {
+       SND_SOC_DAPM_HP("Headphone Jack", NULL),
+       SND_SOC_DAPM_MIC("Mic Jack", spitz_mic_bias),
+       SND_SOC_DAPM_SPK("Ext Spk", NULL),
+       SND_SOC_DAPM_LINE("Line Jack", NULL),
+
+       /* headset is a mic and mono headphone */
+       SND_SOC_DAPM_HP("Headset Jack", NULL),
+};
+
+/* Spitz machine audio_map */
+static const char *audio_map[][3] = {
+
+       /* headphone connected to LOUT1, ROUT1 */
+       {"Headphone Jack", NULL, "LOUT1"},
+       {"Headphone Jack", NULL, "ROUT1"},
+
+       /* headset connected to ROUT1 and LINPUT1 with bias (def below) */
+       {"Headset Jack", NULL, "ROUT1"},
+
+       /* ext speaker connected to LOUT2, ROUT2  */
+       {"Ext Spk", NULL , "ROUT2"},
+       {"Ext Spk", NULL , "LOUT2"},
+
+       /* mic is connected to input 1 - with bias */
+       {"LINPUT1", NULL, "Mic Bias"},
+       {"Mic Bias", NULL, "Mic Jack"},
+
+       /* line is connected to input 1 - no bias */
+       {"LINPUT1", NULL, "Line Jack"},
+
+       {NULL, NULL, NULL},
+};
+
+static const char *jack_function[] = {"Headphone", "Mic", "Line", "Headset",
+       "Off"};
+static const char *spk_function[] = {"On", "Off"};
+static const struct soc_enum spitz_enum[] = {
+       SOC_ENUM_SINGLE_EXT(5, jack_function),
+       SOC_ENUM_SINGLE_EXT(2, spk_function),
+};
+
+static const struct snd_kcontrol_new wm8750_spitz_controls[] = {
+       SOC_ENUM_EXT("Jack Function", spitz_enum[0], spitz_get_jack,
+               spitz_set_jack),
+       SOC_ENUM_EXT("Speaker Function", spitz_enum[1], spitz_get_spk,
+               spitz_set_spk),
+};
+
+/*
+ * Logic for a wm8750 as connected on a Sharp SL-Cxx00 Device
+ */
+static int spitz_wm8750_init(struct snd_soc_codec *codec)
+{
+       int i, err;
+
+       /* NC codec pins */
+       snd_soc_dapm_set_endpoint(codec, "RINPUT1", 0);
+       snd_soc_dapm_set_endpoint(codec, "LINPUT2", 0);
+       snd_soc_dapm_set_endpoint(codec, "RINPUT2", 0);
+       snd_soc_dapm_set_endpoint(codec, "LINPUT3", 0);
+       snd_soc_dapm_set_endpoint(codec, "RINPUT3", 0);
+       snd_soc_dapm_set_endpoint(codec, "OUT3", 0);
+       snd_soc_dapm_set_endpoint(codec, "MONO", 0);
+
+       /* Add spitz specific controls */
+       for (i = 0; i < ARRAY_SIZE(wm8750_spitz_controls); i++) {
+               err = snd_ctl_add(codec->card,
+                       snd_soc_cnew(&wm8750_spitz_controls[i], codec, NULL));
+               if (err < 0)
+                       return err;
+       }
+
+       /* Add spitz specific widgets */
+       for (i = 0; i < ARRAY_SIZE(wm8750_dapm_widgets); i++) {
+               snd_soc_dapm_new_control(codec, &wm8750_dapm_widgets[i]);
+       }
+
+       /* Set up spitz specific audio path audio_map */
+       for (i = 0; audio_map[i][0] != NULL; i++) {
+               snd_soc_dapm_connect_input(codec, audio_map[i][0],
+                       audio_map[i][1], audio_map[i][2]);
+       }
+
+       snd_soc_dapm_sync_endpoints(codec);
+       return 0;
+}
+
+/* spitz digital audio interface glue - connects codec <--> CPU */
+static struct snd_soc_dai_link spitz_dai = {
+       .name = "wm8750",
+       .stream_name = "WM8750",
+       .cpu_dai = &pxa_i2s_dai,
+       .codec_dai = &wm8750_dai,
+       .init = spitz_wm8750_init,
+       .ops = &spitz_ops,
+};
+
+/* spitz audio machine driver */
+static struct snd_soc_machine snd_soc_machine_spitz = {
+       .name = "Spitz",
+       .dai_link = &spitz_dai,
+       .num_links = 1,
+};
+
+/* spitz audio private data */
+static struct wm8750_setup_data spitz_wm8750_setup = {
+       .i2c_address = 0x1b,
+};
+
+/* spitz audio subsystem */
+static struct snd_soc_device spitz_snd_devdata = {
+       .machine = &snd_soc_machine_spitz,
+       .platform = &pxa2xx_soc_platform,
+       .codec_dev = &soc_codec_dev_wm8750,
+       .codec_data = &spitz_wm8750_setup,
+};
+
+static struct platform_device *spitz_snd_device;
+
+static int __init spitz_init(void)
+{
+       int ret;
+
+       if (!(machine_is_spitz() || machine_is_borzoi() || machine_is_akita()))
+               return -ENODEV;
+
+       spitz_snd_device = platform_device_alloc("soc-audio", -1);
+       if (!spitz_snd_device)
+               return -ENOMEM;
+
+       platform_set_drvdata(spitz_snd_device, &spitz_snd_devdata);
+       spitz_snd_devdata.dev = &spitz_snd_device->dev;
+       ret = platform_device_add(spitz_snd_device);
+
+       if (ret)
+               platform_device_put(spitz_snd_device);
+
+       return ret;
+}
+
+static void __exit spitz_exit(void)
+{
+       platform_device_unregister(spitz_snd_device);
+}
+
+module_init(spitz_init);
+module_exit(spitz_exit);
+
+MODULE_AUTHOR("Richard Purdie");
+MODULE_DESCRIPTION("ALSA SoC Spitz");
+MODULE_LICENSE("GPL");
diff --git a/sound/soc/pxa/tosa.c b/sound/soc/pxa/tosa.c
new file mode 100644 (file)
index 0000000..5504e30
--- /dev/null
@@ -0,0 +1,289 @@
+/*
+ * tosa.c  --  SoC audio for Tosa
+ *
+ * Copyright 2005 Wolfson Microelectronics PLC.
+ * Copyright 2005 Openedhand Ltd.
+ *
+ * Authors: Liam Girdwood <liam.girdwood@wolfsonmicro.com>
+ *          Richard Purdie <richard@openedhand.com>
+ *
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ *
+ *  Revision history
+ *    30th Nov 2005   Initial version.
+ *
+ * GPIO's
+ *  1 - Jack Insertion
+ *  5 - Hookswitch (headset answer/hang up switch)
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/device.h>
+
+#include <sound/driver.h>
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/soc.h>
+#include <sound/soc-dapm.h>
+
+#include <asm/mach-types.h>
+#include <asm/hardware/tmio.h>
+#include <asm/arch/pxa-regs.h>
+#include <asm/arch/hardware.h>
+#include <asm/arch/audio.h>
+#include <asm/arch/tosa.h>
+
+#include "../codecs/wm9712.h"
+#include "pxa2xx-pcm.h"
+#include "pxa2xx-ac97.h"
+
+static struct snd_soc_machine tosa;
+
+#define TOSA_HP        0
+#define TOSA_MIC_INT   1
+#define TOSA_HEADSET   2
+#define TOSA_HP_OFF    3
+#define TOSA_SPK_ON    0
+#define TOSA_SPK_OFF   1
+
+static int tosa_jack_func;
+static int tosa_spk_func;
+
+static void tosa_ext_control(struct snd_soc_codec *codec)
+{
+       int spk = 0, mic_int = 0, hp = 0, hs = 0;
+
+       /* set up jack connection */
+       switch (tosa_jack_func) {
+       case TOSA_HP:
+               hp = 1;
+               break;
+       case TOSA_MIC_INT:
+               mic_int = 1;
+               break;
+       case TOSA_HEADSET:
+               hs = 1;
+               break;
+       }
+
+       if (tosa_spk_func == TOSA_SPK_ON)
+               spk = 1;
+
+       snd_soc_dapm_set_endpoint(codec, "Speaker", spk);
+       snd_soc_dapm_set_endpoint(codec, "Mic (Internal)", mic_int);
+       snd_soc_dapm_set_endpoint(codec, "Headphone Jack", hp);
+       snd_soc_dapm_set_endpoint(codec, "Headset Jack", hs);
+       snd_soc_dapm_sync_endpoints(codec);
+}
+
+static int tosa_startup(struct snd_pcm_substream *substream)
+{
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_codec *codec = rtd->socdev->codec;
+
+       /* check the jack status at stream startup */
+       tosa_ext_control(codec);
+       return 0;
+}
+
+static struct snd_soc_ops tosa_ops = {
+       .startup = tosa_startup,
+};
+
+static int tosa_get_jack(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_value *ucontrol)
+{
+       ucontrol->value.integer.value[0] = tosa_jack_func;
+       return 0;
+}
+
+static int tosa_set_jack(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_soc_codec *codec =  snd_kcontrol_chip(kcontrol);
+
+       if (tosa_jack_func == ucontrol->value.integer.value[0])
+               return 0;
+
+       tosa_jack_func = ucontrol->value.integer.value[0];
+       tosa_ext_control(codec);
+       return 1;
+}
+
+static int tosa_get_spk(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_value *ucontrol)
+{
+       ucontrol->value.integer.value[0] = tosa_spk_func;
+       return 0;
+}
+
+static int tosa_set_spk(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_soc_codec *codec =  snd_kcontrol_chip(kcontrol);
+
+       if (tosa_spk_func == ucontrol->value.integer.value[0])
+               return 0;
+
+       tosa_spk_func = ucontrol->value.integer.value[0];
+       tosa_ext_control(codec);
+       return 1;
+}
+
+/* tosa dapm event handlers */
+static int tosa_hp_event(struct snd_soc_dapm_widget *w, int event)
+{
+       if (SND_SOC_DAPM_EVENT_ON(event))
+               set_tc6393_gpio(&tc6393_device.dev,TOSA_TC6393_L_MUTE);
+       else
+               reset_tc6393_gpio(&tc6393_device.dev,TOSA_TC6393_L_MUTE);
+       return 0;
+}
+
+/* tosa machine dapm widgets */
+static const struct snd_soc_dapm_widget tosa_dapm_widgets[] = {
+SND_SOC_DAPM_HP("Headphone Jack", tosa_hp_event),
+SND_SOC_DAPM_HP("Headset Jack", NULL),
+SND_SOC_DAPM_MIC("Mic (Internal)", NULL),
+SND_SOC_DAPM_SPK("Speaker", NULL),
+};
+
+/* tosa audio map */
+static const char *audio_map[][3] = {
+
+       /* headphone connected to HPOUTL, HPOUTR */
+       {"Headphone Jack", NULL, "HPOUTL"},
+       {"Headphone Jack", NULL, "HPOUTR"},
+
+       /* ext speaker connected to LOUT2, ROUT2 */
+       {"Speaker", NULL, "LOUT2"},
+       {"Speaker", NULL, "ROUT2"},
+
+       /* internal mic is connected to mic1, mic2 differential - with bias */
+       {"MIC1", NULL, "Mic Bias"},
+       {"MIC2", NULL, "Mic Bias"},
+       {"Mic Bias", NULL, "Mic (Internal)"},
+
+       /* headset is connected to HPOUTR, and LINEINR with bias */
+       {"Headset Jack", NULL, "HPOUTR"},
+       {"LINEINR", NULL, "Mic Bias"},
+       {"Mic Bias", NULL, "Headset Jack"},
+
+       {NULL, NULL, NULL},
+};
+
+static const char *jack_function[] = {"Headphone", "Mic", "Line", "Headset",
+       "Off"};
+static const char *spk_function[] = {"On", "Off"};
+static const struct soc_enum tosa_enum[] = {
+       SOC_ENUM_SINGLE_EXT(5, jack_function),
+       SOC_ENUM_SINGLE_EXT(2, spk_function),
+};
+
+static const struct snd_kcontrol_new tosa_controls[] = {
+       SOC_ENUM_EXT("Jack Function", tosa_enum[0], tosa_get_jack,
+               tosa_set_jack),
+       SOC_ENUM_EXT("Speaker Function", tosa_enum[1], tosa_get_spk,
+               tosa_set_spk),
+};
+
+static int tosa_ac97_init(struct snd_soc_codec *codec)
+{
+       int i, err;
+
+       snd_soc_dapm_set_endpoint(codec, "OUT3", 0);
+       snd_soc_dapm_set_endpoint(codec, "MONOOUT", 0);
+
+       /* add tosa specific controls */
+       for (i = 0; i < ARRAY_SIZE(tosa_controls); i++) {
+               err = snd_ctl_add(codec->card,
+                               snd_soc_cnew(&tosa_controls[i],codec, NULL));
+               if (err < 0)
+                       return err;
+       }
+
+       /* add tosa specific widgets */
+       for (i = 0; i < ARRAY_SIZE(tosa_dapm_widgets); i++) {
+               snd_soc_dapm_new_control(codec, &tosa_dapm_widgets[i]);
+       }
+
+       /* set up tosa specific audio path audio_map */
+       for (i = 0; audio_map[i][0] != NULL; i++) {
+               snd_soc_dapm_connect_input(codec, audio_map[i][0],
+                       audio_map[i][1], audio_map[i][2]);
+       }
+
+       snd_soc_dapm_sync_endpoints(codec);
+       return 0;
+}
+
+static struct snd_soc_dai_link tosa_dai[] = {
+{
+       .name = "AC97",
+       .stream_name = "AC97 HiFi",
+       .cpu_dai = &pxa_ac97_dai[PXA2XX_DAI_AC97_HIFI],
+       .codec_dai = &wm9712_dai[WM9712_DAI_AC97_HIFI],
+       .init = tosa_ac97_init,
+       .ops = &tosa_ops,
+},
+{
+       .name = "AC97 Aux",
+       .stream_name = "AC97 Aux",
+       .cpu_dai = &pxa_ac97_dai[PXA2XX_DAI_AC97_AUX],
+       .codec_dai = &wm9712_dai[WM9712_DAI_AC97_AUX],
+       .ops = &tosa_ops,
+},
+};
+
+static struct snd_soc_machine tosa = {
+       .name = "Tosa",
+       .dai_link = tosa_dai,
+       .num_links = ARRAY_SIZE(tosa_dai),
+};
+
+static struct snd_soc_device tosa_snd_devdata = {
+       .machine = &tosa,
+       .platform = &pxa2xx_soc_platform,
+       .codec_dev = &soc_codec_dev_wm9712,
+};
+
+static struct platform_device *tosa_snd_device;
+
+static int __init tosa_init(void)
+{
+       int ret;
+
+       if (!machine_is_tosa())
+               return -ENODEV;
+
+       tosa_snd_device = platform_device_alloc("soc-audio", -1);
+       if (!tosa_snd_device)
+               return -ENOMEM;
+
+       platform_set_drvdata(tosa_snd_device, &tosa_snd_devdata);
+       tosa_snd_devdata.dev = &tosa_snd_device->dev;
+       ret = platform_device_add(tosa_snd_device);
+
+       if (ret)
+               platform_device_put(tosa_snd_device);
+
+       return ret;
+}
+
+static void __exit tosa_exit(void)
+{
+       platform_device_unregister(tosa_snd_device);
+}
+
+module_init(tosa_init);
+module_exit(tosa_exit);
+
+/* Module information */
+MODULE_AUTHOR("Richard Purdie");
+MODULE_DESCRIPTION("ALSA SoC Tosa");
+MODULE_LICENSE("GPL");
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
new file mode 100644 (file)
index 0000000..36519ae
--- /dev/null
@@ -0,0 +1,1587 @@
+/*
+ * soc-core.c  --  ALSA SoC Audio Layer
+ *
+ * Copyright 2005 Wolfson Microelectronics PLC.
+ * Copyright 2005 Openedhand Ltd.
+ *
+ * Author: Liam Girdwood
+ *         liam.girdwood@wolfsonmicro.com or linux@wolfsonmicro.com
+ *         with code, comments and ideas from :-
+ *         Richard Purdie <richard@openedhand.com>
+ *
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ *
+ *  Revision history
+ *    12th Aug 2005   Initial version.
+ *    25th Oct 2005   Working Codec, Interface and Platform registration.
+ *
+ *  TODO:
+ *   o Add hw rules to enforce rates, etc.
+ *   o More testing with other codecs/machines.
+ *   o Add more codecs and platforms to ensure good API coverage.
+ *   o Support TDM on PCM and I2S
+ */
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/init.h>
+#include <linux/delay.h>
+#include <linux/pm.h>
+#include <linux/bitops.h>
+#include <linux/platform_device.h>
+#include <sound/driver.h>
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/pcm_params.h>
+#include <sound/soc.h>
+#include <sound/soc-dapm.h>
+#include <sound/initval.h>
+
+/* debug */
+#define SOC_DEBUG 0
+#if SOC_DEBUG
+#define dbg(format, arg...) printk(format, ## arg)
+#else
+#define dbg(format, arg...)
+#endif
+
+static DEFINE_MUTEX(pcm_mutex);
+static DEFINE_MUTEX(io_mutex);
+static DECLARE_WAIT_QUEUE_HEAD(soc_pm_waitq);
+
+/*
+ * This is a timeout to do a DAPM powerdown after a stream is closed().
+ * It can be used to eliminate pops between different playback streams, e.g.
+ * between two audio tracks.
+ */
+static int pmdown_time = 5000;
+module_param(pmdown_time, int, 0);
+MODULE_PARM_DESC(pmdown_time, "DAPM stream powerdown time (msecs)");
+
+/*
+ * This function forces any delayed work to be queued and run.
+ */
+static int run_delayed_work(struct delayed_work *dwork)
+{
+       int ret;
+
+       /* cancel any work waiting to be queued. */
+       ret = cancel_delayed_work(dwork);
+
+       /* if there was any work waiting then we run it now and
+        * wait for it's completion */
+       if (ret) {
+               schedule_delayed_work(dwork, 0);
+               flush_scheduled_work();
+       }
+       return ret;
+}
+
+#ifdef CONFIG_SND_SOC_AC97_BUS
+/* unregister ac97 codec */
+static int soc_ac97_dev_unregister(struct snd_soc_codec *codec)
+{
+       if (codec->ac97->dev.bus)
+               device_unregister(&codec->ac97->dev);
+       return 0;
+}
+
+/* stop no dev release warning */
+static void soc_ac97_device_release(struct device *dev){}
+
+/* register ac97 codec to bus */
+static int soc_ac97_dev_register(struct snd_soc_codec *codec)
+{
+       int err;
+
+       codec->ac97->dev.bus = &ac97_bus_type;
+       codec->ac97->dev.parent = NULL;
+       codec->ac97->dev.release = soc_ac97_device_release;
+
+       snprintf(codec->ac97->dev.bus_id, BUS_ID_SIZE, "%d-%d:%s",
+                codec->card->number, 0, codec->name);
+       err = device_register(&codec->ac97->dev);
+       if (err < 0) {
+               snd_printk(KERN_ERR "Can't register ac97 bus\n");
+               codec->ac97->dev.bus = NULL;
+               return err;
+       }
+       return 0;
+}
+#endif
+
+static inline const char* get_dai_name(int type)
+{
+       switch(type) {
+       case SND_SOC_DAI_AC97:
+               return "AC97";
+       case SND_SOC_DAI_I2S:
+               return "I2S";
+       case SND_SOC_DAI_PCM:
+               return "PCM";
+       }
+       return NULL;
+}
+
+/*
+ * Called by ALSA when a PCM substream is opened, the runtime->hw record is
+ * then initialized and any private data can be allocated. This also calls
+ * startup for the cpu DAI, platform, machine and codec DAI.
+ */
+static int soc_pcm_open(struct snd_pcm_substream *substream)
+{
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_device *socdev = rtd->socdev;
+       struct snd_pcm_runtime *runtime = substream->runtime;
+       struct snd_soc_dai_link *machine = rtd->dai;
+       struct snd_soc_platform *platform = socdev->platform;
+       struct snd_soc_cpu_dai *cpu_dai = machine->cpu_dai;
+       struct snd_soc_codec_dai *codec_dai = machine->codec_dai;
+       int ret = 0;
+
+       mutex_lock(&pcm_mutex);
+
+       /* startup the audio subsystem */
+       if (cpu_dai->ops.startup) {
+               ret = cpu_dai->ops.startup(substream);
+               if (ret < 0) {
+                       printk(KERN_ERR "asoc: can't open interface %s\n",
+                               cpu_dai->name);
+                       goto out;
+               }
+       }
+
+       if (platform->pcm_ops->open) {
+               ret = platform->pcm_ops->open(substream);
+               if (ret < 0) {
+                       printk(KERN_ERR "asoc: can't open platform %s\n", platform->name);
+                       goto platform_err;
+               }
+       }
+
+       if (codec_dai->ops.startup) {
+               ret = codec_dai->ops.startup(substream);
+               if (ret < 0) {
+                       printk(KERN_ERR "asoc: can't open codec %s\n",
+                               codec_dai->name);
+                       goto codec_dai_err;
+               }
+       }
+
+       if (machine->ops && machine->ops->startup) {
+               ret = machine->ops->startup(substream);
+               if (ret < 0) {
+                       printk(KERN_ERR "asoc: %s startup failed\n", machine->name);
+                       goto machine_err;
+               }
+       }
+
+       /* Check that the codec and cpu DAI's are compatible */
+       if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+               runtime->hw.rate_min =
+                       max(codec_dai->playback.rate_min, cpu_dai->playback.rate_min);
+               runtime->hw.rate_max =
+                       min(codec_dai->playback.rate_max, cpu_dai->playback.rate_max);
+               runtime->hw.channels_min =
+                       max(codec_dai->playback.channels_min,
+                               cpu_dai->playback.channels_min);
+               runtime->hw.channels_max =
+                       min(codec_dai->playback.channels_max,
+                               cpu_dai->playback.channels_max);
+               runtime->hw.formats =
+                       codec_dai->playback.formats & cpu_dai->playback.formats;
+               runtime->hw.rates =
+                       codec_dai->playback.rates & cpu_dai->playback.rates;
+       } else {
+               runtime->hw.rate_min =
+                       max(codec_dai->capture.rate_min, cpu_dai->capture.rate_min);
+               runtime->hw.rate_max =
+                       min(codec_dai->capture.rate_max, cpu_dai->capture.rate_max);
+               runtime->hw.channels_min =
+                       max(codec_dai->capture.channels_min,
+                               cpu_dai->capture.channels_min);
+               runtime->hw.channels_max =
+                       min(codec_dai->capture.channels_max,
+                               cpu_dai->capture.channels_max);
+               runtime->hw.formats =
+                       codec_dai->capture.formats & cpu_dai->capture.formats;
+               runtime->hw.rates =
+                       codec_dai->capture.rates & cpu_dai->capture.rates;
+       }
+
+       snd_pcm_limit_hw_rates(runtime);
+       if (!runtime->hw.rates) {
+               printk(KERN_ERR "asoc: %s <-> %s No matching rates\n",
+                       codec_dai->name, cpu_dai->name);
+               goto machine_err;
+       }
+       if (!runtime->hw.formats) {
+               printk(KERN_ERR "asoc: %s <-> %s No matching formats\n",
+                       codec_dai->name, cpu_dai->name);
+               goto machine_err;
+       }
+       if (!runtime->hw.channels_min || !runtime->hw.channels_max) {
+               printk(KERN_ERR "asoc: %s <-> %s No matching channels\n",
+                       codec_dai->name, cpu_dai->name);
+               goto machine_err;
+       }
+
+       dbg("asoc: %s <-> %s info:\n",codec_dai->name, cpu_dai->name);
+       dbg("asoc: rate mask 0x%x\n", runtime->hw.rates);
+       dbg("asoc: min ch %d max ch %d\n", runtime->hw.channels_min,
+               runtime->hw.channels_max);
+       dbg("asoc: min rate %d max rate %d\n", runtime->hw.rate_min,
+               runtime->hw.rate_max);
+
+       if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+               cpu_dai->playback.active = codec_dai->playback.active = 1;
+       else
+               cpu_dai->capture.active = codec_dai->capture.active = 1;
+       cpu_dai->active = codec_dai->active = 1;
+       cpu_dai->runtime = runtime;
+       socdev->codec->active++;
+       mutex_unlock(&pcm_mutex);
+       return 0;
+
+machine_err:
+       if (machine->ops && machine->ops->shutdown)
+               machine->ops->shutdown(substream);
+
+codec_dai_err:
+       if (platform->pcm_ops->close)
+               platform->pcm_ops->close(substream);
+
+platform_err:
+       if (cpu_dai->ops.shutdown)
+               cpu_dai->ops.shutdown(substream);
+out:
+       mutex_unlock(&pcm_mutex);
+       return ret;
+}
+
+/*
+ * Power down the audio subsytem pmdown_time msecs after close is called.
+ * This is to ensure there are no pops or clicks in between any music tracks
+ * due to DAPM power cycling.
+ */
+static void close_delayed_work(struct work_struct *work)
+{
+       struct snd_soc_device *socdev =
+               container_of(work, struct snd_soc_device, delayed_work.work);
+       struct snd_soc_codec *codec = socdev->codec;
+       struct snd_soc_codec_dai *codec_dai;
+       int i;
+
+       mutex_lock(&pcm_mutex);
+       for(i = 0; i < codec->num_dai; i++) {
+               codec_dai = &codec->dai[i];
+
+               dbg("pop wq checking: %s status: %s waiting: %s\n",
+                       codec_dai->playback.stream_name,
+                       codec_dai->playback.active ? "active" : "inactive",
+                       codec_dai->pop_wait ? "yes" : "no");
+
+               /* are we waiting on this codec DAI stream */
+               if (codec_dai->pop_wait == 1) {
+
+                       codec_dai->pop_wait = 0;
+                       snd_soc_dapm_stream_event(codec, codec_dai->playback.stream_name,
+                               SND_SOC_DAPM_STREAM_STOP);
+
+                       /* power down the codec power domain if no longer active */
+                       if (codec->active == 0) {
+                               dbg("pop wq D3 %s %s\n", codec->name,
+                                       codec_dai->playback.stream_name);
+                               if (codec->dapm_event)
+                                       codec->dapm_event(codec, SNDRV_CTL_POWER_D3hot);
+                       }
+               }
+       }
+       mutex_unlock(&pcm_mutex);
+}
+
+/*
+ * Called by ALSA when a PCM substream is closed. Private data can be
+ * freed here. The cpu DAI, codec DAI, machine and platform are also
+ * shutdown.
+ */
+static int soc_codec_close(struct snd_pcm_substream *substream)
+{
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_device *socdev = rtd->socdev;
+       struct snd_soc_dai_link *machine = rtd->dai;
+       struct snd_soc_platform *platform = socdev->platform;
+       struct snd_soc_cpu_dai *cpu_dai = machine->cpu_dai;
+       struct snd_soc_codec_dai *codec_dai = machine->codec_dai;
+       struct snd_soc_codec *codec = socdev->codec;
+
+       mutex_lock(&pcm_mutex);
+
+       if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+               cpu_dai->playback.active = codec_dai->playback.active = 0;
+       else
+               cpu_dai->capture.active = codec_dai->capture.active = 0;
+
+       if (codec_dai->playback.active == 0 &&
+               codec_dai->capture.active == 0) {
+               cpu_dai->active = codec_dai->active = 0;
+       }
+       codec->active--;
+
+       if (cpu_dai->ops.shutdown)
+               cpu_dai->ops.shutdown(substream);
+
+       if (codec_dai->ops.shutdown)
+               codec_dai->ops.shutdown(substream);
+
+       if (machine->ops && machine->ops->shutdown)
+               machine->ops->shutdown(substream);
+
+       if (platform->pcm_ops->close)
+               platform->pcm_ops->close(substream);
+       cpu_dai->runtime = NULL;
+
+       if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+               /* start delayed pop wq here for playback streams */
+               codec_dai->pop_wait = 1;
+               schedule_delayed_work(&socdev->delayed_work,
+                       msecs_to_jiffies(pmdown_time));
+       } else {
+               /* capture streams can be powered down now */
+               snd_soc_dapm_stream_event(codec,
+                       codec_dai->capture.stream_name, SND_SOC_DAPM_STREAM_STOP);
+
+               if (codec->active == 0 && codec_dai->pop_wait == 0){
+                       if (codec->dapm_event)
+                               codec->dapm_event(codec, SNDRV_CTL_POWER_D3hot);
+               }
+       }
+
+       mutex_unlock(&pcm_mutex);
+       return 0;
+}
+
+/*
+ * Called by ALSA when the PCM substream is prepared, can set format, sample
+ * rate, etc.  This function is non atomic and can be called multiple times,
+ * it can refer to the runtime info.
+ */
+static int soc_pcm_prepare(struct snd_pcm_substream *substream)
+{
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_device *socdev = rtd->socdev;
+       struct snd_soc_dai_link *machine = rtd->dai;
+       struct snd_soc_platform *platform = socdev->platform;
+       struct snd_soc_cpu_dai *cpu_dai = machine->cpu_dai;
+       struct snd_soc_codec_dai *codec_dai = machine->codec_dai;
+       struct snd_soc_codec *codec = socdev->codec;
+       int ret = 0;
+
+       mutex_lock(&pcm_mutex);
+
+       if (machine->ops && machine->ops->prepare) {
+               ret = machine->ops->prepare(substream);
+               if (ret < 0) {
+                       printk(KERN_ERR "asoc: machine prepare error\n");
+                       goto out;
+               }
+       }
+
+       if (platform->pcm_ops->prepare) {
+               ret = platform->pcm_ops->prepare(substream);
+               if (ret < 0) {
+                       printk(KERN_ERR "asoc: platform prepare error\n");
+                       goto out;
+               }
+       }
+
+       if (codec_dai->ops.prepare) {
+               ret = codec_dai->ops.prepare(substream);
+               if (ret < 0) {
+                       printk(KERN_ERR "asoc: codec DAI prepare error\n");
+                       goto out;
+               }
+       }
+
+       if (cpu_dai->ops.prepare) {
+               ret = cpu_dai->ops.prepare(substream);
+               if (ret < 0) {
+                       printk(KERN_ERR "asoc: cpu DAI prepare error\n");
+                       goto out;
+               }
+       }
+
+       /* we only want to start a DAPM playback stream if we are not waiting
+        * on an existing one stopping */
+       if (codec_dai->pop_wait) {
+               /* we are waiting for the delayed work to start */
+               if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
+                               snd_soc_dapm_stream_event(socdev->codec,
+                                       codec_dai->capture.stream_name,
+                                       SND_SOC_DAPM_STREAM_START);
+               else {
+                       codec_dai->pop_wait = 0;
+                       cancel_delayed_work(&socdev->delayed_work);
+                       if (codec_dai->dai_ops.digital_mute)
+                               codec_dai->dai_ops.digital_mute(codec_dai, 0);
+               }
+       } else {
+               /* no delayed work - do we need to power up codec */
+               if (codec->dapm_state != SNDRV_CTL_POWER_D0) {
+
+                       if (codec->dapm_event)
+                               codec->dapm_event(codec, SNDRV_CTL_POWER_D1);
+
+                       if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+                               snd_soc_dapm_stream_event(codec,
+                                       codec_dai->playback.stream_name,
+                                       SND_SOC_DAPM_STREAM_START);
+                       else
+                               snd_soc_dapm_stream_event(codec,
+                                       codec_dai->capture.stream_name,
+                                       SND_SOC_DAPM_STREAM_START);
+
+                       if (codec->dapm_event)
+                               codec->dapm_event(codec, SNDRV_CTL_POWER_D0);
+                       if (codec_dai->dai_ops.digital_mute)
+                               codec_dai->dai_ops.digital_mute(codec_dai, 0);
+
+               } else {
+                       /* codec already powered - power on widgets */
+                       if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+                               snd_soc_dapm_stream_event(codec,
+                                       codec_dai->playback.stream_name,
+                                       SND_SOC_DAPM_STREAM_START);
+                       else
+                               snd_soc_dapm_stream_event(codec,
+                                       codec_dai->capture.stream_name,
+                                       SND_SOC_DAPM_STREAM_START);
+                       if (codec_dai->dai_ops.digital_mute)
+                               codec_dai->dai_ops.digital_mute(codec_dai, 0);
+               }
+       }
+
+out:
+       mutex_unlock(&pcm_mutex);
+       return ret;
+}
+
+/*
+ * Called by ALSA when the hardware params are set by application. This
+ * function can also be called multiple times and can allocate buffers
+ * (using snd_pcm_lib_* ). It's non-atomic.
+ */
+static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
+                               struct snd_pcm_hw_params *params)
+{
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_device *socdev = rtd->socdev;
+       struct snd_soc_dai_link *machine = rtd->dai;
+       struct snd_soc_platform *platform = socdev->platform;
+       struct snd_soc_cpu_dai *cpu_dai = machine->cpu_dai;
+       struct snd_soc_codec_dai *codec_dai = machine->codec_dai;
+       int ret = 0;
+
+       mutex_lock(&pcm_mutex);
+
+       if (machine->ops && machine->ops->hw_params) {
+               ret = machine->ops->hw_params(substream, params);
+               if (ret < 0) {
+                       printk(KERN_ERR "asoc: machine hw_params failed\n");
+                       goto out;
+               }
+       }
+
+       if (codec_dai->ops.hw_params) {
+               ret = codec_dai->ops.hw_params(substream, params);
+               if (ret < 0) {
+                       printk(KERN_ERR "asoc: can't set codec %s hw params\n",
+                               codec_dai->name);
+                       goto codec_err;
+               }
+       }
+
+       if (cpu_dai->ops.hw_params) {
+               ret = cpu_dai->ops.hw_params(substream, params);
+               if (ret < 0) {
+                       printk(KERN_ERR "asoc: can't set interface %s hw params\n",
+                               cpu_dai->name);
+                       goto interface_err;
+               }
+       }
+
+       if (platform->pcm_ops->hw_params) {
+               ret = platform->pcm_ops->hw_params(substream, params);
+               if (ret < 0) {
+                       printk(KERN_ERR "asoc: can't set platform %s hw params\n",
+                               platform->name);
+                       goto platform_err;
+               }
+       }
+
+out:
+       mutex_unlock(&pcm_mutex);
+       return ret;
+
+platform_err:
+       if (cpu_dai->ops.hw_free)
+               cpu_dai->ops.hw_free(substream);
+
+interface_err:
+       if (codec_dai->ops.hw_free)
+               codec_dai->ops.hw_free(substream);
+
+codec_err:
+       if(machine->ops && machine->ops->hw_free)
+               machine->ops->hw_free(substream);
+
+       mutex_unlock(&pcm_mutex);
+       return ret;
+}
+
+/*
+ * Free's resources allocated by hw_params, can be called multiple times
+ */
+static int soc_pcm_hw_free(struct snd_pcm_substream *substream)
+{
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_device *socdev = rtd->socdev;
+       struct snd_soc_dai_link *machine = rtd->dai;
+       struct snd_soc_platform *platform = socdev->platform;
+       struct snd_soc_cpu_dai *cpu_dai = machine->cpu_dai;
+       struct snd_soc_codec_dai *codec_dai = machine->codec_dai;
+       struct snd_soc_codec *codec = socdev->codec;
+
+       mutex_lock(&pcm_mutex);
+
+       /* apply codec digital mute */
+       if (!codec->active && codec_dai->dai_ops.digital_mute)
+               codec_dai->dai_ops.digital_mute(codec_dai, 1);
+
+       /* free any machine hw params */
+       if (machine->ops && machine->ops->hw_free)
+               machine->ops->hw_free(substream);
+
+       /* free any DMA resources */
+       if (platform->pcm_ops->hw_free)
+               platform->pcm_ops->hw_free(substream);
+
+       /* now free hw params for the DAI's  */
+       if (codec_dai->ops.hw_free)
+               codec_dai->ops.hw_free(substream);
+
+       if (cpu_dai->ops.hw_free)
+               cpu_dai->ops.hw_free(substream);
+
+       mutex_unlock(&pcm_mutex);
+       return 0;
+}
+
+static int soc_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
+{
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_device *socdev = rtd->socdev;
+       struct snd_soc_dai_link *machine = rtd->dai;
+       struct snd_soc_platform *platform = socdev->platform;
+       struct snd_soc_cpu_dai *cpu_dai = machine->cpu_dai;
+       struct snd_soc_codec_dai *codec_dai = machine->codec_dai;
+       int ret;
+
+       if (codec_dai->ops.trigger) {
+               ret = codec_dai->ops.trigger(substream, cmd);
+               if (ret < 0)
+                       return ret;
+       }
+
+       if (platform->pcm_ops->trigger) {
+               ret = platform->pcm_ops->trigger(substream, cmd);
+               if (ret < 0)
+                       return ret;
+       }
+
+       if (cpu_dai->ops.trigger) {
+               ret = cpu_dai->ops.trigger(substream, cmd);
+               if (ret < 0)
+                       return ret;
+       }
+       return 0;
+}
+
+/* ASoC PCM operations */
+static struct snd_pcm_ops soc_pcm_ops = {
+       .open           = soc_pcm_open,
+       .close          = soc_codec_close,
+       .hw_params      = soc_pcm_hw_params,
+       .hw_free        = soc_pcm_hw_free,
+       .prepare        = soc_pcm_prepare,
+       .trigger        = soc_pcm_trigger,
+};
+
+#ifdef CONFIG_PM
+/* powers down audio subsystem for suspend */
+static int soc_suspend(struct platform_device *pdev, pm_message_t state)
+{
+       struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+       struct snd_soc_machine *machine = socdev->machine;
+       struct snd_soc_platform *platform = socdev->platform;
+       struct snd_soc_codec_device *codec_dev = socdev->codec_dev;
+       struct snd_soc_codec *codec = socdev->codec;
+       int i;
+
+       /* mute any active DAC's */
+       for(i = 0; i < machine->num_links; i++) {
+               struct snd_soc_codec_dai *dai = machine->dai_link[i].codec_dai;
+               if (dai->dai_ops.digital_mute && dai->playback.active)
+                       dai->dai_ops.digital_mute(dai, 1);
+       }
+
+       if (machine->suspend_pre)
+               machine->suspend_pre(pdev, state);
+
+       for(i = 0; i < machine->num_links; i++) {
+               struct snd_soc_cpu_dai  *cpu_dai = machine->dai_link[i].cpu_dai;
+               if (cpu_dai->suspend && cpu_dai->type != SND_SOC_DAI_AC97)
+                       cpu_dai->suspend(pdev, cpu_dai);
+               if (platform->suspend)
+                       platform->suspend(pdev, cpu_dai);
+       }
+
+       /* close any waiting streams and save state */
+       run_delayed_work(&socdev->delayed_work);
+       codec->suspend_dapm_state = codec->dapm_state;
+
+       for(i = 0; i < codec->num_dai; i++) {
+               char *stream = codec->dai[i].playback.stream_name;
+               if (stream != NULL)
+                       snd_soc_dapm_stream_event(codec, stream,
+                               SND_SOC_DAPM_STREAM_SUSPEND);
+               stream = codec->dai[i].capture.stream_name;
+               if (stream != NULL)
+                       snd_soc_dapm_stream_event(codec, stream,
+                               SND_SOC_DAPM_STREAM_SUSPEND);
+       }
+
+       if (codec_dev->suspend)
+               codec_dev->suspend(pdev, state);
+
+       for(i = 0; i < machine->num_links; i++) {
+               struct snd_soc_cpu_dai *cpu_dai = machine->dai_link[i].cpu_dai;
+               if (cpu_dai->suspend && cpu_dai->type == SND_SOC_DAI_AC97)
+                       cpu_dai->suspend(pdev, cpu_dai);
+       }
+
+       if (machine->suspend_post)
+               machine->suspend_post(pdev, state);
+
+       return 0;
+}
+
+/* powers up audio subsystem after a suspend */
+static int soc_resume(struct platform_device *pdev)
+{
+       struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+       struct snd_soc_machine *machine = socdev->machine;
+       struct snd_soc_platform *platform = socdev->platform;
+       struct snd_soc_codec_device *codec_dev = socdev->codec_dev;
+       struct snd_soc_codec *codec = socdev->codec;
+       int i;
+
+       if (machine->resume_pre)
+               machine->resume_pre(pdev);
+
+       for(i = 0; i < machine->num_links; i++) {
+               struct snd_soc_cpu_dai *cpu_dai = machine->dai_link[i].cpu_dai;
+               if (cpu_dai->resume && cpu_dai->type == SND_SOC_DAI_AC97)
+                       cpu_dai->resume(pdev, cpu_dai);
+       }
+
+       if (codec_dev->resume)
+               codec_dev->resume(pdev);
+
+       for(i = 0; i < codec->num_dai; i++) {
+               char* stream = codec->dai[i].playback.stream_name;
+               if (stream != NULL)
+                       snd_soc_dapm_stream_event(codec, stream,
+                               SND_SOC_DAPM_STREAM_RESUME);
+               stream = codec->dai[i].capture.stream_name;
+               if (stream != NULL)
+                       snd_soc_dapm_stream_event(codec, stream,
+                               SND_SOC_DAPM_STREAM_RESUME);
+       }
+
+       /* unmute any active DAC's */
+       for(i = 0; i < machine->num_links; i++) {
+               struct snd_soc_codec_dai *dai = machine->dai_link[i].codec_dai;
+               if (dai->dai_ops.digital_mute && dai->playback.active)
+                       dai->dai_ops.digital_mute(dai, 0);
+       }
+
+       for(i = 0; i < machine->num_links; i++) {
+               struct snd_soc_cpu_dai *cpu_dai = machine->dai_link[i].cpu_dai;
+               if (cpu_dai->resume && cpu_dai->type != SND_SOC_DAI_AC97)
+                       cpu_dai->resume(pdev, cpu_dai);
+               if (platform->resume)
+                       platform->resume(pdev, cpu_dai);
+       }
+
+       if (machine->resume_post)
+               machine->resume_post(pdev);
+
+       return 0;
+}
+
+#else
+#define soc_suspend    NULL
+#define soc_resume     NULL
+#endif
+
+/* probes a new socdev */
+static int soc_probe(struct platform_device *pdev)
+{
+       int ret = 0, i;
+       struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+       struct snd_soc_machine *machine = socdev->machine;
+       struct snd_soc_platform *platform = socdev->platform;
+       struct snd_soc_codec_device *codec_dev = socdev->codec_dev;
+
+       if (machine->probe) {
+               ret = machine->probe(pdev);
+               if(ret < 0)
+                       return ret;
+       }
+
+       for (i = 0; i < machine->num_links; i++) {
+               struct snd_soc_cpu_dai *cpu_dai = machine->dai_link[i].cpu_dai;
+               if (cpu_dai->probe) {
+                       ret = cpu_dai->probe(pdev);
+                       if(ret < 0)
+                               goto cpu_dai_err;
+               }
+       }
+
+       if (codec_dev->probe) {
+               ret = codec_dev->probe(pdev);
+               if(ret < 0)
+                       goto cpu_dai_err;
+       }
+
+       if (platform->probe) {
+               ret = platform->probe(pdev);
+               if(ret < 0)
+                       goto platform_err;
+       }
+
+       /* DAPM stream work */
+       INIT_DELAYED_WORK(&socdev->delayed_work, close_delayed_work);
+       return 0;
+
+platform_err:
+       if (codec_dev->remove)
+               codec_dev->remove(pdev);
+
+cpu_dai_err:
+       for (i--; i >= 0; i--) {
+               struct snd_soc_cpu_dai *cpu_dai = machine->dai_link[i].cpu_dai;
+               if (cpu_dai->remove)
+                       cpu_dai->remove(pdev);
+       }
+
+       if (machine->remove)
+               machine->remove(pdev);
+
+       return ret;
+}
+
+/* removes a socdev */
+static int soc_remove(struct platform_device *pdev)
+{
+       int i;
+       struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+       struct snd_soc_machine *machine = socdev->machine;
+       struct snd_soc_platform *platform = socdev->platform;
+       struct snd_soc_codec_device *codec_dev = socdev->codec_dev;
+
+       run_delayed_work(&socdev->delayed_work);
+
+       if (platform->remove)
+               platform->remove(pdev);
+
+       if (codec_dev->remove)
+               codec_dev->remove(pdev);
+
+       for (i = 0; i < machine->num_links; i++) {
+               struct snd_soc_cpu_dai *cpu_dai = machine->dai_link[i].cpu_dai;
+               if (cpu_dai->remove)
+                       cpu_dai->remove(pdev);
+       }
+
+       if (machine->remove)
+               machine->remove(pdev);
+
+       return 0;
+}
+
+/* ASoC platform driver */
+static struct platform_driver soc_driver = {
+       .driver         = {
+               .name           = "soc-audio",
+       },
+       .probe          = soc_probe,
+       .remove         = soc_remove,
+       .suspend        = soc_suspend,
+       .resume         = soc_resume,
+};
+
+/* create a new pcm */
+static int soc_new_pcm(struct snd_soc_device *socdev,
+       struct snd_soc_dai_link *dai_link, int num)
+{
+       struct snd_soc_codec *codec = socdev->codec;
+       struct snd_soc_codec_dai *codec_dai = dai_link->codec_dai;
+       struct snd_soc_cpu_dai *cpu_dai = dai_link->cpu_dai;
+       struct snd_soc_pcm_runtime *rtd;
+       struct snd_pcm *pcm;
+       char new_name[64];
+       int ret = 0, playback = 0, capture = 0;
+
+       rtd = kzalloc(sizeof(struct snd_soc_pcm_runtime), GFP_KERNEL);
+       if (rtd == NULL)
+               return -ENOMEM;
+
+       rtd->dai = dai_link;
+       rtd->socdev = socdev;
+       codec_dai->codec = socdev->codec;
+
+       /* check client and interface hw capabilities */
+       sprintf(new_name, "%s %s-%s-%d",dai_link->stream_name, codec_dai->name,
+               get_dai_name(cpu_dai->type), num);
+
+       if (codec_dai->playback.channels_min)
+               playback = 1;
+       if (codec_dai->capture.channels_min)
+               capture = 1;
+
+       ret = snd_pcm_new(codec->card, new_name, codec->pcm_devs++, playback,
+               capture, &pcm);
+       if (ret < 0) {
+               printk(KERN_ERR "asoc: can't create pcm for codec %s\n", codec->name);
+               kfree(rtd);
+               return ret;
+       }
+
+       pcm->private_data = rtd;
+       soc_pcm_ops.mmap = socdev->platform->pcm_ops->mmap;
+       soc_pcm_ops.pointer = socdev->platform->pcm_ops->pointer;
+       soc_pcm_ops.ioctl = socdev->platform->pcm_ops->ioctl;
+       soc_pcm_ops.copy = socdev->platform->pcm_ops->copy;
+       soc_pcm_ops.silence = socdev->platform->pcm_ops->silence;
+       soc_pcm_ops.ack = socdev->platform->pcm_ops->ack;
+       soc_pcm_ops.page = socdev->platform->pcm_ops->page;
+
+       if (playback)
+               snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &soc_pcm_ops);
+
+       if (capture)
+               snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &soc_pcm_ops);
+
+       ret = socdev->platform->pcm_new(codec->card, codec_dai, pcm);
+       if (ret < 0) {
+               printk(KERN_ERR "asoc: platform pcm constructor failed\n");
+               kfree(rtd);
+               return ret;
+       }
+
+       pcm->private_free = socdev->platform->pcm_free;
+       printk(KERN_INFO "asoc: %s <-> %s mapping ok\n", codec_dai->name,
+               cpu_dai->name);
+       return ret;
+}
+
+/* codec register dump */
+static ssize_t codec_reg_show(struct device *dev,
+       struct device_attribute *attr, char *buf)
+{
+       struct snd_soc_device *devdata = dev_get_drvdata(dev);
+       struct snd_soc_codec *codec = devdata->codec;
+       int i, step = 1, count = 0;
+
+       if (!codec->reg_cache_size)
+               return 0;
+
+       if (codec->reg_cache_step)
+               step = codec->reg_cache_step;
+
+       count += sprintf(buf, "%s registers\n", codec->name);
+       for(i = 0; i < codec->reg_cache_size; i += step)
+               count += sprintf(buf + count, "%2x: %4x\n", i, codec->read(codec, i));
+
+       return count;
+}
+static DEVICE_ATTR(codec_reg, 0444, codec_reg_show, NULL);
+
+/**
+ * snd_soc_new_ac97_codec - initailise AC97 device
+ * @codec: audio codec
+ * @ops: AC97 bus operations
+ * @num: AC97 codec number
+ *
+ * Initialises AC97 codec resources for use by ad-hoc devices only.
+ */
+int snd_soc_new_ac97_codec(struct snd_soc_codec *codec,
+       struct snd_ac97_bus_ops *ops, int num)
+{
+       mutex_lock(&codec->mutex);
+
+       codec->ac97 = kzalloc(sizeof(struct snd_ac97), GFP_KERNEL);
+       if (codec->ac97 == NULL) {
+               mutex_unlock(&codec->mutex);
+               return -ENOMEM;
+       }
+
+       codec->ac97->bus = kzalloc(sizeof(struct snd_ac97_bus), GFP_KERNEL);
+       if (codec->ac97->bus == NULL) {
+               kfree(codec->ac97);
+               codec->ac97 = NULL;
+               mutex_unlock(&codec->mutex);
+               return -ENOMEM;
+       }
+
+       codec->ac97->bus->ops = ops;
+       codec->ac97->num = num;
+       mutex_unlock(&codec->mutex);
+       return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_new_ac97_codec);
+
+/**
+ * snd_soc_free_ac97_codec - free AC97 codec device
+ * @codec: audio codec
+ *
+ * Frees AC97 codec device resources.
+ */
+void snd_soc_free_ac97_codec(struct snd_soc_codec *codec)
+{
+       mutex_lock(&codec->mutex);
+       kfree(codec->ac97->bus);
+       kfree(codec->ac97);
+       codec->ac97 = NULL;
+       mutex_unlock(&codec->mutex);
+}
+EXPORT_SYMBOL_GPL(snd_soc_free_ac97_codec);
+
+/**
+ * snd_soc_update_bits - update codec register bits
+ * @codec: audio codec
+ * @reg: codec register
+ * @mask: register mask
+ * @value: new value
+ *
+ * Writes new register value.
+ *
+ * Returns 1 for change else 0.
+ */
+int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg,
+                               unsigned short mask, unsigned short value)
+{
+       int change;
+       unsigned short old, new;
+
+       mutex_lock(&io_mutex);
+       old = snd_soc_read(codec, reg);
+       new = (old & ~mask) | value;
+       change = old != new;
+       if (change)
+               snd_soc_write(codec, reg, new);
+
+       mutex_unlock(&io_mutex);
+       return change;
+}
+EXPORT_SYMBOL_GPL(snd_soc_update_bits);
+
+/**
+ * snd_soc_test_bits - test register for change
+ * @codec: audio codec
+ * @reg: codec register
+ * @mask: register mask
+ * @value: new value
+ *
+ * Tests a register with a new value and checks if the new value is
+ * different from the old value.
+ *
+ * Returns 1 for change else 0.
+ */
+int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned short reg,
+                               unsigned short mask, unsigned short value)
+{
+       int change;
+       unsigned short old, new;
+
+       mutex_lock(&io_mutex);
+       old = snd_soc_read(codec, reg);
+       new = (old & ~mask) | value;
+       change = old != new;
+       mutex_unlock(&io_mutex);
+
+       return change;
+}
+EXPORT_SYMBOL_GPL(snd_soc_test_bits);
+
+/**
+ * snd_soc_new_pcms - create new sound card and pcms
+ * @socdev: the SoC audio device
+ *
+ * Create a new sound card based upon the codec and interface pcms.
+ *
+ * Returns 0 for success, else error.
+ */
+int snd_soc_new_pcms(struct snd_soc_device *socdev, int idx, const char *xid)
+{
+       struct snd_soc_codec *codec = socdev->codec;
+       struct snd_soc_machine *machine = socdev->machine;
+       int ret = 0, i;
+
+       mutex_lock(&codec->mutex);
+
+       /* register a sound card */
+       codec->card = snd_card_new(idx, xid, codec->owner, 0);
+       if (!codec->card) {
+               printk(KERN_ERR "asoc: can't create sound card for codec %s\n",
+                       codec->name);
+               mutex_unlock(&codec->mutex);
+               return -ENODEV;
+       }
+
+       codec->card->dev = socdev->dev;
+       codec->card->private_data = codec;
+       strncpy(codec->card->driver, codec->name, sizeof(codec->card->driver));
+
+       /* create the pcms */
+       for(i = 0; i < machine->num_links; i++) {
+               ret = soc_new_pcm(socdev, &machine->dai_link[i], i);
+               if (ret < 0) {
+                       printk(KERN_ERR "asoc: can't create pcm %s\n",
+                               machine->dai_link[i].stream_name);
+                       mutex_unlock(&codec->mutex);
+                       return ret;
+               }
+       }
+
+       mutex_unlock(&codec->mutex);
+       return ret;
+}
+EXPORT_SYMBOL_GPL(snd_soc_new_pcms);
+
+/**
+ * snd_soc_register_card - register sound card
+ * @socdev: the SoC audio device
+ *
+ * Register a SoC sound card. Also registers an AC97 device if the
+ * codec is AC97 for ad hoc devices.
+ *
+ * Returns 0 for success, else error.
+ */
+int snd_soc_register_card(struct snd_soc_device *socdev)
+{
+       struct snd_soc_codec *codec = socdev->codec;
+       struct snd_soc_machine *machine = socdev->machine;
+       int ret = 0, i, ac97 = 0, err = 0;
+
+       mutex_lock(&codec->mutex);
+       for(i = 0; i < machine->num_links; i++) {
+               if (socdev->machine->dai_link[i].init) {
+                       err = socdev->machine->dai_link[i].init(codec);
+                       if (err < 0) {
+                               printk(KERN_ERR "asoc: failed to init %s\n",
+                                       socdev->machine->dai_link[i].stream_name);
+                               continue;
+                       }
+               }
+               if (socdev->machine->dai_link[i].cpu_dai->type == SND_SOC_DAI_AC97)
+                       ac97 = 1;
+       }
+       snprintf(codec->card->shortname, sizeof(codec->card->shortname),
+                "%s", machine->name);
+       snprintf(codec->card->longname, sizeof(codec->card->longname),
+                "%s (%s)", machine->name, codec->name);
+
+       ret = snd_card_register(codec->card);
+       if (ret < 0) {
+               printk(KERN_ERR "asoc: failed to register soundcard for codec %s\n",
+                               codec->name);
+               goto out;
+       }
+
+#ifdef CONFIG_SND_SOC_AC97_BUS
+       if (ac97) {
+               ret = soc_ac97_dev_register(codec);
+               if (ret < 0) {
+                       printk(KERN_ERR "asoc: AC97 device register failed\n");
+                       snd_card_free(codec->card);
+                       goto out;
+               }
+       }
+#endif
+
+       err = snd_soc_dapm_sys_add(socdev->dev);
+       if (err < 0)
+               printk(KERN_WARNING "asoc: failed to add dapm sysfs entries\n");
+
+       err = device_create_file(socdev->dev, &dev_attr_codec_reg);
+       if (err < 0)
+               printk(KERN_WARNING "asoc: failed to add codec sysfs entries\n");
+out:
+       mutex_unlock(&codec->mutex);
+       return ret;
+}
+EXPORT_SYMBOL_GPL(snd_soc_register_card);
+
+/**
+ * snd_soc_free_pcms - free sound card and pcms
+ * @socdev: the SoC audio device
+ *
+ * Frees sound card and pcms associated with the socdev.
+ * Also unregister the codec if it is an AC97 device.
+ */
+void snd_soc_free_pcms(struct snd_soc_device *socdev)
+{
+       struct snd_soc_codec *codec = socdev->codec;
+
+       mutex_lock(&codec->mutex);
+#ifdef CONFIG_SND_SOC_AC97_BUS
+       if (codec->ac97)
+               soc_ac97_dev_unregister(codec);
+#endif
+
+       if (codec->card)
+               snd_card_free(codec->card);
+       device_remove_file(socdev->dev, &dev_attr_codec_reg);
+       mutex_unlock(&codec->mutex);
+}
+EXPORT_SYMBOL_GPL(snd_soc_free_pcms);
+
+/**
+ * snd_soc_set_runtime_hwparams - set the runtime hardware parameters
+ * @substream: the pcm substream
+ * @hw: the hardware parameters
+ *
+ * Sets the substream runtime hardware parameters.
+ */
+int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream,
+       const struct snd_pcm_hardware *hw)
+{
+       struct snd_pcm_runtime *runtime = substream->runtime;
+       runtime->hw.info = hw->info;
+       runtime->hw.formats = hw->formats;
+       runtime->hw.period_bytes_min = hw->period_bytes_min;
+       runtime->hw.period_bytes_max = hw->period_bytes_max;
+       runtime->hw.periods_min = hw->periods_min;
+       runtime->hw.periods_max = hw->periods_max;
+       runtime->hw.buffer_bytes_max = hw->buffer_bytes_max;
+       runtime->hw.fifo_size = hw->fifo_size;
+       return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_set_runtime_hwparams);
+
+/**
+ * snd_soc_cnew - create new control
+ * @_template: control template
+ * @data: control private data
+ * @lnng_name: control long name
+ *
+ * Create a new mixer control from a template control.
+ *
+ * Returns 0 for success, else error.
+ */
+struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template,
+       void *data, char *long_name)
+{
+       struct snd_kcontrol_new template;
+
+       memcpy(&template, _template, sizeof(template));
+       if (long_name)
+               template.name = long_name;
+       template.access = SNDRV_CTL_ELEM_ACCESS_READWRITE;
+       template.index = 0;
+
+       return snd_ctl_new1(&template, data);
+}
+EXPORT_SYMBOL_GPL(snd_soc_cnew);
+
+/**
+ * snd_soc_info_enum_double - enumerated double mixer info callback
+ * @kcontrol: mixer control
+ * @uinfo: control element information
+ *
+ * Callback to provide information about a double enumerated
+ * mixer control.
+ *
+ * Returns 0 for success.
+ */
+int snd_soc_info_enum_double(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_info *uinfo)
+{
+       struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
+
+       uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
+       uinfo->count = e->shift_l == e->shift_r ? 1 : 2;
+       uinfo->value.enumerated.items = e->mask;
+
+       if (uinfo->value.enumerated.item > e->mask - 1)
+               uinfo->value.enumerated.item = e->mask - 1;
+       strcpy(uinfo->value.enumerated.name,
+               e->texts[uinfo->value.enumerated.item]);
+       return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_info_enum_double);
+
+/**
+ * snd_soc_get_enum_double - enumerated double mixer get callback
+ * @kcontrol: mixer control
+ * @uinfo: control element information
+ *
+ * Callback to get the value of a double enumerated mixer.
+ *
+ * Returns 0 for success.
+ */
+int snd_soc_get_enum_double(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
+       unsigned short val, bitmask;
+
+       for (bitmask = 1; bitmask < e->mask; bitmask <<= 1)
+               ;
+       val = snd_soc_read(codec, e->reg);
+       ucontrol->value.enumerated.item[0] = (val >> e->shift_l) & (bitmask - 1);
+       if (e->shift_l != e->shift_r)
+               ucontrol->value.enumerated.item[1] =
+                       (val >> e->shift_r) & (bitmask - 1);
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_get_enum_double);
+
+/**
+ * snd_soc_put_enum_double - enumerated double mixer put callback
+ * @kcontrol: mixer control
+ * @uinfo: control element information
+ *
+ * Callback to set the value of a double enumerated mixer.
+ *
+ * Returns 0 for success.
+ */
+int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
+       unsigned short val;
+       unsigned short mask, bitmask;
+
+       for (bitmask = 1; bitmask < e->mask; bitmask <<= 1)
+               ;
+       if (ucontrol->value.enumerated.item[0] > e->mask - 1)
+               return -EINVAL;
+       val = ucontrol->value.enumerated.item[0] << e->shift_l;
+       mask = (bitmask - 1) << e->shift_l;
+       if (e->shift_l != e->shift_r) {
+               if (ucontrol->value.enumerated.item[1] > e->mask - 1)
+                       return -EINVAL;
+               val |= ucontrol->value.enumerated.item[1] << e->shift_r;
+               mask |= (bitmask - 1) << e->shift_r;
+       }
+
+       return snd_soc_update_bits(codec, e->reg, mask, val);
+}
+EXPORT_SYMBOL_GPL(snd_soc_put_enum_double);
+
+/**
+ * snd_soc_info_enum_ext - external enumerated single mixer info callback
+ * @kcontrol: mixer control
+ * @uinfo: control element information
+ *
+ * Callback to provide information about an external enumerated
+ * single mixer.
+ *
+ * Returns 0 for success.
+ */
+int snd_soc_info_enum_ext(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_info *uinfo)
+{
+       struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
+
+       uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
+       uinfo->count = 1;
+       uinfo->value.enumerated.items = e->mask;
+
+       if (uinfo->value.enumerated.item > e->mask - 1)
+               uinfo->value.enumerated.item = e->mask - 1;
+       strcpy(uinfo->value.enumerated.name,
+               e->texts[uinfo->value.enumerated.item]);
+       return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_info_enum_ext);
+
+/**
+ * snd_soc_info_volsw_ext - external single mixer info callback
+ * @kcontrol: mixer control
+ * @uinfo: control element information
+ *
+ * Callback to provide information about a single external mixer control.
+ *
+ * Returns 0 for success.
+ */
+int snd_soc_info_volsw_ext(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_info *uinfo)
+{
+       int mask = kcontrol->private_value;
+
+       uinfo->type =
+               mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER;
+       uinfo->count = 1;
+       uinfo->value.integer.min = 0;
+       uinfo->value.integer.max = mask;
+       return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_info_volsw_ext);
+
+/**
+ * snd_soc_info_bool_ext - external single boolean mixer info callback
+ * @kcontrol: mixer control
+ * @uinfo: control element information
+ *
+ * Callback to provide information about a single boolean external mixer control.
+ *
+ * Returns 0 for success.
+ */
+int snd_soc_info_bool_ext(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_info *uinfo)
+{
+       uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
+       uinfo->count = 1;
+       uinfo->value.integer.min = 0;
+       uinfo->value.integer.max = 1;
+       return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_info_bool_ext);
+
+/**
+ * snd_soc_info_volsw - single mixer info callback
+ * @kcontrol: mixer control
+ * @uinfo: control element information
+ *
+ * Callback to provide information about a single mixer control.
+ *
+ * Returns 0 for success.
+ */
+int snd_soc_info_volsw(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_info *uinfo)
+{
+       int mask = (kcontrol->private_value >> 16) & 0xff;
+       int shift = (kcontrol->private_value >> 8) & 0x0f;
+       int rshift = (kcontrol->private_value >> 12) & 0x0f;
+
+       uinfo->type =
+               mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER;
+       uinfo->count = shift == rshift ? 1 : 2;
+       uinfo->value.integer.min = 0;
+       uinfo->value.integer.max = mask;
+       return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_info_volsw);
+
+/**
+ * snd_soc_get_volsw - single mixer get callback
+ * @kcontrol: mixer control
+ * @uinfo: control element information
+ *
+ * Callback to get the value of a single mixer control.
+ *
+ * Returns 0 for success.
+ */
+int snd_soc_get_volsw(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       int reg = kcontrol->private_value & 0xff;
+       int shift = (kcontrol->private_value >> 8) & 0x0f;
+       int rshift = (kcontrol->private_value >> 12) & 0x0f;
+       int mask = (kcontrol->private_value >> 16) & 0xff;
+       int invert = (kcontrol->private_value >> 24) & 0x01;
+
+       ucontrol->value.integer.value[0] =
+               (snd_soc_read(codec, reg) >> shift) & mask;
+       if (shift != rshift)
+               ucontrol->value.integer.value[1] =
+                       (snd_soc_read(codec, reg) >> rshift) & mask;
+       if (invert) {
+               ucontrol->value.integer.value[0] =
+                       mask - ucontrol->value.integer.value[0];
+               if (shift != rshift)
+                       ucontrol->value.integer.value[1] =
+                               mask - ucontrol->value.integer.value[1];
+       }
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_get_volsw);
+
+/**
+ * snd_soc_put_volsw - single mixer put callback
+ * @kcontrol: mixer control
+ * @uinfo: control element information
+ *
+ * Callback to set the value of a single mixer control.
+ *
+ * Returns 0 for success.
+ */
+int snd_soc_put_volsw(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       int reg = kcontrol->private_value & 0xff;
+       int shift = (kcontrol->private_value >> 8) & 0x0f;
+       int rshift = (kcontrol->private_value >> 12) & 0x0f;
+       int mask = (kcontrol->private_value >> 16) & 0xff;
+       int invert = (kcontrol->private_value >> 24) & 0x01;
+       int err;
+       unsigned short val, val2, val_mask;
+
+       val = (ucontrol->value.integer.value[0] & mask);
+       if (invert)
+               val = mask - val;
+       val_mask = mask << shift;
+       val = val << shift;
+       if (shift != rshift) {
+               val2 = (ucontrol->value.integer.value[1] & mask);
+               if (invert)
+                       val2 = mask - val2;
+               val_mask |= mask << rshift;
+               val |= val2 << rshift;
+       }
+       err = snd_soc_update_bits(codec, reg, val_mask, val);
+       return err;
+}
+EXPORT_SYMBOL_GPL(snd_soc_put_volsw);
+
+/**
+ * snd_soc_info_volsw_2r - double mixer info callback
+ * @kcontrol: mixer control
+ * @uinfo: control element information
+ *
+ * Callback to provide information about a double mixer control that
+ * spans 2 codec registers.
+ *
+ * Returns 0 for success.
+ */
+int snd_soc_info_volsw_2r(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_info *uinfo)
+{
+       int mask = (kcontrol->private_value >> 12) & 0xff;
+
+       uinfo->type =
+               mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER;
+       uinfo->count = 2;
+       uinfo->value.integer.min = 0;
+       uinfo->value.integer.max = mask;
+       return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_info_volsw_2r);
+
+/**
+ * snd_soc_get_volsw_2r - double mixer get callback
+ * @kcontrol: mixer control
+ * @uinfo: control element information
+ *
+ * Callback to get the value of a double mixer control that spans 2 registers.
+ *
+ * Returns 0 for success.
+ */
+int snd_soc_get_volsw_2r(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       int reg = kcontrol->private_value & 0xff;
+       int reg2 = (kcontrol->private_value >> 24) & 0xff;
+       int shift = (kcontrol->private_value >> 8) & 0x0f;
+       int mask = (kcontrol->private_value >> 12) & 0xff;
+       int invert = (kcontrol->private_value >> 20) & 0x01;
+
+       ucontrol->value.integer.value[0] =
+               (snd_soc_read(codec, reg) >> shift) & mask;
+       ucontrol->value.integer.value[1] =
+               (snd_soc_read(codec, reg2) >> shift) & mask;
+       if (invert) {
+               ucontrol->value.integer.value[0] =
+                       mask - ucontrol->value.integer.value[0];
+               ucontrol->value.integer.value[1] =
+                       mask - ucontrol->value.integer.value[1];
+       }
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_get_volsw_2r);
+
+/**
+ * snd_soc_put_volsw_2r - double mixer set callback
+ * @kcontrol: mixer control
+ * @uinfo: control element information
+ *
+ * Callback to set the value of a double mixer control that spans 2 registers.
+ *
+ * Returns 0 for success.
+ */
+int snd_soc_put_volsw_2r(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       int reg = kcontrol->private_value & 0xff;
+       int reg2 = (kcontrol->private_value >> 24) & 0xff;
+       int shift = (kcontrol->private_value >> 8) & 0x0f;
+       int mask = (kcontrol->private_value >> 12) & 0xff;
+       int invert = (kcontrol->private_value >> 20) & 0x01;
+       int err;
+       unsigned short val, val2, val_mask;
+
+       val_mask = mask << shift;
+       val = (ucontrol->value.integer.value[0] & mask);
+       val2 = (ucontrol->value.integer.value[1] & mask);
+
+       if (invert) {
+               val = mask - val;
+               val2 = mask - val2;
+       }
+
+       val = val << shift;
+       val2 = val2 << shift;
+
+       if ((err = snd_soc_update_bits(codec, reg, val_mask, val)) < 0)
+               return err;
+
+       err = snd_soc_update_bits(codec, reg2, val_mask, val2);
+       return err;
+}
+EXPORT_SYMBOL_GPL(snd_soc_put_volsw_2r);
+
+static int __devinit snd_soc_init(void)
+{
+       printk(KERN_INFO "ASoC version %s\n", SND_SOC_VERSION);
+       return platform_driver_register(&soc_driver);
+}
+
+static void snd_soc_exit(void)
+{
+       platform_driver_unregister(&soc_driver);
+}
+
+module_init(snd_soc_init);
+module_exit(snd_soc_exit);
+
+/* Module information */
+MODULE_AUTHOR("Liam Girdwood, liam.girdwood@wolfsonmicro.com, www.wolfsonmicro.com");
+MODULE_DESCRIPTION("ALSA SoC Core");
+MODULE_LICENSE("GPL");
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
new file mode 100644 (file)
index 0000000..7caf8c7
--- /dev/null
@@ -0,0 +1,1323 @@
+/*
+ * soc-dapm.c  --  ALSA SoC Dynamic Audio Power Management
+ *
+ * Copyright 2005 Wolfson Microelectronics PLC.
+ * Author: Liam Girdwood
+ *         liam.girdwood@wolfsonmicro.com or linux@wolfsonmicro.com
+ *
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ *
+ *  Revision history
+ *    12th Aug 2005   Initial version.
+ *    25th Oct 2005   Implemented path power domain.
+ *    18th Dec 2005   Implemented machine and stream level power domain.
+ *
+ *  Features:
+ *    o Changes power status of internal codec blocks depending on the
+ *      dynamic configuration of codec internal audio paths and active
+ *      DAC's/ADC's.
+ *    o Platform power domain - can support external components i.e. amps and
+ *      mic/meadphone insertion events.
+ *    o Automatic Mic Bias support
+ *    o Jack insertion power event initiation - e.g. hp insertion will enable
+ *      sinks, dacs, etc
+ *    o Delayed powerdown of audio susbsytem to reduce pops between a quick
+ *      device reopen.
+ *
+ *  Todo:
+ *    o DAPM power change sequencing - allow for configurable per
+ *      codec sequences.
+ *    o Support for analogue bias optimisation.
+ *    o Support for reduced codec oversampling rates.
+ *    o Support for reduced codec bias currents.
+ */
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/init.h>
+#include <linux/delay.h>
+#include <linux/pm.h>
+#include <linux/bitops.h>
+#include <linux/platform_device.h>
+#include <linux/jiffies.h>
+#include <sound/driver.h>
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/pcm_params.h>
+#include <sound/soc-dapm.h>
+#include <sound/initval.h>
+
+/* debug */
+#define DAPM_DEBUG 0
+#if DAPM_DEBUG
+#define dump_dapm(codec, action) dbg_dump_dapm(codec, action)
+#define dbg(format, arg...) printk(format, ## arg)
+#else
+#define dump_dapm(codec, action)
+#define dbg(format, arg...)
+#endif
+
+#define POP_DEBUG 0
+#if POP_DEBUG
+#define POP_TIME 500 /* 500 msecs - change if pop debug is too fast */
+#define pop_wait(time) schedule_timeout_interruptible(msecs_to_jiffies(time))
+#define pop_dbg(format, arg...) printk(format, ## arg); pop_wait(POP_TIME)
+#else
+#define pop_dbg(format, arg...)
+#define pop_wait(time)
+#endif
+
+/* dapm power sequences - make this per codec in the future */
+static int dapm_up_seq[] = {
+       snd_soc_dapm_pre, snd_soc_dapm_micbias, snd_soc_dapm_mic,
+       snd_soc_dapm_mux, snd_soc_dapm_dac, snd_soc_dapm_mixer, snd_soc_dapm_pga,
+       snd_soc_dapm_adc, snd_soc_dapm_hp, snd_soc_dapm_spk, snd_soc_dapm_post
+};
+static int dapm_down_seq[] = {
+       snd_soc_dapm_pre, snd_soc_dapm_adc, snd_soc_dapm_hp, snd_soc_dapm_spk,
+       snd_soc_dapm_pga, snd_soc_dapm_mixer, snd_soc_dapm_dac, snd_soc_dapm_mic,
+       snd_soc_dapm_micbias, snd_soc_dapm_mux, snd_soc_dapm_post
+};
+
+static int dapm_status = 1;
+module_param(dapm_status, int, 0);
+MODULE_PARM_DESC(dapm_status, "enable DPM sysfs entries");
+
+/* create a new dapm widget */
+static inline struct snd_soc_dapm_widget *dapm_cnew_widget(
+       const struct snd_soc_dapm_widget *_widget)
+{
+       return kmemdup(_widget, sizeof(*_widget), GFP_KERNEL);
+}
+
+/* set up initial codec paths */
+static void dapm_set_path_status(struct snd_soc_dapm_widget *w,
+       struct snd_soc_dapm_path *p, int i)
+{
+       switch (w->id) {
+       case snd_soc_dapm_switch:
+       case snd_soc_dapm_mixer: {
+               int val;
+               int reg = w->kcontrols[i].private_value & 0xff;
+               int shift = (w->kcontrols[i].private_value >> 8) & 0x0f;
+               int mask = (w->kcontrols[i].private_value >> 16) & 0xff;
+               int invert = (w->kcontrols[i].private_value >> 24) & 0x01;
+
+               val = snd_soc_read(w->codec, reg);
+               val = (val >> shift) & mask;
+
+               if ((invert && !val) || (!invert && val))
+                       p->connect = 1;
+               else
+                       p->connect = 0;
+       }
+       break;
+       case snd_soc_dapm_mux: {
+               struct soc_enum *e = (struct soc_enum *)w->kcontrols[i].private_value;
+               int val, item, bitmask;
+
+               for (bitmask = 1; bitmask < e->mask; bitmask <<= 1)
+               ;
+               val = snd_soc_read(w->codec, e->reg);
+               item = (val >> e->shift_l) & (bitmask - 1);
+
+               p->connect = 0;
+               for (i = 0; i < e->mask; i++) {
+                       if (!(strcmp(p->name, e->texts[i])) && item == i)
+                               p->connect = 1;
+               }
+       }
+       break;
+       /* does not effect routing - always connected */
+       case snd_soc_dapm_pga:
+       case snd_soc_dapm_output:
+       case snd_soc_dapm_adc:
+       case snd_soc_dapm_input:
+       case snd_soc_dapm_dac:
+       case snd_soc_dapm_micbias:
+       case snd_soc_dapm_vmid:
+               p->connect = 1;
+       break;
+       /* does effect routing - dynamically connected */
+       case snd_soc_dapm_hp:
+       case snd_soc_dapm_mic:
+       case snd_soc_dapm_spk:
+       case snd_soc_dapm_line:
+       case snd_soc_dapm_pre:
+       case snd_soc_dapm_post:
+               p->connect = 0;
+       break;
+       }
+}
+
+/* connect mux widget to it's interconnecting audio paths */
+static int dapm_connect_mux(struct snd_soc_codec *codec,
+       struct snd_soc_dapm_widget *src, struct snd_soc_dapm_widget *dest,
+       struct snd_soc_dapm_path *path, const char *control_name,
+       const struct snd_kcontrol_new *kcontrol)
+{
+       struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
+       int i;
+
+       for (i = 0; i < e->mask; i++) {
+               if (!(strcmp(control_name, e->texts[i]))) {
+                       list_add(&path->list, &codec->dapm_paths);
+                       list_add(&path->list_sink, &dest->sources);
+                       list_add(&path->list_source, &src->sinks);
+                       path->name = (char*)e->texts[i];
+                       dapm_set_path_status(dest, path, 0);
+                       return 0;
+               }
+       }
+
+       return -ENODEV;
+}
+
+/* connect mixer widget to it's interconnecting audio paths */
+static int dapm_connect_mixer(struct snd_soc_codec *codec,
+       struct snd_soc_dapm_widget *src, struct snd_soc_dapm_widget *dest,
+       struct snd_soc_dapm_path *path, const char *control_name)
+{
+       int i;
+
+       /* search for mixer kcontrol */
+       for (i = 0; i < dest->num_kcontrols; i++) {
+               if (!strcmp(control_name, dest->kcontrols[i].name)) {
+                       list_add(&path->list, &codec->dapm_paths);
+                       list_add(&path->list_sink, &dest->sources);
+                       list_add(&path->list_source, &src->sinks);
+                       path->name = dest->kcontrols[i].name;
+                       dapm_set_path_status(dest, path, i);
+                       return 0;
+               }
+       }
+       return -ENODEV;
+}
+
+/* update dapm codec register bits */
+static int dapm_update_bits(struct snd_soc_dapm_widget *widget)
+{
+       int change, power;
+       unsigned short old, new;
+       struct snd_soc_codec *codec = widget->codec;
+
+       /* check for valid widgets */
+       if (widget->reg < 0 || widget->id == snd_soc_dapm_input ||
+               widget->id == snd_soc_dapm_output ||
+               widget->id == snd_soc_dapm_hp ||
+               widget->id == snd_soc_dapm_mic ||
+               widget->id == snd_soc_dapm_line ||
+               widget->id == snd_soc_dapm_spk)
+               return 0;
+
+       power = widget->power;
+       if (widget->invert)
+               power = (power ? 0:1);
+
+       old = snd_soc_read(codec, widget->reg);
+       new = (old & ~(0x1 << widget->shift)) | (power << widget->shift);
+
+       change = old != new;
+       if (change) {
+               pop_dbg("pop test %s : %s in %d ms\n", widget->name,
+                       widget->power ? "on" : "off", POP_TIME);
+               snd_soc_write(codec, widget->reg, new);
+               pop_wait(POP_TIME);
+       }
+       dbg("reg old %x new %x change %d\n", old, new, change);
+       return change;
+}
+
+/* ramps the volume up or down to minimise pops before or after a
+ * DAPM power event */
+static int dapm_set_pga(struct snd_soc_dapm_widget *widget, int power)
+{
+       const struct snd_kcontrol_new *k = widget->kcontrols;
+
+       if (widget->muted && !power)
+               return 0;
+       if (!widget->muted && power)
+               return 0;
+
+       if (widget->num_kcontrols && k) {
+               int reg = k->private_value & 0xff;
+               int shift = (k->private_value >> 8) & 0x0f;
+               int mask = (k->private_value >> 16) & 0xff;
+               int invert = (k->private_value >> 24) & 0x01;
+
+               if (power) {
+                       int i;
+                       /* power up has happended, increase volume to last level */
+                       if (invert) {
+                               for (i = mask; i > widget->saved_value; i--)
+                                       snd_soc_update_bits(widget->codec, reg, mask, i);
+                       } else {
+                               for (i = 0; i < widget->saved_value; i++)
+                                       snd_soc_update_bits(widget->codec, reg, mask, i);
+                       }
+                       widget->muted = 0;
+               } else {
+                       /* power down is about to occur, decrease volume to mute */
+                       int val = snd_soc_read(widget->codec, reg);
+                       int i = widget->saved_value = (val >> shift) & mask;
+                       if (invert) {
+                               for (; i < mask; i++)
+                                       snd_soc_update_bits(widget->codec, reg, mask, i);
+                       } else {
+                               for (; i > 0; i--)
+                                       snd_soc_update_bits(widget->codec, reg, mask, i);
+                       }
+                       widget->muted = 1;
+               }
+       }
+       return 0;
+}
+
+/* create new dapm mixer control */
+static int dapm_new_mixer(struct snd_soc_codec *codec,
+       struct snd_soc_dapm_widget *w)
+{
+       int i, ret = 0;
+       char name[32];
+       struct snd_soc_dapm_path *path;
+
+       /* add kcontrol */
+       for (i = 0; i < w->num_kcontrols; i++) {
+
+               /* match name */
+               list_for_each_entry(path, &w->sources, list_sink) {
+
+                       /* mixer/mux paths name must match control name */
+                       if (path->name != (char*)w->kcontrols[i].name)
+                               continue;
+
+                       /* add dapm control with long name */
+                       snprintf(name, 32, "%s %s", w->name, w->kcontrols[i].name);
+                       path->long_name = kstrdup (name, GFP_KERNEL);
+                       if (path->long_name == NULL)
+                               return -ENOMEM;
+
+                       path->kcontrol = snd_soc_cnew(&w->kcontrols[i], w,
+                               path->long_name);
+                       ret = snd_ctl_add(codec->card, path->kcontrol);
+                       if (ret < 0) {
+                               printk(KERN_ERR "asoc: failed to add dapm kcontrol %s\n",
+                                               path->long_name);
+                               kfree(path->long_name);
+                               path->long_name = NULL;
+                               return ret;
+                       }
+               }
+       }
+       return ret;
+}
+
+/* create new dapm mux control */
+static int dapm_new_mux(struct snd_soc_codec *codec,
+       struct snd_soc_dapm_widget *w)
+{
+       struct snd_soc_dapm_path *path = NULL;
+       struct snd_kcontrol *kcontrol;
+       int ret = 0;
+
+       if (!w->num_kcontrols) {
+               printk(KERN_ERR "asoc: mux %s has no controls\n", w->name);
+               return -EINVAL;
+       }
+
+       kcontrol = snd_soc_cnew(&w->kcontrols[0], w, w->name);
+       ret = snd_ctl_add(codec->card, kcontrol);
+       if (ret < 0)
+               goto err;
+
+       list_for_each_entry(path, &w->sources, list_sink)
+               path->kcontrol = kcontrol;
+
+       return ret;
+
+err:
+       printk(KERN_ERR "asoc: failed to add kcontrol %s\n", w->name);
+       return ret;
+}
+
+/* create new dapm volume control */
+static int dapm_new_pga(struct snd_soc_codec *codec,
+       struct snd_soc_dapm_widget *w)
+{
+       struct snd_kcontrol *kcontrol;
+       int ret = 0;
+
+       if (!w->num_kcontrols)
+               return -EINVAL;
+
+       kcontrol = snd_soc_cnew(&w->kcontrols[0], w, w->name);
+       ret = snd_ctl_add(codec->card, kcontrol);
+       if (ret < 0) {
+               printk(KERN_ERR "asoc: failed to add kcontrol %s\n", w->name);
+               return ret;
+       }
+
+       return ret;
+}
+
+/* reset 'walked' bit for each dapm path */
+static inline void dapm_clear_walk(struct snd_soc_codec *codec)
+{
+       struct snd_soc_dapm_path *p;
+
+       list_for_each_entry(p, &codec->dapm_paths, list)
+               p->walked = 0;
+}
+
+/*
+ * Recursively check for a completed path to an active or physically connected
+ * output widget. Returns number of complete paths.
+ */
+static int is_connected_output_ep(struct snd_soc_dapm_widget *widget)
+{
+       struct snd_soc_dapm_path *path;
+       int con = 0;
+
+       if (widget->id == snd_soc_dapm_adc && widget->active)
+               return 1;
+
+       if (widget->connected) {
+               /* connected pin ? */
+               if (widget->id == snd_soc_dapm_output && !widget->ext)
+                       return 1;
+
+               /* connected jack or spk ? */
+               if (widget->id == snd_soc_dapm_hp || widget->id == snd_soc_dapm_spk ||
+                       widget->id == snd_soc_dapm_line)
+                       return 1;
+       }
+
+       list_for_each_entry(path, &widget->sinks, list_source) {
+               if (path->walked)
+                       continue;
+
+               if (path->sink && path->connect) {
+                       path->walked = 1;
+                       con += is_connected_output_ep(path->sink);
+               }
+       }
+
+       return con;
+}
+
+/*
+ * Recursively check for a completed path to an active or physically connected
+ * input widget. Returns number of complete paths.
+ */
+static int is_connected_input_ep(struct snd_soc_dapm_widget *widget)
+{
+       struct snd_soc_dapm_path *path;
+       int con = 0;
+
+       /* active stream ? */
+       if (widget->id == snd_soc_dapm_dac && widget->active)
+               return 1;
+
+       if (widget->connected) {
+               /* connected pin ? */
+               if (widget->id == snd_soc_dapm_input && !widget->ext)
+                       return 1;
+
+               /* connected VMID/Bias for lower pops */
+               if (widget->id == snd_soc_dapm_vmid)
+                       return 1;
+
+               /* connected jack ? */
+               if (widget->id == snd_soc_dapm_mic || widget->id == snd_soc_dapm_line)
+                       return 1;
+       }
+
+       list_for_each_entry(path, &widget->sources, list_sink) {
+               if (path->walked)
+                       continue;
+
+               if (path->source && path->connect) {
+                       path->walked = 1;
+                       con += is_connected_input_ep(path->source);
+               }
+       }
+
+       return con;
+}
+
+/*
+ * Scan each dapm widget for complete audio path.
+ * A complete path is a route that has valid endpoints i.e.:-
+ *
+ *  o DAC to output pin.
+ *  o Input Pin to ADC.
+ *  o Input pin to Output pin (bypass, sidetone)
+ *  o DAC to ADC (loopback).
+ */
+static int dapm_power_widgets(struct snd_soc_codec *codec, int event)
+{
+       struct snd_soc_dapm_widget *w;
+       int in, out, i, c = 1, *seq = NULL, ret = 0, power_change, power;
+
+       /* do we have a sequenced stream event */
+       if (event == SND_SOC_DAPM_STREAM_START) {
+               c = ARRAY_SIZE(dapm_up_seq);
+               seq = dapm_up_seq;
+       } else if (event == SND_SOC_DAPM_STREAM_STOP) {
+               c = ARRAY_SIZE(dapm_down_seq);
+               seq = dapm_down_seq;
+       }
+
+       for(i = 0; i < c; i++) {
+               list_for_each_entry(w, &codec->dapm_widgets, list) {
+
+                       /* is widget in stream order */
+                       if (seq && seq[i] && w->id != seq[i])
+                               continue;
+
+                       /* vmid - no action */
+                       if (w->id == snd_soc_dapm_vmid)
+                               continue;
+
+                       /* active ADC */
+                       if (w->id == snd_soc_dapm_adc && w->active) {
+                               in = is_connected_input_ep(w);
+                               dapm_clear_walk(w->codec);
+                               w->power = (in != 0) ? 1 : 0;
+                               dapm_update_bits(w);
+                               continue;
+                       }
+
+                       /* active DAC */
+                       if (w->id == snd_soc_dapm_dac && w->active) {
+                               out = is_connected_output_ep(w);
+                               dapm_clear_walk(w->codec);
+                               w->power = (out != 0) ? 1 : 0;
+                               dapm_update_bits(w);
+                               continue;
+                       }
+
+                       /* programmable gain/attenuation */
+                       if (w->id == snd_soc_dapm_pga) {
+                               int on;
+                               in = is_connected_input_ep(w);
+                               dapm_clear_walk(w->codec);
+                               out = is_connected_output_ep(w);
+                               dapm_clear_walk(w->codec);
+                               w->power = on = (out != 0 && in != 0) ? 1 : 0;
+
+                               if (!on)
+                                       dapm_set_pga(w, on); /* lower volume to reduce pops */
+                               dapm_update_bits(w);
+                               if (on)
+                                       dapm_set_pga(w, on); /* restore volume from zero */
+
+                               continue;
+                       }
+
+                       /* pre and post event widgets */
+                       if (w->id == snd_soc_dapm_pre) {
+                               if (!w->event)
+                                       continue;
+
+                               if (event == SND_SOC_DAPM_STREAM_START) {
+                                       ret = w->event(w, SND_SOC_DAPM_PRE_PMU);
+                                       if (ret < 0)
+                                               return ret;
+                               } else if (event == SND_SOC_DAPM_STREAM_STOP) {
+                                       ret = w->event(w, SND_SOC_DAPM_PRE_PMD);
+                                       if (ret < 0)
+                                               return ret;
+                               }
+                               continue;
+                       }
+                       if (w->id == snd_soc_dapm_post) {
+                               if (!w->event)
+                                       continue;
+
+                               if (event == SND_SOC_DAPM_STREAM_START) {
+                                       ret = w->event(w, SND_SOC_DAPM_POST_PMU);
+                                       if (ret < 0)
+                                               return ret;
+                               } else if (event == SND_SOC_DAPM_STREAM_STOP) {
+                                       ret = w->event(w, SND_SOC_DAPM_POST_PMD);
+                                       if (ret < 0)
+                                               return ret;
+                               }
+                               continue;
+                       }
+
+                       /* all other widgets */
+                       in = is_connected_input_ep(w);
+                       dapm_clear_walk(w->codec);
+                       out = is_connected_output_ep(w);
+                       dapm_clear_walk(w->codec);
+                       power = (out != 0 && in != 0) ? 1 : 0;
+                       power_change = (w->power == power) ? 0: 1;
+                       w->power = power;
+
+                       /* call any power change event handlers */
+                       if (power_change) {
+                               if (w->event) {
+                                       dbg("power %s event for %s flags %x\n",
+                                               w->power ? "on" : "off", w->name, w->event_flags);
+                                       if (power) {
+                                               /* power up event */
+                                               if (w->event_flags & SND_SOC_DAPM_PRE_PMU) {
+                                                       ret = w->event(w, SND_SOC_DAPM_PRE_PMU);
+                                                       if (ret < 0)
+                                                               return ret;
+                                               }
+                                               dapm_update_bits(w);
+                                               if (w->event_flags & SND_SOC_DAPM_POST_PMU){
+                                                       ret = w->event(w, SND_SOC_DAPM_POST_PMU);
+                                                       if (ret < 0)
+                                                               return ret;
+                                               }
+                                       } else {
+                                               /* power down event */
+                                               if (w->event_flags & SND_SOC_DAPM_PRE_PMD) {
+                                                       ret = w->event(w, SND_SOC_DAPM_PRE_PMD);
+                                                       if (ret < 0)
+                                                               return ret;
+                                               }
+                                               dapm_update_bits(w);
+                                               if (w->event_flags & SND_SOC_DAPM_POST_PMD) {
+                                                       ret = w->event(w, SND_SOC_DAPM_POST_PMD);
+                                                       if (ret < 0)
+                                                               return ret;
+                                               }
+                                       }
+                               } else
+                                       /* no event handler */
+                                       dapm_update_bits(w);
+                       }
+               }
+       }
+
+       return ret;
+}
+
+#if DAPM_DEBUG
+static void dbg_dump_dapm(struct snd_soc_codec* codec, const char *action)
+{
+       struct snd_soc_dapm_widget *w;
+       struct snd_soc_dapm_path *p = NULL;
+       int in, out;
+
+       printk("DAPM %s %s\n", codec->name, action);
+
+       list_for_each_entry(w, &codec->dapm_widgets, list) {
+
+               /* only display widgets that effect routing */
+               switch (w->id) {
+               case snd_soc_dapm_pre:
+               case snd_soc_dapm_post:
+               case snd_soc_dapm_vmid:
+                       continue;
+               case snd_soc_dapm_mux:
+               case snd_soc_dapm_output:
+               case snd_soc_dapm_input:
+               case snd_soc_dapm_switch:
+               case snd_soc_dapm_hp:
+               case snd_soc_dapm_mic:
+               case snd_soc_dapm_spk:
+               case snd_soc_dapm_line:
+               case snd_soc_dapm_micbias:
+               case snd_soc_dapm_dac:
+               case snd_soc_dapm_adc:
+               case snd_soc_dapm_pga:
+               case snd_soc_dapm_mixer:
+                       if (w->name) {
+                               in = is_connected_input_ep(w);
+                               dapm_clear_walk(w->codec);
+                               out = is_connected_output_ep(w);
+                               dapm_clear_walk(w->codec);
+                               printk("%s: %s  in %d out %d\n", w->name,
+                                       w->power ? "On":"Off",in, out);
+
+                               list_for_each_entry(p, &w->sources, list_sink) {
+                                       if (p->connect)
+                                               printk(" in  %s %s\n", p->name ? p->name : "static",
+                                                       p->source->name);
+                               }
+                               list_for_each_entry(p, &w->sinks, list_source) {
+                                       if (p->connect)
+                                               printk(" out %s %s\n", p->name ? p->name : "static",
+                                                       p->sink->name);
+                               }
+                       }
+               break;
+               }
+       }
+}
+#endif
+
+/* test and update the power status of a mux widget */
+static int dapm_mux_update_power(struct snd_soc_dapm_widget *widget,
+                                struct snd_kcontrol *kcontrol, int mask,
+                                int val, struct soc_enum* e)
+{
+       struct snd_soc_dapm_path *path;
+       int found = 0;
+
+       if (widget->id != snd_soc_dapm_mux)
+               return -ENODEV;
+
+       if (!snd_soc_test_bits(widget->codec, e->reg, mask, val))
+               return 0;
+
+       /* find dapm widget path assoc with kcontrol */
+       list_for_each_entry(path, &widget->codec->dapm_paths, list) {
+               if (path->kcontrol != kcontrol)
+                       continue;
+
+               if (!path->name || ! e->texts[val])
+                       continue;
+
+               found = 1;
+               /* we now need to match the string in the enum to the path */
+               if (!(strcmp(path->name, e->texts[val])))
+                       path->connect = 1; /* new connection */
+               else
+                       path->connect = 0; /* old connection must be powered down */
+       }
+
+       if (found)
+               dapm_power_widgets(widget->codec, SND_SOC_DAPM_STREAM_NOP);
+
+       return 0;
+}
+
+/* test and update the power status of a mixer widget */
+static int dapm_mixer_update_power(struct snd_soc_dapm_widget *widget,
+                                  struct snd_kcontrol *kcontrol, int reg,
+                                  int val_mask, int val, int invert)
+{
+       struct snd_soc_dapm_path *path;
+       int found = 0;
+
+       if (widget->id != snd_soc_dapm_mixer)
+               return -ENODEV;
+
+       if (!snd_soc_test_bits(widget->codec, reg, val_mask, val))
+               return 0;
+
+       /* find dapm widget path assoc with kcontrol */
+       list_for_each_entry(path, &widget->codec->dapm_paths, list) {
+               if (path->kcontrol != kcontrol)
+                       continue;
+
+               /* found, now check type */
+               found = 1;
+               if (val)
+                       /* new connection */
+                       path->connect = invert ? 0:1;
+               else
+                       /* old connection must be powered down */
+                       path->connect = invert ? 1:0;
+               break;
+       }
+
+       if (found)
+               dapm_power_widgets(widget->codec, SND_SOC_DAPM_STREAM_NOP);
+
+       return 0;
+}
+
+/* show dapm widget status in sys fs */
+static ssize_t dapm_widget_show(struct device *dev,
+       struct device_attribute *attr, char *buf)
+{
+       struct snd_soc_device *devdata = dev_get_drvdata(dev);
+       struct snd_soc_codec *codec = devdata->codec;
+       struct snd_soc_dapm_widget *w;
+       int count = 0;
+       char *state = "not set";
+
+       list_for_each_entry(w, &codec->dapm_widgets, list) {
+
+               /* only display widgets that burnm power */
+               switch (w->id) {
+               case snd_soc_dapm_hp:
+               case snd_soc_dapm_mic:
+               case snd_soc_dapm_spk:
+               case snd_soc_dapm_line:
+               case snd_soc_dapm_micbias:
+               case snd_soc_dapm_dac:
+               case snd_soc_dapm_adc:
+               case snd_soc_dapm_pga:
+               case snd_soc_dapm_mixer:
+                       if (w->name)
+                               count += sprintf(buf + count, "%s: %s\n",
+                                       w->name, w->power ? "On":"Off");
+               break;
+               default:
+               break;
+               }
+       }
+
+       switch(codec->dapm_state){
+       case SNDRV_CTL_POWER_D0:
+               state = "D0";
+               break;
+       case SNDRV_CTL_POWER_D1:
+               state = "D1";
+               break;
+       case SNDRV_CTL_POWER_D2:
+               state = "D2";
+               break;
+       case SNDRV_CTL_POWER_D3hot:
+               state = "D3hot";
+               break;
+       case SNDRV_CTL_POWER_D3cold:
+               state = "D3cold";
+               break;
+       }
+       count += sprintf(buf + count, "PM State: %s\n", state);
+
+       return count;
+}
+
+static DEVICE_ATTR(dapm_widget, 0444, dapm_widget_show, NULL);
+
+int snd_soc_dapm_sys_add(struct device *dev)
+{
+       int ret = 0;
+
+       if (dapm_status)
+               ret = device_create_file(dev, &dev_attr_dapm_widget);
+
+       return ret;
+}
+
+static void snd_soc_dapm_sys_remove(struct device *dev)
+{
+       if (dapm_status)
+               device_remove_file(dev, &dev_attr_dapm_widget);
+}
+
+/* free all dapm widgets and resources */
+static void dapm_free_widgets(struct snd_soc_codec *codec)
+{
+       struct snd_soc_dapm_widget *w, *next_w;
+       struct snd_soc_dapm_path *p, *next_p;
+
+       list_for_each_entry_safe(w, next_w, &codec->dapm_widgets, list) {
+               list_del(&w->list);
+               kfree(w);
+       }
+
+       list_for_each_entry_safe(p, next_p, &codec->dapm_paths, list) {
+               list_del(&p->list);
+               kfree(p->long_name);
+               kfree(p);
+       }
+}
+
+/**
+ * snd_soc_dapm_sync_endpoints - scan and power dapm paths
+ * @codec: audio codec
+ *
+ * Walks all dapm audio paths and powers widgets according to their
+ * stream or path usage.
+ *
+ * Returns 0 for success.
+ */
+int snd_soc_dapm_sync_endpoints(struct snd_soc_codec *codec)
+{
+       return dapm_power_widgets(codec, SND_SOC_DAPM_STREAM_NOP);
+}
+EXPORT_SYMBOL_GPL(snd_soc_dapm_sync_endpoints);
+
+/**
+ * snd_soc_dapm_connect_input - connect dapm widgets
+ * @codec: audio codec
+ * @sink: name of target widget
+ * @control: mixer control name
+ * @source: name of source name
+ *
+ * Connects 2 dapm widgets together via a named audio path. The sink is
+ * the widget receiving the audio signal, whilst the source is the sender
+ * of the audio signal.
+ *
+ * Returns 0 for success else error.
+ */
+int snd_soc_dapm_connect_input(struct snd_soc_codec *codec, const char *sink,
+       const char * control, const char *source)
+{
+       struct snd_soc_dapm_path *path;
+       struct snd_soc_dapm_widget *wsource = NULL, *wsink = NULL, *w;
+       int ret = 0;
+
+       /* find src and dest widgets */
+       list_for_each_entry(w, &codec->dapm_widgets, list) {
+
+               if (!wsink && !(strcmp(w->name, sink))) {
+                       wsink = w;
+                       continue;
+               }
+               if (!wsource && !(strcmp(w->name, source))) {
+                       wsource = w;
+               }
+       }
+
+       if (wsource == NULL || wsink == NULL)
+               return -ENODEV;
+
+       path = kzalloc(sizeof(struct snd_soc_dapm_path), GFP_KERNEL);
+       if (!path)
+               return -ENOMEM;
+
+       path->source = wsource;
+       path->sink = wsink;
+       INIT_LIST_HEAD(&path->list);
+       INIT_LIST_HEAD(&path->list_source);
+       INIT_LIST_HEAD(&path->list_sink);
+
+       /* check for external widgets */
+       if (wsink->id == snd_soc_dapm_input) {
+               if (wsource->id == snd_soc_dapm_micbias ||
+                       wsource->id == snd_soc_dapm_mic ||
+                       wsink->id == snd_soc_dapm_line)
+                       wsink->ext = 1;
+       }
+       if (wsource->id == snd_soc_dapm_output) {
+               if (wsink->id == snd_soc_dapm_spk ||
+                       wsink->id == snd_soc_dapm_hp ||
+                       wsink->id == snd_soc_dapm_line)
+                       wsource->ext = 1;
+       }
+
+       /* connect static paths */
+       if (control == NULL) {
+               list_add(&path->list, &codec->dapm_paths);
+               list_add(&path->list_sink, &wsink->sources);
+               list_add(&path->list_source, &wsource->sinks);
+               path->connect = 1;
+               return 0;
+       }
+
+       /* connect dynamic paths */
+       switch(wsink->id) {
+       case snd_soc_dapm_adc:
+       case snd_soc_dapm_dac:
+       case snd_soc_dapm_pga:
+       case snd_soc_dapm_input:
+       case snd_soc_dapm_output:
+       case snd_soc_dapm_micbias:
+       case snd_soc_dapm_vmid:
+       case snd_soc_dapm_pre:
+       case snd_soc_dapm_post:
+               list_add(&path->list, &codec->dapm_paths);
+               list_add(&path->list_sink, &wsink->sources);
+               list_add(&path->list_source, &wsource->sinks);
+               path->connect = 1;
+               return 0;
+       case snd_soc_dapm_mux:
+               ret = dapm_connect_mux(codec, wsource, wsink, path, control,
+                       &wsink->kcontrols[0]);
+               if (ret != 0)
+                       goto err;
+               break;
+       case snd_soc_dapm_switch:
+       case snd_soc_dapm_mixer:
+               ret = dapm_connect_mixer(codec, wsource, wsink, path, control);
+               if (ret != 0)
+                       goto err;
+               break;
+       case snd_soc_dapm_hp:
+       case snd_soc_dapm_mic:
+       case snd_soc_dapm_line:
+       case snd_soc_dapm_spk:
+               list_add(&path->list, &codec->dapm_paths);
+               list_add(&path->list_sink, &wsink->sources);
+               list_add(&path->list_source, &wsource->sinks);
+               path->connect = 0;
+               return 0;
+       }
+       return 0;
+
+err:
+       printk(KERN_WARNING "asoc: no dapm match for %s --> %s --> %s\n", source,
+               control, sink);
+       kfree(path);
+       return ret;
+}
+EXPORT_SYMBOL_GPL(snd_soc_dapm_connect_input);
+
+/**
+ * snd_soc_dapm_new_widgets - add new dapm widgets
+ * @codec: audio codec
+ *
+ * Checks the codec for any new dapm widgets and creates them if found.
+ *
+ * Returns 0 for success.
+ */
+int snd_soc_dapm_new_widgets(struct snd_soc_codec *codec)
+{
+       struct snd_soc_dapm_widget *w;
+
+       mutex_lock(&codec->mutex);
+       list_for_each_entry(w, &codec->dapm_widgets, list)
+       {
+               if (w->new)
+                       continue;
+
+               switch(w->id) {
+               case snd_soc_dapm_switch:
+               case snd_soc_dapm_mixer:
+                       dapm_new_mixer(codec, w);
+                       break;
+               case snd_soc_dapm_mux:
+                       dapm_new_mux(codec, w);
+                       break;
+               case snd_soc_dapm_adc:
+               case snd_soc_dapm_dac:
+               case snd_soc_dapm_pga:
+                       dapm_new_pga(codec, w);
+                       break;
+               case snd_soc_dapm_input:
+               case snd_soc_dapm_output:
+               case snd_soc_dapm_micbias:
+               case snd_soc_dapm_spk:
+               case snd_soc_dapm_hp:
+               case snd_soc_dapm_mic:
+               case snd_soc_dapm_line:
+               case snd_soc_dapm_vmid:
+               case snd_soc_dapm_pre:
+               case snd_soc_dapm_post:
+                       break;
+               }
+               w->new = 1;
+       }
+
+       dapm_power_widgets(codec, SND_SOC_DAPM_STREAM_NOP);
+       mutex_unlock(&codec->mutex);
+       return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_dapm_new_widgets);
+
+/**
+ * snd_soc_dapm_get_volsw - dapm mixer get callback
+ * @kcontrol: mixer control
+ * @uinfo: control element information
+ *
+ * Callback to get the value of a dapm mixer control.
+ *
+ * Returns 0 for success.
+ */
+int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_soc_dapm_widget *widget = snd_kcontrol_chip(kcontrol);
+       int reg = kcontrol->private_value & 0xff;
+       int shift = (kcontrol->private_value >> 8) & 0x0f;
+       int rshift = (kcontrol->private_value >> 12) & 0x0f;
+       int mask = (kcontrol->private_value >> 16) & 0xff;
+       int invert = (kcontrol->private_value >> 24) & 0x01;
+
+       /* return the saved value if we are powered down */
+       if (widget->id == snd_soc_dapm_pga && !widget->power) {
+               ucontrol->value.integer.value[0] = widget->saved_value;
+               return 0;
+       }
+
+       ucontrol->value.integer.value[0] =
+               (snd_soc_read(widget->codec, reg) >> shift) & mask;
+       if (shift != rshift)
+               ucontrol->value.integer.value[1] =
+                       (snd_soc_read(widget->codec, reg) >> rshift) & mask;
+       if (invert) {
+               ucontrol->value.integer.value[0] =
+                       mask - ucontrol->value.integer.value[0];
+               if (shift != rshift)
+                       ucontrol->value.integer.value[1] =
+                               mask - ucontrol->value.integer.value[1];
+       }
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_dapm_get_volsw);
+
+/**
+ * snd_soc_dapm_put_volsw - dapm mixer set callback
+ * @kcontrol: mixer control
+ * @uinfo: control element information
+ *
+ * Callback to set the value of a dapm mixer control.
+ *
+ * Returns 0 for success.
+ */
+int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_soc_dapm_widget *widget = snd_kcontrol_chip(kcontrol);
+       int reg = kcontrol->private_value & 0xff;
+       int shift = (kcontrol->private_value >> 8) & 0x0f;
+       int rshift = (kcontrol->private_value >> 12) & 0x0f;
+       int mask = (kcontrol->private_value >> 16) & 0xff;
+       int invert = (kcontrol->private_value >> 24) & 0x01;
+       unsigned short val, val2, val_mask;
+       int ret;
+
+       val = (ucontrol->value.integer.value[0] & mask);
+
+       if (invert)
+               val = mask - val;
+       val_mask = mask << shift;
+       val = val << shift;
+       if (shift != rshift) {
+               val2 = (ucontrol->value.integer.value[1] & mask);
+               if (invert)
+                       val2 = mask - val2;
+               val_mask |= mask << rshift;
+               val |= val2 << rshift;
+       }
+
+       mutex_lock(&widget->codec->mutex);
+       widget->value = val;
+
+       /* save volume value if the widget is powered down */
+       if (widget->id == snd_soc_dapm_pga && !widget->power) {
+               widget->saved_value = val;
+               mutex_unlock(&widget->codec->mutex);
+               return 1;
+       }
+
+       dapm_mixer_update_power(widget, kcontrol, reg, val_mask, val, invert);
+       if (widget->event) {
+               if (widget->event_flags & SND_SOC_DAPM_PRE_REG) {
+                       ret = widget->event(widget, SND_SOC_DAPM_PRE_REG);
+                       if (ret < 0)
+                               goto out;
+               }
+               ret = snd_soc_update_bits(widget->codec, reg, val_mask, val);
+               if (widget->event_flags & SND_SOC_DAPM_POST_REG)
+                       ret = widget->event(widget, SND_SOC_DAPM_POST_REG);
+       } else
+               ret = snd_soc_update_bits(widget->codec, reg, val_mask, val);
+
+out:
+       mutex_unlock(&widget->codec->mutex);
+       return ret;
+}
+EXPORT_SYMBOL_GPL(snd_soc_dapm_put_volsw);
+
+/**
+ * snd_soc_dapm_get_enum_double - dapm enumerated double mixer get callback
+ * @kcontrol: mixer control
+ * @uinfo: control element information
+ *
+ * Callback to get the value of a dapm enumerated double mixer control.
+ *
+ * Returns 0 for success.
+ */
+int snd_soc_dapm_get_enum_double(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_soc_dapm_widget *widget = snd_kcontrol_chip(kcontrol);
+       struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
+       unsigned short val, bitmask;
+
+       for (bitmask = 1; bitmask < e->mask; bitmask <<= 1)
+               ;
+       val = snd_soc_read(widget->codec, e->reg);
+       ucontrol->value.enumerated.item[0] = (val >> e->shift_l) & (bitmask - 1);
+       if (e->shift_l != e->shift_r)
+               ucontrol->value.enumerated.item[1] =
+                       (val >> e->shift_r) & (bitmask - 1);
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_dapm_get_enum_double);
+
+/**
+ * snd_soc_dapm_put_enum_double - dapm enumerated double mixer set callback
+ * @kcontrol: mixer control
+ * @uinfo: control element information
+ *
+ * Callback to set the value of a dapm enumerated double mixer control.
+ *
+ * Returns 0 for success.
+ */
+int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_soc_dapm_widget *widget = snd_kcontrol_chip(kcontrol);
+       struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
+       unsigned short val, mux;
+       unsigned short mask, bitmask;
+       int ret = 0;
+
+       for (bitmask = 1; bitmask < e->mask; bitmask <<= 1)
+               ;
+       if (ucontrol->value.enumerated.item[0] > e->mask - 1)
+               return -EINVAL;
+       mux = ucontrol->value.enumerated.item[0];
+       val = mux << e->shift_l;
+       mask = (bitmask - 1) << e->shift_l;
+       if (e->shift_l != e->shift_r) {
+               if (ucontrol->value.enumerated.item[1] > e->mask - 1)
+                       return -EINVAL;
+               val |= ucontrol->value.enumerated.item[1] << e->shift_r;
+               mask |= (bitmask - 1) << e->shift_r;
+       }
+
+       mutex_lock(&widget->codec->mutex);
+       widget->value = val;
+       dapm_mux_update_power(widget, kcontrol, mask, mux, e);
+       if (widget->event) {
+               if (widget->event_flags & SND_SOC_DAPM_PRE_REG) {
+                       ret = widget->event(widget, SND_SOC_DAPM_PRE_REG);
+                       if (ret < 0)
+                               goto out;
+               }
+               ret = snd_soc_update_bits(widget->codec, e->reg, mask, val);
+               if (widget->event_flags & SND_SOC_DAPM_POST_REG)
+                       ret = widget->event(widget, SND_SOC_DAPM_POST_REG);
+       } else
+               ret = snd_soc_update_bits(widget->codec, e->reg, mask, val);
+
+out:
+       mutex_unlock(&widget->codec->mutex);
+       return ret;
+}
+EXPORT_SYMBOL_GPL(snd_soc_dapm_put_enum_double);
+
+/**
+ * snd_soc_dapm_new_control - create new dapm control
+ * @codec: audio codec
+ * @widget: widget template
+ *
+ * Creates a new dapm control based upon the template.
+ *
+ * Returns 0 for success else error.
+ */
+int snd_soc_dapm_new_control(struct snd_soc_codec *codec,
+       const struct snd_soc_dapm_widget *widget)
+{
+       struct snd_soc_dapm_widget *w;
+
+       if ((w = dapm_cnew_widget(widget)) == NULL)
+               return -ENOMEM;
+
+       w->codec = codec;
+       INIT_LIST_HEAD(&w->sources);
+       INIT_LIST_HEAD(&w->sinks);
+       INIT_LIST_HEAD(&w->list);
+       list_add(&w->list, &codec->dapm_widgets);
+
+       /* machine layer set ups unconnected pins and insertions */
+       w->connected = 1;
+       return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_dapm_new_control);
+
+/**
+ * snd_soc_dapm_stream_event - send a stream event to the dapm core
+ * @codec: audio codec
+ * @stream: stream name
+ * @event: stream event
+ *
+ * Sends a stream event to the dapm core. The core then makes any
+ * necessary widget power changes.
+ *
+ * Returns 0 for success else error.
+ */
+int snd_soc_dapm_stream_event(struct snd_soc_codec *codec,
+       char *stream, int event)
+{
+       struct snd_soc_dapm_widget *w;
+
+       if (stream == NULL)
+               return 0;
+
+       mutex_lock(&codec->mutex);
+       list_for_each_entry(w, &codec->dapm_widgets, list)
+       {
+               if (!w->sname)
+                       continue;
+               dbg("widget %s\n %s stream %s event %d\n", w->name, w->sname,
+                       stream, event);
+               if (strstr(w->sname, stream)) {
+                       switch(event) {
+                       case SND_SOC_DAPM_STREAM_START:
+                               w->active = 1;
+                               break;
+                       case SND_SOC_DAPM_STREAM_STOP:
+                               w->active = 0;
+                               break;
+                       case SND_SOC_DAPM_STREAM_SUSPEND:
+                               if (w->active)
+                                       w->suspend = 1;
+                               w->active = 0;
+                               break;
+                       case SND_SOC_DAPM_STREAM_RESUME:
+                               if (w->suspend) {
+                                       w->active = 1;
+                                       w->suspend = 0;
+                               }
+                               break;
+                       case SND_SOC_DAPM_STREAM_PAUSE_PUSH:
+                               break;
+                       case SND_SOC_DAPM_STREAM_PAUSE_RELEASE:
+                               break;
+                       }
+               }
+       }
+       mutex_unlock(&codec->mutex);
+
+       dapm_power_widgets(codec, event);
+       dump_dapm(codec, __FUNCTION__);
+       return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_dapm_stream_event);
+
+/**
+ * snd_soc_dapm_set_endpoint - set audio endpoint status
+ * @codec: audio codec
+ * @endpoint: audio signal endpoint (or start point)
+ * @status: point status
+ *
+ * Set audio endpoint status - connected or disconnected.
+ *
+ * Returns 0 for success else error.
+ */
+int snd_soc_dapm_set_endpoint(struct snd_soc_codec *codec,
+       char *endpoint, int status)
+{
+       struct snd_soc_dapm_widget *w;
+
+       list_for_each_entry(w, &codec->dapm_widgets, list) {
+               if (!strcmp(w->name, endpoint)) {
+                       w->connected = status;
+               }
+       }
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_dapm_set_endpoint);
+
+/**
+ * snd_soc_dapm_free - free dapm resources
+ * @socdev: SoC device
+ *
+ * Free all dapm widgets and resources.
+ */
+void snd_soc_dapm_free(struct snd_soc_device *socdev)
+{
+       struct snd_soc_codec *codec = socdev->codec;
+
+       snd_soc_dapm_sys_remove(socdev->dev);
+       dapm_free_widgets(codec);
+}
+EXPORT_SYMBOL_GPL(snd_soc_dapm_free);
+
+/* Module information */
+MODULE_AUTHOR("Liam Girdwood, liam.girdwood@wolfsonmicro.com, www.wolfsonmicro.com");
+MODULE_DESCRIPTION("Dynamic Audio Power Management core for ALSA SoC");
+MODULE_LICENSE("GPL");
index 4ceb09d215d8b5b3d10ccc1a7bafb0d01e0d9a43..25a2a733300677162e28186b5e2b274751c9a10f 100644 (file)
@@ -678,7 +678,7 @@ static s32 *dbri_cmdlock(struct snd_dbri * dbri, int len)
  * The JUMP cmd points to the new cmd string.
  * It also releases the cmdlock spinlock.
  *
- * Lock must not be held before calling this.
+ * Lock must be held before calling this.
  */
 static void dbri_cmdsend(struct snd_dbri * dbri, s32 * cmd,int len)
 {
index 19bdcc74c96c9aa376742135c0c65de753dc62e7..4dfb91d4398a02fb6962ba07310f658d7cc30fe9 100644 (file)
@@ -186,6 +186,7 @@ struct snd_usb_substream {
        u64 formats;                    /* format bitmasks (all or'ed) */
        unsigned int num_formats;               /* number of supported audio formats (list) */
        struct list_head fmt_list;      /* format list */
+       struct snd_pcm_hw_constraint_list rate_list;    /* limited rates */
        spinlock_t lock;
 
        struct snd_urb_ops ops;         /* callbacks (must be filled at init) */
@@ -253,7 +254,7 @@ static int prepare_capture_sync_urb(struct snd_usb_substream *subs,
                                    struct urb *urb)
 {
        unsigned char *cp = urb->transfer_buffer;
-       struct snd_urb_ctx *ctx = (struct snd_urb_ctx *)urb->context;
+       struct snd_urb_ctx *ctx = urb->context;
 
        urb->dev = ctx->subs->dev; /* we need to set this at each time */
        urb->iso_frame_desc[0].length = 3;
@@ -275,7 +276,7 @@ static int prepare_capture_sync_urb_hs(struct snd_usb_substream *subs,
                                       struct urb *urb)
 {
        unsigned char *cp = urb->transfer_buffer;
-       struct snd_urb_ctx *ctx = (struct snd_urb_ctx *)urb->context;
+       struct snd_urb_ctx *ctx = urb->context;
 
        urb->dev = ctx->subs->dev; /* we need to set this at each time */
        urb->iso_frame_desc[0].length = 4;
@@ -313,7 +314,7 @@ static int prepare_capture_urb(struct snd_usb_substream *subs,
                               struct urb *urb)
 {
        int i, offs;
-       struct snd_urb_ctx *ctx = (struct snd_urb_ctx *)urb->context;
+       struct snd_urb_ctx *ctx = urb->context;
 
        offs = 0;
        urb->dev = ctx->subs->dev; /* we need to set this at each time */
@@ -391,6 +392,16 @@ static int retire_capture_urb(struct snd_usb_substream *subs,
        return 0;
 }
 
+/*
+ * Process after capture complete when paused.  Nothing to do.
+ */
+static int retire_paused_capture_urb(struct snd_usb_substream *subs,
+                                    struct snd_pcm_runtime *runtime,
+                                    struct urb *urb)
+{
+       return 0;
+}
+
 
 /*
  * prepare urb for full speed playback sync pipe
@@ -402,7 +413,7 @@ static int prepare_playback_sync_urb(struct snd_usb_substream *subs,
                                     struct snd_pcm_runtime *runtime,
                                     struct urb *urb)
 {
-       struct snd_urb_ctx *ctx = (struct snd_urb_ctx *)urb->context;
+       struct snd_urb_ctx *ctx = urb->context;
 
        urb->dev = ctx->subs->dev; /* we need to set this at each time */
        urb->iso_frame_desc[0].length = 3;
@@ -420,7 +431,7 @@ static int prepare_playback_sync_urb_hs(struct snd_usb_substream *subs,
                                        struct snd_pcm_runtime *runtime,
                                        struct urb *urb)
 {
-       struct snd_urb_ctx *ctx = (struct snd_urb_ctx *)urb->context;
+       struct snd_urb_ctx *ctx = urb->context;
 
        urb->dev = ctx->subs->dev; /* we need to set this at each time */
        urb->iso_frame_desc[0].length = 4;
@@ -493,13 +504,13 @@ static int snd_usb_audio_next_packet_size(struct snd_usb_substream *subs)
 }
 
 /*
- * Prepare urb for streaming before playback starts.
+ * Prepare urb for streaming before playback starts or when paused.
  *
- * We don't yet have data, so we send a frame of silence.
+ * We don't have any data, so we send a frame of silence.
  */
-static int prepare_startup_playback_urb(struct snd_usb_substream *subs,
-                                       struct snd_pcm_runtime *runtime,
-                                       struct urb *urb)
+static int prepare_nodata_playback_urb(struct snd_usb_substream *subs,
+                                      struct snd_pcm_runtime *runtime,
+                                      struct urb *urb)
 {
        unsigned int i, offs, counts;
        struct snd_urb_ctx *ctx = urb->context;
@@ -537,7 +548,7 @@ static int prepare_playback_urb(struct snd_usb_substream *subs,
        unsigned int counts;
        unsigned long flags;
        int period_elapsed = 0;
-       struct snd_urb_ctx *ctx = (struct snd_urb_ctx *)urb->context;
+       struct snd_urb_ctx *ctx = urb->context;
 
        stride = runtime->frame_bits >> 3;
 
@@ -622,7 +633,7 @@ static int retire_playback_urb(struct snd_usb_substream *subs,
  */
 static struct snd_urb_ops audio_urb_ops[2] = {
        {
-               .prepare =      prepare_startup_playback_urb,
+               .prepare =      prepare_nodata_playback_urb,
                .retire =       retire_playback_urb,
                .prepare_sync = prepare_playback_sync_urb,
                .retire_sync =  retire_playback_sync_urb,
@@ -637,7 +648,7 @@ static struct snd_urb_ops audio_urb_ops[2] = {
 
 static struct snd_urb_ops audio_urb_ops_high_speed[2] = {
        {
-               .prepare =      prepare_startup_playback_urb,
+               .prepare =      prepare_nodata_playback_urb,
                .retire =       retire_playback_urb,
                .prepare_sync = prepare_playback_sync_urb_hs,
                .retire_sync =  retire_playback_sync_urb_hs,
@@ -655,7 +666,7 @@ static struct snd_urb_ops audio_urb_ops_high_speed[2] = {
  */
 static void snd_complete_urb(struct urb *urb)
 {
-       struct snd_urb_ctx *ctx = (struct snd_urb_ctx *)urb->context;
+       struct snd_urb_ctx *ctx = urb->context;
        struct snd_usb_substream *subs = ctx->subs;
        struct snd_pcm_substream *substream = ctx->subs->pcm_substream;
        int err = 0;
@@ -678,7 +689,7 @@ static void snd_complete_urb(struct urb *urb)
  */
 static void snd_complete_sync_urb(struct urb *urb)
 {
-       struct snd_urb_ctx *ctx = (struct snd_urb_ctx *)urb->context;
+       struct snd_urb_ctx *ctx = urb->context;
        struct snd_usb_substream *subs = ctx->subs;
        struct snd_pcm_substream *substream = ctx->subs->pcm_substream;
        int err = 0;
@@ -925,10 +936,14 @@ static int snd_usb_pcm_playback_trigger(struct snd_pcm_substream *substream,
 
        switch (cmd) {
        case SNDRV_PCM_TRIGGER_START:
+       case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
                subs->ops.prepare = prepare_playback_urb;
                return 0;
        case SNDRV_PCM_TRIGGER_STOP:
                return deactivate_urbs(subs, 0, 0);
+       case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
+               subs->ops.prepare = prepare_nodata_playback_urb;
+               return 0;
        default:
                return -EINVAL;
        }
@@ -944,9 +959,16 @@ static int snd_usb_pcm_capture_trigger(struct snd_pcm_substream *substream,
 
        switch (cmd) {
        case SNDRV_PCM_TRIGGER_START:
+               subs->ops.retire = retire_capture_urb;
                return start_urbs(subs, substream->runtime);
        case SNDRV_PCM_TRIGGER_STOP:
                return deactivate_urbs(subs, 0, 0);
+       case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
+               subs->ops.retire = retire_paused_capture_urb;
+               return 0;
+       case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
+               subs->ops.retire = retire_capture_urb;
+               return 0;
        default:
                return -EINVAL;
        }
@@ -1408,7 +1430,7 @@ static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt)
 static int snd_usb_hw_params(struct snd_pcm_substream *substream,
                             struct snd_pcm_hw_params *hw_params)
 {
-       struct snd_usb_substream *subs = (struct snd_usb_substream *)substream->runtime->private_data;
+       struct snd_usb_substream *subs = substream->runtime->private_data;
        struct audioformat *fmt;
        unsigned int channels, rate, format;
        int ret, changed;
@@ -1464,7 +1486,7 @@ static int snd_usb_hw_params(struct snd_pcm_substream *substream,
  */
 static int snd_usb_hw_free(struct snd_pcm_substream *substream)
 {
-       struct snd_usb_substream *subs = (struct snd_usb_substream *)substream->runtime->private_data;
+       struct snd_usb_substream *subs = substream->runtime->private_data;
 
        subs->cur_audiofmt = NULL;
        subs->cur_rate = 0;
@@ -1505,33 +1527,20 @@ static int snd_usb_pcm_prepare(struct snd_pcm_substream *substream)
        /* for playback, submit the URBs now; otherwise, the first hwptr_done
         * updates for all URBs would happen at the same time when starting */
        if (subs->direction == SNDRV_PCM_STREAM_PLAYBACK) {
-               subs->ops.prepare = prepare_startup_playback_urb;
+               subs->ops.prepare = prepare_nodata_playback_urb;
                return start_urbs(subs, runtime);
        } else
                return 0;
 }
 
-static struct snd_pcm_hardware snd_usb_playback =
+static struct snd_pcm_hardware snd_usb_hardware =
 {
        .info =                 SNDRV_PCM_INFO_MMAP |
                                SNDRV_PCM_INFO_MMAP_VALID |
                                SNDRV_PCM_INFO_BATCH |
                                SNDRV_PCM_INFO_INTERLEAVED |
-                               SNDRV_PCM_INFO_BLOCK_TRANSFER,
-       .buffer_bytes_max =     1024 * 1024,
-       .period_bytes_min =     64,
-       .period_bytes_max =     512 * 1024,
-       .periods_min =          2,
-       .periods_max =          1024,
-};
-
-static struct snd_pcm_hardware snd_usb_capture =
-{
-       .info =                 SNDRV_PCM_INFO_MMAP |
-                               SNDRV_PCM_INFO_MMAP_VALID |
-                               SNDRV_PCM_INFO_BATCH |
-                               SNDRV_PCM_INFO_INTERLEAVED |
-                               SNDRV_PCM_INFO_BLOCK_TRANSFER,
+                               SNDRV_PCM_INFO_BLOCK_TRANSFER |
+                               SNDRV_PCM_INFO_PAUSE,
        .buffer_bytes_max =     1024 * 1024,
        .period_bytes_min =     64,
        .period_bytes_max =     512 * 1024,
@@ -1810,28 +1819,33 @@ static int check_hw_params_convention(struct snd_usb_substream *subs)
 static int snd_usb_pcm_check_knot(struct snd_pcm_runtime *runtime,
                                  struct snd_usb_substream *subs)
 {
-       struct list_head *p;
-       struct snd_pcm_hw_constraint_list constraints_rates;
+       struct audioformat *fp;
+       int count = 0, needs_knot = 0;
        int err;
 
-       list_for_each(p, &subs->fmt_list) {
-               struct audioformat *fp;
-               fp = list_entry(p, struct audioformat, list);
-
-               if (!fp->needs_knot)
-                       continue;
-
-               constraints_rates.count = fp->nr_rates;
-               constraints_rates.list = fp->rate_table;
-               constraints_rates.mask = 0;
-
-               err = snd_pcm_hw_constraint_list(runtime, 0,
-                       SNDRV_PCM_HW_PARAM_RATE,
-                       &constraints_rates);
-
-               if (err < 0)
-                       return err;
+       list_for_each_entry(fp, &subs->fmt_list, list) {
+               if (fp->rates & SNDRV_PCM_RATE_CONTINUOUS)
+                       return 0;
+               count += fp->nr_rates;
+               if (fp->needs_knot)
+                       needs_knot = 1;
        }
+       if (!needs_knot)
+               return 0;
+
+       subs->rate_list.count = count;
+       subs->rate_list.list = kmalloc(sizeof(int) * count, GFP_KERNEL);
+       subs->rate_list.mask = 0;
+       count = 0;
+       list_for_each_entry(fp, &subs->fmt_list, list) {
+               int i;
+               for (i = 0; i < fp->nr_rates; i++)
+                       subs->rate_list.list[count++] = fp->rate_table[i];
+       }
+       err = snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
+                                        &subs->rate_list);
+       if (err < 0)
+               return err;
 
        return 0;
 }
@@ -1904,8 +1918,7 @@ static int setup_hw_info(struct snd_pcm_runtime *runtime, struct snd_usb_substre
        return 0;
 }
 
-static int snd_usb_pcm_open(struct snd_pcm_substream *substream, int direction,
-                           struct snd_pcm_hardware *hw)
+static int snd_usb_pcm_open(struct snd_pcm_substream *substream, int direction)
 {
        struct snd_usb_stream *as = snd_pcm_substream_chip(substream);
        struct snd_pcm_runtime *runtime = substream->runtime;
@@ -1913,7 +1926,7 @@ static int snd_usb_pcm_open(struct snd_pcm_substream *substream, int direction,
 
        subs->interface = -1;
        subs->format = 0;
-       runtime->hw = *hw;
+       runtime->hw = snd_usb_hardware;
        runtime->private_data = subs;
        subs->pcm_substream = substream;
        return setup_hw_info(runtime, subs);
@@ -1934,7 +1947,7 @@ static int snd_usb_pcm_close(struct snd_pcm_substream *substream, int direction)
 
 static int snd_usb_playback_open(struct snd_pcm_substream *substream)
 {
-       return snd_usb_pcm_open(substream, SNDRV_PCM_STREAM_PLAYBACK, &snd_usb_playback);
+       return snd_usb_pcm_open(substream, SNDRV_PCM_STREAM_PLAYBACK);
 }
 
 static int snd_usb_playback_close(struct snd_pcm_substream *substream)
@@ -1944,7 +1957,7 @@ static int snd_usb_playback_close(struct snd_pcm_substream *substream)
 
 static int snd_usb_capture_open(struct snd_pcm_substream *substream)
 {
-       return snd_usb_pcm_open(substream, SNDRV_PCM_STREAM_CAPTURE, &snd_usb_capture);
+       return snd_usb_pcm_open(substream, SNDRV_PCM_STREAM_CAPTURE);
 }
 
 static int snd_usb_capture_close(struct snd_pcm_substream *substream)
@@ -2231,6 +2244,7 @@ static void free_substream(struct snd_usb_substream *subs)
                kfree(fp->rate_table);
                kfree(fp);
        }
+       kfree(subs->rate_list.list);
 }
 
 
@@ -2456,6 +2470,7 @@ static int parse_audio_format_rates(struct snd_usb_audio *chip, struct audioform
                 * build the rate table and bitmap flags
                 */
                int r, idx, c;
+               unsigned int nonzero_rates = 0;
                /* this table corresponds to the SNDRV_PCM_RATE_XXX bit */
                static unsigned int conv_rates[] = {
                        5512, 8000, 11025, 16000, 22050, 32000, 44100, 48000,
@@ -2478,6 +2493,7 @@ static int parse_audio_format_rates(struct snd_usb_audio *chip, struct audioform
                            fp->altsetting == 5 && fp->maxpacksize == 392)
                                rate = 96000;
                        fp->rate_table[r] = rate;
+                       nonzero_rates |= rate;
                        if (rate < fp->rate_min)
                                fp->rate_min = rate;
                        else if (rate > fp->rate_max)
@@ -2493,6 +2509,10 @@ static int parse_audio_format_rates(struct snd_usb_audio *chip, struct audioform
                        if (!found)
                                fp->needs_knot = 1;
                }
+               if (!nonzero_rates) {
+                       hwc_debug("All rates were zero. Skipping format!\n");
+                       return -1;
+               }
                if (fp->needs_knot)
                        fp->rates |= SNDRV_PCM_RATE_KNOT;
        } else {
@@ -3057,6 +3077,58 @@ static int create_ua1000_quirk(struct snd_usb_audio *chip,
        return 0;
 }
 
+/*
+ * Create a stream for an Edirol UA-101 interface.
+ * Copy, paste and modify from Edirol UA-1000
+ */
+static int create_ua101_quirk(struct snd_usb_audio *chip,
+                              struct usb_interface *iface,
+                              const struct snd_usb_audio_quirk *quirk)
+{
+       static const struct audioformat ua101_format = {
+               .format = SNDRV_PCM_FORMAT_S32_LE,
+               .fmt_type = USB_FORMAT_TYPE_I,
+               .altsetting = 1,
+               .altset_idx = 1,
+               .attributes = 0,
+               .rates = SNDRV_PCM_RATE_CONTINUOUS,
+       };
+       struct usb_host_interface *alts;
+       struct usb_interface_descriptor *altsd;
+       struct audioformat *fp;
+       int stream, err;
+
+       if (iface->num_altsetting != 2)
+               return -ENXIO;
+       alts = &iface->altsetting[1];
+       altsd = get_iface_desc(alts);
+       if (alts->extralen != 18 || alts->extra[1] != USB_DT_CS_INTERFACE ||
+           altsd->bNumEndpoints != 1)
+               return -ENXIO;
+
+       fp = kmemdup(&ua101_format, sizeof(*fp), GFP_KERNEL);
+       if (!fp)
+               return -ENOMEM;
+
+       fp->channels = alts->extra[11];
+       fp->iface = altsd->bInterfaceNumber;
+       fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress;
+       fp->ep_attr = get_endpoint(alts, 0)->bmAttributes;
+       fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize);
+       fp->rate_max = fp->rate_min = combine_triple(&alts->extra[15]);
+
+       stream = (fp->endpoint & USB_DIR_IN)
+               ? SNDRV_PCM_STREAM_CAPTURE : SNDRV_PCM_STREAM_PLAYBACK;
+       err = add_audio_endpoint(chip, stream, fp);
+       if (err < 0) {
+               kfree(fp);
+               return err;
+       }
+       /* FIXME: playback must be synchronized to capture */
+       usb_set_interface(chip->dev, fp->iface, 0);
+       return 0;
+}
+
 static int snd_usb_create_quirk(struct snd_usb_audio *chip,
                                struct usb_interface *iface,
                                const struct snd_usb_audio_quirk *quirk);
@@ -3238,6 +3310,7 @@ static int snd_usb_create_quirk(struct snd_usb_audio *chip,
                [QUIRK_AUDIO_FIXED_ENDPOINT] = create_fixed_stream_quirk,
                [QUIRK_AUDIO_EDIROL_UA700_UA25] = create_ua700_ua25_quirk,
                [QUIRK_AUDIO_EDIROL_UA1000] = create_ua1000_quirk,
+               [QUIRK_AUDIO_EDIROL_UA101] = create_ua101_quirk,
        };
 
        if (quirk->type < QUIRK_TYPE_COUNT) {
index 0f4b2b8541d6a54e1d2deeb6bf6e49324bba9933..2272f45a18674320977d5314a6608b4449a27312 100644 (file)
@@ -159,6 +159,7 @@ enum quirk_type {
        QUIRK_AUDIO_FIXED_ENDPOINT,
        QUIRK_AUDIO_EDIROL_UA700_UA25,
        QUIRK_AUDIO_EDIROL_UA1000,
+       QUIRK_AUDIO_EDIROL_UA101,
 
        QUIRK_TYPE_COUNT
 };
index a7e9563a01df48b792db45b0b4373d84bc2cb3b2..25b4ab4f61e7299d1eda8dc84b5eb1b47c2f17fd 100644 (file)
@@ -1098,7 +1098,37 @@ YAMAHA_DEVICE(0x7010, "UB99"),
                }
        }
 },
-       /* TODO: add Edirol UA-101 support */
+/* Roland UA-101 in High-Speed Mode only */
+{
+       USB_DEVICE(0x0582, 0x007d),
+       .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) {
+               .vendor_name = "Roland",
+               .product_name = "UA-101",
+               .ifnum = QUIRK_ANY_INTERFACE,
+               .type = QUIRK_COMPOSITE,
+               .data = (const struct snd_usb_audio_quirk[]) {
+                       {
+                               .ifnum = 0,
+                               .type = QUIRK_AUDIO_EDIROL_UA101
+                       },
+                       {
+                               .ifnum = 1,
+                               .type = QUIRK_AUDIO_EDIROL_UA101
+                       },
+                       {
+                               .ifnum = 2,
+                               .type = QUIRK_MIDI_FIXED_ENDPOINT,
+                               .data = & (const struct snd_usb_midi_endpoint_info) {
+                                       .out_cables = 0x0001,
+                                       .in_cables  = 0x0001
+                               }
+                       },
+                       {
+                               .ifnum = -1
+                       }
+               }
+       }
+},
 {
        /* has ID 0x0081 when not in "Advanced Driver" mode */
        USB_DEVICE(0x0582, 0x0080),
index 382702ad663bea2fd72ba169556c147693a92b4a..201f27f8cbaf1c6b266b68f3a915c3edce50b67b 100644 (file)
@@ -7,7 +7,7 @@ PHONY += klibcdirs
 
 
 # Generate builtin.o based on initramfs_data.o
-obj-y := initramfs_data.o
+obj-$(CONFIG_BLK_DEV_INITRD) := initramfs_data.o
 
 # initramfs_data.o contains the initramfs_data.cpio.gz image.
 # The image is included using .incbin, a dependency which is not
index 83acd6cc0b3cd70325ec383eb8fdc309918a0a98..8365db6cfe06449246ef5156a4a886d7e14fbdbc 100644 (file)
@@ -14,6 +14,7 @@
  * Original work by Jeff Garzik
  *
  * External file lists, symlink, pipe and fifo support by Thayne Harbaugh
+ * Hard link support by Luciano Rocha
  */
 
 #define xstr(s) #s
@@ -286,16 +287,19 @@ static int cpio_mknod_line(const char *line)
        return rc;
 }
 
-/* Not marked static to keep the compiler quiet, as no one uses this yet... */
 static int cpio_mkfile(const char *name, const char *location,
-                       unsigned int mode, uid_t uid, gid_t gid)
+                       unsigned int mode, uid_t uid, gid_t gid,
+                       unsigned int nlinks)
 {
        char s[256];
        char *filebuf = NULL;
        struct stat buf;
+       long size;
        int file = -1;
        int retval;
        int rc = -1;
+       int namesize;
+       int i;
 
        mode |= S_IFREG;
 
@@ -323,29 +327,41 @@ static int cpio_mkfile(const char *name, const char *location,
                goto error;
        }
 
-       sprintf(s,"%s%08X%08X%08lX%08lX%08X%08lX"
-              "%08X%08X%08X%08X%08X%08X%08X",
-               "070701",               /* magic */
-               ino++,                  /* ino */
-               mode,                   /* mode */
-               (long) uid,             /* uid */
-               (long) gid,             /* gid */
-               1,                      /* nlink */
-               (long) buf.st_mtime,    /* mtime */
-               (int) buf.st_size,      /* filesize */
-               3,                      /* major */
-               1,                      /* minor */
-               0,                      /* rmajor */
-               0,                      /* rminor */
-               (unsigned)strlen(name) + 1,/* namesize */
-               0);                     /* chksum */
-       push_hdr(s);
-       push_string(name);
-       push_pad();
+       size = 0;
+       for (i = 1; i <= nlinks; i++) {
+               /* data goes on last link */
+               if (i == nlinks) size = buf.st_size;
+
+               namesize = strlen(name) + 1;
+               sprintf(s,"%s%08X%08X%08lX%08lX%08X%08lX"
+                      "%08lX%08X%08X%08X%08X%08X%08X",
+                       "070701",               /* magic */
+                       ino,                    /* ino */
+                       mode,                   /* mode */
+                       (long) uid,             /* uid */
+                       (long) gid,             /* gid */
+                       nlinks,                 /* nlink */
+                       (long) buf.st_mtime,    /* mtime */
+                       size,                   /* filesize */
+                       3,                      /* major */
+                       1,                      /* minor */
+                       0,                      /* rmajor */
+                       0,                      /* rminor */
+                       namesize,               /* namesize */
+                       0);                     /* chksum */
+               push_hdr(s);
+               push_string(name);
+               push_pad();
+
+               if (size) {
+                       fwrite(filebuf, size, 1, stdout);
+                       offset += size;
+                       push_pad();
+               }
 
-       fwrite(filebuf, buf.st_size, 1, stdout);
-       offset += buf.st_size;
-       push_pad();
+               name += namesize;
+       }
+       ino++;
        rc = 0;
        
 error:
@@ -357,18 +373,51 @@ error:
 static int cpio_mkfile_line(const char *line)
 {
        char name[PATH_MAX + 1];
+       char *dname = NULL; /* malloc'ed buffer for hard links */
        char location[PATH_MAX + 1];
        unsigned int mode;
        int uid;
        int gid;
+       int nlinks = 1;
+       int end = 0, dname_len = 0;
        int rc = -1;
 
-       if (5 != sscanf(line, "%" str(PATH_MAX) "s %" str(PATH_MAX) "s %o %d %d", name, location, &mode, &uid, &gid)) {
+       if (5 > sscanf(line, "%" str(PATH_MAX) "s %" str(PATH_MAX)
+                               "s %o %d %d %n",
+                               name, location, &mode, &uid, &gid, &end)) {
                fprintf(stderr, "Unrecognized file format '%s'", line);
                goto fail;
        }
-       rc = cpio_mkfile(name, location, mode, uid, gid);
+       if (end && isgraph(line[end])) {
+               int len;
+               int nend;
+
+               dname = malloc(strlen(line));
+               if (!dname) {
+                       fprintf (stderr, "out of memory (%d)\n", dname_len);
+                       goto fail;
+               }
+
+               dname_len = strlen(name) + 1;
+               memcpy(dname, name, dname_len);
+
+               do {
+                       nend = 0;
+                       if (sscanf(line + end, "%" str(PATH_MAX) "s %n",
+                                       name, &nend) < 1)
+                               break;
+                       len = strlen(name) + 1;
+                       memcpy(dname + dname_len, name, len);
+                       dname_len += len;
+                       nlinks++;
+                       end += nend;
+               } while (isgraph(line[end]));
+       } else {
+               dname = name;
+       }
+       rc = cpio_mkfile(dname, location, mode, uid, gid, nlinks);
  fail:
+       if (dname_len) free(dname);
        return rc;
 }
 
@@ -381,22 +430,23 @@ void usage(const char *prog)
                "describe the files to be included in the initramfs archive:\n"
                "\n"
                "# a comment\n"
-               "file <name> <location> <mode> <uid> <gid>\n"
+               "file <name> <location> <mode> <uid> <gid> [<hard links>]\n"
                "dir <name> <mode> <uid> <gid>\n"
                "nod <name> <mode> <uid> <gid> <dev_type> <maj> <min>\n"
                "slink <name> <target> <mode> <uid> <gid>\n"
                "pipe <name> <mode> <uid> <gid>\n"
                "sock <name> <mode> <uid> <gid>\n"
                "\n"
-               "<name>      name of the file/dir/nod/etc in the archive\n"
-               "<location>  location of the file in the current filesystem\n"
-               "<target>    link target\n"
-               "<mode>      mode/permissions of the file\n"
-               "<uid>       user id (0=root)\n"
-               "<gid>       group id (0=root)\n"
-               "<dev_type>  device type (b=block, c=character)\n"
-               "<maj>       major number of nod\n"
-               "<min>       minor number of nod\n"
+               "<name>       name of the file/dir/nod/etc in the archive\n"
+               "<location>   location of the file in the current filesystem\n"
+               "<target>     link target\n"
+               "<mode>       mode/permissions of the file\n"
+               "<uid>        user id (0=root)\n"
+               "<gid>        group id (0=root)\n"
+               "<dev_type>   device type (b=block, c=character)\n"
+               "<maj>        major number of nod\n"
+               "<min>        minor number of nod\n"
+               "<hard links> space separated list of other links to file\n"
                "\n"
                "example:\n"
                "# A simple initramfs\n"